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

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


The following commit(s) were added to refs/heads/main by this push:
     new 7a78b45134 toggle project tree panel in merged data orchestration and 
file explorer perspective. fixes #6187 (#6207)
7a78b45134 is described below

commit 7a78b45134e798513e9b4ba7e6e2c61b7c67e3f0
Author: Bart Maertens <[email protected]>
AuthorDate: Tue Dec 23 13:38:24 2025 +0000

    toggle project tree panel in merged data orchestration and file explorer 
perspective. fixes #6187 (#6207)
---
 .../pages/hop-gui/perspective-configuration.adoc   |  5 +-
 .../pages/hop-gui/perspective-file-explorer.adoc   | 17 ++++++
 .../main/java/org/apache/hop/ui/hopgui/HopGui.java | 68 +++++++++++++++++++++-
 .../perspective/explorer/ExplorerPerspective.java  | 50 ++++++++++++++--
 .../explorer/config/ExplorerPerspectiveConfig.java | 11 ++++
 .../config/ExplorerPerspectiveConfigPlugin.java    | 38 ++++++++++++
 .../config/messages/messages_en_US.properties      |  2 +
 .../explorer/messages/messages_en_US.properties    |  1 +
 8 files changed, 184 insertions(+), 8 deletions(-)

diff --git 
a/docs/hop-user-manual/modules/ROOT/pages/hop-gui/perspective-configuration.adoc
 
b/docs/hop-user-manual/modules/ROOT/pages/hop-gui/perspective-configuration.adoc
index 136beb8442..e78ccaae9d 100644
--- 
a/docs/hop-user-manual/modules/ROOT/pages/hop-gui/perspective-configuration.adoc
+++ 
b/docs/hop-user-manual/modules/ROOT/pages/hop-gui/perspective-configuration.adoc
@@ -129,7 +129,10 @@ The following plugins are available by default:
 
 * xref:vfs/azure-blob-storage-vfs.adoc#_configuration[Azure Blob Storage] VFS 
configuration options.
 * xref:vfs/dropbox-vfs.adoc#_configuration[Dropbox] VFS configuration options.
-* xref:hop-gui/perspective-file-explorer.adoc[Explorer perspective] 
configuration options.
+* **Explorer perspective**: Configuration options for the file explorer 
perspective:
+  ** The initial depth to load not lazily: Controls how many folder levels are 
loaded immediately when opening folders.
+  ** The maximum file size to load: Sets the maximum file size (in MB) that 
will be loaded when opening files.
+  ** Show file explorer panel by default: When enabled, the file explorer 
panel (project tree) is shown by default when opening the explorer perspective. 
When disabled, the panel starts hidden.
 * xref:technology/google/index.adoc[Google Cloud] configuration options 
(service account JSON key file).
 * xref:vfs/google-drive-vfs.adoc#_configuration[Google Drive] VFS 
configuration options.
 * xref:projects/index.adoc[Project] configuration options
diff --git 
a/docs/hop-user-manual/modules/ROOT/pages/hop-gui/perspective-file-explorer.adoc
 
