Search in sources :

Example 21 with AreaOwner

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

the class JobGraph method mouseUp.

public void mouseUp(MouseEvent e) {
    boolean control = (e.stateMask & SWT.MOD1) != 0;
    if (iconoffset == null) {
        iconoffset = new Point(0, 0);
    }
    Point real = screen2real(e.x, e.y);
    Point icon = new Point(real.x - iconoffset.x, real.y - iconoffset.y);
    // 
    if (hop_candidate != null) {
        addCandidateAsHop();
        redraw();
    } else {
        // 
        if (selectionRegion != null) {
            selectionRegion.width = real.x - selectionRegion.x;
            selectionRegion.height = real.y - selectionRegion.y;
            jobMeta.unselectAll();
            selectInRect(jobMeta, selectionRegion);
            selectionRegion = null;
            stopEntryMouseOverDelayTimers();
            redraw();
        } else {
            // 
            if (selectedEntry != null && startHopEntry == null) {
                if (e.button == 1) {
                    Point realclick = screen2real(e.x, e.y);
                    if (lastclick.x == realclick.x && lastclick.y == realclick.y) {
                        // Flip selection when control is pressed!
                        if (control) {
                            selectedEntry.flipSelected();
                        } else {
                            // Otherwise, select only the icon clicked on!
                            jobMeta.unselectAll();
                            selectedEntry.setSelected(true);
                        }
                    } else {
                        // Find out which Steps & Notes are selected
                        selectedEntries = jobMeta.getSelectedEntries();
                        selectedNotes = jobMeta.getSelectedNotes();
                        // We moved around some items: store undo info...
                        // 
                        boolean also = false;
                        if (selectedNotes != null && selectedNotes.size() > 0 && previous_note_locations != null) {
                            int[] indexes = jobMeta.getNoteIndexes(selectedNotes);
                            addUndoPosition(selectedNotes.toArray(new NotePadMeta[selectedNotes.size()]), indexes, previous_note_locations, jobMeta.getSelectedNoteLocations(), also);
                            also = selectedEntries != null && selectedEntries.size() > 0;
                        }
                        if (selectedEntries != null && selectedEntries.size() > 0 && previous_step_locations != null) {
                            int[] indexes = jobMeta.getEntryIndexes(selectedEntries);
                            addUndoPosition(selectedEntries.toArray(new JobEntryCopy[selectedEntries.size()]), indexes, previous_step_locations, jobMeta.getSelectedLocations(), also);
                        }
                    }
                }
                // If so, ask to split the hop!
                if (split_hop) {
                    JobHopMeta hi = findHop(icon.x + iconsize / 2, icon.y + iconsize / 2, selectedEntry);
                    if (hi != null) {
                        int id = 0;
                        if (!spoon.props.getAutoSplit()) {
                            MessageDialogWithToggle md = new MessageDialogWithToggle(shell, BaseMessages.getString(PKG, "TransGraph.Dialog.SplitHop.Title"), null, BaseMessages.getString(PKG, "TransGraph.Dialog.SplitHop.Message") + Const.CR + hi.toString(), MessageDialog.QUESTION, new String[] { BaseMessages.getString(PKG, "System.Button.Yes"), BaseMessages.getString(PKG, "System.Button.No") }, 0, BaseMessages.getString(PKG, "TransGraph.Dialog.Option.SplitHop.DoNotAskAgain"), spoon.props.getAutoSplit());
                            MessageDialogWithToggle.setDefaultImage(GUIResource.getInstance().getImageSpoon());
                            id = md.open();
                            spoon.props.setAutoSplit(md.getToggleState());
                        }
                        if ((id & 0xFF) == 0) {
                            // 
                            if (jobMeta.findJobHop(selectedEntry, hi.getFromEntry()) == null && jobMeta.findJobHop(hi.getToEntry(), selectedEntry) == null) {
                                if (jobMeta.findJobHop(hi.getFromEntry(), selectedEntry, true) == null) {
                                    JobHopMeta newhop1 = new JobHopMeta(hi.getFromEntry(), selectedEntry);
                                    if (hi.getFromEntry().getEntry().isUnconditional()) {
                                        newhop1.setUnconditional();
                                    }
                                    jobMeta.addJobHop(newhop1);
                                    spoon.addUndoNew(jobMeta, new JobHopMeta[] { newhop1 }, new int[] { jobMeta.indexOfJobHop(newhop1) }, true);
                                }
                                if (jobMeta.findJobHop(selectedEntry, hi.getToEntry(), true) == null) {
                                    JobHopMeta newhop2 = new JobHopMeta(selectedEntry, hi.getToEntry());
                                    if (selectedEntry.getEntry().isUnconditional()) {
                                        newhop2.setUnconditional();
                                    }
                                    jobMeta.addJobHop(newhop2);
                                    spoon.addUndoNew(jobMeta, new JobHopMeta[] { newhop2 }, new int[] { jobMeta.indexOfJobHop(newhop2) }, true);
                                }
                                int idx = jobMeta.indexOfJobHop(hi);
                                spoon.addUndoDelete(jobMeta, new JobHopMeta[] { hi }, new int[] { idx }, true);
                                jobMeta.removeJobHop(idx);
                                spoon.refreshTree();
                            }
                        // else: Silently discard this hop-split attempt.
                        }
                    }
                    split_hop = false;
                }
                selectedEntries = null;
                selectedNotes = null;
                selectedEntry = null;
                selectedNote = null;
                startHopEntry = null;
                endHopLocation = null;
                redraw();
                spoon.setShellText();
            } else {
                // Notes?
                if (selectedNote != null) {
                    if (e.button == 1) {
                        if (lastclick.x == e.x && lastclick.y == e.y) {
                            // Flip selection when control is pressed!
                            if (control) {
                                selectedNote.flipSelected();
                            } else {
                                // Otherwise, select only the note clicked on!
                                jobMeta.unselectAll();
                                selectedNote.setSelected(true);
                            }
                        } else {
                            // Find out which Steps & Notes are selected
                            selectedEntries = jobMeta.getSelectedEntries();
                            selectedNotes = jobMeta.getSelectedNotes();
                            // We moved around some items: store undo info...
                            boolean also = false;
                            if (selectedNotes != null && selectedNotes.size() > 0 && previous_note_locations != null) {
                                int[] indexes = jobMeta.getNoteIndexes(selectedNotes);
                                addUndoPosition(selectedNotes.toArray(new NotePadMeta[selectedNotes.size()]), indexes, previous_note_locations, jobMeta.getSelectedNoteLocations(), also);
                                also = selectedEntries != null && selectedEntries.size() > 0;
                            }
                            if (selectedEntries != null && selectedEntries.size() > 0 && previous_step_locations != null) {
                                int[] indexes = jobMeta.getEntryIndexes(selectedEntries);
                                addUndoPosition(selectedEntries.toArray(new JobEntryCopy[selectedEntries.size()]), indexes, previous_step_locations, jobMeta.getSelectedLocations(), also);
                            }
                        }
                    }
                    selectedNotes = null;
                    selectedEntries = null;
                    selectedEntry = null;
                    selectedNote = null;
                    startHopEntry = null;
                    endHopLocation = null;
                } else {
                    AreaOwner areaOwner = getVisibleAreaOwner(real.x, real.y);
                    if (areaOwner == null && selectionRegion == null) {
                        // Hit absolutely nothing: clear the settings
                        // 
                        clearSettings();
                    }
                }
            }
        }
    }
    lastButton = 0;
}
Also used : JobEntryCopy(org.pentaho.di.job.entry.JobEntryCopy) JobHopMeta(org.pentaho.di.job.JobHopMeta) AreaOwner(org.pentaho.di.core.gui.AreaOwner) MessageDialogWithToggle(org.eclipse.jface.dialogs.MessageDialogWithToggle) Point(org.pentaho.di.core.gui.Point) KettleExtensionPoint(org.pentaho.di.core.extension.KettleExtensionPoint) NotePadMeta(org.pentaho.di.core.NotePadMeta) Point(org.pentaho.di.core.gui.Point) KettleExtensionPoint(org.pentaho.di.core.extension.KettleExtensionPoint)

