Java Code Examples for org.eclipse.emf.ecore.resource.ResourceSet#createResource()

The following examples show how to use org.eclipse.emf.ecore.resource.ResourceSet#createResource() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Hive.java    From neoscada with Eclipse Public License 1.0 6 votes vote down vote up
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 ();
    }
}
 
Example 2
Source File: JSONModelUtils.java    From n4js with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Serializes the given {@link JSONDocument} using the Xtext serialization facilities provided by the JSON language.
 */
public static String serializeJSON(JSONDocument document) {
	ISerializer jsonSerializer = N4LanguageUtils.getServiceForContext(FILE_EXTENSION, ISerializer.class).get();
	ResourceSet resourceSet = N4LanguageUtils.getServiceForContext(FILE_EXTENSION, ResourceSet.class).get();

	// Use temporary Resource as AbstractFormatter2 implementations can only format
	// semantic elements that are contained in a Resource.
	Resource temporaryResource = resourceSet.createResource(URIUtils.toFileUri("__synthetic." + FILE_EXTENSION));
	temporaryResource.getContents().add(document);

	// create string writer as serialization output
	StringWriter writer = new StringWriter();

	// enable formatting as serialization option
	SaveOptions serializerOptions = SaveOptions.newBuilder().format().getOptions();
	try {
		jsonSerializer.serialize(document, writer, serializerOptions);
		return writer.toString();
	} catch (IOException e) {
		throw new RuntimeException("Failed to serialize JSONDocument " + document, e);
	}
}
 
Example 3
Source File: SerializerImpl.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
public void write( Chart cModel, OutputStream os ) throws IOException
{
	// REMOVE ANY TRANSIENT RUNTIME SERIES
	cModel.clearSections( IConstants.RUN_TIME );

	// Create and setup local ResourceSet
	ResourceSet rsChart = new ResourceSetImpl( );
	rsChart.getResourceFactoryRegistry( )
			.getExtensionToFactoryMap( )
			.put( "chart", new ModelResourceFactoryImpl( ) ); //$NON-NLS-1$

	// Create resources to represent the disk files to be used to store the
	// models
	Resource rChart = rsChart.createResource( URI.createFileURI( "test.chart" ) ); //$NON-NLS-1$

	// Add the chart to the resource
	rChart.getContents( ).add( cModel );

	Map<String, Object> options = new HashMap<String, Object>( );
	options.put( XMLResource.OPTION_ENCODING, "UTF-8" ); //$NON-NLS-1$

	// Save the resource to disk
	rChart.save( os, options );
}
 
Example 4
Source File: ParserDriverImpl.java    From neoscada with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * @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;
}
 
Example 5
Source File: Express2EMF.java    From BIMserver with GNU Affero General Public License v3.0 5 votes vote down vote up
public void writeEMF(String fileName) {
	ResourceSet metaResourceSet = new ResourceSetImpl();
	metaResourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("ecore", new XMLResourceFactoryImpl());

	URI resUri = URI.createURI(fileName);
	Resource metaResource = metaResourceSet.createResource(resUri);
	metaResource.getContents().add(schemaPack);
	try {
		metaResource.save(null);
	} catch (Exception e) {
		LOGGER.error("", e);
	}
}
 
Example 6
Source File: FormatterResourceProvider.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public XtextResource createResource() {
	ResourceSet resourceSet = resourceSetProvider.get(null);
	@SuppressWarnings("restriction")
	XtextResource result = (XtextResource) resourceSet.createResource(URI
			.createURI(org.eclipse.xtext.ui.codetemplates.ui.preferences.TemplateResourceProvider.SYNTHETIC_SCHEME + ":/" + "FormatterPreview.xtend"));
	result.setValidationDisabled(true);
	return result;
}
 
Example 7
Source File: ResourceForResourceWorkingCopyEditorInputFactory.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
protected Resource createWorkingCopy(ResourceWorkingCopyFileEditorInput editorInput) {
	try {
		ResourceSet resourceSet = getResourceSet(editorInput.getFile());
		Resource workingCopy = resourceSet.createResource(editorInput.getResource().getURI());
		InputStream inputStream = editorInput.getFile().getContents();
		try {
			workingCopy.load(inputStream, Collections.singletonMap(XtextResource.OPTION_ENCODING, editorInput.getEncoding()));
		} finally {
			inputStream.close();
		}
		return workingCopy;
	} catch (Exception exc) {
		throw new IllegalStateException(exc);
	}
}
 
Example 8
Source File: PartialParserCrossContainmentMultiTest.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
@Override
protected void setCrossResourceContainer(XtextResource resource) {
	ResourceSet resourceSet = resource.getResourceSet();
	Resource containerResource = resourceSet.createResource(URI.createFileURI("sample.xmi"));
	CrossResourceContainerManyChildren container = PartialParsingTestUtilFactory.eINSTANCE.createCrossResourceContainerManyChildren();
	containerResource.getContents().add(container);
	container.getChildren().addAll(resource.getContents());
}
 
Example 9
Source File: BuiltInTypeModelAccess.java    From dsl-devkit with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Load the concrete meta model instance from modelLocation.
 */
private synchronized void load() {
  if (model == null) {
    URI modelURI = getBuiltInElementsResourceURI();
    try {
      ResourceSet rs = new ResourceSetImpl();
      Resource resource = rs.createResource(modelURI);
      // Stand-alone builder cannot handle platform:/plugin/ URIs...
      final InputStream is = BuiltInTypeModelAccess.class.getClassLoader().getResourceAsStream(MODEL_LOCATION);
      resource.load(is, null);
      EcoreUtil.resolveAll(resource);
      model = (BuiltInTypeModel) resource.getContents().get(0);
      // CHECKSTYLE:CHECK-OFF IllegalCatch
      // We *do* want to catch any exception here because we are in construction and need to initialize with something
    } catch (Exception ex) {
      // CHECKSTYLE:CHECK-ON IllegalCatch
      LOGGER.error("Error loading metamodel from " + modelURI, ex); //$NON-NLS-1$
      // Create an empty model...
      model = BuiltInTypeModelPackage.eINSTANCE.getBuiltInTypeModelFactory().createBuiltInTypeModel();
    }
  }
  GlobalResources.INSTANCE.addResource(model.eResource());
  for (InternalType type : model.getInternalTypes()) {
    String typeName = type.getName();
    if (!Strings.isEmpty(typeName)) {
      internalTypesByName.put(typeName, type);
    } else {
      LOGGER.error("incomplete internal type in " + MODEL_LOCATION); //$NON-NLS-1$
    }
  }
}
 
