Package org.eclipse.core.runtime

Examples of org.eclipse.core.runtime.SubMonitor


import org.evolizer.ontology.java.builder.model.CompilationUnitVisitor;
import org.evolizer.ontology.java.builder.model.JavaOntModel;

public class ProjectAnalyzer {
  public void performFullAnalysis(IJavaProject javaProject, IProgressMonitor monitor) {
    SubMonitor subMonitor = SubMonitor.convert(monitor);
    subMonitor.setTaskName("Performing full analysis of " + javaProject.getElementName());
   
    try {
      IPackageFragment[] packageFragments = javaProject.getPackageFragments();
     
      subMonitor.setWorkRemaining(packageFragments.length);
     
      for(IPackageFragment packageFragment : packageFragments) {
        if(packageFragment.getKind() == IPackageFragmentRoot.K_SOURCE && packageFragment.containsJavaResources()) {
          processPackage(packageFragment, subMonitor.newChild(1));
        }
      }
    } catch(JavaModelException jmex) {
      throw new EvolizerRuntimeException("Error while processing Java project. " + jmex.getMessage(), jmex); // TODO Build exception?
    }
View Full Code Here


  public void performDeltaAnalysis(IResourceDelta delta, IProgressMonitor monitor) {
   
  }

  private void processPackage(IPackageFragment packageFragment, IProgressMonitor monitor) {
    SubMonitor subMonitor = SubMonitor.convert(monitor);
    subMonitor.setTaskName("Processing " + packageFragment.getElementName());
   
    try {
      ICompilationUnit[] compilationUnits = packageFragment.getCompilationUnits();
     
      subMonitor.setWorkRemaining(compilationUnits.length);
     
      for (ICompilationUnit compilationUnit : compilationUnits) {
        processCompilationUnit(compilationUnit, packageFragment.getElementName(), subMonitor.newChild(1));
      }
    } catch(JavaModelException jmex) {
      throw new EvolizerRuntimeException("Error while processing package '" + packageFragment.getElementName() + "'. " + jmex.getMessage(), jmex); // TODO Build exception?
    }
  }
View Full Code Here

      throw new EvolizerRuntimeException("Error while processing package '" + packageFragment.getElementName() + "'. " + jmex.getMessage(), jmex); // TODO Build exception?
    }
  }

  private void processCompilationUnit(ICompilationUnit compilationUnit, String packageName, IProgressMonitor monitor) {
    SubMonitor subMonitor = SubMonitor.convert(monitor, 100);
    subMonitor.setTaskName("Parsing " + compilationUnit.getElementName());
   
    ASTParser lParser = ASTParser.newParser(AST.JLS3); // up to J2SE 1.5
    lParser.setSource(compilationUnit);
    lParser.setResolveBindings(true);
   
    CompilationUnit cu = (CompilationUnit) lParser.createAST(subMonitor.newChild(60));
    cu.accept(new CompilationUnitVisitor(compilationUnit, packageName, modelOf(compilationUnit.getJavaProject())));
    subMonitor.worked(40);
  }
View Full Code Here

  }

  public static void applyTo(IJavaProject javaProject, IProgressMonitor monitor) {
    IProject theProject = javaProject.getProject();
   
    SubMonitor sub = SubMonitor.convert(monitor, 5);
    sub.beginTask("Adding " + NATURE_ID + " nature to project.", 5);
   
    try {
      IProjectDescription description = theProject.getDescription();
      String[] natures = description.getNatureIds();
      sub.worked(1);
     
      String[] newNatures = new String[natures.length + 1];
      System.arraycopy(natures, 0, newNatures, 0, natures.length);   
      newNatures[natures.length] = NATURE_ID;
      sub.worked(1);
     
      description.setNatureIds(newNatures);
      sub.worked(1);
     
      theProject.setDescription(description, sub.newChild(2));
    } catch(CoreException cex) {
      // should not happen
      throw new EvolizerRuntimeException("Unexpected error while applying nature to " + theProject.getName() +".", cex);
    }
  }
