use of org.apache.hop.workflow.WorkflowPainter in project hop by apache.
the class DrawDiffOnActionExtensionPoint method callExtensionPoint.
@Override
public void callExtensionPoint(ILogChannel log, IVariables variables, Object object) throws HopException {
if (!(object instanceof WorkflowPainter)) {
return;
}
WorkflowPainter painter = (WorkflowPainter) object;
Point offset = painter.getOffset();
IGc gc = painter.getGc();
WorkflowMeta workflowMeta = painter.getWorkflowMeta();
try {
workflowMeta.getActions().stream().filter(je -> je.getAttribute(ATTR_GIT, ATTR_STATUS) != null).forEach(je -> {
if (workflowMeta.getWorkflowVersion() == null ? false : workflowMeta.getWorkflowVersion().startsWith("git")) {
String status = je.getAttribute(ATTR_GIT, ATTR_STATUS);
Point n = je.getLocation();
String location;
if (status.equals(REMOVED)) {
location = "removed.svg";
} else if (status.equals(CHANGED)) {
location = "changed.svg";
} else if (status.equals(ADDED)) {
location = "added.svg";
} else {
// Unchanged
return;
}
int iconSize = ConstUi.ICON_SIZE;
try {
iconSize = PropsUi.getInstance().getIconSize();
} catch (Exception e) {
// Exception when accessed from Hop Server
}
int x = (n.x + iconSize + offset.x) - (iconSize / 4);
int y = n.y + offset.y - (iconSize / 4);
try {
gc.drawImage(new SvgFile(location, getClass().getClassLoader()), x, y, iconSize / 4, iconSize / 4, gc.getMagnification(), 0);
} catch (Exception e) {
throw new RuntimeException(e);
}
} else {
je.getAttributesMap().remove(ATTR_GIT);
}
});
} catch (Exception e) {
throw new HopException("Error drawing status icon on action", e);
}
}
Aggregations