Example usage for java.awt.event InputEvent CTRL_MASK

List of usage examples for java.awt.event InputEvent CTRL_MASK

Introduction

In this page you can find the example usage for java.awt.event InputEvent CTRL_MASK.

Prototype

int CTRL_MASK

To view the source code for java.awt.event InputEvent CTRL_MASK.

Click Source Link

Document

The Control key modifier constant.

Usage

From source file:org.eclipse.jubula.rc.swt.driver.RobotSwtImpl.java

/**
 * //from  w  ww . j  av a2s . com
 * @param keyStroke The key stroke. 
 * @return a list of key typers capable of generating the necessary
 *         events to simulate the modifiers of the given key stroke.
 */
private List modifierKeyTypers(KeyStroke keyStroke) {
    List l = new LinkedList();
    int modifiers = keyStroke.getModifiers();
    // this is jdk 1.3 - code.
    // use ALT_DOWN_MASK instead etc. with jdk 1.4 !
    if ((modifiers & InputEvent.ALT_MASK) != 0) {
        l.add(new KeyCodeTyper(SWT.ALT));
    }
    if ((modifiers & InputEvent.CTRL_MASK) != 0) {
        l.add(new KeyCodeTyper(SWT.CTRL));
    }
    if ((modifiers & InputEvent.SHIFT_MASK) != 0) {
        l.add(new KeyCodeTyper(SWT.SHIFT));
    }
    if ((modifiers & InputEvent.META_MASK) != 0) {
        l.add(new KeyCodeTyper(SWT.COMMAND));
    }
    return l;
}

From source file:org.jcurl.demo.editor.EditorApp.java

private JMenuItem newMI(final char mnemonic, final int ctrlAccel, final Action action) {
    final JMenuItem item = new JMenuItem(action);
    item.setMnemonic(mnemonic);//from  w  w  w  .ja  v  a2 s .c om
    if (ctrlAccel >= 0)
        item.setAccelerator(KeyStroke.getKeyStroke(ctrlAccel, InputEvent.CTRL_MASK));
    return item;
}

From source file:org.jcurl.demo.tactics.old.ActionRegistry.java

KeyStroke findAccelerator(final String acc) {
    if (acc == null || "".equals(acc))
        return null;
    final Matcher m = KeyPat.matcher(acc);
    if (m.matches()) {
        int modifiers = 0;
        {/*from  w w w.  j  a v  a2 s.  c om*/
            final String gr = m.group(1);
            if (!"".equals(gr)) {
                final String[] mod = gr.split("-");
                for (final String mm : mod)
                    if ("CTRL".equals(mm))
                        modifiers |= InputEvent.CTRL_MASK;
                    else if ("ALT".equals(mm))
                        modifiers |= InputEvent.ALT_MASK;
                    else if ("SHIFT".equals(mm))
                        modifiers |= InputEvent.SHIFT_MASK;
                    else
                        throw new IllegalStateException(mm);
            }
        }
        if (m.group(2).length() == 1)
            return KeyStroke.getKeyStroke(m.group(2).charAt(0), modifiers);
        final Integer kc = str2key.get(m.group(2));
        if (kc == null)
            throw new IllegalStateException(m.group(2));
        return KeyStroke.getKeyStroke(kc.intValue(), modifiers);
    } else {
        // swing syntax
        final KeyStroke k = KeyStroke.getKeyStroke(acc);
        if (k == null)
            throw new IllegalArgumentException(acc);
        return k;
    }
}

From source file:org.nuclos.client.genericobject.GenericObjectCollectController.java

