You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hop.apache.org by ha...@apache.org on 2021/12/20 07:27:29 UTC

[incubator-hop] branch master updated: HOP-1496 : Duplicate files displayed in the file explorer tabs

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/incubator-hop.git


The following commit(s) were added to refs/heads/master by this push:
     new d5d27bc  HOP-1496 : Duplicate files displayed in the file explorer tabs
     new 42aeefe  Merge pull request #1229 from uraychang/dulplicateFileExplorerTab
d5d27bc is described below

commit d5d27bcd4a25c04d8ac80504b104849defa7cf22
Author: ray.chang <ur...@gmail.com>
AuthorDate: Mon Dec 20 14:17:46 2021 +0800

    HOP-1496 : Duplicate files displayed in the file explorer tabs
---
 .../hop/ui/hopgui/perspective/explorer/ExplorerPerspective.java   | 8 ++++++--
 .../explorer/file/types/base/BaseExplorerFileType.java            | 6 +++---
 2 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/ui/src/main/java/org/apache/hop/ui/hopgui/perspective/explorer/ExplorerPerspective.java b/ui/src/main/java/org/apache/hop/ui/hopgui/perspective/explorer/ExplorerPerspective.java
index 9158e83..b807c3e 100644
--- a/ui/src/main/java/org/apache/hop/ui/hopgui/perspective/explorer/ExplorerPerspective.java
+++ b/ui/src/main/java/org/apache/hop/ui/hopgui/perspective/explorer/ExplorerPerspective.java
@@ -542,7 +542,12 @@ public class ExplorerPerspective implements IHopPerspective {
     }
   }
 
-  public CTabItem addFile(ExplorerFile explorerFile, IExplorerFileTypeHandler renderer) {
+  public void addFile(ExplorerFile explorerFile, IExplorerFileTypeHandler renderer) {
+
+    if(files.contains(explorerFile)){
+      return;
+    }
+
     PropsUi props = PropsUi.getInstance();
 
     // Create tab item
@@ -619,7 +624,6 @@ public class ExplorerPerspective implements IHopPerspective {
 
     updateGui();
 
-    return tabItem;
   }
 
   private void selectInTree(String filename) {
diff --git a/ui/src/main/java/org/apache/hop/ui/hopgui/perspective/explorer/file/types/base/BaseExplorerFileType.java b/ui/src/main/java/org/apache/hop/ui/hopgui/perspective/explorer/file/types/base/BaseExplorerFileType.java
index d085fd8..b42d616 100644
--- a/ui/src/main/java/org/apache/hop/ui/hopgui/perspective/explorer/file/types/base/BaseExplorerFileType.java
+++ b/ui/src/main/java/org/apache/hop/ui/hopgui/perspective/explorer/file/types/base/BaseExplorerFileType.java
@@ -19,6 +19,7 @@
 package org.apache.hop.ui.hopgui.perspective.explorer.file.types.base;
 
 import org.apache.commons.vfs2.FileObject;
+import org.apache.hop.core.Const;
 import org.apache.hop.core.exception.HopException;
 import org.apache.hop.core.file.IHasFilename;
 import org.apache.hop.core.variables.IVariables;
@@ -164,7 +165,7 @@ public abstract class BaseExplorerFileType<T extends IExplorerFileTypeHandler>
       ExplorerPerspective perspective = ExplorerPerspective.getInstance();
 
       ExplorerFile explorerFile = new ExplorerFile();
-      explorerFile.setName(name);
+      explorerFile.setName(Const.NVL(name, ""));
       explorerFile.setFilename(filename);
       explorerFile.setFileType(this);
       explorerFile.setTabImage(perspective.getFileTypeImage(this));
@@ -172,8 +173,7 @@ public abstract class BaseExplorerFileType<T extends IExplorerFileTypeHandler>
       T fileTypeHandler = createFileTypeHandler(hopGui, perspective, explorerFile);
       explorerFile.setFileTypeHandler(fileTypeHandler);
 
-      CTabItem tabItem = perspective.addFile(explorerFile, fileTypeHandler);
-      explorerFile.setName(tabItem.getText());
+      perspective.addFile(explorerFile, fileTypeHandler);
 
       return fileTypeHandler;
     } catch (Exception e) {