From 83f96aa7ee0fda3653bb38024449554368dd974b Mon Sep 17 00:00:00 2001 From: John Camelon Date: Mon, 5 May 2003 14:15:16 +0000 Subject: [PATCH] Patch for Hoda Amer. This patch enables Outline view filters to show/hide -static members, non-public members, and fields (same as in JDT). Please note that the patch creates three new packages and 5 new classes. It also has 9 new icon files (in three different directories). The modified files + the new files are all zipped into the attached file. --- .../icons/full/clcl16/fields_co.gif | Bin 0 -> 160 bytes .../icons/full/clcl16/public_co.gif | Bin 0 -> 97 bytes .../icons/full/clcl16/static_co.gif | Bin 0 -> 111 bytes .../icons/full/dlcl16/fields_co.gif | Bin 0 -> 95 bytes .../icons/full/dlcl16/public_co.gif | Bin 0 -> 69 bytes .../icons/full/dlcl16/static_co.gif | Bin 0 -> 89 bytes .../icons/full/elcl16/fields_co.gif | Bin 0 -> 127 bytes .../icons/full/elcl16/public_co.gif | Bin 0 -> 97 bytes .../icons/full/elcl16/static_co.gif | Bin 0 -> 149 bytes .../cdt/internal/ui/CPluginImages.java | 4 + .../cdt/internal/ui/ICHelpContextIds.java | 4 + .../internal/ui/actions/ActionMessages.java | 71 +++++ .../ui/actions/ActionMessages.properties | 274 ++++++++++++++++++ .../ui/editor/CContentOutlinePage.java | 23 +- .../internal/ui/viewsupport/MemberFilter.java | 95 ++++++ .../ui/viewsupport/MemberFilterAction.java | 50 ++++ .../ui/actions/MemberFilterActionGroup.java | 267 +++++++++++++++++ 17 files changed, 787 insertions(+), 1 deletion(-) create mode 100644 core/org.eclipse.cdt.ui/icons/full/clcl16/fields_co.gif create mode 100644 core/org.eclipse.cdt.ui/icons/full/clcl16/public_co.gif create mode 100644 core/org.eclipse.cdt.ui/icons/full/clcl16/static_co.gif create mode 100644 core/org.eclipse.cdt.ui/icons/full/dlcl16/fields_co.gif create mode 100644 core/org.eclipse.cdt.ui/icons/full/dlcl16/public_co.gif create mode 100644 core/org.eclipse.cdt.ui/icons/full/dlcl16/static_co.gif create mode 100644 core/org.eclipse.cdt.ui/icons/full/elcl16/fields_co.gif create mode 100644 core/org.eclipse.cdt.ui/icons/full/elcl16/public_co.gif create mode 100644 core/org.eclipse.cdt.ui/icons/full/elcl16/static_co.gif create mode 100644 core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/ActionMessages.java create mode 100644 core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/ActionMessages.properties create mode 100644 core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/MemberFilter.java create mode 100644 core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/MemberFilterAction.java create mode 100644 core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/MemberFilterActionGroup.java diff --git a/core/org.eclipse.cdt.ui/icons/full/clcl16/fields_co.gif b/core/org.eclipse.cdt.ui/icons/full/clcl16/fields_co.gif new file mode 100644 index 0000000000000000000000000000000000000000..e14ce565b4ff19b29ea1eae12b19780f00a6d6c7 GIT binary patch literal 160 zcmZ?wbhEHb6krfw*vtR~4fgi+_VN4e>-R4^^+Z^fq{!b2P6hEgMr02;H2m3y%ymPS3I3&$cUTIN$-eY50}_r$e}WoXHE~7r|KLA yS*-`wqD@XpPt7Z4`kmrjp;`S+qy0X&hr|_)4gs#~J8PI;2)b|9+^i|cU=0BHBsIMN literal 0 HcmV?d00001 diff --git a/core/org.eclipse.cdt.ui/icons/full/clcl16/public_co.gif b/core/org.eclipse.cdt.ui/icons/full/clcl16/public_co.gif new file mode 100644 index 0000000000000000000000000000000000000000..18103b11fc7ea74276adbc2cad5252b670854661 GIT binary patch literal 97 zcmZ?wbhEHb6krfwSj50!UvF<8Z(lz@e*XUW|Ns9pz<}aU7DfgJ76u)V07xwZvzo`Q sJO2z$oorwg?y+^caz~+p|3vSEoeNVnHu!(omm+eXx2OHBGd<-|G{UJPkf@rc%W;r8rq=iYh^1_o;Y+aw-f literal 0 HcmV?d00001 diff --git a/core/org.eclipse.cdt.ui/icons/full/elcl16/fields_co.gif b/core/org.eclipse.cdt.ui/icons/full/elcl16/fields_co.gif new file mode 100644 index 0000000000000000000000000000000000000000..ac9f965d0c4b921eed5ab7de0ee5d076f3b618e0 GIT binary patch literal 127 zcmZ?wbhEHb6krfwSj52a|NsB}`}fbEKfj@&AwE7H$YlTn#h)yU3=FIcIv^fMEd#Sl z#I8I449tYQ1eCj9tq^;lV8JNLpwUps?Y1)EMh6q)@gqFbG}h%aboDnfUejxFR93KR Y)DU5B`<9}c-I8)rOY_ODJ{AUR0ITUM2><{9 literal 0 HcmV?d00001 diff --git a/core/org.eclipse.cdt.ui/icons/full/elcl16/public_co.gif b/core/org.eclipse.cdt.ui/icons/full/elcl16/public_co.gif new file mode 100644 index 0000000000000000000000000000000000000000..662f345ec05219899024625cec840e8ab85edd41 GIT binary patch literal 97 zcmZ?wbhEHb6krfwSj51vfB*jZ^XJ#s*T=`l|NsA=0R|L*vM@3*urTO=1VCyTnAJRX t-T7y5>ST*(a09Q~6&ZmF{u8|ub}men*l_;Cz7&%?rc2-Nna99j4FJ0tAyfbW literal 0 HcmV?d00001 diff --git a/core/org.eclipse.cdt.ui/icons/full/elcl16/static_co.gif b/core/org.eclipse.cdt.ui/icons/full/elcl16/static_co.gif new file mode 100644 index 0000000000000000000000000000000000000000..9330990b1080b4ca040441f6c77c675770e84f51 GIT binary patch literal 149 zcmV;G0BZk7Nk%w1VGsZi0J8u9prD|ipP!zdo`Qmcfq{X5fPi0LUtV5bKR-V{K0ZA? zJs%$*9v&VY9UcGw{{R30A^8LW000gEEC2ui01yBW000C+(8)=wts^0FYm#3#g(8(D zTuG5YbA_bST7!ZNRj>d>0jL2+AmA$%f`EX*m}CGBC88kE2&e>x17M+|P`eWyB?16D DCu}eJ literal 0 HcmV?d00001 diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CPluginImages.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CPluginImages.java index f3a2d565134..aaf93f68573 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CPluginImages.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CPluginImages.java @@ -121,6 +121,10 @@ public class CPluginImages { public static final String IMG_TOOL_GOTO_NEXT_ERROR= NAME_PREFIX + "next_error_nav.gif"; public static final String IMG_EDIT_PROPERTIES= NAME_PREFIX + "prop_edt.gif"; + public static final String IMG_ACTION_SHOW_FIELDS= NAME_PREFIX + "fields_co.gif"; + public static final String IMG_ACTION_SHOW_PUBLIC= NAME_PREFIX + "public_co.gif"; + public static final String IMG_ACTION_SHOW_STATIC= NAME_PREFIX + "static_co.gif"; + public static final ImageDescriptor DESC_OBJS_TEMPLATE= createManaged(T_OBJ, IMG_OBJS_TEMPLATE); public static final ImageDescriptor DESC_OVR_STATIC= create(T_OVR, "static_co.gif"); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/ICHelpContextIds.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/ICHelpContextIds.java index f6bf4b6e43a..074c7fde0bf 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/ICHelpContextIds.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/ICHelpContextIds.java @@ -22,6 +22,10 @@ public interface ICHelpContextIds { public static final String NEW_CPROJECT_WIZARD_PAGE= PREFIX + "new_cproject_wizard_page_context"; public static final String NEW_LAUNCH_WIZARD_PAGE= PREFIX + "new_launch_wizard_page_context"; + // Actions + public static final String FILTER_PUBLIC_ACTION= PREFIX + "filter_public_action"; + public static final String FILTER_FIELDS_ACTION= PREFIX + "filter_fields_action"; + public static final String FILTER_STATIC_ACTION= PREFIX + "filter_static_action"; // Preference/property pages public static final String C_PREF_PAGE= PREFIX + "new_c_pref_page_context"; diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/ActionMessages.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/ActionMessages.java new file mode 100644 index 00000000000..c4d4c179a09 --- /dev/null +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/ActionMessages.java @@ -0,0 +1,71 @@ +/******************************************************************************* + * Copyright (c) 2001 Rational Software Corp. and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v0.5 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v05.html + * + * Contributors: + * Rational Software - initial implementation + ******************************************************************************/ +package org.eclipse.cdt.internal.ui.actions; + + +import java.text.MessageFormat; +import java.util.MissingResourceException; +import java.util.ResourceBundle; + +/** + * Class that gives access to the action messages resource bundle. + */ +public class ActionMessages { + + private static final String BUNDLE_NAME= "org.eclipse.cdt.internal.ui.actions.ActionMessages"; //$NON-NLS-1$ + + private static final ResourceBundle RESOURCE_BUNDLE= ResourceBundle.getBundle(BUNDLE_NAME); + + private ActionMessages() { + // 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 formatted resource string associated with the given key in the resource bundle. + * MessageFormat 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. + * MessageFormat 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); + } +} diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/ActionMessages.properties b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/ActionMessages.properties new file mode 100644 index 00000000000..e3f3b5b4559 --- /dev/null +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/ActionMessages.properties @@ -0,0 +1,274 @@ +############################################################################### +# Copyright (c) 2000, 2003 IBM Corporation and others. +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Common Public License v1.0 +# which accompanies this distribution, and is available at +# http://www.eclipse.org/legal/cpl-v10.html +# +# Contributors: +# IBM Corporation - initial API and implementation +############################################################################### + +OpenWithMenu.label=Open Wit&h +RefactorMenu.label=Refac&tor +SourceMenu.label=&Source +NavigateMenu.label=&Navigate + +BuildAction.label=&Build Project +RebuildAction.label=Rebuild Pro&ject + +SelectionConverter.codeResolveOrInput_failed=Couldn't convert text selection into a Java element +SelectionConverter.codeResolve_failed=Couldn't convert text selection into a Java element + +OpenAction.label=&Open +OpenAction.tooltip=Open an editor on the selected element +OpenAction.description=Open an editor on the selected element +OpenAction.declaration.label=&Open Declaration +OpenAction.select_element=&Select or enter the element to open: + +OpenAction.error.title=Open +OpenAction.error.message=Cannot open default editor. +OpenAction.error.messageArgs=Cannot open default editor on {0}. {1} +OpenAction.error.messageProblems=Problems Opening Editor +OpenAction.error.messageBadSelection=Current text selection doesn't resolve to a Java element + +OpenSuperImplementationAction.label=Open S&uper Implementation +OpenSuperImplementationAction.tooltip=Open the Implementation in the Super Type +OpenSuperImplementationAction.description=Open the Implementation in the Super Type +OpenSuperImplementationAction.error.title=Open Super Implementation +OpenSuperImplementationAction.error.message=Opening failed. Check log for details. +OpenSuperImplementationAction.not_applicable=Operation not applicable to current text selection. Please position the cursor inside a method. +OpenSuperImplementationAction.no_super_implementation=Super implementation for method ''{0}'' does not exist. + +OpenTypeHierarchyAction.label=Open Type Hie&rarchy +OpenTypeHierarchyAction.tooltip=Open a type hierarchy on the selected element +OpenTypeHierarchyAction.description=Open a type hierarchy on the selected element +OpenTypeHierarchyAction.dialog.title=Open Type Hierarchy +OpenTypeHierarchyAction.messages.title=Can\'t create type hierarchy +OpenTypeHierarchyAction.messages.no_java_element=No Java element selected. +OpenTypeHierarchyAction.messages.no_java_resources=Selected package fragment doesn\'t contain any Java resource. +OpenTypeHierarchyAction.messages.no_types=Selected compilation unit doesn\'t contain a type. +OpenTypeHierarchyAction.messages.no_valid_java_element=No valid Java 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} ¬ 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 +MemberFilterActionGroup.hide_fields.tooltip=Hide Fields +MemberFilterActionGroup.hide_fields.description=Toggles the visibility of fields + +MemberFilterActionGroup.hide_static.label=Hide &Static Members +MemberFilterActionGroup.hide_static.tooltip=Hide Static Members +MemberFilterActionGroup.hide_static.description=Toggles the visibility of static members + +MemberFilterActionGroup.hide_nonpublic.label=Hide Non-&Public Members +MemberFilterActionGroup.hide_nonpublic.tooltip=Hide Non-Public Members +MemberFilterActionGroup.hide_nonpublic.description=Toggles the visibility of non-public members + +NewWizardsActionGroup.new=Ne&w + +OpenProjectAction.dialog.title=Open Project +OpenProjectAction.dialog.message=Select project(s) to be opened +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 + +OpenTypeInHierarchyAction.tooltip=Open a type in a type hierarchy +OpenTypeInHierarchyAction.dialogMessage=&Choose a type (? = any character, * = any string): +OpenTypeInHierarchyAction.dialogTitle=Open Type in Hierarchy + +RefreshAction.label= Re&fresh +RefreshAction.toolTip= Refresh +RefreshAction.progressMessage= Refreshing... +RefreshAction.error.title= Refresh Problems +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: +OverrideMethodQuery.selectioninfo.one={0} method selected. +OverrideMethodQuery.selectioninfo.more={0} methods selected. + +ActionUtil.notOnBuildPath.title=Operation Cannot be Performed +ActionUtil.notOnBuildPath.message=The resource is not on the build path of a Java project. +ActionUtil.not_possible=Operation Not Possible +ActionUtil.no_linked=This operation is unavailable on linked packages and package fragment roots. + +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. diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CContentOutlinePage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CContentOutlinePage.java index 05523a6c818..9c905291195 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CContentOutlinePage.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CContentOutlinePage.java @@ -17,6 +17,7 @@ import org.eclipse.cdt.internal.ui.util.ProblemTreeViewer; import org.eclipse.cdt.ui.CElementContentProvider; import org.eclipse.cdt.ui.CUIPlugin; import org.eclipse.cdt.ui.IWorkingCopyManager; +import org.eclipse.cdt.ui.actions.MemberFilterActionGroup; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; @@ -59,6 +60,8 @@ public class CContentOutlinePage extends Page implements IContentOutlinePage, IS private OpenIncludeAction fOpenIncludeAction; private SearchForReferencesAction fSearchForReferencesAction; + private MemberFilterActionGroup fMemberFilterActionGroup; + public CContentOutlinePage(CEditor editor) { this("#TranslationUnitOutlinerContext", editor); } @@ -172,7 +175,8 @@ public class CContentOutlinePage extends Page implements IContentOutlinePage, IS site.setSelectionProvider(treeViewer); IActionBars bars= site.getActionBars(); bars.setGlobalActionHandler(ICEditorActionDefinitionIds.TOGGLE_PRESENTATION, fTogglePresentation); - + + registerToolbarActions(); //IFileEditorInput editorInput= (IFileEditorInput)fEditor.getEditorInput(); IEditorInput editorInput= (IEditorInput)fEditor.getEditorInput(); @@ -201,6 +205,10 @@ public class CContentOutlinePage extends Page implements IContentOutlinePage, IS public void dispose() { CUIPlugin.getDefault().getProblemMarkerManager().removeListener(treeViewer); + if (fMemberFilterActionGroup != null) { + fMemberFilterActionGroup.dispose(); + fMemberFilterActionGroup= null; + } super.dispose(); } @@ -298,4 +306,17 @@ public class CContentOutlinePage extends Page implements IContentOutlinePage, IS } contentUpdated(); } + + private void registerToolbarActions() { + + IToolBarManager toolBarManager= getSite().getActionBars().getToolBarManager(); + if (toolBarManager != null) { + //toolBarManager.add(new ClassOnlyAction()); + //toolBarManager.add(new LexicalSortingAction()); + + fMemberFilterActionGroup= new MemberFilterActionGroup(treeViewer, "COutlineViewer"); //$NON-NLS-1$ + fMemberFilterActionGroup.contributeToToolBar(toolBarManager); + } + } + } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/MemberFilter.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/MemberFilter.java new file mode 100644 index 00000000000..ea0de108b2b --- /dev/null +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/MemberFilter.java @@ -0,0 +1,95 @@ +/******************************************************************************* + * Copyright (c) 2001 Rational Software Corp. and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v0.5 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v05.html + * + * Contributors: + * Rational Software - initial implementation + ******************************************************************************/ +package org.eclipse.cdt.internal.ui.viewsupport; + +import org.eclipse.cdt.core.model.IDeclaration; +import org.eclipse.cdt.core.model.IField; +import org.eclipse.cdt.core.model.IMember; +import org.eclipse.jface.viewers.Viewer; +import org.eclipse.jface.viewers.ViewerFilter; + + +/** + * Filter for the methods viewer. + * Changing a filter property does not trigger a refiltering of the viewer + */ + +public class MemberFilter extends ViewerFilter{ + + public static final int FILTER_NONPUBLIC= 1; + public static final int FILTER_STATIC= 2; + public static final int FILTER_FIELDS= 4; + + private int fFilterProperties; + + /** + * Modifies filter and add a property to filter for + */ + public final void addFilter(int filter) { + fFilterProperties |= filter; + } + /** + * Modifies filter and remove a property to filter for + */ + public final void removeFilter(int filter) { + fFilterProperties &= (-1 ^ filter); + } + /** + * Tests if a property is filtered + */ + public final boolean hasFilter(int filter) { + return (fFilterProperties & filter) != 0; + } + + /* + * @see ViewerFilter@isFilterProperty + */ + public boolean isFilterProperty(Object element, Object property) { + return false; + } + /* + * @see ViewerFilter@select + */ + public boolean select(Viewer viewer, Object parentElement, Object element) { + if(element instanceof IDeclaration){ + IDeclaration declaration = (IDeclaration) element; + if (hasFilter(FILTER_STATIC) && (declaration.isStatic()) ) { + return false; + } + if (element instanceof IMember) { + IMember member= (IMember)element; + if (hasFilter(FILTER_NONPUBLIC) && (member.getVisibility() != IMember.V_PUBLIC)) { + return false; + } + + if (hasFilter(FILTER_FIELDS) && element instanceof IField) { + return false; + } + } + } + return true; + } +/* + private boolean isMemberInInterface(IMember member) throws JavaModelException { + IType parent= member.getDeclaringType(); + return parent != null && parent.isInterface(); + } + + private boolean isFieldInInterface(IMember member) throws JavaModelException { + return (member.getElementType() == IJavaElement.FIELD) && member.getDeclaringType().isInterface(); + } + + private boolean isTopLevelType(IMember member) throws JavaModelException { + IType parent= member.getDeclaringType(); + return parent == null; + } +*/ +} diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/MemberFilterAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/MemberFilterAction.java new file mode 100644 index 00000000000..5291c560b14 --- /dev/null +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/MemberFilterAction.java @@ -0,0 +1,50 @@ +/******************************************************************************* + * Copyright (c) 2001 Rational Software Corp. and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v0.5 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v05.html + * + * Contributors: + * Rational Software - initial implementation + ******************************************************************************/ +package org.eclipse.cdt.internal.ui.viewsupport; + +import org.eclipse.jface.action.Action; +import org.eclipse.ui.help.WorkbenchHelp; +import org.eclipse.cdt.ui.actions.MemberFilterActionGroup;; + +/** + * Action used to enable / disable method filter properties + */ + +public class MemberFilterAction extends Action { + + private int fFilterProperty; + private MemberFilterActionGroup fFilterActionGroup; + + public MemberFilterAction(MemberFilterActionGroup actionGroup, String title, int property, String contextHelpId, boolean initValue) { + super(title); + fFilterActionGroup= actionGroup; + fFilterProperty= property; + + WorkbenchHelp.setHelp(this, contextHelpId); + + setChecked(initValue); + } + + /** + * Returns this action's filter property. + */ + public int getFilterProperty() { + return fFilterProperty; + } + + /* + * @see Action#actionPerformed + */ + public void run() { + fFilterActionGroup.setMemberFilter(fFilterProperty, isChecked()); + } + +} diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/MemberFilterActionGroup.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/MemberFilterActionGroup.java new file mode 100644 index 00000000000..cbf3e2ca029 --- /dev/null +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/MemberFilterActionGroup.java @@ -0,0 +1,267 @@ +/******************************************************************************* + * Copyright (c) 2001 Rational Software Corp. and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v0.5 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v05.html + * + * Contributors: + * Rational Software - initial implementation + ******************************************************************************/ +package org.eclipse.cdt.ui.actions; + +/** + * Action Group that contributes filter buttons for a view parts showing + * methods and fields. Contributed filters are: hide fields, hide static + * members and hide non-public members. + *

+ * The action group installs a filter on a structured viewer. The filter is connected + * to the actions installed in the view part's toolbar menu and is updated when the + * state of the buttons changes. + *

+ */ +import org.eclipse.cdt.internal.ui.viewsupport.MemberFilter; +import org.eclipse.cdt.internal.ui.viewsupport.MemberFilterAction; +import org.eclipse.cdt.ui.CUIPlugin; +import org.eclipse.cdt.internal.ui.actions.ActionMessages; +import org.eclipse.jface.action.IMenuManager; +import org.eclipse.jface.action.IToolBarManager; +import org.eclipse.jface.preference.IPreferenceStore; +import org.eclipse.jface.util.Assert; +import org.eclipse.jface.viewers.StructuredViewer; +import org.eclipse.swt.custom.BusyIndicator; +import org.eclipse.ui.IActionBars; +import org.eclipse.ui.IMemento; +import org.eclipse.ui.actions.ActionGroup; +import org.eclipse.cdt.internal.ui.ICHelpContextIds; +import org.eclipse.cdt.internal.ui.CPluginImages; + +public class MemberFilterActionGroup extends ActionGroup { + public static final int FILTER_NONPUBLIC= MemberFilter.FILTER_NONPUBLIC; + public static final int FILTER_STATIC= MemberFilter.FILTER_STATIC; + public static final int FILTER_FIELDS= MemberFilter.FILTER_FIELDS; + + private static final String TAG_HIDEFIELDS= "hidefields"; //$NON-NLS-1$ + private static final String TAG_HIDESTATIC= "hidestatic"; //$NON-NLS-1$ + private static final String TAG_HIDENONPUBLIC= "hidenonpublic"; //$NON-NLS-1$ + + private MemberFilterAction[] fFilterActions; + private MemberFilter fFilter; + + private StructuredViewer fViewer; + private String fViewerId; + private boolean fInViewMenu; + + + /** + * Creates a new MemberFilterActionGroup. + * + * @param viewer the viewer to be filtered + * @param viewerId a unique id of the viewer. Used as a key to to store + * the last used filter settings in the preference store + */ + public MemberFilterActionGroup(StructuredViewer viewer, String viewerId) { + this(viewer, viewerId, false); + } + + /** + * Creates a new MemberFilterActionGroup. + * + * @param viewer the viewer to be filtered + * @param viewerId a unique id of the viewer. Used as a key to to store + * the last used filter settings in the preference store + * @param inViewMenu if true the actions are added to the view + * menu. If false they are added to the toobar. + * + * @since 2.1 + */ + public MemberFilterActionGroup(StructuredViewer viewer, String viewerId, boolean inViewMenu) { + fViewer= viewer; + fViewerId= viewerId; + fInViewMenu= inViewMenu; + + // get initial values + IPreferenceStore store= CUIPlugin.getDefault().getPreferenceStore(); + boolean doHideFields= store.getBoolean(getPreferenceKey(FILTER_FIELDS)); + boolean doHideStatic= store.getBoolean(getPreferenceKey(FILTER_STATIC)); + boolean doHidePublic= store.getBoolean(getPreferenceKey(FILTER_NONPUBLIC)); + + fFilter= new MemberFilter(); + if (doHideFields) + fFilter.addFilter(FILTER_FIELDS); + if (doHideStatic) + fFilter.addFilter(FILTER_STATIC); + if (doHidePublic) + fFilter.addFilter(FILTER_NONPUBLIC); + + // fields + String title= ActionMessages.getString("MemberFilterActionGroup.hide_fields.label"); //$NON-NLS-1$ + String helpContext= ICHelpContextIds.FILTER_FIELDS_ACTION; + MemberFilterAction hideFields= new MemberFilterAction(this, title, FILTER_FIELDS, helpContext, doHideFields); + hideFields.setDescription(ActionMessages.getString("MemberFilterActionGroup.hide_fields.description")); //$NON-NLS-1$ + hideFields.setToolTipText(ActionMessages.getString("MemberFilterActionGroup.hide_fields.tooltip")); //$NON-NLS-1$ + CPluginImages.setImageDescriptors(hideFields, CPluginImages.T_LCL, CPluginImages.IMG_ACTION_SHOW_FIELDS); //$NON-NLS-1$ + + // static + title= ActionMessages.getString("MemberFilterActionGroup.hide_static.label"); //$NON-NLS-1$ + helpContext= ICHelpContextIds.FILTER_STATIC_ACTION; + MemberFilterAction hideStatic= new MemberFilterAction(this, title, FILTER_STATIC, helpContext, doHideStatic); + hideStatic.setDescription(ActionMessages.getString("MemberFilterActionGroup.hide_static.description")); //$NON-NLS-1$ + hideStatic.setToolTipText(ActionMessages.getString("MemberFilterActionGroup.hide_static.tooltip")); //$NON-NLS-1$ + CPluginImages.setImageDescriptors(hideStatic, CPluginImages.T_LCL, CPluginImages.IMG_ACTION_SHOW_STATIC); //$NON-NLS-1$ + + // non-public + title= ActionMessages.getString("MemberFilterActionGroup.hide_nonpublic.label"); //$NON-NLS-1$ + helpContext= ICHelpContextIds.FILTER_PUBLIC_ACTION; + MemberFilterAction hideNonPublic= new MemberFilterAction(this, title, FILTER_NONPUBLIC, helpContext, doHidePublic); + hideNonPublic.setDescription(ActionMessages.getString("MemberFilterActionGroup.hide_nonpublic.description")); //$NON-NLS-1$ + hideNonPublic.setToolTipText(ActionMessages.getString("MemberFilterActionGroup.hide_nonpublic.tooltip")); //$NON-NLS-1$ + CPluginImages.setImageDescriptors(hideNonPublic, CPluginImages.T_LCL, CPluginImages.IMG_ACTION_SHOW_PUBLIC); //$NON-NLS-1$ + + // order corresponds to order in toolbar + fFilterActions= new MemberFilterAction[] { hideFields, hideStatic, hideNonPublic }; + + fViewer.addFilter(fFilter); + } + + private String getPreferenceKey(int filterProperty) { + return "MemberFilterActionGroup." + fViewerId + '.' + String.valueOf(filterProperty); //$NON-NLS-1$ + } + + /** + * Sets the member filters. + * + * @param filterProperty the filter to be manipulated. Valid values are FILTER_FIELDS, + * FILTER_PUBLIC, and FILTER_PRIVATE as defined by this action + * group + * @param set if true the given filter is installed. If false the + * given filter is removed + * . + */ + public void setMemberFilter(int filterProperty, boolean set) { + setMemberFilters(new int[] {filterProperty}, new boolean[] {set}, true); + } + + private void setMemberFilters(int[] propertyKeys, boolean[] propertyValues, boolean refresh) { + if (propertyKeys.length == 0) + return; + Assert.isTrue(propertyKeys.length == propertyValues.length); + + for (int i= 0; i < propertyKeys.length; i++) { + int filterProperty= propertyKeys[i]; + boolean set= propertyValues[i]; + if (set) { + fFilter.addFilter(filterProperty); + } else { + fFilter.removeFilter(filterProperty); + } + IPreferenceStore store= CUIPlugin.getDefault().getPreferenceStore(); + + for (int j= 0; j < fFilterActions.length; j++) { + int currProperty= fFilterActions[j].getFilterProperty(); + if (currProperty == filterProperty) { + fFilterActions[j].setChecked(set); + } + store.setValue(getPreferenceKey(currProperty), hasMemberFilter(currProperty)); + } + } + if (refresh) { + fViewer.getControl().setRedraw(false); + BusyIndicator.showWhile(fViewer.getControl().getDisplay(), new Runnable() { + public void run() { + fViewer.refresh(); + } + }); + fViewer.getControl().setRedraw(true); + } + } + + /** + * Returns true if the given filter is installed. + * + * @param filterProperty the filter to be tested. Valid values are FILTER_FIELDS, + * FILTER_PUBLIC, and FILTER_PRIVATE as defined by this action + * group + */ + public boolean hasMemberFilter(int filterProperty) { + return fFilter.hasFilter(filterProperty); + } + + /** + * Saves the state of the filter actions in a memento. + * + * @param memento the memento to which the state is saved + */ + public void saveState(IMemento memento) { + memento.putString(TAG_HIDEFIELDS, String.valueOf(hasMemberFilter(FILTER_FIELDS))); + memento.putString(TAG_HIDESTATIC, String.valueOf(hasMemberFilter(FILTER_STATIC))); + memento.putString(TAG_HIDENONPUBLIC, String.valueOf(hasMemberFilter(FILTER_NONPUBLIC))); + } + + /** + * Restores the state of the filter actions from a memento. + *

+ * Note: This method does not refresh the viewer. + *

+ * @param memento the memento from which the state is restored + */ + public void restoreState(IMemento memento) { + setMemberFilters( + new int[] {FILTER_FIELDS, FILTER_STATIC, FILTER_NONPUBLIC}, + new boolean[] { + Boolean.valueOf(memento.getString(TAG_HIDEFIELDS)).booleanValue(), + Boolean.valueOf(memento.getString(TAG_HIDESTATIC)).booleanValue(), + Boolean.valueOf(memento.getString(TAG_HIDENONPUBLIC)).booleanValue() + }, false); + } + + /* (non-Javadoc) + * @see ActionGroup#fillActionBars(IActionBars) + */ + public void fillActionBars(IActionBars actionBars) { + contributeToToolBar(actionBars.getToolBarManager()); + }; + + /** + * Adds the filter actions to the given tool bar + * + * @param tbm the tool bar to which the actions are added + */ + public void contributeToToolBar(IToolBarManager tbm) { + if (fInViewMenu) + return; + tbm.add(fFilterActions[0]); // fields + tbm.add(fFilterActions[1]); // static + tbm.add(fFilterActions[2]); // public + } + + /** + * Adds the filter actions to the given menu manager. + * + * @param menu the menu manager to which the actions are added + * @since 2.1 + */ + public void contributeToViewMenu(IMenuManager menu) { + if (!fInViewMenu) + return; + final String filters= "filters"; //$NON-NLS-1$ + if (menu.find(filters) != null) { + menu.prependToGroup(filters, fFilterActions[0]); // fields + menu.prependToGroup(filters, fFilterActions[1]); // static + menu.prependToGroup(filters, fFilterActions[2]); // public + } else { + menu.add(fFilterActions[0]); // fields + menu.add(fFilterActions[1]); // static + menu.add(fFilterActions[2]); // public + } + } + + /* (non-Javadoc) + * @see ActionGroup#dispose() + */ + public void dispose() { + super.dispose(); + } + + +}