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