private void setupKeyActionsForResultPanelVerticalScrollBar() {
    // maps the default key strokes for JTable to set the vertical scrollbar, so we can intervent:
    final InputMap inputmap = getResultTable().getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
    inputmap.put(KeyStroke.getKeyStroke(KeyEvent.VK_END, InputEvent.CTRL_MASK), "last");
    inputmap.put(KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, 0), "nextrow");
    inputmap.put(KeyStroke.getKeyStroke(KeyEvent.VK_PAGE_DOWN, 0), "nextpage");

    final JScrollBar scrlbarVertical = getResultPanel().getResultTableScrollPane().getVerticalScrollBar();
    final DefaultBoundedRangeModel model = (DefaultBoundedRangeModel) scrlbarVertical.getModel();

    getResultTable().getActionMap().put("last", new AbstractAction() {

        @Override//from   w w  w. ja  v  a  2 s .com
        public void actionPerformed(ActionEvent ev) {
            final int iSupposedValue = model.getMaximum() - model.getExtent();
            model.setValue(iSupposedValue);
            // this causes the necessary rows to be loaded. Loading may be cancelled by the user.
            LOG.debug("NOW it's time to select the row...");
            if (model.getValue() == iSupposedValue)
                getCollectNavigationModel().selectLastElement();
        }
    });

    getResultTable().getActionMap().put("nextrow", new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent ev) {
            final int iSelectedRow = getResultTable().getSelectedRow();
            final int iLastVisibleRow = TableUtils.getLastVisibleRow(getResultTable());
            if (iSelectedRow + 1 < iLastVisibleRow) {
                // next row is still visible: just select it:
                if (!getCollectNavigationModel().isLastElementSelected())
                    getCollectNavigationModel().selectNextElement();
            } else {
                // we have to move the viewport before we can select the next row:
                final int iSupposedValue = Math.min(model.getValue() + getResultTable().getRowHeight(),
                        model.getMaximum() - model.getExtent());
                model.setValue(iSupposedValue);
                // this causes the necessary rows to be loaded. Loading may be cancelled by the user.
                LOG.debug("NOW it's time to select the row...");
                if (model.getValue() == iSupposedValue)
                    if (!getCollectNavigationModel().isLastElementSelected())
                        getCollectNavigationModel().selectNextElement();
            }
        }
    });

    getResultTable().getActionMap().put("nextpage", new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent ev) {
            final int iSupposedValue = Math.min(model.getValue() + model.getExtent(),
                    model.getMaximum() - model.getExtent());
            model.setValue(iSupposedValue);
            // this causes the necessary rows to be loaded. Loading may be cancelled by the user.
            LOG.debug("NOW it's time to select the row...");
            if (model.getValue() == iSupposedValue) {
                final int iShiftRowCount = (int) Math
                        .ceil((double) model.getExtent() / (double) getResultTable().getRowHeight());
                final int iRow = Math.min(
                        getResultTable().getSelectionModel().getAnchorSelectionIndex() + iShiftRowCount,
                        getResultTable().getRowCount() - 1);
                getResultTable().setRowSelectionInterval(iRow, iRow);
            }
        }
    });

    final Action actShowLogBook = new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent ev) {
            cmdShowLogBook();
            getDetailsPanel().grabFocus();
        }
    };
    KeyBindingProvider.bindActionToComponent(KeyBindingProvider.SHOW_LOGBOOK, actShowLogBook,
            getDetailsPanel());

    final Action actShowStateHistory = new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent ev) {
            cmdShowStateHistory();
            getDetailsPanel().grabFocus();
        }
    };
    KeyBindingProvider.bindActionToComponent(KeyBindingProvider.SHOW_STATE_HISTORIE, actShowStateHistory,
            getDetailsPanel());

    final Action actPrintCurrentGenericObject = new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent ev) {
            cmdPrintCurrentGenericObject();
            getDetailsPanel().grabFocus();
        }
    };
    KeyBindingProvider.bindActionToComponent(KeyBindingProvider.PRINT_LEASED_OBJECT,
            actPrintCurrentGenericObject, getDetailsPanel());
}

From source file:org.nuclos.client.relation.EntityRelationshipModelEditPanel.java

private void createMouseWheelListener() {
    graphComponent.getGraphControl().addMouseWheelListener(new MouseWheelListener() {

        @Override/*w  ww  .  ja  va 2  s.c o m*/
        public void mouseWheelMoved(MouseWheelEvent e) {

            if (e.getModifiers() == InputEvent.CTRL_MASK) {
                if (e.getWheelRotation() <= 0) {
                    graphComponent.zoomIn();
                } else {
                    if (graphComponent.getGraph().getView().getScale() > 0.2)
                        graphComponent.zoomOut();
                }
            }

        }
    });
}

From source file:org.pentaho.reporting.designer.core.actions.global.ScreenCaptureAction.java

private static int getMenuKeyMask() {
    try {/*from   ww  w .  j a va 2  s  .  c  o  m*/
        return Toolkit.getDefaultToolkit().getMenuShortcutKeyMask();
    } catch (UnsupportedOperationException he) {
        // headless exception extends UnsupportedOperation exception,
        // but the HeadlessException is not defined in older JDKs...
        return InputEvent.CTRL_MASK;
    }
}

