Search in sources :

Example 6 with NotePadMeta

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

the class JobGraph method selectInRect.

public void selectInRect(JobMeta jobMeta, org.pentaho.di.core.gui.Rectangle rect) {
    int i;
    for (i = 0; i < jobMeta.nrJobEntries(); i++) {
        JobEntryCopy je = jobMeta.getJobEntry(i);
        Point p = je.getLocation();
        if (((p.x >= rect.x && p.x <= rect.x + rect.width) || (p.x >= rect.x + rect.width && p.x <= rect.x)) && ((p.y >= rect.y && p.y <= rect.y + rect.height) || (p.y >= rect.y + rect.height && p.y <= rect.y))) {
            je.setSelected(true);
        }
    }
    for (i = 0; i < jobMeta.nrNotes(); i++) {
        NotePadMeta ni = jobMeta.getNote(i);
        Point a = ni.getLocation();
        Point b = new Point(a.x + ni.width, a.y + ni.height);
        if (rect.contains(a.x, a.y) && rect.contains(b.x, b.y)) {
            ni.setSelected(true);
        }
    }
}
Also used : JobEntryCopy(org.pentaho.di.job.entry.JobEntryCopy) 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 7 with NotePadMeta

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

the class TransGraph method newNote.

public void newNote() {
    selectionRegion = null;
    String title = BaseMessages.getString(PKG, "TransGraph.Dialog.NoteEditor.Title");
    NotePadDialog dd = new NotePadDialog(transMeta, shell, title);
    NotePadMeta n = dd.open();
    if (n != null) {
        NotePadMeta npi = new NotePadMeta(n.getNote(), lastclick.x, lastclick.y, ConstUI.NOTE_MIN_SIZE, ConstUI.NOTE_MIN_SIZE, n.getFontName(), n.getFontSize(), n.isFontBold(), n.isFontItalic(), n.getFontColorRed(), n.getFontColorGreen(), n.getFontColorBlue(), n.getBackGroundColorRed(), n.getBackGroundColorGreen(), n.getBackGroundColorBlue(), n.getBorderColorRed(), n.getBorderColorGreen(), n.getBorderColorBlue(), n.isDrawShadow());
        transMeta.addNote(npi);
        spoon.addUndoNew(transMeta, new NotePadMeta[] { npi }, new int[] { transMeta.indexOfNote(npi) });
        redraw();
    }
}
Also used : NotePadDialog(org.pentaho.di.ui.spoon.dialog.NotePadDialog) NotePadMeta(org.pentaho.di.core.NotePadMeta)

Example 8 with NotePadMeta

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

the class TransGraph method mouseUp.

