Java Code Examples for java.awt.event.MouseEvent#isConsumed()

The following examples show how to use java.awt.event.MouseEvent#isConsumed() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may want to check out the right sidebar which shows the related API usage.
Example 1
Source Project: consulo   File: mxInsertHandler.java    License: Apache License 2.0 6 votes vote down vote up
/**
 *
 */
public void mouseReleased(MouseEvent e) {
  if (graphComponent.isEnabled() && isEnabled() && !e.isConsumed() && current != null) {
    mxGraph graph = graphComponent.getGraph();
    double scale = graph.getView().getScale();
    mxPoint tr = graph.getView().getTranslate();
    current.setX(current.getX() / scale - tr.getX());
    current.setY(current.getY() / scale - tr.getY());
    current.setWidth(current.getWidth() / scale);
    current.setHeight(current.getHeight() / scale);

    Object cell = insertCell(current);
    eventSource.fireEvent(new mxEventObject(mxEvent.INSERT, "cell", cell));
    e.consume();
  }

  reset();
}
 
Example 2
Source Project: consulo   File: WindowMoveListener.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void mouseClicked(MouseEvent event) {
  if (event.isConsumed()) return;
  if (BUTTON1_MASK == (BUTTON1_MASK & event.getModifiers()) && 1 < event.getClickCount()) {
    Component view = getView(getContent(event));
    if (view instanceof Frame) {
      Frame frame = (Frame)view;
      int state = frame.getExtendedState();
      if (!isStateSet(Frame.ICONIFIED, state) && frame.isResizable()) {
        event.consume();
        frame.setExtendedState(isStateSet(Frame.MAXIMIZED_BOTH, state) ? (state & ~Frame.MAXIMIZED_BOTH) : (state | Frame.MAXIMIZED_BOTH));
      }
    }
  }
  super.mouseClicked(event);
}
 
Example 3
@Override
public void mouseMoved(MouseEvent e) {
  if (listener_mouse_motion == null) return;

  if (Replay.isRecording) {
    Replay.dumpMouseInput(
        Replay.MOUSE_MOVED,
        e.getX(),
        e.getY(),
        0,
        e.getModifiers(),
        e.getClickCount(),
        0,
        0,
        e.isPopupTrigger(),
        e.getButton());
  }

  if (!e.isConsumed()) {
    x = e.getX();
    y = e.getY();
    listener_mouse_motion.mouseMoved(e);
  }
}
 
Example 4
@Override
public void mouseReleased ( @NotNull final MouseEvent e )
{
    if ( !e.isConsumed () && SwingUtilities.isLeftMouseButton ( e ) && resizing )
    {
        final int cursor = getCursor ( e.getPoint () );
        if ( cursor != -1 )
        {
            e.getComponent ().setCursor ( Cursor.getPredefinedCursor ( cursor ) );
        }
        else if ( initialCursor != null )
        {
            e.getComponent ().setCursor ( initialCursor );
            initialCursor = null;
        }

        resizing = false;
        initialPoint = null;
        initialBounds = null;
        currentDirection = null;

        // Consume event
        e.consume ();
    }
}
 
Example 5
Source Project: consulo   File: mxConnectionHandler.java    License: Apache License 2.0 5 votes vote down vote up
/**
 *
 */
public void mousePressed(MouseEvent e) {
  if (!graphComponent.isForceMarqueeEvent(e) &&
      !graphComponent.isPanningEvent(e) &&
      !e.isPopupTrigger() &&
      graphComponent.isEnabled() &&
      isEnabled() &&
      !e.isConsumed() &&
      ((isHighlighting() && marker.hasValidState()) || (!isHighlighting() && bounds != null && bounds.contains(e.getPoint())))) {
    start(e, marker.getValidState());
    e.consume();
  }
}
 
Example 6
Source Project: blog-codes   File: mxGraphOutline.java    License: Apache License 2.0 5 votes vote down vote up
public void mousePressed(MouseEvent e)
{
	zoomGesture = hitZoomHandle(e.getX(), e.getY());

	if (graphComponent != null && !e.isConsumed()
			&& !e.isPopupTrigger()
			&& (finderBounds.contains(e.getPoint()) || zoomGesture))
	{
		start = e.getPoint();
	}
}
 
