本文整理汇总了Java中org.eclipse.emf.ecore.resource.ResourceSet.getResource方法的典型用法代码示例。如果您正苦于以下问题:Java ResourceSet.getResource方法的具体用法?Java ResourceSet.getResource怎么用?Java ResourceSet.getResource使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.emf.ecore.resource.ResourceSet
的用法示例。
在下文中一共展示了ResourceSet.getResource方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: Validate
import org.eclipse.emf.ecore.resource.ResourceSet; //导入方法依赖的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());
}
示例2: indexResources
import org.eclipse.emf.ecore.resource.ResourceSet; //导入方法依赖的package包/类
/**
* Indexes the resources in the given project including the manifest file resource and adds them to the index stored
* in the given resource set. Assumes that the resources have been loaded, but not fully processed.
*
* @param markedProject
* the project to index
* @param resourceSet
* the resource set that contains the index
*/
private void indexResources(MarkedProject markedProject, ResourceSet resourceSet) {
ResourceDescriptionsData index = ResourceDescriptionsData.ResourceSetAdapter
.findResourceDescriptionsData(resourceSet);
if (logger.isCreateDebugOutput()) {
logger.debug("Indexing project " + markedProject.project.getProjectId());
}
for (Resource resource : markedProject.resources) {
indexResource(resource, index);
}
// Index manifest file, too. Index artifact names among project types and library dependencies.
Optional<URI> manifestUri = markedProject.project.getManifestLocation();
if (manifestUri.isPresent()) {
final Resource manifestResource = resourceSet.getResource(manifestUri.get(), true);
if (manifestResource != null) {
indexResource(manifestResource, index);
}
}
}
示例3: loadManifest
import org.eclipse.emf.ecore.resource.ResourceSet; //导入方法依赖的package包/类
protected ProjectDescription loadManifest(URI manifest) {
ResourceSet resourceSet = resourceSetProvider.get();
Resource resource = resourceSet.getResource(manifest, true);
List<EObject> contents = resource.getContents();
if (contents.isEmpty() || !(contents.get(0) instanceof ProjectDescription)) {
return null;
}
// do some error handling:
if (!resource.getErrors().isEmpty()) {
throw new N4JSBrokenProjectException("Reading project description from "
+ manifest
+ " raised the following errors: "
+ Joiner.on('\n').join(
resource.getErrors().stream().map(
error -> error.getMessage() + " at line " + error.getLine())
.iterator()));
}
ProjectDescription result = (ProjectDescription) contents.get(0);
contents.clear();
return result;
}
示例4: loadManifest
import org.eclipse.emf.ecore.resource.ResourceSet; //导入方法依赖的package包/类
@Override
public ProjectDescription loadManifest(URI manifest) {
ResourceSet resourceSet = resourceSetProvider.get();
Resource resource = resourceSet.getResource(manifest, true);
List<EObject> contents = resource.getContents();
if (contents.isEmpty() || !(contents.get(0) instanceof ProjectDescription)) {
return null;
}
// do some error handling:
if (!resource.getErrors().isEmpty()) {
throw new N4JSBrokenProjectException("Reading project description from "
+ manifest
+ " raised the following errors: "
+ Joiner.on('\n').join(
resource.getErrors().stream().map(
error -> error.getMessage() + " at line " + error.getLine())
.iterator()));
}
ProjectDescription result = (ProjectDescription) contents.get(0);
contents.clear();
return result;
}
示例5: generateDesignProject
import org.eclipse.emf.ecore.resource.ResourceSet; //导入方法依赖的package包/类
private IProject generateDesignProject(String occieLocation, String designName, String designProjectName,
final IProgressMonitor monitor) throws CoreException, IOException {
// Load the ecore file.
String ecoreLocation = occieLocation.replace(".occie", ".ecore");
URI ecoreURI = URI.createFileURI(ecoreLocation);
// Create a new resource set.
ResourceSet resourceSet = new ResourceSetImpl();
// Load the OCCI resource.
org.eclipse.emf.ecore.resource.Resource resource = resourceSet.getResource(ecoreURI, true);
// Return the first element.
EPackage ePackage = (EPackage) resource.getContents().get(0);
String extensionScheme = Occi2Ecore.convertEcoreNamespace2OcciScheme(ePackage.getNsURI());
// Register the ePackage to avoid an error when trying to open the generated
// .odesign file,
EPackage.Registry.INSTANCE.put(ePackage.getNsURI(), ePackage);
URI occieURI = URI.createFileURI(occieLocation);
/*
* Create design project
*/
IProject project = DesignerGeneratorUtils.genDesignProject(designProjectName, designName, extensionScheme,
new ProgressMonitorDialog(shell));
/*
* Create design model
*/
org.eclipse.cmf.occi.core.gen.design.main.Generate generator = new org.eclipse.cmf.occi.core.gen.design.main.Generate(
occieURI, project.getFolder("description").getLocation().toFile(), new ArrayList<String>());
generator.doGenerate(BasicMonitor.toMonitor(monitor));
project.refreshLocal(IResource.DEPTH_INFINITE, monitor);
return project;
}
示例6: load
import org.eclipse.emf.ecore.resource.ResourceSet; //导入方法依赖的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 );
}
}
}
示例7: run
import org.eclipse.emf.ecore.resource.ResourceSet; //导入方法依赖的package包/类
/**
* @see IActionDelegate#run(IAction)
*/
public void run(IAction action) {
if (selection != null) {
IFile selectedFile = (IFile) ((IStructuredSelection) selection)
.getFirstElement();
// Use a platform:/resource/ URI
URI uri = URI.createPlatformResourceURI(selectedFile.getFullPath().toString(), true);
ResourceSet rs = new ResourceSetImpl();
Resource r = rs.getResource(uri, true);
Extension extension = (Extension) r.getContents().get(0);
OcciRegistry.getInstance().registerExtension(extension.getScheme(),
uri.toString());
closeOtherSessions(selectedFile.getProject());
MessageDialog.openInformation(shell,
Messages.RegisterExtensionAction_ExtRegistration,
Messages.RegisterExtensionAction_RegisteredExtension
+ extension.getScheme());
}
}
示例8: getFirstInstruction
import org.eclipse.emf.ecore.resource.ResourceSet; //导入方法依赖的package包/类
/**
* Gets the first {@link EObject instruction}.
*
* @param configuration
* the {@link ILaunchConfiguration}
* @return the first {@link EObject instruction}
*/
protected EObject getFirstInstruction(ILaunchConfiguration configuration) {
EObject res = null;
final ResourceSet rs = getResourceSet();
try {
rs.getResource(URI.createPlatformResourceURI(configuration.getAttribute(RESOURCE_URI, ""),
true), true);
res = rs.getEObject(URI.createURI(configuration.getAttribute(FIRST_INSTRUCTION_URI, ""),
true), true);
} catch (CoreException e) {
Activator.getDefault().error(e);
}
return res;
}
开发者ID:eclipse,项目名称:gemoc-studio-modeldebugging,代码行数:23,代码来源:AbstractDSLLaunchConfigurationDelegate.java
示例9: unloadManifestResource
import org.eclipse.emf.ecore.resource.ResourceSet; //导入方法依赖的package包/类
private void unloadManifestResource(ResourceSet resourceSet, ResourceDescriptionsData index,
N4ProgressStateRecorder recorder) {
Optional<URI> manifestLocation = project.getManifestLocation();
if (manifestLocation.isPresent()) {
Resource resource = resourceSet.getResource(manifestLocation.get(), false);
if (resource != null)
unloadResource(resource, resourceSet, index, recorder);
}
}
示例10: readExample
import org.eclipse.emf.ecore.resource.ResourceSet; //导入方法依赖的package包/类
protected Model readExample() {
File file = new File(getClass().getResource("/actions.brm").getFile());
Injector injector = new BromiumStandaloneSetup().createInjectorAndDoEMFRegistration();
ResourceSet rs = injector.getInstance(ResourceSet.class);
Resource resource = rs.getResource(URI.createURI(file.getAbsolutePath()), true);
return (Model) resource.getAllContents().next();
}
示例11: load
import org.eclipse.emf.ecore.resource.ResourceSet; //导入方法依赖的package包/类
public static XSFSM load(final String uri) {
ResourceSet rs = new ResourceSetImpl();
Resource res = rs.getResource(URI.createURI(uri), true);
XSFSM mm = new XSFSM();
mm.setResource(res);
return mm ;
}
示例12: loadModel
import org.eclipse.emf.ecore.resource.ResourceSet; //导入方法依赖的package包/类
public static Resource loadModel(String filename) {
String path = "platform:/resource" + filename;
System.out.println("Loading type from URI '" + path + "'.");
URI uri = URI.createURI(path);
System.out.println("URI is '" + uri.toString() + "'.");
ResourceSet resourceSet = new ResourceSetImpl();
Resource mainResource = resourceSet.getResource(uri, true);
return mainResource;
}
示例13: registerExtension
import org.eclipse.emf.ecore.resource.ResourceSet; //导入方法依赖的package包/类
private void registerExtension(IFile occieFile) {
String extensionPath = occieFile.getFullPath().toString();
URI uri = URI.createPlatformResourceURI(extensionPath, true);
ResourceSet rs = new ResourceSetImpl();
Resource r = rs.getResource(uri, true);
Extension extension = (Extension) r.getContents().get(0);
if (!OcciRegistry.getInstance().getRegisteredExtensions().contains(extension.getScheme())) {
OcciRegistry.getInstance().registerExtension(extension.getScheme(), uri.toString());
LOGGER.debug("Registered OCCI extension " + extension.getScheme());
}
}
示例14: loadProtocol
import org.eclipse.emf.ecore.resource.ResourceSet; //导入方法依赖的package包/类
protected Protocol loadProtocol ( final URI modelURI )
{
final ResourceSet rs = new ResourceSetImpl ();
rs.getResourceFactoryRegistry ().getExtensionToFactoryMap ().put ( "protocol", new XMIResourceFactoryImpl () );
final Resource resource = rs.getResource ( modelURI, true );
return (Protocol)EcoreUtil.getObjectByType ( resource.getContents (), ProtocolPackage.Literals.PROTOCOL );
}
示例15: loadOCCI
import org.eclipse.emf.ecore.resource.ResourceSet; //导入方法依赖的package包/类
/**
* Load an OCCI object.
*
* @param uri
* URI of the OCCI object to load.
* @return the loaded OCCI object.
*/
private static Object loadOCCI(String uri) {
// Create a new resource set.
ResourceSet resourceSet = new ResourceSetImpl();
// Load the OCCI resource.
org.eclipse.emf.ecore.resource.Resource resource = resourceSet.getResource(URI.createURI(uri), true);
// Return the first element.
return resource.getContents().get(0);
}