diff --git a/haas-imagej-client/src/main/java/cz/it4i/fiji/haas/ui/FXFrame.java b/haas-imagej-client/src/main/java/cz/it4i/fiji/haas/ui/FXFrame.java index 23dda8e8dc97ad23bd3788559e814c3528e21897..74f56f8125cbbe89bf6ca1d2dafd7ed56d5c8dcb 100644 --- a/haas-imagej-client/src/main/java/cz/it4i/fiji/haas/ui/FXFrame.java +++ b/haas-imagej-client/src/main/java/cz/it4i/fiji/haas/ui/FXFrame.java @@ -22,12 +22,12 @@ public abstract class FXFrame<T extends Parent&CloseableControl> extends JDialog private static Logger log = LoggerFactory.getLogger(cz.it4i.fiji.haas.ui.FXFrame.class); private static final long serialVersionUID = 1L; private JFXPanel<T> fxPanel; - + public FXFrame(Supplier<T> fxSupplier) { - this(null,fxSupplier); + this(null, fxSupplier); } - - public FXFrame(Window parent, Supplier<T> fxSupplier) { + + public FXFrame(Window parent, Supplier<T> fxSupplier){ super(parent, ModalityType.MODELESS); fxPanel = new JFXPanel<>(fxSupplier); init(); @@ -37,6 +37,17 @@ public abstract class FXFrame<T extends Parent&CloseableControl> extends JDialog } } + public JFXPanel<T> getFxPanel() { + return fxPanel; + } + + public void executeAdjustment(Runnable command) { + JavaFXRoutines.runOnFxThread(() -> { + command.run(); + }); + } + + private void init() { addWindowListener(new WindowAdapter() { @Override @@ -56,12 +67,9 @@ public abstract class FXFrame<T extends Parent&CloseableControl> extends JDialog this.setLayout(new BorderLayout()); //JScrollPane scrollPane = new JScrollPane(this.fxPanel); this.add(fxPanel, BorderLayout.CENTER); - JavaFXRoutines.runOnFxThread(() -> this.pack()); - - } - - - public JFXPanel<T> getFxPanel() { - return fxPanel; + JavaFXRoutines.runOnFxThread(() -> { + this.pack(); + SwingRoutines.centerOnScreen(this); + }); } } diff --git a/haas-imagej-client/src/main/java/cz/it4i/fiji/haas/ui/SwingRoutines.java b/haas-imagej-client/src/main/java/cz/it4i/fiji/haas/ui/SwingRoutines.java new file mode 100644 index 0000000000000000000000000000000000000000..3286e31ec960f1140de4b67d95c4cff20fd4b0d8 --- /dev/null +++ b/haas-imagej-client/src/main/java/cz/it4i/fiji/haas/ui/SwingRoutines.java @@ -0,0 +1,16 @@ +package cz.it4i.fiji.haas.ui; + +import java.awt.Component; +import java.awt.Dimension; +import java.awt.Toolkit; + +public interface SwingRoutines { + + static void centerOnScreen(Component component) { + Dimension dimension = Toolkit.getDefaultToolkit().getScreenSize(); + int x = (int) ((dimension.getWidth() - component.getWidth()) / 2); + int y = (int) ((dimension.getHeight() - component.getHeight()) / 2); + component.setLocation(x, y); + } + +} diff --git a/haas-spim-benchmark/src/main/java/cz/it4i/fiji/haas_spim_benchmark/commands/ManageSPIMBenchmark.java b/haas-spim-benchmark/src/main/java/cz/it4i/fiji/haas_spim_benchmark/commands/ManageSPIMBenchmark.java index f6e05832b6690660acc1cd696a463de5cb4f9883..d8368e00eb736aab4738351b850ae8aa5dbd7b5c 100644 --- a/haas-spim-benchmark/src/main/java/cz/it4i/fiji/haas_spim_benchmark/commands/ManageSPIMBenchmark.java +++ b/haas-spim-benchmark/src/main/java/cz/it4i/fiji/haas_spim_benchmark/commands/ManageSPIMBenchmark.java @@ -8,7 +8,6 @@ import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; -import javax.swing.JDialog; import javax.swing.WindowConstants; import org.scijava.Context; @@ -31,7 +30,7 @@ import net.imagej.ImageJ; * @author koz01 * */ -@Plugin(type = Command.class, headless = false, menuPath = "Plugins>SPIM benchmark") +@Plugin(type = Command.class, headless = false, menuPath = "Plugins>" + Constants.MENU_ITEM_NAME + ">" + Constants.SUBMENU_ITEM_NAME) public class ManageSPIMBenchmark implements Command { private static Logger log = LoggerFactory @@ -61,33 +60,35 @@ public class ManageSPIMBenchmark implements Command { @Override public void run() { try { - Path workingDirPath = Paths.get(workingDirectory.getPath()); + final Path workingDirPath = Paths.get(workingDirectory.getPath()); if (!Files.isDirectory(workingDirPath)) { Files.createDirectories(workingDirPath); } - FileLock fl = new FileLock(workingDirPath.resolve(LOCK_FILE_NAME)); + final FileLock fl = new FileLock(workingDirPath.resolve(LOCK_FILE_NAME)); if(!fl.tryLock()) { uiService.showDialog("Working directory is already used by someone else", MessageType.ERROR_MESSAGE); return; } try { - JDialog dialog = new BenchmarkSPIMWindow(null, + final BenchmarkSPIMWindow dialog = new BenchmarkSPIMWindow(null, new BenchmarkSPIMParametersImpl(userName, password, Constants.PHONE, email, workingDirPath)); - dialog.setTitle("SPIM workflow computation manager"); - dialog.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); - dialog.addWindowListener(new WindowAdapter() { - @Override - public void windowClosing(WindowEvent e) { - super.windowClosing(e); - fl.close(); - } + dialog.executeAdjustment(() -> { + dialog.setTitle(Constants.MENU_ITEM_NAME + " " + Constants.SUBMENU_ITEM_NAME); + dialog.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); + dialog.addWindowListener(new WindowAdapter() { + @Override + public void windowClosing(final WindowEvent e) { + super.windowClosing(e); + fl.close(); + } + }); + dialog.setVisible(true); }); - dialog.setVisible(true); - } catch(IOException e) { + } catch(final IOException e) { fl.close(); throw e; } - } catch (IOException e) { + } catch (final IOException e) { log.error(e.getMessage(), e); } diff --git a/haas-spim-benchmark/src/main/java/cz/it4i/fiji/haas_spim_benchmark/core/Constants.java b/haas-spim-benchmark/src/main/java/cz/it4i/fiji/haas_spim_benchmark/core/Constants.java index 79b451ac0d9901466ebfa4609d16d9a604ccb98f..970e523452759e46c2c5feeb1c64694bf56688a8 100644 --- a/haas-spim-benchmark/src/main/java/cz/it4i/fiji/haas_spim_benchmark/core/Constants.java +++ b/haas-spim-benchmark/src/main/java/cz/it4i/fiji/haas_spim_benchmark/core/Constants.java @@ -4,6 +4,10 @@ import java.util.LinkedHashMap; import java.util.Map; public interface Constants { + + String MENU_ITEM_NAME = "Multiview Reconstruction"; + String SUBMENU_ITEM_NAME = "Remote Workflow Manager"; + String PHONE = "123456789"; int HAAS_UPDATE_TIMEOUT = 30000; short UI_TO_HAAS_FREQUENCY_UPDATE_RATIO = 10; diff --git a/haas-spim-benchmark/src/main/java/cz/it4i/fiji/haas_spim_benchmark/ui/BenchmarkSPIMControl.java b/haas-spim-benchmark/src/main/java/cz/it4i/fiji/haas_spim_benchmark/ui/BenchmarkSPIMControl.java index 949e68fc749be194ca1239e71954a7f245d2b2f9..5b15ebee78558324c3945a99ea1bde21057095d3 100644 --- a/haas-spim-benchmark/src/main/java/cz/it4i/fiji/haas_spim_benchmark/ui/BenchmarkSPIMControl.java +++ b/haas-spim-benchmark/src/main/java/cz/it4i/fiji/haas_spim_benchmark/ui/BenchmarkSPIMControl.java @@ -140,12 +140,9 @@ public class BenchmarkSPIMControl extends BorderPane implements CloseableControl menu.addItem("Job dashboard", job -> openJobDetailsWindow(job.getValue()), job -> JavaFXRoutines.notNullValue(job, j -> true)); - - menu.addItem("Open working directory", j -> open(j.getValue()), x -> JavaFXRoutines.notNullValue(x, j -> true)); - + menu.addItem("Open job subdirectory", j -> open(j.getValue()), x -> JavaFXRoutines.notNullValue(x, j -> true)); menu.addItem("Open in BigDataViewer", j -> openBigDataViewer(j.getValue()), x -> JavaFXRoutines.notNullValue(x, j -> true)); - menu.addSeparator(); menu.addItem("Upload data", job -> executeWSCallAsync("Uploading data", p -> job.getValue().startUpload()), @@ -341,14 +338,14 @@ public class BenchmarkSPIMControl extends BorderPane implements CloseableControl JavaFXRoutines.setCellValueFactory(jobs, index, mapper); ((TableColumn<ObservableBenchmarkJob, CompletableFuture<String>>) jobs.getColumns().get(index)) .setCellFactory(column -> new TableCellAdapter<ObservableBenchmarkJob, CompletableFuture<String>> // - (// - new P_TableCellUpdaterDecoratorWithToolTip<>// (// - new FutureValueUpdater<ObservableBenchmarkJob, String, CompletableFuture<String>>// + new P_TableCellUpdaterDecoratorWithToolTip<>// (// - new StringValueUpdater<ObservableBenchmarkJob>(), executorServiceFX// - ), // - "Doubleclick to open Dashboard"))); + new FutureValueUpdater<ObservableBenchmarkJob, String, CompletableFuture<String>>// + (// + new StringValueUpdater<ObservableBenchmarkJob>(), executorServiceFX// + ), // + "Doubleclick to open Dashboard"))); } private void openJobDetailsWindow(BenchmarkJob job) { @@ -363,18 +360,19 @@ public class BenchmarkSPIMControl extends BorderPane implements CloseableControl Path resultXML = job.getResultXML(); Path localPathToResultXML = job.getOutputDirectory().resolve(resultXML); String openFile; - if(Files.exists(localPathToResultXML)) { + if (Files.exists(localPathToResultXML)) { openFile = localPathToResultXML.toString(); - } else { + } else { openFile = startBDSForData(job, resultXML); } try { - BigDataViewer.open( openFile, "Result of job " + job.getId(), new ProgressWriterConsole() , ViewerOptions.options() ); + BigDataViewer.open(openFile, "Result of job " + job.getId(), new ProgressWriterConsole(), + ViewerOptions.options()); } catch (SpimDataException e) { log.error(e.getMessage(), e); } } - + private String startBDSForData(BenchmarkJob job, Path resultXML) { throw new UnsupportedOperationException("File " + resultXML + " was not found in " + job.getOutputDirectory() + " and remote BigDataServer is not implemented yet."); diff --git a/haas-spim-benchmark/src/main/java/cz/it4i/fiji/haas_spim_benchmark/ui/BenchmarkSPIMWindow.java b/haas-spim-benchmark/src/main/java/cz/it4i/fiji/haas_spim_benchmark/ui/BenchmarkSPIMWindow.java index 840e058eb57ff7e768c203b5ee0d00ebbc6761eb..7f55466237db8f87121851fbc260d711de489346 100644 --- a/haas-spim-benchmark/src/main/java/cz/it4i/fiji/haas_spim_benchmark/ui/BenchmarkSPIMWindow.java +++ b/haas-spim-benchmark/src/main/java/cz/it4i/fiji/haas_spim_benchmark/ui/BenchmarkSPIMWindow.java @@ -22,5 +22,4 @@ public class BenchmarkSPIMWindow extends FXFrame<BenchmarkSPIMControl>{ }); } - } diff --git a/haas-spim-benchmark/src/main/java/cz/it4i/fiji/haas_spim_benchmark/ui/SPIMPipelineProgressViewWindow.java b/haas-spim-benchmark/src/main/java/cz/it4i/fiji/haas_spim_benchmark/ui/SPIMPipelineProgressViewWindow.java deleted file mode 100644 index 4237bab53e267aad7bb88b753493c9361e507e43..0000000000000000000000000000000000000000 --- a/haas-spim-benchmark/src/main/java/cz/it4i/fiji/haas_spim_benchmark/ui/SPIMPipelineProgressViewWindow.java +++ /dev/null @@ -1,19 +0,0 @@ -package cz.it4i.fiji.haas_spim_benchmark.ui; - -import java.awt.Window; -import java.io.IOException; - -import cz.it4i.fiji.haas.ui.FXFrame; -import cz.it4i.fiji.haas_spim_benchmark.core.BenchmarkJobManager.BenchmarkJob; - -public class SPIMPipelineProgressViewWindow extends FXFrame<SPIMPipelineProgressViewController> { - - private static final long serialVersionUID = 1L; - - public SPIMPipelineProgressViewWindow(Window applicationFrame,BenchmarkJob job) throws IOException { - super(applicationFrame,()->new SPIMPipelineProgressViewController(job)); - - } - - -} diff --git a/haas-spim-benchmark/src/main/resources/cz/it4i/fiji/haas_spim_benchmark/ui/NewJobView.fxml b/haas-spim-benchmark/src/main/resources/cz/it4i/fiji/haas_spim_benchmark/ui/NewJobView.fxml index c111184733fda0fd5c56233790f8fcb6f9980516..ef88f5a576d9a888b9d3e1869b3eb7526967da14 100644 --- a/haas-spim-benchmark/src/main/resources/cz/it4i/fiji/haas_spim_benchmark/ui/NewJobView.fxml +++ b/haas-spim-benchmark/src/main/resources/cz/it4i/fiji/haas_spim_benchmark/ui/NewJobView.fxml @@ -36,10 +36,10 @@ </RadioButton> <RadioButton maxHeight="1.7976931348623157E308" mnemonicParsing="false" toggleGroup="$tg_inputDataLocation"> <graphic> - <Label maxHeight="1.7976931348623157E308" text="Job working directory" /> + <Label maxHeight="1.7976931348623157E308" text="Job subdirectory" /> </graphic> <tooltip> - <Tooltip text="Job working directory will be used as location for input data. Data and config.yaml will be needed to copy into it." /> + <Tooltip text="Local job subdirectory will be used as location for input data. Data and config.yaml will be needed to copy into it." /> </tooltip> </RadioButton> <RadioButton fx:id="rb_ownInput" mnemonicParsing="false" toggleGroup="$tg_inputDataLocation"> @@ -74,7 +74,7 @@ <ToggleGroup fx:id="tg_outputDataLocation" /> </toggleGroup> <graphic> - <Label maxHeight="1.7976931348623157E308" text="Job working directory" /> + <Label maxHeight="1.7976931348623157E308" text="Job subdirectory" /> </graphic> </RadioButton> </children>