blob: 4de34d9ca1a3e2259b17f098b00def3441735401 (
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
|
/*******************************************************************************
* Copyright (c) 2004, 2008 Tasktop Technologies 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:
* Tasktop Technologies - initial API and implementation
*******************************************************************************/
package org.eclipse.mylyn.internal.tasks.ui.search;
import java.text.MessageFormat;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.search.internal.ui.SearchPluginImages;
import org.eclipse.search.ui.ISearchQuery;
import org.eclipse.search.ui.text.AbstractTextSearchResult;
import org.eclipse.search.ui.text.IEditorMatchAdapter;
import org.eclipse.search.ui.text.IFileMatchAdapter;
/**
* Captures the results of a task repository search.
*
* @author Rob Elves
* @see org.eclipse.search.ui.text.AbstractTextSearchResult
* @since 2.0
*/
public class RepositorySearchResult extends AbstractTextSearchResult {
/**
* The query producing this result.
*/
private final ISearchQuery repositoryQuery;
/**
* Constructor for <code>RepositorySearchResult</code> class.
*
* @param query
* <code>AbstractRepositorySearchQuery</code> that is producing this result.
*/
public RepositorySearchResult(ISearchQuery query) {
repositoryQuery = query;
}
@Override
public IEditorMatchAdapter getEditorMatchAdapter() {
return null;
}
/**
* This function always returns <code>null</code>, as the matches for this implementation of
* <code>AbstractTextSearchResult</code> never contain files.
*
* @see org.eclipse.search.ui.text.AbstractTextSearchResult#getFileMatchAdapter()
*/
@Override
public IFileMatchAdapter getFileMatchAdapter() {
return null;
}
public String getLabel() {
return getMatchCount() == 1 ? getSingularLabel() : getPluralLabel();
}
/**
* Get the singular label for the number of results
*
* @return The singular label
*/
protected String getSingularLabel() {
return Messages.RepositorySearchResult_Task_search_1_match;
}
/**
* Get the plural label for the number of results
*
* @return The plural label
*/
protected String getPluralLabel() {
return MessageFormat.format(Messages.RepositorySearchResult_Task_search_X_matches, getMatchCount());
}
public String getTooltip() {
return getLabel();
}
public ImageDescriptor getImageDescriptor() {
return SearchPluginImages.DESC_OBJ_TSEARCH_DPDN;
}
public ISearchQuery getQuery() {
return repositoryQuery;
}
}
|