use of org.apache.hop.ui.hopgui.file.pipeline.extension.HopGuiPipelineGraphExtension in project hop by apache.
the class HopGuiPipelineGraph method mouseMove.
@Override
public void mouseMove(MouseEvent e) {
boolean shift = (e.stateMask & SWT.SHIFT) != 0;
noInputTransform = null;
mouseMovedSinceClick = true;
// disable the tooltip
//
toolTip.setVisible(false);
Point real = screen2real(e.x, e.y);
currentMouseX = real.x;
currentMouseY = real.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);
try {
HopGuiPipelineGraphExtension ext = new HopGuiPipelineGraphExtension(this, e, real, areaOwner);
ExtensionPointHandler.callExtensionPoint(LogChannel.GENERAL, variables, HopExtensionPoint.PipelineGraphMouseMoved.id, ext);
if (ext.isPreventingDefault()) {
return;
}
} catch (Exception ex) {
LogChannel.GENERAL.logError("Error calling PipelineGraphMouseMoved extension point", ex);
}
//
if (selectedTransform != null && !selectedTransform.isSelected()) {
pipelineMeta.unselectAll();
selectedTransform.setSelected(true);
selectedTransforms = new ArrayList<>();
selectedTransforms.add(selectedTransform);
previousTransformLocations = new Point[] { selectedTransform.getLocation() };
redraw();
} else if (selectedNote != null && !selectedNote.isSelected()) {
pipelineMeta.unselectAll();
selectedNote.setSelected(true);
selectedNotes = new ArrayList<>();
selectedNotes.add(selectedNote);
previousNoteLocations = new Point[] { selectedNote.getLocation() };
redraw();
} else if (selectionRegion != null && startHopTransform == null) {
// Did we select a region...?
//
selectionRegion.width = real.x - selectionRegion.x;
selectionRegion.height = real.y - selectionRegion.y;
redraw();
} else if (selectedTransform != null && lastButton == 1 && !shift && startHopTransform == 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 - selectedTransform.getLocation().x;
int dy = icon.y - selectedTransform.getLocation().y;
// See if we have a hop-split candidate
//
PipelineHopMeta hi = findPipelineHop(icon.x + iconSize / 2, icon.y + iconSize / 2, selectedTransform);
if (hi != null) {
//
if (!hi.getFromTransform().equals(selectedTransform) && !hi.getToTransform().equals(selectedTransform)) {
splitHop = true;
lastHopSplit = hi;
hi.split = true;
}
} else {
if (lastHopSplit != null) {
lastHopSplit.split = false;
lastHopSplit = null;
splitHop = false;
}
}
selectedNotes = pipelineMeta.getSelectedNotes();
selectedTransforms = pipelineMeta.getSelectedTransforms();
// Adjust location of selected transforms...
if (selectedTransforms != null) {
for (int i = 0; i < selectedTransforms.size(); i++) {
TransformMeta transformMeta = selectedTransforms.get(i);
PropsUi.setLocation(transformMeta, transformMeta.getLocation().x + dx, transformMeta.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();
} else if ((startHopTransform != null && endHopTransform == null) || (endHopTransform != null && startHopTransform == null)) {
// Are we creating a new hop with the middle button or pressing SHIFT?
//
TransformMeta transformMeta = pipelineMeta.getTransform(real.x, real.y, iconSize);
endHopLocation = new Point(real.x, real.y);
if (transformMeta != null && ((startHopTransform != null && !startHopTransform.equals(transformMeta)) || (endHopTransform != null && !endHopTransform.equals(transformMeta)))) {
ITransformIOMeta ioMeta = transformMeta.getTransform().getTransformIOMeta();
if (candidate == null) {
//
if (startHopTransform != null) {
if (ioMeta.isInputAcceptor()) {
candidate = new PipelineHopMeta(startHopTransform, transformMeta);
endHopLocation = null;
} else {
noInputTransform = transformMeta;
toolTip.setText("This transform does not accept any input from other transforms");
showToolTip(new org.eclipse.swt.graphics.Point(real.x, real.y));
}
} else if (endHopTransform != null) {
if (ioMeta.isOutputProducer()) {
candidate = new PipelineHopMeta(transformMeta, endHopTransform);
endHopLocation = null;
} else {
noInputTransform = transformMeta;
toolTip.setText("This transform doesn't pass any output to other transforms. (except perhaps for targetted output)");
showToolTip(new org.eclipse.swt.graphics.Point(real.x, real.y));
}
}
}
} else {
if (candidate != null) {
candidate = null;
redraw();
}
}
redraw();
} else {
//
if (viewDrag && lastClick != null) {
dragView(viewDragStart, new Point(e.x, e.y));
}
}
//
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 = pipelineMeta.getSelectedNotes();
selectedTransforms = pipelineMeta.getSelectedTransforms();
// Adjust location of selected transforms...
if (selectedTransforms != null) {
for (int i = 0; i < selectedTransforms.size(); i++) {
TransformMeta transformMeta = selectedTransforms.get(i);
PropsUi.setLocation(transformMeta, transformMeta.getLocation().x + dx, transformMeta.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.apache.hop.ui.hopgui.file.pipeline.extension.HopGuiPipelineGraphExtension in project hop by apache.
the class HopGuiPipelineGraph method mouseDoubleClick.
@Override
public void mouseDoubleClick(MouseEvent e) {
if (!PropsUi.getInstance().useDoubleClick()) {
return;
}
doubleClick = true;
clearSettings();
Point real = screen2real(e.x, e.y);
// Hide the tooltip!
hideToolTips();
AreaOwner areaOwner = getVisibleAreaOwner(real.x, real.y);
try {
HopGuiPipelineGraphExtension ext = new HopGuiPipelineGraphExtension(this, e, real, areaOwner);
ExtensionPointHandler.callExtensionPoint(LogChannel.GENERAL, variables, HopExtensionPoint.PipelineGraphMouseDoubleClick.id, ext);
if (ext.isPreventingDefault()) {
return;
}
} catch (Exception ex) {
LogChannel.GENERAL.logError("Error calling PipelineGraphMouseDoubleClick extension point", ex);
}
TransformMeta transformMeta = pipelineMeta.getTransform(real.x, real.y, iconSize);
if (transformMeta != null) {
if (e.button == 1) {
editTransform(transformMeta);
} else {
editDescription(transformMeta);
}
} else {
// Check if point lies on one of the many hop-lines...
PipelineHopMeta online = findPipelineHop(real.x, real.y);
if (online != null) {
editHop(online);
} else {
NotePadMeta ni = pipelineMeta.getNote(real.x, real.y);
if (ni != null) {
selectedNote = null;
editNote(ni);
} else {
//
if (areaOwner != null && areaOwner.getParent() instanceof TransformMeta && areaOwner.getOwner().equals(PipelinePainter.STRING_PARTITIONING_CURRENT_TRANSFORM)) {
TransformMeta transform = (TransformMeta) areaOwner.getParent();
pipelineTransformDelegate.editTransformPartitioning(pipelineMeta, transform);
} else {
editPipelineProperties(new HopGuiPipelineContext(pipelineMeta, this, real));
}
}
}
}
}
use of org.apache.hop.ui.hopgui.file.pipeline.extension.HopGuiPipelineGraphExtension in project hop by apache.
the class HopGuiPipelineGraph method mouseDown.
@Override
public void mouseDown(MouseEvent e) {
if (EnvironmentUtils.getInstance().isWeb()) {
// RAP does not support certain mouse events.
mouseHover(e);
}
doubleClick = false;
mouseMovedSinceClick = false;
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);
setupDragView(e.button, new Point(e.x, e.y));
// Hide the tooltip!
hideToolTips();
AreaOwner areaOwner = getVisibleAreaOwner(real.x, real.y);
try {
HopGuiPipelineGraphExtension ext = new HopGuiPipelineGraphExtension(this, e, real, areaOwner);
ExtensionPointHandler.callExtensionPoint(LogChannel.GENERAL, variables, HopExtensionPoint.PipelineGraphMouseDown.id, ext);
if (ext.isPreventingDefault()) {
return;
}
} catch (Exception ex) {
LogChannel.GENERAL.logError("Error calling PipelineGraphMouseDown extension point", ex);
}
//
if (areaOwner != null && areaOwner.getAreaType() != null) {
switch(areaOwner.getAreaType()) {
case TRANSFORM_OUTPUT_HOP_ICON:
// Click on the output icon means: start of drag
// Action: We show the input icons on the other transforms...
//
selectedTransform = null;
startHopTransform = (TransformMeta) areaOwner.getParent();
candidateHopType = null;
startErrorHopTransform = false;
break;
case TRANSFORM_INPUT_HOP_ICON:
// Click on the input icon means: start to a new hop
// In this case, we set the end hop transform...
//
selectedTransform = null;
startHopTransform = null;
endHopTransform = (TransformMeta) areaOwner.getParent();
candidateHopType = null;
startErrorHopTransform = false;
break;
case HOP_ERROR_ICON:
// Click on the error icon means: Edit error handling
//
TransformMeta transformMeta = (TransformMeta) areaOwner.getParent();
pipelineTransformDelegate.editTransformErrorHandling(pipelineMeta, transformMeta);
break;
case TRANSFORM_TARGET_HOP_ICON_OPTION:
// Below, see showTransformTargetOptions()
break;
case TRANSFORM_EDIT_ICON:
clearSettings();
currentTransform = (TransformMeta) areaOwner.getParent();
editTransform();
break;
case TRANSFORM_INJECT_ICON:
modalMessageDialog(BaseMessages.getString(PKG, "PipelineGraph.TransformInjectionSupported.Title"), BaseMessages.getString(PKG, "PipelineGraph.TransformInjectionSupported.Tooltip"), SWT.OK | SWT.ICON_INFORMATION);
break;
case TRANSFORM_ICON:
if (shift && control) {
openReferencedObject();
return;
}
transformMeta = (TransformMeta) areaOwner.getOwner();
currentTransform = transformMeta;
for (ITransformSelectionListener listener : currentTransformListeners) {
listener.onUpdateSelection(currentTransform);
}
if (candidate != null) {
addCandidateAsHop(e.x, e.y);
avoidContextDialog = true;
}
//
if (e.button == 1 && alt && transformMeta.supportsErrorHandling()) {
pipelineTransformDelegate.editTransformErrorHandling(pipelineMeta, transformMeta);
return;
} else if (e.button == 1 && startHopTransform != null && endHopTransform == null) {
candidate = new PipelineHopMeta(startHopTransform, currentTransform);
addCandidateAsHop(e.x, e.y);
} else if (e.button == 2 || (e.button == 1 && shift)) {
// SHIFT CLICK is start of drag to create a new hop
//
canvas.setData("mode", "hop");
startHopTransform = transformMeta;
} else {
canvas.setData("mode", "drag");
selectedTransforms = pipelineMeta.getSelectedTransforms();
selectedTransform = transformMeta;
//
// When an icon is moved that is not selected, it gets
// selected too late.
// It is not captured here, but in the mouseMoveListener...
//
previousTransformLocations = pipelineMeta.getSelectedTransformLocations();
Point p = transformMeta.getLocation();
iconOffset = new Point(real.x - p.x, real.y - p.y);
}
redraw();
break;
case NOTE:
ni = (NotePadMeta) areaOwner.getOwner();
selectedNotes = pipelineMeta.getSelectedNotes();
selectedNote = ni;
Point loc = ni.getLocation();
previousNoteLocations = pipelineMeta.getSelectedNoteLocations();
noteOffset = new Point(real.x - loc.x, real.y - loc.y);
redraw();
break;
case TRANSFORM_COPIES_TEXT:
copies((TransformMeta) areaOwner.getOwner());
break;
case TRANSFORM_DATA_SERVICE:
editProperties(pipelineMeta, hopGui, PipelineDialog.Tabs.EXTRA_TAB);
break;
default:
break;
}
} else {
// hop links between steps are found searching by (x,y) coordinates.
PipelineHopMeta hop = findPipelineHop(real.x, real.y);
if (hop != null) {
//
if (e.button == 2 || (e.button == 1 && control)) {
hop.setEnabled(!hop.isEnabled());
updateGui();
} else {
// A hop: show context dialog in mouseUp()
//
clickedPipelineHop = hop;
}
} else {
// No area-owner & no hop means : background click:
//
canvas.setData("mode", "select");
startHopTransform = null;
if (!control && e.button == 1) {
selectionRegion = new org.apache.hop.core.gui.Rectangle(real.x, real.y, 0, 0);
}
updateGui();
}
}
if (EnvironmentUtils.getInstance().isWeb()) {
// RAP does not support certain mouse events.
mouseMove(e);
}
}
use of org.apache.hop.ui.hopgui.file.pipeline.extension.HopGuiPipelineGraphExtension in project hop by apache.
the class HopGuiPipelineGraph method mouseUp.
@Override
public void mouseUp(MouseEvent e) {
// canvas.setData("mode", null); does not work.
canvas.setData("mode", "null");
if (EnvironmentUtils.getInstance().isWeb()) {
// RAP does not support certain mouse events.
mouseMove(e);
}
boolean control = (e.stateMask & SWT.MOD1) != 0;
PipelineHopMeta selectedHop = findPipelineHop(e.x, e.y);
updateErrorMetaForHop(selectedHop);
boolean singleClick = false;
viewDrag = false;
viewDragStart = null;
SingleClickType singleClickType = null;
TransformMeta singleClickTransform = null;
NotePadMeta singleClickNote = null;
PipelineHopMeta singleClickHop = null;
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 {
HopGuiPipelineGraphExtension ext = new HopGuiPipelineGraphExtension(this, e, real, areaOwner);
ExtensionPointHandler.callExtensionPoint(LogChannel.GENERAL, variables, HopExtensionPoint.PipelineGraphMouseUp.id, ext);
if (ext.isPreventingDefault()) {
redraw();
clearSettings();
return;
}
} catch (Exception ex) {
LogChannel.GENERAL.logError("Error calling PipelineGraphMouseUp extension point", ex);
}
//
if (areaOwner != null && areaOwner.getAreaType() != null) {
switch(areaOwner.getAreaType()) {
case TRANSFORM_OUTPUT_DATA:
if ((!mouseMovedSinceClick || EnvironmentUtils.getInstance().isWeb()) && showTransformOutputData(areaOwner)) {
return;
}
break;
case TRANSFORM_ICON:
if (startHopTransform != null) {
// Mouse up while dragging around a hop candidate
//
currentTransform = (TransformMeta) areaOwner.getOwner();
candidate = new PipelineHopMeta(startHopTransform, currentTransform);
addCandidateAsHop(e.x, e.y);
redraw();
return;
}
break;
case TRANSFORM_NAME:
if (startHopTransform == null && selectionRegion == null && selectedTransforms == null && selectedNotes == null) {
// This is available only in single click mode...
//
startHopTransform = null;
selectionRegion = null;
TransformMeta transformMeta = (TransformMeta) areaOwner.getParent();
editTransform(transformMeta);
}
return;
default:
break;
}
}
//
if (selectionRegion != null) {
selectionRegion.width = real.x - selectionRegion.x;
selectionRegion.height = real.y - selectionRegion.y;
if (selectionRegion.isEmpty()) {
singleClick = true;
singleClickType = SingleClickType.Pipeline;
} else {
pipelineMeta.unselectAll();
selectInRect(pipelineMeta, selectionRegion);
}
selectionRegion = null;
avoidScrollAdjusting = true;
updateGui();
} else {
//
if (selectedTransform != null && startHopTransform == 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) {
selectedTransform.flipSelected();
} else {
singleClick = true;
singleClickType = SingleClickType.Transform;
singleClickTransform = selectedTransform;
}
} else {
// Find out which Transforms & Notes are selected
selectedTransforms = pipelineMeta.getSelectedTransforms();
selectedNotes = pipelineMeta.getSelectedNotes();
// We moved around some items: store undo info...
//
boolean also = false;
if (selectedNotes != null && selectedNotes.size() > 0 && previousNoteLocations != null) {
int[] indexes = pipelineMeta.getNoteIndexes(selectedNotes);
also = selectedTransforms != null && selectedTransforms.size() > 0;
hopGui.undoDelegate.addUndoPosition(pipelineMeta, selectedNotes.toArray(new NotePadMeta[selectedNotes.size()]), indexes, previousNoteLocations, pipelineMeta.getSelectedNoteLocations(), also);
}
if (selectedTransforms != null && previousTransformLocations != null) {
int[] indexes = pipelineMeta.getTransformIndexes(selectedTransforms);
hopGui.undoDelegate.addUndoPosition(pipelineMeta, selectedTransforms.toArray(new TransformMeta[selectedTransforms.size()]), indexes, previousTransformLocations, pipelineMeta.getSelectedTransformLocations(), also);
}
}
}
// If so, ask to split the hop!
if (splitHop) {
PipelineHopMeta hi = findPipelineHop(icon.x + iconSize / 2, icon.y + iconSize / 2, selectedTransform);
if (hi != null) {
splitHop(hi);
}
splitHop = false;
}
selectedTransforms = null;
selectedNotes = null;
selectedTransform = null;
selectedNote = null;
startHopTransform = null;
endHopLocation = null;
avoidScrollAdjusting = true;
updateGui();
} else {
if (selectedNote != null) {
if (e.button == 1) {
if (lastClick.x == real.x && lastClick.y == real.y) {
// Flip selection when control is pressed!
if (control) {
selectedNote.flipSelected();
} else {
// single click on a note: ask what needs to happen...
//
singleClick = true;
singleClickType = SingleClickType.Note;
singleClickNote = selectedNote;
}
} else {
// Find out which Transforms & Notes are selected
selectedTransforms = pipelineMeta.getSelectedTransforms();
selectedNotes = pipelineMeta.getSelectedNotes();
// We moved around some items: store undo info...
boolean also = false;
if (selectedNotes != null && selectedNotes.size() > 0 && previousNoteLocations != null) {
int[] indexes = pipelineMeta.getNoteIndexes(selectedNotes);
hopGui.undoDelegate.addUndoPosition(pipelineMeta, selectedNotes.toArray(new NotePadMeta[selectedNotes.size()]), indexes, previousNoteLocations, pipelineMeta.getSelectedNoteLocations(), also);
also = selectedTransforms != null && selectedTransforms.size() > 0;
}
if (selectedTransforms != null && selectedTransforms.size() > 0 && previousTransformLocations != null) {
int[] indexes = pipelineMeta.getTransformIndexes(selectedTransforms);
hopGui.undoDelegate.addUndoPosition(pipelineMeta, selectedTransforms.toArray(new TransformMeta[selectedTransforms.size()]), indexes, previousTransformLocations, pipelineMeta.getSelectedTransformLocations(), also);
}
}
}
selectedNotes = null;
selectedTransforms = null;
selectedTransform = null;
selectedNote = null;
startHopTransform = null;
endHopLocation = null;
}
}
}
if (avoidContextDialog) {
avoidContextDialog = false;
selectionRegion = null;
return;
}
if (clickedPipelineHop != null) {
// Clicked on a hop
//
singleClick = true;
singleClickType = SingleClickType.Hop;
singleClickHop = clickedPipelineHop;
}
clickedPipelineHop = null;
// Only do this "mouseUp()" if this is not part of a double click...
//
final boolean fSingleClick = singleClick;
final SingleClickType fSingleClickType = singleClickType;
final TransformMeta fSingleClickTransform = singleClickTransform;
final NotePadMeta fSingleClickNote = singleClickNote;
final PipelineHopMeta fSingleClickHop = singleClickHop;
if (PropsUi.getInstance().useDoubleClick()) {
Display.getDefault().timerExec(Display.getDefault().getDoubleClickTime(), () -> showActionDialog(e, real, fSingleClick, fSingleClickType, fSingleClickTransform, fSingleClickNote, fSingleClickHop));
} else {
showActionDialog(e, real, fSingleClick, fSingleClickType, fSingleClickTransform, fSingleClickNote, fSingleClickHop);
}
lastButton = 0;
}
Aggregations