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

hansva pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hop.git


The following commit(s) were added to refs/heads/master by this push:
     new 3e2a3d4782 HOP-4164 Add description tip when mouse over icon
     new 0d6ba43770 Merge pull request #1659 from nadment/HOP-4158
3e2a3d4782 is described below

commit 3e2a3d47827b49ee25ce5fa67465f1e3c373c2c5
Author: Nicolas Adment <[email protected]>
AuthorDate: Wed Aug 24 22:18:47 2022 +0200

    HOP-4164 Add description tip when mouse over icon
---
 .../java/org/apache/hop/core/gui/AreaOwner.java    |  2 ++
 .../org/apache/hop/pipeline/PipelinePainter.java   | 23 ++++++++++++++--
 .../org/apache/hop/workflow/WorkflowPainter.java   | 27 +++++++++++++++---
 .../hopgui/file/pipeline/HopGuiPipelineGraph.java  | 19 +++++++++++--
 .../hopgui/file/workflow/HopGuiWorkflowGraph.java  | 32 ++++++++++++++++------
 5 files changed, 86 insertions(+), 17 deletions(-)

diff --git a/engine/src/main/java/org/apache/hop/core/gui/AreaOwner.java 
b/engine/src/main/java/org/apache/hop/core/gui/AreaOwner.java
index afd354ed15..6c9f73c397 100644
--- a/engine/src/main/java/org/apache/hop/core/gui/AreaOwner.java
+++ b/engine/src/main/java/org/apache/hop/core/gui/AreaOwner.java
@@ -32,6 +32,7 @@ public class AreaOwner<Parent, Owner> {
     TRANSFORM_PARTITIONING,
     TRANSFORM_ICON,
     TRANSFORM_NAME,
+    TRANSFORM_INFO_ICON,
     TRANSFORM_FAILURE_ICON,
     TRANSFORM_INPUT_HOP_ICON,
     TRANSFORM_OUTPUT_HOP_ICON,
@@ -53,6 +54,7 @@ public class AreaOwner<Parent, Owner> {
 
     ACTION_ICON,
     ACTION_NAME,
+    ACTION_INFO_ICON,
     WORKFLOW_HOP_ICON,
     WORKFLOW_HOP_PARALLEL_ICON,
 
diff --git a/engine/src/main/java/org/apache/hop/pipeline/PipelinePainter.java 
b/engine/src/main/java/org/apache/hop/pipeline/PipelinePainter.java
index 53b50872b4..090bcc8c33 100644
--- a/engine/src/main/java/org/apache/hop/pipeline/PipelinePainter.java
+++ b/engine/src/main/java/org/apache/hop/pipeline/PipelinePainter.java
@@ -24,6 +24,7 @@ import org.apache.hop.core.extension.ExtensionPointHandler;
 import org.apache.hop.core.extension.HopExtensionPoint;
 import org.apache.hop.core.gui.*;
 import org.apache.hop.core.gui.AreaOwner.AreaType;
+import org.apache.hop.core.gui.IGc.EImage;
 import org.apache.hop.core.logging.LogChannel;
 import org.apache.hop.core.row.RowBuffer;
 import org.apache.hop.core.svg.SvgFile;
@@ -783,6 +784,24 @@ public class PipelinePainter extends 
BasePainter<PipelineHopMeta, TransformMeta>
     }
     gc.drawRoundRectangle(x - 1, y - 1, iconSize + 1, iconSize + 1, 8, 8);
 
+    // Show an information icon in the upper left corner of the transform...
+    //
+    if ( !Utils.isEmpty(transformMeta.getDescription()) ) {
+      int xInfo = x - (miniIconSize / 2) - 1;
+      int yInfo = y - (miniIconSize / 2) - 1;
+      gc.drawImage(EImage.INFO_DISABLED, xInfo, yInfo, magnification);
+      areaOwners.add(
+          new AreaOwner(
+              AreaType.TRANSFORM_INFO_ICON,
+              xInfo,
+              yInfo,
+              miniIconSize,
+              miniIconSize,
+              offset,
+              pipelineMeta,
+              transformMeta));
+    }
+    
     Point namePosition = getNamePosition(name, screen, iconSize);
 
     // Help out the user working in single-click mode by allowing the name to 
be clicked to edit
@@ -834,12 +853,12 @@ public class PipelinePainter extends 
BasePainter<PipelineHopMeta, TransformMeta>
       String copies = "x" + transformMeta.getCopiesString();
       Point textExtent = gc.textExtent(copies);
 
-      gc.drawText(copies, x - textExtent.x + 1, y - textExtent.y + 1, false);
+      gc.drawText(copies, x - textExtent.x + 1, y - textExtent.y - 4, false);
       areaOwners.add(
           new AreaOwner(
               AreaType.TRANSFORM_COPIES_TEXT,
               x - textExtent.x + 1,
-              y - textExtent.y + 1,
+              y - textExtent.y - 4,
               textExtent.x,
               textExtent.y,
               offset,
diff --git a/engine/src/main/java/org/apache/hop/workflow/WorkflowPainter.java 
b/engine/src/main/java/org/apache/hop/workflow/WorkflowPainter.java
index 4eac4bea2c..081de7ee76 100644
--- a/engine/src/main/java/org/apache/hop/workflow/WorkflowPainter.java
+++ b/engine/src/main/java/org/apache/hop/workflow/WorkflowPainter.java
@@ -29,6 +29,7 @@ import org.apache.hop.core.gui.IGc.EFont;
 import org.apache.hop.core.gui.IGc.EImage;
 import org.apache.hop.core.gui.IGc.ELineStyle;
 import org.apache.hop.core.logging.LogChannel;
+import org.apache.hop.core.util.Utils;
 import org.apache.hop.core.variables.IVariables;
 import org.apache.hop.workflow.action.ActionMeta;
 
@@ -308,8 +309,8 @@ public class WorkflowPainter extends 
BasePainter<WorkflowHopMeta, ActionMeta> {
 
     if (activeActions != null && activeActions.contains(actionMeta)) {
       gc.setForeground(EColor.BLUE);
-      int iconX = (x + iconSize) - (miniIconSize / 2);
-      int iconY = y - (miniIconSize / 2);
+      int iconX = (x + iconSize) - (miniIconSize / 2) + 1;
+      int iconY = y - (miniIconSize / 2) - 1;
       gc.drawImage(EImage.BUSY, iconX, iconY, magnification);
       areaOwners.add(
           new AreaOwner(
@@ -324,12 +325,30 @@ public class WorkflowPainter extends 
BasePainter<WorkflowHopMeta, ActionMeta> {
     } else {
       gc.setForeground(EColor.BLACK);
     }
+    
+    // Show an information icon in the upper left corner of the action...
+    //
+    if ( !Utils.isEmpty(actionMeta.getDescription()) ) {
+      int xInfo = x - (miniIconSize / 2) - 1;
+      int yInfo = y - (miniIconSize / 2) - 1;
+      gc.drawImage(EImage.INFO_DISABLED, xInfo, yInfo, magnification);
+      areaOwners.add(
+          new AreaOwner(
+              AreaType.ACTION_INFO_ICON,
+              xInfo,
+              yInfo,
+              miniIconSize,
+              miniIconSize,
+              offset,
+              workflowMeta,
+              actionMeta));
+    }
 
     ActionResult actionResult = findActionResult(actionMeta);
     if (actionResult != null) {
       Result result = actionResult.getResult();
-      int iconX = (x + iconSize) - (miniIconSize / 2);
-      int iconY = y - (miniIconSize / 2);
+      int iconX = (x + iconSize) - (miniIconSize / 2) + 1;
+      int iconY = y - (miniIconSize / 2) - 1;
 
       // Draw an execution result on the top right corner...
       //
diff --git 
a/ui/src/main/java/org/apache/hop/ui/hopgui/file/pipeline/HopGuiPipelineGraph.java
 
b/ui/src/main/java/org/apache/hop/ui/hopgui/file/pipeline/HopGuiPipelineGraph.java
index 461ea4ea54..d60fd9bf54 100644
--- 
a/ui/src/main/java/org/apache/hop/ui/hopgui/file/pipeline/HopGuiPipelineGraph.java
+++ 
b/ui/src/main/java/org/apache/hop/ui/hopgui/file/pipeline/HopGuiPipelineGraph.java
@@ -231,6 +231,9 @@ public class HopGuiPipelineGraph extends HopGuiAbstractGraph
 
   private int lastButton;
 
+  // Keep track if a contextual dialog box is open, do not display the tooltip
+  private boolean openedContextDialog = false;
+  
   private PipelineHopMeta lastHopSplit;
 
   private org.apache.hop.core.gui.Rectangle selectionRegion;
@@ -1255,11 +1258,16 @@ public class HopGuiPipelineGraph extends 
HopGuiAbstractGraph
           Shell parent = hopShell();
           org.eclipse.swt.graphics.Point p = parent.getDisplay().map(canvas, 
null, e.x, e.y);
 
+          this.openedContextDialog = true;
+          this.hideToolTips();
+          
           // Show the context dialog
           //
           avoidContextDialog =
               GuiContextUtil.getInstance()
                   .handleActionSelection(parent, message, new Point(p.x, p.y), 
contextHandler);
+          
+          this.openedContextDialog = false;
         }
       }
     }
@@ -2761,7 +2769,7 @@ public class HopGuiPipelineGraph extends 
HopGuiAbstractGraph
   private AreaOwner setToolTip(int x, int y, int screenX, int screenY) {
     AreaOwner subject = null;
 
-    if (!hopGui.getProps().showToolTips()) {
+    if (!hopGui.getProps().showToolTips() || openedContextDialog ) {
       return subject;
     }
 
@@ -2927,9 +2935,13 @@ public class HopGuiPipelineGraph extends 
HopGuiAbstractGraph
           tip.append(BaseMessages.getString(PKG, 
"PipelineGraph.ShowMenu.Tooltip"));
           tipImage = GuiResource.getInstance().getImageContextMenu();
           break;
+          
+        case TRANSFORM_INFO_ICON:  
         case TRANSFORM_ICON:
           TransformMeta iconTransformMeta = (TransformMeta) 
areaOwner.getOwner();
-          if (iconTransformMeta.isDeprecated()) { // only need tooltip if 
transform is deprecated
+          
+          // If transform is deprecated, display first   
+          if (iconTransformMeta.isDeprecated()) { 
             tip.append(
                     BaseMessages.getString(PKG, 
"PipelineGraph.DeprecatedTransform.Tooltip.Title"))
                 .append(Const.CR);
@@ -2957,6 +2969,9 @@ public class HopGuiPipelineGraph extends 
HopGuiAbstractGraph
             }
             tipImage = GuiResource.getInstance().getImageDeprecated();
           }
+          else if ( !Utils.isEmpty(iconTransformMeta.getDescription()) ) {
+            tip.append(iconTransformMeta.getDescription());
+          }
           break;
         case TRANSFORM_OUTPUT_DATA:
           RowBuffer rowBuffer = (RowBuffer) areaOwner.getOwner();
diff --git 
a/ui/src/main/java/org/apache/hop/ui/hopgui/file/workflow/HopGuiWorkflowGraph.java
 
b/ui/src/main/java/org/apache/hop/ui/hopgui/file/workflow/HopGuiWorkflowGraph.java
index 50addb5683..4a4137e9a0 100644
--- 
a/ui/src/main/java/org/apache/hop/ui/hopgui/file/workflow/HopGuiWorkflowGraph.java
+++ 
b/ui/src/main/java/org/apache/hop/ui/hopgui/file/workflow/HopGuiWorkflowGraph.java
@@ -207,6 +207,9 @@ public class HopGuiWorkflowGraph extends HopGuiAbstractGraph
 
   protected boolean splitHop;
 
+  // Keep track if a contextual dialog box is open, do not display the tooltip
+  private boolean openedContextDialog = false;
+  
   protected int lastButton;
 
   protected WorkflowHopMeta lastHopSplit;
@@ -470,7 +473,7 @@ public class HopGuiWorkflowGraph extends HopGuiAbstractGraph
         return;
       }
     } catch (Exception ex) {
-      LogChannel.GENERAL.logError("Error calling JobGraphMouseDoubleClick 
extension point", ex);
+      LogChannel.GENERAL.logError("Error calling WorkflowGraphMouseDoubleClick 
extension point", ex);
     }
 
     ActionMeta action = workflowMeta.getAction(real.x, real.y, iconSize);
@@ -538,7 +541,7 @@ public class HopGuiWorkflowGraph extends HopGuiAbstractGraph
         return;
       }
     } catch (Exception ex) {
-      LogChannel.GENERAL.logError("Error calling JobGraphMouseDown extension 
point", ex);
+      LogChannel.GENERAL.logError("Error calling WorkflowGraphMouseDown 
extension point", ex);
     }
 
     // A single left or middle click on one of the area owners...
@@ -1025,11 +1028,16 @@ public class HopGuiWorkflowGraph extends 
HopGuiAbstractGraph
           Shell parent = hopShell();
           org.eclipse.swt.graphics.Point p = parent.getDisplay().map(canvas, 
null, e.x, e.y);
 
+          this.openedContextDialog = true;
+          this.hideToolTips();
+          
           // Show the context dialog
           //
           ignoreNextClick =
               GuiContextUtil.getInstance()
                   .handleActionSelection(parent, message, new Point(p.x, p.y), 
contextHandler);
+          
+          this.openedContextDialog = false;
         }
       }
     }
@@ -2392,7 +2400,7 @@ public class HopGuiWorkflowGraph extends 
HopGuiAbstractGraph
   }
 
   protected void setToolTip(int x, int y, int screenX, int screenY) {
-    if (!hopGui.getProps().showToolTips()) {
+    if (!hopGui.getProps().showToolTips() || openedContextDialog ) {
       return;
     }
 
@@ -2525,14 +2533,17 @@ public class HopGuiWorkflowGraph extends 
HopGuiAbstractGraph
                   + "that was reached last time the pipeline was executed.");
           tipImage = GuiResource.getInstance().getImageCheckpoint();
           break;
+        case ACTION_INFO_ICON:
         case ACTION_ICON:
-          ActionMeta jec = (ActionMeta) areaOwner.getOwner();
-          if (jec.isDeprecated()) { // only need tooltip if action is 
deprecated
+          ActionMeta actionMetaInfo = (ActionMeta) areaOwner.getOwner();
+          
+          // If transform is deprecated, display first  
+          if (actionMetaInfo.isDeprecated()) { // only need tooltip if action 
is deprecated
             tip.append(BaseMessages.getString(PKG, 
"WorkflowGraph.DeprecatedEntry.Tooltip.Title"))
                 .append(Const.CR);
             String tipNext =
                 BaseMessages.getString(
-                    PKG, "WorkflowGraph.DeprecatedEntry.Tooltip.Message1", 
jec.getName());
+                    PKG, "WorkflowGraph.DeprecatedEntry.Tooltip.Message1", 
actionMetaInfo.getName());
             int length = tipNext.length() + 5;
             for (int i = 0; i < length; i++) {
               tip.append("-");
@@ -2540,15 +2551,18 @@ public class HopGuiWorkflowGraph extends 
HopGuiAbstractGraph
             tip.append(Const.CR).append(tipNext).append(Const.CR);
             tip.append(
                 BaseMessages.getString(PKG, 
"WorkflowGraph.DeprecatedEntry.Tooltip.Message2"));
-            if (!Utils.isEmpty(jec.getSuggestion())
-                && !(jec.getSuggestion().startsWith("!") && 
jec.getSuggestion().endsWith("!"))) {
+            if (!Utils.isEmpty(actionMetaInfo.getSuggestion())
+                && !(actionMetaInfo.getSuggestion().startsWith("!") && 
actionMetaInfo.getSuggestion().endsWith("!"))) {
               tip.append(" ");
               tip.append(
                   BaseMessages.getString(
-                      PKG, "WorkflowGraph.DeprecatedEntry.Tooltip.Message3", 
jec.getSuggestion()));
+                      PKG, "WorkflowGraph.DeprecatedEntry.Tooltip.Message3", 
actionMetaInfo.getSuggestion()));
             }
             tipImage = GuiResource.getInstance().getImageDeprecated();
           }
+          else if ( !Utils.isEmpty(actionMetaInfo.getDescription()) ) {
+            tip.append(actionMetaInfo.getDescription());
+          }      
           break;
         default:
           // For plugins...

Reply via email to