Skip to content

Commit

Permalink
Risolta issue del commit precedente ed aggiunta piccola miglioria gra…
Browse files Browse the repository at this point in the history
…fica.
  • Loading branch information
NoeMurr committed Mar 5, 2018
1 parent a4c1631 commit bec3c8f
Showing 1 changed file with 15 additions and 14 deletions.
29 changes: 15 additions & 14 deletions src/it/teamunivr/powerstrips/view/PreferenceController.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,15 @@ private boolean setTreeView() {
root = new TreeItem<>();
Map<String, ArrayList<String>> itemMap;

MenuItem addType = new MenuItem("Aggiungi Tipologia");
addType.setOnAction(t -> root.getChildren().add(new TreeItem<>("Nuova Tipologia")));

treeView.setContextMenu(new ContextMenu(addType));
treeView.setRoot(root);
treeView.setShowRoot(false);
treeView.setCellFactory(p -> new CustomTextFieldTreeCell());
treeView.setEditable(true);

try {
itemMap = Config.getInstance().getLoanableItems();
} catch (ParseException e) {
Expand All @@ -57,17 +66,6 @@ private boolean setTreeView() {
root.getChildren().add(tmp);
}

MenuItem addType = new MenuItem("Aggiungi Tipologia");

addType.setOnAction(t -> root.getChildren().add(new TreeItem<>("Nuova Tipologia")));

treeView.setRoot(root);
treeView.setShowRoot(false);
treeView.setCellFactory(p -> new CustomTextFieldTreeCell());
treeView.setEditable(true);

treeView.setContextMenu(new ContextMenu(addType));

return true;
}

Expand Down Expand Up @@ -215,10 +213,13 @@ public String fromString(String string) {
addTypeMenuItem.setOnAction(t -> root.getChildren().add(new TreeItem<>("Nuova Tipologia")));

addIDMenuItem.setOnAction(t -> {
if (getTreeItem().getParent() == root)
getTreeItem().getChildren().add(new TreeItem<>("Nuovo ID"));
TreeItem<String> newItem = new TreeItem<>("Nuovo ID");
if (getTreeItem().getParent() == root) {
getTreeItem().setExpanded(true);
}
else if (getTreeItem().getParent() != null) {
getTreeItem().getParent().getChildren().add(new TreeItem<>("Nuovo ID"));
getTreeItem().getParent().setExpanded(true);
getTreeItem().getParent().getChildren().add(newItem);
}
});

Expand Down

0 comments on commit bec3c8f

Please sign in to comment.