public void mouseMove()

in ui/src/main/java/org/apache/hop/ui/hopgui/file/pipeline/HopGuiPipelineGraph.java [1360:1592]


  public void mouseMove(MouseEvent event) {
    boolean shift = (event.stateMask & SWT.SHIFT) != 0;
    noInputTransform = null;
    mouseMovedSinceClick = true;
    boolean doRedraw = false;
    PipelineHopMeta hop = null;

    // disable the tooltip
    //
    toolTip.setVisible(false);

    // Check to see if we're navigating with the view port
    //
    if (viewPortNavigation) {
      dragViewPort(new Point(event.x, event.y));
      return;
    }

    Point real = screen2real(event.x, event.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);

    // Moved over an hop?
    //
    if (areaOwner == null) {
      hop = this.findPipelineHop(real.x, real.y);
    }

    try {
      HopGuiPipelineGraphExtension ext =
          new HopGuiPipelineGraphExtension(this, event, 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);
    }

    // Mouse over the name of the transform
    //
    if (!PropsUi.getInstance().useDoubleClick()) {
      if (areaOwner != null && areaOwner.getAreaType() == AreaType.TRANSFORM_NAME) {
        if (mouseOverName == null) {
          doRedraw = true;
        }
        mouseOverName = (String) areaOwner.getOwner();
      } else {
        if (mouseOverName != null) {
          doRedraw = true;
        }
        mouseOverName = null;
      }
    }

    //
    // First see if the icon we clicked on was selected.
    // If the icon was not selected, we should un-select all other
    // icons, selected and move only the one icon
    //
    if (selectedTransform != null && !selectedTransform.isSelected()) {
      pipelineMeta.unselectAll();
      selectedTransform.setSelected(true);
      selectedTransforms = new ArrayList<>();
      selectedTransforms.add(selectedTransform);
      previousTransformLocations = new Point[] {selectedTransform.getLocation()};
      doRedraw = true;
    } else if (selectedNote != null && !selectedNote.isSelected()) {
      pipelineMeta.unselectAll();
      selectedNote.setSelected(true);
      selectedNotes = new ArrayList<>();
      selectedNotes.add(selectedNote);
      previousNoteLocations = new Point[] {selectedNote.getLocation()};
      doRedraw = true;
    } else if (selectionRegion != null && startHopTransform == null) {
      // Did we select a region...?
      //
      selectionRegion.width = real.x - selectionRegion.x;
      selectionRegion.height = real.y - selectionRegion.y;
      doRedraw = true;
    } 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) {
        // OK, we want to split the hop in 2

        // Check if we can split A-->--B and insert the selected transform C if
        // C-->--A or C-->--B or A-->--C or B-->--C don't exists...
        //
        if (pipelineMeta.findPipelineHop(selectedTransform, hi.getFromTransform()) == null
            && pipelineMeta.findPipelineHop(selectedTransform, hi.getToTransform()) == null
            && pipelineMeta.findPipelineHop(hi.getToTransform(), selectedTransform) == null
            && pipelineMeta.findPipelineHop(hi.getFromTransform(), selectedTransform) == null) {
          splitHop = true;
          lastHopSplit = hi;
          hi.split = true;
        }
      } else {
        if (lastHopSplit != null) {
          lastHopSplit.split = false;
          lastHopSplit = null;
          splitHop = false;
        }
      }

      moveSelected(dx, dy);

      doRedraw = true;
    } 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) {
          // See if the transform accepts input. If not, we can't create a new hop...
          //
          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;
          doRedraw = true;
        }
      }

      doRedraw = true;
    } else {
      // Drag the view around with middle button on the background?
      //
      if (viewDrag && lastClick != null) {
        dragView(viewDragStart, new Point(event.x, event.y));
      }
    }

    // Move around notes & transforms
    //
    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;

        moveSelected(dx, dy);

        doRedraw = true;
      }
    }

    Cursor cursor = null;
    // Change cursor when dragging view or view port
    if (viewDrag || viewPortNavigation) {
      cursor = getDisplay().getSystemCursor(SWT.CURSOR_SIZEALL);
    }
    // Change cursor when selecting a region
    else if (selectionRegion != null) {
      cursor = getDisplay().getSystemCursor(SWT.CURSOR_CROSS);
    }
    // Change cursor when hover an hop or an area that support hover
    else if (hop != null
        || (areaOwner != null
            && areaOwner.getAreaType() != null
            && areaOwner.getAreaType().isSupportHover())) {
      cursor = getDisplay().getSystemCursor(SWT.CURSOR_HAND);
    }
    setCursor(cursor);

    if (doRedraw) {
      redraw();
    }
  }