Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 276466 | Differences between
and this patch

Collapse All | Expand All

(-)ui/org/eclipse/jdt/internal/ui/callhierarchy/CallHierarchyContentProvider.java (-30 / +39 lines)
Lines 55-71 Link Here
55
	 */
55
	 */
56
	public static final String PREF_DEFAULT_EXPAND_WITH_CONSTRUCTORS= "CallHierarchy.defaultExpandWithConstructors"; //$NON-NLS-1$
56
	public static final String PREF_DEFAULT_EXPAND_WITH_CONSTRUCTORS= "CallHierarchy.defaultExpandWithConstructors"; //$NON-NLS-1$
57
57
58
	/**
59
	 * A named preference that controls whether methods from anonymous types are by default expanded
60
	 * with constructors in the Call Hierarchy.
61
	 * <p>
62
	 * Value is of type <code>Boolean</code>.
63
	 * </p>
64
	 * 
65
	 * @since 3.5
66
	 */
67
	public static final String PREF_ANONYMOUS_EXPAND_WITH_CONSTRUCTORS= "CallHierarchy.anonymousExpandWithConstructors"; //$NON-NLS-1$
68
69
	private final static Object[] EMPTY_ARRAY= new Object[0];
58
	private final static Object[] EMPTY_ARRAY= new Object[0];
70
59
71
    private DeferredTreeContentManager fManager;
60
    private DeferredTreeContentManager fManager;
Lines 179-188 Link Here
179
				try {
168
				try {
180
					boolean withConstructors= false;
169
					boolean withConstructors= false;
181
					if (type != null) {
170
					if (type != null) {
182
						boolean anonymousPref= PreferenceConstants.getPreferenceStore().getBoolean(PREF_ANONYMOUS_EXPAND_WITH_CONSTRUCTORS);
171
						boolean anonymousPref= PreferenceConstants.getPreferenceStore().getBoolean(PreferenceConstants.PREF_ANONYMOUS_EXPAND_WITH_CONSTRUCTORS);
183
						if (anonymousPref && type.isAnonymous()) {
172
						if (anonymousPref && type.isAnonymous()) {
184
							withConstructors= true;
173
							withConstructors= true;
185
						} else if (isInTheDefaultExpandWithConstructorList(type)) {
174
						} else if (isInTheDefaultExpandWithConstructorList(wrapper)) {
186
							withConstructors= true;
175
							withConstructors= true;
187
						}
176
						}
188
					}
177
					}
Lines 217-253 Link Here
217
	}
206
	}
218
	
207
	
219
	/**
208
	/**
220
	 * Checks if declaring type matches the pre-defined array of types for default expand with
209
	 * Checks if the member or its declaring type matches the pre-defined array of members and types
221
	 * constructors.
210
	 * for default expand with constructors.
222
	 * 
211
	 * 
223
	 * @param type the declaring type of the caller method wrapper
212
	 * @param wrapper caller method wrapper
224
	 * @return <code>true</code> if type matches the pre-defined list, <code>false</code> otherwise
213
	 * @return <code>true</code> if method or type matches the pre-defined list, <code>false</code> otherwise
225
	 * @since 3.5
214
	 * @since 3.5
226
	 */
215
	 */
