Skip to content

Commit

Permalink
Modified Controller to initialize with EventHandler
Browse files Browse the repository at this point in the history
  • Loading branch information
rexc159 committed Feb 21, 2018
1 parent 3c09655 commit 3c45bed
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions src/StellarisDK/GUI/guiController.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,23 @@ public guiController() {
} catch (IOException e) {
throw new RuntimeException(e);
}

// Can probably cut some RAM cost by using Cell Factories
itemView.addEventHandler(MouseEvent.MOUSE_CLICKED, event -> {
if (event.getClickCount() >= 2) {
Node node = event.getPickResult().getIntersectedNode();
if (node instanceof Text || (node instanceof TreeCell && ((TreeCell) node).getText() != null &&
((TreeCell) node).getChildrenUnmodifiable().size() == 1)) {
System.out.println("Starting Editor");
Object temp;
if ((node instanceof LabeledText)) {
temp = ((TreeCell) node.getParent()).getTreeItem().getValue();
} else
temp = ((TreeCell) node).getTreeItem().getValue();
open((GenericData) temp);
}
}
});
}

public void setStage(Stage stage) {
Expand Down Expand Up @@ -102,23 +119,6 @@ protected void openMod() {
itemView.getRoot().getChildren().add(new TreeItem(mainMd));
itemView.getRoot().setExpanded(true);

// Can probably cut some RAM cost by using Cell Factories
itemView.addEventHandler(MouseEvent.MOUSE_CLICKED, event -> {
if (event.getClickCount() >= 2) {
Node node = event.getPickResult().getIntersectedNode();
if (node instanceof Text || (node instanceof TreeCell && ((TreeCell) node).getText() != null &&
((TreeCell) node).getChildrenUnmodifiable().size() == 1)) {
System.out.println("Starting Editor");
Object temp;
if ((node instanceof LabeledText)) {
temp = ((TreeCell) node.getParent()).getTreeItem().getValue();
} else
temp = ((TreeCell) node).getTreeItem().getValue();
open((GenericData) temp);
}
}
});

if (mainMd.getValue("path") != null) {
mainLoadPath = modPath.getParentFile().getParent() + "\\" + (mainMd.getValue("path").toString().replaceAll("/", "\\\\"));
loadMod();
Expand Down

0 comments on commit 3c45bed

Please sign in to comment.