KickJava   Java API By Example, From Geeks To Geeks.

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


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 import org.eclipse.ui.views.IViewCategory;
16 import org.eclipse.ui.views.IViewDescriptor;
17
18 /**
19  * A class that handles filtering view node items based on a supplied
20  * matching string.
21  *
22  * @since 3.2
23  *
24  */

25 public class ViewPatternFilter extends PatternFilter {
26
27     /**
28      * Create a new instance of a ViewPatternFilter
29      * @param isMatchItem
30      */

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

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

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