Commit f9384742 authored by Dominique Marcadet's avatar Dominique Marcadet

move metamodel handling from Editor to Main project

parent ef94c21f
......@@ -5,7 +5,11 @@ Bundle-SymbolicName: fr.centralesupelec.edf.riseclipse.main;singleton:=true
Bundle-Version: 1.0.2.qualifier
Bundle-Vendor: CentraleSupélec & EDF
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Require-Bundle: org.eclipse.emf.common,
Require-Bundle: org.eclipse.core.runtime,
org.eclipse.emf.common,
org.eclipse.emf.ecore,
org.eclipse.emf.ecore.xmi
org.eclipse.emf.ecore.xmi,
org.eclipse.jface,
org.eclipse.equinox.registry,
org.eclipse.jdt.annotation
Export-Package: fr.centralesupelec.edf.riseclipse.util
......@@ -84,7 +84,7 @@
</documentation>
<appinfo>
<meta.attribute kind="java" basedOn=":org.eclipse.emf.ecore.resource.Resource$Factory"/>
<meta.attribute kind="java" basedOn=":fr.centralesupelec.edf.riseclipse.util.IRiseClipseResourceFactory"/>
</appinfo>
</annotation>
</attribute>
......@@ -104,7 +104,7 @@
</documentation>
<appinfo>
<meta.attribute kind="java" basedOn="fr.centralesupelec.edf.riseclipse.util.RiseClipseResourceSetFactory:"/>
<meta.attribute kind="java" basedOn=":fr.centralesupelec.edf.riseclipse.util.IRiseClipseResourceSetFactory"/>
</appinfo>
</annotation>
</attribute>
......
......@@ -18,6 +18,8 @@
*/
package fr.centralesupelec.edf.riseclipse.util;
import java.util.Optional;
import org.eclipse.emf.common.util.BasicEList;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.common.util.URI;
......@@ -64,16 +66,12 @@ public abstract class AbstractRiseClipseResourceSet extends ResourceSetImpl impl
@Override
public void printStatistics( IRiseClipseConsole console ) {
for( IRiseClipseResource r : getRiseClipseResources() ) {
r.printStatistics( console );
}
getRiseClipseResources().stream().forEach( r -> r.printStatistics( console ) );
}
@Override
public void finalizeLoad( IRiseClipseConsole console ) {
for( IRiseClipseResource r : getRiseClipseResources() ) {
r.finalizeLoad( console );
}
getRiseClipseResources().stream().forEach( r -> r.finalizeLoad( console ) );
}
public EList< IRiseClipseResource > getRiseClipseResources() {
......@@ -95,10 +93,6 @@ public abstract class AbstractRiseClipseResourceSet extends ResourceSetImpl impl
@Override
public Resource getResource( URI uri, boolean loadOnDemand ) {
Resource res = super.getResource( uri, loadOnDemand );
// createResource has been called before, so check is useless
// if(( res != null ) && strictContent && ( ! ( res instanceof IRiseClipseResource ))) {
// throw new RiseClipseFatalException( "AbstractRiseClipseResourceSet.getResource(): not an IRiseClipseResource", null );
// }
if( callFinalizeLoadAfterGetResource && ( res instanceof IRiseClipseResource )) {
finalizeLoad( console );
......@@ -111,13 +105,22 @@ public abstract class AbstractRiseClipseResourceSet extends ResourceSetImpl impl
*/
@Override
public Resource createResource( URI uri, String contentType ) {
Resource res = super.createResource( uri, contentType );
if(( res != null ) && strictContent && ( ! ( res instanceof IRiseClipseResource ))) {
throw new RiseClipseFatalException( "AbstractRiseClipseResourceSet.getResource(): not an IRiseClipseResource", null );
Resource res = null;
Optional< String > metamodelName = RiseClipseMetamodel.findMetamodelFor( uri );
if( metamodelName.isPresent() ) {
res = createRiseClipseResource( uri, contentType );
}
if(( res == null ) && ! strictContent ) {
res = super.createResource( uri, contentType );
}
if( res != null ) {
getResources().add( res );
}
return res;
}
protected abstract IRiseClipseResource createRiseClipseResource( URI uri, String contentType );
}
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