You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hop.apache.org by ha...@apache.org on 2020/12/27 16:06:22 UTC
[incubator-hop] branch master updated: HOP-2354: Fix GuiContextUtil
not to share ContextDialog
This is an automated email from the ASF dual-hosted git repository.
hansva pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-hop.git
The following commit(s) were added to refs/heads/master by this push:
new 46949dc HOP-2354: Fix GuiContextUtil not to share ContextDialog
new 157305f Merge pull request #498 from HiromuHota/HOP-2354
46949dc is described below
commit 46949dc6476100e386c0d1adee69146678fd2156
Author: Hiromu Hota <hi...@gmail.com>
AuthorDate: Sat Dec 26 19:21:03 2020 -0800
HOP-2354: Fix GuiContextUtil not to share ContextDialog
---
.../hop/ui/core/metadata/MetadataManager.java | 4 +--
.../hop/ui/hopgui/context/GuiContextUtil.java | 29 ++++++++++++++--------
.../ui/hopgui/delegates/HopGuiContextDelegate.java | 6 ++---
.../hopgui/file/pipeline/HopGuiPipelineGraph.java | 2 +-
.../hopgui/file/workflow/HopGuiWorkflowGraph.java | 2 +-
5 files changed, 25 insertions(+), 18 deletions(-)
diff --git a/ui/src/main/java/org/apache/hop/ui/core/metadata/MetadataManager.java b/ui/src/main/java/org/apache/hop/ui/core/metadata/MetadataManager.java
index a2cfe27..604c3c6 100644
--- a/ui/src/main/java/org/apache/hop/ui/core/metadata/MetadataManager.java
+++ b/ui/src/main/java/org/apache/hop/ui/core/metadata/MetadataManager.java
@@ -94,7 +94,7 @@ public class MetadataManager<T extends IHopMetadata> {
action.setClassLoader( getClassLoader() );
actions.add( action );
}
- return GuiContextUtil.handleActionSelection( hopGui.getShell(), "Select the " + hopMetadata.name() + " to edit", new GuiContextHandler( "HopGuiMetadataContext", actions ) );
+ return GuiContextUtil.getInstance().handleActionSelection( hopGui.getShell(), "Select the " + hopMetadata.name() + " to edit", new GuiContextHandler( "HopGuiMetadataContext", actions ) );
} catch ( Exception e ) {
new ErrorDialog( hopGui.getShell(), "Error", "Error editing metadata", e );
@@ -123,7 +123,7 @@ public class MetadataManager<T extends IHopMetadata> {
action.setClassLoader( getClassLoader() );
actions.add( action );
}
- return GuiContextUtil.handleActionSelection( hopGui.getShell(), "Select the " + hopMetadata.name() + " to delete after confirmation", new GuiContextHandler( "HopGuiMetadaContext", actions ) );
+ return GuiContextUtil.getInstance().handleActionSelection( hopGui.getShell(), "Select the " + hopMetadata.name() + " to delete after confirmation", new GuiContextHandler( "HopGuiMetadaContext", actions ) );
} catch ( Exception e ) {
new ErrorDialog( hopGui.getShell(), "Error", "Error deleting metadata", e );
diff --git a/ui/src/main/java/org/apache/hop/ui/hopgui/context/GuiContextUtil.java b/ui/src/main/java/org/apache/hop/ui/hopgui/context/GuiContextUtil.java
index fdf9921..1df589f 100644
--- a/ui/src/main/java/org/apache/hop/ui/hopgui/context/GuiContextUtil.java
+++ b/ui/src/main/java/org/apache/hop/ui/hopgui/context/GuiContextUtil.java
@@ -39,11 +39,18 @@ import java.util.Map;
public class GuiContextUtil {
- private static final Map<String, ContextDialog> shellDialogMap = new HashMap<>();
+ private final Map<String, ContextDialog> shellDialogMap = new HashMap<>();
+ private static GuiContextUtil guiContextUtil;
+ public static final GuiContextUtil getInstance() {
+ if (guiContextUtil == null) {
+ guiContextUtil = new GuiContextUtil();
+ }
+ return guiContextUtil;
+ }
- public static final List<GuiAction> getContextActions( IActionContextHandlersProvider provider, GuiActionType actionType, String contextId ) {
- return GuiContextUtil.filterHandlerActions( provider.getContextHandlers(), actionType, contextId );
+ public final List<GuiAction> getContextActions( IActionContextHandlersProvider provider, GuiActionType actionType, String contextId ) {
+ return filterHandlerActions( provider.getContextHandlers(), actionType, contextId );
}
/**
@@ -53,7 +60,7 @@ public class GuiContextUtil {
* @param actionType The type to filter out
* @return A new list with only the actions of the specified type
*/
- public static final List<GuiAction> filterActions( List<GuiAction> guiActions, GuiActionType actionType ) {
+ public final List<GuiAction> filterActions( List<GuiAction> guiActions, GuiActionType actionType ) {
List<GuiAction> filtered = new ArrayList<>();
for ( GuiAction guiAction : guiActions ) {
if ( guiAction.getType().equals( actionType ) ) {
@@ -70,7 +77,7 @@ public class GuiContextUtil {
* @param actionType
* @return
*/
- public static final List<GuiAction> filterHandlerActions( List<IGuiContextHandler> handlers, GuiActionType actionType, String contextId ) {
+ public final List<GuiAction> filterHandlerActions( List<IGuiContextHandler> handlers, GuiActionType actionType, String contextId ) {
List<GuiAction> filtered = new ArrayList<>();
for ( IGuiContextHandler handler : handlers ) {
filtered.addAll( filterActions( handler.getSupportedActions(), actionType ) );
@@ -78,18 +85,18 @@ public class GuiContextUtil {
return filtered;
}
- public static final void handleActionSelection( Shell parent, String message, IActionContextHandlersProvider provider, GuiActionType actionType, String contextId ) {
+ public final void handleActionSelection( Shell parent, String message, IActionContextHandlersProvider provider, GuiActionType actionType, String contextId ) {
handleActionSelection( parent, message, null, provider, actionType, contextId );
}
- public static final void handleActionSelection( Shell parent, String message, Point clickLocation, IActionContextHandlersProvider provider, GuiActionType actionType, String contextId ) {
+ public final void handleActionSelection( Shell parent, String message, Point clickLocation, IActionContextHandlersProvider provider, GuiActionType actionType, String contextId ) {
handleActionSelection( parent, message, clickLocation, provider, actionType, contextId, false );
}
- public static final void handleActionSelection( Shell parent, String message, Point clickLocation, IActionContextHandlersProvider provider, GuiActionType actionType, String contextId, boolean sortByName ) {
+ public final void handleActionSelection( Shell parent, String message, Point clickLocation, IActionContextHandlersProvider provider, GuiActionType actionType, String contextId, boolean sortByName ) {
// Get the list of create actions in the Hop UI context...
//
- List<GuiAction> actions = GuiContextUtil.getContextActions( provider, actionType, contextId );
+ List<GuiAction> actions = getContextActions( provider, actionType, contextId );
if ( actions.isEmpty() ) {
return;
}
@@ -100,7 +107,7 @@ public class GuiContextUtil {
handleActionSelection( parent, message, clickLocation, new GuiContextHandler( contextId, actions ) );
}
- public static boolean handleActionSelection( Shell parent, String message, IGuiContextHandler contextHandler ) {
+ public boolean handleActionSelection( Shell parent, String message, IGuiContextHandler contextHandler ) {
return handleActionSelection( parent, message, null, contextHandler );
}
@@ -111,7 +118,7 @@ public class GuiContextUtil {
* @param contextHandler
* @return true if the action dialog lost focus
*/
- public synchronized static boolean handleActionSelection( Shell parent, String message, Point clickLocation, IGuiContextHandler contextHandler ) {
+ public synchronized boolean handleActionSelection( Shell parent, String message, Point clickLocation, IGuiContextHandler contextHandler ) {
List<GuiAction> actions = contextHandler.getSupportedActions();
if ( actions.isEmpty() ) {
return false;
diff --git a/ui/src/main/java/org/apache/hop/ui/hopgui/delegates/HopGuiContextDelegate.java b/ui/src/main/java/org/apache/hop/ui/hopgui/delegates/HopGuiContextDelegate.java
index 873c693..c7731e6 100644
--- a/ui/src/main/java/org/apache/hop/ui/hopgui/delegates/HopGuiContextDelegate.java
+++ b/ui/src/main/java/org/apache/hop/ui/hopgui/delegates/HopGuiContextDelegate.java
@@ -43,7 +43,7 @@ public class HopGuiContextDelegate {
int x = 50 + hopGui.getShell().getLocation().x;
int y = 50 + hopGui.getShell().getLocation().y;
- GuiContextUtil.handleActionSelection( hopGui.getShell(), "Select the item to create", new Point( x, y ), hopGui, GuiActionType.Create, "FileNew", true );
+ GuiContextUtil.getInstance().handleActionSelection( hopGui.getShell(), "Select the item to create", new Point( x, y ), hopGui, GuiActionType.Create, "FileNew", true );
}
/**
@@ -51,7 +51,7 @@ public class HopGuiContextDelegate {
*/
public void fileMetadataEdit() {
- GuiContextUtil.handleActionSelection( hopGui.getShell(), "Select the element type to edit...", new Point( 0, 0 ), hopGui, GuiActionType.Modify, "FileMetadataEdit", true );
+ GuiContextUtil.getInstance().handleActionSelection( hopGui.getShell(), "Select the element type to edit...", new Point( 0, 0 ), hopGui, GuiActionType.Modify, "FileMetadataEdit", true );
}
/**
@@ -59,7 +59,7 @@ public class HopGuiContextDelegate {
*/
public void fileMetadataDelete() {
- GuiContextUtil.handleActionSelection( hopGui.getShell(), "Select the element type to delete...", new Point( 0, 0 ), hopGui, GuiActionType.Delete, "FileMetadataDelete", true );
+ GuiContextUtil.getInstance().handleActionSelection( hopGui.getShell(), "Select the element type to delete...", new Point( 0, 0 ), hopGui, GuiActionType.Delete, "FileMetadataDelete", true );
}
/**
diff --git a/ui/src/main/java/org/apache/hop/ui/hopgui/file/pipeline/HopGuiPipelineGraph.java b/ui/src/main/java/org/apache/hop/ui/hopgui/file/pipeline/HopGuiPipelineGraph.java
index d8974f4..3c3a0c8 100644
--- a/ui/src/main/java/org/apache/hop/ui/hopgui/file/pipeline/HopGuiPipelineGraph.java
+++ b/ui/src/main/java/org/apache/hop/ui/hopgui/file/pipeline/HopGuiPipelineGraph.java
@@ -1217,7 +1217,7 @@ public class HopGuiPipelineGraph extends HopGuiAbstractGraph
// Show the context dialog
//
avoidContextDialog =
- GuiContextUtil.handleActionSelection(
+ GuiContextUtil.getInstance().handleActionSelection(
parent, message, new Point(p.x, p.y), contextHandler);
}
}
diff --git a/ui/src/main/java/org/apache/hop/ui/hopgui/file/workflow/HopGuiWorkflowGraph.java b/ui/src/main/java/org/apache/hop/ui/hopgui/file/workflow/HopGuiWorkflowGraph.java
index 1511c9c..487d80a 100644
--- a/ui/src/main/java/org/apache/hop/ui/hopgui/file/workflow/HopGuiWorkflowGraph.java
+++ b/ui/src/main/java/org/apache/hop/ui/hopgui/file/workflow/HopGuiWorkflowGraph.java
@@ -1011,7 +1011,7 @@ public class HopGuiWorkflowGraph extends HopGuiAbstractGraph
// Show the context dialog
//
ignoreNextClick =
- GuiContextUtil.handleActionSelection(
+ GuiContextUtil.getInstance().handleActionSelection(
parent, message, new Point(p.x, p.y), contextHandler);
}
}