Example 22 with AreaOwner

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

the class JobGraph method addEntryMouseOverDelayTimer.

private synchronized void addEntryMouseOverDelayTimer(final JobEntryCopy jobEntryCopy) {
    // 
    if (mouseOverEntries.contains(jobEntryCopy)) {
        return;
    }
    mouseOverEntries.add(jobEntryCopy);
    DelayTimer delayTimer = new DelayTimer(500, new DelayListener() {

        public void expired() {
            mouseOverEntries.remove(jobEntryCopy);
            delayTimers.remove(jobEntryCopy);
            asyncRedraw();
        }
    }, new Callable<Boolean>() {

        @Override
        public Boolean call() throws Exception {
            Point cursor = getLastMove();
            if (cursor != null) {
                AreaOwner areaOwner = getVisibleAreaOwner(cursor.x, cursor.y);
                if (areaOwner != null && areaOwner.getAreaType() != null) {
                    AreaType areaType = areaOwner.getAreaType();
                    if (areaType == AreaType.JOB_ENTRY_ICON || areaType.belongsToJobContextMenu()) {
                        JobEntryCopy selectedJobEntryCopy = (JobEntryCopy) areaOwner.getOwner();
                        return selectedJobEntryCopy == jobEntryCopy;
                    }
                }
            }
            return false;
        }
    });
    new Thread(delayTimer).start();
    delayTimers.put(jobEntryCopy, delayTimer);
}
Also used : JobEntryCopy(org.pentaho.di.job.entry.JobEntryCopy) AreaOwner(org.pentaho.di.core.gui.AreaOwner) DelayListener(org.pentaho.di.ui.spoon.trans.DelayListener) DelayTimer(org.pentaho.di.ui.spoon.trans.DelayTimer) Point(org.pentaho.di.core.gui.Point) KettleExtensionPoint(org.pentaho.di.core.extension.KettleExtensionPoint) AreaType(org.pentaho.di.core.gui.AreaOwner.AreaType) XulException(org.pentaho.ui.xul.XulException) KettleRepositoryLostException(org.pentaho.di.repository.KettleRepositoryLostException) KettleException(org.pentaho.di.core.exception.KettleException)

