1 11 package org.eclipse.ui.internal.themes; 12 13 import org.eclipse.swt.graphics.RGB; 14 import org.eclipse.ui.IPluginContribution; 15 import org.eclipse.ui.themes.ColorUtil; 16 17 23 public class ColorDefinition implements IPluginContribution, 24 IHierarchalThemeElementDefinition, ICategorizedThemeElementDefinition, 25 IEditable { 26 private String defaultsTo; 27 28 private String description; 29 30 private String id; 31 32 private String label; 33 34 private String pluginId; 35 36 private String rawValue; 37 38 private String categoryId; 39 40 boolean isEditable; 41 42 private RGB parsedValue; 43 44 57 public ColorDefinition(String label, String id, String defaultsTo, 58 String value, String categoryId, boolean isEditable, 59 String description, String pluginId) { 60 61 this.label = label; 62 this.id = id; 63 this.defaultsTo = defaultsTo; 64 this.rawValue = value; 65 this.categoryId = categoryId; 66 this.description = description; 67 this.isEditable = isEditable; 68 this.pluginId = pluginId; 69 } 70 71 79 public ColorDefinition(ColorDefinition original, RGB value) { 80 81 this.label = original.getName(); 82 this.id = original.getId(); 83 this.categoryId = original.getCategoryId(); 84 this.description = original.getDescription(); 85 this.isEditable = original.isEditable(); 86 this.pluginId = original.getPluginId(); 87 88 this.parsedValue = value; 89 } 90 91 94 public String getCategoryId() { 95 return categoryId; 96 } 97 98 101 public String getDefaultsTo() { 102 return defaultsTo; 103 } 104 105 108 public String getDescription() { 109 return description; 110 } 111 112 115 public String getId() { 116 return id; 117 } 118 119 122 public String getName() { 123 return label; 124 } 125 126 129 public String getLocalId() { 130 return getId(); 131 } 132 133 136 public String getPluginId() { 137 return pluginId; 138 } 139 140 144 public RGB getValue() { 145 if (parsedValue == null) { 146 parsedValue = ColorUtil.getColorValue(rawValue); 147 } 148 return parsedValue; 149 } 150 151 154 public String toString() { 155 return getId(); 156 } 157 158 161 public boolean isEditable() { 162 return isEditable; 163 } 164 165 168 public boolean equals(Object obj) { 169 if (obj instanceof ColorDefinition) { 170 return getId().equals(((ColorDefinition)obj).getId()); 171 } 172 return false; 173 } 174 175 178 public int hashCode() { 179 return id.hashCode(); 180 } 181 } 182 | Popular Tags |