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 ba897b5bb5 Avoid spamming files reverted when doing git revert, fixes 
#6373 (#6374)
ba897b5bb5 is described below

commit ba897b5bb54883d3e71b8d2081461f521ce5a9f7
Author: Hans Van Akelyen <[email protected]>
AuthorDate: Wed Jan 14 12:20:02 2026 +0100

    Avoid spamming files reverted when doing git revert, fixes #6373 (#6374)
    
    Cleanup error when files do not exist
---
 .../main/java/org/apache/hop/git/GitGuiPlugin.java | 14 ++--
 .../apache/hop/projects/project/ProjectDialog.java |  1 -
 .../org/apache/hop/ui/core/dialog/MessageBox.java  | 86 +++++++++++++---------
 .../ui/hopgui/delegates/HopGuiAuditDelegate.java   | 32 +++++++-
 .../delegates/messages/messages_en_US.properties   |  3 +
 5 files changed, 92 insertions(+), 44 deletions(-)

diff --git 
a/plugins/misc/git/src/main/java/org/apache/hop/git/GitGuiPlugin.java 
b/plugins/misc/git/src/main/java/org/apache/hop/git/GitGuiPlugin.java
index de9f6e77c7..3f538405f8 100644
--- a/plugins/misc/git/src/main/java/org/apache/hop/git/GitGuiPlugin.java
+++ b/plugins/misc/git/src/main/java/org/apache/hop/git/GitGuiPlugin.java
@@ -470,14 +470,14 @@ public class GitGuiPlugin
           for (int selectedNr : selectedNrs) {
             String file = files[selectedNr];
             git.revertPath(file);
-
-            MessageBox box =
-                new MessageBox(HopGui.getInstance().getShell(), SWT.OK | 
SWT.ICON_INFORMATION);
-            box.setText(BaseMessages.getString(PKG, 
"GitGuiPlugin.Dialog.FilesReverted.Header"));
-            box.setMessage(
-                BaseMessages.getString(PKG, 
"GitGuiPlugin.Dialog.FilesReverted.Message"));
-            box.open();
           }
