Skip to content

Commit

Permalink
Merge pull request #3336 from mattcasters/master
Browse files Browse the repository at this point in the history
issue #3335 : Underline the name of a transform or action to mimic a hyperlink
  • Loading branch information
hansva authored Nov 8, 2023
2 parents dac84ac + 08463c5 commit 815152c
Show file tree
Hide file tree
Showing 14 changed files with 268 additions and 117 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,17 @@ TIP: Hops will be shown in bold when a transform or action can be dropped on it

|Show help tooltips|Show help tooltips where available in Hop GUI|yes

|Use double click on canvas
a|double-click instead of single click on e.g. transform and action dialogs.
|Use double click on canvas?
|double-click instead of single click on e.g. transform and action dialogs.

enabled: double-click on a transform or action icon to open its properties. A single click on the icon opens the context dialog.
disabled (default): (single) click on a transform or action icon to open the context dialog. (single) click on a transform or action name to open its properties
|no

|Draw border around names on canvas?
|If this option is enabled, a border will be drawn around the names of transforms and actions on the canvas.
|no

|Use global bookmarks in the file dialog|Bookmarks in the file dialog are global (across projects) by default. Enable to make them project-specific|yes

|===
Expand Down
39 changes: 30 additions & 9 deletions engine/src/main/java/org/apache/hop/core/gui/BasePainter.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public abstract class BasePainter<Hop extends BaseHopMeta<?>, Part extends IBase
public static final int CORNER_RADIUS_3 = 6;
public static final int CORNER_RADIUS_2 = 4;

protected boolean drawingEditIcons;
protected boolean drawingBorderAroundName;

protected double zoomFactor;

Expand Down Expand Up @@ -79,6 +79,7 @@ public abstract class BasePainter<Hop extends BaseHopMeta<?>, Part extends IBase
protected float screenMagnification;
protected Rectangle graphPort;
protected Rectangle viewPort;
protected String mouseOverName;