@Override
public void mouseUp(MouseEvent e) {
    try {
        TransGraphExtension ext = new TransGraphExtension(null, e, getArea());
        ExtensionPointHandler.callExtensionPoint(LogChannel.GENERAL, KettleExtensionPoint.TransGraphMouseUp.id, ext);
        if (ext.isPreventDefault()) {
            redraw();
            clearSettings();
            return;
        }
    } catch (Exception ex) {
        LogChannel.GENERAL.logError("Error calling TransGraphMouseUp extension point", ex);
    }
    boolean control = (e.stateMask & SWT.MOD1) != 0;
    TransHopMeta selectedHop = findHop(e.x, e.y);
    updateErrorMetaForHop(selectedHop);
    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);
    AreaOwner areaOwner = getVisibleAreaOwner(real.x, real.y);
    try {
        TransGraphExtension ext = new TransGraphExtension(this, e, real);
        ExtensionPointHandler.callExtensionPoint(LogChannel.GENERAL, KettleExtensionPoint.TransGraphMouseUp.id, ext);
        if (ext.isPreventDefault()) {
            redraw();
            clearSettings();
            return;
        }
    } catch (Exception ex) {
        LogChannel.GENERAL.logError("Error calling TransGraphMouseUp extension point", ex);
    }
    // 
    if (candidate != null && areaOwner != null && areaOwner.getAreaType() != null) {
        switch(areaOwner.getAreaType()) {
            case STEP_ICON:
                currentStep = (StepMeta) areaOwner.getOwner();
                break;
            case STEP_INPUT_HOP_ICON:
                currentStep = (StepMeta) areaOwner.getParent();
                break;
            default:
                break;
        }
        addCandidateAsHop(e.x, e.y);
        redraw();
    } else {
        // 
        if (selectionRegion != null) {
            selectionRegion.width = real.x - selectionRegion.x;
            selectionRegion.height = real.y - selectionRegion.y;
            transMeta.unselectAll();
            selectInRect(transMeta, selectionRegion);
            selectionRegion = null;
            stopStepMouseOverDelayTimers();
            redraw();
        } else {
            // 
            if (selectedStep != null && startHopStep == 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) {
                            selectedStep.flipSelected();
                        } else {
                            // Otherwise, select only the icon clicked on!
                            transMeta.unselectAll();
                            selectedStep.setSelected(true);
                        }
                    } else {
                        // Find out which Steps & Notes are selected
                        selectedSteps = transMeta.getSelectedSteps();
                        selectedNotes = transMeta.getSelectedNotes();
                        // We moved around some items: store undo info...
                        // 
                        boolean also = false;
                        if (selectedNotes != null && selectedNotes.size() > 0 && previous_note_locations != null) {
                            int[] indexes = transMeta.getNoteIndexes(selectedNotes);
                            addUndoPosition(selectedNotes.toArray(new NotePadMeta[selectedNotes.size()]), indexes, previous_note_locations, transMeta.getSelectedNoteLocations(), also);
                            also = selectedSteps != null && selectedSteps.size() > 0;
                        }
                        if (selectedSteps != null && previous_step_locations != null) {
                            int[] indexes = transMeta.getStepIndexes(selectedSteps);
                            addUndoPosition(selectedSteps.toArray(new StepMeta[selectedSteps.size()]), indexes, previous_step_locations, transMeta.getSelectedStepLocations(), also);
                        }
                    }
                }
                // If so, ask to split the hop!
                if (split_hop) {
                    TransHopMeta hi = findHop(icon.x + iconsize / 2, icon.y + iconsize / 2, selectedStep);
                    if (hi != null) {
                        splitHop(hi);
                    }
                    split_hop = false;
                }
                selectedSteps = null;
                selectedNotes = null;
                selectedStep = null;
                selectedNote = null;
                startHopStep = null;
                endHopLocation = null;
                redraw();
                spoon.setShellText();
            } else {
                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!
                                transMeta.unselectAll();
                                selectedNote.setSelected(true);
                            }
                        } else {
                            // Find out which Steps & Notes are selected
                            selectedSteps = transMeta.getSelectedSteps();
                            selectedNotes = transMeta.getSelectedNotes();
                            // We moved around some items: store undo info...
                            boolean also = false;
                            if (selectedNotes != null && selectedNotes.size() > 0 && previous_note_locations != null) {
                                int[] indexes = transMeta.getNoteIndexes(selectedNotes);
                                addUndoPosition(selectedNotes.toArray(new NotePadMeta[selectedNotes.size()]), indexes, previous_note_locations, transMeta.getSelectedNoteLocations(), also);
                                also = selectedSteps != null && selectedSteps.size() > 0;
                            }
                            if (selectedSteps != null && selectedSteps.size() > 0 && previous_step_locations != null) {
                                int[] indexes = transMeta.getStepIndexes(selectedSteps);
                                addUndoPosition(selectedSteps.toArray(new StepMeta[selectedSteps.size()]), indexes, previous_step_locations, transMeta.getSelectedStepLocations(), also);
                            }
                        }
                    }
                    selectedNotes = null;
                    selectedSteps = null;
                    selectedStep = null;
                    selectedNote = null;
                    startHopStep = null;
                    endHopLocation = null;
                } else {
                    if (areaOwner == null && selectionRegion == null) {
                        // Hit absolutely nothing: clear the settings
                        // 
                        clearSettings();
                    }
                }
            }
        }
    }
    lastButton = 0;
}
Also used : AreaOwner(org.pentaho.di.core.gui.AreaOwner) TransHopMeta(org.pentaho.di.trans.TransHopMeta) Point(org.pentaho.di.core.gui.Point) KettleExtensionPoint(org.pentaho.di.core.extension.KettleExtensionPoint) NotePadMeta(org.pentaho.di.core.NotePadMeta) 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)

Example 9 with NotePadMeta

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

the class TransGraph method mouseMove.

