latest quantum sources 2.3.2
authorkhartlage <khartlage>
Fri, 25 Jun 2004 18:16:50 +0000 (18:16 +0000)
committerkhartlage <khartlage>
Fri, 25 Jun 2004 18:16:50 +0000 (18:16 +0000)
107 files changed:
archive/net.sourceforge.phpeclipse.quantum.sql/icons/foreignkey.gif [new file with mode: 0644]
archive/net.sourceforge.phpeclipse.quantum.sql/icons/missingschema.gif [new file with mode: 0644]
archive/net.sourceforge.phpeclipse.quantum.sql/icons/quantum.gif
archive/net.sourceforge.phpeclipse.quantum.sql/icons/schema.gif
archive/net.sourceforge.phpeclipse.quantum.sql/icons/trigger.gif [new file with mode: 0644]
archive/net.sourceforge.phpeclipse.quantum.sql/icons/warning.gif [new file with mode: 0644]
archive/net.sourceforge.phpeclipse.quantum.sql/plugin.properties
archive/net.sourceforge.phpeclipse.quantum.sql/plugin.xml
archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/IQuantumConstants.java
archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/QuantumPlugin.java
archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/QuantumResources.properties
archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/actions/AddToQuickListAction.java
archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/actions/CustomCopyAction.java
archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/actions/DeleteAllRowsAction.java
archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/actions/ExecuteAction.java
archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/actions/ExportQueryAction.java
archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/actions/ImportQueryAction.java
archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/actions/NextSequenceAction.java
archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/actions/PrevSequenceAction.java
archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/actions/RefreshBookmarkAction.java
archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/actions/RemoveFromQuickListAction.java
archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/actions/ViewTableAction.java
archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/adapters/AdabasDAdapter.java
archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/adapters/AdapterFactory.java
archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/adapters/DB2AS400Adapter.java
archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/adapters/DB2Adapter.java
archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/adapters/DatabaseAdapter.java
archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/adapters/DriverInfo.java [deleted file]
archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/adapters/FeatureNotSupported.java [deleted file]
archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/adapters/GenericAdapter.java
archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/adapters/MySQLAdapter.java
archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/adapters/NoSuchAdapterException.java [deleted file]
archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/adapters/OracleAdapter.java
archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/adapters/PostgresAdapter.java
archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/adapters/RedBrickAdapter.java
archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/model/Bookmark.java
archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/model/BookmarkCollection.java
archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/model/ColumnImpl.java
archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/model/DataType.java [new file with mode: 0644]
archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/model/Database.java
archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/model/Entity.java
archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/model/EntityImpl.java
archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/model/ForeignKey.java
archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/model/ForeignKeyImpl.java [new file with mode: 0644]
archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/model/JDBCDriver.java
archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/model/Schema.java
archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/model/TableImpl.java
archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/model/ViewImpl.java
archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/model/xml/ModelToXMLConverter.java
archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/model/xml/TorqueConverter.java
archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/preferences/GlobalPreferences.java
archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/properties/BaseEntityPropertyPage.java [new file with mode: 0644]
archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/properties/BookmarkPropertyPage.java
archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/properties/ColumnPropertyPage.java [new file with mode: 0644]
archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/properties/DatabaseInformationPropertyPage.java
archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/properties/EntityPropertyPage.java [deleted file]
archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/properties/IndexPropertyPage.java [new file with mode: 0644]
archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/properties/ReferencesPropertyPage.java [new file with mode: 0644]
archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/properties/SchemaPropertyPage.java
archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/sql/MultiSQLServer.java
archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/sql/SQLHelper.java
archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/sql/SQLParser.java
archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/sql/metadata/MetaDataXMLInterface.java
archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/sql/metadata/ObjectMetaData.java
archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/sql/parser/SQLLexx.java
archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/ui/dialog/AddDriverDialog.java [deleted file]
archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/ui/dialog/SimpleSelectionDialog.java
archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/util/JarUtil.java
archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/util/StringMatrix.java
archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/util/sql/TypesHelper.java
archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/util/versioning/VersioningHelper.java
archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/CopyAction.java
archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/JDBCDriverTableViewer.java
archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/SQLQueryView.java
archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/SchemaSelectionControl.java [new file with mode: 0644]
archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/bookmark/AddSchemaAction.java [deleted file]
archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/bookmark/AddSchemaDialog.java [deleted file]
archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/bookmark/BookmarkContentProvider.java
archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/bookmark/BookmarkNode.java
archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/bookmark/BookmarkView.java
archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/bookmark/BookmarkViewActionGroup.java
archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/bookmark/CopyAction.java
archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/bookmark/EntityNode.java
archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/bookmark/GroupNode.java
archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/bookmark/PasteAction.java
archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/bookmark/QuickListNode.java
archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/bookmark/RenameAction.java
archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/bookmark/SchemaNode.java
archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/bookmark/TreeNode.java
archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/subset/EntitySubset.java
archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/subset/ObjectNode.java
archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/subset/SubsetContentProvider.java
archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/tableview/TableAdapter.java
archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/tableview/TableView.java
archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/widget/ComboViewer.java [new file with mode: 0644]
archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/wizards/AddDriverWizard.java [new file with mode: 0644]
archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/wizards/BaseSQLPage.java
archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/wizards/BookmarkConnectionWizardPage.java [new file with mode: 0644]
archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/wizards/BookmarkNameWizardPage.java [new file with mode: 0644]
archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/wizards/BookmarkWizard.java
archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/wizards/DeleteRowPage.java
archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/wizards/InsertRowPage.java
archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/wizards/JDBCDriverSelectionWizardPage.java [new file with mode: 0644]
archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/wizards/NewBookmarkPage1.java [deleted file]
archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/wizards/PropertyChangeWizardPage.java [new file with mode: 0644]
archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/wizards/SchemaSelectionWizardPage.java [new file with mode: 0644]
archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/wizards/UpdateRowPage.java

diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/icons/foreignkey.gif b/archive/net.sourceforge.phpeclipse.quantum.sql/icons/foreignkey.gif
new file mode 100644 (file)
index 0000000..983fc91
Binary files /dev/null and b/archive/net.sourceforge.phpeclipse.quantum.sql/icons/foreignkey.gif differ
diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/icons/missingschema.gif b/archive/net.sourceforge.phpeclipse.quantum.sql/icons/missingschema.gif
new file mode 100644 (file)
index 0000000..a312947
Binary files /dev/null and b/archive/net.sourceforge.phpeclipse.quantum.sql/icons/missingschema.gif differ
index b27e10a..13da745 100644 (file)
Binary files a/archive/net.sourceforge.phpeclipse.quantum.sql/icons/quantum.gif and b/archive/net.sourceforge.phpeclipse.quantum.sql/icons/quantum.gif differ
index f92eed1..2fd5bc7 100644 (file)
Binary files a/archive/net.sourceforge.phpeclipse.quantum.sql/icons/schema.gif and b/archive/net.sourceforge.phpeclipse.quantum.sql/icons/schema.gif differ
diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/icons/trigger.gif b/archive/net.sourceforge.phpeclipse.quantum.sql/icons/trigger.gif
new file mode 100644 (file)
index 0000000..a4ab061
Binary files /dev/null and b/archive/net.sourceforge.phpeclipse.quantum.sql/icons/trigger.gif differ
diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/icons/warning.gif b/archive/net.sourceforge.phpeclipse.quantum.sql/icons/warning.gif
new file mode 100644 (file)
index 0000000..5d3622d
Binary files /dev/null and b/archive/net.sourceforge.phpeclipse.quantum.sql/icons/warning.gif differ
index b67550a..4991fe1 100644 (file)
@@ -1,6 +1,7 @@
 quantum.name = Quantum DB Utility
-perspective.name = Quantum DB Perspective
+perspective.name = Quantum DB
 sqllogview.name = Quantum SQL Log
+driverview.name = JDBC Driver View
 tableview.name = Quantum Table View
 sqlqueryview.name = Quantum SQL Query Editor
 bookmarkview.name = Database Bookmarks
@@ -12,4 +13,4 @@ category.description = Quantum Database Tools
 scope.name = Quantum UI Scope
 scope.description = Quantum UI Scope
 command.execute.name = Execute SQL
-command.execute.description = Execute the SQL statements against a database bookmark
+command.execute.description = Execute the SQL statements against a database bookmark
\ No newline at end of file
index ef98a9c..030c378 100644 (file)
@@ -3,8 +3,8 @@
 <plugin
    id="net.sourceforge.phpeclipse.quantum.sql"
    name="%quantum.name"
-   version="2.3.0"
-   provider-name="Tom Schneider"
+   version="2.3.2"
+   provider-name="Tom Schneider, Julen Parra, BC Holmes"
    class="com.quantum.QuantumPlugin">
 
    <runtime>
             id="com.quantum.properties.SchemaPropertyPage">
       </page>
       <page
-            objectClass="com.quantum.view.bookmark.EntityNode"
-            name="Tables, Views and Sequences"
+            objectClass="com.quantum.model.EntityHolder"
+            name="Columns"
             nameFilter="*"
-            class="com.quantum.properties.EntityPropertyPage"
-            id="com.quantum.properties.EntityPropertyPage">
+            class="com.quantum.properties.ColumnPropertyPage"
+            id="com.quantum.properties.ColumnPropertyPage">
+      </page>
+      <page
+            objectClass="com.quantum.model.EntityHolder"
+            name="Indices"
+            nameFilter="*"
+            class="com.quantum.properties.IndexPropertyPage"
+            id="com.quantum.properties.IndexPropertyPage">
+      </page>
+      <page
+            objectClass="com.quantum.model.EntityHolder"
+            name="References"
+            nameFilter="*"
+            class="com.quantum.properties.ReferencesPropertyPage"
+            id="com.quantum.properties.ReferencesPropertyPage">
       </page>
    </extension>
    <extension
index 3f5dc51..444e96c 100644 (file)
@@ -13,8 +13,6 @@ public interface IQuantumConstants {
        public static final String PLUGIN_ID ="com.quantum"; //$NON-NLS-1$
        public static final String PREFIX = PLUGIN_ID+"."; //$NON-NLS-1$
 
-       public static final String ADD_SCHEMA_DIALOG_CONTEXT = PREFIX+"add_schema_dialog_context"; //$NON-NLS-1$
-
        //Constants for specifying Tables, Views and Sequences to the JDBC driver
        public static final String Table = "TABLE";             
        public static final String View = "VIEW";
index 2ef70c3..5a31b26 100644 (file)
@@ -42,15 +42,22 @@ import org.w3c.dom.Element;
 import org.xml.sax.SAXException;
 
 /**
- * @author root
  * Main class of the quantum plugin, sets defaults, saves and recovers state.
+ * @author root
  */
 public class QuantumPlugin extends AbstractUIPlugin {
-    public final static String PLUGIN_ID = "net.sourceforge.phpeclipse.quantum.sql";
+    public final static String PLUGIN_ID = "net.sourceforge.phpeclipse.quantum.sql"; 
        private static QuantumPlugin plugin;
        private Clipboard sysClip;
 
-       
+       /**
+        * 
+        * TODO: BCH - this constructor has changed in Eclipse 3.0.  This
+        * old version of the constructor is still necessary for running under
+        * Eclipse 2.x.
+        * 
+        * @param descriptor
+        */
        public QuantumPlugin(IPluginDescriptor descriptor) {
                super(descriptor);
                plugin = this;
@@ -129,7 +136,7 @@ public class QuantumPlugin extends AbstractUIPlugin {
         */
        public void shutdown() throws CoreException {
                super.shutdown();
-//             sysClip.dispose();
+               sysClip.dispose();
        }
 
        /**
@@ -208,7 +215,8 @@ public class QuantumPlugin extends AbstractUIPlugin {
                getPreferenceStore().setDefault("quantum.numeric.bold", false); //$NON-NLS-1$
                PreferenceConverter.setDefault(getPreferenceStore(), "quantum.font", (FontData) null); //$NON-NLS-1$
         getPreferenceStore().setDefault("com.quantum.model.Bookmark.queryHistorySize", 20); //$NON-NLS-1$
-        
+           
+
         getPreferenceStore().setDefault(
             "phpeclipse.sql.select.template",
             "$results = mysql_query(\"SELECT {0} FROM {1} WHERE {2} \");");
index 26b824f..ec2da55 100644 (file)
@@ -62,16 +62,6 @@ filedialog.options.ConfirmOverwrite = y
 filedialog.message.ConfirmOverwriteTitle = Confirm Overwrite
 filedialog.message.ConfirmOverwriteMessage = This file already exists : 
 filedialog.message.ConfirmOverwriteQuestion= \n\nDo you want to overwrite it?
-adapters.generic = Generic JDBC
-adapters.oracle = Oracle
-adapters.postgres = Postgres
-adapters.mysql = MySQL
-adapters.db2 = DB2
-adapters.db2as400 = DB2 for AS400
-adapters.adabasd = Adabas-D
-adapters.informix = Informix
-adapters.redbrick = Red Brick
-adapters.sybase = Sybase
 QuantumPlugin.save_2=save
 QuantumPlugin.icons_3=icons/
 QuantumPlugin.quantum.keyword.color_6=quantum.keyword.color
@@ -157,9 +147,6 @@ PreferencesPage.bold=bold
 PreferencesPage.italic=italic
 PreferencesPage.boldItalic=bold italic
 PreferencesPage.FontPrompt=Font: 
-BookmarkLabelProvider.TablePrefix= 
-BookmarkLabelProvider.ViewPrefix= 
-BookmarkLabelProvider.SequencePrefix= 
 DeleteColumnAction.DeleteColumns=Delete Columns...
 DeleteColumnAction.ConfirmDeleteColumns=Are you sure you want to delete the selected columns? 
 DeleteObjectAction.DeleteSubset=Delete Subset...
@@ -286,20 +273,93 @@ com.quantum.ui.dialog.ExceptionDisplayDialog.java.sql.IOException.title=I/O Exce
 com.quantum.ui.dialog.ExceptionDisplayDialog.java.sql.IOException.message=A problem was encountered while trying to access the file.
 com.quantum.ui.dialog.ExceptionDisplayDialog.java.sql.SQLException.title=SQL Exception
 com.quantum.ui.dialog.ExceptionDisplayDialog.java.sql.SQLException.message=An SQL Exception was encountered while trying to process your request.
-BookmarkWizard.Error=Error
-BookmarkWizard.bookmarkAlreadyExists=The selected bookmark name already exists.
 
-com.quantum.wizards.NewBookmarkPage1.driverColumn0=JDBC Driver Name
-com.quantum.wizards.NewBookmarkPage1.driverColumn1=Driver Class Name
-com.quantum.wizards.NewBookmarkPage1.driverColumn2=Version
-com.quantum.wizards.NewBookmarkPage1.driverColumn3=File Path
+com.quantum.wizards.JDBCDriverSelectionWizardPage.addDriver=Add driver...
+com.quantum.wizards.JDBCDriverSelectionWizardPage.title=JDBC Driver
+com.quantum.wizards.JDBCDriverSelectionWizardPage.description=Choose one of the drivers from the list or click the Add driver button
+
+com.quantum.wizards.BookmarkConnectionWizardPage.title=Connection details
+com.quantum.wizards.BookmarkConnectionWizardPage.description=Provide the information needed to connect to the database
+com.quantum.wizards.BookmarkConnectionWizardPage.userid=Userid:
+com.quantum.wizards.BookmarkConnectionWizardPage.password=Password:
+com.quantum.wizards.BookmarkConnectionWizardPage.prompt=Prompt for password
+com.quantum.wizards.BookmarkConnectionWizardPage.url=JDBC URL:
+
+com.quantum.wizards.BookmarkNameWizardPage.title=Bookmark Name
+com.quantum.wizards.BookmarkNameWizardPage.description=What name do you want for your bookmark?
+com.quantum.wizards.BookmarkNameWizardPage.name=Name:
+com.quantum.wizards.BookmarkNameWizardPage.alreadyExists=A bookmark with that name already exists.
+com.quantum.wizards.BookmarkNameWizardPage.mustProvide=Please provide a bookmark name.
+
+com.quantum.wizards.SchemaSelectionWizardPage.title=Schemas
+com.quantum.wizards.SchemaSelectionWizardPage.description=Which schemas should be displayed?
 
 com.quantum.view.JDBCDriverTableViewer.driverColumn0=JDBC Driver Name
 com.quantum.view.JDBCDriverTableViewer.driverColumn1=Driver Class Name
-com.quantum.view.JDBCDriverTableViewer.driverColumn2=Version
-com.quantum.view.JDBCDriverTableViewer.driverColumn3=File Path
+com.quantum.view.JDBCDriverTableViewer.driverColumn2=Driver Type
+com.quantum.view.JDBCDriverTableViewer.driverColumn3=Version
+com.quantum.view.JDBCDriverTableViewer.driverColumn4=File Path
+
+com.quantum.wizards.AddDriverWizard.windowTitle=New JDBC Driver
+com.quantum.wizards.AddDriverWizard$PageImpl.title=JDBC Driver
+com.quantum.wizards.AddDriverWizard$PageImpl.description=Provide the following information about the driver.
+com.quantum.wizards.AddDriverWizard$PageImpl.browse=Browse
+com.quantum.wizards.AddDriverWizard$PageImpl.fileName=File name:
+com.quantum.wizards.AddDriverWizard$PageImpl.driverClassName=Class name:
+
+com.quantum.adapters.DatabaseAdapter.GENERIC = Generic JDBC
+com.quantum.adapters.DatabaseAdapter.HSQLDB = HSQL (Hypersonic)
+com.quantum.adapters.DatabaseAdapter.ORACLE = Oracle
+com.quantum.adapters.DatabaseAdapter.POSTGRES = Postgres
+com.quantum.adapters.DatabaseAdapter.MYSQL = MySQL
+com.quantum.adapters.DatabaseAdapter.DB2 = DB2
+com.quantum.adapters.DatabaseAdapter.DB2AS400 = DB2 for AS400
+com.quantum.adapters.DatabaseAdapter.ADABASD = Adabas-D
+com.quantum.adapters.DatabaseAdapter.INFORMIX = Informix Dynamic Server
+com.quantum.adapters.DatabaseAdapter.REDBRICK = Red Brick
+com.quantum.adapters.DatabaseAdapter.SYBASE = Sybase
+com.quantum.adapters.DatabaseAdapter.POINTBASE = Pointbase
+
+com.quantum.view.SchemaSelectionControl.addSchemaDialog = Select a Schema
+com.quantum.view.SchemaSelectionControl.connectTitle = Connect Required
+com.quantum.view.SchemaSelectionControl.connectMessage = We must connect to the database to retrieve schemas.
+com.quantum.view.SchemaSelectionControl.useAllSchemas = Show all schemas
+com.quantum.view.SchemaSelectionControl.useUsernameAsSchema = Show the default schema
+com.quantum.view.SchemaSelectionControl.useSelectedSchemas = Show selected schemas
+
+com.quantum.properties.DatabaseInformationPropertyPage.dataTypes = The following data types are supported by this database:
+com.quantum.properties.DatabaseInformationPropertyPage.column0 = Data Type
+com.quantum.properties.DatabaseInformationPropertyPage.column1 = Java Type
+com.quantum.properties.DatabaseInformationPropertyPage.product = Product:
+com.quantum.properties.DatabaseInformationPropertyPage.unknown = <unknown>
+com.quantum.properties.DatabaseInformationPropertyPage.error = QuantumDB could not retrieve the database information due to an error:
+
+com.quantum.properties.BaseEntityPropertyPage.name = Name:
+com.quantum.properties.BaseEntityPropertyPage.schema = Schema:
+com.quantum.properties.BaseEntityPropertyPage.error = QuantumDB could not retrieve the information due to an error:
+
+com.quantum.properties.ReferencesPropertyPage.column0 = Constraint Name
+com.quantum.properties.ReferencesPropertyPage.column1 = Primary
+com.quantum.properties.ReferencesPropertyPage.column2 = Foreign
+com.quantum.properties.ReferencesPropertyPage.column3 = On Delete
+com.quantum.properties.ReferencesPropertyPage.importedKeyNoAction = NO ACTION
+com.quantum.properties.ReferencesPropertyPage.importedKeyCascade = CASCADE
+com.quantum.properties.ReferencesPropertyPage.importedKeySetNull = SET NULL
+com.quantum.properties.ReferencesPropertyPage.importedKeySetDefault = SET DEFAULT
+com.quantum.properties.ReferencesPropertyPage.importedKeyRestrict = RESTRICT
+
+com.quantum.properties.IndexPropertyPage.column0 = Index Name
+com.quantum.properties.IndexPropertyPage.column1 = Column Name
+com.quantum.properties.IndexPropertyPage.column2 = Order
+com.quantum.properties.IndexPropertyPage.ascending = Ascending
+com.quantum.properties.IndexPropertyPage.descending = Descending
 
-com.quantum.ui.dialog.AddDriverDialog.title=Add Driver
-com.quantum.ui.dialog.AddDriverDialog.browse=Browse
-com.quantum.ui.dialog.AddDriverDialog.fileName=File name:
-com.quantum.ui.dialog.AddDriverDialog.driverClassName=Class name:
+com.quantum.properties.ColumnPropertyPage.column0 = Name
+com.quantum.properties.ColumnPropertyPage.column1 = Type
+com.quantum.properties.ColumnPropertyPage.column2 = Size
+com.quantum.properties.ColumnPropertyPage.column3 = Digits
+com.quantum.properties.ColumnPropertyPage.column4 = Primary Key
+com.quantum.properties.ColumnPropertyPage.column5 = Nullable
+com.quantum.properties.ColumnPropertyPage.column6 = Remarks
+com.quantum.properties.ColumnPropertyPage.true = Yes
+com.quantum.properties.ColumnPropertyPage.false = No
index e773620..99b22f7 100644 (file)
@@ -19,12 +19,10 @@ import org.eclipse.ui.actions.SelectionListenerAction;
  * @author bcholmes
  */
 public class AddToQuickListAction extends SelectionListenerAction {
-    private IViewPart view;
     private List entities = Collections.synchronizedList(new ArrayList());
     
     public AddToQuickListAction(IViewPart view) {
         super(Messages.getString(AddToQuickListAction.class.getName() + ".text"));
-        this.view = view;
     }
     
        public void run() {
index 24ea456..3c0491b 100644 (file)
@@ -4,11 +4,13 @@
  */
 package com.quantum.actions;
 
+import java.sql.SQLException;
 import java.util.Iterator;
 
 import com.quantum.QuantumPlugin;
 import com.quantum.model.Column;
 import com.quantum.model.EntityHolder;
+import com.quantum.model.NotConnectedException;
 import com.quantum.util.NthLevelConverter;
 import com.quantum.util.QuantumUtil;
 import com.quantum.util.StringUtil;
@@ -22,14 +24,12 @@ import org.eclipse.ui.actions.SelectionListenerAction;
 
 
 public class CustomCopyAction extends SelectionListenerAction {
-       private final IViewPart view;
        private final int ind;
        /**
         * @param BookmarkView
         */
        public CustomCopyAction(IViewPart view, int ind) {
         super(null);
-               this.view = view;
                this.ind = ind;
        }
        public void run() {
@@ -43,18 +43,22 @@ public class CustomCopyAction extends SelectionListenerAction {
                                ColumnNode column = (ColumnNode) current;
                                if (column != null) {
                                        converter.add(column.getColumn().getName(), 
-                        column.getColumn().getParentEntity().getCondQualifiedName(), 0);
+                        column.getColumn().getParentEntity().getQualifiedName(), 0);
                                }
                        } else if (current instanceof EntityHolder) {
                 EntityHolder currentSelec = (EntityHolder) current;
-                               converter.add(currentSelec.getEntity().getCondQualifiedName(), null, 1);
-                               Column[] columns = currentSelec.getEntity().getColumns();
-                               for (int i = 0, length = (columns == null) ? 0 : columns.length;
-                    i < length;
-                    i++) {
-                                       converter.add(columns[i].getName(), 
-                        currentSelec.getEntity().getCondQualifiedName(), 0);
-                               }                                       
+                               converter.add(currentSelec.getEntity().getQualifiedName(), null, 1);
+                               try {
+                                       Column[] columns = currentSelec.getEntity().getColumns();
+                                       for (int i = 0, length = (columns == null) ? 0 : columns.length;
+                           i < length;
+                           i++) {
+                                               converter.add(columns[i].getName(), 
+                               currentSelec.getEntity().getQualifiedName(), 0);
+                                       }                                       
+                               } catch (NotConnectedException e) {
+                               } catch (SQLException e) {
+                               }
                        }
                }
                IPreferenceStore store = QuantumPlugin.getDefault().getPreferenceStore();
index 09f67bd..63e5979 100644 (file)
@@ -37,7 +37,7 @@ public class DeleteAllRowsAction extends SelectionListenerAction {
                     view.getSite().getShell(), 
                     Messages.getString(DeleteAllRowsAction.class.getName() + ".confirmTitle"),
                     Messages.getString(DeleteAllRowsAction.class.getName() + ".confirmText",  
-                    new Object[] { table.getCondQualifiedName() }));
+                    new Object[] { table.getQualifiedName() }));
                                if (flag) {
                                        table.deleteAllRows();
                                }
index f8c4418..295cfa3 100644 (file)
@@ -17,27 +17,30 @@ import com.quantum.view.bookmark.BookmarkView;
 import com.quantum.view.tableview.DefaultSizes;
 import com.quantum.view.tableview.TableView;
 
+import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.action.IStatusLineManager;
 import org.eclipse.jface.dialogs.MessageDialog;
 import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.swt.graphics.Image;
 import org.eclipse.swt.widgets.Shell;
 import org.eclipse.ui.IViewActionDelegate;
 import org.eclipse.ui.IViewPart;
 
 /**
- * @author panic
+ * Executes a query from the QueryView
  *
- *     Executes a query from the QueryView
+ * @author panic
  */
 public class ExecuteAction extends BaseSQLAction implements IViewActionDelegate {
        SQLQueryView view;
-       boolean flag = false;
        String execute1 = Messages.getString("ExecuteAction.Executing_Query3"); //$NON-NLS-1$
        String execute2 = Messages.getString("ExecuteAction.Executing_Query2"); //$NON-NLS-1$
     
        public ExecuteAction() {
                setActionDefinitionId("com.quantum.actions.ExecuteAction");
+               setImageDescriptor(QuantumPlugin.getImageDescriptor("play.gif"));
+               setText(Messages.getString("sqlqueryview.executeQuery"));
+               setToolTipText(Messages.getString("sqlqueryview.executeQuery"));
        }
     
        public void init(IViewPart view) {
@@ -56,10 +59,11 @@ public class ExecuteAction extends BaseSQLAction implements IViewActionDelegate
                           view.getSite().getShell(),"Sorry","Please select a bookmark to use as connection.");
                         return;
                }                  
+               getStatusLineManager().setErrorMessage(null);
                Connection con = getConnection();
-               view.setStatus(execute1);
+               getStatusLineManager().setMessage(execute1);
                MultiSQLServer server = MultiSQLServer.getInstance();
-               view.setStatus(Messages.getString("ExecuteAction.Parsing_sql_script3")); //$NON-NLS-1$
+               getStatusLineManager().setMessage(Messages.getString("ExecuteAction.Parsing_sql_script3")); //$NON-NLS-1$
                Vector queries = new Vector();
                String viewQuery = view.getQuery();
                // We parse the executable units to send to the JDBC driver
@@ -75,11 +79,13 @@ public class ExecuteAction extends BaseSQLAction implements IViewActionDelegate
                double startTime = 0.0; // stores the time when query is started
                double queryDuration= 0.0; // stores query's execution time
                
+               IProgressMonitor progressBar = getStatusLineManager().getProgressMonitor();
+               progressBar.beginTask("queries", queries.size());
                for (int i = 0; i < queries.size(); i++) {
-                       if (flag) {
-                               view.setStatus(execute1);
+                       if (i % 2 == 0) {
+                               getStatusLineManager().setMessage(execute1);
                        } else {
-                               view.setStatus(execute2);
+                               getStatusLineManager().setMessage(execute2);
                        }
                   
                   String query = (String) queries.elementAt(i);
@@ -111,19 +117,32 @@ public class ExecuteAction extends BaseSQLAction implements IViewActionDelegate
                                        resultUpdateCount += results.getUpdateCount();
                                 }
                           }
-                  }
-                  flag = !flag;
-                  view.setProgress(i + 1, queries.size());
+                   }
+System.out.println(getStatusLineManager().getProgressMonitor() == null ? "not found" : "found!");
+                       progressBar.worked(i);
+//                 view.setProgress(i + 1, queries.size());
                }
-               Image statImage = QuantumPlugin.getImage((errorCount > 0) ? "stop.gif" : "success.gif"); //$NON-NLS-1$ //$NON-NLS-2$
-               view.setStatus(statImage, Messages.getString("ExecuteAction.Done") + "(" + //$NON-NLS-1$ //$NON-NLS-2$
+               progressBar.done();
+               String message = Messages.getString("ExecuteAction.Done") + "(" + //$NON-NLS-1$ //$NON-NLS-2$
                                                resultCount + Messages.getString("ExecuteAction.QueriesExecuted") +  //$NON-NLS-1$
                                                resultUpdateCount + Messages.getString("ExecuteAction.RowsUpdated") +  //$NON-NLS-1$
                                                resultsDisplayed + Messages.getString("ExecuteAction.ResultsDisplayed") +  //$NON-NLS-1$
                                                errorCount + Messages.getString("ExecuteAction.Errors") +  //$NON-NLS-1$
-                                               queryDuration  + Messages.getString("ExecutAction.TimeExec") + ")"); //$NON-NLS-1$ //$NON-NLS-2$
+                                               queryDuration  + Messages.getString("ExecutAction.TimeExec") + ")"; //$NON-NLS-1$ //$NON-NLS-2$
+               if (errorCount > 0) {
+                       getStatusLineManager().setErrorMessage(
+                                       QuantumPlugin.getImage("stop.gif"), message);
+               } else {
+                       getStatusLineManager().setMessage(
+                                       QuantumPlugin.getImage("success.gif"), message);
+               }
+       }
 
