Example usage for java.awt.event InputEvent CTRL_DOWN_MASK

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

Introduction

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

Prototype

int CTRL_DOWN_MASK

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

Click Source Link

Document

The Control key extended modifier constant.

Usage

From source file:edu.ku.brc.af.ui.forms.ViewFactory.java

/**
 * @param destObj/*w  ww  . j ava 2s . c om*/
 * @param textField
 */
public static void addTextFieldPopup(final GetSetValueIFace destObj, final JTextField textField,
        final boolean doAddDate) {
    if (textField != null) {
        JPopupMenu popupMenu = new JPopupMenu();

        if (doAddDate) {
            AbstractAction aa = new AbstractAction("Clear It") {

                @Override
                public void actionPerformed(ActionEvent e) {
                    DateWrapper scrDateFormat = AppPrefsCache.getDateWrapper("ui", "formatting",
                            "scrdateformat");
                    if (scrDateFormat != null) {
                        destObj.setValue(scrDateFormat.format(Calendar.getInstance()), "");
                    } else {
                        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
                        destObj.setValue(sdf.format(Calendar.getInstance()), "");
                    }
                }
            };

            UIHelper.createLocalizedMenuItem(popupMenu, "ViewFactory.CURR_DATE", "", "", true, aa);

            KeyStroke ctrlShiftT = KeyStroke.getKeyStroke(KeyEvent.VK_T,
                    InputEvent.CTRL_DOWN_MASK | InputEvent.SHIFT_DOWN_MASK);
            textField.getInputMap().put(ctrlShiftT, "SetCurrentDate");
            textField.getActionMap().put("SetCurrentDate", aa);

        }

        String clearField = "ClearField";
        AbstractAction clearAction = new AbstractAction(clearField) {
            @Override
            public void actionPerformed(ActionEvent e) {
                destObj.setValue("", "");
            }
        };

        UIHelper.createLocalizedMenuItem(popupMenu, "ViewFactory.CLEAR", "", "", true, clearAction);

        textField.getInputMap().put(KeyStroke.getKeyStroke("F3"), clearField);
        textField.getActionMap().put(clearField, clearAction);

        textField.add(popupMenu);
        textField.setComponentPopupMenu(popupMenu);
    }
}

From source file:edu.purdue.cc.bionet.ui.CorrelationDisplayPanel.java

/**
 * Adds all of the necessary Components to this Component.
 *//*w ww  . j a v  a 2  s  .  co m*/
