/**
   * Produces a graph depicting the old and new and the delta between them. Output is in SVG format.
   *
   * @param catalogName The name to generate as title in the graph. May be <code>null</code>
   * @param oldCatalogSream
   * @param newCatalogStream
   * @param svgStream
   * @param monitor
   * @param root - the root for files listed as source files in the catalog
   */
  public void produceSVGDeltaGraph(
      String catalogName,
      InputStream oldCatalogStream,
      IPath oldRoot,
      InputStream newCatalogStream,
      IPath newRoot,
      OutputStream svgStream,
      IProgressMonitor monitor)
      throws IOException {
    final SubMonitor ticker = SubMonitor.convert(monitor, 2000);
    CatalogDeltaGraphProducer graphProducer = new CatalogDeltaGraphProducer(hrefProducer, prefix);
    Catalog oldCatalog = CatalogJsonSerializer.load(oldCatalogStream);
    Catalog newCatalog = CatalogJsonSerializer.load(newCatalogStream);

    ICancel cancel =
        new ProgressMonitorCancelIndicator(ticker.newChild(IProgressMonitor.UNKNOWN), 1000);

    ByteArrayOutputStream2 out = new ByteArrayOutputStream2();

    graphProducer.produceGraph(cancel, catalogName, oldCatalog, oldRoot, newCatalog, newRoot, out);
    graphProducer
        .getSVGProducer()
        .produceSVG(
            out.toInputStream(false),
            svgStream,
            false, //
            ticker.newChild(IProgressMonitor.UNKNOWN));
  }
 private RefactoringStatus validate(IProgressMonitor pm, EObject object) {
   RefactoringStatus refactoringStatus = RefactoringStatus.create(Status.OK_STATUS);
   EValidator.Registry validatorRegistry =
       extensions.getInstance(EValidator.Registry.class, object);
   EPackage epackage = object.eClass().getEPackage();
   EValidator validator = validatorRegistry.getEValidator(epackage);
   BasicDiagnostic diagnostics = new BasicDiagnostic();
   if (pm.isCanceled()) {
     refactoringStatus = RefactoringStatus.create(Status.CANCEL_STATUS);
     pm.done();
   } else {
     SubMonitor sm = SubMonitor.convert(pm, "Validating re-factoring.", IProgressMonitor.UNKNOWN);
     validator.validate(object, diagnostics, Maps.newHashMap());
     Iterator<Diagnostic> validationIterator =
         Iterables.filter(
                 diagnostics.getChildren(),
                 new Predicate<Diagnostic>() {
                   @Override
                   public boolean apply(Diagnostic diagnostic) {
                     if (diagnostic instanceof FeatureBasedDiagnostic) {
                       return FeatureBasedDiagnostic.ERROR
                           == ((FeatureBasedDiagnostic) diagnostic).getSeverity();
                     }
                     return false;
                   }
                 })
             .iterator();
     if (validationIterator.hasNext()) {
       Diagnostic diagnostic = validationIterator.next();
       refactoringStatus = RefactoringStatus.createFatalErrorStatus(diagnostic.getMessage());
     }
     sm.done();
   }
   return refactoringStatus;
 }
  @Override
  public void launch(
      final ILaunchConfiguration config,
      final String mode,
      final ILaunch launch,
      final IProgressMonitor monitor)
      throws CoreException {
    final int WORK_LAUNCH = 10;
    final int WORK_POST_LAUNCH = 100;
    SubMonitor subMonitor = SubMonitor.convert(monitor, WORK_LAUNCH + WORK_POST_LAUNCH);

    // Validate all XML before doing anything else
    final SoftPkg spd = SpdLauncherUtil.getSpd(config);
    IStatus status = SpdLauncherUtil.validateAllXML(spd);
    if (!status.isOK()) {
      throw new CoreException(status);
    }

    final ILaunchConfigurationWorkingCopy copy = config.getWorkingCopy();
    insertProgramArguments(spd, launch, copy);

    try {
      super.launch(copy, mode, launch, subMonitor.newChild(WORK_LAUNCH));
      SpdLauncherUtil.postLaunch(spd, copy, mode, launch, subMonitor.newChild(WORK_POST_LAUNCH));
    } finally {
      if (monitor != null) {
        monitor.done();
      }
    }
  }
 private Collection<IInstallableUnit> filterInstallableUnits(
     String idPrefix,
     String idSuffix,
     IQueryResult<IInstallableUnit> queryResult,
     IProgressMonitor monitor)
     throws OperationCanceledException {
   if (monitor == null) {
     monitor = new NullProgressMonitor();
   }
   Collection<IInstallableUnit> wso2IUs = new ArrayList<IInstallableUnit>();
   Iterator<IInstallableUnit> iterator = queryResult.iterator();
   SubMonitor progress =
       SubMonitor.convert(monitor, Messages.UpdateManager_24, queryResult.toSet().size());
   ;
   while (iterator.hasNext()) {
     if (progress.isCanceled()) {
       throw new OperationCanceledException();
     }
     IInstallableUnit iu = iterator.next();
     String versionedID = iu.getId();
     progress.subTask(Messages.UpdateManager_25 + versionedID);
     if (versionedID != null
         && versionedID.startsWith(idPrefix)
         && versionedID.endsWith(idSuffix)) {
       wso2IUs.add(iu);
     }
     progress.worked(1);
   }
   return wso2IUs;
 }
 protected void findIndexedReferences(
     Set<URI> targetURIs,
     IAcceptor<IReferenceDescription> acceptor,
     Predicate<IReferenceDescription> filter,
     IProgressMonitor monitor) {
   Set<URI> targetResourceURIs =
       newHashSet(
           transform(
               targetURIs,
               new Function<URI, URI>() {
                 public URI apply(URI from) {
                   return from.trimFragment();
                 }
               }));
   int numResources = Iterables.size(index.getAllResourceDescriptions());
   SubMonitor subMonitor =
       SubMonitor.convert(monitor, Messages.ReferenceQuery_monitor, numResources);
   for (IResourceDescription resourceDescription : index.getAllResourceDescriptions()) {
     if (subMonitor.isCanceled()) return;
     if (!targetResourceURIs.contains(resourceDescription.getURI())) {
       for (IReferenceDescription referenceDescription :
           resourceDescription.getReferenceDescriptions()) {
         if (targetURIs.contains(referenceDescription.getTargetEObjectUri())
             && (filter == null || filter.apply(referenceDescription))) {
           acceptor.accept(referenceDescription);
         }
       }
     }
     subMonitor.worked(1);
   }
 }
  /**
   * Process all metadata files via the metadata reader returned by createMetadataReader
   *
   * @param monitor
   * @param reader
   * @param resources
   */
  private void loadMetadata(IProgressMonitor monitor, T reader, String... resources) {
    SubMonitor subMonitor = SubMonitor.convert(monitor, resources.length);

    for (String resource : resources) {
      URL url = FileLocator.find(this.getBundle(), new Path(resource), null);

      if (url != null) {
        InputStream stream = null;

        try {
          stream = url.openStream();

          reader.loadXML(stream, url.toString());
        } catch (Throwable t) {
          IdeLog.logError(
              CommonEditorPlugin.getDefault(),
              Messages.MetadataLoader_Error_Loading_Metadata + resource,
              t);
        } finally {
          if (stream != null) {
            try {
              stream.close();
            } catch (IOException e) {
            }
          }
        }
      }

      subMonitor.worked(1);
    }

    subMonitor.done();
  }
  /** This method is extremely expensive. */
  @OnEclipseVersionUpgrade("Replace monitor.newChild(1) by monitor.split(1)")
  private boolean isMethodUsedInItsPackage(IMethodBinding methodBinding, MethodDeclaration node) {
    final IPackageBinding methodPackage = methodBinding.getDeclaringClass().getPackage();

    final AtomicBoolean methodIsUsedInPackage = new AtomicBoolean(false);
    final SearchRequestor requestor =
        new SearchRequestor() {
          @Override
          public void acceptSearchMatch(SearchMatch match) {
            methodIsUsedInPackage.set(true);
          }
        };

    final SubMonitor subMonitor = SubMonitor.convert(ctx.getProgressMonitor(), 1);
    final SubMonitor childMonitor = subMonitor.newChild(1);
    try {
      final SearchEngine searchEngine = new SearchEngine();
      searchEngine.search(
          createPattern(methodBinding.getJavaElement(), REFERENCES, R_EXACT_MATCH),
          new SearchParticipant[] {SearchEngine.getDefaultSearchParticipant()},
          SearchEngine.createJavaSearchScope(new IJavaElement[] {methodPackage.getJavaElement()}),
          requestor,
          childMonitor);
      return methodIsUsedInPackage.get();
    } catch (CoreException e) {
      throw new UnhandledException(node, e);
    } finally {
      childMonitor.done();
    }
  }
 /* (non-Javadoc)
  * @see com.siteview.mde.internal.core.target.impl.AbstractBundleContainer#resolveBundles(com.siteview.mde.internal.core.target.provisional.ITargetDefinition, org.eclipse.core.runtime.IProgressMonitor)
  */
 protected IResolvedBundle[] resolveBundles(ITargetDefinition definition, IProgressMonitor monitor)
     throws CoreException {
   File dir = getDirectory();
   if (dir.isDirectory()) {
     File site = getSite(dir);
     File[] files = site.listFiles();
     SubMonitor localMonitor =
         SubMonitor.convert(monitor, Messages.DirectoryBundleContainer_0, files.length);
     List bundles = new ArrayList(files.length);
     for (int i = 0; i < files.length; i++) {
       if (localMonitor.isCanceled()) {
         return new IResolvedBundle[0];
       }
       try {
         IResolvedBundle rb = generateBundle(files[i]);
         if (rb != null) {
           bundles.add(rb);
         }
       } catch (CoreException e) {
         // ignore invalid bundles
       }
       localMonitor.worked(1);
     }
     localMonitor.done();
     return (IResolvedBundle[]) bundles.toArray(new IResolvedBundle[bundles.size()]);
   }
   throw new CoreException(
       new Status(
           IStatus.ERROR,
           MDECore.PLUGIN_ID,
           NLS.bind(Messages.DirectoryBundleContainer_1, dir.toString())));
 }
  /**
   * Creates a new project resource with the selected name.
   *
   * <p>In normal usage, this method is invoked after the user has pressed Finish on the wizard; the
   * enablement of the Finish button implies that all controls on the pages currently contain valid
   * values.
   *
   * <p>Note that this wizard caches the new project once it has been successfully created;
   * subsequent invocations of this method will answer the same project resource without attempting
   * to create it again.
   *
   * @param monitor TODO
   * @return the created project resource, or <code>null</code> if the project was not created
   */
  protected IProject createNewProject(IProgressMonitor monitor) throws InvocationTargetException {
    SubMonitor sub = SubMonitor.convert(monitor, 100);
    // Project description creation
    IProjectDescription description =
        ResourceUtil.getProjectDescription(destPath, getProjectNatures(), getProjectBuilders());
    description.setName(newProject.getName());
    description.setLocationURI(location);
    // Update the referenced project in case it was initialized.
    if (refProjects != null && refProjects.length > 0) {
      description.setReferencedProjects(refProjects);
    }
    sub.worked(10);

    if (!applySourcedProjectFilesAfterProjectCreated() && isCloneFromGit()) {
      cloneFromGit(newProject, description, sub.newChild(90));
    } else {
      doBasicCreateProject(newProject, description, sub.newChild(75));
      if (!applySourcedProjectFilesAfterProjectCreated()
          && selectedTemplate != null
          && !isCloneFromGit()) {
        selectedTemplate.apply(newProject, true);
      }
    }

    return newProject;
  }
  /**
   * Install selected features in to developer studio. Note: call {@link
   * #setSelectedFeaturesToInstall(List) setSelectedFeaturesToInstall} first.
   *
   * @param monitor
   */
  public void installSelectedFeatures(IProgressMonitor monitor) {
    SubMonitor progress = SubMonitor.convert(monitor, Messages.UpdateManager_32, 2);

    URI[] repos = new URI[] {getDevStudioReleaseSite()};
    session = new ProvisioningSession(p2Agent);
    installOperation = new InstallOperation(session, selectedFeatures);
    installOperation.getProvisioningContext().setArtifactRepositories(repos);
    installOperation.getProvisioningContext().setMetadataRepositories(repos);
    IStatus status = installOperation.resolveModal(progress.newChild(1));
    if (status.getSeverity() == IStatus.CANCEL || progress.isCanceled()) {
      throw new OperationCanceledException();
    } else if (status.getSeverity() == IStatus.ERROR) {
      String message = status.getChildren()[0].getMessage();
      log.error(Messages.UpdateManager_33 + message);
    } else {
      ProvisioningJob provisioningJob = installOperation.getProvisioningJob(progress.newChild(1));
      if (provisioningJob != null) {
        provisioningJob.addJobChangeListener(
            new JobChangeAdapter() {
              @Override
              public void done(IJobChangeEvent arg0) {
                Display.getDefault()
                    .syncExec(
                        new Runnable() {
                          @Override
                          public void run() {
                            boolean restart =
                                MessageDialog.openQuestion(
                                    Display.getDefault().getActiveShell(),
                                    Messages.UpdateManager_34,
                                    Messages.UpdateManager_35 + Messages.UpdateManager_36);
                            if (restart) {
                              PlatformUI.getWorkbench().restart();
                            }
                          }
                        });
              }
            });
        provisioningJob.schedule();
        Display.getDefault()
            .syncExec(
                new Runnable() {
                  @Override
                  public void run() {
                    try {
                      PlatformUI.getWorkbench()
                          .getActiveWorkbenchWindow()
                          .getActivePage()
                          .showView(IProgressConstants.PROGRESS_VIEW_ID);
                    } catch (PartInitException e) {
                      log.error(e);
                    }
                  }
                });
      } else {
        log.error(Messages.UpdateManager_37);
      }
    }
  }
  @Override
  public IStatus execute(final IProgressMonitor monitor)
      throws CoreException, InvocationTargetException {
    final SubMonitor progress =
        SubMonitor.convert(
            monitor,
            Messages.getString("org.kalypso.model.flood.ui.map.operations.ImportTinOperation.0"),
            100); //$NON-NLS-1$

    /* Add sources as new tin references */
    progress.subTask(
        Messages.getString(
            "org.kalypso.model.flood.ui.map.operations.ImportTinOperation.1")); //$NON-NLS-1$
    m_tinRefs = new ITinReference[m_sources.length];
    final Feature[] changedFeatures = new Feature[m_sources.length];

    for (int i = 0; i < m_sources.length; i++) {
      final IGmlSource source = m_sources[i];

      final ITinReference tinRef = m_tins.addNew(-1, ITinReference.QNAME, ITinReference.class);
      tinRef.setName(source.getName());
      tinRef.setDescription(source.getDescription());
      tinRef.setSourceLocation(source.getLocation());
      tinRef.setSourceFeaturePath(source.getPath());
      tinRef.setSourceType(typeForSource(source));

      m_tinRefs[i] = tinRef;
      changedFeatures[i] = tinRef;
    }
    ProgressUtilities.worked(progress, 20);

    /* post command for events stuff... */
    final Feature parentFeature = m_tins.getParentFeature();
    final GMLWorkspace workspace = parentFeature.getWorkspace();
    final ModellEvent modelEvent =
        new FeatureStructureChangeModellEvent(
            workspace,
            parentFeature,
            changedFeatures,
            FeatureStructureChangeModellEvent.STRUCTURE_CHANGE_ADD);
    workspace.fireModellEvent(modelEvent);
    /* Save data model */
    // progress.subTask( "speichere Datenmodell" );
    // m_provider.saveModel( IFloodModel.class, progress.newChild( 20 ) );
    /* update tins */
    progress.subTask(
        Messages.getString(
            "org.kalypso.model.flood.ui.map.operations.ImportTinOperation.2")); //$NON-NLS-1$
    final UpdateTinsOperation updateOp = new UpdateTinsOperation(m_tinRefs, m_provider);
    updateOp.execute(progress.newChild(60));

    /* Jump to imported tins */
    final GM_Envelope envelope = FeatureHelper.getEnvelope(changedFeatures);
    final GM_Envelope scaledBox =
        envelope == null ? null : GeometryUtilities.scaleEnvelope(envelope, 1.05);
    if (m_mapPanel != null && scaledBox != null) m_mapPanel.setBoundingBox(scaledBox);

    return Status.OK_STATUS;
  }
 /**
  * Standard impl of restart justc alls stop and then start. Subclasses should override if there's
  * a quicker implementation.
  */
 public IStatus restart(String mode, IProgressMonitor monitor) {
   SubMonitor sub = SubMonitor.convert(monitor, 100);
   IStatus status = stop(true, sub.newChild(30));
   if (!status.isOK()) {
     return status;
   }
   return start(mode, sub.newChild(70));
 }
