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 189bea7a16 update metadata dropdowns while creating new referenced 
objects, fixes #4613 (#7018)
189bea7a16 is described below

commit 189bea7a166c4c97d2e2249958ef87a5318371b0
Author: Hans Van Akelyen <[email protected]>
AuthorDate: Fri Apr 17 15:15:10 2026 +0200

    update metadata dropdowns while creating new referenced objects, fixes 
#4613 (#7018)
---
 .../hop/ui/core/metadata/MetadataEditor.java       |  9 +++++
 .../hop/ui/core/metadata/MetadataEditorDialog.java |  2 ++
 .../hop/ui/core/widget/MetaSelectionLine.java      | 40 ++++++++++++++++++++--
 .../perspective/metadata/MetadataPerspective.java  | 10 +++++-
 .../config/PipelineRunConfigurationEditor.java     | 11 ++++++
 .../config/WorkflowRunConfigurationEditor.java     | 10 ++++++
 6 files changed, 78 insertions(+), 4 deletions(-)

diff --git 
a/ui/src/main/java/org/apache/hop/ui/core/metadata/MetadataEditor.java 
b/ui/src/main/java/org/apache/hop/ui/core/metadata/MetadataEditor.java
index 8a674e0118..9d8017ca52 100644
--- a/ui/src/main/java/org/apache/hop/ui/core/metadata/MetadataEditor.java
+++ b/ui/src/main/java/org/apache/hop/ui/core/metadata/MetadataEditor.java
@@ -207,6 +207,15 @@ public abstract class MetadataEditor<T extends 
IHopMetadata> extends MetadataFil
     }
   }
 
+  /**
+   * Called when the metadata modal dialog or metadata perspective tab becomes 
active again, so
+   * editors can reload metadata-backed combo items (e.g. execution 
information locations) that may
+   * have changed while the window was in the background.
+   */
+  public void refreshOnDialogActivate() {
+    // default: no-op
+  }
+
   /** Inline usage: copy information from the metadata onto the various 
widgets */
   public abstract void setWidgetsContent();
 
