Search in sources :

Example 1 with FieldDecorationRegistry

use of org.eclipse.jface.fieldassist.FieldDecorationRegistry in project webtools.servertools by eclipse.

the class HostnameComposite method createControl.

/**
 * Creates the UI of the page.
 */
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);
}
Also used : ModifyListener(org.eclipse.swt.events.ModifyListener) FieldDecoration(org.eclipse.jface.fieldassist.FieldDecoration) Label(org.eclipse.swt.widgets.Label) Text(org.eclipse.swt.widgets.Text) TextContentAdapter(org.eclipse.jface.fieldassist.TextContentAdapter) FocusEvent(org.eclipse.swt.events.FocusEvent) AutoCompleteField(org.eclipse.jface.fieldassist.AutoCompleteField) GridLayout(org.eclipse.swt.layout.GridLayout) ModifyEvent(org.eclipse.swt.events.ModifyEvent) FieldDecorationRegistry(org.eclipse.jface.fieldassist.FieldDecorationRegistry) GridData(org.eclipse.swt.layout.GridData) ControlDecoration(org.eclipse.jface.fieldassist.ControlDecoration) FocusListener(org.eclipse.swt.events.FocusListener)

Aggregations

AutoCompleteField (org.eclipse.jface.fieldassist.AutoCompleteField)1 ControlDecoration (org.eclipse.jface.fieldassist.ControlDecoration)1 FieldDecoration (org.eclipse.jface.fieldassist.FieldDecoration)1 FieldDecorationRegistry (org.eclipse.jface.fieldassist.FieldDecorationRegistry)1 TextContentAdapter (org.eclipse.jface.fieldassist.TextContentAdapter)1 FocusEvent (org.eclipse.swt.events.FocusEvent)1 FocusListener (org.eclipse.swt.events.FocusListener)1 ModifyEvent (org.eclipse.swt.events.ModifyEvent)1 ModifyListener (org.eclipse.swt.events.ModifyListener)1 GridData (org.eclipse.swt.layout.GridData)1 GridLayout (org.eclipse.swt.layout.GridLayout)1 Label (org.eclipse.swt.widgets.Label)1 Text (org.eclipse.swt.widgets.Text)1