1 8 package com.nightlabs.editor2d.model; 9 10 import java.awt.Color ; 11 import java.util.List ; 12 13 import org.eclipse.ui.views.properties.PropertyDescriptor; 14 15 import com.nightlabs.editor2d.EditorPlugin; 16 import com.nightlabs.editor2d.ShapeDrawComponent; 17 import com.nightlabs.editor2d.properties.AWTColorPropertyDescriptor; 18 import com.nightlabs.editor2d.properties.CheckboxPropertyDescriptor; 19 import com.nightlabs.editor2d.properties.IntPropertyDescriptor; 20 21 22 public class ShapeDrawComponentPropertySource 23 extends DrawComponentPropertySource 24 { 25 public static final String CATEGORY_COLORS = EditorPlugin.getResourceString("property.category.color"); 26 public static final String CATEGORY_LINE = EditorPlugin.getResourceString("property.category.line"); 27 28 31 public ShapeDrawComponentPropertySource(ShapeDrawComponent element) 32 { 33 super(element); 34 } 35 36 protected List createPropertyDescriptors() 37 { 38 List descriptors = super.createPropertyDescriptors(); 39 40 PropertyDescriptor desc = new AWTColorPropertyDescriptor(ShapeDrawComponent.PROP_LINE_COLOR, 42 EditorPlugin.getResourceString("property.linecolor.label")); 43 desc.setCategory(CATEGORY_COLORS); 44 descriptors.add(desc); 45 46 desc = new AWTColorPropertyDescriptor(ShapeDrawComponent.PROP_FILL_COLOR, 48 EditorPlugin.getResourceString("property.fillcolor.label")); 49 desc.setCategory(CATEGORY_COLORS); 50 descriptors.add(desc); 51 52 desc = new IntPropertyDescriptor(ShapeDrawComponent.PROP_LINE_WIDTH, 54 EditorPlugin.getResourceString("property.linewidth.label")); 55 desc.setCategory(CATEGORY_LINE); 56 descriptors.add(desc); 57 58 desc = new IntPropertyDescriptor(ShapeDrawComponent.PROP_LINE_STYLE, 60 EditorPlugin.getResourceString("property.linestyle.label")); 61 desc.setCategory(CATEGORY_LINE); 62 descriptors.add(desc); 63 64 desc = new CheckboxPropertyDescriptor(ShapeDrawComponent.PROP_FILL, 66 EditorPlugin.getResourceString("property.fill.label")); 67 descriptors.add(desc); 68 69 return descriptors; 70 } 71 72 75 114 117 public Object getPropertyValue(Object id) 118 { 119 Object o = super.getPropertyValue(id); 120 if (o != null) 121 return o; 122 else 123 { 124 if (id.equals(ShapeDrawComponent.PROP_FILL_COLOR)) { 125 return getShapeDrawComponent().getFillColor(); 126 } 127 else if (id.equals(ShapeDrawComponent.PROP_LINE_COLOR)) { 128 return getShapeDrawComponent().getLineColor(); 129 } 130 else if (id.equals(ShapeDrawComponent.PROP_LINE_WIDTH)) { 131 return new Integer (getShapeDrawComponent().getLineWidth()); 132 } 133 else if (id.equals(ShapeDrawComponent.PROP_LINE_STYLE)) { 134 return new Integer (getShapeDrawComponent().getLineStyle()); 135 } 136 else if (id.equals(ShapeDrawComponent.PROP_FILL)) { 137 return new Boolean (getShapeDrawComponent().isFill()); 138 } 139 140 return null; 141 } 142 } 143 144 147 public void setPropertyValue(Object id, Object value) 148 { 149 super.setPropertyValue(id, value); 150 151 if (id.equals(ShapeDrawComponent.PROP_FILL_COLOR)) { 152 getShapeDrawComponent().setFillColor((Color )value); 153 } 154 else if (id.equals(ShapeDrawComponent.PROP_LINE_COLOR)) { 155 getShapeDrawComponent().setLineColor((Color )value); 156 } 157 else if (id.equals(ShapeDrawComponent.PROP_LINE_WIDTH)) { 158 getShapeDrawComponent().setLineWidth(((Integer )value).intValue()); 159 } 160 else if (id.equals(ShapeDrawComponent.PROP_LINE_STYLE)) { 161 getShapeDrawComponent().setLineStyle(((Integer )value).intValue()); 162 } 163 else if (id.equals(ShapeDrawComponent.PROP_FILL)) { 164 getShapeDrawComponent().setFill(((Boolean )value).booleanValue()); 165 } 166 } 167 168 protected ShapeDrawComponent getShapeDrawComponent() { 169 return (ShapeDrawComponent) drawComponent; 170 } 171 } 172
| Popular Tags
|