Java Code Examples for java.awt.event.KeyEvent#SHIFT_DOWN_MASK

The following examples show how to use java.awt.event.KeyEvent#SHIFT_DOWN_MASK . 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: CsvTableEditorKeyListenerTest.java    From intellij-csv-validator with Apache License 2.0 6 votes vote down vote up
public void testDeleteColumnActionByDelete() {
    KeyEvent keyEvent = new KeyEvent(fileEditor.getTable(), KeyEvent.KEY_RELEASED, JComponent.WHEN_FOCUSED,
            KeyEvent.CTRL_DOWN_MASK | KeyEvent.SHIFT_DOWN_MASK, KeyEvent.VK_DELETE, KeyEvent.CHAR_UNDEFINED);

    fileEditor.tableEditorKeyListener.keyReleased(keyEvent);
    assertTrue(fileEditor.getDataHandler().equalsCurrentState(initialState));

    fileEditor.getTable().setRowSelectionInterval(1, 1);
    fileEditor.getTable().setColumnSelectionInterval(1, 1);
    fileEditor.tableEditorKeyListener.keyReleased(keyEvent);
    Object[][] newState = fileEditor.getDataHandler().getCurrentState();
    assertEquals(1, newState[0].length);
    assertEquals(1, newState[1].length);
    assertEquals("Header1", newState[0][0]);
    assertEquals("this is column \"Header1\"", newState[1][0]);
}
 
Example 2
Source File: CsvTableEditorKeyListenerTest.java    From intellij-csv-validator with Apache License 2.0 6 votes vote down vote up
public void testDeleteColumnActionByBackspace() {
    KeyEvent keyEvent = new KeyEvent(fileEditor.getTable(), KeyEvent.KEY_RELEASED, JComponent.WHEN_FOCUSED,
            KeyEvent.CTRL_DOWN_MASK | KeyEvent.SHIFT_DOWN_MASK, KeyEvent.VK_BACK_SPACE, KeyEvent.CHAR_UNDEFINED);

    fileEditor.tableEditorKeyListener.keyReleased(keyEvent);
    assertTrue(fileEditor.getDataHandler().equalsCurrentState(initialState));

    fileEditor.getTable().setRowSelectionInterval(1, 1);
    fileEditor.getTable().setColumnSelectionInterval(1, 1);
    fileEditor.tableEditorKeyListener.keyReleased(keyEvent);
    Object[][] newState = fileEditor.getDataHandler().getCurrentState();
    assertEquals(1, newState[0].length);
    assertEquals(1, newState[1].length);
    assertEquals("Header1", newState[0][0]);
    assertEquals("this is column \"Header1\"", newState[1][0]);
}
 
Example 3
Source File: TreeTable.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void actionPerformed(ActionEvent e) {
    setFocusCycleRoot(false);

    try {
        Container con = TreeTable.this.getFocusCycleRootAncestor();

        if (con != null) {
            Component target = TreeTable.this;

            if (getParent() instanceof JViewport) {
                target = getParent().getParent();

                if (target == con) {
                    target = TreeTable.this;
                }
            }

            EventObject eo = EventQueue.getCurrentEvent();
            boolean backward = false;

            if (eo instanceof KeyEvent) {
                backward = ((((KeyEvent) eo).getModifiers() & KeyEvent.SHIFT_MASK) != 0) &&
                    ((((KeyEvent) eo).getModifiersEx() & KeyEvent.SHIFT_DOWN_MASK) != 0);
            }

            Component to = backward ? con.getFocusTraversalPolicy().getComponentAfter(con, TreeTable.this)
                                    : con.getFocusTraversalPolicy().getComponentAfter(con, TreeTable.this);

            if (to == TreeTable.this) {
                to = backward ? con.getFocusTraversalPolicy().getFirstComponent(con)
                              : con.getFocusTraversalPolicy().getLastComponent(con);
            }

            to.requestFocus();
        }
    } finally {
        setFocusCycleRoot(true);
    }
}
 
