Commit 2768ddcf authored by Marco Konersmann's avatar Marco Konersmann

The resource was not reloaded by the ResourceChangeListener

parent bc61facc
Pipeline #3034 failed with stages
in 1 minute and 41 seconds
......@@ -11,22 +11,25 @@ import org.eclipse.core.resources.IResourceChangeListener;
import org.eclipse.core.resources.IResourceDelta;
import org.eclipse.core.resources.IResourceDeltaVisitor;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
import org.eclipse.jdt.core.IJavaProject;
public class ResourceChangeListener implements IResourceChangeListener, IResourceDeltaVisitor {
CodelingLogger log = new CodelingLogger(getClass());
Resource resource;
private URI resourceURI;
private final ImplementationLanguageDefinition implementationLanguage;
private final SpecificationLanguageDefinition specificationLanguage;
private final List<IJavaProject> projects;
public ResourceChangeListener(Resource resource, ImplementationLanguageDefinition implementationLanguage,
public ResourceChangeListener(URI resourceURI, ImplementationLanguageDefinition implementationLanguage,
SpecificationLanguageDefinition modelingLanguage, List<IJavaProject> projects) {
this.implementationLanguage = implementationLanguage;
this.specificationLanguage = modelingLanguage;
this.resource = resource;
this.resourceURI = resourceURI;
this.projects = projects;
}
......@@ -44,7 +47,7 @@ public class ResourceChangeListener implements IResourceChangeListener, IResourc
// We are only interested in content changes
if ((delta.getFlags() & IResourceDelta.CONTENT) != 0)
// Only the specification model file
if (delta.getResource().getFullPath().toString().equals(resource.getURI().toPlatformString(true))) {
if (delta.getResource().getFullPath().toString().equals(resourceURI.toPlatformString(true))) {
startModelToCodeJob();
return false;
}
......@@ -52,6 +55,8 @@ public class ResourceChangeListener implements IResourceChangeListener, IResourc
}
public void startModelToCodeJob() {
ResourceSet rSet = new ResourceSetImpl();
Resource resource = rSet.getResource(resourceURI, true);
final ModelIntegrationTask job = new ModelIntegrationTask(resource.getContents(), implementationLanguage,
specificationLanguage, projects);
job.setUser(true);
......
......@@ -89,7 +89,7 @@ public class ModelExtractionHandler extends AbstractHandler {
} catch (InterruptedException e) {
}
// Create resource change listener on created resource.
resourceChangeListener = new ResourceChangeListener(modelResource, sourceLanguage,
resourceChangeListener = new ResourceChangeListener(modelResource.getURI(), sourceLanguage,
(SpecificationLanguageDefinition) targetLanguage, projects);
ResourcesPlugin.getWorkspace().addResourceChangeListener(resourceChangeListener,
IResourceChangeEvent.POST_CHANGE);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment