private static void addEditorSettingDescription(ArrayList<EditorSchemeAttributeDescriptor> array, String name, String group, ColorKey backgroundKey, ColorKey foregroundKey, EditorColorsScheme scheme) { String type = null; if (foregroundKey != null) { type = foregroundKey.getExternalName(); } else { if (backgroundKey != null) { type = backgroundKey.getExternalName(); } } ColorAndFontDescription descr = new EditorSettingColorDescription(name, group, backgroundKey, foregroundKey, type, scheme); array.add(descr); }
@Nonnull List<Integer> getAnchorIndexes(@Nullable EditorColorsScheme scheme) { if (scheme == null) scheme = EditorColorsManager.getInstance().getGlobalScheme(); List<Integer> result = new ArrayList<>(ANCHORS_COUNT); int count = 0; for (ColorKey key : ANCHOR_COLOR_KEYS) { if (scheme.getColor(key) != null) { result.add(count); count += COLORS_BETWEEN_ANCHORS + 1; } else { result.add(null); } } return result; }
@NotNull public static ColorKey[] getColorKeys() { final int levelCount = XmlEditorOptions.getInstance().getTagTreeHighlightingLevelCount(); if(ourColorKeys == null || ourColorKeys.length != levelCount) { ourColorKeys = new ColorKey[levelCount]; for(int i = 0; i < ourColorKeys.length; i++) { ourColorKeys[i] = ColorKey.createColorKey("HTML_TAG_TREE_LEVEL" + i, DEFAULT_COLORS[i % DEFAULT_COLORS.length]); } } return ourColorKeys; }
@Nullable @Override public Color getColor(ColorKey key) { if (key == null) return null; Color color = myColorsMap.get(key); return color != null ? color : key.getDefaultColor(); }
@Nullable @Override public Color getColor(ColorKey key) { if (myColorsMap.containsKey(key)) { return myColorsMap.get(key); } else { return myParentScheme.getColor(key); } }
@Override public Color getColor() { while (!myKeys.isEmpty()) { ColorKey key = myKeys.get(myKeys.size() - 1); Color result = myScheme.getColor(key); if (result == null || result.equals(myScheme.getDefaultForeground())) { myKeys.remove(myKeys.size() - 1); } else { return result; } } return myScheme.getDefaultForeground(); }
@Nullable private static String calcType(@Nullable ColorKey backgroundKey, @Nullable ColorKey foregroundKey) { if (foregroundKey != null) { return foregroundKey.getExternalName(); } else if (backgroundKey != null) { return backgroundKey.getExternalName(); } return null; }
private static void addEditorSettingDescription(@NotNull List<EditorSchemeAttributeDescriptor> list, String name, String group, @Nullable ColorKey backgroundKey, @Nullable ColorKey foregroundKey, @NotNull EditorColorsScheme scheme) { list.add(new EditorSettingColorDescription(name, group, backgroundKey, foregroundKey, calcType(backgroundKey, foregroundKey), scheme)); }
private EditorSettingColorDescription(String name, String group, ColorKey backgroundKey, ColorKey foregroundKey, String type, EditorColorsScheme scheme) { super(name, group, type, scheme, null, null); if (backgroundKey != null) { myGetSetBackground = new GetSetColor(backgroundKey, scheme); } if (foregroundKey != null) { myGetSetForeground = new GetSetColor(foregroundKey, scheme); } initCheckedStatus(); }
@NotNull public static ColorKey[] getColorKeys() { final int levelCount = WebEditorOptions.getInstance().getTagTreeHighlightingLevelCount(); if (ourColorKeys == null || ourColorKeys.length != levelCount) { ourColorKeys = new ColorKey[levelCount]; for (int i = 0; i < ourColorKeys.length; i++) { ourColorKeys[i] = ColorKey.createColorKey("HTML_TAG_TREE_LEVEL" + i, DEFAULT_COLORS[i % DEFAULT_COLORS.length]); } } return ourColorKeys; }
static Color[] getBaseColors() { final ColorKey[] colorKeys = XmlTagTreeHighlightingColors.getColorKeys(); final Color[] colors = new Color[colorKeys.length]; final EditorColorsScheme colorsScheme = EditorColorsManager.getInstance().getGlobalScheme(); for (int i = 0; i < colors.length; i++) { colors[i] = colorsScheme.getColor(colorKeys[i]); } return colors; }
@Override @NotNull public ColorDescriptor[] getColorDescriptors() { // todo: make preview for it final ColorKey[] colorKeys = XmlTagTreeHighlightingColors.getColorKeys(); final ColorDescriptor[] colorDescriptors = new ColorDescriptor[colorKeys.length]; for (int i = 0; i < colorDescriptors.length; i++) { colorDescriptors[i] = new ColorDescriptor(OptionsBundle.message("options.html.attribute.descriptor.tag.tree", i + 1), colorKeys[i], ColorDescriptor.Kind.BACKGROUND); } return colorDescriptors; }
public static Color get(final FileStatus status) { final EditorColorsScheme globalScheme = EditorColorsManager.getInstance().getGlobalScheme(); final ColorKey colorKey = MTFileColors.fileStatusColorKeyHashMap.get(status); if (colorKey != null) { return globalScheme.getColor(colorKey); } return globalScheme.getDefaultForeground(); }
@Override public Color getColor(ColorKey key) { if (myColorsMap.containsKey(key)) { return myColorsMap.get(key); } else { return myParentScheme.getColor(key); } }
@NotNull public ColorDescriptor[] getColorDescriptors() { // todo: make preview for it final ColorKey[] colorKeys = XmlTagTreeHighlightingColors.getColorKeys(); final ColorDescriptor[] colorDescriptors = new ColorDescriptor[colorKeys.length]; for (int i = 0; i < colorDescriptors.length; i++) { colorDescriptors[i] = new ColorDescriptor(OptionsBundle.message("options.html.attribute.descriptor.tag.tree", i + 1), colorKeys[i], ColorDescriptor.Kind.BACKGROUND); } return colorDescriptors; }
@Nonnull private static List<ColorKey> createColorKeys(int count) { List<ColorKey> keys = new ArrayList<>(); for (int i = 0; i < count; i++) { keys.add(ColorKey.createColorKey("VCS_ANNOTATIONS_COLOR_" + (i + 1))); } return keys; }
@Nonnull public List<Color> getOrderedColors(@Nullable EditorColorsScheme scheme) { if (scheme == null) scheme = EditorColorsManager.getInstance().getGlobalScheme(); List<Color> anchorColors = new ArrayList<>(); for (ColorKey key : ANCHOR_COLOR_KEYS) { ContainerUtil.addIfNotNull(anchorColors, scheme.getColor(key)); } return ColorGenerator.generateLinearColorSequence(anchorColors, COLORS_BETWEEN_ANCHORS); }
private static void addEditorSettingDescription(@Nonnull List<EditorSchemeAttributeDescriptor> list, String name, String group, @Nullable ColorKey backgroundKey, @Nullable ColorKey foregroundKey, @Nonnull EditorColorsScheme scheme) { list.add(new EditorSettingColorDescription(name, group, backgroundKey, foregroundKey, calcType(backgroundKey, foregroundKey), scheme)); }
@Override public void setColor(ColorKey key, Color color) { }
@Override public void setColor(ColorKey key, Color color) { if (!Comparing.equal(color, getColor(key))) { myColorsMap.put(key, color); } }
@NotNull ColorKey getColorKey();
public synchronized FileStatus createFileStatus(@NonNls @NotNull String id, @NotNull String description, Color color) { FileStatusImpl result = new FileStatusImpl(id, ColorKey.createColorKey("FILESTATUS_" + id, color), description); myStatuses.add(result); return result; }
public synchronized FileStatus createOnlyColorForFileStatus(@NonNls @NotNull String id, final Color color) { FileStatus result = new FileStatusImpl.OnlyColorFileStatus(id, ColorKey.createColorKey("FILESTATUS_" + id, color), null); myStatuses.add(result); return result; }
public FileStatusImpl(@NotNull String status, @NotNull ColorKey key, String text) { myStatus = status; myColorKey = key; myText = text; }
@NotNull @Override public ColorKey getColorKey() { return myColorKey; }
public OnlyColorFileStatus(@NotNull String status, @NotNull ColorKey key, String text) { super(status, key, text); }
@Nullable ColorKey getColor(int line, Editor editor);
@NotNull @Override public ColorKey getColorKey() { throw new AssertionError("Should not be called"); }
ColorSchemeBasedHolder(EditorColorsScheme scheme, ColorKey ... keys) { myScheme = scheme; myKeys.addAll(Arrays.asList(keys)); Collections.reverse(myKeys); // Reverse collection in order to reduce removal cost }
@Override public Color getOutlineColor(boolean isActive) { ColorKey key = isActive ? EditorColors.SELECTED_TEARLINE_COLOR : EditorColors.TEARLINE_COLOR; Color color = myEditor.getColorsScheme().getColor(key); return color != null ? color : JBColor.black; }