### Eclipse Workspace Patch 1.0 #P org.eclipse.ui.workbench Index: Eclipse UI/org/eclipse/ui/internal/keys/NewKeysPreferenceMessages.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/keys/NewKeysPreferenceMessages.java,v retrieving revision 1.7 diff -u -r1.7 NewKeysPreferenceMessages.java --- Eclipse UI/org/eclipse/ui/internal/keys/NewKeysPreferenceMessages.java 26 Apr 2007 18:20:56 -0000 1.7 +++ Eclipse UI/org/eclipse/ui/internal/keys/NewKeysPreferenceMessages.java 27 Apr 2007 01:26:36 -0000 @@ -53,6 +53,10 @@ public static String Unavailable_Category; public static String Undefined_Context; + public static String KeysPreferenceFilterDialog_Title; + public static String ActionSetFilterCheckBox_Text; + public static String InternalFilterCheckBox_Text; + static { // load message values from bundle file NLS.initializeMessages(BUNDLE_NAME, NewKeysPreferenceMessages.class); Index: Eclipse UI/org/eclipse/ui/internal/keys/NewKeysPreferencePage.properties =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/keys/NewKeysPreferencePage.properties,v retrieving revision 1.12 diff -u -r1.12 NewKeysPreferencePage.properties --- Eclipse UI/org/eclipse/ui/internal/keys/NewKeysPreferencePage.properties 26 Apr 2007 18:20:56 -0000 1.12 +++ Eclipse UI/org/eclipse/ui/internal/keys/NewKeysPreferencePage.properties 27 Apr 2007 01:26:36 -0000 @@ -41,3 +41,7 @@ Undefined_Context=Undefined Context +ActionSetFilterCheckBox_Text= Filter ActionSet Contexts +InternalFilterCheckBox_Text = Filter Internal Contexts +KeysPreferenceFilterDialog_Title= When Combo Filters + Index: Eclipse UI/org/eclipse/ui/internal/keys/NewKeysPreferencePage.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/keys/NewKeysPreferencePage.java,v retrieving revision 1.38 diff -u -r1.38 NewKeysPreferencePage.java --- Eclipse UI/org/eclipse/ui/internal/keys/NewKeysPreferencePage.java 26 Apr 2007 18:20:56 -0000 1.38 +++ Eclipse UI/org/eclipse/ui/internal/keys/NewKeysPreferencePage.java 27 Apr 2007 01:26:36 -0000 @@ -19,6 +19,7 @@ import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; +import java.util.List; import java.util.Map; import java.util.Set; @@ -41,6 +42,7 @@ import org.eclipse.jface.bindings.keys.KeySequenceText; import org.eclipse.jface.bindings.keys.KeyStroke; import org.eclipse.jface.contexts.IContextIds; +import org.eclipse.jface.dialogs.Dialog; import org.eclipse.jface.dialogs.IDialogConstants; import org.eclipse.jface.dialogs.IDialogSettings; import org.eclipse.jface.dialogs.MessageDialog; @@ -67,7 +69,10 @@ import org.eclipse.jface.viewers.TreeViewer; import org.eclipse.jface.viewers.Viewer; import org.eclipse.jface.viewers.ViewerComparator; +import org.eclipse.jface.window.Window; import org.eclipse.swt.SWT; +import org.eclipse.swt.events.MouseEvent; +import org.eclipse.swt.events.MouseListener; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.graphics.Image; @@ -664,6 +669,10 @@ * The path at which the icon for "groups of bindings" is located. */ private static final String ICON_GROUP_OF_BINDINGS = "$nl$/icons/full/obj16/keygroups_obj.gif"; //$NON-NLS-1$ + + private static final String CONTEXT_ID_ACTION_SETS="org.eclipse.ui.contexts.actionSet"; //$NON-NLS-1$ + + private static final String CONTEXT_ID_INTERNAL=".internal."; //$NON-NLS-1$ /** * The number of items to show in the bindings table tree. @@ -676,7 +685,7 @@ */ private static final NamedHandleObjectComparator NAMED_HANDLE_OBJECT_COMPARATOR = new NamedHandleObjectComparator(); - private final static String TAG_DIALOG_SECTION = "org.eclipse.ui.preferences.keysPreferencePage"; //$NON-NLS-1$ + public final static String TAG_DIALOG_SECTION = "org.eclipse.ui.preferences.keysPreferencePage"; //$NON-NLS-1$ private final String TAG_FIELD = "showAllField"; //$NON-NLS-1$ @@ -884,7 +893,26 @@ gridData.widthHint = Math.max(widthHint, advancedButton.computeSize( SWT.DEFAULT, SWT.DEFAULT, true).x) + 5; advancedButton.setLayoutData(gridData); + advancedButton.addMouseListener(new MouseListener(){ + + public void mouseDoubleClick(MouseEvent e) { + // TODO Auto-generated method stub + + } + + public void mouseDown(MouseEvent e) { + // TODO Auto-generated method stub + + } + public void mouseUp(MouseEvent e) { + // TODO Auto-generated method stub + + Dialog dialog=new KeysPreferenceFiltersDialog(getShell()); + if (dialog.open() == Window.OK) { + whenCombo.setInput(getContexts()); + } + }}); return buttonBar; } @@ -1038,6 +1066,7 @@ whenCombo.getCombo().setLayoutData(gridData); whenCombo.setLabelProvider(new NamedHandleObjectLabelProvider()); whenCombo.setContentProvider(new ArrayContentProvider()); + whenCombo.setComparator(new ViewerComparator()); // RIGHT DATA AREA // Creates the right data area. @@ -1339,7 +1368,8 @@ setScheme(localChangeManager.getActiveScheme()); // Update the when combo. - whenCombo.setInput(sortByName(contextService.getDefinedContexts())); + whenCombo.setInput(getContexts()); + } /* @@ -1875,4 +1905,67 @@ } return settings; } + + protected Object[] getContexts(){ + + Context[] contexts=contextService.getDefinedContexts(); + List filteredContexts=new ArrayList(); + boolean actionSetFilterchecked; + boolean internalFilterChecked; + IDialogSettings settings=getDialogSettings(); + if (settings.get(KeysPreferenceFiltersDialog.TAG_FILTER_ACTION_SETS)==null){ + //First time TAG_FILTER_ACTION_SETS will be null so we have to set actionSetFilterchecked to true + actionSetFilterchecked=true; + }else + actionSetFilterchecked=settings.getBoolean(KeysPreferenceFiltersDialog.TAG_FILTER_ACTION_SETS); + try { + if (actionSetFilterchecked) { + for (int i = 0; i < contexts.length; i++) { + String parentId = contexts[i].getParentId(); + boolean check = false; + if (contexts[i].getId().equalsIgnoreCase(CONTEXT_ID_ACTION_SETS)){ + check=true; + } + while (parentId != null) { + if (parentId + .equalsIgnoreCase(CONTEXT_ID_ACTION_SETS)) { + check = true; + } + parentId = contextService.getContext(parentId) + .getParentId(); + } + if (!check) { + filteredContexts.add(contexts[i]); + } + } + }else{ + //if actionSet filter is off then filteredContexts will be null so we have to copy all the contexts to it. + for (int i=0; i