private void buildPanel() {

    Language language = Settings.getLanguage();
    this.correlationMethodMenu = new JMenu(language.get("Correlation Method"));
    this.correlationMethodMenuButtonGroup = new ButtonGroup();
    this.pearsonCalculationMenuItem = new JRadioButtonMenuItem(language.get("Pearson"), true);
    this.spearmanCalculationMenuItem = new JRadioButtonMenuItem(language.get("Spearman"));
    this.kendallCalculationMenuItem = new JRadioButtonMenuItem(language.get("Kendall"));

    // layout menu itmes
    this.layoutMenu = new JMenu(language.get("Layout"));
    this.layoutMenuButtonGroup = new ButtonGroup();
    this.multipleCirclesLayoutMenuItem = new JRadioButtonMenuItem(language.get("Multiple Circles"));
    this.singleCircleLayoutMenuItem = new JRadioButtonMenuItem(language.get("Single Circle"), true);
    this.randomLayoutMenuItem = new JRadioButtonMenuItem(language.get("Random"));
    this.heatMapLayoutMenuItem = new JRadioButtonMenuItem(language.get("Heat Map"));
    this.kkLayoutMenuItem = new JRadioButtonMenuItem(language.get("Kamada-Kawai"));
    //      this.frLayoutMenuItem = 
    //            new JRadioButtonMenuItem( language.get( "Fruchterman-Reingold" ));
    //      this.springLayoutMenuItem = 
    //               new JRadioButtonMenuItem( language.get( "Spring Layout" ));
    this.frSpringLayoutMenuItem = new JRadioButtonMenuItem(language.get("Spring Layout"));
    //      this.animatedLayoutMenuItem = new JCheckBoxMenuItem( 
    //         language.get( "Fruchterman-Reingold Spring Embedding" ));

    // view menu items
    this.viewMenu = new JMenu(language.get("View"));
    this.zoomInViewMenuItem = new JMenuItem(language.get("Zoom In"), KeyEvent.VK_I);
    this.zoomOutViewMenuItem = new JMenuItem(language.get("Zoom Out"), KeyEvent.VK_O);
    this.fitToWindowViewMenuItem = new JMenuItem(language.get("Fit to Window"), KeyEvent.VK_F);
    this.selectAllViewMenuItem = new JMenuItem(language.get("Select All"), KeyEvent.VK_A);
    this.clearSelectionViewMenuItem = new JMenuItem(language.get("Clear Selection"), KeyEvent.VK_C);
    this.invertSelectionViewMenuItem = new JMenuItem(language.get("Invert Selection"), KeyEvent.VK_I);
    this.selectCorrelatedViewMenuItem = new JMenuItem(language.get("Select Correlated to Selection"),
            KeyEvent.VK_R);
    this.hideSelectedViewMenuItem = new JMenuItem(language.get("Hide Selected"), KeyEvent.VK_H);
    this.hideUnselectedViewMenuItem = new JMenuItem(language.get("Hide Unselected"), KeyEvent.VK_U);
    this.hideUncorrelatedViewMenuItem = new JMenuItem(language.get("Hide Uncorrelated to Selection"),
            KeyEvent.VK_L);
    this.hideOrphansViewMenuItem = new JMenuItem(language.get("Hide Orphans"), KeyEvent.VK_P);
    this.showCorrelatedViewMenuItem = new JMenuItem(language.get("Show All Correlated to Visible"),
            KeyEvent.VK_S);
    this.saveImageAction = new SaveImageAction(language.get("Save Main Graph Image") + "...", null);

    // groups menu items
    this.groupsMenu = new JMenu(language.get("Groups"));
    this.resetSampleGroupsMenuItem = new JMenuItem(language.get("Reset Sample Groups"), KeyEvent.VK_R);
    this.chooseSampleGroupsMenuItem = new JMenuItem(language.get("Choose Sample Groups") + "...",
            KeyEvent.VK_C);

    // color menu items
    this.colorMenu = new JMenu(language.get("Color"));
    this.colorMenuButtonGroup = new ButtonGroup();
    this.normalColorMenuItem = new JRadioButtonMenuItem(language.get("Normal Color"), true);
    this.highContrastColorMenuItem = new JRadioButtonMenuItem(language.get("High Contrast Color"));

    // CORRELATION FILTER ELEMENTS
    JPanel leftPanel = new JPanel(new BorderLayout());
    this.moleculeFilterPanel = new MoleculeFilterPanel();
    leftPanel.add(moleculeFilterPanel, BorderLayout.CENTER);
    this.correlationFilterPanel = new CorrelationFilterPanel();
    leftPanel.add(this.correlationFilterPanel, BorderLayout.SOUTH);

    //CALCULATION MENU
    this.correlationMethodMenu.setMnemonic(KeyEvent.VK_C);
    this.correlationMethodMenu.getAccessibleContext()
            .setAccessibleDescription(language.get("Perform Data Calculations"));
    this.correlationMethodMenuButtonGroup.add(this.pearsonCalculationMenuItem);
    this.correlationMethodMenuButtonGroup.add(this.spearmanCalculationMenuItem);
    this.correlationMethodMenuButtonGroup.add(this.kendallCalculationMenuItem);
    this.pearsonCalculationMenuItem.setMnemonic(KeyEvent.VK_P);
    this.spearmanCalculationMenuItem.setMnemonic(KeyEvent.VK_S);
    this.kendallCalculationMenuItem.setMnemonic(KeyEvent.VK_K);
    this.correlationMethodMenu.add(this.pearsonCalculationMenuItem);
    this.correlationMethodMenu.add(this.spearmanCalculationMenuItem);
    this.correlationMethodMenu.add(this.kendallCalculationMenuItem);
    this.pearsonCalculationMenuItem.addItemListener(this);
    this.spearmanCalculationMenuItem.addItemListener(this);
    this.kendallCalculationMenuItem.addItemListener(this);

    //LAYOUT MENU
    LayoutChangeListener lcl = new LayoutChangeListener();
    this.layoutMenu.setMnemonic(KeyEvent.VK_L);
    this.layoutMenu.getAccessibleContext()
            .setAccessibleDescription(language.get("Change the layout of the graph"));
    this.layoutMenuButtonGroup.add(this.multipleCirclesLayoutMenuItem);
    this.layoutMenuButtonGroup.add(this.singleCircleLayoutMenuItem);
    this.layoutMenuButtonGroup.add(this.randomLayoutMenuItem);
    this.layoutMenuButtonGroup.add(this.kkLayoutMenuItem);
    //      this.layoutMenuButtonGroup.add( this.frLayoutMenuItem );
    //      this.layoutMenuButtonGroup.add( this.springLayoutMenuItem );
    this.layoutMenuButtonGroup.add(this.frSpringLayoutMenuItem);
    this.layoutMenuButtonGroup.add(this.heatMapLayoutMenuItem);

    Enumeration<AbstractButton> e = this.layoutMenuButtonGroup.getElements();
    this.layoutMenu.add(this.multipleCirclesLayoutMenuItem);
    this.layoutMenu.add(this.singleCircleLayoutMenuItem);
    this.layoutMenu.add(this.randomLayoutMenuItem);
    this.layoutMenu.add(this.kkLayoutMenuItem);
    //      this.layoutMenu.add( this.frLayoutMenuItem );
    //      this.layoutMenu.add( this.springLayoutMenuItem );
    this.layoutMenu.add(this.frSpringLayoutMenuItem);
    this.layoutMenu.add(this.heatMapLayoutMenuItem);
    //      this.layoutMenu.addSeparator( );
    //      this.layoutMenu.add( this.animatedLayoutMenuItem );
    this.multipleCirclesLayoutMenuItem.addActionListener(lcl);
    this.multipleCirclesLayoutMenuItem.setEnabled(false);
    this.singleCircleLayoutMenuItem.addActionListener(lcl);
    this.randomLayoutMenuItem.addActionListener(lcl);
    this.kkLayoutMenuItem.addActionListener(lcl);
    //      this.frLayoutMenuItem.addActionListener( lcl );
    this.frSpringLayoutMenuItem.addActionListener(lcl);
    this.heatMapLayoutMenuItem.addActionListener(lcl);
    //      this.animatedLayoutMenuItem.addActionListener( lcl );

    //VIEW MENU
    this.viewMenu.add(this.colorMenu);
    this.viewMenu.addSeparator();
    this.viewMenu.setMnemonic(KeyEvent.VK_V);
    this.viewMenu.getAccessibleContext()
            .setAccessibleDescription(language.get("Change the data view settings"));
    this.viewMenu.add(this.zoomOutViewMenuItem);
    this.viewMenu.add(this.zoomInViewMenuItem);
    this.viewMenu.add(this.fitToWindowViewMenuItem);
    this.viewMenu.addSeparator();
    this.viewMenu.add(this.selectAllViewMenuItem);
    this.viewMenu.add(this.clearSelectionViewMenuItem);
    this.viewMenu.add(this.invertSelectionViewMenuItem);
    this.viewMenu.add(this.selectCorrelatedViewMenuItem);
    this.viewMenu.addSeparator();
    this.viewMenu.add(this.hideSelectedViewMenuItem);
    this.viewMenu.add(this.hideUnselectedViewMenuItem);
    this.viewMenu.add(this.hideUncorrelatedViewMenuItem);
    this.viewMenu.add(this.hideOrphansViewMenuItem);
    this.viewMenu.add(this.showCorrelatedViewMenuItem);
    this.viewMenu.addSeparator();
    this.viewMenu.add(this.saveImageAction);
    this.resetSampleGroupsMenuItem.addActionListener(this);
    this.chooseSampleGroupsMenuItem.addActionListener(this);
    this.zoomOutViewMenuItem.addActionListener(this);
    this.zoomInViewMenuItem.addActionListener(this);
    this.fitToWindowViewMenuItem.addActionListener(this);
    this.selectAllViewMenuItem.addActionListener(this);
    this.clearSelectionViewMenuItem.addActionListener(this);
    this.invertSelectionViewMenuItem.addActionListener(this);
    this.selectCorrelatedViewMenuItem.addActionListener(this);
    this.hideSelectedViewMenuItem.addActionListener(this);
    this.hideUnselectedViewMenuItem.addActionListener(this);
    this.hideUncorrelatedViewMenuItem.addActionListener(this);
    this.hideOrphansViewMenuItem.addActionListener(this);
    this.showCorrelatedViewMenuItem.addActionListener(this);
    this.selectAllViewMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_A, InputEvent.CTRL_DOWN_MASK));
    this.clearSelectionViewMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0));

    // GROUPS MENU
    this.groupsMenu.setMnemonic(KeyEvent.VK_G);
    this.groupsMenu.add(this.resetSampleGroupsMenuItem);
    this.groupsMenu.add(this.chooseSampleGroupsMenuItem);

    this.zoomOutViewMenuItem
            .setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_MINUS, InputEvent.CTRL_DOWN_MASK));
    this.zoomInViewMenuItem
            .setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_EQUALS, InputEvent.CTRL_DOWN_MASK));
    this.fitToWindowViewMenuItem
            .setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_0, InputEvent.CTRL_DOWN_MASK));
    this.hideSelectedViewMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0));

    //COLOR MENU
    this.colorMenu.setMnemonic(KeyEvent.VK_R);
    this.colorMenu.getAccessibleContext()
            .setAccessibleDescription(language.get("Change the color of the graph"));
    this.colorMenuButtonGroup.add(this.normalColorMenuItem);
    this.colorMenuButtonGroup.add(this.highContrastColorMenuItem);
    this.colorMenu.add(this.normalColorMenuItem);
    this.colorMenu.add(this.highContrastColorMenuItem);
    this.normalColorMenuItem.addItemListener(this);
    this.highContrastColorMenuItem.addItemListener(this);

    this.menuBar.add(this.correlationMethodMenu);
    this.menuBar.add(this.layoutMenu);
    this.menuBar.add(this.viewMenu);
    this.menuBar.add(this.groupsMenu);

    // Add the panels to the main panel
    this.add(menuBar, BorderLayout.NORTH);
    //      this.add( this.correlationViewPanel, BorderLayout.CENTER );
    this.add(leftPanel, BorderLayout.WEST);
}

From source file:com.net2plan.gui.tools.GUINetworkDesign.java