Example 7
@Override
public void mouseReleased(MouseEvent e) {
  if (inConsumableButton()) {
    e.consume();
  }
  if (listener_mouse == null) return;

  if (Replay.isRecording) {
    Replay.dumpMouseInput(
        Replay.MOUSE_RELEASED,
        e.getX(),
        e.getY(),
        0,
        e.getModifiers(),
        e.getClickCount(),
        0,
        0,
        e.isPopupTrigger(),
        e.getButton());
  }

  if (e.getButton() == MouseEvent.BUTTON2) {
    m_rotating = false;
    e.consume();
  }

  if (!e.isConsumed()) {
    x = e.getX();
    y = e.getY();
    listener_mouse.mouseReleased(e);
  }
}
 
Example 8
Source Project: blog-codes   File: mxInsertHandler.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 
 */
public void mouseDragged(MouseEvent e)
{
	if (graphComponent.isEnabled() && isEnabled() && !e.isConsumed()
			&& first != null)
	{
		mxRectangle dirty = current;

		current = new mxRectangle(first.x, first.y, 0, 0);
		current.add(new mxRectangle(e.getX(), e.getY(), 0, 0));

		if (dirty != null)
		{
			dirty.add(current);
		}
		else
		{
			dirty = current;
		}

		Rectangle tmp = dirty.getRectangle();
		int b = (int) Math.ceil(lineWidth);
		graphComponent.getGraphControl().repaint(tmp.x - b, tmp.y - b,
				tmp.width + 2 * b, tmp.height + 2 * b);

		e.consume();
	}
}
 
Example 9
Source Project: wpcleaner   File: PageListMouseListener.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * @param e Event.
 * @see java.awt.event.MouseAdapter#mouseClicked(java.awt.event.MouseEvent)
 */
@Override
public void mouseClicked(MouseEvent e) {
  if ((!e.isConsumed()) &&
      (e.getButton() == MouseEvent.BUTTON1) &&
      (e.getClickCount() == 2)) {
    if (e.getSource() instanceof JTable) {
      JTable table = (JTable) e.getSource();
      if (table.getModel() instanceof PageListTableModel) {
        PageListTableModel model = (PageListTableModel) table.getModel();
        int column = table.columnAtPoint(e.getPoint());
        int row = table.rowAtPoint(e.getPoint());
        if ((column >= 0) && (row >= 0)) {
          row = Utilities.convertRowIndexToModel(table, row);
          Page page = model.getPage(row);
          if (Boolean.TRUE.equals(page.isDisambiguationPage())) {
            Controller.runDisambiguationAnalysis(page.getTitle(), page.getWikipedia());
          } else {
            Controller.runFullAnalysis(page.getTitle(), null, page.getWikipedia());
          }
          e.consume();
        }
      }
    }
  }
  super.mouseClicked(e);
}
 
Example 10
void showTopTermsContextMenu(MouseEvent e) {
  if (e.getClickCount() == 2 && !e.isConsumed()) {
    int row = topTermsTable.rowAtPoint(e.getPoint());
    if (row != topTermsTable.getSelectedRow()) {
      topTermsTable.changeSelection(row, topTermsTable.getSelectedColumn(), false, false);
    }
    topTermsContextMenu.show(e.getComponent(), e.getX(), e.getY());
  }
}
 
Example 11
Source Project: consulo   File: mxSelectionCellsHandler.java    License: Apache License 2.0 5 votes vote down vote up
/**
 *
 */
public void mouseMoved(MouseEvent e) {
  if (graphComponent.isEnabled() && isEnabled()) {
    Iterator<mxCellHandler> it = handlers.values().iterator();

    while (it.hasNext() && !e.isConsumed()) {
      it.next().mouseMoved(e);
    }
  }
}
 
Example 12
Source Project: consulo   File: mxRotationHandler.java    License: Apache License 2.0 5 votes vote down vote up
/**
 *
 */
public void mouseReleased(MouseEvent e) {
  if (graphComponent.isEnabled() && isEnabled() && !e.isConsumed() && first != null) {
    double deg = 0;
    Object cell = null;

    if (currentState != null) {
      cell = currentState.getCell();
                              /*deg = mxUtils.getDouble(currentState.getStyle(),
				mxConstants.STYLE_ROTATION);*/
    }

    deg += currentAngle * mxConstants.DEG_PER_RAD;
    boolean willExecute = cell != null && first != null;

    // TODO: Call reset before execute in all handlers that
    // offer an execute method
    reset();

    if (graphComponent.isEnabled() && isEnabled() && !e.isConsumed() && willExecute) {
      graphComponent.getGraph().setCellStyles(mxConstants.STYLE_ROTATION, String.valueOf(deg), new Object[]{cell});

      graphComponent.getGraphControl().repaint();

      e.consume();
    }
  }

  currentState = null;
}
 
