use of org.pentaho.di.core.gui.Point in project pentaho-kettle by pentaho.
the class Spoon method newTransFile.
public void newTransFile() {
TransMeta transMeta = new TransMeta();
transMeta.addObserver(this);
// Set the variables that were previously defined in this session on the
// transformation metadata too.
//
setTransMetaVariables(transMeta);
// Pass repository information
//
transMeta.setRepository(rep);
transMeta.setMetaStore(metaStore);
try {
SharedObjects sharedObjects = rep != null ? rep.readTransSharedObjects(transMeta) : transMeta.readSharedObjects();
sharedObjectsFileMap.put(sharedObjects.getFilename(), sharedObjects);
if (rep == null) {
transMeta.setSharedObjects(sharedObjects);
}
transMeta.importFromMetaStore();
transMeta.clearChanged();
} catch (Exception e) {
new ErrorDialog(shell, BaseMessages.getString(PKG, "Spoon.Exception.ErrorReadingSharedObjects.Title"), BaseMessages.getString(PKG, "Spoon.Exception.ErrorReadingSharedObjects.Message"), e);
}
// Set the location of the new transMeta to that of the default location or the last saved location
transMeta.setRepositoryDirectory(getDefaultSaveLocation(transMeta));
int nr = 1;
transMeta.setName(STRING_TRANSFORMATION + " " + nr);
//
while (findTransformation(delegates.tabs.makeTabName(transMeta, false)) != null) {
nr++;
// rename
transMeta.setName(STRING_TRANSFORMATION + " " + nr);
}
addTransGraph(transMeta);
applyVariables();
//
if (setDesignMode()) {
// No refresh done yet, do so
refreshTree();
}
loadPerspective(MainSpoonPerspective.ID);
try {
ExtensionPointHandler.callExtensionPoint(log, KettleExtensionPoint.TransformationCreateNew.id, transMeta);
} catch (KettleException e) {
log.logError("Failed to call extension point", e);
}
}
use of org.pentaho.di.core.gui.Point in project pentaho-kettle by pentaho.
the class Spoon method printJobFile.
private void printJobFile(JobMeta jobMeta) {
JobGraph jobGraph = getActiveJobGraph();
if (jobGraph == null) {
return;
}
PrintSpool ps = new PrintSpool();
Printer printer = ps.getPrinter(shell);
// Create an image of the screen
Point max = jobMeta.getMaximum();
Image img = jobGraph.getJobImage(printer, max.x, max.y, 1.0f);
ps.printImage(shell, img);
img.dispose();
ps.dispose();
}
use of org.pentaho.di.core.gui.Point in project pentaho-kettle by pentaho.
the class TransGraph method mouseDown.
@Override
public void mouseDown(MouseEvent e) {
boolean alt = (e.stateMask & SWT.ALT) != 0;
boolean control = (e.stateMask & SWT.MOD1) != 0;
boolean shift = (e.stateMask & SWT.SHIFT) != 0;
lastButton = e.button;
Point real = screen2real(e.x, e.y);
lastclick = new Point(real.x, real.y);
// Hide the tooltip!
hideToolTips();
// Set the pop-up menu
if (e.button == 3) {
setMenu(real.x, real.y);
return;
}
try {
ExtensionPointHandler.callExtensionPoint(LogChannel.GENERAL, KettleExtensionPoint.TransGraphMouseDown.id, new TransGraphExtension(this, e, real));
} catch (Exception ex) {
LogChannel.GENERAL.logError("Error calling TransGraphMouseDown extension point", ex);
}
//
if (e.button == 1 || e.button == 2) {
AreaOwner areaOwner = getVisibleAreaOwner(real.x, real.y);
if (areaOwner != null && areaOwner.getAreaType() != null) {
switch(areaOwner.getAreaType()) {
case STEP_OUTPUT_HOP_ICON:
// Click on the output icon means: start of drag
// Action: We show the input icons on the other steps...
//
selectedStep = null;
startHopStep = (StepMeta) areaOwner.getParent();
candidateHopType = null;
startErrorHopStep = false;
// stopStepMouseOverDelayTimer(startHopStep);
break;
case STEP_INPUT_HOP_ICON:
// Click on the input icon means: start to a new hop
// In this case, we set the end hop step...
//
selectedStep = null;
startHopStep = null;
endHopStep = (StepMeta) areaOwner.getParent();
candidateHopType = null;
startErrorHopStep = false;
// stopStepMouseOverDelayTimer(endHopStep);
break;
case HOP_ERROR_ICON:
// Click on the error icon means: Edit error handling
//
StepMeta stepMeta = (StepMeta) areaOwner.getParent();
spoon.editStepErrorHandling(transMeta, stepMeta);
break;
case STEP_TARGET_HOP_ICON_OPTION:
// Below, see showStepTargetOptions()
break;
case STEP_EDIT_ICON:
clearSettings();
currentStep = (StepMeta) areaOwner.getParent();
stopStepMouseOverDelayTimer(currentStep);
editStep();
break;
case STEP_INJECT_ICON:
MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_INFORMATION);
mb.setMessage(BaseMessages.getString(PKG, "TransGraph.StepInjectionSupported.Tooltip"));
mb.setText(BaseMessages.getString(PKG, "TransGraph.StepInjectionSupported.Title"));
mb.open();
break;
case STEP_MENU_ICON:
clearSettings();
stepMeta = (StepMeta) areaOwner.getParent();
setMenu(stepMeta.getLocation().x, stepMeta.getLocation().y);
break;
case STEP_ICON:
stepMeta = (StepMeta) areaOwner.getOwner();
currentStep = stepMeta;
for (StepSelectionListener listener : currentStepListeners) {
listener.onUpdateSelection(currentStep);
}
if (candidate != null) {
addCandidateAsHop(e.x, e.y);
} else {
if (transPreviewDelegate.isActive()) {
transPreviewDelegate.setSelectedStep(currentStep);
for (SelectedStepListener stepListener : stepListeners) {
if (this.extraViewComposite != null && !this.extraViewComposite.isDisposed()) {
stepListener.onSelect(currentStep);
}
}
transPreviewDelegate.refreshView();
}
}
//
if (e.button == 1 && alt && stepMeta.supportsErrorHandling()) {
spoon.editStepErrorHandling(transMeta, stepMeta);
return;
} else if (e.button == 2 || (e.button == 1 && shift)) {
// SHIFT CLICK is start of drag to create a new hop
//
startHopStep = stepMeta;
} else {
selectedSteps = transMeta.getSelectedSteps();
selectedStep = stepMeta;
//
// When an icon is moved that is not selected, it gets
// selected too late.
// It is not captured here, but in the mouseMoveListener...
//
previous_step_locations = transMeta.getSelectedStepLocations();
Point p = stepMeta.getLocation();
iconoffset = new Point(real.x - p.x, real.y - p.y);
}
redraw();
break;
case NOTE:
ni = (NotePadMeta) areaOwner.getOwner();
selectedNotes = transMeta.getSelectedNotes();
selectedNote = ni;
Point loc = ni.getLocation();
previous_note_locations = transMeta.getSelectedNoteLocations();
noteoffset = new Point(real.x - loc.x, real.y - loc.y);
redraw();
break;
case STEP_COPIES_TEXT:
copies((StepMeta) areaOwner.getOwner());
break;
case STEP_DATA_SERVICE:
editProperties(transMeta, spoon, spoon.getRepository(), true, TransDialog.Tabs.EXTRA_TAB);
break;
default:
break;
}
} else {
// A hop? --> enable/disable
//
TransHopMeta hop = findHop(real.x, real.y);
if (hop != null) {
TransHopMeta before = (TransHopMeta) hop.clone();
setHopEnabled(hop, !hop.isEnabled());
if (hop.isEnabled() && transMeta.hasLoop(hop.getToStep())) {
setHopEnabled(hop, false);
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();
}
TransHopMeta after = (TransHopMeta) hop.clone();
spoon.addUndoChange(transMeta, new TransHopMeta[] { before }, new TransHopMeta[] { after }, new int[] { transMeta.indexOfTransHop(hop) });
redraw();
spoon.setShellText();
} else {
// No area-owner & no hop means : background click:
//
startHopStep = null;
if (!control) {
selectionRegion = new org.pentaho.di.core.gui.Rectangle(real.x, real.y, 0, 0);
}
redraw();
}
}
}
}
use of org.pentaho.di.core.gui.Point in project pentaho-kettle by pentaho.
the class TransGraph method addStepToChain.
public void addStepToChain(PluginInterface stepPlugin, boolean shift) {
TransMeta transMeta = spoon.getActiveTransformation();
if (transMeta == null) {
return;
}
//
if (lastChained != null && transMeta.findStep(lastChained.getName()) == null) {
lastChained = null;
}
// If there is exactly one selected step, pick that one as last chained.
//
List<StepMeta> sel = transMeta.getSelectedSteps();
if (sel.size() == 1) {
lastChained = sel.get(0);
}
// Where do we add this?
Point p = null;
if (lastChained == null) {
p = transMeta.getMaximum();
p.x -= 100;
} else {
p = new Point(lastChained.getLocation().x, lastChained.getLocation().y);
}
p.x += 200;
// Which is the new step?
StepMeta newStep = spoon.newStep(transMeta, stepPlugin.getIds()[0], stepPlugin.getName(), stepPlugin.getName(), false, true);
if (newStep == null) {
return;
}
newStep.setLocation(p.x, p.y);
newStep.setDraw(true);
if (lastChained != null) {
TransHopMeta hop = new TransHopMeta(lastChained, newStep);
spoon.newHop(transMeta, hop);
}
lastChained = newStep;
spoon.refreshGraph();
spoon.refreshTree();
if (shift) {
editStep(newStep);
}
transMeta.unselectAll();
newStep.setSelected(true);
}
use of org.pentaho.di.core.gui.Point in project pentaho-kettle by pentaho.
the class TransGraph method splitHop.
private void splitHop(TransHopMeta hi) {
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) {
// Means: "Yes" button clicked!
// Only split A-->--B by putting C in between IF...
// C-->--A or B-->--C don't exists...
// A ==> hi.getFromStep()
// B ==> hi.getToStep();
// C ==> selected_step
//
boolean caExists = transMeta.findTransHop(selectedStep, hi.getFromStep()) != null;
boolean bcExists = transMeta.findTransHop(hi.getToStep(), selectedStep) != null;
if (!caExists && !bcExists) {
StepMeta fromStep = hi.getFromStep();
StepMeta toStep = hi.getToStep();
// In case step A targets B then we now need to target C
//
StepIOMetaInterface fromIo = fromStep.getStepMetaInterface().getStepIOMeta();
for (StreamInterface stream : fromIo.getTargetStreams()) {
if (stream.getStepMeta() != null && stream.getStepMeta().equals(toStep)) {
// This target stream was directed to B, now we need to direct it to C
stream.setStepMeta(selectedStep);
fromStep.getStepMetaInterface().handleStreamSelection(stream);
}
}
// In case step B sources from A then we now need to source from C
//
StepIOMetaInterface toIo = toStep.getStepMetaInterface().getStepIOMeta();
for (StreamInterface stream : toIo.getInfoStreams()) {
if (stream.getStepMeta() != null && stream.getStepMeta().equals(fromStep)) {
// This info stream was reading from B, now we need to direct it to C
stream.setStepMeta(selectedStep);
toStep.getStepMetaInterface().handleStreamSelection(stream);
}
}
// In case there is error handling on A, we want to make it point to C now
//
StepErrorMeta errorMeta = fromStep.getStepErrorMeta();
if (fromStep.isDoingErrorHandling() && toStep.equals(errorMeta.getTargetStep())) {
errorMeta.setTargetStep(selectedStep);
}
TransHopMeta newhop1 = new TransHopMeta(hi.getFromStep(), selectedStep);
if (transMeta.findTransHop(newhop1) == null) {
transMeta.addTransHop(newhop1);
spoon.addUndoNew(transMeta, new TransHopMeta[] { newhop1 }, new int[] { transMeta.indexOfTransHop(newhop1) }, true);
}
TransHopMeta newhop2 = new TransHopMeta(selectedStep, hi.getToStep());
if (transMeta.findTransHop(newhop2) == null) {
transMeta.addTransHop(newhop2);
spoon.addUndoNew(transMeta, new TransHopMeta[] { newhop2 }, new int[] { transMeta.indexOfTransHop(newhop2) }, true);
}
int idx = transMeta.indexOfTransHop(hi);
spoon.addUndoDelete(transMeta, new TransHopMeta[] { hi }, new int[] { idx }, true);
transMeta.removeTransHop(idx);
spoon.refreshTree();
}
// else: Silently discard this hop-split attempt.
}
}
Aggregations