private void addAllKeyCombinationActions() {
    addKeyCombinationAction("Resets the tool", new AbstractAction() {
        @Override/* ww w  .ja  v  a  2  s  . com*/
        public void actionPerformed(ActionEvent e) {
            resetButton();
        }
    }, KeyStroke.getKeyStroke(KeyEvent.VK_R, InputEvent.CTRL_DOWN_MASK));

    addKeyCombinationAction("Outputs current design to console", new AbstractAction() {
        @Override
        public void actionPerformed(ActionEvent e) {
            System.out.println(getDesign().toString());
        }
    }, KeyStroke.getKeyStroke(KeyEvent.VK_F11, InputEvent.CTRL_DOWN_MASK));

    /* FROM THE OFFLINE ALGORITHM EXECUTION */

    addKeyCombinationAction("Execute algorithm", new AbstractAction() {
        @Override
        public void actionPerformed(ActionEvent e) {
            executionPane.doClickInExecutionButton();
        }
    }, KeyStroke.getKeyStroke(KeyEvent.VK_E, KeyEvent.CTRL_DOWN_MASK));

    /* From the TOPOLOGY PANEL */
    addKeyCombinationAction("Load design", new AbstractAction() {
        @Override
        public void actionPerformed(ActionEvent e) {
            topologyPanel.loadDesign();
        }
    }, KeyStroke.getKeyStroke(KeyEvent.VK_O, InputEvent.CTRL_DOWN_MASK));

    addKeyCombinationAction("Save design", new AbstractAction() {
        @Override
        public void actionPerformed(ActionEvent e) {
            topologyPanel.saveDesign();
        }
    }, KeyStroke.getKeyStroke(KeyEvent.VK_S, InputEvent.CTRL_DOWN_MASK));

    addKeyCombinationAction("Zoom in", new AbstractAction() {
        @Override
        public void actionPerformed(ActionEvent e) {
            if (topologyPanel.getSize().getWidth() != 0 && topologyPanel.getSize().getHeight() != 0)
                topologyPanel.getCanvas().zoomIn();
        }
    }, KeyStroke.getKeyStroke(KeyEvent.VK_ADD, InputEvent.CTRL_DOWN_MASK),
            KeyStroke.getKeyStroke(KeyEvent.VK_PLUS, InputEvent.CTRL_DOWN_MASK));

    addKeyCombinationAction("Zoom out", new AbstractAction() {
        @Override
        public void actionPerformed(ActionEvent e) {
            if (topologyPanel.getSize().getWidth() != 0 && topologyPanel.getSize().getHeight() != 0)
                topologyPanel.getCanvas().zoomOut();
        }
    }, KeyStroke.getKeyStroke(KeyEvent.VK_SUBTRACT, InputEvent.CTRL_DOWN_MASK),
            KeyStroke.getKeyStroke(KeyEvent.VK_MINUS, InputEvent.CTRL_DOWN_MASK));

    addKeyCombinationAction("Zoom all", new AbstractAction() {
        @Override
        public void actionPerformed(ActionEvent e) {
            if (topologyPanel.getSize().getWidth() != 0 && topologyPanel.getSize().getHeight() != 0)
                topologyPanel.getCanvas().zoomAll();
        }
    }, KeyStroke.getKeyStroke(KeyEvent.VK_MULTIPLY, InputEvent.CTRL_DOWN_MASK));

    addKeyCombinationAction("Take snapshot", new AbstractAction() {
        @Override
        public void actionPerformed(ActionEvent e) {
            topologyPanel.takeSnapshot();
        }
    }, KeyStroke.getKeyStroke(KeyEvent.VK_F12, InputEvent.CTRL_DOWN_MASK));

    addKeyCombinationAction("Load traffic demands", new AbstractAction() {
        @Override
        public void actionPerformed(ActionEvent e) {
            topologyPanel.loadTrafficDemands();
        }
    }, KeyStroke.getKeyStroke(KeyEvent.VK_T, InputEvent.CTRL_DOWN_MASK));

    /* FROM REPORT */
    addKeyCombinationAction("Close selected report", new AbstractAction() {
        @Override
        public void actionPerformed(ActionEvent e) {
            int tab = reportPane.getReportContainer().getSelectedIndex();
            if (tab == -1)
                return;
            reportPane.getReportContainer().remove(tab);
        }
    }, KeyStroke.getKeyStroke(KeyEvent.VK_W, InputEvent.CTRL_DOWN_MASK));

    addKeyCombinationAction("Close all reports", new AbstractAction() {
        @Override
        public void actionPerformed(ActionEvent e) {
            reportPane.getReportContainer().removeAll();
        }
    }, KeyStroke.getKeyStroke(KeyEvent.VK_W, InputEvent.CTRL_DOWN_MASK | InputEvent.SHIFT_DOWN_MASK));

    /* Online simulation */
    addKeyCombinationAction("Run simulation", new AbstractAction() {
        @Override
        public void actionPerformed(ActionEvent e) {
            try {
                if (onlineSimulationPane.isRunButtonEnabled())
                    onlineSimulationPane.runSimulation(false);
            } catch (Net2PlanException ex) {
                if (ErrorHandling.isDebugEnabled())
                    ErrorHandling.addErrorOrException(ex, OnlineSimulationPane.class);
                ErrorHandling.showErrorDialog(ex.getMessage(), "Error executing simulation");
            } catch (Throwable ex) {
                ErrorHandling.addErrorOrException(ex, OnlineSimulationPane.class);
                ErrorHandling.showErrorDialog("An error happened");
            }

        }
    }, KeyStroke.getKeyStroke(KeyEvent.VK_U, InputEvent.CTRL_DOWN_MASK));

    // Windows
    addKeyCombinationAction("Show control window", new AbstractAction() {
        @Override
        public void actionPerformed(ActionEvent e) {
            WindowController.showTablesWindow(true);
        }
    }, KeyStroke.getKeyStroke(KeyEvent.VK_1, ActionEvent.ALT_MASK + ActionEvent.SHIFT_MASK));

    viewEditTopTables.setInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW,
            this.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW));
    viewEditTopTables.setActionMap(this.getActionMap());

    reportPane.setInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW,
            this.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW));
    reportPane.setActionMap(this.getActionMap());

    executionPane.setInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW,
            this.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW));
    executionPane.setActionMap(this.getActionMap());

    onlineSimulationPane.setInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW,
            this.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW));
    onlineSimulationPane.setActionMap(this.getActionMap());

    whatIfAnalysisPane.setInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW,
            this.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW));
    whatIfAnalysisPane.setActionMap(this.getActionMap());
}

From source file:net.sourceforge.entrainer.gui.EntrainerFX.java

private void addMnemonic(JMenuItem item, int charKey) {
    item.setMnemonic(charKey);/*from  www.  j av a 2 s  . co  m*/
    if (!(item instanceof JMenu)) {
        item.setAccelerator(KeyStroke.getKeyStroke(charKey, InputEvent.CTRL_DOWN_MASK));
    }
}

From source file:org.jas.gui.MainWindow.java

private void registerKeyStrokeAction() {
    KeyStroke ctrlo = KeyStroke.getKeyStroke(KeyEvent.VK_O, InputEvent.CTRL_DOWN_MASK);
    KeyStroke enter = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0);
    inputMap = getOpenButton().getInputMap(JButton.WHEN_IN_FOCUSED_WINDOW);
    inputMap.put(ctrlo, CTRL_O);//from  ww w.j  ava2  s .c  om
    inputMap.put(enter, ENTER);
    getOpenButton().getActionMap().put(CTRL_O, new ClickAction(getOpenButton()));
    getOpenButton().getActionMap().put(ENTER, new ClickAction(getOpenButton()));
}

From source file:edu.ku.brc.specify.Specify.java

/**
 * Create menus//from w  ww . j av a 2 s  .  c o  m
 */
public JMenuBar createMenus() {
    JMenuBar mb = new JMenuBar();
    JMenuItem mi;

    //--------------------------------------------------------------------
    //-- File Menu
    //--------------------------------------------------------------------

    JMenu menu = null;

    if (!UIHelper.isMacOS() || !isWorkbenchOnly) {
        menu = UIHelper.createLocalizedMenu(mb, "Specify.FILE_MENU", "Specify.FILE_MNEU"); //$NON-NLS-1$ //$NON-NLS-2$
    }

    if (!isWorkbenchOnly) {
        // Add Menu for switching Collection
        String title = "Specify.CHANGE_COLLECTION"; //$NON-NLS-1$
        String mnu = "Specify.CHANGE_COLL_MNEU"; //$NON-NLS-1$
        changeCollectionMenuItem = UIHelper.createLocalizedMenuItem(menu, title, mnu, title, false, null);
        changeCollectionMenuItem.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent ae) {
                if (SubPaneMgr.getInstance().aboutToShutdown()) {

                    // Actually we really need to start over
                    // "true" means that it should NOT use any cached values it can find to automatically initialize itself
                    // instead it should ask the user any questions as if it were starting over
                    restartApp(null, databaseName, userName, true, false);
                }
            }
        });

        menu.addMenuListener(new MenuListener() {
            @Override
            public void menuCanceled(MenuEvent e) {
            }

            @Override
            public void menuDeselected(MenuEvent e) {
            }

            @Override
            public void menuSelected(MenuEvent e) {
                boolean enable = Uploader.getCurrentUpload() == null
                        && ((SpecifyAppContextMgr) AppContextMgr.getInstance()).getNumOfCollectionsForUser() > 1
                        && !TaskMgr.areTasksDisabled();

                changeCollectionMenuItem.setEnabled(enable);
            }

        });
    }

    if (UIHelper.getOSType() != UIHelper.OSTYPE.MacOSX) {
        if (!UIRegistry.isMobile()) {
            menu.addSeparator();
        }
        String title = "Specify.EXIT"; //$NON-NLS-1$
        String mnu = "Specify.Exit_MNEU"; //$NON-NLS-1$
        mi = UIHelper.createLocalizedMenuItem(menu, title, mnu, title, true, null);
        if (!UIHelper.isMacOS()) {
            mi.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Q, InputEvent.CTRL_DOWN_MASK));
        }
        mi.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent ae) {
                doExit(true);
            }
        });
    }

    menu = UIRegistry.getInstance().createEditMenu();
    mb.add(menu);

    //menu = UIHelper.createMenu(mb, "EditMenu", "EditMneu");
    if (UIHelper.getOSType() != UIHelper.OSTYPE.MacOSX) {
        menu.addSeparator();
        String title = "Specify.PREFERENCES"; //$NON-NLS-1$
        String mnu = "Specify.PREFERENCES_MNEU";//$NON-NLS-1$
        mi = UIHelper.createLocalizedMenuItem(menu, title, mnu, title, false, null);
        mi.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent ae) {
                doPreferences();
            }
        });
        mi.setEnabled(true);
    }

    //--------------------------------------------------------------------
    //-- Data Menu
    //--------------------------------------------------------------------
    JMenu dataMenu = UIHelper.createLocalizedMenu(mb, "Specify.DATA_MENU", "Specify.DATA_MNEU"); //$NON-NLS-1$ //$NON-NLS-2$
    ResultSetController.addMenuItems(dataMenu);
    dataMenu.addSeparator();

    // Save And New Menu Item
    Action saveAndNewAction = new AbstractAction(getResourceString("Specify.SAVE_AND_NEW")) { //$NON-NLS-1$
        public void actionPerformed(ActionEvent e) {
            FormViewObj fvo = getCurrentFVO();
            if (fvo != null) {
                fvo.setSaveAndNew(((JCheckBoxMenuItem) e.getSource()).isSelected());
            }
        }
    };
    saveAndNewAction.setEnabled(false);
    JCheckBoxMenuItem saveAndNewCBMI = new JCheckBoxMenuItem(saveAndNewAction);
    dataMenu.add(saveAndNewCBMI);
    UIRegistry.register("SaveAndNew", saveAndNewCBMI); //$NON-NLS-1$
    UIRegistry.registerAction("SaveAndNew", saveAndNewAction); //$NON-NLS-1$
    mb.add(dataMenu);

    // Configure Carry Forward
    Action configCarryForwardAction = new AbstractAction(
            getResourceString("Specify.CONFIG_CARRY_FORWARD_MENU")) { //$NON-NLS-1$
        public void actionPerformed(ActionEvent e) {
            FormViewObj fvo = getCurrentFVO();
            if (fvo != null) {
                fvo.configureCarryForward();
            }
        }
    };
    configCarryForwardAction.setEnabled(false);
    JMenuItem configCFWMI = new JMenuItem(configCarryForwardAction);
    dataMenu.add(configCFWMI);
    UIRegistry.register("ConfigCarryForward", configCFWMI); //$NON-NLS-1$
    UIRegistry.registerAction("ConfigCarryForward", configCarryForwardAction); //$NON-NLS-1$
    mb.add(dataMenu);

    //---------------------------------------
    // Carry Forward Menu Item (On / Off)
    Action carryForwardAction = new AbstractAction(getResourceString("Specify.CARRY_FORWARD_CHECKED_MENU")) { //$NON-NLS-1$
        public void actionPerformed(ActionEvent e) {
            FormViewObj fvo = getCurrentFVO();
            if (fvo != null) {
                fvo.toggleCarryForward();
                ((JCheckBoxMenuItem) e.getSource()).setSelected(fvo.isDoCarryForward());
            }
        }
    };
    carryForwardAction.setEnabled(false);
    JCheckBoxMenuItem carryForwardCBMI = new JCheckBoxMenuItem(carryForwardAction);
    dataMenu.add(carryForwardCBMI);
    UIRegistry.register("CarryForward", carryForwardCBMI); //$NON-NLS-1$
    UIRegistry.registerAction("CarryForward", carryForwardAction); //$NON-NLS-1$
    mb.add(dataMenu);

    if (!isWorkbenchOnly) {
        final String AUTO_NUM = "AutoNumbering";
        //---------------------------------------
        // AutoNumber Menu Item (On / Off)
        Action autoNumberOnOffAction = new AbstractAction(
                getResourceString("FormViewObj.SET_AUTONUMBER_ONOFF")) { //$NON-NLS-1$
            public void actionPerformed(ActionEvent e) {
                FormViewObj fvo = getCurrentFVO();
                if (fvo != null) {
                    fvo.toggleAutoNumberOnOffState();
                    ((JCheckBoxMenuItem) e.getSource()).setSelected(fvo.isAutoNumberOn());
                }
            }
        };
        autoNumberOnOffAction.setEnabled(false);
        JCheckBoxMenuItem autoNumCBMI = new JCheckBoxMenuItem(autoNumberOnOffAction);
        dataMenu.add(autoNumCBMI);
        UIRegistry.register(AUTO_NUM, autoNumCBMI); //$NON-NLS-1$
        UIRegistry.registerAction(AUTO_NUM, autoNumberOnOffAction); //$NON-NLS-1$
    }

    if (System.getProperty("user.name").equals("rods")) {
        dataMenu.addSeparator();

        AbstractAction gpxAction = new AbstractAction("GPS Data") {
            @Override
            public void actionPerformed(ActionEvent e) {
                GPXPanel.getDlgInstance().setVisible(true);
            }
        };
        JMenuItem gpxMI = new JMenuItem(gpxAction);
        dataMenu.add(gpxMI);
        UIRegistry.register("GPXDlg", gpxMI); //$NON-NLS-1$
        UIRegistry.registerAction("GPXDlg", gpxAction); //$NON-NLS-1$
    }

    mb.add(dataMenu);

    SubPaneMgr.getInstance(); // force creating of the Mgr so the menu Actions are created.

    //--------------------------------------------------------------------
    //-- System Menu
    //--------------------------------------------------------------------

    if (!isWorkbenchOnly) {
        // TODO This needs to be moved into the SystemTask, but right now there is no way
        // to ask a task for a menu.
        menu = UIHelper.createLocalizedMenu(mb, "Specify.SYSTEM_MENU", "Specify.SYSTEM_MNEU"); //$NON-NLS-1$ //$NON-NLS-2$

        /*if (true)
        {
        menu = UIHelper.createMenu(mb, "Forms", "o");
        Action genForms = new AbstractAction()
        {
            public void actionPerformed(ActionEvent ae)
            {
                FormGenerator fg = new FormGenerator();
                fg.generateForms();
            }
        };
        mi = UIHelper.createMenuItemWithAction(menu, "Generate All Forms", "G", "", true, genForms);
        }*/
    }

    //--------------------------------------------------------------------
    //-- Tab Menu
    //--------------------------------------------------------------------
    menu = UIHelper.createLocalizedMenu(mb, "Specify.TABS_MENU", "Specify.TABS_MNEU"); //$NON-NLS-1$ //$NON-NLS-2$

    String ttl = UIRegistry.getResourceString("Specify.SBP_CLOSE_CUR_MENU");
    String mnu = UIRegistry.getResourceString("Specify.SBP_CLOSE_CUR_MNEU");
    mi = UIHelper.createMenuItemWithAction(menu, ttl, mnu, ttl, true, getAction("CloseCurrent"));
    if (!UIHelper.isMacOS()) {
        mi.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_W, InputEvent.CTRL_DOWN_MASK));
    }

    ttl = UIRegistry.getResourceString("Specify.SBP_CLOSE_ALL_MENU");
    mnu = UIRegistry.getResourceString("Specify.SBP_CLOSE_ALL_MNEU");
    mi = UIHelper.createMenuItemWithAction(menu, ttl, mnu, ttl, true, getAction("CloseAll"));
    if (!UIHelper.isMacOS()) {
        mi.setAccelerator(
                KeyStroke.getKeyStroke(KeyEvent.VK_W, InputEvent.CTRL_DOWN_MASK | InputEvent.SHIFT_DOWN_MASK));
    }

    ttl = UIRegistry.getResourceString("Specify.SBP_CLOSE_ALLBUT_MENU");
    mnu = UIRegistry.getResourceString("Specify.SBP_CLOSE_ALLBUT_MNEU");
    mi = UIHelper.createMenuItemWithAction(menu, ttl, mnu, ttl, true, getAction("CloseAllBut"));

    menu.addSeparator();

    // Configure Task
    JMenuItem configTaskMI = new JMenuItem(getAction("ConfigureTask"));
    menu.add(configTaskMI);
    //UIRegistry.register("ConfigureTask", configTaskMI); //$NON-NLS-1$

    //--------------------------------------------------------------------
    //-- Debug Menu
    //--------------------------------------------------------------------

    boolean doDebug = AppPreferences.getLocalPrefs().getBoolean("debug.menu", false);
    if (!UIRegistry.isRelease() || doDebug) {
        menu = UIHelper.createLocalizedMenu(mb, "Specify.DEBUG_MENU", "Specify.DEBUG_MNEU"); //$NON-NLS-1$ //$NON-NLS-2$
        String ttle = "Specify.SHOW_LOC_PREFS";//$NON-NLS-1$ 
        String mneu = "Specify.SHOW_LOC_PREF_MNEU";//$NON-NLS-1$ 
        String desc = "Specify.SHOW_LOC_PREFS";//$NON-NLS-1$ 
        mi = UIHelper.createLocalizedMenuItem(menu, ttle, mneu, desc, true, null);
        mi.addActionListener(new ActionListener() {
            @SuppressWarnings("synthetic-access") //$NON-NLS-1$ 
            public void actionPerformed(ActionEvent ae) {
                openLocalPrefs();
            }
        });

        ttle = "Specify.SHOW_REM_PREFS";//$NON-NLS-1$ 
        mneu = "Specify.SHOW_REM_PREFS_MNEU";//$NON-NLS-1$ 
        desc = "Specify.SHOW_REM_PREFS";//$NON-NLS-1$ 
        mi = UIHelper.createLocalizedMenuItem(menu, ttle, mneu, desc, true, null);
        mi.addActionListener(new ActionListener() {
            @SuppressWarnings("synthetic-access") //$NON-NLS-1$
            public void actionPerformed(ActionEvent ae) {
                openRemotePrefs();
            }
        });

        menu.addSeparator();

        ttle = "Specify.CONFIG_LOGGERS";//$NON-NLS-1$ 
        mneu = "Specify.CONFIG_LOGGERS_MNEU";//$NON-NLS-1$ 
        desc = "Specify.CONFIG_LOGGER";//$NON-NLS-1$ 
        mi = UIHelper.createLocalizedMenuItem(menu, ttle, mneu, desc, true, null);
        mi.addActionListener(new ActionListener() {
            @SuppressWarnings("synthetic-access") //$NON-NLS-1$
            public void actionPerformed(ActionEvent ae) {
                final LoggerDialog dialog = new LoggerDialog(topFrame);
                UIHelper.centerAndShow(dialog);
            }
        });

        ttle = "Specify.CONFIG_DEBUG_LOGGERS";//$NON-NLS-1$ 
        mneu = "Specify.CONFIG_DEBUG_LOGGERS_MNEU";//$NON-NLS-1$ 
        desc = "Specify.CONFIG_DEBUG_LOGGER";//$NON-NLS-1$ 
        mi = UIHelper.createLocalizedMenuItem(menu, ttle, mneu, desc, true, null);
        mi.addActionListener(new ActionListener() {
            @SuppressWarnings("synthetic-access") //$NON-NLS-1$
            public void actionPerformed(ActionEvent ae) {
                DebugLoggerDialog dialog = new DebugLoggerDialog(topFrame);
                UIHelper.centerAndShow(dialog);
            }
        });

        menu.addSeparator();

        ttle = "Specify.SHOW_MEM_STATS";//$NON-NLS-1$ 
        mneu = "Specify.SHOW_MEM_STATS_MNEU";//$NON-NLS-1$ 
        desc = "Specify.SHOW_MEM_STATS";//$NON-NLS-1$ 
        mi = UIHelper.createLocalizedMenuItem(menu, ttle, mneu, desc, true, null);
        mi.addActionListener(new ActionListener() {
            @SuppressWarnings("synthetic-access") //$NON-NLS-1$
            public void actionPerformed(ActionEvent ae) {
                System.gc();
                System.runFinalization();

                // Get current size of heap in bytes
                double meg = 1024.0 * 1024.0;
                double heapSize = Runtime.getRuntime().totalMemory() / meg;

                // Get maximum size of heap in bytes. The heap cannot grow beyond this size.
                // Any attempt will result in an OutOfMemoryException.
                double heapMaxSize = Runtime.getRuntime().maxMemory() / meg;

                // Get amount of free memory within the heap in bytes. This size will increase
                // after garbage collection and decrease as new objects are created.
                double heapFreeSize = Runtime.getRuntime().freeMemory() / meg;

                UIRegistry.getStatusBar()
                        .setText(String.format("Heap Size: %7.2f    Max: %7.2f    Free: %7.2f   Used: %7.2f", //$NON-NLS-1$
                                heapSize, heapMaxSize, heapFreeSize, (heapSize - heapFreeSize)));
            }
        });

        JMenu prefsMenu = new JMenu(UIRegistry.getResourceString("Specify.PREFS_IMPORT_EXPORT")); //$NON-NLS-1$
        menu.add(prefsMenu);
        ttle = "Specify.IMPORT_MENU";//$NON-NLS-1$ 
        mneu = "Specify.IMPORT_MNEU";//$NON-NLS-1$ 
        desc = "Specify.IMPORT_PREFS";//$NON-NLS-1$ 
        mi = UIHelper.createLocalizedMenuItem(prefsMenu, ttle, mneu, desc, true, null);
        mi.addActionListener(new ActionListener() {
            @SuppressWarnings("synthetic-access") //$NON-NLS-1$
            public void actionPerformed(ActionEvent ae) {
                importPrefs();
            }
        });
        ttle = "Specify.EXPORT_MENU";//$NON-NLS-1$ 
        mneu = "Specify.EXPORT_MNEU";//$NON-NLS-1$ 
        desc = "Specify.EXPORT_PREFS";//$NON-NLS-1$ 
        mi = UIHelper.createLocalizedMenuItem(prefsMenu, ttle, mneu, desc, true, null);
        mi.addActionListener(new ActionListener() {
            @SuppressWarnings("synthetic-access") //$NON-NLS-1$
            public void actionPerformed(ActionEvent ae) {
                exportPrefs();
            }
        });

        ttle = "Associate Storage Items";//$NON-NLS-1$ 
        mneu = "A";//$NON-NLS-1$ 
        desc = "";//$NON-NLS-1$ 
        mi = UIHelper.createMenuItemWithAction(menu, ttle, mneu, desc, true, null);
        mi.addActionListener(new ActionListener() {
            @SuppressWarnings("synthetic-access") //$NON-NLS-1$
            public void actionPerformed(ActionEvent ae) {
                associateStorageItems();
            }
        });

        ttle = "Load GPX Points";//$NON-NLS-1$ 
        mneu = "a";//$NON-NLS-1$ 
        desc = "";//$NON-NLS-1$ 
        mi = UIHelper.createMenuItemWithAction(menu, ttle, mneu, desc, true, null);
        mi.addActionListener(new ActionListener() {
            @SuppressWarnings("synthetic-access") //$NON-NLS-1$
            public void actionPerformed(ActionEvent ae) {
                CustomDialog dlg = GPXPanel.getDlgInstance();
                if (dlg != null) {
                    dlg.setVisible(true);
                }
            }
        });

        JCheckBoxMenuItem cbMenuItem = new JCheckBoxMenuItem("Security Activated"); //$NON-NLS-1$
        menu.add(cbMenuItem);
        cbMenuItem.setSelected(AppContextMgr.isSecurityOn());
        cbMenuItem.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent ae) {
                boolean isSecurityOn = !SpecifyAppContextMgr.isSecurityOn();
                AppContextMgr.getInstance().setSecurity(isSecurityOn);
                ((JMenuItem) ae.getSource()).setSelected(isSecurityOn);

                JLabel secLbl = statusField.getSectionLabel(3);
                if (secLbl != null) {
                    secLbl.setIcon(IconManager.getImage(isSecurityOn ? "SecurityOn" : "SecurityOff",
                            IconManager.IconSize.Std16));
                    secLbl.setHorizontalAlignment(SwingConstants.CENTER);
                    secLbl.setToolTipText(getResourceString("Specify.SEC_" + (isSecurityOn ? "ON" : "OFF")));
                }
            }
        });

        JMenuItem sizeMenuItem = new JMenuItem("Set to " + PREFERRED_WIDTH + "x" + PREFERRED_HEIGHT); //$NON-NLS-1$
        menu.add(sizeMenuItem);
        sizeMenuItem.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent ae) {
                topFrame.setSize(PREFERRED_WIDTH, PREFERRED_HEIGHT);
            }
        });
    }

    //----------------------------------------------------
    //-- Helper Menu
    //----------------------------------------------------

    JMenu helpMenu = UIHelper.createLocalizedMenu(mb, "Specify.HELP_MENU", "Specify.HELP_MNEU"); //$NON-NLS-1$ //$NON-NLS-2$
    HelpMgr.createHelpMenuItem(helpMenu, getResourceString("SPECIFY_HELP")); //$NON-NLS-1$
    helpMenu.addSeparator();

    String ttle = "Specify.LOG_SHOW_FILES";//$NON-NLS-1$ 
    String mneu = "Specify.LOG_SHOW_FILES_MNEU";//$NON-NLS-1$ 
    String desc = "Specify.LOG_SHOW_FILES";//$NON-NLS-1$      
    mi = UIHelper.createLocalizedMenuItem(helpMenu, ttle, mneu, desc, true, null);
    helpMenu.addSeparator();
    mi.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ae) {
            AppBase.displaySpecifyLogFiles();
        }
    });

    ttle = "SecurityAdminTask.CHANGE_PWD_MENU"; //$NON-NLS-1$
    mneu = "SecurityAdminTask.CHANGE_PWD_MNEU"; //$NON-NLS-1$
    desc = "SecurityAdminTask.CHANGE_PWD_DESC"; //$NON-NLS-1$
    mi = UIHelper.createLocalizedMenuItem(helpMenu, ttle, mneu, desc, true, null);
    mi.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ae) {
            SecurityAdminTask.changePassword(true);
        }
    });

    ttle = "Specify.CHECK_UPDATE";//$NON-NLS-1$ 
    mneu = "Specify.CHECK_UPDATE_MNEU";//$NON-NLS-1$ 
    desc = "Specify.CHECK_UPDATE_DESC";//$NON-NLS-1$      
    mi = UIHelper.createLocalizedMenuItem(helpMenu, ttle, mneu, desc, true, null);
    mi.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ae) {
            checkForUpdates();
        }
    });

    ttle = "Specify.AUTO_REG";//$NON-NLS-1$ 
    mneu = "Specify.AUTO_REG_MNEU";//$NON-NLS-1$ 
    desc = "Specify.AUTO_REG_DESC";//$NON-NLS-1$      
    mi = UIHelper.createLocalizedMenuItem(helpMenu, ttle, mneu, desc, true, null);
    mi.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ae) {
            RegisterSpecify.register(true, 0);
        }
    });

    ttle = "Specify.SA_REG";//$NON-NLS-1$ 
    mneu = "Specify.SA_REG_MNEU";//$NON-NLS-1$ 
    desc = "Specify.SA_REG_DESC";//$NON-NLS-1$      
    mi = UIHelper.createLocalizedMenuItem(helpMenu, ttle, mneu, desc, true, null);
    mi.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ae) {
            RegisterSpecify.registerISA();
        }
    });

    ttle = "Specify.FEEDBACK";//$NON-NLS-1$ 
    mneu = "Specify.FB_MNEU";//$NON-NLS-1$ 
    desc = "Specify.FB_DESC";//$NON-NLS-1$      
    mi = UIHelper.createLocalizedMenuItem(helpMenu, ttle, mneu, desc, true, null);
    mi.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ae) {
            FeedBackDlg feedBackDlg = new FeedBackDlg();
            feedBackDlg.sendFeedback();
        }
    });

    if (UIHelper.getOSType() != UIHelper.OSTYPE.MacOSX) {
        helpMenu.addSeparator();

        ttle = "Specify.ABOUT";//$NON-NLS-1$ 
        mneu = "Specify.ABOUTMNEU";//$NON-NLS-1$ 
        desc = "Specify.ABOUT";//$NON-NLS-1$ 
        mi = UIHelper.createLocalizedMenuItem(helpMenu, ttle, mneu, desc, true, null);
        mi.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent ae) {
                doAbout();
            }
        });
    }
    return mb;
}

