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

task_execution details

parent ddd6dff2
No related branches found
No related tags found
1 merge request!14Iss1026
...@@ -78,6 +78,14 @@ ...@@ -78,6 +78,14 @@
<artifactId>haas-imagej-client</artifactId> <artifactId>haas-imagej-client</artifactId>
<version>0.0.1-SNAPSHOT</version> <version>0.0.1-SNAPSHOT</version>
</dependency> </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 --> <!-- https://mvnrepository.com/artifact/org.slf4j/slf4j-api -->
<dependency> <dependency>
<groupId>org.slf4j</groupId> <groupId>org.slf4j</groupId>
......
...@@ -207,4 +207,8 @@ public class TaskComputation { ...@@ -207,4 +207,8 @@ public class TaskComputation {
return computationAccessor.getActualOutput(Arrays.asList(SynchronizableFileType.StandardErrorFile)).get(0); return computationAccessor.getActualOutput(Arrays.asList(SynchronizableFileType.StandardErrorFile)).get(0);
} }
public Collection<String> getOutputs() {
return outputs;
}
} }
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();
}
<?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>
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);
}
}
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() {
}
}
}
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);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment