private static void initScopesDescriptors( @NotNull List<EditorSchemeAttributeDescriptor> descriptions, @NotNull MyColorScheme scheme) { Set<Pair<NamedScope, NamedScopesHolder>> namedScopes = new THashSet<Pair<NamedScope, NamedScopesHolder>>( new TObjectHashingStrategy<Pair<NamedScope, NamedScopesHolder>>() { @Override public int computeHashCode( @NotNull final Pair<NamedScope, NamedScopesHolder> object) { return object.getFirst().getName().hashCode(); } @Override public boolean equals( @NotNull final Pair<NamedScope, NamedScopesHolder> o1, @NotNull final Pair<NamedScope, NamedScopesHolder> o2) { return o1.getFirst().getName().equals(o2.getFirst().getName()); } }); Project[] projects = ProjectManager.getInstance().getOpenProjects(); for (Project project : projects) { DependencyValidationManagerImpl validationManager = (DependencyValidationManagerImpl) DependencyValidationManager.getInstance(project); List<Pair<NamedScope, NamedScopesHolder>> cachedScopes = validationManager.getScopeBasedHighlightingCachedScopes(); namedScopes.addAll(cachedScopes); } List<Pair<NamedScope, NamedScopesHolder>> list = new ArrayList<Pair<NamedScope, NamedScopesHolder>>(namedScopes); Collections.sort( list, new Comparator<Pair<NamedScope, NamedScopesHolder>>() { @Override public int compare( @NotNull final Pair<NamedScope, NamedScopesHolder> o1, @NotNull final Pair<NamedScope, NamedScopesHolder> o2) { return o1.getFirst().getName().compareToIgnoreCase(o2.getFirst().getName()); } }); for (Pair<NamedScope, NamedScopesHolder> pair : list) { NamedScope namedScope = pair.getFirst(); String name = namedScope.getName(); TextAttributesKey textAttributesKey = ScopeAttributesUtil.getScopeTextAttributeKey(name); if (scheme.getAttributes(textAttributesKey) == null) { scheme.setAttributes(textAttributesKey, new TextAttributes()); } NamedScopesHolder holder = pair.getSecond(); PackageSet value = namedScope.getValue(); String toolTip = holder.getDisplayName() + (value == null ? "" : ": " + value.getText()); addSchemedDescription( descriptions, name, SCOPES_GROUP, textAttributesKey, scheme, holder.getIcon(), toolTip); } }
@NotNull public String[] getSchemeNames() { List<MyColorScheme> schemes = new ArrayList<MyColorScheme>(mySchemes.values()); Collections.sort( schemes, new Comparator<MyColorScheme>() { @Override public int compare(@NotNull MyColorScheme o1, @NotNull MyColorScheme o2) { if (isReadOnly(o1) && !isReadOnly(o2)) return -1; if (!isReadOnly(o1) && isReadOnly(o2)) return 1; return o1.getName().compareToIgnoreCase(o2.getName()); } }); List<String> names = new ArrayList<String>(schemes.size()); for (MyColorScheme scheme : schemes) { names.add(scheme.getName()); } return ArrayUtil.toStringArray(names); }
protected List<ColorAndFontPanelFactory> createPanelFactories() { List<ColorAndFontPanelFactory> result = new ArrayList<ColorAndFontPanelFactory>(); result.add(new FontConfigurableFactory()); List<ColorAndFontPanelFactory> extensions = new ArrayList<ColorAndFontPanelFactory>(); extensions.add(new ConsoleFontConfigurableFactory()); ColorSettingsPage[] pages = ColorSettingsPages.getInstance().getRegisteredPages(); for (final ColorSettingsPage page : pages) { extensions.add( new ColorAndFontPanelFactoryEx() { @Override @NotNull public NewColorAndFontPanel createPanel(@NotNull ColorAndFontOptions options) { final SimpleEditorPreview preview = new SimpleEditorPreview(options, page); return NewColorAndFontPanel.create( preview, page.getDisplayName(), options, null, page); } @Override @NotNull public String getPanelDisplayName() { return page.getDisplayName(); } @Override public DisplayPriority getPriority() { if (page instanceof DisplayPrioritySortable) { return ((DisplayPrioritySortable) page).getPriority(); } return DisplayPriority.LANGUAGE_SETTINGS; } }); } Collections.addAll(extensions, Extensions.getExtensions(ColorAndFontPanelFactory.EP_NAME)); Collections.sort( extensions, new Comparator<ColorAndFontPanelFactory>() { @Override public int compare(ColorAndFontPanelFactory f1, ColorAndFontPanelFactory f2) { if (f1 instanceof DisplayPrioritySortable) { if (f2 instanceof DisplayPrioritySortable) { int result = ((DisplayPrioritySortable) f1) .getPriority() .compareTo(((DisplayPrioritySortable) f2).getPriority()); if (result != 0) return result; } else { return 1; } } else if (f2 instanceof DisplayPrioritySortable) { return -1; } return f1.getPanelDisplayName().compareToIgnoreCase(f2.getPanelDisplayName()); } }); result.addAll(extensions); result.add(new DiffColorsPageFactory()); result.add(new FileStatusColorsPageFactory()); result.add(new ScopeColorsPageFactory()); return result; }