Java Code Examples for com.intellij.ui.SortedComboBoxModel#setSelectedItem()
The following examples show how to use
com.intellij.ui.SortedComboBoxModel#setSelectedItem() .
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: CreatePullRequestModel.java From azure-devops-intellij with MIT License | 6 votes |
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(), 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; }
Example 2
Source File: ConfigFileLocator.java From EclipseCodeFormatter with Apache License 2.0 | 6 votes |
private void processWorkspaceConfig(SortedComboBoxModel profilesModel, JComboBox comboBox, File uiPrefs) throws IOException { Properties properties = FileUtils.readPropertiesFile(uiPrefs); String xml = properties.getProperty("org.eclipse.jdt.ui.formatterprofiles"); List<String> profileNamesFromConfigXML = FileUtils.getProfileNamesFromConfigXML(IOUtils.toInputStream(xml)); if (profileNamesFromConfigXML.isEmpty()) { invalid("Workspace does not contain custom formatter profiles!", profilesModel, comboBox); } else { profilesModel.addAll(profileNamesFromConfigXML); String formatter_profile1 = properties.getProperty("formatter_profile"); String substring = formatter_profile1.substring(1); if (new HashSet<>(profileNamesFromConfigXML).contains(substring)) { profilesModel.setSelectedItem(substring); } } }
Example 3
Source File: CreateBranchModel.java From azure-devops-intellij with MIT License | 5 votes |
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(), remoteBranch -> { // condition: remote must be a vso/tfs remote return tfGitRemotes.contains(remoteBranch.getRemote()); })); sortedRemoteBranches.setSelectedItem(TfGitHelper.getDefaultBranch(sortedRemoteBranches.getItems(), tfGitRemotes)); return sortedRemoteBranches; }
Example 4
Source File: ProjectSettingsForm.java From EclipseCodeFormatter with Apache License 2.0 | 5 votes |
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 (normalBorder == null) { this.normalBorder = javaFormatterProfile.getBorder(); } if (!text.isEmpty() && schemeEclipseFile.isSelected()) { ConfigFileLocator configFileLocator = new ConfigFileLocator(); configFileLocator.validate(this, profilesModel, text); } else { javaFormatterProfile.setEnabled(false); javaFormatterProfile.setBorder(this.normalBorder); } 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; }
Example 5
Source File: DefaultFileExtensionsPanel.java From intellij-xquery with Apache License 2.0 | 4 votes |
private void populateExtensionsList(SortedComboBoxModel<String> model, Object defaultItem, List<String> allItems) { for (String type : allItems) { model.add(type); } model.setSelectedItem(defaultItem); }