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

项目:intellij-ce-playground    文件:ConfigurationModuleSelector.java   
/**
 * @deprecated use {@link #ConfigurationModuleSelector(Project, ModulesComboBox, String)} instead
 */
public ConfigurationModuleSelector(final Project project, final JComboBox modulesList, final String noModule) {
  myProject = project;
  myModulesList = modulesList;
  new ComboboxSpeedSearch(modulesList){
    protected String getElementText(Object element) {
      if (element instanceof Module){
        return ((Module)element).getName();
      } else if (element == null) {
        return noModule;
      }
      return super.getElementText(element);
    }
  };
  myModulesList.setModel(new SortedComboBoxModel<Module>(ModulesAlphaComparator.INSTANCE));
  myModulesList.setRenderer(new ModuleListCellRenderer(noModule));
}
项目:intellij-ce-playground    文件:ModulesComboBox.java   
private ModulesComboBox(final SortedComboBoxModel<Module> model) {
  super(model);
  myModel = model;
  new ComboboxSpeedSearch(this){
    @Override
    protected String getElementText(Object element) {
      if (element instanceof Module) {
        return ((Module)element).getName();
      } else if (element == null) {
        return "";
      }
      return super.getElementText(element);
    }
  };
  setRenderer(new ModuleListCellRenderer());
}
项目:vso-intellij    文件:CreatePullRequestModel.java   
private ComboBoxModel createRemoteBranchDropdownModel() {
    final SortedComboBoxModel<GitRemoteBranch> sortedRemoteBranches
            = new SortedComboBoxModel<GitRemoteBranch>(new TfGitHelper.BranchComparator());
    final GitRemoteBranch remoteTrackingBranch = this.getRemoteTrackingBranch();

    // only show valid remote branches
    sortedRemoteBranches.addAll(Collections2.filter(getInfo().getRemoteBranches(),
                    new Predicate<GitRemoteBranch>() {
                        @Override
                        public boolean apply(final GitRemoteBranch remoteBranch) {
                    /* two conditions:
                     *   1. remote must be a vso/tfs remote
                     *   2. this isn't the remote tracking branch of current local branch
                     */
                            return tfGitRemotes.contains(remoteBranch.getRemote())
                                    && !remoteBranch.equals(remoteTrackingBranch);
                        }
                    })
    );
    sortedRemoteBranches.setSelectedItem(TfGitHelper.getDefaultBranch(sortedRemoteBranches.getItems(), tfGitRemotes));

    return sortedRemoteBranches;
}
项目:vso-intellij    文件:CreateBranchModel.java   
private SortedComboBoxModel<GitRemoteBranch> createRemoteBranchDropdownModel() {
    logger.info("CreateBranchModel.createRemoteBranchDropdownModel");
    final SortedComboBoxModel<GitRemoteBranch> sortedRemoteBranches
            = new SortedComboBoxModel<GitRemoteBranch>(new TfGitHelper.BranchComparator());

    // TODO: add option to retrieve more branches in case the branch they are looking for is missing local
    // only show valid remote branches
    sortedRemoteBranches.addAll(Collections2.filter(gitRepository.getInfo().getRemoteBranches(), new Predicate<GitRemoteBranch>() {
                @Override
                public boolean apply(final GitRemoteBranch remoteBranch) {
                    //  condition: remote must be a vso/tfs remote
                    return tfGitRemotes.contains(remoteBranch.getRemote());
                }
            })
    );
    sortedRemoteBranches.setSelectedItem(TfGitHelper.getDefaultBranch(sortedRemoteBranches.getItems(), tfGitRemotes));
    return sortedRemoteBranches;
}
项目:intellij-xquery    文件:ConfigurationModuleSelector.java   
public ConfigurationModuleSelector(final Project project, final JComboBox<Module> modulesList, final String noModule) {
    myProject = project;
    myModulesList = modulesList;
    new ComboboxSpeedSearch(modulesList) {
        protected String getElementText(Object element) {
            if (element instanceof Module) {
                return ((Module) element).getName();
            } else if (element == null) {
                return noModule;
            }
            return super.getElementText(element);
        }
    };
    myModulesList.setModel(new SortedComboBoxModel<>(ModulesAlphaComparator.INSTANCE));
    myModulesList.setRenderer(new ModuleListCellRenderer(noModule));
}
项目:EclipseCodeFormatter    文件:ProjectSettingsForm.java   
private SortedComboBoxModel createProfilesModel() {
    // noinspection unchecked
    SortedComboBoxModel settingsSortedComboBoxModel = new SortedComboBoxModel(new Comparator<Settings>() {
        @Override
        public int compare(Settings o1, Settings o2) {
            if (o1.isProjectSpecific()) {
                return -1;
            }
            if (o2.isProjectSpecific()) {
                return 1;
            }
            return o1.getName().compareTo(o2.getName());
        }
    });
    refreshProfilesModel(settingsSortedComboBoxModel);
    return settingsSortedComboBoxModel;
}
项目:consulo    文件:ModulesComboBox.java   
private ModulesComboBox(final SortedComboBoxModel<Module> model) {
  super(model);
  myModel = model;
  new ComboboxSpeedSearch(this){
    @Override
    protected String getElementText(Object element) {
      if (element instanceof Module) {
        return ((Module)element).getName();
      } else if (element == null) {
        return "";
      }
      return super.getElementText(element);
    }
  };
  setRenderer(new ModuleListCellRenderer());
}
项目:consulo    文件:ModuleDescriptionsComboBox.java   
public ModuleDescriptionsComboBox() {
  myModel = new SortedComboBoxModel<>(Comparator.comparing(description -> description != null ? description.getName() : "",
                                                           String.CASE_INSENSITIVE_ORDER));
  setModel(myModel);
  new ComboboxSpeedSearch(this){
    @Override
    protected String getElementText(Object element) {
      if (element instanceof ModuleDescription) {
        return ((ModuleDescription)element).getName();
      }
      else {
        return "";
      }
    }
  };
  setRenderer(new ModuleDescriptionListCellRenderer());
}
项目:consulo-java    文件:ConfigurationModuleSelector.java   
/**
 * @deprecated use {@link #ConfigurationModuleSelector(Project, ModulesComboBox, String)} instead
 */
