(MAX_HISTORY_SIZE);
private int fIgnoreSelectionChanges= 0;
// widgets
@@ -180,7 +179,8 @@ public class THViewPart extends ViewPart implements ITHModelPresenter {
private CRefactoringActionGroup fRefactoringActionGroup;
private IContextActivation fContextActivation;
- public void setFocus() {
+ @Override
+ public void setFocus() {
fPagebook.setFocus();
}
@@ -210,6 +210,7 @@ public class THViewPart extends ViewPart implements ITHModelPresenter {
fModel.computeGraph();
}
+ @Override
public void createPartControl(Composite parent) {
fPagebook = new PageBook(parent, SWT.NULL);
fPagebook.setLayoutData(new GridData(GridData.FILL_BOTH));
@@ -231,6 +232,7 @@ public class THViewPart extends ViewPart implements ITHModelPresenter {
}
}
+ @Override
public void dispose() {
if (fContextActivation != null) {
IContextService ctxService = (IContextService)getSite().getService(IContextService.class);
@@ -316,13 +318,15 @@ public class THViewPart extends ViewPart implements ITHModelPresenter {
fMemberToolbarManager.update(true);
}
+ @Override
public void init(IViewSite site, IMemento memento) throws PartInitException {
fMemento= memento;
super.init(site, memento);
}
- public void saveState(IMemento memento) {
+ @Override
+ public void saveState(IMemento memento) {
if (fWorkingSetFilterUI != null) {
fWorkingSetFilterUI.saveState(memento, KEY_WORKING_SET_FILTER);
}
@@ -382,6 +386,7 @@ public class THViewPart extends ViewPart implements ITHModelPresenter {
CElementLabels.getTextLabel(elem, CElementBaseLabels.ALL_FULLY_QUALIFIED | CElementBaseLabels.M_PARAMETER_TYPES)
});
menu.appendToGroup(IContextMenuConstants.GROUP_OPEN, new Action(label) {
+ @Override
public void run() {
setInput(elem, null);
}
@@ -443,7 +448,8 @@ public class THViewPart extends ViewPart implements ITHModelPresenter {
}
});
fMemberViewer.setSorter(new ViewerSorter() {
- public int category(Object element) {
+ @Override
+ public int category(Object element) {
if (element instanceof ICElement) {
ICElement celem= (ICElement)element;
switch (celem.getElementType()) {
@@ -534,15 +540,18 @@ public class THViewPart extends ViewPart implements ITHModelPresenter {
fRefactoringActionGroup= new CRefactoringActionGroup(this);
fWorkingSetFilterUI= new WorkingSetFilterUI(this, fMemento, KEY_WORKING_SET_FILTER) {
- protected void onWorkingSetChange() {
+ @Override
+ protected void onWorkingSetChange() {
updateWorkingSetFilter(this);
}
- protected void onWorkingSetNameChange() {
+ @Override
+ protected void onWorkingSetNameChange() {
updateDescription();
}
};
fHorizontalOrientation= new Action(Messages.THViewPart_HorizontalOrientation, IAction.AS_RADIO_BUTTON) {
+ @Override
public void run() {
setOrientation(ORIENTATION_HORIZONTAL);
}
@@ -550,6 +559,7 @@ public class THViewPart extends ViewPart implements ITHModelPresenter {
CPluginImages.setImageDescriptors(fHorizontalOrientation, CPluginImages.T_LCL, CPluginImages.IMG_LCL_HORIZONTAL_ORIENTATION);
fVerticalOrientation= new Action(Messages.THViewPart_VerticalOrientation, IAction.AS_RADIO_BUTTON) {
+ @Override
public void run() {
setOrientation(ORIENTATION_VERTICAL);
}
@@ -557,6 +567,7 @@ public class THViewPart extends ViewPart implements ITHModelPresenter {
CPluginImages.setImageDescriptors(fVerticalOrientation, CPluginImages.T_LCL, CPluginImages.IMG_LCL_VERTICAL_ORIENTATION);
fAutomaticOrientation= new Action(Messages.THViewPart_AutomaticOrientation, IAction.AS_RADIO_BUTTON) {
+ @Override
public void run() {
setOrientation(ORIENTATION_AUTOMATIC);
}
@@ -564,6 +575,7 @@ public class THViewPart extends ViewPart implements ITHModelPresenter {
CPluginImages.setImageDescriptors(fAutomaticOrientation, CPluginImages.T_LCL, CPluginImages.IMG_LCL_AUTOMATIC_ORIENTATION);
fSingleOrientation= new Action(Messages.THViewPart_SinglePaneOrientation, IAction.AS_RADIO_BUTTON) {
+ @Override
public void run() {
setOrientation(ORIENTATION_SINGLE);
}
@@ -571,6 +583,7 @@ public class THViewPart extends ViewPart implements ITHModelPresenter {
CPluginImages.setImageDescriptors(fSingleOrientation, CPluginImages.T_LCL, CPluginImages.IMG_LCL_SINGLE_ORIENTATION);
fShowTypeHierarchyAction= new Action(Messages.THViewPart_CompleteTypeHierarchy, IAction.AS_RADIO_BUTTON) {
+ @Override
public void run() {
if (isChecked()) {
onSetHierarchyKind(THHierarchyModel.TYPE_HIERARCHY);
@@ -581,6 +594,7 @@ public class THViewPart extends ViewPart implements ITHModelPresenter {
CPluginImages.setImageDescriptors(fShowTypeHierarchyAction, CPluginImages.T_LCL, CPluginImages.IMG_LCL_TYPE_HIERARCHY);
fShowSubTypeHierarchyAction= new Action(Messages.THViewPart_SubtypeHierarchy, IAction.AS_RADIO_BUTTON) {
+ @Override
public void run() {
if (isChecked()) {
onSetHierarchyKind(THHierarchyModel.SUB_TYPE_HIERARCHY);
@@ -591,6 +605,7 @@ public class THViewPart extends ViewPart implements ITHModelPresenter {
CPluginImages.setImageDescriptors(fShowSubTypeHierarchyAction, CPluginImages.T_LCL, CPluginImages.IMG_LCL_SUB_TYPE_HIERARCHY);
fShowSuperTypeHierarchyAction= new Action(Messages.THViewPart_SupertypeHierarchy, IAction.AS_RADIO_BUTTON) {
+ @Override
public void run() {
if (isChecked()) {
onSetHierarchyKind(THHierarchyModel.SUPER_TYPE_HIERARCHY);
@@ -601,6 +616,7 @@ public class THViewPart extends ViewPart implements ITHModelPresenter {
CPluginImages.setImageDescriptors(fShowSuperTypeHierarchyAction, CPluginImages.T_LCL, CPluginImages.IMG_LCL_SUPER_TYPE_HIERARCHY);
fShowInheritedMembersAction= new Action(Messages.THViewPart_ShowInherited_label, IAction.AS_CHECK_BOX) {
+ @Override
public void run() {
onShowInheritedMembers(isChecked());
}
@@ -609,7 +625,8 @@ public class THViewPart extends ViewPart implements ITHModelPresenter {
CPluginImages.setImageDescriptors(fShowInheritedMembersAction, CPluginImages.T_LCL, CPluginImages.IMG_LCL_SHOW_INHERITED_MEMBERS);
fFieldFilter= new ViewerFilter() {
- public boolean select(Viewer viewer, Object parentElement, Object element) {
+ @Override
+ public boolean select(Viewer viewer, Object parentElement, Object element) {
if (element instanceof ICElement) {
ICElement node= (ICElement) element;
switch (node.getElementType()) {
@@ -626,7 +643,8 @@ public class THViewPart extends ViewPart implements ITHModelPresenter {
}
};
fStaticFilter= new ViewerFilter() {
- public boolean select(Viewer viewer, Object parentElement, Object element) {
+ @Override
+ public boolean select(Viewer viewer, Object parentElement, Object element) {
if (element instanceof IDeclaration) {
IDeclaration node= (IDeclaration) element;
try {
@@ -639,7 +657,8 @@ public class THViewPart extends ViewPart implements ITHModelPresenter {
}
};
fNonPublicFilter= new ViewerFilter() {
- public boolean select(Viewer viewer, Object parentElement, Object element) {
+ @Override
+ public boolean select(Viewer viewer, Object parentElement, Object element) {
if (element instanceof IMember) {
IMember node= (IMember) element;
try {
@@ -652,7 +671,8 @@ public class THViewPart extends ViewPart implements ITHModelPresenter {
}
};
fFieldFilterAction= new Action(Messages.THViewPart_HideFields_label, IAction.AS_CHECK_BOX) {
- public void run() {
+ @Override
+ public void run() {
if (isChecked()) {
fMemberViewer.addFilter(fFieldFilter);
}
@@ -665,7 +685,8 @@ public class THViewPart extends ViewPart implements ITHModelPresenter {
CPluginImages.setImageDescriptors(fFieldFilterAction, CPluginImages.T_LCL, CPluginImages.IMG_ACTION_HIDE_FIELDS);
fStaticFilterAction= new Action(Messages.THViewPart_HideStatic_label, IAction.AS_CHECK_BOX) {
- public void run() {
+ @Override
+ public void run() {
if (isChecked()) {
fMemberViewer.addFilter(fStaticFilter);
}
@@ -678,7 +699,8 @@ public class THViewPart extends ViewPart implements ITHModelPresenter {
CPluginImages.setImageDescriptors(fStaticFilterAction, CPluginImages.T_LCL, CPluginImages.IMG_ACTION_HIDE_STATIC);
fNonPublicFilterAction= new Action(Messages.THViewPart_HideNonPublic_label, IAction.AS_CHECK_BOX) {
- public void run() {
+ @Override
+ public void run() {
if (isChecked()) {
fMemberViewer.addFilter(fNonPublicFilter);
}
@@ -691,21 +713,24 @@ public class THViewPart extends ViewPart implements ITHModelPresenter {
CPluginImages.setImageDescriptors(fNonPublicFilterAction, CPluginImages.T_LCL, CPluginImages.IMG_ACTION_SHOW_PUBLIC);
fOpenElement= new Action(Messages.THViewPart_Open) {
- public void run() {
+ @Override
+ public void run() {
onOpenElement(getSite().getSelectionProvider().getSelection());
}
};
fOpenElement.setToolTipText(Messages.THViewPart_Open_tooltip);
fShowFilesInLabelsAction= new Action(Messages.THViewPart_ShowFileNames, IAction.AS_CHECK_BOX) {
- public void run() {
+ @Override
+ public void run() {
onShowFilesInLabels(isChecked());
}
};
fShowFilesInLabelsAction.setToolTipText(Messages.THViewPart_ShowFileNames_tooltip);
fRefreshAction = new Action(Messages.THViewPart_Refresh) {
- public void run() {
+ @Override
+ public void run() {
onRefresh();
}
};
@@ -713,7 +738,8 @@ public class THViewPart extends ViewPart implements ITHModelPresenter {
CPluginImages.setImageDescriptors(fRefreshAction, CPluginImages.T_LCL, CPluginImages.IMG_REFRESH);
fCancelAction = new Action(Messages.THViewPart_Cancel) {
- public void run() {
+ @Override
+ public void run() {
onCancel();
}
};
@@ -961,7 +987,7 @@ public class THViewPart extends ViewPart implements ITHModelPresenter {
}
public ICElement[] getHistoryEntries() {
- return (ICElement[]) fHistoryEntries.toArray(new ICElement[fHistoryEntries.size()]);
+ return fHistoryEntries.toArray(new ICElement[fHistoryEntries.size()]);
}
public void setHistoryEntries(ICElement[] remaining) {
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/messages.properties b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/messages.properties
index 10a01ecd30d..2d810d5584c 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/messages.properties
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/messages.properties
@@ -1,5 +1,5 @@
###############################################################################
-# Copyright (c) 2007 Wind River Systems, Inc. and others.
+# Copyright (c) 2007, 2008 Wind River Systems, Inc. and others.
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Eclipse Public License v1.0
# which accompanies this distribution, and is available at
@@ -34,7 +34,6 @@ THViewPart_SubtypeHierarchy_tooltip=Show the Subtype Hierarchy
THViewPart_SupertypeHierarchy=Supertype Hierarchy
THViewPart_HideFields_tooltip=Hide Fields
THViewPart_HideStatic_tooltip=Hide Static Fields and Methods
-THGraph_error_elementNotFound=Cannot find element ''{0}'' in index.
THViewPart_Open=Open
THViewPart_Open_tooltip=Open
THViewPart_ShowFileNames=Show File Names
@@ -49,7 +48,6 @@ THViewPart_FocusOn=Focus On ''{0}''
THViewPart_Cancel=Cancel
TypeHierarchyUI_OpenTypeHierarchy=Open Type Hierarchy
TypeHierarchyUI_OpenFailure_message=Cannot resolve selected text to a defined type
-TypeHierarchyUI_SelectFromList=Select one element from the list
OpenTypeHierarchyAction_label=Open Type Hierarchy
OpenTypeHierarchyAction_tooltip=Open Type Hierarchy
OpenTypeInHierarchyAction_errorTitle=Open Type in Hierarchy
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/folderwizard/NewFolderWizardMessages.properties b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/folderwizard/NewFolderWizardMessages.properties
index 36f2fe80a7b..be5dc176fbe 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/folderwizard/NewFolderWizardMessages.properties
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/folderwizard/NewFolderWizardMessages.properties
@@ -1,5 +1,5 @@
###############################################################################
-# Copyright (c) 2004, 2006 QNX Software Systems and others.
+# Copyright (c) 2004, 2007 QNX Software Systems and others.
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Eclipse Public License v1.0
# which accompanies this distribution, and is available at
@@ -9,9 +9,6 @@
# QNX Software Systems - Initial API and implementation
###############################################################################
-# ------- NewSourceFolderCreationWizard -------
-NewSourceFolderCreationWizard.title= New Source Folder
-
# ------- NewSourceFolderWizardPage-------
NewSourceFolderCreationWizard.title=New Source Folder
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CUIPlugin.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CUIPlugin.java
index 142c80105bd..59cac78fdb9 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CUIPlugin.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CUIPlugin.java
@@ -68,6 +68,7 @@ import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.IWorkingCopy;
import org.eclipse.cdt.core.model.IWorkingCopyProvider;
+import org.eclipse.cdt.internal.core.dom.rewrite.ASTRewriteAnalyzer;
import org.eclipse.cdt.internal.core.model.IBufferFactory;
import org.eclipse.cdt.internal.corext.template.c.CContextType;
import org.eclipse.cdt.internal.corext.template.c.CodeTemplateContextType;
@@ -85,6 +86,7 @@ import org.eclipse.cdt.internal.ui.editor.CustomBufferFactory;
import org.eclipse.cdt.internal.ui.editor.SharedTextColors;
import org.eclipse.cdt.internal.ui.editor.WorkingCopyManager;
import org.eclipse.cdt.internal.ui.editor.asm.AsmTextTools;
+import org.eclipse.cdt.internal.ui.refactoring.CTextFileChangeFactory;
import org.eclipse.cdt.internal.ui.text.CTextTools;
import org.eclipse.cdt.internal.ui.text.PreferencesAdapter;
import org.eclipse.cdt.internal.ui.text.c.hover.CEditorTextHoverDescriptor;
@@ -461,6 +463,7 @@ public class CUIPlugin extends AbstractUIPlugin {
/*
* @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
*/
+ @Override
public void start(BundleContext context) throws Exception {
super.start(context);
@@ -480,9 +483,11 @@ public class CUIPlugin extends AbstractUIPlugin {
CDTContextActivator.getInstance().install();
DocCommentOwnerManager.getInstance().addListener(new EditorReopener());
+ ASTRewriteAnalyzer.setCTextFileChangeFactory(new CTextFileChangeFactory());
// start make-ui plugin, such that it can check for project conversions.
Job job= new Job(Messages.CUIPlugin_jobStartMakeUI) {
+ @Override
protected IStatus run(IProgressMonitor monitor) {
Bundle bundle= Platform.getBundle("org.eclipse.cdt.make.ui"); //$NON-NLS-1$
try {
@@ -507,6 +512,7 @@ public class CUIPlugin extends AbstractUIPlugin {
/* (non-Javadoc)
* @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
*/
+ @Override
public void stop(BundleContext context) throws Exception {
CDTContextActivator.getInstance().uninstall();
if (fASTProvider != null) {
@@ -711,6 +717,7 @@ public class CUIPlugin extends AbstractUIPlugin {
/**
* {@inheritDoc}
*/
+ @Override
public IConfigurationElement getConfigurationElement(Object object) {
return ((CEditorTextHoverDescriptor)object).getConfigurationElement();
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/refactoring/CTextFileChange.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/refactoring/CTextFileChange.java
new file mode 100644
index 00000000000..e877878c23e
--- /dev/null
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/refactoring/CTextFileChange.java
@@ -0,0 +1,102 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2007 Wind River Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Markus Schorn (Wind River Systems) - Initial API and implementation
+ * Anton Leherbauer (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.ui.refactoring;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.ltk.core.refactoring.Change;
+import org.eclipse.ltk.core.refactoring.ContentStamp;
+import org.eclipse.ltk.core.refactoring.TextFileChange;
+import org.eclipse.text.edits.UndoEdit;
+
+import org.eclipse.cdt.core.model.CoreModel;
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.core.model.ITranslationUnit;
+import org.eclipse.cdt.core.model.IWorkingCopy;
+
+import org.eclipse.cdt.internal.ui.refactoring.DocumentAdapter;
+import org.eclipse.cdt.internal.ui.refactoring.UndoCTextFileChange;
+
+
+/**
+ * A TextFileChange that uses a working copy in order to generate CModel events.
+ */
+public class CTextFileChange extends TextFileChange {
+ private ITranslationUnit fTranslationUnit = null;
+ private IWorkingCopy fWorkingCopy;
+ private int fAquireCount= 0;
+
+ public CTextFileChange(String name, IFile file) {
+ super(name, file);
+ ICElement element = CoreModel.getDefault().create(file);
+ if(element instanceof ITranslationUnit) {
+ fTranslationUnit = (ITranslationUnit)element;
+ // "c2" is the extension which the CContentViewerCreator is registered
+ // with the extension point "org.eclipse.compare.contentMergeViewers"
+ setTextType("c2"); //$NON-NLS-1$
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ltk.core.refactoring.TextFileChange#acquireDocument(org.eclipse.core.runtime.IProgressMonitor)
+ */
+ @Override
+ protected IDocument acquireDocument(IProgressMonitor pm) throws CoreException {
+ IDocument doc= super.acquireDocument(pm);
+ if (++fAquireCount == 1) {
+ if (fTranslationUnit != null && fWorkingCopy == null) {
+ fWorkingCopy= fTranslationUnit.getWorkingCopy(null, DocumentAdapter.FACTORY);
+ if (!fTranslationUnit.isOpen()) {
+ fTranslationUnit.open(null);
+ }
+ }
+ }
+ return doc;
+ }
+
+ @Override
+ protected void commit(final IDocument document, final IProgressMonitor pm) throws CoreException {
+ if (fWorkingCopy == null) {
+ super.commit(document, pm);
+ }
+ else if (needsSaving()) {
+ fWorkingCopy.commit(false, pm);
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ltk.core.refactoring.TextFileChange#releaseDocument(org.eclipse.jface.text.IDocument, org.eclipse.core.runtime.IProgressMonitor)
+ */
+ @Override
+ protected void releaseDocument(IDocument document, IProgressMonitor pm) throws CoreException {
+ super.releaseDocument(document, pm);
+ if (--fAquireCount == 0) {
+ if (fWorkingCopy != null) {
+ fWorkingCopy.destroy();
+ fWorkingCopy= null;
+ }
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ltk.core.refactoring.TextFileChange#createUndoChange(org.eclipse.text.edits.UndoEdit, org.eclipse.ltk.core.refactoring.ContentStamp)
+ */
+ @Override
+ protected Change createUndoChange(UndoEdit edit, ContentStamp stampToRestore) {
+ return new UndoCTextFileChange(getName(), getFile(), edit, stampToRestore, getSaveMode());
+ }
+}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/refactoring/actions/CRefactoringActionGroup.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/refactoring/actions/CRefactoringActionGroup.java
new file mode 100644
index 00000000000..da24db11f83
--- /dev/null
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/refactoring/actions/CRefactoringActionGroup.java
@@ -0,0 +1,266 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Rational Software - Initial API and implementation
+ * Markus Schorn, Wind River Systems Inc. - ported for rename refactoring impl.
+ *******************************************************************************/
+package org.eclipse.cdt.ui.refactoring.actions;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.MenuManager;
+import org.eclipse.jface.action.Separator;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.ISelectionProvider;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.ui.IActionBars;
+import org.eclipse.ui.IWorkbenchActionConstants;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.IWorkbenchSite;
+import org.eclipse.ui.actions.ActionGroup;
+import org.eclipse.ui.part.Page;
+import org.eclipse.ui.texteditor.ITextEditor;
+
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.core.model.ISourceReference;
+import org.eclipse.cdt.ui.actions.CdtActionConstants;
+
+import org.eclipse.cdt.internal.ui.editor.ICEditorActionDefinitionIds;
+
+/**
+ * Action group that adds refactoring actions (for example Rename..., Move..., etc)
+ * to a context menu and the global menu bar.
+ *
+ *
+ * This class may be instantiated; it is not intended to be subclassed.
+ *
+ *
+ * @since 2.0
+ */
+public class CRefactoringActionGroup extends ActionGroup implements ISelectionChangedListener {
+ /**
+ * Pop-up menu: id of the refactor sub menu (value org.eclipse.cdt.ui.refactoring.menu
).
+ *
+ * @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
+ * reorgGroup
).
+ *
+ * @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
+ * typeGroup
).
+ *
+ * @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
+ * codingGroup
).
+ *
+ * @since 2.1
+ */
+ public static final String GROUP_CODING = "codingGroup"; //$NON-NLS-1$
+
+ /**
+ * Pop-up menu: id of the coding group 2 of the refactor sub menu (value
+ * codingGroup2
).
+ *
+ * @since 5.0
+ */
+ public static final String GROUP_CODING2= "codingGroup2"; //$NON-NLS-1$
+
+ /**
+ * Pop-up menu: id of the reorg group 2 of the refactor sub menu (value
+ * reorgGroup2
).
+ *
+ * @since 5.0
+ */
+ public static final String GROUP_REORG2= "reorgGroup2"; //$NON-NLS-1$
+
+ /**
+ * Pop-up menu: id of the type group 2 of the refactor sub menu (value
+ * typeGroup2
).
+ *
+ * @since 5.0
+ */
+ public static final String GROUP_TYPE2= "typeGroup2"; //$NON-NLS-1$
+
+ /**
+ * Pop-up menu: id of the type group 2 of the refactor sub menu (value
+ * typeGroup3
).
+ *
+ * @since 5.0
+ */
+ public static final String GROUP_TYPE3= "typeGroup3"; //$NON-NLS-1$
+
+ private String fGroupName= IWorkbenchActionConstants.GROUP_REORGANIZE;
+ private CRenameAction fRenameAction;
+ private RefactoringAction fExtractConstantAction;
+ private IWorkbenchSite fSite;
+ private List fAllActions= new ArrayList();
+
+ public CRefactoringActionGroup(IWorkbenchPart part) {
+ this(part, null);
+ }
+
+ public CRefactoringActionGroup(Page page) {
+ createActions(false);
+ setWorkbenchSite(page.getSite());
+ }
+
+ public CRefactoringActionGroup(IWorkbenchPart part, String groupName) {
+ if (groupName != null && groupName.length() > 0) {
+ fGroupName= groupName;
+ }
+ createActions(part instanceof ITextEditor);
+
+ if (part instanceof ITextEditor) {
+ setEditor((ITextEditor) part);
+ }
+ else {
+ setWorkbenchSite(part.getSite());
+ }
+ }
+
+ private void createActions(boolean forEditor) {
+ fRenameAction = new CRenameAction();
+ fRenameAction.setActionDefinitionId(ICEditorActionDefinitionIds.RENAME_ELEMENT);
+ fAllActions.add(fRenameAction);
+
+ if (forEditor) {
+ fExtractConstantAction= new ExtractConstantAction();
+ fExtractConstantAction.setActionDefinitionId(ICEditorActionDefinitionIds.EXTRACT_CONSTANT);
+ fAllActions.add(fExtractConstantAction);
+ }
+ }
+
+ public void setWorkbenchSite(IWorkbenchSite site) {
+ unregisterSite();
+ fSite= site;
+
+ for (RefactoringAction action : fAllActions) {
+ action.setSite(site);
+ }
+ final ISelectionProvider sp = fSite.getSelectionProvider();
+ sp.addSelectionChangedListener(this);
+ updateActions(sp.getSelection());
+ }
+
+ private void unregisterSite() {
+ if (fSite != null) {
+ fSite.getSelectionProvider().removeSelectionChangedListener(this);
+ fSite= null;
+ }
+ }
+
+ public void setEditor(ITextEditor textEditor) {
+ unregisterSite();
+
+ for (RefactoringAction action : fAllActions) {
+ action.setEditor(textEditor);
+ }
+ }
+
+
+ @Override
+ public void fillActionBars(IActionBars actionBar) {
+ super.fillActionBars(actionBar);
+ setActionHandler(actionBar, CdtActionConstants.RENAME, fRenameAction);
+ setActionHandler(actionBar, CdtActionConstants.EXTRACT_CONSTANT, fExtractConstantAction);
+ }
+
+ private void setActionHandler(IActionBars actionBar, String id, RefactoringAction action) {
+ if (action != null)
+ actionBar.setGlobalActionHandler(id, action);
+ }
+
+ /* (non-Javadoc)
+ * Method declared in ActionGroup
+ */
+ @Override
+ public void fillContextMenu(IMenuManager menu) {
+ updateActionBars();
+
+ boolean needMenu= false;
+ for (RefactoringAction action : fAllActions) {
+ if (action.isEnabled()) {
+ needMenu= true;
+ break;
+ }
+ }
+
+ if (needMenu) {
+ IMenuManager refactorSubmenu = new MenuManager(Messages.CRefactoringActionGroup_menu, MENU_ID);
+ refactorSubmenu.add(new Separator(GROUP_REORG));
+ addAction(refactorSubmenu, fRenameAction);
+ refactorSubmenu.add(new Separator(GROUP_CODING));
+ addAction(refactorSubmenu, fExtractConstantAction);
+ refactorSubmenu.add(new Separator(GROUP_REORG2));
+ refactorSubmenu.add(new Separator(GROUP_TYPE));
+ refactorSubmenu.add(new Separator(GROUP_TYPE2));
+ refactorSubmenu.add(new Separator(GROUP_CODING2));
+ refactorSubmenu.add(new Separator(GROUP_TYPE3));
+
+ menu.appendToGroup(fGroupName, refactorSubmenu);
+ }
+ }
+
+ private void addAction(IMenuManager refactorSubmenu, RefactoringAction action) {
+ if (action != null && action.isEnabled()) {
+ refactorSubmenu.add(action);
+ }
+ }
+
+ private ICElement getCElement(ISelection selection) {
+ if (selection instanceof IStructuredSelection) {
+ IStructuredSelection ss= (IStructuredSelection) selection;
+ if (ss.size() == 1) {
+ Object o= ss.getFirstElement();
+ if (o instanceof ICElement && o instanceof ISourceReference) {
+ return (ICElement) o;
+ }
+ }
+ }
+ return null;
+ }
+
+ private void updateActions(ISelection selection) {
+ ICElement celem= getCElement(selection);
+ for (RefactoringAction action : fAllActions) {
+ action.updateSelection(celem);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.actions.ActionGroup#dispose()
+ */
+ @Override
+ public void dispose() {
+ unregisterSite();
+ fSite= null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.ISelectionChangedListener#selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent)
+ */
+ public void selectionChanged(SelectionChangedEvent event) {
+ updateActions(event.getSelection());
+ }
+}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/refactoring/actions/CRenameAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/refactoring/actions/CRenameAction.java
new file mode 100644
index 00000000000..cc4f9ccc7a8
--- /dev/null
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/refactoring/actions/CRenameAction.java
@@ -0,0 +1,53 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2006 Wind River Systems, Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Markus Schorn - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.ui.refactoring.actions;
+
+import org.eclipse.jface.text.ITextSelection;
+import org.eclipse.jface.window.IShellProvider;
+
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.core.model.IInclude;
+import org.eclipse.cdt.core.model.ITranslationUnit;
+import org.eclipse.cdt.core.model.IWorkingCopy;
+
+import org.eclipse.cdt.internal.ui.refactoring.rename.CRefactory;
+
+/**
+ * Launches a rename refactoring.
+ */
+public class CRenameAction extends RefactoringAction {
+
+ public CRenameAction() {
+ super(Messages.CRenameAction_label);
+ }
+
+ @Override
+ public void run(IShellProvider shellProvider, ICElement elem) {
+ CRefactory.getInstance().rename(shellProvider.getShell(), elem);
+ }
+
+ @Override
+ public void run(IShellProvider shellProvider, IWorkingCopy wc, ITextSelection s) {
+ CRefactory.getInstance().rename(shellProvider.getShell(), wc, s);
+ }
+
+ @Override
+ public void updateSelection(ICElement elem) {
+ super.updateSelection(elem);
+ if (elem == null || elem instanceof IInclude || elem instanceof ITranslationUnit) {
+ setEnabled(false);
+ }
+ else {
+ setEnabled(true);
+ }
+ }
+}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/refactoring/actions/ExtractConstantAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/refactoring/actions/ExtractConstantAction.java
new file mode 100644
index 00000000000..2e6c0dfc77b
--- /dev/null
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/refactoring/actions/ExtractConstantAction.java
@@ -0,0 +1,52 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2006 Wind River Systems, Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Markus Schorn - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.ui.refactoring.actions;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.jface.text.ITextSelection;
+import org.eclipse.jface.window.IShellProvider;
+
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.core.model.IWorkingCopy;
+
+import org.eclipse.cdt.internal.ui.refactoring.extractconstant.ExtractConstantRefactoringRunner;
+
+/**
+ * Launches a rename refactoring.
+ */
+public class ExtractConstantAction extends RefactoringAction {
+
+ public ExtractConstantAction() {
+ super(Messages.ExtractConstantAction_label);
+ }
+
+ @Override
+ public void run(IShellProvider shellProvider, ICElement elem) {
+ }
+
+ @Override
+ public void run(IShellProvider shellProvider, IWorkingCopy wc, ITextSelection s) {
+ IResource res= wc.getResource();
+ if (res instanceof IFile) {
+ new ExtractConstantRefactoringRunner((IFile) res,
+ fEditor.getSelectionProvider().getSelection(),
+ fEditor.getSite().getWorkbenchWindow()).run();
+ }
+ }
+
+ @Override
+ public void updateSelection(ICElement elem) {
+ super.updateSelection(elem);
+ setEnabled(false);
+ }
+}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/refactoring/actions/Messages.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/refactoring/actions/Messages.java
new file mode 100644
index 00000000000..95be61cea71
--- /dev/null
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/refactoring/actions/Messages.java
@@ -0,0 +1,27 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Markus Schorn - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.refactoring.actions;
+
+import org.eclipse.osgi.util.NLS;
+
+public class Messages extends NLS {
+ private static final String BUNDLE_NAME = "org.eclipse.cdt.ui.refactoring.actions.messages"; //$NON-NLS-1$
+ public static String CRefactoringActionGroup_menu;
+ public static String CRenameAction_label;
+ public static String ExtractConstantAction_label;
+ static {
+ // initialize resource bundle
+ NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+ }
+
+ private Messages() {
+ }
+}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/refactoring/actions/RefactoringAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/refactoring/actions/RefactoringAction.java
new file mode 100644
index 00000000000..978fefdcfc1
--- /dev/null
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/refactoring/actions/RefactoringAction.java
@@ -0,0 +1,79 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Markus Schorn - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.refactoring.actions;
+
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.text.ITextSelection;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionProvider;
+import org.eclipse.jface.window.IShellProvider;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IWorkbenchSite;
+import org.eclipse.ui.texteditor.ITextEditor;
+
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.core.model.IWorkingCopy;
+import org.eclipse.cdt.ui.CUIPlugin;
+
+/**
+ * Common base class for refactoring actions
+ * @since 5.0
+ */
+public abstract class RefactoringAction extends Action {
+ protected ITextEditor fEditor;
+ private IWorkbenchSite fSite;
+ private ICElement fElement;
+
+ public RefactoringAction(String label) {
+ super(label);
+ }
+
+ public void setEditor(IEditorPart editor) {
+ fEditor= null;
+ fSite= null;
+ if (editor instanceof ITextEditor) {
+ fEditor= (ITextEditor) editor;
+ }
+ setEnabled(fEditor!=null);
+ }
+
+ public void setSite(IWorkbenchSite site) {
+ fEditor= null;
+ fSite= site;
+ }
+
+ @Override
+ public final void run() {
+ if (fEditor != null) {
+ ISelectionProvider provider= fEditor.getSelectionProvider();
+ if (provider != null) {
+ ISelection s= provider.getSelection();
+ if (s instanceof ITextSelection) {
+ IWorkingCopy wc= CUIPlugin.getDefault().getWorkingCopyManager().getWorkingCopy(fEditor.getEditorInput());
+ if (wc != null)
+ run(fEditor.getSite(), wc, (ITextSelection) s);
+ }
+ }
+ }
+ else if (fSite != null) {
+ if (fElement != null) {
+ run(fSite, fElement);
+ }
+ }
+ }
+
+ public void updateSelection(ICElement elem) {
+ fElement= elem;
+ }
+
+ public abstract void run(IShellProvider shellProvider, IWorkingCopy wc, ITextSelection s);
+ public abstract void run(IShellProvider shellProvider, ICElement elem);
+}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/refactoring/actions/messages.properties b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/refactoring/actions/messages.properties
new file mode 100644
index 00000000000..65445cd7ca7
--- /dev/null
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/refactoring/actions/messages.properties
@@ -0,0 +1,13 @@
+###############################################################################
+# Copyright (c) 2008 Wind River Systems, Inc. and others.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+# Markus Schorn (Wind River Systems)
+###############################################################################
+CRefactoringActionGroup_menu=Refactor
+CRenameAction_label=Rename...
+ExtractConstantAction_label=Extract Constant...
diff --git a/releng/org.eclipse.cdt-feature/feature.xml b/releng/org.eclipse.cdt-feature/feature.xml
index 78850b873c3..e093f54e0a2 100644
--- a/releng/org.eclipse.cdt-feature/feature.xml
+++ b/releng/org.eclipse.cdt-feature/feature.xml
@@ -232,13 +232,6 @@
version="0.0.0"
unpack="false"/>
-
-
-
-
-
-
-
-
diff --git a/releng/org.eclipse.cdt.releng/maps/cdt.map b/releng/org.eclipse.cdt.releng/maps/cdt.map
index 84f70a0ea8a..b542c96aabf 100644
--- a/releng/org.eclipse.cdt.releng/maps/cdt.map
+++ b/releng/org.eclipse.cdt.releng/maps/cdt.map
@@ -4,7 +4,6 @@ feature@org.eclipse.cdt.master=@cdtTag@,:pserver:anonymous@dev.eclipse.org:/cvsr
! Cross platform
plugin@org.eclipse.cdt.core=@cdtTag@,:pserver:anonymous@dev.eclipse.org:/cvsroot/tools,,org.eclipse.cdt/all/org.eclipse.cdt.core
plugin@org.eclipse.cdt.ui=@cdtTag@,:pserver:anonymous@dev.eclipse.org:/cvsroot/tools,,org.eclipse.cdt/all/org.eclipse.cdt.ui
-plugin@org.eclipse.cdt.refactoring=@cdtTag@,:pserver:anonymous@dev.eclipse.org:/cvsroot/tools,,org.eclipse.cdt/all/org.eclipse.cdt.refactoring
plugin@org.eclipse.cdt.make.core=@cdtTag@,:pserver:anonymous@dev.eclipse.org:/cvsroot/tools,,org.eclipse.cdt/all/org.eclipse.cdt.make.core
plugin@org.eclipse.cdt.make.ui=@cdtTag@,:pserver:anonymous@dev.eclipse.org:/cvsroot/tools,,org.eclipse.cdt/all/org.eclipse.cdt.make.ui
@@ -42,7 +41,6 @@ fragment@org.eclipse.cdt.core.win32=@cdtTag@,:pserver:anonymous@dev.eclipse.org:
! Testing feature
plugin@org.eclipse.cdt.core.tests=@cdtTag@,:pserver:anonymous@dev.eclipse.org:/cvsroot/tools,,org.eclipse.cdt/all/org.eclipse.cdt.core.tests
plugin@org.eclipse.cdt.ui.tests=@cdtTag@,:pserver:anonymous@dev.eclipse.org:/cvsroot/tools,,org.eclipse.cdt/all/org.eclipse.cdt.ui.tests
-plugin@org.eclipse.cdt.refactoring.tests=@cdtTag@,:pserver:anonymous@dev.eclipse.org:/cvsroot/tools,,org.eclipse.cdt/all/org.eclipse.cdt.refactoring.tests
plugin@org.eclipse.cdt.debug.ui.tests=@cdtTag@,:pserver:anonymous@dev.eclipse.org:/cvsroot/tools,,org.eclipse.cdt/all/org.eclipse.cdt.debug.ui.tests
plugin@org.eclipse.cdt.managedbuilder.core.tests=@cdtTag@,:pserver:anonymous@dev.eclipse.org:/cvsroot/tools,,org.eclipse.cdt/all/org.eclipse.cdt.managedbuilder.core.tests
plugin@org.eclipse.cdt.managedbuilder.ui.tests=@cdtTag@,:pserver:anonymous@dev.eclipse.org:/cvsroot/tools,,org.eclipse.cdt/all/org.eclipse.cdt.managedbuilder.ui.tests
diff --git a/releng/org.eclipse.cdt.testing-feature/feature.xml b/releng/org.eclipse.cdt.testing-feature/feature.xml
index 3622f3798f9..12392444bfd 100644
--- a/releng/org.eclipse.cdt.testing-feature/feature.xml
+++ b/releng/org.eclipse.cdt.testing-feature/feature.xml
@@ -42,7 +42,6 @@
-
@@ -102,10 +101,4 @@
install-size="0"
version="0.0.0"/>
-
-