Package org.eclipse.emf.common.util

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


                        uri,
                        FILE_PREFIX,
                        filePrefixWithSlash);
            }
        }
        final URI resourceUri = URI.createURI(uri);
        if (resourceUri == null)
        {
            throw new RepositoryFacadeException("The path '" + uri + "' is not a valid URI");
        }
        return resourceUri;
View Full Code Here


        String location,
        String version)
    {
        final org.eclipse.emf.ecore.EModelElement element = (org.eclipse.emf.ecore.EModelElement)model;
        final Resource resource = element.eResource();
        final URI uri = URI.createURI(location);
        resource.setURI(uri);
        try
        {
            resource.save(null);
        }
View Full Code Here

     *
     * @see org.eclipse.emf.ecore.resource.URIConverter#normalize(org.eclipse.emf.common.util.URI)
     */
    public URI normalize(final URI uri)
    {
        URI normalizedUri = super.normalize(uri);
        if (normalizedUri.equals(uri))
        {
            if (this.moduleSearchPaths != null)
            {
                if (!this.normalizedUris.containsKey(uri))
                {
                    final String resourceName = uri.toString().replaceAll(
                            ".*(\\\\+|/)",
                            "");
                    for (final Iterator iterator = this.moduleSearchPaths.iterator(); iterator.hasNext();)
                    {
                        final String searchPath = (String)iterator.next();
                        final URI fileURI = EMFRepositoryFacadeUtils.createUri(ResourceUtils.normalizePath(searchPath));
                        if (fileURI.lastSegment().equals(resourceName))
                        {
                            AndroMDALogger.info("referenced model --> '" + fileURI + "'");
                            normalizedUri = fileURI;
                            this.normalizedUris.put(
                                uri,
View Full Code Here

    EList<Diagnostic> warnings = null;
    try {
      Lexer lexer = new Lexer(input);
      tokens = lexer.tokenizeToStrings();
      InputStream in = getAsStream("" + input);
      URI uri = URI.createURI("mytestmodel." + getCurrentFileExtension());
      XtextResource resource = doGetResource(in, uri);
      parseResult = getModel(resource);
      errors = resource.getErrors();
      warnings = resource.getWarnings();
      if (errorCount == 0)
View Full Code Here

            TargetPlatformActivator.FR_OBEO_RELENG_TARGETPLATFORM_TARGETPLATFORM);
    Converter converter = new Converter();
    injector.injectMembers(converter);
    Diagnostic diagnostic = null;
    final String path = selectedElement.getLocation().toFile().getAbsolutePath();
    URI targetplatformFileURI = URI.createFileURI(path);

    try {
      diagnostic = converter.generateTargetDefinitionFile(targetplatformFileURI, subMonitor.newChild(95));
    } catch (OperationCanceledException cancel) {
      ret = new Status(
          IStatus.CANCEL,
          TargetPlatformActivator.FR_OBEO_RELENG_TARGETPLATFORM_TARGETPLATFORM,
          cancel.getMessage(), cancel);
    } catch (Exception e) {
      ret = new Status(
          IStatus.ERROR,
          TargetPlatformActivator.FR_OBEO_RELENG_TARGETPLATFORM_TARGETPLATFORM,
          e.getMessage(), e);
    }
    IContainer container = selectedElement.getParent();
    if (container != null) {
      try {
        container.refreshLocal(IResource.DEPTH_ONE, subMonitor.newChild(5));
      } catch (CoreException e) {
        return new Status(IStatus.ERROR, TargetPlatformActivator
            .getInstance().getBundle().getSymbolicName(),
            e.getMessage(), e);
      }
    }

    if (setTargetPlatform) {
      PDEIntegration pdeIntegration = new PDEIntegration();

      final URI targetFileURI = targetplatformFileURI.trimFileExtension().appendFileExtension("target");
      try {
        pdeIntegration.setTargetPlatform(targetFileURI, monitor);
      } catch (CoreException e) {
        ret = new Status(
            IStatus.ERROR,
View Full Code Here

    }
  }

  private boolean trySetTargetPlatform(URI targetFileURIToSet, SubMonitor subMonitor, WorkspaceFileTargetHandle fileHandle) throws CoreException {
    File targetFile = ((WorkspaceFileTargetHandle) fileHandle).getTargetFile().getLocation().toFile();
    URI targetFileURI = URI.createFileURI(targetFile.getAbsolutePath());
    if (targetFileURI.equals(targetFileURIToSet)) {
      ITargetDefinition targetDefinitionToSet = fileHandle.getTargetDefinition();

      if (!targetDefinitionToSet.isResolved()) {
        targetDefinitionToSet.resolve(subMonitor.newChild(80));
      }
View Full Code Here

  public Optional<URI> getActiveTargetPlatformFileURI() throws CoreException {
    if (service.isPresent()) {
      ITargetDefinition currentlySelected = service.get().getWorkspaceTargetHandle().getTargetDefinition();
      if (currentlySelected.getHandle() instanceof WorkspaceFileTargetHandle) {
        IFile targetFile = ((WorkspaceFileTargetHandle) currentlySelected.getHandle()).getTargetFile();
        URI targetFileURI = URI.createFileURI(targetFile.getLocation().toFile().getAbsolutePath());
        return Optional.of(targetFileURI);
      }
    }
    return Optional.absent();
  }
View Full Code Here

          _builder.append(_join, "");
          _builder.append("\'  in \'");
          final Function1<Location, String> _function_5 = new Function1<Location, String>() {
            public String apply(final Location it) {
              Resource _eResource = it.eResource();
              URI _uRI = _eResource.getURI();
              return _uRI.toString();
            }
          };
          Iterable<String> _map_2 = IterableExtensions.<Location, String>map(externalLocationsWithConflictualID, _function_5);
          Set<String> _set = IterableExtensions.<String>toSet(_map_2);
          String _join_1 = IterableExtensions.join(_set, "\', \'");
          _builder.append(_join_1, "");
          _builder.append("\'.");
          final String msg = _builder.toString();
          final Function1<Location, Iterable<IncludeDeclaration>> _function_6 = new Function1<Location, Iterable<IncludeDeclaration>>() {
            public Iterable<IncludeDeclaration> apply(final Location location) {
              EList<IncludeDeclaration> _includes = targetPlatform.getIncludes();
              final Function1<IncludeDeclaration, Boolean> _function = new Function1<IncludeDeclaration, Boolean>() {
                public Boolean apply(final IncludeDeclaration it) {
                  boolean _xblockexpression = false;
                  {
                    final TargetPlatform direct = TargetPlatformValidator.this.indexBuilder.getImportedTargetPlatform(resource, it);
                    boolean _or = false;
                    EList<Location> _locations = direct.getLocations();
                    boolean _contains = _locations.contains(location);
                    if (_contains) {
                      _or = true;
                    } else {
                      LinkedList<TargetPlatform> _importedTargetPlatforms = TargetPlatformValidator.this.indexBuilder.getImportedTargetPlatforms(direct);
                      final Function1<TargetPlatform, EList<Location>> _function = new Function1<TargetPlatform, EList<Location>>() {
                        public EList<Location> apply(final TargetPlatform it) {
                          return it.getLocations();
                        }
                      };
                      List<EList<Location>> _map = ListExtensions.<TargetPlatform, EList<Location>>map(_importedTargetPlatforms, _function);
                      Iterable<Location> _flatten = Iterables.<Location>concat(_map);
                      Set<Location> _set = IterableExtensions.<Location>toSet(_flatten);
                      boolean _contains_1 = _set.contains(location);
                      _or = _contains_1;
                    }
                    _xblockexpression = _or;
                  }
                  return Boolean.valueOf(_xblockexpression);
                }
              };
              return IterableExtensions.<IncludeDeclaration>filter(_includes, _function);
            }
          };
          Iterable<Iterable<IncludeDeclaration>> _map_3 = IterableExtensions.<Location, Iterable<IncludeDeclaration>>map(externalLocationsWithConflictualID, _function_6);
          Iterable<IncludeDeclaration> _flatten = Iterables.<IncludeDeclaration>concat(_map_3);
          final Set<IncludeDeclaration> conflictualInclude = IterableExtensions.<IncludeDeclaration>toSet(_flatten);
          final Procedure1<IncludeDeclaration> _function_7 = new Procedure1<IncludeDeclaration>() {
            public void apply(final IncludeDeclaration it) {
              TargetPlatformValidator.this.error(msg, it,
                TargetPlatformPackage.Literals.INCLUDE_DECLARATION__IMPORT_URI,
                TargetPlatformValidator.CHECK__CONFLICTUAL_ID__BETWEEN_INCLUDED_LOCATION);
            }
          };
          IterableExtensions.<IncludeDeclaration>forEach(conflictualInclude, _function_7);
        }
        int _size_1 = externalIDs.size();
        boolean _equals = (_size_1 == 1);
        if (_equals) {
          final Sets.SetView<String> diff = Sets.<String>symmetricDifference(externalIDs, internalIDs);
          boolean _isEmpty = diff.isEmpty();
          boolean _not = (!_isEmpty);
          if (_not) {
            StringConcatenation _builder_1 = new StringConcatenation();
            _builder_1.append("The ID for location \'");
            _builder_1.append(locationURI, "");
            _builder_1.append("\' must be unique across included target platforms and the current one. Found \'");
            String _head = IterableExtensions.<String>head(externalIDs);
            _builder_1.append(_head, "");
            _builder_1.append("\'  in \'");
            final Function1<Location, String> _function_8 = new Function1<Location, String>() {
              public String apply(final Location it) {
                Resource _eResource = it.eResource();
                URI _uRI = _eResource.getURI();
                return _uRI.toString();
              }
            };
            Iterable<String> _map_4 = IterableExtensions.<Location, String>map(externalLocations, _function_8);
            Set<String> _set_1 = IterableExtensions.<String>toSet(_map_4);
            String _join_2 = IterableExtensions.join(_set_1, "\', \'");
View Full Code Here

  private Diagnostic doGenerateTargetDefinitionFile(URI uri, ResolvedTargetPlatform resolvedTargetPlatform) {
    BasicDiagnostic ret = new BasicDiagnostic();
    TargetDefinitionGenerator generator = new TargetDefinitionGenerator();
    String xml = generator.generate(resolvedTargetPlatform, (int)TimeUnit.MILLISECONDS.toSeconds(System.currentTimeMillis()));
    final URI targetDefinitionLocation = uri.trimFileExtension().appendFileExtension("target");
   
    Diagnostic diagnostic = serialize(targetDefinitionLocation, xml);
    if (diagnostic.getSeverity() >= Diagnostic.WARNING) {
      ret.merge(diagnostic);
    }
View Full Code Here

    return ret;
  }

  private Diagnostic serialize(URI targetPlatformLocation, String xml) {
    BasicDiagnostic ret = new BasicDiagnostic();
    URI targetDefinitionLocation = targetPlatformLocation.trimFileExtension().appendFileExtension("target");
   
    if (hasContentDifferencesOtherThanSequenceNumber(targetDefinitionLocation, xml)) {
      OutputStream outputStream = null;
      try {
        outputStream = new BufferedOutputStream(new FileOutputStream(new File(targetDefinitionLocation.toFileString())));
        outputStream.write(xml.getBytes());
      } catch (Exception e) {
        ret.merge(BasicDiagnostic.toDiagnostic(e));
      } finally {
        try {
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.