~ubuntu-branches/debian/sid/eclipse-cdt/sid

« back to all changes in this revision

Viewing changes to results/plugins/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/GenerateActionGroup.java

  • Committer: Package Import Robot
  • Author(s): Jakub Adam
  • Date: 2011-10-06 21:15:04 UTC
  • mfrom: (1.1.4)
  • Revision ID: package-import@ubuntu.com-20111006211504-8dutmljjih0zikfv
Tags: 8.0.1-1
* New upstream release.
* Split the JNI packages into a separate architecture dependent
  package and made eclipse-cdt architecture independent.
* Install JNI libraries into multiarch aware location
* Bumped Standards-Version to 3.9.2.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*******************************************************************************
2
 
 *  Copyright (c) 2000, 2009 IBM Corporation and others.
3
 
 *  All rights reserved. This program and the accompanying materials
4
 
 *  are made available under the terms of the Eclipse Public License v1.0
5
 
 *  which accompanies this distribution, and is available at
6
 
 *  http://www.eclipse.org/legal/epl-v10.html
7
 
 * 
8
 
 *  Contributors:
9
 
 *     IBM Corporation - initial API and implementation
10
 
 *     Anton Leherbauer (Wind River Systems) - Adapted for CDT
11
 
 *******************************************************************************/
12
 
package org.eclipse.cdt.ui.actions;
13
 
 
14
 
import java.util.ArrayList;
15
 
import java.util.Iterator;
16
 
import java.util.List;
17
 
 
18
 
import org.eclipse.core.runtime.Assert;
19
 
import org.eclipse.jface.action.IAction;
20
 
import org.eclipse.jface.action.IMenuManager;
21
 
import org.eclipse.jface.action.MenuManager;
22
 
import org.eclipse.jface.action.Separator;
23
 
import org.eclipse.jface.viewers.ISelection;
24
 
import org.eclipse.jface.viewers.ISelectionChangedListener;
25
 
import org.eclipse.jface.viewers.ISelectionProvider;
26
 
import org.eclipse.jface.viewers.IStructuredSelection;
27
 
import org.eclipse.ui.IActionBars;
28
 
import org.eclipse.ui.IViewPart;
29
 
import org.eclipse.ui.IWorkbenchSite;
30
 
import org.eclipse.ui.actions.ActionGroup;
31
 
import org.eclipse.ui.actions.AddBookmarkAction;
32
 
import org.eclipse.ui.actions.AddTaskAction;
33
 
import org.eclipse.ui.handlers.IHandlerService;
34
 
import org.eclipse.ui.ide.IDEActionFactory;
35
 
import org.eclipse.ui.part.Page;
36
 
import org.eclipse.ui.texteditor.ITextEditorActionConstants;
37
 
import org.eclipse.ui.texteditor.IUpdate;
38
 
import org.eclipse.ui.texteditor.IWorkbenchActionDefinitionIds;
39
 
 
40
 
import org.eclipse.cdt.ui.refactoring.actions.GettersAndSettersAction;
41
 
import org.eclipse.cdt.ui.refactoring.actions.ImplementMethodAction;
42
 
 
43
 
import org.eclipse.cdt.internal.ui.IContextMenuConstants;
44
 
import org.eclipse.cdt.internal.ui.actions.ActionMessages;
45
 
import org.eclipse.cdt.internal.ui.editor.AddIncludeOnSelectionAction;
46
 
import org.eclipse.cdt.internal.ui.editor.CEditor;
47
 
import org.eclipse.cdt.internal.ui.editor.ICEditorActionDefinitionIds;
48
 
 
49
 
/**
50
 
 * Action group that adds the source and generate actions to a part's context
51
 
 * menu and installs handlers for the corresponding global menu actions.
52
 
 * 
53
 
 * <p>
54
 
 * This class may be instantiated; it is not intended to be subclassed.
55
 
 * </p>
56
 
 * 
57
 
 * @noextend This class is not intended to be subclassed by clients.
58
 
 * @since 4.0
59
 
 */
60
 
public class GenerateActionGroup extends ActionGroup {
61
 
        
62
 