Exemple #13
0
 /**
  * Run a refresh synchronously. FIXME Should this even be visible to callers? We should pick up
  * file events via watcher to refresh whenever we really need to. This should become default
  * visibility.
  *
  * @param monitor
  * @return
  */
 public IStatus refresh(IProgressMonitor monitor) {
   SubMonitor sub = SubMonitor.convert(monitor, 100);
   try {
     return refresh(true, null, sub.newChild(100));
   } finally {
     sub.done();
   }
 }
Exemple #14
0
 /**
  * Scans the specified source {@linkplain CompilationUnit} for contributed API javadoc tags. Tags
  * on methods will have unresolved signatures.
  *
  * @param source the source file to scan for tags
  * @param description the API description to annotate with any new tag rules found
  * @param container optional class file container containing the class file for the given source
  *     that can be used to resolve method signatures if required (for tags on methods). If not
  *     provided (<code>null</code>), method signatures will be unresolved.
  * @param options a map of Java compiler options to use when creating the AST to scan or <code>
  *     null</code> if default options should be used
  * @param monitor
  * @throws CoreException
  */
 public void scan(
     CompilationUnit source,
     IApiDescription description,
     IApiTypeContainer container,
     Map options,
     IProgressMonitor monitor)
     throws CoreException {
   SubMonitor localmonitor = SubMonitor.convert(monitor, 2);
   ASTParser parser = ASTParser.newParser(AST.JLS3);
   InputStream inputStream = null;
   try {
     inputStream = source.getInputStream();
     parser.setSource(
         Util.getInputStreamAsCharArray(
             inputStream, -1, System.getProperty("file.encoding"))); // $NON-NLS-1$
   } catch (FileNotFoundException e) {
     throw new CoreException(
         new Status(
             IStatus.ERROR,
             ApiPlugin.PLUGIN_ID,
             MessageFormat.format(
                 "Compilation unit source not found: {0}", new String[] {source.getName()}),
             e)); //$NON-NLS-1$
   } catch (IOException e) {
     if (DEBUG) {
       System.err.println(source.getName());
     }
     throw new CoreException(
         new Status(
             IStatus.ERROR,
             ApiPlugin.PLUGIN_ID,
             MessageFormat.format(
                 "Error reading compilation unit: {0}", new String[] {source.getName()}),
             e)); //$NON-NLS-1$
   } finally {
     if (inputStream != null) {
       try {
         inputStream.close();
       } catch (IOException e) {
         ApiPlugin.log(e);
       }
     }
   }
   Util.updateMonitor(localmonitor);
   Map loptions = options;
   if (loptions == null) {
     loptions = JavaCore.getOptions();
   }
   loptions.put(JavaCore.COMPILER_DOC_COMMENT_SUPPORT, JavaCore.ENABLED);
   parser.setCompilerOptions(loptions);
   org.eclipse.jdt.core.dom.CompilationUnit cunit =
       (org.eclipse.jdt.core.dom.CompilationUnit) parser.createAST(localmonitor.newChild(1));
   Visitor visitor = new Visitor(description, container);
   cunit.accept(visitor);
   if (visitor.getException() != null) {
     throw visitor.getException();
   }
 }
  private void create_device_project(
      final IPath projectPath,
      final String deviceType,
      final String lang,
      final String codegenId,
      final String templateId,
      final IProgressMonitor progressMonitor)
      throws CoreException {
    final SubMonitor monitor = SubMonitor.convert(progressMonitor, 1);

    final String projectName = projectPath.lastSegment();
    final java.net.URI locationURI = projectPath.toFile().toURI();

    final ICodeGeneratorDescriptor code_gen = findCodeGen(lang, codegenId);

    final ITemplateDesc template = findCodeGenTemplate(templateId, code_gen);

    // Create the implementation
    final SoftPkg spd = SpdFactory.eINSTANCE.createSoftPkg();
    final Implementation impl = SpdFactory.eINSTANCE.createImplementation();
    spd.getImplementation().add(impl);
    final ImplementationSettings settings = CodegenFactory.eINSTANCE.createImplementationSettings();

    initializeSoftPkg(lang, projectName, code_gen, template, spd, impl, settings);

    final WorkspaceModifyOperation operation =
        new WorkspaceModifyOperation() {

          @Override
          protected void execute(final IProgressMonitor progress_monitor)
              throws CoreException, InvocationTargetException, InterruptedException {
            final SubMonitor monitor = SubMonitor.convert(progress_monitor, 2);

            final IProject project =
                DeviceProjectCreator.createEmptyProject(
                    projectName, locationURI, monitor.newChild(1));

            DeviceProjectCreator.createDeviceFiles(
                project, spd.getName(), spd.getId(), "", deviceType, false, monitor.newChild(1));

            ProjectCreator.addImplementation(
                project, spd.getName(), impl, settings, monitor.newChild(1));

            // Setup the IDL Path
            ResourceUtils.createIdlLibraryResource(project, monitor.newChild(1));
          }
        };
    try {
      operation.run(monitor.newChild(1));
    } catch (final InvocationTargetException e) {
      throw new CoreException(
          new Status(
              IStatus.ERROR, CodegeneratorApplication.PLUGIN_ID, "Failure creating project", e));
    } catch (final InterruptedException e) {
      // pass
    }
  }
Exemple #16
0
 private void notifyParticipants(IProgressMonitor monitor) {
   SubMonitor sub =
       SubMonitor.convert(monitor, "Notifying build participants", fParticipants.length);
   for (int i = 0; i < fParticipants.length; i++) {
     fParticipants[i].aboutToBuild(fRubyProject);
     sub.worked(1);
   }
   sub.done();
 }
  /**
   * Finds available WSO2 features in current profile and search for updates to them in WSO2 p2
   * repository for updates.
   *
   * @param monitor
   * @throws Exception
   */
  public void checkForAvailableUpdates(IProgressMonitor monitor) throws Exception {
    if (monitor == null) {
      monitor = new NullProgressMonitor();
    }
    SubMonitor progress = SubMonitor.convert(monitor, Messages.UpdateManager_18, 6);

    // get all available IUs in update repository
    IMetadataRepository metadataRepo =
        metadataRepoManager.loadRepository(getDevStudioUpdateSite(), progress.newChild(1));
    IQuery<IInstallableUnit> allIUQuery = QueryUtil.createIUAnyQuery();
    IQueryResult<IInstallableUnit> allIUQueryResult =
        metadataRepo.query(allIUQuery, progress.newChild(1));

    // read artifact repository for updates
    IArtifactRepository artifactRepo =
        artifactRepoManager.loadRepository(getDevStudioUpdateSite(), progress.newChild(1));

    // read meta-data of all available features
    Map<String, EnhancedFeature> allFeaturesInUpdateRepo =
        loadWSO2FeaturesInRepo(artifactRepo, allIUQueryResult, progress.newChild(1));

    // get all installed wso2 features
    Collection<IInstallableUnit> installedWSO2Features =
        getInstalledWSO2Features(progress.newChild(1));

    installedWSO2FeaturesMap = new HashMap<String, IInstallableUnit>();
    for (IInstallableUnit iInstallableUnit : installedWSO2Features) {
      installedWSO2FeaturesMap.put(iInstallableUnit.getId(), iInstallableUnit);
    }

    if (progress.isCanceled()) {
      throw new OperationCanceledException();
    }

    URI[] repos = new URI[] {getDevStudioUpdateSite()};
    updateOperation = new UpdateOperation(session, installedWSO2Features);
    updateOperation.getProvisioningContext().setArtifactRepositories(repos);
    updateOperation.getProvisioningContext().setMetadataRepositories(repos);

    // resolve update operation
    IStatus status = updateOperation.resolveModal(progress.newChild(1));
    // user cancelled the job while resolving
    if (status.getSeverity() == IStatus.CANCEL || progress.isCanceled()) {
      throw new OperationCanceledException();
    }
    // there is nothing to update
    if (status.getCode() == UpdateOperation.STATUS_NOTHING_TO_UPDATE) {
      featuresWithPossibleUpdates = new HashMap<String, EnhancedFeature>();
      log.info(Messages.UpdateManager_19);
    } else if (status.getSeverity() == IStatus.ERROR) { // resolution errors
      // something wrong with the updates
      log.info(Messages.UpdateManager_20);
    } else {
      // good to proceed installing updates
      setPossibleUpdates(updateOperation.getPossibleUpdates(), allFeaturesInUpdateRepo);
    }
  }
 private void buildEnding(List<IBuildParticipant> participants, IProgressMonitor monitor) {
   if (participants == null) {
     return;
   }
   SubMonitor sub = SubMonitor.convert(monitor, participants.size());
   for (IBuildParticipant participant : participants) {
     participant.buildEnding(sub.newChild(1));
   }
   sub.done();
 }
  private Collection<IInstallableUnit> getInstalledWSO2Features(IProgressMonitor monitor)
      throws OperationCanceledException {
    SubMonitor progress = SubMonitor.convert(monitor, Messages.UpdateManager_23, 2);

    OperationFactory operationFactory = new OperationFactory();
    IQueryResult<IInstallableUnit> queryResult =
        operationFactory.listInstalledElements(true, progress.newChild(1));
    return filterInstallableUnits(
        WSO2_FEATURE_PREFIX, FEATURE_GROUP_IU_ID_SFX, queryResult, progress.newChild(1));
  }
  /**
   * FIXME This is a holy hell of a mess! We map from IFiles to IFileStores, then filter on that,
   * then map back! Can't we make the IIndexFilterParticipants also operate on IFiles? It seems like
   * the only impl does anyways.
   *
   * @return
   */
  private Collection<IFile> filterFiles(Collection<IFile> files, IProgressMonitor monitor) {
    SubMonitor sub = SubMonitor.convert(monitor, 100);
    // First filter out files that don't exist, are derived, or are team-private
    files =
        CollectionsUtil.filter(
            files,
            new IFilter<IFile>() {
              public boolean include(IFile item) {
                return !ResourceUtil.shouldIgnore(item);
              }
            });
    sub.worked(10);

    // Next map IFiles to IFileStores for filter participants' sake
    Set<IFileStore> fileStores =
        new HashSet<IFileStore>(
            CollectionsUtil.map(
                files,
                new IMap<IFile, IFileStore>() {

                  public IFileStore map(IFile item) {
                    IPath path = item.getLocation();
                    return (path == null) ? null : EFS.getLocalFileSystem().getStore(path);
                  }
                }));
    sub.worked(15);

    if (!CollectionsUtil.isEmpty(fileStores)) {
      // Now let filters run
      IndexManager manager = getIndexManager();
      if (manager != null) {
        for (IIndexFilterParticipant filterParticipant : manager.getFilterParticipants()) {
          fileStores = filterParticipant.applyFilter(fileStores);
        }
      }
      sub.worked(60);

      // Now we need to map back to IFiles again. UGH!
      return CollectionsUtil.map(
          fileStores,
          new IMap<IFileStore, IFile>() {

            public IFile map(IFileStore fileStore) {
              IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
              IFile[] iFiles = workspaceRoot.findFilesForLocationURI(fileStore.toURI());
              if (ArrayUtil.isEmpty(iFiles)) {
                return null;
              }
              return iFiles[0];
            }
          });
    }

    return files;
  }
 public void findAllReferences(
     IQueryData queryData,
     ILocalResourceAccess localResourceAccess,
     final IAcceptor<IReferenceDescription> acceptor,
     IProgressMonitor monitor) {
   final SubMonitor subMonitor = SubMonitor.convert(monitor, 2);
   if (!queryData.getTargetURIs().isEmpty()) {
     findLocalReferences(queryData, localResourceAccess, acceptor, subMonitor.newChild(1));
     findIndexedReferences(queryData, acceptor, subMonitor.newChild(1));
   }
 }
 private void buildStarting(
     List<IBuildParticipant> participants, int kind, IProgressMonitor monitor) {
   if (CollectionsUtil.isEmpty(participants)) {
     return;
   }
   SubMonitor sub = SubMonitor.convert(monitor, participants.size());
   for (IBuildParticipant participant : participants) {
     participant.buildStarting(getProjectHandle(), kind, sub.newChild(1));
   }
   sub.done();
 }
