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 60868 Details for
Bug 176235
[Contributions] polish new keys preference page
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Sorting is added to NewKeysPreferencePage
NewKeysPreferencePage v-01.txt (text/plain), 9.38 KB, created by
ali sheraz
on 2007-03-14 17:48:52 EDT
(
hide
)
Description:
Sorting is added to NewKeysPreferencePage
Filename:
MIME Type:
Creator:
ali sheraz
Created:
2007-03-14 17:48:52 EDT
Size:
9.38 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.ui.workbench >Index: Eclipse UI/org/eclipse/ui/internal/IPreferenceConstants.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/IPreferenceConstants.java,v >retrieving revision 1.59 >diff -u -r1.59 IPreferenceConstants.java >--- Eclipse UI/org/eclipse/ui/internal/IPreferenceConstants.java 21 Feb 2007 02:39:02 -0000 1.59 >+++ Eclipse UI/org/eclipse/ui/internal/IPreferenceConstants.java 14 Mar 2007 21:35:08 -0000 >@@ -214,5 +214,16 @@ > * @since 3.0 > */ > public static final String SHOULD_PROMPT_FOR_ENABLEMENT = "shouldPromptForEnablement"; //$NON-NLS-1$ >+ >+ /** >+ * showAllCheckBox Preference ID for NewKeysPreferencePage >+ * <p> >+ * The default value for this preference is: <code>false</code> (prompt) >+ * </p> >+ * >+ * @since 3.3 >+ */ >+ >+ public static final String SHOW_ALL_CHECK_BOX ="SHOW_ALL_CHECK_BOX"; //$NON-NLS-1$ > > } >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.32 >diff -u -r1.32 NewKeysPreferencePage.java >--- Eclipse UI/org/eclipse/ui/internal/keys/NewKeysPreferencePage.java 25 Jan 2007 15:16:20 -0000 1.32 >+++ Eclipse UI/org/eclipse/ui/internal/keys/NewKeysPreferencePage.java 14 Mar 2007 21:35:08 -0000 >@@ -43,6 +43,7 @@ > import org.eclipse.jface.contexts.IContextIds; > import org.eclipse.jface.dialogs.IDialogConstants; > import org.eclipse.jface.dialogs.MessageDialog; >+import org.eclipse.jface.preference.IPreferenceStore; > import org.eclipse.jface.preference.PreferencePage; > import org.eclipse.jface.resource.DeviceResourceException; > import org.eclipse.jface.resource.ImageDescriptor; >@@ -52,6 +53,7 @@ > import org.eclipse.jface.util.PropertyChangeEvent; > import org.eclipse.jface.viewers.ArrayContentProvider; > import org.eclipse.jface.viewers.ComboViewer; >+import org.eclipse.jface.viewers.IBaseLabelProvider; > import org.eclipse.jface.viewers.ISelection; > import org.eclipse.jface.viewers.ISelectionChangedListener; > import org.eclipse.jface.viewers.IStructuredSelection; >@@ -93,6 +95,7 @@ > import org.eclipse.ui.contexts.IContextService; > import org.eclipse.ui.dialogs.FilteredTree; > import org.eclipse.ui.dialogs.PatternFilter; >+import org.eclipse.ui.internal.IPreferenceConstants; > import org.eclipse.ui.internal.WorkbenchPlugin; > import org.eclipse.ui.internal.commands.ICommandImageService; > import org.eclipse.ui.internal.misc.StatusUtil; >@@ -377,6 +380,7 @@ > case COLUMN_COMMAND: > try { > return binding.getParameterizedCommand().getName(); >+ > } catch (final NotDefinedException e) { > return null; > } >@@ -416,7 +420,8 @@ > return null; > } > } >- >+ if (columnIndex== COLUMN_TRIGGER_SEQUENCE) >+ return ""; //$NON-NLS-1$ > return null; > } > >@@ -429,6 +434,9 @@ > */ > private final class BindingComparator extends ViewerComparator { > >+ private int sortColumn = 0; >+ private boolean ascending = true; >+ > public final int category(final Object element) { > switch (grouping) { > case GROUPING_CATEGORY: >@@ -574,19 +582,30 @@ > > } else { // (GROUPING_NONE_NAME.equals(selectedText)) > /* >- * The tree node values will be Binding or >- * ParameterizedCommand instances. >- */ >- final Object x = ((TreeNode) a).getValue(); >- final Object y = ((TreeNode) b).getValue(); >- final ParameterizedCommand commandX = (x instanceof Binding) ? ((Binding) x) >- .getParameterizedCommand() >- : (ParameterizedCommand) x; >- final ParameterizedCommand commandY = (y instanceof Binding) ? ((Binding) y) >- .getParameterizedCommand() >- : (ParameterizedCommand) y; >+// * The tree node values will be Binding or >+// * ParameterizedCommand instances. >+// */ >+// final Object x = ((TreeNode) a).getValue(); >+// final Object y = ((TreeNode) b).getValue(); >+// final ParameterizedCommand commandX = (x instanceof Binding) ? ((Binding) x) >+// .getParameterizedCommand() >+// : (ParameterizedCommand) x; >+// final ParameterizedCommand commandY = (y instanceof Binding) ? ((Binding) y) >+// .getParameterizedCommand() >+// : (ParameterizedCommand) y; >+// >+// return Util.compare(commandX, commandY); >+ IBaseLabelProvider baseLabel = filteredTree.getViewer().getLabelProvider(); >+ if (baseLabel instanceof ITableLabelProvider) { >+ ITableLabelProvider tableProvider = (ITableLabelProvider) baseLabel; >+ String e1p = tableProvider.getColumnText(a, sortColumn); >+ String e2p = tableProvider.getColumnText(b, sortColumn); >+ int result = getComparator().compare(e1p, e2p); >+ return ascending ? result : (-1) * result; >+ } >+ return super.compare(viewer, a, b); >+ > >- return Util.compare(commandX, commandY); > } > } catch (final NotDefinedException e) { > // This could be made a lot more fine-grained. >@@ -594,6 +613,34 @@ > > return 0; > } >+ >+ /** >+ * @return Returns the sortColumn. >+ */ >+ public int getSortColumn() { >+ return sortColumn; >+ } >+ >+ /** >+ * @param sortColumn The sortColumn to set. >+ */ >+ public void setSortColumn(int sortColumn) { >+ this.sortColumn = sortColumn; >+ } >+ >+ /** >+ * @return Returns the ascending. >+ */ >+ public boolean isAscending() { >+ return ascending; >+ } >+ >+ /** >+ * @param ascending The ascending to set. >+ */ >+ public void setAscending(boolean ascending) { >+ this.ascending = ascending; >+ } > } > > /** >@@ -1122,13 +1169,41 @@ > } > } > >+ final BindingComparator comparator = new BindingComparator(); >+ comparator.setSortColumn(0); >+ > // Create the columns for the tree. >+ > final TreeColumn commandNameColumn = new TreeColumn(tree, SWT.LEFT, > BindingLabelProvider.COLUMN_COMMAND); >- commandNameColumn.setText(NewKeysPreferenceMessages.CommandNameColumn_Text); >+ commandNameColumn.setText(NewKeysPreferenceMessages.CommandNameColumn_Text); >+ commandNameColumn.addSelectionListener(new SelectionAdapter(){ >+ public void widgetSelected(SelectionEvent e) { >+ if (comparator.getSortColumn()==0) { >+ comparator.setAscending(!comparator.isAscending()); >+ } >+ comparator.setSortColumn(0); >+ filteredTree.getViewer().refresh(); >+ >+ } >+ >+ }); > final TreeColumn triggerSequenceColumn = new TreeColumn(tree, SWT.LEFT, > BindingLabelProvider.COLUMN_TRIGGER_SEQUENCE); >- triggerSequenceColumn.setText(NewKeysPreferenceMessages.TriggerSequenceColumn_Text); >+ triggerSequenceColumn.setText(NewKeysPreferenceMessages.TriggerSequenceColumn_Text); >+ triggerSequenceColumn.addSelectionListener(new SelectionAdapter(){ >+ public void widgetSelected(SelectionEvent e) { >+ if (comparator.getSortColumn()==1) { >+ comparator.setAscending(!comparator.isAscending()); >+ } >+ comparator.setSortColumn(1); >+ filteredTree.getViewer().refresh(); >+ >+ } >+ >+ }); >+ >+ > new TreeColumn(tree, SWT.LEFT, BindingLabelProvider.COLUMN_ADD); > new TreeColumn(tree, SWT.LEFT, BindingLabelProvider.COLUMN_REMOVE); > >@@ -1136,8 +1211,9 @@ > final TreeViewer viewer = filteredTree.getViewer(); > viewer.setLabelProvider(new BindingLabelProvider()); > viewer.setContentProvider(new TreeNodeContentProvider()); >- viewer.setComparator(new BindingComparator()); >- >+ >+ viewer.setComparator(comparator); >+ > /* > * Listen for selection changes so that the data controls can be > * updated. >@@ -1174,7 +1250,7 @@ > > return filteredTree; > } >- >+ > private final Control createTreeControls(final Composite parent) { > GridLayout layout; > GridData gridData; >@@ -1198,6 +1274,7 @@ > gridData.verticalAlignment = SWT.TOP; > showAllCheckBox.setLayoutData(gridData); > showAllCheckBox.setText(NewKeysPreferenceMessages.ShowAllCheckBox_Text); >+ showAllCheckBox.setSelection(getPreferenceStore().getBoolean(IPreferenceConstants.SHOW_ALL_CHECK_BOX)); > showAllCheckBox.addSelectionListener(new SelectionAdapter() { > public void widgetSelected(SelectionEvent e) { > updateTree(); >@@ -1405,6 +1482,8 @@ > } > > setScheme(localChangeManager.getActiveScheme()); >+ IPreferenceStore store = getPreferenceStore(); >+ showAllCheckBox.setSelection(store.getDefaultBoolean(IPreferenceConstants.SHOW_ALL_CHECK_BOX)); > super.performDefaults(); > } > >@@ -1417,7 +1496,8 @@ > } catch (final IOException e) { > logPreferenceStoreException(e); > } >- >+ IPreferenceStore store = getPreferenceStore(); >+ store.setValue(IPreferenceConstants.SHOW_ALL_CHECK_BOX, showAllCheckBox.getSelection()); > return super.performOk(); > } > >@@ -1813,4 +1893,13 @@ > columns[2].setWidth(22); > columns[3].setWidth(22); > } >+ >+ /** >+ * Returns preference store that belongs to the our plugin. >+ * >+ * @return the preference store for this plugin >+ */ >+ protected IPreferenceStore doGetPreferenceStore() { >+ return WorkbenchPlugin.getDefault().getPreferenceStore(); >+ } > }
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 Raw
Actions:
View
Attachments on
bug 176235
:
60868
|
61014
|
62303
|
62949
|
64943
|
65041
|
65081
|
65134
|
65137
|
65345