Example 10
Source File: ProjectTestsUtils.java    From n4js with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * @param packageJSONBuilderAdjustments
 *            This procedure will be invoked with the {@link PackageJsonBuilder} instances that is used to create
 *            the project description {@link JSONDocument} instance. The builder instance will be pre-configured
 *            with default values (cf {@link PackageJSONTestUtils#defaultPackageJson}). May be <code>null</code> if
 *            no adjustments are required.
 */
public static void createProjectDescriptionFile(IProject project, String sourceFolder, String outputFolder,
		Consumer<PackageJsonBuilder> packageJSONBuilderAdjustments) throws CoreException {

	IFile projectDescriptionWorkspaceFile = project.getFile(N4JSGlobals.PACKAGE_JSON);
	URI uri = URI.createPlatformResourceURI(projectDescriptionWorkspaceFile.getFullPath().toString(), true);

	final PackageJsonBuilder packageJsonBuilder = PackageJSONTestUtils
			.defaultPackageJson(project.getName(), sourceFolder, outputFolder);

	if (packageJSONBuilderAdjustments != null)
		packageJSONBuilderAdjustments.accept(packageJsonBuilder);

	final JSONDocument document = packageJsonBuilder.buildModel();

	final ResourceSet rs = createResourceSet(project);
	final Resource projectDescriptionResource = rs.createResource(uri);
	projectDescriptionResource.getContents().add(document);

	try {
		// save formatted package.json file to disk
		projectDescriptionResource.save(SaveOptions.newBuilder().format().getOptions().toOptionsMap());
	} catch (IOException e) {
		e.printStackTrace();
	}

	project.refreshLocal(IResource.DEPTH_INFINITE, monitor());
	waitForAutoBuild();
	Assert.assertTrue("project description file (package.json) should have been created",
			projectDescriptionWorkspaceFile.exists());
}
 
Example 11
Source File: LiveShadowedAllContainerStateTest.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testPersistedWithOtherResource() {
  try {
    final IProject project = IResourcesSetupUtil.createProject("MyProject");
    IResourcesSetupUtil.addNature(project, XtextProjectHelper.NATURE_ID);
    String _primaryFileExtension = this._fileExtensionProvider.getPrimaryFileExtension();
    final String fileName = ("MyProject/myfile1." + _primaryFileExtension);
    IResourcesSetupUtil.createFile(fileName, "stuff foo");
    IResourcesSetupUtil.waitForBuild();
    final ResourceSet rs = this.liveScopeResourceSetProvider.get(project);
    String _primaryFileExtension_1 = this._fileExtensionProvider.getPrimaryFileExtension();
    String _plus = ("MyProject/myfile2." + _primaryFileExtension_1);
    final Resource resource = rs.createResource(URI.createPlatformResourceURI(_plus, true));
    StringInputStream _stringInputStream = new StringInputStream("stuff bar");
    resource.load(_stringInputStream, CollectionLiterals.<Object, Object>emptyMap());
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("container MyProject isEmpty=false {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("resourceURI=platform:/resource/MyProject/myfile1.testlanguage exported=[foo]");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("resourceURI=platform:/resource/MyProject/myfile2.testlanguage exported=[bar]");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    final String expected = _builder.toString();
    Assert.assertEquals(expected, this.formatContainers(rs));
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
Example 12
Source File: ChartActionBarContributor.java    From neoscada with Eclipse Public License 1.0 5 votes vote down vote up
private void doSave ( final String file ) throws IOException
{
    final ResourceSet rs = new ResourceSetImpl ();

    rs.getResourceFactoryRegistry ().getExtensionToFactoryMap ().put ( "*", new XMLResourceFactoryImpl () ); //$NON-NLS-1$
    final URI fileUri = URI.createFileURI ( file );
    final Resource resource = rs.createResource ( fileUri );
    resource.getContents ().add ( this.chart );

    final Map<Object, Object> options = new HashMap<Object, Object> ();
    //             options.put ( XMIResource., value )
    resource.save ( options );
}
 
Example 13
Source File: FindingsTemplateService.java    From elexis-3-core with Eclipse Public License 1.0 5 votes vote down vote up
public FindingsTemplates getFindingsTemplates(String templateId){
	Assert.isNotNull(templateId);
	templateId = templateId.replaceAll(" ", "_");
	Optional<IBlob> blob =
		coreModelService.load(FINDINGS_TEMPLATE_ID_PREFIX + templateId, IBlob.class);
	if (blob.isPresent()) {
		String stringContent = blob.get().getStringContent();
		if (stringContent != null && !stringContent.isEmpty()) {
			try {
				Resource.Factory.Registry reg = Resource.Factory.Registry.INSTANCE;
				Map<String, Object> m = reg.getExtensionToFactoryMap();
				m.put("xmi", new XMIResourceFactoryImpl());
				// Obtain a new resource set
				ResourceSet resSet = new ResourceSetImpl();
				
				// Get the resource
				Resource resource =
					resSet.createResource(URI.createURI("findingsTemplate.xml"));
				resource.load(new URIConverter.ReadableInputStream(stringContent), null);
				return (FindingsTemplates) resource.getContents().get(0);
			} catch (IOException e) {
				LoggerFactory.getLogger(FindingsTemplateService.class)
					.error("read findings templates error", e);
			}
		}
	}
	
	ModelFactory factory = ModelFactory.eINSTANCE;
	FindingsTemplates findingsTemplates = factory.createFindingsTemplates();
	findingsTemplates.setId(FINDINGS_TEMPLATE_ID_PREFIX + templateId);
	findingsTemplates.setTitle("Standard Vorlagen");
	return findingsTemplates;
}
 
Example 14
Source File: EMFGeneratorFragment.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
protected Resource createResourceForEPackages(Grammar grammar, XpandExecutionContext ctx, List<EPackage> packs,
		ResourceSet rs) {
	URI ecoreFileUri = getEcoreFileUri(grammar, ctx);
	ecoreFileUri = toPlatformResourceURI(ecoreFileUri);
	Resource existing = rs.getResource(ecoreFileUri, false);
	if (existing != null) {
		existing.unload();
		rs.getResources().remove(existing);
	}
	Resource ecoreFile = rs.createResource(ecoreFileUri, ContentHandler.UNSPECIFIED_CONTENT_TYPE);
	ecoreFile.getContents().addAll(packs);
	return ecoreFile;
}
 
Example 15
Source File: ProcessEngineDesignerConfigurationImpl.java    From fixflow with Apache License 2.0 4 votes vote down vote up
@Override
protected void initEmfFile() {
	// TODO 自动生成的方法存根
	
	if(this.processEngineConfigurationXmlPath!=null){
		
		
		ResourceSet resourceSet = new ResourceSetImpl();
		String filePath = this.processEngineConfigurationXmlPath;
		Resource resource = null;
		try {
			if (!filePath.startsWith("jar")) {
				filePath = java.net.URLDecoder.decode(ReflectUtil.getResource("com/founder/fix/fixflow/expand/config/fixflowconfig.xml").getFile(),
						"utf-8");
				resource = resourceSet.createResource(URI.createFileURI(filePath));
			} else {
				resource = resourceSet.createResource(URI.createURI(filePath));
			}

		} catch (UnsupportedEncodingException e2) {
			e2.printStackTrace();
			throw new FixFlowException("流程配置文件加载失败!", e2);
		}

		// register package in local resource registry
		resourceSet.getPackageRegistry().put(CoreconfigPackage.eINSTANCE.getNsURI(), CoreconfigPackage.eINSTANCE);
		// load resource
		try {
			resource.load(null);
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			throw new FixFlowException("流程配置文件加载失败", e);
		}

		fixFlowConfig = (FixFlowConfig) resource.getContents().get(0);
		
	}
	else{
		super.initEmfFile();
	}
	
}
 
Example 16
Source File: BPMNExportImportDataMappingTest.java    From bonita-studio with GNU General Public License v2.0 4 votes vote down vote up
@Before
public void prepareTest() throws IOException {
    new BotApplicationWorkbenchWindow(bot)
            .importBOSArchive()
            .setArchive(BPMNExportImportDataMappingTest.class.getResource("testBPMNDataMapping-1.0.bos"))
            .finish();

    final SWTBotGefEditor editor1 = bot.gefEditor(bot.activeEditor().getTitle());
    final SWTBotGefEditPart step1Part = editor1.getEditPart("Step1").parent();
    final MainProcessEditPart mped = (MainProcessEditPart) step1Part.part().getRoot().getChildren().get(0);

    DiagramRepositoryStore dStore = RepositoryManager.getInstance().getRepositoryStore(DiagramRepositoryStore.class);
    ConnectorDefRepositoryStore connectorDefStore = RepositoryManager.getInstance()
            .getRepositoryStore(ConnectorDefRepositoryStore.class);
    IModelSearch modelSearch = new ModelSearch(() -> dStore.getAllProcesses(), () -> connectorDefStore.getDefinitions());

    final IBonitaModelExporter exporter = new BonitaModelExporterImpl(mped.resolveSemanticElement().eResource(),
            modelSearch);

    final File bpmnFileExported = tmpFolder.newFile("testSingleConnectorOnServiceTask.bpmn");
    BonitaToBPMNExporter bonitaToBPMNExporter = new BonitaToBPMNExporter();
    bonitaToBPMNExporter.export(exporter, modelSearch, bpmnFileExported);
    StatusAssert.assertThat(bonitaToBPMNExporter.getStatus()).hasSeverity(IStatus.INFO);

    final ResourceSet resourceSet1 = new ResourceSetImpl();
    final Map<String, Object> extensionToFactoryMap = resourceSet1.getResourceFactoryRegistry()
            .getExtensionToFactoryMap();
    final DiResourceFactoryImpl diResourceFactoryImpl = new DiResourceFactoryImpl();
    extensionToFactoryMap.put("bpmn", diResourceFactoryImpl);
    resource = resourceSet1.createResource(URI.createFileURI(bpmnFileExported.getAbsolutePath()));
    resource.load(Collections.emptyMap());

    final DocumentRoot model2 = (DocumentRoot) resource.getContents().get(0);

    Display.getDefault().syncExec(() -> {
        try {
            mainProcessAfterReimport = BPMNTestUtil.importBPMNFile(model2);
        } catch (final MalformedURLException e) {
            e.printStackTrace();
        }
    });

    for (final Element element : ((Lane) ((Pool) mainProcessAfterReimport.getElements().get(0)).getElements().get(0))
            .getElements()) {
        if (element instanceof CallActivity) {
            callActivity = (CallActivity) element;
            break;
        }
    }
}
 
Example 17
Source File: Reader.java    From xtext-core with Eclipse Public License 2.0 4 votes vote down vote up
protected void populateResourceSet(ResourceSet set, Multimap<String, URI> uris) {
	Collection<URI> values = Sets.newHashSet(uris.values());
	for (URI uri : values) {
		set.createResource(uri);
	}
}
 
Example 18
Source File: XtextLinkerTest.java    From xtext-core with Eclipse Public License 2.0 4 votes vote down vote up
@Test
public void testNamedParameterAdjustment() throws Exception {
  StringConcatenation _builder = new StringConcatenation();
  _builder.append("grammar test.Lang with org.eclipse.xtext.common.Terminals");
  _builder.newLine();
  _builder.append("generate test \'http://test\'");
  _builder.newLine();
  _builder.append("Root<MyParam>: rule=Rule<true>;");
  _builder.newLine();
  _builder.append("Rule<MyParam>: name=ID child=Root<false>?;");
  _builder.newLine();
  final String grammarAsString = _builder.toString();
  EObject _model = this.getModel(grammarAsString);
  final Grammar grammar = ((Grammar) _model);
  final ResourceSet resourceSet = grammar.eResource().getResourceSet();
  final Resource otherResource = resourceSet.createResource(URI.createURI("other.xtext"));
  StringConcatenation _builder_1 = new StringConcatenation();
  _builder_1.append("grammar test.SubLang with test.Lang");
  _builder_1.newLine();
  _builder_1.append("import \'http://test\'");
  _builder_1.newLine();
  _builder_1.append("Root<MyParam>: rule=super::Rule<true>;");
  _builder_1.newLine();
  LazyStringInputStream _lazyStringInputStream = new LazyStringInputStream(_builder_1.toString());
  otherResource.load(_lazyStringInputStream, null);
  EObject _head = IterableExtensions.<EObject>head(otherResource.getContents());
  final Grammar subGrammar = ((Grammar) _head);
  AbstractRule _head_1 = IterableExtensions.<AbstractRule>head(subGrammar.getRules());
  final ParserRule rootRule = ((ParserRule) _head_1);
  AbstractRule _last = IterableExtensions.<AbstractRule>last(grammar.getRules());
  final ParserRule parentRule = ((ParserRule) _last);
  AbstractElement _alternatives = parentRule.getAlternatives();
  AbstractElement _last_1 = IterableExtensions.<AbstractElement>last(((Group) _alternatives).getElements());
  final Assignment lastAssignment = ((Assignment) _last_1);
  AbstractElement _terminal = lastAssignment.getTerminal();
  final RuleCall ruleCall = ((RuleCall) _terminal);
  final NamedArgument argument = IterableExtensions.<NamedArgument>head(ruleCall.getArguments());
  Assert.assertEquals(IterableExtensions.<Parameter>head(rootRule.getParameters()), argument.getParameter());
  Condition _value = argument.getValue();
  Assert.assertFalse(((LiteralCondition) _value).isTrue());
}
 
Example 19
Source File: BPMNGatewayExportImportTest.java    From bonita-studio with GNU General Public License v2.0 4 votes vote down vote up
@Before
public void prepareTest() throws IOException {
    new BotApplicationWorkbenchWindow(bot)
            .importBOSArchive()
            .setArchive(BPMNGatewayExportImportTest.class.getResource("diagramToTestGateways-6.0.bos"))
            .finish();

    final SWTBotGefEditor editor1 = bot.gefEditor(bot.activeEditor().getTitle());
    final SWTBotGefEditPart step1Part = editor1.getEditPart("Gate1").parent();
    final MainProcessEditPart mped = (MainProcessEditPart) step1Part.part().getRoot().getChildren().get(0);

    DiagramRepositoryStore dStore = RepositoryManager.getInstance().getRepositoryStore(DiagramRepositoryStore.class);
    ConnectorDefRepositoryStore connectorDefStore = RepositoryManager.getInstance()
            .getRepositoryStore(ConnectorDefRepositoryStore.class);
    IModelSearch modelSearch = new ModelSearch(() -> dStore.getAllProcesses(), () -> connectorDefStore.getDefinitions());

    final IBonitaModelExporter exporter = new BonitaModelExporterImpl(mped.resolveSemanticElement().eResource(),
            modelSearch);
    final File bpmnFileExported = tmpFolder.newFile("testGateway.bpmn");
    BonitaToBPMNExporter bonitaToBPMNExporter = new BonitaToBPMNExporter();
    bonitaToBPMNExporter.export(exporter, modelSearch, bpmnFileExported);
    StatusAssert.assertThat(bonitaToBPMNExporter.getStatus()).hasSeverity(IStatus.INFO);

    final ResourceSet resourceSet1 = new ResourceSetImpl();
    final Map<String, Object> extensionToFactoryMap = resourceSet1.getResourceFactoryRegistry()
            .getExtensionToFactoryMap();
    final DiResourceFactoryImpl diResourceFactoryImpl = new DiResourceFactoryImpl();
    extensionToFactoryMap.put("bpmn", diResourceFactoryImpl);
    resource = resourceSet1.createResource(URI.createFileURI(bpmnFileExported.getAbsolutePath()));
    resource.load(Collections.emptyMap());

    final DocumentRoot model2 = (DocumentRoot) resource.getContents().get(0);

    Display.getDefault().syncExec(() -> {
        try {
            mainProcessAfterReimport = BPMNTestUtil.importBPMNFile(model2);
        } catch (final MalformedURLException e) {
            e.printStackTrace();
        }
    });
    final Lane lane = (Lane) ((Pool) mainProcessAfterReimport.getElements().get(0)).getElements().get(0);
    for (final Element element : lane.getElements()) {
        if (element instanceof ANDGateway) {
            andGatewayAfterReimport = (ANDGateway) element;
        }
        if (element instanceof InclusiveGateway) {
            incGatewayAfterReimport = (InclusiveGateway) element;
        }
        if (element instanceof XORGateway) {
            xorGatewayAfterReimport = (XORGateway) element;
        }
    }
}
 
Example 20
Source File: XtextGrammarRefactoringIntegrationTest.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
private Resource createEcoreModel(ResourceSet rs, URI uri, EObject rootElement) throws IOException {
	Resource ecoreResource = rs.createResource(uri);
	ecoreResource.getContents().add(rootElement);
	ecoreResource.save(null);
	return ecoreResource;
}