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

项目:intellij-ce-playground    文件:DownloadingOptionsDialog.java   
private void onVersionChanged(final @Nullable List<? extends DownloadableLibraryFileDescription> selectedFiles) {
  final FrameworkLibraryVersion version = getSelectedVersion();
  if (Comparing.equal(myLastSelectedVersion, version)) return;

  if (version != null) {
    final List<? extends DownloadableLibraryFileDescription> downloads = version.getFiles();
    myFilesList.setModel(new CollectionListModel<JCheckBox>(
      ContainerUtil.map2Array(downloads, JCheckBox.class, new Function<DownloadableLibraryFileDescription, JCheckBox>() {
        @Override
        public JCheckBox fun(DownloadableLibraryFileDescription description) {
          final boolean selected = selectedFiles != null ? selectedFiles.contains(description) : !description.isOptional();
          return new JCheckBox(description.getPresentableFileName(), selected);
        }
      })));
    if (myNameAndLevelPanel != null) {
      myNameAndLevelPanel.setDefaultName(version.getDefaultLibraryName());
    }
  }
  updateSourcesAndJavadocCheckboxes();
  myLastSelectedVersion = version;
}
项目:intellij-ce-playground    文件:ProjectTemplateList.java   
public void setTemplates(List<ProjectTemplate> list, boolean preserveSelection) {
  Collections.sort(list, new Comparator<ProjectTemplate>() {
    @Override
    public int compare(ProjectTemplate o1, ProjectTemplate o2) {
      return Comparing.compare(o1 instanceof ArchivedProjectTemplate, o2 instanceof ArchivedProjectTemplate);
    }
  });

  int index = preserveSelection ? myList.getSelectedIndex() : -1;
  //noinspection unchecked
  myList.setModel(new CollectionListModel(list));
  if (myList.isEnabled()) {
    myList.setSelectedIndex(index == -1 ? 0 : index);
  }
  updateSelection();
}
项目:intellij-ce-playground    文件:SchemesToImportPopup.java   
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);
}
项目:intellij-ce-playground    文件:ImportDependenciesDialog.java   
protected ImportDependenciesDialog(Project project, List<ImportDependenciesTask> tasks) {
  super(project, false);
  setTitle(AndroidBundle.message("android.import.dependencies.dialog.title"));

  myTasks = tasks;

  final JCheckBox[] checkBoxes = new JCheckBox[tasks.size()];

  for (int i = 0; i < checkBoxes.length; i++) {
    final ImportDependenciesTask task = tasks.get(i);
    final JCheckBox checkBox = new JCheckBox(task.getTitle());
    checkBox.setSelected(true);
    checkBoxes[i] = checkBox;
    myTask2Checkbox.put(task, checkBox);
  }

  myCheckBoxList.setModel(new CollectionListModel(checkBoxes));

  init();
}
项目:tools-idea    文件:DownloadingOptionsDialog.java   
private void onVersionChanged(final @Nullable List<? extends DownloadableLibraryFileDescription> selectedFiles) {
  final FrameworkLibraryVersion version = getSelectedVersion();
  if (Comparing.equal(myLastSelectedVersion, version)) return;

  if (version != null) {
    final List<? extends DownloadableLibraryFileDescription> downloads = version.getFiles();
    myFilesList.setModel(new CollectionListModel<JCheckBox>(
      ContainerUtil.map2Array(downloads, JCheckBox.class, new Function<DownloadableLibraryFileDescription, JCheckBox>() {
        @Override
        public JCheckBox fun(DownloadableLibraryFileDescription description) {
          final boolean selected = selectedFiles != null ? selectedFiles.contains(description) : !description.isOptional();
          return new JCheckBox(description.getPresentableFileName(), selected);
        }
      })));
    if (myNameAndLevelPanel != null) {
      myNameAndLevelPanel.setDefaultName(version.getDefaultLibraryName());
    }
  }
  updateSourcesAndJavadocCheckboxes();
  myLastSelectedVersion = version;
}
项目:consulo    文件:SchemesToImportPopup.java   
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);
}
项目:android-parcelable-intellij-plugin    文件:GenerateDialog.java   
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();
}
项目:intellij-nette-factory-generator    文件:GenerateFactoryInterfaceDialog.java   
private void initFactoryParams() {
    Method constructor = originalClass.getConstructor();
    java.util.List<ConstructorParameter> list = new ArrayList<>();
    if (constructor != null) {
        for (Parameter parameter : constructor.getParameters()) {
            list.add(new ConstructorParameter(parameter));
        }
    }

    ListModel<ConstructorParameter> model = new CollectionListModel<>(list);
    factoryParams.setModel(model);
    factoryParams.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
}
项目:protobuf-jetbrains-plugin    文件:SettingsForm.java   
/**
 * Create new {@link SettingsForm} instance.
 *
 * @param settings is null if settings dialog runs without a project.
 */
