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/CallHierarchyMessages.java (+2 lines)
Lines 73-78 Link Here
73
	public static String CallHierarchyLabelProvider_noMethodSelected;
73
	public static String CallHierarchyLabelProvider_noMethodSelected;
74
	public static String CallHierarchyLabelProvider_updatePending;
74
	public static String CallHierarchyLabelProvider_updatePending;
75
	public static String CallHierarchyLabelProvider_matches;
75
	public static String CallHierarchyLabelProvider_matches;
76
	public static String CallHierarchyPreferencePage_expand_with_constructors_title;
76
	public static String CallHierarchyViewPart_empty;
77
	public static String CallHierarchyViewPart_empty;
77
	public static String CallHierarchyViewPart_callsToConstructors;
78
	public static String CallHierarchyViewPart_callsToConstructors;
78
	public static String CallHierarchyViewPart_callsToField;
79
	public static String CallHierarchyViewPart_callsToField;
Lines 140-143 Link Here
140
141
141
	public static String CallHierarchyViewPart_layout_menu;
142
	public static String CallHierarchyViewPart_layout_menu;
142
	public static String CallHierarchyViewPart_field_menu;
143
	public static String CallHierarchyViewPart_field_menu;
144
	public static String CallHierarchyViewPart_preferences_label;
143
}
145
}
(-)ui/org/eclipse/jdt/internal/ui/callhierarchy/CallHierarchyMessages.properties (+2 lines)
Lines 70-75 Link Here
70
CallHierarchyLabelProvider_noMethodSelected=- no method selected -
70
CallHierarchyLabelProvider_noMethodSelected=- no method selected -
71
CallHierarchyLabelProvider_updatePending=...
71
CallHierarchyLabelProvider_updatePending=...
72
CallHierarchyLabelProvider_matches={0} ({1} matches)
72
CallHierarchyLabelProvider_matches={0} ({1} matches)
73
CallHierarchyPreferencePage_expand_with_constructors_title=Expand With Constructors
73
CallHierarchyViewPart_empty=To display the call hierarchy, select one or more methods, classes, fields, or initializers, and select the \'Open Call Hierarchy\' menu option. Alternatively, you can drag and drop the member or members onto this view.
74
CallHierarchyViewPart_empty=To display the call hierarchy, select one or more methods, classes, fields, or initializers, and select the \'Open Call Hierarchy\' menu option. Alternatively, you can drag and drop the member or members onto this view.
74
CallHierarchyViewPart_callsToConstructors=Members calling constructors of ''{0}'' - in {1}
75
CallHierarchyViewPart_callsToConstructors=Members calling constructors of ''{0}'' - in {1}
75
CallHierarchyViewPart_callsToField=Members accessing ''{0}'' - in {1}
76
CallHierarchyViewPart_callsToField=Members accessing ''{0}'' - in {1}
Lines 85-90 Link Here
85
CallHierarchyViewPart_callsFromMembers_3=Calls from ''{0}'', ''{1}'', ''{2}'' - in {3}
86
CallHierarchyViewPart_callsFromMembers_3=Calls from ''{0}'', ''{1}'', ''{2}'' - in {3}
86
CallHierarchyViewPart_callsFromMembers_more=Calls from ''{0}'', ''{1}'', ''{2}'', ... - in {3}
87
CallHierarchyViewPart_callsFromMembers_more=Calls from ''{0}'', ''{1}'', ''{2}'', ... - in {3}
87
CallHierarchyViewPart_callsFromMethod=Calls from ''{0}'' - in {1}
88
CallHierarchyViewPart_callsFromMethod=Calls from ''{0}'' - in {1}
89
CallHierarchyViewPart_preferences_label= Preferences...
88
FocusOnSelectionAction_focusOnSelection_text=Fo&cus On Selection
90
FocusOnSelectionAction_focusOnSelection_text=Fo&cus On Selection
89
FocusOnSelectionAction_focusOnSelection_description=Focus On Selection
91
FocusOnSelectionAction_focusOnSelection_description=Focus On Selection
90
FocusOnSelectionAction_focusOnSelection_tooltip=Focus On Selection
92
FocusOnSelectionAction_focusOnSelection_tooltip=Focus On Selection
(-)ui/org/eclipse/jdt/internal/ui/callhierarchy/CallHierarchyContentProvider.java (-36 / +18 lines)
Lines 53-70 Link Here
53
	 * 
53
	 * 
54
	 * @since 3.5
54
	 * @since 3.5
55
	 */
55
	 */
56
	public static final String PREF_DEFAULT_EXPAND_WITH_CONSTRUCTORS= "CallHierarchy.defaultExpandWithConstructors"; //$NON-NLS-1$
56
	public static final String CALL_HIERARCHY_PREFERENCES= "CallHierarchy.defaultExpandWithConstructors"; //$NON-NLS-1$
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
57
69
	private final static Object[] EMPTY_ARRAY= new Object[0];
58
	private final static Object[] EMPTY_ARRAY= new Object[0];