public BasePainter(
IGc gc,
Expand All @@ -94,7 +95,8 @@ public BasePainter(
String noteFontName,
int noteFontHeight,
double zoomFactor,
boolean drawingEditIcons) {
boolean drawingBorderAroundName,
String mouseOverName) {
this.gc = gc;
this.variables = variables;
this.subject = subject;
Expand All @@ -113,14 +115,15 @@ public BasePainter(

this.magnification = 1.0f;
this.zoomFactor = zoomFactor;
this.drawingEditIcons = drawingEditIcons;
this.drawingBorderAroundName = drawingBorderAroundName;

gc.setAntialias(true);

this.noteFontName = noteFontName;
this.noteFontHeight = noteFontHeight;

this.screenMagnification = 1.0f;
this.mouseOverName = mouseOverName;
}

public static EImage getStreamIconImage(StreamIcon streamIcon, boolean enabled) {
Expand Down Expand Up @@ -536,17 +539,17 @@ public void setZoomFactor(double zoomFactor) {
/**
* Gets drawingEditIcons
*
* @return value of drawingEditIcons
* @return value of drawingBorderAroundName
*/
public boolean isDrawingEditIcons() {
return drawingEditIcons;
public boolean isDrawingBorderAroundName() {
return drawingBorderAroundName;
}

/**
* @param drawingEditIcons The drawingEditIcons to set
* @param drawingBorderAroundName The option to set
*/
public void setDrawingEditIcons(boolean drawingEditIcons) {
this.drawingEditIcons = drawingEditIcons;
public void setDrawingBorderAroundName(boolean drawingBorderAroundName) {
this.drawingBorderAroundName = drawingBorderAroundName;
}

/**
Expand Down Expand Up @@ -672,4 +675,22 @@ public Rectangle getViewPort() {
public void setViewPort(Rectangle viewPort) {
this.viewPort = viewPort;
}

/**
* Gets mouseOverName
*
* @return value of mouseOverName
*/
public String getMouseOverName() {
return mouseOverName;
}

/**
* Sets mouseOverName
*
* @param mouseOverName value of mouseOverName
*/
public void setMouseOverName(String mouseOverName) {
this.mouseOverName = mouseOverName;
}
}
51 changes: 31 additions & 20 deletions engine/src/main/java/org/apache/hop/pipeline/PipelinePainter.java
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@ public PipelinePainter(
boolean slowTransformIndicatorEnabled,
double zoomFactor,
Map<String, RowBuffer> outputRowsMap,
boolean drawingEditIcons,
boolean drawingBorderAroundName,
String mouseOverName,
Map<String, Object> stateMap) {
super(
gc,
Expand All @@ -115,7 +116,8 @@ public PipelinePainter(
noteFontName,
noteFontHeight,
zoomFactor,
drawingEditIcons);
drawingBorderAroundName,
mouseOverName);
this.pipelineMeta = pipelineMeta;

this.candidate = candidate;
Expand Down Expand Up @@ -146,6 +148,7 @@ public PipelinePainter(
int noteFontHeight,
double zoomFactor,
boolean drawingEditIcons,
String mouseOverName,
Map<String, Object> stateMap) {
this(
gc,
Expand All @@ -166,6 +169,7 @@ public PipelinePainter(
zoomFactor,
new HashMap<>(),
drawingEditIcons,
mouseOverName,
stateMap);
}

Expand Down Expand Up @@ -801,18 +805,13 @@ private void drawTransform(TransformMeta transformMeta) throws HopException {
}

Point namePosition = getNamePosition(name, screen, iconSize);
Point nameExtent = gc.textExtent(name);

// Help out the user working in single-click mode by allowing the name to be clicked to edit
//
if (isDrawingEditIcons()) {

Point nameExtent = gc.textExtent(name);

if (isDrawingBorderAroundName()) {
int tmpAlpha = gc.getAlpha();
gc.setAlpha(230);

gc.drawImage(EImage.EDIT, namePosition.x - 6, namePosition.y - 2, magnification);

gc.setBackground(EColor.LIGHTGRAY);
gc.fillRoundRectangle(
namePosition.x - 8,
Expand All @@ -822,24 +821,36 @@ private void drawTransform(TransformMeta transformMeta) throws HopException {
BasePainter.CORNER_RADIUS_5 + 15,
BasePainter.CORNER_RADIUS_5 + 15);
gc.setAlpha(tmpAlpha);

areaOwners.add(
new AreaOwner(
AreaType.TRANSFORM_NAME,
namePosition.x - 8,
namePosition.y - 2,
nameExtent.x + 15,
nameExtent.y + 8,
offset,
transformMeta,
name));
}

// Add the area owner for the transform name
//
areaOwners.add(
new AreaOwner(
AreaType.TRANSFORM_NAME,
namePosition.x - 8,
namePosition.y - 2,
nameExtent.x + 15,
nameExtent.y + 8,
offset,
transformMeta,
name));

gc.setForeground(EColor.BLACK);
gc.setFont(EFont.GRAPH);
gc.drawText(name, namePosition.x, namePosition.y + 2, true);
boolean partitioned = false;

// See if we need to draw a line under the name to make the name look like a hyperlink.
//
if (name.equals(mouseOverName)) {
gc.drawLine(
namePosition.x,
namePosition.y + nameExtent.y,
namePosition.x + nameExtent.x ,
namePosition.y + nameExtent.y);
}

TransformPartitioningMeta meta = transformMeta.getTransformPartitioningMeta();
if (transformMeta.isPartitioned() && meta != null) {
partitioned = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ public static final String generatePipelineSvg(
10,
zoomFactor,
false,
null,
new HashMap<>());
pipelinePainter.setMagnification(magnification);
pipelinePainter.drawPipelineImage();
Expand Down
76 changes: 43 additions & 33 deletions engine/src/main/java/org/apache/hop/workflow/WorkflowPainter.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@

package org.apache.hop.workflow;

import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import org.apache.hop.core.NotePadMeta;
import org.apache.hop.core.Result;
import org.apache.hop.core.exception.HopException;
Expand All @@ -38,10 +41,6 @@
import org.apache.hop.core.variables.IVariables;
import org.apache.hop.workflow.action.ActionMeta;

import java.util.Collections;
import java.util.Iterator;
import java.util.List;

public class WorkflowPainter extends BasePainter<WorkflowHopMeta, ActionMeta> {

private WorkflowMeta workflowMeta;
Expand All @@ -68,7 +67,8 @@ public WorkflowPainter(
String noteFontName,
int noteFontHeight,
double zoomFactor,
boolean drawingEditIcons) {
boolean drawingBorderAroundName,
String mouseOverName) {
super(
gc,
variables,
Expand All @@ -83,7 +83,8 @@ public WorkflowPainter(
noteFontName,
noteFontHeight,
zoomFactor,
drawingEditIcons);
drawingBorderAroundName,
mouseOverName);
this.workflowMeta = workflowMeta;

this.candidate = candidate;
Expand All @@ -99,7 +100,7 @@ public void drawWorkflow() throws HopException {
// Draw the pipeline onto the image
//
gc.setAlpha(255);
gc.setTransform((float)offset.x, (float)offset.y, magnification);
gc.setTransform((float) offset.x, (float) offset.y, magnification);
drawActions();

// Draw the navigation view in native pixels to make calculation a bit easier.
Expand Down Expand Up @@ -211,10 +212,10 @@ private void drawActions() throws HopException {
round(offset.x + n.x + iconSize + 5),
round(offset.y + n.y + iconSize + 5));
gc.drawLine(
round(offset.x + n.x - 5),
round(offset.y + n.y + iconSize + 5),
round(offset.x + n.x + iconSize + 5),
round(offset.y + n.y - 5));
round(offset.x + n.x - 5),
round(offset.y + n.y + iconSize + 5),
round(offset.x + n.x + iconSize + 5),
round(offset.y + n.y - 5));
}

try {
Expand Down Expand Up @@ -274,15 +275,10 @@ protected void drawAction(ActionMeta actionMeta) throws HopException {

// Help out the user working in single-click mode by allowing the name to be clicked to edit
//
if (isDrawingEditIcons()) {

Point nameExtent = gc.textExtent(name);

Point nameExtent = gc.textExtent(name);
if (isDrawingBorderAroundName()) {
int tmpAlpha = gc.getAlpha();
gc.setAlpha(230);

gc.drawImage(EImage.EDIT, xPos - 6, yPos - 2, magnification);

gc.setBackground(EColor.LIGHTGRAY);
gc.fillRoundRectangle(
xPos - 8,
Expand All @@ -292,21 +288,31 @@ protected void drawAction(ActionMeta actionMeta) throws HopException {
BasePainter.CORNER_RADIUS_5 + 15,
BasePainter.CORNER_RADIUS_5 + 15);
gc.setAlpha(tmpAlpha);

areaOwners.add(
new AreaOwner(
AreaType.ACTION_NAME,
xPos - 8,
yPos - 2,
nameExtent.x + 15,
nameExtent.y + 4,
offset,
actionMeta,
name));
}

// Add the area owner for the action name
//
areaOwners.add(
new AreaOwner(
AreaType.ACTION_NAME,
xPos - 8,
yPos - 2,
nameExtent.x + 15,
nameExtent.y + 4,
offset,
actionMeta,
name));

gc.setForeground(EColor.BLACK);
gc.setFont(EFont.GRAPH);
gc.drawText(name, xPos, yPos, true);

// See if we need to draw a line under the name to make the name look like a hyperlink.
//
if (name.equals(mouseOverName)) {
gc.drawLine(xPos, yPos + nameExtent.y, xPos + nameExtent.x, yPos + nameExtent.y);
}

if (activeActions != null && activeActions.contains(actionMeta)) {
gc.setForeground(EColor.BLUE);
int iconX = (x + iconSize) - (miniIconSize / 2) + 1;
Expand All @@ -325,10 +331,10 @@ protected void drawAction(ActionMeta actionMeta) throws HopException {
} else {
gc.setForeground(EColor.BLACK);
}

// Show an information icon in the upper left corner of the action...
//
if ( !Utils.isEmpty(actionMeta.getDescription()) ) {
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);
Expand Down Expand Up @@ -642,12 +648,16 @@ public void setActiveActions(List<ActionMeta> activeActions) {
this.activeActions = activeActions;
}

/** @return the actionResults */
/**
* @return the actionResults
*/
public List<ActionResult> getActionResults() {
return actionResults;
}

/** @param actionResults Sets AND sorts the action results by name and number */
/**
* @param actionResults Sets AND sorts the action results by name and number
*/
public void setActionResults(List<ActionResult> actionResults) {
this.actionResults = actionResults;
Collections.sort(this.actionResults);
Expand Down
Loading

0 comments on commit 815152c

Please sign in to comment.