use of org.pentaho.di.core.gui.Point 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.gui.Point 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.gui.Point 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.gui.Point in project pentaho-kettle by pentaho.
the class TransGraph method keyPressed.
@Override
public void keyPressed(KeyEvent e) {
if (e.keyCode == SWT.ESC) {
clearSettings();
redraw();
}
if (e.keyCode == SWT.DEL) {
List<StepMeta> stepMeta = transMeta.getSelectedSteps();
if (stepMeta != null && stepMeta.size() > 0) {
delSelected(null);
}
}
if (e.keyCode == SWT.F1) {
spoon.browseVersionHistory();
}
if (e.keyCode == SWT.F2) {
spoon.editKettlePropertiesFile();
}
// CTRL-UP : allignTop();
if (e.keyCode == SWT.ARROW_UP && (e.stateMask & SWT.MOD1) != 0) {
alligntop();
}
// CTRL-DOWN : allignBottom();
if (e.keyCode == SWT.ARROW_DOWN && (e.stateMask & SWT.MOD1) != 0) {
allignbottom();
}
// CTRL-LEFT : allignleft();
if (e.keyCode == SWT.ARROW_LEFT && (e.stateMask & SWT.MOD1) != 0) {
allignleft();
}
// CTRL-RIGHT : allignRight();
if (e.keyCode == SWT.ARROW_RIGHT && (e.stateMask & SWT.MOD1) != 0) {
allignright();
}
// ALT-RIGHT : distributeHorizontal();
if (e.keyCode == SWT.ARROW_RIGHT && (e.stateMask & SWT.ALT) != 0) {
distributehorizontal();
}
// ALT-UP : distributeVertical();
if (e.keyCode == SWT.ARROW_UP && (e.stateMask & SWT.ALT) != 0) {
distributevertical();
}
// ALT-HOME : snap to grid
if (e.keyCode == SWT.HOME && (e.stateMask & SWT.ALT) != 0) {
snaptogrid(ConstUI.GRID_SIZE);
}
if (e.character == 'E' && (e.stateMask & SWT.CTRL) != 0) {
checkErrorVisuals();
}
// CTRL-W or CTRL-F4 : close tab
if ((e.keyCode == 'w' && (e.stateMask & SWT.MOD1) != 0) || (e.keyCode == SWT.F4 && (e.stateMask & SWT.MOD1) != 0)) {
spoon.tabCloseSelected();
}
// Auto-layout
if (e.character == 'A') {
autoLayout();
}
// SPACE : over a step: show output fields...
if (e.character == ' ' && lastMove != null) {
Point real = lastMove;
// Hide the tooltip!
hideToolTips();
// Set the pop-up menu
StepMeta stepMeta = transMeta.getStep(real.x, real.y, iconsize);
if (stepMeta != null) {
// OK, we found a step, show the output fields...
inputOutputFields(stepMeta, false);
}
}
}
use of org.pentaho.di.core.gui.Point in project pentaho-kettle by pentaho.
the class JobEntryCopy method setLocation.
public void setLocation(int x, int y) {
int nx = (x >= 0 ? x : 0);
int ny = (y >= 0 ? y : 0);
Point loc = new Point(nx, ny);
if (!loc.equals(location)) {
setChanged();
}
location = loc;
}
Aggregations