Java Code Examples for com.intellij.ui.components.JBCheckBox#setSelected()

The following examples show how to use com.intellij.ui.components.JBCheckBox#setSelected() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ParameterNameHintsConfigurable.java    From consulo with Apache License 2.0 6 votes vote down vote up
private void createUIComponents() {
  List<Language> languages = getBaseLanguagesWithProviders();

  Language selected = myInitiallySelectedLanguage;
  if (selected == null) {
    selected = languages.get(0);
  }

  String text = getLanguageBlackList(selected);
  myEditorTextField = createEditor(text, myNewPreselectedItem);
  myEditorTextField.addDocumentListener(new DocumentAdapter() {
    @Override
    public void documentChanged(DocumentEvent e) {
      updateOkEnabled();
    }
  });

  myDoNotShowIfParameterNameContainedInMethodName = new JBCheckBox();
  myShowWhenMultipleParamsWithSameType = new JBCheckBox();

  ParameterNameHintsSettings settings = ParameterNameHintsSettings.getInstance();
  myDoNotShowIfParameterNameContainedInMethodName.setSelected(settings.isDoNotShowIfMethodNameContainsParameterName());
  myShowWhenMultipleParamsWithSameType.setSelected(settings.isShowForParamsWithSameType());

  initLanguageCombo(languages, selected);
}
 
Example 2
Source File: RecentLocationsAction.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Nonnull
public static JBCheckBox createCheckbox(@Nonnull ShortcutSet checkboxShortcutSet, boolean showChanged) {
  String text = "<html>" +
                IdeBundle.message("recent.locations.title.text") +
                " <font color=\"" +
                SHORTCUT_HEX_COLOR +
                "\">" +
                KeymapUtil.getShortcutsText(checkboxShortcutSet.getShortcuts()) +
                "</font>" +
                "</html>";
  JBCheckBox checkBox = new JBCheckBox(text);
  checkBox.setBorder(JBUI.Borders.empty());
  checkBox.setOpaque(false);
  checkBox.setSelected(showChanged);

  return checkBox;
}
 
Example 3
Source File: DirectoryWrapper.java    From PackageTemplates with Apache License 2.0 5 votes vote down vote up
@NotNull
private JPanel getOptionsPanel() {
    //  isEnabled
    cbEnabled = new JBCheckBox();
    cbEnabled.setSelected(directory.isEnabled());
    cbEnabled.addItemListener(e -> setEnabled(cbEnabled.isSelected()));
    cbEnabled.setToolTipText(Localizer.get("tooltip.IfCheckedElementWillBeCreated"));

    // Script
    jlScript = new IconLabel(
            Localizer.get("tooltip.ColoredWhenItemHasScript"),
            PluginIcons.SCRIPT,
            PluginIcons.SCRIPT_DISABLED
    );

    // CustomPath
    jlCustomPath = new IconLabel(
            Localizer.get("tooltip.ColoredWhenItemHasCustomPath"),
            PluginIcons.CUSTOM_PATH,
            PluginIcons.CUSTOM_PATH_DISABLED
    );

    // WriteRules
    jlWriteRules = new IconLabelCustom<Directory>(Localizer.get("tooltip.WriteRules"), directory) {
        @Override
        public void onUpdateIcon(Directory item) {
            setIcon(item.getWriteRules().toIcon());
        }
    };

    updateOptionIcons();

    JPanel optionsPanel = new JPanel(new MigLayout(new LC().insets("0").gridGap("2pt","0")));
    optionsPanel.add(cbEnabled, new CC());
    optionsPanel.add(jlScript, new CC());
    optionsPanel.add(jlCustomPath, new CC());
    optionsPanel.add(jlWriteRules, new CC());
    return optionsPanel;
}
 
Example 4
Source File: FileStructurePopup.java    From consulo with Apache License 2.0 5 votes vote down vote up
public void setTreeActionState(Class<? extends TreeAction> action, boolean state) {
  JBCheckBox checkBox = myCheckBoxes.get(action);
  if (checkBox != null) {
    checkBox.setSelected(state);
    for (ActionListener listener : checkBox.getActionListeners()) {
      listener.actionPerformed(new ActionEvent(this, 1, ""));
    }
  }
}
 
Example 5
Source File: CamelAnnotatorPageTest.java    From camel-idea-plugin with Apache License 2.0 5 votes vote down vote up
public void testShouldChangeStateOfRealTimeBeanMethodValidationCheckBox() {
    JBCheckBox checkBox = annotatorPage.getRealTimeBeanMethodValidationCheckBox();
    assertEquals(true, checkBox.isSelected());
    assertEquals(true, annotatorPage.getCamelPreferenceService().isRealTimeBeanMethodValidationCheckBox());
    checkBox.setSelected(false);
    annotatorPage.apply();
    assertEquals(false, checkBox.isSelected());
    assertEquals(false, annotatorPage.getCamelPreferenceService().isRealTimeBeanMethodValidationCheckBox());
}
 
Example 6
Source File: CamelAnnotatorPageTest.java    From camel-idea-plugin with Apache License 2.0 5 votes vote down vote up
public void testShouldChangeStateOfRealTimeJSonPathValidationCatalogCheckBox() {
    JBCheckBox checkBox = annotatorPage.getRealTimeJSonPathValidationCatalogCheckBox();
    assertEquals(true, checkBox.isSelected());
    assertEquals(true, annotatorPage.getCamelPreferenceService().isRealTimeJSonPathValidation());
    checkBox.setSelected(false);
    annotatorPage.apply();
    assertEquals(false, checkBox.isSelected());
    assertEquals(false, annotatorPage.getCamelPreferenceService().isRealTimeJSonPathValidation());
}
 
Example 7
Source File: CamelAnnotatorPageTest.java    From camel-idea-plugin with Apache License 2.0 5 votes vote down vote up
public void testShouldResetHighlightCustomOptionsCheckBox() {
    JBCheckBox checkBox = annotatorPage.getHighlightCustomOptionsCheckBox();
    boolean status = checkBox.isSelected();
    checkBox.setSelected(!status);
    annotatorPage.reset();
    assertEquals(status, checkBox.isSelected());
}
 
Example 8
Source File: CamelAnnotatorPageTest.java    From camel-idea-plugin with Apache License 2.0 5 votes vote down vote up
public void testShouldRestRealTimeSimpleValidationCatalogCheckBox() {
    JBCheckBox checkBox = annotatorPage.getRealTimeSimpleValidationCatalogCheckBox();
    boolean status = checkBox.isSelected();
    checkBox.setSelected(!status);
    annotatorPage.reset();
    assertEquals(status, checkBox.isSelected());
}
 
Example 9
Source File: CamelAnnotatorPageTest.java    From camel-idea-plugin with Apache License 2.0 5 votes vote down vote up
public void testShouldChangeStateOfHighlightCustomOptionsCheckBox() throws ConfigurationException {
    JBCheckBox checkBox = annotatorPage.getHighlightCustomOptionsCheckBox();
    assertEquals(true, checkBox.isSelected());
    assertEquals(true, annotatorPage.getCamelPreferenceService().isHighlightCustomOptions());
    checkBox.setSelected(false);
    annotatorPage.apply();
    assertEquals(false, checkBox.isSelected());
    assertEquals(false, annotatorPage.getCamelPreferenceService().isHighlightCustomOptions());
}
 
Example 10
Source File: CamelAnnotatorPageTest.java    From camel-idea-plugin with Apache License 2.0 5 votes vote down vote up
public void testShouldChangeStateOfRealTimeSimpleValidationCatalogCheckBox() throws ConfigurationException {
    JBCheckBox checkBox = annotatorPage.getRealTimeSimpleValidationCatalogCheckBox();
    assertEquals(true, checkBox.isSelected());
    assertEquals(true, annotatorPage.getCamelPreferenceService().isRealTimeSimpleValidation());
    checkBox.setSelected(false);
    annotatorPage.apply();
    assertEquals(false, checkBox.isSelected());
    assertEquals(false, annotatorPage.getCamelPreferenceService().isRealTimeSimpleValidation());
}
 
Example 11
Source File: CamelAnnotatorPageTest.java    From camel-idea-plugin with Apache License 2.0 5 votes vote down vote up
public void testShouldChangeStateOfRealTimeEndpointValidationCatalogCheckBox() throws ConfigurationException {
    JBCheckBox checkBox = annotatorPage.getRealTimeEndpointValidationCatalogCheckBox();
    assertEquals(true, checkBox.isSelected());
    assertEquals(true, annotatorPage.getCamelPreferenceService().isRealTimeEndpointValidation());
    checkBox.setSelected(false);
    annotatorPage.apply();
    assertEquals(false, checkBox.isSelected());
    assertEquals(false, annotatorPage.getCamelPreferenceService().isRealTimeEndpointValidation());
}
 
