1 11 package org.eclipse.ui.internal.themes; 12 13 import org.eclipse.jface.resource.JFaceResources; 14 import org.eclipse.jface.resource.StringConverter; 15 import org.eclipse.swt.graphics.FontData; 16 import org.eclipse.ui.internal.Workbench; 17 18 22 public class FontDefinition implements IHierarchalThemeElementDefinition, 23 ICategorizedThemeElementDefinition, IEditable { 24 25 private String label; 26 27 private String id; 28 29 private String defaultsTo; 30 31 private String categoryId; 32 33 private String description; 34 35 private String value; 36 37 private boolean isEditable; 38 39 private FontData[] parsedValue; 40 41 50 public FontDefinition(String fontName, String uniqueId, String defaultsId, 51 String value, String categoryId, boolean isEditable, 52 String fontDescription) { 53 this.label = fontName; 54 this.id = uniqueId; 55 this.defaultsTo = defaultsId; 56 this.value = value; 57 this.categoryId = categoryId; 58 this.description = fontDescription; 59 this.isEditable = isEditable; 60 } 61 62 70 public FontDefinition(FontDefinition originalFont, FontData[] datas) { 71 this.label = originalFont.getName(); 72 this.id = originalFont.getId(); 73 this.categoryId = originalFont.getCategoryId(); 74 this.description = originalFont.getDescription(); 75 this.isEditable = originalFont.isEditable(); 76 this.parsedValue = datas; 77 } 78 79 84 public String getDefaultsTo() { 85 return defaultsTo; 86 } 87 88 92 public String getDescription() { 93 return description; 94 } 95 96 100 public String getName() { 101 return label; 102 } 103 104 108 public String getId() { 109 return id; 110 } 111 112 116 public String getCategoryId() { 117 return categoryId; 118 } 119 120 125 public FontData[] getValue() { 126 if (value == null) { 127 return null; 128 } 129 if (parsedValue == null) { 130 parsedValue = JFaceResources.getFontRegistry().filterData( 131 StringConverter.asFontDataArray(value), 132 Workbench.getInstance().getDisplay()); 133 } 134 135 return parsedValue; 136 } 137 138 141 public boolean isEditable() { 142 return isEditable; 143 } 144 145 148 public boolean equals(Object obj) { 149 if (obj instanceof FontDefinition) { 150 return getId().equals(((FontDefinition)obj).getId()); 151 } 152 return false; 153 } 154 155 158 public int hashCode() { 159 return id.hashCode(); 160 } 161 } 162 | Popular Tags |