Search in sources :

Example 1 with AreaOwner

use of org.apache.hop.core.gui.AreaOwner 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 2 with AreaOwner

use of org.apache.hop.core.gui.AreaOwner 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 3 with AreaOwner

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

the class ActionDebugLevelToolTipExtensionPoint method callExtensionPoint.

@Override
public void callExtensionPoint(ILogChannel log, IVariables variables, HopGuiTooltipExtension ext) {
    AreaOwner areaOwner = ext.areaOwner;
    try {
        if (areaOwner.getOwner() instanceof ActionDebugLevel) {
            ActionDebugLevel debugLevel = (ActionDebugLevel) areaOwner.getOwner();
            ext.tip.append("Custom action debug level: " + debugLevel.toString());
        }
    } catch (Exception e) {
    // Ignore error, not that important
    }
}
Also used : AreaOwner(org.apache.hop.core.gui.AreaOwner)

Example 4 with AreaOwner

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

the class DrawAsyncLoggingIconExtensionPoint method callExtensionPoint.

@Override
public void callExtensionPoint(ILogChannel log, IVariables variables, WorkflowPainterExtension ext) {
    // 
    if (!ext.actionMeta.isPipeline()) {
        return;
    }
    try {
        // This next map contains a simple "true" flag for every pipeline that contains a status
        // 
        Map<String, String> pipelineMap = ext.actionMeta.getAttributesMap().get(Defaults.ASYNC_STATUS_GROUP);
        if (pipelineMap == null) {
            return;
        }
        String serviceName = pipelineMap.get(Defaults.ASYNC_ACTION_PIPELINE_SERVICE_NAME);
        if (serviceName == null) {
            return;
        }
        // Draw an icon
        // 
        Rectangle r = drawLogIcon(ext.gc, ext.x1, ext.y1, ext.iconSize, this.getClass().getClassLoader());
        ext.areaOwners.add(new AreaOwner(AreaOwner.AreaType.CUSTOM, r.x, r.y, r.width, r.height, ext.offset, ext.actionMeta, STRING_AREA_OWNER_PREFIX + serviceName));
    } catch (Exception e) {
        // Just log the error, not that important
        log.logError("Error drawing async log icon", e);
    }
}
Also used : AreaOwner(org.apache.hop.core.gui.AreaOwner) Rectangle(org.apache.hop.core.gui.Rectangle)

Example 5 with AreaOwner

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

the class ContextDialog method selectItemUp.

/**
 * Find an area owner directly to the top of the area
 *
 * @param area
 */
private void selectItemUp(Rectangle area) {
    List<AreaOwner> topAreas = new ArrayList<>();
    for (AreaOwner areaOwner : areaOwners) {
        if (areaOwner.getOwner() instanceof Item) {
            // 
            if (areaOwner.getArea().y < area.y) {
                topAreas.add(areaOwner);
            }
        }
    }
    selectClosest(area, topAreas);
}
Also used : AreaOwner(org.apache.hop.core.gui.AreaOwner)

Aggregations

AreaOwner (org.apache.hop.core.gui.AreaOwner)16 Rectangle (org.apache.hop.core.gui.Rectangle)6 Point (org.apache.hop.core.gui.Point)4 ExtensionPoint (org.apache.hop.core.extension.ExtensionPoint)3 IExtensionPoint (org.apache.hop.core.extension.IExtensionPoint)3 PipelineUnitTestSetLocation (org.apache.hop.testing.PipelineUnitTestSetLocation)3 HopException (org.apache.hop.core.exception.HopException)2 IGc (org.apache.hop.core.gui.IGc)2 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 GuiAction (org.apache.hop.core.gui.plugin.action.GuiAction)1 IRowMeta (org.apache.hop.core.row.IRowMeta)1 MultiMetadataProvider (org.apache.hop.metadata.serializer.multi.MultiMetadataProvider)1 PipelineMeta (org.apache.hop.pipeline.PipelineMeta)1 TransformMeta (org.apache.hop.pipeline.transform.TransformMeta)1 DataSet (org.apache.hop.testing.DataSet)1 PipelineUnitTest (org.apache.hop.testing.PipelineUnitTest)1 UnitTestResult (org.apache.hop.testing.UnitTestResult)1 ErrorDialog (org.apache.hop.ui.core.dialog.ErrorDialog)1