KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > nightlabs > editor2d > properties > RotationPropertyDescriptor


1 /**
2  * <p> Project: com.nightlabs.editor2d </p>
3  * <p> Copyright: Copyright (c) 2004 </p>
4  * <p> Company: NightLabs GmbH (Germany) </p>
5  * <p> Creation Date: 18.03.2005 </p>
6  * <p> Author: Daniel Mazurek </p>
7 **/

8 package com.nightlabs.editor2d.properties;
9
10 import org.eclipse.jface.viewers.CellEditor;
11 import org.eclipse.jface.viewers.ILabelProvider;
12 import org.eclipse.swt.SWT;
13 import org.eclipse.swt.widgets.Composite;
14 import org.eclipse.ui.views.properties.PropertyDescriptor;
15
16 import com.nightlabs.rcp.property.ComboBoxLabelProvider;
17
18 public class RotationPropertyDescriptor
19 //extends ComboBoxPropertyDescriptor
20
extends PropertyDescriptor
21 {
22   public static final String JavaDoc[] defaultRotations = new String JavaDoc[] {"-180", "-90", "-45", "0", "45", "90", "180"};
23   
24   public RotationPropertyDescriptor(Object JavaDoc id, String JavaDoc displayName)
25   {
26     super(id, displayName);
27   }
28
29   /**
30    * The <code>ComboBoxPropertyDescriptor</code> implementation of this
31    * <code>IPropertyDescriptor</code> method creates and returns a new
32    * <code>ComboBoxCellEditor</code>.
33    * <p>
34    * The editor is configured with the current validator if there is one.
35    * </p>
36    */

37   public CellEditor createPropertyEditor(Composite parent)
38   {
39     CellEditor editor = new RotationCellEditor(parent, defaultRotations, SWT.NONE);
40     if (getValidator() != null)
41       editor.setValidator(getValidator());
42     return editor;
43   }
44   
45   public ILabelProvider getLabelProvider()
46   {
47     if (isLabelProviderSet())
48       return super.getLabelProvider();
49     else
50       return new ComboBoxLabelProvider(defaultRotations);
51   }
52 }
53
Popular Tags