You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hop.apache.org by mc...@apache.org on 2022/09/21 12:20:07 UTC

[hop] branch master updated: HOP-4203 Execute a workflow and start it from a specific action

This is an automated email from the ASF dual-hosted git repository.

mcasters pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hop.git


The following commit(s) were added to refs/heads/master by this push:
     new 80e9d05e7d HOP-4203 Execute a workflow and start it from a specific action
     new 859f2064d9 Merge pull request #1680 from nadment/HOP-4203
80e9d05e7d is described below

commit 80e9d05e7deb3c6f1af8e6ed5c86ca4e178dfb94
Author: Nicolas Adment <39...@users.noreply.github.com>
AuthorDate: Mon Sep 12 21:26:24 2022 +0200

    HOP-4203 Execute a workflow and start it from a specific action
---
 .../hopgui/file/workflow/HopGuiWorkflowGraph.java  | 38 +++++++++++++++++++++-
 .../workflow/messages/messages_en_US.properties    |  2 ++
 2 files changed, 39 insertions(+), 1 deletion(-)

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 54b9791e6d..cc4a4dbc31 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
@@ -1704,7 +1704,43 @@ public class HopGuiWorkflowGraph extends HopGuiAbstractGraph
 
     return new int[] {x1, y1, x2, y2};
   }
-
+  
+  @GuiContextAction(
+      id = "workflow-graph-action-10040-start-workflow-here",
+      parentId = HopGuiWorkflowActionContext.CONTEXT_ID,
+      type = GuiActionType.Info,
+      name = "i18n::HopGuiWorkflowGraph.ContextualAction.StartWorkflowHere.Text",
+      tooltip = "i18n::HopGuiWorkflowGraph.ContextualAction.StartWorkflowHere.Tooltip",
+      image = "ui/images/run.svg",
+      category = "i18n::HopGuiWorkflowGraph.ContextualAction.Category.Basic.Text",
+      categoryOrder = "1")
+  public void startWorkflowHere(HopGuiWorkflowActionContext context) {
+    workflowMeta.setShowDialog(workflowMeta.isAlwaysShowRunOptions());
+    ServerPushSessionFacade.start();    
+    Thread thread =
+        new Thread() {
+          @Override
+          public void run() {
+            hopGui.getDisplay()
+                .asyncExec(
+                    () -> {
+                      try {
+                        workflowRunDelegate.executeWorkflow(
+                            hopGui.getVariables(), workflowMeta, context.getActionMeta().getName());
+                        ServerPushSessionFacade.stop();
+                      } catch (Exception e) {
+                        new ErrorDialog(
+                            hopGui.getShell(),
+                            "Execute workflow",
+                            "There was an error during workflow execution",
+                            e);
+                      }
+                    });
+          }
+        };
+    thread.start();
+  }
+  
   @GuiContextAction(
       id = "workflow-graph-action-10050-create-hop",
       parentId = HopGuiWorkflowActionContext.CONTEXT_ID,
diff --git a/ui/src/main/resources/org/apache/hop/ui/hopgui/file/workflow/messages/messages_en_US.properties b/ui/src/main/resources/org/apache/hop/ui/hopgui/file/workflow/messages/messages_en_US.properties
index d68cb68c56..926a02e316 100644
--- a/ui/src/main/resources/org/apache/hop/ui/hopgui/file/workflow/messages/messages_en_US.properties
+++ b/ui/src/main/resources/org/apache/hop/ui/hopgui/file/workflow/messages/messages_en_US.properties
@@ -57,6 +57,8 @@ HopGuiWorkflowGraph.ContextualAction.ParallelExecution.Text=Parallel execution
 HopGuiWorkflowGraph.ContextualAction.ParallelExecution.Tooltip=Enable or disable parallel execution of next actions
 HopGuiWorkflowGraph.ContextualAction.PasteFromClipboard.Text=Paste from the clipboard
 HopGuiWorkflowGraph.ContextualAction.PasteFromClipboard.Tooltip=Paste actions, notes or a whole workflow from the clipboard
+HopGuiWorkflowGraph.ContextualAction.StartWorkflowHere.Text=Start the workflow here
+HopGuiWorkflowGraph.ContextualAction.StartWorkflowHere.Tooltip=Start the execution of the workflow from this action.
 HopGuiWorkflowGraph.ContextualAction.SuccessHop.Text=Success hop
 HopGuiWorkflowGraph.ContextualAction.SuccessHop.Tooltip=Go to the next execution when successful
 HopGuiWorkflowGraph.ContextualAction.UnconditionalHop.Text=Unconditional hop