b/docs/hop-user-manual/modules/ROOT/pages/hop-gui/perspective-file-explorer.adoc
index 2653d6f952..adb349bd3b 100644
--- 
a/docs/hop-user-manual/modules/ROOT/pages/hop-gui/perspective-file-explorer.adoc
+++ 
b/docs/hop-user-manual/modules/ROOT/pages/hop-gui/perspective-file-explorer.adoc
@@ -48,6 +48,23 @@ image::hop-gui/perspective-explorer-toolbar-items.png[File 
explorer toolbar item
 * Refresh: Refresh the file list.
 * Show or hide files: Show or hide files or directories.
 
+== Toggling the File Explorer Panel
+
+When the File Explorer perspective is already active, clicking the File 
Explorer button in the perspectives toolbar (left side) will toggle the 
visibility of the file explorer panel (project tree). This allows you to 
maximize the workspace area when you don't need to see the file tree.
+
+* When the panel is visible: Clicking the File Explorer button hides the 
panel, maximizing the editor area.
+* When the panel is hidden: Clicking the File Explorer button shows the panel 
again, restoring the split view.
+
+TIP: The tooltip on the File Explorer button will indicate when you can toggle 
the panel: "File Explorer (Ctrl+Shift+E). Click the folder to show/hide the 
project tree"
+
+== Configuration Options
+
+The File Explorer perspective can be configured through the 
xref:hop-gui/perspective-configuration.adoc[Configuration perspective] under 
the Plugins tab. The following options are available:
+
+* **The initial depth to load not lazily**: Controls how many folder levels 
are loaded immediately when opening folders in the file explorer tree.
+* **The maximum file size to load**: Sets the maximum file size (in MB) that 
will be loaded when opening files in the explorer.
+* **Show file explorer panel by default**: When enabled, the file explorer 
panel (project tree) is shown by default when opening the explorer perspective. 
When disabled, the panel starts hidden, giving you more workspace for editing 
files.
+
 == Git integration
 
 === Description
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 e1f6619e32..9a246820ea 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
@@ -263,6 +263,7 @@ public class HopGui
   private Composite mainPerspectivesComposite;
   private HopPerspectiveManager perspectiveManager;
   private IHopPerspective activePerspective;
+  private ToolItem explorerPerspectiveToolItem;
 
   private static final PrintStream originalSystemOut = System.out;
   private static final PrintStream originalSystemErr = System.err;
@@ -601,7 +602,17 @@ public class HopGui
                   perspectivePlugin.getImageFile(),
                   tooltip,
                   // TODO: check if there is unnecessary refresh
-                  event -> setActivePerspective(perspective));
+                  event -> {
+                    // Special handling for ExplorerPerspective: if already 
active, toggle file
+                    // explorer panel instead of just activating
+                    if (perspective instanceof ExplorerPerspective
+                        && isActivePerspective(perspective)) {
+                      ((ExplorerPerspective) 
perspective).toggleFileExplorerPanel();
+                    } else {
+                      // Normal perspective activation
+                      setActivePerspective(perspective);
+                    }
+                  });
         } else {
           item = new ToolItem(this.perspectivesToolbar, SWT.RADIO);
           item.setToolTipText(tooltip);
@@ -609,8 +620,21 @@ public class HopGui
               SWT.Selection,
               event -> {
                 // Event is sent first to the unselected tool item and then 
the selected item.
-                // To avoid unnecessary refresh, only activate perspective on 
the selected item.
+                // To avoid unnecessary refresh, only process on the selected 
item.
                 if (item.getSelection()) {
+                  // Special handling for ExplorerPerspective: check if 
control is already on top
+                  // (truly active and visible) before toggling
+                  if (perspective instanceof ExplorerPerspective
+                      && mainPerspectivesComposite != null
+                      && !mainPerspectivesComposite.isDisposed()) {
+                    StackLayout layout = (StackLayout) 
mainPerspectivesComposite.getLayout();
+                    // Only toggle if the perspective control is already on 
top (truly active)
+                    if (layout.topControl == perspective.getControl()) {
+                      ((ExplorerPerspective) 
perspective).toggleFileExplorerPanel();
+                      return; // Don't call setActivePerspective
+                    }
+                  }
+                  // Normal perspective activation
                   setActivePerspective(perspective);
                 }
               });
@@ -627,6 +651,11 @@ public class HopGui
         }
         item.setData(perspective);
 
+        // Store reference to ExplorerPerspective ToolItem for dynamic tooltip 
updates
+        if (perspective instanceof ExplorerPerspective) {
+          explorerPerspectiveToolItem = item;
+        }
+
         // See if there's a shortcut for the perspective, add it to tooltip...
         KeyboardShortcut shortcut =
             GuiRegistry.getInstance()
@@ -1503,7 +1532,7 @@ public class HopGui
     layout.topControl = perspective.getControl();
     mainPerspectivesComposite.layout();
 
