Java Code Examples for sun.swing.SwingUtilities2#shouldIgnore()

The following examples show how to use sun.swing.SwingUtilities2#shouldIgnore() . 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 check out the related API usage on the sidebar.
Example 1
Source File: BasicListUI.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
public void mouseReleased(MouseEvent e) {
    if (SwingUtilities2.shouldIgnore(e, list)) {
        return;
    }

    if (list.getDragEnabled()) {
        MouseEvent me = DragRecognitionSupport.mouseReleased(e);
        if (me != null) {
            SwingUtilities2.adjustFocus(list);
            if (!dragPressDidSelection) {
                adjustSelection(me);
            }
        }
    } else {
        list.setValueIsAdjusting(false);
    }
}
 
Example 2
Source File: BasicTreeUI.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Invoked when a mouse button has been pressed on a component.
 */
public void mousePressed(MouseEvent e) {
    if (SwingUtilities2.shouldIgnore(e, tree)) {
        return;
    }

    // if we can't stop any ongoing editing, do nothing
    if (isEditing(tree) && tree.getInvokesStopCellEditing()
                        && !stopEditing(tree)) {
        return;
    }

    completeEditing();

    pressedPath = getClosestPathForLocation(tree, e.getX(), e.getY());

    if (tree.getDragEnabled()) {
        mousePressedDND(e);
    } else {
        SwingUtilities2.adjustFocus(tree);
        handleSelection(e);
    }
}
 
Example 3
Source File: TableUIBridge.java    From darklaf with MIT License 6 votes vote down vote up
public void mouseReleased(final MouseEvent e) {
    if (SwingUtilities2.shouldIgnore(e, table)) {
        return;
    }

    if (table.getDragEnabled()) {
        mouseReleasedDND(e);
    } else {
        if (isFileList) {
            maybeStartTimer();
        }
    }

    pressedEvent = null;
    repostEvent(e);
    dispatchComponent = null;
    setValueIsAdjusting(false);
}
 
Example 4
Source File: BasicTableUI.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
public void mouseReleased(MouseEvent e) {
    if (SwingUtilities2.shouldIgnore(e, table)) {
        return;
    }

    if (table.getDragEnabled()) {
        mouseReleasedDND(e);
    } else {
        if (isFileList) {
            maybeStartTimer();
        }
    }

    pressedEvent = null;
    repostEvent(e);
    dispatchComponent = null;
    setValueIsAdjusting(false);
}
 
Example 5
Source File: BasicListUI.java    From Java8CN with Apache License 2.0 6 votes vote down vote up
public void mouseReleased(MouseEvent e) {
    if (SwingUtilities2.shouldIgnore(e, list)) {
        return;
    }

    if (list.getDragEnabled()) {
        MouseEvent me = DragRecognitionSupport.mouseReleased(e);
        if (me != null) {
            SwingUtilities2.adjustFocus(list);
            if (!dragPressDidSelection) {
                adjustSelection(me);
            }
        }
    } else {
        list.setValueIsAdjusting(false);
    }
}
 
Example 6
Source File: BasicTableUI.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
public void mouseReleased(MouseEvent e) {
    if (SwingUtilities2.shouldIgnore(e, table)) {
        return;
    }

    if (table.getDragEnabled()) {
        mouseReleasedDND(e);
    } else {
        if (isFileList) {
            maybeStartTimer();
        }
    }

    pressedEvent = null;
    repostEvent(e);
    dispatchComponent = null;
    setValueIsAdjusting(false);
}
 
Example 7
Source File: BasicTableUI.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public void mouseDragged(MouseEvent e) {
    if (SwingUtilities2.shouldIgnore(e, table)) {
        return;
    }

    if (table.getDragEnabled() &&
            (DragRecognitionSupport.mouseDragged(e, this) || dragStarted)) {

        return;
    }

    repostEvent(e);

    // Check isFileList:
    // Until we support drag-selection, dragging should not change
    // the selection (act like single-select).
    if (isFileList || table.isEditing()) {
        return;
    }

    Point p = e.getPoint();
    int row = table.rowAtPoint(p);
    int column = table.columnAtPoint(p);
    // The autoscroller can generate drag events outside the
    // table's range.
    if ((column == -1) || (row == -1)) {
        return;
    }

    table.changeSelection(row, column,
            BasicGraphicsUtils.isMenuShortcutKeyDown(e), true);
}
 
Example 8
Source File: BasicListUI.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public void mouseDragged(MouseEvent e) {
    if (SwingUtilities2.shouldIgnore(e, list)) {
        return;
    }

    if (list.getDragEnabled()) {
        DragRecognitionSupport.mouseDragged(e, this);
        return;
    }

    if (e.isShiftDown() || BasicGraphicsUtils.isMenuShortcutKeyDown(e)) {
        return;
    }

    int row = locationToIndex(list, e.getPoint());
    if (row != -1) {
        // 4835633.  Dragging onto a File should not select it.
        if (isFileList) {
            return;
        }
        Rectangle cellBounds = getCellBounds(list, row, row);
        if (cellBounds != null) {
            list.scrollRectToVisible(cellBounds);
            list.setSelectionInterval(row, row);
        }
    }
}
 
