use of org.pentaho.di.core.gui.AreaOwner in project pentaho-kettle by pentaho.
the class TransGraph method mouseDoubleClick.
@Override
public void mouseDoubleClick(MouseEvent e) {
clearSettings();
Point real = screen2real(e.x, e.y);
// Hide the tooltip!
hideToolTips();
try {
ExtensionPointHandler.callExtensionPoint(LogChannel.GENERAL, KettleExtensionPoint.TransGraphMouseDoubleClick.id, new TransGraphExtension(this, e, real));
} catch (Exception ex) {
LogChannel.GENERAL.logError("Error calling TransGraphMouseDoubleClick extension point", ex);
}
StepMeta stepMeta = transMeta.getStep(real.x, real.y, iconsize);
if (stepMeta != null) {
if (e.button == 1) {
editStep(stepMeta);
} else {
editDescription(stepMeta);
}
} else {
// Check if point lies on one of the many hop-lines...
TransHopMeta online = findHop(real.x, real.y);
if (online != null) {
editHop(online);
} else {
NotePadMeta ni = transMeta.getNote(real.x, real.y);
if (ni != null) {
selectedNote = null;
editNote(ni);
} else {
// See if the double click was in one of the area's...
//
boolean hit = false;
for (AreaOwner areaOwner : areaOwners) {
if (areaOwner.contains(real.x, real.y)) {
if (areaOwner.getParent() instanceof StepMeta && areaOwner.getOwner().equals(TransPainter.STRING_PARTITIONING_CURRENT_STEP)) {
StepMeta step = (StepMeta) areaOwner.getParent();
spoon.editPartitioning(transMeta, step);
hit = true;
break;
}
}
}
if (!hit) {
settings();
}
}
}
}
}
use of org.pentaho.di.core.gui.AreaOwner in project pentaho-kettle by pentaho.
the class JobGraph method mouseDown.
public void mouseDown(MouseEvent e) {
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.JobGraphMouseDown.id, new JobGraphExtension(this, e, real));
} catch (Exception ex) {
LogChannel.GENERAL.logError("Error calling JobGraphMouseDown 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 JOB_ENTRY_MINI_ICON_OUTPUT:
// Click on the output icon means: start of drag
// Action: We show the input icons on the other steps...
//
selectedEntry = null;
startHopEntry = (JobEntryCopy) areaOwner.getOwner();
// stopEntryMouseOverDelayTimer(startHopEntry);
break;
case JOB_ENTRY_MINI_ICON_INPUT:
// Click on the input icon means: start to a new hop
// In this case, we set the end hop step...
//
selectedEntry = null;
startHopEntry = null;
endHopEntry = (JobEntryCopy) areaOwner.getOwner();
// stopEntryMouseOverDelayTimer(endHopEntry);
break;
case JOB_ENTRY_MINI_ICON_EDIT:
clearSettings();
currentEntry = (JobEntryCopy) areaOwner.getOwner();
stopEntryMouseOverDelayTimer(currentEntry);
editEntry(currentEntry);
break;
case JOB_ENTRY_MINI_ICON_CONTEXT:
clearSettings();
JobEntryCopy jobEntryCopy = (JobEntryCopy) areaOwner.getOwner();
setMenu(jobEntryCopy.getLocation().x, jobEntryCopy.getLocation().y);
break;
case JOB_ENTRY_ICON:
jobEntryCopy = (JobEntryCopy) areaOwner.getOwner();
currentEntry = jobEntryCopy;
if (hop_candidate != null) {
addCandidateAsHop();
} else if (e.button == 2 || (e.button == 1 && shift)) {
// SHIFT CLICK is start of drag to create a new hop
//
startHopEntry = jobEntryCopy;
} else {
selectedEntries = jobMeta.getSelectedEntries();
selectedEntry = jobEntryCopy;
//
// 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 = jobMeta.getSelectedLocations();
Point p = jobEntryCopy.getLocation();
iconoffset = new Point(real.x - p.x, real.y - p.y);
}
redraw();
break;
case NOTE:
ni = (NotePadMeta) areaOwner.getOwner();
selectedNotes = jobMeta.getSelectedNotes();
selectedNote = ni;
Point loc = ni.getLocation();
previous_note_locations = jobMeta.getSelectedNoteLocations();
noteoffset = new Point(real.x - loc.x, real.y - loc.y);
redraw();
break;
//
case JOB_HOP_ICON:
JobHopMeta hop = (JobHopMeta) areaOwner.getOwner();
if (hop.getFromEntry().evaluates()) {
if (hop.isUnconditional()) {
hop.setUnconditional(false);
hop.setEvaluation(true);
} else {
if (hop.getEvaluation()) {
hop.setEvaluation(false);
} else {
hop.setUnconditional(true);
}
}
spoon.setShellText();
redraw();
}
break;
default:
break;
}
} else {
// A hop? --> enable/disable
//
JobHopMeta hop = findJobHop(real.x, real.y);
if (hop != null) {
JobHopMeta before = (JobHopMeta) hop.clone();
hop.setEnabled(!hop.isEnabled());
if (hop.isEnabled() && (jobMeta.hasLoop(hop.getToEntry()))) {
MessageBox mb = new MessageBox(shell, SWT.CANCEL | SWT.OK | SWT.ICON_WARNING);
mb.setMessage(BaseMessages.getString(PKG, "JobGraph.Dialog.LoopAfterHopEnabled.Message"));
mb.setText(BaseMessages.getString(PKG, "JobGraph.Dialog.LoopAfterHopEnabled.Title"));
int choice = mb.open();
if (choice == SWT.CANCEL) {
hop.setEnabled(false);
}
}
JobHopMeta after = (JobHopMeta) hop.clone();
spoon.addUndoChange(jobMeta, new JobHopMeta[] { before }, new JobHopMeta[] { after }, new int[] { jobMeta.indexOfJobHop(hop) });
spoon.setShellText();
redraw();
} else {
// No area-owner means: background:
//
startHopEntry = 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.AreaOwner 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.gui.AreaOwner in project pentaho-kettle by pentaho.
the class JobGraph method setToolTip.
protected void setToolTip(int x, int y, int screenX, int screenY) {
if (!spoon.getProperties().showToolTips()) {
return;
}
// Some stupid bug in GTK+ causes a phantom tool tip to pop up, even if the tip is
canvas.setToolTipText("-");
// null
canvas.setToolTipText(null);
Image tipImage = null;
JobHopMeta hi = findJobHop(x, y);
// check the area owner list...
//
StringBuilder tip = new StringBuilder();
AreaOwner areaOwner = getVisibleAreaOwner(x, y);
if (areaOwner != null && areaOwner.getAreaType() != null) {
JobEntryCopy jobEntryCopy;
switch(areaOwner.getAreaType()) {
case JOB_HOP_ICON:
hi = (JobHopMeta) areaOwner.getOwner();
if (hi.isUnconditional()) {
tipImage = GUIResource.getInstance().getImageUnconditionalHop();
tip.append(BaseMessages.getString(PKG, "JobGraph.Hop.Tooltip.Unconditional", hi.getFromEntry().getName(), Const.CR));
} else {
if (hi.getEvaluation()) {
tip.append(BaseMessages.getString(PKG, "JobGraph.Hop.Tooltip.EvaluatingTrue", hi.getFromEntry().getName(), Const.CR));
tipImage = GUIResource.getInstance().getImageTrue();
} else {
tip.append(BaseMessages.getString(PKG, "JobGraph.Hop.Tooltip.EvaluatingFalse", hi.getFromEntry().getName(), Const.CR));
tipImage = GUIResource.getInstance().getImageFalse();
}
}
break;
case JOB_HOP_PARALLEL_ICON:
hi = (JobHopMeta) areaOwner.getOwner();
tip.append(BaseMessages.getString(PKG, "JobGraph.Hop.Tooltip.Parallel", hi.getFromEntry().getName(), Const.CR));
tipImage = GUIResource.getInstance().getImageParallelHop();
break;
case CUSTOM:
String message = (String) areaOwner.getOwner();
tip.append(message);
tipImage = null;
GUIResource.getInstance().getImageTransGraph();
break;
case JOB_ENTRY_MINI_ICON_INPUT:
tip.append(BaseMessages.getString(PKG, "JobGraph.EntryInputConnector.Tooltip"));
tipImage = GUIResource.getInstance().getImageHopInput();
resetDelayTimer((JobEntryCopy) areaOwner.getOwner());
break;
case JOB_ENTRY_MINI_ICON_OUTPUT:
tip.append(BaseMessages.getString(PKG, "JobGraph.EntryOutputConnector.Tooltip"));
tipImage = GUIResource.getInstance().getImageHopOutput();
resetDelayTimer((JobEntryCopy) areaOwner.getOwner());
break;
case JOB_ENTRY_MINI_ICON_EDIT:
tip.append(BaseMessages.getString(PKG, "JobGraph.EditStep.Tooltip"));
tipImage = GUIResource.getInstance().getImageEdit();
resetDelayTimer((JobEntryCopy) areaOwner.getOwner());
break;
case JOB_ENTRY_MINI_ICON_CONTEXT:
tip.append(BaseMessages.getString(PKG, "JobGraph.ShowMenu.Tooltip"));
tipImage = GUIResource.getInstance().getImageContextMenu();
resetDelayTimer((JobEntryCopy) areaOwner.getOwner());
break;
case JOB_ENTRY_RESULT_FAILURE:
case JOB_ENTRY_RESULT_SUCCESS:
JobEntryResult jobEntryResult = (JobEntryResult) areaOwner.getOwner();
jobEntryCopy = (JobEntryCopy) areaOwner.getParent();
Result result = jobEntryResult.getResult();
tip.append("'").append(jobEntryCopy.getName()).append("' ");
if (result.getResult()) {
tipImage = GUIResource.getInstance().getImageTrue();
tip.append("finished successfully.");
} else {
tipImage = GUIResource.getInstance().getImageFalse();
tip.append("failed.");
}
tip.append(Const.CR).append("------------------------").append(Const.CR).append(Const.CR);
tip.append("Result : ").append(result.getResult()).append(Const.CR);
tip.append("Errors : ").append(result.getNrErrors()).append(Const.CR);
if (result.getNrLinesRead() > 0) {
tip.append("Lines read : ").append(result.getNrLinesRead()).append(Const.CR);
}
if (result.getNrLinesWritten() > 0) {
tip.append("Lines written : ").append(result.getNrLinesWritten()).append(Const.CR);
}
if (result.getNrLinesInput() > 0) {
tip.append("Lines input : ").append(result.getNrLinesInput()).append(Const.CR);
}
if (result.getNrLinesOutput() > 0) {
tip.append("Lines output : ").append(result.getNrLinesOutput()).append(Const.CR);
}
if (result.getNrLinesUpdated() > 0) {
tip.append("Lines updated : ").append(result.getNrLinesUpdated()).append(Const.CR);
}
if (result.getNrLinesDeleted() > 0) {
tip.append("Lines deleted : ").append(result.getNrLinesDeleted()).append(Const.CR);
}
if (result.getNrLinesRejected() > 0) {
tip.append("Lines rejected : ").append(result.getNrLinesRejected()).append(Const.CR);
}
if (result.getResultFiles() != null && !result.getResultFiles().isEmpty()) {
tip.append(Const.CR).append("Result files:").append(Const.CR);
if (result.getResultFiles().size() > 10) {
tip.append(" (10 files of ").append(result.getResultFiles().size()).append(" shown");
}
List<ResultFile> files = new ArrayList<>(result.getResultFiles().values());
for (int i = 0; i < files.size(); i++) {
ResultFile file = files.get(i);
tip.append(" - ").append(file.toString()).append(Const.CR);
}
}
if (result.getRows() != null && !result.getRows().isEmpty()) {
tip.append(Const.CR).append("Result rows: ");
if (result.getRows().size() > 10) {
tip.append(" (10 rows of ").append(result.getRows().size()).append(" shown");
}
tip.append(Const.CR);
for (int i = 0; i < result.getRows().size() && i < 10; i++) {
RowMetaAndData row = result.getRows().get(i);
tip.append(" - ").append(row.toString()).append(Const.CR);
}
}
break;
case JOB_ENTRY_RESULT_CHECKPOINT:
tip.append("The job started here since this is the furthest checkpoint " + "that was reached last time the transformation was executed.");
tipImage = GUIResource.getInstance().getImageCheckpoint();
break;
default:
break;
}
}
if (hi != null && tip.length() == 0) {
// Set the tooltip for the hop:
tip.append(BaseMessages.getString(PKG, "JobGraph.Dialog.HopInfo")).append(Const.CR);
tip.append(BaseMessages.getString(PKG, "JobGraph.Dialog.HopInfo.SourceEntry")).append(" ").append(hi.getFromEntry().getName()).append(Const.CR);
tip.append(BaseMessages.getString(PKG, "JobGraph.Dialog.HopInfo.TargetEntry")).append(" ").append(hi.getToEntry().getName()).append(Const.CR);
tip.append(BaseMessages.getString(PKG, "TransGraph.Dialog.HopInfo.Status")).append(" ");
tip.append((hi.isEnabled() ? BaseMessages.getString(PKG, "JobGraph.Dialog.HopInfo.Enable") : BaseMessages.getString(PKG, "JobGraph.Dialog.HopInfo.Disable")));
if (hi.isUnconditional()) {
tipImage = GUIResource.getInstance().getImageUnconditionalHop();
} else {
if (hi.getEvaluation()) {
tipImage = GUIResource.getInstance().getImageTrue();
} else {
tipImage = GUIResource.getInstance().getImageFalse();
}
}
}
if (tip == null || tip.length() == 0) {
toolTip.hide();
} else {
if (!tip.toString().equalsIgnoreCase(getToolTipText())) {
if (tipImage != null) {
toolTip.setImage(tipImage);
} else {
toolTip.setImage(GUIResource.getInstance().getImageSpoon());
}
toolTip.setText(tip.toString());
toolTip.hide();
toolTip.show(new org.eclipse.swt.graphics.Point(screenX, screenY));
}
}
}
use of org.pentaho.di.core.gui.AreaOwner in project pentaho-kettle by pentaho.
the class JobGraph method mouseHover.
public void mouseHover(MouseEvent e) {
boolean tip = true;
// toolTip.hide();
Point real = screen2real(e.x, e.y);
AreaOwner areaOwner = getVisibleAreaOwner(real.x, real.y);
if (areaOwner != null && areaOwner.getAreaType() != null) {
switch(areaOwner.getAreaType()) {
case JOB_ENTRY_ICON:
JobEntryCopy jobEntryCopy = (JobEntryCopy) areaOwner.getOwner();
if (!jobEntryCopy.isMissing() && !mouseOverEntries.contains(jobEntryCopy)) {
addEntryMouseOverDelayTimer(jobEntryCopy);
redraw();
tip = false;
}
break;
default:
break;
}
}
if (tip) {
//
if (!helpTip.isVisible()) {
setToolTip(real.x, real.y, e.x, e.y);
}
}
}
Aggregations