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 83728 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
[patch]
NPE fix
clipboard.txt (text/plain), 24.00 KB, created by
George Lindholm
on 2007-11-25 19:08:22 EST
(
hide
)
Description:
NPE fix
Filename:
MIME Type:
Creator:
George Lindholm
Created:
2007-11-25 19:08:22 EST
Size:
24.00 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#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 26 Nov 2007 00:04:53 -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[component, taskId, summary] >+ */ >+ public static String[] getSortableFromElement(AbstractTaskContainer element) { >+ final String a[] = new String[] {"", null, element.getSummary()}; >+ >+ if (element instanceof AbstractTask) { >+ AbstractTask task1 = (AbstractTask) element; >+ if (task1.getTaskKey() != null) { >+ a[1] = 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 26 Nov 2007 00:04:52 -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 26 Nov 2007 00:04:52 -0000 >@@ -14,38 +14,73 @@ > /** > * @author Eugene Kuleshov (https://bugs.eclipse.org/bugs/show_bug.cgi?taskId=129511) > */ >-public class TaskKeyComparator implements Comparator<String> { >+public class TaskKeyComparator implements Comparator<String[]> { > >- public static final Pattern PATTERN = Pattern.compile("(?:([A-Za-z]*[:_\\-]?)(\\d+))?(.*)"); >+ private static final String MODULE_TASK_PATTERN = "(?:([A-Za-z]*[:_\\-]?)(\\d+))?"; >+ private static final Pattern ID_PATTERN = Pattern.compile(MODULE_TASK_PATTERN); >+ public static final Pattern PATTERN = Pattern.compile(MODULE_TASK_PATTERN + "(.*)"); > >- public int compare(String o1, String o2) { >+ public int compare2(String o1, String o2) { > String[] a1 = split(o1); > String[] a2 = split(o2); >+ return compare(a1, a2); >+ } >+ >+ public int compare(String a1[], String a2[]) { >+ if (a1[0] == null && a1[1] == null) { >+ a1 = split(a1[2]); >+ } else if ((a1[0] == null || a1[0].length() == 0) && a1[1] != null && a1[1].length() > 0) { >+ String b1[] = splitTask(a1[1]); >+ a1[0] = b1[0]; >+ a1[1] = b1[1]; >+ } >+ >+ if (a2[0] == null && a2[1] == null) { >+ a2 = split(a2[2]); >+ } else if ((a2[0] == null || a2[0].length() == 0) && a2[1] != null && a2[1].length() > 0) { >+ String b2[] = splitTask(a2[1]); >+ a2[0] = b2[0]; >+ a2[1] = b2[1]; >+ >+ } >+ 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) >+ private static int compare(final String component1, final String key1, final String value1, >+ final String component2, final String key2, final String value2) { >+ if (component1 == null && component2 != null) { > return -1; >- if (s1 != null && s2 == null) >+ } >+ if (component1 != null && component2 == null) { > return 1; >+ } > >- if (s1 != null && s2 != null) { >- int n = s1.compareToIgnoreCase(s2); >- if (n != 0) >+ if (component1 != null && component2 != null) { >+ int n = component1.compareToIgnoreCase(component2); >+ 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); >- } else { >- n = Integer.valueOf(s1).compareTo(Integer.valueOf(s2)); >+ if (key1 == null && key2 != null) { >+ return -1; >+ } >+ if (key1 != null && key2 == null) { >+ return 1; >+ } >+ >+ if (key1 != null && key2 != null) { >+ if (key1.length() == key2.length() || key1.length() == 0 || key2.length() == 0) { >+ n = key1.compareTo(key2); >+ } else { >+ n = Integer.valueOf(key1).compareTo(Integer.valueOf(key2)); >+ } >+ if (n != 0) { >+ return n; >+ } > } >- if (n != 0) >- return n; > } > >- return a1[2].compareToIgnoreCase(a2[2]); >+ return value1.compareToIgnoreCase(value2); > } > > public String[] split(String s) { >@@ -62,4 +97,19 @@ > } > return res; > } >+ private static String[] splitTask(final String s) { >+ Matcher matcher = ID_PATTERN.matcher(s); >+ >+ if (!matcher.find()) { >+ return new String[] {null, s}; >+ } >+ >+ int n = matcher.groupCount(); >+ String[] res = new String[n]; >+ for (int i = 1; i < n + 1; i++) { >+ res[i - 1] = matcher.group(i); >+ } >+ return res; >+ } >+ > } >\ No newline at end of file >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 26 Nov 2007 00:04:54 -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; >+ } >+ > } >Index: src/org/eclipse/mylyn/internal/tasks/ui/search/SearchResultSorterDescription.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.mylyn/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/search/SearchResultSorterDescription.java,v >retrieving revision 1.9 >diff -u -r1.9 SearchResultSorterDescription.java >--- src/org/eclipse/mylyn/internal/tasks/ui/search/SearchResultSorterDescription.java 26 Jun 2007 01:16:41 -0000 1.9 >+++ src/org/eclipse/mylyn/internal/tasks/ui/search/SearchResultSorterDescription.java 26 Nov 2007 00:04:52 -0000 >@@ -11,11 +11,12 @@ > import org.eclipse.jface.viewers.Viewer; > import org.eclipse.jface.viewers.ViewerSorter; > import org.eclipse.mylyn.internal.tasks.ui.views.TaskKeyComparator; >+import org.eclipse.mylyn.internal.tasks.ui.views.TaskListTableSorter; > import org.eclipse.mylyn.tasks.core.AbstractTask; > > /** > * Sorts search results by summary. >- * >+ * > * @author Rob Elves > */ > public class SearchResultSorterDescription extends ViewerSorter { >@@ -26,7 +27,7 @@ > * Returns a negative, zero, or positive number depending on whether the first bug's summary goes before, is the > * same as, or goes after the second element's summary. > * <p> >- * >+ * > * @see org.eclipse.jface.viewers.ViewerSorter#compare(org.eclipse.jface.viewers.Viewer, java.lang.Object, > * java.lang.Object) > */ >@@ -38,7 +39,8 @@ > AbstractTask entry2 = (AbstractTask) e2; > // NOTE we just comparing ids here, once summary and taskId separated > // they should have their own column/sorter. >- return taskKeyComparator.compare(entry1.getTaskId(), entry2.getTaskId()); >+ return taskKeyComparator.compare(TaskListTableSorter.getSortableFromElement(entry1), >+ TaskListTableSorter.getSortableFromElement(entry2)); > // return taskKeyComparator.compare(entry1.getDescription(), > // entry2.getDescription()); > } catch (Exception ignored) { >@@ -54,7 +56,7 @@ > * are arranged in ascending numeric order. The elements within a bin are arranged via a second level sort > * criterion. > * <p> >- * >+ * > * @see org.eclipse.jface.viewers.ViewerSorter#category(Object) > */ > @Override >#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 26 Nov 2007 00:04:55 -0000 >@@ -10,14 +10,20 @@ > > 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.TaskKeyComparator; > 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 +37,80 @@ > 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", "11", "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()) && "b".equals(tasks[0].getSummary())); >+ assertTrue("3".equals(tasks[1].getTaskKey()) && "c".equals(tasks[1].getSummary())); >+ assertTrue("11".equals(tasks[4].getTaskKey()) && "a".equals(tasks[4].getSummary())); >+ } >+ >+ public void testModuleSummaryOrderSorting() { >+ final TaskListTableSorter sorter = new TaskListTableSorter(TaskListView.getFromActivePerspective()); >+ >+ final MockRepositoryTask[] tasks = new MockRepositoryTask[5]; >+ tasks[0] = new MockRepositoryTask("local", "MYLN:4", "c"); >+ tasks[1] = new MockRepositoryTask("local", "MYLN:1", "b"); >+ tasks[2] = new MockRepositoryTask("local", "MYLN:11", "a"); >+ tasks[3] = new MockRepositoryTask("local", "MYLN:11", "b"); >+ tasks[4] = new MockRepositoryTask("local", "MYLN:5", "a"); >+ >+ sorter.sort(new EmptyViewer(), tasks); >+ >+ assertTrue("MYLN:1".equals(tasks[0].getTaskKey()) && "b".equals(tasks[0].getSummary())); >+ assertTrue("MYLN:4".equals(tasks[1].getTaskKey()) && "c".equals(tasks[1].getSummary())); >+ assertTrue("MYLN:11".equals(tasks[4].getTaskKey()) && "b".equals(tasks[4].getSummary())); >+ } >+ >+ public void testLocalTaskSort() { >+ final TaskListTableSorter sorter = new TaskListTableSorter(TaskListView.getFromActivePerspective()); >+ AbstractTask task1 = new LocalTask("1", "task1"); >+ AbstractTask task2 = new LocalTask("2", "task2"); >+ AbstractTask task3 = new LocalTask("3", "task3"); >+ AbstractTask[] tasks = { task1, task2, task3 }; >+ sorter.sort(new EmptyViewer(), tasks); >+ } >+ > } >Index: src/org/eclipse/mylyn/tasks/tests/TaskKeyComparatorTest.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.mylyn/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskKeyComparatorTest.java,v >retrieving revision 1.4 >diff -u -r1.4 TaskKeyComparatorTest.java >--- src/org/eclipse/mylyn/tasks/tests/TaskKeyComparatorTest.java 26 Jun 2007 01:16:10 -0000 1.4 >+++ src/org/eclipse/mylyn/tasks/tests/TaskKeyComparatorTest.java 26 Nov 2007 00:04:55 -0000 >@@ -54,8 +54,11 @@ > assertTrue("Invalid " + Arrays.asList(res) + " " + Arrays.asList(exptecation), Arrays.equals(res, exptecation)); > } > >+ private static final TaskKeyComparator tkc = new TaskKeyComparator(); > public void comparisonCheck(String s1, String s2, int n) { >- assertEquals(n, new TaskKeyComparator().compare(s1, s2)); >+ final String[] c1 = new String[] {null, null, s1}; >+ final String[] c2 = new String[] {null, null, s2}; >+ assertEquals(n, tkc.compare(c1, c2)); > } > > } >#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 26 Nov 2007 00:04:56 -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) {
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 208363
:
81834
|
81835
|
83022
|
83023
|
83408
|
83476
|
83477
|
83706
|
83707
| 83728