public ConfigurationModuleSelector(final Project project, final JComboBox<Module> modulesList, final String noModule)
{
    myProject = project;
    myModulesList = modulesList;
    myModulesDescriptionsComboBox = null;
    new ComboboxSpeedSearch(modulesList)
    {
        protected String getElementText(Object element)
        {
            if(element instanceof Module)
            {
                return ((Module) element).getName();
            }
            else if(element == null)
            {
                return noModule;
            }
            return super.getElementText(element);
        }
    };
    myModulesList.setModel(new SortedComboBoxModel<>(ModulesAlphaComparator.INSTANCE));
    myModulesList.setRenderer(new ModuleListCellRenderer(noModule));
}
项目:consulo-java    文件:ConfigurationModuleSelector.java   
private void setModules(final Collection<Module> modules)
{
    if(myModulesDescriptionsComboBox != null)
    {
        myModulesDescriptionsComboBox.setModules(modules);
    }
    else if(myModulesList instanceof ModulesComboBox)
    {
        ((ModulesComboBox) myModulesList).setModules(modules);
    }
    else
    {
        SortedComboBoxModel<Module> model = (SortedComboBoxModel<Module>) myModulesList.getModel();
        model.setAll(modules);
        model.add(null);
    }
}
项目:intellij-ce-playground    文件:ConfigurationModuleSelector.java   
private void setModules(final Collection<Module> modules) {
  if (myModulesList instanceof ModulesComboBox) {
    ((ModulesComboBox)myModulesList).setModules(modules);
  }
  else {
    SortedComboBoxModel<Module> model = (SortedComboBoxModel<Module>)myModulesList.getModel();
    model.setAll(modules);
    model.add(null);
  }
}
项目:intellij-ce-playground    文件:GithubCreatePullRequestPanel.java   
public GithubCreatePullRequestPanel() {
  myDescriptionTextArea.setBorder(BorderFactory.createEtchedBorder());

  myBranchModel = new SortedComboBoxModel<BranchInfo>(new Comparator<BranchInfo>() {
    @Override
    public int compare(BranchInfo o1, BranchInfo o2) {
      return StringUtil.naturalCompare(o1.getRemoteName(), o2.getRemoteName());
    }
  });
  myBranchComboBox.setModel(myBranchModel);

  myForkModel = new SortedComboBoxModel<ForkInfo>(new Comparator<ForkInfo>() {
    @Override
    public int compare(ForkInfo o1, ForkInfo o2) {
      return StringUtil.naturalCompare(o1.getPath().getUser(), o2.getPath().getUser());
    }
  });
  myForkComboBox.setModel(myForkModel);

  DocumentListener userModifiedDocumentListener = new DocumentAdapter() {
    @Override
    protected void textChanged(DocumentEvent e) {
      myTitleDescriptionUserModified = true;
    }
  };
  myTitleTextField.getDocument().addDocumentListener(userModifiedDocumentListener);
  myDescriptionTextArea.getDocument().addDocumentListener(userModifiedDocumentListener);
}
项目:intellij-ce-playground    文件:GithubSelectForkPanel.java   
public GithubSelectForkPanel() {
  myModel = new SortedComboBoxModel<String>(new Comparator<String>() {
    @Override
    public int compare(String o1, String o2) {
      return StringUtil.naturalCompare(o1, o2);
    }
  });

  myComboBox.setModel(myModel);
}
项目:intellij-ce-playground    文件:ChooseAndEditComboBoxController.java   
public ChooseAndEditComboBoxController(ComboboxWithBrowseButton combobox,
                                       Convertor<Item, Ref> toRef,
                                       Comparator<Ref> comparator) {
  myCombobox = combobox;
  myToString = toRef;
  myCombobox.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {
      resetList(openConfigureDialog(myItems.get(getSelectedString()), getCombobox()));
    }
  });
  getCombobox().setModel(new SortedComboBoxModel<Ref>(comparator));
}
项目:intellij-ce-playground    文件:ChooseAndEditComboBoxController.java   
public void resetList(Item selection) {
  Ref selectedItem = getSelectedString();
  myItems.clear();
  myItems.putAll(ContainerUtil.newMapFromValues(getAllListItems(), myToString));
  SortedComboBoxModel<Ref> model = getModel();
  model.setAll(myItems.keySet());
  if (selection != null) model.setSelectedItem(myToString.convert(selection));
  else model.setSelectedItem(selectedItem);
}
项目:tools-idea    文件:ModulesCombobox.java   
private ModulesCombobox(final SortedComboBoxModel<Module> model) {
  super(model);
  myModel = model;
  new ComboboxSpeedSearch(this){
    @Override
    protected String getElementText(Object element) {
      if (element instanceof Module) {
        return ((Module)element).getName();
      } else if (element == null) {
        return "";
      }
      return super.getElementText(element);
    }
  };
  setRenderer(new ListCellRendererWrapper<Module>() {
    @Override
    public void customize(JList list, Module value, int index, boolean selected, boolean hasFocus) {
      if (value != null) {
        setText(value.getName());
        setIcon(ModuleType.get(value).getIcon());
      }
      else {
        setText("[none]");
      }
    }
  });
}
项目:tools-idea    文件:ChooseAndEditComboBoxController.java   
public ChooseAndEditComboBoxController(ComboboxWithBrowseButton combobox,
                                       Convertor<Item, Ref> toRef,
                                       Comparator<Ref> comparator) {
  myCombobox = combobox;
  myToString = toRef;
  myCombobox.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {
      resetList(openConfigureDialog(myItems.get(getSelectedString()), getCombobox()));
    }
  });
  getCombobox().setModel(new SortedComboBoxModel<Ref>(comparator));
}
项目:tools-idea    文件:ChooseAndEditComboBoxController.java   
public void resetList(Item selection) {
  Ref selectedItem = getSelectedString();
  myItems.clear();
  myItems.putAll(ContainerUtil.newMapFromValues(getAllListItems(), myToString));
  SortedComboBoxModel<Ref> model = getModel();
  model.setAll(myItems.keySet());
  if (selection != null) model.setSelectedItem(myToString.convert(selection));
  else model.setSelectedItem(selectedItem);
}
项目:intellij-xquery    文件:UIUtils.java   
static SortedComboBoxModel<String> comboBoxModel() {
    return new SortedComboBoxModel<String>(new Comparator<String>() {
        @Override
        public int compare(String o1, String o2) {
            return o1.compareToIgnoreCase(o2);
        }
    });
}
项目:intellij-xquery    文件:OtherOptionsPanel.java   
private SortedComboBoxModel<XQueryFlavour> comboBoxModel() {
    return new SortedComboBoxModel<>(new Comparator<XQueryFlavour>() {
        @Override
        public int compare(XQueryFlavour o1, XQueryFlavour o2) {
            return o1.getPresentableName().compareToIgnoreCase(o2.getPresentableName());
        }
    });
}
项目:intellij-xquery    文件:ConfigurationModuleSelector.java   
private void setModules(final Collection<Module> modules) {
    if (myModulesList instanceof ModulesComboBox) {
        ((ModulesComboBox) myModulesList).setModules(modules);
    } else {
        SortedComboBoxModel<Module> model = (SortedComboBoxModel<Module>) myModulesList.getModel();
        model.setAll(modules);
        model.add(null);
    }
}
项目:EclipseCodeFormatter    文件:ProjectSettingsForm.java   
private ComboBoxModel createProfilesModel(JTextField pathToEclipsePreferenceFile, String selectedProfile) {
    @SuppressWarnings("unchecked")
    SortedComboBoxModel profilesModel = new SortedComboBoxModel(new Comparator<String>() {
        @Override
        public int compare(String o1, String o2) {
            return o1.compareTo(o2);
        }
    });
    String text = pathToEclipsePreferenceFile.getText();
    if (!text.isEmpty()) {
        if (text.endsWith("xml")) {
            try {
                profilesModel.addAll(FileUtils.getProfileNamesFromConfigXML(new File(text)));
            } catch (ParsingFailedException e) {
                profilesModel.add(PARSING_FAILED);
            }
        } else {
            // not xml
        }
    } else {
        // empty
    }
    List<String> items = profilesModel.getItems();
    if (items.size() > 0) {
        for (String item : items) {
            if (item.equals(selectedProfile)) {
                profilesModel.setSelectedItem(item);
            }
        }
        if (profilesModel.getSelectedItem() == null) {
            profilesModel.setSelectedItem(items.get(0));
        }
    }

    return profilesModel;
}
项目:consulo-apache-ant    文件:ChooseAndEditComboBoxController.java   
public ChooseAndEditComboBoxController(ComboboxWithBrowseButton combobox,
                                       Convertor<Item, Ref> toRef,
                                       Comparator<Ref> comparator) {
  myCombobox = combobox;
  myToString = toRef;
  myCombobox.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {
      resetList(openConfigureDialog(myItems.get(getSelectedString()), getCombobox()));
    }
  });
  getCombobox().setModel(new SortedComboBoxModel<Ref>(comparator));
}
项目:consulo-apache-ant    文件:ChooseAndEditComboBoxController.java   
public void resetList(Item selection) {
  Ref selectedItem = getSelectedString();
  myItems.clear();
  myItems.putAll(ContainerUtil.newMapFromValues(getAllListItems(), myToString));
  SortedComboBoxModel<Ref> model = getModel();
  model.setAll(myItems.keySet());
  if (selection != null) model.setSelectedItem(myToString.convert(selection));
  else model.setSelectedItem(selectedItem);
}
项目:consulo    文件:LocalToServerSettingsEditor.java   
public LocalToServerSettingsEditor(final ServerType<S> type, DeploymentConfigurator<D> deploymentConfigurator, Project project) {
  myServerType = type;
  myDeploymentConfigurator = deploymentConfigurator;
  myProject = project;

   mySourceListModel = new SortedComboBoxModel<DeploymentSource>(new Comparator<DeploymentSource>() {
    @Override
    public int compare(DeploymentSource o1, DeploymentSource o2) {
      return o1.getPresentableName().compareToIgnoreCase(o2.getPresentableName());
    }
  });
  mySourceListModel.addAll(deploymentConfigurator.getAvailableDeploymentSources());
  mySourceComboBox = new ComboBox(mySourceListModel);
  mySourceComboBox.setRenderer(new ListCellRendererWrapper<DeploymentSource>() {
    @Override
    public void customize(JList list, DeploymentSource value, int index, boolean selected, boolean hasFocus) {
      if (value == null) return;
      setIcon(value.getIcon());
      setText(value.getPresentableName());
    }
  });

  myDeploymentSettingsComponent = new JPanel(new BorderLayout());
  mySourceComboBox.addActionListener(new ActionListener() {
    @Override
    public void actionPerformed(ActionEvent e) {
      onDeploymentSourceChanged(null);
    }
  });
}
项目:intellij-ce-playground    文件:JreComboboxEditor.java   
public JreComboboxEditor(SortedComboBoxModel<JrePathEditor.JreComboBoxItem> comboBoxModel) {
  myComboBoxModel = comboBoxModel;
}
项目:intellij-ce-playground    文件:ModulesComboBox.java   
public ModulesComboBox() {
  this(new SortedComboBoxModel<Module>(ModulesAlphaComparator.INSTANCE));
}
项目:intellij-ce-playground    文件:ChooseAndEditComboBoxController.java   
private SortedComboBoxModel<Ref> getModel() {
  return ((SortedComboBoxModel<Ref>)getCombobox().getModel());
}
项目:tools-idea    文件:ModulesCombobox.java   
public ModulesCombobox() {
  this(new SortedComboBoxModel<Module>(ModulesAlphaComparator.INSTANCE));
}
项目:tools-idea    文件:ChooseAndEditComboBoxController.java   
private SortedComboBoxModel<Ref> getModel() {
  return ((SortedComboBoxModel<Ref>)getCombobox().getModel());
}
项目:intellij-xquery    文件:DefaultFileExtensionsPanel.java   
private void populateExtensionsList(SortedComboBoxModel<String> model, Object defaultItem, List<String> allItems) {
    for (String type : allItems) {
        model.add(type);
    }
    model.setSelectedItem(defaultItem);
}
项目:EclipseCodeFormatter    文件:ProjectSettingsForm.java   
private void refreshProfilesModel(SortedComboBoxModel profilesModel) {
    profilesModel.setAll(GlobalSettings.getInstance().getSettingsList());
    Settings projectSpecificProfile = ProjectSettings.getInstance(project).getState().getProjectSpecificProfile();
    profilesModel.add(projectSpecificProfile);
}
项目:consulo-apache-ant    文件:ChooseAndEditComboBoxController.java   
private SortedComboBoxModel<Ref> getModel() {
  return ((SortedComboBoxModel<Ref>)getCombobox().getModel());
}
项目:consulo    文件:ModulesComboBox.java   
public ModulesComboBox() {
  this(new SortedComboBoxModel<>(ModulesAlphaComparator.INSTANCE));
}