Example 9
Source File: BasicTreeUI.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public void mouseReleased(MouseEvent e) {
    if (SwingUtilities2.shouldIgnore(e, tree)) {
        return;
    }

    if (tree.getDragEnabled()) {
        mouseReleasedDND(e);
    }

    pressedEvent = null;
    pressedPath = null;
}
 
Example 10
Source File: BasicTreeUI.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public void mouseReleased(MouseEvent e) {
    if (SwingUtilities2.shouldIgnore(e, tree)) {
        return;
    }

    if (tree.getDragEnabled()) {
        mouseReleasedDND(e);
    }

    pressedEvent = null;
    pressedPath = null;
}
 
Example 11
Source File: BasicListUI.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
public void mouseDragged(MouseEvent e) {
    if (SwingUtilities2.shouldIgnore(e, list)) {
        return;
    }

    if (list.getDragEnabled()) {
        DragRecognitionSupport.mouseDragged(e, this);
        return;
    }

    if (e.isShiftDown() || BasicGraphicsUtils.isMenuShortcutKeyDown(e)) {
        return;
    }

    int row = locationToIndex(list, e.getPoint());
    if (row != -1) {
        // 4835633.  Dragging onto a File should not select it.
        if (isFileList) {
            return;
        }
        Rectangle cellBounds = getCellBounds(list, row, row);
        if (cellBounds != null) {
            list.scrollRectToVisible(cellBounds);
            list.setSelectionInterval(row, row);
        }
    }
}
 
Example 12
Source File: BasicTableUI.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public void mouseDragged(MouseEvent e) {
    if (SwingUtilities2.shouldIgnore(e, table)) {
        return;
    }

    if (table.getDragEnabled() &&
            (DragRecognitionSupport.mouseDragged(e, this) || dragStarted)) {

        return;
    }

    repostEvent(e);

    // Check isFileList:
    // Until we support drag-selection, dragging should not change
    // the selection (act like single-select).
    if (isFileList || table.isEditing()) {
        return;
    }

    Point p = e.getPoint();
    int row = table.rowAtPoint(p);
    int column = table.columnAtPoint(p);
    // The autoscroller can generate drag events outside the
    // table's range.
    if ((column == -1) || (row == -1)) {
        return;
    }

    table.changeSelection(row, column,
            BasicGraphicsUtils.isMenuShortcutKeyDown(e), true);
}
 
Example 13
Source File: BasicTreeUI.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
public void mouseDragged(MouseEvent e) {
    if (SwingUtilities2.shouldIgnore(e, tree)) {
        return;
    }

    if (tree.getDragEnabled()) {
        DragRecognitionSupport.mouseDragged(e, this);
    }
}
 
Example 14
Source File: BasicTreeUI.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
public void mouseReleased(MouseEvent e) {
    if (SwingUtilities2.shouldIgnore(e, tree)) {
        return;
    }

    if (tree.getDragEnabled()) {
        mouseReleasedDND(e);
    }

    pressedEvent = null;
    pressedPath = null;
}
 
Example 15
Source File: BasicListUI.java    From Java8CN with Apache License 2.0 5 votes vote down vote up
public void mouseDragged(MouseEvent e) {
    if (SwingUtilities2.shouldIgnore(e, list)) {
        return;
    }

    if (list.getDragEnabled()) {
        DragRecognitionSupport.mouseDragged(e, this);
        return;
    }

    if (e.isShiftDown() || BasicGraphicsUtils.isMenuShortcutKeyDown(e)) {
        return;
    }

    int row = locationToIndex(list, e.getPoint());
    if (row != -1) {
        // 4835633.  Dragging onto a File should not select it.
        if (isFileList) {
            return;
        }
        Rectangle cellBounds = getCellBounds(list, row, row);
        if (cellBounds != null) {
            list.scrollRectToVisible(cellBounds);
            list.setSelectionInterval(row, row);
        }
    }
}
 
Example 16
Source File: BasicTableUI.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
public void mousePressed(MouseEvent e) {
    if (SwingUtilities2.shouldIgnore(e, table)) {
        return;
    }

    if (table.isEditing() && !table.getCellEditor().stopCellEditing()) {
        Component editorComponent = table.getEditorComponent();
        if (editorComponent != null && !editorComponent.hasFocus()) {
            SwingUtilities2.compositeRequestFocus(editorComponent);
        }
        return;
    }

    Point p = e.getPoint();
    pressedRow = table.rowAtPoint(p);
    pressedCol = table.columnAtPoint(p);
    outsidePrefSize = pointOutsidePrefSize(pressedRow, pressedCol, p);

    if (isFileList) {
        shouldStartTimer =
            table.isCellSelected(pressedRow, pressedCol) &&
            !e.isShiftDown() &&
            !BasicGraphicsUtils.isMenuShortcutKeyDown(e) &&
            !outsidePrefSize;
    }

    if (table.getDragEnabled()) {
        mousePressedDND(e);
    } else {
        SwingUtilities2.adjustFocus(table);
        if (!isFileList) {
            setValueIsAdjusting(true);
        }
        adjustSelection(e);
    }
}
 
