|
@@ -58,8 +58,9 @@ public class InspectorTable extends JPanel {
|
|
private final static Color selectedColor = new Color(126, 186, 255);
|
|
private final static Color selectedColor = new Color(126, 186, 255);
|
|
private final static Color borderColor = new Color(171, 173, 179);
|
|
private final static Color borderColor = new Color(171, 173, 179);
|
|
//Events
|
|
//Events
|
|
- public Action<Set<HolonElement>> OnElementSelectionChanged = new Action<>();
|
|
|
|
-
|
|
|
|
|
|
+ public Action<Set<HolonElement>> OnElementSelectionChanged = new Action<>();
|
|
|
|
+ private Thread populateRowsThread;
|
|
|
|
+ private boolean abortThread = false;
|
|
public InspectorTable(Control control) {
|
|
public InspectorTable(Control control) {
|
|
control.OnSelectionChanged.addListener(() -> update_ui());
|
|
control.OnSelectionChanged.addListener(() -> update_ui());
|
|
this.control = control;
|
|
this.control = control;
|
|
@@ -182,22 +183,44 @@ public class InspectorTable extends JPanel {
|
|
}
|
|
}
|
|
|
|
|
|
private void update_ui() {
|
|
private void update_ui() {
|
|
- Stream<HolonElement> elements = extractElements(control.getModel().getSelectedObjects());
|
|
|
|
- // TODO Pooling
|
|
|
|
- this.removeAll();
|
|
|
|
- elementRows.clear();
|
|
|
|
- generateHeader();
|
|
|
|
- elements.forEach(element -> elementRows.add(new ElementRow(element)));
|
|
|
|
- this.add(buttonPanel, "span");
|
|
|
|
- boolean isAtLeastOneHolonObjectSelected =
|
|
|
|
- control.getModel().getSelectedObjects().stream().anyMatch(object -> object instanceof HolonObject);
|
|
|
|
- this.addButton.setEnabled(isAtLeastOneHolonObjectSelected);
|
|
|
|
- duplicateButton.setEnabled(false);
|
|
|
|
- deleteButton.setEnabled(false);
|
|
|
|
- selectAllCheckBox.setSelectionState(State.unselected);
|
|
|
|
- revalidate();
|
|
|
|
- repaint();
|
|
|
|
- this.OnElementSelectionChanged.broadcast(new HashSet<HolonElement>());
|
|
|
|
|
|
+
|
|
|
|
+ if(populateRowsThread != null) {
|
|
|
|
+ try {
|
|
|
|
+ abortThread = true;
|
|
|
|
+ populateRowsThread.join();
|
|
|
|
+ abortThread = false;
|
|
|
|
+ } catch (InterruptedException e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ populateRowsThread = new Thread(() -> {
|
|
|
|
+ Stream<HolonElement> elements = extractElements(control.getModel().getSelectedObjects());
|
|
|
|
+ List<HolonElement> elementList = elements.toList();
|
|
|
|
+ this.removeAll();
|
|
|
|
+ elementRows.clear();
|
|
|
|
+ // TODO Pooling
|
|
|
|
+ generateHeader();
|
|
|
|
+ for(HolonElement element : elementList)
|
|
|
|
+ {
|
|
|
|
+ if(abortThread) break;
|
|
|
|
+ elementRows.add(new ElementRow(element));
|
|
|
|
+ revalidate();
|
|
|
|
+ repaint();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ this.add(buttonPanel, "span");
|
|
|
|
+ boolean isAtLeastOneHolonObjectSelected =
|
|
|
|
+ control.getModel().getSelectedObjects().stream().anyMatch(object -> object instanceof HolonObject);
|
|
|
|
+ this.addButton.setEnabled(isAtLeastOneHolonObjectSelected);
|
|
|
|
+ duplicateButton.setEnabled(false);
|
|
|
|
+ deleteButton.setEnabled(false);
|
|
|
|
+ selectAllCheckBox.setSelectionState(State.unselected);
|
|
|
|
+ revalidate();
|
|
|
|
+ repaint();
|
|
|
|
+ this.OnElementSelectionChanged.broadcast(new HashSet<HolonElement>());
|
|
|
|
+ });
|
|
|
|
+ populateRowsThread.start();
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|