From source file:org.pmedv.core.provider.ApplicationMenuBarProviderImpl.java

@SuppressWarnings("unused")
public ApplicationMenuBarProviderImpl() {

    populateKeyTable();//from  www.  ja  v a2s  .  co  m

    menubar = new JMenuBar();

    try {
        JAXBContext c = JAXBContext.newInstance(ApplicationMenubar.class);

        Unmarshaller u = c.createUnmarshaller();

        ApplicationMenubar appMenuBar = (ApplicationMenubar) u
                .unmarshal(getClass().getClassLoader().getResourceAsStream("menus.xml"));

        for (ApplicationMenu currentMenu : appMenuBar.getMenus()) {

            JMenuWithId menu = new JMenuWithId(resources.getResourceByKey(currentMenu.getName()));

            menu.setMnemonic(resources.getResourceByKey(currentMenu.getName()).charAt(0));

            for (ApplicationMenuItem currentItem : currentMenu.getItems()) {

                try {

                    if (currentItem.getActionClass() != null) {

                        if (currentItem.getActionClass().equals("separator")) {
                            menu.addSeparator();
                            continue;
                        }

                        log.info("Mapping action class : " + currentItem.getActionClass());

                        try {

                            AbstractCommand command = null;
                            Class<?> clazz = Class.forName(currentItem.getActionClass());

                            if (currentItem.isBean()) {
                                command = (AbstractCommand) ctx.getBean(clazz);
                            } else {
                                command = (AbstractCommand) clazz.newInstance();
                            }

                            ImageIcon icon = null;
                            String mnemonic = null;
                            String toolTipText = null;

                            if (currentItem.getImageIcon() != null) {

                                InputStream is = getClass().getClassLoader()
                                        .getResourceAsStream(currentItem.getImageIcon());

                                if (is == null) {
                                    is = getClass().getClassLoader()
                                            .getResourceAsStream("icons/noresource_16x16.png");
                                }

                                icon = new ImageIcon(ImageIO.read(is));

                            }
                            if (currentItem.getMnemonic() != null) {
                                mnemonic = currentItem.getMnemonic();
                            }
                            if (currentItem.getToolTipText() != null) {
                                toolTipText = currentItem.getToolTipText();
                            }
                            if (currentItem.getType() != null
                                    && currentItem.getType().equals("ApplicationMenuItemType.CHECKBOX")) {

                                CmdJCheckBoxMenuItem cmdItem = new CmdJCheckBoxMenuItem(currentItem.getName(),
                                        icon, command, mnemonic, toolTipText, null);

                                if (mnemonic != null && currentItem.getModifier() != null) {

                                    if (currentItem.getModifier().equalsIgnoreCase("ctrl")) {
                                        cmdItem.setAccelerator(KeyStroke.getKeyStroke(keyMap.get(mnemonic),
                                                InputEvent.CTRL_MASK, false));
                                    } else if (currentItem.getModifier().equalsIgnoreCase("alt")) {
                                        cmdItem.setAccelerator(KeyStroke.getKeyStroke(keyMap.get(mnemonic),
                                                InputEvent.ALT_MASK, false));
                                    } else if (currentItem.getModifier().equalsIgnoreCase("shift")) {
                                        cmdItem.setAccelerator(KeyStroke.getKeyStroke(keyMap.get(mnemonic),
                                                InputEvent.SHIFT_MASK, false));
                                    }

                                }

                                menu.add(cmdItem);

                            } else {

                                JMenuItem cmdItem = new JMenuItem(command);

                                if (mnemonic != null && currentItem.getModifier() != null) {

                                    if (currentItem.getModifier().equalsIgnoreCase("ctrl")) {
                                        cmdItem.setAccelerator(KeyStroke.getKeyStroke(keyMap.get(mnemonic),
                                                InputEvent.CTRL_MASK, false));
                                    } else if (currentItem.getModifier().equalsIgnoreCase("alt")) {
                                        cmdItem.setAccelerator(KeyStroke.getKeyStroke(keyMap.get(mnemonic),
                                                InputEvent.ALT_MASK, false));
                                    } else if (currentItem.getModifier().equalsIgnoreCase("shift")) {
                                        cmdItem.setAccelerator(KeyStroke.getKeyStroke(keyMap.get(mnemonic),
                                                InputEvent.SHIFT_MASK, false));
                                    }

                                }

                                menu.add(cmdItem);

                            }

                        } catch (InstantiationException e) {
                            log.info("could not instanciate menuitem, skipping.");
                        } catch (IllegalAccessException e) {
                            log.info("could not access menuitem, skipping.");
                        }

                    }

                } catch (ClassNotFoundException e) {
                    log.info("could not find action class " + currentItem.getActionClass());
                }

            }

            if (currentMenu.getType() != null && currentMenu.getType().equalsIgnoreCase("file")) {

                JMenu openRecentMenu = new JMenu(resources.getResourceByKey("menu.recentfiles"));

                RecentFileList fileList = null;

                try {

                    String inputDir = System.getProperty("user.home") + "/." + AppContext.getName() + "/";
                    String inputFileName = "recentFiles.xml";
                    File inputFile = new File(inputDir + inputFileName);

                    if (inputFile.exists()) {
                        Unmarshaller u1 = JAXBContext.newInstance(RecentFileList.class).createUnmarshaller();
                        fileList = (RecentFileList) u1.unmarshal(inputFile);
                    }

                    if (fileList == null)
                        fileList = new RecentFileList();

                    ArrayList<String> recent = fileList.getRecentFiles();
                    Collections.reverse(recent);

                    for (String recentFile : fileList.getRecentFiles()) {
                        File file = new File(recentFile);
                        AbstractCommand openBoardAction = new OpenBoardCommand(file.getName(), file);
                        JMenuItem item = new JMenuItem(openBoardAction);
                        openRecentMenu.add(item);
                    }

                } catch (JAXBException e) {
                    e.printStackTrace();
                }

                menu.addSeparator();
                menu.add(openRecentMenu);

                JMenu openSamplesMenu = createSamplesMenu();

                menu.add(openSamplesMenu);

            }

            menu.setId("common");

            if (currentMenu.getType() != null && !currentMenu.getType().equalsIgnoreCase("help"))
                menubar.add(menu);
            else
                helpMenus.add(menu);

            menubar.setFont(new Font("SansSerif", Font.PLAIN, 12));

        }

        ApplicationPerspectiveProvider perspectiveProvider = ctx.getBean(ApplicationPerspectiveProvider.class);
        ArrayList<ApplicationPerspective> perspectives = perspectiveProvider.getPerspectives();

        JMenuWithId perspectivesMenu = new JMenuWithId("Perspectives");
        perspectivesMenu.setId("common");
        perspectivesMenu.setMnemonic('P');

        for (ApplicationPerspective perspective : perspectives) {

            ImageIcon icon = null;
            String mnemonic = null;
            String toolTipText = null;

            if (perspective.getPerspectiveIcon() != null) {

                InputStream is = getClass().getClassLoader()
                        .getResourceAsStream(perspective.getPerspectiveIcon());

                if (is != null) {
                    icon = new ImageIcon(ImageIO.read(is));
                } else {

                    is = getClass().getClassLoader().getResourceAsStream("icons/noresource_16x16.png");

                    if (is != null)
                        icon = new ImageIcon(ImageIO.read(is));

                }

            }
            if (perspective.getMnemonic() != null) {
                mnemonic = perspective.getMnemonic();
            }
            if (perspective.getToolTipText() != null) {
                toolTipText = perspective.getToolTipText();
            }

            log.info("mapping perspective class " + perspective.getPerspectiveClass());
            OpenPerspectiveCommand command = new OpenPerspectiveCommand(perspective.getId());

            JMenuItem item = new JMenuItem(command);

            if (mnemonic != null && perspective.getModifier() != null) {

                if (perspective.getModifier().equalsIgnoreCase("ctrl")) {
                    item.setAccelerator(
                            KeyStroke.getKeyStroke(keyMap.get(mnemonic), InputEvent.CTRL_MASK, false));
                } else if (perspective.getModifier().equalsIgnoreCase("alt")) {
                    item.setAccelerator(
                            KeyStroke.getKeyStroke(keyMap.get(mnemonic), InputEvent.ALT_MASK, false));
                } else if (perspective.getModifier().equalsIgnoreCase("shift")) {
                    item.setAccelerator(
                            KeyStroke.getKeyStroke(keyMap.get(mnemonic), InputEvent.SHIFT_MASK, false));
                }

            }

            perspectivesMenu.add(item);

            for (ApplicationMenu pMenu : perspective.getMenubarContributions()) {

                JMenuWithId menu = new JMenuWithId(resources.getResourceByKey(pMenu.getName()));

                // if (pMenu.getMnemonic() != null && pMenu.getMnemonic().length() > 0)               
                menu.setMnemonic(resources.getResourceByKey(pMenu.getName()).charAt(0));

                for (ApplicationMenuItem currentItem : pMenu.getItems()) {

                    try {

                        if (currentItem.getActionClass() != null) {

                            if (currentItem.getActionClass().equals("separator")) {
                                menu.addSeparator();
                                continue;
                            }

                            log.info("Mapping action class : " + currentItem.getActionClass());

                            try {

                                AbstractCommand pCommand = null;
                                Class<?> clazz = Class.forName(currentItem.getActionClass());

                                if (currentItem.isBean()) {
                                    pCommand = (AbstractCommand) ctx.getBean(clazz);
                                } else {
                                    pCommand = (AbstractCommand) clazz.newInstance();
                                }

                                ImageIcon pIcon = null;
                                String pMnemonic = null;
                                String pToolTipText = null;

                                if (currentItem.getImageIcon() != null) {

                                    InputStream is = getClass().getClassLoader()
                                            .getResourceAsStream(currentItem.getImageIcon());
                                    pIcon = new ImageIcon(ImageIO.read(is));

                                }
                                if (currentItem.getMnemonic() != null) {
                                    pMnemonic = currentItem.getMnemonic();
                                }
                                if (currentItem.getToolTipText() != null) {
                                    pToolTipText = currentItem.getToolTipText();
                                }

                                if (currentItem.getType() != null
                                        && currentItem.getType().equals("ApplicationMenuItemType.CHECKBOX")) {

                                    log.info(
                                            "Creating menu checkbox for class " + currentItem.getActionClass());

                                    JCheckBoxMenuItem cmdItem = new JCheckBoxMenuItem(pCommand);

                                    if (pMnemonic != null && currentItem.getModifier() != null) {

                                        if (currentItem.getModifier().equalsIgnoreCase("ctrl")) {
                                            cmdItem.setAccelerator(KeyStroke.getKeyStroke(keyMap.get(pMnemonic),
                                                    InputEvent.CTRL_MASK, false));
                                        } else if (currentItem.getModifier().equalsIgnoreCase("alt")) {
                                            cmdItem.setAccelerator(KeyStroke.getKeyStroke(keyMap.get(pMnemonic),
                                                    InputEvent.ALT_MASK, false));
                                        } else if (currentItem.getModifier().equalsIgnoreCase("shift")) {
                                            cmdItem.setAccelerator(KeyStroke.getKeyStroke(keyMap.get(pMnemonic),
                                                    InputEvent.SHIFT_MASK, false));
                                        }

                                    }

                                    menu.add(cmdItem);
                                    cmdItem.setSelected(true);

                                } else {

                                    log.info("Creating menu entry for class " + currentItem.getActionClass());

                                    JMenuItem cmdItem = new JMenuItem(pCommand);

                                    if (pMnemonic != null && currentItem.getModifier() != null) {

                                        if (currentItem.getModifier().equalsIgnoreCase("ctrl")) {
                                            cmdItem.setAccelerator(KeyStroke.getKeyStroke(keyMap.get(pMnemonic),
                                                    InputEvent.CTRL_MASK, false));
                                        } else if (currentItem.getModifier().equalsIgnoreCase("alt")) {
                                            cmdItem.setAccelerator(KeyStroke.getKeyStroke(keyMap.get(pMnemonic),
                                                    InputEvent.ALT_MASK, false));
                                        } else if (currentItem.getModifier().equalsIgnoreCase("shift")) {
                                            cmdItem.setAccelerator(KeyStroke.getKeyStroke(keyMap.get(pMnemonic),
                                                    InputEvent.SHIFT_MASK, false));
                                        }

                                    }

                                    menu.add(cmdItem);

                                }

                            } catch (InstantiationException e) {
                                log.info("could not instanciate menuitem, skipping.");
                            } catch (IllegalAccessException e) {
                                log.info("could not access menuitem, skipping.");
                            }

                        }

                    } catch (ClassNotFoundException e) {
                        log.info("could not find action class " + currentItem.getActionClass());
                    }

                }

                menu.setId(perspective.getId());
                menu.setVisible(false);

                menubar.add(menu);

            }

        }

        if (perspectiveProvider.getPerspectives().size() > 1) {
            menubar.add(perspectivesMenu);
        }

        for (JMenuWithId helpmenu : helpMenus) {
            menubar.add(helpmenu);
        }

        menubar.setFont(new Font("SansSerif", Font.PLAIN, 12));

    } catch (JAXBException e) {
        log.info("could not deserialize menus.");
        throw new RuntimeException("could not deserialize menus.");
    } catch (IOException e) {
        log.info("could not load menus.");
        throw new RuntimeException("could not load menus.");
    }

}

