[204613] Update server editor forms
diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/editor/ServerEditorPart.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/editor/ServerEditorPart.java
index b41ba8e..f8cb714 100644
--- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/editor/ServerEditorPart.java
+++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/editor/ServerEditorPart.java
@@ -19,6 +19,8 @@
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorSite;
+import org.eclipse.ui.forms.IManagedForm;
+import org.eclipse.ui.forms.IMessageManager;
import org.eclipse.ui.forms.widgets.FormToolkit;
import org.eclipse.ui.part.EditorPart;
import org.eclipse.wst.server.core.IServerWorkingCopy;
@@ -43,6 +45,7 @@
private List<ServerEditorSection> sections = null;
private ServerResourceCommandManager commandManager;
private FormToolkit toolkit;
+ private IManagedForm managedForm;
/**
* The server currently being edited.
@@ -91,9 +94,31 @@
}
/**
+ * Set the managed form that this part is using.
+ *
+ * @param managedForm a managed form
+ */
+ protected void setManagedForm(IManagedForm managedForm) {
+ this.managedForm = managedForm;
+ }
+
+ /**
+ * Returns the managed form that this part is using, or <code>null</code> if no
+ * managed form has been set.
+ *
+ * @return managedForm the managed form that this part is using, or <code>null</code>
+ * if no managed form has been set
+ */
+ protected IManagedForm getManagedForm() {
+ return managedForm;
+ }
+
+ /**
* Set an error message for this page.
*
- * @param error java.lang.String
+ * @param error the error message
+ * @see #getManagedForm() Use forms UI based for errors via {@link IMessageManager}
+ * on the message form instead of this method
*/
public void setErrorMessage(String error) {
if (error == null && errorMessage == null)
@@ -108,6 +133,9 @@
/**
* Updates the error message shown in the editor.
+ *
+ * @see #getManagedForm() Use forms UI based for errors via {@link IMessageManager}
+ * on the message form instead of this method
*/
public void updateErrorMessage() {
super.firePropertyChange(PROP_ERROR);
@@ -116,7 +144,9 @@
/**
* Return the error message for this page.
*
- * @return java.lang.String
+ * @return the error message
+ * @see #getManagedForm() Use forms UI based for errors via {@link IMessageManager}
+ * on the message form instead of this method
*/
public String getErrorMessage() {
if (errorMessage == null) {
@@ -136,7 +166,9 @@
* server resource is saved. If there are any error messages, the
* user will be unable to save the editor.
*
- * @return org.eclipse.core.runtime.IStatus
+ * @return a set of status
+ * @see #getManagedForm() Use forms UI based for errors via {@link IMessageManager}
+ * on the message form instead of this method
*/
public IStatus[] getSaveStatus() {
Iterator iterator = getSections().iterator();
@@ -247,7 +279,7 @@
}
/**
- * Return the server that is being editted.
+ * Return the server that is being edited.
*
* @return a server working copy
*/
@@ -295,13 +327,16 @@
}
/**
- * Get a form toolkit to create widgets. It will automatically be disposed
- * when the editor is disposed.
+ * Get a form toolkit to create widgets. It will be disposed automatically
+ * when the editor is closed.
*
* @param display the display
* @return FormToolkit
*/
protected FormToolkit getFormToolkit(Display display) {
+ if (managedForm != null)
+ return managedForm.getToolkit();
+
if (toolkit == null)
toolkit = new FormToolkit(display);
return toolkit;
diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/editor/ServerEditorSection.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/editor/ServerEditorSection.java
index 218d922..ccc2473 100644
--- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/editor/ServerEditorSection.java
+++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/editor/ServerEditorSection.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2003, 2005 IBM Corporation and others.
+ * Copyright (c) 2003, 2007 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -17,6 +17,8 @@
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorSite;
+import org.eclipse.ui.forms.IManagedForm;
+import org.eclipse.ui.forms.IMessageManager;
import org.eclipse.ui.forms.widgets.FormToolkit;
import org.eclipse.wst.server.core.IServerWorkingCopy;
import org.eclipse.wst.server.ui.internal.editor.ServerEditorPartInput;
@@ -89,9 +91,11 @@
}
/**
- * Return the error message for this page.
+ * Return the error message for this section.
*
* @return the error message
+ * @see #getManagedForm() Use forms UI based for errors via {@link IMessageManager}
+ * on the message form instead of this method
*/
public String getErrorMessage() {
return errorMessage;
@@ -105,6 +109,8 @@
* @return a status object with code <code>IStatus.OK</code> if this
* server can be saved, otherwise a status object indicating why
* it can't be
+ * @see #getManagedForm() Use forms UI based for errors via {@link IMessageManager}
+ * on the message form instead of this method
*/
public IStatus[] getSaveStatus() {
return null;
@@ -120,9 +126,11 @@
}
/**
- * Set an error message for this page.
+ * Set an error message for this section.
*
* @param error an error message
+ * @see #getManagedForm() Use forms UI based for errors via {@link IMessageManager}
+ * on the message form instead of this method
*/
public void setErrorMessage(String error) {
if (error == null && errorMessage == null)
@@ -137,17 +145,28 @@
}
/**
- * Get a form toolkit to create widgets. It will automatically be disposed
- * when the editor is disposed.
+ * Get a form toolkit to create widgets. It will be disposed automatically
+ * when the editor is closed.
*
* @param display the display
- * @return FormToolkit
+ * @return a FormToolkit
*/
protected FormToolkit getFormToolkit(Display display) {
return editor.getFormToolkit(display);
}
/**
+ * Returns the managed form that the editor is using, or <code>null</code> if no
+ * managed form has been set.
+ *
+ * @return the managed form that the editor is using, or <code>null</code> if no
+ * managed form has been set.
+ */
+ protected IManagedForm getManagedForm() {
+ return editor.getManagedForm();
+ }
+
+ /**
* Disposes of the section.
*/
public void dispose() {
diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/Messages.properties b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/Messages.properties
index 3da7c95..1eef84c 100644
--- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/Messages.properties
+++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/Messages.properties
@@ -430,7 +430,7 @@
serverEditorOverviewServerName=Server name:
serverEditorOverviewServerNameCommand=set server name
serverEditorOverviewServerConfigurationPath=Configuration path:
-serverEditorOverviewServerConfigurationBrowse=Browse
+serverEditorOverviewServerConfigurationBrowse=Browse...
serverEditorOverviewServerConfigurationBrowseMessage=Specify the location of the server configuration.
serverEditorOverviewServerHostname=Host name:
serverEditorOverviewServerHostnameCommand=set host name
@@ -447,7 +447,7 @@
serverEditorOverviewAutoPublishDisable=Never publish automatically
serverEditorOverviewAutoPublishCommand=modify publish settings
serverEditorOverviewOpenLaunchConfiguration=Open launch configuration
-serverEditorOverviewAutoPublishInvalid=The automatic publish setting is invalid. It must be a {0} seconds or more.
+serverEditorOverviewAutoPublishInvalid=The automatic publish setting is invalid. It must be a 1 second or more.
# Menu items. {0} will be replaced by one of the xxxEditorActionXxx fields
# from below. @Ctrl+Z is the menu mnemonic
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 ccb167d..0bee128 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,6 +26,7 @@
import org.eclipse.debug.core.ILaunchConfigurationType;
import org.eclipse.debug.core.ILaunchManager;
import org.eclipse.debug.ui.DebugUITools;
+import org.eclipse.jface.dialogs.IMessageProvider;
import org.eclipse.jface.fieldassist.AutoCompleteField;
import org.eclipse.jface.fieldassist.ControlDecoration;
import org.eclipse.jface.fieldassist.FieldDecoration;
@@ -33,7 +34,6 @@
import org.eclipse.jface.fieldassist.TextContentAdapter;
import org.eclipse.jface.preference.PreferenceDialog;
import org.eclipse.jface.window.Window;
-import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.*;
import org.eclipse.swt.graphics.Image;
@@ -52,6 +52,8 @@
import org.eclipse.ui.dialogs.ContainerSelectionDialog;
import org.eclipse.ui.dialogs.PreferencesUtil;
import org.eclipse.ui.forms.IFormColors;
+import org.eclipse.ui.forms.IManagedForm;
+import org.eclipse.ui.forms.ManagedForm;
import org.eclipse.ui.forms.events.HyperlinkAdapter;
import org.eclipse.ui.forms.events.HyperlinkEvent;
import org.eclipse.ui.forms.widgets.*;
@@ -86,9 +88,6 @@
protected Button autoPublishOverride;
protected Spinner autoPublishTime;
- protected ControlDecoration serverConfigurationDecoration;
- protected ControlDecoration serverNameDecoration;
-
protected boolean updating;
protected IRuntime[] runtimes;
@@ -110,18 +109,8 @@
protected void addChangeListener() {
listener = new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent event) {
- if (event.getPropertyName().equals("configuration-id") && serverConfiguration != null) {
- IFolder folder = getServer().getServerConfiguration();
- if (folder == null || !folder.exists()) {
- FieldDecorationRegistry registry = FieldDecorationRegistry.getDefault();
- FieldDecoration fd = registry.getFieldDecoration(FieldDecorationRegistry.DEC_ERROR);
- serverConfigurationDecoration.setImage(fd.getImage());
- serverConfigurationDecoration.setDescriptionText(Messages.errorMissingConfiguration);
- serverConfigurationDecoration.show();
- } else
- serverConfigurationDecoration.hide();
- }
- validate();
+ if (event.getPropertyName().equals("configuration-id") && serverConfiguration != null)
+ validate();
// following code behaves poorly because there is no default local or remote
// publishing time per server or server type. as a result it sets the value
@@ -205,9 +194,10 @@
* @param parent the parent control
*/
public final void createPartControl(final Composite parent) {
- FormToolkit toolkit = getFormToolkit(parent.getDisplay());
-
- ScrolledForm form = toolkit.createScrolledForm(parent);
+ IManagedForm mForm = new ManagedForm(parent);
+ setManagedForm(mForm);
+ ScrolledForm form = mForm.getForm();
+ FormToolkit toolkit = mForm.getToolkit();
toolkit.decorateFormHeading(form.getForm());
form.setText(Messages.serverEditorOverviewPageTitle);
form.setImage(ImageResource.getImage(ImageResource.IMG_SERVER));
@@ -294,6 +284,7 @@
updating = true;
execute(new SetServerNameCommand(getServer(), serverName.getText()));
updating = false;
+ validate();
}
});
whs.setHelp(serverName, ContextIds.EDITOR_SERVER);
@@ -344,7 +335,12 @@
// runtime
if (server != null && server.getServerType() != null && server.getServerType().hasRuntime()) {
final IRuntime runtime = server.getRuntime();
- createLabel(toolkit, composite, Messages.serverEditorOverviewRuntime);
+ Hyperlink link = toolkit.createHyperlink(composite, Messages.serverEditorOverviewRuntime, SWT.NONE);
+ link.addHyperlinkListener(new HyperlinkAdapter() {
+ public void linkActivated(HyperlinkEvent e) {
+ editRuntime(runtime);
+ }
+ });
IRuntimeType runtimeType = server.getServerType().getRuntimeType();
runtimes = ServerUIPlugin.getRuntimes(runtimeType);
@@ -352,6 +348,7 @@
runtimeCombo = new Combo(composite, SWT.READ_ONLY);
GridData data = new GridData(GridData.FILL_HORIZONTAL);
data.horizontalIndent = decorationWidth;
+ data.horizontalSpan = 2;
runtimeCombo.setLayoutData(data);
updateRuntimeCombo();
@@ -380,14 +377,6 @@
});
whs.setHelp(runtimeCombo, ContextIds.EDITOR_RUNTIME);
- Hyperlink link = toolkit.createHyperlink(composite, Messages.serverEditorOverviewRuntimeEdit, SWT.NONE);
- link.addHyperlinkListener(new HyperlinkAdapter() {
- public void linkActivated(HyperlinkEvent e) {
- editRuntime(runtime);
- }
- });
- link.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));
-
// add runtime listener
runtimeListener = new IRuntimeLifecycleListener() {
public void runtimeChanged(final IRuntime runtime2) {
@@ -464,15 +453,6 @@
serverConfiguration = toolkit.createText(composite, Messages.elementUnknownName);
else
serverConfiguration = toolkit.createText(composite, "" + server.getServerConfiguration().getFullPath());
- serverConfigurationDecoration = new ControlDecoration(serverConfiguration, SWT.TOP | SWT.LEAD);
- if (folder == null || !folder.exists()) {
- FieldDecorationRegistry registry = FieldDecorationRegistry.getDefault();
- FieldDecoration fd = registry.getFieldDecoration(FieldDecorationRegistry.DEC_ERROR);
- serverConfigurationDecoration.setImage(fd.getImage());
- serverConfigurationDecoration.setDescriptionText(Messages.errorMissingConfiguration);
- serverConfigurationDecoration.show();
- }
- //if (!server.getServerConfiguration().getFullPath().toFile().exists())
serverConfiguration.setEditable(false);
GridData data = new GridData(GridData.FILL_HORIZONTAL);
@@ -828,30 +808,31 @@
}
protected void validate() {
+ IManagedForm mForm = getManagedForm();
+ if (mForm == null)
+ return;
+
+ mForm.getMessageManager().removeMessage("name", serverName);
if (server != null && serverName != null) {
- if (ServerPlugin.isNameInUse(server, serverName.getText().trim())) {
- setErrorMessage(Messages.errorDuplicateName);
- return;
- }
+ if (ServerPlugin.isNameInUse(server, serverName.getText().trim()))
+ mForm.getMessageManager().addMessage("name", Messages.errorDuplicateName, null, IMessageProvider.WARNING, serverName);
}
+ mForm.getMessageManager().removeMessage("config", serverConfiguration);
if (server != null && server.getServerType() != null && server.getServerType().hasServerConfiguration()) {
IFolder folder = getServer().getServerConfiguration();
- if (folder == null || !folder.exists()) {
- setErrorMessage(Messages.errorMissingConfiguration);
- return;
- }
+ if (folder == null || !folder.exists())
+ mForm.getMessageManager().addMessage("config", Messages.errorMissingConfiguration, null, IMessageProvider.WARNING, serverConfiguration);
}
+ mForm.getMessageManager().removeMessage("auto-publish", autoPublishTime);
if (autoPublishTime != null && autoPublishTime.isEnabled() && autoPublishOverride.getSelection()) {
int i = autoPublishTime.getSelection();
- if (i < 1) {
- setErrorMessage(NLS.bind(Messages.serverEditorOverviewAutoPublishInvalid, "1"));
- return;
- }
+ if (i < 1)
+ mForm.getMessageManager().addMessage("auto-publish", Messages.serverEditorOverviewAutoPublishInvalid, null, IMessageProvider.WARNING, autoPublishTime);
}
- setErrorMessage(null);
+ mForm.getMessageManager().update();
}
protected void updateDecoration(ControlDecoration decoration, IStatus status) {
diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/editor/ServerEditor.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/editor/ServerEditor.java
index 8f09fb1..6d6a8cd 100644
--- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/editor/ServerEditor.java
+++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/editor/ServerEditor.java
@@ -400,7 +400,7 @@
/**
* Fire a property change event.
*
- * @param i int
+ * @param i a property change value
*/
protected void firePropertyChange(int i) {
if (i == ServerEditorPart.PROP_ERROR)