Example 4
Source File: BaseTable.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void actionPerformed(ActionEvent e) {
    setFocusCycleRoot(false);

    try {
        Container con = BaseTable.this.getFocusCycleRootAncestor();

        if (con != null) {
            Component target = BaseTable.this;

            if (getParent() instanceof JViewport) {
                target = getParent().getParent();

                if (target == con) {
                    target = BaseTable.this;
                }
            }

            EventObject eo = EventQueue.getCurrentEvent();
            boolean backward = false;

            if (eo instanceof KeyEvent) {
                backward = ((((KeyEvent) eo).getModifiers() & KeyEvent.SHIFT_MASK) != 0) &&
                    ((((KeyEvent) eo).getModifiersEx() & KeyEvent.SHIFT_DOWN_MASK) != 0);
            }

            Component to = backward ? con.getFocusTraversalPolicy().getComponentAfter(con, BaseTable.this)
                                    : con.getFocusTraversalPolicy().getComponentAfter(con, BaseTable.this);

            if (to == BaseTable.this) {
                to = backward ? con.getFocusTraversalPolicy().getFirstComponent(con)
                              : con.getFocusTraversalPolicy().getLastComponent(con);
            }

            to.requestFocus();
        }
    } finally {
        setFocusCycleRoot(true);
    }
}
 
Example 5
Source File: HotKeyAction.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public State keyTyped (Widget widget, WidgetKeyEvent event) {
    if (event.getModifiersEx() == (KeyEvent.ALT_DOWN_MASK | KeyEvent.SHIFT_DOWN_MASK) &&
            provider.processHotKey(widget, event.getKeyChar())) {
        return State.CONSUMED;
    }
    return super.keyTyped(widget, event);
}
 
Example 6
Source File: KeyMapOperator.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private int buildKeyModifierMask(boolean ctrl, boolean alt, boolean shift) {
    int _mask = 0;
    if (ctrl) {
        _mask = _mask | KeyEvent.CTRL_DOWN_MASK;
    }
    if (alt) {
        _mask = _mask | KeyEvent.ALT_DOWN_MASK;
    }
    if (shift) {
        _mask = _mask | KeyEvent.SHIFT_DOWN_MASK;
    }
    return _mask;
}
 
Example 7
Source File: WalletListPanel.java    From bither-desktop-java with Apache License 2.0 5 votes vote down vote up
public final void selectAdjacentWallet(KeyEvent e, String keyStatus) {
    int keyCode = e.getKeyCode();
    int modifiersEx = e.getModifiersEx();

    boolean moveToNextWallet = ((keyCode == KeyEvent.VK_DOWN || keyCode == KeyEvent.VK_KP_DOWN) && modifiersEx == KeyEvent.SHIFT_DOWN_MASK);
    boolean moveToPreviousWallet = ((keyCode == KeyEvent.VK_UP || keyCode == KeyEvent.VK_KP_UP) && modifiersEx == KeyEvent.SHIFT_DOWN_MASK);

    if (walletPanels != null) {
        synchronized (walletPanels) {
            int currentlySelectedWalletIndex = 0;
            int nextSelectedWalletIndex = -1;
            for (IAddressForm loopSingleWalletPanel : walletPanels) {

                // Found the currently selected panel.
                if (moveToNextWallet && currentlySelectedWalletIndex < walletPanels.size() - 1) {
                    nextSelectedWalletIndex = currentlySelectedWalletIndex + 1;
                    break;

                } else {
                    if (moveToPreviousWallet && currentlySelectedWalletIndex > 0) {
                        nextSelectedWalletIndex = currentlySelectedWalletIndex - 1;
                        break;
                    }
                }


                currentlySelectedWalletIndex++;
            }
            if (nextSelectedWalletIndex > -1) {
                Bither.getCoreController().fireDataChangedUpdateNow();
            }
        }
    }
}
 
