From 8f1afe25ea8fc8801aab66331c32a50859a758c2 Mon Sep 17 00:00:00 2001
From: Normand Briere <nbriere@noware.ca>
Date: Mon, 12 Aug 2019 18:20:19 -0400
Subject: [PATCH] Fix version manager.

---
 GroupEditor.java |   63 ++++++++++++++++++++++---------
 1 files changed, 44 insertions(+), 19 deletions(-)

diff --git a/GroupEditor.java b/GroupEditor.java
index 1e9db13..e09d28f 100644
--- a/GroupEditor.java
+++ b/GroupEditor.java
@@ -410,6 +410,8 @@
         {
             copy.versionlist = new Object3D[100];
             copy.versionindex = -1;
+            
+            Save(true);
         }
         
 		if(ui)
@@ -641,11 +643,9 @@
 		oe.cameraMenu.add(lookAtItem = new MenuItem("Set Interest"));
 		//cameraMenu.add(lookFromItem = new MenuItem("Look From Selection"));
 		//cameraMenu.add(switchViewItem = new MenuItem("Reverse View"));
-		editLeafItem = oe.cameraMenu.add(new MenuItem("Edit Leaf"));
 		oe.cameraMenu.add("-");
 		openWindowItem =  oe.cameraMenu.add(new MenuItem("Edit copy..."));
 		openWindowItem.addActionListener(this);
-		editLeafItem.addActionListener(this);
 		lookAtItem.addActionListener(this);
 		//lookFromItem.addActinoListener(this);
 		//switchViewItem.addActionListener(this);
@@ -893,6 +893,9 @@
 		shareGeometriesItem.addActionListener(this);
 		mergeGeometriesItem = menu.add(new MenuItem("Merge Geometries"));
 		mergeGeometriesItem.addActionListener(this);
+		menu.add("-");
+		editLeafItem = menu.add(new MenuItem("Edit leaf..."));
+		editLeafItem.addActionListener(this);
         if (Globals.ADVANCED)
         {
             // Pretty much the same as duplicate and clone.
@@ -1026,22 +1029,22 @@
                 
                 if (Globals.ADVANCED)
                 {
-                    oe.toolbarPanel.add(maxButton = GetButton("icons/add-128.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
-                    maxButton.setToolTipText("Maximize window");
-                    maxButton.addActionListener(this);
+//                    oe.toolbarPanel.add(maxButton = GetButton("icons/add-128.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
+//                    maxButton.setToolTipText("Maximize window");
+//                    maxButton.addActionListener(this);
                 }
                 
-                cButton gcButton;
-                
-		oe.toolbarPanel.add(gcButton = GetButton("icons/trash.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
-                gcButton.setToolTipText("Garbage collect");
-        gcButton.addActionListener(new ActionListener()
-        {
-                public void actionPerformed(ActionEvent e)
-                {
-                    System.gc();
-                }
-        });
+//                cButton gcButton;
+//                
+//		oe.toolbarPanel.add(gcButton = GetButton("icons/trash.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
+//                gcButton.setToolTipText("Garbage collect");
+//                gcButton.addActionListener(new ActionListener()
+//                {
+//                        public void actionPerformed(ActionEvent e)
+//                        {
+//                            System.gc();
+//                        }
+//                });
                 
 		oe.toolbarPanel.add(collapseButton = GetButton("icons/collapse.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
                 collapseButton.setToolTipText("Collapse toolbar");
@@ -1162,7 +1165,7 @@
                 
                 // INSERT
                 row1.add(gridButton = GetButton("icons/grid.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
-                gridButton.setToolTipText("Create grid");
+                gridButton.setToolTipText("Create ground");
                                 gridButton.addActionListener(this);
 
                 row1.add(boxButton = GetButton("icons/box.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
@@ -1454,6 +1457,14 @@
 	
         void EditObject(Object3D obj)
         {
+            assert(obj instanceof Composite);
+            
+            if (obj.versionlist == null)
+            {
+                obj.versionlist = new Object3D[100];
+                obj.versionindex = -1;
+            }
+            
             cRadio radioButton = new cRadio(obj.name);
             
             // June 2019. Patch to avoid bug with transparency.
@@ -3892,6 +3903,7 @@
                 } else
 		if (source == rootButton)
 		{
+                    Replace();
                     Object3D obj;
                     for (Enumeration e = group.selection.elements(); e.hasMoreElements();)
                     {
@@ -4028,8 +4040,6 @@
                     
                     copy = group;
                     
-                    SetUndoStates();
-
                     //Globals.theRenderer.object = group;
                     if(!useclient)
                     {
@@ -4057,6 +4067,8 @@
                      */
                     radio.layout.doClick();
                     
+                    SetUndoStates();
+
                     ClearUnpinned();
                     
                     //Grafreed.Assert(group != null);
@@ -5291,6 +5303,19 @@
             flashSelectionButton.setEnabled(enabled);
             
             clearPanelButton.setEnabled(!listUI.isEmpty());
+            
+            boolean allComposites = true;
+            
+            for (Enumeration e = group.selection.elements(); e.hasMoreElements();)
+            {
+                    if (!(e.nextElement() instanceof Composite))
+                    {
+                        allComposites = false;
+                        break;
+                    }
+            }
+            
+            rootButton.setEnabled(allComposites);
         }
 
         void refreshContents(boolean cp)

--
Gitblit v1.6.2