List of usage examples for org.eclipse.jface.fieldassist AutoCompleteField AutoCompleteField
public AutoCompleteField(Control control, IControlContentAdapter controlContentAdapter, String... proposals)
From source file:org.ebayopensource.turmeric.eclipse.ui.SOABasePage.java
License:Open Source License
/** * Creates the combo.//from w w w. ja v a2 s .c o m * * @param composite the composite * @param labelText the label text * @param editable the editable * @param items the items * @param tooltip the tooltip * @return the combo */ public Combo createCombo(final Composite composite, final String labelText, final boolean editable, final String[] items, final String tooltip) { final Label label = new Label(composite, SWT.LEFT); label.setText(labelText); final int defaultStyle = SWT.BORDER | SWT.DROP_DOWN; final int style = editable ? defaultStyle : SWT.READ_ONLY | defaultStyle; final Combo combo = new Combo(composite, style); if (editable == false) { // we still want it look like modifiable although it is ready only. combo.setBackground(UIUtil.display().getSystemColor(SWT.COLOR_LIST_BACKGROUND)); } else { combo.setTextLimit(100); } combo.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 3, 1)); if (items != null && items.length > 0) { combo.setItems(items); combo.select(0); if (editable == true) new AutoCompleteField(combo, new ComboContentAdapter(), items); } UIUtil.decorateControl(this, combo, tooltip); return combo; }
From source file:org.eclipse.emf.ecp.ecoreeditor.ecore.controls.DataTypeControl.java
License:Open Source License
@Override protected Viewer createJFaceViewer(Composite parent, Setting setting) { final ComboViewer combo = new ComboViewer(parent, SWT.DROP_DOWN); Class<?> type = EClassifier.class; boolean includeEcorePackage = false; if (getViewModelContext().getDomainModel() instanceof EAttribute) { type = EDataType.class; includeEcorePackage = true;/*ww w . j av a 2 s .com*/ } else if (getViewModelContext().getDomainModel() instanceof EReference) { type = EClass.class; includeEcorePackage = false; } final List<?> classifiers = ResourceSetHelpers .findAllOfTypeInResourceSet(getViewModelContext().getDomainModel(), type, includeEcorePackage); combo.setLabelProvider(new LabelProvider() { @Override public String getText(Object element) { if (element instanceof EClassifier) { return ((EClassifier) element).getName(); } return super.getText(element); } }); combo.setContentProvider(new ArrayContentProvider()); combo.setInput(classifiers.toArray()); new AutoCompleteField(combo.getCombo(), new ComboContentAdapter(), combo.getCombo().getItems()); return combo; }
From source file:org.eclipse.emfforms.internal.editor.ecore.controls.DataTypeControl.java
License:Open Source License
@Override protected Viewer createJFaceViewer(Composite parent) { final ComboViewer combo = new ComboViewer(parent, SWT.DROP_DOWN); Class<?> type = EClassifier.class; boolean includeEcorePackage = false; if (getViewModelContext().getDomainModel() instanceof EAttribute) { type = EDataType.class; includeEcorePackage = true;//from ww w . j a v a 2 s. co m } else if (getViewModelContext().getDomainModel() instanceof EReference) { type = EClass.class; includeEcorePackage = false; } final List<?> classifiers = ResourceSetHelpers .findAllOfTypeInResourceSet(getViewModelContext().getDomainModel(), type, includeEcorePackage); combo.setLabelProvider(new LabelProvider() { @Override public String getText(Object element) { if (element instanceof EClassifier) { return ((EClassifier) element).getName(); } return super.getText(element); } }); combo.setContentProvider(new ArrayContentProvider()); combo.setInput(classifiers.toArray()); new AutoCompleteField(combo.getCombo(), new ComboContentAdapter(), combo.getCombo().getItems()); return combo; }
From source file:org.eclipse.emfforms.internal.swt.control.text.autocomplete.renderer.AutocompleteTextControlSWTRenderer.java
License:Open Source License
/** * {@inheritDoc}/*from w ww .j a v a2s.c o m*/ * * @see org.eclipse.emf.ecp.view.spi.core.swt.SimpleControlJFaceViewerSWTRenderer#createJFaceViewer(org.eclipse.swt.widgets.Composite) */ @Override protected Viewer createJFaceViewer(Composite parent) throws DatabindingFailedException { final ComboViewer combo = new ComboViewer(parent, SWT.DROP_DOWN); combo.setContentProvider(ArrayContentProvider.getInstance()); combo.setInput(getProposals()); new AutoCompleteField(combo.getCombo(), new ComboContentAdapter(), combo.getCombo().getItems()); return combo; }
From source file:org.eclipse.php.composer.ui.editor.composer.GeneralSection.java
License:Open Source License
private void createTypeEntry(Composite client, FormToolkit toolkit) { typeEntry = new FormEntry(client, toolkit, Messages.GeneralSection_TypeLabel, null, false); typeEntry.setValue(composerPackage.getType(), true); ControlDecoration decoration = new ControlDecoration(typeEntry.getText(), SWT.TOP | SWT.LEFT); FieldDecoration indicator = FieldDecorationRegistry.getDefault() .getFieldDecoration(FieldDecorationRegistry.DEC_CONTENT_PROPOSAL); decoration.setImage(indicator.getImage()); decoration.setDescriptionText(//from www .ja v a 2 s .c o m NLS.bind(Messages.GeneralSection_ContentAssistDecorationText, indicator.getDescription())); decoration.setShowOnlyOnFocus(true); new AutoCompleteField(typeEntry.getText(), new TextContentAdapter(), ComposerConstants.TYPES); typeEntry.addFormEntryListener(new FormEntryAdapter() { public void textValueChanged(FormEntry entry) { composerPackage.set("type", entry.getValue()); //$NON-NLS-1$ } }); composerPackage.addPropertyChangeListener("type", new PropertyChangeListener() { //$NON-NLS-1$ public void propertyChange(PropertyChangeEvent e) { typeEntry.setValue(composerPackage.getType(), true); } }); }
From source file:org.eclipse.php.composer.ui.editor.composer.GeneralSection.java
License:Open Source License
private void createLicenseEntry(Composite client, FormToolkit toolkit) { licenseEntry = new FormEntry(client, toolkit, Messages.GeneralSection_LicenseLabel, null, false); ControlDecoration decoration = new ControlDecoration(licenseEntry.getText(), SWT.TOP | SWT.LEFT); FieldDecoration indicator = FieldDecorationRegistry.getDefault() .getFieldDecoration(FieldDecorationRegistry.DEC_CONTENT_PROPOSAL); decoration.setImage(indicator.getImage()); decoration.setDescriptionText(// w ww.j av a2 s .c om NLS.bind(Messages.GeneralSection_ContentAssistDecorationText, indicator.getDescription())); decoration.setShowOnlyOnFocus(true); new AutoCompleteField(licenseEntry.getText(), new LicenseContentAdapter(), ComposerConstants.LICENSES); final License2StringConverter converter = new License2StringConverter(); licenseEntry.setValue(converter.convert(composerPackage.getLicense()), true); licenseEntry.addFormEntryListener(new FormEntryAdapter() { String2LicenseConverter converter; public void focusGained(FormEntry entry) { converter = new String2LicenseConverter(composerPackage); } public void focusLost(FormEntry entry) { converter.convert(entry.getValue()); } }); composerPackage.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent e) { if (e.getPropertyName().startsWith("license")) { //$NON-NLS-1$ licenseEntry.setValue(converter.convert(composerPackage.getLicense()), true); } } }); }
From source file:org.eclipse.php.composer.ui.wizard.project.BasicSettingsGroup.java
License:Open Source License
public void createControl(Composite composite, Shell shell) { this.shell = shell; nameComposite = new Composite(composite, SWT.NONE); nameComposite.setFont(composite.getFont()); nameComposite.setLayout(new GridLayout(2, false)); nameComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); // text field for project vendor name vendorField = new StringDialogField(); vendorField.setLabelText(Messages.BasicSettingsGroup_VendorNameLabel); vendorField.setDialogFieldListener(this); vendorField.doFillIntoGrid(nameComposite, 2); LayoutUtil.setHorizontalGrabbing(vendorField.getTextControl(null)); // text field for project type typeField = new StringDialogField(); typeField.setLabelText(Messages.BasicSettingsGroup_TypeLabel); typeField.setDialogFieldListener(this); typeField.doFillIntoGrid(nameComposite, 2); LayoutUtil.setHorizontalGrabbing(typeField.getTextControl(null)); ControlDecoration decoration = new ControlDecoration(typeField.getTextControl(), SWT.TOP | SWT.LEFT); FieldDecoration indicator = FieldDecorationRegistry.getDefault() .getFieldDecoration(FieldDecorationRegistry.DEC_CONTENT_PROPOSAL); decoration.setImage(indicator.getImage()); decoration.setDescriptionText(/*ww w. j a v a 2s. c o m*/ NLS.bind(Messages.BasicSettingsGroup_ContentAssistDecorationText, indicator.getDescription())); decoration.setShowOnlyOnFocus(true); new AutoCompleteField(typeField.getTextControl(), new TextContentAdapter(), ComposerConstants.TYPES); // text field for project description descriptionField = new StringDialogField(); descriptionField.setLabelText(Messages.BasicSettingsGroup_DescriptionLabel); descriptionField.setDialogFieldListener(this); descriptionField.doFillIntoGrid(nameComposite, 2); LayoutUtil.setHorizontalGrabbing(descriptionField.getTextControl(null)); // text field for project description keywordField = new StringDialogField(); keywordField.setLabelText(Messages.BasicSettingsGroup_KeywordsLabel); keywordField.setDialogFieldListener(this); keywordField.doFillIntoGrid(nameComposite, 2); LayoutUtil.setHorizontalGrabbing(keywordField.getTextControl(null)); // text field for project description licenseField = new StringDialogField(); licenseField.setLabelText(Messages.BasicSettingsGroup_LicenseLabel); licenseField.setDialogFieldListener(this); licenseField.doFillIntoGrid(nameComposite, 2); LayoutUtil.setHorizontalGrabbing(licenseField.getTextControl(null)); ControlDecoration licenseDecoration = new ControlDecoration(licenseField.getTextControl(), SWT.TOP | SWT.LEFT); licenseDecoration.setImage(indicator.getImage()); licenseDecoration.setDescriptionText( NLS.bind(Messages.BasicSettingsGroup_ContentAssistDecorationText, indicator.getDescription())); licenseDecoration.setShowOnlyOnFocus(true); new AutoCompleteField(licenseField.getTextControl(), new LicenseContentAdapter(), ComposerConstants.LICENSES); }
From source file:org.eclipse.ui.examples.fieldassist.FieldAssistTestDialog.java
License:Open Source License
protected Control createDialogArea(Composite parent) { Composite outer = (Composite) super.createDialogArea(parent); initializeDialogUnits(outer);/*www . j ava 2s . c om*/ createSecurityGroup(outer); // Create a simple field to show how field assist can be used for // autocomplete. Group autoComplete = new Group(outer, SWT.NONE); autoComplete.setLayoutData(new GridData(GridData.FILL_BOTH)); GridLayout layout = new GridLayout(); layout.numColumns = 2; layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN); layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN); layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING); layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING); autoComplete.setLayout(layout); autoComplete.setText(TaskAssistExampleMessages.ExampleDialog_AutoCompleteGroup); Label label = new Label(autoComplete, SWT.LEFT); label.setText(TaskAssistExampleMessages.ExampleDialog_UserName); // Create an auto-complete field representing a user name Text text = new Text(autoComplete, SWT.BORDER); text.setLayoutData(getFieldGridData()); new AutoCompleteField(text, new TextContentAdapter(), validUsers); // Another one to test combos label = new Label(autoComplete, SWT.LEFT); label.setText(TaskAssistExampleMessages.ExampleDialog_ComboUserName); Combo combo = new Combo(autoComplete, SWT.BORDER | SWT.DROP_DOWN); combo.setText(username); combo.setItems(validUsers); combo.setLayoutData(getFieldGridData()); new AutoCompleteField(combo, new ComboContentAdapter(), validUsers); Dialog.applyDialogFont(outer); return outer; }
From source file:org.eclipse.wst.server.ui.internal.editor.OverviewEditorPart.java
License:Open Source License
protected void createGeneralSection(Composite leftColumnComp, FormToolkit toolkit) { Section section = toolkit.createSection(leftColumnComp, ExpandableComposite.TITLE_BAR | Section.DESCRIPTION); section.setText(Messages.serverEditorOverviewGeneralSection); section.setDescription(Messages.serverEditorOverviewGeneralDescription); section.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_FILL)); Composite composite = toolkit.createComposite(section); GridLayout layout = new GridLayout(); layout.numColumns = 3;/* w w w. ja v a2 s.c o m*/ layout.marginHeight = 5; layout.marginWidth = 10; layout.verticalSpacing = 5; layout.horizontalSpacing = 5; composite.setLayout(layout); composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_FILL)); IWorkbenchHelpSystem whs = PlatformUI.getWorkbench().getHelpSystem(); whs.setHelp(composite, ContextIds.EDITOR_OVERVIEW_PAGE); toolkit.paintBordersFor(composite); section.setClient(composite); int decorationWidth = FieldDecorationRegistry.getDefault().getMaximumDecorationWidth(); // server name if (server != null) { createLabel(toolkit, composite, Messages.serverEditorOverviewServerName); serverName = toolkit.createText(composite, server.getName()); GridData data = new GridData(GridData.FILL_HORIZONTAL); data.horizontalSpan = 2; data.horizontalIndent = decorationWidth; serverName.setLayoutData(data); serverName.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { if (updating) return; updating = true; execute(new SetServerNameCommand(getServer(), serverName.getText())); updating = false; validate(); } }); whs.setHelp(serverName, ContextIds.EDITOR_SERVER); // hostname hostnameLabel = createLabel(toolkit, composite, Messages.serverEditorOverviewServerHostname); hostname = toolkit.createText(composite, server.getHost()); hostnameDecoration = new ControlDecoration(hostname, SWT.TOP | SWT.LEAD); data = new GridData(GridData.FILL_HORIZONTAL); data.horizontalSpan = 2; data.horizontalIndent = decorationWidth; hostname.setLayoutData(data); hostname.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { if (updating) return; updating = true; execute(new SetServerHostnameCommand(getServer(), hostname.getText())); updating = false; } }); whs.setHelp(hostname, ContextIds.EDITOR_HOSTNAME); FieldDecorationRegistry registry = FieldDecorationRegistry.getDefault(); FieldDecoration fd = registry.getFieldDecoration(FieldDecorationRegistry.DEC_CONTENT_PROPOSAL); hostnameDecoration.setImage(fd.getImage()); hostnameDecoration.setDescriptionText(fd.getDescription()); hostnameDecoration.hide(); hostname.addFocusListener(new FocusListener() { public void focusGained(FocusEvent e) { hostnameDecoration.show(); } public void focusLost(FocusEvent e) { hostnameDecoration.hide(); } }); //updateDecoration(hostnameDecoration, new Status(IStatus.INFO, ServerUIPlugin.PLUGIN_ID, "Press Ctrl-Space")); List<String> hosts = ServerUIPlugin.getPreferences().getHostnames(); String[] hosts2 = hosts.toArray(new String[hosts.size()]); new AutoCompleteField(hostname, new TextContentAdapter(), hosts2); } // runtime if (server != null && server.getServerType() != null && server.getServerType().hasRuntime()) { final Hyperlink link = toolkit.createHyperlink(composite, Messages.serverEditorOverviewRuntime, SWT.NONE); final IServerWorkingCopy server2 = server; link.addHyperlinkListener(new HyperlinkAdapter() { public void linkActivated(HyperlinkEvent e) { IRuntime runtime = server2.getRuntime(); if (runtime != null && ServerUIPlugin.hasWizardFragment(runtime.getRuntimeType().getId())) editRuntime(runtime); } }); final IRuntime runtime = server.getRuntime(); if (runtime == null || !ServerUIPlugin.hasWizardFragment(runtime.getRuntimeType().getId())) link.setEnabled(false); IRuntimeType runtimeType = server.getServerType().getRuntimeType(); runtimes = ServerUIPlugin.getRuntimes(runtimeType); runtimeCombo = new Combo(composite, SWT.READ_ONLY); GridData data = new GridData(GridData.FILL_HORIZONTAL); data.horizontalIndent = decorationWidth; data.horizontalSpan = 2; runtimeCombo.setLayoutData(data); updateRuntimeCombo(); int size = runtimes.length; for (int i = 0; i < size; i++) { if (runtimes[i].equals(runtime)) runtimeCombo.select(i); } runtimeCombo.addSelectionListener(new SelectionListener() { public void widgetSelected(SelectionEvent e) { try { if (updating) return; updating = true; IRuntime newRuntime = runtimes[runtimeCombo.getSelectionIndex()]; execute(new SetServerRuntimeCommand(getServer(), newRuntime)); link.setEnabled(newRuntime != null && ServerUIPlugin.hasWizardFragment(newRuntime.getRuntimeType().getId())); updating = false; } catch (Exception ex) { // ignore } } public void widgetDefaultSelected(SelectionEvent e) { widgetSelected(e); } }); whs.setHelp(runtimeCombo, ContextIds.EDITOR_RUNTIME); // add runtime listener runtimeListener = new IRuntimeLifecycleListener() { public void runtimeChanged(final IRuntime runtime2) { // may be name change of current runtime Display.getDefault().syncExec(new Runnable() { public void run() { if (runtime2.equals(getServer().getRuntime())) { try { if (updating) return; updating = true; execute(new SetServerRuntimeCommand(getServer(), runtime2)); updating = false; } catch (Exception ex) { // ignore } } if (runtimeCombo != null && !runtimeCombo.isDisposed()) { updateRuntimeCombo(); int size2 = runtimes.length; for (int i = 0; i < size2; i++) { if (runtimes[i].equals(runtime)) runtimeCombo.select(i); } } } }); } public void runtimeAdded(final IRuntime runtime2) { Display.getDefault().syncExec(new Runnable() { public void run() { if (runtimeCombo != null && !runtimeCombo.isDisposed()) { updateRuntimeCombo(); int size2 = runtimes.length; for (int i = 0; i < size2; i++) { if (runtimes[i].equals(runtime)) runtimeCombo.select(i); } } } }); } public void runtimeRemoved(IRuntime runtime2) { Display.getDefault().syncExec(new Runnable() { public void run() { if (runtimeCombo != null && !runtimeCombo.isDisposed()) { updateRuntimeCombo(); int size2 = runtimes.length; for (int i = 0; i < size2; i++) { if (runtimes[i].equals(runtime)) runtimeCombo.select(i); } } } }); } }; ServerCore.addRuntimeLifecycleListener(runtimeListener); } // server configuration path if (server != null && server.getServerType() != null && server.getServerType().hasServerConfiguration()) { createLabel(toolkit, composite, Messages.serverEditorOverviewServerConfigurationPath); IFolder folder = server.getServerConfiguration(); if (folder == null) serverConfiguration = toolkit.createText(composite, Messages.elementUnknownName); else serverConfiguration = toolkit.createText(composite, "" + server.getServerConfiguration().getFullPath()); serverConfiguration.setEditable(false); GridData data = new GridData(GridData.FILL_HORIZONTAL); data.horizontalIndent = decorationWidth; data.widthHint = 75; serverConfiguration.setLayoutData(data); whs.setHelp(serverConfiguration, ContextIds.EDITOR_CONFIGURATION); final IFolder currentFolder = server.getServerConfiguration(); browse = toolkit.createButton(composite, Messages.serverEditorOverviewServerConfigurationBrowse, SWT.PUSH); browse.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { ContainerSelectionDialog dialog = new ContainerSelectionDialog(serverConfiguration.getShell(), currentFolder, true, Messages.serverEditorOverviewServerConfigurationBrowseMessage); dialog.showClosedProjects(false); if (dialog.open() != Window.CANCEL) { Object[] result = dialog.getResult(); if (result != null && result.length == 1) { IPath path = (IPath) result[0]; IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); IResource resource = root.findMember(path); if (resource != null && resource instanceof IFolder) { IFolder folder2 = (IFolder) resource; if (updating) return; updating = true; execute(new SetServerConfigurationFolderCommand(getServer(), folder2)); serverConfiguration.setText(folder2.getFullPath().toString()); updating = false; } } } } }); browse.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); } IServerType serverType = null; if (server != null && server.getServerType() != null) { serverType = server.getServerType(); if (serverType.supportsLaunchMode(ILaunchManager.RUN_MODE) || serverType.supportsLaunchMode(ILaunchManager.DEBUG_MODE) || serverType.supportsLaunchMode(ILaunchManager.PROFILE_MODE)) { ILaunchConfigurationType launchType = ((ServerType) serverType).getLaunchConfigurationType(); if (launchType != null && launchType.isPublic()) { final Hyperlink link = toolkit.createHyperlink(composite, Messages.serverEditorOverviewOpenLaunchConfiguration, SWT.NONE); GridData data = new GridData(); data.horizontalSpan = 3; link.setLayoutData(data); link.addHyperlinkListener(new HyperlinkAdapter() { public void linkActivated(HyperlinkEvent e) { IEditorPart part = ((MultiPageEditorSite) getSite()).getMultiPageEditor(); IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow() .getActivePage(); page.saveEditor(part, true); try { ILaunchConfiguration launchConfig = ((Server) getServer()) .getLaunchConfiguration(true, null); // TODO: use correct launch group DebugUITools.openLaunchConfigurationPropertiesDialog(link.getShell(), launchConfig, "org.eclipse.debug.ui.launchGroup.run"); } catch (CoreException ce) { if (Trace.SEVERE) { Trace.trace(Trace.STRING_SEVERE, "Could not create launch configuration", ce); } } } }); } } } // Insertion of extension widgets. If the page modifier createControl is not implemented still // add the modifier to the listeners list. List<ServerEditorOverviewPageModifier> pageModifiersLst = getPageModifiers( serverType == null ? null : serverType.getId()); for (ServerEditorOverviewPageModifier curPageModifier : pageModifiersLst) { if (server != null && server.getServerType() != null) { curPageModifier.setServerWorkingCopy(server); curPageModifier.setServerEditorPart(this); curPageModifier.setFormToolkit(toolkit); curPageModifier.createControl(ServerEditorOverviewPageModifier.UI_LOCATION.OVERVIEW, composite); curPageModifier.setUIControlListener(this); } } }
From source file:org.eclipse.wst.server.ui.internal.wizard.page.HostnameComposite.java
License:Open Source License
/** * Creates the UI of the page.//from ww w. j av a 2s . c o m */ protected void createControl() { GridLayout layout = new GridLayout(); layout.horizontalSpacing = SWTUtil.convertHorizontalDLUsToPixels(this, 4); layout.verticalSpacing = SWTUtil.convertVerticalDLUsToPixels(this, 4); layout.marginWidth = 0; layout.marginHeight = 0; layout.numColumns = 3; setLayout(layout); //WorkbenchHelp.setHelp(this, ContextIds.SELECT_CLIENT_WIZARD); Label label = new Label(this, SWT.WRAP); label.setText(Messages.hostname); label.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL)); hostname = new Text(this, SWT.BORDER); hostname.setText(LOCALHOST); final ControlDecoration hostnameDecoration = new ControlDecoration(hostname, SWT.TOP | SWT.LEAD); GridData data = new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_CENTER); data.horizontalSpan = 2; hostname.setLayoutData(data); hostname.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { hostnameChanged(hostname.getText()); } }); FieldDecorationRegistry registry = FieldDecorationRegistry.getDefault(); FieldDecoration fd = registry.getFieldDecoration(FieldDecorationRegistry.DEC_CONTENT_PROPOSAL); hostnameDecoration.setImage(fd.getImage()); hostnameDecoration.setDescriptionText(fd.getDescription()); hostname.addFocusListener(new FocusListener() { public void focusGained(FocusEvent e) { hostnameDecoration.show(); } public void focusLost(FocusEvent e) { hostnameDecoration.hide(); } }); List<String> hosts = ServerUIPlugin.getPreferences().getHostnames(); String[] hosts2 = hosts.toArray(new String[hosts.size()]); new AutoCompleteField(hostname, new TextContentAdapter(), hosts2); Dialog.applyDialogFont(this); }