@Override
public void mouseMove(MouseEvent e) {
    boolean shift = (e.stateMask & SWT.SHIFT) != 0;
    noInputStep = null;
    // disable the tooltip
    // 
    toolTip.hide();
    Point real = screen2real(e.x, e.y);
    // Remember the last position of the mouse for paste with keyboard
    // 
    lastMove = real;
    if (iconoffset == null) {
        iconoffset = new Point(0, 0);
    }
    Point icon = new Point(real.x - iconoffset.x, real.y - iconoffset.y);
    if (noteoffset == null) {
        noteoffset = new Point(0, 0);
    }
    Point note = new Point(real.x - noteoffset.x, real.y - noteoffset.y);
    // Moved over an area?
    // 
    AreaOwner areaOwner = getVisibleAreaOwner(real.x, real.y);
    if (areaOwner != null && areaOwner.getAreaType() != null) {
        switch(areaOwner.getAreaType()) {
            case STEP_ICON:
                StepMeta stepMeta = (StepMeta) areaOwner.getOwner();
                resetDelayTimer(stepMeta);
                break;
            case // Give the timer a bit more time
            MINI_ICONS_BALLOON:
                stepMeta = (StepMeta) areaOwner.getParent();
                resetDelayTimer(stepMeta);
                break;
            default:
                break;
        }
    }
    try {
        TransGraphExtension ext = new TransGraphExtension(this, e, real);
        ExtensionPointHandler.callExtensionPoint(LogChannel.GENERAL, KettleExtensionPoint.TransGraphMouseMoved.id, ext);
    } catch (Exception ex) {
        LogChannel.GENERAL.logError("Error calling TransGraphMouseMoved extension point", ex);
    }
    // 
    if (selectedStep != null && !selectedStep.isSelected()) {
        transMeta.unselectAll();
        selectedStep.setSelected(true);
        selectedSteps = new ArrayList<>();
        selectedSteps.add(selectedStep);
        previous_step_locations = new Point[] { selectedStep.getLocation() };
        redraw();
    } else if (selectedNote != null && !selectedNote.isSelected()) {
        transMeta.unselectAll();
        selectedNote.setSelected(true);
        selectedNotes = new ArrayList<>();
        selectedNotes.add(selectedNote);
        previous_note_locations = new Point[] { selectedNote.getLocation() };
        redraw();
    } else if (selectionRegion != null && startHopStep == null) {
        // Did we select a region...?
        // 
        selectionRegion.width = real.x - selectionRegion.x;
        selectionRegion.height = real.y - selectionRegion.y;
        redraw();
    } else if (selectedStep != null && lastButton == 1 && !shift && startHopStep == null) {
        // 
        // One or more icons are selected and moved around...
        // 
        // new : new position of the ICON (not the mouse pointer) dx : difference with previous position
        // 
        int dx = icon.x - selectedStep.getLocation().x;
        int dy = icon.y - selectedStep.getLocation().y;
        // See if we have a hop-split candidate
        // 
        TransHopMeta hi = findHop(icon.x + iconsize / 2, icon.y + iconsize / 2, selectedStep);
        if (hi != null) {
            // 
            if (!hi.getFromStep().equals(selectedStep) && !hi.getToStep().equals(selectedStep)) {
                split_hop = true;
                last_hop_split = hi;
                hi.split = true;
            }
        } else {
            if (last_hop_split != null) {
                last_hop_split.split = false;
                last_hop_split = null;
                split_hop = false;
            }
        }
        selectedNotes = transMeta.getSelectedNotes();
        selectedSteps = transMeta.getSelectedSteps();
        // Adjust location of selected steps...
        if (selectedSteps != null) {
            for (int i = 0; i < selectedSteps.size(); i++) {
                StepMeta stepMeta = selectedSteps.get(i);
                PropsUI.setLocation(stepMeta, stepMeta.getLocation().x + dx, stepMeta.getLocation().y + dy);
                stopStepMouseOverDelayTimer(stepMeta);
            }
        }
        // Adjust location of selected hops...
        if (selectedNotes != null) {
            for (int i = 0; i < selectedNotes.size(); i++) {
                NotePadMeta ni = selectedNotes.get(i);
                PropsUI.setLocation(ni, ni.getLocation().x + dx, ni.getLocation().y + dy);
            }
        }
        redraw();
    } else if ((startHopStep != null && endHopStep == null) || (endHopStep != null && startHopStep == null)) {
        // Are we creating a new hop with the middle button or pressing SHIFT?
        // 
        StepMeta stepMeta = transMeta.getStep(real.x, real.y, iconsize);
        endHopLocation = new Point(real.x, real.y);
        if (stepMeta != null && ((startHopStep != null && !startHopStep.equals(stepMeta)) || (endHopStep != null && !endHopStep.equals(stepMeta)))) {
            StepIOMetaInterface ioMeta = stepMeta.getStepMetaInterface().getStepIOMeta();
            if (candidate == null) {
                // 
                if (startHopStep != null) {
                    if (ioMeta.isInputAcceptor()) {
                        candidate = new TransHopMeta(startHopStep, stepMeta);
                        endHopLocation = null;
                    } else {
                        noInputStep = stepMeta;
                        toolTip.setImage(null);
                        toolTip.setText("This step does not accept any input from other steps");
                        toolTip.show(new org.eclipse.swt.graphics.Point(real.x, real.y));
                    }
                } else if (endHopStep != null) {
                    if (ioMeta.isOutputProducer()) {
                        candidate = new TransHopMeta(stepMeta, endHopStep);
                        endHopLocation = null;
                    } else {
                        noInputStep = stepMeta;
                        toolTip.setImage(null);
                        toolTip.setText("This step doesn't pass any output to other steps. (except perhaps for targetted output)");
                        toolTip.show(new org.eclipse.swt.graphics.Point(real.x, real.y));
                    }
                }
            }
        } else {
            if (candidate != null) {
                candidate = null;
                redraw();
            }
        }
        redraw();
    }
    // 
    if (selectedNote != null) {
        if (lastButton == 1 && !shift) {
            /*
         * One or more notes are selected and moved around...
         *
         * new : new position of the note (not the mouse pointer) dx : difference with previous position
         */
            int dx = note.x - selectedNote.getLocation().x;
            int dy = note.y - selectedNote.getLocation().y;
            selectedNotes = transMeta.getSelectedNotes();
            selectedSteps = transMeta.getSelectedSteps();
            // Adjust location of selected steps...
            if (selectedSteps != null) {
                for (int i = 0; i < selectedSteps.size(); i++) {
                    StepMeta stepMeta = selectedSteps.get(i);
                    PropsUI.setLocation(stepMeta, stepMeta.getLocation().x + dx, stepMeta.getLocation().y + dy);
                }
            }
            // Adjust location of selected hops...
            if (selectedNotes != null) {
                for (int i = 0; i < selectedNotes.size(); i++) {
                    NotePadMeta ni = selectedNotes.get(i);
                    PropsUI.setLocation(ni, ni.getLocation().x + dx, ni.getLocation().y + dy);
                }
            }
            redraw();
        }
    }
}
Also used : ArrayList(java.util.ArrayList) StepIOMetaInterface(org.pentaho.di.trans.step.StepIOMetaInterface) 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) Point(org.pentaho.di.core.gui.Point) KettleExtensionPoint(org.pentaho.di.core.extension.KettleExtensionPoint) AreaOwner(org.pentaho.di.core.gui.AreaOwner) TransHopMeta(org.pentaho.di.trans.TransHopMeta) NotePadMeta(org.pentaho.di.core.NotePadMeta)

