newest quantum CVS sources
authorkhartlage <khartlage>
Sat, 3 Jul 2004 17:39:31 +0000 (17:39 +0000)
committerkhartlage <khartlage>
Sat, 3 Jul 2004 17:39:31 +0000 (17:39 +0000)
70 files changed:
archive/net.sourceforge.phpeclipse.quantum.sql/icons/close.gif
archive/net.sourceforge.phpeclipse.quantum.sql/icons/close_2x.gif [new file with mode: 0644]
archive/net.sourceforge.phpeclipse.quantum.sql/icons/copy.gif
archive/net.sourceforge.phpeclipse.quantum.sql/icons/copy_2x.gif [new file with mode: 0644]
archive/net.sourceforge.phpeclipse.quantum.sql/icons/delete.gif
archive/net.sourceforge.phpeclipse.quantum.sql/icons/delete_2x.gif [new file with mode: 0644]
archive/net.sourceforge.phpeclipse.quantum.sql/icons/export.gif
archive/net.sourceforge.phpeclipse.quantum.sql/icons/export_2x.gif [new file with mode: 0644]
archive/net.sourceforge.phpeclipse.quantum.sql/icons/import.gif
archive/net.sourceforge.phpeclipse.quantum.sql/icons/import_2x.gif [new file with mode: 0644]
archive/net.sourceforge.phpeclipse.quantum.sql/icons/paste.gif
archive/net.sourceforge.phpeclipse.quantum.sql/icons/paste_2x.gif [new file with mode: 0644]
archive/net.sourceforge.phpeclipse.quantum.sql/icons/play.gif
archive/net.sourceforge.phpeclipse.quantum.sql/icons/refresh.gif
archive/net.sourceforge.phpeclipse.quantum.sql/icons/refresh_2x.gif [new file with mode: 0644]
archive/net.sourceforge.phpeclipse.quantum.sql/icons/template.gif [new file with mode: 0644]
archive/net.sourceforge.phpeclipse.quantum.sql/plugin.xml
archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/ImageStore.java [new file with mode: 0644]
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/QuantumSaveParticipant.java [new file with mode: 0644]
archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/actions/BaseExecuteAction.java [new file with mode: 0644]
archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/actions/ConnectAction.java
archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/actions/DeleteBookmarkAction.java
archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/actions/DisconnectAction.java
archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/actions/ExecuteAction.java
archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/actions/ExecuteAgainstAction.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/NewBookmarkAction.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/ViewTableAction.java
archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/actions/ViewTableDetailsAction.java
archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/adapters/DB2AS400Adapter.java
archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/editors/SQLConfiguration.java
archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/editors/SQLContentAssistProcessor.java [new file with mode: 0644]
archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/model/Bookmark.java
archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/model/Displayable.java [new file with mode: 0644]
archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/model/Schema.java
archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/properties/BaseEntityPropertyPage.java
archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/properties/ColumnPropertyPage.java
archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/properties/DatabaseInformationPropertyPage.java
archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/properties/IndexPropertyPage.java
archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/properties/ReferencesPropertyPage.java
archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/sql/MultiSQLServer.java
archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/sql/SQLGrammar.java [new file with mode: 0644]
archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/sql/SQLResults.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/ExceptionDisplayDialog.java
archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/ui/dialog/SimpleSelectionDialog.java
archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/util/versioning/VersioningHelper.java
archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/JDBCDriverLabelProvider.java [deleted file]
archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/JDBCDriverTableViewer.java
archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/SQLLogView.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
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/PasteAction.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/SubsetView.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/tableview/TableViewToolBar.java
archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/wizards/AddDriverWizard.java
archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/wizards/BaseSQLPage.java
archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/wizards/ExportBookmarkWizardPage.java

index fed9c3b..3fb8662 100644 (file)
Binary files a/archive/net.sourceforge.phpeclipse.quantum.sql/icons/close.gif and b/archive/net.sourceforge.phpeclipse.quantum.sql/icons/close.gif differ
diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/icons/close_2x.gif b/archive/net.sourceforge.phpeclipse.quantum.sql/icons/close_2x.gif
new file mode 100644 (file)
index 0000000..29a8bac
Binary files /dev/null and b/archive/net.sourceforge.phpeclipse.quantum.sql/icons/close_2x.gif differ
index fa98681..ddfc57a 100644 (file)
Binary files a/archive/net.sourceforge.phpeclipse.quantum.sql/icons/copy.gif and b/archive/net.sourceforge.phpeclipse.quantum.sql/icons/copy.gif differ
diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/icons/copy_2x.gif b/archive/net.sourceforge.phpeclipse.quantum.sql/icons/copy_2x.gif
new file mode 100644 (file)
index 0000000..5c02d9f
Binary files /dev/null and b/archive/net.sourceforge.phpeclipse.quantum.sql/icons/copy_2x.gif differ
index 7f50621..97a78f7 100644 (file)
Binary files a/archive/net.sourceforge.phpeclipse.quantum.sql/icons/delete.gif and b/archive/net.sourceforge.phpeclipse.quantum.sql/icons/delete.gif differ
diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/icons/delete_2x.gif b/archive/net.sourceforge.phpeclipse.quantum.sql/icons/delete_2x.gif
new file mode 100644 (file)
index 0000000..7f50621
Binary files /dev/null and b/archive/net.sourceforge.phpeclipse.quantum.sql/icons/delete_2x.gif differ
index c501e51..807c2d2 100644 (file)
Binary files a/archive/net.sourceforge.phpeclipse.quantum.sql/icons/export.gif and b/archive/net.sourceforge.phpeclipse.quantum.sql/icons/export.gif differ
diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/icons/export_2x.gif b/archive/net.sourceforge.phpeclipse.quantum.sql/icons/export_2x.gif
new file mode 100644 (file)
index 0000000..c501e51
Binary files /dev/null and b/archive/net.sourceforge.phpeclipse.quantum.sql/icons/export_2x.gif differ
index 2191d13..990d4b3 100644 (file)
Binary files a/archive/net.sourceforge.phpeclipse.quantum.sql/icons/import.gif and b/archive/net.sourceforge.phpeclipse.quantum.sql/icons/import.gif differ
diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/icons/import_2x.gif b/archive/net.sourceforge.phpeclipse.quantum.sql/icons/import_2x.gif
new file mode 100644 (file)
index 0000000..2191d13
Binary files /dev/null and b/archive/net.sourceforge.phpeclipse.quantum.sql/icons/import_2x.gif differ
index f118c7e..62cbe07 100644 (file)
Binary files a/archive/net.sourceforge.phpeclipse.quantum.sql/icons/paste.gif and b/archive/net.sourceforge.phpeclipse.quantum.sql/icons/paste.gif differ
diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/icons/paste_2x.gif b/archive/net.sourceforge.phpeclipse.quantum.sql/icons/paste_2x.gif
new file mode 100644 (file)
index 0000000..040d7ef
Binary files /dev/null and b/archive/net.sourceforge.phpeclipse.quantum.sql/icons/paste_2x.gif differ
index a8bfcf5..1328a4e 100644 (file)
Binary files a/archive/net.sourceforge.phpeclipse.quantum.sql/icons/play.gif and b/archive/net.sourceforge.phpeclipse.quantum.sql/icons/play.gif differ
index aa450f7..7aff1a9 100644 (file)
Binary files a/archive/net.sourceforge.phpeclipse.quantum.sql/icons/refresh.gif and b/archive/net.sourceforge.phpeclipse.quantum.sql/icons/refresh.gif differ
diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/icons/refresh_2x.gif b/archive/net.sourceforge.phpeclipse.quantum.sql/icons/refresh_2x.gif
new file mode 100644 (file)
index 0000000..aa450f7
Binary files /dev/null and b/archive/net.sourceforge.phpeclipse.quantum.sql/icons/refresh_2x.gif differ
diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/icons/template.gif b/archive/net.sourceforge.phpeclipse.quantum.sql/icons/template.gif
new file mode 100644 (file)
index 0000000..bfee10d
Binary files /dev/null and b/archive/net.sourceforge.phpeclipse.quantum.sql/icons/template.gif differ
index ffc897b..bc0c025 100644 (file)
@@ -3,7 +3,7 @@
 <plugin
    id="net.sourceforge.phpeclipse.quantum.sql"
    name="%quantum.name"
-   version="2.3.2"
+   version="2.3.3"
    provider-name="Tom Schneider, Julen Parra, BC Holmes"
    class="com.quantum.QuantumPlugin">
 
             class="com.quantum.view.SQLLogView"
             id="com.quantum.view.logview">
       </view>
+      <view name="%driverview.name" 
+            icon="icons/driver.gif" 
+            category="com.quantum.views" 
+            class="com.quantum.view.JDBCDriverView" 
+            id="com.quantum.view.JDBCDriverView">
+      </view> 
       <view
             name="%tableview.name"
             icon="icons/table.gif" 
diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/ImageStore.java b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/ImageStore.java
new file mode 100644 (file)
index 0000000..4d643d7
--- /dev/null
@@ -0,0 +1,228 @@
+package com.quantum;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.Collections;
+import java.util.HashMap;
+
+import java.util.Map;
+
+import com.quantum.util.versioning.VersioningHelper;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.resource.ImageRegistry;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+
+
+
+/**
+ * @author BC
+ */
+public class ImageStore {
+       
+       private static final Map imageDescriptorMap = Collections.synchronizedMap(new HashMap());
+       
+       private static final String VERSION_2 = "_2x";
+       private static final String GIF_FILE_EXTENSION = ".gif";
+       
+       public static final String ADD = "add";
+       public static final String ADD_SCHEMA = "add_schema";
+       public static final String APPEND = "append";
+       public static final String AUTOCOMMIT = "autocommit";
+       public static final String BOOKMARK = "bookmarks";
+       public static final String BOOKMARKFILE = "bookmarkfile";
+       public static final String CLASS = "class";
+       public static final String CLEAR = "clear";
+       public static final String CLOSE = "close";
+       public static final String COLUMN = "column";
+       public static final String CONNECT = "connect";
+       public static final String CONNECTED = "connected";
+       public static final String COPY = "copy";
+       public static final String CUT = "cut";
+       public static final String DELETE = "delete";
+       public static final String DISCONNECT = "disconnect";
+       public static final String DRIVER = "driver";
+       public static final String EDIT = "edit";
+       public static final String ENTITYGROUP = "entitygroup";
+       public static final String EXPORT = "export";
+       public static final String FILTER = "filter";
+       public static final String FOREIGNKEY = "foreignkey";
+       public static final String FULLDATA = "fulldata";
+       public static final String GRID = "grid";
+       public static final String GROUP = "group";
+       public static final String IMPORT = "import";
+       public static final String KEY = "key";
+       public static final String KEYCOLUMN = "keycolumn";
+       public static final String LOG = "log";
+       public static final String MISSINGSCHEMA = "missingschema";
+       public static final String MISSINGTABLE = "table";
+       public static final String NEXT = "next";
+       public static final String OPEN_TABLE = "table";
+       public static final String PASTE = "paste";
+       public static final String PLAY = "play";
+       public static final String PREVIOUS = "previous";
+       public static final String QMODEL = "qmodel";
+       public static final String QUANTUM = "quantum";
+       public static final String REFRESH = "refresh";
+       public static final String ROLLBACK = "rollback";
+       public static final String SAMPLE = "sample";
+       public static final String SCHEMA = "schema";
+       public static final String SCRIPT = "script";
+       public static final String SEQUENCE = "sequence";
+       public static final String STATEMENT = "statement";
+       public static final String STOP = "stop";
+       public static final String SUBSET = "subset";
+       public static final String SUCCESS = "success";
+       public static final String TABLE = "bigtable";
+       public static final String TEMPLATE = "template";
+       public static final String TORQUE = "torque";
+       public static final String TRIGGER = "trigger";
+       public static final String USER = "user";
+       public static final String VIEW = "view";
+       public static final String WARNING = "warning";
+       public static final String XML = "xml";
+       
+       public static ImageDescriptor getImageDescriptor(String imageName) {
+               return getImageDescriptor(imageName, QuantumPlugin.getDefault());
+       }
+
+       public static Image getImage(String imageName) {
+               return getImage(imageName, QuantumPlugin.getDefault());
+       }
+
+       /**
+        * @param imageName
+        * @param default1
+        * @return
+        */
+       private static Image getImage(String imageName, AbstractUIPlugin plugin) {
+               ImageRegistry registry = plugin.getImageRegistry();
+               String key = stripSuffix(imageName);
+               Image image = registry.get(getVersionAppropriateImage(key));
+               return image;
+       }
+
+       public static ImageDescriptor getImageDescriptor(String imageName, AbstractUIPlugin plugin) {
+               ImageRegistry registry = plugin.getImageRegistry();
+               String key = stripSuffix(imageName);
+               key = getVersionAppropriateImage(key);
+
+               if (VersioningHelper.isEclipse21OrHigher()) {
+                       return VersioningHelper.getDescriptor(registry, key);
+               } else {
+                       return (ImageDescriptor) imageDescriptorMap.get(key);
+               }
+       }
+
+       /**
+        * @param imageName
+        * @return
+        */
+       private static String stripSuffix(String imageName) {
+               return imageName.endsWith(GIF_FILE_EXTENSION) 
+                       ? imageName.substring(0, imageName.length() - 4)
+                       : imageName;
+       }
+
+       /**
+        * @param imageName
+        * @return
+        */
+       private static String getVersionAppropriateImage(String imageName) {
+               String version2Key = imageName + VERSION_2;
+               return !VersioningHelper.isEclipse30() && imageDescriptorMap.containsKey(version2Key) 
+                       ? version2Key : imageName;
+       }
+
+       /**
+        * @param registry
+        * @param url
+        */
+       static void initialize(ImageRegistry registry, URL url) {
+               
+               addImage(registry, url, ADD);
+               addImage(registry, url, BOOKMARK);
+               addImage(registry, url, DISCONNECT);
+               addImage(registry, url, ADD);
+               addImage(registry, url, ADD_SCHEMA);
+               addImage(registry, url, APPEND);
+               addImage(registry, url, AUTOCOMMIT);
+               addImage(registry, url, BOOKMARK);
+               addImage(registry, url, BOOKMARKFILE);
+               addImage(registry, url, CLASS);
+               addImage(registry, url, CLEAR);
+               addImage(registry, url, CLOSE);
+               addImage(registry, url, COLUMN);
+               addImage(registry, url, CONNECT);
+               addImage(registry, url, CONNECTED);
+               addImage(registry, url, COPY);
+               addImage(registry, url, CUT);
+               addImage(registry, url, DELETE);
+               addImage(registry, url, DISCONNECT);
+               addImage(registry, url, DRIVER);
+               addImage(registry, url, EDIT);
+               addImage(registry, url, ENTITYGROUP);
+               addImage(registry, url, EXPORT);
+               addImage(registry, url, FILTER);
+               addImage(registry, url, FOREIGNKEY);
+               addImage(registry, url, FULLDATA);
+               addImage(registry, url, GRID);
+               addImage(registry, url, GROUP);
+               addImage(registry, url, IMPORT);
+               addImage(registry, url, KEY);
+               addImage(registry, url, KEYCOLUMN);
+               addImage(registry, url, LOG);
+               addImage(registry, url, MISSINGSCHEMA);
+               addImage(registry, url, MISSINGTABLE);
+               addImage(registry, url, NEXT);
+               addImage(registry, url, PASTE);
+               addImage(registry, url, PLAY);
+               addImage(registry, url, PREVIOUS);
+               addImage(registry, url, QMODEL);
+               addImage(registry, url, QUANTUM);
+               addImage(registry, url, REFRESH);
+               addImage(registry, url, ROLLBACK);
+               addImage(registry, url, SAMPLE);
+               addImage(registry, url, SCHEMA);
+               addImage(registry, url, SCRIPT);
+               addImage(registry, url, SEQUENCE);
+               addImage(registry, url, STATEMENT);
+               addImage(registry, url, STOP);
+               addImage(registry, url, SUBSET);
+               addImage(registry, url, SUCCESS);
+               addImage(registry, url, TABLE);
+               addImage(registry, url, TEMPLATE);
+               addImage(registry, url, TORQUE);
+               addImage(registry, url, TRIGGER);
+               addImage(registry, url, USER);
+               addImage(registry, url, VIEW);
+               addImage(registry, url, WARNING);
+               addImage(registry, url, XML);
+               
+               if (!VersioningHelper.isEclipse30()) {
+                       addImage(registry, url, CLOSE + VERSION_2);
+                       addImage(registry, url, COPY + VERSION_2);
+                       addImage(registry, url, DELETE + VERSION_2);
+                       addImage(registry, url, EXPORT + VERSION_2);
+                       addImage(registry, url, IMPORT + VERSION_2);
+                       addImage(registry, url, PASTE + VERSION_2);
+                       addImage(registry, url, REFRESH + VERSION_2);
+               }
+       }
+
+       /**
+        * @param registry
+        * @param url
+        */
+       private static void addImage(ImageRegistry registry, URL url, String key) {
+               try {
+                       ImageDescriptor descriptor = ImageDescriptor.createFromURL(
+                                       new URL(url, key + GIF_FILE_EXTENSION));
+                       ImageStore.imageDescriptorMap.put(key, descriptor);
+                       registry.put(key, descriptor);
+               } catch (MalformedURLException e) {
+                       // skip, but try to go on to the next one...
+               }
+       }
+}
index 5a31b26..d3028d8 100644 (file)
@@ -5,18 +5,13 @@ import java.io.FileInputStream;
 import java.io.FileNotFoundException;
 import java.io.FileWriter;
 import java.io.IOException;
+import java.net.MalformedURLException;
 import java.net.URL;
 
 import javax.xml.parsers.DocumentBuilder;
 import javax.xml.parsers.DocumentBuilderFactory;
 import javax.xml.parsers.ParserConfigurationException;
 
-import com.quantum.model.BookmarkCollection;
-import com.quantum.util.xml.XMLHelper;
-import com.quantum.view.subset.SubsetContentProvider;
-
-import org.eclipse.core.resources.ISaveContext;
-import org.eclipse.core.resources.ISaveParticipant;
 import org.eclipse.core.resources.ISavedState;
 import org.eclipse.core.resources.ResourcesPlugin;
 import org.eclipse.core.runtime.CoreException;
@@ -26,6 +21,7 @@ import org.eclipse.core.runtime.Path;
 import org.eclipse.jface.preference.IPreferenceStore;
 import org.eclipse.jface.preference.PreferenceConverter;
 import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.resource.ImageRegistry;
 import org.eclipse.swt.dnd.Clipboard;
 import org.eclipse.swt.graphics.FontData;
 import org.eclipse.swt.graphics.Image;
@@ -41,6 +37,10 @@ import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 import org.xml.sax.SAXException;
 
+import com.quantum.model.BookmarkCollection;
+import com.quantum.util.xml.XMLHelper;
+import com.quantum.view.subset.SubsetContentProvider;
+
 /**
  * Main class of the quantum plugin, sets defaults, saves and recovers state.
  * @author root
@@ -114,11 +114,10 @@ public class QuantumPlugin extends AbstractUIPlugin {
         */
        public void startup() throws CoreException {
                super.startup();
-               ISaveParticipant saveParticipant = new QuantumSaveParticipant();
                ISavedState lastState =
                        ResourcesPlugin.getWorkspace().addSaveParticipant(
                                this,
-                               saveParticipant);
+                               new QuantumSaveParticipant());
                if (lastState != null) {
                IPath location = lastState.lookup(new Path(Messages.getString("QuantumPlugin.saveDir"))); //$NON-NLS-1$
                if (location != null) {
@@ -135,8 +134,10 @@ public class QuantumPlugin extends AbstractUIPlugin {
         * @see org.eclipse.core.runtime.Plugin#shutdown()
         */
        public void shutdown() throws CoreException {
+               if (!sysClip.isDisposed()) {
+                       sysClip.dispose();
+               }
                super.shutdown();
-               sysClip.dispose();
        }
 
        /**
@@ -166,27 +167,11 @@ public class QuantumPlugin extends AbstractUIPlugin {
         }
        }
        
-       /**
-        *  Gets an image descriptof from a file in the icons directory 
-        * @param name of the file to get
-        * @return ImageDescriptor or null if not found
-        */
-       public static ImageDescriptor getImageDescriptor(String name) {
-               ImageDescriptor descriptor = null;
-               try {
-                       URL installURL =
-                               QuantumPlugin.getDefault().getDescriptor().getInstallURL();
-                       URL url = new URL(installURL, Messages.getString("QuantumPlugin.iconsDir") + name); //$NON-NLS-1$
-                       descriptor = ImageDescriptor.createFromURL(url);
-               } catch (Exception e) {
-                       e.printStackTrace();
-               }
-               return descriptor;
-       }
-       public static Image getImage(String name) {
-        ImageDescriptor imageDescriptor = getImageDescriptor(name);
-               return imageDescriptor == null ? null : imageDescriptor.createImage();
-       }
+       
+//     public static Image getImage(String name) {
+//        ImageDescriptor imageDescriptor = getImageDescriptor(name);
+//             return imageDescriptor == null ? null : imageDescriptor.createImage();
+//     }
 
        protected void initializeDefaultPluginPreferences() {
                RGB BACKGROUND = new RGB(255, 255, 255);
@@ -275,68 +260,27 @@ public class QuantumPlugin extends AbstractUIPlugin {
                return tableView;
        }
 
-
-
-       class QuantumSaveParticipant implements ISaveParticipant {
-               /**
-               * @see org.eclipse.core.resources.ISaveParticipant#doneSaving(ISaveContext)
-               */
-               public void doneSaving(ISaveContext context) {
-               }
-               /**
-                * @see org.eclipse.core.resources.ISaveParticipant#prepareToSave(ISaveContext)
-                */
-               public void prepareToSave(ISaveContext context) throws CoreException {
-               }
-
-               /**
-                * @see org.eclipse.core.resources.ISaveParticipant#rollback(ISaveContext)
-                */
-               public void rollback(ISaveContext context) {
-               }
-
-               /**
-                * @see org.eclipse.core.resources.ISaveParticipant#saving(ISaveContext)
-                */
-               public void saving(ISaveContext context) throws CoreException {
-                       switch (context.getKind()) {
-                               case ISaveContext.FULL_SAVE :
-                                       QuantumPlugin quantumPluginInstance = QuantumPlugin.getDefault();
-                                       // save the plug in state 
-                                       if (BookmarkCollection.getInstance().isAnythingChanged()
-                                               || SubsetContentProvider.getInstance().hasChanged()) {
-
-                                               int saveNumber = context.getSaveNumber();
-                                               String saveFileName = Messages.getString("QuantumPlugin.saveDir") + "-" + Integer.toString(saveNumber) + Messages.getString("QuantumPlugin.saveFileExtension"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-                                               File f = quantumPluginInstance.getStateLocation().append(saveFileName).toFile();
-
-                                               // if we fail to write, an exception is thrown and we do not update the path 
-                                               quantumPluginInstance.writeImportantState(f);
-
-                                               context.map(new Path(Messages.getString("QuantumPlugin.saveDir")), new Path(saveFileName)); //$NON-NLS-1$
-                                               context.needSaveNumber();
-
-                                       } else {
-                                               System.out.println("Not saving unchanged bookmarks"); //$NON-NLS-1$
-                                       }
-                                       break;
-                               case ISaveContext.PROJECT_SAVE :
-                                       // get the project related to this save operation 
-                                       //IProject project = context.getProject(); 
-                                       // save its information, if necessary 
-                                       break;
-                               case ISaveContext.SNAPSHOT :
-                                       // This operation needs to be really fast because 
-                                       // snapshots can be requested frequently by the 
-                                       // workspace. 
-                                       break;
-                       }
-               }
-       }
        /**
         * @return
         */
        public Clipboard getSysClip() {
                return sysClip;
        }
+       protected void initializeImageRegistry(ImageRegistry registry) {
+               super.initializeImageRegistry(registry);
+               try {
+                       ImageStore.initialize(registry, getIconLocation());
+               } catch (MalformedURLException e) {
+                       // this should never happen, but if it does, we don't get images.
+               }
+       }
+
+       /**
+        * @return
+        * @throws MalformedURLException
+        */
+       URL getIconLocation() throws MalformedURLException {
+               URL installURL = QuantumPlugin.getDefault().getDescriptor().getInstallURL();
+               return new URL(installURL, "icons/");
+       }
 }
\ No newline at end of file
index ec2da55..326db6a 100644 (file)
@@ -363,3 +363,12 @@ com.quantum.properties.ColumnPropertyPage.column5 = Nullable
 com.quantum.properties.ColumnPropertyPage.column6 = Remarks
 com.quantum.properties.ColumnPropertyPage.true = Yes
 com.quantum.properties.ColumnPropertyPage.false = No
+
+com.quantum.actions.BaseExecuteAction.execute1=Executing Query...
+com.quantum.actions.BaseExecuteAction.execute2=Executing Query..
+com.quantum.actions.BaseExecuteAction.done=Done ({0} queries executed, {1} rows updated, {2} result sets displayed, {3} errors, {4} seconds)
+com.quantum.actions.BaseExecuteAction.selectBookmark=Select a bookmark
+
+com.quantum.actions.ExecuteAction.parsing=Parsing sql script...
+com.quantum.actions.ExecuteAction.autocommitTitle=Autocommit changed
+com.quantum.actions.ExecuteAction.autocommitMessage=The autocommit setting of the bookmark, {0} has been changed.
\ No newline at end of file
diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/QuantumSaveParticipant.java b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/QuantumSaveParticipant.java
new file mode 100644 (file)
index 0000000..ac9ac9d
--- /dev/null
@@ -0,0 +1,70 @@
+package com.quantum;
+
+import java.io.File;
+
+import com.quantum.model.BookmarkCollection;
+import com.quantum.view.subset.SubsetContentProvider;
+
+import org.eclipse.core.resources.ISaveContext;
+import org.eclipse.core.resources.ISaveParticipant;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.Path;
+
+
+class QuantumSaveParticipant implements ISaveParticipant {
+       
+       /**
+       * @see org.eclipse.core.resources.ISaveParticipant#doneSaving(ISaveContext)
+       */
+       public void doneSaving(ISaveContext context) {
+       }
+       /**
+        * @see org.eclipse.core.resources.ISaveParticipant#prepareToSave(ISaveContext)
+        */
+       public void prepareToSave(ISaveContext context) throws CoreException {
+       }
+
+       /**
+        * @see org.eclipse.core.resources.ISaveParticipant#rollback(ISaveContext)
+        */
+       public void rollback(ISaveContext context) {
+       }
+
+       /**
+        * @see org.eclipse.core.resources.ISaveParticipant#saving(ISaveContext)
+        */
+       public void saving(ISaveContext context) throws CoreException {
+               switch (context.getKind()) {
+                       case ISaveContext.FULL_SAVE :
+                               QuantumPlugin quantumPluginInstance = QuantumPlugin.getDefault();
+                               // save the plug in state 
+                               if (BookmarkCollection.getInstance().isAnythingChanged()
+                                       || SubsetContentProvider.getInstance().hasChanged()) {
+
+                                       int saveNumber = context.getSaveNumber();
+                                       String saveFileName = Messages.getString("QuantumPlugin.saveDir") + "-" + Integer.toString(saveNumber) + Messages.getString("QuantumPlugin.saveFileExtension"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+                                       File f = quantumPluginInstance.getStateLocation().append(saveFileName).toFile();
+
+                                       // if we fail to write, an exception is thrown and we do not update the path 
+                                       quantumPluginInstance.writeImportantState(f);
+
+                                       context.map(new Path(Messages.getString("QuantumPlugin.saveDir")), new Path(saveFileName)); //$NON-NLS-1$
+                                       context.needSaveNumber();
+
+                               } else {
+                                       System.out.println("Not saving unchanged bookmarks"); //$NON-NLS-1$
+                               }
+                               break;
+                       case ISaveContext.PROJECT_SAVE :
+                               // get the project related to this save operation 
+                               //IProject project = context.getProject(); 
+                               // save its information, if necessary 
+                               break;
+                       case ISaveContext.SNAPSHOT :
+                               // This operation needs to be really fast because 
+                               // snapshots can be requested frequently by the 
+                               // workspace. 
+                               break;
+               }
+       }
+}
\ No newline at end of file
diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/actions/BaseExecuteAction.java b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/actions/BaseExecuteAction.java
new file mode 100644 (file)
index 0000000..5e8c9d6
--- /dev/null
@@ -0,0 +1,212 @@
+package com.quantum.actions;
+
+import java.io.IOException;
+import java.sql.Connection;
+import java.sql.SQLException;
+import java.util.List;
+
+import com.quantum.ImageStore;
+import com.quantum.Messages;
+import com.quantum.model.Bookmark;
+import com.quantum.model.BookmarkCollection;
+import com.quantum.sql.MultiSQLServer;
+import com.quantum.sql.SQLResults;
+import com.quantum.ui.dialog.ExceptionDisplayDialog;
+import com.quantum.ui.dialog.SimpleSelectionDialog;
+import com.quantum.util.connection.ConnectionUtil;
+import com.quantum.view.LogProxy;
+import com.quantum.view.tableview.DefaultSizes;
+import com.quantum.view.tableview.TableView;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IStatusLineManager;
+import org.eclipse.jface.dialogs.ErrorDialog;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.swt.widgets.Shell;
+
+/**
+ * @author BC
+ */
+public abstract class BaseExecuteAction extends Action {
+       
+       class Metrics {
+               int resultCount = 0;
+               int resultUpdateCount = 0;
+               int errorCount = 0;
+               int resultsDisplayed = 0;
+               double queryDuration= 0.0;
+               
+               public void measure(SQLResults results) {
+                       if (results == null) {
+                               errorCount++;
+                       } else {
+                               queryDuration += results.getTime()/1000.0; // calculate the execution time (in seconds)                          
+                               resultCount++;
+                               if (results.isResultSet()) {
+                                       resultsDisplayed++;
+                               } else {
+                                       resultUpdateCount += results.getUpdateCount();
+                               }
+                       }
+               }
+               
+               public boolean hasErrors() {
+                       return this.errorCount > 0;
+               }
+               
+               Object[] getResults() {
+                       return new Object[] {
+                               new Integer(this.resultCount),
+                               new Integer(this.resultUpdateCount),
+                               new Integer(this.resultsDisplayed),
+                               new Integer(this.errorCount),
+                               new Double(this.queryDuration),
+                       };
+               }
+       }
+    
+    private ConnectionUtil connectionUtil = new ConnectionUtil();
+    
+    protected abstract Shell getShell();
+    
+    protected Connection getConnection(Bookmark bookmark) {
+        return this.connectionUtil.getConnection(bookmark, getShell());
+    }
+
+       String execute1 = Messages.getString(BaseExecuteAction.class, "execute1");
+       String execute2 = Messages.getString(BaseExecuteAction.class, "execute2");
+
+       public void run() {
+               Bookmark bookmark = getBookmark();
+               if (bookmark != null) {
+               execute(bookmark);
+               }
+       }
+
+       /**
+        * @param bookmark
+        */
+       protected void execute(Bookmark bookmark) {
+               if (bookmark != null) {
+               try {
+                               getStatusLineManager().setErrorMessage(null);
+                               Connection connection = getConnection(bookmark);
+                               if (connection != null) {
+                                       execute(bookmark, connection);
+                               }
+               } catch (IOException e) {
+                   ExceptionDisplayDialog.openError(getShell(), null, null, e);
+               } catch (SQLException e) {
+                   ExceptionDisplayDialog.openError(getShell(), null, null, e);
+               } catch (CoreException e) {
+                   ErrorDialog.openError(getShell(), null, null, e.getStatus());
+               }
+               }
+       }
+
+       /**
+        * @param bookmark
+        * @param connection
+        * @throws IOException
+        * @throws CoreException
+        */
+       protected void execute(Bookmark bookmark, Connection connection) 
+                       throws IOException, CoreException, SQLException {
+               getStatusLineManager().setMessage(execute1);
+               MultiSQLServer server = MultiSQLServer.getInstance();
+
+               Metrics metrics = new Metrics();
+               
+               List queries = getQueries();
+               IProgressMonitor progressBar = getStatusLineManager().getProgressMonitor();
+               progressBar.beginTask("queries", queries.size());
+               for (int i = 0; i < queries.size(); i++) {
+                       getStatusLineManager().setMessage((i % 2 == 0) ? execute1 : execute2);
+                  
+                       String query = (String) queries.get(i);
+                       System.out.println(">" + query + "<"); //$NON-NLS-1$ //$NON-NLS-2$
+                       if (query != null && query.trim().length() > 0) {
+                               SQLResults results = getSQLResults(connection, server, query);
+                               metrics.measure(results);
+                               if (results != null) {
+                                       bookmark.addQuery(query);
+                                       if (results.isResultSet()) {
+                                               TableView.getInstance().loadQuery(bookmark, results);
+                                       }
+                               }
+                   }
+                       progressBar.worked(i);
+               }
+               progressBar.done();
+               displayFinalStatusMessage(metrics);
+       }
+
+       /**
+        * @return
+        * @throws CoreException
+        * @throws IOException
+        */
+       protected abstract List getQueries() throws IOException, CoreException;
+
+       /**
+        * @return
+        */
+       protected abstract IStatusLineManager getStatusLineManager();
+
+       /**
+        * @param metrics
+        */
+       private void displayFinalStatusMessage(Metrics metrics) {
+               String message = Messages.getString(
+                               BaseExecuteAction.class, 
+                               "done", //$NON-NLS-1$ //$NON-NLS-2$
+                               metrics.getResults()); 
+               if (metrics.hasErrors()) {
+                       getStatusLineManager().setErrorMessage(
+                                       ImageStore.getImage(ImageStore.STOP), message);
+               } else {
+                       getStatusLineManager().setMessage(
+                                       ImageStore.getImage(ImageStore.SUCCESS), message);
+               }
+       }
+
+       /**
+        * @param connection
+        * @param server
+        * @param query
+        * @return
+        */
+       private SQLResults getSQLResults(Connection connection, MultiSQLServer server, String query) {
+               SQLResults results = null;
+               try {
+                       results = server.execute(connection, query, 1, 
+                                       DefaultSizes.PAGE_SIZE, DefaultSizes.MAX_COLUMN_SIZE);
+               } catch (SQLException e) {
+                       LogProxy log = LogProxy.getInstance();
+                       log.addText(LogProxy.ERROR,
+                               "Error Executing: " + query + ":" + e.toString(), e); //$NON-NLS-1$ //$NON-NLS-2$
+                       MessageDialog.openConfirm(getShell(), 
+                                       "Database returned error", 
+                                       e.getLocalizedMessage());  //$NON-NLS-1$ 
+               }
+               return results;
+       }
+
+       protected Bookmark getBookmark() {
+               Bookmark bookmark = null;
+               SimpleSelectionDialog dialog = new SimpleSelectionDialog(
+                               getShell(), 
+                               Messages.getString(BaseExecuteAction.class, "selectBookmark"), 
+                               BookmarkCollection.getInstance().getBookmarks(),
+                               ImageStore.getImage(ImageStore.BOOKMARK));
+               if (SimpleSelectionDialog.OK == dialog.open()) {
+                       IStructuredSelection selection = dialog.getSelection();
+                       
+                       bookmark = (Bookmark) selection.getFirstElement();
+               }
+               return bookmark;
+       }
+}
index 05eeed9..ba99f42 100644 (file)
@@ -3,8 +3,8 @@ package com.quantum.actions;
 import java.sql.Connection;
 import java.util.Iterator;
 
+import com.quantum.ImageStore;
 import com.quantum.Messages;
-import com.quantum.QuantumPlugin;
 import com.quantum.model.Bookmark;
 import com.quantum.util.connection.ConnectionUtil;
 import com.quantum.view.bookmark.BookmarkNode;
@@ -12,6 +12,7 @@ import com.quantum.view.bookmark.BookmarkNode;
 import org.eclipse.jface.action.IAction;
 import org.eclipse.jface.viewers.IStructuredSelection;
 import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IActionDelegate;
 import org.eclipse.ui.IViewPart;
 import org.eclipse.ui.actions.SelectionListenerAction;
 
@@ -23,7 +24,7 @@ public class ConnectAction extends SelectionListenerAction {
         super(Messages.getString(ConnectAction.class.getName() + ".text"));
         this.view = view;
         setImageDescriptor(
-            QuantumPlugin.getImageDescriptor("connect.gif")); //$NON-NLS-1$
+            ImageStore.getImageDescriptor(ImageStore.CONNECT));
     }
 
     private IViewPart view;
index a00c028..2064fd2 100644 (file)
@@ -3,8 +3,8 @@ package com.quantum.actions;
 import java.util.Iterator;
 import java.util.List;
 
+import com.quantum.ImageStore;
 import com.quantum.Messages;
-import com.quantum.QuantumPlugin;
 import com.quantum.model.BookmarkCollection;
 import com.quantum.view.bookmark.BookmarkNode;
 
@@ -24,7 +24,7 @@ public class DeleteBookmarkAction extends SelectionListenerAction {
     
        public DeleteBookmarkAction(IViewPart view) {
         super(Messages.getString(DeleteBookmarkAction.class.getName() + ".text"));
-        setImageDescriptor(QuantumPlugin.getImageDescriptor("delete.gif"));
+        setImageDescriptor(ImageStore.getImageDescriptor(ImageStore.DELETE));
                this.view = view;
        }
 
index 7966a08..3860403 100644 (file)
@@ -4,8 +4,8 @@ import java.util.Iterator;
 import java.util.List;
 import java.util.Vector;
 
+import com.quantum.ImageStore;
 import com.quantum.Messages;
-import com.quantum.QuantumPlugin;
 import com.quantum.model.Bookmark;
 import com.quantum.model.ConnectionException;
 import com.quantum.view.bookmark.BookmarkNode;
@@ -30,7 +30,7 @@ public class DisconnectAction extends SelectionListenerAction {
         super(Messages.getString(DisconnectAction.class.getName() + ".text"));
         this.view = view;
         setImageDescriptor(
-            QuantumPlugin.getImageDescriptor("disconnect.gif")); //$NON-NLS-1$
+                       ImageStore.getImageDescriptor(ImageStore.DISCONNECT));
     }
 
 
index 295cfa3..d0044f5 100644 (file)
 package com.quantum.actions;
 
+import java.io.IOException;
 import java.sql.Connection;
 import java.sql.SQLException;
+import java.util.List;
 import java.util.Vector;
 
+import com.quantum.ImageStore;
 import com.quantum.Messages;
-import com.quantum.QuantumPlugin;
 import com.quantum.model.Bookmark;
-import com.quantum.sql.MultiSQLServer;
+import com.quantum.model.BookmarkCollection;
 import com.quantum.sql.SQLParser;
-import com.quantum.sql.SQLResults;
-import com.quantum.view.LogProxy;
 import com.quantum.view.SQLQueryView;
-import com.quantum.view.bookmark.BookmarkNode;
-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.core.runtime.CoreException;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.ActionContributionItem;
+import org.eclipse.jface.action.IMenuCreator;
 import org.eclipse.jface.action.IStatusLineManager;
 import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.swt.events.MenuAdapter;
+import org.eclipse.swt.events.MenuEvent;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.swt.widgets.MenuItem;
 import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.IViewActionDelegate;
-import org.eclipse.ui.IViewPart;
 
 /**
  * Executes a query from the QueryView
  *
  * @author panic
  */
-public class ExecuteAction extends BaseSQLAction implements IViewActionDelegate {
-       SQLQueryView view;
-       String execute1 = Messages.getString("ExecuteAction.Executing_Query3"); //$NON-NLS-1$
-       String execute2 = Messages.getString("ExecuteAction.Executing_Query2"); //$NON-NLS-1$
-    
-       public ExecuteAction() {
+public class ExecuteAction extends BaseExecuteAction implements IMenuCreator {
+       private SQLQueryView view;
+       
+       public ExecuteAction(SQLQueryView view) {
+               this.view = view;
                setActionDefinitionId("com.quantum.actions.ExecuteAction");
-               setImageDescriptor(QuantumPlugin.getImageDescriptor("play.gif"));
+               setImageDescriptor(ImageStore.getImageDescriptor(ImageStore.PLAY));
                setText(Messages.getString("sqlqueryview.executeQuery"));
                setToolTipText(Messages.getString("sqlqueryview.executeQuery"));
-       }
-    
-       public void init(IViewPart view) {
-               this.view = (SQLQueryView) view;
+               setMenuCreator(this);
        }
 
-       public void run(IAction action) {
-               run();
-       }
-    
-       public void run() {
-               BookmarkNode current = BookmarkView.getInstance().getCurrentBookmark();
-               if (current == null)
-               {
-                        MessageDialog.openInformation(
-                          view.getSite().getShell(),"Sorry","Please select a bookmark to use as connection.");
-                        return;
-               }                  
-               getStatusLineManager().setErrorMessage(null);
-               Connection con = getConnection();
-               getStatusLineManager().setMessage(execute1);
-               MultiSQLServer server = MultiSQLServer.getInstance();
-               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
-               queries = SQLParser.parse(viewQuery);
-               for (int i = 0; i < queries.size(); i++) {
-                       String query = (String) queries.elementAt(i);
-                       System.out.println(query);
-               }
-               int resultCount = 0;
-               int resultUpdateCount = 0;
-               int errorCount = 0;
-               int resultsDisplayed = 0;
-               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 (i % 2 == 0) {
-                               getStatusLineManager().setMessage(execute1);
-                       } else {
-                               getStatusLineManager().setMessage(execute2);
-                       }
-                  
-                  String query = (String) queries.elementAt(i);
-                  System.out.println(">" + query + "<"); //$NON-NLS-1$ //$NON-NLS-2$
-                  if (con != null && !query.equals("")) { //$NON-NLS-1$
        
-                       SQLResults results;
-                       try {
-                               startTime = System.currentTimeMillis(); // Start the measure of execution time
-                               results = server.execute(con, query, 1, DefaultSizes.PAGE_SIZE, DefaultSizes.MAX_COLUMN_SIZE);
-                               queryDuration = (System.currentTimeMillis() - startTime)/1000; // calculate the execution time (in seconds)                              
-                               current.getBookmark().addQuery(query);
-                       } catch (SQLException e) {
-                                errorCount++;
-                               LogProxy log = LogProxy.getInstance();
-                               log.addText(
-                                       LogProxy.ERROR,
-                                       "Error Executing: " + query + ":" + e.toString(), e); //$NON-NLS-1$ //$NON-NLS-2$
-                               MessageDialog.openConfirm(view.getSite().getShell(), "Database returned error", e.getLocalizedMessage());  //$NON-NLS-1$ 
-                               continue;
-                       }
-                          resultCount++;
-                          if (results.isResultSet()) {
-                                TableView.getInstance().loadQuery(current.getBookmark(), results);
-                                resultsDisplayed++;
-                          } else {
-                                int count = results.getUpdateCount();
-                                if (count > 0) {
-                                       resultUpdateCount += results.getUpdateCount();
-                                }
-                          }
-                   }
-System.out.println(getStatusLineManager().getProgressMonitor() == null ? "not found" : "found!");
-                       progressBar.worked(i);
-//                 view.setProgress(i + 1, queries.size());
+       
+       protected void execute(Bookmark bookmark, Connection connection) 
+                       throws IOException, CoreException, SQLException {
+               
+               boolean autoCommitPreference = this.view.isAutoCommitPreference();
+               boolean changed = false;
+               if (connection.getAutoCommit() != autoCommitPreference) {
+                       connection.setAutoCommit(autoCommitPreference);
+                       changed = true;
                }
-               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$
-               if (errorCount > 0) {
-                       getStatusLineManager().setErrorMessage(
-                                       QuantumPlugin.getImage("stop.gif"), message);
-               } else {
-                       getStatusLineManager().setMessage(
-                                       QuantumPlugin.getImage("success.gif"), message);
+               
+               super.execute(bookmark, connection);
+               
+               if (changed) {
+                       MessageDialog.openInformation(getShell(), 
+                                       Messages.getString(ExecuteAction.class, "autocommitTitle"), 
+                                       Messages.getString(ExecuteAction.class, "autocommitMessage", 
+                                                       new Object[] { bookmark.getName() }));
                }
        }
+       /**
+        * @return
+        */
+       protected List getQueries() {
+               getStatusLineManager().setMessage(
+                               Messages.getString(ExecuteAction.class, "parsing")); //$NON-NLS-1$
+               Vector queries = SQLParser.parse(view.getQuery());
+               return queries;
+       }
 
        /**
         * @return
         */
-       private IStatusLineManager getStatusLineManager() {
+       protected IStatusLineManager getStatusLineManager() {
                return this.view.getViewSite().getActionBars().getStatusLineManager();
        }
 
-       public void selectionChanged(IAction action, ISelection selection) {
+       protected Shell getShell() {
+               return this.view.getViewSite().getShell();
        }
-       protected Bookmark getBookmark() {
-               BookmarkNode current = BookmarkView.getInstance().getCurrentBookmark();
-               return current.getBookmark();
+
+       public void dispose() {
        }
 
-       /* (non-Javadoc)
-        * @see com.quantum.actions.BaseSQLAction#getShell()
-        */
-       protected Shell getShell() {
-               return this.view.getViewSite().getShell();
+       public Menu getMenu(Control parent) {
+               Menu menu = new Menu(parent);
+               /**
+                * Add listener to repopulate the menu each time
+                * it is shown because the list of bookmarks may have changed.
+                */
+               menu.addMenuListener(new MenuAdapter() {
+                       public void menuShown(MenuEvent e) {
+                               Menu menu = (Menu)e.widget;
+                               MenuItem[] items = menu.getItems();
+                               for (int i=0; i < items.length; i++) {
+                                       items[i].dispose();
+                               }
+                               fillMenu(menu);
+                       }
+               });
+               return menu;
+       }
+
+       public Menu getMenu(Menu parent) {
+               // never called...
+               return null;
+       }
+
+       protected void fillMenu(Menu menu) {
+               Bookmark[] bookmarks = BookmarkCollection.getInstance().getBookmarks();
+               for (int i = 0, length = bookmarks == null ? 0 : bookmarks.length; i < length; i++) {
+                       final Bookmark bookmark = bookmarks[i];
+                       Action action = new Action() {
+                               public void run() {
+                                       ExecuteAction.this.execute(bookmark);
+                               }
+                       };
+                       action.setImageDescriptor(ImageStore.getImageDescriptor(ImageStore.BOOKMARK));
+                       action.setText(bookmark.getName());
+                       ActionContributionItem item = new ActionContributionItem(action);
+                       item.fill(menu, -1);
+               }
        }
 }
index c1e2486..ffdac6c 100644 (file)
@@ -1,51 +1,43 @@
 package com.quantum.actions;
 
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
 import java.io.IOException;
-import java.sql.Connection;
-import java.sql.SQLException;
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
 
+import com.quantum.ImageStore;
 import com.quantum.Messages;
 import com.quantum.model.Bookmark;
 import com.quantum.model.BookmarkCollection;
-import com.quantum.model.ConnectionException;
-import com.quantum.sql.MultiSQLServer;
 import com.quantum.sql.SQLParser;
-import com.quantum.sql.SQLResults;
-import com.quantum.ui.dialog.BookmarkSelectionDialog;
-import com.quantum.ui.dialog.ExceptionDisplayDialog;
+import com.quantum.ui.dialog.SimpleSelectionDialog;
 import com.quantum.util.io.InputStreamHelper;
-import com.quantum.view.tableview.DefaultSizes;
-import com.quantum.view.tableview.TableView;
 
 import org.eclipse.core.resources.IFile;
 import org.eclipse.core.runtime.CoreException;
 import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.dialogs.ErrorDialog;
+import org.eclipse.jface.action.IStatusLineManager;
 import org.eclipse.jface.viewers.ISelection;
 import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.window.Window;
 import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IEditorPart;
 import org.eclipse.ui.IObjectActionDelegate;
+import org.eclipse.ui.IViewPart;
 import org.eclipse.ui.IWorkbenchPart;
 
 /**
  * This action can be executed against any .sql file, regardless of 
  * whether or not the Quantum perspective is open.
  * 
- * @author BC
+ * @author BC Holmes
  */
-public class ExecuteAgainstAction extends BaseSQLAction
-    implements IObjectActionDelegate, PropertyChangeListener {
+public class ExecuteAgainstAction extends BaseExecuteAction
+    implements IObjectActionDelegate {
 
-    private String selectedBookmark = null;
     private IFile[] files = null;
 
     private IWorkbenchPart workbenchPart;
+    
 
     /**
      * @see IObjectActionDelegate#setActivePart(IAction, IWorkbenchPart)
@@ -59,99 +51,7 @@ public class ExecuteAgainstAction extends BaseSQLAction
     }
 
     /**
-     * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
-     */
-    public void run(IAction action) {
-        
-        BookmarkSelectionDialog dialog = new BookmarkSelectionDialog(getShell());
-        dialog.addPropertyChangeListener(this);
-        int result = dialog.open();
-
-        if (result == Window.OK) {
-            try {
-                executeAgainstBookmark();
-            } catch (SQLException e) {
-                ExceptionDisplayDialog.openError(getShell(), 
-                    null, 
-                    null, e);
-            } catch (IOException e) {
-                ExceptionDisplayDialog.openError(getShell(), 
-                    Messages.getString("ExecuteAgainstAction.title"), 
-                    Messages.getString("ExecuteAgainstAction.IOException"), e);
-            } catch (ConnectionException e) {
-                ExceptionDisplayDialog.openError(getShell(), 
-                    null, 
-                    null, e);
-            } catch (CoreException e) {
-                ErrorDialog.openError(getShell(), null, null, e.getStatus());
-            }
-        }
-    }
-    
-    protected Bookmark getBookmark() {
-        return BookmarkCollection.getInstance().find(this.selectedBookmark);
-    }
-    
-    private void executeAgainstBookmark()
-        throws SQLException, IOException, CoreException, ConnectionException {
-        Bookmark bookmark = getBookmark();
-        if (bookmark != null) {
-            boolean alreadyConnected = bookmark.isConnected();
-            Connection connection = getConnection();
-            try {
-                for (int i = 0,
-                    length = (this.files == null) ? 0 : this.files.length;
-                    connection != null && i < length;
-                    i++) {
-                    executeAgainstBookmark(bookmark, connection, this.files[i]);
-                }
-            } finally {
-                if (!alreadyConnected && connection != null) {
-                    bookmark.disconnect();
-                }
-            }
-        }
-    }
-
-    private void executeAgainstBookmark(
-        Bookmark bookmark,
-        Connection connection,
-        IFile file)
-        throws SQLException, IOException, CoreException {
-        executeAgainstBookmark(
-            bookmark,
-            connection,
-            InputStreamHelper.readIntoString(file.getContents()));
-    }
-
-    private void executeAgainstBookmark(
-        Bookmark bookmark,
-        Connection connection,
-        String queries)
-        throws SQLException {
-        List queryList = SQLParser.parse(queries);
-        MultiSQLServer server = MultiSQLServer.getInstance();
-        
-        for (Iterator i = queryList.iterator(); i.hasNext();) {
-            String query = (String) i.next();
-            SQLResults results =
-                server.execute(
-                    connection,
-                    query,
-                    1,
-                    DefaultSizes.PAGE_SIZE,
-                    DefaultSizes.MAX_COLUMN_SIZE);
-            if (results.isResultSet()) {
-                TableView view = TableView.getInstance();
-                if (view != null) {
-                    view.loadQuery(bookmark, results);
-                }
-            }
-        }
-    }
-
-    /**
-     * This method is called with a new selection has been made on one 
+     * This method is called when a new selection has been made on one 
      * of the views.
      * 
      * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection)
@@ -165,7 +65,6 @@ public class ExecuteAgainstAction extends BaseSQLAction
             for (Iterator i = structuredSelection.iterator(); i.hasNext();) {
                 Object temp = i.next();
                 if (temp != null && temp instanceof IFile) {
-                    System.out.println(((IFile) temp).getName());
                     list.add(temp);
                 }
             }
@@ -173,12 +72,31 @@ public class ExecuteAgainstAction extends BaseSQLAction
         }
     }
 
-    /**
-     * @see java.beans.PropertyChangeListener#propertyChange(java.beans.PropertyChangeEvent)
-     */
-    public void propertyChange(PropertyChangeEvent event) {
-        if ("selection".equals(event.getPropertyName())) {
-            this.selectedBookmark = (String) event.getNewValue();
-        }
-    }
+       /* (non-Javadoc)
+        * @see com.quantum.actions.BaseSQLAction#getQueries()
+        */
+       protected List getQueries() throws IOException, CoreException {
+               List list = new ArrayList();
+               for (int i = 0, length = this.files == null ? 0 : this.files.length; i < length; i++) {
+                       String fileContents = InputStreamHelper.readIntoString(this.files[i].getContents());
+                       List queryList = SQLParser.parse(fileContents);
+                       list.addAll(queryList);
+               }
+               return list;
+       }
+
+       protected IStatusLineManager getStatusLineManager() {
+               if (this.workbenchPart instanceof IViewPart) {
+                       return ((IViewPart) this.workbenchPart).getViewSite().getActionBars().getStatusLineManager();
+               } else {
+                       return null;
+               }
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
+        */
+       public void run(IAction action) {
+               run();
+       }
 }
index cef3fe7..cce682b 100644 (file)
@@ -6,8 +6,8 @@ import java.io.IOException;
 import java.io.PrintWriter;
 import java.util.StringTokenizer;
 
+import com.quantum.ImageStore;
 import com.quantum.Messages;
-import com.quantum.QuantumPlugin;
 import com.quantum.util.StringUtil;
 import com.quantum.view.LogProxy;
 import com.quantum.view.SQLLogView;
@@ -24,7 +24,7 @@ public class ExportQueryAction extends Action implements IViewActionDelegate  {
        SQLQueryView view;
        
        public ExportQueryAction() {
-               setImageDescriptor(QuantumPlugin.getImageDescriptor("export.gif"));
+               setImageDescriptor(ImageStore.getImageDescriptor(ImageStore.EXPORT));
                setText(Messages.getString("sqlqueryview.exportQuery"));
                setToolTipText(Messages.getString("sqlqueryview.exportQuery"));
        }
index 16cda89..22dbe66 100644 (file)
@@ -5,6 +5,7 @@ import java.io.File;
 import java.io.FileReader;
 import java.io.IOException;
 
+import com.quantum.ImageStore;
 import com.quantum.Messages;
 import com.quantum.QuantumPlugin;
 import com.quantum.view.LogProxy;
@@ -29,7 +30,7 @@ public class ImportQueryAction extends Action implements IViewActionDelegate {
        
        public ImportQueryAction() {
                setText(Messages.getString("sqlqueryview.importQuery"));
-               setImageDescriptor(QuantumPlugin.getImageDescriptor("import.gif"));
+               setImageDescriptor(ImageStore.getImageDescriptor(ImageStore.IMPORT));
                setToolTipText(Messages.getString("sqlqueryview.importQuery"));
        }
        
index b3dbd19..13ade29 100644 (file)
@@ -1,7 +1,7 @@
 package com.quantum.actions;
 
+import com.quantum.ImageStore;
 import com.quantum.Messages;
-import com.quantum.QuantumPlugin;
 import com.quantum.wizards.BookmarkWizard;
 
 import org.eclipse.jface.action.Action;
@@ -17,9 +17,9 @@ public class NewBookmarkAction extends Action {
 
     public NewBookmarkAction(IViewPart view) {
         this.view = view;
-        setText(Messages.getString(getClass().getName() + ".text")); //$NON-NLS-1$
-        setToolTipText(Messages.getString(getClass().getName() + ".text")); //$NON-NLS-1$
-        setImageDescriptor(QuantumPlugin.getImageDescriptor("bookmarks.gif")); //$NON-NLS-1$
+        setText(Messages.getString(getClass(), "text")); //$NON-NLS-1$
+        setToolTipText(Messages.getString(getClass(), "text")); //$NON-NLS-1$
+        setImageDescriptor(ImageStore.getImageDescriptor(ImageStore.BOOKMARK));
     }
 
     public void run() {
index 13d1d06..83a7a26 100644 (file)
@@ -1,9 +1,7 @@
 package com.quantum.actions;
 
-import org.eclipse.ui.IViewPart;
-
+import com.quantum.ImageStore;
 import com.quantum.Messages;
-import com.quantum.QuantumPlugin;
 import com.quantum.adapters.DatabaseAdapter;
 import com.quantum.model.Bookmark;
 import com.quantum.sql.SQLResults;
@@ -11,6 +9,8 @@ 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 {
     
     /**
@@ -18,8 +18,8 @@ public class NextSequenceAction extends BaseSequenceAction {
      * @param view
      */
     public NextSequenceAction(IViewPart view) {
-        super(Messages.getString(NextSequenceAction.class.getName() + ".text"), view);
-        setImageDescriptor(QuantumPlugin.getImageDescriptor("append.gif"));    
+        super(Messages.getString(NextSequenceAction.class, "text"), view);
+        setImageDescriptor(ImageStore.getImageDescriptor(ImageStore.APPEND));    
     }
     
        public void run() {
index c632ba2..ab63311 100644 (file)
@@ -4,10 +4,8 @@
  */
 package com.quantum.actions;
 
-import org.eclipse.ui.IViewPart;
-
+import com.quantum.ImageStore;
 import com.quantum.Messages;
-import com.quantum.QuantumPlugin;
 import com.quantum.adapters.DatabaseAdapter;
 import com.quantum.model.Bookmark;
 import com.quantum.sql.SQLResults;
@@ -15,6 +13,8 @@ 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
@@ -22,7 +22,7 @@ public class PrevSequenceAction extends BaseSequenceAction {
      */
     public PrevSequenceAction(IViewPart view) {
         super(Messages.getString(PrevSequenceAction.class.getName() + ".text"), view);
-        setImageDescriptor(QuantumPlugin.getImageDescriptor("grid.gif"));
+        setImageDescriptor(ImageStore.getImageDescriptor(ImageStore.GRID));
     }
 
     public void run() {
index c28df56..366644b 100644 (file)
@@ -4,8 +4,8 @@ import java.sql.SQLException;
 import java.util.Iterator;
 import java.util.List;
 
+import com.quantum.ImageStore;
 import com.quantum.Messages;
-import com.quantum.QuantumPlugin;
 import com.quantum.model.NotConnectedException;
 import com.quantum.ui.dialog.ExceptionDisplayDialog;
 import com.quantum.view.bookmark.TreeNode;
@@ -19,9 +19,9 @@ import org.eclipse.ui.actions.SelectionListenerAction;
 public class RefreshBookmarkAction extends SelectionListenerAction {
     private IViewPart view;
        public RefreshBookmarkAction(IViewPart view) {
-        super(Messages.getString(RefreshBookmarkAction.class.getName() + ".text"));
+        super(Messages.getString(RefreshBookmarkAction.class, "text"));
                this.view = view;
-        setImageDescriptor(QuantumPlugin.getImageDescriptor("refresh.gif"));
+        setImageDescriptor(ImageStore.getImageDescriptor(ImageStore.REFRESH));
        }
 
        public void run() {
index 45c6a7d..91b9916 100644 (file)
@@ -1,7 +1,7 @@
 package com.quantum.actions;
 
+import com.quantum.ImageStore;
 import com.quantum.Messages;
-import com.quantum.QuantumPlugin;
 import com.quantum.model.Entity;
 import com.quantum.view.bookmark.EntityNode;
 import com.quantum.view.tableview.TableView;
@@ -18,9 +18,9 @@ public class ViewTableAction extends SelectionListenerAction {
     private Entity entity;
     
        public ViewTableAction(IViewPart view) {
-        super(Messages.getString(ViewTableAction.class.getName() + ".text"));
+        super(Messages.getString(ViewTableAction.class, "text"));
         setImageDescriptor(
-            QuantumPlugin.getImageDescriptor("table.gif")); //$NON-NLS-1$
+                       ImageStore.getImageDescriptor(ImageStore.OPEN_TABLE));
        }
 
        public void run() {
index 5215912..9d16eef 100644 (file)
@@ -3,8 +3,8 @@ package com.quantum.actions;
 import java.sql.Connection;
 import java.util.List;
 
+import com.quantum.ImageStore;
 import com.quantum.Messages;
-import com.quantum.QuantumPlugin;
 import com.quantum.model.Bookmark;
 import com.quantum.model.Entity;
 import com.quantum.sql.SQLResults;
@@ -26,7 +26,7 @@ public class ViewTableDetailsAction extends SelectionListenerAction  {
        
        public ViewTableDetailsAction(IViewPart view) {
         super(Messages.getString(ViewTableDetailsAction.class, "text"));
-        setImageDescriptor(QuantumPlugin.getImageDescriptor("table.gif")); //$NON-NLS-1$
+        setImageDescriptor(ImageStore.getImageDescriptor(ImageStore.OPEN_TABLE));
                this.view = view;
        }
 
index d31c905..437dbf4 100644 (file)
@@ -8,11 +8,11 @@ public class DB2AS400Adapter extends DatabaseAdapter {
        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$
+                               "' AND TABLE_TYPE IN ('T', 'P')"; //$NON-NLS-1$ //$NON-NLS-2$
     }
     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$
+                        "' AND TABLE_TYPE IN ('V', 'L')"; //$NON-NLS-1$ //$NON-NLS-2$
     }
 }
index 985c0d8..b2993fe 100644 (file)
@@ -8,6 +8,8 @@ import org.eclipse.jface.preference.IPreferenceStore;
 import org.eclipse.jface.preference.PreferenceConverter;
 import org.eclipse.jface.text.IDocument;
 import org.eclipse.jface.text.TextAttribute;
+import org.eclipse.jface.text.contentassist.ContentAssistant;
+import org.eclipse.jface.text.contentassist.IContentAssistant;
 import org.eclipse.jface.text.presentation.IPresentationReconciler;
 import org.eclipse.jface.text.presentation.PresentationReconciler;
 import org.eclipse.jface.text.source.ISourceViewer;
@@ -86,4 +88,23 @@ public class SQLConfiguration extends SourceViewerConfiguration {
                        ndr.setTextAttribute(attr);
                }
        }
+//     public IContentAssistant getContentAssistant(ISourceViewer sourceViewer) {
+//             ContentAssistant assistant = new ContentAssistant();
+//             assistant.setContentAssistProcessor(new SQLContentAssistProcessor("default"), 
+//                             IDocument.DEFAULT_CONTENT_TYPE);
+//             assistant.setContentAssistProcessor(new SQLContentAssistProcessor("comment"), 
+//                             SQLPartitionScanner.SQL_COMMENT);
+//             assistant.setContentAssistProcessor(new SQLContentAssistProcessor("keyword"), 
+//                             SQLPartitionScanner.SQL_KEYWORD);
+//             assistant.setContentAssistProcessor(new SQLContentAssistProcessor("identifier"), 
+//                             SQLPartitionScanner.SQL_IDENTIFIER);
+//             
+//             // everybody else is doin' it...
+//             assistant.enableAutoActivation(true);
+//             assistant.setAutoActivationDelay(500);
+//             
+//             assistant.setProposalPopupOrientation(ContentAssistant.CONTEXT_INFO_BELOW);
+//             assistant.setContextInformationPopupOrientation(ContentAssistant.CONTEXT_INFO_BELOW);
+//             return assistant;
+//     }
 }
\ No newline at end of file
diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/editors/SQLContentAssistProcessor.java b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/editors/SQLContentAssistProcessor.java
new file mode 100644 (file)
index 0000000..bf225cf
--- /dev/null
@@ -0,0 +1,69 @@
+package com.quantum.editors;
+
+import com.quantum.ImageStore;
+
+import org.eclipse.jface.text.ITextViewer;
+import org.eclipse.jface.text.contentassist.CompletionProposal;
+import org.eclipse.jface.text.contentassist.ICompletionProposal;
+import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
+import org.eclipse.jface.text.contentassist.IContextInformation;
+import org.eclipse.jface.text.contentassist.IContextInformationValidator;
+
+
+/**
+ * @author BC
+ */
+public class SQLContentAssistProcessor implements IContentAssistProcessor {
+
+       private String text;
+       /**
+        * @param string
+        */
+       public SQLContentAssistProcessor(String text) {
+               this.text = text;
+       }
+
+       public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int offset) {
+               
+               ICompletionProposal proposal = new CompletionProposal("select", 
+                               offset, 0, 6, ImageStore.getImage(ImageStore.TEMPLATE), 
+                               "select - select columns from a table or view", null, null);
+System.out.println(this.text);
+               // complete a key word
+
+               // complete a function
+
+               // provide a template
+
+               // TODO Auto-generated method stub
+               return new ICompletionProposal[] { proposal };
+       }
+
+       /**
+        * BCH: I have no idea what the difference is between context information and 
+        * completion proposals.
+        */
+       public IContextInformation[] computeContextInformation(ITextViewer viewer, int offset) {
+               return null;
+       }
+
+       /**
+        * Unless this method includes a space character, the standard Ctrl-Space key doesn't
+        * provide content assist.
+        */
+       public char[] getCompletionProposalAutoActivationCharacters() {
+               return new char[] { ' ' };
+       }
+
+       public char[] getContextInformationAutoActivationCharacters() {
+               return null;
+       }
+
+       public String getErrorMessage() {
+               return null;
+       }
+
+       public IContextInformationValidator getContextInformationValidator() {
+               return null;
+       }
+}
index 3ee61be..a4a50e8 100644 (file)
@@ -29,7 +29,7 @@ import org.eclipse.jface.preference.IPreferenceStore;
  * 
  * @author root
  */
-public class Bookmark {
+public class Bookmark implements Displayable {
        
        public static final int SCHEMA_RULE_USE_ALL = 1;
        public static final int SCHEMA_RULE_USE_DEFAULT = 2;
@@ -540,4 +540,8 @@ public class Bookmark {
             this.propertyChangeSupport.firePropertyChange("schemas", null, null);
         }
        }
+
+       public String getDisplayName() {
+               return this.name;
+       }
 }
diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/model/Displayable.java b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/model/Displayable.java
new file mode 100644 (file)
index 0000000..17222e1
--- /dev/null
@@ -0,0 +1,9 @@
+package com.quantum.model;
+
+
+/**
+ * @author BC
+ */
+public interface Displayable {
+       public String getDisplayName();
+}
index 62d7cd3..4f4f1d2 100644 (file)
@@ -3,7 +3,7 @@ package com.quantum.model;
 /**
  * @author BC
  */
-public class Schema implements Comparable {
+public class Schema implements Comparable, Displayable {
     
     private String name;
     private String displayName;
index c6f3b00..9e80375 100644 (file)
@@ -1,7 +1,7 @@
 package com.quantum.properties;
 
+import com.quantum.ImageStore;
 import com.quantum.Messages;
-import com.quantum.QuantumPlugin;
 import com.quantum.model.Entity;
 import com.quantum.model.EntityHolder;
 
@@ -63,7 +63,7 @@ public abstract class BaseEntityPropertyPage extends PropertyPage {
        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"));
+               icon.setImage(ImageStore.getImage(ImageStore.WARNING));
                
                Label error = new Label(composite, SWT.NONE);
                error.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING));
index 21d37f9..2a0bf10 100644 (file)
@@ -2,8 +2,8 @@ package com.quantum.properties;
 
 import java.sql.SQLException;
 
+import com.quantum.ImageStore;
 import com.quantum.Messages;
-import com.quantum.QuantumPlugin;
 import com.quantum.model.Column;
 import com.quantum.model.Entity;
 import com.quantum.model.NotConnectedException;
@@ -56,8 +56,8 @@ public class ColumnPropertyPage extends BaseEntityPropertyPage {
                        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");
+                                                       ? ImageStore.getImage(ImageStore.KEYCOLUMN) 
+                                                       : ImageStore.getImage(ImageStore.COLUMN);
                                } else {
                                        return null;
                                }
index 322ba0e..a61c93b 100644 (file)
@@ -2,8 +2,8 @@ package com.quantum.properties;
 
 import java.sql.SQLException;
 
+import com.quantum.ImageStore;
 import com.quantum.Messages;
-import com.quantum.QuantumPlugin;
 import com.quantum.model.Bookmark;
 import com.quantum.model.DataType;
 import com.quantum.model.NotConnectedException;
@@ -140,7 +140,7 @@ public class DatabaseInformationPropertyPage extends PropertyPage {
        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"));
+               icon.setImage(ImageStore.getImage(ImageStore.WARNING));
                
                Label error = new Label(composite, SWT.NONE);
                error.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING));
index 84719ed..dc511f7 100644 (file)
@@ -4,8 +4,8 @@ import java.sql.SQLException;
 import java.util.ArrayList;
 import java.util.List;
 
+import com.quantum.ImageStore;
 import com.quantum.Messages;
-import com.quantum.QuantumPlugin;
 import com.quantum.model.Entity;
 import com.quantum.model.Index;
 import com.quantum.model.NotConnectedException;
@@ -93,7 +93,7 @@ public class IndexPropertyPage extends BaseEntityPropertyPage {
 
                        public Image getColumnImage(Object element, int columnIndex) {
                                if (columnIndex == 1 && element instanceof IndexAdaptor) {
-                                       return QuantumPlugin.getImage("column.gif");
+                                       return ImageStore.getImage(ImageStore.COLUMN);
                                } else {
                                        return null;
                                }
index 75edc3b..630af95 100644 (file)
@@ -5,8 +5,8 @@ import java.sql.SQLException;
 import java.util.ArrayList;
 import java.util.List;
 
+import com.quantum.ImageStore;
 import com.quantum.Messages;
-import com.quantum.QuantumPlugin;
 import com.quantum.model.Entity;
 import com.quantum.model.ForeignKey;
 import com.quantum.model.NotConnectedException;
@@ -111,13 +111,13 @@ public class ReferencesPropertyPage extends BaseEntityPropertyPage {
                        public Image getColumnImage(Object element, int columnIndex) {
                                if ((columnIndex == 1 || columnIndex == 2) 
                                                && element instanceof ColumnDetailsAdaptor) {
-                                       return QuantumPlugin.getImage("column.gif");
+                                       return ImageStore.getImage(ImageStore.COLUMN);
                                } else if ((columnIndex == 1 || columnIndex == 2) 
                                                && element instanceof TableDetailsAdaptor) {
-                                       return QuantumPlugin.getImage("bigtable.gif");
+                                       return ImageStore.getImage(ImageStore.TABLE);
                                } else if ((columnIndex == 0) 
                                                && element instanceof TableDetailsAdaptor) {
-                                       return QuantumPlugin.getImage("foreignkey.gif");
+                                       return ImageStore.getImage(ImageStore.FOREIGNKEY);
                                } else {
                                        return null;
                                }
index ef233fb..97c1cc1 100644 (file)
@@ -172,6 +172,7 @@ public class MultiSQLServer implements ConnectionEstablisher {
 
                SQLResults results = new SQLResults();
 
+               long startTime = System.currentTimeMillis();
                System.out.println("Executing"); //$NON-NLS-1$
                LogProxy log = LogProxy.getInstance();
                log.addText(LogProxy.QUERY, "Executing Request [" + s + "]"); //$NON-NLS-1$ //$NON-NLS-2$
@@ -315,6 +316,7 @@ public class MultiSQLServer implements ConnectionEstablisher {
                }
                log.addText(LogProxy.RESULTS, "Success: result set displayed"); //$NON-NLS-1$
                stmt.close();
+               results.setTime(System.currentTimeMillis() - startTime);
                System.out.println("Executed"); //$NON-NLS-1$
                System.out.println();
                return results;
diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/sql/SQLGrammar.java b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/sql/SQLGrammar.java
new file mode 100644 (file)
index 0000000..0bb0eed
--- /dev/null
@@ -0,0 +1,54 @@
+package com.quantum.sql;
+
+/**
+ * @author BC
+ */
+public abstract class SQLGrammar {
+
+       public static String[] KEYWORDS = {
+               "ADD", "ALL", "ALTER", "AND", "ANY",
+               "AS", "ASC", "AUTOINCREMENT", "AVA", "BETWEEN",
+               "BINARY", "BIT", "BOOLEAN", "BY", "CREATE",
+               "BYTE", "CHAR", "CHARACTER", "COLUMN", "CONSTRAINT",
+               "COUNT", "COUNTER", "CURRENCY", "DATABASE", "DATE",
+               "DATETIME", "DELETE", "DESC", "DISALLOW", "DISTINCT",
+               "DISTINCTROW", "DOUBLE", "DROP", "EXISTS", "FROM",
+               "FLOAT", "FLOAT4", "FLOAT8", "FOREIGN", "GENERAL",
+               "GROUP", "GUID", "HAVING", "INNER", "INSERT",
+               "IGNORE", "IMP", "IN", "INDEX", "INT", 
+               "INTEGER", "INTEGER1", "INTEGER2", "INTEGER4", "INTO",
+               "IS", "JOIN", "KEY", "LEFT", "LEVEL", 
+               "LIKE", "LOGICAL", "LONG", "LONGBINARY", "LONGTEXT",
+               "MAX", "MEMO", "MIN", "MOD", "MONEY", 
+               "NOT", "NULL", "NUMBER", "NUMERIC", "OLEOBJECT",
+               "ON", "PIVOT", "OPTION", "PRIMARY", "ORDER",
+               "OUTER", "OWNERACCESS", "PARAMETERS", "PERCENT", "REAL",
+               "REFERENCES", "RIGHT", "SELECT", "SET", "SHORT",
+               "SINGLE", "SMALLINT", "SOME", "STDEV", "STDEVP",
+               "STRING", "SUM", "TABLE", "TABLEID", "TEXT", 
+               "TIME", "TIMESTAMP", "TOP", "TRANSFORM", "UNION",
+               "UNIQUE", "UPDATE", "VALUE", "VALUES", "VAR",
+               "VARBINARY", "VARCHAR", "VARP", "WHERE", "WITH",
+               "YESNO" 
+       };
+       
+    public static final String[] NON_RESERVED_WORDS = { 
+               "ADA", "C", "CATALOG_NAME", "CHARACTER_SET_CATALOG", "CHARACTER_SET_NAME", 
+                       "CHARACTER_SET_SCHEMA", "CLASS_ORIGIN", "COBOL", "COLLATION_CATALOG", 
+                       "COLLATION_NAME", "COLLATION_SCHEMA", "COLUMN_NAME", "COMMAND_FUNCTION", 
+                       "COMMITTED", "CONDITION_NUMBER", "CONNECTION_NAME", "CONSTRAINT_CATALOG", 
+                       "CONSTRAINT_NAME", "CONSTRAINT_SCHEMA", "CURSOR_NAME", "DATA", 
+                       "DATETIME_INTERVAL_CODE", "DATETIME_INTERVAL_PRECISION", "DYNAMIC_FUNCTION", 
+                       "FORTRAN", "LENGTH", "MESSAGE_LENGTH", "MESSAGE_OCTET_LENGTH", 
+                       "MESSAGE_TEXT", "MORE", "MUMPS", "NAME", "NULLABLE", "NUMBER", "PASCAL", 
+                       "PLI", "REPEATABLE", "RETURNED_LENGTH", "RETURNED_OCTET_LENGTH", 
+                       "RETURNED_SQLSTATE", "ROW_COUNT", "SCALE", "SCHEMA_NAME", 
+                       "SERIALIZABLE", "SERVER_NAME", "SUBCLASS_ORIGIN", "TABLE_NAME", 
+                       "TYPE", "UNCOMMITTED", "UNNAMED"
+    };
+    
+    public static final String[] COMMANDS = {
+       "select * from ${tablename} where ${columnname} = ${value}",
+               "update ${tablename} set ${columnname} = ${value} where ${column2name} = ${value2}"
+    };
+}
index 3abc2b9..44b67ed 100644 (file)
@@ -20,6 +20,7 @@ public class SQLResults {
        private boolean hasMore = false;
        private boolean isError = false;
        private int maxSize = -1;
+       private long time;
        
        public void setColumnNames(Vector columns) {
                this.columns = columns;
@@ -136,4 +137,10 @@ public class SQLResults {
                return rows.toArray();          
        }
 
+       public long getTime() {
+               return this.time;
+       }
+       public void setTime(long time) {
+               this.time = time;
+       }
 }
index 42c6276..543b1ef 100644 (file)
@@ -2,6 +2,21 @@ package com.quantum.sql.parser;
 
 import java.util.Vector;
 
+/**
+ * <p>An SQL Lexer.  From 
+ * <a href="http://www.dictionary.com/">dictionary.com</a>:
+ * 
+ * <blockquote>
+ * <p><b>lexer</b>
+ *
+ * <p>/lek'sr/ n. Common hacker shorthand for 'lexical
+ * analyzer', the input-tokenizing stage in the parser for a language
+ * (the part that breaks it into word-like pieces).
+ * </blockquote>
+ * 
+ * <p>Note that this class has nothing to do with the Sci-fi channel's
+ * <a href="http://www.scifi.com/lexx/">Lexx</a> TV series.
+ */
 public class SQLLexx {
        private static String endline = ";"; //$NON-NLS-1$
        private static String dash = "-"; //$NON-NLS-1$
index 7917a07..51e85dd 100644 (file)
@@ -200,7 +200,7 @@ public class ExceptionDisplayDialog extends Dialog {
                 composite,
                 SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI);
 
-        text.setText(this.throwable.getMessage());
+        text.setText(this.throwable.getLocalizedMessage());
 
         GridData data =
             new GridData(
index ccb1a43..ad76c71 100644 (file)
@@ -5,6 +5,8 @@ import java.util.Collections;
 import java.util.Iterator;
 import java.util.List;
 
+import com.quantum.model.Displayable;
+
 import org.eclipse.jface.dialogs.Dialog;
 import org.eclipse.jface.dialogs.IDialogConstants;
 import org.eclipse.jface.viewers.ILabelProviderListener;
@@ -38,7 +40,11 @@ public class SimpleSelectionDialog extends Dialog {
                }
 
                public String getColumnText(Object element, int columnIndex) {
-                       return element.toString();
+                       if (element instanceof Displayable) {
+                               return ((Displayable) element).getDisplayName();
+                       } else {
+                               return element.toString();
+                       }
                }
 
                public void addListener(ILabelProviderListener listener) {
index fcf6188..bbc2979 100644 (file)
@@ -1,11 +1,20 @@
 package com.quantum.util.versioning;
 
+import java.lang.reflect.Constructor;
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.resource.ImageRegistry;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.graphics.FontData;
 import org.eclipse.swt.widgets.FontDialog;
+import org.eclipse.ui.IKeyBindingService;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPartSite;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.actions.ExportResourcesAction;
 import org.eclipse.ui.part.ViewPart;
 import org.eclipse.ui.part.WorkbenchPart;
 
@@ -17,6 +26,7 @@ import org.eclipse.ui.part.WorkbenchPart;
  */
 public class VersioningHelper {
     
+    public static final int ECLIPSE_VERSION_2_0_1 = 2049;
     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;
@@ -73,7 +83,104 @@ public class VersioningHelper {
         }
     }
     
+    public static ExportResourcesAction createExportResourcesAction(IWorkbenchWindow window) {
+       ExportResourcesAction action = null;
+       
+       try {
+               if (isEclipse21OrHigher()) {
+                       Constructor constructor = ExportResourcesAction.class.getConstructor(
+                               new Class[] { IWorkbenchWindow.class });
+                       action = (ExportResourcesAction) constructor.newInstance(
+                               new Object[] { window });
+               } else {
+                       Constructor constructor = ExportResourcesAction.class.getConstructor(
+                               new Class[] { IWorkbench.class });
+                       action = (ExportResourcesAction) constructor.newInstance(
+                               new Object[] { window.getWorkbench() });
+               }
+        } catch (NoSuchMethodException e) {
+            // should not happen
+        } catch (IllegalArgumentException e) {
+            // should not happen
+        } catch (IllegalAccessException e) {
+            // should not happen
+        } catch (InvocationTargetException e) {
+            // should not happen
+        } catch (InstantiationException e) {
+            // should not happen
+        }
+       return action;
+    }
+    
+    public static void registerActionToKeyBindingService(
+       IWorkbenchPartSite site, String[] scopes, IAction action) {
+               
+       try {
+               if (isEclipse21OrHigher()) {
+                Method method = IWorkbenchPartSite.class.getMethod(
+                    "getKeyBindingService", new Class[0]);
+                IKeyBindingService service = (IKeyBindingService) method.invoke(site, null);
+                
+                method = IKeyBindingService.class.getMethod(
+                       "setScopes", new Class[] { String[].class });
+                method.invoke(service, new Object[] { scopes});
+                
+                       service.registerAction(action);
+               }
+        } 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());
     }
+
+       /**
+        * @return
+        */
+       public static boolean isEclipse30() {
+               return SWT.getVersion() >= 3000;
+       }
+
+       /**
+        * @return
+        */
+       public static boolean isEclipse21OrHigher() {
+               return SWT.getVersion() >= 2100;
+       }
+       /**
+        * Method getDescriptor.
+        * @param registry
+        * @param imageName
+        * @return ImageDescriptor
+        */
+       public static ImageDescriptor getDescriptor(
+               ImageRegistry registry,
+               String imageName) {
+               ImageDescriptor descriptor = null;
+        try {
+            if (isEclipse21OrHigher()) {
+                Method method = ImageRegistry.class.getMethod(
+                    "getDescriptor", new Class[] { String.class });
+                descriptor = (ImageDescriptor) method.invoke(registry, new Object[] {imageName});
+            }
+        } catch (NoSuchMethodException e) {
+            // should not happen
+        } catch (IllegalArgumentException e) {
+            // should not happen
+        } catch (IllegalAccessException e) {
+            // should not happen
+        } catch (InvocationTargetException e) {
+            // should not happen
+        }
+        return descriptor;
+       }
+
 }
diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/JDBCDriverLabelProvider.java b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/JDBCDriverLabelProvider.java
deleted file mode 100644 (file)
index ca2f50f..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-package com.quantum.view;
-
-import org.eclipse.jface.viewers.ILabelProviderListener;
-import org.eclipse.jface.viewers.ITableLabelProvider;
-import org.eclipse.swt.graphics.Image;
-
-import com.quantum.QuantumPlugin;
-import com.quantum.model.JDBCDriver;
-
-
-/**
- * @author BC
- */
-public class JDBCDriverLabelProvider 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) {
-               switch (columnIndex) {
-               case 0: 
-                       return ((JDBCDriver) element).getName();
-               case 1: 
-                       return ((JDBCDriver) element).getClassName();
-               case 2: 
-                       return ((JDBCDriver) element).getVersion();
-               case 3: 
-                       return ((JDBCDriver) element).getJarFileName();
-               }
-               return null;
-       }
-
-       public void addListener(ILabelProviderListener listener) {
-       }
-
-       public void dispose() {
-       }
-
-       public boolean isLabelProperty(Object element, String property) {
-               return false;
-       }
-
-       public void removeListener(ILabelProviderListener listener) {
-       }
-
-}
index c80e75e..8eb4bf1 100644 (file)
@@ -7,6 +7,12 @@ import java.util.Collections;
 import java.util.Iterator;
 import java.util.List;
 
+import com.quantum.ImageStore;
+import com.quantum.Messages;
+import com.quantum.adapters.AdapterFactory;
+import com.quantum.model.BookmarkCollection;
+import com.quantum.model.JDBCDriver;
+
 import org.eclipse.jface.viewers.ILabelProviderListener;
 import org.eclipse.jface.viewers.ISelection;
 import org.eclipse.jface.viewers.ISelectionChangedListener;
@@ -23,12 +29,6 @@ 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;
-
 
 /**
  * @author BC
@@ -38,7 +38,7 @@ public class JDBCDriverTableViewer implements PropertyChangeListener, ISelection
        public class LabelProviderImpl implements ITableLabelProvider {
                public Image getColumnImage(Object element, int columnIndex) {
                        if (columnIndex == 0) {
-                               return QuantumPlugin.getImage("driver.gif");
+                               return ImageStore.getImage(ImageStore.DRIVER);
                        } else {
                                return null;
                        }
index dfd7465..a3df2af 100644 (file)
@@ -1,7 +1,7 @@
 package com.quantum.view;
 
+import com.quantum.ImageStore;
 import com.quantum.Messages;
-import com.quantum.QuantumPlugin;
 
 import org.eclipse.jface.action.Action;
 import org.eclipse.jface.action.IToolBarManager;
@@ -43,7 +43,7 @@ public class SQLLogView extends ViewPart implements LogConstants {
                bars.setGlobalActionHandler(IWorkbenchActionConstants.SELECT_ALL, selectAllAction);
 
                IToolBarManager toolBar = getViewSite().getActionBars().getToolBarManager();
-               clearAction.setImageDescriptor(QuantumPlugin.getImageDescriptor("clear.gif")); //$NON-NLS-1$
+               clearAction.setImageDescriptor(ImageStore.getImageDescriptor(ImageStore.CLEAR));
                clearAction.setToolTipText(Messages.getString("SQLLogView.ClearLog")); //$NON-NLS-1$
                toolBar.add(clearAction);
 
index efdac83..0b14583 100644 (file)
@@ -1,51 +1,57 @@
 package com.quantum.view;
 
-import java.sql.Connection;
 import java.sql.SQLException;
 import java.util.LinkedList;
 import java.util.NoSuchElementException;
 import java.util.Vector;
 
+import com.quantum.ImageStore;
+import com.quantum.Messages;
+import com.quantum.QuantumPlugin;
+import com.quantum.actions.ExecuteAction;
+import com.quantum.actions.ExportQueryAction;
+import com.quantum.actions.ImportQueryAction;
+import com.quantum.model.Bookmark;
+import com.quantum.model.BookmarkCollection;
+import com.quantum.model.NotConnectedException;
+import com.quantum.sql.MultiSQLServer;
+import com.quantum.sql.SQLGrammar;
+import com.quantum.sql.parser.SQLLexx;
+import com.quantum.sql.parser.Token;
+import com.quantum.ui.dialog.ExceptionDisplayDialog;
+import com.quantum.util.versioning.VersioningHelper;
+
 import org.eclipse.jface.action.Action;
 import org.eclipse.jface.action.IToolBarManager;
 import org.eclipse.jface.action.Separator;
+import org.eclipse.jface.preference.PreferenceConverter;
+import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.jface.util.PropertyChangeEvent;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.ILabelProviderListener;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.Viewer;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.custom.ExtendedModifyEvent;
 import org.eclipse.swt.custom.ExtendedModifyListener;
 import org.eclipse.swt.custom.StyleRange;
 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.Font;
+import org.eclipse.swt.graphics.FontData;
+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.ToolBar;
-import org.eclipse.swt.widgets.ToolItem;
+import org.eclipse.swt.widgets.Display;
 import org.eclipse.ui.IActionBars;
-import org.eclipse.ui.IKeyBindingService;
 import org.eclipse.ui.IWorkbenchActionConstants;
 import org.eclipse.ui.part.ViewPart;
 
-import com.quantum.Messages;
-import com.quantum.QuantumPlugin;
-import com.quantum.actions.ExecuteAction;
-import com.quantum.actions.ExportQueryAction;
-import com.quantum.actions.ImportQueryAction;
-import com.quantum.model.Bookmark;
-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"));
+                       setImageDescriptor(ImageStore.getImageDescriptor(ImageStore.CLEAR));
                        setToolTipText(Messages.getString("sqlqueryview.clear"));
                }
 
@@ -57,79 +63,119 @@ public class SQLQueryView extends ViewPart {
        private class AutoCommitPreferenceAction extends Action {
                
                public AutoCommitPreferenceAction() {
-                       super(Messages.getString("SQLQueryView.AutoCommit"), SWT.CHECK);
+                       super(Messages.getString("SQLQueryView.AutoCommit"));
                        setToolTipText(Messages.getString("SQLQueryView.AutoCommit"));
-                       setImageDescriptor(QuantumPlugin.getImageDescriptor("autocommit.gif"));
+                       setImageDescriptor(ImageStore.getImageDescriptor(ImageStore.AUTOCOMMIT));
                }
                
                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);
+                       setAutoCommitPreference(isChecked());
                }
        }
        
+       private class RollbackAction extends Action {
+               public RollbackAction() {
+                       setText(Messages.getString("SQLQueryView.RollBack"));
+                       setToolTipText(Messages.getString("SQLQueryView.RollBack"));
+               }
+               
+               public void run() {
+               Bookmark[] bookmarks = BookmarkCollection.getInstance().getBookmarks();
+               for (int i = 0, length = bookmarks == null ? 0 : bookmarks.length; i < length; i++) {
+                       try {
+                                       if (bookmarks[i].isConnected() && !bookmarks[i].getConnection().getAutoCommit()) {
+                                               MultiSQLServer.getInstance().rollback(bookmarks[i].getConnection());
+                                       }
+                   } catch (SQLException e) {
+                       ExceptionDisplayDialog.openError(getSite().getShell(), null, null, e);
+                   } catch (NotConnectedException e) {
+                       ExceptionDisplayDialog.openError(getSite().getShell(), null, null, e);
+                   }
+                       }
+               }
+       }
+       
+       
+       private class CommitAction extends Action {
+               public CommitAction() {
+                       setText(Messages.getString("SQLQueryView.Commit"));
+                       setToolTipText(Messages.getString("SQLQueryView.Commit"));
+               }
+               
+               public void run() {
+               Bookmark[] bookmarks = BookmarkCollection.getInstance().getBookmarks();
+               for (int i = 0, length = bookmarks == null ? 0 : bookmarks.length; i < length; i++) {
+                       try {
+                                       if (bookmarks[i].isConnected() && !bookmarks[i].getConnection().getAutoCommit()) {
+                                               MultiSQLServer.getInstance().commit(bookmarks[i].getConnection());
+                                       }
+                   } catch (SQLException e) {
+                       ExceptionDisplayDialog.openError(getSite().getShell(), null, null, e);
+                   } catch (NotConnectedException e) {
+                       ExceptionDisplayDialog.openError(getSite().getShell(), null, null, e);
+                   }
+                       }
+               }
+       }
+       
+       
+       public class LabelProviderImpl implements ILabelProvider {
+               public Image getImage(Object element) {
+                       return ImageStore.getImage(ImageStore.BOOKMARK);
+               }
+               public String getText(Object element) {
+                       if (element instanceof Bookmark) {
+                               return ((Bookmark) element).getName();
+                       } else {
+                               return null;
+                       }
+               }
+               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 Object[] getElements(Object inputElement) {
+                       if (inputElement instanceof BookmarkCollection) {
+                               return ((BookmarkCollection) inputElement).getBookmarks();
+                       } else {
+                               return null;
+                       }
+               }
+               public void dispose() {
+               }
+               public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+               }
+       }
        
        private ExecuteAction executeAction;
        private ImportQueryAction importQueryAction;
        private ExportQueryAction exportQueryAction;
        private StyledText widget;
-       private ToolItem autoCommitItem;
-       private ToolItem commitItem;
-       private ToolItem rollbackItem;
        private Color STRING_LITERAL;
        private Color KEYWORD;
        private Color COMMENT;
        private Color NUMERIC;
        private Color DEFAULT;
        private AutoCommitPreferenceAction autoCommitPreferenceAction;
+       private RollbackAction rollbackAction;
+       private CommitAction commitAction;
+       private boolean autoCommitPreference = true;
        
        public SQLQueryView() {
                super();
-       }
-       public void setFocus() {
-               
-               String title = "Quantum SQL Query Editor";
-               Bookmark bookmark = null;
-               Connection con = null;
-               if (BookmarkView.getInstance() != null ) {
-                       bookmark = getBookmark();
-               }
-               if (bookmark != null) {         
-                       title = bookmark.getName() + " (" + title + ")";
-                       VersioningHelper.setPartName(this, title);
-//                     setPartName("fred");
-                       try {
-                               con = bookmark.getConnection();
-                       } catch (NotConnectedException e) {
-                               // Doesn't matter, "con" remains null
+               IPropertyChangeListener listener = new IPropertyChangeListener() {
+                       public void propertyChange(PropertyChangeEvent event) {
+                               setFont();
                        }
-               }
-               
-               updateAutoCommitState(bookmark, con);
-
-               widget.setFocus();
-
-       }
-       /**
-        * @return
-        */
-       private Bookmark getBookmark() {
-               if (BookmarkView.getInstance() != null ) {
-                       BookmarkNode node = BookmarkView.getInstance().getCurrentBookmark();
-                       return node == null ? null : node.getBookmark();
-               } else {
-                       return null;
-               }
+               };
+               QuantumPlugin.getDefault().getPreferenceStore().addPropertyChangeListener(listener);
        }
        public static SQLQueryView getInstance() {
                return (SQLQueryView) QuantumPlugin.getDefault().getView("com.quantum.view.sqlqueryview");
@@ -139,97 +185,18 @@ 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);
-               NUMERIC = new Color(parent.getShell().getDisplay(), 255, 0, 0);
-           DEFAULT = new Color(parent.getShell().getDisplay(), 0, 0, 0);
-               Composite main = new Composite(parent, SWT.NONE);
+               initializeColours(parent);
                GridLayout layout = new GridLayout(1, false);
                layout.horizontalSpacing = 0;
                layout.verticalSpacing = 0;
-               main.setLayout(layout);
-               ToolBar toolbar = new ToolBar(main, SWT.HORIZONTAL);
-
-               commitItem = new ToolItem(toolbar, SWT.PUSH);
-               commitItem.setImage(QuantumPlugin.getImage("commit.gif")); //$NON-NLS-1$
-               commitItem.setToolTipText(Messages.getString("SQLQueryView.Commit")); //$NON-NLS-1$
-               commitItem.addSelectionListener(new SelectionListener() {
-                       public void widgetDefaultSelected(SelectionEvent e) {
-                       }
-                       public void widgetSelected(SelectionEvent event) {
-                try {
-                               BookmarkNode node = BookmarkView.getInstance().getCurrentBookmark();
-                               if (node != null) MultiSQLServer.getInstance().commit(
-                        node.getBookmark().getConnection());
-                } catch (NotConnectedException e) {
-                    e.printStackTrace();
-                }
-                       }
-               });
+               layout.marginHeight = 0;
+               layout.marginWidth = 0;
+               parent.setLayout(layout);
+               parent.setLayoutData(new GridData(GridData.FILL_BOTH));
                
-               rollbackItem = new ToolItem(toolbar, SWT.PUSH);
-               rollbackItem.setImage(QuantumPlugin.getImage("rollback.gif")); //$NON-NLS-1$
-               rollbackItem.setToolTipText(Messages.getString("SQLQueryView.RollBack")); //$NON-NLS-1$
-               rollbackItem.addSelectionListener(new SelectionListener() {
-                       public void widgetDefaultSelected(SelectionEvent event) {
-                       }
-                       public void widgetSelected(SelectionEvent event) {
-                try {
-                    BookmarkNode node = BookmarkView.getInstance().getCurrentBookmark();
-                    if (node != null) MultiSQLServer.getInstance().rollback(
-                        node.getBookmark().getConnection());
-                } catch (NotConnectedException e) {
-                    e.printStackTrace();
-                }
-                       }
-               });
-               
-               autoCommitItem = new ToolItem(toolbar, SWT.CHECK);
-               autoCommitItem.setImage(QuantumPlugin.getImage("autocommit.gif")); //$NON-NLS-1$
-               autoCommitItem.setToolTipText(Messages.getString("SQLQueryView.AutoCommit")); //$NON-NLS-1$
-               autoCommitItem.addSelectionListener(new SelectionListener() {
-                       public void widgetDefaultSelected(SelectionEvent e) {
-                       }
-                       public void widgetSelected(SelectionEvent event) {
-                               BookmarkNode node = BookmarkView.getInstance().getCurrentBookmark();
-                               if (node == null) return;
-                               Connection con = null; 
-                               try { 
-                                       // Get the connection
-                                       con = node.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(     con, autoCommitItem.getSelection());
-                } catch (NotConnectedException e) {
-                       //Doesn't matter
-                }
-                // Update the bookmark and the buttons
-                               updateAutoCommitState(node.getBookmark(), con);
-                               
-                       }
-               });
-
-               // TODO: BCH -- this is causing some problems during start-up
-               Bookmark bookmark = null;
-               try {
-                       bookmark = getBookmark();
-               } catch (NullPointerException e) {
-               }
+               widget = new StyledText(parent, SWT.H_SCROLL | SWT.V_SCROLL);
                
-               if (bookmark == null) {
-                       autoCommitItem.setSelection(true); 
-               } else {
-                       autoCommitItem.setSelection(bookmark.isAutoCommit());
-               }
-               if (autoCommitItem.getSelection()) {
-                       commitItem.setEnabled(false);
-                       rollbackItem.setEnabled(false);
-               } else {
-                       commitItem.setEnabled(true);
-                       rollbackItem.setEnabled(true);
-               }
-               widget = new StyledText(main, SWT.H_SCROLL | SWT.V_SCROLL);
+               setFont();
 
                IActionBars bars = this.getViewSite().getActionBars();
                bars.setGlobalActionHandler(IWorkbenchActionConstants.CUT, cutAction);
@@ -240,64 +207,41 @@ public class SQLQueryView extends ViewPart {
                widget.setEditable(true);
                widget.addExtendedModifyListener(modifyListener);
 
-               GridData gridData = new GridData();
-               gridData.horizontalAlignment = GridData.FILL;
-               gridData.verticalAlignment = GridData.FILL;
-               gridData.grabExcessHorizontalSpace = true;
-               gridData.grabExcessVerticalSpace = true;
-               widget.setLayoutData(gridData);
+               widget.setLayoutData(new GridData(GridData.FILL_BOTH));
 
-        IKeyBindingService keyBindingService = getSite().getKeyBindingService();
-        // TODO: check the version numbers for this method
-        keyBindingService.setScopes(new String[] {
-            "org.eclipse.ui.globalScope",
-            "com.quantum.view.sql"
-        });
-        keyBindingService.registerAction(this.executeAction);
+               VersioningHelper.registerActionToKeyBindingService(getSite(), 
+                               new String[] { "org.eclipse.ui.globalScope", "com.quantum.view.sql" }, 
+                       this.executeAction);
        }
 
        /**
-        * Sets the state of the "Commit", "Rollback" and "autoCommit" buttons
-        * to reflect the situation in the connection
+        * @param widget2
         */
-       protected void updateAutoCommitState(Bookmark bookmark, Connection connection) {
-               boolean autoCommit = true;
-               // Calculate the state of the autoCommit option
-               if (connection != null)
-               {
-                       // If we have a connection, the autoCommit state is that of the connection
-                       try {
-                               autoCommit = connection.getAutoCommit();
-                       } catch (SQLException e) {
-                               // Doesn't matter, we take default
-                       }
-               } else {
-                       // if no connection, we try the autoCommit of the bookmark, or else the default
-                       if (bookmark != null) autoCommit = bookmark.isAutoCommit();
-               }
-               // Set the autoCommit state of the bookmark to the calculated
-               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);
-               } else {
-                       commitItem.setEnabled(true);
-                       rollbackItem.setEnabled(true);
+       private void setFont() {
+               FontData font = PreferenceConverter.getFontData(
+                               QuantumPlugin.getDefault().getPreferenceStore(), 
+                               "quantum.font"); //$NON-NLS-1$
+               if (font != null && this.widget != null) {
+                       this.widget.setFont(new Font(Display.getCurrent(), font));
                }
        }
+       /**
+        * @param parent
+        */
+       private void initializeColours(org.eclipse.swt.widgets.Composite parent) {
+               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);
+               NUMERIC = new Color(parent.getShell().getDisplay(), 255, 0, 0);
+           DEFAULT = new Color(parent.getShell().getDisplay(), 0, 0, 0);
+       }
+       
        private void initActions() {
 
-               executeAction = new ExecuteAction();
-               executeAction.init(this);
-
                IToolBarManager toolBar = getViewSite().getActionBars().getToolBarManager();
+
+               executeAction = new ExecuteAction(this);
                toolBar.add(this.executeAction);
-//             toolBar.add(this.importQueryAction);
-//             toolBar.add(this.exportQueryAction);
-               
                toolBar.add(new ClearAction());
                
         IActionBars actionBars = getViewSite().getActionBars();
@@ -309,8 +253,15 @@ public class SQLQueryView extends ViewPart {
         actionBars.getMenuManager().add(this.exportQueryAction);
         actionBars.getMenuManager().add(new Separator());
         this.autoCommitPreferenceAction = new AutoCommitPreferenceAction();
+        this.autoCommitPreferenceAction.setChecked(this.autoCommitPreference);
         actionBars.getMenuManager().add(this.autoCommitPreferenceAction);
-       }
+
+        this.rollbackAction = new RollbackAction();
+        actionBars.getMenuManager().add(this.rollbackAction);
+
+        this.commitAction = new CommitAction();
+        actionBars.getMenuManager().add(this.commitAction);
+}
 
        public String getQuery() {
                return widget.getText();
@@ -320,32 +271,6 @@ public class SQLQueryView extends ViewPart {
                widget.setText(text);
        }
        
-       private String[] keywords = {
-       "ADD", "ALL", "ALTER", "AND", "ANY",
-       "AS", "ASC", "AUTOINCREMENT", "AVA", "BETWEEN",
-       "BINARY", "BIT", "BOOLEAN", "BY", "CREATE",
-       "BYTE", "CHAR", "CHARACTER", "COLUMN", "CONSTRAINT",
-       "COUNT", "COUNTER", "CURRENCY", "DATABASE", "DATE",
-       "DATETIME", "DELETE", "DESC", "DISALLOW", "DISTINCT",
-       "DISTINCTROW", "DOUBLE", "DROP", "EXISTS", "FROM",
-       "FLOAT", "FLOAT4", "FLOAT8", "FOREIGN", "GENERAL",
-       "GROUP", "GUID", "HAVING", "INNER", "INSERT",
-       "IGNORE", "IMP", "IN", "INDEX", "INT", 
-       "INTEGER", "INTEGER1", "INTEGER2", "INTEGER4", "INTO",
-       "IS", "JOIN", "KEY", "LEFT", "LEVEL", 
-       "LIKE", "LOGICAL", "LONG", "LONGBINARY", "LONGTEXT",
-       "MAX", "MEMO", "MIN", "MOD", "MONEY", 
-       "NOT", "NULL", "NUMBER", "NUMERIC", "OLEOBJECT",
-       "ON", "PIVOT", "OPTION", "PRIMARY", "ORDER",
-       "OUTER", "OWNERACCESS", "PARAMETERS", "PERCENT", "REAL",
-       "REFERENCES", "RIGHT", "SELECT", "SET", "SHORT",
-       "SINGLE", "SMALLINT", "SOME", "STDEV", "STDEVP",
-       "STRING", "SUM", "TABLE", "TABLEID", "TEXT", 
-       "TIME", "TIMESTAMP", "TOP", "TRANSFORM", "UNION",
-       "UNIQUE", "UPDATE", "VALUE", "VALUES", "VAR",
-       "VARBINARY", "VARCHAR", "VARP", "WHERE", "WITH",
-       "YESNO" };
-       
        SyntaxHighlighter textUpdater = new SyntaxHighlighter();
        
        private class UpdateRequest {
@@ -413,8 +338,8 @@ public class SQLQueryView extends ViewPart {
                                                        max = Math.max(max, start + length);
                                                        if (t.getType() == Token.IDENTIFIER) {
                                                                boolean keyword = false;
-                                                               for (int index = 0; index < keywords.length; index++) {
-                                                                       if (value.equals(keywords[index])) {
+                                                               for (int index = 0; index < SQLGrammar.KEYWORDS.length; index++) {
+                                                                       if (value.equals(SQLGrammar.KEYWORDS[index])) {
                                                                                keyword = true;
                                                                        }
                                                                }
@@ -495,4 +420,13 @@ public class SQLQueryView extends ViewPart {
                        widget.selectAll();
                }
        };
+
+       public void setFocus() {
+       }
+       public boolean isAutoCommitPreference() {
+               return this.autoCommitPreference;
+       }
+       public void setAutoCommitPreference(boolean autoCommitPreference) {
+               this.autoCommitPreference = autoCommitPreference;
+       }
 }
index f18c3b9..4a7fa72 100644 (file)
@@ -12,8 +12,8 @@ import java.util.Iterator;
 import java.util.List;
 import java.util.Set;
 
+import com.quantum.ImageStore;
 import com.quantum.Messages;
-import com.quantum.QuantumPlugin;
 import com.quantum.model.Bookmark;
 import com.quantum.model.ConnectionException;
 import com.quantum.model.NotConnectedException;
@@ -65,7 +65,7 @@ public class SchemaSelectionControl extends Composite {
 
         public Image getColumnImage(Object element, int columnIndex) {
             if (columnIndex == 0) {
-                return QuantumPlugin.getImage("schema.gif");
+                return ImageStore.getImage(ImageStore.SCHEMA);
             } else {
                 return null;
             }
@@ -254,7 +254,7 @@ public class SchemaSelectionControl extends Composite {
                 SimpleSelectionDialog dialog = new SimpleSelectionDialog(
                                getShell(), Messages.getString(getClass(), "addSchemaDialog"), 
                                                schemaList.toArray(), 
-                                               QuantumPlugin.getImage("schema.gif"), true);
+                                               ImageStore.getImage(ImageStore.SCHEMA), true);
                 int result = dialog.open();
                 if (result == SimpleSelectionDialog.OK 
                                && !dialog.getSelection().isEmpty()) {
index f43a99a..e266cb4 100644 (file)
@@ -25,6 +25,7 @@ import org.eclipse.ui.WorkbenchException;
 import org.eclipse.ui.actions.ActionContext;
 import org.eclipse.ui.part.ViewPart;
 
+import com.quantum.ImageStore;
 import com.quantum.Messages;
 import com.quantum.QuantumPlugin;
 import com.quantum.actions.CustomCopyAction;
@@ -185,21 +186,21 @@ public class BookmarkView extends ViewPart implements PropertyChangeListener {
                        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$
+                                       ImageStore.getImageDescriptor(ImageStore.COPY)); //$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$
+                                       ImageStore.getImageDescriptor(ImageStore.COPY)); //$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$
+                                       ImageStore.getImageDescriptor(ImageStore.COPY)); //$NON-NLS-1$
         }
        }
        public void dispose(){
index 09f636b..3af90bd 100644 (file)
@@ -2,7 +2,7 @@ package com.quantum.view.bookmark;
 
 import java.util.Iterator;
 
-import com.quantum.QuantumPlugin;
+import com.quantum.ImageStore;
 import com.quantum.actions.AddToQuickListAction;
 import com.quantum.actions.ConnectAction;
 import com.quantum.actions.DeleteAllRowsAction;
@@ -17,6 +17,7 @@ import com.quantum.actions.RemoveFromQuickListAction;
 import com.quantum.actions.ViewTableAction;
 import com.quantum.actions.ViewTableDetailsAction;
 import com.quantum.model.Bookmark;
+import com.quantum.util.versioning.VersioningHelper;
 
 import org.eclipse.jface.action.Action;
 import org.eclipse.jface.action.IAction;
@@ -103,9 +104,9 @@ public class BookmarkViewActionGroup extends ActionGroup
         this.renameAction = new RenameAction(this.viewPart);
         this.copyAction = new CopyAction(this.viewPart, this, selectionProvider);
         this.pasteAction = new PasteAction(this.viewPart, this, selectionProvider);
-        this.exportAction = new ExportResourcesAction(
-            this.viewPart.getViewSite().getWorkbenchWindow());
-        this.exportAction.setImageDescriptor(QuantumPlugin.getImageDescriptor("export.gif"));
+        this.exportAction = VersioningHelper.createExportResourcesAction(
+                       this.viewPart.getViewSite().getWorkbenchWindow());
+        this.exportAction.setImageDescriptor(ImageStore.getImageDescriptor(ImageStore.EXPORT));
         
         this.propertiesAction = new PropertyDialogAction(
             this.viewPart.getSite().getShell(), selectionProvider);
@@ -144,8 +145,10 @@ public class BookmarkViewActionGroup extends ActionGroup
 
         // NOTE: In Eclipse 3.0.0 M6, Export is no longer a sub-class of 
         //       SelectionListenerAction.
-        this.exportAction.selectionChanged(getStructuredSelection());
-        menu.add(this.exportAction);
+        if (this.exportAction != null) {
+               this.exportAction.selectionChanged(getStructuredSelection());
+               menu.add(this.exportAction);
+        }
 
         if (getStructuredSelection().size() == 1 && 
             isEverySelectionInstanceof(BookmarkNode.class)) {
index 4166947..d4d97ab 100644 (file)
@@ -11,6 +11,7 @@ import java.util.List;
 
 import javax.xml.parsers.ParserConfigurationException;
 
+import com.quantum.ImageStore;
 import com.quantum.Messages;
 import com.quantum.QuantumPlugin;
 import com.quantum.model.Bookmark;
@@ -38,7 +39,7 @@ final class CopyAction extends SelectionListenerAction {
        public CopyAction(IViewPart view, BookmarkClipboard bookmarkClipboard, 
         ISelectionProvider selectionProvider) {
         super(Messages.getString(CopyAction.class.getName() + ".text"));
-        setImageDescriptor(QuantumPlugin.getImageDescriptor("copy.gif"));
+        setImageDescriptor(ImageStore.getImageDescriptor(ImageStore.COPY));
         this.bookmarkClipboard = bookmarkClipboard;
         selectionProvider.addSelectionChangedListener(this);
        }
index cf0f628..f43c1e4 100644 (file)
@@ -5,8 +5,8 @@ import org.eclipse.jface.viewers.IStructuredSelection;
 import org.eclipse.ui.IViewPart;
 import org.eclipse.ui.actions.SelectionListenerAction;
 
+import com.quantum.ImageStore;
 import com.quantum.Messages;
-import com.quantum.QuantumPlugin;
 import com.quantum.model.Bookmark;
 import com.quantum.model.BookmarkCollection;
 
@@ -19,7 +19,7 @@ final class PasteAction extends SelectionListenerAction {
     public PasteAction(IViewPart view, BookmarkClipboard bookmarkClipboard, 
         ISelectionProvider selectionProvider) {
         super(Messages.getString(PasteAction.class.getName() + ".text"));
-        setImageDescriptor(QuantumPlugin.getImageDescriptor("paste.gif"));
+        setImageDescriptor(ImageStore.getImageDescriptor(ImageStore.PASTE));
         selectionProvider.addSelectionChangedListener(this);
         this.bookmarkClipboard = bookmarkClipboard;
     }
index 7552995..8b9825e 100644 (file)
@@ -5,7 +5,7 @@ import java.sql.SQLException;
 import java.util.Iterator;
 import java.util.Vector;
 
-import com.quantum.QuantumPlugin;
+import com.quantum.ImageStore;
 import com.quantum.model.Bookmark;
 import com.quantum.model.BookmarkHolder;
 import com.quantum.model.NotConnectedException;
@@ -47,7 +47,7 @@ public abstract class TreeNode
         * @return an Image object to appear in the view, null if not found
         */
     public Image getImage() {
-       return QuantumPlugin.getImage(getImageName());
+       return ImageStore.getImage(getImageName());
     }
 
     /**
index 448ff51..09cd2c1 100644 (file)
@@ -8,6 +8,7 @@ import javax.xml.parsers.DocumentBuilder;
 import javax.xml.parsers.DocumentBuilderFactory;
 import javax.xml.parsers.ParserConfigurationException;
 
+import com.quantum.ImageStore;
 import com.quantum.Messages;
 import com.quantum.QuantumPlugin;
 import com.quantum.actions.CustomCopyAction;
@@ -104,7 +105,7 @@ public class SubsetView extends ViewPart {
        private static SubsetNode getRoot(TreeNode node){
                while (!( node instanceof SubsetNode))
                {
-                       node = (TreeNode) node.getParent();
+                       node = node.getParent();
                }
                return (SubsetNode) node;
 
@@ -174,31 +175,31 @@ public class SubsetView extends ViewPart {
                                        mgr.add(deleteSubsetAction);
                                        deleteSubsetAction.setText(Messages.getString("SubsetView.Delete")); //$NON-NLS-1$
                                        deleteSubsetAction.setImageDescriptor(
-                                               QuantumPlugin.getImageDescriptor("delete.gif")); //$NON-NLS-1$
+                                                       ImageStore.getImageDescriptor(ImageStore.DELETE));
                                        mgr.add(pasteAction);
                                        pasteAction.setText(Messages.getString("SubsetView.Paste")); //$NON-NLS-1$
-                                       pasteAction.setImageDescriptor(QuantumPlugin.getImageDescriptor("paste.gif")); //$NON-NLS-1$
+                                       pasteAction.setImageDescriptor(ImageStore.getImageDescriptor(ImageStore.PASTE));
                                        mgr.add(exportXMLAction);
                                        exportXMLAction.setText(Messages.getString("bookmarkview.exportXML")); //$NON-NLS-1$
-                                       exportXMLAction.setImageDescriptor(QuantumPlugin.getImageDescriptor("xml.gif")); //$NON-NLS-1$
+                                       exportXMLAction.setImageDescriptor(ImageStore.getImageDescriptor(ImageStore.XML));
                 
                                } else  if (sel instanceof ObjectNode) {
                                        mgr.add(deleteObjectAction);
                                        deleteObjectAction.setText(Messages.getString("SubsetView.Delete")); //$NON-NLS-1$
-                                       deleteObjectAction.setImageDescriptor(QuantumPlugin.getImageDescriptor("delete.gif")); //$NON-NLS-1$
+                                       deleteObjectAction.setImageDescriptor(ImageStore.getImageDescriptor(ImageStore.DELETE));
                                        mgr.add(viewTableAction);
                                        viewTableAction.setText(Messages.getString("bookmarkview.viewTable")); //$NON-NLS-1$
-                                       viewTableAction.setImageDescriptor(QuantumPlugin.getImageDescriptor("table.gif")); //$NON-NLS-1$
+                                       viewTableAction.setImageDescriptor(ImageStore.getImageDescriptor(ImageStore.OPEN_TABLE));
                                        mgr.add(exportXMLAction);
                                        exportXMLAction.setText(Messages.getString("bookmarkview.exportXML")); //$NON-NLS-1$
-                                       exportXMLAction.setImageDescriptor(QuantumPlugin.getImageDescriptor("xml.gif")); //$NON-NLS-1$
+                                       exportXMLAction.setImageDescriptor(ImageStore.getImageDescriptor(ImageStore.XML));
                     customCopyAction.selectionChanged(
                         (IStructuredSelection) treeViewer.getSelection());
                                        mgr.add(customCopyAction);
                                } else if (sel instanceof ColumnNode){
                                        mgr.add(deleteColumnAction);
                                        deleteColumnAction.setText(Messages.getString("SubsetView.Delete")); //$NON-NLS-1$
-                                       deleteColumnAction.setImageDescriptor(QuantumPlugin.getImageDescriptor("delete.gif")); //$NON-NLS-1$
+                                       deleteColumnAction.setImageDescriptor(ImageStore.getImageDescriptor(ImageStore.DELETE));
                     customCopyAction.selectionChanged(
                         (IStructuredSelection) treeViewer.getSelection());
                                        mgr.add(customCopyAction);
@@ -235,25 +236,25 @@ public class SubsetView extends ViewPart {
                newSubsetAction.setText("New Subset"); //$NON-NLS-1$
                newSubsetAction.setToolTipText(Messages.getString("SubsetView.CreatesANewEmptySubset")); //$NON-NLS-1$
                newSubsetAction.setImageDescriptor(
-                       QuantumPlugin.getImageDescriptor("subset.gif")); //$NON-NLS-1$
+                               ImageStore.getImageDescriptor(ImageStore.SUBSET));
                newSubsetAction.init(this);
                deleteColumnAction = new DeleteColumnAction();
                deleteColumnAction.setText("Delete Column"); //$NON-NLS-1$
                deleteColumnAction.setToolTipText(Messages.getString("SubsetView.DeletesTheSelectedColumns")); //$NON-NLS-1$
                deleteColumnAction.setImageDescriptor(
-                       QuantumPlugin.getImageDescriptor("delete.gif")); //$NON-NLS-1$
+                               ImageStore.getImageDescriptor(ImageStore.DELETE));
                deleteColumnAction.init(this);
                deleteObjectAction = new DeleteObjectAction();
                deleteObjectAction.setText("Delete Object"); //$NON-NLS-1$
                deleteObjectAction.setToolTipText(Messages.getString("SubsetView.DeletesTheSelectedObject")); //$NON-NLS-1$
                deleteObjectAction.setImageDescriptor(
-                       QuantumPlugin.getImageDescriptor("delete.gif")); //$NON-NLS-1$
+                               ImageStore.getImageDescriptor(ImageStore.DELETE));
                deleteObjectAction.init(this);
                deleteSubsetAction = new DeleteSubsetAction();
                deleteSubsetAction.setText("Delete Subset"); //$NON-NLS-1$
                deleteSubsetAction.setToolTipText(Messages.getString("SubsetView.DeletesTheSelectedSubset")); //$NON-NLS-1$
                deleteSubsetAction.setImageDescriptor(
-                       QuantumPlugin.getImageDescriptor("delete.gif")); //$NON-NLS-1$
+                               ImageStore.getImageDescriptor(ImageStore.DELETE));
                deleteSubsetAction.init(this);
 //             viewTableAction = new ViewTableAction();
 //             viewTableAction.setText(Messages.getString("bookmarkview.viewTable")); //$NON-NLS-1$
@@ -263,13 +264,13 @@ public class SubsetView extends ViewPart {
                exportXMLAction = new ExportXMLAction();
                exportXMLAction.setText(Messages.getString("bookmarkview.exportXML")); //$NON-NLS-1$
                exportXMLAction.setImageDescriptor(
-                       QuantumPlugin.getImageDescriptor("table.gif")); //$NON-NLS-1$
+                               ImageStore.getImageDescriptor(ImageStore.XML));
                exportXMLAction.init(this);
 
                this.customCopyAction = new CustomCopyAction(this,1); // 1 is unused, just in case more custom copies are defined        
                this.customCopyAction.setText(Messages.getString("bookmarkview.customCopyAction")); //$NON-NLS-1$
                this.customCopyAction.setImageDescriptor(
-                       QuantumPlugin.getImageDescriptor("copy.gif")); //$NON-NLS-1$
+                               ImageStore.getImageDescriptor(ImageStore.COPY));
 
 
                
index e833620..e65c9d0 100644 (file)
@@ -187,31 +187,31 @@ public class TableAdapter {
                }
        }
        
-       public TableViewer addTableViewer(Table table) {
-               TableViewer tableViewer = new TableViewer(table);
-               tableViewer.setUseHashlookup(true);
-               String[] colNams = new String[columnNames.size()];
-               for (int i = 0; i < columnNames.size(); i++) {
-                       colNams[i] = (String) columnNames.get(i);
-               }
-               tableViewer.setColumnProperties(colNams);
-
-               // Create the cell editors
-               CellEditor[] editors = new CellEditor[columnNames.size()];
-               for (int i = 0; i < columnNames.size(); i++) {
-                       TextCellEditor textEditor = new TextCellEditor(table);
-                       ((Text) textEditor.getControl()).setTextLimit(60);
-                       editors[i] = textEditor;
-               }
-               // Assign the cell editors to the viewer 
-               tableViewer.setCellEditors(editors);
-               // Set the cell modifier for the viewer
-               //tableViewer.setCellModifier(new MetaDataModifier(this));
-               // Set the default sorter for the viewer 
-               //tableViewer.setSorter(new ExampleTaskSorter(ExampleTaskSorter.DESCRIPTION));
-               
-               return tableViewer;
-       }
+//     public TableViewer addTableViewer(Table table) {
+//             TableViewer tableViewer = new TableViewer(table);
+//             tableViewer.setUseHashlookup(true);
+//             String[] colNams = new String[columnNames.size()];
+//             for (int i = 0; i < columnNames.size(); i++) {
+//                     colNams[i] = (String) columnNames.get(i);
+//             }
+//             tableViewer.setColumnProperties(colNams);
+//
+//             // Create the cell editors
+//             CellEditor[] editors = new CellEditor[columnNames.size()];
+//             for (int i = 0; i < columnNames.size(); i++) {
+//                     TextCellEditor textEditor = new TextCellEditor(table);
+//                     ((Text) textEditor.getControl()).setTextLimit(60);
+//                     editors[i] = textEditor;
+//             }
+//             // Assign the cell editors to the viewer 
+//             tableViewer.setCellEditors(editors);
+//             // Set the cell modifier for the viewer
+//             //tableViewer.setCellModifier(new MetaDataModifier(this));
+//             // Set the default sorter for the viewer 
+//             //tableViewer.setSorter(new ExampleTaskSorter(ExampleTaskSorter.DESCRIPTION));
+//             
+//             return tableViewer;
+//     }
        
        public int getPageSize() {
                return pageSize;
index 8e23888..c9b151a 100644 (file)
@@ -2,6 +2,16 @@ package com.quantum.view.tableview;
 
 import java.util.Vector;
 
+import com.quantum.Messages;
+import com.quantum.QuantumPlugin;
+import com.quantum.extensions.ProcessServiceMembers;
+import com.quantum.model.Bookmark;
+import com.quantum.model.Entity;
+import com.quantum.model.NotConnectedException;
+import com.quantum.sql.SQLResults;
+import com.quantum.ui.dialog.ExceptionDisplayDialog;
+import com.quantum.view.LogProxy;
+
 import org.eclipse.jface.action.Action;
 import org.eclipse.jface.action.IMenuListener;
 import org.eclipse.jface.action.MenuManager;
@@ -23,16 +33,6 @@ import org.eclipse.ui.IWorkbenchPart;
 import org.eclipse.ui.WorkbenchException;
 import org.eclipse.ui.part.ViewPart;
 
-import com.quantum.Messages;
-import com.quantum.QuantumPlugin;
-import com.quantum.extensions.ProcessServiceMembers;
-import com.quantum.model.Bookmark;
-import com.quantum.model.Entity;
-import com.quantum.model.NotConnectedException;
-import com.quantum.sql.SQLResults;
-import com.quantum.ui.dialog.ExceptionDisplayDialog;
-import com.quantum.view.LogProxy;
-
 /**
  * The Table View. Displays tables and Queries.
  */
@@ -98,19 +98,23 @@ public class TableView extends ViewPart implements ISelectionListener {
         * Reload table or query data into the selected tab
         */
        public void refreshCurrent() {
-               TabItem item = tabs.getItem(tabs.getSelectionIndex());
-               TableAdapter adapter = (TableAdapter) item.getData();
-               Bookmark bookmark = adapter.getBookmark();
-               String table = adapter.getTable();
-               if (table == null) {
-                       loadTable(bookmark, item, null, null, true, true);
-               } else {
-                       loadTable(bookmark, item, null, null, true, true);
+System.out.println("Refresh?");
+               if (tabs.getSelectionIndex() >= 0) {
+System.out.println("Refresh!");
+                       TabItem item = tabs.getItem(tabs.getSelectionIndex());
+                       TableAdapter adapter = (TableAdapter) item.getData();
+                       Bookmark bookmark = adapter.getBookmark();
+                       String table = adapter.getTable();
+                       if (table == null) {
+                               loadTable(bookmark, item, null, null, true, true);
+                       } else {
+                               loadTable(bookmark, item, null, null, true, true);
+                       }
+                       String title = Messages.getString("tableview.QuantumTableViewName"); //$NON-NLS-1$
+                       if (bookmark != null)
+                               title = bookmark.getName() + Messages.getString("tableview.ViewNameInitialDecoration") + title + Messages.getString("tableview.ViewNameFinalDecoration"); //$NON-NLS-1$ //$NON-NLS-2$
+                       setTitle(title);
                }
-               String title = Messages.getString("tableview.QuantumTableViewName"); //$NON-NLS-1$
-               if (bookmark != null)
-                       title = bookmark.getName() + Messages.getString("tableview.ViewNameInitialDecoration") + title + Messages.getString("tableview.ViewNameFinalDecoration"); //$NON-NLS-1$ //$NON-NLS-2$
-               setTitle(title);
        }
        
     public void loadQuery(Bookmark bookmark, SQLResults results) {
@@ -277,6 +281,5 @@ public class TableView extends ViewPart implements ISelectionListener {
        }
 
        public void selectionChanged(IWorkbenchPart part, ISelection selection) {
-
        }
 }
\ No newline at end of file
index cb06fbd..a4cd450 100644 (file)
@@ -4,8 +4,8 @@
  */
 package com.quantum.view.tableview;
 
+import com.quantum.ImageStore;
 import com.quantum.Messages;
-import com.quantum.QuantumPlugin;
 import com.quantum.actions.CloseTableAction;
 import com.quantum.actions.RefreshTableAction;
 import com.quantum.model.NotConnectedException;
@@ -33,8 +33,6 @@ import org.eclipse.swt.widgets.ToolItem;
 public class TableViewToolBar {
 
        private ToolBar toolBar;
-       private RefreshTableAction refreshTableAction;
-       private CloseTableAction closeTableAction;
        private ToolItem previous;
        private ToolItem next;
        
@@ -49,36 +47,14 @@ public class TableViewToolBar {
 
                this.toolBar = toolBar;
                
-               refreshTableAction = new RefreshTableAction();
-               refreshTableAction.setText(Messages.getString("tableview.refresh")); //$NON-NLS-1$
-               refreshTableAction.setImageDescriptor(
-                       QuantumPlugin.getImageDescriptor("refresh.gif")); //$NON-NLS-1$
-               refreshTableAction.init(view);
-               closeTableAction = new CloseTableAction();
-               closeTableAction.setText(Messages.getString("tableview.close")); //$NON-NLS-1$
-               closeTableAction.setImageDescriptor(
-                       QuantumPlugin.getImageDescriptor("close.gif")); //$NON-NLS-1$
-               closeTableAction.init(view);
-
-               ToolItem toolItem = new ToolItem(toolBar, SWT.PUSH);
-               toolItem.setImage(QuantumPlugin.getImage("refresh.gif")); //$NON-NLS-1$
-               toolItem.setToolTipText(Messages.getString("tableview.refresh")); //$NON-NLS-1$
-               toolItem.addSelectionListener(new SelectionListener() {
-                       public void widgetDefaultSelected(SelectionEvent e) {
-                       }
-                       public void widgetSelected(SelectionEvent e) {
-                               refreshTableAction.run();
-                       }
-               });
-
                final Action copyAction = new CopyAction(view, table);
                final Action selectAllAction = new Action() {
                        public void run() {
                                table.selectAll();
                        }
                };
-               toolItem = new ToolItem(toolBar, SWT.PUSH);
-               toolItem.setImage(QuantumPlugin.getImage("copy.gif")); //$NON-NLS-1$
+               ToolItem toolItem = new ToolItem(toolBar, SWT.PUSH);
+               toolItem.setImage(ImageStore.getImage(ImageStore.COPY));
                toolItem.setToolTipText(Messages.getString("tableview.copy")); //$NON-NLS-1$
                toolItem.addSelectionListener(new SelectionListener() {
                        public void widgetDefaultSelected(SelectionEvent e) {
@@ -88,7 +64,7 @@ public class TableViewToolBar {
                        }
                });
                toolItem = new ToolItem(toolBar, SWT.PUSH);
-               toolItem.setImage(QuantumPlugin.getImage("table.gif")); //$NON-NLS-1$
+               toolItem.setImage(ImageStore.getImage(ImageStore.OPEN_TABLE)); //$NON-NLS-1$
                toolItem.setToolTipText(Messages.getString("tableview.selectAll")); //$NON-NLS-1$
                toolItem.addSelectionListener(new SelectionListener() {
                        public void widgetDefaultSelected(SelectionEvent e) {
@@ -99,7 +75,7 @@ public class TableViewToolBar {
                });
 
                filter = new ToolItem(toolBar, SWT.PUSH);
-               filter.setImage(QuantumPlugin.getImage("filter.gif")); //$NON-NLS-1$
+               filter.setImage(ImageStore.getImage(ImageStore.FILTER));
                filter.setToolTipText(Messages.getString("tableview.filterSort")); //$NON-NLS-1$
 
                toolItem = new ToolItem(toolBar, SWT.SEPARATOR);
@@ -109,7 +85,7 @@ public class TableViewToolBar {
                previous = new ToolItem(toolBar, SWT.PUSH);
                next = new ToolItem(toolBar, SWT.PUSH);
 
-               fullMode.setImage(QuantumPlugin.getImage("fulldata.gif")); //$NON-NLS-1$
+               fullMode.setImage(ImageStore.getImage(ImageStore.FULLDATA));
                fullMode.setToolTipText(Messages.getString("tableview.showAll")); //$NON-NLS-1$
                fullMode.setSelection(false);
                fullMode.addSelectionListener(new SelectionListener() {
@@ -136,7 +112,7 @@ public class TableViewToolBar {
                 }
                        }
                });
-               previous.setImage(QuantumPlugin.getImage("previous.gif")); //$NON-NLS-1$
+               previous.setImage(ImageStore.getImage(ImageStore.PREVIOUS));
                previous.setToolTipText("Previous"); //$NON-NLS-1$
                previous.addSelectionListener(new SelectionListener() {
                        public void widgetDefaultSelected(SelectionEvent e) {
@@ -158,7 +134,7 @@ public class TableViewToolBar {
                 }
                        }
                });
-               next.setImage(QuantumPlugin.getImage("next.gif")); //$NON-NLS-1$
+               next.setImage(ImageStore.getImage(ImageStore.NEXT));
                next.setToolTipText("Next"); //$NON-NLS-1$
                next.addSelectionListener(new SelectionListener() {
                        public void widgetDefaultSelected(SelectionEvent e) {
@@ -181,19 +157,6 @@ public class TableViewToolBar {
                        }
                });
 
-               toolItem = new ToolItem(toolBar, SWT.SEPARATOR);
-
-               toolItem = new ToolItem(toolBar, SWT.PUSH);
-               toolItem.setImage(QuantumPlugin.getImage("close.gif")); //$NON-NLS-1$
-               toolItem.setToolTipText(Messages.getString("tableview.close")); //$NON-NLS-1$
-               toolItem.addSelectionListener(new SelectionListener() {
-                       public void widgetDefaultSelected(SelectionEvent e) {
-                       }
-                       public void widgetSelected(SelectionEvent e) {
-                               closeTableAction.run();
-                       }
-               });
-
        }
 
        public void setColumns( final TableView view,   final TableAdapter ta,  Table table) {
index 93dd10b..e3cb426 100644 (file)
@@ -1,5 +1,6 @@
 package com.quantum.wizards;
 
+import com.quantum.ImageStore;
 import com.quantum.Messages;
 import com.quantum.QuantumPlugin;
 import com.quantum.adapters.AdapterFactory;
@@ -126,7 +127,7 @@ public class AddDriverWizard extends Wizard {
                                public void widgetSelected(SelectionEvent event) {
                                        SimpleSelectionDialog dialog = new SimpleSelectionDialog(
                                                        getShell(), "Select a Driver", JarUtil.getAllDriverNames(
-                                                                       getDriverFile()), QuantumPlugin.getImage("class.gif"));
+                                                                       getDriverFile()), ImageStore.getImage(ImageStore.CLASS));
                                        if (dialog.open() == SimpleSelectionDialog.OK) {
                                                IStructuredSelection selection = dialog.getSelection();
                                                if (!selection.isEmpty()) {
index 755f9be..a7a84fe 100644 (file)
@@ -8,6 +8,7 @@ import com.quantum.model.Column;
 import com.quantum.model.ConnectionException;
 import com.quantum.model.Entity;
 import com.quantum.model.NotConnectedException;
+import com.quantum.sql.SQLResults;
 import com.quantum.sql.TableRow;
 import com.quantum.view.ViewHelper;
 import com.quantum.view.tableview.TableAdapter;
@@ -15,7 +16,8 @@ import com.quantum.view.tableview.TableAdapter;
 import org.eclipse.jface.wizard.WizardPage;
 
 /**
- * @author BC
+ * @author BC Holmes
+ * @author Sirkware
  */
 public abstract class BaseSQLPage extends WizardPage implements SQLPage {
 
@@ -26,15 +28,18 @@ public abstract class BaseSQLPage extends WizardPage implements SQLPage {
         super(pageName);
     }
     public boolean performFinish() {
-        try {
-            Bookmark bookmark = this.adapter.getBookmark();
-            bookmark.addQuery(getQueryText());
-            ViewHelper.tryGetResults(getShell(), bookmark.getConnection(), getQueryText());
-        } catch (ConnectionException e) {
-            e.printStackTrace();
-        }
-        return true;
-    }
+               try {
+                       Bookmark bookmark = this.adapter.getBookmark();
+                       bookmark.addQuery(getQueryText());
+                       SQLResults sqlResults = ViewHelper.tryGetResults(getShell(),
+                                       bookmark.getConnection(), getQueryText());
+                       return sqlResults.isError() ? false : true;
+               } catch (ConnectionException e) {
+                       e.printStackTrace();
+                       return false;
+               }
+       }
+    
     protected abstract String getQueryText();
     protected void appendColumn(StringBuffer whereClause, Entity entity, String columnName, DatabaseAdapter adapter, String value) {
         
index 3feed8f..e8be91d 100644 (file)
@@ -6,8 +6,8 @@ import java.io.IOException;
 
 import javax.xml.parsers.ParserConfigurationException;
 
+import com.quantum.ImageStore;
 import com.quantum.Messages;
-import com.quantum.QuantumPlugin;
 import com.quantum.model.Bookmark;
 import com.quantum.model.BookmarkCollection;
 import com.quantum.model.xml.ModelToXMLConverter;
@@ -78,7 +78,7 @@ public class ExportBookmarkWizardPage extends WizardPage {
 
         public Image getImage(Object element) {
             if (element instanceof Bookmark) {
-                return QuantumPlugin.getImage("bookmarks.gif");
+                return ImageStore.getImage(ImageStore.BOOKMARK);
             } else {
                 return null;
             }