Commit 91def584 authored by Ivan Dages's avatar Ivan Dages
Browse files

axis link : search field

parent 21d28eee
......@@ -469,6 +469,7 @@ public class EditorMenuBar extends MenuBar {
return;
}
double sceneWidth = 200;
GridPane scenePane = new GridPane();
scenePane.setAlignment(Pos.CENTER);
scenePane.setVgap(5);
......@@ -489,12 +490,51 @@ public class EditorMenuBar extends MenuBar {
return o1.getName().compareTo(o2.getName());
}
));
scenePane.addRow(0, controllersList);
controllersList.setPrefWidth(200);
controllersList.requestFocus();
String unFocusedSearch = "Search...";
TextField searchField = new TextField(unFocusedSearch);
searchField.focusedProperty().addListener(new ChangeListener<Boolean>() {
@Override
public void changed(ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) {
if (newValue.booleanValue() && searchField.getText().equals(unFocusedSearch)) {
searchField.setText("");
} else if (!newValue.booleanValue()) {
searchField.setText(unFocusedSearch);
}
}
});
searchField.textProperty().addListener(new ChangeListener<String>() {
@Override
public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) {
// First pass, looking for the first controllers starting with text
for (Nomad3DController c : controllersList.getItems()) {
if (c.getName().toUpperCase().startsWith(newValue.toUpperCase())) {
controllersList.getSelectionModel().select(c);
controllersList.scrollTo(c);
return;
}
}
// Second pass, looking for the first controllers containing text
for (Nomad3DController c : controllersList.getItems()) {
if (c.getName().toUpperCase().contains(newValue.toUpperCase())) {
controllersList.getSelectionModel().select(c);
controllersList.scrollTo(c);
return;
}
}
}
});
scenePane.addRow(0, searchField);
searchField.setPrefWidth(sceneWidth);
GridPane.setColumnSpan(searchField, GridPane.REMAINING);
scenePane.addRow(1, controllersList);
controllersList.setPrefWidth(sceneWidth);
GridPane.setColumnSpan(controllersList, GridPane.REMAINING);
Button selectButton = new Button("Select");
selectButton.setPrefWidth(100);
selectButton.setPrefWidth(sceneWidth/2);
selectButton.setDefaultButton(true);
selectButton.setOnAction(selEvent -> {
Nomad3DController selectedController = controllersList.getSelectionModel().getSelectedItem();
......@@ -513,12 +553,12 @@ public class EditorMenuBar extends MenuBar {
}
});
Button cancelButton = new Button("Cancel");
cancelButton.setPrefWidth(100);
cancelButton.setPrefWidth(sceneWidth/2);
cancelButton.setCancelButton(true);
cancelButton.setOnAction(cancelEvent -> {
linkStage.close();
});
scenePane.addRow(1, selectButton, cancelButton);
scenePane.addRow(2, selectButton, cancelButton);
GridPane.setMargin(scenePane, new Insets(10));
......@@ -538,10 +578,11 @@ public class EditorMenuBar extends MenuBar {
GridPane scenePane = new GridPane();
scenePane.setAlignment(Pos.CENTER);
Scene modifyScene = new Scene(scenePane); // PATAFIX
Scene modifyScene = new Scene(scenePane);
Stage modifyStage = new Stage(StageStyle.UTILITY);
modifyStage.setTitle(modifyMaterialItem.getText());
modifyStage.setScene(modifyScene);
modifyStage.initOwner(Nomad3DEditor.getInstance().getStage());
GridPane modifyPane = new GridPane();
modifyPane.setVgap(5);
......@@ -662,6 +703,7 @@ public class EditorMenuBar extends MenuBar {
Stage modifyStage = new Stage(StageStyle.UTILITY);
modifyStage.setTitle(modifyMaterialItem.getText());
modifyStage.setScene(modifyScene);
modifyStage.initOwner(Nomad3DEditor.getInstance().getStage());
GridPane modifyPane = new GridPane();
modifyPane.setVgap(5);
......@@ -831,6 +873,7 @@ public class EditorMenuBar extends MenuBar {
Stage statsStage = new Stage(StageStyle.UTILITY);
statsStage.setTitle(statsItem.getText());
statsStage.setScene(statsScene);
statsStage.initOwner(Nomad3DEditor.getInstance().getStage());
statsStage.show();
}
......
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