Package org.eclipse.core.runtime

Examples of org.eclipse.core.runtime.SubMonitor


  }

  @Override
  protected IStatus run(IProgressMonitor monitor) {
    IStatus ret = Status.OK_STATUS;
    SubMonitor subMonitor = SubMonitor.convert(monitor, 100);
    Injector injector = TargetPlatformActivator
        .getInstance()
        .getInjector(
            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);
      }
View Full Code Here


    );
  }

  public void setTargetPlatform(URI targetFileURIToSet, IProgressMonitor monitor) throws CoreException {
    if (service.isPresent()) {
      SubMonitor subMonitor = SubMonitor.convert(monitor, 100);
      ITargetHandle[] targets = service.get().getTargets(subMonitor.newChild(20));

      boolean hasBeenSet = false;
      for (int i = 0; i < targets.length && !hasBeenSet; i++) {
        if (targets[i] instanceof WorkspaceFileTargetHandle) {
          WorkspaceFileTargetHandle fileHandle = (WorkspaceFileTargetHandle) targets[i];
View Full Code Here

        final IRunnableWithProgress _function = new IRunnableWithProgress() {
          public void run(final IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
            Shell _shell = window.getShell();
            Display _display = _shell.getDisplay();
            ReadAndDispatchProgressMonitorWrapper _readAndDispatchProgressMonitorWrapper = new ReadAndDispatchProgressMonitorWrapper(monitor, _display);
            final SubMonitor wpm = SubMonitor.convert(_readAndDispatchProgressMonitorWrapper, ("Creating content assist for " + uri), 100);
            try {
              Object _service = TargetPlatformProposalProvider.this.provisioningAgent.getService(IMetadataRepositoryManager.SERVICE_NAME);
              final IMetadataRepositoryManager repositoryManager = ((IMetadataRepositoryManager) _service);
              URI _uRI = new URI(uri);
              SubMonitor _newChild = wpm.newChild(90);
              final IMetadataRepository metadataRepository = repositoryManager.loadRepository(_uRI, _newChild);
              IQuery<IInstallableUnit> _iUAssistQuery = TargetPlatformProposalProvider.this.getIUAssistQuery();
              SubMonitor _newChild_1 = wpm.newChild(5);
              IQueryResult<IInstallableUnit> _query = metadataRepository.query(_iUAssistQuery, _newChild_1);
              final Set<IInstallableUnit> results = _query.toUnmodifiableSet();
              final Function1<IInstallableUnit, Boolean> _function = new Function1<IInstallableUnit, Boolean>() {
                public Boolean apply(final IInstallableUnit it) {
                  EList<IU> _ius = location.getIus();
                  final Function1<IU, String> _function = new Function1<IU, String>() {
                    public String apply(final IU it) {
                      return it.getID();
                    }
                  };
                  List<String> _map = ListExtensions.<IU, String>map(_ius, _function);
                  String _id = it.getId();
                  boolean _contains = _map.contains(_id);
                  return Boolean.valueOf((!_contains));
                }
              };
              Iterable<IInstallableUnit> _filter = IterableExtensions.<IInstallableUnit>filter(results, _function);
              final Procedure1<IInstallableUnit> _function_1 = new Procedure1<IInstallableUnit>() {
                public void apply(final IInstallableUnit it) {
                  String _id = it.getId();
                  IQuery<IInstallableUnit> _createIUQuery = QueryUtil.createIUQuery(_id);
                  SubMonitor _newChild = wpm.newChild(5);
                  final IQueryResult<IInstallableUnit> allVersions = metadataRepository.query(_createIUQuery, _newChild);
                  String _id_1 = it.getId();
                  Iterator<IInstallableUnit> _iterator = allVersions.iterator();
                  final Function1<IInstallableUnit, String> _function = new Function1<IInstallableUnit, String>() {
                    public String apply(final IInstallableUnit it) {
View Full Code Here

  private IRunnableWithProgress versionProposalRunnable(final String uri, final IU iu, final String prefix, final Display display, final ContentAssistContext context, final ICompletionProposalAcceptor acceptor) {
    final IRunnableWithProgress _function = new IRunnableWithProgress() {
      public void run(final IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
        try {
          ReadAndDispatchProgressMonitorWrapper _readAndDispatchProgressMonitorWrapper = new ReadAndDispatchProgressMonitorWrapper(monitor, display);
          final SubMonitor wpm = SubMonitor.convert(_readAndDispatchProgressMonitorWrapper, ("Creating content assist for " + uri), 100);
          try {
            Object _service = TargetPlatformProposalProvider.this.provisioningAgent.getService(IMetadataRepositoryManager.SERVICE_NAME);
            final IMetadataRepositoryManager repositoryManager = ((IMetadataRepositoryManager) _service);
            URI _uRI = new URI(uri);
            SubMonitor _newChild = wpm.newChild(95);
            final IMetadataRepository metadataRepository = repositoryManager.loadRepository(_uRI, _newChild);
            String _iD = iu.getID();
            IQuery<IInstallableUnit> _createIUQuery = QueryUtil.createIUQuery(_iD);
            SubMonitor _newChild_1 = wpm.newChild(5);
            IQueryResult<IInstallableUnit> _query = metadataRepository.query(_createIUQuery, _newChild_1);
            final Set<IInstallableUnit> results = _query.toUnmodifiableSet();
            final Procedure1<IInstallableUnit> _function = new Procedure1<IInstallableUnit>() {
              public void apply(final IInstallableUnit it) {
                Version _version = it.getVersion();
View Full Code Here

    this.options = options;
  }
 
  public Diagnostic resolve(IMetadataRepositoryManager metadataRepositoryManager, IProgressMonitor monitor) {
    BasicDiagnostic diag = new BasicDiagnostic();
    SubMonitor subMonitor = SubMonitor.convert(monitor, 100);
   
    IMetadataRepository metadataRepository;
    try {
      metadataRepository = metadataRepositoryManager.loadRepository(uri, subMonitor.newChild(80));
      SubMonitor loopMonitor = subMonitor.newChild(20).setWorkRemaining(unresolvedIUs.size());
      for (UnresolvedIU iu : unresolvedIUs) {
        if (monitor.isCanceled()) {
          break;
        }
        Set<IInstallableUnit> results = metadataRepository.query(iu.getQuery(), loopMonitor.newChild(1)).toUnmodifiableSet();
        if (!results.isEmpty()) {
          IInstallableUnit unit =  results.iterator().next();
          if (iu.isLazyRange() && unit instanceof InstallableUnit) {
            ((InstallableUnit)unit).setVersion(Version.create("0.0.0"));
          }
View Full Code Here

    return environment;
  }
 
  public Diagnostic resolve(IMetadataRepositoryManager metadataRepositoryManager, IProgressMonitor monitor) {
    BasicDiagnostic ret = new BasicDiagnostic();
    SubMonitor subMonitor = SubMonitor.convert(monitor, getLocations().size());
    for (ResolvedLocation location : getLocations()) {
      if(subMonitor.isCanceled()) {
        ret.merge(BasicDiagnostic.CANCEL_INSTANCE);
        break;
      }
      Diagnostic diagnostic = location.resolve(metadataRepositoryManager, subMonitor);
      if (diagnostic.getSeverity() >= Diagnostic.WARNING) {
        ret.merge(diagnostic);
      }
      subMonitor.worked(1);
    }
    return ret;
  }
View Full Code Here

    return ret;
  }

  private Diagnostic doGenerateTargetDefinitionFile(URI uri, IProgressMonitor monitor) {
    BasicDiagnostic ret = new BasicDiagnostic();
    SubMonitor subMonitor = SubMonitor.convert(monitor, 100);
   
    try {
      Resource resource = loadTargetPlatform(uri);
      subMonitor.worked(2);
     
      Diagnostic resourceDiagnostic = EcoreUtil.computeDiagnostic(resource, true);
      if (resourceDiagnostic.getSeverity() >= Diagnostic.WARNING) {
        ret.merge(resourceDiagnostic);
      }

      if (resourceDiagnostic.getSeverity() < Diagnostic.ERROR) {
        TargetPlatform targetPlatform = null;
        if (resource != null && !resource.getContents().isEmpty()) {
          targetPlatform = (TargetPlatform) resource.getContents().get(0);
        }
        if (targetPlatform == null) {
          ret.merge(new BasicDiagnostic(Diagnostic.ERROR, TargetPlatformBundleActivator.PLUGIN_ID, -1, "Error occured while loading the file " + uri + ".", null));
        } else if (subMonitor.isCanceled()) {
          ret.merge(Diagnostic.CANCEL_INSTANCE);
        } else {
          SubMonitor diagnosticianMonitor = subMonitor.newChild(90).setWorkRemaining(targetPlatform.getLocations().size());
          Diagnostic validation = new CustomDiagnostician(diagnosticianMonitor).validate(targetPlatform);
          if (validation.getSeverity() >= Diagnostic.WARNING) {
            ret.merge(validation);
          } else if (subMonitor.isCanceled()) {
            ret.merge(Diagnostic.CANCEL_INSTANCE);
View Full Code Here

    return ret;
  }

  private Diagnostic doGenerateTargetDefinitionFile(URI uri, TargetPlatform targetPlatform, IProgressMonitor monitor)  {
    final BasicDiagnostic ret = new BasicDiagnostic();
    SubMonitor subMonitor = SubMonitor.convert(monitor, 100);
   
    try {
      IMetadataRepositoryManager repositoryManager = (IMetadataRepositoryManager) agent.getService(IMetadataRepositoryManager.SERVICE_NAME);
      ResolvedTargetPlatform resolvedTargetPlatform = ResolvedTargetPlatform.create(targetPlatform, indexBuilder);
      subMonitor.worked(5);
     
      if (subMonitor.isCanceled()) {
        ret.merge(Diagnostic.CANCEL_INSTANCE);
      } else {
        Diagnostic diagnostic = resolvedTargetPlatform.resolve(repositoryManager, subMonitor.newChild(90));
        if (diagnostic.getSeverity() >= Diagnostic.WARNING) {
          ret.merge(diagnostic);
        }
        if (subMonitor.isCanceled()) {
          ret.merge(Diagnostic.CANCEL_INSTANCE);
        } else if (ret.getSeverity() < Diagnostic.ERROR) {
          diagnostic = doGenerateTargetDefinitionFile(uri, resolvedTargetPlatform);
          if (diagnostic.getSeverity() >= Diagnostic.WARNING) {
            ret.merge(diagnostic);
          }
          subMonitor.worked(5);
        }
      }
    } catch (Exception e) {
      ret.merge(BasicDiagnostic.toDiagnostic(e));
    }
View Full Code Here

  }

  private void copyWithSize(InputStream in, OutputStream out, IProgressMonitor monitor, int size) throws IOException {
    if (BUFFER == null)
      BUFFER = new byte[8192];
    SubMonitor progress = SubMonitor.convert(monitor, size);
    int r = in.read(BUFFER);
    while (r >= 0) {
      out.write(BUFFER, 0, r);
      progress.worked(r);
      r = in.read(BUFFER);
    }
  }
View Full Code Here

    if (BUFFER == null)
      BUFFER = new byte[8192];
   
    String msg = NLS.bind((size > 0) ? Messages.InstallableRuntime2_DownloadKnownSize : Messages.InstallableRuntime2_DownloadUnknownSize,
        new Object [] { name, "{0}", Integer.toString(size / 1024) }); //$NON-NLS-1$
    SubMonitor progress = SubMonitor.convert(monitor, NLS.bind(msg, "0"), (size > 0) ? size : DEFAULT_DOWNLOAD_SIZE); //$NON-NLS-1$
   
    int r = in.read(BUFFER);
    int total = 0;
    int lastTotal = 0;
    while (r >= 0) {
      out.write(BUFFER, 0, r);
      total += r;
      if (total >= lastTotal + 8192) {
        lastTotal = total;
        progress.subTask(NLS.bind(msg, Integer.toString(lastTotal / 1024)));
      }
      progress.worked(r);
      // if size is not known, use infinite logarithmic progress
      if (size <= 0)
        progress.setWorkRemaining(DEFAULT_DOWNLOAD_SIZE);
     
      if (progress.isCanceled())
        break;
      r = in.read(BUFFER);
    }
  }
View Full Code Here

TOP

Related Classes of org.eclipse.core.runtime.SubMonitor

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.