Author: max.andersen(a)jboss.com
Date: 2007-10-26 10:24:17 -0400 (Fri, 26 Oct 2007)
New Revision: 4542
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/hqleditor/HQLEditor.java
Log:
JBIDE-736 Query editors lost focus after execution
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/hqleditor/HQLEditor.java
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/hqleditor/HQLEditor.java 2007-10-26
14:23:14 UTC (rev 4541)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/hqleditor/HQLEditor.java 2007-10-26
14:24:17 UTC (rev 4542)
@@ -34,6 +34,11 @@
import org.eclipse.jface.text.source.IVerticalRuler;
import org.eclipse.jface.text.source.projection.ProjectionSupport;
import org.eclipse.jface.text.source.projection.ProjectionViewer;
+import org.eclipse.swt.custom.StyledText;
+import org.eclipse.swt.events.KeyAdapter;
+import org.eclipse.swt.events.KeyEvent;
+import org.eclipse.swt.events.MouseAdapter;
+import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
@@ -145,6 +150,23 @@
/* Set a help context ID to enable F1 help. */
getSite().getWorkbenchWindow().getWorkbench().getHelpSystem().setHelp( parent,
HELP_CONTEXT_ID );
+ // the following is needed to make sure the editor area gets focus when editing
after query execution
+ // TODO: find a better way since this is triggered on evey mouse click and key
stroke in the editor area
+ StyledText textWidget = getSourceViewer().getTextWidget();
+ textWidget.addKeyListener(new KeyAdapter() {
+
+ public void keyPressed(KeyEvent e) {
+ getSite().getPage().activate(HQLEditor.this);
+ }
+
+ });
+ textWidget.addMouseListener(new MouseAdapter() {
+
+ public void mouseDown(MouseEvent e) {
+ getSite().getPage().activate(HQLEditor.this);
+ }
+
+ });
}
/**
Show replies by date