KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * Created on 22-Mar-2005
3  *
4  */

5 package org.hibernate.eclipse.console.views.properties;
6
7 import java.util.ArrayList JavaDoc;
8 import java.util.Collection JavaDoc;
9 import java.util.Iterator JavaDoc;
10 import java.util.List JavaDoc;
11 import java.util.Set JavaDoc;
12
13 import org.eclipse.ui.views.properties.IPropertyDescriptor;
14 import org.eclipse.ui.views.properties.IPropertySource;
15
16 import com.l2fprod.common.propertysheet.Property;
17
18 public class HibernatePropertySource implements IPropertySource
19 {
20     private Property property;
21     
22     public HibernatePropertySource (Object JavaDoc property)
23     {
24         this.property = (Property) property;
25     }
26
27     public Object JavaDoc getEditableValue() {
28         if (property.getType().equals(Set JavaDoc.class) || property.getType().equals(List JavaDoc.class))
29         {
30             return "";
31         }
32         
33         if (property.getValue() == null) return "";
34         
35         return property.getValue().toString();
36     }
37
38     public IPropertyDescriptor[] getPropertyDescriptors() {
39         ArrayList JavaDoc descriptors = new ArrayList JavaDoc();
40         
41         if (property.getType().equals(Set JavaDoc.class) || property.getType().equals(List JavaDoc.class))
42         {
43             Collection JavaDoc collection = (Collection JavaDoc) property.getValue();
44             int i = 0;
45             
46             for (Iterator JavaDoc iter = collection.iterator(); iter.hasNext(); i++)
47             {
48                 Object JavaDoc object = iter.next();
49                 descriptors.add( HibernatePropertyHelper.getClassDescriptor(object.hashCode() + "", object.getClass().getName() + "[" + i + "]", object.getClass()) );
50             }
51         }
52         
53         return (IPropertyDescriptor[]) descriptors.toArray(new IPropertyDescriptor[descriptors.size()]);
54     }
55     
56     public Object JavaDoc getPropertyValue(Object JavaDoc id) {
57         if (property.getType().equals(Set JavaDoc.class) || property.getType().equals(List JavaDoc.class))
58         {
59             Collection JavaDoc collection = (Collection JavaDoc) property.getValue();
60             
61             for (Iterator JavaDoc iter = collection.iterator(); iter.hasNext();)
62             {
63                 Object JavaDoc object = iter.next();
64                 if (id.equals(object.hashCode() + ""))
65                 {
66                     return object;
67                 }
68             }
69         }
70         
71         return "";
72     }
73
74     public boolean isPropertySet(Object JavaDoc id) {
75         return false;
76     }
77
78     public void resetPropertyValue(Object JavaDoc id) {
79         // TODO Auto-generated method stub
80

81     }
82
83     public void setPropertyValue(Object JavaDoc id, Object JavaDoc value) {
84         // TODO Auto-generated method stub
85
}
86     
87     
88 }
Popular Tags