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