當前位置: 首頁>>代碼示例>>Java>>正文


Java XMIResourceFactoryImpl類代碼示例

本文整理匯總了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);
    }
}
 
開發者ID:Heverton,項目名稱:grapheditor,代碼行數:26,代碼來源:GraphEditorPersistence.java

示例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());
}
 
開發者ID:Nielko,項目名稱:MBSE-Vacation-Manager,代碼行數:17,代碼來源:Validate.java

示例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;
}
 
開發者ID:eclipse,項目名稱:n4js,代碼行數:20,代碼來源:UnicodeStandaloneSetupGenerated.java

示例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;
}
 
開發者ID:eclipse,項目名稱:gemoc-studio-modeldebugging,代碼行數:19,代碼來源:CreateDSAWizardContextActionDSAK3.java

示例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 () );
}
 
開發者ID:eclipse,項目名稱:neoscada,代碼行數:25,代碼來源:Generate.java

示例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());
}
 
開發者ID:eclipse,項目名稱:neoscada,代碼行數:29,代碼來源:Generate.java

示例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;
}
 
開發者ID:eclipse,項目名稱:neoscada,代碼行數:26,代碼來源:ChartHelper.java

示例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 );
        }
    }
}
 
開發者ID:eclipse,項目名稱:neoscada,代碼行數:20,代碼來源:DetailViewImpl.java

示例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;
    }
 
開發者ID:datathings,項目名稱:greycat-idea-plugin,代碼行數:18,代碼來源:PrettyPrinter.java

示例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();
    }
}
 
開發者ID:meteoorkip,項目名稱:JavaGraph,代碼行數:20,代碼來源:EcoreResource.java

示例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;
}
 
開發者ID:TodorovicNikola,項目名稱:SurveyDSL,代碼行數:23,代碼來源:SurveyGenerator.java

示例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();
	}		
}
 
開發者ID:eMoflon,項目名稱:benchmarx,代碼行數:27,代碼來源:MediniQVTFamiliesToPersonsConfig.java

示例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();
}
 
開發者ID:eMoflon,項目名稱:benchmarx,代碼行數:32,代碼來源:UbtXtendFamiliesToPersons.java

示例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();
	}			
}
 
開發者ID:eMoflon,項目名稱:benchmarx,代碼行數:28,代碼來源:UbtXtendFamiliesToPersons.java

示例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();
	}
	
}
 
開發者ID:eMoflon,項目名稱:benchmarx,代碼行數:23,代碼來源:EMoflonFamiliesToPersons.java


注:本文中的org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。