Example 10 with NotePadMeta

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

the class JobMeta method getMaximum.

/**
 * Gets the maximum.
 *
 * @return the maximum
 */
public Point getMaximum() {
    int maxx = 0, maxy = 0;
    for (int i = 0; i < nrJobEntries(); i++) {
        JobEntryCopy entry = getJobEntry(i);
        Point loc = entry.getLocation();
        if (loc.x > maxx) {
            maxx = loc.x;
        }
        if (loc.y > maxy) {
            maxy = loc.y;
        }
    }
    for (int i = 0; i < nrNotes(); i++) {
        NotePadMeta ni = getNote(i);
        Point loc = ni.getLocation();
        if (loc.x + ni.width > maxx) {
            maxx = loc.x + ni.width;
        }
        if (loc.y + ni.height > maxy) {
            maxy = loc.y + ni.height;
        }
    }
    return new Point(maxx + 100, maxy + 100);
}
Also used : JobEntryCopy(org.pentaho.di.job.entry.JobEntryCopy) 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)

Aggregations

NotePadMeta (org.pentaho.di.core.NotePadMeta)63 Point (org.pentaho.di.core.gui.Point)39 KettleExtensionPoint (org.pentaho.di.core.extension.KettleExtensionPoint)34 StepMeta (org.pentaho.di.trans.step.StepMeta)26 KettleException (org.pentaho.di.core.exception.KettleException)25 JobEntryCopy (org.pentaho.di.job.entry.JobEntryCopy)23 DatabaseMeta (org.pentaho.di.core.database.DatabaseMeta)15 TransHopMeta (org.pentaho.di.trans.TransHopMeta)14 JobHopMeta (org.pentaho.di.job.JobHopMeta)11 ArrayList (java.util.ArrayList)10 KettleDatabaseException (org.pentaho.di.core.exception.KettleDatabaseException)10 SlaveServer (org.pentaho.di.cluster.SlaveServer)9 KettleStepException (org.pentaho.di.core.exception.KettleStepException)8 StepMetaInterface (org.pentaho.di.trans.step.StepMetaInterface)8 KettleRepositoryLostException (org.pentaho.di.repository.KettleRepositoryLostException)7 TransMeta (org.pentaho.di.trans.TransMeta)7 FileSystemException (org.apache.commons.vfs2.FileSystemException)6 KettleFileException (org.pentaho.di.core.exception.KettleFileException)6 KettleXMLException (org.pentaho.di.core.exception.KettleXMLException)6 StepErrorMeta (org.pentaho.di.trans.step.StepErrorMeta)6