Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 177018
Collapse All | Expand All

(-)plugin.properties (-1 / +16 lines)
Lines 74-79 Link Here
74
category.source.name=C/C++ Source
74
category.source.name=C/C++ Source
75
category.source.description= C/C++ Source Actions
75
category.source.description= C/C++ Source Actions
76
76
77
ActionDefinition.sourceQuickMenu.name= Show Source Quick Menu
78
ActionDefinition.sourceQuickMenu.description= Shows the source quick menu
79
77
ActionDefinition.comment.name= Comment
80
ActionDefinition.comment.name= Comment
78
ActionDefinition.comment.description= Turn the selected lines into // style comments
81
ActionDefinition.comment.description= Turn the selected lines into // style comments
79
82
Lines 543-549 Link Here
543
preferenceKeywords.folding=editor folding section comment header function method statement preprocessor
546
preferenceKeywords.folding=editor folding section comment header function method statement preprocessor
544
preferenceKeywords.markoccurrences=editor occurrence mark highlight
547
preferenceKeywords.markoccurrences=editor occurrence mark highlight
545
preferenceKeywords.smarttyping=editor typing type close comment tabs indentation indent imports wrap escape semicolons braces brackets parenthesis parentheses strings literals paste pasting tabulator automatically
548
preferenceKeywords.smarttyping=editor typing type close comment tabs indentation indent imports wrap escape semicolons braces brackets parenthesis parentheses strings literals paste pasting tabulator automatically
549
546
historyAction.label = History...
550
historyAction.label = History...
547
createScriptAction.label = Create Script...
551
createScriptAction.label = Create Script...
548
applyScriptAction.label = Apply Script...
552
applyScriptAction.label = Apply Script...
549
renameParticipant.name = Source Folder Rename
553
renameParticipant.name = Source Folder Rename
554
555
FormatAction.label= &Format
556
IndentAction.label= Correct &Indentation
557
AddIncludeAction.label= A&dd Include
558
CommentAction.label= Co&mment
559
UncommentAction.label= &Uncomment
560
ToggleCommentAction.label= Togg&le Comment
561
AddBlockCommentAction.label= Add &Block Comment
562
RemoveBlockCommentAction.label= Remove Bloc&k Comment
563
ShiftRightAction.label= &Shift Right
564
ShiftLeftAction.label= S&hift Left
(-)plugin.xml (-22 / +153 lines)
Lines 1262-1289 Link Here
1262
               id="org.eclipse.cdt.ui.actions.ExtractLocalVariable"
1262
               id="org.eclipse.cdt.ui.actions.ExtractLocalVariable"
1263
               retarget="true">
1263
               retarget="true">
1264
         </action>
1264
         </action>
1265
        <action
1266
               definitionId="org.eclipse.cdt.ui.refactor.getters.and.setters"
1267
               label="%Refactoring.gettersAndSetters.label"
1268
               menubarPath="org.eclipse.jdt.ui.source.menu/generateGroup"
1269
               id="org.eclipse.cdt.ui.actions.GettersAndSetters"
1270
               retarget="true">
1271
         </action> 
1272
         <action
1273
               definitionId="org.eclipse.cdt.ui.refactor.implement.method"
1274
               label="%Refactoring.implementMethod.label"
1275
               menubarPath="org.eclipse.jdt.ui.source.menu/generateGroup"
1276
               id="org.eclipse.cdt.ui.actions.ImplementMethod"
1277
               retarget="true">
1278
         </action>
1279
         <action
1280
               class="org.eclipse.cdt.internal.ui.actions.SurroundWithTemplateMenuAction"
1281
               definitionId="org.eclipse.cdt.ui.edit.text.c.surround.with.quickMenu"
1282
               label="%SurroundWithTemplateAction.label"
1283
               menubarPath="org.eclipse.jdt.ui.source.menu/codeGroup"
1284
               id="org.eclipse.cdt.internal.ui.actions.SurroundWithTemplateMenuAction"
1285
               style="pulldown">
1286
         </action>
1287
         <action
1265
         <action
1288
               class="org.eclipse.ltk.ui.refactoring.actions.ShowRefactoringHistoryAction"
1266
               class="org.eclipse.ltk.ui.refactoring.actions.ShowRefactoringHistoryAction"
