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


Java ResourceSet.getResource方法代碼示例

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

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

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

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

示例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;
}
 
開發者ID:occiware,項目名稱:OCCI-Studio,代碼行數:38,代碼來源:DesignerGeneratorAction.java

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

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

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

示例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();
}
 
開發者ID:hristo-vrigazov,項目名稱:bromium,代碼行數:8,代碼來源:BaseDSLConfigurationConverterTest.java

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

示例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;
}
 
開發者ID:awortmann,項目名稱:xmontiarc,代碼行數:10,代碼來源:DesignerHelper.java

示例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());
	}
}
 
開發者ID:occiware,項目名稱:OCCI-Studio,代碼行數:14,代碼來源:DesignerGeneratorAction.java

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

示例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);
}
 
開發者ID:occiware,項目名稱:OCCI-Studio,代碼行數:16,代碼來源:OcciHelper.java


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