View | Details | Raw Unified | Return to bug 176235 | Differences between
and this patch

Collapse All | Expand All

(-)Eclipse UI/org/eclipse/ui/internal/keys/NewKeysPreferenceMessages.java (+4 lines)
Lines 53-58 Link Here
53
	public static String Unavailable_Category;
53
	public static String Unavailable_Category;
54
	public static String Undefined_Context;
54
	public static String Undefined_Context;
55
	
55
	
56
	public static String KeysPreferenceFilterDialog_Title;
57
	public static String ActionSetFilterCheckBox_Text;
58
	public static String InternalFilterCheckBox_Text;
59
	
56
	static {
60
	static {
57
		// load message values from bundle file
61
		// load message values from bundle file
58
		NLS.initializeMessages(BUNDLE_NAME, NewKeysPreferenceMessages.class);
62
		NLS.initializeMessages(BUNDLE_NAME, NewKeysPreferenceMessages.class);
(-)Eclipse UI/org/eclipse/ui/internal/keys/NewKeysPreferencePage.properties (+4 lines)
Lines 41-43 Link Here
41
		
41
		
42
Undefined_Context=Undefined Context
42
Undefined_Context=Undefined Context
43
43
44
ActionSetFilterCheckBox_Text= Filter ActionSet Contexts
45
InternalFilterCheckBox_Text = Filter Internal Contexts
46
KeysPreferenceFilterDialog_Title= When Combo Filters
47
(-)Eclipse UI/org/eclipse/ui/internal/keys/NewKeysPreferencePage.java (-2 / +95 lines)
Lines 19-24 Link Here
19
import java.util.HashMap;
19
import java.util.HashMap;
20
import java.util.HashSet;
20
import java.util.HashSet;
21
import java.util.Iterator;
21
import java.util.Iterator;
22
import java.util.List;
22
import java.util.Map;
23
import java.util.Map;
23
import java.util.Set;
24
import java.util.Set;
24
25
Lines 41-46 Link Here
41
import org.eclipse.jface.bindings.keys.KeySequenceText;
42
import org.eclipse.jface.bindings.keys.KeySequenceText;
42
import org.eclipse.jface.bindings.keys.KeyStroke;
43
import org.eclipse.jface.bindings.keys.KeyStroke;
43
import org.eclipse.jface.contexts.IContextIds;
44
import org.eclipse.jface.contexts.IContextIds;
45
import org.eclipse.jface.dialogs.Dialog;
44
import org.eclipse.jface.dialogs.IDialogConstants;
46
import org.eclipse.jface.dialogs.IDialogConstants;
45
import org.eclipse.jface.dialogs.IDialogSettings;
47
import org.eclipse.jface.dialogs.IDialogSettings;
46
import org.eclipse.jface.dialogs.MessageDialog;
48
import org.eclipse.jface.dialogs.MessageDialog;
Lines 67-73 Link Here
67
import org.eclipse.jface.viewers.TreeViewer;
69
import org.eclipse.jface.viewers.TreeViewer;
68
import org.eclipse.jface.viewers.Viewer;
70
import org.eclipse.jface.viewers.Viewer;
69
import org.eclipse.jface.viewers.ViewerComparator;
71
import org.eclipse.jface.viewers.ViewerComparator;
72
import org.eclipse.jface.window.Window;
70
import org.eclipse.swt.SWT;
73
import org.eclipse.swt.SWT;
74
import org.eclipse.swt.events.MouseEvent;
75
import org.eclipse.swt.events.MouseListener;
71
import org.eclipse.swt.events.SelectionAdapter;
76
import org.eclipse.swt.events.SelectionAdapter;
72
import org.eclipse.swt.events.SelectionEvent;
77
import org.eclipse.swt.events.SelectionEvent;
73
import org.eclipse.swt.graphics.Image;
78
import org.eclipse.swt.graphics.Image;
Lines 664-669 Link Here
664
	 * The path at which the icon for "groups of bindings" is located.
669
	 * The path at which the icon for "groups of bindings" is located.
665
	 */
670
	 */
666
	private static final String ICON_GROUP_OF_BINDINGS = "$nl$/icons/full/obj16/keygroups_obj.gif"; //$NON-NLS-1$
671
	private static final String ICON_GROUP_OF_BINDINGS = "$nl$/icons/full/obj16/keygroups_obj.gif"; //$NON-NLS-1$
672
	
673
	private static final String CONTEXT_ID_ACTION_SETS="org.eclipse.ui.contexts.actionSet"; //$NON-NLS-1$
674
	
675
	private static final String CONTEXT_ID_INTERNAL=".internal."; //$NON-NLS-1$
667
676
668
	/**
677
	/**
669
	 * The number of items to show in the bindings table tree.
678
	 * The number of items to show in the bindings table tree.
Lines 676-682 Link Here
676
	 */
685
	 */
677
	private static final NamedHandleObjectComparator NAMED_HANDLE_OBJECT_COMPARATOR = new NamedHandleObjectComparator();
686
	private static final NamedHandleObjectComparator NAMED_HANDLE_OBJECT_COMPARATOR = new NamedHandleObjectComparator();
678
	
687
	
679
	private final static String TAG_DIALOG_SECTION = "org.eclipse.ui.preferences.keysPreferencePage"; //$NON-NLS-1$
688
	public final static String TAG_DIALOG_SECTION = "org.eclipse.ui.preferences.keysPreferencePage"; //$NON-NLS-1$
680
	
689
	
681
	private final String TAG_FIELD = "showAllField"; //$NON-NLS-1$
690
	private final String TAG_FIELD = "showAllField"; //$NON-NLS-1$
682
691
Lines 884-890 Link Here
884
		gridData.widthHint = Math.max(widthHint, advancedButton.computeSize(
893
		gridData.widthHint = Math.max(widthHint, advancedButton.computeSize(
885
				SWT.DEFAULT, SWT.DEFAULT, true).x) + 5;
894
				SWT.DEFAULT, SWT.DEFAULT, true).x) + 5;
886
		advancedButton.setLayoutData(gridData);
895
		advancedButton.setLayoutData(gridData);
896
		advancedButton.addMouseListener(new MouseListener(){
897
898
			public void mouseDoubleClick(MouseEvent e) {
899
				// TODO Auto-generated method stub
900
				
901
			}
902
903
			public void mouseDown(MouseEvent e) {
904
				// TODO Auto-generated method stub
905
				
906
			}
887
907
908
			public void mouseUp(MouseEvent e) {
909
				// TODO Auto-generated method stub
910
				
911
				Dialog dialog=new KeysPreferenceFiltersDialog(getShell());
912
				if (dialog.open() == Window.OK) {
913
					whenCombo.setInput(getContexts());
914
				}
915
			}});
888
		return buttonBar;
916
		return buttonBar;
889
	}
917
	}