diff --git 
a/ui/src/main/java/org/apache/hop/ui/core/metadata/MetadataEditorDialog.java 
b/ui/src/main/java/org/apache/hop/ui/core/metadata/MetadataEditorDialog.java
index 9ff48c42ec..cbc4742529 100644
--- a/ui/src/main/java/org/apache/hop/ui/core/metadata/MetadataEditorDialog.java
+++ b/ui/src/main/java/org/apache/hop/ui/core/metadata/MetadataEditorDialog.java
@@ -104,6 +104,8 @@ public class MetadataEditorDialog extends Dialog implements 
IMetadataDialog {
     // Create editor controls
     editor.createControl(area);
 
+    shell.addListener(SWT.Activate, e -> editor.refreshOnDialogActivate());
+
     BaseDialog.defaultShellHandling(shell, c -> ok(), c -> cancel());
 
     return result;
diff --git 
a/ui/src/main/java/org/apache/hop/ui/core/widget/MetaSelectionLine.java 
b/ui/src/main/java/org/apache/hop/ui/core/widget/MetaSelectionLine.java
index 7c4ce5b09d..c635aa1bfa 100644
--- a/ui/src/main/java/org/apache/hop/ui/core/widget/MetaSelectionLine.java
+++ b/ui/src/main/java/org/apache/hop/ui/core/widget/MetaSelectionLine.java
@@ -82,6 +82,9 @@ public class MetaSelectionLine<T extends IHopMetadata> 
extends Composite {
   private ComboVar wCombo = null;
   private final Control wToolBar;
 
+  /** Prevents re-entrant refresh while {@link #fillItems()} runs. */
+  private boolean repopulatingItems;
+
   public MetaSelectionLine(
       IVariables variables,
       IHopMetadataProvider metadataProvider,
@@ -227,6 +230,25 @@ public class MetaSelectionLine<T extends IHopMetadata> 
extends Composite {
 
     PropsUi.setLook(wCombo);
 
+    // Refresh the item list whenever the user focuses the control (including 
opening the
+    // dropdown), so names added elsewhere in the GUI are visible without 
reopening the dialog.
+    wCombo
+        .getCComboWidget()
+        .addListener(
+            SWT.FocusIn,
+            e -> {
+              if (repopulatingItems || wCombo.getCComboWidget().isDisposed()) {
+                return;
+              }
+              try {
+                fillItems();
+              } catch (HopException ex) {
+                LogChannel.UI.logError(
+                    "Error refreshing list of " + getMetadataDescription() + " 
metadata elements",
+                    ex);
+              }
+            });
+
     layout(true, true);
   }
 
@@ -318,9 +340,21 @@ public class MetaSelectionLine<T extends IHopMetadata> 
extends Composite {
    * @throws HopException In case something went horribly wrong.
    */
   public void fillItems() throws HopException {
-    List<String> elementNames = manager.getSerializer().listObjectNames();
-    Collections.sort(elementNames);
-    wCombo.setItems(elementNames.toArray(new String[0]));
+    if (repopulatingItems) {
+      return;
+    }
+    repopulatingItems = true;
+    try {
+      String previous = wCombo.getText();
+      List<String> elementNames = manager.getSerializer().listObjectNames();
+      Collections.sort(elementNames);
+      wCombo.setItems(elementNames.toArray(new String[0]));
+      if (!wCombo.getCComboWidget().isDisposed()) {
+        wCombo.setText(Const.NVL(previous, ""));
+      }
+    } finally {
+      repopulatingItems = false;
+    }
   }
 
   /**
diff --git 
a/ui/src/main/java/org/apache/hop/ui/hopgui/perspective/metadata/MetadataPerspective.java
 
b/ui/src/main/java/org/apache/hop/ui/hopgui/perspective/metadata/MetadataPerspective.java
index 9a466a3369..de3ec739e8 100644
--- 
a/ui/src/main/java/org/apache/hop/ui/hopgui/perspective/metadata/MetadataPerspective.java
+++ 
b/ui/src/main/java/org/apache/hop/ui/hopgui/perspective/metadata/MetadataPerspective.java
@@ -561,7 +561,15 @@ public class MetadataPerspective implements 
IHopPerspective, TabClosable, IMetad
             closeTab(event, tabItem);
           }
         });
-    tabFolder.addListener(SWT.Selection, event -> updateGui());
+    tabFolder.addListener(
+        SWT.Selection,
+        event -> {
+          MetadataEditor<?> active = getActiveEditor();
+          if (active != null) {
+            active.refreshOnDialogActivate();
+          }
+          updateGui();
+        });
     PropsUi.setLook(tabFolder, Props.WIDGET_STYLE_TAB);
 
     // Show/Hide tree
diff --git 
a/ui/src/main/java/org/apache/hop/ui/pipeline/config/PipelineRunConfigurationEditor.java
 
b/ui/src/main/java/org/apache/hop/ui/pipeline/config/PipelineRunConfigurationEditor.java
index 1f90dc04f1..0fd24e336b 100644
--- 
a/ui/src/main/java/org/apache/hop/ui/pipeline/config/PipelineRunConfigurationEditor.java
+++ 
b/ui/src/main/java/org/apache/hop/ui/pipeline/config/PipelineRunConfigurationEditor.java
@@ -25,6 +25,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
 import org.apache.hop.core.Const;
 import org.apache.hop.core.exception.HopException;
 import org.apache.hop.core.gui.plugin.GuiPlugin;
+import org.apache.hop.core.logging.LogChannel;
 import org.apache.hop.core.plugins.IPlugin;
 import org.apache.hop.core.plugins.PluginRegistry;
 import org.apache.hop.core.variables.DescribedVariable;
@@ -502,6 +503,16 @@ public class PipelineRunConfigurationEditor extends 
MetadataEditor<PipelineRunCo
     super.save();
   }
 
+  @Override
+  public void refreshOnDialogActivate() {
+    try {
+      wExecutionInfoLocation.fillItems();
+      wProfile.fillItems();
+    } catch (Exception e) {
+      LogChannel.UI.logError("Error refreshing execution metadata lists", e);
+    }
+  }
+
   @Override
   public void setWidgetsContent() {
 
diff --git 
a/ui/src/main/java/org/apache/hop/ui/workflow/config/WorkflowRunConfigurationEditor.java
 
b/ui/src/main/java/org/apache/hop/ui/workflow/config/WorkflowRunConfigurationEditor.java
index b128b35f54..7414e9ade3 100644
--- 
a/ui/src/main/java/org/apache/hop/ui/workflow/config/WorkflowRunConfigurationEditor.java
+++ 
b/ui/src/main/java/org/apache/hop/ui/workflow/config/WorkflowRunConfigurationEditor.java
@@ -25,6 +25,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
 import org.apache.hop.core.Const;
 import org.apache.hop.core.exception.HopException;
 import org.apache.hop.core.gui.plugin.GuiPlugin;
+import org.apache.hop.core.logging.LogChannel;
 import org.apache.hop.core.plugins.IPlugin;
 import org.apache.hop.core.plugins.PluginRegistry;
 import org.apache.hop.execution.ExecutionInfoLocation;
@@ -336,6 +337,15 @@ public class WorkflowRunConfigurationEditor extends 
MetadataEditor<WorkflowRunCo
     super.save();
   }
 
+  @Override
+  public void refreshOnDialogActivate() {
+    try {
+      wExecutionInfoLocation.fillItems();
+    } catch (Exception e) {
+      LogChannel.UI.logError("Error refreshing execution information 
locations", e);
+    }
+  }
+
   @Override
   public void setWidgetsContent() {
 

Reply via email to