aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDean Roberts2011-12-02 09:48:37 (EST)
committerPaul Webster2011-12-02 09:48:37 (EST)
commitc1f054ce49ad7f9eadc6ab1c63841f538b18d43d (patch)
tree01d6cf56ec7a9690598e60b11d5cbeb22cbdc346
parentfd7f397dcfa200fcbd43232a47b33f06fc650402 (diff)
downloadeclipse.platform.ui-c1f054ce49ad7f9eadc6ab1c63841f538b18d43d.zip
eclipse.platform.ui-c1f054ce49ad7f9eadc6ab1c63841f538b18d43d.tar.gz
eclipse.platform.ui-c1f054ce49ad7f9eadc6ab1c63841f538b18d43d.tar.bz2
Bug 320673 - QuickAccess should restore previous focus when
hitting Escape
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/quickaccess/QuickAccessHandler.java7
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/quickaccess/SearchField.java9
2 files changed, 10 insertions, 6 deletions
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/quickaccess/QuickAccessHandler.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/quickaccess/QuickAccessHandler.java
index 5907e64..f38faab 100644
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/quickaccess/QuickAccessHandler.java
+++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/quickaccess/QuickAccessHandler.java
@@ -51,14 +51,11 @@ public class QuickAccessHandler extends AbstractHandler {
control = (Control) searchField.getWidget();
}
if (control != null) {
+ Control previousFocusControl = control.getDisplay().getFocusControl();
control.setFocus();
SearchField field = (SearchField) searchField.getObject();
- field.activate();
+ field.activate(previousFocusControl);
}
-
-// final PopupDialog popupDialog = new QuickAccessDialog(window,
- // executionEvent.getCommand());
- // popupDialog.open();
return null;
}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/quickaccess/SearchField.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/quickaccess/SearchField.java
index 16e0fe9..1fce686 100644
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/quickaccess/SearchField.java
+++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/quickaccess/SearchField.java
@@ -45,6 +45,7 @@ import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Monitor;
import org.eclipse.swt.widgets.Shell;
@@ -84,6 +85,7 @@ public class SearchField {
private LinkedList<QuickAccessElement> previousPicksList = new LinkedList<QuickAccessElement>();
private int dialogHeight = -1;
private int dialogWidth = -1;
+ private Control previousFocusControl;
@PostConstruct
void createWidget(final Composite parent, MApplication application, MWindow window) {
@@ -153,6 +155,8 @@ public class SearchField {
if (commandProvider.getContextSnapshot() == null) {
commandProvider.setSnapshot(hs.createContextSnapshot(true));
}
+
+ previousFocusControl = (Control) e.getSource();
}
});
shell.addFocusListener(new FocusListener() {
@@ -178,6 +182,8 @@ public class SearchField {
public void keyPressed(KeyEvent e) {
if (e.keyCode == SWT.ESC) {
text.setText(""); //$NON-NLS-1$
+ if (previousFocusControl != null && !previousFocusControl.isDisposed())
+ previousFocusControl.setFocus();
}
}
});
@@ -296,7 +302,8 @@ public class SearchField {
shell.layout();
}
- public void activate() {
+ public void activate(Control previousFocusControl) {
+ this.previousFocusControl = previousFocusControl;
if (!shell.isVisible()) {
layoutShell();
shell.setVisible(true);