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 95ba975921 Fix NPE on empty clipboard paste and clarify File Explorer 
copy/paste (#9214)
95ba975921 is described below

commit 95ba975921db04a5253a24400610eb5f3ef86a68
Author: Lance <[email protected]>
AuthorDate: Mon Nov 2 23:37:08 2026 +0800

    Fix NPE on empty clipboard paste and clarify File Explorer copy/paste 
(#9214)
    
    Signed-off-by: leehaut <[email protected]>
---
 .../delegates/HopGuiPipelineClipboardDelegate.java | 10 +++++++++
 .../delegates/HopGuiWorkflowClipboardDelegate.java |  8 +++++++
 .../perspective/explorer/ExplorerPerspective.java  | 25 ++++++++++++++++++++++
 .../explorer/messages/messages_en_US.properties    |  2 ++
 .../explorer/messages/messages_zh_CN.properties    |  2 ++
 5 files changed, 47 insertions(+)

diff --git 
a/ui/src/main/java/org/apache/hop/ui/hopgui/file/pipeline/delegates/HopGuiPipelineClipboardDelegate.java
 
b/ui/src/main/java/org/apache/hop/ui/hopgui/file/pipeline/delegates/HopGuiPipelineClipboardDelegate.java
index ea9e97f205..d1a647c69c 100644
--- 
a/ui/src/main/java/org/apache/hop/ui/hopgui/file/pipeline/delegates/HopGuiPipelineClipboardDelegate.java
+++ 
b/ui/src/main/java/org/apache/hop/ui/hopgui/file/pipeline/delegates/HopGuiPipelineClipboardDelegate.java
@@ -29,6 +29,7 @@ import org.apache.hop.core.exception.HopPluginLoaderException;
 import org.apache.hop.core.exception.HopXmlException;
 import org.apache.hop.core.gui.Point;
 import org.apache.hop.core.logging.ILogChannel;
+import org.apache.hop.core.util.Utils;
 import org.apache.hop.core.xml.XmlHandler;
 import org.apache.hop.i18n.BaseMessages;
 import org.apache.hop.pipeline.PipelineHopMeta;
@@ -92,6 +93,11 @@ public class HopGuiPipelineClipboardDelegate {
   }
 
   public void pasteXml(PipelineMeta pipelineMeta, String clipboardContent, 
Point location) {
+    // Empty clipboard (e.g. OS file copy with no text) — nothing to paste, 
stay quiet.
+    if (Utils.isEmpty(clipboardContent)) {
+      return;
+    }
+
     try {
       Document doc = XmlHandler.loadXmlString(clipboardContent);
       Node pipelineNode = XmlHandler.getSubNode(doc, 
XML_TAG_PIPELINE_TRANSFORMS);
@@ -249,6 +255,10 @@ public class HopGuiPipelineClipboardDelegate {
   private void pasteNoXmlContent(
       PipelineMeta pipelineMeta, String clipboardContent, Point location) {
     try {
+      if (Utils.isEmpty(clipboardContent)) {
+        return;
+      }
+
       // Add a notepad
       //
       NotePadMeta notePadMeta =
diff --git 
a/ui/src/main/java/org/apache/hop/ui/hopgui/file/workflow/delegates/HopGuiWorkflowClipboardDelegate.java
 
b/ui/src/main/java/org/apache/hop/ui/hopgui/file/workflow/delegates/HopGuiWorkflowClipboardDelegate.java
index 3298882611..a632bb8ec6 100644
--- 
a/ui/src/main/java/org/apache/hop/ui/hopgui/file/workflow/delegates/HopGuiWorkflowClipboardDelegate.java
+++ 
b/ui/src/main/java/org/apache/hop/ui/hopgui/file/workflow/delegates/HopGuiWorkflowClipboardDelegate.java
@@ -90,6 +90,10 @@ public class HopGuiWorkflowClipboardDelegate {
   }
 
   public void pasteXml(WorkflowMeta workflowMeta, String clipboardContent, 
Point location) {
+    // Empty clipboard (e.g. OS file copy with no text) — nothing to paste, 
stay quiet.
+    if (Utils.isEmpty(clipboardContent)) {
+      return;
+    }
 
     try {
       Document doc = XmlHandler.loadXmlString(clipboardContent);
@@ -200,6 +204,10 @@ public class HopGuiWorkflowClipboardDelegate {
   private void pasteNoXmlContent(
       WorkflowMeta workflowMeta, String clipboardContent, Point location) {
     try {
+      if (Utils.isEmpty(clipboardContent)) {
+        return;
+      }
+
       // Are we pasting filenames?
       //
       if (clipboardContent.startsWith("file:///") || 
clipboardContent.startsWith("/")) {
diff --git 
a/ui/src/main/java/org/apache/hop/ui/hopgui/perspective/explorer/ExplorerPerspective.java
 
b/ui/src/main/java/org/apache/hop/ui/hopgui/perspective/explorer/ExplorerPerspective.java
index 834b3d5735..20f438b9c3 100644
--- 
a/ui/src/main/java/org/apache/hop/ui/hopgui/perspective/explorer/ExplorerPerspective.java
+++ 
b/ui/src/main/java/org/apache/hop/ui/hopgui/perspective/explorer/ExplorerPerspective.java
@@ -3939,6 +3939,31 @@ public class ExplorerPerspective implements 
IHopPerspective, TabClosable, IFileD
     copyToClipboard(tif -> tif.path);
   }
 
+  /**
+   * Ctrl/Cmd+C and Ctrl/Cmd+V do not copy files in the project tree. Tell the 
user to drag and drop
+   * instead of falling through to the active workflow/pipeline paste handler.
+   */
+  @GuiKeyboardShortcut(control = true, key = 'c')
+  @GuiOsxKeyboardShortcut(command = true, key = 'c')
+  public void copyFilesUnsupported() {
+    showFileClipboardUnsupported();
+  }
+
+  @GuiKeyboardShortcut(control = true, key = 'v')
+  @GuiOsxKeyboardShortcut(command = true, key = 'v')
+  public void pasteFilesUnsupported() {
+    showFileClipboardUnsupported();
+  }
+
+  private void showFileClipboardUnsupported() {
+    MessageBox messageBox = new MessageBox(hopGui.getActiveShell(), SWT.OK | 
SWT.ICON_INFORMATION);
+    messageBox.setText(
+        BaseMessages.getString(PKG, 
"ExplorerPerspective.Dialog.FileClipboardUnsupported.Title"));
+    messageBox.setMessage(
+        BaseMessages.getString(PKG, 
"ExplorerPerspective.Dialog.FileClipboardUnsupported.Message"));
+    messageBox.open();
+  }
+
   /** Copy one line per selected file to the clipboard. */
   private void copyToClipboard(Function<TreeItemFolder, String> valueGetter) {
     TreeItem[] selection = tree.getSelection();
diff --git 
a/ui/src/main/resources/org/apache/hop/ui/hopgui/perspective/explorer/messages/messages_en_US.properties
 
b/ui/src/main/resources/org/apache/hop/ui/hopgui/perspective/explorer/messages/messages_en_US.properties
index c6293128ab..9f14c65d20 100644
--- 
a/ui/src/main/resources/org/apache/hop/ui/hopgui/perspective/explorer/messages/messages_en_US.properties
+++ 
b/ui/src/main/resources/org/apache/hop/ui/hopgui/perspective/explorer/messages/messages_en_US.properties
@@ -50,6 +50,8 @@ ExplorerPerspective.Error.OpenFileInExplorer.Message=Error 
opening file in explo
 ExplorerPerspective.GuiPlugin.Description=A file explorer for your current 
project
 ExplorerPerspective.Menu.CopyName=Copy name
 ExplorerPerspective.Menu.CopyPath=Copy path
+ExplorerPerspective.Dialog.FileClipboardUnsupported.Title=Copy / Paste
+ExplorerPerspective.Dialog.FileClipboardUnsupported.Message=Copying files with 
Ctrl+C / Ctrl+V is not supported in the File Explorer.\n\nDrag and drop files 
onto a folder to copy or move them.
 ExplorerPerspective.Menu.CreateFolder=Create folder
 ExplorerPerspective.Menu.Delete=Delete
 ExplorerPerspective.Menu.FindReferences=Find references
diff --git 
a/ui/src/main/resources/org/apache/hop/ui/hopgui/perspective/explorer/messages/messages_zh_CN.properties
 
b/ui/src/main/resources/org/apache/hop/ui/hopgui/perspective/explorer/messages/messages_zh_CN.properties
index 0ebcb897c5..5a65828500 100644
--- 
a/ui/src/main/resources/org/apache/hop/ui/hopgui/perspective/explorer/messages/messages_zh_CN.properties
+++ 
b/ui/src/main/resources/org/apache/hop/ui/hopgui/perspective/explorer/messages/messages_zh_CN.properties
@@ -34,6 +34,8 @@ ExplorerPerspective.Error.RootFolder.Header=\u9519\u8BEF
 
ExplorerPerspective.Error.RootFolder.Message=\u83B7\u53D6\u6D4F\u89C8\u5668\u900F\u89C6\u56FE\u7684
 \u6839\u76EE\u5F55 \u6216 \u540D\u79F0 \u65F6\u51FA\u9519
 ExplorerPerspective.Error.TreeRefresh.Header=\u9519\u8BEF
 
ExplorerPerspective.Error.TreeRefresh.Message=\u5237\u65B0\u6587\u4EF6\u6D4F\u89C8\u5668\u4FE1\u606F\u65F6\u51FA\u9519
+ExplorerPerspective.Dialog.FileClipboardUnsupported.Title=\u590D\u5236 / 
\u7C98\u8D34
+ExplorerPerspective.Dialog.FileClipboardUnsupported.Message=\u6587\u4EF6\u6D4F\u89C8\u5668\u4E0D\u652F\u6301\u4F7F\u7528
 Ctrl+C / Ctrl+V 
\u590D\u5236\u6587\u4EF6\u3002\n\n\u8BF7\u5C06\u6587\u4EF6\u62D6\u62FD\u5230\u76EE\u6807\u6587\u4EF6\u5939\u4EE5\u590D\u5236\u6216\u79FB\u52A8\u3002
 
ExplorerPerspective.GuiPlugin.Description=\u5F53\u524D\u9879\u76EE\u7684\u6587\u4EF6\u6D4F\u89C8\u5668
 ExplorerPerspective.Name=\u6587\u4EF6\u6D4F\u89C8\u5668
 
ExplorerPerspective.ToolbarElement.CreateFolder.Tooltip=\u521B\u5EFA\u6587\u4EF6\u5939

Reply via email to