Java 类com.intellij.ui.EnumComboBoxModel 实例源码

项目:intellij-ce-playground    文件:ComboBoxTableCellEditor.java   
@Override
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
  if (value instanceof ListWithSelection) {
    ListWithSelection options = (ListWithSelection)value;
    //noinspection unchecked
    comboBox.setModel(new ListComboBoxModel(options));

    if (options.getSelection() == null) {
      options.selectFirst();
    }
    comboBox.setSelectedItem(options.getSelection());
  }
  else {
    Enum enumValue = (Enum)value;
    Class enumClass = enumValue.getDeclaringClass();
    //noinspection unchecked
    ComboBoxModel model = comboBox.getModel();
    if (!(model instanceof EnumComboBoxModel && model.getSize() > 0 && ((Enum)model.getElementAt(0)).getDeclaringClass() == enumClass)) {
      //noinspection unchecked
      comboBox.setModel(new EnumComboBoxModel(enumClass));
    }
    comboBox.setSelectedItem(value);
  }

  return comboBox;
}
项目:intellij-ce-playground    文件:GitVcsPanel.java   
private void createUIComponents() {
  myProtectedBranchesButton = new TextFieldWithBrowseButton.NoPathCompletion(new ActionListener() {
    @Override
    public void actionPerformed(ActionEvent e) {
      Messages.showTextAreaDialog(myProtectedBranchesButton.getTextField(), "Protected Branches", "Git.Force.Push.Protected.Branches",
                                  ParametersListUtil.COLON_LINE_PARSER, ParametersListUtil.COLON_LINE_JOINER);
    }
  });
  myProtectedBranchesButton.setButtonIcon(AllIcons.Actions.ShowViewer);
  myUpdateMethodComboBox = new ComboBox(new EnumComboBoxModel<UpdateMethod>(UpdateMethod.class));
  myUpdateMethodComboBox.setRenderer(new ListCellRendererWrapper<UpdateMethod>() {
    @Override
    public void customize(JList list, UpdateMethod value, int index, boolean selected, boolean hasFocus) {
      setText(StringUtil.capitalize(StringUtil.toLowerCase(value.name().replace('_', ' '))));
    }
  });
}
项目:ibatis-plugin    文件:IbatisConfigurationTab.java   
public void fillData() {
    fillDatasourceList();

    sqlmapSuffixTextField.setText(configuration.sqlMapSuffix);

    sqlMapPackageName.setText(configuration.sqlMapPackage);
    sqlMapPackageName.setEnabled(false);

    beanPackageTextField.setText(configuration.beanPackage);
    beanPackageTextField.setEnabled(false);

    beanTemplate.setText(configuration.beanTemplate);
    sqlMapTemplate.setText(configuration.sqlMapTemplate);
    selectKeyType.setModel(new EnumComboBoxModel<SelectKeyType>(SelectKeyType.class));
    selectKeyType.setSelectedItem(configuration.selectKeyType);
    selectKeyTemplate.setText(configuration.selectKeyTemplate);
    selectKeyTemplate.setEnabled(configuration.selectKeyType != SelectKeyType.none);

    insertTemplate.setText(configuration.insertTemplate);
    selectTemplate.setText(configuration.selectTemplate);
    updateTemplate.setText(configuration.updateTemplate);
    deleteTemplate.setText(configuration.deleteTemplate);

    generateDefaultCRUDOperationsCheckBox.setSelected(configuration.generateCrudOperations);
    injectGeneratedSQLMapCheckBox.setSelected(configuration.injectCreatedSqlMap);
}
项目:consulo    文件:ComboBoxTableCellEditor.java   
@Override
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
  if (value instanceof ListWithSelection) {
    ListWithSelection options = (ListWithSelection)value;
    //noinspection unchecked
    comboBox.setModel(new ListComboBoxModel(options));

    if (options.getSelection() == null) {
      options.selectFirst();
    }
    comboBox.setSelectedItem(options.getSelection());
  }
  else {
    Enum enumValue = (Enum)value;
    Class enumClass = enumValue.getDeclaringClass();
    //noinspection unchecked
    ComboBoxModel model = comboBox.getModel();
    if (!(model instanceof EnumComboBoxModel && model.getSize() > 0 && ((Enum)model.getElementAt(0)).getDeclaringClass() == enumClass)) {
      //noinspection unchecked
      comboBox.setModel(new EnumComboBoxModel(enumClass));
    }
    comboBox.setSelectedItem(value);
  }

  return comboBox;
}
项目:consulo    文件:CleanUnshelvedFilterDialog.java   
public CleanUnshelvedFilterDialog(@Nullable Project project) {
  super(project);
  setTitle("Clean Unshelved Changelists");
  mySystemUnshelvedButton = new JRadioButton("created automatically", true);
  myUnshelvedWithFilterButton = new JRadioButton("older than one", false);
  myAllUnshelvedButton = new JRadioButton("all", false);
  myTimePeriodComboBox = new ComboBox(new EnumComboBoxModel<>(TimePeriod.class));
  myTimePeriodComboBox.setEnabled(myUnshelvedWithFilterButton.isSelected());
  myUnshelvedWithFilterButton.addItemListener(new ItemListener() {
    @Override
    public void itemStateChanged(ItemEvent e) {
      myTimePeriodComboBox.setEnabled(myUnshelvedWithFilterButton.isSelected());
    }
  });
  setOKButtonText("Delete");
  init();
  setResizable(false);
}
项目:PackageTemplates    文件:SettingsDialog.java   
private void createLanguageViews() {
    jlLanguage = new JLabel(Localizer.get("settings.Language"));

    comboLanguages = new ComboBox(new EnumComboBoxModel<>(Language.class));
    if (SaveUtil.reader().getLanguage() != null) {
        comboLanguages.setSelectedItem(SaveUtil.reader().getLanguage());
    }
}
项目:GitLink    文件:Settings.java   
public Settings(Preferences preferences, List<UrlModifier> urlModifiers, Plugin plugin)
{
    this.preferences = preferences;

    $$$setupUI$$$();
    this.hostSelect.setModel(new EnumComboBoxModel<>(RemoteHost.class));
    this.defaultBranchTextField.setText(this.preferences.getDefaultBranch().toString());
    this.customURLPanel.setVisible(this.preferences.getRemoteHost().custom());

    this.applyLabelHelpTextStlye(this.customFileUrlLabel);
    this.applyLabelHelpTextStlye(this.customCommitUrlLabel);
    this.applyLabelHeadingStlye(this.projectSettingsLabel);
    this.applyLabelHeadingStlye(this.customUrlLabel);

    this.hostSelect.addActionListener(e -> {
        RemoteHost host = (((RemoteHost) hostSelect.getSelectedItem()));
        Settings.this.customURLPanel.setVisible((host != null && host.custom()));
    });

    for (UrlModifier modifier : urlModifiers) {
        JBCheckBox checkBox = new JBCheckBox(modifier.name());
        this.urlModifierCheckBoxes.put(modifier, checkBox);
        this.urlModifierCheckBoxPanel.add(checkBox, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
    }

    this.pluginDetailsLabel.setText(plugin.toString());
    this.featureRequestLabel.setText(String.format("Submit feature requests and bug reports to %s", plugin.issueTracker()));
    this.applyLabelHelpTextStlye(this.pluginDetailsLabel);
    this.applyLabelHelpTextStlye(this.featureRequestLabel);

}
项目:intellij-ce-playground    文件:MavenImportingSettingsForm.java   
public MavenImportingSettingsForm(boolean isImportStep, boolean isCreatingNewProject) {
  mySearchRecursivelyCheckBox.setVisible(isImportStep);
  myProjectFormatLabel.setVisible(isImportStep && isCreatingNewProject);
  myProjectFormatComboBox.setVisible(isImportStep && isCreatingNewProject);

  ActionListener listener = new ActionListener() {
    public void actionPerformed(ActionEvent e) {
      updateControls();
    }
  };
  mySeparateModulesDirCheckBox.addActionListener(listener);

  mySeparateModulesDirChooser.addBrowseFolderListener(ProjectBundle.message("maven.import.title.module.dir"), "", null,
                                                      FileChooserDescriptorFactory.createSingleFolderDescriptor());

  myUpdateFoldersOnImportPhaseComboBox.setModel(new DefaultComboBoxModel(MavenImportingSettings.UPDATE_FOLDERS_PHASES));

  myGeneratedSourcesComboBox.setModel(new EnumComboBoxModel<MavenImportingSettings.GeneratedSourcesFolder>(MavenImportingSettings.GeneratedSourcesFolder.class));
  myGeneratedSourcesComboBox.setRenderer(new ListCellRendererWrapper() {
    @Override
    public void customize(JList list, Object value, int index, boolean selected, boolean hasFocus) {
      if (value instanceof MavenImportingSettings.GeneratedSourcesFolder) {
        setText(((MavenImportingSettings.GeneratedSourcesFolder)value).title);
      }
    }
  });

  LabelTextReplacingUtil.replaceText(myPanel);
}
项目:tools-idea    文件:MavenImportingSettingsForm.java   
public MavenImportingSettingsForm(boolean isImportStep, boolean isCreatingNewProject) {
  mySearchRecursivelyCheckBox.setVisible(isImportStep);
  myProjectFormatLabel.setVisible(isImportStep && isCreatingNewProject);
  myProjectFormatComboBox.setVisible(isImportStep && isCreatingNewProject);

  ActionListener listener = new ActionListener() {
    public void actionPerformed(ActionEvent e) {
      updateControls();
    }
  };
  mySeparateModulesDirCheckBox.addActionListener(listener);

  mySeparateModulesDirChooser.addBrowseFolderListener(ProjectBundle.message("maven.import.title.module.dir"), "", null,
                                                      FileChooserDescriptorFactory.createSingleFolderDescriptor());

  myUpdateFoldersOnImportPhaseComboBox.setModel(new DefaultComboBoxModel(MavenImportingSettings.UPDATE_FOLDERS_PHASES));

  myGeneratedSourcesComboBox.setModel(new EnumComboBoxModel<MavenImportingSettings.GeneratedSourcesFolder>(MavenImportingSettings.GeneratedSourcesFolder.class));
  myGeneratedSourcesComboBox.setRenderer(new ListCellRendererWrapper() {
    @Override
    public void customize(JList list, Object value, int index, boolean selected, boolean hasFocus) {
      if (value instanceof MavenImportingSettings.GeneratedSourcesFolder) {
        setText(((MavenImportingSettings.GeneratedSourcesFolder)value).title);
      }
    }
  });

  LabelTextReplacingUtil.replaceText(myPanel);
}
项目:intellij-ce-playground    文件:ForceArrangementPanel.java   
public ForceArrangementPanel() {
  myForceRearrangeComboBox = new JComboBox();
  myForceRearrangeComboBox.setModel(new EnumComboBoxModel<SelectedMode>(SelectedMode.class));
  myForceRearrangeComboBox.setMaximumSize(myForceRearrangeComboBox.getPreferredSize());
  myPanel = createPanel();
}
项目:intellij-ce-playground    文件:CreateResourceDirectoryDialog.java   
public CreateResourceDirectoryDialog(@NotNull Project project, @Nullable ResourceFolderType resType,
                                     @Nullable PsiDirectory resDirectory, @Nullable Module module) {
  super(project);
  myResDirectory = resDirectory;
  myResourceTypeComboBox.setModel(new EnumComboBoxModel<ResourceFolderType>(ResourceFolderType.class));
  myResourceTypeComboBox.setRenderer(new ListCellRendererWrapper() {
    @Override
    public void customize(JList list, Object value, int index, boolean selected, boolean hasFocus) {
      if (value instanceof ResourceFolderType) {
        setText(((ResourceFolderType)value).getName());
      }
    }
  });

  myDeviceConfiguratorPanel = new DeviceConfiguratorPanel() {
    @Override
    public void applyEditors() {
      try {
        doApplyEditors();
        final FolderConfiguration config = myDeviceConfiguratorPanel.getConfiguration();
        final ResourceFolderType selectedResourceType = (ResourceFolderType)myResourceTypeComboBox.getSelectedItem();
        myDirectoryNameTextField.setText(selectedResourceType != null ? config.getFolderName(selectedResourceType) : "");
        myErrorLabel.setText("");
      }
      catch (InvalidOptionValueException e) {
        myErrorLabel.setText("<html><body><font color=\"red\">" + e.getMessage() + "</font></body></html>");
        myDirectoryNameTextField.setText("");
      }
      setOKActionEnabled(myDirectoryNameTextField.getText().length() > 0);
    }
  };

  myDeviceConfiguratorWrapper.add(myDeviceConfiguratorPanel, BorderLayout.CENTER);
  myResourceTypeComboBox.addActionListener(new ActionListener() {
    @Override
    public void actionPerformed(ActionEvent e) {
      myDeviceConfiguratorPanel.applyEditors();
    }
  });

  if (resType != null) {
    myResourceTypeComboBox.setSelectedItem(resType);
    myResourceTypeComboBox.setEnabled(false);
  } else {
    // Select values by default if not otherwise specified
    myResourceTypeComboBox.setSelectedItem(ResourceFolderType.VALUES);
  }

  AndroidFacet facet = module != null ? AndroidFacet.getInstance(module) : null;
  CreateResourceActionBase.updateSourceSetCombo(mySourceSetLabel, mySourceSetCombo, facet, myResDirectory);

  myDeviceConfiguratorPanel.updateAll();
  setOKActionEnabled(myDirectoryNameTextField.getText().length() > 0);
  init();
}
项目:consulo    文件:ForceArrangementPanel.java   
public ForceArrangementPanel() {
  myForceRearrangeComboBox = new JComboBox();
  myForceRearrangeComboBox.setModel(new EnumComboBoxModel<SelectedMode>(SelectedMode.class));
  myForceRearrangeComboBox.setMaximumSize(myForceRearrangeComboBox.getPreferredSize());
  myPanel = createPanel();
}