mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-08 18:26:01 +02:00
Fix for [Bug 54323] Refactor: Menu item from outline view
This commit is contained in:
parent
a5f8faffc5
commit
e74475bdbe
19 changed files with 511 additions and 471 deletions
|
@ -1,3 +1,6 @@
|
||||||
|
2004-03-15 Hoda Amer
|
||||||
|
Fix for [Bug 54323] Refactor: Menu item from outline view
|
||||||
|
|
||||||
2004-03-15 Alain Magloire
|
2004-03-15 Alain Magloire
|
||||||
|
|
||||||
The (Re)Build action were always disable.
|
The (Re)Build action were always disable.
|
||||||
|
|
|
@ -102,7 +102,7 @@ refactoringMenu.label= Re&factor
|
||||||
# Refactoring
|
# Refactoring
|
||||||
Refactoring.renameAction.label= Re&name
|
Refactoring.renameAction.label= Re&name
|
||||||
Refactoring.undoAction.label= &Undo
|
Refactoring.undoAction.label= &Undo
|
||||||
Refactoring.redoAction.label= Re&do
|
Refactoring.redoAction.label= &Redo
|
||||||
|
|
||||||
# Open Type
|
# Open Type
|
||||||
OpenTypeAction.label= Open &Type...
|
OpenTypeAction.label= Open &Type...
|
||||||
|
|
|
@ -160,35 +160,35 @@
|
||||||
id="org.eclipse.cdt.ui.ceditor"
|
id="org.eclipse.cdt.ui.ceditor"
|
||||||
point="org.eclipse.ui.editors">
|
point="org.eclipse.ui.editors">
|
||||||
<editor
|
<editor
|
||||||
default="true"
|
|
||||||
name="%CEditor.name"
|
name="%CEditor.name"
|
||||||
extensions="c, cc, cpp, cxx"
|
default="true"
|
||||||
icon="icons/full/obj16/c_file_obj.gif"
|
icon="icons/full/obj16/c_file_obj.gif"
|
||||||
class="org.eclipse.cdt.internal.ui.editor.CEditor"
|
extensions="c, cc, cpp, cxx"
|
||||||
contributorClass="org.eclipse.cdt.internal.ui.editor.CEditorActionContributor"
|
contributorClass="org.eclipse.cdt.internal.ui.editor.CEditorActionContributor"
|
||||||
|
class="org.eclipse.cdt.internal.ui.editor.CEditor"
|
||||||
id="org.eclipse.cdt.ui.editor.CEditor">
|
id="org.eclipse.cdt.ui.editor.CEditor">
|
||||||
</editor>
|
</editor>
|
||||||
<editor
|
<editor
|
||||||
default="true"
|
|
||||||
name="%CEditor.name"
|
name="%CEditor.name"
|
||||||
extensions="h, hh, hpp"
|
default="true"
|
||||||
icon="icons/full/obj16/h_file_obj.gif"
|
icon="icons/full/obj16/h_file_obj.gif"
|
||||||
class="org.eclipse.cdt.internal.ui.editor.CEditor"
|
extensions="h, hh, hpp"
|
||||||
contributorClass="org.eclipse.cdt.internal.ui.editor.CEditorActionContributor"
|
contributorClass="org.eclipse.cdt.internal.ui.editor.CEditorActionContributor"
|
||||||
|
class="org.eclipse.cdt.internal.ui.editor.CEditor"
|
||||||
id="org.eclipse.cdt.ui.editor.CEditor">
|
id="org.eclipse.cdt.ui.editor.CEditor">
|
||||||
</editor>
|
</editor>
|
||||||
<editor
|
<editor
|
||||||
name="%Editors.DefaultTextEditor"
|
name="%Editors.DefaultTextEditor"
|
||||||
extensions="mk"
|
|
||||||
icon="icons/full/obj16/file_obj.gif"
|
icon="icons/full/obj16/file_obj.gif"
|
||||||
class="org.eclipse.ui.editors.text.TextEditor"
|
extensions="mk"
|
||||||
contributorClass="org.eclipse.ui.texteditor.BasicTextEditorActionContributor"
|
contributorClass="org.eclipse.ui.texteditor.BasicTextEditorActionContributor"
|
||||||
|
class="org.eclipse.ui.editors.text.TextEditor"
|
||||||
id="org.eclipse.ui.DefaultTextEditor">
|
id="org.eclipse.ui.DefaultTextEditor">
|
||||||
</editor>
|
</editor>
|
||||||
<editor
|
<editor
|
||||||
name="%AsmEditor.name"
|
name="%AsmEditor.name"
|
||||||
extensions="s"
|
|
||||||
icon="icons/full/obj16/c_file_obj.gif"
|
icon="icons/full/obj16/c_file_obj.gif"
|
||||||
|
extensions="s"
|
||||||
class="org.eclipse.cdt.internal.ui.editor.asm.AsmTextEditor"
|
class="org.eclipse.cdt.internal.ui.editor.asm.AsmTextEditor"
|
||||||
id="org.eclipse.cdt.ui.editor.asm.AsmEditor">
|
id="org.eclipse.cdt.ui.editor.asm.AsmEditor">
|
||||||
</editor>
|
</editor>
|
||||||
|
@ -257,16 +257,16 @@
|
||||||
<action
|
<action
|
||||||
label="%AddTask.label"
|
label="%AddTask.label"
|
||||||
helpContextId="org.eclipse.ui.AddTask_action_context"
|
helpContextId="org.eclipse.ui.AddTask_action_context"
|
||||||
class="org.eclipse.ui.texteditor.TaskRulerAction"
|
|
||||||
tooltip="%AddTask.tooltip"
|
tooltip="%AddTask.tooltip"
|
||||||
|
class="org.eclipse.ui.texteditor.TaskRulerAction"
|
||||||
menubarPath="add"
|
menubarPath="add"
|
||||||
id="org.eclipse.ui.texteditor.TaskRulerAction">
|
id="org.eclipse.ui.texteditor.TaskRulerAction">
|
||||||
</action>
|
</action>
|
||||||
<action
|
<action
|
||||||
label="%AddBookmark.label"
|
label="%AddBookmark.label"
|
||||||
helpContextId="org.eclipse.ui.bookmark_action_context"
|
helpContextId="org.eclipse.ui.bookmark_action_context"
|
||||||
class="org.eclipse.ui.texteditor.BookmarkRulerAction"
|
|
||||||
tooltip="%AddBookmark.tooltip"
|
tooltip="%AddBookmark.tooltip"
|
||||||
|
class="org.eclipse.ui.texteditor.BookmarkRulerAction"
|
||||||
menubarPath="add"
|
menubarPath="add"
|
||||||
id="org.eclipse.ui.texteditor.BookmarkRulerAction">
|
id="org.eclipse.ui.texteditor.BookmarkRulerAction">
|
||||||
</action>
|
</action>
|
||||||
|
@ -277,49 +277,20 @@
|
||||||
<action
|
<action
|
||||||
label="%AddTask.label"
|
label="%AddTask.label"
|
||||||
helpContextId="org.eclipse.ui.AddTask_action_context"
|
helpContextId="org.eclipse.ui.AddTask_action_context"
|
||||||
class="org.eclipse.ui.texteditor.TaskRulerAction"
|
|
||||||
tooltip="%AddTask.tooltip"
|
tooltip="%AddTask.tooltip"
|
||||||
|
class="org.eclipse.ui.texteditor.TaskRulerAction"
|
||||||
menubarPath="add"
|
menubarPath="add"
|
||||||
id="org.eclipse.ui.texteditor.TaskRulerAction">
|
id="org.eclipse.ui.texteditor.TaskRulerAction">
|
||||||
</action>
|
</action>
|
||||||
<action
|
<action
|
||||||
label="%AddBookmark.label"
|
label="%AddBookmark.label"
|
||||||
helpContextId="org.eclipse.ui.bookmark_action_context"
|
helpContextId="org.eclipse.ui.bookmark_action_context"
|
||||||
class="org.eclipse.ui.texteditor.BookmarkRulerAction"
|
|
||||||
tooltip="%AddBookmark.tooltip"
|
tooltip="%AddBookmark.tooltip"
|
||||||
|
class="org.eclipse.ui.texteditor.BookmarkRulerAction"
|
||||||
menubarPath="add"
|
menubarPath="add"
|
||||||
id="org.eclipse.ui.texteditor.BookmarkRulerAction">
|
id="org.eclipse.ui.texteditor.BookmarkRulerAction">
|
||||||
</action>
|
</action>
|
||||||
</viewerContribution>
|
</viewerContribution>
|
||||||
<viewerContribution
|
|
||||||
targetID="org.eclipse.cdt.ui.CView"
|
|
||||||
id="org.eclipse.cdt.ui.refactoringControbution">
|
|
||||||
<menu
|
|
||||||
label="%refactoringMenu.label"
|
|
||||||
id="org.eclipse.cdt.ui.refactoring.menu">
|
|
||||||
<separator
|
|
||||||
name="reorgGroup">
|
|
||||||
</separator>
|
|
||||||
</menu>
|
|
||||||
<action
|
|
||||||
label="%Refactoring.renameAction.label"
|
|
||||||
class="org.eclipse.cdt.ui.refactoring.RenameAction"
|
|
||||||
menubarPath="org.eclipse.cdt.ui.refactoring.menu/reorgGroup"
|
|
||||||
id="org.eclipse.cdt.ui.actions.refactor.Rename">
|
|
||||||
</action>
|
|
||||||
<action
|
|
||||||
label="%Refactoring.undoAction.label"
|
|
||||||
class="org.eclipse.cdt.ui.refactoring.UndoAction"
|
|
||||||
menubarPath="org.eclipse.cdt.ui.refactoring.menu/reorgGroup"
|
|
||||||
id="org.eclipse.cdt.ui.actions.refactor.Undo">
|
|
||||||
</action>
|
|
||||||
<action
|
|
||||||
label="%Refactoring.redoAction.label"
|
|
||||||
class="org.eclipse.cdt.ui.refactoring.RedoAction"
|
|
||||||
menubarPath="org.eclipse.cdt.ui.refactoring.menu/reorgGroup"
|
|
||||||
id="org.eclipse.cdt.ui.actions.refactor.Redo">
|
|
||||||
</action>
|
|
||||||
</viewerContribution>
|
|
||||||
</extension>
|
</extension>
|
||||||
<extension
|
<extension
|
||||||
point="org.eclipse.compare.structureCreators">
|
point="org.eclipse.compare.structureCreators">
|
||||||
|
@ -345,24 +316,24 @@
|
||||||
<action
|
<action
|
||||||
label="%OpenNewFileWizardAction.label"
|
label="%OpenNewFileWizardAction.label"
|
||||||
icon="icons/full/ctool16/newfile_wiz.gif"
|
icon="icons/full/ctool16/newfile_wiz.gif"
|
||||||
class="org.eclipse.cdt.internal.ui.wizards.OpenNewFileWizardAction"
|
|
||||||
tooltip="%OpenNewFileWizardAction.tooltip"
|
tooltip="%OpenNewFileWizardAction.tooltip"
|
||||||
|
class="org.eclipse.cdt.internal.ui.wizards.OpenNewFileWizardAction"
|
||||||
toolbarPath="Normal/FolderWizards"
|
toolbarPath="Normal/FolderWizards"
|
||||||
id="org.eclipse.cdt.ui.actions.OpenNewFileWizardAction">
|
id="org.eclipse.cdt.ui.actions.OpenNewFileWizardAction">
|
||||||
</action>
|
</action>
|
||||||
<action
|
<action
|
||||||
label="%OpenNewFolderWizardAction.label"
|
label="%OpenNewFolderWizardAction.label"
|
||||||
icon="icons/full/ctool16/newfolder_wiz.gif"
|
icon="icons/full/ctool16/newfolder_wiz.gif"
|
||||||
class="org.eclipse.cdt.internal.ui.wizards.OpenNewFolderWizardAction"
|
|
||||||
tooltip="%OpenNewFolderWizardAction.tooltip"
|
tooltip="%OpenNewFolderWizardAction.tooltip"
|
||||||
|
class="org.eclipse.cdt.internal.ui.wizards.OpenNewFolderWizardAction"
|
||||||
toolbarPath="Normal/FolderWizards"
|
toolbarPath="Normal/FolderWizards"
|
||||||
id="org.eclipse.cdt.ui.actions.OpenNewFolderWizardAction">
|
id="org.eclipse.cdt.ui.actions.OpenNewFolderWizardAction">
|
||||||
</action>
|
</action>
|
||||||
<action
|
<action
|
||||||
label="%OpenClassWizardAction.label"
|
label="%OpenClassWizardAction.label"
|
||||||
icon="icons/full/ctool16/newclass_wiz.gif"
|
icon="icons/full/ctool16/newclass_wiz.gif"
|
||||||
class="org.eclipse.cdt.ui.actions.OpenClassWizardAction"
|
|
||||||
tooltip="%OpenClassWizardAction.tooltip"
|
tooltip="%OpenClassWizardAction.tooltip"
|
||||||
|
class="org.eclipse.cdt.ui.actions.OpenClassWizardAction"
|
||||||
toolbarPath="Normal/FolderWizards"
|
toolbarPath="Normal/FolderWizards"
|
||||||
id="org.eclipse.cdt.ui.actions.OpenClassWizardAction">
|
id="org.eclipse.cdt.ui.actions.OpenClassWizardAction">
|
||||||
<enablement>
|
<enablement>
|
||||||
|
@ -403,8 +374,8 @@
|
||||||
</category>
|
</category>
|
||||||
<command
|
<command
|
||||||
name="%ActionDefinition.comment.name"
|
name="%ActionDefinition.comment.name"
|
||||||
category="org.eclipse.cdt.ui.category.source"
|
|
||||||
description="%ActionDefinition.comment.description"
|
description="%ActionDefinition.comment.description"
|
||||||
|
category="org.eclipse.cdt.ui.category.source"
|
||||||
id="org.eclipse.cdt.ui.edit.text.c.comment">
|
id="org.eclipse.cdt.ui.edit.text.c.comment">
|
||||||
</command>
|
</command>
|
||||||
<keyBinding
|
<keyBinding
|
||||||
|
@ -415,8 +386,8 @@
|
||||||
</keyBinding>
|
</keyBinding>
|
||||||
<command
|
<command
|
||||||
name="%ActionDefinition.uncomment.name"
|
name="%ActionDefinition.uncomment.name"
|
||||||
category="org.eclipse.cdt.ui.category.source"
|
|
||||||
description="%ActionDefinition.uncomment.description"
|
description="%ActionDefinition.uncomment.description"
|
||||||
|
category="org.eclipse.cdt.ui.category.source"
|
||||||
id="org.eclipse.cdt.ui.edit.text.c.uncomment">
|
id="org.eclipse.cdt.ui.edit.text.c.uncomment">
|
||||||
</command>
|
</command>
|
||||||
<keyBinding
|
<keyBinding
|
||||||
|
@ -427,8 +398,8 @@
|
||||||
</keyBinding>
|
</keyBinding>
|
||||||
<command
|
<command
|
||||||
name="%ActionDefinition.opendecl.name"
|
name="%ActionDefinition.opendecl.name"
|
||||||
category="org.eclipse.cdt.ui.category.source"
|
|
||||||
description="%ActionDefinition.opendecl.description"
|
description="%ActionDefinition.opendecl.description"
|
||||||
|
category="org.eclipse.cdt.ui.category.source"
|
||||||
id="org.eclipse.cdt.ui.edit.opendecl">
|
id="org.eclipse.cdt.ui.edit.opendecl">
|
||||||
</command>
|
</command>
|
||||||
<keyBinding
|
<keyBinding
|
||||||
|
@ -439,8 +410,8 @@
|
||||||
</keyBinding>
|
</keyBinding>
|
||||||
<command
|
<command
|
||||||
name="%ActionDefinition.openType.name"
|
name="%ActionDefinition.openType.name"
|
||||||
category="org.eclipse.cdt.ui.category.source"
|
|
||||||
description="%ActionDefinition.openType.description"
|
description="%ActionDefinition.openType.description"
|
||||||
|
category="org.eclipse.cdt.ui.category.source"
|
||||||
id="org.eclipse.cdt.ui.navigate.opentype">
|
id="org.eclipse.cdt.ui.navigate.opentype">
|
||||||
</command>
|
</command>
|
||||||
<keyBinding
|
<keyBinding
|
||||||
|
@ -451,8 +422,8 @@
|
||||||
</keyBinding>
|
</keyBinding>
|
||||||
<command
|
<command
|
||||||
name="%ActionDefinition.opencview.name"
|
name="%ActionDefinition.opencview.name"
|
||||||
description="%ActionDefinition.opencview.description"
|
|
||||||
category="org.eclipse.cdt.ui.category.source"
|
category="org.eclipse.cdt.ui.category.source"
|
||||||
|
description="%ActionDefinition.opencview.description"
|
||||||
id="org.eclipse.cdt.ui.edit.opencview">
|
id="org.eclipse.cdt.ui.edit.opencview">
|
||||||
</command>
|
</command>
|
||||||
</extension>
|
</extension>
|
||||||
|
@ -463,8 +434,8 @@
|
||||||
<page
|
<page
|
||||||
showScopeSection="true"
|
showScopeSection="true"
|
||||||
label="%CSearchPage.label"
|
label="%CSearchPage.label"
|
||||||
extensions="c:90,cpp:90, cxx:90, cc:90,C:90, h:90, hh:90, hpp:90, H:90"
|
|
||||||
icon="icons/full/obj16/csearch_obj.gif"
|
icon="icons/full/obj16/csearch_obj.gif"
|
||||||
|
extensions="c:90,cpp:90, cxx:90, cc:90,C:90, h:90, hh:90, hpp:90, H:90"
|
||||||
class="org.eclipse.cdt.internal.ui.search.CSearchPage"
|
class="org.eclipse.cdt.internal.ui.search.CSearchPage"
|
||||||
sizeHint="460, 160"
|
sizeHint="460, 160"
|
||||||
id="org.eclipse.cdt.ui.CSearchPage">
|
id="org.eclipse.cdt.ui.CSearchPage">
|
||||||
|
@ -476,24 +447,24 @@
|
||||||
pageId="org.eclipse.cdt.ui.CSearchPage"
|
pageId="org.eclipse.cdt.ui.CSearchPage"
|
||||||
label="%ElementNameSorter.label"
|
label="%ElementNameSorter.label"
|
||||||
icon="icons/full/clcl16/search_sortmatch.gif"
|
icon="icons/full/clcl16/search_sortmatch.gif"
|
||||||
class="org.eclipse.cdt.internal.ui.search.ElementNameSorter"
|
|
||||||
tooltip="%ElementNameSorter.tooltip"
|
tooltip="%ElementNameSorter.tooltip"
|
||||||
|
class="org.eclipse.cdt.internal.ui.search.ElementNameSorter"
|
||||||
id="org.eclipse.cdt.search.internal.ui.ElementNameSorter">
|
id="org.eclipse.cdt.search.internal.ui.ElementNameSorter">
|
||||||
</sorter>
|
</sorter>
|
||||||
<sorter
|
<sorter
|
||||||
pageId="org.eclipse.cdt.ui.CSearchPage"
|
pageId="org.eclipse.cdt.ui.CSearchPage"
|
||||||
label="%ParentNameSorter.label"
|
label="%ParentNameSorter.label"
|
||||||
icon="icons/full/clcl16/search_sortmatch.gif"
|
icon="icons/full/clcl16/search_sortmatch.gif"
|
||||||
class="org.eclipse.cdt.internal.ui.search.ParentNameSorter"
|
|
||||||
tooltip="%ParentNameSorter.tooltip"
|
tooltip="%ParentNameSorter.tooltip"
|
||||||
|
class="org.eclipse.cdt.internal.ui.search.ParentNameSorter"
|
||||||
id="org.eclipse.cdt.search.internal.ui.ParentNameSorter">
|
id="org.eclipse.cdt.search.internal.ui.ParentNameSorter">
|
||||||
</sorter>
|
</sorter>
|
||||||
<sorter
|
<sorter
|
||||||
pageId="org.eclipse.cdt.ui.CSearchPage"
|
pageId="org.eclipse.cdt.ui.CSearchPage"
|
||||||
label="%PathNameSorter.label"
|
label="%PathNameSorter.label"
|
||||||
icon="icons/full/clcl16/search_sortmatch.gif"
|
icon="icons/full/clcl16/search_sortmatch.gif"
|
||||||
class="org.eclipse.cdt.internal.ui.search.PathNameSorter"
|
|
||||||
tooltip="%PathNameSorter.tooltip"
|
tooltip="%PathNameSorter.tooltip"
|
||||||
|
class="org.eclipse.cdt.internal.ui.search.PathNameSorter"
|
||||||
id="org.eclipse.cdt.search.internal.ui.PathNameSorter">
|
id="org.eclipse.cdt.search.internal.ui.PathNameSorter">
|
||||||
</sorter>
|
</sorter>
|
||||||
</extension>
|
</extension>
|
||||||
|
@ -546,16 +517,16 @@
|
||||||
<extension
|
<extension
|
||||||
point="org.eclipse.cdt.ui.BinaryParserPage">
|
point="org.eclipse.cdt.ui.BinaryParserPage">
|
||||||
<parserPage
|
<parserPage
|
||||||
class="org.eclipse.cdt.ui.dialogs.GNUElfBinaryParserPage"
|
|
||||||
parserID="org.eclipse.cdt.core.GNU_ELF"
|
parserID="org.eclipse.cdt.core.GNU_ELF"
|
||||||
|
class="org.eclipse.cdt.ui.dialogs.GNUElfBinaryParserPage"
|
||||||
id="ElfBinaryParserPage">
|
id="ElfBinaryParserPage">
|
||||||
</parserPage>
|
</parserPage>
|
||||||
</extension>
|
</extension>
|
||||||
<extension
|
<extension
|
||||||
point="org.eclipse.cdt.ui.BinaryParserPage">
|
point="org.eclipse.cdt.ui.BinaryParserPage">
|
||||||
<parserPage
|
<parserPage
|
||||||
class="org.eclipse.cdt.ui.dialogs.CygwinPEBinaryParserPage"
|
|
||||||
parserID="org.eclipse.cdt.core.Cygwin_PE"
|
parserID="org.eclipse.cdt.core.Cygwin_PE"
|
||||||
|
class="org.eclipse.cdt.ui.dialogs.CygwinPEBinaryParserPage"
|
||||||
id="PEBinaryParserPage">
|
id="PEBinaryParserPage">
|
||||||
</parserPage>
|
</parserPage>
|
||||||
</extension>
|
</extension>
|
||||||
|
@ -579,4 +550,5 @@
|
||||||
</description>
|
</description>
|
||||||
</fontDefinition>
|
</fontDefinition>
|
||||||
</extension>
|
</extension>
|
||||||
|
|
||||||
</plugin>
|
</plugin>
|
||||||
|
|
|
@ -70,7 +70,7 @@ public class UndoManager implements IUndoManager {
|
||||||
case ICElement.C_CCONTAINER:
|
case ICElement.C_CCONTAINER:
|
||||||
// If we did something different than changing a child we flush the the undo / redo stack.
|
// If we did something different than changing a child we flush the the undo / redo stack.
|
||||||
if (kind != ICElementDelta.CHANGED
|
if (kind != ICElementDelta.CHANGED
|
||||||
|| ((details & ICElementDelta.F_CHILDREN) == 0)) {
|
&& ((details & ICElementDelta.F_CHILDREN) == 0)) {
|
||||||
flush();
|
flush();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -383,6 +383,10 @@ public class RenameElementProcessor extends RenameProcessor implements IReferenc
|
||||||
orPattern.addPattern(SearchEngine.createSearchPattern( searchPrefix,
|
orPattern.addPattern(SearchEngine.createSearchPattern( searchPrefix,
|
||||||
ICSearchConstants.FUNCTION, ICSearchConstants.REFERENCES, false ));
|
ICSearchConstants.FUNCTION, ICSearchConstants.REFERENCES, false ));
|
||||||
}
|
}
|
||||||
|
else if(fCElement instanceof IEnumeration){
|
||||||
|
orPattern.addPattern(SearchEngine.createSearchPattern( searchPrefix,
|
||||||
|
ICSearchConstants.ENUM, ICSearchConstants.REFERENCES, false ));
|
||||||
|
}
|
||||||
else if(fCElement instanceof IField){
|
else if(fCElement instanceof IField){
|
||||||
orPattern.addPattern(SearchEngine.createSearchPattern( searchPrefix,
|
orPattern.addPattern(SearchEngine.createSearchPattern( searchPrefix,
|
||||||
ICSearchConstants.FIELD, ICSearchConstants.REFERENCES, false ));
|
ICSearchConstants.FIELD, ICSearchConstants.REFERENCES, false ));
|
||||||
|
@ -395,10 +399,6 @@ public class RenameElementProcessor extends RenameProcessor implements IReferenc
|
||||||
orPattern.addPattern(SearchEngine.createSearchPattern( searchPrefix,
|
orPattern.addPattern(SearchEngine.createSearchPattern( searchPrefix,
|
||||||
ICSearchConstants.NAMESPACE, ICSearchConstants.REFERENCES, false ));
|
ICSearchConstants.NAMESPACE, ICSearchConstants.REFERENCES, false ));
|
||||||
}
|
}
|
||||||
else if(fCElement instanceof IEnumeration){
|
|
||||||
orPattern.addPattern(SearchEngine.createSearchPattern( searchPrefix,
|
|
||||||
ICSearchConstants.ENUM, ICSearchConstants.REFERENCES, false ));
|
|
||||||
}
|
|
||||||
else {
|
else {
|
||||||
orPattern.addPattern(SearchEngine.createSearchPattern( searchPrefix,
|
orPattern.addPattern(SearchEngine.createSearchPattern( searchPrefix,
|
||||||
ICSearchConstants.UNKNOWN_SEARCH_FOR, ICSearchConstants.REFERENCES, false ));
|
ICSearchConstants.UNKNOWN_SEARCH_FOR, ICSearchConstants.REFERENCES, false ));
|
||||||
|
|
|
@ -13,26 +13,33 @@ package org.eclipse.cdt.internal.ui.refactoring.actions;
|
||||||
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
|
|
||||||
import org.eclipse.core.runtime.IProgressMonitor;
|
|
||||||
|
|
||||||
import org.eclipse.jface.action.IAction;
|
|
||||||
import org.eclipse.jface.operation.IRunnableWithProgress;
|
|
||||||
import org.eclipse.jface.viewers.ISelection;
|
|
||||||
|
|
||||||
import org.eclipse.cdt.core.model.CModelException;
|
import org.eclipse.cdt.core.model.CModelException;
|
||||||
|
|
||||||
import org.eclipse.cdt.internal.corext.refactoring.base.ChangeAbortException;
|
import org.eclipse.cdt.internal.corext.refactoring.base.ChangeAbortException;
|
||||||
import org.eclipse.cdt.internal.corext.refactoring.base.ChangeContext;
|
import org.eclipse.cdt.internal.corext.refactoring.base.ChangeContext;
|
||||||
import org.eclipse.cdt.internal.corext.refactoring.base.IUndoManager;
|
import org.eclipse.cdt.internal.corext.refactoring.base.IUndoManager;
|
||||||
import org.eclipse.cdt.internal.corext.refactoring.base.Refactoring;
|
import org.eclipse.cdt.internal.corext.refactoring.base.Refactoring;
|
||||||
import org.eclipse.cdt.internal.corext.refactoring.base.UndoManagerAdapter;
|
import org.eclipse.cdt.internal.corext.refactoring.base.UndoManagerAdapter;
|
||||||
|
import org.eclipse.cdt.internal.ui.editor.CEditor;
|
||||||
import org.eclipse.cdt.internal.ui.refactoring.RefactoringMessages;
|
import org.eclipse.cdt.internal.ui.refactoring.RefactoringMessages;
|
||||||
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
|
import org.eclipse.jface.action.IAction;
|
||||||
|
import org.eclipse.jface.operation.IRunnableWithProgress;
|
||||||
|
import org.eclipse.jface.viewers.ISelection;
|
||||||
|
import org.eclipse.ui.IWorkbenchSite;
|
||||||
|
|
||||||
public class RedoRefactoringAction extends UndoManagerAction {
|
public class RedoRefactoringAction extends UndoManagerAction {
|
||||||
|
|
||||||
private int fPatternLength;
|
private int fPatternLength;
|
||||||
|
private CEditor fEditor;
|
||||||
|
|
||||||
public RedoRefactoringAction() {
|
public RedoRefactoringAction(CEditor editor) {
|
||||||
|
this(editor.getEditorSite());
|
||||||
|
fEditor= editor;
|
||||||
|
}
|
||||||
|
|
||||||
|
public RedoRefactoringAction(IWorkbenchSite site) {
|
||||||
|
super(site);
|
||||||
|
init(site.getWorkbenchWindow());
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
@ -86,11 +93,17 @@ public class RedoRefactoringAction extends UndoManagerAction {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* Method declared in IActionDelegate
|
*/
|
||||||
|
public void selectionChanged(ISelection s) {
|
||||||
|
selectionChanged(this, s);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
*/
|
*/
|
||||||
public void selectionChanged(IAction action, ISelection s) {
|
public void selectionChanged(IAction action, ISelection s) {
|
||||||
// if (!isHooked()) {
|
if (!isHooked()) {
|
||||||
hookListener(action);
|
hookListener(action);
|
||||||
|
}
|
||||||
fPatternLength= RefactoringMessages.getString("RedoRefactoringAction.extendedLabel").length(); //$NON-NLS-1$
|
fPatternLength= RefactoringMessages.getString("RedoRefactoringAction.extendedLabel").length(); //$NON-NLS-1$
|
||||||
IUndoManager undoManager = Refactoring.getUndoManager();
|
IUndoManager undoManager = Refactoring.getUndoManager();
|
||||||
if (undoManager.anythingToRedo()) {
|
if (undoManager.anythingToRedo()) {
|
||||||
|
@ -100,7 +113,6 @@ public class RedoRefactoringAction extends UndoManagerAction {
|
||||||
} else {
|
} else {
|
||||||
action.setEnabled(false);
|
action.setEnabled(false);
|
||||||
}
|
}
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getActionText() {
|
private String getActionText() {
|
||||||
|
|
|
@ -12,6 +12,7 @@ package org.eclipse.cdt.internal.ui.refactoring.actions;
|
||||||
|
|
||||||
|
|
||||||
import org.eclipse.cdt.internal.corext.refactoring.RenameRefactoring;
|
import org.eclipse.cdt.internal.corext.refactoring.RenameRefactoring;
|
||||||
|
import org.eclipse.cdt.internal.ui.editor.CEditor;
|
||||||
import org.eclipse.cdt.internal.ui.refactoring.RefactoringMessages;
|
import org.eclipse.cdt.internal.ui.refactoring.RefactoringMessages;
|
||||||
import org.eclipse.cdt.internal.ui.refactoring.UserInterfaceStarter;
|
import org.eclipse.cdt.internal.ui.refactoring.UserInterfaceStarter;
|
||||||
import org.eclipse.cdt.internal.ui.util.ExceptionHandler;
|
import org.eclipse.cdt.internal.ui.util.ExceptionHandler;
|
||||||
|
@ -27,6 +28,13 @@ import org.eclipse.ui.IWorkbenchSite;
|
||||||
|
|
||||||
public class RenameRefactoringAction extends SelectionDispatchAction {
|
public class RenameRefactoringAction extends SelectionDispatchAction {
|
||||||
|
|
||||||
|
private CEditor fEditor;
|
||||||
|
|
||||||
|
public RenameRefactoringAction(CEditor editor) {
|
||||||
|
this(editor.getEditorSite());
|
||||||
|
fEditor= editor;
|
||||||
|
}
|
||||||
|
|
||||||
public RenameRefactoringAction(IWorkbenchSite site) {
|
public RenameRefactoringAction(IWorkbenchSite site) {
|
||||||
super(site);
|
super(site);
|
||||||
setText(RefactoringMessages.getString("RenameRefactoringAction.text"));//$NON-NLS-1$
|
setText(RefactoringMessages.getString("RenameRefactoringAction.text"));//$NON-NLS-1$
|
||||||
|
|
|
@ -16,36 +16,34 @@ import java.util.ArrayList;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.eclipse.core.resources.IFile;
|
|
||||||
import org.eclipse.core.runtime.IStatus;
|
|
||||||
import org.eclipse.core.runtime.MultiStatus;
|
|
||||||
import org.eclipse.core.runtime.Status;
|
|
||||||
|
|
||||||
import org.eclipse.swt.widgets.Shell;
|
|
||||||
|
|
||||||
import org.eclipse.jface.action.IAction;
|
|
||||||
import org.eclipse.jface.dialogs.ErrorDialog;
|
|
||||||
import org.eclipse.jface.dialogs.IDialogConstants;
|
|
||||||
import org.eclipse.jface.operation.IRunnableWithProgress;
|
|
||||||
|
|
||||||
import org.eclipse.ui.IEditorInput;
|
|
||||||
import org.eclipse.ui.IEditorPart;
|
|
||||||
import org.eclipse.ui.IFileEditorInput;
|
|
||||||
import org.eclipse.ui.IWorkbenchWindow;
|
|
||||||
import org.eclipse.ui.IWorkbenchWindowActionDelegate;
|
|
||||||
import org.eclipse.ui.PlatformUI;
|
|
||||||
|
|
||||||
import org.eclipse.cdt.internal.corext.refactoring.base.ChangeContext;
|
import org.eclipse.cdt.internal.corext.refactoring.base.ChangeContext;
|
||||||
import org.eclipse.cdt.internal.corext.refactoring.base.Refactoring;
|
import org.eclipse.cdt.internal.corext.refactoring.base.Refactoring;
|
||||||
import org.eclipse.cdt.internal.corext.refactoring.base.RefactoringStatus;
|
import org.eclipse.cdt.internal.corext.refactoring.base.RefactoringStatus;
|
||||||
import org.eclipse.cdt.internal.corext.refactoring.base.RefactoringStatusEntry;
|
import org.eclipse.cdt.internal.corext.refactoring.base.RefactoringStatusEntry;
|
||||||
import org.eclipse.cdt.internal.corext.refactoring.base.UndoManagerAdapter;
|
import org.eclipse.cdt.internal.corext.refactoring.base.UndoManagerAdapter;
|
||||||
import org.eclipse.cdt.ui.CUIPlugin;
|
|
||||||
import org.eclipse.cdt.internal.ui.refactoring.RefactoringMessages;
|
|
||||||
import org.eclipse.cdt.internal.ui.refactoring.AbortChangeExceptionHandler;
|
import org.eclipse.cdt.internal.ui.refactoring.AbortChangeExceptionHandler;
|
||||||
|
import org.eclipse.cdt.internal.ui.refactoring.RefactoringMessages;
|
||||||
import org.eclipse.cdt.internal.ui.util.ExceptionHandler;
|
import org.eclipse.cdt.internal.ui.util.ExceptionHandler;
|
||||||
|
import org.eclipse.cdt.ui.CUIPlugin;
|
||||||
|
import org.eclipse.cdt.ui.actions.SelectionDispatchAction;
|
||||||
|
import org.eclipse.core.resources.IFile;
|
||||||
|
import org.eclipse.core.runtime.IStatus;
|
||||||
|
import org.eclipse.core.runtime.MultiStatus;
|
||||||
|
import org.eclipse.core.runtime.Status;
|
||||||
|
import org.eclipse.jface.action.IAction;
|
||||||
|
import org.eclipse.jface.dialogs.ErrorDialog;
|
||||||
|
import org.eclipse.jface.dialogs.IDialogConstants;
|
||||||
|
import org.eclipse.jface.operation.IRunnableWithProgress;
|
||||||
|
import org.eclipse.jface.viewers.IStructuredSelection;
|
||||||
|
import org.eclipse.swt.widgets.Shell;
|
||||||
|
import org.eclipse.ui.IEditorInput;
|
||||||
|
import org.eclipse.ui.IEditorPart;
|
||||||
|
import org.eclipse.ui.IFileEditorInput;
|
||||||
|
import org.eclipse.ui.IWorkbenchSite;
|
||||||
|
import org.eclipse.ui.IWorkbenchWindow;
|
||||||
|
import org.eclipse.ui.PlatformUI;
|
||||||
|
|
||||||
abstract class UndoManagerAction implements IWorkbenchWindowActionDelegate {
|
abstract class UndoManagerAction extends SelectionDispatchAction {
|
||||||
|
|
||||||
private static final int MAX_LENGTH= 30;
|
private static final int MAX_LENGTH= 30;
|
||||||
|
|
||||||
|
@ -54,7 +52,8 @@ abstract class UndoManagerAction implements IWorkbenchWindowActionDelegate {
|
||||||
private IWorkbenchWindow fWorkbenchWindow;
|
private IWorkbenchWindow fWorkbenchWindow;
|
||||||
private UndoManagerAdapter fUndoManagerListener;
|
private UndoManagerAdapter fUndoManagerListener;
|
||||||
|
|
||||||
public UndoManagerAction() {
|
public UndoManagerAction(IWorkbenchSite site) {
|
||||||
|
super(site);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract IRunnableWithProgress createOperation(ChangeContext context);
|
protected abstract IRunnableWithProgress createOperation(ChangeContext context);
|
||||||
|
@ -108,16 +107,19 @@ abstract class UndoManagerAction implements IWorkbenchWindowActionDelegate {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* Method declared in IActionDelegate
|
|
||||||
*/
|
*/
|
||||||
public void init(IWorkbenchWindow window) {
|
public void init(IWorkbenchWindow window) {
|
||||||
fWorkbenchWindow= window;
|
fWorkbenchWindow= window;
|
||||||
}
|
}
|
||||||
|
public void run(IStructuredSelection selection) {
|
||||||
/* (non-Javadoc)
|
run();
|
||||||
* Method declared in IActionDelegate
|
}
|
||||||
*/
|
|
||||||
public void run(IAction action) {
|
public void run(IAction action) {
|
||||||
|
run();
|
||||||
|
}
|
||||||
|
/* (non-Javadoc)
|
||||||
|
*/
|
||||||
|
public void run() {
|
||||||
Shell parent= fWorkbenchWindow.getShell();
|
Shell parent= fWorkbenchWindow.getShell();
|
||||||
ChangeContext context= new ChangeContext(new AbortChangeExceptionHandler(), getUnsavedFiles());
|
ChangeContext context= new ChangeContext(new AbortChangeExceptionHandler(), getUnsavedFiles());
|
||||||
IRunnableWithProgress op= createOperation(context);
|
IRunnableWithProgress op= createOperation(context);
|
||||||
|
|
|
@ -13,26 +13,33 @@ package org.eclipse.cdt.internal.ui.refactoring.actions;
|
||||||
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
|
|
||||||
import org.eclipse.core.runtime.IProgressMonitor;
|
|
||||||
|
|
||||||
import org.eclipse.jface.action.IAction;
|
|
||||||
import org.eclipse.jface.operation.IRunnableWithProgress;
|
|
||||||
import org.eclipse.jface.viewers.ISelection;
|
|
||||||
|
|
||||||
import org.eclipse.cdt.core.model.CModelException;
|
import org.eclipse.cdt.core.model.CModelException;
|
||||||
|
|
||||||
import org.eclipse.cdt.internal.corext.refactoring.base.ChangeAbortException;
|
import org.eclipse.cdt.internal.corext.refactoring.base.ChangeAbortException;
|
||||||
import org.eclipse.cdt.internal.corext.refactoring.base.ChangeContext;
|
import org.eclipse.cdt.internal.corext.refactoring.base.ChangeContext;
|
||||||
import org.eclipse.cdt.internal.corext.refactoring.base.IUndoManager;
|
import org.eclipse.cdt.internal.corext.refactoring.base.IUndoManager;
|
||||||
import org.eclipse.cdt.internal.corext.refactoring.base.Refactoring;
|
import org.eclipse.cdt.internal.corext.refactoring.base.Refactoring;
|
||||||
import org.eclipse.cdt.internal.corext.refactoring.base.UndoManagerAdapter;
|
import org.eclipse.cdt.internal.corext.refactoring.base.UndoManagerAdapter;
|
||||||
|
import org.eclipse.cdt.internal.ui.editor.CEditor;
|
||||||
import org.eclipse.cdt.internal.ui.refactoring.RefactoringMessages;
|
import org.eclipse.cdt.internal.ui.refactoring.RefactoringMessages;
|
||||||
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
|
import org.eclipse.jface.action.IAction;
|
||||||
|
import org.eclipse.jface.operation.IRunnableWithProgress;
|
||||||
|
import org.eclipse.jface.viewers.ISelection;
|
||||||
|
import org.eclipse.ui.IWorkbenchSite;
|
||||||
|
|
||||||
public class UndoRefactoringAction extends UndoManagerAction {
|
public class UndoRefactoringAction extends UndoManagerAction {
|
||||||
|
|
||||||
private int fPatternLength;
|
private int fPatternLength;
|
||||||
|
private CEditor fEditor;
|
||||||
|
|
||||||
public UndoRefactoringAction() {
|
public UndoRefactoringAction(CEditor editor) {
|
||||||
|
this(editor.getEditorSite());
|
||||||
|
fEditor= editor;
|
||||||
|
}
|
||||||
|
|
||||||
|
public UndoRefactoringAction(IWorkbenchSite site) {
|
||||||
|
super(site);
|
||||||
|
init(site.getWorkbenchWindow());
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
@ -84,13 +91,17 @@ public class UndoRefactoringAction extends UndoManagerAction {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* Method declared in IActionDelegate
|
*/
|
||||||
|
public void selectionChanged(ISelection s) {
|
||||||
|
selectionChanged(this, s);
|
||||||
|
}
|
||||||
|
/* (non-Javadoc)
|
||||||
*/
|
*/
|
||||||
public void selectionChanged(IAction action, ISelection s) {
|
public void selectionChanged(IAction action, ISelection s) {
|
||||||
// if (!isHooked()) {
|
if (!isHooked()) {
|
||||||
hookListener(action);
|
hookListener(this);
|
||||||
|
}
|
||||||
fPatternLength= RefactoringMessages.getString("UndoRefactoringAction.extendedLabel").length(); //$NON-NLS-1$
|
fPatternLength= RefactoringMessages.getString("UndoRefactoringAction.extendedLabel").length(); //$NON-NLS-1$
|
||||||
IUndoManager undoManager = Refactoring.getUndoManager();
|
IUndoManager undoManager = Refactoring.getUndoManager();
|
||||||
if (undoManager.anythingToUndo()) {
|
if (undoManager.anythingToUndo()) {
|
||||||
|
@ -100,7 +111,6 @@ public class UndoRefactoringAction extends UndoManagerAction {
|
||||||
} else {
|
} else {
|
||||||
action.setEnabled(false);
|
action.setEnabled(false);
|
||||||
}
|
}
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getActionText() {
|
private String getActionText() {
|
||||||
|
|
|
@ -227,8 +227,17 @@ InlineTempAction.inline_temp=Inline Local Variable
|
||||||
InlineTempAction.label=&Inline Local Variable...
|
InlineTempAction.label=&Inline Local Variable...
|
||||||
|
|
||||||
RenameAction.rename=Rename
|
RenameAction.rename=Rename
|
||||||
RenameAction.unavailable=Operation unavailable on the current selection.\nSelect a java project, source folder, resource, package or a translation unit, or a non binary type, field, method, parameter or a local variable.
|
RenameAction.unavailable=Operation unavailable on the current selection.\nSelect a C/C++ project, source folder, resource or a translation unit, or a non binary type, field, method, parameter or a local variable.
|
||||||
RenameAction.text=Rena&me...
|
RenameAction.text=Re&name...
|
||||||
|
|
||||||
|
UndoAction.rename=Undo Action
|
||||||
|
UndoAction.unavailable=Operation unavailable.
|
||||||
|
UndoAction.text=&Undo...
|
||||||
|
|
||||||
|
RedoAction.rename=Redo Action
|
||||||
|
RedoAction.unavailable=Operation unavailable.
|
||||||
|
RedoAction.text=&Redo...
|
||||||
|
|
||||||
|
|
||||||
RenameInputDialog.update_references=&Update references to the renamed element
|
RenameInputDialog.update_references=&Update references to the renamed element
|
||||||
|
|
||||||
|
|
|
@ -1,86 +0,0 @@
|
||||||
/**********************************************************************
|
|
||||||
* Copyright (c) 2004 Rational Software Corporation and others.
|
|
||||||
* All rights reserved. This program and the accompanying materials
|
|
||||||
* are made available under the terms of the Common Public License v0.5
|
|
||||||
* which accompanies this distribution, and is available at
|
|
||||||
* http://www.eclipse.org/legal/cpl-v05.html
|
|
||||||
*
|
|
||||||
* Contributors:
|
|
||||||
* IBM Rational Software - Initial API and implementation
|
|
||||||
***********************************************************************/
|
|
||||||
|
|
||||||
package org.eclipse.cdt.ui.refactoring;
|
|
||||||
|
|
||||||
import org.eclipse.cdt.core.model.ICElement;
|
|
||||||
import org.eclipse.cdt.internal.ui.refactoring.actions.RedoRefactoringAction;
|
|
||||||
import org.eclipse.jface.action.Action;
|
|
||||||
import org.eclipse.jface.action.IAction;
|
|
||||||
import org.eclipse.jface.viewers.ISelection;
|
|
||||||
import org.eclipse.jface.viewers.IStructuredSelection;
|
|
||||||
import org.eclipse.ui.IViewActionDelegate;
|
|
||||||
import org.eclipse.ui.IViewPart;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* TODO: Provide description for "RefactoringRenameAction".
|
|
||||||
*/
|
|
||||||
public class RedoAction extends Action implements IViewActionDelegate {
|
|
||||||
// private IViewPart fView;
|
|
||||||
// private IAction fAction;
|
|
||||||
RedoRefactoringAction refactoringAction = new RedoRefactoringAction();
|
|
||||||
|
|
||||||
// protected IViewPart getView() {
|
|
||||||
// return fView;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// protected void setView(IViewPart view) {
|
|
||||||
// fView = view;
|
|
||||||
// }
|
|
||||||
// protected IAction getAction() {
|
|
||||||
// return fAction;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// protected void setAction(IAction action) {
|
|
||||||
// fAction = action;
|
|
||||||
// }
|
|
||||||
/**
|
|
||||||
* TODO: Implement the "RefactoringRenameAction" constructor.
|
|
||||||
*/
|
|
||||||
public RedoAction() {
|
|
||||||
}
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.ui.IViewActionDelegate#init(org.eclipse.ui.IViewPart)
|
|
||||||
*/
|
|
||||||
public void init(IViewPart view) {
|
|
||||||
// setView(view);
|
|
||||||
refactoringAction.init(view.getSite().getWorkbenchWindow());
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
|
|
||||||
*/
|
|
||||||
public void run(IAction action) {
|
|
||||||
refactoringAction.run(action);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection)
|
|
||||||
*/
|
|
||||||
public void selectionChanged(IAction action, ISelection selection) {
|
|
||||||
refactoringAction.selectionChanged(action, selection);
|
|
||||||
// setAction(action);
|
|
||||||
// if (!(selection instanceof IStructuredSelection)) {
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
// IStructuredSelection sel= (IStructuredSelection)selection;
|
|
||||||
// Object o= sel.getFirstElement();
|
|
||||||
// if (!(o instanceof ICElement)) {
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
|
|
||||||
// private IStructuredSelection getSelection() {
|
|
||||||
// return (IStructuredSelection)getView().getViewSite().getSelectionProvider().getSelection();
|
|
||||||
// }
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,84 +0,0 @@
|
||||||
/**********************************************************************
|
|
||||||
* Copyright (c) 2004 Rational Software Corporation and others.
|
|
||||||
* All rights reserved. This program and the accompanying materials
|
|
||||||
* are made available under the terms of the Common Public License v0.5
|
|
||||||
* which accompanies this distribution, and is available at
|
|
||||||
* http://www.eclipse.org/legal/cpl-v05.html
|
|
||||||
*
|
|
||||||
* Contributors:
|
|
||||||
* IBM Rational Software - Initial API and implementation
|
|
||||||
***********************************************************************/
|
|
||||||
|
|
||||||
package org.eclipse.cdt.ui.refactoring;
|
|
||||||
|
|
||||||
import org.eclipse.cdt.core.model.ICElement;
|
|
||||||
import org.eclipse.cdt.internal.ui.refactoring.actions.RenameRefactoringAction;
|
|
||||||
import org.eclipse.jface.action.Action;
|
|
||||||
import org.eclipse.jface.action.IAction;
|
|
||||||
import org.eclipse.jface.viewers.ISelection;
|
|
||||||
import org.eclipse.jface.viewers.IStructuredSelection;
|
|
||||||
import org.eclipse.ui.IViewActionDelegate;
|
|
||||||
import org.eclipse.ui.IViewPart;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* TODO: Provide description for "RefactoringRenameAction".
|
|
||||||
*/
|
|
||||||
public class RenameAction extends Action implements IViewActionDelegate {
|
|
||||||
private IViewPart fView;
|
|
||||||
private IAction fAction;
|
|
||||||
|
|
||||||
protected IViewPart getView() {
|
|
||||||
return fView;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void setView(IViewPart view) {
|
|
||||||
fView = view;
|
|
||||||
}
|
|
||||||
protected IAction getAction() {
|
|
||||||
return fAction;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void setAction(IAction action) {
|
|
||||||
fAction = action;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* TODO: Implement the "RefactoringRenameAction" constructor.
|
|
||||||
*/
|
|
||||||
public RenameAction() {
|
|
||||||
}
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.ui.IViewActionDelegate#init(org.eclipse.ui.IViewPart)
|
|
||||||
*/
|
|
||||||
public void init(IViewPart view) {
|
|
||||||
setView(view);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
|
|
||||||
*/
|
|
||||||
public void run(IAction action) {
|
|
||||||
RenameRefactoringAction refactoringAction = new RenameRefactoringAction(getView().getSite());
|
|
||||||
refactoringAction.run(getSelection());
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection)
|
|
||||||
*/
|
|
||||||
public void selectionChanged(IAction action, ISelection selection) {
|
|
||||||
setAction(action);
|
|
||||||
if (!(selection instanceof IStructuredSelection)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
IStructuredSelection sel= (IStructuredSelection)selection;
|
|
||||||
Object o= sel.getFirstElement();
|
|
||||||
if (!(o instanceof ICElement)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private IStructuredSelection getSelection() {
|
|
||||||
return (IStructuredSelection)getView().getViewSite().getSelectionProvider().getSelection();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,86 +0,0 @@
|
||||||
/**********************************************************************
|
|
||||||
* Copyright (c) 2004 Rational Software Corporation and others.
|
|
||||||
* All rights reserved. This program and the accompanying materials
|
|
||||||
* are made available under the terms of the Common Public License v0.5
|
|
||||||
* which accompanies this distribution, and is available at
|
|
||||||
* http://www.eclipse.org/legal/cpl-v05.html
|
|
||||||
*
|
|
||||||
* Contributors:
|
|
||||||
* IBM Rational Software - Initial API and implementation
|
|
||||||
***********************************************************************/
|
|
||||||
|
|
||||||
package org.eclipse.cdt.ui.refactoring;
|
|
||||||
|
|
||||||
import org.eclipse.cdt.core.model.ICElement;
|
|
||||||
import org.eclipse.cdt.internal.ui.refactoring.actions.UndoRefactoringAction;
|
|
||||||
import org.eclipse.jface.action.Action;
|
|
||||||
import org.eclipse.jface.action.IAction;
|
|
||||||
import org.eclipse.jface.viewers.ISelection;
|
|
||||||
import org.eclipse.jface.viewers.IStructuredSelection;
|
|
||||||
import org.eclipse.ui.IViewActionDelegate;
|
|
||||||
import org.eclipse.ui.IViewPart;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* TODO: Provide description for "RefactoringRenameAction".
|
|
||||||
*/
|
|
||||||
public class UndoAction extends Action implements IViewActionDelegate {
|
|
||||||
// private IViewPart fView;
|
|
||||||
// private IAction fAction;
|
|
||||||
UndoRefactoringAction refactoringAction = new UndoRefactoringAction();
|
|
||||||
|
|
||||||
// protected IViewPart getView() {
|
|
||||||
// return fView;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// protected void setView(IViewPart view) {
|
|
||||||
// fView = view;
|
|
||||||
// }
|
|
||||||
// protected IAction getAction() {
|
|
||||||
// return fAction;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// protected void setAction(IAction action) {
|
|
||||||
// fAction = action;
|
|
||||||
// }
|
|
||||||
/**
|
|
||||||
* TODO: Implement the "RefactoringRenameAction" constructor.
|
|
||||||
*/
|
|
||||||
public UndoAction() {
|
|
||||||
}
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.ui.IViewActionDelegate#init(org.eclipse.ui.IViewPart)
|
|
||||||
*/
|
|
||||||
public void init(IViewPart view) {
|
|
||||||
// setView(view);
|
|
||||||
refactoringAction.init(view.getSite().getWorkbenchWindow());
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
|
|
||||||
*/
|
|
||||||
public void run(IAction action) {
|
|
||||||
refactoringAction.run(action);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection)
|
|
||||||
*/
|
|
||||||
public void selectionChanged(IAction action, ISelection selection) {
|
|
||||||
refactoringAction.selectionChanged(action, selection);
|
|
||||||
// setAction(action);
|
|
||||||
// if (!(selection instanceof IStructuredSelection)) {
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
// IStructuredSelection sel= (IStructuredSelection)selection;
|
|
||||||
// Object o= sel.getFirstElement();
|
|
||||||
// if (!(o instanceof ICElement)) {
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
|
|
||||||
// private IStructuredSelection getSelection() {
|
|
||||||
// return (IStructuredSelection)getView().getViewSite().getSelectionProvider().getSelection();
|
|
||||||
// }
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
|
@ -19,6 +19,7 @@ import org.eclipse.cdt.internal.ui.editor.OpenIncludeAction;
|
||||||
import org.eclipse.cdt.internal.ui.editor.SearchDialogAction;
|
import org.eclipse.cdt.internal.ui.editor.SearchDialogAction;
|
||||||
import org.eclipse.cdt.internal.ui.search.actions.SelectionSearchGroup;
|
import org.eclipse.cdt.internal.ui.search.actions.SelectionSearchGroup;
|
||||||
import org.eclipse.cdt.ui.CUIPlugin;
|
import org.eclipse.cdt.ui.CUIPlugin;
|
||||||
|
import org.eclipse.cdt.ui.actions.RefactoringActionGroup;
|
||||||
import org.eclipse.core.resources.IFile;
|
import org.eclipse.core.resources.IFile;
|
||||||
import org.eclipse.core.resources.IResource;
|
import org.eclipse.core.resources.IResource;
|
||||||
import org.eclipse.core.resources.IWorkspace;
|
import org.eclipse.core.resources.IWorkspace;
|
||||||
|
@ -82,6 +83,7 @@ public class MainActionGroup extends CViewActionGroup {
|
||||||
WorkingSetFilterActionGroup workingSetGroup;
|
WorkingSetFilterActionGroup workingSetGroup;
|
||||||
|
|
||||||
SelectionSearchGroup selectionSearchGroup;
|
SelectionSearchGroup selectionSearchGroup;
|
||||||
|
RefactoringActionGroup refactoringActionGroup;
|
||||||
|
|
||||||
public MainActionGroup(CView cview) {
|
public MainActionGroup(CView cview) {
|
||||||
super(cview);
|
super(cview);
|
||||||
|
@ -164,7 +166,7 @@ public class MainActionGroup extends CViewActionGroup {
|
||||||
fSearchDialogAction = new SearchDialogAction(viewer, getCView().getViewSite().getWorkbenchWindow());
|
fSearchDialogAction = new SearchDialogAction(viewer, getCView().getViewSite().getWorkbenchWindow());
|
||||||
|
|
||||||
selectionSearchGroup = new SelectionSearchGroup(getCView().getSite());
|
selectionSearchGroup = new SelectionSearchGroup(getCView().getSite());
|
||||||
|
refactoringActionGroup = new RefactoringActionGroup(getCView().getSite());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -178,6 +180,8 @@ public class MainActionGroup extends CViewActionGroup {
|
||||||
|
|
||||||
if (resources.isEmpty()) {
|
if (resources.isEmpty()) {
|
||||||
new NewWizardMenu(menu, getCView().getSite().getWorkbenchWindow(), false);
|
new NewWizardMenu(menu, getCView().getSite().getWorkbenchWindow(), false);
|
||||||
|
menu.add(new Separator(IContextMenuConstants.GROUP_REORGANIZE));
|
||||||
|
refactoringActionGroup.fillContextMenu(menu);
|
||||||
menu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
|
menu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
|
||||||
menu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS + "-end")); //$NON-NLS-1$
|
menu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS + "-end")); //$NON-NLS-1$
|
||||||
menu.add(new Separator());
|
menu.add(new Separator());
|
||||||
|
@ -207,6 +211,7 @@ public class MainActionGroup extends CViewActionGroup {
|
||||||
menu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
|
menu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
|
||||||
menu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS + "-end")); //$NON-NLS-1$
|
menu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS + "-end")); //$NON-NLS-1$
|
||||||
addPropertyMenu(menu, resources);
|
addPropertyMenu(menu, resources);
|
||||||
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Extends the superclass implementation to set the context in the
|
* Extends the superclass implementation to set the context in the
|
||||||
|
|
|
@ -19,6 +19,7 @@ import org.eclipse.cdt.ui.CElementContentProvider;
|
||||||
import org.eclipse.cdt.ui.CUIPlugin;
|
import org.eclipse.cdt.ui.CUIPlugin;
|
||||||
import org.eclipse.cdt.ui.IWorkingCopyManager;
|
import org.eclipse.cdt.ui.IWorkingCopyManager;
|
||||||
import org.eclipse.cdt.ui.actions.MemberFilterActionGroup;
|
import org.eclipse.cdt.ui.actions.MemberFilterActionGroup;
|
||||||
|
import org.eclipse.cdt.ui.actions.RefactoringActionGroup;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IStatus;
|
import org.eclipse.core.runtime.IStatus;
|
||||||
import org.eclipse.core.runtime.Status;
|
import org.eclipse.core.runtime.Status;
|
||||||
|
@ -66,6 +67,7 @@ public class CContentOutlinePage extends Page implements IContentOutlinePage, IS
|
||||||
private MemberFilterActionGroup fMemberFilterActionGroup;
|
private MemberFilterActionGroup fMemberFilterActionGroup;
|
||||||
|
|
||||||
private ActionGroup fSelectionSearchGroup;
|
private ActionGroup fSelectionSearchGroup;
|
||||||
|
private ActionGroup fRefactoringActionGroup;
|
||||||
|
|
||||||
public CContentOutlinePage(CEditor editor) {
|
public CContentOutlinePage(CEditor editor) {
|
||||||
this("#TranslationUnitOutlinerContext", editor); //$NON-NLS-1$
|
this("#TranslationUnitOutlinerContext", editor); //$NON-NLS-1$
|
||||||
|
@ -131,6 +133,8 @@ public class CContentOutlinePage extends Page implements IContentOutlinePage, IS
|
||||||
* called to create the context menu of the outline
|
* called to create the context menu of the outline
|
||||||
*/
|
*/
|
||||||
protected void contextMenuAboutToShow(IMenuManager menu) {
|
protected void contextMenuAboutToShow(IMenuManager menu) {
|
||||||
|
CUIPlugin.createStandardGroups(menu);
|
||||||
|
|
||||||
if (OpenIncludeAction.canActionBeAdded(getSelection())) {
|
if (OpenIncludeAction.canActionBeAdded(getSelection())) {
|
||||||
menu.add(fOpenIncludeAction);
|
menu.add(fOpenIncludeAction);
|
||||||
}
|
}
|
||||||
|
@ -149,6 +153,7 @@ public class CContentOutlinePage extends Page implements IContentOutlinePage, IS
|
||||||
menu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS+"-end"));//$NON-NLS-1$
|
menu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS+"-end"));//$NON-NLS-1$
|
||||||
|
|
||||||
fSelectionSearchGroup.fillContextMenu(menu);
|
fSelectionSearchGroup.fillContextMenu(menu);
|
||||||
|
fRefactoringActionGroup.fillContextMenu(menu);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -176,7 +181,6 @@ public class CContentOutlinePage extends Page implements IContentOutlinePage, IS
|
||||||
Menu menu= manager.createContextMenu(control);
|
Menu menu= manager.createContextMenu(control);
|
||||||
control.setMenu(menu);
|
control.setMenu(menu);
|
||||||
|
|
||||||
fSelectionSearchGroup = new SelectionSearchGroup(this);
|
|
||||||
|
|
||||||
// register global actions
|
// register global actions
|
||||||
IPageSite site= getSite();
|
IPageSite site= getSite();
|
||||||
|
@ -187,6 +191,10 @@ public class CContentOutlinePage extends Page implements IContentOutlinePage, IS
|
||||||
|
|
||||||
registerToolbarActions();
|
registerToolbarActions();
|
||||||
|
|
||||||
|
fSelectionSearchGroup = new SelectionSearchGroup(this);
|
||||||
|
fRefactoringActionGroup = new RefactoringActionGroup(this);
|
||||||
|
|
||||||
|
|
||||||
IEditorInput editorInput= (IEditorInput)fEditor.getEditorInput();
|
IEditorInput editorInput= (IEditorInput)fEditor.getEditorInput();
|
||||||
IDocumentProvider provider= fEditor.getDocumentProvider();
|
IDocumentProvider provider= fEditor.getDocumentProvider();
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -64,5 +64,19 @@ public interface ICEditorActionDefinitionIds extends ITextEditorActionDefinition
|
||||||
* (value <code>"org.eclipse.cdt.ui.edit.opencview"</code>).
|
* (value <code>"org.eclipse.cdt.ui.edit.opencview"</code>).
|
||||||
*/
|
*/
|
||||||
public static final String OPEN_CVIEW= "org.eclipse.cdt.ui.edit.opencview"; //$NON-NLS-1$
|
public static final String OPEN_CVIEW= "org.eclipse.cdt.ui.edit.opencview"; //$NON-NLS-1$
|
||||||
|
/**
|
||||||
|
* Action definition ID of the refactor -> rename element action
|
||||||
|
* (value <code>"org.eclipse.cdt.ui.edit.text.rename.element"</code>).
|
||||||
|
*/
|
||||||
|
public static final String RENAME_ELEMENT= "org.eclipse.cdt.ui.edit.text.rename.element"; //$NON-NLS-1$
|
||||||
|
/**
|
||||||
|
* Action definition ID of the refactor -> undo action
|
||||||
|
* (value <code>"org.eclipse.cdt.ui.edit.text.undo.action"</code>).
|
||||||
|
*/
|
||||||
|
public static final String UNDO_ACTION= "org.eclipse.cdt.ui.edit.text.undo.action"; //$NON-NLS-1$
|
||||||
|
/**
|
||||||
|
* Action definition ID of the refactor -> redo action
|
||||||
|
* (value <code>"org.eclipse.cdt.ui.edit.text.redo.action"</code>).
|
||||||
|
*/
|
||||||
|
public static final String REDO_ACTION= "org.eclipse.cdt.ui.edit.text.redo.action"; //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,6 +28,7 @@ import org.eclipse.cdt.internal.core.model.IBufferFactory;
|
||||||
import org.eclipse.cdt.internal.corext.refactoring.base.Refactoring;
|
import org.eclipse.cdt.internal.corext.refactoring.base.Refactoring;
|
||||||
import org.eclipse.cdt.internal.ui.CElementAdapterFactory;
|
import org.eclipse.cdt.internal.ui.CElementAdapterFactory;
|
||||||
import org.eclipse.cdt.internal.ui.CPluginImages;
|
import org.eclipse.cdt.internal.ui.CPluginImages;
|
||||||
|
import org.eclipse.cdt.internal.ui.IContextMenuConstants;
|
||||||
import org.eclipse.cdt.internal.ui.ResourceAdapterFactory;
|
import org.eclipse.cdt.internal.ui.ResourceAdapterFactory;
|
||||||
import org.eclipse.cdt.internal.ui.buildconsole.BuildConsoleManager;
|
import org.eclipse.cdt.internal.ui.buildconsole.BuildConsoleManager;
|
||||||
import org.eclipse.cdt.internal.ui.cview.CView;
|
import org.eclipse.cdt.internal.ui.cview.CView;
|
||||||
|
@ -52,6 +53,9 @@ import org.eclipse.core.runtime.IPluginDescriptor;
|
||||||
import org.eclipse.core.runtime.IStatus;
|
import org.eclipse.core.runtime.IStatus;
|
||||||
import org.eclipse.core.runtime.Platform;
|
import org.eclipse.core.runtime.Platform;
|
||||||
import org.eclipse.core.runtime.Status;
|
import org.eclipse.core.runtime.Status;
|
||||||
|
import org.eclipse.jface.action.GroupMarker;
|
||||||
|
import org.eclipse.jface.action.IMenuManager;
|
||||||
|
import org.eclipse.jface.action.Separator;
|
||||||
import org.eclipse.jface.dialogs.ErrorDialog;
|
import org.eclipse.jface.dialogs.ErrorDialog;
|
||||||
import org.eclipse.jface.preference.IPreferenceStore;
|
import org.eclipse.jface.preference.IPreferenceStore;
|
||||||
import org.eclipse.jface.text.source.ISharedTextColors;
|
import org.eclipse.jface.text.source.ISharedTextColors;
|
||||||
|
@ -469,4 +473,26 @@ public class CUIPlugin extends AbstractUIPlugin {
|
||||||
}
|
}
|
||||||
return display;
|
return display;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates the CUIplugin standard groups in a context menu.
|
||||||
|
*/
|
||||||
|
public static void createStandardGroups(IMenuManager menu) {
|
||||||
|
if (!menu.isEmpty())
|
||||||
|
return;
|
||||||
|
|
||||||
|
menu.add(new Separator(IContextMenuConstants.GROUP_NEW));
|
||||||
|
menu.add(new GroupMarker(IContextMenuConstants.GROUP_GOTO));
|
||||||
|
menu.add(new Separator(IContextMenuConstants.GROUP_OPEN));
|
||||||
|
menu.add(new GroupMarker(IContextMenuConstants.GROUP_SHOW));
|
||||||
|
menu.add(new Separator(IContextMenuConstants.GROUP_REORGANIZE));
|
||||||
|
menu.add(new Separator(IContextMenuConstants.GROUP_GENERATE));
|
||||||
|
menu.add(new Separator(IContextMenuConstants.GROUP_SEARCH));
|
||||||
|
menu.add(new Separator(IContextMenuConstants.GROUP_BUILD));
|
||||||
|
menu.add(new Separator(IContextMenuConstants.GROUP_ADDITIONS));
|
||||||
|
menu.add(new Separator(IContextMenuConstants.GROUP_VIEWER_SETUP));
|
||||||
|
menu.add(new Separator(IContextMenuConstants.GROUP_PROPERTIES));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,304 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2000, 2003 IBM Corporation and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Common Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/cpl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* IBM Corporation - initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.ui.actions;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.model.ICElement;
|
||||||
|
import org.eclipse.cdt.internal.ui.IContextMenuConstants;
|
||||||
|
import org.eclipse.cdt.internal.ui.actions.ActionMessages;
|
||||||
|
import org.eclipse.cdt.internal.ui.editor.CEditor;
|
||||||
|
import org.eclipse.cdt.internal.ui.editor.ICEditorActionDefinitionIds;
|
||||||
|
import org.eclipse.cdt.internal.ui.refactoring.RefactoringMessages;
|
||||||
|
import org.eclipse.cdt.internal.ui.refactoring.actions.RedoRefactoringAction;
|
||||||
|
import org.eclipse.cdt.internal.ui.refactoring.actions.RenameRefactoringAction;
|
||||||
|
import org.eclipse.cdt.internal.ui.refactoring.actions.UndoRefactoringAction;
|
||||||
|
import org.eclipse.cdt.ui.CUIPlugin;
|
||||||
|
import org.eclipse.jface.action.Action;
|
||||||
|
import org.eclipse.jface.action.IAction;
|
||||||
|
import org.eclipse.jface.action.IMenuListener;
|
||||||
|
import org.eclipse.jface.action.IMenuManager;
|
||||||
|
import org.eclipse.jface.action.MenuManager;
|
||||||
|
import org.eclipse.jface.action.Separator;
|
||||||
|
import org.eclipse.jface.text.IDocument;
|
||||||
|
import org.eclipse.jface.text.ITextSelection;
|
||||||
|
import org.eclipse.jface.viewers.ISelection;
|
||||||
|
import org.eclipse.jface.viewers.ISelectionChangedListener;
|
||||||
|
import org.eclipse.jface.viewers.ISelectionProvider;
|
||||||
|
import org.eclipse.swt.events.MenuAdapter;
|
||||||
|
import org.eclipse.swt.events.MenuEvent;
|
||||||
|
import org.eclipse.swt.widgets.Menu;
|
||||||
|
import org.eclipse.ui.IActionBars;
|
||||||
|
import org.eclipse.ui.IViewPart;
|
||||||
|
import org.eclipse.ui.IWorkbenchSite;
|
||||||
|
import org.eclipse.ui.actions.ActionGroup;
|
||||||
|
import org.eclipse.ui.part.Page;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Action group that adds refactor actions (for example Rename..., Move..., etc)
|
||||||
|
* to a context menu and the global menu bar.
|
||||||
|
*
|
||||||
|
* <p>
|
||||||
|
* This class may be instantiated; it is not intended to be subclassed.
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @since 2.0
|
||||||
|
*/
|
||||||
|
public class RefactoringActionGroup extends ActionGroup {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Pop-up menu: id of the refactor sub menu (value <code>org.eclipse.cdt.ui.refactoring.menu</code>).
|
||||||
|
*
|
||||||
|
* @since 2.1
|
||||||
|
*/
|
||||||
|
public static final String MENU_ID= "org.eclipse.cdt.ui.refactoring.menu"; //$NON-NLS-1$
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Pop-up menu: id of the reorg group of the refactor sub menu (value
|
||||||
|
* <code>reorgGroup</code>).
|
||||||
|
*
|
||||||
|
* @since 2.1
|
||||||
|
*/
|
||||||
|
public static final String GROUP_REORG= "reorgGroup"; //$NON-NLS-1$
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Pop-up menu: id of the type group of the refactor sub menu (value
|
||||||
|
* <code>typeGroup</code>).
|
||||||
|
*
|
||||||
|
* @since 2.1
|
||||||
|
*/
|
||||||
|
public static final String GROUP_TYPE= "typeGroup"; //$NON-NLS-1$
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Pop-up menu: id of the coding group of the refactor sub menu (value
|
||||||
|
* <code>codingGroup</code>).
|
||||||
|
*
|
||||||
|
* @since 2.1
|
||||||
|
*/
|
||||||
|
public static final String GROUP_CODING= "codingGroup"; //$NON-NLS-1$
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Refactor menu: name of standard Rename Element global action
|
||||||
|
* (value <code>"org.eclipse.cdt.ui.actions.refactor.Rename"</code>).
|
||||||
|
*/
|
||||||
|
public static final String REFACTOR_RENAME= "org.eclipse.cdt.ui.actions.refactor.RenameAction"; //$NON-NLS-1$
|
||||||
|
/**
|
||||||
|
* Refactor menu: name of standard Undo global action
|
||||||
|
* (value <code>"org.eclipse.cdt.ui.actions.refactor.undo"</code>).
|
||||||
|
*/
|
||||||
|
public static final String REFACTOR_UNDO= "org.eclipse.cdt.ui.actions.refactor.UndoAction"; //$NON-NLS-1$
|
||||||
|
/**
|
||||||
|
* Refactor menu: name of standard Redo global action
|
||||||
|
* (value <code>"org.eclipse.cdt.ui.actions.refactor.redo"</code>).
|
||||||
|
*/
|
||||||
|
public static final String REFACTOR_REDO= "org.eclipse.cdt.ui.actions.refactor.RedoAction"; //$NON-NLS-1$
|
||||||
|
|
||||||
|
private IWorkbenchSite fSite;
|
||||||
|
private CEditor fEditor;
|
||||||
|
private String fGroupName= IContextMenuConstants.GROUP_REORGANIZE;
|
||||||
|
|
||||||
|
private SelectionDispatchAction fRenameAction;
|
||||||
|
private SelectionDispatchAction fRedoAction;
|
||||||
|
private SelectionDispatchAction fUndoAction;
|
||||||
|
private List fEditorActions;
|
||||||
|
|
||||||
|
private static class NoActionAvailable extends Action {
|
||||||
|
public NoActionAvailable() {
|
||||||
|
setEnabled(false);
|
||||||
|
setText(RefactoringMessages.getString("RefactorActionGroup.no_refactoring_available")); //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private Action fNoActionAvailable= new NoActionAvailable();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new <code>RefactorActionGroup</code>. The group requires
|
||||||
|
* that the selection provided by the part's selection provider is of type <code>
|
||||||
|
* org.eclipse.jface.viewers.IStructuredSelection</code>.
|
||||||
|
*
|
||||||
|
* @param part the view part that owns this action group
|
||||||
|
*/
|
||||||
|
public RefactoringActionGroup(IViewPart part) {
|
||||||
|
this(part.getSite());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new <code>RefactorActionGroup</code>. The action requires
|
||||||
|
* that the selection provided by the page's selection provider is of type <code>
|
||||||
|
* org.eclipse.jface.viewers.IStructuredSelection</code>.
|
||||||
|
*
|
||||||
|
* @param page the page that owns this action group
|
||||||
|
*/
|
||||||
|
public RefactoringActionGroup(Page page) {
|
||||||
|
this(page.getSite());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Note: This constructor is for internal use only. Clients should not call this constructor.
|
||||||
|
*/
|
||||||
|
public RefactoringActionGroup(CEditor editor, String groupName) {
|
||||||
|
fSite= editor.getEditorSite();
|
||||||
|
fEditor= editor;
|
||||||
|
fGroupName= groupName;
|
||||||
|
ISelectionProvider provider= editor.getSelectionProvider();
|
||||||
|
ISelection selection= provider.getSelection();
|
||||||
|
fEditorActions= new ArrayList();
|
||||||
|
|
||||||
|
fRenameAction= new RenameRefactoringAction(editor);
|
||||||
|
fRenameAction.setActionDefinitionId(ICEditorActionDefinitionIds.RENAME_ELEMENT);
|
||||||
|
fRenameAction.update(selection);
|
||||||
|
editor.setAction("RenameElement", fRenameAction); //$NON-NLS-1$
|
||||||
|
fEditorActions.add(fRenameAction);
|
||||||
|
|
||||||
|
fUndoAction= new UndoRefactoringAction(editor);
|
||||||
|
fUndoAction.setActionDefinitionId(ICEditorActionDefinitionIds.UNDO_ACTION);
|
||||||
|
fUndoAction.update(selection);
|
||||||
|
editor.setAction("UndoAction", fUndoAction); //$NON-NLS-1$
|
||||||
|
fEditorActions.add(fUndoAction);
|
||||||
|
|
||||||
|
fRedoAction= new RedoRefactoringAction(editor);
|
||||||
|
fRedoAction.setActionDefinitionId(ICEditorActionDefinitionIds.REDO_ACTION);
|
||||||
|
fRedoAction.update(selection);
|
||||||
|
editor.setAction("RedoAction", fRedoAction); //$NON-NLS-1$
|
||||||
|
fEditorActions.add(fRedoAction);
|
||||||
|
}
|
||||||
|
|
||||||
|
public RefactoringActionGroup(IWorkbenchSite site) {
|
||||||
|
fSite= site;
|
||||||
|
ISelectionProvider provider= fSite.getSelectionProvider();
|
||||||
|
ISelection selection= provider.getSelection();
|
||||||
|
|
||||||
|
fRenameAction= new RenameRefactoringAction(site);
|
||||||
|
initAction(fRenameAction, provider, selection);
|
||||||
|
|
||||||
|
fUndoAction= new UndoRefactoringAction(site);
|
||||||
|
initAction(fUndoAction, provider, selection);
|
||||||
|
|
||||||
|
fRedoAction= new RedoRefactoringAction(site);
|
||||||
|
initAction(fRedoAction, provider, selection);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void initAction(SelectionDispatchAction action, ISelectionProvider provider, ISelection selection){
|
||||||
|
action.update(selection);
|
||||||
|
provider.addSelectionChangedListener(action);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* Method declared in ActionGroup
|
||||||
|
*/
|
||||||
|
public void fillActionBars(IActionBars actionBars) {
|
||||||
|
super.fillActionBars(actionBars);
|
||||||
|
actionBars.setGlobalActionHandler(REFACTOR_RENAME, fRenameAction);
|
||||||
|
actionBars.setGlobalActionHandler(REFACTOR_UNDO, fUndoAction);
|
||||||
|
actionBars.setGlobalActionHandler(REFACTOR_REDO, fRedoAction);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* Method declared in ActionGroup
|
||||||
|
*/
|
||||||
|
public void fillContextMenu(IMenuManager menu) {
|
||||||
|
super.fillContextMenu(menu);
|
||||||
|
addRefactorSubmenu(menu);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @see ActionGroup#dispose()
|
||||||
|
*/
|
||||||
|
public void dispose() {
|
||||||
|
ISelectionProvider provider= fSite.getSelectionProvider();
|
||||||
|
disposeAction(fRenameAction, provider);
|
||||||
|
disposeAction(fUndoAction, provider);
|
||||||
|
disposeAction(fRedoAction, provider);
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void disposeAction(ISelectionChangedListener action, ISelectionProvider provider) {
|
||||||
|
if (action != null)
|
||||||
|
provider.removeSelectionChangedListener(action);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addRefactorSubmenu(IMenuManager menu) {
|
||||||
|
IMenuManager refactorSubmenu= new MenuManager(ActionMessages.getString("RefactorMenu.label"), MENU_ID); //$NON-NLS-1$
|
||||||
|
if (fEditor != null) {
|
||||||
|
refactorSubmenu.addMenuListener(new IMenuListener() {
|
||||||
|
public void menuAboutToShow(IMenuManager manager) {
|
||||||
|
refactorMenuShown(manager);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
refactorSubmenu.add(fNoActionAvailable);
|
||||||
|
menu.appendToGroup(fGroupName, refactorSubmenu);
|
||||||
|
} else {
|
||||||
|
if (fillRefactorMenu(refactorSubmenu) > 0){
|
||||||
|
menu.appendToGroup(fGroupName, refactorSubmenu);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private int fillRefactorMenu(IMenuManager refactorSubmenu) {
|
||||||
|
int added= 0;
|
||||||
|
refactorSubmenu.add(new Separator(GROUP_REORG));
|
||||||
|
added+= addAction(refactorSubmenu, fRenameAction);
|
||||||
|
added+= addAction(refactorSubmenu, fUndoAction);
|
||||||
|
added+= addAction(refactorSubmenu, fRedoAction);
|
||||||
|
return added;
|
||||||
|
}
|
||||||
|
|
||||||
|
private int addAction(IMenuManager menu, IAction action) {
|
||||||
|
if (action != null && action.isEnabled()) {
|
||||||
|
menu.add(action);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void refactorMenuShown(final IMenuManager refactorSubmenu) {
|
||||||
|
// we know that we have an MenuManager since we created it in
|
||||||
|
// addRefactorSubmenu.
|
||||||
|
Menu menu= ((MenuManager)refactorSubmenu).getMenu();
|
||||||
|
menu.addMenuListener(new MenuAdapter() {
|
||||||
|
public void menuHidden(MenuEvent e) {
|
||||||
|
refactorMenuHidden(refactorSubmenu);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
ITextSelection textSelection= (ITextSelection)fEditor.getSelectionProvider().getSelection();
|
||||||
|
// CTextSelection javaSelection= new CTextSelection(
|
||||||
|
// getEditorInput(), getDocument(), textSelection.getOffset(), textSelection.getLength());
|
||||||
|
|
||||||
|
for (Iterator iter= fEditorActions.iterator(); iter.hasNext(); ) {
|
||||||
|
SelectionDispatchAction action= (SelectionDispatchAction)iter.next();
|
||||||
|
// action.update(javaSelection);
|
||||||
|
}
|
||||||
|
refactorSubmenu.removeAll();
|
||||||
|
if (fillRefactorMenu(refactorSubmenu) == 0)
|
||||||
|
refactorSubmenu.add(fNoActionAvailable);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void refactorMenuHidden(IMenuManager manager) {
|
||||||
|
ITextSelection textSelection= (ITextSelection)fEditor.getSelectionProvider().getSelection();
|
||||||
|
for (Iterator iter= fEditorActions.iterator(); iter.hasNext(); ) {
|
||||||
|
SelectionDispatchAction action= (SelectionDispatchAction)iter.next();
|
||||||
|
action.update(textSelection);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private ICElement getEditorInput() {
|
||||||
|
return CUIPlugin.getDefault().getWorkingCopyManager().getWorkingCopy(
|
||||||
|
fEditor.getEditorInput());
|
||||||
|
}
|
||||||
|
|
||||||
|
private IDocument getDocument() {
|
||||||
|
return CUIPlugin.getDefault().getDocumentProvider().
|
||||||
|
getDocument(fEditor.getEditorInput());
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,77 +0,0 @@
|
||||||
/**********************************************************************
|
|
||||||
* Copyright (c) 2004 Rational Software Corporation and others.
|
|
||||||
* All rights reserved. This program and the accompanying materials
|
|
||||||
* are made available under the terms of the Common Public License v0.5
|
|
||||||
* which accompanies this distribution, and is available at
|
|
||||||
* http://www.eclipse.org/legal/cpl-v05.html
|
|
||||||
*
|
|
||||||
* Contributors:
|
|
||||||
* IBM Rational Software - Initial API and implementation
|
|
||||||
***********************************************************************/
|
|
||||||
package org.eclipse.cdt.ui.actions;
|
|
||||||
|
|
||||||
import org.eclipse.cdt.internal.ui.ICHelpContextIds;
|
|
||||||
import org.eclipse.cdt.internal.ui.refactoring.RefactoringMessages;
|
|
||||||
import org.eclipse.cdt.internal.ui.refactoring.actions.RenameRefactoringAction;
|
|
||||||
import org.eclipse.jface.viewers.ISelection;
|
|
||||||
import org.eclipse.jface.viewers.IStructuredSelection;
|
|
||||||
import org.eclipse.jface.viewers.SelectionChangedEvent;
|
|
||||||
import org.eclipse.ui.IWorkbenchSite;
|
|
||||||
import org.eclipse.ui.help.WorkbenchHelp;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Renames a C element or workbench resource.
|
|
||||||
* <p>
|
|
||||||
* Action is applicable to selections containing elements of type
|
|
||||||
* <code>ICElement</code>.
|
|
||||||
*
|
|
||||||
* <p>
|
|
||||||
* This class may be instantiated; it is not intended to be subclassed.
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @since 2.0
|
|
||||||
*/
|
|
||||||
public class RenameAction extends SelectionDispatchAction {
|
|
||||||
|
|
||||||
private RenameRefactoringAction fRenameCElement;
|
|
||||||
/**
|
|
||||||
* Creates a new <code>RenameAction</code>. The action requires
|
|
||||||
* that the selection provided by the site's selection provider is of type <code>
|
|
||||||
* org.eclipse.jface.viewers.IStructuredSelection</code>.
|
|
||||||
*
|
|
||||||
* @param site the site providing context information for this action
|
|
||||||
*/
|
|
||||||
public RenameAction(IWorkbenchSite site) {
|
|
||||||
super(site);
|
|
||||||
setText(RefactoringMessages.getString("RenameAction.text")); //$NON-NLS-1$
|
|
||||||
fRenameCElement= new RenameRefactoringAction(site);
|
|
||||||
fRenameCElement.setText(getText());
|
|
||||||
WorkbenchHelp.setHelp(this, ICHelpContextIds.RENAME_ACTION);
|
|
||||||
}
|
|
||||||
/*
|
|
||||||
* @see ISelectionChangedListener#selectionChanged(SelectionChangedEvent)
|
|
||||||
*/
|
|
||||||
public void selectionChanged(SelectionChangedEvent event) {
|
|
||||||
fRenameCElement.selectionChanged(event);
|
|
||||||
setEnabled(computeEnabledState());
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* @see SelectionDispatchAction#update(ISelection)
|
|
||||||
*/
|
|
||||||
public void update(ISelection selection) {
|
|
||||||
fRenameCElement.update(selection);
|
|
||||||
|
|
||||||
setEnabled(computeEnabledState());
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean computeEnabledState(){
|
|
||||||
return fRenameCElement.isEnabled();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void run(IStructuredSelection selection) {
|
|
||||||
if (fRenameCElement.isEnabled())
|
|
||||||
fRenameCElement.run(selection);
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Add table
Reference in a new issue