Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/quickaccess/SearchField.java')
-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 a345246b3fd..226b82dd389 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);

Back to the top