1 5 package org.hibernate.eclipse.console.views.properties; 6 7 import java.util.ArrayList ; 8 import java.util.Collection ; 9 import java.util.Iterator ; 10 import java.util.List ; 11 import java.util.Set ; 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 property) 23 { 24 this.property = (Property) property; 25 } 26 27 public Object getEditableValue() { 28 if (property.getType().equals(Set .class) || property.getType().equals(List .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 descriptors = new ArrayList (); 40 41 if (property.getType().equals(Set .class) || property.getType().equals(List .class)) 42 { 43 Collection collection = (Collection ) property.getValue(); 44 int i = 0; 45 46 for (Iterator iter = collection.iterator(); iter.hasNext(); i++) 47 { 48 Object 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 getPropertyValue(Object id) { 57 if (property.getType().equals(Set .class) || property.getType().equals(List .class)) 58 { 59 Collection collection = (Collection ) property.getValue(); 60 61 for (Iterator iter = collection.iterator(); iter.hasNext();) 62 { 63 Object 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 id) { 75 return false; 76 } 77 78 public void resetPropertyValue(Object id) { 79 81 } 82 83 public void setPropertyValue(Object id, Object value) { 84 } 86 87 88 } | Popular Tags |