Skip to content
Snippets Groups Projects
Commit b81619af authored by Jan Kožusznik's avatar Jan Kožusznik
Browse files

Merge branch 'master'

Conflicts:
	haas-spim-benchmark/src/main/java/cz/it4i/fiji/haas_spim_benchmark/ui/BenchmarkSPIMControl.java
parents 36335ee6 2ab025d5
Branches
Tags
No related merge requests found
Showing with 71 additions and 64 deletions
......@@ -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);
});
}
}
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);
}
}
......@@ -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);
}
......
......@@ -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;
......
......@@ -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.");
......
......@@ -22,5 +22,4 @@ public class BenchmarkSPIMWindow extends FXFrame<BenchmarkSPIMControl>{
});
}
}
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));
}
}
......@@ -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>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment