summaryrefslogtreecommitdiffstatsabout
diff options
context:
space:
mode:
authorDaniel Rolka2013-08-19 11:04:47 (EDT)
committer Gerrit Code Review @ Eclipse.org2013-08-20 09:45:43 (EDT)
commit9a67c52d627b4257b6e30cf64ee1950d11b87693 (patch)
tree97fdc2ca8ebe9d3e45d7ee3aae37fc03384d8238
parent390d1b17f4c1b4b65391eae620ebc0069591502d (diff)
downloadeclipse.platform.ui-9a67c52d627b4257b6e30cf64ee1950d11b87693.zip
eclipse.platform.ui-9a67c52d627b4257b6e30cf64ee1950d11b87693.tar.gz
eclipse.platform.ui-9a67c52d627b4257b6e30cf64ee1950d11b87693.tar.bz2
Bug 413167 - Make Quick Access smallerrefs/changes/41/14641/5
Change-Id: I04d5e53e7e52e92dc423430658324bbe79edf7a9 Signed-off-by: Daniel Rolka <daniel.rolka@pl.ibm.com>
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/quickaccess/SearchField.java20
1 files changed, 17 insertions, 3 deletions
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 a345246..226b82d 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
@@ -47,6 +47,8 @@ import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.ShellAdapter;
import org.eclipse.swt.events.ShellEvent;
+import org.eclipse.swt.graphics.FontMetrics;
+import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.layout.GridLayout;
@@ -106,9 +108,7 @@ public class SearchField {
// borderColor = new Color(parent.getDisplay(), 170, 176, 191);
final Composite comp = new Composite(parent, SWT.NONE);
comp.setLayout(new GridLayout());
- text = new Text(comp, SWT.SEARCH | SWT.ICON_SEARCH);
- GridDataFactory.fillDefaults().hint(130, SWT.DEFAULT).applyTo(text);
- text.setMessage(QuickAccessMessages.QuickAccess_EnterSearch);
+ text = createText(comp);
parent.getShell().addControlListener(new ControlListener() {
public void controlResized(ControlEvent e) {
@@ -256,6 +256,20 @@ public class SearchField {
quickAccessContents.createInfoLabel(shell);
}
+ private Text createText(Composite parent) {
+ Text text = new Text(parent, SWT.SEARCH | SWT.ICON_SEARCH);
+ text.setMessage(QuickAccessMessages.QuickAccess_EnterSearch);
+
+ GC gc = new GC(text);
+ FontMetrics fm = gc.getFontMetrics();
+ int width = text.computeSize(fm.getAverageCharWidth() * text.getMessage().length(),
+ SWT.DEFAULT).x + 15 /* some extra space */;
+ gc.dispose();
+
+ GridDataFactory.fillDefaults().hint(width, SWT.DEFAULT).applyTo(text);
+ return text;
+ }
+
private void hookUpSelectAll() {
final IEclipseContext windowContext = window.getContext();
IFocusService focus = windowContext.get(IFocusService.class);