257b5b893f620bebb11841a2568348482eae6dba
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpeclipse / resourcesview / MainActionGroup.java
1 package net.sourceforge.phpeclipse.resourcesview;
2
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;
29
30 public class MainActionGroup extends ActionGroup {
31
32         private OpenActionGroup openActionGroup;
33         private RefactorActionGroup refactorActionGroup;
34         private PropertyDialogAction propertyDialogAction ;
35         private RefreshAction refreshAction ;
36
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) ;
44         }
45
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) ;
55
56         }
57
58         public void setContext(ActionContext actionContext) {
59                 this.openActionGroup.setContext(actionContext);
60                 this.refactorActionGroup.setContext(actionContext);
61         }
62
63         public void runDefaultAction(IStructuredSelection selection) {
64                 this.openActionGroup.runDefaultAction(selection);
65         }
66
67         class ResourceNavigatorAdapter implements IResourceNavigator {
68                 PHPResourcesView phpResourcesView;
69                 ResourceNavigatorAdapter(PHPResourcesView phpResourcesView) {
70                         this.phpResourcesView = phpResourcesView;
71                 }
72
73                 public FrameList getFrameList() {
74                         return null;
75                 }
76
77                 public ResourcePatternFilter getPatternFilter() {
78                         return null;
79                 }
80
81                 public  ResourceSorter getSorter() {
82                         return null;
83                 }
84
85                 public TreeViewer getViewer() {
86                         return phpResourcesView.getViewer();
87                 }
88
89                 public IWorkingSet getWorkingSet() {
90                         return null;
91                 }
92
93                 public void setFiltersPreference(String[] patterns) {
94                 }
95
96                 public void setSorter(ResourceSorter sorter) {
97                 }
98
99                 public void setWorkingSet(IWorkingSet workingSet) {
100                 }
101
102                 public IViewSite getViewSite() {
103                         return phpResourcesView.getViewSite();
104                 }
105
106                 public void init(IViewSite arg0, IMemento arg1) throws PartInitException {
107                 }
108
109                 public void init(IViewSite arg0) throws PartInitException {
110                 }
111
112                 public void saveState(IMemento arg0) {
113                 }
114
115                 public void addPropertyListener(IPropertyListener arg0) {
116                 }
117
118                 public void createPartControl(Composite arg0) {
119                 }
120
121                 public void dispose() {
122                 }
123
124                 public IWorkbenchPartSite getSite() {
125                         return phpResourcesView.getSite();
126                 }
127
128                 public String getTitle() {
129                         return phpResourcesView.getTitle();
130                 }
131
132                 public Image getTitleImage() {
133                         return phpResourcesView.getTitleImage();
134                 }
135
136                 public String getTitleToolTip() {
137                         return phpResourcesView.getTitleToolTip();
138                 }
139
140                 public void removePropertyListener(IPropertyListener arg0) {
141                 }
142
143                 public void setFocus() {
144                 }
145
146                 public Object getAdapter(Class arg0) {
147                         return phpResourcesView.getAdapter(arg0);
148                 }
149
150     //It was missing ?
151     public boolean isLinkingEnabled() {
152       return false;
153     }
154
155     //It was missing ?
156     public void setLinkingEnabled(boolean b) {
157     }
158         }
159
160 }