1 11 package org.eclipse.jdt.internal.ui.navigator; 12 13 import org.eclipse.jface.action.IMenuManager; 14 15 import org.eclipse.ui.IActionBars; 16 import org.eclipse.ui.IViewPart; 17 import org.eclipse.ui.actions.ActionContext; 18 import org.eclipse.ui.navigator.CommonActionProvider; 19 import org.eclipse.ui.navigator.ICommonActionExtensionSite; 20 import org.eclipse.ui.navigator.ICommonViewerWorkbenchSite; 21 22 import org.eclipse.jdt.ui.actions.CCPActionGroup; 23 import org.eclipse.jdt.ui.actions.GenerateActionGroup; 24 import org.eclipse.jdt.ui.actions.JavaSearchActionGroup; 25 import org.eclipse.jdt.ui.actions.OpenViewActionGroup; 26 27 import org.eclipse.jdt.internal.ui.wizards.buildpaths.newsourcepage.GenerateBuildPathActionGroup; 28 29 42 public class JavaNavigatorActionProvider extends CommonActionProvider { 43 44 private OpenViewActionGroup fOpenViewGroup; 45 46 private CCPActionGroup fCCPGroup; 47 48 private JavaSearchActionGroup fSearchGroup; 49 50 private GenerateBuildPathActionGroup fBuildPathGroup; 51 52 private GenerateActionGroup fGenerateGroup; 53 54 private boolean fInViewPart= false; 55 56 public void fillActionBars(IActionBars actionBars) { 57 if (fInViewPart) { 58 fOpenViewGroup.fillActionBars(actionBars); 59 fCCPGroup.fillActionBars(actionBars); 60 fBuildPathGroup.fillActionBars(actionBars); 61 fGenerateGroup.fillActionBars(actionBars); 62 fSearchGroup.fillActionBars(actionBars); 63 } 64 } 65 66 public void fillContextMenu(IMenuManager menu) { 67 if (fInViewPart) { 68 fOpenViewGroup.fillContextMenu(menu); 69 fCCPGroup.fillContextMenu(menu); 70 fBuildPathGroup.fillContextMenu(menu); 71 fGenerateGroup.fillContextMenu(menu); 72 fSearchGroup.fillContextMenu(menu); 73 } 74 } 75 76 public void init(ICommonActionExtensionSite site) { 77 78 ICommonViewerWorkbenchSite workbenchSite= null; 79 if (site.getViewSite() instanceof ICommonViewerWorkbenchSite) 80 workbenchSite= (ICommonViewerWorkbenchSite) site.getViewSite(); 81 82 if (workbenchSite != null) { 83 if (workbenchSite.getPart() != null && workbenchSite.getPart() instanceof IViewPart) { 84 IViewPart viewPart= (IViewPart) workbenchSite.getPart(); 85 86 fOpenViewGroup= new OpenViewActionGroup(viewPart, site.getStructuredViewer()); 87 fOpenViewGroup.containsOpenPropertiesAction(false); 88 fCCPGroup= new CCPActionGroup(viewPart); 89 fGenerateGroup= new GenerateActionGroup(viewPart); 90 fSearchGroup= new JavaSearchActionGroup(viewPart); 91 fBuildPathGroup= new GenerateBuildPathActionGroup(viewPart); 92 93 fInViewPart= true; 94 } 95 } 96 } 97 98 public void setContext(ActionContext context) { 99 super.setContext(context); 100 if (fInViewPart) { 101 fOpenViewGroup.setContext(context); 102 fCCPGroup.setContext(context); 103 fGenerateGroup.setContext(context); 104 fSearchGroup.setContext(context); 105 fBuildPathGroup.setContext(context); 106 } 107 } 108 } 109 | Popular Tags |