1 19 20 package org.netbeans.modules.db.explorer; 21 22 import org.openide.nodes.PropertySupport; 23 24 import org.netbeans.modules.db.explorer.infos.ConnectionNodeInfo; 25 import org.netbeans.modules.db.explorer.infos.DatabaseNodeInfo; 26 27 public class DatabasePropertySupport extends PropertySupport { 28 protected Object repository; 29 30 public DatabasePropertySupport(String name, Class type, String displayName, String shortDescription, Object rep, boolean writable) { 31 super(name, type, displayName, shortDescription, true, writable); 32 repository = rep; 33 } 34 35 public Object getValue() throws IllegalAccessException , IllegalArgumentException { 36 String code = getName(); 37 Object rval = ((DatabaseNodeInfo) repository).getProperty(code); 38 return rval; 39 } 40 41 public void setValue(Object val) throws IllegalAccessException , IllegalArgumentException { 42 String code = getName(); 43 ((DatabaseNodeInfo) repository).setProperty(code, val); 44 } 45 46 50 public boolean canWrite () { 51 if (repository instanceof ConnectionNodeInfo) { 52 String propName = getName(); 53 if ("db".equals(propName) || "driver".equals(propName) || "schema".equals(propName) || "user".equals(propName) || "rememberpwd".equals(propName)) return ((ConnectionNodeInfo) repository).getConnection() == null ? true : false; 55 else 56 return super.canWrite(); 57 } else 58 return super.canWrite(); 59 } 60 } 61 | Popular Tags |