1 11 package org.eclipse.ui.internal.themes; 12 13 import java.util.Arrays ; 14 import java.util.Comparator ; 15 import java.util.Map ; 16 import java.util.Set ; 17 18 23 public interface IThemeRegistry { 24 25 31 public static class HierarchyComparator implements Comparator { 32 33 private IHierarchalThemeElementDefinition[] definitions; 34 35 40 public HierarchyComparator( 41 IHierarchalThemeElementDefinition[] definitions) { 42 this.definitions = definitions; 43 } 44 45 48 public int compare(Object arg0, Object arg1) { 49 String def0 = arg0 == null ? null 50 : ((IHierarchalThemeElementDefinition) arg0) 51 .getDefaultsTo(); 52 String def1 = arg1 == null ? null 53 : ((IHierarchalThemeElementDefinition) arg1) 54 .getDefaultsTo(); 55 56 if (def0 == null && def1 == null) { 57 return 0; 58 } 59 60 if (def0 == null) { 61 return -1; 62 } 63 64 if (def1 == null) { 65 return 1; 66 } 67 68 return compare(getDefaultsTo(def0), getDefaultsTo(def1)); 69 } 70 71 76 private IHierarchalThemeElementDefinition getDefaultsTo(String id) { 77 int idx = Arrays.binarySearch(definitions, id, ID_COMPARATOR); 78 if (idx >= 0) { 79 return definitions[idx]; 80 } 81 return null; 82 } 83 } 84 85 93 public static final Comparator ID_COMPARATOR = new Comparator () { 94 95 98 public int compare(Object arg0, Object arg1) { 99 String str0 = getCompareString(arg0); 100 String str1 = getCompareString(arg1); 101 return str0.compareTo(str1); 102 } 103 104 108 private String getCompareString(Object object) { 109 if (object instanceof String ) { 110 return (String ) object; 111 } else if (object instanceof IThemeElementDefinition) { 112 return ((IThemeElementDefinition) object).getId(); 113 } 114 return ""; } 116 }; 117 118 125 public ThemeElementCategory findCategory(String id); 126 127 134 public ColorDefinition findColor(String id); 135 136 143 public FontDefinition findFont(String id); 144 145 152 public IThemeDescriptor findTheme(String id); 153 154 159 public ThemeElementCategory[] getCategories(); 160 161 166 public ColorDefinition[] getColors(); 167 168 175 public ColorDefinition[] getColorsFor(String themeId); 176 177 184 public FontDefinition[] getFontsFor(String themeId); 185 186 191 public FontDefinition[] getFonts(); 192 193 198 public IThemeDescriptor[] getThemes(); 199 200 205 public Map getData(); 206 207 213 public Set getPresentationsBindingsFor(ThemeElementCategory category); 214 } 215 | Popular Tags |