Search in sources :

Example 1 with ProjectOrder

use of org.eclipse.core.resources.IWorkspace.ProjectOrder in project ow by vtst.

the class ProjectOrderManager method update.

public synchronized State update() throws CoreException {
    State localState = this.state;
    if (localState != null && !localState.dirty)
        return localState;
    OwJsDev.log("Computing project order");
    IWorkspace workspace = ResourcesPlugin.getWorkspace();
    IProject[] projects = workspace.getRoot().getProjects();
    ArrayList<IProject> projectsWithNature = new ArrayList<IProject>(projects.length);
    for (IProject project : projects) {
        if (project.isOpen() && project.hasNature(ClosureNature.NATURE_ID)) {
            projectsWithNature.add(project);
        }
    }
    ProjectOrder order = workspace.computeProjectOrder(projectsWithNature.toArray(projects));
    HashMap<IProject, Integer> projectToIndex = new HashMap<IProject, Integer>();
    for (int i = 0; i < order.projects.length; ++i) {
        projectToIndex.put(order.projects[i], i);
    }
    localState = new State(projectToIndex);
    this.state = localState;
    return localState;
}
Also used : HashMap(java.util.HashMap) IWorkspace(org.eclipse.core.resources.IWorkspace) ArrayList(java.util.ArrayList) ProjectOrder(org.eclipse.core.resources.IWorkspace.ProjectOrder) IProject(org.eclipse.core.resources.IProject)

Example 2 with ProjectOrder

use of org.eclipse.core.resources.IWorkspace.ProjectOrder in project xtext-eclipse by eclipse.

the class JdtToBeBuiltComputer method updateProject.

@Override
public void updateProject(ToBeBuilt toBeBuilt, IProject project, IProgressMonitor monitor) throws CoreException {
    SubMonitor progress = SubMonitor.convert(monitor, 2);
    if (progress.isCanceled()) {
        throw new OperationCanceledException();
    }
    if (!project.isAccessible())
        return;
    IJavaProject javaProject = JavaCore.create(project);
    if (javaProject.exists()) {
        IPackageFragmentRoot[] roots = javaProject.getPackageFragmentRoots();
        progress.setWorkRemaining(roots.length);
        final Map<String, Long> updated = Maps.newHashMap();
        ProjectOrder orderedProjects = workspace.computeProjectOrder(workspace.getRoot().getProjects());
        for (final IPackageFragmentRoot root : roots) {
            if (progress.isCanceled())
                throw new OperationCanceledException();
            if (shouldHandle(root) && !isBuiltByUpstream(root, project, orderedProjects.projects)) {
                Map<URI, IStorage> rootData = jdtUriMapperExtension.getAllEntries(root);
                for (Map.Entry<URI, IStorage> e : rootData.entrySet()) if (uriValidator.canBuild(e.getKey(), e.getValue())) {
                    toBeBuilt.getToBeDeleted().add(e.getKey());
                    toBeBuilt.getToBeUpdated().add(e.getKey());
                }
            }
            progress.worked(1);
        }
        synchronized (modificationStampCache) {
            modificationStampCache.projectToModificationStamp.putAll(updated);
        }
    }
}
Also used : OperationCanceledException(org.eclipse.core.runtime.OperationCanceledException) SubMonitor(org.eclipse.core.runtime.SubMonitor) IStorage(org.eclipse.core.resources.IStorage) URI(org.eclipse.emf.common.util.URI) IPackageFragmentRoot(org.eclipse.jdt.core.IPackageFragmentRoot) IJavaProject(org.eclipse.jdt.core.IJavaProject) ProjectOrder(org.eclipse.core.resources.IWorkspace.ProjectOrder) Map(java.util.Map)

Aggregations

ProjectOrder (org.eclipse.core.resources.IWorkspace.ProjectOrder)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 IProject (org.eclipse.core.resources.IProject)1 IStorage (org.eclipse.core.resources.IStorage)1 IWorkspace (org.eclipse.core.resources.IWorkspace)1 OperationCanceledException (org.eclipse.core.runtime.OperationCanceledException)1 SubMonitor (org.eclipse.core.runtime.SubMonitor)1 URI (org.eclipse.emf.common.util.URI)1 IJavaProject (org.eclipse.jdt.core.IJavaProject)1 IPackageFragmentRoot (org.eclipse.jdt.core.IPackageFragmentRoot)1