227
	static boolean isInTheDefaultExpandWithConstructorList(IType type) {
216
	static boolean isInTheDefaultExpandWithConstructorList(CallerMethodWrapper wrapper) {
228
		String serializedTypes= PreferenceConstants.getPreferenceStore().getString(PREF_DEFAULT_EXPAND_WITH_CONSTRUCTORS);
217
		String serializedTypesAndMembers= PreferenceConstants.getPreferenceStore().getString(PreferenceConstants.PREF_DEFAULT_EXPAND_WITH_CONSTRUCTORS_MEMBERS);
229
		if (serializedTypes.length() == 0)
218
		if (serializedTypesAndMembers.length() == 0)
230
			return false;
219
			return false;
231
		
220
		String member= wrapper.getMember().getElementName();
232
		String[] defaultTypes= serializedTypes.split(";"); //$NON-NLS-1$
221
		IType declaringType= wrapper.getMember().getDeclaringType();
233
		
222
		String[] defaultTypesOrMembers= serializedTypesAndMembers.split(";"); //$NON-NLS-1$
234
		String typeName= type.getFullyQualifiedName('.');
223
224
		String declaringTypeName= declaringType.getFullyQualifiedName('.').concat(".*"); //$NON-NLS-1$;
225
		String qualifiedMemberName= declaringType.getFullyQualifiedName('.').concat(".").concat(member); //$NON-NLS-1$
235
		String superClass;
226
		String superClass;
236
		String[] superInterfaces;
227
		String[] superInterfaces;
237
		try {
228
		try {
238
			superClass= type.getSuperclassName();
229
			superClass= declaringType.getSuperclassName();
239
			superInterfaces= type.getSuperInterfaceNames();
230
			superInterfaces= declaringType.getSuperInterfaceNames();
240
		} catch (JavaModelException e) {
231
		} catch (JavaModelException e) {
241
			return false;
232
			return false;
242
		}
233
		}
243
		for (int i= 0; i < defaultTypes.length; i++) {
234
		for (int i= 0; i < defaultTypesOrMembers.length; i++) {
244
			String defaultType= defaultTypes[i];
235
			String defaultTypeOrMember= defaultTypesOrMembers[i];
245
			if (typeName.equals(defaultType) || (superClass != null && typeNameMatches(superClass, defaultType))) {
236
			if (qualifiedMemberName.equals(defaultTypeOrMember) || declaringTypeName.equals(defaultTypeOrMember)
237
					|| (typeNameMatches(member, defaultTypeOrMember) && superClass != null && defaultTypeOrMember.endsWith(superClass.concat(".").concat(member))) //$NON-NLS-1$
238
							|| checkSuperClassMatch(superClass, defaultTypeOrMember)) {
246
				return true;
239
				return true;
247
			}
240
			}
248
			if (superInterfaces.length > 0) {
241
			if (superInterfaces.length > 0) {
249
				for (int j= 0; j < superInterfaces.length; j++) {
242
				for (int j= 0; j < superInterfaces.length; j++) {
250
					if (typeNameMatches(superInterfaces[j], defaultType))
243
					if (typeNameMatches(superInterfaces[j].concat(".*"), defaultTypeOrMember)) //$NON-NLS-1$
251
						return true;
244
						return true;
252
				}
245
				}
253
			}
246
			}
Lines 256-261 Link Here
256
	}
249
	}
257
250
258
	/**
251
	/**
252
	 * Check whether the given super class name matches the given default type.
253
	 *
254
	 * @param superClass the super class name
255
	 * @param defaultTypeOrMember the default type or member from the default list
256
	 *
257
	 * @return <code>true</code> if super class matches with the given type , <code>false></code> otherwise
258
	 * @since 3.6
259
	 */
260
	private static boolean checkSuperClassMatch(String superClass, String defaultTypeOrMember) {
261
		if (defaultTypeOrMember.endsWith(".*")){ //$NON-NLS-1$
262
			defaultTypeOrMember= defaultTypeOrMember.substring(0, defaultTypeOrMember.length() - 2);
263
		}
264
		return (superClass != null && typeNameMatches(superClass, defaultTypeOrMember));
265
	}
266
267
	/**
259
	 * Checks whether the two type names match. They match if they
268
	 * Checks whether the two type names match. They match if they
260
	 * are equal, or if could be the same type but one is missing the package.
269
	 * are equal, or if could be the same type but one is missing the package.
261
	 * 
270
	 * 
(-)ui/org/eclipse/jdt/internal/ui/callhierarchy/CallHierarchyMessages.java (-4 / +19 lines)
Lines 88-93 Link Here
88
	public static String CallHierarchyViewPart_callsFromMembers_3;
88
	public static String CallHierarchyViewPart_callsFromMembers_3;
89
	public static String CallHierarchyViewPart_callsFromMembers_more;
89
	public static String CallHierarchyViewPart_callsFromMembers_more;
90
	public static String CallHierarchyViewPart_callsFromMethod;
90
	public static String CallHierarchyViewPart_callsFromMethod;
91
	public static String ExpandWithConstructorsConfigurationBlock_description;
92
	public static String ExpandWithConstructorsConfigurationBlock_newType_button;
93
	public static String ExpandWithConstructorsConfigurationBlock_newMember_button;
94
	public static String ExpandWithConstructorsConfigurationBlock_edit_button;
95
	public static String ExpandWithConstructorsConfigurationBlock_remove_button;
96
	public static String ExpandWithConstructorsConfigurationBlock_restoreDefaults_button;
97
	public static String CallHierarchyTypesOrMembersDialog_member_title;
98
	public static String CallHierarchyTypesOrMembersDialog_member_labelText;
99
	public static String CallHierarchyTypesOrMembersDialog_type_title;
100
	public static String CallHierarchyTypesOrMembersDialog_type_labelText;
101
	public static String CallHierarchyTypesOrMembersDialog_browse_button;
102
	public static String CallHierarchyTypesOrMembersDialog_ChooseTypeDialog_title;
103
	public static String CallHierarchyTypesOrMembersDialog_ChooseTypeDialog_description;
104
	public static String CallHierarchyTypesOrMembersDialog_ChooseTypeDialog_error_message;
105
	public static String CallHierarchyTypesOrMembersDialog_error_enterName;
106
	public static String CallHierarchyTypesOrMembersDialog_error_invalidMemberName;
107
	public static String CallHierarchyTypesOrMembersDialog_error_invalidTypeName;
108
	public static String CallHierarchyTypesOrMembersDialog_error_entryExists;
109
	public static String CallHierarchyTypesOrMembersDialog_anonymousTypes_label;
91
	public static String FocusOnSelectionAction_focusOnSelection_text;
110
	public static String FocusOnSelectionAction_focusOnSelection_text;
92
	public static String FocusOnSelectionAction_focusOnSelection_description;
111
	public static String FocusOnSelectionAction_focusOnSelection_description;
93
	public static String FocusOnSelectionAction_focusOnSelection_tooltip;
112
	public static String FocusOnSelectionAction_focusOnSelection_tooltip;
Lines 139-149 Link Here
139
	public static String ExpandWithConstructorsAction_expandWithConstructors_text;
158
	public static String ExpandWithConstructorsAction_expandWithConstructors_text;
140
	public static String ExpandWithConstructorsAction_expandWithConstructors_description;
159
	public static String ExpandWithConstructorsAction_expandWithConstructors_description;
141
	public static String ExpandWithConstructorsAction_expandWithConstructors_tooltip;
160
	public static String ExpandWithConstructorsAction_expandWithConstructors_tooltip;
142
	public static String ExpandWithConstructorsDialog_anonymousTypes_label;
143
	public static String ExpandWithConstructorsDialog_explanation_label;
144
	public static String ExpandWithConstructorsDialog_not_a_valid_type_name;
145
	public static String ExpandWithConstructorsDialog_title;
161
	public static String ExpandWithConstructorsDialog_title;
146
	public static String ExpandWithConstructorsDialog_typeNames_label;
147
	static {
162
	static {
148
		NLS.initializeMessages(BUNDLE_NAME, CallHierarchyMessages.class);
163
		NLS.initializeMessages(BUNDLE_NAME, CallHierarchyMessages.class);
149
	}
164
	}
(-)ui/org/eclipse/jdt/internal/ui/callhierarchy/CallHierarchyMessages.properties (-5 / +23 lines)
Lines 146-153 Link Here
146
ExpandWithConstructorsAction_expandWithConstructors_text= &Expand with Constructors
146
ExpandWithConstructorsAction_expandWithConstructors_text= &Expand with Constructors
147
ExpandWithConstructorsAction_expandWithConstructors_description= Expand with constructors
147
ExpandWithConstructorsAction_expandWithConstructors_description= Expand with constructors
148
ExpandWithConstructorsAction_expandWithConstructors_tooltip= Expand with Constructors
148
ExpandWithConstructorsAction_expandWithConstructors_tooltip= Expand with Constructors
149
ExpandWithConstructorsDialog_anonymousTypes_label=&All methods in anonymous types
149
ExpandWithConstructorsDialog_title= Expand with Constructors
150
ExpandWithConstructorsDialog_explanation_label=Configure the types whose instance methods are expanded with constructors by default.
150
151
ExpandWithConstructorsDialog_not_a_valid_type_name=''{0}'' is not a valid type name
151
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.
152
ExpandWithConstructorsDialog_title=Expand with Constructors
152
ExpandWithConstructorsConfigurationBlock_newType_button= New &Type...
153
ExpandWithConstructorsDialog_typeNames_label=Type &names (each on a line):
153
ExpandWithConstructorsConfigurationBlock_newMember_button= New &Member...
154
ExpandWithConstructorsConfigurationBlock_edit_button= &Edit...
155
ExpandWithConstructorsConfigurationBlock_remove_button= &Remove 
156
ExpandWithConstructorsConfigurationBlock_restoreDefaults_button= Restore &Defaults
157
158
CallHierarchyTypesOrMembersDialog_member_title= New Member for Expand With Constructors
159
CallHierarchyTypesOrMembersDialog_member_labelText= Enter a fully qualified non-static, non-constructor member (e.g. \'java.lang.Runnable.run\'): 
160
CallHierarchyTypesOrMembersDialog_type_title= New Type for Expand With Constructors
161
CallHierarchyTypesOrMembersDialog_type_labelText= Enter a fully qualified type (e.g. \'java.lang.Runnable\'):
162
CallHierarchyTypesOrMembersDialog_browse_button= &Browse...
163
CallHierarchyTypesOrMembersDialog_ChooseTypeDialog_title= Type Selection
164
CallHierarchyTypesOrMembersDialog_ChooseTypeDialog_description= Choose type name:
165
CallHierarchyTypesOrMembersDialog_ChooseTypeDialog_error_message= A problem occurred while collecting types. See the error Log for details.
166
CallHierarchyTypesOrMembersDialog_error_enterName=Enter a name or prefix.
167
CallHierarchyTypesOrMembersDialog_error_invalidTypeName=Not a valid type name.
168
CallHierarchyTypesOrMembersDialog_error_invalidMemberName=Not a valid member name.
169
CallHierarchyTypesOrMembersDialog_error_entryExists=Entry already exists in list.
170
CallHierarchyTypesOrMembersDialog_anonymousTypes_label=&All methods in anonymous types
171
(-)ui/org/eclipse/jdt/internal/ui/callhierarchy/ExpandWithConstructorsConfigurationBlock.java (+650 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 *******************************************************************************/
9
10
package org.eclipse.jdt.internal.ui.callhierarchy;
11
12
import java.util.ArrayList;
13
import java.util.Arrays;
14
import java.util.List;
15
16
import org.eclipse.swt.SWT;
17
import org.eclipse.swt.events.SelectionAdapter;
18
import org.eclipse.swt.events.SelectionEvent;
19
import org.eclipse.swt.graphics.Image;
20
import org.eclipse.swt.layout.GridData;
21
import org.eclipse.swt.layout.GridLayout;
22
import org.eclipse.swt.widgets.Button;
23
import org.eclipse.swt.widgets.Composite;
24
import org.eclipse.swt.widgets.Control;
25
import org.eclipse.swt.widgets.Shell;
26
import org.eclipse.swt.widgets.Text;
27
28
import org.eclipse.core.runtime.Assert;
29
import org.eclipse.core.runtime.IStatus;
30
31
import org.eclipse.jface.dialogs.Dialog;
32
import org.eclipse.jface.dialogs.StatusDialog;
33
import org.eclipse.jface.layout.PixelConverter;
34
import org.eclipse.jface.operation.IRunnableContext;
35
import org.eclipse.jface.viewers.LabelProvider;
36
import org.eclipse.jface.viewers.ViewerComparator;
37
import org.eclipse.jface.window.Window;
38
39
import org.eclipse.ui.PlatformUI;
40
import org.eclipse.ui.dialogs.SelectionDialog;
41
import org.eclipse.ui.preferences.IWorkbenchPreferenceContainer;
42
43
import org.eclipse.jdt.core.IType;
44
import org.eclipse.jdt.core.JavaConventions;
45
import org.eclipse.jdt.core.JavaCore;
46
import org.eclipse.jdt.core.JavaModelException;
47
import org.eclipse.jdt.core.search.IJavaSearchScope;
48
import org.eclipse.jdt.core.search.SearchEngine;
49
50
import org.eclipse.jdt.ui.IJavaElementSearchConstants;
51
import org.eclipse.jdt.ui.JavaUI;
52
import org.eclipse.jdt.ui.PreferenceConstants;
53
54
import org.eclipse.jdt.internal.ui.IJavaHelpContextIds;
55
import org.eclipse.jdt.internal.ui.JavaPluginImages;
56
import org.eclipse.jdt.internal.ui.dialogs.StatusInfo;
57
import org.eclipse.jdt.internal.ui.dialogs.TextFieldNavigationHandler;
58
import org.eclipse.jdt.internal.ui.preferences.OptionsConfigurationBlock;
59
import org.eclipse.jdt.internal.ui.util.BusyIndicatorRunnableContext;
60
import org.eclipse.jdt.internal.ui.util.ExceptionHandler;
61
import org.eclipse.jdt.internal.ui.viewsupport.BasicElementLabels;
62
import org.eclipse.jdt.internal.ui.viewsupport.JavaElementImageProvider;
63
import org.eclipse.jdt.internal.ui.wizards.IStatusChangeListener;
64
import org.eclipse.jdt.internal.ui.wizards.dialogfields.DialogField;
65
import org.eclipse.jdt.internal.ui.wizards.dialogfields.IDialogFieldListener;
66
import org.eclipse.jdt.internal.ui.wizards.dialogfields.IListAdapter;
67
import org.eclipse.jdt.internal.ui.wizards.dialogfields.IStringButtonAdapter;
68
import org.eclipse.jdt.internal.ui.wizards.dialogfields.LayoutUtil;
69
import org.eclipse.jdt.internal.ui.wizards.dialogfields.ListDialogField;
70
import org.eclipse.jdt.internal.ui.wizards.dialogfields.StringButtonDialogField;
71
72
/**
73
 * Call hierarchy expand with constructors configuration block.
74
 *
75
 * @since 3.6
76
 */
77
/**
78
 * @author raksha
79
 *
80
 */
81
public class ExpandWithConstructorsConfigurationBlock extends OptionsConfigurationBlock {
82
83
	/**
84
	 * Call hierarchy expand with constructors dialog for types and members.
85
	 */
86
	private static class CallHierarchyTypesOrMembersDialog extends StatusDialog {
87
88
		/**
89
		 * The change listener class for the dialog field and the string button dialog field.
90
		 *
91
		 */
92
		private class StringButtonAdapter implements IDialogFieldListener, IStringButtonAdapter {
93
			/*
94
			 * @see IDialogFieldListener#dialogFieldChanged(DialogField)
95
			 */
96
			public void dialogFieldChanged(DialogField field) {
97
				doValidation();
98
			}
99
100
			/*
101
			 * @see IStringButtonAdapter#changeControlPressed(DialogField)
102
			 */
103
			public void changeControlPressed(DialogField field) {
104
				doBrowseTypes();
105
			}
106
		}
107
108
		/**
109
		 * The name dialog field to hold the default expand with constructors list.
110
		 */
111
		private StringButtonDialogField fNameDialogField;
112
113
		/**
114
		 * The list of previously existing entries.
115
		 */
116
		private List fExistingEntries;
117
118
		/**
119
		 * Tells whether it is an member or type.
120
		 */
121
		private final boolean fIsEditingMember;
122
123
		/**
124
		 * Creates a call hierarchy preference dialog for members or types.
125
		 *
126
		 * @param parent the parent shell
127
		 * @param existingEntries the existing list of types and members
128
		 * @param isEditingMember <code>true</code if its a member, <code>false</code> otherwise
129
		 */
130
		public CallHierarchyTypesOrMembersDialog(Shell parent, List existingEntries, boolean isEditingMember) {
131
			super(parent);
132
			fIsEditingMember= isEditingMember;
133
			fExistingEntries= existingEntries;
134
135
			String label, title;
136
			if (isEditingMember) {
137
				title= CallHierarchyMessages.CallHierarchyTypesOrMembersDialog_member_title;
138
				label= CallHierarchyMessages.CallHierarchyTypesOrMembersDialog_member_labelText;
139
			} else {
140
				title= CallHierarchyMessages.CallHierarchyTypesOrMembersDialog_type_title;
141
				label= CallHierarchyMessages.CallHierarchyTypesOrMembersDialog_type_labelText;
142
			}
143
			setTitle(title);
144
145
			StringButtonAdapter adapter= new StringButtonAdapter();
146
147
			fNameDialogField= new StringButtonDialogField(adapter);
148
			fNameDialogField.setLabelText(label);
149
			fNameDialogField.setButtonLabel(CallHierarchyMessages.CallHierarchyTypesOrMembersDialog_browse_button);
150
			fNameDialogField.setDialogFieldListener(adapter);
151
			fNameDialogField.setText(""); //$NON-NLS-1$
152
		}
153
154
		/*
155
		 * @see org.eclipse.jface.dialogs.Dialog#isResizable()		 *
156
		 */
157
		protected boolean isResizable() {
158
			return true;
159
		}
160
161
		/**
162
		 * Sets the initial selection in the name dialog field.
163
		 *
164
		 * @param editedEntry the edited entry
165
		 */
166
		public void setInitialSelection(String editedEntry) {
167
			Assert.isNotNull(editedEntry);
168
			if (editedEntry.length() == 0)
169
				fNameDialogField.setText(""); //$NON-NLS-1$
170
			else
171
				fNameDialogField.setText(editedEntry);
172
		}
173
174
		/**
175
		 * Returns the resulting text from the name dialog field.
176
		 *
177
		 * @return the resulting text from the name dialog field
178
		 */
179
		public String getResult() {
180
			String val= fNameDialogField.getText();
181
			if (!fIsEditingMember)
182
				val= val + WILDCARD;
183
			return val;
184
		}
185
186
		/*
187
		 * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
188
		 */
189
		protected Control createDialogArea(Composite parent) {
190
			Composite composite= (Composite)super.createDialogArea(parent);
191
			initializeDialogUnits(composite);
192
193
			GridLayout layout= (GridLayout)composite.getLayout();
194
			layout.numColumns= 2;
195
196
			fNameDialogField.doFillIntoGrid(composite, 3);
197
198
			fNameDialogField.getChangeControl(null).setVisible(!fIsEditingMember);
199
200
			LayoutUtil.setHorizontalSpan(fNameDialogField.getLabelControl(null), 2);
201
202
			int fieldWidthHint= convertWidthInCharsToPixels(60);
203
			Text text= fNameDialogField.getTextControl(null);
204
			LayoutUtil.setWidthHint(text, fieldWidthHint);
205
			LayoutUtil.setHorizontalGrabbing(text);
206
			LayoutUtil.setHorizontalSpan(text, fIsEditingMember ? 2 : 1);
207
			TextFieldNavigationHandler.install(text);
208
209
			DialogField.createEmptySpace(composite, 1);
210
211
			fNameDialogField.postSetFocusOnDialogField(parent.getDisplay());
212
213
			applyDialogFont(composite);
214
			return composite;
215
		}
216
217
		/**
218
		 * Creates the type hierarchy for type selection.
219
		 */
220
		private void doBrowseTypes() {
221
			IRunnableContext context= new BusyIndicatorRunnableContext();
222
			IJavaSearchScope scope= SearchEngine.createWorkspaceScope();
223
			int style= IJavaElementSearchConstants.CONSIDER_ALL_TYPES;
224
			try {
225
				SelectionDialog dialog= JavaUI.createTypeDialog(getShell(), context, scope, style, false, fNameDialogField.getText());
226
				dialog.setTitle(CallHierarchyMessages.CallHierarchyTypesOrMembersDialog_ChooseTypeDialog_title);
227
				dialog.setMessage(CallHierarchyMessages.CallHierarchyTypesOrMembersDialog_ChooseTypeDialog_description);
228
				if (dialog.open() == Window.OK) {
229
					IType res= (IType)dialog.getResult()[0];
230
					fNameDialogField.setText(res.getFullyQualifiedName('.'));
231
				}
232
			} catch (JavaModelException e) {
233
				ExceptionHandler.handle(e, getShell(), CallHierarchyMessages.CallHierarchyTypesOrMembersDialog_ChooseTypeDialog_title,
234
						CallHierarchyMessages.CallHierarchyTypesOrMembersDialog_ChooseTypeDialog_error_message);
235
			}
236
		}
237
238
		/**
239
		 * Validates the entered type or member and updates the status.
240
		 */
241
		private void doValidation() {
242
			StatusInfo status= new StatusInfo();
243
			String newText= fNameDialogField.getText();
244
			if (newText.length() == 0) {
245
				status.setError(""); //$NON-NLS-1$
246
			} else {
247
				IStatus val= JavaConventions.validateJavaTypeName(newText, JavaCore.VERSION_1_3, JavaCore.VERSION_1_3);
248
				if (val.matches(IStatus.ERROR)) {
249
					if (fIsEditingMember)
250
						status.setError(CallHierarchyMessages.CallHierarchyTypesOrMembersDialog_error_invalidMemberName);
251
					else
252
						status.setError(CallHierarchyMessages.CallHierarchyTypesOrMembersDialog_error_invalidTypeName);
253
				} else {
254
					if (doesExist(newText)) {
255
						status.setError(CallHierarchyMessages.CallHierarchyTypesOrMembersDialog_error_entryExists);
256
					}
257
				}
258
			}
259
			updateStatus(status);
260
		}
261
262
		/**
263
		 * Checks if the entry already exists.
264
		 *
265
		 * @param name the type or member name
266
		 * @return <code>true</code> if it already exists in the list of types and members,
267
		 *         <code>false</code> otherwise
268
		 */
269
		private boolean doesExist(String name) {
270
			for (int i= 0; i < fExistingEntries.size(); i++) {
271
				String entry= (String)fExistingEntries.get(i);
272
				if (name.equals(entry)) {
273
					return true;
274
				}
275
			}
276
			return false;
277
		}
278
279
280
		/*
281
		 * @see org.eclipse.jface.window.Window#configureShell(Shell)
282
		 */
283
		protected void configureShell(Shell newShell) {
284
			super.configureShell(newShell);
285
			PlatformUI.getWorkbench().getHelpSystem().setHelp(newShell, IJavaHelpContextIds.CALL_HIERARCHY_EXPAND_WITH_CONSTRUCTORS_DIALOG);
286
		}
287
288
	}
289
290
	/*
291
	 * @see org.eclipse.jdt.internal.ui.preferences.OptionsConfigurationBlock#performOk()
292
	 */
293
	public boolean performOk() {
294
		setValue(ANONYMOUS_EXPAND_WITH_CONSTRUCTORS, fIsAnonymous);
295
		return super.performOk();
296
	}
297
298
	/**
299
	 * The list label provider class.
300
	 */
301
	private static class ListLabelProvider extends LabelProvider {
302
303
		public final Image MEMBER_ICON;
304
305
		private final Image CLASS_ICON;
306
307
		/**
308
		 * Create the member and class icons.
309
		 */
310
		public ListLabelProvider() {
311
			MEMBER_ICON= JavaElementImageProvider.getDecoratedImage(JavaPluginImages.DESC_MISC_PUBLIC, 0, JavaElementImageProvider.SMALL_SIZE);
312
			CLASS_ICON= JavaElementImageProvider.getDecoratedImage(JavaPluginImages.DESC_OBJS_CLASS, 0, JavaElementImageProvider.SMALL_SIZE);
313
		}
314
315
		/*
316
		 * @see org.eclipse.jface.viewers.LabelProvider#getImage(java.lang.Object)
317
		 */
318
		public Image getImage(Object element) {
319
			return ((String)element).endsWith(WILDCARD) ? CLASS_ICON : MEMBER_ICON;
320
		}
321
322
		/*
323
		 * @see org.eclipse.jface.viewers.LabelProvider#getText(java.lang.Object)
324
		 */
325
		public String getText(Object element) {
326
			return BasicElementLabels.getJavaElementName((String)element);
327
		}
328
	}
329
330
331
	/**
332
	 * The change listener for <code>ListDialogField</code>.
333
	 */
334
	private class ListAdapter implements IListAdapter, IDialogFieldListener {
335
336
		/**
337
		 * Checks if field can be edited.
338
		 *
339
		 * @param field the list dialog field
340
		 * @return <code>true</code> if it can be edited, <code>false</code> otherwise
341
		 */
342
		private boolean canEdit(ListDialogField field) {
343
			List selected= field.getSelectedElements();
344
			return selected.size() == 1;
345
		}
346
347
		/*
348
		 * @see org.eclipse.jdt.internal.ui.wizards.dialogfields.IListAdapter#customButtonPressed(org.eclipse.jdt.internal.ui.wizards.dialogfields.ListDialogField, int)
349
		 */
350
		public void customButtonPressed(ListDialogField field, int index) {
351
			doButtonPressed(index);
352
		}
353
354
		/*
355
		 * @see org.eclipse.jdt.internal.ui.wizards.dialogfields.IListAdapter#selectionChanged(org.eclipse.jdt.internal.ui.wizards.dialogfields.ListDialogField)
356
		 */
357
		public void selectionChanged(ListDialogField field) {
358
			fList.enableButton(IDX_EDIT, canEdit(field));
359
			fList.enableButton(IDX_REMOVE, canRemove(field));
360
		}
361
362
		/**
363
		 * Checks if the field can be removed.
364
		 *
365
		 * @param field the list dialog field
366
		 * @return <code>true</code> if it can be removed, <code>false</code> otherwise
367
		 */
368
		private boolean canRemove(ListDialogField field) {
369
			List selected= field.getSelectedElements();
370
			return selected.size() != 0;
371
		}
372
373
		/* )
374
		 * @see org.eclipse.jdt.internal.ui.wizards.dialogfields.IDialogFieldListener#dialogFieldChanged(org.eclipse.jdt.internal.ui.wizards.dialogfields.DialogField)
375
		 */
376
		public void dialogFieldChanged(DialogField field) {
377
			doDialogFieldChanged(field);
378
		}
379
380
		/*
381
		 * @see org.eclipse.jdt.internal.ui.wizards.dialogfields.IListAdapter#doubleClicked(org.eclipse.jdt.internal.ui.wizards.dialogfields.ListDialogField)
382
		 */
383
		public void doubleClicked(ListDialogField field) {
384
			if (canEdit(field)) {
385
				doButtonPressed(IDX_EDIT);
386
			}
387
		}
388
	}
389
390
	private static final String WILDCARD= ".*"; //$NON-NLS-1$
391
392
	private static final int IDX_NEW_TYPE= 0;
393
	private static final int IDX_NEW_MEMBER= 1;
394
	private static final int IDX_EDIT= 2;
395
	private static final int IDX_REMOVE= 3;
396
	private static final int IDX_RESTORE_DEFAULTS= 4;
397
398
	private ListDialogField fList;
399
400
	private Button fAnonymousButton;
401
402
	protected boolean fIsAnonymous;
403
404
	/**
405
	 * A key that holds the list of methods or types whose methods are by default expanded with constructors in the Call Hierarchy.
406
	 */
407
	private static Key DEFAULT_EXPAND_WITH_CONSTRUCTORS= getJDTUIKey(PreferenceConstants.PREF_DEFAULT_EXPAND_WITH_CONSTRUCTORS_MEMBERS);
408
409
	/**
410
	 * A key that controls whether the methods from anonymous types are by default expanded with constructors in the Call Hierarchy.
411
	 */
412
	private static Key ANONYMOUS_EXPAND_WITH_CONSTRUCTORS= getJDTUIKey(PreferenceConstants.PREF_ANONYMOUS_EXPAND_WITH_CONSTRUCTORS);
413
414
	/**
415
	 * Returns all the key values.
416
	 *
417
	 * @return array of keys
418
	 */
419
	public static Key[] getAllKeys() {
420
		return new Key[] {DEFAULT_EXPAND_WITH_CONSTRUCTORS, ANONYMOUS_EXPAND_WITH_CONSTRUCTORS};
421
	}
422
423
424
	/**
425
	 * Creates the call hierarchy preferences configuration block.
426
	 *
427
	 * @param context the status
428
	 * @param container the preference container
429
	 */
430
	public ExpandWithConstructorsConfigurationBlock(IStatusChangeListener context, IWorkbenchPreferenceContainer container) {
431
		super(context, null, getAllKeys(), container);
432
	}
433
434
	/*
435
	 * @see org.eclipse.jdt.internal.ui.preferences.OptionsConfigurationBlock#createContents(org.eclipse.swt.widgets.Composite)
436
	 */
437
	protected Control createContents(Composite parent) {
438
		Composite control= new Composite(parent, SWT.NONE);
439
		GridLayout layout= new GridLayout();
440
		layout.numColumns= 2;
441
		layout.marginWidth= 10;
442
		layout.marginHeight= 10;
443
		control.setLayout(layout);
444
445
		createPreferenceList(control);
446
447
		fAnonymousButton= new Button(control, SWT.CHECK);
448
		fAnonymousButton.setText(CallHierarchyMessages.CallHierarchyTypesOrMembersDialog_anonymousTypes_label);
449
		fIsAnonymous= getBooleanValue(ANONYMOUS_EXPAND_WITH_CONSTRUCTORS);
450
		fAnonymousButton.setSelection(fIsAnonymous);
451
		fAnonymousButton.setLayoutData(new GridData(SWT.LEAD, SWT.TOP, false, false));
452
		fAnonymousButton.addSelectionListener(new SelectionAdapter() {
453
			public void widgetSelected(SelectionEvent e) {
454
				fIsAnonymous= fAnonymousButton.getSelection();
455
			}
456
457
		});
458
459
		initialize();
460
461
		Dialog.applyDialogFont(control);
462
463
		return control;
464
	}
465
466
	/**
467
	 * Create a list dialog field.
468
	 *
469
	 * @param parent the composite
470
	 */
471
	private void createPreferenceList(Composite parent) {
472
		String[] buttonLabels= new String[] {
473
				CallHierarchyMessages.ExpandWithConstructorsConfigurationBlock_newType_button,
474
				CallHierarchyMessages.ExpandWithConstructorsConfigurationBlock_newMember_button,
475
				CallHierarchyMessages.ExpandWithConstructorsConfigurationBlock_edit_button,
476
				CallHierarchyMessages.ExpandWithConstructorsConfigurationBlock_remove_button,
477
				CallHierarchyMessages.ExpandWithConstructorsConfigurationBlock_restoreDefaults_button
478
		};
479
480
		ListAdapter adapter= new ListAdapter();
481
482
		fList= new ListDialogField(adapter, buttonLabels, new ListLabelProvider());
483
		fList.setDialogFieldListener(adapter);
484
		fList.setLabelText(CallHierarchyMessages.ExpandWithConstructorsConfigurationBlock_description);
485
		fList.setRemoveButtonIndex(IDX_REMOVE);
486
		fList.enableButton(IDX_EDIT, false);
487
		fList.setViewerComparator(new ViewerComparator());
488
489
		PixelConverter pixelConverter= new PixelConverter(parent);
490
491
		fList.doFillIntoGrid(parent, 3);
492
		LayoutUtil.setHorizontalSpan(fList.getLabelControl(null), 2);
493
		LayoutUtil.setWidthHint(fList.getLabelControl(null), pixelConverter.convertWidthInCharsToPixels(60));
494
		LayoutUtil.setHorizontalGrabbing(fList.getListControl(null));
495
496
		Control listControl= fList.getListControl(null);
497
		GridData gd= (GridData)listControl.getLayoutData();
498
		gd.verticalAlignment= GridData.FILL;
499
		gd.grabExcessVerticalSpace= true;
500
		gd.heightHint= pixelConverter.convertHeightInCharsToPixels(10);
501
	}
502
503
	/**
504
	 * Initialize the elements of the list dialog field.
505
	 */
506
	public void initialize() {
507
		initializeFields();
508
	}
509
510
	/**
511
	 * Initialize the elements of the list dialog field.
512
	 */
513
	private void initializeFields() {
514
		List storedPreference= new ArrayList();
515
		storedPreference.addAll(Arrays.asList(getDefaultExpandWithConstructorsMembers()));
516
		fList.setElements(storedPreference);
517
	}
518
519
	/*
520
	 * @see org.eclipse.jdt.internal.ui.preferences.OptionsConfigurationBlock#performDefaults()
521
	 */
522
	public void performDefaults() {
523
		String str= PreferenceConstants.getPreferenceStore().getDefaultString(PreferenceConstants.PREF_DEFAULT_EXPAND_WITH_CONSTRUCTORS_MEMBERS);
524
		fList.setElements(Arrays.asList(deserializeMembers(str)));
525
		fIsAnonymous= PreferenceConstants.getPreferenceStore().getDefaultBoolean(PreferenceConstants.PREF_ANONYMOUS_EXPAND_WITH_CONSTRUCTORS);
526
		fAnonymousButton.setSelection(fIsAnonymous);
527
		super.performDefaults();
528
	}
529
530
	/*
531
	 * @see org.eclipse.jdt.internal.ui.preferences.OptionsConfigurationBlock#getFullBuildDialogStrings(boolean)
532
	 */
533
	protected String[] getFullBuildDialogStrings(boolean workspaceSettings) {
534
		return null;
535
	}
536
537
	/*
538
	 * @see org.eclipse.jdt.internal.ui.preferences.OptionsConfigurationBlock#validateSettings(org.eclipse.jdt.internal.ui.preferences.OptionsConfigurationBlock.Key, java.lang.String, java.lang.String)
539
	 */
540
	protected void validateSettings(Key changedKey, String oldValue, String newValue) {
541
542
	}
543
544
	/**
545
	 * Perform the 'New' and 'Edit' button operations by opening the respective call hierarchy
546
	 * preferences dialog, and 'Restore Defaults' button by restoring to default values for the list dialog.
547
	 *
548
	 * @param index the index of the button
549
	 */
550
	private void doButtonPressed(int index) {
551
		if (index == IDX_NEW_TYPE || index == IDX_NEW_MEMBER) { // add new
552
			List existing= fList.getElements();
553
			CallHierarchyTypesOrMembersDialog dialog= new CallHierarchyTypesOrMembersDialog(getShell(), existing, index == IDX_NEW_MEMBER);
554
			if (dialog.open() == Window.OK) {
555
				fList.addElement(dialog.getResult());
556
			}
557
		} else if (index == IDX_EDIT) { // edit
558
			List selected= fList.getSelectedElements();
559
			if (selected.isEmpty())
560
				return;
561
562
			String editedEntry= (String)selected.get(0);
563
564
			List existing= fList.getElements();
565
			existing.remove(editedEntry);
566
			boolean isType= editedEntry.endsWith(WILDCARD);
567
			CallHierarchyTypesOrMembersDialog dialog= new CallHierarchyTypesOrMembersDialog(getShell(), existing, !isType);
568
			if (isType)
569
				dialog.setInitialSelection(editedEntry.substring(0, editedEntry.length() - 2));
570
			else
571
				dialog.setInitialSelection(editedEntry);
572
573
			if (dialog.open() == Window.OK) {
574
				fList.replaceElement(editedEntry, dialog.getResult());
575
			}
576
		} else if (index == IDX_RESTORE_DEFAULTS){
577
			performDefaults();
578
		}
579
	}
580
581
	/**
582
	 * Update the key on dialog field change.
583
	 *
584
	 * @param field the dialog field
585
	 */
586
	protected final void doDialogFieldChanged(DialogField field) {
587
		// set values in working copy
588
		if (field == fList) {
589
			setValue(DEFAULT_EXPAND_WITH_CONSTRUCTORS, serializeMembers(fList.getElements()));
590
		}
591
	}
592
593
	/**
594
	 * Returns the array of strings containing the types or methods for default expand with constructors.
595
	 *
596
	 * @return the array of strings containing the types or methods for default expand with constructors
597
	 */
598
	private String[] getDefaultExpandWithConstructorsMembers() {
599
		List list= null;
600
		String newstr= getValue(DEFAULT_EXPAND_WITH_CONSTRUCTORS);
601
		if (newstr != null && newstr.length() > 0){
602
			list= Arrays.asList(deserializeMembers(newstr));
603
		}
604
		String oldstr= PreferenceConstants.getPreferenceStore().getString(CallHierarchyContentProvider.PREF_DEFAULT_EXPAND_WITH_CONSTRUCTORS);
605
		if (oldstr !=  null && oldstr.length() > 0){
606
			String []oldPrefList;
607
			oldPrefList=  deserializeMembers(oldstr);
608
			for (int i= 0; i < oldPrefList.length; i++) {
609
				oldPrefList[i]= oldPrefList[i].concat(".*"); //$NON-NLS-1$
610
				if (list != null && !list.contains(oldPrefList[i])){
611
					list.add(oldPrefList[i]);
612
				}
613
614
			}
615
			if (list == null) {
616
				list= Arrays.asList(oldPrefList);
617
			}
618
			PreferenceConstants.getPreferenceStore().putValue(CallHierarchyContentProvider.PREF_DEFAULT_EXPAND_WITH_CONSTRUCTORS, ""); //$NON-NLS-1$
619
		}
620
		return list == null? new String[0]: (String[])list.toArray(new String[list.size()]);
621
	}
622
623
	/**
624
	 * Return the array of types and/or methods after splitting the stored preference string.
625
	 *
626
	 * @param str the input string
627
	 * @return the array of types and/or methods
628
	 */
629
	private static String[] deserializeMembers(String str) {
630
		return str.split(";"); //$NON-NLS-1$
631
	}
632
633
	/**
634
	 * Creates a single output string from the list of strings using a delimiter.
635
	 *
636
	 * @param str the input string
637
	 * @return the single output string from the list of strings using a delimiter
638
	 */
639
	private static String serializeMembers(List str) {
640
		int size= str.size();
641
		StringBuffer buf= new StringBuffer();
642
		for (int i= 0; i < size; i++) {
643
			buf.append((String)str.get(i));
644
			if (i < size - 1)
645
				buf.append(';');
646
		}
647
		return buf.toString();
648
	}
649
650
}
(-)ui/org/eclipse/jdt/internal/ui/callhierarchy/ExpandWithConstructorsDialog.java (-81 / +18 lines)
Lines 10-54 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.jdt.internal.ui.callhierarchy;
11
package org.eclipse.jdt.internal.ui.callhierarchy;
12
12
13
import org.eclipse.swt.SWT;
14
import org.eclipse.swt.custom.StyledText;
15
import org.eclipse.swt.events.ModifyEvent;
16
import org.eclipse.swt.events.ModifyListener;
17
import org.eclipse.swt.layout.GridData;
13
import org.eclipse.swt.layout.GridData;
18
import org.eclipse.swt.widgets.Button;
19
import org.eclipse.swt.widgets.Composite;
14
import org.eclipse.swt.widgets.Composite;
20
import org.eclipse.swt.widgets.Control;
15
import org.eclipse.swt.widgets.Control;
21
import org.eclipse.swt.widgets.Label;
22
import org.eclipse.swt.widgets.Shell;
16
import org.eclipse.swt.widgets.Shell;
23
17
24
import org.eclipse.core.runtime.IStatus;
18
import org.eclipse.core.runtime.IStatus;
25
19
26
import org.eclipse.jface.dialogs.StatusDialog;
20
import org.eclipse.jface.dialogs.Dialog;
21
import org.eclipse.jface.dialogs.TrayDialog;
27
22
28
import org.eclipse.ui.PlatformUI;
23
import org.eclipse.ui.PlatformUI;
29
24
30
import org.eclipse.jdt.core.JavaConventions;
31
import org.eclipse.jdt.core.JavaCore;
32
33
import org.eclipse.jdt.internal.corext.util.Messages;
34
35
import org.eclipse.jdt.ui.PreferenceConstants;
36
37
import org.eclipse.jdt.internal.ui.IJavaHelpContextIds;
25
import org.eclipse.jdt.internal.ui.IJavaHelpContextIds;
38
import org.eclipse.jdt.internal.ui.dialogs.StatusInfo;
26
import org.eclipse.jdt.internal.ui.wizards.IStatusChangeListener;
39
27
40
/**
28
/**
41
 * Configuration dialog for default "Expand with Constructors" behavior.
29
 * Configuration dialog for default "Expand with Constructors" behavior.
42
 * 
30
 * 
43
 * @since 3.5
31
 * @since 3.5
44
 */
32
 */
45
class ExpandWithConstructorsDialog extends StatusDialog {
33
class ExpandWithConstructorsDialog extends TrayDialog {
46
34
47
	private static final String LINE_DELIMITER_REGEX= "\\r\\n?|\\n"; //$NON-NLS-1$
35
	private Control fConfigurationBlockControl;
36
	private ExpandWithConstructorsConfigurationBlock fConfigurationBlock;
48
37
49
	private Button fAnonymousButton;
50
	private StyledText fDefaultTypesText;
51
	
52
	protected ExpandWithConstructorsDialog(Shell parentShell) {
38
	protected ExpandWithConstructorsDialog(Shell parentShell) {
53
		super(parentShell);
39
		super(parentShell);
54
	}
40
	}
Lines 66-114 Link Here
66
	protected void configureShell(Shell newShell) {
52
	protected void configureShell(Shell newShell) {
67
		super.configureShell(newShell);
53
		super.configureShell(newShell);
68
		newShell.setText(CallHierarchyMessages.ExpandWithConstructorsDialog_title);
54
		newShell.setText(CallHierarchyMessages.ExpandWithConstructorsDialog_title);
69
		setHelpAvailable(false);
70
		PlatformUI.getWorkbench().getHelpSystem().setHelp(newShell, IJavaHelpContextIds.CALL_HIERARCHY_EXPAND_WITH_CONSTRUCTORS_DIALOG);
55
		PlatformUI.getWorkbench().getHelpSystem().setHelp(newShell, IJavaHelpContextIds.CALL_HIERARCHY_EXPAND_WITH_CONSTRUCTORS_DIALOG);
71
	}
56
	}
72
57
73
	/*
58
	/*
74
	 * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
59
	 * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
75
	 */
60
	 */
76
	protected Control createDialogArea(Composite parent) {
61
	protected Control createDialogArea(Composite composite) {
77
		Composite composite= (Composite)super.createDialogArea(parent);
62
		fConfigurationBlock= new ExpandWithConstructorsConfigurationBlock(new IStatusChangeListener() {
78
		((GridData)composite.getLayoutData()).widthHint= convertWidthInCharsToPixels(60);
63
			public void statusChanged(IStatus status) {
79
		
64
				//Do nothing
80
		Label descriptionLabel= new Label(composite, SWT.WRAP);
65
81
		descriptionLabel.setText(CallHierarchyMessages.ExpandWithConstructorsDialog_explanation_label);
82
		descriptionLabel.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false));
83
		
84
		
85
		Label typesLabel= new Label(composite, SWT.WRAP);
86
		typesLabel.setText(CallHierarchyMessages.ExpandWithConstructorsDialog_typeNames_label);
87
		typesLabel.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false));
88
		
89
		fDefaultTypesText= new StyledText(composite, SWT.BORDER | SWT.WRAP | SWT.H_SCROLL | SWT.V_SCROLL);
90
		GridData gd= new GridData(SWT.FILL, SWT.FILL, true, true);
91
		gd.heightHint= convertHeightInCharsToPixels(10);
92
		fDefaultTypesText.setLayoutData(gd);
93
		
94
		String defaultTypesPref= PreferenceConstants.getPreferenceStore().getString(CallHierarchyContentProvider.PREF_DEFAULT_EXPAND_WITH_CONSTRUCTORS);
95
		String defaultTypesText= defaultTypesPref.replace(';', '\n');
96
		fDefaultTypesText.setText(defaultTypesText);
97
		fDefaultTypesText.setSelection(fDefaultTypesText.getCharCount());
98
		
99
		fDefaultTypesText.addModifyListener(new ModifyListener() {
100
			public void modifyText(ModifyEvent e) {
101
				validateInput();
102
			}
66
			}
103
		});
67
		}, null);
104
		
68
		GridData data= new GridData(GridData.FILL, GridData.FILL, true, true);
105
		
69
		fConfigurationBlockControl= fConfigurationBlock.createContents(composite);
106
		fAnonymousButton= new Button(composite, SWT.CHECK);
70
		fConfigurationBlockControl.setLayoutData(data);
107
		fAnonymousButton.setText(CallHierarchyMessages.ExpandWithConstructorsDialog_anonymousTypes_label);
71
108
		boolean anonymousPref= PreferenceConstants.getPreferenceStore().getBoolean(CallHierarchyContentProvider.PREF_ANONYMOUS_EXPAND_WITH_CONSTRUCTORS);
72
		Dialog.applyDialogFont(composite);
109
		fAnonymousButton.setSelection(anonymousPref);
110
		fAnonymousButton.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false));