890
918
Lines 1038-1043 Link Here
1038
		whenCombo.getCombo().setLayoutData(gridData);
1066
		whenCombo.getCombo().setLayoutData(gridData);
1039
		whenCombo.setLabelProvider(new NamedHandleObjectLabelProvider());
1067
		whenCombo.setLabelProvider(new NamedHandleObjectLabelProvider());
1040
		whenCombo.setContentProvider(new ArrayContentProvider());
1068
		whenCombo.setContentProvider(new ArrayContentProvider());
1069
		whenCombo.setComparator(new ViewerComparator());
1041
1070
1042
		// RIGHT DATA AREA
1071
		// RIGHT DATA AREA
1043
		// Creates the right data area.
1072
		// Creates the right data area.
Lines 1339-1345 Link Here
1339
		setScheme(localChangeManager.getActiveScheme());
1368
		setScheme(localChangeManager.getActiveScheme());
1340
1369
1341
		// Update the when combo.
1370
		// Update the when combo.
1342
		whenCombo.setInput(sortByName(contextService.getDefinedContexts()));
1371
		whenCombo.setInput(getContexts());
1372
1343
	}
1373
	}
1344
1374
1345
	/*
1375
	/*
Lines 1875-1878 Link Here
1875
		}
1905
		}
1876
		return settings;
1906
		return settings;
1877
	}
1907
	}
1908
	
1909
	protected Object[] getContexts(){
1910
		
1911
		Context[] contexts=contextService.getDefinedContexts();
1912
		List filteredContexts=new ArrayList();
1913
		boolean actionSetFilterchecked;
1914
		boolean internalFilterChecked;
1915
		IDialogSettings settings=getDialogSettings();
1916
		if (settings.get(KeysPreferenceFiltersDialog.TAG_FILTER_ACTION_SETS)==null){
1917
			//First time TAG_FILTER_ACTION_SETS will be null so we have to set actionSetFilterchecked to true  
1918
			actionSetFilterchecked=true;
1919
		}else
1920
			actionSetFilterchecked=settings.getBoolean(KeysPreferenceFiltersDialog.TAG_FILTER_ACTION_SETS);
1921
		try {
1922
			if (actionSetFilterchecked) {
1923
				for (int i = 0; i < contexts.length; i++) {
1924
					String parentId = contexts[i].getParentId();
1925
					boolean check = false;
1926
					if (contexts[i].getId().equalsIgnoreCase(CONTEXT_ID_ACTION_SETS)){
1927
						check=true;
1928
					}
1929
					while (parentId != null) {
1930
						if (parentId
1931
								.equalsIgnoreCase(CONTEXT_ID_ACTION_SETS)) {
1932
							check = true;
1933
						}
1934
						parentId = contextService.getContext(parentId)
1935
								.getParentId();
1936
					}
1937
					if (!check) {
1938
						filteredContexts.add(contexts[i]);
1939
					}
1940
				}
1941
			}else{
1942
				//if actionSet filter is off then filteredContexts will be null so we have to copy all the contexts to it.
1943
				for (int i=0; i<contexts.length;i++){
1944
					filteredContexts.add(contexts[i]);
1945
				}
1946
			}
1947
1948
			if (settings.get(KeysPreferenceFiltersDialog.TAG_FILTER_INTERNAL) == null) {
1949
				//First time TAG_FILTER_INTERNAL will be null so we have to set actionSetFilterchecked to true
1950
				internalFilterChecked = true;
1951
			} else
1952
				internalFilterChecked = settings
1953
						.getBoolean(KeysPreferenceFiltersDialog.TAG_FILTER_INTERNAL);
1954
1955
			if (internalFilterChecked) {
1956
				for (int i = 0; i < filteredContexts.size(); i++) {
1957
					if (((Context) filteredContexts.get(i)).getId().indexOf(
1958
							CONTEXT_ID_INTERNAL) != -1) { 
1959
						filteredContexts.remove(i);
1960
					}
1961
				}
1962
			}
1963
1964
		} catch (NotDefinedException e) {
1965
			return contexts;
1966
		}
1967
		
1968
1969
		return filteredContexts.toArray();
1970
	}
1878
}
1971
}
(-)Eclipse (+140 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2007 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
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 ******************************************************************************/
11
12
package org.eclipse.ui.internal.keys;
13
14
import org.eclipse.jface.dialogs.IDialogSettings;
15
import org.eclipse.swt.SWT;
16
import org.eclipse.swt.layout.GridData;
17
import org.eclipse.swt.layout.GridLayout;
18
import org.eclipse.swt.widgets.Button;
19
import org.eclipse.swt.widgets.Composite;
20
import org.eclipse.swt.widgets.Control;
21
import org.eclipse.swt.widgets.Shell;
22
import org.eclipse.ui.internal.WorkbenchPlugin;
23
import org.eclipse.ui.preferences.ViewSettingsDialog;
24
25
/**
26
 * Creates a dialog box for applying filter selection of When combo box in
27
 * NewKeysPreferencePage
28
 * 
29
 * @since 3.3
30
 * 
31
 */