        /**
63
 
         * Pop-up menu: id of the source sub menu (value <code>org.eclipse.cdt.ui.source.menu</code>).
64
 
         */
65
 
        public static final String MENU_ID= "org.eclipse.cdt.ui.source.menu"; //$NON-NLS-1$
66
 
        
67
 
        /**
68
 
         * Pop-up menu: id of the organize group of the source sub menu (value
69
 
         * <code>organizeGroup</code>).
70
 
         */
71
 
        public static final String GROUP_ORGANIZE= "organizeGroup";  //$NON-NLS-1$
72
 
        
73
 
        /**
74
 
         * Pop-up menu: id of the generate group of the source sub menu (value
75
 
         * <code>generateGroup</code>).
76
 
         */
77
 
        public static final String GROUP_GENERATE= "generateGroup";  //$NON-NLS-1$
78
 
 
79
 
        /**
80
 
         * Pop-up menu: id of the code group of the source sub menu (value
81
 
         * <code>codeGroup</code>).
82
 
         */
83
 
        public static final String GROUP_CODE= "codeGroup";  //$NON-NLS-1$
84
 
 
85
 
        /**
86
 
         * Pop-up menu: id of the externalize group of the source sub menu (value
87
 
         * <code>externalizeGroup</code>).
88
 
         */
89
 
        private static final String GROUP_EXTERNALIZE= "externalizeGroup"; //$NON-NLS-1$
90
 
 
91
 
        /**
92
 
         * Pop-up menu: id of the comment group of the source sub menu (value
93
 
         * <code>commentGroup</code>).
94
 
         */
95
 
        private static final String GROUP_COMMENT= "commentGroup"; //$NON-NLS-1$
96
 
 
97
 
        /**
98
 
         * Pop-up menu: id of the edit group of the source sub menu (value
99
 
         * <code>editGroup</code>).
100
 
         */
101
 
        private static final String GROUP_EDIT= "editGroup"; //$NON-NLS-1$
102
 
        
103
 
        private CEditor fEditor;
104
 
        private IWorkbenchSite fSite;
105
 
        private String fGroupName= IContextMenuConstants.GROUP_REORGANIZE;
106
 
        private List<ISelectionChangedListener> fRegisteredSelectionListeners;
107
 
        
108
 
        private AddIncludeOnSelectionAction fAddInclude;
109
 
//      private OverrideMethodsAction fOverrideMethods;
110
 
//      private GenerateHashCodeEqualsAction fHashCodeEquals;
111
 
        private GettersAndSettersAction fAddGetterSetter;
112
 
        private ImplementMethodAction fImplementMethod;
113
 
//      private AddDelegateMethodsAction fAddDelegateMethods;
114
 
//      private AddUnimplementedConstructorsAction fAddUnimplementedConstructors;
115
 
//      private GenerateNewConstructorUsingFieldsAction fGenerateConstructorUsingFields;
116
 
//      private AddJavaDocStubAction fAddCppDocStub;
117
 
        private AddBookmarkAction fAddBookmark;
118
 
        private AddTaskAction fAddTaskAction;
119
 
//      private ExternalizeStringsAction fExternalizeStrings;
120
 
//      private CleanUpAction fCleanUp; 
121
 
//      
122
 
//      private OrganizeIncludesAction fOrganizeIncludes;
123
 
//      private SortMembersAction fSortMembers;
124
 
//      private FormatAllAction fFormatAll;
125
 
//      private CopyQualifiedNameAction fCopyQualifiedNameAction;
126
 
//      
127
 
//      private static final String QUICK_MENU_ID= "org.eclipse.cdt.ui.edit.text.c.source.quickMenu"; //$NON-NLS-1$
128
 
//      
129
 
//      private class RefactorQuickAccessAction extends CDTQuickMenuAction {
130
 
//              public RefactorQuickAccessAction(CEditor editor) {
131
 
//                      super(editor, QUICK_MENU_ID); 
132
 
//              }
133
 
//              protected void fillMenu(IMenuManager menu) {
134
 
//                      fillQuickMenu(menu);
135
 
//              }
136
 
//      }
137
 
//      
138
 
//      private RefactorQuickAccessAction fQuickAccessAction;
139
 
//      private IKeyBindingService fKeyBindingService;
140
 
 
141
 
