Java Code Examples for com.intellij.util.containers.ContainerUtil#newLinkedHashMap()
The following examples show how to use
com.intellij.util.containers.ContainerUtil#newLinkedHashMap() .
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: LabelPainter.java From consulo with Apache License 2.0 | 6 votes |
@Nonnull private static Color[] getColors(@Nonnull Collection<RefGroup> groups) { LinkedHashMap<Color, Integer> usedColors = ContainerUtil.newLinkedHashMap(); for (RefGroup group : groups) { List<Color> colors = group.getColors(); for (Color color : colors) { Integer count = usedColors.get(color); if (count == null) count = 0; usedColors.put(color, count + 1); } } List<Color> result = ContainerUtil.newArrayList(); for (Map.Entry<Color, Integer> entry : usedColors.entrySet()) { result.add(entry.getKey()); if (entry.getValue() > 1) { result.add(entry.getKey()); } } return result.toArray(new Color[result.size()]); }
Example 2
Source File: FileUtil.java From consulo with Apache License 2.0 | 6 votes |
/** * Like {@link Properties#load(Reader)}, but preserves the order of key/value pairs. */ @Nonnull public static Map<String, String> loadProperties(@Nonnull Reader reader) throws IOException { final Map<String, String> map = ContainerUtil.newLinkedHashMap(); new Properties() { @Override public synchronized Object put(Object key, Object value) { map.put(String.valueOf(key), String.valueOf(value)); //noinspection UseOfPropertiesAsHashtable return super.put(key, value); } }.load(reader); return map; }
Example 3
Source File: PushController.java From consulo with Apache License 2.0 | 6 votes |
private void startLoadingCommits() { Map<RepositoryNode, MyRepoModel> priorityLoading = ContainerUtil.newLinkedHashMap(); Map<RepositoryNode, MyRepoModel> others = ContainerUtil.newLinkedHashMap(); RepositoryNode nodeForCurrentEditor = findNodeByRepo(myCurrentlyOpenedRepository); for (Map.Entry<RepositoryNode, MyRepoModel<?, ?, ?>> entry : myView2Model.entrySet()) { MyRepoModel model = entry.getValue(); Repository repository = model.getRepository(); RepositoryNode repoNode = entry.getKey(); if (preselectByUser(repository)) { priorityLoading.put(repoNode, model); } else if (model.getSupport().shouldRequestIncomingChangesForNotCheckedRepositories() && !repoNode.equals(nodeForCurrentEditor)) { others.put(repoNode, model); } if (shouldPreSelect(model)) { model.setChecked(true); } } if (nodeForCurrentEditor != null) { //add repo for currently opened editor to the end of priority queue priorityLoading.put(nodeForCurrentEditor, myView2Model.get(nodeForCurrentEditor)); } loadCommitsFromMap(priorityLoading); loadCommitsFromMap(others); }
Example 4
Source File: TemplateContext.java From consulo with Apache License 2.0 | 6 votes |
Map<TemplateContextType, Boolean> getDifference(@Nullable TemplateContext defaultContext) { Map<TemplateContextType, Boolean> result = ContainerUtil.newLinkedHashMap(); synchronized (myContextStates) { //noinspection NestedSynchronizedStatement synchronized (defaultContext == null ? myContextStates : defaultContext.myContextStates) { for (TemplateContextType contextType : TemplateContextType.EP_NAME.getExtensions()) { String context = contextType.getContextId(); Boolean myStateInContext = myContextStates.get(context); if (myStateInContext != null && differsFromDefault(defaultContext, context, myStateInContext)) { result.put(contextType, myStateInContext); } } } } return result; }
Example 5
Source File: EnvironmentVariablesData.java From consulo with Apache License 2.0 | 6 votes |
@Nonnull public static EnvironmentVariablesData readExternal(@Nonnull Element element) { Element envsElement = element.getChild(ENVS); if (envsElement == null) { return DEFAULT; } Map<String, String> envs = ImmutableMap.of(); String passParentEnvsStr = envsElement.getAttributeValue(PASS_PARENT_ENVS); boolean passParentEnvs = passParentEnvsStr == null || Boolean.parseBoolean(passParentEnvsStr); for (Element envElement : envsElement.getChildren(ENV)) { String envName = envElement.getAttributeValue(NAME); String envValue = envElement.getAttributeValue(VALUE); if (envName != null && envValue != null) { if (envs.isEmpty()) { envs = ContainerUtil.newLinkedHashMap(); } envs.put(envName, envValue); } } return create(envs, passParentEnvs); }
Example 6
Source File: CodeStyleSettingPresentation.java From consulo with Apache License 2.0 | 6 votes |
/** * Returns an immutable map containing all standard settings in a mapping of type (group -> settings contained in the group). * Notice that lists containing settings for a specific group are also immutable. Use copies to make modifications. * * @param settingsType type to get standard settings for * @return mapping setting groups to contained setting presentations */ @Nonnull public static Map<SettingsGroup, List<CodeStyleSettingPresentation>> getStandardSettings(LanguageCodeStyleSettingsProvider.SettingsType settingsType) { switch (settingsType) { case BLANK_LINES_SETTINGS: return BLANK_LINES_STANDARD_SETTINGS; case SPACING_SETTINGS: return SPACING_STANDARD_SETTINGS; case WRAPPING_AND_BRACES_SETTINGS: return WRAPPING_AND_BRACES_STANDARD_SETTINGS; case INDENT_SETTINGS: return INDENT_STANDARD_SETTINGS; case LANGUAGE_SPECIFIC: } return ContainerUtil.newLinkedHashMap(); }
Example 7
Source File: PushController.java From consulo with Apache License 2.0 | 5 votes |
@Nonnull public Map<PushSupport, VcsPushOptionsPanel> createAdditionalPanels() { Map<PushSupport, VcsPushOptionsPanel> result = ContainerUtil.newLinkedHashMap(); for (PushSupport support : myPushSupports) { ContainerUtil.putIfNotNull(support, support.createOptionsPanel(), result); } return result; }
Example 8
Source File: VcsLocaleHelper.java From consulo with Apache License 2.0 | 5 votes |
@Nonnull public static Map<String, String> getDefaultLocaleEnvironmentVars(@Nonnull String prefix) { Map<String, String> envMap = ContainerUtil.newLinkedHashMap(); String defaultLocale = getDefaultLocaleFromRegistry(prefix); if (defaultLocale.isEmpty()) { // let skip locale definition if needed return envMap; } envMap.put("LANGUAGE", ""); envMap.put("LC_ALL", defaultLocale); return envMap; }
Example 9
Source File: OccurrencesChooser.java From consulo with Apache License 2.0 | 5 votes |
public void showChooser(final T selectedOccurrence, final List<T> allOccurrences, final Pass<ReplaceChoice> callback) { if (allOccurrences.size() == 1) { callback.pass(ReplaceChoice.ALL); } else { Map<ReplaceChoice, List<T>> occurrencesMap = ContainerUtil.newLinkedHashMap(); occurrencesMap.put(ReplaceChoice.NO, Collections.singletonList(selectedOccurrence)); occurrencesMap.put(ReplaceChoice.ALL, allOccurrences); showChooser(callback, occurrencesMap); } }