summaryrefslogtreecommitdiffstatsabout
diff options
context:
space:
mode:
authorCurtis Windatt2012-04-05 16:55:07 (EDT)
committer Paul Webster2012-04-10 10:06:20 (EDT)
commit6dc76888d658c49d74d3379448b4259625d075f8 (patch)
tree80641b99fc1fdf0cda8b78809ab584f1b4f104e8
parent21fd001ce9dd1ea4da8adf6810526ba45624c172 (diff)
downloadeclipse.platform.ui-6dc76888d658c49d74d3379448b4259625d075f8.zip
eclipse.platform.ui-6dc76888d658c49d74d3379448b4259625d075f8.tar.gz
eclipse.platform.ui-6dc76888d658c49d74d3379448b4259625d075f8.tar.bz2
Bug 374058 - Quick Access drop-down list is overly wide
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/quickaccess/QuickAccessContents.java5
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/quickaccess/QuickAccessDialog.java5
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/quickaccess/SearchField.java66
3 files changed, 50 insertions, 26 deletions
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/quickaccess/QuickAccessContents.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/quickaccess/QuickAccessContents.java
index b7873b4..291b19c 100644
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/quickaccess/QuickAccessContents.java
+++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/quickaccess/QuickAccessContents.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2011 IBM Corporation and others.
+ * Copyright (c) 2005, 2012 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -327,7 +327,8 @@ public abstract class QuickAccessContents {
}
/**
- *
+ * Attempts to close the quick access dialog/shell. Must be called from a UI
+ * thread. Default implementation does nothing.
*/
abstract void doClose();
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/quickaccess/QuickAccessDialog.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/quickaccess/QuickAccessDialog.java
index 66eb711..796b3c2 100644
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/quickaccess/QuickAccessDialog.java
+++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/quickaccess/QuickAccessDialog.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2009 IBM Corporation and others.
+ * Copyright (c) 2005, 2012 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -48,6 +48,9 @@ import org.eclipse.ui.internal.progress.ProgressManagerUtil;
import org.eclipse.ui.keys.IBindingService;
/**
+ * This is the quick access popup dialog used in 3.x. The new quick access is
+ * done through a shell in {@link SearchField}.
+ *
* @since 3.3
*
*/
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 c30d4a8..0deabec 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
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010, 2011 IBM Corporation and others.
+ * Copyright (c) 2010, 2012 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -35,6 +35,7 @@ import org.eclipse.jface.window.Window;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ControlEvent;
import org.eclipse.swt.events.ControlListener;
+import org.eclipse.swt.events.FocusAdapter;
import org.eclipse.swt.events.FocusEvent;
import org.eclipse.swt.events.FocusListener;
import org.eclipse.swt.events.KeyAdapter;
@@ -137,6 +138,7 @@ public class SearchField {
void doClose() {
dialogHeight = shell.getSize().y;
dialogWidth = shell.getSize().x;
+ shell.setVisible(false);
}
QuickAccessElement getPerfectMatch(String filter) {
@@ -167,7 +169,12 @@ public class SearchField {
final Table table = quickAccessContents.createTable(shell, Window.getDefaultOrientation());
text.addFocusListener(new FocusListener() {
public void focusLost(FocusEvent e) {
- checkFocusLost(table, text);
+ // Once the focus event is complete, check if we should close the shell
+ table.getDisplay().asyncExec(new Runnable() {
+ public void run() {
+ checkFocusLost(table, text);
+ }
+ });
}
public void focusGained(FocusEvent e) {
@@ -179,13 +186,17 @@ public class SearchField {
previousFocusControl = (Control) e.getSource();
}
+
});
- shell.addFocusListener(new FocusListener() {
+ table.addFocusListener(new FocusAdapter() {
public void focusLost(FocusEvent e) {
- checkFocusLost(table, text);
- }
-
- public void focusGained(FocusEvent e) {
+ // Once the focus event is complete, check if we should close
+ // the shell
+ table.getDisplay().asyncExec(new Runnable() {
+ public void run() {
+ checkFocusLost(table, text);
+ }
+ });
}
});
text.addModifyListener(new ModifyListener() {
@@ -332,7 +343,14 @@ public class SearchField {
int preferredWidth = dialogWidth == -1 ? 350 : dialogWidth;
int width = Math.max(preferredWidth, compBounds.width);
int height = dialogHeight == -1 ? 250 : dialogHeight;
-
+
+ // If size would extend past the right edge of the shell, try to move it
+ // to the left of the text
+ Rectangle shellBounds = text.getShell().getBounds();
+ if (compBounds.x + width > shellBounds.x + shellBounds.width){
+ compBounds.x = Math.max(shellBounds.x, (compBounds.x + compBounds.width - width));
+ }
+
shell.setBounds(getConstrainedShellBounds(display, new Rectangle(compBounds.x, compBounds.y
+ compBounds.height, width, height)));
shell.layout();
@@ -348,26 +366,28 @@ public class SearchField {
}
/**
+ * Checks if the text or shell has focus. If not, closes the shell.
+ *
* @param table
+ * the shell's table
* @param text
+ * the search text field
*/
protected void checkFocusLost(final Table table, final Text text) {
- table.getDisplay().asyncExec(new Runnable() {
- public void run() {
- if (!shell.isDisposed() && !table.isDisposed() && !text.isDisposed()) {
- if (table.getDisplay().getActiveShell() == table.getShell()) {
- text.setFocus();
- return;
- }
- if (!shell.isFocusControl() && !table.isFocusControl()
- && !text.isFocusControl()) {
- quickAccessContents.doClose();
- text.setText(""); //$NON-NLS-1$
- quickAccessContents.resetProviders();
- }
- }
+ if (!shell.isDisposed() && !table.isDisposed() && !text.isDisposed()) {
+ if (table.getDisplay().getActiveShell() == table.getShell()) {
+ // If the user selects the trim shell, leave focus on the text
+ // so shell stays open
+ text.setFocus();
+ return;
}
- });
+ if (!shell.isFocusControl() && !table.isFocusControl()
+ && !text.isFocusControl()) {
+ quickAccessContents.doClose();
+ text.setText(""); //$NON-NLS-1$
+ quickAccessContents.resetProviders();
+ }
+ }
}
private void restoreDialog() {