RSS news reader; initially copied from "all the news"
[phpeclipse.git] / archive / net.sourceforge.phpeclipse.quantum.sql / src / com / quantum / model / Bookmark.java
index 3ee61be..8b3feef 100644 (file)
@@ -29,7 +29,7 @@ import org.eclipse.jface.preference.IPreferenceStore;
  * 
  * @author root
  */
-public class Bookmark {
+public class Bookmark implements Displayable {
        
        public static final int SCHEMA_RULE_USE_ALL = 1;
        public static final int SCHEMA_RULE_USE_DEFAULT = 2;
@@ -57,6 +57,7 @@ public class Bookmark {
     private boolean promptForPassword = false;
     private boolean autoCommit = true;
     private String autoCommitPreference = IQuantumConstants.autoCommitTrue;
+       private Database database;
        
        public Bookmark() {
         this(MultiSQLServer.getInstance());
@@ -76,6 +77,7 @@ public class Bookmark {
         setPromptForPassword(data.getPromptForPassword());
         setAutoCommit(data.isAutoCommit());
         setAutoCommitPreference(data.getAutoCommitPreference());
+        setSchemaRule(data.getSchemaRule());
         
         this.schemas.addAll(data.schemas);
         this.quickList = new Hashtable(data.quickList);
@@ -238,7 +240,7 @@ public class Bookmark {
        this.connection = connection;
     }
 
-    public void disconnect() throws ConnectionException {
+    public void disconnect() throws SQLException {
         boolean isConnected = isConnected();
         try {
             if (this.connection != null) {
@@ -246,6 +248,7 @@ public class Bookmark {
             }
         } finally {
             this.connection = null;
+            this.database = null;
             if (isConnected() != isConnected) {
                 this.propertyChangeSupport.firePropertyChange(
                     "connected", isConnected, isConnected());
@@ -397,7 +400,10 @@ public class Bookmark {
         if (!isConnected()) {
             throw new NotConnectedException();
         }
-        return new Database(this);
+        if (this.database == null) {
+               this.database = new Database(this);
+        }
+        return this.database;
     }
     
     public DatabaseAdapter getAdapter() {
@@ -540,4 +546,18 @@ public class Bookmark {
             this.propertyChangeSupport.firePropertyChange("schemas", null, null);
         }
        }
+
+       public String getDisplayName() {
+               return this.name;
+       }
+
+       /**
+        * @param query
+        */
+       public void removeQuery(String query) {
+               if (this.queries.remove(query)) {
+               this.propertyChangeSupport.firePropertyChange("queries", null, null);
+               this.changed = true;
+               }
+       }
 }