本文整理匯總了Java中org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl類的典型用法代碼示例。如果您正苦於以下問題:Java XMIResourceFactoryImpl類的具體用法?Java XMIResourceFactoryImpl怎麽用?Java XMIResourceFactoryImpl使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
XMIResourceFactoryImpl類屬於org.eclipse.emf.ecore.xmi.impl包,在下文中一共展示了XMIResourceFactoryImpl類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: loadSample
import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl; //導入依賴的package包/類
/**
* Loads the sample saved in the given file.
*
* @param graphEditor the graph editor in which the loaded model will be set
*/
private void loadSample(final String file, final GraphEditor graphEditor) {
final String samplePath = getClass().getResource(file).toExternalForm();
final URI fileUri = URI.createURI(samplePath);
final XMIResourceFactoryImpl resourceFactory = new XMIResourceFactoryImpl();
final Resource resource = resourceFactory.createResource(fileUri);
try {
resource.load(Collections.EMPTY_MAP);
} catch (final IOException e) {
e.printStackTrace();
}
if (!resource.getContents().isEmpty() && resource.getContents().get(0) instanceof GModel) {
final GModel model = (GModel) resource.getContents().get(0);
graphEditor.setModel(model);
}
}
示例2: Validate
import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl; //導入依賴的package包/類
public Validate()
{
Resource.Factory.Registry reg = Resource.Factory.Registry.INSTANCE;
Map<String, Object> m = reg.getExtensionToFactoryMap();
m.put("calender", new XMIResourceFactoryImpl());
ResourceSet rs = new ResourceSetImpl();
Resource r = rs.getResource(URI.createFileURI("model/mynew.calender"), true);
EObject root = r.getContents().get(0);
Iterator<EObject> i = r.getAllContents();
while(i.hasNext())
System.out.println(i.next());
}
示例3: createInjectorAndDoEMFRegistration
import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl; //導入依賴的package包/類
@Override
public Injector createInjectorAndDoEMFRegistration() {
// register default ePackages
if (!Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().containsKey("ecore"))
Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put(
"ecore", new EcoreResourceFactoryImpl());
if (!Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().containsKey("xmi"))
Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put(
"xmi", new XMIResourceFactoryImpl());
if (!Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().containsKey("xtextbin"))
Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put(
"xtextbin", new BinaryGrammarResourceFactoryImpl());
if (!EPackage.Registry.INSTANCE.containsKey(XtextPackage.eNS_URI))
EPackage.Registry.INSTANCE.put(XtextPackage.eNS_URI, XtextPackage.eINSTANCE);
Injector injector = createInjector();
register(injector);
return injector;
}
示例4: loadGenmodel
import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl; //導入依賴的package包/類
private GenModel loadGenmodel(String path) {
try {
if (!EPackage.Registry.INSTANCE.containsKey(GenModelPackage.eNS_URI))
EPackage.Registry.INSTANCE.put(GenModelPackage.eNS_URI, GenModelPackage.eINSTANCE);
Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("genmodel", new XMIResourceFactoryImpl());
ResourceSet rs = new ResourceSetImpl();
URI uri = URI.createURI(path);
Resource pkg = rs.getResource(uri, true);
return (GenModel) pkg.getContents().get(0);
} catch (Exception e) {
// ...
}
return null;
}
示例5: registerResourceFactories
import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl; //導入依賴的package包/類
/**
* This can be used to update the resource set's resource factory registry
* with all needed factories.
*
* @param resourceSet
* The resource set which registry has to be updated.
* @generated NOT
*/
@Override
public void registerResourceFactories ( final ResourceSet resourceSet )
{
super.registerResourceFactories ( resourceSet );
/*
* TODO If you need additional resource factories registrations, you can register them here. the following line
* (in comment) is an example of the resource factory registration for UML. If you want to change the content
* of this method, do NOT forget to change the "@generated" tag in the Javadoc of this method to "@generated NOT".
* Without this new tag, any compilation of the Acceleo module with the main template that has caused the creation
* of this class will revert your modifications.
*
* To learn more about the registration of Resource Factories, have a look at the Acceleo Launcher documentation (Help -> Help Contents).
*/
resourceSet.getResourceFactoryRegistry ().getExtensionToFactoryMap ().put ( "protocol", new XMIResourceFactoryImpl () );
}
示例6: registerResourceFactories
import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl; //導入依賴的package包/類
/**
* This can be used to update the resource set's resource factory registry with all needed factories.
*
* @param resourceSet
* The resource set which registry has to be updated.
* @generated NOT
*/
@Override
public void registerResourceFactories(ResourceSet resourceSet) {
super.registerResourceFactories(resourceSet);
/*
* If you want to change the content of this method, do NOT forget to change the "@generated"
* tag in the Javadoc of this method to "@generated NOT". Without this new tag, any compilation
* of the Acceleo module with the main template that has caused the creation of this class will
* revert your modifications.
*/
/*
* TODO If you need additional resource factories registrations, you can register them here. the following line
* (in comment) is an example of the resource factory registration for UML.
*
* If you want to use the generator in stand alone, the resource factory registration will be required.
*
* To learn more about the registration of Resource Factories, have a look at the Acceleo documentation (Help -> Help Contents).
*/
resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("*.xmi", new XMIResourceFactoryImpl());
}
示例7: loadConfiguraton
import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl; //導入依賴的package包/類
public static Chart loadConfiguraton ( final String configurationUri )
{
if ( configurationUri == null || configurationUri.isEmpty () )
{
return null;
}
// load
ChartPackage.eINSTANCE.eClass ();
final ResourceSet resourceSet = new ResourceSetImpl ();
resourceSet.getResourceFactoryRegistry ().getExtensionToFactoryMap ().put ( "*", new XMIResourceFactoryImpl () ); //$NON-NLS-1$
final Resource resource = resourceSet.getResource ( URI.createURI ( configurationUri ), true );
for ( final EObject o : resource.getContents () )
{
if ( o instanceof Chart )
{
return (Chart)o;
}
}
return null;
}
示例8: load
import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl; //導入依賴的package包/類
private void load ()
{
logger.info ( "Loading: {}", this.uri ); //$NON-NLS-1$
final ResourceSet resourceSet = new ResourceSetImpl ();
resourceSet.getResourceFactoryRegistry ().getExtensionToFactoryMap ().put ( "*", new XMIResourceFactoryImpl () ); //$NON-NLS-1$
final URI file = URI.createURI ( this.uri );
final Resource resource = resourceSet.getResource ( file, true );
for ( final EObject o : resource.getContents () )
{
if ( o instanceof View )
{
createView ( (View)o );
}
}
}
示例9: getEcoreModel
import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl; //導入依賴的package包/類
protected ResourceSet getEcoreModel(File ecorefile) {
ResourceSetImpl rs = new ResourceSetImpl();
Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put(Resource.Factory.Registry.DEFAULT_EXTENSION, new XMIResourceFactoryImpl());
try {
URI fileUri = URI.createFileURI(ecorefile.getCanonicalPath());
Resource resource = rs.createResource(fileUri);
resource.load(null);
EcoreUtil.resolveAll(resource);
rs.getResources().add(resource);
EcoreUtil.resolveAll(rs);
} catch (IOException e) {
e.printStackTrace();
}
return rs;
}
示例10: EcoreResource
import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl; //導入依賴的package包/類
public EcoreResource(File typeTarget, File instanceTarget) {
this.m_resourceSet = new ResourceSetImpl();
this.m_resourceSet.getResourceFactoryRegistry()
.getExtensionToFactoryMap()
.put("*", new XMIResourceFactoryImpl());
this.m_typeFile = typeTarget;
this.m_instanceFile = instanceTarget;
if (this.m_typeFile == this.m_instanceFile || this.m_typeFile == null
|| this.m_instanceFile == null) {
this.relPath = "";
} else {
this.relPath =
groove.io.Util.getRelativePath(new File(this.m_instanceFile.getAbsoluteFile()
.getParent()), this.m_typeFile.getAbsoluteFile())
.toString();
}
}
示例11: loadSurveyModel
import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl; //導入依賴的package包/類
private static Survey loadSurveyModel(String modulePath) {
// Initialize the model
QueryITPackage.eINSTANCE.eClass();
Resource.Factory.Registry reg = Resource.Factory.Registry.INSTANCE;
Map<String, Object> m = reg.getExtensionToFactoryMap();
m.put("xmi", new XMIResourceFactoryImpl());
m.put("ecore", new EcoreResourceFactoryImpl());
// Obtain a new resource set
ResourceSet resSet = new ResourceSetImpl();
// Get the resource
//Resource resource = resSet.getResource(URI.createFileURI(modulePath), true);
Resource resource = resSet.getResource(URI.createURI(modulePath), true);
// Get the first model element and cast it to the right type, in my
// example everything is included in this first node
Survey s = (Survey) resource.getContents().get(0);
return s;
}
示例12: saveModels
import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl; //導入依賴的package包/類
/**
* Allows to save the current state of the source and target models
*
* @param name : Filename
*/
public void saveModels(String name) {
ResourceSet set = new ResourceSetImpl();
set.getResourceFactoryRegistry().getExtensionToFactoryMap().put(Resource.Factory.Registry.DEFAULT_EXTENSION, new XMIResourceFactoryImpl());
URI srcURI = URI.createFileURI(RESULTPATH + "/" + name + "Family.xmi");
URI trgURI = URI.createFileURI(RESULTPATH + "/" + name + "Person.xmi");
Resource resSource = set.createResource(srcURI);
Resource resTarget = set.createResource(trgURI);
EObject colSource = EcoreUtil.copy(getSourceModel());
EObject colTarget = EcoreUtil.copy(getTargetModel());
resSource.getContents().add(colSource);
resTarget.getContents().add(colTarget);
try {
resSource.save(null);
resTarget.save(null);
} catch (IOException e) {
e.printStackTrace();
}
}
示例13: initiateSynchronisationDialogue
import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl; //導入依賴的package包/類
/**
* Initiates a synchronization between a source and a target model. The BXtend Transformation is
* initialized and empty source, target and correspondence models are created.
* Finally a FamilyRegister is added to the source model and an initial forward transformation is issued
* to create a corresponding PersonRegister.
*/
@Override
public void initiateSynchronisationDialogue() {
// Fix default preferences (which can be overwritten)
setConfigurator(new Configurator<Decisions>()
.makeDecision(Decisions.PREFER_CREATING_PARENT_TO_CHILD, true)
.makeDecision(Decisions.PREFER_EXISTING_FAMILY_TO_NEW, true));
set.getResourceFactoryRegistry().getExtensionToFactoryMap().put("family", new XMIResourceFactoryImpl());
set.getResourceFactoryRegistry().getExtensionToFactoryMap().put("person", new XMIResourceFactoryImpl());
set.getResourceFactoryRegistry().getExtensionToFactoryMap().put("corr", new XMIResourceFactoryImpl());
source = set.createResource(URI.createURI("sourceModel.family"));
target = set.createResource(URI.createURI("targetModel.person"));
corr = set.createResource(URI.createURI("corrModel.corr"));
FamilyRegister familiesRoot = FamiliesFactory.eINSTANCE.createFamilyRegister();
source.getContents().add(familiesRoot);
f2pt = new Family2PersonTransformation(source, target, corr);
// Fix default preferences (which can be overwritten)
setConfigurator(new Configurator<Decisions>()
.makeDecision(Decisions.PREFER_CREATING_PARENT_TO_CHILD, true)
.makeDecision(Decisions.PREFER_EXISTING_FAMILY_TO_NEW, true));
// perform batch to establish consistent starting state
f2pt.Family2Person();
}
示例14: saveModels
import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl; //導入依賴的package包/類
/**
* Allows to save the current state of the source and target models
*
* @param name : Filename
*/
@Override
public void saveModels(String name) {
ResourceSet set = new ResourceSetImpl();
set.getResourceFactoryRegistry().getExtensionToFactoryMap().put(Resource.Factory.Registry.DEFAULT_EXTENSION, new XMIResourceFactoryImpl());
URI srcURI = URI.createFileURI(RESULTPATH + "/" + name + "Family.xmi");
URI trgURI = URI.createFileURI(RESULTPATH + "/" + name + "Person.xmi");
Resource resSource = set.createResource(srcURI);
Resource resTarget = set.createResource(trgURI);
EObject colSource = EcoreUtil.copy(getSourceModel());
EObject colTarget = EcoreUtil.copy(getTargetModel());
resSource.getContents().add(colSource);
resTarget.getContents().add(colTarget);
try {
resSource.save(null);
resTarget.save(null);
} catch (IOException e) {
e.printStackTrace();
}
}
示例15: saveModels
import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl; //導入依賴的package包/類
public void saveModels(String name) {
ResourceSet set = new ResourceSetImpl();
set.getResourceFactoryRegistry().getExtensionToFactoryMap().put(Resource.Factory.Registry.DEFAULT_EXTENSION, new XMIResourceFactoryImpl());
URI srcURI = URI.createFileURI(RESULTPATH + "/" + name + "Family.xmi");
URI trgURI = URI.createFileURI(RESULTPATH + "/" + name + "Person.xmi");
Resource resSource = set.createResource(srcURI);
Resource resTarget = set.createResource(trgURI);
EObject colSource = EcoreUtil.copy(getSourceModel());
EObject colTarget = EcoreUtil.copy(getTargetModel());
resSource.getContents().add(colSource);
resTarget.getContents().add(colTarget);
try {
resSource.save(null);
resTarget.save(null);
} catch (IOException e) {
e.printStackTrace();
}
}