32
public class KeysPreferenceFiltersDialog extends ViewSettingsDialog {
33
34
	private Button actionSetFilterCheckBox;
35
	private Button internalFilterCheckBox;
36
37
	public static final String TAG_FILTER_ACTION_SETS = "actionSetFilter"; //$NON-NLS-1$
38
	public static final String TAG_FILTER_INTERNAL = "internalFilter"; //$NON-NLS-1$
39
40
	/**
41
	 * @param parentShell
42
	 */
43
	public KeysPreferenceFiltersDialog(Shell parentShell) {
44
		super(parentShell);
45
	}
46
47
	/*
48
	 * (non-Javadoc)
49
	 * 
50
	 * @see org.eclipse.ui.preferences.ViewSettingsDialog#performDefaults()
51
	 */
52
	protected void performDefaults() {
53
		actionSetFilterCheckBox.setSelection(true);
54
		internalFilterCheckBox.setSelection(true);
55
		super.performDefaults();
56
	}
57
58
	/*
59
	 * (non-Javadoc)
60
	 * 
61
	 * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
62
	 */
63
	protected Control createDialogArea(Composite parent) {
64
		Composite topComposite = (Composite) super.createDialogArea(parent);
65
		super.createDialogArea(parent);
66
		GridLayout layout = new GridLayout(1, false);
67
		topComposite.setLayout(layout);
68
		topComposite.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL));
