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);
}
}
}
}
}
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()));
}
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
}
}
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);
}
}
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);
}
Aggregations