use of org.pentaho.di.trans.step.StepMeta in project pentaho-kettle by pentaho.
the class TransGraph method enableDisableNextHops.
private Set<StepMeta> enableDisableNextHops(StepMeta from, boolean enabled, Set<StepMeta> checkedEntries) {
checkedEntries.add(from);
transMeta.getTransHops().stream().filter(hop -> from.equals(hop.getFromStep())).forEach(hop -> {
if (hop.isEnabled() != enabled) {
TransHopMeta before = (TransHopMeta) hop.clone();
setHopEnabled(hop, enabled);
TransHopMeta after = (TransHopMeta) hop.clone();
spoon.addUndoChange(transMeta, new TransHopMeta[] { before }, new TransHopMeta[] { after }, new int[] { transMeta.indexOfTransHop(hop) });
}
if (!checkedEntries.contains(hop.getToStep())) {
enableDisableNextHops(hop.getToStep(), enabled, checkedEntries);
}
});
return checkedEntries;
}
use of org.pentaho.di.trans.step.StepMeta 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.trans.step.StepMeta 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.trans.step.StepMeta in project pentaho-kettle by pentaho.
the class TransGraph method renameStep.
public void renameStep(StepMeta stepMeta, String stepname) {
String newname = stepname;
StepMeta smeta = transMeta.findStep(newname, stepMeta);
int nr = 2;
while (smeta != null) {
newname = stepname + " " + nr;
smeta = transMeta.findStep(newname);
nr++;
}
if (nr > 2) {
stepname = newname;
MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_INFORMATION);
mb.setMessage(BaseMessages.getString(PKG, "Spoon.Dialog.StepnameExists.Message", stepname));
mb.setText(BaseMessages.getString(PKG, "Spoon.Dialog.StepnameExists.Title"));
mb.open();
}
stepMeta.setName(stepname);
stepMeta.setChanged();
// to reflect the new name
spoon.refreshTree();
spoon.refreshGraph();
}
use of org.pentaho.di.trans.step.StepMeta in project pentaho-kettle by pentaho.
the class TransGraph method enableHopsBetweenSelectedSteps.
/**
* This method enables or disables all the hops between the selected steps.
*/
public void enableHopsBetweenSelectedSteps(boolean enabled) {
List<StepMeta> list = transMeta.getSelectedSteps();
boolean hasLoop = false;
for (int i = 0; i < transMeta.nrTransHops(); i++) {
TransHopMeta hop = transMeta.getTransHop(i);
if (list.contains(hop.getFromStep()) && list.contains(hop.getToStep())) {
TransHopMeta before = (TransHopMeta) hop.clone();
setHopEnabled(hop, enabled);
TransHopMeta after = (TransHopMeta) hop.clone();
spoon.addUndoChange(transMeta, new TransHopMeta[] { before }, new TransHopMeta[] { after }, new int[] { transMeta.indexOfTransHop(hop) });
if (transMeta.hasLoop(hop.getToStep())) {
hasLoop = true;
setHopEnabled(hop, false);
}
}
}
if (enabled && hasLoop) {
MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_ERROR);
mb.setMessage(BaseMessages.getString(PKG, "TransGraph.Dialog.HopCausesLoop.Message"));
mb.setText(BaseMessages.getString(PKG, "TransGraph.Dialog.HopCausesLoop.Title"));
mb.open();
}
spoon.refreshGraph();
}
Aggregations