Example 23 with AreaOwner

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

the class JobInformation method drawImage.

public void drawImage(final Graphics2D g2d, final Rectangle2D rectangle2d, ReportSubjectLocation location, boolean pixelateImages) throws KettleException {
    // Load the job
    // 
    JobMeta jobMeta = loadJob(location);
    Point min = jobMeta.getMinimum();
    Point area = jobMeta.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);
    List<AreaOwner> areaOwners = new ArrayList<AreaOwner>();
    JobPainter painter = new JobPainter(gc, jobMeta, area, bar, bar, null, null, null, areaOwners, new ArrayList<JobEntryCopy>(), iconsize, 1, 0, 0, true, "FreeSans", 10);
    painter.setMagnification(magnification);
    painter.setTranslationX((-min.x) * magnification);
    painter.setTranslationY((-min.y) * magnification);
    painter.drawJob();
}
Also used : JobMeta(org.pentaho.di.job.JobMeta) JobPainter(org.pentaho.di.job.JobPainter) Rectangle(java.awt.Rectangle) ArrayList(java.util.ArrayList) Point(org.pentaho.di.core.gui.Point) SwingGC(org.pentaho.di.core.gui.SwingGC) Point(org.pentaho.di.core.gui.Point) ScrollBarInterface(org.pentaho.di.core.gui.ScrollBarInterface) JobEntryCopy(org.pentaho.di.job.entry.JobEntryCopy) AreaOwner(org.pentaho.di.core.gui.AreaOwner)

