Package org.eclipse.emf.common.util

Examples of org.eclipse.emf.common.util.URI


        }
        if (nextEObject instanceof Diagram) {
          break;
        }
      }
      URI uri = EcoreUtil.getURI(myDiagram);
      String editorName = uri.lastSegment()
          + "#" + myDiagram.eResource().getContents().indexOf(myDiagram); //$NON-NLS-1$
      IEditorInput editorInput = new URIEditorInput(uri, editorName);
      return editorInput;
    }
View Full Code Here


      return null;
    }
    if (fileDialog.getFilterPath() != null) {
      fileName = fileDialog.getFilterPath() + File.separator + fileName;
    }
    URI uri = URI.createFileURI(fileName);
    Resource resource = null;
    try {
      resource = editingDomain.getResourceSet().getResource(uri, true);
    } catch (WrappedException we) {
      OntoUML.diagram.part.OntoUMLDiagramEditorPlugin.getInstance()
View Full Code Here

   * <!-- 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.
      //
View Full Code Here

  @Override
  public void doSaveAs() {
    String[] filters = FILE_EXTENSION_FILTERS.toArray(new String[FILE_EXTENSION_FILTERS.size()]);
    String[] files = OntoUMLEditorAdvisor.openFilePathDialog(getSite().getShell(), SWT.SAVE, filters);
    if (files.length > 0) {
      URI uri = URI.createFileURI(files[0]);
      doSaveAs(uri, new URIEditorInput(uri));
    }
  }
View Full Code Here

  @Override
  public boolean performFinish() {
    try {
      // Get the URI of the model file.
      //
      final URI fileURI = getModelURI();
      if (new File(fileURI.toFileString()).exists()) {
        if (!MessageDialog.openQuestion
            (getShell(),
             OntoUMLEditorPlugin.INSTANCE.getString("_UI_Question_title"),
             OntoUMLEditorPlugin.INSTANCE.getString("_WARN_FileConflict", new String []{ fileURI.toFileString() }))) {
          initialObjectCreationPage.selectFileField();
          return false;
        }
      }
     
View Full Code Here

     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    protected boolean validatePage() {
      URI fileURI = getFileURI();
      if (fileURI == null || fileURI.isEmpty()) {
        setErrorMessage(null);
        return false;
      }

      String extension = fileURI.fileExtension();
      if (extension == null || !FILE_EXTENSIONS.contains(extension)) {
        String key = FILE_EXTENSIONS.size() > 1 ? "_WARN_FilenameExtensions" : "_WARN_FilenameExtension";
        setErrorMessage(OntoUMLEditorPlugin.INSTANCE.getString(key, new Object [] { FORMATTED_FILE_EXTENSIONS }));
        return false;
      }
View Full Code Here

    @SuppressWarnings("unchecked")
    public static GenPackage createGenPackage(EPackage ePackage, String basePackage, String prefix,
                                              int genOptions, ResourceSet resourceSet) {
        GenModel genModel = ecore2GenModel(ePackage, basePackage, prefix, genOptions);

        URI ecoreURI = URI.createURI("file:///" + ePackage.getName() + ".ecore");
        URI genModelURI = ecoreURI.trimFileExtension().appendFileExtension("genmodel");

        Resource ecoreResource = resourceSet.createResource(ecoreURI);
        ecoreResource.getContents().add(ePackage);

        Resource genModelResource = resourceSet.createResource(genModelURI);
View Full Code Here

  }

public static String getDefaultPackageName(String targetNamespace)
  {

      URI uri = URI.createURI(targetNamespace);
      List parsedName;
      if (uri.isHierarchical())
      {
        String host = uri.host();
        if (host != null && host.startsWith("www."))
        {
          host = host.substring(4);
        }
        parsedName = parseNameStatic(host, '.');
        Collections.reverse(parsedName);
        if (!parsedName.isEmpty())
        {
          parsedName.set(0, ((String)parsedName.get(0)).toLowerCase());
        }
 
        parsedName.addAll(parseNameStatic(uri.trimFileExtension().path(), '/'));
      }
      else
      {
        String opaquePart = uri.opaquePart();
        int index = opaquePart.indexOf(":");
        if (index != -1 && "urn".equalsIgnoreCase(uri.scheme()))
        {
          parsedName = parseNameStatic(opaquePart.substring(0, index), '-');
          if (parsedName.size() > 0 && DOMAINS.contains(parsedName.get(parsedName.size() - 1)))
          {
            Collections.reverse(parsedName);
View Full Code Here

   *          from schema location map.
   * @return string form of URI from provided value, deresolved if appropriate.
   */
  protected String deresolve(String value)
  {
    URI location = URI.createURI(value);
    URI resourceURI = resource.getURI();
    boolean shouldDeresolve = resourceURI != null && !resourceURI.isRelative()
        && resourceURI.isHierarchical();
    if (shouldDeresolve && !location.isRelative())
    {
      URI deresolvedURI = location.deresolve(resourceURI, true, true, false);
      if (deresolvedURI.hasRelativePath())
      {
        location = deresolvedURI;
      }
    }
    return location.toString();
View Full Code Here

   *          for schema location from input parameter.
   * @return string form of URI from provided value, resolved if appropriate.
   */
  protected String resolve(String value)
  {
    URI location = URI.createURI(value);
    URI resourceURI = resource.getURI();
    boolean shouldResolve = resourceURI != null && resourceURI.isHierarchical()
        && !resourceURI.isRelative();
    if (shouldResolve && location.isRelative() && location.hasRelativePath())
    {
      location = location.resolve(resourceURI, false);
    }
    return location.toString();
View Full Code Here

TOP

Related Classes of org.eclipse.emf.common.util.URI

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.