This is an automated email from the ASF dual-hosted git repository.
mattcasters 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 0b32f2c076 Issue #9091 : Add a Start action to workflows created from
the file explorer (#9092)
0b32f2c076 is described below
commit 0b32f2c076747f75f16b01d9eb7ae9f08eddece6
Author: Matt Casters <[email protected]>
AuthorDate: Fri Oct 23 11:12:04 2026 +0200
Issue #9091 : Add a Start action to workflows created from the file
explorer (#9092)
The file explorer Create workflow command saved an empty workflow. File >
New already added a Start action. Both paths now share
HopWorkflowFileType.addDefaultStartAction.
---
.../pages/hop-gui/perspective-file-explorer.adoc | 2 +-
.../hopgui/file/workflow/HopWorkflowFileType.java | 13 ++++---
.../perspective/explorer/ExplorerPerspective.java | 1 +
.../file/workflow/HopWorkflowFileTypeTest.java | 42 ++++++++++++++++++++++
4 files changed, 53 insertions(+), 5 deletions(-)
diff --git
a/docs/hop-user-manual/modules/ROOT/pages/hop-gui/perspective-file-explorer.adoc
b/docs/hop-user-manual/modules/ROOT/pages/hop-gui/perspective-file-explorer.adoc
index dc38a7e5d2..735c1b3c06 100644
---
a/docs/hop-user-manual/modules/ROOT/pages/hop-gui/perspective-file-explorer.adoc
+++
b/docs/hop-user-manual/modules/ROOT/pages/hop-gui/perspective-file-explorer.adoc
@@ -76,7 +76,7 @@ New pipelines, workflows and files are created from the
right-click menu rather
Right-click a file or folder in the tree to open this menu.
Options that don't apply to the selection are greyed out.
-* Create pipeline..., Create workflow..., Create file...: Create a new, empty
pipeline, workflow or file inside the selected folder and open it. For a file
you choose its name and file type. Only available when one folder is selected.
+* Create pipeline..., Create workflow..., Create file...: Create a new empty
pipeline, a new workflow with a Start action, or a new file inside the selected
folder and open it. For a file you choose its name and file type. Only
available when one folder is selected.
* Create folder: Create a new folder inside the selected folder. Only
available when one folder is selected.
* Expand All, Collapse All: Show or hide all nested folders in the tree.
* Refresh folder: Read the selected folder, or the folder of the selected
file, again from disk.
diff --git
a/ui/src/main/java/org/apache/hop/ui/hopgui/file/workflow/HopWorkflowFileType.java
b/ui/src/main/java/org/apache/hop/ui/hopgui/file/workflow/HopWorkflowFileType.java
index 8f957826b2..10238bd222 100644
---
a/ui/src/main/java/org/apache/hop/ui/hopgui/file/workflow/HopWorkflowFileType.java
+++
b/ui/src/main/java/org/apache/hop/ui/hopgui/file/workflow/HopWorkflowFileType.java
@@ -165,6 +165,14 @@ public class HopWorkflowFileType<T extends WorkflowMeta>
extends HopFileTypeBase
}
}
+ /** A workflow runs from a Start action, so every way of creating one adds
the same action. */
+ public static void addDefaultStartAction(WorkflowMeta workflowMeta) {
+ ActionStart start = new ActionStart("Start");
+ ActionMeta startMeta = new ActionMeta(start);
+ startMeta.setLocation(50, 50);
+ workflowMeta.addAction(startMeta);
+ }
+
@Override
public IHopFileTypeHandler newFile(HopGui hopGui, IVariables
parentVariableSpace)
throws HopException {
@@ -185,10 +193,7 @@ public class HopWorkflowFileType<T extends WorkflowMeta>
extends HopFileTypeBase
// Add a Start action by default...
//
- ActionStart start = new ActionStart("Start");
- ActionMeta startMeta = new ActionMeta(start);
- startMeta.setLocation(50, 50);
- workflowMeta.addAction(startMeta);
+ addDefaultStartAction(workflowMeta);
// Show it in the editor
//
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 ff28fb707a..834b3d5735 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
@@ -3630,6 +3630,7 @@ public class ExplorerPerspective implements
IHopPerspective, TabClosable, IFileD
workflowMeta.setName(ExplorerCreateUtils.baseName(fileName));
workflowMeta.setMetadataProvider(hopGui.getMetadataProvider());
workflowMeta.setFilename(filename);
+ HopWorkflowFileType.addDefaultStartAction(workflowMeta);
IHopFileTypeHandler handler = addWorkflow(workflowMeta);
handler.save();
} catch (Exception e) {
diff --git
a/ui/src/test/java/org/apache/hop/ui/hopgui/file/workflow/HopWorkflowFileTypeTest.java
b/ui/src/test/java/org/apache/hop/ui/hopgui/file/workflow/HopWorkflowFileTypeTest.java
new file mode 100644
index 0000000000..0fcba8dc77
--- /dev/null
+++
b/ui/src/test/java/org/apache/hop/ui/hopgui/file/workflow/HopWorkflowFileTypeTest.java
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hop.ui.hopgui.file.workflow;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import org.apache.hop.workflow.WorkflowMeta;
+import org.apache.hop.workflow.action.ActionMeta;
+import org.junit.jupiter.api.Test;
+
+class HopWorkflowFileTypeTest {
+
+ @Test
+ void addDefaultStartActionAddsOneStartAction() {
+ WorkflowMeta workflowMeta = new WorkflowMeta();
+
+ HopWorkflowFileType.addDefaultStartAction(workflowMeta);
+
+ assertEquals(1, workflowMeta.nrActions());
+ ActionMeta start = workflowMeta.getAction(0);
+ assertTrue(start.isStart());
+ assertEquals("Start", start.getName());
+ assertEquals(50, start.getLocation().x);
+ assertEquals(50, start.getLocation().y);
+ }
+}