Example usage for com.intellij.openapi.keymap Keymap getPresentableName

List of usage examples for com.intellij.openapi.keymap Keymap getPresentableName

Introduction

In this page you can find the example usage for com.intellij.openapi.keymap Keymap getPresentableName.

Prototype

String getPresentableName();

Source Link

Usage

From source file:com.intellij.application.options.InitialConfigurationDialog.java

License:Apache License

public InitialConfigurationDialog(Component parent, String colorSettingsPage) {
    super(parent, true);
    myColorSettingsPage = colorSettingsPage;
    setTitle(ApplicationNamesInfo.getInstance().getFullProductName() + " Initial Configuration");

    final ArrayList<Keymap> keymaps = new ArrayList<Keymap>();
    for (Keymap keymap : ((KeymapManagerImpl) KeymapManager.getInstance()).getAllKeymaps()) {
        if (matchesPlatform(keymap)) {
            keymaps.add(keymap);/*  w  ww . ja  va2s .co  m*/
        }
    }

    myAppearanceComboBox
            .setModel(new DefaultComboBoxModel(LafManager.getInstance().getInstalledLookAndFeels()));
    myAppearanceComboBox.setRenderer(new LafComboBoxRenderer());
    myAppearanceComboBox.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent event) {
            preselectColorScheme();
        }
    });
    myAppearanceComboBox.setSelectedItem(LafManager.getInstance().getCurrentLookAndFeel());
    myColorSchemeComboBox.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent event) {
            EditorColorsScheme scheme = (EditorColorsScheme) myColorSchemeComboBox.getSelectedItem();
            if (scheme.getName().equals("Darcula")) {
                UIManager.LookAndFeelInfo[] lafs = LafManager.getInstance().getInstalledLookAndFeels();
                for (UIManager.LookAndFeelInfo laf : lafs) {
                    if (laf.getName().contains("Darcula")) {
                        myAppearanceComboBox.setSelectedItem(laf);
                        break;
                    }
                }
            }
        }
    });

    myKeymapComboBox.setModel(new DefaultComboBoxModel(keymaps.toArray(new Keymap[keymaps.size()])));
    myKeymapComboBox.setRenderer(new ListCellRendererWrapper() {
        @Override
        public void customize(final JList list, final Object value, final int index, final boolean selected,
                final boolean cellHasFocus) {
            Keymap keymap = (Keymap) value;
            if (keymap == null) {
                return;
            }
            if (KeymapManager.DEFAULT_IDEA_KEYMAP.equals(keymap.getName())) {
                setText("IntelliJ IDEA Classic");
            } else if ("Mac OS X".equals(keymap.getName())) {
                setText("IntelliJ IDEA Classic - Mac OS X");
            } else {
                setText(keymap.getPresentableName());
            }
        }
    });
    preselectKeyMap(keymaps);

    final EditorColorsScheme[] colorSchemes = EditorColorsManager.getInstance().getAllSchemes();
    myColorSchemeComboBox.setModel(new DefaultComboBoxModel(colorSchemes));
    myColorSchemeComboBox.setRenderer(new ListCellRendererWrapper() {
        @Override
        public void customize(JList list, Object value, int index, boolean selected, boolean cellHasFocus) {
            if (value != null) {
                setText(((EditorColorsScheme) value).getName());
            }
        }
    });
    myColorSchemeComboBox.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent actionEvent) {
            if (myHidingPreviewPanel != null)
                myHidingPreviewPanel.updateColorSchemePreview(true);
        }
    });
    preselectColorScheme();
    setResizable(false);
    setCancelButtonText("Skip");
    init();

    final boolean canCreateLauncherScript = canCreateLauncherScript();
    myCreateScriptCheckbox.setVisible(canCreateLauncherScript);
    myCreateScriptCheckbox.setSelected(canCreateLauncherScript);
    myCreateScriptPanel.setVisible(canCreateLauncherScript);
    if (canCreateLauncherScript) {
        myScriptPathTextField.setText("/usr/local/bin/" + CreateLauncherScriptAction.defaultScriptName());
    }

    final boolean canCreateDesktopEntry = canCreateDesktopEntry();
    myCreateEntryCheckBox.setVisible(canCreateDesktopEntry);
    myCreateEntryCheckBox.setSelected(canCreateDesktopEntry);
    myCreateEntryPanel.setVisible(canCreateDesktopEntry);
    if (canCreateDesktopEntry) {
        myGlobalEntryCheckBox.setSelected(!PathManager.getHomePath().startsWith("/home"));
    }

    myPreferencesLabel.setText(
            "You can use " + CommonBundle.settingsActionPath() + " to configure any of these settings later.");

    Disposer.register(myDisposable, new Disposable() {
        @Override
        public void dispose() {
            disposeUIResources();
        }
    });
}