        /**
142
 
         * Note: This constructor is for internal use only. Clients should not call this constructor.
143
 
         * @param editor the C editor
144
 
         * @param groupName the group name to add the action to
145
 
         * 
146
 
         * @noreference This constructor is not intended to be referenced by clients.
147
 
         */
148
 
        public GenerateActionGroup(CEditor editor, String groupName) {
149
 
                fSite= editor.getSite();
150
 
                fEditor= editor;
151
 
                fGroupName= groupName;
152
 
                                
153
 
                fAddInclude= new AddIncludeOnSelectionAction(editor);
154
 
                fAddInclude.setActionDefinitionId(ICEditorActionDefinitionIds.ADD_INCLUDE);
155
 
                editor.setAction("AddIncludeOnSelection", fAddInclude); //$NON-NLS-1$
156
 
                
157
 
//              fOrganizeIncludes= new OrganizeIncludesAction(editor);
158
 
//              fOrganizeIncludes.setActionDefinitionId(ICEditorActionDefinitionIds.ORGANIZE_INCLUDES);
159
 
//              editor.setAction("OrganizeIncludes", fOrganizeIncludes); //$NON-NLS-1$
160
 
//
161
 
//              fSortMembers= new SortMembersAction(editor);
162
 
//              fSortMembers.setActionDefinitionId(ICEditorActionDefinitionIds.SORT_MEMBERS);
163
 
//              editor.setAction("SortMembers", fSortMembers); //$NON-NLS-1$
164
 
//              
165
 
//              IAction pastAction= editor.getAction(ITextEditorActionConstants.PASTE);//IWorkbenchActionDefinitionIds.PASTE);
166
 
//              fCopyQualifiedNameAction= new CopyQualifiedNameAction(editor, null, pastAction);
167
 
//              fCopyQualifiedNameAction.setActionDefinitionId(CopyQualifiedNameAction.JAVA_EDITOR_ACTION_DEFINITIONS_ID);
168
 
//              editor.setAction("CopyQualifiedName", fCopyQualifiedNameAction); //$NON-NLS-1$
169
 
//
170
 
//              fOverrideMethods= new OverrideMethodsAction(editor);
171
 
//              fOverrideMethods.setActionDefinitionId(ICEditorActionDefinitionIds.OVERRIDE_METHODS);
172
 
//              editor.setAction("OverrideMethods", fOverrideMethods); //$NON-NLS-1$
173
 
//              
174
 
                fAddGetterSetter= new GettersAndSettersAction(editor);
175
 
                fAddGetterSetter.setActionDefinitionId(ICEditorActionDefinitionIds.GETTERS_AND_SETTERS);
176
 
                editor.setAction("org.eclipse.cdt.ui.refactor.getters.and.setters", fAddGetterSetter); //$NON-NLS-1$
177
 
                
178
 
                fImplementMethod = new ImplementMethodAction(editor);
179
 
                fImplementMethod.setActionDefinitionId(ICEditorActionDefinitionIds.IMPLEMENT_METHOD);
180
 
                editor.setAction("org.eclipse.cdt.ui.refactor.implement.method", fImplementMethod); //$NON-NLS-1$
181
 
//
182
 
//              fAddDelegateMethods= new AddDelegateMethodsAction(editor);
183
 
//              fAddDelegateMethods.setActionDefinitionId(ICEditorActionDefinitionIds.CREATE_DELEGATE_METHODS);
184
 
//              editor.setAction("AddDelegateMethods", fAddDelegateMethods); //$NON-NLS-1$
185
 
//                      
186
 
//              fAddUnimplementedConstructors= new AddUnimplementedConstructorsAction(editor);
187
 
//              fAddUnimplementedConstructors.setActionDefinitionId(ICEditorActionDefinitionIds.ADD_UNIMPLEMENTED_CONTRUCTORS);
188
 
//              editor.setAction("AddUnimplementedConstructors", fAddUnimplementedConstructors); //$NON-NLS-1$          
189
 
//
190
 
//              fGenerateConstructorUsingFields= new GenerateNewConstructorUsingFieldsAction(editor);
191
 
//              fGenerateConstructorUsingFields.setActionDefinitionId(ICEditorActionDefinitionIds.GENERATE_CONSTRUCTOR_USING_FIELDS);
192
 
//              editor.setAction("GenerateConstructorUsingFields", fGenerateConstructorUsingFields); //$NON-NLS-1$              
193
 
//
194
 
//              fHashCodeEquals= new GenerateHashCodeEqualsAction(editor);
195
 
//              fHashCodeEquals.setActionDefinitionId(ICEditorActionDefinitionIds.GENERATE_HASHCODE_EQUALS);
196
 
//              editor.setAction("GenerateHashCodeEquals", fHashCodeEquals); //$NON-NLS-1$
197
 
//
198
 
//              fAddCppDocStub= new AddJavaDocStubAction(editor);
199
 
//              fAddCppDocStub.setActionDefinitionId(ICEditorActionDefinitionIds.ADD_JAVADOC_COMMENT);
200
 
//              editor.setAction("AddJavadocComment", fAddCppDocStub); //$NON-NLS-1$
201
 
//              
202
 
//              fCleanUp= new CleanUpAction(editor);
203
 
//              fCleanUp.setActionDefinitionId(ICEditorActionDefinitionIds.CLEAN_UP);
204
 
//              editor.setAction("CleanUp", fCleanUp); //$NON-NLS-1$
205
 
//              
206
 
//              fExternalizeStrings= new ExternalizeStringsAction(editor);
207
 
//              fExternalizeStrings.setActionDefinitionId(ICEditorActionDefinitionIds.EXTERNALIZE_STRINGS);
208
 
//              editor.setAction("ExternalizeStrings", fExternalizeStrings); //$NON-NLS-1$      
209
 
//                              
210
 
//              fQuickAccessAction= new RefactorQuickAccessAction(editor);
211
 
//              fKeyBindingService= editor.getEditorSite().getKeyBindingService();
212
 
//              fKeyBindingService.registerAction(fQuickAccessAction);
213
 
        }
214
 
        
215
 
