Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 66197 Details for
Bug 118028
[Commands] misc: Many identical entries in 'Uncategorized'
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Filter out uncategorized commands v03
patternFilterInternal-v03.txt (text/plain), 15.87 KB, created by
Paul Webster
on 2007-05-07 15:28:43 EDT
(
hide
)
Description:
Filter out uncategorized commands v03
Filename:
MIME Type:
Creator:
Paul Webster
Created:
2007-05-07 15:28:43 EDT
Size:
15.87 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.ui.workbench >Index: Eclipse UI/org/eclipse/ui/dialogs/PatternFilter.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/dialogs/PatternFilter.java,v >retrieving revision 1.8 >diff -u -r1.8 PatternFilter.java >--- Eclipse UI/org/eclipse/ui/dialogs/PatternFilter.java 15 Nov 2006 17:19:59 -0000 1.8 >+++ Eclipse UI/org/eclipse/ui/dialogs/PatternFilter.java 7 May 2007 19:27:48 -0000 >@@ -10,7 +10,6 @@ > *******************************************************************************/ > package org.eclipse.ui.dialogs; > >-import com.ibm.icu.text.BreakIterator; > import java.util.ArrayList; > import java.util.HashMap; > import java.util.List; >@@ -24,6 +23,8 @@ > import org.eclipse.jface.viewers.ViewerFilter; > import org.eclipse.ui.internal.misc.StringMatcher; > >+import com.ibm.icu.text.BreakIterator; >+ > /** > * A filter used in conjunction with <code>FilteredTree</code>. In order to > * determine if a node should be filtered it uses the content provider of the >@@ -55,13 +56,17 @@ > */ > private StringMatcher matcher; > >+ private boolean useFilterOptimization = true; >+ > private static Object[] EMPTY = new Object[0]; > > /* (non-Javadoc) > * @see org.eclipse.jface.viewers.ViewerFilter#filter(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object[]) > */ > public final Object[] filter(Viewer viewer, Object parent, Object[] elements) { >- if (matcher == null) { >+ // we don't want to optimize if we've extended the filter ... this >+ // needs to be addressed in 3.4 >+ if (matcher == null && useFilterOptimization) { > return elements; > } > >@@ -134,6 +139,13 @@ > * @param patternString > */ > public void setPattern(String patternString) { >+ if ("org.eclipse.ui.keys.optimization.true".equals(patternString)) { //$NON-NLS-1$ >+ useFilterOptimization = true; >+ return; >+ } else if ("org.eclipse.ui.keys.optimization.false".equals(patternString)) { //$NON-NLS-1$ >+ useFilterOptimization = false; >+ return; >+ } > cache.clear(); > foundAnyCache.clear(); > if (patternString == null || patternString.equals("")) { //$NON-NLS-1$ >Index: Eclipse UI/org/eclipse/ui/internal/keys/KeysPreferenceFiltersDialog.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/keys/KeysPreferenceFiltersDialog.java,v >retrieving revision 1.2 >diff -u -r1.2 KeysPreferenceFiltersDialog.java >--- Eclipse UI/org/eclipse/ui/internal/keys/KeysPreferenceFiltersDialog.java 2 May 2007 03:47:58 -0000 1.2 >+++ Eclipse UI/org/eclipse/ui/internal/keys/KeysPreferenceFiltersDialog.java 7 May 2007 19:27:48 -0000 >@@ -31,9 +31,11 @@ > > private Button actionSetFilterCheckBox; > private Button internalFilterCheckBox; >+ private Button uncategorizedFilterCheckBox; > > private boolean filterActionSet; > private boolean filterInternal; >+ private boolean filterUncategorized; > > void setFilterActionSet(boolean b) { > filterActionSet = b; >@@ -42,6 +44,10 @@ > void setFilterInternal(boolean b) { > filterInternal = b; > } >+ >+ void setFilterUncategorized(boolean b) { >+ filterUncategorized = b; >+ } > > boolean getFilterActionSet() { > return filterActionSet; >@@ -50,6 +56,10 @@ > boolean getFilterInternal() { > return filterInternal; > } >+ >+ boolean getFilterUncategorized() { >+ return filterUncategorized; >+ } > > /** > * @param parentShell >@@ -66,6 +76,7 @@ > protected void performDefaults() { > actionSetFilterCheckBox.setSelection(true); > internalFilterCheckBox.setSelection(true); >+ uncategorizedFilterCheckBox.setSelection(true); > super.performDefaults(); > } > >@@ -85,9 +96,13 @@ > internalFilterCheckBox = new Button(topComposite, SWT.CHECK); > internalFilterCheckBox > .setText(NewKeysPreferenceMessages.InternalFilterCheckBox_Text); >+ uncategorizedFilterCheckBox = new Button(topComposite, SWT.CHECK); >+ uncategorizedFilterCheckBox >+ .setText(NewKeysPreferenceMessages.UncategorizedFilterCheckBox_Text); > > actionSetFilterCheckBox.setSelection(filterActionSet); > internalFilterCheckBox.setSelection(filterInternal); >+ uncategorizedFilterCheckBox.setSelection(filterUncategorized); > applyDialogFont(topComposite); > > return topComposite; >@@ -101,6 +116,7 @@ > protected void okPressed() { > filterActionSet = actionSetFilterCheckBox.getSelection(); > filterInternal = internalFilterCheckBox.getSelection(); >+ filterUncategorized = uncategorizedFilterCheckBox.getSelection(); > super.okPressed(); > } > >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.57 >diff -u -r1.57 NewKeysPreferencePage.java >--- Eclipse UI/org/eclipse/ui/internal/keys/NewKeysPreferencePage.java 3 May 2007 01:48:10 -0000 1.57 >+++ Eclipse UI/org/eclipse/ui/internal/keys/NewKeysPreferencePage.java 7 May 2007 19:27:48 -0000 >@@ -115,7 +115,6 @@ > import org.eclipse.ui.commands.ICommandService; > import org.eclipse.ui.contexts.IContextService; > import org.eclipse.ui.dialogs.FilteredTree; >-import org.eclipse.ui.dialogs.PatternFilter; > import org.eclipse.ui.internal.WorkbenchPlugin; > import org.eclipse.ui.internal.commands.ICommandImageService; > import org.eclipse.ui.internal.misc.Policy; >@@ -399,80 +398,30 @@ > * display elements in the tree according to the selected criteria. > * > */ >- protected class GroupedFilteredTree extends FilteredTree { >+ protected class CategoryFilterTree extends FilteredTree { >+ >+ private CategoryPatternFilter filter; > > /** >- * Constructor for GroupedFilteredTree. >+ * Constructor for PatternFilteredTree. > * > * @param parent > * @param treeStyle > * @param filter > */ >- protected GroupedFilteredTree(Composite parent, int treeStyle, >- PatternFilter filter) { >+ protected CategoryFilterTree(Composite parent, int treeStyle, >+ CategoryPatternFilter filter) { > super(parent, treeStyle, filter); >+ this.filter = filter; > } > >- protected void createControl(final Composite parent, final int treeStyle) { >- GridData gridData; >- GridLayout layout; >- >- layout = new GridLayout(); >- // Why doesn't this seem to be working?? >- layout.marginHeight = 0; >- layout.marginWidth = 0; >- setLayout(layout); >- setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); >- setFont(parent.getFont()); >- >- // Create the filter controls >- filterComposite = new Composite(this, SWT.NONE); >- GridLayout filterLayout = new GridLayout(2, false); >- filterLayout.marginHeight = 0; >- filterLayout.marginWidth = 0; >- filterComposite.setLayout(filterLayout); >- filterComposite.setFont(parent.getFont()); >- >- createFilterControls(filterComposite); >- filterComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, >- true, false)); >- >- // Create a table tree viewer. >- final Control treeControl = createTreeControl(this, treeStyle); >- gridData = new GridData(SWT.FILL, SWT.FILL, true, true); >- gridData.horizontalSpan = 3; >- treeControl.setLayoutData(gridData); >+ public void filterCategories(boolean b) { >+ filter.filterCategories(b); >+ textChanged(); > } > >- /** >- * <p> >- * Creates the grouping controls that will appear in the top-right in >- * the default layout. The default grouping controls are a label and a >- * combo box. >- * </p> >- * <p> >- * Subclasses may extend or override this method. Before this method >- * completes, <code>groupingCombo</code> should be initialized. >- * Subclasses must create a combo box which contains the possible >- * groupings. >- * </p> >- * >- * @param parent >- * The composite in which the grouping control should be >- * placed; must not be <code>null</code>. >- * @return The composite containing the grouping controls, or the >- * grouping control itself (if there is only one control). >- */ >- protected Control createGroupingControl(final Composite parent) { >- // Create the composite that will contain the grouping controls. >- Composite groupingControl = new Composite(parent, SWT.NONE); >- GridLayout layout = new GridLayout(2, false); >- layout.marginWidth = 0; >- layout.marginHeight = 0; >- groupingControl.setLayout(layout); >- groupingControl.setFont(parent.getFont()); >- >- return groupingControl; >+ public boolean isFilteringCategories() { >+ return filter.isFilteringCategories(); > } > } > >@@ -834,6 +783,8 @@ > > private static final String TAG_FILTER_INTERNAL = "internalFilter"; //$NON-NLS-1$ > >+ private static final String TAG_FILTER_UNCAT = "uncategorizedFilter"; //$NON-NLS-1$ >+ > /** > * Sorts the given array of <code>NamedHandleObject</code> instances based > * on their name. This is generally useful if they will be displayed to an >@@ -896,7 +847,9 @@ > /** > * The filtered tree containing the list of commands and bindings to edit. > */ >- private GroupedFilteredTree filteredTree; >+ private CategoryFilterTree filteredTree; >+ >+ private CategoryPatternFilter patternFilter; > > /** > * The grouping for the bindings tree. Either there should be no group >@@ -1165,9 +1118,12 @@ > getShell()); > dialog.setFilterActionSet(filterActionSetContexts); > dialog.setFilterInternal(filterInternalContexts); >+ dialog.setFilterUncategorized(filteredTree.isFilteringCategories()); > if (dialog.open() == Window.OK) { > filterActionSetContexts = dialog.getFilterActionSet(); > filterInternalContexts = dialog.getFilterInternal(); >+ filteredTree.filterCategories(dialog >+ .getFilterUncategorized()); > whenCombo.setInput(getContexts()); > updateDataControls(); > } >@@ -1197,6 +1153,12 @@ > if (settings.get(TAG_FILTER_INTERNAL) != null) { > filterInternalContexts = settings.getBoolean(TAG_FILTER_INTERNAL); > } >+ patternFilter = new CategoryPatternFilter( >+ true, commandService.getCategory(null)); >+ if (settings.get(TAG_FILTER_UNCAT) != null) { >+ patternFilter.filterCategories(settings >+ .getBoolean(TAG_FILTER_UNCAT)); >+ } > > // Creates a composite to hold all of the page contents. > final Composite page = new Composite(parent, SWT.NONE); >@@ -1466,9 +1428,9 @@ > private final Control createTree(final Composite parent) { > GridData gridData; > >- filteredTree = new GroupedFilteredTree(parent, SWT.SINGLE >- | SWT.FULL_SELECTION | SWT.BORDER, new PatternFilter()); >- final GridLayout layout = new GridLayout(2, false); >+ filteredTree = new CategoryFilterTree(parent, SWT.SINGLE >+ | SWT.FULL_SELECTION | SWT.BORDER, patternFilter); >+ final GridLayout layout = new GridLayout(1, false); > layout.marginWidth = 0; > filteredTree.setLayout(layout); > gridData = new GridData(); >@@ -1509,7 +1471,8 @@ > triggerSequenceColumn > .setText(NewKeysPreferenceMessages.TriggerSequenceColumn_Text); > triggerSequenceColumn.addSelectionListener(new ResortColumn(comparator, >- triggerSequenceColumn, tree, BindingLabelProvider.COLUMN_TRIGGER_SEQUENCE)); >+ triggerSequenceColumn, tree, >+ BindingLabelProvider.COLUMN_TRIGGER_SEQUENCE)); > > final TreeColumn whenColumn = new TreeColumn(tree, SWT.LEFT, > BindingLabelProvider.COLUMN_WHEN); >@@ -2247,6 +2210,7 @@ > dialogSettings.put(TAG_FIELD, showAllCheckBox.getSelection()); > dialogSettings.put(TAG_FILTER_ACTION_SETS, filterActionSetContexts); > dialogSettings.put(TAG_FILTER_INTERNAL, filterInternalContexts); >+ dialogSettings.put(TAG_FILTER_UNCAT, filteredTree.isFilteringCategories()); > } > > protected IDialogSettings getDialogSettings() { >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.10 >diff -u -r1.10 NewKeysPreferenceMessages.java >--- Eclipse UI/org/eclipse/ui/internal/keys/NewKeysPreferenceMessages.java 1 May 2007 02:22:52 -0000 1.10 >+++ Eclipse UI/org/eclipse/ui/internal/keys/NewKeysPreferenceMessages.java 7 May 2007 19:27:48 -0000 >@@ -58,6 +58,7 @@ > public static String KeysPreferenceFilterDialog_Title; > public static String ActionSetFilterCheckBox_Text; > public static String InternalFilterCheckBox_Text; >+ public static String UncategorizedFilterCheckBox_Text; > > static { > // load message values from bundle file >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.18 >diff -u -r1.18 NewKeysPreferencePage.properties >--- Eclipse UI/org/eclipse/ui/internal/keys/NewKeysPreferencePage.properties 2 May 2007 00:22:09 -0000 1.18 >+++ Eclipse UI/org/eclipse/ui/internal/keys/NewKeysPreferencePage.properties 7 May 2007 19:27:48 -0000 >@@ -45,5 +45,6 @@ > > ActionSetFilterCheckBox_Text= Filter &action set contexts > InternalFilterCheckBox_Text = Filter &internal contexts >+UncategorizedFilterCheckBox_Text = Filter &uncategorized commands > KeysPreferenceFilterDialog_Title= When Context Filters > >Index: Eclipse UI/org/eclipse/ui/internal/keys/CategoryPatternFilter.java >=================================================================== >RCS file: Eclipse UI/org/eclipse/ui/internal/keys/CategoryPatternFilter.java >diff -N Eclipse UI/org/eclipse/ui/internal/keys/CategoryPatternFilter.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ Eclipse UI/org/eclipse/ui/internal/keys/CategoryPatternFilter.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,73 @@ >+/******************************************************************************* >+ * Copyright (c) 2007 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ ******************************************************************************/ >+ >+package org.eclipse.ui.internal.keys; >+ >+import org.eclipse.core.commands.Category; >+import org.eclipse.core.commands.ParameterizedCommand; >+import org.eclipse.core.commands.common.NotDefinedException; >+import org.eclipse.jface.bindings.Binding; >+import org.eclipse.jface.viewers.Viewer; >+import org.eclipse.ui.dialogs.PatternFilter; >+ >+class CategoryPatternFilter extends PatternFilter { >+ private boolean filterCategories; >+ final Category uncategorized; >+ >+ public CategoryPatternFilter(boolean filterCategories, Category c) { >+ uncategorized = c; >+ filterCategories(filterCategories); >+ } >+ >+ public void filterCategories(boolean b) { >+ filterCategories = b; >+ if (filterCategories) { >+ setPattern("org.eclipse.ui.keys.optimization.false"); //$NON-NLS-1$ >+ } else { >+ setPattern("org.eclipse.ui.keys.optimization.true"); //$NON-NLS-1$ >+ } >+ } >+ >+ public boolean isFilteringCategories() { >+ return filterCategories; >+ } >+ >+ /* >+ * (non-Javadoc) >+ * >+ * @see org.eclipse.ui.dialogs.PatternFilter#isLeafMatch(org.eclipse.jface.viewers.Viewer, >+ * java.lang.Object) >+ */ >+ protected boolean isLeafMatch(Viewer viewer, Object element) { >+ if (filterCategories) { >+ final ParameterizedCommand cmd = getCommand(element); >+ try { >+ if (cmd != null >+ && cmd.getCommand().getCategory() == uncategorized) { >+ return false; >+ } >+ } catch (NotDefinedException e) { >+ return false; >+ } >+ } >+ return super.isLeafMatch(viewer, element); >+ } >+ >+ private ParameterizedCommand getCommand(Object element) { >+ if (element instanceof ParameterizedCommand) { >+ return (ParameterizedCommand) element; >+ } >+ if (element instanceof Binding) { >+ return ((Binding) element).getParameterizedCommand(); >+ } >+ return null; >+ } >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 118028
:
66140
|
66197
|
66348
|
66692
|
67205