Search in sources :

Example 6 with AreaOwner

use of org.pentaho.di.core.gui.AreaOwner in project pentaho-kettle by pentaho.

the class TransformationInformation method drawImage.

public void drawImage(final Graphics2D g2d, final Rectangle2D rectangle2d, ReportSubjectLocation location, boolean pixelateImages) throws KettleException {
    // Load the transformation
    // 
    TransMeta transMeta = loadTransformation(location);
    Point min = transMeta.getMinimum();
    Point area = transMeta.getMaximum();
    area.x -= min.x;
    area.y -= min.y;
    int iconsize = 32;
    ScrollBarInterface bar = new ScrollBarInterface() {

        public void setThumb(int thumb) {
        }

        public int getSelection() {
            return 0;
        }
    };
    // Paint the transformation...
    // 
    Rectangle rect = new java.awt.Rectangle(0, 0, area.x, area.y);
    double magnificationX = rectangle2d.getWidth() / rect.getWidth();
    double magnificationY = rectangle2d.getHeight() / rect.getHeight();
    float magnification = (float) Math.min(1, Math.min(magnificationX, magnificationY));
    SwingGC gc = new SwingGC(g2d, rect, iconsize, 0, 0);
    gc.setDrawingPixelatedImages(pixelateImages);
    TransPainter painter = new TransPainter(gc, transMeta, area, bar, bar, null, null, null, new ArrayList<AreaOwner>(), new ArrayList<StepMeta>(), iconsize, 1, 0, 0, true, "FreeSans", 10);
    painter.setMagnification(magnification);
    painter.setTranslationX((-min.x) * magnification);
    painter.setTranslationY((-min.y) * magnification);
    painter.buildTransformationImage();
}
Also used : TransMeta(org.pentaho.di.trans.TransMeta) Rectangle(java.awt.Rectangle) Point(org.pentaho.di.core.gui.Point) SwingGC(org.pentaho.di.core.gui.SwingGC) StepMeta(org.pentaho.di.trans.step.StepMeta) Point(org.pentaho.di.core.gui.Point) ScrollBarInterface(org.pentaho.di.core.gui.ScrollBarInterface) AreaOwner(org.pentaho.di.core.gui.AreaOwner) TransPainter(org.pentaho.di.trans.TransPainter)

Example 7 with AreaOwner

use of org.pentaho.di.core.gui.AreaOwner in project pentaho-kettle by pentaho.

the class GetTransImageServlet method generateTransformationImage.

private BufferedImage generateTransformationImage(TransMeta transMeta) throws Exception {
    float magnification = 1.0f;
    Point maximum = transMeta.getMaximum();
    maximum.multiply(magnification);
    SwingGC gc = new SwingGC(null, maximum, 32, 0, 0);
    TransPainter transPainter = new TransPainter(gc, transMeta, maximum, null, null, null, null, null, new ArrayList<AreaOwner>(), new ArrayList<StepMeta>(), 32, 1, 0, 0, true, "Arial", 10);
    transPainter.setMagnification(magnification);
    transPainter.buildTransformationImage();
    return (BufferedImage) gc.getImage();
}
Also used : AreaOwner(org.pentaho.di.core.gui.AreaOwner) Point(org.pentaho.di.core.gui.Point) SwingGC(org.pentaho.di.core.gui.SwingGC) TransPainter(org.pentaho.di.trans.TransPainter) StepMeta(org.pentaho.di.trans.step.StepMeta) BufferedImage(java.awt.image.BufferedImage)

Example 8 with AreaOwner

use of org.pentaho.di.core.gui.AreaOwner in project pentaho-kettle by pentaho.

the class TransGraph method mouseDown.

