Skip to content

Commit

Permalink
Added Context Menu to default editor
Browse files Browse the repository at this point in the history
  • Loading branch information
rexc159 committed Mar 9, 2018
1 parent 8f70217 commit 3784db6
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions src/StellarisDK/FileClasses/Helper/DataCell.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@

import com.sun.javafx.scene.control.skin.LabeledText;
import javafx.scene.Node;
import javafx.scene.control.ContextMenu;
import javafx.scene.control.TextField;
import javafx.scene.control.TreeCell;
import javafx.scene.control.TreeItem;
import javafx.scene.control.*;
import javafx.scene.input.ClipboardContent;
import javafx.scene.input.Dragboard;
import javafx.scene.input.KeyCode;
Expand Down Expand Up @@ -88,6 +85,8 @@ public DataCell() {
System.out.println(getItem());
}
});

setCM();
}

@Override
Expand Down Expand Up @@ -155,8 +154,20 @@ protected void updateItem(T item, boolean empty) {

private void setCM() {
ContextMenu contextMenu = new ContextMenu();
MenuItem createNew = new MenuItem("New..");
createNew.setOnAction(event -> {
getTreeItem().getChildren().add(new TreeItem("Click to Edit.."));
});
MenuItem edit = new MenuItem("Rename");
edit.setOnAction(event -> startEdit());

MenuItem delete = new MenuItem("Delete");
delete.setOnAction(event -> {
if(getTreeItem().getParent() != null)
getTreeItem().getParent().getChildren().remove(getTreeItem());
});

contextMenu.getItems().addAll(createNew, edit, delete);
setContextMenu(contextMenu);
}
}

0 comments on commit 3784db6

Please sign in to comment.