Author: akazakov
Date: 2011-09-22 19:28:04 -0400 (Thu, 22 Sep 2011)
New Revision: 34983
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web/src/org/jboss/tools/jst/web/WebUtils.java
Log:
https://issues.jboss.org/browse/JBIDE-9766 Refactor
org.jboss.tools.jst.web.WebUtils.getWebRootFolders() to take into account derived
resources and default web root folder
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web/src/org/jboss/tools/jst/web/WebUtils.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web/src/org/jboss/tools/jst/web/WebUtils.java 2011-09-22
23:21:13 UTC (rev 34982)
+++
trunk/jst/plugins/org.jboss.tools.jst.web/src/org/jboss/tools/jst/web/WebUtils.java 2011-09-22
23:28:04 UTC (rev 34983)
@@ -88,6 +88,17 @@
return (modelNature != null) ?
WebProject.getInstance(modelNature.getModel()).getWebRootLocation() : null;
}
+ private static final IContainer[] EMPTY_ARRAY = new IContainer[0];
+
+ /**
+ * Returns all the web root folders of the project.
+ * If the project is not a web project then the method will return an empty array.
+ * If ignoreDerived==true then all the derived resources or resources belonged to
derived containers will be eliminated.
+ * If some folder is set as default web root source folder (available since WTP 3.3.1)
then this folder will be places in the very beginning of the result array.
+ * @param project
+ * @param ignoreDerived
+ * @return
+ */
public static IContainer[] getWebRootFolders(IProject project, boolean ignoreDerived) {
IFacetedProject facetedProject = null;
try {
@@ -120,15 +131,23 @@
}
}
}
- return null;
+ return EMPTY_ARRAY;
}
private static boolean WTP_3_3_0 = false;
+ /**
+ * Returns all the web root folders of the project.
+ * If the project is not a web project then the method will return an empty array.
+ * All the derived resources or resources belonged to derived containers will be
eliminated.
+ * If some folder is set as default web root source folder (available since WTP 3.3.1)
then this folder will be places in the very beginning of the result array.
+ * @param project
+ * @return
+ */
public static IPath getDefaultDeploymentDescriptorFolder(IVirtualFolder folder) {
if(!WTP_3_3_0) {
try {
- Method getDefaultDeploymentDescriptorFolder =
J2EEModuleVirtualComponent.class.getMethod("getDefaultDeploymentDescriptorFolder",
IVirtualFolder.class);
+ Method getDefaultDeploymentDescriptorFolder =
J2EEModuleVirtualComponent.class.getMethod("getDefaultDeploymentDescriptorFolder",
IVirtualFolder.class); //$NON-NLS-1$
return (IPath) getDefaultDeploymentDescriptorFolder.invoke(null, folder);
} catch (NoSuchMethodException nsme) {
// Not available in this WTP version, let's ignore it