KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ui > internal > dialogs > WizardPatternFilter


1 /*******************************************************************************
2  * Copyright (c) 2005, 2006 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.ui.internal.dialogs;
12
13 import org.eclipse.jface.viewers.Viewer;
14 import org.eclipse.ui.dialogs.PatternFilter;
15
16 /**
17  * A class that handles filtering wizard node items based on a supplied
18  * matching string.
19  *
20  * @since 3.2
21  *
22  */

23 public class WizardPatternFilter extends PatternFilter {
24
25     /**
26      * Create a new instance of a WizardPatternFilter
27      * @param isMatchItem
28      */

29     public WizardPatternFilter() {
30         super();
31     }
32
33     /*
34      * (non-Javadoc)
35      * @see org.eclipse.ui.internal.dialogs.PatternFilter#isElementSelectable(java.lang.Object)
36      */

37     public boolean isElementSelectable(Object JavaDoc element) {
38         return element instanceof WorkbenchWizardElement;
39     }
40
41     /*
42      * (non-Javadoc)
43      * @see org.eclipse.ui.internal.dialogs.PatternFilter#isElementMatch(org.eclipse.jface.viewers.Viewer, java.lang.Object)
44      */

45     protected boolean isLeafMatch(Viewer viewer, Object JavaDoc element) {
46         if (element instanceof WizardCollectionElement) {
47             return false;
48         }
49         
50         if (element instanceof WorkbenchWizardElement) {
51             WorkbenchWizardElement desc = (WorkbenchWizardElement) element;
52             String JavaDoc text = desc.getLabel();
53             if (wordMatches(text)) {
54                 return true;
55             }
56         }
57         return false;
58     }
59
60 }
61
Popular Tags