        /**
216
 
         * Creates a new <code>GenerateActionGroup</code>. The group 
217
 
         * requires that the selection provided by the page's selection provider 
218
 
         * is of type <code>org.eclipse.jface.viewers.IStructuredSelection</code>.
219
 
         * 
220
 
         * @param page the page that owns this action group
221
 
         */
222
 
        public GenerateActionGroup(Page page) {
223
 
                this(page.getSite(), null);
224
 
        }
225
 
 
226
 
        /**
227
 
         * Creates a new <code>GenerateActionGroup</code>. The group 
228
 
         * requires that the selection provided by the part's selection provider 
229
 
         * is of type <code>org.eclipse.jface.viewers.IStructuredSelection</code>.
230
 
         * 
231
 
         * @param part the view part that owns this action group
232
 
         */
233
 
        public GenerateActionGroup(IViewPart part) {
234
 
                this(part.getSite(), (IHandlerService)part.getSite().getService(IHandlerService.class));
235
 
        }
236
 
        
237
 
        private GenerateActionGroup(IWorkbenchSite site, IHandlerService handlerService) {
238
 
                fSite= site;
239
 
                ISelectionProvider provider= fSite.getSelectionProvider();
240
 
                ISelection selection= provider.getSelection();
241
 
                
242
 
//              fOverrideMethods= new OverrideMethodsAction(site);
243
 
//              fOverrideMethods.setActionDefinitionId(ICEditorActionDefinitionIds.OVERRIDE_METHODS);
244
 
//              
245
 
//              fAddGetterSetter= new AddGetterSetterAction(site);
246
 
//              fAddGetterSetter.setActionDefinitionId(ICEditorActionDefinitionIds.CREATE_GETTER_SETTER);
247
 
//              
248
 
//              fAddDelegateMethods= new AddDelegateMethodsAction(site);
249
 
//              fAddDelegateMethods.setActionDefinitionId(ICEditorActionDefinitionIds.CREATE_DELEGATE_METHODS);
250
 
//              
251
 
//              fAddUnimplementedConstructors= new AddUnimplementedConstructorsAction(site);
252
 
//              fAddUnimplementedConstructors.setActionDefinitionId(ICEditorActionDefinitionIds.ADD_UNIMPLEMENTED_CONTRUCTORS);
253
 
//              
254
 
//              fGenerateConstructorUsingFields= new GenerateNewConstructorUsingFieldsAction(site);
255
 
//              fGenerateConstructorUsingFields.setActionDefinitionId(ICEditorActionDefinitionIds.GENERATE_CONSTRUCTOR_USING_FIELDS);
256
 
//
257
 
//              fHashCodeEquals= new GenerateHashCodeEqualsAction(site);
258
 
//              fHashCodeEquals.setActionDefinitionId(ICEditorActionDefinitionIds.GENERATE_HASHCODE_EQUALS);
259
 
//
260
 
//              fAddCppDocStub= new AddJavaDocStubAction(site);
261
 
//              fAddCppDocStub.setActionDefinitionId(ICEditorActionDefinitionIds.ADD_JAVADOC_COMMENT);
262
 
                
263
 
                fAddBookmark= new AddBookmarkAction(site, true);
264
 
                fAddBookmark.setActionDefinitionId(IWorkbenchActionDefinitionIds.ADD_BOOKMARK);
265
 
                
266
 
                fAddTaskAction= new AddTaskAction(site);
267
 
                fAddTaskAction.setActionDefinitionId(IWorkbenchActionDefinitionIds.ADD_TASK);
268
 
                
269
 
//              fExternalizeStrings= new ExternalizeStringsAction(site);
270
 
//              fExternalizeStrings.setActionDefinitionId(ICEditorActionDefinitionIds.EXTERNALIZE_STRINGS);
271
 
//              
272
 
//              fOrganizeIncludes= new OrganizeIncludesAction(site);
273
 
//              fOrganizeIncludes.setActionDefinitionId(ICEditorActionDefinitionIds.ORGANIZE_INCLUDES);
274
 
//              
275
 
//              fSortMembers= new SortMembersAction(site);
276
 
//              fSortMembers.setActionDefinitionId(ICEditorActionDefinitionIds.SORT_MEMBERS);
277
 
//              
278
 
//              fFormatAll= new FormatAllAction(site);
279
 
//              fFormatAll.setActionDefinitionId(ICEditorActionDefinitionIds.FORMAT);
280
 
//              
281
 
//              fCleanUp= new CleanUpAction(site);
282
 
//              fCleanUp.setActionDefinitionId(ICEditorActionDefinitionIds.CLEAN_UP);
283
 
 
284
 
                
285
 
//              fOverrideMethods.update(selection);
286
 
//              fAddGetterSetter.update(selection);
287
 
//              fAddDelegateMethods.update(selection);
288
 
//              fAddUnimplementedConstructors.update(selection);        
289
 
//              fGenerateConstructorUsingFields.update(selection);
290
 
//              fHashCodeEquals.update(selection);
291
 
//              fAddCppDocStub.update(selection);
292
 
//              fExternalizeStrings.update(selection);
293
 
//              fFindNLSProblems.update(selection);
294
 
//              fCleanUp.update(selection);
295
 
//              fOrganizeIncludes.update(selection);
296
 
//              fSortMembers.update(selection);
297
 
//              fFormatAll.update(selection);
298
 
                if (selection instanceof IStructuredSelection) {
299
 
                        IStructuredSelection ss= (IStructuredSelection)selection;
300
 
                        fAddBookmark.selectionChanged(ss);
301
 
                        fAddTaskAction.selectionChanged(ss);
302
 
                } else {
303
 
                        fAddBookmark.setEnabled(false);
304
 
                        fAddTaskAction.setEnabled(false);
305
 
                }
306
 
                
307
 
//              registerSelectionListener(provider, fOverrideMethods);
308
 
//              registerSelectionListener(provider, fAddGetterSetter);
309
 
//              registerSelectionListener(provider, fAddDelegateMethods);
310
 
//              registerSelectionListener(provider, fAddUnimplementedConstructors);
311
 
//              registerSelectionListener(provider, fGenerateConstructorUsingFields);
312
 
//              registerSelectionListener(provider, fHashCodeEquals);
313
 
//              registerSelectionListener(provider, fAddCppDocStub);
314
 
                registerSelectionListener(provider, fAddBookmark);
315
 
//              registerSelectionListener(provider, fExternalizeStrings);
316
 
//              registerSelectionListener(provider, fFindNLSProblems);
317
 
//              registerSelectionListener(provider, fOrganizeIncludes);
318
 
//              registerSelectionListener(provider, fFormatAll);
319
 
//              registerSelectionListener(provider, fSortMembers);
320
 
                registerSelectionListener(provider, fAddTaskAction);
321
 
//              registerSelectionListener(provider, fCleanUp);
322
 
                
323
 
//              fKeyBindingService= keyBindingService;
324
 
//              if (fKeyBindingService != null) {
325
 
//                      fQuickAccessAction= new RefactorQuickAccessAction(null);
326
 
//                      fKeyBindingService.registerAction(fQuickAccessAction);
327
 
//              }
328
 
        }
329
 
        
330
 