111
		
112
		return composite;
73
		return composite;
113
	}
74
	}
114
75
Lines 116-146 Link Here
116
	 * @see org.eclipse.jface.dialogs.Dialog#okPressed()
77
	 * @see org.eclipse.jface.dialogs.Dialog#okPressed()
117
	 */
78
	 */
118
	protected void okPressed() {
79
	protected void okPressed() {
119
		PreferenceConstants.getPreferenceStore().setValue(CallHierarchyContentProvider.PREF_ANONYMOUS_EXPAND_WITH_CONSTRUCTORS, fAnonymousButton.getSelection());
80
		fConfigurationBlock.performOk();
120
		
121
		String defaultTypes= fDefaultTypesText.getText().trim();
122
		String defaultTypesPref= defaultTypes.replaceAll(LINE_DELIMITER_REGEX, ";"); //$NON-NLS-1$
123
		PreferenceConstants.getPreferenceStore().setValue(CallHierarchyContentProvider.PREF_DEFAULT_EXPAND_WITH_CONSTRUCTORS, defaultTypesPref);
124
		
125
		super.okPressed();
81
		super.okPressed();
126
	}
82
	}
127
128
	private void validateInput() {
129
		StatusInfo status= new StatusInfo();
130
		
131
		String[] defaultTypes= fDefaultTypesText.getText().split(LINE_DELIMITER_REGEX);
132
		for (int i= 0; i < defaultTypes.length; i++) {
133
			String type= defaultTypes[i];
134
			if (type.length() == 0)
135
				continue;
136
			
137
			IStatus typeNameStatus= JavaConventions.validateJavaTypeName(type, JavaCore.VERSION_1_3, JavaCore.VERSION_1_3);
138
			if (typeNameStatus.getSeverity() == IStatus.ERROR) {
139
				status.setError(Messages.format(CallHierarchyMessages.ExpandWithConstructorsDialog_not_a_valid_type_name, type));
140
				break;
141
			}
142
		}
143
		
144
		updateStatus(status);
145
	}
