This is an automated email from the ASF dual-hosted git repository.

hansva pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hop.git


The following commit(s) were added to refs/heads/master by this push:
     new 9ee0f4a3d9 Fix for issue #2766 : Data orchestration perspective 
doesn't remember tabs
     new a89daff749 Merge pull request #2768 from mattcasters/master
9ee0f4a3d9 is described below

commit 9ee0f4a3d9e4dee2ca51300d3dba275d3bebf99a
Author: Matt Casters <[email protected]>
AuthorDate: Thu Mar 23 15:36:46 2023 +0100

    Fix for issue #2766 : Data orchestration perspective doesn't remember tabs
---
 .../hop/projects/xp/HopGuiStartProjectLoad.java    |  6 ++---
 .../main/java/org/apache/hop/ui/hopgui/HopGui.java | 30 +++++++++++++++++++++-
 .../ui/hopgui/delegates/HopGuiAuditDelegate.java   | 27 +++++++++++++------
 .../ui/hopgui/delegates/HopGuiFileDelegate.java    | 22 ++++++++--------
 4 files changed, 62 insertions(+), 23 deletions(-)

diff --git 
a/plugins/misc/projects/src/main/java/org/apache/hop/projects/xp/HopGuiStartProjectLoad.java
 
b/plugins/misc/projects/src/main/java/org/apache/hop/projects/xp/HopGuiStartProjectLoad.java
index 17aced5706..0325f9c114 100644
--- 
a/plugins/misc/projects/src/main/java/org/apache/hop/projects/xp/HopGuiStartProjectLoad.java
+++ 
b/plugins/misc/projects/src/main/java/org/apache/hop/projects/xp/HopGuiStartProjectLoad.java
@@ -116,13 +116,13 @@ public class HopGuiStartProjectLoad implements 
IExtensionPoint {
             }
 
             // Set system variables for HOP_HOME, HOP_METADATA_FOLDER, ...
-            // Sets the namespace in HopGui to the name of the project
+            // Sets the namespace in HopGui to the name of the project.
             //
             ProjectsGuiPlugin.enableHopGuiProject(lastProjectName, project, 
lastEnvironment);
 
-            // Don't open the files twice
+            // Don't open the files again in the HopGui startup code.
             //
