Commit 5035bd86 authored by Dominique Marcadet's avatar Dominique Marcadet

update for correct finalization

Add console to resourceSet constructor and allow for calling finalize
automatically after a resource is loaded
parent 5b1d4a9d
......@@ -44,7 +44,7 @@ public abstract class RiseClipseModelLoader {
}
public void reset() {
this.resourceSet = new RiseClipseResourceSet();
this.resourceSet = new RiseClipseResourceSet( console );
}
public void reset( IRiseClipseResourceSet resourceSet ) {
......
......@@ -34,6 +34,31 @@ import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
*/
public class RiseClipseResourceSet extends ResourceSetImpl implements IRiseClipseResourceSet {
protected IRiseClipseConsole console;
// When the resourceSet will load several resources at once, it is
// useless to call finalizeLoad() after each one. Indeed, such a call
// can lead to wrong error messages.
// As the resourceSet do not know when the last resource is loaded,
// it is the client that must call finalizeLoad() in this case.
//
// When a resource is added to an existing resourceSet, the client
// may not have an easy way to call finalizeLoad() after (the "load
// resource" command in RiseClipse editor use directly the editing
// domain). If set, this boolean will then call finalizeLoad() after
// a getResource().
private boolean callFinalizeLoadAfterGetResource;
public RiseClipseResourceSet( IRiseClipseConsole console ) {
this.console = console;
this.callFinalizeLoadAfterGetResource = false;
}
// TODO: is unset needed ?
public void setCallFinalizeLoadAfterGetResource() {
callFinalizeLoadAfterGetResource = true;
}
@Override
public void printStatistics( IRiseClipseConsole console ) {
for( IRiseClipseResource r : getRiseClipseResources() ) {
......@@ -71,6 +96,7 @@ public class RiseClipseResourceSet extends ResourceSetImpl implements IRiseClips
if(( res != null ) && ( ! ( res instanceof IRiseClipseResource ))) {
throw new RiseClipseFatalException( "RiseClipseResourceSet.getResource(): not an IRiseClipseResource", null );
}
if( callFinalizeLoadAfterGetResource ) finalizeLoad( console );
return ( IRiseClipseResource ) res;
}
......
......@@ -20,8 +20,8 @@ package fr.centralesupelec.edf.riseclipse.util;
public class RiseClipseResourceSetFactory {
public IRiseClipseResourceSet createResourceSet() {
return new RiseClipseResourceSet();
public IRiseClipseResourceSet createResourceSet( IRiseClipseConsole console ) {
return new RiseClipseResourceSet( console );
}
}
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