01: package net.refractions.udig.style.sld.editor.internal;
02:
03: import org.eclipse.jface.resource.JFaceResources;
04: import org.eclipse.jface.viewers.IFontProvider;
05: import org.eclipse.jface.viewers.ITreeContentProvider;
06: import org.eclipse.swt.graphics.Font;
07:
08: /**
09: * This PreferenceBoldLabelProvider will bold those elements which really match
10: * the search contents
11: */
12: public class EditorBoldLabelProvider extends EditorPageLabelProvider
13: implements IFontProvider {
14:
15: private FilteredComboTree comboTree;
16:
17: public EditorBoldLabelProvider(FilteredComboTree comboTree) {
18: this .comboTree = comboTree;
19: }
20:
21: /**
22: * Using "false" to construct the filter so that this filter can filter
23: * supernodes of a matching node
24: */
25: PatternItemFilter filterForBoldElements = new PatternItemFilter(
26: false);
27:
28: public Font getFont(Object element) {
29:
30: String filterText = comboTree.getFilterControlText();
31:
32: // Do nothing if it's empty string
33: if (!(filterText.equals("") || filterText.equals(comboTree.getInitialText()))) {//$NON-NLS-1$
34:
35: boolean initial = comboTree.getInitialText() != null
36: && filterText.equals(comboTree.getInitialText());
37: if (initial) {
38: filterForBoldElements.setPattern(null);
39: } else {
40: filterForBoldElements.setPattern(filterText);
41: }
42:
43: ITreeContentProvider contentProvider = (ITreeContentProvider) comboTree
44: .getViewer().getContentProvider();
45: Object parent = contentProvider.getParent(element);
46:
47: if (filterForBoldElements.select(comboTree.getViewer(),
48: parent, element)) {
49: return JFaceResources.getFontRegistry().getBold(
50: JFaceResources.DIALOG_FONT);
51: }
52: }
53: return null;
54: }
55:
56: }
|