Added FlatProjectView. Used it to create an 'All Issues' project in pit-swing.

Solves issue #11: pit-swing: Add a default, "all-projects" view.
This commit is contained in:
Jonathan Bernard
2010-04-24 18:10:19 -05:00
parent f2f470ff2a
commit cd7f14cb2d
17 changed files with 330 additions and 63 deletions

View File

@ -0,0 +1,34 @@
package com.jdbernard.pit;
public class FlatProjectView extends Project {
public FlatProjectView(String name) { super(name); }
public Issue createNewIssue(Map options) {
throw new UnsupportedOperationException("The FlatProjectView is " +
"read-only.")
}
public Project createNewProject(String name) {
throw new UnsupportedOperationException("The FlatProjectView is " +
"read-only.")
}
public boolean delete() { return true };
public void eachIssue(Filter filter = null, Closure closure) {
def sorter = filter?.issueSorter ?: Filter.defaultIssueSorter
def gatherIssues
def gatheredIssues = []
gatherIssues = { project, f ->
project.eachIssue(f) { gatheredIssues << it };
project.eachProject(f) { gatherIssues(it, f) }
}
for (p in projects.values())
if (!filter || filter.accept(p))
gatherIssues(p, filter)
gatheredIssues.sort(sorter).each(closure)
}
}