1 19 20 package org.netbeans.modules.db.explorer.infos; 21 22 import java.io.IOException ; 23 import org.netbeans.api.db.explorer.DatabaseException; 24 import org.netbeans.api.db.explorer.JDBCDriver; 25 import org.netbeans.api.db.explorer.JDBCDriverManager; 26 import org.netbeans.modules.db.explorer.DatabaseDriver; 27 import org.netbeans.modules.db.explorer.driver.JDBCDriverSupport; 28 29 public class DriverNodeInfo extends DatabaseNodeInfo { 30 31 static final long serialVersionUID =6994829681095273161L; 32 33 public DriverNodeInfo() { 34 } 35 36 public DatabaseDriver getDatabaseDriver() { 37 return (DatabaseDriver)get(DatabaseNodeInfo.DBDRIVER); 38 } 39 40 public void setDatabaseDriver(DatabaseDriver drv) { 41 put(DatabaseNodeInfo.NAME, drv.getName()); 42 put(DatabaseNodeInfo.URL, drv.getURL()); 43 put(DatabaseNodeInfo.PREFIX, drv.getDatabasePrefix()); 44 put(DatabaseNodeInfo.DBDRIVER, drv); 46 } 47 48 public void delete() throws IOException { 49 try { 50 JDBCDriver driver = getJDBCDriver(); 51 if (driver != null) { 52 JDBCDriverManager.getDefault().removeDriver(driver); 53 } 54 } catch (DatabaseException e) { 55 } 57 } 58 59 public String getIconBase() { 60 return (String ) ((checkDriverFiles()) ? get("iconbaseprefered") : get("iconbasepreferednotinstalled")); } 62 63 public void setIconBase(String base) { 64 if (checkDriverFiles()) 65 put("iconbaseprefered", base); else 67 put("iconbasepreferednotinstalled", base); } 69 70 private boolean checkDriverFiles() { 71 JDBCDriver driver = getJDBCDriver(); 72 if (driver != null) { 73 return JDBCDriverSupport.isAvailable(driver); 74 } else { 75 return false; 76 } 77 } 78 79 public JDBCDriver getJDBCDriver() { 80 DatabaseDriver dbdrv = getDatabaseDriver(); 81 if (dbdrv == null) { 82 return null; 83 } 84 return dbdrv.getJDBCDriver(); 85 } 86 } 87 | Popular Tags |