-               view.setProgress(0, 1);
+       /**
+        * @return
+        */
+       private IStatusLineManager getStatusLineManager() {
+               return this.view.getViewSite().getActionBars().getStatusLineManager();
        }
 
        public void selectionChanged(IAction action, ISelection selection) {
index 081897e..cef3fe7 100644 (file)
@@ -7,6 +7,7 @@ import java.io.PrintWriter;
 import java.util.StringTokenizer;
 
 import com.quantum.Messages;
+import com.quantum.QuantumPlugin;
 import com.quantum.util.StringUtil;
 import com.quantum.view.LogProxy;
 import com.quantum.view.SQLLogView;
@@ -22,6 +23,12 @@ import org.eclipse.ui.IViewPart;
 public class ExportQueryAction extends Action implements IViewActionDelegate  {
        SQLQueryView view;
        
+       public ExportQueryAction() {
+               setImageDescriptor(QuantumPlugin.getImageDescriptor("export.gif"));
+               setText(Messages.getString("sqlqueryview.exportQuery"));
+               setToolTipText(Messages.getString("sqlqueryview.exportQuery"));
+       }
+       
        /**
         * @see org.eclipse.ui.IViewActionDelegate#init(IViewPart)
         */
index 6d9654b..16cda89 100644 (file)
@@ -25,7 +25,14 @@ import org.eclipse.ui.IViewPart;
  */
 public class ImportQueryAction extends Action implements IViewActionDelegate {
        SQLQueryView view;
-               FileDialog dialog;
+       FileDialog dialog;
+       
+       public ImportQueryAction() {
+               setText(Messages.getString("sqlqueryview.importQuery"));
+               setImageDescriptor(QuantumPlugin.getImageDescriptor("import.gif"));
+               setToolTipText(Messages.getString("sqlqueryview.importQuery"));
+       }
+       
        /**
         * @see org.eclipse.ui.IViewActionDelegate#init(IViewPart)
         */
@@ -35,7 +42,6 @@ public class ImportQueryAction extends Action implements IViewActionDelegate {
                dialog.setFilterExtensions(new String[]{"*.sql", "*.ddl", "*.*"}); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
                dialog.setFilterNames(new String[]{Messages.getString("filedialog.sqlFiles"), //$NON-NLS-1$
                        Messages.getString("filedialog.ddlFiles"), Messages.getString("filedialog.allfiles")}); //$NON-NLS-1$ //$NON-NLS-2$
-               
        }
 
        /**
index 88331d8..13d1d06 100644 (file)
@@ -1,8 +1,9 @@
 package com.quantum.actions;
 
+import org.eclipse.ui.IViewPart;
+
 import com.quantum.Messages;
 import com.quantum.QuantumPlugin;
-import com.quantum.adapters.AdapterFactory;
 import com.quantum.adapters.DatabaseAdapter;
 import com.quantum.model.Bookmark;
 import com.quantum.sql.SQLResults;
@@ -10,8 +11,6 @@ import com.quantum.view.ViewHelper;
 import com.quantum.view.bookmark.EntityNode;
 import com.quantum.view.tableview.TableView;
 
-import org.eclipse.ui.IViewPart;
-
 public class NextSequenceAction extends BaseSequenceAction {
     
     /**
@@ -24,12 +23,11 @@ public class NextSequenceAction extends BaseSequenceAction {
     }
     
        public void run() {
-               EntityNode node = getEntityNode();
+               EntityNode sequence = getEntityNode();
                String name = null;
-               if (node.isSequence()) {
-                       EntityNode sequence = (EntityNode) node;
+               if (sequence.isSequence()) {
                        Bookmark bookmark = sequence.getBookmark();
-                       DatabaseAdapter adapter = AdapterFactory.getInstance().getAdapter(bookmark.getType());
+                       DatabaseAdapter adapter = bookmark.getAdapter();
                        if (adapter == null) return;
                        name = sequence.getName();
                        String query = adapter.getNextValue(name, sequence.getEntity().getSchema());
index 875df6d..c632ba2 100644 (file)
@@ -4,9 +4,10 @@
  */
 package com.quantum.actions;
 
+import org.eclipse.ui.IViewPart;
+
 import com.quantum.Messages;
 import com.quantum.QuantumPlugin;
-import com.quantum.adapters.AdapterFactory;
 import com.quantum.adapters.DatabaseAdapter;
 import com.quantum.model.Bookmark;
 import com.quantum.sql.SQLResults;
@@ -14,8 +15,6 @@ import com.quantum.view.ViewHelper;
 import com.quantum.view.bookmark.EntityNode;
 import com.quantum.view.tableview.TableView;
 
-import org.eclipse.ui.IViewPart;
-
 public class PrevSequenceAction extends BaseSequenceAction {
        /**
      * @param text
@@ -27,12 +26,10 @@ public class PrevSequenceAction extends BaseSequenceAction {
     }
 
     public void run() {
-               EntityNode node = getEntityNode();
-               if (((EntityNode) node).isSequence()) {
-            EntityNode sequence = (EntityNode) node;
+               EntityNode sequence = getEntityNode();
+               if (sequence.isSequence()) {
                        Bookmark bookmark = sequence.getBookmark();
-                       DatabaseAdapter adapter = AdapterFactory.getInstance().getAdapter(
-                bookmark.getType());
+                       DatabaseAdapter adapter = bookmark.getAdapter();
                        if (adapter == null) return;
                        String name = sequence.getName();
                        String query = adapter.getPrevValue(name, sequence.getEntity().getSchema());
index 525503f..c28df56 100644 (file)
@@ -1,12 +1,13 @@
 package com.quantum.actions;
 
+import java.sql.SQLException;
 import java.util.Iterator;
 import java.util.List;
 
 import com.quantum.Messages;
 import com.quantum.QuantumPlugin;
-import com.quantum.sql.SQLHelper;
-import com.quantum.view.bookmark.BookmarkView;
+import com.quantum.model.NotConnectedException;
+import com.quantum.ui.dialog.ExceptionDisplayDialog;
 import com.quantum.view.bookmark.TreeNode;
 
 import org.eclipse.ui.IViewPart;
@@ -16,12 +17,10 @@ import org.eclipse.ui.actions.SelectionListenerAction;
  * @author root
  */
 public class RefreshBookmarkAction extends SelectionListenerAction {
-       SQLHelper helper = new SQLHelper();
-
-    BookmarkView view;
+    private IViewPart view;
        public RefreshBookmarkAction(IViewPart view) {
         super(Messages.getString(RefreshBookmarkAction.class.getName() + ".text"));
-               this.view = (BookmarkView) view;
+               this.view = view;
         setImageDescriptor(QuantumPlugin.getImageDescriptor("refresh.gif"));
        }
 
@@ -30,8 +29,22 @@ public class RefreshBookmarkAction extends SelectionListenerAction {
         for (Iterator i = list.iterator(); i.hasNext(); ) {
             Object object = i.next();
             if (object != null && object instanceof TreeNode) {
-                ((TreeNode) object).reload();
+               try {
+                       ((TreeNode) object).reload();
+               } catch (NotConnectedException e) {
+                       handleException(e);
+               } catch (SQLException e) {
+                       handleException(e);
+               }
             }
         }
        }
+
+       /**
+        * @param e
+        */
+       private void handleException(Throwable t) {
+               ExceptionDisplayDialog.openError(
+                               this.view.getSite().getShell(), null, null, t);
+       }
 }
index a677733..55b894a 100644 (file)
@@ -19,12 +19,10 @@ import org.eclipse.ui.actions.SelectionListenerAction;
  * @author bcholmes
  */
 public class RemoveFromQuickListAction extends SelectionListenerAction  {
-    private IViewPart view;
     private List entities = Collections.synchronizedList(new ArrayList());
 
     public RemoveFromQuickListAction(IViewPart view) {
         super(Messages.getString(RemoveFromQuickListAction.class.getName() + ".text"));
-        this.view = view;
     }
 
     public void run() {
index 6da4e9f..45c6a7d 100644 (file)
@@ -15,12 +15,10 @@ import org.eclipse.ui.actions.SelectionListenerAction;
  * Implements action for "View Table"
 */
 public class ViewTableAction extends SelectionListenerAction {
-    private IViewPart view;
     private Entity entity;
     
        public ViewTableAction(IViewPart view) {
         super(Messages.getString(ViewTableAction.class.getName() + ".text"));
-               this.view = view;
         setImageDescriptor(
             QuantumPlugin.getImageDescriptor("table.gif")); //$NON-NLS-1$
        }
index 42c403a..996fc3d 100644 (file)
@@ -2,10 +2,16 @@ package com.quantum.adapters;
 
 
 public class AdabasDAdapter extends DatabaseAdapter {
-    public String getShowTableQuery(String qualifier, boolean isDefault) {
+    /**
+        * @param type
+        */
+       protected AdabasDAdapter() {
+               super(AdapterFactory.ADABASD);
+       }
+       public String getShowTableQuery(String qualifier) {
         return "SELECT OWNER, TABLENAME FROM TABLES WHERE OWNER = '" + qualifier.toUpperCase() + "'"; //$NON-NLS-1$
     }
-    public String getShowViewQuery(String qualifier, boolean isDefault) {
+    public String getShowViewQuery(String qualifier) {
         return "SELECT OWNER, VIEWNAME FROM VIEWS WHERE OWNER = '" + qualifier.toUpperCase() + "'"; //$NON-NLS-1$
     }
 }
index f26b278..37f05c4 100644 (file)
@@ -2,16 +2,37 @@ package com.quantum.adapters;
 
 import java.util.ArrayList;
 import java.util.Collections;
+import java.util.Comparator;
+import java.util.HashMap;
 import java.util.List;
-
-import com.quantum.Messages;
+import java.util.Map;
 
 /**
- * @author root
  * Basically this Factory is a Singleton that is used to return the proper adapter
+ * @author root
  */
 public class AdapterFactory {
+       
+       static class ComparatorImpl implements Comparator {
+
+               public int compare(Object arg0, Object arg1) {
+                       DatabaseAdapter adapter0 = (DatabaseAdapter) arg0;
+                       DatabaseAdapter adapter1 = (DatabaseAdapter) arg1;
+                       
+                       if (adapter0 == null && adapter0 != null) {
+                               return -1;
+                       } else if (adapter0 != null && adapter1 == null) {
+                               return 1;
+                       } else if (adapter0 == null && adapter1 == null) {
+                               return 0;
+                       } else {
+                               return adapter0.getDisplayName().compareTo(adapter1.getDisplayName());
+                       }
+               }
+       }
+       
        public static final String GENERIC = "GENERIC"; //$NON-NLS-1$
+       public static final String HSQLDB = "HSQLDB"; //$NON-NLS-1$
     public static final String ORACLE = "ORACLE"; //$NON-NLS-1$
     public static final String POSTGRES = "POSTGRES"; //$NON-NLS-1$
     public static final String MYSQL = "MYSQL"; //$NON-NLS-1$
@@ -20,15 +41,59 @@ public class AdapterFactory {
        public static final String ADABASD = "ADABASD"; //$NON-NLS-1$
     public static final String INFORMIX = "INFORMIX"; //$NON-NLS-1$
        public static final String REDBRICK = "REDBRICK"; //$NON-NLS-1$
+       public static final String POINTBASE = "POINTBASE"; //$NON-NLS-1$
     public static final String SYBASE = "SYBASE"; //$NON-NLS-1$
 
+       private static final Map DRIVER_MAP = Collections.synchronizedMap(new HashMap());
+       
+       static {
+               DRIVER_MAP.put("com.ddtek.jdbc.informix.InformixDriver", AdapterFactory.INFORMIX);
+               DRIVER_MAP.put("com.ddtek.jdbc.db2.DB2Driver", AdapterFactory.DB2);
+               DRIVER_MAP.put("com.ddtek.jdbc.oracle.OracleDriver", AdapterFactory.ORACLE);
+               DRIVER_MAP.put("com.ddtek.jdbc.sqlserver.SQLServerDriver", AdapterFactory.GENERIC);
+               DRIVER_MAP.put("com.ddtek.jdbc.sybase.SybaseDriver", AdapterFactory.SYBASE);
+               DRIVER_MAP.put("com.ibm.as400.access.AS400JDBCDriver", AdapterFactory.DB2AS400);
+               DRIVER_MAP.put("COM.ibm.db2.jdbc.app.DB2Driver", AdapterFactory.DB2);
+               DRIVER_MAP.put("COM.ibm.db2.jdbc.net.DB2Driver", AdapterFactory.DB2);
+               DRIVER_MAP.put("com.inet.ora.OraDriver", AdapterFactory.ORACLE);
+               DRIVER_MAP.put("com.inet.drda.DRDADriver", AdapterFactory.DB2);
+               DRIVER_MAP.put("com.inet.syb.SybDriver", AdapterFactory.SYBASE);
+               DRIVER_MAP.put("com.inet.tds.TdsDriver", AdapterFactory.GENERIC);
+               DRIVER_MAP.put("com.informix.jdbc.IfxDriver", AdapterFactory.INFORMIX);
+               DRIVER_MAP.put("com.microsoft.jdbc.sqlserver.SQLServerDriver", AdapterFactory.GENERIC);
+               DRIVER_MAP.put("com.mysql.jdbc.Driver", AdapterFactory.MYSQL);
+               DRIVER_MAP.put("com.pointbase.jdbc.jdbcUniversalDriver", AdapterFactory.POINTBASE);
+               DRIVER_MAP.put("com.sybase.jdbcx.SybDriver", AdapterFactory.SYBASE);
+               DRIVER_MAP.put("oracle.jdbc.driver.OracleDriver", AdapterFactory.ORACLE);
+               DRIVER_MAP.put("org.gjt.mm.mysql.Driver", AdapterFactory.MYSQL);
+               DRIVER_MAP.put("org.hsqldb.jdbcDriver", AdapterFactory.HSQLDB);
+               DRIVER_MAP.put("org.postgresql.Driver", AdapterFactory.POSTGRES);
+               DRIVER_MAP.put("weblogic.jdbc.informix.InformixDriver", AdapterFactory.INFORMIX);
+               DRIVER_MAP.put("weblogic.jdbc.sqlserver.SybaseDriver", AdapterFactory.SYBASE);
+       }
+       
     private static AdapterFactory instance;
     
-    private ArrayList drivers;
+    private Map adapters = Collections.synchronizedMap(new HashMap());
     
     private AdapterFactory() {
-       loadDrivers();
+       addAdapter(new GenericAdapter(GENERIC));
+       addAdapter(new GenericAdapter(HSQLDB));
+       addAdapter(new OracleAdapter());
+       addAdapter(new DB2Adapter());
+       addAdapter(new DB2AS400Adapter());
+       addAdapter(new PostgresAdapter());
+       addAdapter(new GenericAdapter(MYSQL));
+       addAdapter(new AdabasDAdapter());
+       addAdapter(new GenericAdapter(INFORMIX));
+       addAdapter(new RedBrickAdapter());
+       addAdapter(new GenericAdapter(SYBASE));
+       addAdapter(new GenericAdapter(POINTBASE));
+    }
+    private void addAdapter(DatabaseAdapter adapter) {
+       this.adapters.put(adapter.getType(), adapter);
     }
+    
     public static synchronized AdapterFactory getInstance() {
        if (instance == null) {
                instance = new AdapterFactory();
@@ -36,58 +101,26 @@ public class AdapterFactory {
        return instance;
     }
 
-    /**
-     * Master list of supported drivers
-     */
-    private void loadDrivers() {
-       drivers = new ArrayList();
-
-               DriverInfo generic = new DriverInfo(GENERIC, Messages.getString("adapters.generic"), new GenericAdapter()); //$NON-NLS-1$
-               DriverInfo oracle = new DriverInfo(ORACLE, Messages.getString("adapters.oracle"), new OracleAdapter()); //$NON-NLS-1$
-               DriverInfo db2 = new DriverInfo(DB2,  Messages.getString("adapters.db2"), new DB2Adapter()); //$NON-NLS-1$
-               DriverInfo db2as400 = new DriverInfo(DB2AS400,  Messages.getString("adapters.db2as400"), new DB2AS400Adapter()); //$NON-NLS-1$
-               DriverInfo postgres = new DriverInfo(POSTGRES,  Messages.getString("adapters.postgres"), new PostgresAdapter()); //$NON-NLS-1$
-               DriverInfo mysql = new DriverInfo(MYSQL,  Messages.getString("adapters.mysql"), new GenericAdapter()); //$NON-NLS-1$
-               DriverInfo adabasd = new DriverInfo(ADABASD, Messages.getString("adapters.adabasd"), new AdabasDAdapter()); //$NON-NLS-1$
-        DriverInfo informix = new DriverInfo(INFORMIX, Messages.getString("adapters.informix"), new GenericAdapter()); //$NON-NLS-1$
-               DriverInfo redbrick = new DriverInfo(REDBRICK, Messages.getString("adapters.redbrick"), new RedBrickAdapter()); //$NON-NLS-1$
-        DriverInfo sybase = new DriverInfo(SYBASE, Messages.getString("adapters.sybase"), new GenericAdapter()); //$NON-NLS-1$
-
-       drivers.add(generic);
-       drivers.add(oracle);
-       drivers.add(db2);
-       drivers.add(db2as400);
-       drivers.add(postgres);
-       drivers.add(mysql);
-               drivers.add(adabasd);
-        drivers.add(informix);
-               drivers.add(redbrick);
-        drivers.add(sybase);
+    public DatabaseAdapter getAdapter(String type){
+       DatabaseAdapter result = (DatabaseAdapter) this.adapters.get(type);
+       if (result == null) {
+               result = (DatabaseAdapter) this.adapters.get(GENERIC);
+       }
+       return result == null ? null : result;
     }
     
-    public synchronized DatabaseAdapter getAdapter(String type){
-       if (drivers == null) {
-               loadDrivers();
-       }
-       for (int i = 0; i < drivers.size(); i++) {
-               DriverInfo info = (DriverInfo) drivers.get(i);
-               if (type.equals(info.getDriverType())) {
-                       return info.getAdapter();
-               }
-       }
-       // If its not a recognized driver, we return the generic one
-               for (int i = 0; i < drivers.size(); i++) {
-                       DriverInfo info = (DriverInfo) drivers.get(i);
-                       if (type.equals(GENERIC)) {
-                               return info.getAdapter();
-                       }
-               }
-               return null;
+    public DatabaseAdapter[] getDriverList() {
+        List list = new ArrayList(this.adapters.values());
+        Collections.sort(list, new ComparatorImpl());
+       return (DatabaseAdapter[]) list.toArray(new DatabaseAdapter[list.size()]);
     }
     
-    public synchronized DriverInfo[] getDriverList() {
-        List list = new ArrayList(this.drivers);
-        Collections.sort(list);
-       return (DriverInfo[]) list.toArray(new DriverInfo[list.size()]);
+    /**
+     * 
+     * @param driverClassName
+     * @return the adapter type, or null if the adapter type is not known
+     */
+    public String getAdapterType(String driverClassName) {
+       return (String) DRIVER_MAP.get(driverClassName);
     }
 }
\ No newline at end of file
index ff6bf2e..d31c905 100644 (file)
@@ -2,12 +2,15 @@ package com.quantum.adapters;
 
 
 public class DB2AS400Adapter extends DatabaseAdapter {
-    public String getShowTableQuery(String qualifier, boolean isDefault) {
+       protected DB2AS400Adapter() {
+               super(AdapterFactory.DB2AS400);
+       }
+       public String getShowTableQuery(String qualifier) {
         return "SELECT TABLE_NAME FROM QSYS2.SYSTABLES WHERE table_schema  = '" + 
                        qualifier.toUpperCase() + 
                                "' AND TABLE_TYPE IN ('T', 'P') AND SYSTEM_TABLE= 'N'"; //$NON-NLS-1$ //$NON-NLS-2$
     }
-    public String getShowViewQuery(String qualifier, boolean isDefault) {
+    public String getShowViewQuery(String qualifier) {
         return "SELECT TABLE_NAME FROM QSYS2.SYSTABLES WHERE table_schema  = '" +
                        qualifier.toUpperCase() +
                         "' AND TABLE_TYPE IN ('V', 'L') AND SYSTEM_TABLE= 'N'"; //$NON-NLS-1$ //$NON-NLS-2$
index ca5dd76..3f0141d 100644 (file)
@@ -3,13 +3,19 @@ package com.quantum.adapters;
 import com.quantum.sql.SQLHelper;
 
 public class DB2Adapter extends DatabaseAdapter {
-    public String getShowTableQuery(String qualifier, boolean isDefault) {
+    /**
+        * @param type
+        */
+       protected DB2Adapter() {
+               super(AdapterFactory.DB2);
+       }
+       public String getShowTableQuery(String qualifier) {
         return "SELECT TABNAME FROM syscat.tables WHERE tabschema = '" + qualifier.toUpperCase() + "' AND TYPE='T'"; //$NON-NLS-1$ //$NON-NLS-2$
     }
-    public String getShowViewQuery(String qualifier, boolean isDefault) {
+    public String getShowViewQuery(String qualifier) {
         return "SELECT TABNAME FROM syscat.tables WHERE tabschema = '" + qualifier.toUpperCase() + "' AND TYPE='V'"; //$NON-NLS-1$ //$NON-NLS-2$
     }
-    public String getShowSequenceQuery(String qualifier, boolean isDefault) {
+    public String getShowSequenceQuery(String qualifier) {
         return "SELECT SEQNAME FROM sysibm.syssequences WHERE seqschema = '" + qualifier.toUpperCase() + "'"; //$NON-NLS-1$ //$NON-NLS-2$
     }
     public String getNextValue(String sequence, String owner) {
index d17e8b0..12bde71 100644 (file)
@@ -1,5 +1,6 @@
 package com.quantum.adapters;
 
+import com.quantum.Messages;
 import com.quantum.sql.SQLHelper;
 import com.quantum.util.StringUtil;
 
@@ -12,12 +13,22 @@ import com.quantum.util.StringUtil;
  */
 public abstract class DatabaseAdapter {
     
+       private final String type;
+       
+       protected DatabaseAdapter(String type) {
+               this.type = type;
+       }
+       
+       public String getDisplayName() {
+               return Messages.getString(DatabaseAdapter.class, getType());
+       }
+       
        /**
         * Returns the SQL Query to get a list of the tables for the current user (schema) 
         * @param info
         * @return - A String with the SQL query 
         */
-       public String getShowTableQuery(String schema, boolean isDefault) {
+       public String getShowTableQuery(String schema) {
                return null;
        }
        /**
@@ -25,7 +36,7 @@ public abstract class DatabaseAdapter {
         * @param info
         * @return - A String with the SQL query
         */
-       public String getShowViewQuery(String schema, boolean isDefault) {
+       public String getShowViewQuery(String schema) {
                return null;
        }
        /**
@@ -33,7 +44,7 @@ public abstract class DatabaseAdapter {
         * @param info
         * @return - A String with the SQL query
         */
-       public String getShowSequenceQuery(String schema, boolean isDefault) {
+       public String getShowSequenceQuery(String schema) {
         return null;
        }
 
@@ -195,4 +206,10 @@ public abstract class DatabaseAdapter {
     public String getDefaultSchema(String userid) {
         return userid;
     }
+       /**
+        * @return Returns the type.
+        */
+       public String getType() {
+               return this.type;
+       }
 }
\ No newline at end of file
diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/adapters/DriverInfo.java b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/adapters/DriverInfo.java
deleted file mode 100644 (file)
index 6b13c1d..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-package com.quantum.adapters;
-
-import java.util.Vector;
-
-public class DriverInfo implements Comparable {
-       private String driverType;
-       private String displayName;
-       private Vector driverNames = new Vector();
-       private DatabaseAdapter adapter;
-       public DriverInfo(String driverType, String displayName, DatabaseAdapter adapter) {
-               this.driverType = driverType;
-               this.displayName = displayName;
-               this.adapter = adapter;
-       }
-
-       public String getDriverType() {
-               return driverType;
-       }
-
-       public void setDriverType(String driverType) {
-               this.driverType = driverType;
-       }
-
-       public void addDriverName(String driverName) {
-               driverNames.addElement(driverName);
-       }
-       
-       public String[] getDriverNames() {
-               String retVal[] = new String[driverNames.size()];
-               for (int i = 0; i < driverNames.size(); i++) {
-                       retVal[i] = (String) driverNames.elementAt(i);
-               }
-               return retVal;
-       }
-
-       public DatabaseAdapter getAdapter() {
-               return adapter;
-       }
-
-       public void setAdapter(DatabaseAdapter adapter) {
-               this.adapter = adapter;
-       }
-
-       public String getDisplayName() {
-               return displayName;
-       }
-
-       public void setDisplayName(String displayName) {
-               this.displayName = displayName;
-       }
-
-    public int compareTo(Object o) {
-        DriverInfo that = (DriverInfo) o;
-        return this.getDisplayName().compareTo(that.getDisplayName());
-    }
-
-}
diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/adapters/FeatureNotSupported.java b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/adapters/FeatureNotSupported.java
deleted file mode 100644 (file)
index f80aa56..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-package com.quantum.adapters;
-
-public class FeatureNotSupported extends Error {
-    public FeatureNotSupported(String error) {
-        super(error);
-    }
-}
\ No newline at end of file
index bb4eb6b..1734321 100644 (file)
@@ -5,16 +5,20 @@ package com.quantum.adapters;
 
 public class GenericAdapter extends DatabaseAdapter {
 
-       public String getShowTableQuery(String qualifier, boolean isDefault) {
+       /**
+        * @param type
+        */
+       protected GenericAdapter(String type) {
+               super(type);
+       }
+       public String getShowTableQuery(String qualifier) {
                return null;
        }
-    public String getShowViewQuery(String qualifier, boolean isDefault) {
+    public String getShowViewQuery(String qualifier) {
                return null;
     }
     
-    public String getShowSequenceQuery(String qualifier, boolean isDefault) {
+    public String getShowSequenceQuery(String qualifier) {
         return null;
     }
-
-    
 }
index d764095..3478b3c 100644 (file)
@@ -3,7 +3,14 @@ package com.quantum.adapters;
 
 
 public class MySQLAdapter extends DatabaseAdapter {
-    public String getShowTableQuery(String qualifier, boolean isDefault) {
-        return "SHOW TABLES"; //$NON-NLS-1$
-    }
+
+       /**
+        * @param type
+        */
+       protected MySQLAdapter() {
+               super(AdapterFactory.MYSQL);
+       }
+//    public String getShowTableQuery(String qualifier, boolean isDefault) {
+//        return "SHOW TABLES"; //$NON-NLS-1$
+//    }
 }
\ No newline at end of file
diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/adapters/NoSuchAdapterException.java b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/adapters/NoSuchAdapterException.java
deleted file mode 100644 (file)
index ec71a00..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-package com.quantum.adapters;
-
-import com.quantum.Messages;
-
-public class NoSuchAdapterException extends Exception {
-    public NoSuchAdapterException(String driverName) {
-        super(Messages.getString("Error.NoDatabase") + driverName + Messages.getString("NoSuchAdapterException.<-_2")); //$NON-NLS-1$ //$NON-NLS-2$
-    }
-}
\ No newline at end of file
index a7fc544..a01fbbf 100644 (file)
@@ -7,7 +7,10 @@ import com.quantum.util.QuantumUtil;
 
 
 public class OracleAdapter extends DatabaseAdapter {
-       public String getShowSequenceQuery(String qualifier, boolean isDefault) {
+       protected OracleAdapter() {
+               super(AdapterFactory.ORACLE);
+       }
+       public String getShowSequenceQuery(String qualifier) {
         return "SELECT SEQUENCE_OWNER, SEQUENCE_NAME FROM ALL_SEQUENCES WHERE SEQUENCE_OWNER = '" + qualifier + "'"; //$NON-NLS-1$
        }
        public String getPrevValue(String sequence, String owner) {
index 8389bf1..3283163 100644 (file)
@@ -6,17 +6,22 @@ import com.quantum.util.sql.TypesHelper;
 
 
 public class PostgresAdapter extends DatabaseAdapter {
-    public String getShowTableQuery(String qualifier, boolean isDefault) {
+       protected PostgresAdapter() {
+               super(AdapterFactory.POSTGRES);
+       }
+       public String getShowTableQuery(String qualifier) {
         return "SELECT SCHEMANAME, TABLENAME FROM PG_TABLES WHERE SCHEMANAME = '" 
             + qualifier + "'";
     }
-    public String getShowViewQuery(String qualifier, boolean isDefault) {
+    public String getShowViewQuery(String qualifier) {
         return "SELECT SCHEMANAME, VIEWNAME FROM PG_VIEWS WHERE SCHEMANAME = '" 
             + qualifier + "'";
     }
-    public String getShowSequenceQuery(String qualifier, boolean isDefault) {
-        return "SELECT SCHEMANAME, relname FROM pg_class WHERE relkind = 'S'" +
-            "AND SCHEMANAME = '" + qualifier + "'";
+    public String getShowSequenceQuery(String qualifier) {
+       return "select pg_namespace.nspname, relname " +
+                       "from pg_class, pg_namespace where relkind = 'S' " +
+                       "and relnamespace = pg_namespace.oid " +
+                       "and pg_namespace.nspname = '" + qualifier + "'";
     }
        public String getNextValue(String sequence, String owner) {
                return "SELECT NEXTVAL('" + SQLHelper.getQualifiedName(owner, sequence) + "')";
index 623c3be..59d908f 100644 (file)
@@ -6,11 +6,18 @@ package com.quantum.adapters;
  */
 public class RedBrickAdapter extends DatabaseAdapter {
 
-       public String getShowTableQuery(String qualifier, boolean isDefault) {
+       /**
+        * @param type
+        */
+       protected RedBrickAdapter() {
+               super(AdapterFactory.REDBRICK);
+       }
+
+       public String getShowTableQuery(String qualifier) {
                return "select name from rbw_tables where type = 'TABLE'";
        }
 
-       public String getShowViewQuery(String qualifier, boolean isDefault) {
+       public String getShowViewQuery(String qualifier) {
                return "select name from rbw_tables where type = 'VIEW'";
        }
     /**
index 8082a39..3ee61be 100644 (file)
@@ -5,6 +5,7 @@ import java.beans.PropertyChangeSupport;
 import java.sql.Connection;
 import java.sql.SQLException;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Collections;
 import java.util.HashSet;
 import java.util.Hashtable;
@@ -29,15 +30,19 @@ import org.eclipse.jface.preference.IPreferenceStore;
  * @author root
  */
 public class Bookmark {
+       
+       public static final int SCHEMA_RULE_USE_ALL = 1;
+       public static final int SCHEMA_RULE_USE_DEFAULT = 2;
+       public static final int SCHEMA_RULE_USE_SELECTED = 3;
     
     private PropertyChangeSupport propertyChangeSupport = new PropertyChangeSupport(this);
        private String name = ""; //$NON-NLS-1$
        private String username = ""; //$NON-NLS-1$
     private String password = ""; //$NON-NLS-1$
-    private String connect = ""; //$NON-NLS-1$
-    private String driver = ""; //$NON-NLS-1$
-    private String type = ""; //$NON-NLS-1$
-    private String driverFile = ""; //$NON-NLS-1$
+    private String connectionUrl = ""; //$NON-NLS-1$
+    private JDBCDriver driver;
+    
+    private int schemaRule = SCHEMA_RULE_USE_ALL;
     
     /**
      * A quick list is a list of favourite tables that a person might want to view
@@ -67,9 +72,7 @@ public class Bookmark {
                setUsername(data.getUsername());
                setPassword(data.getPassword());
                setConnect(data.getConnect());
-               setDriver(data.getDriver());
-               setType(data.getType());
-               setDriverFile(data.getDriverFile());
+               setJDBCDriver(data.getJDBCDriver());
         setPromptForPassword(data.getPromptForPassword());
         setAutoCommit(data.isAutoCommit());
         setAutoCommitPreference(data.getAutoCommitPreference());
@@ -83,23 +86,7 @@ public class Bookmark {
         * @return String
         */
        public String getConnect() {
-               return connect;
-       }
-
-       /**
-        * Returns the driver.
-        * @return String
-        */
-       String getDriver() {
-               return driver;
-       }
-
-       /**
-        * Returns the driverFile.
-        * @return String
-        */
-       String getDriverFile() {
-               return driverFile;
+               return this.connectionUrl;
        }
 
        /**
@@ -107,7 +94,11 @@ public class Bookmark {
         * @return String
         */
        public String getPassword() {
-               return password;
+               if (this.promptForPassword) {
+                       return null;
+               } else {
+                       return this.password;
+               }
        }
 
        /**
@@ -120,35 +111,13 @@ public class Bookmark {
 
        /**
         * Sets the connect.
-        * @param connect The connect to set
+        * @param connectionUrl The connect to set
         */
-       public void setConnect(String connect) {
-               if (connect == null) {
-                       connect = ""; //$NON-NLS-1$
+       public void setConnect(String connectionUrl) {
+               if (connectionUrl == null) {
+                       connectionUrl = ""; //$NON-NLS-1$
                }
-               this.connect = connect;
-       }
-
-       /**
-        * Sets the driver.
-        * @param driver The driver to set
-        */
-       void setDriver(String driver) {
-               if (driver == null) {
-                       driver = ""; //$NON-NLS-1$
-               }
-               this.driver = driver;
-       }
-
-       /**
-        * Sets the driverFile.
-        * @param driverFile The driverFile to set
-        */
-       void setDriverFile(String driverFile) {
-               if (driverFile == null) {
-                       driverFile = ""; //$NON-NLS-1$
-               }
-               this.driverFile = driverFile;
+               this.connectionUrl = connectionUrl;
        }
 
        /**
@@ -202,10 +171,9 @@ public class Bookmark {
                if (name.equals("") && //$NON-NLS-1$
                username.equals("") && //$NON-NLS-1$
                password.equals("") && //$NON-NLS-1$
-               connect.equals("") && //$NON-NLS-1$
+               connectionUrl.equals("") && //$NON-NLS-1$
                driver.equals("") && //$NON-NLS-1$
-               type.equals("") && //$NON-NLS-1$
-               driverFile.equals("")) { //$NON-NLS-1$
+               driver == null) {
                        return true;
                }
                return false;
@@ -222,28 +190,14 @@ public class Bookmark {
                buffer.append("password=****"); //$NON-NLS-1$
                buffer.append(", "); //$NON-NLS-1$
                buffer.append("connect="); //$NON-NLS-1$
-               buffer.append(connect);
+               buffer.append(connectionUrl);
                buffer.append(", "); //$NON-NLS-1$
                buffer.append("driver="); //$NON-NLS-1$
                buffer.append(driver);
-               buffer.append(", "); //$NON-NLS-1$
-               buffer.append("type="); //$NON-NLS-1$
-               buffer.append(type);
-               buffer.append(", "); //$NON-NLS-1$
-               buffer.append("driverFile="); //$NON-NLS-1$
-               buffer.append(driverFile);
                buffer.append("]"); //$NON-NLS-1$
                return buffer.toString();
        }
        
-       public String getType() {
-               return type;
-       }
-
-       public void setType(String type) {
-               this.type = type;
-       }
-
     public Connection connect(PasswordFinder passwordFinder) throws ConnectionException {
         boolean isConnected = isConnected();
         if (this.connection == null) {
@@ -312,7 +266,7 @@ public class Bookmark {
         }
     }
 
-    public void setSchemas(Schema[] schemas) {
+    public void setSchemaSelections(Schema[] schemas) {
         this.schemas.clear();
         for (int i = 0, length = (schemas == null) ? 0 : schemas.length;
             i < length;
@@ -327,17 +281,53 @@ public class Bookmark {
     /**
      * @return a list of all the schemas that have been set up.
      */
-    public Schema[] getSchemas() {
-        Set set = new HashSet();
-        set.addAll(this.schemas);
-        if (set.isEmpty()) {
-            set.add(new Schema(getAdapter().getDefaultSchema(this.username), 
-                this.username, true));
-        }
-        List list = new ArrayList(set);
+    public Schema[] getSchemaSelections() {
+        List list = new ArrayList(this.schemas);
         Collections.sort(list);
         return (Schema[]) list.toArray(new Schema[list.size()]);
     }
+    
+    public Schema[] getSchemas() throws NotConnectedException, SQLException {
+       Schema[] schemas = null;
+       if (useUsernameAsSchema()) {
+               // do nothing
+       } else if (useAllSchemas()) {
+               schemas = getDatabase().getSchemas();
+       } else {
+               schemas = verifySchemas(getSchemaSelections());
+       }
+       return (schemas == null || schemas.length == 0) 
+                               ? new Schema[] { getDefaultSchema() } 
+                       : schemas;
+    }
+
+       /**
+        * @param schemaSelections
+        * @return
+        * @throws SQLException
+        * @throws NotConnectedException
+        */
+       private Schema[] verifySchemas(Schema[] schemaSelections) 
+                       throws NotConnectedException, SQLException {
+               Schema[] schemasFromDatabase = getDatabase().getSchemas();
+               List list = Arrays.asList(schemasFromDatabase);
+               for (int i = 0, length = schemaSelections == null ? 0 : schemaSelections.length; 
+                               i < length; i++) {
+                       schemaSelections[i].setExists(list.contains(schemaSelections[i]));
+               }
+               return schemaSelections;
+       }
+
+       /**
+        * @return
+        * @throws NotConnectedException
+        * @throws SQLException
+        */
+       private Schema getDefaultSchema() throws NotConnectedException, SQLException {
+               String username = getDatabase().getUsername();
+               String actual = getAdapter().getDefaultSchema(username);
+               return new Schema(actual, username, true);
+       }
 
        /**
         * @see java.lang.Object#equals(java.lang.Object)
@@ -365,7 +355,7 @@ public class Bookmark {
 
     public void addQuickListEntry(String type, String schemaName, String name) {
         Entity entity = EntityFactory.getInstance().create(this, schemaName, name, type);
-        this.quickList.put(entity.getCondQualifiedName(), entity);
+        this.quickList.put(entity.getQualifiedName(), entity);
         this.propertyChangeSupport.firePropertyChange("quickList", null, null);
         this.changed = true;
     }
@@ -375,8 +365,8 @@ public class Bookmark {
     }
     
     public void removeQuickListEntry(Entity entity) {
-        if (entity != null  && this.quickList.containsKey(entity.getCondQualifiedName())) {
-            this.quickList.remove(entity.getCondQualifiedName());
+        if (entity != null  && this.quickList.containsKey(entity.getQualifiedName())) {
+            this.quickList.remove(entity.getQualifiedName());
             this.propertyChangeSupport.firePropertyChange("quickList", null, null);
             this.changed = true;
         }
@@ -411,7 +401,9 @@ public class Bookmark {
     }
     
     public DatabaseAdapter getAdapter() {
-        return AdapterFactory.getInstance().getAdapter(getType());
+        return this.driver == null 
+                               ? null 
+                               : AdapterFactory.getInstance().getAdapter(this.driver.getType());
     }
 
     public Entity[] getEntitiesForSchema(Schema schema, String type) throws SQLException {
@@ -440,7 +432,7 @@ public class Bookmark {
     }
     
     public boolean isInQuickList(Entity entity) {
-        return this.quickList.containsKey(entity.getCondQualifiedName());
+        return this.quickList.containsKey(entity.getQualifiedName());
     }
     
     /**
@@ -523,12 +515,29 @@ public class Bookmark {
        }
        
        public void setJDBCDriver(JDBCDriver jdbcDriver) {
-               jdbcDriver = BookmarkCollection.getInstance().findDriver(jdbcDriver);
-               setDriver(jdbcDriver.getClassName());
-               setDriverFile(jdbcDriver.getJarFileName());
+               this.driver = BookmarkCollection.getInstance().findDriver(jdbcDriver);
+        this.changed = true;
        }
        
        public JDBCDriver getJDBCDriver() {
-               return BookmarkCollection.getInstance().findDriver(getDriver(), getDriverFile());
+               return this.driver;
+       }
+       public boolean useAllSchemas() {
+               return this.schemaRule == SCHEMA_RULE_USE_ALL;
+       }
+       public boolean useUsernameAsSchema() {
+               return this.schemaRule == SCHEMA_RULE_USE_DEFAULT;
+       }
+       public boolean useSelectedSchemas() {
+               return this.schemaRule == SCHEMA_RULE_USE_SELECTED;
+       }
+       public int getSchemaRule() {
+               return this.schemaRule;
+       }
+       public void setSchemaRule(int schemaRule) {
+        if (this.schemaRule != schemaRule) {
+            this.schemaRule = schemaRule;
+            this.propertyChangeSupport.firePropertyChange("schemas", null, null);
+        }
        }
 }
index 184f790..882f111 100644 (file)
@@ -75,29 +75,18 @@ public class BookmarkCollection {
             bookmark.setUsername(props.getProperty(i + ".username")); //$NON-NLS-1$
             bookmark.setPassword(props.getProperty(i + ".password")); //$NON-NLS-1$
             bookmark.setConnect(props.getProperty(i + ".connect")); //$NON-NLS-1$
-            bookmark.setDriver(props.getProperty(i + ".driver")); //$NON-NLS-1$
             String schema = props.getProperty(i + ".schema"); //$NON-NLS-1$
             if (schema != null) {
                 bookmark.addSchema(schema);
             }
-            String type = props.getProperty(i + ".type"); //$NON-NLS-1$
-            if (type != null) {
-                bookmark.setType(type);
-            } else {
-                bookmark.setType(""); //$NON-NLS-1$
-            }
-            String driverFile = props.getProperty(i + ".driverLocation"); //$NON-NLS-1$
-            if (driverFile != null) {
-                bookmark.setDriverFile(driverFile);
-            } else {
-                bookmark.setDriverFile(""); //$NON-NLS-1$
-            }
-            System.out.println(bookmark.toString());
             if (!bookmark.isEmpty()) {
                 newBookmarks.add(bookmark);
             }
             i++;
-            this.drivers.add(new JDBCDriver(bookmark.getDriver(), driverFile));
+            String driver = props.getProperty(i + ".driver"); //$NON-NLS-1$
+            String driverFile = props.getProperty(i + ".driverLocation"); //$NON-NLS-1$
+            String type = props.getProperty(i + ".type"); //$NON-NLS-1$
+            this.drivers.add(new JDBCDriver(driver, driverFile, type));
         }
         if (overwrite) {
             this.bookmarks = newBookmarks;
@@ -164,11 +153,16 @@ public class BookmarkCollection {
         NodeList nodes = root.getElementsByTagName("jdbcDriver"); //$NON-NLS-1$
         for (int i = 0; i < nodes.getLength(); i++) {
                Element driver = (Element) nodes.item(i);
-               addDriver(new JDBCDriver(
-                       driver.getAttribute("className"),
-                       driver.getAttribute("jarFileName"),
-                       driver.getAttribute("name"),
-                       driver.getAttribute("version")));
+
+               if (!"".equals(driver.getAttribute("type"))) {
+                       addDriver(new JDBCDriver(
+                               driver.getAttribute("className"),
+                               driver.getAttribute("jarFileName"),
+                               driver.getAttribute("type"),
+                               driver.getAttribute("name"),
+                               driver.getAttribute("version")));
+               }
+               
         }
        }
 
@@ -206,18 +200,21 @@ public class BookmarkCollection {
                        bookmark.setAutoCommit(Boolean.TRUE.toString().equalsIgnoreCase(
                                MetaDataXMLInterface.getElementText(column,"autoCommit", "True"))); //$NON-NLS-1$
                        bookmark.setAutoCommitPreference(MetaDataXMLInterface.getElementText(column,"autoCommitPreference", IQuantumConstants.autoCommitTrue)); //$NON-NLS-1$
-            bookmark.addSchema(MetaDataXMLInterface.getElementText(column,"schema")); //$NON-NLS-1$
-            bookmark.setType(MetaDataXMLInterface.getElementText(column,"type")); //$NON-NLS-1$
-            NodeList children = column.getElementsByTagName(Messages.getString("ExportXMLAction.OtherSchemas"));
+                       
+                       backwardCompatibility(bookmark, column);
 
             String driverClassName = MetaDataXMLInterface.getElementText(column,"driver"); //$NON-NLS-1$
             String driverFile = MetaDataXMLInterface.getElementText(column,"driverLocation"); //$NON-NLS-1$
+            String type = MetaDataXMLInterface.getElementText(column,"type"); //$NON-NLS-1$
             
-            bookmark.setJDBCDriver(new JDBCDriver(driverClassName, driverFile));
+            bookmark.setJDBCDriver(new JDBCDriver(driverClassName, driverFile, type));
             
+            NodeList children = column.getElementsByTagName("Other_Schemas");
             if (children.getLength() > 0) {
                 importSchemas((Element) children.item(0), bookmark);
             }
+            
+            
             System.out.println(bookmark.toString());
             if (!bookmark.isEmpty()) {
                 newBookmarks.addElement(bookmark);
@@ -228,17 +225,51 @@ public class BookmarkCollection {
                return newBookmarks;
        }
 
+       /**
+        * Earlier versions of the xml file expected one schema element under the 
+        * bookmark element.  This method sees if it exists.
+        * 
+        * @param bookmark
+        * @param element
+        */
+       private void backwardCompatibility(Bookmark bookmark, Element element) {
+               NodeList children = element.getChildNodes();
+               for (int i = 0, length = children.getLength(); i < length; i++) {
+                       Node node = children.item(i);
+                       if (node.getNodeType() == Node.ELEMENT_NODE && 
+                                       "schema".equals(((Element) node).getTagName())) {
+                               String schema = MetaDataXMLInterface.extractText(element,"");
+                               if (schema != null && schema.trim().length() > 0) {
+                                       bookmark.addSchema(schema);
+                               }
+                       }
+               }
+       }
+
        private void importSchemas(Element otherSchemas, Bookmark bookmark) {
-        Vector vector = MetaDataXMLInterface.getVectorText(otherSchemas, Messages.getString("ExportXMLAction.SchemaName"));
         List list = new ArrayList();
-        for (Iterator i = vector.iterator(); i.hasNext();) {
-            String schemaName = (String) i.next();
-            list.add(new Schema(schemaName));
+        NodeList children = otherSchemas.getChildNodes();
+        for (int i = 0, length = children.getLength(); i < length; i++) {
+               Node node = children.item(i);
+               if (node.getNodeType() == Node.ELEMENT_NODE
+                               && "schema".equalsIgnoreCase(((Element) node).getTagName())) {
+                   list.add(new Schema(
+                               MetaDataXMLInterface.extractText((Element) node, "")));
+               }
+        }
+        
+        String schemaRule = otherSchemas.getAttribute("schemaRule");
+        if ("useAll".equals(schemaRule)) {
+               bookmark.setSchemaRule(Bookmark.SCHEMA_RULE_USE_ALL);
+        } else if ("useDefault".equals(schemaRule)) {
+               bookmark.setSchemaRule(Bookmark.SCHEMA_RULE_USE_DEFAULT);
+        } else {
+               bookmark.setSchemaRule(Bookmark.SCHEMA_RULE_USE_SELECTED);
         }
-        bookmark.setSchemas((Schema[]) list.toArray(new Schema[list.size()]));
+        bookmark.setSchemaSelections((Schema[]) list.toArray(new Schema[list.size()]));
     }
 
-    private void importQuickList(Bookmark bookmark, Element bookmarkElement) {
+       private void importQuickList(Bookmark bookmark, Element bookmarkElement) {
         NodeList quickList = bookmarkElement.getElementsByTagName("quickList");
         for (int j = 0,
             length = (quickList == null) ? 0 : quickList.getLength();
@@ -365,8 +396,8 @@ public class BookmarkCollection {
         * @param driver
         * @param driverFile
         */
-       public JDBCDriver findDriver(String driverClassName, String driverFile) {
-               JDBCDriver temp = new JDBCDriver(driverClassName, driverFile);
+       public JDBCDriver findDriver(String driverClassName, String driverFile, String type) {
+               JDBCDriver temp = new JDBCDriver(driverClassName, driverFile, type);
                return findDriver(temp);
        }
 
index eb4e6cb..0775427 100644 (file)
@@ -100,7 +100,7 @@ class ColumnImpl implements Column, Comparable {
      * @see com.quantum.model.Column#getQualifiedTableName()
      */
     public String getQualifiedTableName() {
-        return this.entity.getCondQualifiedName();
+        return this.entity.getQualifiedName();
     }
     /**
      * @param i
diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/model/DataType.java b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/model/DataType.java
new file mode 100644 (file)
index 0000000..2eb26a0
--- /dev/null
@@ -0,0 +1,28 @@
+package com.quantum.model;
+
+import com.quantum.util.sql.TypesHelper;
+
+
+/**
+ * This class represents a data type.  Columns in databases can be of particular types.
+ * 
+ * @author BC
+ */
+public class DataType {
+       private final int javaType;
+       private final String databaseTypeName;
+
+       public DataType(int javaType, String databaseTypeName) {
+               this.javaType = javaType;
+               this.databaseTypeName = databaseTypeName;
+       }
+       public String getDatabaseTypeName() {
+               return this.databaseTypeName;
+       }
+       public int getJavaType() {
+               return this.javaType;
+       }
+       public String getJavaNameType() {
+               return TypesHelper.getTypeName(this.javaType);
+       }
+}
index b6dee05..5637b55 100644 (file)
@@ -10,7 +10,6 @@ import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
 
-import com.quantum.IQuantumConstants;
 import com.quantum.adapters.DatabaseAdapter;
 import com.quantum.sql.MultiSQLServer;
 import com.quantum.sql.SQLResults;
@@ -28,25 +27,29 @@ public class Database {
         this.databaseAdapter = bookmark.getAdapter();
     }
 
-    private static final String[] ALL_TYPES = { 
-        IQuantumConstants.Table, 
-        IQuantumConstants.View, 
-        IQuantumConstants.Sequence };
+    private static final String[] ALL_TABLE_TYPES = { 
+        Entity.TABLE_TYPE, 
+        Entity.VIEW_TYPE, 
+        Entity.SEQUENCE_TYPE };
         
     private static final List STANDARD_TABLE_TYPES = 
         Collections.synchronizedList(new ArrayList());
         
     static {
-        for (int i = 0, length = (ALL_TYPES == null) ? 0 : ALL_TYPES.length;
+        for (int i = 0, length = (ALL_TABLE_TYPES == null) ? 0 : ALL_TABLE_TYPES.length;
             i < length;
             i++) {
-            STANDARD_TABLE_TYPES.add(ALL_TYPES[i]);
+            STANDARD_TABLE_TYPES.add(ALL_TABLE_TYPES[i]);
         }
     }
     
     public String[] getEntityTypes() 
         throws NotConnectedException, SQLException {
-        return getEntityTypes(this.bookmark.getConnection(), this.bookmark.getSchemas()[0]);
+        return getEntityTypes(this.bookmark.getConnection());
+    }
+    
+    public String getUsername() throws NotConnectedException, SQLException {
+       return getMetaData().getUserName();
     }
 
 
@@ -60,23 +63,18 @@ public class Database {
      * Tables, Views and Sequences.</p>
      * 
      * @param connection
-     * @param schema -
-     *      This parameter is somewhat bogus.  It is used to determine if the
-     *      adapter defines an SQL statement for finding entities of a 
-     *      particular types.  
      * @return
      * @throws SQLException
      */
-    public String[] getEntityTypes(Connection connection, Schema schema) 
-        throws SQLException {
+    public String[] getEntityTypes(Connection connection) throws SQLException {
         
         Set set = new HashSet();
-        if (this.databaseAdapter.getShowTableQuery(schema.getName(), false) != null) {
-            set.add(IQuantumConstants.Table);
-        } else if (this.databaseAdapter.getShowViewQuery(schema.getName(), false) != null) {
-            set.add(IQuantumConstants.View);
-        } else if (this.databaseAdapter.getShowSequenceQuery(schema.getName(), false) != null) {
-            set.add(IQuantumConstants.Sequence);
+        if (this.databaseAdapter.getShowTableQuery(this.bookmark.getUsername()) != null) {
+            set.add(Entity.TABLE_TYPE);
+        } else if (this.databaseAdapter.getShowViewQuery(this.bookmark.getUsername()) != null) {
+            set.add(Entity.VIEW_TYPE);
+        } else if (this.databaseAdapter.getShowSequenceQuery(this.bookmark.getUsername()) != null) {
+            set.add(Entity.SEQUENCE_TYPE);
         }
         
         DatabaseMetaData metaData = connection.getMetaData();
@@ -84,6 +82,7 @@ public class Database {
         while (resultSet.next()) {
             String type = resultSet.getString("TABLE_TYPE");
             if (type != null) {
+               // Informix, in particular, pads this with extra spaces
                 type = type.trim();
             }
             if (STANDARD_TABLE_TYPES.contains(type)) {
@@ -96,8 +95,7 @@ public class Database {
 
     public String getInformation() throws SQLException {
         try {
-            Connection connection = this.bookmark.getConnection();
-            DatabaseMetaData metaData = connection.getMetaData();
+            DatabaseMetaData metaData = getMetaData();
         
             return metaData == null ? null : metaData.getDatabaseProductName() + " " 
                     + metaData.getDatabaseProductVersion();
@@ -137,7 +135,7 @@ public class Database {
         throws SQLException {
         
         List list = new ArrayList();
-        String[] types = (type == null) ? ALL_TYPES : new String[] { type };
+        String[] types = (type == null) ? ALL_TABLE_TYPES : new String[] { type };
             
         for (int i = 0; i < types.length; i++) {
             list.addAll(getEntitiesList(bookmark, connection, types[i], schema));
@@ -196,19 +194,114 @@ public class Database {
         set.close();
         return list;
     }
+    
+    public DataType[] getTypes() throws NotConnectedException, SQLException {
+       DatabaseMetaData metaData = getMetaData();
+       List list = new ArrayList();
+       ResultSet results = metaData.getTypeInfo();
+       try {
+               while (results.next()) {
+                       String name = results.getString("TYPE_NAME");
+                       int type = results.getInt("DATA_TYPE");
+                       list.add(new DataType(type, name));
+               }
+       } finally {
+               results.close();
+       }
+       return (DataType[]) list.toArray(new DataType[list.size()]);
+    }
 
 
-    private String getSQL(Bookmark bookmark, String type, Schema schema) {
+    /**
+        * @return
+        * @throws NotConnectedException
+        * @throws SQLException
+        */
+       private DatabaseMetaData getMetaData() throws NotConnectedException, SQLException {
+               Connection connection = this.bookmark.getConnection();
+       DatabaseMetaData metaData = connection.getMetaData();
+               return metaData;
+       }
+
+       private String getSQL(Bookmark bookmark, String type, Schema schema) {
         if (Entity.TABLE_TYPE.equals(type)) {
-            return this.databaseAdapter.getShowTableQuery(schema.getName(), schema.isDefault());
+            return this.databaseAdapter.getShowTableQuery(schema.getName());
         } else if (Entity.VIEW_TYPE.equals(type)) {
-            return this.databaseAdapter.getShowViewQuery(schema.getName(), schema.isDefault());
+            return this.databaseAdapter.getShowViewQuery(schema.getName());
         } else if (Entity.SEQUENCE_TYPE.equals(type)) {
-            return this.databaseAdapter.getShowSequenceQuery(schema.getName(), schema.isDefault());
+            return this.databaseAdapter.getShowSequenceQuery(schema.getName());
         } else {
             return null;
         }
     }
-    
+       
+       public ForeignKey[] getExportedKeys(String schema, String entityName) 
+                       throws NotConnectedException, SQLException {
+               DatabaseMetaData metaData = getMetaData();
+               List list = new ArrayList();
+               return getForeignKeys(list, metaData.getExportedKeys(null, schema, entityName));
+       }
+
+       public ForeignKey[] getImportedKeys(String schema, String entityName) 
+                       throws NotConnectedException, SQLException {
+               DatabaseMetaData metaData = getMetaData();
+               List list = new ArrayList();
+               return getForeignKeys(list, metaData.getImportedKeys(null, schema, entityName));
+       }
+
+       /**
+        * @param list
+        * @param resultSet
+        * @return
+        * @throws SQLException
+        */
+       private ForeignKey[] getForeignKeys(List list, ResultSet resultSet) throws SQLException {
+               ForeignKeyImpl foreignKey = null;
+               
+               int lowestKeySequence = Integer.MAX_VALUE;
+               try {
+                       while (resultSet.next()) {
+                               int keySequence = resultSet.getInt("KEY_SEQ");
+                               lowestKeySequence = Math.min(lowestKeySequence, keySequence);
+                               
+                               if (keySequence == lowestKeySequence || foreignKey == null) {
+                                       foreignKey = new ForeignKeyImpl();
+                                       list.add(foreignKey);
+                                       foreignKey.setName(resultSet.getString("FK_NAME"));
+                                       foreignKey.setDeleteRule(resultSet.getShort("DELETE_RULE"));
+                                       foreignKey.setForeignEntitySchema(resultSet.getString("FKTABLE_SCHEM"));
+                                       foreignKey.setForeignEntityName(resultSet.getString("FKTABLE_NAME"));
+                                       foreignKey.setLocalEntitySchema(resultSet.getString("PKTABLE_SCHEM"));
+                                       foreignKey.setLocalEntityName(resultSet.getString("PKTABLE_NAME"));
+                               }
+                               
+                               foreignKey.addColumns(
+                                               resultSet.getString("PKCOLUMN_NAME"), 
+                                               resultSet.getString("FKCOLUMN_NAME"));
+                       }
+                       return (ForeignKey[]) list.toArray(new ForeignKey[list.size()]);
+               } finally {
+                       resultSet.close();
+               }
+       }
 
+       /**
+        * @return
+        * @throws SQLException
+        * @throws NotConnectedException
+        */
+       public Schema[] getSchemas() throws NotConnectedException, SQLException {
+               DatabaseMetaData metaData = getMetaData();
+               List list = new ArrayList();
+               ResultSet resultSet = metaData.getSchemas();
+               try {
+                       while (resultSet.next()) {
+                               String schemaName = resultSet.getString("TABLE_SCHEM");
+                               list.add(new Schema(schemaName));
+                       }
+                       return (Schema[]) list.toArray(new Schema[list.size()]);
+               } finally {
+                       resultSet.close();
+               }
+       }
 }
index 845c751..c911730 100644 (file)
@@ -1,11 +1,13 @@
 package com.quantum.model;
 
+import java.sql.SQLException;
+
 import com.quantum.IQuantumConstants;
 
 /**
  * @author BC
  */
-public interface Entity extends BookmarkHolder {
+public interface Entity extends BookmarkHolder, Comparable {
     
     public static final String TABLE_TYPE = IQuantumConstants.Table;
     public static final String VIEW_TYPE = IQuantumConstants.View;
@@ -14,15 +16,14 @@ public interface Entity extends BookmarkHolder {
     public String getName();
     public String getSchema();
     public String getType();
-    public Column[] getColumns();
-    public Index[] getIndexes();
-    public Column getColumn(String columnName);
+    public Column[] getColumns() throws NotConnectedException, SQLException;
+    public Index[] getIndexes() throws NotConnectedException, SQLException;
+    public Column getColumn(String columnName) throws NotConnectedException, SQLException;
     /**
-     * Returns a String with the qualified name of the Entity.
-     * That is, "schema.name". The difference with getQualifiedName() 
-     * is that the schema may be absent if it's not defined in the bookmark
+     * Returns a String with the qualified name of the Entity in the
+     * format "schema.name". 
         */
-       public String getCondQualifiedName();
+       public String getQualifiedName();
     
     /**
      * @return - TRUE if the entity exists in the database<br />
@@ -37,4 +38,7 @@ public interface Entity extends BookmarkHolder {
      * @return
      */
     public String getQuotedTableName();
+    public ForeignKey[] getExportedKeys() throws NotConnectedException, SQLException;
+    public ForeignKey[] getImportedKeys() throws NotConnectedException, SQLException;
+    public ForeignKey[] getReferences() throws NotConnectedException, SQLException;
 }
index a960fbb..8973ffd 100644 (file)
@@ -11,7 +11,6 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
-import com.quantum.adapters.AdapterFactory;
 import com.quantum.adapters.DatabaseAdapter;
 
 /**
@@ -44,11 +43,11 @@ abstract class EntityImpl implements Entity {
     public String getType() {
         return this.type;
     }
-    public String getCondQualifiedName() {
+    public String getQualifiedName() {
         return (this.schema == null || this.schema.length() == 0) ?
             this.name : this.schema + "." + this.name;
     }
-    public Column getColumn(String columnName) {
+    public Column getColumn(String columnName) throws NotConnectedException, SQLException  {
         Column column = null;
         Column[] columns = getColumns();
         for (int i = 0, length = (columns == null) ? 0 : columns.length;
@@ -60,52 +59,50 @@ abstract class EntityImpl implements Entity {
         }
         return column;
     }
-    public Column[] getColumns() {
+    public Column[] getColumns() throws NotConnectedException, SQLException {
         
-        Column[] columns = new Column[0];
+        Map temp = new HashMap();
+        Connection connection = this.bookmark.getConnection();
+        DatabaseMetaData metaData = connection.getMetaData();
+        ResultSet resultSet = metaData.getColumns(null, getSchema(), getName(), null);
         try {
-            // TODO: Some DBs (like DB2) don't support metadata
-            Map temp = new HashMap();
-            Connection connection = this.bookmark.getConnection();
-            DatabaseMetaData metaData = connection.getMetaData();
-            ResultSet resultSet = metaData.getColumns(null, getSchema(), getName(), null);
-            
-            while (resultSet.next()) {
-                ColumnImpl column = new ColumnImpl(
-                    this, 
-                    resultSet.getString("COLUMN_NAME"),
-                    resultSet.getString("TYPE_NAME"),
-                    resultSet.getInt("DATA_TYPE"),
-                    resultSet.getInt("COLUMN_SIZE"),
-                    resultSet.getInt("DECIMAL_DIGITS"),
-                    "YES".equalsIgnoreCase(resultSet.getString("IS_NULLABLE")),
-                    resultSet.getInt("ORDINAL_POSITION"),
-                                       getComments(resultSet.getString("REMARKS"),getCondQualifiedName(), resultSet.getString("COLUMN_NAME"))
-                    );
-                temp.put(column.getName(), column);
-            }
-            resultSet.close();
+               while (resultSet.next()) {
+                   ColumnImpl column = new ColumnImpl(
+                       this, 
+                       resultSet.getString("COLUMN_NAME"),
+                       resultSet.getString("TYPE_NAME"),
+                       resultSet.getInt("DATA_TYPE"),
+                       resultSet.getInt("COLUMN_SIZE"),
+                       resultSet.getInt("DECIMAL_DIGITS"),
+                       "YES".equalsIgnoreCase(resultSet.getString("IS_NULLABLE")),
+                       resultSet.getInt("ORDINAL_POSITION"),
+                                       getComments(resultSet.getString("REMARKS"),getQualifiedName(), resultSet.getString("COLUMN_NAME"))
+                       );
+                   temp.put(column.getName(), column);
+               }
+        } finally {
+               resultSet.close();
+        }
 
-            resultSet = metaData.getPrimaryKeys(null, getSchema(), getName());
-            while (resultSet.next()) {
-                String name = resultSet.getString("COLUMN_NAME");
-                short keySequence = resultSet.getShort("KEY_SEQ");
-                ColumnImpl column = (ColumnImpl) temp.get(name);
-                if (column != null) {
-                    column.setPrimaryKeyOrder(keySequence);
-                }
-            }
-            resultSet.close();
-            
-            List columnList = Collections.synchronizedList(
-                new ArrayList(temp.values()));
-            Collections.sort(columnList);
-            columns = (Column[]) columnList.toArray(new Column[columnList.size()]);
-            
-        } catch (NotConnectedException e) {
-        } catch (SQLException e) {
+        resultSet = metaData.getPrimaryKeys(null, getSchema(), getName());
+        try {
+               while (resultSet.next()) {
+                   String name = resultSet.getString("COLUMN_NAME");
+                   short keySequence = resultSet.getShort("KEY_SEQ");
+                   ColumnImpl column = (ColumnImpl) temp.get(name);
+                   if (column != null) {
+                       column.setPrimaryKeyOrder(keySequence);
+                   }
+               }
+               resultSet.close();
+               
+               List columnList = Collections.synchronizedList(
+                   new ArrayList(temp.values()));
+               Collections.sort(columnList);
+               return (Column[]) columnList.toArray(new Column[columnList.size()]);
+        } finally {
+               resultSet.close();
         }
-        return columns;
     }
     
     /**
@@ -122,7 +119,7 @@ abstract class EntityImpl implements Entity {
                try {
                        Connection con = this.bookmark.getConnection();
                        Statement stmt = con.createStatement();
-                       DatabaseAdapter adapter = AdapterFactory.getInstance().getAdapter(this.bookmark.getType());
+                       DatabaseAdapter adapter = this.bookmark.getAdapter();
                        if (adapter != null && stmt != null && adapter.getCommentsQuery(tableName, columnName) != null) {
                        
                                stmt.execute(adapter.getCommentsQuery(tableName, columnName));
@@ -176,7 +173,42 @@ abstract class EntityImpl implements Entity {
      * @see com.quantum.model.Entity#getQuotedTableName()
      */
     public String getQuotedTableName() {
-        return getBookmark().getAdapter().filterTableName(getCondQualifiedName());
+        return getBookmark().getAdapter().filterTableName(getQualifiedName());
     }
 
+    public ForeignKey[] getExportedKeys() throws SQLException, NotConnectedException {
+       return this.bookmark.getDatabase().getExportedKeys(getSchema(), getName());
+    }
+
+    public ForeignKey[] getImportedKeys() throws SQLException, NotConnectedException {
+       return this.bookmark.getDatabase().getImportedKeys(getSchema(), getName());
+    }
+    public ForeignKey[] getReferences() throws SQLException, NotConnectedException {
+       ForeignKey[] importedKeys = getImportedKeys();
+       ForeignKey[] exportedKeys = getExportedKeys();
+       
+       List list = new ArrayList(); // if we could guarantee JDK 1.4, we'd use LinkedHashSet 
+       for (int i = 0, length = importedKeys == null ? 0 : importedKeys.length; i < length; i++) {
+                       list.add(importedKeys[i]);
+               }
+       for (int i = 0, length = exportedKeys == null ? 0 : exportedKeys.length; i < length; i++) {
+               if (!list.contains(exportedKeys[i])) {
+                       list.add(exportedKeys[i]);
+               }
+               }
+       return (ForeignKey[]) list.toArray(new ForeignKey[list.size()]);
+    }
+    
+    public int compareTo(Object object) {
+               Entity that = (Entity) object;
+               if (that.getQualifiedName() == null && this.getQualifiedName() != null) {
+                       return 1;
+               } else if (this.getQualifiedName() == null && that.getQualifiedName() != null) {
+                       return -1;
+               } else if (this.getQualifiedName() == null && that.getQualifiedName() == null) {
+                       return 0;
+               } else {
+                       return this.getQualifiedName().compareTo(that.getQualifiedName());
+               }
+       }
 }
\ No newline at end of file
index 6a39917..1b1c544 100644 (file)
@@ -3,11 +3,14 @@ package com.quantum.model;
 /**
  * @author BC
  */
-public interface ForeignKey extends Constraint {
+public interface ForeignKey {
     public String getName();
-    public Entity getForeignEntity();
+    public String getLocalEntityName();
+    public String getLocalEntitySchema();
+    public String getLocalEntityQualifiedName();
     public String getForeignEntityName();
     public String getForeignEntitySchema();
+    public String getForeignEntityQualifiedName();
     public int getNumberOfColumns();
     public String getLocalColumnName(int index);
     public String getForeignColumnName(int index);
diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/model/ForeignKeyImpl.java b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/model/ForeignKeyImpl.java
new file mode 100644 (file)
index 0000000..2cc5f3c
--- /dev/null
@@ -0,0 +1,151 @@
+package com.quantum.model;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+
+/**
+ * @author BC
+ */
+public class ForeignKeyImpl implements ForeignKey {
+       
+       private String name;
+       private String localEntityName;
+       private String localEntitySchema;
+       private String foreignEntityName;
+       private String foreignEntitySchema;
+       private List foreignColumns = Collections.synchronizedList(new ArrayList());
+       private List localColumns = Collections.synchronizedList(new ArrayList());
+       private int deleteRule;
+       
+       void addColumns(String localColumnName, String foreignColumnName) {
+               this.foreignColumns.add(foreignColumnName);
+               this.localColumns.add(localColumnName);
+       }
+
+       public int getDeleteRule() {
+               return this.deleteRule;
+       }
+       public void setDeleteRule(int deleteRule) {
+               this.deleteRule = deleteRule;
+       }
+       public String getForeignEntityName() {
+               return this.foreignEntityName;
+       }
+       public void setForeignEntityName(String foreignEntityName) {
+               this.foreignEntityName = foreignEntityName;
+       }
+       public String getForeignEntitySchema() {
+               return this.foreignEntitySchema;
+       }
+       public void setForeignEntitySchema(String foreignEntitySchema) {
+               this.foreignEntitySchema = foreignEntitySchema;
+       }
+       public String getLocalEntityName() {
+               return this.localEntityName;
+       }
+       public void setLocalEntityName(String localEntityName) {
+               this.localEntityName = localEntityName;
+       }
+       public String getLocalEntitySchema() {
+               return this.localEntitySchema;
+       }
+       public void setLocalEntitySchema(String localEntitySchema) {
+               this.localEntitySchema = localEntitySchema;
+       }
+       public String getName() {
+               return this.name;
+       }
+       public void setName(String name) {
+               this.name = name;
+       }
+
+       public int getNumberOfColumns() {
+               return this.localColumns.size();
+       }
+       
+       public boolean equals(Object object) {
+               if (this.getClass() != object.getClass()) {
+                       return false;
+               } else {
+                       ForeignKeyImpl that = (ForeignKeyImpl) object;
+                       if (this.name == null && that.name != null) {
+                               return false;
+                       } else if (this.name != null && !this.name.equals(that.name)) {
+                               return false;
+                       } else if (this.foreignEntitySchema == null && that.foreignEntitySchema != null) {
+                               return false;
+                       } else if (this.foreignEntitySchema != null && !this.foreignEntitySchema.equals(that.foreignEntitySchema)) {
+                               return false;
+                       } else if (this.foreignEntityName == null && that.foreignEntityName != null) {
+                               return false;
+                       } else if (this.foreignEntityName != null && !this.foreignEntityName.equals(that.foreignEntityName)) {
+                               return false;
+                       } else if (this.localEntitySchema == null && that.localEntitySchema != null) {
+                               return false;
+                       } else if (this.localEntitySchema != null && !this.localEntitySchema.equals(that.foreignEntitySchema)) {
+                               return false;
+                       } else if (this.localEntityName == null && that.localEntityName != null) {
+                               return false;
+                       } else if (this.localEntityName != null && !this.localEntityName.equals(that.localEntityName)) {
+                               return false;
+                       } else if (this.deleteRule != that.deleteRule) {
+                               return false;
+                       } else if (this.localColumns.size() != that.localColumns.size() 
+                                       || this.foreignColumns.size() != that.foreignColumns.size()) {
+                               return false;
+                       } else {
+                               boolean result = true;
+                               for (int i = 0, length = this.localColumns.size(); i < length; i++) {
+                                       Object localColumn = this.localColumns.get(i);
+                                       result &= (localColumn != null && localColumn.equals(that.localColumns.get(i)));
+                                       Object foreignColumn = this.foreignColumns.get(i);
+                                       result &= (foreignColumn != null && foreignColumn.equals(that.foreignColumns.get(i)));
+                               }
+                               return result;
+                       }
+                       
+               }
+       }
+       
+       public int hashCode() {
+               int hashCode = 57;
+               if (this.name != null) {
+                       hashCode ^= this.name.hashCode();
+               }
+               if (this.foreignEntitySchema != null) {
+                       hashCode ^= this.foreignEntitySchema.hashCode();
+               }
+               if (this.foreignEntityName != null) {
+                       hashCode ^= this.foreignEntityName.hashCode();
+               }
+               if (this.localEntitySchema != null) {
+                       hashCode ^= this.localEntitySchema.hashCode();
+               }
+               if (this.localEntityName != null) {
+                       hashCode ^= this.localEntityName.hashCode();
+               }
+               hashCode ^= this.deleteRule;
+               for (int i = 0, length = this.localColumns.size(); i < length; i++) {
+                       hashCode ^= this.localColumns.get(i).hashCode();
+                       hashCode ^= this.foreignColumns.get(i).hashCode();
+               }
+               return hashCode;
+       }
+       public String getLocalColumnName(int index) {
+               return (String) this.localColumns.get(index);
+       }
+
+       public String getForeignColumnName(int index) {
+               return (String) this.foreignColumns.get(index);
+       }
+       public String getLocalEntityQualifiedName() {
+               return getLocalEntitySchema() == null ? getLocalEntityName() :
+                       getLocalEntitySchema() + "." + getLocalEntityName();
+       }
+       public String getForeignEntityQualifiedName() {
+               return getForeignEntitySchema() == null ? getForeignEntityName() :
+                       getForeignEntitySchema() + "." + getForeignEntityName();
+       }
+}
index aff0f3c..8f28a75 100644 (file)
@@ -15,15 +15,14 @@ public class JDBCDriver {
        private String version;
        private String className;
        private String jarFileName;
+       private String type;
        private PropertyChangeSupport propertyChangeSupport = new PropertyChangeSupport(this);
        /**
         * @param className
         * @param jarFileName
         */
-       public JDBCDriver(String className, String jarFileName) {
-               super();
-               this.className = className;
-               this.jarFileName = jarFileName;
+       public JDBCDriver(String className, String jarFileName, String type) {
+               this(className, jarFileName, type, null, null);
        }
        /**
         * 
@@ -36,9 +35,10 @@ public class JDBCDriver {
         * @param name
         * @param version
         */
-       public JDBCDriver(String className, String jarFileName, String name, String version) {
+       public JDBCDriver(String className, String jarFileName, String type, String name, String version) {
                this.name = name;
                this.version = version;
+               this.type = type;
                this.className = className;
                this.jarFileName = jarFileName;
        }
@@ -125,6 +125,10 @@ public class JDBCDriver {
                                return false;
                        } else if (this.jarFileName != null && !this.jarFileName.equals(that.jarFileName)) {
                                return false;
+                       } else if (this.type == null && that.type != null) {
+                               return false;
+                       } else if (this.type != null && !this.type.equals(that.type)) {
+                               return false;
                        } else {
                                return true;
                        }
@@ -138,6 +142,9 @@ public class JDBCDriver {
                if (this.jarFileName != null) {
                        hashCode ^= this.jarFileName.hashCode();
                }
+               if (this.type != null) {
+                       hashCode ^= this.type.hashCode();
+               }
                return hashCode;
        }
        
@@ -170,4 +177,20 @@ public class JDBCDriver {
        public void removePropertyChangeListener(String arg0, PropertyChangeListener arg1) {
                this.propertyChangeSupport.removePropertyChangeListener(arg0, arg1);
        }
+       /**
+        * @return Returns the type.
+        */
+       public String getType() {
+               return this.type;
+       }
+       /**
+        * @param type The type to set.
+        */
+       public void setType(String type) {
+               if (type != null && !type.equals(this.type)) {
+                       String original = this.type;
+                       this.type = type;
+                       this.propertyChangeSupport.firePropertyChange("type", original, type);
+               }
+       }
 }
index 154e15b..62d7cd3 100644 (file)
@@ -8,7 +8,7 @@ public class Schema implements Comparable {
     private String name;
     private String displayName;
     private boolean isDefault;
-    
+    private boolean exists = true;
     
     public Schema() {
     }
@@ -27,14 +27,14 @@ public class Schema implements Comparable {
      * @return
      */
     public String getName() {
-        return name;
+        return this.name;
     }
 
     /**
      * @param string
      */
-    public void setName(String string) {
-        name = string;
+    public void setName(String name) {
+        this.name = name;
     }
 
     /**
@@ -67,7 +67,7 @@ public class Schema implements Comparable {
         }
     }
     public int hashCode() {
-        int hashCode = super.hashCode();
+        int hashCode = 51;
         if (this.name != null) {
             hashCode ^= this.name.hashCode();
         }
@@ -82,7 +82,7 @@ public class Schema implements Comparable {
      * @return
      */
     public boolean isDefault() {
-        return isDefault;
+        return this.isDefault;
     }
 
     /**
@@ -96,14 +96,25 @@ public class Schema implements Comparable {
      * @return
      */
     public String getDisplayName() {
-        return displayName;
+        return this.displayName;
     }
 
     /**
      * @param string
      */
-    public void setDisplayName(String string) {
-        displayName = string;
+    public void setDisplayName(String displayName) {
+        this.displayName = displayName;
     }
 
+    public boolean exists() {
+       return this.exists;
+    }
+    
+    void setExists(boolean exists) {
+       this.exists = exists;
+    }
+    
+    public String toString() {
+       return this.displayName == null ? this.name : this.displayName;
+    }
 }
index 161ab0f..cddb0bc 100644 (file)
@@ -2,7 +2,6 @@ package com.quantum.model;
 
 import java.sql.SQLException;
 
-import com.quantum.adapters.AdapterFactory;
 import com.quantum.sql.MultiSQLServer;
 import com.quantum.sql.SQLHelper;
 
@@ -16,8 +15,8 @@ class TableImpl extends EntityImpl implements Table {
         Integer size = null;
         try {
             size = new Integer(SQLHelper.getSize(
-                getBookmark().getConnection(), getCondQualifiedName(), 
-                    AdapterFactory.getInstance().getAdapter(getBookmark().getType())));
+                getBookmark().getConnection(), getQualifiedName(), 
+                    getBookmark().getAdapter()));
         } catch (SQLException e) {
         } catch (ConnectionException e) {
         }
@@ -25,7 +24,7 @@ class TableImpl extends EntityImpl implements Table {
     }
     
     public void deleteAllRows() throws SQLException, ConnectionException {
-        String sql = "DELETE FROM " + getCondQualifiedName();
+        String sql = "DELETE FROM " + getQualifiedName();
                MultiSQLServer.getInstance().execute(getBookmark().getConnection(), sql);
     }
 }
\ No newline at end of file
index 7a49d86..d63ca35 100644 (file)
@@ -2,7 +2,6 @@ package com.quantum.model;
 
 import java.sql.SQLException;
 
-import com.quantum.adapters.AdapterFactory;
 import com.quantum.sql.SQLHelper;
 
 
@@ -15,8 +14,8 @@ class ViewImpl extends EntityImpl implements View {
         Integer size = null;
         try {
             size = new Integer(SQLHelper.getSize(
-                getBookmark().getConnection(), getCondQualifiedName(), 
-                    AdapterFactory.getInstance().getAdapter(getBookmark().getType())));
+                getBookmark().getConnection(), getQualifiedName(), 
+                    getBookmark().getAdapter()));
         } catch (SQLException e) {
         } catch (ConnectionException e) {
         }
index fc282e6..5251fdc 100644 (file)
@@ -1,10 +1,12 @@
 package com.quantum.model.xml;
 
-import com.quantum.Messages;
+import java.sql.SQLException;
+
 import com.quantum.model.Bookmark;
 import com.quantum.model.Column;
 import com.quantum.model.Entity;
 import com.quantum.model.JDBCDriver;
+import com.quantum.model.NotConnectedException;
 import com.quantum.model.Schema;
 import com.quantum.sql.metadata.MetaDataXMLInterface;
 
@@ -34,6 +36,7 @@ public class ModelToXMLConverter {
         Element driverNode = document.createElement("jdbcDriver");
         driverNode.setAttribute("name", jdbcDriver.getName());
         driverNode.setAttribute("version", jdbcDriver.getVersion());
+        driverNode.setAttribute("type", jdbcDriver.getType());
         driverNode.setAttribute("jarFileName", jdbcDriver.getJarFileName());
         driverNode.setAttribute("className", jdbcDriver.getClassName());
         bookmarkRoot.appendChild(driverNode);
@@ -50,18 +53,20 @@ public class ModelToXMLConverter {
                MetaDataXMLInterface.createElementText(bookmark,"autoCommit", b.isAutoCommit() ? "true" : "false"); //$NON-NLS-1$
                MetaDataXMLInterface.createElementText(bookmark,"autoCommitPreference", b.getAutoCommitPreference()); //$NON-NLS-1$
         MetaDataXMLInterface.createElementText(bookmark,"driver", b.getJDBCDriver().getClassName()); //$NON-NLS-1$
-        MetaDataXMLInterface.createElementText(bookmark,"type", b.getType()); //$NON-NLS-1$
+        MetaDataXMLInterface.createElementText(bookmark,"type", b.getJDBCDriver().getType()); //$NON-NLS-1$
                MetaDataXMLInterface.createElementText(bookmark,"driverLocation", b.getJDBCDriver().getJarFileName()); //$NON-NLS-1$
-        Element otherSchemas = (Element) bookmark.appendChild(document.createElement(Messages.getString("ExportXMLAction.OtherSchemas"))); //$NON-NLS-1$
-        Schema[] schemas = b.getSchemas();
-        for (int i = 0, length = (schemas == null) ? 0 : schemas.length;
-            i < length;
-            i++) {
-            if (!schemas[i].isDefault()) {
-                MetaDataXMLInterface.createElementText(
-                    otherSchemas,Messages.getString("ExportXMLAction.SchemaName"), schemas[i].getName()); //$NON-NLS-1$
-            }
+        Element otherSchemas = (Element) bookmark.appendChild(document.createElement("Other_Schemas")); //$NON-NLS-1$
+        otherSchemas.setAttribute("schemaRule", 
+                       b.useAllSchemas() 
+                                       ? "useAll" 
+                                       : b.useUsernameAsSchema() ? "useDefault" : "useSelected");
+        
+        Schema[] schemas = b.getSchemaSelections();
+        for (int i = 0, length = (schemas == null) ? 0 : schemas.length; i < length; i++) {
+            MetaDataXMLInterface.createElementText(
+                otherSchemas,"schema", schemas[i].getName()); //$NON-NLS-1$
         }
+        
         Entity[] quickList = b.getQuickListEntries();
         Element quickListEntity = document.createElement("quickList");
         for (int j = 0, length = (quickList == null) ? 0 : quickList.length;
@@ -85,7 +90,11 @@ public class ModelToXMLConverter {
             element.setAttribute("schema", entity.getSchema());
         }
         if (recurse) {
-            convert(element, entity.getColumns());
+            try {
+                               convert(element, entity.getColumns());
+                       } catch (NotConnectedException e) {
+                       } catch (SQLException e) {
+                       }
         }
         parent.appendChild(element);
     }
index 15c3c57..928a1f0 100644 (file)
@@ -8,6 +8,7 @@ import java.sql.Types;
 import com.quantum.model.Bookmark;
 import com.quantum.model.Column;
 import com.quantum.model.Entity;
+import com.quantum.model.NotConnectedException;
 import com.quantum.model.Schema;
 
 import org.w3c.dom.Document;
@@ -39,12 +40,16 @@ public class TorqueConverter {
         Element table = root.getOwnerDocument().createElement("table");
         table.setAttribute("name", entity.getName());
         
-        Column[] columns = entity.getColumns();
-        for (int i = 0, length = (columns == null) ? 0 : columns.length;
-            i < length;
-            i++) {
-            convert(table, columns[i]);
-        }
+               try {
+                       Column[] columns = entity.getColumns();
+                       for (int i = 0, length = (columns == null) ? 0 : columns.length;
+                   i < length;
+                   i++) {
+                   convert(table, columns[i]);
+               }
+               } catch (NotConnectedException e) {
+               } catch (SQLException e) {
+               }
         
         root.appendChild(table);
     }
index 05156eb..01c9eb6 100644 (file)
@@ -7,7 +7,6 @@ import com.quantum.QuantumPlugin;
 import org.eclipse.jface.preference.FieldEditorPreferencePage;
 import org.eclipse.jface.preference.IPreferenceStore;
 import org.eclipse.jface.preference.IntegerFieldEditor;
-import org.eclipse.jface.preference.StringFieldEditor;
 import org.eclipse.ui.IWorkbench;
 import org.eclipse.ui.IWorkbenchPreferencePage;
 
@@ -43,7 +42,5 @@ implements IWorkbenchPreferencePage {
             getFieldEditorParent());
         queryHistorySize.setValidRange(0, Integer.MAX_VALUE);
         this.addField(queryHistorySize);
-               StringFieldEditor askPasswordString = new StringFieldEditor("askPasswordString", "&Ask for password string:", getFieldEditorParent());
-               this.addField(askPasswordString);
        }
 }
diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/properties/BaseEntityPropertyPage.java b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/properties/BaseEntityPropertyPage.java
new file mode 100644 (file)
index 0000000..c6f3b00
--- /dev/null
@@ -0,0 +1,95 @@
+package com.quantum.properties;
+
+import com.quantum.Messages;
+import com.quantum.QuantumPlugin;
+import com.quantum.model.Entity;
+import com.quantum.model.EntityHolder;
+
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.ui.dialogs.PropertyPage;
+
+/**
+ * @author BC
+ */
+public abstract class BaseEntityPropertyPage extends PropertyPage {
+
+       class BasicContentProvider implements IStructuredContentProvider {
+       
+               public Object[] getElements(Object inputElement) {
+                       return (inputElement instanceof Object[]) ? (Object[]) inputElement : null; 
+               }
+               public void dispose() {
+               }
+               public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+               }
+       }
+    protected Control createContents(Composite parent) {
+
+        Composite composite = new Composite(parent, SWT.NONE);
+        GridLayout layout = new GridLayout();
+        layout.numColumns = 2;
+        composite.setLayout(layout);
+        composite.setLayoutData(new GridData(GridData.FILL_BOTH));
+
+               Label label = new Label(composite, SWT.NONE);
+        label.setText(Messages.getString(BaseEntityPropertyPage.class, "name"));
+
+        Entity entity = getEntity();
+
+        Label name = new Label(composite, SWT.NONE);
+        name.setText(entity.getName());
+
+        label = new Label(composite, SWT.NONE);
+        label.setText(Messages.getString(BaseEntityPropertyPage.class, "schema"));
+
+        Label schema = new Label(composite, SWT.NONE);
+        schema.setText(entity.getSchema());
+        
+        createInformationArea(composite);
+        
+        return composite;
+    }  
+       /**
+        * @param composite
+        */
+       protected void createErrorMessage(Composite composite, Exception e) {
+               Label icon = new Label(composite, SWT.NONE);
+               icon.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING));
+               icon.setImage(QuantumPlugin.getImage("warning.gif"));
+               
+               Label error = new Label(composite, SWT.NONE);
+               error.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING));
+               error.setText(Messages.getString(BaseEntityPropertyPage.class, "error") 
+                               + (e.getMessage() == null ? "" : "\n" + e.getMessage()));
+       }
+
+
+    /**
+        * @param composite
+        */
+       protected abstract void createInformationArea(Composite composite);
+
+       protected Entity getEntity() {
+        Entity entity =
+            ((EntityHolder) getElement()).getEntity();
+        return entity;
+    }
+       /**
+        * @param table
+        */
+       protected void setColumnWidths(Table table) {
+               for (int i = 0, length = table.getColumnCount(); i < length; i++) {
+                   table.getColumn(i).pack();
+               }
+       }
+
+}
+
index 2463376..b4d53ea 100644 (file)
@@ -1,13 +1,5 @@
 package com.quantum.properties;
 
-import com.quantum.IQuantumConstants;
-import com.quantum.adapters.AdapterFactory;
-import com.quantum.adapters.DriverInfo;
-import com.quantum.model.Bookmark;
-import com.quantum.model.BookmarkCollection;
-import com.quantum.model.JDBCDriver;
-import com.quantum.view.bookmark.TreeNode;
-
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.events.SelectionAdapter;
 import org.eclipse.swt.events.SelectionEvent;
@@ -23,6 +15,14 @@ import org.eclipse.swt.widgets.TabItem;
 import org.eclipse.swt.widgets.Text;
 import org.eclipse.ui.dialogs.PropertyPage;
 
+import com.quantum.IQuantumConstants;
+import com.quantum.adapters.AdapterFactory;
+import com.quantum.adapters.DatabaseAdapter;
+import com.quantum.model.Bookmark;
+import com.quantum.model.BookmarkCollection;
+import com.quantum.model.BookmarkHolder;
+import com.quantum.model.JDBCDriver;
+
 public class BookmarkPropertyPage extends PropertyPage {
     
     private Text password;
@@ -35,7 +35,7 @@ public class BookmarkPropertyPage extends PropertyPage {
     
     private Combo type;
        private Combo autoCommit;
-    private DriverInfo[] adapters = AdapterFactory.getInstance().getDriverList();
+    private DatabaseAdapter[] adapters = AdapterFactory.getInstance().getDriverList();
 
     protected Control createContents(Composite parent) {
 
@@ -43,9 +43,7 @@ public class BookmarkPropertyPage extends PropertyPage {
         GridLayout layout = new GridLayout();
         layout.numColumns = 2;
         composite.setLayout(layout);
-        GridData data = new GridData(GridData.FILL);
-        data.grabExcessHorizontalSpace = true;
-        composite.setLayoutData(data);
+        composite.setLayoutData(new GridData(GridData.FILL_BOTH));
 
                Label nameLabel = new Label(composite, SWT.NONE);
         nameLabel.setText("Name:");
@@ -55,16 +53,15 @@ public class BookmarkPropertyPage extends PropertyPage {
         Bookmark bookmark = getBookmark();
         String description = bookmark.getName();
         name.setText(description);
+        name.setLayoutData(
+                       new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING 
+                                       | GridData.VERTICAL_ALIGN_BEGINNING));
         
-        TabFolder tabFolder = new TabFolder(parent, SWT.NONE);
+        TabFolder tabFolder = new TabFolder(composite, SWT.NONE);
         layout = new GridLayout();
         tabFolder.setLayout(layout);
-        data = new GridData(GridData.FILL_BOTH);
-        data.grabExcessHorizontalSpace = true;
-        data.grabExcessVerticalSpace = true;
-        data.verticalAlignment = GridData.FILL;
+        GridData data = new GridData(GridData.FILL_BOTH);
         data.horizontalSpan = 2;
-        data.verticalAlignment = GridData.VERTICAL_ALIGN_BEGINNING;
         tabFolder.setLayoutData(data);
         
         createUserTab(tabFolder);
@@ -77,7 +74,7 @@ public class BookmarkPropertyPage extends PropertyPage {
 
        private Bookmark getBookmark() {
         Bookmark bookmark =
-            ((TreeNode) getElement()).getBookmark();
+            ((BookmarkHolder) getElement()).getBookmark();
         return bookmark;
     }
 
@@ -95,16 +92,6 @@ public class BookmarkPropertyPage extends PropertyPage {
         composite.setLayoutData(data);
         
         Label label = new Label(composite, SWT.NONE);
-        label.setText("Connection URL:");
-
-        this.jdbcURL = new Text(composite, SWT.BORDER);
-        data = new GridData(GridData.FILL);
-        data.horizontalAlignment = GridData.FILL;
-        data.grabExcessHorizontalSpace = true;
-        data.grabExcessHorizontalSpace = true;
-        this.jdbcURL.setLayoutData(data);
-        
-        label = new Label(composite, SWT.NONE);
         label.setText("Driver Name:");
 
         this.driverName = new Text(composite, SWT.BORDER);
@@ -140,7 +127,7 @@ public class BookmarkPropertyPage extends PropertyPage {
 
     private void createUserTab(TabFolder tabFolder) {
         TabItem userTab = new TabItem(tabFolder, SWT.NONE);
-        userTab.setText("User");
+        userTab.setText("Connection");
         
         Composite composite = new Composite(tabFolder, SWT.NONE);
         GridLayout layout = new GridLayout();
@@ -185,6 +172,16 @@ public class BookmarkPropertyPage extends PropertyPage {
             }
         });
         
+        Label label = new Label(composite, SWT.NONE);
+        label.setText("Connection URL:");
+
+        this.jdbcURL = new Text(composite, SWT.BORDER);
+        data = new GridData(GridData.FILL);
+        data.horizontalAlignment = GridData.FILL;
+        data.grabExcessHorizontalSpace = true;
+        data.grabExcessHorizontalSpace = true;
+        this.jdbcURL.setLayoutData(data);
+        
         userTab.setControl(composite);
     }
 
@@ -240,10 +237,9 @@ public class BookmarkPropertyPage extends PropertyPage {
         }
 
         int index = this.type.getSelectionIndex();
-        bookmark.setType(this.adapters[index].getDriverType());
         bookmark.setConnect(this.jdbcURL.getText());
                JDBCDriver jdbcDriver = BookmarkCollection.getInstance().findDriver(
-                               this.driverName.getText(), this.driverPath.getText());
+                               this.driverName.getText(), this.driverPath.getText(), this.adapters[index].getType());
                bookmark.setJDBCDriver(jdbcDriver);
         if (this.autoCommit.getSelectionIndex() >= 0)
                bookmark.setAutoCommitPreference(this.autoCommit.getItem(this.autoCommit.getSelectionIndex()));
@@ -258,7 +254,8 @@ public class BookmarkPropertyPage extends PropertyPage {
 
         this.prompt.setSelection(bookmark.getPromptForPassword());
         this.password.setEditable(!bookmark.getPromptForPassword());
-        this.password.setText(bookmark.getPassword());
+        String password = bookmark.getPassword();
+        this.password.setText(password == null ? "" : password);
         this.userid.setText(bookmark.getUsername());
 
         this.type.select(0);
@@ -267,8 +264,8 @@ public class BookmarkPropertyPage extends PropertyPage {
             length = (adapters == null) ? 0 : adapters.length;
             !done && i < length;
             i++) {
-            if (bookmark.getType() != null && 
-                bookmark.getType().equals(adapters[i].getDriverType())) {
+            if (bookmark.getJDBCDriver().getType() != null && 
+                bookmark.getJDBCDriver().getType().equals(adapters[i].getType())) {
                 this.type.select(i);
                 done = true;
             }
diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/properties/ColumnPropertyPage.java b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/properties/ColumnPropertyPage.java
new file mode 100644 (file)
index 0000000..21d37f9
--- /dev/null
@@ -0,0 +1,114 @@
+package com.quantum.properties;
+
+import java.sql.SQLException;
+
+import com.quantum.Messages;
+import com.quantum.QuantumPlugin;
+import com.quantum.model.Column;
+import com.quantum.model.Entity;
+import com.quantum.model.NotConnectedException;
+
+import org.eclipse.jface.viewers.ILabelProviderListener;
+import org.eclipse.jface.viewers.ITableLabelProvider;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+
+public class ColumnPropertyPage extends BaseEntityPropertyPage {
+    
+       protected void createInformationArea(Composite composite) {
+        if (!Entity.SEQUENCE_TYPE.equals(getEntity().getType())) {
+                       try {
+                               Column[] columns = getEntity().getColumns();
+                       
+                       Table table = new Table(composite, SWT.SINGLE | SWT.FULL_SELECTION | SWT.BORDER);
+                   table.setHeaderVisible(true);
+                   GridData gridData = new GridData(GridData.FILL_BOTH);
+                   gridData.horizontalSpan = 2;
+                   table.setLayoutData(gridData);
+                   for (int i = 0, length = 7; i < length; i++) {
+                       TableColumn column = new TableColumn(table, SWT.NONE);
+                       column.setText(Messages.getString(getClass(), "column" + i));
+                   }
+                       
+                       TableViewer viewer = new TableViewer(table);
+                   setTableContents(viewer, columns);
+                   setColumnWidths(table);
+                       } catch (NotConnectedException e) {
+                               createErrorMessage(composite, e);
+                       } catch (SQLException e) {
+                               createErrorMessage(composite, e);
+                       } catch (RuntimeException e) {
+                               createErrorMessage(composite, e);
+                       }
+        }
+       }
+
+    private void setTableContents(TableViewer viewer, Column[] columns) {
+               viewer.setContentProvider(new BasicContentProvider());
+               
+               viewer.setLabelProvider(new ITableLabelProvider() {
+
+                       public Image getColumnImage(Object element, int columnIndex) {
+                               if (columnIndex == 0 && element instanceof Column) {
+                                       return ((Column) element).isPrimaryKey() 
+                                                       ? QuantumPlugin.getImage("keycolumn.gif") 
+                                                       : QuantumPlugin.getImage("column.gif");
+                               } else {
+                                       return null;
+                               }
+                       }
+                       public String getColumnText(Object element, int columnIndex) {
+                               String label = null;
+                               if (element instanceof Column) {
+                                       Column column = (Column) element;
+                                       switch (columnIndex) {
+                                       case 0: 
+                                               label = column.getName();
+                                               break;
+                                       case 1: 
+                                               label = column.getTypeName();
+                                               break;
+                                       case 2: 
+                                               label = String.valueOf(column.getSize());
+                                               break;
+                                       case 3: 
+                                               label = String.valueOf(column.getNumberOfFractionalDigits());
+                                               break;
+                                       case 4: 
+                                               label = column.isPrimaryKey() 
+                                                       ? Messages.getString(ColumnPropertyPage.class, "true") 
+                                                       : Messages.getString(ColumnPropertyPage.class, "false");
+                                               break;
+                                       case 5: 
+                                               label = column.isNullable() 
+                                                       ? Messages.getString(ColumnPropertyPage.class, "true") 
+                                                       : Messages.getString(ColumnPropertyPage.class, "false");
+                                               break;
+                                       case 6: 
+                                               label = column.getRemarks();
+                                               break;
+                                       default:
+                                       }
+                               }
+                               
+                               return label == null ? "" : label;
+                       }
+                       public void addListener(ILabelProviderListener listener) {
+                       }
+                       public void dispose() {
+                       }
+                       public boolean isLabelProperty(Object element, String property) {
+                               return false;
+                       }
+                       public void removeListener(ILabelProviderListener listener) {
+                       }
+               });
+               
+               viewer.setInput(columns);
+    }
+}
\ No newline at end of file
index e1a0606..322ba0e 100644 (file)
@@ -2,16 +2,27 @@ package com.quantum.properties;
 
 import java.sql.SQLException;
 
+import com.quantum.Messages;
+import com.quantum.QuantumPlugin;
 import com.quantum.model.Bookmark;
+import com.quantum.model.DataType;
 import com.quantum.model.NotConnectedException;
 import com.quantum.view.bookmark.TreeNode;
 
+import org.eclipse.jface.viewers.ILabelProviderListener;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.ITableLabelProvider;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.Viewer;
 import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Image;
 import org.eclipse.swt.layout.GridData;
 import org.eclipse.swt.layout.GridLayout;
 import org.eclipse.swt.widgets.Composite;
 import org.eclipse.swt.widgets.Control;
 import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
 import org.eclipse.ui.dialogs.PropertyPage;
 
 public class DatabaseInformationPropertyPage extends PropertyPage {
@@ -26,28 +37,143 @@ public class DatabaseInformationPropertyPage extends PropertyPage {
         GridLayout layout = new GridLayout();
         layout.numColumns = 2;
         composite.setLayout(layout);
-        GridData data = new GridData(GridData.FILL);
-        data.grabExcessHorizontalSpace = true;
+        GridData data = new GridData(GridData.FILL_BOTH);
         composite.setLayoutData(data);
+        Bookmark bookmark =
+            ((TreeNode) getElement()).getBookmark();
 
+               createDatabaseNameArea(composite, bookmark);
+        createTypesArea(composite, bookmark);
+        
+        return composite;
+       }
+
+       /**
+        * @param composite
+        * @param bookmark
+        */
+       private void createTypesArea(Composite composite, Bookmark bookmark) {
+               if (bookmark.isConnected()) {
+               try {
+                       DataType[] dataTypes = bookmark.getDatabase().getTypes();
+                       Label label = new Label(composite, SWT.NONE);
+                       label.setText(Messages.getString(getClass(), "dataTypes"));
+                       GridData data = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING | GridData.VERTICAL_ALIGN_BEGINNING);
+                       data.horizontalSpan = 2;
+                       label.setLayoutData(data);
+               
+                       Table table = new Table(composite, SWT.SINGLE | SWT.FULL_SELECTION | SWT.BORDER);
+                table.setHeaderVisible(true);
+                GridData gridData = new GridData(GridData.FILL_BOTH);
+                gridData.horizontalSpan = 2;
+                gridData.heightHint = 200;
+                table.setLayoutData(gridData);
+                for (int i = 0, length = 2; i < length; i++) {
+                    TableColumn column = new TableColumn(table, SWT.NONE);
+                    column.setText(Messages.getString(getClass(), "column" + i));
+                }
+                       TableViewer viewer = new TableViewer(table);
+                       viewer.setContentProvider(new IStructuredContentProvider() {
+                                       public Object[] getElements(Object inputElement) {
+                                               if (inputElement instanceof DataType[]) {
+                                                       return (DataType[]) inputElement;
+                                               } else {
+                                                       return null;
+                                               }
+                                       }
+                                       public void dispose() {
+                                       }
+                                       public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+                                       }
+                               });
+                       viewer.setLabelProvider(new ITableLabelProvider() {
+                                       public Image getColumnImage(Object element, int columnIndex) {
+                                               return null;
+                                       }
+                                       public String getColumnText(Object element, int columnIndex) {
+                                               String result = null;
+                                               if (element != null && element instanceof DataType) {
+                                                       DataType dataType = (DataType) element;
+                                                       switch (columnIndex) {
+                                                       case 0:
+                                                               result = dataType.getDatabaseTypeName();
+                                                               break;
+                                                       case 1:
+                                                               result = dataType.getJavaNameType();
+                                                               break;
+                                                       default:
+                                                               result = null;
+                                                       }
+                                               }
+                                               return result == null ? "" : result;
+                                       }
+                                       public void addListener(ILabelProviderListener listener) {
+                                       }
+                                       public void dispose() {
+                                       }
+                                       public boolean isLabelProperty(Object element, String property) {
+                                               return false;
+                                       }
+                                       public void removeListener(ILabelProviderListener listener) {
+                                       }
+                       });
+                       
+                       viewer.setInput(dataTypes);
+                       
+                for (int i = 0, length = table.getColumnCount(); i < length; i++) {
+                    table.getColumn(i).pack();
+                }
+               
+               } catch (SQLException e) {
+                       createErrorMessage(composite, e);
+               } catch (NotConnectedException e) {
+                       createErrorMessage(composite, e);
+               } catch (RuntimeException e) {
+                       createErrorMessage(composite, e);
+                       }
+        }
+       }
+
+       /**
+        * @param composite
+        */
+       private void createErrorMessage(Composite composite, Exception e) {
+               Label icon = new Label(composite, SWT.NONE);
+               icon.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING));
+               icon.setImage(QuantumPlugin.getImage("warning.gif"));
+               
+               Label error = new Label(composite, SWT.NONE);
+               error.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING));
+               error.setText(Messages.getString(getClass(), "error") 
+                               + (e.getMessage() == null ? "" : "\n" + e.getMessage()));
+       }
+
+       /**
+        * @param composite
+        * @param bookmark
+        */
+       private void createDatabaseNameArea(Composite composite, Bookmark bookmark) {
                Label productLabel = new Label(composite, SWT.NONE);
-               productLabel.setText("Product:");
+               productLabel.setText(Messages.getString(getClass(), "product"));
 
         Label productDescriptionLabel = new Label(composite, SWT.NONE);
 
-        Bookmark bookmark =
-            ((TreeNode) getElement()).getBookmark();
         String description = null;
-        try {
-            description = bookmark.getDatabase().getInformation();
-        } catch (NotConnectedException e) {
-        } catch (SQLException e) {
+        if (bookmark.isConnected()) {
+               try {
+                   description = bookmark.getDatabase().getInformation();
+               } catch (NotConnectedException e) {
+                       createErrorMessage(composite, e);
+               } catch (SQLException e) {
+                       createErrorMessage(composite, e);
+               } catch (RuntimeException e) {
+                       createErrorMessage(composite, e);
+               }
         }
         if (description == null) {
-            description = "<unknown>";
+            description = Messages.getString(getClass(), "unknown");
         }
         productDescriptionLabel.setText(description);
-        return composite;
        }
 
        protected void performDefaults() {
diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/properties/EntityPropertyPage.java b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/properties/EntityPropertyPage.java
deleted file mode 100644 (file)
index 6937c1b..0000000
+++ /dev/null
@@ -1,187 +0,0 @@
-package com.quantum.properties;
-
-import com.quantum.model.Column;
-import com.quantum.model.Entity;
-import com.quantum.model.Index;
-import com.quantum.view.bookmark.EntityNode;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.TabFolder;
-import org.eclipse.swt.widgets.TabItem;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.TableColumn;
-import org.eclipse.swt.widgets.TableItem;
-import org.eclipse.ui.dialogs.PropertyPage;
-
-public class EntityPropertyPage extends PropertyPage {
-    
-    protected Control createContents(Composite parent) {
-
-        Composite composite = new Composite(parent, SWT.NONE);
-        GridLayout layout = new GridLayout();
-        layout.numColumns = 2;
-        composite.setLayout(layout);
-        GridData data = new GridData(GridData.FILL);
-        data.grabExcessHorizontalSpace = true;
-        composite.setLayoutData(data);
-
-               Label label = new Label(composite, SWT.NONE);
-        label.setText("Name:");
-
-        Entity entity = getEntity();
-
-        Label name = new Label(composite, SWT.NONE);
-        name.setText(entity.getName());
-
-        label = new Label(composite, SWT.NONE);
-        label.setText("Schema:");
-
-        Label schema = new Label(composite, SWT.NONE);
-        schema.setText(entity.getSchema());
-        
-        if (!Entity.SEQUENCE_TYPE.equals(getEntity().getType())) {
-            TabFolder tabFolder = new TabFolder(parent, SWT.NONE);
-            layout = new GridLayout();
-            tabFolder.setLayout(layout);
-            data = new GridData(GridData.FILL_BOTH);
-            data.grabExcessHorizontalSpace = true;
-            data.grabExcessVerticalSpace = true;
-            data.verticalAlignment = GridData.FILL;
-            data.horizontalSpan = 2;
-            data.verticalAlignment = GridData.VERTICAL_ALIGN_BEGINNING;
-            tabFolder.setLayoutData(data);
-            
-            createColumnsTab(tabFolder);
-            createIndexesTab(tabFolder);
-        }
-        
-        return composite;
-       }
-
-    private Entity getEntity() {
-        Entity entity =
-            ((EntityNode) getElement()).getEntity();
-        return entity;
-    }
-
-    private void createColumnsTab(TabFolder tabFolder) {
-        TabItem columnsTab = new TabItem(tabFolder, SWT.NONE);
-        columnsTab.setText("Columns");
-
-        Table table = new Table(tabFolder, SWT.FULL_SELECTION | SWT.MULTI);
-        table.setLinesVisible(true);
-        table.setHeaderVisible(true);
-
-        GridLayout layout = new GridLayout();
-        layout.marginWidth = 5;
-        layout.marginHeight = 5;
-        table.setLayout(layout);
-        GridData data = new GridData(GridData.FILL);
-        data.horizontalAlignment = GridData.FILL_HORIZONTAL;
-        data.verticalAlignment = GridData.FILL_VERTICAL;
-        data.grabExcessHorizontalSpace = true;
-        data.grabExcessVerticalSpace = true;
-        table.setLayoutData(data);
-
-        String[] columnNames = { "Name", "Type", "Size", "Digits", 
-            "Primary Key", "Nullable", "Remarks" };
-        
-        for (int i = 0, length = columnNames.length; i < length; i++) {
-            TableColumn column = new TableColumn(table, SWT.NONE);
-            column.setText(columnNames[i]);
-        }
-        for (int i = 0, length = columnNames.length; i < length; i++) {
-            table.getColumn(i).pack();
-        }
-
-        Column[] columns = getEntity().getColumns();
-        for (int i = 0, length = columns.length; i < length; i++) {
-            TableItem item = new TableItem(table, SWT.NONE);
-            item.setText(new String[] {
-                columns[i].getName(), 
-                columns[i].getTypeName(),
-                String.valueOf(columns[i].getSize()),
-                columns[i].getNumberOfFractionalDigits() == 0 ? "" :
-                    String.valueOf(columns[i].getNumberOfFractionalDigits()),
-                columns[i].isPrimaryKey() ? "Yes" : "No",
-                columns[i].isNullable() ? "Yes" : "No",
-                columns[i].getRemarks() });
-        }
-
-        for (int i = 0, length = columnNames.length; i < length; i++) {
-            table.getColumn(i).pack();
-        }
-
-        data = new GridData(GridData.FILL);
-        data.horizontalAlignment = GridData.FILL_HORIZONTAL;
-        data.verticalAlignment = GridData.FILL_VERTICAL;
-        data.grabExcessHorizontalSpace = true;
-        data.grabExcessVerticalSpace = true;
-        table.setLayoutData(data);
-
-        columnsTab.setControl(table);
-    }
-
-    private void createIndexesTab(TabFolder tabFolder) {
-        TabItem indexesTab = new TabItem(tabFolder, SWT.NONE);
-        indexesTab.setText("Indexes");
-
-        Table table = new Table(tabFolder, SWT.FULL_SELECTION | SWT.MULTI);
-        table.setLinesVisible(true);
-        table.setHeaderVisible(true);
-
-        GridLayout layout = new GridLayout();
-        layout.marginWidth = 5;
-        layout.marginHeight = 5;
-        table.setLayout(layout);
-        GridData data = new GridData(GridData.FILL);
-        data.horizontalAlignment = GridData.FILL_HORIZONTAL;
-        data.verticalAlignment = GridData.FILL_VERTICAL;
-        data.grabExcessHorizontalSpace = true;
-        data.grabExcessVerticalSpace = true;
-        table.setLayoutData(data);
-
-        String[] columnNames = { "Name", "Column", "Ascending" };
-        
-        for (int i = 0, length = columnNames.length; i < length; i++) {
-            TableColumn column = new TableColumn(table, SWT.NONE);
-            column.setText(columnNames[i]);
-        }
-        for (int i = 0, length = columnNames.length; i < length; i++) {
-            table.getColumn(i).pack();
-        }
-
-        Index[] indexes = getEntity().getIndexes();
-        for (int i = 0, length = indexes.length; i < length; i++) {
-            for (int j = 0, numberOfColumns = indexes[i].getNumberOfColumns(); 
-                j < numberOfColumns; j++) {
-                    
-                TableItem item = new TableItem(table, SWT.NONE);
-                item.setText(new String[] {
-                    j == 0 ? indexes[i].getName() : "", 
-                    indexes[i].getColumnName(j),
-                    indexes[i].isAscending(j) ? "Yes" 
-                        : (indexes[i].isDescending(j)) ? "No" : "" });
-            }
-        }
-
-        for (int i = 0, length = columnNames.length; i < length; i++) {
-            table.getColumn(i).pack();
-        }
-
-        data = new GridData(GridData.FILL);
-        data.horizontalAlignment = GridData.FILL_HORIZONTAL;
-        data.verticalAlignment = GridData.FILL_VERTICAL;
-        data.grabExcessHorizontalSpace = true;
-        data.grabExcessVerticalSpace = true;
-        table.setLayoutData(data);
-
-        indexesTab.setControl(table);
-    }
-        
-}
\ No newline at end of file
diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/properties/IndexPropertyPage.java b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/properties/IndexPropertyPage.java
new file mode 100644 (file)
index 0000000..84719ed
--- /dev/null
@@ -0,0 +1,141 @@
+package com.quantum.properties;
+
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.List;
+
+import com.quantum.Messages;
+import com.quantum.QuantumPlugin;
+import com.quantum.model.Entity;
+import com.quantum.model.Index;
+import com.quantum.model.NotConnectedException;
+
+import org.eclipse.jface.viewers.ILabelProviderListener;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.ITableLabelProvider;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+
+public class IndexPropertyPage extends BaseEntityPropertyPage {
+       
+       class IndexAdaptor {
+               private final Index index;
+               private final int columnNumber;
+               public IndexAdaptor(Index index, int columnNumber) {
+                       this.index = index;
+                       this.columnNumber = columnNumber;
+               }
+               public Index getIndex() {
+                       return this.index;
+               }
+               public int getColumnNumber() {
+                       return this.columnNumber;
+               }
+       }
+    
+       protected void createInformationArea(Composite composite) {
+        if (!Entity.SEQUENCE_TYPE.equals(getEntity().getType())) {
+                       try {
+                               Index[] indeces = getEntity().getIndexes();
+                       
+                       Table table = new Table(composite, SWT.SINGLE | SWT.FULL_SELECTION | SWT.BORDER);
+                   table.setHeaderVisible(true);
+                   GridData gridData = new GridData(GridData.FILL_BOTH);
+                   gridData.horizontalSpan = 2;
+                   table.setLayoutData(gridData);
+                   for (int i = 0, length = 3; i < length; i++) {
+                       TableColumn column = new TableColumn(table, SWT.NONE);
+                       column.setText(Messages.getString(getClass(), "column" + i));
+                   }
+                       
+                       TableViewer viewer = new TableViewer(table);
+                   setTableContents(viewer, indeces);
+                   setColumnWidths(table);
+                       } catch (NotConnectedException e) {
+                               createErrorMessage(composite, e);
+                       } catch (SQLException e) {
+                               createErrorMessage(composite, e);
+                       } catch (RuntimeException e) {
+                               createErrorMessage(composite, e);
+                       }
+        }
+       }
+
+       private void setTableContents(TableViewer viewer, Index[] indeces) {
+               viewer.setContentProvider(new IStructuredContentProvider() {
+                       public Object[] getElements(Object inputElement) {
+                               if (inputElement instanceof Index[]) {
+                                       Index[] indeces = (Index[]) inputElement;
+                                       List list = new ArrayList();
+                                       for (int i = 0, length = indeces == null ? 0 : indeces.length; i < length; i++) {
+                                               for (int j = 0, columns = indeces[i].getNumberOfColumns(); j < columns; j++) {
+                                                       list.add(new IndexAdaptor(indeces[i], j));
+                                               }
+                                       }
+                                       return list.toArray();
+                               } else {
+                                       return null;
+                               }
+                       }
+                       public void dispose() {
+                       }
+                       public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+                       }
+               });
+       
+               viewer.setLabelProvider(new ITableLabelProvider() {
+
+                       public Image getColumnImage(Object element, int columnIndex) {
+                               if (columnIndex == 1 && element instanceof IndexAdaptor) {
+                                       return QuantumPlugin.getImage("column.gif");
+                               } else {
+                                       return null;
+                               }
+                       }
+                       public String getColumnText(Object element, int columnIndex) {
+                               String label = null;
+                               if (element instanceof IndexAdaptor) {
+                                       IndexAdaptor index = (IndexAdaptor) element;
+                                       switch (columnIndex) {
+                                       case 0:
+                                               if (index.getColumnNumber() == 0) {
+                                                       label = index.getIndex().getName();
+                                               }
+                                               break;
+                                       case 1: 
+                                               label = index.getIndex().getColumnName(index.getColumnNumber());
+                                               break;
+                                       case 2: 
+                                               if (index.getIndex().isAscending(index.getColumnNumber())) {
+                                                       label = Messages.getString(IndexPropertyPage.class, "ascending");
+                                               } else if (index.getIndex().isDescending(index.getColumnNumber())) {
+                                                       label = Messages.getString(IndexPropertyPage.class, "descending");
+                                               }
+                                               break;
+                                       default:
+                                       }
+                               }
+                               
+                               return label == null ? "" : label;
+                       }
+                       public void addListener(ILabelProviderListener listener) {
+                       }
+                       public void dispose() {
+                       }
+                       public boolean isLabelProperty(Object element, String property) {
+                               return false;
+                       }
+                       public void removeListener(ILabelProviderListener listener) {
+                       }
+               });
+               
+               
+               viewer.setInput(indeces);
+       }
+}
\ No newline at end of file
diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/properties/ReferencesPropertyPage.java b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/properties/ReferencesPropertyPage.java
new file mode 100644 (file)
index 0000000..75edc3b
--- /dev/null
@@ -0,0 +1,190 @@
+package com.quantum.properties;
+
+import java.sql.DatabaseMetaData;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.List;
+
+import com.quantum.Messages;
+import com.quantum.QuantumPlugin;
+import com.quantum.model.Entity;
+import com.quantum.model.ForeignKey;
+import com.quantum.model.NotConnectedException;
+
+import org.eclipse.jface.viewers.ILabelProviderListener;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.ITableLabelProvider;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+
+public class ReferencesPropertyPage extends BaseEntityPropertyPage {
+       
+       class ColumnDetailsAdaptor {
+               private final int columnNumber;
+               private final ForeignKey foreignKey;
+
+               public ColumnDetailsAdaptor(ForeignKey foreignKey, int columnNumber) {
+                       this.foreignKey = foreignKey;
+                       this.columnNumber = columnNumber;
+               }
+               public int getColumnNumber() {
+                       return this.columnNumber;
+               }
+               public ForeignKey getForeignKey() {
+                       return this.foreignKey;
+               }
+       }
+    
+       class TableDetailsAdaptor {
+               private final ForeignKey foreignKey;
+
+               public TableDetailsAdaptor(ForeignKey foreignKey) {
+                       this.foreignKey = foreignKey;
+               }
+               public ForeignKey getForeignKey() {
+                       return this.foreignKey;
+               }
+       }
+    
+       protected void createInformationArea(Composite composite) {
+        if (!Entity.SEQUENCE_TYPE.equals(getEntity().getType())) {
+                       try {
+                               ForeignKey[] references = getEntity().getReferences();
+               
+                       Table table = new Table(composite, SWT.SINGLE | SWT.FULL_SELECTION | SWT.BORDER);
+                   table.setHeaderVisible(true);
+                   GridData gridData = new GridData(GridData.FILL_BOTH);
+                   gridData.horizontalSpan = 2;
+                   table.setLayoutData(gridData);
+                   for (int i = 0, length = 4; i < length; i++) {
+                       TableColumn column = new TableColumn(table, SWT.NONE);
+                       column.setText(Messages.getString(getClass(), "column" + i));
+                   }
+                       
+                       TableViewer viewer = new TableViewer(table);
+                   setTableContents(viewer, references);
+                   setColumnWidths(table);
+                       } catch (NotConnectedException e) {
+                               createErrorMessage(composite, e);
+                       } catch (SQLException e) {
+                               createErrorMessage(composite, e);
+                       } catch (RuntimeException e) {
+                               createErrorMessage(composite, e);
+                       }
+        }
+       }
+
+       /**
+        * @param viewer
+        */
+       private void setTableContents(TableViewer viewer, ForeignKey[] references) {
+               viewer.setContentProvider(new IStructuredContentProvider() {
+
+                       public Object[] getElements(Object inputElement) {
+                               List list = new ArrayList();
+                               if (inputElement instanceof ForeignKey[]) {
+                                       ForeignKey[] keys = (ForeignKey[]) inputElement;
+                                       for (int i = 0, length = keys == null ? 0
+                                                       : keys.length; i < length; i++) {
+                                               list.add(new TableDetailsAdaptor(keys[i]));
+                                               for (int j = 0, columns = keys[i].getNumberOfColumns(); j < columns; j++) {
+                                                       list.add(new ColumnDetailsAdaptor(keys[i], j));
+                                               }
+                                       }
+                               }
+                               return list.toArray();
+                       }
+                       public void dispose() {
+                       }
+                       public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+                       }
+               });
+               
+               viewer.setLabelProvider(new ITableLabelProvider() {
+
+                       public Image getColumnImage(Object element, int columnIndex) {
+                               if ((columnIndex == 1 || columnIndex == 2) 
+                                               && element instanceof ColumnDetailsAdaptor) {
+                                       return QuantumPlugin.getImage("column.gif");
+                               } else if ((columnIndex == 1 || columnIndex == 2) 
+                                               && element instanceof TableDetailsAdaptor) {
+                                       return QuantumPlugin.getImage("bigtable.gif");
+                               } else if ((columnIndex == 0) 
+                                               && element instanceof TableDetailsAdaptor) {
+                                       return QuantumPlugin.getImage("foreignkey.gif");
+                               } else {
+                                       return null;
+                               }
+                       }
+                       public String getColumnText(Object element, int columnIndex) {
+                               String label = null;
+                               if (element instanceof TableDetailsAdaptor) {
+                                       label = getColumnText((TableDetailsAdaptor) element,  columnIndex);
+                               } else if (element instanceof ColumnDetailsAdaptor) {
+                                               label = getColumnText((ColumnDetailsAdaptor) element,  columnIndex);
+                               }
+                               
+                               return label == null ? "" : label;
+                       }
+                       private String getColumnText(TableDetailsAdaptor adaptor,  int columnIndex) {
+                               switch (columnIndex) {
+                               case 0:
+                                       return adaptor.getForeignKey().getName();
+                               case 1:
+                                       return adaptor.getForeignKey().getLocalEntityQualifiedName();
+                               case 2:
+                                       return adaptor.getForeignKey().getForeignEntityQualifiedName();
+                               case 3:
+                                       ForeignKey key = adaptor.getForeignKey();
+                                       if (key.getDeleteRule() == DatabaseMetaData.importedKeyCascade) {
+                                               return Messages.getString(
+                                                               ReferencesPropertyPage.class, "importedKeyCascade");
+                                       } else if (key.getDeleteRule() == DatabaseMetaData.importedKeyNoAction) {
+                                                       return Messages.getString(
+                                                                       ReferencesPropertyPage.class, "importedKeyNoAction");
+                                       } else if (key.getDeleteRule() == DatabaseMetaData.importedKeyRestrict) {
+                                               return Messages.getString(
+                                                               ReferencesPropertyPage.class, "importedKeyRestrict");
+                                       } else if (key.getDeleteRule() == DatabaseMetaData.importedKeySetDefault) {
+                                               return Messages.getString(
+                                                               ReferencesPropertyPage.class, "importedKeySetDefault");
+                                       } else if (key.getDeleteRule() == DatabaseMetaData.importedKeySetNull) {
+                                               return Messages.getString(
+                                                               ReferencesPropertyPage.class, "importedKeySetNull");
+                                       } else {
+                                               return null;
+                                       }
+                               default:
+                                       return null;
+                               }
+                       }
+                       private String getColumnText(ColumnDetailsAdaptor adaptor,  int columnIndex) {
+                               switch (columnIndex) {
+                               case 1:
+                                       return adaptor.getForeignKey().getLocalColumnName(adaptor.getColumnNumber());
+                               case 2:
+                                       return adaptor.getForeignKey().getForeignColumnName(adaptor.getColumnNumber());
+                               default:
+                                       return null;
+                               }
+                       }
+                       public void addListener(ILabelProviderListener listener) {
+                       }
+                       public void dispose() {
+                       }
+                       public boolean isLabelProperty(Object element, String property) {
+                               return false;
+                       }
+                       public void removeListener(ILabelProviderListener listener) {
+                       }
+               });
+               
+               viewer.setInput(references);
+       }
+}
\ No newline at end of file
index d812f59..049bcb8 100644 (file)
 package com.quantum.properties;
 
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-import java.util.Vector;
-
-import com.quantum.QuantumPlugin;
 import com.quantum.model.Bookmark;
 import com.quantum.model.BookmarkHolder;
-import com.quantum.model.ConnectionException;
-import com.quantum.model.Schema;
-import com.quantum.sql.SQLHelper;
-import com.quantum.ui.dialog.ExceptionDisplayDialog;
-import com.quantum.util.connection.ConnectionUtil;
-import com.quantum.view.bookmark.AddSchemaDialog;
+import com.quantum.view.SchemaSelectionControl;
 
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.viewers.ILabelProviderListener;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.IStructuredContentProvider;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.ITableLabelProvider;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
 import org.eclipse.swt.widgets.Composite;
 import org.eclipse.swt.widgets.Control;
 import org.eclipse.ui.dialogs.PropertyPage;
 
 public class SchemaPropertyPage extends PropertyPage {
-    
-    class ContentProviderImpl implements IStructuredContentProvider {
-        public Object[] getElements(Object inputElement) {
-            List list = new ArrayList((Collection) inputElement);
-            Collections.sort(list);
-            return list.toArray();
-        }
-
-        public void dispose() {
-        }
-
-        public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
-        }
-    }
-    
-    class LabelProviderImpl implements ITableLabelProvider {
-
-        public Image getColumnImage(Object element, int columnIndex) {
-            if (columnIndex == 0) {
-                return QuantumPlugin.getImage("schema.gif");
-            } else {
-                return null;
-            }
-        }
-
-        public String getColumnText(Object element, int columnIndex) {
-            if (columnIndex == 0) {
-                return ((Schema) element).getDisplayName();
-            } else {
-                return null;
-            }
-        }
-
-        public void addListener(ILabelProviderListener listener) {
-        }
-
-        public void dispose() {
-        }
-
-        public boolean isLabelProperty(Object element, String property) {
-            return "displayName".equals(property);
-        }
-
-        public void removeListener(ILabelProviderListener listener) {
-        }
-    }
-    
-    private Set schemas = Collections.synchronizedSet(new HashSet());
-    private TableViewer schemaTable;
-    private Button addButton;
-    private Button removeButton;
-    
-    private ConnectionUtil connectionUtil = new ConnectionUtil();
+       
+       private SchemaSelectionControl control;
     
     protected Control createContents(Composite parent) {
-
-        Composite composite = new Composite(parent, SWT.NONE);
-        GridLayout layout = new GridLayout();
-        layout.numColumns = 2;
-        composite.setLayout(layout);
-        GridData data = new GridData();
-        composite.setLayoutData(data);
-
-        this.schemaTable = new TableViewer(composite, 
-            SWT.FULL_SELECTION | SWT.MULTI | SWT.BORDER);
-            
-        layout = new GridLayout();
-        layout.marginWidth = 5;
-        layout.marginHeight = 5;
-        
-        this.schemaTable.getTable().setLayout(layout);
-        data = new GridData();
-        data.heightHint = 200;
-        data.widthHint = 200;
-//        data.verticalSpan = 2;
-        this.schemaTable.getTable().setLayoutData(data);
-        this.schemaTable.setLabelProvider(new LabelProviderImpl());
-        this.schemaTable.setContentProvider(new ContentProviderImpl());
-        this.schemaTable.setInput(this.schemas);
-        
-        createButtonArea(composite);
-        
-        performDefaults();
-        return composite;
-    }
-
-    private void createButtonArea(Composite composite) {
-        GridLayout layout;
-        GridData data;
-        Composite buttonArea = new Composite(composite, SWT.NONE);
-        layout = new GridLayout();
-        layout.numColumns = 1;
-        buttonArea.setLayout(layout);
-        data = new GridData();
-        data.verticalAlignment = GridData.VERTICAL_ALIGN_BEGINNING;
-        buttonArea.setLayoutData(data);
-        
-        this.addButton = new Button(buttonArea, SWT.NULL);
-        this.addButton.setText("Add");
-        data = new GridData();
-        data.horizontalAlignment = GridData.FILL_HORIZONTAL;
-        data.verticalAlignment = GridData.VERTICAL_ALIGN_BEGINNING;
-        data.widthHint = 60;
-        this.addButton.setLayoutData(data);
-        this.addButton.addSelectionListener(new SelectionAdapter() {
-            public void widgetSelected(SelectionEvent event) {
-                addSchema();
-            }
-        });
-        
-        this.removeButton = new Button(buttonArea, SWT.NULL);
-        this.removeButton.setText("Remove");
-        this.removeButton.setEnabled(false);
-        data = new GridData();
-        data.horizontalAlignment = GridData.FILL_HORIZONTAL;
-        data.verticalAlignment = GridData.VERTICAL_ALIGN_BEGINNING;
-        data.widthHint = 60;
-        this.removeButton.setLayoutData(data);
-        this.removeButton.addSelectionListener(new SelectionAdapter() {
-            public void widgetSelected(SelectionEvent event) {
-                removeSchema(SchemaPropertyPage.this.schemaTable.getSelection());
-            }
-        });
-        
-        this.schemaTable.addSelectionChangedListener(new ISelectionChangedListener() {
-            public void selectionChanged(SelectionChangedEvent event) {
-                SchemaPropertyPage.this.removeButton.setEnabled(
-                    !event.getSelection().isEmpty());
-            }
-        });
-    }
-    
-    private void addSchema() {
-        Bookmark bookmark = getBookmark();
-        boolean isAlreadyConnected = bookmark.isConnected();
-        
-        if (!isAlreadyConnected) {
-            boolean confirmed = MessageDialog.openConfirm(getShell(), "Connect Required", 
-                "We must connect to the database to retrieve schemas.");
-            if (confirmed) {
-                this.connectionUtil.connect(bookmark, getShell());
-            }
-        }
-        
-        try {
-            if (bookmark.isConnected()) {
-                Vector schemas = SQLHelper.getSchemas(bookmark.getConnection());
-                AddSchemaDialog dialog = new AddSchemaDialog(getShell(), schemas);
-                dialog.open();
-                if (dialog.getSelectedSchemas() != null) {
-                    Collection temp = dialog.getSelectedSchemas();
-                    for (Iterator i = temp.iterator(); i.hasNext();) {
-                        String name = (String) i.next();
-                        this.schemas.add(new Schema(name));
-                    }
-                    refreshTable();
-                }
-    
-                if (!isAlreadyConnected) {
-                    bookmark.disconnect();
-                }
-            }
-        } catch (ConnectionException e) {
-            ExceptionDisplayDialog.openError(getShell(), null, null, e);
-        }
-    }
-    
-    private void removeSchema(ISelection selection) {
-        IStructuredSelection structuredSelection = (IStructuredSelection) selection;
-        for (Iterator i = structuredSelection.iterator(); i.hasNext();) {
-            Schema element = (Schema) i.next();
-            this.schemas.remove(element);
-        }
-        refreshTable();
+       return this.control = new SchemaSelectionControl(parent, getBookmark());
     }
 
     private Bookmark getBookmark() {
@@ -227,30 +26,16 @@ public class SchemaPropertyPage extends PropertyPage {
      * @see org.eclipse.jface.preference.PreferencePage#performApply()
      */
     public boolean performOk() {
-        getBookmark().setSchemas((Schema[]) this.schemas.toArray(
-            new Schema[this.schemas.size()]));
+        Bookmark bookmark = getBookmark();
+       bookmark.setSchemaSelections(this.control.getSchemas());
+       bookmark.setSchemaRule(this.control.getSchemaRule());
         return true;
     }
-    /* (non-Javadoc)
-     * @see org.eclipse.jface.preference.PreferencePage#performDefaults()
-     */
+    
     protected void performDefaults() {
         super.performDefaults();
         Bookmark bookmark = getBookmark();
-
-        this.schemas.clear();
-        Schema[] schemas = bookmark.getSchemas();
-        for (int i = 0, length = (schemas == null) ? 0 : schemas.length;
-            i < length;
-            i++) {
-            if (!schemas[i].isDefault()) {
-                this.schemas.add(schemas[i]);
-            }
-        }
-        refreshTable();
-    }
-
-    private void refreshTable() {
-        this.schemaTable.refresh();
+        this.control.setSchemaRule(bookmark.getSchemaRule());
+        this.control.setSchemas(bookmark.getSchemaSelections());
     }
 }
\ No newline at end of file
index 4946bf6..ef233fb 100644 (file)
@@ -87,22 +87,6 @@ public class MultiSQLServer implements ConnectionEstablisher {
         }
     }
 
-    public Vector getSchemas(Connection con) {
-        ResultSet set;
-        Vector schemaList = new Vector();
-        try {
-            DatabaseMetaData meta = con.getMetaData();
-            set = meta.getSchemas();
-            while (set.next()) {
-                schemaList.add(set.getString("TABLE_SCHEM")); //$NON-NLS-1$
-            }
-            set.close();
-        } catch (SQLException e) {
-            LogProxy log = LogProxy.getInstance();
-            log.addText(LogProxy.ERROR, e);
-        }
-        return schemaList;
-    }
     /**
      * Makes a connection to a JDBC driver based on the data from a bookmark
      * @param bookmark - 
@@ -122,17 +106,19 @@ public class MultiSQLServer implements ConnectionEstablisher {
                 bookmark.setPassword(password);
             }
         }
-               Connection con;
+        
         if (password != null) {
-            con = connect(bookmark, password);
+            Connection connection = connect(bookmark, password);
+            if (connection != null) {
+                       // Set the autoCommit state of the bookmark to the default on new connections
+                               bookmark.setAutoCommit(bookmark.getDefaultAutoCommit());
+                               // Set the autoCommit state of the JDBC connection to the bookmark autoCommit statec
+                       setAutoCommit(connection, bookmark.isAutoCommit());
+            }
+               return connection;
         } else {
             return null;
         }
-        // Set the autoCommit state of the bookmark to the default on new connections
-               bookmark.setAutoCommit(bookmark.getDefaultAutoCommit());
-               // Set the autoCommit state of the JDBC connection to the bookmark autoCommit statec
-               setAutoCommit(con, bookmark.isAutoCommit());
-               return con;
         
     }
     private Connection connect(Bookmark bookmark, String password)
index 7a050d1..144a170 100644 (file)
@@ -2,16 +2,12 @@ package com.quantum.sql;
 
 import java.sql.Connection;
 import java.sql.SQLException;
-import java.util.Vector;
 
 import com.quantum.adapters.DatabaseAdapter;
 import com.quantum.view.LogProxy;
 
 public class SQLHelper {
        
-       public static Vector getSchemas(Connection connection) {
-               return MultiSQLServer.getInstance().getSchemas(connection);
-       }
     public static int getSize(Connection connection, String tableName, DatabaseAdapter adapter) throws SQLException {
         SQLResults results = MultiSQLServer.getInstance().execute( 
                 connection, adapter.getCountQuery(tableName));
index c2dc2cb..f583afa 100644 (file)
@@ -53,7 +53,6 @@ public class SQLParser {
                } catch (Throwable e) {
                        e.printStackTrace();
                }
-               System.out.println("Returning"); //$NON-NLS-1$
                Vector result = new Vector();
                result.addAll(groups);
                result.addAll(commands);
index 03cc5e4..85e1545 100644 (file)
@@ -161,7 +161,7 @@ public class MetaDataXMLInterface {
                return value;
        }
 
-       private static String extractText(Element node, String defValue){
+       public static String extractText(Element node, String defValue){
                String value = defValue;
                if (node != null && node.hasChildNodes()) {
                        Node valueNode = node.getFirstChild();
index 3858253..c897771 100644 (file)
@@ -71,7 +71,7 @@ public class ObjectMetaData {
                Vector result = new Vector();
                Vector columnNames = columns.getColumn("COLUMN_NAME"); //$NON-NLS-1$
                for (int i = 0; i < columnNames.size(); i++) {
-                       result.add((String) columnNames.get(i)); 
+                       result.add(columnNames.get(i)); 
                }
                return result;
        }
index e901266..42c6276 100644 (file)
@@ -130,22 +130,12 @@ public class SQLLexx {
                                        p.mark();
                                        // If we have '/*', it's a comment till '*/' found or eof
                                        if (p.peek() == '*') {
-                                               StringBuffer value = new StringBuffer();
-                                               c = p.getNext();
-                                               value.append('/');
-                                               while (!( c == '*' && p.peek() == '/' ) && !p.isDone()) {
-                                                       value.append(c);
-                                                       c = p.getNext();
-                                               }
-                                               if (!p.isDone()){
-                                                       value.append(c);
-                                                       c = p.getNext();
-                                                       value.append(c);        
-                                               }
-                                               tokens.addElement(new Token(Token.COMMENT, value.toString(), offset, offset + value.length()));
+                                               tokens.addElement(tokenizeComment(p, offset));
                                        } else {
                                                // It's not '/*' , so it's a group token
-                                               tokens.addElement(new Token(Token.GROUP, group, offset, offset + 1));
+                                               // BCH ??? what's this business about groups?  
+                                               // Shouldn't '/' be a divide operator?
+                                               tokens.addElement(new Token(Token.SYMBOL, new String(new char[] {c}) /*group*/, offset, offset + 1));
                                                p.reset();
                                        }
                                // Adds SYMBOL token;
@@ -163,4 +153,25 @@ public class SQLLexx {
 //             }
                return tokens;
        }
+       /**
+        * @param tokens
+        * @param p
+        * @param offset
+        */
+       private static Token tokenizeComment(StringPointer p, int offset) {
+               char c;
+               StringBuffer value = new StringBuffer();
+               c = p.getNext();
+               value.append('/');
+               while (!( c == '*' && p.peek() == '/' ) && !p.isDone()) {
+                       value.append(c);
+                       c = p.getNext();
+               }
+               if (!p.isDone()){
+                       value.append(c);
+                       c = p.getNext();
+                       value.append(c);        
+               }
+               return new Token(Token.COMMENT, value.toString(), offset, offset + value.length());
+       }
 }
diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/ui/dialog/AddDriverDialog.java b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/ui/dialog/AddDriverDialog.java
deleted file mode 100644 (file)
index bcab770..0000000
+++ /dev/null
@@ -1,124 +0,0 @@
-package com.quantum.ui.dialog;
-
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.FileDialog;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Text;
-
-import com.quantum.Messages;
-import com.quantum.QuantumPlugin;
-import com.quantum.util.JarUtil;
-
-/**
- * @author BC
- */
-public class AddDriverDialog extends Dialog {
-
-       private FileDialog fileDialog;
-
-       private Text driverFileName;
-       private Text driverClassName;
-
-       
-       /**
-        * @param parentShell
-        */
-       public AddDriverDialog(Shell parentShell) {
-               super(parentShell);
-       }
-
-       protected void configureShell(Shell shell) {
-               super.configureShell(shell);
-               shell.setText(Messages.getString(getClass(), "title"));
-       }
-       
-    /* (non-Javadoc)
-     * Method declared on Dialog
-     */
-    protected Control createDialogArea(Composite parent) {
-       parent.setLayout(new GridLayout());
-        Composite composite = (Composite) super.createDialogArea(parent);
-               GridLayout layout = new GridLayout();
-               composite.setLayout(layout);
-               layout.numColumns = 3;
-               GridData fullHorizontal = new GridData(
-                               GridData.HORIZONTAL_ALIGN_BEGINNING,
-                               GridData.VERTICAL_ALIGN_BEGINNING, 
-                               true, false);
-               composite.setLayoutData(fullHorizontal);
-               
-
-               this.fileDialog = new FileDialog(composite.getShell(), SWT.OPEN);
-               this.fileDialog.setFilterExtensions(new String[] { "*.jar", "*.zip", "*.*" });
-               this.fileDialog.setFilterNames(new String[] {
-                               Messages.getString("BookmarkWizard.JarFiles"),
-                               Messages.getString("BookmarkWizard.ZipFiles"),
-                               Messages.getString("BookmarkWizard.AllFiles") });
-
-               Label label = new Label(composite, SWT.NULL);
-               label.setText(Messages.getString(getClass(), "fileName"));
-               this.driverFileName = new Text(composite, SWT.BORDER | SWT.SINGLE);
-               fullHorizontal = new GridData(
-                               GridData.HORIZONTAL_ALIGN_FILL,
-                               GridData.VERTICAL_ALIGN_BEGINNING, 
-                               true, false);
-               fullHorizontal.widthHint = 150;
-               this.driverFileName.setLayoutData(fullHorizontal);
-
-               Button button = new Button(composite, SWT.PUSH);
-               button.setText(Messages.getString(getClass(), "browse"));
-
-               button.addSelectionListener(new SelectionAdapter() {
-                       public void widgetSelected(SelectionEvent event) {
-                               AddDriverDialog.this.fileDialog.setFilterPath(QuantumPlugin.getDefault()
-                                               .getPreferenceStore().getString(
-                                                               "quantum.dialogs.bookmarkwizard.path"));
-                               String filename = AddDriverDialog.this.fileDialog.open();
-                               if (filename != null) {
-                                       AddDriverDialog.this.driverFileName.setText(filename);
-                                       QuantumPlugin.getDefault().getPreferenceStore().setValue(
-                                                       "quantum.dialogs.bookmarkwizard.path", filename);
-                               }
-                       }
-               });
-
-               label = new Label(composite, SWT.NULL);
-               label.setText(Messages.getString(getClass(), "driverClassName"));
-               this.driverClassName = new Text(composite, SWT.BORDER | SWT.SINGLE);
-               fullHorizontal = new GridData(
-                               GridData.HORIZONTAL_ALIGN_FILL,
-                               GridData.VERTICAL_ALIGN_BEGINNING, 
-                               true, false);
-               fullHorizontal.widthHint = 150;
-               this.driverClassName.setLayoutData(fullHorizontal);
-
-               button = new Button(composite, SWT.PUSH);
-               button.setText(Messages.getString(getClass(), "browse"));
-
-               button.addSelectionListener(new SelectionAdapter() {
-                       public void widgetSelected(SelectionEvent event) {
-                               SimpleSelectionDialog dialog = new SimpleSelectionDialog(
-                                               getShell(), "Select a Driver", JarUtil.getAllDriverNames(
-                                                               getDriverFile()), QuantumPlugin.getImage("class.gif"));
-                               if (dialog.open() == SimpleSelectionDialog.OK) {
-                                       AddDriverDialog.this.driverClassName.setText(
-                                                       dialog.getSelectedElement());
-                               }
-                       }
-               });
-               return composite;
-    }
-    
-    protected String getDriverFile() {
-       return this.driverFileName.getText();
-    }
-}
\ No newline at end of file
index 311b217..ccb1a43 100644 (file)
@@ -1,15 +1,26 @@
 package com.quantum.ui.dialog;
 
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+
 import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
 import org.eclipse.jface.viewers.ILabelProviderListener;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
 import org.eclipse.jface.viewers.IStructuredContentProvider;
 import org.eclipse.jface.viewers.IStructuredSelection;
 import org.eclipse.jface.viewers.ITableLabelProvider;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
 import org.eclipse.jface.viewers.TableViewer;
 import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.swt.SWT;
 import org.eclipse.swt.graphics.Image;
 import org.eclipse.swt.layout.GridData;
 import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
 import org.eclipse.swt.widgets.Composite;
 import org.eclipse.swt.widgets.Control;
 import org.eclipse.swt.widgets.Shell;
@@ -27,7 +38,7 @@ public class SimpleSelectionDialog extends Dialog {
                }
 
                public String getColumnText(Object element, int columnIndex) {
-                       return (String) element;
+                       return element.toString();
                }
 
                public void addListener(ILabelProviderListener listener) {
@@ -61,19 +72,25 @@ public class SimpleSelectionDialog extends Dialog {
        private final String title;
        private TableViewer viewer;
        private final Image image;
-       private final String[] objects;
+       private final Object[] objects;
        
-       private String selectedElement = null;
+       private List selection = Collections.synchronizedList(new ArrayList());
+       private final boolean multipleSelection;
 
        /**
         * @param parentShell
         */
-       protected SimpleSelectionDialog(Shell parentShell, String title, 
-                       String[] objects, Image image) {
+       public SimpleSelectionDialog(Shell parentShell, String title, 
+                       Object[] objects, Image image) {
+               this(parentShell, title, objects, image, false);
+       }
+       public SimpleSelectionDialog(Shell parentShell, String title, 
+                       Object[] objects, Image image, boolean multipleSelection) {
                super(parentShell);
                this.title = title;
                this.objects = objects;
                this.image = image;
+               this.multipleSelection = multipleSelection;
        }
 
     protected void configureShell(Shell shell) {
@@ -91,7 +108,11 @@ public class SimpleSelectionDialog extends Dialog {
         layout.numColumns = 1;
         layout.verticalSpacing = 1;
         
-        this.viewer = new TableViewer(composite);
+        int style = SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL;
+        if (this.multipleSelection) {
+               style |= SWT.MULTI;
+        }
+        this.viewer = new TableViewer(composite, style);
         GridData full = new GridData(GridData.FILL_HORIZONTAL);
         full.widthHint = 200;
         full.heightHint = 50;
@@ -101,27 +122,37 @@ public class SimpleSelectionDialog extends Dialog {
         this.viewer.setContentProvider(new ContentProvider());
 
         this.viewer.setInput(this);
+        
+        this.viewer.addSelectionChangedListener(new ISelectionChangedListener() {
+
+                       public void selectionChanged(SelectionChangedEvent event) {
+                               Button okButton = getButton(IDialogConstants.OK_ID);
+                               okButton.setEnabled(!event.getSelection().isEmpty());
+                       }
+               
+        });
 
         return composite;
     }
     
+       protected void createButtonsForButtonBar(Composite parent) {
+               super.createButtonsForButtonBar(parent);
+               Button okButton = getButton(IDialogConstants.OK_ID);
+               okButton.setEnabled(false);
+       }
        
        protected void okPressed() {
-               
         IStructuredSelection selection = (IStructuredSelection) this.viewer.getSelection();
-        this.selectedElement = (String) selection.getFirstElement();
+        this.selection.clear();
+        for (Iterator i = selection.iterator(); i.hasNext();) {
+                       this.selection.add(i.next());
+               }
         super.okPressed();
        }
        /**
         * @return Returns the selectedElement.
         */
-       public String getSelectedElement() {
-               return this.selectedElement;
-       }
-       /**
-        * @param selectedElement The selectedElement to set.
-        */
-       public void setSelectedElement(String selectedElement) {
-               this.selectedElement = selectedElement;
+       public IStructuredSelection getSelection() {
+               return new StructuredSelection(this.selection);
        }
 }
index c30bdad..2519891 100644 (file)
@@ -24,23 +24,36 @@ public class JarUtil {
        public static Driver loadDriver(String driverFile, String className) {
                Driver result = null;
                try {
-               File file = new File(driverFile);
-               if (file.exists() && file.isFile()) {
-                       URLClassLoader loader = getURLClassLoader(file);
-                       Class driverClass = loader.loadClass(className);
+                       Class driverClass = loadDriverClass(driverFile, className);
+                       if (driverClass != null) {
                    try {
                        result = (Driver) driverClass.newInstance();
                    } catch (ClassCastException e) {
                    }
                }
-               } catch (MalformedURLException e) {
-               } catch (ClassNotFoundException e) {
                } catch (InstantiationException e) {
                } catch (IllegalAccessException e) {
                }
                return result;
        }
        
+       public static Class loadDriverClass(String driverFile, String className) {
+               Class result = null;
+               if (driverFile != null && className != null) {
+                       try {
+                       File file = new File(driverFile);
+                       if (file.exists() && file.isFile()) {
+                               URLClassLoader loader = getURLClassLoader(file);
+                               Class driverClass = loader.loadClass(className);
+                               result = Driver.class.isAssignableFrom(driverClass) ? driverClass : null;
+                       }
+                       } catch (MalformedURLException e) {
+                       } catch (ClassNotFoundException e) {
+                       }
+               }
+               return result;
+       }
+       
        public static String[] getAllDriverNames(String driverFile) {
                List list = new ArrayList();
                try {
index f87f14d..d680939 100644 (file)
@@ -44,7 +44,7 @@ public class StringMatrix {
         */
        public void addMatrixHeader(String header[]){
                        for (int i = 0; i < header.length; i++) {       
-                               String element = (String) header[i];
+                               String element = header[i];
                                this.header.add(element);                       
                        }
        }
index e8b87f6..feed61e 100644 (file)
@@ -2,10 +2,15 @@
 package com.quantum.util.sql;
 
 import java.lang.reflect.Field;
+import java.lang.reflect.Modifier;
 import java.sql.Types;
 
 /**
- * @author holmesbc
+ * This class provides some utilities for working with Types, as well as providing some
+ * support around SQL types that exist in certain versions of the JDK.
+ * 
+ * @author BC Holmes
+ * @see java.lang.Types
  */
 public class TypesHelper {
        
@@ -37,6 +42,14 @@ public class TypesHelper {
        public static final int BLOB = Types.BLOB;
        public static final int CLOB = Types.CLOB;
        public static final int REF = Types.REF;
+       /**
+        * <p>The constant in the Java programming language, somtimes referred to 
+        * as a type code, that identifies the generic SQL type <code>DATALINK</code>.
+        * 
+        * <p>Note: For some reason, some versions of DB2 and/or the DB2 driver use an invalid 
+        * type code for DATALINK.  The correct value should be 70, but DB2/NT 7.01.00 uses
+        * -400.
+        */
        public static final int DATALINK;
        public static final int BOOLEAN;
        
@@ -56,4 +69,22 @@ public class TypesHelper {
                return defaultValue;
        }
 
+       public static String getTypeName(int type) {
+               String name = null;
+               try {
+                       Field[] fields = TypesHelper.class.getFields();
+                       for (int i = 0, length = fields == null ? 0 : fields.length; 
+                                       name == null && i < length; i++) {
+                               if (Modifier.isStatic(fields[i].getModifiers()) 
+                                               && Modifier.isPublic(fields[i].getModifiers()) 
+                                               && fields[i].getType() == Integer.TYPE 
+                                               && type == fields[i].getInt(null)) {
+                                       name = fields[i].getName();
+                               }
+                       }
+               } catch (IllegalAccessException e) {
+               }
+               return name;
+       }
+
 }
index 1f3bacf..fcf6188 100644 (file)
@@ -6,6 +6,8 @@ import java.lang.reflect.Method;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.graphics.FontData;
 import org.eclipse.swt.widgets.FontDialog;
+import org.eclipse.ui.part.ViewPart;
+import org.eclipse.ui.part.WorkbenchPart;
 
 /**
  * This class provides backward compatibility between versions of Eclipse for
@@ -16,6 +18,8 @@ import org.eclipse.swt.widgets.FontDialog;
 public class VersioningHelper {
     
     public static final int ECLIPSE_VERSION_2_1_1 = 2135;
+    public static final int ECLIPSE_VERSION_3_0_RC1 = 3054;
+    public static final int ECLIPSE_VERSION_3_0_RC3 = 3061;
 
     /**
      * Set the font in a FontDialog.  In Eclipse 2.1.1, the 
@@ -46,4 +50,30 @@ public class VersioningHelper {
             // should not happen
         }
     }
+    
+    public static void setPartName(ViewPart viewPart, String partName) {
+        try {
+            if (SWT.getVersion() >= ECLIPSE_VERSION_3_0_RC1) {
+                Method method = WorkbenchPart.class.getDeclaredMethod(
+                    "setPartName", new Class[] { String.class });
+                method.invoke(viewPart, new Object[] {partName});
+            } else {
+                Method method = WorkbenchPart.class.getDeclaredMethod(
+                    "setTitle", new Class[] { FontData.class });
+                method.invoke(method, new Object[] { partName });
+            }
+        } catch (NoSuchMethodException e) {
+            // should not happen
+        } catch (IllegalArgumentException e) {
+            // should not happen
+        } catch (IllegalAccessException e) {
+            // should not happen
+        } catch (InvocationTargetException e) {
+            // should not happen
+        }
+    }
+    
+    public static void main(String[] args) {
+       System.out.println(SWT.getVersion());
+    }
 }
index 27fe957..aa4c29e 100644 (file)
@@ -15,11 +15,9 @@ import org.eclipse.swt.widgets.TableItem;
 
 
 public final class CopyAction extends Action {
-       private final TableView view;
        private final Table table;
        public CopyAction(TableView view, Table table) {
                super();
-               this.view = view;
                this.table = table;
        }
        public void run() {
index 05cd697..c80e75e 100644 (file)
@@ -2,15 +2,30 @@ package com.quantum.view;
 
 import java.beans.PropertyChangeEvent;
 import java.beans.PropertyChangeListener;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
 
+import org.eclipse.jface.viewers.ILabelProviderListener;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.ISelectionProvider;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.ITableLabelProvider;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
 import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.Viewer;
 import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Image;
 import org.eclipse.swt.widgets.Composite;
 import org.eclipse.swt.widgets.Control;
 import org.eclipse.swt.widgets.Table;
 import org.eclipse.swt.widgets.TableColumn;
 
 import com.quantum.Messages;
+import com.quantum.QuantumPlugin;
+import com.quantum.adapters.AdapterFactory;
 import com.quantum.model.BookmarkCollection;
 import com.quantum.model.JDBCDriver;
 
@@ -18,28 +33,91 @@ import com.quantum.model.JDBCDriver;
 /**
  * @author BC
  */
-public class JDBCDriverTableViewer implements PropertyChangeListener {
+public class JDBCDriverTableViewer implements PropertyChangeListener, ISelectionProvider {
 
+       public class LabelProviderImpl implements ITableLabelProvider {
+               public Image getColumnImage(Object element, int columnIndex) {
+                       if (columnIndex == 0) {
+                               return QuantumPlugin.getImage("driver.gif");
+                       } else {
+                               return null;
+                       }
+               }
+               public String getColumnText(Object element, int columnIndex) {
+                       String result = null;
+                       switch (columnIndex) {
+                       case 0: 
+                               result = ((JDBCDriver) element).getName();
+                               break;
+                       case 1: 
+                               result = ((JDBCDriver) element).getClassName();
+                               break;
+                       case 2: 
+                               String type = ((JDBCDriver) element).getType();
+                               result = AdapterFactory.getInstance().getAdapter(type).getDisplayName();
+                               break;
+                       case 3: 
+                               result = ((JDBCDriver) element).getVersion();
+                               break;
+                       case 4: 
+                               result = ((JDBCDriver) element).getJarFileName();
+                               break;
+                       default:
+                       }
+                       return result == null ? "" : result;
+               }
+               public void addListener(ILabelProviderListener listener) {
+               }
+               public void dispose() {
+               }
+               public boolean isLabelProperty(Object element, String property) {
+                       return false;
+               }
+               public void removeListener(ILabelProviderListener listener) {
+               }
+       }
+       
+       public class ContentProviderImpl implements IStructuredContentProvider {
+               public void dispose() {
+               }
+               public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+               }
+               public Object[] getElements(Object inputElement) {
+                       if (inputElement == BookmarkCollection.getInstance()) {
+                               return BookmarkCollection.getInstance().getJDBCDrivers();
+                       } else {
+                               return null;
+                       }
+               }
+       }
+       
        private TableViewer tableViewer;
+       private List listeners = Collections.synchronizedList(new ArrayList());
        
        public JDBCDriverTableViewer(Composite container) {
                Table table = new Table(container, SWT.SINGLE | SWT.FULL_SELECTION | SWT.BORDER);
         table.setHeaderVisible(true);
-        for (int i = 0, length = 4; i < length; i++) {
+        for (int i = 0, length = 5; i < length; i++) {
             TableColumn column = new TableColumn(table, SWT.NONE);
             column.setText(Messages.getString(getClass(), "driverColumn" + i));
         }
                
-        for (int i = 0, length = 4; i < length; i++) {
+        for (int i = 0, length = table.getColumnCount(); i < length; i++) {
             table.getColumn(i).pack();
         }
                
                this.tableViewer = new TableViewer(table);
-               this.tableViewer.setContentProvider(new JDBCDriverContentProvider());
-               this.tableViewer.setLabelProvider(new JDBCDriverLabelProvider());
-               this.tableViewer.setColumnProperties(new String[] { "name", "className", "version", "jarFileName" });
+               this.tableViewer.setContentProvider(new ContentProviderImpl());
+               this.tableViewer.setLabelProvider(new LabelProviderImpl());
+               this.tableViewer.setColumnProperties(new String[] { "name", "className", "driverType", "version", "jarFileName" });
                this.tableViewer.setInput(BookmarkCollection.getInstance());
                
+               this.tableViewer.addSelectionChangedListener(new ISelectionChangedListener(){
+                       public void selectionChanged(SelectionChangedEvent event) {
+                               fireSelectionChangedEvent(event.getSelection());
+                       }
+               });
+               
                BookmarkCollection.getInstance().addPropertyChangeListener(this);
                registerWithAllDrivers();
        }
@@ -49,6 +127,7 @@ public class JDBCDriverTableViewer implements PropertyChangeListener {
        private void registerWithAllDrivers() {
                JDBCDriver[] drivers = BookmarkCollection.getInstance().getJDBCDrivers();
                for (int i = 0, length = drivers == null ? 0 : drivers.length; i < length; i++) {
+                       drivers[i].removePropertyChangeListener(this);
                        drivers[i].addPropertyChangeListener(this);
                }
        }
@@ -58,15 +137,16 @@ public class JDBCDriverTableViewer implements PropertyChangeListener {
        public Control getControl() {
                return this.tableViewer.getControl();
        }
-       /* (non-Javadoc)
-        * @see java.beans.PropertyChangeListener#propertyChange(java.beans.PropertyChangeEvent)
-        */
        public void propertyChange(PropertyChangeEvent event) {
                if ("drivers".equals(event.getPropertyName())) {
                        registerWithAllDrivers();
-                       this.tableViewer.refresh();
+                       if (!this.tableViewer.getControl().isDisposed()) {
+                               this.tableViewer.refresh();
+                       }
                } else if (event.getSource() instanceof JDBCDriver) {
-                       this.tableViewer.refresh(event.getSource());
+                       if (!this.tableViewer.getControl().isDisposed()) {
+                               this.tableViewer.refresh(event.getSource());
+                       }
                }
        }
        
@@ -77,4 +157,26 @@ public class JDBCDriverTableViewer implements PropertyChangeListener {
                }
                BookmarkCollection.getInstance().removePropertyChangeListener(this);
        }
+       public void addSelectionChangedListener(ISelectionChangedListener listener) {
+               if (!this.listeners.contains(listener)) {
+                       this.listeners.add(listener);
+               }
+       }
+       public ISelection getSelection() {
+               return this.tableViewer == null ? null : this.tableViewer.getSelection();
+       }
+       public void removeSelectionChangedListener(ISelectionChangedListener listener) {
+               this.listeners.remove(listener);
+       }
+       public void setSelection(ISelection selection) {
+       }
+       /**
+        * @param selection
+        */
+       protected void fireSelectionChangedEvent(ISelection selection) {
+               for (Iterator i = this.listeners.iterator(); selection != null && i.hasNext();) {
+                       ISelectionChangedListener listener = (ISelectionChangedListener) i.next();
+                       listener.selectionChanged(new SelectionChangedEvent(this, selection));
+               }
+       }
 }
index a8469e7..efdac83 100644 (file)
@@ -7,6 +7,8 @@ import java.util.NoSuchElementException;
 import java.util.Vector;
 
 import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IToolBarManager;
+import org.eclipse.jface.action.Separator;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.custom.ExtendedModifyEvent;
 import org.eclipse.swt.custom.ExtendedModifyListener;
@@ -15,12 +17,9 @@ import org.eclipse.swt.custom.StyledText;
 import org.eclipse.swt.events.SelectionEvent;
 import org.eclipse.swt.events.SelectionListener;
 import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.Image;
 import org.eclipse.swt.layout.GridData;
 import org.eclipse.swt.layout.GridLayout;
 import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.ProgressBar;
 import org.eclipse.swt.widgets.ToolBar;
 import org.eclipse.swt.widgets.ToolItem;
 import org.eclipse.ui.IActionBars;
@@ -38,16 +37,51 @@ import com.quantum.model.NotConnectedException;
 import com.quantum.sql.MultiSQLServer;
 import com.quantum.sql.parser.SQLLexx;
 import com.quantum.sql.parser.Token;
+import com.quantum.util.versioning.VersioningHelper;
 import com.quantum.view.bookmark.BookmarkNode;
 import com.quantum.view.bookmark.BookmarkView;
 
 public class SQLQueryView extends ViewPart {
+       private class ClearAction extends Action {
+               
+               public ClearAction() {
+                       setImageDescriptor(QuantumPlugin.getImageDescriptor("clear.gif"));
+                       setToolTipText(Messages.getString("sqlqueryview.clear"));
+               }
+
+               public void run() {
+                       setQuery("");
+               }
+       }
+
+       private class AutoCommitPreferenceAction extends Action {
+               
+               public AutoCommitPreferenceAction() {
+                       super(Messages.getString("SQLQueryView.AutoCommit"), SWT.CHECK);
+                       setToolTipText(Messages.getString("SQLQueryView.AutoCommit"));
+                       setImageDescriptor(QuantumPlugin.getImageDescriptor("autocommit.gif"));
+               }
+               
+               public void run() {
+                       Connection connection = null; 
+                       try { 
+                               // Get the connection
+                               connection = getBookmark().getConnection();
+                               // If connected (else will throw exception and jump out) switchs the state of the
+                               // autoCommit option of the JDBC driver
+                               MultiSQLServer.getInstance().setAutoCommit(     connection, isChecked());
+            } catch (NotConnectedException e) {
+               //Doesn't matter
+            }
+            // Update the bookmark and the buttons
+                       updateAutoCommitState(getBookmark(), connection);
+               }
+       }
+       
+       
        private ExecuteAction executeAction;
        private ImportQueryAction importQueryAction;
        private ExportQueryAction exportQueryAction;
-       private Label statusImage;
-       private Label status;
-       private ProgressBar progress;
        private StyledText widget;
        private ToolItem autoCommitItem;
        private ToolItem commitItem;
@@ -57,25 +91,23 @@ public class SQLQueryView extends ViewPart {
        private Color COMMENT;
        private Color NUMERIC;
        private Color DEFAULT;
-       private long parseTime = 0;
-       private long fullTime = 0;
+       private AutoCommitPreferenceAction autoCommitPreferenceAction;
+       
        public SQLQueryView() {
                super();
        }
        public void setFocus() {
                
                String title = "Quantum SQL Query Editor";
-               BookmarkNode bookmarkNode = null;
                Bookmark bookmark = null;
                Connection con = null;
                if (BookmarkView.getInstance() != null ) {
-                       bookmarkNode = BookmarkView.getInstance().getCurrentBookmark();
+                       bookmark = getBookmark();
                }
-               if (bookmarkNode != null)
-                       bookmark = bookmarkNode.getBookmark();
                if (bookmark != null) {         
                        title = bookmark.getName() + " (" + title + ")";
-                       setTitle( title );
+                       VersioningHelper.setPartName(this, title);
+//                     setPartName("fred");
                        try {
                                con = bookmark.getConnection();
                        } catch (NotConnectedException e) {
@@ -88,6 +120,17 @@ public class SQLQueryView extends ViewPart {
                widget.setFocus();
 
        }
+       /**
+        * @return
+        */
+       private Bookmark getBookmark() {
+               if (BookmarkView.getInstance() != null ) {
+                       BookmarkNode node = BookmarkView.getInstance().getCurrentBookmark();
+                       return node == null ? null : node.getBookmark();
+               } else {
+                       return null;
+               }
+       }
        public static SQLQueryView getInstance() {
                return (SQLQueryView) QuantumPlugin.getDefault().getView("com.quantum.view.sqlqueryview");
 
@@ -95,6 +138,7 @@ public class SQLQueryView extends ViewPart {
 
        public void createPartControl(org.eclipse.swt.widgets.Composite parent) {
                initActions();
+               
                KEYWORD = new Color(parent.getShell().getDisplay(), 126, 0, 75);
                STRING_LITERAL = new Color(parent.getShell().getDisplay(), 0, 0, 255);
                COMMENT = new Color(parent.getShell().getDisplay(), 88, 148, 64);
@@ -106,49 +150,6 @@ public class SQLQueryView extends ViewPart {
                layout.verticalSpacing = 0;
                main.setLayout(layout);
                ToolBar toolbar = new ToolBar(main, SWT.HORIZONTAL);
-               ToolItem item = new ToolItem(toolbar, SWT.PUSH);
-               item.setImage(QuantumPlugin.getImage("play.gif")); //$NON-NLS-1$
-               item.setToolTipText(Messages.getString("sqlqueryview.executeQuery")); //$NON-NLS-1$
-               item.addSelectionListener(new SelectionListener() {
-                       public void widgetDefaultSelected(SelectionEvent e) {
-                       }
-                       public void widgetSelected(SelectionEvent e) {
-                               executeAction.run();
-                       }
-               });
-               item = new ToolItem(toolbar, SWT.SEPARATOR);
-               item = new ToolItem(toolbar, SWT.PUSH);
-               item.setImage(QuantumPlugin.getImage("import.gif")); //$NON-NLS-1$
-               item.setToolTipText(Messages.getString("sqlqueryview.importQuery")); //$NON-NLS-1$
-               item.addSelectionListener(new SelectionListener() {
-                       public void widgetDefaultSelected(SelectionEvent e) {
-                       }
-                       public void widgetSelected(SelectionEvent e) {
-                               importQueryAction.run();
-                       }
-               });
-               item = new ToolItem(toolbar, SWT.PUSH);
-               item.setImage(QuantumPlugin.getImage("export.gif")); //$NON-NLS-1$
-               item.setToolTipText(Messages.getString("sqlqueryview.exportQuery")); //$NON-NLS-1$
-               item.addSelectionListener(new SelectionListener() {
-                       public void widgetDefaultSelected(SelectionEvent e) {
-                       }
-                       public void widgetSelected(SelectionEvent e) {
-                               exportQueryAction.run();
-                       }
-               });
-               item = new ToolItem(toolbar, SWT.PUSH);
-               item.setImage(QuantumPlugin.getImage("clear.gif")); //$NON-NLS-1$
-               item.setToolTipText(Messages.getString("sqlqueryview.clear")); //$NON-NLS-1$
-               item.addSelectionListener(new SelectionListener() {
-                       public void widgetDefaultSelected(SelectionEvent e) {
-                       }
-                       public void widgetSelected(SelectionEvent e) {
-                               setQuery(""); //$NON-NLS-1$
-                       }
-               });
-
-               item = new ToolItem(toolbar, SWT.SEPARATOR);
 
                commitItem = new ToolItem(toolbar, SWT.PUSH);
                commitItem.setImage(QuantumPlugin.getImage("commit.gif")); //$NON-NLS-1$
@@ -208,9 +209,19 @@ public class SQLQueryView extends ViewPart {
                                
                        }
                });
-               BookmarkNode node = BookmarkView.getInstance().getCurrentBookmark();
-               if (node == null) autoCommitItem.setSelection(true); 
-               else autoCommitItem.setSelection(node.getBookmark().isAutoCommit());
+
+               // TODO: BCH -- this is causing some problems during start-up
+               Bookmark bookmark = null;
+               try {
+                       bookmark = getBookmark();
+               } catch (NullPointerException e) {
+               }
+               
+               if (bookmark == null) {
+                       autoCommitItem.setSelection(true); 
+               } else {
+                       autoCommitItem.setSelection(bookmark.isAutoCommit());
+               }
                if (autoCommitItem.getSelection()) {
                        commitItem.setEnabled(false);
                        rollbackItem.setEnabled(false);
@@ -236,32 +247,6 @@ public class SQLQueryView extends ViewPart {
                gridData.grabExcessVerticalSpace = true;
                widget.setLayoutData(gridData);
 
-               Composite bottomStatus = new Composite(main, SWT.NONE);
-               gridData = new GridData();
-               gridData.horizontalAlignment = GridData.FILL;
-               gridData.grabExcessHorizontalSpace = true;
-               bottomStatus.setLayoutData(gridData);
-               
-               GridLayout horizontal = new GridLayout(3, false);
-               layout.horizontalSpacing = 0;
-               layout.verticalSpacing = 0;
-               layout.marginHeight = 0;
-               layout.marginWidth = 0;
-               bottomStatus.setLayout(horizontal);
-
-               statusImage = new Label(bottomStatus, SWT.NONE);
-               status = new Label(bottomStatus, SWT.NONE);
-               gridData = new GridData();
-               gridData.horizontalAlignment = GridData.FILL;
-               gridData.grabExcessHorizontalSpace = true;
-               status.setLayoutData(gridData);
-
-               progress = new ProgressBar(bottomStatus, SWT.HORIZONTAL);
-
-               status.setText(Messages.getString("sqlqueryview.done")); //$NON-NLS-1$
-               statusImage.setImage(QuantumPlugin.getImage("success.gif")); //$NON-NLS-1$
-               progress.setMinimum(0);
-        
         IKeyBindingService keyBindingService = getSite().getKeyBindingService();
         // TODO: check the version numbers for this method
         keyBindingService.setScopes(new String[] {
@@ -275,14 +260,14 @@ public class SQLQueryView extends ViewPart {
         * Sets the state of the "Commit", "Rollback" and "autoCommit" buttons
         * to reflect the situation in the connection
         */
-       protected void updateAutoCommitState(Bookmark bookmark, Connection con) {
+       protected void updateAutoCommitState(Bookmark bookmark, Connection connection) {
                boolean autoCommit = true;
                // Calculate the state of the autoCommit option
-               if (con != null)
+               if (connection != null)
                {
                        // If we have a connection, the autoCommit state is that of the connection
                        try {
-                               autoCommit = con.getAutoCommit();
+                               autoCommit = connection.getAutoCommit();
                        } catch (SQLException e) {
                                // Doesn't matter, we take default
                        }
@@ -294,6 +279,7 @@ public class SQLQueryView extends ViewPart {
                if (bookmark != null) bookmark.setAutoCommit(autoCommit);
                // Set the state of the buttons to the correct autoCommit state
                autoCommitItem.setSelection(autoCommit);
+               this.autoCommitPreferenceAction.setChecked(autoCommit);
                if (autoCommitItem.getSelection()) {
                        commitItem.setEnabled(false);
                        rollbackItem.setEnabled(false);
@@ -302,30 +288,30 @@ public class SQLQueryView extends ViewPart {
                        rollbackItem.setEnabled(true);
                }
        }
-       public void setProgress(int increment, int max) {
-               progress.setMaximum(max);
-               progress.setSelection(increment);
-       }
-       
        private void initActions() {
+
                executeAction = new ExecuteAction();
                executeAction.init(this);
-               importQueryAction = new ImportQueryAction();
-               importQueryAction.init(this);
-               exportQueryAction = new ExportQueryAction();
-               exportQueryAction.init(this);
-       }
 
-       public void setStatus(String text) {
-               statusImage.setImage(null);
-               status.setText(text);
+               IToolBarManager toolBar = getViewSite().getActionBars().getToolBarManager();
+               toolBar.add(this.executeAction);
+//             toolBar.add(this.importQueryAction);
+//             toolBar.add(this.exportQueryAction);
+               
+               toolBar.add(new ClearAction());
+               
+        IActionBars actionBars = getViewSite().getActionBars();
+               this.importQueryAction = new ImportQueryAction();
+               this.importQueryAction.init(this);
+        actionBars.getMenuManager().add(this.importQueryAction);
+        this.exportQueryAction = new ExportQueryAction();
+        this.exportQueryAction.init(this);
+        actionBars.getMenuManager().add(this.exportQueryAction);
+        actionBars.getMenuManager().add(new Separator());
+        this.autoCommitPreferenceAction = new AutoCommitPreferenceAction();
+        actionBars.getMenuManager().add(this.autoCommitPreferenceAction);
        }
 
-       public void setStatus(Image img, String text) {
-               statusImage.setImage(img);
-               status.setText(text);
-       }
-       
        public String getQuery() {
                return widget.getText();
        }
@@ -404,9 +390,7 @@ public class SQLQueryView extends ViewPart {
                                        //int dirtyStart = request.start;
                                        //int dirtyEnd = request.start + request.length;
                                        StyleRange styleRange;
-                                       long startTime = System.currentTimeMillis();
                                        Vector tokens = SQLLexx.parse(text);
-                                       long subTime = System.currentTimeMillis();
                                        Vector styles = new Vector();
                                        int min = Integer.MAX_VALUE;
                                        int max = 0;
@@ -462,9 +446,6 @@ public class SQLQueryView extends ViewPart {
                                        if (max >= 0 && ranges.length > 0) {
                                                setStyles(ranges, min, max - min);
                                        }
-                                       long endTime = System.currentTimeMillis();
-                                       parseTime = subTime - startTime;
-                                       fullTime = endTime - startTime;
                                } catch (NoSuchElementException e) {
                                        // ignore a missing request
                                } catch (InterruptedException e) {
diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/SchemaSelectionControl.java b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/SchemaSelectionControl.java
new file mode 100644 (file)
index 0000000..f18c3b9
--- /dev/null
@@ -0,0 +1,343 @@
+package com.quantum.view;
+
+import java.beans.PropertyChangeListener;
+import java.beans.PropertyChangeSupport;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+import com.quantum.Messages;
+import com.quantum.QuantumPlugin;
+import com.quantum.model.Bookmark;
+import com.quantum.model.ConnectionException;
+import com.quantum.model.NotConnectedException;
+import com.quantum.model.Schema;
+import com.quantum.ui.dialog.ExceptionDisplayDialog;
+import com.quantum.ui.dialog.SimpleSelectionDialog;
+import com.quantum.util.connection.ConnectionUtil;
+
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.viewers.ILabelProviderListener;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.ITableLabelProvider;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+
+
+/**
+ * @author BC
+ */
+public class SchemaSelectionControl extends Composite {
+       
+    class ContentProviderImpl implements IStructuredContentProvider {
+        public Object[] getElements(Object inputElement) {
+            List list = new ArrayList((Collection) inputElement);
+            Collections.sort(list);
+            return list.toArray();
+        }
+
+        public void dispose() {
+        }
+
+        public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+        }
+    }
+    
+    class LabelProviderImpl implements ITableLabelProvider {
+
+        public Image getColumnImage(Object element, int columnIndex) {
+            if (columnIndex == 0) {
+                return QuantumPlugin.getImage("schema.gif");
+            } else {
+                return null;
+            }
+        }
+
+        public String getColumnText(Object element, int columnIndex) {
+            if (columnIndex == 0) {
+                return ((Schema) element).getDisplayName();
+            } else {
+                return null;
+            }
+        }
+
+        public void addListener(ILabelProviderListener listener) {
+        }
+
+        public void dispose() {
+        }
+
+        public boolean isLabelProperty(Object element, String property) {
+            return "displayName".equals(property);
+        }
+
+        public void removeListener(ILabelProviderListener listener) {
+        }
+    }
+    
+       
+    private final Bookmark bookmarkForConnection;
+    private ConnectionUtil connectionUtil = new ConnectionUtil();
+       private Set schemas = Collections.synchronizedSet(new HashSet());
+       private TableViewer schemaTable;
+       private Button useAllSchemasButton;
+       
+       private int schemaRule;
+       
+       private PropertyChangeSupport propertyChangeSupport = new PropertyChangeSupport(this);
+       private Button useUsernameAsSchemaButton;
+       private Button useSelectedSchemasButton;
+       private Button removeButton;
+       private Button addButton;
+
+       /**
+        * @param parent
+        * @param style
+        */
+       public SchemaSelectionControl(Composite parent, Bookmark bookmarkForConnection) {
+               super(parent, SWT.NONE);
+               this.bookmarkForConnection = bookmarkForConnection;
+               
+               Schema[] schemas = bookmarkForConnection.getSchemaSelections();
+               this.schemas.addAll(Arrays.asList(schemas));
+               this.schemaRule = this.bookmarkForConnection.getSchemaRule();
+               createContents();
+       }
+
+       protected void createContents() {
+
+        GridLayout layout = new GridLayout();
+        layout.numColumns = 1;
+        setLayout(layout);
+        GridData data = new GridData(GridData.FILL_BOTH);
+        setLayoutData(data);
+
+        this.useAllSchemasButton = new Button(this, SWT.RADIO);
+        this.useAllSchemasButton.setText(Messages.getString(getClass(), "useAllSchemas")); //$NON-NLS-1$
+               this.useAllSchemasButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+               this.useAllSchemasButton.addSelectionListener(new SelectionAdapter() {
+                       public void widgetSelected(SelectionEvent event) {
+                               setSchemaRule(Bookmark.SCHEMA_RULE_USE_ALL);
+                               updateControls();
+                       }
+               });
+               
+        this.useUsernameAsSchemaButton = new Button(this, SWT.RADIO);
+        this.useUsernameAsSchemaButton.setText(Messages.getString(getClass(), "useUsernameAsSchema")); //$NON-NLS-1$
+        this.useUsernameAsSchemaButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+               this.useUsernameAsSchemaButton.addSelectionListener(new SelectionAdapter() {
+                       public void widgetSelected(SelectionEvent event) {
+                               setSchemaRule(Bookmark.SCHEMA_RULE_USE_DEFAULT);
+                               updateControls();
+                       }
+               });
+               
+        this.useSelectedSchemasButton = new Button(this, SWT.RADIO);
+        this.useSelectedSchemasButton.setText(Messages.getString(getClass(), "useSelectedSchemas")); //$NON-NLS-1$
+        this.useSelectedSchemasButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+               this.useSelectedSchemasButton.addSelectionListener(new SelectionAdapter() {
+                       public void widgetSelected(SelectionEvent event) {
+                               setSchemaRule(Bookmark.SCHEMA_RULE_USE_SELECTED);
+                               updateControls();
+                       }
+               });
+               
+               Composite composite = new Composite(this, SWT.NONE);
+        layout = new GridLayout();
+        layout.numColumns = 2;
+        composite.setLayout(layout);
+        data = new GridData(GridData.FILL_BOTH);
+        composite.setLayoutData(data);
+               
+        this.schemaTable = new TableViewer(composite, 
+                                           SWT.FULL_SELECTION | SWT.MULTI | SWT.BORDER);
+               layout = new GridLayout();
+        layout.marginWidth = 5;
+        layout.marginHeight = 5;
+        
+        this.schemaTable.getTable().setLayout(layout);
+        data = new GridData(GridData.FILL_BOTH);
+        this.schemaTable.getTable().setLayoutData(data);
+        this.schemaTable.setLabelProvider(new LabelProviderImpl());
+        this.schemaTable.setContentProvider(new ContentProviderImpl());
+        this.schemaTable.setInput(this.schemas);
+        
+        createButtonArea(composite);
+        
+        updateControls();
+    }
+       
+       private void updateControls() {
+               this.useAllSchemasButton.setSelection(this.schemaRule == Bookmark.SCHEMA_RULE_USE_ALL);
+               this.useUsernameAsSchemaButton.setSelection(this.schemaRule == Bookmark.SCHEMA_RULE_USE_DEFAULT);
+               
+               boolean enabled = (this.schemaRule != Bookmark.SCHEMA_RULE_USE_ALL
+                               && this.schemaRule != Bookmark.SCHEMA_RULE_USE_DEFAULT);
+
+               this.useSelectedSchemasButton.setSelection(enabled);
+        this.schemaTable.getControl().setEnabled(enabled);
+        
+        this.addButton.setEnabled(enabled);
+        this.removeButton.setEnabled(
+                       enabled && !this.schemaTable.getSelection().isEmpty());
+       }
+
+    private void createButtonArea(Composite composite) {
+        Composite buttonArea = new Composite(composite, SWT.NONE);
+        GridLayout layout = new GridLayout();
+        layout.numColumns = 1;
+        buttonArea.setLayout(layout);
+        GridData data = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING | GridData.VERTICAL_ALIGN_BEGINNING);
+        buttonArea.setLayoutData(data);
+        
+        this.addButton = new Button(buttonArea, SWT.NULL);
+        this.addButton.setText("Add");
+        data = new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING);
+        this.addButton.setLayoutData(data);
+        this.addButton.addSelectionListener(new SelectionAdapter() {
+            public void widgetSelected(SelectionEvent event) {
+                addSchema();
+            }
+        });
+        
+        this.removeButton = new Button(buttonArea, SWT.NULL);
+        this.removeButton.setText("Remove");
+        this.removeButton.setEnabled(false);
+        data = new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING);
+        this.removeButton.setLayoutData(data);
+        this.removeButton.addSelectionListener(new SelectionAdapter() {
+            public void widgetSelected(SelectionEvent event) {
+                removeSchema(SchemaSelectionControl.this.schemaTable.getSelection());
+            }
+        });
+        
+        schemaTable.addSelectionChangedListener(new ISelectionChangedListener() {
+            public void selectionChanged(SelectionChangedEvent event) {
+               updateControls();
+            }
+        });
+    }
+    private void addSchema() {
+        Bookmark bookmark = getBookmark();
+        boolean isAlreadyConnected = bookmark.isConnected();
+        
+        if (!isAlreadyConnected) {
+            boolean confirmed = MessageDialog.openConfirm(getShell(), 
+                       Messages.getString(getClass(), "connectTitle"),
+                       Messages.getString(getClass(), "connectMessage"));
+            if (confirmed) {
+                this.connectionUtil.connect(bookmark, getShell());
+            }
+        }
+        
+        try {
+            if (bookmark.isConnected()) {
+                List schemaList = getAllUnselectedSchemas(bookmark);
+                SimpleSelectionDialog dialog = new SimpleSelectionDialog(
+                               getShell(), Messages.getString(getClass(), "addSchemaDialog"), 
+                                               schemaList.toArray(), 
+                                               QuantumPlugin.getImage("schema.gif"), true);
+                int result = dialog.open();
+                if (result == SimpleSelectionDialog.OK 
+                               && !dialog.getSelection().isEmpty()) {
+                    for (Iterator i = dialog.getSelection().iterator(); i.hasNext();) {
+                        this.schemas.add(i.next());
+                    }
+                    
+                       refreshTable();
+                       this.propertyChangeSupport.firePropertyChange("schemas", null, getSchemas());
+                }
+    
+                if (!isAlreadyConnected) {
+                    bookmark.disconnect();
+                }
+            }
+        } catch (ConnectionException e) {
+            ExceptionDisplayDialog.openError(getShell(), null, null, e);
+        } catch (SQLException e) {
+            ExceptionDisplayDialog.openError(getShell(), null, null, e);
+               }
+    }
+    
+    /**
+        * @param bookmark
+        * @return
+        * @throws NotConnectedException
+        * @throws SQLException
+        */
+       private List getAllUnselectedSchemas(Bookmark bookmark) 
+                       throws NotConnectedException, SQLException {
+               Schema[] schemas = bookmark.getDatabase().getSchemas();
+               List schemaList = new ArrayList(Arrays.asList(schemas));
+               schemaList.removeAll(this.schemas);
+               Collections.sort(schemaList);
+               return schemaList;
+       }
+
+       private void removeSchema(ISelection selection) {
+        IStructuredSelection structuredSelection = (IStructuredSelection) selection;
+        for (Iterator i = structuredSelection.iterator(); i.hasNext();) {
+            Schema element = (Schema) i.next();
+            this.schemas.remove(element);
+        }
+        refreshTable();
+       this.propertyChangeSupport.firePropertyChange("schemas", null, getSchemas());
+    }
+
+    private Bookmark getBookmark() {
+        return this.bookmarkForConnection;
+    }
+
+    private void refreshTable() {
+        this.schemaTable.refresh();
+    }
+    
+    public Schema[] getSchemas() {
+       return (Schema[]) this.schemas.toArray(new Schema[this.schemas.size()]);
+    }
+
+    public void setSchemas(Schema[] schemas) {
+       this.schemas.clear();
+       this.schemas.addAll(Arrays.asList(schemas));
+               updateControls();
+       refreshTable();
+       this.propertyChangeSupport.firePropertyChange("schemas", null, getSchemas());
+    }
+       public void addPropertyChangeListener(PropertyChangeListener arg0) {
+               this.propertyChangeSupport.addPropertyChangeListener(arg0);
+       }
+       public void removePropertyChangeListener(PropertyChangeListener arg0) {
+               this.propertyChangeSupport.removePropertyChangeListener(arg0);
+       }
+       public int getSchemaRule() {
+               return this.schemaRule;
+       }
+       public void setSchemaRule(int schemaRule) {
+               if (schemaRule != this.schemaRule) {
+                       int original = this.schemaRule;
+                       this.schemaRule = schemaRule;
+                       updateControls();
+                       refreshTable();
+                       this.propertyChangeSupport.firePropertyChange(
+                                       "schemaRule", original, schemaRule);
+               }
+       }
+}
diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/bookmark/AddSchemaAction.java b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/bookmark/AddSchemaAction.java
deleted file mode 100644 (file)
index 9713922..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-package com.quantum.view.bookmark;
-
-import java.util.Iterator;
-import java.util.List;
-import java.util.Vector;
-
-import com.quantum.Messages;
-import com.quantum.QuantumPlugin;
-import com.quantum.model.Bookmark;
-import com.quantum.model.NotConnectedException;
-import com.quantum.sql.SQLHelper;
-
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.ui.IViewPart;
-import org.eclipse.ui.actions.SelectionListenerAction;
-
-
-final class AddSchemaAction extends SelectionListenerAction {
-    private final IViewPart view;
-    /**
-     * @param BookmarkView
-     */
-    public AddSchemaAction(IViewPart view) {
-        super(Messages.getString("BookmarkView.SetExtraSchemas")); //$NON-NLS-1$
-        setImageDescriptor(
-            QuantumPlugin.getImageDescriptor("add_schema.gif")); //$NON-NLS-1$
-        this.view = view;
-    }
-    
-    public void run() {
-        Bookmark bookmark = getBookmark();
-        if (bookmark != null) {
-            try {
-                       Vector schemas = SQLHelper.getSchemas(bookmark.getConnection());
-                       AddSchemaDialog dialog = new AddSchemaDialog(this.view.getSite().getShell(), schemas);
-                       dialog.open();
-                       if (dialog.getSelectedSchemas() != null) {
-                    for (Iterator i = dialog.getSelectedSchemas().iterator(); i.hasNext();) {
-                                       bookmark.addSchema((String) i.next());
-                    }
-                       }
-            } catch (NotConnectedException e) {
-            }
-        }
-    }
-    
-    protected Bookmark getBookmark() {
-        List list = getSelectedNonResources();
-        return (list.size() > 0) ? ((BookmarkNode) list.get(0)).getBookmark() : null;
-    }
-    
-    protected boolean updateSelection(IStructuredSelection selection) {
-        boolean enabled = super.updateSelection(selection) &
-            selection.size() == 1 & 
-            (selection.getFirstElement() instanceof BookmarkNode);
-        return enabled & getBookmark().isConnected();
-    }
-}
\ No newline at end of file
diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/bookmark/AddSchemaDialog.java b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/bookmark/AddSchemaDialog.java
deleted file mode 100644 (file)
index ce2819e..0000000
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * Created on 12-jul-2003
- *
- */
-package com.quantum.view.bookmark;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.Vector;
-
-import com.quantum.IQuantumConstants;
-
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.List;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.help.WorkbenchHelp;
-
-/**
- * @author panic
- *
- */
-public class AddSchemaDialog extends Dialog {
-
-    protected Vector input;
-    protected List list;
-    private Vector selection;
-    /**
-     * Creates a new AddSchemaDialog.
-     */
-    public AddSchemaDialog(Shell parentShell, Vector input) {
-        super(parentShell);
-        this.input = input;
-        this.list = null;
-        selection = null;
-    }
-    /* (non-Javadoc)
-     * Method declared on Window.
-     */
-    protected void configureShell(Shell newShell) {
-        super.configureShell(newShell);
-        newShell.setText("Set Schemas");
-        WorkbenchHelp.setHelp(
-            newShell,
-            IQuantumConstants.ADD_SCHEMA_DIALOG_CONTEXT);
-    }
-    /* (non-Javadoc)
-     * Method declared on Dialog
-     */
-    protected Control createDialogArea(Composite parent) {
-        Composite composite = (Composite) super.createDialogArea(parent);
-
-        list = new List(composite, SWT.BORDER | SWT.V_SCROLL | SWT.MULTI);
-        GridData data = new GridData(GridData.FILL_BOTH);
-        list.setLayoutData(data);
-        for (Iterator iter = input.iterator(); iter.hasNext();) {
-            String element = (String) iter.next();
-            list.add(element);
-        }
-        return composite;
-    }
-
-    /* (non-Javadoc)
-     * @see org.eclipse.jface.dialogs.Dialog#okPressed()
-     */
-    protected void okPressed() {
-        // If it's OK, then the selection is not null. Null is used to signal a canceled dialog.
-        selection = new Vector();
-        if (list != null) {
-            String selecStr[] = list.getSelection();
-            for (int i = 0; i < selecStr.length; i++) {
-                String string = selecStr[i];
-                selection.add(string);
-            }
-        }
-        super.okPressed();
-    }
-
-    public Collection getSelectedSchemas() {
-        return this.selection == null ? null : new ArrayList(this.selection);
-    }
-
-}
index 2335110..79d70bf 100644 (file)
@@ -1,17 +1,44 @@
 package com.quantum.view.bookmark;
 
+import java.sql.SQLException;
+
+import com.quantum.model.NotConnectedException;
+import com.quantum.ui.dialog.ExceptionDisplayDialog;
+
 import org.eclipse.jface.viewers.ITreeContentProvider;
 import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IViewPart;
 
 public class BookmarkContentProvider implements ITreeContentProvider {
+       
+       private final IViewPart view;
+
+       public BookmarkContentProvider(IViewPart view) {
+               this.view = view;
+       }
+       
     
        public Object[] getChildren(Object element) {
                if (element instanceof TreeNode) {
                        TreeNode node = (TreeNode) element;
-                       return node.getChildren();
+                       try {
+                               return node.getChildren();
+                       } catch (NotConnectedException e) {
+                               ExceptionDisplayDialog.openError(getShell(), null, null, e);
+                       } catch (SQLException e) {
+                               ExceptionDisplayDialog.openError(getShell(), null, null, e);
+                       }
                }
                return BookmarkListNode.EMPTY_ARRAY;
        }
+       /**
+        * @return
+        */
+       private Shell getShell() {
+               return this.view.getSite().getShell();
+       }
+
        public Object[] getElements(Object inputElement) {
                return getChildren(inputElement);
        }
index e3a42bd..aca7002 100644 (file)
@@ -24,7 +24,7 @@ public class BookmarkNode extends TreeNode implements PropertyChangeListener {
         this.bookmark.addPropertyChangeListener(this);
     }
 
-       public Object[] getChildren() {
+       public Object[] getChildren() throws NotConnectedException, SQLException {
                if (bookmark.isConnected() && this.children.isEmpty()) {
             initializeChildren();
                }
@@ -35,7 +35,7 @@ public class BookmarkNode extends TreeNode implements PropertyChangeListener {
         }
        }
 
-    protected void initializeChildren() {
+    protected void initializeChildren() throws NotConnectedException, SQLException {
         boolean changed = false;
         Map temp = new HashMap();
         for (Iterator i = this.children.iterator(); i.hasNext(); ) {
@@ -129,7 +129,13 @@ public class BookmarkNode extends TreeNode implements PropertyChangeListener {
             }
             firePropertyChange("connected", event.getOldValue(), event.getNewValue());
         } else if ("schemas".equals(event.getPropertyName())) {
-            initializeChildren();
+               try {
+                       initializeChildren();
+               } catch (NotConnectedException e) {
+                       this.children.clear();
+               } catch (SQLException e) {
+                       this.children.clear();
+               }
             firePropertyChange("children", event.getOldValue(), event.getNewValue());
         } else if ("name".equals(event.getPropertyName())) {
             firePropertyChange("name", event.getOldValue(), event.getNewValue());
index efc055f..f43a99a 100644 (file)
@@ -81,10 +81,9 @@ public class BookmarkView extends ViewPart implements PropertyChangeListener {
 
        private static BookmarkNode getRoot(TreeNode node){
                if (node == null) return null;
-               if (! (node instanceof TreeNode)) return null;
                while (!( node instanceof BookmarkNode))
                {
-                       node = (TreeNode) node.getParent();
+                       node = node.getParent();
                }
                if (node instanceof BookmarkNode) return (BookmarkNode) node;
                else return null;
@@ -97,7 +96,7 @@ public class BookmarkView extends ViewPart implements PropertyChangeListener {
 
                treeViewer = new TreeViewer(
             parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
-               treeViewer.setContentProvider(new BookmarkContentProvider());
+               treeViewer.setContentProvider(new BookmarkContentProvider(this));
                treeViewer.setLabelProvider(this.labelProvider);
         BookmarkListNode input = BookmarkListNode.getInstance();
                treeViewer.setInput(input);
@@ -166,25 +165,6 @@ public class BookmarkView extends ViewPart implements PropertyChangeListener {
         
         this.actionGroup = new BookmarkViewActionGroup(this, this.treeViewer);
         
-//             openDataEditorAction = new OpenDataEditorAction();
-//             openDataEditorAction.setText("Edit Data"); 
-//             openDataEditorAction.setImageDescriptor(
-//                     QuantumPlugin.getImageDescriptor("greentable.gif")); //$NON-NLS-1$
-//             openDataEditorAction.init(this);
-
-               IPreferenceStore store = QuantumPlugin.getDefault().getPreferenceStore();
-               this.customCopyAction1 = new CustomCopyAction(this,1); // 1 is unused, just in case more custom copies are defined        
-               this.customCopyAction1.setText(store.getString("customCopyName1")); //$NON-NLS-1$
-               this.customCopyAction1.setImageDescriptor(
-                       QuantumPlugin.getImageDescriptor("copy.gif")); //$NON-NLS-1$
-               this.customCopyAction2 = new CustomCopyAction(this,2); // 1 is unused, just in case more custom copies are defined        
-               this.customCopyAction2.setText(store.getString("customCopyName2")); //$NON-NLS-1$
-               this.customCopyAction2.setImageDescriptor(
-                       QuantumPlugin.getImageDescriptor("copy.gif")); //$NON-NLS-1$
-               this.customCopyAction3 = new CustomCopyAction(this,3); // 1 is unused, just in case more custom copies are defined        
-               this.customCopyAction3.setText(store.getString("customCopyName3")); //$NON-NLS-1$
-               this.customCopyAction3.setImageDescriptor(
-                       QuantumPlugin.getImageDescriptor("copy.gif")); //$NON-NLS-1$
 
                extensionVector = new Vector();
                try {
@@ -193,8 +173,35 @@ public class BookmarkView extends ViewPart implements PropertyChangeListener {
                        e.printStackTrace();
                }
 
-               }
+       }
        
+       /**
+        * 
+        */
+       private void initCustomCopyActions() {
+               IPreferenceStore store = QuantumPlugin.getDefault().getPreferenceStore();
+        String text1 = store.getString("customCopyName1");
+        if (text1 != null && text1.trim().length() > 0) {
+                       this.customCopyAction1 = new CustomCopyAction(this,1); // 1 is unused, just in case more custom copies are defined        
+                       this.customCopyAction1.setText(text1); //$NON-NLS-1$
+                       this.customCopyAction1.setImageDescriptor(
+                               QuantumPlugin.getImageDescriptor("copy.gif")); //$NON-NLS-1$
+        }
+        String text2 = store.getString("customCopyName2");
+        if (text2 != null && text1.trim().length() > 0) {
+                       this.customCopyAction2 = new CustomCopyAction(this,2); // 1 is unused, just in case more custom copies are defined        
+                       this.customCopyAction2.setText(text2); //$NON-NLS-1$
+                       this.customCopyAction2.setImageDescriptor(
+                               QuantumPlugin.getImageDescriptor("copy.gif")); //$NON-NLS-1$
+        }
+        String text3 = store.getString("customCopyName3");
+        if (text3 != null && text1.trim().length() > 0) {
+                       this.customCopyAction3 = new CustomCopyAction(this,3); // 1 is unused, just in case more custom copies are defined        
+                       this.customCopyAction3.setText(text3); //$NON-NLS-1$
+                       this.customCopyAction3.setImageDescriptor(
+                               QuantumPlugin.getImageDescriptor("copy.gif")); //$NON-NLS-1$
+        }
+       }
        public void dispose(){
                super.dispose();
         BookmarkListNode.getInstance().removePropertyChangeListener(this);
@@ -226,6 +233,7 @@ public class BookmarkView extends ViewPart implements PropertyChangeListener {
     private void fillContextMenu(IMenuManager mgr) {
     // TODO: this method is pretty barfy... make it cleaner
     
+               initCustomCopyActions();
         IStructuredSelection selection = getSelection();
         ActionContext context = new ActionContext(selection);
         this.actionGroup.setContext(context);
@@ -236,12 +244,22 @@ public class BookmarkView extends ViewPart implements PropertyChangeListener {
         if (sel instanceof EntityNode) {
             EntityNode entityNode = (EntityNode) sel;
             if (!entityNode.isSequence()) {
-                mgr.add(new Separator());
-                MenuManager subMenu = new MenuManager(Messages.getString("bookmarkview.customCopyAction")); 
-                subMenu.add(customCopyAction1);
-                subMenu.add(customCopyAction2);
-                subMenu.add(customCopyAction3);
-                mgr.add(subMenu);
+               if (this.customCopyAction1 != null 
+                               || this.customCopyAction2 != null 
+                                               || this.customCopyAction3 != null) {
+                       mgr.add(new Separator());
+                       MenuManager subMenu = new MenuManager(Messages.getString("bookmarkview.customCopyAction")); 
+                       if (this.customCopyAction1 != null) {
+                               subMenu.add(customCopyAction1);
+                       }
+                       if (this.customCopyAction2 != null) {
+                               subMenu.add(customCopyAction2);
+                       }
+                       if (this.customCopyAction3 != null) {
+                               subMenu.add(customCopyAction3);
+                       }
+                       mgr.add(subMenu);
+               }
 
                                MenuManager subMenuExtension = new MenuManager("Extensions"); 
                                for (int i = 0; i < extensionVector.size(); i++) {
@@ -250,13 +268,20 @@ public class BookmarkView extends ViewPart implements PropertyChangeListener {
                                }
                                if (extensionVector.size() > 0) mgr.add(subMenuExtension);
             }
-        } else if (sel instanceof ColumnNode) {
+        } else if ((sel instanceof ColumnNode) && (this.customCopyAction1 != null 
+                               || this.customCopyAction2 != null 
+                                       || this.customCopyAction3 != null)) {
             MenuManager subMenu = new MenuManager(Messages.getString("bookmarkview.customCopyAction")); 
+            if (this.customCopyAction1 != null) {
             subMenu.add(customCopyAction1);
-            subMenu.add(customCopyAction2);
-            subMenu.add(customCopyAction3);
+            }
+            if (this.customCopyAction2 != null) {
+               subMenu.add(customCopyAction2);
+            }
+            if (this.customCopyAction3 != null) {
+               subMenu.add(customCopyAction3);
+            }
             mgr.add(subMenu);
-
         }
     }
     /**
index 9293770..09f636b 100644 (file)
@@ -56,7 +56,6 @@ public class BookmarkViewActionGroup extends ActionGroup
     private SelectionListenerAction addToQuickListAction;
     private SelectionListenerAction removeFromQuickListAction;
     private SelectionListenerAction viewTableAction;
-    private SelectionListenerAction addSchemaAction;
     private SelectionListenerAction viewTableDetailsAction;
 
     private SelectionListenerAction nextSequenceAction;
@@ -100,7 +99,6 @@ public class BookmarkViewActionGroup extends ActionGroup
         this.openQueryAction = new OpenQueryAction(this.viewPart);
         
         this.viewTableAction = new ViewTableAction(this.viewPart);
-        this.addSchemaAction = new AddSchemaAction(this.viewPart);
         this.refreshAction = new RefreshBookmarkAction(this.viewPart);
         this.renameAction = new RenameAction(this.viewPart);
         this.copyAction = new CopyAction(this.viewPart, this, selectionProvider);
@@ -151,9 +149,6 @@ public class BookmarkViewActionGroup extends ActionGroup
 
         if (getStructuredSelection().size() == 1 && 
             isEverySelectionInstanceof(BookmarkNode.class)) {
-                
-            menu.add(new Separator());
-            addToMenu(menu, this.addSchemaAction);
         }
 
         if (isEverySelectionInstanceof(QueryNode.class)) {
index ec24e79..4166947 100644 (file)
@@ -30,7 +30,6 @@ import org.w3c.dom.Element;
 
 
 final class CopyAction extends SelectionListenerAction {
-       private IViewPart view;
     private BookmarkClipboard bookmarkClipboard;
     
        /**
@@ -40,7 +39,6 @@ final class CopyAction extends SelectionListenerAction {
         ISelectionProvider selectionProvider) {
         super(Messages.getString(CopyAction.class.getName() + ".text"));
         setImageDescriptor(QuantumPlugin.getImageDescriptor("copy.gif"));
-               this.view = view;
         this.bookmarkClipboard = bookmarkClipboard;
         selectionProvider.addSelectionChangedListener(this);
        }
index 6d5adbe..eb9d742 100644 (file)
@@ -1,8 +1,11 @@
 package com.quantum.view.bookmark;
 
+import java.sql.SQLException;
+
 import com.quantum.model.Column;
 import com.quantum.model.Entity;
 import com.quantum.model.EntityHolder;
+import com.quantum.model.NotConnectedException;
 import com.quantum.model.SchemaHolder;
 import com.quantum.model.Table;
 import com.quantum.model.View;
@@ -31,7 +34,7 @@ public class EntityNode extends TreeNode implements EntityHolder {
         }
     }
 
-    public Object[] getChildren() {
+    public Object[] getChildren() throws NotConnectedException, SQLException {
         initializeChildren();
         if (this.children.size() > 0) {
             return (ColumnNode[]) this.children.toArray(new ColumnNode[this.children.size()]);
@@ -40,7 +43,7 @@ public class EntityNode extends TreeNode implements EntityHolder {
         }
     }
 
-    protected synchronized void initializeChildren() {
+    protected synchronized void initializeChildren() throws NotConnectedException, SQLException {
         this.children.clear();
         Column[] columns = this.entity.getColumns();
         for (int i = 0, length = (columns == null) ? 0 : columns.length;
@@ -68,7 +71,7 @@ public class EntityNode extends TreeNode implements EntityHolder {
     }
     
     public String getLabelName() {
-        return (this.longFormName) ? this.entity.getCondQualifiedName() : this.entity.getName();
+        return (this.longFormName) ? this.entity.getQualifiedName() : this.entity.getName();
     }
     
     public boolean isTable() {
@@ -119,8 +122,8 @@ public class EntityNode extends TreeNode implements EntityHolder {
     public int compareTo(Object o) {
         if (o instanceof EntityNode) {
             EntityNode that = (EntityNode) o;
-            return this.entity.getCondQualifiedName().compareTo(
-                that.entity.getCondQualifiedName());
+            return this.entity.getQualifiedName().compareTo(
+                that.entity.getQualifiedName());
         } else {
             return super.compareTo(o);
         }
index 04b5da5..974dcd7 100644 (file)
@@ -5,6 +5,7 @@
 package com.quantum.view.bookmark;
 
 import java.sql.SQLException;
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.Map;
@@ -71,6 +72,7 @@ public class GroupNode extends TreeNode implements Comparable, SchemaHolder {
                     this.children.add(entityNode);
                 }
             }
+            Collections.sort(this.children);
             if ((temp.size() > 0 || changed ) && !firstTimeInitialization) {
                 firePropertyChange("children", null, null);
             }
index a7bf476..cf0f628 100644 (file)
@@ -1,18 +1,17 @@
 package com.quantum.view.bookmark;
 
-import com.quantum.Messages;
-import com.quantum.QuantumPlugin;
-import com.quantum.model.Bookmark;
-import com.quantum.model.BookmarkCollection;
-
 import org.eclipse.jface.viewers.ISelectionProvider;
 import org.eclipse.jface.viewers.IStructuredSelection;
 import org.eclipse.ui.IViewPart;
 import org.eclipse.ui.actions.SelectionListenerAction;
 
+import com.quantum.Messages;
+import com.quantum.QuantumPlugin;
+import com.quantum.model.Bookmark;
+import com.quantum.model.BookmarkCollection;
+
 
 final class PasteAction extends SelectionListenerAction {
-    private IViewPart view;
     private BookmarkClipboard bookmarkClipboard;
     /**
      * @param BookmarkView
@@ -21,7 +20,6 @@ final class PasteAction extends SelectionListenerAction {
         ISelectionProvider selectionProvider) {
         super(Messages.getString(PasteAction.class.getName() + ".text"));
         setImageDescriptor(QuantumPlugin.getImageDescriptor("paste.gif"));
-        this.view = view;
         selectionProvider.addSelectionChangedListener(this);
         this.bookmarkClipboard = bookmarkClipboard;
     }
index 9e74ef5..fba6c62 100644 (file)
@@ -84,7 +84,7 @@ public class QuickListNode extends TreeNode implements PropertyChangeListener {
             i < length;
             i++) {
                 
-            this.children.put(entities[i].getCondQualifiedName(), 
+            this.children.put(entities[i].getQualifiedName(), 
                 new EntityNode(this, entities[i], true));
         }
     }
index 175c68a..ca5bde7 100644 (file)
@@ -1,17 +1,61 @@
 package com.quantum.view.bookmark;
 
-import com.quantum.Messages;
-import com.quantum.model.Bookmark;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
 
-import org.eclipse.jface.dialogs.InputDialog;
 import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.jface.wizard.WizardDialog;
 import org.eclipse.ui.IViewPart;
 import org.eclipse.ui.actions.SelectionListenerAction;
 
+import com.quantum.Messages;
+import com.quantum.model.Bookmark;
+import com.quantum.wizards.BookmarkNameWizardPage;
+
 /**
  * @author BC
  */
 public class RenameAction extends SelectionListenerAction {
+       
+       public class RenameWizard extends Wizard implements PropertyChangeListener {
+               
+               private BookmarkNameWizardPage page;
+               private String name;
+               
+               public RenameWizard(String name) {
+                       this.name = name;
+               }
+               
+               public void addPages() {
+                       super.addPages();
+                       this.page = new BookmarkNameWizardPage("pageName", this.name);
+                       this.page.addPropertyChangeListener(this);
+                       addPage(this.page);
+               }
+               
+               public void dispose() {
+                       this.page.removePropertyChangeListener(this);
+                       super.dispose();
+               }
+               public boolean performFinish() {
+                       return true;
+               }
+
+               public void propertyChange(PropertyChangeEvent event) {
+                       if ("name".equals(event.getPropertyName())) {
+                               setName((String) event.getNewValue());
+                       }
+               }
+               
+               public String getName() {
+                       return this.name;
+               }
+               public void setName(String name) {
+                       this.name = name;
+               }
+       }
+       
 
     private IViewPart viewPart;
 
@@ -22,8 +66,6 @@ public class RenameAction extends SelectionListenerAction {
         super(Messages.getString(RenameAction.class.getName() + ".text"));
         this.viewPart = viewPart;
     }
-    
-    
 
     /**
      * @see org.eclipse.ui.actions.SelectionListenerAction#updateSelection(org.eclipse.jface.viewers.IStructuredSelection)
@@ -42,11 +84,11 @@ public class RenameAction extends SelectionListenerAction {
      * @see org.eclipse.jface.action.IAction#run()
      */
     public void run() {
-        InputDialog dialog = new InputDialog(this.viewPart.getSite().getShell(), "Select a new name",
-            "Name: ", getBookmark().getName(), null);
+       RenameWizard wizard = new RenameWizard(getBookmark().getName());
+        WizardDialog dialog = new WizardDialog(this.viewPart.getSite().getShell(), wizard);
         int result = dialog.open();
-        if (result == InputDialog.OK) {
-            getBookmark().setName(dialog.getValue());
+        if (result == WizardDialog.OK) {
+            getBookmark().setName(wizard.getName());
         }
     }
 }
index 6b44cda..4b6f3c3 100644 (file)
@@ -69,7 +69,11 @@ public class SchemaNode extends TreeNode implements SchemaHolder {
      * @see com.quantum.view.bookmark.TreeNode#getImageName()
      */
     protected String getImageName() {
-        return this.schema.isDefault() ? "user.gif" : "schema.gif";
+        return this.schema.isDefault() 
+                       ? "user.gif" 
+                       :  this.schema.exists() 
+                               ? "schema.gif" 
+                               : "missingschema.gif";
     }
 
     /**
index 1d18d38..7552995 100644 (file)
@@ -1,12 +1,14 @@
 package com.quantum.view.bookmark;
 
 import java.beans.PropertyChangeEvent;
+import java.sql.SQLException;
 import java.util.Iterator;
 import java.util.Vector;
 
 import com.quantum.QuantumPlugin;
 import com.quantum.model.Bookmark;
 import com.quantum.model.BookmarkHolder;
+import com.quantum.model.NotConnectedException;
 
 import org.eclipse.core.runtime.IAdaptable;
 import org.eclipse.swt.graphics.Image;
@@ -26,7 +28,7 @@ public abstract class TreeNode
         this.parent = parent;
     }
     
-       public abstract Object[] getChildren();
+       public abstract Object[] getChildren() throws NotConnectedException, SQLException;
        public TreeNode getParent() {
         return this.parent;
        }
@@ -112,8 +114,8 @@ public abstract class TreeNode
     public Object getAdapter(Class adapter) {
         return null;
     }
-    protected abstract void initializeChildren();
-    public void reload() {
+    protected abstract void initializeChildren() throws SQLException, NotConnectedException;
+    public void reload() throws NotConnectedException, SQLException {
         if (isInitialized()) {
             initializeChildren();
             for (Iterator i = this.children.iterator(); i.hasNext(); ) {
index 0b70c9d..853d135 100644 (file)
@@ -6,7 +6,9 @@ import com.quantum.model.Bookmark;
 import com.quantum.model.BookmarkCollection;
 import com.quantum.model.Column;
 import com.quantum.model.Entity;
+import com.quantum.model.ForeignKey;
 import com.quantum.model.Index;
+import com.quantum.model.NotConnectedException;
 import com.quantum.model.Schema;
 
 /**
@@ -40,8 +42,14 @@ public class EntitySubset implements Entity {
         // TODO: limit the columns
         Entity relatedEntity = getEntityFromBookmark();
         if (relatedEntity != null) {
-            Column[] columns = relatedEntity.getColumns();
-            return columns;
+               try {
+                   Column[] columns = relatedEntity.getColumns();
+                   return columns;
+               } catch (NotConnectedException e) {
+                       return new Column[0];
+               } catch (SQLException e) {
+                       return new Column[0];
+               }
         } else {
             return null;
         }
@@ -51,13 +59,13 @@ public class EntitySubset implements Entity {
         return new Index[0];
     }
 
-    public Column getColumn(String columnName) {
+    public Column getColumn(String columnName) throws NotConnectedException, SQLException {
         Entity relatedEntity = getEntityFromBookmark();
         return relatedEntity == null 
             ? null : relatedEntity.getColumn(columnName);
     }
 
-    public String getCondQualifiedName() {
+    public String getQualifiedName() {
         return this.schema + "." + this.name;
     }
 
@@ -81,6 +89,38 @@ public class EntitySubset implements Entity {
      * @see com.quantum.model.Entity#getQuotedTableName()
      */
     public String getQuotedTableName() {
-        return getBookmark().getAdapter().filterTableName(getCondQualifiedName());
+        return getBookmark().getAdapter().filterTableName(getQualifiedName());
     }
+
+       /* (non-Javadoc)
+        * @see java.lang.Comparable#compareTo(java.lang.Object)
+        */
+       public int compareTo(Object arg0) {
+               // TODO Auto-generated method stub
+               return 0;
+       }
+
+       /* (non-Javadoc)
+        * @see com.quantum.model.Entity#getExportedKeys()
+        */
+       public ForeignKey[] getExportedKeys() throws NotConnectedException, SQLException {
+               // TODO Auto-generated method stub
+               return null;
+       }
+
+       /* (non-Javadoc)
+        * @see com.quantum.model.Entity#getImportedKeys()
+        */
+       public ForeignKey[] getImportedKeys() throws NotConnectedException, SQLException {
+               // TODO Auto-generated method stub
+               return null;
+       }
+
+       /* (non-Javadoc)
+        * @see com.quantum.model.Entity#getReferences()
+        */
+       public ForeignKey[] getReferences() throws NotConnectedException, SQLException {
+               // TODO Auto-generated method stub
+               return null;
+       }
 }
index 149135f..7d6fcf7 100644 (file)
@@ -71,8 +71,8 @@ public class ObjectNode implements Comparable, EntityHolder {
                        if (node.getOrder() > getOrder()) return -1;
                        if (node.getOrder() < getOrder()) return 1;
                        // If the order is the same, we use alphabetical order 
-                       return getEntity().getCondQualifiedName().compareTo(
-                node.getEntity().getCondQualifiedName());
+                       return getEntity().getQualifiedName().compareTo(
+                node.getEntity().getQualifiedName());
                } else throw new ClassCastException();
        }
        
@@ -105,8 +105,8 @@ public class ObjectNode implements Comparable, EntityHolder {
         */
        public boolean equals(Object obj) {
                if (!(obj instanceof ObjectNode)) return false;
-               return (getEntity().getCondQualifiedName().equals(
-            ((ObjectNode) obj).getEntity().getCondQualifiedName()));
+               return (getEntity().getQualifiedName().equals(
+            ((ObjectNode) obj).getEntity().getQualifiedName()));
        }
        
        /**
@@ -153,7 +153,7 @@ public class ObjectNode implements Comparable, EntityHolder {
         */
        public String getQuery() {
                String result = new String(""); //$NON-NLS-1$
-               result = "SELECT " + metadata.getColumnsString() + " FROM " + getEntity().getCondQualifiedName(); //$NON-NLS-1$ //$NON-NLS-2$
+               result = "SELECT " + metadata.getColumnsString() + " FROM " + getEntity().getQualifiedName(); //$NON-NLS-1$ //$NON-NLS-2$
                return result;
        }
 
index dd8133b..4608543 100644 (file)
@@ -1,8 +1,10 @@
 package com.quantum.view.subset;
 
+import java.sql.SQLException;
 import java.util.Vector;
 
 import com.quantum.Messages;
+import com.quantum.model.NotConnectedException;
 import com.quantum.sql.metadata.MetaDataXMLInterface;
 import com.quantum.view.bookmark.ColumnNode;
 import com.quantum.view.bookmark.TreeNode;
@@ -63,7 +65,11 @@ public class SubsetContentProvider implements ITreeContentProvider {
                        return subsets.toArray();
                } else if (parentElement instanceof TreeNode) {
                        TreeNode node = (TreeNode) parentElement;
-                       return node.getChildren();
+                       try {
+                               return node.getChildren();
+                       } catch (NotConnectedException e) {
+                       } catch (SQLException e) {
+                       }
                }
                return SubsetRoot.EMPTY_ARRAY;
        }
index 17d7b29..e833620 100644 (file)
@@ -3,16 +3,6 @@ package com.quantum.view.tableview;
 import java.sql.SQLException;
 import java.util.Vector;
 
-import com.quantum.Messages;
-import com.quantum.adapters.AdapterFactory;
-import com.quantum.adapters.DatabaseAdapter;
-import com.quantum.model.Bookmark;
-import com.quantum.model.Entity;
-import com.quantum.model.NotConnectedException;
-import com.quantum.sql.FilterSort;
-import com.quantum.sql.SQLHelper;
-import com.quantum.sql.SQLResults;
-
 import org.eclipse.jface.viewers.CellEditor;
 import org.eclipse.jface.viewers.TableViewer;
 import org.eclipse.jface.viewers.TextCellEditor;
@@ -22,10 +12,17 @@ import org.eclipse.swt.widgets.TableColumn;
 import org.eclipse.swt.widgets.TableItem;
 import org.eclipse.swt.widgets.Text;
 
+import com.quantum.Messages;
+import com.quantum.adapters.DatabaseAdapter;
+import com.quantum.model.Bookmark;
+import com.quantum.model.Entity;
+import com.quantum.model.NotConnectedException;
+import com.quantum.sql.FilterSort;
+import com.quantum.sql.SQLHelper;
+import com.quantum.sql.SQLResults;
+
 public class TableAdapter {
        
-       private Table table = null;
-       
        public static final String DEFAULT = ""; //$NON-NLS-1$
        public static final String UTF_8 = "UTF-8"; //$NON-NLS-1$
        public static final String UTF_16 = "UTF-16"; //$NON-NLS-1$
@@ -74,8 +71,8 @@ public class TableAdapter {
         try {
                if (entity != null) {
                 totalSize = SQLHelper.getSize(
-                    bookmark.getConnection(), entity.getCondQualifiedName(), 
-                        AdapterFactory.getInstance().getAdapter(bookmark.getType()));
+                    bookmark.getConnection(), entity.getQualifiedName(), 
+                        bookmark.getAdapter());
                }
         } catch (SQLException e) {
             e.printStackTrace();
@@ -126,9 +123,9 @@ public class TableAdapter {
 
        public String getQuery() {
                if (entity != null) {
-                       DatabaseAdapter adapter = AdapterFactory.getInstance().getAdapter(bookmark.getType());
+                       DatabaseAdapter adapter = bookmark.getAdapter();
                        if (adapter == null) throw new RuntimeException();
-                       else return adapter.getTableQuery((entity).getCondQualifiedName()) + extra.toString();
+                       else return adapter.getTableQuery((entity).getQualifiedName()) + extra.toString();
                }
                return query;
        }
@@ -172,7 +169,6 @@ public class TableAdapter {
                }
        }
        public void loadTable(Table table) {
-               this.table = table;
                table.setHeaderVisible(true);
                for (int i = 0; i < columnNames.size(); i++) {
                        TableColumn column = new TableColumn(table, SWT.NONE);
@@ -225,7 +221,7 @@ public class TableAdapter {
                this.extra = extra;
        }
        public String getTable() {
-               return (entity != null) ? entity.getCondQualifiedName() : null;
+               return (entity != null) ? entity.getQualifiedName() : null;
        }
 
        public void setQuery(String query) {
index dc41455..8e23888 100644 (file)
@@ -48,7 +48,6 @@ public class TableView extends ViewPart implements ISelectionListener {
                ta.setEncoding(TableAdapter.DEFAULT);
         }
     }
-    private static TableView instance = null;
        private TabFolder tabs = null;
        private Composite parent;
        private Vector extensionVector;
@@ -179,7 +178,8 @@ public class TableView extends ViewPart implements ISelectionListener {
                if (tableName != null) {
                        tabItem.setText(bookmark.getName() + ":" + tableName);
                } else {
-                       tabItem.setText(bookmark.getName() + ":" + adapter.getQuery());
+                       tabItem.setText(bookmark.getName() + ": SQL");
+                       tabItem.setToolTipText(bookmark.getName() + ":\n" + adapter.getQuery());
                }
     
                toolBar.getPrevious().setEnabled(adapter.hasPreviousPage());
@@ -261,7 +261,6 @@ public class TableView extends ViewPart implements ISelectionListener {
        }
 
        public void createPartControl(Composite parent) {
-               instance = this;
                this.parent = parent;
                initActions();
                tabs = new TabFolder(parent, SWT.NONE);
diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/widget/ComboViewer.java b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/widget/ComboViewer.java
new file mode 100644 (file)
index 0000000..7dd692a
--- /dev/null
@@ -0,0 +1,79 @@
+package com.quantum.view.widget;
+
+import org.eclipse.jface.viewers.ContentViewer;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+
+/**
+ * <p>A Combo viewer.
+ * 
+ * <p>In Eclipse version 3.0, a standard JFace ComboViewer class exists.
+ * 
+ * @author BC Holmes
+ */
+public class ComboViewer extends ContentViewer {
+
+       private Combo combo;
+
+       private Object[] objects = new Object[0];
+
+       public ComboViewer(Composite parent) {
+               this.combo = new Combo(parent, SWT.SIMPLE | SWT.DROP_DOWN | SWT.READ_ONLY);
+               this.combo.addSelectionListener(new SelectionAdapter() {
+                       public void widgetSelected(SelectionEvent event) {
+                               ComboViewer.this.fireSelectionChanged(new SelectionChangedEvent(
+                                               ComboViewer.this, getSelection()) );
+                       }
+               });
+       }
+
+       public Control getControl() {
+               return this.combo;
+       }
+
+       public ISelection getSelection() {
+               int index = this.combo.getSelectionIndex();
+
+               return (this.objects == null || index >= this.objects.length || index < 0) 
+                               ? new StructuredSelection()
+                               : new StructuredSelection(this.objects[index]);
+       }
+
+       protected void inputChanged(Object input, Object oldInput) {
+               super.inputChanged(input, oldInput);
+
+               if (input == null) {
+                       this.objects = new Object[0];
+               } else {
+                       this.objects = ((IStructuredContentProvider) getContentProvider()).getElements(input);
+                       for (int i = 0, length = this.objects == null ? 0 : this.objects.length; i < length; i++) {
+                               String label = ((ILabelProvider) getLabelProvider()).getText(this.objects[i]);
+                               this.combo.add(label);
+                       }
+               }
+       }
+       public void refresh() {
+       }
+
+       public void setSelection(ISelection selection, boolean reveal) {
+               if (selection != null && selection instanceof IStructuredSelection) {
+                       Object object = ((IStructuredSelection) selection).getFirstElement();
+                       for (int i = 0, length = this.objects == null ? 0 : this.objects.length; 
+                                       object != null && i < length; i++) {
+                               if (this.objects[i] == object) {
+                                       this.combo.select(i);
+                               }
+                       }
+               }
+       }
+}
\ No newline at end of file
diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/wizards/AddDriverWizard.java b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/wizards/AddDriverWizard.java
new file mode 100644 (file)
index 0000000..93dd10b
--- /dev/null
@@ -0,0 +1,275 @@
+package com.quantum.wizards;
+
+import com.quantum.Messages;
+import com.quantum.QuantumPlugin;
+import com.quantum.adapters.AdapterFactory;
+import com.quantum.adapters.DatabaseAdapter;
+import com.quantum.model.BookmarkCollection;
+import com.quantum.model.JDBCDriver;
+import com.quantum.ui.dialog.SimpleSelectionDialog;
+import com.quantum.util.JarUtil;
+import com.quantum.view.widget.ComboViewer;
+
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.ILabelProviderListener;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.FileDialog;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+
+/**
+ * @author BC Holmes
+ */
+public class AddDriverWizard extends Wizard {
+       
+       public class PageImpl extends WizardPage {
+
+               private FileDialog fileDialog;
+
+               private Text driverFileName;
+               private Text driverClassName;
+               private ComboViewer type;
+               private DatabaseAdapter[] adapters = AdapterFactory.getInstance().getDriverList();
+
+               public PageImpl() {
+                       super("");
+               }
+               public void createControl(Composite parent) {
+                       setPageComplete(false);
+
+                       setTitle(Messages.getString(getClass(), "title"));
+                       setDescription(Messages.getString(getClass(), "description"));
+                       
+                       
+               parent.setLayout(new GridLayout());
+               Composite composite = new Composite(parent, SWT.NONE);
+                       GridLayout layout = new GridLayout();
+                       composite.setLayout(layout);
+                       layout.numColumns = 3;
+                       GridData fullHorizontal = new GridData(
+                                       GridData.FILL_HORIZONTAL |
+                                       GridData.VERTICAL_ALIGN_BEGINNING);
+                       composite.setLayoutData(fullHorizontal);
+                       
+       
+                       this.fileDialog = new FileDialog(composite.getShell(), SWT.OPEN);
+                       this.fileDialog.setFilterExtensions(new String[] { "*.jar", "*.zip", "*.*" });
+                       this.fileDialog.setFilterNames(new String[] {
+                                       Messages.getString("BookmarkWizard.JarFiles"),
+                                       Messages.getString("BookmarkWizard.ZipFiles"),
+                                       Messages.getString("BookmarkWizard.AllFiles") });
+       
+                       Label label = new Label(composite, SWT.NULL);
+                       label.setText(Messages.getString(getClass(), "fileName"));
+                       this.driverFileName = new Text(composite, SWT.BORDER | SWT.SINGLE);
+                       fullHorizontal = new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING);
+                       this.driverFileName.setLayoutData(fullHorizontal);
+                       
+                       this.driverFileName.addModifyListener(new ModifyListener() {
+                               public void modifyText(ModifyEvent event) {
+                                       updateButtons();
+                               }
+                               
+                       });
+       
+                       Button button = new Button(composite, SWT.PUSH);
+                       button.setText(Messages.getString(getClass(), "browse"));
+       
+                       button.addSelectionListener(new SelectionAdapter() {
+                               public void widgetSelected(SelectionEvent event) {
+                                       PageImpl.this.fileDialog.setFilterPath(QuantumPlugin.getDefault()
+                                                       .getPreferenceStore().getString(
+                                                                       "quantum.dialogs.bookmarkwizard.path"));
+                                       String filename = PageImpl.this.fileDialog.open();
+                                       if (filename != null) {
+                                               PageImpl.this.driverFileName.setText(filename);
+                                               QuantumPlugin.getDefault().getPreferenceStore().setValue(
+                                                               "quantum.dialogs.bookmarkwizard.path", filename);
+                                               AddDriverWizard.this.setDriverFileName(filename);
+                                               updateButtons();
+                                       }
+                               }
+                       });
+       
+                       label = new Label(composite, SWT.NULL);
+                       label.setText(Messages.getString(getClass(), "driverClassName"));
+                       this.driverClassName = new Text(composite, SWT.BORDER | SWT.SINGLE);
+                       fullHorizontal = new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING);
+                       this.driverClassName.setLayoutData(fullHorizontal);
+       
+                       this.driverClassName.addModifyListener(new ModifyListener() {
+                               public void modifyText(ModifyEvent event) {
+                                       AddDriverWizard.this.setDriverClassName(((Text) event.getSource()).getText());
+                                       updateButtons();
+                               }
+                               
+                       });
+                       button = new Button(composite, SWT.PUSH);
+                       button.setText(Messages.getString(getClass(), "browse"));
+       
+                       button.addSelectionListener(new SelectionAdapter() {
+                               public void widgetSelected(SelectionEvent event) {
+                                       SimpleSelectionDialog dialog = new SimpleSelectionDialog(
+                                                       getShell(), "Select a Driver", JarUtil.getAllDriverNames(
+                                                                       getDriverFile()), QuantumPlugin.getImage("class.gif"));
+                                       if (dialog.open() == SimpleSelectionDialog.OK) {
+                                               IStructuredSelection selection = dialog.getSelection();
+                                               if (!selection.isEmpty()) {
+                                                       String className = (String) selection.getFirstElement();
+                                                       PageImpl.this.driverClassName.setText(
+                                                                       className);
+                                                       AddDriverWizard.this.setDriverClassName(className);
+                                                       updateButtons();
+                                               }
+                                               
+                                               
+                                       }
+                               }
+                       });
+                       label = new Label(composite, SWT.NULL);
+                       label.setText(Messages.getString("BookmarkWizard.TypeAst")); //$NON-NLS-1$
+                       this.type = new ComboViewer(composite);
+                       this.type.setContentProvider(new IStructuredContentProvider() {
+                               public void dispose() {
+                               }
+                               public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+                               }
+                               public Object[] getElements(Object inputElement) {
+                                       return PageImpl.this.adapters;
+                               }
+                       });
+                       
+                       this.type.setLabelProvider(new ILabelProvider() {
+                               public Image getImage(Object element) {
+                                       return null;
+                               }
+                               public String getText(Object element) {
+                                       if (element != null && element instanceof DatabaseAdapter) {
+                                               return ((DatabaseAdapter) element).getDisplayName();
+                                       } else {
+                                               return "";
+                                       }
+                               }
+                               public void addListener(ILabelProviderListener listener) {
+                               }
+                               public void dispose() {
+                               }
+                               public boolean isLabelProperty(Object element, String property) {
+                                       return false;
+                               }
+                               public void removeListener(ILabelProviderListener listener) {
+                               }
+                       });
+                       
+                       type.setInput(this);
+                       fullHorizontal = new GridData();
+                       fullHorizontal.horizontalAlignment = GridData.FILL;
+                       type.getControl().setLayoutData(fullHorizontal);
+                       
+                       type.setSelection(new StructuredSelection(
+                                       AdapterFactory.getInstance().getAdapter(AdapterFactory.GENERIC)));
+                       
+                       setControl(composite);
+           }
+           protected void updateButtons() {
+               Class driver = JarUtil.loadDriverClass(getDriverFile(), getDriverClassName());
+               setPageComplete(driver != null);
+               
+               String adapterType = AdapterFactory.getInstance().getAdapterType(getDriverClassName());
+               if (adapterType != null) {
+                       this.type.setSelection(new StructuredSelection(
+                                       AdapterFactory.getInstance().getAdapter(adapterType)));
+               }
+           }
+               protected String getDriverClassName() {
+               return this.driverClassName == null ? null : this.driverClassName.getText();
+               }
+               protected String getDriverFile() {
+               return this.driverFileName == null ? null : this.driverFileName.getText();
+           }
+               
+               protected String getDriverType() {
+                       DatabaseAdapter driverInfo = (DatabaseAdapter) 
+                                       ((IStructuredSelection) this.type.getSelection()).getFirstElement();
+                       return (driverInfo == null) ? null : driverInfo.getType();
+               }
+       }
+       private PageImpl page;
+       
+       private String driverClassName;
+       private String driverFileName;
+       private String driverType;
+
+       
+       public void addPages() {
+               this.page = new PageImpl();
+               addPage(page);
+       }
+       
+       public AddDriverWizard() {
+               super();
+               setWindowTitle(Messages.getString(getClass(), "windowTitle"));
+       }
+       
+       public boolean performFinish() {
+               JDBCDriver driver = new JDBCDriver(
+                               getDriverClassName(), 
+                               getDriverFileName(), 
+                               this.page.getDriverType());
+               BookmarkCollection.getInstance().addDriver(driver);
+               return true;
+       }
+       
+       
+       /**
+        * @return Returns the driverClassName.
+        */
+       public String getDriverClassName() {
+               return this.driverClassName;
+       }
+       /**
+        * @param driverClassName The driverClassName to set.
+        */
+       public void setDriverClassName(String driverClassName) {
+               this.driverClassName = driverClassName;
+       }
+       /**
+        * @return Returns the driverType.
+        */
+       public String getDriverType() {
+               return this.driverType;
+       }
+       /**
+        * @param driverType The driverType to set.
+        */
+       public void setDriverType(String driverType) {
+               this.driverType = driverType;
+       }
+       /**
+        * @return Returns the driverFileName.
+        */
+       public String getDriverFileName() {
+               return this.driverFileName;
+       }
+       /**
+        * @param driverFileName The driverFileName to set.
+        */
+       public void setDriverFileName(String driverFileName) {
+               this.driverFileName = driverFileName;
+       }
+}
\ No newline at end of file
index 459a949..755f9be 100644 (file)
@@ -1,10 +1,13 @@
 package com.quantum.wizards;
 
+import java.sql.SQLException;
+
 import com.quantum.adapters.DatabaseAdapter;
 import com.quantum.model.Bookmark;
 import com.quantum.model.Column;
 import com.quantum.model.ConnectionException;
 import com.quantum.model.Entity;
+import com.quantum.model.NotConnectedException;
 import com.quantum.sql.TableRow;
 import com.quantum.view.ViewHelper;
 import com.quantum.view.tableview.TableAdapter;
@@ -34,15 +37,31 @@ public abstract class BaseSQLPage extends WizardPage implements SQLPage {
     }
     protected abstract String getQueryText();
     protected void appendColumn(StringBuffer whereClause, Entity entity, String columnName, DatabaseAdapter adapter, String value) {
-            
-        if (adapter != null && entity != null && entity.getColumn(columnName) != null) {
-            Column column = entity.getColumn(columnName);
+        
+        if (adapter != null && entity != null && getColumn(entity, columnName) != null) {
+            Column column = getColumn(entity, columnName);
                whereClause.append(adapter.quote(value, column.getType(), column.getTypeName()));
         } else {
                whereClause.append(value);
         }
     }
-    public void init(TableRow row, TableAdapter adapter) {
+    /**
+        * @param entity
+        * @param columnName
+        * @return
+        * @throws NotConnectedException
+        * @throws SQLException
+        */
+       protected Column getColumn(Entity entity, String columnName)  {
+               try {
+                       return entity == null ? null : entity.getColumn(columnName);
+               } catch (NotConnectedException e) {
+                       return null;
+               } catch (SQLException e) {
+                       return null;
+               }
+       }
+       public void init(TableRow row, TableAdapter adapter) {
        this.row = row;
         this.adapter = adapter;
     }
diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/wizards/BookmarkConnectionWizardPage.java b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/wizards/BookmarkConnectionWizardPage.java
new file mode 100644 (file)
index 0000000..25cbc3c
--- /dev/null
@@ -0,0 +1,196 @@
+package com.quantum.wizards;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+
+import com.quantum.Messages;
+import com.quantum.model.JDBCDriver;
+
+
+class BookmarkConnectionWizardPage extends PropertyChangeWizardPage {
+       
+       /* use this to paint a more helpful UI for the JDBC URL */
+       private JDBCDriver driver;
+       private String userid;
+       private String password;
+       private String connectionURL;
+    private boolean prompt;
+    
+    /**
+        * Constructor for BookmarkPage.
+        * @param pageName
+        */
+       public BookmarkConnectionWizardPage(String pageName) {
+               super(pageName);
+               setTitle(Messages.getString(getClass(), "title"));
+               setDescription(Messages.getString(getClass(), "description"));
+       }
+       public void createControl(Composite parent) {
+               setPageComplete(false);
+               
+               Composite container = new Composite(parent, SWT.NULL);
+               GridLayout layout = new GridLayout();
+               container.setLayout(layout);
+               layout.numColumns = 3;
+               layout.verticalSpacing = 9;
+
+               Label label = new Label(container, SWT.NULL);
+               label.setText(Messages.getString(getClass(), "userid")); //$NON-NLS-1$
+               Text username = new Text(container, SWT.BORDER | SWT.SINGLE);
+               
+               
+               GridData fullHorizontal = new GridData(GridData.FILL_HORIZONTAL);
+               fullHorizontal.horizontalSpan = 2;
+               username.setLayoutData(fullHorizontal);
+               username.addModifyListener(new ModifyListener() {
+                       public void modifyText(ModifyEvent event) {
+                               String userid = ((Text) event.getSource()).getText();
+                               setUserid(userid);
+                               updateButtonState();
+                       }
+               });
+
+               label = new Label(container, SWT.NULL);
+               label.setText(Messages.getString(getClass(), "password")); //$NON-NLS-1$
+               final Text password = new Text(container, SWT.BORDER | SWT.SINGLE);
+               password.setEchoChar('*');
+               fullHorizontal = new GridData(GridData.FILL_HORIZONTAL);
+               fullHorizontal.horizontalSpan = 2;
+               password.setLayoutData(fullHorizontal);
+               password.addModifyListener(new ModifyListener() {
+                       public void modifyText(ModifyEvent event) {
+                               String password = ((Text) event.getSource()).getText();
+                               setPassword(password);
+                               updateButtonState();
+                       }
+               });
+
+        Button prompt = new Button(container, SWT.CHECK);
+               prompt.setText(Messages.getString(getClass(), "prompt")); //$NON-NLS-1$
+               fullHorizontal = new GridData(GridData.FILL_HORIZONTAL);
+               fullHorizontal.horizontalSpan = 3;
+        prompt.setLayoutData(fullHorizontal);
+               label = new Label(container, SWT.NULL);
+               label.setText(Messages.getString(getClass(), "url")); //$NON-NLS-1$
+               
+               Text connect = new Text(container, SWT.BORDER | SWT.SINGLE);
+               fullHorizontal = new GridData(GridData.FILL_HORIZONTAL);
+               fullHorizontal.horizontalSpan = 2;
+               connect.setLayoutData(fullHorizontal);
+               connect.addModifyListener(new ModifyListener() {
+                       public void modifyText(ModifyEvent event) {
+                               String connectionURL = ((Text) event.getSource()).getText();
+                               setConnectionURL(connectionURL);
+                               updateButtonState();
+                       }
+               });
+        prompt.addSelectionListener(new SelectionAdapter() {
+            public void widgetSelected(SelectionEvent event) {
+               Button prompt = ((Button) event.getSource());
+                password.setEditable(!prompt.getSelection());
+                setPrompt(prompt.getSelection());
+                updateButtonState();
+            }
+        });
+
+               setControl(container);
+       }
+       
+       /**
+        * @return Returns the driver.
+        */
+       public JDBCDriver getDriver() {
+               return this.driver;
+       }
+       /**
+        * @param driver The driver to set.
+        */
+       public void setDriver(JDBCDriver driver) {
+               this.driver = driver;
+       }
+       /**
+        * 
+        */
+       private void updateButtonState() {
+               boolean complete = true;
+               complete &= (this.connectionURL != null 
+                               && this.connectionURL.trim().length() > 0);
+               complete &= (this.userid != null 
+                               && this.userid.trim().length() > 0);
+               setPageComplete(complete);
+       }
+       /**
+        * @return Returns the userid.
+        */
+       public String getUserid() {
+               return this.userid;
+       }
+       /**
+        * @param userid The userid to set.
+        */
+       public void setUserid(String userid) {
+               if (userid != null && !userid.equals(this.userid)) {
+                       String original = this.userid;
+                       this.userid = userid;
+                       firePropertyChange("userid", original, userid);
+               }
+       }
+       /**
+        * @return Returns the prompt.
+        */
+       public boolean isPrompt() {
+               return this.prompt;
+       }
+       /**
+        * @param prompt The prompt to set.
+        */
+       public void setPrompt(boolean prompt) {
+               if (this.prompt != prompt) {
+                       boolean original = this.prompt;
+                       this.prompt = prompt;
+                       firePropertyChange("prompt", original, prompt);
+               }
+       }
+       /**
+        * @return Returns the connectionURL.
+        */
+       public String getConnectionURL() {
+               return this.connectionURL;
+       }
+       /**
+        * @param connectionURL The connectionURL to set.
+        */
+       public void setConnectionURL(String connectionURL) {
+               if (connectionURL != null && !connectionURL.equals(this.connectionURL)) {
+                       String original = this.connectionURL;
+                       this.connectionURL = connectionURL;
+                       firePropertyChange("connectionURL", original, connectionURL);
+               }
+       }
+       /**
+        * @return Returns the password.
+        */
+       public String getPassword() {
+               return this.password;
+       }
+       /**
+        * @param password The password to set.
+        */
+       public void setPassword(String password) {
+               if (password != null && !password.equals(this.password)) {
+                       String original = this.password;
+                       this.password = password;
+                       firePropertyChange("password", original, password);
+               }
+       }
+}
\ No newline at end of file
diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/wizards/BookmarkNameWizardPage.java b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/wizards/BookmarkNameWizardPage.java
new file mode 100644 (file)
index 0000000..8a2f675
--- /dev/null
@@ -0,0 +1,96 @@
+package com.quantum.wizards;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+
+import com.quantum.Messages;
+import com.quantum.model.BookmarkCollection;
+
+
+/**
+ * @author BC
+ */
+public class BookmarkNameWizardPage extends PropertyChangeWizardPage {
+       
+       private String name;
+       private final String originalName;
+
+       public BookmarkNameWizardPage(String pageName) {
+               this(pageName, null);
+       }
+
+       /**
+        * @param pageName
+        */
+       public BookmarkNameWizardPage(String pageName, String originalName) {
+               super(pageName);
+               this.originalName = originalName;
+               setTitle(Messages.getString(getClass(), "title"));
+               setDescription(Messages.getString(getClass(), "description"));
+       }
+
+       public void createControl(Composite parent) {
+               setPageComplete(false);
+               
+               Composite composite = new Composite(parent, SWT.NONE);
+               GridLayout layout = new GridLayout();
+               layout.numColumns = 2;
+               composite.setLayout(layout);
+               
+               Label label = new Label(composite, SWT.NONE);
+               label.setText(Messages.getString(getClass(), "name"));
+               
+               Text name = new Text(composite, SWT.BORDER | SWT.SINGLE);
+               GridData data = new GridData(GridData.FILL_HORIZONTAL);
+               name.setLayoutData(data);
+               if (this.originalName != null) {
+                       name.setText(this.originalName);
+               }
+               name.addModifyListener(new ModifyListener() {
+                       public void modifyText(ModifyEvent event) {
+                               String name = ((Text) event.getSource()).getText();
+                               setName(name);
+                       }
+               });
+               setControl(composite);
+       }
+
+       /**
+        * 
+        */
+       private void setName(String bookmarkName) {
+               String errorMessage = null;
+               boolean done = true;
+               if (bookmarkName == null || bookmarkName.trim().length() == 0) {
+                       errorMessage = Messages.getString(getClass(), "mustProvide");
+                       done = false;
+               } else if (this.originalName != null && this.originalName.equals(bookmarkName)) {
+                       done = false;
+               } else if (BookmarkCollection.getInstance().find(bookmarkName) != null) {
+                       errorMessage = Messages.getString(getClass(), "alreadyExists");
+                       done = false;
+               }
+               
+               setErrorMessage(errorMessage);
+               setPageComplete(done);
+
+               if (errorMessage == null && !bookmarkName.equals(this.name)) {
+                       String original = this.name;
+                       this.name = bookmarkName;
+                       firePropertyChange("name", original, bookmarkName);
+               }
+       }
+
+       /**
+        * @return Returns the name.
+        */
+       public String getName() {
+               return this.name;
+       }
+}
index 201c58d..5ba3d54 100644 (file)
 package com.quantum.wizards;
 
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.preference.IPreferenceStore;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+
 import org.eclipse.jface.wizard.Wizard;
-import org.eclipse.jface.wizard.WizardPage;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Combo;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.FileDialog;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Text;
 
 import com.quantum.Messages;
-import com.quantum.QuantumPlugin;
-import com.quantum.adapters.AdapterFactory;
-import com.quantum.adapters.DriverInfo;
 import com.quantum.model.Bookmark;
 import com.quantum.model.BookmarkCollection;
 import com.quantum.model.JDBCDriver;
+import com.quantum.model.Schema;
 
-public class BookmarkWizard extends Wizard {
-       BookmarkPage mainPage;
+public class BookmarkWizard extends Wizard implements PropertyChangeListener {
+       private JDBCDriverSelectionWizardPage page1;
+       private BookmarkConnectionWizardPage page2;
+       private BookmarkNameWizardPage page3;
+       private SchemaSelectionWizardPage page4;
 
+       private Bookmark bookmark;
+       
        public void init() {
-               System.out.println("Initing workbench"); //$NON-NLS-1$
                setWindowTitle(Messages.getString("BookmarkWizard.NewBookmark")); //$NON-NLS-1$
+               this.bookmark = new Bookmark();
        }
        public boolean performFinish() {
-               System.out.println("perform finish workbench"); //$NON-NLS-1$
-               String bookmarkName = mainPage.name.getText();
-               if ( BookmarkCollection.getInstance().find(bookmarkName) != null){
-                       MessageDialog.openInformation(
-                               this.getShell(),Messages.getString("BookmarkWizard.Error"),Messages.getString("BookmarkWizard.bookmarkAlreadyExists"));  //$NON-NLS-1$ //$NON-NLS-2$
-                               return false;
-               }
-
-               mainPage.performFinish();
+               BookmarkCollection.getInstance().addBookmark(this.bookmark);
+               
                return true;
        }
        public void addPages() {
-               System.out.println("adding pages"); //$NON-NLS-1$
-//             WizardPage page = new NewBookmarkPage1(Messages.getString("BookmarkWizard.Testing")); //$NON-NLS-1$
-//             addPage(page);
-               mainPage = new BookmarkPage(Messages.getString("BookmarkWizard.Testing")); //$NON-NLS-1$
-               addPage(mainPage);
-               System.out.println("adding pages"); //$NON-NLS-1$
-       }
-}
-
-class BookmarkPage extends WizardPage {
-       public static final String ADD = "ADD"; //$NON-NLS-1$
-       String action = ADD;
-       Text name;
-       Text username;
-       Text password;
-       Text schema;
-       Text connect;
-       Text driver;
-       //List driverList;
-       Combo type;
-       Text driverFile;
-    Button prompt;
-
-       FileDialog dialog;
-
-       DriverInfo[] drivers = AdapterFactory.getInstance().getDriverList();
-       /**
-        * Constructor for BookmarkPage.
-        * @param pageName
-        */
-       public BookmarkPage(String pageName) {
-               super(pageName);
+               this.page1 = new JDBCDriverSelectionWizardPage("page1"); //$NON-NLS-1$
+               this.page1.addPropertyChangeListener(this);
+               addPage(this.page1);
+               this.page2 = new BookmarkConnectionWizardPage("page2"); //$NON-NLS-1$
+               this.page2.addPropertyChangeListener(this);
+               addPage(this.page2);
+               this.page3 = new BookmarkNameWizardPage("page3"); //$NON-NLS-1$
+               this.page3.addPropertyChangeListener(this);
+               addPage(this.page3);
+               this.page4 = new SchemaSelectionWizardPage("page4", this.bookmark); //$NON-NLS-1$
+               this.page4.addPropertyChangeListener(this);
+               addPage(this.page4);
        }
-       public void createControl(Composite parent) {
-               System.out.println("page create control"); //$NON-NLS-1$
-               dialog = new FileDialog(getContainer().getShell(), SWT.OPEN);
-               dialog.setFilterExtensions(new String[]{"*.jar", "*.zip","*.*"}); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-               dialog.setFilterNames(new String[]{Messages.getString("BookmarkWizard.JarFiles"),Messages.getString("BookmarkWizard.ZipFiles"), Messages.getString("BookmarkWizard.AllFiles")}); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-               Composite container = new Composite(parent, SWT.NULL);
-               GridLayout layout = new GridLayout();
-               container.setLayout(layout);
-               layout.numColumns = 2;
-               layout.verticalSpacing = 9;
-
-
-               Label label = new Label(container, SWT.NULL);
-               label.setText(Messages.getString("BookmarkWizard.BookmarkNameAst")); //$NON-NLS-1$
-               name = new Text(container, SWT.BORDER | SWT.SINGLE);
-               GridData fullHorizontal = new GridData();
-               fullHorizontal.horizontalAlignment = GridData.FILL;
-               name.setLayoutData(fullHorizontal);
-
-               label = new Label(container, SWT.NULL);
-               label.setText(Messages.getString("BookmarkWizard.UsernameAst")); //$NON-NLS-1$
-               username = new Text(container, SWT.BORDER | SWT.SINGLE);
-               fullHorizontal = new GridData();
-               fullHorizontal.horizontalAlignment = GridData.FILL;
-               username.setLayoutData(fullHorizontal);
-
-               label = new Label(container, SWT.NULL);
-               label.setText(Messages.getString("BookmarkWizard.PasswordAst")); //$NON-NLS-1$
-               password = new Text(container, SWT.BORDER | SWT.SINGLE);
-               password.setEchoChar('*');
-               fullHorizontal = new GridData();
-               fullHorizontal.horizontalAlignment = GridData.FILL;
-               password.setLayoutData(fullHorizontal);
-        this.prompt = new Button(container, SWT.CHECK);
-        this.prompt.setText(Messages.getString("BookmarkWizard.Prompt")); //$NON-NLS-1$
-        fullHorizontal = new GridData();
-        fullHorizontal.horizontalAlignment = GridData.FILL;
-        fullHorizontal.horizontalSpan = 2;
-        this.prompt.setLayoutData(fullHorizontal);
-               label = new Label(container, SWT.NULL);
-               label.setText(Messages.getString("BookmarkWizard.Schema")); //$NON-NLS-1$
-               schema = new Text(container, SWT.BORDER | SWT.SINGLE);
-               fullHorizontal = new GridData();
-               fullHorizontal.horizontalAlignment = GridData.FILL;
-               schema.setLayoutData(fullHorizontal);
-
-               label = new Label(container, SWT.NULL);
-               label.setText(Messages.getString("BookmarkWizard.ConnectAst")); //$NON-NLS-1$
-               connect = new Text(container, SWT.BORDER | SWT.SINGLE);
-               fullHorizontal = new GridData();
-               fullHorizontal.horizontalAlignment = GridData.FILL;
-               connect.setLayoutData(fullHorizontal);
-
-               label = new Label(container, SWT.NULL);
-               label.setText(Messages.getString("BookmarkWizard.DriverAst")); //$NON-NLS-1$
-               driver = new Text(container, SWT.BORDER | SWT.SINGLE);
-               fullHorizontal = new GridData();
-               fullHorizontal.horizontalAlignment = GridData.FILL;
-               driver.setLayoutData(fullHorizontal);
-
-               label = new Label(container, SWT.NULL);
-               label.setText(Messages.getString("BookmarkWizard.TypeAst")); //$NON-NLS-1$
-               type = new Combo(container, SWT.SIMPLE | SWT.DROP_DOWN | SWT.READ_ONLY);
-               String driverNames[] = new String[drivers.length];
-               for (int i = 0; i < drivers.length; i++) {
-                       driverNames[i] = drivers[i].getDisplayName();
-               }
-               type.setItems(driverNames);
-               type.select(0);
-               fullHorizontal = new GridData();
-               fullHorizontal.horizontalAlignment = GridData.FILL;
-               type.setLayoutData(fullHorizontal);
-
-               label = new Label(container, SWT.NULL);
-               label.setText(Messages.getString("BookmarkWizard.DriverFilenameAst")); //$NON-NLS-1$
-               driverFile = new Text(container, SWT.BORDER | SWT.SINGLE);
-               fullHorizontal = new GridData();
-               fullHorizontal.horizontalAlignment = GridData.FILL;
-               driverFile.setLayoutData(fullHorizontal);
-
-               Button button = new Button(container, SWT.PUSH);
-               button.setText(Messages.getString("BookmarkWizard.Browse")); //$NON-NLS-1$
-               
-               button.addSelectionListener(new SelectionListener() {
-                       public void widgetDefaultSelected(SelectionEvent e) {
-                       }
-                       public void widgetSelected(SelectionEvent e) {
-                               // We retrieve the last saved path
-                               dialog.setFilterPath(QuantumPlugin.getDefault().getPreferenceStore().getString("quantum.dialogs.bookmarkwizard.path")); //$NON-NLS-1$
-                               String filename = dialog.open();
-                               if (filename != null) {
-                                       driverFile.setText(filename);
-                               //      We save the used path
-                                        QuantumPlugin.getDefault().getPreferenceStore().setValue("quantum.dialogs.bookmarkwizard.path", filename); //$NON-NLS-1$
+       public void propertyChange(PropertyChangeEvent event) {
                
-                               }
-                       }
-               });
-
-        prompt.addSelectionListener(new SelectionAdapter() {
-            public void widgetSelected(SelectionEvent event) {
-                BookmarkPage.this.password.setEditable(!prompt.getSelection());
-            }
-        });
-        //jsurfer start typical MySQL settings !?
-        IPreferenceStore fStore =      QuantumPlugin.getDefault().getPreferenceStore();
-
-        username.setText(fStore.getString("phpeclipse.sql.username.connect"));
-               connect.setText(fStore.getString("phpeclipse.sql.connect.connect"));
-               driver.setText(fStore.getString("phpeclipse.sql.driver.connect"));
-               String typeData = fStore.getString("phpeclipse.sql.type.connect");
-               int selectedIndex = 0;
-               for (int i = 0; i < drivers.length; i++) {
-                       if (typeData.equals(drivers[i].getDisplayName())) {
-                               selectedIndex = i;
-                       }
+               if ("driver".equals(event.getPropertyName())) {
+                       JDBCDriver driver = (JDBCDriver) event.getNewValue();
+                       this.bookmark.setJDBCDriver(driver);
+                       this.page2.setDriver(driver);
+               } else if ("name".equals(event.getPropertyName())) {
+                       this.bookmark.setName((String) event.getNewValue());
+               } else if ("userid".equals(event.getPropertyName())) {
+                       this.bookmark.setUsername((String) event.getNewValue());
+               } else if ("password".equals(event.getPropertyName())) {
+                       this.bookmark.setPassword((String) event.getNewValue());
+               } else if ("connectionURL".equals(event.getPropertyName())) {
+                       this.bookmark.setConnect((String) event.getNewValue());
+               } else if ("prompt".equals(event.getPropertyName())) {
+                       this.bookmark.setPromptForPassword(Boolean.TRUE.equals(event.getNewValue()));
+               } else if ("schemaRule".equals(event.getPropertyName())) {
+                       this.bookmark.setSchemaRule(((Integer) event.getNewValue()).intValue());
+               } else if ("schemas".equals(event.getPropertyName())) {
+                       this.bookmark.setSchemaSelections((Schema[]) event.getNewValue());
                }
-               type.select(selectedIndex);
-               driverFile.setText(fStore.getString("phpeclipse.sql.filename.connect"));
-//             jsurfer end
                
-               setControl(container);
-
-               setPageComplete(true);
-       }
-       public void updateDriverList() {
-                       /*try {
-                               JarFile file = new JarFile(driverFile.getText());
-                               Enumeration enum = file.entries();
-                               while (enum.hasMoreElements()) {
-                                       JarEntry entry = (JarEntry) enum.nextElement();
-                                       String className = entry.getName().replace('/', '.');
-                                       if (className.endsWith("Driver.class")) {
-                                               className = className.substring(0, className.lastIndexOf('.'));
-                                               //driverList.add(className);
-                                       }
-                               }
-                       } catch (IOException ex) {
-                               //driverList.removeAll();
-                       }*/
        }
-       public void performFinish() {
-               Bookmark initialData = new Bookmark();
-               initialData.setName(name.getText());
-               initialData.setUsername(username.getText());
-        initialData.setPromptForPassword(this.prompt.getSelection());
-        if (initialData.getPromptForPassword()) {
-            initialData.setPassword(""); //$NON-NLS-1$
-        } else {
-               initialData.setPassword(password.getText());
-        }
-               initialData.addSchema(schema.getText());
-               initialData.setConnect(connect.getText());
-               JDBCDriver jdbcDriver = BookmarkCollection.getInstance().findDriver(
-                               driver.getText(), driverFile.getText());
-               initialData.setJDBCDriver(jdbcDriver);
-               int selection = type.getSelectionIndex();
-               if (selection >= 0) {
-                       initialData.setType(drivers[selection].getDriverType());
-               }
-        BookmarkCollection.getInstance().addBookmark(initialData);
+       public void dispose() {
+               this.page1.removePropertyChangeListener(this);
+               this.page2.removePropertyChangeListener(this);
+               this.page3.removePropertyChangeListener(this);
+               this.page4.removePropertyChangeListener(this);
+               super.dispose();
        }
-}
\ No newline at end of file
+}
+
index dc90a00..e259f76 100644 (file)
@@ -1,11 +1,5 @@
 package com.quantum.wizards;
 
-import com.quantum.Messages;
-import com.quantum.adapters.AdapterFactory;
-import com.quantum.adapters.DatabaseAdapter;
-import com.quantum.model.Bookmark;
-import com.quantum.model.Entity;
-
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.events.ModifyEvent;
 import org.eclipse.swt.events.ModifyListener;
@@ -18,6 +12,12 @@ import org.eclipse.swt.widgets.Composite;
 import org.eclipse.swt.widgets.Label;
 import org.eclipse.swt.widgets.Text;
 
+import com.quantum.Messages;
+import com.quantum.adapters.DatabaseAdapter;
+import com.quantum.model.Bookmark;
+import com.quantum.model.Column;
+import com.quantum.model.Entity;
+
 public class DeleteRowPage extends BaseSQLPage implements SQLPage {
        String[] columnNames;
        Text[] values;
@@ -74,11 +74,8 @@ public class DeleteRowPage extends BaseSQLPage implements SQLPage {
                        whereValues[i] = new Button(container, SWT.CHECK);
                        whereValues[i].setText(Messages.getString("DeleteRowPage.WhereClause")); //$NON-NLS-1$
                        // we check if it's a primary key to select it in the WHERE clause
-                       if (entity != null && entity.getColumn(columnNames[i]).isPrimaryKey()) {
-                whereValues[i].setSelection(true);
-                       } else {
-                               whereValues[i].setSelection(false);
-            }
+                       Column column = getColumn(entity, columnNames[i]);
+            whereValues[i].setSelection(column == null ? false : column.isPrimaryKey());
                        whereValues[i].addSelectionListener(new SelectionListener() {
                                public void widgetDefaultSelected(SelectionEvent e) {
                                }
@@ -107,7 +104,7 @@ public class DeleteRowPage extends BaseSQLPage implements SQLPage {
                StringBuffer whereClause = new StringBuffer();
                Bookmark bookmark = row.getBookmark();
                Entity entity = row.getEntity();
-               DatabaseAdapter adapter = AdapterFactory.getInstance().getAdapter(bookmark.getType());
+               DatabaseAdapter adapter = bookmark.getAdapter();
                
                int numSelected = 0;
                for (int i = 0; i < columnNames.length; i++) {
index cbf7ff1..91c55d0 100644 (file)
@@ -1,11 +1,5 @@
 package com.quantum.wizards;
 
-import com.quantum.Messages;
-import com.quantum.adapters.AdapterFactory;
-import com.quantum.adapters.DatabaseAdapter;
-import com.quantum.model.Bookmark;
-import com.quantum.model.Entity;
-
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.events.ModifyEvent;
 import org.eclipse.swt.events.ModifyListener;
@@ -15,6 +9,11 @@ import org.eclipse.swt.widgets.Composite;
 import org.eclipse.swt.widgets.Label;
 import org.eclipse.swt.widgets.Text;
 
+import com.quantum.Messages;
+import com.quantum.adapters.DatabaseAdapter;
+import com.quantum.model.Bookmark;
+import com.quantum.model.Entity;
+
 public class InsertRowPage extends BaseSQLPage implements SQLPage {
        String[] columnNames;
        Text[] values;
@@ -85,7 +84,7 @@ public class InsertRowPage extends BaseSQLPage implements SQLPage {
                StringBuffer namesClause = new StringBuffer();
                Bookmark bookmark = row.getBookmark();
                Entity entity = row.getEntity();
-               DatabaseAdapter adapter = AdapterFactory.getInstance().getAdapter(bookmark.getType());
+               DatabaseAdapter adapter = bookmark.getAdapter();
                
                numColumns = 0;
                for (int i = 0; i < columnNames.length; i++) {
diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/wizards/JDBCDriverSelectionWizardPage.java b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/wizards/JDBCDriverSelectionWizardPage.java
new file mode 100644 (file)
index 0000000..7770614
--- /dev/null
@@ -0,0 +1,105 @@
+package com.quantum.wizards;
+
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+
+import com.quantum.Messages;
+import com.quantum.model.JDBCDriver;
+import com.quantum.view.JDBCDriverTableViewer;
+
+/**
+ * @author BC
+ */
+public class JDBCDriverSelectionWizardPage extends PropertyChangeWizardPage implements ISelectionChangedListener {
+
+       private JDBCDriverTableViewer tableViewer;
+       
+       private JDBCDriver driver;
+       
+       /**
+        * @param pageName
+        */
+       protected JDBCDriverSelectionWizardPage(String pageName) {
+               super(pageName);
+
+               setTitle(Messages.getString(getClass(), "title"));
+               setDescription(Messages.getString(getClass(), "description"));
+       }
+
+       public void createControl(Composite parent) {
+               setPageComplete(false);
+               Composite container = createBasicContainer(parent, 1);
+               GridLayout layout = new GridLayout(1, false);
+               container.setLayout(layout);
+               
+               this.tableViewer = new JDBCDriverTableViewer(container);
+               GridData data = new GridData(GridData.FILL_BOTH);
+               this.tableViewer.getControl().setLayoutData(data);
+               this.tableViewer.addSelectionChangedListener(this);
+
+               Button newDriver = new Button(container, SWT.PUSH);
+               newDriver.setText(Messages.getString(getClass(), "addDriver"));
+               newDriver.addSelectionListener(new SelectionAdapter() {
+                       public void widgetSelected(SelectionEvent e) {
+                       AddDriverWizard wizard = new AddDriverWizard();
+                       WizardDialog dialog =
+                           new WizardDialog(getShell(), wizard);
+                       dialog.open();
+                       }
+               });
+               data = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING | GridData.VERTICAL_ALIGN_BEGINNING);
+               newDriver.setLayoutData(data);
+               
+               setControl(container);
+       }
+       /**
+        * @param parent
+        */
+       private Composite createBasicContainer(Composite parent, int numberOfColumns) {
+               Composite container = new Composite(parent, SWT.NULL);
+               GridLayout layout = new GridLayout();
+               container.setLayout(layout);
+               layout.numColumns = numberOfColumns;
+               layout.verticalSpacing = 9;
+               GridData fullHorizontal = new GridData(GridData.FILL_BOTH);
+               container.setLayoutData(fullHorizontal);
+               return container;
+       }
+       public void selectionChanged(SelectionChangedEvent event) {
+               IStructuredSelection selection = (IStructuredSelection) event.getSelection();
+               setPageComplete(!selection.isEmpty());
+               if (!selection.isEmpty()) {
+                       setDriver((JDBCDriver) selection.getFirstElement());
+               }
+               
+       }
+       /**
+        * @return Returns the driver.
+        */
+       public JDBCDriver getDriver() {
+               return this.driver;
+       }
+       /**
+        * @param driver The driver to set.
+        */
+       public void setDriver(JDBCDriver driver) {
+               if (this.driver != driver) {
+                       JDBCDriver original = this.driver;
+                       this.driver = driver;
+                       firePropertyChange("driver", original, driver);
+               }
+       }
+       public void dispose() {
+               this.tableViewer.dispose();
+               super.dispose();
+       }
+}
\ No newline at end of file
diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/wizards/NewBookmarkPage1.java b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/wizards/NewBookmarkPage1.java
deleted file mode 100644 (file)
index 89bb37f..0000000
+++ /dev/null
@@ -1,170 +0,0 @@
-package com.quantum.wizards;
-
-import java.io.File;
-
-import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.jface.wizard.WizardPage;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.FileDialog;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.TableColumn;
-import org.eclipse.swt.widgets.Text;
-
-import com.quantum.Messages;
-import com.quantum.QuantumPlugin;
-import com.quantum.model.BookmarkCollection;
-import com.quantum.ui.dialog.AddDriverDialog;
-import com.quantum.view.JDBCDriverContentProvider;
-import com.quantum.view.JDBCDriverLabelProvider;
-
-/**
- * @author BC
- */
-public class NewBookmarkPage1 extends WizardPage {
-
-       private FileDialog fileDialog;
-
-       private Text driverFileName;
-       
-       private TableViewer tableViewer;
-
-       /**
-        * @param pageName
-        */
-       protected NewBookmarkPage1(String pageName) {
-               super(pageName);
-       }
-
-       public void createControl(Composite parent) {
-               Composite container = createBasicContainer(parent, 1);
-               GridLayout layout = new GridLayout(2, false);
-               container.setLayout(layout);
-               
-               Label label = new Label(container, SWT.NONE);
-               label.setText("Select a driver");
-               GridData data = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
-               data.horizontalSpan = 2;
-               label.setLayoutData(data);
-               
-               Table table = new Table(container, SWT.SINGLE | SWT.FULL_SELECTION | SWT.BORDER);
-        table.setHeaderVisible(true);
-        for (int i = 0, length = 4; i < length; i++) {
-            TableColumn column = new TableColumn(table, SWT.NONE);
-            column.setText(Messages.getString(getClass(), "driverColumn" + i));
-        }
-               
-        for (int i = 0, length = 4; i < length; i++) {
-            table.getColumn(i).pack();
-        }
-               
-               this.tableViewer = new TableViewer(table);
-               data = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL);
-               this.tableViewer.getControl().setLayoutData(data);
-               this.tableViewer.setContentProvider(new JDBCDriverContentProvider());
-               this.tableViewer.setLabelProvider(new JDBCDriverLabelProvider());
-               this.tableViewer.setColumnProperties(new String[] { "name", "className", "version", "jarFileName" });
-//             Table table = ((Table) this.tableViewer.getControl());
-               this.tableViewer.setInput(BookmarkCollection.getInstance());
-               
-               
-               Button newDriver = new Button(container, SWT.PUSH);
-               newDriver.setText("Add driver...");
-               newDriver.addSelectionListener(new SelectionAdapter() {
-                       public void widgetSelected(SelectionEvent e) {
-                       AddDriverDialog dialog = new AddDriverDialog(getShell());
-                       dialog.open();
-                       }
-               });
-               data = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING | GridData.VERTICAL_ALIGN_BEGINNING);
-               newDriver.setLayoutData(data);
-               
-               setControl(container);
-       }
-
-       /**
-        * @param parent
-        */
-       private Composite createBasicContainer(Composite parent, int numberOfColumns) {
-               Composite container = new Composite(parent, SWT.NULL);
-               GridLayout layout = new GridLayout();
-               container.setLayout(layout);
-               layout.numColumns = numberOfColumns;
-               layout.verticalSpacing = 9;
-               GridData fullHorizontal = new GridData(
-                               GridData.HORIZONTAL_ALIGN_BEGINNING,
-                               GridData.VERTICAL_ALIGN_BEGINNING, 
-                               true, false);
-               container.setLayoutData(fullHorizontal);
-               return container;
-       }
-
-       /**
-        * @param parent
-        * @return
-        */
-       private Composite createNewDriverSelection(Composite parent) {
-               this.fileDialog = new FileDialog(getContainer().getShell(), SWT.OPEN);
-               this.fileDialog.setFilterExtensions(new String[] { "*.jar", "*.zip", "*.*" });
-               this.fileDialog.setFilterNames(new String[] {
-                               Messages.getString("BookmarkWizard.JarFiles"),
-                               Messages.getString("BookmarkWizard.ZipFiles"),
-                               Messages.getString("BookmarkWizard.AllFiles") });
-
-               Composite container = createBasicContainer(parent, 3);
-
-               Label label = new Label(container, SWT.NULL);
-               label.setText(Messages.getString("BookmarkWizard.DriverAst")); //$NON-NLS-1$
-               this.driverFileName = new Text(container, SWT.BORDER | SWT.SINGLE);
-               GridData fullHorizontal = new GridData(
-                               GridData.HORIZONTAL_ALIGN_BEGINNING,
-                               GridData.VERTICAL_ALIGN_BEGINNING, 
-                               false, false);
-               this.driverFileName.setLayoutData(fullHorizontal);
-
-               Button button = new Button(container, SWT.PUSH);
-               button.setText(Messages.getString("BookmarkWizard.Browse")); //$NON-NLS-1$
-
-               button.addSelectionListener(new SelectionListener() {
-
-                       public void widgetDefaultSelected(SelectionEvent e) {
-                       }
-
-                       public void widgetSelected(SelectionEvent e) {
-                               NewBookmarkPage1.this.fileDialog.setFilterPath(QuantumPlugin.getDefault()
-                                               .getPreferenceStore().getString(
-                                                               "quantum.dialogs.bookmarkwizard.path"));
-                               String filename = NewBookmarkPage1.this.fileDialog.open();
-                               if (filename != null) {
-                                       NewBookmarkPage1.this.driverFileName.setText(filename);
-                                       QuantumPlugin.getDefault().getPreferenceStore().setValue(
-                                                       "quantum.dialogs.bookmarkwizard.path", filename);
-                               }
-                       }
-               });
-               return container;
-       }
-
-       //      public boolean isPageComplete() {
-       //              File file = getDriverFile();
-       //              if (file == null) {
-       //                      return false;
-       //              } else if (!file.exists() || !file.isFile()) {
-       //                      return false;
-       //              } else {
-       //                      return true;
-       //              }
-       //      }
-       //      
-       private File getDriverFile() {
-               return (this.driverFileName == null || this.driverFileName.getText() == null) ? null
-                               : new File(this.driverFileName.getText());
-       }
-}
\ No newline at end of file
diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/wizards/PropertyChangeWizardPage.java b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/wizards/PropertyChangeWizardPage.java
new file mode 100644 (file)
index 0000000..3bdbac2
--- /dev/null
@@ -0,0 +1,58 @@
+package com.quantum.wizards;
+
+import java.beans.PropertyChangeListener;
+import java.beans.PropertyChangeSupport;
+
+import org.eclipse.jface.wizard.WizardPage;
+
+
+/**
+ * @author BC
+ */
+public abstract class PropertyChangeWizardPage extends WizardPage {
+
+       protected PropertyChangeWizardPage(String pageName) {
+               super(pageName);
+       }
+
+       private PropertyChangeSupport propertyChangeSupport = new PropertyChangeSupport(this);
+
+       /**
+        * @param listener
+        */
+       public void addPropertyChangeListener(PropertyChangeListener listener) {
+               this.propertyChangeSupport.addPropertyChangeListener(listener);
+       }
+
+       /**
+        * @param listener
+        */
+       public void removePropertyChangeListener(PropertyChangeListener listener) {
+               this.propertyChangeSupport.removePropertyChangeListener(listener);
+       }
+
+       /**
+        * @param propertyName
+        * @param oldValue
+        * @param newValue
+        */
+       protected void firePropertyChange(String propertyName, boolean oldValue, boolean newValue) {
+               this.propertyChangeSupport.firePropertyChange(propertyName, oldValue, newValue);
+       }
+       /**
+        * @param propertyName
+        * @param oldValue
+        * @param newValue
+        */
+       protected void firePropertyChange(String propertyName, int oldValue, int newValue) {
+               this.propertyChangeSupport.firePropertyChange(propertyName, oldValue, newValue);
+       }
+       /**
+        * @param propertyName
+        * @param oldValue
+        * @param newValue
+        */
+       protected void firePropertyChange(String propertyName, Object oldValue, Object newValue) {
+               this.propertyChangeSupport.firePropertyChange(propertyName, oldValue, newValue);
+       }
+}
diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/wizards/SchemaSelectionWizardPage.java b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/wizards/SchemaSelectionWizardPage.java
new file mode 100644 (file)
index 0000000..e91f66e
--- /dev/null
@@ -0,0 +1,47 @@
+package com.quantum.wizards;
+
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+
+import com.quantum.Messages;
+import com.quantum.model.Bookmark;
+import com.quantum.view.SchemaSelectionControl;
+
+import org.eclipse.swt.widgets.Composite;
+
+
+/**
+ * @author BC
+ */
+public class SchemaSelectionWizardPage extends PropertyChangeWizardPage {
+
+       private final Bookmark bookmark;
+       private SchemaSelectionControl control;
+       private PropertyChangeListener listener;
+
+       /**
+        * @param pageName
+        */
+       protected SchemaSelectionWizardPage(String pageName, Bookmark bookmark) {
+               super(pageName);
+               this.bookmark = bookmark;
+               setTitle(Messages.getString(getClass(), "title"));
+               setDescription(Messages.getString(getClass(), "description"));
+       }
+
+       public void createControl(Composite parent) {
+               control = new SchemaSelectionControl(parent, this.bookmark);
+               control.addPropertyChangeListener(this.listener = new PropertyChangeListener() {
+                       public void propertyChange(PropertyChangeEvent event) {
+                               firePropertyChange(event.getPropertyName(), event.getOldValue(), event.getNewValue());
+                       }
+               });
+               setControl(control);
+       }
+       public void dispose() {
+               if (this.listener != null) {
+                       this.control.removePropertyChangeListener(this.listener);
+               }
+               super.dispose();
+       }
+}
index b057d59..e1dd3c5 100644 (file)
@@ -1,11 +1,5 @@
 package com.quantum.wizards;
 
-import com.quantum.Messages;
-import com.quantum.adapters.AdapterFactory;
-import com.quantum.adapters.DatabaseAdapter;
-import com.quantum.model.Bookmark;
-import com.quantum.model.Entity;
-
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.events.ModifyEvent;
 import org.eclipse.swt.events.ModifyListener;
@@ -18,6 +12,11 @@ import org.eclipse.swt.widgets.Composite;
 import org.eclipse.swt.widgets.Label;
 import org.eclipse.swt.widgets.Text;
 
+import com.quantum.Messages;
+import com.quantum.adapters.DatabaseAdapter;
+import com.quantum.model.Bookmark;
+import com.quantum.model.Entity;
+
 public class UpdateRowPage extends BaseSQLPage implements SQLPage {
        String[] columnNames;
        Text[] oldValues;
@@ -80,7 +79,7 @@ public class UpdateRowPage extends BaseSQLPage implements SQLPage {
                        });
                        primaryKeys[i] = new Button(container, SWT.CHECK);
                        primaryKeys[i].setText("Where"); //$NON-NLS-1$
-                       if (entity != null && entity.getColumn(columnNames[i]).isPrimaryKey()) 
+                       if (entity != null && getColumn(entity, columnNames[i]).isPrimaryKey()) 
                                primaryKeys[i].setSelection(true);
                        primaryKeys[i].addSelectionListener(new SelectionListener() {
                                public void widgetDefaultSelected(SelectionEvent e) {
@@ -126,7 +125,7 @@ public class UpdateRowPage extends BaseSQLPage implements SQLPage {
                StringBuffer whereClause = new StringBuffer();
                Bookmark bookmark = row.getBookmark();
                Entity entity = row.getEntity();
-               DatabaseAdapter adapter = AdapterFactory.getInstance().getAdapter(bookmark.getType());
+               DatabaseAdapter adapter = bookmark.getAdapter();
                
                int numValuesSet = 0;
                int numValuesWhere = 0;