KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > nightlabs > editor2d > model > EllipsePropertySource


1 package com.nightlabs.editor2d.model;
2
3 import java.util.List JavaDoc;
4
5 import com.nightlabs.editor2d.EditorPlugin;
6 import com.nightlabs.editor2d.EllipseDrawComponent;
7 import com.nightlabs.editor2d.properties.IntPropertyDescriptor;
8
9 public class EllipsePropertySource
10 extends ShapeDrawComponentPropertySource
11 {
12     public EllipsePropertySource(EllipseDrawComponent ellipse) {
13         super(ellipse);
14     }
15     
16     protected EllipseDrawComponent getEllipseDrawComponent() {
17         return (EllipseDrawComponent) drawComponent;
18     }
19     
20     protected List JavaDoc createPropertyDescriptors()
21     {
22         List JavaDoc descriptors = super.createPropertyDescriptors();
23         // Start Angle
24
descriptors.add(new IntPropertyDescriptor(EllipseDrawComponent.PROP_START_ANGLE,
25                 EditorPlugin.getResourceString("property.startangle.label")));
26         // End Angle
27
descriptors.add(new IntPropertyDescriptor(EllipseDrawComponent.PROP_END_ANGLE,
28                 EditorPlugin.getResourceString("property.endangle.label")));
29         
30         return descriptors;
31     }
32     
33     /* (non-Javadoc)
34      * @see org.eclipse.ui.views.properties.IPropertySource#setPropertyValue(java.lang.Object, java.lang.Object)
35      */

36     public void setPropertyValue(Object JavaDoc id, Object JavaDoc value)
37     {
38         super.setPropertyValue(id, value);
39         
40         if (id.equals(EllipseDrawComponent.PROP_START_ANGLE)) {
41             getEllipseDrawComponent().setStartAngle(((Integer JavaDoc)value).intValue());
42         }
43         else if (id.equals(EllipseDrawComponent.PROP_END_ANGLE)) {
44             getEllipseDrawComponent().setEndAngle(((Integer JavaDoc)value).intValue());
45         }
46     }
47     
48     /* (non-Javadoc)
49      * @see org.eclipse.ui.views.properties.IPropertySource#getPropertyValue(java.lang.Object)
50      */

51     public Object JavaDoc getPropertyValue(Object JavaDoc id)
52     {
53         Object JavaDoc o = super.getPropertyValue(id);
54         if (o != null)
55             return o;
56         else
57         {
58             if (id.equals(EllipseDrawComponent.PROP_START_ANGLE)) {
59                 return new Integer JavaDoc(getEllipseDrawComponent().getStartAngle());
60             }
61             else if (id.equals(EllipseDrawComponent.PROP_END_ANGLE)) {
62                 return new Integer JavaDoc(getEllipseDrawComponent().getEndAngle());
63             }
64             
65             return null;
66         }
67     }
68 }
69
Popular Tags