blob: 844c9503a36e75d4890576ae9649f8c46774768a (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
/*******************************************************************************
* Copyright (c) 2003 - 2006 University Of British Columbia and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* University Of British Columbia - initial API and implementation
*******************************************************************************/
package org.eclipse.mylyn.tasks.core;
import java.util.HashSet;
import java.util.Set;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.NullProgressMonitor;
/**
* Collects QueryHits resulting from repository search.
*
* @author Shawn Minto
* @author Rob Elves (generalized from bugzilla)
* @author Steffen Pingel
* @since 2.0
*/
public class QueryHitCollector implements ITaskCollector {
public static final int MAX_HITS = 5000;
public static final String MAX_HITS_REACHED = "Max allowed number of hits returned exceeded. Some hits may not be displayed. Please narrow query scope.";
private final Set<AbstractTask> taskResults = new HashSet<AbstractTask>();
private final ITaskFactory taskFactory;
public QueryHitCollector(ITaskFactory taskFactory) {
this.taskFactory = taskFactory;
}
public void accept(AbstractTask task) {
if (task == null) {
throw new IllegalArgumentException();
}
if (taskResults.size() < MAX_HITS) {
taskResults.add(task);
}
}
public void accept(RepositoryTaskData taskData) throws CoreException {
if (taskData == null) {
throw new IllegalArgumentException();
}
AbstractTask task = taskFactory.createTask(taskData, new NullProgressMonitor());
if (taskResults.size() < MAX_HITS) {
taskResults.add(task);
}
}
public Set<AbstractTask> getTasks() {
return taskResults;
}
}
|