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 147082 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]
Updated Patch
patch5_276466.txt (text/plain), 48.19 KB, created by
Raksha Vasisht
on 2009-09-14 04:58:29 EDT
(
hide
)
Description:
Updated Patch
Filename:
MIME Type:
Creator:
Raksha Vasisht
Created:
2009-09-14 04:58:29 EDT
Size:
48.19 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 Sep 2009 08:45:27 -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; >@@ -88,6 +87,25 @@ > public static String CallHierarchyViewPart_callsFromMembers_3; > public static String CallHierarchyViewPart_callsFromMembers_more; > public static String CallHierarchyViewPart_callsFromMethod; >+ public static String ExpandWithConstructorsConfigurationBlock_description; >+ public static String ExpandWithConstructorsConfigurationBlock_newType_button; >+ public static String ExpandWithConstructorsConfigurationBlock_newMember_button; >+ public static String ExpandWithConstructorsConfigurationBlock_edit_button; >+ public static String ExpandWithConstructorsConfigurationBlock_remove_button; >+ public static String ExpandWithConstructorsConfigurationBlock_restoreDefaults_button; >+ public static String CallHierarchyTypesOrMembersDialog_member_title; >+ public static String CallHierarchyTypesOrMembersDialog_member_labelText; >+ public static String CallHierarchyTypesOrMembersDialog_type_title; >+ public static String CallHierarchyTypesOrMembersDialog_type_labelText; >+ public static String CallHierarchyTypesOrMembersDialog_browse_button; >+ public static String CallHierarchyTypesOrMembersDialog_ChooseTypeDialog_title; >+ public static String CallHierarchyTypesOrMembersDialog_ChooseTypeDialog_description; >+ public static String CallHierarchyTypesOrMembersDialog_ChooseTypeDialog_error_message; >+ public static String CallHierarchyTypesOrMembersDialog_error_enterName; >+ public static String CallHierarchyTypesOrMembersDialog_error_invalidMemberName; >+ public static String CallHierarchyTypesOrMembersDialog_error_invalidTypeName; >+ public static String CallHierarchyTypesOrMembersDialog_error_entryExists; >+ public static String CallHierarchyTypesOrMembersDialog_anonymousTypes_label; > public static String FocusOnSelectionAction_focusOnSelection_text; > public static String FocusOnSelectionAction_focusOnSelection_description; > public static String FocusOnSelectionAction_focusOnSelection_tooltip; >@@ -139,11 +157,8 @@ > 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 ExpandWithConstructorsDialogAction_expandWithConstructors_label; > public static String ExpandWithConstructorsDialog_title; >- public static String ExpandWithConstructorsDialog_typeNames_label; > static { > NLS.initializeMessages(BUNDLE_NAME, CallHierarchyMessages.class); > } >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.47 >diff -u -r1.47 CallHierarchyMessages.properties >--- ui/org/eclipse/jdt/internal/ui/callhierarchy/CallHierarchyMessages.properties 17 Aug 2009 15:28:36 -0000 1.47 >+++ ui/org/eclipse/jdt/internal/ui/callhierarchy/CallHierarchyMessages.properties 14 Sep 2009 08:45:27 -0000 >@@ -55,7 +55,6 @@ > ToggleOrientationAction_single_tooltip=Hierarchy Only > ToggleOrientationAction_single_description=Hierarchy Only > >-ShowExpandWithConstructorsDialogAction_text=E&xpand with Constructors... > ShowFilterDialogAction_text= &Filters... > FiltersDialog_filter= Filter Calls > FiltersDialog_filterOnNames= &Name filter patterns (matching names will be hidden): >@@ -146,8 +145,27 @@ > 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): >+ExpandWithConstructorsDialogAction_expandWithConstructors_label= E&xpand with Constructors... >+ExpandWithConstructorsDialog_title= Expand with Constructors >+ >+ExpandWithConstructorsConfigurationBlock_description= De&fine a list of members or types with their fully qualified names. The call hierarchy for these members or members of the types will be expanded with constructors by default. >+ExpandWithConstructorsConfigurationBlock_newType_button= New &Type... >+ExpandWithConstructorsConfigurationBlock_newMember_button= New &Member... >+ExpandWithConstructorsConfigurationBlock_edit_button= &Edit... >+ExpandWithConstructorsConfigurationBlock_remove_button= &Remove >+ExpandWithConstructorsConfigurationBlock_restoreDefaults_button= Restore &Defaults >+ >+CallHierarchyTypesOrMembersDialog_member_title= New Member for Expand With Constructors >+CallHierarchyTypesOrMembersDialog_member_labelText= Enter a fully qualified non-static, non-constructor member (e.g. \'java.lang.Runnable.run\'): >+CallHierarchyTypesOrMembersDialog_type_title= New Type for Expand With Constructors >+CallHierarchyTypesOrMembersDialog_type_labelText= Enter a fully qualified type (e.g. \'java.lang.Runnable\'): >+CallHierarchyTypesOrMembersDialog_browse_button= &Browse... >+CallHierarchyTypesOrMembersDialog_ChooseTypeDialog_title= Type Selection >+CallHierarchyTypesOrMembersDialog_ChooseTypeDialog_description= Choose type name: >+CallHierarchyTypesOrMembersDialog_ChooseTypeDialog_error_message= A problem occurred while collecting types. See the error Log for details. >+CallHierarchyTypesOrMembersDialog_error_enterName=Enter a name or prefix. >+CallHierarchyTypesOrMembersDialog_error_invalidTypeName=Not a valid type name. >+CallHierarchyTypesOrMembersDialog_error_invalidMemberName=Not a valid member name. >+CallHierarchyTypesOrMembersDialog_error_entryExists=Entry already exists in list. >+CallHierarchyTypesOrMembersDialog_anonymousTypes_label=&All methods in anonymous types >+ >Index: ui/org/eclipse/jdt/internal/ui/callhierarchy/ExpandWithConstructorsDialog.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/callhierarchy/ExpandWithConstructorsDialog.java,v >retrieving revision 1.2 >diff -u -r1.2 ExpandWithConstructorsDialog.java >--- ui/org/eclipse/jdt/internal/ui/callhierarchy/ExpandWithConstructorsDialog.java 28 May 2009 13:05:43 -0000 1.2 >+++ ui/org/eclipse/jdt/internal/ui/callhierarchy/ExpandWithConstructorsDialog.java 14 Sep 2009 08:45:28 -0000 >@@ -10,32 +10,20 @@ > *******************************************************************************/ > 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.Dialog; > 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; >+import org.eclipse.jdt.internal.ui.wizards.IStatusChangeListener; > > /** > * Configuration dialog for default "Expand with Constructors" behavior. >@@ -44,11 +32,9 @@ > */ > class ExpandWithConstructorsDialog extends StatusDialog { > >- private static final String LINE_DELIMITER_REGEX= "\\r\\n?|\\n"; //$NON-NLS-1$ >+ private Control fConfigurationBlockControl; >+ private ExpandWithConstructorsConfigurationBlock fConfigurationBlock; > >- private Button fAnonymousButton; >- private StyledText fDefaultTypesText; >- > protected ExpandWithConstructorsDialog(Shell parentShell) { > super(parentShell); > } >@@ -66,49 +52,24 @@ > 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(); >+ protected Control createDialogArea(Composite composite) { >+ fConfigurationBlock= new ExpandWithConstructorsConfigurationBlock(new IStatusChangeListener() { >+ public void statusChanged(IStatus status) { >+ //Do nothing >+ > } >- }); >- >- >- 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)); >- >+ }, null); >+ GridData data= new GridData(GridData.FILL, GridData.FILL, true, true); >+ fConfigurationBlockControl= fConfigurationBlock.createContents(composite); >+ fConfigurationBlockControl.setLayoutData(data); >+ >+ Dialog.applyDialogFont(composite); > return composite; > } > >@@ -116,31 +77,7 @@ > * @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); >- >+ fConfigurationBlock.performOk(); > 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/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 Sep 2009 08:45:26 -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 Sep 2009 08:45:28 -0000 >@@ -237,6 +237,7 @@ > private boolean fShowCallDetails; > protected Composite fParent; > private IPartListener2 fPartListener; >+ private ExpandWithConstructorsActionGroup fExpandWithConstructorsActionGroup; > > > public CallHierarchyViewPart() { >@@ -1007,6 +1008,7 @@ > fSearchScopeActions = new SearchScopeActionGroup(this, fDialogSettings); > fFiltersActionGroup = new CallHierarchyFiltersActionGroup(this, > fCallHierarchyViewer); >+ fExpandWithConstructorsActionGroup= new ExpandWithConstructorsActionGroup(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, fExpandWithConstructorsActionGroup > }); > } > >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 Sep 2009 08:45:26 -0000 >@@ -45,10 +45,10 @@ > public class CallHierarchyContentProvider implements ITreeContentProvider { > > /** >- * A named preference that holds the types whose methods are by default expanded with >+ * A named preference that holds the methods or types whose methods are by default expanded with > * constructors in the Call Hierarchy. > * <p> >- * Value is of type <code>String</code>: semicolon separated list of fully qualified type names. >+ * Value is of type <code>String</code>: semicolon separated list of fully qualified type or method names. > * </p> > * > * @since 3.5 >@@ -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,37 +217,41 @@ > } > > /** >- * 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 >+ * @param wrapper caller method wrapper >+ * @return <code>true</code> if method or type matches the pre-defined list, <code>false</code> otherwise > * @since 3.5 > */ >- static boolean isInTheDefaultExpandWithConstructorList(IType type) { >- String serializedTypes= PreferenceConstants.getPreferenceStore().getString(PREF_DEFAULT_EXPAND_WITH_CONSTRUCTORS); >- if (serializedTypes.length() == 0) >+ static boolean isInTheDefaultExpandWithConstructorList(CallerMethodWrapper wrapper) { >+ String serializedTypesAndMembers= PreferenceConstants.getPreferenceStore().getString(PREF_DEFAULT_EXPAND_WITH_CONSTRUCTORS); >+ if (serializedTypesAndMembers.length() == 0) > return false; >- >- String[] defaultTypes= serializedTypes.split(";"); //$NON-NLS-1$ >- >- String typeName= type.getFullyQualifiedName('.'); >+ String member= wrapper.getMember().getElementName(); >+ IType declaringType= wrapper.getMember().getDeclaringType(); >+ String[] defaultTypesOrMembers= serializedTypesAndMembers.split(";"); //$NON-NLS-1$ >+ >+ String declaringTypeName= declaringType.getFullyQualifiedName('.').concat(".*"); //$NON-NLS-1$; >+ String qualifiedMemberName= declaringType.getFullyQualifiedName('.').concat(".").concat(member); //$NON-NLS-1$ > String superClass; > String[] superInterfaces; > try { >- superClass= type.getSuperclassName(); >- superInterfaces= type.getSuperInterfaceNames(); >+ superClass= declaringType.getSuperclassName(); >+ superInterfaces= declaringType.getSuperInterfaceNames(); > } catch (JavaModelException e) { > return false; > } >- for (int i= 0; i < defaultTypes.length; i++) { >- String defaultType= defaultTypes[i]; >- if (typeName.equals(defaultType) || (superClass != null && typeNameMatches(superClass, defaultType))) { >+ for (int i= 0; i < defaultTypesOrMembers.length; i++) { >+ String defaultTypeOrMember= defaultTypesOrMembers[i]; >+ if (qualifiedMemberName.equals(defaultTypeOrMember) || declaringTypeName.equals(defaultTypeOrMember) >+ || (typeNameMatches(member, defaultTypeOrMember) && superClass != null && defaultTypeOrMember.endsWith(superClass.concat(".").concat(member))) //$NON-NLS-1$ >+ || checkSuperClassMatch(superClass, defaultTypeOrMember)) { > return true; > } > if (superInterfaces.length > 0) { > for (int j= 0; j < superInterfaces.length; j++) { >- if (typeNameMatches(superInterfaces[j], defaultType)) >+ if (typeNameMatches(superInterfaces[j].concat(".*"), defaultTypeOrMember)) //$NON-NLS-1$ > return true; > } > } >@@ -256,6 +260,22 @@ > } > > /** >+ * Check whether the given super class name matches the given default type. >+ * >+ * @param superClass the super class name >+ * @param defaultTypeOrMember the default type or member from the default list >+ * >+ * @return <code>true</code> if super class matches with the given type , <code>false></code> otherwise >+ * @since 3.6 >+ */ >+ private static boolean checkSuperClassMatch(String superClass, String defaultTypeOrMember) { >+ if (defaultTypeOrMember.endsWith(".*")){ //$NON-NLS-1$ >+ defaultTypeOrMember= defaultTypeOrMember.substring(0, defaultTypeOrMember.length() - 2); >+ } >+ return (superClass != null && typeNameMatches(superClass, defaultTypeOrMember)); >+ } >+ >+ /** > * Checks whether the two type names match. They match if they > * are equal, or if could be the same type but one is missing the package. > * >Index: ui/org/eclipse/jdt/internal/ui/callhierarchy/ExpandWithConstructorsConfigurationBlock.java >=================================================================== >RCS file: ui/org/eclipse/jdt/internal/ui/callhierarchy/ExpandWithConstructorsConfigurationBlock.java >diff -N ui/org/eclipse/jdt/internal/ui/callhierarchy/ExpandWithConstructorsConfigurationBlock.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ ui/org/eclipse/jdt/internal/ui/callhierarchy/ExpandWithConstructorsConfigurationBlock.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,626 @@ >+/******************************************************************************* >+ * 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.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.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 expand with constructors configuration block. >+ * >+ * @since 3.6 >+ */ >+public class ExpandWithConstructorsConfigurationBlock extends OptionsConfigurationBlock { >+ >+ /** >+ * Call hierarchy expand with constructors dialog for types and members. >+ */ >+ private static class CallHierarchyTypesOrMembersDialog extends StatusDialog { >+ >+ /** >+ * The change listener class for the dialog field and the string button dialog field. >+ * >+ */ >+ 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(); >+ } >+ } >+ >+ /** >+ * The name dialog field to hold the default expand with constructors list. >+ */ >+ private StringButtonDialogField fNameDialogField; >+ >+ /** >+ * The list of previously existing entries. >+ */ >+ private List fExistingEntries; >+ >+ /** >+ * Tells whether it is an member or type. >+ */ >+ 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 CallHierarchyTypesOrMembersDialog(Shell parent, List existingEntries, boolean isEditingMember) { >+ super(parent); >+ fIsEditingMember= isEditingMember; >+ fExistingEntries= existingEntries; >+ >+ String label, title; >+ if (isEditingMember) { >+ title= CallHierarchyMessages.CallHierarchyTypesOrMembersDialog_member_title; >+ label= CallHierarchyMessages.CallHierarchyTypesOrMembersDialog_member_labelText; >+ } else { >+ title= CallHierarchyMessages.CallHierarchyTypesOrMembersDialog_type_title; >+ label= CallHierarchyMessages.CallHierarchyTypesOrMembersDialog_type_labelText; >+ } >+ setTitle(title); >+ >+ StringButtonAdapter adapter= new StringButtonAdapter(); >+ >+ fNameDialogField= new StringButtonDialogField(adapter); >+ fNameDialogField.setLabelText(label); >+ fNameDialogField.setButtonLabel(CallHierarchyMessages.CallHierarchyTypesOrMembersDialog_browse_button); >+ fNameDialogField.setDialogFieldListener(adapter); >+ fNameDialogField.setText(""); //$NON-NLS-1$ >+ } >+ >+ /* >+ * @see org.eclipse.jface.dialogs.Dialog#isResizable() * >+ */ >+ 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); >+ } >+ >+ /** >+ * Returns the resulting text from the name dialog field. >+ * >+ * @return the resulting text from the name dialog field >+ */ >+ public String getResult() { >+ String val= fNameDialogField.getText(); >+ if (!fIsEditingMember) >+ val= val + WILDCARD; >+ return val; >+ } >+ >+ /* >+ * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite) >+ */ >+ protected Control createDialogArea(Composite parent) { >+ Composite composite= (Composite)super.createDialogArea(parent); >+ initializeDialogUnits(composite); >+ >+ 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(CallHierarchyMessages.CallHierarchyTypesOrMembersDialog_ChooseTypeDialog_title); >+ dialog.setMessage(CallHierarchyMessages.CallHierarchyTypesOrMembersDialog_ChooseTypeDialog_description); >+ if (dialog.open() == Window.OK) { >+ IType res= (IType)dialog.getResult()[0]; >+ fNameDialogField.setText(res.getFullyQualifiedName('.')); >+ } >+ } catch (JavaModelException e) { >+ ExceptionHandler.handle(e, getShell(), CallHierarchyMessages.CallHierarchyTypesOrMembersDialog_ChooseTypeDialog_title, >+ CallHierarchyMessages.CallHierarchyTypesOrMembersDialog_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(CallHierarchyMessages.CallHierarchyTypesOrMembersDialog_error_invalidMemberName); >+ else >+ status.setError(CallHierarchyMessages.CallHierarchyTypesOrMembersDialog_error_invalidTypeName); >+ } else { >+ if (doesExist(newText)) { >+ status.setError(CallHierarchyMessages.CallHierarchyTypesOrMembersDialog_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.CALL_HIERARCHY_EXPAND_WITH_CONSTRUCTORS_DIALOG); >+ } >+ >+ } >+ >+ /* >+ * @see org.eclipse.jdt.internal.ui.preferences.OptionsConfigurationBlock#performOk() >+ */ >+ public boolean performOk() { >+ PreferenceConstants.getPreferenceStore().setValue(CallHierarchyContentProvider.PREF_DEFAULT_EXPAND_WITH_CONSTRUCTORS, serializeFavorites(fList.getElements())); >+ 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; >+ >+ /** >+ * Create the member and class icons. >+ */ >+ 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); >+ } >+ >+ /* >+ * @see org.eclipse.jface.viewers.LabelProvider#getImage(java.lang.Object) >+ */ >+ public Image getImage(Object element) { >+ return ((String)element).endsWith(WILDCARD) ? CLASS_ICON : MEMBER_ICON; >+ } >+ >+ /* >+ * @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; >+ } >+ >+ /* >+ * @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); >+ } >+ >+ /* >+ * @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(); >+ return selected.size() != 0; >+ } >+ >+ /* ) >+ * @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); >+ } >+ >+ /* >+ * @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); >+ } >+ } >+ } >+ >+ 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 static final int IDX_RESTORE_DEFAULTS= 4; >+ >+ 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; >+ >+ /** >+ * A key that holds the list of methods or types whose methods are by default expanded with constructors. >+ */ >+ private static Key DEFAULT_EXPAND_WITH_CONSTRUCTORS= getJDTUIKey(PreferenceConstants.getPreferenceStore().getString(CallHierarchyContentProvider.PREF_DEFAULT_EXPAND_WITH_CONSTRUCTORS)); >+ >+ /** >+ * Returns all the key values. >+ * >+ * @return array of keys >+ */ >+ public static Key[] getAllKeys() { >+ return new Key[] {DEFAULT_EXPAND_WITH_CONSTRUCTORS}; >+ } >+ >+ >+ /** >+ * Creates the call hierarchy preferences configuration block. >+ * >+ * @param context the status >+ * @param container the preference container >+ */ >+ public ExpandWithConstructorsConfigurationBlock(IStatusChangeListener context, IWorkbenchPreferenceContainer container) { >+ super(context, null, getAllKeys(), container); >+ } >+ >+ /* >+ * @see org.eclipse.jdt.internal.ui.preferences.OptionsConfigurationBlock#createContents(org.eclipse.swt.widgets.Composite) >+ */ >+ protected Control createContents(Composite parent) { >+ Composite control= new Composite(parent, SWT.NONE); >+ GridLayout layout= new GridLayout(); >+ layout.numColumns= 2; >+ layout.marginWidth= 10; >+ layout.marginHeight= 10; >+ control.setLayout(layout); >+ >+ createPreferenceList(control); >+ >+ fAnonymousButton= new Button(control, SWT.CHECK); >+ fAnonymousButton.setText(CallHierarchyMessages.CallHierarchyTypesOrMembersDialog_anonymousTypes_label); >+ boolean anonymousPref= PreferenceConstants.getPreferenceStore().getBoolean(CallHierarchyContentProvider.PREF_ANONYMOUS_EXPAND_WITH_CONSTRUCTORS); >+ fAnonymousButton.setSelection(anonymousPref); >+ fAnonymousButton.setLayoutData(new GridData(SWT.LEAD, SWT.TOP, false, false)); >+ fAnonymousButton.addSelectionListener(new SelectionAdapter() { >+ public void widgetSelected(SelectionEvent e) { >+ fIsAnonymous= fAnonymousButton.getSelection(); >+ } >+ >+ }); >+ >+ initialize(); >+ >+ Dialog.applyDialogFont(control); >+ >+ return control; >+ } >+ >+ /** >+ * Create a list dialog field. >+ * >+ * @param parent the composite >+ */ >+ private void createPreferenceList(Composite parent) { >+ String[] buttonLabels= new String[] { >+ CallHierarchyMessages.ExpandWithConstructorsConfigurationBlock_newType_button, >+ CallHierarchyMessages.ExpandWithConstructorsConfigurationBlock_newMember_button, >+ CallHierarchyMessages.ExpandWithConstructorsConfigurationBlock_edit_button, >+ CallHierarchyMessages.ExpandWithConstructorsConfigurationBlock_remove_button, >+ CallHierarchyMessages.ExpandWithConstructorsConfigurationBlock_restoreDefaults_button >+ }; >+ >+ ListAdapter adapter= new ListAdapter(); >+ >+ fList= new ListDialogField(adapter, buttonLabels, new ListLabelProvider()); >+ fList.setDialogFieldListener(adapter); >+ fList.setLabelText(CallHierarchyMessages.ExpandWithConstructorsConfigurationBlock_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(10); >+ } >+ >+ /** >+ * 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(getExpandWithConstructorsKey())); >+ fList.setElements(storedPreference); >+ } >+ >+ /* >+ * @see org.eclipse.jdt.internal.ui.preferences.OptionsConfigurationBlock#performDefaults() >+ */ >+ public void performDefaults() { >+ super.performDefaults(); >+ fList.setElements(Arrays.asList(defaultTypes)); >+ } >+ >+ /* >+ * @see org.eclipse.jdt.internal.ui.preferences.OptionsConfigurationBlock#getFullBuildDialogStrings(boolean) >+ */ >+ protected String[] getFullBuildDialogStrings(boolean workspaceSettings) { >+ return null; >+ } >+ >+ /* >+ * @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, and 'Restore Defaults' button by restoring to default values for the list 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(); >+ CallHierarchyTypesOrMembersDialog dialog= new CallHierarchyTypesOrMembersDialog(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); >+ CallHierarchyTypesOrMembersDialog dialog= new CallHierarchyTypesOrMembersDialog(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()); >+ } >+ } else if (index == IDX_RESTORE_DEFAULTS){ >+ performDefaults(); >+ } >+ } >+ >+ /** >+ * Update the key on dialog field change. >+ * >+ * @param field the dialog field >+ */ >+ protected final void doDialogFieldChanged(DialogField field) { >+ // set values in working copy >+ if (field == fList) { >+ setValue(DEFAULT_EXPAND_WITH_CONSTRUCTORS, serializeFavorites(fList.getElements())); >+ } >+ } >+ >+ /** >+ * Returns the key that holds the user preferences for default expand with constructors. >+ * >+ * @return the call hierarchy expand with constructors key >+ */ >+ private String[] getExpandWithConstructorsKey() { >+ setValue(DEFAULT_EXPAND_WITH_CONSTRUCTORS, PreferenceConstants.getPreferenceStore().getString(CallHierarchyContentProvider.PREF_DEFAULT_EXPAND_WITH_CONSTRUCTORS)); >+ String str= getValue(DEFAULT_EXPAND_WITH_CONSTRUCTORS); >+ 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/ExpandWithConstructorsActionGroup.java >=================================================================== >RCS file: ui/org/eclipse/jdt/internal/ui/callhierarchy/ExpandWithConstructorsActionGroup.java >diff -N ui/org/eclipse/jdt/internal/ui/callhierarchy/ExpandWithConstructorsActionGroup.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ ui/org/eclipse/jdt/internal/ui/callhierarchy/ExpandWithConstructorsActionGroup.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,81 @@ >+/******************************************************************************* >+ * 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.Shell; >+ >+import org.eclipse.jface.action.Action; >+import org.eclipse.jface.action.IMenuManager; >+import org.eclipse.jface.action.Separator; >+ >+import org.eclipse.ui.IActionBars; >+import org.eclipse.ui.actions.ActionGroup; >+ >+/** >+ * Call Hierarchy expand with constructors action group. >+ * >+ * @since 3.6 >+ * >+ */ >+public class ExpandWithConstructorsActionGroup extends ActionGroup { >+ private CallHierarchyViewPart fPart; >+ >+ /** >+ * Creates the expand with constructors action group. >+ * >+ * @param part the call hierarchy view part >+ */ >+ public ExpandWithConstructorsActionGroup(CallHierarchyViewPart part) { >+ fPart= part; >+ } >+ >+ /** >+ * Call hierarchy expand with constructors action class. >+ * >+ */ >+ public class ExpandWithConstructorsDialogAction extends Action { >+ >+ /** >+ * Creates the call hierarchy expand with constructors action. >+ */ >+ public ExpandWithConstructorsDialogAction() { >+ setText(CallHierarchyMessages.ExpandWithConstructorsDialogAction_expandWithConstructors_label); >+ } >+ >+ /* >+ * @see org.eclipse.jface.action.Action#run() >+ */ >+ public void run() { >+ Shell shell= fPart.getViewSite().getShell(); >+ ExpandWithConstructorsDialog dialog= new ExpandWithConstructorsDialog(shell); >+ dialog.open(); >+ } >+ } >+ >+ >+ /* >+ * @see org.eclipse.ui.actions.ActionGroup#fillActionBars(org.eclipse.ui.IActionBars) >+ */ >+ public void fillActionBars(IActionBars actionBars) { >+ fillViewMenu(actionBars.getMenuManager()); >+ } >+ >+ >+ /** >+ * Fills the action to the view menu. >+ * @param viewMenu the menu manager >+ */ >+ private void fillViewMenu(IMenuManager viewMenu) { >+ viewMenu.add(new Separator("expandWithConstructors")); //$NON-NLS-1$ >+ viewMenu.add(new ExpandWithConstructorsDialogAction()); >+ } >+ >+ >+}
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
Actions:
View
|
Diff
Attachments on
bug 276466
:
135958
|
144529
|
146514
|
147082
|
149404
|
151152
|
151933