View Full Code Here

     * {@inheritDoc}
     */
    @Override
    protected IStatus run(IProgressMonitor monitor) {
        IStatus status = Status.OK_STATUS;
        SubMonitor progress = SubMonitor.convert(monitor, "Storing entities and associations", 100);

        try {
            // Always perform a schema update before storing the model
            progress.setTaskName("Checking database schema ...");
            IEvolizerSession session = EvolizerSessionHandler.getHandler().getCurrentSession(fDBUrl);
            if (session.isOpen()) {
                session.close();
                Properties properties = EvolizerSessionHandler.getHandler().getProperties(fDBUrl);
                EvolizerSessionHandler.getHandler().updateSchema(properties);
            }
            progress.worked(20);
            progress.setTaskName("Deleting existing models of this project ...");
            DAOModel queryModel= new DAOModel(fDBUrl);
            List<FamixModel> existingModels = queryModel.queryStoredModels(fFamixModel.getName());
            for (FamixModel famixModel : existingModels) {
                DAOModel modelToDelete = new DAOModel(fDBUrl, famixModel);
                modelToDelete.deleteModel();
            }
            progress.worked(20);
           
            DAOModel newDAOModel = new DAOModel(fDBUrl, fFamixModel);
            newDAOModel.store(progress.newChild(60));
        } catch (EvolizerRuntimeException ere) {
            sfLogger.error("Error storing FAMIX" , ere);
        } catch (EvolizerException ee) {
            sfLogger.error("Error storing FAMIX" , ee);
        } finally {
View Full Code Here

     * {@inheritDoc}
     */
    @Override
    protected IStatus run(IProgressMonitor monitor) {
        IStatus status = Status.OK_STATUS;
        SubMonitor progress = SubMonitor.convert(monitor, "Process selected items", 100);
        try {
            final ProjectParser projectParser = new ProjectParser(fSelectedJavaElements);
            status = projectParser.parse(progress.newChild(70));

            // process unresolved method calls
            if ((projectParser.getModel() != null) && (status.getSeverity() == IStatus.OK)) {
                UnresolvedInvocationHandler unresolvedInvocationHandler =
                        new UnresolvedInvocationHandler(projectParser.getModel(), projectParser
                                .getUnresolvedCalls());
                status = unresolvedInvocationHandler.process(progress.newChild(20));
                if (status.getSeverity() == IStatus.OK) {
                    status = unresolvedInvocationHandler.addInvocations(progress.newChild(10));
                }
                if (status.getSeverity() == IStatus.OK) {
                    FamixImporterPlugin.getDefault().setUnresolvedInvocationHandler(
                            unresolvedInvocationHandler);
                    FamixImporterPlugin.getDefault().setParser(projectParser);
View Full Code Here

   *      java.util.Map, org.eclipse.core.runtime.IProgressMonitor)
   */ 
  @Override @SuppressWarnings("rawtypes")
  protected IProject[] build(int kind, Map args, IProgressMonitor monitor)
      throws CoreException {
    SubMonitor subMonitor = SubMonitor.convert(monitor);
   
    if (kind == FULL_BUILD) {
      fullBuild(subMonitor);
    } else {
      IResourceDelta delta = getDelta(getProject());
View Full Code Here

    }
  }

  private void fullBuild(final IProgressMonitor monitor)
      throws CoreException
    SubMonitor subMonitor = SubMonitor.convert(monitor, 1);
   
    IJavaProject theJavaProject = getJavaProject();
    if(theJavaProject != null) { // there will be no analysis if project is not an IJavaProject.
      fAnalyzer.performFullAnalysis(theJavaProject, subMonitor.newChild(1));
    }
  }
View Full Code Here

    }
  }
 
  // TODO build stuff should go elsewhere
  public static void waitForBuild(IProgressMonitor monitor) {
    SubMonitor subMonitor = SubMonitor.convert(monitor, 100);
   
    IJobManager jobManager = Job.getJobManager();
   
    // we need to ensure that the build has completed:
    // for some strange reason join-thread gets interrupted
    // once in a while (at least on windows).
    boolean buildHasntFinishedYet = true;
    while(buildHasntFinishedYet && !subMonitor.isCanceled()) {
      subMonitor.setWorkRemaining(100);
      try {
        jobManager.join(ResourcesPlugin.FAMILY_AUTO_BUILD, subMonitor.newChild(50));
        jobManager.join(ResourcesPlugin.FAMILY_MANUAL_BUILD, subMonitor.newChild(50));
       
        buildHasntFinishedYet = false;
      } catch (InterruptedException e) {
        buildHasntFinishedYet = true; //
      }
View Full Code Here

     */
    public IStatus parse(IProgressMonitor monitor) {
        fParsedElements = new HashSet<IJavaElement>();
        IStatus status = Status.OK_STATUS;

        SubMonitor progress = SubMonitor.convert(monitor, 100);
        progress.setTaskName("Parse selected items");
        SubMonitor loopProgress = progress.newChild(100).setWorkRemaining(getSelection().size());

        try {
            for (IJavaElement javaElement : getSelection()) {
                switch (javaElement.getElementType()) {
                    case IJavaElement.JAVA_PROJECT:
                        status = parseProject((IJavaProject) javaElement, loopProgress.newChild(1));
                        break;
                    case IJavaElement.PACKAGE_FRAGMENT:
                        status = parsePackageFragment((IPackageFragment) javaElement, loopProgress.newChild(1));
                        break;
                    case IJavaElement.COMPILATION_UNIT:
                        status = parseCompilationUnit((ICompilationUnit) javaElement, loopProgress.newChild(1));
                        break;
                    default:
                        sLogger.error("Parsing of this Java element is not supported.");
                        break;
                }
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.