Bug 77871 [GlobalActions] (Re)Build Project should track resources itself
bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/actions/BuildSetAction.java
for (int i = 0; i < selection.length; i++) {
            if (selection[i] instanceof IResource) {
                projects.add(((IResource) selection[i]).getProject());
            } else if (selection[i] instanceof IAdaptable) {
                IAdaptable adaptable = (IAdaptable) selection[i];
                IResource resource = (IResource) adaptable
                        .getAdapter(IResource.class);
                if (resource != null)
                    projects.add(resource.getProject());
            }
        }
        return (IProject[]) projects.toArray(new IProject[projects.size()]);
    }
    /**
     * Creates a new action that builds the provided working set when run
     */
    public BuildSetAction(IWorkingSet set, IWorkbenchWindow window,
            IActionBarConfigurer actionBars) {
        super(set == null ? "" : set.getName(), AS_RADIO_BUTTON); 
        this.window = window;
        this.actionBars = actionBars;
        this.workingSet = set;
    }
    /**
     * Returns the working set that this instance is building
     */
    public IWorkingSet getWorkingSet() {
        return workingSet;
    }
    public void run() {