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 9ab53ae8a8 Small cleanup to find perspective #6014 (#6015)
9ab53ae8a8 is described below

commit 9ab53ae8a861e36bee07ac56887e2840af542315
Author: Nicolas Adment <[email protected]>
AuthorDate: Mon Nov 17 11:03:09 2025 +0100

    Small cleanup to find perspective #6014 (#6015)
---
 .../main/java/org/apache/hop/ui/hopgui/HopGui.java | 27 +++++++++-------------
 .../hopgui/perspective/HopPerspectiveManager.java  | 19 +++++++--------
 2 files changed, 19 insertions(+), 27 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 878b399998..a029555bb0 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
@@ -1523,7 +1523,7 @@ public class HopGui
     //
     perspective.perspectiveActivated();
 
-    perspectiveManager.notifyPerspectiveActiviated(perspective);
+    perspectiveManager.notifyPerspectiveActivated(perspective);
   }
 
   public boolean isActivePerspective(IHopPerspective perspective) {
@@ -1620,36 +1620,31 @@ public class HopGui
   }
 
   public static HopDataOrchestrationPerspective 
getDataOrchestrationPerspective() {
-    return (HopDataOrchestrationPerspective)
-        HopGui.getInstance()
-            .getPerspectiveManager()
-            .findPerspective(HopDataOrchestrationPerspective.class);
+    return HopGui.getInstance()
+        .getPerspectiveManager()
+        .findPerspective(HopDataOrchestrationPerspective.class);
   }
 
   public static MetadataPerspective getMetadataPerspective() {
-    return (MetadataPerspective)
-        
HopGui.getInstance().getPerspectiveManager().findPerspective(MetadataPerspective.class);
+    return 
HopGui.getInstance().getPerspectiveManager().findPerspective(MetadataPerspective.class);
   }
 
   public static ExecutionPerspective getExecutionPerspective() {
-    return (ExecutionPerspective)
-        
HopGui.getInstance().getPerspectiveManager().findPerspective(ExecutionPerspective.class);
+    return 
HopGui.getInstance().getPerspectiveManager().findPerspective(ExecutionPerspective.class);
   }
 
   public static ExplorerPerspective getExplorerPerspective() {
-    return (ExplorerPerspective)
-        
HopGui.getInstance().getPerspectiveManager().findPerspective(ExplorerPerspective.class);
+    return 
HopGui.getInstance().getPerspectiveManager().findPerspective(ExplorerPerspective.class);
   }
 
   public static ConfigurationPerspective getConfigurationPerspective() {
-    return (ConfigurationPerspective)
-        HopGui.getInstance()
-            .getPerspectiveManager()
-            .findPerspective(ConfigurationPerspective.class);
+    return HopGui.getInstance()
+        .getPerspectiveManager()
+        .findPerspective(ConfigurationPerspective.class);
   }
 
   /**
-   * Create a list of all the searcheables locations. By default this means 
HopGui, the the current
+   * Create a list of all the searcheables locations. By default this means 
HopGui, the current
    * metadata
    */
   @Override
diff --git 
a/ui/src/main/java/org/apache/hop/ui/hopgui/perspective/HopPerspectiveManager.java
 
b/ui/src/main/java/org/apache/hop/ui/hopgui/perspective/HopPerspectiveManager.java
index b7e3c5e050..08c62e0c96 100644
--- 
a/ui/src/main/java/org/apache/hop/ui/hopgui/perspective/HopPerspectiveManager.java
+++ 
b/ui/src/main/java/org/apache/hop/ui/hopgui/perspective/HopPerspectiveManager.java
@@ -18,7 +18,6 @@
 package org.apache.hop.ui.hopgui.perspective;
 
 import java.util.ArrayList;
-import java.util.Collections;
 import java.util.Comparator;
 import java.util.HashMap;
 import java.util.List;
@@ -30,15 +29,15 @@ import org.apache.hop.ui.hopgui.file.IHopFileType;
 import org.apache.hop.ui.hopgui.file.empty.EmptyFileType;
 
 /**
- * This class helps the perspective plugins to keep track of their 
visualisation. The main principle
+ * This class helps the perspective plugins to keep track of their 
visualization. The main principle
  * is that a perspective has it's own composite and draws on it. It's shown or 
not depending on what
  * is selected.
  */
 public class HopPerspectiveManager {
 
-  private HopGui hopGui;
+  private final HopGui hopGui;
 
-  private Map<Class<? extends IHopPerspective>, IHopPerspective> 
perspectivesMap;
+  private final Map<Class<? extends IHopPerspective>, IHopPerspective> 
perspectivesMap;
 
   private final ConcurrentLinkedQueue<IHopPerspectiveListener> listeners;
 
@@ -66,17 +65,17 @@ public class HopPerspectiveManager {
     }
   }
 
-  public IHopPerspective findPerspective(Class<? extends IHopPerspective> 
perspectiveClass) {
+  public <T extends IHopPerspective> T findPerspective(Class<T> 
perspectiveClass) {
     for (IHopPerspective perspective : perspectivesMap.values()) {
       if (perspective.getClass().equals(perspectiveClass)) {
-        return perspective;
+        return perspectiveClass.cast(perspective);
       }
     }
     return null;
   }
 
   /**
-   * Loop over all perspectives and see if any one of them recognises the 
object
+   * Loop over all perspectives and see if any one of them recognizes the 
object
    *
    * @param fileMetadata
    * @return
@@ -113,17 +112,15 @@ public class HopPerspectiveManager {
     }
   }
 
-  public void notifyPerspectiveActiviated(IHopPerspective perspective) {
+  public void notifyPerspectiveActivated(IHopPerspective perspective) {
     for (IHopPerspectiveListener listener : this.listeners) {
       listener.perspectiveActivated(perspective);
     }
   }
 
   private List<Class<? extends IHopPerspective>> getSortedClasses() {
-
     List<Class<? extends IHopPerspective>> list = new 
ArrayList<>(perspectivesMap.keySet());
-    Collections.sort(
-        list, Comparator.comparing(c -> 
c.getAnnotation(HopPerspectivePlugin.class).id()));
+    list.sort(Comparator.comparing(c -> 
c.getAnnotation(HopPerspectivePlugin.class).id()));
     return list;
   }
 

Reply via email to