From: khartlage Date: Sat, 3 Jul 2004 17:39:31 +0000 (+0000) Subject: newest quantum CVS sources X-Git-Url: http://git.phpeclipse.com newest quantum CVS sources --- diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/icons/close.gif b/archive/net.sourceforge.phpeclipse.quantum.sql/icons/close.gif index fed9c3b..3fb8662 100644 Binary files a/archive/net.sourceforge.phpeclipse.quantum.sql/icons/close.gif and b/archive/net.sourceforge.phpeclipse.quantum.sql/icons/close.gif differ diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/icons/close_2x.gif b/archive/net.sourceforge.phpeclipse.quantum.sql/icons/close_2x.gif new file mode 100644 index 0000000..29a8bac Binary files /dev/null and b/archive/net.sourceforge.phpeclipse.quantum.sql/icons/close_2x.gif differ diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/icons/copy.gif b/archive/net.sourceforge.phpeclipse.quantum.sql/icons/copy.gif index fa98681..ddfc57a 100644 Binary files a/archive/net.sourceforge.phpeclipse.quantum.sql/icons/copy.gif and b/archive/net.sourceforge.phpeclipse.quantum.sql/icons/copy.gif differ diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/icons/copy_2x.gif b/archive/net.sourceforge.phpeclipse.quantum.sql/icons/copy_2x.gif new file mode 100644 index 0000000..5c02d9f Binary files /dev/null and b/archive/net.sourceforge.phpeclipse.quantum.sql/icons/copy_2x.gif differ diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/icons/delete.gif b/archive/net.sourceforge.phpeclipse.quantum.sql/icons/delete.gif index 7f50621..97a78f7 100644 Binary files a/archive/net.sourceforge.phpeclipse.quantum.sql/icons/delete.gif and b/archive/net.sourceforge.phpeclipse.quantum.sql/icons/delete.gif differ diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/icons/delete_2x.gif b/archive/net.sourceforge.phpeclipse.quantum.sql/icons/delete_2x.gif new file mode 100644 index 0000000..7f50621 Binary files /dev/null and b/archive/net.sourceforge.phpeclipse.quantum.sql/icons/delete_2x.gif differ diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/icons/export.gif b/archive/net.sourceforge.phpeclipse.quantum.sql/icons/export.gif index c501e51..807c2d2 100644 Binary files a/archive/net.sourceforge.phpeclipse.quantum.sql/icons/export.gif and b/archive/net.sourceforge.phpeclipse.quantum.sql/icons/export.gif differ diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/icons/export_2x.gif b/archive/net.sourceforge.phpeclipse.quantum.sql/icons/export_2x.gif new file mode 100644 index 0000000..c501e51 Binary files /dev/null and b/archive/net.sourceforge.phpeclipse.quantum.sql/icons/export_2x.gif differ diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/icons/import.gif b/archive/net.sourceforge.phpeclipse.quantum.sql/icons/import.gif index 2191d13..990d4b3 100644 Binary files a/archive/net.sourceforge.phpeclipse.quantum.sql/icons/import.gif and b/archive/net.sourceforge.phpeclipse.quantum.sql/icons/import.gif differ diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/icons/import_2x.gif b/archive/net.sourceforge.phpeclipse.quantum.sql/icons/import_2x.gif new file mode 100644 index 0000000..2191d13 Binary files /dev/null and b/archive/net.sourceforge.phpeclipse.quantum.sql/icons/import_2x.gif differ diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/icons/paste.gif b/archive/net.sourceforge.phpeclipse.quantum.sql/icons/paste.gif index f118c7e..62cbe07 100644 Binary files a/archive/net.sourceforge.phpeclipse.quantum.sql/icons/paste.gif and b/archive/net.sourceforge.phpeclipse.quantum.sql/icons/paste.gif differ diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/icons/paste_2x.gif b/archive/net.sourceforge.phpeclipse.quantum.sql/icons/paste_2x.gif new file mode 100644 index 0000000..040d7ef Binary files /dev/null and b/archive/net.sourceforge.phpeclipse.quantum.sql/icons/paste_2x.gif differ diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/icons/play.gif b/archive/net.sourceforge.phpeclipse.quantum.sql/icons/play.gif index a8bfcf5..1328a4e 100644 Binary files a/archive/net.sourceforge.phpeclipse.quantum.sql/icons/play.gif and b/archive/net.sourceforge.phpeclipse.quantum.sql/icons/play.gif differ diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/icons/refresh.gif b/archive/net.sourceforge.phpeclipse.quantum.sql/icons/refresh.gif index aa450f7..7aff1a9 100644 Binary files a/archive/net.sourceforge.phpeclipse.quantum.sql/icons/refresh.gif and b/archive/net.sourceforge.phpeclipse.quantum.sql/icons/refresh.gif differ diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/icons/refresh_2x.gif b/archive/net.sourceforge.phpeclipse.quantum.sql/icons/refresh_2x.gif new file mode 100644 index 0000000..aa450f7 Binary files /dev/null and b/archive/net.sourceforge.phpeclipse.quantum.sql/icons/refresh_2x.gif differ diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/icons/template.gif b/archive/net.sourceforge.phpeclipse.quantum.sql/icons/template.gif new file mode 100644 index 0000000..bfee10d Binary files /dev/null and b/archive/net.sourceforge.phpeclipse.quantum.sql/icons/template.gif differ diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/plugin.xml b/archive/net.sourceforge.phpeclipse.quantum.sql/plugin.xml index ffc897b..bc0c025 100644 --- a/archive/net.sourceforge.phpeclipse.quantum.sql/plugin.xml +++ b/archive/net.sourceforge.phpeclipse.quantum.sql/plugin.xml @@ -3,7 +3,7 @@ @@ -119,6 +119,12 @@ class="com.quantum.view.SQLLogView" id="com.quantum.view.logview"> + + 0; + } + + Object[] getResults() { + return new Object[] { + new Integer(this.resultCount), + new Integer(this.resultUpdateCount), + new Integer(this.resultsDisplayed), + new Integer(this.errorCount), + new Double(this.queryDuration), + }; + } + } + + private ConnectionUtil connectionUtil = new ConnectionUtil(); + + protected abstract Shell getShell(); + + protected Connection getConnection(Bookmark bookmark) { + return this.connectionUtil.getConnection(bookmark, getShell()); + } + + String execute1 = Messages.getString(BaseExecuteAction.class, "execute1"); + String execute2 = Messages.getString(BaseExecuteAction.class, "execute2"); + + public void run() { + Bookmark bookmark = getBookmark(); + if (bookmark != null) { + execute(bookmark); + } + } + + /** + * @param bookmark + */ + protected void execute(Bookmark bookmark) { + if (bookmark != null) { + try { + getStatusLineManager().setErrorMessage(null); + Connection connection = getConnection(bookmark); + if (connection != null) { + execute(bookmark, connection); + } + } catch (IOException e) { + ExceptionDisplayDialog.openError(getShell(), null, null, e); + } catch (SQLException e) { + ExceptionDisplayDialog.openError(getShell(), null, null, e); + } catch (CoreException e) { + ErrorDialog.openError(getShell(), null, null, e.getStatus()); + } + } + } + + /** + * @param bookmark + * @param connection + * @throws IOException + * @throws CoreException + */ + protected void execute(Bookmark bookmark, Connection connection) + throws IOException, CoreException, SQLException { + getStatusLineManager().setMessage(execute1); + MultiSQLServer server = MultiSQLServer.getInstance(); + + Metrics metrics = new Metrics(); + + List queries = getQueries(); + IProgressMonitor progressBar = getStatusLineManager().getProgressMonitor(); + progressBar.beginTask("queries", queries.size()); + for (int i = 0; i < queries.size(); i++) { + getStatusLineManager().setMessage((i % 2 == 0) ? execute1 : execute2); + + String query = (String) queries.get(i); + System.out.println(">" + query + "<"); //$NON-NLS-1$ //$NON-NLS-2$ + if (query != null && query.trim().length() > 0) { + SQLResults results = getSQLResults(connection, server, query); + metrics.measure(results); + if (results != null) { + bookmark.addQuery(query); + if (results.isResultSet()) { + TableView.getInstance().loadQuery(bookmark, results); + } + } + } + progressBar.worked(i); + } + progressBar.done(); + displayFinalStatusMessage(metrics); + } + + /** + * @return + * @throws CoreException + * @throws IOException + */ + protected abstract List getQueries() throws IOException, CoreException; + + /** + * @return + */ + protected abstract IStatusLineManager getStatusLineManager(); + + /** + * @param metrics + */ + private void displayFinalStatusMessage(Metrics metrics) { + String message = Messages.getString( + BaseExecuteAction.class, + "done", //$NON-NLS-1$ //$NON-NLS-2$ + metrics.getResults()); + if (metrics.hasErrors()) { + getStatusLineManager().setErrorMessage( + ImageStore.getImage(ImageStore.STOP), message); + } else { + getStatusLineManager().setMessage( + ImageStore.getImage(ImageStore.SUCCESS), message); + } + } + + /** + * @param connection + * @param server + * @param query + * @return + */ + private SQLResults getSQLResults(Connection connection, MultiSQLServer server, String query) { + SQLResults results = null; + try { + results = server.execute(connection, query, 1, + DefaultSizes.PAGE_SIZE, DefaultSizes.MAX_COLUMN_SIZE); + } catch (SQLException e) { + LogProxy log = LogProxy.getInstance(); + log.addText(LogProxy.ERROR, + "Error Executing: " + query + ":" + e.toString(), e); //$NON-NLS-1$ //$NON-NLS-2$ + MessageDialog.openConfirm(getShell(), + "Database returned error", + e.getLocalizedMessage()); //$NON-NLS-1$ + } + return results; + } + + protected Bookmark getBookmark() { + Bookmark bookmark = null; + SimpleSelectionDialog dialog = new SimpleSelectionDialog( + getShell(), + Messages.getString(BaseExecuteAction.class, "selectBookmark"), + BookmarkCollection.getInstance().getBookmarks(), + ImageStore.getImage(ImageStore.BOOKMARK)); + if (SimpleSelectionDialog.OK == dialog.open()) { + IStructuredSelection selection = dialog.getSelection(); + + bookmark = (Bookmark) selection.getFirstElement(); + } + return bookmark; + } +} diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/actions/ConnectAction.java b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/actions/ConnectAction.java index 05eeed9..ba99f42 100644 --- a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/actions/ConnectAction.java +++ b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/actions/ConnectAction.java @@ -3,8 +3,8 @@ package com.quantum.actions; import java.sql.Connection; import java.util.Iterator; +import com.quantum.ImageStore; import com.quantum.Messages; -import com.quantum.QuantumPlugin; import com.quantum.model.Bookmark; import com.quantum.util.connection.ConnectionUtil; import com.quantum.view.bookmark.BookmarkNode; @@ -12,6 +12,7 @@ import com.quantum.view.bookmark.BookmarkNode; import org.eclipse.jface.action.IAction; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.swt.widgets.Shell; +import org.eclipse.ui.IActionDelegate; import org.eclipse.ui.IViewPart; import org.eclipse.ui.actions.SelectionListenerAction; @@ -23,7 +24,7 @@ public class ConnectAction extends SelectionListenerAction { super(Messages.getString(ConnectAction.class.getName() + ".text")); this.view = view; setImageDescriptor( - QuantumPlugin.getImageDescriptor("connect.gif")); //$NON-NLS-1$ + ImageStore.getImageDescriptor(ImageStore.CONNECT)); } private IViewPart view; diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/actions/DeleteBookmarkAction.java b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/actions/DeleteBookmarkAction.java index a00c028..2064fd2 100644 --- a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/actions/DeleteBookmarkAction.java +++ b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/actions/DeleteBookmarkAction.java @@ -3,8 +3,8 @@ package com.quantum.actions; import java.util.Iterator; import java.util.List; +import com.quantum.ImageStore; import com.quantum.Messages; -import com.quantum.QuantumPlugin; import com.quantum.model.BookmarkCollection; import com.quantum.view.bookmark.BookmarkNode; @@ -24,7 +24,7 @@ public class DeleteBookmarkAction extends SelectionListenerAction { public DeleteBookmarkAction(IViewPart view) { super(Messages.getString(DeleteBookmarkAction.class.getName() + ".text")); - setImageDescriptor(QuantumPlugin.getImageDescriptor("delete.gif")); + setImageDescriptor(ImageStore.getImageDescriptor(ImageStore.DELETE)); this.view = view; } 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 7966a08..3860403 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 @@ -4,8 +4,8 @@ import java.util.Iterator; import java.util.List; import java.util.Vector; +import com.quantum.ImageStore; import com.quantum.Messages; -import com.quantum.QuantumPlugin; import com.quantum.model.Bookmark; import com.quantum.model.ConnectionException; import com.quantum.view.bookmark.BookmarkNode; @@ -30,7 +30,7 @@ public class DisconnectAction extends SelectionListenerAction { super(Messages.getString(DisconnectAction.class.getName() + ".text")); this.view = view; setImageDescriptor( - QuantumPlugin.getImageDescriptor("disconnect.gif")); //$NON-NLS-1$ + ImageStore.getImageDescriptor(ImageStore.DISCONNECT)); } diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/actions/ExecuteAction.java b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/actions/ExecuteAction.java index 295cfa3..d0044f5 100644 --- a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/actions/ExecuteAction.java +++ b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/actions/ExecuteAction.java @@ -1,161 +1,130 @@ package com.quantum.actions; +import java.io.IOException; import java.sql.Connection; import java.sql.SQLException; +import java.util.List; import java.util.Vector; +import com.quantum.ImageStore; import com.quantum.Messages; -import com.quantum.QuantumPlugin; import com.quantum.model.Bookmark; -import com.quantum.sql.MultiSQLServer; +import com.quantum.model.BookmarkCollection; import com.quantum.sql.SQLParser; -import com.quantum.sql.SQLResults; -import com.quantum.view.LogProxy; import com.quantum.view.SQLQueryView; -import com.quantum.view.bookmark.BookmarkNode; -import com.quantum.view.bookmark.BookmarkView; -import com.quantum.view.tableview.DefaultSizes; -import com.quantum.view.tableview.TableView; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.jface.action.IAction; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.jface.action.Action; +import org.eclipse.jface.action.ActionContributionItem; +import org.eclipse.jface.action.IMenuCreator; import org.eclipse.jface.action.IStatusLineManager; import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jface.viewers.ISelection; +import org.eclipse.swt.events.MenuAdapter; +import org.eclipse.swt.events.MenuEvent; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Menu; +import org.eclipse.swt.widgets.MenuItem; import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.IViewActionDelegate; -import org.eclipse.ui.IViewPart; /** * Executes a query from the QueryView * * @author panic */ -public class ExecuteAction extends BaseSQLAction implements IViewActionDelegate { - SQLQueryView view; - String execute1 = Messages.getString("ExecuteAction.Executing_Query3"); //$NON-NLS-1$ - String execute2 = Messages.getString("ExecuteAction.Executing_Query2"); //$NON-NLS-1$ - - public ExecuteAction() { +public class ExecuteAction extends BaseExecuteAction implements IMenuCreator { + private SQLQueryView view; + + public ExecuteAction(SQLQueryView view) { + this.view = view; setActionDefinitionId("com.quantum.actions.ExecuteAction"); - setImageDescriptor(QuantumPlugin.getImageDescriptor("play.gif")); + setImageDescriptor(ImageStore.getImageDescriptor(ImageStore.PLAY)); setText(Messages.getString("sqlqueryview.executeQuery")); setToolTipText(Messages.getString("sqlqueryview.executeQuery")); - } - - public void init(IViewPart view) { - this.view = (SQLQueryView) view; + setMenuCreator(this); } - public void run(IAction action) { - run(); - } - - public void run() { - BookmarkNode current = BookmarkView.getInstance().getCurrentBookmark(); - if (current == null) - { - MessageDialog.openInformation( - view.getSite().getShell(),"Sorry","Please select a bookmark to use as connection."); - return; - } - getStatusLineManager().setErrorMessage(null); - Connection con = getConnection(); - getStatusLineManager().setMessage(execute1); - MultiSQLServer server = MultiSQLServer.getInstance(); - getStatusLineManager().setMessage(Messages.getString("ExecuteAction.Parsing_sql_script3")); //$NON-NLS-1$ - Vector queries = new Vector(); - String viewQuery = view.getQuery(); - // We parse the executable units to send to the JDBC driver - queries = SQLParser.parse(viewQuery); - for (int i = 0; i < queries.size(); i++) { - String query = (String) queries.elementAt(i); - System.out.println(query); - } - int resultCount = 0; - int resultUpdateCount = 0; - int errorCount = 0; - int resultsDisplayed = 0; - double startTime = 0.0; // stores the time when query is started - double queryDuration= 0.0; // stores query's execution time - - IProgressMonitor progressBar = getStatusLineManager().getProgressMonitor(); - progressBar.beginTask("queries", queries.size()); - for (int i = 0; i < queries.size(); i++) { - if (i % 2 == 0) { - getStatusLineManager().setMessage(execute1); - } else { - getStatusLineManager().setMessage(execute2); - } - - String query = (String) queries.elementAt(i); - System.out.println(">" + query + "<"); //$NON-NLS-1$ //$NON-NLS-2$ - if (con != null && !query.equals("")) { //$NON-NLS-1$ - SQLResults results; - try { - startTime = System.currentTimeMillis(); // Start the measure of execution time - results = server.execute(con, query, 1, DefaultSizes.PAGE_SIZE, DefaultSizes.MAX_COLUMN_SIZE); - queryDuration = (System.currentTimeMillis() - startTime)/1000; // calculate the execution time (in seconds) - current.getBookmark().addQuery(query); - } catch (SQLException e) { - errorCount++; - LogProxy log = LogProxy.getInstance(); - log.addText( - LogProxy.ERROR, - "Error Executing: " + query + ":" + e.toString(), e); //$NON-NLS-1$ //$NON-NLS-2$ - MessageDialog.openConfirm(view.getSite().getShell(), "Database returned error", e.getLocalizedMessage()); //$NON-NLS-1$ - continue; - } - resultCount++; - if (results.isResultSet()) { - TableView.getInstance().loadQuery(current.getBookmark(), results); - resultsDisplayed++; - } else { - int count = results.getUpdateCount(); - if (count > 0) { - resultUpdateCount += results.getUpdateCount(); - } - } - } -System.out.println(getStatusLineManager().getProgressMonitor() == null ? "not found" : "found!"); - progressBar.worked(i); -// view.setProgress(i + 1, queries.size()); + + protected void execute(Bookmark bookmark, Connection connection) + throws IOException, CoreException, SQLException { + + boolean autoCommitPreference = this.view.isAutoCommitPreference(); + boolean changed = false; + if (connection.getAutoCommit() != autoCommitPreference) { + connection.setAutoCommit(autoCommitPreference); + changed = true; } - progressBar.done(); - String message = Messages.getString("ExecuteAction.Done") + "(" + //$NON-NLS-1$ //$NON-NLS-2$ - resultCount + Messages.getString("ExecuteAction.QueriesExecuted") + //$NON-NLS-1$ - resultUpdateCount + Messages.getString("ExecuteAction.RowsUpdated") + //$NON-NLS-1$ - resultsDisplayed + Messages.getString("ExecuteAction.ResultsDisplayed") + //$NON-NLS-1$ - errorCount + Messages.getString("ExecuteAction.Errors") + //$NON-NLS-1$ - queryDuration + Messages.getString("ExecutAction.TimeExec") + ")"; //$NON-NLS-1$ //$NON-NLS-2$ - if (errorCount > 0) { - getStatusLineManager().setErrorMessage( - QuantumPlugin.getImage("stop.gif"), message); - } else { - getStatusLineManager().setMessage( - QuantumPlugin.getImage("success.gif"), message); + + super.execute(bookmark, connection); + + if (changed) { + MessageDialog.openInformation(getShell(), + Messages.getString(ExecuteAction.class, "autocommitTitle"), + Messages.getString(ExecuteAction.class, "autocommitMessage", + new Object[] { bookmark.getName() })); } } + /** + * @return + */ + protected List getQueries() { + getStatusLineManager().setMessage( + Messages.getString(ExecuteAction.class, "parsing")); //$NON-NLS-1$ + Vector queries = SQLParser.parse(view.getQuery()); + return queries; + } /** * @return */ - private IStatusLineManager getStatusLineManager() { + protected IStatusLineManager getStatusLineManager() { return this.view.getViewSite().getActionBars().getStatusLineManager(); } - public void selectionChanged(IAction action, ISelection selection) { + protected Shell getShell() { + return this.view.getViewSite().getShell(); } - protected Bookmark getBookmark() { - BookmarkNode current = BookmarkView.getInstance().getCurrentBookmark(); - return current.getBookmark(); + + public void dispose() { } - /* (non-Javadoc) - * @see com.quantum.actions.BaseSQLAction#getShell() - */ - protected Shell getShell() { - return this.view.getViewSite().getShell(); + public Menu getMenu(Control parent) { + Menu menu = new Menu(parent); + /** + * Add listener to repopulate the menu each time + * it is shown because the list of bookmarks may have changed. + */ + menu.addMenuListener(new MenuAdapter() { + public void menuShown(MenuEvent e) { + Menu menu = (Menu)e.widget; + MenuItem[] items = menu.getItems(); + for (int i=0; i < items.length; i++) { + items[i].dispose(); + } + fillMenu(menu); + } + }); + return menu; + } + + public Menu getMenu(Menu parent) { + // never called... + return null; + } + + protected void fillMenu(Menu menu) { + Bookmark[] bookmarks = BookmarkCollection.getInstance().getBookmarks(); + for (int i = 0, length = bookmarks == null ? 0 : bookmarks.length; i < length; i++) { + final Bookmark bookmark = bookmarks[i]; + Action action = new Action() { + public void run() { + ExecuteAction.this.execute(bookmark); + } + }; + action.setImageDescriptor(ImageStore.getImageDescriptor(ImageStore.BOOKMARK)); + action.setText(bookmark.getName()); + ActionContributionItem item = new ActionContributionItem(action); + item.fill(menu, -1); + } } } 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 c1e2486..ffdac6c 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 @@ -1,51 +1,43 @@ package com.quantum.actions; -import java.beans.PropertyChangeEvent; -import java.beans.PropertyChangeListener; import java.io.IOException; -import java.sql.Connection; -import java.sql.SQLException; import java.util.ArrayList; import java.util.Iterator; import java.util.List; +import com.quantum.ImageStore; import com.quantum.Messages; import com.quantum.model.Bookmark; import com.quantum.model.BookmarkCollection; -import com.quantum.model.ConnectionException; -import com.quantum.sql.MultiSQLServer; import com.quantum.sql.SQLParser; -import com.quantum.sql.SQLResults; -import com.quantum.ui.dialog.BookmarkSelectionDialog; -import com.quantum.ui.dialog.ExceptionDisplayDialog; +import com.quantum.ui.dialog.SimpleSelectionDialog; import com.quantum.util.io.InputStreamHelper; -import com.quantum.view.tableview.DefaultSizes; -import com.quantum.view.tableview.TableView; import org.eclipse.core.resources.IFile; import org.eclipse.core.runtime.CoreException; import org.eclipse.jface.action.IAction; -import org.eclipse.jface.dialogs.ErrorDialog; +import org.eclipse.jface.action.IStatusLineManager; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.window.Window; import org.eclipse.swt.widgets.Shell; +import org.eclipse.ui.IEditorPart; import org.eclipse.ui.IObjectActionDelegate; +import org.eclipse.ui.IViewPart; import org.eclipse.ui.IWorkbenchPart; /** * This action can be executed against any .sql file, regardless of * whether or not the Quantum perspective is open. * - * @author BC + * @author BC Holmes */ -public class ExecuteAgainstAction extends BaseSQLAction - implements IObjectActionDelegate, PropertyChangeListener { +public class ExecuteAgainstAction extends BaseExecuteAction + implements IObjectActionDelegate { - private String selectedBookmark = null; private IFile[] files = null; private IWorkbenchPart workbenchPart; + /** * @see IObjectActionDelegate#setActivePart(IAction, IWorkbenchPart) @@ -59,99 +51,7 @@ public class ExecuteAgainstAction extends BaseSQLAction } /** - * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction) - */ - public void run(IAction action) { - - BookmarkSelectionDialog dialog = new BookmarkSelectionDialog(getShell()); - dialog.addPropertyChangeListener(this); - int result = dialog.open(); - - if (result == Window.OK) { - try { - executeAgainstBookmark(); - } catch (SQLException e) { - ExceptionDisplayDialog.openError(getShell(), - null, - null, e); - } catch (IOException e) { - ExceptionDisplayDialog.openError(getShell(), - Messages.getString("ExecuteAgainstAction.title"), - Messages.getString("ExecuteAgainstAction.IOException"), e); - } catch (ConnectionException e) { - ExceptionDisplayDialog.openError(getShell(), - null, - null, e); - } catch (CoreException e) { - ErrorDialog.openError(getShell(), null, null, e.getStatus()); - } - } - } - - protected Bookmark getBookmark() { - return BookmarkCollection.getInstance().find(this.selectedBookmark); - } - - private void executeAgainstBookmark() - throws SQLException, IOException, CoreException, ConnectionException { - Bookmark bookmark = getBookmark(); - if (bookmark != null) { - boolean alreadyConnected = bookmark.isConnected(); - Connection connection = getConnection(); - try { - for (int i = 0, - length = (this.files == null) ? 0 : this.files.length; - connection != null && i < length; - i++) { - executeAgainstBookmark(bookmark, connection, this.files[i]); - } - } finally { - if (!alreadyConnected && connection != null) { - bookmark.disconnect(); - } - } - } - } - - private void executeAgainstBookmark( - Bookmark bookmark, - Connection connection, - IFile file) - throws SQLException, IOException, CoreException { - executeAgainstBookmark( - bookmark, - connection, - InputStreamHelper.readIntoString(file.getContents())); - } - - private void executeAgainstBookmark( - Bookmark bookmark, - Connection connection, - String queries) - throws SQLException { - List queryList = SQLParser.parse(queries); - MultiSQLServer server = MultiSQLServer.getInstance(); - - for (Iterator i = queryList.iterator(); i.hasNext();) { - String query = (String) i.next(); - SQLResults results = - server.execute( - connection, - query, - 1, - DefaultSizes.PAGE_SIZE, - DefaultSizes.MAX_COLUMN_SIZE); - if (results.isResultSet()) { - TableView view = TableView.getInstance(); - if (view != null) { - view.loadQuery(bookmark, results); - } - } - } - } - - /** - * This method is called with a new selection has been made on one + * This method is called when a new selection has been made on one * of the views. * * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection) @@ -165,7 +65,6 @@ public class ExecuteAgainstAction extends BaseSQLAction for (Iterator i = structuredSelection.iterator(); i.hasNext();) { Object temp = i.next(); if (temp != null && temp instanceof IFile) { - System.out.println(((IFile) temp).getName()); list.add(temp); } } @@ -173,12 +72,31 @@ public class ExecuteAgainstAction extends BaseSQLAction } } - /** - * @see java.beans.PropertyChangeListener#propertyChange(java.beans.PropertyChangeEvent) - */ - public void propertyChange(PropertyChangeEvent event) { - if ("selection".equals(event.getPropertyName())) { - this.selectedBookmark = (String) event.getNewValue(); - } - } + /* (non-Javadoc) + * @see com.quantum.actions.BaseSQLAction#getQueries() + */ + protected List getQueries() throws IOException, CoreException { + List list = new ArrayList(); + for (int i = 0, length = this.files == null ? 0 : this.files.length; i < length; i++) { + String fileContents = InputStreamHelper.readIntoString(this.files[i].getContents()); + List queryList = SQLParser.parse(fileContents); + list.addAll(queryList); + } + return list; + } + + protected IStatusLineManager getStatusLineManager() { + if (this.workbenchPart instanceof IViewPart) { + return ((IViewPart) this.workbenchPart).getViewSite().getActionBars().getStatusLineManager(); + } else { + return null; + } + } + + /* (non-Javadoc) + * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction) + */ + public void run(IAction action) { + run(); + } } diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/actions/ExportQueryAction.java b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/actions/ExportQueryAction.java index cef3fe7..cce682b 100644 --- a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/actions/ExportQueryAction.java +++ b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/actions/ExportQueryAction.java @@ -6,8 +6,8 @@ import java.io.IOException; import java.io.PrintWriter; import java.util.StringTokenizer; +import com.quantum.ImageStore; import com.quantum.Messages; -import com.quantum.QuantumPlugin; import com.quantum.util.StringUtil; import com.quantum.view.LogProxy; import com.quantum.view.SQLLogView; @@ -24,7 +24,7 @@ public class ExportQueryAction extends Action implements IViewActionDelegate { SQLQueryView view; public ExportQueryAction() { - setImageDescriptor(QuantumPlugin.getImageDescriptor("export.gif")); + setImageDescriptor(ImageStore.getImageDescriptor(ImageStore.EXPORT)); setText(Messages.getString("sqlqueryview.exportQuery")); setToolTipText(Messages.getString("sqlqueryview.exportQuery")); } diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/actions/ImportQueryAction.java b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/actions/ImportQueryAction.java index 16cda89..22dbe66 100644 --- a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/actions/ImportQueryAction.java +++ b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/actions/ImportQueryAction.java @@ -5,6 +5,7 @@ import java.io.File; import java.io.FileReader; import java.io.IOException; +import com.quantum.ImageStore; import com.quantum.Messages; import com.quantum.QuantumPlugin; import com.quantum.view.LogProxy; @@ -29,7 +30,7 @@ public class ImportQueryAction extends Action implements IViewActionDelegate { public ImportQueryAction() { setText(Messages.getString("sqlqueryview.importQuery")); - setImageDescriptor(QuantumPlugin.getImageDescriptor("import.gif")); + setImageDescriptor(ImageStore.getImageDescriptor(ImageStore.IMPORT)); setToolTipText(Messages.getString("sqlqueryview.importQuery")); } 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 b3dbd19..13ade29 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 @@ -1,7 +1,7 @@ package com.quantum.actions; +import com.quantum.ImageStore; import com.quantum.Messages; -import com.quantum.QuantumPlugin; import com.quantum.wizards.BookmarkWizard; import org.eclipse.jface.action.Action; @@ -17,9 +17,9 @@ public class NewBookmarkAction extends Action { public NewBookmarkAction(IViewPart view) { this.view = view; - setText(Messages.getString(getClass().getName() + ".text")); //$NON-NLS-1$ - setToolTipText(Messages.getString(getClass().getName() + ".text")); //$NON-NLS-1$ - setImageDescriptor(QuantumPlugin.getImageDescriptor("bookmarks.gif")); //$NON-NLS-1$ + setText(Messages.getString(getClass(), "text")); //$NON-NLS-1$ + setToolTipText(Messages.getString(getClass(), "text")); //$NON-NLS-1$ + setImageDescriptor(ImageStore.getImageDescriptor(ImageStore.BOOKMARK)); } public void run() { diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/actions/NextSequenceAction.java b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/actions/NextSequenceAction.java index 13d1d06..83a7a26 100644 --- a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/actions/NextSequenceAction.java +++ b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/actions/NextSequenceAction.java @@ -1,9 +1,7 @@ package com.quantum.actions; -import org.eclipse.ui.IViewPart; - +import com.quantum.ImageStore; import com.quantum.Messages; -import com.quantum.QuantumPlugin; import com.quantum.adapters.DatabaseAdapter; import com.quantum.model.Bookmark; import com.quantum.sql.SQLResults; @@ -11,6 +9,8 @@ import com.quantum.view.ViewHelper; import com.quantum.view.bookmark.EntityNode; import com.quantum.view.tableview.TableView; +import org.eclipse.ui.IViewPart; + public class NextSequenceAction extends BaseSequenceAction { /** @@ -18,8 +18,8 @@ public class NextSequenceAction extends BaseSequenceAction { * @param view */ public NextSequenceAction(IViewPart view) { - super(Messages.getString(NextSequenceAction.class.getName() + ".text"), view); - setImageDescriptor(QuantumPlugin.getImageDescriptor("append.gif")); + super(Messages.getString(NextSequenceAction.class, "text"), view); + setImageDescriptor(ImageStore.getImageDescriptor(ImageStore.APPEND)); } public void run() { diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/actions/PrevSequenceAction.java b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/actions/PrevSequenceAction.java index c632ba2..ab63311 100644 --- a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/actions/PrevSequenceAction.java +++ b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/actions/PrevSequenceAction.java @@ -4,10 +4,8 @@ */ package com.quantum.actions; -import org.eclipse.ui.IViewPart; - +import com.quantum.ImageStore; import com.quantum.Messages; -import com.quantum.QuantumPlugin; import com.quantum.adapters.DatabaseAdapter; import com.quantum.model.Bookmark; import com.quantum.sql.SQLResults; @@ -15,6 +13,8 @@ import com.quantum.view.ViewHelper; import com.quantum.view.bookmark.EntityNode; import com.quantum.view.tableview.TableView; +import org.eclipse.ui.IViewPart; + public class PrevSequenceAction extends BaseSequenceAction { /** * @param text @@ -22,7 +22,7 @@ public class PrevSequenceAction extends BaseSequenceAction { */ public PrevSequenceAction(IViewPart view) { super(Messages.getString(PrevSequenceAction.class.getName() + ".text"), view); - setImageDescriptor(QuantumPlugin.getImageDescriptor("grid.gif")); + setImageDescriptor(ImageStore.getImageDescriptor(ImageStore.GRID)); } public void run() { 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 c28df56..366644b 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 @@ -4,8 +4,8 @@ import java.sql.SQLException; import java.util.Iterator; import java.util.List; +import com.quantum.ImageStore; import com.quantum.Messages; -import com.quantum.QuantumPlugin; import com.quantum.model.NotConnectedException; import com.quantum.ui.dialog.ExceptionDisplayDialog; import com.quantum.view.bookmark.TreeNode; @@ -19,9 +19,9 @@ import org.eclipse.ui.actions.SelectionListenerAction; public class RefreshBookmarkAction extends SelectionListenerAction { private IViewPart view; public RefreshBookmarkAction(IViewPart view) { - super(Messages.getString(RefreshBookmarkAction.class.getName() + ".text")); + super(Messages.getString(RefreshBookmarkAction.class, "text")); this.view = view; - setImageDescriptor(QuantumPlugin.getImageDescriptor("refresh.gif")); + setImageDescriptor(ImageStore.getImageDescriptor(ImageStore.REFRESH)); } public void run() { 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 45c6a7d..91b9916 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 @@ -1,7 +1,7 @@ package com.quantum.actions; +import com.quantum.ImageStore; import com.quantum.Messages; -import com.quantum.QuantumPlugin; import com.quantum.model.Entity; import com.quantum.view.bookmark.EntityNode; import com.quantum.view.tableview.TableView; @@ -18,9 +18,9 @@ public class ViewTableAction extends SelectionListenerAction { private Entity entity; public ViewTableAction(IViewPart view) { - super(Messages.getString(ViewTableAction.class.getName() + ".text")); + super(Messages.getString(ViewTableAction.class, "text")); setImageDescriptor( - QuantumPlugin.getImageDescriptor("table.gif")); //$NON-NLS-1$ + ImageStore.getImageDescriptor(ImageStore.OPEN_TABLE)); } public void run() { 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 5215912..9d16eef 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 @@ -3,8 +3,8 @@ package com.quantum.actions; import java.sql.Connection; import java.util.List; +import com.quantum.ImageStore; import com.quantum.Messages; -import com.quantum.QuantumPlugin; import com.quantum.model.Bookmark; import com.quantum.model.Entity; import com.quantum.sql.SQLResults; @@ -26,7 +26,7 @@ public class ViewTableDetailsAction extends SelectionListenerAction { public ViewTableDetailsAction(IViewPart view) { super(Messages.getString(ViewTableDetailsAction.class, "text")); - setImageDescriptor(QuantumPlugin.getImageDescriptor("table.gif")); //$NON-NLS-1$ + setImageDescriptor(ImageStore.getImageDescriptor(ImageStore.OPEN_TABLE)); this.view = view; } diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/adapters/DB2AS400Adapter.java b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/adapters/DB2AS400Adapter.java index d31c905..437dbf4 100644 --- a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/adapters/DB2AS400Adapter.java +++ b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/adapters/DB2AS400Adapter.java @@ -8,11 +8,11 @@ public class DB2AS400Adapter extends DatabaseAdapter { public String getShowTableQuery(String qualifier) { return "SELECT TABLE_NAME FROM QSYS2.SYSTABLES WHERE table_schema = '" + qualifier.toUpperCase() + - "' AND TABLE_TYPE IN ('T', 'P') AND SYSTEM_TABLE= 'N'"; //$NON-NLS-1$ //$NON-NLS-2$ + "' AND TABLE_TYPE IN ('T', 'P')"; //$NON-NLS-1$ //$NON-NLS-2$ } public String getShowViewQuery(String qualifier) { return "SELECT TABLE_NAME FROM QSYS2.SYSTABLES WHERE table_schema = '" + qualifier.toUpperCase() + - "' AND TABLE_TYPE IN ('V', 'L') AND SYSTEM_TABLE= 'N'"; //$NON-NLS-1$ //$NON-NLS-2$ + "' AND TABLE_TYPE IN ('V', 'L')"; //$NON-NLS-1$ //$NON-NLS-2$ } } diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/editors/SQLConfiguration.java b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/editors/SQLConfiguration.java index 985c0d8..b2993fe 100644 --- a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/editors/SQLConfiguration.java +++ b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/editors/SQLConfiguration.java @@ -8,6 +8,8 @@ import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.jface.preference.PreferenceConverter; import org.eclipse.jface.text.IDocument; import org.eclipse.jface.text.TextAttribute; +import org.eclipse.jface.text.contentassist.ContentAssistant; +import org.eclipse.jface.text.contentassist.IContentAssistant; import org.eclipse.jface.text.presentation.IPresentationReconciler; import org.eclipse.jface.text.presentation.PresentationReconciler; import org.eclipse.jface.text.source.ISourceViewer; @@ -86,4 +88,23 @@ public class SQLConfiguration extends SourceViewerConfiguration { ndr.setTextAttribute(attr); } } +// public IContentAssistant getContentAssistant(ISourceViewer sourceViewer) { +// ContentAssistant assistant = new ContentAssistant(); +// assistant.setContentAssistProcessor(new SQLContentAssistProcessor("default"), +// IDocument.DEFAULT_CONTENT_TYPE); +// assistant.setContentAssistProcessor(new SQLContentAssistProcessor("comment"), +// SQLPartitionScanner.SQL_COMMENT); +// assistant.setContentAssistProcessor(new SQLContentAssistProcessor("keyword"), +// SQLPartitionScanner.SQL_KEYWORD); +// assistant.setContentAssistProcessor(new SQLContentAssistProcessor("identifier"), +// SQLPartitionScanner.SQL_IDENTIFIER); +// +// // everybody else is doin' it... +// assistant.enableAutoActivation(true); +// assistant.setAutoActivationDelay(500); +// +// assistant.setProposalPopupOrientation(ContentAssistant.CONTEXT_INFO_BELOW); +// assistant.setContextInformationPopupOrientation(ContentAssistant.CONTEXT_INFO_BELOW); +// return assistant; +// } } \ No newline at end of file diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/editors/SQLContentAssistProcessor.java b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/editors/SQLContentAssistProcessor.java new file mode 100644 index 0000000..bf225cf --- /dev/null +++ b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/editors/SQLContentAssistProcessor.java @@ -0,0 +1,69 @@ +package com.quantum.editors; + +import com.quantum.ImageStore; + +import org.eclipse.jface.text.ITextViewer; +import org.eclipse.jface.text.contentassist.CompletionProposal; +import org.eclipse.jface.text.contentassist.ICompletionProposal; +import org.eclipse.jface.text.contentassist.IContentAssistProcessor; +import org.eclipse.jface.text.contentassist.IContextInformation; +import org.eclipse.jface.text.contentassist.IContextInformationValidator; + + +/** + * @author BC + */ +public class SQLContentAssistProcessor implements IContentAssistProcessor { + + private String text; + /** + * @param string + */ + public SQLContentAssistProcessor(String text) { + this.text = text; + } + + public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int offset) { + + ICompletionProposal proposal = new CompletionProposal("select", + offset, 0, 6, ImageStore.getImage(ImageStore.TEMPLATE), + "select - select columns from a table or view", null, null); +System.out.println(this.text); + // complete a key word + + // complete a function + + // provide a template + + // TODO Auto-generated method stub + return new ICompletionProposal[] { proposal }; + } + + /** + * BCH: I have no idea what the difference is between context information and + * completion proposals. + */ + public IContextInformation[] computeContextInformation(ITextViewer viewer, int offset) { + return null; + } + + /** + * Unless this method includes a space character, the standard Ctrl-Space key doesn't + * provide content assist. + */ + public char[] getCompletionProposalAutoActivationCharacters() { + return new char[] { ' ' }; + } + + public char[] getContextInformationAutoActivationCharacters() { + return null; + } + + public String getErrorMessage() { + return null; + } + + public IContextInformationValidator getContextInformationValidator() { + return null; + } +} 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 3ee61be..a4a50e8 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 @@ -29,7 +29,7 @@ import org.eclipse.jface.preference.IPreferenceStore; * * @author root */ -public class Bookmark { +public class Bookmark implements Displayable { public static final int SCHEMA_RULE_USE_ALL = 1; public static final int SCHEMA_RULE_USE_DEFAULT = 2; @@ -540,4 +540,8 @@ public class Bookmark { this.propertyChangeSupport.firePropertyChange("schemas", null, null); } } + + public String getDisplayName() { + return this.name; + } } diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/model/Displayable.java b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/model/Displayable.java new file mode 100644 index 0000000..17222e1 --- /dev/null +++ b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/model/Displayable.java @@ -0,0 +1,9 @@ +package com.quantum.model; + + +/** + * @author BC + */ +public interface Displayable { + public String getDisplayName(); +} diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/model/Schema.java b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/model/Schema.java index 62d7cd3..4f4f1d2 100644 --- a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/model/Schema.java +++ b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/model/Schema.java @@ -3,7 +3,7 @@ package com.quantum.model; /** * @author BC */ -public class Schema implements Comparable { +public class Schema implements Comparable, Displayable { private String name; private String displayName; diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/properties/BaseEntityPropertyPage.java b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/properties/BaseEntityPropertyPage.java index c6f3b00..9e80375 100644 --- a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/properties/BaseEntityPropertyPage.java +++ b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/properties/BaseEntityPropertyPage.java @@ -1,7 +1,7 @@ package com.quantum.properties; +import com.quantum.ImageStore; import com.quantum.Messages; -import com.quantum.QuantumPlugin; import com.quantum.model.Entity; import com.quantum.model.EntityHolder; @@ -63,7 +63,7 @@ public abstract class BaseEntityPropertyPage extends PropertyPage { protected void createErrorMessage(Composite composite, Exception e) { Label icon = new Label(composite, SWT.NONE); icon.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING)); - icon.setImage(QuantumPlugin.getImage("warning.gif")); + icon.setImage(ImageStore.getImage(ImageStore.WARNING)); Label error = new Label(composite, SWT.NONE); error.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING)); diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/properties/ColumnPropertyPage.java b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/properties/ColumnPropertyPage.java index 21d37f9..2a0bf10 100644 --- a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/properties/ColumnPropertyPage.java +++ b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/properties/ColumnPropertyPage.java @@ -2,8 +2,8 @@ package com.quantum.properties; import java.sql.SQLException; +import com.quantum.ImageStore; import com.quantum.Messages; -import com.quantum.QuantumPlugin; import com.quantum.model.Column; import com.quantum.model.Entity; import com.quantum.model.NotConnectedException; @@ -56,8 +56,8 @@ public class ColumnPropertyPage extends BaseEntityPropertyPage { public Image getColumnImage(Object element, int columnIndex) { if (columnIndex == 0 && element instanceof Column) { return ((Column) element).isPrimaryKey() - ? QuantumPlugin.getImage("keycolumn.gif") - : QuantumPlugin.getImage("column.gif"); + ? ImageStore.getImage(ImageStore.KEYCOLUMN) + : ImageStore.getImage(ImageStore.COLUMN); } else { return null; } 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 322ba0e..a61c93b 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 @@ -2,8 +2,8 @@ package com.quantum.properties; import java.sql.SQLException; +import com.quantum.ImageStore; import com.quantum.Messages; -import com.quantum.QuantumPlugin; import com.quantum.model.Bookmark; import com.quantum.model.DataType; import com.quantum.model.NotConnectedException; @@ -140,7 +140,7 @@ public class DatabaseInformationPropertyPage extends PropertyPage { private void createErrorMessage(Composite composite, Exception e) { Label icon = new Label(composite, SWT.NONE); icon.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING)); - icon.setImage(QuantumPlugin.getImage("warning.gif")); + icon.setImage(ImageStore.getImage(ImageStore.WARNING)); Label error = new Label(composite, SWT.NONE); error.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING)); diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/properties/IndexPropertyPage.java b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/properties/IndexPropertyPage.java index 84719ed..dc511f7 100644 --- a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/properties/IndexPropertyPage.java +++ b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/properties/IndexPropertyPage.java @@ -4,8 +4,8 @@ import java.sql.SQLException; import java.util.ArrayList; import java.util.List; +import com.quantum.ImageStore; import com.quantum.Messages; -import com.quantum.QuantumPlugin; import com.quantum.model.Entity; import com.quantum.model.Index; import com.quantum.model.NotConnectedException; @@ -93,7 +93,7 @@ public class IndexPropertyPage extends BaseEntityPropertyPage { public Image getColumnImage(Object element, int columnIndex) { if (columnIndex == 1 && element instanceof IndexAdaptor) { - return QuantumPlugin.getImage("column.gif"); + return ImageStore.getImage(ImageStore.COLUMN); } else { return null; } diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/properties/ReferencesPropertyPage.java b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/properties/ReferencesPropertyPage.java index 75edc3b..630af95 100644 --- a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/properties/ReferencesPropertyPage.java +++ b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/properties/ReferencesPropertyPage.java @@ -5,8 +5,8 @@ import java.sql.SQLException; import java.util.ArrayList; import java.util.List; +import com.quantum.ImageStore; import com.quantum.Messages; -import com.quantum.QuantumPlugin; import com.quantum.model.Entity; import com.quantum.model.ForeignKey; import com.quantum.model.NotConnectedException; @@ -111,13 +111,13 @@ public class ReferencesPropertyPage extends BaseEntityPropertyPage { public Image getColumnImage(Object element, int columnIndex) { if ((columnIndex == 1 || columnIndex == 2) && element instanceof ColumnDetailsAdaptor) { - return QuantumPlugin.getImage("column.gif"); + return ImageStore.getImage(ImageStore.COLUMN); } else if ((columnIndex == 1 || columnIndex == 2) && element instanceof TableDetailsAdaptor) { - return QuantumPlugin.getImage("bigtable.gif"); + return ImageStore.getImage(ImageStore.TABLE); } else if ((columnIndex == 0) && element instanceof TableDetailsAdaptor) { - return QuantumPlugin.getImage("foreignkey.gif"); + return ImageStore.getImage(ImageStore.FOREIGNKEY); } else { return null; } 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 ef233fb..97c1cc1 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 @@ -172,6 +172,7 @@ public class MultiSQLServer implements ConnectionEstablisher { SQLResults results = new SQLResults(); + long startTime = System.currentTimeMillis(); System.out.println("Executing"); //$NON-NLS-1$ LogProxy log = LogProxy.getInstance(); log.addText(LogProxy.QUERY, "Executing Request [" + s + "]"); //$NON-NLS-1$ //$NON-NLS-2$ @@ -315,6 +316,7 @@ public class MultiSQLServer implements ConnectionEstablisher { } log.addText(LogProxy.RESULTS, "Success: result set displayed"); //$NON-NLS-1$ stmt.close(); + results.setTime(System.currentTimeMillis() - startTime); System.out.println("Executed"); //$NON-NLS-1$ System.out.println(); return results; diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/sql/SQLGrammar.java b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/sql/SQLGrammar.java new file mode 100644 index 0000000..0bb0eed --- /dev/null +++ b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/sql/SQLGrammar.java @@ -0,0 +1,54 @@ +package com.quantum.sql; + +/** + * @author BC + */ +public abstract class SQLGrammar { + + public static String[] KEYWORDS = { + "ADD", "ALL", "ALTER", "AND", "ANY", + "AS", "ASC", "AUTOINCREMENT", "AVA", "BETWEEN", + "BINARY", "BIT", "BOOLEAN", "BY", "CREATE", + "BYTE", "CHAR", "CHARACTER", "COLUMN", "CONSTRAINT", + "COUNT", "COUNTER", "CURRENCY", "DATABASE", "DATE", + "DATETIME", "DELETE", "DESC", "DISALLOW", "DISTINCT", + "DISTINCTROW", "DOUBLE", "DROP", "EXISTS", "FROM", + "FLOAT", "FLOAT4", "FLOAT8", "FOREIGN", "GENERAL", + "GROUP", "GUID", "HAVING", "INNER", "INSERT", + "IGNORE", "IMP", "IN", "INDEX", "INT", + "INTEGER", "INTEGER1", "INTEGER2", "INTEGER4", "INTO", + "IS", "JOIN", "KEY", "LEFT", "LEVEL", + "LIKE", "LOGICAL", "LONG", "LONGBINARY", "LONGTEXT", + "MAX", "MEMO", "MIN", "MOD", "MONEY", + "NOT", "NULL", "NUMBER", "NUMERIC", "OLEOBJECT", + "ON", "PIVOT", "OPTION", "PRIMARY", "ORDER", + "OUTER", "OWNERACCESS", "PARAMETERS", "PERCENT", "REAL", + "REFERENCES", "RIGHT", "SELECT", "SET", "SHORT", + "SINGLE", "SMALLINT", "SOME", "STDEV", "STDEVP", + "STRING", "SUM", "TABLE", "TABLEID", "TEXT", + "TIME", "TIMESTAMP", "TOP", "TRANSFORM", "UNION", + "UNIQUE", "UPDATE", "VALUE", "VALUES", "VAR", + "VARBINARY", "VARCHAR", "VARP", "WHERE", "WITH", + "YESNO" + }; + + public static final String[] NON_RESERVED_WORDS = { + "ADA", "C", "CATALOG_NAME", "CHARACTER_SET_CATALOG", "CHARACTER_SET_NAME", + "CHARACTER_SET_SCHEMA", "CLASS_ORIGIN", "COBOL", "COLLATION_CATALOG", + "COLLATION_NAME", "COLLATION_SCHEMA", "COLUMN_NAME", "COMMAND_FUNCTION", + "COMMITTED", "CONDITION_NUMBER", "CONNECTION_NAME", "CONSTRAINT_CATALOG", + "CONSTRAINT_NAME", "CONSTRAINT_SCHEMA", "CURSOR_NAME", "DATA", + "DATETIME_INTERVAL_CODE", "DATETIME_INTERVAL_PRECISION", "DYNAMIC_FUNCTION", + "FORTRAN", "LENGTH", "MESSAGE_LENGTH", "MESSAGE_OCTET_LENGTH", + "MESSAGE_TEXT", "MORE", "MUMPS", "NAME", "NULLABLE", "NUMBER", "PASCAL", + "PLI", "REPEATABLE", "RETURNED_LENGTH", "RETURNED_OCTET_LENGTH", + "RETURNED_SQLSTATE", "ROW_COUNT", "SCALE", "SCHEMA_NAME", + "SERIALIZABLE", "SERVER_NAME", "SUBCLASS_ORIGIN", "TABLE_NAME", + "TYPE", "UNCOMMITTED", "UNNAMED" + }; + + public static final String[] COMMANDS = { + "select * from ${tablename} where ${columnname} = ${value}", + "update ${tablename} set ${columnname} = ${value} where ${column2name} = ${value2}" + }; +} diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/sql/SQLResults.java b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/sql/SQLResults.java index 3abc2b9..44b67ed 100644 --- a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/sql/SQLResults.java +++ b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/sql/SQLResults.java @@ -20,6 +20,7 @@ public class SQLResults { private boolean hasMore = false; private boolean isError = false; private int maxSize = -1; + private long time; public void setColumnNames(Vector columns) { this.columns = columns; @@ -136,4 +137,10 @@ public class SQLResults { return rows.toArray(); } + public long getTime() { + return this.time; + } + public void setTime(long time) { + this.time = time; + } } diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/sql/parser/SQLLexx.java b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/sql/parser/SQLLexx.java index 42c6276..543b1ef 100644 --- a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/sql/parser/SQLLexx.java +++ b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/sql/parser/SQLLexx.java @@ -2,6 +2,21 @@ package com.quantum.sql.parser; import java.util.Vector; +/** + *

An SQL Lexer. From + * dictionary.com: + * + *

+ *

lexer + * + *

/lek'sr/ n. Common hacker shorthand for 'lexical + * analyzer', the input-tokenizing stage in the parser for a language + * (the part that breaks it into word-like pieces). + *

+ * + *

Note that this class has nothing to do with the Sci-fi channel's + * Lexx TV series. + */ public class SQLLexx { private static String endline = ";"; //$NON-NLS-1$ private static String dash = "-"; //$NON-NLS-1$ diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/ui/dialog/ExceptionDisplayDialog.java b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/ui/dialog/ExceptionDisplayDialog.java index 7917a07..51e85dd 100644 --- a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/ui/dialog/ExceptionDisplayDialog.java +++ b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/ui/dialog/ExceptionDisplayDialog.java @@ -200,7 +200,7 @@ public class ExceptionDisplayDialog extends Dialog { composite, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI); - text.setText(this.throwable.getMessage()); + text.setText(this.throwable.getLocalizedMessage()); GridData data = new GridData( diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/ui/dialog/SimpleSelectionDialog.java b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/ui/dialog/SimpleSelectionDialog.java index ccb1a43..ad76c71 100644 --- a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/ui/dialog/SimpleSelectionDialog.java +++ b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/ui/dialog/SimpleSelectionDialog.java @@ -5,6 +5,8 @@ import java.util.Collections; import java.util.Iterator; import java.util.List; +import com.quantum.model.Displayable; + import org.eclipse.jface.dialogs.Dialog; import org.eclipse.jface.dialogs.IDialogConstants; import org.eclipse.jface.viewers.ILabelProviderListener; @@ -38,7 +40,11 @@ public class SimpleSelectionDialog extends Dialog { } public String getColumnText(Object element, int columnIndex) { - return element.toString(); + if (element instanceof Displayable) { + return ((Displayable) element).getDisplayName(); + } else { + return element.toString(); + } } public void addListener(ILabelProviderListener listener) { diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/util/versioning/VersioningHelper.java b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/util/versioning/VersioningHelper.java index fcf6188..bbc2979 100644 --- a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/util/versioning/VersioningHelper.java +++ b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/util/versioning/VersioningHelper.java @@ -1,11 +1,20 @@ package com.quantum.util.versioning; +import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; +import org.eclipse.jface.action.IAction; +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.jface.resource.ImageRegistry; import org.eclipse.swt.SWT; import org.eclipse.swt.graphics.FontData; import org.eclipse.swt.widgets.FontDialog; +import org.eclipse.ui.IKeyBindingService; +import org.eclipse.ui.IWorkbench; +import org.eclipse.ui.IWorkbenchPartSite; +import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.actions.ExportResourcesAction; import org.eclipse.ui.part.ViewPart; import org.eclipse.ui.part.WorkbenchPart; @@ -17,6 +26,7 @@ import org.eclipse.ui.part.WorkbenchPart; */ public class VersioningHelper { + public static final int ECLIPSE_VERSION_2_0_1 = 2049; public static final int ECLIPSE_VERSION_2_1_1 = 2135; public static final int ECLIPSE_VERSION_3_0_RC1 = 3054; public static final int ECLIPSE_VERSION_3_0_RC3 = 3061; @@ -73,7 +83,104 @@ public class VersioningHelper { } } + public static ExportResourcesAction createExportResourcesAction(IWorkbenchWindow window) { + ExportResourcesAction action = null; + + try { + if (isEclipse21OrHigher()) { + Constructor constructor = ExportResourcesAction.class.getConstructor( + new Class[] { IWorkbenchWindow.class }); + action = (ExportResourcesAction) constructor.newInstance( + new Object[] { window }); + } else { + Constructor constructor = ExportResourcesAction.class.getConstructor( + new Class[] { IWorkbench.class }); + action = (ExportResourcesAction) constructor.newInstance( + new Object[] { window.getWorkbench() }); + } + } catch (NoSuchMethodException e) { + // should not happen + } catch (IllegalArgumentException e) { + // should not happen + } catch (IllegalAccessException e) { + // should not happen + } catch (InvocationTargetException e) { + // should not happen + } catch (InstantiationException e) { + // should not happen + } + return action; + } + + public static void registerActionToKeyBindingService( + IWorkbenchPartSite site, String[] scopes, IAction action) { + + try { + if (isEclipse21OrHigher()) { + Method method = IWorkbenchPartSite.class.getMethod( + "getKeyBindingService", new Class[0]); + IKeyBindingService service = (IKeyBindingService) method.invoke(site, null); + + method = IKeyBindingService.class.getMethod( + "setScopes", new Class[] { String[].class }); + method.invoke(service, new Object[] { scopes}); + + service.registerAction(action); + } + } catch (NoSuchMethodException e) { + // should not happen + } catch (IllegalArgumentException e) { + // should not happen + } catch (IllegalAccessException e) { + // should not happen + } catch (InvocationTargetException e) { + // should not happen + } + } + public static void main(String[] args) { System.out.println(SWT.getVersion()); } + + /** + * @return + */ + public static boolean isEclipse30() { + return SWT.getVersion() >= 3000; + } + + /** + * @return + */ + public static boolean isEclipse21OrHigher() { + return SWT.getVersion() >= 2100; + } + /** + * Method getDescriptor. + * @param registry + * @param imageName + * @return ImageDescriptor + */ + public static ImageDescriptor getDescriptor( + ImageRegistry registry, + String imageName) { + ImageDescriptor descriptor = null; + try { + if (isEclipse21OrHigher()) { + Method method = ImageRegistry.class.getMethod( + "getDescriptor", new Class[] { String.class }); + descriptor = (ImageDescriptor) method.invoke(registry, new Object[] {imageName}); + } + } catch (NoSuchMethodException e) { + // should not happen + } catch (IllegalArgumentException e) { + // should not happen + } catch (IllegalAccessException e) { + // should not happen + } catch (InvocationTargetException e) { + // should not happen + } + return descriptor; + } + } diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/JDBCDriverLabelProvider.java b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/JDBCDriverLabelProvider.java deleted file mode 100644 index ca2f50f..0000000 --- a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/JDBCDriverLabelProvider.java +++ /dev/null @@ -1,51 +0,0 @@ -package com.quantum.view; - -import org.eclipse.jface.viewers.ILabelProviderListener; -import org.eclipse.jface.viewers.ITableLabelProvider; -import org.eclipse.swt.graphics.Image; - -import com.quantum.QuantumPlugin; -import com.quantum.model.JDBCDriver; - - -/** - * @author BC - */ -public class JDBCDriverLabelProvider implements ITableLabelProvider { - - public Image getColumnImage(Object element, int columnIndex) { - if (columnIndex == 0) { - return QuantumPlugin.getImage("driver.gif"); - } else { - return null; - } - } - - public String getColumnText(Object element, int columnIndex) { - switch (columnIndex) { - case 0: - return ((JDBCDriver) element).getName(); - case 1: - return ((JDBCDriver) element).getClassName(); - case 2: - return ((JDBCDriver) element).getVersion(); - case 3: - return ((JDBCDriver) element).getJarFileName(); - } - return null; - } - - public void addListener(ILabelProviderListener listener) { - } - - public void dispose() { - } - - public boolean isLabelProperty(Object element, String property) { - return false; - } - - public void removeListener(ILabelProviderListener listener) { - } - -} diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/JDBCDriverTableViewer.java b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/JDBCDriverTableViewer.java index c80e75e..8eb4bf1 100644 --- a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/JDBCDriverTableViewer.java +++ b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/JDBCDriverTableViewer.java @@ -7,6 +7,12 @@ import java.util.Collections; import java.util.Iterator; import java.util.List; +import com.quantum.ImageStore; +import com.quantum.Messages; +import com.quantum.adapters.AdapterFactory; +import com.quantum.model.BookmarkCollection; +import com.quantum.model.JDBCDriver; + import org.eclipse.jface.viewers.ILabelProviderListener; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.ISelectionChangedListener; @@ -23,12 +29,6 @@ import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Table; import org.eclipse.swt.widgets.TableColumn; -import com.quantum.Messages; -import com.quantum.QuantumPlugin; -import com.quantum.adapters.AdapterFactory; -import com.quantum.model.BookmarkCollection; -import com.quantum.model.JDBCDriver; - /** * @author BC @@ -38,7 +38,7 @@ public class JDBCDriverTableViewer implements PropertyChangeListener, ISelection public class LabelProviderImpl implements ITableLabelProvider { public Image getColumnImage(Object element, int columnIndex) { if (columnIndex == 0) { - return QuantumPlugin.getImage("driver.gif"); + return ImageStore.getImage(ImageStore.DRIVER); } else { return null; } diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/SQLLogView.java b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/SQLLogView.java index dfd7465..a3df2af 100644 --- a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/SQLLogView.java +++ b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/SQLLogView.java @@ -1,7 +1,7 @@ package com.quantum.view; +import com.quantum.ImageStore; import com.quantum.Messages; -import com.quantum.QuantumPlugin; import org.eclipse.jface.action.Action; import org.eclipse.jface.action.IToolBarManager; @@ -43,7 +43,7 @@ public class SQLLogView extends ViewPart implements LogConstants { bars.setGlobalActionHandler(IWorkbenchActionConstants.SELECT_ALL, selectAllAction); IToolBarManager toolBar = getViewSite().getActionBars().getToolBarManager(); - clearAction.setImageDescriptor(QuantumPlugin.getImageDescriptor("clear.gif")); //$NON-NLS-1$ + clearAction.setImageDescriptor(ImageStore.getImageDescriptor(ImageStore.CLEAR)); clearAction.setToolTipText(Messages.getString("SQLLogView.ClearLog")); //$NON-NLS-1$ toolBar.add(clearAction); 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 efdac83..0b14583 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,51 +1,57 @@ package com.quantum.view; -import java.sql.Connection; import java.sql.SQLException; import java.util.LinkedList; import java.util.NoSuchElementException; import java.util.Vector; +import com.quantum.ImageStore; +import com.quantum.Messages; +import com.quantum.QuantumPlugin; +import com.quantum.actions.ExecuteAction; +import com.quantum.actions.ExportQueryAction; +import com.quantum.actions.ImportQueryAction; +import com.quantum.model.Bookmark; +import com.quantum.model.BookmarkCollection; +import com.quantum.model.NotConnectedException; +import com.quantum.sql.MultiSQLServer; +import com.quantum.sql.SQLGrammar; +import com.quantum.sql.parser.SQLLexx; +import com.quantum.sql.parser.Token; +import com.quantum.ui.dialog.ExceptionDisplayDialog; +import com.quantum.util.versioning.VersioningHelper; + import org.eclipse.jface.action.Action; import org.eclipse.jface.action.IToolBarManager; import org.eclipse.jface.action.Separator; +import org.eclipse.jface.preference.PreferenceConverter; +import org.eclipse.jface.util.IPropertyChangeListener; +import org.eclipse.jface.util.PropertyChangeEvent; +import org.eclipse.jface.viewers.ILabelProvider; +import org.eclipse.jface.viewers.ILabelProviderListener; +import org.eclipse.jface.viewers.IStructuredContentProvider; +import org.eclipse.jface.viewers.Viewer; import org.eclipse.swt.SWT; import org.eclipse.swt.custom.ExtendedModifyEvent; import org.eclipse.swt.custom.ExtendedModifyListener; import org.eclipse.swt.custom.StyleRange; import org.eclipse.swt.custom.StyledText; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.events.SelectionListener; import org.eclipse.swt.graphics.Color; +import org.eclipse.swt.graphics.Font; +import org.eclipse.swt.graphics.FontData; +import org.eclipse.swt.graphics.Image; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.ToolBar; -import org.eclipse.swt.widgets.ToolItem; +import org.eclipse.swt.widgets.Display; import org.eclipse.ui.IActionBars; -import org.eclipse.ui.IKeyBindingService; import org.eclipse.ui.IWorkbenchActionConstants; import org.eclipse.ui.part.ViewPart; -import com.quantum.Messages; -import com.quantum.QuantumPlugin; -import com.quantum.actions.ExecuteAction; -import com.quantum.actions.ExportQueryAction; -import com.quantum.actions.ImportQueryAction; -import com.quantum.model.Bookmark; -import com.quantum.model.NotConnectedException; -import com.quantum.sql.MultiSQLServer; -import com.quantum.sql.parser.SQLLexx; -import com.quantum.sql.parser.Token; -import com.quantum.util.versioning.VersioningHelper; -import com.quantum.view.bookmark.BookmarkNode; -import com.quantum.view.bookmark.BookmarkView; - public class SQLQueryView extends ViewPart { private class ClearAction extends Action { public ClearAction() { - setImageDescriptor(QuantumPlugin.getImageDescriptor("clear.gif")); + setImageDescriptor(ImageStore.getImageDescriptor(ImageStore.CLEAR)); setToolTipText(Messages.getString("sqlqueryview.clear")); } @@ -57,79 +63,119 @@ public class SQLQueryView extends ViewPart { private class AutoCommitPreferenceAction extends Action { public AutoCommitPreferenceAction() { - super(Messages.getString("SQLQueryView.AutoCommit"), SWT.CHECK); + super(Messages.getString("SQLQueryView.AutoCommit")); setToolTipText(Messages.getString("SQLQueryView.AutoCommit")); - setImageDescriptor(QuantumPlugin.getImageDescriptor("autocommit.gif")); + setImageDescriptor(ImageStore.getImageDescriptor(ImageStore.AUTOCOMMIT)); } public void run() { - Connection connection = null; - try { - // Get the connection - connection = getBookmark().getConnection(); - // If connected (else will throw exception and jump out) switchs the state of the - // autoCommit option of the JDBC driver - MultiSQLServer.getInstance().setAutoCommit( connection, isChecked()); - } catch (NotConnectedException e) { - //Doesn't matter - } - // Update the bookmark and the buttons - updateAutoCommitState(getBookmark(), connection); + setAutoCommitPreference(isChecked()); } } + private class RollbackAction extends Action { + public RollbackAction() { + setText(Messages.getString("SQLQueryView.RollBack")); + setToolTipText(Messages.getString("SQLQueryView.RollBack")); + } + + public void run() { + Bookmark[] bookmarks = BookmarkCollection.getInstance().getBookmarks(); + for (int i = 0, length = bookmarks == null ? 0 : bookmarks.length; i < length; i++) { + try { + if (bookmarks[i].isConnected() && !bookmarks[i].getConnection().getAutoCommit()) { + MultiSQLServer.getInstance().rollback(bookmarks[i].getConnection()); + } + } catch (SQLException e) { + ExceptionDisplayDialog.openError(getSite().getShell(), null, null, e); + } catch (NotConnectedException e) { + ExceptionDisplayDialog.openError(getSite().getShell(), null, null, e); + } + } + } + } + + + private class CommitAction extends Action { + public CommitAction() { + setText(Messages.getString("SQLQueryView.Commit")); + setToolTipText(Messages.getString("SQLQueryView.Commit")); + } + + public void run() { + Bookmark[] bookmarks = BookmarkCollection.getInstance().getBookmarks(); + for (int i = 0, length = bookmarks == null ? 0 : bookmarks.length; i < length; i++) { + try { + if (bookmarks[i].isConnected() && !bookmarks[i].getConnection().getAutoCommit()) { + MultiSQLServer.getInstance().commit(bookmarks[i].getConnection()); + } + } catch (SQLException e) { + ExceptionDisplayDialog.openError(getSite().getShell(), null, null, e); + } catch (NotConnectedException e) { + ExceptionDisplayDialog.openError(getSite().getShell(), null, null, e); + } + } + } + } + + + public class LabelProviderImpl implements ILabelProvider { + public Image getImage(Object element) { + return ImageStore.getImage(ImageStore.BOOKMARK); + } + public String getText(Object element) { + if (element instanceof Bookmark) { + return ((Bookmark) element).getName(); + } else { + return null; + } + } + public void addListener(ILabelProviderListener listener) { + } + public void dispose() { + } + public boolean isLabelProperty(Object element, String property) { + return false; + } + public void removeListener(ILabelProviderListener listener) { + } + } + public class ContentProviderImpl implements IStructuredContentProvider { + public Object[] getElements(Object inputElement) { + if (inputElement instanceof BookmarkCollection) { + return ((BookmarkCollection) inputElement).getBookmarks(); + } else { + return null; + } + } + public void dispose() { + } + public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { + } + } private ExecuteAction executeAction; private ImportQueryAction importQueryAction; private ExportQueryAction exportQueryAction; private StyledText widget; - private ToolItem autoCommitItem; - private ToolItem commitItem; - private ToolItem rollbackItem; private Color STRING_LITERAL; private Color KEYWORD; private Color COMMENT; private Color NUMERIC; private Color DEFAULT; private AutoCommitPreferenceAction autoCommitPreferenceAction; + private RollbackAction rollbackAction; + private CommitAction commitAction; + private boolean autoCommitPreference = true; public SQLQueryView() { super(); - } - public void setFocus() { - - String title = "Quantum SQL Query Editor"; - Bookmark bookmark = null; - Connection con = null; - if (BookmarkView.getInstance() != null ) { - bookmark = getBookmark(); - } - if (bookmark != null) { - title = bookmark.getName() + " (" + title + ")"; - VersioningHelper.setPartName(this, title); -// setPartName("fred"); - try { - con = bookmark.getConnection(); - } catch (NotConnectedException e) { - // Doesn't matter, "con" remains null + IPropertyChangeListener listener = new IPropertyChangeListener() { + public void propertyChange(PropertyChangeEvent event) { + setFont(); } - } - - updateAutoCommitState(bookmark, con); - - widget.setFocus(); - - } - /** - * @return - */ - private Bookmark getBookmark() { - if (BookmarkView.getInstance() != null ) { - BookmarkNode node = BookmarkView.getInstance().getCurrentBookmark(); - return node == null ? null : node.getBookmark(); - } else { - return null; - } + }; + QuantumPlugin.getDefault().getPreferenceStore().addPropertyChangeListener(listener); } public static SQLQueryView getInstance() { return (SQLQueryView) QuantumPlugin.getDefault().getView("com.quantum.view.sqlqueryview"); @@ -139,97 +185,18 @@ public class SQLQueryView extends ViewPart { public void createPartControl(org.eclipse.swt.widgets.Composite parent) { initActions(); - KEYWORD = new Color(parent.getShell().getDisplay(), 126, 0, 75); - STRING_LITERAL = new Color(parent.getShell().getDisplay(), 0, 0, 255); - COMMENT = new Color(parent.getShell().getDisplay(), 88, 148, 64); - NUMERIC = new Color(parent.getShell().getDisplay(), 255, 0, 0); - DEFAULT = new Color(parent.getShell().getDisplay(), 0, 0, 0); - Composite main = new Composite(parent, SWT.NONE); + initializeColours(parent); GridLayout layout = new GridLayout(1, false); layout.horizontalSpacing = 0; layout.verticalSpacing = 0; - main.setLayout(layout); - ToolBar toolbar = new ToolBar(main, SWT.HORIZONTAL); - - commitItem = new ToolItem(toolbar, SWT.PUSH); - commitItem.setImage(QuantumPlugin.getImage("commit.gif")); //$NON-NLS-1$ - commitItem.setToolTipText(Messages.getString("SQLQueryView.Commit")); //$NON-NLS-1$ - commitItem.addSelectionListener(new SelectionListener() { - public void widgetDefaultSelected(SelectionEvent e) { - } - public void widgetSelected(SelectionEvent event) { - try { - BookmarkNode node = BookmarkView.getInstance().getCurrentBookmark(); - if (node != null) MultiSQLServer.getInstance().commit( - node.getBookmark().getConnection()); - } catch (NotConnectedException e) { - e.printStackTrace(); - } - } - }); + layout.marginHeight = 0; + layout.marginWidth = 0; + parent.setLayout(layout); + parent.setLayoutData(new GridData(GridData.FILL_BOTH)); - rollbackItem = new ToolItem(toolbar, SWT.PUSH); - rollbackItem.setImage(QuantumPlugin.getImage("rollback.gif")); //$NON-NLS-1$ - rollbackItem.setToolTipText(Messages.getString("SQLQueryView.RollBack")); //$NON-NLS-1$ - rollbackItem.addSelectionListener(new SelectionListener() { - public void widgetDefaultSelected(SelectionEvent event) { - } - public void widgetSelected(SelectionEvent event) { - try { - BookmarkNode node = BookmarkView.getInstance().getCurrentBookmark(); - if (node != null) MultiSQLServer.getInstance().rollback( - node.getBookmark().getConnection()); - } catch (NotConnectedException e) { - e.printStackTrace(); - } - } - }); - - autoCommitItem = new ToolItem(toolbar, SWT.CHECK); - autoCommitItem.setImage(QuantumPlugin.getImage("autocommit.gif")); //$NON-NLS-1$ - autoCommitItem.setToolTipText(Messages.getString("SQLQueryView.AutoCommit")); //$NON-NLS-1$ - autoCommitItem.addSelectionListener(new SelectionListener() { - public void widgetDefaultSelected(SelectionEvent e) { - } - public void widgetSelected(SelectionEvent event) { - BookmarkNode node = BookmarkView.getInstance().getCurrentBookmark(); - if (node == null) return; - Connection con = null; - try { - // Get the connection - con = node.getBookmark().getConnection(); - // If connected (else will throw exception and jump out) switchs the state of the - // autoCommit option of the JDBC driver - MultiSQLServer.getInstance().setAutoCommit( con, autoCommitItem.getSelection()); - } catch (NotConnectedException e) { - //Doesn't matter - } - // Update the bookmark and the buttons - updateAutoCommitState(node.getBookmark(), con); - - } - }); - - // TODO: BCH -- this is causing some problems during start-up - Bookmark bookmark = null; - try { - bookmark = getBookmark(); - } catch (NullPointerException e) { - } + widget = new StyledText(parent, SWT.H_SCROLL | SWT.V_SCROLL); - if (bookmark == null) { - autoCommitItem.setSelection(true); - } else { - autoCommitItem.setSelection(bookmark.isAutoCommit()); - } - if (autoCommitItem.getSelection()) { - commitItem.setEnabled(false); - rollbackItem.setEnabled(false); - } else { - commitItem.setEnabled(true); - rollbackItem.setEnabled(true); - } - widget = new StyledText(main, SWT.H_SCROLL | SWT.V_SCROLL); + setFont(); IActionBars bars = this.getViewSite().getActionBars(); bars.setGlobalActionHandler(IWorkbenchActionConstants.CUT, cutAction); @@ -240,64 +207,41 @@ public class SQLQueryView extends ViewPart { widget.setEditable(true); widget.addExtendedModifyListener(modifyListener); - GridData gridData = new GridData(); - gridData.horizontalAlignment = GridData.FILL; - gridData.verticalAlignment = GridData.FILL; - gridData.grabExcessHorizontalSpace = true; - gridData.grabExcessVerticalSpace = true; - widget.setLayoutData(gridData); + widget.setLayoutData(new GridData(GridData.FILL_BOTH)); - IKeyBindingService keyBindingService = getSite().getKeyBindingService(); - // TODO: check the version numbers for this method - keyBindingService.setScopes(new String[] { - "org.eclipse.ui.globalScope", - "com.quantum.view.sql" - }); - keyBindingService.registerAction(this.executeAction); + VersioningHelper.registerActionToKeyBindingService(getSite(), + new String[] { "org.eclipse.ui.globalScope", "com.quantum.view.sql" }, + this.executeAction); } /** - * Sets the state of the "Commit", "Rollback" and "autoCommit" buttons - * to reflect the situation in the connection + * @param widget2 */ - protected void updateAutoCommitState(Bookmark bookmark, Connection connection) { - boolean autoCommit = true; - // Calculate the state of the autoCommit option - if (connection != null) - { - // If we have a connection, the autoCommit state is that of the connection - try { - autoCommit = connection.getAutoCommit(); - } catch (SQLException e) { - // Doesn't matter, we take default - } - } else { - // if no connection, we try the autoCommit of the bookmark, or else the default - if (bookmark != null) autoCommit = bookmark.isAutoCommit(); - } - // Set the autoCommit state of the bookmark to the calculated - if (bookmark != null) bookmark.setAutoCommit(autoCommit); - // Set the state of the buttons to the correct autoCommit state - autoCommitItem.setSelection(autoCommit); - this.autoCommitPreferenceAction.setChecked(autoCommit); - if (autoCommitItem.getSelection()) { - commitItem.setEnabled(false); - rollbackItem.setEnabled(false); - } else { - commitItem.setEnabled(true); - rollbackItem.setEnabled(true); + private void setFont() { + FontData font = PreferenceConverter.getFontData( + QuantumPlugin.getDefault().getPreferenceStore(), + "quantum.font"); //$NON-NLS-1$ + if (font != null && this.widget != null) { + this.widget.setFont(new Font(Display.getCurrent(), font)); } } + /** + * @param parent + */ + private void initializeColours(org.eclipse.swt.widgets.Composite parent) { + KEYWORD = new Color(parent.getShell().getDisplay(), 126, 0, 75); + STRING_LITERAL = new Color(parent.getShell().getDisplay(), 0, 0, 255); + COMMENT = new Color(parent.getShell().getDisplay(), 88, 148, 64); + NUMERIC = new Color(parent.getShell().getDisplay(), 255, 0, 0); + DEFAULT = new Color(parent.getShell().getDisplay(), 0, 0, 0); + } + private void initActions() { - executeAction = new ExecuteAction(); - executeAction.init(this); - IToolBarManager toolBar = getViewSite().getActionBars().getToolBarManager(); + + executeAction = new ExecuteAction(this); toolBar.add(this.executeAction); -// toolBar.add(this.importQueryAction); -// toolBar.add(this.exportQueryAction); - toolBar.add(new ClearAction()); IActionBars actionBars = getViewSite().getActionBars(); @@ -309,8 +253,15 @@ public class SQLQueryView extends ViewPart { actionBars.getMenuManager().add(this.exportQueryAction); actionBars.getMenuManager().add(new Separator()); this.autoCommitPreferenceAction = new AutoCommitPreferenceAction(); + this.autoCommitPreferenceAction.setChecked(this.autoCommitPreference); actionBars.getMenuManager().add(this.autoCommitPreferenceAction); - } + + this.rollbackAction = new RollbackAction(); + actionBars.getMenuManager().add(this.rollbackAction); + + this.commitAction = new CommitAction(); + actionBars.getMenuManager().add(this.commitAction); +} public String getQuery() { return widget.getText(); @@ -320,32 +271,6 @@ public class SQLQueryView extends ViewPart { widget.setText(text); } - private String[] keywords = { - "ADD", "ALL", "ALTER", "AND", "ANY", - "AS", "ASC", "AUTOINCREMENT", "AVA", "BETWEEN", - "BINARY", "BIT", "BOOLEAN", "BY", "CREATE", - "BYTE", "CHAR", "CHARACTER", "COLUMN", "CONSTRAINT", - "COUNT", "COUNTER", "CURRENCY", "DATABASE", "DATE", - "DATETIME", "DELETE", "DESC", "DISALLOW", "DISTINCT", - "DISTINCTROW", "DOUBLE", "DROP", "EXISTS", "FROM", - "FLOAT", "FLOAT4", "FLOAT8", "FOREIGN", "GENERAL", - "GROUP", "GUID", "HAVING", "INNER", "INSERT", - "IGNORE", "IMP", "IN", "INDEX", "INT", - "INTEGER", "INTEGER1", "INTEGER2", "INTEGER4", "INTO", - "IS", "JOIN", "KEY", "LEFT", "LEVEL", - "LIKE", "LOGICAL", "LONG", "LONGBINARY", "LONGTEXT", - "MAX", "MEMO", "MIN", "MOD", "MONEY", - "NOT", "NULL", "NUMBER", "NUMERIC", "OLEOBJECT", - "ON", "PIVOT", "OPTION", "PRIMARY", "ORDER", - "OUTER", "OWNERACCESS", "PARAMETERS", "PERCENT", "REAL", - "REFERENCES", "RIGHT", "SELECT", "SET", "SHORT", - "SINGLE", "SMALLINT", "SOME", "STDEV", "STDEVP", - "STRING", "SUM", "TABLE", "TABLEID", "TEXT", - "TIME", "TIMESTAMP", "TOP", "TRANSFORM", "UNION", - "UNIQUE", "UPDATE", "VALUE", "VALUES", "VAR", - "VARBINARY", "VARCHAR", "VARP", "WHERE", "WITH", - "YESNO" }; - SyntaxHighlighter textUpdater = new SyntaxHighlighter(); private class UpdateRequest { @@ -413,8 +338,8 @@ public class SQLQueryView extends ViewPart { max = Math.max(max, start + length); if (t.getType() == Token.IDENTIFIER) { boolean keyword = false; - for (int index = 0; index < keywords.length; index++) { - if (value.equals(keywords[index])) { + for (int index = 0; index < SQLGrammar.KEYWORDS.length; index++) { + if (value.equals(SQLGrammar.KEYWORDS[index])) { keyword = true; } } @@ -495,4 +420,13 @@ public class SQLQueryView extends ViewPart { widget.selectAll(); } }; + + public void setFocus() { + } + public boolean isAutoCommitPreference() { + return this.autoCommitPreference; + } + public void setAutoCommitPreference(boolean autoCommitPreference) { + this.autoCommitPreference = autoCommitPreference; + } } 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 f18c3b9..4a7fa72 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 @@ -12,8 +12,8 @@ import java.util.Iterator; import java.util.List; import java.util.Set; +import com.quantum.ImageStore; import com.quantum.Messages; -import com.quantum.QuantumPlugin; import com.quantum.model.Bookmark; import com.quantum.model.ConnectionException; import com.quantum.model.NotConnectedException; @@ -65,7 +65,7 @@ public class SchemaSelectionControl extends Composite { public Image getColumnImage(Object element, int columnIndex) { if (columnIndex == 0) { - return QuantumPlugin.getImage("schema.gif"); + return ImageStore.getImage(ImageStore.SCHEMA); } else { return null; } @@ -254,7 +254,7 @@ public class SchemaSelectionControl extends Composite { SimpleSelectionDialog dialog = new SimpleSelectionDialog( getShell(), Messages.getString(getClass(), "addSchemaDialog"), schemaList.toArray(), - QuantumPlugin.getImage("schema.gif"), true); + ImageStore.getImage(ImageStore.SCHEMA), true); int result = dialog.open(); if (result == SimpleSelectionDialog.OK && !dialog.getSelection().isEmpty()) { diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/bookmark/BookmarkView.java b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/bookmark/BookmarkView.java index f43a99a..e266cb4 100644 --- a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/bookmark/BookmarkView.java +++ b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/bookmark/BookmarkView.java @@ -25,6 +25,7 @@ import org.eclipse.ui.WorkbenchException; import org.eclipse.ui.actions.ActionContext; import org.eclipse.ui.part.ViewPart; +import com.quantum.ImageStore; import com.quantum.Messages; import com.quantum.QuantumPlugin; import com.quantum.actions.CustomCopyAction; @@ -185,21 +186,21 @@ public class BookmarkView extends ViewPart implements PropertyChangeListener { this.customCopyAction1 = new CustomCopyAction(this,1); // 1 is unused, just in case more custom copies are defined this.customCopyAction1.setText(text1); //$NON-NLS-1$ this.customCopyAction1.setImageDescriptor( - QuantumPlugin.getImageDescriptor("copy.gif")); //$NON-NLS-1$ + ImageStore.getImageDescriptor(ImageStore.COPY)); //$NON-NLS-1$ } String text2 = store.getString("customCopyName2"); if (text2 != null && text1.trim().length() > 0) { this.customCopyAction2 = new CustomCopyAction(this,2); // 1 is unused, just in case more custom copies are defined this.customCopyAction2.setText(text2); //$NON-NLS-1$ this.customCopyAction2.setImageDescriptor( - QuantumPlugin.getImageDescriptor("copy.gif")); //$NON-NLS-1$ + ImageStore.getImageDescriptor(ImageStore.COPY)); //$NON-NLS-1$ } String text3 = store.getString("customCopyName3"); if (text3 != null && text1.trim().length() > 0) { this.customCopyAction3 = new CustomCopyAction(this,3); // 1 is unused, just in case more custom copies are defined this.customCopyAction3.setText(text3); //$NON-NLS-1$ this.customCopyAction3.setImageDescriptor( - QuantumPlugin.getImageDescriptor("copy.gif")); //$NON-NLS-1$ + ImageStore.getImageDescriptor(ImageStore.COPY)); //$NON-NLS-1$ } } public void dispose(){ 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 09f636b..3af90bd 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 @@ -2,7 +2,7 @@ package com.quantum.view.bookmark; import java.util.Iterator; -import com.quantum.QuantumPlugin; +import com.quantum.ImageStore; import com.quantum.actions.AddToQuickListAction; import com.quantum.actions.ConnectAction; import com.quantum.actions.DeleteAllRowsAction; @@ -17,6 +17,7 @@ import com.quantum.actions.RemoveFromQuickListAction; import com.quantum.actions.ViewTableAction; import com.quantum.actions.ViewTableDetailsAction; import com.quantum.model.Bookmark; +import com.quantum.util.versioning.VersioningHelper; import org.eclipse.jface.action.Action; import org.eclipse.jface.action.IAction; @@ -103,9 +104,9 @@ public class BookmarkViewActionGroup extends ActionGroup this.renameAction = new RenameAction(this.viewPart); this.copyAction = new CopyAction(this.viewPart, this, selectionProvider); this.pasteAction = new PasteAction(this.viewPart, this, selectionProvider); - this.exportAction = new ExportResourcesAction( - this.viewPart.getViewSite().getWorkbenchWindow()); - this.exportAction.setImageDescriptor(QuantumPlugin.getImageDescriptor("export.gif")); + this.exportAction = VersioningHelper.createExportResourcesAction( + this.viewPart.getViewSite().getWorkbenchWindow()); + this.exportAction.setImageDescriptor(ImageStore.getImageDescriptor(ImageStore.EXPORT)); this.propertiesAction = new PropertyDialogAction( this.viewPart.getSite().getShell(), selectionProvider); @@ -144,8 +145,10 @@ public class BookmarkViewActionGroup extends ActionGroup // NOTE: In Eclipse 3.0.0 M6, Export is no longer a sub-class of // SelectionListenerAction. - this.exportAction.selectionChanged(getStructuredSelection()); - menu.add(this.exportAction); + if (this.exportAction != null) { + this.exportAction.selectionChanged(getStructuredSelection()); + menu.add(this.exportAction); + } if (getStructuredSelection().size() == 1 && isEverySelectionInstanceof(BookmarkNode.class)) { diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/bookmark/CopyAction.java b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/bookmark/CopyAction.java index 4166947..d4d97ab 100644 --- a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/bookmark/CopyAction.java +++ b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/bookmark/CopyAction.java @@ -11,6 +11,7 @@ import java.util.List; import javax.xml.parsers.ParserConfigurationException; +import com.quantum.ImageStore; import com.quantum.Messages; import com.quantum.QuantumPlugin; import com.quantum.model.Bookmark; @@ -38,7 +39,7 @@ final class CopyAction extends SelectionListenerAction { public CopyAction(IViewPart view, BookmarkClipboard bookmarkClipboard, ISelectionProvider selectionProvider) { super(Messages.getString(CopyAction.class.getName() + ".text")); - setImageDescriptor(QuantumPlugin.getImageDescriptor("copy.gif")); + setImageDescriptor(ImageStore.getImageDescriptor(ImageStore.COPY)); this.bookmarkClipboard = bookmarkClipboard; selectionProvider.addSelectionChangedListener(this); } diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/bookmark/PasteAction.java b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/bookmark/PasteAction.java index cf0f628..f43c1e4 100644 --- a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/bookmark/PasteAction.java +++ b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/bookmark/PasteAction.java @@ -5,8 +5,8 @@ import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.ui.IViewPart; import org.eclipse.ui.actions.SelectionListenerAction; +import com.quantum.ImageStore; import com.quantum.Messages; -import com.quantum.QuantumPlugin; import com.quantum.model.Bookmark; import com.quantum.model.BookmarkCollection; @@ -19,7 +19,7 @@ final class PasteAction extends SelectionListenerAction { public PasteAction(IViewPart view, BookmarkClipboard bookmarkClipboard, ISelectionProvider selectionProvider) { super(Messages.getString(PasteAction.class.getName() + ".text")); - setImageDescriptor(QuantumPlugin.getImageDescriptor("paste.gif")); + setImageDescriptor(ImageStore.getImageDescriptor(ImageStore.PASTE)); selectionProvider.addSelectionChangedListener(this); this.bookmarkClipboard = bookmarkClipboard; } 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 7552995..8b9825e 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 @@ -5,7 +5,7 @@ import java.sql.SQLException; import java.util.Iterator; import java.util.Vector; -import com.quantum.QuantumPlugin; +import com.quantum.ImageStore; import com.quantum.model.Bookmark; import com.quantum.model.BookmarkHolder; import com.quantum.model.NotConnectedException; @@ -47,7 +47,7 @@ public abstract class TreeNode * @return an Image object to appear in the view, null if not found */ public Image getImage() { - return QuantumPlugin.getImage(getImageName()); + return ImageStore.getImage(getImageName()); } /** diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/subset/SubsetView.java b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/subset/SubsetView.java index 448ff51..09cd2c1 100644 --- a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/subset/SubsetView.java +++ b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/subset/SubsetView.java @@ -8,6 +8,7 @@ import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; +import com.quantum.ImageStore; import com.quantum.Messages; import com.quantum.QuantumPlugin; import com.quantum.actions.CustomCopyAction; @@ -104,7 +105,7 @@ public class SubsetView extends ViewPart { private static SubsetNode getRoot(TreeNode node){ while (!( node instanceof SubsetNode)) { - node = (TreeNode) node.getParent(); + node = node.getParent(); } return (SubsetNode) node; @@ -174,31 +175,31 @@ public class SubsetView extends ViewPart { mgr.add(deleteSubsetAction); deleteSubsetAction.setText(Messages.getString("SubsetView.Delete")); //$NON-NLS-1$ deleteSubsetAction.setImageDescriptor( - QuantumPlugin.getImageDescriptor("delete.gif")); //$NON-NLS-1$ + ImageStore.getImageDescriptor(ImageStore.DELETE)); mgr.add(pasteAction); pasteAction.setText(Messages.getString("SubsetView.Paste")); //$NON-NLS-1$ - pasteAction.setImageDescriptor(QuantumPlugin.getImageDescriptor("paste.gif")); //$NON-NLS-1$ + pasteAction.setImageDescriptor(ImageStore.getImageDescriptor(ImageStore.PASTE)); mgr.add(exportXMLAction); exportXMLAction.setText(Messages.getString("bookmarkview.exportXML")); //$NON-NLS-1$ - exportXMLAction.setImageDescriptor(QuantumPlugin.getImageDescriptor("xml.gif")); //$NON-NLS-1$ + exportXMLAction.setImageDescriptor(ImageStore.getImageDescriptor(ImageStore.XML)); } else if (sel instanceof ObjectNode) { mgr.add(deleteObjectAction); deleteObjectAction.setText(Messages.getString("SubsetView.Delete")); //$NON-NLS-1$ - deleteObjectAction.setImageDescriptor(QuantumPlugin.getImageDescriptor("delete.gif")); //$NON-NLS-1$ + deleteObjectAction.setImageDescriptor(ImageStore.getImageDescriptor(ImageStore.DELETE)); mgr.add(viewTableAction); viewTableAction.setText(Messages.getString("bookmarkview.viewTable")); //$NON-NLS-1$ - viewTableAction.setImageDescriptor(QuantumPlugin.getImageDescriptor("table.gif")); //$NON-NLS-1$ + viewTableAction.setImageDescriptor(ImageStore.getImageDescriptor(ImageStore.OPEN_TABLE)); mgr.add(exportXMLAction); exportXMLAction.setText(Messages.getString("bookmarkview.exportXML")); //$NON-NLS-1$ - exportXMLAction.setImageDescriptor(QuantumPlugin.getImageDescriptor("xml.gif")); //$NON-NLS-1$ + exportXMLAction.setImageDescriptor(ImageStore.getImageDescriptor(ImageStore.XML)); customCopyAction.selectionChanged( (IStructuredSelection) treeViewer.getSelection()); mgr.add(customCopyAction); } else if (sel instanceof ColumnNode){ mgr.add(deleteColumnAction); deleteColumnAction.setText(Messages.getString("SubsetView.Delete")); //$NON-NLS-1$ - deleteColumnAction.setImageDescriptor(QuantumPlugin.getImageDescriptor("delete.gif")); //$NON-NLS-1$ + deleteColumnAction.setImageDescriptor(ImageStore.getImageDescriptor(ImageStore.DELETE)); customCopyAction.selectionChanged( (IStructuredSelection) treeViewer.getSelection()); mgr.add(customCopyAction); @@ -235,25 +236,25 @@ public class SubsetView extends ViewPart { newSubsetAction.setText("New Subset"); //$NON-NLS-1$ newSubsetAction.setToolTipText(Messages.getString("SubsetView.CreatesANewEmptySubset")); //$NON-NLS-1$ newSubsetAction.setImageDescriptor( - QuantumPlugin.getImageDescriptor("subset.gif")); //$NON-NLS-1$ + ImageStore.getImageDescriptor(ImageStore.SUBSET)); newSubsetAction.init(this); deleteColumnAction = new DeleteColumnAction(); deleteColumnAction.setText("Delete Column"); //$NON-NLS-1$ deleteColumnAction.setToolTipText(Messages.getString("SubsetView.DeletesTheSelectedColumns")); //$NON-NLS-1$ deleteColumnAction.setImageDescriptor( - QuantumPlugin.getImageDescriptor("delete.gif")); //$NON-NLS-1$ + ImageStore.getImageDescriptor(ImageStore.DELETE)); deleteColumnAction.init(this); deleteObjectAction = new DeleteObjectAction(); deleteObjectAction.setText("Delete Object"); //$NON-NLS-1$ deleteObjectAction.setToolTipText(Messages.getString("SubsetView.DeletesTheSelectedObject")); //$NON-NLS-1$ deleteObjectAction.setImageDescriptor( - QuantumPlugin.getImageDescriptor("delete.gif")); //$NON-NLS-1$ + ImageStore.getImageDescriptor(ImageStore.DELETE)); deleteObjectAction.init(this); deleteSubsetAction = new DeleteSubsetAction(); deleteSubsetAction.setText("Delete Subset"); //$NON-NLS-1$ deleteSubsetAction.setToolTipText(Messages.getString("SubsetView.DeletesTheSelectedSubset")); //$NON-NLS-1$ deleteSubsetAction.setImageDescriptor( - QuantumPlugin.getImageDescriptor("delete.gif")); //$NON-NLS-1$ + ImageStore.getImageDescriptor(ImageStore.DELETE)); deleteSubsetAction.init(this); // viewTableAction = new ViewTableAction(); // viewTableAction.setText(Messages.getString("bookmarkview.viewTable")); //$NON-NLS-1$ @@ -263,13 +264,13 @@ public class SubsetView extends ViewPart { exportXMLAction = new ExportXMLAction(); exportXMLAction.setText(Messages.getString("bookmarkview.exportXML")); //$NON-NLS-1$ exportXMLAction.setImageDescriptor( - QuantumPlugin.getImageDescriptor("table.gif")); //$NON-NLS-1$ + ImageStore.getImageDescriptor(ImageStore.XML)); exportXMLAction.init(this); this.customCopyAction = new CustomCopyAction(this,1); // 1 is unused, just in case more custom copies are defined this.customCopyAction.setText(Messages.getString("bookmarkview.customCopyAction")); //$NON-NLS-1$ this.customCopyAction.setImageDescriptor( - QuantumPlugin.getImageDescriptor("copy.gif")); //$NON-NLS-1$ + ImageStore.getImageDescriptor(ImageStore.COPY)); diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/tableview/TableAdapter.java b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/tableview/TableAdapter.java index e833620..e65c9d0 100644 --- a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/tableview/TableAdapter.java +++ b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/tableview/TableAdapter.java @@ -187,31 +187,31 @@ public class TableAdapter { } } - public TableViewer addTableViewer(Table table) { - TableViewer tableViewer = new TableViewer(table); - tableViewer.setUseHashlookup(true); - String[] colNams = new String[columnNames.size()]; - for (int i = 0; i < columnNames.size(); i++) { - colNams[i] = (String) columnNames.get(i); - } - tableViewer.setColumnProperties(colNams); - - // Create the cell editors - CellEditor[] editors = new CellEditor[columnNames.size()]; - for (int i = 0; i < columnNames.size(); i++) { - TextCellEditor textEditor = new TextCellEditor(table); - ((Text) textEditor.getControl()).setTextLimit(60); - editors[i] = textEditor; - } - // Assign the cell editors to the viewer - tableViewer.setCellEditors(editors); - // Set the cell modifier for the viewer - //tableViewer.setCellModifier(new MetaDataModifier(this)); - // Set the default sorter for the viewer - //tableViewer.setSorter(new ExampleTaskSorter(ExampleTaskSorter.DESCRIPTION)); - - return tableViewer; - } +// public TableViewer addTableViewer(Table table) { +// TableViewer tableViewer = new TableViewer(table); +// tableViewer.setUseHashlookup(true); +// String[] colNams = new String[columnNames.size()]; +// for (int i = 0; i < columnNames.size(); i++) { +// colNams[i] = (String) columnNames.get(i); +// } +// tableViewer.setColumnProperties(colNams); +// +// // Create the cell editors +// CellEditor[] editors = new CellEditor[columnNames.size()]; +// for (int i = 0; i < columnNames.size(); i++) { +// TextCellEditor textEditor = new TextCellEditor(table); +// ((Text) textEditor.getControl()).setTextLimit(60); +// editors[i] = textEditor; +// } +// // Assign the cell editors to the viewer +// tableViewer.setCellEditors(editors); +// // Set the cell modifier for the viewer +// //tableViewer.setCellModifier(new MetaDataModifier(this)); +// // Set the default sorter for the viewer +// //tableViewer.setSorter(new ExampleTaskSorter(ExampleTaskSorter.DESCRIPTION)); +// +// return tableViewer; +// } public int getPageSize() { return pageSize; diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/tableview/TableView.java b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/tableview/TableView.java index 8e23888..c9b151a 100644 --- a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/tableview/TableView.java +++ b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/tableview/TableView.java @@ -2,6 +2,16 @@ package com.quantum.view.tableview; import java.util.Vector; +import com.quantum.Messages; +import com.quantum.QuantumPlugin; +import com.quantum.extensions.ProcessServiceMembers; +import com.quantum.model.Bookmark; +import com.quantum.model.Entity; +import com.quantum.model.NotConnectedException; +import com.quantum.sql.SQLResults; +import com.quantum.ui.dialog.ExceptionDisplayDialog; +import com.quantum.view.LogProxy; + import org.eclipse.jface.action.Action; import org.eclipse.jface.action.IMenuListener; import org.eclipse.jface.action.MenuManager; @@ -23,16 +33,6 @@ import org.eclipse.ui.IWorkbenchPart; import org.eclipse.ui.WorkbenchException; import org.eclipse.ui.part.ViewPart; -import com.quantum.Messages; -import com.quantum.QuantumPlugin; -import com.quantum.extensions.ProcessServiceMembers; -import com.quantum.model.Bookmark; -import com.quantum.model.Entity; -import com.quantum.model.NotConnectedException; -import com.quantum.sql.SQLResults; -import com.quantum.ui.dialog.ExceptionDisplayDialog; -import com.quantum.view.LogProxy; - /** * The Table View. Displays tables and Queries. */ @@ -98,19 +98,23 @@ public class TableView extends ViewPart implements ISelectionListener { * Reload table or query data into the selected tab */ public void refreshCurrent() { - TabItem item = tabs.getItem(tabs.getSelectionIndex()); - TableAdapter adapter = (TableAdapter) item.getData(); - Bookmark bookmark = adapter.getBookmark(); - String table = adapter.getTable(); - if (table == null) { - loadTable(bookmark, item, null, null, true, true); - } else { - loadTable(bookmark, item, null, null, true, true); +System.out.println("Refresh?"); + if (tabs.getSelectionIndex() >= 0) { +System.out.println("Refresh!"); + TabItem item = tabs.getItem(tabs.getSelectionIndex()); + TableAdapter adapter = (TableAdapter) item.getData(); + Bookmark bookmark = adapter.getBookmark(); + String table = adapter.getTable(); + if (table == null) { + loadTable(bookmark, item, null, null, true, true); + } else { + loadTable(bookmark, item, null, null, true, true); + } + String title = Messages.getString("tableview.QuantumTableViewName"); //$NON-NLS-1$ + if (bookmark != null) + title = bookmark.getName() + Messages.getString("tableview.ViewNameInitialDecoration") + title + Messages.getString("tableview.ViewNameFinalDecoration"); //$NON-NLS-1$ //$NON-NLS-2$ + setTitle(title); } - String title = Messages.getString("tableview.QuantumTableViewName"); //$NON-NLS-1$ - if (bookmark != null) - title = bookmark.getName() + Messages.getString("tableview.ViewNameInitialDecoration") + title + Messages.getString("tableview.ViewNameFinalDecoration"); //$NON-NLS-1$ //$NON-NLS-2$ - setTitle(title); } public void loadQuery(Bookmark bookmark, SQLResults results) { @@ -277,6 +281,5 @@ public class TableView extends ViewPart implements ISelectionListener { } public void selectionChanged(IWorkbenchPart part, ISelection selection) { - } } \ No newline at end of file diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/tableview/TableViewToolBar.java b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/tableview/TableViewToolBar.java index cb06fbd..a4cd450 100644 --- a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/tableview/TableViewToolBar.java +++ b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/view/tableview/TableViewToolBar.java @@ -4,8 +4,8 @@ */ package com.quantum.view.tableview; +import com.quantum.ImageStore; import com.quantum.Messages; -import com.quantum.QuantumPlugin; import com.quantum.actions.CloseTableAction; import com.quantum.actions.RefreshTableAction; import com.quantum.model.NotConnectedException; @@ -33,8 +33,6 @@ import org.eclipse.swt.widgets.ToolItem; public class TableViewToolBar { private ToolBar toolBar; - private RefreshTableAction refreshTableAction; - private CloseTableAction closeTableAction; private ToolItem previous; private ToolItem next; @@ -49,36 +47,14 @@ public class TableViewToolBar { this.toolBar = toolBar; - refreshTableAction = new RefreshTableAction(); - refreshTableAction.setText(Messages.getString("tableview.refresh")); //$NON-NLS-1$ - refreshTableAction.setImageDescriptor( - QuantumPlugin.getImageDescriptor("refresh.gif")); //$NON-NLS-1$ - refreshTableAction.init(view); - closeTableAction = new CloseTableAction(); - closeTableAction.setText(Messages.getString("tableview.close")); //$NON-NLS-1$ - closeTableAction.setImageDescriptor( - QuantumPlugin.getImageDescriptor("close.gif")); //$NON-NLS-1$ - closeTableAction.init(view); - - ToolItem toolItem = new ToolItem(toolBar, SWT.PUSH); - toolItem.setImage(QuantumPlugin.getImage("refresh.gif")); //$NON-NLS-1$ - toolItem.setToolTipText(Messages.getString("tableview.refresh")); //$NON-NLS-1$ - toolItem.addSelectionListener(new SelectionListener() { - public void widgetDefaultSelected(SelectionEvent e) { - } - public void widgetSelected(SelectionEvent e) { - refreshTableAction.run(); - } - }); - final Action copyAction = new CopyAction(view, table); final Action selectAllAction = new Action() { public void run() { table.selectAll(); } }; - toolItem = new ToolItem(toolBar, SWT.PUSH); - toolItem.setImage(QuantumPlugin.getImage("copy.gif")); //$NON-NLS-1$ + ToolItem toolItem = new ToolItem(toolBar, SWT.PUSH); + toolItem.setImage(ImageStore.getImage(ImageStore.COPY)); toolItem.setToolTipText(Messages.getString("tableview.copy")); //$NON-NLS-1$ toolItem.addSelectionListener(new SelectionListener() { public void widgetDefaultSelected(SelectionEvent e) { @@ -88,7 +64,7 @@ public class TableViewToolBar { } }); toolItem = new ToolItem(toolBar, SWT.PUSH); - toolItem.setImage(QuantumPlugin.getImage("table.gif")); //$NON-NLS-1$ + toolItem.setImage(ImageStore.getImage(ImageStore.OPEN_TABLE)); //$NON-NLS-1$ toolItem.setToolTipText(Messages.getString("tableview.selectAll")); //$NON-NLS-1$ toolItem.addSelectionListener(new SelectionListener() { public void widgetDefaultSelected(SelectionEvent e) { @@ -99,7 +75,7 @@ public class TableViewToolBar { }); filter = new ToolItem(toolBar, SWT.PUSH); - filter.setImage(QuantumPlugin.getImage("filter.gif")); //$NON-NLS-1$ + filter.setImage(ImageStore.getImage(ImageStore.FILTER)); filter.setToolTipText(Messages.getString("tableview.filterSort")); //$NON-NLS-1$ toolItem = new ToolItem(toolBar, SWT.SEPARATOR); @@ -109,7 +85,7 @@ public class TableViewToolBar { previous = new ToolItem(toolBar, SWT.PUSH); next = new ToolItem(toolBar, SWT.PUSH); - fullMode.setImage(QuantumPlugin.getImage("fulldata.gif")); //$NON-NLS-1$ + fullMode.setImage(ImageStore.getImage(ImageStore.FULLDATA)); fullMode.setToolTipText(Messages.getString("tableview.showAll")); //$NON-NLS-1$ fullMode.setSelection(false); fullMode.addSelectionListener(new SelectionListener() { @@ -136,7 +112,7 @@ public class TableViewToolBar { } } }); - previous.setImage(QuantumPlugin.getImage("previous.gif")); //$NON-NLS-1$ + previous.setImage(ImageStore.getImage(ImageStore.PREVIOUS)); previous.setToolTipText("Previous"); //$NON-NLS-1$ previous.addSelectionListener(new SelectionListener() { public void widgetDefaultSelected(SelectionEvent e) { @@ -158,7 +134,7 @@ public class TableViewToolBar { } } }); - next.setImage(QuantumPlugin.getImage("next.gif")); //$NON-NLS-1$ + next.setImage(ImageStore.getImage(ImageStore.NEXT)); next.setToolTipText("Next"); //$NON-NLS-1$ next.addSelectionListener(new SelectionListener() { public void widgetDefaultSelected(SelectionEvent e) { @@ -181,19 +157,6 @@ public class TableViewToolBar { } }); - toolItem = new ToolItem(toolBar, SWT.SEPARATOR); - - toolItem = new ToolItem(toolBar, SWT.PUSH); - toolItem.setImage(QuantumPlugin.getImage("close.gif")); //$NON-NLS-1$ - toolItem.setToolTipText(Messages.getString("tableview.close")); //$NON-NLS-1$ - toolItem.addSelectionListener(new SelectionListener() { - public void widgetDefaultSelected(SelectionEvent e) { - } - public void widgetSelected(SelectionEvent e) { - closeTableAction.run(); - } - }); - } public void setColumns( final TableView view, final TableAdapter ta, Table table) { diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/wizards/AddDriverWizard.java b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/wizards/AddDriverWizard.java index 93dd10b..e3cb426 100644 --- a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/wizards/AddDriverWizard.java +++ b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/wizards/AddDriverWizard.java @@ -1,5 +1,6 @@ package com.quantum.wizards; +import com.quantum.ImageStore; import com.quantum.Messages; import com.quantum.QuantumPlugin; import com.quantum.adapters.AdapterFactory; @@ -126,7 +127,7 @@ public class AddDriverWizard extends Wizard { public void widgetSelected(SelectionEvent event) { SimpleSelectionDialog dialog = new SimpleSelectionDialog( getShell(), "Select a Driver", JarUtil.getAllDriverNames( - getDriverFile()), QuantumPlugin.getImage("class.gif")); + getDriverFile()), ImageStore.getImage(ImageStore.CLASS)); if (dialog.open() == SimpleSelectionDialog.OK) { IStructuredSelection selection = dialog.getSelection(); if (!selection.isEmpty()) { 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 755f9be..a7a84fe 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 @@ -8,6 +8,7 @@ import com.quantum.model.Column; import com.quantum.model.ConnectionException; import com.quantum.model.Entity; import com.quantum.model.NotConnectedException; +import com.quantum.sql.SQLResults; import com.quantum.sql.TableRow; import com.quantum.view.ViewHelper; import com.quantum.view.tableview.TableAdapter; @@ -15,7 +16,8 @@ import com.quantum.view.tableview.TableAdapter; import org.eclipse.jface.wizard.WizardPage; /** - * @author BC + * @author BC Holmes + * @author Sirkware */ public abstract class BaseSQLPage extends WizardPage implements SQLPage { @@ -26,15 +28,18 @@ public abstract class BaseSQLPage extends WizardPage implements SQLPage { super(pageName); } public boolean performFinish() { - try { - Bookmark bookmark = this.adapter.getBookmark(); - bookmark.addQuery(getQueryText()); - ViewHelper.tryGetResults(getShell(), bookmark.getConnection(), getQueryText()); - } catch (ConnectionException e) { - e.printStackTrace(); - } - return true; - } + try { + Bookmark bookmark = this.adapter.getBookmark(); + bookmark.addQuery(getQueryText()); + SQLResults sqlResults = ViewHelper.tryGetResults(getShell(), + bookmark.getConnection(), getQueryText()); + return sqlResults.isError() ? false : true; + } catch (ConnectionException e) { + e.printStackTrace(); + return false; + } + } + protected abstract String getQueryText(); protected void appendColumn(StringBuffer whereClause, Entity entity, String columnName, DatabaseAdapter adapter, String value) { 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 3feed8f..e8be91d 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 @@ -6,8 +6,8 @@ import java.io.IOException; import javax.xml.parsers.ParserConfigurationException; +import com.quantum.ImageStore; import com.quantum.Messages; -import com.quantum.QuantumPlugin; import com.quantum.model.Bookmark; import com.quantum.model.BookmarkCollection; import com.quantum.model.xml.ModelToXMLConverter; @@ -78,7 +78,7 @@ public class ExportBookmarkWizardPage extends WizardPage { public Image getImage(Object element) { if (element instanceof Bookmark) { - return QuantumPlugin.getImage("bookmarks.gif"); + return ImageStore.getImage(ImageStore.BOOKMARK); } else { return null; }