1 11 12 package org.eclipse.search.ui.actions; 13 14 import org.eclipse.jface.action.GroupMarker; 15 import org.eclipse.jface.action.IMenuManager; 16 import org.eclipse.jface.action.MenuManager; 17 import org.eclipse.jface.action.Separator; 18 19 import org.eclipse.ui.IEditorPart; 20 import org.eclipse.ui.IWorkbenchActionConstants; 21 import org.eclipse.ui.actions.ActionGroup; 22 import org.eclipse.ui.texteditor.ITextEditorActionConstants; 23 24 import org.eclipse.search2.internal.ui.SearchMessages; 25 import org.eclipse.search2.internal.ui.text2.FindInFileActionDelegate; 26 import org.eclipse.search2.internal.ui.text2.FindInProjectActionDelegate; 27 import org.eclipse.search2.internal.ui.text2.FindInRecentScopeActionDelegate; 28 import org.eclipse.search2.internal.ui.text2.FindInWorkingSetActionDelegate; 29 import org.eclipse.search2.internal.ui.text2.FindInWorkspaceActionDelegate; 30 31 36 public class TextSearchGroup extends ActionGroup { 37 38 private static final String CTX_MENU_ID= "org.eclipse.search.text.ctxmenu"; 40 private String fAppendToGroup= ITextEditorActionConstants.GROUP_FIND; 41 private String fMenuText= SearchMessages.TextSearchGroup_submenu_text; 42 private FindInRecentScopeActionDelegate[] fActions; 43 44 49 public TextSearchGroup(IEditorPart editor) { 50 createActions(editor); 51 } 52 53 57 public void setMenuText(String text) { 58 fMenuText= text; 59 } 60 61 65 public void setAppendToGroup(String groupID) { 66 fAppendToGroup= groupID; 67 } 68 69 private void createActions(IEditorPart editor) { 70 fActions= new FindInRecentScopeActionDelegate[] { 71 new FindInWorkspaceActionDelegate(), new FindInProjectActionDelegate(), new FindInFileActionDelegate(), new FindInWorkingSetActionDelegate()}; 72 for (int i= 0; i < fActions.length; i++) { 73 FindInRecentScopeActionDelegate action= fActions[i]; 74 action.setActiveEditor(action, editor); 75 } 76 } 77 78 81 public void fillContextMenu(IMenuManager menu) { 82 MenuManager textSearchMM= new MenuManager(fMenuText, CTX_MENU_ID); 83 int i=0; 84 for (i= 0; i < fActions.length-1; i++) { 85 textSearchMM.add(fActions[i]); 86 } 87 textSearchMM.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS)); 88 textSearchMM.add(new Separator()); 89 textSearchMM.add(fActions[i]); 90 91 menu.appendToGroup(fAppendToGroup, textSearchMM); 92 } 93 } 94 | Popular Tags |