1289
               definitionId="org.eclipse.ltk.ui.refactor.show.refactoring.history"
1267
               definitionId="org.eclipse.ltk.ui.refactor.show.refactoring.history"
Lines 1308-1324 Link Here
1308
               menubarPath="org.eclipse.jdt.ui.refactoring.menu/historyGroup"
1286
               menubarPath="org.eclipse.jdt.ui.refactoring.menu/historyGroup"
1309
               retarget="false">
1287
               retarget="false">
1310
         </action>
1288
         </action>
1289
<!-- =========================================================================== -->
1290
<!-- Source Menu                                                                 -->
1291
<!-- =========================================================================== -->
1292
         <!-- Note: This menu layout must match the definition in org.eclipse.jdt.ui -->
1311
         <menu
1293
         <menu
1312
               id="org.eclipse.jdt.ui.source.menu"
1294
               id="org.eclipse.jdt.ui.source.menu"
1313
               label="%Source.menu.label"
1295
               label="%Source.menu.label"
1314
               path="edit">
1296
               path="edit">
1297
		    <separator
1298
                  name="commentGroup">
1299
            </separator>
1300
            <separator
1301
                  name="editGroup">
1302
            </separator>
1303
            <separator
1304
                  name="importGroup">
1305
            </separator>
1315
            <separator
1306
            <separator
1316
                  name="generateGroup">
1307
                  name="generateGroup">
1317
            </separator>
1308
            </separator>
1318
            <separator
1309
            <separator
1319
                  name="codeGroup">
1310
                  name="codeGroup">
1320
            </separator>
1311
            </separator>
1312
            <separator
1313
                  name="externalizeGroup">
1314
            </separator>
1315
            <separator
1316
                  name="convertGroup">
1317
            </separator>
1321
         </menu>
1318
         </menu>
1319
<!-- Code Group -->
1320
         <action
1321
               class="org.eclipse.cdt.internal.ui.actions.SurroundWithTemplateMenuAction"
1322
               definitionId="org.eclipse.cdt.ui.edit.text.c.surround.with.quickMenu"
1323
               label="%SurroundWithTemplateAction.label"
1324
               menubarPath="org.eclipse.jdt.ui.source.menu/codeGroup"
1325
               id="org.eclipse.cdt.internal.ui.actions.SurroundWithTemplateMenuAction"
1326
               style="pulldown">
1327
         </action>
1328
<!-- Generate Group -->
1329
        <action
1330
               definitionId="org.eclipse.cdt.ui.refactor.getters.and.setters"
1331
               label="%Refactoring.gettersAndSetters.label"
1332
               menubarPath="org.eclipse.jdt.ui.source.menu/generateGroup"
1333
               id="org.eclipse.cdt.ui.actions.GettersAndSetters"
1334
               retarget="true">
1335
         </action> 
1336
         <action
1337
               definitionId="org.eclipse.cdt.ui.refactor.implement.method"
1338
               label="%Refactoring.implementMethod.label"
1339
               menubarPath="org.eclipse.jdt.ui.source.menu/generateGroup"
1340
               id="org.eclipse.cdt.ui.actions.ImplementMethod"
1341
               retarget="true">
1342
         </action>
1343
<!-- Import Group -->
1344
         <action
1345
               definitionId="org.eclipse.cdt.ui.edit.text.c.add.include"
1346
               label="%AddIncludeAction.label"
1347
               retarget="true"
1348
               menubarPath="org.eclipse.jdt.ui.source.menu/importGroup"
1349
               id="org.eclipse.cdt.ui.actions.AddInclude">
1350
         </action>
1351
<!-- Edit group -->
1352
         <action
1353
               definitionId="org.eclipse.cdt.ui.edit.text.c.format"
1354
               label="%FormatAction.label"
1355
               retarget="true"
1356
               menubarPath="org.eclipse.jdt.ui.source.menu/editGroup"
1357
               id="org.eclipse.cdt.ui.actions.Format">
1358
         </action>
1359
         <action
1360
               definitionId="org.eclipse.cdt.ui.edit.text.c.indent"
1361
               label="%IndentAction.label"
1362
               retarget="true"
1363
               menubarPath="org.eclipse.jdt.ui.source.menu/editGroup"
