[199789] Server editor improvements
diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/editor/OverviewEditorPart.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/editor/OverviewEditorPart.java
index 14ecea2..ccb167d 100644
--- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/editor/OverviewEditorPart.java
+++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/editor/OverviewEditorPart.java
@@ -26,9 +26,11 @@
import org.eclipse.debug.core.ILaunchConfigurationType;
import org.eclipse.debug.core.ILaunchManager;
import org.eclipse.debug.ui.DebugUITools;
+import org.eclipse.jface.fieldassist.AutoCompleteField;
import org.eclipse.jface.fieldassist.ControlDecoration;
import org.eclipse.jface.fieldassist.FieldDecoration;
import org.eclipse.jface.fieldassist.FieldDecorationRegistry;
+import org.eclipse.jface.fieldassist.TextContentAdapter;
import org.eclipse.jface.preference.PreferenceDialog;
import org.eclipse.jface.window.Window;
import org.eclipse.osgi.util.NLS;
@@ -300,7 +302,7 @@
createLabel(toolkit, composite, Messages.serverEditorOverviewServerHostname);
hostname = toolkit.createText(composite, server.getHost());
- //ControlDecoration hostnameDecoration = new ControlDecoration(hostname, SWT.TOP | SWT.LEAD);
+ final ControlDecoration hostnameDecoration = new ControlDecoration(hostname, SWT.TOP | SWT.LEAD);
data = new GridData(GridData.FILL_HORIZONTAL);
data.horizontalSpan = 2;
data.horizontalIndent = decorationWidth;
@@ -316,15 +318,27 @@
});
whs.setHelp(hostname, ContextIds.EDITOR_HOSTNAME);
- /*FieldDecorationRegistry registry = FieldDecorationRegistry.getDefault();
+ FieldDecorationRegistry registry = FieldDecorationRegistry.getDefault();
FieldDecoration fd = registry.getFieldDecoration(FieldDecorationRegistry.DEC_CONTENT_PROPOSAL);
hostnameDecoration.setImage(fd.getImage());
hostnameDecoration.setDescriptionText(fd.getDescription());
- hostnameDecoration.show();*/
+ 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"));
- //AutoCompleteField acf = new AutoCompleteField(hostname, new TextContentAdapter(), new String[] { "Testing", "A hostname"});
+ List<String> hosts = ServerUIPlugin.getPreferences().getHostnames();
+ String[] hosts2 = hosts.toArray(new String[hosts.size()]);
+ new AutoCompleteField(hostname, new TextContentAdapter(), hosts2);
}
// runtime
diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/page/HostnameComposite.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/page/HostnameComposite.java
index ab9cf88..0804b1c 100644
--- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/page/HostnameComposite.java
+++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/page/HostnameComposite.java
@@ -13,22 +13,26 @@
import java.util.List;
import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.fieldassist.AutoCompleteField;
+import org.eclipse.jface.fieldassist.ControlDecoration;
+import org.eclipse.jface.fieldassist.FieldDecoration;
+import org.eclipse.jface.fieldassist.FieldDecorationRegistry;
+import org.eclipse.jface.fieldassist.TextContentAdapter;
import org.eclipse.wst.server.ui.internal.Messages;
import org.eclipse.wst.server.ui.internal.SWTUtil;
import org.eclipse.wst.server.ui.internal.ServerUIPlugin;
import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.FocusEvent;
+import org.eclipse.swt.events.FocusListener;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
/**
* A composite used to select a hostname.
*/
@@ -37,7 +41,7 @@
protected String host;
protected IHostnameSelectionListener listener;
- protected Combo combo;
+ protected Text hostname;
public interface IHostnameSelectionListener {
public void hostnameSelected(String host);
@@ -73,30 +77,38 @@
label.setText(Messages.hostname);
label.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
- List<String> hosts = ServerUIPlugin.getPreferences().getHostnames();
- String[] s = new String[hosts.size()];
- hosts.toArray(s);
-
- combo = new Combo(this, SWT.DROP_DOWN);
- combo.setItems(s);
- combo.setText(LOCALHOST);
+ 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;
- combo.setLayoutData(data);
+ hostname.setLayoutData(data);
- combo.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- hostnameChanged(combo.getText());
- }
- });
- combo.addModifyListener(new ModifyListener() {
+ hostname.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
- Point p = combo.getSelection();
- hostnameChanged(combo.getText());
- combo.setSelection(p);
+ 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);
}
@@ -115,7 +127,7 @@
return host;
}
- public void setHostname(String hostname) {
- combo.setText(hostname);
+ public void setHostname(String newHostname) {
+ hostname.setText(newHostname);
}
}