[nobug] Fixing editmodel access
diff --git a/plugins/org.eclipse.wst.common.emfworkbench.integration/src/org/eclipse/wst/common/internal/emfworkbench/integration/EditModel.java b/plugins/org.eclipse.wst.common.emfworkbench.integration/src/org/eclipse/wst/common/internal/emfworkbench/integration/EditModel.java
index 2f638a8..c1a88a4 100644
--- a/plugins/org.eclipse.wst.common.emfworkbench.integration/src/org/eclipse/wst/common/internal/emfworkbench/integration/EditModel.java
+++ b/plugins/org.eclipse.wst.common.emfworkbench.integration/src/org/eclipse/wst/common/internal/emfworkbench/integration/EditModel.java
@@ -85,6 +85,7 @@
protected EditModelEvent dirtyModelEvent;
protected boolean isNotifing = false;
protected boolean disposing = false;
+ private boolean disposed = false;
protected ResourceStateValidator stateValidator;
protected boolean accessAsReadForUnKnownURIs;
protected ResourceAdapter resourceAdapter = new ResourceAdapter();
@@ -106,6 +107,8 @@
}
public EditModel(String editModelID, EMFWorkbenchContext context, boolean readOnly) {
+ if (context == null)
+ throw new IllegalStateException("EMF context can't be null");
this.editModelID = editModelID;
this.readOnly = readOnly;
this.emfContext = context;
@@ -139,6 +142,7 @@
}
public void dispose() {
+ disposed = true;
disposing = true;
if (commandStack != null)
commandStack.removeCommandStackListener(this);
@@ -890,9 +894,20 @@
}
public EMFWorkbenchContext getEmfContext() {
+ if (isDisposed())
+ throw new IllegalStateException("Edit Model already disposed");
+ if (emfContext == null)
+ throw new IllegalStateException("EMF context is null");
return emfContext;
}
+ private boolean isDisposed() {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+
+
public IProject getProject() {
return project;
}
diff --git a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/ModuleCoreNature.java b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/ModuleCoreNature.java
index 4e777b3..cf063fe 100644
--- a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/ModuleCoreNature.java
+++ b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/ModuleCoreNature.java
@@ -477,18 +477,18 @@
ProjectUtilities.addToBuildSpec(COMPONENT_STRUCTURAL_DEPENDENCY_RESOLVER_ID, getProject());
}
- private String getArtifactEditModelId(URI aModuleURI) {
- ModuleStructuralModel structuralModel = null;
+ private String getArtifactEditModelId(URI aModuleURI) {
+ StructureEdit editUtility = null;
try {
- structuralModel = getModuleStructuralModelForRead(Thread.currentThread());
- StructureEdit editUtility = (StructureEdit) structuralModel.getAdapter(StructureEdit.ADAPTER_TYPE);
+ IProject project = StructureEdit.getContainingProject(aModuleURI);
+ editUtility = StructureEdit.getStructureEditForRead(project);
WorkbenchComponent module = editUtility.findComponentByName(ModuleURIUtil.getDeployedName(aModuleURI));
return module.getComponentType().getComponentTypeId();
} catch (UnresolveableURIException uurie) {
// Ignore
} finally {
- if (structuralModel != null)
- structuralModel.releaseAccess(Thread.currentThread());
+ if (editUtility != null)
+ editUtility.dispose();
}
return null;
}