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);
}
Aggregations