Example 12
Source File: FileWrapper.java    From PackageTemplates with Apache License 2.0 5 votes vote down vote up
@NotNull
private JPanel getOptionsPanel() {
    JPanel optionsPanel = new JPanel(new MigLayout(new LC().insets("0").gridGap("2pt","0")));

    cbEnabled = new JBCheckBox();
    cbEnabled.setSelected(file.isEnabled());
    cbEnabled.addItemListener(e -> setEnabled(cbEnabled.isSelected()));
    cbEnabled.setToolTipText(Localizer.get("tooltip.IfCheckedElementWillBeCreated"));

    // Script
    jlScript = new IconLabel(
            Localizer.get("tooltip.ColoredWhenItemHasScript"),
            PluginIcons.SCRIPT,
            PluginIcons.SCRIPT_DISABLED
    );

    // CustomPath
    jlCustomPath = new IconLabel(
            Localizer.get("tooltip.ColoredWhenItemHasCustomPath"),
            PluginIcons.CUSTOM_PATH,
            PluginIcons.CUSTOM_PATH_DISABLED
    );

    // WriteRules
    jlWriteRules = new IconLabelCustom<File>(Localizer.get("tooltip.WriteRules"), file) {
        @Override
        public void onUpdateIcon(File item) {
            setIcon(item.getWriteRules().toIcon());
        }
    };

    updateOptionIcons();

    optionsPanel.add(cbEnabled, new CC());
    optionsPanel.add(jlScript, new CC());
    optionsPanel.add(jlCustomPath, new CC());
    optionsPanel.add(jlWriteRules, new CC());
    return optionsPanel;
}
 
Example 13
Source File: BinaryFileWrapper.java    From PackageTemplates with Apache License 2.0 5 votes vote down vote up
@NotNull
private JPanel getOptionsPanel() {
    JPanel optionsPanel = new JPanel(new MigLayout(new LC().insets("0").gridGap("2pt", "0")));

    cbEnabled = new JBCheckBox();
    cbEnabled.setSelected(binaryFile.isEnabled());
    cbEnabled.addItemListener(e -> setEnabled(cbEnabled.isSelected()));
    cbEnabled.setToolTipText(Localizer.get("tooltip.IfCheckedElementWillBeCreated"));

    // Script
    jlScript = new IconLabel(
            Localizer.get("tooltip.ColoredWhenItemHasScript"),
            PluginIcons.SCRIPT,
            PluginIcons.SCRIPT_DISABLED
    );

    // CustomPath
    jlCustomPath = new IconLabel(
            Localizer.get("tooltip.ColoredWhenItemHasCustomPath"),
            PluginIcons.CUSTOM_PATH,
            PluginIcons.CUSTOM_PATH_DISABLED
    );

    // WriteRules
    jlWriteRules = new IconLabelCustom<BinaryFile>(Localizer.get("tooltip.WriteRules"), binaryFile) {
        @Override
        public void onUpdateIcon(BinaryFile item) {
            setIcon(item.getWriteRules().toIcon());
        }
    };

    updateOptionIcons();

    optionsPanel.add(cbEnabled, new CC());
    optionsPanel.add(jlScript, new CC());
    optionsPanel.add(jlCustomPath, new CC());
    optionsPanel.add(jlWriteRules, new CC());
    return optionsPanel;
}
 
Example 14
Source File: CamelAnnotatorPageTest.java    From camel-idea-plugin with Apache License 2.0 4 votes vote down vote up
public void testShouldResetRealTimeEndpointValidationCatalogCheckBox() {
    JBCheckBox checkBox = annotatorPage.getRealTimeEndpointValidationCatalogCheckBox();
    checkBox.setSelected(false);
    annotatorPage.reset();
    assertTrue(checkBox.isSelected());
}
 
Example 15
Source File: CamelEditorSettingsPageTest.java    From camel-idea-plugin with Apache License 2.0 4 votes vote down vote up
public void testShouldResetCamelIconInGutterCheckBox() {
    JBCheckBox checkBox = editorSettingsPage.getCamelIconInGutterCheckBox();
    checkBox.setSelected(false);
    editorSettingsPage.reset();
    assertTrue(checkBox.isSelected());
}
 
Example 16
Source File: CamelEditorSettingsPageTest.java    From camel-idea-plugin with Apache License 2.0 4 votes vote down vote up
public void testShouldResetScanThirdPartyLegacyComponentsCatalogCheckBox() {
    JBCheckBox checkBox = editorSettingsPage.getScanThirdPartyLegacyComponentsCatalogCheckBox();
    checkBox.setSelected(false);
    editorSettingsPage.reset();
    assertTrue(checkBox.isSelected());
}
 