+
+          // Show confirmation message once after all files have been reverted
+          MessageBox box =
+              new MessageBox(HopGui.getInstance().getShell(), SWT.OK | 
SWT.ICON_INFORMATION);
+          box.setText(BaseMessages.getString(PKG, 
"GitGuiPlugin.Dialog.FilesReverted.Header"));
+          box.setMessage(BaseMessages.getString(PKG, 
"GitGuiPlugin.Dialog.FilesReverted.Message"));
+          box.open();
         }
       }
     } catch (Exception e) {
diff --git 
a/plugins/misc/projects/src/main/java/org/apache/hop/projects/project/ProjectDialog.java
 
b/plugins/misc/projects/src/main/java/org/apache/hop/projects/project/ProjectDialog.java
index 959062f3ac..1a7b923c9c 100644
--- 
a/plugins/misc/projects/src/main/java/org/apache/hop/projects/project/ProjectDialog.java
+++ 
b/plugins/misc/projects/src/main/java/org/apache/hop/projects/project/ProjectDialog.java
@@ -163,7 +163,6 @@ public class ProjectDialog extends Dialog {
     scroll.setLayout(new FillLayout());
     scroll.setExpandHorizontal(true);
     scroll.setExpandVertical(true);
-    scroll.setBackground(shell.getDisplay().getSystemColor(SWT.COLOR_BLACK));
     PropsUi.setLook(scroll);
     shell.setLayoutData(scroll);
 
diff --git a/ui/src/main/java/org/apache/hop/ui/core/dialog/MessageBox.java 
b/ui/src/main/java/org/apache/hop/ui/core/dialog/MessageBox.java
index 528bc915cb..bb8c70d9d9 100644
--- a/ui/src/main/java/org/apache/hop/ui/core/dialog/MessageBox.java
+++ b/ui/src/main/java/org/apache/hop/ui/core/dialog/MessageBox.java
@@ -19,6 +19,8 @@ package org.apache.hop.ui.core.dialog;
 
 import java.util.ArrayList;
 import java.util.List;
+import lombok.Getter;
+import lombok.Setter;
 import org.apache.hop.core.Const;
 import org.apache.hop.i18n.BaseMessages;
 import org.apache.hop.ui.core.FormDataBuilder;
@@ -28,6 +30,8 @@ import org.apache.hop.ui.core.gui.WindowProperty;
 import org.apache.hop.ui.pipeline.transform.BaseTransformDialog;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.FormAttachment;
+import org.eclipse.swt.layout.FormData;
 import org.eclipse.swt.layout.FormLayout;
 import org.eclipse.swt.layout.GridData;
 import org.eclipse.swt.layout.GridLayout;
@@ -40,6 +44,8 @@ import org.eclipse.swt.widgets.Shell;
 /**
  * A replacement of the system message box dialog to make sure the correct 
font and colors are used.
  */
+@Getter
+@Setter
 public class MessageBox extends Dialog {
   private static final Class<?> PKG = MessageBox.class;
 
@@ -53,6 +59,9 @@ public class MessageBox extends Dialog {
 
   private Shell shell;
 
+  private int minimumWidth = -1;
+  private int minimumHeight = -1;
+
   public MessageBox(Shell parent) {
     this(parent, SWT.ICON_INFORMATION | SWT.APPLICATION_MODAL);
   }
@@ -89,7 +98,6 @@ public class MessageBox extends Dialog {
     gridLayout.numColumns = 2;
     gridLayout.horizontalSpacing = 15;
     composite.setLayout(gridLayout);
-    composite.setLayoutData(new FormDataBuilder().top().fullWidth().result());
 
     // The message...
     //
@@ -114,6 +122,7 @@ public class MessageBox extends Dialog {
       Button wYes = new Button(shell, SWT.PUSH);
       wYes.setText(BaseMessages.getString(PKG, "System.Button.Yes"));
       wYes.addListener(SWT.Selection, e -> yes());
+      shell.setDefaultButton(wYes);
       buttons.add(wYes);
     }
     if ((style & SWT.NO) != 0) {
@@ -132,17 +141,53 @@ public class MessageBox extends Dialog {
       Button wOk = new Button(shell, SWT.PUSH);
       wOk.setText(BaseMessages.getString(PKG, "System.Button.OK"));
       wOk.addListener(SWT.Selection, e -> ok());
+      shell.setDefaultButton(wOk);
       buttons.add(0, wOk);
     }
 
+    // Set the composite to fill from top to bottom with margin
+    composite.setLayoutData(
+        new FormDataBuilder().top().left().right(100, 0).bottom(100, 
-50).result());
+
     BaseTransformDialog.positionBottomButtons(
         shell, buttons.toArray(new Button[0]), margin, composite);
 
+    // Reposition buttons to be attached to the bottom of the shell instead of 
the composite
+    // This ensures they stay at the bottom when the shell is resized
+    if (!buttons.isEmpty()) {
+      for (Button button : buttons) {
+        FormData fd = (FormData) button.getLayoutData();
+        // Keep horizontal positioning but attach to bottom of shell
+        fd.top = null;
+        fd.bottom = new FormAttachment(100, -margin);
+      }
+      // Update composite to fill space above buttons
+      composite.setLayoutData(
+          new FormDataBuilder()
+              .top()
+              .left()
+              .right(100, 0)
+              .bottom(buttons.get(0), -margin)
+              .result());
+    }
+
     shell.addListener(SWT.Close, e -> cancel());
 
     BaseTransformDialog.setSize(shell);
 
-    shell.pack();
+    // If minimum size is set, use it directly instead of packing
+    if (minimumWidth > 0 || minimumHeight > 0) {
+      shell.layout();
+      shell.pack();
+      int width = Math.max(shell.getSize().x, minimumWidth > 0 ? minimumWidth 
: 0);
+      int height = Math.max(shell.getSize().y, minimumHeight > 0 ? 
minimumHeight : 0);
+      shell.setSize(width, height);
+      shell.setMinimumSize(
+          minimumWidth > 0 ? minimumWidth : 0, minimumHeight > 0 ? 
minimumHeight : 0);
+    } else {
+      shell.pack();
+    }
+
     shell.open();
     while (!shell.isDisposed()) {
       if (!shell.getDisplay().readAndDispatch()) {
@@ -228,38 +273,13 @@ public class MessageBox extends Dialog {
   }
 
   /**
-   * Gets message
-   *
-   * @return value of message
-   */
-  public String getMessage() {
-    return message;
-  }
-
-  /**
-   * Sets message
-   *
-   * @param message value of message
-   */
-  public void setMessage(String message) {
-    this.message = message;
-  }
-
-  /**
-   * Gets returnValue
-   *
-   * @return value of returnValue
-   */
-  public int getReturnValue() {
-    return returnValue;
-  }
-
-  /**
-   * Sets returnValue
+   * Sets the minimum size for the dialog
    *
-   * @param returnValue value of returnValue
+   * @param width minimum width in pixels
+   * @param height minimum height in pixels
    */
-  public void setReturnValue(int returnValue) {
-    this.returnValue = returnValue;
+  public void setMinimumSize(int width, int height) {
+    this.minimumWidth = width;
+    this.minimumHeight = height;
   }
 }
diff --git 
a/ui/src/main/java/org/apache/hop/ui/hopgui/delegates/HopGuiAuditDelegate.java 
b/ui/src/main/java/org/apache/hop/ui/hopgui/delegates/HopGuiAuditDelegate.java
index 9179ca8dc9..8d4f11e1f8 100644
--- 
a/ui/src/main/java/org/apache/hop/ui/hopgui/delegates/HopGuiAuditDelegate.java
+++ 
b/ui/src/main/java/org/apache/hop/ui/hopgui/delegates/HopGuiAuditDelegate.java
@@ -26,11 +26,12 @@ import org.apache.hop.history.AuditList;
 import org.apache.hop.history.AuditManager;
 import org.apache.hop.history.AuditState;
 import org.apache.hop.history.AuditStateMap;
+import org.apache.hop.i18n.BaseMessages;
 import org.apache.hop.metadata.api.HopMetadata;
 import org.apache.hop.metadata.api.IHopMetadata;
 import org.apache.hop.metadata.api.IHopMetadataProvider;
 import org.apache.hop.metadata.api.IHopMetadataSerializer;
-import org.apache.hop.ui.core.dialog.ErrorDialog;
+import org.apache.hop.ui.core.dialog.MessageBox;
 import org.apache.hop.ui.core.gui.HopNamespace;
 import org.apache.hop.ui.core.metadata.MetadataEditor;
 import org.apache.hop.ui.core.metadata.MetadataManager;
@@ -40,9 +41,12 @@ import org.apache.hop.ui.hopgui.perspective.IHopPerspective;
 import org.apache.hop.ui.hopgui.perspective.TabItemHandler;
 import org.apache.hop.ui.hopgui.perspective.metadata.MetadataPerspective;
 import org.apache.hop.ui.util.SwtErrorHandler;
+import org.eclipse.swt.SWT;
 
 public class HopGuiAuditDelegate {
 
+  private static final Class<?> PKG = HopGuiAuditDelegate.class;
+
   public static final String STATE_PROPERTY_ACTIVE = "active";
   public static final String METADATA_FILENAME_PREFIX = "METADATA:";
 
@@ -57,6 +61,9 @@ public class HopGuiAuditDelegate {
       return;
     }
 
+    // Collect files that fail to open
+    List<String> failedFiles = new ArrayList<>();
+
     // Open the last files for each perspective...
     //
     List<IHopPerspective> perspectives = 
hopGui.getPerspectiveManager().getPerspectives();
@@ -122,8 +129,9 @@ public class HopGuiAuditDelegate {
               }
             }
           } catch (Exception e) {
-            new ErrorDialog(
-                hopGui.getActiveShell(), "Error", "Error opening file '" + 
filename + "'", e);
+            // Collect failed files instead of showing error dialog immediately
+            hopGui.getLog().logError("Error opening file '" + filename + "'", 
e);
+            failedFiles.add(filename);
           }
         }
 
@@ -134,6 +142,24 @@ public class HopGuiAuditDelegate {
         }
       }
     }
+
+    // Show a single dialog with all files that failed to open
+    if (!failedFiles.isEmpty()) {
+      StringBuilder message =
+          new StringBuilder(
+              BaseMessages.getString(
+                  PKG, 
"HopGuiAuditDelegate.FilesNoLongerAvailable.Dialog.Message"));
+      for (String failedFile : failedFiles) {
+        message.append("  - ").append(failedFile).append("\n");
+      }
+
+      MessageBox box = new MessageBox(hopGui.getActiveShell(), SWT.OK | 
SWT.ICON_WARNING);
+      box.setText(
+          BaseMessages.getString(PKG, 
"HopGuiAuditDelegate.FilesNoLongerAvailable.Dialog.Header"));
+      box.setMessage(message.toString());
+      box.setMinimumSize(400, -1);
+      box.open();
+    }
   }
 
   private void openMetadataObject(String className, String name) throws 
HopException {
diff --git 
a/ui/src/main/resources/org/apache/hop/ui/hopgui/delegates/messages/messages_en_US.properties
 
b/ui/src/main/resources/org/apache/hop/ui/hopgui/delegates/messages/messages_en_US.properties
index ff991fd17c..db07a96631 100644
--- 
a/ui/src/main/resources/org/apache/hop/ui/hopgui/delegates/messages/messages_en_US.properties
+++ 
b/ui/src/main/resources/org/apache/hop/ui/hopgui/delegates/messages/messages_en_US.properties
@@ -19,3 +19,6 @@
 HopGuiContextDelegate.SelectElementTypeDelete.Dialog.Header=Select the element 
type to delete...
 HopGuiContextDelegate.SelectElementTypeEdit.Dialog.Header=Select the element 
type to edit...
 HopGuiContextDelegate.SelectItemCreate.Dialog.Header=Select the item to create
+
+HopGuiAuditDelegate.FilesNoLongerAvailable.Dialog.Header=Some Files Couldn’t 
Be Reopened
+HopGuiAuditDelegate.FilesNoLongerAvailable.Dialog.Message=We couldn’t reopen 
the following files because they’re no longer available (they may have been 
moved, renamed, or deleted):\n\n

Reply via email to