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);
}
}
}
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();
}
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);
}
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);
}
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);
}
Aggregations