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 f8b37694f1 when tableview is disabled it should dispose the active 
editors, fixes #6409 (#6410)
f8b37694f1 is described below

commit f8b37694f17d8d2e773c268b00d26ede25325ee3
Author: Hans Van Akelyen <[email protected]>
AuthorDate: Sat Jan 17 11:13:26 2026 +0100

    when tableview is disabled it should dispose the active editors, fixes 
#6409 (#6410)
    
    Update grid when activating, Ingore manual fields
---
 .../transforms/excelinput/ExcelInputDialog.java    | 29 +++++--
 .../excelwriter/ExcelWriterTransformDialog.java    | 29 +++++--
 .../transforms/csvinput/CsvInputDialog.java        | 32 ++++++--
 .../fileinput/text/TextFileInputDialog.java        | 33 ++++++--
 .../textfileoutput/TextFileOutputDialog.java       | 23 ++++--
 .../org/apache/hop/ui/core/widget/TableView.java   | 91 +++++++++++++++-------
 6 files changed, 178 insertions(+), 59 deletions(-)

diff --git 
a/plugins/transforms/excel/src/main/java/org/apache/hop/pipeline/transforms/excelinput/ExcelInputDialog.java
 
b/plugins/transforms/excel/src/main/java/org/apache/hop/pipeline/transforms/excelinput/ExcelInputDialog.java
index 6f5e8e4b61..653dfb4d4a 100644
--- 
a/plugins/transforms/excel/src/main/java/org/apache/hop/pipeline/transforms/excelinput/ExcelInputDialog.java
+++ 
b/plugins/transforms/excel/src/main/java/org/apache/hop/pipeline/transforms/excelinput/ExcelInputDialog.java
@@ -808,7 +808,15 @@ public class ExcelInputDialog extends BaseTransformDialog {
     fdIgnoreFields.right = new FormAttachment(100, 0);
     fdIgnoreFields.top = new FormAttachment(wlIgnoreFields, 0, SWT.CENTER);
     wIgnoreFields.setLayoutData(fdIgnoreFields);
-    wIgnoreFields.addListener(SWT.Selection, e -> setFlags());
+    wIgnoreFields.addListener(
+        SWT.Selection,
+        e -> {
+          // If checkbox is being checked (not unchecked), refresh from schema
+          if (wIgnoreFields.getSelection()) {
+            fillFieldsLayoutFromSchema(false);
+          }
+          setFlags();
+        });
 
     Group wManualSchemaDefinition = new Group(wFieldsComp, SWT.SHADOW_NONE);
     PropsUi.setLook(wManualSchemaDefinition);
@@ -940,16 +948,23 @@ public class ExcelInputDialog extends BaseTransformDialog 
{
   }
 
   private void fillFieldsLayoutFromSchema() {
+    fillFieldsLayoutFromSchema(true);
+  }
+
+  private void fillFieldsLayoutFromSchema(boolean askConfirmation) {
 
     if (!wSchemaDefinition.isDisposed()) {
       final String schemaName = wSchemaDefinition.getText();
 
-      MessageBox mb = new MessageBox(shell, SWT.ICON_QUESTION | SWT.NO | 
SWT.YES);
-      mb.setMessage(
-          BaseMessages.getString(
-              PKG, "ExcelInputDialog.Load.SchemaDefinition.Message", 
schemaName));
-      mb.setText(BaseMessages.getString(PKG, 
"ExcelInputDialog.Load.SchemaDefinition.Title"));
-      int answer = mb.open();
+      int answer = SWT.YES;
+      if (askConfirmation) {
+        MessageBox mb = new MessageBox(shell, SWT.ICON_QUESTION | SWT.NO | 
SWT.YES);
+        mb.setMessage(
+            BaseMessages.getString(
+                PKG, "ExcelInputDialog.Load.SchemaDefinition.Message", 
schemaName));
+        mb.setText(BaseMessages.getString(PKG, 
"ExcelInputDialog.Load.SchemaDefinition.Title"));
+        answer = mb.open();
+      }
 
       if (answer == SWT.YES && !Utils.isEmpty(schemaName)) {
         try {
diff --git 
a/plugins/transforms/excel/src/main/java/org/apache/hop/pipeline/transforms/excelwriter/ExcelWriterTransformDialog.java
 
b/plugins/transforms/excel/src/main/java/org/apache/hop/pipeline/transforms/excelwriter/ExcelWriterTransformDialog.java
index eaa3bfeb84..47673e1e4e 100644
--- 
a/plugins/transforms/excel/src/main/java/org/apache/hop/pipeline/transforms/excelwriter/ExcelWriterTransformDialog.java
+++ 
b/plugins/transforms/excel/src/main/java/org/apache/hop/pipeline/transforms/excelwriter/ExcelWriterTransformDialog.java
@@ -1428,7 +1428,15 @@ public class ExcelWriterTransformDialog extends 
BaseTransformDialog {
     fdIgnoreFields.right = new FormAttachment(100, 0);
     fdIgnoreFields.top = new FormAttachment(wlIgnoreFields, 0, SWT.CENTER);
     wIgnoreFields.setLayoutData(fdIgnoreFields);
-    wIgnoreFields.addListener(SWT.Selection, e -> enableIgnorefiedls());
+    wIgnoreFields.addListener(
+        SWT.Selection,
+        e -> {
+          // If checkbox is being checked (not unchecked), refresh from schema
+          if (wIgnoreFields.getSelection()) {
+            fillFieldsLayoutFromSchema(false);
+          }
+          enableIgnorefiedls();
+        });
 
     Collections.sort(nonReservedFormats);
     String[] formats = nonReservedFormats.toArray(new String[0]);
@@ -1660,16 +1668,23 @@ public class ExcelWriterTransformDialog extends 
BaseTransformDialog {
   }
 
   private void fillFieldsLayoutFromSchema() {
+    fillFieldsLayoutFromSchema(true);
+  }
+
+  private void fillFieldsLayoutFromSchema(boolean askConfirmation) {
 
     if (!wSchemaDefinition.isDisposed()) {
       final String schemaName = wSchemaDefinition.getText();
 
-      MessageBox mb = new MessageBox(shell, SWT.ICON_QUESTION | SWT.NO | 
SWT.YES);
-      mb.setMessage(
-          BaseMessages.getString(
-              PKG, "ExcelWriterDialog.Load.SchemaDefinition.Message", 
schemaName));
-      mb.setText(BaseMessages.getString(PKG, 
"ExcelWriterDialog.Load.SchemaDefinition.Title"));
-      int answer = mb.open();
+      int answer = SWT.YES;
+      if (askConfirmation) {
+        MessageBox mb = new MessageBox(shell, SWT.ICON_QUESTION | SWT.NO | 
SWT.YES);
+        mb.setMessage(
+            BaseMessages.getString(
+                PKG, "ExcelWriterDialog.Load.SchemaDefinition.Message", 
schemaName));
+        mb.setText(BaseMessages.getString(PKG, 
"ExcelWriterDialog.Load.SchemaDefinition.Title"));
+        answer = mb.open();
+      }
 
       if (answer == SWT.YES && !Utils.isEmpty(schemaName)) {
         try {
diff --git 
a/plugins/transforms/textfile/src/main/java/org/apache/hop/pipeline/transforms/csvinput/CsvInputDialog.java
 
b/plugins/transforms/textfile/src/main/java/org/apache/hop/pipeline/transforms/csvinput/CsvInputDialog.java
index b246862be9..108eb3c2ae 100644
--- 
a/plugins/transforms/textfile/src/main/java/org/apache/hop/pipeline/transforms/csvinput/CsvInputDialog.java
+++ 
b/plugins/transforms/textfile/src/main/java/org/apache/hop/pipeline/transforms/csvinput/CsvInputDialog.java
@@ -676,7 +676,19 @@ public class CsvInputDialog extends BaseTransformDialog
             setFlags();
           }
         };
-    wIgnoreFields.addSelectionListener(lsFlags);
+
+    // When ignoring manual fields, refresh fields from schema one last time
+    wIgnoreFields.addSelectionListener(
+        new SelectionAdapter() {
+          @Override
+          public void widgetSelected(SelectionEvent e) {
+            // If checkbox is being checked (not unchecked), refresh from 
schema
+            if (wIgnoreFields.getSelection()) {
+              fillFieldsLayoutFromSchema(false);
+            }
+            setFlags();
+          }
+        });
 
     getData();
 
@@ -719,15 +731,23 @@ public class CsvInputDialog extends BaseTransformDialog
   }
 
   private void fillFieldsLayoutFromSchema() {
+    fillFieldsLayoutFromSchema(true);
+  }
+
+  private void fillFieldsLayoutFromSchema(boolean askConfirmation) {
 
     if (!wSchemaDefinition.isDisposed()) {
       final String schemaName = wSchemaDefinition.getText();
 
-      MessageBox mb = new MessageBox(shell, SWT.ICON_QUESTION | SWT.NO | 
SWT.YES);
-      mb.setMessage(
-          BaseMessages.getString(PKG, 
"CsvInputDialog.Load.SchemaDefinition.Message", schemaName));
-      mb.setText(BaseMessages.getString(PKG, 
"CsvInputDialog.Load.SchemaDefinition.Title"));
-      int answer = mb.open();
+      int answer = SWT.YES;
+      if (askConfirmation) {
+        MessageBox mb = new MessageBox(shell, SWT.ICON_QUESTION | SWT.NO | 
SWT.YES);
+        mb.setMessage(
+            BaseMessages.getString(
+                PKG, "CsvInputDialog.Load.SchemaDefinition.Message", 
schemaName));
+        mb.setText(BaseMessages.getString(PKG, 
"CsvInputDialog.Load.SchemaDefinition.Title"));
+        answer = mb.open();
+      }
 
       if (answer == SWT.YES && !Utils.isEmpty(schemaName)) {
         try {
diff --git 
a/plugins/transforms/textfile/src/main/java/org/apache/hop/pipeline/transforms/fileinput/text/TextFileInputDialog.java
 
b/plugins/transforms/textfile/src/main/java/org/apache/hop/pipeline/transforms/fileinput/text/TextFileInputDialog.java
index c1f7779167..beeef82bb1 100644
--- 
a/plugins/transforms/textfile/src/main/java/org/apache/hop/pipeline/transforms/fileinput/text/TextFileInputDialog.java
+++ 
b/plugins/transforms/textfile/src/main/java/org/apache/hop/pipeline/transforms/fileinput/text/TextFileInputDialog.java
@@ -485,7 +485,19 @@ public class TextFileInputDialog extends 
BaseTransformDialog
     wWraps.addSelectionListener(lsFlags);
     wLayoutPaged.addSelectionListener(lsFlags);
     wAccFilenames.addSelectionListener(lsFlags);
-    wIgnoreFields.addSelectionListener(lsFlags);
+
+    // When ignoring manual fields, refresh fields from schema one last time
+    wIgnoreFields.addSelectionListener(
+        new SelectionAdapter() {
+          @Override
+          public void widgetSelected(SelectionEvent e) {
+            // If checkbox is being checked (not unchecked), refresh from 
schema
+            if (wIgnoreFields.getSelection()) {
+              fillFieldsLayoutFromSchema(false);
+            }
+            setFlags();
+          }
+        });
 
     wbbFilename.addListener(
         SWT.Selection,
@@ -2163,16 +2175,23 @@ public class TextFileInputDialog extends 
BaseTransformDialog
   }
 
   private void fillFieldsLayoutFromSchema() {
+    fillFieldsLayoutFromSchema(true);
+  }
+
+  private void fillFieldsLayoutFromSchema(boolean askConfirmation) {
 
     if (!wSchemaDefinition.isDisposed()) {
       final String schemaName = wSchemaDefinition.getText();
 
-      MessageBox mb = new MessageBox(shell, SWT.ICON_QUESTION | SWT.NO | 
SWT.YES);
-      mb.setMessage(
-          BaseMessages.getString(
-              PKG, "TextFileInputDialog.Load.SchemaDefinition.Message", 
schemaName));
-      mb.setText(BaseMessages.getString(PKG, 
"TextFileInputDialog.Load.SchemaDefinition.Title"));
-      int answer = mb.open();
+      int answer = SWT.YES;
+      if (askConfirmation) {
+        MessageBox mb = new MessageBox(shell, SWT.ICON_QUESTION | SWT.NO | 
SWT.YES);
+        mb.setMessage(
+            BaseMessages.getString(
+                PKG, "TextFileInputDialog.Load.SchemaDefinition.Message", 
schemaName));
+        mb.setText(BaseMessages.getString(PKG, 
"TextFileInputDialog.Load.SchemaDefinition.Title"));
+        answer = mb.open();
+      }
 
       if (answer == SWT.YES && !Utils.isEmpty(schemaName)) {
         try {
diff --git 
a/plugins/transforms/textfile/src/main/java/org/apache/hop/pipeline/transforms/textfileoutput/TextFileOutputDialog.java
 
b/plugins/transforms/textfile/src/main/java/org/apache/hop/pipeline/transforms/textfileoutput/TextFileOutputDialog.java
index 0259e0cddf..1079e930df 100644
--- 
a/plugins/transforms/textfile/src/main/java/org/apache/hop/pipeline/transforms/textfileoutput/TextFileOutputDialog.java
+++ 
b/plugins/transforms/textfile/src/main/java/org/apache/hop/pipeline/transforms/textfileoutput/TextFileOutputDialog.java
@@ -1128,6 +1128,10 @@ public class TextFileOutputDialog extends 
BaseTransformDialog {
         new SelectionAdapter() {
           @Override
           public void widgetSelected(SelectionEvent e) {
+            // If checkbox is being checked (not unchecked), refresh from 
schema
+            if (wIgnoreFields.getSelection()) {
+              fillFieldsLayoutFromSchema(false);
+            }
             wFields.setEnabled(!wIgnoreFields.getSelection());
             wGet.setEnabled(!wIgnoreFields.getSelection());
             wMinWidth.setEnabled(!wIgnoreFields.getSelection());
@@ -1288,16 +1292,23 @@ public class TextFileOutputDialog extends 
BaseTransformDialog {
   }
 
   private void fillFieldsLayoutFromSchema() {
+    fillFieldsLayoutFromSchema(true);
+  }
+
+  private void fillFieldsLayoutFromSchema(boolean askConfirmation) {
 
     if (!wSchemaDefinition.isDisposed()) {
       final String schemaName = wSchemaDefinition.getText();
 
-      MessageBox mb = new MessageBox(shell, SWT.ICON_QUESTION | SWT.NO | 
SWT.YES);
-      mb.setMessage(
-          BaseMessages.getString(
-              PKG, "TextFileOutputDialog.Load.SchemaDefinition.Message", 
schemaName));
-      mb.setText(BaseMessages.getString(PKG, 
"TextFileOutputDialog.Load.SchemaDefinition.Title"));
-      int answer = mb.open();
+      int answer = SWT.YES;
+      if (askConfirmation) {
+        MessageBox mb = new MessageBox(shell, SWT.ICON_QUESTION | SWT.NO | 
SWT.YES);
+        mb.setMessage(
+            BaseMessages.getString(
+                PKG, "TextFileOutputDialog.Load.SchemaDefinition.Message", 
schemaName));
+        mb.setText(BaseMessages.getString(PKG, 
"TextFileOutputDialog.Load.SchemaDefinition.Title"));
+        answer = mb.open();
+      }
 
       if (answer == SWT.YES && !Utils.isEmpty(schemaName)) {
         try {
diff --git a/ui/src/main/java/org/apache/hop/ui/core/widget/TableView.java 
b/ui/src/main/java/org/apache/hop/ui/core/widget/TableView.java
index 89efb73200..b101984d45 100644
--- a/ui/src/main/java/org/apache/hop/ui/core/widget/TableView.java
+++ b/ui/src/main/java/org/apache/hop/ui/core/widget/TableView.java
@@ -116,6 +116,12 @@ public class TableView extends Composite {
     if (toolbar != null) {
       toolbar.setEnabled(enabled);
     }
+
+    // Cleanup active editors when disabling the table
+    if (!enabled) {
+      closeActiveEditors();
+    }
+
     this.table.setEnabled(enabled);
   }
 
@@ -2300,20 +2306,9 @@ public class TableView extends Composite {
     int[] items = table.getSelectionIndices();
     table.setSelection(items);
 
-    // Check if there is an active editor and save its value before deleting 
rows
+    // Close any active editors before deleting rows
     // This prevents the editor value from being saved to the wrong row
-    if (text != null && !text.isDisposed() && lsFocusText != null) {
-      lsFocusText.focusLost(null);
-      // Text focus lost handler disposes the control itself
-    } else if (combo != null && !combo.isDisposed() && lsFocusCombo != null) {
-      lsFocusCombo.focusLost(null);
-      // Combo focus lost handler doesn't dispose, so we need to do it
-      safelyDisposeControl(combo);
-    } else if (comboVar != null && !comboVar.isDisposed() && lsFocusCombo != 
null) {
-      lsFocusCombo.focusLost(null);
-      // ComboVar focus lost handler doesn't dispose, so we need to do it
-      safelyDisposeControl(comboVar);
-    }
+    closeActiveEditors();
 
     if (items.length == 0) {
       return;
@@ -2409,20 +2404,9 @@ public class TableView extends Composite {
     ta.setDelete(before, itemsToDelete);
     addUndo(ta);
 
-    // Check if there is an active editor and save its value before deleting 
rows
+    // Close any active editors before deleting rows
     // This prevents the editor value from being saved to the wrong row
-    if (text != null && !text.isDisposed() && lsFocusText != null) {
-      lsFocusText.focusLost(null);
-      // Text focus lost handler disposes the control itself
-    } else if (combo != null && !combo.isDisposed() && lsFocusCombo != null) {
-      lsFocusCombo.focusLost(null);
-      // Combo focus lost handler doesn't dispose, so we need to do it
-      safelyDisposeControl(combo);
-    } else if (comboVar != null && !comboVar.isDisposed() && lsFocusCombo != 
null) {
-      lsFocusCombo.focusLost(null);
-      // ComboVar focus lost handler doesn't dispose, so we need to do it
-      safelyDisposeControl(comboVar);
-    }
+    closeActiveEditors();
 
     // Delete non-selected items.
     table.remove(itemsToDelete);
@@ -3501,6 +3485,61 @@ public class TableView extends Composite {
     }
   }
 
+  /**
+   * Closes and cleans up any active editors in the table. This method should 
be called when you
+   * need to ensure that no editors are active, such as when disabling the 
table, deleting rows, or
+   * performing other operations that require a clean state.
+   *
+   * <p>This method:
+   *
+   * <ul>
+   *   <li>Triggers focus lost handlers to save any pending edits
+   *   <li>Safely disposes all active editor controls (text, combo, comboVar, 
button)
+   *   <li>Cleans up the TableEditor's active control
+   * </ul>
+   */
+  public void closeActiveEditors() {
+    // Check if there is an active text editor and save its value
+    if (text != null && !text.isDisposed() && lsFocusText != null) {
+      lsFocusText.focusLost(null);
+      // Text focus lost handler disposes the control itself
+    }
+
+    // Check if there is an active combo editor and save its value
+    if (combo != null && !combo.isDisposed() && lsFocusCombo != null) {
+      lsFocusCombo.focusLost(null);
+      // Combo focus lost handler doesn't dispose, so we need to do it
+      safelyDisposeControl(combo);
+      combo = null;
+    }
+
+    // Check if there is an active comboVar editor and save its value
+    if (comboVar != null && !comboVar.isDisposed() && lsFocusCombo != null) {
+      lsFocusCombo.focusLost(null);
+      // ComboVar focus lost handler doesn't dispose, so we need to do it
+      safelyDisposeControl(comboVar);
+      comboVar = null;
+    }
+
+    // Close any active button
+    if (button != null && !button.isDisposed()) {
+      button.dispose();
+      button = null;
+    }
+
+    // Clean up the table editor's active control
+    if (editor != null) {
+      Control oldEditor = editor.getEditor();
+      if (oldEditor != null && !oldEditor.isDisposed()) {
+        try {
+          oldEditor.dispose();
+        } catch (SWTException swte) {
+          // Eat "Widget Is Disposed Exception"
+        }
+      }
+    }
+  }
+
   // Filtering...
 
   @GuiToolbarElement(

Reply via email to