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

fixes of runtime errors

parent 6d0ebb3d
No related branches found
No related tags found
1 merge request!12Dialog for complet job info
This commit is part of merge request !12. Comments created here will be created in the context of that merge request.
......@@ -24,41 +24,44 @@ public class HaaSOutputObservableValueRegistry implements Closeable {
private static Logger log = LoggerFactory
.getLogger(cz.it4i.fiji.haas_spim_benchmark.ui.HaaSOutputObservableValueRegistry.class);
private Map<SynchronizableFileType, P_HaaSOutputObservableValue> observable = new HashMap<>();
private List<SynchronizableFileType> types;
private Map<SynchronizableFileType, P_HaaSOutputObservableValue> observable = new HashMap<>();
private List<SynchronizableFileType> types = new LinkedList<>();
private Timer timer;
private HaaSOutputHolder holder;
private long timeout;
private final TimerTask task = new TimerTask() {
@Override
public void run() {
update();
}
};
public HaaSOutputObservableValueRegistry(HaaSOutputHolder holder,long timeout) {
public HaaSOutputObservableValueRegistry(HaaSOutputHolder holder, long timeout) {
super();
this.types = new LinkedList<SynchronizableFileType>(types);
this.holder = holder;
timer = new Timer();
this.timeout = timeout;
}
public void start() {
timer.schedule(task, 0);
timer.schedule(task, timeout, timeout);
timer.schedule(createTask(), 0);
timer.schedule(createTask(), timeout, timeout);
}
private TimerTask createTask() {
return new TimerTask() {
@Override
public void run() {
update();
}
};
}
@Override
public void close() {
timer.cancel();
}
public ObservableValue<String> createObservable(SynchronizableFileType type) {
ObservableValue<String> result;
types.add(type);
observable.put(type, (P_HaaSOutputObservableValue) (result = new P_HaaSOutputObservableValue()));
return result;
}
......@@ -73,7 +76,7 @@ public class HaaSOutputObservableValueRegistry implements Closeable {
String value;
private void update(String value) {
private synchronized void update(String value) {
String oldValue = this.value;
this.value = value;
if (value != null && oldValue == null || value == null && oldValue != null
......
......@@ -32,7 +32,7 @@ public class JobDetailControl extends TabPane implements CloseableControl {
observableValueRegistry = new HaaSOutputObservableValueRegistry(job,
Constants.HAAS_UPDATE_TIMEOUT / Constants.UI_TO_HAAS_FREQUENCY_UPDATE_RATIO);
errorOutput.setObservable(observableValueRegistry.createObservable(SynchronizableFileType.StandardErrorFile));
errorOutput.setObservable(observableValueRegistry.createObservable(SynchronizableFileType.StandardOutputFile));
standardOutput.setObservable(observableValueRegistry.createObservable(SynchronizableFileType.StandardOutputFile));
observableValueRegistry.start();
}
......
......@@ -41,19 +41,18 @@ public class LogViewControl extends BorderPane implements CloseableControl {
private TextArea ta;
public void setObservable(ObservableValue<String> value) {
ta.setText(value.getValue());
JavaFXRoutines.runOnFxThread(()->ta.setText(value.getValue()));
value.addListener(new ChangeListener<String>() {
@Override
public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) {
ta.setText(newValue);
JavaFXRoutines.runOnFxThread(()->ta.setText(value.getValue()));
}
});
}
@Override
public void close() {
// TODO Auto-generated method stub
//DO NOTHING
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment