Example usage for java.awt.event KeyEvent VK_ENTER

List of usage examples for java.awt.event KeyEvent VK_ENTER

Introduction

In this page you can find the example usage for java.awt.event KeyEvent VK_ENTER.

Prototype

int VK_ENTER

To view the source code for java.awt.event KeyEvent VK_ENTER.

Click Source Link

Document

Constant for the ENTER virtual key.

Usage

From source file:burp.BurpExtender.java

private JPanel createMainPanel() {
    JPanel main = new JPanel();
    main.setLayout(new GridBagLayout());

    // Create Settings Panel
    JPanel settings = new JPanel(new GridBagLayout());

    createTitle("Settings", settings);
    KeyListener projectEnter = new KeyAdapter() {
        @Override/*from  w  w  w  .ja va 2 s  .  c o  m*/
        public void keyPressed(KeyEvent k) {
            if (k.getKeyCode() == KeyEvent.VK_ENTER)
                updateProjects();
        }
    };

    serverUrl = labelTextField("Server URL: ", settings,
            callbacks.loadExtensionSetting(BurpExtender.SERVER_KEY));
    serverUrl.addKeyListener(projectEnter);
    serverUrl.addFocusListener(new JTextFieldSettingFocusListener(BurpExtender.SERVER_KEY, callbacks));

    apiKey = labelTextField("API Key: ", settings, callbacks.loadExtensionSetting(BurpExtender.API_KEY));
    apiKey.addKeyListener(projectEnter);
    apiKey.addFocusListener(new JTextFieldSettingFocusListener(BurpExtender.API_KEY, callbacks));

    JButton targetRefresh = new JButton();
    targetRefresh.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            updateTargets();
        }
    });
    targetUrl = createComboBox("Target URL: ", settings, 3, targetRefresh);

    projectRefresh = new JButton();
    projectRefresh.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            Thread updateThread = new Thread() {
                public void run() {
                    NameValuePair selected = getProject();
                    if (selected != null)
                        callbacks.saveExtensionSetting(BurpExtender.PROJECT_KEY, selected.getValue());
                    updateProjects();
                }
            };
            updateThread.start();
        }
    });
    projectBox = createComboBox("Projects: ", settings, 4, projectRefresh);

    GridBagConstraints setGBC = new GridBagConstraints();
    setGBC.gridy = 3;
    setGBC.anchor = GridBagConstraints.NORTHWEST;
    main.add(settings, setGBC);

    // Separator
    Insets ins = new Insets(10, 10, 2, 10);

    JSeparator sep = new JSeparator(JSeparator.HORIZONTAL);
    callbacks.customizeUiComponent(sep);
    GridBagConstraints sepGBC = new GridBagConstraints();
    sepGBC.gridwidth = 3;
    sepGBC.gridx = 0;
    sepGBC.fill = GridBagConstraints.HORIZONTAL;
    sepGBC.insets = ins;
    main.add(sep, sepGBC);

    // Create Export Button
    JButton exportBtn = new JButton();
    exportBtn.setText("Send to Code Dx");
    exportBtn.addActionListener(new ExportActionListener(this, callbacks));
    callbacks.customizeUiComponent(exportBtn);
    GridBagConstraints btnGBC = new GridBagConstraints();
    btnGBC.gridx = 0;
    btnGBC.weightx = 1.0;
    btnGBC.weighty = 1.0;
    btnGBC.insets = ins;
    btnGBC.anchor = GridBagConstraints.NORTHWEST;
    main.add(exportBtn, btnGBC);

    updateTargets();
    return main;
}

From source file:com.mirth.connect.client.ui.browsers.event.EventBrowser.java

public void initComponentsManual() {
    this.addMouseListener(new java.awt.event.MouseAdapter() {

        public void mousePressed(java.awt.event.MouseEvent evt) {
            if (evt.isPopupTrigger()) {
                parent.eventPopupMenu.show(evt.getComponent(), evt.getX(), evt.getY());
            }/*from  ww w. j av  a 2 s  .  c o  m*/
        }

        public void mouseReleased(java.awt.event.MouseEvent evt) {
            if (evt.isPopupTrigger()) {
                parent.eventPopupMenu.show(evt.getComponent(), evt.getX(), evt.getY());
            }
        }
    });

    pageSizeField.setDocument(new MirthFieldConstraints(3, false, false, true));
    pageNumberField.setDocument(new MirthFieldConstraints(7, false, false, true));

    LineBorder lineBorder = new LineBorder(new Color(0, 0, 0));
    TitledBorder titledBorder = new TitledBorder("Current Search");
    titledBorder.setBorder(lineBorder);

    lastSearchCriteriaPane.setBorder(titledBorder);
    lastSearchCriteriaPane.setBackground(Color.white);
    lastSearchCriteria.setBackground(Color.white);

    startDatePicker.addPropertyChangeListener(new PropertyChangeListener() {
        @Override
        public void propertyChange(PropertyChangeEvent arg0) {
            allDayCheckBox.setEnabled(startDatePicker.getDate() != null || endDatePicker.getDate() != null);
            startTimePicker.setEnabled(startDatePicker.getDate() != null && !allDayCheckBox.isSelected());
        }
    });

    endDatePicker.addPropertyChangeListener(new PropertyChangeListener() {
        @Override
        public void propertyChange(PropertyChangeEvent arg0) {
            allDayCheckBox.setEnabled(startDatePicker.getDate() != null || endDatePicker.getDate() != null);
            endTimePicker.setEnabled(endDatePicker.getDate() != null && !allDayCheckBox.isSelected());
        }
    });

    pageNumberField.addKeyListener(new KeyAdapter() {

        @Override
        public void keyReleased(KeyEvent arg0) {
            if (arg0.getKeyCode() == KeyEvent.VK_ENTER && pageGoButton.isEnabled()) {
                jumpToPageNumber();
            }
        }
    });

    updateCachedUserMap();

    advancedSearchPopup = new EventBrowserAdvancedFilter(parent, "Advanced Search Filter", true, userMapById);
    advancedSearchPopup.setVisible(false);

    eventSplitPane.setDividerLocation(0.8);

    this.addAncestorListener(new AncestorListener() {

        @Override
        public void ancestorAdded(AncestorEvent event) {
        }

        @Override
        public void ancestorMoved(AncestorEvent event) {
        }

        @Override
        public void ancestorRemoved(AncestorEvent event) {
            // Stop waiting for event browser requests when the event browser 
            // is no longer being displayed
            parent.mirthClient.getServerConnection().abort(getAbortOperations());
            // Clear the event cache when leaving the event browser.
            parent.eventBrowser.clearCache();
        }

    });
}

From source file:net.sf.xmm.moviemanager.gui.DialogIMDB.java

JPanel createMoviehitsList() {
    /* Movies List panel...*/
    JPanel panelMoviesList = new JPanel();
    panelMoviesList.setBorder(BorderFactory.createCompoundBorder(
            BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(),
                    Localizer.get("DialogIMDB.panel-movie-list.title")), //$NON-NLS-1$
            BorderFactory.createEmptyBorder(5, 5, 5, 5)));

    listMovies = new JList() {

        public String getToolTipText(MouseEvent e) {

            if (getCellBounds(0, 0) == null)
                return null;

            String retVal = null;

            int row = (int) e.getPoint().getY() / (int) getCellBounds(0, 0).getHeight();

            if (row >= 0 && row < getModel().getSize()
                    && getMoviesList().getModel().getElementAt(row) instanceof ModelIMDbSearchHit) {
                retVal = ((ModelIMDbSearchHit) getMoviesList().getModel().getElementAt(row)).getAka();

                if (retVal != null && retVal.trim().equals("")) //$NON-NLS-1$
                    retVal = null;//  ww  w. j av  a 2 s . co m
            }

            return retVal;
        }

        public JToolTip createToolTip() {
            JMultiLineToolTip tooltip = new JMultiLineToolTip();
            tooltip.setComponent(this);
            return tooltip;
        }
    };

    // Unfortunately setting tooltip timeout affects ALL tooltips
    ToolTipManager ttm = ToolTipManager.sharedInstance();
    ttm.registerComponent(listMovies);
    ttm.setInitialDelay(0);
    ttm.setReshowDelay(0);

    listMovies.setFixedCellHeight(18);

    listMovies.setFont(new Font(listMovies.getFont().getName(), Font.PLAIN, listMovies.getFont().getSize()));
    listMovies.setLayoutOrientation(JList.VERTICAL);
    listMovies.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    listMovies.setCellRenderer(new MovieHitListCellRenderer());

    listMovies.addMouseListener(new MouseAdapter() {
        public void mouseClicked(MouseEvent event) {

            // Open we page
            if (SwingUtilities.isRightMouseButton(event)) {

                int index = listMovies.locationToIndex(event.getPoint());

                if (index >= 0) {
                    ModelIMDbSearchHit hit = (ModelIMDbSearchHit) listMovies.getModel().getElementAt(index);

                    if (hit.getUrlID() != null && !hit.getUrlID().equals("")) {
                        BrowserOpener opener = new BrowserOpener(hit.getCompleteUrl());
                        opener.executeOpenBrowser(MovieManager.getConfig().getSystemWebBrowser(),
                                MovieManager.getConfig().getBrowserPath());
                    }
                }
            } else if (SwingUtilities.isLeftMouseButton(event) && event.getClickCount() >= 2) {
                buttonSelect.doClick();
            }
        }
    });

    KeyStroke enterKeyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0, true);
    ActionListener listKeyBoardActionListener = new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            log.debug("ActionPerformed: " + "Movielist - ENTER pressed."); //$NON-NLS-1$
            buttonSelect.doClick();
        }
    };
    listMovies.registerKeyboardAction(listKeyBoardActionListener, enterKeyStroke, JComponent.WHEN_FOCUSED);

    JScrollPane scrollPaneMovies = new JScrollPane(listMovies);
    scrollPaneMovies.setAutoscrolls(true);
    //scrollPaneMovies.registerKeyboardAction(listKeyBoardActionListener,enterKeyStroke, JComponent.WHEN_FOCUSED);

    panelMoviesList.setLayout(new BorderLayout());
    panelMoviesList.add(scrollPaneMovies, BorderLayout.CENTER);

    return panelMoviesList;
}

From source file:org.orbisgis.sqlconsole.ui.SQLConsolePanel.java

/**
 * Create actions instances/* www .  j av  a  2s . c  o m*/
 * 
 * Each action is put in the Popup menu and the tool bar
 * Their shortcuts are registered also in the editor
 */
private void initActions() {
    //Execute Action
    executeAction = new DefaultAction(SQLAction.A_EXECUTE, I18N.tr("Execute"), I18N.tr("Run SQL statements"),
            SQLConsoleIcon.getIcon("execute"), EventHandler.create(ActionListener.class, this, "onExecute"),
            KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, InputEvent.CTRL_DOWN_MASK)).setLogicalGroup("custom");
    actions.addAction(executeAction);
    //Execute Selected SQL
    executeSelectedAction = new DefaultAction(SQLAction.A_EXECUTE_SELECTION, I18N.tr("Execute selected"),
            I18N.tr("Run selected SQL statements"), SQLConsoleIcon.getIcon("execute_selection"),
            EventHandler.create(ActionListener.class, this, "onExecuteSelected"),
            KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, InputEvent.ALT_DOWN_MASK)).setLogicalGroup("custom")
                    .setAfter(SQLAction.A_EXECUTE);
    actions.addAction(executeSelectedAction);
    //Clear action
    clearAction = new DefaultAction(SQLAction.A_CLEAR, I18N.tr("Clear"),
            I18N.tr("Erase the content of the editor"), SQLConsoleIcon.getIcon("erase"),
            EventHandler.create(ActionListener.class, this, "onClear"), null).setLogicalGroup("custom")
                    .setAfter(SQLAction.A_EXECUTE_SELECTION);
    actions.addAction(clearAction);
    //Find action
    findAction = new DefaultAction(SQLAction.A_SEARCH, I18N.tr("Search.."),
            I18N.tr("Search text in the document"), SQLConsoleIcon.getIcon("find"),
            EventHandler.create(ActionListener.class, this, "openFindReplaceDialog"),
            KeyStroke.getKeyStroke(KeyEvent.VK_F, InputEvent.CTRL_DOWN_MASK))
                    .addStroke(KeyStroke.getKeyStroke(KeyEvent.VK_H, InputEvent.CTRL_DOWN_MASK))
                    .setLogicalGroup("custom");
    actions.addAction(findAction);

    //Quote
    quoteAction = new DefaultAction(SQLAction.A_QUOTE, I18N.tr("Quote"), I18N.tr("Quote selected text"), null,
            EventHandler.create(ActionListener.class, this, "onQuote"),
            KeyStroke.getKeyStroke(KeyEvent.VK_SLASH, InputEvent.SHIFT_DOWN_MASK)).setLogicalGroup("format");
    actions.addAction(quoteAction);
    //unQuote
    unQuoteAction = new DefaultAction(SQLAction.A_UNQUOTE, I18N.tr("Un Quote"),
            I18N.tr("Un Quote selected text"), null,
            EventHandler.create(ActionListener.class, this, "onUnQuote"),
            KeyStroke.getKeyStroke(KeyEvent.VK_BACK_SLASH, InputEvent.SHIFT_DOWN_MASK))
                    .setLogicalGroup("format");
    actions.addAction(unQuoteAction);

    // Comment/Uncomment
    commentAction = new DefaultAction(SQLAction.A_COMMENT, I18N.tr("(Un)comment"),
            I18N.tr("(Un)comment the selected text"), null,
            EventHandler.create(ActionListener.class, this, "onComment"), KeyStroke.getKeyStroke("alt C"))
                    .setLogicalGroup("format");
    actions.addAction(commentAction);

    // Block Comment/Uncomment
    blockCommentAction = new DefaultAction(SQLAction.A_BLOCKCOMMENT, I18N.tr("Block (un)comment"),
            I18N.tr("Block (un)comment the selected text."), null,
            EventHandler.create(ActionListener.class, this, "onBlockComment"),
            KeyStroke.getKeyStroke("alt shift C")).setLogicalGroup("format");
    actions.addAction(blockCommentAction);

    //Format SQL
    formatSQLAction = new DefaultAction(SQLAction.A_FORMAT, I18N.tr("Format"), I18N.tr("Format editor content"),
            null, EventHandler.create(ActionListener.class, this, "onFormatCode"),
            KeyStroke.getKeyStroke("alt shift F")).setLogicalGroup("format");
    actions.addAction(formatSQLAction);

    //Save
    saveAction = new DefaultAction(SQLAction.A_SAVE, I18N.tr("Save"),
            I18N.tr("Save the editor content into a file"), SQLConsoleIcon.getIcon("save"),
            EventHandler.create(ActionListener.class, this, "onSaveFile"),
            KeyStroke.getKeyStroke(KeyEvent.VK_S, InputEvent.CTRL_DOWN_MASK)).setLogicalGroup("custom");
    actions.addAction(saveAction);
    // Save As
    saveAsAction = new DefaultAction(SQLAction.A_SAVE, I18N.tr("Save As"),
            I18N.tr("Save the editor content into a new file"), SQLConsoleIcon.getIcon("page_white_save"),
            EventHandler.create(ActionListener.class, this, "onSaveAsNewFile"),
            KeyStroke.getKeyStroke("ctrl maj s")).setLogicalGroup("custom");
    actions.addAction(saveAsAction);

    //Open action
    actions.addAction(new DefaultAction(SQLAction.A_OPEN, I18N.tr("Open"),
            I18N.tr("Load a file in this editor"), SQLConsoleIcon.getIcon("open"),
            EventHandler.create(ActionListener.class, this, "onOpenFile"),
            KeyStroke.getKeyStroke(KeyEvent.VK_O, InputEvent.CTRL_DOWN_MASK)).setLogicalGroup("custom"));
    //ShowHide function list
    actions.addAction(new DefaultAction(SQLAction.A_SQL_LIST, I18N.tr("SQL list"),
            I18N.tr("Show/Hide SQL function list"), SQLConsoleIcon.getIcon("builtinfunctionmap"),
            EventHandler.create(ActionListener.class, this, "onShowHideFunctionPanel"), null)
                    .setLogicalGroup("custom"));
    //Time out action
    actions.addAction(new DefaultAction(SQLAction.A_SQL_TIMEOUT, I18N.tr("Timeout"),
            I18N.tr("Custom a time out to execute the SQL statement"), SQLConsoleIcon.getIcon("timeout_sql"),
            EventHandler.create(ActionListener.class, this, "onSQLTimeOut"),
            KeyStroke.getKeyStroke(KeyEvent.VK_T, InputEvent.CTRL_DOWN_MASK)).setLogicalGroup("custom"));
}

From source file:edu.ku.brc.ui.tmanfe.SearchReplacePanel.java

/**
 * sets up the keystroke mappings for "Ctrl-F" firing the find/replace panel
 * Escape making it disappear, and enter key firing a search
 *///ww  w .  j av a  2s.c  o m
private void setupKeyStrokeMappings() {
    //table.getActionMap().clear();

    //override the "Ctrl-F" function for launching the find dialog shipped with JXTable
    table.getInputMap().put(
            KeyStroke.getKeyStroke(KeyEvent.VK_F, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()),
            UIRegistry.getResourceString(FIND));
    table.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_F, InputEvent.CTRL_MASK),
            UIRegistry.getResourceString(FIND));

    //create action that will display the find/replace dialog
    launchFindAction = new LaunchFindAction();
    table.getActionMap().put(FIND, launchFindAction);

    //Allow ESC buttun to call DisablePanelAction   
    String CANCEL_KEY = "CANCELKEY"; // i18n
    //Allow ENTER button to SearchAction
    String ENTER_KEY = "ENTERKEY"; // i18n
    String REPLACE_KEY = "REPLACEKEY"; // i18n

    KeyStroke enterKey = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0, false);
    KeyStroke escapeKey = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0, false);

    InputMap textFieldInputMap = findField.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
    textFieldInputMap.put(enterKey, ENTER_KEY);
    textFieldInputMap.put(escapeKey, CANCEL_KEY);

    ActionMap textFieldActionMap = findField.getActionMap();
    textFieldActionMap.put(ENTER_KEY, searchAction);
    textFieldActionMap.put(CANCEL_KEY, hideFindPanelAction);

    if (!table.isReadOnly()) {
        InputMap replaceFieldInputMap = replaceField.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
        replaceFieldInputMap.put(enterKey, REPLACE_KEY);
        replaceFieldInputMap.put(escapeKey, CANCEL_KEY);

        ActionMap replaceFieldActionMap = replaceField.getActionMap();
        replaceFieldActionMap.put(REPLACE_KEY, replaceAction);
        replaceFieldActionMap.put(CANCEL_KEY, hideFindPanelAction);
    }
}

From source file:vistas.Login.java

private void txt_PassKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txt_PassKeyTyped
    char c = evt.getKeyChar();
    if (c == KeyEvent.VK_ENTER) {
        btn_acceder.doClick();/*from   ww  w . j a v a 2  s .  c o m*/
    }
}

From source file:adams.gui.tools.TelnetPanel.java

/**
 * For initializing the GUI./*from  www. j a va 2  s.  co m*/
 */
@Override
protected void initGUI() {
    JPanel topPanel;
    JPanel bottomPanel;
    JLabel label;

    super.initGUI();

    setLayout(new BorderLayout());

    // connection
    topPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
    add(topPanel, BorderLayout.NORTH);

    m_TextRemote = new BaseTextField(20);
    label = new JLabel("Remote");
    label.setDisplayedMnemonic('R');
    label.setLabelFor(m_TextRemote);
    topPanel.add(label);
    topPanel.add(m_TextRemote);

    m_PortModel = new SpinnerNumberModel();
    m_PortModel.setMinimum(1);
    m_PortModel.setMaximum(65536);
    m_PortModel.setStepSize(1);
    m_PortModel.setValue(23);
    m_SpinnerPort = new JSpinner(m_PortModel);
    label = new JLabel("Port");
    label.setDisplayedMnemonic('P');
    label.setLabelFor(m_SpinnerPort);
    topPanel.add(label);
    topPanel.add(m_SpinnerPort);

    m_ButtonConnection = new BaseButton();
    m_ButtonConnection.setMnemonic('n');
    m_ButtonConnection.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            handleConnectionEvent();
        }
    });
    topPanel.add(m_ButtonConnection);

    // output
    m_ButtonClear = new BaseButton("Clear", GUIHelper.getIcon("new.gif"));
    m_ButtonClear.setMnemonic('l');
    m_ButtonClear.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            m_TextOutput.setText("");
        }
    });
    m_ButtonCopy = new BaseButton("Copy", GUIHelper.getIcon("copy.gif"));
    m_ButtonCopy.setMnemonic('C');
    m_ButtonCopy.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            if (m_TextOutput.getSelectedText().length() > 0)
                ClipboardHelper.copyToClipboard(m_TextOutput.getSelectedText());
            else if (m_TextOutput.getText().length() > 0)
                ClipboardHelper.copyToClipboard(m_TextOutput.getText());
        }
    });
    m_TextOutput = new BaseTextAreaWithButtons(10, 40);
    m_TextOutput.setTextFont(Fonts.getMonospacedFont());
    m_TextOutput.addToButtonsPanel(m_ButtonClear);
    m_TextOutput.addToButtonsPanel(m_ButtonCopy);
    add(m_TextOutput, BorderLayout.CENTER);

    // commands
    bottomPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
    add(bottomPanel, BorderLayout.SOUTH);

    m_TextCommand = new BaseTextField(40);
    m_TextCommand.setFont(Fonts.getMonospacedFont());
    m_TextCommand.addKeyListener(new KeyListener() {
        @Override
        public void keyTyped(KeyEvent e) {
        }

        @Override
        public void keyReleased(KeyEvent e) {
        }

        @Override
        public void keyPressed(KeyEvent e) {
            switch (e.getKeyCode()) {
            case KeyEvent.VK_ENTER:
                e.consume();
                execCommand();
                break;
            case KeyEvent.VK_UP:
                e.consume();
                previousCommand();
                break;
            case KeyEvent.VK_DOWN:
                e.consume();
                nextCommand();
                break;
            }
        }
    });
    label = new JLabel("Command");
    label.setDisplayedMnemonic('m');
    label.setLabelFor(m_TextCommand);
    bottomPanel.add(label);
    bottomPanel.add(m_TextCommand);

    m_ButtonCommand = new BaseButton(GUIHelper.getIcon("run.gif"));
    m_ButtonCommand.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            execCommand();
        }
    });
    bottomPanel.add(m_ButtonCommand);
}

From source file:org.orbisgis.r.RConsolePanel.java

/**
 * Create actions instances/*from w w w  .j a v a 2  s .co  m*/
 *
 * Each action is put in the Popup menu and the tool bar Their shortcuts are
 * registered also in the editor
 */
private void initActions() {
    //Execute action
    executeAction = new DefaultAction(RConsoleActions.A_EXECUTE, I18N.tr("Execute"),
            I18N.tr("Execute the R script"), RIcon.getIcon("execute"),
            EventHandler.create(ActionListener.class, this, "onExecute"),
            KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, InputEvent.CTRL_DOWN_MASK));
    actions.addAction(executeAction);

    //Execute Selected SQL
    executeSelectedAction = new DefaultAction(RConsoleActions.A_EXECUTE_SELECTION, I18N.tr("Execute selected"),
            I18N.tr("Run selected code"), RIcon.getIcon("execute_selection"),
            EventHandler.create(ActionListener.class, this, "onExecuteSelected"),
            KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, InputEvent.ALT_DOWN_MASK)).setLogicalGroup("custom")
                    .setAfter(RConsoleActions.A_EXECUTE);
    actions.addAction(executeSelectedAction);

    //Clear action
    clearAction = new DefaultAction(RConsoleActions.A_CLEAR, I18N.tr("Clear"),
            I18N.tr("Erase the content of the editor"), RIcon.getIcon("erase"),
            EventHandler.create(ActionListener.class, this, "onClear"), null);
    actions.addAction(clearAction);

    //Open action
    actions.addAction(
            new DefaultAction(RConsoleActions.A_OPEN, I18N.tr("Open"), I18N.tr("Load a file in this editor"),
                    RIcon.getIcon("open"), EventHandler.create(ActionListener.class, this, "onOpenFile"),
                    KeyStroke.getKeyStroke(KeyEvent.VK_O, InputEvent.CTRL_DOWN_MASK)));
    //Save
    saveAction = new DefaultAction(RConsoleActions.A_SAVE, I18N.tr("Save"),
            I18N.tr("Save the editor content into a file"), RIcon.getIcon("save"),
            EventHandler.create(ActionListener.class, this, "onSaveFile"),
            KeyStroke.getKeyStroke(KeyEvent.VK_S, InputEvent.CTRL_DOWN_MASK));
    actions.addAction(saveAction);
    // Save As
    saveAsAction = new DefaultAction(RConsoleActions.A_SAVE, I18N.tr("Save As"),
            I18N.tr("Save the editor content into a new file"), RIcon.getIcon("page_white_save"),
            EventHandler.create(ActionListener.class, this, "onSaveAsNewFile"),
            KeyStroke.getKeyStroke("ctrl maj s"));
    actions.addAction(saveAsAction);
    //Find action
    findAction = new DefaultAction(RConsoleActions.A_SEARCH, I18N.tr("Search.."),
            I18N.tr("Search text in the document"), RIcon.getIcon("find"),
            EventHandler.create(ActionListener.class, this, "openFindReplaceDialog"),
            KeyStroke.getKeyStroke(KeyEvent.VK_F, InputEvent.CTRL_DOWN_MASK))
                    .addStroke(KeyStroke.getKeyStroke(KeyEvent.VK_H, InputEvent.CTRL_DOWN_MASK));
    actions.addAction(findAction);

    // Comment/Uncomment
    commentAction = new DefaultAction(RConsoleActions.A_COMMENT, I18N.tr("(Un)comment"),
            I18N.tr("(Un)comment the selected text"), null,
            EventHandler.create(ActionListener.class, this, "onComment"), KeyStroke.getKeyStroke("alt C"))
                    .setLogicalGroup("format");
    actions.addAction(commentAction);

}

