1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Fix 48209, 147772 - editor context menu cleanup

This commit is contained in:
Anton Leherbauer 2006-09-15 14:07:08 +00:00
parent a0368c245a
commit f3367693d7
13 changed files with 922 additions and 555 deletions

View file

@ -196,10 +196,10 @@ CEditorFontDefinition.description = The C/C++ editor text font is used by C/C++
BuildConsoleFontDefinition.description= The C-Build console font is used by the C-Build console
BuildConsoleFontDefinition.label= C-Build Console Text Font
ActionDefinition.GotoNextMember.name = Go to next C/C++ member
ActionDefinition.GotoNextMember.description = Goes to the next C/C++ member
ActionDefinition.GotoPrevMember.name = Go to previous C/C++ member
ActionDefinition.GotoPrevMember.description = Goes to the previous C/C++ member
ActionDefinition.GotoNextMember.name = Go to Next Member
ActionDefinition.GotoNextMember.description = Move the caret to the next member of the translation unit
ActionDefinition.GotoPrevMember.name = Go to Previous Member
ActionDefinition.GotoPrevMember.description = Move the caret to the previous member of the translation unit
##########################################################################
# Filter Support

View file

@ -215,6 +215,8 @@
<showInPart id="org.eclipse.cdt.ui.includeBrowser"/>
<showInPart id="org.eclipse.cdt.ui.CView"/>
<actionSet id="org.eclipse.cdt.ui.CEditorPresentationActionSet"/>
<showInPart id="org.eclipse.ui.navigator.ProjectExplorer"/>
<viewShortcut id="org.eclipse.ui.navigator.ProjectExplorer"/>
<!--perspectiveShortcut
id="org.eclipse.cdt.ui.CBrowsingPerspective">
</perspectiveShortcut-->

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2005 IBM Corporation and others.
* Copyright (c) 2006 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
@ -8,11 +8,13 @@
* Contributors:
* IBM Corporation - initial API and implementation
* QNX Software System
* Anton Leherbauer (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.internal.ui;
import org.eclipse.ui.navigator.ICommonMenuConstants;
import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.ui.IWorkbenchActionConstants;
/**
* Constants for menu groups used in context menus for C views and editors.
@ -39,7 +41,7 @@ public interface IContextMenuConstants {
public static final String TARGET_ID_SUBTYPES_VIEW= CUIPlugin.ID_TYPE_HIERARCHY + ".subtypes"; //$NON-NLS-1$
/**
* Type hierarchy view part: pop-up menu target ID for the meber viewer
* Type hierarchy view part: pop-up menu target ID for the member viewer
* (value <code>"org.eclipse.cdt.ui.TypeHierarchy.members"</code>).
*
* @since 2.0
@ -47,7 +49,7 @@ public interface IContextMenuConstants {
public static final String TARGET_ID_MEMBERS_VIEW= CUIPlugin.ID_TYPE_HIERARCHY + ".members"; //$NON-NLS-1$
/**
* Pop-up menu: name of group for goto actions (value <code>"group.open"</code>).
* Pop-up menu: name of group for goto actions (value <code>"group.goto"</code>).
* <p>
* Examples for open actions are:
* <ul>
@ -56,7 +58,7 @@ public interface IContextMenuConstants {
* </ul>
* </p>
*/
public static final String GROUP_GOTO= "group.goto"; //$NON-NLS-1$
public static final String GROUP_GOTO= ICommonMenuConstants.GROUP_GOTO;
/**
* Pop-up menu: name of group for open actions (value <code>"group.open"</code>).
* <p>
@ -67,7 +69,7 @@ public interface IContextMenuConstants {
* </ul>
* </p>
*/
public static final String GROUP_OPEN= "group.open"; //$NON-NLS-1$
public static final String GROUP_OPEN= ICommonMenuConstants.GROUP_OPEN;
/**
* Pop-up menu: name of group for show actions (value <code>"group.show"</code>).
@ -79,7 +81,7 @@ public interface IContextMenuConstants {
* </ul>
* </p>
*/
public static final String GROUP_SHOW= "group.show"; //$NON-NLS-1$
public static final String GROUP_SHOW= ICommonMenuConstants.GROUP_SHOW;
/**
* Pop-up menu: name of group for new actions (value <code>"group.new"</code>).
@ -91,42 +93,42 @@ public interface IContextMenuConstants {
* </ul>
* </p>
*/
public static final String GROUP_NEW= "group.new"; //$NON-NLS-1$
public static final String GROUP_NEW= ICommonMenuConstants.GROUP_NEW;
/**
* Pop-up menu: name of group for build actions (value <code>"group.build"</code>).
*/
public static final String GROUP_BUILD= "group.build"; //$NON-NLS-1$
public static final String GROUP_BUILD= ICommonMenuConstants.GROUP_BUILD;
/**
* Pop-up menu: name of group for reorganize actions (value <code>"group.reorganize"</code>).
*/
public static final String GROUP_REORGANIZE= IWorkbenchActionConstants.GROUP_REORGANIZE;
public static final String GROUP_REORGANIZE= ICommonMenuConstants.GROUP_REORGANIZE;
/**
* Pop-up menu: name of group for code generation or refactoring actions (
* value <code>"group.generate"</code>).
*/
public static final String GROUP_GENERATE= "group.generate"; //$NON-NLS-1$
public static final String GROUP_GENERATE= ICommonMenuConstants.GROUP_GENERATE;
/**
* Pop-up menu: name of group for search actions (value <code>"group.search"</code>).
*/
public static final String GROUP_SEARCH= "group.search"; //$NON-NLS-1$
public static final String GROUP_SEARCH= ICommonMenuConstants.GROUP_SEARCH;
/**
* Pop-up menu: name of group for additional actions (value <code>"group.additions"</code>).
*/
public static final String GROUP_ADDITIONS= "additions"; //$NON-NLS-1$
public static final String GROUP_ADDITIONS= ICommonMenuConstants.GROUP_ADDITIONS;
/**
* Pop-up menu: name of group for viewer setup actions (value <code>"group.viewerSetup"</code>).
*/
public static final String GROUP_VIEWER_SETUP= "group.viewerSetup"; //$NON-NLS-1$
public static final String GROUP_VIEWER_SETUP= ICommonMenuConstants.GROUP_VIEWER_SETUP;
/**
* Pop-up menu: name of group for properties actions (value <code>"group.properties"</code>).
*/
public static final String GROUP_PROPERTIES= "group.properties"; //$NON-NLS-1$
public static final String GROUP_PROPERTIES= ICommonMenuConstants.GROUP_PROPERTIES;
}

View file

@ -1,5 +1,5 @@
###############################################################################
# Copyright (c) 2000, 2005 IBM Corporation and others.
# Copyright (c) 2000, 2006 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
@ -13,6 +13,7 @@ OpenWithMenu.label=Open Wit&h
RefactorMenu.label=Refac&tor
SourceMenu.label=&Source
NavigateMenu.label=&Navigate
SourceMenu_label=Source
BuildAction.label=&Build Project
RebuildAction.label=Rebuild Pro&ject
@ -50,135 +51,6 @@ OpenTypeHierarchyAction.messages.no_c_resources=Selected package fragment doesn\
OpenTypeHierarchyAction.messages.no_types=Selected translation unit doesn\'t contain a type.
OpenTypeHierarchyAction.messages.no_valid_c_element=No valid C element selected.
ShowInPackageViewAction.label=Show in Pac&kage Explorer
ShowInPackageViewAction.description=Show the selected element in Package Explorer
ShowInPackageViewAction.tooltip=Show in Package Explorer
ShowInPackageViewAction.select_name=&Select or enter the element to reveal:
ShowInPackageViewAction.dialog.title=Show In Package Explorer
ShowInPackageViewAction.error.message=Internal error. Please see log for details.
ShowInPackageViewAction.not_found=Cannot reveal the selected element in Package Explorer. The element may be filtered out.
ShowInNavigatorView.label=Show in &Navigator View
ShowInNavigatorView.dialog.title=Show in Navigator View
ShowInNavigatorView.dialog.message=Select the element to be opened in the navigator view:
ShowInNavigatorView.error.activation_failed=Unable to activate Resource Navigator
ShowInNavigatorView.error.conversion_failed=Unable to convert Java element into a resource
OverrideMethodsAction.label=O&verride/Implement Methods...
OverrideMethodsAction.description=Override or Implement Methods from super types.
OverrideMethodsAction.tooltip=Override/Implement Methods
OverrideMethodsAction.error.title=Override/Implement Methods
OverrideMethodsAction.error.nothing_found=No methods to override found for this type.
OverrideMethodsAction.error.type_removed_in_editor=Input type has been removed in editor.
OverrideMethodsAction.not_applicable=Operation not applicable to current text selection. Please position the cursor inside a type.
AddGetterSetterAction.label=Gene&rate Getter and Setter...
AddGetterSetterAction.description=Generate Getter and Setter methods for type's fields
AddGetterSetterAction.tooltip=Generate Getter and Setter methods for the Type's Fields
AddGetterSetterAction.error.title=Generate Getter and Setter
AddGetterSetterAction.error.actionfailed=Generating Getter and Setter Failed.
AddGetterSetterAction.error.fieldNotExisting=The field ''{0}'' has been removed in the editor.
AddGetterSetterAction.not_applicable=Operation not applicable to current text selection. A field has to be selected or a type that declares fields.
AddGetterSetterAction.read_only=The compilation unit in which the field ''{0}'' is declared is read only.
AddGetterSetterAction.QueryDialog.title=Generate Getter and Setter
AddGetterSetterAction.SkipSetterForFinalDialog.message=Field ''{0}'' is final.\nOK to skip creation of the setter method?
AddGetterSetterAction.SkipExistingDialog.message=Method ''{0}'' already exists.\nSkip creation?
AddGetterSetterAction.SkipExistingDialog.skip.label=&Skip
AddGetterSetterAction.SkipExistingDialog.replace.label=&Replace
AddGetterSetterAction.SkipExistingDialog.skipAll.label=Skip &All
AddGetterSetterAction.dialog.title=&Select getters and setters to create:
AddGetterSetterAction.one_selected=1 method selected.
AddGetterSetterAction.methods_selected={0} methods selected.
AddGettSetterAction.typeContainsNoFields.message=The type contains no fields or all fields have getters/setters already.
AddUnimplementedConstructorsAction.label=Add &Constructors from Superclass
AddUnimplementedConstructorsAction.description=Evaluate and add constructors from superclass
AddUnimplementedConstructorsAction.tooltip=Add Constructors from Superclass
AddUnimplementedConstructorsAction.error.title=Add Constructors from Superclass
AddUnimplementedConstructorsAction.error.nothing_found=No unimplemented constructors found.
AddUnimplementedConstructorsAction.error.type_removed_in_editor=Input type has been removed in editor.
AddUnimplementedConstructorsAction.not_applicable=Operation not applicable to current text selection. Please position the cursor inside a type.
AddJavaDocStubAction.label=Add &Javadoc Comment
AddJavaDocStubAction.description=Add a Javadoc comment stub to the member element
AddJavaDocStubAction.tooltip=Add a Javadoc comment stub to the member element
AddJavaDocStubsAction.error.dialogTitle=Add Javadoc Comment
AddJavaDocStubsAction.error.noWorkingCopy=Could not find working copy.
AddJavaDocStubsAction.error.memberNotExisting=Member has been removed in editor.
AddJavaDocStubsAction.error.actionFailed=Error while adding Javadoc comment
AddJavaDocStubsAction.not_applicable=Operation not applicable to current text selection. Please position the cursor inside a type or method.
ExternalizeStringsAction.label= &Externalize Strings...
ExternalizeStringsAction.dialog.title= Externalize Strings
ExternalizeStringsAction.dialog.message=Couldn't open Externalize String Wizard
FindStringsToExternalizeAction.label= &Find Strings to Externalize...
FindStringsToExternalizeAction.dialog.title= Find Strings to Externalize
FindStringsToExternalizeAction.error.message=Unexpected Exception. See log.
FindStringsToExternalizeAction.foundStrings= {0} in {1}
FindStringsToExternalizeAction.noStrings= No strings to externalize were found.
FindStringsToExternalizeAction.not_externalized= {0} &not externalized string(s) found.
FindStringsToExternalizeAction.button.label= &Externalize...
FindStringsToExternalizeAction.find_strings=Finding not externalized strings...
OpenExternalJavadocAction.label=Open E&xternal Javadoc
OpenExternalJavadocAction.description=Opens the Javadoc of the selected element in an external browser
OpenExternalJavadocAction.tooltip=Opens the Javadoc of the selected element in an external browser
OpenExternalJavadocAction.help_not_available=Help support not available
OpenExternalJavadocAction.select_element=&Select or enter the element to open:
OpenExternalJavadocAction.libraries.no_location=The documentation location for ''{0}'' has not been configured. For elements from libraries specify the Javadoc location URL on the property page of the parent JAR (''{1}'')
OpenExternalJavadocAction.source.no_location=The documentation location for ''{0}'' has not been configured. For elements from source specify the Javadoc location URL on the property page of the parent project (''{1}'')
OpenExternalJavadocAction.no_entry=The documentation does not contain an entry for ''{0}''.\n(File ''{1}'' does not exist.)
OpenExternalJavadocAction.opening_failed=Opening Javadoc failed. See log for details
OpenExternalJavadocAction.dialog.title=Open External Javadoc
OpenExternalJavadocAction.code_resolve_failed=Couldn't convert text selection into a Java element
SelfEncapsulateFieldAction.label=Encap&sulate Field...
SelfEncapsulateFieldAction.dialog.title=Encapsulate Field
SelfEncapsulateFieldAction.dialog.unavailable=Operation unavailable on the current selection. Select a field.
SelfEncapsulateFieldAction.dialog.cannot_perform=Cannot perform refactoring. See log for more details.
SelfEncapsulateFieldAction.dialog.field_doesnot_exit=Editor buffer does not contain field {0}.
OrganizeImportsAction.label=Or&ganize Imports
OrganizeImportsAction.tooltip=Evaluate All Required Imports and Replace the Current Imports
OrganizeImportsAction.description=Evaluate all required imports and replace the current imports
OrganizeImportsAction.multi.op.description=Organizing imports...
OrganizeImportsAction.multi.error.parse={0}: Compilation unit has parse errors. No changes applied.
OrganizeImportsAction.multi.error.readonly={0}: Compilation unit is read-only. No changes applied.
OrganizeImportsAction.multi.error.unresolvable={0}: Compilation unit contains ambiguous references. User interaction required.
OrganizeImportsAction.multi.error.unexpected={0}: Unexpected error. See log for details.
OrganizeImportsAction.multi.error.notoncp={0}: Compilation unit not on build path. No changes applied.
OrganizeImportsAction.selectiondialog.title=Organize Imports
OrganizeImportsAction.selectiondialog.message=&Choose type to import:
OrganizeImportsAction.error.title=Organize Imports
OrganizeImportsAction.error.message=Unexpected error in organize imports. See log for details.
OrganizeImportsAction.single.error.parse=Compilation unit has parse errors: ''{0}''. No changes applied.
OrganizeImportsAction.summary_added={0} import(s) added.
OrganizeImportsAction.summary_removed={0} import(s) removed.
OrganizeImportsAction.multi.status.title=Organize Imports
OrganizeImportsAction.multi.status.description=Problems while organizing imports on some compilation units. See 'Details' for more information.
SortMembersAction.label=Sort &Members
SortMembersAction.tooltip=Sorts all Members using the Member Order Preference
SortMembersAction.description=Sorts all members using the member order preference
SortMembersAction.error.title=Sort Members
SortMembersAction.not_applicable=Operation not applicable to current text editor.
SortMembersAction.containsmarkers=Markers like bookmarks, breakpoints or user defined tasks in a reordered member will be lost. Ok to continue?
OpenBrowserUtil.help_not_available=Help support not available
MemberFilterActionGroup.hide_fields.label=Hide Fiel&ds
@ -201,13 +73,6 @@ OpenProjectAction.error.message=Problems while opening projects
OpenProjectAction.no_java_nature.one=The following project doesn't have a Java nature and is therefore not present in the Package Explorer:
OpenProjectAction.no_java_nature.multiple=The following projects don't have a Java nature and are therefore not present in the Package Explorer:
OpenJavaPerspectiveAction.dialog.title=Open Java Perspective
OpenJavaPerspectiveAction.error.open_failed=Couldn\'t open Java perspective
OpenJavaBrowsingPerspectiveAction.dialog.title=Open Java Browsing Perspective
OpenJavaBrowsingPerspectiveAction.error.open_failed=Couldn\'t open Java browsing perspective
OpenTypeInHierarchyAction.label=Open Type in Hierarchy...
OpenTypeInHierarchyAction.description=Open a type in a type hierarchy
@ -223,12 +88,6 @@ RefreshAction.error.message= Problems occurred refreshing the selected resources
RefreshAction.locationDeleted.title= Project location has been deleted
RefreshAction.locationDeleted.message= The location for project {0} ({1}) has been deleted.\n Delete {0} from the workspace?
ModifyParameterAction.problem.title=Refactoring
ModifyParameterAction.problem.message=Operation not possible.
PullUpAction.problem.title=Refactoring
PullUpAction.problem.message=Operation not possible.
OverrideMethodQuery.groupMethodsByTypes=Group methods by &types
OverrideMethodQuery.dialog.title=Override/Implement Methods
OverrideMethodQuery.dialog.description=&Select methods to override or implement:
@ -243,36 +102,6 @@ ActionUtil.no_linked=This operation is unavailable on linked packages and packag
SelectAllAction.label= Select A&ll
SelectAllAction.tooltip= Select All
AddToClasspathAction.label=Add to &Build Path
AddToClasspathAction.toolTip=Add JAR to the Java build path
AddToClasspathAction.progressMessage=Adding to build path...
AddToClasspathAction.error.title=Add to Build Path
AddToClasspathAction.error.message=Problems occurred while adding to the build path.
RemoveFromClasspathAction.Remove=Remove from &Build Path
RemoveFromClasspathAction.tooltip=Remove package fragment root from the Java build path
RemoveFromClasspathAction.Removing=Removing from build path...
RemoveFromClasspathAction.exception_dialog_title=Remove From Build Path
RemoveFromClasspathAction.Problems_occurred=Problems occurred while removing from the build path.
AddDelegateMethodsAction.error.title=Generate Delegate Methods
AddDelegateMethodsAction.error.actionfailed=Generating delegate methods failed.
AddDelegateMethodsAction.label=Generate Delegate &Methods...
AddDelegateMethodsAction.description=Adds delegate methods for a type's fields
AddDelegateMethodsAction.tooltip=Adds Delegates Methods for a Type's Fields
AddDelegateMethodsAction.not_applicable=Operation not applicable to current text selection. Please select a field or a type that declares some fields.
AddDelegateMethodsAction.duplicate_methods=Duplicate method(s) selected
AddDelegateMethodsAction.title=Delegate Methods Generation
AddDelegateMethodsAction.message=Select &methods to create delegates for:
AddDelegateMethodsAction.monitor.message=Creating {0} methods...
AddDelegateMethodsAction.selectioninfo.one={0} method selected.
AddDelegateMethodsAction.selectioninfo.more={0} methods selected.
ToggleLinkingAction.label=Lin&k With Editor
ToggleLinkingAction.tooltip=Link with Editor
ToggleLinkingAction.description=Link with active editor

View file

@ -7,35 +7,65 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
* Anton Leherbauer (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.internal.ui.actions;
import org.eclipse.jface.action.IMenuManager;
import java.util.ResourceBundle;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.text.ITextViewer;
import org.eclipse.jface.text.source.projection.IProjectionListener;
import org.eclipse.jface.text.source.projection.ProjectionViewer;
import org.eclipse.ui.actions.ActionGroup;
import org.eclipse.ui.editors.text.IFoldingCommandIds;
import org.eclipse.ui.texteditor.ITextEditor;
import org.eclipse.ui.texteditor.IUpdate;
import org.eclipse.ui.texteditor.ResourceAction;
import org.eclipse.ui.texteditor.TextOperationAction;
import org.eclipse.cdt.internal.ui.editor.CEditor;
/**
* Groups the JDT folding actions.
* Groups the CDT folding actions.
*
* @since 3.0
*/
public class FoldingActionGroup extends ActionGroup {
private static abstract class PreferenceAction extends ResourceAction implements IUpdate {
PreferenceAction(ResourceBundle bundle, String prefix, int style) {
super(bundle, prefix, style);
}
}
private class FoldingAction extends PreferenceAction {
FoldingAction(ResourceBundle bundle, String prefix) {
super(bundle, prefix, IAction.AS_PUSH_BUTTON);
}
public void update() {
setEnabled(FoldingActionGroup.this.isEnabled() && fViewer.isProjectionMode());
}
}
private ProjectionViewer fViewer;
private IProjectionListener fProjectionListener;
private TextOperationAction fToggle;
private TextOperationAction fExpand;
private TextOperationAction fCollapse;
private TextOperationAction fExpandAll;
// since 4.0
private TextOperationAction fCollapseAll;
private PreferenceAction fRestoreDefaults;
private IProjectionListener fProjectionListener;
/**
* Creates a new projection action group for <code>editor</code>. If the
@ -45,40 +75,64 @@ public class FoldingActionGroup extends ActionGroup {
* @param editor the text editor to operate on
* @param viewer the viewer of the editor
*/
public FoldingActionGroup(ITextEditor editor, ITextViewer viewer) {
if (viewer instanceof ProjectionViewer) {
fViewer= (ProjectionViewer) viewer;
fProjectionListener= new IProjectionListener() {
public void projectionEnabled() {
update();
}
public void projectionDisabled() {
update();
}
};
fViewer.addProjectionListener(fProjectionListener);
fToggle= new TextOperationAction(ActionMessages.getResourceBundle(), "Projection.Toggle.", editor, ProjectionViewer.TOGGLE, true); //$NON-NLS-1$
fToggle.setChecked(true);
fToggle.setActionDefinitionId(IFoldingCommandIds.FOLDING_TOGGLE);
editor.setAction("FoldingToggle", fToggle); //$NON-NLS-1$
fExpandAll= new TextOperationAction(ActionMessages.getResourceBundle(), "Projection.ExpandAll.", editor, ProjectionViewer.EXPAND_ALL, true); //$NON-NLS-1$
fExpandAll.setActionDefinitionId(IFoldingCommandIds.FOLDING_EXPAND_ALL);
editor.setAction("FoldingExpandAll", fExpandAll); //$NON-NLS-1$
fExpand= new TextOperationAction(ActionMessages.getResourceBundle(), "Projection.Expand.", editor, ProjectionViewer.EXPAND, true); //$NON-NLS-1$
fExpand.setActionDefinitionId(IFoldingCommandIds.FOLDING_EXPAND);
editor.setAction("FoldingExpand", fExpand); //$NON-NLS-1$
fCollapse= new TextOperationAction(ActionMessages.getResourceBundle(), "Projection.Collapse.", editor, ProjectionViewer.COLLAPSE, true); //$NON-NLS-1$
fCollapse.setActionDefinitionId(IFoldingCommandIds.FOLDING_COLLAPSE);
editor.setAction("FoldingCollapse", fCollapse); //$NON-NLS-1$
public FoldingActionGroup(final ITextEditor editor, ITextViewer viewer) {
if (!(viewer instanceof ProjectionViewer)) {
fToggle= null;
fExpand= null;
fCollapse= null;
fExpandAll= null;
fCollapseAll= null;
fRestoreDefaults= null;
fProjectionListener= null;
return;
}
fViewer= (ProjectionViewer) viewer;
fProjectionListener= new IProjectionListener() {
public void projectionEnabled() {
update();
}
public void projectionDisabled() {
update();
}
};
fViewer.addProjectionListener(fProjectionListener);
fToggle= new TextOperationAction(FoldingMessages.getResourceBundle(), "Projection.Toggle.", editor, ProjectionViewer.TOGGLE, true); //$NON-NLS-1$
fToggle.setChecked(true);
fToggle.setActionDefinitionId(IFoldingCommandIds.FOLDING_TOGGLE);
editor.setAction("FoldingToggle", fToggle); //$NON-NLS-1$
fExpandAll= new TextOperationAction(FoldingMessages.getResourceBundle(), "Projection.ExpandAll.", editor, ProjectionViewer.EXPAND_ALL, true); //$NON-NLS-1$
fExpandAll.setActionDefinitionId(IFoldingCommandIds.FOLDING_EXPAND_ALL);
editor.setAction("FoldingExpandAll", fExpandAll); //$NON-NLS-1$
fCollapseAll= new TextOperationAction(FoldingMessages.getResourceBundle(), "Projection.CollapseAll.", editor, ProjectionViewer.COLLAPSE, true); //$NON-NLS-1$
fCollapseAll.setActionDefinitionId(IFoldingCommandIds.FOLDING_COLLAPSE_ALL);
editor.setAction("FoldingCollapseAll", fCollapseAll); //$NON-NLS-1$
fExpand= new TextOperationAction(FoldingMessages.getResourceBundle(), "Projection.Expand.", editor, ProjectionViewer.EXPAND, true); //$NON-NLS-1$
fExpand.setActionDefinitionId(IFoldingCommandIds.FOLDING_EXPAND);
editor.setAction("FoldingExpand", fExpand); //$NON-NLS-1$
fCollapse= new TextOperationAction(FoldingMessages.getResourceBundle(), "Projection.Collapse.", editor, ProjectionViewer.COLLAPSE, true); //$NON-NLS-1$
fCollapse.setActionDefinitionId(IFoldingCommandIds.FOLDING_COLLAPSE);
editor.setAction("FoldingCollapse", fCollapse); //$NON-NLS-1$
fRestoreDefaults= new FoldingAction(FoldingMessages.getResourceBundle(), "Projection.Restore.") { //$NON-NLS-1$
public void run() {
if (editor instanceof CEditor) {
CEditor cEditor= (CEditor) editor;
cEditor.resetProjection();
}
}
};
fRestoreDefaults.setActionDefinitionId(IFoldingCommandIds.FOLDING_RESTORE);
editor.setAction("FoldingRestore", fRestoreDefaults); //$NON-NLS-1$
}
/**
@ -114,6 +168,8 @@ public class FoldingActionGroup extends ActionGroup {
fExpand.update();
fExpandAll.update();
fCollapse.update();
fCollapseAll.update();
fRestoreDefaults.update();
}
}
@ -129,6 +185,8 @@ public class FoldingActionGroup extends ActionGroup {
manager.add(fExpandAll);
manager.add(fExpand);
manager.add(fCollapse);
manager.add(fCollapseAll);
manager.add(fRestoreDefaults);
}
}

View file

@ -0,0 +1,80 @@
/*******************************************************************************
* Copyright (c) 2000, 2006 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 Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.ui.actions;
import com.ibm.icu.text.MessageFormat;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
/**
* Class that gives access to the folding messages resource bundle.
*/
public class FoldingMessages {
private static final String BUNDLE_NAME= "org.eclipse.cdt.internal.ui.actions.FoldingMessages"; //$NON-NLS-1$
private static final ResourceBundle RESOURCE_BUNDLE= ResourceBundle.getBundle(BUNDLE_NAME);
private FoldingMessages() {
// no instance
}
/**
* Returns the resource string associated with the given key in the resource bundle. If there isn't
* any value under the given key, the key is returned.
*
* @param key the resource key
* @return the string
*/
public static String getString(String key) {
try {
return RESOURCE_BUNDLE.getString(key);
} catch (MissingResourceException e) {
return '!' + key + '!';
}
}
/**
* Returns the resource bundle managed by the receiver.
*
* @return the resource bundle
* @since 3.0
*/
public static ResourceBundle getResourceBundle() {
return RESOURCE_BUNDLE;
}
/**
* Returns the formatted resource string associated with the given key in the resource bundle.
* <code>MessageFormat</code> is used to format the message. If there isn't any value
* under the given key, the key is returned.
*
* @param key the resource key
* @param arg the message argument
* @return the string
*/
public static String getFormattedString(String key, Object arg) {
return getFormattedString(key, new Object[] { arg });
}
/**
* Returns the formatted resource string associated with the given key in the resource bundle.
* <code>MessageFormat</code> is used to format the message. If there isn't any value
* under the given key, the key is returned.
*
* @param key the resource key
* @param args the message arguments
* @return the string
*/
public static String getFormattedString(String key, Object[] args) {
return MessageFormat.format(getString(key), args);
}
}

View file

@ -0,0 +1,39 @@
###############################################################################
# Copyright (c) 2005, 2006 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 Corporation - initial API and implementation
###############################################################################
Projection.Toggle.label= &Enable Folding
Projection.Toggle.tooltip= Toggles Folding
Projection.Toggle.description= Toggles folding for the current editor
Projection.Toggle.image=
Projection.ExpandAll.label= Expand &All
Projection.ExpandAll.tooltip= Expands All Collapsed Regions
Projection.ExpandAll.description= Expands any collapsed regions in the current editor
Projection.ExpandAll.image=
Projection.Expand.label= E&xpand
Projection.Expand.tooltip= Expands the Current Collapsed Region
Projection.Expand.description= Expands the collapsed region at the current selection
Projection.Expand.image=
Projection.CollapseAll.label= Collapse A&ll
Projection.CollapseAll.tooltip= Collapses All Expanded Regions
Projection.CollapseAll.description= Collapse any expanded regions in the current editor
Projection.CollapseAll.image=
Projection.Collapse.label= Colla&pse
Projection.Collapse.tooltip= Collapses the Current Region
Projection.Collapse.description= Collapses the Current Region
Projection.Collapse.image=
Projection.Restore.label= &Reset Structure
Projection.Restore.tooltip= Restore the Original Folding Structure
Projection.Restore.description= Restores the original folding structure
Projection.Restore.image=

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2005 IBM Corporation and others.
* Copyright (c) 2005, 2006 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
@ -7,6 +7,7 @@
*
* Contributors:
* P.Tomaszewski
* Anton Leherbauer (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.internal.ui.actions;
@ -15,17 +16,19 @@ import java.util.LinkedList;
import java.util.List;
import java.util.ResourceBundle;
import org.eclipse.cdt.core.model.CModelException;
import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.ISourceReference;
import org.eclipse.cdt.internal.core.model.WorkingCopy;
import org.eclipse.cdt.internal.ui.editor.CEditor;
import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.jface.text.ITextSelection;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.texteditor.ITextEditor;
import org.eclipse.ui.texteditor.TextEditorAction;
import org.eclipse.cdt.core.model.CModelException;
import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.ISourceReference;
import org.eclipse.cdt.core.model.IWorkingCopy;
import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.cdt.internal.ui.editor.CEditor;
/**
* Gives possibility to move fast between member elements of the c/c++ source.
*
@ -33,7 +36,10 @@ import org.eclipse.ui.texteditor.TextEditorAction;
*/
public class GoToNextPreviousMemberAction extends TextEditorAction {
/** Determines should action take user to the next member or to the previous one. */
public static final String NEXT_MEMBER = "GotoNextMember"; //$NON-NLS-1$
public static final String PREVIOUS_MEMBER = "GotoPrevMember"; //$NON-NLS-1$
/** Determines should action take user to the next member or to the previous one. */
private boolean fGotoNext;
/**
@ -63,14 +69,22 @@ public class GoToNextPreviousMemberAction extends TextEditorAction {
fGotoNext = gotoNext;
}
/**
/*
* @see org.eclipse.ui.texteditor.TextEditorAction#update()
*/
public void update() {
final ITextEditor editor = getTextEditor();
setEnabled(editor instanceof CEditor && ((CEditor)editor).getInputCElement() != null);
}
/**
* @see org.eclipse.jface.action.Action#run()
*/
public void run() {
final CEditor editor = (CEditor) getTextEditor();
final ITextSelection selection = (ITextSelection) editor.getSelectionProvider().getSelection();
final IEditorInput editorInput = editor.getEditorInput();
final WorkingCopy workingCopy = (WorkingCopy) CUIPlugin.getDefault().getWorkingCopyManager().getWorkingCopy(editorInput);
final IWorkingCopy workingCopy = CUIPlugin.getDefault().getWorkingCopyManager().getWorkingCopy(editorInput);
try {
final ICElement[] elements = workingCopy.getChildren();
final Integer[] elementOffsets = createSourceIndexes(elements);

View file

@ -24,10 +24,11 @@ import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.ListenerList;
import org.eclipse.core.runtime.content.IContentType;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.GroupMarker;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.IStatusLineManager;
import org.eclipse.jface.action.MenuManager;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.text.AbstractInformationControlManager;
import org.eclipse.jface.text.BadLocationException;
@ -97,6 +98,7 @@ import org.eclipse.ui.IPageLayout;
import org.eclipse.ui.IPartService;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.actions.ActionContext;
import org.eclipse.ui.actions.ActionGroup;
import org.eclipse.ui.editors.text.TextEditor;
import org.eclipse.ui.part.EditorActionBarContributor;
@ -133,6 +135,7 @@ import org.eclipse.cdt.refactoring.actions.CRefactoringActionGroup;
import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.cdt.ui.IWorkingCopyManager;
import org.eclipse.cdt.ui.PreferenceConstants;
import org.eclipse.cdt.ui.actions.GenerateActionGroup;
import org.eclipse.cdt.ui.actions.OpenViewActionGroup;
import org.eclipse.cdt.ui.actions.ShowInCViewAction;
import org.eclipse.cdt.ui.text.ICPartitions;
@ -140,6 +143,7 @@ import org.eclipse.cdt.ui.text.folding.ICFoldingStructureProvider;
import org.eclipse.cdt.internal.corext.util.SimplePositionTracker;
import org.eclipse.cdt.internal.ui.CPluginImages;
import org.eclipse.cdt.internal.ui.ICHelpContextIds;
import org.eclipse.cdt.internal.ui.IContextMenuConstants;
import org.eclipse.cdt.internal.ui.actions.AddBlockCommentAction;
@ -513,7 +517,10 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IS
private ActionGroup fTextSearchGroup;
private CRefactoringActionGroup fRefactoringActionGroup;
private ActionGroup fOpenInViewGroup;
/** Generate action group filling the "Source" submenu */
private GenerateActionGroup fGenerateActionGroup;
/** Action which shows selected element in CView. */
private ShowInCViewAction fShowInCViewAction;
@ -1034,6 +1041,11 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IS
fOpenInViewGroup = null;
}
if (fGenerateActionGroup != null) {
fGenerateActionGroup.dispose();
fGenerateActionGroup= null;
}
if (fEditorSelectionChangedListener != null) {
fEditorSelectionChangedListener.uninstall(getSelectionProvider());
fEditorSelectionChangedListener= null;
@ -1094,7 +1106,7 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IS
PlatformUI.getWorkbench().getHelpSystem().setHelp(resAction2, ICHelpContextIds.SHOW_TOOLTIP_ACTION);
// Default text editing menu items
Action action= new GotoMatchingBracketAction(this);
IAction action= new GotoMatchingBracketAction(this);
action.setActionDefinitionId(ICEditorActionDefinitionIds.GOTO_MATCHING_BRACKET);
setAction(GotoMatchingBracketAction.GOTO_MATCHING_BRACKET, action);
@ -1136,10 +1148,6 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IS
action.setActionDefinitionId(ITextEditorActionDefinitionIds.CONTENT_ASSIST_CONTEXT_INFORMATION);
setAction("ContentAssistTip", action); //$NON-NLS-1$
action = new AddIncludeOnSelectionAction(this);
action.setActionDefinitionId(ICEditorActionDefinitionIds.ADD_INCLUDE);
setAction("AddIncludeOnSelection", action); //$NON-NLS-1$
action = new OpenDeclarationsAction(this);
action.setActionDefinitionId(ICEditorActionDefinitionIds.OPEN_DECL);
setAction("OpenDeclarations", action); //$NON-NLS-1$
@ -1163,17 +1171,29 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IS
action = new GoToNextPreviousMemberAction(CEditorMessages.getResourceBundle(), "GotoNextMember.", this, true); //$NON-NLS-1$
action.setActionDefinitionId(ICEditorActionDefinitionIds.GOTO_NEXT_MEMBER);
setAction("GotoNextMember", action); //$NON-NLS-1$*/
setAction(GoToNextPreviousMemberAction.PREVIOUS_MEMBER, action);
action = new GoToNextPreviousMemberAction(CEditorMessages.getResourceBundle(), "GotoPrevMember.", this, false); //$NON-NLS-1$
action = new GoToNextPreviousMemberAction(CEditorMessages.getResourceBundle(), "GotoPreviousMember.", this, false); //$NON-NLS-1$
action.setActionDefinitionId(ICEditorActionDefinitionIds.GOTO_PREVIOUS_MEMBER);
setAction("GotoPrevMember", action); //$NON-NLS-1$*/
setAction(GoToNextPreviousMemberAction.NEXT_MEMBER, action);
//Assorted action groupings
fSelectionSearchGroup = new SelectionSearchGroup(this);
fTextSearchGroup= new TextSearchGroup(this);
fRefactoringActionGroup= new CRefactoringActionGroup(this);
fRefactoringActionGroup= new CRefactoringActionGroup(this, ITextEditorActionConstants.GROUP_EDIT);
fOpenInViewGroup= new OpenViewActionGroup(this);
fGenerateActionGroup= new GenerateActionGroup(this, ITextEditorActionConstants.GROUP_EDIT);
action = getAction(ITextEditorActionConstants.SHIFT_RIGHT);
if (action != null) {
action.setId(ITextEditorActionConstants.SHIFT_RIGHT);
CPluginImages.setImageDescriptors(action, CPluginImages.T_LCL, CPluginImages.IMG_MENU_SHIFT_RIGHT);
}
action = getAction(ITextEditorActionConstants.SHIFT_LEFT);
if (action != null) {
action.setId(ITextEditorActionConstants.SHIFT_LEFT);
CPluginImages.setImageDescriptors(action, CPluginImages.T_LCL, CPluginImages.IMG_MENU_SHIFT_LEFT);
}
}
/**
@ -1181,28 +1201,22 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IS
*/
public void editorContextMenuAboutToShow(IMenuManager menu) {
super.editorContextMenuAboutToShow(menu);
// remove shift actions added by base class
menu.remove(ITextEditorActionConstants.SHIFT_LEFT);
menu.remove(ITextEditorActionConstants.SHIFT_RIGHT);
addGroup(menu, ITextEditorActionConstants.GROUP_EDIT, IContextMenuConstants.GROUP_REORGANIZE);
addGroup(menu, ITextEditorActionConstants.GROUP_EDIT, IContextMenuConstants.GROUP_GENERATE);
addGroup(menu, ITextEditorActionConstants.GROUP_EDIT, IContextMenuConstants.GROUP_NEW);
menu.insertAfter(IContextMenuConstants.GROUP_OPEN, new GroupMarker(IContextMenuConstants.GROUP_SHOW));
// Code formatting menu items -- only show in C perspective
addAction(menu, ITextEditorActionConstants.GROUP_EDIT, "ToggleComment"); //$NON-NLS-1$
addAction(menu, ITextEditorActionConstants.GROUP_EDIT, "AddBlockComment"); //$NON-NLS-1$
addAction(menu, ITextEditorActionConstants.GROUP_EDIT, "RemoveBlockComment"); //$NON-NLS-1$
addAction(menu, IContextMenuConstants.GROUP_OPEN, "OpenDeclarations"); //$NON-NLS-1$
addAction(menu, IContextMenuConstants.GROUP_OPEN, "OpenDefinition"); //$NON-NLS-1$
addAction(menu, IContextMenuConstants.GROUP_OPEN, "OpenTypeHierarchy"); //$NON-NLS-1$
addAction(menu, ITextEditorActionConstants.GROUP_FIND, "OpenDeclarations"); //$NON-NLS-1$
addAction(menu, ITextEditorActionConstants.GROUP_FIND, "OpenDefinition"); //$NON-NLS-1$
addAction(menu, IContextMenuConstants.GROUP_OPEN, "OpenOutline"); //$NON-NLS-1$
addAction(menu, ITextEditorActionConstants.GROUP_FIND, "OpenTypeHierarchy"); //$NON-NLS-1$
addAction(menu, ITextEditorActionConstants.GROUP_FIND, "GotoNextMember"); //$NON-NLS-1$
addAction(menu, ITextEditorActionConstants.GROUP_FIND, "GotoPrevMember"); //$NON-NLS-1$
addAction(menu, IContextMenuConstants.GROUP_GENERATE, "ContentAssistProposal"); //$NON-NLS-1$
addAction(menu, IContextMenuConstants.GROUP_GENERATE, "AddIncludeOnSelection"); //$NON-NLS-1$
addAction(menu, IContextMenuConstants.GROUP_GENERATE, "Format"); //$NON-NLS-1$
addAction(menu, IContextMenuConstants.GROUP_GENERATE, "ShowInCView"); //$NON-NLS-1$
ActionContext context= new ActionContext(getSelectionProvider().getSelection());
fGenerateActionGroup.setContext(context);
fGenerateActionGroup.fillContextMenu(menu);
fGenerateActionGroup.setContext(null);
fSelectionSearchGroup.fillContextMenu(menu);
fTextSearchGroup.fillContextMenu(menu);
@ -1210,6 +1224,24 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IS
fOpenInViewGroup.fillContextMenu(menu);
}
/*
* @see org.eclipse.ui.texteditor.AbstractTextEditor#rulerContextMenuAboutToShow(org.eclipse.jface.action.IMenuManager)
*/
protected void rulerContextMenuAboutToShow(IMenuManager menu) {
super.rulerContextMenuAboutToShow(menu);
IMenuManager foldingMenu= new MenuManager(CEditorMessages.getString("CEditor.menu.folding"), "projection"); //$NON-NLS-1$ //$NON-NLS-2$
menu.appendToGroup(ITextEditorActionConstants.GROUP_RULERS, foldingMenu);
IAction action= getAction("FoldingToggle"); //$NON-NLS-1$
foldingMenu.add(action);
action= getAction("FoldingExpandAll"); //$NON-NLS-1$
foldingMenu.add(action);
action= getAction("FoldingCollapseAll"); //$NON-NLS-1$
foldingMenu.add(action);
action= getAction("FoldingRestore"); //$NON-NLS-1$
foldingMenu.add(action);
}
/**
* Sets an input for the outline page.
* @param page Page to set the input.
@ -2296,6 +2328,27 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IS
public void fillActionBars(IActionBars actionBars) {
fOpenInViewGroup.fillActionBars(actionBars);
fRefactoringActionGroup.fillActionBars(actionBars);
fGenerateActionGroup.fillActionBars(actionBars);
}
/*
* @see org.eclipse.ui.texteditor.AbstractTextEditor#updateStateDependentActions()
*/
protected void updateStateDependentActions() {
super.updateStateDependentActions();
fGenerateActionGroup.editorStateChanged();
}
/**
* Resets the foldings structure according to the folding
* preferences.
*
* @since 4.0
*/
public void resetProjection() {
if (fProjectionModelUpdater != null) {
fProjectionModelUpdater.initialize();
}
}
}

View file

@ -9,20 +9,17 @@
* IBM Corporation - initial API and implementation
* QNX Software System
* Markus Schorn (Wind River Systems)
* Anton Leherbauer (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.internal.ui.editor;
import java.util.ResourceBundle;
import org.eclipse.cdt.internal.ui.CPluginImages;
import org.eclipse.cdt.internal.ui.IContextMenuConstants;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.IStatusLineManager;
import org.eclipse.jface.action.Separator;
import org.eclipse.jface.text.ITextOperationTarget;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.ISelectionProvider;
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.ui.IActionBars;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IWorkbenchActionConstants;
@ -31,83 +28,38 @@ import org.eclipse.ui.texteditor.ITextEditor;
import org.eclipse.ui.texteditor.ITextEditorActionConstants;
import org.eclipse.ui.texteditor.ITextEditorActionDefinitionIds;
import org.eclipse.ui.texteditor.RetargetTextEditorAction;
import org.eclipse.ui.texteditor.TextEditorAction;
import org.eclipse.cdt.internal.ui.CPluginImages;
import org.eclipse.cdt.internal.ui.IContextMenuConstants;
import org.eclipse.cdt.internal.ui.actions.GoToNextPreviousMemberAction;
public class CEditorActionContributor extends TextEditorActionContributor {
protected static class SelectionAction extends TextEditorAction implements ISelectionChangedListener {
protected int fOperationCode;
protected ITextOperationTarget fOperationTarget= null;
public SelectionAction(String prefix, int operation) {
super(CEditorMessages.getResourceBundle(), prefix, null);
fOperationCode= operation;
setEnabled(false);
}
/**
* @see TextEditorAction#setEditor(ITextEditor)
*/
public void setEditor(ITextEditor editor) {
if (getTextEditor() != null) {
ISelectionProvider p= getTextEditor().getSelectionProvider();
if (p != null) p.removeSelectionChangedListener(this);
}
super.setEditor(editor);
if (editor != null) {
ISelectionProvider p= editor.getSelectionProvider();
if (p != null) p.addSelectionChangedListener(this);
fOperationTarget= (ITextOperationTarget) editor.getAdapter(ITextOperationTarget.class);
} else {
fOperationTarget= null;
}
selectionChanged(null);
}
/**
* @see ISelectionChangedListener#selectionChanged(SelectionChangedEvent)
*/
public void selectionChanged(SelectionChangedEvent event) {
boolean isEnabled= (fOperationTarget != null && fOperationTarget.canDoOperation(fOperationCode));
setEnabled(isEnabled);
}
/*
* @see org.eclipse.jface.action.Action#run()
*/
public void run() {
if (fOperationCode != -1 && fOperationTarget != null)
fOperationTarget.doOperation(fOperationCode);
}
}
protected CEditor fCEditor;
protected RetargetTextEditorAction fContentAssist;
protected RetargetTextEditorAction fFormatter;
protected RetargetTextEditorAction fAddInclude;
protected RetargetTextEditorAction fOpenOnSelection;
protected SelectionAction fShiftLeft;
protected SelectionAction fShiftRight;
// protected RetargetTextEditorAction fOpenOnSelection;
protected RetargetTextEditorAction fShiftLeft;
protected RetargetTextEditorAction fShiftRight;
private TogglePresentationAction fTogglePresentation;
private GotoAnnotationAction fPreviousAnnotation;
private GotoAnnotationAction fNextAnnotation;
private RetargetTextEditorAction fGotoMatchingBracket;
private RetargetTextEditorAction fGotoNextMemberAction;
private RetargetTextEditorAction fGotoPreviousMemberAction;
private RetargetTextEditorAction fToggleInsertModeAction;
public CEditorActionContributor() {
super();
ResourceBundle bundle = CEditorMessages.getResourceBundle();
fShiftRight= new SelectionAction("ShiftRight.", ITextOperationTarget.SHIFT_RIGHT); //$NON-NLS-1$
fShiftRight= new RetargetTextEditorAction(bundle, "ShiftRight.", ITextOperationTarget.SHIFT_RIGHT); //$NON-NLS-1$
fShiftRight.setActionDefinitionId(ITextEditorActionDefinitionIds.SHIFT_RIGHT);
CPluginImages.setImageDescriptors(fShiftRight, CPluginImages.T_LCL, CPluginImages.IMG_MENU_SHIFT_RIGHT);
fShiftLeft= new SelectionAction("ShiftLeft.", ITextOperationTarget.SHIFT_LEFT); //$NON-NLS-1$
fShiftLeft= new RetargetTextEditorAction(bundle, "ShiftLeft.", ITextOperationTarget.SHIFT_LEFT); //$NON-NLS-1$
fShiftLeft.setActionDefinitionId(ITextEditorActionDefinitionIds.SHIFT_LEFT);
CPluginImages.setImageDescriptors(fShiftLeft, CPluginImages.T_LCL, CPluginImages.IMG_MENU_SHIFT_LEFT);
@ -120,7 +72,7 @@ public class CEditorActionContributor extends TextEditorActionContributor {
fAddInclude = new RetargetTextEditorAction(bundle, "AddIncludeOnSelection."); //$NON-NLS-1$
fAddInclude.setActionDefinitionId(ICEditorActionDefinitionIds.ADD_INCLUDE);
fOpenOnSelection = new RetargetTextEditorAction(bundle, "OpenOnSelection."); //$NON-NLS-1$
// fOpenOnSelection = new RetargetTextEditorAction(bundle, "OpenOnSelection."); //$NON-NLS-1$
// actions that are "contributed" to editors, they are considered belonging to the active editor
fTogglePresentation= new TogglePresentationAction();
@ -131,7 +83,16 @@ public class CEditorActionContributor extends TextEditorActionContributor {
fPreviousAnnotation= new GotoAnnotationAction("PreviousAnnotation.", false); //$NON-NLS-1$
fNextAnnotation= new GotoAnnotationAction("NextAnnotation.", true); //$NON-NLS-1$
//fToggleTextHover= new ToggleTextHoverAction();
fGotoMatchingBracket= new RetargetTextEditorAction(bundle, "GotoMatchingBracket."); //$NON-NLS-1$
fGotoMatchingBracket.setActionDefinitionId(ICEditorActionDefinitionIds.GOTO_MATCHING_BRACKET);
fGotoNextMemberAction= new RetargetTextEditorAction(bundle, "GotoNextMember."); //$NON-NLS-1$
fGotoNextMemberAction.setActionDefinitionId(ICEditorActionDefinitionIds.GOTO_NEXT_MEMBER);
fGotoPreviousMemberAction= new RetargetTextEditorAction(bundle, "GotoPreviousMember."); //$NON-NLS-1$
fGotoPreviousMemberAction.setActionDefinitionId(ICEditorActionDefinitionIds.GOTO_PREVIOUS_MEMBER);
fToggleInsertModeAction= new RetargetTextEditorAction(bundle, "ToggleInsertMode.", IAction.AS_CHECK_BOX); //$NON-NLS-1$
fToggleInsertModeAction.setActionDefinitionId(ITextEditorActionDefinitionIds.TOGGLE_INSERT_MODE);
}
@ -142,24 +103,26 @@ public class CEditorActionContributor extends TextEditorActionContributor {
super.contributeToMenu(menu);
/*
* Hook in the code assist
*/
IMenuManager editMenu= menu.findMenuUsingPath(IWorkbenchActionConstants.M_EDIT);
if (editMenu != null) {
editMenu.add(fShiftRight);
editMenu.add(fShiftLeft);
// editMenu.add(new Separator(IContextMenuConstants.GROUP_OPEN));
// editMenu.add(fNextError);
// editMenu.add(fPreviousError);
editMenu.add(new Separator(IContextMenuConstants.GROUP_GENERATE));
editMenu.appendToGroup(IContextMenuConstants.GROUP_GENERATE, fContentAssist);
editMenu.appendToGroup(IContextMenuConstants.GROUP_GENERATE, fAddInclude);
editMenu.appendToGroup(IContextMenuConstants.GROUP_GENERATE, fFormatter);
editMenu.appendToGroup(IContextMenuConstants.GROUP_GENERATE, fOpenOnSelection);
// editMenu.appendToGroup(IContextMenuConstants.GROUP_GENERATE, fOpenOnSelection);
editMenu.appendToGroup(IContextMenuConstants.GROUP_ADDITIONS, fToggleInsertModeAction);
IMenuManager gotoMenu= menu.findMenuUsingPath("navigate/goTo"); //$NON-NLS-1$
if (gotoMenu != null) {
gotoMenu.add(new Separator("additions2")); //$NON-NLS-1$
gotoMenu.appendToGroup("additions2", fGotoPreviousMemberAction); //$NON-NLS-1$
gotoMenu.appendToGroup("additions2", fGotoNextMemberAction); //$NON-NLS-1$
gotoMenu.appendToGroup("additions2", fGotoMatchingBracket); //$NON-NLS-1$
}
}
}
@ -189,19 +152,24 @@ public class CEditorActionContributor extends TextEditorActionContributor {
if (part instanceof ITextEditor)
textEditor= (ITextEditor) part;
fShiftRight.setEditor(textEditor);
fShiftLeft.setEditor(textEditor);
fShiftRight.setAction(getAction(textEditor, ITextEditorActionConstants.SHIFT_RIGHT));
fShiftLeft.setAction(getAction(textEditor, ITextEditorActionConstants.SHIFT_LEFT));
fTogglePresentation.setEditor(textEditor);
fPreviousAnnotation.setEditor(textEditor);
fNextAnnotation.setEditor(textEditor);
//caAction.setEditor(textEditor);
//caAction.update();
fContentAssist.setAction(getAction(textEditor, "ContentAssistProposal")); //$NON-NLS-1$
fAddInclude.setAction(getAction(textEditor, "AddIncludeOnSelection")); //$NON-NLS-1$
fOpenOnSelection.setAction(getAction(textEditor, "OpenOnSelection")); //$NON-NLS-1$
// fOpenOnSelection.setAction(getAction(textEditor, "OpenOnSelection")); //$NON-NLS-1$
fFormatter.setAction(getAction(textEditor, "Format")); //$NON-NLS-1$
fGotoMatchingBracket.setAction(getAction(textEditor, GotoMatchingBracketAction.GOTO_MATCHING_BRACKET));
fGotoNextMemberAction.setAction(getAction(textEditor, GoToNextPreviousMemberAction.NEXT_MEMBER));
fGotoPreviousMemberAction.setAction(getAction(textEditor, GoToNextPreviousMemberAction.PREVIOUS_MEMBER));
fToggleInsertModeAction.setAction(getAction(textEditor, ITextEditorActionConstants.TOGGLE_INSERT_MODE));
if (part instanceof CEditor) {
CEditor cEditor= (CEditor) part;
cEditor.fillActionBars(getActionBars());

View file

@ -21,90 +21,27 @@ AddIncludeOnSelection.error.message4=BadLocationException:
AddIncludeOnSelection.label=Add Include
AddIncludeOnSelection.tooltip=Add Include Statement on Selection
ShowInCView.description=Show the current resource in the C/C++ Projects view
ShowInCView.label=Show in C/C++ Projects
ShowInCView.tooltip=Show current resource in C/C++ Projects view
ClassFileEditor.error.invalid_input_message=Invalid input for Class File Editor
ClassFileMarkerAnnotationModel.error.isAcceptable=ClassFileMarkerAnnotationModel.isAcceptable
ClassFileMarkerAnnotationModel.error.isAffected=ClassFileMarkerAnnotationModel.isAffected
ClassFileMarkerAnnotationModel.error.resourceChanged=ClassFileMarkerAnnotationModel.resourceChanged
CEditor.error.saving.message=Save could not be completed. {0}
CEditor.error.saving.title=Problems During Save As...
CEditorPreferencePage.description= C Editor Preferences
DeleteISourceManipulations.description=Delete the selected element in the editor
DeleteISourceManipulations.error.deleting.message1=Cannot delete element:
DeleteISourceManipulations.error.deleting.title1=Problems while deleting element
DeleteISourceManipulations.label=&Delete
DeleteISourceManipulations.tooltip=Delete the selected element in the editor
EditorDisplay.description=Display
EditorDisplay.label=D&isplay
EditorDisplay.tooltip=Display
EditorDisplay.error.title1=Cannot open Display viewer
JavaOutlinePage.ContextMenu.refactoring.label=&Refactor
JavaOutlinePage.HideFields.description.checked=Shows Fields
JavaOutlinePage.HideFields.description.unchecked=Hides Fields
JavaOutlinePage.HideFields.label=Hide Fields
JavaOutlinePage.HideFields.tooltip.checked=Show Fields
JavaOutlinePage.HideFields.tooltip.unchecked=Hide Fields
JavaOutlinePage.HideNonePublicMembers.description.checked=Shows non-public members
JavaOutlinePage.HideNonePublicMembers.description.unchecked=Hides non-public members
JavaOutlinePage.HideNonePublicMembers.label=Show Public Members Only
JavaOutlinePage.HideNonePublicMembers.tooltip.checked=Show Non-Public Members
JavaOutlinePage.HideNonePublicMembers.tooltip.unchecked=Hide Non-Public Members
JavaOutlinePage.HideStaticMembers.description.checked=Shows static members
JavaOutlinePage.HideStaticMembers.description.unchecked=Hides static members
JavaOutlinePage.HideStaticMembers.label=Hide Static Members
JavaOutlinePage.HideStaticMembers.tooltip.checked=Show Static Members
JavaOutlinePage.HideStaticMembers.tooltip.unchecked=Hide Static Members
JavaOutlinePage.Sort.description.checked=Disable Sorting
JavaOutlinePage.Sort.description.unchecked=Enable Sorting
JavaOutlinePage.Sort.label=Sort
JavaOutlinePage.Sort.tooltip.checked=Do Not Sort
JavaOutlinePage.Sort.tooltip.unchecked=Sort
JavaOutlinePage.error.ChildrenProvider.getChildren.message1=JavaOutlinePage.ChildrenProvider.getChildren
JavaOutlinePage.error.ChildrenProvider.hasChildren.message1=JavaOutlinePage.ChildrenProvider.hasChildren
OpenHierarchy.description=Show the type hierarchy of the selected element
OpenHierarchy.dialog.message=&Select the type to open:
OpenHierarchy.dialog.title=Open Type Hierarchy
OpenHierarchy.label=Open Type &Hierarchy@F4
OpenHierarchy.label=Open Type &Hierarchy
OpenHierarchy.tooltip=Show the type hierarchy of the selected element
OpenDeclarations.description=Open an editor on the selected element's declaration
OpenDeclarations.dialog.message=&Select or enter the element to open:
OpenDeclarations.dialog.title=Open Declaration
OpenDeclarations.label=&Open Declaration@F3
OpenDeclarations.label=&Open Declaration
OpenDeclarations.tooltip=Open an editor on the selected element's declaration
OpenDefinition.description=Open an editor on the selected element's definition
OpenDefinition.label=Open &Definition@Ctrl+F3
OpenDefinition.label=Open &Definition
OpenDefinition.tooltip=Open an editor on the selected element's definition
OpenOutline.description=Shows outline
OpenOutline.dialog.title=Show outline
OpenOutline.label=&Show outline@Ctrl+O
OpenOutline.tooltip=Shows outline
OrganizeImports.description=Evaluate all required imports and replace the current imports
OrganizeImports.error.message2=Syntax errors in compilation unit prevent correct evaluation\nof type references. Fix errors first.
OrganizeImports.error.title1=Organize Imports
OrganizeImports.error.title2=Organize Imports
OrganizeImports.label=Or&ganize Imports@Ctrl+Shift+O
OrganizeImports.ok_label=OK
OrganizeImports.tooltip=Evaluate All Required Imports and Replace the Current Imports
RunToLine.description=Run to line
RunToLine.error.message1=Unable to process run to line request.
RunToLine.error.title1=Run to Line
RunToLine.label=R&un to Line
RunToLine.tooltip=Run to line
OpenOutline.label= Quick Out&line
OpenOutline.tooltip= Shows the Quick Outline of Editor Input
OpenOutline.description= Shows the quick outline for the editor input
TogglePresentation.label=Show Source of Selected Element Only
TogglePresentation.tooltip=Show Source of Selected Element Only
@ -124,19 +61,6 @@ ContentAssistProposal.label=Co&ntent Assist
ContentAssistProposal.tooltip=Content Assist
ContentAssistProposal.description=Content Assist
RunToLine.label=R&un to Line
RunToLine.description=Run to line
RunToLine.error.title1=Run To Line
RunToLine.error.message1=Unable to process run to line request.
Comment.label=&Comment
Comment.tooltip=Comment the Selected Lines
Comment.description=Turn the selected lines into C // style comments
Uncomment.label=Uncommen&t
Uncomment.tooltip=Uncomment the Selected C // comment Lines
Uncomment.description=Uncomment the selected C // comment lines
ToggleComment.label=Comment/Uncomment
ToggleComment.tooltip=Comment/Uncomment For the Selected Lines
ToggleComment.description=Comment/Uncomment for the selected lines
@ -157,11 +81,11 @@ Format.label=F&ormat
Format.tooltip=Format the Selected Text
Format.description=Format the selected text
ShiftRight.label=Sh&ift Right@Ctrl+I
ShiftRight.label=Sh&ift Right
ShiftRight.tooltip=Shift Right
ShiftRight.description=Shift the selected text to the right
ShiftLeft.label=S&hift Left@Ctrl+Shift+I
ShiftLeft.label=S&hift Left
ShiftLeft.tooltip=Shift Left
ShiftLeft.description=Shift the selected text to the left
@ -173,12 +97,6 @@ PreviousAnnotation.label= Pre&vious Annotation
PreviousAnnotation.tooltip= Previous Annotation
PreviousAnnotation.description= Previous Annotation
CompilationUnitDocumentProvider.error.createElementInfo=CompilationUnitDocumentProvider.createElementInfo
CompilationUnitDocumentProvider.out_of_sync.message=Compilation unit buffer and document are out of sync
JavaEditor.Inspect.description=Inspect the result of evaluating the selected text
JavaEditor.Inspect.label=I&nspect
JavaEditor.Inspect.tooltip=Inspect the Result of Evaluating the Selected Text
AddIncludeOnSelectionAction.error.noInput=no Editor Input
DefaultCEditorTextHover.html.name=<b>Name:</b>
DefaultCEditorTextHover.html.prototype=<br><b>Protoype:</b>
@ -187,16 +105,22 @@ CContentOutlinePage.menu.fileSearch=File Search
CContentOutlinePage.error.noInput=no Editor Input
CEditor.menu.fileSearch=File Search
CEditor.menu.search=Search
CEditor.menu.folding=F&olding
EditorUtility.concatModifierStrings= {0} + {1}
OpenOnSelection.label=Open On Selection
GotoNextMember.description=Goes to next member
GotoNextMember.label=Go to &next member
GotoNextMember.tooltip=Goes to next member
GotoPrevMember.description=Goes to previous member
GotoPrevMember.label=Go to &previous member
GotoPrevMember.tooltip=Goes to previous member.
GotoNextMember.label= N&ext Member
GotoNextMember.tooltip=Move the Caret to the Next Member of the Translation Unit
GotoNextMember.description=Move the caret to the next member of the translation unit
GotoPreviousMember.label= Previ&ous Member
GotoPreviousMember.tooltip=Move the Caret to the Previous Member of the Translation Unit
GotoPreviousMember.description=Move the caret to the previous member of the translation unit
GotoMatchingBracket.label= Matching &Bracket
GotoMatchingBracket.tooltip=Go to Matching Bracket
GotoMatchingBracket.description=Go to Matching Bracket
ShowToolTip.label=Show T&ooltip Description
@ -232,3 +156,8 @@ SemanticHighlighting_typeDef= Typedefs
SemanticHighlighting_namespace= Namespaces
SemanticHighlighting_label= Labels
SemanticHighlighting_problem= Problems
ToggleInsertMode.label=Sma&rt Insert Mode
ToggleInsertMode.tooltip=Toggle Smart Insert Mode
ToggleInsertMode.image=
ToggleInsertMode.description= Toggles smart insert mode

View file

@ -30,18 +30,6 @@ public class CdtActionConstants {
*/
public static final String GOTO_TYPE= "org.eclipse.cdt.ui.actions.GoToType"; //$NON-NLS-1$
/**
* Navigate menu: name of standard Goto Package global action
* (value <code>"org.eclipse.cdt.ui.actions.GoToPackage"</code>).
*/
public static final String GOTO_PACKAGE= "org.eclipse.cdt.ui.actions.GoToPackage"; //$NON-NLS-1$
/**
* Navigate menu: name of standard Open global action
* (value <code>"org.eclipse.cdt.ui.actions.Open"</code>).
*/
public static final String OPEN= "org.eclipse.cdt.ui.actions.Open"; //$NON-NLS-1$
/**
* Navigate menu: name of standard Open Super Implementation global action
* (value <code>"org.eclipse.cdt.ui.actions.OpenSuperImplementation"</code>).
@ -61,32 +49,8 @@ public class CdtActionConstants {
*/
public static final String OPEN_CALL_HIERARCHY= "org.eclipse.cdt.ui.actions.OpenCallHierarchy"; //$NON-NLS-1$
/**
* Navigate menu: name of standard Open External Javadoc global action
* (value <code>"org.eclipse.cdt.ui.actions.OpenExternalJavaDoc"</code>).
*/
public static final String OPEN_EXTERNAL_JAVA_DOC= "org.eclipse.cdt.ui.actions.OpenExternalJavaDoc"; //$NON-NLS-1$
/**
* Navigate menu: name of standard Show in Packages View global action
* (value <code>"org.eclipse.cdt.ui.actions.ShowInPackagesView"</code>).
*/
public static final String SHOW_IN_PACKAGE_VIEW= "org.eclipse.cdt.ui.actions.ShowInPackagesView"; //$NON-NLS-1$
/**
* Navigate menu: name of standard Show in Navigator View global action
* (value <code>"org.eclipse.cdt.ui.actions.ShowInNaviagtorView"</code>).
*/
public static final String SHOW_IN_NAVIGATOR_VIEW= "org.eclipse.cdt.ui.actions.ShowInNaviagtorView"; //$NON-NLS-1$
// Edit menu
/**
* Edit menu: name of standard Show Javadoc global action
* (value <code>"org.eclipse.cdt.ui.actions.ShowJavaDoc"</code>).
*/
public static final String SHOW_JAVA_DOC= "org.eclipse.cdt.ui.actions.ShowJavaDoc"; //$NON-NLS-1$
/**
* Edit menu: name of standard Code Assist global action
* (value <code>"org.eclipse.cdt.ui.actions.ContentAssist"</code>).
@ -133,8 +97,6 @@ public class CdtActionConstants {
/**
* Source menu: name of standard Indent global action
* (value <code>"org.eclipse.cdt.ui.actions.Indent"</code>).
*
* @since 3.0
*/
public static final String INDENT= "org.eclipse.cdt.ui.actions.Indent"; //$NON-NLS-1$
@ -157,28 +119,14 @@ public class CdtActionConstants {
public static final String FORMAT= "org.eclipse.cdt.ui.actions.Format"; //$NON-NLS-1$
/**
* Source menu: name of standard Format Element global action
* (value <code>"org.eclipse.cdt.ui.actions.FormatElement"</code>).
* @since 3.0
* Source menu: name of standard Add Include global action
* (value <code>"org.eclipse.cdt.ui.actions.AddInclude"</code>).
*/
public static final String FORMAT_ELEMENT= "org.eclipse.cdt.ui.actions.FormatElement"; //$NON-NLS-1$
public static final String ADD_INCLUDE= "org.eclipse.cdt.ui.actions.AddInclude"; //$NON-NLS-1$
/**
* Source menu: name of standard Add Import global action
* (value <code>"org.eclipse.cdt.ui.actions.AddImport"</code>).
*/
public static final String ADD_IMPORT= "org.eclipse.cdt.ui.actions.AddImport"; //$NON-NLS-1$
/**
* Source menu: name of standard Organize Imports global action
* (value <code>"org.eclipse.cdt.ui.actions.OrganizeImports"</code>).
*/
public static final String ORGANIZE_IMPORTS= "org.eclipse.cdt.ui.actions.OrganizeImports"; //$NON-NLS-1$
/**
* Source menu: name of standard Sort Members global action (value
* <code>"org.eclipse.cdt.ui.actions.SortMembers"</code>).
* @since 2.1
*/
public static final String SORT_MEMBERS= "org.eclipse.cdt.ui.actions.SortMembers"; //$NON-NLS-1$
@ -203,7 +151,6 @@ public class CdtActionConstants {
/**
* Source menu: name of standard delegate methods global action (value
* <code>"org.eclipse.cdt.ui.actions.GenerateDelegateMethods"</code>).
* @since 2.1
*/
public static final String GENERATE_DELEGATE_METHODS= "org.eclipse.cdt.ui.actions.GenerateDelegateMethods"; //$NON-NLS-1$
@ -220,10 +167,10 @@ public class CdtActionConstants {
public static final String GENERATE_CONSTRUCTOR_USING_FIELDS= "org.eclipse.cdt.ui.actions.GenerateConstructorUsingFields"; //$NON-NLS-1$
/**
* Source menu: name of standard Add Javadoc Comment global action
* (value <code>"org.eclipse.cdt.ui.actions.AddJavaDocComment"</code>).
* Source menu: name of standard Add Cppdoc Comment global action
* (value <code>"org.eclipse.cdt.ui.actions.AddCppDocComment"</code>).
*/
public static final String ADD_JAVA_DOC_COMMENT= "org.eclipse.cdt.ui.actions.AddJavaDocComment"; //$NON-NLS-1$
public static final String ADD_CPP_DOC_COMMENT= "org.eclipse.cdt.ui.actions.AddCppDocComment"; //$NON-NLS-1$
/**
* Source menu: name of standard Find Strings to Externalize global action
@ -237,24 +184,6 @@ public class CdtActionConstants {
*/
public static final String EXTERNALIZE_STRINGS= "org.eclipse.cdt.ui.actions.ExternalizeStrings"; //$NON-NLS-1$
/**
* Source menu: name of standard Convert Line Delimiters To Windows global action
* (value <code>"org.eclipse.cdt.ui.actions.ConvertLineDelimitersToWindows"</code>).
*/
public static final String CONVERT_LINE_DELIMITERS_TO_WINDOWS= "org.eclipse.cdt.ui.actions.ConvertLineDelimitersToWindows"; //$NON-NLS-1$
/**
* Source menu: name of standard Convert Line Delimiters To UNIX global action
* (value <code>"org.eclipse.cdt.ui.actions.ConvertLineDelimitersToUNIX"</code>).
*/
public static final String CONVERT_LINE_DELIMITERS_TO_UNIX= "org.eclipse.cdt.ui.actions.ConvertLineDelimitersToUNIX"; //$NON-NLS-1$
/**
* Source menu: name of standardConvert Line Delimiters To Mac global action
* (value <code>"org.eclipse.cdt.ui.actions.ConvertLineDelimitersToMac"</code>).
*/
public static final String CONVERT_LINE_DELIMITERS_TO_MAC= "org.eclipse.cdt.ui.actions.ConvertLineDelimitersToMac"; //$NON-NLS-1$
// Refactor menu
/**
@ -278,8 +207,6 @@ public class CdtActionConstants {
/**
* Refactor menu: name of standard Push Down global action
* (value <code>"org.eclipse.cdt.ui.actions.PushDown"</code>).
*
* @since 2.1
*/
public static final String PUSH_DOWN= "org.eclipse.cdt.ui.actions.PushDown"; //$NON-NLS-1$
@ -295,13 +222,6 @@ public class CdtActionConstants {
*/
public static final String RENAME= "org.eclipse.cdt.ui.actions.Rename"; //$NON-NLS-1$
/**
* Refactor menu: name of standard Inline Temp global action
* (value <code>"org.eclipse.cdt.ui.actions.InlineTemp"</code>).
* @deprecated Use INLINE
*/
public static final String INLINE_TEMP= "org.eclipse.cdt.ui.actions.InlineTemp"; //$NON-NLS-1$
/**
* Refactor menu: name of standard Extract Temp global action
* (value <code>"org.eclipse.cdt.ui.actions.ExtractTemp"</code>).
@ -311,24 +231,18 @@ public class CdtActionConstants {
/**
* Refactor menu: name of standard Extract Constant global action
* (value <code>"org.eclipse.cdt.ui.actions.ExtractConstant"</code>).
*
* @since 2.1
*/
public static final String EXTRACT_CONSTANT= "org.eclipse.cdt.ui.actions.ExtractConstant"; //$NON-NLS-1$
/**
* Refactor menu: name of standard Introduce Parameter global action
* (value <code>"org.eclipse.cdt.ui.actions.IntroduceParameter"</code>).
*
* @since 3.0
*/
public static final String INTRODUCE_PARAMETER= "org.eclipse.cdt.ui.actions.IntroduceParameter"; //$NON-NLS-1$
/**
* Refactor menu: name of standard Introduce Factory global action
* (value <code>"org.eclipse.cdt.ui.actions.IntroduceFactory"</code>).
*
* @since 3.0
*/
public static final String INTRODUCE_FACTORY= "org.eclipse.cdt.ui.actions.IntroduceFactory"; //$NON-NLS-1$
@ -341,56 +255,42 @@ public class CdtActionConstants {
/**
* Refactor menu: name of standard Inline global action
* (value <code>"org.eclipse.cdt.ui.actions.Inline"</code>).
*
* @since 2.1
*/
public static final String INLINE= "org.eclipse.cdt.ui.actions.Inline"; //$NON-NLS-1$
/**
* Refactor menu: name of standard Extract Interface global action
* (value <code>"org.eclipse.cdt.ui.actions.ExtractInterface"</code>).
*
* @since 2.1
*/
public static final String EXTRACT_INTERFACE= "org.eclipse.cdt.ui.actions.ExtractInterface"; //$NON-NLS-1$
/**
* Refactor menu: name of standard Generalize Type global action
* (value <code>"org.eclipse.cdt.ui.actions.ChangeType"</code>).
*
* @since 3.0
*/
public static final String CHANGE_TYPE= "org.eclipse.cdt.ui.actions.ChangeType"; //$NON-NLS-1$
/**
* Refactor menu: name of standard global action to convert a nested type to a top level type
* (value <code>"org.eclipse.cdt.ui.actions.MoveInnerToTop"</code>).
*
* @since 2.1
*/
public static final String CONVERT_NESTED_TO_TOP= "org.eclipse.cdt.ui.actions.ConvertNestedToTop"; //$NON-NLS-1$
/**
* Refactor menu: name of standard Use Supertype global action
* (value <code>"org.eclipse.cdt.ui.actions.UseSupertype"</code>).
*
* @since 2.1
*/
public static final String USE_SUPERTYPE= "org.eclipse.cdt.ui.actions.UseSupertype"; //$NON-NLS-1$
/**
* Refactor menu: name of standard global action to convert a local
* variable to a field (value <code>"org.eclipse.cdt.ui.actions.ConvertLocalToField"</code>).
*
* @since 2.1
*/
public static final String CONVERT_LOCAL_TO_FIELD= "org.eclipse.cdt.ui.actions.ConvertLocalToField"; //$NON-NLS-1$
/**
* Refactor menu: name of standard Covert Anonymous to Nested global action
* (value <code>"org.eclipse.cdt.ui.actions.ConvertAnonymousToNested"</code>).
*
* @since 2.1
*/
public static final String CONVERT_ANONYMOUS_TO_NESTED= "org.eclipse.cdt.ui.actions.ConvertAnonymousToNested"; //$NON-NLS-1$
@ -515,16 +415,12 @@ public class CdtActionConstants {
/**
* Search menu: name of standard Occurrences in File global action (value
* <code>"org.eclipse.cdt.ui.actions.OccurrencesInFile"</code>).
*
* @since 2.1
*/
public static final String FIND_OCCURRENCES_IN_FILE= "org.eclipse.cdt.ui.actions.OccurrencesInFile"; //$NON-NLS-1$
/**
* Search menu: name of standard Find exception occurrences global action (value
* <code>"org.eclipse.cdt.ui.actions.ExceptionOccurrences"</code>).
*
* @since 3.0
*/
public static final String FIND_EXCEPTION_OCCURRENCES= "org.eclipse.cdt.ui.actions.ExceptionOccurrences"; //$NON-NLS-1$
}

View file

@ -0,0 +1,497 @@
/*******************************************************************************
* Copyright (c) 2000, 2006 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 Corporation - initial API and implementation
* Anton Leherbauer (Wind River Systems) - Adapted for CDT
*******************************************************************************/
package org.eclipse.cdt.ui.actions;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.MenuManager;
import org.eclipse.jface.action.Separator;
import org.eclipse.jface.util.Assert;
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.ui.IActionBars;
import org.eclipse.ui.IViewPart;
import org.eclipse.ui.IWorkbenchSite;
import org.eclipse.ui.actions.ActionGroup;
import org.eclipse.ui.actions.AddBookmarkAction;
import org.eclipse.ui.actions.AddTaskAction;
import org.eclipse.ui.handlers.IHandlerService;
import org.eclipse.ui.ide.IDEActionFactory;
import org.eclipse.ui.part.Page;
import org.eclipse.ui.texteditor.ITextEditorActionConstants;
import org.eclipse.ui.texteditor.IUpdate;
import org.eclipse.ui.texteditor.IWorkbenchActionDefinitionIds;
import org.eclipse.cdt.internal.ui.IContextMenuConstants;
import org.eclipse.cdt.internal.ui.actions.ActionMessages;
import org.eclipse.cdt.internal.ui.editor.AddIncludeOnSelectionAction;
import org.eclipse.cdt.internal.ui.editor.CEditor;
import org.eclipse.cdt.internal.ui.editor.ICEditorActionDefinitionIds;
/**
* Action group that adds the source and generate actions to a part's context
* menu and installs handlers for the corresponding global menu actions.
*
* <p>
* This class may be instantiated; it is not intended to be subclassed.
* </p>
*
* @since 4.0
*/
public class GenerateActionGroup extends ActionGroup {
/**
* Pop-up menu: id of the source sub menu (value <code>org.eclipse.cdt.ui.source.menu</code>).
*/
public static final String MENU_ID= "org.eclipse.cdt.ui.source.menu"; //$NON-NLS-1$
/**
* Pop-up menu: id of the organize group of the source sub menu (value
* <code>organizeGroup</code>).
*/
public static final String GROUP_ORGANIZE= "organizeGroup"; //$NON-NLS-1$
/**
* Pop-up menu: id of the generate group of the source sub menu (value
* <code>generateGroup</code>).
*/
public static final String GROUP_GENERATE= "generateGroup"; //$NON-NLS-1$
/**
* Pop-up menu: id of the code group of the source sub menu (value
* <code>codeGroup</code>).
*/
public static final String GROUP_CODE= "codeGroup"; //$NON-NLS-1$
/**
* Pop-up menu: id of the externalize group of the source sub menu (value
* <code>externalizeGroup</code>).
*/
private static final String GROUP_EXTERNALIZE= "externalizeGroup"; //$NON-NLS-1$
/**
* Pop-up menu: id of the comment group of the source sub menu (value
* <code>commentGroup</code>).
*/
private static final String GROUP_COMMENT= "commentGroup"; //$NON-NLS-1$
/**
* Pop-up menu: id of the edit group of the source sub menu (value
* <code>editGroup</code>).
*/
private static final String GROUP_EDIT= "editGroup"; //$NON-NLS-1$
private CEditor fEditor;
private IWorkbenchSite fSite;
private String fGroupName= IContextMenuConstants.GROUP_REORGANIZE;
private List fRegisteredSelectionListeners;
private AddIncludeOnSelectionAction fAddInclude;
// private OverrideMethodsAction fOverrideMethods;
// private GenerateHashCodeEqualsAction fHashCodeEquals;
// private AddGetterSetterAction fAddGetterSetter;
// private AddDelegateMethodsAction fAddDelegateMethods;
// private AddUnimplementedConstructorsAction fAddUnimplementedConstructors;
// private GenerateNewConstructorUsingFieldsAction fGenerateConstructorUsingFields;
// private AddJavaDocStubAction fAddCppDocStub;
private AddBookmarkAction fAddBookmark;
private AddTaskAction fAddTaskAction;
// private ExternalizeStringsAction fExternalizeStrings;
// private CleanUpAction fCleanUp;
//
// private OrganizeIncludesAction fOrganizeIncludes;
// private SortMembersAction fSortMembers;
// private FormatAllAction fFormatAll;
// private CopyQualifiedNameAction fCopyQualifiedNameAction;
//
// private static final String QUICK_MENU_ID= "org.eclipse.cdt.ui.edit.text.c.source.quickMenu"; //$NON-NLS-1$
//
// private class RefactorQuickAccessAction extends CDTQuickMenuAction {
// public RefactorQuickAccessAction(CEditor editor) {
// super(editor, QUICK_MENU_ID);
// }
// protected void fillMenu(IMenuManager menu) {
// fillQuickMenu(menu);
// }
// }
//
// private RefactorQuickAccessAction fQuickAccessAction;
// private IKeyBindingService fKeyBindingService;
/**
* Note: This constructor is for internal use only. Clients should not call this constructor.
* @param editor the C editor
* @param groupName the group name to add the action to
*/
public GenerateActionGroup(CEditor editor, String groupName) {
fSite= editor.getSite();
fEditor= editor;
fGroupName= groupName;
fAddInclude= new AddIncludeOnSelectionAction(editor);
fAddInclude.setActionDefinitionId(ICEditorActionDefinitionIds.ADD_INCLUDE);
editor.setAction("AddIncludeOnSelection", fAddInclude); //$NON-NLS-1$
// fOrganizeIncludes= new OrganizeIncludesAction(editor);
// fOrganizeIncludes.setActionDefinitionId(ICEditorActionDefinitionIds.ORGANIZE_INCLUDES);
// editor.setAction("OrganizeIncludes", fOrganizeIncludes); //$NON-NLS-1$
//
// fSortMembers= new SortMembersAction(editor);
// fSortMembers.setActionDefinitionId(ICEditorActionDefinitionIds.SORT_MEMBERS);
// editor.setAction("SortMembers", fSortMembers); //$NON-NLS-1$
//
// IAction pastAction= editor.getAction(ITextEditorActionConstants.PASTE);//IWorkbenchActionDefinitionIds.PASTE);
// fCopyQualifiedNameAction= new CopyQualifiedNameAction(editor, null, pastAction);
// fCopyQualifiedNameAction.setActionDefinitionId(CopyQualifiedNameAction.JAVA_EDITOR_ACTION_DEFINITIONS_ID);
// editor.setAction("CopyQualifiedName", fCopyQualifiedNameAction); //$NON-NLS-1$
//
// fOverrideMethods= new OverrideMethodsAction(editor);
// fOverrideMethods.setActionDefinitionId(ICEditorActionDefinitionIds.OVERRIDE_METHODS);
// editor.setAction("OverrideMethods", fOverrideMethods); //$NON-NLS-1$
//
// fAddGetterSetter= new AddGetterSetterAction(editor);
// fAddGetterSetter.setActionDefinitionId(ICEditorActionDefinitionIds.CREATE_GETTER_SETTER);
// editor.setAction("AddGetterSetter", fAddGetterSetter); //$NON-NLS-1$
//
// fAddDelegateMethods= new AddDelegateMethodsAction(editor);
// fAddDelegateMethods.setActionDefinitionId(ICEditorActionDefinitionIds.CREATE_DELEGATE_METHODS);
// editor.setAction("AddDelegateMethods", fAddDelegateMethods); //$NON-NLS-1$
//
// fAddUnimplementedConstructors= new AddUnimplementedConstructorsAction(editor);
// fAddUnimplementedConstructors.setActionDefinitionId(ICEditorActionDefinitionIds.ADD_UNIMPLEMENTED_CONTRUCTORS);
// editor.setAction("AddUnimplementedConstructors", fAddUnimplementedConstructors); //$NON-NLS-1$
//
// fGenerateConstructorUsingFields= new GenerateNewConstructorUsingFieldsAction(editor);
// fGenerateConstructorUsingFields.setActionDefinitionId(ICEditorActionDefinitionIds.GENERATE_CONSTRUCTOR_USING_FIELDS);
// editor.setAction("GenerateConstructorUsingFields", fGenerateConstructorUsingFields); //$NON-NLS-1$
//
// fHashCodeEquals= new GenerateHashCodeEqualsAction(editor);
// fHashCodeEquals.setActionDefinitionId(ICEditorActionDefinitionIds.GENERATE_HASHCODE_EQUALS);
// editor.setAction("GenerateHashCodeEquals", fHashCodeEquals); //$NON-NLS-1$
//
// fAddCppDocStub= new AddJavaDocStubAction(editor);
// fAddCppDocStub.setActionDefinitionId(ICEditorActionDefinitionIds.ADD_JAVADOC_COMMENT);
// editor.setAction("AddJavadocComment", fAddCppDocStub); //$NON-NLS-1$
//
// fCleanUp= new CleanUpAction(editor);
// fCleanUp.setActionDefinitionId(ICEditorActionDefinitionIds.CLEAN_UP);
// editor.setAction("CleanUp", fCleanUp); //$NON-NLS-1$
//
// fExternalizeStrings= new ExternalizeStringsAction(editor);
// fExternalizeStrings.setActionDefinitionId(ICEditorActionDefinitionIds.EXTERNALIZE_STRINGS);
// editor.setAction("ExternalizeStrings", fExternalizeStrings); //$NON-NLS-1$
//
// fQuickAccessAction= new RefactorQuickAccessAction(editor);
// fKeyBindingService= editor.getEditorSite().getKeyBindingService();
// fKeyBindingService.registerAction(fQuickAccessAction);
}
/**
* Creates a new <code>GenerateActionGroup</code>. The group
* 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 GenerateActionGroup(Page page) {
this(page.getSite(), null);
}
/**
* Creates a new <code>GenerateActionGroup</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 GenerateActionGroup(IViewPart part) {
this(part.getSite(), (IHandlerService)part.getSite().getService(IHandlerService.class));
}
private GenerateActionGroup(IWorkbenchSite site, IHandlerService handlerService) {
fSite= site;
ISelectionProvider provider= fSite.getSelectionProvider();
ISelection selection= provider.getSelection();
// fOverrideMethods= new OverrideMethodsAction(site);
// fOverrideMethods.setActionDefinitionId(ICEditorActionDefinitionIds.OVERRIDE_METHODS);
//
// fAddGetterSetter= new AddGetterSetterAction(site);
// fAddGetterSetter.setActionDefinitionId(ICEditorActionDefinitionIds.CREATE_GETTER_SETTER);
//
// fAddDelegateMethods= new AddDelegateMethodsAction(site);
// fAddDelegateMethods.setActionDefinitionId(ICEditorActionDefinitionIds.CREATE_DELEGATE_METHODS);
//
// fAddUnimplementedConstructors= new AddUnimplementedConstructorsAction(site);
// fAddUnimplementedConstructors.setActionDefinitionId(ICEditorActionDefinitionIds.ADD_UNIMPLEMENTED_CONTRUCTORS);
//
// fGenerateConstructorUsingFields= new GenerateNewConstructorUsingFieldsAction(site);
// fGenerateConstructorUsingFields.setActionDefinitionId(ICEditorActionDefinitionIds.GENERATE_CONSTRUCTOR_USING_FIELDS);
//
// fHashCodeEquals= new GenerateHashCodeEqualsAction(site);
// fHashCodeEquals.setActionDefinitionId(ICEditorActionDefinitionIds.GENERATE_HASHCODE_EQUALS);
//
// fAddCppDocStub= new AddJavaDocStubAction(site);
// fAddCppDocStub.setActionDefinitionId(ICEditorActionDefinitionIds.ADD_JAVADOC_COMMENT);
fAddBookmark= new AddBookmarkAction(site.getShell());
fAddBookmark.setActionDefinitionId(IWorkbenchActionDefinitionIds.ADD_BOOKMARK);
fAddTaskAction= new AddTaskAction(site.getShell());
fAddTaskAction.setActionDefinitionId(IWorkbenchActionDefinitionIds.ADD_TASK);
// fExternalizeStrings= new ExternalizeStringsAction(site);
// fExternalizeStrings.setActionDefinitionId(ICEditorActionDefinitionIds.EXTERNALIZE_STRINGS);
//
// fOrganizeIncludes= new OrganizeIncludesAction(site);
// fOrganizeIncludes.setActionDefinitionId(ICEditorActionDefinitionIds.ORGANIZE_INCLUDES);
//
// fSortMembers= new SortMembersAction(site);
// fSortMembers.setActionDefinitionId(ICEditorActionDefinitionIds.SORT_MEMBERS);
//
// fFormatAll= new FormatAllAction(site);
// fFormatAll.setActionDefinitionId(ICEditorActionDefinitionIds.FORMAT);
//
// fCleanUp= new CleanUpAction(site);
// fCleanUp.setActionDefinitionId(ICEditorActionDefinitionIds.CLEAN_UP);
// fOverrideMethods.update(selection);
// fAddGetterSetter.update(selection);
// fAddDelegateMethods.update(selection);
// fAddUnimplementedConstructors.update(selection);
// fGenerateConstructorUsingFields.update(selection);
// fHashCodeEquals.update(selection);
// fAddCppDocStub.update(selection);
// fExternalizeStrings.update(selection);
// fFindNLSProblems.update(selection);
// fCleanUp.update(selection);
// fOrganizeIncludes.update(selection);
// fSortMembers.update(selection);
// fFormatAll.update(selection);
if (selection instanceof IStructuredSelection) {
IStructuredSelection ss= (IStructuredSelection)selection;
fAddBookmark.selectionChanged(ss);
fAddTaskAction.selectionChanged(ss);
} else {
fAddBookmark.setEnabled(false);
fAddTaskAction.setEnabled(false);
}
// registerSelectionListener(provider, fOverrideMethods);
// registerSelectionListener(provider, fAddGetterSetter);
// registerSelectionListener(provider, fAddDelegateMethods);
// registerSelectionListener(provider, fAddUnimplementedConstructors);
// registerSelectionListener(provider, fGenerateConstructorUsingFields);
// registerSelectionListener(provider, fHashCodeEquals);
// registerSelectionListener(provider, fAddCppDocStub);
registerSelectionListener(provider, fAddBookmark);
// registerSelectionListener(provider, fExternalizeStrings);
// registerSelectionListener(provider, fFindNLSProblems);
// registerSelectionListener(provider, fOrganizeIncludes);
// registerSelectionListener(provider, fFormatAll);
// registerSelectionListener(provider, fSortMembers);
registerSelectionListener(provider, fAddTaskAction);
// registerSelectionListener(provider, fCleanUp);
// fKeyBindingService= keyBindingService;
// if (fKeyBindingService != null) {
// fQuickAccessAction= new RefactorQuickAccessAction(null);
// fKeyBindingService.registerAction(fQuickAccessAction);
// }
}
private void registerSelectionListener(ISelectionProvider provider, ISelectionChangedListener listener) {
if (fRegisteredSelectionListeners == null)
fRegisteredSelectionListeners= new ArrayList(10);
provider.addSelectionChangedListener(listener);
fRegisteredSelectionListeners.add(listener);
}
/*
* The state of the editor owning this action group has changed.
* This method does nothing if the group's owner isn't an
* editor.
*/
/**
* Note: This method is for internal use only. Clients should not call this method.
*/
public void editorStateChanged() {
Assert.isTrue(isEditorOwner());
}
/*
* Method declared in ActionGroup
*/
public void fillActionBars(IActionBars actionBar) {
super.fillActionBars(actionBar);
setGlobalActionHandlers(actionBar);
}
/*
* Method declared in ActionGroup
*/
public void fillContextMenu(IMenuManager menu) {
super.fillContextMenu(menu);
String menuText= ActionMessages.getString("SourceMenu_label"); //$NON-NLS-1$
// if (fQuickAccessAction != null) {
// menuText= fQuickAccessAction.addShortcut(menuText);
// }
IMenuManager subMenu= new MenuManager(menuText, MENU_ID);
int added= 0;
if (isEditorOwner()) {
added= fillEditorSubMenu(subMenu);
} else {
added= fillViewSubMenu(subMenu);
}
if (added > 0)
menu.appendToGroup(fGroupName, subMenu);
}
// private void fillQuickMenu(IMenuManager menu) {
// if (isEditorOwner()) {
// fillEditorSubMenu(menu);
// } else {
// fillViewSubMenu(menu);
// }
// }
private int fillEditorSubMenu(IMenuManager source) {
int added= 0;
source.add(new Separator(GROUP_COMMENT));
added+= addEditorAction(source, "ToggleComment"); //$NON-NLS-1$
added+= addEditorAction(source, "AddBlockComment"); //$NON-NLS-1$
added+= addEditorAction(source, "RemoveBlockComment"); //$NON-NLS-1$
// added+= addAction(source, fAddCppDocStub);
source.add(new Separator(GROUP_EDIT));
added+= addEditorAction(source, ITextEditorActionConstants.SHIFT_RIGHT);
added+= addEditorAction(source, ITextEditorActionConstants.SHIFT_LEFT);
added+= addEditorAction(source, "Indent"); //$NON-NLS-1$
added+= addEditorAction(source, "Format"); //$NON-NLS-1$
source.add(new Separator(GROUP_ORGANIZE));
added+= addAction(source, fAddInclude);
// added+= addAction(source, fOrganizeIncludes);
// added+= addAction(source, fSortMembers);
// added+= addAction(source, fCleanUp);
source.add(new Separator(GROUP_GENERATE));
added+= addEditorAction(source, "ContentAssistProposal"); //$NON-NLS-1$
// added+= addAction(source, fOverrideMethods);
// added+= addAction(source, fAddGetterSetter);
// added+= addAction(source, fAddDelegateMethods);
// added+= addAction(source, fHashCodeEquals);
// added+= addAction(source, fGenerateConstructorUsingFields);
// added+= addAction(source, fAddUnimplementedConstructors);
source.add(new Separator(GROUP_CODE));
source.add(new Separator(GROUP_EXTERNALIZE));
// added+= addAction(source, fExternalizeStrings);
return added;
}
private int fillViewSubMenu(IMenuManager source) {
int added= 0;
source.add(new Separator(GROUP_COMMENT));
// added+= addAction(source, fAddCppDocStub);
source.add(new Separator(GROUP_EDIT));
// added+= addAction(source, fFormatAll);
source.add(new Separator(GROUP_ORGANIZE));
added+= addAction(source, fAddInclude);
// added+= addAction(source, fOrganizeIncludes);
// added+= addAction(source, fSortMembers);
// added+= addAction(source, fCleanUp);
source.add(new Separator(GROUP_GENERATE));
// added+= addAction(source, fOverrideMethods);
// added+= addAction(source, fAddGetterSetter);
// added+= addAction(source, fAddDelegateMethods);
// added+= addAction(source, fHashCodeEquals);
// added+= addAction(source, fGenerateConstructorUsingFields);
// added+= addAction(source, fAddUnimplementedConstructors);
source.add(new Separator(GROUP_CODE));
source.add(new Separator(GROUP_EXTERNALIZE));
// added+= addAction(source, fExternalizeStrings);
// added+= addAction(source, fFindNLSProblems);
return added;
}
/*
* Method declared in ActionGroup
*/
public void dispose() {
if (fRegisteredSelectionListeners != null) {
ISelectionProvider provider= fSite.getSelectionProvider();
for (Iterator iter= fRegisteredSelectionListeners.iterator(); iter.hasNext();) {
ISelectionChangedListener listener= (ISelectionChangedListener) iter.next();
provider.removeSelectionChangedListener(listener);
}
}
// if (fQuickAccessAction != null && fKeyBindingService != null) {
// fKeyBindingService.unregisterAction(fQuickAccessAction);
// }
fEditor= null;
super.dispose();
}
private void setGlobalActionHandlers(IActionBars actionBar) {
actionBar.setGlobalActionHandler(CdtActionConstants.ADD_INCLUDE, fAddInclude);
// actionBar.setGlobalActionHandler(CdtActionConstants.OVERRIDE_METHODS, fOverrideMethods);
// actionBar.setGlobalActionHandler(CdtActionConstants.GENERATE_GETTER_SETTER, fAddGetterSetter);
// actionBar.setGlobalActionHandler(CdtActionConstants.GENERATE_DELEGATE_METHODS, fAddDelegateMethods);
// actionBar.setGlobalActionHandler(CdtActionConstants.ADD_CONSTRUCTOR_FROM_SUPERCLASS, fAddUnimplementedConstructors);
// actionBar.setGlobalActionHandler(CdtActionConstants.GENERATE_CONSTRUCTOR_USING_FIELDS, fGenerateConstructorUsingFields);
// actionBar.setGlobalActionHandler(CdtActionConstants.GENERATE_HASHCODE_EQUALS, fHashCodeEquals);
// actionBar.setGlobalActionHandler(CdtActionConstants.ADD_CPP_DOC_COMMENT, fAddCppDocStub);
// actionBar.setGlobalActionHandler(CdtActionConstants.EXTERNALIZE_STRINGS, fExternalizeStrings);
// actionBar.setGlobalActionHandler(CdtActionConstants.CLEAN_UP, fCleanUp);
// actionBar.setGlobalActionHandler(CdtActionConstants.ORGANIZE_INCLUDES, fOrganizeIncludes);
// actionBar.setGlobalActionHandler(CdtActionConstants.SORT_MEMBERS, fSortMembers);
if (!isEditorOwner()) {
// editor provides its own implementation of these actions.
actionBar.setGlobalActionHandler(IDEActionFactory.BOOKMARK.getId(), fAddBookmark);
actionBar.setGlobalActionHandler(IDEActionFactory.ADD_TASK.getId(), fAddTaskAction);
// actionBar.setGlobalActionHandler(CdtActionConstants.FORMAT, fFormatAll);
} else {
// actionBar.setGlobalActionHandler(CopyQualifiedNameAction.ACTION_HANDLER_ID, fCopyQualifiedNameAction);
}
}
private int addAction(IMenuManager menu, IAction action) {
if (action != null && action.isEnabled()) {
menu.add(action);
return 1;
}
return 0;
}
private int addEditorAction(IMenuManager menu, String actionID) {
if (fEditor == null)
return 0;
IAction action= fEditor.getAction(actionID);
if (action == null)
return 0;
if (action instanceof IUpdate)
((IUpdate)action).update();
if (action.isEnabled()) {
menu.add(action);
return 1;
}
return 0;
}
private boolean isEditorOwner() {
return fEditor != null;
}
}