-    // Select toolbar item
+    // Select toolbar item and update tooltips
     //
     if (perspectivesToolbar != null && !perspectivesToolbar.isDisposed()) {
       for (ToolItem item : perspectivesToolbar.getItems()) {
@@ -1514,6 +1543,39 @@ public class HopGui
           item.setSelection(shaded);
         }
       }
+
+      // Update ExplorerPerspective tooltip based on active state
+      if (explorerPerspectiveToolItem != null && 
!explorerPerspectiveToolItem.isDisposed()) {
+        boolean isExplorerActive = perspective instanceof ExplorerPerspective;
+        String baseName =
+            BaseMessages.getString(ExplorerPerspective.PKG, 
"ExplorerPerspective.Name");
+        String tooltipText;
+
+        // Get keyboard shortcut if it exists
+        KeyboardShortcut shortcut =
+            GuiRegistry.getInstance()
+                .findKeyboardShortcut(
+                    ExplorerPerspective.class.getName(), "activate", 
Const.isOSX());
+
+        if (isExplorerActive) {
+          // Format: "File Explorer (Ctrl+Shift+E). Click the folder to 
show/hide the project tree"
+          String additionalText =
+              BaseMessages.getString(ExplorerPerspective.PKG, 
"ExplorerPerspective.Tooltip.Active");
+          if (shortcut != null) {
+            tooltipText = baseName + " (" + shortcut + "). " + additionalText;
+          } else {
+            tooltipText = baseName + ". " + additionalText;
+          }
+        } else {
+          // Format: "File Explorer (Ctrl+Shift+E)"
+          if (shortcut != null) {
+            tooltipText = baseName + " (" + shortcut + ')';
+          } else {
+            tooltipText = baseName;
+          }
+        }
+        explorerPerspectiveToolItem.setToolTipText(tooltipText);
+      }
     }
 
     // Notify the perspective that it has been activated.
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 be3bf9659d..130b0d8a1d 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
@@ -189,6 +189,8 @@ public class ExplorerPerspective implements 
IHopPerspective, TabClosable {
   @Getter private GuiMenuWidgets menuWidgets;
   private final List<TabItemHandler> items;
   private boolean showingHiddenFiles;
+  private Composite treeComposite;
+  private boolean fileExplorerPanelVisible = true;
   @Getter private String rootFolder;
   @Getter private String rootName;
   private String dragFile;
@@ -269,6 +271,16 @@ public class ExplorerPerspective implements 
IHopPerspective, TabClosable {
 
     sash.setWeights(new int[] {20, 80});
 
+    // Set initial file explorer panel visibility from configuration
+    Boolean visibleByDefault =
+        
ExplorerPerspectiveConfigSingleton.getConfig().getFileExplorerVisibleByDefault();
+    if (visibleByDefault != null && !visibleByDefault) {
+      fileExplorerPanelVisible = false;
+      sash.setMaximizedControl(tabFolder);
+    } else {
+      fileExplorerPanelVisible = true;
+    }
+
     // Refresh the file explorer when a project is activated or updated.
     //
     hopGui
@@ -381,15 +393,15 @@ public class ExplorerPerspective implements 
IHopPerspective, TabClosable {
   protected void createTree(Composite parent) {
     // Create composite
     //
-    Composite composite = new Composite(parent, SWT.BORDER);
+    treeComposite = new Composite(parent, SWT.BORDER);
     FormLayout layout = new FormLayout();
     layout.marginWidth = 0;
     layout.marginHeight = 0;
-    composite.setLayout(layout);
+    treeComposite.setLayout(layout);
 
     // Create toolbar
     //
-    toolBar = new ToolBar(composite, SWT.WRAP | SWT.LEFT | SWT.HORIZONTAL);
+    toolBar = new ToolBar(treeComposite, SWT.WRAP | SWT.LEFT | SWT.HORIZONTAL);
     toolBarWidgets = new GuiToolbarWidgets();
     toolBarWidgets.registerGuiPluginObject(this);
     toolBarWidgets.createToolbarWidgets(toolBar, GUI_PLUGIN_TOOLBAR_PARENT_ID);
@@ -401,7 +413,7 @@ public class ExplorerPerspective implements 
IHopPerspective, TabClosable {
     toolBar.pack();
     PropsUi.setLook(toolBar, Props.WIDGET_STYLE_TOOLBAR);
 
-    tree = new Tree(composite, SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL);
+    tree = new Tree(treeComposite, SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL);
     tree.setHeaderVisible(false);
     tree.addListener(SWT.Selection, event -> updateSelection());
     tree.addListener(SWT.DefaultSelection, this::openFile);
@@ -1966,6 +1978,36 @@ public class ExplorerPerspective implements 
IHopPerspective, TabClosable {
     activeHandler.updateGui();
   }
 
+  /**
+   * Toggle the visibility of the file explorer panel (tree). When hidden, the 
tab folder is
+   * maximized. When shown, normal sash weights are restored.
+   */
+  public void toggleFileExplorerPanel() {
+    if (sash == null || sash.isDisposed()) {
+      return;
+    }
+
+    fileExplorerPanelVisible = !fileExplorerPanelVisible;
+
+    if (fileExplorerPanelVisible) {
+      // Show the file explorer panel - restore normal layout
+      sash.setMaximizedControl(null);
+      sash.setWeights(new int[] {20, 80});
+    } else {
+      // Hide the file explorer panel - maximize the tab folder
+      sash.setMaximizedControl(tabFolder);
+    }
+  }
+
+  /**
+   * Check if the file explorer panel is currently visible.
+   *
+   * @return true if the file explorer panel is visible, false otherwise
+   */
+  public boolean isFileExplorerPanelVisible() {
+    return fileExplorerPanelVisible;
+  }
+
   public static class DetermineRootFolderExtension {
     public HopGui hopGui;
     public String rootFolder;
diff --git 
a/ui/src/main/java/org/apache/hop/ui/hopgui/perspective/explorer/config/ExplorerPerspectiveConfig.java
 
b/ui/src/main/java/org/apache/hop/ui/hopgui/perspective/explorer/config/ExplorerPerspectiveConfig.java
index 3a5e4725be..e6c0175105 100644
--- 
a/ui/src/main/java/org/apache/hop/ui/hopgui/perspective/explorer/config/ExplorerPerspectiveConfig.java
+++ 
b/ui/src/main/java/org/apache/hop/ui/hopgui/perspective/explorer/config/ExplorerPerspectiveConfig.java
@@ -23,16 +23,19 @@ public class ExplorerPerspectiveConfig {
 
   private String lazyLoadingDepth;
   private String fileLoadingMaxSize;
+  private Boolean fileExplorerVisibleByDefault;
 
   public ExplorerPerspectiveConfig() {
     this.lazyLoadingDepth = "0";
     this.fileLoadingMaxSize = "16";
+    this.fileExplorerVisibleByDefault = true;
   }
 
   public ExplorerPerspectiveConfig(ExplorerPerspectiveConfig config) {
     this();
     this.lazyLoadingDepth = config.lazyLoadingDepth;
     this.fileLoadingMaxSize = config.fileLoadingMaxSize;
+    this.fileExplorerVisibleByDefault = config.fileExplorerVisibleByDefault;
   }
 
   public String getLazyLoadingDepth() {
@@ -50,4 +53,12 @@ public class ExplorerPerspectiveConfig {
   public void setFileLoadingMaxSize(String fileLoadingMaxSize) {
     this.fileLoadingMaxSize = fileLoadingMaxSize;
   }
+
+  public Boolean getFileExplorerVisibleByDefault() {
+    return fileExplorerVisibleByDefault;
+  }
+
+  public void setFileExplorerVisibleByDefault(Boolean 
fileExplorerVisibleByDefault) {
+    this.fileExplorerVisibleByDefault = fileExplorerVisibleByDefault;
+  }
 }
diff --git 
a/ui/src/main/java/org/apache/hop/ui/hopgui/perspective/explorer/config/ExplorerPerspectiveConfigPlugin.java
 
b/ui/src/main/java/org/apache/hop/ui/hopgui/perspective/explorer/config/ExplorerPerspectiveConfigPlugin.java
index e63c362501..831f6101b4 100644
--- 
a/ui/src/main/java/org/apache/hop/ui/hopgui/perspective/explorer/config/ExplorerPerspectiveConfigPlugin.java
+++ 
b/ui/src/main/java/org/apache/hop/ui/hopgui/perspective/explorer/config/ExplorerPerspectiveConfigPlugin.java
@@ -32,6 +32,7 @@ import 
org.apache.hop.ui.core.gui.IGuiPluginCompositeWidgetsListener;
 import org.apache.hop.ui.core.widget.TextVar;
 import org.apache.hop.ui.hopgui.HopGui;
 import 
org.apache.hop.ui.hopgui.perspective.configuration.tabs.ConfigPluginOptionsTab;
+import org.eclipse.swt.widgets.Button;
 import org.eclipse.swt.widgets.Control;
 import picocli.CommandLine;
 
@@ -47,6 +48,8 @@ public class ExplorerPerspectiveConfigPlugin
 
   private static final String WIDGET_ID_LAZY_LOADING_DEPTH = 
"10000-lazy-loading-depth";
   private static final String WIDGET_ID_FILE_LOADING_MAX_SIZE = 
"10100-file-loading-max-size";
+  private static final String WIDGET_ID_FILE_EXPLORER_VISIBLE_BY_DEFAULT =
+      "10200-file-explorer-visible-by-default";
 
   @GuiWidgetElement(
       id = WIDGET_ID_LAZY_LOADING_DEPTH,
@@ -72,6 +75,17 @@ public class ExplorerPerspectiveConfigPlugin
       description = "For the explorer: the maximum file size to load")
   private String fileLoadingMaxSize;
 
+  @GuiWidgetElement(
+      id = WIDGET_ID_FILE_EXPLORER_VISIBLE_BY_DEFAULT,
+      parentId = ConfigPluginOptionsTab.GUI_WIDGETS_PARENT_ID,
+      type = GuiElementType.CHECKBOX,
+      label = "i18n::ExplorerPerspectiveConfig.FileExplorerVisible.Label",
+      toolTip = "i18n::ExplorerPerspectiveConfig.FileExplorerVisible.Tooltip")
+  @CommandLine.Option(
+      names = {"-exv", "--explorer-file-explorer-visible-by-default"},
+      description = "Show the file explorer panel by default in the explorer 
perspective")
+  private Boolean fileExplorerVisibleByDefault = true;
+
   /**
    * Gets instance
    *
@@ -83,6 +97,8 @@ public class ExplorerPerspectiveConfigPlugin
     ExplorerPerspectiveConfig config = 
ExplorerPerspectiveConfigSingleton.getConfig();
     instance.lazyLoadingDepth = config.getLazyLoadingDepth();
     instance.fileLoadingMaxSize = config.getFileLoadingMaxSize();
+    Boolean visibleByDefault = config.getFileExplorerVisibleByDefault();
+    instance.fileExplorerVisibleByDefault = visibleByDefault != null ? 
visibleByDefault : true;
 
     return instance;
   }
@@ -111,6 +127,15 @@ public class ExplorerPerspectiveConfigPlugin
         changed = true;
       }
 
+      if (fileExplorerVisibleByDefault != null) {
+        config.setFileExplorerVisibleByDefault(fileExplorerVisibleByDefault);
+        log.logBasic(
+            "Explorer perspective: file explorer visible by default is set to 
'"
+                + fileExplorerVisibleByDefault
+                + "'");
+        changed = true;
+      }
+
       // Save to file if anything changed
       //
       if (changed) {
@@ -151,6 +176,11 @@ public class ExplorerPerspectiveConfigPlugin
           fileLoadingMaxSize = ((TextVar) control).getText();
           
ExplorerPerspectiveConfigSingleton.getConfig().setFileLoadingMaxSize(fileLoadingMaxSize);
           break;
+        case WIDGET_ID_FILE_EXPLORER_VISIBLE_BY_DEFAULT:
+          fileExplorerVisibleByDefault = ((Button) control).getSelection();
+          ExplorerPerspectiveConfigSingleton.getConfig()
+              .setFileExplorerVisibleByDefault(fileExplorerVisibleByDefault);
+          break;
         default:
           break;
       }
@@ -179,4 +209,12 @@ public class ExplorerPerspectiveConfigPlugin
   public void setFileLoadingMaxSize(String fileLoadingMaxSize) {
     this.fileLoadingMaxSize = fileLoadingMaxSize;
   }
+
+  public Boolean getFileExplorerVisibleByDefault() {
+    return fileExplorerVisibleByDefault != null ? fileExplorerVisibleByDefault 
: true;
+  }
+
+  public void setFileExplorerVisibleByDefault(Boolean 
fileExplorerVisibleByDefault) {
+    this.fileExplorerVisibleByDefault = fileExplorerVisibleByDefault;
+  }
 }
diff --git 
a/ui/src/main/resources/org/apache/hop/ui/hopgui/perspective/explorer/config/messages/messages_en_US.properties
 
b/ui/src/main/resources/org/apache/hop/ui/hopgui/perspective/explorer/config/messages/messages_en_US.properties
index 9cee0f67df..4afe25f5f6 100644
--- 
a/ui/src/main/resources/org/apache/hop/ui/hopgui/perspective/explorer/config/messages/messages_en_US.properties
+++ 
b/ui/src/main/resources/org/apache/hop/ui/hopgui/perspective/explorer/config/messages/messages_en_US.properties
@@ -19,3 +19,5 @@ ExplorerPerspectiveConfig.FileSize.Label=The maximum file 
size to load
 ExplorerPerspectiveConfig.FileSize.Tooltip=The maximum file size to load
 ExplorerPerspectiveConfig.LazyLoading.Label=The initial depth to load not 
lazily
 ExplorerPerspectiveConfig.LazyLoading.Tooltip=The initial depth to load not 
lazily
+ExplorerPerspectiveConfig.FileExplorerVisible.Label=Show file explorer panel 
by default
+ExplorerPerspectiveConfig.FileExplorerVisible.Tooltip=When enabled, the file 
explorer panel (project tree) is shown by default when opening the explorer 
perspective
diff --git 
a/ui/src/main/resources/org/apache/hop/ui/hopgui/perspective/explorer/messages/messages_en_US.properties
 
b/ui/src/main/resources/org/apache/hop/ui/hopgui/perspective/explorer/messages/messages_en_US.properties
index 6bc07d8f0c..ec27856ff7 100644
--- 
a/ui/src/main/resources/org/apache/hop/ui/hopgui/perspective/explorer/messages/messages_en_US.properties
+++ 
b/ui/src/main/resources/org/apache/hop/ui/hopgui/perspective/explorer/messages/messages_en_US.properties
@@ -44,6 +44,7 @@ ExplorerPerspective.Menu.Rename=Rename
 ExplorerPerspective.Menu.ExpandAll=Expand All
 ExplorerPerspective.Menu.CollapseAll=Collapse All
 ExplorerPerspective.Name=File Explorer
+ExplorerPerspective.Tooltip.Active=Click the folder to show/hide the project 
tree
 ExplorerPerspective.ToolbarElement.CreateFolder.Tooltip=Create folder
 ExplorerPerspective.ToolbarElement.Delete.Tooltip=Delete selected file
 ExplorerPerspective.ToolbarElement.Open.Tooltip=Open selected file

Reply via email to