146
}
83
}
(-)ui/org/eclipse/jdt/ui/PreferenceConstants.java (-2 / +31 lines)
Lines 3233-3238 Link Here
3233
	 */
3233
	 */
3234
	public static final String EDITOR_FOLDING_HEADERS= "editor_folding_default_headers"; //$NON-NLS-1$
3234
	public static final String EDITOR_FOLDING_HEADERS= "editor_folding_default_headers"; //$NON-NLS-1$
3235
3235
3236
	/**
3237
	 * A named preference that holds the methods or types whose methods are by default expanded with
3238
	 * constructors in the Call Hierarchy.
3239
	 * <p>
3240
	 * Value is of type <code>String</code>: semicolon separated list of fully qualified type or method names.
3241
	 * </p>
3242
	 * <p>
3243
	 * New API: Could not be added when the feature was added in 3.5 M7 due to API restrictions.
3244
	 * </p>
3245
	 *
3246
	 * @since 3.6
3247
	 */
3248
	public static final String PREF_DEFAULT_EXPAND_WITH_CONSTRUCTORS_MEMBERS= "CallHierarchy.defaultExpandWithConstructorsMembers"; //$NON-NLS-1$
3249
3250
	/**
3251
	 * A named preference that controls whether methods from anonymous types are by default expanded
3252
	 * with constructors in the Call Hierarchy.
3253
	 * <p>
3254
	 * Value is of type <code>Boolean</code>.
3255
	 * </p>
3256
	 * <p>
3257
	 * New API: Could not be added when the feature was added in 3.5 M7 due to API restrictions.
3258
	 * </p>
3259
	 *
3260
	 * @since 3.6
3261
	 */