        private void registerSelectionListener(ISelectionProvider provider, ISelectionChangedListener listener) {
331
 
                if (fRegisteredSelectionListeners == null)
332
 
                        fRegisteredSelectionListeners= new ArrayList<ISelectionChangedListener>(10);
333
 
                provider.addSelectionChangedListener(listener);
334
 
                fRegisteredSelectionListeners.add(listener);
335
 
        }
336
 
        
337
 
        /*
338
 
         * The state of the editor owning this action group has changed. 
339
 
         * This method does nothing if the group's owner isn't an
340
 
         * editor.
341
 
         */
342
 
        /**
343
 
         * Note: This method is for internal use only. Clients should not call this method.
344
 
         */
345
 
        public void editorStateChanged() {
346
 
                Assert.isTrue(isEditorOwner());
347
 
        }
348
 
 
349
 
        /* 
350
 
         * Method declared in ActionGroup
351
 
         */
352
 
        @Override
353
 
        public void fillActionBars(IActionBars actionBar) {
354
 
                super.fillActionBars(actionBar);
355
 
                setGlobalActionHandlers(actionBar);
356
 
        }
357
 
        
358
 
        /* 
359
 
         * Method declared in ActionGroup
360
 
         */
361
 
        @Override
362
 
        public void fillContextMenu(IMenuManager menu) {
363
 
                super.fillContextMenu(menu);
364
 
                String menuText= ActionMessages.getString("SourceMenu_label");  //$NON-NLS-1$
365
 
//              if (fQuickAccessAction != null) {
366
 
//                      menuText= fQuickAccessAction.addShortcut(menuText); 
367
 
//              }
368
 
                IMenuManager subMenu= new MenuManager(menuText, MENU_ID); 
369
 
                int added= 0;
370
 
                if (isEditorOwner()) {
371
 
                        added= fillEditorSubMenu(subMenu);
372
 
                } else {
373
 
                        added= fillViewSubMenu(subMenu);
374
 
                }
375
 
                if (added > 0)
376
 
                        menu.appendToGroup(fGroupName, subMenu);
377
 
        }
378
 
 
379
 
//      private void fillQuickMenu(IMenuManager menu) {
380
 
//              if (isEditorOwner()) {
381
 
//                      fillEditorSubMenu(menu);
382
 
//              } else {
383
 
//                      fillViewSubMenu(menu);
384
 
//              }
385
 
//      }
386
 
        
387
 