Exemple #23
0
  /**
   * @param monitor the progress monitor to use for reporting progress to the user. It is the
   *     caller's responsibility to call done() on the given monitor. Accepts null, indicating that
   *     no progress should be reported and that the operation cannot be cancelled.
   */
  protected void fullBuild(final IProgressMonitor monitor, boolean isRecoveryBuild)
      throws CoreException {
    SubMonitor progress = SubMonitor.convert(monitor, 10);

    IProject project = getProject();
    ToBeBuilt toBeBuilt =
        isRecoveryBuild
            ? toBeBuiltComputer.updateProjectNewResourcesOnly(project, progress.newChild(2))
            : toBeBuiltComputer.updateProject(project, progress.newChild(2));
    doBuild(toBeBuilt, progress.newChild(8), isRecoveryBuild ? BuildType.RECOVERY : BuildType.FULL);
  }
 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);
   }
 }
  private void deleteFile(
      BuildContext context, List<IBuildParticipant> participants, IProgressMonitor monitor) {
    if (CollectionsUtil.isEmpty(participants)) {
      return;
    }

    SubMonitor sub = SubMonitor.convert(monitor, participants.size());
    for (IBuildParticipant participant : participants) {
      participant.deleteFile(context, sub.newChild(1));
    }
    sub.done();
  }
 /**
  * Creates a new REDHAWK component project without any files. Should be invoked in the context of
  * a {@link org.eclipse.ui.actions.WorkspaceModifyOperation WorkspaceModifyOperation}.
  *
  * @param projectName The project name
  * @param projectLocation the location on disk to create the project
  * @param monitor the progress monitor to use for reporting progress to the user. It is the
  *     caller's responsibility to call done() on the given monitor. Accepts null, indicating that
  *     no progress should be reported and that the operation cannot be canceled.
  * @return The newly created project
  * @throws CoreException A problem occurs while creating the project
  */
 public static IProject createEmptyProject(
     final String projectName, final URI projectLocation, final IProgressMonitor monitor)
     throws CoreException {
   final SubMonitor progress = SubMonitor.convert(monitor, "Creating empty project", 2);
   final String[] additionalNatureIDs =
       new String[] {ScaComponentProjectNature.ID, "org.python.pydev.pythonNature"};
   final IProject project =
       ProjectCreator.createEmptyProject(
           projectName, projectLocation, additionalNatureIDs, progress.newChild(1));
   ProjectCreator.resetProject(project, progress.newChild(1));
   return project;
 }
  @Override
  public void build(final IBuildContext context, IProgressMonitor monitor) throws CoreException {
    if (!isEnabled(context)) {
      return;
    }

    final List<IResourceDescription.Delta> deltas = getRelevantDeltas(context);
    if (deltas.isEmpty()) {
      return;
    }

    StoppedTask task =
        Stopwatches.forTask(
            "org.eclipse.xtext.builder.BuilderParticipant.build(IBuildContext, IProgressMonitor)");
    try {
      task.start();

      // monitor handling
      if (monitor.isCanceled()) throw new OperationCanceledException();
      SubMonitor subMonitor =
          SubMonitor.convert(monitor, context.getBuildType() == BuildType.RECOVERY ? 5 : 3);

      EclipseResourceFileSystemAccess2 access = fileSystemAccessProvider.get();
      IProject builtProject = context.getBuiltProject();
      access.setProject(builtProject);
      Map<String, OutputConfiguration> outputConfigurations = getOutputConfigurations(context);
      refreshOutputFolders(context, outputConfigurations, subMonitor.newChild(1));
      if (subMonitor.isCanceled()) {
        throw new OperationCanceledException();
      }
      access.setOutputConfigurations(outputConfigurations);
      if (context.getBuildType() == BuildType.CLEAN
          || context.getBuildType() == BuildType.RECOVERY) {
        SubMonitor cleanMonitor =
            SubMonitor.convert(subMonitor.newChild(2), outputConfigurations.size());
        for (OutputConfiguration config : outputConfigurations.values()) {
          cleanOutput(context, config, access, cleanMonitor.newChild(1));
        }
        if (context.getBuildType() == BuildType.CLEAN) return;
      }
      Map<OutputConfiguration, Iterable<IMarker>> generatorMarkers =
          getGeneratorMarkers(builtProject, outputConfigurations.values());
      if (subMonitor.isCanceled()) {
        throw new OperationCanceledException();
      }
      doBuild(
          deltas, outputConfigurations, generatorMarkers, context, access, subMonitor.newChild(2));

    } finally {
      task.stop();
    }
  }
