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 2f026e28b8 Issue #5793 (When using save as unit test is not being 
detached) (#6178)
2f026e28b8 is described below

commit 2f026e28b83f43ea0e8a723e3743ced25ac2ab51
Author: Matt Casters <[email protected]>
AuthorDate: Fri Dec 12 05:09:37 2025 +0100

    Issue #5793 (When using save as unit test is not being detached) (#6178)
    
    Co-authored-by: Matt Casters <[email protected]>
---
 .../hop/core/extension/HopExtensionPoint.java      |  1 +
 .../apache/hop/testing/gui/TestingGuiPlugin.java   |  4 --
 .../xp/HopGuiPipelineSaveAsExtensionPoint.java     | 43 ++++++++++++++++++++++
 .../hopgui/file/pipeline/HopGuiPipelineGraph.java  |  9 +++++
 .../extension/PipelineRenamedExtension.java        | 38 +++++++++++++++++++
 5 files changed, 91 insertions(+), 4 deletions(-)

diff --git 
a/core/src/main/java/org/apache/hop/core/extension/HopExtensionPoint.java 
b/core/src/main/java/org/apache/hop/core/extension/HopExtensionPoint.java
index 5511eb66a2..c1d8a1e51e 100644
--- a/core/src/main/java/org/apache/hop/core/extension/HopExtensionPoint.java
+++ b/core/src/main/java/org/apache/hop/core/extension/HopExtensionPoint.java
@@ -43,6 +43,7 @@ public enum HopExtensionPoint {
   PipelineAfterOpen("A Pipeline file was opened (PipelineMeta)"),
   PipelineBeforeSave("A Pipeline file is about to be saved (PipelineMeta)"),
   PipelineAfterSave("A Pipeline file was saved (PipelineMeta)"),
+  PipelineAfterSaveAs("A Pipeline file was saved with a new name 
(PipelineRenamedExtension)"),
   PipelineBeforeClose("A Pipeline file is about to be closed"),
   PipelineAfterClose("A Pipeline file was closed"),
   PipelineChanged("A Pipeline has been changed"),
diff --git 
a/plugins/misc/testing/src/main/java/org/apache/hop/testing/gui/TestingGuiPlugin.java
 
b/plugins/misc/testing/src/main/java/org/apache/hop/testing/gui/TestingGuiPlugin.java
index f4bb322b28..69d6cd2a8a 100644
--- 
a/plugins/misc/testing/src/main/java/org/apache/hop/testing/gui/TestingGuiPlugin.java
+++ 
b/plugins/misc/testing/src/main/java/org/apache/hop/testing/gui/TestingGuiPlugin.java
@@ -824,9 +824,6 @@ public class TestingGuiPlugin {
     }
 
     try {
-      IHopMetadataSerializer<PipelineUnitTest> testSerializer =
-          hopGui.getMetadataProvider().getSerializer(PipelineUnitTest.class);
-
       PipelineMeta pipelineMeta = getActivePipelineMeta();
       if (pipelineMeta == null) {
         return;
@@ -853,7 +850,6 @@ public class TestingGuiPlugin {
 
       // Update the GUI
       //
-      pipelineGraph.setChanged();
       pipelineGraph.updateGui();
     } catch (Exception e) {
       new ErrorDialog(
diff --git 
a/plugins/misc/testing/src/main/java/org/apache/hop/testing/xp/HopGuiPipelineSaveAsExtensionPoint.java
 
b/plugins/misc/testing/src/main/java/org/apache/hop/testing/xp/HopGuiPipelineSaveAsExtensionPoint.java
new file mode 100644
index 0000000000..8b2724713a
--- /dev/null
+++ 
b/plugins/misc/testing/src/main/java/org/apache/hop/testing/xp/HopGuiPipelineSaveAsExtensionPoint.java
@@ -0,0 +1,43 @@
+/*
+ * 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.testing.xp;
+
+import org.apache.hop.core.exception.HopException;
+import org.apache.hop.core.extension.ExtensionPoint;
+import org.apache.hop.core.extension.IExtensionPoint;
+import org.apache.hop.core.logging.ILogChannel;
+import org.apache.hop.core.variables.IVariables;
+import org.apache.hop.testing.gui.TestingGuiPlugin;
+import 
org.apache.hop.ui.hopgui.file.pipeline.extension.PipelineRenamedExtension;
+
+@ExtensionPoint(
+    extensionPointId = "PipelineAfterSaveAs",
+    id = "HopGuiPipelineSaveAsExtensionPoint",
+    description = "Detach an active unit test if a pipeline is renamed")
+public class HopGuiPipelineSaveAsExtensionPoint
+    implements IExtensionPoint<PipelineRenamedExtension> {
+
+  @Override
+  public void callExtensionPoint(
+      ILogChannel log, IVariables variables, PipelineRenamedExtension 
pipelineRenamedExtension)
+      throws HopException {
+    TestingGuiPlugin.getInstance().detachUnitTest();
+    TestingGuiPlugin.refreshUnitTestsList();
+  }
+}
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 877fc21084..c71fff5a6d 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
@@ -173,6 +173,7 @@ import 
org.apache.hop.ui.hopgui.file.pipeline.delegates.HopGuiPipelineTransformD
 import 
org.apache.hop.ui.hopgui.file.pipeline.delegates.HopGuiPipelineUndoDelegate;
 import 
org.apache.hop.ui.hopgui.file.pipeline.extension.HopGuiPipelineFinishedExtension;
 import 
org.apache.hop.ui.hopgui.file.pipeline.extension.HopGuiPipelineGraphExtension;
+import 
org.apache.hop.ui.hopgui.file.pipeline.extension.PipelineRenamedExtension;
 import org.apache.hop.ui.hopgui.file.shared.HopGuiAbstractGraph;
 import org.apache.hop.ui.hopgui.file.shared.HopGuiTooltipExtension;
 import org.apache.hop.ui.hopgui.perspective.execution.ExecutionPerspective;
@@ -3805,6 +3806,7 @@ public class HopGuiPipelineGraph extends 
HopGuiAbstractGraph
   public void saveAs(String filename) throws HopException {
 
     try {
+      String oldFilename = pipelineMeta.getFilename();
 
       // Enforce file extension
       if 
(!filename.toLowerCase().endsWith(this.getFileType().getDefaultFileExtension()))
 {
@@ -3828,6 +3830,13 @@ public class HopGuiPipelineGraph extends 
HopGuiAbstractGraph
       pipelineMeta.setFilename(filename);
       save();
       hopGui.fileRefreshDelegate.register(filename, this);
+
+      // Allow the rest of the world to know that a file was renamed.
+      ExtensionPointHandler.callExtensionPoint(
+          log,
+          variables,
+          HopExtensionPoint.PipelineAfterSaveAs.id,
+          new PipelineRenamedExtension(pipelineMeta, oldFilename));
     } catch (Exception e) {
       throw new HopException("Error validating file existence for '" + 
filename + "'", e);
     }
diff --git 
a/ui/src/main/java/org/apache/hop/ui/hopgui/file/pipeline/extension/PipelineRenamedExtension.java
 
b/ui/src/main/java/org/apache/hop/ui/hopgui/file/pipeline/extension/PipelineRenamedExtension.java
new file mode 100644
index 0000000000..bce5d2fdd6
--- /dev/null
+++ 
b/ui/src/main/java/org/apache/hop/ui/hopgui/file/pipeline/extension/PipelineRenamedExtension.java
@@ -0,0 +1,38 @@
+/*
+ * 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.pipeline.extension;
+
+import lombok.Getter;
+import lombok.Setter;
+import org.apache.hop.pipeline.PipelineMeta;
+
+@Getter
+@Setter
+public class PipelineRenamedExtension {
+  private PipelineMeta pipelineMeta;
+  private String oldFilename;
+
+  public PipelineRenamedExtension() {}
+
+  public PipelineRenamedExtension(PipelineMeta pipelineMeta, String 
oldFilename) {
+    this();
+    this.pipelineMeta = pipelineMeta;
+    this.oldFilename = oldFilename;
+  }
+}

Reply via email to