From 77f1e8e2cf456433324bdb8dc71fe2ec4a491c70 Mon Sep 17 00:00:00 2001
From: khartlage
Date: Tue, 17 Aug 2004 09:54:03 +0000
Subject: [PATCH] Quantum version 2.4.2
---
.../plugin.xml | 15 +-
.../src/com/quantum/IQuantumConstants.java | 15 +-
.../src/com/quantum/ImageStore.java | 198 ++++++-----
.../src/com/quantum/PluginPreferences.java | 55 +++
.../src/com/quantum/QuantumPlugin.java | 57 +---
.../src/com/quantum/QuantumResources.properties | 122 ++++---
.../src/com/quantum/actions/BaseExecuteAction.java | 20 +-
.../com/quantum/actions/DeleteAllRowsAction.java | 8 +-
.../src/com/quantum/actions/DisconnectAction.java | 10 +-
.../com/quantum/actions/ExecuteAgainstAction.java | 1 -
.../src/com/quantum/actions/NewBookmarkAction.java | 2 +-
.../src/com/quantum/actions/OpenQueryAction.java | 3 +-
.../com/quantum/actions/RefreshBookmarkAction.java | 10 +-
.../src/com/quantum/actions/ViewTableAction.java | 4 +-
.../quantum/actions/ViewTableDetailsAction.java | 4 +-
.../src/com/quantum/editors/ColorManager.java | 11 +-
.../src/com/quantum/editors/SQLColorConstants.java | 2 +-
.../editors/SQLSourceViewerConfiguration.java | 15 +-
.../src/com/quantum/model/Bookmark.java | 19 +-
.../src/com/quantum/model/DataType.java | 34 ++-
.../src/com/quantum/model/Database.java | 110 ++++--
.../src/com/quantum/model/Entity.java | 8 +-
.../src/com/quantum/model/EntityImpl.java | 135 +++++--
.../com/quantum/preferences/GlobalPreferences.java | 16 +-
.../quantum/preferences/SQLEditorPreferences.java | 356 +++++++++---------
.../quantum/properties/DataTypesPropertyPage.java | 156 ++++++++
.../DatabaseInformationPropertyPage.java | 96 -----
.../src/com/quantum/sql/ConnectionEstablisher.java | 3 +-
.../src/com/quantum/sql/MultiSQLServer.java | 10 +-
.../src/com/quantum/sql/SQLMetaDataResults.java | 19 +-
.../quantum/sql/SQLStandardResultSetResults.java | 2 +-
.../quantum/sql/parser/DropEntityStatement.java | 46 +++
.../com/quantum/ui/dialog/SQLExceptionDialog.java | 66 ++++
.../quantum/util/connection/ConnectionUtil.java | 16 +-
.../src/com/quantum/util/sql/SQLStates.java | 18 +
.../src/com/quantum/view/SQLQueryView.java | 99 ++++--
.../com/quantum/view/SchemaSelectionControl.java | 3 +-
.../src/com/quantum/view/ViewHelper.java | 3 +-
.../view/bookmark/BookmarkContentProvider.java | 5 +-
.../com/quantum/view/bookmark/BookmarkNode.java | 3 +-
.../view/bookmark/BookmarkViewActionGroup.java | 82 ++++-
.../src/com/quantum/view/bookmark/ColumnNode.java | 7 +
.../com/quantum/view/bookmark/DeleteAction.java | 88 +++++
.../quantum/view/bookmark/DropEntityAction.java | 81 ++++
.../src/com/quantum/view/bookmark/EntityNode.java | 45 ++-
.../src/com/quantum/view/bookmark/GroupNode.java | 23 +-
.../src/com/quantum/view/bookmark/QueryNode.java | 3 +
.../src/com/quantum/view/bookmark/SchemaNode.java | 30 ++-
.../src/com/quantum/view/bookmark/TreeNode.java | 4 +-
.../src/com/quantum/view/subset/ObjectNode.java | 3 +-
.../quantum/view/tableview/ResultSetAction.java | 3 +-
.../src/com/quantum/view/widget/ComboViewer.java | 2 +-
.../quantum/view/widget/SimpleLabelProvider.java | 32 ++
.../src/com/quantum/wizards/BaseSQLPage.java | 30 ++-
.../wizards/BookmarkConnectionWizardPage.java | 10 +-
.../src/com/quantum/wizards/BookmarkWizard.java | 2 +
.../quantum/wizards/ExportBookmarkWizardPage.java | 3 +-
.../src/com/quantum/wizards/InsertRowPage.java | 225 ++++++++++--
.../src/com/quantum/wizards/SortFilterPage.java | 4 +-
.../src/com/quantum/wizards/UpdateRowPage.java | 384 +++++++++++++++----
.../quantum/wizards/sql/DropEntityWizardPage.java | 68 ++++
.../quantum/wizards/sql/SQLStatementWizard.java | 64 ++++
.../wizards/sql/ShowSQLStatementWizardPage.java | 62 ++++
63 files changed, 2202 insertions(+), 828 deletions(-)
create mode 100644 archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/PluginPreferences.java
create mode 100644 archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/properties/DataTypesPropertyPage.java
create mode 100644 archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/sql/parser/DropEntityStatement.java
create mode 100644 archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/ui/dialog/SQLExceptionDialog.java
create mode 100644 archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/util/sql/SQLStates.java
create mode 100644 archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/bookmark/DeleteAction.java
create mode 100644 archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/bookmark/DropEntityAction.java
create mode 100644 archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/widget/SimpleLabelProvider.java
create mode 100644 archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/wizards/sql/DropEntityWizardPage.java
create mode 100644 archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/wizards/sql/SQLStatementWizard.java
create mode 100644 archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/wizards/sql/ShowSQLStatementWizardPage.java
diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/plugin.xml b/archive/net.sourceforge.phpeclipse.quantum.sql/plugin.xml
index 710df0b..ef6a869 100644
--- a/archive/net.sourceforge.phpeclipse.quantum.sql/plugin.xml
+++ b/archive/net.sourceforge.phpeclipse.quantum.sql/plugin.xml
@@ -3,8 +3,8 @@
@@ -266,6 +266,13 @@
id="com.quantum.properties.DatabaseInformationPropertyPage">
+
+
-
-
+ -->
diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/IQuantumConstants.java b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/IQuantumConstants.java
index 444e96c..b9bd47d 100644
--- a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/IQuantumConstants.java
+++ b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/IQuantumConstants.java
@@ -1,22 +1,11 @@
-/*
- * Created on 12-jul-2003
- *
- */
package com.quantum;
/**
- * @author panic
- *
* Constants for general use in the quantum plug-in
+ *
+ * @author panic
*/
public interface IQuantumConstants {
- public static final String PLUGIN_ID ="com.quantum"; //$NON-NLS-1$
- public static final String PREFIX = PLUGIN_ID+"."; //$NON-NLS-1$
-
- //Constants for specifying Tables, Views and Sequences to the JDBC driver
- public static final String Table = "TABLE";
- public static final String View = "VIEW";
- public static final String Sequence = "SEQUENCE";
public static final String autoCommitTrue = "Always True";
public static final String autoCommitFalse = "Always False";
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
index 1a7495f..565de9f 100644
--- a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/ImageStore.java
+++ b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/ImageStore.java
@@ -25,6 +25,7 @@ public class ImageStore {
private static final String VERSION_2 = "_2x";
private static final String GIF_FILE_EXTENSION = ".gif";
+ private static final String JPG_FILE_EXTENSION = ".jpg";
public static final String ADD = "add";
public static final String ADD_SCHEMA = "add_schema";
@@ -62,6 +63,8 @@ public class ImageStore {
public static final String MISSINGSCHEMA = "missingschema";
public static final String MISSINGTABLE = "table";
public static final String NEXT = "next";
+ public static final String NEW_BOOKMARK = "new_bookmark";
+ public static final String NEW_BOOKMARK_WIZARD = "new_bookmark_wizard";
public static final String OPEN_TABLE = "table";
public static final String PASTE = "paste";
public static final String PLAY = "play";
@@ -81,12 +84,13 @@ public class ImageStore {
public static final String TABLE = "bigtable";
public static final String TABLE_DETAILS = "table_details";
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 final String CHECKED = "checked";
+ public static final String UNCHECKED = "unchecked";
public static ImageDescriptor getImageDescriptor(String imageName) {
return getImageDescriptor(imageName, QuantumPlugin.getDefault());
@@ -104,39 +108,51 @@ public class ImageStore {
public static Image getImage(String imageName, AbstractUIPlugin plugin) {
ImageRegistry registry = plugin.getImageRegistry();
String key = stripSuffix(imageName);
- Image image = registry.get(getVersionAppropriateImage(key));
+ Image image = registry.get(getVersionAppropriateImage(key, plugin));
return image;
}
public static ImageDescriptor getImageDescriptor(String imageName, AbstractUIPlugin plugin) {
ImageRegistry registry = plugin.getImageRegistry();
String key = stripSuffix(imageName);
- key = getVersionAppropriateImage(key);
+ key = getVersionAppropriateImage(key, plugin);
if (VersioningHelper.isEclipse21OrHigher()) {
return VersioningHelper.getDescriptor(registry, key);
} else {
- return (ImageDescriptor) imageDescriptorMap.get(key);
+ return (ImageDescriptor) getImageDescriptorMap(plugin).get(key);
}
}
+
+ private static Map getImageDescriptorMap(AbstractUIPlugin plugin) {
+ String key = plugin.getClass().getName();
+ if (!imageDescriptorMap.containsKey(key)) {
+ imageDescriptorMap.put(key, new HashMap());
+ }
+ return (Map) 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;
+ if (imageName.endsWith(GIF_FILE_EXTENSION)) {
+ return imageName.substring(0, imageName.length() - 4);
+ }else if (imageName.endsWith(JPG_FILE_EXTENSION)) {
+ return imageName.substring(0, imageName.length() - 4);
+ } else {
+ return imageName;
+ }
}
/**
* @param imageName
* @return
*/
- private static String getVersionAppropriateImage(String imageName) {
+ private static String getVersionAppropriateImage(String imageName, AbstractUIPlugin plugin) {
String version2Key = imageName + VERSION_2;
- return !VersioningHelper.isEclipse30() && imageDescriptorMap.containsKey(version2Key)
+ return !VersioningHelper.isEclipse30() && getImageDescriptorMap(plugin).containsKey(version2Key)
? version2Key : imageName;
}
@@ -144,94 +160,98 @@ public class ImageStore {
* @param registry
* @param url
*/
- static void initialize(ImageRegistry registry, URL url) {
+ static void initialize(AbstractUIPlugin plugin, 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, CLOSE_DISABLED);
- addImage(registry, url, CLOSE_ALL);
- addImage(registry, url, CLOSE_ALL_DISABLED);
- 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, EXTERNAL_JAR);
- 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, TABLE_DETAILS);
- 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);
+ addImage(plugin, registry, url, ADD);
+ addImage(plugin, registry, url, BOOKMARK);
+ addImage(plugin, registry, url, DISCONNECT);
+ addImage(plugin, registry, url, ADD);
+ addImage(plugin, registry, url, ADD_SCHEMA);
+ addImage(plugin, registry, url, APPEND);
+ addImage(plugin, registry, url, AUTOCOMMIT);
+ addImage(plugin, registry, url, BOOKMARK);
+ addImage(plugin, registry, url, BOOKMARKFILE);
+ addImage(plugin, registry, url, CLASS);
+ addImage(plugin, registry, url, CLEAR);
+ addImage(plugin, registry, url, CLOSE);
+ addImage(plugin, registry, url, CLOSE_DISABLED);
+ addImage(plugin, registry, url, CLOSE_ALL);
+ addImage(plugin, registry, url, CLOSE_ALL_DISABLED);
+ addImage(plugin, registry, url, COLUMN);
+ addImage(plugin, registry, url, CONNECT);
+ addImage(plugin, registry, url, CONNECTED);
+ addImage(plugin, registry, url, COPY);
+ addImage(plugin, registry, url, CUT);
+ addImage(plugin, registry, url, DELETE);
+ addImage(plugin, registry, url, DISCONNECT);
+ addImage(plugin, registry, url, DRIVER);
+ addImage(plugin, registry, url, EDIT);
+ addImage(plugin, registry, url, ENTITYGROUP);
+ addImage(plugin, registry, url, EXPORT);
+ addImage(plugin, registry, url, EXTERNAL_JAR);
+ addImage(plugin, registry, url, FILTER);
+ addImage(plugin, registry, url, FOREIGNKEY);
+ addImage(plugin, registry, url, FULLDATA);
+ addImage(plugin, registry, url, GRID);
+ addImage(plugin, registry, url, GROUP);
+ addImage(plugin, registry, url, IMPORT);
+ addImage(plugin, registry, url, KEY);
+ addImage(plugin, registry, url, KEYCOLUMN);
+ addImage(plugin, registry, url, LOG);
+ addImage(plugin, registry, url, MISSINGSCHEMA);
+ addImage(plugin, registry, url, MISSINGTABLE);
+ addImage(plugin, registry, url, NEXT);
+ addImage(plugin, registry, url, NEW_BOOKMARK);
+ addImage(plugin, registry, url, NEW_BOOKMARK_WIZARD, JPG_FILE_EXTENSION);
+ addImage(plugin, registry, url, PASTE);
+ addImage(plugin, registry, url, PLAY);
+ addImage(plugin, registry, url, PREVIOUS);
+ addImage(plugin, registry, url, QMODEL);
+ addImage(plugin, registry, url, QUANTUM);
+ addImage(plugin, registry, url, REFRESH);
+ addImage(plugin, registry, url, ROLLBACK);
+ addImage(plugin, registry, url, SAMPLE);
+ addImage(plugin, registry, url, SCHEMA);
+ addImage(plugin, registry, url, SCRIPT);
+ addImage(plugin, registry, url, SEQUENCE);
+ addImage(plugin, registry, url, STATEMENT);
+ addImage(plugin, registry, url, STOP);
+ addImage(plugin, registry, url, SUBSET);
+ addImage(plugin, registry, url, SUCCESS);
+ addImage(plugin, registry, url, TABLE);
+ addImage(plugin, registry, url, TABLE_DETAILS);
+ addImage(plugin, registry, url, TEMPLATE);
+ addImage(plugin, registry, url, TRIGGER);
+ addImage(plugin, registry, url, USER);
+ addImage(plugin, registry, url, VIEW);
+ addImage(plugin, registry, url, WARNING);
+ addImage(plugin, registry, url, XML);
+ addImage(plugin, registry, url, CHECKED);
+ addImage(plugin, registry, url, UNCHECKED);
if (!VersioningHelper.isEclipse30()) {
- addImage(registry, url, CLOSE + VERSION_2);
- addImage(registry, url, CLOSE_ALL + VERSION_2);
- addImage(registry, url, COPY + VERSION_2);
- addImage(registry, url, DELETE + VERSION_2);
- addImage(registry, url, EXPORT + VERSION_2);
- addImage(registry, url, EXTERNAL_JAR + VERSION_2);
- addImage(registry, url, IMPORT + VERSION_2);
- addImage(registry, url, PASTE + VERSION_2);
- addImage(registry, url, REFRESH + VERSION_2);
+ addImage(plugin, registry, url, CLOSE + VERSION_2);
+ addImage(plugin, registry, url, CLOSE_ALL + VERSION_2);
+ addImage(plugin, registry, url, COPY + VERSION_2);
+ addImage(plugin, registry, url, DELETE + VERSION_2);
+ addImage(plugin, registry, url, EXPORT + VERSION_2);
+ addImage(plugin, registry, url, EXTERNAL_JAR + VERSION_2);
+ addImage(plugin, registry, url, IMPORT + VERSION_2);
+ addImage(plugin, registry, url, PASTE + VERSION_2);
+ addImage(plugin, registry, url, REFRESH + VERSION_2);
}
}
+ public static void addImage(AbstractUIPlugin plugin, ImageRegistry registry,
+ URL url, String key) {
+ addImage(plugin, registry, url, key, GIF_FILE_EXTENSION);
+ }
- /**
- * @param registry
- * @param url
- */
- private static void addImage(ImageRegistry registry, URL url, String key) {
+ public static void addImage(AbstractUIPlugin plugin, ImageRegistry registry,
+ URL url, String key, String extension) {
try {
ImageDescriptor descriptor = ImageDescriptor.createFromURL(
- new URL(url, key + GIF_FILE_EXTENSION));
- ImageStore.imageDescriptorMap.put(key, descriptor);
+ new URL(url, key + extension));
+ getImageDescriptorMap(plugin).put(key, descriptor);
registry.put(key, descriptor);
} catch (MalformedURLException e) {
// skip, but try to go on to the next one...
diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/PluginPreferences.java b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/PluginPreferences.java
new file mode 100644
index 0000000..9b554fd
--- /dev/null
+++ b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/PluginPreferences.java
@@ -0,0 +1,55 @@
+package com.quantum;
+
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.preference.PreferenceConverter;
+import org.eclipse.jface.resource.JFaceResources;
+import org.eclipse.swt.graphics.FontData;
+import org.eclipse.swt.graphics.RGB;
+
+
+/**
+ * @author BC Holmes
+ */
+public class PluginPreferences {
+
+ public static final String NUMERIC_COLOR = "quantum.numeric.color";
+ public static final String STRING_COLOR = "quantum.string.color";
+ public static final String COMMENT_COLOR = "quantum.comment.color";
+ public static final String KEYWORD_COLOR = "quantum.keyword.color";
+ public static final String TEXT_COLOR = "quantum.text.color";
+ public static final String BACKGROUND_COLOR = "quantum.background.color";
+
+ public static void initialize(IPreferenceStore store) {
+ initializeColors(store);
+
+ store.setDefault("quantum.text.bold", false); //$NON-NLS-1$
+ store.setDefault("quantum.keyword.bold", true); //$NON-NLS-1$
+ store.setDefault("quantum.string.bold", false); //$NON-NLS-1$
+ store.setDefault("quantum.comment.bold", false); //$NON-NLS-1$
+ store.setDefault("quantum.numeric.bold", false); //$NON-NLS-1$
+ PreferenceConverter.setDefault(store, "quantum.font", //$NON-NLS-1$
+ JFaceResources.getTextFont().getFontData());
+ store.setDefault("com.quantum.model.Bookmark.queryHistorySize", 20); //$NON-NLS-1$
+ }
+
+ /**
+ * @param store
+ */
+ private static void initializeColors(IPreferenceStore store) {
+ PreferenceConverter.setDefault(store, BACKGROUND_COLOR, new RGB(255, 255, 255));
+ PreferenceConverter.setDefault(store, TEXT_COLOR, new RGB(0, 0, 0));
+ PreferenceConverter.setDefault(store, KEYWORD_COLOR, new RGB(126, 0, 75));
+ PreferenceConverter.setDefault(store, COMMENT_COLOR, new RGB(88, 148, 64));
+ PreferenceConverter.setDefault(store, STRING_COLOR, new RGB(0, 0, 255));
+ PreferenceConverter.setDefault(store, NUMERIC_COLOR, new RGB(255, 0, 0));
+ }
+
+ /**
+ *
+ */
+ public static FontData getDefaultFont() {
+ FontData[] temp = JFaceResources.getTextFont().getFontData();
+ return temp == null || temp.length == 0 ? null : temp[0];
+ }
+
+}
diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/QuantumPlugin.java b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/QuantumPlugin.java
index 5a8b0e9..3842086 100644
--- a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/QuantumPlugin.java
+++ b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/QuantumPlugin.java
@@ -12,6 +12,10 @@ 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.ISavedState;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
@@ -35,10 +39,6 @@ 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
@@ -128,7 +128,7 @@ public class QuantumPlugin extends AbstractUIPlugin {
sysClip = new Clipboard(null);
}
-
+
/**
* Write the bookmarks and subsets to a file, saving them for next use of the quantum plugin
* @param target
@@ -156,43 +156,10 @@ public class QuantumPlugin extends AbstractUIPlugin {
}
}
-
-// 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);
- RGB COMMENT = new RGB(88, 148, 64);
- RGB KEYWORD = new RGB(126, 0, 75);
- RGB STRING = new RGB(0, 0, 255);
- RGB NUMERIC = new RGB(255, 0, 0);
- RGB DEFAULT = new RGB(0, 0, 0);
- IPreferenceStore store = getPreferenceStore();
- PreferenceConverter.setDefault(store,
- "quantum.background.color", BACKGROUND); //$NON-NLS-1$
- PreferenceConverter.setDefault(store,
- "quantum.text.color", DEFAULT); //$NON-NLS-1$
- PreferenceConverter.setDefault(store,
- "quantum.keyword.color", KEYWORD); //$NON-NLS-1$
- PreferenceConverter.setDefault(store,
- "quantum.comment.color", COMMENT); //$NON-NLS-1$
- PreferenceConverter.setDefault(store,
- "quantum.string.color", STRING); //$NON-NLS-1$
- PreferenceConverter.setDefault(store,
- "quantum.numeric.color", NUMERIC); //$NON-NLS-1$
- getPreferenceStore().setDefault("quantum.text.bold", false); //$NON-NLS-1$
- getPreferenceStore().setDefault("quantum.keyword.bold", true); //$NON-NLS-1$
- getPreferenceStore().setDefault("quantum.string.bold", false); //$NON-NLS-1$
- getPreferenceStore().setDefault("quantum.comment.bold", false); //$NON-NLS-1$
- getPreferenceStore().setDefault("quantum.numeric.bold", false); //$NON-NLS-1$
- PreferenceConverter.setDefault(getPreferenceStore(), "quantum.font", //$NON-NLS-1$
- JFaceResources.getTextFont().getFontData());
- getPreferenceStore().setDefault("com.quantum.model.Bookmark.queryHistorySize", 20); //$NON-NLS-1$
-
-
- getPreferenceStore().setDefault(
+ PluginPreferences.initialize(getPreferenceStore());
+
+ getPreferenceStore().setDefault(
"phpeclipse.sql.select.template",
"$results = mysql_query(\"SELECT {0} FROM {1} WHERE {2} \");");
@@ -250,6 +217,8 @@ public class QuantumPlugin extends AbstractUIPlugin {
return tableView;
}
+
+
/**
* @return
*/
@@ -259,7 +228,7 @@ public class QuantumPlugin extends AbstractUIPlugin {
protected void initializeImageRegistry(ImageRegistry registry) {
super.initializeImageRegistry(registry);
try {
- ImageStore.initialize(registry, getIconLocation());
+ ImageStore.initialize(this, registry, getIconLocation());
} catch (MalformedURLException e) {
// this should never happen, but if it does, we don't get images.
}
@@ -269,8 +238,8 @@ public class QuantumPlugin extends AbstractUIPlugin {
* @return
* @throws MalformedURLException
*/
- URL getIconLocation() throws MalformedURLException {
- URL installURL = QuantumPlugin.getDefault().getDescriptor().getInstallURL();
+ private URL getIconLocation() throws MalformedURLException {
+ URL installURL = getDescriptor().getInstallURL();
return new URL(installURL, "icons/");
}
}
\ No newline at end of file
diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/QuantumResources.properties b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/QuantumResources.properties
index 7cb2931..cb2d1bb 100644
--- a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/QuantumResources.properties
+++ b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/QuantumResources.properties
@@ -69,16 +69,6 @@ QuantumPlugin.Not_saving_unchanged_bookmarks_18=Not saving unchanged bookmarks
QuantumPlugin.iconsDir=icons/
QuantumPlugin.saveDir=save
QuantumPlugin.saveFileExtension=.xml
-ExecuteAction.Executing_Query3=Executing Query...
-ExecuteAction.Executing_Query2=Executing Query..
-ExecuteAction.Parsing_sql_script3=Parsing sql script...
-ExecuteAction.QueriesExecuted=\ queries executed,
-ExecuteAction.RowsUpdated=\ rows updated,
-ExecuteAction.Errors=\ errors,
-ExecutAction.TimeExec=\ seconds
-ExecuteAction.Done=Done
-ExecuteAction.RowUpdated=\ rows updated,
-ExecuteAction.ResultsDisplayed=\ results displayed,
ExportXMLAction.XMLExporting=XML struct: Exporting to file:
ExportXMLAction.Metadata=Metadata
ExportXMLAction.Author=Author
@@ -129,22 +119,6 @@ MetaDataKeySeparator=:
NoFeature.Views=Views
NoFeature.Sequences=Sequences
Error.NoDatabase=Database not supported:
-PreferencesPage.PickFont=Pick Font
-PreferencesPage.DefaultFont=Default Font
-PreferencesPage.BackgroundColor=Background Color
-PreferencesPage.DefaultTextColor=Default Text Color
-PreferencesPage.quantum.keyword.color_26=quantum.keyword.color
-PreferencesPage.KeywordTextColor=Keyword Text Color
-PreferencesPage.Bold=Bold
-PreferencesPage.CommentTextColor=Comment Text Color
-PreferencesPage.StringTextColor=String Text Color
-PreferencesPage.NumericTextColor=Numeric Text Color
-PreferencesPage.Font_Default=Font: default
-PreferencesPage.regular=regular
-PreferencesPage.bold=bold
-PreferencesPage.italic=italic
-PreferencesPage.boldItalic=bold italic
-PreferencesPage.FontPrompt=Font:
DeleteColumnAction.DeleteColumns=Delete Columns...
DeleteColumnAction.ConfirmDeleteColumns=Are you sure you want to delete the selected columns?
DeleteObjectAction.DeleteSubset=Delete Subset...
@@ -216,11 +190,6 @@ BookmarkView.SetExtraSchemas=Set Extra Schemas
BookmarkView.CopyColumnSeparator=\
MultiSQLServer.Enter_Password=Enter Password
MultiSQLServer.PasswordNotProvided=Password not provided in Bookmark
-BookmarkSelectionDialog.text=Select a bookmark
-BookmarkSelectionDialog.title=Bookmark Selection
-ExecuteAgainstAction.IOException=An I/O Exception was encountered while \ntrying to read the input file.
-ExecuteAgainstAction.SQLException=A database error was encountered while \ntrying to execute the SQL statements.
-ExecuteAgainstAction.title=Problem Encountered
ExceptionDisplayDialog.stackTrace=Stack trace:
# Actions
@@ -235,7 +204,6 @@ com.quantum.actions.DisconnectAction.text = Disconnect
com.quantum.actions.DisconnectAction.message = Disconnected
com.quantum.actions.ViewTableAction.text = View Table
com.quantum.actions.OpenQueryAction.text = Open
-com.quantum.actions.DeleteBookmarkAction.text = Delete
com.quantum.actions.RefreshBookmarkAction.text = Refresh
com.quantum.actions.NextSequenceAction.text = Increment Sequence Value
com.quantum.actions.PrevSequenceAction.text = Current Sequence Value
@@ -246,18 +214,24 @@ com.quantum.actions.DeleteAllRowsAction.confirmTitle = Warning
com.quantum.actions.DeleteAllRowsAction.confirmText = Are you sure you want to delete all the rows from the table {0}?
com.quantum.actions.ViewTableDetailsAction.text = View Table Details
+com.quantum.adapters.DatabaseAdapter.GENERIC = Generic JDBC
+com.quantum.adapters.DatabaseAdapter.HSQLDB = HSQL (Hypersonic)
+com.quantum.adapters.DatabaseAdapter.ORACLE = Oracle
+com.quantum.adapters.DatabaseAdapter.POSTGRES = Postgres
+com.quantum.adapters.DatabaseAdapter.MYSQL = MySQL
+com.quantum.adapters.DatabaseAdapter.DB2 = DB2
+com.quantum.adapters.DatabaseAdapter.DB2AS400 = DB2 for AS400
+com.quantum.adapters.DatabaseAdapter.ADABASD = Adabas-D
+com.quantum.adapters.DatabaseAdapter.INFORMIX = Informix Dynamic Server
+com.quantum.adapters.DatabaseAdapter.REDBRICK = Red Brick
+com.quantum.adapters.DatabaseAdapter.SYBASE = Sybase
+com.quantum.adapters.DatabaseAdapter.POINTBASE = Pointbase
+com.quantum.adapters.DatabaseAdapter.JDBC_ODBC_BRIDGE = JDBC-ODBC Bridge
+com.quantum.adapters.DatabaseAdapter.MS_SQL_SERVER = Microsoft SQL Server
+
com.quantum.util.connection.ConnectionUtil.title = Connection Not Established
com.quantum.util.connection.ConnectionUtil.message = The bookmark could not be connected.
-com.quantum.view.bookmark.CopyAction.text = Copy
-com.quantum.view.bookmark.PasteAction.text = Paste
-com.quantum.view.bookmark.RenameAction.text = Rename
-com.quantum.view.bookmark.QuickListNode.labelName=Quick List
-com.quantum.view.bookmark.QueryListNode.labelName=Recent SQL Statements
-com.quantum.view.bookmark.GroupNode.TABLE=Tables
-com.quantum.view.bookmark.GroupNode.VIEW=Views
-com.quantum.view.bookmark.GroupNode.SEQUENCE=Sequences
-
com.quantum.preferences.GlobalPreferences.com.quantum.model.Bookmark.queryHistorySize=Maximum size of query history:
com.quantum.wizards.ExportBookmarkWizardPage.title = Export Bookmark List
@@ -310,21 +284,6 @@ com.quantum.wizards.AddDriverWizard.browse=Browse...
com.quantum.wizards.AddDriverWizard.jars=Driver Jars:
com.quantum.wizards.AddDriverWizard.driverClassName=Class name:
-com.quantum.adapters.DatabaseAdapter.GENERIC = Generic JDBC
-com.quantum.adapters.DatabaseAdapter.HSQLDB = HSQL (Hypersonic)
-com.quantum.adapters.DatabaseAdapter.ORACLE = Oracle
-com.quantum.adapters.DatabaseAdapter.POSTGRES = Postgres
-com.quantum.adapters.DatabaseAdapter.MYSQL = MySQL
-com.quantum.adapters.DatabaseAdapter.DB2 = DB2
-com.quantum.adapters.DatabaseAdapter.DB2AS400 = DB2 for AS400
-com.quantum.adapters.DatabaseAdapter.ADABASD = Adabas-D
-com.quantum.adapters.DatabaseAdapter.INFORMIX = Informix Dynamic Server
-com.quantum.adapters.DatabaseAdapter.REDBRICK = Red Brick
-com.quantum.adapters.DatabaseAdapter.SYBASE = Sybase
-com.quantum.adapters.DatabaseAdapter.POINTBASE = Pointbase
-com.quantum.adapters.DatabaseAdapter.JDBC_ODBC_BRIDGE = JDBC-ODBC Bridge
-com.quantum.adapters.DatabaseAdapter.MS_SQL_SERVER = Microsoft SQL Server
-
com.quantum.view.SchemaSelectionControl.addSchemaDialog = Select a Schema
com.quantum.view.SchemaSelectionControl.connectTitle = Connect Required
com.quantum.view.SchemaSelectionControl.connectMessage = We must connect to the database to retrieve schemas.
@@ -332,13 +291,36 @@ com.quantum.view.SchemaSelectionControl.useAllSchemas = Show all schemas
com.quantum.view.SchemaSelectionControl.useUsernameAsSchema = Show the default schema
com.quantum.view.SchemaSelectionControl.useSelectedSchemas = Show selected schemas
-com.quantum.properties.DatabaseInformationPropertyPage.dataTypes = The following data types are supported by this database:
-com.quantum.properties.DatabaseInformationPropertyPage.column0 = Data Type
-com.quantum.properties.DatabaseInformationPropertyPage.column1 = Java Type
+com.quantum.preferences.SQLEditorPreferences.font=Font
+com.quantum.preferences.SQLEditorPreferences.pickFont=Pick Font
+com.quantum.preferences.SQLEditorPreferences.defaultFont=Default Font
+com.quantum.preferences.SQLEditorPreferences.backgroundColor=Background Color
+com.quantum.preferences.SQLEditorPreferences.defaultTextColor=Default Text Color
+com.quantum.preferences.SQLEditorPreferences.keywordTextColor=Keyword Text Color
+com.quantum.preferences.SQLEditorPreferences.bold=Bold
+com.quantum.preferences.SQLEditorPreferences.commentTextColor=Comment Text Color
+com.quantum.preferences.SQLEditorPreferences.stringTextColor=String Text Color
+com.quantum.preferences.SQLEditorPreferences.numericTextColor=Numeric Text Color
+com.quantum.preferences.SQLEditorPreferences.default=Font: default
+com.quantum.preferences.SQLEditorPreferences.regularFont={0} {1}
+com.quantum.preferences.SQLEditorPreferences.boldFont={0} {1} Bold
+com.quantum.preferences.SQLEditorPreferences.italicFont={0} {1} Italic
+com.quantum.preferences.SQLEditorPreferences.boldItalicFont={0} {1} Bold Italic
+
com.quantum.properties.DatabaseInformationPropertyPage.product = Product:
com.quantum.properties.DatabaseInformationPropertyPage.unknown =
com.quantum.properties.DatabaseInformationPropertyPage.error = QuantumDB could not retrieve the database information due to an error:
+com.quantum.properties.DataTypesPropertyPage.dataTypes = The following data types are supported by this database:
+com.quantum.properties.DataTypesPropertyPage.column0 = Data Type
+com.quantum.properties.DataTypesPropertyPage.column1 = Java Type
+com.quantum.properties.DataTypesPropertyPage.column2 = Precision
+com.quantum.properties.DataTypesPropertyPage.column3 = Literal Prefix
+com.quantum.properties.DataTypesPropertyPage.column4 = Literal Suffix
+com.quantum.properties.DataTypesPropertyPage.column5 = Create Parameters
+com.quantum.properties.DataTypesPropertyPage.unknown =
+com.quantum.properties.DataTypesPropertyPage.error = QuantumDB could not retrieve the data type due to an error:
+
com.quantum.properties.BaseEntityPropertyPage.name = Name:
com.quantum.properties.BaseEntityPropertyPage.schema = Schema:
com.quantum.properties.BaseEntityPropertyPage.error = QuantumDB could not retrieve the information due to an error:
@@ -379,6 +361,22 @@ com.quantum.actions.ExecuteAction.text=Execute Against "{0}"
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.
+
+com.quantum.view.bookmark.CopyAction.text = Copy
+com.quantum.view.bookmark.DeleteAction.text = Delete
+com.quantum.view.bookmark.DeleteAction.confirmTitle = Delete Bookmark
+com.quantum.view.bookmark.DeleteAction.confirmText = Are you sure you want to delete the selected bookmarks?
+com.quantum.view.bookmark.DropEntityAction.text=Drop Table/View/Sequence...
+com.quantum.view.bookmark.GroupNode.TABLE=Tables
+com.quantum.view.bookmark.GroupNode.VIEW=Views
+com.quantum.view.bookmark.GroupNode.SEQUENCE=Sequences
+com.quantum.view.bookmark.PasteAction.text = Paste
+com.quantum.view.bookmark.QuickListNode.labelName=Quick List
+com.quantum.view.bookmark.QueryListNode.labelName=Recent SQL Statements
+com.quantum.view.bookmark.RenameAction.text = Rename
+
+com.quantum.view.bookmark.BookmarkViewActionGroup.sqlAction.text = SQL Statements
+
com.quantum.view.driver.DeleteDriverAction.text=Delete
com.quantum.view.driver.DeleteDriverAction.confirm=Confirm Delete
com.quantum.view.driver.DeleteDriverAction.confirmText=Are you sure you want to delete "{0}"?
@@ -411,4 +409,10 @@ com.quantum.wizards.URLSetupControl.datasource=Data Source:
com.quantum.wizards.InformixURLSetupControl.informixserver=Informix Server:
com.quantum.wizards.URLSetupControl.url=URL:
+com.quantum.ui.dialog.SQLExceptionDialog.title=SQL Exception
+com.quantum.ui.dialog.SQLExceptionDialog.sqlState=SQL State:
+com.quantum.ui.dialog.SQLExceptionDialog.errorCode=Error Code:
+com.quantum.ui.dialog.SQLExceptionDialog.titleWithBookmark=SQL Exception on Bookmark: {0}
+
com.quantum.model.ConnectionException.couldNotInstaniateDriver = The driver, {0}, could not be instantiated.\nPlease ensure that the bookmark, {1}, is properly defined.
+
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
index c5ab79e..830e5ee 100644
--- 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
@@ -15,6 +15,7 @@ import com.quantum.sql.SQLResultSetResults;
import com.quantum.sql.SQLResults;
import com.quantum.sql.SQLUpdateResults;
import com.quantum.ui.dialog.ExceptionDisplayDialog;
+import com.quantum.ui.dialog.SQLExceptionDialog;
import com.quantum.ui.dialog.SimpleSelectionDialog;
import com.quantum.util.connection.ConnectionUtil;
import com.quantum.view.LogProxy;
@@ -22,17 +23,16 @@ 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;
+import org.eclipse.ui.actions.SelectionListenerAction;
/**
* @author BC
*/
-public abstract class BaseExecuteAction extends Action {
+public abstract class BaseExecuteAction extends SelectionListenerAction {
class Metrics {
int resultCount = 0;
@@ -81,6 +81,14 @@ public abstract class BaseExecuteAction extends Action {
String execute1 = Messages.getString(BaseExecuteAction.class, "execute1");
String execute2 = Messages.getString(BaseExecuteAction.class, "execute2");
+ protected BaseExecuteAction(String text) {
+ super(text);
+ }
+
+ protected BaseExecuteAction() {
+ super(null);
+ }
+
public void run() {
Bookmark bookmark = getBookmark();
if (bookmark != null) {
@@ -102,7 +110,7 @@ public abstract class BaseExecuteAction extends Action {
} catch (IOException e) {
ExceptionDisplayDialog.openError(getShell(), null, null, e);
} catch (SQLException e) {
- ExceptionDisplayDialog.openError(getShell(), null, null, e);
+ SQLExceptionDialog.openException(getShell(), bookmark, e);
} catch (CoreException e) {
ErrorDialog.openError(getShell(), null, null, e.getStatus());
}
@@ -197,9 +205,7 @@ public abstract class BaseExecuteAction extends Action {
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$
+ SQLExceptionDialog.openException(getShell(), bookmark, e);
}
return results;
}
diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/actions/DeleteAllRowsAction.java b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/actions/DeleteAllRowsAction.java
index 63e5979..439f8ad 100644
--- a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/actions/DeleteAllRowsAction.java
+++ b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/actions/DeleteAllRowsAction.java
@@ -6,6 +6,7 @@ import com.quantum.Messages;
import com.quantum.model.ConnectionException;
import com.quantum.model.Table;
import com.quantum.ui.dialog.ExceptionDisplayDialog;
+import com.quantum.ui.dialog.SQLExceptionDialog;
import com.quantum.view.bookmark.EntityNode;
import org.eclipse.jface.dialogs.MessageDialog;
@@ -30,8 +31,8 @@ public class DeleteAllRowsAction extends SelectionListenerAction {
}
public void run() {
+ Table table = getTable();
try {
- Table table = getTable();
if (table != null) {
boolean flag = MessageDialog.openConfirm(
view.getSite().getShell(),
@@ -43,9 +44,8 @@ public class DeleteAllRowsAction extends SelectionListenerAction {
}
}
} catch (SQLException e) {
- ExceptionDisplayDialog.openError(getShell(),
- Messages.getString("ExecuteAgainstAction.title"),
- Messages.getString("ExecuteAgainstAction.ConnectionException"), e);
+ SQLExceptionDialog.openException(getShell(),
+ table == null ? null : table.getBookmark(), e);
} catch (ConnectionException e) {
ExceptionDisplayDialog.openError(getShell(),
Messages.getString("ExecuteAgainstAction.title"),
diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/actions/DisconnectAction.java b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/actions/DisconnectAction.java
index 3860403..aa0ca9c 100644
--- a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/actions/DisconnectAction.java
+++ b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/actions/DisconnectAction.java
@@ -1,5 +1,6 @@
package com.quantum.actions;
+import java.sql.SQLException;
import java.util.Iterator;
import java.util.List;
import java.util.Vector;
@@ -7,7 +8,7 @@ import java.util.Vector;
import com.quantum.ImageStore;
import com.quantum.Messages;
import com.quantum.model.Bookmark;
-import com.quantum.model.ConnectionException;
+import com.quantum.ui.dialog.SQLExceptionDialog;
import com.quantum.view.bookmark.BookmarkNode;
import org.eclipse.jface.viewers.IStructuredSelection;
@@ -35,12 +36,13 @@ public class DisconnectAction extends SelectionListenerAction {
public void run() {
- for (Iterator i = this.selections.iterator(); i.hasNext();) {
+ for (Iterator i = this.selections.iterator(); i.hasNext(); ) {
Bookmark bookmark = (Bookmark) i.next();
try {
bookmark.disconnect();
- } catch (ConnectionException e) {
- e.printStackTrace();
+ } catch (SQLException e) {
+ SQLExceptionDialog.openException(
+ this.view.getViewSite().getShell(), bookmark, e);
}
}
updateStatusLine(getMessage("message"));
diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/actions/ExecuteAgainstAction.java b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/actions/ExecuteAgainstAction.java
index 0051eaf..0479ab8 100644
--- a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/actions/ExecuteAgainstAction.java
+++ b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/actions/ExecuteAgainstAction.java
@@ -32,7 +32,6 @@ public class ExecuteAgainstAction extends BaseExecuteAction
private IWorkbenchPart workbenchPart;
-
/**
* @see IObjectActionDelegate#setActivePart(IAction, IWorkbenchPart)
*/
diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/actions/NewBookmarkAction.java b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/actions/NewBookmarkAction.java
index 13ade29..106580d 100644
--- a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/actions/NewBookmarkAction.java
+++ b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/actions/NewBookmarkAction.java
@@ -19,7 +19,7 @@ public class NewBookmarkAction extends Action {
this.view = view;
setText(Messages.getString(getClass(), "text")); //$NON-NLS-1$
setToolTipText(Messages.getString(getClass(), "text")); //$NON-NLS-1$
- setImageDescriptor(ImageStore.getImageDescriptor(ImageStore.BOOKMARK));
+ setImageDescriptor(ImageStore.getImageDescriptor(ImageStore.NEW_BOOKMARK));
}
public void run() {
diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/actions/OpenQueryAction.java b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/actions/OpenQueryAction.java
index 8a78c6e..071b130 100644
--- a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/actions/OpenQueryAction.java
+++ b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/actions/OpenQueryAction.java
@@ -35,7 +35,8 @@ public class OpenQueryAction extends SelectionListenerAction {
private String getQuery() {
if (isEnabled()) {
QueryNode node = (QueryNode) getSelectedNonResources().get(0);
- return node.getQuery();
+ String query = node.getQuery();
+ return query == null || query.trim().endsWith(";") ? query : (query + ";");
} else {
return null;
}
diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/actions/RefreshBookmarkAction.java b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/actions/RefreshBookmarkAction.java
index 366644b..3250564 100644
--- a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/actions/RefreshBookmarkAction.java
+++ b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/actions/RefreshBookmarkAction.java
@@ -8,6 +8,7 @@ import com.quantum.ImageStore;
import com.quantum.Messages;
import com.quantum.model.NotConnectedException;
import com.quantum.ui.dialog.ExceptionDisplayDialog;
+import com.quantum.ui.dialog.SQLExceptionDialog;
import com.quantum.view.bookmark.TreeNode;
import org.eclipse.ui.IViewPart;
@@ -44,7 +45,12 @@ public class RefreshBookmarkAction extends SelectionListenerAction {
* @param e
*/
private void handleException(Throwable t) {
- ExceptionDisplayDialog.openError(
- this.view.getSite().getShell(), null, null, t);
+ if (t instanceof SQLException) {
+ SQLExceptionDialog.openException(
+ this.view.getSite().getShell(), null, (SQLException) t);
+ } else {
+ ExceptionDisplayDialog.openError(
+ this.view.getSite().getShell(), null, null, t);
+ }
}
}
diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/actions/ViewTableAction.java b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/actions/ViewTableAction.java
index 7975f0b..5bd627b 100644
--- a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/actions/ViewTableAction.java
+++ b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/actions/ViewTableAction.java
@@ -11,7 +11,7 @@ import com.quantum.sql.MultiSQLServer;
import com.quantum.sql.SQLResultSetCollection;
import com.quantum.sql.SQLResultSetResults;
import com.quantum.sql.SQLResults;
-import com.quantum.ui.dialog.ExceptionDisplayDialog;
+import com.quantum.ui.dialog.SQLExceptionDialog;
import com.quantum.util.connection.ConnectionUtil;
import com.quantum.view.bookmark.EntityNode;
@@ -53,7 +53,7 @@ public class ViewTableAction extends SelectionListenerAction {
SQLResultSetCollection.getInstance().addSQLResultSet((SQLResultSetResults) results);
}
} catch (SQLException e) {
- ExceptionDisplayDialog.openError(getShell(), null, null, e);
+ SQLExceptionDialog.openException(getShell(), bookmark, e);
}
}
diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/actions/ViewTableDetailsAction.java b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/actions/ViewTableDetailsAction.java
index 19d803c..80db996 100644
--- a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/actions/ViewTableDetailsAction.java
+++ b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/actions/ViewTableDetailsAction.java
@@ -12,6 +12,7 @@ import com.quantum.sql.MultiSQLServer;
import com.quantum.sql.SQLResultSetCollection;
import com.quantum.sql.SQLResultSetResults;
import com.quantum.ui.dialog.ExceptionDisplayDialog;
+import com.quantum.ui.dialog.SQLExceptionDialog;
import com.quantum.util.connection.ConnectionUtil;
import com.quantum.view.bookmark.EntityNode;
@@ -43,7 +44,8 @@ public class ViewTableDetailsAction extends SelectionListenerAction {
SQLResultSetCollection.getInstance().addSQLResultSet(results);
}
} catch (SQLException e) {
- ExceptionDisplayDialog.openError(getShell(), null, null, e);
+ SQLExceptionDialog.openException(getShell(),
+ entity == null ? null : entity.getBookmark(), e);
}
}
}
diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/editors/ColorManager.java b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/editors/ColorManager.java
index a7a662c..6b12a99 100644
--- a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/editors/ColorManager.java
+++ b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/editors/ColorManager.java
@@ -10,18 +10,19 @@ import org.eclipse.swt.widgets.Display;
public class ColorManager {
- protected Map fColorTable = new HashMap(10);
+ protected Map colorTable = new HashMap(10);
public void dispose() {
- Iterator e= fColorTable.values().iterator();
- while (e.hasNext())
+ Iterator e= this.colorTable.values().iterator();
+ while (e.hasNext()) {
((Color) e.next()).dispose();
+ }
}
public Color getColor(RGB rgb) {
- Color color= (Color) fColorTable.get(rgb);
+ Color color= (Color) colorTable.get(rgb);
if (color == null) {
color= new Color(Display.getCurrent(), rgb);
- fColorTable.put(rgb, color);
+ this.colorTable.put(rgb, color);
}
return color;
}
diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/editors/SQLColorConstants.java b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/editors/SQLColorConstants.java
index ae519bf..21557d2 100644
--- a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/editors/SQLColorConstants.java
+++ b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/editors/SQLColorConstants.java
@@ -2,7 +2,7 @@ package com.quantum.editors;
import org.eclipse.swt.graphics.RGB;
-public class SQLColorConstants {
+class SQLColorConstants {
public static RGB BACKGROUND = new RGB(255, 0, 255);
public static RGB COMMENT = new RGB(88, 148, 64);
public static RGB IDENTIFIER = new RGB(0, 0, 0);
diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/editors/SQLSourceViewerConfiguration.java b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/editors/SQLSourceViewerConfiguration.java
index 8582103..9ebc7b3 100644
--- a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/editors/SQLSourceViewerConfiguration.java
+++ b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/editors/SQLSourceViewerConfiguration.java
@@ -2,6 +2,7 @@ package com.quantum.editors;
import java.util.HashMap;
+import com.quantum.PluginPreferences;
import com.quantum.QuantumPlugin;
import org.eclipse.jface.preference.IPreferenceStore;
@@ -49,13 +50,13 @@ public class SQLSourceViewerConfiguration extends SourceViewerConfiguration {
stringBold = store.getBoolean("quantum.string.bold"); //$NON-NLS-1$
commentBold = store.getBoolean("quantum.comment.bold"); //$NON-NLS-1$
numericBold = store.getBoolean("quantum.numeric.bold"); //$NON-NLS-1$
- SQLColorConstants.BACKGROUND = PreferenceConverter.getColor(store, "quantum.background.color"); //$NON-NLS-1$
- SQLColorConstants.DEFAULT = PreferenceConverter.getColor(store, "quantum.text.color"); //$NON-NLS-1$
- SQLColorConstants.IDENTIFIER = PreferenceConverter.getColor(store, "quantum.text.color"); //$NON-NLS-1$
- SQLColorConstants.KEYWORD = PreferenceConverter.getColor(store, "quantum.keyword.color"); //$NON-NLS-1$
- SQLColorConstants.STRING = PreferenceConverter.getColor(store, "quantum.string.color"); //$NON-NLS-1$
- SQLColorConstants.COMMENT = PreferenceConverter.getColor(store, "quantum.comment.color"); //$NON-NLS-1$
- SQLColorConstants.NUMERIC = PreferenceConverter.getColor(store, "quantum.numeric.color"); //$NON-NLS-1$
+ SQLColorConstants.BACKGROUND = PreferenceConverter.getColor(store, PluginPreferences.BACKGROUND_COLOR); //$NON-NLS-1$
+ SQLColorConstants.DEFAULT = PreferenceConverter.getColor(store, PluginPreferences.TEXT_COLOR); //$NON-NLS-1$
+ SQLColorConstants.IDENTIFIER = PreferenceConverter.getColor(store, PluginPreferences.TEXT_COLOR); //$NON-NLS-1$
+ SQLColorConstants.KEYWORD = PreferenceConverter.getColor(store, PluginPreferences.KEYWORD_COLOR); //$NON-NLS-1$
+ SQLColorConstants.STRING = PreferenceConverter.getColor(store, PluginPreferences.STRING_COLOR); //$NON-NLS-1$
+ SQLColorConstants.COMMENT = PreferenceConverter.getColor(store, PluginPreferences.COMMENT_COLOR); //$NON-NLS-1$
+ SQLColorConstants.NUMERIC = PreferenceConverter.getColor(store, PluginPreferences.NUMERIC_COLOR); //$NON-NLS-1$
}
public void initializeColors() {
setDamageRepairer(getAttr(SQLColorConstants.KEYWORD, keywordBold), SQLPartitionScanner.SQL_KEYWORD);
diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/model/Bookmark.java b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/model/Bookmark.java
index 4b42669..8b3feef 100644
--- a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/model/Bookmark.java
+++ b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/model/Bookmark.java
@@ -57,6 +57,7 @@ public class Bookmark implements Displayable {
private boolean promptForPassword = false;
private boolean autoCommit = true;
private String autoCommitPreference = IQuantumConstants.autoCommitTrue;
+ private Database database;
public Bookmark() {
this(MultiSQLServer.getInstance());
@@ -239,7 +240,7 @@ public class Bookmark implements Displayable {
this.connection = connection;
}
- public void disconnect() throws ConnectionException {
+ public void disconnect() throws SQLException {
boolean isConnected = isConnected();
try {
if (this.connection != null) {
@@ -247,6 +248,7 @@ public class Bookmark implements Displayable {
}
} finally {
this.connection = null;
+ this.database = null;
if (isConnected() != isConnected) {
this.propertyChangeSupport.firePropertyChange(
"connected", isConnected, isConnected());
@@ -398,7 +400,10 @@ public class Bookmark implements Displayable {
if (!isConnected()) {
throw new NotConnectedException();
}
- return new Database(this);
+ if (this.database == null) {
+ this.database = new Database(this);
+ }
+ return this.database;
}
public DatabaseAdapter getAdapter() {
@@ -545,4 +550,14 @@ public class Bookmark implements Displayable {
public String getDisplayName() {
return this.name;
}
+
+ /**
+ * @param query
+ */
+ public void removeQuery(String query) {
+ if (this.queries.remove(query)) {
+ this.propertyChangeSupport.firePropertyChange("queries", null, null);
+ this.changed = true;
+ }
+ }
}
diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/model/DataType.java b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/model/DataType.java
index 2eb26a0..9640df1 100644
--- a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/model/DataType.java
+++ b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/model/DataType.java
@@ -11,10 +11,30 @@ import com.quantum.util.sql.TypesHelper;
public class DataType {
private final int javaType;
private final String databaseTypeName;
+ private final int precision;
+ private final String literalPrefix;
+ private final String literalSuffix;
+ private final String createParameters;
- public DataType(int javaType, String databaseTypeName) {
+
+ /**
+ * @param javaType
+ * @param databaseTypeName
+ * @param precision
+ * @param literalPrefix
+ * @param literalSuffix
+ * @param createParameters
+ */
+ public DataType(final int javaType, final String databaseTypeName,
+ final int precision, final String literalPrefix, final String literalSuffix,
+ final String createParameters) {
+ super();
this.javaType = javaType;
this.databaseTypeName = databaseTypeName;
+ this.precision = precision;
+ this.literalPrefix = literalPrefix;
+ this.literalSuffix = literalSuffix;
+ this.createParameters = createParameters;
}
public String getDatabaseTypeName() {
return this.databaseTypeName;
@@ -25,4 +45,16 @@ public class DataType {
public String getJavaNameType() {
return TypesHelper.getTypeName(this.javaType);
}
+ public String getCreateParameters() {
+ return this.createParameters;
+ }
+ public String getLiteralPrefix() {
+ return this.literalPrefix;
+ }
+ public String getLiteralSuffix() {
+ return this.literalSuffix;
+ }
+ public int getPrecision() {
+ return this.precision;
+ }
}
diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/model/Database.java b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/model/Database.java
index cdc3501..058c48d 100644
--- a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/model/Database.java
+++ b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/model/Database.java
@@ -5,6 +5,7 @@ import java.sql.DatabaseMetaData;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
@@ -36,10 +37,16 @@ public class Database {
private static final int TYPE_INFO_METADATA_TYPE_NAME = 1;
private static final int TYPE_INFO_METADATA_DATA_TYPE = 2;
+ private static final int TYPE_INFO_METADATA_PRECISION = 3;
+ private static final int TYPE_INFO_METADATA_LITERAL_PREFIX = 4;
+ private static final int TYPE_INFO_METADATA_LITERAL_SUFFIX = 5;
+ private static final int TYPE_INFO_METADATA_CREATE_PARMS = 6;
private DatabaseAdapter databaseAdapter;
private Bookmark bookmark;
+ private List entityTypes;
+
public Database(Bookmark bookmark) {
this.bookmark = bookmark;
this.databaseAdapter = bookmark.getAdapter();
@@ -61,9 +68,13 @@ public class Database {
}
}
- public String[] getEntityTypes()
+ public synchronized String[] getEntityTypes()
throws NotConnectedException, SQLException {
- return getEntityTypes(this.bookmark.getConnection());
+ if (this.entityTypes == null) {
+ Collection collection = initializeEntityTypes(this.bookmark.getConnection());
+ this.entityTypes = Collections.synchronizedList(new ArrayList(collection));
+ }
+ return (String[]) this.entityTypes.toArray(new String[this.entityTypes.size()]);
}
public String getUsername() throws NotConnectedException, SQLException {
@@ -72,7 +83,7 @@ public class Database {
/**
- * This method returns a list of entity types supported by the database
+ *
This method returns a set of entity types supported by the database
* adapter. This list will always be limited to Tables, Views and
* Sequences.
*
@@ -81,10 +92,10 @@ public class Database {
* Tables, Views and Sequences.
*
* @param connection
- * @return
+ * @return a set of Strings, typically "TABLE", "VIEW", and "SEQUENCE"
* @throws SQLException
*/
- public String[] getEntityTypes(Connection connection) throws SQLException {
+ private Set initializeEntityTypes(Connection connection) throws SQLException {
Set set = new HashSet();
if (this.databaseAdapter.getShowTableQuery(this.bookmark.getUsername()) != null) {
@@ -107,8 +118,7 @@ public class Database {
set.add(type);
}
}
-
- return (String[]) set.toArray(new String[set.size()]);
+ return set;
}
public String getInformation() throws SQLException {
@@ -165,30 +175,8 @@ public class Database {
protected List getEntitiesList(Bookmark bookmark, Connection connection, String type, Schema schema)
throws SQLException {
- String sql = getSQL(bookmark, type, schema);
List list = new ArrayList();
- SQLResultSetResults results = null;
- if (sql != null) {
- results = (SQLResultSetResults) MultiSQLServer.getInstance().execute(
- bookmark, connection, sql, Integer.MAX_VALUE);
- for (int i = 1, size = (results == null) ? 0 : results.getRowCount(); i <= size; i++) {
- String schemaName = results.getColumnCount() == 1
- ? schema.getName() : results.getElement(1, i).toString();
- String tableName = results.getColumnCount() == 1
- ? results.getElement(1, i).toString()
- : results.getElement(2, i).toString();
- if (tableName != null && tableName.length() > 0) {
- Entity entity = EntityFactory.getInstance().create(
- bookmark, schemaName, tableName, type);
- if (entity != null) {
- list.add(entity);
- }
- }
- }
- }
- // If we have some results, we go back
- if (results != null) return list;
- // Else, we try the JDBC driver
+ // We try first the JDBC driver
DatabaseMetaData metaData = connection.getMetaData();
// getTables needs a null schema to get all the schemas. So we don't pass a "" schema, but a null one
ResultSet set = null;
@@ -212,6 +200,38 @@ public class Database {
}
}
set.close();
+ // If we have some results, then the JDBC driver is working,
+ // so we return the results and quit
+ if (list.size() > 0)
+ return list;
+
+
+ // If no results, we check also the sql query to get the list of entities
+ SQLResultSetResults results = null;
+ // Get the proper sql query to the appropiate type of entity
+ String sql = getSQL(bookmark, type, schema);
+ // If nothing returned, too bad, it seems there is no sql query for that database and entity type
+ if (sql != null) {
+ results = (SQLResultSetResults) MultiSQLServer.getInstance().execute(
+ bookmark, connection, sql, Integer.MAX_VALUE);
+ for (int i = 1, size = (results == null) ? 0 : results.getRowCount(); i <= size; i++) {
+ String schemaName = results.getColumnCount() == 1
+ ? schema.getName() : results.getElement(1, i).toString();
+ if (schemaName != null) {
+ schemaName = schemaName.trim();
+ }
+ String tableName = results.getColumnCount() == 1
+ ? results.getElement(1, i).toString()
+ : results.getElement(2, i).toString();
+ if (tableName != null && tableName.length() > 0) {
+ Entity entity = EntityFactory.getInstance().create(
+ bookmark, schemaName, tableName, type);
+ if (entity != null) {
+ list.add(entity);
+ }
+ }
+ }
+ }
return list;
}
@@ -221,9 +241,14 @@ public class Database {
ResultSet results = metaData.getTypeInfo();
try {
while (results.next()) {
- String name = results.getString(TYPE_INFO_METADATA_TYPE_NAME);
- int type = results.getInt(TYPE_INFO_METADATA_DATA_TYPE);
- list.add(new DataType(type, name));
+ list.add(new DataType(
+ results.getInt(TYPE_INFO_METADATA_DATA_TYPE),
+ results.getString(TYPE_INFO_METADATA_TYPE_NAME),
+ results.getInt(TYPE_INFO_METADATA_PRECISION),
+ results.getString(TYPE_INFO_METADATA_LITERAL_PREFIX),
+ results.getString(TYPE_INFO_METADATA_LITERAL_SUFFIX),
+ results.getString(TYPE_INFO_METADATA_CREATE_PARMS)
+ ));
}
} finally {
results.close();
@@ -313,15 +338,18 @@ public class Database {
public Schema[] getSchemas() throws NotConnectedException, SQLException {
DatabaseMetaData metaData = getMetaData();
List list = new ArrayList();
- ResultSet resultSet = metaData.getSchemas();
- try {
- while (resultSet.next()) {
- String schemaName = resultSet.getString("TABLE_SCHEM");
- list.add(new Schema(schemaName));
+
+ if (metaData.supportsSchemasInTableDefinitions()) {
+ ResultSet resultSet = metaData.getSchemas();
+ try {
+ while (resultSet.next()) {
+ String schemaName = resultSet.getString("TABLE_SCHEM");
+ list.add(new Schema(schemaName));
+ }
+ } finally {
+ resultSet.close();
}
- return (Schema[]) list.toArray(new Schema[list.size()]);
- } finally {
- resultSet.close();
}
+ return (Schema[]) list.toArray(new Schema[list.size()]);
}
}
diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/model/Entity.java b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/model/Entity.java
index c911730..66632cc 100644
--- a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/model/Entity.java
+++ b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/model/Entity.java
@@ -2,16 +2,14 @@ package com.quantum.model;
import java.sql.SQLException;
-import com.quantum.IQuantumConstants;
-
/**
* @author BC
*/
public interface Entity extends BookmarkHolder, Comparable {
- public static final String TABLE_TYPE = IQuantumConstants.Table;
- public static final String VIEW_TYPE = IQuantumConstants.View;
- public static final String SEQUENCE_TYPE = IQuantumConstants.Sequence;
+ public static final String TABLE_TYPE = "TABLE";
+ public static final String VIEW_TYPE = "VIEW";
+ public static final String SEQUENCE_TYPE = "SEQUENCE";
public String getName();
public String getSchema();
diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/model/EntityImpl.java b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/model/EntityImpl.java
index f16a1e0..966329a 100644
--- a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/model/EntityImpl.java
+++ b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/model/EntityImpl.java
@@ -11,7 +11,11 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import com.quantum.adapters.AdapterFactory;
import com.quantum.adapters.DatabaseAdapter;
+import com.quantum.sql.MultiSQLServer;
+import com.quantum.sql.SQLMetaDataResults;
+import com.quantum.util.sql.SQLStates;
/**
* This class models a table or view.
@@ -81,54 +85,103 @@ abstract class EntityImpl implements Entity {
}
public Column[] getColumns() throws NotConnectedException, SQLException {
- Map temp = new HashMap();
Connection connection = this.bookmark.getConnection();
- DatabaseMetaData metaData = connection.getMetaData();
- ResultSet resultSet = metaData.getColumns(null, getSchema(), getName(), null);
try {
- while (resultSet.next()) {
- ColumnImpl column = new ColumnImpl(
- this,
- resultSet.getString(COLUMN_METADATA_COLUMN_NAME),
- resultSet.getString(COLUMN_METATDATA_TYPE_NAME),
- resultSet.getInt(COLUMN_METATDATA_DATA_TYPE),
- resultSet.getInt(COLUMN_METADATA_COLUMN_SIZE),
- resultSet.getInt(COLUMN_METADATA_DECIMAL_DIGITS),
- "YES".equalsIgnoreCase(resultSet.getString(COLUMN_METADATA_IS_NULLABLE)),
- resultSet.getInt(COLUMN_METADATA_ORDINAL_POSITION),
+ return getColumnsFromMetaData(connection);
+ } catch (SQLException e) {
+ if (SQLStates.ODBC_DRIVER_NOT_CAPABLE.equals(e.getSQLState())
+ && AdapterFactory.JDBC_ODBC_BRIDGE.equals(
+ getBookmark().getJDBCDriver().getType())) {
+ return getColumnsFromQuery(connection);
+ } else {
+ throw e;
+ }
+ }
+
+ }
+
+ /**
+ * @param connection
+ * @return
+ * @throws SQLException
+ */
+ private Column[] getColumnsFromMetaData(Connection connection) throws SQLException {
+ Map temp = new HashMap();
+ DatabaseMetaData metaData = connection.getMetaData();
+ ResultSet resultSet = metaData.getColumns(null, getSchema(), getName(), null);
+ try {
+ while (resultSet.next()) {
+ ColumnImpl column = new ColumnImpl(
+ this,
+ resultSet.getString(COLUMN_METADATA_COLUMN_NAME),
+ resultSet.getString(COLUMN_METATDATA_TYPE_NAME),
+ resultSet.getInt(COLUMN_METATDATA_DATA_TYPE),
+ resultSet.getInt(COLUMN_METADATA_COLUMN_SIZE),
+ resultSet.getInt(COLUMN_METADATA_DECIMAL_DIGITS),
+ "YES".equalsIgnoreCase(resultSet.getString(COLUMN_METADATA_IS_NULLABLE)),
+ resultSet.getInt(COLUMN_METADATA_ORDINAL_POSITION),
getComments(
resultSet.getString(COLUMN_METADATA_REMARKS),
getQualifiedName(),
resultSet.getString(COLUMN_METADATA_COLUMN_NAME))
- );
- temp.put(column.getName(), column);
- }
- } finally {
- resultSet.close();
- }
+ );
+ temp.put(column.getName(), column);
+ }
+ } finally {
+ resultSet.close();
+ }
- resultSet = metaData.getPrimaryKeys(null, getSchema(), getName());
- try {
- while (resultSet.next()) {
- String name = resultSet.getString(PRIMARY_KEYS_METADATA_COLUMN_NAME);
- short keySequence = resultSet.getShort(PRIMARY_KEYS_METADATA_KEY_SEQ);
- ColumnImpl column = (ColumnImpl) temp.get(name);
- if (column != null) {
- column.setPrimaryKeyOrder(keySequence);
- }
- }
- resultSet.close();
-
- List columnList = Collections.synchronizedList(
- new ArrayList(temp.values()));
- Collections.sort(columnList);
- return (Column[]) columnList.toArray(new Column[columnList.size()]);
- } finally {
- resultSet.close();
- }
- }
-
- /**
+ resultSet = metaData.getPrimaryKeys(null, getSchema(), getName());
+ try {
+ while (resultSet.next()) {
+ String name = resultSet.getString(PRIMARY_KEYS_METADATA_COLUMN_NAME);
+ short keySequence = resultSet.getShort(PRIMARY_KEYS_METADATA_KEY_SEQ);
+ ColumnImpl column = (ColumnImpl) temp.get(name);
+ if (column != null) {
+ column.setPrimaryKeyOrder(keySequence);
+ }
+
+ }
+
+ List columnList = Collections.synchronizedList(
+ new ArrayList(temp.values()));
+ Collections.sort(columnList);
+ return (Column[]) columnList.toArray(new Column[columnList.size()]);
+
+ } finally {
+ resultSet.close();
+ }
+ }
+
+ /**
+ * Some databases, (in particular, MS Access under ODBC) aren't terribly friendly
+ * about supporting metadata. This method scrapes out the data the old-fashioned way.
+ *
+ * @param temp
+ * @param connection
+ * @throws SQLException
+ */
+ private Column[] getColumnsFromQuery(Connection connection) throws SQLException {
+ List temp = new ArrayList();
+ SQLMetaDataResults results =
+ (SQLMetaDataResults) MultiSQLServer.getInstance().getMetaData(
+ this, connection);
+ SQLMetaDataResults.Row[] rows = results.getRows();
+ for (int i = 0, length = results.getRowCount(); i < length; i++) {
+ ColumnImpl column = new ColumnImpl(
+ this,
+ (String) rows[i].get(1),
+ (String) rows[i].get(2),
+ ((Integer) rows[i].get(7)).intValue(),
+ ((Integer) rows[i].get(3)).intValue(),
+ ((Integer) rows[i].get(4)).intValue(),
+ "Nullable".equalsIgnoreCase((String) rows[i].get(5)),
+ i+1, "");
+ temp.add(column);
+ }
+ return (Column[]) temp.toArray(new Column[temp.size()]);
+ }
+ /**
* Some JDBC drivers (Oracle for example) won't return the comments
* We recheck with a custom query, if it's defined
* @param iniComment The already got comment
diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/preferences/GlobalPreferences.java b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/preferences/GlobalPreferences.java
index 01c9eb6..079ca43 100644
--- a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/preferences/GlobalPreferences.java
+++ b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/preferences/GlobalPreferences.java
@@ -1,15 +1,14 @@
package com.quantum.preferences;
-import com.quantum.Messages;
-import com.quantum.QuantumPlugin;
-
import org.eclipse.jface.preference.FieldEditorPreferencePage;
-import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.preference.IntegerFieldEditor;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPreferencePage;
+import com.quantum.Messages;
+import com.quantum.QuantumPlugin;
+
/**
* PreferencePage for the global options on QuantumDB
* @author panic
@@ -21,19 +20,12 @@ implements IWorkbenchPreferencePage {
public GlobalPreferences() {
super(FieldEditorPreferencePage.GRID);
-
- // Set the preference store for the preference page.
- IPreferenceStore store =
- QuantumPlugin.getDefault().getPreferenceStore();
- setPreferenceStore(store);
+ setPreferenceStore(QuantumPlugin.getDefault().getPreferenceStore());
}
public void init(IWorkbench workbench) {
- this.workbench = workbench;
}
- IWorkbench workbench;
-
protected void createFieldEditors() {
IntegerFieldEditor queryHistorySize = new IntegerFieldEditor(
"com.quantum.model.Bookmark.queryHistorySize",
diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/preferences/SQLEditorPreferences.java b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/preferences/SQLEditorPreferences.java
index daf8164..ec0c7e1 100644
--- a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/preferences/SQLEditorPreferences.java
+++ b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/preferences/SQLEditorPreferences.java
@@ -1,93 +1,74 @@
package com.quantum.preferences;
-
import com.quantum.Messages;
+import com.quantum.PluginPreferences;
import com.quantum.QuantumPlugin;
-import com.quantum.editors.ColorManager;
-import com.quantum.editors.SQLColorConstants;
import com.quantum.util.versioning.VersioningHelper;
import org.eclipse.jface.preference.ColorFieldEditor;
-import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.preference.PreferenceConverter;
import org.eclipse.jface.preference.PreferencePage;
-import org.eclipse.jface.resource.JFaceResources;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.graphics.FontData;
-import org.eclipse.swt.graphics.RGB;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.FontDialog;
+import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPreferencePage;
-public class SQLEditorPreferences extends PreferencePage
- implements IWorkbenchPreferencePage {
- FontDialog fontDialog;
- ColorFieldEditor backgroundColorEditor;
+
+/**
+ * A preference page for font and colour preferences for the SQL
+ * Editor.
+ *
+ * @author Tom Schneider
+ */
+public class SQLEditorPreferences extends PreferencePage
+ implements IWorkbenchPreferencePage {
+
+ private FontDialog fontDialog;
+
+ private ColorFieldEditor backgroundColorEditor;
+ private ColorFieldEditor textColorEditor;
+ private ColorFieldEditor keywordColorEditor;
+ private ColorFieldEditor stringColorEditor;
+ private ColorFieldEditor numericColorEditor;
+ private ColorFieldEditor commentColorEditor;
+
+ private boolean textFlag;
+ private boolean keywordFlag;
+ private boolean stringFlag;
+ private boolean numericFlag;
+ private boolean commentFlag;
- ColorFieldEditor textColorEditor;
- boolean textFlag;
- ColorFieldEditor keywordColorEditor;
- boolean keywordFlag;
- ColorFieldEditor stringColorEditor;
- boolean stringFlag;
- ColorFieldEditor numericColorEditor;
- boolean numericFlag;
- ColorFieldEditor commentColorEditor;
- boolean commentFlag;
+ private Button boldText;
+ private Button boldKeyword;
+ private Button boldString;
+ private Button boldNumeric;
+ private Button boldComment;
- Button boldText;
- Button boldKeyword;
- Button boldString;
- Button boldNumeric;
- Button boldComment;
+ private FontData fontData;
+ private Label fontDisplay;
- IWorkbench workbench;
- FontData fontData;
- Label fontDisplay;
public void init(IWorkbench workbench) {
- //Initialize the preference store
- this.workbench = workbench;
setPreferenceStore(QuantumPlugin.getDefault().getPreferenceStore());
- initializeColorDefaults(getPreferenceStore());
- }
-
- private void initializeColorDefaults(IPreferenceStore store) {
- RGB BACKGROUND = new RGB(255, 255, 255);
- RGB COMMENT = new RGB(88, 148, 64);
- RGB KEYWORD = new RGB(126, 0, 75);
- RGB STRING = new RGB(0, 0, 255);
- RGB NUMERIC = new RGB(255, 0, 0);
- RGB DEFAULT = new RGB(0, 0, 0);
- PreferenceConverter.setDefault(store,
- "quantum.background.color", BACKGROUND); //$NON-NLS-1$
- PreferenceConverter.setDefault(store,
- "quantum.text.color", DEFAULT); //$NON-NLS-1$
- PreferenceConverter.setDefault(store,
- "quantum.keyword.color", KEYWORD); //$NON-NLS-1$
- PreferenceConverter.setDefault(store,
- "quantum.comment.color", COMMENT); //$NON-NLS-1$
- PreferenceConverter.setDefault(store,
- "quantum.string.color", STRING); //$NON-NLS-1$
- PreferenceConverter.setDefault(store,
- "quantum.numeric.color", NUMERIC); //$NON-NLS-1$
}
protected void performDefaults() {
- fontData = null;
+ fontData = PluginPreferences.getDefaultFont();
updateFontDisplay();
- textFlag = false;
- keywordFlag = true;
- stringFlag = false;
- numericFlag = false;
- commentFlag = false;
+ this.textFlag = false;
+ this.keywordFlag = true;
+ this.stringFlag = false;
+ this.numericFlag = false;
+ this.commentFlag = false;
updateFlags();
backgroundColorEditor.loadDefault();
textColorEditor.loadDefault();
@@ -114,87 +95,62 @@ public class SQLEditorPreferences extends PreferencePage
numericColorEditor.store();
return super.performOk();
}
+
protected Control createContents(Composite parent) {
Composite main = new Composite(parent, SWT.NULL);
+ main.setLayout(new GridLayout());
- GridLayout innerLayout = new GridLayout();
- innerLayout.numColumns = 4;
- main.setLayout(innerLayout);
+ createFontSelectionArea(main);
+ Label label = new Label(main, SWT.NONE);
+ label.setText("");
+
+ createColorSelectionArea(main);
- fontData = PreferenceConverter.getFontData(getPreferenceStore(), "quantum.font"); //$NON-NLS-1$
- textFlag = getPreferenceStore().getBoolean("quantum.text.bold"); //$NON-NLS-1$
- keywordFlag = getPreferenceStore().getBoolean("quantum.keyword.bold"); //$NON-NLS-1$
- stringFlag = getPreferenceStore().getBoolean("quantum.string.bold"); //$NON-NLS-1$
- commentFlag = getPreferenceStore().getBoolean("quantum.comment.bold"); //$NON-NLS-1$
- numericFlag = getPreferenceStore().getBoolean("quantum.numeric.bold"); //$NON-NLS-1$
-
- fontDialog = new FontDialog(workbench.getActiveWorkbenchWindow().getShell());
- Button fontButton = new Button(main, SWT.PUSH);
- fontButton.setText(Messages.getString("PreferencesPage.PickFont")); //$NON-NLS-1$
- fontButton.addSelectionListener(new SelectionListener() {
- public void widgetDefaultSelected(SelectionEvent e) {
- }
- public void widgetSelected(SelectionEvent e) {
- if (fontData != null) {
- VersioningHelper.setFont(fontDialog, new FontData[] { fontData} );
- }
- FontData data = fontDialog.open();
- if (data != null) {
- fontData = data;
- updateFontDisplay();
- }
- }
- });
- Button defaultButton = new Button(main, SWT.PUSH);
- defaultButton.setText(Messages.getString("PreferencesPage.DefaultFont")); //$NON-NLS-1$
- defaultButton.addSelectionListener(new SelectionListener() {
- public void widgetDefaultSelected(SelectionEvent e) {
- }
- public void widgetSelected(SelectionEvent e) {
- FontData[] temp = JFaceResources.getTextFont().getFontData();
- fontData = temp == null || temp.length == 0 ? null : temp[0];
- updateFontDisplay();
- }
- });
-
- fontDisplay = new Label(main, SWT.NULL);
- GridData data = new GridData(GridData.FILL_HORIZONTAL);
- data.grabExcessHorizontalSpace = true;
- fontDisplay.setLayoutData(data);
- updateFontDisplay();
-
- ColorManager manager = new ColorManager();
+ return main;
+ }
+ /**
+ * @param main
+ * @return
+ */
+ private void createColorSelectionArea(Composite parent) {
+ Composite main = new Composite(parent, SWT.NULL);
- Composite comp = new Composite(main, SWT.NULL);
- GridData layoutData = new GridData();
- layoutData.horizontalSpan = 2;
- comp.setLayoutData(layoutData);
+ this.textFlag = getPreferenceStore().getBoolean("quantum.text.bold"); //$NON-NLS-1$
+ this.keywordFlag = getPreferenceStore().getBoolean("quantum.keyword.bold"); //$NON-NLS-1$
+ this.stringFlag = getPreferenceStore().getBoolean("quantum.string.bold"); //$NON-NLS-1$
+ this.commentFlag = getPreferenceStore().getBoolean("quantum.comment.bold"); //$NON-NLS-1$
+ this.numericFlag = getPreferenceStore().getBoolean("quantum.numeric.bold"); //$NON-NLS-1$
+
+
+ GridLayout layout = new GridLayout();
+
+ // the colour preference chooser really, really wants to take up a whole
+ // row, so we need to pretend that our row is only two cells wide, then
+ // pull a switcheroo later...
+ layout.numColumns = 2;
+ main.setLayout(layout);
- manager.getColor(SQLColorConstants.DEFAULT);
backgroundColorEditor =
new ColorFieldEditor(
- "quantum.background.color", //$NON-NLS-1$
- Messages.getString("PreferencesPage.BackgroundColor"), //$NON-NLS-1$
- comp);
+ PluginPreferences.BACKGROUND_COLOR,
+ Messages.getString(getClass(), "backgroundColor"), //$NON-NLS-1$
+ main);
- Composite temp = new Composite(main, SWT.NULL);
- temp.setSize(0, 0);
+ Label emptyLabel = new Label(main, SWT.NULL);
+ emptyLabel.setText("");
- comp = new Composite(main, SWT.NULL);
- layoutData = new GridData();
- layoutData.horizontalSpan = 2;
- comp.setLayoutData(layoutData);
+ createEmptyRow(main);
- textColorEditor =
+ this.textColorEditor =
new ColorFieldEditor(
- "quantum.text.color", //$NON-NLS-1$
- Messages.getString("PreferencesPage.DefaultTextColor"), //$NON-NLS-1$
- comp);
+ PluginPreferences.TEXT_COLOR,
+ Messages.getString(getClass(), "defaultTextColor"), //$NON-NLS-1$
+ main);
- boldText = new Button(main, SWT.CHECK);
- boldText.setSelection(textFlag);
- boldText.setText(Messages.getString("PreferencesPage.Bold")); //$NON-NLS-1$
- boldText.addSelectionListener(new SelectionListener() {
+ this.boldText = new Button(main, SWT.CHECK);
+ this.boldText.setSelection(textFlag);
+ this.boldText.setText(Messages.getString(getClass(), "bold")); //$NON-NLS-1$
+ this.boldText.addSelectionListener(new SelectionListener() {
public void widgetDefaultSelected(SelectionEvent e) {
}
public void widgetSelected(SelectionEvent e) {
@@ -202,20 +158,15 @@ public class SQLEditorPreferences extends PreferencePage
}
});
- comp = new Composite(main, SWT.NULL);
- layoutData = new GridData();
- layoutData.horizontalSpan = 2;
- comp.setLayoutData(layoutData);
-
keywordColorEditor =
new ColorFieldEditor(
- Messages.getString("PreferencesPage.quantum.keyword.color_26"), //$NON-NLS-1$
- Messages.getString("PreferencesPage.KeywordTextColor"), //$NON-NLS-1$
- comp);
+ PluginPreferences.KEYWORD_COLOR,
+ Messages.getString(getClass(), "keywordTextColor"), //$NON-NLS-1$
+ main);
boldKeyword = new Button(main, SWT.CHECK);
boldKeyword.setSelection(keywordFlag);
- boldKeyword.setText(Messages.getString("PreferencesPage.Bold")); //$NON-NLS-1$
+ boldKeyword.setText(Messages.getString(getClass(), "bold")); //$NON-NLS-1$
boldKeyword.addSelectionListener(new SelectionListener() {
public void widgetDefaultSelected(SelectionEvent e) {
}
@@ -224,20 +175,15 @@ public class SQLEditorPreferences extends PreferencePage
}
});
- comp = new Composite(main, SWT.NULL);
- layoutData = new GridData();
- layoutData.horizontalSpan = 2;
- comp.setLayoutData(layoutData);
-
commentColorEditor =
new ColorFieldEditor(
- "quantum.comment.color", //$NON-NLS-1$
- Messages.getString("PreferencesPage.CommentTextColor"), //$NON-NLS-1$
- comp);
+ PluginPreferences.COMMENT_COLOR,
+ Messages.getString(getClass(), "commentTextColor"), //$NON-NLS-1$
+ main);
boldComment = new Button(main, SWT.CHECK);
boldComment.setSelection(commentFlag);
- boldComment.setText(Messages.getString("PreferencesPage.Bold")); //$NON-NLS-1$
+ boldComment.setText(Messages.getString(getClass(), "bold")); //$NON-NLS-1$
boldComment.addSelectionListener(new SelectionListener() {
public void widgetDefaultSelected(SelectionEvent e) {
}
@@ -246,20 +192,15 @@ public class SQLEditorPreferences extends PreferencePage
}
});
- comp = new Composite(main, SWT.NULL);
- layoutData = new GridData();
- layoutData.horizontalSpan = 2;
- comp.setLayoutData(layoutData);
-
stringColorEditor =
new ColorFieldEditor(
- "quantum.string.color", //$NON-NLS-1$
- Messages.getString("PreferencesPage.StringTextColor"), //$NON-NLS-1$
- comp);
+ PluginPreferences.STRING_COLOR,
+ Messages.getString(getClass(), "stringTextColor"), //$NON-NLS-1$
+ main);
boldString = new Button(main, SWT.CHECK);
boldString.setSelection(stringFlag);
- boldString.setText(Messages.getString("PreferencesPage.Bold")); //$NON-NLS-1$
+ boldString.setText(Messages.getString(getClass(), "bold")); //$NON-NLS-1$
boldString.addSelectionListener(new SelectionListener() {
public void widgetDefaultSelected(SelectionEvent e) {
}
@@ -268,20 +209,15 @@ public class SQLEditorPreferences extends PreferencePage
}
});
- comp = new Composite(main, SWT.NULL);
- layoutData = new GridData();
- layoutData.horizontalSpan = 2;
- comp.setLayoutData(layoutData);
-
numericColorEditor =
new ColorFieldEditor(
- "quantum.numeric.color", //$NON-NLS-1$
- Messages.getString("PreferencesPage.NumericTextColor"), //$NON-NLS-1$
- comp);
+ PluginPreferences.NUMERIC_COLOR,
+ Messages.getString(getClass(), "numericTextColor"), //$NON-NLS-1$
+ main);
boldNumeric = new Button(main, SWT.CHECK);
boldNumeric.setSelection(numericFlag);
- boldNumeric.setText(Messages.getString("PreferencesPage.Bold")); //$NON-NLS-1$
+ boldNumeric.setText(Messages.getString(getClass(), "bold")); //$NON-NLS-1$
boldNumeric.addSelectionListener(new SelectionListener() {
public void widgetDefaultSelected(SelectionEvent e) {
}
@@ -313,29 +249,95 @@ public class SQLEditorPreferences extends PreferencePage
numericColorEditor.setPreferencePage(this);
numericColorEditor.setPreferenceStore(getPreferenceStore());
numericColorEditor.load();
+
+ // now for the switcheroo...
+ // reset the number of columns to 3
+ GridLayout innerLayout = new GridLayout();
+ innerLayout.numColumns = 3;
+ main.setLayout(innerLayout);
+ }
- return main;
- }
- public void updateFontDisplay() {
+ /**
+ * @param main
+ */
+ private void createFontSelectionArea(Composite main) {
+ Group group = new Group(main, SWT.NONE);
+ group.setText(Messages.getString(getClass(), "font"));
+ GridLayout innerLayout = new GridLayout();
+ innerLayout.numColumns = 2;
+ group.setLayout(innerLayout);
+ group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+ fontDisplay = new Label(group, SWT.NULL);
+ GridData data = new GridData(GridData.FILL_HORIZONTAL);
+ data.horizontalSpan = 2;
+ fontDisplay.setLayoutData(data);
+
+ fontData = PreferenceConverter.getFontData(getPreferenceStore(), "quantum.font"); //$NON-NLS-1$
+ fontDialog = new FontDialog(getShell());
+ Button fontButton = new Button(group, SWT.PUSH);
+ fontButton.setText(Messages.getString(getClass(), "pickFont")); //$NON-NLS-1$
+ fontButton.addSelectionListener(new SelectionListener() {
+ public void widgetDefaultSelected(SelectionEvent e) {
+ }
+ public void widgetSelected(SelectionEvent e) {
+ if (fontData != null) {
+ VersioningHelper.setFont(fontDialog, new FontData[] { fontData} );
+ }
+ FontData data = fontDialog.open();
+ if (data != null) {
+ fontData = data;
+ updateFontDisplay();
+ }
+ }
+ });
+ Button defaultButton = new Button(group, SWT.PUSH);
+ defaultButton.setText(Messages.getString(getClass(), "defaultFont")); //$NON-NLS-1$
+ defaultButton.addSelectionListener(new SelectionListener() {
+ public void widgetDefaultSelected(SelectionEvent e) {
+ }
+ public void widgetSelected(SelectionEvent e) {
+ fontData = PluginPreferences.getDefaultFont();
+ updateFontDisplay();
+ }
+ });
+
+ updateFontDisplay();
+ }
+
+ /**
+ * @param main
+ */
+ private void createEmptyRow(Composite main) {
+ Label emptyLabel = new Label(main, SWT.NULL);
+ emptyLabel.setText("");
+ GridData gridData = new GridData();
+ gridData.horizontalSpan = 3;
+ emptyLabel.setLayoutData(gridData);
+ }
+
+ protected void updateFontDisplay() {
if (fontData == null) {
- fontDisplay.setText(Messages.getString("PreferencesPage.Font_Default")); //$NON-NLS-1$
+ fontDisplay.setText(Messages.getString(getClass(), "default")); //$NON-NLS-1$
} else {
- String style = Messages.getString("PreferencesPage.regular"); //$NON-NLS-1$
+ Object[] parameters = new Object[] {
+ fontData.getName(), new Integer(fontData.getHeight()) };
+ String style = Messages.getString(getClass(), "regularFont", parameters); //$NON-NLS-1$
if (fontData.getStyle() == SWT.BOLD) {
- style = Messages.getString("PreferencesPage.bold"); //$NON-NLS-1$
+ style = Messages.getString(getClass(), "boldFont", parameters); //$NON-NLS-1$
} else if (fontData.getStyle() == SWT.ITALIC) {
- style = Messages.getString("PreferencesPage.italic"); //$NON-NLS-1$
+ style = Messages.getString(getClass(), "italicFont", parameters); //$NON-NLS-1$
} else if (fontData.getStyle() == (SWT.BOLD | SWT.ITALIC)) {
- style = Messages.getString("PreferencesPage.boldItalic"); //$NON-NLS-1$
+ style = Messages.getString(getClass(), "boldItalicFont", parameters); //$NON-NLS-1$
}
- fontDisplay.setText(Messages.getString("PreferencesPage.FontPrompt") + fontData.getName() + '-' + style + '-' + fontData.getHeight()); //$NON-NLS-1$
+ fontDisplay.setText(style); //$NON-NLS-1$
}
}
- public void updateFlags() {
- boldText.setSelection(textFlag);
- boldKeyword.setSelection(keywordFlag);
- boldString.setSelection(stringFlag);
- boldNumeric.setSelection(numericFlag);
- boldComment.setSelection(commentFlag);
+ protected void updateFlags() {
+ this.boldText.setSelection(this.textFlag);
+ this.boldKeyword.setSelection(this.keywordFlag);
+ this.boldString.setSelection(this.stringFlag);
+ this.boldNumeric.setSelection(this.numericFlag);
+ this.boldComment.setSelection(this.commentFlag);
}
}
diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/properties/DataTypesPropertyPage.java b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/properties/DataTypesPropertyPage.java
new file mode 100644
index 0000000..a1f5929
--- /dev/null
+++ b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/properties/DataTypesPropertyPage.java
@@ -0,0 +1,156 @@
+package com.quantum.properties;
+
+import java.sql.SQLException;
+
+import com.quantum.ImageStore;
+import com.quantum.Messages;
+import com.quantum.model.Bookmark;
+import com.quantum.model.DataType;
+import com.quantum.model.NotConnectedException;
+import com.quantum.view.bookmark.TreeNode;
+
+import org.eclipse.jface.viewers.ILabelProviderListener;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.ITableLabelProvider;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+import org.eclipse.ui.dialogs.PropertyPage;
+
+public class DataTypesPropertyPage extends PropertyPage {
+
+ protected Control createContents(Composite parent) {
+
+ Composite composite = new Composite(parent, SWT.NONE);
+ GridLayout layout = new GridLayout();
+ layout.numColumns = 2;
+ composite.setLayout(layout);
+ composite.setLayoutData(new GridData(GridData.FILL_BOTH));
+ Bookmark bookmark =
+ ((TreeNode) getElement()).getBookmark();
+ createTypesArea(composite, bookmark);
+
+ return composite;
+ }
+
+ /**
+ * @param composite
+ * @param bookmark
+ */
+ private void createTypesArea(Composite composite, Bookmark bookmark) {
+ if (bookmark.isConnected()) {
+ try {
+ DataType[] dataTypes = bookmark.getDatabase().getTypes();
+ Label label = new Label(composite, SWT.NONE);
+ label.setText(Messages.getString(getClass(), "dataTypes"));
+ GridData data = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING | GridData.VERTICAL_ALIGN_BEGINNING);
+ data.horizontalSpan = 2;
+ label.setLayoutData(data);
+
+ Table table = new Table(composite, SWT.SINGLE | SWT.FULL_SELECTION | SWT.BORDER);
+ table.setHeaderVisible(true);
+ GridData gridData = new GridData(GridData.FILL_BOTH);
+ gridData.horizontalSpan = 2;
+ gridData.heightHint = 200;
+ gridData.widthHint = 100;
+ table.setLayoutData(gridData);
+ for (int i = 0, length = 6; i < length; i++) {
+ TableColumn column = new TableColumn(table, SWT.NONE);
+ column.setText(Messages.getString(getClass(), "column" + i));
+ }
+ TableViewer viewer = new TableViewer(table);
+ viewer.setContentProvider(new IStructuredContentProvider() {
+ public Object[] getElements(Object inputElement) {
+ if (inputElement instanceof DataType[]) {
+ return (DataType[]) inputElement;
+ } else {
+ return null;
+ }
+ }
+ public void dispose() {
+ }
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ }
+ });
+ viewer.setLabelProvider(new ITableLabelProvider() {
+ public Image getColumnImage(Object element, int columnIndex) {
+ return null;
+ }
+ public String getColumnText(Object element, int columnIndex) {
+ String result = null;
+ if (element != null && element instanceof DataType) {
+ DataType dataType = (DataType) element;
+ switch (columnIndex) {
+ case 0:
+ result = dataType.getDatabaseTypeName();
+ break;
+ case 1:
+ result = dataType.getJavaNameType();
+ break;
+ case 2:
+ result = String.valueOf(dataType.getPrecision());
+ break;
+ case 3:
+ result = dataType.getLiteralPrefix();
+ break;
+ case 4:
+ result = dataType.getLiteralSuffix();
+ break;
+ case 5:
+ result = dataType.getCreateParameters();
+ break;
+ default:
+ result = null;
+ }
+ }
+ return result == null ? "" : result;
+ }
+ public void addListener(ILabelProviderListener listener) {
+ }
+ public void dispose() {
+ }
+ public boolean isLabelProperty(Object element, String property) {
+ return false;
+ }
+ public void removeListener(ILabelProviderListener listener) {
+ }
+ });
+
+ viewer.setInput(dataTypes);
+
+ for (int i = 0, length = table.getColumnCount(); i < length; i++) {
+ table.getColumn(i).pack();
+ }
+
+ } catch (SQLException e) {
+ createErrorMessage(composite, e);
+ } catch (NotConnectedException e) {
+ createErrorMessage(composite, e);
+ } catch (RuntimeException e) {
+ createErrorMessage(composite, e);
+ }
+ }
+ }
+
+ /**
+ * @param composite
+ */
+ private void createErrorMessage(Composite composite, Exception e) {
+ Label icon = new Label(composite, SWT.NONE);
+ icon.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING));
+ icon.setImage(ImageStore.getImage(ImageStore.WARNING));
+
+ Label error = new Label(composite, SWT.NONE);
+ error.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING));
+ error.setText(Messages.getString(getClass(), "error")
+ + (e.getMessage() == null ? "" : "\n" + e.getMessage()));
+ }
+}
\ No newline at end of file
diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/properties/DatabaseInformationPropertyPage.java b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/properties/DatabaseInformationPropertyPage.java
index a61c93b..d60dcf9 100644
--- a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/properties/DatabaseInformationPropertyPage.java
+++ b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/properties/DatabaseInformationPropertyPage.java
@@ -5,24 +5,15 @@ import java.sql.SQLException;
import com.quantum.ImageStore;
import com.quantum.Messages;
import com.quantum.model.Bookmark;
-import com.quantum.model.DataType;
import com.quantum.model.NotConnectedException;
import com.quantum.view.bookmark.TreeNode;
-import org.eclipse.jface.viewers.ILabelProviderListener;
-import org.eclipse.jface.viewers.IStructuredContentProvider;
-import org.eclipse.jface.viewers.ITableLabelProvider;
-import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.jface.viewers.Viewer;
import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.ui.dialogs.PropertyPage;
public class DatabaseInformationPropertyPage extends PropertyPage {
@@ -43,99 +34,12 @@ public class DatabaseInformationPropertyPage extends PropertyPage {
((TreeNode) getElement()).getBookmark();
createDatabaseNameArea(composite, bookmark);
- createTypesArea(composite, bookmark);
return composite;
}
/**
* @param composite
- * @param bookmark
- */
- private void createTypesArea(Composite composite, Bookmark bookmark) {
- if (bookmark.isConnected()) {
- try {
- DataType[] dataTypes = bookmark.getDatabase().getTypes();
- Label label = new Label(composite, SWT.NONE);
- label.setText(Messages.getString(getClass(), "dataTypes"));
- GridData data = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING | GridData.VERTICAL_ALIGN_BEGINNING);
- data.horizontalSpan = 2;
- label.setLayoutData(data);
-
- Table table = new Table(composite, SWT.SINGLE | SWT.FULL_SELECTION | SWT.BORDER);
- table.setHeaderVisible(true);
- GridData gridData = new GridData(GridData.FILL_BOTH);
- gridData.horizontalSpan = 2;
- gridData.heightHint = 200;
- table.setLayoutData(gridData);
- for (int i = 0, length = 2; i < length; i++) {
- TableColumn column = new TableColumn(table, SWT.NONE);
- column.setText(Messages.getString(getClass(), "column" + i));
- }
- TableViewer viewer = new TableViewer(table);
- viewer.setContentProvider(new IStructuredContentProvider() {
- public Object[] getElements(Object inputElement) {
- if (inputElement instanceof DataType[]) {
- return (DataType[]) inputElement;
- } else {
- return null;
- }
- }
- public void dispose() {
- }
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- }
- });
- viewer.setLabelProvider(new ITableLabelProvider() {
- public Image getColumnImage(Object element, int columnIndex) {
- return null;
- }
- public String getColumnText(Object element, int columnIndex) {
- String result = null;
- if (element != null && element instanceof DataType) {
- DataType dataType = (DataType) element;
- switch (columnIndex) {
- case 0:
- result = dataType.getDatabaseTypeName();
- break;
- case 1:
- result = dataType.getJavaNameType();
- break;
- default:
- result = null;
- }
- }
- return result == null ? "" : result;
- }
- public void addListener(ILabelProviderListener listener) {
- }
- public void dispose() {
- }
- public boolean isLabelProperty(Object element, String property) {
- return false;
- }
- public void removeListener(ILabelProviderListener listener) {
- }
- });
-
- viewer.setInput(dataTypes);
-
- for (int i = 0, length = table.getColumnCount(); i < length; i++) {
- table.getColumn(i).pack();
- }
-
- } catch (SQLException e) {
- createErrorMessage(composite, e);
- } catch (NotConnectedException e) {
- createErrorMessage(composite, e);
- } catch (RuntimeException e) {
- createErrorMessage(composite, e);
- }
- }
- }
-
- /**
- * @param composite
*/
private void createErrorMessage(Composite composite, Exception e) {
Label icon = new Label(composite, SWT.NONE);
diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/sql/ConnectionEstablisher.java b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/sql/ConnectionEstablisher.java
index 75d9363..a7ad73e 100644
--- a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/sql/ConnectionEstablisher.java
+++ b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/sql/ConnectionEstablisher.java
@@ -1,6 +1,7 @@
package com.quantum.sql;
import java.sql.Connection;
+import java.sql.SQLException;
import com.quantum.model.Bookmark;
import com.quantum.model.ConnectionException;
@@ -14,6 +15,6 @@ public interface ConnectionEstablisher {
public Connection connect(Bookmark bookmark, PasswordFinder passwordFinder)
throws ConnectionException;
public void disconnect(Connection connection)
- throws ConnectionException;
+ throws SQLException;
}
diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/sql/MultiSQLServer.java b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/sql/MultiSQLServer.java
index f5eb590..8875a1d 100644
--- a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/sql/MultiSQLServer.java
+++ b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/sql/MultiSQLServer.java
@@ -69,13 +69,9 @@ public class MultiSQLServer implements ConnectionEstablisher {
}
}
- public void disconnect(Connection connection) throws ConnectionException {
- try {
- if (connection != null) {
- connection.close();
- }
- } catch (SQLException e) {
- throw new ConnectionException(e);
+ public void disconnect(Connection connection) throws SQLException {
+ if (connection != null) {
+ connection.close();
}
}
diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/sql/SQLMetaDataResults.java b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/sql/SQLMetaDataResults.java
index 61b3333..3835511 100644
--- a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/sql/SQLMetaDataResults.java
+++ b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/sql/SQLMetaDataResults.java
@@ -42,10 +42,12 @@ public class SQLMetaDataResults extends SQLResultSetResults {
List columns = new ArrayList();
columns.add(new Column("ColumnName", "", 0)); //$NON-NLS-1$
- columns.add(new Column("Type", "", 0)); //$NON-NLS-1$
+ columns.add(new Column("Type Name", "", 0)); //$NON-NLS-1$
columns.add(new Column("Size", "", 0)); //$NON-NLS-1$
+ columns.add(new Column("Scale", "", 0)); //$NON-NLS-1$
columns.add(new Column("Nullable", "", 0)); //$NON-NLS-1$
columns.add(new Column("AutoIncrement", "", 0)); //$NON-NLS-1$
+ columns.add(new Column("Type", "", 0)); //$NON-NLS-1$
setColumns((Column[]) columns.toArray(new Column[columns.size()]));
ResultSetMetaData metaData = set.getMetaData();
@@ -55,14 +57,15 @@ public class SQLMetaDataResults extends SQLResultSetResults {
Vector row = new Vector();
row.addElement(metaData.getColumnName(i));
row.addElement(metaData.getColumnTypeName(i));
- int textSize = metaData.getColumnDisplaySize(i);
int precision = metaData.getPrecision(i);
- int scale = metaData.getScale(i);
- if (scale == 0 && precision == 0) {
- row.addElement(Integer.toString(precision));
- } else {
- row.addElement(textSize + ", " + precision + ", " + scale); //$NON-NLS-1$ //$NON-NLS-2$
+ if (precision == 0) {
+ precision = metaData.getColumnDisplaySize(i);
}
+ int scale = metaData.getScale(i);
+
+ row.addElement(new Integer(precision));
+ row.addElement(new Integer(scale));
+
int nullable = metaData.isNullable(i);
if (nullable == ResultSetMetaData.columnNoNulls) {
row.addElement("Not Null"); //$NON-NLS-1$
@@ -80,9 +83,9 @@ public class SQLMetaDataResults extends SQLResultSetResults {
: Boolean.FALSE)
.toString());
rowList.add(new Row(row));
+ row.addElement(new Integer(metaData.getColumnType(i)));
}
setRows((Row[]) rowList.toArray(new Row[rowList.size()]));
- set.close();
}
public boolean isMetaData() {
diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/sql/SQLStandardResultSetResults.java b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/sql/SQLStandardResultSetResults.java
index 7358b26..1a21e00 100644
--- a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/sql/SQLStandardResultSetResults.java
+++ b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/sql/SQLStandardResultSetResults.java
@@ -108,7 +108,7 @@ public class SQLStandardResultSetResults extends SQLResultSetResults implements
value = set.getString(i);
}
}
- if (value == null) {
+ if (value == null && !set.wasNull()) {
value = set.getString(i);
}
row.add(value == null || set.wasNull() ? "" : value); //$NON-NLS-1$
diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/sql/parser/DropEntityStatement.java b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/sql/parser/DropEntityStatement.java
new file mode 100644
index 0000000..61edb06
--- /dev/null
+++ b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/sql/parser/DropEntityStatement.java
@@ -0,0 +1,46 @@
+package com.quantum.sql.parser;
+
+import com.quantum.model.Entity;
+
+
+/**
+ * Drop a table, view or sequence.
+ *
+ * @author BC Holmes
+ */
+public class DropEntityStatement implements SQL {
+
+ private String tableName;
+ private String type = Entity.TABLE_TYPE;
+ private String dependentRule = "";
+
+ /**
+ * @see com.quantum.sql.parser.SQL#getCommand()
+ */
+ public String getCommand() {
+ return "DROP " + getType().toUpperCase();
+ }
+
+ public String getTableName() {
+ return this.tableName;
+ }
+ public void setTableName(String tableName) {
+ this.tableName = tableName;
+ }
+
+ public String toString() {
+ return getCommand() + " " + getTableName() + " " + this.dependentRule;
+ }
+ public String getType() {
+ return this.type;
+ }
+ public void setType(String type) {
+ this.type = type;
+ }
+ public String getDependentRule() {
+ return this.dependentRule;
+ }
+ public void setDependentRule(String dependentRule) {
+ this.dependentRule = dependentRule;
+ }
+}
diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/ui/dialog/SQLExceptionDialog.java b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/ui/dialog/SQLExceptionDialog.java
new file mode 100644
index 0000000..91a77a3
--- /dev/null
+++ b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/ui/dialog/SQLExceptionDialog.java
@@ -0,0 +1,66 @@
+package com.quantum.ui.dialog;
+
+import java.sql.SQLException;
+
+import com.quantum.Messages;
+import com.quantum.model.Bookmark;
+
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+
+
+/**
+ * @author BC Holmes
+ */
+public class SQLExceptionDialog extends MessageDialog {
+
+ private final SQLException sqlException;
+
+ /**
+ * @param parentShell
+ * @param dialogTitle
+ * @param sqlException
+ */
+ private SQLExceptionDialog(Shell parentShell, String dialogTitle,
+ SQLException sqlException) {
+ super(parentShell, dialogTitle, null, sqlException.getLocalizedMessage(), ERROR,
+ new String[]{IDialogConstants.OK_LABEL}, 0);
+ this.sqlException = sqlException;
+ }
+
+ protected Control createCustomArea(Composite parent) {
+ Composite composite = new Composite(parent, SWT.NONE);
+ composite.setLayout(new GridLayout(2, false));
+ composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+ Label label = new Label(composite, SWT.NONE);
+ label.setText(Messages.getString(SQLExceptionDialog.class, "sqlState"));
+ label = new Label(composite, SWT.NONE);
+ label.setText(this.sqlException.getSQLState() == null
+ ? "" : this.sqlException.getSQLState());
+
+ label = new Label(composite, SWT.NONE);
+ label.setText(Messages.getString(SQLExceptionDialog.class, "errorCode"));
+ label = new Label(composite, SWT.NONE);
+ label.setText(String.valueOf(this.sqlException.getErrorCode()));
+ return composite;
+ }
+
+ public static void openException(Shell shell, Bookmark bookmark, SQLException sqlException) {
+ SQLExceptionDialog dialog = new SQLExceptionDialog(shell,
+ bookmark == null
+ ? Messages.getString(SQLExceptionDialog.class, "title")
+ : Messages.getString(
+ SQLExceptionDialog.class, "titleWithBookmark",
+ new Object[] { bookmark.getDisplayName() }),
+ sqlException);
+ dialog.open();
+ }
+}
diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/util/connection/ConnectionUtil.java b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/util/connection/ConnectionUtil.java
index ecfe620..8c775a3 100644
--- a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/util/connection/ConnectionUtil.java
+++ b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/util/connection/ConnectionUtil.java
@@ -1,6 +1,7 @@
package com.quantum.util.connection;
import java.sql.Connection;
+import java.sql.SQLException;
import com.quantum.Messages;
import com.quantum.model.Bookmark;
@@ -8,6 +9,7 @@ import com.quantum.model.ConnectionException;
import com.quantum.model.NotConnectedException;
import com.quantum.ui.dialog.ExceptionDisplayDialog;
import com.quantum.ui.dialog.PasswordDialog;
+import com.quantum.ui.dialog.SQLExceptionDialog;
import org.eclipse.swt.widgets.Shell;
@@ -16,7 +18,7 @@ import org.eclipse.swt.widgets.Shell;
* interactions such as providing messages to the user and/or prompting for a
* password.
*
- * @author BC
+ * @author BC Holmes
*/
public class ConnectionUtil {
@@ -35,10 +37,14 @@ public class ConnectionUtil {
try {
connection = bookmark.connect(PasswordDialog.createPasswordFinder(shell));
} catch (ConnectionException e) {
- ExceptionDisplayDialog.openError(shell,
- Messages.getString(getClass().getName() + ".title"),
- Messages.getString(getClass().getName() + ".message") +
- " (Bookmark:"+bookmark.getName()+")", e);
+ if (e.getCause() != null && e.getCause() instanceof SQLException) {
+ SQLExceptionDialog.openException(shell, bookmark, (SQLException) e.getCause());
+ } else {
+ ExceptionDisplayDialog.openError(shell,
+ Messages.getString(getClass().getName() + ".title"),
+ Messages.getString(getClass().getName() + ".message") +
+ " (Bookmark:"+bookmark.getName()+")", e);
+ }
}
return connection;
}
diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/util/sql/SQLStates.java b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/util/sql/SQLStates.java
new file mode 100644
index 0000000..0850412
--- /dev/null
+++ b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/util/sql/SQLStates.java
@@ -0,0 +1,18 @@
+package com.quantum.util.sql;
+
+
+/**
+ * @author BC Holmes
+ */
+public abstract class SQLStates {
+
+ /**
+ * The driver does not support the requested operation. This SQL code is returned
+ * by MS Access (and possibly others) when calling JDBC functions that are not
+ * implemented by the driver.
+ */
+ public static final String ODBC_DRIVER_NOT_CAPABLE = "S1C00";
+
+ private SQLStates() {
+ }
+}
diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/SQLQueryView.java b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/SQLQueryView.java
index 0b14583..fd3348e 100644
--- a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/SQLQueryView.java
+++ b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/SQLQueryView.java
@@ -1,16 +1,20 @@
package com.quantum.view;
import java.sql.SQLException;
+import java.util.ArrayList;
import java.util.LinkedList;
+import java.util.List;
import java.util.NoSuchElementException;
import java.util.Vector;
import com.quantum.ImageStore;
import com.quantum.Messages;
+import com.quantum.PluginPreferences;
import com.quantum.QuantumPlugin;
import com.quantum.actions.ExecuteAction;
import com.quantum.actions.ExportQueryAction;
import com.quantum.actions.ImportQueryAction;
+import com.quantum.editors.ColorManager;
import com.quantum.model.Bookmark;
import com.quantum.model.BookmarkCollection;
import com.quantum.model.NotConnectedException;
@@ -19,11 +23,13 @@ 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.ui.dialog.SQLExceptionDialog;
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.IPreferenceStore;
import org.eclipse.jface.preference.PreferenceConverter;
import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.PropertyChangeEvent;
@@ -36,12 +42,15 @@ 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.dnd.Clipboard;
+import org.eclipse.swt.dnd.TransferData;
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.Display;
import org.eclipse.ui.IActionBars;
import org.eclipse.ui.IWorkbenchActionConstants;
@@ -87,7 +96,7 @@ public class SQLQueryView extends ViewPart {
MultiSQLServer.getInstance().rollback(bookmarks[i].getConnection());
}
} catch (SQLException e) {
- ExceptionDisplayDialog.openError(getSite().getShell(), null, null, e);
+ SQLExceptionDialog.openException(getSite().getShell(), bookmarks[i], e);
} catch (NotConnectedException e) {
ExceptionDisplayDialog.openError(getSite().getShell(), null, null, e);
}
@@ -110,7 +119,7 @@ public class SQLQueryView extends ViewPart {
MultiSQLServer.getInstance().commit(bookmarks[i].getConnection());
}
} catch (SQLException e) {
- ExceptionDisplayDialog.openError(getSite().getShell(), null, null, e);
+ SQLExceptionDialog.openException(getSite().getShell(), bookmarks[i], e);
} catch (NotConnectedException e) {
ExceptionDisplayDialog.openError(getSite().getShell(), null, null, e);
}
@@ -158,25 +167,32 @@ public class SQLQueryView extends ViewPart {
private ImportQueryAction importQueryAction;
private ExportQueryAction exportQueryAction;
private StyledText widget;
- 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;
+ private IPropertyChangeListener listener;
+ private ColorManager colorManager = new ColorManager();
+
+ private SyntaxHighlighter textUpdater = new SyntaxHighlighter(this.colorManager);
+
public SQLQueryView() {
super();
- IPropertyChangeListener listener = new IPropertyChangeListener() {
+ this.listener = new IPropertyChangeListener() {
public void propertyChange(PropertyChangeEvent event) {
setFont();
}
};
QuantumPlugin.getDefault().getPreferenceStore().addPropertyChangeListener(listener);
}
+
+ public void dispose() {
+ QuantumPlugin.getDefault().getPreferenceStore().removePropertyChangeListener(this.listener);
+ this.colorManager.dispose();
+ super.dispose();
+ }
+
public static SQLQueryView getInstance() {
return (SQLQueryView) QuantumPlugin.getDefault().getView("com.quantum.view.sqlqueryview");
@@ -228,12 +244,12 @@ public class SQLQueryView extends ViewPart {
/**
* @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 initializeColours(Composite parent) {
+ IPreferenceStore store = QuantumPlugin.getDefault().getPreferenceStore();
+
+ parent.setBackground(this.colorManager.getColor(
+ PreferenceConverter.getColor(store, PluginPreferences.BACKGROUND_COLOR)));
+ this.textUpdater.initializeColours();
}
private void initActions() {
@@ -271,8 +287,6 @@ public class SQLQueryView extends ViewPart {
widget.setText(text);
}
- SyntaxHighlighter textUpdater = new SyntaxHighlighter();
-
private class UpdateRequest {
public UpdateRequest(String text, int start, int length) {
this.text = text;
@@ -285,21 +299,42 @@ public class SQLQueryView extends ViewPart {
}
private class SyntaxHighlighter extends Thread {
+
+ private Color STRING_LITERAL;
+ private Color KEYWORD;
+ private Color COMMENT;
+ private Color NUMERIC;
+ private Color DEFAULT;
+
private boolean running = true;
private LinkedList requests = new LinkedList();
- public SyntaxHighlighter() {
+ private final ColorManager colorManager;
+ public SyntaxHighlighter(ColorManager colorManager) {
super();
+ this.colorManager = colorManager;
+
setPriority(Thread.MIN_PRIORITY);
start();
}
+ public void initializeColours() {
+ IPreferenceStore store = QuantumPlugin.getDefault().getPreferenceStore();
+
+ this.DEFAULT = this.colorManager.getColor(
+ PreferenceConverter.getColor(store, PluginPreferences.TEXT_COLOR));
+ this.KEYWORD = this.colorManager.getColor(
+ PreferenceConverter.getColor(store, PluginPreferences.KEYWORD_COLOR));
+ this.STRING_LITERAL = this.colorManager.getColor(
+ PreferenceConverter.getColor(store, PluginPreferences.STRING_COLOR));
+ this.COMMENT = this.colorManager.getColor(
+ PreferenceConverter.getColor(store, PluginPreferences.COMMENT_COLOR));
+ this.NUMERIC = this.colorManager.getColor(
+ PreferenceConverter.getColor(store, PluginPreferences.NUMERIC_COLOR));
+
+ }
public synchronized void updateText(String text, int start, int length) {
requests.add(new UpdateRequest(text, start, length));
notify();
}
- public synchronized void shutdown() {
- running = false;
- interrupt();
- }
public void run() {
while (running) {
try {
@@ -315,12 +350,12 @@ public class SQLQueryView extends ViewPart {
//int dirtyStart = request.start;
//int dirtyEnd = request.start + request.length;
StyleRange styleRange;
- Vector tokens = SQLLexx.parse(text);
- Vector styles = new Vector();
+ List tokens = SQLLexx.parse(text);
+ List styles = new ArrayList();
int min = Integer.MAX_VALUE;
int max = 0;
for (int i = 0; i < tokens.size(); i++) {
- Token t = (Token) tokens.elementAt(i);
+ Token t = (Token) tokens.get(i);
String value = t.getValue();
int start = t.getStart();
int length = t.getEnd() - t.getStart();
@@ -349,25 +384,23 @@ public class SQLQueryView extends ViewPart {
} else {
styleRange.foreground = DEFAULT;
}
- styles.addElement(styleRange);
+ styles.add(styleRange);
} else if (t.getType() == Token.COMMENT) {
styleRange.foreground = COMMENT;
- styles.addElement(styleRange);
+ styles.add(styleRange);
} else if (t.getType() == Token.LITERAL) {
styleRange.foreground = STRING_LITERAL;
- styles.addElement(styleRange);
+ styles.add(styleRange);
} else if (t.getType() == Token.NUMERIC) {
styleRange.foreground = NUMERIC;
- styles.addElement(styleRange);
+ styles.add(styleRange);
} else {
- styles.addElement(styleRange);
+ styles.add(styleRange);
}
}
}
- StyleRange[] ranges = new StyleRange[styles.size()];
- for (int k = 0; k < ranges.length; k++) {
- ranges[k] = (StyleRange) styles.elementAt(k);
- }
+ StyleRange[] ranges =
+ (StyleRange[]) styles.toArray(new StyleRange[styles.size()]);
if (max >= 0 && ranges.length > 0) {
setStyles(ranges, min, max - min);
}
diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/SchemaSelectionControl.java b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/SchemaSelectionControl.java
index 4a7fa72..c6e21cf 100644
--- a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/SchemaSelectionControl.java
+++ b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/SchemaSelectionControl.java
@@ -19,6 +19,7 @@ import com.quantum.model.ConnectionException;
import com.quantum.model.NotConnectedException;
import com.quantum.model.Schema;
import com.quantum.ui.dialog.ExceptionDisplayDialog;
+import com.quantum.ui.dialog.SQLExceptionDialog;
import com.quantum.ui.dialog.SimpleSelectionDialog;
import com.quantum.util.connection.ConnectionUtil;
@@ -273,7 +274,7 @@ public class SchemaSelectionControl extends Composite {
} catch (ConnectionException e) {
ExceptionDisplayDialog.openError(getShell(), null, null, e);
} catch (SQLException e) {
- ExceptionDisplayDialog.openError(getShell(), null, null, e);
+ SQLExceptionDialog.openException(getShell(), bookmark, e);
}
}
diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/ViewHelper.java b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/ViewHelper.java
index 252c0a8..7733294 100644
--- a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/ViewHelper.java
+++ b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/ViewHelper.java
@@ -15,6 +15,7 @@ import com.quantum.QuantumPlugin;
import com.quantum.model.Bookmark;
import com.quantum.sql.MultiSQLServer;
import com.quantum.sql.SQLResults;
+import com.quantum.ui.dialog.SQLExceptionDialog;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.swt.SWT;
@@ -41,7 +42,7 @@ public class ViewHelper {
} catch (SQLException e) {
LogProxy log = LogProxy.getInstance();
log.addText(LogProxy.ERROR, e.getLocalizedMessage(), e); //$NON-NLS-1$ //$NON-NLS-2$
- MessageDialog.openConfirm(shell, "Database returned error", e.getLocalizedMessage()); //$NON-NLS-1$
+ SQLExceptionDialog.openException(shell, bookmark, e);
return null;
}
}
diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/bookmark/BookmarkContentProvider.java b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/bookmark/BookmarkContentProvider.java
index 79d70bf..680a382 100644
--- a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/bookmark/BookmarkContentProvider.java
+++ b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/bookmark/BookmarkContentProvider.java
@@ -4,6 +4,7 @@ import java.sql.SQLException;
import com.quantum.model.NotConnectedException;
import com.quantum.ui.dialog.ExceptionDisplayDialog;
+import com.quantum.ui.dialog.SQLExceptionDialog;
import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.jface.viewers.Viewer;
@@ -20,14 +21,14 @@ public class BookmarkContentProvider implements ITreeContentProvider {
public Object[] getChildren(Object element) {
- if (element instanceof TreeNode) {
+ if (element != null && element instanceof TreeNode) {
TreeNode node = (TreeNode) element;
try {
return node.getChildren();
} catch (NotConnectedException e) {
ExceptionDisplayDialog.openError(getShell(), null, null, e);
} catch (SQLException e) {
- ExceptionDisplayDialog.openError(getShell(), null, null, e);
+ SQLExceptionDialog.openException(getShell(), node.getBookmark(), e);
}
}
return BookmarkListNode.EMPTY_ARRAY;
diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/bookmark/BookmarkNode.java b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/bookmark/BookmarkNode.java
index aca7002..852745c 100644
--- a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/bookmark/BookmarkNode.java
+++ b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/bookmark/BookmarkNode.java
@@ -8,7 +8,6 @@ import java.util.Iterator;
import java.util.Map;
import com.quantum.model.Bookmark;
-import com.quantum.model.ConnectionException;
import com.quantum.model.NotConnectedException;
import com.quantum.model.Schema;
@@ -97,7 +96,7 @@ public class BookmarkNode extends TreeNode implements PropertyChangeListener {
if (this.bookmark.isConnected()) {
this.bookmark.disconnect();
}
- } catch (ConnectionException e) {
+ } catch (SQLException e) {
}
}
diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/bookmark/BookmarkViewActionGroup.java b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/bookmark/BookmarkViewActionGroup.java
index 3af90bd..2cd661c 100644
--- a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/bookmark/BookmarkViewActionGroup.java
+++ b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/bookmark/BookmarkViewActionGroup.java
@@ -3,10 +3,10 @@ package com.quantum.view.bookmark;
import java.util.Iterator;
import com.quantum.ImageStore;
+import com.quantum.Messages;
import com.quantum.actions.AddToQuickListAction;
import com.quantum.actions.ConnectAction;
import com.quantum.actions.DeleteAllRowsAction;
-import com.quantum.actions.DeleteBookmarkAction;
import com.quantum.actions.DisconnectAction;
import com.quantum.actions.NewBookmarkAction;
import com.quantum.actions.NextSequenceAction;
@@ -20,12 +20,19 @@ import com.quantum.model.Bookmark;
import com.quantum.util.versioning.VersioningHelper;
import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.ActionContributionItem;
import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.action.IMenuCreator;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.IToolBarManager;
import org.eclipse.jface.action.Separator;
import org.eclipse.jface.viewers.ISelectionProvider;
import org.eclipse.jface.viewers.IStructuredSelection;
+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.ui.IActionBars;
import org.eclipse.ui.IViewPart;
import org.eclipse.ui.IWorkbenchActionConstants;
@@ -36,19 +43,52 @@ import org.eclipse.ui.actions.SelectionProviderAction;
import org.eclipse.ui.dialogs.PropertyDialogAction;
/**
- * @author BC
+ * This class manages the list of actions for the bookmark view.
+ *
+ * @author BC Holmes
*/
public class BookmarkViewActionGroup extends ActionGroup
implements BookmarkClipboard {
+
+ class SQLAction extends Action implements IMenuCreator {
+ public SQLAction() {
+ setText(Messages.getString(BookmarkViewActionGroup.class, "sqlAction.text"));
+ setMenuCreator(this);
+ }
+ public void dispose() {
+ }
+ public Menu getMenu(Control parent) {
+ return null;
+ }
+ public Menu getMenu(Menu 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 event) {
+ Menu menu = (Menu) event.widget;
+ MenuItem[] items = menu.getItems();
+ for (int i=0; i < items.length; i++) {
+ items[i].dispose();
+ }
+ fillSQLMenu(menu);
+ }
+ });
+ return menu;
+ }
+ }
private Bookmark bookmarkClipboard;
private Action newBookmarkAction;
+ private Action sqlAction;
// bookmark node actions
private SelectionListenerAction connectAction;
private SelectionListenerAction disconnectAction;
- private SelectionListenerAction deleteBookmarkAction;
+ private SelectionListenerAction deleteAction;
// Query node actions
private SelectionListenerAction openQueryAction;
@@ -62,6 +102,9 @@ public class BookmarkViewActionGroup extends ActionGroup
private SelectionListenerAction nextSequenceAction;
private SelectionListenerAction previousSequenceAction;
+
+ private SelectionListenerAction dropAction;
+
// other actions
private SelectionListenerAction refreshAction;
@@ -87,7 +130,8 @@ public class BookmarkViewActionGroup extends ActionGroup
// bookmark actions
this.connectAction = new ConnectAction(this.viewPart);
this.disconnectAction = new DisconnectAction(this.viewPart);
- this.deleteBookmarkAction = new DeleteBookmarkAction(this.viewPart);
+
+ this.sqlAction = new SQLAction();
// entity actions
this.previousSequenceAction = new PrevSequenceAction(this.viewPart);
@@ -104,16 +148,22 @@ 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.deleteAction = new DeleteAction(this.viewPart, selectionProvider);
this.exportAction = VersioningHelper.createExportResourcesAction(
this.viewPart.getViewSite().getWorkbenchWindow());
this.exportAction.setImageDescriptor(ImageStore.getImageDescriptor(ImageStore.EXPORT));
+ this.dropAction = new DropEntityAction(this.viewPart);
+
this.propertiesAction = new PropertyDialogAction(
this.viewPart.getSite().getShell(), selectionProvider);
}
/**
+ * Add all the appropriate actions to the popup menu. This method is
+ * called whenever someone right-clicks on an object in the bookmark view.
+ *
* @see org.eclipse.ui.actions.ActionGroup#fillContextMenu(org.eclipse.jface.action.IMenuManager)
*/
public void fillContextMenu(IMenuManager menu) {
@@ -133,7 +183,7 @@ public class BookmarkViewActionGroup extends ActionGroup
// TODO: paste needs to change enablement whenever something is added
// to the clipboard
addToMenu(menu, this.pasteAction);
- addToMenu(menu, this.deleteBookmarkAction);
+ addToMenu(menu, this.deleteAction);
if (getStructuredSelection().size() == 1 &&
isEverySelectionInstanceof(BookmarkNode.class)) {
@@ -143,7 +193,7 @@ public class BookmarkViewActionGroup extends ActionGroup
menu.add(new Separator());
- // NOTE: In Eclipse 3.0.0 M6, Export is no longer a sub-class of
+ // NOTE: In Eclipse 3.0, Export is no longer a sub-class of
// SelectionListenerAction.
if (this.exportAction != null) {
this.exportAction.selectionChanged(getStructuredSelection());
@@ -178,6 +228,11 @@ public class BookmarkViewActionGroup extends ActionGroup
addToMenu(menu, this.addToQuickListAction);
addToMenu(menu, this.removeFromQuickListAction);
+
+ if (getStructuredSelection().size() == 1) {
+ menu.add(new Separator());
+ menu.add(this.sqlAction);
+ }
}
if (getStructuredSelection().size() == 1) {
@@ -190,7 +245,19 @@ public class BookmarkViewActionGroup extends ActionGroup
if (getStructuredSelection().size() == 1) {
addToMenu(menu, this.propertiesAction);
}
-
+ }
+
+ protected void fillSQLMenu(Menu parent) {
+ if (getStructuredSelection().size() > 0 &&
+ isEverySelectionInstanceof(EntityNode.class)) {
+ addToMenu(parent, this.dropAction);
+ }
+ }
+
+ private void addToMenu(Menu menu, SelectionListenerAction action) {
+ action.selectionChanged(getStructuredSelection());
+ ActionContributionItem item = new ActionContributionItem(action);
+ item.fill(menu, -1);
}
private void addToMenu(IMenuManager menu, SelectionListenerAction action) {
@@ -244,6 +311,7 @@ public class BookmarkViewActionGroup extends ActionGroup
toolBar.add(this.newBookmarkAction);
actionBars.setGlobalActionHandler(IWorkbenchActionConstants.COPY, this.copyAction);
+ actionBars.setGlobalActionHandler(IWorkbenchActionConstants.DELETE, this.deleteAction);
}
diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/bookmark/ColumnNode.java b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/bookmark/ColumnNode.java
index 2894c03..d1f53af 100644
--- a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/bookmark/ColumnNode.java
+++ b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/bookmark/ColumnNode.java
@@ -61,4 +61,11 @@ public class ColumnNode extends TreeNode {
return column;
}
+ void setColumn(Column column) {
+ if (this.column == null || !this.column.equals(column)) {
+ Column original = column;
+ this.column = column;
+ firePropertyChange("column", original, column);
+ }
+ }
}
diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/bookmark/DeleteAction.java b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/bookmark/DeleteAction.java
new file mode 100644
index 0000000..c38ba7a
--- /dev/null
+++ b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/bookmark/DeleteAction.java
@@ -0,0 +1,88 @@
+package com.quantum.view.bookmark;
+
+import java.util.Iterator;
+import java.util.List;
+
+import com.quantum.ImageStore;
+import com.quantum.Messages;
+import com.quantum.model.BookmarkCollection;
+
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.viewers.ISelectionProvider;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.ui.IViewPart;
+import org.eclipse.ui.actions.SelectionListenerAction;
+
+/**
+ * @author root
+ *
+ */
+public class DeleteAction extends SelectionListenerAction {
+
+ private IViewPart view;
+
+ public DeleteAction(IViewPart view, ISelectionProvider selectionProvider) {
+ super(Messages.getString(DeleteAction.class.getName() + ".text"));
+ setImageDescriptor(ImageStore.getImageDescriptor(ImageStore.DELETE));
+ this.view = view;
+ selectionProvider.addSelectionChangedListener(this);
+ }
+
+ public void run() {
+ if (isEachSelectionInstanceOf(getSelectedNonResources().iterator(), BookmarkNode.class)) {
+ deleteBookmarks();
+ } else if (isEachSelectionInstanceOf(getSelectedNonResources().iterator(), QueryNode.class)) {
+ deleteQueries();
+ }
+ }
+
+ /**
+ *
+ */
+ private void deleteQueries() {
+ List nodes = getSelectedNonResources();
+ for (Iterator i = nodes.iterator(); i.hasNext();) {
+ QueryNode queryNode = (QueryNode) i.next();
+ if (queryNode != null) {
+ queryNode.getBookmark().removeQuery(queryNode.getQuery());
+ }
+ }
+ }
+
+ /**
+ *
+ */
+ private void deleteBookmarks() {
+ List bookmarkNodes = getSelectedNonResources();
+ boolean flag = MessageDialog.openConfirm(view.getSite().getShell(),
+ Messages.getString(getClass(), "confirmTitle"),
+ Messages.getString(getClass(), "confirmText"));
+
+ for (Iterator i = bookmarkNodes.iterator(); flag && i.hasNext();) {
+ BookmarkNode bookmarkNode = (BookmarkNode) i.next();
+ if (bookmarkNode != null) {
+ BookmarkCollection.getInstance().removeBookmark(bookmarkNode.getBookmark());
+ }
+ }
+ }
+
+ public boolean updateSelection(IStructuredSelection selection) {
+ return isEachSelectionInstanceOf(selection.iterator(), BookmarkNode.class) ||
+ isEachSelectionInstanceOf(selection.iterator(), QueryNode.class);
+ }
+
+ /**
+ * @param selection
+ * @param enabled
+ * @param selectionClass
+ * @return
+ */
+ private boolean isEachSelectionInstanceOf(Iterator selection, Class selectionClass) {
+ boolean result = true;
+ for (Iterator i = selection; result && i.hasNext(); ) {
+ result &= (selectionClass.isInstance(i.next()));
+ }
+ return result;
+ }
+
+}
diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/bookmark/DropEntityAction.java b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/bookmark/DropEntityAction.java
new file mode 100644
index 0000000..f8f2e80
--- /dev/null
+++ b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/bookmark/DropEntityAction.java
@@ -0,0 +1,81 @@
+package com.quantum.view.bookmark;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import com.quantum.Messages;
+import com.quantum.actions.BaseExecuteAction;
+import com.quantum.model.Bookmark;
+import com.quantum.model.Entity;
+import com.quantum.model.EntityHolder;
+import com.quantum.sql.parser.DropEntityStatement;
+import com.quantum.wizards.sql.DropEntityWizardPage;
+import com.quantum.wizards.sql.SQLStatementWizard;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jface.action.IStatusLineManager;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IViewPart;
+
+
+/**
+ * Drop a table.
+ *
+ * @author BC Holmes
+ */
+public class DropEntityAction extends BaseExecuteAction {
+
+ private final IViewPart view;
+ private DropEntityStatement statement = new DropEntityStatement();
+
+ public DropEntityAction(IViewPart view) {
+ this.view = view;
+ setText(Messages.getString(getClass(), "text"));
+ }
+
+ public void run() {
+ Entity entity = getEntity();
+ if (entity != null) {
+ this.statement.setTableName(entity.getQuotedTableName());
+ this.statement.setType(entity.getType());
+ }
+
+ DropEntityWizardPage page = new DropEntityWizardPage("page1", this.statement);
+ SQLStatementWizard wizard = new SQLStatementWizard(new WizardPage[] { page }, this.statement);
+
+ WizardDialog dialog = new WizardDialog(this.view.getViewSite().getShell(), wizard);
+ if (WizardDialog.OK == dialog.open()) {
+ super.run();
+ }
+ }
+ protected Shell getShell() {
+ return this.view.getViewSite().getShell();
+ }
+
+ protected Bookmark getBookmark() {
+ Entity entity = getEntity();
+ return entity != null ? entity.getBookmark() : super.getBookmark();
+ }
+ protected List getQueries() throws IOException, CoreException {
+ List list = new ArrayList();
+ list.add(this.statement.toString());
+ return list;
+ }
+
+ protected Entity getEntity() {
+ List list = getSelectedNonResources();
+ return list == null || list.isEmpty() ? null : ((EntityHolder) list.get(0)).getEntity();
+ }
+
+ protected IStatusLineManager getStatusLineManager() {
+ return this.view.getViewSite().getActionBars().getStatusLineManager();
+ }
+
+ protected boolean updateSelection(IStructuredSelection selection) {
+ return !selection.isEmpty();
+ }
+}
diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/bookmark/EntityNode.java b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/bookmark/EntityNode.java
index eb9d742..9d59f71 100644
--- a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/bookmark/EntityNode.java
+++ b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/bookmark/EntityNode.java
@@ -1,6 +1,12 @@
package com.quantum.view.bookmark;
import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
import com.quantum.model.Column;
import com.quantum.model.Entity;
@@ -18,6 +24,10 @@ public class EntityNode extends TreeNode implements EntityHolder {
private Entity entity;
private boolean longFormName;
+ private List columns = Collections.synchronizedList(new ArrayList());
+ private List foreignKeys = Collections.synchronizedList(new ArrayList());
+ boolean initialized = false;
+
public EntityNode(TreeNode parent, Entity entity) {
this(parent, entity, false);
}
@@ -35,7 +45,10 @@ public class EntityNode extends TreeNode implements EntityHolder {
}
public Object[] getChildren() throws NotConnectedException, SQLException {
- initializeChildren();
+ if (!isInitialized()) {
+ initializeChildren();
+ }
+
if (this.children.size() > 0) {
return (ColumnNode[]) this.children.toArray(new ColumnNode[this.children.size()]);
} else {
@@ -44,14 +57,35 @@ public class EntityNode extends TreeNode implements EntityHolder {
}
protected synchronized void initializeChildren() throws NotConnectedException, SQLException {
- this.children.clear();
+ boolean wasInitialized = isInitialized();
+ Map map = getChildrenAsMap();
Column[] columns = this.entity.getColumns();
+ this.children.clear();
for (int i = 0, length = (columns == null) ? 0 : columns.length;
i < length;
i++) {
- this.children.add(new ColumnNode(this, columns[i]));
+
+ ColumnNode node = (ColumnNode) map.get(columns[i].getName());
+ if (node == null) {
+ this.children.add(new ColumnNode(this, columns[i]));
+ } else {
+ node.setColumn(columns[i]);
+ this.children.add(node);
+ }
+
+ if (wasInitialized) {
+ firePropertyChange("columns", null, null);
+ }
}
- // TODO: fire property change event
+ }
+
+ private Map getChildrenAsMap() {
+ Map map = new HashMap();
+ for (Iterator i = this.children.iterator(); i.hasNext();) {
+ TreeNode node = (TreeNode) i.next();
+ map.put(node.getName(), node);
+ }
+ return map;
}
public boolean hasChildren() {
@@ -128,4 +162,7 @@ public class EntityNode extends TreeNode implements EntityHolder {
return super.compareTo(o);
}
}
+ void setEntity(Entity entity) {
+ this.entity = entity;
+ }
}
diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/bookmark/GroupNode.java b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/bookmark/GroupNode.java
index 974dcd7..354edd3 100644
--- a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/bookmark/GroupNode.java
+++ b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/bookmark/GroupNode.java
@@ -1,7 +1,3 @@
-/*
- * Created on 27/06/2003
- *
- */
package com.quantum.view.bookmark;
import java.sql.SQLException;
@@ -26,12 +22,17 @@ import com.quantum.model.SchemaHolder;
public class GroupNode extends TreeNode implements Comparable, SchemaHolder {
private String type = null;
private Schema schema = null;
+ private boolean initialized = false;
public GroupNode(TreeNode parent, Schema schema, String type) {
super(parent);
this.schema = schema;
this.type = type;
}
+
+ protected boolean isInitialized() {
+ return this.initialized;
+ }
public boolean hasChildren() {
if (!isInitialized()) {
return true;
@@ -48,7 +49,6 @@ public class GroupNode extends TreeNode implements Comparable, SchemaHolder {
protected void initializeChildren() {
try {
boolean firstTimeInitialization = !isInitialized();
- boolean changed = false;
Map temp = new HashMap();
for (Iterator i = this.children.iterator(); i.hasNext();) {
TreeNode treeNode = (TreeNode) i.next();
@@ -67,15 +67,21 @@ public class GroupNode extends TreeNode implements Comparable, SchemaHolder {
EntityNode entityNode = (EntityNode) temp.remove(name);
if (entityNode == null) {
this.children.add(new EntityNode(this, entities[i]));
- changed = true;
} else {
+ entityNode.setEntity(entities[i]);
this.children.add(entityNode);
}
}
+ for (Iterator i = temp.values().iterator(); i.hasNext();) {
+ ((TreeNode) i.next()).dispose();
+ }
+
Collections.sort(this.children);
- if ((temp.size() > 0 || changed ) && !firstTimeInitialization) {
+ if (!firstTimeInitialization) {
firePropertyChange("children", null, null);
}
+
+ this.initialized = true;
} catch (SQLException e) {
}
}
@@ -91,4 +97,7 @@ public class GroupNode extends TreeNode implements Comparable, SchemaHolder {
public Schema getSchema() {
return schema;
}
+ public String getType() {
+ return this.type;
+ }
}
diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/bookmark/QueryNode.java b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/bookmark/QueryNode.java
index 4826003..2615a0a 100644
--- a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/bookmark/QueryNode.java
+++ b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/bookmark/QueryNode.java
@@ -24,6 +24,9 @@ public class QueryNode extends TreeNode {
String name = this.query.trim();
boolean trimmed = false;
name = name.replace('\n', ' ');
+ name = name.replace('\f', ' ');
+ name = name.replace('\r', ' ');
+ name = name.replace('\t', ' ');
if (name.length() > MAX_SIZE) {
name = name.substring(0, MAX_SIZE);
diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/bookmark/SchemaNode.java b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/bookmark/SchemaNode.java
index 4b6f3c3..5181d2e 100644
--- a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/bookmark/SchemaNode.java
+++ b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/bookmark/SchemaNode.java
@@ -1,6 +1,9 @@
package com.quantum.view.bookmark;
import java.sql.SQLException;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
import com.quantum.model.Bookmark;
import com.quantum.model.NotConnectedException;
@@ -37,14 +40,35 @@ public class SchemaNode extends TreeNode implements SchemaHolder {
}
protected void initializeChildren() {
+ boolean firstTimeInitialization = this.children.isEmpty();
+ boolean changed = false;
+ Map temp = new HashMap();
+ for (Iterator i = this.children.iterator(); i.hasNext();) {
+ GroupNode element = (GroupNode) i.next();
+ temp.put(element.getType(), element);
+ }
this.children.clear();
+
Bookmark bookmark = getBookmark();
try {
String[] types = bookmark.getDatabase().getEntityTypes();
for (int i = 0, length = (types == null) ? 0 : types.length;
i < length;
i++) {
- this.children.add(new GroupNode(this, this.schema, types[i]));
+ GroupNode node = (GroupNode) temp.remove(types[i]);
+ if (node == null) {
+ this.children.add(new GroupNode(this, this.schema, types[i]));
+ changed = true;
+ } else {
+ this.children.add(node);
+ }
+ }
+ for (Iterator i = temp.values().iterator(); i.hasNext();) {
+ ((GroupNode) i.next()).dispose();
+ changed = true;
+ }
+ if (!firstTimeInitialization && changed) {
+ firePropertyChange("children", null, null);
}
} catch (NotConnectedException e) {
} catch (SQLException e) {
@@ -69,9 +93,7 @@ public class SchemaNode extends TreeNode implements SchemaHolder {
* @see com.quantum.view.bookmark.TreeNode#getImageName()
*/
protected String getImageName() {
- return this.schema.isDefault()
- ? "user.gif"
- : this.schema.exists()
+ return this.schema.exists()
? "schema.gif"
: "missingschema.gif";
}
diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/bookmark/TreeNode.java b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/bookmark/TreeNode.java
index e3bf412..e4130b0 100644
--- a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/bookmark/TreeNode.java
+++ b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/bookmark/TreeNode.java
@@ -36,7 +36,7 @@ public abstract class TreeNode
public abstract String getName();
public Bookmark getBookmark() {
- return getParent().getBookmark();
+ return getParent() == null ? null : getParent().getBookmark();
}
public String getLabelName() {
@@ -99,6 +99,7 @@ public abstract class TreeNode
protected void dispose() {
this.disposed = true;
removeAllChildren();
+// this.parent = null;
}
protected void removeAllChildren() {
for (Iterator i = this.children.iterator(); i.hasNext();) {
@@ -115,6 +116,7 @@ public abstract class TreeNode
return null;
}
protected abstract void initializeChildren() throws SQLException, NotConnectedException;
+
public void reload() throws NotConnectedException, SQLException {
if (isInitialized()) {
initializeChildren();
diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/subset/ObjectNode.java b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/subset/ObjectNode.java
index 7d6fcf7..cfa3fbe 100644
--- a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/subset/ObjectNode.java
+++ b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/subset/ObjectNode.java
@@ -1,6 +1,5 @@
package com.quantum.view.subset;
-import com.quantum.IQuantumConstants;
import com.quantum.Messages;
import com.quantum.model.Entity;
import com.quantum.model.EntityHolder;
@@ -31,7 +30,7 @@ public class ObjectNode implements Comparable, EntityHolder {
public ObjectNode(){
}
public String getType(){
- return IQuantumConstants.View;
+ return Entity.VIEW_TYPE;
}
/* (non-Javadoc)
diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/tableview/ResultSetAction.java b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/tableview/ResultSetAction.java
index 03a7f55..8be4378 100644
--- a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/tableview/ResultSetAction.java
+++ b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/tableview/ResultSetAction.java
@@ -5,6 +5,7 @@ import java.sql.SQLException;
import com.quantum.sql.SQLResultSetResults;
import com.quantum.ui.dialog.ExceptionDisplayDialog;
+import com.quantum.ui.dialog.SQLExceptionDialog;
import com.quantum.util.connection.ConnectionUtil;
import org.eclipse.jface.viewers.ISelectionProvider;
@@ -40,7 +41,7 @@ public abstract class ResultSetAction extends SelectionListenerAction {
executeResultSetAction(results);
}
} catch (SQLException e) {
- ExceptionDisplayDialog.openError(getShell(), null, null, e);
+ SQLExceptionDialog.openException(getShell(), null, e);
} catch (RuntimeException e) {
ExceptionDisplayDialog.openError(getShell(), null, null, e);
}
diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/widget/ComboViewer.java b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/widget/ComboViewer.java
index 7dd692a..2b12aff 100644
--- a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/widget/ComboViewer.java
+++ b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/widget/ComboViewer.java
@@ -70,7 +70,7 @@ public class ComboViewer extends ContentViewer {
Object object = ((IStructuredSelection) selection).getFirstElement();
for (int i = 0, length = this.objects == null ? 0 : this.objects.length;
object != null && i < length; i++) {
- if (this.objects[i] == object) {
+ if (this.objects[i].equals(object)) {
this.combo.select(i);
}
}
diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/widget/SimpleLabelProvider.java b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/widget/SimpleLabelProvider.java
new file mode 100644
index 0000000..de0de7e
--- /dev/null
+++ b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/widget/SimpleLabelProvider.java
@@ -0,0 +1,32 @@
+package com.quantum.view.widget;
+
+import com.quantum.model.Displayable;
+
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.swt.graphics.Image;
+
+
+/**
+ * @author BC
+ */
+public class SimpleLabelProvider extends LabelProvider {
+
+ private final Image image;
+
+ public SimpleLabelProvider() {
+ this(null);
+ }
+ public SimpleLabelProvider(Image image) {
+ this.image = image;
+ }
+ public Image getImage(Object element) {
+ return this.image;
+ }
+ public String getText(Object element) {
+ if (element instanceof Displayable) {
+ return ((Displayable) element).getDisplayName();
+ } else {
+ return super.getText(element);
+ }
+ }
+}
diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/wizards/BaseSQLPage.java b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/wizards/BaseSQLPage.java
index 3c75b99..435f0cc 100644
--- a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/wizards/BaseSQLPage.java
+++ b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/wizards/BaseSQLPage.java
@@ -1,6 +1,7 @@
package com.quantum.wizards;
import java.sql.SQLException;
+import java.util.Arrays;
import com.quantum.adapters.DatabaseAdapter;
import com.quantum.model.Bookmark;
@@ -10,10 +11,12 @@ import com.quantum.model.NotConnectedException;
import com.quantum.sql.MultiSQLServer;
import com.quantum.sql.SQLResultSetResults;
import com.quantum.sql.SQLResults;
-import com.quantum.ui.dialog.ExceptionDisplayDialog;
+import com.quantum.ui.dialog.SQLExceptionDialog;
import com.quantum.util.connection.ConnectionUtil;
import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
/**
* @author BC Holmes
@@ -29,14 +32,14 @@ public abstract class BaseSQLPage extends WizardPage implements SQLPage {
super(pageName);
}
public boolean performFinish() {
+ Bookmark bookmark = this.results.getBookmark();
try {
- Bookmark bookmark = this.results.getBookmark();
bookmark.addQuery(getQueryText());
SQLResults sqlResults = MultiSQLServer.getInstance().execute(bookmark,
this.connectionUtil.getConnection(bookmark, getShell()), getQueryText());
return sqlResults == null ? false : true;
} catch (SQLException e) {
- ExceptionDisplayDialog.openError(getShell(), null, null, e);
+ SQLExceptionDialog.openException(getShell(), bookmark, e);
return false;
}
}
@@ -71,4 +74,25 @@ public abstract class BaseSQLPage extends WizardPage implements SQLPage {
this.results = results;
this.row = row;
}
+
+ /**
+ * @param table
+ * @param colName
+ * @param style
+ * @param pos
+ * @param width
+ */
+ protected void createTableColumn(Table table, String colName, int style, int pos, int width) {
+ TableColumn column = new TableColumn(table, style, pos);
+ column.setText(colName);
+ column.setWidth(width);
+ }
+
+ /**
+ * @param columnNames
+ * @return
+ */
+ protected java.util.List getColumnNamesAsList(String[] columnNames) {
+ return Arrays.asList(columnNames);
+ }
}
diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/wizards/BookmarkConnectionWizardPage.java b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/wizards/BookmarkConnectionWizardPage.java
index 36a4077..e76daaf 100644
--- a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/wizards/BookmarkConnectionWizardPage.java
+++ b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/wizards/BookmarkConnectionWizardPage.java
@@ -33,6 +33,7 @@ class BookmarkConnectionWizardPage extends PropertyChangeWizardPage {
private Text jdbcUrl;
private URLSetupControl urlSetupControl;
private Composite container;
+ private boolean requiresRebuild = false;
private PropertyChangeListener listener = new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent event) {
@@ -110,6 +111,13 @@ class BookmarkConnectionWizardPage extends PropertyChangeWizardPage {
setControl(container);
}
+ public void setVisible(boolean visible) {
+ if (visible && this.requiresRebuild) {
+ rebuildJDBCControls(this.driver);
+ }
+ super.setVisible(visible);
+ }
+
/**
* @param container
*/
@@ -145,7 +153,7 @@ class BookmarkConnectionWizardPage extends PropertyChangeWizardPage {
if (oldDriverClassName == null
|| !oldDriverClassName.equals(this.driver.getClassName())) {
- rebuildJDBCControls(this.driver);
+ this.requiresRebuild = true;
}
}
/**
diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/wizards/BookmarkWizard.java b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/wizards/BookmarkWizard.java
index 5ba3d54..a2e4f13 100644
--- a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/wizards/BookmarkWizard.java
+++ b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/wizards/BookmarkWizard.java
@@ -5,6 +5,7 @@ import java.beans.PropertyChangeListener;
import org.eclipse.jface.wizard.Wizard;
+import com.quantum.ImageStore;
import com.quantum.Messages;
import com.quantum.model.Bookmark;
import com.quantum.model.BookmarkCollection;
@@ -21,6 +22,7 @@ public class BookmarkWizard extends Wizard implements PropertyChangeListener {
public void init() {
setWindowTitle(Messages.getString("BookmarkWizard.NewBookmark")); //$NON-NLS-1$
+ setDefaultPageImageDescriptor(ImageStore.getImageDescriptor(ImageStore.NEW_BOOKMARK_WIZARD));
this.bookmark = new Bookmark();
}
public boolean performFinish() {
diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/wizards/ExportBookmarkWizardPage.java b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/wizards/ExportBookmarkWizardPage.java
index e8be91d..94dccdd 100644
--- a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/wizards/ExportBookmarkWizardPage.java
+++ b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/wizards/ExportBookmarkWizardPage.java
@@ -178,7 +178,6 @@ public class ExportBookmarkWizardPage extends WizardPage {
}
private void createDestinationArea(Composite composite) {
- GridData data;
Composite fileArea = new Composite(composite, SWT.NULL);
fileArea.setLayout(new GridLayout(3, false));
fileArea.setLayoutData(
@@ -187,7 +186,7 @@ public class ExportBookmarkWizardPage extends WizardPage {
label.setText("File name:");
this.fileNameText = new Text(fileArea, SWT.BORDER);
- data = new GridData();
+ GridData data = new GridData();
data.horizontalAlignment = GridData.HORIZONTAL_ALIGN_FILL;
data.widthHint = 300;
this.fileNameText.setLayoutData(data);
diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/wizards/InsertRowPage.java b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/wizards/InsertRowPage.java
index ecaf832..f25054d 100644
--- a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/wizards/InsertRowPage.java
+++ b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/wizards/InsertRowPage.java
@@ -1,62 +1,191 @@
package com.quantum.wizards;
+import java.util.Arrays;
+
+import org.eclipse.jface.viewers.CellEditor;
+import org.eclipse.jface.viewers.ICellModifier;
+import org.eclipse.jface.viewers.ILabelProviderListener;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.ITableLabelProvider;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.TextCellEditor;
+import org.eclipse.jface.viewers.Viewer;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+import org.eclipse.swt.widgets.TableItem;
import org.eclipse.swt.widgets.Text;
import com.quantum.Messages;
import com.quantum.adapters.DatabaseAdapter;
import com.quantum.model.Bookmark;
import com.quantum.model.Entity;
+import com.quantum.sql.SQLResultSetResults;
public class InsertRowPage extends BaseSQLPage implements SQLPage {
+
+ class InsertRowTableValues {
+ private String colNames = null;
+ private String values = null;
+
+ public InsertRowTableValues() {
+ }
+ /**
+ * @return Returns the colNames.
+ */
+ public String getColNames() {
+ return colNames;
+ }
+ /**
+ * @param colNames The colNames to set.
+ */
+ public void setColNames(String colNames) {
+ this.colNames = colNames;
+ }
+ /**
+ * @return Returns the values.
+ */
+ public String getValues() {
+ return values;
+ }
+ /**
+ * @param values The values to set.
+ */
+ public void setValues(String values) {
+ this.values = values;
+ }
+ }
+
+ class LabelProviderImpl implements ITableLabelProvider {
+ public Image getColumnImage(Object element, int columnIndex) {
+ return null;
+ }
+ public String getColumnText(Object element, int columnIndex) {
+ String sReturn = "";
+ InsertRowTableValues insertRow = (InsertRowTableValues)element;
+ switch (columnIndex) {
+ case 0:
+ sReturn = insertRow.getColNames();
+ break;
+ case 1:
+ sReturn = insertRow.getValues();
+ break;
+ default:
+ break;
+ }
+ return sReturn;
+ }
+ public void addListener(ILabelProviderListener listener) {}
+ public void dispose() {}
+ public boolean isLabelProperty(Object element, String property) {
+ return false;
+ }
+ public void removeListener(ILabelProviderListener listener) {}
+ }
+
+ class ContentProviderImpl implements IStructuredContentProvider {
+ public Object[] getElements(Object inputElement) {
+ return insertTable;
+ }
+
+ public void dispose() {}
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {}
+ }
+
+ class CellModifierImpl implements ICellModifier {
+
+ public boolean canModify(Object element, String property) {
+ return true;
+ }
+
+ public Object getValue(Object element, String property) {
+ System.out.println("getValue called");
+
+ // Find the index of the column
+ int colIndx = getColumnNamesAsList(colNames).indexOf(property);
+ System.out.println("colIndx : " + colIndx);
+
+ Object rResult = null;
+ InsertRowTableValues insertVal = (InsertRowTableValues)element;
+
+ switch (colIndx) {
+ case 0:
+ rResult = insertVal.getColNames();
+ break;
+ case 1:
+ rResult = insertVal.getValues();
+ break;
+ default:
+ rResult = "";
+ break;
+ }
+
+ return rResult;
+ }
+
+ public void modify(Object element, String property, Object value) {
+ int colIndx = getColumnNamesAsList(colNames).indexOf(property);
+
+ TableItem item = (TableItem) element;
+ InsertRowTableValues insertVal = (InsertRowTableValues)item.getData();
+
+ switch (colIndx) {
+ case 0: // field names
+ break;
+ case 1: // field values
+ insertVal.setValues(value.toString());
+ updateView();
+ updateQuery();
+ break;
+ default:
+ break;
+ }
+ }
+ }
+
String[] columnNames;
+ String[] colNames;
Text[] values;
Label query;
+ InsertRowTableValues[] insertTable = null;
+ TableViewer tableViewer = null;
int numColumns = 0;
public InsertRowPage(String pageName) {
- super(pageName);
+ super(pageName);
}
public void createControl(Composite parent) {
System.out.println("page create control"); //$NON-NLS-1$
- Composite container = new Composite(parent, SWT.V_SCROLL);
- GridLayout layout = new GridLayout();
- container.setLayout(layout);
- layout.numColumns = 2;
+ Composite container = new Composite(parent, SWT.NULL);
+ container.setLayout(new GridLayout());
+ container.setLayoutData(new GridData(GridData.FILL_BOTH | GridData.VERTICAL_ALIGN_BEGINNING));
+ // init values to be displayed on the table
columnNames = this.results.getColumnNames();
- values = new Text[columnNames.length];
- new Label(container, SWT.NULL).setText(Messages.getString("InsertRowPage.ColumnName")); //$NON-NLS-1$
- new Label(container, SWT.NULL).setText(Messages.getString("InsertRowPage.Value")); //$NON-NLS-1$
- for (int i = 0; i < columnNames.length; i++) {
- Label label = new Label(container, SWT.NULL);
- label.setText(columnNames[i]);
- values[i] = new Text(container, SWT.BORDER | SWT.SINGLE);
- GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
- gridData.widthHint = 150;
- values[i].setLayoutData(gridData);
-
- //values[i].setText(data[i]);
- values[i].addModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- updateQuery();
- }
- });
- }
+ int nLen = columnNames.length;
+ insertTable = new InsertRowTableValues[nLen];
+
+ for (int nCtr=0; nCtr 0) {
+ String name = insertTable[i].getColNames();
+ String value = insertTable[i].getValues();
+ if (value != null && value.length() > 0) {
if (numColumns > 0) {
valuesClause.append(", "); //$NON-NLS-1$
namesClause.append(", ");
@@ -101,4 +230,38 @@ public class InsertRowPage extends BaseSQLPage implements SQLPage {
protected String getQueryText() {
return this.query.getText();
}
+
+ private void createTable(Composite composite) {
+ System.out.println("Creating table...");
+ int style = SWT.SINGLE | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.HIDE_SELECTION;
+ Table table = new Table(composite, style);
+ table.setHeaderVisible(true);
+ table.setLinesVisible(true);
+ table.setLayoutData(new GridData(GridData.FILL_BOTH | GridData.VERTICAL_ALIGN_BEGINNING));
+
+ colNames = new String[] { Messages.getString("InsertRowPage.ColumnName"), Messages.getString("InsertRowPage.Value") };
+
+ createTableColumn(table, colNames[0], SWT.LEFT, 0, 200);
+ createTableColumn(table, colNames[1], SWT.LEFT, 1, 500);
+ this.tableViewer = new TableViewer(table);
+ this.tableViewer.setColumnProperties(colNames);
+
+ CellEditor[] editor = new CellEditor[colNames.length];
+ TextCellEditor txtEditorField = new TextCellEditor(table);
+ txtEditorField.getControl().setEnabled(false);
+ editor[0] = txtEditorField;
+
+ TextCellEditor txtEditorValues = new TextCellEditor(table);
+ editor[1] = txtEditorValues;
+
+ this.tableViewer.setCellEditors(editor);
+ this.tableViewer.setLabelProvider(new LabelProviderImpl());
+ this.tableViewer.setContentProvider(new ContentProviderImpl());
+ this.tableViewer.setCellModifier(new CellModifierImpl());
+ this.tableViewer.setInput(insertTable);
+ }
+
+ private void updateView() {
+ this.tableViewer.update(insertTable, null);
+ }
}
\ No newline at end of file
diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/wizards/SortFilterPage.java b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/wizards/SortFilterPage.java
index 4447e10..e0500bd 100644
--- a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/wizards/SortFilterPage.java
+++ b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/wizards/SortFilterPage.java
@@ -4,7 +4,7 @@ import java.sql.SQLException;
import com.quantum.sql.FilterSort;
import com.quantum.sql.SQLResultSetResults;
-import com.quantum.ui.dialog.ExceptionDisplayDialog;
+import com.quantum.ui.dialog.SQLExceptionDialog;
import com.quantum.util.connection.ConnectionUtil;
import org.eclipse.jface.wizard.WizardPage;
@@ -170,7 +170,7 @@ public class SortFilterPage extends WizardPage implements SQLPage {
this.results.getBookmark(), getShell()));
return true;
} catch (SQLException e) {
- ExceptionDisplayDialog.openError(getShell(), null, null, e);
+ SQLExceptionDialog.openException(getShell(), this.results.getBookmark(), e);
return false;
}
}
diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/wizards/UpdateRowPage.java b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/wizards/UpdateRowPage.java
index 3753b7c..031ed9f 100644
--- a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/wizards/UpdateRowPage.java
+++ b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/wizards/UpdateRowPage.java
@@ -1,112 +1,286 @@
package com.quantum.wizards;
+import java.util.Arrays;
+
+import org.eclipse.jface.viewers.CellEditor;
+import org.eclipse.jface.viewers.CheckboxCellEditor;
+import org.eclipse.jface.viewers.ICellModifier;
+import org.eclipse.jface.viewers.ILabelProviderListener;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.ITableLabelProvider;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.TextCellEditor;
+import org.eclipse.jface.viewers.Viewer;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+import org.eclipse.swt.widgets.TableItem;
import org.eclipse.swt.widgets.Text;
+import com.quantum.ImageStore;
import com.quantum.Messages;
import com.quantum.adapters.DatabaseAdapter;
import com.quantum.model.Bookmark;
import com.quantum.model.Column;
import com.quantum.model.Entity;
+import com.quantum.wizards.InsertRowPage.CellModifierImpl;
+import com.quantum.wizards.InsertRowPage.ContentProviderImpl;
+import com.quantum.wizards.InsertRowPage.InsertRowTableValues;
+import com.quantum.wizards.InsertRowPage.LabelProviderImpl;
public class UpdateRowPage extends BaseSQLPage implements SQLPage {
+
+ class UpdateRowTableValues {
+ private String sColNames = null;
+ private String sOldValue = null;
+ private boolean bPrimary = false;
+ private String sNewValue = null;
+ private boolean bSetValue = false;
+
+ public UpdateRowTableValues() {
+ }
+ /**
+ * @return Returns the bSetValue.
+ */
+ public boolean isBSetValue() {
+ return bSetValue;
+ }
+ /**
+ * @param setValue The bSetValue to set.
+ */
+ public void setBSetValue(boolean setValue) {
+ bSetValue = setValue;
+ }
+ /**
+ * @return Returns the bPrimary.
+ */
+ public boolean isBPrimary() {
+ return bPrimary;
+ }
+ /**
+ * @param where The bPrimary to set.
+ */
+ public void setBPrimary(boolean where) {
+ bPrimary = where;
+ }
+ /**
+ * @return Returns the sColNames.
+ */
+ public String getSColNames() {
+ return sColNames;
+ }
+ /**
+ * @param colNames The sColNames to set.
+ */
+ public void setSColNames(String colNames) {
+ sColNames = colNames;
+ }
+ /**
+ * @return Returns the sNewValue.
+ */
+ public String getSNewValue() {
+ return sNewValue;
+ }
+ /**
+ * @param newValue The sNewValue to set.
+ */
+ public void setSNewValue(String newValue) {
+ sNewValue = newValue;
+ }
+ /**
+ * @return Returns the sOldValue.
+ */
+ public String getSOldValue() {
+ return sOldValue;
+ }
+ /**
+ * @param oldValue The sOldValue to set.
+ */
+ public void setSOldValue(String oldValue) {
+ sOldValue = oldValue;
+ }
+ }
+
+ class LabelProviderImpl implements ITableLabelProvider {
+ public Image getColumnImage(Object element, int columnIndex) {
+ if (columnIndex == 2) {
+ return ((UpdateRowTableValues)element).isBPrimary() ? imgCheck : imgUncheck;
+ } else if (columnIndex == 4) {
+ return ((UpdateRowTableValues)element).isBSetValue() ? imgCheck : imgUncheck;
+ } else {
+ return null;
+ }
+ }
+ public String getColumnText(Object element, int columnIndex) {
+ String sReturn = "";
+ UpdateRowTableValues updateRow = (UpdateRowTableValues)element;
+ switch (columnIndex) {
+ case 0: // column names
+ sReturn = updateRow.getSColNames();
+ break;
+ case 1: // old values
+ sReturn = updateRow.getSOldValue();
+ break;
+ case 2: // set checkbox
+ break;
+ case 3: // new value
+ sReturn = updateRow.getSNewValue();
+ break;
+ case 4: // set value checkbox
+ break;
+ default:
+ break;
+ }
+ return sReturn;
+ }
+ public void addListener(ILabelProviderListener listener) {}
+ public void dispose() {}
+ public boolean isLabelProperty(Object element, String property) {
+ return false;
+ }
+ public void removeListener(ILabelProviderListener listener) {}
+ }
+
+ class ContentProviderImpl implements IStructuredContentProvider {
+ public Object[] getElements(Object inputElement) {
+ return updateTable;
+ }
+
+ public void dispose() {}
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {}
+ }
+
+ class CellModifierImpl implements ICellModifier {
+
+ public boolean canModify(Object element, String property) {
+ return true;
+ }
+
+ public Object getValue(Object element, String property) {
+ System.out.println("getValue called");
+
+ // Find the index of the column
+ int colIndx = getColumnNamesAsList(colNames).indexOf(property);
+ System.out.println("colIndx : " + colIndx);
+
+ Object rResult = null;
+ UpdateRowTableValues updateVal = (UpdateRowTableValues)element;
+
+ switch (colIndx) {
+ case 0: // column names
+ rResult = updateVal.getSColNames();
+ break;
+ case 1: // old values
+ rResult = updateVal.getSOldValue();
+ break;
+ case 2: // set checkbox
+ rResult = new Boolean(updateVal.isBPrimary());
+ break;
+ case 3: // new value
+ rResult = updateVal.getSNewValue();
+ break;
+ case 4: // set value checkbox
+ rResult = new Boolean(updateVal.isBSetValue());
+ break;
+ default:
+ break;
+ }
+
+ return rResult;
+ }
+
+ public void modify(Object element, String property, Object value) {
+ int colIndx = getColumnNamesAsList(colNames).indexOf(property);
+
+ TableItem item = (TableItem) element;
+ UpdateRowTableValues updateVal = (UpdateRowTableValues)item.getData();
+
+ switch (colIndx) {
+ case 0: // column names
+ break;
+ case 1: // old values
+ break;
+ case 2: // set checkbox
+ updateVal.setBPrimary(((Boolean)value).booleanValue());
+ break;
+ case 3: // new value
+ updateVal.setSNewValue(value.toString());
+ break;
+ case 4: // set value checkbox
+ updateVal.setBSetValue(((Boolean)value).booleanValue());
+ break;
+ default:
+ break;
+ }
+
+ updateView();
+ updateQuery();
+ }
+ }
+
String[] columnNames;
+ String[] colNames;
Text[] oldValues;
Text[] newValues;
Button[] primaryKeys;
Button[] setValues;
Label query;
+ UpdateRowTableValues[] updateTable = null;
+ TableViewer tableViewer = null;
+ static Image imgCheck = null;
+ static Image imgUncheck = null;
+
+ static {
+ imgCheck = ImageStore.getImage(ImageStore.CHECKED);
+ imgUncheck = ImageStore.getImage(ImageStore.UNCHECKED);
+ }
+
public UpdateRowPage(String pageName) {
super(pageName);
}
public void createControl(Composite parent) {
System.out.println("page create control"); //$NON-NLS-1$
- Composite container = new Composite(parent, SWT.V_SCROLL);
- GridLayout layout = new GridLayout();
- container.setLayout(layout);
+ Composite container = new Composite(parent, SWT.NULL);
+ container.setLayout(new GridLayout());
+ container.setLayoutData(new GridData(GridData.FILL_BOTH | GridData.VERTICAL_ALIGN_BEGINNING));
+
Entity entity = this.results.getEntity();
- int layoutColumns = 5;
- layout.numColumns = layoutColumns;
-
+ // init values to be displayed on the table
columnNames = this.results.getColumnNames();
- oldValues = new Text[columnNames.length];
- newValues = new Text[columnNames.length];
- primaryKeys = new Button[columnNames.length];
- setValues = new Button[columnNames.length];
- Label temp = new Label(container, SWT.NULL);
- temp.setText(Messages.getString("UpdateRowPage.ColumnName")); //$NON-NLS-1$
- temp = new Label(container, SWT.NULL);
- temp.setText(Messages.getString("UpdateRowPage.OldValue")); //$NON-NLS-1$
- temp = new Label(container, SWT.NULL);
- temp.setText(""); //$NON-NLS-1$
- temp = new Label(container, SWT.NULL);
- temp.setText(Messages.getString("UpdateRowPage.NewValue")); //$NON-NLS-1$
- temp = new Label(container, SWT.NULL);
- temp.setText(Messages.getString("UpdateRowPage._13")); //$NON-NLS-1$
- for (int i = 0; i < columnNames.length; i++) {
- Label label = new Label(container, SWT.NULL);
- label.setText(columnNames[i]);
- oldValues[i] = new Text(container, SWT.BORDER | SWT.SINGLE);
- GridData gridData = new GridData();
- gridData.widthHint = 100;
- oldValues[i].setLayoutData(gridData);
- Object data = this.row == null ? null : this.row.get(i+1);
- oldValues[i].setText(data == null ? "" : data.toString());
- oldValues[i].addModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- updateQuery();
- }
- });
- primaryKeys[i] = new Button(container, SWT.CHECK);
- primaryKeys[i].setText("Where"); //$NON-NLS-1$
- Column column = (entity == null) ? null : getColumn(entity, columnNames[i]);
- if (column != null && column.isPrimaryKey())
- primaryKeys[i].setSelection(true);
- primaryKeys[i].addSelectionListener(new SelectionListener() {
- public void widgetDefaultSelected(SelectionEvent e) {
- }
- public void widgetSelected(SelectionEvent e) {
- updateQuery();
- }
- });
- newValues[i] = new Text(container, SWT.BORDER | SWT.SINGLE);
- newValues[i].setText(data == null ? "" : data.toString());
- gridData = new GridData();
- gridData.widthHint = 100;
- newValues[i].setLayoutData(gridData);
- newValues[i].addModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- updateQuery();
- }
- });
- setValues[i] = new Button(container, SWT.CHECK);
- setValues[i].setText(Messages.getString("UpdateRowPage.SetValue")); //$NON-NLS-1$
- setValues[i].addSelectionListener(new SelectionListener() {
- public void widgetDefaultSelected(SelectionEvent e) {
- }
- public void widgetSelected(SelectionEvent e) {
- updateQuery();
- }
- });
+ int nLen = columnNames.length;
+ updateTable = new UpdateRowTableValues[nLen];
+
+ for(int nCtr=0; nCtr 0) whereClause.append(" AND "); //$NON-NLS-1$
whereClause.append("("); //$NON-NLS-1$
- whereClause.append(columnNames[i]);
+ whereClause.append(updateTable[nCtr].getSColNames());
whereClause.append(" = "); //$NON-NLS-1$
- appendColumn(whereClause, entity, columnNames[i], adapter, value);
+ appendColumn(whereClause, entity, updateTable[nCtr].getSColNames(), adapter, value);
whereClause.append(")"); //$NON-NLS-1$
numValuesWhere++;
}
- if (setValues[i].getSelection()) {
- String value = newValues[i].getText();
+ if (updateTable[nCtr].isBSetValue()) {
+ String value = updateTable[nCtr].getSNewValue();
if (numValuesSet > 0) setClause.append(", "); //$NON-NLS-1$
- setClause.append(columnNames[i]);
+ setClause.append(updateTable[nCtr].getSColNames());
setClause.append(" = "); //$NON-NLS-1$
- appendColumn(setClause, entity, columnNames[i], adapter, value);
+ appendColumn(setClause, entity, updateTable[nCtr].getSColNames(), adapter, value);
numValuesSet++;
}
}
+
String query = "UPDATE " + this.results.getEntity().getQuotedTableName(); //$NON-NLS-1$
query += " SET " + setClause.toString(); //$NON-NLS-1$
query += " WHERE " + whereClause.toString(); //$NON-NLS-1$
@@ -156,5 +331,52 @@ public class UpdateRowPage extends BaseSQLPage implements SQLPage {
protected String getQueryText() {
return query.getText();
}
+
+ private void updateView() {
+ this.tableViewer.update(updateTable, null);
+ }
+
+ private void createTable(Composite composite) {
+ System.out.println("Creating table...");
+ int style = SWT.SINGLE | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.HIDE_SELECTION;
+ Table table = new Table(composite, style);
+ table.setHeaderVisible(true);
+ table.setLinesVisible(true);
+ table.setLayoutData(new GridData(GridData.FILL_BOTH | GridData.VERTICAL_ALIGN_BEGINNING));
+
+ colNames = new String[] { Messages.getString("UpdateRowPage.ColumnName"), Messages.getString("UpdateRowPage.OldValue"),
+ "Where", Messages.getString("UpdateRowPage.NewValue"), Messages.getString("UpdateRowPage.SetValue") };
+ createTableColumn(table, colNames[0], SWT.LEFT, 0, 150);
+ createTableColumn(table, colNames[1], SWT.LEFT, 1, 300);
+ createTableColumn(table, colNames[2], SWT.CENTER, 2, 60);
+ createTableColumn(table, colNames[3], SWT.LEFT, 3, 300);
+ createTableColumn(table, colNames[4], SWT.CENTER, 4, 70);
+ this.tableViewer = new TableViewer(table);
+ this.tableViewer.setColumnProperties(colNames);
+
+ CellEditor[] editor = new CellEditor[colNames.length];
+ TextCellEditor txtEditorField = new TextCellEditor(table);
+ txtEditorField.getControl().setEnabled(false);
+ editor[0] = txtEditorField;
+
+ TextCellEditor txtEditorFieldOld = new TextCellEditor(table);
+ txtEditorFieldOld.getControl().setEnabled(false);
+ editor[1] = txtEditorFieldOld;
+
+ editor[2] = new CheckboxCellEditor(table, SWT.NULL);
+
+ TextCellEditor txtEditorValues = new TextCellEditor(table);
+ editor[3] = txtEditorValues;
+
+ editor[4] = new CheckboxCellEditor(table, SWT.NULL);
+
+ this.tableViewer.setCellEditors(editor);
+ this.tableViewer.setLabelProvider(new LabelProviderImpl());
+ this.tableViewer.setContentProvider(new ContentProviderImpl());
+ this.tableViewer.setCellModifier(new CellModifierImpl());
+ this.tableViewer.setInput(updateTable);
+ }
+
+
}
\ No newline at end of file
diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/wizards/sql/DropEntityWizardPage.java b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/wizards/sql/DropEntityWizardPage.java
new file mode 100644
index 0000000..b7b9cd6
--- /dev/null
+++ b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/wizards/sql/DropEntityWizardPage.java
@@ -0,0 +1,68 @@
+package com.quantum.wizards.sql;
+
+import com.quantum.sql.parser.DropEntityStatement;
+import com.quantum.wizards.PropertyChangeWizardPage;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+
+
+/**
+ * @author BC Holmes
+ */
+public class DropEntityWizardPage extends PropertyChangeWizardPage {
+
+ private final DropEntityStatement dropEntityStatement;
+
+ /**
+ * @param pageName
+ */
+ public DropEntityWizardPage(String pageName, DropEntityStatement dropEntityStatement) {
+ super(pageName);
+ this.dropEntityStatement = dropEntityStatement;
+ setTitle("Drop Parameters");
+ setDescription("Choose your drop parameters");
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
+ */
+ public void createControl(Composite parent) {
+ Composite composite = new Composite(parent, SWT.NONE);
+ composite.setLayout(new GridLayout(2, false));
+ composite.setLayoutData(new GridData(GridData.FILL_BOTH));
+
+ Label label = new Label(composite, SWT.NONE);
+ label.setText("Entity:");
+
+ Text text = new Text(composite, SWT.BORDER | SWT.READ_ONLY);
+ text.setText(this.dropEntityStatement.getTableName());
+ text.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+ label = new Label(composite, SWT.NONE);
+ label.setText("How to handle dependent entities:");
+
+ final Combo combo = new Combo(composite, SWT.READ_ONLY);
+ combo.setItems(new String[] { "", "CASCADE", "RESTRICT" });
+ combo.select(0);
+ combo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+ combo.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent event) {
+ String rule = combo.getItem(combo.getSelectionIndex());
+ dropEntityStatement.setDependentRule(rule);
+
+ firePropertyChange("sqlStatement", null, dropEntityStatement.toString());
+ }
+ });
+
+ setControl(composite);
+ }
+}
diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/wizards/sql/SQLStatementWizard.java b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/wizards/sql/SQLStatementWizard.java
new file mode 100644
index 0000000..25adccf
--- /dev/null
+++ b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/wizards/sql/SQLStatementWizard.java
@@ -0,0 +1,64 @@
+package com.quantum.wizards.sql;
+
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+
+import com.quantum.sql.parser.SQL;
+import com.quantum.wizards.PropertyChangeWizardPage;
+
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.jface.wizard.WizardPage;
+
+/**
+ * @author BC Holmes
+ */
+public class SQLStatementWizard extends Wizard implements PropertyChangeListener {
+
+ private List wizardPages = Collections.synchronizedList(new ArrayList());
+ private ShowSQLStatementWizardPage finalPage;
+
+ public SQLStatementWizard(WizardPage[] pages, SQL sql) {
+ setWindowTitle("SQL Statement: " + sql.getCommand());
+
+ for (int i = 0, length = pages == null ? 0 : pages.length; i < length; i++) {
+ this.wizardPages.add(pages[i]);
+ }
+ this.finalPage = new ShowSQLStatementWizardPage("finalPage");
+ this.finalPage.setSQLStatement(sql == null ? "" : sql.toString());
+ }
+
+ public void addPages() {
+ for (Iterator i = this.wizardPages.iterator(); i.hasNext();) {
+ WizardPage wizardPage = (WizardPage) i.next();
+ addPage(wizardPage);
+ if (wizardPage instanceof PropertyChangeWizardPage) {
+ ((PropertyChangeWizardPage) wizardPage).addPropertyChangeListener(this);
+ }
+ }
+ addPage(this.finalPage);
+ }
+
+ public void dispose() {
+ for (Iterator i = this.wizardPages.iterator(); i.hasNext();) {
+ WizardPage wizardPage = (WizardPage) i.next();
+ if (wizardPage instanceof PropertyChangeWizardPage) {
+ ((PropertyChangeWizardPage) wizardPage).removePropertyChangeListener(this);
+ }
+ }
+ super.dispose();
+ }
+
+ public boolean performFinish() {
+ return true;
+ }
+
+ public void propertyChange(PropertyChangeEvent event) {
+ if ("sqlStatement".equals(event.getPropertyName())) {
+ this.finalPage.setSQLStatement((String) event.getNewValue());
+ }
+ }
+}
diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/wizards/sql/ShowSQLStatementWizardPage.java b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/wizards/sql/ShowSQLStatementWizardPage.java
new file mode 100644
index 0000000..1872220
--- /dev/null
+++ b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/wizards/sql/ShowSQLStatementWizardPage.java
@@ -0,0 +1,62 @@
+package com.quantum.wizards.sql;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+
+/**
+ * @author BC
+ */
+public class ShowSQLStatementWizardPage extends WizardPage {
+
+ private Text text;
+ private String sqlStatement;
+
+ /**
+ * @param pageName
+ * @param title
+ * @param titleImage
+ */
+ public ShowSQLStatementWizardPage(String pageName, String title,
+ ImageDescriptor titleImage) {
+ super(pageName, title, titleImage);
+ }
+
+ /**
+ * @param pageName
+ */
+ protected ShowSQLStatementWizardPage(String pageName) {
+ super(pageName);
+ setTitle("Final SQL Statement");
+ setDescription("Review the final SQL Statement before executing it");
+ }
+
+ public void createControl(Composite parent) {
+ Composite composite = new Composite(parent, SWT.NONE);
+ composite.setLayout(new GridLayout(1, false));
+ composite.setLayoutData(new GridData(GridData.FILL_BOTH));
+
+ Label label = new Label(composite, SWT.NONE);
+ label.setText("SQL Statement");
+
+ this.text = new Text(composite, SWT.MULTI | SWT.READ_ONLY | SWT.BORDER);
+ this.text.setText(this.sqlStatement == null ? "" : this.sqlStatement);
+ this.text.setLayoutData(new GridData(GridData.FILL_BOTH));
+
+ setControl(composite);
+ }
+ public String getSQLStatement() {
+ return this.sqlStatement;
+ }
+ public void setSQLStatement(String sqlStatement) {
+ this.sqlStatement = sqlStatement;
+ if (this.text != null) {
+ this.text.setText(this.sqlStatement == null ? "" : this.sqlStatement);
+ }
+ }
+}
--
1.7.1