1364
               id="org.eclipse.cdt.ui.actions.Indent">
1365
         </action>
1366
         <action
1367
               definitionId="org.eclipse.ui.edit.text.shiftLeft"
1368
               disabledIcon="icons/dlcl16/shift_l_edit.gif"
1369
               icon="icons/elcl16/shift_l_edit.gif"
1370
               id="org.eclipse.cdt.ui.actions.ShiftLeft"
1371
               label="%ShiftLeftAction.label"
1372
               menubarPath="org.eclipse.jdt.ui.source.menu/editGroup"
1373
               retarget="true">
1374
         </action>
1375
         <action
1376
               definitionId="org.eclipse.ui.edit.text.shiftRight"
1377
               disabledIcon="icons/dlcl16/shift_r_edit.gif"
1378
               icon="icons/elcl16/shift_r_edit.gif"
1379
               id="org.eclipse.cdt.ui.actions.ShiftRight"
1380
               label="%ShiftRightAction.label"
1381
               menubarPath="org.eclipse.jdt.ui.source.menu/editGroup"
1382
               retarget="true">
1383
         </action>
1384
<!-- Comment Group -->
1385
         <action
1386
               definitionId="org.eclipse.cdt.ui.edit.text.c.uncomment"
1387
               label="%UncommentAction.label"
1388
               retarget="true"
1389
               id="org.eclipse.cdt.ui.actions.Uncomment">
1390
         </action>
1391
         <action
1392
               definitionId="org.eclipse.cdt.ui.edit.text.c.comment"
1393
               label="%CommentAction.label"
1394
               retarget="true"
1395
               id="org.eclipse.cdt.ui.actions.Comment">
1396
         </action>
1397
         <action
1398
               definitionId="org.eclipse.cdt.ui.edit.text.c.remove.block.comment"
1399
               label="%RemoveBlockCommentAction.label"
1400
               retarget="true"
1401
               menubarPath="org.eclipse.jdt.ui.source.menu/commentGroup"
1402
               id="org.eclipse.cdt.ui.actions.RemoveBlockComment">
1403
         </action>
1404
         <action
1405
               definitionId="org.eclipse.cdt.ui.edit.text.c.add.block.comment"
1406
               label="%AddBlockCommentAction.label"
1407
               retarget="true"
1408
               menubarPath="org.eclipse.jdt.ui.source.menu/commentGroup"
1409
               id="org.eclipse.cdt.ui.actions.AddBlockComment">
1410
         </action>
1411
         <action
1412
               definitionId="org.eclipse.cdt.ui.edit.text.c.toggle.comment"
1413
               label="%ToggleCommentAction.label"
1414
               retarget="true"
1415
               menubarPath="org.eclipse.jdt.ui.source.menu/commentGroup"
1416
               id="org.eclipse.cdt.ui.actions.ToggleComment">
1417
         </action>
1322
      </actionSet>
1418
      </actionSet>
1323
      <actionSet
1419
      <actionSet
1324
            label="%CSearchActionSet.label"
1420
            label="%CSearchActionSet.label"
Lines 1569-1574 Link Here
1569
 
1665
 
1570
      <!--  win32:  M1=CTRL,    M2=SHIFT, M3=ALT, M4=-
1666
      <!--  win32:  M1=CTRL,    M2=SHIFT, M3=ALT, M4=-
1571
            carbon: M1=COMMAND, M2=SHIFT, M3=ALT, M4=CTRL -->
1667
            carbon: M1=COMMAND, M2=SHIFT, M3=ALT, M4=CTRL -->
1668
      <key
1669
            sequence="M2+M3+S"
1670
            commandId="org.eclipse.cdt.ui.edit.text.c.source.quickMenu"
1671
            schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
1672
            contextId="org.eclipse.cdt.ui.cEditorScope"/>
1673
      <key
1674
            platform="carbon"
1675
            sequence="M2+M3+S"
1676
            commandId=""
1677
            schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
1678
            contextId="org.eclipse.cdt.ui.cEditorScope"/>
1679
      <key
1680
            platform="carbon"
1681
            sequence="COMMAND+ALT+S"
1682
            commandId="org.eclipse.cdt.ui.edit.text.c.source.quickMenu"
