Search in sources :

Example 1 with JBCheckboxMenuItem

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

the class DaemonEditorPopup method invokePopup.

@Override
public void invokePopup(final Component comp, final int x, final int y) {
    if (ApplicationManager.getApplication() == null)
        return;
    final JRadioButtonMenuItem errorsFirst = createRadioButtonMenuItem(EditorBundle.message("errors.panel.go.to.errors.first.radio"));
    errorsFirst.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            DaemonCodeAnalyzerSettings.getInstance().NEXT_ERROR_ACTION_GOES_TO_ERRORS_FIRST = errorsFirst.isSelected();
        }
    });
    final JPopupMenu popupMenu = new JBPopupMenu();
    popupMenu.add(errorsFirst);
    final JRadioButtonMenuItem next = createRadioButtonMenuItem(EditorBundle.message("errors.panel.go.to.next.error.warning.radio"));
    next.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            DaemonCodeAnalyzerSettings.getInstance().NEXT_ERROR_ACTION_GOES_TO_ERRORS_FIRST = !next.isSelected();
        }
    });
    popupMenu.add(next);
    ButtonGroup group = new ButtonGroup();
    group.add(errorsFirst);
    group.add(next);
    popupMenu.addSeparator();
    final JMenuItem hLevel = new JBMenuItem(EditorBundle.message("customize.highlighting.level.menu.item"));
    popupMenu.add(hLevel);
    final boolean isErrorsFirst = DaemonCodeAnalyzerSettings.getInstance().NEXT_ERROR_ACTION_GOES_TO_ERRORS_FIRST;
    errorsFirst.setSelected(isErrorsFirst);
    next.setSelected(!isErrorsFirst);
    hLevel.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            final PsiFile psiFile = myPsiFile;
            if (psiFile == null)
                return;
            final HectorComponent component = new HectorComponent(psiFile);
            final Dimension dimension = component.getPreferredSize();
            Point point = new Point(x, y);
            component.showComponent(new RelativePoint(comp, new Point(point.x - dimension.width, point.y)));
        }
    });
    final JBCheckboxMenuItem previewCheckbox = new JBCheckboxMenuItem(IdeBundle.message("checkbox.show.editor.preview.popup"), UISettings.getInstance().getShowEditorToolTip());
    popupMenu.addSeparator();
    popupMenu.add(previewCheckbox);
    previewCheckbox.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            UISettings.getInstance().setShowToolWindowsNumbers(previewCheckbox.isSelected());
            UISettings.getInstance().fireUISettingsChanged();
        }
    });
    PsiFile file = myPsiFile;
    if (file != null && DaemonCodeAnalyzer.getInstance(myPsiFile.getProject()).isHighlightingAvailable(file)) {
        popupMenu.show(comp, x, y);
    }
}
Also used : ActionEvent(java.awt.event.ActionEvent) JBCheckboxMenuItem(com.intellij.openapi.ui.JBCheckboxMenuItem) RelativePoint(com.intellij.ui.awt.RelativePoint) RelativePoint(com.intellij.ui.awt.RelativePoint) JBPopupMenu(com.intellij.openapi.ui.JBPopupMenu) ActionListener(java.awt.event.ActionListener) PsiFile(com.intellij.psi.PsiFile) JBMenuItem(com.intellij.openapi.ui.JBMenuItem)

Aggregations

JBCheckboxMenuItem (com.intellij.openapi.ui.JBCheckboxMenuItem)1 JBMenuItem (com.intellij.openapi.ui.JBMenuItem)1 JBPopupMenu (com.intellij.openapi.ui.JBPopupMenu)1 PsiFile (com.intellij.psi.PsiFile)1 RelativePoint (com.intellij.ui.awt.RelativePoint)1 ActionEvent (java.awt.event.ActionEvent)1 ActionListener (java.awt.event.ActionListener)1