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

enable decoration

parent 027cd211
Branches
Tags
No related merge requests found
...@@ -55,9 +55,10 @@ public class FXFrame<C extends FXFrame.Controller> extends JDialog { ...@@ -55,9 +55,10 @@ public class FXFrame<C extends FXFrame.Controller> extends JDialog {
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
static public <U,T extends ObservableValue<U>> void setCellValueFactory(TableView<T> tableView,int index, Function<U, String> mapper) { static public <U,T extends ObservableValue<U>,V> void setCellValueFactory(TableView<T> tableView,int index, Function<U, V> mapper) {
((TableColumn<T, String>) tableView.getColumns().get(index)) ((TableColumn<T, V>) tableView.getColumns().get(index))
.setCellValueFactory(f -> new ObservableValueAdapter<U, String>(f.getValue(), mapper)); .setCellValueFactory(f -> new ObservableValueAdapter<U, V>(f.getValue(), mapper));
//((TableColumn<T, String>) tableView.getColumns().get(index)).setCellFactory(f->f.set);
} }
} }
......
...@@ -10,12 +10,14 @@ import java.util.function.Function; ...@@ -10,12 +10,14 @@ import java.util.function.Function;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import cz.it4i.fiji.haas.ui.FXFrame; import cz.it4i.fiji.haas.ui.FXFrame;
import cz.it4i.fiji.haas_java_client.JobState;
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 cz.it4i.fiji.haas_spim_benchmark.core.Task; import cz.it4i.fiji.haas_spim_benchmark.core.Task;
import cz.it4i.fiji.haas_spim_benchmark.core.TaskComputation; import cz.it4i.fiji.haas_spim_benchmark.core.TaskComputation;
import javafx.beans.value.ObservableValue; import javafx.beans.value.ObservableValue;
import javafx.fxml.FXML; import javafx.fxml.FXML;
import javafx.scene.control.TableCell;
import javafx.scene.control.TableColumn; import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView; import javafx.scene.control.TableView;
...@@ -47,6 +49,7 @@ public class SPIMPipelineProgressViewController implements FXFrame.Controller { ...@@ -47,6 +49,7 @@ public class SPIMPipelineProgressViewController implements FXFrame.Controller {
this.job = job; this.job = job;
} }
@SuppressWarnings("unchecked")
private void fillTable() { private void fillTable() {
List<Task> tasks = job.getTasks(); List<Task> tasks = job.getTasks();
if (tasks == null) { if (tasks == null) {
...@@ -64,15 +67,32 @@ public class SPIMPipelineProgressViewController implements FXFrame.Controller { ...@@ -64,15 +67,32 @@ public class SPIMPipelineProgressViewController implements FXFrame.Controller {
for (TaskComputation tc : computations) { for (TaskComputation tc : computations) {
this.tasks.getColumns().add(new TableColumn<>(tc.getTimepoint() + "")); this.tasks.getColumns().add(new TableColumn<>(tc.getTimepoint() + ""));
int index = i; int index = i++;
FXFrame.Controller.setCellValueFactory(this.tasks, i, (Function<Task, String>) v -> {
List<TaskComputation> items = v.getComputations(); FXFrame.Controller.setCellValueFactory(this.tasks, index, (Function<Task, JobState>) v -> {
if (items.size() >= index) { if (v.getComputations().size() >= index) {
return ""; return v.getComputations().get(index - 1).getState();
} else { } else {
return v.getComputations().get(index).getState().toString(); return null;
}
});
((TableColumn<ObservableValue<Task>, JobState>)this.tasks.getColumns().get(index)).setCellFactory(column->new TableCell<ObservableValue<Task>,JobState>(){
@Override
protected void updateItem(JobState state, boolean empty) {
if (state == null || empty) {
setText(null);
setStyle("");
} else {
// Format date.
setText(state + "");
if(state == JobState.Unknown) {
setStyle("-fx-background-color: yellow");
}
}
} }
}); });
} }
this.tasks.getItems() this.tasks.getItems()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment