com.intellij.ui.CollectionListModel Java Examples
The following examples show how to use
com.intellij.ui.CollectionListModel.
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: SchemesToImportPopup.java From consulo with Apache License 2.0 | 6 votes |
public void show(Collection<T> schemes) { if (schemes.isEmpty()) { Messages.showMessageDialog("There are no available schemes to import", "Import", Messages.getWarningIcon()); return; } final JList list = new JBList(new CollectionListModel<T>(schemes)); list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); list.setCellRenderer(new SchemesToImportListCellRenderer()); Runnable selectAction = new Runnable() { @Override public void run() { onSchemeSelected((T)list.getSelectedValue()); } }; showList(list, selectAction); }
Example #2
Source File: JBListUpdater.java From consulo with Apache License 2.0 | 6 votes |
@Override public void replaceModel(@Nonnull List<? extends PsiElement> data) { final Object selectedValue = myComponent.getSelectedValue(); final int index = myComponent.getSelectedIndex(); ListModel model = myComponent.getModel(); if (model instanceof NameFilteringListModel) { ((NameFilteringListModel)model).replaceAll(data); } else if (model instanceof CollectionListModel) { ((CollectionListModel)model).replaceAll(data); } else { throw new UnsupportedOperationException("JList model of class " + model.getClass() + " is not supported by JBListUpdater"); } if (index == 0) { myComponent.setSelectedIndex(0); } else { myComponent.setSelectedValue(selectedValue, true); } }
Example #3
Source File: GenerateDialog.java From android-parcelable-intellij-plugin with Apache License 2.0 | 6 votes |
protected GenerateDialog(final PsiClass psiClass) { super(psiClass.getProject()); setTitle("Select Fields for Parcelable Generation"); fieldsCollection = new CollectionListModel<PsiField>(); final JBList fieldList = new JBList(fieldsCollection); fieldList.setCellRenderer(new DefaultPsiElementCellRenderer()); final ToolbarDecorator decorator = ToolbarDecorator.createDecorator(fieldList).disableAddAction(); final JPanel panel = decorator.createPanel(); fieldsComponent = LabeledComponent.create(panel, "Fields to include in Parcelable"); includeSubclasses = new JBCheckBox("Include fields from base classes"); setupCheckboxClickAction(psiClass); showCheckbox = psiClass.getFields().length != psiClass.getAllFields().length; updateFieldsDisplay(psiClass); init(); }
Example #4
Source File: CommonConfigView.java From easy_javadoc with Apache License 2.0 | 5 votes |
private void createUIComponents() { typeMapList = new JBList<>(new CollectionListModel<>(Lists.newArrayList())); typeMapList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); typeMapList.setCellRenderer(new ListCellRendererWrapper<Entry<String, String>>() { @Override public void customize(JList list, Entry<String, String> value, int index, boolean selected, boolean hasFocus) { setText(value.getKey() + " -> " + value.getValue()); } }); typeMapList.setEmptyText("请添加单词映射"); typeMapList.setSelectedIndex(0); ToolbarDecorator toolbarDecorator = ToolbarDecorator.createDecorator(typeMapList); toolbarDecorator.setAddAction(button -> { WordMapAddView wordMapAddView = new WordMapAddView(); if (wordMapAddView.showAndGet()) { if (config != null) { Entry<String, String> entry = wordMapAddView.getMapping(); config.getWordMap().put(entry.getKey(), entry.getValue()); refreshWordMap(); } } }); toolbarDecorator.setRemoveAction(anActionButton -> { if (config != null) { Map<String, String> typeMap = config.getWordMap(); typeMap.remove(typeMapList.getSelectedValue().getKey()); refreshWordMap(); } }); wordMapPanel = toolbarDecorator.createPanel(); }
Example #5
Source File: BaseItemSelectPanel.java From EasyCode with MIT License | 5 votes |
/** * 重置方法 * * @param itemList 元素列表 * @param selectedIndex 选中的元素下标 */ public void reset(@NotNull List<T> itemList, int selectedIndex) { this.itemList = itemList; listPanel.setModel(new CollectionListModel<>(dataConvert())); // 存在元素时,默认选中第一个元素 if (!itemList.isEmpty()) { listPanel.setSelectedIndex(selectedIndex); } }
Example #6
Source File: SettingsForm.java From protobuf-jetbrains-plugin with Apache License 2.0 | 5 votes |
/** * Create new {@link SettingsForm} instance. * * @param settings is null if settings dialog runs without a project. */ @SuppressWarnings("unchecked") public SettingsForm(@Nullable Project project, @Nullable ProtobufSettings settings) { this.project = project; List<String> internalIncludePathList = new ArrayList<>(); if (settings != null) { internalIncludePathList.addAll(settings.getIncludePaths()); } includePathListList = Collections.unmodifiableList(internalIncludePathList); includePathModel = new CollectionListModel<>(internalIncludePathList, true); includePathList.setModel(includePathModel); addButton.addActionListener(e -> { FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createSingleFolderDescriptor(); FileChooser.chooseFile(descriptor, this.project, null, selectedFolder -> { String path = selectedFolder.getPath(); includePathModel.add(path); }); }); removeButton.addActionListener(e -> { int selectedIndex = includePathList.getSelectedIndex(); if (selectedIndex != -1) { includePathModel.removeRow(selectedIndex); } }); if (settings == null) { addButton.setEnabled(false); removeButton.setEnabled(false); } }
Example #7
Source File: WorkspaceTypeList.java From intellij with Apache License 2.0 | 5 votes |
public WorkspaceTypeList(ImmutableList<TopLevelSelectWorkspaceOption> supportedOptions) { setSelectionMode(ListSelectionModel.SINGLE_SELECTION); setModel(new CollectionListModel<>(supportedOptions)); setCellRenderer( new GroupedItemsListRenderer<TopLevelSelectWorkspaceOption>(new ItemDescriptor()) { @Override protected JComponent createItemComponent() { JComponent component = super.createItemComponent(); myTextLabel.setBorder(JBUI.Borders.empty(3)); return component; } }); }
Example #8
Source File: NonProjectFileWritingAccessDialog.java From consulo with Apache License 2.0 | 5 votes |
public NonProjectFileWritingAccessDialog(@Nonnull Project project, @Nonnull List<VirtualFile> nonProjectFiles, @Nonnull String filesType) { super(project); setTitle(filesType + " Protection"); myFileList.setPreferredSize(ReadOnlyStatusDialog.getDialogPreferredSize()); myFileList.setCellRenderer(new FileListRenderer()); myFileList.setModel(new CollectionListModel<>(nonProjectFiles)); String theseFilesMessage = ReadOnlyStatusDialog.getTheseFilesMessage(nonProjectFiles); myListTitle.setText(StringUtil.capitalize(theseFilesMessage) + " " + (nonProjectFiles.size() > 1 ? "do" : "does") + " not belong to the project:"); myUnlockOneButton.setSelected(true); setTextAndMnemonicAndListeners(myUnlockOneButton, "I want to edit " + theseFilesMessage + " anyway", "edit"); int dirs = ContainerUtil.map2Set(nonProjectFiles, VirtualFile::getParent).size(); setTextAndMnemonicAndListeners(myUnlockDirButton, "I want to edit all files in " + StringUtil.pluralize("this", dirs) + " " + StringUtil.pluralize("directory", dirs), "dir"); setTextAndMnemonicAndListeners(myUnlockAllButton, "I want to edit any non-project file in the current session", "any"); // disable default button to avoid accidental pressing, if user typed something, missed the dialog and pressed 'enter'. getOKAction().putValue(DEFAULT_ACTION, null); getCancelAction().putValue(DEFAULT_ACTION, null); getRootPane().registerKeyboardAction(e -> doOKAction(), KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, InputEvent.CTRL_DOWN_MASK), JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); getRootPane().registerKeyboardAction(e -> doOKAction(), KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, InputEvent.META_DOWN_MASK), JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); init(); }
Example #9
Source File: ChangelistConflictDialog.java From consulo with Apache License 2.0 | 5 votes |
public ChangelistConflictDialog(Project project, List<ChangeList> changeLists, List<VirtualFile> conflicts) { super(project); myProject = project; setTitle("Resolve Changelist Conflict"); myFileList.setCellRenderer(new FileListRenderer()); myFileList.setModel(new CollectionListModel(conflicts)); ChangeListManagerImpl manager = ChangeListManagerImpl.getInstanceImpl(myProject); ChangelistConflictResolution resolution = manager.getConflictTracker().getOptions().LAST_RESOLUTION; if (changeLists.size() > 1) { mySwitchToChangelistRadioButton.setEnabled(false); if (resolution == ChangelistConflictResolution.SWITCH) { resolution = ChangelistConflictResolution.IGNORE; } } mySwitchToChangelistRadioButton.setText(VcsBundle.message("switch.to.changelist", changeLists.iterator().next().getName())); myMoveChangesToActiveRadioButton.setText(VcsBundle.message("move.to.changelist", manager.getDefaultChangeList().getName())); switch (resolution) { case SHELVE: myShelveChangesRadioButton.setSelected(true); break; case MOVE: myMoveChangesToActiveRadioButton.setSelected(true); break; case SWITCH: mySwitchToChangelistRadioButton.setSelected(true) ; break; case IGNORE: myIgnoreRadioButton.setSelected(true); break; } init(); }
Example #10
Source File: CommonConfigView.java From easy_javadoc with Apache License 2.0 | 4 votes |
private void refreshWordMap() { if (null != config && config.getWordMap() != null) { typeMapList.setModel(new CollectionListModel<>(Lists.newArrayList(config.getWordMap().entrySet()))); } }
Example #11
Source File: GtRepoChooser.java From GitToolBox with Apache License 2.0 | 4 votes |
private void fillData() { List<GitRepository> repositoriesToShow = new ArrayList<>(repositories); repositoriesToShow.removeAll(selectedRepositories); repositoriesToShow = GtUtil.sort(repositoriesToShow); repoList.setModel(new CollectionListModel<>(repositoriesToShow)); }
Example #12
Source File: PopupFactoryImpl.java From consulo with Apache License 2.0 | 4 votes |
@Nonnull @Override public <T> IPopupChooserBuilder<T> createPopupChooserBuilder(@Nonnull List<? extends T> list) { return new PopupChooserBuilder<>(new JBList<>(new CollectionListModel<>(list))); }