Normand Briere
2019-08-15 24a2a946b35279605e645349bd6b82e9e60aac88
GroupEditor.java
....@@ -540,32 +540,37 @@
540540 // menu.add("-");
541541 duplicateItem = oe.jTree.popup.add(new JMenuItem("Duplicate"));
542542 duplicateItem.addActionListener(this);
543
- cloneItem = menu.add(new MenuItem("Clone"));
543
+
544
+ cloneItem = oe.jTree.popup.add(new JMenuItem("Clone"));
544545 cloneItem.addActionListener(this);
545
- if (Globals.ADVANCED)
546
+ //if (Globals.ADVANCED)
546547 {
547548 cloneSupportItem = menu.add(new MenuItem("Clone (+supports)"));
548549 cloneSupportItem.addActionListener(this);
549550 }
551
+ oe.jTree.popup.addSeparator();
550552 menu.add("-");
551
- cutItem = menu.add(new MenuItem("Cut"));
553
+ cutItem = oe.jTree.popup.add(new JMenuItem("Cut"));
552554 cutItem.addActionListener(this);
553
- copyItem = menu.add(new MenuItem("Copy"));
555
+ copyItem = oe.jTree.popup.add(new JMenuItem("Copy"));
554556 copyItem.addActionListener(this);
555557 pasteItem = menu.add(new MenuItem("Paste"));
556558 pasteItem.addActionListener(this);
557559
558
- menu.add("-");
559
- pasteIntoItem = menu.add(new MenuItem("Paste into"));
560
+ oe.jTree.popup.addSeparator();
561
+ //menu.add("-");
562
+ pasteIntoItem = oe.jTree.popup.add(new JMenuItem("Paste into"));
560563 pasteIntoItem.addActionListener(this);
561
- pasteLinkItem = menu.add(new MenuItem("Paste link"));
564
+ pasteLinkItem = oe.jTree.popup.add(new JMenuItem("Paste link"));
562565 pasteLinkItem.addActionListener(this);
563
- pasteCloneItem = menu.add(new MenuItem("Paste clone"));
566
+ pasteCloneItem = oe.jTree.popup.add(new JMenuItem("Paste clone"));
564567 pasteCloneItem.addActionListener(this);
565
-// pasteExpandItem = menu.add(new MenuItem("Paste expand"));
568
+// CRASH pasteExpandItem = oe.jTree.popup.add(new JMenuItem("Paste expand"));
566569 // pasteExpandItem.addActionListener(this);
567
- menu.add("-");
568
- deleteItem = menu.add(new MenuItem("Delete"));
570
+ //menu.add("-");
571
+ oe.jTree.popup.addSeparator();
572
+
573
+ deleteItem = oe.jTree.popup.add(new JMenuItem("Delete"));
569574 deleteItem.addActionListener(this);
570575
571576 if (Globals.ADVANCED)
....@@ -716,7 +721,7 @@
716721 hideItem = menu.add(new MenuItem("Hidden Group"));
717722 hideItem.addActionListener(this);
718723 }
719
- ungroupItem = menu.add(new MenuItem("Ungroup"));
724
+ ungroupItem = oe.jTree.popup.add(new JMenuItem("Ungroup"));
720725 ungroupItem.addActionListener(this);
721726
722727 // menu.add("-");
....@@ -923,7 +928,7 @@
923928
924929 JTabbedPane resourcecontainer;
925930 cGridBag currenttab;
926
- boolean added; // patch for jar
931
+ //boolean added; // patch for jar
927932
928933 int tabcount = 0;
929934 int colcount = 0;
....@@ -940,12 +945,14 @@
940945 // System.out.println();
941946
942947 if (//rowcount == 0 ||
943
- path.length == 1)
948
+ path.length == 1 && !path[0].equals("") && !path[0].equals(".DS_Store"))
944949 {
945950 currenttab = new cGridBag();
946
- added = false;
947951 String tabname = path[0]; // String.valueOf((char)('A'+tabcount));
948952 currenttab.setName(tabname);
953
+ //added = false;
954
+ resourcecontainer.add(currenttab);
955
+ resourcecontainer.setToolTipTextAt(tabcount++, "Texture Group " + tabname);
949956 rowcount = 1;
950957 colcount = 0;
951958 texturecount = 0;
....@@ -953,12 +960,11 @@
953960
954961 if (path.length > 2 && path[2].toLowerCase().endsWith(".jpg"))
955962 {
956
- if (!added)
963
+ //if (!added)
957964 {
958
- added = true;
959
- resourcecontainer.add(currenttab);
965
+ //added = true;
960966 String tabname = path[0]; // String.valueOf((char)('A'+tabcount));
961
- resourcecontainer.setToolTipTextAt(tabcount++, "Texture Group " + tabname);
967
+ currenttab = (cGridBag)resourcecontainer.getComponentAt(resourcecontainer.indexOfTab(tabname));
962968 }
963969
964970 AddTextureButton(path[0], path[1], path[2], texturecount++, currenttab);
....@@ -1043,8 +1049,8 @@
10431049 // maxButton.addActionListener(this);
10441050 }
10451051
1046
-// cButton gcButton;
1047
-//
1052
+ cButton gcButton;
1053
+
10481054 // oe.toolbarPanel.add(gcButton = GetButton("icons/trash.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
10491055 // gcButton.setToolTipText("Garbage collect");
10501056 // gcButton.addActionListener(new ActionListener()
....@@ -2680,27 +2686,35 @@
26802686 } else
26812687 if (source == loopItem || source == loopButton)
26822688 {
2689
+ if (!group.selection.isEmpty())
2690
+ {
26832691 Composite csg = new GroupLeaf();
26842692 csg.count = 5;
2685
- group(csg);
26862693 Composite child = new cGroup("Branch");
26872694 csg.addChild(child);
26882695 child.addChild(csg);
2696
+ group(csg);
2697
+ }
26892698 } else
26902699 if (source == doubleItem)
26912700 {
2701
+ if (!group.selection.isEmpty())
2702
+ {
26922703 Composite csg = new GroupLeaf("Fork");
26932704 csg.count = 5;
2694
- group(csg);
26952705 Composite child = new cGroup("Branch A");
26962706 csg.addChild(child);
26972707 child.addChild(csg);
26982708 child = new cGroup("Branch B");
26992709 csg.addChild(child);
27002710 child.addChild(csg);
2711
+ group(csg);
2712
+ }
27012713 } else
27022714 if (source == tripleItem)
27032715 {
2716
+ if (!group.selection.isEmpty())
2717
+ {
27042718 Composite csg = new GroupLeaf("Trident");
27052719 csg.count = 4;
27062720 group(csg);
....@@ -2713,6 +2727,7 @@
27132727 child = new cGroup();
27142728 csg.addChild(child);
27152729 child.addChild(csg);
2730
+ }
27162731 } else
27172732 if (source == computeAOItem)
27182733 {
....@@ -3348,22 +3363,34 @@
33483363 } else
33493364 if (source == ungroupItem || source == ungroupButton)
33503365 {
3351
- boolean hasRoot = false;
3366
+ boolean canUngroup = true;
33523367
33533368 for (int i=0; i<group.selection.size(); i++)
33543369 {
3355
- if (group.selection.get(i) == group)
3370
+ Object3D selectedItem = group.selection.get(i);
3371
+
3372
+ if (selectedItem.Size() == 0)
33563373 {
3357
- hasRoot = true;
3374
+ // Cannot ungroup leaves
3375
+ canUngroup = false;
3376
+ break;
3377
+ }
3378
+
3379
+ if (selectedItem == group)
3380
+ {
3381
+ // Cannot ungroup root
3382
+ canUngroup = false;
33583383 break;
33593384 }
33603385 }
33613386
3362
- if (!hasRoot)
3387
+ if (canUngroup)
33633388 {
33643389 for (int i=0; i<group.selection.size(); i++)
33653390 {
3366
- Ungroup(group.selection.get(i));
3391
+ Object3D selectedItem = group.selection.get(i);
3392
+
3393
+ Ungroup(selectedItem);
33673394 }
33683395
33693396 ClearSelection(false);
....@@ -5325,6 +5352,7 @@
53255352
53265353 boolean allComposites = true;
53275354
5355
+ if (group.selection != null)
53285356 for (Enumeration e = group.selection.elements(); e.hasMoreElements();)
53295357 {
53305358 if (!(e.nextElement() instanceof Composite))
....@@ -6232,11 +6260,11 @@
62326260 private MenuItem lookAtItem;
62336261 private MenuItem lookFromItem;
62346262 private MenuItem switchViewItem;
6235
- private MenuItem cutItem;
6263
+ private JMenuItem cutItem;
62366264 private MenuItem undoItem;
62376265 private MenuItem redoItem;
62386266 private JMenuItem duplicateItem;
6239
- private MenuItem cloneItem;
6267
+ private JMenuItem cloneItem;
62406268 private MenuItem cloneSupportItem;
62416269 private MenuItem overwriteGeoItem;
62426270 private MenuItem overwriteMatItem;
....@@ -6257,13 +6285,13 @@
62576285 private MenuItem cloneGeometriesItem;
62586286 private MenuItem shareGeometriesItem;
62596287 private MenuItem mergeGeometriesItem;
6260
- private MenuItem copyItem;
6288
+ private JMenuItem copyItem;
62616289 private MenuItem pasteItem;
6262
- private MenuItem pasteIntoItem;
6263
- private MenuItem pasteLinkItem;
6264
- private MenuItem pasteCloneItem;
6265
- private MenuItem pasteExpandItem;
6266
- private MenuItem deleteItem;
6290
+ private JMenuItem pasteIntoItem;
6291
+ private JMenuItem pasteLinkItem;
6292
+ private JMenuItem pasteCloneItem;
6293
+ private JMenuItem pasteExpandItem;
6294
+ private JMenuItem deleteItem;
62676295 private MenuItem clearAllItem;
62686296 private MenuItem genUVItem;
62696297 private MenuItem genNormalsMESHItem;
....@@ -6331,7 +6359,7 @@
63316359 private MenuItem switchTransfoItem;
63326360 private MenuItem morphItem;
63336361 private MenuItem linkerItem;
6334
- private MenuItem ungroupItem;
6362
+ private JMenuItem ungroupItem;
63356363 private MenuItem editItem;
63366364 private MenuItem openWindowItem;
63376365 private MenuItem editLeafItem;