01: /*******************************************************************************
02: * Copyright (c) 2005, 2006 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.ui.internal.dialogs;
11:
12: import org.eclipse.jface.viewers.Viewer;
13: import org.eclipse.ui.dialogs.PatternFilter;
14:
15: /**
16: * A class that handles filtering wizard node items based on a supplied
17: * matching string.
18: *
19: * @since 3.2
20: *
21: */
22: public class WizardPatternFilter extends PatternFilter {
23:
24: /**
25: * Create a new instance of a WizardPatternFilter
26: * @param isMatchItem
27: */
28: public WizardPatternFilter() {
29: super ();
30: }
31:
32: /*
33: * (non-Javadoc)
34: * @see org.eclipse.ui.internal.dialogs.PatternFilter#isElementSelectable(java.lang.Object)
35: */
36: public boolean isElementSelectable(Object element) {
37: return element instanceof WorkbenchWizardElement;
38: }
39:
40: /*
41: * (non-Javadoc)
42: * @see org.eclipse.ui.internal.dialogs.PatternFilter#isElementMatch(org.eclipse.jface.viewers.Viewer, java.lang.Object)
43: */
44: protected boolean isLeafMatch(Viewer viewer, Object element) {
45: if (element instanceof WizardCollectionElement) {
46: return false;
47: }
48:
49: if (element instanceof WorkbenchWizardElement) {
50: WorkbenchWizardElement desc = (WorkbenchWizardElement) element;
51: String text = desc.getLabel();
52: if (wordMatches(text)) {
53: return true;
54: }
55: }
56: return false;
57: }
58:
59: }
|