This is an automated email from the ASF dual-hosted git repository.
mattcasters 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 7ee5d9ccf9 issue #7380 : follow active file in the explorer (#7381)
7ee5d9ccf9 is described below
commit 7ee5d9ccf9b937039cd806a689ce3abb431845b3
Author: Matt Casters <[email protected]>
AuthorDate: Tue Jun 30 21:26:04 2026 +0200
issue #7380 : follow active file in the explorer (#7381)
* issue #7380 : follow active file in the explorer with configuration option
---
.../perspective/explorer/ExplorerPerspective.java | 74 ++++++++++++++++++----
.../explorer/config/ExplorerPerspectiveConfig.java | 11 ++++
.../config/ExplorerPerspectiveConfigPlugin.java | 33 ++++++++++
.../config/messages/messages_en_US.properties | 4 ++
.../config/messages/messages_fr_FR.properties | 4 ++
.../config/messages/messages_pt_BR.properties | 4 ++
6 files changed, 119 insertions(+), 11 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 d33850c40b..5e1f94fb9d 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
@@ -394,14 +394,10 @@ public class ExplorerPerspective implements
IHopPerspective, TabClosable, IFileD
activeTabFolder = folder;
folder.setSelection(item);
folder.showItem(item);
- Object handler = item.getData();
- if (handler instanceof IHopFileTypeHandler) {
+ if (item.getData() instanceof IHopFileTypeHandler
handler) {
hopGui.handleFileCapabilities(
- ((IHopFileTypeHandler) handler).getFileType(),
- (IHopFileTypeHandler) handler,
- ((IHopFileTypeHandler) handler).hasChanged(),
- false,
- false);
+ handler.getFileType(), handler,
handler.hasChanged(), false, false);
+ selectInTree(handler.getFilename());
}
}
break;
@@ -1752,6 +1748,13 @@ public class ExplorerPerspective implements
IHopPerspective, TabClosable, IFileD
notifyZoomHandlerForActiveTab();
updateWebUrlForActiveTab();
}
+ CTabItem selection = folder.getSelection();
+ if (selection != null) {
+ Object data = selection.getData();
+ if (data instanceof IHopFileTypeHandler handler) {
+ selectInTree(handler.getFilename());
+ }
+ }
});
folder.addCTabFolder2Listener(
new CTabFolder2Adapter() {
@@ -2128,6 +2131,7 @@ public class ExplorerPerspective implements
IHopPerspective, TabClosable, IFileD
if (EnvironmentUtils.getInstance().isWeb()) {
updateWebUrlForActiveTab();
}
+ selectInTree(fileTypeHandler.getFilename());
return;
}
@@ -2187,6 +2191,7 @@ public class ExplorerPerspective implements
IHopPerspective, TabClosable, IFileD
if (EnvironmentUtils.getInstance().isWeb()) {
updateWebUrlForActiveTab();
}
+ selectInTree(fileTypeHandler.getFilename());
}
/**
@@ -2207,6 +2212,7 @@ public class ExplorerPerspective implements
IHopPerspective, TabClosable, IFileD
if (EnvironmentUtils.getInstance().isWeb()) {
updateWebUrlForActiveTab();
}
+ selectInTree(pipelineMeta.getFilename());
return handler.getTypeHandler();
}
@@ -2265,6 +2271,7 @@ public class ExplorerPerspective implements
IHopPerspective, TabClosable, IFileD
if (EnvironmentUtils.getInstance().isWeb()) {
updateWebUrlForActiveTab();
}
+ selectInTree(pipelineMeta.getFilename());
return pipelineGraph;
}
@@ -2287,6 +2294,7 @@ public class ExplorerPerspective implements
IHopPerspective, TabClosable, IFileD
if (EnvironmentUtils.getInstance().isWeb()) {
updateWebUrlForActiveTab();
}
+ selectInTree(workflowMeta.getFilename());
return handler.getTypeHandler();
}
@@ -2345,12 +2353,24 @@ public class ExplorerPerspective implements
IHopPerspective, TabClosable, IFileD
if (EnvironmentUtils.getInstance().isWeb()) {
updateWebUrlForActiveTab();
}
+ selectInTree(workflowMeta.getFilename());
return workflowGraph;
}
/** Select the corresponding file in the left-hand tree */
private void selectInTree(String filename) {
+ selectInTree(filename, true);
+ }
+
+ private void selectInTree(String filename, boolean automatic) {
+ if (automatic) {
+ Boolean activeFileSelection =
+
ExplorerPerspectiveConfigSingleton.getConfig().getActiveFileSelection();
+ if (activeFileSelection != null && !activeFileSelection) {
+ return;
+ }
+ }
if (Utils.isEmpty(filename)) {
return;
@@ -2365,15 +2385,47 @@ public class ExplorerPerspective implements
IHopPerspective, TabClosable, IFileD
}
}
+ private boolean isDescendant(String parentPath, String childPath) {
+ if (parentPath == null || childPath == null) {
+ return false;
+ }
+ try {
+ FileObject parentFile = HopVfs.getFileObject(parentPath);
+ FileObject childFile = HopVfs.getFileObject(childPath);
+ return parentFile.getName().isDescendent(childFile.getName());
+ } catch (Exception e) {
+ // Fallback
+ String parent = parentPath.replace('\\', '/');
+ String child = childPath.replace('\\', '/');
+ if (!parent.endsWith("/")) {
+ parent += "/";
+ }
+ return child.startsWith(parent);
+ }
+ }
+
private boolean selectInTree(TreeItem item, String filename) {
TreeItemFolder tif = (TreeItemFolder) item.getData();
if (tif != null && tif.path.equals(filename)) {
tree.setSelection(tif.treeItem);
+ tree.showItem(tif.treeItem);
return true;
}
- for (TreeItem child : item.getItems()) {
- if (selectInTree(child, filename)) {
- return true;
+ if (tif != null && tif.folder && isDescendant(tif.path, filename)) {
+ if (!tif.loaded) {
+ BusyIndicator.showWhile(
+ hopGui.getDisplay(),
+ () -> {
+ refreshFolder(item, tif.path, tif.depth + 1);
+ tif.loaded = true;
+ });
+ }
+ item.setExpanded(true);
+ TreeMemory.getInstance().storeExpanded(FILE_EXPLORER_TREE, item, true);
+ for (TreeItem child : item.getItems()) {
+ if (selectInTree(child, filename)) {
+ return true;
+ }
}
}
return false;
@@ -2629,7 +2681,7 @@ public class ExplorerPerspective implements
IHopPerspective, TabClosable, IFileD
public void selectInTree() {
CTabFolder active = getTargetTabFolder();
if (active.getSelectionIndex() >= 0) {
- this.selectInTree(getActiveFileTypeHandler().getFilename());
+ this.selectInTree(getActiveFileTypeHandler().getFilename(), false);
}
}
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 9c7b541949..a14fd63aa9 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
@@ -25,12 +25,14 @@ public class ExplorerPerspectiveConfig {
private String fileLoadingMaxSize;
private Boolean fileExplorerVisibleByDefault;
private Boolean openingHelpFiles;
+ private Boolean activeFileSelection;
public ExplorerPerspectiveConfig() {
this.lazyLoadingDepth = "0";
this.fileLoadingMaxSize = "16";
this.fileExplorerVisibleByDefault = true;
this.openingHelpFiles = false;
+ this.activeFileSelection = true;
}
public ExplorerPerspectiveConfig(ExplorerPerspectiveConfig config) {
@@ -39,6 +41,7 @@ public class ExplorerPerspectiveConfig {
this.fileLoadingMaxSize = config.fileLoadingMaxSize;
this.fileExplorerVisibleByDefault = config.fileExplorerVisibleByDefault;
this.openingHelpFiles = config.openingHelpFiles;
+ this.activeFileSelection = config.activeFileSelection;
}
public String getLazyLoadingDepth() {
@@ -72,4 +75,12 @@ public class ExplorerPerspectiveConfig {
public void setOpeningHelpFiles(Boolean openingHelpFiles) {
this.openingHelpFiles = openingHelpFiles;
}
+
+ public Boolean getActiveFileSelection() {
+ return activeFileSelection != null ? activeFileSelection : true;
+ }
+
+ public void setActiveFileSelection(Boolean activeFileSelection) {
+ this.activeFileSelection = activeFileSelection;
+ }
}
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 a1139eb0a9..13c2ab7cf2 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
@@ -51,6 +51,7 @@ public class ExplorerPerspectiveConfigPlugin
private static final String WIDGET_ID_FILE_EXPLORER_VISIBLE_BY_DEFAULT =
"10200-file-explorer-visible-by-default";
private static final String WIDGET_ID_OPEN_HELP_FILES =
"10300-open-help-files";
+ private static final String WIDGET_ID_ACTIVE_FILE_SELECTION =
"10400-active-file-selection";
@GuiWidgetElement(
id = WIDGET_ID_LAZY_LOADING_DEPTH,
@@ -98,6 +99,17 @@ public class ExplorerPerspectiveConfigPlugin
description = "Open help files in Hop GUI tabs instead of external
browser")
private Boolean openingHelpFiles;
+ @GuiWidgetElement(
+ id = WIDGET_ID_ACTIVE_FILE_SELECTION,
+ parentId = ConfigPluginOptionsTab.GUI_WIDGETS_PARENT_ID,
+ type = GuiElementType.CHECKBOX,
+ label = "i18n::ExplorerPerspectiveConfig.ActiveFileSelection.Label",
+ toolTip = "i18n::ExplorerPerspectiveConfig.ActiveFileSelection.Tooltip")
+ @CommandLine.Option(
+ names = {"-exafs", "--explorer-active-file-selection"},
+ description = "Automatically select the active tab file in the file
explorer tree")
+ private Boolean activeFileSelection = true;
+
/**
* Gets instance
*
@@ -112,6 +124,7 @@ public class ExplorerPerspectiveConfigPlugin
Boolean visibleByDefault = config.getFileExplorerVisibleByDefault();
instance.fileExplorerVisibleByDefault = visibleByDefault != null ?
visibleByDefault : true;
instance.openingHelpFiles = config.isOpeningHelpFiles();
+ instance.activeFileSelection = config.getActiveFileSelection();
return instance;
}
@@ -156,6 +169,13 @@ public class ExplorerPerspectiveConfigPlugin
changed = true;
}
+ if (activeFileSelection != null) {
+ config.setActiveFileSelection(activeFileSelection);
+ log.logDetailed(
+ "Explorer perspective: active file selection is set to '" +
activeFileSelection + "'");
+ changed = true;
+ }
+
// Save to file if anything changed
//
if (changed) {
@@ -205,6 +225,11 @@ public class ExplorerPerspectiveConfigPlugin
openingHelpFiles = ((Button) control).getSelection();
ExplorerPerspectiveConfigSingleton.getConfig().setOpeningHelpFiles(openingHelpFiles);
break;
+ case WIDGET_ID_ACTIVE_FILE_SELECTION:
+ activeFileSelection = ((Button) control).getSelection();
+ ExplorerPerspectiveConfigSingleton.getConfig()
+ .setActiveFileSelection(activeFileSelection);
+ break;
default:
break;
}
@@ -249,4 +274,12 @@ public class ExplorerPerspectiveConfigPlugin
public void setOpeningHelpFiles(Boolean openingHelpFiles) {
this.openingHelpFiles = openingHelpFiles;
}
+
+ public Boolean getActiveFileSelection() {
+ return activeFileSelection != null ? activeFileSelection : true;
+ }
+
+ public void setActiveFileSelection(Boolean activeFileSelection) {
+ this.activeFileSelection = activeFileSelection;
+ }
}
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 7938d11c8f..b19a2b9820 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
@@ -24,3 +24,7 @@ ExplorerPerspectiveConfig.FileExplorerVisible.Tooltip=When
enabled, the file exp
ExplorerPerspectiveConfig.OpenHelpFiles.Label=Open help files in Hop GUI tabs
instead of external browser
ExplorerPerspectiveConfig.OpenHelpFiles.Tooltip=When checked, help links will
open as a new tab within the Hop GUI using the internal HTML viewer. Unchecked
will open the system default browser.
+
+ExplorerPerspectiveConfig.ActiveFileSelection.Label=Select active file in tree
automatically
+ExplorerPerspectiveConfig.ActiveFileSelection.Tooltip=Automatically select the
active tab file in the file explorer tree on the left hand side when it is
shown in a tab.
+
diff --git
a/ui/src/main/resources/org/apache/hop/ui/hopgui/perspective/explorer/config/messages/messages_fr_FR.properties
b/ui/src/main/resources/org/apache/hop/ui/hopgui/perspective/explorer/config/messages/messages_fr_FR.properties
index d2cc325a23..c0feb83e1d 100644
---
a/ui/src/main/resources/org/apache/hop/ui/hopgui/perspective/explorer/config/messages/messages_fr_FR.properties
+++
b/ui/src/main/resources/org/apache/hop/ui/hopgui/perspective/explorer/config/messages/messages_fr_FR.properties
@@ -23,3 +23,7 @@ ExplorerPerspectiveConfig.FileExplorerVisible.Tooltip=Lorsque
cette option est a
ExplorerPerspectiveConfig.OpenHelpFiles.Label=Ouvrir l''aide dans Hop
plut\u00F4t que dans un navigateur externe
ExplorerPerspectiveConfig.FileSize.Tooltip=Taille maximale des fichiers \u00E0
charger
ExplorerPerspectiveConfig.OpenHelpFiles.Tooltip=Lorsque cette option est
coch\u00E9e, l''aide s''ouvrent dans un nouvel onglet de Hop \u00E0 l''aide de
la visionneuse HTML interne., sinon le navigateur par d\u00E9faut du
syst\u00E8me est utilis\u00E9.
+
+ExplorerPerspectiveConfig.ActiveFileSelection.Label=S\u00E9lectionner
automatiquement le fichier actif dans l''arborescence
+ExplorerPerspectiveConfig.ActiveFileSelection.Tooltip=S\u00E9lectionner
automatiquement le fichier de l''onglet actif dans l''explorateur de fichiers
de gauche lorsqu''il est affich\u00E9.
+
diff --git
a/ui/src/main/resources/org/apache/hop/ui/hopgui/perspective/explorer/config/messages/messages_pt_BR.properties
b/ui/src/main/resources/org/apache/hop/ui/hopgui/perspective/explorer/config/messages/messages_pt_BR.properties
index 7ccf3985ba..54d847b622 100644
---
a/ui/src/main/resources/org/apache/hop/ui/hopgui/perspective/explorer/config/messages/messages_pt_BR.properties
+++
b/ui/src/main/resources/org/apache/hop/ui/hopgui/perspective/explorer/config/messages/messages_pt_BR.properties
@@ -25,3 +25,7 @@ ExplorerPerspectiveConfig.FileExplorerVisible.Label=Mostrar
painel explorador de
ExplorerPerspectiveConfig.FileExplorerVisible.Tooltip=Quando habilitado, o
painel explorador de arquivos (árvore do projeto) é mostrado por padrão ao
abrir a perspectiva exploradora
ExplorerPerspectiveConfig.OpenHelpFiles.Label=Abra arquivos de ajuda nas abas
do Hop GUI em vez de navegador externo
ExplorerPerspectiveConfig.OpenHelpFiles.Tooltip=Quando marcada, links de ajuda
abrirão como uma nova guia dentro da GUI Hop usando o visualizador HTML
interno. Sem controle, abrirá o navegador padrão do sistema.
+
+ExplorerPerspectiveConfig.ActiveFileSelection.Label=Selecionar automaticamente
arquivo ativo na \u00E1rvore
+ExplorerPerspectiveConfig.ActiveFileSelection.Tooltip=Selecionar
automaticamente o arquivo da guia ativa na \u00E1rvore do explorador de
arquivos no lado esquerdo.
+