From 7f97054d681518416a4ee1c1548ad42cfb489a8f Mon Sep 17 00:00:00 2001 From: Normand Briere <nbriere@noware.ca> Date: Wed, 14 Aug 2019 21:28:24 -0400 Subject: [PATCH] Popup menu. --- GroupEditor.java | 88 ++++++++++++++++++++++++++++--------------- 1 files changed, 57 insertions(+), 31 deletions(-) diff --git a/GroupEditor.java b/GroupEditor.java index 9f3c422..b32dee9 100644 --- a/GroupEditor.java +++ b/GroupEditor.java @@ -540,32 +540,37 @@ // menu.add("-"); duplicateItem = oe.jTree.popup.add(new JMenuItem("Duplicate")); duplicateItem.addActionListener(this); - cloneItem = menu.add(new MenuItem("Clone")); + + cloneItem = oe.jTree.popup.add(new JMenuItem("Clone")); cloneItem.addActionListener(this); - if (Globals.ADVANCED) + //if (Globals.ADVANCED) { cloneSupportItem = menu.add(new MenuItem("Clone (+supports)")); cloneSupportItem.addActionListener(this); } + oe.jTree.popup.addSeparator(); menu.add("-"); - cutItem = menu.add(new MenuItem("Cut")); + cutItem = oe.jTree.popup.add(new JMenuItem("Cut")); cutItem.addActionListener(this); - copyItem = menu.add(new MenuItem("Copy")); + copyItem = oe.jTree.popup.add(new JMenuItem("Copy")); copyItem.addActionListener(this); pasteItem = menu.add(new MenuItem("Paste")); pasteItem.addActionListener(this); - menu.add("-"); - pasteIntoItem = menu.add(new MenuItem("Paste into")); + oe.jTree.popup.addSeparator(); + //menu.add("-"); + pasteIntoItem = oe.jTree.popup.add(new JMenuItem("Paste into")); pasteIntoItem.addActionListener(this); - pasteLinkItem = menu.add(new MenuItem("Paste link")); + pasteLinkItem = oe.jTree.popup.add(new JMenuItem("Paste link")); pasteLinkItem.addActionListener(this); - pasteCloneItem = menu.add(new MenuItem("Paste clone")); + pasteCloneItem = oe.jTree.popup.add(new JMenuItem("Paste clone")); pasteCloneItem.addActionListener(this); -// pasteExpandItem = menu.add(new MenuItem("Paste expand")); +// CRASH pasteExpandItem = oe.jTree.popup.add(new JMenuItem("Paste expand")); // pasteExpandItem.addActionListener(this); - menu.add("-"); - deleteItem = menu.add(new MenuItem("Delete")); + //menu.add("-"); + oe.jTree.popup.addSeparator(); + + deleteItem = oe.jTree.popup.add(new JMenuItem("Delete")); deleteItem.addActionListener(this); if (Globals.ADVANCED) @@ -716,7 +721,7 @@ hideItem = menu.add(new MenuItem("Hidden Group")); hideItem.addActionListener(this); } - ungroupItem = menu.add(new MenuItem("Ungroup")); + ungroupItem = oe.jTree.popup.add(new JMenuItem("Ungroup")); ungroupItem.addActionListener(this); // menu.add("-"); @@ -935,9 +940,9 @@ public void ResourceCallBack(String[] path) { -// for (int i = 0; i < path.length; i++) -// System.out.print(path[i] + "/"); -// System.out.println(); + for (int i = 0; i < path.length; i++) + System.out.print(path[i] + "/"); + System.out.println(); if (//rowcount == 0 || path.length == 1) @@ -2680,27 +2685,35 @@ } else if (source == loopItem || source == loopButton) { + if (!group.selection.isEmpty()) + { Composite csg = new GroupLeaf(); csg.count = 5; - group(csg); Composite child = new cGroup("Branch"); csg.addChild(child); child.addChild(csg); + group(csg); + } } else if (source == doubleItem) { + if (!group.selection.isEmpty()) + { Composite csg = new GroupLeaf("Fork"); csg.count = 5; - group(csg); Composite child = new cGroup("Branch A"); csg.addChild(child); child.addChild(csg); child = new cGroup("Branch B"); csg.addChild(child); child.addChild(csg); + group(csg); + } } else if (source == tripleItem) { + if (!group.selection.isEmpty()) + { Composite csg = new GroupLeaf("Trident"); csg.count = 4; group(csg); @@ -2713,6 +2726,7 @@ child = new cGroup(); csg.addChild(child); child.addChild(csg); + } } else if (source == computeAOItem) { @@ -3348,22 +3362,34 @@ } else if (source == ungroupItem || source == ungroupButton) { - boolean hasRoot = false; + boolean canUngroup = true; for (int i=0; i<group.selection.size(); i++) { - if (group.selection.get(i) == group) + Object3D selectedItem = group.selection.get(i); + + if (selectedItem.Size() == 0) { - hasRoot = true; + // Cannot ungroup leaves + canUngroup = false; + break; + } + + if (selectedItem == group) + { + // Cannot ungroup root + canUngroup = false; break; } } - if (!hasRoot) + if (canUngroup) { for (int i=0; i<group.selection.size(); i++) { - Ungroup(group.selection.get(i)); + Object3D selectedItem = group.selection.get(i); + + Ungroup(selectedItem); } ClearSelection(false); @@ -6233,11 +6259,11 @@ private MenuItem lookAtItem; private MenuItem lookFromItem; private MenuItem switchViewItem; - private MenuItem cutItem; + private JMenuItem cutItem; private MenuItem undoItem; private MenuItem redoItem; private JMenuItem duplicateItem; - private MenuItem cloneItem; + private JMenuItem cloneItem; private MenuItem cloneSupportItem; private MenuItem overwriteGeoItem; private MenuItem overwriteMatItem; @@ -6258,13 +6284,13 @@ private MenuItem cloneGeometriesItem; private MenuItem shareGeometriesItem; private MenuItem mergeGeometriesItem; - private MenuItem copyItem; + private JMenuItem copyItem; private MenuItem pasteItem; - private MenuItem pasteIntoItem; - private MenuItem pasteLinkItem; - private MenuItem pasteCloneItem; - private MenuItem pasteExpandItem; - private MenuItem deleteItem; + private JMenuItem pasteIntoItem; + private JMenuItem pasteLinkItem; + private JMenuItem pasteCloneItem; + private JMenuItem pasteExpandItem; + private JMenuItem deleteItem; private MenuItem clearAllItem; private MenuItem genUVItem; private MenuItem genNormalsMESHItem; @@ -6332,7 +6358,7 @@ private MenuItem switchTransfoItem; private MenuItem morphItem; private MenuItem linkerItem; - private MenuItem ungroupItem; + private JMenuItem ungroupItem; private MenuItem editItem; private MenuItem openWindowItem; private MenuItem editLeafItem; -- Gitblit v1.6.2