69
		actionSetFilterCheckBox = new Button(topComposite, SWT.CHECK);
70
		actionSetFilterCheckBox
71
				.setText(NewKeysPreferenceMessages.ActionSetFilterCheckBox_Text);
72
		internalFilterCheckBox = new Button(topComposite, SWT.CHECK);
73
		internalFilterCheckBox
74
				.setText(NewKeysPreferenceMessages.InternalFilterCheckBox_Text);
75
76
		IDialogSettings settings = getDialogSettings();
77
		boolean checked;
78
		if (settings.get(TAG_FILTER_ACTION_SETS) == null) {
79
			// Using workspace first time, TAG_FILTER_ACTION_SETS is null
80
			checked = true;
81
		} else
82
			checked = settings.getBoolean(TAG_FILTER_ACTION_SETS);
83
		actionSetFilterCheckBox.setSelection(checked);
84
85
		if (settings.get(TAG_FILTER_INTERNAL) == null) {
86
			// //Using workspace first time, TAG_FILTER_INTERNAL is null
87
			checked = true;
88
		} else
89
			checked = settings.getBoolean(TAG_FILTER_INTERNAL);
90
		internalFilterCheckBox.setSelection(checked);
91
92
		return topComposite;
93
	}
94
95
	/*
96
	 * (non-Javadoc)
97
	 * 
98
	 * @see org.eclipse.jface.dialogs.Dialog#okPressed()
99
	 */
100
	protected void okPressed() {
101
		saveState(getDialogSettings());
102
		super.okPressed();
103
	}
104
105
	public void saveState(IDialogSettings dialogSettings) {
106
		if (dialogSettings == null) {
107
			return;
108
		}
109
		dialogSettings.put(TAG_FILTER_ACTION_SETS, actionSetFilterCheckBox
110
				.getSelection());
111
		dialogSettings.put(TAG_FILTER_INTERNAL, internalFilterCheckBox
112
				.getSelection());
113
	}
114
115
	protected IDialogSettings getDialogSettings() {
116
		IDialogSettings workbenchSettings = WorkbenchPlugin.getDefault()
117
				.getDialogSettings();
118
119
		IDialogSettings settings = workbenchSettings
120
				.getSection(NewKeysPreferencePage.TAG_DIALOG_SECTION);
121
122
		if (settings == null) {
123
			settings = workbenchSettings
124
					.addNewSection(NewKeysPreferencePage.TAG_DIALOG_SECTION);
125
		}
126
		return settings;
127
	}
128
129
	/*
130
	 * (non-Javadoc)
131
	 * 
132
	 * @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell)
133
	 */
134
	protected void configureShell(Shell newShell) {
135
		super.configureShell(newShell);
136
		newShell
137
				.setText(NewKeysPreferenceMessages.KeysPreferenceFilterDialog_Title);
138
	}
139
140
}

Return to bug 176235