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 9dcae73700 clear filters on project switch. fixes #7305 (#7307)
9dcae73700 is described below
commit 9dcae73700f41b0ad9cf5646b72dab9219322501
Author: Bart Maertens <[email protected]>
AuthorDate: Thu Jun 18 09:31:37 2026 +0200
clear filters on project switch. fixes #7305 (#7307)
---
.../java/org/apache/hop/git/GitPerspective.java | 23 +++++++++++++++++++-
.../hop/ui/hopgui/perspective/IHopPerspective.java | 5 +++++
.../configuration/ConfigurationPerspective.java | 21 +++++++++++++++++-
.../execution/ExecutionPerspective.java | 25 ++++++++++++++++++++++
.../perspective/explorer/ExplorerPerspective.java | 23 +++++++++++++++-----
.../perspective/metadata/MetadataPerspective.java | 16 ++++++++++++++
.../perspective/search/HopSearchPerspective.java | 19 ++++++++++++++++
7 files changed, 125 insertions(+), 7 deletions(-)
diff --git
a/plugins/misc/git/src/main/java/org/apache/hop/git/GitPerspective.java
b/plugins/misc/git/src/main/java/org/apache/hop/git/GitPerspective.java
index 66fd584f5a..d07c3d824f 100644
--- a/plugins/misc/git/src/main/java/org/apache/hop/git/GitPerspective.java
+++ b/plugins/misc/git/src/main/java/org/apache/hop/git/GitPerspective.java
@@ -45,6 +45,7 @@ import org.apache.hop.git.util.FileTypeUtils;
import org.apache.hop.i18n.BaseMessages;
import org.apache.hop.ui.core.FormDataBuilder;
import org.apache.hop.ui.core.PropsUi;
+import org.apache.hop.ui.core.bus.HopGuiEvents;
import org.apache.hop.ui.core.dialog.EnterStringDialog;
import org.apache.hop.ui.core.dialog.ErrorDialog;
import org.apache.hop.ui.core.dialog.MessageBox;
@@ -278,6 +279,20 @@ public class GitPerspective implements IHopPerspective {
// Add key listeners
HopGuiKeyHandler.getInstance().addParentObjectToHandle(this);
+
+ hopGui
+ .getEventsHandler()
+ .addEventListener(
+ getClass().getName() + "ProjectActivated",
+ e -> hopGui.getDisplay().asyncExec(this::clearSearchFilters),
+ HopGuiEvents.ProjectActivated.name());
+ }
+
+ @Override
+ public void clearSearchFilters() {
+ if (wSearchText != null && !wSearchText.isDisposed()) {
+ wSearchText.setText("");
+ }
}
protected void createRefTree(Composite parent) {
@@ -1521,7 +1536,13 @@ public class GitPerspective implements IHopPerspective {
}
String search = wSearchText.getText().trim();
- plotRenderer.setFiltered(!Utils.isEmpty(search));
+ if (plotRenderer != null) {
+ plotRenderer.setFiltered(!Utils.isEmpty(search));
+ }
+
+ if (GitGuiPlugin.getInstance().getGit() == null) {
+ return;
+ }
refreshHistory();
}
diff --git
a/ui/src/main/java/org/apache/hop/ui/hopgui/perspective/IHopPerspective.java
b/ui/src/main/java/org/apache/hop/ui/hopgui/perspective/IHopPerspective.java
index 7f562a0c87..d1a4d6b017 100644
--- a/ui/src/main/java/org/apache/hop/ui/hopgui/perspective/IHopPerspective.java
+++ b/ui/src/main/java/org/apache/hop/ui/hopgui/perspective/IHopPerspective.java
@@ -147,4 +147,9 @@ public interface IHopPerspective extends
IActionContextHandlersProvider {
default void setDropTargetFolder(CTabFolder folder) {
// Do nothing by default
}
+
+ /** Clear search/filter text fields when a new project is activated. */
+ default void clearSearchFilters() {
+ // Do nothing by default
+ }
}
diff --git
a/ui/src/main/java/org/apache/hop/ui/hopgui/perspective/configuration/ConfigurationPerspective.java
b/ui/src/main/java/org/apache/hop/ui/hopgui/perspective/configuration/ConfigurationPerspective.java
index 4569b0c64c..be9901c5aa 100644
---
a/ui/src/main/java/org/apache/hop/ui/hopgui/perspective/configuration/ConfigurationPerspective.java
+++
b/ui/src/main/java/org/apache/hop/ui/hopgui/perspective/configuration/ConfigurationPerspective.java
@@ -34,6 +34,7 @@ import org.apache.hop.core.logging.LogChannel;
import org.apache.hop.i18n.BaseMessages;
import org.apache.hop.ui.core.FormDataBuilder;
import org.apache.hop.ui.core.PropsUi;
+import org.apache.hop.ui.core.bus.HopGuiEvents;
import org.apache.hop.ui.core.dialog.ErrorDialog;
import org.apache.hop.ui.core.gui.GuiResource;
import org.apache.hop.ui.core.widget.TableView;
@@ -106,6 +107,7 @@ public class ConfigurationPerspective implements
IHopPerspective {
private List<Control> highlightedControls = new ArrayList<>();
private String currentSearchText = ""; // Track current search for
re-applying highlights
private Color highlightColor; // Custom neutral highlight color
+ private Text searchBox;
@Getter private static ConfigurationPerspective instance;
public ConfigurationPerspective() {
@@ -180,7 +182,7 @@ public class ConfigurationPerspective implements
IHopPerspective {
treeComposite.setLayout(new FormLayout());
// Search box at the top
- Text searchBox =
+ searchBox =
new Text(treeComposite, SWT.SEARCH | SWT.ICON_SEARCH | SWT.ICON_CANCEL
| SWT.BORDER);
PropsUi.setLook(searchBox);
searchBox.setMessage(BaseMessages.getString(PKG,
"HopConfigurationperspective.Search.Text"));
@@ -305,6 +307,23 @@ public class ConfigurationPerspective implements
IHopPerspective {
if (shell != null) {
HopGui.getInstance().replaceKeyboardShortcutListeners(shell, keyHandler);
}
+
+ hopGui
+ .getEventsHandler()
+ .addEventListener(
+ getClass().getName() + "ProjectActivated",
+ e -> hopGui.getDisplay().asyncExec(this::clearSearchFilters),
+ HopGuiEvents.ProjectActivated.name());
+ }
+
+ @Override
+ public void clearSearchFilters() {
+ if (searchBox != null && !searchBox.isDisposed()) {
+ searchBox.setText("");
+ } else {
+ currentSearchText = "";
+ clearHighlights();
+ }
}
private void loadSettingCategories() {
diff --git
a/ui/src/main/java/org/apache/hop/ui/hopgui/perspective/execution/ExecutionPerspective.java
b/ui/src/main/java/org/apache/hop/ui/hopgui/perspective/execution/ExecutionPerspective.java
index 165852e03d..ae4a3fcdd6 100644
---
a/ui/src/main/java/org/apache/hop/ui/hopgui/perspective/execution/ExecutionPerspective.java
+++
b/ui/src/main/java/org/apache/hop/ui/hopgui/perspective/execution/ExecutionPerspective.java
@@ -60,6 +60,7 @@ import org.apache.hop.metadata.api.IHopMetadataSerializer;
import org.apache.hop.pipeline.PipelineMeta;
import org.apache.hop.ui.core.FormDataBuilder;
import org.apache.hop.ui.core.PropsUi;
+import org.apache.hop.ui.core.bus.HopGuiEvents;
import org.apache.hop.ui.core.dialog.ErrorDialog;
import org.apache.hop.ui.core.dialog.MessageBox;
import org.apache.hop.ui.core.gui.GuiResource;
@@ -252,6 +253,30 @@ public class ExecutionPerspective implements
IHopPerspective, TabClosable {
// Add key listeners
HopGuiKeyHandler.getInstance().addParentObjectToHandle(this);
+
+ hopGui
+ .getEventsHandler()
+ .addEventListener(
+ getClass().getName() + "ProjectActivated",
+ e -> hopGui.getDisplay().asyncExec(this::clearSearchFilters),
+ HopGuiEvents.ProjectActivated.name());
+ }
+
+ @Override
+ public void clearSearchFilters() {
+ filterText = "";
+ if (toolBarWidgets != null) {
+ ToolItem item = toolBarWidgets.findToolItem(TOOLBAR_ITEM_FILTER_TEXT);
+ if (item != null && !item.isDisposed()) {
+ org.eclipse.swt.widgets.Control control = item.getControl();
+ if (control != null && !control.isDisposed() && control instanceof
Text text) {
+ text.setText("");
+ }
+ }
+ }
+ if (hopGui != null && hopGui.isActivePerspective(this)) {
+ refresh();
+ }
}
protected MetadataManager<IHopMetadata> getMetadataManager(String objectKey)
throws HopException {
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 b1b40498f7..218b12510c 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
@@ -341,11 +341,15 @@ public class ExplorerPerspective implements
IHopPerspective, TabClosable, IFileD
.getEventsHandler()
.addEventListener(
getClass().getName() + "ProjectActivated",
- e -> {
- refresh();
- // Defer so namespace and UI are fully updated after project
switch
- hopGui.getDisplay().asyncExec(() -> applyRestoredState());
- },
+ e ->
+ hopGui
+ .getDisplay()
+ .asyncExec(
+ () -> {
+ clearSearchFilters();
+ refresh();
+ applyRestoredState();
+ }),
HopGuiEvents.ProjectActivated.name());
hopGui
@@ -2771,6 +2775,15 @@ public class ExplorerPerspective implements
IHopPerspective, TabClosable, IFileD
image = "ui/images/refresh.svg")
@GuiKeyboardShortcut(key = SWT.F5)
@GuiOsxKeyboardShortcut(key = SWT.F5)
+ @Override
+ public void clearSearchFilters() {
+ if (searchText != null && !searchText.isDisposed()) {
+ searchText.setText("");
+ } else {
+ filterText = "";
+ }
+ }
+
public void refresh() {
try {
determineRootFolderName(hopGui);
diff --git
a/ui/src/main/java/org/apache/hop/ui/hopgui/perspective/metadata/MetadataPerspective.java
b/ui/src/main/java/org/apache/hop/ui/hopgui/perspective/metadata/MetadataPerspective.java
index 39f77b52a4..e79132e93d 100644
---
a/ui/src/main/java/org/apache/hop/ui/hopgui/perspective/metadata/MetadataPerspective.java
+++
b/ui/src/main/java/org/apache/hop/ui/hopgui/perspective/metadata/MetadataPerspective.java
@@ -232,6 +232,13 @@ public class MetadataPerspective implements
IHopPerspective, TabClosable, IMetad
.addEventListener(
getClass().getName(), e -> refresh(),
HopGuiEvents.MetadataChanged.name());
+ hopGui
+ .getEventsHandler()
+ .addEventListener(
+ getClass().getName() + "ProjectActivated",
+ e -> hopGui.getDisplay().asyncExec(this::clearSearchFilters),
+ HopGuiEvents.ProjectActivated.name());
+
// Add key listeners
HopGuiKeyHandler.getInstance().addParentObjectToHandle(this);
}
@@ -1823,6 +1830,15 @@ public class MetadataPerspective implements
IHopPerspective, TabClosable, IMetad
}
/** Filter the tree based on search text */
+ @Override
+ public void clearSearchFilters() {
+ if (searchText != null && !searchText.isDisposed()) {
+ searchText.setText("");
+ } else {
+ currentSearchFilter = "";
+ }
+ }
+
protected void filterTree() {
if (searchText == null || searchText.isDisposed()) {
return;
diff --git
a/ui/src/main/java/org/apache/hop/ui/hopgui/perspective/search/HopSearchPerspective.java
b/ui/src/main/java/org/apache/hop/ui/hopgui/perspective/search/HopSearchPerspective.java
index 68d15b1d06..803cd7a4ae 100644
---
a/ui/src/main/java/org/apache/hop/ui/hopgui/perspective/search/HopSearchPerspective.java
+++
b/ui/src/main/java/org/apache/hop/ui/hopgui/perspective/search/HopSearchPerspective.java
@@ -37,6 +37,7 @@ import
org.apache.hop.core.search.SearchableAnalyserPluginType;
import org.apache.hop.core.util.Utils;
import org.apache.hop.i18n.BaseMessages;
import org.apache.hop.ui.core.PropsUi;
+import org.apache.hop.ui.core.bus.HopGuiEvents;
import org.apache.hop.ui.core.dialog.ErrorDialog;
import org.apache.hop.ui.core.gui.GuiResource;
import org.apache.hop.ui.core.widget.ColumnInfo;
@@ -343,6 +344,24 @@ public class HopSearchPerspective implements
IHopPerspective {
wResults.table.addListener(
SWT.Selection, e ->
wbOpen.setEnabled(wResults.getSelectionIndices().length == 1));
wResults.table.addListener(SWT.DefaultSelection, this::open);
+
+ hopGui
+ .getEventsHandler()
+ .addEventListener(
+ getClass().getName() + "ProjectActivated",
+ e -> hopGui.getDisplay().asyncExec(this::clearSearchFilters),
+ HopGuiEvents.ProjectActivated.name());
+ }
+
+ @Override
+ public void clearSearchFilters() {
+ if (wSearchString != null && !wSearchString.isDisposed()) {
+ wSearchString.setText("");
+ }
+ if (wResults != null && !wResults.isDisposed()) {
+ wResults.table.removeAll();
+ }
+ allSearchResults = new ArrayList<>();
}
private void open(Event event) {