From source file:com.hp.alm.ali.idea.ui.editor.field.HTMLAreaField.java

public static void installNavigationShortCuts(final JTextPane desc) {
    Keymap keymap = KeymapManager.getInstance().getActiveKeymap();
    new AnAction() {
        public void actionPerformed(AnActionEvent e) {
            // default action moves to the end of the document - override
            desc.getActionMap().get(DefaultEditorKit.endLineAction).actionPerformed(null);
        }/*from ww  w.  j a  v  a 2 s.  c o  m*/
    }.registerCustomShortcutSet(
            new CustomShortcutSet(keymap.getShortcuts(IdeActions.ACTION_EDITOR_MOVE_LINE_END)), desc);
    new AnAction() {
        public void actionPerformed(AnActionEvent e) {
            // default action moves to the beginning of the document - override
            desc.getActionMap().get(DefaultEditorKit.beginLineAction).actionPerformed(null);
        }
    }.registerCustomShortcutSet(
            new CustomShortcutSet(keymap.getShortcuts(IdeActions.ACTION_EDITOR_MOVE_LINE_START)), desc);
    new AnAction() {
        public void actionPerformed(AnActionEvent e) {
            // default action moves to the end of the document - override
            desc.getActionMap().get(DefaultEditorKit.selectionEndLineAction).actionPerformed(null);
        }
    }.registerCustomShortcutSet(
            new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_END, InputEvent.SHIFT_MASK)), desc);
    new AnAction() {
        public void actionPerformed(AnActionEvent e) {
            // default action moves to the beginning of the document - override
            desc.getActionMap().get(DefaultEditorKit.selectionBeginLineAction).actionPerformed(null);
        }
    }.registerCustomShortcutSet(
            new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_HOME, InputEvent.SHIFT_MASK)), desc);
    new AnAction() {
        public void actionPerformed(AnActionEvent e) {
            // when editing html insert hard break
            new InsertHardBreakAction().actionPerformed(null);
        }
    }.registerCustomShortcutSet(new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0)), desc);
}

From source file:org.omegat.gui.issues.IssuesPanelController.java

