diff --git a/haas-spim-benchmark/pom.xml b/haas-spim-benchmark/pom.xml index 92859dc556c15ffd153120c062eef63adf87d9ea..10057406c4c5b478647fc61aae0ee12efb56925d 100644 --- a/haas-spim-benchmark/pom.xml +++ b/haas-spim-benchmark/pom.xml @@ -78,6 +78,14 @@ <artifactId>haas-imagej-client</artifactId> <version>0.0.1-SNAPSHOT</version> </dependency> + + <!-- https://mvnrepository.com/artifact/commons-io/commons-io --> + <dependency> + <groupId>commons-io</groupId> + <artifactId>commons-io</artifactId> + <version>2.6</version> + </dependency> + <!-- https://mvnrepository.com/artifact/org.slf4j/slf4j-api --> <dependency> <groupId>org.slf4j</groupId> diff --git a/haas-spim-benchmark/src/main/java/cz/it4i/fiji/haas_spim_benchmark/core/TaskComputation.java b/haas-spim-benchmark/src/main/java/cz/it4i/fiji/haas_spim_benchmark/core/TaskComputation.java index 75ec8d161156a2f50b9c61dd3623afd7372d1937..974baa8d4c3cc46e84d57b0e51e4af7fb8a272f0 100644 --- a/haas-spim-benchmark/src/main/java/cz/it4i/fiji/haas_spim_benchmark/core/TaskComputation.java +++ b/haas-spim-benchmark/src/main/java/cz/it4i/fiji/haas_spim_benchmark/core/TaskComputation.java @@ -207,4 +207,8 @@ public class TaskComputation { return computationAccessor.getActualOutput(Arrays.asList(SynchronizableFileType.StandardErrorFile)).get(0); } + public Collection<String> getOutputs() { + return outputs; + } + } diff --git a/haas-spim-benchmark/src/main/java/cz/it4i/fiji/haas_spim_benchmark/ui/RemoteFileInfo.java b/haas-spim-benchmark/src/main/java/cz/it4i/fiji/haas_spim_benchmark/ui/RemoteFileInfo.java new file mode 100644 index 0000000000000000000000000000000000000000..ffe8175cb7fff9ca58ad7fb8a2c4199ac9f5e318 --- /dev/null +++ b/haas-spim-benchmark/src/main/java/cz/it4i/fiji/haas_spim_benchmark/ui/RemoteFileInfo.java @@ -0,0 +1,12 @@ +package cz.it4i.fiji.haas_spim_benchmark.ui; + +public interface RemoteFileInfo { + + /** + * + * @return size of file or -1 in case of absence + */ + long getSize(); + + String getName(); +} diff --git a/haas-spim-benchmark/src/main/java/cz/it4i/fiji/haas_spim_benchmark/ui/RemoteFilesInfo.fxml b/haas-spim-benchmark/src/main/java/cz/it4i/fiji/haas_spim_benchmark/ui/RemoteFilesInfo.fxml new file mode 100644 index 0000000000000000000000000000000000000000..d16c28005d7c4d5544e947867934119c805b160a --- /dev/null +++ b/haas-spim-benchmark/src/main/java/cz/it4i/fiji/haas_spim_benchmark/ui/RemoteFilesInfo.fxml @@ -0,0 +1,28 @@ +<?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.RemoteFilesInfoControl"> + <center> + + <HBox> + <children> + + <TableView fx:id="files" HBox.hgrow="ALWAYS"> + <columns> + <TableColumn prefWidth="450.0" text="File name" /> + <TableColumn minWidth="150.0" prefWidth="0.0" text="Size of file" /> + </columns> + </TableView> + </children> + <padding> + <Insets bottom="1.0" left="1.0" right="1.0" top="1.0" /> + </padding> + </HBox> + </center> + +</fx:root> diff --git a/haas-spim-benchmark/src/main/java/cz/it4i/fiji/haas_spim_benchmark/ui/RemoteFilesInfoControl.java b/haas-spim-benchmark/src/main/java/cz/it4i/fiji/haas_spim_benchmark/ui/RemoteFilesInfoControl.java new file mode 100644 index 0000000000000000000000000000000000000000..de9e3af739c6c7a6e2eaaa18902591b17b5af4ca --- /dev/null +++ b/haas-spim-benchmark/src/main/java/cz/it4i/fiji/haas_spim_benchmark/ui/RemoteFilesInfoControl.java @@ -0,0 +1,54 @@ +package cz.it4i.fiji.haas_spim_benchmark.ui; + +import java.awt.Window; +import java.util.List; +import java.util.function.Function; + +import org.apache.commons.io.FileUtils; + +import cz.it4i.fiji.haas.ui.CloseableControl; +import cz.it4i.fiji.haas.ui.InitiableControl; +import cz.it4i.fiji.haas.ui.JavaFXRoutines; +import javafx.beans.value.ObservableValue; +import javafx.fxml.FXML; +import javafx.scene.control.TableView; +import javafx.scene.layout.BorderPane; + +public class RemoteFilesInfoControl extends BorderPane implements CloseableControl, InitiableControl { + + @SuppressWarnings("unused") + private Window root; + + @FXML + private TableView<ObservableValue<RemoteFileInfo>> files; + + public RemoteFilesInfoControl(List<ObservableValue< RemoteFileInfo>> files) { + JavaFXRoutines.initRootAndController("RemoteFilesInfo.fxml", this); + files.forEach(file->this.files.getItems().add(file)); + + } + + @Override + public void init(Window parameter) { + this.root = parameter; + initTable(); + } + + @Override + public void close() { + // TODO Auto-generated method stub + + } + + private void initTable() { + JavaFXRoutines.setCellValueFactory(files, 0, file -> file.getName()); + JavaFXRoutines.setCellValueFactory(files, 1, + (Function<RemoteFileInfo, String>) file -> file.getSize() >= 0 ? formatSize(file.getSize()) : "Not exists"); + + } + + private String formatSize(long size) { + return FileUtils.byteCountToDisplaySize(size); + } + +} diff --git a/haas-spim-benchmark/src/main/java/cz/it4i/fiji/haas_spim_benchmark/ui/TaskComputationAdapter.java b/haas-spim-benchmark/src/main/java/cz/it4i/fiji/haas_spim_benchmark/ui/TaskComputationAdapter.java new file mode 100644 index 0000000000000000000000000000000000000000..f60f1fba05d76152ab734e800dfe12e5f74979a2 --- /dev/null +++ b/haas-spim-benchmark/src/main/java/cz/it4i/fiji/haas_spim_benchmark/ui/TaskComputationAdapter.java @@ -0,0 +1,87 @@ +package cz.it4i.fiji.haas_spim_benchmark.ui; + +import java.io.Closeable; +import java.util.LinkedList; +import java.util.List; +import java.util.Timer; +import java.util.TimerTask; + +import cz.it4i.fiji.haas_spim_benchmark.core.TaskComputation; +import javafx.beans.value.ObservableValue; +import javafx.beans.value.ObservableValueBase; + +public class TaskComputationAdapter implements Closeable{ + + private final TaskComputation computation; + + private final List<ObservableValue<RemoteFileInfo>> outputs = new LinkedList<>(); + + private final List<ObservableValue<String>> logs = new LinkedList<>(); + + private final Timer timer; + + + public TaskComputationAdapter(TaskComputation computation) { + this.computation = computation; + timer = new Timer(); + computation.getOutputs().forEach(outputFile->addOutputFile(outputFile)); + } + + + + private void addOutputFile(String outputFile) { + outputs.add(new ObservableOutputFile(outputFile)); + } + + + + @Override + public void close() { + timer.cancel(); + } + + public static class Log { + public String getName() { + return null; + } + public ObservableValue<String> getContent() { + return null; + } + } + + private class ObservableOutputFile extends ObservableValueBase<RemoteFileInfo> { + + private final String name; + + private final RemoteFileInfo value = new RemoteFileInfo() { + + @Override + public long getSize() { + return 0; + } + + @Override + public String getName() { + return null; + } + }; + + public ObservableOutputFile(String name) { + this.name = name; + } + + @Override + public RemoteFileInfo getValue() { + return value; + } + } + + private class P_TimerTask extends TimerTask { + + @Override + public void run() { + + } + + } +} diff --git a/haas-spim-benchmark/src/test/java/cz/it4i/fiji/haas/RunRemoteFilesView.java b/haas-spim-benchmark/src/test/java/cz/it4i/fiji/haas/RunRemoteFilesView.java new file mode 100644 index 0000000000000000000000000000000000000000..5efd28f1f9a31eb806160e9ef1689d5772d51cf7 --- /dev/null +++ b/haas-spim-benchmark/src/test/java/cz/it4i/fiji/haas/RunRemoteFilesView.java @@ -0,0 +1,53 @@ +package cz.it4i.fiji.haas; + +import java.util.Collection; +import java.util.LinkedList; +import java.util.List; + +import cz.it4i.fiji.haas_spim_benchmark.ui.RemoteFileInfo; +import cz.it4i.fiji.haas_spim_benchmark.ui.RemoteFilesInfoControl; +import javafx.beans.value.ObservableValue; +import javafx.beans.value.ObservableValueBase; + +public class RunRemoteFilesView { + + + public static void main(String[] args) { + List<ObservableValue<RemoteFileInfo>> files = new LinkedList<>(); + add(files, "Some file.txt", 100025456); + + class Window extends cz.it4i.fiji.haas.ui.FXFrame<RemoteFilesInfoControl>{ + public Window() { + super(()-> new RemoteFilesInfoControl(files)); + } + } + + new Window().setVisible(true); + } + + static void add(Collection<ObservableValue<RemoteFileInfo>> files, String name, long size) { + RemoteFileInfo file = new RemoteFileInfo() { + + @Override + public long getSize() { + return size; + } + + @Override + public String getName() { + return name; + } + + }; + ObservableValue<RemoteFileInfo> value = new ObservableValueBase<RemoteFileInfo>() { + + @Override + public RemoteFileInfo getValue() { + return file; + } + }; + + files.add(value); + } + +}