Search in sources :

Example 66 with Point

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);
}
Also used : Composite(org.eclipse.swt.widgets.Composite) Point(org.pentaho.di.core.gui.Point) KettleExtensionPoint(org.pentaho.di.core.extension.KettleExtensionPoint) Point(org.pentaho.di.core.gui.Point) KettleExtensionPoint(org.pentaho.di.core.extension.KettleExtensionPoint)

Example 67 with Point

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);
}
Also used : Point(org.pentaho.di.core.gui.Point) KettleExtensionPoint(org.pentaho.di.core.extension.KettleExtensionPoint)

Example 68 with Point

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;
}
Also used : StepIOMetaInterface(org.pentaho.di.trans.step.StepIOMetaInterface) Point(org.pentaho.di.core.gui.Point) KettleExtensionPoint(org.pentaho.di.core.extension.KettleExtensionPoint) SwtUniversalImage(org.pentaho.di.core.SwtUniversalImage) Image(org.eclipse.swt.graphics.Image) StepMeta(org.pentaho.di.trans.step.StepMeta) XulException(org.pentaho.ui.xul.XulException) InvocationTargetException(java.lang.reflect.InvocationTargetException) KettleValueException(org.pentaho.di.core.exception.KettleValueException) KettleStepException(org.pentaho.di.core.exception.KettleStepException) KettleRepositoryLostException(org.pentaho.di.repository.KettleRepositoryLostException) KettleException(org.pentaho.di.core.exception.KettleException) RemoteStep(org.pentaho.di.trans.step.RemoteStep) AreaOwner(org.pentaho.di.core.gui.AreaOwner) SimpleLoggingObject(org.pentaho.di.core.logging.SimpleLoggingObject) TransHopMeta(org.pentaho.di.trans.TransHopMeta) StreamInterface(org.pentaho.di.trans.step.errorhandling.StreamInterface)

Example 69 with Point

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"));
}
Also used : Point(org.pentaho.di.core.gui.Point) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Example 70 with Point

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"));
}
Also used : Point(org.pentaho.di.core.gui.Point) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Aggregations

Point (org.pentaho.di.core.gui.Point)141 KettleExtensionPoint (org.pentaho.di.core.extension.KettleExtensionPoint)72 Test (org.junit.Test)37 StepMeta (org.pentaho.di.trans.step.StepMeta)34 NotePadMeta (org.pentaho.di.core.NotePadMeta)29 KettleException (org.pentaho.di.core.exception.KettleException)28 JobEntryCopy (org.pentaho.di.job.entry.JobEntryCopy)28 PrintWriter (java.io.PrintWriter)26 HttpServletRequest (javax.servlet.http.HttpServletRequest)26 HttpServletResponse (javax.servlet.http.HttpServletResponse)26 LogChannelInterface (org.pentaho.di.core.logging.LogChannelInterface)26 TransMeta (org.pentaho.di.trans.TransMeta)25 StringWriter (java.io.StringWriter)24 AreaOwner (org.pentaho.di.core.gui.AreaOwner)22 Trans (org.pentaho.di.trans.Trans)18 JobMeta (org.pentaho.di.job.JobMeta)17 ArrayList (java.util.ArrayList)16 TransHopMeta (org.pentaho.di.trans.TransHopMeta)14 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)14 KettleRepositoryLostException (org.pentaho.di.repository.KettleRepositoryLostException)12