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

The following examples show how to use com.intellij.ui.components.JBCheckBox#addItemListener() . 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: SelectFileTemplateDialog.java    From PackageTemplates with Apache License 2.0 6 votes vote down vote up
@NotNull
private JPanel getOptionsPanel(final JPanel root) {
    JPanel options = new JPanel(new GridBagLayout());
    GridBag bag = new GridBag()
            .setDefaultInsets(new JBInsets(0, 4, 0, 4))
            .setDefaultFill(GridBagConstraints.HORIZONTAL);

    cbAddInternal = new JBCheckBox("Internal");
    cbAddJ2EE = new JBCheckBox("J2EE");

    ItemListener itemListener = e -> {
        root.remove(comboBox);
        comboBox = getSelector();
        root.add(comboBox);
        root.revalidate();
    };

    cbAddInternal.addItemListener(itemListener);
    cbAddJ2EE.addItemListener(itemListener);

    options.add(cbAddInternal, bag.nextLine().next());
    options.add(cbAddJ2EE, bag.next());
    return options;
}
 
Example 2
Source File: BlazeIntellijPluginConfiguration.java    From intellij with Apache License 2.0 6 votes vote down vote up
public BlazeIntellijPluginConfigurationSettingsEditor(
    Iterable<Label> javaLabels,
    RunConfigurationStateEditor blazeFlagsEditor,
    RunConfigurationStateEditor exeFlagsEditor) {
  targetCombo =
      new ComboBox<>(
          new DefaultComboBoxModel<>(
              Ordering.usingToString().sortedCopy(javaLabels).toArray(new Label[0])));
  targetCombo.setRenderer(
      new ListCellRendererWrapper<Label>() {
        @Override
        public void customize(
            JList list, @Nullable Label value, int index, boolean selected, boolean hasFocus) {
          setText(value == null ? null : value.toString());
        }
      });
  this.blazeFlagsEditor = blazeFlagsEditor;
  this.exeFlagsEditor = exeFlagsEditor;
  ProjectSdksModel sdksModel = new ProjectSdksModel();
  sdksModel.reset(null);
  sdkCombo = new JdkComboBox(sdksModel, IdeaJdkHelper::isIdeaJdkType);

  keepInSyncCheckBox = new JBCheckBox("Keep in sync with source XML");
  keepInSyncCheckBox.addItemListener(e -> updateEnabledStatus());
}
 
Example 3
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 4
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 5
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 6
Source File: BlazeCommandRunConfiguration.java    From intellij with Apache License 2.0 5 votes vote down vote up
BlazeCommandRunConfigurationSettingsEditor(BlazeCommandRunConfiguration config) {
  Project project = config.getProject();
  elementState = config.blazeElementState.clone();
  targetsUi = new TargetExpressionListUi(project);
  targetExpressionLabel = new JBLabel(UIUtil.ComponentStyle.LARGE);
  keepInSyncCheckBox = new JBCheckBox("Keep in sync with source XML");
  outputFileUi = new ConsoleOutputFileSettingsUi<>();
  editorWithoutSyncCheckBox = UiUtil.createBox(targetExpressionLabel, targetsUi);
  editor =
      UiUtil.createBox(
          editorWithoutSyncCheckBox, outputFileUi.getComponent(), keepInSyncCheckBox);
  updateEditor(config);
  updateHandlerEditor(config);
  keepInSyncCheckBox.addItemListener(e -> updateEnabledStatus());
}
 
Example 7
Source File: PackageTemplateWrapper.java    From PackageTemplates with Apache License 2.0 4 votes vote down vote up
private void buildProperties() {
    // Header
    JLabel jlName = new JLabel(Localizer.get("Name"));
    JLabel jlDescription = new JLabel(Localizer.get("Description"));

    jtfName = new JBTextField(packageTemplate.getName());
    jtaDescription = new JTextArea(packageTemplate.getDescription());

    panelProperties.add(jlName, new CC().wrap().spanX().pad(0, 0, 0, 8).gapY("0", "4pt"));
    panelProperties.add(jtfName, new CC().spanX().growX().pushX().wrap());
    panelProperties.add(jlDescription, new CC().wrap().spanX().pad(0, 0, 0, 8).gapY("4pt", "4pt"));
    panelProperties.add(jtaDescription, new CC().spanX().growX().pushX().wrap().gapY("0", "4pt"));

    //FileTemplate Source
    ArrayList<FileTemplateSource> actionTypes = new ArrayList<>();
    actionTypes.add(FileTemplateSource.DEFAULT_ONLY);
    actionTypes.add(FileTemplateSource.PROJECT_ONLY);
    actionTypes.add(FileTemplateSource.PROJECT_PRIORITY);
    actionTypes.add(FileTemplateSource.DEFAULT_PRIORITY);

    cboxFileTemplateSource = new ComboBox(actionTypes.toArray());
    cboxFileTemplateSource.setRenderer(new FileTemplateSourceCellRenderer());
    cboxFileTemplateSource.setSelectedItem(packageTemplate.getFileTemplateSource());
    cboxFileTemplateSource.addActionListener(e -> {
        packageTemplate.setFileTemplateSource((FileTemplateSource) cboxFileTemplateSource.getSelectedItem());
    });

    if (mode == ViewMode.USAGE) {
        jtfName.setEditable(false);
        jtaDescription.setEditable(false);
        cboxFileTemplateSource.setEnabled(false);
    } else {
        // Properties
        cbShouldRegisterAction = new JBCheckBox(Localizer.get("property.ShouldRegisterAction"), packageTemplate.isShouldRegisterAction());
        cbSkipDefiningNames = new JBCheckBox(Localizer.get("property.SkipPresettings"), packageTemplate.isSkipDefiningNames());
        panelProperties.add(cbShouldRegisterAction, new CC().wrap().spanX());
        panelProperties.add(cbSkipDefiningNames, new CC().wrap().spanX());
    }

    // Properties
    cbSkipRootDirectory = new JBCheckBox(Localizer.get("property.SkipRootDirectory"), packageTemplate.isSkipRootDirectory());
    cbSkipRootDirectory.addItemListener(e -> {
        collectDataFromFields();
        reBuildElements();
    });
    cbShowReportDialog = new JBCheckBox(Localizer.get("property.ShowReportDialog"), packageTemplate.shouldShowReport());

    panelProperties.add(cbSkipRootDirectory, new CC().spanX().wrap());
    panelProperties.add(cbShowReportDialog, new CC().spanX().wrap());
    panelProperties.add(new JLabel(Localizer.get("FileTemplateSource")), new CC().spanX().split(2));
    panelProperties.add(cboxFileTemplateSource, new CC().pushX().growX().wrap());

}