本文整理汇总了Java中org.eclipse.emf.common.util.URI类的典型用法代码示例。如果您正苦于以下问题:Java URI类的具体用法?Java URI怎么用?Java URI使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
URI类属于org.eclipse.emf.common.util包,在下文中一共展示了URI类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: startServer
import org.eclipse.emf.common.util.URI; //导入依赖的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 );
}
示例2: loadPackage
import org.eclipse.emf.common.util.URI; //导入依赖的package包/类
/**
* Laods the package and any sub-packages from their serialized form.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void loadPackage() {
if (isLoaded)
return;
isLoaded = true;
URL url = getClass().getResource(packageFilename);
if (url == null) {
throw new RuntimeException("Missing serialized package: " + packageFilename);
}
URI uri = URI.createURI(url.toString());
Resource resource = new EcoreResourceFactoryImpl().createResource(uri);
try {
resource.load(null);
} catch (IOException exception) {
throw new WrappedException(exception);
}
initializeFromLoadedEPackage(this, (EPackage) resource.getContents().get(0));
createResource(eNS_URI);
}
示例3: createResource
import org.eclipse.emf.common.util.URI; //导入依赖的package包/类
/**
* Creates an instance of the resource.
* <!-- begin-user-doc --> <!-- end-user-doc -->
* @generated
*/
@Override
public Resource createResource(URI uri)
{
XMLResource result = new MailModuleResourceImpl(uri);
result.getDefaultSaveOptions().put(XMLResource.OPTION_EXTENDED_META_DATA, Boolean.TRUE);
result.getDefaultLoadOptions().put(XMLResource.OPTION_EXTENDED_META_DATA, Boolean.TRUE);
result.getDefaultSaveOptions().put(XMLResource.OPTION_SCHEMA_LOCATION, Boolean.TRUE);
result.getDefaultLoadOptions().put(XMLResource.OPTION_USE_ENCODED_ATTRIBUTE_STYLE, Boolean.TRUE);
result.getDefaultSaveOptions().put(XMLResource.OPTION_USE_ENCODED_ATTRIBUTE_STYLE, Boolean.TRUE);
result.getDefaultLoadOptions().put(XMLResource.OPTION_USE_LEXICAL_HANDLER, Boolean.TRUE);
return result;
}
示例4: createModel
import org.eclipse.emf.common.util.URI; //导入依赖的package包/类
/**
* This is the method called to load a resource into the editing domain's resource set based on the editor's input.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void createModel() {
URI resourceURI = EditUIUtil.getURI(getEditorInput(), editingDomain.getResourceSet().getURIConverter());
Exception exception = null;
Resource resource = null;
try {
// Load the resource through the editing domain.
//
resource = editingDomain.getResourceSet().getResource(resourceURI, true);
}
catch (Exception e) {
exception = e;
resource = editingDomain.getResourceSet().getResource(resourceURI, false);
}
Diagnostic diagnostic = analyzeResourceProblems(resource, exception);
if (diagnostic.getSeverity() != Diagnostic.OK) {
resourceToDiagnosticMap.put(resource, analyzeResourceProblems(resource, exception));
}
editingDomain.getResourceSet().eAdapters().add(problemIndicationAdapter);
}
示例5: loadLastSelection
import org.eclipse.emf.common.util.URI; //导入依赖的package包/类
private MasterServer loadLastSelection ()
{
final String lastUri = this.dialogSettings.get ( SETTINGS_LAST_SELECTION );
if ( lastUri == null )
{
return null;
}
try
{
final EObject lastSelection = this.world.eResource ().getResourceSet ().getEObject ( URI.createURI ( lastUri ), true );
if ( lastSelection instanceof MasterServer )
{
return (MasterServer)lastSelection;
}
}
catch ( final Exception e )
{
}
return null;
}
示例6: loadPackage
import org.eclipse.emf.common.util.URI; //导入依赖的package包/类
/**
* Laods the package and any sub-packages from their serialized form.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void loadPackage() {
if (isLoaded) return;
isLoaded = true;
URL url = getClass().getResource(packageFilename);
if (url == null) {
throw new RuntimeException("Missing serialized package: " + packageFilename);
}
URI uri = URI.createURI(url.toString());
Resource resource = new EcoreResourceFactoryImpl().createResource(uri);
try {
resource.load(null);
}
catch (IOException exception) {
throw new WrappedException(exception);
}
initializeFromLoadedEPackage(this, (EPackage)resource.getContents().get(0));
createResource(eNS_URI);
}
示例7: getProjects
import org.eclipse.emf.common.util.URI; //导入依赖的package包/类
@Override
public Iterable<IProject> getProjects(java.net.URI rootLocation) {
ensureInitialized();
final File rootFolder = new File(rootLocation);
final Map<String, IProject> projectsMapping = newTreeMap();
final URI rootUri = URI.createFileURI(rootFolder.getAbsolutePath());
for (Entry<URI, Optional<Pair<ExternalProject, ProjectDescription>>> entry : projectCache.asMap().entrySet()) {
final URI projectLocation = entry.getKey();
if (rootUri.equals(projectLocation.trimSegments(1))) {
final Pair<ExternalProject, ProjectDescription> pair = entry.getValue().orNull();
if (null != pair && null != pair.getFirst()) {
final ExternalProject project = pair.getFirst();
projectsMapping.put(project.getName(), project);
}
}
}
return unmodifiableCollection(projectsMapping.values());
}
示例8: getIncomingReferences
import org.eclipse.emf.common.util.URI; //导入依赖的package包/类
/***/
public static Set<IReferenceDescription> getIncomingReferences(URI uri) {
Set<IReferenceDescription> desc = Sets.newHashSet();
Iterable<IResourceDescription> descriptions = getAllResourceDescriptions();
for (IResourceDescription res : descriptions) {
Iterable<IReferenceDescription> descriptions2 = res.getReferenceDescriptions();
for (IReferenceDescription ref : descriptions2) {
if (uri.hasFragment()) {
if (ref.getTargetEObjectUri().equals(uri))
desc.add(ref);
} else {
if (ref.getTargetEObjectUri().trimFragment().equals(uri.trimFragment()))
desc.add(ref);
}
}
}
return desc;
}
示例9: createModel
import org.eclipse.emf.common.util.URI; //导入依赖的package包/类
/**
* This is the method called to load a resource into the editing domain's resource set based on the editor's input.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void createModel ()
{
URI resourceURI = EditUIUtil.getURI ( getEditorInput () );
Exception exception = null;
Resource resource = null;
try
{
// Load the resource through the editing domain.
//
resource = editingDomain.getResourceSet ().getResource ( resourceURI, true );
}
catch ( Exception e )
{
exception = e;
resource = editingDomain.getResourceSet ().getResource ( resourceURI, false );
}
Diagnostic diagnostic = analyzeResourceProblems ( resource, exception );
if ( diagnostic.getSeverity () != Diagnostic.OK )
{
resourceToDiagnosticMap.put ( resource, analyzeResourceProblems ( resource, exception ) );
}
editingDomain.getResourceSet ().eAdapters ().add ( problemIndicationAdapter );
}
示例10: load
import org.eclipse.emf.common.util.URI; //导入依赖的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 ) );
}
示例11: generateDesignProject
import org.eclipse.emf.common.util.URI; //导入依赖的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;
}
示例12: createResource
import org.eclipse.emf.common.util.URI; //导入依赖的package包/类
/**
* Creates an instance of the resource.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public Resource createResource ( URI uri )
{
XMLResource result = new ChartResourceImpl ( uri );
result.getDefaultSaveOptions ().put ( XMLResource.OPTION_EXTENDED_META_DATA, Boolean.TRUE );
result.getDefaultLoadOptions ().put ( XMLResource.OPTION_EXTENDED_META_DATA, Boolean.TRUE );
result.getDefaultSaveOptions ().put ( XMLResource.OPTION_SCHEMA_LOCATION, Boolean.TRUE );
result.getDefaultLoadOptions ().put ( XMLResource.OPTION_USE_ENCODED_ATTRIBUTE_STYLE, Boolean.TRUE );
result.getDefaultSaveOptions ().put ( XMLResource.OPTION_USE_ENCODED_ATTRIBUTE_STYLE, Boolean.TRUE );
result.getDefaultLoadOptions ().put ( XMLResource.OPTION_USE_LEXICAL_HANDLER, Boolean.TRUE );
return result;
}
示例13: getProjectDescription
import org.eclipse.emf.common.util.URI; //导入依赖的package包/类
@Override
public ProjectDescription getProjectDescription(URI location) {
LazyProjectDescriptionHandle handle = projectElementHandles.get(location);
if (handle == null) {
// check case without trailing path separator
if (location.hasTrailingPathSeparator()) {
handle = projectElementHandles.get(location.trimSegments(1));
}
}
if (handle == null) {
return null;
}
ProjectDescription description = handle.resolve();
return description;
}
示例14: matches
import org.eclipse.emf.common.util.URI; //导入依赖的package包/类
@Override
public boolean matches(Issue issue) {
URI actualValue = getActualValue.apply(issue);
if (actualValue == null)
return false;
List<String> actualSegments = actualValue.segmentsList();
List<String> expectedSegments = expectedPattern.segmentsList();
switch (mode) {
case StartsWith:
return Collections.indexOfSubList(actualSegments, expectedSegments) == 0;
case EndsWith:
return Collections.lastIndexOfSubList(actualSegments, expectedSegments) == actualSegments.size()
- expectedSegments.size();
case Equals:
return actualSegments.equals(expectedSegments);
}
throw new IllegalStateException("Unknown URI property matching mode: " + mode);
}
示例15: getIFile
import org.eclipse.emf.common.util.URI; //导入依赖的package包/类
/**
* Getting an IFile from an EMF Resource
*
* @param eObject
* @return
*/
public static IFile getIFile(Resource res) {
URI uri = res.getURI();
String filePath = uri.toPlatformString(true);
IFile ifile = ResourcesPlugin.getWorkspace().getRoot()
.getFile(new Path(filePath));
return ifile;
}