@SuppressWarnings("serial")
synchronized void init() {
    if (frame != null) {
        // Regenerate menu bar to reflect current prefs
        frame.setJMenuBar(generateMenuBar());
        return;/*  w  ww .j  av a 2 s.c o m*/
    }

    frame = new JFrame(OStrings.getString("ISSUES_WINDOW_TITLE"));
    StaticUIUtils.setEscapeClosable(frame);
    StaticUIUtils.setWindowIcon(frame);
    if (Platform.isMacOSX()) {
        OSXIntegration.enableFullScreen(frame);
    }
    panel = new IssuesPanel();
    frame.add(panel);

    frame.setJMenuBar(generateMenuBar());

    frame.setPreferredSize(new Dimension(600, 400));
    frame.pack();
    frame.setLocationRelativeTo(parent);
    panel.innerSplitPane.setDividerLocation(INNER_SPLIT_INITIAL_RATIO);
    panel.outerSplitPane.setDividerLocation(OUTER_SPLIT_INITIAL_RATIO);

    StaticUIUtils.persistGeometry(frame, Preferences.ISSUES_WINDOW_GEOMETRY_PREFIX, () -> {
        Preferences.setPreference(Preferences.ISSUES_WINDOW_DIVIDER_LOCATION_BOTTOM,
                panel.outerSplitPane.getDividerLocation());
    });

    try {
        int bottomDL = Integer
                .parseInt(Preferences.getPreference(Preferences.ISSUES_WINDOW_DIVIDER_LOCATION_BOTTOM));
        panel.outerSplitPane.setDividerLocation(bottomDL);
    } catch (NumberFormatException e) {
        // Ignore
    }

    frame.addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosing(WindowEvent e) {
            reset();
        }
    });

    if (Preferences.isPreference(Preferences.PROJECT_FILES_USE_FONT)) {
        String fontName = Preferences.getPreference(Preferences.TF_SRC_FONT_NAME);
        int fontSize = Integer.parseInt(Preferences.getPreference(Preferences.TF_SRC_FONT_SIZE));
        setFont(new Font(fontName, Font.PLAIN, fontSize));
    }

    panel.table.getSelectionModel().addListSelectionListener(e -> {
        if (!e.getValueIsAdjusting()) {
            viewSelectedIssueDetail();
            selectedEntry = getSelectedIssue().map(IIssue::getSegmentNumber).orElse(-1);
        }
    });

    panel.table.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0),
            ACTION_KEY_JUMP_TO_SELECTED_ISSUE);
    panel.table.getActionMap().put(ACTION_KEY_JUMP_TO_SELECTED_ISSUE, new AbstractAction() {
        @Override
        public void actionPerformed(ActionEvent e) {
            jumpToSelectedIssue();
        }
    });

    // Swap focus between the Types list and Issues table; don't allow
    // tabbing within the table because it's pointless. Maybe this would be
    // better accomplished by adjusting the focus traversal policy?
    panel.table.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_TAB, KeyEvent.SHIFT_DOWN_MASK),
            ACTION_KEY_FOCUS_ON_TYPES_LIST);
    panel.table.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_TAB, 0), ACTION_KEY_FOCUS_ON_TYPES_LIST);
    panel.table.getActionMap().put(ACTION_KEY_FOCUS_ON_TYPES_LIST, new AbstractAction() {
        @Override
        public void actionPerformed(ActionEvent e) {
            if (panel.typeList.isVisible()) {
                panel.typeList.requestFocusInWindow();
            }
        }
    });

    panel.closeButton.addActionListener(e -> StaticUIUtils.closeWindowByEvent(frame));

    MouseAdapter adapter = new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent e) {
            if (e.getClickCount() == 2 && e.getButton() == MouseEvent.BUTTON1) {
                jumpToSelectedIssue();
            } else if (e.getButton() == MouseEvent.BUTTON1 && mouseoverCol == IssueColumn.ACTION_BUTTON.index) {
                doPopup(e);
            }
        }

        @Override
        public void mousePressed(MouseEvent e) {
            if (e.isPopupTrigger()) {
                doPopup(e);
            }
        }

        @Override
        public void mouseReleased(MouseEvent e) {
            if (e.isPopupTrigger()) {
                doPopup(e);
            }
        }

        @Override
        public void mouseExited(MouseEvent e) {
            updateRollover();
        }

        @Override
        public void mouseMoved(MouseEvent e) {
            updateRollover();
        }

        private void doPopup(MouseEvent e) {
            getIssueAt(e.getPoint()).ifPresent(issue -> showPopupMenu(e.getComponent(), e.getPoint(), issue));
        }
    };
    panel.table.addMouseListener(adapter);
    panel.table.addMouseMotionListener(adapter);

    panel.typeList.addListSelectionListener(e -> {
        if (!e.getValueIsAdjusting()) {
            updateFilter();
            selectedType = getSelectedType().orElse(null);
        }
    });

    panel.jumpButton.addActionListener(e -> jumpToSelectedIssue());

    panel.reloadButton.addActionListener(e -> refreshData(selectedEntry, selectedType));

    panel.showAllButton.addActionListener(e -> showAll());

    colSizer = TableColumnSizer.autoSize(panel.table, IssueColumn.DESCRIPTION.index, true);

    CoreEvents.registerProjectChangeListener(e -> {
        switch (e) {
        case CLOSE:
            SwingUtilities.invokeLater(() -> {
                filePattern = ALL_FILES_PATTERN;
                instructions = NO_INSTRUCTIONS;
                reset();
                frame.setVisible(false);
            });
            break;
        case MODIFIED:
            if (frame.isVisible()) {
                SwingUtilities.invokeLater(() -> refreshData(selectedEntry, selectedType));
            }
            break;
        default:
        }
    });

    CoreEvents.registerFontChangedEventListener(f -> {
        if (!Preferences.isPreference(Preferences.PROJECT_FILES_USE_FONT)) {
            f = new JTable().getFont();
        }
        setFont(f);
        viewSelectedIssueDetail();
    });
}