diff options
145 files changed, 2249 insertions, 1734 deletions
diff --git a/plugins/org.eclipse.jst.server.core/sjavacore/org/eclipse/jst/server/core/ClasspathRuntimeTargetHandler.java b/plugins/org.eclipse.jst.server.core/sjavacore/org/eclipse/jst/server/core/ClasspathRuntimeTargetHandler.java index 90fc3566a..8ab327498 100644 --- a/plugins/org.eclipse.jst.server.core/sjavacore/org/eclipse/jst/server/core/ClasspathRuntimeTargetHandler.java +++ b/plugins/org.eclipse.jst.server.core/sjavacore/org/eclipse/jst/server/core/ClasspathRuntimeTargetHandler.java @@ -22,15 +22,33 @@ import org.eclipse.jdt.core.IClasspathEntry; import org.eclipse.jdt.core.IJavaProject; import org.eclipse.jdt.core.JavaCore; import org.eclipse.jdt.launching.JavaRuntime; +import org.eclipse.jst.server.core.internal.IMemento; import org.eclipse.jst.server.core.internal.JavaServerPlugin; import org.eclipse.jst.server.core.internal.RuntimeClasspathContainer; import org.eclipse.jst.server.core.internal.Trace; +import org.eclipse.jst.server.core.internal.XMLMemento; import org.eclipse.wst.server.core.IRuntime; import org.eclipse.wst.server.core.model.RuntimeTargetHandlerDelegate; /** + * A runtime target handler that supports changing the classpath of the + * project by adding one or more classpath containers. Runtime providers + * can extend this class and implement the abstract methods to provide + * the correct build path for their runtime type. * + * @since 1.0 */ public abstract class ClasspathRuntimeTargetHandler extends RuntimeTargetHandlerDelegate { + + class SourceAttachmentUpdate { + String runtimeId; + String id; + IPath entry; + IPath sourceAttachmentPath; + IPath sourceAttachmentRootPath; + } + + protected List sourceAttachments; + /* (non-Javadoc) * @see org.eclipse.wst.server.core.model.IRuntimeTargetDelegate#setRuntimeTarget(org.eclipse.core.resources.IProject, org.eclipse.wst.server.core.IRuntime) */ @@ -321,14 +339,44 @@ public abstract class ClasspathRuntimeTargetHandler extends RuntimeTargetHandler * <code>new String[] { "id1", "id2" }</code> * </p> * - * @param runtime - * @return + * @return an array of classpath entry ids */ public String[] getClasspathEntryIds() { return new String[1]; } /** + * Request that the classpath container for the given runtime and id be updated + * with the given classpath container entries. + * + * @param runtime + * @param id + * @param entries + */ + public void requestClasspathContainerUpdate(IRuntime runtime, String id, IClasspathEntry[] entries) { + // default behaviour is to save the source path entries + if (runtime == null || entries == null) + return; + + // find the source attachments + sourceAttachments = new ArrayList(); + + int size = entries.length; + for (int i = 0; i < size; i++) { + if (entries[i].getSourceAttachmentPath() != null) { + SourceAttachmentUpdate sau = new SourceAttachmentUpdate(); + sau.runtimeId = runtime.getId(); + sau.id = id; + sau.entry = entries[i].getPath(); + sau.sourceAttachmentPath = entries[i].getSourceAttachmentPath(); + sau.sourceAttachmentRootPath = entries[i].getSourceAttachmentRootPath(); + sourceAttachments.add(sau); + } + } + save(); + } + + /** * Returns the classpath container label for the given runtime and the given * classpath container id (returned from getClasspathEntryIds()). This method * must not return null. @@ -339,6 +387,95 @@ public abstract class ClasspathRuntimeTargetHandler extends RuntimeTargetHandler */ public abstract String getClasspathContainerLabel(IRuntime runtime, String id); + public IClasspathEntry[] resolveClasspathContainerImpl(IRuntime runtime, String id) { + IClasspathEntry[] entries = resolveClasspathContainer(runtime, id); + + if (entries == null) + entries = new IClasspathEntry[0]; + + if (sourceAttachments == null) + load(); + + int size = entries.length; + int size2 = sourceAttachments.size(); + for (int i = 0; i < size; i++) { + for (int j = 0; j < size2; j++) { + SourceAttachmentUpdate sau = (SourceAttachmentUpdate) sourceAttachments.get(j); + if ((id != null && sau.id.equals(id)) || (id == null && sau.id == null)) { + if (sau.runtimeId.equals(runtime.getId()) && sau.entry.equals(entries[i].getPath())) { + entries[i] = JavaCore.newLibraryEntry(entries[i].getPath(), sau.sourceAttachmentPath, sau.sourceAttachmentRootPath); + } + } + } + } + + return entries; + } + + protected void save() { + if (sourceAttachments == null) + return; + String id = getRuntimeTargetHandler().getId(); + String filename = JavaServerPlugin.getInstance().getStateLocation().append(id + ".xml").toOSString(); + try { + XMLMemento memento = XMLMemento.createWriteRoot("classpath"); + + Iterator iterator = sourceAttachments.iterator(); + while (iterator.hasNext()) { + SourceAttachmentUpdate sau = (SourceAttachmentUpdate) iterator.next(); + IMemento child = memento.createChild("source-attachment"); + child.putString("runtime-id", sau.runtimeId); + if (sau.id != null) + child.putString("id", sau.id); + if (sau.entry != null) + child.putString("entry", sau.entry.toPortableString()); + if (sau.sourceAttachmentPath != null) + child.putString("source-attachment-path", sau.sourceAttachmentPath.toPortableString()); + if (sau.sourceAttachmentRootPath != null) + child.putString("source-attachment-root-path", sau.sourceAttachmentRootPath.toPortableString()); + } + + memento.saveToFile(filename); + } catch (Exception e) { + Trace.trace(Trace.SEVERE, "Error saving source path info", e); + } + } + + protected void load() { + String id = getRuntimeTargetHandler().getId(); + String filename = JavaServerPlugin.getInstance().getStateLocation().append(id + ".xml").toOSString(); + + sourceAttachments = new ArrayList(); + try { + IMemento memento = XMLMemento.loadMemento(filename); + + IMemento[] children = memento.getChildren("source-attachment"); + int size = children.length; + + for (int i = 0; i < size; i++) { + try { + SourceAttachmentUpdate sau = new SourceAttachmentUpdate(); + sau.runtimeId = children[i].getString("runtime-id"); + sau.id = children[i].getString("id"); + String temp = children[i].getString("entry"); + if (temp != null) + sau.entry = new Path(temp); + temp = children[i].getString("source-attachment-path"); + if (temp != null) + sau.sourceAttachmentPath = new Path(temp); + temp = children[i].getString("source-attachment-root-path"); + if (temp != null) + sau.sourceAttachmentRootPath = new Path(temp); + sourceAttachments.add(sau); + } catch (Exception e) { + Trace.trace(Trace.WARNING, "Could not load monitor: " + e); + } + } + } catch (Exception e) { + Trace.trace(Trace.WARNING, "Could not load source path info: " + e.getMessage()); + } + } + /** * Resolves (creates the classpath entries for) the classpath container with * the given runtime and the given classpath container id (returned from diff --git a/plugins/org.eclipse.jst.server.core/sjavacore/org/eclipse/jst/server/core/WebResource.java b/plugins/org.eclipse.jst.server.core/sjavacore/org/eclipse/jst/server/core/WebResource.java deleted file mode 100644 index 8afbb0a11..000000000 --- a/plugins/org.eclipse.jst.server.core/sjavacore/org/eclipse/jst/server/core/WebResource.java +++ /dev/null @@ -1,46 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2005 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 - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.server.core; - -import org.eclipse.core.runtime.IPath; - -import org.eclipse.wst.server.core.IModule; -import org.eclipse.wst.server.core.IModuleArtifact; -/** - * - */ -public class WebResource implements IModuleArtifact { - public static final String ID = "org.eclipse.jst.server.j2ee.webresource"; - - private IModule module; - private IPath path; - - public WebResource(IModule module, IPath path) { - this.module = module; - this.path = path; - } - - public String getId() { - return ID; - } - - public IModule getModule() { - return module; - } - - public IPath getPath() { - return path; - } - - public String toString() { - return "WebResource [module=" + module + ", path=" + path + "]"; - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.server.core/sjavacore/org/eclipse/jst/server/core/internal/IMemento.java b/plugins/org.eclipse.jst.server.core/sjavacore/org/eclipse/jst/server/core/internal/IMemento.java new file mode 100644 index 000000000..6035548f4 --- /dev/null +++ b/plugins/org.eclipse.jst.server.core/sjavacore/org/eclipse/jst/server/core/internal/IMemento.java @@ -0,0 +1,189 @@ +/********************************************************************** + * Copyright (c) 2003, 2005 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 + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - Initial API and implementation + **********************************************************************/ +package org.eclipse.jst.server.core.internal; + +import java.util.List; +/** + * Interface to a memento used for saving the important state of an object + * in a form that can be persisted in the file system. + * <p> + * Mementos were designed with the following requirements in mind: + * <ol> + * <li>Certain objects need to be saved and restored across platform sessions. + * </li> + * <li>When an object is restored, an appropriate class for an object might not + * be available. It must be possible to skip an object in this case.</li> + * <li>When an object is restored, the appropriate class for the object may be + * different from the one when the object was originally saved. If so, the + * new class should still be able to read the old form of the data.</li> + * </ol> + * </p> + * <p> + * Mementos meet these requirements by providing support for storing a + * mapping of arbitrary string keys to primitive values, and by allowing + * mementos to have other mementos as children (arranged into a tree). + * A robust external storage format based on XML is used. + * </p><p> + * The key for an attribute may be any alpha numeric value. However, the + * value of <code>TAG_ID</code> is reserved for internal use. + * </p><p> + * This interface is not intended to be implemented by clients. + * </p> + */ +public interface IMemento { + /** + * Special reserved key used to store the memento id + * (value <code>"org.eclipse.ui.id"</code>). + * + * @see #getId + */ + public static final String TAG_ID = "IMemento.internal.id"; //$NON-NLS-1$ + + /** + * Creates a new child of this memento with the given type. + * <p> + * The <code>getChild</code> and <code>getChildren</code> methods + * are used to retrieve children of a given type. + * </p> + * + * @param type the type + * @return a new child memento + * @see #getChild + * @see #getChildren + */ + public IMemento createChild(String type); + + /** + * Creates a new child of this memento with the given type and id. + * The id is stored in the child memento (using a special reserved + * key, <code>TAG_ID</code>) and can be retrieved using <code>getId</code>. + * <p> + * The <code>getChild</code> and <code>getChildren</code> methods + * are used to retrieve children of a given type. + * </p> + * + * @param type the type + * @param id the child id + * @return a new child memento with the given type and id + * @see #getId + */ + public IMemento createChild(String type, String id); + + /** + * Returns the first child with the given type id. + * + * @param type the type id + * @return the first child with the given type + */ + public IMemento getChild(String type); + + /** + * Returns all children with the given type id. + * + * @param type the type id + * @return the list of children with the given type + */ + public IMemento[] getChildren(String type); + + /** + * Returns the floating point value of the given key. + * + * @param key the key + * @return the value, or <code>null</code> if the key was not found or was found + * but was not a floating point number + */ + public Float getFloat(String key); + + /** + * Returns the id for this memento. + * + * @return the memento id, or <code>null</code> if none + * @see #createChild(java.lang.String,java.lang.String) + */ + public String getId(); + + /** + * Returns the name for this memento. + * + * @return the memento name, or <code>null</code> if none + * @see #createChild(java.lang.String,java.lang.String) + */ + public String getName(); + + /** + * Returns the integer value of the given key. + * + * @param key the key + * @return the value, or <code>null</code> if the key was not found or was found + * but was not an integer + */ + public Integer getInteger(String key); + + /** + * Returns the string value of the given key. + * + * @param key the key + * @return the value, or <code>null</code> if the key was not found or was found + * but was not an integer + */ + public String getString(String key); + + /** + * Returns the boolean value of the given key. + * + * @param key the key + * @return the value, or <code>null</code> if the key was not found or was found + * but was not a boolean + */ + public Boolean getBoolean(String key); + + public List getNames(); + + /** + * Sets the value of the given key to the given floating point number. + * + * @param key the key + * @param value the value + */ + public void putFloat(String key, float value); + + /** + * Sets the value of the given key to the given integer. + * + * @param key the key + * @param value the value + */ + public void putInteger(String key, int value); + + /** + * Sets the value of the given key to the given boolean value. + * + * @param key the key + * @param value the value + */ + public void putBoolean(String key, boolean value); + + /** + * Copy the attributes and children from <code>memento</code> + * to the receiver. + * + * @param memento the IMemento to be copied. + */ + public void putMemento(IMemento memento); + + /** + * Sets the value of the given key to the given string. + * + * @param key the key + * @param value the value + */ + public void putString(String key, String value); +}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.server.core/sjavacore/org/eclipse/jst/server/core/internal/RuntimeClasspathContainer.java b/plugins/org.eclipse.jst.server.core/sjavacore/org/eclipse/jst/server/core/internal/RuntimeClasspathContainer.java index 5232e75ae..79c57e815 100644 --- a/plugins/org.eclipse.jst.server.core/sjavacore/org/eclipse/jst/server/core/internal/RuntimeClasspathContainer.java +++ b/plugins/org.eclipse.jst.server.core/sjavacore/org/eclipse/jst/server/core/internal/RuntimeClasspathContainer.java @@ -41,7 +41,7 @@ public class RuntimeClasspathContainer implements IClasspathContainer { public IClasspathEntry[] getClasspathEntries() { IClasspathEntry[] entries = null; if (delegate != null && runtime != null) - entries = delegate.resolveClasspathContainer(runtime, id); + entries = delegate.resolveClasspathContainerImpl(runtime, id); if (entries == null) return new IClasspathEntry[0]; diff --git a/plugins/org.eclipse.jst.server.core/sjavacore/org/eclipse/jst/server/core/internal/RuntimeClasspathContainerInitializer.java b/plugins/org.eclipse.jst.server.core/sjavacore/org/eclipse/jst/server/core/internal/RuntimeClasspathContainerInitializer.java index cceabc0ef..3091ecaea 100644 --- a/plugins/org.eclipse.jst.server.core/sjavacore/org/eclipse/jst/server/core/internal/RuntimeClasspathContainerInitializer.java +++ b/plugins/org.eclipse.jst.server.core/sjavacore/org/eclipse/jst/server/core/internal/RuntimeClasspathContainerInitializer.java @@ -13,7 +13,7 @@ package org.eclipse.jst.server.core.internal; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IPath; import org.eclipse.jdt.core.*; -import org.eclipse.jst.server.core.ClasspathRuntimeTargetHandler; +import org.eclipse.jst.server.core.*; import org.eclipse.wst.server.core.IRuntime; import org.eclipse.wst.server.core.IRuntimeTargetHandler; import org.eclipse.wst.server.core.ServerCore; @@ -21,7 +21,6 @@ import org.eclipse.wst.server.core.ServerCore; * */ public class RuntimeClasspathContainerInitializer extends ClasspathContainerInitializer { - /* (non-Javadoc) * @see org.eclipse.jdt.core.ClasspathContainerInitializer#initialize(org.eclipse.core.runtime.IPath, org.eclipse.jdt.core.IJavaProject) */ @@ -46,11 +45,53 @@ public class RuntimeClasspathContainerInitializer extends ClasspathContainerInit } } } - - /** + + /* (non-Javadoc) * @see org.eclipse.jdt.core.ClasspathContainerInitializer#getDescription(org.eclipse.core.runtime.IPath, org.eclipse.jdt.core.IJavaProject) */ public String getDescription(IPath containerPath, IJavaProject project) { return JavaServerPlugin.getResource("%classpathContainerDescription"); } + + /* (non-Javadoc) + * @see org.eclipse.jdt.core.ClasspathContainerInitializer#canUpdateClasspathContainer(org.eclipse.core.runtime.IPath, org.eclipse.jdt.core.IJavaProject) + */ + public boolean canUpdateClasspathContainer(IPath containerPath, IJavaProject project) { + return true; + } + + /* (non-Javadoc) + * @see org.eclipse.jdt.core.ClasspathContainerInitializer#requestClasspathContainerUpdate(org.eclipse.core.runtime.IPath, org.eclipse.jdt.core.IJavaProject, org.eclipse.jdt.core.IClasspathContainer) + */ + public void requestClasspathContainerUpdate(IPath containerPath, IJavaProject project, IClasspathContainer containerSuggestion) throws CoreException { + if (containerPath.segmentCount() > 0) { + if (containerPath.segment(0).equals(RuntimeClasspathContainer.SERVER_CONTAINER)) { + ClasspathRuntimeTargetHandler crth = null; + IRuntime runtime = null; + String id = ""; + if (containerPath.segmentCount() > 2) { + IRuntimeTargetHandler handler = ServerCore.findRuntimeTargetHandler(containerPath.segment(1)); + if (handler != null) { + crth = (ClasspathRuntimeTargetHandler) handler.getAdapter(ClasspathRuntimeTargetHandler.class); + } + String runtimeId = containerPath.segment(2); + if (runtimeId != null) + runtime = ServerCore.findRuntime(runtimeId); + if (containerPath.segmentCount() > 3) + id = containerPath.segment(3); + crth.requestClasspathContainerUpdate(runtime, id, containerSuggestion.getClasspathEntries()); + } + } + } + } + + /* (non-Javadoc) + * @see org.eclipse.jdt.core.ClasspathContainerInitializer#getComparisonID(org.eclipse.core.runtime.IPath, org.eclipse.jdt.core.IJavaProject) + */ + public Object getComparisonID(IPath containerPath, IJavaProject project) { + if (containerPath == null) + return null; + + return containerPath.toPortableString(); + } }
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.server.core/sjavacore/org/eclipse/jst/server/core/internal/XMLMemento.java b/plugins/org.eclipse.jst.server.core/sjavacore/org/eclipse/jst/server/core/internal/XMLMemento.java new file mode 100644 index 000000000..098a629bc --- /dev/null +++ b/plugins/org.eclipse.jst.server.core/sjavacore/org/eclipse/jst/server/core/internal/XMLMemento.java @@ -0,0 +1,453 @@ +/******************************************************************************* + * Copyright (c) 2003, 2005 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 + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - Initial API and implementation + *******************************************************************************/ +package org.eclipse.jst.server.core.internal; + +import java.io.*; +import java.util.*; +import java.net.URL; +import org.w3c.dom.*; +import org.xml.sax.*; + +import javax.xml.parsers.*; +import javax.xml.transform.*; +import javax.xml.transform.dom.DOMSource; +import javax.xml.transform.stream.StreamResult; +/** + * A Memento is a class independent container for persistence + * info. It is a reflection of 3 storage requirements. + * + * 1) We need the ability to persist an object and restore it. + * 2) The class for an object may be absent. If so we would + * like to skip the object and keep reading. + * 3) The class for an object may change. If so the new class + * should be able to read the old persistence info. + * + * We could ask the objects to serialize themselves into an + * ObjectOutputStream, DataOutputStream, or Hashtable. However + * all of these approaches fail to meet the second requirement. + * + * Memento supports binary persistance with a version ID. + */ +public final class XMLMemento implements IMemento { + private Document factory; + private Element element; + + /** + * Answer a memento for the document and element. For simplicity + * you should use createReadRoot and createWriteRoot to create the initial + * mementos on a document. + */ + public XMLMemento(Document doc, Element el) { + factory = doc; + element = el; + } + + /** + * @see IMemento. + */ + public IMemento createChild(String type) { + Element child = factory.createElement(type); + element.appendChild(child); + return new XMLMemento(factory, child); + } + + /** + * @see IMemento. + */ + public IMemento createChild(String type, String id) { + Element child = factory.createElement(type); + child.setAttribute(TAG_ID, id); + element.appendChild(child); + return new XMLMemento(factory, child); + } + + /** + * Create a Document from a Reader and answer a root memento for reading + * a document. + */ + protected static XMLMemento createReadRoot(Reader reader) { + Document document = null; + try { + DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); + DocumentBuilder parser = factory.newDocumentBuilder(); + document = parser.parse(new InputSource(reader)); + Node node = document.getFirstChild(); + if (node instanceof Element) + return new XMLMemento(document, (Element) node); + } catch (Exception e) { + // ignore + } finally { + try { + reader.close(); + } catch (Exception e) { + // ignore + } + } + return null; + } + + /** + * Answer a root memento for writing a document. + */ + public static XMLMemento createWriteRoot(String type) { + Document document; + try { + document = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument(); + Element element = document.createElement(type); + document.appendChild(element); + return new XMLMemento(document, element); + } catch (ParserConfigurationException e) { + throw new Error(e); + } + } + + /** + * @see IMemento. + */ + public IMemento getChild(String type) { + // Get the nodes. + NodeList nodes = element.getChildNodes(); + int size = nodes.getLength(); + if (size == 0) + return null; + + // Find the first node which is a child of this node. + for (int nX = 0; nX < size; nX ++) { + Node node = nodes.item(nX); + if (node instanceof Element) { + Element element2 = (Element)node; + if (element2.getNodeName().equals(type)) + return new XMLMemento(factory, element2); + } + } + + // A child was not found. + return null; + } + + /** + * @see IMemento. + */ + public IMemento [] getChildren(String type) { + // Get the nodes. + NodeList nodes = element.getChildNodes(); + int size = nodes.getLength(); + if (size == 0) + return new IMemento[0]; + + // Extract each node with given type. + ArrayList list = new ArrayList(size); + for (int nX = 0; nX < size; nX ++) { + Node node = nodes.item(nX); + if (node instanceof Element) { + Element element2 = (Element)node; + if (element2.getNodeName().equals(type)) + list.add(element2); + } + } + + // Create a memento for each node. + size = list.size(); + IMemento [] results = new IMemento[size]; + for (int x = 0; x < size; x ++) { + results[x] = new XMLMemento(factory, (Element)list.get(x)); + } + return results; + } + + /** + * Return the contents of this memento as a byte array. + * + * @return byte[] + */ + public byte[] getContents() throws IOException { + ByteArrayOutputStream out = new ByteArrayOutputStream(); + save(out); + return out.toByteArray(); + } + + /** + * Returns an input stream for writing to the disk with a local locale. + * + * @return java.io.InputStream + */ + public InputStream getInputStream() throws IOException { + ByteArrayOutputStream out = new ByteArrayOutputStream(); + save(out); + return new ByteArrayInputStream(out.toByteArray()); + } + + /** + * @see IMemento. + */ + public Float getFloat(String key) { + Attr attr = element.getAttributeNode(key); + if (attr == null) + return null; + String strValue = attr.getValue(); + try { + return new Float(strValue); + } catch (NumberFormatException e) { + return null; + } + } + + /** + * @see IMemento. + */ + public String getId() { + return element.getAttribute(TAG_ID); + } + + /** + * @see IMemento. + */ + public String getName() { + return element.getNodeName(); + } + + /** + * @see IMemento. + */ + public Integer getInteger(String key) { + Attr attr = element.getAttributeNode(key); + if (attr == null) + return null; + String strValue = attr.getValue(); + try { + return new Integer(strValue); + } catch (NumberFormatException e) { + return null; + } + } + + /** + * @see IMemento. + */ + public String getString(String key) { + Attr attr = element.getAttributeNode(key); + if (attr == null) + return null; + return attr.getValue(); + } + + public List getNames() { + NamedNodeMap map = element.getAttributes(); + int size = map.getLength(); + List list = new ArrayList(); + for (int i = 0; i < size; i++) { + Node node = map.item(i); + String name = node.getNodeName(); + list.add(name); + } + return list; + } + + /** + * Loads a memento from the given filename. + * + * @param in java.io.InputStream + * @return org.eclipse.ui.IMemento + * @exception java.io.IOException + */ + public static IMemento loadMemento(InputStream in) { + return createReadRoot(new InputStreamReader(in)); + } + + /** + * Loads a memento from the given filename. + * + * @param in java.io.InputStream + * @return org.eclipse.ui.IMemento + * @exception java.io.IOException + */ + public static IMemento loadCorruptMemento(InputStream in) { + Document document = null; + try { + DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); + DocumentBuilder parser = factory.newDocumentBuilder(); + document = parser.parse(in); + Node node = document.getFirstChild(); + if (node instanceof Element) + return new XMLMemento(document, (Element) node); + } catch (Exception e) { + // ignore + } finally { + try { + in.close(); + } catch (Exception e) { + // ignore + } + } + return null; + } + + /** + * Loads a memento from the given filename. + * + * @param filename java.lang.String + * @return org.eclipse.ui.IMemento + * @exception java.io.IOException + */ + public static IMemento loadMemento(String filename) throws IOException { + return XMLMemento.createReadRoot(new FileReader(filename)); + } + + /** + * Loads a memento from the given filename. + * + * @param url java.net.URL + * @return org.eclipse.ui.IMemento + * @exception java.io.IOException + */ + public static IMemento loadMemento(URL url) throws IOException { + return XMLMemento.createReadRoot(new InputStreamReader(url.openStream())); + } + + /** + * @see IMemento. + */ + private void putElement(Element element2) { + NamedNodeMap nodeMap = element2.getAttributes(); + int size = nodeMap.getLength(); + for (int i = 0; i < size; i++){ + Attr attr = (Attr)nodeMap.item(i); + putString(attr.getName(),attr.getValue()); + } + + NodeList nodes = element2.getChildNodes(); + size = nodes.getLength(); + for (int i = 0; i < size; i ++) { + Node node = nodes.item(i); + if (node instanceof Element) { + XMLMemento child = (XMLMemento)createChild(node.getNodeName()); + child.putElement((Element)node); + } + } + } + + /** + * @see IMemento. + */ + public void putFloat(String key, float f) { + element.setAttribute(key, String.valueOf(f)); + } + + /** + * @see IMemento. + */ + public void putInteger(String key, int n) { + element.setAttribute(key, String.valueOf(n)); + } + + /** + * @see IMemento. + */ + public void putMemento(IMemento memento) { + XMLMemento xmlMemento = (XMLMemento) memento; + putElement(xmlMemento.element); + } + + /** + * @see IMemento. + */ + public void putString(String key, String value) { + if (value == null) + return; + element.setAttribute(key, value); + } + + /** + * Save this Memento to a Writer. + */ + public void save(Writer writer) throws IOException { + Result result = new StreamResult(writer); + Source source = new DOMSource(factory); + try { + Transformer transformer = TransformerFactory.newInstance().newTransformer(); + transformer.setOutputProperty(OutputKeys.INDENT, "yes"); + transformer.setOutputProperty(OutputKeys.METHOD, "xml"); + transformer.setOutputProperty("{http://xml.apache.org/xalan}indent-amount", "2"); + transformer.transform(source, result); + } catch (Exception e) { + throw (IOException) (new IOException().initCause(e)); + } + } + + /** + * Save this Memento to a Writer. + */ + public void save(OutputStream os) throws IOException { + Result result = new StreamResult(os); + Source source = new DOMSource(factory); + try { + Transformer transformer = TransformerFactory.newInstance().newTransformer(); + transformer.setOutputProperty(OutputKeys.INDENT, "yes"); + transformer.setOutputProperty(OutputKeys.METHOD, "xml"); + transformer.setOutputProperty("{http://xml.apache.org/xalan}indent-amount", "2"); + transformer.transform(source, result); + } catch (Exception e) { + throw (IOException) (new IOException().initCause(e)); + } + } + + /** + * Saves the memento to the given file. + * + * @param filename java.lang.String + * @exception java.io.IOException + */ + public void saveToFile(String filename) throws IOException { + Writer w = null; + try { + w = new FileWriter(filename); + save(w); + } catch (IOException e) { + throw e; + } catch (Exception e) { + throw new IOException(e.getLocalizedMessage()); + } finally { + if (w != null) { + try { + w.close(); + } catch (Exception e) { + // ignore + } + } + } + } + + public String saveToString() throws IOException { + ByteArrayOutputStream out = new ByteArrayOutputStream(); + save(out); + return out.toString("UTF-8"); + } + + /* + * @see IMemento#getBoolean(String) + */ + public Boolean getBoolean(String key) { + Attr attr = element.getAttributeNode(key); + if (attr == null) + return null; + String strValue = attr.getValue(); + if ("true".equalsIgnoreCase(strValue)) + return new Boolean(true); + return new Boolean(false); + } + + /* + * @see IMemento#putBoolean(String, boolean) + */ + public void putBoolean(String key, boolean value) { + element.setAttribute(key, value ? "true" : "false"); + } +}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/TomcatServer.java b/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/TomcatServer.java index d87596034..658475c8f 100644 --- a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/TomcatServer.java +++ b/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/TomcatServer.java @@ -18,6 +18,7 @@ import org.eclipse.core.runtime.*; import org.eclipse.jst.server.core.IWebModule; import org.eclipse.wst.server.core.*; +import org.eclipse.wst.server.core.internal.ServerMonitorManager; import org.eclipse.wst.server.core.model.*; /** * Generic Tomcat server. @@ -131,7 +132,7 @@ public class TomcatServer extends ServerDelegate implements ITomcatServer, ITomc String url = "http://localhost"; int port = config.getMainPort().getPort(); - port = ServerCore.getServerMonitorManager().getMonitoredPort(getServer(), port, "web"); + port = ServerMonitorManager.getInstance().getMonitoredPort(getServer(), port, "web"); if (port != 80) url += ":" + port; diff --git a/plugins/org.eclipse.wst.server.core/plugin.properties b/plugins/org.eclipse.wst.server.core/plugin.properties index e2a6a2629..932b6dce2 100644 --- a/plugins/org.eclipse.wst.server.core/plugin.properties +++ b/plugins/org.eclipse.wst.server.core/plugin.properties @@ -78,4 +78,8 @@ moduleTypeUnknown=Unknown module # null launchable nullLaunchableClient=Do nothing -nullLaunchableClientDescription=Do not launch anything after starting the server.
\ No newline at end of file +nullLaunchableClientDescription=Do not launch anything after starting the server. + +canStartOk=The server can be started. +canStartErrorState=The server cannot be started because it is current starting or stopping. +errorLaunchMode=The server does not support the given launch mode.
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/ILaunchable.java b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/ILaunchable.java index c60351564..1416df273 100644 --- a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/ILaunchable.java +++ b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/ILaunchable.java @@ -16,14 +16,9 @@ package org.eclipse.wst.server.core; * resource. Examples may include HTTP requests and JNDI names. * * [issue: rename to avoid confusion with debug.ui.ILaunchable] + * + * @since 1.0 */ public interface ILaunchable { - /** - * Returns the id of this launchable. Each known launchable has a distinct id. - * Ids are intended to be used internally as keys; they are not - * intended to be shown to end users. - * - * @return the launchable id - */ - public String getId(); + // no content }
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/IModule.java b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/IModule.java index b8347cfe8..d7011250d 100644 --- a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/IModule.java +++ b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/IModule.java @@ -12,8 +12,6 @@ package org.eclipse.wst.server.core; import org.eclipse.core.resources.IProject; import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; import org.eclipse.wst.server.core.model.IModuleListener; /** * A module is a unit of "content" that can be published to a @@ -66,66 +64,6 @@ public interface IModule extends IAdaptable { public String getId(); /** - * Validates this module. - * <p> - * [issue: Conjecture: Each different type of module prescribes - * legal arrangements of, and the significance of, the files within - * it. This would be spelled out in the spec for the particular - * module types. - * This validate operation is suppose to check the actual - * arrangement of files in this module to see whether they - * meet expectations. - * It's an open question as to how "strenuous" a check this - * is.] - * </p> - * <p> - * [issue: Old comment said: "If there is an error - * that should block the server from starting (e.g. major errors) - * it should be returned from this method. This method can also be used to - * return warning for such things as an open (and dirty) editor."] - * </p> - * <p> - * [issue: All existing implementations of this return null, - * which is illegal.] - * </p> - * <p> - * [issue: Old comment said: "Returns an IStatus that is used to determine if this object can - * be published to the server." Since the same module can - * be associated with any number of servers, "the server" is - * ill-defined.] - * </p> - * <p> - * [issue: Old comment said: "Should return an error if there - * is a major problem with the resources, or can be used to - * return warnings on unsaved files, etc." It is usually - * difficult in principle for core-level infrastructure to - * detect whether there are open editors with unsaved changes.] - * </p> - * - * @return a status object with code <code>IStatus.OK</code> if the given - * module is valid, otherwise a status object indicating what is - * wrong with it - */ - public IStatus validate(IProgressMonitor monitor); - - /** - * Returns the root resources of this module. All members - * belong to this module (as do their members, and so on). - * <p> - * [issue: What are the exact constraints on where these - * resources are located? - * Do they all have to be inside the workspace? - * Do they all have to be in the same project? - * When a folder is included, does that mean the entire - * subtree is published to server?] - * </p> - * - * @return the members of this module - * @throws CoreException [missing] - */ - //public IModuleResource[] members() throws CoreException; - - /** * Returns the displayable name for this module. * <p> * Note that this name is appropriate for the current locale. @@ -184,11 +122,4 @@ public interface IModule extends IAdaptable { * @param listener org.eclipse.wst.server.core.model.IModuleListener */ public void removeModuleListener(IModuleListener listener); - - /** - * Returns the child modules of this module. - * - * @return org.eclipse.wst.server.core.model.IModule[] - */ - public IModule[] getChildModules(IProgressMonitor monitor); }
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/IModuleArtifact.java b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/IModuleArtifact.java index 15c02235e..cb97452a4 100644 --- a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/IModuleArtifact.java +++ b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/IModuleArtifact.java @@ -17,6 +17,8 @@ package org.eclipse.wst.server.core; * Objects that provide an adapter of this type will be considered by the * contextual Run on Server launch support. * </p> + * + * @since 1.0 */ public interface IModuleArtifact { /** diff --git a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/IOptionalTask.java b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/IOptionalTask.java index 440d51ca3..8c1020809 100644 --- a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/IOptionalTask.java +++ b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/IOptionalTask.java @@ -11,6 +11,8 @@ package org.eclipse.wst.server.core; /** * An optional task. + * + * @since 1.0 */ public interface IOptionalTask extends ITask { public static final int TASK_UNNECESSARY = 0; diff --git a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/IProjectProperties.java b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/IProjectProperties.java index 4b3f288e7..75af19c3f 100644 --- a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/IProjectProperties.java +++ b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/IProjectProperties.java @@ -16,6 +16,9 @@ import org.eclipse.core.runtime.IProgressMonitor; * This interface holds information on the properties of a given project. * * <p>This interface is not intended to be implemented by clients.</p> + * + * @see IProjectPropertiesListener + * @since 1.0 */ public interface IProjectProperties { /** @@ -24,7 +27,8 @@ public interface IProjectProperties { * server is recreated or was in a closed project, etc. this method will return * the original value if it becomes available again) * - * @return org.eclipse.wst.server.core.IServer + * @return the current default server, or <code>null</code> if there is no + * default server */ public IServer getDefaultServer(); @@ -33,43 +37,60 @@ public interface IProjectProperties { * null to clear the setting. If there is a problem saving the file, a CoreException * will be thrown. * - * @param server org.eclipse.wst.server.model.IServer - * @param monitor org.eclipse.core.runtime.IProgressMonitor - * @throws org.eclipse.core.runtime.CoreException + * @param server the server to set the default server, or <code>null</code> + * to unset the default + * @param monitor a progress monitor, or <code>null</code> if progress + * reporting and cancellation are not desired + * @throws CoreException if there is a problem setting the default server */ public void setDefaultServer(IServer server, IProgressMonitor monitor) throws CoreException; /** * Returns the current runtime target for this project. * - * @return + * @return the current runtime target, or <code>null</code> if the project has + * no runtime target */ public IRuntime getRuntimeTarget(); /** * Sets the runtime target for the project. * - * @param target - * @param monitor + * @param runtime the runtime to use as the target, or <code>null</code> to + * unset the target + * @param monitor a progress monitor, or <code>null</code> if progress + * reporting and cancellation are not desired + * @throws CoreException if there is a problem setting the runtime target */ public void setRuntimeTarget(IRuntime runtime, IProgressMonitor monitor) throws CoreException; /** + * Returns <code>true</code> if this project can contain server artifacts, and + * <code>false</code> otherwise. * + * @return <code>true</code> if this project can contain server artifacts, and + * <code>false</code> otherwise */ - public boolean isServerProject(); + //public boolean isServerProject(); /** + * Sets whether the project can contain server resources. * - * @param b + * @param sp <code>true</code> to allow the project to contain server + * resources, or <code>false</code> to not allow the project to contain + * servers + * @param monitor a progress monitor, or <code>null</code> if progress + * reporting and cancellation are not desired + * @throws CoreException if there is a problem setting the server project */ - public void setServerProject(boolean b, IProgressMonitor monitor) throws CoreException; + //public void setServerProject(boolean sp, IProgressMonitor monitor) throws CoreException; /** * Adds a new project properties listener. * Has no effect if an identical listener is already registered. * - * @param listener + * @param listener the properties listener + * @see #removeProjectPropertiesListener(IProjectPropertiesListener) */ public void addProjectPropertiesListener(IProjectPropertiesListener listener); @@ -77,7 +98,8 @@ public interface IProjectProperties { * Removes an existing project properties listener. * Has no effect if the listener is not registered. * - * @param listener + * @param listener the properties listener + * @see #addProjectPropertiesListener(IProjectPropertiesListener) */ public void removeProjectPropertiesListener(IProjectPropertiesListener listener); }
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/IProjectPropertiesListener.java b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/IProjectPropertiesListener.java index 0f138214e..4418aa255 100644 --- a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/IProjectPropertiesListener.java +++ b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/IProjectPropertiesListener.java @@ -13,28 +13,35 @@ package org.eclipse.wst.server.core; import org.eclipse.core.resources.IProject; /** * A project properties listener. Fires events when the default server or - * runtime target changes. Note that this interface should be used for - * informational purposes only. If (e.g.) you have code that needs to respond - * to a specific runtime target, you should use the runtimeTargetHandler - * extension point. The extension point will allow your code to be automatically - * loaded when necessary (instead of having to preload and add a listener), - * will not cause unnecessary plugin loading, and will allow ordering of - * setting/unsetting the runtime target. + * runtime target changes. + * <p> + * This interface should be used for informational purposes only. If (e.g.) + * you have code that needs to respond to a specific runtime target, you should + * use the runtimeTargetHandler extension point. The extension point will allow + * your code to be automatically loaded when necessary (instead of having to + * preload and add a listener), will not cause unnecessary plugin loading, and + * will allow ordering of setting/unsetting the runtime target. + * </p> + * + * @see IProjectProperties + * @since 1.0 */ public interface IProjectPropertiesListener { /** * Fired when the default server for the project changes. * - * @param project org.eclipse.core.resources.IProject - * @param server org.eclipse.wst.server.core.IServer + * @param project the project that has changed + * @param server the new default server, or <code>null</code> if the default + * server has been removed */ public void defaultServerChanged(IProject project, IServer server); /** * Fired when the runtime target for the project changes. * - * @param project org.eclipse.core.resources.IProject - * @param server org.eclipse.wst.server.core.IRuntime + * @param project the project that has changed + * @param runtime the new runtime target, or <code>null</code> if the runtime + * target has been removed */ public void runtimeTargetChanged(IProject project, IRuntime runtime); }
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/IRuntime.java b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/IRuntime.java index 741e25a29..f9eea9b16 100644 --- a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/IRuntime.java +++ b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/IRuntime.java @@ -60,6 +60,7 @@ import org.eclipse.core.runtime.*; * likely to change significantly before the initial release.</it> * </p> * + * @see IRuntimeWorkingCopy * @since 1.0 */ public interface IRuntime extends IAdaptable { @@ -121,7 +122,8 @@ public interface IRuntime extends IAdaptable { /** * Returns true if the delegate has been loaded. * - * @return + * @return <code>true</code> if the delegate is loaded, and <code>false</code> + * otherwise */ public boolean isDelegateLoaded(); diff --git a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/IRuntimeLifecycleListener.java b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/IRuntimeLifecycleListener.java index d44ebe336..2d7a00974 100644 --- a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/IRuntimeLifecycleListener.java +++ b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/IRuntimeLifecycleListener.java @@ -11,6 +11,8 @@ package org.eclipse.wst.server.core; /** * Listener interface for runtime changes. + * + * @since 1.0 */ public interface IRuntimeLifecycleListener { /** diff --git a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/IRuntimeLocator.java b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/IRuntimeLocator.java index f5a4d5aaf..e82a8dd5d 100644 --- a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/IRuntimeLocator.java +++ b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/IRuntimeLocator.java @@ -16,9 +16,13 @@ import org.eclipse.core.runtime.IProgressMonitor; /** * A runtime locator provides the ability to locate or search for additional * runtimes of a particular type. + * <p> + * Runtime locators are found via ServerCore.getRuntimeLocators(). + * </p> * * <p>This interface is not intended to be implemented by clients.</p> * + * @see ServerCore * @since 1.0 */ public interface IRuntimeLocator { diff --git a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/IRuntimeTargetHandler.java b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/IRuntimeTargetHandler.java index 6c1de1153..ae92015c2 100644 --- a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/IRuntimeTargetHandler.java +++ b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/IRuntimeTargetHandler.java @@ -22,6 +22,8 @@ import org.eclipse.core.runtime.IProgressMonitor; * resources that can be created. * * <p>This interface is not intended to be implemented by clients.</p> + * + * @since 1.0 */ public interface IRuntimeTargetHandler extends IAdaptable { /** diff --git a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/IServer.java b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/IServer.java index 9dbca8bba..b3fcb3f8a 100644 --- a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/IServer.java +++ b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/IServer.java @@ -13,7 +13,6 @@ package org.eclipse.wst.server.core; import org.eclipse.core.runtime.*; import org.eclipse.debug.core.ILaunch; import org.eclipse.debug.core.ILaunchConfiguration; -import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; /** * Represents a server instance. Every server is an instance of a * particular, fixed server type. @@ -238,7 +237,7 @@ public interface IServer extends IServerAttributes { * @see #removeServerListener(IServerListener) */ public void addServerListener(IServerListener listener); - + /** * Removes the given server state listener from this server. Has no * effect if the listener is not registered. @@ -249,29 +248,13 @@ public interface IServer extends IServerAttributes { public void removeServerListener(IServerListener listener); /** - * Adds a publish listener to this server. - * Has no effect if an identical listener is already registered. - * - * @param listener org.eclipse.wst.server.core.model.IPublishListener - */ - public void addPublishListener(IPublishListener listener); - - /** - * Removes a publish listener from this server. - * Has no effect if the listener is not registered. - * - * @param listener org.eclipse.wst.server.core.model.IPublishListener - */ - public void removePublishListener(IPublishListener listener); - - /** * Returns whether this server is in a state that it can * be published to. * - * @return <code>true</code> if this server can be published to, - * and <code>false</code> otherwise + * @return a status object with code <code>IStatus.OK</code> if the server can + * be published to, otherwise a status object indicating what is wrong */ - public boolean canPublish(); + public IStatus canPublish(); /** * Returns true if the server may have any projects or it's @@ -316,12 +299,10 @@ public interface IServer extends IServerAttributes { * @param launchMode a mode in which a server can be launched, * one of the mode constants defined by * {@link org.eclipse.debug.core.ILaunchManager} - * @return <code>true</code> if this server can be started - * in the given mode, and <code>false</code> if it is either - * not ready to be started or if it does not support the given - * mode + * @return a status object with code <code>IStatus.OK</code> if the server can + * be started, otherwise a status object indicating why it can't */ - public boolean canStart(String launchMode); + public IStatus canStart(String launchMode); /** * Returns an existing launch for this server, or null if there is @@ -329,7 +310,7 @@ public interface IServer extends IServerAttributes { * * @return */ - public ILaunch getExistingLaunch(); + //public ILaunch getExistingLaunch(); /** * Return the launch configuration for this server. If one does not exist, it @@ -351,7 +332,7 @@ public interface IServer extends IServerAttributes { * @param monitor * @throws CoreException */ - public void setupLaunchConfiguration(ILaunchConfigurationWorkingCopy workingCopy, IProgressMonitor monitor) throws CoreException; + //public void setupLaunchConfiguration(ILaunchConfigurationWorkingCopy workingCopy, IProgressMonitor monitor) throws CoreException; /** * Asynchronously starts this server in the given launch mode. @@ -404,11 +385,10 @@ public interface IServer extends IServerAttributes { * @param launchMode a mode in which a server can be launched, * one of the mode constants defined by * {@link org.eclipse.debug.core.ILaunchManager} - * @return <code>true</code> if this server can be restarted in the - * given mode, and <code>false</code> if it is either not ready - * to be restarted or if it does not support the given mode + * @return a status object with code <code>IStatus.OK</code> if the server can + * be restarted, otherwise a status object indicating why it can't */ - public boolean canRestart(String mode); + public IStatus canRestart(String mode); /** * Returns whether this server is out of sync and needs to be @@ -469,10 +449,10 @@ public interface IServer extends IServerAttributes { * Servers can be stopped if they are not already stopped and if * they belong to a state-set that can be stopped. * - * @return <code>true</code> if this server can be stopped, - * and <code>false</code> otherwise + * @return a status object with code <code>IStatus.OK</code> if the server can + * be stopped, otherwise a status object indicating why it can't */ - public boolean canStop(); + public IStatus canStop(); /** * Asynchronously stops this server. This operation does @@ -518,10 +498,10 @@ public interface IServer extends IServerAttributes { * </p> * * @param module the module - * @return <code>true</code> if the given module can be - * restarted, and <code>false</code> otherwise + * @return a status object with code <code>IStatus.OK</code> if the module can + * be restarted, otherwise a status object indicating why it can't */ - public boolean canRestartModule(IModule module); + public IStatus canRestartModule(IModule module); /** * Check if the given module is in sync on the server. It should diff --git a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/IServerAttributes.java b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/IServerAttributes.java index 9d03cacd8..6c665623e 100644 --- a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/IServerAttributes.java +++ b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/IServerAttributes.java @@ -297,26 +297,6 @@ public interface IServerAttributes extends IAdaptable { public IServerWorkingCopy createWorkingCopy(); /** - * Returns a temporary directory that the requestor can use - * throughout it's lifecycle. This is primary to be used by - * servers for working directories, server specific - * files, etc. - * - * <p>As long as the same key is used to call this method on - * each use of the workbench, this method directory will return - * the same directory. If the directory is not requested over a - * period of time, the directory may be deleted and a new one - * will be assigned on the next request. For this reason, a - * server should request the temp directory on startup - * if it wants to store files there. In all cases, the server - * should have a backup plan to refill the directory - * in case it has been deleted since last use.</p> - * - * @return org.eclipse.core.runtime.IPath - */ - public IPath getTempDirectory(); - - /** * Returns an array of user modules that are currently being published to * this server. * <p> diff --git a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/IServerLifecycleListener.java b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/IServerLifecycleListener.java index da2d97d01..cbac7f3fd 100644 --- a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/IServerLifecycleListener.java +++ b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/IServerLifecycleListener.java @@ -11,6 +11,8 @@ package org.eclipse.wst.server.core; /** * Listener interface for server changes. + * + * @since 1.0 */ public interface IServerLifecycleListener { /** diff --git a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/IServerListener.java b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/IServerListener.java index 8f579db9f..844ceeafc 100644 --- a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/IServerListener.java +++ b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/IServerListener.java @@ -9,7 +9,6 @@ * IBM Corporation - Initial API and implementation *******************************************************************************/ package org.eclipse.wst.server.core; - /** * This interface is used by the server to broadcast a change of state. * Usually, the change of state will be caused by some user action, @@ -22,33 +21,35 @@ package org.eclipse.wst.server.core; * the server's state via one of the server's method. For example, a server * stopped event cannot directly trigger a start(). Doing this may cause * the thread to hang.</p> + * + * @since 1.0 */ public interface IServerListener { /** * Called when the server configuration's sync state changes. * - * @param server org.eclipse.wst.server.IServer + * @param server the affected server */ public void configurationSyncStateChange(IServer server); /** * Called when the server isRestartNeeded() property changes. * - * @param server org.eclipse.wst.server.IServer + * @param server the affected server */ public void restartStateChange(IServer server); /** * Notification when the server state has changed. * - * @param server org.eclipse.wst.server.IServer + * @param server the affected server */ public void serverStateChange(IServer server); /** * Called when the modules tree of this server has changed. * - * @param server org.eclipse.wst.server.IServer + * @param server the affected server */ public void modulesChanged(IServer server); @@ -57,9 +58,9 @@ public interface IServerListener { * or no longer needs to be published, or it's state has * changed. * - * @param server org.eclipse.wst.server.IServer - * @param parents org.eclipse.wst.server.IModule[] - * @param module org.eclipse.wst.server.IModule + * @param server the affected server + * @param parents the module's parents + * @param module the module */ public void moduleStateChange(IServer server, IModule[] parents, IModule module); }
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/IServerLocator.java b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/IServerLocator.java index 8fea0861b..5b5e32dc8 100644 --- a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/IServerLocator.java +++ b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/IServerLocator.java @@ -15,9 +15,13 @@ import org.eclipse.core.runtime.IProgressMonitor; /** * A server locator provides the ability to locate or search for additional * servers of a particular type, on a particular host. + * <p> + * Server locators are found via ServerCore.getServerLocators(). + * </p> * * <p>This interface is not intended to be implemented by clients.</p> * + * @see ServerCore * @since 1.0 */ public interface IServerLocator { diff --git a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/IServerPort.java b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/IServerPort.java index fec126877..4b8daaa58 100644 --- a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/IServerPort.java +++ b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/IServerPort.java @@ -11,6 +11,8 @@ package org.eclipse.wst.server.core; /** * An abstract port on a server. + * + * @since 1.0 */ public interface IServerPort { /** diff --git a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/IServerType.java b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/IServerType.java index 0238464e9..ab5492e23 100644 --- a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/IServerType.java +++ b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/IServerType.java @@ -297,20 +297,4 @@ public interface IServerType { * or setting it's default values */ public IServerWorkingCopy createServer(String id, IFile file, IProgressMonitor monitor) throws CoreException; - - /** - * Return the timeout (in ms) that should be used to wait for the server to start. - * Returns -1 if there is no timeout. - * - * @return the server startup timeout - */ - public int getStartTimeout(); - - /** - * Return the timeout (in ms) to wait before assuming that the server - * has failed to stop. Returns -1 if there is no timeout. - * - * @return the server shutdown timeout - */ - public int getStopTimeout(); }
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/ITask.java b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/ITask.java index 5344f7d11..f5fa77ed9 100644 --- a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/ITask.java +++ b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/ITask.java @@ -19,6 +19,8 @@ import org.eclipse.core.runtime.IProgressMonitor; * another task. * * <p>This interface is not intended to be implemented by clients.</p> + * + * @since 1.0 */ public interface ITask { /** diff --git a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/ITaskModel.java b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/ITaskModel.java index 9a2f7db3d..8fea76343 100644 --- a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/ITaskModel.java +++ b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/ITaskModel.java @@ -10,9 +10,12 @@ *******************************************************************************/ package org.eclipse.wst.server.core; /** - * This interface + * This interface represents a task model that can be shared between multiple + * tasks in a common workflow. * * <p>This interface is not intended to be implemented by clients.</p> + * + * @since 1.0 */ public interface ITaskModel { /** diff --git a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/ServerCore.java b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/ServerCore.java index 833e4662a..d403d0bde 100644 --- a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/ServerCore.java +++ b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/ServerCore.java @@ -14,7 +14,6 @@ import java.util.*; import org.eclipse.core.resources.*; import org.eclipse.core.runtime.*; -import org.eclipse.wst.server.core.model.*; import org.eclipse.wst.server.core.internal.*; /** * Main class for server core API. @@ -35,12 +34,6 @@ import org.eclipse.wst.server.core.internal.*; * @since 1.0 */ public class ServerCore { - // cached copy of all module factories - private static List moduleFactories; - - // cached copy of all server tasks - private static List serverTasks; - // cached copy of all runtime types private static List runtimeTypes; @@ -52,9 +45,6 @@ public class ServerCore { // cached copy of all server and configuration types private static List serverTypes; - - // cached copy of all monitors - private static List monitors; static { executeStartups(); @@ -77,15 +67,6 @@ public class ServerCore { } /** - * Returns the server monitor manager. - * - * @return org.eclipse.wst.server.core.IServerMonitorManager - */ - public static IServerMonitorManager getServerMonitorManager() { - return ServerMonitorManager.getInstance(); - } - - /** * Returns the preference information for the project. The project may not * be null. * @@ -120,7 +101,7 @@ public class ServerCore { * runtime types ({@link #getRuntimeTypes()}) for the one with a matching * runtime type id ({@link IRuntimeType#getId()}). The id may not be null. * - * @param the runtime type id + * @param id the runtime type id * @return the runtime type, or <code>null</code> if there is no runtime type * with the given id */ @@ -181,7 +162,7 @@ public class ServerCore { * a matching runtime target handler id ({@link IRuntimeTargetHandler#getId()}). * The id may not be null. * - * @param the runtime target handler id + * @param id the runtime target handler id * @return the runtime target handler instance, or <code>null</code> if * there is no runtime target handler with the given id */ @@ -224,7 +205,7 @@ public class ServerCore { * server types ({@link #getServerTypes()}) for the one with a matching * server type id ({@link IServerType#getId()}). The id may not be null. * - * @param the server type id + * @param id the server type id * @return the server type, or <code>null</code> if there is no server type * with the given id */ @@ -245,81 +226,6 @@ public class ServerCore { } /** - * Returns an array of all known module module factories. - * <p> - * A new array is returned on each call, so clients may store or modify the result. - * </p> - * - * @return the array of module factories {@link IModuleFactory} - */ - protected static ModuleFactory[] getModuleFactories() { - if (moduleFactories == null) - loadModuleFactories(); - - ModuleFactory[] mf = new ModuleFactory[moduleFactories.size()]; - moduleFactories.toArray(mf); - return mf; - } - - /** - * Returns the module factory with the given id, or <code>null</code> - * if none. This convenience method searches the list of known - * module factories ({@link #getModuleFactories()}) for the one a matching - * module factory id ({@link IModuleFactory#getId()}). The id may not be null. - * - * @param the module factory id - * @return the module factory, or <code>null</code> if there is no module factory - * with the given id - */ - protected static ModuleFactory findModuleFactory(String id) { - if (id == null) - throw new IllegalArgumentException(); - - if (moduleFactories == null) - loadModuleFactories(); - - Iterator iterator = moduleFactories.iterator(); - while (iterator.hasNext()) { - ModuleFactory factory = (ModuleFactory) iterator.next(); - if (id.equals(factory.getId())) - return factory; - } - return null; - } - - /** - * Returns an array of all known server tasks. - * <p> - * A new array is returned on each call, so clients may store or modify the result. - * </p> - * - * @return a possibly-empty array of server tasks instances {@link IServerTask} - */ - public static IServerTask[] getServerTasks() { - if (serverTasks == null) - loadServerTasks(); - IServerTask[] st = new IServerTask[serverTasks.size()]; - serverTasks.toArray(st); - return st; - } - - /** - * Returns an array of all known server monitor instances. - * <p> - * A new array is returned on each call, so clients may store or modify the result. - * </p> - * - * @return a possibly-empty array of server monitor instances {@link IServerMonitor} - */ - public static IServerMonitor[] getServerMonitors() { - if (monitors == null) - loadServerMonitors(); - IServerMonitor[] sm = new IServerMonitor[monitors.size()]; - monitors.toArray(sm); - return sm; - } - - /** * Execute the server startup extension points. */ private static synchronized void executeStartups() { @@ -449,87 +355,12 @@ public class ServerCore { } /** - * Load the module factories extension point. - */ - private static synchronized void loadModuleFactories() { - if (moduleFactories != null) - return; - Trace.trace(Trace.EXTENSION_POINT, "->- Loading .moduleFactories extension point ->-"); - IExtensionRegistry registry = Platform.getExtensionRegistry(); - IConfigurationElement[] cf = registry.getConfigurationElementsFor(ServerPlugin.PLUGIN_ID, "moduleFactories"); - - int size = cf.length; - moduleFactories = new ArrayList(size); - for (int i = 0; i < size; i++) { - try { - moduleFactories.add(new ModuleFactory(cf[i])); - Trace.trace(Trace.EXTENSION_POINT, " Loaded moduleFactories: " + cf[i].getAttribute("id")); - } catch (Throwable t) { - Trace.trace(Trace.SEVERE, " Could not load moduleFactories: " + cf[i].getAttribute("id"), t); - } - } - sortOrderedList(moduleFactories); - - Trace.trace(Trace.EXTENSION_POINT, "-<- Done loading .moduleFactories extension point -<-"); - } - - /** - * Load the server task extension point. - */ - private static synchronized void loadServerTasks() { - if (serverTasks != null) - return; - Trace.trace(Trace.EXTENSION_POINT, "->- Loading .serverTasks extension point ->-"); - IExtensionRegistry registry = Platform.getExtensionRegistry(); - IConfigurationElement[] cf = registry.getConfigurationElementsFor(ServerPlugin.PLUGIN_ID, "serverTasks"); - - int size = cf.length; - serverTasks = new ArrayList(size); - for (int i = 0; i < size; i++) { - try { - serverTasks.add(new ServerTask(cf[i])); - Trace.trace(Trace.EXTENSION_POINT, " Loaded serverTask: " + cf[i].getAttribute("id")); - } catch (Throwable t) { - Trace.trace(Trace.SEVERE, " Could not load serverTask: " + cf[i].getAttribute("id"), t); - } - } - - sortOrderedList(serverTasks); - - Trace.trace(Trace.EXTENSION_POINT, "-<- Done loading .serverTasks extension point -<-"); - } - - /** - * Load the server monitor extension point. - */ - private static synchronized void loadServerMonitors() { - if (monitors != null) - return; - Trace.trace(Trace.EXTENSION_POINT, "->- Loading .serverMonitors extension point ->-"); - IExtensionRegistry registry = Platform.getExtensionRegistry(); - IConfigurationElement[] cf = registry.getConfigurationElementsFor(ServerPlugin.PLUGIN_ID, "serverMonitors"); - - int size = cf.length; - monitors = new ArrayList(size); - for (int i = 0; i < size; i++) { - try { - monitors.add(new ServerMonitor(cf[i])); - Trace.trace(Trace.EXTENSION_POINT, " Loaded serverMonitor: " + cf[i].getAttribute("id")); - } catch (Throwable t) { - Trace.trace(Trace.SEVERE, " Could not load serverMonitor: " + cf[i].getAttribute("id"), t); - } - } - - Trace.trace(Trace.EXTENSION_POINT, "-<- Done loading .serverMonitors extension point -<-"); - } - - /** * Returns the runtime with the given id, or <code>null</code> * if none. This convenience method searches the list of known * runtimes ({@link #getRuntimes()}) for the one with a matching * runtime id ({@link IRuntime#getId()}). The id may not be null. * - * @param the runtime id + * @param id the runtime id * @return the runtime instance, or <code>null</code> if there is no runtime * with the given id */ @@ -556,7 +387,7 @@ public class ServerCore { * servers ({@link #getServers()}) for the one with a matching * server id ({@link IServer#getId()}). The id must not be null. * - * @param the server id + * @param id the server id * @return the server instance, or <code>null</code> if there is no server * with the given id */ @@ -576,12 +407,13 @@ public class ServerCore { public static IServer[] getServers() { return getResourceManager().getServers(); } - + /** * Adds a new runtime lifecycle listener. * Has no effect if an identical listener is already registered. * - * @param listener org.eclipse.wst.server.IRuntimeLifecycleListener + * @param listener a runtime lifecycle listener + * @see #removeRuntimeLifecycleListener(IRuntimeLifecycleListener) */ public static void addRuntimeLifecycleListener(IRuntimeLifecycleListener listener) { getResourceManager().addRuntimeLifecycleListener(listener); @@ -591,17 +423,19 @@ public class ServerCore { * Removes a runtime lifecycle listener. * Has no effect if the listener is not registered. * - * @param listener org.eclipse.wst.server.IRuntimeLifecycleListener + * @param listener a runtime lifecycle listener + * @see #addRuntimeLifecycleListener(IRuntimeLifecycleListener) */ public static void removeRuntimeLifecycleListener(IRuntimeLifecycleListener listener) { getResourceManager().removeRuntimeLifecycleListener(listener); } - + /** * Adds a new server lifecycle listener. * Has no effect if an identical listener is already registered. * - * @param listener org.eclipse.wst.server.IServerLifecycleListener + * @param listener a server lifecycle listener + * @see #removeServerLifecycleListener(IServerLifecycleListener) */ public static void addServerLifecycleListener(IServerLifecycleListener listener) { getResourceManager().addServerLifecycleListener(listener); @@ -611,33 +445,14 @@ public class ServerCore { * Removes a server lifecycle listener. * Has no effect if the listener is not registered. * - * @param listener org.eclipse.wst.server.IServerLifecycleListener + * @param listener a server lifecycle listener + * #addServerLifecycleListener(IServerLifecycleListener) */ public static void removeServerLifecycleListener(IServerLifecycleListener listener) { getResourceManager().removeServerLifecycleListener(listener); } /** - * Adds a new module events listener. - * Has no effect if an identical listener is already registered. - * - * @param listener org.eclipse.wst.server.model.IModuleEventsListener - */ - public static void addModuleEventsListener(IModuleEventsListener listener) { - getResourceManager().addModuleEventsListener(listener); - } - - /** - * Removes an existing module events listener. - * Has no effect if the listener is not registered. - * - * @param listener org.eclipse.wst.server.model.IModuleEventsListener - */ - public static void removeModuleEventsListener(IModuleEventsListener listener) { - getResourceManager().removeModuleEventsListener(listener); - } - - /** * Sort the given list of IOrdered items into indexed order. * * @param list java.util.List diff --git a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/ServerUtil.java b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/ServerUtil.java index a19b18c17..b405975bd 100644 --- a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/ServerUtil.java +++ b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/ServerUtil.java @@ -22,6 +22,8 @@ import org.eclipse.wst.server.core.internal.ServerPlugin; import org.eclipse.wst.server.core.internal.Trace; /** * Server utility methods. + * + * @since 1.0 */ public class ServerUtil { /** @@ -30,119 +32,6 @@ public class ServerUtil { private ServerUtil() { // do nothing } - - /** - * Returns true if the given server currently contains the given module. - * - * @param server org.eclipse.wst.server.core.IServer - * @param module org.eclipse.wst.server.core.IModule - * @param monitor a progress monitor, or <code>null</code> if progress - * reporting and cancellation are not desired - * @return boolean - */ - public static boolean containsModule(IServer server, IModule module, IProgressMonitor monitor) { - if (server == null) - return false; - Trace.trace(Trace.FINEST, "containsModule() " + server + " " + module); - try { - IModule[] modules = getAllContainedModules(server, monitor); - if (modules != null) { - int size = modules.length; - for (int i = 0; i < size; i++) { - Trace.trace(Trace.FINEST, "module: " + modules[i] + " " + module.equals(modules[i])); - if (module.equals(modules[i])) - return true; - } - } - } catch (Throwable t) { - // ignore - } - return false; - } - - /** - * Returns all projects contained by the server. This included the - * projects that are in the configuration, as well as their - * children, and their children... - * - * @param server org.eclipse.wst.server.core.IServer - * @param monitor a progress monitor, or <code>null</code> if progress - * reporting and cancellation are not desired - * @return a possibly-empty array of module instances {@link IModule} - */ - public static IModule[] getAllContainedModules(IServer server, IProgressMonitor monitor) { - //Trace.trace("> getAllContainedModules: " + getName(configuration)); - List modules = new ArrayList(); - if (server == null) - return new IModule[0]; - - // get all of the directly contained projects - IModule[] deploys = server.getModules(); - if (deploys == null || deploys.length == 0) - return new IModule[0]; - - int size = deploys.length; - for (int i = 0; i < size; i++) { - if (deploys[i] != null && !modules.contains(deploys[i])) - modules.add(deploys[i]); - } - - //Trace.trace(" getAllContainedModules: root level done"); - - // get all of the module's children - int count = 0; - while (count < modules.size()) { - IModule module = (IModule) modules.get(count); - try { - IModule[] children = server.getChildModules(module, monitor); - if (children != null) { - size = children.length; - for (int i = 0; i < size; i++) { - if (children[i] != null && !modules.contains(children[i])) - modules.add(children[i]); - } - } - } catch (Exception e) { - Trace.trace(Trace.SEVERE, "Error getting child modules for: " + module.getName(), e); - } - count ++; - } - - //Trace.trace("< getAllContainedModules"); - - IModule[] modules2 = new IModule[modules.size()]; - modules.toArray(modules2); - return modules2; - } - - /** - * Returns a list of all servers that this module is configured on. - * - * @param module org.eclipse.wst.server.core.model.IModule - * @param monitor a progress monitor, or <code>null</code> if progress - * reporting and cancellation are not desired - * @return a possibly-empty array of server instances {@link IServer} - */ - public static IServer[] getServersByModule(IModule module, IProgressMonitor monitor) { - if (module == null) - return new IServer[0]; - - // do it the slow way - go through all servers and - // see if this module is configured in it - List list = new ArrayList(); - IServer[] servers = ServerCore.getServers(); - if (servers != null) { - int size = servers.length; - for (int i = 0; i < size; i++) { - if (containsModule(servers[i], module, monitor)) - list.add(servers[i]); - } - } - - IServer[] allServers = new IServer[list.size()]; - list.toArray(allServers); - return allServers; - } /** * Returns the project modules attached to a project. @@ -169,7 +58,7 @@ public class ServerUtil { /** * Returns a module from the given moduleId. * - * @param java.lang.String moduleId + * @param moduleId * @return the module */ public static IModule getModule(String moduleId) { @@ -178,7 +67,7 @@ public class ServerUtil { return null; String factoryId = moduleId.substring(0, index); - ModuleFactory moduleFactory = ServerCore.findModuleFactory(factoryId); + ModuleFactory moduleFactory = ServerPlugin.findModuleFactory(factoryId); if (moduleFactory == null) return null; @@ -199,7 +88,7 @@ public class ServerUtil { public static IModule[] getModules(IModuleType[] moduleTypes) { List list = new ArrayList(); - ModuleFactory[] factories = ServerCore.getModuleFactories(); + ModuleFactory[] factories = ServerPlugin.getModuleFactories(); if (factories != null) { int size = factories.length; for (int i = 0; i < size; i++) { @@ -228,7 +117,7 @@ public class ServerUtil { public static IModule[] getModules(String type) { List list = new ArrayList(); - ModuleFactory[] factories = ServerCore.getModuleFactories(); + ModuleFactory[] factories = ServerPlugin.getModuleFactories(); if (factories != null) { int size = factories.length; for (int i = 0; i < size; i++) { @@ -267,7 +156,7 @@ public class ServerUtil { return false; } - protected static boolean isSupportedModule(IModuleType[] moduleTypes, IModuleType[] mt) { + private static boolean isSupportedModule(IModuleType[] moduleTypes, IModuleType[] mt) { if (mt != null) { int size = mt.length; for (int i = 0; i < size; i++) { @@ -297,7 +186,7 @@ public class ServerUtil { return false; } - protected static boolean isSupportedModule(IModuleType moduleType, String type, String version) { + private static boolean isSupportedModule(IModuleType moduleType, String type, String version) { String type2 = moduleType.getId(); if (matches(type, type2)) { String version2 = moduleType.getVersion(); @@ -324,7 +213,7 @@ public class ServerUtil { return false; } - protected static boolean matches(String a, String b) { + private static boolean matches(String a, String b) { if (a == null || b == null || "*".equals(a) || "*".equals(b) || a.startsWith(b) || b.startsWith(a)) return true; return false; @@ -335,10 +224,10 @@ public class ServerUtil { * * @return IModule[] */ - protected static IModule[] getModules() { + private static IModule[] getModules() { List list = new ArrayList(); - ModuleFactory[] factories = ServerCore.getModuleFactories(); + ModuleFactory[] factories = ServerPlugin.getModuleFactories(); if (factories != null) { int size = factories.length; for (int i = 0; i < size; i++) { @@ -431,77 +320,6 @@ public class ServerUtil { } /** - * Returns true if the given server is already started in the given - * mode, or could be (re)started in the start mode. - * - * @param server - * @param launchMode - * @return boolean - */ - public static boolean isCompatibleWithLaunchMode(IServer server, String launchMode) { - if (server == null || launchMode == null) - return false; - - int state = server.getServerState(); - if (state == IServer.STATE_STARTED && launchMode.equals(server.getMode())) - return true; - - if (server.getServerType().supportsLaunchMode(launchMode)) - return true; - return false; - } - - /** - * Visit all the modules in the server with the given module visitor. - * - * @param monitor a progress monitor, or <code>null</code> if progress - * reporting and cancellation are not desired - */ - public static void visit(IServerAttributes server, IModuleVisitor visitor, IProgressMonitor monitor) { - if (server == null) - return; - - IModule[] modules = server.getModules(); - if (modules != null) { - int size = modules.length; - for (int i = 0; i < size; i++) { - if (!visitModule(server, new IModule[0], modules[i], visitor, monitor)) - return; - } - } - } - - /** - * Returns true to keep visiting, and false to stop. - * - * @param monitor a progress monitor, or <code>null</code> if progress - * reporting and cancellation are not desired - */ - private static boolean visitModule(IServerAttributes server, IModule[] parents, IModule module, IModuleVisitor visitor, IProgressMonitor monitor) { - if (server == null || module == null || parents == null) - return true; - - if (!visitor.visit(parents, module)) - return false; - - IModule[] children = server.getChildModules(module, monitor); - if (children != null) { - int size = children.length; - for (int i = 0; i < size; i++) { - IModule module2 = children[i]; - IModule[] parents2 = new IModule[parents.length + 1]; - System.arraycopy(parents, 0, parents2, 0, parents.length); - parents2[parents.length] = module; - - if (!visitModule(server, parents2, module2, visitor, monitor)) - return false; - } - } - - return true; - } - - /** * Sets a default name on the given runtime. * * @param wc @@ -571,7 +389,7 @@ public class ServerUtil { * * @param project * @param type - * @return + * @return an unused file within the given project */ public static IFile getUnusedServerFile(IProject project, IServerType type) { String typeName = getValidFileName(type.getName()); @@ -588,7 +406,8 @@ public class ServerUtil { * Returns true if a server or runtime exists with the given name. * * @param name java.lang.String - * @return boolean + * @return <code>true</code> if the name is in use, and <code>false</code> + * otherwise */ private static boolean isNameInUse(String name) { if (name == null) @@ -730,7 +549,7 @@ public class ServerUtil { * reporting and cancellation are not desired * @return com.ibm.etools.server.core.IServer[] */ - public static IServer[] getAvailableServersForModule(IModule module, boolean includeErrors, IProgressMonitor monitor) { + /*public static IServer[] getAvailableServersForModule(IModule module, boolean includeErrors, IProgressMonitor monitor) { if (module == null) return new IServer[0]; @@ -742,7 +561,7 @@ public class ServerUtil { if (servers != null) { int size = servers.length; for (int i = 0; i < size; i++) { - if (!containsModule(servers[i], module, monitor)) { + if (!ServerPlugin.containsModule(servers[i], module, monitor)) { try { IModule[] parents = servers[i].getRootModules(module, monitor); if (parents != null && parents.length > 0) { @@ -777,5 +596,5 @@ public class ServerUtil { IServer[] allServers = new IServer[list.size()]; list.toArray(allServers); return allServers; - } + }*/ }
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/IModuleVisitor.java b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/IModuleVisitor.java index 43a797f81..f2bdf964e 100644 --- a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/IModuleVisitor.java +++ b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/IModuleVisitor.java @@ -8,9 +8,13 @@ * Contributors: * IBM Corporation - Initial API and implementation *******************************************************************************/ -package org.eclipse.wst.server.core; +package org.eclipse.wst.server.core.internal; + +import org.eclipse.wst.server.core.IModule; /** * A visitor on a server's modules. + * + * @since 1.0 */ public interface IModuleVisitor { /** diff --git a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/IMonitoredServerPort.java b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/IMonitoredServerPort.java index fdf99636f..2050b0e80 100644 --- a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/IMonitoredServerPort.java +++ b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/IMonitoredServerPort.java @@ -8,11 +8,17 @@ * Contributors: * IBM Corporation - Initial API and implementation *******************************************************************************/ -package org.eclipse.wst.server.core; +package org.eclipse.wst.server.core.internal; + +import org.eclipse.wst.server.core.IServer; +import org.eclipse.wst.server.core.IServerPort; + /** * An monitored port on a server. * * <p>This interface is not intended to be implemented by clients.</p> + * + * @since 1.0 */ public interface IMonitoredServerPort { /** diff --git a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/IPublishListener.java b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/IPublishListener.java index 532ebb5c1..86da530df 100644 --- a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/IPublishListener.java +++ b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/IPublishListener.java @@ -8,9 +8,11 @@ * Contributors: * IBM Corporation - Initial API and implementation **********************************************************************/ -package org.eclipse.wst.server.core; +package org.eclipse.wst.server.core.internal; import org.eclipse.core.runtime.IStatus; +import org.eclipse.wst.server.core.IModule; +import org.eclipse.wst.server.core.IServer; /** * A publish listener is used to listen for publishing events from a server. * The events are typically received in the following order: @@ -21,6 +23,11 @@ import org.eclipse.core.runtime.IStatus; * publishModuleStarted() - The next module is publishing * ... * publishFinished() - The publish operation is finished + * <p> + * Publish listeners are added to a server via IServer.addPublishListener(). + * </p> + * @see IServer + * @since 1.0 */ public interface IPublishListener { /** diff --git a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/IServerMonitorManager.java b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/IServerMonitorManager.java index 8c78556b7..35db11e57 100644 --- a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/IServerMonitorManager.java +++ b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/IServerMonitorManager.java @@ -8,34 +8,22 @@ * Contributors: * IBM Corporation - Initial API and implementation *******************************************************************************/ -package org.eclipse.wst.server.core; +package org.eclipse.wst.server.core.internal; import org.eclipse.core.runtime.CoreException; +import org.eclipse.wst.server.core.IServer; +import org.eclipse.wst.server.core.IServerPort; /** * * <p>This interface is not intended to be implemented by clients.</p> + * + * @since 1.0 */ public interface IServerMonitorManager { /** - * Returns the monitor that is currently being used. - * - * @return - */ - //public IServerMonitor getCurrentServerMonitor(); - - /** - * Switch to use a different server monitor. All existing monitors will be - * removed from the current monitor and added to the new monitor. - * - * @param newMonitor - * @throws CoreException - */ - //public void setServerMonitor(IServerMonitor newMonitor) throws CoreException; - - /** * Returns the array of ports that are currently being monitored. * - * @return + * @return an array containing the monitored ports for this server */ public IMonitoredServerPort[] getMonitoredPorts(IServer server); diff --git a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/IServerTask.java b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/IServerTask.java index 1d80ccaae..fba78036d 100644 --- a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/IServerTask.java +++ b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/IServerTask.java @@ -8,13 +8,18 @@ * Contributors: * IBM Corporation - Initial API and implementation *******************************************************************************/ -package org.eclipse.wst.server.core; +package org.eclipse.wst.server.core.internal; import java.util.List; +import org.eclipse.wst.server.core.IModule; +import org.eclipse.wst.server.core.IOptionalTask; +import org.eclipse.wst.server.core.IServer; /** * A task for a server. * * <p>This interface is not intended to be implemented by clients.</p> + * + * @since 1.0 */ public interface IServerTask { /** diff --git a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/model/IStartup.java b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/IStartup.java index 5d84bf975..43e2312be 100644 --- a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/model/IStartup.java +++ b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/IStartup.java @@ -8,7 +8,7 @@ * Contributors: * IBM Corporation - Initial API and implementation **********************************************************************/ -package org.eclipse.wst.server.core.model; +package org.eclipse.wst.server.core.internal; /** * An interface for the startup extension point. * Plug-ins that register a startup extension will be activated when the server @@ -17,9 +17,9 @@ package org.eclipse.wst.server.core.model; * * @since 1.0 */ -public abstract class IStartup { +public interface IStartup { /** * Will be called on server core startup. */ - public abstract void startup(); + public void startup(); }
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/Module.java b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/Module.java index 7ce12ee01..5aa101c77 100644 --- a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/Module.java +++ b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/Module.java @@ -119,9 +119,45 @@ public class Module implements IModule { } /** - * Return the validation status of the module. - * - * @return + * Validates this module. + * <p> + * [issue: Conjecture: Each different type of module prescribes + * legal arrangements of, and the significance of, the files within + * it. This would be spelled out in the spec for the particular + * module types. + * This validate operation is suppose to check the actual + * arrangement of files in this module to see whether they + * meet expectations. + * It's an open question as to how "strenuous" a check this + * is.] + * </p> + * <p> + * [issue: Old comment said: "If there is an error + * that should block the server from starting (e.g. major errors) + * it should be returned from this method. This method can also be used to + * return warning for such things as an open (and dirty) editor."] + * </p> + * <p> + * [issue: All existing implementations of this return null, + * which is illegal.] + * </p> + * <p> + * [issue: Old comment said: "Returns an IStatus that is used to determine if this object can + * be published to the server." Since the same module can + * be associated with any number of servers, "the server" is + * ill-defined.] + * </p> + * <p> + * [issue: Old comment said: "Should return an error if there + * is a major problem with the resources, or can be used to + * return warnings on unsaved files, etc." It is usually + * difficult in principle for core-level infrastructure to + * detect whether there are open editors with unsaved changes.] + * </p> + * + * @return a status object with code <code>IStatus.OK</code> if the given + * module is valid, otherwise a status object indicating what is + * wrong with it */ public IStatus validate(IProgressMonitor monitor) { try { diff --git a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/util/PublishAdapter.java b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/PublishAdapter.java index 8a2d4f026..0000cd871 100644 --- a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/util/PublishAdapter.java +++ b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/PublishAdapter.java @@ -8,40 +8,31 @@ * Contributors: * IBM Corporation - Initial API and implementation *******************************************************************************/ -package org.eclipse.wst.server.core.util; +package org.eclipse.wst.server.core.internal; import org.eclipse.core.runtime.IStatus; import org.eclipse.wst.server.core.IModule; -import org.eclipse.wst.server.core.IPublishListener; import org.eclipse.wst.server.core.IServer; /** - * + * Helper class which implements the IPublishListener interface + * with empty methods. + * + * @see org.eclipse.wst.server.core.internal.IPublishListener + * @since 1.0 */ public class PublishAdapter implements IPublishListener { - /* (non-Javadoc) - * @see org.eclipse.wst.server.core.model.IPublishListener#publishStarted(org.eclipse.wst.server.core.IServer2) - */ public void publishStarted(IServer server) { // do nothing } - /* (non-Javadoc) - * @see org.eclipse.wst.server.core.model.IPublishListener#moduleStarting(org.eclipse.wst.server.core.IServer2, java.util.List, org.eclipse.wst.server.core.model.IModule) - */ public void publishModuleStarted(IServer server, IModule[] parents, IModule module) { // do nothing } - /* (non-Javadoc) - * @see org.eclipse.wst.server.core.model.IPublishListener#moduleFinished(org.eclipse.wst.server.core.IServer2, java.util.List, org.eclipse.wst.server.core.model.IModule, org.eclipse.wst.server.core.IPublishStatus) - */ public void publishModuleFinished(IServer server, IModule[] parents, IModule module, IStatus status) { // do nothing } - /* (non-Javadoc) - * @see org.eclipse.wst.server.core.model.IPublishListener#publishFinished(org.eclipse.wst.server.core.IServer, org.eclipse.wst.server.core.IPublishStatus) - */ public void publishFinished(IServer server, IStatus status) { // do nothing } diff --git a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/ResourceManager.java b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/ResourceManager.java index e0010dbf4..31edeb06f 100644 --- a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/ResourceManager.java +++ b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/ResourceManager.java @@ -117,7 +117,7 @@ public class ResourceManager { * @param delta org.eclipse.core.resources.IResourceDelta */ protected void projectChanged(IProject project, IResourceDelta delta) { - if (!ServerCore.getProjectProperties(project).isServerProject()) { + if (!((ProjectProperties)ServerCore.getProjectProperties(project)).isServerProject()) { Trace.trace(Trace.RESOURCES, "Not a server project: " + project.getName()); return; } @@ -275,7 +275,7 @@ public class ResourceManager { if (projects != null) { int size = projects.length; for (int i = 0; i < size; i++) { - if (ServerCore.getProjectProperties(projects[i]).isServerProject()) + if (((ProjectProperties)ServerCore.getProjectProperties(projects[i])).isServerProject()) loadFromProject(projects[i]); } } diff --git a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/Server.java b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/Server.java index 6fe0ca79c..d828f6b26 100644 --- a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/Server.java +++ b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/Server.java @@ -463,7 +463,7 @@ public class Server extends Base implements IServer { } }; - ServerUtil.visit(this, visitor, null); + visit(visitor, null); if (!helper.changed) return; @@ -519,8 +519,10 @@ public class Server extends Base implements IServer { /** * Adds a publish listener to this server. + * Has no effect if an identical listener is already registered. * - * @param listener org.eclipse.wst.server.core.model.IPublishListener + * @param listener the publish listener + * @see #removePublishListener(IPublishListener) */ public void addPublishListener(IPublishListener listener) { Trace.trace(Trace.LISTENERS, "Adding publish listener " + listener + " to " + this); @@ -532,8 +534,10 @@ public class Server extends Base implements IServer { /** * Removes a publish listener from this server. + * Has no effect if the listener is not registered. * - * @param listener org.eclipse.wst.server.core.model.IPublishListener + * @param listener the publish listener + * @see #addPublishListener(IPublishListener) */ public void removePublishListener(IPublishListener listener) { Trace.trace(Trace.LISTENERS, "Removing publish listener " + listener + " from " + this); @@ -682,20 +686,21 @@ public class Server extends Base implements IServer { * be published to. * * @return boolean + * TODO: fix return strings */ - public boolean canPublish() { + public IStatus canPublish() { // can't publish if the server is starting or stopping int state = getServerState(); if (state == STATE_STARTING || state == STATE_STOPPING) - return false; + return new Status(IStatus.ERROR, ServerPlugin.PLUGIN_ID, 0, ServerPlugin.getResource("%errorLaunchMode"), null); // can't publish if there is no configuration if (getServerType() == null || getServerType().hasServerConfiguration() && configuration == null) - return false; + return new Status(IStatus.ERROR, ServerPlugin.PLUGIN_ID, 0, ServerPlugin.getResource("%errorLaunchMode"), null); // return true if the configuration can be published if (getServerPublishState() != PUBLISH_STATE_NONE) - return true; + return new Status(IStatus.OK, ServerPlugin.PLUGIN_ID, 0, ServerPlugin.getResource("%errorLaunchMode"), null); // return true if any modules can be published class Temp { @@ -703,7 +708,7 @@ public class Server extends Base implements IServer { } //final Temp temp = new Temp(); - return true; + return new Status(IStatus.OK, ServerPlugin.PLUGIN_ID, 0, ServerPlugin.getResource("%errorLaunchMode"), null); /*IModuleVisitor visitor = new IModuleVisitor() { public boolean visit(IModule[] parents, IModule module) { @@ -726,7 +731,7 @@ public class Server extends Base implements IServer { * @return boolean */ public boolean shouldPublish() { - if (!canPublish()) + if (!canPublish().isOK()) return false; if (getServerPublishState() != PUBLISH_STATE_NONE) @@ -832,7 +837,7 @@ public class Server extends Base implements IServer { } }; - ServerUtil.visit(this, visitor, monitor); + visit(visitor, monitor); // build arrays & lists List[] taskParents = new List[taskParentList.size()]; @@ -1024,7 +1029,7 @@ public class Server extends Base implements IServer { String serverTypeId = getServerType().getId(); - IServerTask[] serverTasks = ServerCore.getServerTasks(); + IServerTask[] serverTasks = ServerPlugin.getServerTasks(); if (serverTasks != null) { int size = serverTasks.length; for (int i = 0; i < size; i++) { @@ -1113,17 +1118,17 @@ public class Server extends Base implements IServer { * be started, and supports the given mode. * * @param mode - * @return boolean + * @return status */ - public boolean canStart(String mode2) { + public IStatus canStart(String mode2) { int state = getServerState(); if (state != STATE_STOPPED && state != STATE_UNKNOWN) - return false; + return new Status(IStatus.ERROR, ServerPlugin.PLUGIN_ID, 0, ServerPlugin.getResource("%canStartErrorState"), null); if (getServerType() == null || !getServerType().supportsLaunchMode(mode2)) - return false; + return new Status(IStatus.ERROR, ServerPlugin.PLUGIN_ID, 0, ServerPlugin.getResource("%errorLaunchMode"), null); - return true; + return new Status(IStatus.OK, ServerPlugin.PLUGIN_ID, 0, ServerPlugin.getResource("%canStartOk"), null); } public ILaunch getExistingLaunch() { @@ -1270,16 +1275,17 @@ public class Server extends Base implements IServer { * be restarted. * * @return boolean + * TODO: fix return strings */ - public boolean canRestart(String mode2) { - /*ServerDelegate delegate2 = getDelegate(); - if (!(delegate2 instanceof IStartableServer)) - return false;*/ + public IStatus canRestart(String mode2) { if (!getServerType().supportsLaunchMode(mode2)) - return false; + return new Status(IStatus.ERROR, ServerPlugin.PLUGIN_ID, 0, ServerPlugin.getResource("%errorLaunchMode"), null); int state = getServerState(); - return (state == STATE_STARTED); + if (state == STATE_STARTED) + return new Status(IStatus.OK, ServerPlugin.PLUGIN_ID, 0, ServerPlugin.getResource("%errorLaunchMode"), null); + + return new Status(IStatus.ERROR, ServerPlugin.PLUGIN_ID, 0, ServerPlugin.getResource("%errorLaunchMode"), null); } /** @@ -1368,12 +1374,13 @@ public class Server extends Base implements IServer { * be stopped. * * @return boolean + * TODO: fix return strings */ - public boolean canStop() { + public IStatus canStop() { if (getServerState() == STATE_STOPPED) - return false; + return new Status(IStatus.ERROR, ServerPlugin.PLUGIN_ID, 0, ServerPlugin.getResource("%errorLaunchMode"), null); - return true; + return new Status(IStatus.OK, ServerPlugin.PLUGIN_ID, 0, ServerPlugin.getResource("%errorLaunchMode"), null); } /** @@ -1423,7 +1430,7 @@ public class Server extends Base implements IServer { }; addServerListener(listener); - final int serverTimeout = getServerType().getStartTimeout(); + final int serverTimeout = ((ServerType) getServerType()).getStartTimeout(); class Timer { boolean timeout; boolean alreadyDone; @@ -1876,15 +1883,18 @@ public class Server extends Base implements IServer { * * @param module the module * @return <code>true</code> if the given module can be - * restarted, and <code>false</code> otherwise + * restarted, and <code>false</code> otherwise + * TODO: fix return strings */ - public boolean canRestartModule(IModule module) { + public IStatus canRestartModule(IModule module) { try { - return getBehaviourDelegate().canRestartModule(module); + boolean b = getBehaviourDelegate().canRestartModule(module); + if (b) + return new Status(IStatus.OK, ServerPlugin.PLUGIN_ID, 0, ServerPlugin.getResource("%errorLaunchMode"), null); } catch (Exception e) { Trace.trace(Trace.SEVERE, "Error calling delegate canRestartRuntime() " + toString(), e); - return false; } + return new Status(IStatus.ERROR, ServerPlugin.PLUGIN_ID, 0, ServerPlugin.getResource("%errorLaunchMode"), null); } /** @@ -1930,4 +1940,51 @@ public class Server extends Base implements IServer { return null; } } + + /** + * Visit all the modules in the server with the given module visitor. + * + * @param monitor a progress monitor, or <code>null</code> if progress + * reporting and cancellation are not desired + */ + public void visit(IModuleVisitor visitor, IProgressMonitor monitor) { + IModule[] modules2 = getModules(); + if (modules2 != null) { + int size = modules2.length; + for (int i = 0; i < size; i++) { + if (!visitModule(new IModule[0], modules2[i], visitor, monitor)) + return; + } + } + } + + /** + * Returns true to keep visiting, and false to stop. + * + * @param monitor a progress monitor, or <code>null</code> if progress + * reporting and cancellation are not desired + */ + private boolean visitModule(IModule[] parents, IModule module, IModuleVisitor visitor, IProgressMonitor monitor) { + if (module == null || parents == null) + return true; + + if (!visitor.visit(parents, module)) + return false; + + IModule[] children = getChildModules(module, monitor); + if (children != null) { + int size = children.length; + for (int i = 0; i < size; i++) { + IModule module2 = children[i]; + IModule[] parents2 = new IModule[parents.length + 1]; + System.arraycopy(parents, 0, parents2, 0, parents.length); + parents2[parents.length] = module; + + if (!visitModule(parents2, module2, visitor, monitor)) + return false; + } + } + + return true; + } }
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/ServerMonitorManager.java b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/ServerMonitorManager.java index bbbd1ec4c..1b055c686 100644 --- a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/ServerMonitorManager.java +++ b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/ServerMonitorManager.java @@ -63,6 +63,8 @@ public class ServerMonitorManager implements IServerMonitorManager { } public String[] getContentTypes() { + if (content == null) + return new String[0]; return content; } @@ -163,7 +165,7 @@ public class ServerMonitorManager implements IServerMonitorManager { } public ServerMonitorManager() { - IServerMonitor[] monitors = ServerCore.getServerMonitors(); + IServerMonitor[] monitors = ServerPlugin.getServerMonitors(); if (monitors != null && monitors.length > 0) monitor = (ServerMonitor) monitors[0]; diff --git a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/ServerPlugin.java b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/ServerPlugin.java index 1f5ddc325..adbc4fdb8 100644 --- a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/ServerPlugin.java +++ b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/ServerPlugin.java @@ -16,6 +16,8 @@ import java.text.DateFormat; import java.text.MessageFormat; import org.eclipse.core.runtime.*; +import org.eclipse.wst.server.core.IModule; +import org.eclipse.wst.server.core.IServer; import org.osgi.framework.BundleContext; /** * The main server plugin class. @@ -31,10 +33,19 @@ public class ServerPlugin extends Plugin { // cached copy of all launchable clients private static List clients; + + // cached copy of all module factories + private static List moduleFactories; // singleton instance of this class private static ServerPlugin singleton; + // cached copy of all server tasks + private static List serverTasks; + + // cached copy of all server monitors + private static List monitors; + private static final String TEMP_DATA_FILE = "tmp-data.xml"; class TempDir { @@ -466,4 +477,263 @@ public class ServerPlugin extends Plugin { } Trace.trace(Trace.EXTENSION_POINT, "-<- Done loading .clients extension point -<-"); } + + /** + * Returns an array of all known server tasks. + * <p> + * A new array is returned on each call, so clients may store or modify the result. + * </p> + * + * @return a possibly-empty array of server tasks instances {@link IServerTask} + */ + public static IServerTask[] getServerTasks() { + if (serverTasks == null) + loadServerTasks(); + IServerTask[] st = new IServerTask[serverTasks.size()]; + serverTasks.toArray(st); + return st; + } + + /** + * Load the server task extension point. + */ + private static synchronized void loadServerTasks() { + if (serverTasks != null) + return; + Trace.trace(Trace.EXTENSION_POINT, "->- Loading .serverTasks extension point ->-"); + IExtensionRegistry registry = Platform.getExtensionRegistry(); + IConfigurationElement[] cf = registry.getConfigurationElementsFor(ServerPlugin.PLUGIN_ID, "serverTasks"); + + int size = cf.length; + serverTasks = new ArrayList(size); + for (int i = 0; i < size; i++) { + try { + serverTasks.add(new ServerTask(cf[i])); + Trace.trace(Trace.EXTENSION_POINT, " Loaded serverTask: " + cf[i].getAttribute("id")); + } catch (Throwable t) { + Trace.trace(Trace.SEVERE, " Could not load serverTask: " + cf[i].getAttribute("id"), t); + } + } + + sortOrderedList(serverTasks); + + Trace.trace(Trace.EXTENSION_POINT, "-<- Done loading .serverTasks extension point -<-"); + } + + /** + * Sort the given list of IOrdered items into indexed order. + * + * @param list java.util.List + * @return java.util.List + */ + private static List sortOrderedList(List list) { + if (list == null) + return null; + + int size = list.size(); + for (int i = 0; i < size - 1; i++) { + for (int j = i + 1; j < size; j++) { + IOrdered a = (IOrdered) list.get(i); + IOrdered b = (IOrdered) list.get(j); + if (a.getOrder() > b.getOrder()) { + Object temp = a; + list.set(i, b); + list.set(j, temp); + } + } + } + return list; + } + + /** + * Returns an array of all known module module factories. + * <p> + * A new array is returned on each call, so clients may store or modify the result. + * </p> + * + * @return the array of module factories {@link IModuleFactory} + */ + public static ModuleFactory[] getModuleFactories() { + if (moduleFactories == null) + loadModuleFactories(); + + ModuleFactory[] mf = new ModuleFactory[moduleFactories.size()]; + moduleFactories.toArray(mf); + return mf; + } + + /** + * Returns the module factory with the given id, or <code>null</code> + * if none. This convenience method searches the list of known + * module factories ({@link #getModuleFactories()}) for the one a matching + * module factory id ({@link IModuleFactory#getId()}). The id may not be null. + * + * @param the module factory id + * @return the module factory, or <code>null</code> if there is no module factory + * with the given id + */ + public static ModuleFactory findModuleFactory(String id) { + if (id == null) + throw new IllegalArgumentException(); + + if (moduleFactories == null) + loadModuleFactories(); + + Iterator iterator = moduleFactories.iterator(); + while (iterator.hasNext()) { + ModuleFactory factory = (ModuleFactory) iterator.next(); + if (id.equals(factory.getId())) + return factory; + } + return null; + } + + /** + * Load the module factories extension point. + */ + private static synchronized void loadModuleFactories() { + if (moduleFactories != null) + return; + Trace.trace(Trace.EXTENSION_POINT, "->- Loading .moduleFactories extension point ->-"); + IExtensionRegistry registry = Platform.getExtensionRegistry(); + IConfigurationElement[] cf = registry.getConfigurationElementsFor(ServerPlugin.PLUGIN_ID, "moduleFactories"); + + int size = cf.length; + moduleFactories = new ArrayList(size); + for (int i = 0; i < size; i++) { + try { + moduleFactories.add(new ModuleFactory(cf[i])); + Trace.trace(Trace.EXTENSION_POINT, " Loaded moduleFactories: " + cf[i].getAttribute("id")); + } catch (Throwable t) { + Trace.trace(Trace.SEVERE, " Could not load moduleFactories: " + cf[i].getAttribute("id"), t); + } + } + sortOrderedList(moduleFactories); + + Trace.trace(Trace.EXTENSION_POINT, "-<- Done loading .moduleFactories extension point -<-"); + } + + /** + * Returns all projects contained by the server. This included the + * projects that are in the configuration, as well as their + * children, and their children... + * + * @param server org.eclipse.wst.server.core.IServer + * @param monitor a progress monitor, or <code>null</code> if progress + * reporting and cancellation are not desired + * @return a possibly-empty array of module instances {@link IModule} + */ + private static IModule[] getAllContainedModules(IServer server, IProgressMonitor monitor) { + //Trace.trace("> getAllContainedModules: " + getName(configuration)); + List modules = new ArrayList(); + if (server == null) + return new IModule[0]; + + // get all of the directly contained projects + IModule[] deploys = server.getModules(); + if (deploys == null || deploys.length == 0) + return new IModule[0]; + + int size = deploys.length; + for (int i = 0; i < size; i++) { + if (deploys[i] != null && !modules.contains(deploys[i])) + modules.add(deploys[i]); + } + + //Trace.trace(" getAllContainedModules: root level done"); + + // get all of the module's children + int count = 0; + while (count < modules.size()) { + IModule module = (IModule) modules.get(count); + try { + IModule[] children = server.getChildModules(module, monitor); + if (children != null) { + size = children.length; + for (int i = 0; i < size; i++) { + if (children[i] != null && !modules.contains(children[i])) + modules.add(children[i]); + } + } + } catch (Exception e) { + Trace.trace(Trace.SEVERE, "Error getting child modules for: " + module.getName(), e); + } + count ++; + } + + //Trace.trace("< getAllContainedModules"); + + IModule[] modules2 = new IModule[modules.size()]; + modules.toArray(modules2); + return modules2; + } + + /** + * Returns true if the given server currently contains the given module. + * + * @param server org.eclipse.wst.server.core.IServer + * @param module org.eclipse.wst.server.core.IModule + * @param monitor a progress monitor, or <code>null</code> if progress + * reporting and cancellation are not desired + * @return boolean + */ + public static boolean containsModule(IServer server, IModule module, IProgressMonitor monitor) { + if (server == null) + return false; + Trace.trace(Trace.FINEST, "containsModule() " + server + " " + module); + try { + IModule[] modules = getAllContainedModules(server, monitor); + if (modules != null) { + int size = modules.length; + for (int i = 0; i < size; i++) { + Trace.trace(Trace.FINEST, "module: " + modules[i] + " " + module.equals(modules[i])); + if (module.equals(modules[i])) + return true; + } + } + } catch (Throwable t) { + // ignore + } + return false; + } + + /** + * Returns an array of all known server monitor instances. + * <p> + * A new array is returned on each call, so clients may store or modify the result. + * </p> + * + * @return a possibly-empty array of server monitor instances {@link IServerMonitor} + */ + public static IServerMonitor[] getServerMonitors() { + if (monitors == null) + loadServerMonitors(); + IServerMonitor[] sm = new IServerMonitor[monitors.size()]; + monitors.toArray(sm); + return sm; + } + + /** + * Load the server monitor extension point. + */ + private static synchronized void loadServerMonitors() { + if (monitors != null) + return; + Trace.trace(Trace.EXTENSION_POINT, "->- Loading .serverMonitors extension point ->-"); + IExtensionRegistry registry = Platform.getExtensionRegistry(); + IConfigurationElement[] cf = registry.getConfigurationElementsFor(ServerPlugin.PLUGIN_ID, "serverMonitors"); + + int size = cf.length; + monitors = new ArrayList(size); + for (int i = 0; i < size; i++) { + try { + monitors.add(new ServerMonitor(cf[i])); + Trace.trace(Trace.EXTENSION_POINT, " Loaded serverMonitor: " + cf[i].getAttribute("id")); + } catch (Throwable t) { + Trace.trace(Trace.SEVERE, " Could not load serverMonitor: " + cf[i].getAttribute("id"), t); + } + } + + Trace.trace(Trace.EXTENSION_POINT, "-<- Done loading .serverMonitors extension point -<-"); + } }
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/ServerPublishInfo.java b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/ServerPublishInfo.java index 12278fd5e..3a87794d1 100644 --- a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/ServerPublishInfo.java +++ b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/ServerPublishInfo.java @@ -252,7 +252,7 @@ public class ServerPublishInfo { int size2 = current.length; for (int i = 0; i < size; i++) { for (int j = 0; j < size2; j++) { - if (!found.contains(original[i]) && !found.contains(current[i]) && original[i].equals(current[j])) { + if (!found.contains(original[i]) && !found.contains(current[j]) && original[i].equals(current[j])) { // found a match found.add(original[i]); if (original[i] instanceof IModuleFile) { diff --git a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/ServerType.java b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/ServerType.java index 9b463fdb2..dc9774667 100644 --- a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/ServerType.java +++ b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/ServerType.java @@ -231,7 +231,7 @@ public class ServerType implements IServerType, IOrdered { if (projects != null) { int size = projects.length; for (int i = 0; i < size; i++) { - if (ServerCore.getProjectProperties(projects[i]).isServerProject()) + if (((ProjectProperties)ServerCore.getProjectProperties(projects[i])).isServerProject()) return projects[i]; } } @@ -240,7 +240,7 @@ public class ServerType implements IServerType, IOrdered { IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(s); project.create(null); project.open(null); - ServerCore.getProjectProperties(project).setServerProject(true, null); + ((ProjectProperties)ServerCore.getProjectProperties(project)).setServerProject(true, null); return project; } @@ -258,12 +258,12 @@ public class ServerType implements IServerType, IOrdered { } return name; } - + /** * Return the timeout (in ms) that should be used to wait for the server to start. * Returns -1 if there is no timeout. * - * @return + * @return the server startup timeout */ public int getStartTimeout() { try { @@ -276,8 +276,8 @@ public class ServerType implements IServerType, IOrdered { /** * Return the timeout (in ms) to wait before assuming that the server * has failed to stop. Returns -1 if there is no timeout. - * - * @return + * + * @return the server shutdown timeout */ public int getStopTimeout() { try { diff --git a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/ServerWorkingCopy.java b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/ServerWorkingCopy.java index f6de25f3a..d17f8a988 100644 --- a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/ServerWorkingCopy.java +++ b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/ServerWorkingCopy.java @@ -234,7 +234,7 @@ public class ServerWorkingCopy extends Server implements IServerWorkingCopy { if (project != null && !project.exists()) { project.create(null); project.open(null); - ServerCore.getProjectProperties(project).setServerProject(true, monitor); + ((ProjectProperties)ServerCore.getProjectProperties(project)).setServerProject(true, monitor); } if (!folder.exists()) folder.create(IResource.FORCE, true, null); diff --git a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/operations/AddModuleOperation.java b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/operations/AddModuleOperation.java deleted file mode 100644 index c61860f92..000000000 --- a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/operations/AddModuleOperation.java +++ /dev/null @@ -1,34 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 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 - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.core.internal.operations; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.wst.server.core.IModule; -/** - * Add module operation. - */ -public class AddModuleOperation implements IServerOperation { - private IModule module; - - public AddModuleOperation(IModule module) { - this.module = module; - } - - public IModule getModule() { - return module; - } - - public IStatus execute(IProgressMonitor monitor) throws CoreException { - return null; - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/operations/IServer.java b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/operations/IServer.java deleted file mode 100644 index 7c770866b..000000000 --- a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/operations/IServer.java +++ /dev/null @@ -1,31 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 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 - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.core.internal.operations; - -import org.eclipse.core.runtime.IStatus; -/** - * A server. - */ -public interface IServer { - /** - * - */ - public boolean canOperate(IServerOperation[] operations); - - /** - * - * @param operation - * @param state - * @param synchronous - * @return - */ - public IStatus operate(IServerOperation[] operations, ServerState state, boolean synchronous); -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/operations/IServerOperation.java b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/operations/IServerOperation.java deleted file mode 100644 index 118530864..000000000 --- a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/operations/IServerOperation.java +++ /dev/null @@ -1,24 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 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 - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.core.internal.operations; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -/** - * A server operation. - */ -public interface IServerOperation { - /** - * - */ - public IStatus execute(IProgressMonitor monitor) throws CoreException; -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/operations/ModuleState.java b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/operations/ModuleState.java deleted file mode 100644 index d237ba462..000000000 --- a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/operations/ModuleState.java +++ /dev/null @@ -1,39 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 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 - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.core.internal.operations; - -import org.eclipse.wst.server.core.IModule; -/** - * A module state. - */ -public class ModuleState { - private IModule module; - private boolean publish; - private int state; - - public ModuleState(IModule module, int state, boolean publish) { - this.module = module; - this.state = state; - this.publish = publish; - } - - public IModule getModule() { - return module; - } - - public int getState() { - return state; - } - - public boolean getPublish() { - return publish; - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/operations/NullOperation.java b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/operations/NullOperation.java deleted file mode 100644 index 318aceede..000000000 --- a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/operations/NullOperation.java +++ /dev/null @@ -1,23 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 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 - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.core.internal.operations; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -/** - * Null operation. - */ -public class NullOperation implements IServerOperation { - public IStatus execute(IProgressMonitor monitor) throws CoreException { - return null; - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/operations/RemoveModuleOperation.java b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/operations/RemoveModuleOperation.java deleted file mode 100644 index 88d089bfe..000000000 --- a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/operations/RemoveModuleOperation.java +++ /dev/null @@ -1,34 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 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 - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.core.internal.operations; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.wst.server.core.IModule; -/** - * Remove module operation. - */ -public class RemoveModuleOperation implements IServerOperation { - private IModule module; - - public RemoveModuleOperation(IModule module) { - this.module = module; - } - - public IModule getModule() { - return module; - } - - public IStatus execute(IProgressMonitor monitor) throws CoreException { - return null; - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/operations/ServerState.java b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/operations/ServerState.java deleted file mode 100644 index 4fb48e100..000000000 --- a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/operations/ServerState.java +++ /dev/null @@ -1,47 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 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 - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.core.internal.operations; - -import java.util.ArrayList; -import java.util.List; -/** - * A server state. - */ -public class ServerState { - private int state; - private boolean publish; - private List moduleStates = new ArrayList(2); - - public ServerState(int state, boolean publish) { - this.state = state; - this.publish = publish; - } - - public void addModuleState(ModuleState moduleState) { - if (moduleStates.contains(moduleState)) - return; - moduleStates.add(moduleState); - } - - public int getState() { - return state; - } - - public boolean getPublish() { - return publish; - } - - public ModuleState[] getModuleStates() { - ModuleState[] ms = new ModuleState[moduleStates.size()]; - moduleStates.toArray(ms); - return ms; - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/operations/StartServerOperation.java b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/operations/StartServerOperation.java deleted file mode 100644 index 30d663331..000000000 --- a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/operations/StartServerOperation.java +++ /dev/null @@ -1,23 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 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 - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.core.internal.operations; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -/** - * Start server operation. - */ -public class StartServerOperation implements IServerOperation { - public IStatus execute(IProgressMonitor monitor) throws CoreException { - return null; - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/operations/StopServerOperation.java b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/operations/StopServerOperation.java deleted file mode 100644 index 870009789..000000000 --- a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/operations/StopServerOperation.java +++ /dev/null @@ -1,23 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2005 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 - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.core.internal.operations; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -/** - * Start server operation. - */ -public class StopServerOperation implements IServerOperation { - public IStatus execute(IProgressMonitor monitor) throws CoreException { - return null; - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/model/ClientDelegate.java b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/model/ClientDelegate.java index 38aa086cc..e45e806e2 100644 --- a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/model/ClientDelegate.java +++ b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/model/ClientDelegate.java @@ -21,6 +21,8 @@ import org.eclipse.wst.server.core.IServer; * This abstract class is intended to be extended only by clients * to extend the <code>clients</code> extension point. * </p> + * + * @since 1.0 */ public abstract class ClientDelegate { /** @@ -29,7 +31,8 @@ public abstract class ClientDelegate { * @param server * @param launchable * @param launchMode - * @return + * @return <code>true</code> if the client supports this combination, and <code>false</code> + * otherwise */ public abstract boolean supports(IServer server, ILaunchable launchable, String launchMode); @@ -40,7 +43,7 @@ public abstract class ClientDelegate { * @param launchable * @param launchMode * @param launch - * @return + * @return status indicating what (if anything) went wrong */ public abstract IStatus launch(IServer server, ILaunchable launchable, String launchMode, ILaunch launch); }
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/model/IModuleEventsListener.java b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/model/IModuleEventsListener.java index 609cbe97a..64a285406 100644 --- a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/model/IModuleEventsListener.java +++ b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/model/IModuleEventsListener.java @@ -11,6 +11,8 @@ package org.eclipse.wst.server.core.model; /** * + * + * @since 1.0 */ public interface IModuleEventsListener { /** diff --git a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/model/IModuleFactoryListener.java b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/model/IModuleFactoryListener.java index 99ef4e7c9..fb7744823 100644 --- a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/model/IModuleFactoryListener.java +++ b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/model/IModuleFactoryListener.java @@ -11,6 +11,8 @@ package org.eclipse.wst.server.core.model; /** * + * + * @since 1.0 */ public interface IModuleFactoryListener { /** diff --git a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/model/IModuleFile.java b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/model/IModuleFile.java index c914756bc..612ccc1e8 100644 --- a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/model/IModuleFile.java +++ b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/model/IModuleFile.java @@ -11,6 +11,8 @@ package org.eclipse.wst.server.core.model; /** * A file within a module. + * + * @since 1.0 */ public interface IModuleFile extends IModuleResource { /** diff --git a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/model/IModuleFolder.java b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/model/IModuleFolder.java index 79ca7d976..b8c082040 100644 --- a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/model/IModuleFolder.java +++ b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/model/IModuleFolder.java @@ -11,12 +11,14 @@ package org.eclipse.wst.server.core.model; /** * A folder within a module. + * + * @since 1.0 */ public interface IModuleFolder extends IModuleResource { /** * Returns the members (contents) of this folder. * - * @return + * @return an array containing the module resources contained in this folder */ public IModuleResource[] members(); }
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/model/IModuleListener.java b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/model/IModuleListener.java index a6bdb5248..532ceb742 100644 --- a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/model/IModuleListener.java +++ b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/model/IModuleListener.java @@ -11,6 +11,7 @@ package org.eclipse.wst.server.core.model; /** * + * @since 1.0 */ public interface IModuleListener { /** diff --git a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/model/IModuleResource.java b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/model/IModuleResource.java index e0b0afb12..663df7e8e 100644 --- a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/model/IModuleResource.java +++ b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/model/IModuleResource.java @@ -13,6 +13,8 @@ package org.eclipse.wst.server.core.model; import org.eclipse.core.runtime.IPath; /** * A resource (file or folder) within a module. + * + * @since 1.0 */ public interface IModuleResource { /** diff --git a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/model/IModuleResourceDelta.java b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/model/IModuleResourceDelta.java index a613f6266..33a0c2d0d 100644 --- a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/model/IModuleResourceDelta.java +++ b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/model/IModuleResourceDelta.java @@ -13,6 +13,7 @@ package org.eclipse.wst.server.core.model; import org.eclipse.core.runtime.IPath; /** * + * @since 1.0 */ public interface IModuleResourceDelta { public static final int NO_CHANGE = 0; @@ -21,8 +22,9 @@ public interface IModuleResourceDelta { public static final int REMOVED = 3; /** + * Returns the module resource represented by this delta. * - * @return + * @return the corresponding module resource */ public IModuleResource getModuleResource(); diff --git a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/model/IModuleResourceDeltaVisitor.java b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/model/IModuleResourceDeltaVisitor.java index 0a79c2d53..b9714720b 100644 --- a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/model/IModuleResourceDeltaVisitor.java +++ b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/model/IModuleResourceDeltaVisitor.java @@ -40,7 +40,9 @@ import org.eclipse.core.runtime.CoreException; * Clients may implement this interface. * </p> * - * @see IModuleResourceDelta#accept(IModuleResourceVisitor) + * [issue: @see IModuleResourceDelta#accept(IModuleResourceVisitor)] + * + * @since 1.0 */ public interface IModuleResourceDeltaVisitor { /** diff --git a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/model/IRunningActionServer.java b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/model/IRunningActionServer.java index aeb54218b..86889f047 100644 --- a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/model/IRunningActionServer.java +++ b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/model/IRunningActionServer.java @@ -13,6 +13,8 @@ package org.eclipse.wst.server.core.model; * This interface is a tag for a server that should be running before calling * modifyModules(). It will be implemented by delegate classes of servers that * should be started before calling API. + * + * @since 1.0 */ public interface IRunningActionServer { // marker interface diff --git a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/model/IURLProvider.java b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/model/IURLProvider.java index b6e550cbe..c0d9d5e79 100644 --- a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/model/IURLProvider.java +++ b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/model/IURLProvider.java @@ -15,6 +15,7 @@ import java.net.URL; import org.eclipse.wst.server.core.IModule; /** * + * @since 1.0 */ public interface IURLProvider { /** diff --git a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/model/LaunchableAdapterDelegate.java b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/model/LaunchableAdapterDelegate.java index 2376c6cdb..5300f7603 100644 --- a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/model/LaunchableAdapterDelegate.java +++ b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/model/LaunchableAdapterDelegate.java @@ -19,6 +19,8 @@ import org.eclipse.wst.server.core.IServer; * an IModuleArtifact to an ILaunchable. * * <p>This is the implementation of a launchableAdapter extension point.</p> + * + * @since 1.0 */ public abstract class LaunchableAdapterDelegate { /** @@ -26,8 +28,8 @@ public abstract class LaunchableAdapterDelegate { * * @param server * @param moduleObject - * @return - * @exception + * @return the launchable object + * @exception if there was an error doing the conversion */ public abstract ILaunchable getLaunchable(IServer server, IModuleArtifact moduleObject) throws CoreException; }
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/model/ModuleDelegate.java b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/model/ModuleDelegate.java index 3a0636006..d65585800 100644 --- a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/model/ModuleDelegate.java +++ b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/model/ModuleDelegate.java @@ -111,7 +111,7 @@ public abstract class ModuleDelegate { * Returns the current array of module artifacts. * * @param module - * @return + * @return an array containing the module resources */ public abstract IModuleResource[] members() throws CoreException; }
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/model/ModuleEvent.java b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/model/ModuleEvent.java index 6da1a83bb..4c42f5621 100644 --- a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/model/ModuleEvent.java +++ b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/model/ModuleEvent.java @@ -14,6 +14,8 @@ import org.eclipse.core.runtime.IPath; import org.eclipse.wst.server.core.IModule; /** * An event fired when a module changes. + * + * @since 1.0 */ public class ModuleEvent { protected IModule module; diff --git a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/model/ModuleFactoryDelegate.java b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/model/ModuleFactoryDelegate.java index 241281949..549998fb6 100644 --- a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/model/ModuleFactoryDelegate.java +++ b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/model/ModuleFactoryDelegate.java @@ -119,7 +119,7 @@ public abstract class ModuleFactoryDelegate { * associated with the given module. * * @param module a module - * @return + * @return the module delegate */ public abstract ModuleDelegate getModuleDelegate(IModule module); diff --git a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/model/ModuleFactoryEvent.java b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/model/ModuleFactoryEvent.java index 32ff9b3e0..5695d94ee 100644 --- a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/model/ModuleFactoryEvent.java +++ b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/model/ModuleFactoryEvent.java @@ -13,6 +13,8 @@ package org.eclipse.wst.server.core.model; import org.eclipse.wst.server.core.IModule; /** * An event fired when a module factory changes. + * + * @since 1.0 */ public class ModuleFactoryEvent { protected IModule[] added; diff --git a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/model/RuntimeDelegate.java b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/model/RuntimeDelegate.java index 56b288133..a19b979dc 100644 --- a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/model/RuntimeDelegate.java +++ b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/model/RuntimeDelegate.java @@ -141,7 +141,7 @@ public abstract class RuntimeDelegate { return new Status(IStatus.OK, ServerPlugin.PLUGIN_ID, 0, "", null); } - protected boolean isNameInUse() { + private boolean isNameInUse() { IRuntime orig = runtime; if (runtimeWC != null) orig = runtimeWC.getOriginal(); diff --git a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/model/RuntimeLocatorDelegate.java b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/model/RuntimeLocatorDelegate.java index 47decfb67..884aecfa8 100644 --- a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/model/RuntimeLocatorDelegate.java +++ b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/model/RuntimeLocatorDelegate.java @@ -21,7 +21,7 @@ import org.eclipse.wst.server.core.IRuntimeLocator; * to extend the <code>runtimeLocators</code> extension point. * </p> * - * @see IRuntimeLocator + * @see org.eclipse.wst.server.core.IRuntimeLocator * @since 1.0 */ public abstract class RuntimeLocatorDelegate { @@ -35,7 +35,7 @@ public abstract class RuntimeLocatorDelegate { * @param listener a listener to report status to * @param monitor a progress monitor, or <code>null</code> if progress * reporting and cancellation are not desired - * @see IRuntimeLocator.searchForRuntimes(IPath, IRuntimeLocator.RuntimeSearchListener, IProgressMonitor) + * @see org.eclipse.wst.server.core.IRuntimeLocator.searchForRuntimes(IPath, IRuntimeLocator.RuntimeSearchListener, IProgressMonitor) */ public abstract void searchForRuntimes(IPath path, IRuntimeLocator.RuntimeSearchListener listener, IProgressMonitor monitor); }
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/model/RuntimeTargetHandlerDelegate.java b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/model/RuntimeTargetHandlerDelegate.java index b74cde2a0..f547c1894 100644 --- a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/model/RuntimeTargetHandlerDelegate.java +++ b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/model/RuntimeTargetHandlerDelegate.java @@ -17,6 +17,7 @@ import org.eclipse.wst.server.core.IRuntime; import org.eclipse.wst.server.core.IRuntimeTargetHandler; /** * + * @since 1.0 */ public abstract class RuntimeTargetHandlerDelegate { private IRuntimeTargetHandler handler; @@ -33,7 +34,7 @@ public abstract class RuntimeTargetHandlerDelegate { /** * Returns the runtime target handler that this delegate is associated with. * - * @return + * @return the runtime target handler */ public IRuntimeTargetHandler getRuntimeTargetHandler() { return handler; diff --git a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/model/ServerLocatorDelegate.java b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/model/ServerLocatorDelegate.java index 905d21be4..44b1b89ab 100644 --- a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/model/ServerLocatorDelegate.java +++ b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/model/ServerLocatorDelegate.java @@ -20,7 +20,7 @@ import org.eclipse.wst.server.core.IServerLocator; * to extend the <code>serverLocators</code> extension point. * </p> * - * @see IServerLocator + * @see org.eclipse.wst.server.core.IServerLocator * @since 1.0 */ public abstract class ServerLocatorDelegate { @@ -32,7 +32,7 @@ public abstract class ServerLocatorDelegate { * @param listener a listener to report status to * @param monitor a progress monitor, or <code>null</code> if progress * reporting and cancellation are not desired - * @see IServerLocator.searchForServers(IServerLocator.Listener, IProgressMonitor) + * @see org.eclipse.wst.server.core.IServerLocator.searchForServers(String, IServerLocator.Listener, IProgressMonitor) */ public abstract void searchForServers(String host, IServerLocator.Listener listener, IProgressMonitor monitor); }
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/model/ServerTaskDelegate.java b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/model/ServerTaskDelegate.java index 5e4262a72..c204dc519 100644 --- a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/model/ServerTaskDelegate.java +++ b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/model/ServerTaskDelegate.java @@ -19,6 +19,8 @@ import org.eclipse.wst.server.core.IServer; * A server task delegate. * * <p>This is the implementation of a serverTask extension point.</p> + * + * @since 1.0 */ public abstract class ServerTaskDelegate { /** diff --git a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/util/FileUtil.java b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/util/FileUtil.java deleted file mode 100644 index 07bf478bc..000000000 --- a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/util/FileUtil.java +++ /dev/null @@ -1,349 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2005 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 - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.server.core.util; - -import java.io.*; -import java.util.zip.*; -import java.net.URL; -import org.eclipse.core.runtime.*; -import org.eclipse.wst.server.core.internal.ProgressUtil; -import org.eclipse.wst.server.core.internal.ServerPlugin; -import org.eclipse.wst.server.core.internal.Trace; -/** - * Utility class with an assortment of useful file methods. - * - * @deprecated This class will be removed in M4 - */ -public class FileUtil { - // size of the buffer - private static final int BUFFER = 10240; - - // the buffer - private static byte[] buf = new byte[BUFFER]; - - /** - * FileUtil cannot be created. Use static methods. - */ - private FileUtil() { - super(); - } - - /** - * Copys a directory from a to b. - * - * @param from java.lang.String - * @param to java.lang.String - */ - public static void copyDirectory(String from, String to, IProgressMonitor monitor) { - try { - File fromDir = new File(from); - File toDir = new File(to); - - File[] files = fromDir.listFiles(); - - toDir.mkdir(); - - // cycle through files - int size = files.length; - monitor = ProgressUtil.getMonitorFor(monitor); - monitor.beginTask(ServerPlugin.getResource("%copyingTask", new String[] {from, to}), size * 50); - - for (int i = 0; i < size; i++) { - File current = files[i]; - String fromFile = current.getAbsolutePath(); - String toFile = to; - if (!toFile.endsWith(File.separator)) - toFile += File.separator; - toFile += current.getName(); - if (current.isFile()) { - copyFile(fromFile, toFile); - monitor.worked(50); - } else if (current.isDirectory()) { - monitor.subTask(ServerPlugin.getResource("%copyingTask", new String[] {fromFile, toFile})); - copyDirectory(fromFile, toFile, ProgressUtil.getSubMonitorFor(monitor, 50)); - } - if (monitor.isCanceled()) - return; - } - monitor.done(); - } catch (Exception e) { - Trace.trace(Trace.SEVERE, "Error copying directory", e); - } - } - - /** - * Copy a file from a to b. Closes the input stream after use. - * - * @param in java.io.InputStream - * @param to java.lang.String - */ - public static IStatus copyFile(InputStream in, String to) { - OutputStream out = null; - - try { - out = new FileOutputStream(to); - - int avail = in.read(buf); - while (avail > 0) { - out.write(buf, 0, avail); - avail = in.read(buf); - } - return new Status(IStatus.OK, ServerPlugin.PLUGIN_ID, 0, ServerPlugin.getResource("%copyingTask", new String[] {to}), null); - } catch (Exception e) { - Trace.trace(Trace.SEVERE, "Error copying file", e); - return new Status(IStatus.ERROR, ServerPlugin.PLUGIN_ID, 0, ServerPlugin.getResource("%errorCopyingFile", new String[] {to, e.getLocalizedMessage()}), e); - } finally { - try { - if (in != null) - in.close(); - } catch (Exception ex) { - // ignore - } - try { - if (out != null) - out.close(); - } catch (Exception ex) { - // ignore - } - } - } - - /** - * Copy a file from a to b. - * - * @param from java.lang.String - * @param to java.lang.String - */ - public static IStatus copyFile(String from, String to) { - try { - return copyFile(new FileInputStream(from), to); - } catch (Exception e) { - Trace.trace(Trace.SEVERE, "Error copying file", e); - return new Status(IStatus.ERROR, ServerPlugin.PLUGIN_ID, 0, ServerPlugin.getResource("%errorCopyingFile", new String[] {to, e.getLocalizedMessage()}), e); - } - } - - /** - * Copy a file from a to b. - * - * @param from java.net.URL - * @param to java.lang.String - */ - public static IStatus copyFile(URL from, String to) { - try { - return copyFile(from.openStream(), to); - } catch (Exception e) { - Trace.trace(Trace.SEVERE, "Error copying file", e); - return new Status(IStatus.ERROR, ServerPlugin.PLUGIN_ID, 0, ServerPlugin.getResource("%errorCopyingFile", new String[] {to, e.getLocalizedMessage()}), e); - } - } - - /** - * Recursively deletes a directory. - * - * @param dir java.io.File - */ - public static void deleteDirectory(File dir, IProgressMonitor monitor) { - try { - if (!dir.exists() || !dir.isDirectory()) - return; - - File[] files = dir.listFiles(); - int size = files.length; - monitor = ProgressUtil.getMonitorFor(monitor); - monitor.beginTask(ServerPlugin.getResource("%deletingTask", new String[] {dir.getAbsolutePath()}), size * 10); - - // cycle through files - for (int i = 0; i < size; i++) { - File current = files[i]; - if (current.isFile()) { - current.delete(); - monitor.worked(10); - } else if (current.isDirectory()) { - monitor.subTask(ServerPlugin.getResource("%deletingTask", new String[] {current.getAbsolutePath()})); - deleteDirectory(current, ProgressUtil.getSubMonitorFor(monitor, 10)); - } - } - dir.delete(); - monitor.done(); - } catch (Exception e) { - Trace.trace(Trace.SEVERE, "Error deleting directory " + dir.getAbsolutePath(), e); - } - } - - /** - * Expand a zip file to a given directory. - * - * @param zipFile java.io.File - * @param dir java.io.File - */ - public static void expandZip(File zipFile, File dir, IProgressMonitor monitor) { - ZipInputStream zis = null; - - try { - // first, count number of items in zip file - zis = new ZipInputStream(new FileInputStream(zipFile)); - int count = 0; - while (zis.getNextEntry() != null) - count++; - - monitor = ProgressUtil.getMonitorFor(monitor); - monitor.beginTask(ServerPlugin.getResource("%unZippingTask", new String[] {zipFile.getName()}), count); - - zis = new ZipInputStream(new FileInputStream(zipFile)); - ZipEntry ze = zis.getNextEntry(); - - FileOutputStream out = null; - - while (ze != null) { - try { - monitor.subTask(ServerPlugin.getResource("%expandingTask", new String[] {ze.getName()})); - File f = new File(dir, ze.getName()); - - if (ze.isDirectory()) { - out = null; - f.mkdirs(); - } else { - out = new FileOutputStream(f); - - int avail = zis.read(buf); - while (avail > 0) { - out.write(buf, 0, avail); - avail = zis.read(buf); - } - } - } catch (FileNotFoundException ex) { - Trace.trace(Trace.SEVERE, "Error extracting " + ze.getName() + " from zip " + zipFile.getAbsolutePath(), ex); - } finally { - try { - if (out != null) - out.close(); - } catch (Exception e) { - // ignore - } - } - ze = zis.getNextEntry(); - monitor.worked(1); - if (monitor.isCanceled()) - return; - } - monitor.done(); - } catch (Exception e) { - Trace.trace(Trace.SEVERE, "Error expanding zip file " + zipFile.getAbsolutePath(), e); - } finally { - try { - if (zis != null) - zis.close(); - } catch (Exception ex) { - // ignore - } - } - } - - /** - * Copys a directory from a to b, only modifying as needed - * and deleting old files and directories. - * - * @param from java.lang.String - * @param to java.lang.String - * @param IProgressMonitor - */ - public static void smartCopyDirectory(String from, String to, IProgressMonitor monitor) { - try { - File fromDir = new File(from); - File toDir = new File(to); - - File[] fromFiles = fromDir.listFiles(); - int fromSize = fromFiles.length; - - monitor = ProgressUtil.getMonitorFor(monitor); - monitor.beginTask(ServerPlugin.getResource("%copyingTask", new String[] {from, to}), 550); - - File[] toFiles = null; - - // delete old files and directories from this directory - if (toDir.exists() && toDir.isDirectory()) { - toFiles = toDir.listFiles(); - int toSize = toFiles.length; - - // check if this exact file exists in the new directory - for (int i = 0; i < toSize; i++) { - String name = toFiles[i].getName(); - boolean isDir = toFiles[i].isDirectory(); - boolean found = false; - for (int j = 0; j < fromSize; j++) { - if (name.equals(fromFiles[j].getName()) && isDir == fromFiles[j].isDirectory()) - found = true; - } - - // delete file if it can't be found or isn't the correct type - if (!found) { - if (isDir) - deleteDirectory(toFiles[i], new NullProgressMonitor()); - else - toFiles[i].delete(); - } - if (monitor.isCanceled()) - return; - } - } else { - if (toDir.isFile()) - toDir.delete(); - toDir.mkdir(); - } - monitor.worked(50); - - // cycle through files and only copy when it doesn't exist - // or is newer - toFiles = toDir.listFiles(); - int toSize = toFiles.length; - int dw = 0; - if (toSize > 0) - dw = 500 / toSize; - - for (int i = 0; i < fromSize; i++) { - File current = fromFiles[i]; - - // check if this is a new or newer file - boolean copy = true; - if (!current.isDirectory()) { - String name = current.getName(); - long mod = current.lastModified(); - for (int j = 0; j < toSize; j++) { - if (name.equals(toFiles[j].getName()) && mod <= toFiles[j].lastModified()) - copy = false; - } - } - - if (copy) { - String fromFile = current.getAbsolutePath(); - String toFile = to; - if (!toFile.endsWith(File.separator)) - toFile += File.separator; - toFile += current.getName(); - if (current.isFile()) { - copyFile(fromFile, toFile); - monitor.worked(dw); - } else if (current.isDirectory()) { - monitor.subTask(ServerPlugin.getResource("%copyingTask", new String[] {fromFile, toFile})); - smartCopyDirectory(fromFile, toFile, ProgressUtil.getSubMonitorFor(monitor, dw)); - } - } - if (monitor.isCanceled()) - return; - } - monitor.worked(500 - dw * toSize); - monitor.done(); - } catch (Exception e) { - Trace.trace(Trace.SEVERE, "Error smart copying directory " + from + " - " + to, e); - } - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/util/HttpLaunchable.java b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/util/HttpLaunchable.java index 004a2d96d..8dabd43eb 100644 --- a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/util/HttpLaunchable.java +++ b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/util/HttpLaunchable.java @@ -15,25 +15,20 @@ import java.net.URL; import org.eclipse.wst.server.core.ILaunchable; /** * + * @since 1.0 */ public class HttpLaunchable implements ILaunchable { - public static final String ID = "http.launchable"; - private URL url; public HttpLaunchable(URL url) { this.url = url; } - public String getId() { - return ID; - } - public URL getURL() { return url; } public String toString() { - return "HttpLaunchable[id=" + getId() + ", url=" + url.toString() + "]"; + return "HttpLaunchable[url=" + url.toString() + "]"; } }
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/util/IStaticWeb.java b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/util/IStaticWeb.java index d0310700e..97471a445 100644 --- a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/util/IStaticWeb.java +++ b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/util/IStaticWeb.java @@ -12,6 +12,8 @@ package org.eclipse.wst.server.core.util; /** * A static Web module that could be deployed to Apache or another * HTTP server. + * + * @since 1.0 */ public interface IStaticWeb { /** diff --git a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/util/NullModuleArtifact.java b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/util/NullModuleArtifact.java index eb97ebb56..80cc6cfa0 100644 --- a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/util/NullModuleArtifact.java +++ b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/util/NullModuleArtifact.java @@ -14,20 +14,15 @@ import org.eclipse.wst.server.core.IModule; import org.eclipse.wst.server.core.IModuleArtifact; /** * + * @since 1.0 */ public class NullModuleArtifact implements IModuleArtifact { - public static final String ID = "org.eclipse.wst.server.core.null"; - private IModule module; public NullModuleArtifact(IModule module) { this.module = module; } - public String getId() { - return ID; - } - public IModule getModule() { return module; } diff --git a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/util/PingThread.java b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/util/PingThread.java index 40f33c49d..beadfefe5 100644 --- a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/util/PingThread.java +++ b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/util/PingThread.java @@ -20,6 +20,8 @@ import org.eclipse.wst.server.core.internal.Trace; import org.eclipse.wst.server.core.model.ServerBehaviourDelegate; /** * Thread used to ping server to test when it is started. + * + * @since 1.0 */ public class PingThread { // delay before pinging starts @@ -42,7 +44,7 @@ public class PingThread { * @param server2 * @param server * @param url - * @param mode + * @param maxPings */ public PingThread(IServer server2, ServerBehaviourDelegate server, String url, int maxPings) { super(); diff --git a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/util/ProjectModule.java b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/util/ProjectModule.java index 8f77e5ae4..4fd27f2bd 100644 --- a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/util/ProjectModule.java +++ b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/util/ProjectModule.java @@ -23,6 +23,8 @@ import org.eclipse.wst.server.core.model.*; /** * A simple IModuleProject that maps a folder within a project * (or the root of the project itself) to the module. + * + * @since 1.0 */ public abstract class ProjectModule extends ModuleDelegate { protected IProject project; diff --git a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/util/ProjectModuleFactoryDelegate.java b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/util/ProjectModuleFactoryDelegate.java index 68748d528..26ddeda94 100644 --- a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/util/ProjectModuleFactoryDelegate.java +++ b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/util/ProjectModuleFactoryDelegate.java @@ -21,6 +21,8 @@ import org.eclipse.wst.server.core.internal.Trace; import org.eclipse.wst.server.core.model.ModuleFactoryDelegate; /** * + * + * @since 1.0 */ public abstract class ProjectModuleFactoryDelegate extends ModuleFactoryDelegate { protected static IResourceChangeListener listener; diff --git a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/util/RuntimeLifecycleAdapter.java b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/util/RuntimeLifecycleAdapter.java index b62dd04b0..63b55ddea 100644 --- a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/util/RuntimeLifecycleAdapter.java +++ b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/util/RuntimeLifecycleAdapter.java @@ -15,6 +15,9 @@ import org.eclipse.wst.server.core.IRuntimeLifecycleListener; /** * Helper class which implements the IRuntimeLifecycleListener interface * with empty methods. + * + * @see org.eclipse.wst.server.core.IRuntimeLifecycleListener + * @since 1.0 */ public class RuntimeLifecycleAdapter implements IRuntimeLifecycleListener { public void runtimeAdded(IRuntime runtime) { diff --git a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/util/ServerAdapter.java b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/util/ServerAdapter.java index c06287c57..162d523c1 100644 --- a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/util/ServerAdapter.java +++ b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/util/ServerAdapter.java @@ -16,53 +16,27 @@ import org.eclipse.wst.server.core.IServerListener; /** * Helper class which implements the IServerListener interface * with empty methods. + * + * @see org.eclipse.wst.server.core.IServerListener + * @since 1.0 */ public abstract class ServerAdapter implements IServerListener { - /** - * Called when the server configuration's sync state changes. - * - * @param server org.eclipse.wst.server.IServer - */ public void configurationSyncStateChange(IServer server) { // do nothing } - /** - * Called when the server isRestartNeeded() property changes. - * - * @param server org.eclipse.wst.server.IServer - */ public void restartStateChange(IServer server) { // do nothing } - /** - * Notification when the server state has changed. - * - * @param server org.eclipse.wst.server.IServer - */ public void serverStateChange(IServer server) { // do nothing } - /** - * Called when the modules tree of this server has changed. - * - * @param server org.eclipse.wst.server.IServer - */ public void modulesChanged(IServer server) { // do nothing } - /** - * Fired when a module on this server needs to be published - * or no longer needs to be published, or it's state has - * changed. - * - * @param server org.eclipse.wst.server.IServer - * @param parents org.eclipse.wst.server.IModule[] - * @param module org.eclipse.wst.server.IModule - */ public void moduleStateChange(IServer server, IModule[] parents, IModule module) { // do nothing } diff --git a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/util/ServerLifecycleAdapter.java b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/util/ServerLifecycleAdapter.java index 63953eeb4..581561b3c 100644 --- a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/util/ServerLifecycleAdapter.java +++ b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/util/ServerLifecycleAdapter.java @@ -15,6 +15,9 @@ import org.eclipse.wst.server.core.IServerLifecycleListener; /** * Helper class which implements the IServerLifecycleListener interface * with empty methods. + * + * @see org.eclipse.wst.server.core.IServerLifecycleListener + * @since 1.0 */ public class ServerLifecycleAdapter implements IServerLifecycleListener { public void serverAdded(IServer server) { diff --git a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/util/ServerPort.java b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/util/ServerPort.java index 6cb5ca0f8..84cd41f03 100644 --- a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/util/ServerPort.java +++ b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/util/ServerPort.java @@ -13,6 +13,8 @@ package org.eclipse.wst.server.core.util; import org.eclipse.wst.server.core.IServerPort; /** * A default implementation of the IServerPort interface. + * + * @since 1.0 */ public class ServerPort implements IServerPort { private String id; diff --git a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/util/SocketUtil.java b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/util/SocketUtil.java index d143e09f1..25de3bae2 100644 --- a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/util/SocketUtil.java +++ b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/util/SocketUtil.java @@ -22,7 +22,9 @@ import sun.net.spi.nameservice.dns.DNSNameService; /** * A utility class for socket-related function. It's main purposes are to find * unused ports, check whether a port is in use, and check whether a given - * address is a local(host) address. + * address is a local(host) address. + * + * @since 1.0 */ public class SocketUtil { private static final Random rand = new Random(System.currentTimeMillis()); @@ -32,14 +34,16 @@ public class SocketUtil { /** * Finds an unused port between the given from and to values. * - * @param host - * @param searchFrom - * @param searchTo - * @return + * @param low lowest possible port number + * @param high highest possible port number + * @return an usused port number, or <code>-1</code> if no used ports could be found */ - public static int findUnusedPort(int searchFrom, int searchTo) { + public static int findUnusedPort(int low, int high) { + if (high < low) + return -1; + for (int i = 0; i < 10; i++) { - int port = getRandomPort(searchFrom, searchTo); + int port = getRandomPort(low, high); if (!isPortInUse(port)) return port; } diff --git a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/util/Task.java b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/util/Task.java index 71da9044e..69dc54bbd 100644 --- a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/util/Task.java +++ b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/util/Task.java @@ -13,7 +13,9 @@ package org.eclipse.wst.server.core.util; import org.eclipse.wst.server.core.*; /** * An abstract implementation of the org.eclipse.wst.server.core.ITask interface - * that provides default implementation of the methods. + * that provides default implementation of the methods. + * + * @since 1.0 */ public abstract class Task implements ITask { private ITaskModel model; diff --git a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/util/TaskModel.java b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/util/TaskModel.java index 0fc2213dc..e6a3174eb 100644 --- a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/util/TaskModel.java +++ b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/util/TaskModel.java @@ -16,7 +16,9 @@ import java.util.Map; import org.eclipse.wst.server.core.*; /** * An implementation of the org.eclipse.wst.server.core.ITaskModel interface - * that provides a default implementation of the methods. + * that provides a default implementation of the methods. + * + * @since 1.0 */ public class TaskModel implements ITaskModel { private Map map = new HashMap(); diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/ServerLaunchConfigurationTab.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/ServerLaunchConfigurationTab.java index ff94ba7ed..f024c5073 100644 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/ServerLaunchConfigurationTab.java +++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/ServerLaunchConfigurationTab.java @@ -30,9 +30,12 @@ import org.eclipse.swt.widgets.Label; import org.eclipse.ui.PlatformUI; import org.eclipse.wst.server.core.*; +import org.eclipse.wst.server.core.internal.Server; import org.eclipse.wst.server.ui.internal.*; /** * Server launch configuration tab. + * + * @since 1.0 */ public class ServerLaunchConfigurationTab extends AbstractLaunchConfigurationTab { protected String[] serverTypeIds; @@ -59,7 +62,7 @@ public class ServerLaunchConfigurationTab extends AbstractLaunchConfigurationTab this.serverTypeIds = serverTypeIds; } - /** + /* * @see ILaunchConfigurationTab#createControl(Composite) */ public void createControl(Composite parent) { @@ -173,7 +176,7 @@ public class ServerLaunchConfigurationTab extends AbstractLaunchConfigurationTab super.updateLaunchConfigurationDialog(); } - /** + /* * @see ILaunchConfigurationTab#setDefaults(ILaunchConfigurationWorkingCopy) */ public void setDefaults(ILaunchConfigurationWorkingCopy configuration) { @@ -188,14 +191,14 @@ public class ServerLaunchConfigurationTab extends AbstractLaunchConfigurationTab server = (IServer) servers.get(serverCombo.getSelectionIndex()); if (server != null) try { - server.setupLaunchConfiguration(configuration, null); + ((Server) server).setupLaunchConfiguration(configuration, null); } catch (CoreException ce) { Trace.trace(Trace.SEVERE, "Error setting up launch configuration", ce); } } } - /** + /* * @see ILaunchConfigurationTab#initializeFrom(ILaunchConfiguration) */ public void initializeFrom(ILaunchConfiguration configuration) { @@ -230,7 +233,7 @@ public class ServerLaunchConfigurationTab extends AbstractLaunchConfigurationTab } } - /** + /* * @see ILaunchConfigurationTab#performApply(ILaunchConfigurationWorkingCopy) */ public void performApply(ILaunchConfigurationWorkingCopy configuration) { @@ -240,7 +243,7 @@ public class ServerLaunchConfigurationTab extends AbstractLaunchConfigurationTab configuration.setAttribute(IServerAttributes.ATTR_SERVER_ID, (String)null); } - /** + /* * @see ILaunchConfigurationTab#isValid() */ public boolean isValid() { @@ -249,7 +252,7 @@ public class ServerLaunchConfigurationTab extends AbstractLaunchConfigurationTab return false; } - /** + /* * @see ILaunchConfigurationTab#isValid(ILaunchConfiguration) */ public boolean isValid(ILaunchConfiguration launchConfig) { @@ -272,7 +275,7 @@ public class ServerLaunchConfigurationTab extends AbstractLaunchConfigurationTab return ImageResource.getImage(ImageResource.IMG_SERVER); } - /** + /* * @see ILaunchConfigurationTab#getName() */ public String getName() { diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/ServerUICore.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/ServerUICore.java index 16afb6a08..d8e9b25d5 100644 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/ServerUICore.java +++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/ServerUICore.java @@ -10,128 +10,27 @@ *******************************************************************************/ package org.eclipse.wst.server.ui; -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; - -import org.eclipse.core.runtime.IConfigurationElement; -import org.eclipse.core.runtime.IExtensionRegistry; -import org.eclipse.core.runtime.Platform; -import org.eclipse.jface.action.Action; import org.eclipse.jface.viewers.ILabelProvider; -import org.eclipse.jface.viewers.StructuredSelection; import org.eclipse.wst.server.ui.internal.ServerLabelProvider; -import org.eclipse.wst.server.ui.internal.ServerUIPlugin; -import org.eclipse.wst.server.ui.internal.Trace; -import org.eclipse.wst.server.ui.internal.actions.RunOnServerActionDelegate; -import org.eclipse.wst.server.ui.wizard.WizardFragment; /** * Server UI core. + * + * @since 1.0 */ public class ServerUICore { private static ServerLabelProvider labelProvider; - // cached copy of all runtime wizards - private static Map wizardFragments; - - static class WizardFragmentData { - String id; - IConfigurationElement ce; - WizardFragment fragment; - - public WizardFragmentData(String id, IConfigurationElement ce) { - this.id = id; - this.ce = ce; - } - } - /** * ServerUICore constructor comment. */ private ServerUICore() { super(); } - - /** - * Returns the wizard fragment with the given id. - * - * @return - */ - public static WizardFragment getWizardFragment(String typeId) { - if (typeId == null) - return null; - - if (wizardFragments == null) - loadWizardFragments(); - - Iterator iterator = wizardFragments.keySet().iterator(); - while (iterator.hasNext()) { - String key = (String) iterator.next(); - if (typeId.equals(key)) { - WizardFragmentData data = (WizardFragmentData) wizardFragments.get(key); - return getWizardFragment(data); - } - } - return null; - } - - /** - * Load the wizard fragments. - */ - private static synchronized void loadWizardFragments() { - if (wizardFragments != null) - return; - Trace.trace(Trace.CONFIG, "->- Loading .wizardFragments extension point ->-"); - IExtensionRegistry registry = Platform.getExtensionRegistry(); - IConfigurationElement[] cf = registry.getConfigurationElementsFor(ServerUIPlugin.PLUGIN_ID, "wizardFragments"); - - int size = cf.length; - wizardFragments = new HashMap(size); - for (int i = 0; i < size; i++) { - try { - String id = cf[i].getAttribute("typeIds"); - wizardFragments.put(id, new WizardFragmentData(id, cf[i])); - Trace.trace(Trace.CONFIG, " Loaded wizardFragment: " + id); - } catch (Throwable t) { - Trace.trace(Trace.SEVERE, " Could not load wizardFragment: " + cf[i].getAttribute("id"), t); - } - } - - Trace.trace(Trace.CONFIG, "-<- Done loading .wizardFragments extension point -<-"); - } - - protected static WizardFragment getWizardFragment(WizardFragmentData fragment) { - if (fragment == null) - return null; - - if (fragment.fragment == null) { - try { - fragment.fragment = (WizardFragment) fragment.ce.createExecutableExtension("class"); - } catch (Throwable t) { - Trace.trace(Trace.SEVERE, "Could not create wizardFragment: " + fragment.ce.getAttribute("id"), t); - } - } - return fragment.fragment; - } public static ILabelProvider getLabelProvider() { if (labelProvider == null) labelProvider = new ServerLabelProvider(); return labelProvider; } - - public static void runOnServer(Object object, String launchMode) { - RunOnServerActionDelegate delegate = new RunOnServerActionDelegate(); - Action action = new Action() { - // dummy action - }; - if (object != null) { - StructuredSelection sel = new StructuredSelection(object); - delegate.selectionChanged(action, sel); - } else - delegate.selectionChanged(action, null); - - delegate.run(action); - } }
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/ServerUIUtil.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/ServerUIUtil.java index 5a67a8e9c..002332c2f 100644 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/ServerUIUtil.java +++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/ServerUIUtil.java @@ -10,21 +10,13 @@ **********************************************************************/ package org.eclipse.wst.server.ui; -import java.util.List; - -import org.eclipse.jface.dialogs.IDialogConstants; -import org.eclipse.wst.server.core.*; import org.eclipse.wst.server.ui.internal.ServerUIPlugin; -import org.eclipse.wst.server.ui.internal.task.FinishWizardFragment; -import org.eclipse.wst.server.ui.internal.task.InputWizardFragment; -import org.eclipse.wst.server.ui.internal.task.SaveRuntimeTask; -import org.eclipse.wst.server.ui.internal.wizard.ClosableWizardDialog; -import org.eclipse.wst.server.ui.internal.wizard.fragment.NewRuntimeWizardFragment; -import org.eclipse.wst.server.ui.wizard.*; import org.eclipse.swt.widgets.Shell; /** * Server UI utility methods. + * + * @since 1.0 */ public class ServerUIUtil { /** @@ -38,74 +30,11 @@ public class ServerUIUtil { * Open the new runtime wizard. * * @param shell - * @param runtimeTypeId - * @return - */ - public static boolean showNewRuntimeWizard(Shell shell, final String runtimeTypeId) { - IRuntimeType runtimeType = null; - if (runtimeTypeId != null) - runtimeType = ServerCore.findRuntimeType(runtimeTypeId); - if (runtimeType != null) { - try { - final IRuntimeWorkingCopy runtime = runtimeType.createRuntime(null, null); - WizardFragment fragment = new WizardFragment() { - protected void createChildFragments(List list) { - list.add(new InputWizardFragment(ITaskModel.TASK_RUNTIME, runtime)); - list.add(ServerUICore.getWizardFragment(runtimeTypeId)); - list.add(new FinishWizardFragment(new SaveRuntimeTask())); - } - }; - TaskWizard wizard = new TaskWizard(ServerUIPlugin.getResource("%wizNewRuntimeWizardTitle"), fragment); - wizard.setForcePreviousAndNextButtons(true); - ClosableWizardDialog dialog = new ClosableWizardDialog(shell, wizard); - return (dialog.open() == IDialogConstants.OK_ID); - } catch (Exception e) { - return false; - } - } - return showNewRuntimeWizard(shell, null, null, runtimeTypeId); - } - - /** - * Open the new runtime wizard. - * @param shell - * @return - */ - public static boolean showNewRuntimeWizard(Shell shell) { - return showNewRuntimeWizard(shell, null, null); - } - - /** - * Open the new runtime wizard. - * - * @param shell * @param type * @param version * @return */ public static boolean showNewRuntimeWizard(Shell shell, final String type, final String version) { - return showNewRuntimeWizard(shell, type, version, null); - } - - /** - * Open the new runtime wizard. - * - * @param shell - * @param type - * @param version - * @param runtimeTypeId - * @return - */ - public static boolean showNewRuntimeWizard(Shell shell, final String type, final String version, final String runtimeTypeId) { - WizardFragment fragment = new WizardFragment() { - protected void createChildFragments(List list) { - list.add(new NewRuntimeWizardFragment(type, version, runtimeTypeId)); - list.add(new FinishWizardFragment(new SaveRuntimeTask())); - } - }; - TaskWizard wizard = new TaskWizard(ServerUIPlugin.getResource("%wizNewRuntimeWizardTitle"), fragment); - wizard.setForcePreviousAndNextButtons(true); - ClosableWizardDialog dialog = new ClosableWizardDialog(shell, wizard); - return (dialog.open() == IDialogConstants.OK_ID); + return ServerUIPlugin.showNewRuntimeWizard(shell, type, version, null); } }
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/actions/DebugOnServerAction.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/actions/DebugOnServerAction.java index 35051221f..1c036f269 100644 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/actions/DebugOnServerAction.java +++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/actions/DebugOnServerAction.java @@ -20,6 +20,8 @@ import org.eclipse.wst.server.ui.internal.actions.DebugOnServerActionDelegate; * object, and have automatic server creation, launching, and * the appropriate client to appear. A new instance of this * action must be created for each object that the user selects. + * + * @since 1.0 */ public class DebugOnServerAction extends Action { protected DebugOnServerActionDelegate delegate; diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/actions/LaunchWizardAction.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/actions/LaunchWizardAction.java index 9b1f17ff5..560c7ae61 100644 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/actions/LaunchWizardAction.java +++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/actions/LaunchWizardAction.java @@ -21,6 +21,8 @@ import org.eclipse.ui.IWorkbenchWizard; import org.eclipse.ui.PlatformUI; /** * An abstract action that opens up a workbench wizard when run. + * + * @since 1.0 */ abstract class LaunchWizardAction extends Action { /** diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/actions/NewServerAction.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/actions/NewServerAction.java index 39de1c094..8b32dc1bf 100644 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/actions/NewServerAction.java +++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/actions/NewServerAction.java @@ -16,6 +16,8 @@ import org.eclipse.wst.server.ui.internal.ServerUIPlugin; import org.eclipse.wst.server.ui.internal.wizard.NewServerWizard; /** * An action to invoke the new server and server configuration wizard. + * + * @since 1.0 */ public class NewServerAction extends LaunchWizardAction { protected String[] ids; diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/actions/ProfileOnServerAction.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/actions/ProfileOnServerAction.java index 9a9d377ce..8229dc0c6 100644 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/actions/ProfileOnServerAction.java +++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/actions/ProfileOnServerAction.java @@ -20,6 +20,8 @@ import org.eclipse.wst.server.ui.internal.actions.ProfileOnServerActionDelegate; * object, and have automatic server creation, launching, and * the appropriate client to appear. A new instance of this * action must be created for each object that the user selects. + * + * @since 1.0 */ public class ProfileOnServerAction extends Action { protected ProfileOnServerActionDelegate delegate; diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/actions/RestartProjectAction.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/actions/RestartProjectAction.java index 76970ec91..b2d2c1369 100644 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/actions/RestartProjectAction.java +++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/actions/RestartProjectAction.java @@ -18,6 +18,8 @@ import org.eclipse.wst.server.ui.internal.actions.RestartProjectActionDelegate; /** * Action to restart an individual project on servers that * support it. + * + * @since 1.0 */ public class RestartProjectAction extends Action { protected RestartProjectActionDelegate delegate; diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/actions/RunOnServerAction.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/actions/RunOnServerAction.java index 8eed1ecdc..d06949310 100644 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/actions/RunOnServerAction.java +++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/actions/RunOnServerAction.java @@ -20,6 +20,8 @@ import org.eclipse.wst.server.ui.internal.actions.RunOnServerActionDelegate; * object, and have automatic server creation, launching, and * the appropriate client to appear. A new instance of this * action must be created for each object that the user selects. + * + * @since 1.0 */ public class RunOnServerAction extends Action { protected RunOnServerActionDelegate delegate; diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/editor/ICommandManager.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/editor/ICommandManager.java index 4f7a61686..ccba52f9a 100644 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/editor/ICommandManager.java +++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/editor/ICommandManager.java @@ -13,6 +13,8 @@ package org.eclipse.wst.server.ui.editor; import org.eclipse.wst.server.core.ITask; /** * A command manager. + * + * @since 1.0 */ public interface ICommandManager { /** diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/editor/IOrdered.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/editor/IOrdered.java index aee3d85d2..ff05a3699 100644 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/editor/IOrdered.java +++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/editor/IOrdered.java @@ -22,6 +22,8 @@ package org.eclipse.wst.server.ui.editor; * </p> * * <p>This interface is not intended to be implemented by clients.</p> + * + * @since 1.0 */ public interface IOrdered { /** diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/editor/IServerEditorInput.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/editor/IServerEditorInput.java index 99d7ae740..5eae31047 100644 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/editor/IServerEditorInput.java +++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/editor/IServerEditorInput.java @@ -18,6 +18,8 @@ import org.eclipse.ui.IEditorInput; * and server configuration. * * <p>This interface is not intended to be implemented by clients.</p> + * + * @since 1.0 */ public interface IServerEditorInput extends IEditorInput { public static final String EDITOR_ID = ServerUIPlugin.PLUGIN_ID + ".editor"; diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/editor/IServerEditorPartInput.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/editor/IServerEditorPartInput.java index c2e57a4da..a939513d2 100644 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/editor/IServerEditorPartInput.java +++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/editor/IServerEditorPartInput.java @@ -15,6 +15,8 @@ import org.eclipse.ui.IEditorInput; import org.eclipse.wst.server.core.IServerWorkingCopy; /** * + * + * @since 1.0 */ public interface IServerEditorPartInput extends IEditorInput { /** diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/editor/IServerEditorSection.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/editor/IServerEditorSection.java index fd9920969..7527abc26 100644 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/editor/IServerEditorSection.java +++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/editor/IServerEditorSection.java @@ -16,6 +16,7 @@ import org.eclipse.ui.IEditorInput; import org.eclipse.ui.IEditorSite; /** * + * @since 1.0 */ public interface IServerEditorSection { public void init(IEditorSite site, IEditorInput input); diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/editor/ServerEditorActionFactoryDelegate.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/editor/ServerEditorActionFactoryDelegate.java index 4f46ed800..ea0001705 100644 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/editor/ServerEditorActionFactoryDelegate.java +++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/editor/ServerEditorActionFactoryDelegate.java @@ -16,6 +16,7 @@ import org.eclipse.ui.IEditorSite; import org.eclipse.wst.server.core.IServerWorkingCopy; /** * + * @since 1.0 */ public abstract class ServerEditorActionFactoryDelegate { /** diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/editor/ServerEditorPageSectionFactoryDelegate.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/editor/ServerEditorPageSectionFactoryDelegate.java index 6c4ce642c..f823bae90 100644 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/editor/ServerEditorPageSectionFactoryDelegate.java +++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/editor/ServerEditorPageSectionFactoryDelegate.java @@ -12,7 +12,8 @@ package org.eclipse.wst.server.ui.editor; import org.eclipse.wst.server.core.IServerWorkingCopy; /** - * + * + * @since 1.0 */ public abstract class ServerEditorPageSectionFactoryDelegate { /** 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 9bbd4ae43..5b083541d 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 @@ -31,6 +31,8 @@ import org.eclipse.wst.server.ui.internal.editor.ServerEditorCore; * * This class also provides each editor page with an error message which * will be displayed on the status bar of the editor. + * + * @since 1.0 */ public abstract class ServerEditorPart extends EditorPart { public static final int PROP_ERROR = 5; diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/editor/ServerEditorPartFactoryDelegate.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/editor/ServerEditorPartFactoryDelegate.java index 9e3c61835..b34063c2f 100644 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/editor/ServerEditorPartFactoryDelegate.java +++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/editor/ServerEditorPartFactoryDelegate.java @@ -15,6 +15,7 @@ import org.eclipse.ui.IEditorPart; import org.eclipse.wst.server.core.IServerWorkingCopy; /** * + * @since 1.0 */ public abstract class ServerEditorPartFactoryDelegate { /** 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 c67fdc3e9..5bb025d42 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 @@ -20,6 +20,8 @@ import org.eclipse.ui.forms.widgets.FormToolkit; import org.eclipse.wst.server.core.IServerWorkingCopy; /** * + * + * @since 1.0 */ public abstract class ServerEditorSection implements IServerEditorSection { private String errorMessage = null; diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/ContextIds.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/ContextIds.java index 7a6f4e6de..8d28a4a22 100644 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/ContextIds.java +++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/ContextIds.java @@ -59,7 +59,7 @@ public interface ContextIds { public static final String PREF_GENERAL_SHOW_PUBLISHING_DETAILS = ServerUIPlugin.PLUGIN_ID + ".spge0010"; public static final String PREF_GENERAL_PUBLISH_BEFORE_START = ServerUIPlugin.PLUGIN_ID + ".spge0012"; public static final String PREF_GENERAL_AUTO_RESTART = ServerUIPlugin.PLUGIN_ID + ".spge0014"; - public static final String PREF_GENERAL_PUBLISHER = ServerUIPlugin.PLUGIN_ID + ".spge0015"; + public static final String PREF_GENERAL_SHOW_ON_ACTIVITY = ServerUIPlugin.PLUGIN_ID + ".spge0016"; public static final String PREF_GENERAL_REPAIR = ServerUIPlugin.PLUGIN_ID + ".spge0018"; public static final String PREF_GENERAL_PROMPT_IRREVERSIBLE = ServerUIPlugin.PLUGIN_ID + ".spge0020"; public static final String PREF_GENERAL_CREATE_IN_WORKSPACE = ServerUIPlugin.PLUGIN_ID + ".spge0022"; diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/EclipseUtil.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/EclipseUtil.java index d0d9e31ec..b5d523321 100644 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/EclipseUtil.java +++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/EclipseUtil.java @@ -24,6 +24,7 @@ import org.eclipse.ui.model.IWorkbenchAdapter; import org.eclipse.wst.server.core.IServer; import org.eclipse.wst.server.core.ServerCore; +import org.eclipse.wst.server.core.internal.ProjectProperties; /** * Eclipse utility methods. */ @@ -64,7 +65,7 @@ public class EclipseUtil { return null; // add the server project nature - ServerCore.getProjectProperties(project).setServerProject(true, monitor); + ((ProjectProperties)ServerCore.getProjectProperties(project)).setServerProject(true, monitor); if (monitor.isCanceled()) return null; diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/LaunchClientJob.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/LaunchClientJob.java index 27fd42bdc..00125ba1e 100644 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/LaunchClientJob.java +++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/LaunchClientJob.java @@ -83,7 +83,7 @@ public class LaunchClientJob extends Job { Trace.trace(Trace.FINEST, "Attempting to load client: " + client); try { ILaunchable launchable = launchableAdapter.getLaunchable(server, moduleArtifact); - client.launch(server, launchable, launchMode, server.getExistingLaunch()); + client.launch(server, launchable, launchMode, ((Server) server).getExistingLaunch()); } catch (Exception e) { Trace.trace(Trace.SEVERE, "Server client failed", e); } diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/RuntimePreferencePage.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/RuntimePreferencePage.java index 2189db35a..6665466b8 100644 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/RuntimePreferencePage.java +++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/RuntimePreferencePage.java @@ -43,7 +43,6 @@ import org.eclipse.ui.IWorkbench; import org.eclipse.ui.IWorkbenchPreferencePage; import org.eclipse.ui.PlatformUI; import org.eclipse.wst.server.core.*; -import org.eclipse.wst.server.ui.ServerUICore; import org.eclipse.wst.server.ui.internal.task.FinishWizardFragment; import org.eclipse.wst.server.ui.internal.task.SaveRuntimeTask; import org.eclipse.wst.server.ui.internal.viewers.RuntimeComposite; @@ -329,7 +328,7 @@ public class RuntimePreferencePage extends PreferencePage implements IWorkbenchP }; } else { title = ServerUIPlugin.getResource("%wizEditRuntimeWizardTitle"); - final WizardFragment fragment2 = ServerUICore.getWizardFragment(runtimeWorkingCopy.getRuntimeType().getId()); + final WizardFragment fragment2 = ServerUIPlugin.getWizardFragment(runtimeWorkingCopy.getRuntimeType().getId()); if (fragment2 == null) { edit.setEnabled(false); return Window.CANCEL; diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/RuntimeTargetComposite.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/RuntimeTargetComposite.java index 7c2414f9a..7ca364d2f 100644 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/RuntimeTargetComposite.java +++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/RuntimeTargetComposite.java @@ -23,6 +23,7 @@ import org.eclipse.jface.preference.PreferenceManager; import org.eclipse.jface.window.Window; import org.eclipse.ui.PlatformUI; import org.eclipse.wst.server.core.*; +import org.eclipse.wst.server.core.internal.Module; import org.eclipse.wst.server.ui.ServerUIUtil; import org.eclipse.swt.SWT; import org.eclipse.swt.custom.BusyIndicator; @@ -69,7 +70,7 @@ public class RuntimeTargetComposite { childProjects = new ArrayList(); if (projectModule != null) { List children = new ArrayList(); - IModule[] child = projectModule.getChildModules(null); + IModule[] child = ((Module) projectModule).getChildModules(null); if (child != null) { int size = child.length; for (int i = 0; i < size; i++) @@ -77,7 +78,7 @@ public class RuntimeTargetComposite { int a = 0; while (a < children.size()) { IModule module = (IModule) children.get(a); - IModule[] child2 = module.getChildModules(null); + IModule[] child2 = ((Module) module).getChildModules(null); if (child2 != null) { size = child2.length; for (int i = 0; i < size; i++) diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/ServerPreferencePage.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/ServerPreferencePage.java index 1fa2a29b5..7a07f808a 100644 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/ServerPreferencePage.java +++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/ServerPreferencePage.java @@ -39,6 +39,8 @@ public class ServerPreferencePage extends PreferencePage implements IWorkbenchPr protected Button promptIrreversible; + protected Button showOnActivity; + protected byte saveEditors; protected Button saveNever; @@ -168,6 +170,14 @@ public class ServerPreferencePage extends PreferencePage implements IWorkbenchPr promptIrreversible.setSelection(uiPreferences.getPromptBeforeIrreversibleChange()); whs.setHelp(promptIrreversible, ContextIds.PREF_GENERAL_PROMPT_IRREVERSIBLE); + showOnActivity = new Button(composite, SWT.CHECK); + showOnActivity.setText(ServerUIPlugin.getResource("%prefShowOnActivity")); + data = new GridData(GridData.HORIZONTAL_ALIGN_FILL); + data.horizontalSpan = 3; + showOnActivity.setLayoutData(data); + showOnActivity.setSelection(uiPreferences.getShowOnActivity()); + whs.setHelp(showOnActivity, ContextIds.PREF_GENERAL_SHOW_ON_ACTIVITY); + createInWorkspace = new Button(composite, SWT.CHECK); createInWorkspace.setText(ServerUIPlugin.getResource("%prefCreateInWorkspace")); data = new GridData(GridData.HORIZONTAL_ALIGN_FILL); @@ -249,6 +259,7 @@ public class ServerPreferencePage extends PreferencePage implements IWorkbenchPr autoRestart.setSelection(preferences.isDefaultAutoRestarting()); publishBeforeStart.setSelection(preferences.isDefaultAutoPublishing()); promptIrreversible.setSelection(uiPreferences.getDefaultPromptBeforeIrreversibleChange()); + showOnActivity.setSelection(uiPreferences.getDefaultShowOnActivity()); createInWorkspace.setSelection(preferences.isDefaultCreateResourcesInWorkspace()); autoPublishLocal.setSelection(preferences.getDefaultAutoPublishLocal()); @@ -270,6 +281,7 @@ public class ServerPreferencePage extends PreferencePage implements IWorkbenchPr preferences.setAutoRestarting(autoRestart.getSelection()); uiPreferences.setSaveEditors(saveEditors); uiPreferences.setPromptBeforeIrreversibleChange(promptIrreversible.getSelection()); + uiPreferences.setShowOnActivity(showOnActivity.getSelection()); preferences.setCreateResourcesInWorkspace(createInWorkspace.getSelection()); preferences.setAutoPublishLocal(autoPublishLocal.getSelection()); @@ -297,7 +309,7 @@ public class ServerPreferencePage extends PreferencePage implements IWorkbenchPr IServer server = servers[i]; if (server.getServerRestartState()) { String mode = server.getMode(); - if (server.canRestart(mode)) + if (server.canRestart(mode).isOK()) try { Trace.trace(Trace.FINEST, "Attempting to auto restart " + server.getName()); server.restart(mode); diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/ServerTreeContentProvider.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/ServerTreeContentProvider.java index 2f8b88749..21c2b5088 100644 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/ServerTreeContentProvider.java +++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/ServerTreeContentProvider.java @@ -16,6 +16,7 @@ import org.eclipse.jface.viewers.ITreeContentProvider; import org.eclipse.jface.viewers.TreeViewer; import org.eclipse.jface.viewers.Viewer; import org.eclipse.wst.server.core.*; +import org.eclipse.wst.server.core.internal.ResourceManager; import org.eclipse.wst.server.core.model.ModuleEvent; import org.eclipse.wst.server.core.model.IModuleEventsListener; import org.eclipse.wst.server.core.model.ModuleFactoryEvent; @@ -98,7 +99,7 @@ public class ServerTreeContentProvider implements ITreeContentProvider { ServerCore.removeServerLifecycleListener(listener); if (moduleEventsListener != null) - ServerCore.removeModuleEventsListener(moduleEventsListener); + ResourceManager.getInstance().removeModuleEventsListener(moduleEventsListener); } /** @@ -225,7 +226,7 @@ public class ServerTreeContentProvider implements ITreeContentProvider { } }; - ServerCore.addModuleEventsListener(moduleEventsListener); + ResourceManager.getInstance().addModuleEventsListener(moduleEventsListener); } /** 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 3372bcb7c..6f4aced4d 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 @@ -13,21 +13,39 @@ package org.eclipse.wst.server.ui.internal; import java.text.MessageFormat; import java.util.ArrayList; import java.util.HashMap; +import java.util.Iterator; import java.util.List; import java.util.Map; import org.eclipse.core.resources.IFile; import org.eclipse.core.runtime.*; +import org.eclipse.jface.action.Action; import org.eclipse.jface.dialogs.IDialogConstants; import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.jface.viewers.StructuredSelection; import org.eclipse.wst.server.core.*; +import org.eclipse.wst.server.core.internal.IPublishListener; +import org.eclipse.wst.server.core.internal.PublishAdapter; +import org.eclipse.wst.server.core.internal.Server; +import org.eclipse.wst.server.core.internal.ServerType; import org.eclipse.wst.server.core.util.ServerAdapter; +import org.eclipse.wst.server.ui.ServerUIUtil; import org.eclipse.wst.server.ui.editor.IServerEditorInput; +import org.eclipse.wst.server.ui.internal.actions.RunOnServerActionDelegate; import org.eclipse.wst.server.ui.internal.editor.ServerEditorInput; +import org.eclipse.wst.server.ui.internal.task.FinishWizardFragment; +import org.eclipse.wst.server.ui.internal.task.InputWizardFragment; +import org.eclipse.wst.server.ui.internal.task.SaveRuntimeTask; +import org.eclipse.wst.server.ui.internal.wizard.ClosableWizardDialog; +import org.eclipse.wst.server.ui.internal.wizard.fragment.NewRuntimeWizardFragment; +import org.eclipse.wst.server.ui.wizard.TaskWizard; +import org.eclipse.wst.server.ui.wizard.WizardFragment; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Shell; +import org.eclipse.ui.IViewPart; +import org.eclipse.ui.IWorkbench; import org.eclipse.ui.IWorkbenchPage; import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.plugin.AbstractUIPlugin; @@ -37,6 +55,10 @@ import org.osgi.framework.BundleContext; */ public class ServerUIPlugin extends AbstractUIPlugin { private static final String MODULE_ARTIFACT_CLASS = "org.eclipse.wst.server.core.IModuleArtifact"; + protected static final String VIEW_ID = "org.eclipse.wst.server.ui.ServersView"; + + // server UI plugin id + public static final String PLUGIN_ID = "org.eclipse.wst.server.ui"; //public static final byte START = 0; public static final byte STOP = 1; @@ -46,11 +68,58 @@ public class ServerUIPlugin extends AbstractUIPlugin { private static ServerUIPlugin singleton; protected Map imageDescriptors = new HashMap(); + + // cached copy of all runtime wizards + private static Map wizardFragments; + + static class WizardFragmentData { + String id; + IConfigurationElement ce; + WizardFragment fragment; + + public WizardFragmentData(String id, IConfigurationElement ce) { + this.id = id; + this.ce = ce; + } + } protected static List terminationWatches = new ArrayList(); - // server UI plugin id - public static final String PLUGIN_ID = "org.eclipse.wst.server.ui"; + protected IServerLifecycleListener serverLifecycleListener = new IServerLifecycleListener() { + public void serverAdded(IServer server) { + server.addServerListener(serverListener); + ((Server) server).addPublishListener(publishListener); + } + + public void serverChanged(IServer server) { + // ignore + } + + public void serverRemoved(IServer server) { + server.removeServerListener(serverListener); + ((Server) server).removePublishListener(publishListener); + } + }; + + protected static IServerListener serverListener = new ServerAdapter() { + public void serverStateChange(IServer server) { + showServersView(); + } + + public void modulesChanged(IServer server) { + showServersView(); + } + }; + + protected static IPublishListener publishListener = new PublishAdapter() { + public void publishStarted(IServer server) { + showServersView(); + } + + public void publishFinished(IServer server, IStatus status) { + showServersView(); + } + }; /** * Create the ServerUIPlugin. @@ -141,8 +210,19 @@ public class ServerUIPlugin extends AbstractUIPlugin { ServerUIPreferences prefs = getPreferences(); prefs.setDefaults(); + + ServerCore.addServerLifecycleListener(serverLifecycleListener); + + IServer[] servers = ServerCore.getServers(); + if (servers != null) { + int size = servers.length; + for (int i = 0; i < size; i++) { + servers[i].addServerListener(serverListener); + ((Server) servers[i]).addPublishListener(publishListener); + } + } } - + /** * Shuts down this plug-in and saves all plug-in state. * @@ -153,6 +233,17 @@ public class ServerUIPlugin extends AbstractUIPlugin { super.stop(context); ImageResource.dispose(); + + IServer[] servers = ServerCore.getServers(); + if (servers != null) { + int size = servers.length; + for (int i = 0; i < size; i++) { + servers[i].removeServerListener(serverListener); + ((Server) servers[i]).removePublishListener(publishListener); + } + } + + ServerCore.removeServerLifecycleListener(serverLifecycleListener); } /** @@ -174,11 +265,12 @@ public class ServerUIPlugin extends AbstractUIPlugin { public void run() { while (alive) { - int delay = server.getServerType().getStartTimeout(); + ServerType serverType = (ServerType) server.getServerType(); + int delay = serverType.getStartTimeout(); if (mode == 1) - delay = server.getServerType().getStopTimeout(); + delay = serverType.getStopTimeout(); else if (mode == 2) - delay += server.getServerType().getStopTimeout(); + delay += serverType.getStopTimeout(); if (delay < 0) return; @@ -516,4 +608,190 @@ public class ServerUIPlugin extends AbstractUIPlugin { return true; } + + protected static void showServersView() { + if (!getPreferences().getShowOnActivity()) + return; + + Display.getDefault().asyncExec(new Runnable() { + public void run() { + try { + IWorkbench workbench = ServerUIPlugin.getInstance().getWorkbench(); + IWorkbenchWindow workbenchWindow = workbench.getActiveWorkbenchWindow(); + + IWorkbenchPage page = workbenchWindow.getActivePage(); + + IViewPart view2 = page.findView(VIEW_ID); + + if (view2 != null) + page.bringToTop(view2); + else + page.showView(VIEW_ID); + } catch (Exception e) { + Trace.trace(Trace.SEVERE, "Error opening TCP/IP view", e); + } + } + }); + } + + /** + * Returns true if the given server is already started in the given + * mode, or could be (re)started in the start mode. + * + * @param server + * @param launchMode + * @return boolean + */ + public static boolean isCompatibleWithLaunchMode(IServer server, String launchMode) { + if (server == null || launchMode == null) + return false; + + int state = server.getServerState(); + if (state == IServer.STATE_STARTED && launchMode.equals(server.getMode())) + return true; + + if (server.getServerType().supportsLaunchMode(launchMode)) + return true; + return false; + } + + /** + * Open the new runtime wizard. + * + * @param shell + * @param type + * @param version + * @param runtimeTypeId + * @return + */ + public static boolean showNewRuntimeWizard(Shell shell, final String type, final String version, final String runtimeTypeId) { + WizardFragment fragment = new WizardFragment() { + protected void createChildFragments(List list) { + list.add(new NewRuntimeWizardFragment(type, version, runtimeTypeId)); + list.add(new FinishWizardFragment(new SaveRuntimeTask())); + } + }; + TaskWizard wizard = new TaskWizard(ServerUIPlugin.getResource("%wizNewRuntimeWizardTitle"), fragment); + wizard.setForcePreviousAndNextButtons(true); + ClosableWizardDialog dialog = new ClosableWizardDialog(shell, wizard); + return (dialog.open() == IDialogConstants.OK_ID); + } + + /** + * Open the new runtime wizard. + * + * @param shell + * @param runtimeTypeId + * @return + */ + public static boolean showNewRuntimeWizard(Shell shell, final String runtimeTypeId) { + IRuntimeType runtimeType = null; + if (runtimeTypeId != null) + runtimeType = ServerCore.findRuntimeType(runtimeTypeId); + if (runtimeType != null) { + try { + final IRuntimeWorkingCopy runtime = runtimeType.createRuntime(null, null); + WizardFragment fragment = new WizardFragment() { + protected void createChildFragments(List list) { + list.add(new InputWizardFragment(ITaskModel.TASK_RUNTIME, runtime)); + list.add(getWizardFragment(runtimeTypeId)); + list.add(new FinishWizardFragment(new SaveRuntimeTask())); + } + }; + TaskWizard wizard = new TaskWizard(ServerUIPlugin.getResource("%wizNewRuntimeWizardTitle"), fragment); + wizard.setForcePreviousAndNextButtons(true); + ClosableWizardDialog dialog = new ClosableWizardDialog(shell, wizard); + return (dialog.open() == IDialogConstants.OK_ID); + } catch (Exception e) { + return false; + } + } + return showNewRuntimeWizard(shell, null, null, runtimeTypeId); + } + + /** + * Open the new runtime wizard. + * @param shell + * @return + */ + public static boolean showNewRuntimeWizard(Shell shell) { + return ServerUIUtil.showNewRuntimeWizard(shell, null, null); + } + + /** + * Returns the wizard fragment with the given id. + * + * @param typeId the server or runtime type id + * @return a wizard fragment, or <code>null</code> if none could be found + */ + public static WizardFragment getWizardFragment(String typeId) { + if (typeId == null) + return null; + + if (wizardFragments == null) + loadWizardFragments(); + + Iterator iterator = wizardFragments.keySet().iterator(); + while (iterator.hasNext()) { + String key = (String) iterator.next(); + if (typeId.equals(key)) { + WizardFragmentData data = (WizardFragmentData) wizardFragments.get(key); + return getWizardFragment(data); + } + } + return null; + } + + /** + * Load the wizard fragments. + */ + private static synchronized void loadWizardFragments() { + if (wizardFragments != null) + return; + Trace.trace(Trace.CONFIG, "->- Loading .wizardFragments extension point ->-"); + IExtensionRegistry registry = Platform.getExtensionRegistry(); + IConfigurationElement[] cf = registry.getConfigurationElementsFor(ServerUIPlugin.PLUGIN_ID, "wizardFragments"); + + int size = cf.length; + wizardFragments = new HashMap(size); + for (int i = 0; i < size; i++) { + try { + String id = cf[i].getAttribute("typeIds"); + wizardFragments.put(id, new WizardFragmentData(id, cf[i])); + Trace.trace(Trace.CONFIG, " Loaded wizardFragment: " + id); + } catch (Throwable t) { + Trace.trace(Trace.SEVERE, " Could not load wizardFragment: " + cf[i].getAttribute("id"), t); + } + } + + Trace.trace(Trace.CONFIG, "-<- Done loading .wizardFragments extension point -<-"); + } + + protected static WizardFragment getWizardFragment(WizardFragmentData fragment) { + if (fragment == null) + return null; + + if (fragment.fragment == null) { + try { + fragment.fragment = (WizardFragment) fragment.ce.createExecutableExtension("class"); + } catch (Throwable t) { + Trace.trace(Trace.SEVERE, "Could not create wizardFragment: " + fragment.ce.getAttribute("id"), t); + } + } + return fragment.fragment; + } + + public static void runOnServer(Object object, String launchMode) { + RunOnServerActionDelegate delegate = new RunOnServerActionDelegate(); + Action action = new Action() { + // dummy action + }; + if (object != null) { + StructuredSelection sel = new StructuredSelection(object); + delegate.selectionChanged(action, sel); + } else + delegate.selectionChanged(action, null); + + delegate.run(action); + } }
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/ServerUIPreferences.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/ServerUIPreferences.java index 59c67c05b..8d7ac4e2b 100644 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/ServerUIPreferences.java +++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/ServerUIPreferences.java @@ -25,6 +25,7 @@ public class ServerUIPreferences { private static final String PREF_IMPORT_LOCATION = "import-location"; private static final String PREF_SAVE_EDITORS = "save-editors"; private static final String PREF_HOST_NAMES = "host-names"; + private static final String PREF_SHOW_ON_ACTIVITY = "show-on-activity"; public static final byte SAVE_EDITORS_NEVER = 0; public static final byte SAVE_EDITORS_PROMPT = 1; @@ -46,6 +47,7 @@ public class ServerUIPreferences { preferences.setDefault(PREF_PROMPT_IRREVERSIBLE, getDefaultPromptBeforeIrreversibleChange()); preferences.setDefault(PREF_SAVE_EDITORS, getDefaultSaveEditors()); preferences.setDefault(PREF_HOST_NAMES, "localhost"); + preferences.setDefault(PREF_SHOW_ON_ACTIVITY, true); } /** @@ -125,6 +127,34 @@ public class ServerUIPreferences { preferences.setValue(PREF_SAVE_EDITORS, b); ServerUIPlugin.getInstance().savePluginPreferences(); } + + /** + * Returns the default setting for opening the servers view on activity. + * + * @return boolean + */ + public boolean getDefaultShowOnActivity() { + return true; + } + + /** + * Returns the setting for opening the servers view on activity. + * + * @return boolean + */ + public boolean getShowOnActivity() { + return preferences.getBoolean(PREF_SHOW_ON_ACTIVITY); + } + + /** + * Sets the value for opening the servers view on activity. + * + * @param boolean + */ + public void setShowOnActivity(boolean b) { + preferences.setValue(PREF_SHOW_ON_ACTIVITY, b); + ServerUIPlugin.getInstance().savePluginPreferences(); + } /** * Return the list of most recently used hostnames. diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/actions/RestartProjectActionDelegate.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/actions/RestartProjectActionDelegate.java index 379f80071..ae8b4eb3d 100644 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/actions/RestartProjectActionDelegate.java +++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/actions/RestartProjectActionDelegate.java @@ -10,9 +10,12 @@ *******************************************************************************/ package org.eclipse.wst.server.ui.internal.actions; +import java.util.ArrayList; import java.util.Iterator; +import java.util.List; import org.eclipse.core.resources.IProject; +import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.jface.action.IAction; import org.eclipse.jface.dialogs.MessageDialog; @@ -20,7 +23,9 @@ import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.wst.server.core.IModule; import org.eclipse.wst.server.core.IServer; +import org.eclipse.wst.server.core.ServerCore; import org.eclipse.wst.server.core.ServerUtil; +import org.eclipse.wst.server.core.internal.ServerPlugin; import org.eclipse.wst.server.ui.internal.EclipseUtil; import org.eclipse.wst.server.ui.internal.ServerUIPlugin; import org.eclipse.wst.server.ui.internal.Trace; @@ -42,6 +47,35 @@ public class RestartProjectActionDelegate implements IActionDelegate { } /** + * Returns a list of all servers that this module is configured on. + * + * @param module org.eclipse.wst.server.core.model.IModule + * @param monitor a progress monitor, or <code>null</code> if progress + * reporting and cancellation are not desired + * @return a possibly-empty array of server instances {@link IServer} + */ + protected static IServer[] getServersByModule(IModule module, IProgressMonitor monitor) { + if (module == null) + return new IServer[0]; + + // do it the slow way - go through all servers and + // see if this module is configured in it + List list = new ArrayList(); + IServer[] servers = ServerCore.getServers(); + if (servers != null) { + int size = servers.length; + for (int i = 0; i < size; i++) { + if (ServerPlugin.containsModule(servers[i], module, monitor)) + list.add(servers[i]); + } + } + + IServer[] allServers = new IServer[list.size()]; + list.toArray(allServers); + return allServers; + } + + /** * Performs this action. * <p> * This method is called when the delegating action has been triggered. @@ -62,13 +96,13 @@ public class RestartProjectActionDelegate implements IActionDelegate { IModule[] modules = ServerUtil.getModules(project); if (modules != null && modules.length > 0) { IModule module = modules[0]; - IServer[] servers = ServerUtil.getServersByModule(module, null); + IServer[] servers = getServersByModule(module, null); if (servers != null) { int size2 = servers.length; for (int j = 0; j < size2; j++) { int state = servers[j].getServerState(); if (state == IServer.STATE_STARTED) { - if (servers[j].canRestartModule(module)) { + if (servers[j].canRestartModule(module).isOK()) { try { servers[j].restartModule(module, new NullProgressMonitor()); } catch (Exception e) { @@ -123,13 +157,13 @@ public class RestartProjectActionDelegate implements IActionDelegate { IModule[] modules = ServerUtil.getModules(project); if (modules != null && modules.length > 0) { IModule module = modules[0]; - IServer[] servers = ServerUtil.getServersByModule(module, null); + IServer[] servers = getServersByModule(module, null); if (servers != null) { int size2 = servers.length; for (int j = 0; j < size2; j++) { int state = servers[j].getServerState(); if (state == IServer.STATE_STARTED) { - if (servers[j].canRestartModule(module)) { + if (servers[j].canRestartModule(module).isOK()) { action.setEnabled(true); return; } diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/actions/RunOnServerActionDelegate.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/actions/RunOnServerActionDelegate.java index fbba5f706..3dbe2f6e6 100644 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/actions/RunOnServerActionDelegate.java +++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/actions/RunOnServerActionDelegate.java @@ -50,6 +50,8 @@ public class RunOnServerActionDelegate implements IWorkbenchWindowActionDelegate protected static Object globalSelection; protected static Map globalLaunchMode; + + protected boolean tasksRun; /** * RunOnServerActionDelegate constructor comment. @@ -74,6 +76,60 @@ public class RunOnServerActionDelegate implements IWorkbenchWindowActionDelegate public void init(IWorkbenchWindow newWindow) { window = newWindow; } + + public IServer getServer(IModule module, String launchMode, IProgressMonitor monitor) { + IServer server = null; + IProject project = module.getProject(); + if (project != null) + server = ServerCore.getProjectProperties(project).getDefaultServer(); + + // ignore preference if the server doesn't support this mode. + if (server != null && !ServerUIPlugin.isCompatibleWithLaunchMode(server, launchMode)) + server = null; + + if (server != null && !ServerPlugin.containsModule(server, module, monitor)) { + IServerWorkingCopy wc = server.createWorkingCopy(); + try { + ServerUtil.modifyModules(wc, new IModule[] { module }, new IModule[0], monitor); + wc.save(false, monitor); + } catch (CoreException ce) { + Trace.trace(Trace.SEVERE, "Could not add module to server", ce); + server = null; + } + } + + Shell shell; + if (window != null) + shell = window.getShell(); + else + shell = ServerUIPlugin.getInstance().getWorkbench().getActiveWorkbenchWindow().getShell(); + + if (server == null) { + // try the full wizard + RunOnServerWizard wizard = new RunOnServerWizard(module, launchMode); + ClosableWizardDialog dialog = new ClosableWizardDialog(shell, wizard); + if (dialog.open() == Window.CANCEL) { + monitor.setCanceled(true); + return null; + } + + // TODO - this can't be called until the wizard's job finishes!! + server = wizard.getServer(); + boolean preferred = wizard.isPreferredServer(); + tasksRun = true; + + // set preferred server if requested + if (server != null && preferred && project != null) { + try { + ServerCore.getProjectProperties(project).setDefaultServer(server, monitor); + } catch (CoreException ce) { + String message = ServerUIPlugin.getResource("%errorCouldNotSavePreference"); + ErrorDialog.openError(shell, ServerUIPlugin.getResource("%errorDialogTitle"), message, ce.getStatus()); + } + } + } + return server; + } /** * Run the resource on a server. @@ -103,7 +159,7 @@ public class RunOnServerActionDelegate implements IWorkbenchWindowActionDelegate if (servers != null) { int size = servers.length; for (int i = 0; i < size && !found; i++) { - if (ServerUtil.isCompatibleWithLaunchMode(servers[i], launchMode)) { + if (ServerUIPlugin.isCompatibleWithLaunchMode(servers[i], launchMode)) { try { IModule[] parents = servers[i].getRootModules(module, monitor); if (parents != null && parents.length > 0) @@ -140,50 +196,11 @@ public class RunOnServerActionDelegate implements IWorkbenchWindowActionDelegate if (!ServerUIPlugin.saveEditors()) return; - IServer server = null; - IProject project = module.getProject(); - if (project != null) - server = ServerCore.getProjectProperties(project).getDefaultServer(); - - // ignore preference if the server doesn't support this mode. - if (server != null && !ServerUtil.isCompatibleWithLaunchMode(server, launchMode)) - server = null; + tasksRun = false; + IServer server = getServer(module, launchMode, monitor); + if (monitor.isCanceled()) + return; - if (server != null && !ServerUtil.containsModule(server, module, monitor)) { - IServerWorkingCopy wc = server.createWorkingCopy(); - try { - ServerUtil.modifyModules(wc, new IModule[] { module }, new IModule[0], monitor); - wc.save(false, monitor); - } catch (CoreException ce) { - Trace.trace(Trace.SEVERE, "Could not add module to server", ce); - server = null; - } - } - - boolean tasksRun = false; - if (server == null) { - // try the full wizard - RunOnServerWizard wizard = new RunOnServerWizard(module, launchMode); - ClosableWizardDialog dialog = new ClosableWizardDialog(shell, wizard); - if (dialog.open() == Window.CANCEL) { - return; - } - - // TODO - this can't be called until the wizard's job finishes!! - server = wizard.getServer(); - boolean preferred = wizard.isPreferredServer(); - tasksRun = true; - - // set preferred server if requested - if (server != null && preferred && project != null) { - try { - ServerCore.getProjectProperties(project).setDefaultServer(server, new NullProgressMonitor()); - } catch (CoreException ce) { - String message = ServerUIPlugin.getResource("%errorCouldNotSavePreference"); - ErrorDialog.openError(shell, ServerUIPlugin.getResource("%errorDialogTitle"), message, ce.getStatus()); - } - } - } Trace.trace(Trace.FINEST, "Server: " + server); if (server == null) { diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/task/ModifyModulesTask.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/task/ModifyModulesTask.java index c830ebde8..f860bd3d3 100644 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/task/ModifyModulesTask.java +++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/task/ModifyModulesTask.java @@ -17,12 +17,8 @@ import org.eclipse.core.resources.IProject; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.debug.core.ILaunchManager; -import org.eclipse.wst.server.core.IModule; -import org.eclipse.wst.server.core.IProjectProperties; -import org.eclipse.wst.server.core.IServer; -import org.eclipse.wst.server.core.IServerWorkingCopy; -import org.eclipse.wst.server.core.ITaskModel; -import org.eclipse.wst.server.core.ServerCore; +import org.eclipse.wst.server.core.*; +import org.eclipse.wst.server.core.internal.ProjectProperties; import org.eclipse.wst.server.core.model.IRunningActionServer; import org.eclipse.wst.server.core.util.Task; import org.eclipse.wst.server.ui.internal.EclipseUtil; @@ -87,7 +83,7 @@ public class ModifyModulesTask extends Task { if (!file.getProject().exists()) EclipseUtil.createNewServerProject(null, project.getName(), null, monitor); - IProjectProperties pp = ServerCore.getProjectProperties(project); + ProjectProperties pp = (ProjectProperties) ServerCore.getProjectProperties(project); if (!pp.isServerProject()) pp.setServerProject(true, monitor); } diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/task/SaveServerTask.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/task/SaveServerTask.java index e22e61952..212da7443 100644 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/task/SaveServerTask.java +++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/task/SaveServerTask.java @@ -14,11 +14,8 @@ import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IProject; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.wst.server.core.IProjectProperties; -import org.eclipse.wst.server.core.IServer; -import org.eclipse.wst.server.core.IServerWorkingCopy; -import org.eclipse.wst.server.core.ITaskModel; -import org.eclipse.wst.server.core.ServerCore; +import org.eclipse.wst.server.core.*; +import org.eclipse.wst.server.core.internal.ProjectProperties; import org.eclipse.wst.server.core.util.Task; import org.eclipse.wst.server.ui.internal.EclipseUtil; /** @@ -44,7 +41,7 @@ public class SaveServerTask extends Task { if (!file.getProject().exists()) EclipseUtil.createNewServerProject(null, project.getName(), null, monitor); - IProjectProperties pp = ServerCore.getProjectProperties(project); + ProjectProperties pp = (ProjectProperties) ServerCore.getProjectProperties(project); if (!pp.isServerProject()) pp.setServerProject(true, monitor); } diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/task/TempSaveServerTask.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/task/TempSaveServerTask.java index e80dcfe59..5c7e88b84 100644 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/task/TempSaveServerTask.java +++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/task/TempSaveServerTask.java @@ -15,6 +15,7 @@ import org.eclipse.core.resources.IProject; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.wst.server.core.*; +import org.eclipse.wst.server.core.internal.ProjectProperties; import org.eclipse.wst.server.core.internal.Server; import org.eclipse.wst.server.core.util.Task; import org.eclipse.wst.server.ui.internal.EclipseUtil; @@ -43,7 +44,7 @@ public class TempSaveServerTask extends Task { if (!file.getProject().exists()) EclipseUtil.createNewServerProject(null, project.getName(), null, monitor); - IProjectProperties pp = ServerCore.getProjectProperties(project); + ProjectProperties pp = (ProjectProperties) ServerCore.getProjectProperties(project); if (!pp.isServerProject()) pp.setServerProject(true, monitor); } diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/servers/MonitorServerPortAction.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/servers/MonitorServerPortAction.java index 51c4b16a3..6dbae790c 100644 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/servers/MonitorServerPortAction.java +++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/servers/MonitorServerPortAction.java @@ -13,6 +13,9 @@ package org.eclipse.wst.server.ui.internal.view.servers; import org.eclipse.jface.action.Action; import org.eclipse.wst.server.core.*; +import org.eclipse.wst.server.core.internal.IMonitoredServerPort; +import org.eclipse.wst.server.core.internal.IServerMonitorManager; +import org.eclipse.wst.server.core.internal.ServerMonitorManager; import org.eclipse.wst.server.ui.internal.ServerUIPlugin; import org.eclipse.wst.server.ui.internal.Trace; import org.eclipse.swt.widgets.Shell; @@ -33,7 +36,7 @@ public class MonitorServerPortAction extends Action { this.server = server; this.port = port; - IMonitoredServerPort[] msps = ServerCore.getServerMonitorManager().getMonitoredPorts(server); + IMonitoredServerPort[] msps = ServerMonitorManager.getInstance().getMonitoredPorts(server); if (msps != null) { int size = msps.length; for (int i = 0; i < size; i++) { @@ -51,10 +54,10 @@ public class MonitorServerPortAction extends Action { * Enable or disable monitoring. */ public void run() { + IServerMonitorManager smm = ServerMonitorManager.getInstance(); if (checked) { - ServerCore.getServerMonitorManager().removeMonitor(monitoredPort); + smm.removeMonitor(monitoredPort); } else { - IServerMonitorManager smm = ServerCore.getServerMonitorManager(); if (monitoredPort == null) monitoredPort = smm.createMonitor(server, port, -1, null); diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/servers/PublishAction.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/servers/PublishAction.java index 2d23a586c..acc047391 100644 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/servers/PublishAction.java +++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/servers/PublishAction.java @@ -35,7 +35,7 @@ public class PublishAction extends AbstractServerAction { * @param server org.eclipse.wst.server.core.IServer */ public boolean accept(IServer server) { - return server.canPublish(); + return server.canPublish().isOK(); } /** diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/servers/RestartAction.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/servers/RestartAction.java index 7cf605795..9ecbd4330 100644 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/servers/RestartAction.java +++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/servers/RestartAction.java @@ -50,7 +50,7 @@ public class RestartAction extends AbstractServerAction { String mode2 = mode; if (mode2 == null) mode2 = server.getMode(); - return server.getServerType() != null && server.getServerType().getServerStateSet() == IServerType.SERVER_STATE_SET_MANAGED && server.canRestart(mode2); + return server.getServerType() != null && server.getServerType().getServerStateSet() == IServerType.SERVER_STATE_SET_MANAGED && server.canRestart(mode2).isOK(); } /** diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/servers/RestartModuleAction.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/servers/RestartModuleAction.java index 6c25db303..d6eb19a06 100644 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/servers/RestartModuleAction.java +++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/servers/RestartModuleAction.java @@ -52,7 +52,7 @@ public class RestartModuleAction extends Action { return; }*/ - setEnabled(server.canRestartModule(module)); + setEnabled(server.canRestartModule(module).isOK()); } /** 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 d91769d4c..92809f227 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 @@ -20,7 +20,9 @@ import org.eclipse.core.runtime.IStatus; import org.eclipse.jface.viewers.*; import org.eclipse.wst.server.core.*; -import org.eclipse.wst.server.core.util.PublishAdapter; +import org.eclipse.wst.server.core.internal.IPublishListener; +import org.eclipse.wst.server.core.internal.PublishAdapter; +import org.eclipse.wst.server.core.internal.Server; import org.eclipse.wst.server.ui.internal.ServerTree; import org.eclipse.wst.server.ui.internal.Trace; import org.eclipse.wst.server.ui.internal.view.tree.ServerTreeAction; @@ -230,7 +232,7 @@ public class ServerTableViewer extends TableViewer { public void serverAdded(IServer server) { addServer(server); server.addServerListener(serverListener); - server.addPublishListener(publishListener); + ((Server) server).addPublishListener(publishListener); } public void serverChanged(IServer server) { refreshServer(server); @@ -238,7 +240,7 @@ public class ServerTableViewer extends TableViewer { public void serverRemoved(IServer server) { removeServer(server); server.removeServerListener(serverListener); - server.removePublishListener(publishListener); + ((Server) server).removePublishListener(publishListener); } }; ServerCore.addServerLifecycleListener(serverResourceListener); @@ -296,7 +298,7 @@ public class ServerTableViewer extends TableViewer { int size = servers.length; for (int i = 0; i < size; i++) { servers[i].addServerListener(serverListener); - servers[i].addPublishListener(publishListener); + ((Server) servers[i]).addPublishListener(publishListener); } } } @@ -350,7 +352,7 @@ public class ServerTableViewer extends TableViewer { int size = servers.length; for (int i = 0; i < size; i++) { servers[i].removeServerListener(serverListener); - servers[i].removePublishListener(publishListener); + ((Server) servers[i]).removePublishListener(publishListener); } } diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/servers/ServersView.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/servers/ServersView.java index 17393f59e..48e97c1a2 100644 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/servers/ServersView.java +++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/servers/ServersView.java @@ -10,17 +10,24 @@ *******************************************************************************/ 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.runtime.IProgressMonitor; import org.eclipse.debug.core.ILaunchManager; import org.eclipse.debug.ui.IDebugUIConstants; import org.eclipse.debug.ui.IDebugView; import org.eclipse.jface.action.*; import org.eclipse.jface.viewers.*; import org.eclipse.wst.server.core.*; +import org.eclipse.wst.server.core.internal.Trace; import org.eclipse.wst.server.ui.internal.*; import org.eclipse.wst.server.ui.internal.view.tree.DisabledMenuManager; import org.eclipse.swt.SWT; +import org.eclipse.swt.dnd.DND; +import org.eclipse.swt.dnd.FileTransfer; +import org.eclipse.swt.dnd.Transfer; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.layout.GridData; @@ -31,13 +38,13 @@ import org.eclipse.swt.widgets.Table; import org.eclipse.swt.widgets.TableColumn; import org.eclipse.swt.widgets.TableItem; import org.eclipse.ui.*; +import org.eclipse.ui.part.ResourceTransfer; import org.eclipse.ui.part.ViewPart; +import org.eclipse.ui.views.navigator.LocalSelectionTransfer; /** * View of server, their configurations and status. */ public class ServersView extends ViewPart { - //private static final String LAUNCH_CONFIGURATION_TYPE_ID = "org.eclipse.wst.server.core.launchConfigurationTypes"; - protected Table table; protected ServerTableViewer tableViewer; @@ -144,6 +151,8 @@ public class ServersView extends ViewPart { table.setMenu(menu); getSite().registerContextMenu(menuManager, tableViewer); getSite().setSelectionProvider(tableViewer); + + initDragAndDrop(); } protected void selectServerProcess(Object process) { @@ -363,7 +372,7 @@ public class ServersView extends ViewPart { MenuManager restartProjectMenu = new MenuManager(ServerUIPlugin.getResource("%actionRestartProject")); if (server != null) { - IModule[] modules = ServerUtil.getAllContainedModules(server, null); + IModule[] modules = getAllContainedModules(server, null); if (modules != null) { int size = modules.length; for (int i = 0; i < size; i++) { @@ -410,13 +419,6 @@ public class ServersView extends ViewPart { return sc; }*/ - /* - * @see IWorkbenchPart#getAdapter(Class) - */ - /*public Object getAdapter(Class adapter) { - return null; - }*/ - /** * */ @@ -424,4 +426,70 @@ public class ServersView extends ViewPart { if (table != null) table.setFocus(); } + + /** + * Adds drag and drop support to the Servers view. + */ + protected void initDragAndDrop() { + int ops = DND.DROP_COPY; + Transfer[] transfers = new Transfer[] { LocalSelectionTransfer.getInstance(), + ResourceTransfer.getInstance(), FileTransfer.getInstance() }; + //tableViewer.addDragSupport(ops, transfers, new ServersViewDragAdapter(viewer)); + tableViewer.addDropSupport(ops | DND.DROP_DEFAULT, transfers, new ServersViewDropAdapter(tableViewer)); + } + + /** + * Returns all projects contained by the server. This included the + * projects that are in the configuration, as well as their + * children, and their children... + * + * @param server org.eclipse.wst.server.core.IServer + * @param monitor a progress monitor, or <code>null</code> if progress + * reporting and cancellation are not desired + * @return a possibly-empty array of module instances {@link IModule} + */ + public static IModule[] getAllContainedModules(IServer server, IProgressMonitor monitor) { + //Trace.trace("> getAllContainedModules: " + getName(configuration)); + List modules = new ArrayList(); + if (server == null) + return new IModule[0]; + + // get all of the directly contained projects + IModule[] deploys = server.getModules(); + if (deploys == null || deploys.length == 0) + return new IModule[0]; + + int size = deploys.length; + for (int i = 0; i < size; i++) { + if (deploys[i] != null && !modules.contains(deploys[i])) + modules.add(deploys[i]); + } + + //Trace.trace(" getAllContainedModules: root level done"); + + // get all of the module's children + int count = 0; + while (count < modules.size()) { + IModule module = (IModule) modules.get(count); + try { + IModule[] children = server.getChildModules(module, monitor); + if (children != null) { + size = children.length; + for (int i = 0; i < size; i++) { + if (children[i] != null && !modules.contains(children[i])) + modules.add(children[i]); + } + } + } catch (Exception e) { + Trace.trace(Trace.SEVERE, "Error getting child modules for: " + module.getName(), e); + } + count ++; + } + + //Trace.trace("< getAllContainedModules"); + + IModule[] modules2 = new IModule[modules.size()]; + modules.toArray(modules2); + return modules2; + } }
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/servers/ServersViewDropAdapter.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/servers/ServersViewDropAdapter.java new file mode 100644 index 000000000..e5d3109c4 --- /dev/null +++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/servers/ServersViewDropAdapter.java @@ -0,0 +1,116 @@ +/********************************************************************** + * Copyright (c) 2005 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 + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - Initial API and implementation + **********************************************************************/ +package org.eclipse.wst.server.ui.internal.view.servers; + +import org.eclipse.jface.action.Action; +import org.eclipse.jface.viewers.StructuredSelection; +import org.eclipse.jface.viewers.Viewer; +import org.eclipse.jface.viewers.ViewerDropAdapter; +import org.eclipse.swt.dnd.DND; +import org.eclipse.swt.dnd.DropTargetEvent; +import org.eclipse.swt.dnd.FileTransfer; +import org.eclipse.swt.dnd.TransferData; +import org.eclipse.ui.part.ResourceTransfer; +import org.eclipse.ui.views.navigator.LocalSelectionTransfer; +import org.eclipse.wst.server.core.IServer; +import org.eclipse.wst.server.ui.internal.actions.RunOnServerActionDelegate; +/** + * + */ +public class ServersViewDropAdapter extends ViewerDropAdapter { + protected ServersViewDropAdapter(Viewer viewer) { + super(viewer); + } + + public void dragEnter(DropTargetEvent event) { + if (event.detail == DND.DROP_DEFAULT) + event.detail = DND.DROP_COPY; + + super.dragEnter(event); + } + + public boolean performDrop(Object data) { + Object target = getCurrentTarget(); + IServer server = null; + if (target instanceof IServer) + server = (IServer) target; + + if (server == null) + return false; + + final IServer finalServer = server; + RunOnServerActionDelegate ros = new RunOnServerActionDelegate() { + protected IServer getServer() { + return finalServer; + } + }; + Action action = new Action() { + // + }; + ros.selectionChanged(action, new StructuredSelection(data)); + + //if (!action.isEnabled()) + // return false; + + ros.run(action); + return true; + } + + public boolean validateDrop(Object target, int operation, TransferData transferType) { + if (target == null) + return false; + /*IServer server = null; + if (target instanceof IServer) + server = (IServer) target;*/ + //if (!ServerUIPlugin.hasModuleArtifact(target)) + // return false; + + System.out.println("Target: " + target + " " + operation + " " + transferType); + + if (FileTransfer.getInstance().isSupportedType(transferType)) + return true; + if (ResourceTransfer.getInstance().isSupportedType(transferType)) + return true; + if (LocalSelectionTransfer.getInstance().isSupportedType(transferType)) + return true; + + return false; + } + + /** + * Returns the resource selection from the LocalSelectionTransfer. + * + * @return the resource selection from the LocalSelectionTransfer + */ + /*private IResource[] getSelectedResources() { + ArrayList selectedResources = new ArrayList(); + + ISelection selection = LocalSelectionTransfer.getInstance() + .getSelection(); + if (selection instanceof IStructuredSelection) { + IStructuredSelection ssel = (IStructuredSelection) selection; + for (Iterator i = ssel.iterator(); i.hasNext();) { + Object o = i.next(); + if (o instanceof IResource) { + selectedResources.add(o); + } + else if (o instanceof IAdaptable) { + IAdaptable a = (IAdaptable) o; + IResource r = (IResource) a.getAdapter(IResource.class); + if (r != null) { + selectedResources.add(r); + } + } + } + } + return (IResource[]) selectedResources.toArray(new IResource[selectedResources.size()]); + }*/ +}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/servers/StartAction.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/servers/StartAction.java index be0e818f9..e3e03562c 100644 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/servers/StartAction.java +++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/servers/StartAction.java @@ -42,7 +42,7 @@ public class StartAction extends AbstractServerAction { * @param server org.eclipse.wst.server.core.IServer */ public boolean accept(IServer server) { - return server.canStart(launchMode); + return server.canStart(launchMode).isOK(); } /** diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/servers/StopAction.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/servers/StopAction.java index 20868d529..00e2e1bd8 100644 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/servers/StopAction.java +++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/view/servers/StopAction.java @@ -41,7 +41,7 @@ public class StopAction extends AbstractServerAction { public boolean accept(IServer server) { if (server.getServerType() == null || server.getServerType().getServerStateSet() != serverStateSet) return false; - return server.getServerType() != null && server.canStop(); + return server.getServerType() != null && server.canStop().isOK(); } /** diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/MonitorComposite.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/MonitorComposite.java index 6416068a6..57eff07da 100644 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/MonitorComposite.java +++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/MonitorComposite.java @@ -22,11 +22,11 @@ import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Table; import org.eclipse.swt.widgets.TableColumn; -import org.eclipse.wst.server.core.IMonitoredServerPort; import org.eclipse.wst.server.core.IServer; -import org.eclipse.wst.server.core.IServerMonitorManager; import org.eclipse.wst.server.core.IServerPort; -import org.eclipse.wst.server.core.ServerCore; +import org.eclipse.wst.server.core.internal.IMonitoredServerPort; +import org.eclipse.wst.server.core.internal.IServerMonitorManager; +import org.eclipse.wst.server.core.internal.ServerMonitorManager; import org.eclipse.wst.server.ui.internal.EclipseUtil; import org.eclipse.wst.server.ui.internal.SWTUtil; import org.eclipse.wst.server.ui.internal.ServerUIPlugin; @@ -52,7 +52,7 @@ public class MonitorComposite extends Composite { this.listener = listener2; this.server = server; - smm = ServerCore.getServerMonitorManager(); + smm = ServerMonitorManager.getInstance(); GridLayout layout = new GridLayout(); layout.marginWidth = 0; @@ -215,7 +215,7 @@ public class MonitorComposite extends Composite { } }); - IMonitoredServerPort[] msps = ServerCore.getServerMonitorManager().getMonitoredPorts(server); + IMonitoredServerPort[] msps = ServerMonitorManager.getInstance().getMonitoredPorts(server); if (msps != null && msps.length > 0) monitorTableViewer.setSelection(new StructuredSelection(msps[0])); } diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/MonitorContentProvider.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/MonitorContentProvider.java index 038b45fab..466619272 100644 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/MonitorContentProvider.java +++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/MonitorContentProvider.java @@ -14,7 +14,7 @@ import org.eclipse.jface.viewers.IStructuredContentProvider; import org.eclipse.jface.viewers.Viewer; import org.eclipse.wst.server.core.IServer; -import org.eclipse.wst.server.core.ServerCore; +import org.eclipse.wst.server.core.internal.ServerMonitorManager; /** * Monitor port content provider. */ @@ -31,7 +31,7 @@ public class MonitorContentProvider implements IStructuredContentProvider { } public Object[] getElements(Object inputElement) { - return ServerCore.getServerMonitorManager().getMonitoredPorts(server); + return ServerMonitorManager.getInstance().getMonitoredPorts(server); } public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/MonitorLabelProvider.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/MonitorLabelProvider.java index 4c26e0a44..aae68a8fe 100644 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/MonitorLabelProvider.java +++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/MonitorLabelProvider.java @@ -13,8 +13,8 @@ package org.eclipse.wst.server.ui.internal.viewers; import org.eclipse.jface.viewers.ITableLabelProvider; import org.eclipse.swt.graphics.Image; -import org.eclipse.wst.server.core.IMonitoredServerPort; import org.eclipse.wst.server.core.IServer; +import org.eclipse.wst.server.core.internal.IMonitoredServerPort; import org.eclipse.wst.server.ui.internal.ImageResource; import org.eclipse.wst.server.ui.internal.ServerUIPlugin; /** diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/ServerTreeContentProvider.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/ServerTreeContentProvider.java index d5ea4e524..af0ec4692 100644 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/ServerTreeContentProvider.java +++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/viewers/ServerTreeContentProvider.java @@ -111,7 +111,7 @@ public class ServerTreeContentProvider extends AbstractTreeContentProvider { protected boolean acceptServer(IServer server) { if (module == null || launchMode == null) return true; - if (!ServerUtil.isCompatibleWithLaunchMode(server, launchMode)) + if (!ServerUIPlugin.isCompatibleWithLaunchMode(server, launchMode)) return false; IModuleType mt = module.getModuleType(); diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/fragment/ModifyModulesWizardFragment.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/fragment/ModifyModulesWizardFragment.java index 858686a4e..2ec6fef12 100644 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/fragment/ModifyModulesWizardFragment.java +++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/fragment/ModifyModulesWizardFragment.java @@ -14,12 +14,9 @@ import java.util.ArrayList; import java.util.List; import org.eclipse.swt.widgets.Composite; -import org.eclipse.wst.server.core.IModule; -import org.eclipse.wst.server.core.IModuleVisitor; -import org.eclipse.wst.server.core.IServerWorkingCopy; -import org.eclipse.wst.server.core.ITask; -import org.eclipse.wst.server.core.ITaskModel; -import org.eclipse.wst.server.core.ServerUtil; +import org.eclipse.wst.server.core.*; +import org.eclipse.wst.server.core.internal.IModuleVisitor; +import org.eclipse.wst.server.core.internal.Server; import org.eclipse.wst.server.ui.internal.Trace; import org.eclipse.wst.server.ui.internal.task.ModifyModulesTask; import org.eclipse.wst.server.ui.internal.wizard.page.ModifyModulesComposite; @@ -91,7 +88,7 @@ public class ModifyModulesWizardFragment extends WizardFragment { } final Helper help = new Helper(); if (server != null) { - ServerUtil.visit(server, new IModuleVisitor() { + ((Server) server).visit(new IModuleVisitor() { public boolean visit(IModule[] parents2, IModule module2) { help.parentList.add(parents2); help.moduleList.add(module2); diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/fragment/NewRuntimeWizardFragment.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/fragment/NewRuntimeWizardFragment.java index 88c36840a..043cd0b40 100644 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/fragment/NewRuntimeWizardFragment.java +++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/fragment/NewRuntimeWizardFragment.java @@ -14,7 +14,7 @@ import java.util.List; import org.eclipse.wst.server.core.IRuntimeWorkingCopy; import org.eclipse.wst.server.core.ITaskModel; -import org.eclipse.wst.server.ui.ServerUICore; +import org.eclipse.wst.server.ui.internal.ServerUIPlugin; import org.eclipse.wst.server.ui.internal.wizard.page.NewRuntimeComposite; import org.eclipse.wst.server.ui.wizard.WizardFragment; import org.eclipse.wst.server.ui.wizard.IWizardHandle; @@ -74,7 +74,7 @@ public class NewRuntimeWizardFragment extends WizardFragment { if (runtime == null) return; - WizardFragment sub = ServerUICore.getWizardFragment(runtime.getRuntimeType().getId()); + WizardFragment sub = ServerUIPlugin.getWizardFragment(runtime.getRuntimeType().getId()); if (sub != null) list.add(sub); } diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/fragment/NewServerWizardFragment.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/fragment/NewServerWizardFragment.java index 1506cc652..6a55b8609 100644 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/fragment/NewServerWizardFragment.java +++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/fragment/NewServerWizardFragment.java @@ -18,7 +18,7 @@ import java.util.Map; import org.eclipse.swt.widgets.Composite; import org.eclipse.wst.server.core.*; import org.eclipse.wst.server.core.internal.Server; -import org.eclipse.wst.server.ui.ServerUICore; +import org.eclipse.wst.server.ui.internal.ServerUIPlugin; import org.eclipse.wst.server.ui.internal.wizard.page.NewServerComposite; import org.eclipse.wst.server.ui.wizard.WizardFragment; import org.eclipse.wst.server.ui.wizard.IWizardHandle; @@ -117,7 +117,7 @@ public class NewServerWizardFragment extends WizardFragment { // ignore } - WizardFragment fragment = ServerUICore.getWizardFragment(typeId); + WizardFragment fragment = ServerUIPlugin.getWizardFragment(typeId); if (fragment != null) fragmentMap.put(typeId, fragment); return fragment; diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/fragment/TasksWizardFragment.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/fragment/TasksWizardFragment.java index 9ba16f205..f7ab821e5 100644 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/fragment/TasksWizardFragment.java +++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/fragment/TasksWizardFragment.java @@ -23,6 +23,7 @@ import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Display; import org.eclipse.wst.server.core.*; +import org.eclipse.wst.server.core.internal.*; import org.eclipse.wst.server.core.util.Task; import org.eclipse.wst.server.ui.editor.IOrdered; import org.eclipse.wst.server.ui.internal.EclipseUtil; @@ -119,7 +120,7 @@ public class TasksWizardFragment extends WizardFragment { List moduleList = new ArrayList(); } final Helper help = new Helper(); - ServerUtil.visit(server, new IModuleVisitor() { + ((Server) server).visit(new IModuleVisitor() { public boolean visit(IModule[] parents2, IModule module2) { int size = parents2.length; List list = new ArrayList(size); @@ -158,7 +159,7 @@ public class TasksWizardFragment extends WizardFragment { serverTypeId = server.getServerType().getId(); // server tasks - IServerTask[] serverTasks = ServerCore.getServerTasks(); + IServerTask[] serverTasks = ServerPlugin.getServerTasks(); if (serverTasks != null) { int size = serverTasks.length; for (int i = 0; i < size; i++) { @@ -287,7 +288,7 @@ public class TasksWizardFragment extends WizardFragment { if (!file.getProject().exists()) EclipseUtil.createNewServerProject(null, project.getName(), null, monitor); - IProjectProperties pp = ServerCore.getProjectProperties(project); + ProjectProperties pp = (ProjectProperties) ServerCore.getProjectProperties(project); if (!pp.isServerProject()) pp.setServerProject(true, monitor); } 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 a3cb62c72..47b032a1b 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 @@ -427,7 +427,7 @@ public class ModifyModulesComposite extends Composite { if (add2) { modules.remove(module); deployed.add(module); - } else { + } else if (!module.equals(newModule)) { modules.add(module); deployed.remove(module); } diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/page/NewServerComposite.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/page/NewServerComposite.java index 3c3a0240d..f9c50156e 100644 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/page/NewServerComposite.java +++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/page/NewServerComposite.java @@ -356,7 +356,7 @@ public class NewServerComposite extends Composite { int size = servers.length; for (int i = 0; i < size; i++) { IModuleType mt = module.getModuleType(); - if (ServerUtil.isCompatibleWithLaunchMode(servers[i], launchMode) && + if (ServerUIPlugin.isCompatibleWithLaunchMode(servers[i], launchMode) && ServerUtil.isSupportedModule(servers[i].getServerType().getRuntimeType().getModuleTypes(), mt)) return true; } diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/page/WizardUtil.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/page/WizardUtil.java index e8275aa9d..3ebaf8875 100644 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/page/WizardUtil.java +++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/internal/wizard/page/WizardUtil.java @@ -18,6 +18,7 @@ import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.wizard.IWizard; import org.eclipse.jface.wizard.IWizardPage; import org.eclipse.wst.server.core.ServerCore; +import org.eclipse.wst.server.core.internal.ProjectProperties; import org.eclipse.wst.server.core.internal.ServerPlugin; import org.eclipse.wst.server.ui.internal.ServerUIPlugin; import org.eclipse.wst.server.ui.internal.wizard.ClosableWizardDialog; @@ -38,7 +39,7 @@ public class WizardUtil { if (projects != null) { int size = projects.length; for (int i = 0; i < size; i++) { - if (ServerCore.getProjectProperties(projects[i]).isServerProject()) + if (((ProjectProperties)ServerCore.getProjectProperties(projects[i])).isServerProject()) return projects[i]; } } diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/wizard/IWizardHandle.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/wizard/IWizardHandle.java index f2163e2ff..c384975a6 100644 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/wizard/IWizardHandle.java +++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/wizard/IWizardHandle.java @@ -17,6 +17,8 @@ import org.eclipse.jface.operation.IRunnableWithProgress; import org.eclipse.jface.resource.ImageDescriptor; /** * + * + * @since 1.0 */ public interface IWizardHandle extends IMessageProvider { public void update(); diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/wizard/TaskWizard.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/wizard/TaskWizard.java index 15529d18e..d4c215f3f 100644 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/wizard/TaskWizard.java +++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/wizard/TaskWizard.java @@ -18,11 +18,7 @@ import java.util.List; import java.util.Map; import org.eclipse.core.resources.IWorkspaceRunnable; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.NullProgressMonitor; -import org.eclipse.core.runtime.Status; +import org.eclipse.core.runtime.*; import org.eclipse.core.runtime.jobs.Job; import org.eclipse.jface.dialogs.IDialogSettings; import org.eclipse.jface.operation.IRunnableWithProgress; @@ -42,6 +38,8 @@ import org.eclipse.wst.server.ui.internal.Trace; import org.eclipse.wst.server.ui.internal.wizard.page.WorkspaceRunnableAdapter; /** * A wizard used to execute tasks. + * + * @since 1.0 */ public class TaskWizard implements IWizard { private static final byte FINISH = 2; diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/wizard/TaskWizardPage.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/wizard/TaskWizardPage.java index e43d34fe7..c4b5d6115 100644 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/wizard/TaskWizardPage.java +++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/wizard/TaskWizardPage.java @@ -19,6 +19,8 @@ import org.eclipse.swt.layout.GridData; import org.eclipse.swt.widgets.Composite; /** * + * + * @since 1.0 */ class TaskWizardPage extends WizardPage implements IWizardHandle { protected WizardFragment fragment; diff --git a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/wizard/WizardFragment.java b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/wizard/WizardFragment.java index dd36c497a..c402f00f2 100644 --- a/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/wizard/WizardFragment.java +++ b/plugins/org.eclipse.wst.server.ui/serverui/org/eclipse/wst/server/ui/wizard/WizardFragment.java @@ -18,7 +18,9 @@ import org.eclipse.swt.widgets.Composite; import org.eclipse.wst.server.core.ITask; import org.eclipse.wst.server.core.ITaskModel; /** - * A wizard fragment is a + * A wizard fragment is a + * + * @since 1.0 */ public abstract class WizardFragment { private ITaskModel taskModel; |