@Override
public void mouseDown(MouseEvent e) {
    boolean alt = (e.stateMask & SWT.ALT) != 0;
    boolean control = (e.stateMask & SWT.MOD1) != 0;
    boolean shift = (e.stateMask & SWT.SHIFT) != 0;
    lastButton = e.button;
    Point real = screen2real(e.x, e.y);
    lastclick = new Point(real.x, real.y);
    // Hide the tooltip!
    hideToolTips();
    // Set the pop-up menu
    if (e.button == 3) {
        setMenu(real.x, real.y);
        return;
    }
    try {
        ExtensionPointHandler.callExtensionPoint(LogChannel.GENERAL, KettleExtensionPoint.TransGraphMouseDown.id, new TransGraphExtension(this, e, real));
    } catch (Exception ex) {
        LogChannel.GENERAL.logError("Error calling TransGraphMouseDown extension point", ex);
    }
    // 
    if (e.button == 1 || e.button == 2) {
        AreaOwner areaOwner = getVisibleAreaOwner(real.x, real.y);
        if (areaOwner != null && areaOwner.getAreaType() != null) {
            switch(areaOwner.getAreaType()) {
                case STEP_OUTPUT_HOP_ICON:
                    // Click on the output icon means: start of drag
                    // Action: We show the input icons on the other steps...
                    // 
                    selectedStep = null;
                    startHopStep = (StepMeta) areaOwner.getParent();
                    candidateHopType = null;
                    startErrorHopStep = false;
                    // stopStepMouseOverDelayTimer(startHopStep);
                    break;
                case STEP_INPUT_HOP_ICON:
                    // Click on the input icon means: start to a new hop
                    // In this case, we set the end hop step...
                    // 
                    selectedStep = null;
                    startHopStep = null;
                    endHopStep = (StepMeta) areaOwner.getParent();
                    candidateHopType = null;
                    startErrorHopStep = false;
                    // stopStepMouseOverDelayTimer(endHopStep);
                    break;
                case HOP_ERROR_ICON:
                    // Click on the error icon means: Edit error handling
                    // 
                    StepMeta stepMeta = (StepMeta) areaOwner.getParent();
                    spoon.editStepErrorHandling(transMeta, stepMeta);
                    break;
                case STEP_TARGET_HOP_ICON_OPTION:
                    // Below, see showStepTargetOptions()
                    break;
                case STEP_EDIT_ICON:
                    clearSettings();
                    currentStep = (StepMeta) areaOwner.getParent();
                    stopStepMouseOverDelayTimer(currentStep);
                    editStep();
                    break;
                case STEP_INJECT_ICON:
                    MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_INFORMATION);
                    mb.setMessage(BaseMessages.getString(PKG, "TransGraph.StepInjectionSupported.Tooltip"));
                    mb.setText(BaseMessages.getString(PKG, "TransGraph.StepInjectionSupported.Title"));
                    mb.open();
                    break;
                case STEP_MENU_ICON:
                    clearSettings();
                    stepMeta = (StepMeta) areaOwner.getParent();
                    setMenu(stepMeta.getLocation().x, stepMeta.getLocation().y);
                    break;
                case STEP_ICON:
                    stepMeta = (StepMeta) areaOwner.getOwner();
                    currentStep = stepMeta;
                    for (StepSelectionListener listener : currentStepListeners) {
                        listener.onUpdateSelection(currentStep);
                    }
                    if (candidate != null) {
                        addCandidateAsHop(e.x, e.y);
                    } else {
                        if (transPreviewDelegate.isActive()) {
                            transPreviewDelegate.setSelectedStep(currentStep);
                            for (SelectedStepListener stepListener : stepListeners) {
                                if (this.extraViewComposite != null && !this.extraViewComposite.isDisposed()) {
                                    stepListener.onSelect(currentStep);
                                }
                            }
                            transPreviewDelegate.refreshView();
                        }
                    }
                    // 
                    if (e.button == 1 && alt && stepMeta.supportsErrorHandling()) {
                        spoon.editStepErrorHandling(transMeta, stepMeta);
                        return;
                    } else if (e.button == 2 || (e.button == 1 && shift)) {
                        // SHIFT CLICK is start of drag to create a new hop
                        // 
                        startHopStep = stepMeta;
                    } else {
                        selectedSteps = transMeta.getSelectedSteps();
                        selectedStep = stepMeta;
                        // 
                        // When an icon is moved that is not selected, it gets
                        // selected too late.
                        // It is not captured here, but in the mouseMoveListener...
                        // 
                        previous_step_locations = transMeta.getSelectedStepLocations();
                        Point p = stepMeta.getLocation();
                        iconoffset = new Point(real.x - p.x, real.y - p.y);
                    }
                    redraw();
                    break;
                case NOTE:
                    ni = (NotePadMeta) areaOwner.getOwner();
                    selectedNotes = transMeta.getSelectedNotes();
                    selectedNote = ni;
                    Point loc = ni.getLocation();
                    previous_note_locations = transMeta.getSelectedNoteLocations();
                    noteoffset = new Point(real.x - loc.x, real.y - loc.y);
                    redraw();
                    break;
                case STEP_COPIES_TEXT:
                    copies((StepMeta) areaOwner.getOwner());
                    break;
                case STEP_DATA_SERVICE:
                    editProperties(transMeta, spoon, spoon.getRepository(), true, TransDialog.Tabs.EXTRA_TAB);
                    break;
                default:
                    break;
            }
        } else {
            // A hop? --> enable/disable
            // 
            TransHopMeta hop = findHop(real.x, real.y);
            if (hop != null) {
                TransHopMeta before = (TransHopMeta) hop.clone();
                setHopEnabled(hop, !hop.isEnabled());
                if (hop.isEnabled() && transMeta.hasLoop(hop.getToStep())) {
                    setHopEnabled(hop, false);
                    MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_ERROR);
                    mb.setMessage(BaseMessages.getString(PKG, "TransGraph.Dialog.HopCausesLoop.Message"));
                    mb.setText(BaseMessages.getString(PKG, "TransGraph.Dialog.HopCausesLoop.Title"));
                    mb.open();
                }
                TransHopMeta after = (TransHopMeta) hop.clone();
                spoon.addUndoChange(transMeta, new TransHopMeta[] { before }, new TransHopMeta[] { after }, new int[] { transMeta.indexOfTransHop(hop) });
                redraw();
                spoon.setShellText();
            } else {
                // No area-owner & no hop means : background click:
                // 
                startHopStep = null;
                if (!control) {
                    selectionRegion = new org.pentaho.di.core.gui.Rectangle(real.x, real.y, 0, 0);
                }
                redraw();
            }
        }
    }
}
Also used : Point(org.pentaho.di.core.gui.Point) KettleExtensionPoint(org.pentaho.di.core.extension.KettleExtensionPoint) 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) MessageBox(org.eclipse.swt.widgets.MessageBox) AreaOwner(org.pentaho.di.core.gui.AreaOwner) TransHopMeta(org.pentaho.di.trans.TransHopMeta)