3262
	public static final String PREF_ANONYMOUS_EXPAND_WITH_CONSTRUCTORS= "CallHierarchy.anonymousExpandWithConstructors"; //$NON-NLS-1$
3263
3236
3264
3237
	//---------- Properties File Editor ----------
3265
	//---------- Properties File Editor ----------
3238
3266
Lines 3875-3882 Link Here
3875
3903
3876
		// Colors that are set by the current theme
3904
		// Colors that are set by the current theme
3877
		JavaUIPreferenceInitializer.setThemeBasedPreferences(store, false);
3905
		JavaUIPreferenceInitializer.setThemeBasedPreferences(store, false);
3878
		
3906
3879
		store.setDefault(CallHierarchyContentProvider.PREF_ANONYMOUS_EXPAND_WITH_CONSTRUCTORS, true);
3907
		store.setDefault(PREF_ANONYMOUS_EXPAND_WITH_CONSTRUCTORS, true);
3908
		store.setDefault(PREF_DEFAULT_EXPAND_WITH_CONSTRUCTORS_MEMBERS, "java.lang.Runnable.*;java.util.concurrent.Callable.*;org.eclipse.swt.widgets.Listener.*"); //$NON-NLS-1$
3880
		store.setDefault(CallHierarchyContentProvider.PREF_DEFAULT_EXPAND_WITH_CONSTRUCTORS, "java.lang.Runnable;java.util.concurrent.Callable;org.eclipse.swt.widgets.Listener"); //$NON-NLS-1$
3909
		store.setDefault(CallHierarchyContentProvider.PREF_DEFAULT_EXPAND_WITH_CONSTRUCTORS, "java.lang.Runnable;java.util.concurrent.Callable;org.eclipse.swt.widgets.Listener"); //$NON-NLS-1$
3881
	}
3910
	}

Return to bug 276466