Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 158014 Details for
Bug 301601
SingleRoot participant needs to filter files
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Preliminary patch, moves to jst.common.frameworks
301601.patch (text/plain), 69.83 KB, created by
Rob Stryker
on 2010-02-03 04:38:48 EST
(
hide
)
Description:
Preliminary patch, moves to jst.common.frameworks
Filename:
MIME Type:
Creator:
Rob Stryker
Created:
2010-02-03 04:38:48 EST
Size:
69.83 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jst.common.frameworks >Index: META-INF/MANIFEST.MF >=================================================================== >RCS file: /cvsroot/webtools/jeetools/plugins/org.eclipse.jst.common.frameworks/META-INF/MANIFEST.MF,v >retrieving revision 1.39 >diff -u -r1.39 MANIFEST.MF >--- META-INF/MANIFEST.MF 25 Aug 2009 18:34:16 -0000 1.39 >+++ META-INF/MANIFEST.MF 3 Feb 2010 09:37:25 -0000 >@@ -10,6 +10,7 @@ > org.eclipse.jst.common.jdt.internal.classpath;x-internal:=true, > org.eclipse.jst.common.jdt.internal.integration;x-internal:=true, > org.eclipse.jst.common.jdt.internal.javalite, >+ org.eclipse.jst.common.modulecore, > org.eclipse.jst.common.project.facet > Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.2.0,4.0.0)", > org.eclipse.jdt.core;bundle-version="[3.2.0,4.0.0)", >Index: src/org/eclipse/jst/common/modulecore/ISingleRootStatus.java >=================================================================== >RCS file: src/org/eclipse/jst/common/modulecore/ISingleRootStatus.java >diff -N src/org/eclipse/jst/common/modulecore/ISingleRootStatus.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/jst/common/modulecore/ISingleRootStatus.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,54 @@ >+/******************************************************************************* >+ * Copyright (c) 2009 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.common.modulecore; >+ >+import org.eclipse.core.resources.IContainer; >+import org.eclipse.core.runtime.IPath; >+import org.eclipse.core.runtime.IStatus; >+ >+public interface ISingleRootStatus extends IStatus { >+ >+ // Information [0-32] >+ public static final int SINGLE_ROOT_CONTAINER_FOUND = 1; >+ public static final int SINGLE_ROOT_FORCED = 2; >+ //DO NOT ADD ANY OTHER CONSTANTS TO THE INFORMATION SECTION >+ >+ // Warnings [33-127] >+ public static final int SOURCE_PATH_NOT_FOUND = 33; >+ >+ // Errors [128-512] >+ public static final int NO_COMPONENT_FOUND = 67; >+ public static final int EXPLICITLY_DISABLED = 68; >+ public static final int CONSUMABLE_REFERENCES_FOUND = 69; >+ public static final int LINKED_RESOURCES_FOUND = 70; >+ public static final int NO_RESOURCE_MAPS_FOUND = 71; >+ public static final int JAVA_OUTPUT_NOT_A_CONTENT_ROOT = 72; >+ public static final int JAVA_OUTPUT_GREATER_THAN_1 = 73; >+ public static final int RUNTIME_PATH_NOT_ROOT = 74; >+ public static final int SOURCE_NOT_JAVA_CONTAINER = 75; >+ >+ // callback-contributed errors: 128-anything >+ >+ /** >+ * Returns the path with which the status is associated. >+ * >+ * @return the path with which the status is associated. >+ */ >+ public IPath getPath(); >+ >+ /** >+ * Will return the IContainer that is used as the "single-root". >+ * If a "single-root" structure is not found this method will return null. >+ * >+ * @return the "single-root" container >+ */ >+ public IContainer getSingleRoot(); >+} >Index: src/org/eclipse/jst/common/modulecore/SingleRootExportParticipant.java >=================================================================== >RCS file: src/org/eclipse/jst/common/modulecore/SingleRootExportParticipant.java >diff -N src/org/eclipse/jst/common/modulecore/SingleRootExportParticipant.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/jst/common/modulecore/SingleRootExportParticipant.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,139 @@ >+/******************************************************************************* >+ * Copyright (c) 2009 Red Hat 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: >+ * Red Hat - Initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.jst.common.modulecore; >+ >+import java.util.ArrayList; >+import java.util.List; >+ >+import org.eclipse.core.resources.IContainer; >+import org.eclipse.core.resources.IFile; >+import org.eclipse.core.resources.IResource; >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.runtime.IPath; >+import org.eclipse.core.runtime.Path; >+import org.eclipse.jst.common.modulecore.SingleRootUtil.SingleRootCallback; >+import org.eclipse.wst.common.componentcore.internal.flat.AbstractFlattenParticipant; >+import org.eclipse.wst.common.componentcore.internal.flat.FlatFolder; >+import org.eclipse.wst.common.componentcore.internal.flat.FlatResource; >+import org.eclipse.wst.common.componentcore.internal.flat.IFlatFile; >+import org.eclipse.wst.common.componentcore.internal.flat.IFlatFolder; >+import org.eclipse.wst.common.componentcore.internal.flat.IFlatResource; >+import org.eclipse.wst.common.componentcore.internal.flat.IFlattenParticipant; >+import org.eclipse.wst.common.componentcore.internal.flat.VirtualComponentFlattenUtility; >+import org.eclipse.wst.common.componentcore.internal.flat.FlatVirtualComponent.FlatComponentTaskModel; >+import org.eclipse.wst.common.componentcore.resources.IVirtualComponent; >+ >+/** >+ * Single root optimization. >+ * @author rob >+ */ >+public class SingleRootExportParticipant extends AbstractFlattenParticipant { >+ private SingleRootParticipantCallback callbackHandler; >+ private IVirtualComponent rootComponent; >+ private FlatComponentTaskModel dataModel; >+ >+ public interface SingleRootParticipantCallback extends SingleRootCallback { >+ public IFlattenParticipant[] getDelegateParticipants(); >+ } >+ >+ public SingleRootExportParticipant() { >+ super(); >+ callbackHandler = null; >+ } >+ public SingleRootExportParticipant(SingleRootParticipantCallback handler) { >+ this(); >+ callbackHandler = handler; >+ } >+ >+ @Override >+ public void initialize(IVirtualComponent component, >+ FlatComponentTaskModel dataModel, List<IFlatResource> resources) { >+ this.rootComponent = component; >+ this.dataModel = dataModel; >+ } >+ >+ >+ @Override >+ public boolean canOptimize(IVirtualComponent component, >+ FlatComponentTaskModel dataModel) { >+ return new SingleRootUtil(component, callbackHandler).isSingleRoot(); >+ } >+ >+ @Override >+ public void optimize(IVirtualComponent component, >+ FlatComponentTaskModel dataModel, List<IFlatResource> resources) { >+ try { >+ resources.clear(); // We want complete control >+ IContainer container = new SingleRootUtil(component).getSingleRoot(); >+ IFlatResource[] mr = getMembers(resources, container, new Path("")); //$NON-NLS-1$ >+ int size = mr.length; >+ for (int j = 0; j < size; j++) { >+ resources.add(mr[j]); >+ } >+ >+ // run finalizers >+ IFlattenParticipant[] delegates = callbackHandler.getDelegateParticipants(); >+ for(int i = 0; i < delegates.length; i++ ) { >+ delegates[i].finalize(component, dataModel, resources); >+ } >+ } catch( CoreException ce ) { >+ // TODO >+ } >+ } >+ >+ protected IFlatResource[] getMembers(List<IFlatResource> members, >+ IContainer cont, IPath path) throws CoreException { >+ IResource[] res = cont.members(); >+ int size2 = res.length; >+ List list = new ArrayList(size2); >+ for (int j = 0; j < size2; j++) { >+ if (res[j] instanceof IContainer) { >+ IContainer cc = (IContainer) res[j]; >+ // Retrieve already existing module folder if applicable >+ IFlatFolder mf = (FlatFolder) VirtualComponentFlattenUtility.getExistingModuleResource(members,path.append(new Path(cc.getName()).makeRelative())); >+ if (mf == null) { >+ mf = new FlatFolder(cc, cc.getName(), path); >+ IFlatFolder parent = (FlatFolder) VirtualComponentFlattenUtility.getExistingModuleResource(members, path); >+ if (path.isEmpty() || path.equals(new Path("/"))) //$NON-NLS-1$ >+ members.add(mf); >+ else { >+ if (parent == null) >+ parent = VirtualComponentFlattenUtility.ensureParentExists(members, path, cc); >+ VirtualComponentFlattenUtility.addMembersToModuleFolder(parent, new IFlatResource[] {mf}); >+ } >+ } >+ IFlatResource[] mr = getMembers(members, cc, path.append(cc.getName())); >+ VirtualComponentFlattenUtility.addMembersToModuleFolder(mf, mr); >+ } else { >+ IFile f = (IFile) res[j]; >+ IFlatFile mf = VirtualComponentFlattenUtility.createModuleFile(f, path); >+ if( shouldAddExportableFile(rootComponent, rootComponent, dataModel, mf)) >+ list.add(mf); >+ } >+ } >+ FlatResource[] mr = new FlatResource[list.size()]; >+ list.toArray(mr); >+ return mr; >+ } >+ >+ @Override >+ public boolean shouldAddExportableFile(IVirtualComponent rootComponent, >+ IVirtualComponent currentComponent, FlatComponentTaskModel dataModel, >+ IFlatFile file) { >+ IFlattenParticipant[] delegates = callbackHandler.getDelegateParticipants(); >+ for(int i = 0; i < delegates.length; i++ ) { >+ if( !delegates[i].shouldAddExportableFile(rootComponent, currentComponent, dataModel, file)) >+ return false; >+ } >+ return true; >+ } >+ >+} >Index: src/org/eclipse/jst/common/modulecore/SingleRootStatus.java >=================================================================== >RCS file: src/org/eclipse/jst/common/modulecore/SingleRootStatus.java >diff -N src/org/eclipse/jst/common/modulecore/SingleRootStatus.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/jst/common/modulecore/SingleRootStatus.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,48 @@ >+/******************************************************************************* >+ * Copyright (c) 2009 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.common.modulecore; >+ >+import org.eclipse.core.resources.IContainer; >+import org.eclipse.core.runtime.IPath; >+import org.eclipse.core.runtime.IStatus; >+import org.eclipse.core.runtime.Status; >+import org.eclipse.jst.common.frameworks.CommonFrameworksPlugin; >+ >+public class SingleRootStatus extends Status implements ISingleRootStatus { >+ >+ IPath path; >+ IContainer container; >+ >+ public SingleRootStatus(int type, int code, IPath resourcePath, IContainer containerPath, String message, Throwable exception) { >+ super(type, CommonFrameworksPlugin.PLUGIN_ID, code, message, exception); >+ path = resourcePath; >+ container = containerPath; >+ } >+ >+ public SingleRootStatus(int code, IPath resourcePath, IContainer containerPath) { >+ this(getSeverity(code), code, resourcePath, containerPath, null, null); >+ } >+ >+ public IPath getPath() { >+ return path; >+ } >+ >+ public IContainer getSingleRoot() { >+ return container; >+ } >+ >+ protected static int getSeverity(int code) { >+ if( code < 33 ) return IStatus.INFO; >+ if( code < 128 ) return IStatus.WARNING; >+ return IStatus.ERROR; >+ } >+ >+} >Index: src/org/eclipse/jst/common/modulecore/SingleRootUtil.java >=================================================================== >RCS file: src/org/eclipse/jst/common/modulecore/SingleRootUtil.java >diff -N src/org/eclipse/jst/common/modulecore/SingleRootUtil.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/jst/common/modulecore/SingleRootUtil.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,443 @@ >+/******************************************************************************* >+ * Copyright (c) 2009 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.common.modulecore; >+ >+import java.util.Collections; >+import java.util.Iterator; >+import java.util.List; >+ >+import org.eclipse.core.resources.IContainer; >+import org.eclipse.core.resources.IFolder; >+import org.eclipse.core.resources.IProject; >+import org.eclipse.core.resources.IResource; >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.runtime.IPath; >+import org.eclipse.core.runtime.IStatus; >+import org.eclipse.core.runtime.MultiStatus; >+import org.eclipse.core.runtime.Path; >+import org.eclipse.core.runtime.Status; >+import org.eclipse.jst.common.frameworks.CommonFrameworksPlugin; >+import org.eclipse.jst.common.jdt.internal.javalite.JavaLiteUtilities; >+import org.eclipse.wst.common.componentcore.internal.ComponentResource; >+import org.eclipse.wst.common.componentcore.internal.Property; >+import org.eclipse.wst.common.componentcore.internal.StructureEdit; >+import org.eclipse.wst.common.componentcore.internal.WorkbenchComponent; >+import org.eclipse.wst.common.componentcore.resources.IVirtualComponent; >+import org.eclipse.wst.common.componentcore.resources.IVirtualReference; >+ >+public class SingleRootUtil { >+ public interface SingleRootCallback { >+ public boolean canValidate(IProject project); >+ public void validate(SingleRootUtil util, IVirtualComponent vc, IProject project, List resourceMaps); >+ } >+ >+ /** >+ * Used to return immediately after the first error code is found. >+ */ >+ public static final int INCLUDE_FIRST_ERROR = 0x08; >+ /** >+ * Used to capture all status codes (error, warning, info) >+ */ >+ public static final int INCLUDE_ALL = 0x07; >+ /** >+ * Used to capture all error and warning status codes only. >+ */ >+ public static final int INCLUDE_ERRORS_AND_WARNINGS = 0x06; >+ /** >+ * Used to capture all error status codes only. >+ */ >+ public static final int INCLUDE_ERRORS = 0x04; >+ >+ private static final int WARNINGS = 0x02; >+ private static final int INFO = 0x01; >+ private static final int CANCEL = 0x0; >+ private static final int GET_SINGLE_ROOT_CONTAINER = 0x09; >+ private static String USE_SINGLE_ROOT_PROPERTY = "useSingleRoot"; //$NON-NLS-1$ >+ private IVirtualComponent aComponent; >+ private SingleRootCallback callback; >+ private List<IContainer> cachedSourceContainers; >+ private IContainer[] cachedOutputContainers; >+ private MultiStatus wrapperStatus; >+ private int VALIDATE_FLAG; >+ >+ public SingleRootUtil(IVirtualComponent component) { >+ this(component, null); >+ } >+ >+ public SingleRootUtil(IVirtualComponent component, SingleRootCallback callback) { >+ this.aComponent = component; >+ this.callback = callback; >+ } >+ >+ >+ /** >+ * Returns true if this module has a simple structure based on a >+ * single-root folder, and false otherwise. >+ * >+ * In a single-root structure, all files that are contained within the root folder >+ * are part of the module, and are already in the correct module structure. No >+ * module resources exist outside of this single folder. >+ * >+ * @return true if this module has a single-root structure, and >+ * false otherwise >+ */ >+ public boolean isSingleRoot() { >+ return validateSingleRoot(INCLUDE_FIRST_ERROR).getSeverity() != IStatus.ERROR; >+ } >+ >+ /** >+ * Will attempt to return the IContainer that counts as the "single-root". >+ * If this module does not qualify as a "single-root" module, this >+ * method will return null. Otherwise it will return an IContainer >+ * that may be used as the single-root container. >+ * >+ * @return IContainer representing single-root container >+ */ >+ public IContainer getSingleRoot() { >+ IStatus status = validateSingleRoot(GET_SINGLE_ROOT_CONTAINER); >+ if (status.getSeverity() == IStatus.INFO) { >+ IStatus[] children = ((MultiStatus) status).getChildren(); >+ ISingleRootStatus rootStatus = (ISingleRootStatus) children[0]; >+ return rootStatus.getSingleRoot(); >+ } >+ return null; >+ } >+ >+ /** >+ * Validates whether the component module has a single-root structure. >+ * An IStatus with a severity of OK is returned for a valid single-root >+ * structure. A MultiStatus containing children of type ISingleRootStatus >+ * is returned if any status codes were captured during the validation. >+ * A MultiStatus with a severity of INFO or WARNING is returned for a valid >+ * single-root structure containing status codes with no severities of ERROR. >+ * A MultiStatus with a severity of ERROR means the component does not have a >+ * valid single-root structure. >+ * >+ * @param flag - indicates the status codes (by severity) to capture during >+ * the validation. The INLCUDE_ALL flag will also capture the >+ * single-root container if a single-root structure was found. >+ * Valid flags are: >+ * INCLUDE_ALL >+ * INCLUDE_ERRORS_AND_WARNINGS >+ * INCLUDE_ERRORS >+ * INCLUDE_FIRST_ERROR >+ * >+ * @return IStatus >+ */ >+ public IStatus validateSingleRoot(int flag) { >+ VALIDATE_FLAG = flag; >+ wrapperStatus = null; >+ StructureEdit edit = null; >+ try { >+ edit = StructureEdit.getStructureEditForRead(getProject()); >+ if (edit == null || edit.getComponent() == null) { >+ reportStatus(ISingleRootStatus.NO_COMPONENT_FOUND); >+ return getStatus(); >+ } >+ >+ // 229650 - check to see if the property 'useSingleRoot' is defined. >+ Boolean useSingleRoot = getUseSingleRootProperty(edit); >+ if (useSingleRoot != null) { >+ //check if it was set to false >+ if (!useSingleRoot.booleanValue()) { >+ reportStatus(ISingleRootStatus.EXPLICITLY_DISABLED); >+ } >+ else { >+ reportStatus(ISingleRootStatus.SINGLE_ROOT_FORCED, aComponent.getRootFolder().getUnderlyingFolder()); >+ } >+ return getStatus(); >+ } >+ >+ // if there are any consumed references, this is not single-root >+ if (hasConsumableReferences(aComponent)) { >+ reportStatus(ISingleRootStatus.CONSUMABLE_REFERENCES_FOUND); >+ if (VALIDATE_FLAG == CANCEL) >+ return getStatus(); >+ } >+ >+ // if there are any linked resources then this is not a single-root module >+ if (rootFoldersHaveLinkedContent()) { >+ reportStatus(ISingleRootStatus.LINKED_RESOURCES_FOUND); >+ if (VALIDATE_FLAG == CANCEL) >+ return getStatus(); >+ } >+ >+ List resourceMaps = edit.getComponent().getResources(); >+ >+ // If the list is empty, return false >+ if (resourceMaps.size() < 1) { >+ reportStatus(ISingleRootStatus.NO_RESOURCE_MAPS_FOUND); >+ return getStatus(); >+ } >+ >+ if (resourceMaps.size() == 1) { >+ ComponentResource mapping = (ComponentResource)resourceMaps.get(0); >+ if (isRootMapping(mapping)) { >+ IResource sourceResource = getProject().findMember(mapping.getSourcePath()); >+ if (sourceResource != null && sourceResource.exists()) { >+ if (sourceResource instanceof IContainer && !isSourceContainer((IContainer) sourceResource)) { >+ reportStatus(ISingleRootStatus.SINGLE_ROOT_CONTAINER_FOUND, (IContainer) sourceResource); >+ return getStatus(); >+ } >+ } >+ } >+ } >+ >+ if( callback != null && callback.canValidate(getProject())) { >+ callback.validate(this, aComponent, getProject(), resourceMaps); >+ } else { >+ validateProject(resourceMaps); >+ } >+ return getStatus(); >+ } finally { >+ cachedOutputContainers = null; >+ cachedSourceContainers = null; >+ if (edit != null) >+ edit.dispose(); >+ } >+ } >+ >+ protected Boolean getUseSingleRootProperty(StructureEdit edit) { >+ WorkbenchComponent wbComp = edit.getComponent(); >+ final List componentProperties = wbComp.getProperties(); >+ if (componentProperties != null) { >+ final Iterator componentPropertiesIterator = componentProperties.iterator(); >+ while (componentPropertiesIterator.hasNext()) { >+ Property wbProperty = (Property) componentPropertiesIterator.next(); >+ if (USE_SINGLE_ROOT_PROPERTY.equals(wbProperty.getName())) { >+ return Boolean.valueOf(wbProperty.getValue()); >+ } >+ } >+ } >+ return null; >+ } >+ >+ protected boolean hasConsumableReferences(IVirtualComponent vc) { >+ IVirtualReference[] refComponents = vc.getReferences(); >+ for (int i = 0; i < refComponents.length; i++) { >+ IVirtualReference reference = refComponents[i]; >+ if (reference != null && reference.getDependencyType()==IVirtualReference.DEPENDENCY_TYPE_CONSUMES) { >+ return true; >+ } >+ } >+ return false; >+ } >+ >+ private void validateProject(List resourceMaps) { >+ // Ensure there are only source folder component resource mappings to the root content folder >+ if (isRootResourceMapping(resourceMaps)) { >+ IContainer[] javaOutputFolders = getJavaOutputFolders(); >+ // Verify only one java outputfolder >+ if (javaOutputFolders.length == 1) { >+ // By the time we get here we know: for any folders defined as source in the >+ // .component file that they are also java source folders. >+ if (!isSourceContainer(javaOutputFolders[0])) { >+ // The single output folder is NOT a source folder so this is single-rooted. Since the >+ // output folder (something like classes or bin) is not a source folder, JDT copies all files >+ // (including non Java files) to this folder, so every resource needed at runtime is located >+ // in a single directory. >+ reportStatus(ISingleRootStatus.SINGLE_ROOT_CONTAINER_FOUND, javaOutputFolders[0]); >+ return; >+ } >+ // Verify the java output folder is the same as one of the content roots >+ IPath javaOutputPath = getJavaOutputFolders()[0].getProjectRelativePath(); >+ IContainer[] rootFolders = aComponent.getRootFolder().getUnderlyingFolders(); >+ for (int i=0; i < rootFolders.length; i++) { >+ IPath compRootPath = rootFolders[i].getProjectRelativePath(); >+ if (javaOutputPath.equals(compRootPath)) { >+ reportStatus(ISingleRootStatus.SINGLE_ROOT_CONTAINER_FOUND, aComponent.getRootFolder().getUnderlyingFolder()); >+ return; >+ } >+ } >+ reportStatus(ISingleRootStatus.JAVA_OUTPUT_NOT_A_CONTENT_ROOT); >+ } >+ else { >+ reportStatus(ISingleRootStatus.JAVA_OUTPUT_GREATER_THAN_1); >+ } >+ } >+ } >+ >+ public IContainer[] getJavaOutputFolders() { >+ if (cachedOutputContainers == null) >+ cachedOutputContainers = getJavaOutputFolders(aComponent); >+ return cachedOutputContainers; >+ } >+ >+ public static IContainer[] getJavaOutputFolders(IVirtualComponent component) { >+ if (component == null) >+ return new IContainer[0]; >+ >+ List<IContainer> l = JavaLiteUtilities.getJavaOutputContainers(component); >+ return l.toArray(new IContainer[l.size()]); >+ } >+ >+ /** >+ * Checks if the path argument is to a source container for the project. >+ * >+ * @param a workspace relative full path >+ * @return is path a source container? >+ */ >+ public boolean isSourceContainer(IContainer sourceContainer) { >+ if (cachedSourceContainers == null) { >+ cachedSourceContainers = getSourceContainers(aComponent); >+ } >+ return cachedSourceContainers.contains(sourceContainer); >+ } >+ >+ public static List<IContainer> getSourceContainers(IVirtualComponent component) { >+ if (component == null) >+ Collections.emptyList(); >+ return JavaLiteUtilities.getJavaSourceContainers(component); >+ } >+ >+ /* >+ * This method returns true if the root folders of this component have any linked resources (folder or file); >+ * Otherwise false is returned. >+ */ >+ private boolean rootFoldersHaveLinkedContent() { >+ if (this.aComponent != null) { >+ final IContainer[] rootFolders = this.aComponent.getRootFolder().getUnderlyingFolders(); >+ for (int i = 0; i < rootFolders.length; i++) { >+ try { >+ boolean hasLinkedContent = this.hasLinkedContent(rootFolders[i]); >+ if (hasLinkedContent) { >+ return true; >+ } >+ } >+ catch (CoreException coreEx) { >+ CommonFrameworksPlugin.logError(coreEx); >+ } >+ } >+ } >+ return false; >+ } >+ >+ /* >+ * If the resource to check is a file then this method will return true if the file is linked. If the resource to >+ * check is a folder then this method will return true if it, any of its sub directories, or any file contained >+ * with-in this directory of any of it's sub directories are linked. Otherwise false is returned. >+ */ >+ private boolean hasLinkedContent(final IResource resourceToCheck) throws CoreException { >+ if ((resourceToCheck != null) && resourceToCheck.isAccessible()) { >+ // skip non-accessible files >+ if (resourceToCheck.isLinked()) { >+ return true; >+ } >+ switch (resourceToCheck.getType()) { >+ case IResource.FOLDER: >+ // recursively check sub directory contents >+ final IResource[] subDirContents = ((IFolder) resourceToCheck).members(); >+ for (int i = 0; i < subDirContents.length; i++) { >+ if (hasLinkedContent(subDirContents[i])) { >+ return true; >+ } >+ } >+ break; >+ case IResource.FILE: >+ return resourceToCheck.isLinked(); >+ default: >+ // skip as we only care about files and folders >+ break; >+ } >+ } >+ return false; >+ } >+ >+ /** >+ * Ensure that any component resource mappings are for source folders and >+ * that they map to the root content folder >+ * >+ * @param resourceMaps >+ * @return boolean >+ */ >+ private boolean isRootResourceMapping(List resourceMaps) { >+ for (int i=0; i < resourceMaps.size(); i++) { >+ ComponentResource resourceMap = (ComponentResource) resourceMaps.get(i); >+ // Verify it maps to "/" for the content root >+ if (!isRootMapping(resourceMap)) { >+ reportStatus(ISingleRootStatus.RUNTIME_PATH_NOT_ROOT, resourceMap.getRuntimePath()); >+ if (VALIDATE_FLAG == CANCEL) return false; >+ } >+ >+ // verify it is also a src container >+ IPath sourcePath = resourceMap.getSourcePath(); >+ IResource sourceResource = getProject().findMember(sourcePath); >+ if (sourceResource != null && sourceResource.exists()) { >+ if (sourceResource instanceof IContainer && !isSourceContainer((IContainer) sourceResource)) { >+ reportStatus(ISingleRootStatus.SOURCE_NOT_JAVA_CONTAINER, sourcePath); >+ } >+ } >+ else { >+ reportStatus(ISingleRootStatus.SOURCE_PATH_NOT_FOUND, sourcePath); >+ } >+ if (VALIDATE_FLAG == CANCEL) return false; >+ } >+ return true; >+ } >+ >+ public boolean isRootMapping(ComponentResource map) { >+ // Verify it maps to "/" for the content root >+ if (map.getRuntimePath().equals(Path.ROOT)) >+ return true; >+ return false; >+ } >+ >+ public IProject getProject() { >+ return aComponent.getProject(); >+ } >+ >+ public void reportStatus(int code) { >+ reportStatus(code, null, null); >+ } >+ >+ public void reportStatus(int code, IContainer container) { >+ reportStatus(code, null, container); >+ } >+ >+ public void reportStatus(int code, IPath path) { >+ reportStatus(code, path, null); >+ } >+ >+ public void reportStatus(int code, IPath path, IContainer container) { >+ ISingleRootStatus status = new SingleRootStatus(code, path, container); >+ if (status.getSeverity() == IStatus.ERROR) { >+ if ((VALIDATE_FLAG & INCLUDE_FIRST_ERROR) != 0) { >+ VALIDATE_FLAG = CANCEL; >+ addStatus(status); >+ } >+ else if ((VALIDATE_FLAG & INCLUDE_ERRORS) != 0) { >+ addStatus(status); >+ } >+ } >+ else if (status.getSeverity() == IStatus.WARNING && (VALIDATE_FLAG & WARNINGS) != 0) { >+ addStatus(status); >+ } >+ else if (status.getSeverity() == IStatus.INFO && (VALIDATE_FLAG & INFO) != 0) { >+ addStatus(status); >+ } >+ } >+ >+ public IStatus getStatus() { >+ if (wrapperStatus != null) { >+ return wrapperStatus; >+ } >+ return Status.OK_STATUS; >+ } >+ >+ private void addStatus(ISingleRootStatus status) { >+ if (wrapperStatus == null) { >+ wrapperStatus = new MultiStatus(CommonFrameworksPlugin.PLUGIN_ID, 0, new IStatus[] { status }, null, null); >+ } else { >+ wrapperStatus.add(status); >+ } >+ } >+ >+} >#P org.eclipse.jst.j2ee >Index: archiveops/org/eclipse/jst/j2ee/internal/archive/ComponentArchiveLoadAdapter.java >=================================================================== >RCS file: /cvsroot/webtools/jeetools/plugins/org.eclipse.jst.j2ee/archiveops/org/eclipse/jst/j2ee/internal/archive/ComponentArchiveLoadAdapter.java,v >retrieving revision 1.19 >diff -u -r1.19 ComponentArchiveLoadAdapter.java >--- archiveops/org/eclipse/jst/j2ee/internal/archive/ComponentArchiveLoadAdapter.java 4 Dec 2009 16:44:05 -0000 1.19 >+++ archiveops/org/eclipse/jst/j2ee/internal/archive/ComponentArchiveLoadAdapter.java 3 Feb 2010 09:37:28 -0000 >@@ -39,6 +39,7 @@ > import org.eclipse.jdt.core.IJavaProject; > import org.eclipse.jdt.core.IPackageFragmentRoot; > import org.eclipse.jdt.core.JavaCore; >+import org.eclipse.jst.common.modulecore.SingleRootUtil; > import org.eclipse.jst.j2ee.classpathdep.IClasspathDependencyConstants; > import org.eclipse.jst.j2ee.componentcore.J2EEModuleVirtualComponent; > import org.eclipse.jst.j2ee.internal.J2EEConstants; >@@ -47,7 +48,7 @@ > import org.eclipse.jst.j2ee.internal.classpathdep.ClasspathDependencyVirtualComponent; > import org.eclipse.jst.j2ee.internal.plugin.J2EEPlugin; > import org.eclipse.jst.j2ee.internal.project.J2EEProjectUtilities; >-import org.eclipse.jst.j2ee.project.SingleRootUtil; >+import org.eclipse.jst.j2ee.project.JavaEESingleRootCallback; > import org.eclipse.jst.jee.archive.AbstractArchiveLoadAdapter; > import org.eclipse.jst.jee.archive.ArchiveModelLoadException; > import org.eclipse.jst.jee.archive.IArchive; >@@ -312,7 +313,7 @@ > } > > protected void attemptOptimization() { >- SingleRootUtil util = new SingleRootUtil(getComponent()); >+ SingleRootUtil util = new SingleRootUtil(getComponent(), new JavaEESingleRootCallback()); > IContainer rootContainer = util.getSingleRoot(); > if (rootContainer != null) { > try { >Index: common/org/eclipse/jst/j2ee/internal/common/exportmodel/SingleRootExportParticipant.java >=================================================================== >RCS file: common/org/eclipse/jst/j2ee/internal/common/exportmodel/SingleRootExportParticipant.java >diff -N common/org/eclipse/jst/j2ee/internal/common/exportmodel/SingleRootExportParticipant.java >--- common/org/eclipse/jst/j2ee/internal/common/exportmodel/SingleRootExportParticipant.java 12 Jan 2010 21:24:12 -0000 1.3 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,130 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2009 Red Hat 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: >- * Red Hat - Initial API and implementation >- *******************************************************************************/ >-package org.eclipse.jst.j2ee.internal.common.exportmodel; >- >-import java.util.ArrayList; >-import java.util.List; >-import java.util.Map; >- >-import org.eclipse.core.resources.IContainer; >-import org.eclipse.core.resources.IFile; >-import org.eclipse.core.resources.IResource; >-import org.eclipse.core.runtime.CoreException; >-import org.eclipse.core.runtime.IPath; >-import org.eclipse.core.runtime.Path; >-import org.eclipse.jst.common.jdt.internal.javalite.JavaCoreLite; >-import org.eclipse.jst.j2ee.classpathdep.ClasspathDependencyUtil; >-import org.eclipse.jst.j2ee.classpathdep.IClasspathDependencyConstants.DependencyAttributeType; >-import org.eclipse.jst.j2ee.project.SingleRootUtil; >-import org.eclipse.wst.common.componentcore.internal.flat.AbstractFlattenParticipant; >-import org.eclipse.wst.common.componentcore.internal.flat.VirtualComponentFlattenUtility; >-import org.eclipse.wst.common.componentcore.internal.flat.FlatFile; >-import org.eclipse.wst.common.componentcore.internal.flat.FlatFolder; >-import org.eclipse.wst.common.componentcore.internal.flat.FlatResource; >-import org.eclipse.wst.common.componentcore.internal.flat.IFlatFolder; >-import org.eclipse.wst.common.componentcore.internal.flat.IFlatResource; >-import org.eclipse.wst.common.componentcore.internal.flat.FlatVirtualComponent.FlatComponentTaskModel; >-import org.eclipse.wst.common.componentcore.resources.IVirtualComponent; >- >-/** >- * Single root optimization. >- * @author rob >- */ >-public class SingleRootExportParticipant extends AbstractFlattenParticipant { >- private IVirtualComponent component; >- private FlatComponentTaskModel dataModel; >- private ReplaceManifestExportParticipant manifestReplacementDelegate; >- >- @Override >- public void initialize(IVirtualComponent component, >- FlatComponentTaskModel dataModel, List<IFlatResource> resources) { >- this.component = component; >- this.dataModel = dataModel; >- } >- >- >- @Override >- public boolean canOptimize(IVirtualComponent component, >- FlatComponentTaskModel dataModel) { >- return new SingleRootUtil(component).isSingleRoot() && !hasClasspathDependencies(component); >- } >- >- protected boolean hasClasspathDependencies(IVirtualComponent component) { >- try { >- final Map entriesToAttrib = ClasspathDependencyUtil.getRawComponentClasspathDependencies( >- JavaCoreLite.create(component.getProject()), >- DependencyAttributeType.CLASSPATH_COMPONENT_DEPENDENCY); >- return entriesToAttrib != null && entriesToAttrib.size() > 0; >- } catch( CoreException ce ) {} >- return false; >- } >- >- @Override >- public void optimize(IVirtualComponent component, >- FlatComponentTaskModel dataModel, List<IFlatResource> resources) { >- manifestReplacementDelegate = new ReplaceManifestExportParticipant(); >- >- try { >- resources.clear(); // We want complete control >- IContainer container = new SingleRootUtil(component).getSingleRoot(); >- IFlatResource[] mr = getMembers(resources, container, new Path("")); //$NON-NLS-1$ >- int size = mr.length; >- for (int j = 0; j < size; j++) { >- resources.add(mr[j]); >- } >- manifestReplacementDelegate.forceUpdate(component, dataModel, resources); >- } catch( CoreException ce ) { >- // TODO >- } >- } >- >- protected IFlatResource[] getMembers(List<IFlatResource> members, >- IContainer cont, IPath path) throws CoreException { >- IResource[] res = cont.members(); >- int size2 = res.length; >- List list = new ArrayList(size2); >- for (int j = 0; j < size2; j++) { >- if (res[j] instanceof IContainer) { >- IContainer cc = (IContainer) res[j]; >- // Retrieve already existing module folder if applicable >- IFlatFolder mf = (FlatFolder) VirtualComponentFlattenUtility.getExistingModuleResource(members,path.append(new Path(cc.getName()).makeRelative())); >- if (mf == null) { >- mf = new FlatFolder(cc, cc.getName(), path); >- IFlatFolder parent = (FlatFolder) VirtualComponentFlattenUtility.getExistingModuleResource(members, path); >- if (path.isEmpty() || path.equals(new Path("/"))) //$NON-NLS-1$ >- members.add(mf); >- else { >- if (parent == null) >- parent = VirtualComponentFlattenUtility.ensureParentExists(members, path, cc); >- VirtualComponentFlattenUtility.addMembersToModuleFolder(parent, new IFlatResource[] {mf}); >- } >- } >- IFlatResource[] mr = getMembers(members, cc, path.append(cc.getName())); >- VirtualComponentFlattenUtility.addMembersToModuleFolder(mf, mr); >- } else { >- IFile f = (IFile) res[j]; >- FlatFile mf = VirtualComponentFlattenUtility.createModuleFile(f, path); >- if (shouldAddComponentFile(mf)) { >- list.add(mf); >- } >- } >- } >- FlatResource[] mr = new FlatResource[list.size()]; >- list.toArray(mr); >- return mr; >- } >- >- // checking solely for manifest file >- protected boolean shouldAddComponentFile(FlatFile file) { >- return manifestReplacementDelegate.shouldAddExportableFile(component, component, dataModel, file); >- } >- >-} >Index: j2eecreation/org/eclipse/jst/j2ee/internal/project/SingleRootStatus.java >=================================================================== >RCS file: j2eecreation/org/eclipse/jst/j2ee/internal/project/SingleRootStatus.java >diff -N j2eecreation/org/eclipse/jst/j2ee/internal/project/SingleRootStatus.java >--- j2eecreation/org/eclipse/jst/j2ee/internal/project/SingleRootStatus.java 18 Nov 2009 22:38:28 -0000 1.2 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,46 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2009 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.j2ee.internal.project; >- >-import org.eclipse.core.resources.IContainer; >-import org.eclipse.core.runtime.IPath; >-import org.eclipse.core.runtime.Status; >-import org.eclipse.jst.j2ee.internal.plugin.J2EEPlugin; >-import org.eclipse.jst.j2ee.project.ISingleRootStatus; >- >-public class SingleRootStatus extends Status implements ISingleRootStatus { >- >- IPath path; >- IContainer container; >- >- public SingleRootStatus(int type, int code, IPath resourcePath, IContainer containerPath, String message, Throwable exception) { >- super(type, J2EEPlugin.PLUGIN_ID, code, message, exception); >- path = resourcePath; >- container = containerPath; >- } >- >- public SingleRootStatus(int code, IPath resourcePath, IContainer containerPath) { >- this(getSeverity(code), code, resourcePath, containerPath, null, null); >- } >- >- public IPath getPath() { >- return path; >- } >- >- public IContainer getSingleRoot() { >- return container; >- } >- >- protected static int getSeverity(int code) { >- return code == 0 ? 0 : 1 << (code / 33); >- } >- >-} >Index: j2eecreation/org/eclipse/jst/j2ee/project/ISingleRootStatus.java >=================================================================== >RCS file: j2eecreation/org/eclipse/jst/j2ee/project/ISingleRootStatus.java >diff -N j2eecreation/org/eclipse/jst/j2ee/project/ISingleRootStatus.java >--- j2eecreation/org/eclipse/jst/j2ee/project/ISingleRootStatus.java 18 Nov 2009 22:38:28 -0000 1.2 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,77 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2009 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.j2ee.project; >- >-import org.eclipse.core.resources.IContainer; >-import org.eclipse.core.runtime.IPath; >-import org.eclipse.core.runtime.IStatus; >- >-public interface ISingleRootStatus extends IStatus { >- >- // Information [0-32] >- public static final int SINGLE_ROOT_CONTAINER_FOUND = 1; >- public static final int SINGLE_ROOT_FORCED = 2; >- //DO NOT ADD ANY OTHER CONSTANTS TO THE INFORMATION SECTION >- >- // Warnings [33-65] >- public static final int SOURCE_PATH_NOT_FOUND = 33; >- >- // Errors [66-98] >- public static final int NO_COMPONENT_FOUND = 67; >- >- public static final int JAVA_OUTPUT_GREATER_THAN_1 = 68; >- >- public static final int EAR_PROJECT_FOUND = 69; >- >- public static final int LINKED_RESOURCES_FOUND = 70; >- >- public static final int JAVA_OUTPUT_NOT_A_CONTENT_ROOT = 71; >- >- public static final int JAVA_OUTPUT_NOT_WEBINF_CLASSES = 72; >- >- public static final int ATLEAST_1_RESOURCE_MAP_MISSING = 73; >- >- public static final int NO_RESOURCE_MAPS_FOUND = 74; >- >- public static final int ONE_CONTENT_ROOT_REQUIRED = 75; >- >- public static final int ATLEAST_1_JAVA_SOURCE_REQUIRED = 76; >- >- public static final int RUNTIME_PATH_NOT_ROOT = 77; >- >- public static final int SOURCE_NOT_JAVA_CONTAINER = 78; >- >- public static final int RUNTIME_PATH_NOT_ROOT_OR_WEBINF_CLASSES = 79; >- >- public static final int ONLY_1_CONTENT_ROOT_ALLOWED = 80; >- >- public static final int EXPLICITLY_DISABLED = 81; >- >- public static final int CONSUMABLE_REFERENCES_FOUND = 82; >- >- >- /** >- * Returns the path with which the status is associated. >- * >- * @return the path with which the status is associated. >- */ >- public IPath getPath(); >- >- /** >- * Will return the IContainer that is used as the "single-root". >- * If a "single-root" structure is not found this method will return null. >- * >- * @return the "single-root" container >- */ >- public IContainer getSingleRoot(); >- >- >-} >Index: j2eecreation/org/eclipse/jst/j2ee/project/JavaEESingleRootCallback.java >=================================================================== >RCS file: j2eecreation/org/eclipse/jst/j2ee/project/JavaEESingleRootCallback.java >diff -N j2eecreation/org/eclipse/jst/j2ee/project/JavaEESingleRootCallback.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ j2eecreation/org/eclipse/jst/j2ee/project/JavaEESingleRootCallback.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,170 @@ >+/******************************************************************************* >+ * Copyright (c) 2009 Red Hat 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: >+ * Red Hat - Initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.jst.j2ee.project; >+ >+import java.util.List; >+import java.util.Map; >+ >+import org.eclipse.core.resources.IContainer; >+import org.eclipse.core.resources.IProject; >+import org.eclipse.core.resources.IResource; >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.runtime.IPath; >+import org.eclipse.core.runtime.Path; >+import org.eclipse.jst.common.jdt.internal.javalite.JavaCoreLite; >+import org.eclipse.jst.common.modulecore.ISingleRootStatus; >+import org.eclipse.jst.common.modulecore.SingleRootUtil; >+import org.eclipse.jst.common.modulecore.SingleRootExportParticipant.SingleRootParticipantCallback; >+import org.eclipse.jst.j2ee.classpathdep.ClasspathDependencyUtil; >+import org.eclipse.jst.j2ee.classpathdep.IClasspathDependencyConstants.DependencyAttributeType; >+import org.eclipse.jst.j2ee.internal.J2EEConstants; >+import org.eclipse.jst.j2ee.internal.common.exportmodel.ReplaceManifestExportParticipant; >+import org.eclipse.wst.common.componentcore.internal.ComponentResource; >+import org.eclipse.wst.common.componentcore.internal.flat.AbstractFlattenParticipant; >+import org.eclipse.wst.common.componentcore.internal.flat.FilterResourceParticipant; >+import org.eclipse.wst.common.componentcore.internal.flat.IFlatResource; >+import org.eclipse.wst.common.componentcore.internal.flat.IFlattenParticipant; >+import org.eclipse.wst.common.componentcore.internal.flat.FlatVirtualComponent.FlatComponentTaskModel; >+import org.eclipse.wst.common.componentcore.resources.IVirtualComponent; >+ >+public class JavaEESingleRootCallback implements SingleRootParticipantCallback { >+ public static final int EAR_PROJECT_FOUND = 10100; >+ public static final int ATLEAST_1_RESOURCE_MAP_MISSING = 10101; >+ public static final int JAVA_OUTPUT_NOT_WEBINF_CLASSES = 10102; >+ public static final int RUNTIME_PATH_NOT_ROOT_OR_WEBINF_CLASSES = 10103; >+ public static final int ONLY_1_CONTENT_ROOT_ALLOWED = 10104; >+ public static final int ONE_CONTENT_ROOT_REQUIRED = 10105; >+ public static final int ATLEAST_1_JAVA_SOURCE_REQUIRED = 10106; >+ public static final int CLASSPATH_DEPENDENCIES_FOUND = 10107; >+ >+ public boolean canValidate(IProject project) { >+ return JavaEEProjectUtilities.isEARProject(project) || >+ JavaEEProjectUtilities.isDynamicWebProject(project); >+ } >+ >+ public void validate(SingleRootUtil util, IVirtualComponent vc, IProject project, List resourceMaps) { >+ // Always return false for EARs so that members for EAR are always calculated and j2ee modules are filtered out >+ if (JavaEEProjectUtilities.isEARProject(project)) >+ util.reportStatus(EAR_PROJECT_FOUND); >+ >+ //validate web projects for single root >+ if (JavaEEProjectUtilities.isDynamicWebProject(project)) >+ validateWebProject(util, vc, resourceMaps); >+ >+ // If we have classpath dependencies we can't be single root >+ if( hasClasspathDependencies(vc)) >+ util.reportStatus(CLASSPATH_DEPENDENCIES_FOUND); >+ } >+ >+ protected boolean hasClasspathDependencies(IVirtualComponent component) { >+ try { >+ final Map entriesToAttrib = ClasspathDependencyUtil.getRawComponentClasspathDependencies( >+ JavaCoreLite.create(component.getProject()), >+ DependencyAttributeType.CLASSPATH_COMPONENT_DEPENDENCY); >+ return entriesToAttrib != null && entriesToAttrib.size() > 0; >+ } catch( CoreException ce ) {} >+ return false; >+ } >+ >+ >+ private void validateWebProject(SingleRootUtil util, IVirtualComponent vc, List resourceMaps) { >+ // Ensure there are only basic component resource mappings -- one for the content folder >+ // and any for src folders mapped to WEB-INF/classes >+ if (hasDefaultWebResourceMappings(util, resourceMaps)) { >+ IContainer[] javaOutputFolders = util.getJavaOutputFolders(); >+ // Verify only one java output folder >+ if (javaOutputFolders.length == 1) { >+ // Verify the java output folder is to <content root>/WEB-INF/classes >+ IPath javaOutputPath = util.getJavaOutputFolders()[0].getProjectRelativePath(); >+ IContainer rootContainer = vc.getRootFolder().getUnderlyingFolder(); >+ IPath compRootPath = rootContainer.getProjectRelativePath(); >+ if (compRootPath.append(J2EEConstants.WEB_INF_CLASSES).equals(javaOutputPath)) { >+ util.reportStatus(ISingleRootStatus.SINGLE_ROOT_CONTAINER_FOUND, rootContainer); >+ return; >+ } >+ util.reportStatus(JAVA_OUTPUT_NOT_WEBINF_CLASSES); >+ } >+ else { >+ util.reportStatus(ISingleRootStatus.JAVA_OUTPUT_GREATER_THAN_1); >+ } >+ } >+ } >+ >+ /** >+ * Ensure the default web setup is correct with one resource map and any number of java >+ * resource maps to WEB-INF/classes >+ * >+ * @param resourceMaps >+ * @return boolean >+ */ >+ private boolean hasDefaultWebResourceMappings(SingleRootUtil util, List resourceMaps) { >+ int rootValidMaps = 0; >+ >+ IPath webInfClasses = new Path(J2EEConstants.WEB_INF_CLASSES).makeAbsolute(); >+ for (int i = 0; i < resourceMaps.size(); i++) { >+ ComponentResource resourceMap = (ComponentResource) resourceMaps.get(i); >+ IPath sourcePath = resourceMap.getSourcePath(); >+ IPath runtimePath = resourceMap.getRuntimePath(); >+ IResource sourceResource = util.getProject().findMember(sourcePath); >+ >+ // Verify if the map is for the content root >+ if (util.isRootMapping(resourceMap)) { >+ rootValidMaps++; >+ } >+ // Verify if the map is for a java src folder and is mapped to "WEB-INF/classes" >+ else if (runtimePath.equals(webInfClasses)) { >+ if (sourceResource != null && sourceResource.exists()) { >+ if (sourceResource instanceof IContainer && !util.isSourceContainer((IContainer) sourceResource)) { >+ util.reportStatus(ISingleRootStatus.SOURCE_NOT_JAVA_CONTAINER, sourcePath); >+ return false; >+ } >+ } >+ else { >+ util.reportStatus(ISingleRootStatus.SOURCE_PATH_NOT_FOUND, sourcePath); >+ return false; >+ } >+ } >+ else { >+ util.reportStatus(RUNTIME_PATH_NOT_ROOT_OR_WEBINF_CLASSES, runtimePath); >+ return false; >+ } >+ } >+ // Make sure only one of the maps is the content root, and that at least one is for the java folder >+ if (rootValidMaps != 1) { >+ if (rootValidMaps < 1) { >+ util.reportStatus(ONE_CONTENT_ROOT_REQUIRED); >+ return false; >+ } >+ else if (rootValidMaps > 1) { >+ util.reportStatus(ONLY_1_CONTENT_ROOT_ALLOWED); >+ return false; >+ } >+ } >+ return true; >+ } >+ >+ public IFlattenParticipant[] getDelegateParticipants() { >+ return new IFlattenParticipant[] { >+ createManifestFinalizer(), >+ FilterResourceParticipant.createSuffixFilterParticipant(new String[]{".java"}) //$NON-NLS-1$ >+ }; >+ } >+ >+ public IFlattenParticipant createManifestFinalizer() { >+ return new AbstractFlattenParticipant() { >+ @Override >+ public void finalize(IVirtualComponent component, >+ FlatComponentTaskModel dataModel, List<IFlatResource> resources) { >+ new ReplaceManifestExportParticipant().forceUpdate(component, dataModel, resources); >+ } >+ }; >+ } >+} >Index: j2eecreation/org/eclipse/jst/j2ee/project/SingleRootUtil.java >=================================================================== >RCS file: j2eecreation/org/eclipse/jst/j2ee/project/SingleRootUtil.java >diff -N j2eecreation/org/eclipse/jst/j2ee/project/SingleRootUtil.java >--- j2eecreation/org/eclipse/jst/j2ee/project/SingleRootUtil.java 11 Jan 2010 20:02:49 -0000 1.4 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,517 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2009 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.j2ee.project; >- >-import java.util.Collections; >-import java.util.Iterator; >-import java.util.List; >- >-import org.eclipse.core.resources.IContainer; >-import org.eclipse.core.resources.IFolder; >-import org.eclipse.core.resources.IProject; >-import org.eclipse.core.resources.IResource; >-import org.eclipse.core.runtime.CoreException; >-import org.eclipse.core.runtime.IPath; >-import org.eclipse.core.runtime.IStatus; >-import org.eclipse.core.runtime.MultiStatus; >-import org.eclipse.core.runtime.Path; >-import org.eclipse.core.runtime.Status; >-import org.eclipse.jst.common.jdt.internal.javalite.JavaLiteUtilities; >-import org.eclipse.jst.j2ee.internal.J2EEConstants; >-import org.eclipse.jst.j2ee.internal.plugin.J2EEPlugin; >-import org.eclipse.jst.j2ee.internal.project.SingleRootStatus; >-import org.eclipse.wst.common.componentcore.internal.ComponentResource; >-import org.eclipse.wst.common.componentcore.internal.Property; >-import org.eclipse.wst.common.componentcore.internal.StructureEdit; >-import org.eclipse.wst.common.componentcore.internal.WorkbenchComponent; >-import org.eclipse.wst.common.componentcore.resources.IVirtualComponent; >-import org.eclipse.wst.common.componentcore.resources.IVirtualReference; >- >-public class SingleRootUtil { >- >- >- /** >- * Used to return immediately after the first error code is found. >- */ >- public static final int INCLUDE_FIRST_ERROR = 0x08; >- /** >- * Used to capture all status codes (error, warning, info) >- */ >- public static final int INCLUDE_ALL = 0x07; >- /** >- * Used to capture all error and warning status codes only. >- */ >- public static final int INCLUDE_ERRORS_AND_WARNINGS = 0x06; >- /** >- * Used to capture all error status codes only. >- */ >- public static final int INCLUDE_ERRORS = 0x04; >- >- private static final int WARNINGS = 0x02; >- private static final int INFO = 0x01; >- private static final int CANCEL = 0x0; >- private static final int GET_SINGLE_ROOT_CONTAINER = 0x09; >- private static String USE_SINGLE_ROOT_PROPERTY = "useSingleRoot"; //$NON-NLS-1$ >- private IVirtualComponent aComponent; >- private List<IContainer> cachedSourceContainers; >- private IContainer[] cachedOutputContainers; >- private MultiStatus wrapperStatus; >- private int VALIDATE_FLAG; >- >- public SingleRootUtil(IVirtualComponent component) { >- this.aComponent = component; >- } >- >- /** >- * Returns true if this module has a simple structure based on a >- * single-root folder, and false otherwise. >- * >- * In a single-root structure, all files that are contained within the root folder >- * are part of the module, and are already in the correct module structure. No >- * module resources exist outside of this single folder. >- * >- * @return true if this module has a single-root structure, and >- * false otherwise >- */ >- public boolean isSingleRoot() { >- return validateSingleRoot(INCLUDE_FIRST_ERROR).getSeverity() != IStatus.ERROR; >- } >- >- /** >- * Will attempt to return the IContainer that counts as the "single-root". >- * If this module does not qualify as a "single-root" module, this >- * method will return null. Otherwise it will return an IContainer >- * that may be used as the single-root container. >- * >- * @return IContainer representing single-root container >- */ >- public IContainer getSingleRoot() { >- IStatus status = validateSingleRoot(GET_SINGLE_ROOT_CONTAINER); >- if (status.getSeverity() == IStatus.INFO) { >- IStatus[] children = ((MultiStatus) status).getChildren(); >- ISingleRootStatus rootStatus = (ISingleRootStatus) children[0]; >- return rootStatus.getSingleRoot(); >- } >- return null; >- } >- >- /** >- * Validates whether the component module has a single-root structure. >- * An IStatus with a severity of OK is returned for a valid single-root >- * structure. A MultiStatus containing children of type ISingleRootStatus >- * is returned if any status codes were captured during the validation. >- * A MultiStatus with a severity of INFO or WARNING is returned for a valid >- * single-root structure containing status codes with no severities of ERROR. >- * A MultiStatus with a severity of ERROR means the component does not have a >- * valid single-root structure. >- * >- * @param flag - indicates the status codes (by severity) to capture during >- * the validation. The INLCUDE_ALL flag will also capture the >- * single-root container if a single-root structure was found. >- * Valid flags are: >- * INCLUDE_ALL >- * INCLUDE_ERRORS_AND_WARNINGS >- * INCLUDE_ERRORS >- * INCLUDE_FIRST_ERROR >- * >- * @return IStatus >- */ >- public IStatus validateSingleRoot(int flag) { >- VALIDATE_FLAG = flag; >- wrapperStatus = null; >- StructureEdit edit = null; >- try { >- edit = StructureEdit.getStructureEditForRead(getProject()); >- if (edit == null || edit.getComponent() == null) { >- reportStatus(ISingleRootStatus.NO_COMPONENT_FOUND); >- return getStatus(); >- } >- >- // 229650 - check to see if the property 'useSingleRoot' is defined. >- Boolean useSingleRoot = getUseSingleRootProperty(edit); >- if (useSingleRoot != null) { >- //check if it was set to false >- if (!useSingleRoot.booleanValue()) { >- reportStatus(ISingleRootStatus.EXPLICITLY_DISABLED); >- } >- else { >- reportStatus(ISingleRootStatus.SINGLE_ROOT_FORCED, aComponent.getRootFolder().getUnderlyingFolder()); >- } >- return getStatus(); >- } >- >- if (JavaEEProjectUtilities.isEARProject(getProject())) { >- // Always return false for EARs so that members for EAR are always calculated and j2ee modules are filtered out >- reportStatus(ISingleRootStatus.EAR_PROJECT_FOUND); >- return getStatus(); >- } >- >- // if there are any consumed references, this is not single-root >- if (hasConsumableReferences(aComponent)) { >- reportStatus(ISingleRootStatus.CONSUMABLE_REFERENCES_FOUND); >- if (VALIDATE_FLAG == CANCEL) >- return getStatus(); >- } >- >- // if there are any linked resources then this is not a single-root module >- if (rootFoldersHaveLinkedContent()) { >- reportStatus(ISingleRootStatus.LINKED_RESOURCES_FOUND); >- if (VALIDATE_FLAG == CANCEL) >- return getStatus(); >- } >- >- List resourceMaps = edit.getComponent().getResources(); >- >- // If the list is empty, return false >- if (resourceMaps.size() < 1) { >- reportStatus(ISingleRootStatus.NO_RESOURCE_MAPS_FOUND); >- return getStatus(); >- } >- >- if (resourceMaps.size() == 1) { >- ComponentResource mapping = (ComponentResource)resourceMaps.get(0); >- if (isRootMapping(mapping)) { >- IResource sourceResource = getProject().findMember(mapping.getSourcePath()); >- if (sourceResource != null && sourceResource.exists()) { >- if (sourceResource instanceof IContainer && !isSourceContainer((IContainer) sourceResource)) { >- reportStatus(ISingleRootStatus.SINGLE_ROOT_CONTAINER_FOUND, (IContainer) sourceResource); >- return getStatus(); >- } >- } >- } >- } >- >- if (JavaEEProjectUtilities.isDynamicWebProject(getProject())) { >- //validate web projects for single root >- validateWebProject(resourceMaps); >- } else { >- validateProject(resourceMaps); >- } >- //return the current status >- return getStatus(); >- } finally { >- cachedOutputContainers = null; >- cachedSourceContainers = null; >- if (edit != null) >- edit.dispose(); >- } >- } >- >- protected Boolean getUseSingleRootProperty(StructureEdit edit) { >- WorkbenchComponent wbComp = edit.getComponent(); >- final List componentProperties = wbComp.getProperties(); >- if (componentProperties != null) { >- final Iterator componentPropertiesIterator = componentProperties.iterator(); >- while (componentPropertiesIterator.hasNext()) { >- Property wbProperty = (Property) componentPropertiesIterator.next(); >- if (USE_SINGLE_ROOT_PROPERTY.equals(wbProperty.getName())) { >- return Boolean.valueOf(wbProperty.getValue()); >- } >- } >- } >- return null; >- } >- >- protected boolean hasConsumableReferences(IVirtualComponent vc) { >- IVirtualReference[] refComponents = vc.getReferences(); >- for (int i = 0; i < refComponents.length; i++) { >- IVirtualReference reference = refComponents[i]; >- if (reference != null && reference.getDependencyType()==IVirtualReference.DEPENDENCY_TYPE_CONSUMES) { >- return true; >- } >- } >- return false; >- } >- >- private void validateProject(List resourceMaps) { >- // Ensure there are only source folder component resource mappings to the root content folder >- if (isRootResourceMapping(resourceMaps)) { >- IContainer[] javaOutputFolders = getJavaOutputFolders(); >- // Verify only one java outputfolder >- if (javaOutputFolders.length == 1) { >- // By the time we get here we know: for any folders defined as source in the >- // .component file that they are also java source folders. >- if (!isSourceContainer(javaOutputFolders[0])) { >- // The single output folder is NOT a source folder so this is single-rooted. Since the >- // output folder (something like classes or bin) is not a source folder, JDT copies all files >- // (including non Java files) to this folder, so every resource needed at runtime is located >- // in a single directory. >- reportStatus(ISingleRootStatus.SINGLE_ROOT_CONTAINER_FOUND, javaOutputFolders[0]); >- return; >- } >- // Verify the java output folder is the same as one of the content roots >- IPath javaOutputPath = getJavaOutputFolders()[0].getProjectRelativePath(); >- IContainer[] rootFolders = aComponent.getRootFolder().getUnderlyingFolders(); >- for (int i=0; i < rootFolders.length; i++) { >- IPath compRootPath = rootFolders[i].getProjectRelativePath(); >- if (javaOutputPath.equals(compRootPath)) { >- reportStatus(ISingleRootStatus.SINGLE_ROOT_CONTAINER_FOUND, aComponent.getRootFolder().getUnderlyingFolder()); >- return; >- } >- } >- reportStatus(ISingleRootStatus.JAVA_OUTPUT_NOT_A_CONTENT_ROOT); >- } >- else { >- reportStatus(ISingleRootStatus.JAVA_OUTPUT_GREATER_THAN_1); >- } >- } >- } >- >- private void validateWebProject(List resourceMaps) { >- // Ensure there are only basic component resource mappings -- one for the content folder >- // and any for src folders mapped to WEB-INF/classes >- if (hasDefaultWebResourceMappings(resourceMaps)) { >- IContainer[] javaOutputFolders = getJavaOutputFolders(); >- // Verify only one java output folder >- if (javaOutputFolders.length == 1) { >- // Verify the java output folder is to <content root>/WEB-INF/classes >- IPath javaOutputPath = getJavaOutputFolders()[0].getProjectRelativePath(); >- IContainer rootContainer = aComponent.getRootFolder().getUnderlyingFolder(); >- IPath compRootPath = rootContainer.getProjectRelativePath(); >- if (compRootPath.append(J2EEConstants.WEB_INF_CLASSES).equals(javaOutputPath)) { >- reportStatus(ISingleRootStatus.SINGLE_ROOT_CONTAINER_FOUND, rootContainer); >- return; >- } >- reportStatus(ISingleRootStatus.JAVA_OUTPUT_NOT_WEBINF_CLASSES); >- } >- else { >- reportStatus(ISingleRootStatus.JAVA_OUTPUT_GREATER_THAN_1); >- } >- } >- } >- >- public IContainer[] getJavaOutputFolders() { >- if (cachedOutputContainers == null) >- cachedOutputContainers = getJavaOutputFolders(aComponent); >- return cachedOutputContainers; >- } >- >- public IContainer[] getJavaOutputFolders(IVirtualComponent component) { >- if (component == null) >- return new IContainer[0]; >- >- List<IContainer> l = JavaLiteUtilities.getJavaOutputContainers(component); >- return l.toArray(new IContainer[l.size()]); >- } >- >- /** >- * Checks if the path argument is to a source container for the project. >- * >- * @param a workspace relative full path >- * @return is path a source container? >- */ >- private boolean isSourceContainer(IContainer sourceContainer) { >- if (cachedSourceContainers == null) { >- cachedSourceContainers = getSourceContainers(aComponent); >- } >- return cachedSourceContainers.contains(sourceContainer); >- } >- >- public List<IContainer> getSourceContainers(IVirtualComponent component) { >- if (component == null) >- Collections.emptyList(); >- >- return JavaLiteUtilities.getJavaSourceContainers(component); >- } >- >- /* >- * This method returns true if the root folders of this component have any linked resources (folder or file); >- * Otherwise false is returned. >- */ >- private boolean rootFoldersHaveLinkedContent() { >- if (this.aComponent != null) { >- final IContainer[] rootFolders = this.aComponent.getRootFolder().getUnderlyingFolders(); >- for (int i = 0; i < rootFolders.length; i++) { >- try { >- boolean hasLinkedContent = this.hasLinkedContent(rootFolders[i]); >- if (hasLinkedContent) { >- return true; >- } >- } >- catch (CoreException coreEx) { >- J2EEPlugin.logError(coreEx); >- } >- } >- } >- return false; >- } >- >- /* >- * If the resource to check is a file then this method will return true if the file is linked. If the resource to >- * check is a folder then this method will return true if it, any of its sub directories, or any file contained >- * with-in this directory of any of it's sub directories are linked. Otherwise false is returned. >- */ >- private boolean hasLinkedContent(final IResource resourceToCheck) throws CoreException { >- if ((resourceToCheck != null) && resourceToCheck.isAccessible()) { >- // skip non-accessible files >- if (resourceToCheck.isLinked()) { >- return true; >- } >- switch (resourceToCheck.getType()) { >- case IResource.FOLDER: >- // recursively check sub directory contents >- final IResource[] subDirContents = ((IFolder) resourceToCheck).members(); >- for (int i = 0; i < subDirContents.length; i++) { >- if (hasLinkedContent(subDirContents[i])) { >- return true; >- } >- } >- break; >- case IResource.FILE: >- return resourceToCheck.isLinked(); >- default: >- // skip as we only care about files and folders >- break; >- } >- } >- return false; >- } >- >- /** >- * Ensure that any component resource mappings are for source folders and >- * that they map to the root content folder >- * >- * @param resourceMaps >- * @return boolean >- */ >- private boolean isRootResourceMapping(List resourceMaps) { >- for (int i=0; i < resourceMaps.size(); i++) { >- ComponentResource resourceMap = (ComponentResource) resourceMaps.get(i); >- // Verify it maps to "/" for the content root >- if (!isRootMapping(resourceMap)) { >- reportStatus(ISingleRootStatus.RUNTIME_PATH_NOT_ROOT, resourceMap.getRuntimePath()); >- if (VALIDATE_FLAG == CANCEL) return false; >- } >- >- // verify it is also a src container >- IPath sourcePath = resourceMap.getSourcePath(); >- IResource sourceResource = getProject().findMember(sourcePath); >- if (sourceResource != null && sourceResource.exists()) { >- if (sourceResource instanceof IContainer && !isSourceContainer((IContainer) sourceResource)) { >- reportStatus(ISingleRootStatus.SOURCE_NOT_JAVA_CONTAINER, sourcePath); >- } >- } >- else { >- reportStatus(ISingleRootStatus.SOURCE_PATH_NOT_FOUND, sourcePath); >- } >- if (VALIDATE_FLAG == CANCEL) return false; >- } >- return true; >- } >- >- private boolean isRootMapping(ComponentResource map) { >- // Verify it maps to "/" for the content root >- if (map.getRuntimePath().equals(Path.ROOT)) >- return true; >- return false; >- } >- >- /** >- * Ensure the default web setup is correct with one resource map and any number of java >- * resource maps to WEB-INF/classes >- * >- * @param resourceMaps >- * @return boolean >- */ >- private boolean hasDefaultWebResourceMappings(List resourceMaps) { >- int rootValidMaps = 0; >- >- IPath webInfClasses = new Path(J2EEConstants.WEB_INF_CLASSES).makeAbsolute(); >- for (int i = 0; i < resourceMaps.size(); i++) { >- ComponentResource resourceMap = (ComponentResource) resourceMaps.get(i); >- IPath sourcePath = resourceMap.getSourcePath(); >- IPath runtimePath = resourceMap.getRuntimePath(); >- IResource sourceResource = getProject().findMember(sourcePath); >- >- // Verify if the map is for the content root >- if (isRootMapping(resourceMap)) { >- rootValidMaps++; >- } >- // Verify if the map is for a java src folder and is mapped to "WEB-INF/classes" >- else if (runtimePath.equals(webInfClasses)) { >- if (sourceResource != null && sourceResource.exists()) { >- if (sourceResource instanceof IContainer && !isSourceContainer((IContainer) sourceResource)) { >- reportStatus(ISingleRootStatus.SOURCE_NOT_JAVA_CONTAINER, sourcePath); >- } >- } >- else { >- reportStatus(ISingleRootStatus.SOURCE_PATH_NOT_FOUND, sourcePath); >- } >- } >- else { >- reportStatus(ISingleRootStatus.RUNTIME_PATH_NOT_ROOT_OR_WEBINF_CLASSES, runtimePath); >- } >- if (VALIDATE_FLAG == CANCEL) return false; >- } >- // Make sure only one of the maps is the content root, and that at least one is for the java folder >- if (rootValidMaps != 1) { >- if (rootValidMaps < 1) { >- reportStatus(ISingleRootStatus.ONE_CONTENT_ROOT_REQUIRED); >- } >- else if (rootValidMaps > 1) { >- reportStatus(ISingleRootStatus.ONLY_1_CONTENT_ROOT_ALLOWED); >- } >- } >- return VALIDATE_FLAG == CANCEL ? false : true; >- } >- >- private IProject getProject() { >- return aComponent.getProject(); >- } >- >- public void reportStatus(int code) { >- reportStatus(code, null, null); >- } >- >- public void reportStatus(int code, IContainer container) { >- reportStatus(code, null, container); >- } >- >- public void reportStatus(int code, IPath path) { >- reportStatus(code, path, null); >- } >- >- public void reportStatus(int code, IPath path, IContainer container) { >- ISingleRootStatus status = new SingleRootStatus(code, path, container); >- if (status.getSeverity() == IStatus.ERROR) { >- if ((VALIDATE_FLAG & INCLUDE_FIRST_ERROR) != 0) { >- VALIDATE_FLAG = CANCEL; >- addStatus(status); >- } >- else if ((VALIDATE_FLAG & INCLUDE_ERRORS) != 0) { >- addStatus(status); >- } >- } >- else if (status.getSeverity() == IStatus.WARNING && (VALIDATE_FLAG & WARNINGS) != 0) { >- addStatus(status); >- } >- else if (status.getSeverity() == IStatus.INFO && (VALIDATE_FLAG & INFO) != 0) { >- addStatus(status); >- } >- } >- >- public IStatus getStatus() { >- if (wrapperStatus != null) { >- return wrapperStatus; >- } >- return Status.OK_STATUS; >- } >- >- private void addStatus(ISingleRootStatus status) { >- if (wrapperStatus == null) { >- wrapperStatus = new MultiStatus(J2EEPlugin.PLUGIN_ID, 0, new IStatus[] { status }, null, null); >- } >- else { >- wrapperStatus.add(status); >- } >- } >- >-} >Index: j2eeplugin/org/eclipse/jst/j2ee/internal/deployables/J2EEFlexProjDeployable.java >=================================================================== >RCS file: /cvsroot/webtools/jeetools/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/deployables/J2EEFlexProjDeployable.java,v >retrieving revision 1.104 >diff -u -r1.104 J2EEFlexProjDeployable.java >--- j2eeplugin/org/eclipse/jst/j2ee/internal/deployables/J2EEFlexProjDeployable.java 21 Jan 2010 15:55:10 -0000 1.104 >+++ j2eeplugin/org/eclipse/jst/j2ee/internal/deployables/J2EEFlexProjDeployable.java 3 Feb 2010 09:37:30 -0000 >@@ -22,6 +22,8 @@ > import org.eclipse.jdt.core.IJavaProject; > import org.eclipse.jem.workbench.utility.JemProjectUtilities; > import org.eclipse.jst.common.jdt.internal.javalite.JavaLiteUtilities; >+import org.eclipse.jst.common.modulecore.SingleRootExportParticipant; >+import org.eclipse.jst.common.modulecore.SingleRootUtil; > import org.eclipse.jst.j2ee.componentcore.util.EARArtifactEdit; > import org.eclipse.jst.j2ee.ejb.EJBJar; > import org.eclipse.jst.j2ee.internal.EjbModuleExtensionHelper; >@@ -32,10 +34,9 @@ > import org.eclipse.jst.j2ee.internal.common.exportmodel.IgnoreJavaInSourceFolderParticipant; > import org.eclipse.jst.j2ee.internal.common.exportmodel.JEEHeirarchyExportParticipant; > import org.eclipse.jst.j2ee.internal.common.exportmodel.ReplaceManifestExportParticipant; >-import org.eclipse.jst.j2ee.internal.common.exportmodel.SingleRootExportParticipant; > import org.eclipse.jst.j2ee.internal.plugin.J2EEPlugin; > import org.eclipse.jst.j2ee.project.JavaEEProjectUtilities; >-import org.eclipse.jst.j2ee.project.SingleRootUtil; >+import org.eclipse.jst.j2ee.project.JavaEESingleRootCallback; > import org.eclipse.jst.server.core.IApplicationClientModule; > import org.eclipse.jst.server.core.IConnectorModule; > import org.eclipse.jst.server.core.IEJBModule; >@@ -84,13 +85,13 @@ > */ > @Override > public boolean isSingleRootStructure() { >- return new SingleRootUtil(getComponent()).isSingleRoot(); >+ return new SingleRootUtil(getComponent(), new JavaEESingleRootCallback()).isSingleRoot(); > } > > @Override > protected IFlattenParticipant[] getParticipants() { > return new IFlattenParticipant[]{ >- new SingleRootExportParticipant(), >+ new SingleRootExportParticipant(new JavaEESingleRootCallback()), > new JEEHeirarchyExportParticipant(), > new AddClasspathReferencesParticipant(), > new AddMappedOutputFoldersParticipant(),
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 301601
: 158014