added file extension php5
[phpeclipse.git] / archive / net.sourceforge.phpeclipse.quantum.sql / src / com / quantum / view / SQLQueryView.java
index a8469e7..0b14583 100644 (file)
 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.Label;
-import org.eclipse.swt.widgets.ProgressBar;
-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.view.bookmark.BookmarkNode;
-import com.quantum.view.bookmark.BookmarkView;
-
 public class SQLQueryView extends ViewPart {
+       private class ClearAction extends Action {
+               
+               public ClearAction() {
+                       setImageDescriptor(ImageStore.getImageDescriptor(ImageStore.CLEAR));
+                       setToolTipText(Messages.getString("sqlqueryview.clear"));
+               }
+
+               public void run() {
+                       setQuery("");
+               }
+       }
+
+       private class AutoCommitPreferenceAction extends Action {
+               
+               public AutoCommitPreferenceAction() {
+                       super(Messages.getString("SQLQueryView.AutoCommit"));
+                       setToolTipText(Messages.getString("SQLQueryView.AutoCommit"));
+                       setImageDescriptor(ImageStore.getImageDescriptor(ImageStore.AUTOCOMMIT));
+               }
+               
+               public void run() {
+                       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 Label statusImage;
-       private Label status;
-       private ProgressBar progress;
        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 long parseTime = 0;
-       private long fullTime = 0;
+       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";
-               BookmarkNode bookmarkNode = null;
-               Bookmark bookmark = null;
-               Connection con = null;
-               if (BookmarkView.getInstance() != null ) {
-                       bookmarkNode = BookmarkView.getInstance().getCurrentBookmark();
-               }
-               if (bookmarkNode != null)
-                       bookmark = bookmarkNode.getBookmark();
-               if (bookmark != null) {         
-                       title = bookmark.getName() + " (" + title + ")";
-                       setTitle( title );
-                       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();
-
+               };
+               QuantumPlugin.getDefault().getPreferenceStore().addPropertyChangeListener(listener);
        }
        public static SQLQueryView getInstance() {
                return (SQLQueryView) QuantumPlugin.getDefault().getView("com.quantum.view.sqlqueryview");
@@ -95,130 +184,19 @@ 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);
-               ToolItem item = new ToolItem(toolbar, SWT.PUSH);
-               item.setImage(QuantumPlugin.getImage("play.gif")); //$NON-NLS-1$
-               item.setToolTipText(Messages.getString("sqlqueryview.executeQuery")); //$NON-NLS-1$
-               item.addSelectionListener(new SelectionListener() {
-                       public void widgetDefaultSelected(SelectionEvent e) {
-                       }
-                       public void widgetSelected(SelectionEvent e) {
-                               executeAction.run();
-                       }
-               });
-               item = new ToolItem(toolbar, SWT.SEPARATOR);
-               item = new ToolItem(toolbar, SWT.PUSH);
-               item.setImage(QuantumPlugin.getImage("import.gif")); //$NON-NLS-1$
-               item.setToolTipText(Messages.getString("sqlqueryview.importQuery")); //$NON-NLS-1$
-               item.addSelectionListener(new SelectionListener() {
-                       public void widgetDefaultSelected(SelectionEvent e) {
-                       }
-                       public void widgetSelected(SelectionEvent e) {
-                               importQueryAction.run();
-                       }
-               });
-               item = new ToolItem(toolbar, SWT.PUSH);
-               item.setImage(QuantumPlugin.getImage("export.gif")); //$NON-NLS-1$
-               item.setToolTipText(Messages.getString("sqlqueryview.exportQuery")); //$NON-NLS-1$
-               item.addSelectionListener(new SelectionListener() {
-                       public void widgetDefaultSelected(SelectionEvent e) {
-                       }
-                       public void widgetSelected(SelectionEvent e) {
-                               exportQueryAction.run();
-                       }
-               });
-               item = new ToolItem(toolbar, SWT.PUSH);
-               item.setImage(QuantumPlugin.getImage("clear.gif")); //$NON-NLS-1$
-               item.setToolTipText(Messages.getString("sqlqueryview.clear")); //$NON-NLS-1$
-               item.addSelectionListener(new SelectionListener() {
-                       public void widgetDefaultSelected(SelectionEvent e) {
-                       }
-                       public void widgetSelected(SelectionEvent e) {
-                               setQuery(""); //$NON-NLS-1$
-                       }
-               });
-
-               item = new ToolItem(toolbar, SWT.SEPARATOR);
-
-               commitItem = new ToolItem(toolbar, SWT.PUSH);
-               commitItem.setImage(QuantumPlugin.getImage("commit.gif")); //$NON-NLS-1$
-               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();
-                }
-                       }
-               });
+               widget = new StyledText(parent, SWT.H_SCROLL | SWT.V_SCROLL);
                
-               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);
-                               
-                       }
-               });
-               BookmarkNode node = BookmarkView.getInstance().getCurrentBookmark();
-               if (node == null) autoCommitItem.setSelection(true); 
-               else autoCommitItem.setSelection(node.getBookmark().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);
@@ -229,103 +207,62 @@ 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);
-
-               Composite bottomStatus = new Composite(main, SWT.NONE);
-               gridData = new GridData();
-               gridData.horizontalAlignment = GridData.FILL;
-               gridData.grabExcessHorizontalSpace = true;
-               bottomStatus.setLayoutData(gridData);
-               
-               GridLayout horizontal = new GridLayout(3, false);
-               layout.horizontalSpacing = 0;
-               layout.verticalSpacing = 0;
-               layout.marginHeight = 0;
-               layout.marginWidth = 0;
-               bottomStatus.setLayout(horizontal);
+               widget.setLayoutData(new GridData(GridData.FILL_BOTH));
 
-               statusImage = new Label(bottomStatus, SWT.NONE);
-               status = new Label(bottomStatus, SWT.NONE);
-               gridData = new GridData();
-               gridData.horizontalAlignment = GridData.FILL;
-               gridData.grabExcessHorizontalSpace = true;
-               status.setLayoutData(gridData);
-
-               progress = new ProgressBar(bottomStatus, SWT.HORIZONTAL);
-
-               status.setText(Messages.getString("sqlqueryview.done")); //$NON-NLS-1$
-               statusImage.setImage(QuantumPlugin.getImage("success.gif")); //$NON-NLS-1$
-               progress.setMinimum(0);
-        
-        IKeyBindingService keyBindingService = getSite().getKeyBindingService();
-        // TODO: check the version numbers for this method
-        keyBindingService.setScopes(new String[] {
-            "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 con) {
-               boolean autoCommit = true;
-               // Calculate the state of the autoCommit option
-               if (con != null)
-               {
-                       // If we have a connection, the autoCommit state is that of the connection
-                       try {
-                               autoCommit = con.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);
-               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));
                }
        }
-       public void setProgress(int increment, int max) {
-               progress.setMaximum(max);
-               progress.setSelection(increment);
+       /**
+        * @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);
-               importQueryAction = new ImportQueryAction();
-               importQueryAction.init(this);
-               exportQueryAction = new ExportQueryAction();
-               exportQueryAction.init(this);
-       }
 
-       public void setStatus(String text) {
-               statusImage.setImage(null);
-               status.setText(text);
-       }
+               IToolBarManager toolBar = getViewSite().getActionBars().getToolBarManager();
+
+               executeAction = new ExecuteAction(this);
+               toolBar.add(this.executeAction);
+               toolBar.add(new ClearAction());
+               
+        IActionBars actionBars = getViewSite().getActionBars();
+               this.importQueryAction = new ImportQueryAction();
+               this.importQueryAction.init(this);
+        actionBars.getMenuManager().add(this.importQueryAction);
+        this.exportQueryAction = new ExportQueryAction();
+        this.exportQueryAction.init(this);
+        actionBars.getMenuManager().add(this.exportQueryAction);
+        actionBars.getMenuManager().add(new Separator());
+        this.autoCommitPreferenceAction = new AutoCommitPreferenceAction();
+        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 void setStatus(Image img, String text) {
-               statusImage.setImage(img);
-               status.setText(text);
-       }
-       
        public String getQuery() {
                return widget.getText();
        }
@@ -334,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 {
@@ -404,9 +315,7 @@ public class SQLQueryView extends ViewPart {
                                        //int dirtyStart = request.start;
                                        //int dirtyEnd = request.start + request.length;
                                        StyleRange styleRange;
-                                       long startTime = System.currentTimeMillis();
                                        Vector tokens = SQLLexx.parse(text);
-                                       long subTime = System.currentTimeMillis();
                                        Vector styles = new Vector();
                                        int min = Integer.MAX_VALUE;
                                        int max = 0;
@@ -429,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;
                                                                        }
                                                                }
@@ -462,9 +371,6 @@ public class SQLQueryView extends ViewPart {
                                        if (max >= 0 && ranges.length > 0) {
                                                setStyles(ranges, min, max - min);
                                        }
-                                       long endTime = System.currentTimeMillis();
-                                       parseTime = subTime - startTime;
-                                       fullTime = endTime - startTime;
                                } catch (NoSuchElementException e) {
                                        // ignore a missing request
                                } catch (InterruptedException e) {
@@ -514,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;
+       }
 }