use of org.pentaho.di.core.gui.Point in project pentaho-kettle by pentaho.
the class TransGraph method getRealPosition.
public Point getRealPosition(Composite canvas, int x, int y) {
Point p = new Point(0, 0);
Composite follow = canvas;
while (follow != null) {
org.eclipse.swt.graphics.Point loc = follow.getLocation();
Point xy = new Point(loc.x, loc.y);
p.x += xy.x;
p.y += xy.y;
follow = follow.getParent();
}
int offsetX = -16;
int offsetY = -64;
if (Const.isOSX()) {
offsetX = -2;
offsetY = -24;
}
p.x = x - p.x + offsetX;
p.y = y - p.y + offsetY;
return screen2real(p.x, p.y);
}
use of org.pentaho.di.core.gui.Point in project pentaho-kettle by pentaho.
the class TransGraph method getOffset.
@Override
protected Point getOffset() {
Point area = getArea();
Point max = transMeta.getMaximum();
Point thumb = getThumb(area, max);
return getOffset(thumb, area);
}
use of org.pentaho.di.core.gui.Point in project pentaho-kettle by pentaho.
the class TransGraph method setToolTip.
private AreaOwner setToolTip(int x, int y, int screenX, int screenY) {
AreaOwner subject = null;
if (!spoon.getProperties().showToolTips()) {
return subject;
}
canvas.setToolTipText(null);
String newTip = null;
Image tipImage = null;
final TransHopMeta hi = findHop(x, y);
// check the area owner list...
//
StringBuilder tip = new StringBuilder();
AreaOwner areaOwner = getVisibleAreaOwner(x, y);
if (areaOwner != null && areaOwner.getAreaType() != null) {
switch(areaOwner.getAreaType()) {
case REMOTE_INPUT_STEP:
StepMeta step = (StepMeta) areaOwner.getParent();
tip.append("Remote input steps:").append(Const.CR).append("-----------------------").append(Const.CR);
for (RemoteStep remoteStep : step.getRemoteInputSteps()) {
tip.append(remoteStep.toString()).append(Const.CR);
}
break;
case REMOTE_OUTPUT_STEP:
step = (StepMeta) areaOwner.getParent();
tip.append("Remote output steps:").append(Const.CR).append("-----------------------").append(Const.CR);
for (RemoteStep remoteStep : step.getRemoteOutputSteps()) {
tip.append(remoteStep.toString()).append(Const.CR);
}
break;
case STEP_PARTITIONING:
step = (StepMeta) areaOwner.getParent();
tip.append("Step partitioning:").append(Const.CR).append("-----------------------").append(Const.CR);
tip.append(step.getStepPartitioningMeta().toString()).append(Const.CR);
if (step.getTargetStepPartitioningMeta() != null) {
tip.append(Const.CR).append(Const.CR).append("TARGET: " + step.getTargetStepPartitioningMeta().toString()).append(Const.CR);
}
break;
case STEP_ERROR_ICON:
String log = (String) areaOwner.getParent();
tip.append(log);
tipImage = GUIResource.getInstance().getImageStepError();
break;
case STEP_ERROR_RED_ICON:
String redLog = (String) areaOwner.getParent();
tip.append(redLog);
tipImage = GUIResource.getInstance().getImageRedStepError();
break;
case HOP_COPY_ICON:
step = (StepMeta) areaOwner.getParent();
tip.append(BaseMessages.getString(PKG, "TransGraph.Hop.Tooltip.HopTypeCopy", step.getName(), Const.CR));
tipImage = GUIResource.getInstance().getImageCopyHop();
break;
case ROW_DISTRIBUTION_ICON:
step = (StepMeta) areaOwner.getParent();
tip.append(BaseMessages.getString(PKG, "TransGraph.Hop.Tooltip.RowDistribution", step.getName(), step.getRowDistribution() == null ? "" : step.getRowDistribution().getDescription()));
tip.append(Const.CR);
tipImage = GUIResource.getInstance().getImageBalance();
break;
case HOP_INFO_ICON:
StepMeta from = (StepMeta) areaOwner.getParent();
StepMeta to = (StepMeta) areaOwner.getOwner();
tip.append(BaseMessages.getString(PKG, "TransGraph.Hop.Tooltip.HopTypeInfo", to.getName(), from.getName(), Const.CR));
tipImage = GUIResource.getInstance().getImageInfoHop();
break;
case HOP_ERROR_ICON:
from = (StepMeta) areaOwner.getParent();
to = (StepMeta) areaOwner.getOwner();
areaOwner.getOwner();
tip.append(BaseMessages.getString(PKG, "TransGraph.Hop.Tooltip.HopTypeError", from.getName(), to.getName(), Const.CR));
tipImage = GUIResource.getInstance().getImageErrorHop();
break;
case HOP_INFO_STEP_COPIES_ERROR:
from = (StepMeta) areaOwner.getParent();
to = (StepMeta) areaOwner.getOwner();
tip.append(BaseMessages.getString(PKG, "TransGraph.Hop.Tooltip.InfoStepCopies", from.getName(), to.getName(), Const.CR));
tipImage = GUIResource.getInstance().getImageStepError();
break;
case STEP_INPUT_HOP_ICON:
// StepMeta subjectStep = (StepMeta) (areaOwner.getParent());
tip.append(BaseMessages.getString(PKG, "TransGraph.StepInputConnector.Tooltip"));
tipImage = GUIResource.getInstance().getImageHopInput();
break;
case STEP_OUTPUT_HOP_ICON:
// subjectStep = (StepMeta) (areaOwner.getParent());
tip.append(BaseMessages.getString(PKG, "TransGraph.StepOutputConnector.Tooltip"));
tipImage = GUIResource.getInstance().getImageHopOutput();
break;
case STEP_INFO_HOP_ICON:
// subjectStep = (StepMeta) (areaOwner.getParent());
// StreamInterface stream = (StreamInterface) areaOwner.getOwner();
StepIOMetaInterface ioMeta = (StepIOMetaInterface) areaOwner.getOwner();
tip.append(BaseMessages.getString(PKG, "TransGraph.StepInfoConnector.Tooltip") + Const.CR + ioMeta.toString());
tipImage = GUIResource.getInstance().getImageHopOutput();
break;
case STEP_TARGET_HOP_ICON:
StreamInterface stream = (StreamInterface) areaOwner.getOwner();
tip.append(stream.getDescription());
tipImage = GUIResource.getInstance().getImageHopOutput();
break;
case STEP_ERROR_HOP_ICON:
StepMeta stepMeta = (StepMeta) areaOwner.getParent();
if (stepMeta.supportsErrorHandling()) {
tip.append(BaseMessages.getString(PKG, "TransGraph.StepSupportsErrorHandling.Tooltip"));
} else {
tip.append(BaseMessages.getString(PKG, "TransGraph.StepDoesNotSupportsErrorHandling.Tooltip"));
}
tipImage = GUIResource.getInstance().getImageHopOutput();
break;
case STEP_EDIT_ICON:
stepMeta = (StepMeta) (areaOwner.getParent());
tip.append(BaseMessages.getString(PKG, "TransGraph.EditStep.Tooltip"));
tipImage = GUIResource.getInstance().getImageEdit();
break;
case STEP_INJECT_ICON:
stepMeta = (StepMeta) (areaOwner.getParent());
Object injection = areaOwner.getOwner();
if (injection != null) {
tip.append(BaseMessages.getString(PKG, "TransGraph.StepInjectionSupported.Tooltip"));
} else {
tip.append(BaseMessages.getString(PKG, "TransGraph.StepInjectionNotSupported.Tooltip"));
}
tipImage = GUIResource.getInstance().getImageInject();
break;
case STEP_MENU_ICON:
tip.append(BaseMessages.getString(PKG, "TransGraph.ShowMenu.Tooltip"));
tipImage = GUIResource.getInstance().getImageContextMenu();
break;
default:
break;
}
}
if (hi != null) {
// We clicked on a HOP!
// Set the tooltip for the hop:
tip.append(Const.CR).append(BaseMessages.getString(PKG, "TransGraph.Dialog.HopInfo")).append(newTip = hi.toString()).append(Const.CR);
}
if (tip.length() == 0) {
newTip = null;
} else {
newTip = tip.toString();
}
if (newTip == null) {
toolTip.hide();
if (hi != null) {
// We clicked on a HOP!
// Set the tooltip for the hop:
newTip = BaseMessages.getString(PKG, "TransGraph.Dialog.HopInfo") + Const.CR + BaseMessages.getString(PKG, "TransGraph.Dialog.HopInfo.SourceStep") + " " + hi.getFromStep().getName() + Const.CR + BaseMessages.getString(PKG, "TransGraph.Dialog.HopInfo.TargetStep") + " " + hi.getToStep().getName() + Const.CR + BaseMessages.getString(PKG, "TransGraph.Dialog.HopInfo.Status") + " " + (hi.isEnabled() ? BaseMessages.getString(PKG, "TransGraph.Dialog.HopInfo.Enable") : BaseMessages.getString(PKG, "TransGraph.Dialog.HopInfo.Disable"));
toolTip.setText(newTip);
if (hi.isEnabled()) {
toolTip.setImage(GUIResource.getInstance().getImageHop());
} else {
toolTip.setImage(GUIResource.getInstance().getImageDisabledHop());
}
toolTip.show(new org.eclipse.swt.graphics.Point(screenX, screenY));
} else {
newTip = null;
}
} else if (!newTip.equalsIgnoreCase(getToolTipText())) {
Image tooltipImage = null;
if (tipImage != null) {
tooltipImage = tipImage;
} else {
tooltipImage = GUIResource.getInstance().getImageSpoonLow();
}
showTooltip(newTip, tooltipImage, screenX, screenY);
}
if (areaOwner != null && areaOwner.getExtensionAreaType() != null) {
try {
TransPainterFlyoutTooltipExtension extension = new TransPainterFlyoutTooltipExtension(areaOwner, this, new Point(screenX, screenY));
ExtensionPointHandler.callExtensionPoint(LogChannel.GENERAL, KettleExtensionPoint.TransPainterFlyoutTooltip.id, extension);
} catch (Exception e) {
LogChannel.GENERAL.logError("Error calling extension point(s) for the transformation painter step", e);
}
}
return subject;
}
use of org.pentaho.di.core.gui.Point in project pdi-dataservice-server-plugin by pentaho.
the class TransPainterStepExtesionPointPluginTest method testCallExtensionPoint.
@Test
public void testCallExtensionPoint() throws Exception {
extension.transMeta = transMeta;
extension.stepMeta = stepMeta;
extension.gc = gc;
extension.x1 = 0;
extension.y1 = 0;
extension.iconsize = 32;
extension.offset = new Point(0, 0);
extension.areaOwners = new ArrayList<>();
when(stepMeta.getName()).thenReturn(STEP_NAME);
when(metaStoreUtil.getDataServiceByStepName(transMeta, STEP_NAME)).thenReturn(dataServiceMeta);
when(dataServiceMeta.isUserDefined()).thenReturn(true);
ArgumentCaptor<String> captor = ArgumentCaptor.forClass(String.class);
when(dataServiceMeta.isStreaming()).thenReturn(false);
plugin.callExtensionPoint(log, extension);
verify(metaStoreUtil).getDataServiceByStepName(transMeta, STEP_NAME);
verify(gc).drawImage(captor.capture(), any(ClassLoader.class), anyInt(), anyInt());
assert (captor.getValue().equals("images/data-services.svg"));
}
use of org.pentaho.di.core.gui.Point in project pdi-dataservice-server-plugin by pentaho.
the class TransPainterStepExtesionPointPluginTest method testCallExtensionPointWithStreamingDataService.
@Test
public void testCallExtensionPointWithStreamingDataService() throws Exception {
extension.transMeta = transMeta;
extension.stepMeta = stepMeta;
extension.gc = gc;
extension.x1 = 0;
extension.y1 = 0;
extension.iconsize = 32;
extension.offset = new Point(0, 0);
extension.areaOwners = new ArrayList<>();
when(stepMeta.getName()).thenReturn(STEP_NAME);
when(metaStoreUtil.getDataServiceByStepName(transMeta, STEP_NAME)).thenReturn(dataServiceMeta);
when(dataServiceMeta.isUserDefined()).thenReturn(true);
ArgumentCaptor<String> captor = ArgumentCaptor.forClass(String.class);
when(dataServiceMeta.isStreaming()).thenReturn(true);
plugin.callExtensionPoint(log, extension);
verify(metaStoreUtil).getDataServiceByStepName(transMeta, STEP_NAME);
verify(gc).drawImage(captor.capture(), any(ClassLoader.class), anyInt(), anyInt());
assert (captor.getValue().equals("images/data-services-streaming.svg"));
}
Aggregations