Search in sources :

Example 1 with IGc

use of org.apache.hop.core.gui.IGc in project hop by apache.

the class DrawTweakOnTransformExtensionPoint method drawRemovedTweak.

private void drawRemovedTweak(PipelinePainterExtension ext, TransformMeta transformMeta) {
    // Now we're here, mark the transform as removed: a cross over the transform icon
    // 
    IGc gc = ext.gc;
    int iconSize = ext.iconSize;
    int x = ext.x1 - 5;
    int y = ext.y1 - 5;
    gc.setLineWidth(transformMeta.isSelected() ? 4 : 3);
    gc.setForeground(IGc.EColor.CRYSTAL);
    gc.setBackground(IGc.EColor.LIGHTGRAY);
    gc.setFont(IGc.EFont.GRAPH);
    gc.drawLine(x, y, x + iconSize / 2, y + iconSize / 2);
    gc.drawLine(x + iconSize / 2, y, x, y + iconSize / 2);
}
Also used : IGc(org.apache.hop.core.gui.IGc) IExtensionPoint(org.apache.hop.core.extension.IExtensionPoint) ExtensionPoint(org.apache.hop.core.extension.ExtensionPoint)

Example 2 with IGc

use of org.apache.hop.core.gui.IGc in project hop by apache.

the class DrawGoldenDataSetOnTransformExtensionPoint method drawGoldenSetMarker.

protected void drawGoldenSetMarker(PipelinePainterExtension ext, TransformMeta transformMeta, PipelineUnitTest unitTest, List<AreaOwner> areaOwners) {
    PipelineUnitTestSetLocation location = unitTest.findGoldenLocation(transformMeta.getName());
    if (location == null) {
        return;
    }
    String dataSetName = Const.NVL(location.getDataSetName(), "");
    // Now we're here, draw a marker and indicate the name of the unit test
    // 
    IGc gc = ext.gc;
    int iconSize = ext.iconSize;
    int x = ext.x1;
    int y = ext.y1;
    gc.setLineWidth(transformMeta.isSelected() ? 2 : 1);
    gc.setForeground(IGc.EColor.CRYSTAL);
    gc.setBackground(IGc.EColor.LIGHTGRAY);
    gc.setFont(IGc.EFont.GRAPH);
    Point textExtent = gc.textExtent(dataSetName);
    // add a tiny bit of a margin
    textExtent.x += 6;
    textExtent.y += 6;
    // Draw it at the right hand side
    // 
    int arrowSize = textExtent.y;
    Point point = new Point(x + iconSize, y + (iconSize - textExtent.y) / 2);
    int[] arrow = new int[] { point.x, point.y + textExtent.y / 2, point.x + arrowSize, point.y, point.x + textExtent.x + arrowSize, point.y, point.x + textExtent.x + arrowSize, point.y + textExtent.y, point.x + arrowSize, point.y + textExtent.y };
    gc.fillPolygon(arrow);
    gc.drawPolygon(arrow);
    gc.drawText(dataSetName, point.x + arrowSize + 3, point.y + 3);
    // Leave a trace of what we drew, for memory reasons, just the name of the data set here.
    // 
    areaOwners.add(new AreaOwner(AreaOwner.AreaType.CUSTOM, point.x, point.y, textExtent.x, textExtent.y, new Point(0, 0), DataSetConst.AREA_DRAWN_GOLDEN_DATA_SET, transformMeta.getName()));
    // 
    if (ext.stateMap != null) {
        Map<String, Boolean> results = (Map<String, Boolean>) ext.stateMap.get(DataSetConst.STATE_KEY_GOLDEN_DATASET_RESULTS);
        if (results != null) {
            Boolean result = results.get(dataSetName);
            if (result != null) {
                try {
                    int iconX = point.x + arrowSize + textExtent.x - 5;
                    int iconY = point.y - 5;
                    if (result) {
                        gc.drawImage(IGc.EImage.SUCCESS, iconX, iconY, gc.getMagnification());
                    } else {
                        gc.drawImage(IGc.EImage.FAILURE, iconX, iconY, gc.getMagnification());
                    }
                    areaOwners.add(new AreaOwner(AreaOwner.AreaType.CUSTOM, iconX + ConstUi.SMALL_ICON_SIZE, iconY + 5, ConstUi.SMALL_ICON_SIZE, ConstUi.SMALL_ICON_SIZE, new Point(0, 0), DataSetConst.AREA_DRAWN_GOLDEN_DATA_RESULT, transformMeta.getName()));
                } catch (Exception e) {
                    LogChannel.UI.logError("Error drawing golden data set result on pipeline", e);
                }
            }
        }
    }
}
Also used : PipelineUnitTestSetLocation(org.apache.hop.testing.PipelineUnitTestSetLocation) IGc(org.apache.hop.core.gui.IGc) AreaOwner(org.apache.hop.core.gui.AreaOwner) ExtensionPoint(org.apache.hop.core.extension.ExtensionPoint) IExtensionPoint(org.apache.hop.core.extension.IExtensionPoint) Point(org.apache.hop.core.gui.Point) Map(java.util.Map) 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)

Example 3 with IGc

use of org.apache.hop.core.gui.IGc in project hop by apache.

the class DrawInputDataSetOnTransformExtensionPoint method drawInputDataSetMarker.

