1 11 package org.eclipse.jdt.internal.ui.javaeditor; 12 13 import org.eclipse.swt.graphics.RGB; 14 15 import org.eclipse.jface.resource.ColorRegistry; 16 17 import org.eclipse.ui.PlatformUI; 18 19 import org.eclipse.jdt.ui.JavaUI; 20 21 22 25 public abstract class SemanticHighlighting { 26 27 30 public abstract String getPreferenceKey(); 31 32 36 public abstract RGB getDefaultDefaultTextColor(); 37 38 41 public RGB getDefaultTextColor() { 42 return findRGB(getThemeColorKey(), getDefaultDefaultTextColor()); 43 } 44 45 48 public abstract boolean isBoldByDefault(); 49 50 53 public abstract boolean isItalicByDefault(); 54 55 59 public boolean isStrikethroughByDefault() { 60 return false; 61 } 62 63 67 public boolean isUnderlineByDefault() { 68 return false; 69 } 70 71 74 public abstract boolean isEnabledByDefault(); 75 76 79 public abstract String getDisplayName(); 80 81 91 public abstract boolean consumes(SemanticToken token); 92 93 107 public boolean consumesLiteral(SemanticToken token) { 108 return false; 109 } 110 111 private String getThemeColorKey() { 112 return JavaUI.ID_PLUGIN + "." + getPreferenceKey() + "Highlighting"; } 114 115 123 private static RGB findRGB(String key, RGB defaultRGB) { 124 if (!PlatformUI.isWorkbenchRunning()) 125 return defaultRGB; 126 127 ColorRegistry registry= PlatformUI.getWorkbench().getThemeManager().getCurrentTheme().getColorRegistry(); 128 RGB rgb= registry.getRGB(key); 129 if (rgb != null) 130 return rgb; 131 return defaultRGB; 132 } 133 134 } 135 | Popular Tags |