Example 17
Source File: CamelEditorSettingsPageTest.java    From camel-idea-plugin with Apache License 2.0 4 votes vote down vote up
public void testShouldResetScanThirdPartyComponentsCatalogCheckBox() {
    JBCheckBox checkBox = editorSettingsPage.getScanThirdPartyComponentsCatalogCheckBox();
    checkBox.setSelected(false);
    editorSettingsPage.reset();
    assertTrue(checkBox.isSelected());
}
 
Example 18
Source File: CamelEditorSettingsPageTest.java    From camel-idea-plugin with Apache License 2.0 4 votes vote down vote up
public void testShouldDownloadCatalogCheckBox() {
    JBCheckBox checkBox = editorSettingsPage.getDownloadCatalogCheckBox();
    checkBox.setSelected(false);
    editorSettingsPage.reset();
    assertTrue(checkBox.isSelected());
}
 
Example 19
Source File: MoveChangesDialog.java    From consulo with Apache License 2.0 4 votes vote down vote up
public MoveChangesDialog(final Project project, Collection<Change> selected, final Set<ChangeList> changeLists, VirtualFile current) {
  super(project, true);
  mySelected = selected;
  setTitle("Move Changes to Active Changelist");
  myTreeList = new ChangesTreeList<Change>(project, selected, true, false, null, null) {

    @Override
    protected DefaultTreeModel buildTreeModel(List<Change> changes, ChangeNodeDecorator changeNodeDecorator) {
      return TreeModelBuilder.buildFromChangeLists(project, isShowFlatten(), changeLists);
    }

    @Override
    protected List<Change> getSelectedObjects(ChangesBrowserNode<Change> node) {
      return node.getAllChangesUnder();
    }

    @Override
    protected Change getLeadSelectedObject(ChangesBrowserNode node) {
      final Object o = node.getUserObject();
      if (o instanceof Change) {
        return (Change) o;
      }
      return null;
    }
  };

  myChanges = new ArrayList<>();
  for (ChangeList list : changeLists) {
    myChanges.addAll(list.getChanges());
  }
  myTreeList.setChangesToDisplay(myChanges, current);

  myCheckBox = new JBCheckBox("Select current file only");
  myCheckBox.setMnemonic('c');
  myCheckBox.addActionListener(e -> setSelected(myCheckBox.isSelected()));

  boolean selectCurrent = PropertiesComponent.getInstance().getBoolean(MOVE_CHANGES_CURRENT_ONLY);
  myCheckBox.setSelected(selectCurrent);
  setSelected(selectCurrent);

  init();
}
 
Example 20
Source File: FileStructurePopup.java    From consulo with Apache License 2.0 4 votes vote down vote up
private void addCheckbox(JPanel panel, TreeAction action) {
  String text = action instanceof FileStructureFilter
                ? ((FileStructureFilter)action).getCheckBoxText()
                : action instanceof FileStructureNodeProvider ? ((FileStructureNodeProvider)action).getCheckBoxText() : null;

  if (text == null) return;

  Shortcut[] shortcuts = extractShortcutFor(action);


  JBCheckBox checkBox = new JBCheckBox();
  checkBox.setOpaque(false);
  UIUtil.applyStyle(UIUtil.ComponentStyle.SMALL, checkBox);

  boolean selected = getDefaultValue(action);
  checkBox.setSelected(selected);
  boolean isRevertedStructureFilter = action instanceof FileStructureFilter && ((FileStructureFilter)action).isReverted();
  myTreeActionsOwner.setActionIncluded(action, isRevertedStructureFilter != selected);
  checkBox.addActionListener(__ -> {
    boolean state = checkBox.isSelected();
    if (!myAutoClicked.contains(checkBox)) {
      saveState(action, state);
    }
    myTreeActionsOwner.setActionIncluded(action, isRevertedStructureFilter != state);
    rebuild(false).onProcessed(ignore -> {
      if (mySpeedSearch.isPopupActive()) {
        mySpeedSearch.refreshSelection();
      }
    });
  });
  checkBox.setFocusable(false);

  if (shortcuts.length > 0) {
    text += " (" + KeymapUtil.getShortcutText(shortcuts[0]) + ")";
    DumbAwareAction.create(e -> checkBox.doClick()).registerCustomShortcutSet(new CustomShortcutSet(shortcuts), myTree);
  }
  checkBox.setText(StringUtil.capitalize(StringUtil.trimStart(text.trim(), "Show ")));
  panel.add(checkBox);

  myCheckBoxes.put(action.getClass(), checkBox);
}