remove name clash with JDT editor category
[phpeclipse.git] / archive / net.sourceforge.phpeclipse.quantum.sql / src / com / quantum / view / SQLQueryView.java
index fd3348e..a438d7f 100644 (file)
@@ -5,26 +5,6 @@ import java.util.ArrayList;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.NoSuchElementException;
-import java.util.Vector;
-
-import com.quantum.ImageStore;
-import com.quantum.Messages;
-import com.quantum.PluginPreferences;
-import com.quantum.QuantumPlugin;
-import com.quantum.actions.ExecuteAction;
-import com.quantum.actions.ExportQueryAction;
-import com.quantum.actions.ImportQueryAction;
-import com.quantum.editors.ColorManager;
-import com.quantum.model.Bookmark;
-import com.quantum.model.BookmarkCollection;
-import com.quantum.model.NotConnectedException;
-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.ui.dialog.SQLExceptionDialog;
-import com.quantum.util.versioning.VersioningHelper;
 
 import org.eclipse.jface.action.Action;
 import org.eclipse.jface.action.IToolBarManager;
@@ -42,8 +22,6 @@ import org.eclipse.swt.custom.ExtendedModifyEvent;
 import org.eclipse.swt.custom.ExtendedModifyListener;
 import org.eclipse.swt.custom.StyleRange;
 import org.eclipse.swt.custom.StyledText;
-import org.eclipse.swt.dnd.Clipboard;
-import org.eclipse.swt.dnd.TransferData;
 import org.eclipse.swt.graphics.Color;
 import org.eclipse.swt.graphics.Font;
 import org.eclipse.swt.graphics.FontData;
@@ -56,6 +34,25 @@ import org.eclipse.ui.IActionBars;
 import org.eclipse.ui.IWorkbenchActionConstants;
 import org.eclipse.ui.part.ViewPart;
 
+import com.quantum.ImageStore;
+import com.quantum.Messages;
+import com.quantum.PluginPreferences;
+import com.quantum.QuantumPlugin;
+import com.quantum.actions.ExecuteAction;
+import com.quantum.actions.ExportQueryAction;
+import com.quantum.actions.ImportQueryAction;
+import com.quantum.editors.ColorManager;
+import com.quantum.model.Bookmark;
+import com.quantum.model.BookmarkCollection;
+import com.quantum.model.NotConnectedException;
+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.ui.dialog.SQLExceptionDialog;
+import com.quantum.util.versioning.VersioningHelper;
+
 public class SQLQueryView extends ViewPart {
        private class ClearAction extends Action {
                
@@ -230,9 +227,6 @@ public class SQLQueryView extends ViewPart {
                        this.executeAction);
        }
 
-       /**
-        * @param widget2
-        */
        private void setFont() {
                FontData font = PreferenceConverter.getFontData(
                                QuantumPlugin.getDefault().getPreferenceStore(), 
@@ -279,8 +273,21 @@ public class SQLQueryView extends ViewPart {
         actionBars.getMenuManager().add(this.commitAction);
 }
 
+       /**
+        * Returns the query to be executed. The query is either 1) the 
+        * text currently highlighted/selected in the editor or 2) all of 
+     * the text in the editor. 
+        * @return query string to be executed
+        */
        public String getQuery() {
-               return widget.getText();
+           String query; 
+           
+           if (widget.getSelectionText().length() > 0)
+               query = widget.getSelectionText();
+           else    
+               query = widget.getText();
+           
+               return query;
        }
        
        public void setQuery(String text) {