Search in sources :

Example 6 with JBMenuItem

use of com.intellij.openapi.ui.JBMenuItem in project intellij-community by JetBrains.

the class TabbedLanguageCodeStylePanel method fillLanguages.

private void fillLanguages(JComponent parentMenu) {
    Language[] languages = LanguageCodeStyleSettingsProvider.getLanguagesWithCodeStyleSettings();
    @SuppressWarnings("UnnecessaryFullyQualifiedName") java.util.List<JMenuItem> langItems = new ArrayList<>();
    for (final Language lang : languages) {
        if (!lang.equals(getDefaultLanguage())) {
            final String langName = LanguageCodeStyleSettingsProvider.getLanguageName(lang);
            JMenuItem langItem = new JBMenuItem(langName);
            langItem.addActionListener(new ActionListener() {

                @Override
                public void actionPerformed(ActionEvent e) {
                    applyLanguageSettings(lang);
                }
            });
            langItems.add(langItem);
        }
    }
    Collections.sort(langItems, (item1, item2) -> item1.getText().compareToIgnoreCase(item2.getText()));
    for (JMenuItem langItem : langItems) {
        parentMenu.add(langItem);
    }
}
Also used : Language(com.intellij.lang.Language) java.util(java.util) ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent) JBMenuItem(com.intellij.openapi.ui.JBMenuItem)

Aggregations

JBMenuItem (com.intellij.openapi.ui.JBMenuItem)6 JBPopupMenu (com.intellij.openapi.ui.JBPopupMenu)3 ActionEvent (java.awt.event.ActionEvent)3 ActionListener (java.awt.event.ActionListener)3 NotNull (org.jetbrains.annotations.NotNull)3 XmlNode (com.android.manifmerger.XmlNode)1 Language (com.intellij.lang.Language)1 WriteCommandAction (com.intellij.openapi.command.WriteCommandAction)1 JBCheckboxMenuItem (com.intellij.openapi.ui.JBCheckboxMenuItem)1 PsiFile (com.intellij.psi.PsiFile)1 RelativePoint (com.intellij.ui.awt.RelativePoint)1 JBEmptyBorder (com.intellij.util.ui.JBEmptyBorder)1 MouseAdapter (java.awt.event.MouseAdapter)1 MouseEvent (java.awt.event.MouseEvent)1 MouseListener (java.awt.event.MouseListener)1 java.util (java.util)1 Border (javax.swing.border.Border)1