private void writeAttributes(Element attrElements) throws WriteExternalException { List<TextAttributesKey> list = new ArrayList<TextAttributesKey>(myAttributesMap.keySet()); Collections.sort(list); for (TextAttributesKey key : list) { TextAttributes defaultAttr = myParentScheme != null ? myParentScheme.getAttributes(key) : new TextAttributes(); TextAttributesKey baseKey = key.getFallbackAttributeKey(); TextAttributes defaultFallbackAttr = baseKey != null && myParentScheme instanceof AbstractColorsScheme ? ((AbstractColorsScheme) myParentScheme).getFallbackAttributes(baseKey) : null; TextAttributes value = myAttributesMap.get(key); if (!value.equals(defaultAttr) || defaultAttr == defaultFallbackAttr) { Element element = new Element(OPTION_ELEMENT); element.setAttribute(NAME_ATTR, key.getExternalName()); if (baseKey == null || !value.isFallbackEnabled()) { Element valueElement = new Element(VALUE_ELEMENT); value.writeExternal(valueElement); element.addContent(valueElement); attrElements.addContent(element); } else if (defaultAttr != defaultFallbackAttr) { element.setAttribute(BASE_ATTRIBUTES_ATTR, baseKey.getExternalName()); attrElements.addContent(element); } } } }
public static Map<String, TextAttributesKey> createRainbowHLM() { Map<String, TextAttributesKey> hashMap = new HashMap<>(); hashMap.put(RAINBOW_ANCHOR.getExternalName(), RAINBOW_ANCHOR); hashMap.put(RAINBOW_GRADIENT_DEMO.getExternalName(), RAINBOW_GRADIENT_DEMO); for (TextAttributesKey key : RAINBOW_TEMP_KEYS) { hashMap.put(key.getExternalName(), key); } return hashMap; }
private SchemeTextAttributesDescription( String name, String group, @NotNull TextAttributesKey key, @NotNull MyColorScheme scheme, Icon icon, String toolTip) { super(name, group, getInitialAttributes(scheme, key).clone(), key, scheme, icon, toolTip); this.key = key; myAttributesToApply = getInitialAttributes(scheme, key); TextAttributesKey fallbackKey = key.getFallbackAttributeKey(); if (fallbackKey != null) { myFallbackAttributes = scheme.getAttributes(fallbackKey); myBaseAttributeDescriptor = ColorSettingsPages.getInstance().getAttributeDescriptor(fallbackKey); if (myBaseAttributeDescriptor == null) { myBaseAttributeDescriptor = new Pair<ColorSettingsPage, AttributesDescriptor>( null, new AttributesDescriptor(fallbackKey.getExternalName(), fallbackKey)); } } myIsInheritedInitial = isInherited(scheme); setInherited(myIsInheritedInitial); initCheckedStatus(); }
private void migrateErrorStripeColorFrom14( @NotNull TextAttributesKey name, @NotNull TextAttributes attr) { if (myVersion >= 141 || myParentScheme == null) return; Couple<Color> m = DEFAULT_STRIPE_COLORS.get(name.getExternalName()); if (m != null && Comparing.equal(m.first, attr.getErrorStripeColor())) { attr.setErrorStripeColor(m.second); } }
@NotNull public static String generatePaletteExample() { int stopCount = RAINBOW_COLOR_KEYS.length; StringBuilder sb = new StringBuilder(); String tagRainbow = RAINBOW_GRADIENT_DEMO.getExternalName(); for (int i = 0; i < RAINBOW_TEMP_KEYS.length; ++i) { if (sb.length() != 0) { sb.append(" "); } sb.append("<").append(tagRainbow).append(">"); sb.append((i % stopCount == 0) ? "Stop#" + String.valueOf(i / stopCount + 1) : "T"); sb.append("</").append(tagRainbow).append(">"); } return sb.toString(); }
public static boolean isRainbowTempKey(TextAttributesKey key) { return key.getExternalName().startsWith(RAINBOW_TEMP_PREF); }