Example 9 with AreaOwner

use of org.pentaho.di.core.gui.AreaOwner 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 10 with AreaOwner

use of org.pentaho.di.core.gui.AreaOwner in project pentaho-kettle by pentaho.

the class GetJobImageServlet method generateJobImage.

private BufferedImage generateJobImage(JobMeta jobMeta) throws Exception {
    float magnification = 1.0f;
    Point maximum = jobMeta.getMaximum();
    maximum.multiply(magnification);
    SwingGC gc = new SwingGC(null, maximum, 32, 0, 0);
    JobPainter jobPainter = new JobPainter(gc, jobMeta, maximum, null, null, null, null, null, new ArrayList<AreaOwner>(), new ArrayList<JobEntryCopy>(), 32, 1, 0, 0, true, "Arial", 10);
    jobPainter.setMagnification(magnification);
    jobPainter.drawJob();
    BufferedImage image = (BufferedImage) gc.getImage();
    return image;
}
Also used : JobEntryCopy(org.pentaho.di.job.entry.JobEntryCopy) JobPainter(org.pentaho.di.job.JobPainter) AreaOwner(org.pentaho.di.core.gui.AreaOwner) Point(org.pentaho.di.core.gui.Point) SwingGC(org.pentaho.di.core.gui.SwingGC) BufferedImage(java.awt.image.BufferedImage)

Aggregations

AreaOwner (org.pentaho.di.core.gui.AreaOwner)25 Point (org.pentaho.di.core.gui.Point)23 KettleExtensionPoint (org.pentaho.di.core.extension.KettleExtensionPoint)17 KettleException (org.pentaho.di.core.exception.KettleException)12 StepMeta (org.pentaho.di.trans.step.StepMeta)12 JobEntryCopy (org.pentaho.di.job.entry.JobEntryCopy)9 KettleRepositoryLostException (org.pentaho.di.repository.KettleRepositoryLostException)8 XulException (org.pentaho.ui.xul.XulException)8 InvocationTargetException (java.lang.reflect.InvocationTargetException)6 ArrayList (java.util.ArrayList)6 KettleStepException (org.pentaho.di.core.exception.KettleStepException)6 KettleValueException (org.pentaho.di.core.exception.KettleValueException)6 SwingGC (org.pentaho.di.core.gui.SwingGC)6 BufferedImage (java.awt.image.BufferedImage)5 NotePadMeta (org.pentaho.di.core.NotePadMeta)5 TransHopMeta (org.pentaho.di.trans.TransHopMeta)5 EImage (org.pentaho.di.core.gui.PrimitiveGCInterface.EImage)4 ScrollBarInterface (org.pentaho.di.core.gui.ScrollBarInterface)4 JobHopMeta (org.pentaho.di.job.JobHopMeta)4 TransMeta (org.pentaho.di.trans.TransMeta)4