Example 13
void showAttributeValues(MouseEvent e) {
  if (e.getClickCount() != 2 || e.isConsumed()) {
    return;
  }
  int rowIndex = namedTokensTable.rowAtPoint(e.getPoint());
  int columnIndex = namedTokensTable.columnAtPoint(e.getPoint());
  if (rowIndex < 0 || rowIndex >= namedTokensTable.getRowCount()) {
    return;
  } else if (columnIndex < 0 || columnIndex >= namedTokensTable.getColumnCount()) {
    return;
  }
  StepByStepAnalyzeResultPanelProvider.this.showAttributeValues(rowIndex, columnIndex);
}
 
Example 14
void showDocumentContextMenu(MouseEvent e) {
  if (e.getClickCount() == 2 && !e.isConsumed()) {
    int row = documentTable.rowAtPoint(e.getPoint());
    if (row != documentTable.getSelectedRow()) {
      documentTable.changeSelection(row, documentTable.getSelectedColumn(), false, false);
    }
    documentContextMenu.show(e.getComponent(), e.getX(), e.getY());
  }
}
 
Example 15
protected void processMouseEvent(MouseEvent e) {
    if (processMouseEvents()) header.processMouseEvent(e);
    if (!e.isConsumed()) super.processMouseEvent(e);
}
 
Example 16
Source Project: netbeans   File: StayOpenPopupMenu.java    License: Apache License 2.0 4 votes vote down vote up
protected void processMouseEvent(MouseEvent e) {
    performAction(this, e);
    if (!e.isConsumed()) super.processMouseEvent(e);
}
 
Example 17
protected void processMouseEvent(MouseEvent e) {
    if (processMouseEvents()) header.processMouseEvent(e);
    if (!e.isConsumed()) super.processMouseEvent(e);
}
 
Example 18
Source Project: Bytecoder   File: SwingUtilities2.java    License: Apache License 2.0 4 votes vote down vote up
/**
 * Ignore mouse events if the component is null, not enabled, the event
 * is not associated with the left mouse button, or the event has been
 * consumed.
 */
public static boolean shouldIgnore(MouseEvent me, JComponent c) {
    return c == null || !c.isEnabled()
                     || !SwingUtilities.isLeftMouseButton(me)
                     || me.isConsumed();
}
 
Example 19
Source Project: consulo   File: mxEdgeHandler.java    License: Apache License 2.0 4 votes vote down vote up
/**
 *
 */
public void mouseReleased(MouseEvent e) {
  mxGraph graph = graphComponent.getGraph();

  if (!e.isConsumed() && first != null) {
    double dx = e.getX() - first.x;
    double dy = e.getY() - first.y;

    if (graphComponent.isSignificant(dx, dy)) {
      if (error != null) {
        if (error.length() > 0) {
          JOptionPane.showMessageDialog(graphComponent, error);
        }
      }
      else if (isLabel(index)) {
        mxPoint abs = state.getAbsoluteOffset();
        dx = abs.getX() - first.x;
        dy = abs.getY() - first.y;

        mxPoint pt = new mxPoint(e.getPoint());

        if (gridEnabledEvent) {
          pt = graphComponent.snapScaledPoint(pt, dx, dy);
        }

        if (constrainedEvent) {
          if (Math.abs(e.getX() - first.x) > Math.abs(e.getY() - first.y)) {
            pt.setY(abs.getY());
          }
          else {
            pt.setX(abs.getX());
          }
        }

        moveLabelTo(state, pt.getX() + dx, pt.getY() + dy);
      }
      else if (marker.hasValidState() && (isSource(index) || isTarget(index))) {
        connect(state.getCell(), marker.getValidState().getCell(), isSource(index), graphComponent.isCloneEvent(e) && isCloneEnabled());
      }
      else if ((!isSource(index) && !isTarget(index)) || graphComponent.getGraph().isAllowDanglingEdges()) {
        movePoint(state.getCell(), index, convertPoint(new mxPoint(e.getPoint()), gridEnabledEvent));
      }

      e.consume();
    }
  }

  if (!e.isConsumed() && isFlipEvent(e)) {
    graph.flipEdge(state.getCell());
    e.consume();
  }

  super.mouseReleased(e);
}
 
Example 20
Source Project: lucene-solr   File: SearchPanelProvider.java    License: Apache License 2.0 4 votes vote down vote up
void showContextMenuInResultsTable(MouseEvent e) {
  if (e.getClickCount() == 2 && !e.isConsumed()) {
    SearchPanelProvider.this.setupResultsContextMenuPopup().show(e.getComponent(), e.getX(), e.getY());
    setupResultsContextMenuPopup().show(e.getComponent(), e.getX(), e.getY());
  }
}