KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > ui > search > FilterAction


1 /*******************************************************************************
2  * Copyright (c) 2000, 2005 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.jdt.internal.ui.search;
12
13 import org.eclipse.jface.action.Action;
14 import org.eclipse.jface.action.IAction;
15
16
17 public class FilterAction extends Action {
18     private MatchFilter fFilter;
19     private JavaSearchResultPage fPage;
20     
21     public FilterAction(JavaSearchResultPage page, MatchFilter filter) {
22         super(filter.getActionLabel(), IAction.AS_CHECK_BOX);
23         fPage= page;
24         fFilter= filter;
25     }
26
27     public void run() {
28         if (fPage.hasMatchFilter(getFilter())) {
29             fPage.removeMatchFilter(fFilter);
30         } else {
31             fPage.addMatchFilter(fFilter);
32         }
33     }
34
35     public MatchFilter getFilter() {
36         return fFilter;
37     }
38
39     public void updateCheckState() {
40         setChecked(fPage.hasMatchFilter(getFilter()));
41     }
42 }
43
Popular Tags