From source file:org.sikuli.ide.SikuliIDE.java

private void initFileMenu() throws NoSuchMethodException {
    JMenuItem jmi;/* w  w  w. ja v  a 2 s. c om*/
    int scMask = Toolkit.getDefaultToolkit().getMenuShortcutKeyMask();
    _fileMenu.setMnemonic(java.awt.event.KeyEvent.VK_F);

    if (showAbout) {
        _fileMenu.add(
                createMenuItem("About SikuliX", KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_A, scMask),
                        new FileAction(FileAction.ABOUT)));
        _fileMenu.addSeparator();
    }

    _fileMenu.add(createMenuItem(_I("menuFileNew"),
            KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_N, scMask), new FileAction(FileAction.NEW)));

    jmi = _fileMenu.add(createMenuItem(_I("menuFileOpen"),
            KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_O, scMask), new FileAction(FileAction.OPEN)));
    jmi.setName("OPEN");

    recentMenu = new JMenu(_I("menuRecent"));

    if (Settings.experimental) {
        _fileMenu.add(recentMenu);
    }

    if (Settings.isMac() && !Settings.handlesMacBundles) {
        _fileMenu.add(createMenuItem("Open folder.sikuli ...", null,
                //            KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_O, scMask),
                new FileAction(FileAction.OPEN_FOLDER)));
    }

    jmi = _fileMenu.add(createMenuItem(_I("menuFileSave"),
            KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S, scMask), new FileAction(FileAction.SAVE)));
    jmi.setName("SAVE");

    jmi = _fileMenu.add(createMenuItem(_I("menuFileSaveAs"),
            KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S, InputEvent.SHIFT_MASK | scMask),
            new FileAction(FileAction.SAVE_AS)));
    jmi.setName("SAVE_AS");

    if (Settings.isMac() && !Settings.handlesMacBundles) {
        _fileMenu.add(createMenuItem(_I("Save as folder.sikuli ..."),
                //            KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S,
                //            InputEvent.SHIFT_MASK | scMask),
                null, new FileAction(FileAction.SAVE_AS_FOLDER)));
    }

    //TODO    _fileMenu.add(createMenuItem(_I("menuFileSaveAll"),
    _fileMenu.add(createMenuItem("Save all",
            KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S, InputEvent.CTRL_MASK | scMask),
            new FileAction(FileAction.SAVE_ALL)));

    _fileMenu.add(createMenuItem(_I("menuFileExport"),
            KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_E, InputEvent.SHIFT_MASK | scMask),
            new FileAction(FileAction.EXPORT)));

    jmi = _fileMenu.add(
            createMenuItem(_I("menuFileCloseTab"), KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_W, scMask),
                    new FileAction(FileAction.CLOSE_TAB)));
    jmi.setName("CLOSE_TAB");

    if (showPrefs) {
        _fileMenu.addSeparator();
        _fileMenu.add(createMenuItem(_I("menuFilePreferences"),
                KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_P, scMask),
                new FileAction(FileAction.PREFERENCES)));
    }

    if (showQuit) {
        _fileMenu.addSeparator();
        _fileMenu.add(createMenuItem(_I("menuFileQuit"), null, new FileAction(FileAction.QUIT)));
    }
}

