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

mcasters 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 ec53059fd2 Fix#6574 correct option to retrieve rows from previous 
transformations (#6582)
ec53059fd2 is described below

commit ec53059fd2aa05f84ee29fc0c0a0121ad1e670ea
Author: lance <[email protected]>
AuthorDate: Fri Feb 20 22:14:57 2026 +0800

    Fix#6574 correct option to retrieve rows from previous transformations 
(#6582)
    
    * Fix correct option to retrieve rows from previous transformations
    
    Signed-off-by: lance <[email protected]>
    
    * Fix correct option to retrieve rows from previous transformations
    
    Signed-off-by: lance <[email protected]>
    
    ---------
    
    Signed-off-by: lance <[email protected]>
---
 .../selectvalues/SelectValuesDialog.java           | 167 ++++++++-------------
 .../org/apache/hop/ui/core/FormDataBuilder.java    |  18 +++
 .../ui/pipeline/transform/BaseTransformDialog.java |  18 +--
 3 files changed, 86 insertions(+), 117 deletions(-)

diff --git 
a/plugins/transforms/selectvalues/src/main/java/org/apache/hop/pipeline/transforms/selectvalues/SelectValuesDialog.java
 
b/plugins/transforms/selectvalues/src/main/java/org/apache/hop/pipeline/transforms/selectvalues/SelectValuesDialog.java
index 448aeba603..87ff533107 100644
--- 
a/plugins/transforms/selectvalues/src/main/java/org/apache/hop/pipeline/transforms/selectvalues/SelectValuesDialog.java
+++ 
b/plugins/transforms/selectvalues/src/main/java/org/apache/hop/pipeline/transforms/selectvalues/SelectValuesDialog.java
@@ -41,6 +41,7 @@ import org.apache.hop.core.variables.IVariables;
 import org.apache.hop.i18n.BaseMessages;
 import org.apache.hop.pipeline.PipelineMeta;
 import org.apache.hop.pipeline.transform.TransformMeta;
+import org.apache.hop.ui.core.FormDataBuilder;
 import org.apache.hop.ui.core.PropsUi;
 import org.apache.hop.ui.core.dialog.BaseDialog;
 import org.apache.hop.ui.core.dialog.ErrorDialog;
@@ -55,8 +56,6 @@ import org.eclipse.swt.events.ModifyListener;
 import org.eclipse.swt.events.SelectionAdapter;
 import org.eclipse.swt.events.SelectionEvent;
 import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.layout.FormAttachment;
-import org.eclipse.swt.layout.FormData;
 import org.eclipse.swt.layout.FormLayout;
 import org.eclipse.swt.widgets.Button;
 import org.eclipse.swt.widgets.Composite;
@@ -156,19 +155,12 @@ public class SelectValuesDialog extends 
BaseTransformDialog {
     Label wlUnspecified = new Label(wSelectComp, SWT.RIGHT);
     wlUnspecified.setText(BaseMessages.getString(PKG, 
"SelectValuesDialog.Unspecified.Label"));
     PropsUi.setLook(wlUnspecified);
-    FormData fdlUnspecified = new FormData();
-    fdlUnspecified.left = new FormAttachment(0, 0);
-    fdlUnspecified.right = new FormAttachment(middle, 0);
-    fdlUnspecified.bottom = new FormAttachment(100, 0);
-    wlUnspecified.setLayoutData(fdlUnspecified);
+    wlUnspecified.setLayoutData(FormDataBuilder.builder().left().bottom(100, 
0).build());
 
     wUnspecified = new Button(wSelectComp, SWT.CHECK);
     PropsUi.setLook(wUnspecified);
-    FormData fdUnspecified = new FormData();
-    fdUnspecified.left = new FormAttachment(middle, margin);
-    fdUnspecified.right = new FormAttachment(100, 0);
-    fdUnspecified.bottom = new FormAttachment(wlUnspecified, 0, SWT.CENTER);
-    wUnspecified.setLayoutData(fdUnspecified);
+    wUnspecified.setLayoutData(
+        FormDataBuilder.builder().left(wlUnspecified, margin).bottom(100, 
5).build());
     wUnspecified.addSelectionListener(lsSel);
     // Update combo boxes when "Include unspecified fields" checkbox is toggled
     wUnspecified.addSelectionListener(
@@ -187,19 +179,16 @@ public class SelectValuesDialog extends 
BaseTransformDialog {
             }
           }
         });
+    // Label: select & Alter.  Button: Get fields to select
+    Label wlFields = new Label(wSelectComp, SWT.NONE);
+    wlFields.setText(BaseMessages.getString(PKG, 
"SelectValuesDialog.Fields.Label"));
+    PropsUi.setLook(wlFields);
+    wlFields.setLayoutData(FormDataBuilder.builder().top().left().build());
 
     Button wGetSelect = new Button(wSelectComp, SWT.PUSH);
     wGetSelect.setText(BaseMessages.getString(PKG, 
"SelectValuesDialog.GetSelect.Button"));
     wGetSelect.addListener(SWT.Selection, e -> get());
-    setButtonPositions(new Button[] {wGetSelect}, margin, null);
-
-    Label wlFields = new Label(wSelectComp, SWT.NONE);
-    wlFields.setText(BaseMessages.getString(PKG, 
"SelectValuesDialog.Fields.Label"));
-    PropsUi.setLook(wlFields);
-    FormData fdlFields = new FormData();
-    fdlFields.left = new FormAttachment(0, 0);
-    fdlFields.top = new FormAttachment(0, 0);
-    wlFields.setLayoutData(fdlFields);
+    wGetSelect.setLayoutData(FormDataBuilder.builder().top().right().build());
 
     final int fieldsCols = 4;
     final int fieldsRows = input.getSelectOption().getSelectFields().size();
@@ -242,24 +231,15 @@ public class SelectValuesDialog extends 
BaseTransformDialog {
             lsMod,
             props);
 
-    FormData fdFields = new FormData();
-    fdFields.left = new FormAttachment(0, 0);
-    fdFields.top = new FormAttachment(wlFields, margin);
-    fdFields.right = new FormAttachment(100, 0);
-    fdFields.bottom = new FormAttachment(wlUnspecified, -margin);
-    wFields.setLayoutData(fdFields);
-
-    fdlUnspecified.bottom = new FormAttachment(wGetSelect, -margin);
-    wlUnspecified.setLayoutData(fdlUnspecified);
-    fdUnspecified.bottom = new FormAttachment(wGetSelect, -margin);
-    wUnspecified.setLayoutData(fdUnspecified);
-
-    FormData fdSelectComp = new FormData();
-    fdSelectComp.left = new FormAttachment(0, 0);
-    fdSelectComp.top = new FormAttachment(0, 0);
-    fdSelectComp.right = new FormAttachment(100, 0);
-    fdSelectComp.bottom = new FormAttachment(100, 0);
-    wSelectComp.setLayoutData(fdSelectComp);
+    wFields.setLayoutData(
+        FormDataBuilder.builder()
+            .top(wlFields, margin)
+            .left()
+            .right()
+            .bottom(wlUnspecified, -2 * margin)
+            .build());
+    wSelectComp.setLayoutData(
+        FormDataBuilder.builder().top().left().right().bottom(100, 0).build());
 
     wSelectComp.layout();
     wSelectTab.setControl(wSelectComp);
@@ -283,18 +263,15 @@ public class SelectValuesDialog extends 
BaseTransformDialog {
     PropsUi.setLook(wRemoveComp);
     wRemoveComp.setLayout(contentLayout);
 
-    Button wGetRemove = new Button(wRemoveComp, SWT.PUSH);
-    wGetRemove.setText(BaseMessages.getString(PKG, 
"SelectValuesDialog.GetRemove.Button"));
-    wGetRemove.addListener(SWT.Selection, e -> get());
-    setButtonPositions(new Button[] {wGetRemove}, margin, null);
-
     Label wlRemove = new Label(wRemoveComp, SWT.NONE);
     wlRemove.setText(BaseMessages.getString(PKG, 
"SelectValuesDialog.Remove.Label"));
     PropsUi.setLook(wlRemove);
-    FormData fdlRemove = new FormData();
-    fdlRemove.left = new FormAttachment(0, 0);
-    fdlRemove.top = new FormAttachment(0, 0);
-    wlRemove.setLayoutData(fdlRemove);
+    wlRemove.setLayoutData(FormDataBuilder.builder().top().left().build());
+
+    Button wGetRemove = new Button(wRemoveComp, SWT.PUSH);
+    wGetRemove.setText(BaseMessages.getString(PKG, 
"SelectValuesDialog.GetRemove.Button"));
+    wGetRemove.addListener(SWT.Selection, e -> get());
+    wGetRemove.setLayoutData(FormDataBuilder.builder().top().right().build());
 
     final int RemoveCols = 1;
     final int RemoveRows = input.getSelectOption().getDeleteName().size();
@@ -319,20 +296,9 @@ public class SelectValuesDialog extends 
BaseTransformDialog {
             RemoveRows,
             lsMod,
             props);
-
-    FormData fdRemove = new FormData();
-    fdRemove.left = new FormAttachment(0, 0);
-    fdRemove.top = new FormAttachment(wlRemove, margin);
-    fdRemove.right = new FormAttachment(100, 0);
-    fdRemove.bottom = new FormAttachment(wGetRemove, -margin);
-    wRemove.setLayoutData(fdRemove);
-
-    FormData fdRemoveComp = new FormData();
-    fdRemoveComp.left = new FormAttachment(0, 0);
-    fdRemoveComp.top = new FormAttachment(0, 0);
-    fdRemoveComp.right = new FormAttachment(100, 0);
-    fdRemoveComp.bottom = new FormAttachment(100, 0);
-    wRemoveComp.setLayoutData(fdRemoveComp);
+    wRemove.setLayoutData(
+        FormDataBuilder.builder().top(wlRemove, 
margin).left().right().bottom(100, 0).build());
+    
wRemoveComp.setLayoutData(FormDataBuilder.builder().top().left().bottom(100, 
0).build());
 
     wRemoveComp.layout();
     wRemoveTab.setControl(wRemoveComp);
@@ -357,18 +323,15 @@ public class SelectValuesDialog extends 
BaseTransformDialog {
     metaLayout.marginHeight = margin;
     wMetaComp.setLayout(metaLayout);
 
-    Button wGetMeta = new Button(wMetaComp, SWT.PUSH);
-    wGetMeta.setText(BaseMessages.getString(PKG, 
"SelectValuesDialog.GetMeta.Button"));
-    wGetMeta.addListener(SWT.Selection, e -> get());
-    setButtonPositions(new Button[] {wGetMeta}, margin, null);
-
     Label wlMeta = new Label(wMetaComp, SWT.NONE);
     wlMeta.setText(BaseMessages.getString(PKG, 
"SelectValuesDialog.Meta.Label"));
     PropsUi.setLook(wlMeta);
-    FormData fdlMeta = new FormData();
-    fdlMeta.left = new FormAttachment(0, 0);
-    fdlMeta.top = new FormAttachment(0, 0);
-    wlMeta.setLayoutData(fdlMeta);
+    wlMeta.setLayoutData(FormDataBuilder.builder().top().left().build());
+
+    Button wGetMeta = new Button(wMetaComp, SWT.PUSH);
+    wGetMeta.setText(BaseMessages.getString(PKG, 
"SelectValuesDialog.GetMeta.Button"));
+    wGetMeta.addListener(SWT.Selection, e -> get());
+    wGetMeta.setLayoutData(FormDataBuilder.builder().top().right().build());
 
     final int MetaRows = input.getSelectOption().getMeta().size();
 
@@ -450,7 +413,8 @@ public class SelectValuesDialog extends BaseTransformDialog 
{
     colmeta[5].setToolTip(
         BaseMessages.getString(PKG, 
"SelectValuesDialog.ColumnInfo.Storage.Tooltip"));
     fieldColumns.add(colmeta[0]);
-    metaFieldColumns.add(colmeta[0]); // Metadata tab should show fields 
remaining after Remove
+    // Metadata tab should show fields remaining after Remove
+    metaFieldColumns.add(colmeta[0]);
     wMeta =
         new TableView(
             variables,
@@ -461,19 +425,10 @@ public class SelectValuesDialog extends 
BaseTransformDialog {
             lsMod,
             props);
 
-    FormData fdMeta = new FormData();
-    fdMeta.left = new FormAttachment(0, 0);
-    fdMeta.top = new FormAttachment(wlMeta, margin);
-    fdMeta.right = new FormAttachment(100, 0);
-    fdMeta.bottom = new FormAttachment(wGetMeta, -margin);
-    wMeta.setLayoutData(fdMeta);
-
-    FormData fdMetaComp = new FormData();
-    fdMetaComp.left = new FormAttachment(0, 0);
-    fdMetaComp.top = new FormAttachment(0, 0);
-    fdMetaComp.right = new FormAttachment(100, 0);
-    fdMetaComp.bottom = new FormAttachment(100, 0);
-    wMetaComp.setLayoutData(fdMetaComp);
+    wMeta.setLayoutData(
+        FormDataBuilder.builder().top(wlMeta, 
margin).left().right().bottom(100, 0).build());
+    wMetaComp.setLayoutData(
+        FormDataBuilder.builder().top().left().right(100, 0).bottom(100, 
0).build());
 
     wMetaComp.layout();
     wMetaTab.setControl(wMetaComp);
@@ -481,13 +436,13 @@ public class SelectValuesDialog extends 
BaseTransformDialog {
     // ///////////////////////////////////////////////////////////
     // / END OF META TAB
     // ///////////////////////////////////////////////////////////
-
-    FormData fdTabFolder = new FormData();
-    fdTabFolder.left = new FormAttachment(0, 0);
-    fdTabFolder.top = new FormAttachment(wSpacer, margin);
-    fdTabFolder.right = new FormAttachment(100, 0);
-    fdTabFolder.bottom = new FormAttachment(wOk, -margin);
-    wTabFolder.setLayoutData(fdTabFolder);
+    wTabFolder.setLayoutData(
+        FormDataBuilder.builder()
+            .top(wTransformName, margin)
+            .left()
+            .right(100, 0)
+            .bottom(wOk, -2 * margin)
+            .build());
 
     // Add a listener to update combo boxes when switching tabs
     // This ensures Remove and Metadata tabs see any field renamings from 
Select & Alter tab
@@ -592,15 +547,15 @@ public class SelectValuesDialog extends 
BaseTransformDialog {
 
   /** Copy information from the meta-data input to the dialog fields. */
   public void getData() {
-    wTabFolder.setSelection(0); // Default
+    wTabFolder.setSelection(0);
 
     /*
      * Select fields
      */
-    if (input.getSelectOption().getSelectFields() != null
-        && !input.getSelectOption().getSelectFields().isEmpty()) {
-      for (int i = 0; i < input.getSelectOption().getSelectFields().size(); 
i++) {
-        SelectField selectField = 
input.getSelectOption().getSelectFields().get(i);
+    List<SelectField> fields = input.getSelectOption().getSelectFields();
+    if (!Utils.isEmpty(fields)) {
+      for (int i = 0; i < fields.size(); i++) {
+        SelectField selectField = fields.get(i);
         TableItem item = wFields.table.getItem(i);
         if (selectField.getName() != null) {
           item.setText(1, selectField.getName());
@@ -614,17 +569,16 @@ public class SelectValuesDialog extends 
BaseTransformDialog {
       }
       wFields.setRowNums();
       wFields.optWidth(true);
-      wTabFolder.setSelection(0);
     }
     
wUnspecified.setSelection(input.getSelectOption().isSelectingAndSortingUnspecifiedFields());
 
     /*
      * Remove certain fields...
      */
-    if (input.getSelectOption().getDeleteName() != null
-        && !input.getSelectOption().getDeleteName().isEmpty()) {
-      for (int i = 0; i < input.getSelectOption().getDeleteName().size(); i++) 
{
-        DeleteField deleteName = 
input.getSelectOption().getDeleteName().get(i);
+    List<DeleteField> deleteFields = input.getSelectOption().getDeleteName();
+    if (!Utils.isEmpty(deleteFields)) {
+      for (int i = 0; i < deleteFields.size(); i++) {
+        DeleteField deleteName = deleteFields.get(i);
         TableItem item = wRemove.table.getItem(i);
         if (deleteName != null) {
           item.setText(1, deleteName.getName());
@@ -632,15 +586,15 @@ public class SelectValuesDialog extends 
BaseTransformDialog {
       }
       wRemove.setRowNums();
       wRemove.optWidth(true);
-      wTabFolder.setSelection(1);
     }
 
     /*
      * Change the meta-data of certain fields
      */
-    if (!Utils.isEmpty(input.getSelectOption().getMeta())) {
-      for (int i = 0; i < input.getSelectOption().getMeta().size(); i++) {
-        SelectMetadataChange change = input.getSelectOption().getMeta().get(i);
+    List<SelectMetadataChange> meta = input.getSelectOption().getMeta();
+    if (!Utils.isEmpty(meta)) {
+      for (int i = 0; i < meta.size(); i++) {
+        SelectMetadataChange change = meta.get(i);
 
         TableItem item = wMeta.table.getItem(i);
         int index = 1;
@@ -685,7 +639,6 @@ public class SelectValuesDialog extends BaseTransformDialog 
{
       }
       wMeta.setRowNums();
       wMeta.optWidth(true);
-      wTabFolder.setSelection(2);
     }
   }
 
diff --git a/ui/src/main/java/org/apache/hop/ui/core/FormDataBuilder.java 
b/ui/src/main/java/org/apache/hop/ui/core/FormDataBuilder.java
index 4f685bef5a..0a36b1e7a3 100644
--- a/ui/src/main/java/org/apache/hop/ui/core/FormDataBuilder.java
+++ b/ui/src/main/java/org/apache/hop/ui/core/FormDataBuilder.java
@@ -17,6 +17,7 @@
 
 package org.apache.hop.ui.core;
 
+import org.eclipse.swt.SWT;
 import org.eclipse.swt.layout.FormAttachment;
 import org.eclipse.swt.layout.FormData;
 import org.eclipse.swt.widgets.Control;
@@ -128,6 +129,23 @@ public class FormDataBuilder implements Cloneable {
     return bottom(new FormAttachment(control, margin));
   }
 
+  /**
+   * Sets the bottom attachment of this {@code FormDataBuilder} relative to 
the specified control.
+   *
+   * <p>The bottom edge will be attached to the given {@link Control} with the 
specified margin and
+   * alignment.
+   *
+   * @param control the reference control to which the bottom edge will be 
attached; must not be
+   *     {@code null}
+   * @param margin the offset in pixels from the specified control
+   * @param alignment the alignment relative to the control (for example, 
{@link SWT#TOP}, {@link
+   *     SWT#BOTTOM}, or {@link SWT#CENTER})
+   * @return this {@code FormDataBuilder} instance for method chaining
+   */
+  public FormDataBuilder bottom(Control control, int margin, int alignment) {
+    return bottom(new FormAttachment(control, margin, alignment));
+  }
+
   public FormDataBuilder right(Control control, int margin) {
     return right(new FormAttachment(control, margin));
   }
diff --git 
a/ui/src/main/java/org/apache/hop/ui/pipeline/transform/BaseTransformDialog.java
 
b/ui/src/main/java/org/apache/hop/ui/pipeline/transform/BaseTransformDialog.java
index 5f08207517..2f79ebefb3 100644
--- 
a/ui/src/main/java/org/apache/hop/ui/pipeline/transform/BaseTransformDialog.java
+++ 
b/ui/src/main/java/org/apache/hop/ui/pipeline/transform/BaseTransformDialog.java
@@ -1141,19 +1141,22 @@ public abstract class BaseTransformDialog extends 
Dialog implements ITransformDi
     }
 
     int choice = 0;
+    boolean isOpenDialog = false;
 
     if (!keys.isEmpty()) {
       // Ask what we should do with the existing data in the transform.
-      //
       DialogBoxWithButtons getFieldsChoiceDialog =
           getFieldsChoiceDialogProvider.provide(tableView.getShell(), 
keys.size(), row.size());
 
       int idx = getFieldsChoiceDialog.open();
       choice = idx & 0xFF;
+      // Mark that the dialog was actually opened.
+      isOpenDialog = true;
     }
 
-    if (choice == 3 || choice == 255) {
-      return; // Cancel clicked
+    // Cancel clicked, Close x
+    if ((choice == 0 && isOpenDialog) || choice == 3 || choice == 255) {
+      return;
     }
 
     if (choice == 2) {
@@ -1163,13 +1166,8 @@ public abstract class BaseTransformDialog extends Dialog 
implements ITransformDi
     for (int i = 0; i < row.size(); i++) {
       IValueMeta v = row.getValueMeta(i);
 
-      boolean add = true;
-
-      if (choice == 0
-          && keys.indexOf(v.getName()) >= 0) { // hang on, see if it's not yet 
in the table view
-        add = false;
-      }
-
+      // hang on, see if it's not yet in the table view
+      boolean add = choice != 0 || !keys.contains(v.getName());
       if (add) {
         TableItem tableItem = new TableItem(table, SWT.NONE);
 

Reply via email to