view com.redhat.thermostat.tools.eclipse.plugin/src/com/redhat/thermostat/tools/eclipse/plugin/ProjectFinder.java @ 136:31d0ab4467ad

Add an export wizard to export entire plugin Introduce an export wizard that can export the entire plugin projects into a Thermostat installation. Add 'tags' to projects to keep track of what the root project (to export) is. There's barely any feedback for the export process right now. Errors and issues are effectively ignored.
author Omair Majid <omajid@redhat.com>
date Thu, 05 Jun 2014 11:53:06 -0400
parents
children
line wrap: on
line source

package com.redhat.thermostat.tools.eclipse.plugin;

import java.util.ArrayList;
import java.util.List;

import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.ResourcesPlugin;

public class ProjectFinder {

    // TODO replace with j.u.f.Predicate
    public static interface Criteria {
        public boolean matches(IProject project);
    }

    public List<IProject> find(Criteria criteria) {
        List<IProject> result = new ArrayList<>();

        IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
        for (IProject project : projects) {
           if (criteria.matches(project)) {
               result.add(project);
           }
        }
        return result;
    }

    public List<String> findProjectNames(Criteria criteria) {
        List<String> result = new ArrayList<>();

        IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
        for (IProject project : projects) {
           if (criteria.matches(project)) {
               result.add(project.getName());
           }
        }
        return result;
    }
}