From source file:org.sikuli.ide.SikuliIDE.java

private void initShortcutKeys() {
    final int scMask = Toolkit.getDefaultToolkit().getMenuShortcutKeyMask();
    Toolkit.getDefaultToolkit().addAWTEventListener(new AWTEventListener() {
        private boolean isKeyNextTab(java.awt.event.KeyEvent ke) {
            if (ke.getKeyCode() == java.awt.event.KeyEvent.VK_TAB
                    && ke.getModifiers() == InputEvent.CTRL_MASK) {
                return true;
            }//from w w w .j av a2 s  .  com
            if (ke.getKeyCode() == java.awt.event.KeyEvent.VK_CLOSE_BRACKET
                    && ke.getModifiers() == (InputEvent.META_MASK | InputEvent.SHIFT_MASK)) {
                return true;
            }
            return false;
        }

        private boolean isKeyPrevTab(java.awt.event.KeyEvent ke) {
            if (ke.getKeyCode() == java.awt.event.KeyEvent.VK_TAB
                    && ke.getModifiers() == (InputEvent.CTRL_MASK | InputEvent.SHIFT_MASK)) {
                return true;
            }
            if (ke.getKeyCode() == java.awt.event.KeyEvent.VK_OPEN_BRACKET
                    && ke.getModifiers() == (InputEvent.META_MASK | InputEvent.SHIFT_MASK)) {
                return true;
            }
            return false;
        }

        public void eventDispatched(AWTEvent e) {
            java.awt.event.KeyEvent ke = (java.awt.event.KeyEvent) e;
            //Debug.log(ke.toString());
            if (ke.getID() == java.awt.event.KeyEvent.KEY_PRESSED) {
                if (isKeyNextTab(ke)) {
                    nextTab();
                } else if (isKeyPrevTab(ke)) {
                    prevTab();
                }
            }
        }
    }, AWTEvent.KEY_EVENT_MASK);

}

