use of org.pentaho.di.core.NotePadMeta in project pentaho-kettle by pentaho.
the class SpoonTransformationDelegate method undoTransformationAction.
public void undoTransformationAction(TransMeta transMeta, TransAction transAction) {
switch(transAction.getType()) {
// We created a new step : undo this...
case TransAction.TYPE_ACTION_NEW_STEP:
// Delete 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;
// We created a new connection : undo this...
case TransAction.TYPE_ACTION_NEW_CONNECTION:
// Delete 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;
// We created a new note : undo this...
case TransAction.TYPE_ACTION_NEW_NOTE:
// Delete 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;
// We created a new hop : undo this...
case TransAction.TYPE_ACTION_NEW_HOP:
// Delete 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 created a new slave : undo this...
case TransAction.TYPE_ACTION_NEW_SLAVE:
// Delete the slave at correct location:
for (int i = transAction.getCurrent().length - 1; i >= 0; i--) {
int idx = transAction.getCurrentIndex()[i];
transMeta.getSlaveServers().remove(idx);
}
spoon.refreshTree();
spoon.refreshGraph();
break;
// We created a new slave : undo this...
case TransAction.TYPE_ACTION_NEW_CLUSTER:
// Delete the slave at correct location:
for (int i = transAction.getCurrent().length - 1; i >= 0; i--) {
int idx = transAction.getCurrentIndex()[i];
transMeta.getClusterSchemas().remove(idx);
}
spoon.refreshTree();
spoon.refreshGraph();
break;
// We delete a step : undo this...
case TransAction.TYPE_ACTION_DELETE_STEP:
// un-Delete the step at correct location: re-insert
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;
// We deleted a connection : undo this...
case TransAction.TYPE_ACTION_DELETE_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;
// We delete new note : undo this...
case TransAction.TYPE_ACTION_DELETE_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;
// We deleted a hop : undo this...
case TransAction.TYPE_ACTION_DELETE_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];
// Build a new hop:
StepMeta from = transMeta.findStep(hi.getFromStep().getName());
StepMeta to = transMeta.findStep(hi.getToStep().getName());
TransHopMeta hinew = new TransHopMeta(from, to);
transMeta.addTransHop(idx, hinew);
}
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 prev = (StepMeta) ((StepMeta) transAction.getPrevious()[i]).clone();
int idx = transAction.getCurrentIndex()[i];
transMeta.getStep(idx).replaceMeta(prev);
}
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 prev = (DatabaseMeta) transAction.getPrevious()[i];
int idx = transAction.getCurrentIndex()[i];
transMeta.getDatabase(idx).replaceMeta((DatabaseMeta) prev.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++) {
int idx = transAction.getCurrentIndex()[i];
transMeta.removeNote(idx);
NotePadMeta prev = (NotePadMeta) transAction.getPrevious()[i];
transMeta.addNote(idx, (NotePadMeta) prev.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 prev = (TransHopMeta) transAction.getPrevious()[i];
int idx = transAction.getCurrentIndex()[i];
transMeta.removeTransHop(idx);
transMeta.addTransHop(idx, (TransHopMeta) prev.clone());
}
spoon.refreshTree();
spoon.refreshGraph();
break;
// The position of a step has changed: undo this...
case TransAction.TYPE_ACTION_POSITION_STEP:
// Find the location of the step:
for (int i = 0; i < transAction.getCurrentIndex().length; i++) {
StepMeta stepMeta = transMeta.getStep(transAction.getCurrentIndex()[i]);
stepMeta.setLocation(transAction.getPreviousLocation()[i]);
}
spoon.refreshGraph();
break;
// The position of a note has changed: undo this...
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 prev = transAction.getPreviousLocation()[i];
npi.setLocation(prev);
}
spoon.refreshGraph();
break;
default:
break;
}
// OK, now check if we need to do this again...
if (transMeta.viewNextUndo() != null) {
if (transMeta.viewNextUndo().getNextAlso()) {
spoon.undoAction(transMeta);
}
}
}
use of org.pentaho.di.core.NotePadMeta in project pentaho-kettle by pentaho.
the class JobGraph method mouseMove.
public void mouseMove(MouseEvent e) {
boolean shift = (e.stateMask & SWT.SHIFT) != 0;
noInputEntry = 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) {
JobEntryCopy jobEntryCopy = null;
switch(areaOwner.getAreaType()) {
case JOB_ENTRY_ICON:
jobEntryCopy = (JobEntryCopy) areaOwner.getOwner();
resetDelayTimer(jobEntryCopy);
break;
case // Give the timer a bit more time
MINI_ICONS_BALLOON:
jobEntryCopy = (JobEntryCopy) areaOwner.getOwner();
resetDelayTimer(jobEntryCopy);
break;
default:
break;
}
}
//
if (selectedEntry != null && !selectedEntry.isSelected()) {
jobMeta.unselectAll();
selectedEntry.setSelected(true);
selectedEntries = new ArrayList<>();
selectedEntries.add(selectedEntry);
previous_step_locations = new Point[] { selectedEntry.getLocation() };
redraw();
} else if (selectedNote != null && !selectedNote.isSelected()) {
jobMeta.unselectAll();
selectedNote.setSelected(true);
selectedNotes = new ArrayList<>();
selectedNotes.add(selectedNote);
previous_note_locations = new Point[] { selectedNote.getLocation() };
redraw();
} else if (selectionRegion != null && startHopEntry == null) {
// Did we select a region...?
//
selectionRegion.width = real.x - selectionRegion.x;
selectionRegion.height = real.y - selectionRegion.y;
redraw();
} else if (selectedEntry != null && lastButton == 1 && !shift && startHopEntry == null) {
// Move around steps & notes
//
//
// 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 - selectedEntry.getLocation().x;
int dy = icon.y - selectedEntry.getLocation().y;
// See if we have a hop-split candidate
//
JobHopMeta hi = findHop(icon.x + iconsize / 2, icon.y + iconsize / 2, selectedEntry);
if (hi != null) {
//
if (!hi.getFromEntry().equals(selectedEntry) && !hi.getToEntry().equals(selectedEntry)) {
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 = jobMeta.getSelectedNotes();
selectedEntries = jobMeta.getSelectedEntries();
// Adjust location of selected steps...
if (selectedEntries != null) {
for (int i = 0; i < selectedEntries.size(); i++) {
JobEntryCopy jobEntryCopy = selectedEntries.get(i);
PropsUI.setLocation(jobEntryCopy, jobEntryCopy.getLocation().x + dx, jobEntryCopy.getLocation().y + dy);
stopEntryMouseOverDelayTimer(jobEntryCopy);
}
}
// 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 ((startHopEntry != null && endHopEntry == null) || (endHopEntry != null && startHopEntry == null)) {
// Are we creating a new hop with the middle button or pressing SHIFT?
//
JobEntryCopy jobEntryCopy = jobMeta.getJobEntryCopy(real.x, real.y, iconsize);
endHopLocation = new Point(real.x, real.y);
if (jobEntryCopy != null && ((startHopEntry != null && !startHopEntry.equals(jobEntryCopy)) || (endHopEntry != null && !endHopEntry.equals(jobEntryCopy)))) {
if (hop_candidate == null) {
//
if (startHopEntry != null) {
if (!jobEntryCopy.isStart()) {
hop_candidate = new JobHopMeta(startHopEntry, jobEntryCopy);
endHopLocation = null;
} else {
noInputEntry = jobEntryCopy;
toolTip.setImage(null);
toolTip.setText("The start entry can only be used at the start of a Job");
toolTip.show(new org.eclipse.swt.graphics.Point(real.x, real.y));
}
} else if (endHopEntry != null) {
hop_candidate = new JobHopMeta(jobEntryCopy, endHopEntry);
endHopLocation = null;
}
}
} else {
if (hop_candidate != null) {
hop_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 = jobMeta.getSelectedNotes();
selectedEntries = jobMeta.getSelectedEntries();
// Adjust location of selected steps...
if (selectedEntries != null) {
for (int i = 0; i < selectedEntries.size(); i++) {
JobEntryCopy jobEntryCopy = selectedEntries.get(i);
PropsUI.setLocation(jobEntryCopy, jobEntryCopy.getLocation().x + dx, jobEntryCopy.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();
}
}
}
use of org.pentaho.di.core.NotePadMeta in project pentaho-kettle by pentaho.
the class JobGraph method newNote.
public void newNote() {
String title = BaseMessages.getString(PKG, "JobGraph.Dialog.EditNote.Title");
NotePadDialog dd = new NotePadDialog(jobMeta, 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());
jobMeta.addNote(npi);
spoon.addUndoNew(jobMeta, new NotePadMeta[] { npi }, new int[] { jobMeta.indexOfNote(npi) });
redraw();
}
}
use of org.pentaho.di.core.NotePadMeta in project pentaho-kettle by pentaho.
the class JobGraph method mouseDoubleClick.
public void mouseDoubleClick(MouseEvent e) {
clearSettings();
Point real = screen2real(e.x, e.y);
// Hide the tooltip!
hideToolTips();
try {
ExtensionPointHandler.callExtensionPoint(LogChannel.GENERAL, KettleExtensionPoint.JobGraphMouseDoubleClick.id, new JobGraphExtension(this, e, real));
} catch (Exception ex) {
LogChannel.GENERAL.logError("Error calling JobGraphMouseDoubleClick extension point", ex);
}
JobEntryCopy jobentry = jobMeta.getJobEntryCopy(real.x, real.y, iconsize);
if (jobentry != null) {
if (e.button == 1) {
editEntry(jobentry);
} else {
// open tab in Spoon
launchStuff(jobentry);
}
} else {
// Check if point lies on one of the many hop-lines...
JobHopMeta online = findJobHop(real.x, real.y);
if (online == null) {
NotePadMeta ni = jobMeta.getNote(real.x, real.y);
if (ni != null) {
editNote(ni);
} else {
// Clicked on the background...
//
editJobProperties();
}
}
}
}
use of org.pentaho.di.core.NotePadMeta 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;
}
Aggregations