Java 类com.intellij.util.ColorSampleLookupValue 实例源码

项目:consulo-javafx    文件:JavaFxAnnotator.java   
private static void attachColorIcon(final PsiElement element, AnnotationHolder holder, String attributeValueText) {
  try {
    Color color = null;
    if (attributeValueText.startsWith("#")) {
      color = ColorUtil.fromHex(attributeValueText.substring(1));
    } else {
      final String hexCode = ColorSampleLookupValue.getHexCodeForColorName(StringUtil.toLowerCase(attributeValueText));
      if (hexCode != null) {
        color = ColorUtil.fromHex(hexCode);
      }
    }
    if (color != null) {
      final ColorIcon icon = new ColorIcon(8, color);
      final Annotation annotation = holder.createInfoAnnotation(element, null);
      annotation.setGutterIconRenderer(new ColorIconRenderer(icon, element));
    }
  }
  catch (Exception ignored) {
  }
}
项目:consulo-javafx    文件:JavaFxColorReference.java   
@NotNull
@Override
public Object[] getVariants() {
  final ColorSampleLookupValue[] lookupValues = ColorSampleLookupValue.getColors();
  final Object[] vars = new Object[lookupValues.length + 1];
  for (int i = 0; i < lookupValues.length; i++) {
    final ColorSampleLookupValue value = lookupValues[i];
    vars[i] = new ColorSampleLookupValue(value.getName(), value.getValue(), true);
  }
  vars[lookupValues.length] = new UserColorLookup();
  return vars;
}
项目:consulo-xml    文件:HtmlDocumentationProvider.java   
public static void addColorPreviewAndCodeToLookup(final PsiElement currentElement, final StringBuilder buf) {
  final Color colorFromElement = UserColorLookup.getColorFromElement(currentElement);

  if (colorFromElement != null) {
    ColorSampleLookupValue.addColorPreviewAndCodeToLookup(colorFromElement, buf);
  }
}
项目:consulo-xml    文件:UserColorLookup.java   
@Nullable
public static Color getColorFromElement(final PsiElement element) {
  if (!(element instanceof XmlToken)) return null;

  return ColorSampleLookupValue.getColor(element.getText());
}