Example 8
Source File: WalletListPanel.java    From bither-desktop-java with Apache License 2.0 5 votes vote down vote up
public final void selectAdjacentWallet(KeyEvent e, String keyStatus) {
    int keyCode = e.getKeyCode();
    int modifiersEx = e.getModifiersEx();

    boolean moveToNextWallet = ((keyCode == KeyEvent.VK_DOWN || keyCode == KeyEvent.VK_KP_DOWN) && modifiersEx == KeyEvent.SHIFT_DOWN_MASK);
    boolean moveToPreviousWallet = ((keyCode == KeyEvent.VK_UP || keyCode == KeyEvent.VK_KP_UP) && modifiersEx == KeyEvent.SHIFT_DOWN_MASK);

    if (walletPanels != null) {
        synchronized (walletPanels) {
            int currentlySelectedWalletIndex = 0;
            int nextSelectedWalletIndex = -1;
            for (IAddressForm loopSingleWalletPanel : walletPanels) {

                // Found the currently selected panel.
                if (moveToNextWallet && currentlySelectedWalletIndex < walletPanels.size() - 1) {
                    nextSelectedWalletIndex = currentlySelectedWalletIndex + 1;
                    break;

                } else {
                    if (moveToPreviousWallet && currentlySelectedWalletIndex > 0) {
                        nextSelectedWalletIndex = currentlySelectedWalletIndex - 1;
                        break;
                    }
                }


                currentlySelectedWalletIndex++;
            }
            if (nextSelectedWalletIndex > -1) {
                Bither.getCoreController().fireDataChangedUpdateNow();
            }
        }
    }
}
 
Example 9
Source File: ETable.java    From netbeans with Apache License 2.0 4 votes vote down vote up
@Override
public void actionPerformed(ActionEvent e) {
    setFocusCycleRoot(false);
    try {
        Container con = ETable.this.getFocusCycleRootAncestor();
        if (con != null) {
            /*
            Component target = ETable.this;
            if (getParent() instanceof JViewport) {
                target = getParent().getParent();
                if (target == con) {
                    target = ETable.this;
                }
            }
            */

            EventObject eo = EventQueue.getCurrentEvent();
            boolean backward = false;
            if (eo instanceof KeyEvent) {
                backward = 
                    (((KeyEvent) eo).getModifiers() 
                    & KeyEvent.SHIFT_MASK) 
                    != 0 && (((KeyEvent) eo).getModifiersEx() & 
                    KeyEvent.SHIFT_DOWN_MASK) != 0;
            }

            Component c = ETable.this;
            Component to;
            Container parentWithFTP = null;
            do {
                FocusTraversalPolicy ftp = con.getFocusTraversalPolicy();
                to = backward ? ftp.getComponentBefore(con, c)
                              : ftp.getComponentAfter(con, c);


                if (to == ETable.this) {
                    to = backward ? ftp.getFirstComponent(con)
                                  : ftp.getLastComponent(con);
                }
                if (to == ETable.this) {
                    parentWithFTP = con.getParent();
                    if (parentWithFTP != null) {
                        parentWithFTP = parentWithFTP.getFocusCycleRootAncestor();
                    }
                    if (parentWithFTP != null) {
                        c = con;
                        con = parentWithFTP;
                    }
                }
            } while (to == ETable.this && parentWithFTP != null);
            if (to != null) {
                to.requestFocus();
            }
        }
    } finally {
        setFocusCycleRoot(true);
    }
}
 
Example 10
Source File: TrayIconEventModifiersTest.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String[] args) throws Exception {
    if (! SystemTray.isSupported()) {
        System.out.println("SystemTray not supported on the platform under test. " +
                "Marking the test passed");
    } else {
        if (System.getProperty("os.name").toLowerCase().startsWith("win"))
            System.err.println("Test can fail if the icon hides to a tray icons pool" +
                    "in Windows 7, which is behavior by default.\n" +
                    "Set \"Right mouse click\" -> \"Customize notification icons\" -> " +
                    "\"Always show all icons and notifications on the taskbar\" true " +
                    "to avoid this problem. Or change behavior only for Java SE tray " +
                    "icon and rerun test.");

        System.out.println(System.getProperty("os.arch"));
        if (System.getProperty("os.name").indexOf("Sun") != -1 &&
                System.getProperty("os.arch").indexOf("sparc") != -1) {
            keyTypes = new int[]{
                    KeyEvent.VK_SHIFT,
                    KeyEvent.VK_CONTROL,
                    KeyEvent.VK_META
            };

            keyNames = new String[]{
                    "SHIFT",
                    "CONTROL",
                    "META"
            };
            keyMasks = new int[]{
                    KeyEvent.SHIFT_DOWN_MASK,
                    KeyEvent.CTRL_DOWN_MASK,
                    KeyEvent.META_DOWN_MASK
            };
        }

        if (SystemTrayIconHelper.isOel7()) {
            System.out.println("OEL 7 doesn't support click modifiers in " +
                    "systray. Skipped");
            return;
        }

        new TrayIconEventModifiersTest().doTest();
    }
}