        private int fillEditorSubMenu(IMenuManager source) {
388
 
                int added= 0;
389
 
                source.add(new Separator(GROUP_COMMENT));
390
 
                added+= addEditorAction(source, "ToggleComment"); //$NON-NLS-1$
391
 
                added+= addEditorAction(source, "AddBlockComment"); //$NON-NLS-1$
392
 
                added+= addEditorAction(source, "RemoveBlockComment"); //$NON-NLS-1$
393
 
//              added+= addAction(source, fAddCppDocStub);
394
 
                source.add(new Separator(GROUP_EDIT));
395
 
                added+= addEditorAction(source, ITextEditorActionConstants.SHIFT_RIGHT);
396
 
                added+= addEditorAction(source, ITextEditorActionConstants.SHIFT_LEFT);
397
 
                added+= addEditorAction(source, "Indent"); //$NON-NLS-1$
398
 
                added+= addEditorAction(source, "Format"); //$NON-NLS-1$
399
 
                source.add(new Separator(GROUP_ORGANIZE));
400
 
                added+= addAction(source, fAddInclude);
401
 
//              added+= addAction(source, fOrganizeIncludes);
402
 
//              added+= addAction(source, fSortMembers);
403
 
//              added+= addAction(source, fCleanUp);
404
 
                source.add(new Separator(GROUP_GENERATE));
405
 
                added+= addEditorAction(source, "ContentAssistProposal"); //$NON-NLS-1$
406
 
//              added+= addAction(source, fOverrideMethods);
407
 
                added+= addAction(source, fAddGetterSetter);
408
 
                added+= addAction(source, fImplementMethod);
409
 
//              added+= addAction(source, fAddDelegateMethods);
410
 
//              added+= addAction(source, fHashCodeEquals);
411
 
//              added+= addAction(source, fGenerateConstructorUsingFields);
412
 
//              added+= addAction(source, fAddUnimplementedConstructors);
413
 
                source.add(new Separator(GROUP_CODE));
414
 
                source.add(new Separator(GROUP_EXTERNALIZE));
415
 
//              added+= addAction(source, fExternalizeStrings);
416
 
                return added;
417
 
        }
418
 
 
419
 