1683
            schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
1684
            contextId="org.eclipse.cdt.ui.cEditorScope"/>
1572
   	 <key
1685
   	 <key
1573
            sequence="M1+M2+F"
1686
            sequence="M1+M2+F"
1574
            schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
1687
            schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
Lines 1985-1990 Link Here
1985
            id="org.eclipse.cdt.ui.edit.text.c.format">
2098
            id="org.eclipse.cdt.ui.edit.text.c.format">
1986
      </command>
2099
      </command>
1987
      <command
2100
      <command
2101
            name="%ActionDefinition.sourceQuickMenu.name"
2102
            description="%ActionDefinition.sourceQuickMenu.description"
2103
            categoryId="org.eclipse.cdt.ui.category.source"
2104
            id="org.eclipse.cdt.ui.edit.text.c.source.quickMenu">
2105
      </command>
2106
      <command
2107
            name="%ActionDefinition.comment.name"
2108
            description="%ActionDefinition.comment.description"
2109
            categoryId="org.eclipse.cdt.ui.category.source"
2110
            id="org.eclipse.cdt.ui.edit.text.c.comment">
2111
      </command>
2112
      <command
2113
            name="%ActionDefinition.uncomment.name"
2114
            description="%ActionDefinition.uncomment.description"
2115
            categoryId="org.eclipse.cdt.ui.category.source"
2116
            id="org.eclipse.cdt.ui.edit.text.c.uncomment">
2117
      </command>
2118
      <command
1988
            name="%ActionDefinition.toggleComment.name"
2119
            name="%ActionDefinition.toggleComment.name"
1989
            description="%ActionDefinition.toggleComment.description"
2120
            description="%ActionDefinition.toggleComment.description"
1990
            categoryId="org.eclipse.cdt.ui.category.source"
2121
            categoryId="org.eclipse.cdt.ui.category.source"
(-)src/org/eclipse/cdt/internal/ui/editor/ConstructedCEditorMessages.properties (-3 / +3 lines)
Lines 44-52 Link Here
44
ContentAssistContextInformation.tooltip=Show Parameter Hints
44
ContentAssistContextInformation.tooltip=Show Parameter Hints
45
ContentAssistContextInformation.description=Show Method Parameter Hints
45
ContentAssistContextInformation.description=Show Method Parameter Hints
46
46
47
ToggleComment.label=Comment/Uncomment
47
ToggleComment.label=Togg&le Comment
48
ToggleComment.tooltip=Comment/Uncomment For the Selected Lines
48
ToggleComment.tooltip=Toggle Comment For the Selected Lines
49
ToggleComment.description=Comment/Uncomment for the selected lines
49
ToggleComment.description=Toggle Comment for the selected lines
50
50
51
AddBlockComment.label=Add &Block Comment
51
AddBlockComment.label=Add &Block Comment
52
AddBlockComment.tooltip=Enclose the Selection in a Block Comment
52
AddBlockComment.tooltip=Enclose the Selection in a Block Comment
(-)src/org/eclipse/cdt/internal/ui/editor/CEditorActionContributor.java (-32 / +33 lines)
Lines 18-34 Link Here
18
import org.eclipse.jface.action.IAction;
18
import org.eclipse.jface.action.IAction;
19
import org.eclipse.jface.action.IMenuManager;
19
import org.eclipse.jface.action.IMenuManager;
20
import org.eclipse.jface.action.Separator;
20
import org.eclipse.jface.action.Separator;
21
import org.eclipse.jface.text.ITextOperationTarget;
22
import org.eclipse.ui.IActionBars;
21
import org.eclipse.ui.IActionBars;
23
import org.eclipse.ui.IEditorPart;
22
import org.eclipse.ui.IEditorPart;
24
import org.eclipse.ui.IWorkbenchActionConstants;
23
import org.eclipse.ui.IWorkbenchActionConstants;
25
import org.eclipse.ui.editors.text.TextEditorActionContributor;
24
import org.eclipse.ui.editors.text.TextEditorActionContributor;
25
import org.eclipse.ui.ide.IDEActionFactory;
26
import org.eclipse.ui.texteditor.ITextEditor;
26
import org.eclipse.ui.texteditor.ITextEditor;
27
import org.eclipse.ui.texteditor.ITextEditorActionConstants;
27
import org.eclipse.ui.texteditor.ITextEditorActionConstants;
28
import org.eclipse.ui.texteditor.ITextEditorActionDefinitionIds;
28
import org.eclipse.ui.texteditor.ITextEditorActionDefinitionIds;
29
import org.eclipse.ui.texteditor.RetargetTextEditorAction;
29
import org.eclipse.ui.texteditor.RetargetTextEditorAction;
30
30
31
import org.eclipse.cdt.internal.ui.CPluginImages;
31
import org.eclipse.cdt.ui.actions.CdtActionConstants;
32
32
import org.eclipse.cdt.internal.ui.IContextMenuConstants;
33
import org.eclipse.cdt.internal.ui.IContextMenuConstants;
33
import org.eclipse.cdt.internal.ui.actions.FindWordAction;
34
import org.eclipse.cdt.internal.ui.actions.FindWordAction;
34
import org.eclipse.cdt.internal.ui.actions.GoToNextPreviousMemberAction;
35
import org.eclipse.cdt.internal.ui.actions.GoToNextPreviousMemberAction;
Lines 38-47 Link Here
38
	
