KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > hibernate > eclipse > console > views > properties > HibernatePropertyHelper


1 /*
2  * Created on Feb 21, 2005
3  *
4  */

5 package org.hibernate.eclipse.console.views.properties;
6
7
8 import java.util.Collection JavaDoc;
9
10 import org.eclipse.ui.views.properties.ComboBoxPropertyDescriptor;
11 import org.eclipse.ui.views.properties.IPropertyDescriptor;
12 import org.eclipse.ui.views.properties.TextPropertyDescriptor;
13
14 import com.l2fprod.common.propertysheet.Property;
15
16
17 /**
18  * @author Marshall
19  *
20  * TODO: remove this class since it just contains helper stuff.
21  */

22 public class HibernatePropertyHelper {
23     
24     static String JavaDoc getPropertyId (Property property)
25     {
26         return property.getType().getName() + "_" + property.getName();
27     }
28     
29     static IPropertyDescriptor getPropertyDescriptor (Property property)
30     {
31         return getClassDescriptor (getPropertyId(property), property.getName(), property.getType());
32     }
33     
34     static IPropertyDescriptor getClassDescriptor (String JavaDoc propertyId, String JavaDoc propertyName, Class JavaDoc clazz)
35     {
36         try {
37             
38             if (clazz.equals(Boolean JavaDoc.class))
39             {
40                 return new ComboBoxPropertyDescriptor(propertyId, propertyName, new String JavaDoc[] { "true", "false" });
41             }
42             
43             if(clazz.isAssignableFrom(Collection JavaDoc.class)) {
44                 return new org.eclipse.ui.views.properties.PropertyDescriptor(propertyId, propertyName);
45             }
46             return new TextPropertyDescriptor(propertyId, propertyName);
47             
48         } catch (Exception JavaDoc e) {
49             e.printStackTrace();
50         }
51         
52         return null;
53     }
54     
55 }
56
Popular Tags