From source file:org.wandora.application.gui.topicpanels.ProcessingTopicPanel.java

@Override
public void init() {
    Wandora wandora = Wandora.getWandora();
    if (options == null) {
        if (USE_LOCAL_OPTIONS) {
            options = new Options(wandora.getOptions());
        } else {//from  ww  w.j  a v a 2 s.  c  o m
            options = wandora.getOptions();
        }
    }
    tm = wandora.getTopicMap();

    initComponents();
    this.addComponentListener(this);
    try {
        // JavaSyntaxKit syntaxKit = new JavaSyntaxKit();
        // syntaxKit.install(processingEditor);
        DefaultSyntaxKit.initKit();
        processingEditor.setContentType("text/java");
    } catch (Exception e) {
        e.printStackTrace();
    }

    /*
    EditorKit ek=processingEditor.getEditorKit();
    if(ek instanceof DefaultSyntaxKit){
    DefaultSyntaxKit sk=(DefaultSyntaxKit)ek;
    sk.setProperty("Action.parenthesis", null); 
    sk.setProperty("Action.brackets", null);
    sk.setProperty("Action.quotes", null);
    sk.setProperty("Action.double-quotes", null);
    sk.setProperty("Action.close-curly", null);
    }*/
    readOptions();

    KeyStroke key = KeyStroke.getKeyStroke(KeyEvent.VK_S, InputEvent.CTRL_MASK);
    processingEditor.getInputMap().put(key, "saveOperation");
    Action saveOperation = new AbstractAction() {
        @Override
        public void actionPerformed(ActionEvent e) {
            saveCurrentSketch();
        }
    };
    processingEditor.getActionMap().put("saveOperation", saveOperation);
    processingEditor.getDocument().putProperty(DefaultEditorKit.EndOfLineStringProperty, "\n");

    innerPanel.addComponentListener(new ComponentListener() {
        @Override
        public void componentResized(ComponentEvent e) {
            revalidate();
            Wandora.getWandora().validate();
        }

        @Override
        public void componentMoved(ComponentEvent e) {
            revalidate();
            Wandora.getWandora().validate();
        }

        @Override
        public void componentShown(ComponentEvent e) {
            revalidate();
            Wandora.getWandora().validate();
        }

        @Override
        public void componentHidden(ComponentEvent e) {
            revalidate();
            Wandora.getWandora().validate();
        }
    });

    if (currentSketch != null) {
        processingEditor.setText(currentSketch);
    } else {
        processingEditor.setText(defaultMessage);
    }

    FileNameExtensionFilter sketchFilter = new FileNameExtensionFilter("Processing sketch files", "sketch");
    fc = new JFileChooser();
    fc.setFileFilter(sketchFilter);
    fc.setCurrentDirectory(new File(sketchPath));
}