[221565] fix eresource content type issues
diff --git a/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/emf/workbench/ProjectUtilities.java b/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/emf/workbench/ProjectUtilities.java
index 2bdc3ff..eae2e81 100644
--- a/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/emf/workbench/ProjectUtilities.java
+++ b/plugins/org.eclipse.jem.util/jemutil/org/eclipse/jem/util/emf/workbench/ProjectUtilities.java
@@ -10,7 +10,7 @@
*******************************************************************************/
/*
* $$RCSfile: ProjectUtilities.java,v $$
- * $$Revision: 1.5 $$ $$Date: 2008/02/28 18:55:47 $$
+ * $$Revision: 1.6 $$ $$Date: 2008/03/05 19:43:18 $$
*/
package org.eclipse.jem.util.emf.workbench;
@@ -285,7 +285,8 @@
public static IProject getProject(EObject aRefObject) {
if (aRefObject != null) {
Resource resource = aRefObject.eResource();
- return getProject(resource);
+ if (resource != null)
+ return getProject(resource);
}
return null;
}
diff --git a/plugins/org.eclipse.wst.common.emfworkbench.integration/META-INF/MANIFEST.MF b/plugins/org.eclipse.wst.common.emfworkbench.integration/META-INF/MANIFEST.MF
index da94f00..636603b 100644
--- a/plugins/org.eclipse.wst.common.emfworkbench.integration/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.wst.common.emfworkbench.integration/META-INF/MANIFEST.MF
@@ -21,4 +21,5 @@
org.eclipse.wst.common.project.facet.core;bundle-version="[1.1.0,2.0.0)",
org.eclipse.core.expressions;bundle-version="[3.2.0,4.0.0)"
Eclipse-LazyStart: true
-Bundle-RequiredExecutionEnvironment: J2SE-1.4
+Bundle-RequiredExecutionEnvironment: J2SE-1.4,
+ J2SE-1.5
diff --git a/plugins/org.eclipse.wst.common.emfworkbench.integration/src/org/eclipse/wst/common/internal/emfworkbench/EMFWorkbenchContext.java b/plugins/org.eclipse.wst.common.emfworkbench.integration/src/org/eclipse/wst/common/internal/emfworkbench/EMFWorkbenchContext.java
index dc33755..66c6b35 100644
--- a/plugins/org.eclipse.wst.common.emfworkbench.integration/src/org/eclipse/wst/common/internal/emfworkbench/EMFWorkbenchContext.java
+++ b/plugins/org.eclipse.wst.common.emfworkbench.integration/src/org/eclipse/wst/common/internal/emfworkbench/EMFWorkbenchContext.java
@@ -105,11 +105,11 @@
editModel.access(accessorKey);
}
} else {
+ if (editModel.isDisposed() || editModel.isDisposing()) {
+ editModel = createEditModelForWrite(editModelID, params);
+ cacheEditModel(editModel, params);
+ }
synchronized (editModel) {
- if (editModel.isDisposed() || editModel.isDisposing()) {
- editModel = createEditModelForWrite(editModelID, params);
- cacheEditModel(editModel, params);
- }
editModel.access(accessorKey);
}
}
@@ -136,11 +136,11 @@
editModel.access(accessorKey);
}
} else {
+ if (editModel.isDisposed() || editModel.isDisposing()) {
+ editModel = createEditModelForRead(editModelID, params);
+ cacheEditModel(editModel, params);
+ }
synchronized (editModel) {
- if (editModel.isDisposed() || editModel.isDisposing()) {
- editModel = createEditModelForRead(editModelID, params);
- cacheEditModel(editModel, params);
- }
EditModelLeastUsedCache.getInstance().access(editModel);
editModel.access(accessorKey);
}
diff --git a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/SimpleValidateEdit.java b/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/SimpleValidateEdit.java
index cd27da2..ec84468 100644
--- a/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/SimpleValidateEdit.java
+++ b/plugins/org.eclipse.wst.common.frameworks/src/org/eclipse/wst/common/frameworks/internal/SimpleValidateEdit.java
@@ -13,6 +13,7 @@
import java.util.List;
import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.IStatus;
import org.eclipse.jem.util.UIContextDetermination;
public class SimpleValidateEdit {
@@ -33,7 +34,12 @@
return true;
}
ISimpleValidateEditContext validator = (ISimpleValidateEditContext) UIContextDetermination.createInstance(ISimpleValidateEditContext.CLASS_KEY);
- return validator.validateEdit(files).isOK();
+ if (validator != null) {
+ IStatus status = validator.validateEdit(files);
+ if (status != null)
+ return status.isOK();
+ }
+ return true;
}
}
diff --git a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/ArtifactEdit.java b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/ArtifactEdit.java
index a6745fd..86bd496 100644
--- a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/ArtifactEdit.java
+++ b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/ArtifactEdit.java
@@ -11,6 +11,7 @@
package org.eclipse.wst.common.componentcore;
import java.util.EventObject;
+import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.logging.Level;
@@ -31,6 +32,7 @@
import org.eclipse.jem.util.UIContextDetermination;
import org.eclipse.wst.common.componentcore.internal.ArtifactEditModel;
import org.eclipse.wst.common.componentcore.internal.BinaryComponentHelper;
+import org.eclipse.wst.common.componentcore.internal.impl.ArtifactEditModelFactory;
import org.eclipse.wst.common.componentcore.internal.impl.ModuleURIUtil;
import org.eclipse.wst.common.componentcore.internal.util.IModuleConstants;
import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
@@ -367,16 +369,19 @@
if (!forCreate && !isValidEditableModule(component))
throw new IllegalArgumentException("Invalid component handle: " + aProject);
project = aProject;
- URI componentURI = null;
- if (getContentTypeDescriber() != null)
- componentURI = ModuleURIUtil.fullyQualifyURI(aProject,getContentTypeDescriber());
- else
- componentURI = ModuleURIUtil.fullyQualifyURI(aProject);
-
- if (toAccessAsReadOnly)
+ URI componentURI = ModuleURIUtil.fullyQualifyURI(aProject);
+ if (getContentTypeDescriber() != null) {
+ if (editModelParams == null)
+ editModelParams = new HashMap();
+ editModelParams.put(ArtifactEditModelFactory.PARAM_ROOT_URI, getRootURI());
+ editModelParams.put(ArtifactEditModelFactory.PARAM_ROOT_CONTENT_TYPE, getContentTypeDescriber());
+ }
+ if (toAccessAsReadOnly)
artifactEditModel = nature.getArtifactEditModelForRead(componentURI, this, projectType, editModelParams);
- else
+ else
artifactEditModel = nature.getArtifactEditModelForWrite(componentURI, this, projectType, editModelParams);
+
+
isReadOnly = toAccessAsReadOnly;
isArtifactEditModelSelfManaged = true;
}
@@ -410,6 +415,23 @@
return "org.eclipse.jst.j2ee.appclientDD";
return null;
}
+
+ /**
+ * Used to optionally define an root URI for the project
+ * @return
+ */
+ protected URI getRootURI() {
+
+ if (isProjectOfType(project, IModuleConstants.JST_EJB_MODULE))
+ return URI.createURI("META-INF/ejb-jar.xml");
+ if (isProjectOfType(project, IModuleConstants.JST_WEB_MODULE))
+ return URI.createURI("WEB-INF/web.xml");
+ if (isProjectOfType(project, IModuleConstants.JST_EAR_MODULE))
+ return URI.createURI("META-INF/application.xml");
+ if (isProjectOfType(project, IModuleConstants.JST_APPCLIENT_MODULE))
+ return URI.createURI("META-INF/application-client.xml");
+ return null;
+ }
protected boolean validProjectVersion(IProject project2) {
return true;
diff --git a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/ArtifactEditModel.java b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/ArtifactEditModel.java
index fd1385a..9e38950 100644
--- a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/ArtifactEditModel.java
+++ b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/ArtifactEditModel.java
@@ -66,6 +66,8 @@
public static final Class ADAPTER_TYPE = ArtifactEditModel.class;
private final IProject componentProject;
private final IPath modulePath;
+ private URI rootURI;
+ private String rootContentType;
private final IVirtualComponent virtualComponent;
private final URI componentURI;
@@ -101,7 +103,16 @@
public ArtifactEditModel(String anEditModelId, EMFWorkbenchContext aContext, boolean toMakeReadOnly, URI aModuleURI) {
this(anEditModelId, aContext, toMakeReadOnly, true, aModuleURI);
}
-
+
+ public ArtifactEditModel(String anEditModelId, EMFWorkbenchContext aContext, boolean toMakeReadOnly, boolean toAccessUnknownResourcesAsReadOnly, URI aModuleURI,URI rootURI,
+ String rootContentType) {
+ this(anEditModelId, aContext, toMakeReadOnly, toAccessUnknownResourcesAsReadOnly, aModuleURI);
+ this.rootURI = rootURI;
+ this.rootContentType = rootContentType;
+
+ }
+
+
/**
*
* <p>
@@ -154,6 +165,14 @@
processLoadedResources(componentProject);
}
+ public ArtifactEditModel(String editModelID, EMFWorkbenchContext context, boolean toMakeReadOnly, URI moduleURI, URI rootURI,
+ String rootContentType) {
+ this(editModelID, context, toMakeReadOnly, true, moduleURI);
+ this.rootURI = rootURI;
+ this.rootContentType = rootContentType;
+
+ }
+
/**
* <p>
* Accesses resources within the underlying resource set. Takes a standard URI attaches module
@@ -168,8 +187,15 @@
* @return Resource (@see Resource)
*/
public Resource getResource(URI aUri) {
- // First check if passed URI is already normalized...
- IPath requestPath = modulePath.append(new Path(aUri.path()));
+ IPath requestPath;
+ //If requesting rootURI, use content type describer if available
+ if (rootURI != null && rootURI.equals(aUri) && rootContentType != null) {
+ requestPath = modulePath.append(new Path(rootContentType));
+ requestPath = requestPath.append(new Path(aUri.path()));
+ }
+ else {// First check if passed URI is already normalized...
+ requestPath = modulePath.append(new Path(aUri.path()));
+ }
URI resourceURI = URI.createURI(PlatformURLModuleConnection.MODULE_PROTOCOL + requestPath.toString());
return super.getResource(resourceURI);
}
diff --git a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/impl/ArtifactEditModelFactory.java b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/impl/ArtifactEditModelFactory.java
index aad88e4..17c57ea 100644
--- a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/impl/ArtifactEditModelFactory.java
+++ b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/impl/ArtifactEditModelFactory.java
@@ -29,15 +29,21 @@
public static final String PARAM_MODULE_URI = "MODULE_URI"; //$NON-NLS-1$
+ public static final String PARAM_ROOT_URI = "ROOT_URI"; //$NON-NLS-1$
+
+ public static final String PARAM_ROOT_CONTENT_TYPE = "ROOT_CONTENT_TYPE"; //$NON-NLS-1$
+
/* (non-Javadoc)
* @see org.eclipse.wst.common.internal.emfworkbench.integration.EditModelFactory#createEditModelForRead(java.lang.String, org.eclipse.wst.common.internal.emfworkbench.EMFWorkbenchContext, java.util.Map)
*/
public EditModel createEditModelForRead(String editModelID, EMFWorkbenchContext context, Map params) {
URI moduleURI = (URI) ((params != null) ? params.get(PARAM_MODULE_URI) : null);
+ URI rootURI = (URI) ((params != null) ? params.get(PARAM_ROOT_URI) : null);
+ String rootContentType = (String) ((params != null) ? params.get(PARAM_ROOT_CONTENT_TYPE) : null);
if(moduleURI == null)
throw new IllegalStateException("A Module URI must be provided");
- return new ArtifactEditModel(editModelID, context, true, moduleURI);
+ return new ArtifactEditModel(editModelID, context, true, moduleURI, rootURI, rootContentType);
}
/* (non-Javadoc)
@@ -45,9 +51,11 @@
*/
public EditModel createEditModelForWrite(String editModelID, EMFWorkbenchContext context, Map params) {
URI moduleURI = (URI) ((params != null) ? params.get(PARAM_MODULE_URI) : null);
+ URI rootURI = (URI) ((params != null) ? params.get(PARAM_ROOT_URI) : null);
+ String rootContentType = (String) ((params != null) ? params.get(PARAM_ROOT_CONTENT_TYPE) : null);
if(moduleURI == null)
throw new IllegalStateException("A Module URI must be provided");
- return new ArtifactEditModel(editModelID, context, false,false, moduleURI);
+ return new ArtifactEditModel(editModelID, context, false, moduleURI, rootURI, rootContentType);
}
/* (non-Javadoc)