From source file:org.forester.archaeopteryx.TreePanel.java

final private void keyPressedCalls(final KeyEvent e) {
    if (isOvOn() && (getMousePosition() != null) && (getMousePosition().getLocation() != null)) {
        if (inOvVirtualRectangle(getMousePosition().x, getMousePosition().y)) {
            if (!isInOvRect()) {
                setInOvRect(true);/*from   w ww.  j av a 2  s . c  om*/
            }
        } else if (isInOvRect()) {
            setInOvRect(false);
        }
    }
    if (e.getModifiersEx() == InputEvent.CTRL_DOWN_MASK) {
        if ((e.getKeyCode() == KeyEvent.VK_DELETE) || (e.getKeyCode() == KeyEvent.VK_HOME)
                || (e.getKeyCode() == KeyEvent.VK_F)) {
            getMainPanel().getTreeFontSet().mediumFonts();
            getMainPanel().getControlPanel().displayedPhylogenyMightHaveChanged(true);
        } else if ((e.getKeyCode() == KeyEvent.VK_SUBTRACT) || (e.getKeyCode() == KeyEvent.VK_MINUS)) {
            getMainPanel().getTreeFontSet().decreaseFontSize();
            getMainPanel().getControlPanel().displayedPhylogenyMightHaveChanged(true);
        } else if (plusPressed(e.getKeyCode())) {
            getMainPanel().getTreeFontSet().increaseFontSize();
            getMainPanel().getControlPanel().displayedPhylogenyMightHaveChanged(true);
        }
    } else {
        if ((e.getKeyCode() == KeyEvent.VK_DELETE) || (e.getKeyCode() == KeyEvent.VK_HOME)
                || (e.getKeyCode() == KeyEvent.VK_F)) {
            getControlPanel().showWhole();
        } else if ((e.getKeyCode() == KeyEvent.VK_UP) || (e.getKeyCode() == KeyEvent.VK_DOWN)
                || (e.getKeyCode() == KeyEvent.VK_LEFT) || (e.getKeyCode() == KeyEvent.VK_RIGHT)) {
            if (e.getModifiersEx() == InputEvent.SHIFT_DOWN_MASK) {
                if (e.getKeyCode() == KeyEvent.VK_UP) {
                    getMainPanel().getControlPanel().zoomInY(Constants.WHEEL_ZOOM_IN_FACTOR);
                    getMainPanel().getControlPanel().displayedPhylogenyMightHaveChanged(false);
                } else if (e.getKeyCode() == KeyEvent.VK_DOWN) {
                    getMainPanel().getControlPanel().zoomOutY(Constants.WHEEL_ZOOM_OUT_FACTOR);
                    getMainPanel().getControlPanel().displayedPhylogenyMightHaveChanged(false);
                } else if (e.getKeyCode() == KeyEvent.VK_LEFT) {
                    getMainPanel().getControlPanel().zoomOutX(Constants.WHEEL_ZOOM_OUT_FACTOR,
                            Constants.WHEEL_ZOOM_OUT_X_CORRECTION_FACTOR);
                    getMainPanel().getControlPanel().displayedPhylogenyMightHaveChanged(false);
                } else if (e.getKeyCode() == KeyEvent.VK_RIGHT) {
                    getMainPanel().getControlPanel().zoomInX(Constants.WHEEL_ZOOM_IN_FACTOR,
                            Constants.WHEEL_ZOOM_IN_FACTOR);
                    getMainPanel().getControlPanel().displayedPhylogenyMightHaveChanged(false);
                }
            } else {
                final int d = 80;
                int dx = 0;
                int dy = -d;
                if (e.getKeyCode() == KeyEvent.VK_DOWN) {
                    dy = d;
                } else if (e.getKeyCode() == KeyEvent.VK_LEFT) {
                    dx = -d;
                    dy = 0;
                } else if (e.getKeyCode() == KeyEvent.VK_RIGHT) {
                    dx = d;
                    dy = 0;
                }
                final Point scroll_position = getMainPanel().getCurrentScrollPane().getViewport()
                        .getViewPosition();
                scroll_position.x = scroll_position.x + dx;
                scroll_position.y = scroll_position.y + dy;
                if (scroll_position.x <= 0) {
                    scroll_position.x = 0;
                } else {
                    final int max_x = getMainPanel().getCurrentScrollPane().getHorizontalScrollBar()
                            .getMaximum()
                            - getMainPanel().getCurrentScrollPane().getHorizontalScrollBar().getVisibleAmount();
                    if (scroll_position.x >= max_x) {
                        scroll_position.x = max_x;
                    }
                }
                if (scroll_position.y <= 0) {
                    scroll_position.y = 0;
                } else {
                    final int max_y = getMainPanel().getCurrentScrollPane().getVerticalScrollBar().getMaximum()
                            - getMainPanel().getCurrentScrollPane().getVerticalScrollBar().getVisibleAmount();
                    if (scroll_position.y >= max_y) {
                        scroll_position.y = max_y;
                    }
                }
                repaint();
                getMainPanel().getCurrentScrollPane().getViewport().setViewPosition(scroll_position);
            }
        } else if ((e.getKeyCode() == KeyEvent.VK_SUBTRACT) || (e.getKeyCode() == KeyEvent.VK_MINUS)) {
            getMainPanel().getControlPanel().zoomOutY(Constants.WHEEL_ZOOM_OUT_FACTOR);
            getMainPanel().getControlPanel().zoomOutX(Constants.WHEEL_ZOOM_OUT_FACTOR,
                    Constants.WHEEL_ZOOM_OUT_X_CORRECTION_FACTOR);
            getMainPanel().getControlPanel().displayedPhylogenyMightHaveChanged(false);
        } else if (plusPressed(e.getKeyCode())) {
            getMainPanel().getControlPanel().zoomInX(Constants.WHEEL_ZOOM_IN_FACTOR,
                    Constants.WHEEL_ZOOM_IN_FACTOR);
            getMainPanel().getControlPanel().zoomInY(Constants.WHEEL_ZOOM_IN_FACTOR);
            getMainPanel().getControlPanel().displayedPhylogenyMightHaveChanged(false);
        } else if (e.getKeyCode() == KeyEvent.VK_S) {
            if ((getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED)
                    || (getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR)) {
                setStartingAngle((getStartingAngle() % TWO_PI) + ANGLE_ROTATION_UNIT);
                getControlPanel().displayedPhylogenyMightHaveChanged(false);
            }
        } else if (e.getKeyCode() == KeyEvent.VK_A) {
            if ((getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED)
                    || (getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR)) {
                setStartingAngle((getStartingAngle() % TWO_PI) - ANGLE_ROTATION_UNIT);
                if (getStartingAngle() < 0) {
                    setStartingAngle(TWO_PI + getStartingAngle());
                }
                getControlPanel().displayedPhylogenyMightHaveChanged(false);
            }
        } else if (e.getKeyCode() == KeyEvent.VK_D) {
            boolean selected = false;
            if (getOptions().getNodeLabelDirection() == NODE_LABEL_DIRECTION.HORIZONTAL) {
                getOptions().setNodeLabelDirection(NODE_LABEL_DIRECTION.RADIAL);
                selected = true;
            } else {
                getOptions().setNodeLabelDirection(NODE_LABEL_DIRECTION.HORIZONTAL);
            }
            if (getMainPanel().getMainFrame() == null) {
                // Must be "E" applet version.
                final ArchaeopteryxE ae = (ArchaeopteryxE) ((MainPanelApplets) getMainPanel()).getApplet();
                if (ae.getlabelDirectionCbmi() != null) {
                    ae.getlabelDirectionCbmi().setSelected(selected);
                }
            } else {
                getMainPanel().getMainFrame().getlabelDirectionCbmi().setSelected(selected);
            }
            repaint();
        } else if (e.getKeyCode() == KeyEvent.VK_X) {
            switchDisplaygetPhylogenyGraphicsType();
            repaint();
        } else if (e.getKeyCode() == KeyEvent.VK_C) {
            cycleColors();
            repaint();
        } else if (getOptions().isShowOverview() && isOvOn() && (e.getKeyCode() == KeyEvent.VK_O)) {
            MainFrame.cycleOverview(getOptions(), this);
            repaint();
        } else if (getOptions().isShowOverview() && isOvOn() && (e.getKeyCode() == KeyEvent.VK_I)) {
            increaseOvSize();
        } else if (getOptions().isShowOverview() && isOvOn() && (e.getKeyCode() == KeyEvent.VK_U)) {
            decreaseOvSize();
        }
        e.consume();
    }
}

