List of usage examples for com.intellij.openapi.ui JBCheckboxMenuItem JBCheckboxMenuItem
public JBCheckboxMenuItem(String text, boolean b)
From source file:com.intellij.codeInsight.daemon.impl.DaemonEditorPopup.java
License:Apache License
@Override public void invokePopup(final Component comp, final int x, final int y) { if (ApplicationManager.getApplication() == null) return;// w w w . jav a2 s . co m 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().SHOW_EDITOR_TOOLTIP); popupMenu.addSeparator(); popupMenu.add(previewCheckbox); previewCheckbox.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { UISettings.getInstance().SHOW_EDITOR_TOOLTIP = previewCheckbox.isSelected(); UISettings.getInstance().fireUISettingsChanged(); } }); PsiFile file = myPsiFile; if (file != null && DaemonCodeAnalyzer.getInstance(myPsiFile.getProject()).isHighlightingAvailable(file)) { popupMenu.show(comp, x, y); } }