[148442] Module label decorator
diff --git a/plugins/org.eclipse.wst.server.ui/plugin.properties b/plugins/org.eclipse.wst.server.ui/plugin.properties
index 64929f4..8326a5d 100644
--- a/plugins/org.eclipse.wst.server.ui/plugin.properties
+++ b/plugins/org.eclipse.wst.server.ui/plugin.properties
@@ -76,8 +76,8 @@
monitorLabel=TCP/IP monitor
monitorDescription=Uses the internal TCP/IP monitor to monitor server requests.
-moduleProjectDecoratorLabel=Module Project Decorator
-moduleProjectDecoratorDescription=A module label decorator
+moduleProjectDecoratorLabel=Module Project
+moduleProjectDecoratorDescription=Decorates server modules with information on the project that they come from
# --------------- Action Sets (toolbar icon groups) ---------------
diff --git a/plugins/org.eclipse.wst.server.ui/plugin.xml b/plugins/org.eclipse.wst.server.ui/plugin.xml
index 4478f83..7666f8d 100644
--- a/plugins/org.eclipse.wst.server.ui/plugin.xml
+++ b/plugins/org.eclipse.wst.server.ui/plugin.xml
@@ -413,7 +413,6 @@
markerType="org.eclipse.wst.common.project.facet.core.validation.marker"/>
</extension>
-<!--
<extension point="org.eclipse.ui.decorators">
<decorator
adaptable="true"
@@ -431,6 +430,5 @@
</enablement>
</decorator>
</extension>
--->
</plugin>
\ No newline at end of file
diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/Messages.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/Messages.java
index 0a2a439..2e1a2a1 100644
--- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/Messages.java
+++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/Messages.java
@@ -177,6 +177,8 @@
public static String wizModuleRemove;
public static String wizModuleAddAll;
public static String wizModuleRemoveAll;
+ public static String wizModuleRequiredModule;
+ public static String wizModuleRequiredModules;
public static String wizTaskTitle;
public static String wizTaskDescription;
public static String wizErrorInvalidFolder;
@@ -326,6 +328,7 @@
public static String jobRestarting;
public static String clientDefaultName;
public static String clientDefaultDescription;
+ public static String moduleDecoratorProject;
public static String errorStartingMonitor;
public static String audioPrefSelectFile;
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 928969b..1924832 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
@@ -54,7 +54,7 @@
wizNewInstallableServerDescription=Download and install support for a new server
wizNewInstallableServerMessage=The following server adapters have been found on remote update manager sites. Select a server adapter to download and install.
wizNewInstallableServerConfirm=Support for {0} will now be downloaded and installed. You will be prompted to restart once the installation is complete.
-wizNewInstallableServerJob=Installing support for {0}
+wizNewInstallableServerJob=Installing {0}
wizNewInstallableServerRestart=Installation complete. The new server will not be available until after the workbench is restarted. Do you want to restart now?
# License wizard
@@ -75,6 +75,8 @@
wizModuleAddAll=Add A&ll >>
wizModuleRemove=< &Remove
wizModuleRemoveAll=<< Re&move All
+wizModuleRequiredModule={0} is required and can't be removed from the server
+wizModuleRequiredModules=One of the required modules ({0}) must be added to the server
# Wizard info and error messages
wizErrorInvalidFolder=The folder must be a server project or a folder within a server project
@@ -405,6 +407,9 @@
clientDefaultName=Do nothing
clientDefaultDescription=Launch the module on the server but do not bring up a client application.
+# Module decorator
+moduleDecoratorProject={0} ({1})
+
# --------------- Editor support ---------------
serverEditorOverviewPageTitle=Server Overview
diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/ModuleLabelDecorator.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/ModuleLabelDecorator.java
index 04935ec..5b12d9d 100644
--- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/ModuleLabelDecorator.java
+++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/ModuleLabelDecorator.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006 IBM Corporation and others.
+ * Copyright (c) 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
@@ -12,6 +12,7 @@
import org.eclipse.core.resources.IProject;
import org.eclipse.jface.viewers.ILabelDecorator;
+import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.graphics.Image;
import org.eclipse.ui.PlatformUI;
import org.eclipse.wst.server.core.IModule;
@@ -58,17 +59,18 @@
module = modules[modules.length - 1];
}
if (module == null)
- return "";
+ return null;
IProject project = module.getProject();
if (project == null)
- return "";
+ return null;
- String text2 = PlatformUI.getWorkbench().getDecoratorManager().decorateText(text, project);
- return text2;
+ if (!project.getName().equals(text))
+ text = NLS.bind(Messages.moduleDecoratorProject, new String[] {text, project.getName()});
+ return PlatformUI.getWorkbench().getDecoratorManager().decorateText(text, project);
} catch (Exception e) {
- return "";
+ return null;
}
}
}
\ No newline at end of file
diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/ServerPropertyTester.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/ServerPropertyTester.java
index 04be1fc..95e1d7d 100644
--- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/ServerPropertyTester.java
+++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/ServerPropertyTester.java
@@ -74,7 +74,7 @@
ModuleServer ms = (ModuleServer) target;
server = ms.server;
}
- if (server == null)
+ if (server == null || server.getServerType() == null)
return false;
String[] typeIds = ServerPlugin.tokenize(value, ",");
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 4c980af..4de5539 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
@@ -18,6 +18,7 @@
import java.util.StringTokenizer;
import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.*;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.dialogs.IDialogConstants;
@@ -33,6 +34,7 @@
import org.eclipse.wst.server.ui.internal.editor.IServerEditorInput;
import org.eclipse.wst.server.ui.internal.editor.ServerEditorCore;
import org.eclipse.wst.server.ui.internal.editor.ServerEditorInput;
+import org.eclipse.wst.server.ui.internal.view.servers.ModuleServer;
import org.eclipse.wst.server.ui.internal.viewers.InitialSelectionProvider;
import org.eclipse.wst.server.ui.internal.wizard.ClosableWizardDialog;
import org.eclipse.wst.server.ui.internal.wizard.TaskWizard;
@@ -58,7 +60,7 @@
// server UI plugin id
public static final String PLUGIN_ID = "org.eclipse.wst.server.ui";
-
+
protected static final String EXTENSION_SERVER_IMAGES = "serverImages";
private static final String EXTENSION_WIZARD_FRAGMENTS = "wizardFragments";
public static final String EXTENSION_EDITOR_PAGES = "editorPages";
@@ -856,4 +858,31 @@
}
return new Object[] { launchableAdapter, launchable };
}
+
+ public static Object[] adaptLabelChangeObjects(Object[] obj) {
+ if (obj == null)
+ return obj;
+
+ List list = new ArrayList();
+ int size = obj.length;
+ for (int i = 0; i < size; i++) {
+ if (obj[i] instanceof IModule) {
+ list.add(obj[i]);
+ } else if (obj[i] instanceof IServer) {
+ list.add(obj[i]);
+ } else if (obj[i] instanceof ModuleServer) {
+ list.add(obj[i]);
+ } else if (obj[i] instanceof IProject) {
+ IProject proj = (IProject) obj[i];
+ IModule[] m = ServerUtil.getModules(proj);
+ int size2 = m.length;
+ for (int j = 0; j < size2; j++)
+ list.add(m[j]);
+ }
+ }
+
+ Object[] o = new Object[list.size()];
+ list.toArray(o);
+ return o;
+ }
}
\ No newline at end of file
diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/servers/ServerTableLabelProvider.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/servers/ServerTableLabelProvider.java
index 7947466..22c1115 100644
--- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/servers/ServerTableLabelProvider.java
+++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/servers/ServerTableLabelProvider.java
@@ -145,7 +145,13 @@
if (ms.module == null)
return "";
int size = ms.module.length;
- return ms.module[size - 1].getName();
+ String name = ms.module[size - 1].getName();
+ if (decorator != null) {
+ String dec = decorator.decorateText(name, ms);
+ if (dec != null)
+ return dec;
+ }
+ return name;
} else if (columnIndex == 1) {
if (ms.server == null)
return "";
diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/servers/ServerTableViewer.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/servers/ServerTableViewer.java
index 86729d1..000827b 100644
--- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/servers/ServerTableViewer.java
+++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/servers/ServerTableViewer.java
@@ -11,8 +11,10 @@
package org.eclipse.wst.server.ui.internal.view.servers;
import java.util.ArrayList;
+import java.util.Iterator;
import java.util.List;
+import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.jface.viewers.*;
@@ -22,7 +24,9 @@
import org.eclipse.wst.server.ui.internal.Trace;
import org.eclipse.swt.events.DisposeEvent;
import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Item;
import org.eclipse.swt.widgets.Tree;
+import org.eclipse.swt.widgets.Widget;
import org.eclipse.ui.IActionBars;
import org.eclipse.ui.actions.ActionFactory;
/**
@@ -231,6 +235,7 @@
if (obj == null)
refresh(true);
else {
+ obj = adaptLabelChangeObjects(obj);
int size = obj.length;
for (int i = 0; i < size; i++)
refresh(obj[i], true);
@@ -238,7 +243,21 @@
}
});
setLabelProvider(labelProvider);
- setComparator(new ViewerComparator());
+ setComparator(new ViewerComparator() {
+ public int compare(Viewer viewer, Object e1, Object e2) {
+ if (e1 instanceof IServer && e2 instanceof IServer) {
+ IServer s1 = (IServer) e1;
+ IServer s2 = (IServer) e2;
+ return (s1.getName().compareTo(s2.getName()));
+ } else if (e1 instanceof ModuleServer && e2 instanceof ModuleServer) {
+ ModuleServer s1 = (ModuleServer) e1;
+ ModuleServer s2 = (ModuleServer) e2;
+ return (s1.module[s1.module.length - 1].getName().compareTo(s2.module[s2.module.length - 1].getName()));
+ }
+
+ return super.compare(viewer, e1, e2);
+ }
+ });
setInput(ROOT);
@@ -303,6 +322,58 @@
this.setSelection(new StructuredSelection(getTree().getItem(0).getData()));
}
+ protected Object[] adaptLabelChangeObjects(Object[] obj) {
+ if (obj == null)
+ return obj;
+
+ List list = new ArrayList();
+ int size = obj.length;
+ for (int i = 0; i < size; i++) {
+ if (obj[i] instanceof IModule) {
+ list.add(obj[i]);
+ } else if (obj[i] instanceof IServer) {
+ list.add(obj[i]);
+ } else if (obj[i] instanceof ModuleServer) {
+ list.add(obj[i]);
+ } else if (obj[i] instanceof IProject) {
+ IProject proj = (IProject) obj[i];
+
+ List list2 = new ArrayList();
+ getTreeChildren(list2, view.treeTable);
+
+ Iterator iterator = list2.iterator();
+ while (iterator.hasNext()) {
+ Object o = iterator.next();
+ if (o instanceof ModuleServer) {
+ ModuleServer ms = (ModuleServer) o;
+ if (proj.equals(ms.module[ms.module.length - 1].getProject()))
+ list.add(ms);
+ }
+ }
+ }
+ }
+
+ Object[] o = new Object[list.size()];
+ list.toArray(o);
+ return o;
+ }
+
+ private void getTreeChildren(List list, Widget widget) {
+ Item[] items = getChildren(widget);
+ for (int i = 0; i < items.length; i++) {
+ Item item = items[i];
+ Object data = item.getData();
+ if (data != null)
+ list.add(data);
+
+ if (getExpanded(item)) {
+ // only recurse if it is expanded - if
+ // not then the children aren't visible
+ getTreeChildren(list, item);
+ }
+ }
+ }
+
protected void addListeners() {
serverResourceListener = new IServerLifecycleListener() {
public void serverAdded(IServer server) {
diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/RuntimeComposite.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/RuntimeComposite.java
index 5750535..b4e0a18 100644
--- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/RuntimeComposite.java
+++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/RuntimeComposite.java
@@ -22,6 +22,7 @@
import org.eclipse.wst.server.core.IRuntime;
import org.eclipse.wst.server.core.IRuntimeWorkingCopy;
import org.eclipse.wst.server.ui.internal.Messages;
+import org.eclipse.wst.server.ui.internal.ServerUIPlugin;
/**
*
*/
@@ -103,6 +104,7 @@
if (obj == null)
tableViewer.refresh(true);
else {
+ obj = ServerUIPlugin.adaptLabelChangeObjects(obj);
int size = obj.length;
for (int i = 0; i < size; i++)
tableViewer.refresh(obj[i], true);
diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/RuntimeTypeComposite.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/RuntimeTypeComposite.java
index 1373a41..e193c07 100644
--- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/RuntimeTypeComposite.java
+++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/RuntimeTypeComposite.java
@@ -16,6 +16,7 @@
import org.eclipse.wst.server.core.IRuntimeType;
import org.eclipse.wst.server.core.internal.ServerPlugin;
import org.eclipse.wst.server.ui.internal.Messages;
+import org.eclipse.wst.server.ui.internal.ServerUIPlugin;
import org.eclipse.wst.server.ui.internal.extension.ExtensionUtility;
/**
*
@@ -53,6 +54,7 @@
if (obj == null)
treeViewer.refresh(true);
else {
+ obj = ServerUIPlugin.adaptLabelChangeObjects(obj);
int size = obj.length;
for (int i = 0; i < size; i++)
treeViewer.refresh(obj[i], true);
diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/ServerComposite.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/ServerComposite.java
index a660be7..737279e 100644
--- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/ServerComposite.java
+++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/ServerComposite.java
@@ -22,6 +22,7 @@
import org.eclipse.wst.server.core.IModule;
import org.eclipse.wst.server.core.IServer;
import org.eclipse.wst.server.ui.internal.Messages;
+import org.eclipse.wst.server.ui.internal.ServerUIPlugin;
/**
*
*/
@@ -58,6 +59,7 @@
if (obj == null)
treeViewer.refresh(true);
else {
+ obj = ServerUIPlugin.adaptLabelChangeObjects(obj);
int size = obj.length;
for (int i = 0; i < size; i++)
treeViewer.refresh(obj[i], true);
diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/ServerTypeComposite.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/ServerTypeComposite.java
index e5bf6bd..43283c6 100644
--- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/ServerTypeComposite.java
+++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/ServerTypeComposite.java
@@ -23,6 +23,7 @@
import org.eclipse.wst.server.core.IServerType;
import org.eclipse.wst.server.core.internal.ServerPlugin;
import org.eclipse.wst.server.ui.internal.Messages;
+import org.eclipse.wst.server.ui.internal.ServerUIPlugin;
import org.eclipse.wst.server.ui.internal.extension.ExtensionUtility;
/**
*
@@ -58,6 +59,7 @@
if (obj == null)
treeViewer.refresh(true);
else {
+ obj = ServerUIPlugin.adaptLabelChangeObjects(obj);
int size = obj.length;
for (int i = 0; i < size; i++)
treeViewer.refresh(obj[i], true);
diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/ExtensionWizard.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/ExtensionWizard.java
index 4162e0e..229f75a 100644
--- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/ExtensionWizard.java
+++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/ExtensionWizard.java
@@ -36,7 +36,10 @@
*/
public class ExtensionWizard extends TaskWizard {
/**
- * NewInstallableServerWizard constructor comment.
+ * Create a new ExtensionWizard.
+ *
+ * @param title the wizard title
+ * @param message the description message
*/
public ExtensionWizard(String title, String message) {
super(title, new WizardFragment() {
diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/page/ModifyModulesComposite.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/page/ModifyModulesComposite.java
index 214a230..eff24c6 100644
--- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/page/ModifyModulesComposite.java
+++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/page/ModifyModulesComposite.java
@@ -31,7 +31,7 @@
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.viewers.ViewerSorter;
+import org.eclipse.jface.viewers.ViewerComparator;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
@@ -423,7 +423,17 @@
});
availableTreeViewer.setLabelProvider(labelProvider);
availableTreeViewer.setContentProvider(new AvailableContentProvider());
- availableTreeViewer.setSorter(new ViewerSorter());
+ availableTreeViewer.setComparator(new ViewerComparator() {
+ public int compare(Viewer viewer, Object e1, Object e2) {
+ if (e1 instanceof ModuleServer && e2 instanceof ModuleServer) {
+ ModuleServer s1 = (ModuleServer) e1;
+ ModuleServer s2 = (ModuleServer) e2;
+ return (s1.module[s1.module.length - 1].getName().compareTo(s2.module[s2.module.length - 1].getName()));
+ }
+
+ return super.compare(viewer, e1, e2);
+ }
+ });
availableTreeViewer.setInput("root");
availableTreeViewer.addSelectionChangedListener(new ISelectionChangedListener() {
@@ -511,7 +521,17 @@
});
deployedTreeViewer.setLabelProvider(labelProvider);
deployedTreeViewer.setContentProvider(new DeployedContentProvider());
- deployedTreeViewer.setSorter(new ViewerSorter());
+ deployedTreeViewer.setComparator(new ViewerComparator() {
+ public int compare(Viewer viewer, Object e1, Object e2) {
+ if (e1 instanceof ModuleServer && e2 instanceof ModuleServer) {
+ ModuleServer s1 = (ModuleServer) e1;
+ ModuleServer s2 = (ModuleServer) e2;
+ return (s1.module[s1.module.length - 1].getName().compareTo(s2.module[s2.module.length - 1].getName()));
+ }
+
+ return super.compare(viewer, e1, e2);
+ }
+ });
deployedTreeViewer.setInput("root");
deployedTreeViewer.addSelectionChangedListener(new ISelectionChangedListener() {