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 a60d0c6114 Speed up project change and perspective change #5985 (#5986)
a60d0c6114 is described below
commit a60d0c61141f92e3bff9d28f5a08a82a73bedaba
Author: Nicolas Adment <[email protected]>
AuthorDate: Fri Nov 14 15:26:17 2025 +0100
Speed up project change and perspective change #5985 (#5986)
---
.../main/java/org/apache/hop/ui/hopgui/HopGui.java | 14 +++++++++++---
.../hop/ui/hopgui/delegates/HopGuiFileDelegate.java | 6 ++++++
.../perspective/explorer/ExplorerPerspective.java | 20 +++++++++++---------
.../perspective/metadata/MetadataPerspective.java | 13 ++++++++-----
4 files changed, 36 insertions(+), 17 deletions(-)
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 55de257de9..878b399998 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
@@ -588,7 +588,6 @@ public class HopGui
Const.NVL(
TranslateUtil.translate(perspectivePlugin.getName(),
perspectiveClass),
perspective.getId());
- Listener listener = event -> setActivePerspective(perspective);
ClassLoader classLoader =
pluginRegistry.getClassLoader(perspectivePlugin);
ToolItem item;
@@ -599,11 +598,20 @@ public class HopGui
this.perspectivesToolbar,
perspectivePlugin.getImageFile(),
tooltip,
- listener);
+ // TODO: check if there is unnecessary refresh
+ event -> setActivePerspective(perspective));
} else {
item = new ToolItem(this.perspectivesToolbar, SWT.RADIO);
item.setToolTipText(tooltip);
- item.addListener(SWT.Selection, listener);
+ item.addListener(
+ 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.
+ if (item.getSelection()) {
+ setActivePerspective(perspective);
+ }
+ });
Image image =
GuiResource.getInstance()
.getImage(
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 877417c3f9..0a95596e00 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
@@ -25,6 +25,7 @@ import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
+import lombok.Getter;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.vfs2.FileObject;
import org.apache.hop.core.RowMetaAndData;
@@ -61,6 +62,9 @@ public class HopGuiFileDelegate {
public static final String CONST_ERROR = "Error";
private final HopGui hopGui;
+ /** Returns a boolean indicating whether the gui in the process of closing
files. */
+ @Getter private boolean isClosing;
+
public HopGuiFileDelegate(HopGui hopGui) {
this.hopGui = hopGui;
}
@@ -225,6 +229,7 @@ public class HopGuiFileDelegate {
}
public void closeAllFiles() {
+ this.isClosing = true;
for (IHopPerspective perspective :
hopGui.getPerspectiveManager().getPerspectives()) {
List<TabItemHandler> tabItemHandlers = perspective.getItems();
if (tabItemHandlers != null) {
@@ -237,6 +242,7 @@ public class HopGuiFileDelegate {
}
}
}
+ this.isClosing = false;
}
/** When the app exits we need to see if all open files are saved in all
perspectives... */
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 9c2760b3f4..54604ab930 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
@@ -1530,9 +1530,7 @@ public class ExplorerPerspective implements
IHopPerspective, TabClosable {
@Override
public boolean remove(IHopFileTypeHandler typeHandler) {
- if (typeHandler instanceof BaseExplorerFileTypeHandler
baseExplorerFileTypeHandler) {
- BaseExplorerFileTypeHandler fileTypeHandler =
baseExplorerFileTypeHandler;
-
+ if (typeHandler instanceof BaseExplorerFileTypeHandler fileTypeHandler) {
if (fileTypeHandler.isCloseable()) {
ExplorerFile file = fileTypeHandler.getExplorerFile();
files.remove(file);
@@ -1542,13 +1540,17 @@ public class ExplorerPerspective implements
IHopPerspective, TabClosable {
}
}
- // Refresh tree to remove bold
- //
- this.refresh();
+ // Avoid refresh in a closing process (when switching project)
+ if (!hopGui.fileDelegate.isClosing()) {
+
+ // Refresh tree to remove bold
+ //
+ this.refresh();
- // Update HopGui menu and toolbar
- //
- this.updateGui();
+ // Update HopGui menu and toolbar
+ //
+ this.updateGui();
+ }
}
}
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 29f1c0cec2..dc4908b1ea 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
@@ -938,12 +938,15 @@ public class MetadataPerspective implements
IHopPerspective, TabClosable {
}
}
- // Refresh tree to remove bold
- //
- this.refresh();
+ // Avoid refresh in a closing process (when switching project)
+ if (!hopGui.fileDelegate.isClosing()) {
+ // Refresh tree to remove bold
+ //
+ this.refresh();
- // Update Gui menu and toolbar
- this.updateGui();
+ // Update Gui menu and toolbar
+ this.updateGui();
+ }
}
return false;