[428539] ServerEditorOverviewPageModifier has several flaws
diff --git a/plugins/org.eclipse.wst.server.ui/META-INF/MANIFEST.MF b/plugins/org.eclipse.wst.server.ui/META-INF/MANIFEST.MF
index 69e246a..bdc5bbc 100644
--- a/plugins/org.eclipse.wst.server.ui/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.wst.server.ui/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.wst.server.ui; singleton:=true
-Bundle-Version: 1.4.202.qualifier
+Bundle-Version: 1.5.0.qualifier
Bundle-Activator: org.eclipse.wst.server.ui.internal.ServerUIPlugin
Bundle-Vendor: %providerName
Bundle-Localization: plugin
diff --git a/plugins/org.eclipse.wst.server.ui/schema/serverEditorOverviewPageModifier.exsd b/plugins/org.eclipse.wst.server.ui/schema/serverEditorOverviewPageModifier.exsd
index 9bf999f..a700764 100644
--- a/plugins/org.eclipse.wst.server.ui/schema/serverEditorOverviewPageModifier.exsd
+++ b/plugins/org.eclipse.wst.server.ui/schema/serverEditorOverviewPageModifier.exsd
@@ -19,7 +19,7 @@
</appInfo>
</annotation>
<complexType>
- <sequence>
+ <sequence minOccurs="1" maxOccurs="unbounded">
<element ref="serverEditorOverviewPageModifier"/>
</sequence>
<attribute name="point" type="string" use="required">
@@ -70,11 +70,41 @@
</appInfo>
</annotation>
</attribute>
+ <attribute name="serverTypes" type="string">
+ <annotation>
+ <documentation>
+ An optional list of comma-separated server types IDs for which this modifier is valid. An unset or empty value will be interpreted as the modifier being valid for all server types. May include wildcards (*) at the end of an id.
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="order" type="string">
+ <annotation>
+ <documentation>
+ Integer value to help the order which modifiers are run. Modifier with smaller order will be created near the top, while a larger order is placed near the bottom. Default value is 10 to
+ allow relative order for modifiers that do not have order value provided.
+ </documentation>
+ </annotation>
+ </attribute>
</complexType>
</element>
<annotation>
<appInfo>
+ <meta.section type="apiInfo"/>
+ </appInfo>
+ <documentation>
+ Value of the attribute <b>class</b> must be a fully qualified name of a Java class that extends <code>org.eclipse.wst.server.ui.editor.ServerEditorPageExtension</code>.
+
+This extension point currently only supports the control on the following fields on the implementation of org.eclipse.wst.server.ui.AbstractUIControl.IUIControlListener.handleUIControlMapChanged(Map<String, UIControlEntry>):
+Server's host name
+
+This extension point currently only issue property change event on the following property change:
+Server type selection change
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
<meta.section type="since"/>
</appInfo>
<documentation>
@@ -93,8 +123,11 @@
<extension
point="org.eclipse.wst.server.ui.serverEditorPageExtension">
<serverEditorOverviewPageModifier
- id="org.eclipse.wst.server.ui.test.serverEditorOverviewModifier"
- class="org.eclipse.wst.server.ui.test.internal.serverEditorPageExtension.ServerEditorOverviewPageModifierTest"/>
+ id="org.eclipse.wst.server.ui.tests.wizard.serverEditorOverviewPageModifierTest"
+ class="org.eclipse.wst.server.ui.editor.ServerEditorOverviewPageModifierTest"
+ order="12"
+ serverTypes="org.eclipse.my.server.type,org.eclipse.my.server.type2.*">
+ </serverEditorOverviewPageModifier>
</extension>
</pre>
</documentation>
@@ -106,7 +139,7 @@
<meta.section type="copyright"/>
</appInfo>
<documentation>
- Copyright (c) 2010 IBM Corporation and others.<br>
+ Copyright (c) 2010,2014 IBM Corporation and others.<br>
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
@@ -114,19 +147,4 @@
</documentation>
</annotation>
- <annotation>
- <appInfo>
- <meta.section type="apiInfo"/>
- </appInfo>
- <documentation>
- Value of the attribute <b>class</b> must be a fully qualified name of a Java class that extends <code>org.eclipse.wst.server.ui.editor.ServerEditorPageExtension</code>.
-
-This extension point currently only supports the control on the following fields on the implementation of org.eclipse.wst.server.ui.AbstractUIControl.IUIControlListener.handleUIControlMapChanged(Map<String, UIControlEntry>):
-Server's host name
-
-This extension point currently only issue property change event on the following property change:
-Server type selection change
- </documentation>
- </annotation>
-
</schema>
diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/ServerUIPlugin.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/ServerUIPlugin.java
index 13b3db8..195bb5d 100644
--- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/ServerUIPlugin.java
+++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/ServerUIPlugin.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2003, 2011 IBM Corporation and others.
+ * Copyright (c) 2003, 2014 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
@@ -85,7 +85,7 @@
private static List<ServerCreationWizardPageExtension> serverCreationWizardPageExtensions;
// Cached copy of all server editor UI modifiers
- private static List<ServerEditorOverviewPageModifier> serverEditorOverviewPageModifier;
+ private static List<OverviewPageModifierFactory> serverEditorOverviewPageModifierFactories;
// Cached copy of all delete dialog UI modifier
private static List<DeleteServerDialogExtension> deleteServerDialogExtensions;
@@ -782,16 +782,77 @@
}
/**
- * Returns the list of server editor modifiers.
+ * Returns the list of server editor modifiers that are valid for this server type
*
* @return the list of server editor modifiers, or an empty list if none could be found
*/
- public static List<ServerEditorOverviewPageModifier> getServerEditorOverviewPageModifiers() {
- if (serverEditorOverviewPageModifier == null)
- loadServerEditorOverviewPageModifiers();
- return serverEditorOverviewPageModifier;
+ public static List<ServerEditorOverviewPageModifier> getServerEditorOverviewPageModifiers(String serverType) {
+ return getServerEditorOverviewPageModifiersImpl(serverType);
}
+ private static List<ServerEditorOverviewPageModifier> getServerEditorOverviewPageModifiersImpl(String serverType) {
+ if (serverEditorOverviewPageModifierFactories == null)
+ loadServerEditorOverviewPageModifiers();
+ ArrayList<ServerEditorOverviewPageModifier> pageModifierImplLst = new ArrayList<ServerEditorOverviewPageModifier>();
+ Iterator<OverviewPageModifierFactory> dIterator = serverEditorOverviewPageModifierFactories.iterator();
+ OverviewPageModifierFactory curFactory;
+ while(dIterator.hasNext()) {
+ curFactory = dIterator.next();
+ if( curFactory != null && (serverType == null || curFactory.supportsType(serverType))) {
+ pageModifierImplLst.add(curFactory.createModifier());
+ }
+ }
+ return pageModifierImplLst;
+ }
+
+ private static class OverviewPageModifierFactory implements Comparable<OverviewPageModifierFactory> {
+ IConfigurationElement element;
+ String[] serverTypes = null;
+ int order = 10;
+ OverviewPageModifierFactory(IConfigurationElement element) {
+ this.element = element;
+ init();
+ }
+ private void init() {
+ String attr = element.getAttribute("serverTypes");
+ serverTypes = (attr == null || attr.length() == 0) ? null : attr.split(",");
+
+ String w = element.getAttribute("order");
+ if( w != null ) {
+ try {
+ order = Integer.parseInt(w);
+ } catch (NumberFormatException e) {
+ // Do nothing.
+ }
+ }
+ }
+ ServerEditorOverviewPageModifier createModifier() {
+ try {
+ ServerEditorOverviewPageModifier curExtension = (ServerEditorOverviewPageModifier)element.createExecutableExtension("class");
+ if (Trace.CONFIG) {
+ Trace.trace(Trace.STRING_CONFIG,
+ " New instance of .serverEditorOverviewPageModifier: " + element.getAttribute("id")
+ + ", loaded class=" + curExtension);
+ }
+ return curExtension;
+ } catch (Throwable t) {
+ if (Trace.SEVERE) {
+ Trace.trace(Trace.STRING_SEVERE,
+ " Could not create new instance .serverEditorOverviewPageModifier: " + element.getAttribute("id"), t);
+ }
+ }
+ return null;
+ }
+
+ boolean supportsType(String serverType) {
+ return ServerPlugin.contains(serverTypes, serverType);
+ }
+
+ public int compareTo(OverviewPageModifierFactory factory) {
+ return order - factory.order;
+ }
+ }
+
/**
* Returns the list of delete server dialog modifiers.
*
@@ -848,13 +909,13 @@
* Load the Server editor page modifiers.
*/
private static synchronized void loadServerEditorOverviewPageModifiers() {
- if (serverEditorOverviewPageModifier != null)
+ if (serverEditorOverviewPageModifierFactories != null)
return;
if (Trace.CONFIG) {
Trace.trace(Trace.STRING_CONFIG, "->- Loading .serverEditorOverviewPageModifier extension point ->-");
}
- serverEditorOverviewPageModifier = new ArrayList<ServerEditorOverviewPageModifier>();
+ serverEditorOverviewPageModifierFactories = new ArrayList<OverviewPageModifierFactory>();
IExtensionRegistry registry = Platform.getExtensionRegistry();
IConfigurationElement[] cf = registry.getConfigurationElementsFor(ServerUIPlugin.PLUGIN_ID, "serverEditorOverviewPageModifier");
@@ -867,8 +928,7 @@
+ ", loaded class=" + curExtension);
}
if (curExtension != null)
- serverEditorOverviewPageModifier.add(curExtension);
-
+ serverEditorOverviewPageModifierFactories.add(new OverviewPageModifierFactory(curConfigElement));
} catch (Throwable t) {
if (Trace.SEVERE) {
Trace.trace(Trace.STRING_SEVERE,
@@ -876,7 +936,7 @@
}
}
}
-
+ Collections.sort(serverEditorOverviewPageModifierFactories);
if (Trace.CONFIG) {
Trace.trace(Trace.STRING_CONFIG, "-<- Done loading .serverEditorOverviewPageModifier extension point -<-");
}
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 a11415d..6d35cab 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
@@ -107,6 +107,7 @@
protected Spinner startTimeoutSpinner;
protected Spinner stopTimeoutSpinner;
protected ManagedForm managedForm;
+ private List<ServerEditorOverviewPageModifier> pageModifiersList;
protected boolean updating;
@@ -411,9 +412,10 @@
// 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 = server.getRuntime();
+ IRuntime runtime = server2.getRuntime();
if (runtime != null && ServerUIPlugin.hasWizardFragment(runtime.getRuntimeType().getId()))
editRuntime(runtime);
}
@@ -576,15 +578,16 @@
browse.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));
}
+ IServerType serverType = null;
if (server != null && server.getServerType() != null) {
- IServerType serverType = server.getServerType();
+ 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 = 2;
+ data.horizontalSpan = 3;
link.setLayoutData(data);
link.addHyperlinkListener(new HyperlinkAdapter() {
public void linkActivated(HyperlinkEvent e) {
@@ -605,9 +608,10 @@
// Insertion of extension widgets. If the page modifier createControl is not implemented still
// add the modifier to the listeners list.
- List<ServerEditorOverviewPageModifier> pageModifiersLst = ServerUIPlugin.getServerEditorOverviewPageModifiers();
+ List<ServerEditorOverviewPageModifier> pageModifiersLst = getPageModifiers(serverType == null ? null : serverType.getId());
for (ServerEditorOverviewPageModifier curPageModifier : pageModifiersLst) {
if(server != null && server.getServerType() != null){
+ curPageModifier.setServerWorkingCopy(server);
curPageModifier.createControl(ServerEditorOverviewPageModifier.UI_LOCATION.OVERVIEW, composite);
curPageModifier.setUIControlListener(this);
}
@@ -1016,7 +1020,7 @@
autoPublishTime.setEnabled(publishSetting != Server.AUTO_PUBLISH_DISABLE);
}
- List<ServerEditorOverviewPageModifier> pageModifiersLst = ServerUIPlugin.getServerEditorOverviewPageModifiers();
+ List<ServerEditorOverviewPageModifier> pageModifiersLst = getPageModifiers(null);
for (ServerEditorOverviewPageModifier curPageModifier : pageModifiersLst) {
if(server != null && server.getServerType() != null)
curPageModifier.setServerWorkingCopy(server);
@@ -1027,6 +1031,14 @@
updating = false;
validate();
}
+
+ private List<ServerEditorOverviewPageModifier> getPageModifiers(String serverTypeId) {
+ if( pageModifiersList == null ) {
+ pageModifiersList = ServerUIPlugin.getServerEditorOverviewPageModifiers(serverTypeId);
+ }
+
+ return pageModifiersList;
+ }
protected void validate() {
IManagedForm mForm = getManagedForm();