Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCarl Anderson2016-04-29 18:54:56 +0000
committerCarl Anderson2016-04-29 18:54:56 +0000
commitf59a81ed20ced10166d28c28cfcbc47352fb8ba8 (patch)
treebf58a131be74c9286d16653450d92a001c746681 /plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse
parent6921b4538f904c74670060b47165e2b736a3647e (diff)
downloadwebtools.javaee-f59a81ed20ced10166d28c28cfcbc47352fb8ba8.tar.gz
webtools.javaee-f59a81ed20ced10166d28c28cfcbc47352fb8ba8.tar.xz
webtools.javaee-f59a81ed20ced10166d28c28cfcbc47352fb8ba8.zip
[492096] Contribute Servlet project detection to Smart Importer - fixes
Diffstat (limited to 'plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse')
-rw-r--r--plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/wizard/ServletProjectConfigurator.java17
1 files changed, 10 insertions, 7 deletions
diff --git a/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/wizard/ServletProjectConfigurator.java b/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/wizard/ServletProjectConfigurator.java
index 1a8ba7b9b..eccd4d6fd 100644
--- a/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/wizard/ServletProjectConfigurator.java
+++ b/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/wizard/ServletProjectConfigurator.java
@@ -28,11 +28,14 @@ import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jface.wizard.IWizard;
+import org.eclipse.jst.j2ee.internal.J2EEConstants;
+import org.eclipse.jst.j2ee.internal.J2EEVersionConstants;
import org.eclipse.jst.j2ee.project.facet.IJ2EEModuleFacetInstallDataModelProperties;
import org.eclipse.jst.j2ee.web.project.facet.WebFacetInstallDataModelProvider;
import org.eclipse.jst.servlet.ui.internal.plugin.ServletUIPlugin;
import org.eclipse.ui.wizards.datatransfer.ProjectConfigurator;
import org.eclipse.ui.wizards.datatransfer.RecursiveFileFinder;
+import org.eclipse.wst.common.componentcore.internal.util.IModuleConstants;
import org.eclipse.wst.common.frameworks.datamodel.DataModelFactory;
import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
import org.eclipse.wst.common.project.facet.core.IFacetedProject;
@@ -45,7 +48,7 @@ public class ServletProjectConfigurator implements ProjectConfigurator {
public boolean canConfigure(IProject project, Set<IPath> ignoredDirectories, IProgressMonitor monitor) {
try {
- RecursiveFileFinder finder = new RecursiveFileFinder("web.xml", ignoredDirectories); //$NON-NLS-1$
+ RecursiveFileFinder finder = new RecursiveFileFinder(J2EEConstants.WEBAPP_DD_SHORT_NAME, ignoredDirectories);
project.accept(finder);
return finder.getFile() != null;
} catch (CoreException ex) {
@@ -63,7 +66,7 @@ public class ServletProjectConfigurator implements ProjectConfigurator {
try {
if (!ProjectFacetsManager.isProjectFacetDefined(project.getName())) {
IFacetedProject facetedProject = ProjectFacetsManager.create(project, true, monitor);
- IProjectFacet JAVA_FACET = ProjectFacetsManager.getProjectFacet("jst.java"); //$NON-NLS-1$
+ IProjectFacet JAVA_FACET = ProjectFacetsManager.getProjectFacet(IModuleConstants.JST_JAVA);
ProjectScope ps = new ProjectScope(project);
IEclipsePreferences JDPprojectNode = ps.getNode(JavaCore.PLUGIN_ID);
@@ -75,11 +78,11 @@ public class ServletProjectConfigurator implements ProjectConfigurator {
IFacetedProject facetedProject = ProjectFacetsManager.create(project, true, monitor);
- IProjectFacet WEB_FACET = ProjectFacetsManager.getProjectFacet("jst.web"); //$NON-NLS-1$
+ IProjectFacet WEB_FACET = ProjectFacetsManager.getProjectFacet(IModuleConstants.JST_WEB_MODULE);
if (!facetedProject.hasProjectFacet(WEB_FACET)) {
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
- RecursiveFileFinder finder = new RecursiveFileFinder("web.xml", ignoredDirectories); //$NON-NLS-1$
+ RecursiveFileFinder finder = new RecursiveFileFinder(J2EEConstants.WEBAPP_DD_SHORT_NAME, ignoredDirectories);
project.accept(finder);
InputStream webXmlStream = finder.getFile().getContents();
Document doc = dBuilder.parse(webXmlStream);
@@ -87,10 +90,10 @@ public class ServletProjectConfigurator implements ProjectConfigurator {
IDataModel aFacetInstallDataModel = DataModelFactory.createDataModel(new WebFacetInstallDataModelProvider());
aFacetInstallDataModel.setBooleanProperty(IJ2EEModuleFacetInstallDataModelProperties.ADD_TO_EAR, false);
- String version = ((Element)doc.getElementsByTagName("web-app").item(0)).getAttribute("version"); //$NON-NLS-1$ //$NON-NLS-2$
- if (version.isEmpty()) {
+ String version = ((Element)doc.getElementsByTagName(J2EEConstants.WEBAPP_DOCTYPE).item(0)).getAttribute("version"); //$NON-NLS-1$
+ if (version.length() < 1) {
// TODO decide this according to JRE version : Java6 => servlet 2.5; Java 7 => servlet 3.1
- version = "3.1"; //$NON-NLS-1$
+ version = J2EEVersionConstants.VERSION_3_1_TEXT;
}
facetedProject.installProjectFacet(WEB_FACET.getVersion(version), aFacetInstallDataModel, monitor);
}

Back to the top