Exemple #28
0
 protected void refreshOutputFolders(
     IBuildContext ctx,
     Map<String, OutputConfiguration> outputConfigurations,
     IProgressMonitor monitor)
     throws CoreException {
   SubMonitor subMonitor = SubMonitor.convert(monitor, outputConfigurations.size());
   for (OutputConfiguration config : outputConfigurations.values()) {
     SubMonitor child = subMonitor.newChild(1);
     final IProject project = ctx.getBuiltProject();
     IFolder folder = project.getFolder(config.getOutputDirectory());
     folder.refreshLocal(IResource.DEPTH_INFINITE, child);
   }
 }
Exemple #29
0
 /**
  * @param monitor the progress monitor to use for reporting progress to the user. It is the
  *     <em>implementors</em> responsibility to call done() on the given monitor. Accepts null,
  *     indicating that no progress should be reported and that the operation cannot be cancelled.
  */
 @Override
 protected void clean(IProgressMonitor monitor) throws CoreException {
   SubMonitor progress = SubMonitor.convert(monitor, 10);
   try {
     ToBeBuilt toBeBuilt = toBeBuiltComputer.removeProject(getProject(), progress.newChild(2));
     if (monitor.isCanceled()) {
       throw new OperationCanceledException();
     }
     doClean(toBeBuilt, progress.newChild(8));
   } finally {
     if (monitor != null) monitor.done();
   }
 }
 public IStatus getArtifacts(IArtifactRequest[] requests, IProgressMonitor monitor) {
   SubMonitor subMonitor = SubMonitor.convert(monitor, requests.length);
   try {
     MultiStatus overallStatus =
         new MultiStatus(TestActivator.PI_PROV_TESTS, IStatus.OK, null, null);
     for (int i = 0; i < requests.length; i++) {
       overallStatus.add(getArtifact((ArtifactRequest) requests[i], subMonitor.newChild(1)));
     }
     return (monitor.isCanceled() ? Status.CANCEL_STATUS : overallStatus);
   } finally {
     subMonitor.done();
   }
 }