private void drawInputDataSetMarker(PipelinePainterExtension ext, TransformMeta transformMeta, PipelineUnitTest unitTest, List<AreaOwner> areaOwners) {
    // Now we're here, draw a marker and indicate the name of the data set name
    // 
    PipelineUnitTestSetLocation location = unitTest.findInputLocation(transformMeta.getName());
    if (location == null) {
        return;
    }
    String dataSetName = Const.NVL(location.getDataSetName(), "");
    IGc gc = ext.gc;
    int iconSize = ext.iconSize;
    int x = ext.x1;
    int y = ext.y1;
    gc.setLineWidth(transformMeta.isSelected() ? 2 : 1);
    gc.setForeground(IGc.EColor.CRYSTAL);
    gc.setBackground(IGc.EColor.LIGHTGRAY);
    gc.setFont(IGc.EFont.GRAPH);
    Point textExtent = gc.textExtent(dataSetName);
    // add a tiny bit of a margin
    textExtent.x += 6;
    textExtent.y += 6;
    // Draw it to the left as an arrow
    // 
    int arrowSize = textExtent.y;
    Point point = new Point(x - textExtent.x - arrowSize - 2, y + (iconSize - textExtent.y) / 2);
    int[] arrow = new int[] { point.x, point.y, point.x + textExtent.x, point.y, point.x + textExtent.x + arrowSize, point.y + textExtent.y / 2, point.x + textExtent.x, point.y + textExtent.y, point.x, point.y + textExtent.y };
    gc.fillPolygon(arrow);
    gc.drawPolygon(arrow);
    gc.drawText(dataSetName, point.x + 3, point.y + 3);
    // Leave a trace of what we drew, for memory reasons, just the name of the data set here.
    // 
    areaOwners.add(new AreaOwner(AreaOwner.AreaType.CUSTOM, point.x, point.y, textExtent.x, textExtent.y, new Point(0, 0), DataSetConst.AREA_DRAWN_INPUT_DATA_SET, transformMeta.getName()));
}
Also used : PipelineUnitTestSetLocation(org.apache.hop.testing.PipelineUnitTestSetLocation) IGc(org.apache.hop.core.gui.IGc) AreaOwner(org.apache.hop.core.gui.AreaOwner) ExtensionPoint(org.apache.hop.core.extension.ExtensionPoint) IExtensionPoint(org.apache.hop.core.extension.IExtensionPoint) Point(org.apache.hop.core.gui.Point) ExtensionPoint(org.apache.hop.core.extension.ExtensionPoint) IExtensionPoint(org.apache.hop.core.extension.IExtensionPoint) Point(org.apache.hop.core.gui.Point)

Example 4 with IGc

use of org.apache.hop.core.gui.IGc 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)

Example 5 with IGc

use of org.apache.hop.core.gui.IGc in project hop by apache.

the class DrawDiffOnPipelineHopExtensionPoint method callExtensionPoint.

@Override
public void callExtensionPoint(ILogChannel log, IVariables variables, PipelinePainterExtension ext) throws HopException {
    IGc gc = ext.gc;
    ClassLoader classLoader = this.getClass().getClassLoader();
    try {
        Map<String, String> gitHops = ext.pipelineMeta.getAttributes(ATTR_GIT_HOPS);
        if (gitHops == null) {
            return;
        }
        for (String hopName : gitHops.keySet()) {
            String pipelineHopName = getPipelineHopName(ext.pipelineHop);
            if (ext.pipelineHop != null && pipelineHopName.equals(hopName)) {
                // Draw this status...
                // 
                SvgFile svgFile = null;
                String status = gitHops.get(hopName);
                if (status != null) {
                    switch(status) {
                        case ADDED:
                            svgFile = new SvgFile("added.svg", classLoader);
                            break;
                        case REMOVED:
                            svgFile = new SvgFile("removed.svg", classLoader);
                            break;
                        case CHANGED:
                            svgFile = new SvgFile("changed.svg", classLoader);
                            break;
                    }
                    if (svgFile != null) {
                        // Center of hop...
                        // 
                        Point fr = ext.pipelineHop.getFromTransform().getLocation();
                        Point to = ext.pipelineHop.getToTransform().getLocation();
                        Point middle = new Point((fr.x + to.x) / 2, (fr.y + to.y) / 2);
                        int iconSize = ConstUi.ICON_SIZE;
                        try {
                            iconSize = PropsUi.getInstance().getIconSize();
                        } catch (Exception e) {
                        // Exception when accessed from Hop Server
                        }
                        gc.drawImage(svgFile, middle.x, middle.y, iconSize / 2, iconSize / 2, gc.getMagnification(), 0);
                    }
                }
            }
        }
    } catch (Exception e) {
        throw new HopException("Error drawing status on pipeline hop", e);
    }
}
Also used : IGc(org.apache.hop.core.gui.IGc) HopException(org.apache.hop.core.exception.HopException) 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)

Aggregations

ExtensionPoint (org.apache.hop.core.extension.ExtensionPoint)8 IExtensionPoint (org.apache.hop.core.extension.IExtensionPoint)8 IGc (org.apache.hop.core.gui.IGc)8 Point (org.apache.hop.core.gui.Point)6 HopException (org.apache.hop.core.exception.HopException)5 SvgFile (org.apache.hop.core.svg.SvgFile)4 AreaOwner (org.apache.hop.core.gui.AreaOwner)2 ILogChannel (org.apache.hop.core.logging.ILogChannel)2 IVariables (org.apache.hop.core.variables.IVariables)2 HopDiff (org.apache.hop.git.HopDiff)2 PipelineUnitTestSetLocation (org.apache.hop.testing.PipelineUnitTestSetLocation)2 ConstUi (org.apache.hop.ui.core.ConstUi)2 PropsUi (org.apache.hop.ui.core.PropsUi)2 Map (java.util.Map)1 PipelineMeta (org.apache.hop.pipeline.PipelineMeta)1 PipelinePainter (org.apache.hop.pipeline.PipelinePainter)1 WorkflowMeta (org.apache.hop.workflow.WorkflowMeta)1 WorkflowPainter (org.apache.hop.workflow.WorkflowPainter)1