Пример #1
0
 /**
  * @param input
  * @return
  */
 public static URI getUri(IEditorInput input, String editorID) {
   String uriString = null;
   if (input instanceof URIEditorInput) {
     uriString = PathsUtil.getRelativeWorkspaceFromEditorInputWithFragment(input);
   } else {
     uriString = PathsUtil.getRelativeWorkspaceFromEditorInput(input);
     String fragment = MDTUtil.getLastOpenedDiagramPropertyForEditor(uriString, editorID);
     if (fragment != null) {
       uriString = URI.createURI(uriString).appendFragment(fragment).toString();
     }
   }
   if (input != null) {
     URI uri = URI.createURI(uriString);
     if (uri.hasFragment()) {
       return uri;
     }
     ResourceSet resourceSet = new ResourceSetImpl();
     try {
       resourceSet
           .getResourceFactoryRegistry()
           .getExtensionToFactoryMap()
           .put(Resource.Factory.Registry.DEFAULT_EXTENSION, new XMIResourceFactoryImpl());
       Resource resource = resourceSet.getResource(uri, true);
       Diagram diagram = MDTUtil.getFirstDiagramFromResource(resource);
       if (diagram != null) {
         String fragment = resource.getURIFragment(diagram);
         uri = uri.appendFragment(fragment);
       }
     } finally {
       EMFHelper.unload(resourceSet);
     }
     return uri;
   }
   return null;
 }
Пример #2
0
 public static void dumpURI(URI uri, Logger logger) {
   logger.debug("URI: " + uri);
   logger.debug("authority: " + uri.authority());
   logger.debug("device: " + uri.device());
   logger.debug("devicePath: " + uri.devicePath());
   logger.debug("fileExtension: " + uri.fileExtension());
   logger.debug("fragment: " + uri.fragment());
   logger.debug("host: " + uri.host());
   logger.debug("lastSegment: " + uri.lastSegment());
   logger.debug("opaquePart: " + uri.opaquePart());
   logger.debug("path: " + uri.path());
   logger.debug("port: " + uri.port());
   logger.debug("query: " + uri.query());
   logger.debug("scheme: " + uri.scheme());
   logger.debug("segmentCount: " + uri.segmentCount());
   logger.debug("toFileString: " + uri.toFileString());
   logger.debug("userInfo: " + uri.userInfo());
   logger.debug("hasAbsolutePath: " + uri.hasAbsolutePath());
   logger.debug("schemehasAbsolutePath: " + uri.hasAbsolutePath());
   logger.debug("hasAuthority: " + uri.hasAuthority());
   logger.debug("hasDevice: " + uri.hasDevice());
   logger.debug("hasEmptyPath: " + uri.hasEmptyPath());
   logger.debug("hasFragment: " + uri.hasFragment());
   logger.debug("hasOpaquePart: " + uri.hasOpaquePart());
   logger.debug("hasPath: " + uri.hasPath());
   logger.debug("hasQuery: " + uri.hasQuery());
   logger.debug("hasRelativePath: " + uri.hasRelativePath());
   logger.debug("hasTrailingPathSeparator: " + uri.hasTrailingPathSeparator());
   logger.debug("isCurrentDocumentReference: " + uri.isCurrentDocumentReference());
   logger.debug("isEmpty: " + uri.isEmpty());
   logger.debug("isFile: " + uri.isFile());
   logger.debug("isHierarchical: " + uri.isHierarchical());
   logger.debug("isPrefix: " + uri.isPrefix());
   logger.debug("isRelative: " + uri.isRelative());
   logger.debug("segments: " + uri.segments());
 }