From source file:com.intellij.ide.actions.QuickChangeKeymapAction.java

License:Apache License

private static void addKeymapAction(final DefaultActionGroup group, final KeymapManagerEx manager,
        final Keymap current, final Keymap keymap, final boolean addScheme) {
    group.add(new AnAction(keymap.getPresentableName(), "",
            keymap == current ? ourCurrentAction : ourNotCurrentAction) {
        @Override//from  w ww.j av  a2 s  .c  om
        public void actionPerformed(AnActionEvent e) {
            if (addScheme) {
                manager.getSchemesManager().addNewScheme(keymap, false);
            }
            manager.setActiveKeymap(keymap);
        }
    });
}

From source file:com.maddyhome.idea.vim.VimPlugin.java

License:Open Source License

private void updateState() {
    if (isEnabled() && !ApplicationManager.getApplication().isUnitTestMode()) {
        if (SystemInfo.isMac) {
            final MacKeyRepeat keyRepeat = MacKeyRepeat.getInstance();
            final Boolean enabled = keyRepeat.isEnabled();
            final Boolean isKeyRepeat = editor.isKeyRepeat();
            if ((enabled == null || !enabled) && (isKeyRepeat == null || isKeyRepeat)) {
                if (Messages.showYesNoDialog(
                        "Do you want to enable repeating keys in Mac OS X on press and hold?\n\n"
                                + "(You can do it manually by running 'defaults write -g "
                                + "ApplePressAndHoldEnabled 0' in the console).",
                        IDEAVIM_NOTIFICATION_TITLE, Messages.getQuestionIcon()) == Messages.YES) {
                    editor.setKeyRepeat(true);
                    keyRepeat.setEnabled(true);
                } else {
                    editor.setKeyRepeat(false);
                }//from ww  w .  ja v a2 s  . com
            }
        }
        if (previousStateVersion > 0 && previousStateVersion < 3) {
            final KeymapManagerEx manager = KeymapManagerEx.getInstanceEx();
            Keymap keymap = null;
            if (previousKeyMap != null) {
                keymap = manager.getKeymap(previousKeyMap);
            }
            if (keymap == null) {
                keymap = manager.getKeymap(DefaultKeymap.getInstance().getDefaultKeymapName());
            }
            assert keymap != null : "Default keymap not found";
            new Notification(VimPlugin.IDEAVIM_STICKY_NOTIFICATION_ID, VimPlugin.IDEAVIM_NOTIFICATION_TITLE,
                    String.format("IdeaVim plugin doesn't use the special \"Vim\" keymap any longer. "
                            + "Switching to \"%s\" keymap.<br/><br/>" + "Now it is possible to set up:<br/>"
                            + "<ul>" + "<li>Vim keys in your ~/.ideavimrc file using key mapping commands</li>"
                            + "<li>IDE action shortcuts in \"File | Settings | Keymap\"</li>"
                            + "<li>Vim or IDE handlers for conflicting shortcuts in <a href='#settings'>Vim Emulation</a> settings</li>"
                            + "</ul>", keymap.getPresentableName()),
                    NotificationType.INFORMATION, new NotificationListener.Adapter() {
                        @Override
                        protected void hyperlinkActivated(@NotNull Notification notification,
                                @NotNull HyperlinkEvent e) {
                            ShowSettingsUtil.getInstance().editConfigurable((Project) null,
                                    new VimEmulationConfigurable());
                        }
                    }).notify(null);
            manager.setActiveKeymap(keymap);
        }
        if (previousStateVersion > 0 && previousStateVersion < 4) {
            new Notification(VimPlugin.IDEAVIM_STICKY_NOTIFICATION_ID, VimPlugin.IDEAVIM_NOTIFICATION_TITLE,
                    "The ~/.vimrc file is no longer read by default, use ~/.ideavimrc instead. You can read it from your "
                            + "~/.ideavimrc using this command:<br/><br/>" + "<code>source ~/.vimrc</code>",
                    NotificationType.INFORMATION).notify(null);
        }
    }
}