blob: 2d54c69222f7ffa10e2f4bf37ea951dc6628f77f (
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
|
/*******************************************************************************
* 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:
* Willian Mitsuda - initial API and implementation
*******************************************************************************/
package org.eclipse.mylyn.internal.tasks.ui.search;
import org.eclipse.core.runtime.IAdapterFactory;
import org.eclipse.mylyn.internal.tasks.core.AbstractTaskContainer;
import org.eclipse.mylyn.internal.tasks.ui.TaskSearchPage;
import org.eclipse.mylyn.tasks.core.IRepositoryElement;
import org.eclipse.search.ui.ISearchPageScoreComputer;
/**
* Implements a {@link IAdapterFactory} for {@link ISearchPageScoreComputer}s which ranks {@link AbstractTaskContainer}s
* high for the task search page
*
* @author Willian Mitsuda
*/
public class SearchScoreComputerAdapterFactory implements IAdapterFactory {
private final ISearchPageScoreComputer computer = new ISearchPageScoreComputer() {
public int computeScore(String pageId, Object input) {
if (!TaskSearchPage.ID.equals(pageId)) {
return ISearchPageScoreComputer.UNKNOWN;
}
if (input instanceof IRepositoryElement) {
return 100;
}
return ISearchPageScoreComputer.LOWEST;
}
};
@SuppressWarnings("unchecked")
public Object getAdapter(Object adaptableObject, Class adapterType) {
if (ISearchPageScoreComputer.class.equals(adapterType)) {
return computer;
}
return null;
}
@SuppressWarnings("unchecked")
public Class[] getAdapterList() {
return new Class[] { ISearchPageScoreComputer.class };
}
}
|