1 27 28 package org.nightlabs.editor2d.model; 29 30 import java.awt.Color ; 31 import java.util.List ; 32 33 import org.eclipse.ui.views.properties.PropertyDescriptor; 34 35 import org.nightlabs.base.property.AWTColorPropertyDescriptor; 36 import org.nightlabs.base.property.CheckboxPropertyDescriptor; 37 import org.nightlabs.base.property.IntPropertyDescriptor; 38 import org.nightlabs.editor2d.EditorPlugin; 39 import org.nightlabs.editor2d.ShapeDrawComponent; 40 41 42 public class ShapeDrawComponentPropertySource 43 extends DrawComponentPropertySource 44 { 45 public static final String CATEGORY_COLORS = EditorPlugin.getResourceString("property.category.color"); 46 public static final String CATEGORY_LINE = EditorPlugin.getResourceString("property.category.line"); 47 48 51 public ShapeDrawComponentPropertySource(ShapeDrawComponent element) 52 { 53 super(element); 54 } 55 56 protected List createPropertyDescriptors() 57 { 58 List descriptors = super.createPropertyDescriptors(); 59 60 PropertyDescriptor desc = new AWTColorPropertyDescriptor(ShapeDrawComponent.PROP_LINE_COLOR, 62 EditorPlugin.getResourceString("property.linecolor.label")); 63 desc.setCategory(CATEGORY_COLORS); 64 descriptors.add(desc); 65 66 desc = new AWTColorPropertyDescriptor(ShapeDrawComponent.PROP_FILL_COLOR, 68 EditorPlugin.getResourceString("property.fillcolor.label")); 69 desc.setCategory(CATEGORY_COLORS); 70 descriptors.add(desc); 71 72 desc = new IntPropertyDescriptor(ShapeDrawComponent.PROP_LINE_WIDTH, 74 EditorPlugin.getResourceString("property.linewidth.label")); 75 desc.setCategory(CATEGORY_LINE); 76 descriptors.add(desc); 77 78 desc = new IntPropertyDescriptor(ShapeDrawComponent.PROP_LINE_STYLE, 80 EditorPlugin.getResourceString("property.linestyle.label")); 81 desc.setCategory(CATEGORY_LINE); 82 descriptors.add(desc); 83 84 desc = new CheckboxPropertyDescriptor(ShapeDrawComponent.PROP_FILL, 86 EditorPlugin.getResourceString("property.fill.label")); 87 descriptors.add(desc); 88 89 return descriptors; 90 } 91 92 95 public Object getPropertyValue(Object id) 96 { 97 Object o = super.getPropertyValue(id); 98 if (o != null) 99 return o; 100 else 101 { 102 if (id.equals(ShapeDrawComponent.PROP_FILL_COLOR)) { 103 return getShapeDrawComponent().getFillColor(); 104 } 105 else if (id.equals(ShapeDrawComponent.PROP_LINE_COLOR)) { 106 return getShapeDrawComponent().getLineColor(); 107 } 108 else if (id.equals(ShapeDrawComponent.PROP_LINE_WIDTH)) { 109 return new Integer (getShapeDrawComponent().getLineWidth()); 110 } 111 else if (id.equals(ShapeDrawComponent.PROP_LINE_STYLE)) { 112 return new Integer (getShapeDrawComponent().getLineStyle()); 113 } 114 else if (id.equals(ShapeDrawComponent.PROP_FILL)) { 115 return new Boolean (getShapeDrawComponent().isFill()); 116 } 117 118 return null; 119 } 120 } 121 122 125 public void setPropertyValue(Object id, Object value) 126 { 127 super.setPropertyValue(id, value); 128 129 if (id.equals(ShapeDrawComponent.PROP_FILL_COLOR)) { 130 getShapeDrawComponent().setFillColor((Color )value); 131 } 132 else if (id.equals(ShapeDrawComponent.PROP_LINE_COLOR)) { 133 getShapeDrawComponent().setLineColor((Color )value); 134 } 135 else if (id.equals(ShapeDrawComponent.PROP_LINE_WIDTH)) { 136 getShapeDrawComponent().setLineWidth(((Integer )value).intValue()); 137 } 138 else if (id.equals(ShapeDrawComponent.PROP_LINE_STYLE)) { 139 getShapeDrawComponent().setLineStyle(((Integer )value).intValue()); 140 } 141 else if (id.equals(ShapeDrawComponent.PROP_FILL)) { 142 getShapeDrawComponent().setFill(((Boolean )value).booleanValue()); 143 } 144 } 145 146 protected ShapeDrawComponent getShapeDrawComponent() { 147 return (ShapeDrawComponent) drawComponent; 148 } 149 } 150 | Popular Tags |