From source file:com.projity.contrib.calendar.JXXMonthView.java

protected void selectFromEvent(MouseEvent e) {
    boolean shift = (e.getModifiersEx() & InputEvent.SHIFT_DOWN_MASK) == InputEvent.SHIFT_DOWN_MASK;
    boolean control = (e.getModifiersEx() & InputEvent.CTRL_DOWN_MASK) == InputEvent.CTRL_DOWN_MASK;
    int x = e.getX();
    int y = e.getY();

    long selected = getDayAt(x, y);
    if (selected == -1) {
        return;/*  w  w  w .jav a 2  s. c  o  m*/
    }
    if (!control && !shift)
        clearSelection();

    DateSpan selection;
    if (selected <= WEEKDAY_OFFSET) { //hk
        int weekDayNum = (int) (-selected + WEEKDAY_OFFSET);
        selectWeekDay(weekDayNum);
        _asKirkWouldSay_FIRE = true;
        return;
    } else {
        if (_pivotDate == -1 || (!shift))
            selection = new DateSpan(selected, selected);
        else
            selection = new DateSpan(Math.min(_pivotDate, selected), Math.max(_pivotDate, selected));
    }

    select(selection);

    _pivotDate = selected;

    // Arm so we fire action performed on mouse release.
    _asKirkWouldSay_FIRE = true;

}