70
59
Lines 174-192 Link Here
174
	static void ensureDefaultExpandWithConstructors(CallerMethodWrapper wrapper) {
163
	static void ensureDefaultExpandWithConstructors(CallerMethodWrapper wrapper) {
175
164
176
		if (!wrapper.isExpandWithConstructorsSet()) {
165
		if (!wrapper.isExpandWithConstructorsSet()) {
177
			if (CallHierarchyContentProvider.canExpandWithConstructors(wrapper)) {
166
			if (canExpandWithConstructors(wrapper)) {
178
				IType type= wrapper.getMember().getDeclaringType();
167
				IType type= wrapper.getMember().getDeclaringType();
179
				try {
168
				try {
180
					boolean withConstructors= false;
169
					wrapper.setExpandWithConstructors(type != null && (type.isAnonymous() || isInTheDefaultExpandWithConstructorList(wrapper)));
181
					if (type != null) {
182
						boolean anonymousPref= PreferenceConstants.getPreferenceStore().getBoolean(PREF_ANONYMOUS_EXPAND_WITH_CONSTRUCTORS);
183
						if (anonymousPref && type.isAnonymous()) {
184
							withConstructors= true;
185
						} else if (isInTheDefaultExpandWithConstructorList(type)) {
186
							withConstructors= true;
187
						}
188
					}
189
					wrapper.setExpandWithConstructors(withConstructors);
190
				} catch (JavaModelException e) {
170
				} catch (JavaModelException e) {
191
					// ignore: expand mode will be off
171
					// ignore: expand mode will be off
192
				}
172
				}
Lines 215-237 Link Here
215
		}
195
		}
216
		return true;
196
		return true;
217
	}
197
	}
218
	
198
219
	/**
199
	/**
220
	 * Checks if declaring type matches the pre-defined array of types for default expand with
200
	 * Checks if the member or its declaring type matches the pre-defined array of members and types
221
	 * constructors.
201
	 * for default expand with constructors.
222
	 * 
202
	 * 
223
	 * @param type the declaring type of the caller method wrapper
203
	 * @param wrapper caller method wrapper
224
	 * @return <code>true</code> if type matches the pre-defined list, <code>false</code> otherwise
204
	 * @return <code>true</code> if method or type matches the pre-defined list, <code>false</code>
205
	 *         otherwise
225
	 * @since 3.5
206
	 * @since 3.5
226
	 */
207
	 */
227
	static boolean isInTheDefaultExpandWithConstructorList(IType type) {
208
	static boolean isInTheDefaultExpandWithConstructorList(CallerMethodWrapper wrapper) {
228
		String serializedTypes= PreferenceConstants.getPreferenceStore().getString(PREF_DEFAULT_EXPAND_WITH_CONSTRUCTORS);
209
		String storedTypes= (PreferenceConstants.getPreferenceStore().getString(CALL_HIERARCHY_PREFERENCES));
229
		if (serializedTypes.length() == 0)
210
		if (storedTypes.length() == 0)
230
			return false;
211
			return false;
212
		String member= wrapper.getMember().getElementName();
213
		IType type= wrapper.getMember().getDeclaringType();
214
		String[] defaultTypes= storedTypes.split(";"); //$NON-NLS-1$
231
		
215
		
232
		String[] defaultTypes= serializedTypes.split(";"); //$NON-NLS-1$
216
		String typeName= type.getFullyQualifiedName('.').concat(".*"); //$NON-NLS-1$
233
		
234
		String typeName= type.getFullyQualifiedName('.');
235
		String superClass;
217
		String superClass;
236
		String[] superInterfaces;
218
		String[] superInterfaces;
237
		try {
219
		try {
Lines 242-253 Link Here
242
		}
224
		}
243
		for (int i= 0; i < defaultTypes.length; i++) {
225
		for (int i= 0; i < defaultTypes.length; i++) {
244
			String defaultType= defaultTypes[i];
226
			String defaultType= defaultTypes[i];
245
			if (typeName.equals(defaultType) || (superClass != null && typeNameMatches(superClass, defaultType))) {
227
			if (typeNameMatches(member, defaultType) || typeName.equals(defaultType) || (superClass != null && typeNameMatches(superClass.concat(".*"), defaultType))) { //$NON-NLS-1$
246
				return true;
228
				return true;
247
			}
229
			}
248
			if (superInterfaces.length > 0) {
230
			if (superInterfaces.length > 0) {
249
				for (int j= 0; j < superInterfaces.length; j++) {
231
				for (int j= 0; j < superInterfaces.length; j++) {
250
					if (typeNameMatches(superInterfaces[j], defaultType))
232
					if (typeNameMatches(superInterfaces[j].concat(".*"), defaultType)) //$NON-NLS-1$
251
						return true;
233
						return true;
252
				}
234
				}
253
			}
235
			}
(-)ui/org/eclipse/jdt/internal/ui/callhierarchy/CallHierarchyViewPart.java (-1 / +3 lines)
Lines 235-240 Link Here
235
    private boolean fShowCallDetails;
235
    private boolean fShowCallDetails;
236
	protected Composite fParent;
236
	protected Composite fParent;
237
	private IPartListener2 fPartListener;
237
	private IPartListener2 fPartListener;
238
	private PreferencesActionGroup fPreferences;
238
239
239
240
240
    public CallHierarchyViewPart() {
241
    public CallHierarchyViewPart() {
Lines 1000-1005 Link Here
1000
        fSearchScopeActions = new SearchScopeActionGroup(this, fDialogSettings);
1001
        fSearchScopeActions = new SearchScopeActionGroup(this, fDialogSettings);
1001
        fFiltersActionGroup = new CallHierarchyFiltersActionGroup(this,
1002
        fFiltersActionGroup = new CallHierarchyFiltersActionGroup(this,
1002
                fCallHierarchyViewer);
1003
                fCallHierarchyViewer);
1004
        fPreferences= new PreferencesActionGroup(this);
1003
        fHistoryDropDownAction = new HistoryDropDownAction(this);
1005
        fHistoryDropDownAction = new HistoryDropDownAction(this);
1004
        fHistoryDropDownAction.setEnabled(false);
1006
        fHistoryDropDownAction.setEnabled(false);
1005
        fCancelSearchAction = new CancelSearchAction(this);
1007
        fCancelSearchAction = new CancelSearchAction(this);
Lines 1027-1033 Link Here
1027
                    new GenerateActionGroup(this),
1029
                    new GenerateActionGroup(this),
1028
                    new RefactorActionGroup(this),
1030
                    new RefactorActionGroup(this),
1029
                    new JavaSearchActionGroup(this),
1031
                    new JavaSearchActionGroup(this),
1030
                    fSearchScopeActions, fFiltersActionGroup
1032
                    fSearchScopeActions, fFiltersActionGroup, fPreferences
1031
                });
1033
                });
1032
    }
1034
    }
1033
1035
(-)ui/org/eclipse/jdt/internal/ui/preferences/PreferencesMessages.properties (-1 / +20 lines)
Lines 1-5 Link Here
1
###############################################################################
1
###############################################################################
2
# Copyright (c) 2000, 2008 IBM Corporation and others.
2
# Copyright (c) 2000, 2009 IBM Corporation and others.
3
# All rights reserved. This program and the accompanying materials
3
# All rights reserved. This program and the accompanying materials
4
# are made available under the terms of the Eclipse Public License v1.0
4
# are made available under the terms of the Eclipse Public License v1.0
5
# which accompanies this distribution, and is available at
5
# which accompanies this distribution, and is available at
Lines 923-928 Link Here
923
CodeAssistStaticMembersConfigurationBlock_edit_button= &Edit
923
CodeAssistStaticMembersConfigurationBlock_edit_button= &Edit
924
CodeAssistStaticMembersConfigurationBlock_remove_button= &Remove
924
CodeAssistStaticMembersConfigurationBlock_remove_button= &Remove
925
925
926
CallHierarchyPreferencesConfigurationBlock_description= De&fine a list of members or types with their fully qualified names.Call Hierarchy for these types/members will "Expand With Constructors" by default.
927
CallHierarchyPreferencesConfigurationBlock_newType_button= New &Type...
928
CallHierarchyPreferencesConfigurationBlock_newMember_button= New &Member...
929
CallHierarchyPreferencesConfigurationBlock_edit_button= &Edit
930
CallHierarchyPreferencesConfigurationBlock_remove_button= &Remove 
931
932
CallHierarchyPreferencesDialog_member_title= New Member for Expand With Constructors
933
CallHierarchyPreferencesDialog_member_labelText= Enter a fully qualified static member (e.g. \'java.lang.Math.sqrt\'): 
934
CallHierarchyPreferencesDialog_type_title= New Type for Expand With Constructors
935
CallHierarchyPreferencesDialog_type_labelText= Enter a fully qualified type (e.g. \'java.lang.Math\'):
936
CallHierarchyPreferencesDialog_browse_button= &Browse...
937
CallHierarchyPreferencesDialog_ChooseTypeDialog_title= Type Selection
938
CallHierarchyPreferencesDialog_ChooseTypeDialog_description= Choose type name:
939
CallHierarchyPreferencesDialog_ChooseTypeDialog_error_message= A problem occurred while collecting types. See the error Log for details.
940
CallHierarchyPreferencesDialog_error_enterName=Enter a name or prefix.
941
CallHierarchyPreferencesDialog_error_invalidTypeName=Not a valid type name.
942
CallHierarchyPreferencesDialog_error_invalidMemberName=Not a valid member name.
943
CallHierarchyPreferencesDialog_error_entryExists=Entry already exists in list.
944
926
FavoriteStaticMemberInputDialog_member_title= New Member Favorite
945
FavoriteStaticMemberInputDialog_member_title= New Member Favorite
927
FavoriteStaticMemberInputDialog_member_labelText= Enter a fully qualified static member (e.g. \'java.lang.Math.sqrt\'): 
946
FavoriteStaticMemberInputDialog_member_labelText= Enter a fully qualified static member (e.g. \'java.lang.Math.sqrt\'): 
928
FavoriteStaticMemberInputDialog_type_title= New Type Favorite 
947
FavoriteStaticMemberInputDialog_type_title= New Type Favorite 
(-)ui/org/eclipse/jdt/internal/ui/preferences/PreferencesMessages.java (+20 lines)
Lines 807-812 Link Here
807
	public static String CodeAssistStaticMembersConfigurationBlock_newMember_button;
807
	public static String CodeAssistStaticMembersConfigurationBlock_newMember_button;
808
	public static String CodeAssistStaticMembersConfigurationBlock_edit_button;
808
	public static String CodeAssistStaticMembersConfigurationBlock_edit_button;
809
	public static String CodeAssistStaticMembersConfigurationBlock_remove_button;
809
	public static String CodeAssistStaticMembersConfigurationBlock_remove_button;
810
	
811
	public static String CallHierarchyPreferencesConfigurationBlock_description;
812
	public static String CallHierarchyPreferencesConfigurationBlock_newType_button;
813
	public static String CallHierarchyPreferencesConfigurationBlock_newMember_button;
814
	public static String CallHierarchyPreferencesConfigurationBlock_edit_button;
815
	public static String CallHierarchyPreferencesConfigurationBlock_remove_button;
810
816
811
	public static String FavoriteStaticMemberInputDialog_member_title;
817
	public static String FavoriteStaticMemberInputDialog_member_title;
812
	public static String FavoriteStaticMemberInputDialog_member_labelText;
818
	public static String FavoriteStaticMemberInputDialog_member_labelText;
Lines 820-824 Link Here
820
	public static String FavoriteStaticMemberInputDialog_error_invalidMemberName;
826
	public static String FavoriteStaticMemberInputDialog_error_invalidMemberName;
821
	public static String FavoriteStaticMemberInputDialog_error_invalidTypeName;
827
	public static String FavoriteStaticMemberInputDialog_error_invalidTypeName;
822
	public static String FavoriteStaticMemberInputDialog_error_entryExists;
828
	public static String FavoriteStaticMemberInputDialog_error_entryExists;
829
	
830
	public static String CallHierarchyPreferencesDialog_member_title;
831
	public static String CallHierarchyPreferencesDialog_member_labelText;
832
	public static String CallHierarchyPreferencesDialog_type_title;
833
	public static String CallHierarchyPreferencesDialog_type_labelText;
834
	public static String CallHierarchyPreferencesDialog_browse_button;
835
	public static String CallHierarchyPreferencesDialog_ChooseTypeDialog_title;
836
	public static String CallHierarchyPreferencesDialog_ChooseTypeDialog_description;
837
	public static String CallHierarchyPreferencesDialog_ChooseTypeDialog_error_message;
838
	public static String CallHierarchyPreferencesDialog_error_enterName;
839
	public static String CallHierarchyPreferencesDialog_error_invalidMemberName;
840
	public static String CallHierarchyPreferencesDialog_error_invalidTypeName;
841
	public static String CallHierarchyPreferencesDialog_error_entryExists;
842
	
823
843
824
}
844
}
(-)ui/org/eclipse/jdt/ui/PreferenceConstants.java (+9 lines)
Lines 43-48 Link Here
43
43
44
import org.eclipse.jdt.internal.ui.JavaPlugin;
44
import org.eclipse.jdt.internal.ui.JavaPlugin;
45
import org.eclipse.jdt.internal.ui.JavaUIPreferenceInitializer;
45
import org.eclipse.jdt.internal.ui.JavaUIPreferenceInitializer;
46
import org.eclipse.jdt.internal.ui.callhierarchy.CallHierarchyContentProvider;
46
import org.eclipse.jdt.internal.ui.javaeditor.SemanticHighlightings;
47
import org.eclipse.jdt.internal.ui.javaeditor.SemanticHighlightings;
47
import org.eclipse.jdt.internal.ui.preferences.NewJavaProjectPreferencePage;
48
import org.eclipse.jdt.internal.ui.preferences.NewJavaProjectPreferencePage;
48
import org.eclipse.jdt.internal.ui.preferences.formatter.FormatterProfileManager;
49
import org.eclipse.jdt.internal.ui.preferences.formatter.FormatterProfileManager;
Lines 2976-2981 Link Here
2976
	 */
2977
	 */
2977
	public final static String CODEASSIST_FAVORITE_STATIC_MEMBERS= "content_assist_favorite_static_members"; //$NON-NLS-1$
2978
	public final static String CODEASSIST_FAVORITE_STATIC_MEMBERS= "content_assist_favorite_static_members"; //$NON-NLS-1$
2978
2979
2980
	/**
2981
	 * A named preference that holds the types/members which expand with constructors by default.
2982
	 * 
2983
	 * @since 3.5
2984
	 */
2985
	public static final String CALL_HIERARCHY_PREFERENCES= "call_hierarchy_preferences_page"; //$NON-NLS-1$
2986
2979
2987
2980
	/**
2988
	/**
2981
	 * A named preference that controls the behavior of the refactoring wizard for showing the error page.
2989
	 * A named preference that controls the behavior of the refactoring wizard for showing the error page.
Lines 3832-3837 Link Here
3832
3841
3833
		store.setDefault(PreferenceConstants.PROPERTIES_FILE_COLORING_COMMENT_BOLD, false);
3842
		store.setDefault(PreferenceConstants.PROPERTIES_FILE_COLORING_COMMENT_BOLD, false);
3834
		store.setDefault(PreferenceConstants.PROPERTIES_FILE_COLORING_COMMENT_ITALIC, false);
3843
		store.setDefault(PreferenceConstants.PROPERTIES_FILE_COLORING_COMMENT_ITALIC, false);
3844
		store.setDefault(CallHierarchyContentProvider.CALL_HIERARCHY_PREFERENCES, "java.lang.Runnable;java.util.concurrent.Callable;org.eclipse.swt.widgets.Listener"); //$NON-NLS-1$
3835
3845
3836
		// semantic highlighting
3846
		// semantic highlighting
3837
		SemanticHighlightings.initDefaults(store);
3847
		SemanticHighlightings.initDefaults(store);
(-)ui/org/eclipse/jdt/internal/ui/callhierarchy/PreferencesActionGroup.java (+82 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 org.eclipse.jface.action.Action;
13
import org.eclipse.jface.action.IMenuManager;
14
import org.eclipse.jface.action.Separator;
15
import org.eclipse.jface.preference.IPreferenceNode;
16
import org.eclipse.jface.preference.PreferenceDialog;
17
import org.eclipse.jface.preference.PreferenceManager;
18
import org.eclipse.jface.preference.PreferenceNode;
19
20
import org.eclipse.ui.IActionBars;
21
import org.eclipse.ui.actions.ActionGroup;
22
23
/**
24
 * Call Hierarchy preferences action group.
25
 * 
26
 * @since 3.5
27
 * 
28
 */
29
public class PreferencesActionGroup extends ActionGroup {
30
	private CallHierarchyViewPart fPart;
31
32
	public PreferencesActionGroup(CallHierarchyViewPart part) {
33
		fPart= part;
34
	}
35
	
36
	/**
37
	 * Call hierarchy preferences action class.
38
	 * 
39
	 * @since 3.5
40
	 * 
41
	 */
42
	public class CallHierarchyPreferencesAction extends Action {
43
44
		/**
45
		 * Creates the call hierarchy preference action.
46
		 */
47
		public CallHierarchyPreferencesAction() {
48
			setText(CallHierarchyMessages.CallHierarchyViewPart_preferences_label);
49
		}
50
51
		/* (non-Javadoc)
52
		 * @see org.eclipse.jface.action.Action#run()
53
		 */
54
		public void run() {
55
			CallHierarchyPreferencePage page= new CallHierarchyPreferencePage();
56
			IPreferenceNode targetNode= new PreferenceNode("org.eclipse.jdt.ui.preferences.CallHierarchyPreferencePage", page); //$NON-NLS-1$
57
			PreferenceManager manager= new PreferenceManager();
58
			manager.addToRoot(targetNode);
59
			PreferenceDialog dialog= new PreferenceDialog(fPart.getSite().getShell(), manager);
60
			dialog.create();
61
			dialog.open();
62
		}
63
	}
64
	
65
	
66
	/* (non-Javadoc)
67
     * Method declared on ActionGroup.
68
     */
69
    public void fillActionBars(IActionBars actionBars) {
70
        fillViewMenu(actionBars.getMenuManager());
71
    }
72
73
	/* (non-Javadoc)
74
	 * Method declared on ActionGroup.
75
	 */
76
    private void fillViewMenu(IMenuManager viewMenu) {
77
		viewMenu.add(new Separator("preferences")); //$NON-NLS-1$
78
		viewMenu.add(new CallHierarchyPreferencesAction());
79
    }
80
	
81
82
}
(-)ui/org/eclipse/jdt/internal/ui/callhierarchy/CallHierarchyPreferencesConfigurationBlock.java (+597 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.graphics.Image;
18
import org.eclipse.swt.graphics.Point;
19
import org.eclipse.swt.layout.GridData;
20
import org.eclipse.swt.layout.GridLayout;
21
import org.eclipse.swt.widgets.Composite;
22
import org.eclipse.swt.widgets.Control;
23
import org.eclipse.swt.widgets.Shell;
24
import org.eclipse.swt.widgets.Text;
25
26
import org.eclipse.core.runtime.Assert;
27
import org.eclipse.core.runtime.IStatus;
28
29
import org.eclipse.jface.dialogs.Dialog;
30
import org.eclipse.jface.dialogs.StatusDialog;
31
import org.eclipse.jface.layout.PixelConverter;
32
import org.eclipse.jface.operation.IRunnableContext;
33
import org.eclipse.jface.viewers.LabelProvider;
34
import org.eclipse.jface.viewers.ViewerComparator;
35
import org.eclipse.jface.window.Window;
36
37
import org.eclipse.ui.PlatformUI;
38
import org.eclipse.ui.dialogs.SelectionDialog;
39
import org.eclipse.ui.preferences.IWorkbenchPreferenceContainer;
40
41
import org.eclipse.jdt.core.IType;
42
import org.eclipse.jdt.core.JavaConventions;
43
import org.eclipse.jdt.core.JavaCore;
44
import org.eclipse.jdt.core.JavaModelException;
45
import org.eclipse.jdt.core.search.IJavaSearchScope;
46
import org.eclipse.jdt.core.search.SearchEngine;
47
48
import org.eclipse.jdt.ui.IJavaElementSearchConstants;
49
import org.eclipse.jdt.ui.JavaUI;
50
import org.eclipse.jdt.ui.PreferenceConstants;
51
52
import org.eclipse.jdt.internal.ui.IJavaHelpContextIds;
53
import org.eclipse.jdt.internal.ui.JavaPluginImages;
54
import org.eclipse.jdt.internal.ui.dialogs.StatusInfo;
55
import org.eclipse.jdt.internal.ui.dialogs.TextFieldNavigationHandler;
56
import org.eclipse.jdt.internal.ui.preferences.OptionsConfigurationBlock;
57
import org.eclipse.jdt.internal.ui.preferences.PreferencesMessages;
58
import org.eclipse.jdt.internal.ui.preferences.ScrolledPageContent;
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 preferences page configuration block.
74
 * 
75
 * @since 3.5 *
76
 */
77
public class CallHierarchyPreferencesConfigurationBlock extends OptionsConfigurationBlock {
78
79
	/**
80
	 * Call hierarchy preferences dialog for types and members.
81
	 */
82
	private static class CallHierarchyPreferencesDialog extends StatusDialog {
83
84
		private class StringButtonAdapter implements IDialogFieldListener, IStringButtonAdapter {
85
			/*
86
			 * @see IDialogFieldListener#dialogFieldChanged(DialogField)
87
			 */
88
			public void dialogFieldChanged(DialogField field) {
89
				doValidation();
90
			}
91
92
			/*
93
			 * @see IStringButtonAdapter#changeControlPressed(DialogField)
94
			 */
95
			public void changeControlPressed(DialogField field) {
96
				doBrowseTypes();
97
			}
98
		}
99
100
		private StringButtonDialogField fNameDialogField;
101
102
		private List fExistingEntries;
103
104
		private final boolean fIsEditingMember;
105
106
		/**
107
		 * Creates a call hierarchy preference dialog for members or types.
108
		 * 
109
		 * @param parent the parent shell
110
		 * @param existingEntries the existing list of types and members
111
		 * @param isEditingMember <code>true</code if its a member, <code>false</code> otherwise
112
		 */
113
		public CallHierarchyPreferencesDialog(Shell parent, List existingEntries, boolean isEditingMember) {
114
			super(parent);
115
			fIsEditingMember= isEditingMember;
116
			fExistingEntries= existingEntries;
117
118
			String label, title;
119
			if (isEditingMember) {
120
				title= PreferencesMessages.CallHierarchyPreferencesDialog_member_title;
121
				label= PreferencesMessages.CallHierarchyPreferencesDialog_member_labelText;
122
			} else {
123
				title= PreferencesMessages.CallHierarchyPreferencesDialog_type_title;
124
				label= PreferencesMessages.CallHierarchyPreferencesDialog_type_labelText;
125
			}
126
			setTitle(title);
127
128
			StringButtonAdapter adapter= new StringButtonAdapter();
129
130
			fNameDialogField= new StringButtonDialogField(adapter);
131
			fNameDialogField.setLabelText(label);
132
			fNameDialogField.setButtonLabel(PreferencesMessages.CallHierarchyPreferencesDialog_browse_button);
133
			fNameDialogField.setDialogFieldListener(adapter);
134
			fNameDialogField.setText(""); //$NON-NLS-1$
135
		}
136
137
		/*
138
		 * @see org.eclipse.jface.dialogs.Dialog#isResizable()
139
		 * @since 3.4
140
		 */
141
		protected boolean isResizable() {
142
			return true;
143
		}
144
145
		/**
146
		 * Sets the initial selection in the name dialog field.
147
		 * 
148
		 * @param editedEntry the edited entry
149
		 */
150
		public void setInitialSelection(String editedEntry) {
151
			Assert.isNotNull(editedEntry);
152
			if (editedEntry.length() == 0)
153
				fNameDialogField.setText(""); //$NON-NLS-1$
154
			else
155
				fNameDialogField.setText(editedEntry);
156
		}
157
158
		public String getResult() {
159
			String val= fNameDialogField.getText();
160
			if (!fIsEditingMember)
161
				val= val + WILDCARD;
162
			return val;
163
		}
164
165
		/* (non-Javadoc)
166
		 * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
167
		 */
168
		protected Control createDialogArea(Composite parent) {
169
			Composite composite= (Composite)super.createDialogArea(parent);
170
			initializeDialogUnits(parent);
171
172
			GridLayout layout= (GridLayout)composite.getLayout();
173
			layout.numColumns= 2;
174
175
			fNameDialogField.doFillIntoGrid(composite, 3);
176
177
			fNameDialogField.getChangeControl(null).setVisible(!fIsEditingMember);
178
179
			LayoutUtil.setHorizontalSpan(fNameDialogField.getLabelControl(null), 2);
180
181
			int fieldWidthHint= convertWidthInCharsToPixels(60);
182
			Text text= fNameDialogField.getTextControl(null);
183
			LayoutUtil.setWidthHint(text, fieldWidthHint);
184
			LayoutUtil.setHorizontalGrabbing(text);
185
			LayoutUtil.setHorizontalSpan(text, fIsEditingMember ? 2 : 1);
186
			TextFieldNavigationHandler.install(text);
187
188
			DialogField.createEmptySpace(composite, 1);
189
190
			fNameDialogField.postSetFocusOnDialogField(parent.getDisplay());
191
192
193
			applyDialogFont(composite);
194
			return composite;
195
		}
196
197
		/**
198
		 * Creates the type hierarchy for type selection.
199
		 */
200
		private void doBrowseTypes() {
201
			IRunnableContext context= new BusyIndicatorRunnableContext();
202
			IJavaSearchScope scope= SearchEngine.createWorkspaceScope();
203
			int style= IJavaElementSearchConstants.CONSIDER_ALL_TYPES;
204
			try {
205
				SelectionDialog dialog= JavaUI.createTypeDialog(getShell(), context, scope, style, false, fNameDialogField.getText());
206
				dialog.setTitle(PreferencesMessages.CallHierarchyPreferencesDialog_ChooseTypeDialog_title);
207
				dialog.setMessage(PreferencesMessages.CallHierarchyPreferencesDialog_ChooseTypeDialog_description);
208
				if (dialog.open() == Window.OK) {
209
					IType res= (IType)dialog.getResult()[0];
210
					fNameDialogField.setText(res.getFullyQualifiedName('.'));
211
				}
212
			} catch (JavaModelException e) {
213
				ExceptionHandler.handle(e, getShell(), PreferencesMessages.CallHierarchyPreferencesDialog_ChooseTypeDialog_title,
214
						PreferencesMessages.CallHierarchyPreferencesDialog_ChooseTypeDialog_error_message);
215
			}
216
		}
217
218
		/**
219
		 * Validates the entered type or member adn updates the status.
220
		 */
221
		private void doValidation() {
222
			StatusInfo status= new StatusInfo();
223
			String newText= fNameDialogField.getText();
224
			if (newText.length() == 0) {
225
				status.setError(""); //$NON-NLS-1$
226
			} else {
227
				IStatus val= JavaConventions.validateJavaTypeName(newText, JavaCore.VERSION_1_3, JavaCore.VERSION_1_3);
228
				if (val.matches(IStatus.ERROR)) {
229
					if (fIsEditingMember)
230
						status.setError(PreferencesMessages.CallHierarchyPreferencesDialog_error_invalidMemberName);
231
					else
232
						status.setError(PreferencesMessages.CallHierarchyPreferencesDialog_error_invalidTypeName);
233
				} else {
234
					if (doesExist(newText)) {
235
						status.setError(PreferencesMessages.CallHierarchyPreferencesDialog_error_entryExists);
236
					}
237
				}
238
			}
239
			updateStatus(status);
240
		}
241
242
		/**
243
		 * Checks if the entry already exists.
244
		 * 
245
		 * @param name the type or member name
246
		 * @return <code>true</code> if it already exists in the list of types and members,
247
		 *         <code>false</code> otherwise
248
		 */
249
		private boolean doesExist(String name) {
250
			for (int i= 0; i < fExistingEntries.size(); i++) {
251
				String entry= (String)fExistingEntries.get(i);
252
				if (name.equals(entry)) {
253
					return true;
254
				}
255
			}
256
			return false;
257
		}
258
259
260
		/*
261
		 * @see org.eclipse.jface.window.Window#configureShell(Shell)
262
		 */
263
		protected void configureShell(Shell newShell) {
264
			super.configureShell(newShell);
265
			PlatformUI.getWorkbench().getHelpSystem().setHelp(newShell, IJavaHelpContextIds.JAVA_EDITOR_PREFERENCE_PAGE);
266
		}
267
268
	}
269
270
	/**
271
	 * The list label provider class.
272
	 */
273
	private static class ListLabelProvider extends LabelProvider {
274
275
		public final Image MEMBER_ICON;
276
277
		private final Image CLASS_ICON;
278
279
		public ListLabelProvider() {
280
			MEMBER_ICON= JavaElementImageProvider.getDecoratedImage(JavaPluginImages.DESC_MISC_PUBLIC, 0, JavaElementImageProvider.SMALL_SIZE);
281
			CLASS_ICON= JavaElementImageProvider.getDecoratedImage(JavaPluginImages.DESC_OBJS_CLASS, 0, JavaElementImageProvider.SMALL_SIZE);
282
		}
283
284
		/* (non-Javadoc)
285
		 * @see org.eclipse.jface.viewers.LabelProvider#getImage(java.lang.Object)
286
		 */
287
		public Image getImage(Object element) {
288
			return ((String)element).endsWith(WILDCARD) ? CLASS_ICON : MEMBER_ICON;
289
		}
290
291
		/* (non-Javadoc)
292
		 * @see org.eclipse.jface.viewers.LabelProvider#getText(java.lang.Object)
293
		 */
294
		public String getText(Object element) {
295
			return BasicElementLabels.getJavaElementName((String)element);
296
		}
297
	}
298
299
300
	/**
301
	 * The change listener for <code>ListDialogField</code>.
302
	 */
303
	private class ListAdapter implements IListAdapter, IDialogFieldListener {
304
305
		/**
306
		 * Checks if field can be edited.
307
		 * 
308
		 * @param field the list dialog field
309
		 * @return <code>true</code> if it can be edited, <code>false</code> otherwise
310
		 */
311
		private boolean canEdit(ListDialogField field) {
312
			List selected= field.getSelectedElements();
313
			return selected.size() == 1 && canRemove(field);
314
		}
315
316
		/* (non-Javadoc)
317
		 * @see org.eclipse.jdt.internal.ui.wizards.dialogfields.IListAdapter#customButtonPressed(org.eclipse.jdt.internal.ui.wizards.dialogfields.ListDialogField, int)
318
		 */
319
		public void customButtonPressed(ListDialogField field, int index) {
320
			doButtonPressed(index);
321
		}
322
323
		/* (non-Javadoc)
324
		 * @see org.eclipse.jdt.internal.ui.wizards.dialogfields.IListAdapter#selectionChanged(org.eclipse.jdt.internal.ui.wizards.dialogfields.ListDialogField)
325
		 */
326
		public void selectionChanged(ListDialogField field) {
327
			fList.enableButton(IDX_EDIT, canEdit(field));
328
			fList.enableButton(IDX_REMOVE, canRemove(field));
329
		}
330
331
		/**
332
		 * Checks if the field can be removed.
333
		 * 
334
		 * @param field the list dialog field
335
		 * @return <code>true</code> if it can be removed, <code>false</code> otherwise
336
		 */
337
		private boolean canRemove(ListDialogField field) {
338
			List selected= field.getSelectedElements();
339
			for (int j= 0; j < defaultTypes.length; j++) {
340
				if (selected.contains(defaultTypes[j]))
341
					return false;
342
			}
343
			return true;
344
		}
345
346
		/* (non-Javadoc)
347
		 * @see org.eclipse.jdt.internal.ui.wizards.dialogfields.IDialogFieldListener#dialogFieldChanged(org.eclipse.jdt.internal.ui.wizards.dialogfields.DialogField)
348
		 */
349
		public void dialogFieldChanged(DialogField field) {
350
			doDialogFieldChanged(field);
351
		}
352
353
		/* (non-Javadoc)
354
		 * @see org.eclipse.jdt.internal.ui.wizards.dialogfields.IListAdapter#doubleClicked(org.eclipse.jdt.internal.ui.wizards.dialogfields.ListDialogField)
355
		 */
356
		public void doubleClicked(ListDialogField field) {
357
			if (canEdit(field)) {
358
				doButtonPressed(IDX_EDIT);
359
			}
360
		}
361
	}
362
363
	/**
364
	 * A named preference key that holds the types whose methods are by default expanded with
365
	 * constructors in the Call Hierarchy.
366
	 * 
367
	 * @since 3.5
368
	 */
369
	public static final Key CALL_HIERARCHY_PREFERENCES= getJDTUIKey(PreferenceConstants.CALL_HIERARCHY_PREFERENCES);
370
	
371
	private static final String WILDCARD= ".*"; //$NON-NLS-1$
372
373
	private static final int IDX_NEW_TYPE= 0;
374
	private static final int IDX_NEW_MEMBER= 1;
375
	private static final int IDX_EDIT= 2;
376
	private static final int IDX_REMOVE= 3;
377
378
	private ListDialogField fList;
379
380
	/**
381
	 * The array of types for default expand with constructors.
382
	 */
383
	String[] defaultTypes= { "java.lang.Runnable.*", "java.util.concurrent.Callable.*", "org.eclipse.swt.widgets.Listener.*" }; //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
384
385
	/**
386
	 * Returns all the key values.
387
	 * 
388
	 * @return array of keys
389
	 */
390
	public static Key[] getAllKeys() {
391
		return new Key[] { CALL_HIERARCHY_PREFERENCES };
392
	}
393
394
395
	/**
396
	 * Creates the call hierarchy preferences configuration block.
397
	 * 
398
	 * @param context the status
399
	 * @param container the preference container
400
	 */
401
	public CallHierarchyPreferencesConfigurationBlock(IStatusChangeListener context, IWorkbenchPreferenceContainer container) {
402
		super(context, null, getAllKeys(), container);
403
	}
404
405
	/* (non-Javadoc)
406
	 * @see org.eclipse.jdt.internal.ui.preferences.OptionsConfigurationBlock#createContents(org.eclipse.swt.widgets.Composite)
407
	 */
408
	protected Control createContents(Composite parent) {
409
		ScrolledPageContent scrolled= new ScrolledPageContent(parent, SWT.H_SCROLL | SWT.V_SCROLL);
410
		scrolled.setExpandHorizontal(true);
411
		scrolled.setExpandVertical(true);
412
413
		Composite control= new Composite(scrolled, SWT.NONE);
414
		GridLayout layout= new GridLayout();
415
		layout.numColumns= 2;
416
		layout.marginWidth= 0;
417
		layout.marginHeight= 0;
418
		control.setLayout(layout);
419
420
		createFavoriteList(control);
421
422
		initialize();
423
424
		scrolled.setContent(control);
425
		final Point size= control.computeSize(SWT.DEFAULT, SWT.DEFAULT);
426
		scrolled.setMinSize(size.x, size.y);
427
428
		Dialog.applyDialogFont(scrolled);
429
430
		return scrolled;
431
	}
432
433
	/**
434
	 * Create a list dialog field.
435
	 * 
436
	 * @param parent the composite
437
	 */
438
	private void createFavoriteList(Composite parent) {
439
		String[] buttonLabels= new String[] {
440
				PreferencesMessages.CallHierarchyPreferencesConfigurationBlock_newType_button,
441
				PreferencesMessages.CallHierarchyPreferencesConfigurationBlock_newMember_button,
442
				PreferencesMessages.CallHierarchyPreferencesConfigurationBlock_edit_button,
443
				PreferencesMessages.CallHierarchyPreferencesConfigurationBlock_remove_button
444
				};
445
446
		ListAdapter adapter= new ListAdapter();
447
448
		fList= new ListDialogField(adapter, buttonLabels, new ListLabelProvider());
449
		fList.setDialogFieldListener(adapter);
450
		fList.setLabelText(PreferencesMessages.CallHierarchyPreferencesConfigurationBlock_description);
451
		fList.setRemoveButtonIndex(IDX_REMOVE);
452
		fList.enableButton(IDX_EDIT, false);
453
		fList.setViewerComparator(new ViewerComparator());
454
455
		PixelConverter pixelConverter= new PixelConverter(parent);
456
457
		fList.doFillIntoGrid(parent, 3);
458
		LayoutUtil.setHorizontalSpan(fList.getLabelControl(null), 2);
459
		LayoutUtil.setWidthHint(fList.getLabelControl(null), pixelConverter.convertWidthInCharsToPixels(60));
460
		LayoutUtil.setHorizontalGrabbing(fList.getListControl(null));
461
462
		Control listControl= fList.getListControl(null);
463
		GridData gd= (GridData)listControl.getLayoutData();
464
		gd.verticalAlignment= GridData.BEGINNING;
465
		gd.heightHint= pixelConverter.convertHeightInCharsToPixels(7);
466
467
	}
468
469
	/**
470
	 * Initialize the elements of the list dialog field.
471
	 */
472
	public void initialize() {
473
		initializeFields();
474
	}
475
476
	/**
477
	 * Initialize the elements of the list dialog field.
478
	 */
479
	private void initializeFields() {
480
		List storedPreference= new ArrayList();
481
		storedPreference.addAll(Arrays.asList(getCallHierarchyPreferences()));
482
		if (!storedPreference.contains(defaultTypes[0])) {
483
			storedPreference.addAll(Arrays.asList(defaultTypes));
484
		}
485
		fList.setElements(storedPreference);
486
	}
487
488
	/* (non-Javadoc)
489
	 * @see org.eclipse.jdt.internal.ui.preferences.OptionsConfigurationBlock#performDefaults()
490
	 */
491
	public void performDefaults() {
492
		super.performDefaults();
493
		fList.setElements(Arrays.asList(defaultTypes));
494
	}
495
496
	/* (non-Javadoc)
497
	 * @see org.eclipse.jdt.internal.ui.preferences.OptionsConfigurationBlock#getFullBuildDialogStrings(boolean)
498
	 */
499
	protected String[] getFullBuildDialogStrings(boolean workspaceSettings) {
500
		return null;
501
	}
502
503
	/* (non-Javadoc)
504
	 * @see org.eclipse.jdt.internal.ui.preferences.OptionsConfigurationBlock#validateSettings(org.eclipse.jdt.internal.ui.preferences.OptionsConfigurationBlock.Key, java.lang.String, java.lang.String)
505
	 */
506
	protected void validateSettings(Key changedKey, String oldValue, String newValue) {
507
508
	}
509
510
	/**
511
	 * Perform the 'New' and 'Edit' button operations by opening the respective call hierarchy
512
	 * preferences dialog.
513
	 * 
514
	 * @param index the index of the button
515
	 */
516
	private void doButtonPressed(int index) {
517
		if (index == IDX_NEW_TYPE || index == IDX_NEW_MEMBER) { // add new
518
			List existing= fList.getElements();
519
			CallHierarchyPreferencesDialog dialog= new CallHierarchyPreferencesDialog(getShell(), existing, index == IDX_NEW_MEMBER);
520
			if (dialog.open() == Window.OK) {
521
				fList.addElement(dialog.getResult());
522
			}
523
		} else if (index == IDX_EDIT) { // edit
524
			List selected= fList.getSelectedElements();
525
			if (selected.isEmpty())
526
				return;
527
528
			String editedEntry= (String)selected.get(0);
529
530
			List existing= fList.getElements();
531
			existing.remove(editedEntry);
532
			boolean isType= editedEntry.endsWith(WILDCARD);
533
			CallHierarchyPreferencesDialog dialog= new CallHierarchyPreferencesDialog(getShell(), existing, !isType);
534
			if (isType)
535
				dialog.setInitialSelection(editedEntry.substring(0, editedEntry.length() - 2));
536
			else
537
				dialog.setInitialSelection(editedEntry);
538
539
			if (dialog.open() == Window.OK) {
540
				fList.replaceElement(editedEntry, dialog.getResult());
541
			}
542
		}
543
	}
544
545
	/**
546
	 * Update the preference keys and constants.
547
	 * 
548
	 * @param field the dialog field
549
	 */
550
	protected final void doDialogFieldChanged(DialogField field) {
551
		// set values in working copy
552
		if (field == fList) {
553
			setValue(CALL_HIERARCHY_PREFERENCES, serializeFavorites(fList.getElements()));
554
			PreferenceConstants.getPreferenceStore().setValue(CallHierarchyContentProvider.CALL_HIERARCHY_PREFERENCES, serializeFavorites(fList.getElements()));
555
		}
556
	}
557
558
	/**
559
	 * Returns the call hierarchy preferences.
560
	 * 
561
	 * @return the call hierarchy preferences
562
	 */
563
	private String[] getCallHierarchyPreferences() {
564
		String str= getValue(CALL_HIERARCHY_PREFERENCES);
565
		if (str != null && str.length() > 0)
566
			return deserializeFavorites(str);
567
		return new String[0];
568
	}
569
570
	/**
571
	 * Return the array of types and/or members after splitting the stored preference string.
572
	 * 
573
	 * @param str the input string
574
	 * @return the array of types and/or members
575
	 */
576
	private static String[] deserializeFavorites(String str) {
577
		return str.split(";"); //$NON-NLS-1$
578
	}
579
580
	/**
581
	 * Creates a single output string from the list of strings using a delimiter.
582
	 * 
583
	 * @param str the input string
584
	 * @return the single output string from the list of strings using a delimiter
585
	 */
586
	private static String serializeFavorites(List str) {
587
		int size= str.size();
588
		StringBuffer buf= new StringBuffer();
589
		for (int i= 0; i < size; i++) {
590
			buf.append((String)str.get(i));
591
			if (i < size - 1)
592
				buf.append(';');
593
		}
594
		return buf.toString();
595
	}
596
597
}
(-)ui/org/eclipse/jdt/internal/ui/callhierarchy/CallHierarchyPreferencePage.java (+119 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 org.eclipse.swt.widgets.Composite;
13
import org.eclipse.swt.widgets.Control;
14
15
import org.eclipse.core.resources.IProject;
16
17
import org.eclipse.jdt.internal.ui.preferences.PropertyAndPreferencePage;
18
19
/**
20
 * Call Hierarchy view menu preference page.
21
 * 
22
 * @since 3.5
23
 * 
24
 */
25
public class CallHierarchyPreferencePage extends PropertyAndPreferencePage {
26
27
	private CallHierarchyPreferencesConfigurationBlock fConfigurationBlock;
28
29
	/**
30
	 * Creates a call hierarchy preference page and sets the title.
31
	 */
32
	public CallHierarchyPreferencePage() {
33
		super();
34
		setTitle(CallHierarchyMessages.CallHierarchyPreferencePage_expand_with_constructors_title);
35
	}
36
37
	/* (non-Javadoc)
38
	 * @see org.eclipse.jface.preference.PreferencePage#createControl(org.eclipse.swt.widgets.Composite)
39
	 */
40
	public void createControl(Composite parent) {
41
		//IWorkbenchPreferenceContainer container= (IWorkbenchPreferenceContainer)getContainer();
42
		fConfigurationBlock= new CallHierarchyPreferencesConfigurationBlock(getNewStatusChangedListener(), null);
43
		super.createControl(parent);
44
		//PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), IJavaHelpContextIds.JAVA_EDITOR_PREFERENCE_PAGE);
45
	}
46
47
	/* (non-Javadoc)
48
	 * @see org.eclipse.jdt.internal.ui.preferences.PropertyAndPreferencePage#createPreferenceContent(org.eclipse.swt.widgets.Composite)
49
	 */
50
	protected Control createPreferenceContent(Composite composite) {
51
		return fConfigurationBlock.createContents(composite);
52
	}
53
54
	/* (non-Javadoc)
55
	 * @see org.eclipse.jdt.internal.ui.preferences.PropertyAndPreferencePage#getPreferencePageID()
56
	 */
57
	protected String getPreferencePageID() {
58
		return "org.eclipse.jdt.ui.preferences.CallHierarchyPreferencePage"; //$NON-NLS-1$
59
	}
60
61
	/* (non-Javadoc)
62
	 * @see org.eclipse.jdt.internal.ui.preferences.PropertyAndPreferencePage#getPropertyPageID()
63
	 */
64
	protected String getPropertyPageID() {
65
		return null;
66
	}
67
68
	/* (non-Javadoc)
69
	 * @see org.eclipse.jdt.internal.ui.preferences.PropertyAndPreferencePage#hasProjectSpecificOptions(org.eclipse.core.resources.IProject)
70
	 */
71
	protected boolean hasProjectSpecificOptions(IProject project) {
72
		return false;
73
	}
74
75
76
	/* (non-Javadoc)
77
	* @see org.eclipse.jface.dialogs.DialogPage#dispose()
78
	*/
79
	public void dispose() {
80
		if (fConfigurationBlock != null) {
81
			fConfigurationBlock.dispose();
82
		}
83
		super.dispose();
84
	}
85
86
87
	/* (non-Javadoc)
88
	 * @see org.eclipse.jdt.internal.ui.preferences.PropertyAndPreferencePage#performDefaults()
89
	 */
90
	protected void performDefaults() {
91
		super.performDefaults();
92
		if (fConfigurationBlock != null) {
93
			fConfigurationBlock.performDefaults();
94
		}
95
	}
96
97
98
	/* (non-Javadoc)
99
	 * @see org.eclipse.jface.preference.PreferencePage#performOk()
100
	 */
101
	public boolean performOk() {
102
		if (fConfigurationBlock != null && !fConfigurationBlock.performOk()) {
103
			return false;
104
		}
105
		return super.performOk();
106
	}
107
108
109
	/* (non-Javadoc)
110
	 * @see org.eclipse.jface.preference.PreferencePage#performApply()
111
	 */
112
	public void performApply() {
113
		if (fConfigurationBlock != null) {
114
			fConfigurationBlock.performApply();
115
		}
116
	}
117
118
119
}

Return to bug 276466