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

Merge branch 'iss1091'

parents 597620c2 fb05d762
No related branches found
No related tags found
No related merge requests found
Showing
with 233 additions and 31 deletions
...@@ -398,6 +398,10 @@ public class Job { ...@@ -398,6 +398,10 @@ public class Job {
return inputDirectory; return inputDirectory;
} }
public Path getOutputDirectory() {
return outputDirectory;
}
private void storeInputOutputDirectory() { private void storeInputOutputDirectory() {
if (inputDirectory == null) { if (inputDirectory == null) {
useDemoData = true; useDemoData = true;
......
package cz.it4i.fiji.haas.ui;
import java.awt.Desktop;
import java.io.IOException;
import java.nio.file.Path;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public interface ShellRoutines {
public static final Logger log = LoggerFactory.getLogger(cz.it4i.fiji.haas.ui.ShellRoutines.class);
public static void openDirectoryInBrowser(Path directory) {
Desktop desktop = Desktop.getDesktop();
try {
desktop.open(directory.toFile());
} catch (IOException e) {
log.error(e.getMessage(), e);
}
}
}
...@@ -267,6 +267,10 @@ public class BenchmarkJobManager implements Closeable { ...@@ -267,6 +267,10 @@ public class BenchmarkJobManager implements Closeable {
return job.getInputDirectory(); return job.getInputDirectory();
} }
public Path getOutputDirectory() {
return job.getOutputDirectory();
}
private ProgressNotifier convertTo(Progress progress) { private ProgressNotifier convertTo(Progress progress) {
return progress == null ? null : new P_ProgressNotifierAdapter(progress); return progress == null ? null : new P_ProgressNotifierAdapter(progress);
} }
......
...@@ -2,7 +2,6 @@ package cz.it4i.fiji.haas_spim_benchmark.ui; ...@@ -2,7 +2,6 @@ package cz.it4i.fiji.haas_spim_benchmark.ui;
import static cz.it4i.fiji.haas_spim_benchmark.core.Constants.CONFIG_YAML; import static cz.it4i.fiji.haas_spim_benchmark.core.Constants.CONFIG_YAML;
import java.awt.Desktop;
import java.awt.Window; import java.awt.Window;
import java.io.IOException; import java.io.IOException;
import java.nio.file.Files; import java.nio.file.Files;
...@@ -33,6 +32,7 @@ import cz.it4i.fiji.haas.ui.InitiableControl; ...@@ -33,6 +32,7 @@ import cz.it4i.fiji.haas.ui.InitiableControl;
import cz.it4i.fiji.haas.ui.JavaFXRoutines; import cz.it4i.fiji.haas.ui.JavaFXRoutines;
import cz.it4i.fiji.haas.ui.ModalDialogs; import cz.it4i.fiji.haas.ui.ModalDialogs;
import cz.it4i.fiji.haas.ui.ProgressDialog; import cz.it4i.fiji.haas.ui.ProgressDialog;
import cz.it4i.fiji.haas.ui.ShellRoutines;
import cz.it4i.fiji.haas.ui.TableViewContextMenu; import cz.it4i.fiji.haas.ui.TableViewContextMenu;
import cz.it4i.fiji.haas_java_client.JobState; import cz.it4i.fiji.haas_java_client.JobState;
import cz.it4i.fiji.haas_java_client.UploadingFile; import cz.it4i.fiji.haas_java_client.UploadingFile;
...@@ -54,7 +54,7 @@ import javafx.scene.layout.Region; ...@@ -54,7 +54,7 @@ import javafx.scene.layout.Region;
import net.imagej.updater.util.Progress; import net.imagej.updater.util.Progress;
//FIXME: fix Exception during context menu request on task with N/A state //FIXME: fix Exception during context menu request on task with N/A state
public class BenchmarkSPIMController extends BorderPane implements CloseableControl, InitiableControl { public class BenchmarkSPIMControl extends BorderPane implements CloseableControl, InitiableControl {
@FXML @FXML
private TableView<ObservableBenchmarkJob> jobs; private TableView<ObservableBenchmarkJob> jobs;
...@@ -76,9 +76,9 @@ public class BenchmarkSPIMController extends BorderPane implements CloseableCont ...@@ -76,9 +76,9 @@ public class BenchmarkSPIMController extends BorderPane implements CloseableCont
private ObservableBenchmarkJobRegistry registry; private ObservableBenchmarkJobRegistry registry;
private static Logger log = LoggerFactory private static Logger log = LoggerFactory
.getLogger(cz.it4i.fiji.haas_spim_benchmark.ui.BenchmarkSPIMController.class); .getLogger(cz.it4i.fiji.haas_spim_benchmark.ui.BenchmarkSPIMControl.class);
public BenchmarkSPIMController(BenchmarkJobManager manager) { public BenchmarkSPIMControl(BenchmarkJobManager manager) {
this.manager = manager; this.manager = manager;
JavaFXRoutines.initRootAndController("BenchmarkSPIM.fxml", this); JavaFXRoutines.initRootAndController("BenchmarkSPIM.fxml", this);
...@@ -132,8 +132,7 @@ public class BenchmarkSPIMController extends BorderPane implements CloseableCont ...@@ -132,8 +132,7 @@ public class BenchmarkSPIMController extends BorderPane implements CloseableCont
log.error(e.getMessage(), e); log.error(e.getMessage(), e);
} }
}, job -> JavaFXRoutines.notNullValue(job, }, job -> JavaFXRoutines.notNullValue(job,
j -> j.getState() == JobState.Running || j.getState() == JobState.Finished j -> true));
|| j.getState() == JobState.Failed || j.getState() == JobState.Canceled));
menu.addItem("Upload data", job -> executeWSCallAsync("Uploading data", p -> job.getValue().startUpload()), menu.addItem("Upload data", job -> executeWSCallAsync("Uploading data", p -> job.getValue().startUpload()),
job -> executeWSCallAsync("Stop uploading data", p -> job.getValue().stopUpload()), job -> executeWSCallAsync("Stop uploading data", p -> job.getValue().stopUpload()),
...@@ -226,12 +225,7 @@ public class BenchmarkSPIMController extends BorderPane implements CloseableCont ...@@ -226,12 +225,7 @@ public class BenchmarkSPIMController extends BorderPane implements CloseableCont
private void open(BenchmarkJob j) { private void open(BenchmarkJob j) {
executorServiceUI.execute(() -> { executorServiceUI.execute(() -> {
Desktop desktop = Desktop.getDesktop(); ShellRoutines.openDirectoryInBrowser(j.getDirectory());
try {
desktop.open(j.getDirectory().toFile());
} catch (IOException e) {
log.error(e.getMessage(), e);
}
}); });
} }
......
...@@ -8,14 +8,14 @@ import cz.it4i.fiji.haas_spim_benchmark.core.BenchmarkJobManager; ...@@ -8,14 +8,14 @@ import cz.it4i.fiji.haas_spim_benchmark.core.BenchmarkJobManager;
import cz.it4i.fiji.haas_spim_benchmark.core.BenchmarkSPIMParameters; import cz.it4i.fiji.haas_spim_benchmark.core.BenchmarkSPIMParameters;
public class BenchmarkSPIMWindow extends FXFrame<BenchmarkSPIMController>{ public class BenchmarkSPIMWindow extends FXFrame<BenchmarkSPIMControl>{
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
public BenchmarkSPIMWindow(Window parentWindow, BenchmarkSPIMParameters params) throws IOException { public BenchmarkSPIMWindow(Window parentWindow, BenchmarkSPIMParameters params) throws IOException {
super(parentWindow,()->{ super(parentWindow,()->{
try { try {
return new BenchmarkSPIMController(new BenchmarkJobManager(params)); return new BenchmarkSPIMControl(new BenchmarkJobManager(params));
} catch (IOException e) { } catch (IOException e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
......
package cz.it4i.fiji.haas_spim_benchmark.ui; package cz.it4i.fiji.haas_spim_benchmark.ui;
import java.awt.Window;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import cz.it4i.fiji.haas.ui.CloseableControl; import cz.it4i.fiji.haas.ui.CloseableControl;
import cz.it4i.fiji.haas.ui.InitiableControl;
import cz.it4i.fiji.haas.ui.JavaFXRoutines; import cz.it4i.fiji.haas.ui.JavaFXRoutines;
import cz.it4i.fiji.haas_java_client.JobState;
import cz.it4i.fiji.haas_java_client.SynchronizableFileType; import cz.it4i.fiji.haas_java_client.SynchronizableFileType;
import cz.it4i.fiji.haas_spim_benchmark.core.BenchmarkJobManager.BenchmarkJob; import cz.it4i.fiji.haas_spim_benchmark.core.BenchmarkJobManager.BenchmarkJob;
import cz.it4i.fiji.haas_spim_benchmark.core.Constants; import cz.it4i.fiji.haas_spim_benchmark.core.Constants;
import javafx.fxml.FXML; import javafx.fxml.FXML;
import javafx.scene.control.Tab;
import javafx.scene.control.TabPane; import javafx.scene.control.TabPane;
public class JobDetailControl extends TabPane implements CloseableControl { public class JobDetailControl extends TabPane implements CloseableControl, InitiableControl {
@SuppressWarnings("unused") @SuppressWarnings("unused")
private static Logger log = LoggerFactory.getLogger(cz.it4i.fiji.haas_spim_benchmark.ui.JobDetailControl.class); private static Logger log = LoggerFactory.getLogger(cz.it4i.fiji.haas_spim_benchmark.ui.JobDetailControl.class);
@FXML @FXML private SPIMPipelineProgressViewController progressView;
private SPIMPipelineProgressViewController progressView;
@FXML private LogViewControl errorOutput;
@FXML @FXML private LogViewControl standardOutput;
private LogViewControl errorOutput;
@FXML @FXML private JobPropertiesControl jobProperties;
private LogViewControl standardOutput;
@FXML private Tab jobPropertiesTab;
private final HaaSOutputObservableValueRegistry observableValueRegistry; private final HaaSOutputObservableValueRegistry observableValueRegistry;
private final BenchmarkJob job;
public JobDetailControl(BenchmarkJob job) { public JobDetailControl(BenchmarkJob job) {
JavaFXRoutines.initRootAndController("JobDetail.fxml", this); JavaFXRoutines.initRootAndController("JobDetail.fxml", this);
progressView.setJob(job); progressView.setJob(job);
observableValueRegistry = new HaaSOutputObservableValueRegistry(job, observableValueRegistry = new HaaSOutputObservableValueRegistry(job,
Constants.HAAS_UPDATE_TIMEOUT / Constants.UI_TO_HAAS_FREQUENCY_UPDATE_RATIO); Constants.HAAS_UPDATE_TIMEOUT / Constants.UI_TO_HAAS_FREQUENCY_UPDATE_RATIO);
errorOutput.setObservable(observableValueRegistry.createObservable(SynchronizableFileType.StandardErrorFile)); errorOutput.setObservable(observableValueRegistry.createObservable(SynchronizableFileType.StandardErrorFile));
standardOutput.setObservable(observableValueRegistry.createObservable(SynchronizableFileType.StandardOutputFile)); standardOutput
.setObservable(observableValueRegistry.createObservable(SynchronizableFileType.StandardOutputFile));
jobProperties.setJob(job);
observableValueRegistry.start(); observableValueRegistry.start();
this.job = job;
}
@Override
public void init(Window parameter) {
if (!isExecutionDetailsAvailable(job)) {
enableOnlySpecificTab(jobPropertiesTab);
}
}
private void enableOnlySpecificTab(Tab tabToLeaveEnabled) {
getTabs().stream().filter(node -> node != jobPropertiesTab).forEach(node -> node.setDisable(true));
getSelectionModel().select(jobPropertiesTab);
}
private boolean isExecutionDetailsAvailable(BenchmarkJob job) {
return job.getState() == JobState.Running || job.getState() == JobState.Finished
|| job.getState() == JobState.Failed || job.getState() == JobState.Canceled;
} }
@Override @Override
public void close() { public void close() {
observableValueRegistry.close(); observableValueRegistry.close();
progressView.close(); progressView.close();
jobProperties.close();
} }
} }
package cz.it4i.fiji.haas_spim_benchmark.ui;
import java.io.Closeable;
import java.nio.file.Path;
import java.util.Optional;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.function.Consumer;
import java.util.function.Function;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import cz.it4i.fiji.haas.ui.JavaFXRoutines;
import cz.it4i.fiji.haas.ui.ShellRoutines;
import cz.it4i.fiji.haas.ui.UpdatableObservableValue;
import cz.it4i.fiji.haas.ui.UpdatableObservableValue.UpdateStatus;
import cz.it4i.fiji.haas_spim_benchmark.core.BenchmarkJobManager.BenchmarkJob;
import javafx.beans.value.ObservableValue;
import javafx.fxml.FXML;
import javafx.scene.control.TableRow;
import javafx.scene.control.TableView;
import javafx.scene.layout.BorderPane;
public class JobPropertiesControl extends BorderPane implements Closeable{
private static final String FXML_FILE_NAME = "JobProperties.fxml";
public static final Logger log = LoggerFactory
.getLogger(cz.it4i.fiji.haas_spim_benchmark.ui.JobPropertiesControl.class);
@FXML
private TableView<ObservableValue<P_Value>> properties;
private BenchmarkJob job;
private final ExecutorService executorServiceUI;
public JobPropertiesControl() {
JavaFXRoutines.initRootAndController(FXML_FILE_NAME, this);
executorServiceUI = Executors.newSingleThreadExecutor();
initTable();
}
public void setJob(BenchmarkJob job) {
this.job = job;
fillTable();
}
@Override
public void close() {
executorServiceUI.shutdown();
}
private void initTable() {
setCellValueFactory(0, s -> s.getName());
setCellValueFactory(1, s -> s.getValueAsString());
setOnDoubleClickAction(rowData -> ShellRoutines.openDirectoryInBrowser(rowData.getPath()));
}
private void setOnDoubleClickAction(Consumer<P_Value> r) {
properties.setRowFactory( tv -> {
TableRow<ObservableValue<P_Value>> row = new TableRow<>();
row.setOnMouseClicked(event -> {
if (event.getClickCount() == 2 && (! row.isEmpty()) ) {
P_Value rowData = row.getItem().getValue();
if(rowData.isOpenAllowed()) {
executorServiceUI.execute(()->r.accept(rowData));
}
}
});
return row ;
});
}
private void fillTable() {
properties.getItems().add(new UpdatableObservableValue<JobPropertiesControl.P_Value>(
new P_Value("Input", job.getInputDirectory(), "Demo data on server"), x->UpdateStatus.NotUpdated, x->x));
properties.getItems().add(new UpdatableObservableValue<JobPropertiesControl.P_Value>(
new P_Value("Output", job.getOutputDirectory(), "N/A"), x->UpdateStatus.NotUpdated, x->x));
}
private void setCellValueFactory(int i, Function<P_Value, String> mapper) {
JavaFXRoutines.setCellValueFactory(properties, i, mapper);
}
private class P_Value {
private final String name;
private final Path path;
private final String textIfNull;
public P_Value(String name, Path path, String textIfNull) {
this.name = name;
this.path = path;
this.textIfNull = textIfNull;
}
public String getName() {
return name;
}
public String getValueAsString() {
return Optional.ofNullable(path).map(p->p.toString()).orElse(textIfNull);
}
public boolean isOpenAllowed() {
return path != null;
}
public Path getPath() {
return path;
}
}
}
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
<?import javafx.scene.layout.BorderPane?> <?import javafx.scene.layout.BorderPane?>
<?import javafx.scene.layout.HBox?> <?import javafx.scene.layout.HBox?>
<fx:root type="BorderPane" xmlns="http://javafx.com/javafx/8.0.65" xmlns:fx="http://javafx.com/fxml/1" fx:controller="cz.it4i.fiji.haas_spim_benchmark.ui.BenchmarkSPIMController"> <fx:root type="BorderPane" xmlns="http://javafx.com/javafx/8.0.65" xmlns:fx="http://javafx.com/fxml/1" fx:controller="cz.it4i.fiji.haas_spim_benchmark.ui.BenchmarkSPIMControl">
<center> <center>
<HBox> <HBox>
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
<TableView fx:id="jobs" prefHeight="400.0" prefWidth="1410.0" HBox.hgrow="ALWAYS"> <TableView fx:id="jobs" prefHeight="400.0" prefWidth="1410.0" HBox.hgrow="ALWAYS">
<columns> <columns>
<TableColumn prefWidth="70.0" text="Job Id" /> <TableColumn prefWidth="70.0" text="Job ID" />
<TableColumn prefWidth="149.0" text="Status" /> <TableColumn prefWidth="149.0" text="Status" />
<TableColumn prefWidth="230.0" text="Creation time" /> <TableColumn prefWidth="230.0" text="Creation time" />
<TableColumn prefWidth="230.0" text="Start time" /> <TableColumn prefWidth="230.0" text="Start time" />
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
<?import javafx.scene.control.TabPane?> <?import javafx.scene.control.TabPane?>
<?import javafx.scene.layout.AnchorPane?> <?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.HBox?> <?import javafx.scene.layout.HBox?>
<?import cz.it4i.fiji.haas_spim_benchmark.ui.JobPropertiesControl?>
<fx:root type="TabPane" xmlns:fx="http://javafx.com/fxml/1" <fx:root type="TabPane" xmlns:fx="http://javafx.com/fxml/1"
...@@ -36,5 +37,13 @@ ...@@ -36,5 +37,13 @@
</content> </content>
</Tab> </Tab>
<Tab closable="false" text="Job directories" fx:id="jobPropertiesTab">
<content>
<HBox>
<JobPropertiesControl fx:id="jobProperties" HBox.hgrow="ALWAYS" />
</HBox>
</content>
</Tab>
</tabs> </tabs>
</fx:root> </fx:root>
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.geometry.Insets?>
<?import javafx.scene.control.TableColumn?>
<?import javafx.scene.control.TableView?>
<?import javafx.scene.layout.BorderPane?>
<?import javafx.scene.layout.HBox?>
<fx:root type="BorderPane" xmlns="http://javafx.com/javafx/8.0.65" xmlns:fx="http://javafx.com/fxml/1" fx:controller="cz.it4i.fiji.haas_spim_benchmark.ui.JobPropertiesControl">
<center>
<HBox>
<children>
<TableView fx:id="properties" prefHeight="400.0" prefWidth="550.0" HBox.hgrow="ALWAYS">
<columns>
<TableColumn prefWidth="150.0" text="Type of directory" />
<TableColumn prefWidth="400.0" text="Location" />
</columns>
</TableView>
</children>
<padding>
<Insets bottom="1.0" left="1.0" right="1.0" top="1.0" />
</padding>
</HBox>
</center>
</fx:root>
...@@ -3,16 +3,15 @@ package cz.it4i.fiji.haas; ...@@ -3,16 +3,15 @@ package cz.it4i.fiji.haas;
import java.awt.event.WindowAdapter; import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent; import java.awt.event.WindowEvent;
import cz.it4i.fiji.haas_spim_benchmark.ui.BenchmarkSPIMController; import cz.it4i.fiji.haas_spim_benchmark.ui.BenchmarkSPIMControl;
public class TestFX { public class TestFX {
public static void main(String[] args) { public static void main(String[] args) {
@SuppressWarnings("serial") @SuppressWarnings("serial")
class Window extends FXFrame<BenchmarkSPIMController>{ class Window extends FXFrame<BenchmarkSPIMControl>{
public Window() { public Window() {
super(()->new BenchmarkSPIMController(null)); super(()->new BenchmarkSPIMControl(null));
// TODO Auto-generated constructor stub
} }
} }
...@@ -22,7 +21,6 @@ public class TestFX { ...@@ -22,7 +21,6 @@ public class TestFX {
window.addWindowListener(new WindowAdapter() { window.addWindowListener(new WindowAdapter() {
@Override @Override
public void windowClosed(WindowEvent e) { public void windowClosed(WindowEvent e) {
// TODO Auto-generated method stub
super.windowClosed(e); super.windowClosed(e);
System.exit(0); System.exit(0);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment