summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteffen Pingel2012-03-08 04:42:46 (EST)
committerSteffen Pingel2012-03-08 04:42:46 (EST)
commit83f9f56294f1d4949cdb293cc89bec21e64fecaa (patch)
tree06911340427cade82bfbbc1f21d229135d5d43d4
parent1421da850c58f744dcc1d5dfd838ea4a2ec999c7 (diff)
downloadorg.eclipse.mylyn.tasks-83f9f56294f1d4949cdb293cc89bec21e64fecaa.zip
org.eclipse.mylyn.tasks-83f9f56294f1d4949cdb293cc89bec21e64fecaa.tar.gz
org.eclipse.mylyn.tasks-83f9f56294f1d4949cdb293cc89bec21e64fecaa.tar.bz2
NEW - bug 373279: task list find box loses focus after using content
assist https://bugs.eclipse.org/bugs/show_bug.cgi?id=373279 Change-Id: Ia2358d94770d77d5f8515787f7b9747b12ca7903
-rw-r--r--org.eclipse.mylyn.tasks.index.ui/src/org/eclipse/mylyn/internal/tasks/index/ui/IndexSearchHandler.java25
1 files changed, 23 insertions, 2 deletions
diff --git a/org.eclipse.mylyn.tasks.index.ui/src/org/eclipse/mylyn/internal/tasks/index/ui/IndexSearchHandler.java b/org.eclipse.mylyn.tasks.index.ui/src/org/eclipse/mylyn/internal/tasks/index/ui/IndexSearchHandler.java
index 44505c5..01ef81b 100644
--- a/org.eclipse.mylyn.tasks.index.ui/src/org/eclipse/mylyn/internal/tasks/index/ui/IndexSearchHandler.java
+++ b/org.eclipse.mylyn.tasks.index.ui/src/org/eclipse/mylyn/internal/tasks/index/ui/IndexSearchHandler.java
@@ -38,7 +38,10 @@ import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Text;
+import org.eclipse.swt.widgets.TypedListener;
import org.eclipse.ui.dialogs.PatternFilter;
import org.eclipse.ui.fieldassist.ContentAssistCommandAdapter;
@@ -227,8 +230,8 @@ public class IndexSearchHandler extends AbstractSearchHandler {
@Override
public void adaptTextSearchControl(Text textControl) {
IContentProposalProvider proposalProvider = new ContentProposalProvider();
- ContentAssistCommandAdapter adapter = new ContentAssistCommandAdapter(textControl, new TextContentAdapter(),
- proposalProvider, null, new char[0]);
+ final ContentAssistCommandAdapter adapter = new ContentAssistCommandAdapter(textControl,
+ new TextContentAdapter(), proposalProvider, null, new char[0]);
adapter.setProposalAcceptanceStyle(ContentProposalAdapter.PROPOSAL_REPLACE);
// if we decorate the control it lets the user know that they can use content assist...
@@ -238,6 +241,24 @@ public class IndexSearchHandler extends AbstractSearchHandler {
// FieldDecoration contentProposalImage = FieldDecorationRegistry.getDefault().getFieldDecoration(
// FieldDecorationRegistry.DEC_CONTENT_PROPOSAL);
// controlDecoration.setImage(contentProposalImage.getImage());
+
+ // FilteredTree registers a traverse listener that focuses the tree when ENTER is pressed. This
+ // causes focus to be lost when a content proposal is selected. To avoid transfer of focus the
+ // traverse listener registered by FilteredTree is skipped while content assist is being used.
+ Listener[] traverseListeners = textControl.getListeners(SWT.Traverse);
+ for (final Listener listener : traverseListeners) {
+ if (listener.getClass() == TypedListener.class) {
+ // replace listener with delegate that filters events
+ textControl.removeListener(SWT.Traverse, listener);
+ textControl.addListener(SWT.Traverse, new Listener() {
+ public void handleEvent(Event event) {
+ if (!adapter.isProposalPopupOpen()) {
+ listener.handleEvent(event);
+ }
+ }
+ });
+ }
+ }
}
@Override