        private int fillViewSubMenu(IMenuManager source) {
420
 
                int added= 0;
421
 
                source.add(new Separator(GROUP_COMMENT));
422
 
//              added+= addAction(source, fAddCppDocStub);
423
 
                source.add(new Separator(GROUP_EDIT));
424
 
//              added+= addAction(source, fFormatAll);
425
 
                source.add(new Separator(GROUP_ORGANIZE));
426
 
                added+= addAction(source, fAddInclude);
427
 
//              added+= addAction(source, fOrganizeIncludes);
428
 
//              added+= addAction(source, fSortMembers);
429
 
//              added+= addAction(source, fCleanUp);
430
 
                source.add(new Separator(GROUP_GENERATE));
431
 
//              added+= addAction(source, fOverrideMethods);
432
 
                added+= addAction(source, fAddGetterSetter);
433
 
                added+= addAction(source, fImplementMethod);
434
 
//              added+= addAction(source, fAddDelegateMethods);
435
 
//              added+= addAction(source, fHashCodeEquals);
436
 
//              added+= addAction(source, fGenerateConstructorUsingFields);
437
 
//              added+= addAction(source, fAddUnimplementedConstructors);
438
 
                source.add(new Separator(GROUP_CODE));
439
 
                source.add(new Separator(GROUP_EXTERNALIZE));
440
 
//              added+= addAction(source, fExternalizeStrings);
441
 
//              added+= addAction(source, fFindNLSProblems);
442
 
                return added;
443
 
        }
444
 
 
445
 
        /* 
446
 
         * Method declared in ActionGroup
447
 
         */
448
 
        @Override
449
 
        public void dispose() {
450
 
                if (fRegisteredSelectionListeners != null) {
451
 
                        ISelectionProvider provider= fSite.getSelectionProvider();
452
 
                        for (Iterator<ISelectionChangedListener> iter= fRegisteredSelectionListeners.iterator(); iter.hasNext();) {
453
 
                                ISelectionChangedListener listener= iter.next();
454
 
                                provider.removeSelectionChangedListener(listener);
455
 
                        }
456
 
                }
457
 
//              if (fQuickAccessAction != null && fKeyBindingService != null) {
458
 
//                      fKeyBindingService.unregisterAction(fQuickAccessAction);
459
 
//              }
460
 
                fEditor= null;
461
 
                super.dispose();
462
 
        }
463
 
        
464
 
        private void setGlobalActionHandlers(IActionBars actionBar) {
465
 
                actionBar.setGlobalActionHandler(CdtActionConstants.ADD_INCLUDE, fAddInclude);
466
 
//              actionBar.setGlobalActionHandler(CdtActionConstants.OVERRIDE_METHODS, fOverrideMethods);
467
 
                actionBar.setGlobalActionHandler(CdtActionConstants.GETTERS_AND_SETTERS, fAddGetterSetter);
468
 
                actionBar.setGlobalActionHandler(CdtActionConstants.IMPLEMENT_METHOD, fImplementMethod);
469
 
//              actionBar.setGlobalActionHandler(CdtActionConstants.GENERATE_DELEGATE_METHODS, fAddDelegateMethods);
470
 
//              actionBar.setGlobalActionHandler(CdtActionConstants.ADD_CONSTRUCTOR_FROM_SUPERCLASS, fAddUnimplementedConstructors);            
471
 
//              actionBar.setGlobalActionHandler(CdtActionConstants.GENERATE_CONSTRUCTOR_USING_FIELDS, fGenerateConstructorUsingFields);
472
 
//              actionBar.setGlobalActionHandler(CdtActionConstants.GENERATE_HASHCODE_EQUALS, fHashCodeEquals);
473
 
//              actionBar.setGlobalActionHandler(CdtActionConstants.ADD_CPP_DOC_COMMENT, fAddCppDocStub);
474
 
//              actionBar.setGlobalActionHandler(CdtActionConstants.EXTERNALIZE_STRINGS, fExternalizeStrings);
475
 
//              actionBar.setGlobalActionHandler(CdtActionConstants.CLEAN_UP, fCleanUp);
476
 
//              actionBar.setGlobalActionHandler(CdtActionConstants.ORGANIZE_INCLUDES, fOrganizeIncludes);
477
 
//              actionBar.setGlobalActionHandler(CdtActionConstants.SORT_MEMBERS, fSortMembers);
478
 
                if (!isEditorOwner()) {
479
 
                        // editor provides its own implementation of these actions.
480
 
                        actionBar.setGlobalActionHandler(IDEActionFactory.BOOKMARK.getId(), fAddBookmark);
481
 
                        actionBar.setGlobalActionHandler(IDEActionFactory.ADD_TASK.getId(), fAddTaskAction);
482
 
//                      actionBar.setGlobalActionHandler(CdtActionConstants.FORMAT, fFormatAll);
483
 
                } else {
484
 
//                      actionBar.setGlobalActionHandler(CopyQualifiedNameAction.ACTION_HANDLER_ID, fCopyQualifiedNameAction);
485
 
                }
486
 
        }
487
 
        
488
 
        private int addAction(IMenuManager menu, IAction action) {
489
 
                if (action instanceof IUpdate)
490
 
                        ((IUpdate)action).update();
491
 
                if (action != null && action.isEnabled()) {
492
 
                        menu.add(action);
493
 
                        return 1;
494
 
                }
495
 
                return 0;
496
 
        }       
497
 
        
498
 
        private int addEditorAction(IMenuManager menu, String actionID) {
499
 
                if (fEditor == null)
500
 
                        return 0;
501
 
                IAction action= fEditor.getAction(actionID);
502
 
                if (action == null)
503
 
                        return 0;
504
 
                if (action instanceof IUpdate)
505
 
                        ((IUpdate)action).update();
506
 
                if (action.isEnabled()) {
507
 
                        menu.add(action);
508
 
                        return 1;
509
 
                }
510
 
                return 0;
511
 
        }
512
 
        
513
 
        private boolean isEditorOwner() {
514
 
                return fEditor != null;
515
 
        }       
516
 
}