Search in sources :

Example 6 with Point

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

the class SpoonTransformationDelegate method redoTransformationAction.

public void redoTransformationAction(TransMeta transMeta, TransAction transAction) {
    switch(transAction.getType()) {
        case TransAction.TYPE_ACTION_NEW_STEP:
            // re-delete the step at correct location:
            for (int i = 0; i < transAction.getCurrent().length; i++) {
                StepMeta stepMeta = (StepMeta) transAction.getCurrent()[i];
                int idx = transAction.getCurrentIndex()[i];
                transMeta.addStep(idx, stepMeta);
                spoon.refreshTree();
                spoon.refreshGraph();
            }
            break;
        case TransAction.TYPE_ACTION_NEW_CONNECTION:
            // re-insert the connection at correct location:
            for (int i = 0; i < transAction.getCurrent().length; i++) {
                DatabaseMeta ci = (DatabaseMeta) transAction.getCurrent()[i];
                int idx = transAction.getCurrentIndex()[i];
                transMeta.addDatabase(idx, ci);
                spoon.refreshTree();
                spoon.refreshGraph();
            }
            break;
        case TransAction.TYPE_ACTION_NEW_NOTE:
            // re-insert the note at correct location:
            for (int i = 0; i < transAction.getCurrent().length; i++) {
                NotePadMeta ni = (NotePadMeta) transAction.getCurrent()[i];
                int idx = transAction.getCurrentIndex()[i];
                transMeta.addNote(idx, ni);
                spoon.refreshTree();
                spoon.refreshGraph();
            }
            break;
        case TransAction.TYPE_ACTION_NEW_HOP:
            // re-insert the hop at correct location:
            for (int i = 0; i < transAction.getCurrent().length; i++) {
                TransHopMeta hi = (TransHopMeta) transAction.getCurrent()[i];
                int idx = transAction.getCurrentIndex()[i];
                transMeta.addTransHop(idx, hi);
                spoon.refreshTree();
                spoon.refreshGraph();
            }
            break;
        // 
        case TransAction.TYPE_ACTION_DELETE_STEP:
            // re-remove the step at correct location:
            for (int i = transAction.getCurrent().length - 1; i >= 0; i--) {
                int idx = transAction.getCurrentIndex()[i];
                transMeta.removeStep(idx);
            }
            spoon.refreshTree();
            spoon.refreshGraph();
            break;
        case TransAction.TYPE_ACTION_DELETE_CONNECTION:
            // re-remove the connection at correct location:
            for (int i = transAction.getCurrent().length - 1; i >= 0; i--) {
                int idx = transAction.getCurrentIndex()[i];
                transMeta.removeDatabase(idx);
            }
            spoon.refreshTree();
            spoon.refreshGraph();
            break;
        case TransAction.TYPE_ACTION_DELETE_NOTE:
            // re-remove the note at correct location:
            for (int i = transAction.getCurrent().length - 1; i >= 0; i--) {
                int idx = transAction.getCurrentIndex()[i];
                transMeta.removeNote(idx);
            }
            spoon.refreshTree();
            spoon.refreshGraph();
            break;
        case TransAction.TYPE_ACTION_DELETE_HOP:
            // re-remove the hop at correct location:
            for (int i = transAction.getCurrent().length - 1; i >= 0; i--) {
                int idx = transAction.getCurrentIndex()[i];
                transMeta.removeTransHop(idx);
            }
            spoon.refreshTree();
            spoon.refreshGraph();
            break;
        // We changed a step : undo this...
        case TransAction.TYPE_ACTION_CHANGE_STEP:
            // Delete the current step, insert previous version.
            for (int i = 0; i < transAction.getCurrent().length; i++) {
                StepMeta stepMeta = (StepMeta) ((StepMeta) transAction.getCurrent()[i]).clone();
                transMeta.getStep(transAction.getCurrentIndex()[i]).replaceMeta(stepMeta);
            }
            spoon.refreshTree();
            spoon.refreshGraph();
            break;
        // We changed a connection : undo this...
        case TransAction.TYPE_ACTION_CHANGE_CONNECTION:
            // Delete & re-insert
            for (int i = 0; i < transAction.getCurrent().length; i++) {
                DatabaseMeta databaseMeta = (DatabaseMeta) transAction.getCurrent()[i];
                int idx = transAction.getCurrentIndex()[i];
                transMeta.getDatabase(idx).replaceMeta((DatabaseMeta) databaseMeta.clone());
            }
            spoon.refreshTree();
            spoon.refreshGraph();
            break;
        // We changed a note : undo this...
        case TransAction.TYPE_ACTION_CHANGE_NOTE:
            // Delete & re-insert
            for (int i = 0; i < transAction.getCurrent().length; i++) {
                NotePadMeta ni = (NotePadMeta) transAction.getCurrent()[i];
                int idx = transAction.getCurrentIndex()[i];
                transMeta.removeNote(idx);
                transMeta.addNote(idx, (NotePadMeta) ni.clone());
            }
            spoon.refreshTree();
            spoon.refreshGraph();
            break;
        // We changed a hop : undo this...
        case TransAction.TYPE_ACTION_CHANGE_HOP:
            // Delete & re-insert
            for (int i = 0; i < transAction.getCurrent().length; i++) {
                TransHopMeta hi = (TransHopMeta) transAction.getCurrent()[i];
                int idx = transAction.getCurrentIndex()[i];
                transMeta.removeTransHop(idx);
                transMeta.addTransHop(idx, (TransHopMeta) hi.clone());
            }
            spoon.refreshTree();
            spoon.refreshGraph();
            break;
        // 
        case TransAction.TYPE_ACTION_POSITION_STEP:
            for (int i = 0; i < transAction.getCurrentIndex().length; i++) {
                // Find & change the location of the step:
                StepMeta stepMeta = transMeta.getStep(transAction.getCurrentIndex()[i]);
                stepMeta.setLocation(transAction.getCurrentLocation()[i]);
            }
            spoon.refreshGraph();
            break;
        case TransAction.TYPE_ACTION_POSITION_NOTE:
            for (int i = 0; i < transAction.getCurrentIndex().length; i++) {
                int idx = transAction.getCurrentIndex()[i];
                NotePadMeta npi = transMeta.getNote(idx);
                Point curr = transAction.getCurrentLocation()[i];
                npi.setLocation(curr);
            }
            spoon.refreshGraph();
            break;
        default:
            break;
    }
    // OK, now check if we need to do this again...
    if (transMeta.viewNextUndo() != null) {
        if (transMeta.viewNextUndo().getNextAlso()) {
            spoon.redoAction(transMeta);
        }
    }
}
Also used : NotePadMeta(org.pentaho.di.core.NotePadMeta) TransHopMeta(org.pentaho.di.trans.TransHopMeta) Point(org.pentaho.di.core.gui.Point) KettleExtensionPoint(org.pentaho.di.core.extension.KettleExtensionPoint) StepMeta(org.pentaho.di.trans.step.StepMeta) DatabaseMeta(org.pentaho.di.core.database.DatabaseMeta) Point(org.pentaho.di.core.gui.Point) KettleExtensionPoint(org.pentaho.di.core.extension.KettleExtensionPoint)