39
	
39
	private RetargetTextEditorAction fContentAssist;
40
	private RetargetTextEditorAction fContentAssist;
40
	private RetargetTextEditorAction fContextInformation;
41
	private RetargetTextEditorAction fContextInformation;
41
	private RetargetTextEditorAction fFormatter;
42
	private RetargetTextEditorAction fAddInclude;
43
	private RetargetTextEditorAction fShiftLeft;
44
	private RetargetTextEditorAction fShiftRight;
45
	private TogglePresentationAction fTogglePresentation;
42
	private TogglePresentationAction fTogglePresentation;
46
	private GotoAnnotationAction fPreviousAnnotation;
43
	private GotoAnnotationAction fPreviousAnnotation;
47
	private GotoAnnotationAction fNextAnnotation;
44
	private GotoAnnotationAction fNextAnnotation;
Lines 60-85 Link Here
60
		
57
		
61
		ResourceBundle bundle = ConstructedCEditorMessages.getResourceBundle();
58
		ResourceBundle bundle = ConstructedCEditorMessages.getResourceBundle();
62
	
59
	
63
		fShiftRight= new RetargetTextEditorAction(bundle, "ShiftRight.", ITextOperationTarget.SHIFT_RIGHT);		 //$NON-NLS-1$
64
		fShiftRight.setActionDefinitionId(ITextEditorActionDefinitionIds.SHIFT_RIGHT);
65
		CPluginImages.setImageDescriptors(fShiftRight, CPluginImages.T_LCL, CPluginImages.IMG_MENU_SHIFT_RIGHT);
66
67
		fShiftLeft= new RetargetTextEditorAction(bundle, "ShiftLeft.", ITextOperationTarget.SHIFT_LEFT); //$NON-NLS-1$
68
		fShiftLeft.setActionDefinitionId(ITextEditorActionDefinitionIds.SHIFT_LEFT);
69
		CPluginImages.setImageDescriptors(fShiftLeft, CPluginImages.T_LCL, CPluginImages.IMG_MENU_SHIFT_LEFT);
70
		
71
		fContentAssist = new RetargetTextEditorAction(bundle, "ContentAssistProposal."); //$NON-NLS-1$
60
		fContentAssist = new RetargetTextEditorAction(bundle, "ContentAssistProposal."); //$NON-NLS-1$
72
		fContentAssist.setActionDefinitionId(ITextEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS);
61
		fContentAssist.setActionDefinitionId(ITextEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS);
73
62
74
		fContextInformation = new RetargetTextEditorAction(bundle, "ContentAssistContextInformation."); //$NON-NLS-1$
63
		fContextInformation = new RetargetTextEditorAction(bundle, "ContentAssistContextInformation."); //$NON-NLS-1$
75
		fContextInformation.setActionDefinitionId(ITextEditorActionDefinitionIds.CONTENT_ASSIST_CONTEXT_INFORMATION);
64
		fContextInformation.setActionDefinitionId(ITextEditorActionDefinitionIds.CONTENT_ASSIST_CONTEXT_INFORMATION);
76
65
77
		fFormatter = new RetargetTextEditorAction(bundle, "Format."); //$NON-NLS-1$
78
		fFormatter.setActionDefinitionId(ICEditorActionDefinitionIds.FORMAT);
79
		
80
		fAddInclude = new RetargetTextEditorAction(bundle, "AddIncludeOnSelection."); //$NON-NLS-1$
81
		fAddInclude.setActionDefinitionId(ICEditorActionDefinitionIds.ADD_INCLUDE);
82
83
		// actions that are "contributed" to editors, they are considered belonging to the active editor
66
		// actions that are "contributed" to editors, they are considered belonging to the active editor
84
		fTogglePresentation= new TogglePresentationAction();
67
		fTogglePresentation= new TogglePresentationAction();
85
68
Lines 127-138 Link Here
127
110
128
			editMenu.prependToGroup(IWorkbenchActionConstants.FIND_EXT, fFindWord);
111
			editMenu.prependToGroup(IWorkbenchActionConstants.FIND_EXT, fFindWord);
129
112
130
			editMenu.appendToGroup(ITextEditorActionConstants.GROUP_GENERATE, fShiftRight);
113
//			editMenu.appendToGroup(ITextEditorActionConstants.GROUP_GENERATE, fShiftRight);
131
			editMenu.appendToGroup(ITextEditorActionConstants.GROUP_GENERATE, fShiftLeft);
114
//			editMenu.appendToGroup(ITextEditorActionConstants.GROUP_GENERATE, fShiftLeft);
132
			editMenu.appendToGroup(ITextEditorActionConstants.GROUP_GENERATE, fFormatter);
115
//			editMenu.appendToGroup(ITextEditorActionConstants.GROUP_GENERATE, fFormatter);
133
			editMenu.appendToGroup(ITextEditorActionConstants.GROUP_GENERATE, new Separator());
116
//			editMenu.appendToGroup(ITextEditorActionConstants.GROUP_GENERATE, new Separator());
134
			editMenu.appendToGroup(ITextEditorActionConstants.GROUP_GENERATE, fAddInclude);
117
//			editMenu.appendToGroup(ITextEditorActionConstants.GROUP_GENERATE, fAddInclude);
135
			editMenu.appendToGroup(ITextEditorActionConstants.GROUP_GENERATE, new Separator());
118
//			editMenu.appendToGroup(ITextEditorActionConstants.GROUP_GENERATE, new Separator());
136
119
137
			editMenu.appendToGroup(IContextMenuConstants.GROUP_ADDITIONS, fToggleInsertModeAction);
120
			editMenu.appendToGroup(IContextMenuConstants.GROUP_ADDITIONS, fToggleInsertModeAction);
138
		}
121
		}
Lines 183-191 Link Here
183
		if (part instanceof ITextEditor)
166
		if (part instanceof ITextEditor)
184
			textEditor= (ITextEditor) part;
167
			textEditor= (ITextEditor) part;
185
		
168
		
186
		fShiftRight.setAction(getAction(textEditor, ITextEditorActionConstants.SHIFT_RIGHT));
187
		fShiftLeft.setAction(getAction(textEditor, ITextEditorActionConstants.SHIFT_LEFT));
188
189
		fTogglePresentation.setEditor(textEditor);
169
		fTogglePresentation.setEditor(textEditor);
190
		fToggleMarkOccurrencesAction.setEditor(textEditor);
170
		fToggleMarkOccurrencesAction.setEditor(textEditor);
191
		fPreviousAnnotation.setEditor(textEditor);
171
		fPreviousAnnotation.setEditor(textEditor);
Lines 193-200 Link Here
193
173
194
		fContentAssist.setAction(getAction(textEditor, "ContentAssistProposal")); //$NON-NLS-1$
174
		fContentAssist.setAction(getAction(textEditor, "ContentAssistProposal")); //$NON-NLS-1$
195
		fContextInformation.setAction(getAction(textEditor, "ContentAssistContextInformation")); //$NON-NLS-1$
175
		fContextInformation.setAction(getAction(textEditor, "ContentAssistContextInformation")); //$NON-NLS-1$
196
		fAddInclude.setAction(getAction(textEditor, "AddIncludeOnSelection")); //$NON-NLS-1$
197
		fFormatter.setAction(getAction(textEditor, "Format")); //$NON-NLS-1$
198
176
199
		fGotoMatchingBracket.setAction(getAction(textEditor, GotoMatchingBracketAction.GOTO_MATCHING_BRACKET));
177
		fGotoMatchingBracket.setAction(getAction(textEditor, GotoMatchingBracketAction.GOTO_MATCHING_BRACKET));
200
		fGotoNextBookmark.setAction(getAction(textEditor, GotoNextBookmarkAction.NEXT_BOOKMARK));
178
		fGotoNextBookmark.setAction(getAction(textEditor, GotoNextBookmarkAction.NEXT_BOOKMARK));
Lines 206-214 Link Here
206
		fToggleInsertModeAction.setAction(getAction(textEditor, ITextEditorActionConstants.TOGGLE_INSERT_MODE));
184
		fToggleInsertModeAction.setAction(getAction(textEditor, ITextEditorActionConstants.TOGGLE_INSERT_MODE));
207
		fFindWord.setAction(getAction(textEditor, FindWordAction.FIND_WORD));
185
		fFindWord.setAction(getAction(textEditor, FindWordAction.FIND_WORD));
208
186
187
		// Source menu.
188
		IActionBars bars= getActionBars();
189
		bars.setGlobalActionHandler(CdtActionConstants.SHIFT_RIGHT, getAction(textEditor, "ShiftRight")); //$NON-NLS-1$
190
		bars.setGlobalActionHandler(CdtActionConstants.SHIFT_LEFT, getAction(textEditor, "ShiftLeft")); //$NON-NLS-1$
191
		bars.setGlobalActionHandler(CdtActionConstants.COMMENT, getAction(textEditor, "Comment")); //$NON-NLS-1$
192
		bars.setGlobalActionHandler(CdtActionConstants.UNCOMMENT, getAction(textEditor, "Uncomment")); //$NON-NLS-1$
193
		bars.setGlobalActionHandler(CdtActionConstants.TOGGLE_COMMENT, getAction(textEditor, "ToggleComment")); //$NON-NLS-1$
194
		bars.setGlobalActionHandler(CdtActionConstants.FORMAT, getAction(textEditor, "Format")); //$NON-NLS-1$
195
		bars.setGlobalActionHandler(CdtActionConstants.ADD_BLOCK_COMMENT, getAction(textEditor, "AddBlockComment")); //$NON-NLS-1$
196
		bars.setGlobalActionHandler(CdtActionConstants.REMOVE_BLOCK_COMMENT, getAction(textEditor, "RemoveBlockComment")); //$NON-NLS-1$
197
		bars.setGlobalActionHandler(CdtActionConstants.INDENT, getAction(textEditor, "Indent")); //$NON-NLS-1$
198
		bars.setGlobalActionHandler(CdtActionConstants.ADD_INCLUDE, getAction(textEditor, "AddIncludeOnSelection")); //$NON-NLS-1$
199
200
		IAction action= getAction(textEditor, ITextEditorActionConstants.REFRESH);
201
		bars.setGlobalActionHandler(ITextEditorActionConstants.REFRESH, action);
202
203
		bars.setGlobalActionHandler(IDEActionFactory.ADD_TASK.getId(), getAction(textEditor, IDEActionFactory.ADD_TASK.getId()));
204
		bars.setGlobalActionHandler(IDEActionFactory.BOOKMARK.getId(), getAction(textEditor, IDEActionFactory.BOOKMARK.getId()));
205
206
		bars.setGlobalActionHandler(IDEActionFactory.OPEN_PROJECT.getId(), getAction(textEditor, IDEActionFactory.OPEN_PROJECT.getId()));
207
		bars.setGlobalActionHandler(IDEActionFactory.CLOSE_PROJECT.getId(), getAction(textEditor, IDEActionFactory.CLOSE_PROJECT.getId()));
208
		bars.setGlobalActionHandler(IDEActionFactory.CLOSE_UNRELATED_PROJECTS.getId(), getAction(textEditor, IDEActionFactory.CLOSE_UNRELATED_PROJECTS.getId()));
209
209
		if (part instanceof CEditor) {
210
		if (part instanceof CEditor) {
210
			CEditor cEditor= (CEditor) part;
211
			CEditor cEditor= (CEditor) part;
211
			cEditor.fillActionBars(getActionBars());
212
			cEditor.fillActionBars(bars);
212
		}
213
		}
213
214
214
	}
215
	}
(-)src/org/eclipse/cdt/ui/actions/GenerateActionGroup.java (-45 / +42 lines)
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
	}
(-)src/org/eclipse/cdt/internal/ui/actions/CDTQuickMenuCreator.java (+109 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 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) - Ported to CDT
11
 *******************************************************************************/
12
package org.eclipse.cdt.internal.ui.actions;
13
14
import org.eclipse.swt.custom.StyledText;
15
import org.eclipse.swt.graphics.Point;
16
17
import org.eclipse.core.commands.AbstractHandler;
18
import org.eclipse.core.commands.ExecutionEvent;
19
import org.eclipse.core.commands.ExecutionException;
20
import org.eclipse.core.commands.IHandler;
21
22
import org.eclipse.jface.text.IRegion;
23
import org.eclipse.jface.text.ITextSelection;
24
import org.eclipse.jface.text.ITextViewerExtension5;
25
import org.eclipse.jface.text.Region;
26
import org.eclipse.jface.text.source.ISourceViewer;
27
28
import org.eclipse.ui.actions.QuickMenuCreator;
29
30
import org.eclipse.cdt.internal.ui.editor.CEditor;
31
import org.eclipse.cdt.internal.ui.text.CWordFinder;
32
33
/**
34
 * C/C++ editor aware quick menu creator. In the given editor, the menu will be aligned with the word
35
 * at the current offset.
36
 * 
37
 * @since 5.2
38
 */
39
public abstract class CDTQuickMenuCreator extends QuickMenuCreator {
40
41
	private final CEditor fEditor;
42
43
	/**
44
	 * Create a CDT quick menu creator
45
	 * @param editor a Java editor, or <code>null</code> if none
46
	 */
47
	public CDTQuickMenuCreator(CEditor editor) {
48
		fEditor= editor;
49
	}
50
51
	@Override
52
	protected Point computeMenuLocation(StyledText text) {
53
		if (fEditor == null || text != fEditor.getViewer().getTextWidget())
54
			return super.computeMenuLocation(text);
55
		return computeWordStart();
56
	}
57
58
	private Point computeWordStart() {
59
		ITextSelection selection= (ITextSelection)fEditor.getSelectionProvider().getSelection();
60
		IRegion textRegion= CWordFinder.findWord(fEditor.getViewer().getDocument(), selection.getOffset());
61
		if (textRegion == null)
62
			return null;
63
64
		IRegion widgetRegion= modelRange2WidgetRange(textRegion);
65
		if (widgetRegion == null)
66
			return null;
67
68
		int start= widgetRegion.getOffset();
69
70
		StyledText styledText= fEditor.getViewer().getTextWidget();
71
		Point result= styledText.getLocationAtOffset(start);
72
		result.y+= styledText.getLineHeight(start);
73
74
		if (!styledText.getClientArea().contains(result))
75
			return null;
76
		return result;
77
	}
78
79
	private IRegion modelRange2WidgetRange(IRegion region) {
80
		ISourceViewer viewer= fEditor.getViewer();
81
		if (viewer instanceof ITextViewerExtension5) {
82
			ITextViewerExtension5 extension= (ITextViewerExtension5)viewer;
83
			return extension.modelRange2WidgetRange(region);
84
		}
85
86
		IRegion visibleRegion= viewer.getVisibleRegion();
87
		int start= region.getOffset() - visibleRegion.getOffset();
88
		int end= start + region.getLength();
89
		if (end > visibleRegion.getLength())
90
			end= visibleRegion.getLength();
91
92
		return new Region(start, end - start);
93
	}
94
95
	/**
96
	 * Returns a handler that can create and open the quick menu.
97
	 * 
98
	 * @return a handler that can create and open the quick menu
99
	 */
100
	public IHandler createHandler() {
101
		return new AbstractHandler() {
102
			public Object execute(ExecutionEvent event) throws ExecutionException {
103
				createMenu();
104
				return null;
105
			}
106
		};
107
	}
108
109
}

Return to bug 177018