Author: scabanovich
Date: 2008-01-29 11:33:45 -0500 (Tue, 29 Jan 2008)
New Revision: 6014
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/util/EclipseResourceUtil.java
Log:
JBIDE-1655
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/util/EclipseResourceUtil.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/util/EclipseResourceUtil.java 2008-01-29
14:56:13 UTC (rev 6013)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/util/EclipseResourceUtil.java 2008-01-29
16:33:45 UTC (rev 6014)
@@ -13,7 +13,6 @@
import java.io.File;
import java.io.IOException;
import java.net.URL;
-import java.net.URLClassLoader;
import java.util.*;
import org.eclipse.core.resources.*;
@@ -204,7 +203,13 @@
try {
if(p.hasNature(natures[i])) {
IModelNature n = (IModelNature)p.getNature(natures[i]);
- return n == null || n.getModel() == null ? null : n;
+ if(n == null) return null;
+ n = testNature(n);
+ if(n == null) {
+ ModelPlugin.getPluginLog().logWarning("Project " + p + " has
corrupted nuture: " + natures[i]);
+ removeNatureFromProject(p, natures[i]);
+ }
+ return n;
}
} catch (CoreException e) {
ModelPlugin.getPluginLog().logError(e);
@@ -212,11 +217,29 @@
}
return null;
}
+
+ private static IModelNature testNature(IModelNature n) {
+ if(n == null || n.getModel() == null) return null;
+ XModel model = n.getModel();
+ XModelObject object = model.getRoot();
+ if(object == null) return null;
+ if(!"Root".equals(object.getModelEntity().getName())) return null;
+ return n;
+ }
public static IModelNature getModelNature(IProject p, String id) {
if(p == null || !p.isOpen()) return null;
try {
- if(p.hasNature(id)) return (IModelNature)p.getNature(id);
+ if(p.hasNature(id)) {
+ IModelNature n = (IModelNature)p.getNature(id);
+ if(n == null) return null;
+ n = testNature(n);
+ if(n == null) {
+ ModelPlugin.getPluginLog().logWarning("Project " + p + " has
corrupted nuture: " + id);
+ removeNatureFromProject(p, id);
+ }
+ return n;
+ }
} catch (CoreException e) {
ModelPlugin.getPluginLog().logError(e);
}
Show replies by date