KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > search2 > internal > ui > MatchFilterSelectionAction


1 /*******************************************************************************
2  * Copyright (c) 2000, 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.search2.internal.ui;
12
13 import org.eclipse.swt.widgets.Shell;
14
15 import org.eclipse.jface.action.Action;
16 import org.eclipse.jface.window.Window;
17
18 import org.eclipse.search.ui.text.AbstractTextSearchResult;
19 import org.eclipse.search.ui.text.AbstractTextSearchViewPage;
20 import org.eclipse.search.ui.text.MatchFilter;
21
22 import org.eclipse.search.internal.ui.SearchPluginImages;
23
24
25 public class MatchFilterSelectionAction extends Action {
26     
27     public static final String JavaDoc ACTION_ID= "MatchFilterSelectionAction"; //$NON-NLS-1$
28

29     private AbstractTextSearchViewPage fPage;
30     
31     public MatchFilterSelectionAction(AbstractTextSearchViewPage page) {
32         super(SearchMessages.MatchFilterSelectionAction_label);
33         setId(ACTION_ID);
34         SearchPluginImages.setImageDescriptors(this, SearchPluginImages.T_LCL, SearchPluginImages.IMG_LCL_SEARCH_FILTER);
35         fPage= page;
36     }
37
38     public void run() {
39         Shell shell= fPage.getSite().getShell();
40         
41         AbstractTextSearchResult input= fPage.getInput();
42         if (input == null) {
43             return;
44         }
45         
46         MatchFilter[] allFilters= input.getAllMatchFilters();
47         MatchFilter[] checkedFilters= input.getActiveMatchFilters();
48         Integer JavaDoc limit= fPage.getElementLimit();
49         
50         boolean enableMatchFilterConfiguration= checkedFilters != null;
51         boolean enableLimitConfiguration= limit != null;
52         int elementLimit= limit != null ? limit.intValue() : -1;
53         
54         MatchFilterSelectionDialog dialog = new MatchFilterSelectionDialog(shell, enableMatchFilterConfiguration, allFilters, checkedFilters, enableLimitConfiguration, elementLimit);
55         if (dialog.open() == Window.OK) {
56             if (enableMatchFilterConfiguration) {
57                 input.setActiveMatchFilters(dialog.getMatchFilters());
58             }
59             if (enableLimitConfiguration) {
60                 fPage.setElementLimit(new Integer JavaDoc(dialog.getLimit()));
61             }
62         }
63     }
64
65 }
66
Popular Tags