Author: scabanovich
Date: 2010-04-21 09:56:06 -0400 (Wed, 21 Apr 2010)
New Revision: 21581
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/wizards/project/ImportWebProjectWizardPage.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-5974
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/wizards/project/ImportWebProjectWizardPage.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/wizards/project/ImportWebProjectWizardPage.java 2010-04-21
13:55:32 UTC (rev 21580)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/wizards/project/ImportWebProjectWizardPage.java 2010-04-21
13:56:06 UTC (rev 21581)
@@ -13,6 +13,8 @@
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.io.File;
+import java.util.HashSet;
+import java.util.Set;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
@@ -22,6 +24,7 @@
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Status;
import org.jboss.tools.common.model.ui.attribute.XAttributeSupport;
import org.jboss.tools.common.model.ui.attribute.adapter.IModelPropertyEditorAdapter;
import org.jboss.tools.common.model.ui.attribute.editor.IPropertyEditor;
@@ -36,6 +39,11 @@
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Layout;
import org.eclipse.swt.widgets.Shell;
+import org.eclipse.wst.common.project.facet.core.IFacetedProject;
+import org.eclipse.wst.common.project.facet.core.IProjectFacet;
+import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion;
+import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager;
+import org.eclipse.wst.common.project.facet.core.IFacetedProject.Action;
import org.jboss.tools.common.meta.action.XEntityData;
import org.jboss.tools.common.meta.action.impl.XEntityDataImpl;
@@ -364,6 +372,50 @@
}
}
+ if(project != null && project.exists()) {
+ //Check existing faceted project
+ IProjectFacet f = ProjectFacetsManager.getProjectFacet("jst.web");
//$NON-NLS-1$
+ if(f != null) {
+ IFacetedProject fp = null;
+ try {
+ fp = ProjectFacetsManager.create(project);
+ } catch (CoreException e) {
+ e.printStackTrace();
+ }
+ if(fp != null) {
+ //Check that 'jst.web' facet is compatible with facets of existing faceted
projects
+ boolean hasJSTWebFacet = false;
+ Set<IProjectFacetVersion> vs = fp.getProjectFacets();
+ if(vs != null) for (IProjectFacetVersion v: vs) {
+ String id = v.getProjectFacet().getId();
+ if("jst.web".equals(id)) { //$NON-NLS-1$
+ hasJSTWebFacet = true;
+ }
+ }
+ if(!hasJSTWebFacet) {
+ Set<IProjectFacetVersion> fvs = f.getVersions();
+ boolean ok = false;
+ for (IProjectFacetVersion v: fvs) {
+ IFacetedProject.Action action = new Action(IFacetedProject.Action.Type.INSTALL, v,
null);
+ Set<IFacetedProject.Action> actions = new HashSet<Action>();
+ actions.add(action);
+ IStatus status = ProjectFacetsManager.check(vs, actions);
+ if(status != null && status.isOK()) {
+ ok = true;
+ break;
+ }
+ }
+ if (!ok) {
+ String message = "This project cannot be converted to Web Dynamic project
required for JSF capabilities."; //$NON-NLS-1$
+ setErrorMessage(message);
+ return false;
+ }
+ }
+ }
+
+ }
+ }
+
if(context.isInitialized()) return true;
boolean hasNature = false;
boolean hasJavaNature = false;