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;
import org.eclipse.swt.custom.ExtendedModifyListener;
import org.eclipse.swt.custom.StyleRange;
import org.eclipse.swt.custom.StyledText;
-import org.eclipse.swt.dnd.Clipboard;
-import org.eclipse.swt.dnd.TransferData;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.FontData;
import org.eclipse.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 {
this.executeAction);
}
- /**
- * @param widget2
- */
private void setFont() {
FontData font = PreferenceConverter.getFontData(
QuantumPlugin.getDefault().getPreferenceStore(),
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) {