1 package net.sourceforge.phpeclipse.resourcesview;
3 import org.eclipse.jface.action.IMenuManager;
4 import org.eclipse.jface.action.Separator;
5 import org.eclipse.jface.viewers.IStructuredSelection;
6 import org.eclipse.jface.viewers.TreeViewer;
7 import org.eclipse.swt.graphics.Image;
8 import org.eclipse.swt.widgets.Composite;
9 import org.eclipse.swt.widgets.Shell;
10 import org.eclipse.ui.IMemento;
11 import org.eclipse.ui.IPropertyListener;
12 import org.eclipse.ui.IViewSite;
13 import org.eclipse.ui.IWorkbenchActionConstants;
14 import org.eclipse.ui.IWorkbenchPartSite;
15 import org.eclipse.ui.IWorkingSet;
16 import org.eclipse.ui.PartInitException;
17 import org.eclipse.ui.actions.ActionContext;
18 import org.eclipse.ui.actions.ActionGroup;
19 import org.eclipse.ui.actions.RefreshAction;
20 import org.eclipse.ui.dialogs.PropertyDialogAction;
21 import org.eclipse.ui.internal.dialogs.ResourceSorter;
22 import org.eclipse.ui.views.framelist.FrameList;
23 import org.eclipse.ui.views.navigator.IResourceNavigator;
24 import org.eclipse.ui.views.navigator.OpenActionGroup;
25 import org.eclipse.ui.views.navigator.RefactorActionGroup;
26 import org.eclipse.ui.views.navigator.ResourcePatternFilter;
28 public class MainActionGroup extends ActionGroup {
30 private OpenActionGroup openActionGroup;
31 private RefactorActionGroup refactorActionGroup;
32 private PropertyDialogAction propertyDialogAction ;
33 private RefreshAction refreshAction ;
35 public MainActionGroup(PHPResourcesView phpResourcesView) {
36 ResourceNavigatorAdapter adapter = new ResourceNavigatorAdapter(phpResourcesView) ;
37 this.openActionGroup = new OpenActionGroup(adapter);
38 this.refactorActionGroup = new RefactorActionGroup(adapter);
39 Shell shell = phpResourcesView.getSite().getShell();
40 propertyDialogAction = new PropertyDialogAction(shell, phpResourcesView.getViewer());
41 refreshAction = new RefreshAction(shell) ;
44 public void fillContextMenu(IMenuManager menu) {
45 this.openActionGroup.fillContextMenu(menu);
46 menu.add(new Separator());
47 this.refactorActionGroup.fillContextMenu(menu);
48 menu.add(new Separator());
49 menu.add(refreshAction) ;
50 menu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
51 menu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS + "-end")); //$NON-NLS-1$
52 menu.add(propertyDialogAction) ;
56 public void setContext(ActionContext actionContext) {
57 this.openActionGroup.setContext(actionContext);
58 this.refactorActionGroup.setContext(actionContext);
61 public void runDefaultAction(IStructuredSelection selection) {
62 this.openActionGroup.runDefaultAction(selection);
65 class ResourceNavigatorAdapter implements IResourceNavigator {
66 PHPResourcesView phpResourcesView;
67 ResourceNavigatorAdapter(PHPResourcesView phpResourcesView) {
68 this.phpResourcesView = phpResourcesView;
71 public FrameList getFrameList() {
75 public ResourcePatternFilter getPatternFilter() {
79 public ResourceSorter getSorter() {
83 public TreeViewer getViewer() {
84 return phpResourcesView.getViewer();
87 public IWorkingSet getWorkingSet() {
91 public void setFiltersPreference(String[] patterns) {
94 public void setSorter(ResourceSorter sorter) {
97 public void setWorkingSet(IWorkingSet workingSet) {
100 public IViewSite getViewSite() {
101 return phpResourcesView.getViewSite();
104 public void init(IViewSite arg0, IMemento arg1) throws PartInitException {
107 public void init(IViewSite arg0) throws PartInitException {
110 public void saveState(IMemento arg0) {
113 public void addPropertyListener(IPropertyListener arg0) {
116 public void createPartControl(Composite arg0) {
119 public void dispose() {
122 public IWorkbenchPartSite getSite() {
123 return phpResourcesView.getSite();
126 public String getTitle() {
127 return phpResourcesView.getTitle();
130 public Image getTitleImage() {
131 return phpResourcesView.getTitleImage();
134 public String getTitleToolTip() {
135 return phpResourcesView.getTitleToolTip();
138 public void removePropertyListener(IPropertyListener arg0) {
141 public void setFocus() {
144 public Object getAdapter(Class arg0) {
145 return phpResourcesView.getAdapter(arg0);