Search in sources :

Example 1 with WorkflowPainter

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);
    }
}
Also used : ILogChannel(org.apache.hop.core.logging.ILogChannel) SvgFile(org.apache.hop.core.svg.SvgFile) ExtensionPoint(org.apache.hop.core.extension.ExtensionPoint) IVariables(org.apache.hop.core.variables.IVariables) WorkflowPainter(org.apache.hop.workflow.WorkflowPainter) HopDiff(org.apache.hop.git.HopDiff) HopException(org.apache.hop.core.exception.HopException) WorkflowMeta(org.apache.hop.workflow.WorkflowMeta) PropsUi(org.apache.hop.ui.core.PropsUi) IExtensionPoint(org.apache.hop.core.extension.IExtensionPoint) IGc(org.apache.hop.core.gui.IGc) Point(org.apache.hop.core.gui.Point) ConstUi(org.apache.hop.ui.core.ConstUi) IGc(org.apache.hop.core.gui.IGc) HopException(org.apache.hop.core.exception.HopException) WorkflowPainter(org.apache.hop.workflow.WorkflowPainter) ExtensionPoint(org.apache.hop.core.extension.ExtensionPoint) IExtensionPoint(org.apache.hop.core.extension.IExtensionPoint) Point(org.apache.hop.core.gui.Point) SvgFile(org.apache.hop.core.svg.SvgFile) ExtensionPoint(org.apache.hop.core.extension.ExtensionPoint) IExtensionPoint(org.apache.hop.core.extension.IExtensionPoint) Point(org.apache.hop.core.gui.Point) HopException(org.apache.hop.core.exception.HopException) WorkflowMeta(org.apache.hop.workflow.WorkflowMeta)

Aggregations

HopException (org.apache.hop.core.exception.HopException)1 ExtensionPoint (org.apache.hop.core.extension.ExtensionPoint)1 IExtensionPoint (org.apache.hop.core.extension.IExtensionPoint)1 IGc (org.apache.hop.core.gui.IGc)1 Point (org.apache.hop.core.gui.Point)1 ILogChannel (org.apache.hop.core.logging.ILogChannel)1 SvgFile (org.apache.hop.core.svg.SvgFile)1 IVariables (org.apache.hop.core.variables.IVariables)1 HopDiff (org.apache.hop.git.HopDiff)1 ConstUi (org.apache.hop.ui.core.ConstUi)1 PropsUi (org.apache.hop.ui.core.PropsUi)1 WorkflowMeta (org.apache.hop.workflow.WorkflowMeta)1 WorkflowPainter (org.apache.hop.workflow.WorkflowPainter)1