com.intellij.ui.CollectionComboBoxModel Java Examples
The following examples show how to use
com.intellij.ui.CollectionComboBoxModel.
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: FlutterLogFilterPanel.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 6 votes |
public FlutterLogFilterPanel(@NotNull OnFilterListener onFilterListener) { this.onFilterListener = onFilterListener; final ItemListener listener = e -> doFilter(); matchCaseCheckBox.addItemListener(listener); regexCheckBox.addItemListener(listener); final List<FlutterLog.Level> logLevels = Arrays.stream(FlutterLog.Level.values()) .collect(Collectors.toList()); logLevelComboBox.setModel(new CollectionComboBoxModel<>(logLevels)); logLevelComboBox.setSelectedItem(FlutterLog.Level.NONE); logLevelComboBox.addActionListener(event -> doFilter()); logLevelComboBox.setRenderer(new ColoredListCellRenderer<FlutterLog.Level>() { @Override protected void customizeCellRenderer(@NotNull JList<? extends FlutterLog.Level> list, FlutterLog.Level value, int index, boolean selected, boolean hasFocus) { // When NONE is selected, show an empty string in the combo selector. final String label = index == -1 && value == FlutterLog.Level.NONE ? "" : value.toDisplayString(); append(label); } }); }
Example #2
Source File: FlutterLogFilterPanel.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 6 votes |
public FlutterLogFilterPanel(@NotNull OnFilterListener onFilterListener) { this.onFilterListener = onFilterListener; final ItemListener listener = e -> doFilter(); matchCaseCheckBox.addItemListener(listener); regexCheckBox.addItemListener(listener); final List<FlutterLog.Level> logLevels = Arrays.stream(FlutterLog.Level.values()) .collect(Collectors.toList()); logLevelComboBox.setModel(new CollectionComboBoxModel<>(logLevels)); logLevelComboBox.setSelectedItem(FlutterLog.Level.NONE); logLevelComboBox.addActionListener(event -> doFilter()); logLevelComboBox.setRenderer(new ColoredListCellRenderer<FlutterLog.Level>() { @Override protected void customizeCellRenderer(@NotNull JList<? extends FlutterLog.Level> list, FlutterLog.Level value, int index, boolean selected, boolean hasFocus) { // When NONE is selected, show an empty string in the combo selector. final String label = index == -1 && value == FlutterLog.Level.NONE ? "" : value.toDisplayString(); append(label); } }); }
Example #3
Source File: QuarkusModuleInfoStep.java From intellij-quarkus with Eclipse Public License 2.0 | 5 votes |
@Override public void _init() { ProgressIndicator indicator = new EmptyProgressIndicator() { @Override public void setText(String text) { SwingUtilities.invokeLater(() -> panel.setLoadingText(text)); } }; try { QuarkusModel model = QuarkusModelRegistry.INSTANCE.load(context.getUserData(QuarkusConstants.WIZARD_ENDPOINT_URL_KEY), indicator); context.putUserData(QuarkusConstants.WIZARD_MODEL_KEY, model); final FormBuilder formBuilder = new FormBuilder(); final CollectionComboBoxModel<ToolDelegate> toolModel = new CollectionComboBoxModel<>(Arrays.asList(ToolDelegate.getDelegates())); toolComboBox = new ComboBox<>(toolModel); toolComboBox.setRenderer(new ColoredListCellRenderer<ToolDelegate>() { @Override protected void customizeCellRenderer(@NotNull JList<? extends ToolDelegate> list, ToolDelegate toolDelegate, int index, boolean selected, boolean hasFocus) { this.append(toolDelegate.getDisplay()); } }); formBuilder.addLabeledComponent("Tool:", toolComboBox); groupIdField = new JBTextField("org.acme"); formBuilder.addLabeledComponent("Group:", groupIdField); artifactIdField = new JBTextField("code-with-quarkus"); formBuilder.addLabeledComponent("Artifact:", artifactIdField); versionField = new JBTextField("1.0.0-SNAPSHOT"); formBuilder.addLabeledComponent("Version:", versionField); classNameField = new JBTextField("org.acme.ExampleResource"); formBuilder.addLabeledComponent("Class name:", classNameField); pathField = new JBTextField("/hello"); formBuilder.addLabeledComponent("Path:", pathField); panel.add(ScrollPaneFactory.createScrollPane(formBuilder.getPanel(), true), "North"); } catch (IOException e) { LOGGER.error(e.getLocalizedMessage(), e); throw new RuntimeException(e); } }
Example #4
Source File: BaseGroupPanel.java From EasyCode with MIT License | 5 votes |
/** * 初始化方法 * * @param defaultGroupName 默认选中分组 */ private void init(String defaultGroupName) { // 创建一个内容面板 JPanel contentPanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); ComboBoxModel<String> comboBoxModel = new CollectionComboBoxModel<>(groupNameList); this.comboBox = new ComboBox<>(comboBoxModel); // 添加下拉框 contentPanel.add(new Label("Group Name:")); contentPanel.add(this.comboBox); // 添加事件按钮 DefaultActionGroup actionGroup = createActionGroup(); // 添加分组选中事件 this.comboBox.addItemListener(e -> changeGroup((String) comboBox.getSelectedItem())); // 选择默认分组 this.comboBox.setSelectedItem(defaultGroupName); ActionToolbar actionToolbar = ActionManager.getInstance().createActionToolbar("Group Toolbar", actionGroup, true); contentPanel.add(actionToolbar.getComponent()); contentPanel.setPreferredSize(JBUI.size(600, 40)); // 将内容面板添加至主面板左边(西边) this.add(contentPanel, BorderLayout.WEST); }
Example #5
Source File: BaseGroupPanel.java From EasyCode with MIT License | 5 votes |
/** * 重置方法 * @param groupNameList 分组列表 * @param defaultGroupName 默认选中分组 */ public void reset(@NotNull List<String> groupNameList, String defaultGroupName) { this.groupNameList = groupNameList; ComboBoxModel<String> comboBoxModel = new CollectionComboBoxModel<>(groupNameList); this.comboBox.setModel(comboBoxModel); this.comboBox.setSelectedItem(defaultGroupName); // 回调一波 changeGroup(defaultGroupName); }
Example #6
Source File: InitializrUtil.java From intellij-spring-assistant with MIT License | 5 votes |
@NotNull public static <T extends IdContainer> CollectionComboBoxModel<T> newCollectionComboBoxModel( @NotNull List<T> values, @Nullable String defaultValueId) { T defaultIdAndName = null; if (!isEmpty(defaultValueId)) { for (T idAndName : values) { if (idAndName.getId().equals(defaultValueId)) { defaultIdAndName = idAndName; break; } } } return new CollectionComboBoxModel<>(values, defaultIdAndName); }
Example #7
Source File: GraphQLEditConfigAction.java From js-graphql-intellij-plugin with MIT License | 5 votes |
@Nullable @Override protected JComponent createCenterPanel() { comboBox = new ComboBox<>(new CollectionComboBoxModel<>(configDirectoryCandidates)); comboBox.setRenderer(new DefaultPsiElementCellRenderer()); comboBox.setMinimumAndPreferredWidth(450); if (comboBox.getItemCount() > 0) { comboBox.setSelectedIndex(0); } final NonOpaquePanel panel = new NonOpaquePanel(); panel.add(comboBox, BorderLayout.NORTH); return panel; }
Example #8
Source File: FileTypeChooser.java From consulo with Apache License 2.0 | 5 votes |
private FileTypeChooser(@Nonnull List<String> patterns, @Nonnull String fileName) { super(true); myFileName = fileName; FileType[] fileTypes = FileTypeManager.getInstance().getRegisteredFileTypes(); Arrays.sort(fileTypes, (fileType1, fileType2) -> { if (fileType1 == null) { return 1; } if (fileType2 == null) { return -1; } return fileType1.getDescription().compareToIgnoreCase(fileType2.getDescription()); }); final DefaultListModel<FileType> model = new DefaultListModel<>(); for (FileType type : fileTypes) { if (!type.isReadOnly() && type != UnknownFileType.INSTANCE && !(type instanceof NativeFileType)) { model.addElement(type); } } myList.setModel(model); myPattern.setModel(new CollectionComboBoxModel<>(ContainerUtil.map(patterns, FunctionUtil.<String>id()), patterns.get(0))); UnknownExtension fileFeatureForChecking = new UnknownExtension(FileTypeFactory.FILE_TYPE_FACTORY_EP.getName(), fileName); List<PluginDescriptor> allPlugins = PluginsAdvertiserHolder.getLoadedPluginDescriptors(); myFeaturePlugins = PluginsAdvertiser.findByFeature(allPlugins, fileFeatureForChecking); if (!myFeaturePlugins.isEmpty()) { myInstallPluginFromRepository.setSelected(true); myInstallPluginFromRepository.setText(FileTypesBundle.message("filetype.chooser.install.plugin")); } else { myInstallPluginFromRepository.setVisible(false); } setTitle(FileTypesBundle.message("filetype.chooser.title")); init(); }
Example #9
Source File: BrowserSettingsPanel.java From consulo with Apache License 2.0 | 5 votes |
BrowserSettingsPanel() { alternativeBrowserPathField.addBrowseFolderListener(IdeBundle.message("title.select.path.to.browser"), null, null, APP_FILE_CHOOSER_DESCRIPTOR); defaultBrowserPanel.setBorder(TitledSeparator.createEmptyBorder()); ArrayList<DefaultBrowserPolicy> defaultBrowserPolicies = new ArrayList<>(); if (BrowserLauncherAppless.canUseSystemDefaultBrowserPolicy()) { defaultBrowserPolicies.add(DefaultBrowserPolicy.SYSTEM); } defaultBrowserPolicies.add(DefaultBrowserPolicy.FIRST); defaultBrowserPolicies.add(DefaultBrowserPolicy.ALTERNATIVE); defaultBrowserPolicyComboBox.setModel(new CollectionComboBoxModel<>(defaultBrowserPolicies)); defaultBrowserPolicyComboBox.addItemListener(new ItemListener() { @Override public void itemStateChanged(@Nonnull ItemEvent e) { boolean customPathEnabled = e.getItem() == DefaultBrowserPolicy.ALTERNATIVE; if (e.getStateChange() == ItemEvent.DESELECTED) { if (customPathEnabled) { customPathValue = alternativeBrowserPathField.getText(); } } else if (e.getStateChange() == ItemEvent.SELECTED) { alternativeBrowserPathField.setEnabled(customPathEnabled); updateCustomPathTextFieldValue((DefaultBrowserPolicy)e.getItem()); } } }); defaultBrowserPolicyComboBox.setRenderer(SimpleListCellRenderer.create("", value -> { String text = value == DefaultBrowserPolicy.SYSTEM ? "System default" : value == DefaultBrowserPolicy.FIRST ? "First listed" : value == DefaultBrowserPolicy.ALTERNATIVE ? "Custom path" : null; if (text == null) throw new IllegalStateException(String.valueOf(value)); return text; })); }
Example #10
Source File: CodeDialogBuilder.java From android-codegenerator-plugin-intellij with Apache License 2.0 | 4 votes |
public void addSourcePathSection(java.util.List<String> string, String defaultValue) { topPanel.add(new JLabel(StringResources.SOURCE_PATH_LABEL)); sourcePathComboBox = new ComboBox(new CollectionComboBoxModel(string)); sourcePathComboBox.setSelectedItem(defaultValue); topPanel.add(sourcePathComboBox); }