Example 24 with AreaOwner

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

the class TransformationInformation method loadValues.

private TransformationInformationValues loadValues(ReportSubjectLocation location) throws KettleException {
    // Load the transformation
    // 
    TransMeta transMeta = loadTransformation(location);
    Point min = transMeta.getMinimum();
    Point area = transMeta.getMaximum();
    area.x += 100;
    area.y += 100;
    int iconsize = 32;
    ScrollBarInterface bar = new ScrollBarInterface() {

        public void setThumb(int thumb) {
        }

        public int getSelection() {
            return 0;
        }
    };
    // Paint the transformation...
    // 
    GCInterface gc = new SwingGC(null, area, iconsize, 50, 20);
    List<AreaOwner> areaOwners = new ArrayList<AreaOwner>();
    TransPainter painter = new TransPainter(gc, transMeta, area, bar, bar, null, null, null, areaOwners, new ArrayList<StepMeta>(), iconsize, 1, 0, 0, true, "FreeSans", 10);
    painter.setMagnification(0.5f);
    painter.setTranslationX(min.x);
    painter.setTranslationY(min.y);
    painter.buildTransformationImage();
    BufferedImage bufferedImage = (BufferedImage) gc.getImage();
    int newWidth = bufferedImage.getWidth() - min.x;
    int newHeigth = bufferedImage.getHeight() - min.y;
    BufferedImage image = new BufferedImage(newWidth, newHeigth, bufferedImage.getType());
    image.getGraphics().drawImage(bufferedImage, 0, 0, newWidth, newHeigth, min.x, min.y, min.x + newWidth, min.y + newHeigth, null);
    TransformationInformationValues values = new TransformationInformationValues();
    values.transMeta = transMeta;
    values.image = image;
    values.areaOwners = areaOwners;
    return values;
}
Also used : TransMeta(org.pentaho.di.trans.TransMeta) ArrayList(java.util.ArrayList) 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) BufferedImage(java.awt.image.BufferedImage) GCInterface(org.pentaho.di.core.gui.GCInterface) AreaOwner(org.pentaho.di.core.gui.AreaOwner) TransPainter(org.pentaho.di.trans.TransPainter)

Example 25 with AreaOwner

use of org.pentaho.di.core.gui.AreaOwner in project pdi-dataservice-server-plugin by pentaho.

the class TransPainterStepExtensionPointPlugin method callExtensionPoint.

@Override
public void callExtensionPoint(LogChannelInterface log, Object object) throws KettleException {
    if (!(object instanceof TransPainterExtension)) {
        return;
    }
    TransPainterExtension extension = (TransPainterExtension) object;
    TransMeta transMeta = extension.transMeta;
    StepMeta stepMeta = extension.stepMeta;
    DataServiceMeta dataService = metaStoreUtil.getDataServiceByStepName(transMeta, stepMeta.getName());
    if (dataService != null && dataService.isUserDefined()) {
        // Is this step a data service provider?
        // 
        String image = dataService.isStreaming() ? "images/data-services-streaming.svg" : "images/data-services.svg";
        extension.gc.drawImage(image, getClass().getClassLoader(), extension.x1 - 13, extension.y1 - 8 + extension.iconsize);
        extension.areaOwners.add(new AreaOwner(AreaType.CUSTOM, extension.x1 - 13, extension.y1 - 8 + extension.iconsize, 16, 16, extension.offset, transMeta, stepMeta));
    }
}
Also used : AreaOwner(org.pentaho.di.core.gui.AreaOwner) TransPainterExtension(org.pentaho.di.trans.TransPainterExtension) TransMeta(org.pentaho.di.trans.TransMeta) StepMeta(org.pentaho.di.trans.step.StepMeta)

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