1 11 package org.eclipse.ui.views.properties; 12 13 import org.eclipse.core.runtime.Assert; 14 import org.eclipse.jface.viewers.CellEditor; 15 import org.eclipse.jface.viewers.ICellEditorValidator; 16 import org.eclipse.jface.viewers.ILabelProvider; 17 import org.eclipse.jface.viewers.LabelProvider; 18 import org.eclipse.swt.widgets.Composite; 19 20 49 public class PropertyDescriptor implements IPropertyDescriptor { 50 51 54 private Object id; 55 56 59 private String display; 60 61 64 private String category = null; 65 66 69 private String description = null; 70 71 74 private Object helpIds; 75 76 79 private String [] filterFlags; 80 81 85 private ILabelProvider labelProvider = null; 86 87 91 private ICellEditorValidator validator; 92 93 97 private boolean incompatible = false; 98 99 102 public PropertyDescriptor(Object id, String displayName) { 103 Assert.isNotNull(id); 104 Assert.isNotNull(displayName); 105 this.id = id; 106 this.display = displayName; 107 } 108 109 116 public CellEditor createPropertyEditor(Composite parent) { 117 return null; 118 } 119 120 128 protected boolean getAlwaysIncompatible() { 129 return incompatible; 130 } 131 132 140 public String getCategory() { 141 return category; 142 } 143 144 152 public String getDescription() { 153 return description; 154 } 155 156 161 public String getDisplayName() { 162 return display; 163 } 164 165 174 public String [] getFilterFlags() { 175 return filterFlags; 176 } 177 178 186 public Object getHelpContextIds() { 187 return helpIds; 188 } 189 190 195 public Object getId() { 196 return id; 197 } 198 199 207 public ILabelProvider getLabelProvider() { 208 if (labelProvider != null) { 209 return labelProvider; 210 } else { 211 return new LabelProvider(); 212 } 213 } 214 215 221 protected ICellEditorValidator getValidator() { 222 return validator; 223 } 224 225 231 public boolean isLabelProviderSet() { 232 return labelProvider != null; 233 } 234 235 241 public boolean isCompatibleWith(IPropertyDescriptor anotherProperty) { 242 if (getAlwaysIncompatible()) { 243 return false; 244 } 245 246 Object id1 = getId(); 248 Object id2 = anotherProperty.getId(); 249 if (!id1.equals(id2)) { 250 return false; 251 } 252 253 if (getCategory() == null) { 255 if (anotherProperty.getCategory() != null) { 256 return false; 257 } 258 } else { 259 if (!getCategory().equals(anotherProperty.getCategory())) { 260 return false; 261 } 262 } 263 264 return true; 265 } 266 267 275 public void setAlwaysIncompatible(boolean flag) { 276 incompatible = flag; 277 } 278 279 285 public void setCategory(String category) { 286 this.category = category; 287 } 288 289 297 public void setDescription(String description) { 298 this.description = description; 299 } 300 301 313 public void setFilterFlags(String value[]) { 314 filterFlags = value; 315 } 316 317 333 public void setHelpContextIds(Object contextIds) { 334 helpIds = contextIds; 335 } 336 337 348 public void setLabelProvider(ILabelProvider provider) { 349 labelProvider = provider; 350 } 351 352 362 public void setValidator(ICellEditorValidator validator) { 363 this.validator = validator; 364 } 365 } 366 | Popular Tags |