|
Lines 15-20
Link Here
|
| 15 |
import java.util.Iterator; |
15 |
import java.util.Iterator; |
| 16 |
import java.util.List; |
16 |
import java.util.List; |
| 17 |
|
17 |
|
|
|
18 |
import org.eclipse.core.commands.IHandler; |
| 18 |
import org.eclipse.core.runtime.Assert; |
19 |
import org.eclipse.core.runtime.Assert; |
| 19 |
import org.eclipse.jface.action.IAction; |
20 |
import org.eclipse.jface.action.IAction; |
| 20 |
import org.eclipse.jface.action.IMenuManager; |
21 |
import org.eclipse.jface.action.IMenuManager; |
|
Lines 26-47
Link Here
|
| 26 |
import org.eclipse.jface.viewers.IStructuredSelection; |
27 |
import org.eclipse.jface.viewers.IStructuredSelection; |
| 27 |
import org.eclipse.ui.IActionBars; |
28 |
import org.eclipse.ui.IActionBars; |
| 28 |
import org.eclipse.ui.IViewPart; |
29 |
import org.eclipse.ui.IViewPart; |
|
|
30 |
import org.eclipse.ui.IWorkbenchCommandConstants; |
| 29 |
import org.eclipse.ui.IWorkbenchSite; |
31 |
import org.eclipse.ui.IWorkbenchSite; |
| 30 |
import org.eclipse.ui.actions.ActionGroup; |
32 |
import org.eclipse.ui.actions.ActionGroup; |
| 31 |
import org.eclipse.ui.actions.AddBookmarkAction; |
33 |
import org.eclipse.ui.actions.AddBookmarkAction; |
| 32 |
import org.eclipse.ui.actions.AddTaskAction; |
34 |
import org.eclipse.ui.actions.AddTaskAction; |
|
|
35 |
import org.eclipse.ui.handlers.IHandlerActivation; |
| 33 |
import org.eclipse.ui.handlers.IHandlerService; |
36 |
import org.eclipse.ui.handlers.IHandlerService; |
| 34 |
import org.eclipse.ui.ide.IDEActionFactory; |
37 |
import org.eclipse.ui.ide.IDEActionFactory; |
| 35 |
import org.eclipse.ui.part.Page; |
38 |
import org.eclipse.ui.part.Page; |
| 36 |
import org.eclipse.ui.texteditor.ITextEditorActionConstants; |
39 |
import org.eclipse.ui.texteditor.ITextEditorActionConstants; |
| 37 |
import org.eclipse.ui.texteditor.IUpdate; |
40 |
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.GettersAndSettersAction; |
| 41 |
import org.eclipse.cdt.ui.refactoring.actions.ImplementMethodAction; |
42 |
import org.eclipse.cdt.ui.refactoring.actions.ImplementMethodAction; |
| 42 |
|
43 |
|
| 43 |
import org.eclipse.cdt.internal.ui.IContextMenuConstants; |
44 |
import org.eclipse.cdt.internal.ui.IContextMenuConstants; |
| 44 |
import org.eclipse.cdt.internal.ui.actions.ActionMessages; |
45 |
import org.eclipse.cdt.internal.ui.actions.ActionMessages; |
|
|
46 |
import org.eclipse.cdt.internal.ui.actions.CDTQuickMenuCreator; |
| 45 |
import org.eclipse.cdt.internal.ui.editor.AddIncludeOnSelectionAction; |
47 |
import org.eclipse.cdt.internal.ui.editor.AddIncludeOnSelectionAction; |
| 46 |
import org.eclipse.cdt.internal.ui.editor.CEditor; |
48 |
import org.eclipse.cdt.internal.ui.editor.CEditor; |
| 47 |
import org.eclipse.cdt.internal.ui.editor.ICEditorActionDefinitionIds; |
49 |
import org.eclipse.cdt.internal.ui.editor.ICEditorActionDefinitionIds; |
|
Lines 124-142
Link Here
|
| 124 |
// private FormatAllAction fFormatAll; |
126 |
// private FormatAllAction fFormatAll; |
| 125 |
// private CopyQualifiedNameAction fCopyQualifiedNameAction; |
127 |
// private CopyQualifiedNameAction fCopyQualifiedNameAction; |
| 126 |
// |
128 |
// |
| 127 |
// private static final String QUICK_MENU_ID= "org.eclipse.cdt.ui.edit.text.c.source.quickMenu"; //$NON-NLS-1$ |
129 |
private static final String QUICK_MENU_ID= "org.eclipse.cdt.ui.edit.text.c.source.quickMenu"; //$NON-NLS-1$ |
| 128 |
// |
130 |
|
| 129 |
// private class RefactorQuickAccessAction extends CDTQuickMenuAction { |
131 |
private IHandlerActivation fQuickAccessHandlerActivation; |
| 130 |
// public RefactorQuickAccessAction(CEditor editor) { |
132 |
private IHandlerService fHandlerService; |
| 131 |
// super(editor, QUICK_MENU_ID); |
133 |
|
| 132 |
// } |
|
|
| 133 |
// protected void fillMenu(IMenuManager menu) { |
| 134 |
// fillQuickMenu(menu); |
| 135 |
// } |
| 136 |
// } |
| 137 |
// |
| 138 |
// private RefactorQuickAccessAction fQuickAccessAction; |
| 139 |
// private IKeyBindingService fKeyBindingService; |
| 140 |
|
134 |
|
| 141 |
/** |
135 |
/** |
| 142 |
* Note: This constructor is for internal use only. Clients should not call this constructor. |
136 |
* Note: This constructor is for internal use only. Clients should not call this constructor. |
|
Lines 149-155
Link Here
|
| 149 |
fSite= editor.getSite(); |
143 |
fSite= editor.getSite(); |
| 150 |
fEditor= editor; |
144 |
fEditor= editor; |
| 151 |
fGroupName= groupName; |
145 |
fGroupName= groupName; |
| 152 |
|
146 |
|
| 153 |
fAddInclude= new AddIncludeOnSelectionAction(editor); |
147 |
fAddInclude= new AddIncludeOnSelectionAction(editor); |
| 154 |
fAddInclude.setActionDefinitionId(ICEditorActionDefinitionIds.ADD_INCLUDE); |
148 |
fAddInclude.setActionDefinitionId(ICEditorActionDefinitionIds.ADD_INCLUDE); |
| 155 |
editor.setAction("AddIncludeOnSelection", fAddInclude); //$NON-NLS-1$ |
149 |
editor.setAction("AddIncludeOnSelection", fAddInclude); //$NON-NLS-1$ |
|
Lines 207-215
Link Here
|
| 207 |
// fExternalizeStrings.setActionDefinitionId(ICEditorActionDefinitionIds.EXTERNALIZE_STRINGS); |
201 |
// fExternalizeStrings.setActionDefinitionId(ICEditorActionDefinitionIds.EXTERNALIZE_STRINGS); |
| 208 |
// editor.setAction("ExternalizeStrings", fExternalizeStrings); //$NON-NLS-1$ |
202 |
// editor.setAction("ExternalizeStrings", fExternalizeStrings); //$NON-NLS-1$ |
| 209 |
// |
203 |
// |
| 210 |
// fQuickAccessAction= new RefactorQuickAccessAction(editor); |
204 |
installQuickAccessAction(); |
| 211 |
// fKeyBindingService= editor.getEditorSite().getKeyBindingService(); |
|
|
| 212 |
// fKeyBindingService.registerAction(fQuickAccessAction); |
| 213 |
} |
205 |
} |
| 214 |
|
206 |
|
| 215 |
/** |
207 |
/** |
|
Lines 220-226
Link Here
|
| 220 |
* @param page the page that owns this action group |
212 |
* @param page the page that owns this action group |
| 221 |
*/ |
213 |
*/ |
| 222 |
public GenerateActionGroup(Page page) { |
214 |
public GenerateActionGroup(Page page) { |
| 223 |
this(page.getSite(), null); |
215 |
this(page.getSite()); |
| 224 |
} |
216 |
} |
| 225 |
|
217 |
|
| 226 |
/** |
218 |
/** |
|
Lines 231-240
Link Here
|
| 231 |
* @param part the view part that owns this action group |
223 |
* @param part the view part that owns this action group |
| 232 |
*/ |
224 |
*/ |
| 233 |
public GenerateActionGroup(IViewPart part) { |
225 |
public GenerateActionGroup(IViewPart part) { |
| 234 |
this(part.getSite(), (IHandlerService)part.getSite().getService(IHandlerService.class)); |
226 |
this(part.getSite()); |
| 235 |
} |
227 |
} |
| 236 |
|
228 |
|
| 237 |
private GenerateActionGroup(IWorkbenchSite site, IHandlerService handlerService) { |
229 |
private GenerateActionGroup(IWorkbenchSite site) { |
| 238 |
fSite= site; |
230 |
fSite= site; |
| 239 |
ISelectionProvider provider= fSite.getSelectionProvider(); |
231 |
ISelectionProvider provider= fSite.getSelectionProvider(); |
| 240 |
ISelection selection= provider.getSelection(); |
232 |
ISelection selection= provider.getSelection(); |
|
Lines 261-270
Link Here
|
| 261 |
// fAddCppDocStub.setActionDefinitionId(ICEditorActionDefinitionIds.ADD_JAVADOC_COMMENT); |
253 |
// fAddCppDocStub.setActionDefinitionId(ICEditorActionDefinitionIds.ADD_JAVADOC_COMMENT); |
| 262 |
|
254 |
|
| 263 |
fAddBookmark= new AddBookmarkAction(site, true); |
255 |
fAddBookmark= new AddBookmarkAction(site, true); |
| 264 |
fAddBookmark.setActionDefinitionId(IWorkbenchActionDefinitionIds.ADD_BOOKMARK); |
256 |
fAddBookmark.setActionDefinitionId(IWorkbenchCommandConstants.EDIT_ADD_BOOKMARK); |
| 265 |
|
257 |
|
| 266 |
fAddTaskAction= new AddTaskAction(site); |
258 |
fAddTaskAction= new AddTaskAction(site); |
| 267 |
fAddTaskAction.setActionDefinitionId(IWorkbenchActionDefinitionIds.ADD_TASK); |
259 |
fAddTaskAction.setActionDefinitionId(IWorkbenchCommandConstants.EDIT_ADD_TASK); |
| 268 |
|
260 |
|
| 269 |
// fExternalizeStrings= new ExternalizeStringsAction(site); |
261 |
// fExternalizeStrings= new ExternalizeStringsAction(site); |
| 270 |
// fExternalizeStrings.setActionDefinitionId(ICEditorActionDefinitionIds.EXTERNALIZE_STRINGS); |
262 |
// fExternalizeStrings.setActionDefinitionId(ICEditorActionDefinitionIds.EXTERNALIZE_STRINGS); |
|
Lines 320-332
Link Here
|
| 320 |
registerSelectionListener(provider, fAddTaskAction); |
312 |
registerSelectionListener(provider, fAddTaskAction); |
| 321 |
// registerSelectionListener(provider, fCleanUp); |
313 |
// registerSelectionListener(provider, fCleanUp); |
| 322 |
|
314 |
|
| 323 |
// fKeyBindingService= keyBindingService; |
315 |
installQuickAccessAction(); |
| 324 |
// if (fKeyBindingService != null) { |
|
|
| 325 |
// fQuickAccessAction= new RefactorQuickAccessAction(null); |
| 326 |
// fKeyBindingService.registerAction(fQuickAccessAction); |
| 327 |
// } |
| 328 |
} |
316 |
} |
| 329 |
|
317 |
|
|
|
318 |
private void installQuickAccessAction() { |
| 319 |
fHandlerService= (IHandlerService)fSite.getService(IHandlerService.class); |
| 320 |
if (fHandlerService != null) { |
| 321 |
IHandler handler= new CDTQuickMenuCreator(fEditor) { |
| 322 |
@Override |
| 323 |
protected void fillMenu(IMenuManager menu) { |
| 324 |
fillQuickMenu(menu); |
| 325 |
} |
| 326 |
}.createHandler(); |
| 327 |
fQuickAccessHandlerActivation= fHandlerService.activateHandler(QUICK_MENU_ID, handler); |
| 328 |
} |
| 329 |
} |
| 330 |
|
| 330 |
private void registerSelectionListener(ISelectionProvider provider, ISelectionChangedListener listener) { |
331 |
private void registerSelectionListener(ISelectionProvider provider, ISelectionChangedListener listener) { |
| 331 |
if (fRegisteredSelectionListeners == null) |
332 |
if (fRegisteredSelectionListeners == null) |
| 332 |
fRegisteredSelectionListeners= new ArrayList<ISelectionChangedListener>(10); |
333 |
fRegisteredSelectionListeners= new ArrayList<ISelectionChangedListener>(10); |
|
Lines 361-371
Link Here
|
| 361 |
@Override |
362 |
@Override |
| 362 |
public void fillContextMenu(IMenuManager menu) { |
363 |
public void fillContextMenu(IMenuManager menu) { |
| 363 |
super.fillContextMenu(menu); |
364 |
super.fillContextMenu(menu); |
| 364 |
String menuText= ActionMessages.getString("SourceMenu_label"); //$NON-NLS-1$ |
365 |
MenuManager subMenu= new MenuManager(ActionMessages.getString("SourceMenu_label"), MENU_ID); //$NON-NLS-1$ |
| 365 |
// if (fQuickAccessAction != null) { |
366 |
subMenu.setActionDefinitionId(QUICK_MENU_ID); |
| 366 |
// menuText= fQuickAccessAction.addShortcut(menuText); |
|
|
| 367 |
// } |
| 368 |
IMenuManager subMenu= new MenuManager(menuText, MENU_ID); |
| 369 |
int added= 0; |
367 |
int added= 0; |
| 370 |
if (isEditorOwner()) { |
368 |
if (isEditorOwner()) { |
| 371 |
added= fillEditorSubMenu(subMenu); |
369 |
added= fillEditorSubMenu(subMenu); |
|
Lines 376-388
Link Here
|
| 376 |
menu.appendToGroup(fGroupName, subMenu); |
374 |
menu.appendToGroup(fGroupName, subMenu); |
| 377 |
} |
375 |
} |
| 378 |
|
376 |
|
| 379 |
// private void fillQuickMenu(IMenuManager menu) { |
377 |
private void fillQuickMenu(IMenuManager menu) { |
| 380 |
// if (isEditorOwner()) { |
378 |
if (isEditorOwner()) { |
| 381 |
// fillEditorSubMenu(menu); |
379 |
fillEditorSubMenu(menu); |
| 382 |
// } else { |
380 |
} else { |
| 383 |
// fillViewSubMenu(menu); |
381 |
fillViewSubMenu(menu); |
| 384 |
// } |
382 |
} |
| 385 |
// } |
383 |
} |
| 386 |
|
384 |
|
| 387 |
private int fillEditorSubMenu(IMenuManager source) { |
385 |
private int fillEditorSubMenu(IMenuManager source) { |
| 388 |
int added= 0; |
386 |
int added= 0; |
|
Lines 402-408
Link Here
|
| 402 |
// added+= addAction(source, fSortMembers); |
400 |
// added+= addAction(source, fSortMembers); |
| 403 |
// added+= addAction(source, fCleanUp); |
401 |
// added+= addAction(source, fCleanUp); |
| 404 |
source.add(new Separator(GROUP_GENERATE)); |
402 |
source.add(new Separator(GROUP_GENERATE)); |
| 405 |
added+= addEditorAction(source, "ContentAssistProposal"); //$NON-NLS-1$ |
|
|
| 406 |
// added+= addAction(source, fOverrideMethods); |
403 |
// added+= addAction(source, fOverrideMethods); |
| 407 |
added+= addAction(source, fAddGetterSetter); |
404 |
added+= addAction(source, fAddGetterSetter); |
| 408 |
added+= addAction(source, fImplementMethod); |
405 |
added+= addAction(source, fImplementMethod); |
|
Lines 454-462
Link Here
|
| 454 |
provider.removeSelectionChangedListener(listener); |
451 |
provider.removeSelectionChangedListener(listener); |
| 455 |
} |
452 |
} |
| 456 |
} |
453 |
} |
| 457 |
// if (fQuickAccessAction != null && fKeyBindingService != null) { |
454 |
if (fQuickAccessHandlerActivation != null && fHandlerService != null) { |
| 458 |
// fKeyBindingService.unregisterAction(fQuickAccessAction); |
455 |
fHandlerService.deactivateHandler(fQuickAccessHandlerActivation); |
| 459 |
// } |
456 |
} |
| 460 |
fEditor= null; |
457 |
fEditor= null; |
| 461 |
super.dispose(); |
458 |
super.dispose(); |
| 462 |
} |
459 |
} |