1 5 package org.hibernate.eclipse.console.views.properties; 6 7 8 import java.util.Collection ; 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 22 public class HibernatePropertyHelper { 23 24 static String 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 propertyId, String propertyName, Class clazz) 35 { 36 try { 37 38 if (clazz.equals(Boolean .class)) 39 { 40 return new ComboBoxPropertyDescriptor(propertyId, propertyName, new String [] { "true", "false" }); 41 } 42 43 if(clazz.isAssignableFrom(Collection .class)) { 44 return new org.eclipse.ui.views.properties.PropertyDescriptor(propertyId, propertyName); 45 } 46 return new TextPropertyDescriptor(propertyId, propertyName); 47 48 } catch (Exception e) { 49 e.printStackTrace(); 50 } 51 52 return null; 53 } 54 55 } 56 | Popular Tags |