1 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 ACTION_ID= "MatchFilterSelectionAction"; 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 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 (dialog.getLimit())); 61 } 62 } 63 } 64 65 } 66 | Popular Tags |