From source file:nz.govt.natlib.ndha.manualdeposit.ManualDepositMain.java

private void checkHotKey(java.awt.event.KeyEvent evt) {
    if ((evt.getModifiersEx() & InputEvent.ALT_DOWN_MASK) != 0) {
        if (evt.getKeyCode() == KeyEvent.VK_1) {
            showSearch(true);//from   www .  j a v  a2 s. c om
        } else if (evt.getKeyCode() == KeyEvent.VK_2) {
            showMetaData(true);
        }
    } else if ((evt.getModifiersEx() & InputEvent.CTRL_DOWN_MASK) != 0) {
        if (evt.getKeyCode() == KeyEvent.VK_S) {
            showSearch(true);
        } else if (evt.getKeyCode() == KeyEvent.VK_M) {
            showMetaData(true);
        }
    }
    if (evt.getKeyCode() == KeyEvent.VK_F5) {
        depositPresenter.refreshFileList();
    }
}

From source file:org.deegree.tools.rendering.InteractiveWPVS.java

@Override
public void keyPressed(KeyEvent ev) {

    int k = ev.getKeyCode();

    float scale = 1.01f;
    if ((ev.getModifiersEx()
            & (InputEvent.SHIFT_DOWN_MASK | InputEvent.CTRL_DOWN_MASK)) == InputEvent.SHIFT_DOWN_MASK) {
        // SHIFT (and not CTRL)
        scale = 1.10f;/*from w ww  . jav a 2  s. co  m*/
    } else if ((ev.getModifiersEx()
            & (InputEvent.SHIFT_DOWN_MASK | InputEvent.CTRL_DOWN_MASK)) == InputEvent.CTRL_DOWN_MASK) {
        // CTRL (and not SHIFT)
        scale /= 1.001;
    }

    switch (k) {
    case KeyEvent.VK_U: {
        this.updateLODStructure = !updateLODStructure;
        break;
    }
    case KeyEvent.VK_F11: {
        lodAnalyzerFrame.setVisible(!lodAnalyzerFrame.isVisible());
        this.setEnabled(true);
        break;
    }
    case KeyEvent.VK_T: {
        if (this.availableDatasets.contains("trees")) {
            renderTrees = !renderTrees;
            if (renderTrees) {
                this.currentDatasets.add(currentDatasets.size() - 1, "trees");
            } else {
                this.currentDatasets.remove("trees");
            }
        }
        break;
    }
    case KeyEvent.VK_C: {
        if (!this.availableColorMaps.isEmpty()) {
            this.currentColormap++;
            if (this.currentColormap >= this.availableColorMaps.size()) {
                this.currentColormap = -1;
            }
            if (this.currentColormap >= 0) {
                String title = this.availableColorMaps.get(currentColormap);
                List<String> cm = new ArrayList<String>(1);
                cm.add(title);
                this.activeColormap = new Pair<String, Colormap>(title,
                        this.perspectiveViewService.getColormap(cm, null));
                this.currentDatasets.add(title);
            } else {
                if (this.activeColormap != null) {
                    this.currentDatasets.remove(this.activeColormap.first);
                }
                this.activeColormap = null;
            }

        }
        break;
    }
    case KeyEvent.VK_B: {
        if (this.availableDatasets.contains("buildings")) {
            renderBuildings = !renderBuildings;
            renderTrees = !renderTrees;
            if (renderBuildings) {
                this.currentDatasets.add(currentDatasets.size() - 1, "buildings");
            } else {
                this.currentDatasets.remove("buildings");
            }
        }
        break;
    }
    case KeyEvent.VK_G: {
        getImage = true;
        break;
    }
    case KeyEvent.VK_1: {
        disableElevationModel = !disableElevationModel;
        if (disableElevationModel) {
            this.currentDatasets.remove("dem");
        } else {
            this.currentDatasets.add("dem");
        }
        break;
    }
    case KeyEvent.VK_2: {
        if (activeTextureManagers.length >= 1) {
            activeTextureManagers[0] = !activeTextureManagers[0];
            if (activeTextureManagers[0]) {
                this.currentDatasets.add(Math.min(currentDatasets.size(), 1), this.availableDatasets.get(1));
            } else {
                this.currentDatasets.remove(this.availableDatasets.get(1));
            }
        }
        break;
    }
    case KeyEvent.VK_3: {
        if (activeTextureManagers.length >= 2) {
            activeTextureManagers[1] = !activeTextureManagers[1];
            if (activeTextureManagers[1]) {
                this.currentDatasets.add(Math.min(currentDatasets.size(), 2), this.availableDatasets.get(2));
            } else {
                this.currentDatasets.remove(this.availableDatasets.get(2));
            }
        }
        break;
    }
    case KeyEvent.VK_4: {
        if (activeTextureManagers.length >= 3) {
            activeTextureManagers[2] = !activeTextureManagers[2];
            if (activeTextureManagers[2]) {
                this.currentDatasets.add(Math.min(currentDatasets.size(), 3), this.availableDatasets.get(3));
            } else {
                this.currentDatasets.remove(this.availableDatasets.get(3));
            }
        }
        break;
    }
    case KeyEvent.VK_5: {
        if (activeTextureManagers.length >= 4) {
            activeTextureManagers[3] = !activeTextureManagers[3];
            if (activeTextureManagers[3]) {
                this.currentDatasets.add(Math.min(currentDatasets.size(), 4), this.availableDatasets.get(4));
            } else {
                this.currentDatasets.remove(this.availableDatasets.get(4));
            }

        }
        break;
    }
    case KeyEvent.VK_6: {
        if (activeTextureManagers.length >= 5) {
            activeTextureManagers[4] = !activeTextureManagers[4];
            if (activeTextureManagers[4]) {
                this.currentDatasets.add(Math.min(currentDatasets.size(), 5), this.availableDatasets.get(5));
            } else {
                this.currentDatasets.remove(this.availableDatasets.get(5));
            }

        }
        break;
    }
    case KeyEvent.VK_7: {
        if (activeTextureManagers.length >= 6) {
            activeTextureManagers[5] = !activeTextureManagers[5];
            if (activeTextureManagers[5]) {
                this.currentDatasets.add(Math.min(currentDatasets.size(), 6), this.availableDatasets.get(6));
            } else {
                this.currentDatasets.remove(this.availableDatasets.get(6));
            }
        }
        break;
    }
    case KeyEvent.VK_8: {
        if (activeTextureManagers.length >= 7) {
            activeTextureManagers[6] = !activeTextureManagers[6];
            if (activeTextureManagers[6]) {
                this.currentDatasets.add(Math.min(currentDatasets.size(), 7), this.availableDatasets.get(7));
            } else {
                this.currentDatasets.remove(this.availableDatasets.get(7));
            }

        }
        break;
    }
    case KeyEvent.VK_9: {
        if (activeTextureManagers.length >= 8) {
            activeTextureManagers[7] = !activeTextureManagers[7];
            if (activeTextureManagers[7]) {
                this.currentDatasets.add(Math.min(currentDatasets.size(), 8), this.availableDatasets.get(8));
            } else {
                this.currentDatasets.remove(this.availableDatasets.get(8));
            }

        }
        break;
    }
    case KeyEvent.VK_PAGE_DOWN: {
        glRenderContext.setTerrainScale(glRenderContext.getTerrainScale() / scale);
        break;
    }
    case KeyEvent.VK_PAGE_UP: {
        glRenderContext.setTerrainScale(glRenderContext.getTerrainScale() * scale);
        break;
    }
    }
}