@SuppressWarnings("unchecked")
public SettingsForm(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);
    }
}
项目:intellij-ce-playground    文件:NonProjectFileWritingAccessDialog.java   
protected NonProjectFileWritingAccessDialog(@NotNull Project project, @NotNull List<VirtualFile> nonProjectFiles) {
  super(project);
  setTitle("Non-Project Files Access");

  myFileList.setCellRenderer(new FileListRenderer());
  myFileList.setModel(new CollectionListModel<VirtualFile>(nonProjectFiles));

  getOKAction().putValue(DEFAULT_ACTION, null);
  getCancelAction().putValue(DEFAULT_ACTION, true);

  init();
}
项目:intellij-ce-playground    文件:SelectPluginsStep.java   
public void fillPlugins() {
  Collections.sort(myPlugins, new Comparator<IdeaPluginDescriptor>() {
    public int compare(final IdeaPluginDescriptor o1, final IdeaPluginDescriptor o2) {
      return StringUtil.compare(o1.getName(), o2.getName(), true);
    }
  });
  myPluginsList.setModel(new CollectionListModel(myPlugins));
  myPluginsList.setSelectedIndex(0);
}
项目:intellij-ce-playground    文件:ChangelistConflictDialog.java   
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();
}
项目:SerializableParcelableGenerator    文件:GenerateDialog.java   
protected GenerateDialog(PsiClass psiClass) {
    super(psiClass.getProject());
    setTitle("Select fields for SerializableParcelable generation");

    PsiField[] allFields = psiClass.getAllFields();
    PsiField[] fields = new PsiField[allFields.length];

    int i = 0;

    for (PsiField field : allFields) {
        // Exclude static fields
        if (!field.hasModifierProperty(PsiModifier.STATIC)) {
            fields[i++] = field;
        }
    }

    // i is post-incremented, so no need to add 1 for the count
    fields = Arrays.copyOfRange(fields, 0, i);

    myFields = new CollectionListModel<PsiField>(fields);

    JBList fieldList = new JBList(myFields);
    fieldList.setCellRenderer(new DefaultPsiElementCellRenderer());
    ToolbarDecorator decorator = ToolbarDecorator.createDecorator(fieldList);
    decorator.disableAddAction();
    JPanel panel = decorator.createPanel();

    myComponent = LabeledComponent.create(panel, "Fields to include in Parcelable");

    init();
}
项目:step-builder-generator    文件:GeneratorDialog.java   
protected GeneratorDialog(PsiClass psiClass, List<PsiPropertyContainer> allProperties) {
    super(psiClass.getProject());
    setTitle("Configure Step Builder");
    this.properties = new JBList(new CollectionListModel<PsiPropertyContainer>(allProperties));
    this.properties.setCellRenderer(new PropertyCellRenderer());
    this.properties.setSelectedIndices(range(allProperties.size()));
    ToolbarDecorator decorator = ToolbarDecorator.createDecorator(properties);
    decorator.disableAddAction();
    decorator.disableRemoveAction();
    JPanel panel = decorator.createPanel();
    component = LabeledComponent.create(panel, "Properties to include in Step Builder:");

    init();
}
项目:tools-idea    文件:SelectPluginsStep.java   
public void fillPlugins() {
  Collections.sort(myPlugins, new Comparator<IdeaPluginDescriptor>() {
    public int compare(final IdeaPluginDescriptor o1, final IdeaPluginDescriptor o2) {
      return StringUtil.compare(o1.getName(), o2.getName(), true);
    }
  });
  myPluginsList.setModel(new CollectionListModel(myPlugins));
  myPluginsList.setSelectedIndex(0);
}
项目:tools-idea    文件:ChangelistConflictDialog.java   
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();
}
项目:consulo    文件:NonProjectFileWritingAccessDialog.java   
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();
}
项目:consulo    文件:ChangelistConflictDialog.java   
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();
}
项目:consulo    文件:NavBarPopup.java   
private static JComponent createPopupContent(NavBarPanel panel, Object[] siblings) {
  class MyList<E> extends JBList<E> implements DataProvider, Queryable {
    @Override
    public void putInfo(@Nonnull Map<String, String> info) {
      panel.putInfo(info);
    }

    @Nullable
    @Override
    public Object getData(Key dataId) {
      return panel.getDataImpl(dataId, () -> JBIterable.of(getSelectedValuesList()));
    }
  }
  JBList<Object> list = new MyList<>();
  list.setModel(new CollectionListModel<>(siblings));
  HintUpdateSupply.installSimpleHintUpdateSupply(list);
  List<Disposable> disposables = new ArrayList<>();
  list.putClientProperty(DISPOSED_OBJECTS, disposables);
  list.installCellRenderer(obj -> {
    final NavBarItem navBarItem = new NavBarItem(panel, obj, null);
    disposables.add(navBarItem);
    return navBarItem;
  });
  list.setBorder(JBUI.Borders.empty(5));
  installMoveAction(list, panel, -1, KeyEvent.VK_LEFT);
  installMoveAction(list, panel, 1, KeyEvent.VK_RIGHT);
  installEnterAction(list, panel, KeyEvent.VK_ENTER);
  installEscapeAction(list, panel, KeyEvent.VK_ESCAPE);
  JComponent component = ListWithFilter.wrap(list, new NavBarListWrapper(list), o -> panel.getPresentation().getPresentableText(o));
  component.putClientProperty(JBLIST_KEY, list);
  return component;
}
项目:intellij-ce-playground    文件:FilteringListModel.java   
public void addAll(List elements) {
  myData.addAll(elements);
  ((CollectionListModel)myOriginalModel).add(elements);
}
项目:intellij-ce-playground    文件:FilteringListModel.java   
public void replaceAll(List elements) {
  myData.clear();
  myData.addAll(elements);
  ((CollectionListModel)myOriginalModel).replaceAll(elements);
}
项目:intellij-ce-playground    文件:ListModelEditorBase.java   
@NotNull
public CollectionListModel<T> getModel() {
  return model;
}
项目:GitToolBox    文件:GtRepoChooser.java   
private void fillData() {
  List<GitRepository> repositoriesToShow = new ArrayList<>(repositories);
  repositoriesToShow.removeAll(selectedRepositories);
  repositoriesToShow = GtUtil.sort(repositoriesToShow);
  repoList.setModel(new CollectionListModel<>(repositoriesToShow));
}
项目:tools-idea    文件:FilteringListModel.java   
public void addAll(List elements) {
  myData.addAll(elements);
  ((CollectionListModel)myOriginalModel).add(elements);
}
项目:tools-idea    文件:FilteringListModel.java   
public void replaceAll(List elements) {
  myData.clear();
  myData.addAll(elements);
  ((CollectionListModel)myOriginalModel).replaceAll(elements);
}
项目:consulo-javaee    文件:JavaEEStartupConfigurationEditor.java   
@NotNull
@Override
protected JComponent createEditor()
{
    JPanel panel = new JPanel(new VerticalFlowLayout());
    JBList<Executor> executorList = new JBList<>(new CollectionListModel<>(Executor.EP_NAME.getExtensions()));
    executorList.setCellRenderer(new ColoredListCellRenderer<Executor>()
    {
        @Override
        protected void customizeCellRenderer(@NotNull JList<? extends Executor> list, Executor value, int index, boolean selected, boolean hasFocus)
        {
            setIcon(value.getIcon());
            append(value.getActionName());
        }
    });
    JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(executorList);
    scrollPane.setPreferredSize(JBUI.size(-1, 90));
    panel.add(scrollPane);

    JBTextField startupScript = new JBTextField();
    JBTextField shutdownScript = new JBTextField();

    JBCheckBox startScriptDefault = new JBCheckBox(J2EEBundle.message("checkbox.edit.script.properties.use.default"));
    JBCheckBox shutdownScriptDefault = new JBCheckBox(J2EEBundle.message("checkbox.edit.script.properties.use.default"));

    JPanel scriptPanel = new JPanel(new GridLayout(2, 3));
    panel.add(scriptPanel);
    scriptPanel.add(new JBLabel(J2EEBundle.message("label.run.configuration.editor.startup.script")));
    scriptPanel.add(startupScript);
    scriptPanel.add(startScriptDefault);
    scriptPanel.add(new JBLabel(J2EEBundle.message("label.run.configuration.editor.shutdown.script")));
    scriptPanel.add(shutdownScript);
    scriptPanel.add(shutdownScriptDefault);

    JPanel envPanel = new JPanel(new BorderLayout());
    envPanel.setBorder(IdeBorderFactory.createTitledBorder(J2EEBundle.message("border.run.configuration.editor.environment.variables"), false));
    JBCheckBox passEnvVariables = new JBCheckBox(J2EEBundle.message("checkbox.run.configuration.editor.pass.environment.variables"));
    envPanel.add(passEnvVariables, BorderLayout.NORTH);

    java.util.List<Couple<String>> env = new ArrayList<>();
    ColumnInfo[] columnInfos = {
            new ColumnInfo.StringColumn("Name"),
            new ColumnInfo.StringColumn("Value")
    };
    TableView<Couple<String>> tableView = new TableView<>(new ListTableModel<>(columnInfos, env));
    ToolbarDecorator decorator = ToolbarDecorator.createDecorator(tableView);
    decorator.disableUpDownActions();

    JPanel comp = decorator.createPanel();
    comp.setPreferredSize(JBUI.size(-1, 100));
    envPanel.add(comp, BorderLayout.CENTER);

    panel.add(envPanel);
    return ScrollPaneFactory.createScrollPane(panel);
}
项目:consulo-tasks    文件:TaskRepositoriesConfigurable.java   
private void addRepository(TaskRepository repository) {
  myRepositories.add(repository);
  ((CollectionListModel)myRepositoriesList.getModel()).add(repository);
  addRepositoryEditor(repository, true);
  myRepositoriesList.setSelectedIndex(myRepositoriesList.getModel().getSize() - 1);
}
项目:consulo    文件:FilteringListModel.java   
public void addAll(List elements) {
  myData.addAll(elements);
  ((CollectionListModel)myOriginalModel).add(elements);
}
项目:consulo    文件:FilteringListModel.java   
public void replaceAll(List elements) {
  myData.clear();
  myData.addAll(elements);
  ((CollectionListModel)myOriginalModel).replaceAll(elements);
}