Example 7 with Point

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

the class JobGraph method paintControl.

public void paintControl(PaintEvent e) {
    Point area = getArea();
    if (area.x == 0 || area.y == 0) {
        // nothing to do!
        return;
    }
    Display disp = shell.getDisplay();
    Image img = getJobImage(disp, area.x, area.y, magnification);
    e.gc.drawImage(img, 0, 0);
    if (jobMeta.nrJobEntries() == 0) {
        e.gc.setForeground(GUIResource.getInstance().getColorCrystalTextPentaho());
        e.gc.setBackground(GUIResource.getInstance().getColorBackground());
        e.gc.setFont(GUIResource.getInstance().getFontMedium());
        Image pentahoImage = GUIResource.getInstance().getImageJobCanvas();
        int leftPosition = (area.x - pentahoImage.getBounds().width) / 2;
        int topPosition = (area.y - pentahoImage.getBounds().height) / 2;
        e.gc.drawImage(pentahoImage, leftPosition, topPosition);
    }
    img.dispose();
}
Also used : Point(org.pentaho.di.core.gui.Point) KettleExtensionPoint(org.pentaho.di.core.extension.KettleExtensionPoint) Image(org.eclipse.swt.graphics.Image) Point(org.pentaho.di.core.gui.Point) KettleExtensionPoint(org.pentaho.di.core.extension.KettleExtensionPoint) Display(org.eclipse.swt.widgets.Display)

Example 8 with Point

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

the class JobGraph method getRealPosition.

public Point getRealPosition(Composite canvas, int x, int y) {
    Point p = new Point(0, 0);
    Composite follow = canvas;
    while (follow != null) {
        Point xy = new Point(follow.getLocation().x, follow.getLocation().y);
        p.x += xy.x;
        p.y += xy.y;
        follow = follow.getParent();
    }
    p.x = x - p.x - 8;
    p.y = y - p.y - 48;
    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)

Example 9 with Point

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

the class JobGraph method drawRect.

protected void drawRect(GC gc, Rectangle rect) {
    if (rect == null) {
        return;
    }
    gc.setLineStyle(SWT.LINE_DASHDOT);
    gc.setLineWidth(1);
    gc.setForeground(GUIResource.getInstance().getColorDarkGray());
    // PDI-2619: SWT on Windows doesn't cater for negative rect.width/height so handle here.
    Point s = new Point(rect.x + offset.x, rect.y + offset.y);
    if (rect.width < 0) {
        s.x = s.x + rect.width;
    }
    if (rect.height < 0) {
        s.y = s.y + rect.height;
    }
    gc.drawRoundRectangle(s.x, s.y, Math.abs(rect.width), Math.abs(rect.height), 3, 3);
    gc.setLineStyle(SWT.LINE_SOLID);
}
Also used : Point(org.pentaho.di.core.gui.Point) KettleExtensionPoint(org.pentaho.di.core.extension.KettleExtensionPoint)

Example 10 with Point

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

the class JobGraph method pasteNote.

public void pasteNote() {
    final String clipcontent = spoon.fromClipboard();
    Point loc = new Point(currentMouseX, currentMouseY);
    spoon.pasteXML(jobMeta, clipcontent, loc);
}
Also used : Point(org.pentaho.di.core.gui.Point) KettleExtensionPoint(org.pentaho.di.core.extension.KettleExtensionPoint)

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