Commit 8c02715c authored by legoc's avatar legoc

Added listener on the JavaFX property axisProperty of Component to get the updates

parent 0a1966d2
......@@ -814,6 +814,9 @@ public class EditorMenuBar extends MenuBar {
// Hide the axes.
selectedAxis.setVisible(false);
// Set the axis property for refreshing the tree.
selectedComponent.setAxisProperty();
valueThread.interrupt();
addStage.close();
});
......@@ -829,6 +832,9 @@ public class EditorMenuBar extends MenuBar {
// Reset the initial axis.
selectedComponent.resetAxis(initialAxis);
// Set the axis property for refreshing the tree.
selectedComponent.setAxisProperty();
valueThread.interrupt();
addStage.close();
});
......
......@@ -14,6 +14,8 @@ import javafx.scene.control.TreeView;
import javafx.scene.control.cell.CheckBoxTreeCell;
import javafx.util.Callback;
import javafx.scene.control.Tooltip;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
/**
* @author dages
......@@ -21,8 +23,6 @@ import javafx.scene.control.Tooltip;
*/
public class HierarchyCell extends CheckBoxTreeCell<Component> {
private Tooltip tooltip = new Tooltip();
public static final Callback<TreeView<Component>, TreeCell<Component>> FACTORY;
static {
......@@ -35,6 +35,8 @@ public class HierarchyCell extends CheckBoxTreeCell<Component> {
}
private ContextMenu rigthClickMenu = new ContextMenu();
private Tooltip tooltip = new Tooltip();
private ChangeListener<String> listener;
public HierarchyCell() {
super();
......@@ -80,29 +82,50 @@ public class HierarchyCell extends CheckBoxTreeCell<Component> {
rigthClickMenu.getItems().add(displayAllTheComponentsItem);
}
private String getTextValue(Component component) {
String text = component.getName();
if (component.hasDuplicateName()) {
text += "*" + component.getDuplicationNameId();
}
if (component.getAxis().getController() != null) {
text += " (" + component.getAxis().getController().getName() + ")";
}
return text;
}
@Override
public void updateItem(Component component, boolean empty) {
super.updateItem(component, empty);
if (empty || isEditing()) {
return;
} else {
String text = component.getName();
if (component.hasDuplicateName()) {
text += "*" + component.getDuplicationNameId();
}
if (component.getAxis().getController() != null) {
text += " (" + component.getAxis().getController().getName() + ")";
}
}
else {
setText(text);
setText(getTextValue(component));
setContextMenu(rigthClickMenu);
tooltip.setText(component.getName());
setTooltip(tooltip);
if (listener != null) {
component.axisProperty().removeListener(listener);
}
listener = new ChangeListener<String>() {
@Override
public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) {
setText(getTextValue(component));
}
};
component.axisProperty().addListener(listener);
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment