Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 144529 Details for
Bug 276466
[call hierarchy] Improve UI for View Menu Preferences
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Patch on top of latest code
patch6_274087UI.txt (text/plain), 55.89 KB, created by
Raksha Vasisht
on 2009-08-14 09:38:10 EDT
(
hide
)
Description:
Patch on top of latest code
Filename:
MIME Type:
Creator:
Raksha Vasisht
Created:
2009-08-14 09:38:10 EDT
Size:
55.89 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.ui >Index: ui/org/eclipse/jdt/internal/ui/callhierarchy/CallHierarchyMessages.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/callhierarchy/CallHierarchyMessages.java,v >retrieving revision 1.15 >diff -u -r1.15 CallHierarchyMessages.java >--- ui/org/eclipse/jdt/internal/ui/callhierarchy/CallHierarchyMessages.java 29 Jun 2009 15:00:22 -0000 1.15 >+++ ui/org/eclipse/jdt/internal/ui/callhierarchy/CallHierarchyMessages.java 14 Aug 2009 13:21:37 -0000 >@@ -58,7 +58,6 @@ > public static String ToggleOrientationAction_single_label; > public static String ToggleOrientationAction_single_tooltip; > public static String ToggleOrientationAction_single_description; >- public static String ShowExpandWithConstructorsDialogAction_text; > public static String ShowFilterDialogAction_text; > public static String FiltersDialog_filter; > public static String FiltersDialog_filterOnNames; >@@ -74,6 +73,8 @@ > public static String CallHierarchyLabelProvider_noMethodSelected; > public static String CallHierarchyLabelProvider_updatePending; > public static String CallHierarchyLabelProvider_matches; >+ public static String CallHierarchyPreferencePage_expand_with_constructors_title; >+ public static String CallHierarchyPreferenceDialog_anonymousTypes_label; > public static String CallHierarchyViewPart_empty; > public static String CallHierarchyViewPart_callsToConstructors; > public static String CallHierarchyViewPart_callsToField; >@@ -139,15 +140,12 @@ > public static String ExpandWithConstructorsAction_expandWithConstructors_text; > public static String ExpandWithConstructorsAction_expandWithConstructors_description; > public static String ExpandWithConstructorsAction_expandWithConstructors_tooltip; >- public static String ExpandWithConstructorsDialog_anonymousTypes_label; >- public static String ExpandWithConstructorsDialog_explanation_label; >- public static String ExpandWithConstructorsDialog_not_a_valid_type_name; >- public static String ExpandWithConstructorsDialog_title; >- public static String ExpandWithConstructorsDialog_typeNames_label; > static { > NLS.initializeMessages(BUNDLE_NAME, CallHierarchyMessages.class); > } > > public static String CallHierarchyViewPart_layout_menu; > public static String CallHierarchyViewPart_field_menu; >+ public static String CallHierarchyViewPart_preferences_label; >+ > } >Index: ui/org/eclipse/jdt/internal/ui/callhierarchy/ExpandWithConstructorsDialog.java >=================================================================== >RCS file: ui/org/eclipse/jdt/internal/ui/callhierarchy/ExpandWithConstructorsDialog.java >diff -N ui/org/eclipse/jdt/internal/ui/callhierarchy/ExpandWithConstructorsDialog.java >--- ui/org/eclipse/jdt/internal/ui/callhierarchy/ExpandWithConstructorsDialog.java 28 May 2009 13:05:43 -0000 1.2 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,146 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2009 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.jdt.internal.ui.callhierarchy; >- >-import org.eclipse.swt.SWT; >-import org.eclipse.swt.custom.StyledText; >-import org.eclipse.swt.events.ModifyEvent; >-import org.eclipse.swt.events.ModifyListener; >-import org.eclipse.swt.layout.GridData; >-import org.eclipse.swt.widgets.Button; >-import org.eclipse.swt.widgets.Composite; >-import org.eclipse.swt.widgets.Control; >-import org.eclipse.swt.widgets.Label; >-import org.eclipse.swt.widgets.Shell; >- >-import org.eclipse.core.runtime.IStatus; >- >-import org.eclipse.jface.dialogs.StatusDialog; >- >-import org.eclipse.ui.PlatformUI; >- >-import org.eclipse.jdt.core.JavaConventions; >-import org.eclipse.jdt.core.JavaCore; >- >-import org.eclipse.jdt.internal.corext.util.Messages; >- >-import org.eclipse.jdt.ui.PreferenceConstants; >- >-import org.eclipse.jdt.internal.ui.IJavaHelpContextIds; >-import org.eclipse.jdt.internal.ui.dialogs.StatusInfo; >- >-/** >- * Configuration dialog for default "Expand with Constructors" behavior. >- * >- * @since 3.5 >- */ >-class ExpandWithConstructorsDialog extends StatusDialog { >- >- private static final String LINE_DELIMITER_REGEX= "\\r\\n?|\\n"; //$NON-NLS-1$ >- >- private Button fAnonymousButton; >- private StyledText fDefaultTypesText; >- >- protected ExpandWithConstructorsDialog(Shell parentShell) { >- super(parentShell); >- } >- >- /* >- * @see org.eclipse.jface.dialogs.Dialog#isResizable() >- */ >- protected boolean isResizable() { >- return true; >- } >- >- /* >- * @see org.eclipse.jface.dialogs.StatusDialog#configureShell(org.eclipse.swt.widgets.Shell) >- */ >- protected void configureShell(Shell newShell) { >- super.configureShell(newShell); >- newShell.setText(CallHierarchyMessages.ExpandWithConstructorsDialog_title); >- setHelpAvailable(false); >- PlatformUI.getWorkbench().getHelpSystem().setHelp(newShell, IJavaHelpContextIds.CALL_HIERARCHY_EXPAND_WITH_CONSTRUCTORS_DIALOG); >- } >- >- /* >- * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite) >- */ >- protected Control createDialogArea(Composite parent) { >- Composite composite= (Composite)super.createDialogArea(parent); >- ((GridData)composite.getLayoutData()).widthHint= convertWidthInCharsToPixels(60); >- >- Label descriptionLabel= new Label(composite, SWT.WRAP); >- descriptionLabel.setText(CallHierarchyMessages.ExpandWithConstructorsDialog_explanation_label); >- descriptionLabel.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false)); >- >- >- Label typesLabel= new Label(composite, SWT.WRAP); >- typesLabel.setText(CallHierarchyMessages.ExpandWithConstructorsDialog_typeNames_label); >- typesLabel.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false)); >- >- fDefaultTypesText= new StyledText(composite, SWT.BORDER | SWT.WRAP | SWT.H_SCROLL | SWT.V_SCROLL); >- GridData gd= new GridData(SWT.FILL, SWT.FILL, true, true); >- gd.heightHint= convertHeightInCharsToPixels(10); >- fDefaultTypesText.setLayoutData(gd); >- >- String defaultTypesPref= PreferenceConstants.getPreferenceStore().getString(CallHierarchyContentProvider.PREF_DEFAULT_EXPAND_WITH_CONSTRUCTORS); >- String defaultTypesText= defaultTypesPref.replace(';', '\n'); >- fDefaultTypesText.setText(defaultTypesText); >- fDefaultTypesText.setSelection(fDefaultTypesText.getCharCount()); >- >- fDefaultTypesText.addModifyListener(new ModifyListener() { >- public void modifyText(ModifyEvent e) { >- validateInput(); >- } >- }); >- >- >- fAnonymousButton= new Button(composite, SWT.CHECK); >- fAnonymousButton.setText(CallHierarchyMessages.ExpandWithConstructorsDialog_anonymousTypes_label); >- boolean anonymousPref= PreferenceConstants.getPreferenceStore().getBoolean(CallHierarchyContentProvider.PREF_ANONYMOUS_EXPAND_WITH_CONSTRUCTORS); >- fAnonymousButton.setSelection(anonymousPref); >- fAnonymousButton.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false)); >- >- return composite; >- } >- >- /* >- * @see org.eclipse.jface.dialogs.Dialog#okPressed() >- */ >- protected void okPressed() { >- PreferenceConstants.getPreferenceStore().setValue(CallHierarchyContentProvider.PREF_ANONYMOUS_EXPAND_WITH_CONSTRUCTORS, fAnonymousButton.getSelection()); >- >- String defaultTypes= fDefaultTypesText.getText().trim(); >- String defaultTypesPref= defaultTypes.replaceAll(LINE_DELIMITER_REGEX, ";"); //$NON-NLS-1$ >- PreferenceConstants.getPreferenceStore().setValue(CallHierarchyContentProvider.PREF_DEFAULT_EXPAND_WITH_CONSTRUCTORS, defaultTypesPref); >- >- super.okPressed(); >- } >- >- private void validateInput() { >- StatusInfo status= new StatusInfo(); >- >- String[] defaultTypes= fDefaultTypesText.getText().split(LINE_DELIMITER_REGEX); >- for (int i= 0; i < defaultTypes.length; i++) { >- String type= defaultTypes[i]; >- if (type.length() == 0) >- continue; >- >- IStatus typeNameStatus= JavaConventions.validateJavaTypeName(type, JavaCore.VERSION_1_3, JavaCore.VERSION_1_3); >- if (typeNameStatus.getSeverity() == IStatus.ERROR) { >- status.setError(Messages.format(CallHierarchyMessages.ExpandWithConstructorsDialog_not_a_valid_type_name, type)); >- break; >- } >- } >- >- updateStatus(status); >- } >-} >Index: ui/org/eclipse/jdt/internal/ui/callhierarchy/CallHierarchyContentProvider.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/callhierarchy/CallHierarchyContentProvider.java,v >retrieving revision 1.32 >diff -u -r1.32 CallHierarchyContentProvider.java >--- ui/org/eclipse/jdt/internal/ui/callhierarchy/CallHierarchyContentProvider.java 14 May 2009 20:05:18 -0000 1.32 >+++ ui/org/eclipse/jdt/internal/ui/callhierarchy/CallHierarchyContentProvider.java 14 Aug 2009 13:21:37 -0000 >@@ -51,9 +51,9 @@ > * Value is of type <code>String</code>: semicolon separated list of fully qualified type names. > * </p> > * >- * @since 3.5 >+ * @since 3.6 > */ >- public static final String PREF_DEFAULT_EXPAND_WITH_CONSTRUCTORS= "CallHierarchy.defaultExpandWithConstructors"; //$NON-NLS-1$ >+ public static final String CALL_HIERARCHY_PREFERENCES= "CallHierarchy.defaultExpandWithConstructors"; //$NON-NLS-1$ > > /** > * A named preference that controls whether methods from anonymous types are by default expanded >@@ -62,7 +62,7 @@ > * Value is of type <code>Boolean</code>. > * </p> > * >- * @since 3.5 >+ * @since 3.6 > */ > public static final String PREF_ANONYMOUS_EXPAND_WITH_CONSTRUCTORS= "CallHierarchy.anonymousExpandWithConstructors"; //$NON-NLS-1$ > >@@ -182,7 +182,7 @@ > boolean anonymousPref= PreferenceConstants.getPreferenceStore().getBoolean(PREF_ANONYMOUS_EXPAND_WITH_CONSTRUCTORS); > if (anonymousPref && type.isAnonymous()) { > withConstructors= true; >- } else if (isInTheDefaultExpandWithConstructorList(type)) { >+ } else if (isInTheDefaultExpandWithConstructorList(wrapper)) { > withConstructors= true; > } > } >@@ -217,21 +217,22 @@ > } > > /** >- * Checks if declaring type matches the pre-defined array of types for default expand with >- * constructors. >+ * Checks if the member or its declaring type matches the pre-defined array of members and types >+ * for default expand with constructors. > * >- * @param type the declaring type of the caller method wrapper >- * @return <code>true</code> if type matches the pre-defined list, <code>false</code> otherwise >- * @since 3.5 >+ * @param wrapper caller method wrapper >+ * @return <code>true</code> if method or type matches the pre-defined list, <code>false</code> otherwise >+ * @since 3.6 > */ >- static boolean isInTheDefaultExpandWithConstructorList(IType type) { >- String serializedTypes= PreferenceConstants.getPreferenceStore().getString(PREF_DEFAULT_EXPAND_WITH_CONSTRUCTORS); >+ static boolean isInTheDefaultExpandWithConstructorList(CallerMethodWrapper wrapper) { >+ String serializedTypes= PreferenceConstants.getPreferenceStore().getString(CALL_HIERARCHY_PREFERENCES); > if (serializedTypes.length() == 0) > return false; >- >+ String member= wrapper.getMember().getElementName(); >+ IType type= wrapper.getMember().getDeclaringType(); > String[] defaultTypes= serializedTypes.split(";"); //$NON-NLS-1$ >- >- String typeName= type.getFullyQualifiedName('.'); >+ >+ String typeName= type.getFullyQualifiedName('.').concat(".*"); //$NON-NLS-1$; > String superClass; > String[] superInterfaces; > try { >@@ -242,12 +243,12 @@ > } > for (int i= 0; i < defaultTypes.length; i++) { > String defaultType= defaultTypes[i]; >- if (typeName.equals(defaultType) || (superClass != null && typeNameMatches(superClass, defaultType))) { >+ if (typeNameMatches(member, defaultType) || typeName.equals(defaultType) || (superClass != null && typeNameMatches(superClass.concat(".*"), defaultType))) { //$NON-NLS-1$ > return true; > } > if (superInterfaces.length > 0) { > for (int j= 0; j < superInterfaces.length; j++) { >- if (typeNameMatches(superInterfaces[j], defaultType)) >+ if (typeNameMatches(superInterfaces[j].concat(".*"), defaultType)) //$NON-NLS-1$ > return true; > } > } >Index: ui/org/eclipse/jdt/internal/ui/callhierarchy/CallHierarchyMessages.properties >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/callhierarchy/CallHierarchyMessages.properties,v >retrieving revision 1.46 >diff -u -r1.46 CallHierarchyMessages.properties >--- ui/org/eclipse/jdt/internal/ui/callhierarchy/CallHierarchyMessages.properties 29 Jun 2009 15:00:22 -0000 1.46 >+++ ui/org/eclipse/jdt/internal/ui/callhierarchy/CallHierarchyMessages.properties 14 Aug 2009 13:21:37 -0000 >@@ -55,7 +55,6 @@ > ToggleOrientationAction_single_tooltip=Hierarchy View Only > ToggleOrientationAction_single_description=Hierarchy View Only > >-ShowExpandWithConstructorsDialogAction_text=E&xpand with Constructors... > ShowFilterDialogAction_text= &Filters... > FiltersDialog_filter= Filter Calls > FiltersDialog_filterOnNames= &Name filter patterns (matching names will be hidden): >@@ -71,6 +70,8 @@ > CallHierarchyLabelProvider_noMethodSelected=- no method selected - > CallHierarchyLabelProvider_updatePending=... > CallHierarchyLabelProvider_matches={0} ({1} matches) >+CallHierarchyPreferencePage_expand_with_constructors_title=Expand With Constructors >+CallHierarchyPreferenceDialog_anonymousTypes_label=&All methods in anonymous types > CallHierarchyViewPart_empty=To display the call hierarchy, select one or more methods, classes, fields, or initializers, and select the \'Open Call Hierarchy\' menu option. Alternatively, you can drag and drop the member or members onto this view. > CallHierarchyViewPart_callsToConstructors=Members calling constructors of ''{0}'' - in {1} > CallHierarchyViewPart_callsToField=Members accessing ''{0}'' - in {1} >@@ -86,6 +87,8 @@ > CallHierarchyViewPart_callsFromMembers_3=Calls from ''{0}'', ''{1}'', ''{2}'' - in {3} > CallHierarchyViewPart_callsFromMembers_more=Calls from ''{0}'', ''{1}'', ''{2}'', ... - in {3} > CallHierarchyViewPart_callsFromMethod=Calls from ''{0}'' - in {1} >+CallHierarchyViewPart_preferences_label= Preferences... >+ > FocusOnSelectionAction_focusOnSelection_text=Fo&cus On Selection > FocusOnSelectionAction_focusOnSelection_description=Focus On Selection > FocusOnSelectionAction_focusOnSelection_tooltip=Focus On Selection >@@ -145,9 +148,4 @@ > RemoveFromViewAction_removeFromView_tooltip= Remove from View > ExpandWithConstructorsAction_expandWithConstructors_text= &Expand with Constructors > ExpandWithConstructorsAction_expandWithConstructors_description= Expand with constructors >-ExpandWithConstructorsAction_expandWithConstructors_tooltip= Expand with Constructors >-ExpandWithConstructorsDialog_anonymousTypes_label=&All methods in anonymous types >-ExpandWithConstructorsDialog_explanation_label=Configure the types whose instance methods are expanded with constructors by default. >-ExpandWithConstructorsDialog_not_a_valid_type_name=''{0}'' is not a valid type name >-ExpandWithConstructorsDialog_title=Expand with Constructors >-ExpandWithConstructorsDialog_typeNames_label=Type &names (each on a line): >+ExpandWithConstructorsAction_expandWithConstructors_tooltip= Expand with Constructors >\ No newline at end of file >Index: ui/org/eclipse/jdt/internal/ui/callhierarchy/CallHierarchyFiltersActionGroup.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/callhierarchy/CallHierarchyFiltersActionGroup.java,v >retrieving revision 1.13 >diff -u -r1.13 CallHierarchyFiltersActionGroup.java >--- ui/org/eclipse/jdt/internal/ui/callhierarchy/CallHierarchyFiltersActionGroup.java 14 May 2009 20:05:18 -0000 1.13 >+++ ui/org/eclipse/jdt/internal/ui/callhierarchy/CallHierarchyFiltersActionGroup.java 14 Aug 2009 13:21:37 -0000 >@@ -11,8 +11,6 @@ > *******************************************************************************/ > package org.eclipse.jdt.internal.ui.callhierarchy; > >-import org.eclipse.swt.widgets.Shell; >- > import org.eclipse.core.runtime.Assert; > > import org.eclipse.jface.action.Action; >@@ -46,17 +44,7 @@ > openFiltersDialog(); > } > } >- >- class ShowExpandWithConstructorsDialogAction extends Action { >- ShowExpandWithConstructorsDialogAction() { >- setText(CallHierarchyMessages.ShowExpandWithConstructorsDialogAction_text); >- } >- >- public void run() { >- openExpandWithConstructorsDialog(); >- } >- } >- >+ > private IViewPart fPart; > > /** >@@ -81,7 +69,6 @@ > private void fillViewMenu(IMenuManager viewMenu) { > viewMenu.add(new Separator("filters")); //$NON-NLS-1$ > viewMenu.add(new ShowFilterDialogAction()); >- viewMenu.add(new ShowExpandWithConstructorsDialogAction()); > } > > /* (non-Javadoc) >@@ -99,9 +86,4 @@ > > dialog.open(); > } >- >- private void openExpandWithConstructorsDialog() { >- Shell parentShell= fPart.getViewSite().getShell(); >- new ExpandWithConstructorsDialog(parentShell).open(); >- } > } >Index: ui/org/eclipse/jdt/internal/ui/callhierarchy/CallHierarchyViewPart.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/callhierarchy/CallHierarchyViewPart.java,v >retrieving revision 1.76 >diff -u -r1.76 CallHierarchyViewPart.java >--- ui/org/eclipse/jdt/internal/ui/callhierarchy/CallHierarchyViewPart.java 29 Jun 2009 15:00:44 -0000 1.76 >+++ ui/org/eclipse/jdt/internal/ui/callhierarchy/CallHierarchyViewPart.java 14 Aug 2009 13:21:38 -0000 >@@ -237,6 +237,7 @@ > private boolean fShowCallDetails; > protected Composite fParent; > private IPartListener2 fPartListener; >+ private PreferencesActionGroup fPreferences; > > > public CallHierarchyViewPart() { >@@ -1007,6 +1008,7 @@ > fSearchScopeActions = new SearchScopeActionGroup(this, fDialogSettings); > fFiltersActionGroup = new CallHierarchyFiltersActionGroup(this, > fCallHierarchyViewer); >+ fPreferences= new PreferencesActionGroup(this); > fHistoryDropDownAction = new HistoryDropDownAction(this); > fHistoryDropDownAction.setEnabled(false); > fCancelSearchAction = new CancelSearchAction(this); >@@ -1035,7 +1037,7 @@ > new GenerateActionGroup(this), > new RefactorActionGroup(this), > new JavaSearchActionGroup(this), >- fSearchScopeActions, fFiltersActionGroup >+ fSearchScopeActions, fFiltersActionGroup, fPreferences > }); > } > >Index: ui/org/eclipse/jdt/internal/ui/preferences/PreferencesMessages.properties >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/PreferencesMessages.properties,v >retrieving revision 1.487 >diff -u -r1.487 PreferencesMessages.properties >--- ui/org/eclipse/jdt/internal/ui/preferences/PreferencesMessages.properties 15 May 2009 06:44:19 -0000 1.487 >+++ ui/org/eclipse/jdt/internal/ui/preferences/PreferencesMessages.properties 14 Aug 2009 13:21:39 -0000 >@@ -923,6 +923,25 @@ > CodeAssistStaticMembersConfigurationBlock_edit_button= &Edit... > CodeAssistStaticMembersConfigurationBlock_remove_button= &Remove > >+CallHierarchyPreferencesConfigurationBlock_description= De&fine a list of members or types with their fully qualified names.Call Hierarchy for these types/members will "Expand With Constructors" by default. >+CallHierarchyPreferencesConfigurationBlock_newType_button= New &Type... >+CallHierarchyPreferencesConfigurationBlock_newMember_button= New &Member... >+CallHierarchyPreferencesConfigurationBlock_edit_button= &Edit >+CallHierarchyPreferencesConfigurationBlock_remove_button= &Remove >+ >+CallHierarchyPreferencesDialog_member_title= New Member for Expand With Constructors >+CallHierarchyPreferencesDialog_member_labelText= Enter a fully qualified static member (e.g. \'java.lang.Math.sqrt\'): >+CallHierarchyPreferencesDialog_type_title= New Type for Expand With Constructors >+CallHierarchyPreferencesDialog_type_labelText= Enter a fully qualified type (e.g. \'java.lang.Math\'): >+CallHierarchyPreferencesDialog_browse_button= &Browse... >+CallHierarchyPreferencesDialog_ChooseTypeDialog_title= Type Selection >+CallHierarchyPreferencesDialog_ChooseTypeDialog_description= Choose type name: >+CallHierarchyPreferencesDialog_ChooseTypeDialog_error_message= A problem occurred while collecting types. See the error Log for details. >+CallHierarchyPreferencesDialog_error_enterName=Enter a name or prefix. >+CallHierarchyPreferencesDialog_error_invalidTypeName=Not a valid type name. >+CallHierarchyPreferencesDialog_error_invalidMemberName=Not a valid member name. >+CallHierarchyPreferencesDialog_error_entryExists=Entry already exists in list. >+ > FavoriteStaticMemberInputDialog_member_title= New Member Favorite > FavoriteStaticMemberInputDialog_member_labelText= Enter a fully qualified static member (e.g. \'java.lang.Math.sqrt\'): > FavoriteStaticMemberInputDialog_type_title= New Type Favorite >Index: ui/org/eclipse/jdt/internal/ui/preferences/PreferencesMessages.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/PreferencesMessages.java,v >retrieving revision 1.117 >diff -u -r1.117 PreferencesMessages.java >--- ui/org/eclipse/jdt/internal/ui/preferences/PreferencesMessages.java 2 Apr 2009 09:30:30 -0000 1.117 >+++ ui/org/eclipse/jdt/internal/ui/preferences/PreferencesMessages.java 14 Aug 2009 13:21:38 -0000 >@@ -808,6 +808,12 @@ > public static String CodeAssistStaticMembersConfigurationBlock_edit_button; > public static String CodeAssistStaticMembersConfigurationBlock_remove_button; > >+ public static String CallHierarchyPreferencesConfigurationBlock_description; >+ public static String CallHierarchyPreferencesConfigurationBlock_newType_button; >+ public static String CallHierarchyPreferencesConfigurationBlock_newMember_button; >+ public static String CallHierarchyPreferencesConfigurationBlock_edit_button; >+ public static String CallHierarchyPreferencesConfigurationBlock_remove_button; >+ > public static String FavoriteStaticMemberInputDialog_member_title; > public static String FavoriteStaticMemberInputDialog_member_labelText; > public static String FavoriteStaticMemberInputDialog_type_title; >@@ -821,4 +827,17 @@ > public static String FavoriteStaticMemberInputDialog_error_invalidTypeName; > public static String FavoriteStaticMemberInputDialog_error_entryExists; > >+ public static String CallHierarchyPreferencesDialog_member_title; >+ public static String CallHierarchyPreferencesDialog_member_labelText; >+ public static String CallHierarchyPreferencesDialog_type_title; >+ public static String CallHierarchyPreferencesDialog_type_labelText; >+ public static String CallHierarchyPreferencesDialog_browse_button; >+ public static String CallHierarchyPreferencesDialog_ChooseTypeDialog_title; >+ public static String CallHierarchyPreferencesDialog_ChooseTypeDialog_description; >+ public static String CallHierarchyPreferencesDialog_ChooseTypeDialog_error_message; >+ public static String CallHierarchyPreferencesDialog_error_enterName; >+ public static String CallHierarchyPreferencesDialog_error_invalidMemberName; >+ public static String CallHierarchyPreferencesDialog_error_invalidTypeName; >+ public static String CallHierarchyPreferencesDialog_error_entryExists; >+ > } >Index: ui/org/eclipse/jdt/ui/PreferenceConstants.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/PreferenceConstants.java,v >retrieving revision 1.246 >diff -u -r1.246 PreferenceConstants.java >--- ui/org/eclipse/jdt/ui/PreferenceConstants.java 14 May 2009 20:05:18 -0000 1.246 >+++ ui/org/eclipse/jdt/ui/PreferenceConstants.java 14 Aug 2009 13:21:41 -0000 >@@ -64,7 +64,7 @@ > * > * @noinstantiate This class is not intended to be instantiated by clients. > * @noextend This class is not intended to be subclassed by clients. >- */ >+ */ > public class PreferenceConstants { > > private PreferenceConstants() { >@@ -2977,6 +2977,13 @@ > */ > public final static String CODEASSIST_FAVORITE_STATIC_MEMBERS= "content_assist_favorite_static_members"; //$NON-NLS-1$ > >+ /** >+ * A named preference that holds the types/members which expand with >+ * constructors by default. >+ * >+ * @since 3.6 >+ */ >+ public static final String CALL_HIERARCHY_PREFERENCES= "call_hierarchy_preferences_page"; //$NON-NLS-1$ > > /** > * A named preference that controls the behavior of the refactoring wizard for showing the error page. >@@ -3833,6 +3840,7 @@ > > store.setDefault(PreferenceConstants.PROPERTIES_FILE_COLORING_COMMENT_BOLD, false); > store.setDefault(PreferenceConstants.PROPERTIES_FILE_COLORING_COMMENT_ITALIC, false); >+ store.setDefault(CallHierarchyContentProvider.CALL_HIERARCHY_PREFERENCES, "java.lang.Runnable;java.util.concurrent.Callable;org.eclipse.swt.widgets.Listener"); //$NON-NLS-1$ > > // semantic highlighting > SemanticHighlightings.initDefaults(store); >@@ -3876,8 +3884,7 @@ > // Colors that are set by the current theme > JavaUIPreferenceInitializer.setThemeBasedPreferences(store, false); > >- store.setDefault(CallHierarchyContentProvider.PREF_ANONYMOUS_EXPAND_WITH_CONSTRUCTORS, true); >- store.setDefault(CallHierarchyContentProvider.PREF_DEFAULT_EXPAND_WITH_CONSTRUCTORS, "java.lang.Runnable;java.util.concurrent.Callable;org.eclipse.swt.widgets.Listener"); //$NON-NLS-1$ >+ store.setDefault(CallHierarchyContentProvider.PREF_ANONYMOUS_EXPAND_WITH_CONSTRUCTORS, true); > } > > /** >Index: ui/org/eclipse/jdt/internal/ui/callhierarchy/PreferencesActionGroup.java >=================================================================== >RCS file: ui/org/eclipse/jdt/internal/ui/callhierarchy/PreferencesActionGroup.java >diff -N ui/org/eclipse/jdt/internal/ui/callhierarchy/PreferencesActionGroup.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ ui/org/eclipse/jdt/internal/ui/callhierarchy/PreferencesActionGroup.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,82 @@ >+/******************************************************************************* >+ * Copyright (c) 2009 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 >+ * >+ *******************************************************************************/ >+ >+package org.eclipse.jdt.internal.ui.callhierarchy; >+ >+import org.eclipse.jface.action.Action; >+import org.eclipse.jface.action.IMenuManager; >+import org.eclipse.jface.action.Separator; >+import org.eclipse.jface.preference.IPreferenceNode; >+import org.eclipse.jface.preference.PreferenceDialog; >+import org.eclipse.jface.preference.PreferenceManager; >+import org.eclipse.jface.preference.PreferenceNode; >+ >+import org.eclipse.ui.IActionBars; >+import org.eclipse.ui.actions.ActionGroup; >+ >+/** >+ * Call Hierarchy preferences action group. >+ * >+ * @since 3.6 >+ * >+ */ >+public class PreferencesActionGroup extends ActionGroup { >+ private CallHierarchyViewPart fPart; >+ >+ public PreferencesActionGroup(CallHierarchyViewPart part) { >+ fPart= part; >+ } >+ >+ /** >+ * Call hierarchy preferences action class. >+ * >+ * @since 3.6 >+ * >+ */ >+ public class CallHierarchyPreferencesAction extends Action { >+ >+ /** >+ * Creates the call hierarchy preference action. >+ */ >+ public CallHierarchyPreferencesAction() { >+ setText(CallHierarchyMessages.CallHierarchyViewPart_preferences_label); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.action.Action#run() >+ */ >+ public void run() { >+ CallHierarchyPreferencePage page= new CallHierarchyPreferencePage(); >+ IPreferenceNode targetNode= new PreferenceNode("org.eclipse.jdt.ui.preferences.CallHierarchyPreferencePage", page); //$NON-NLS-1$ >+ PreferenceManager manager= new PreferenceManager(); >+ manager.addToRoot(targetNode); >+ PreferenceDialog dialog= new PreferenceDialog(fPart.getSite().getShell(), manager); >+ dialog.create(); >+ dialog.open(); >+ } >+ } >+ >+ >+ /* (non-Javadoc) >+ * Method declared on ActionGroup. >+ */ >+ public void fillActionBars(IActionBars actionBars) { >+ fillViewMenu(actionBars.getMenuManager()); >+ } >+ >+ /* (non-Javadoc) >+ * Method declared on ActionGroup. >+ */ >+ private void fillViewMenu(IMenuManager viewMenu) { >+ viewMenu.add(new Separator("preferences")); //$NON-NLS-1$ >+ viewMenu.add(new CallHierarchyPreferencesAction()); >+ } >+ >+ >+} >Index: ui/org/eclipse/jdt/internal/ui/callhierarchy/CallHierarchyPreferencesConfigurationBlock.java >=================================================================== >RCS file: ui/org/eclipse/jdt/internal/ui/callhierarchy/CallHierarchyPreferencesConfigurationBlock.java >diff -N ui/org/eclipse/jdt/internal/ui/callhierarchy/CallHierarchyPreferencesConfigurationBlock.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ ui/org/eclipse/jdt/internal/ui/callhierarchy/CallHierarchyPreferencesConfigurationBlock.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,624 @@ >+/******************************************************************************* >+ * Copyright (c) 2009 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 >+ * >+ *******************************************************************************/ >+ >+package org.eclipse.jdt.internal.ui.callhierarchy; >+ >+import java.util.ArrayList; >+import java.util.Arrays; >+import java.util.List; >+ >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.events.SelectionAdapter; >+import org.eclipse.swt.events.SelectionEvent; >+import org.eclipse.swt.graphics.Image; >+import org.eclipse.swt.graphics.Point; >+import org.eclipse.swt.layout.GridData; >+import org.eclipse.swt.layout.GridLayout; >+import org.eclipse.swt.widgets.Button; >+import org.eclipse.swt.widgets.Composite; >+import org.eclipse.swt.widgets.Control; >+import org.eclipse.swt.widgets.Shell; >+import org.eclipse.swt.widgets.Text; >+ >+import org.eclipse.core.runtime.Assert; >+import org.eclipse.core.runtime.IStatus; >+ >+import org.eclipse.jface.dialogs.Dialog; >+import org.eclipse.jface.dialogs.StatusDialog; >+import org.eclipse.jface.layout.PixelConverter; >+import org.eclipse.jface.operation.IRunnableContext; >+import org.eclipse.jface.viewers.LabelProvider; >+import org.eclipse.jface.viewers.ViewerComparator; >+import org.eclipse.jface.window.Window; >+ >+import org.eclipse.ui.PlatformUI; >+import org.eclipse.ui.dialogs.SelectionDialog; >+import org.eclipse.ui.preferences.IWorkbenchPreferenceContainer; >+ >+import org.eclipse.jdt.core.IType; >+import org.eclipse.jdt.core.JavaConventions; >+import org.eclipse.jdt.core.JavaCore; >+import org.eclipse.jdt.core.JavaModelException; >+import org.eclipse.jdt.core.search.IJavaSearchScope; >+import org.eclipse.jdt.core.search.SearchEngine; >+ >+import org.eclipse.jdt.ui.IJavaElementSearchConstants; >+import org.eclipse.jdt.ui.JavaUI; >+import org.eclipse.jdt.ui.PreferenceConstants; >+ >+import org.eclipse.jdt.internal.ui.IJavaHelpContextIds; >+import org.eclipse.jdt.internal.ui.JavaPluginImages; >+import org.eclipse.jdt.internal.ui.dialogs.StatusInfo; >+import org.eclipse.jdt.internal.ui.dialogs.TextFieldNavigationHandler; >+import org.eclipse.jdt.internal.ui.preferences.OptionsConfigurationBlock; >+import org.eclipse.jdt.internal.ui.preferences.PreferencesMessages; >+import org.eclipse.jdt.internal.ui.preferences.ScrolledPageContent; >+import org.eclipse.jdt.internal.ui.util.BusyIndicatorRunnableContext; >+import org.eclipse.jdt.internal.ui.util.ExceptionHandler; >+import org.eclipse.jdt.internal.ui.viewsupport.BasicElementLabels; >+import org.eclipse.jdt.internal.ui.viewsupport.JavaElementImageProvider; >+import org.eclipse.jdt.internal.ui.wizards.IStatusChangeListener; >+import org.eclipse.jdt.internal.ui.wizards.dialogfields.DialogField; >+import org.eclipse.jdt.internal.ui.wizards.dialogfields.IDialogFieldListener; >+import org.eclipse.jdt.internal.ui.wizards.dialogfields.IListAdapter; >+import org.eclipse.jdt.internal.ui.wizards.dialogfields.IStringButtonAdapter; >+import org.eclipse.jdt.internal.ui.wizards.dialogfields.LayoutUtil; >+import org.eclipse.jdt.internal.ui.wizards.dialogfields.ListDialogField; >+import org.eclipse.jdt.internal.ui.wizards.dialogfields.StringButtonDialogField; >+ >+/** >+ * Call hierarchy preferences page configuration block. >+ * >+ * @since 3.6 >+ */ >+public class CallHierarchyPreferencesConfigurationBlock extends OptionsConfigurationBlock { >+ >+ /** >+ * Call hierarchy preferences dialog for types and members. >+ */ >+ private static class CallHierarchyPreferencesDialog extends StatusDialog { >+ >+ private class StringButtonAdapter implements IDialogFieldListener, IStringButtonAdapter { >+ /* >+ * @see IDialogFieldListener#dialogFieldChanged(DialogField) >+ */ >+ public void dialogFieldChanged(DialogField field) { >+ doValidation(); >+ } >+ >+ /* >+ * @see IStringButtonAdapter#changeControlPressed(DialogField) >+ */ >+ public void changeControlPressed(DialogField field) { >+ doBrowseTypes(); >+ } >+ } >+ >+ private StringButtonDialogField fNameDialogField; >+ >+ private List fExistingEntries; >+ >+ private final boolean fIsEditingMember; >+ >+ /** >+ * Creates a call hierarchy preference dialog for members or types. >+ * >+ * @param parent the parent shell >+ * @param existingEntries the existing list of types and members >+ * @param isEditingMember <code>true</code if its a member, <code>false</code> otherwise >+ */ >+ public CallHierarchyPreferencesDialog(Shell parent, List existingEntries, boolean isEditingMember) { >+ super(parent); >+ fIsEditingMember= isEditingMember; >+ fExistingEntries= existingEntries; >+ >+ String label, title; >+ if (isEditingMember) { >+ title= PreferencesMessages.CallHierarchyPreferencesDialog_member_title; >+ label= PreferencesMessages.CallHierarchyPreferencesDialog_member_labelText; >+ } else { >+ title= PreferencesMessages.CallHierarchyPreferencesDialog_type_title; >+ label= PreferencesMessages.CallHierarchyPreferencesDialog_type_labelText; >+ } >+ setTitle(title); >+ >+ StringButtonAdapter adapter= new StringButtonAdapter(); >+ >+ fNameDialogField= new StringButtonDialogField(adapter); >+ fNameDialogField.setLabelText(label); >+ fNameDialogField.setButtonLabel(PreferencesMessages.CallHierarchyPreferencesDialog_browse_button); >+ fNameDialogField.setDialogFieldListener(adapter); >+ fNameDialogField.setText(""); //$NON-NLS-1$ >+ } >+ >+ /* >+ * @see org.eclipse.jface.dialogs.Dialog#isResizable() >+ * @since 3.4 >+ */ >+ protected boolean isResizable() { >+ return true; >+ } >+ >+ /** >+ * Sets the initial selection in the name dialog field. >+ * >+ * @param editedEntry the edited entry >+ */ >+ public void setInitialSelection(String editedEntry) { >+ Assert.isNotNull(editedEntry); >+ if (editedEntry.length() == 0) >+ fNameDialogField.setText(""); //$NON-NLS-1$ >+ else >+ fNameDialogField.setText(editedEntry); >+ } >+ >+ public String getResult() { >+ String val= fNameDialogField.getText(); >+ if (!fIsEditingMember) >+ val= val + WILDCARD; >+ return val; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite) >+ */ >+ protected Control createDialogArea(Composite parent) { >+ Composite composite= (Composite)super.createDialogArea(parent); >+ initializeDialogUnits(parent); >+ >+ GridLayout layout= (GridLayout)composite.getLayout(); >+ layout.numColumns= 2; >+ >+ fNameDialogField.doFillIntoGrid(composite, 3); >+ >+ fNameDialogField.getChangeControl(null).setVisible(!fIsEditingMember); >+ >+ LayoutUtil.setHorizontalSpan(fNameDialogField.getLabelControl(null), 2); >+ >+ int fieldWidthHint= convertWidthInCharsToPixels(60); >+ Text text= fNameDialogField.getTextControl(null); >+ LayoutUtil.setWidthHint(text, fieldWidthHint); >+ LayoutUtil.setHorizontalGrabbing(text); >+ LayoutUtil.setHorizontalSpan(text, fIsEditingMember ? 2 : 1); >+ TextFieldNavigationHandler.install(text); >+ >+ DialogField.createEmptySpace(composite, 1); >+ >+ fNameDialogField.postSetFocusOnDialogField(parent.getDisplay()); >+ >+ applyDialogFont(composite); >+ return composite; >+ } >+ >+ /** >+ * Creates the type hierarchy for type selection. >+ */ >+ private void doBrowseTypes() { >+ IRunnableContext context= new BusyIndicatorRunnableContext(); >+ IJavaSearchScope scope= SearchEngine.createWorkspaceScope(); >+ int style= IJavaElementSearchConstants.CONSIDER_ALL_TYPES; >+ try { >+ SelectionDialog dialog= JavaUI.createTypeDialog(getShell(), context, scope, style, false, fNameDialogField.getText()); >+ dialog.setTitle(PreferencesMessages.CallHierarchyPreferencesDialog_ChooseTypeDialog_title); >+ dialog.setMessage(PreferencesMessages.CallHierarchyPreferencesDialog_ChooseTypeDialog_description); >+ if (dialog.open() == Window.OK) { >+ IType res= (IType)dialog.getResult()[0]; >+ fNameDialogField.setText(res.getFullyQualifiedName('.')); >+ } >+ } catch (JavaModelException e) { >+ ExceptionHandler.handle(e, getShell(), PreferencesMessages.CallHierarchyPreferencesDialog_ChooseTypeDialog_title, >+ PreferencesMessages.CallHierarchyPreferencesDialog_ChooseTypeDialog_error_message); >+ } >+ } >+ >+ /** >+ * Validates the entered type or member and updates the status. >+ */ >+ private void doValidation() { >+ StatusInfo status= new StatusInfo(); >+ String newText= fNameDialogField.getText(); >+ if (newText.length() == 0) { >+ status.setError(""); //$NON-NLS-1$ >+ } else { >+ IStatus val= JavaConventions.validateJavaTypeName(newText, JavaCore.VERSION_1_3, JavaCore.VERSION_1_3); >+ if (val.matches(IStatus.ERROR)) { >+ if (fIsEditingMember) >+ status.setError(PreferencesMessages.CallHierarchyPreferencesDialog_error_invalidMemberName); >+ else >+ status.setError(PreferencesMessages.CallHierarchyPreferencesDialog_error_invalidTypeName); >+ } else { >+ if (doesExist(newText)) { >+ status.setError(PreferencesMessages.CallHierarchyPreferencesDialog_error_entryExists); >+ } >+ } >+ } >+ updateStatus(status); >+ } >+ >+ /** >+ * Checks if the entry already exists. >+ * >+ * @param name the type or member name >+ * @return <code>true</code> if it already exists in the list of types and members, >+ * <code>false</code> otherwise >+ */ >+ private boolean doesExist(String name) { >+ for (int i= 0; i < fExistingEntries.size(); i++) { >+ String entry= (String)fExistingEntries.get(i); >+ if (name.equals(entry)) { >+ return true; >+ } >+ } >+ return false; >+ } >+ >+ >+ /* >+ * @see org.eclipse.jface.window.Window#configureShell(Shell) >+ */ >+ protected void configureShell(Shell newShell) { >+ super.configureShell(newShell); >+ PlatformUI.getWorkbench().getHelpSystem().setHelp(newShell, IJavaHelpContextIds.JAVA_EDITOR_PREFERENCE_PAGE); >+ } >+ >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jdt.internal.ui.preferences.OptionsConfigurationBlock#performOk() >+ */ >+ public boolean performOk() { >+ PreferenceConstants.getPreferenceStore().setValue(CallHierarchyContentProvider.PREF_ANONYMOUS_EXPAND_WITH_CONSTRUCTORS, fIsAnonymous); >+ return super.performOk(); >+ } >+ >+ /** >+ * The list label provider class. >+ */ >+ private static class ListLabelProvider extends LabelProvider { >+ >+ public final Image MEMBER_ICON; >+ >+ private final Image CLASS_ICON; >+ >+ public ListLabelProvider() { >+ MEMBER_ICON= JavaElementImageProvider.getDecoratedImage(JavaPluginImages.DESC_MISC_PUBLIC, 0, JavaElementImageProvider.SMALL_SIZE); >+ CLASS_ICON= JavaElementImageProvider.getDecoratedImage(JavaPluginImages.DESC_OBJS_CLASS, 0, JavaElementImageProvider.SMALL_SIZE); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.viewers.LabelProvider#getImage(java.lang.Object) >+ */ >+ public Image getImage(Object element) { >+ return ((String)element).endsWith(WILDCARD) ? CLASS_ICON : MEMBER_ICON; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.viewers.LabelProvider#getText(java.lang.Object) >+ */ >+ public String getText(Object element) { >+ return BasicElementLabels.getJavaElementName((String)element); >+ } >+ } >+ >+ >+ /** >+ * The change listener for <code>ListDialogField</code>. >+ */ >+ private class ListAdapter implements IListAdapter, IDialogFieldListener { >+ >+ /** >+ * Checks if field can be edited. >+ * >+ * @param field the list dialog field >+ * @return <code>true</code> if it can be edited, <code>false</code> otherwise >+ */ >+ private boolean canEdit(ListDialogField field) { >+ List selected= field.getSelectedElements(); >+ return selected.size() == 1 && canRemove(field); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jdt.internal.ui.wizards.dialogfields.IListAdapter#customButtonPressed(org.eclipse.jdt.internal.ui.wizards.dialogfields.ListDialogField, int) >+ */ >+ public void customButtonPressed(ListDialogField field, int index) { >+ doButtonPressed(index); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jdt.internal.ui.wizards.dialogfields.IListAdapter#selectionChanged(org.eclipse.jdt.internal.ui.wizards.dialogfields.ListDialogField) >+ */ >+ public void selectionChanged(ListDialogField field) { >+ fList.enableButton(IDX_EDIT, canEdit(field)); >+ fList.enableButton(IDX_REMOVE, canRemove(field)); >+ } >+ >+ /** >+ * Checks if the field can be removed. >+ * >+ * @param field the list dialog field >+ * @return <code>true</code> if it can be removed, <code>false</code> otherwise >+ */ >+ private boolean canRemove(ListDialogField field) { >+ List selected= field.getSelectedElements(); >+ for (int j= 0; j < defaultTypes.length; j++) { >+ if (selected.contains(defaultTypes[j])) >+ return false; >+ } >+ return true; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jdt.internal.ui.wizards.dialogfields.IDialogFieldListener#dialogFieldChanged(org.eclipse.jdt.internal.ui.wizards.dialogfields.DialogField) >+ */ >+ public void dialogFieldChanged(DialogField field) { >+ doDialogFieldChanged(field); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jdt.internal.ui.wizards.dialogfields.IListAdapter#doubleClicked(org.eclipse.jdt.internal.ui.wizards.dialogfields.ListDialogField) >+ */ >+ public void doubleClicked(ListDialogField field) { >+ if (canEdit(field)) { >+ doButtonPressed(IDX_EDIT); >+ } >+ } >+ } >+ >+ /** >+ * A named preference key that holds the types whose methods are by default expanded with >+ * constructors in the Call Hierarchy. >+ * >+ * @since 3.6 >+ */ >+ public static final Key CALL_HIERARCHY_PREFERENCES= getJDTUIKey(PreferenceConstants.CALL_HIERARCHY_PREFERENCES); >+ >+ private static final String WILDCARD= ".*"; //$NON-NLS-1$ >+ >+ private static final int IDX_NEW_TYPE= 0; >+ private static final int IDX_NEW_MEMBER= 1; >+ private static final int IDX_EDIT= 2; >+ private static final int IDX_REMOVE= 3; >+ >+ private ListDialogField fList; >+ >+ /** >+ * The array of types for default expand with constructors. >+ */ >+ String[] defaultTypes= { "java.lang.Runnable.*", "java.util.concurrent.Callable.*", "org.eclipse.swt.widgets.Listener.*" }; //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$ >+ >+ private Button fAnonymousButton; >+ >+ protected boolean fIsAnonymous; >+ >+ /** >+ * Returns all the key values. >+ * >+ * @return array of keys >+ */ >+ public static Key[] getAllKeys() { >+ return new Key[] { CALL_HIERARCHY_PREFERENCES }; >+ } >+ >+ >+ /** >+ * Creates the call hierarchy preferences configuration block. >+ * >+ * @param context the status >+ * @param container the preference container >+ */ >+ public CallHierarchyPreferencesConfigurationBlock(IStatusChangeListener context, IWorkbenchPreferenceContainer container) { >+ super(context, null, getAllKeys(), container); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jdt.internal.ui.preferences.OptionsConfigurationBlock#createContents(org.eclipse.swt.widgets.Composite) >+ */ >+ protected Control createContents(Composite parent) { >+ ScrolledPageContent scrolled= new ScrolledPageContent(parent, SWT.H_SCROLL | SWT.V_SCROLL); >+ scrolled.setExpandHorizontal(true); >+ scrolled.setExpandVertical(true); >+ >+ Composite control= new Composite(scrolled, SWT.NONE); >+ GridLayout layout= new GridLayout(); >+ layout.numColumns= 2; >+ layout.marginWidth= 0; >+ layout.marginHeight= 0; >+ control.setLayout(layout); >+ >+ createPreferenceList(control); >+ >+ fAnonymousButton= new Button(parent, SWT.CHECK); >+ fAnonymousButton.setText(CallHierarchyMessages.CallHierarchyPreferenceDialog_anonymousTypes_label); >+ boolean anonymousPref= PreferenceConstants.getPreferenceStore().getBoolean(CallHierarchyContentProvider.PREF_ANONYMOUS_EXPAND_WITH_CONSTRUCTORS); >+ fAnonymousButton.setSelection(anonymousPref); >+ fAnonymousButton.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false)); >+ fAnonymousButton.addSelectionListener(new SelectionAdapter() { >+ public void widgetSelected(SelectionEvent e) { >+ fIsAnonymous= fAnonymousButton.getSelection(); >+ >+ } >+ >+ }); >+ >+ initialize(); >+ >+ scrolled.setContent(control); >+ final Point size= control.computeSize(SWT.DEFAULT, SWT.DEFAULT); >+ scrolled.setMinSize(size.x, size.y); >+ >+ Dialog.applyDialogFont(scrolled); >+ >+ return scrolled; >+ } >+ >+ /** >+ * Create a list dialog field. >+ * >+ * @param parent the composite >+ */ >+ private void createPreferenceList(Composite parent) { >+ String[] buttonLabels= new String[] { >+ PreferencesMessages.CallHierarchyPreferencesConfigurationBlock_newType_button, >+ PreferencesMessages.CallHierarchyPreferencesConfigurationBlock_newMember_button, >+ PreferencesMessages.CallHierarchyPreferencesConfigurationBlock_edit_button, >+ PreferencesMessages.CallHierarchyPreferencesConfigurationBlock_remove_button >+ }; >+ >+ ListAdapter adapter= new ListAdapter(); >+ >+ fList= new ListDialogField(adapter, buttonLabels, new ListLabelProvider()); >+ fList.setDialogFieldListener(adapter); >+ fList.setLabelText(PreferencesMessages.CallHierarchyPreferencesConfigurationBlock_description); >+ fList.setRemoveButtonIndex(IDX_REMOVE); >+ fList.enableButton(IDX_EDIT, false); >+ fList.setViewerComparator(new ViewerComparator()); >+ >+ PixelConverter pixelConverter= new PixelConverter(parent); >+ >+ fList.doFillIntoGrid(parent, 3); >+ LayoutUtil.setHorizontalSpan(fList.getLabelControl(null), 2); >+ LayoutUtil.setWidthHint(fList.getLabelControl(null), pixelConverter.convertWidthInCharsToPixels(60)); >+ LayoutUtil.setHorizontalGrabbing(fList.getListControl(null)); >+ >+ Control listControl= fList.getListControl(null); >+ GridData gd= (GridData)listControl.getLayoutData(); >+ gd.verticalAlignment= GridData.BEGINNING; >+ gd.heightHint= pixelConverter.convertHeightInCharsToPixels(7); >+ >+ } >+ >+ /** >+ * Initialize the elements of the list dialog field. >+ */ >+ public void initialize() { >+ initializeFields(); >+ } >+ >+ /** >+ * Initialize the elements of the list dialog field. >+ */ >+ private void initializeFields() { >+ List storedPreference= new ArrayList(); >+ storedPreference.addAll(Arrays.asList(getCallHierarchyPreferences())); >+ if (!storedPreference.contains(defaultTypes[0])) { >+ storedPreference.addAll(Arrays.asList(defaultTypes)); >+ } >+ fList.setElements(storedPreference); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jdt.internal.ui.preferences.OptionsConfigurationBlock#performDefaults() >+ */ >+ public void performDefaults() { >+ super.performDefaults(); >+ fList.setElements(Arrays.asList(defaultTypes)); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jdt.internal.ui.preferences.OptionsConfigurationBlock#getFullBuildDialogStrings(boolean) >+ */ >+ protected String[] getFullBuildDialogStrings(boolean workspaceSettings) { >+ return null; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jdt.internal.ui.preferences.OptionsConfigurationBlock#validateSettings(org.eclipse.jdt.internal.ui.preferences.OptionsConfigurationBlock.Key, java.lang.String, java.lang.String) >+ */ >+ protected void validateSettings(Key changedKey, String oldValue, String newValue) { >+ >+ } >+ >+ /** >+ * Perform the 'New' and 'Edit' button operations by opening the respective call hierarchy >+ * preferences dialog. >+ * >+ * @param index the index of the button >+ */ >+ private void doButtonPressed(int index) { >+ if (index == IDX_NEW_TYPE || index == IDX_NEW_MEMBER) { // add new >+ List existing= fList.getElements(); >+ CallHierarchyPreferencesDialog dialog= new CallHierarchyPreferencesDialog(getShell(), existing, index == IDX_NEW_MEMBER); >+ if (dialog.open() == Window.OK) { >+ fList.addElement(dialog.getResult()); >+ } >+ } else if (index == IDX_EDIT) { // edit >+ List selected= fList.getSelectedElements(); >+ if (selected.isEmpty()) >+ return; >+ >+ String editedEntry= (String)selected.get(0); >+ >+ List existing= fList.getElements(); >+ existing.remove(editedEntry); >+ boolean isType= editedEntry.endsWith(WILDCARD); >+ CallHierarchyPreferencesDialog dialog= new CallHierarchyPreferencesDialog(getShell(), existing, !isType); >+ if (isType) >+ dialog.setInitialSelection(editedEntry.substring(0, editedEntry.length() - 2)); >+ else >+ dialog.setInitialSelection(editedEntry); >+ >+ if (dialog.open() == Window.OK) { >+ fList.replaceElement(editedEntry, dialog.getResult()); >+ } >+ } >+ } >+ >+ /** >+ * Update the preference keys and constants. >+ * >+ * @param field the dialog field >+ */ >+ protected final void doDialogFieldChanged(DialogField field) { >+ // set values in working copy >+ if (field == fList) { >+ setValue(CALL_HIERARCHY_PREFERENCES, serializeFavorites(fList.getElements())); >+ PreferenceConstants.getPreferenceStore().setValue(CallHierarchyContentProvider.CALL_HIERARCHY_PREFERENCES, serializeFavorites(fList.getElements())); >+ } >+ } >+ >+ /** >+ * Returns the call hierarchy preferences. >+ * >+ * @return the call hierarchy preferences >+ */ >+ private String[] getCallHierarchyPreferences() { >+ String str= getValue(CALL_HIERARCHY_PREFERENCES); >+ if (str != null && str.length() > 0) >+ return deserializeFavorites(str); >+ return new String[0]; >+ } >+ >+ /** >+ * Return the array of types and/or members after splitting the stored preference string. >+ * >+ * @param str the input string >+ * @return the array of types and/or members >+ */ >+ private static String[] deserializeFavorites(String str) { >+ return str.split(";"); //$NON-NLS-1$ >+ } >+ >+ /** >+ * Creates a single output string from the list of strings using a delimiter. >+ * >+ * @param str the input string >+ * @return the single output string from the list of strings using a delimiter >+ */ >+ private static String serializeFavorites(List str) { >+ int size= str.size(); >+ StringBuffer buf= new StringBuffer(); >+ for (int i= 0; i < size; i++) { >+ buf.append((String)str.get(i)); >+ if (i < size - 1) >+ buf.append(';'); >+ } >+ return buf.toString(); >+ } >+ >+} >Index: ui/org/eclipse/jdt/internal/ui/callhierarchy/CallHierarchyPreferencePage.java >=================================================================== >RCS file: ui/org/eclipse/jdt/internal/ui/callhierarchy/CallHierarchyPreferencePage.java >diff -N ui/org/eclipse/jdt/internal/ui/callhierarchy/CallHierarchyPreferencePage.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ ui/org/eclipse/jdt/internal/ui/callhierarchy/CallHierarchyPreferencePage.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,119 @@ >+/******************************************************************************* >+ * Copyright (c) 2009 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 >+ * >+ *******************************************************************************/ >+ >+package org.eclipse.jdt.internal.ui.callhierarchy; >+ >+import org.eclipse.swt.widgets.Composite; >+import org.eclipse.swt.widgets.Control; >+ >+import org.eclipse.core.resources.IProject; >+ >+import org.eclipse.jdt.internal.ui.preferences.PropertyAndPreferencePage; >+ >+/** >+ * Call Hierarchy view menu preference page. >+ * >+ * @since 3.6 >+ * >+ */ >+public class CallHierarchyPreferencePage extends PropertyAndPreferencePage { >+ >+ private CallHierarchyPreferencesConfigurationBlock fConfigurationBlock; >+ >+ /** >+ * Creates a call hierarchy preference page and sets the title. >+ */ >+ public CallHierarchyPreferencePage() { >+ super(); >+ setTitle(CallHierarchyMessages.CallHierarchyPreferencePage_expand_with_constructors_title); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.preference.PreferencePage#createControl(org.eclipse.swt.widgets.Composite) >+ */ >+ public void createControl(Composite parent) { >+ //IWorkbenchPreferenceContainer container= (IWorkbenchPreferenceContainer)getContainer(); >+ fConfigurationBlock= new CallHierarchyPreferencesConfigurationBlock(getNewStatusChangedListener(), null); >+ super.createControl(parent); >+ //PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), IJavaHelpContextIds.JAVA_EDITOR_PREFERENCE_PAGE); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jdt.internal.ui.preferences.PropertyAndPreferencePage#createPreferenceContent(org.eclipse.swt.widgets.Composite) >+ */ >+ protected Control createPreferenceContent(Composite composite) { >+ return fConfigurationBlock.createContents(composite); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jdt.internal.ui.preferences.PropertyAndPreferencePage#getPreferencePageID() >+ */ >+ protected String getPreferencePageID() { >+ return "org.eclipse.jdt.ui.preferences.CallHierarchyPreferencePage"; //$NON-NLS-1$ >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jdt.internal.ui.preferences.PropertyAndPreferencePage#getPropertyPageID() >+ */ >+ protected String getPropertyPageID() { >+ return null; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jdt.internal.ui.preferences.PropertyAndPreferencePage#hasProjectSpecificOptions(org.eclipse.core.resources.IProject) >+ */ >+ protected boolean hasProjectSpecificOptions(IProject project) { >+ return false; >+ } >+ >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.dialogs.DialogPage#dispose() >+ */ >+ public void dispose() { >+ if (fConfigurationBlock != null) { >+ fConfigurationBlock.dispose(); >+ } >+ super.dispose(); >+ } >+ >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jdt.internal.ui.preferences.PropertyAndPreferencePage#performDefaults() >+ */ >+ protected void performDefaults() { >+ super.performDefaults(); >+ if (fConfigurationBlock != null) { >+ fConfigurationBlock.performDefaults(); >+ } >+ } >+ >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.preference.PreferencePage#performOk() >+ */ >+ public boolean performOk() { >+ if (fConfigurationBlock != null && !fConfigurationBlock.performOk()) { >+ return false; >+ } >+ return super.performOk(); >+ } >+ >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.preference.PreferencePage#performApply() >+ */ >+ public void performApply() { >+ if (fConfigurationBlock != null) { >+ fConfigurationBlock.performApply(); >+ } >+ } >+ >+ >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Flags:
markus.kell.r
:
review-
Actions:
View
|
Diff
Attachments on
bug 276466
:
135958
|
144529
|
146514
|
147082
|
149404
|
151152
|
151933