-            HopGui.getInstance().setOpeningLastFiles(false);
+            hopGui.setOpeningLastFiles(false);
           }
         }
       } else {
diff --git a/ui/src/main/java/org/apache/hop/ui/hopgui/HopGui.java 
b/ui/src/main/java/org/apache/hop/ui/hopgui/HopGui.java
index 8ee185a083..61e29a2b2c 100644
--- a/ui/src/main/java/org/apache/hop/ui/hopgui/HopGui.java
+++ b/ui/src/main/java/org/apache/hop/ui/hopgui/HopGui.java
@@ -259,6 +259,7 @@ public class HopGui
   public HopGuiFileRefreshDelegate fileRefreshDelegate;
 
   private boolean openingLastFiles;
+  private boolean reOpeningFiles;
 
   protected HopGui() {
     this(Display.getCurrent());
@@ -418,7 +419,12 @@ public class HopGui
         () -> {
           openingLastFiles = true;
 
-          // Here the projects plugin opens up the last project/environment.
+          // We keep track of the fact that we might be re-opening files at 
this time.
+          // If we change the open files list while we're re-opening files 
things get chaotic and buggy.
+          //
+          reOpeningFiles = true;
+
+          // Here the 'projects' plugin opens up the last project/environment.
           // It sets openingLastFiles to false so the block below is not 
executed.
           //
           try {
@@ -437,6 +443,10 @@ public class HopGui
           if (openingLastFiles) {
             auditDelegate.openLastFiles();
           }
+
+          // We need to start tracking file history again.
+          //
+          reOpeningFiles = false;
         });
 
     // See if we need to show the Welcome dialog
@@ -1905,4 +1915,22 @@ public class HopGui
   public void setEventsHandler(HopGuiEventsHandler eventsHandler) {
     this.eventsHandler = eventsHandler;
   }
+
+  /**
+   * Gets reOpeningFiles
+   *
+   * @return value of reOpeningFiles
+   */
+  public boolean isReOpeningFiles() {
+    return reOpeningFiles;
+  }
+
+  /**
+   * Sets reOpeningFiles
+   *
+   * @param reOpeningFiles value of reOpeningFiles
+   */
+  public void setReOpeningFiles(boolean reOpeningFiles) {
+    this.reOpeningFiles = reOpeningFiles;
+  }
 }
diff --git 
a/ui/src/main/java/org/apache/hop/ui/hopgui/delegates/HopGuiAuditDelegate.java 
b/ui/src/main/java/org/apache/hop/ui/hopgui/delegates/HopGuiAuditDelegate.java
index 0f428634df..8fbb8927c5 100644
--- 
a/ui/src/main/java/org/apache/hop/ui/hopgui/delegates/HopGuiAuditDelegate.java
+++ 
b/ui/src/main/java/org/apache/hop/ui/hopgui/delegates/HopGuiAuditDelegate.java
@@ -17,6 +17,9 @@
 
 package org.apache.hop.ui.hopgui.delegates;
 
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
 import org.apache.commons.lang.StringUtils;
 import org.apache.hop.core.exception.HopException;
 import org.apache.hop.history.AuditList;
@@ -36,10 +39,6 @@ import org.apache.hop.ui.hopgui.perspective.IHopPerspective;
 import org.apache.hop.ui.hopgui.perspective.TabItemHandler;
 import org.apache.hop.ui.hopgui.perspective.metadata.MetadataPerspective;
 
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
 public class HopGuiAuditDelegate {
 
   public static final String STATE_PROPERTY_ACTIVE = "active";
@@ -109,11 +108,11 @@ public class HopGuiAuditDelegate {
                 if (fileTypeHandler != null) {
                   // Restore zoom, scroll and so on
                   AuditState auditState = auditStateMap.get(filename);
-                  if (auditState != null && fileTypeHandler != null) {
+                  if (auditState != null) {
                     
fileTypeHandler.applyStateProperties(auditState.getStateMap());
 
                     Boolean bActive = (Boolean) 
auditState.getStateMap().get(STATE_PROPERTY_ACTIVE);
-                    if (bActive != null && bActive.booleanValue()) {
+                    if (bActive != null && bActive) {
                       activeFileTypeHandler = fileTypeHandler;
                     }
                   }
@@ -132,6 +131,9 @@ public class HopGuiAuditDelegate {
         }
       }
     }
+    // Always start with an active data orchestration perspective.
+    //
+    HopGui.getDataOrchestrationPerspective().activate();
   }
 
   private void openMetadataObject(String className, String name) throws 
HopException {
@@ -154,7 +156,10 @@ public class HopGuiAuditDelegate {
             IHopMetadata metadata = serializer.load(name);
             MetadataManager<IHopMetadata> metadataManager =
                 new MetadataManager<>(
-                    HopGui.getInstance().getVariables(), metadataProvider, 
metadataClass, hopGui.getShell());
+                    HopGui.getInstance().getVariables(),
+                    metadataProvider,
+                    metadataClass,
+                    hopGui.getShell());
             MetadataEditor<IHopMetadata> editor = 
metadataManager.createEditor(metadata);
 
             // We assume that all tab items are closed so we can just open up 
a new editor for the
@@ -173,6 +178,12 @@ public class HopGuiAuditDelegate {
 
   /** Remember all the open files per perspective */
   public void writeLastOpenFiles() {
+    // When we're re-opening files at the start of the Hop GUI, we don't need 
to save the open files list.
+    // Things get chaotic otherwise.
+    //
+    if (hopGui.isReOpeningFiles()) {
+      return;
+    }
     if (!hopGui.getProps().openLastFile()) {
       return;
     }
@@ -183,7 +194,7 @@ public class HopGuiAuditDelegate {
       List<TabItemHandler> tabItems = perspective.getItems();
       if (tabItems != null) {
         // This perspective has the ability to handle multiple files.
-        // Lets's save the files in the given order...
+        // Let's save the files in the given order...
         //
         AuditStateMap auditStateMap = new AuditStateMap();
 
diff --git 
a/ui/src/main/java/org/apache/hop/ui/hopgui/delegates/HopGuiFileDelegate.java 
b/ui/src/main/java/org/apache/hop/ui/hopgui/delegates/HopGuiFileDelegate.java
index 5f7f742020..e9750eae54 100644
--- 
a/ui/src/main/java/org/apache/hop/ui/hopgui/delegates/HopGuiFileDelegate.java
+++ 
b/ui/src/main/java/org/apache/hop/ui/hopgui/delegates/HopGuiFileDelegate.java
@@ -17,6 +17,13 @@
 
 package org.apache.hop.ui.hopgui.delegates;
 
+import java.io.File;
+import java.io.OutputStream;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
 import org.apache.commons.lang.StringUtils;
 import org.apache.commons.vfs2.FileObject;
 import org.apache.hop.core.Const;
@@ -49,14 +56,6 @@ import org.apache.hop.workflow.WorkflowMeta;
 import org.apache.hop.workflow.WorkflowSvgPainter;
 import org.eclipse.swt.SWT;
 
-import java.io.File;
-import java.io.OutputStream;
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
 public class HopGuiFileDelegate {
 
   private HopGui hopGui;
@@ -112,9 +111,10 @@ public class HopGuiFileDelegate {
         // Do it again to test
         hopGui.handleFileCapabilities(hopFile, fileTypeHandler.hasChanged(), 
false, false);
       }
-        // Also save the state of Hop GUI
-        //
-        hopGui.auditDelegate.writeLastOpenFiles();
+
+      // Also save the state of Hop GUI
+      //
+      hopGui.auditDelegate.writeLastOpenFiles();
     }
 
     return fileTypeHandler;

Reply via email to