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 //Impossible to compile with this, I don't know why
22 //import org.eclipse.ui.internal.dialogs.ResourceSorter;
23 import org.eclipse.ui.views.navigator.ResourceSorter;
24 import org.eclipse.ui.views.framelist.FrameList;
25 import org.eclipse.ui.views.navigator.IResourceNavigator;
26 import org.eclipse.ui.views.navigator.OpenActionGroup;
27 import org.eclipse.ui.views.navigator.RefactorActionGroup;
28 import org.eclipse.ui.views.navigator.ResourcePatternFilter;
30 public class MainActionGroup extends ActionGroup {
32 private OpenActionGroup openActionGroup;
33 private RefactorActionGroup refactorActionGroup;
34 private PropertyDialogAction propertyDialogAction ;
35 private RefreshAction refreshAction ;
37 public MainActionGroup(PHPResourcesView phpResourcesView) {
38 ResourceNavigatorAdapter adapter = new ResourceNavigatorAdapter(phpResourcesView) ;
39 this.openActionGroup = new OpenActionGroup(adapter);
40 this.refactorActionGroup = new RefactorActionGroup(adapter);
41 Shell shell = phpResourcesView.getSite().getShell();
42 propertyDialogAction = new PropertyDialogAction(shell, phpResourcesView.getViewer());
43 refreshAction = new RefreshAction(shell) ;
46 public void fillContextMenu(IMenuManager menu) {
47 this.openActionGroup.fillContextMenu(menu);
48 menu.add(new Separator());
49 this.refactorActionGroup.fillContextMenu(menu);
50 menu.add(new Separator());
51 menu.add(refreshAction) ;
52 menu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
53 menu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS + "-end")); //$NON-NLS-1$
54 menu.add(propertyDialogAction) ;
58 public void setContext(ActionContext actionContext) {
59 this.openActionGroup.setContext(actionContext);
60 this.refactorActionGroup.setContext(actionContext);
63 public void runDefaultAction(IStructuredSelection selection) {
64 this.openActionGroup.runDefaultAction(selection);
67 class ResourceNavigatorAdapter implements IResourceNavigator {
68 PHPResourcesView phpResourcesView;
69 ResourceNavigatorAdapter(PHPResourcesView phpResourcesView) {
70 this.phpResourcesView = phpResourcesView;
73 public FrameList getFrameList() {
77 public ResourcePatternFilter getPatternFilter() {
81 public ResourceSorter getSorter() {
85 public TreeViewer getViewer() {
86 return phpResourcesView.getViewer();
89 public IWorkingSet getWorkingSet() {
93 public void setFiltersPreference(String[] patterns) {
96 public void setSorter(ResourceSorter sorter) {
99 public void setWorkingSet(IWorkingSet workingSet) {
102 public IViewSite getViewSite() {
103 return phpResourcesView.getViewSite();
106 public void init(IViewSite arg0, IMemento arg1) throws PartInitException {
109 public void init(IViewSite arg0) throws PartInitException {
112 public void saveState(IMemento arg0) {
115 public void addPropertyListener(IPropertyListener arg0) {
118 public void createPartControl(Composite arg0) {
121 public void dispose() {
124 public IWorkbenchPartSite getSite() {
125 return phpResourcesView.getSite();
128 public String getTitle() {
129 return phpResourcesView.getTitle();
132 public Image getTitleImage() {
133 return phpResourcesView.getTitleImage();
136 public String getTitleToolTip() {
137 return phpResourcesView.getTitleToolTip();
140 public void removePropertyListener(IPropertyListener arg0) {
143 public void setFocus() {
146 public Object getAdapter(Class arg0) {
147 return phpResourcesView.getAdapter(arg0);