当前位置: 首页>>代码示例>>Java>>正文


Java ResourceSetImpl类代码示例

本文整理汇总了Java中org.eclipse.emf.ecore.resource.impl.ResourceSetImpl的典型用法代码示例。如果您正苦于以下问题:Java ResourceSetImpl类的具体用法?Java ResourceSetImpl怎么用?Java ResourceSetImpl使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ResourceSetImpl类属于org.eclipse.emf.ecore.resource.impl包,在下文中一共展示了ResourceSetImpl类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getProfile

import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; //导入依赖的package包/类
@Override
public Profile getProfile ()
{
    if ( this.profile == null )
    {
        final ResourceSet rs = new ResourceSetImpl ();
        final Resource r = rs.createResource ( URI.createURI ( DEFAULT_URI ) );
        try
        {
            r.load ( null );
        }
        catch ( final IOException e )
        {
            throw new RuntimeException ( e );
        }
        this.profile = (Profile)EcoreUtil.getObjectByType ( r.getContents (), ProfilePackage.Literals.PROFILE );
        if ( this.profile == null )
        {
            throw new IllegalStateException ( String.format ( "Resource loaded from %s does not contain an object of type %s", DEFAULT_URI, Profile.class.getName () ) );
        }
    }

    return this.profile;
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:25,代码来源:ArduinoDriverImpl.java

示例2: Validate

import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; //导入依赖的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: isModel

import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; //导入依赖的package包/类
protected boolean isModel(IAdaptable receiver){
	IFile modelFile = (IFile)(receiver).getAdapter(IFile.class);
	if(modelFile !=null){
		ResourceSet rs = new ResourceSetImpl();
		URI modelURI = URI.createURI("platform:/resource/"+modelFile.getFullPath().toString());
		try{
			Resource resource = rs.getResource(modelURI, true);
		if (resource != null) {
			return true;
		}
		} catch (Exception e){
			// not a valid model, simply ignore
			return false;
		}
	}
	return false;
}
 
开发者ID:eclipse,项目名称:gemoc-studio-modeldebugging,代码行数:18,代码来源:GemocSequentialPropertyTester.java

示例4: loadGenmodel

import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; //导入依赖的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: setChartConfiguration

import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; //导入依赖的package包/类
public void setChartConfiguration ( final Chart chart )
{
    if ( chart == null )
    {
        this.viewer.setInput ( null );
    }
    else
    {
        if ( chart.eResource () == null )
        {
            final ResourceSetImpl rs = new ResourceSetImpl ();
            final Resource r = rs.createResource ( URI.createURI ( "urn:dummy" ) );
            r.getContents ().add ( chart );
        }

        if ( chart.eResource ().getURI () == null )
        {
            chart.eResource ().setURI ( URI.createURI ( "urn:dummy" ) );
        }

        this.viewer.setInput ( chart.eResource () );
    }
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:24,代码来源:ChartConfiguratorView.java

示例6: loadConfiguraton

import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; //导入依赖的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

示例7: load

import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; //导入依赖的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

示例8: startServer

import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; //导入依赖的package包/类
public Collection<? extends ServerDescriptor> startServer ( final URI exporterFileUri, final String locationLabel ) throws CoreException
{
    final ResourceSetImpl resourceSet = new ResourceSetImpl ();

    resourceSet.getResourceFactoryRegistry ().getExtensionToFactoryMap ().put ( "*", new ExporterResourceFactoryImpl () );

    final Resource resource = resourceSet.createResource ( exporterFileUri );
    try
    {
        resource.load ( null );
    }
    catch ( final IOException e )
    {
        throw new CoreException ( StatusHelper.convertStatus ( HivesPlugin.PLUGIN_ID, "Failed to load configuration", e ) );
    }

    final DocumentRoot root = (DocumentRoot)EcoreUtil.getObjectByType ( resource.getContents (), ExporterPackage.Literals.DOCUMENT_ROOT );
    if ( root == null )
    {
        throw new CoreException ( new Status ( IStatus.ERROR, HivesPlugin.PLUGIN_ID, "Failed to locate exporter configuration in: " + exporterFileUri ) );
    }
    return startServer ( root, locationLabel );
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:24,代码来源:ServerHostImpl.java

示例9: getProfile

import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; //导入依赖的package包/类
/**
 * @generated NOT
 */
@Override
public Profile getProfile ()
{
    if ( this.profile == null )
    {
        final ResourceSet rs = new ResourceSetImpl ();
        final Resource r = rs.createResource ( URI.createURI ( DEFAULT_URI ), "org.eclipse.scada.configuration.world.osgi.profile" );
        try
        {
            r.load ( null );
        }
        catch ( final IOException e )
        {
            throw new RuntimeException ( e );
        }
        this.profile = (Profile)EcoreUtil.getObjectByType ( r.getContents (), ProfilePackage.Literals.PROFILE );
        if ( this.profile == null )
        {
            throw new IllegalStateException ( String.format ( "Resource loaded from %s does not contain an object of type %s", DEFAULT_URI, Profile.class.getName () ) );
        }
    }

    return this.profile;
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:28,代码来源:ParserDriverImpl.java

示例10: patchProfile

import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; //导入依赖的package包/类
/**
 * Inject the CA bootstrap property to the profile
 *
 * @param file
 *            the profile.xml file in the package target
 * @throws IOException
 */
protected void patchProfile ( final String appName, final File file ) throws IOException
{
    final ResourceSet rs = new ResourceSetImpl ();
    final Resource r = rs.createResource ( URI.createFileURI ( file.toString () ) );
    r.load ( null );

    final Profile profile = (Profile)EcoreUtil.getObjectByType ( r.getContents (), ProfilePackage.Literals.PROFILE );
    Profiles.addSystemProperty ( profile, "org.eclipse.scada.ca.file.provisionJsonUrl", "file:///usr/share/eclipsescada/ca.bootstrap/bootstrap." + appName + ".json" );
    r.save ( null );
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:18,代码来源:CommonPackageHandler.java

示例11: load

import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; //导入依赖的package包/类
public T load ( final URI uri, final String contentTypeId ) throws IOException
{
    final ResourceSet rs = new ResourceSetImpl ();
    final Resource r = rs.createResource ( uri, contentTypeId );
    r.load ( null );

    for ( final Object o : r.getContents () )
    {
        if ( this.clazz.isAssignableFrom ( o.getClass () ) )
        {
            return this.clazz.cast ( o );
        }
    }

    throw new IllegalStateException ( String.format ( "Model %s does not contain an object of type %s", uri, this.clazz ) );
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:17,代码来源:ModelLoader.java

示例12: getProfile

import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; //导入依赖的package包/类
@Override
public Profile getProfile ()
{
    if ( this.profile == null )
    {
        final ResourceSet rs = new ResourceSetImpl ();
        final Resource r = rs.createResource ( URI.createURI ( DEFAULT_URI ), "org.eclipse.scada.configuration.world.osgi.profile" );
        try
        {
            r.load ( null );
        }
        catch ( final IOException e )
        {
            throw new RuntimeException ( e );
        }
        this.profile = (Profile)EcoreUtil.getObjectByType ( r.getContents (), ProfilePackage.Literals.PROFILE );
        if ( this.profile == null )
        {
            throw new IllegalStateException ( String.format ( "Resource loaded from %s does not contain an object of type %s", DEFAULT_URI, Profile.class.getName () ) );
        }
    }

    return this.profile;
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:25,代码来源:ModbusDriverImpl.java

示例13: parse

import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; //导入依赖的package包/类
private static RootType parse ( final URI uri ) throws IOException
{
    final ResourceSet rs = new ResourceSetImpl ();
    rs.getResourceFactoryRegistry ().getExtensionToFactoryMap ().put ( "*", new ConfigurationResourceFactoryImpl () );

    final Resource r = rs.createResource ( uri );
    r.load ( null );

    final DocumentRoot doc = (DocumentRoot)EcoreUtil.getObjectByType ( r.getContents (), ConfigurationPackage.Literals.DOCUMENT_ROOT );
    if ( doc == null )
    {
        return null;
    }
    else
    {
        return doc.getRoot ();
    }
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:19,代码来源:Hive.java

示例14: getEcoreModel

import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; //导入依赖的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

示例15: EcoreResource

import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; //导入依赖的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


注:本文中的org.eclipse.emf.ecore.resource.impl.ResourceSetImpl类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。