use of controller.command.ChangePropertyValueCommand in project uPMT by coco35700.
the class TypePropertyRepresentation method setLabelChangeName.
private void setLabelChangeName(HBox propertyPane2, TypePropertyRepresentation tpr) {
propertyValue.setOnMouseClicked(new EventHandler<MouseEvent>() {
@Override
public void handle(MouseEvent arg0) {
if (arg0.getClickCount() == 2) {
TextField t = new TextField(propertyValue.getText());
t.setMaxWidth(70);
t.setMinWidth(10);
ChangeListener<Boolean> listener = new ChangeListener<Boolean>() {
@Override
public void changed(ObservableValue<? extends Boolean> arg0, Boolean oldPropertyValue, Boolean newPropertyValue) {
if (!newPropertyValue) {
ChangePropertyValueCommand cmd = new ChangePropertyValueCommand(tpr, property.getValue(), t.getText(), main);
cmd.execute();
UndoCollector.INSTANCE.add(cmd);
propertyPane2.getChildren().remove(2);
propertyPane2.getChildren().add(propertyValue);
// propertyPane2.setRight(propertyValue);
}
}
};
t.setOnKeyPressed(new EventHandler<KeyEvent>() {
@Override
public void handle(KeyEvent event) {
if (event.getCode() == KeyCode.ENTER) {
t.setText(t.getText());
propertyPane2.getChildren().remove(2);
propertyPane2.getChildren().add(propertyValue);
// propertyPane2.setRight(propertyValue);
}
if (event.getCode() == KeyCode.ESCAPE) {
propertyPane2.getChildren().remove(2);
propertyPane2.getChildren().add(propertyValue);
// propertyPane2.setRight(propertyValue);
}
}
});
t.focusedProperty().addListener(listener);
Platform.runLater(() -> t.requestFocus());
Platform.runLater(() -> t.selectAll());
propertyPane2.getChildren().remove(2);
propertyPane2.getChildren().add(t);
// propertyPane2.setRight(t);
}
}
});
}
Aggregations