summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSnjezana Peco2013-01-24 16:43:46 (EST)
committerRoberto Sanchez2014-04-09 16:04:35 (EDT)
commit53d811683a2fbe7e8f8223c55d789a0ec2f2ebd2 (patch)
treec68fd6e4a6b94e8527a29421b1130bbf66a2fdff
parent6821ae1a2b30987de2b3cfca36136628c252a204 (diff)
downloadwebtools.javaee-53d811683a2fbe7e8f8223c55d789a0ec2f2ebd2.zip
webtools.javaee-53d811683a2fbe7e8f8223c55d789a0ec2f2ebd2.tar.gz
webtools.javaee-53d811683a2fbe7e8f8223c55d789a0ec2f2ebd2.tar.bz2
-rw-r--r--plugins/org.eclipse.jst.j2ee/common/org/eclipse/jst/j2ee/internal/common/classpath/J2EEComponentClasspathUpdater.java4
-rw-r--r--plugins/org.eclipse.jst.jee/jeecreation/org/eclipse/jst/jee/model/internal/EAR5ModelProviderFactory.java33
-rw-r--r--plugins/org.eclipse.jst.jee/jeecreation/org/eclipse/jst/jee/model/internal/JEE5ModelProvider.java16
3 files changed, 50 insertions, 3 deletions
diff --git a/plugins/org.eclipse.jst.j2ee/common/org/eclipse/jst/j2ee/internal/common/classpath/J2EEComponentClasspathUpdater.java b/plugins/org.eclipse.jst.j2ee/common/org/eclipse/jst/j2ee/internal/common/classpath/J2EEComponentClasspathUpdater.java
index a4d3277..16ff147 100644
--- a/plugins/org.eclipse.jst.j2ee/common/org/eclipse/jst/j2ee/internal/common/classpath/J2EEComponentClasspathUpdater.java
+++ b/plugins/org.eclipse.jst.j2ee/common/org/eclipse/jst/j2ee/internal/common/classpath/J2EEComponentClasspathUpdater.java
@@ -64,6 +64,7 @@ import org.eclipse.wst.common.componentcore.internal.builder.IDependencyGraphLis
import org.eclipse.wst.common.componentcore.internal.builder.IDependencyGraphUpdateEvent;
import org.eclipse.wst.common.componentcore.internal.impl.ResourceTreeRootAdapter;
import org.eclipse.wst.common.componentcore.internal.impl.WTPModulesResourceFactory;
+import org.eclipse.wst.common.componentcore.internal.resources.VirtualComponent;
import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
import org.eclipse.wst.common.componentcore.resources.IVirtualFolder;
import org.eclipse.wst.common.componentcore.resources.IVirtualReference;
@@ -347,6 +348,9 @@ public class J2EEComponentClasspathUpdater implements IResourceChangeListener, I
if (JavaEEProjectUtilities.isEARProject(earProject))
{
IVirtualComponent earComponent = ComponentCore.createComponent(earProject);
+ if (earComponent instanceof VirtualComponent) {
+ ((VirtualComponent)earComponent).flushCache();
+ }
IVirtualReference[] refs = J2EEProjectUtilities.getComponentReferences(earComponent);
IVirtualComponent comp = null;
for (int j = 0; j < refs.length; j++) {
diff --git a/plugins/org.eclipse.jst.jee/jeecreation/org/eclipse/jst/jee/model/internal/EAR5ModelProviderFactory.java b/plugins/org.eclipse.jst.jee/jeecreation/org/eclipse/jst/jee/model/internal/EAR5ModelProviderFactory.java
index c364830..3aa970e 100644
--- a/plugins/org.eclipse.jst.jee/jeecreation/org/eclipse/jst/jee/model/internal/EAR5ModelProviderFactory.java
+++ b/plugins/org.eclipse.jst.jee/jeecreation/org/eclipse/jst/jee/model/internal/EAR5ModelProviderFactory.java
@@ -10,19 +10,46 @@
*******************************************************************************/
package org.eclipse.jst.jee.model.internal;
+import java.util.HashMap;
+import java.util.Map;
+
import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IResourceChangeEvent;
+import org.eclipse.core.resources.IResourceChangeListener;
+import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.jst.j2ee.model.IModelProvider;
import org.eclipse.jst.j2ee.model.IModelProviderFactory;
import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
public class EAR5ModelProviderFactory implements IModelProviderFactory {
- public IModelProvider create(IProject project) {
- return new EAR5ModelProvider(project);
+ private static Map<IProject, IModelProvider> providersMap = new HashMap<IProject, IModelProvider>();
+
+ private static IResourceChangeListener listener = new IResourceChangeListener() {
+
+ public void resourceChanged(IResourceChangeEvent event) {
+ IResource project = event.getResource();
+ if (project instanceof IProject) {
+ providersMap.remove(project);
+ }
+
+ }
+ };
+ static {
+ ResourcesPlugin.getWorkspace().addResourceChangeListener(listener, IResourceChangeEvent.PRE_DELETE | IResourceChangeEvent.PRE_CLOSE);
+ }
+ public synchronized IModelProvider create(IProject project) {
+ IModelProvider provider = providersMap.get(project);
+ if (provider == null) {
+ provider = new EAR5ModelProvider(project);
+ providersMap.put(project, provider);
+ }
+ return provider;
}
public IModelProvider create(IVirtualComponent component) {
- return new EAR5ModelProvider(component.getProject());
+ return create(component.getProject());
}
}
diff --git a/plugins/org.eclipse.jst.jee/jeecreation/org/eclipse/jst/jee/model/internal/JEE5ModelProvider.java b/plugins/org.eclipse.jst.jee/jeecreation/org/eclipse/jst/jee/model/internal/JEE5ModelProvider.java
index c417e0b..574d0ae 100644
--- a/plugins/org.eclipse.jst.jee/jeecreation/org/eclipse/jst/jee/model/internal/JEE5ModelProvider.java
+++ b/plugins/org.eclipse.jst.jee/jeecreation/org/eclipse/jst/jee/model/internal/JEE5ModelProvider.java
@@ -14,6 +14,7 @@ import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
+import java.util.Iterator;
import java.util.List;
import org.eclipse.core.resources.IFile;
@@ -126,6 +127,21 @@ public class JEE5ModelProvider implements IModelProvider, ResourceStateInputProv
}
}
private void addManagedResource(XMLResourceImpl res) {
+ if (res == null || modelResources.contains(res)) {
+ return;
+ }
+ URI uri = res.getURI();
+ for (Iterator iterator = modelResources.iterator(); iterator.hasNext();) {
+ XMLResourceImpl resource = (XMLResourceImpl) iterator.next();
+ if (resource == null) {
+ iterator.remove();
+ continue;
+ }
+ if (resource.getURI() != null && resource.getURI().equals(uri)) {
+ resource.eAdapters().remove(resourceAdapter);
+ iterator.remove();
+ }
+ }
modelResources.add(res);
if (!res.eAdapters().contains(resourceAdapter))
res.eAdapters().add(resourceAdapter);