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 83408 Details for
Bug 208363
Second level Priority sort by id/summary
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
updated patch
Sorting.patch (text/plain), 18.20 KB, created by
Robert Elves
on 2007-11-21 03:20:56 EST
(
hide
)
Description:
updated patch
Filename:
MIME Type:
Creator:
Robert Elves
Created:
2007-11-21 03:20:56 EST
Size:
18.20 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.mylyn.tasks.tests >Index: src/org/eclipse/mylyn/tasks/tests/TableSorterTest.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.mylyn/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TableSorterTest.java,v >retrieving revision 1.15 >diff -u -r1.15 TableSorterTest.java >--- src/org/eclipse/mylyn/tasks/tests/TableSorterTest.java 26 Jun 2007 01:16:10 -0000 1.15 >+++ src/org/eclipse/mylyn/tasks/tests/TableSorterTest.java 21 Nov 2007 08:12:55 -0000 >@@ -10,14 +10,19 @@ > > import junit.framework.TestCase; > >+import org.eclipse.jface.viewers.ISelection; >+import org.eclipse.jface.viewers.Viewer; > import org.eclipse.mylyn.internal.tasks.core.LocalTask; > import org.eclipse.mylyn.internal.tasks.core.TaskCategory; > import org.eclipse.mylyn.internal.tasks.ui.views.TaskListTableSorter; > import org.eclipse.mylyn.internal.tasks.ui.views.TaskListView; > import org.eclipse.mylyn.tasks.core.AbstractTask; >+import org.eclipse.mylyn.tasks.tests.connector.MockRepositoryTask; >+import org.eclipse.swt.widgets.Control; > > /** > * @author Mik Kersten >+ * @author George Lindholm > */ > public class TableSorterTest extends TestCase { > >@@ -31,4 +36,53 @@ > assertEquals(-1, sorter.compare(null, task, category)); > assertEquals(1, sorter.compare(null, category, task)); > } >+ >+ public class EmptyViewer extends Viewer { >+ public EmptyViewer() { >+ } >+ >+ @Override >+ public Control getControl() { >+ return null; >+ } >+ >+ @Override >+ public Object getInput() { >+ return null; >+ } >+ >+ @Override >+ public ISelection getSelection() { >+ return null; >+ } >+ >+ @Override >+ public void refresh() { >+ } >+ >+ @Override >+ public void setInput(Object input) { >+ } >+ >+ @Override >+ public void setSelection(ISelection selection, boolean reveal) { >+ } >+ } >+ >+ public void testSummaryOrderSorting() { >+ final TaskListTableSorter sorter = new TaskListTableSorter(TaskListView.getFromActivePerspective()); >+ >+ final MockRepositoryTask[] tasks = new MockRepositoryTask[5]; >+ tasks[0] = new MockRepositoryTask("local", "4", "c"); >+ tasks[1] = new MockRepositoryTask("local", "1", "b"); >+ tasks[2] = new MockRepositoryTask("local", "1", "a"); >+ tasks[3] = new MockRepositoryTask("local", "3", "c"); >+ tasks[4] = new MockRepositoryTask("local", "5", "a"); >+ >+ sorter.sort(new EmptyViewer(), tasks); >+ >+ assertTrue("1".equals(tasks[0].getTaskKey()) && "a".equals(tasks[0].getSummary())); >+ assertTrue("5".equals(tasks[4].getTaskKey()) && "a".equals(tasks[4].getSummary())); >+ } >+ > } >#P org.eclipse.mylyn.context.ui >Index: src/org/eclipse/mylyn/internal/context/ui/TaskListInterestSorter.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.mylyn/org.eclipse.mylyn.context.ui/src/org/eclipse/mylyn/internal/context/ui/TaskListInterestSorter.java,v >retrieving revision 1.23 >diff -u -r1.23 TaskListInterestSorter.java >--- src/org/eclipse/mylyn/internal/context/ui/TaskListInterestSorter.java 28 Aug 2007 03:55:27 -0000 1.23 >+++ src/org/eclipse/mylyn/internal/context/ui/TaskListInterestSorter.java 21 Nov 2007 08:12:59 -0000 >@@ -186,9 +186,7 @@ > } > > private int compareKeys(AbstractTaskContainer element1, AbstractTaskContainer element2) { >- String summary1 = TaskListTableSorter.getSortableSummaryFromElement(element1); >- String summary2 = TaskListTableSorter.getSortableSummaryFromElement(element2); >- return taskKeyComparator.compare(summary1, summary2); >+ return taskKeyComparator.compare(TaskListTableSorter.getSortableFromElement(element1), TaskListTableSorter.getSortableFromElement(element2)); > } > > private int comparePriorities(AbstractTaskContainer element1, AbstractTaskContainer element2) { >#P org.eclipse.mylyn.tasks.ui >Index: src/org/eclipse/mylyn/internal/tasks/ui/views/TaskListTableSorter.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.mylyn/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/views/TaskListTableSorter.java,v >retrieving revision 1.30 >diff -u -r1.30 TaskListTableSorter.java >--- src/org/eclipse/mylyn/internal/tasks/ui/views/TaskListTableSorter.java 27 Aug 2007 01:04:13 -0000 1.30 >+++ src/org/eclipse/mylyn/internal/tasks/ui/views/TaskListTableSorter.java 21 Nov 2007 08:13:03 -0000 >@@ -29,16 +29,25 @@ > PRIORITY, SUMMARY, DATE_CREATED; > } > >+ private static final int DEFAULT_SORT_DIRECTION = 1; >+ >+ private int sortDirection = DEFAULT_SORT_DIRECTION; >+ >+ private SortByIndex sortByIndex = SortByIndex.PRIORITY; >+ > private final TaskListView view; > > private TaskKeyComparator taskKeyComparator = new TaskKeyComparator(); > >- private SortByIndex sortByIndex; >+ public TaskListTableSorter(TaskListView view) { >+ super(); >+ this.view = view; >+ } > >- public TaskListTableSorter(TaskListView view, SortByIndex sortByIndex) { >+ public TaskListTableSorter(TaskListView view, SortByIndex index) { > super(); > this.view = view; >- this.sortByIndex = sortByIndex; >+ this.sortByIndex = index; > } > > public void setColumn(String column) { >@@ -90,7 +99,7 @@ > if (!(o1 instanceof AbstractTask)) { > if (o2 instanceof AbstractTaskContainer || o2 instanceof AbstractRepositoryQuery) { > >- return this.view.sortDirection >+ return this.sortDirection > * ((AbstractTaskContainer) o1).getSummary().compareToIgnoreCase( > ((AbstractTaskContainer) o2).getSummary()); > } else { >@@ -113,10 +122,12 @@ > > private int compareElements(AbstractTaskContainer element1, AbstractTaskContainer element2) { > if (SortByIndex.PRIORITY.equals(sortByIndex)) { >- int result = this.view.sortDirection * element1.getPriority().compareTo(element2.getPriority()); >+ int result = this.sortDirection * element1.getPriority().compareTo(element2.getPriority()); > if (result != 0) { > return result; > } >+ return sortBySummary(element1, element2); >+ > } else if (SortByIndex.DATE_CREATED.equals(sortByIndex)) { > AbstractTask t1 = null; > AbstractTask t2 = null; >@@ -132,14 +143,30 @@ > } > } > } else { >- String summary1 = getSortableSummaryFromElement(element1); >- String summary2 = getSortableSummaryFromElement(element2); >- element2.getSummary(); >- return this.view.sortDirection * taskKeyComparator.compare(summary1, summary2); >+ return sortBySummary(element1, element2); > } > return 0; > } > >+ /** >+ * Determine the sort order of two tasks by id/summary >+ * >+ * @param element1 >+ * @param element2 >+ * @return sort order >+ */ >+ private int sortBySummary(AbstractTaskContainer element1, AbstractTaskContainer element2) { >+ return this.sortDirection >+ * taskKeyComparator.compare(getSortableFromElement(element1), getSortableFromElement(element2)); >+ } >+ >+ /** >+ * Return a sortable string in the format "key: summary" >+ * >+ * @param element >+ * @return sortable string >+ * @deprecated Use getSortableFromElement() >+ */ > public static String getSortableSummaryFromElement(AbstractTaskContainer element) { > String summary = element.getSummary(); > >@@ -151,4 +178,48 @@ > } > return summary; > } >+ >+ /** >+ * Return a array of values to pass to taskKeyComparator.compare() for sorting >+ * >+ * @param element >+ * @return String array[key, summary, ""] >+ */ >+ public static String[] getSortableFromElement(AbstractTaskContainer element) { >+ final String a[] = new String[] { "", element.getSummary(), "" }; >+ >+ if (element instanceof AbstractTask) { >+ AbstractTask task1 = (AbstractTask) element; >+ if (task1.getTaskKey() != null) { >+ a[0] = task1.getTaskKey(); >+ } >+ } >+ return a; >+ } >+ >+ public SortByIndex getSortByIndex() { >+ return sortByIndex; >+ } >+ >+ public void setSortByIndex(SortByIndex sortByIndex) { >+ SortByIndex oldValue = this.sortByIndex; >+ this.sortByIndex = sortByIndex; >+ if (!oldValue.equals(sortByIndex)) { >+ view.getViewer().refresh(); >+ } >+ >+ } >+ >+ public int getSortDirection() { >+ return sortDirection; >+ } >+ >+ public void setSortDirection(int sortDirection) { >+ int oldValue = this.sortDirection; >+ this.sortDirection = sortDirection; >+ if (oldValue != this.sortDirection) { >+ view.getViewer().refresh(); >+ } >+ } >+ > } >Index: src/org/eclipse/mylyn/internal/tasks/ui/views/SortyByDropDownAction.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.mylyn/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/views/SortyByDropDownAction.java,v >retrieving revision 1.6 >diff -u -r1.6 SortyByDropDownAction.java >--- src/org/eclipse/mylyn/internal/tasks/ui/views/SortyByDropDownAction.java 10 Jul 2007 00:30:39 -0000 1.6 >+++ src/org/eclipse/mylyn/internal/tasks/ui/views/SortyByDropDownAction.java 21 Nov 2007 08:13:03 -0000 >@@ -71,7 +71,7 @@ > byPriority = new Action("", AS_CHECK_BOX) { > @Override > public void run() { >- taskListView.setSortBy(SortByIndex.PRIORITY); >+ taskListView.getSorter().setSortByIndex(SortByIndex.PRIORITY); > byPriority.setChecked(true); > bySummary.setChecked(false); > byDateCreated.setChecked(false); >@@ -85,7 +85,7 @@ > bySummary = new Action("", AS_CHECK_BOX) { > @Override > public void run() { >- taskListView.setSortBy(SortByIndex.SUMMARY); >+ taskListView.getSorter().setSortByIndex(SortByIndex.SUMMARY); > byPriority.setChecked(false); > bySummary.setChecked(true); > byDateCreated.setChecked(false); >@@ -98,7 +98,7 @@ > byDateCreated = new Action("", AS_CHECK_BOX) { > @Override > public void run() { >- taskListView.setSortBy(SortByIndex.DATE_CREATED); >+ taskListView.getSorter().setSortByIndex(SortByIndex.DATE_CREATED); > byPriority.setChecked(false); > bySummary.setChecked(false); > byDateCreated.setChecked(true); >@@ -114,16 +114,16 @@ > Action reverse = new Action("", AS_CHECK_BOX) { > @Override > public void run() { >- taskListView.setSortDirection(taskListView.sortDirection * -1); >- setChecked(taskListView.sortDirection < 0); >+ taskListView.getSorter().setSortDirection(taskListView.getSorter().getSortDirection() * -1); >+ setChecked(taskListView.getSorter().getSortDirection() < 0); > } > }; > reverse.setEnabled(true); > reverse.setText("Descending"); >- reverse.setChecked(taskListView.sortDirection < 0); >+ reverse.setChecked(taskListView.getSorter().getSortDirection() < 0); > new ActionContributionItem(reverse).fill(dropDownMenu, -1); >- >- switch (taskListView.getSortByIndex()) { >+ >+ switch (taskListView.getSorter().getSortByIndex()) { > case PRIORITY: > byPriority.setChecked(true); > break; >Index: src/org/eclipse/mylyn/internal/tasks/ui/views/TaskKeyComparator.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.mylyn/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/views/TaskKeyComparator.java,v >retrieving revision 1.7 >diff -u -r1.7 TaskKeyComparator.java >--- src/org/eclipse/mylyn/internal/tasks/ui/views/TaskKeyComparator.java 26 Jun 2007 01:16:39 -0000 1.7 >+++ src/org/eclipse/mylyn/internal/tasks/ui/views/TaskKeyComparator.java 21 Nov 2007 08:13:03 -0000 >@@ -21,31 +21,35 @@ > public int compare(String o1, String o2) { > String[] a1 = split(o1); > String[] a2 = split(o2); >+ return compare(a1, a2); >+ } >+ >+ public int compare(final String a1[], final String a2[]) { >+ return compare(a1[0], a1[1], a1[2], a2[0], a2[1], a2[2]); >+ } > >- String s1 = a1[0]; >- String s2 = a2[0]; >- if (s1 == null && s2 != null) >+ public int compare(final String key1, final String value1, final String arb1, final String key2, >+ final String value2, final String arb2) { >+ if (key1 == null && key2 != null) > return -1; >- if (s1 != null && s2 == null) >+ if (key1 != null && key2 == null) > return 1; > >- if (s1 != null && s2 != null) { >- int n = s1.compareToIgnoreCase(s2); >+ if (key1 != null && key2 != null) { >+ int n = key1.compareToIgnoreCase(key2); > if (n != 0) > return n; > >- s1 = a1[1]; >- s2 = a2[1]; >- if (s1.length() == s2.length() || s1.length() == 0 || s2.length() == 0) { >- n = s1.compareTo(s2); >+ if (value1.length() == value2.length() || value1.length() == 0 || value2.length() == 0) { >+ n = value1.compareTo(value2); > } else { >- n = Integer.valueOf(s1).compareTo(Integer.valueOf(s2)); >+ n = Integer.valueOf(value1).compareTo(Integer.valueOf(value2)); > } > if (n != 0) > return n; > } > >- return a1[2].compareToIgnoreCase(a2[2]); >+ return arb1.compareToIgnoreCase(arb2); > } > > public String[] split(String s) { >Index: src/org/eclipse/mylyn/internal/tasks/ui/views/TaskListView.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.mylyn/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/views/TaskListView.java,v >retrieving revision 1.209 >diff -u -r1.209 TaskListView.java >--- src/org/eclipse/mylyn/internal/tasks/ui/views/TaskListView.java 17 Nov 2007 05:22:09 -0000 1.209 >+++ src/org/eclipse/mylyn/internal/tasks/ui/views/TaskListView.java 21 Nov 2007 08:13:07 -0000 >@@ -197,8 +197,6 @@ > > private static final String PART_NAME = "Task List"; > >- private static final int DEFAULT_SORT_DIRECTION = 1; >- > static final String[] PRIORITY_LEVELS = { PriorityLevel.P1.toString(), PriorityLevel.P2.toString(), > PriorityLevel.P3.toString(), PriorityLevel.P4.toString(), PriorityLevel.P5.toString() }; > >@@ -286,16 +284,12 @@ > > private IMemento taskListMemento; > >- private SortByIndex sortByIndex = SortByIndex.PRIORITY; >- > private AbstractTaskListPresentation currentPresentation; > > private TaskTableLabelProvider taskListTableLabelProvider; > > private TaskListTableSorter tableSorter; > >- int sortDirection = DEFAULT_SORT_DIRECTION; >- > private Color categoryGradientStart; > > private Color categoryGradientEnd; >@@ -641,7 +635,7 @@ > public void saveState(IMemento memento) { > IMemento sorter = memento.createChild(MEMENTO_SORT_INDEX); > IMemento m = sorter.createChild(MEMENTO_KEY_SORTER); >- switch (sortByIndex) { >+ switch (tableSorter.getSortByIndex()) { > case SUMMARY: > m.putInteger(MEMENTO_KEY_SORT_INDEX, 1); > break; >@@ -652,16 +646,18 @@ > m.putInteger(MEMENTO_KEY_SORT_INDEX, 0); > } > >- m.putInteger(MEMENTO_KEY_SORT_DIRECTION, sortDirection); >+ m.putInteger(MEMENTO_KEY_SORT_DIRECTION, tableSorter.getSortDirection()); > memento.putString(MEMENTO_LINK_WITH_EDITOR, Boolean.toString(linkWithEditor)); > memento.putString(MEMENTO_PRESENTATION, currentPresentation.getId()); > } > > private void restoreState() { >+ tableSorter = null; > if (taskListMemento != null) { > IMemento sorterMemento = taskListMemento.getChild(MEMENTO_SORT_INDEX); > int restoredSortIndex = 0; > if (sorterMemento != null) { >+ int sortDirection = -1; > IMemento m = sorterMemento.getChild(MEMENTO_KEY_SORTER); > if (m != null) { > Integer sortIndexInt = m.getInteger(MEMENTO_KEY_SORT_INDEX); >@@ -671,27 +667,28 @@ > Integer sortDirInt = m.getInteger(MEMENTO_KEY_SORT_DIRECTION); > if (sortDirInt != null) { > sortDirection = sortDirInt.intValue(); >+ tableSorter = new TaskListTableSorter(this); >+ tableSorter.setSortDirection(sortDirection); >+ switch (restoredSortIndex) { >+ case 1: >+ tableSorter.setSortByIndex(SortByIndex.SUMMARY); >+ break; >+ case 2: >+ tableSorter.setSortByIndex(SortByIndex.DATE_CREATED); >+ break; >+ default: >+ tableSorter.setSortByIndex(SortByIndex.PRIORITY); >+ } > } >- } else { >- sortDirection = DEFAULT_SORT_DIRECTION; > } >- } else { >- sortDirection = DEFAULT_SORT_DIRECTION; >- } >- switch (restoredSortIndex) { >- case 1: >- this.sortByIndex = SortByIndex.SUMMARY; >- break; >- case 2: >- this.sortByIndex = SortByIndex.DATE_CREATED; >- break; >- default: >- this.sortByIndex = SortByIndex.PRIORITY; > } >- > applyPresentation(taskListMemento.getString(MEMENTO_PRESENTATION)); > } > >+ if (tableSorter == null) { >+ tableSorter = new TaskListTableSorter(this); >+ } >+ > filterWorkingSet = new TaskWorkingSetFilter(TasksUiPlugin.getTaskListManager().getTaskList()); > filterWorkingSet.setCurrentWorkingSet(getSite().getPage().getAggregateWorkingSet()); > addFilter(filterWorkingSet); >@@ -711,7 +708,7 @@ > } > setLinkWithEditor(linkValue); > >- getViewer().setSorter(new TaskListTableSorter(this, sortByIndex)); >+ getViewer().setSorter(tableSorter); > getViewer().refresh(); > } > >@@ -758,7 +755,7 @@ > getViewer().setCellEditors(editors); > getViewer().setCellModifier(taskListCellModifier); > >- tableSorter = new TaskListTableSorter(this, TaskListTableSorter.SortByIndex.PRIORITY); >+ tableSorter = new TaskListTableSorter(this); > getViewer().setSorter(tableSorter); > > applyPresentation(CategorizedPresentation.ID); >@@ -961,7 +958,7 @@ > > @Override > public void widgetSelected(SelectionEvent e) { >- sortDirection *= DEFAULT_SORT_DIRECTION; >+ tableSorter.setSortDirection(tableSorter.getSortDirection() * -1); > getViewer().refresh(false); > } > }); >@@ -1583,20 +1580,6 @@ > this.focusedMode = focusedMode; > } > >- public void setSortBy(SortByIndex sortByIndex) { >- this.sortByIndex = sortByIndex; >- getViewer().setSorter(new TaskListTableSorter(this, sortByIndex)); >- } >- >- public void setSortDirection(int sortDirection) { >- this.sortDirection = sortDirection; >- getViewer().setSorter(new TaskListTableSorter(this, sortByIndex)); >- } >- >- public SortByIndex getSortByIndex() { >- return sortByIndex; >- } >- > public void setSynchronizationOverlaid(boolean synchronizationOverlaid) { > this.synchronizationOverlaid = synchronizationOverlaid; > getViewer().refresh(); >@@ -1688,7 +1671,7 @@ > if (!force && taskListToolTip.isTriggeredByMouse()) { > return; > } >- >+ > TreeItem[] selection = getViewer().getTree().getSelection(); > if (selection != null && selection.length > 0) { > Rectangle bounds = selection[0].getBounds(); >@@ -1735,4 +1718,8 @@ > } > } > >+ public TaskListTableSorter getSorter() { >+ return tableSorter; >+ } >+ > }
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 208363
:
81834
|
81835
|
83022
|
83023
| 83408 |
83476
|
83477
|
83706
|
83707
|
83728