Example 17
Source File: BasicTableUI.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public void mouseDragged(MouseEvent e) {
    if (SwingUtilities2.shouldIgnore(e, table)) {
        return;
    }

    if (table.getDragEnabled() &&
            (DragRecognitionSupport.mouseDragged(e, this) || dragStarted)) {

        return;
    }

    repostEvent(e);

    // Check isFileList:
    // Until we support drag-selection, dragging should not change
    // the selection (act like single-select).
    if (isFileList || table.isEditing()) {
        return;
    }

    Point p = e.getPoint();
    int row = table.rowAtPoint(p);
    int column = table.columnAtPoint(p);
    // The autoscroller can generate drag events outside the
    // table's range.
    if ((column == -1) || (row == -1)) {
        return;
    }

    table.changeSelection(row, column,
            BasicGraphicsUtils.isMenuShortcutKeyDown(e), true);
}
 
Example 18
Source File: DarkListUIBridge.java    From darklaf with MIT License 5 votes vote down vote up
public void mouseDragged(final MouseEvent e) {
    if (SwingUtilities2.shouldIgnore(e, list)) {
        return;
    }

    if (list.getDragEnabled()) {
        DragRecognitionSupport.mouseDragged(e, this);
        return;
    }

    if (e.isShiftDown() || DarkUIUtil.isMenuShortcutKeyDown(e)) {
        return;
    }

    int row = locationToIndex(list, e.getPoint());
    if (row != -1) {
        // 4835633. Dragging onto a File should not select it.
        if (isFileList) {
            return;
        }
        Rectangle cellBounds = getCellBounds(list, row, row);
        if (cellBounds != null) {
            list.scrollRectToVisible(cellBounds);
            list.setSelectionInterval(row, row);
        }
    }
}
 
Example 19
Source File: BasicListUI.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
public void mousePressed(MouseEvent e) {
    if (SwingUtilities2.shouldIgnore(e, list)) {
        return;
    }

    boolean dragEnabled = list.getDragEnabled();
    boolean grabFocus = true;

    // different behavior if drag is enabled
    if (dragEnabled) {
        int row = SwingUtilities2.loc2IndexFileList(list, e.getPoint());
        // if we have a valid row and this is a drag initiating event
        if (row != -1 && DragRecognitionSupport.mousePressed(e)) {
            dragPressDidSelection = false;

            if (BasicGraphicsUtils.isMenuShortcutKeyDown(e)) {
                // do nothing for control - will be handled on release
                // or when drag starts
                return;
            } else if (!e.isShiftDown() && list.isSelectedIndex(row)) {
                // clicking on something that's already selected
                // and need to make it the lead now
                list.addSelectionInterval(row, row);
                return;
            }

            // could be a drag initiating event - don't grab focus
            grabFocus = false;

            dragPressDidSelection = true;
        }
    } else {
        // When drag is enabled mouse drags won't change the selection
        // in the list, so we only set the isAdjusting flag when it's
        // not enabled
        list.setValueIsAdjusting(true);
    }

    if (grabFocus) {
        SwingUtilities2.adjustFocus(list);
    }

    adjustSelection(e);
}
 
Example 20
Source File: BasicListUI.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
public void mousePressed(MouseEvent e) {
    if (SwingUtilities2.shouldIgnore(e, list)) {
        return;
    }

    boolean dragEnabled = list.getDragEnabled();
    boolean grabFocus = true;

    // different behavior if drag is enabled
    if (dragEnabled) {
        int row = SwingUtilities2.loc2IndexFileList(list, e.getPoint());
        // if we have a valid row and this is a drag initiating event
        if (row != -1 && DragRecognitionSupport.mousePressed(e)) {
            dragPressDidSelection = false;

            if (BasicGraphicsUtils.isMenuShortcutKeyDown(e)) {
                // do nothing for control - will be handled on release
                // or when drag starts
                return;
            } else if (!e.isShiftDown() && list.isSelectedIndex(row)) {
                // clicking on something that's already selected
                // and need to make it the lead now
                list.addSelectionInterval(row, row);
                return;
            }

            // could be a drag initiating event - don't grab focus
            grabFocus = false;

            dragPressDidSelection = true;
        }
    } else {
        // When drag is enabled mouse drags won't change the selection
        // in the list, so we only set the isAdjusting flag when it's
        // not enabled
        list.setValueIsAdjusting(true);
    }

    if (grabFocus) {
        SwingUtilities2.adjustFocus(list);
    }

    adjustSelection(e);
}