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 136130 Details for
Bug 212967
sorting of query nodes and archive categories in the task list
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
patch with new UI
patch212967.txt (text/plain), 54.65 KB, created by
Frank Becker
on 2009-05-17 17:03:49 EDT
(
hide
)
Description:
patch with new UI
Filename:
MIME Type:
Creator:
Frank Becker
Created:
2009-05-17 17:03:49 EDT
Size:
54.65 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.mylyn.tasks.tests >Index: src/org/eclipse/mylyn/tasks/tests/TaskListSorterTest.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.mylyn/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskListSorterTest.java,v >retrieving revision 1.2 >diff -u -r1.2 TaskListSorterTest.java >--- src/org/eclipse/mylyn/tasks/tests/TaskListSorterTest.java 3 May 2009 19:50:18 -0000 1.2 >+++ src/org/eclipse/mylyn/tasks/tests/TaskListSorterTest.java 17 May 2009 21:03:24 -0000 >@@ -32,7 +32,7 @@ > import org.eclipse.mylyn.internal.tasks.core.UnsubmittedTaskContainer; > import org.eclipse.mylyn.internal.tasks.core.WeekDateRange; > import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin; >-import org.eclipse.mylyn.internal.tasks.ui.util.TaskComparator; >+import org.eclipse.mylyn.internal.tasks.ui.util.SortKindEntry; > import org.eclipse.mylyn.internal.tasks.ui.views.TaskListInterestSorter; > import org.eclipse.mylyn.internal.tasks.ui.views.TaskListSorter; > import org.eclipse.mylyn.tasks.core.ITask; >@@ -57,22 +57,22 @@ > task1.setPriority("P5"); > task2.setPriority("P1"); > >- sorter.getComparator().setSortByIndex(TaskComparator.SortByIndex.TASK_ID); >+ sorter.getComparator().setSortByIndex(SortKindEntry.SortByIndex.TASK_ID); > sorter.sort(new EmptyViewer(), tasks); > assertEquals(task1, tasks[1]); > assertEquals(task2, tasks[0]); > >- sorter.getComparator().setSortByIndex(TaskComparator.SortByIndex.DATE_CREATED); >+ sorter.getComparator().setSortByIndex(SortKindEntry.SortByIndex.DATE_CREATED); > sorter.sort(new EmptyViewer(), tasks); > assertEquals(task1, tasks[0]); > assertEquals(task2, tasks[1]); > >- sorter.getComparator().setSortByIndex(TaskComparator.SortByIndex.PRIORITY); >+ sorter.getComparator().setSortByIndex(SortKindEntry.SortByIndex.PRIORITY); > sorter.sort(new EmptyViewer(), tasks); > assertEquals(task1, tasks[1]); > assertEquals(task2, tasks[0]); > >- sorter.getComparator().setSortByIndex(TaskComparator.SortByIndex.SUMMARY); >+ sorter.getComparator().setSortByIndex(SortKindEntry.SortByIndex.SUMMARY); > sorter.getComparator().setSortDirection(-1); > sorter.sort(new EmptyViewer(), tasks); > assertEquals(task1, tasks[0]); >@@ -82,7 +82,7 @@ > > public void testRootTaskSorting() { > TaskListSorter sorter = new TaskListSorter(); >- sorter.getComparator().setSortByIndex(TaskComparator.SortByIndex.SUMMARY); >+ sorter.getComparator().setSortByIndex(SortKindEntry.SortByIndex.SUMMARY); > > AbstractTask task = new LocalTask("1", ""); > UncategorizedTaskContainer uncategorizedTaskContainer = new UncategorizedTaskContainer(); >@@ -198,8 +198,8 @@ > tasks[0].setCreationDate(new Date(start.getTime() - 5)); > > TaskListSorter sorter = new TaskListSorter(); >- sorter.getComparator().setSortByIndex(TaskComparator.SortByIndex.SUMMARY); >- sorter.getComparator().setSortByIndex2(TaskComparator.SortByIndex.DATE_CREATED); >+ sorter.getComparator().setSortByIndex(SortKindEntry.SortByIndex.SUMMARY); >+ sorter.getComparator().setSortByIndex2(SortKindEntry.SortByIndex.DATE_CREATED); > sorter.sort(new EmptyViewer(), tasks); > > assertEquals("11", tasks[0].getTaskKey()); >@@ -227,8 +227,8 @@ > tasks[0].setCreationDate(new Date(start.getTime() - 4)); > > TaskListSorter sorter = new TaskListSorter(); >- sorter.getComparator().setSortByIndex(TaskComparator.SortByIndex.SUMMARY); >- sorter.getComparator().setSortByIndex2(TaskComparator.SortByIndex.DATE_CREATED); >+ sorter.getComparator().setSortByIndex(SortKindEntry.SortByIndex.SUMMARY); >+ sorter.getComparator().setSortByIndex2(SortKindEntry.SortByIndex.DATE_CREATED); > sorter.sort(new EmptyViewer(), tasks); > > assertEquals("MYLN:11", tasks[0].getTaskKey()); >@@ -250,7 +250,7 @@ > task1.setCreationDate(start); > task2.setCreationDate(new Date(start.getTime() - 1)); > task3.setCreationDate(new Date(start.getTime() - 2)); >- sorter.getComparator().setSortByIndex(TaskComparator.SortByIndex.DATE_CREATED); >+ sorter.getComparator().setSortByIndex(SortKindEntry.SortByIndex.DATE_CREATED); > sorter.sort(new EmptyViewer(), tasks); > sorter.getComparator().setSortDirection(-1); > sorter.sort(new EmptyViewer(), tasks); >#P org.eclipse.mylyn.tasks.ui >Index: src/org/eclipse/mylyn/internal/tasks/ui/views/Messages.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.mylyn/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/views/Messages.java,v >retrieving revision 1.4 >diff -u -r1.4 Messages.java >--- src/org/eclipse/mylyn/internal/tasks/ui/views/Messages.java 28 Jan 2009 02:48:57 -0000 1.4 >+++ src/org/eclipse/mylyn/internal/tasks/ui/views/Messages.java 17 May 2009 21:03:26 -0000 >@@ -59,6 +59,12 @@ > > public static String TaskListFilteredTree_Workweek_Progress; > >+ public static String TaskListSorter_Catagory_and_Query; >+ >+ public static String TaskListSorter_Catagory_and_Repository; >+ >+ public static String TaskListSorter_No_Grouping; >+ > public static String TaskListToolTip_Automatic_container_for_all_local_tasks; > > public static String TaskListToolTip_Automatic_container_for_repository_tasks; >Index: src/org/eclipse/mylyn/internal/tasks/ui/views/messages.properties >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.mylyn/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/views/messages.properties,v >retrieving revision 1.4 >diff -u -r1.4 messages.properties >--- src/org/eclipse/mylyn/internal/tasks/ui/views/messages.properties 28 Jan 2009 02:48:57 -0000 1.4 >+++ src/org/eclipse/mylyn/internal/tasks/ui/views/messages.properties 17 May 2009 21:03:26 -0000 >@@ -19,6 +19,9 @@ > TaskListFilteredTree_Select_Active_Task=Select Active Task > TaskListFilteredTree_Select_Working_Set=Select Working Set > TaskListFilteredTree_Workweek_Progress=Workweek Progress >+TaskListSorter_Catagory_and_Query=Category and Query >+TaskListSorter_Catagory_and_Repository=Category and Repository >+TaskListSorter_No_Grouping=no Grouping > > TaskListToolTip_Automatic_container_for_all_local_tasks=Automatic container for all local tasks\nwith no category set > TaskListToolTip_Automatic_container_for_repository_tasks=Automatic container for repository tasks\nnot matched by any query >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.315 >diff -u -r1.315 TaskListView.java >--- src/org/eclipse/mylyn/internal/tasks/ui/views/TaskListView.java 13 May 2009 20:06:08 -0000 1.315 >+++ src/org/eclipse/mylyn/internal/tasks/ui/views/TaskListView.java 17 May 2009 21:03:26 -0000 >@@ -764,109 +764,21 @@ > > @Override > public void saveState(IMemento memento) { >- IMemento sorter = memento.createChild(MEMENTO_SORT_INDEX); >- IMemento m = sorter.createChild(MEMENTO_KEY_SORTER); >- switch (tableSorter.getComparator().getSortByIndex()) { >- case SUMMARY: >- m.putInteger(MEMENTO_KEY_SORT_INDEX, 1); >- break; >- case DATE_CREATED: >- m.putInteger(MEMENTO_KEY_SORT_INDEX, 2); >- break; >- case TASK_ID: >- m.putInteger(MEMENTO_KEY_SORT_INDEX, 3); >- break; >- default: >- m.putInteger(MEMENTO_KEY_SORT_INDEX, 0); >- } >- >- m.putInteger(MEMENTO_KEY_SORT_DIRECTION, tableSorter.getComparator().getSortDirection()); >- IMemento m2 = sorter.createChild(MEMENTO_KEY_SORTER2); >- switch (tableSorter.getComparator().getSortByIndex2()) { >- case SUMMARY: >- m2.putInteger(MEMENTO_KEY_SORT_INDEX, 1); >- break; >- case DATE_CREATED: >- m2.putInteger(MEMENTO_KEY_SORT_INDEX, 2); >- break; >- case TASK_ID: >- m2.putInteger(MEMENTO_KEY_SORT_INDEX, 3); >- break; >- default: >- m2.putInteger(MEMENTO_KEY_SORT_INDEX, 0); >+ if (tableSorter != null) { >+ tableSorter.saveState(memento); > } > >- m2.putInteger(MEMENTO_KEY_SORT_DIRECTION, tableSorter.getComparator().getSortDirection2()); > memento.putString(MEMENTO_LINK_WITH_EDITOR, Boolean.toString(linkWithEditor)); > memento.putString(MEMENTO_PRESENTATION, currentPresentation.getId()); >- memento.putInteger(MEMENTO_KEY_ROOT_SORT_DIRECTION, tableSorter.getSortDirectionRootElement()); > } > > private void restoreState() { > 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); >- if (sortIndexInt != null) { >- restoredSortIndex = sortIndexInt.intValue(); >- } >- Integer sortDirInt = m.getInteger(MEMENTO_KEY_SORT_DIRECTION); >- if (sortDirInt != null) { >- sortDirection = sortDirInt.intValue(); >- tableSorter.getComparator().setSortDirection(sortDirection); >- switch (restoredSortIndex) { >- case 1: >- tableSorter.getComparator().setSortByIndex(TaskComparator.SortByIndex.SUMMARY); >- break; >- case 2: >- tableSorter.getComparator().setSortByIndex(TaskComparator.SortByIndex.DATE_CREATED); >- break; >- case 3: >- tableSorter.getComparator().setSortByIndex(TaskComparator.SortByIndex.TASK_ID); >- break; >- default: >- tableSorter.getComparator().setSortByIndex(TaskComparator.SortByIndex.PRIORITY); >- } >- } >- } >- >- IMemento m2 = sorterMemento.getChild(MEMENTO_KEY_SORTER2); >- if (m2 != null) { >- Integer sortIndexInt = m2.getInteger(MEMENTO_KEY_SORT_INDEX); >- if (sortIndexInt != null) { >- restoredSortIndex = sortIndexInt.intValue(); >- } >- Integer sortDirInt = m2.getInteger(MEMENTO_KEY_SORT_DIRECTION); >- if (sortDirInt != null) { >- sortDirection = sortDirInt.intValue(); >- tableSorter.getComparator().setSortDirection2(sortDirection); >- switch (restoredSortIndex) { >- case 1: >- tableSorter.getComparator().setSortByIndex2(TaskComparator.SortByIndex.SUMMARY); >- break; >- case 2: >- tableSorter.getComparator().setSortByIndex2(TaskComparator.SortByIndex.DATE_CREATED); >- break; >- case 3: >- tableSorter.getComparator().setSortByIndex2(TaskComparator.SortByIndex.TASK_ID); >- break; >- default: >- tableSorter.getComparator().setSortByIndex2(TaskComparator.SortByIndex.PRIORITY); >- } >- } >- } >+ if (tableSorter != null) { >+ tableSorter.restoreState(taskListMemento); > } >+ > applyPresentation(taskListMemento.getString(MEMENTO_PRESENTATION)); >- Integer sortOrder = taskListMemento.getInteger(MEMENTO_KEY_ROOT_SORT_DIRECTION); >- if (sortOrder != null) { >- tableSorter.setSortDirectionRootElement(sortOrder); >- } else { >- tableSorter.setSortDirectionRootElement(TaskListSorter.DEFAULT_SORT_DIRECTION); >- } > } > > filterWorkingSet = new TaskWorkingSetFilter(); >Index: src/org/eclipse/mylyn/internal/tasks/ui/views/TaskListSorter.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.mylyn/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/views/TaskListSorter.java,v >retrieving revision 1.1 >diff -u -r1.1 TaskListSorter.java >--- src/org/eclipse/mylyn/internal/tasks/ui/views/TaskListSorter.java 18 Jan 2009 08:53:02 -0000 1.1 >+++ src/org/eclipse/mylyn/internal/tasks/ui/views/TaskListSorter.java 17 May 2009 21:03:26 -0000 >@@ -11,10 +11,14 @@ > > package org.eclipse.mylyn.internal.tasks.ui.views; > >+import java.text.Collator; >+ >+import org.eclipse.core.runtime.Assert; > import org.eclipse.jface.viewers.Viewer; > import org.eclipse.jface.viewers.ViewerSorter; > import org.eclipse.mylyn.internal.tasks.core.AbstractTask; > import org.eclipse.mylyn.internal.tasks.core.AbstractTaskContainer; >+import org.eclipse.mylyn.internal.tasks.core.ITaskRepositoryElement; > import org.eclipse.mylyn.internal.tasks.core.RepositoryQuery; > import org.eclipse.mylyn.internal.tasks.core.ScheduledTaskContainer; > import org.eclipse.mylyn.internal.tasks.core.TaskCategory; >@@ -24,21 +28,69 @@ > import org.eclipse.mylyn.internal.tasks.core.UnsubmittedTaskContainer; > import org.eclipse.mylyn.internal.tasks.ui.util.TaskComparator; > import org.eclipse.mylyn.tasks.core.ITask; >+import org.eclipse.mylyn.tasks.core.TaskRepository; >+import org.eclipse.mylyn.tasks.ui.TasksUi; >+import org.eclipse.ui.IMemento; > > /** > * @author Mik Kersten > */ > public class TaskListSorter extends ViewerSorter { > >- public static final int DEFAULT_SORT_DIRECTION = 1; >+ private static final String MEMENTO_KEY_SORTER = "sorter"; //$NON-NLS-1$ >+ >+ private static final String MEMENTO_KEY_GROUP_BY = "groupBy"; //$NON-NLS-1$ >+ >+ private static final TaskListSorter.GroupBy DEFAULT_GROUP_BY = TaskListSorter.GroupBy.NONE; >+ >+ public enum GroupBy { >+ NONE, CATEGORY_QUERY, CATEGORY_REPOSITORY; >+ >+ public String getLabel() { >+ switch (this) { >+ case NONE: >+ return Messages.TaskListSorter_No_Grouping; >+ case CATEGORY_QUERY: >+ return Messages.TaskListSorter_Catagory_and_Query; >+ case CATEGORY_REPOSITORY: >+ return Messages.TaskListSorter_Catagory_and_Repository; >+ default: >+ return null; >+ } >+ } >+ >+ public static GroupBy valueOfLabel(String label) { >+ for (GroupBy value : values()) { >+ if (value.getLabel().equals(label)) { >+ return value; >+ } >+ } >+ return null; >+ } >+ >+ } > >- private int sortDirectionRootElement; >+ private class SortKey { >+ >+ private int weight; >+ >+ private final String[] values = new String[3]; >+ >+ } > > private final TaskComparator taskComparator; > >+ private GroupBy groupBy; >+ >+ private final SortKey key1; >+ >+ private final SortKey key2; >+ > public TaskListSorter() { >- this.sortDirectionRootElement = DEFAULT_SORT_DIRECTION; > this.taskComparator = new TaskComparator(); >+ this.groupBy = GroupBy.NONE; >+ this.key1 = new SortKey(); >+ this.key2 = new SortKey(); > } > > /** >@@ -57,54 +109,93 @@ > ScheduledTaskContainer dateRangeTaskContainer2 = (ScheduledTaskContainer) o2; > return dateRangeTaskContainer1.getDateRange().compareTo(dateRangeTaskContainer2.getDateRange()); > } else { >- int o1Type; >- if (o1 instanceof AbstractTask) { >- o1Type = 0; >- } else if (o1 instanceof UncategorizedTaskContainer) { >- o1Type = 1; >- } else if (o1 instanceof UnsubmittedTaskContainer) { >- o1Type = 2; >- } else if (o1 instanceof TaskCategory) { >- o1Type = 3; >- } else if (o1 instanceof RepositoryQuery) { >- o1Type = 4; >- } else if (o1 instanceof TaskGroup) { // support for the experimental grouping of tasks >- o1Type = 5; >- } else if (o1 instanceof UnmatchedTaskContainer) { >- o1Type = 6; >- } else { >- o1Type = 99; >- } >- int o2Type; >- if (o2 instanceof AbstractTask) { >- o2Type = 0; >- } else if (o2 instanceof UncategorizedTaskContainer) { >- o2Type = 1; >- } else if (o2 instanceof UnsubmittedTaskContainer) { >- o2Type = 2; >- } else if (o2 instanceof TaskCategory) { >- o2Type = 3; >- } else if (o2 instanceof RepositoryQuery) { >- o2Type = 4; >- } else if (o2 instanceof TaskGroup) { // support for the experimental grouping of tasks >- o2Type = 5; >- } else if (o2 instanceof UnmatchedTaskContainer) { >- o2Type = 6; >- } else { >- o2Type = 99; >+ updateKey(key1, o1); >+ updateKey(key2, o2); >+ >+ if (key1.weight != key2.weight) { >+ return key1.weight - key2.weight < 0 ? -1 : 1; > } >- if (o1Type != o2Type) { >- return o1Type - o2Type < 0 ? -1 : 1; >+ int result = compare(key1.values[0], key2.values[0]); >+ if (result != 0) { >+ return result; > } >- if (o1Type < 7) { >- AbstractTaskContainer taskContainer1 = (AbstractTaskContainer) o1; >- AbstractTaskContainer taskContainer2 = (AbstractTaskContainer) o2; >+ result = compare(key1.values[1], key2.values[1]); >+ return (result != 0) ? result : compare(key1.values[2], key2.values[2]); >+ } >+ } >+ >+ private int compare(String key1, String key2) { >+ if (key1 == null) { >+ return (key2 != null) ? 1 : 0; >+ } else if (key2 == null) { >+ return -1; >+ } >+ return Collator.getInstance().compare(key1, key2); >+ } > >- return this.sortDirectionRootElement >- * taskContainer1.getSummary().compareToIgnoreCase(taskContainer2.getSummary()); >+ private void updateKey(SortKey key, Object object) { >+ int weight; >+ if (object instanceof AbstractTask) { >+ weight = 0; >+ } else if (object instanceof UncategorizedTaskContainer) { >+ weight = 1; >+ } else if (object instanceof UnsubmittedTaskContainer) { >+ weight = 2; >+ } else if (object instanceof TaskCategory) { >+ weight = 3; >+ } else if (object instanceof RepositoryQuery) { >+ weight = 4; >+ } else if (object instanceof TaskGroup) { // support for the experimental grouping of tasks >+ weight = 5; >+ } else if (object instanceof UnmatchedTaskContainer) { >+ weight = 6; >+ } else { >+ weight = 99; >+ } >+ >+ key.values[0] = ((AbstractTaskContainer) object).getSummary(); >+ key.values[1] = null; >+ key.values[2] = null; >+ >+ switch (groupBy) { >+ case NONE: >+ weight = 1; >+ break; >+ case CATEGORY_QUERY: >+ break; >+ case CATEGORY_REPOSITORY: >+ if (weight == 1) { >+ // keep >+ } else if (weight == 3) { >+ weight = 2; >+ } else { >+ key.values[0] = getRepositoryUrl(object); >+ key.values[1] = weight + ""; //$NON-NLS-1$ >+ key.values[2] = ((AbstractTaskContainer) object).getSummary(); >+ weight = 3; > } >+ break; >+ } >+ >+ key.weight = weight; >+ } >+ >+ private String getRepositoryUrl(Object object) { >+ if (object instanceof ITaskRepositoryElement) { >+ ITaskRepositoryElement repositoryElement = (ITaskRepositoryElement) object; >+ String repositoryUrl = repositoryElement.getRepositoryUrl(); >+ TaskRepository taskRepository = TasksUi.getRepositoryManager().getRepository( >+ repositoryElement.getConnectorKind(), repositoryUrl); >+ return taskRepository != null ? taskRepository.getRepositoryLabel() : null; > } >- return 0; >+// if (object instanceof UnsubmittedTaskContainer) { >+// return ((UnsubmittedTaskContainer) object).getRepositoryUrl(); >+// } else if (object instanceof RepositoryQuery) { >+// return ((RepositoryQuery) object).getRepositoryUrl(); >+// } else if (object instanceof UnmatchedTaskContainer) { >+// return ((UnmatchedTaskContainer) object).getRepositoryUrl(); >+// } >+ return null; > } > > private int compareElements(ITask element1, ITask element2) { >@@ -116,12 +207,40 @@ > return taskComparator; > } > >- public int getSortDirectionRootElement() { >- return sortDirectionRootElement; >+ public GroupBy getGroupBy() { >+ return groupBy; >+ } >+ >+ public void setGroupBy(GroupBy sortByIndex) { >+ Assert.isNotNull(sortByIndex); >+ this.groupBy = sortByIndex; > } > >- public void setSortDirectionRootElement(int sortDirection) { >- this.sortDirectionRootElement = sortDirection; >+ public void restoreState(IMemento memento) { >+ IMemento child = memento.getChild(MEMENTO_KEY_SORTER); >+ if (child != null) { >+ getComparator().restoreState(child); >+ } >+ setGroupBy(getGroupBy(memento, MEMENTO_KEY_GROUP_BY, DEFAULT_GROUP_BY)); > } > >+ public void saveState(IMemento memento) { >+ IMemento child = memento.createChild(MEMENTO_KEY_SORTER); >+ if (child != null) { >+ getComparator().saveState(child); >+ } >+ memento.putString(MEMENTO_KEY_GROUP_BY, getGroupBy().name()); >+ } >+ >+ private TaskListSorter.GroupBy getGroupBy(IMemento memento, String key, TaskListSorter.GroupBy defaultValue) { >+ String value = memento.getString(key); >+ if (value != null) { >+ try { >+ return TaskListSorter.GroupBy.valueOf(value); >+ } catch (IllegalArgumentException e) { >+ // ignore >+ } >+ } >+ return defaultValue; >+ } > } >Index: src/org/eclipse/mylyn/internal/tasks/ui/util/Messages.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.mylyn/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/util/Messages.java,v >retrieving revision 1.7 >diff -u -r1.7 Messages.java >--- src/org/eclipse/mylyn/internal/tasks/ui/util/Messages.java 11 Feb 2009 00:14:00 -0000 1.7 >+++ src/org/eclipse/mylyn/internal/tasks/ui/util/Messages.java 17 May 2009 21:03:26 -0000 >@@ -41,6 +41,16 @@ > > public static String ImportExportUtil_Tasks_and_queries_Filter0; > >+ public static String SortKindEntry_Date_Created; >+ >+ public static String SortKindEntry_None; >+ >+ public static String SortKindEntry_Priority; >+ >+ public static String SortKindEntry_Summary; >+ >+ public static String SortKindEntry_Task_ID; >+ > public static String TaskDataExportOperation_exporting_task_data; > > public static String TasksUiInternal_Configuration_Refresh_Failed; >Index: src/org/eclipse/mylyn/internal/tasks/ui/util/TaskComparator.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.mylyn/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/util/TaskComparator.java,v >retrieving revision 1.7 >diff -u -r1.7 TaskComparator.java >--- src/org/eclipse/mylyn/internal/tasks/ui/util/TaskComparator.java 8 May 2009 06:13:37 -0000 1.7 >+++ src/org/eclipse/mylyn/internal/tasks/ui/util/TaskComparator.java 17 May 2009 21:03:26 -0000 >@@ -16,7 +16,7 @@ > import java.util.Date; > > import org.eclipse.core.runtime.Assert; >-import org.eclipse.mylyn.internal.tasks.ui.dialogs.Messages; >+import org.eclipse.mylyn.internal.tasks.ui.util.SortKindEntry.SortByIndex; > import org.eclipse.mylyn.internal.tasks.ui.views.TaskKeyComparator; > import org.eclipse.mylyn.tasks.core.IRepositoryElement; > import org.eclipse.mylyn.tasks.core.ITask; >@@ -28,49 +28,31 @@ > */ > public class TaskComparator implements Comparator<ITask> { > >- public enum SortByIndex { >- DATE_CREATED, PRIORITY, SUMMARY, TASK_ID; >- >- public static SortByIndex valueOfLabel(String label) { >- for (SortByIndex value : values()) { >- if (value.getLabel().equals(label)) { >- return value; >- } >- } >- return null; >- } >- >- public String getLabel() { >- switch (this) { >- case PRIORITY: >- return Messages.TaskCompareDialog_Priority; >- case SUMMARY: >- return Messages.TaskCompareDialog_Summary; >- case DATE_CREATED: >- return Messages.TaskCompareDialog_DateCreated; >- case TASK_ID: >- return Messages.TaskCompareDialog_TaskID; >- default: >- return null; >- } >- } >- >- } >+ private final SortKindEntry[] sortKindEntries; > >+ @Deprecated > public static final int DEFAULT_SORT_DIRECTION = 1; > >+ @Deprecated > private static final SortByIndex DEFAULT_SORT_INDEX = SortByIndex.PRIORITY; > >+ @Deprecated > private static final SortByIndex DEFAULT_SORT_INDEX2 = SortByIndex.DATE_CREATED; > >+ @Deprecated > private static final String MEMENTO_KEY_SORT_DIRECTION = "sortDirection"; //$NON-NLS-1$ > >+ @Deprecated > private static final String MEMENTO_KEY_SORT_DIRECTION2 = "sortDirection2"; //$NON-NLS-1$ > >+ @Deprecated > private static final String MEMENTO_KEY_SORT_INDEX = "sortIndex"; //$NON-NLS-1$ > >+ @Deprecated > private static final String MEMENTO_KEY_SORT_INDEX2 = "sortIndex2"; //$NON-NLS-1$ > >+ private static final String MEMENTO_KEY_SORT = "sort"; //$NON-NLS-1$ >+ > /** > * Return a array of values to pass to taskKeyComparator.compare() for sorting > * >@@ -90,98 +72,127 @@ > return a; > } > >- private SortByIndex sortByIndex = DEFAULT_SORT_INDEX; >- >- private SortByIndex sortByIndex2 = DEFAULT_SORT_INDEX2; >- >- private int sortDirection = DEFAULT_SORT_DIRECTION; >- >- private int sortDirection2 = DEFAULT_SORT_DIRECTION; >- > private final TaskKeyComparator taskKeyComparator = new TaskKeyComparator(); > > public TaskComparator() { >+ sortKindEntries = new SortKindEntry[SortKindEntry.kindCount]; >+ for (int index = 0; index < SortKindEntry.kindCount; index++) { >+ sortKindEntries[index] = new SortKindEntry(); >+ } >+ sortKindEntries[0].setKind(DEFAULT_SORT_INDEX); >+ sortKindEntries[1].setKind(DEFAULT_SORT_INDEX2); > } > >- public int compare(ITask element1, ITask element2) { >- if (DEFAULT_SORT_INDEX.equals(sortByIndex)) { >- int result = sortByPriority(element1, element2, sortDirection); >- if (result != 0) { >- return result; >- } >+ private int compareInternal(int index, ITask element1, ITask element2) { >+ int result; >+ switch (sortKindEntries[index].getKind()) { >+ case DATE_CREATED: >+ result = sortByDate(element1, element2, sortKindEntries[index].getSortDirection()); >+ break; >+ case PRIORITY: >+ result = sortByPriority(element1, element2, sortKindEntries[index].getSortDirection()); >+ break; >+ case SUMMARY: >+ result = sortBySummary(element1, element2, sortKindEntries[index].getSortDirection()); >+ break; >+ case TASK_ID: >+ result = sortByID(element1, element2, sortKindEntries[index].getSortDirection()); >+ break; >+ case NONE: >+ default: >+ result = 0; >+ break; >+ } > >- if (DEFAULT_SORT_INDEX2.equals(sortByIndex2)) { >- return sortByDate(element1, element2, sortDirection2); >- } else { >- if (SortByIndex.SUMMARY.equals(sortByIndex2)) { >- return sortBySummary(element1, element2, sortDirection2); >- } else if (SortByIndex.TASK_ID.equals(sortByIndex2)) { >- return sortByID(element1, element2, sortDirection2); >- } else { >- return result; >- } >- } >- } else if (DEFAULT_SORT_INDEX2.equals(sortByIndex)) { >- int result = sortByDate(element1, element2, sortDirection); >- if (result != 0) { >- return result; >- } >- if (DEFAULT_SORT_INDEX.equals(sortByIndex2)) { >- return sortByPriority(element1, element2, sortDirection2); >- } else { >- if (SortByIndex.SUMMARY.equals(sortByIndex2)) { >- return sortBySummary(element1, element2, sortDirection2); >- } else if (SortByIndex.TASK_ID.equals(sortByIndex2)) { >- return sortByID(element1, element2, sortDirection2); >- } else { >- return result; >- } >- } >- } else if (SortByIndex.SUMMARY.equals(sortByIndex)) { >- int result = sortBySummary(element1, element2, sortDirection); >- if (result != 0) { >- return result; >- } >- if (DEFAULT_SORT_INDEX2.equals(sortByIndex2)) { >- return sortByDate(element1, element2, sortDirection2); >- } else { >- if (DEFAULT_SORT_INDEX.equals(sortByIndex2)) { >- return sortByPriority(element1, element2, sortDirection2); >- } else if (SortByIndex.TASK_ID.equals(sortByIndex2)) { >- return sortByID(element1, element2, sortDirection2); >- } else { >- return result; >- } >- } >- } else { >- int result = sortByID(element1, element2, sortDirection); >- if (result != 0) { >- return result; >- } >- if (DEFAULT_SORT_INDEX2.equals(sortByIndex2)) { >- return sortByDate(element1, element2, sortDirection2); >- } else { >- if (DEFAULT_SORT_INDEX.equals(sortByIndex2)) { >- return sortByPriority(element1, element2, sortDirection2); >- } else if (SortByIndex.SUMMARY.equals(sortByIndex2)) { >- return sortBySummary(element1, element2, sortDirection2); >- } else { >- return result; >- } >- } >+ if (result != 0 && index < 3 && sortKindEntries[index].getKind() != SortKindEntry.SortByIndex.NONE) { >+ result = compareInternal(index + 1, element1, element2); > } >+ return result; >+ } >+ >+ public int compare(ITask element1, ITask element2) { >+ return compareInternal(0, element1, element2); >+// if (DEFAULT_SORT_INDEX.equals(sortKindEntries[0].getKind())) { >+// int result = sortByPriority(element1, element2, sortKindEntries[0].getSortDirection()); >+// if (result != 0) { >+// return result; >+// } >+// >+// switch (sortKindEntries[1].getKind()) { >+// case DATE_CREATED: >+// return sortByDate(element1, element2, sortKindEntries[1].getSortDirection()); >+// case SUMMARY: >+// return sortBySummary(element1, element2, sortKindEntries[1].getSortDirection()); >+// case TASK_ID: >+// return sortByID(element1, element2, sortKindEntries[1].getSortDirection()); >+// default: >+// return result; >+// } >+// } else if (DEFAULT_SORT_INDEX2.equals(sortKindEntries[1].getKind())) { >+// int result = sortByDate(element1, element2, sortKindEntries[0].getSortDirection()); >+// if (result != 0) { >+// return result; >+// } >+// if (DEFAULT_SORT_INDEX.equals(sortKindEntries[1].getKind())) { >+// return sortByPriority(element1, element2, sortKindEntries[1].getSortDirection()); >+// } else { >+// if (SortByIndex.SUMMARY.equals(sortKindEntries[1].getKind())) { >+// return sortBySummary(element1, element2, sortKindEntries[1].getSortDirection()); >+// } else if (SortByIndex.TASK_ID.equals(sortKindEntries[1].getKind())) { >+// return sortByID(element1, element2, sortKindEntries[1].getSortDirection()); >+// } else { >+// return result; >+// } >+// } >+// } else if (SortByIndex.SUMMARY.equals(sortKindEntries[1].getKind())) { >+// int result = sortBySummary(element1, element2, sortKindEntries[0].getSortDirection()); >+// if (result != 0) { >+// return result; >+// } >+// if (DEFAULT_SORT_INDEX2.equals(sortKindEntries[1].getKind())) { >+// return sortByDate(element1, element2, sortKindEntries[1].getSortDirection()); >+// } else { >+// if (DEFAULT_SORT_INDEX.equals(sortKindEntries[1].getKind())) { >+// return sortByPriority(element1, element2, sortKindEntries[1].getSortDirection()); >+// } else if (SortByIndex.TASK_ID.equals(sortKindEntries[1].getKind())) { >+// return sortByID(element1, element2, sortKindEntries[1].getSortDirection()); >+// } else { >+// return result; >+// } >+// } >+// } else { >+// int result = sortByID(element1, element2, sortKindEntries[0].getSortDirection()); >+// if (result != 0) { >+// return result; >+// } >+// if (DEFAULT_SORT_INDEX2.equals(sortKindEntries[1].getKind())) { >+// return sortByDate(element1, element2, sortKindEntries[1].getSortDirection()); >+// } else { >+// if (DEFAULT_SORT_INDEX.equals(sortKindEntries[1].getKind())) { >+// return sortByPriority(element1, element2, sortKindEntries[1].getSortDirection()); >+// } else if (SortByIndex.SUMMARY.equals(sortKindEntries[1].getKind())) { >+// return sortBySummary(element1, element2, sortKindEntries[1].getSortDirection()); >+// } else { >+// return result; >+// } >+// } >+// } >+ } >+ >+ public SortKindEntry[] getSortKindEntries() { >+ return sortKindEntries; > } > > public SortByIndex getSortByIndex() { >- return sortByIndex; >+ return sortKindEntries[0].getKind(); > } > > public SortByIndex getSortByIndex2() { >- return sortByIndex2; >+ return sortKindEntries[1].getKind(); > } > > public int getSortDirection() { >- return sortDirection; >+ return sortKindEntries[0].getSortDirection(); > } > > private int getSortDirection(IMemento memento, String key, int defaultValue) { >@@ -193,7 +204,7 @@ > } > > public int getSortDirection2() { >- return sortDirection2; >+ return sortKindEntries[1].getSortDirection(); > } > > private SortByIndex getSortIndex(IMemento memento, String key, SortByIndex defaultValue) { >@@ -209,37 +220,55 @@ > } > > public void restoreState(IMemento memento) { >- setSortByIndex(getSortIndex(memento, MEMENTO_KEY_SORT_INDEX, DEFAULT_SORT_INDEX)); >- setSortDirection(getSortDirection(memento, MEMENTO_KEY_SORT_DIRECTION, DEFAULT_SORT_DIRECTION)); >- setSortByIndex2(getSortIndex(memento, MEMENTO_KEY_SORT_INDEX2, DEFAULT_SORT_INDEX2)); >- setSortDirection(getSortDirection(memento, MEMENTO_KEY_SORT_DIRECTION2, DEFAULT_SORT_DIRECTION)); >+ //TODO: remove access of old perferences in 3.3 >+ String value = memento.getString(MEMENTO_KEY_SORT_INDEX); >+ if (value != null) { >+ // old perferences >+ setSortByIndex(getSortIndex(memento, MEMENTO_KEY_SORT_INDEX, DEFAULT_SORT_INDEX)); >+ setSortDirection(getSortDirection(memento, MEMENTO_KEY_SORT_DIRECTION, DEFAULT_SORT_DIRECTION)); >+ setSortByIndex2(getSortIndex(memento, MEMENTO_KEY_SORT_INDEX2, DEFAULT_SORT_INDEX2)); >+ setSortDirection2(getSortDirection(memento, MEMENTO_KEY_SORT_DIRECTION2, DEFAULT_SORT_DIRECTION)); >+ } else { >+ if (memento != null) { >+ for (int index = 0; index < SortKindEntry.kindCount; index++) { >+ IMemento child = memento.getChild(MEMENTO_KEY_SORT + index); >+ if (child != null && sortKindEntries[index] != null) { >+ sortKindEntries[index].restoreState(child); >+ } >+ } >+ } >+ } > } > > public void saveState(IMemento memento) { >- memento.putString(MEMENTO_KEY_SORT_INDEX, getSortByIndex().name()); >- memento.putInteger(MEMENTO_KEY_SORT_DIRECTION, getSortDirection()); >- memento.putString(MEMENTO_KEY_SORT_INDEX2, getSortByIndex2().name()); >- memento.putInteger(MEMENTO_KEY_SORT_DIRECTION2, getSortDirection2()); >+ if (memento != null) { >+ for (int index = 0; index < SortKindEntry.kindCount; index++) { >+ IMemento child = memento.createChild(MEMENTO_KEY_SORT + index); >+ if (child != null && sortKindEntries[index] != null) { >+ sortKindEntries[index].saveState(child); >+ } >+ } >+ } > } > > public void setSortByIndex(SortByIndex sortByIndex) { > Assert.isNotNull(sortByIndex); >- this.sortByIndex = sortByIndex; >+ sortKindEntries[0].setKind(sortByIndex); > } > > public void setSortByIndex2(SortByIndex sortByIndex) { > Assert.isNotNull(sortByIndex); >- this.sortByIndex2 = sortByIndex; >+ sortKindEntries[1].setKind(sortByIndex); > } > > public void setSortDirection(int sortDirection) { > Assert.isTrue(sortDirection == -1 || sortDirection == 1); >- this.sortDirection = sortDirection; >+ sortKindEntries[0].setSortDirection(sortDirection); > } > > public void setSortDirection2(int sortDirection) { > Assert.isTrue(sortDirection == -1 || sortDirection == 1); >- this.sortDirection2 = sortDirection; >+ sortKindEntries[1].setSortDirection(sortDirection); > } > > private int sortByDate(ITask element1, ITask element2, int sortDirection) { >Index: src/org/eclipse/mylyn/internal/tasks/ui/util/messages.properties >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.mylyn/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/util/messages.properties,v >retrieving revision 1.7 >diff -u -r1.7 messages.properties >--- src/org/eclipse/mylyn/internal/tasks/ui/util/messages.properties 11 Feb 2009 00:14:00 -0000 1.7 >+++ src/org/eclipse/mylyn/internal/tasks/ui/util/messages.properties 17 May 2009 21:03:26 -0000 >@@ -8,6 +8,11 @@ > DownloadAttachmentJob_Copy_Attachment_to_Clipboard=Copy Attachment to Clipboard > DownloadAttachmentJob_Downloading_Attachment=Downloading Attachment > ImportExportUtil_Tasks_and_queries_Filter0=Mylyn Tasks and Queries (*{0}) >+SortKindEntry_Date_Created=Date Created >+SortKindEntry_None=None >+SortKindEntry_Priority=Priority >+SortKindEntry_Summary=Summary >+SortKindEntry_Task_ID=Task ID > > TaskDataExportOperation_exporting_task_data=Exporting Task Data > >Index: src/org/eclipse/mylyn/internal/tasks/ui/dialogs/Messages.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.mylyn/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/dialogs/Messages.java,v >retrieving revision 1.3 >diff -u -r1.3 Messages.java >--- src/org/eclipse/mylyn/internal/tasks/ui/dialogs/Messages.java 26 Feb 2009 08:42:14 -0000 1.3 >+++ src/org/eclipse/mylyn/internal/tasks/ui/dialogs/Messages.java 17 May 2009 21:03:26 -0000 >@@ -27,21 +27,17 @@ > > public static String TaskCompareDialog_Ascending; > >- public static String TaskCompareDialog_DateCreated; >- > public static String TaskCompareDialog_Descending; > >- public static String TaskCompareDialog_Priority; >- > public static String TaskCompareDialog_Sorting; > > public static String TaskCompareDialog_SortOrder; > >- public static String TaskCompareDialog_Summary; >+ public static String TaskListSortDialog_Queries_and_Categories; > >- public static String TaskCompareDialog_TaskID; >+ public static String TaskListSortDialog_Grouped_by; > >- public static String TaskListSortDialog_Sort_order; >+ public static String TaskListSortDialog_Tasks; > > public static String TaskListSortDialog_Title; > >Index: src/org/eclipse/mylyn/internal/tasks/ui/dialogs/TaskListSortDialog.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.mylyn/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/dialogs/TaskListSortDialog.java,v >retrieving revision 1.7 >diff -u -r1.7 TaskListSortDialog.java >--- src/org/eclipse/mylyn/internal/tasks/ui/dialogs/TaskListSortDialog.java 26 Feb 2009 08:42:14 -0000 1.7 >+++ src/org/eclipse/mylyn/internal/tasks/ui/dialogs/TaskListSortDialog.java 17 May 2009 21:03:26 -0000 >@@ -13,9 +13,14 @@ > > import org.eclipse.jface.dialogs.Dialog; > import org.eclipse.jface.window.IShellProvider; >+import org.eclipse.mylyn.internal.tasks.ui.views.TaskListSorter; > import org.eclipse.mylyn.internal.tasks.ui.views.TaskListView; >+import org.eclipse.mylyn.internal.tasks.ui.views.TaskListSorter.GroupBy; > import org.eclipse.swt.SWT; >+import org.eclipse.swt.events.SelectionAdapter; >+import org.eclipse.swt.events.SelectionEvent; > import org.eclipse.swt.layout.GridData; >+import org.eclipse.swt.widgets.Combo; > import org.eclipse.swt.widgets.Composite; > import org.eclipse.swt.widgets.Label; > >@@ -24,19 +29,59 @@ > */ > public class TaskListSortDialog extends TaskCompareDialog { > >+ private Combo modeCombo; >+ >+ private final TaskListView taskListView; >+ > public TaskListSortDialog(IShellProvider parentShell, TaskListView taskListView) { > super(parentShell, taskListView.getSorter().getComparator()); >+ this.taskListView = taskListView; > setTitle(Messages.TaskListSortDialog_Title); > } > > @Override > protected void createDialogStartArea(Composite parent) { >- Label sortByLabel = new Label(parent, SWT.NULL); >- sortByLabel.setText(Messages.TaskListSortDialog_Sort_order); >+ Label numberLabel = new Label(parent, SWT.NULL); > GridData data = new GridData(); > data.horizontalSpan = 3; >+ numberLabel.setLayoutData(data); >+ numberLabel.setText(Messages.TaskListSortDialog_Queries_and_Categories); >+ numberLabel = new Label(parent, SWT.NULL); >+ numberLabel.setText(Messages.TaskListSortDialog_Grouped_by); >+ modeCombo = new Combo(parent, SWT.READ_ONLY); >+ modeCombo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); >+ data = new GridData(); >+ data.horizontalSpan = 2; >+ modeCombo.setLayoutData(data); >+ GroupBy[] values = TaskListSorter.GroupBy.values(); >+ for (GroupBy groupBy : values) { >+ modeCombo.add(groupBy.getLabel()); >+ } >+ modeCombo.addSelectionListener(new SelectionAdapter() { >+ @Override >+ public void widgetSelected(SelectionEvent e) { >+ markDirty(); >+ } >+ }); >+ modeCombo.select(taskListView.getSorter().getGroupBy().ordinal()); >+ >+ Label sortByLabel = new Label(parent, SWT.NULL); >+ sortByLabel.setText(Messages.TaskListSortDialog_Tasks); >+ data = new GridData(); >+ data.horizontalSpan = 3; > sortByLabel.setLayoutData(data); > Dialog.applyDialogFont(parent); > } > >+ @Override >+ protected void okPressed() { >+ if (isDirty()) { >+ int selectionIndex = modeCombo.getSelectionIndex(); >+ if (selectionIndex != -1) { >+ taskListView.getSorter().setGroupBy(TaskListSorter.GroupBy.values()[selectionIndex]); >+ } >+ } >+ super.okPressed(); >+ } >+ > } >Index: src/org/eclipse/mylyn/internal/tasks/ui/dialogs/TaskCompareDialog.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.mylyn/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/dialogs/TaskCompareDialog.java,v >retrieving revision 1.2 >diff -u -r1.2 TaskCompareDialog.java >--- src/org/eclipse/mylyn/internal/tasks/ui/dialogs/TaskCompareDialog.java 26 Feb 2009 08:42:14 -0000 1.2 >+++ src/org/eclipse/mylyn/internal/tasks/ui/dialogs/TaskCompareDialog.java 17 May 2009 21:03:26 -0000 >@@ -17,8 +17,9 @@ > > import org.eclipse.jface.dialogs.Dialog; > import org.eclipse.jface.window.IShellProvider; >+import org.eclipse.mylyn.internal.tasks.ui.util.SortKindEntry; > import org.eclipse.mylyn.internal.tasks.ui.util.TaskComparator; >-import org.eclipse.mylyn.internal.tasks.ui.util.TaskComparator.SortByIndex; >+import org.eclipse.mylyn.internal.tasks.ui.util.SortKindEntry.SortByIndex; > import org.eclipse.swt.SWT; > import org.eclipse.swt.events.SelectionAdapter; > import org.eclipse.swt.events.SelectionEvent; >@@ -50,7 +51,7 @@ > > public TaskCompareDialog(IShellProvider parentShell, TaskComparator taskComparator) { > super(parentShell.getShell()); >- SortByIndex[] values = SortByIndex.values(); >+ SortKindEntry.SortByIndex[] values = SortKindEntry.SortByIndex.values(); > propertyText = new String[values.length]; > for (int i = 0; i < values.length; i++) { > propertyText[i] = values[i].getLabel(); >@@ -78,14 +79,19 @@ > > createDialogStartArea(prioritiesArea); > >- ascendingButtons = new Button[2]; >- descendingButtons = new Button[2]; >- priorityCombos = new Combo[2]; >+ ascendingButtons = new Button[SortKindEntry.kindCount]; >+ descendingButtons = new Button[SortKindEntry.kindCount]; >+ priorityCombos = new Combo[SortKindEntry.kindCount]; > >- for (int i = 0; i < 2; i++) { >+ for (int i = 0; i < SortKindEntry.kindCount; i++) { > final int index = i; > Label numberLabel = new Label(prioritiesArea, SWT.NULL); >- numberLabel.setText("" + (i + 1) + "."); //$NON-NLS-1$ //$NON-NLS-2$ >+ if (i == 0) { >+ numberLabel.setText("Sort by:"); >+ } else { >+ numberLabel.setText("Then by:"); >+ } >+// numberLabel.setText("" + (i + 1) + "."); //$NON-NLS-1$ //$NON-NLS-2$ > priorityCombos[i] = new Combo(prioritiesArea, SWT.READ_ONLY); > priorityCombos[i].setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); > >@@ -107,7 +113,7 @@ > markDirty(); > } > }); >- if (i < priorityCombos.length - 1) { >+ if (i < priorityCombos.length) { > priorityCombos[i].addSelectionListener(new SelectionAdapter() { > @Override > public void widgetSelected(SelectionEvent e) { >@@ -118,45 +124,81 @@ > ArrayList<String> oldSelectionList = new ArrayList<String>( > Arrays.asList(priorityCombos[index].getItems())); > oldSelectionList.removeAll(Arrays.asList(priorityCombos[index + 1].getItems())); >- if (oldSelectionList.size() != 1) { >- return; >+ String oldSelection = propertyText[SortByIndex.NONE.ordinal()]; >+ if (oldSelectionList.size() == 1) { >+ oldSelection = oldSelectionList.get(0); > } >- String oldSelection = oldSelectionList.get(0); > String newSelection = priorityCombos[index].getItem(priorityCombos[index].getSelectionIndex()); > if (oldSelection.equals(newSelection)) { > return; > } >- for (int j = index + 1; j < priorityCombos.length; j++) { >- int newSelectionIndex = priorityCombos[j].indexOf(newSelection); >- //this combo's current selection is equal to newSelection >- if (priorityCombos[j].getSelectionIndex() == newSelectionIndex) { >- priorityCombos[j].remove(newSelection); >- int insertionPoint = -1 >- - Arrays.binarySearch(priorityCombos[j].getItems(), oldSelection, >- columnComparator); >- if (insertionPoint >= 0 && insertionPoint <= priorityCombos[j].getItemCount()) { >- priorityCombos[j].add(oldSelection, insertionPoint); >- } else { >- priorityCombos[j].add(oldSelection); >+ if (oldSelection.equals(propertyText[SortByIndex.NONE.ordinal()])) { >+ ascendingButtons[index].setEnabled(true); >+ descendingButtons[index].setEnabled(true); >+ if (index + 1 < SortKindEntry.kindCount) { >+ priorityCombos[index + 1].setEnabled(true); >+ ArrayList<String> availablePriorities = new ArrayList<String>( >+ Arrays.asList(priorityCombos[index].getItems())); >+ availablePriorities.remove(newSelection); >+ for (int k = index + 1; k < SortKindEntry.kindCount; k++) { >+ priorityCombos[k].removeAll(); >+ for (int j = 0; j < availablePriorities.size(); j++) { >+ priorityCombos[k].add(availablePriorities.get(j)); >+ } >+ priorityCombos[k].select(priorityCombos[k].indexOf(propertyText[SortByIndex.NONE.ordinal()])); >+ } >+ } >+ } else if (newSelection.equals(propertyText[SortByIndex.NONE.ordinal()])) { >+ ascendingButtons[index].setEnabled(false); >+ descendingButtons[index].setEnabled(false); >+ if (index + 1 < SortKindEntry.kindCount) { >+ ArrayList<String> availablePriorities = new ArrayList<String>( >+ Arrays.asList(priorityCombos[index].getItems())); >+ for (int k = index + 1; k < SortKindEntry.kindCount; k++) { >+ priorityCombos[k].setEnabled(true); >+ priorityCombos[k].removeAll(); >+ for (int j = 0; j < availablePriorities.size(); j++) { >+ priorityCombos[k].add(availablePriorities.get(j)); >+ } >+ priorityCombos[k].select(priorityCombos[k].indexOf(propertyText[SortByIndex.NONE.ordinal()])); >+ priorityCombos[k].setEnabled(false); >+ ascendingButtons[k].setEnabled(false); >+ descendingButtons[k].setEnabled(false); > } >- priorityCombos[j].select(priorityCombos[j].indexOf(oldSelection)); >- ascendingButtons[index].setSelection(ascendingButtons[j].getSelection()); >- descendingButtons[index].setSelection(descendingButtons[j].getSelection()); >- ascendingButtons[j].setSelection(oldSelectionDirection == 1); >- descendingButtons[j].setSelection(oldSelectionDirection == -1); > } >- //this combo contains newSelection >- else if (newSelectionIndex >= 0) { >- String currentText = priorityCombos[j].getText(); >- priorityCombos[j].remove(newSelection); >- int insertionPoint = -1 >- - Arrays.binarySearch(priorityCombos[j].getItems(), oldSelection, >- columnComparator); >- if (insertionPoint >= 0 && insertionPoint <= priorityCombos[j].getItemCount()) { >- priorityCombos[j].add(oldSelection, insertionPoint); >- priorityCombos[j].select(priorityCombos[j].indexOf(currentText)); >- } else { >- priorityCombos[j].add(oldSelection); >+ } else { >+ for (int j = index + 1; j < priorityCombos.length; j++) { >+ int newSelectionIndex = priorityCombos[j].indexOf(newSelection); >+ //this combo's current selection is equal to newSelection >+ if (priorityCombos[j].getSelectionIndex() == newSelectionIndex) { >+ priorityCombos[j].remove(newSelection); >+ int insertionPoint = -1 >+ - Arrays.binarySearch(priorityCombos[j].getItems(), oldSelection, >+ columnComparator); >+ if (insertionPoint >= 0 && insertionPoint <= priorityCombos[j].getItemCount()) { >+ priorityCombos[j].add(oldSelection, insertionPoint); >+ } else { >+ priorityCombos[j].add(oldSelection); >+ } >+ priorityCombos[j].select(priorityCombos[j].indexOf(oldSelection)); >+ ascendingButtons[index].setSelection(ascendingButtons[j].getSelection()); >+ descendingButtons[index].setSelection(descendingButtons[j].getSelection()); >+ ascendingButtons[j].setSelection(oldSelectionDirection == 1); >+ descendingButtons[j].setSelection(oldSelectionDirection == -1); >+ } >+ //this combo contains newSelection >+ else if (newSelectionIndex >= 0) { >+ String currentText = priorityCombos[j].getText(); >+ priorityCombos[j].remove(newSelection); >+ int insertionPoint = -1 >+ - Arrays.binarySearch(priorityCombos[j].getItems(), oldSelection, >+ columnComparator); >+ if (insertionPoint >= 0 && insertionPoint <= priorityCombos[j].getItemCount()) { >+ priorityCombos[j].add(oldSelection, insertionPoint); >+ priorityCombos[j].select(priorityCombos[j].indexOf(currentText)); >+ } else { >+ priorityCombos[j].add(oldSelection); >+ } > } > } > } >@@ -173,13 +215,7 @@ > } > > } >- int a[] = new int[2]; >- int b[] = new int[2]; >- a[0] = taskComparator.getSortByIndex().ordinal(); >- a[1] = taskComparator.getSortByIndex2().ordinal(); >- b[0] = taskComparator.getSortDirection(); >- b[1] = taskComparator.getSortDirection2(); >- updateUI(a, b); >+ updateUI(); > Dialog.applyDialogFont(composite); > return composite; > } >@@ -187,17 +223,14 @@ > @Override > protected void okPressed() { > if (isDirty()) { >- taskComparator.setSortByIndex(SortByIndex.valueOfLabel(priorityCombos[0].getText())); >- taskComparator.setSortByIndex2(SortByIndex.valueOfLabel(priorityCombos[1].getText())); >- if (descendingButtons[0].getSelection()) { >- taskComparator.setSortDirection(-1); >- } else { >- taskComparator.setSortDirection(1); >- } >- if (descendingButtons[1].getSelection()) { >- taskComparator.setSortDirection2(-1); >- } else { >- taskComparator.setSortDirection2(1); >+ SortKindEntry[] keyEntries = taskComparator.getSortKindEntries(); >+ for (int i = 0; i < SortKindEntry.kindCount; i++) { >+ keyEntries[i].setKind(SortByIndex.valueOfLabel(priorityCombos[i].getText())); >+ if (descendingButtons[i].getSelection()) { >+ keyEntries[i].setSortDirection(-1); >+ } else { >+ keyEntries[i].setSortDirection(1); >+ } > } > } > super.okPressed(); >@@ -230,18 +263,35 @@ > } > }; > >- protected void updateUI(int[] priorities, int[] directions) { >+ protected void updateUI() { > ArrayList<String> availablePriorities = new ArrayList<String>(Arrays.asList(propertyText)); >- >- for (int i = 0; i < priorityCombos.length; i++) { >+ SortKindEntry[] keyEntries = taskComparator.getSortKindEntries(); >+ for (int i = 0; i < keyEntries.length; i++) { > priorityCombos[i].removeAll(); > for (int j = 0; j < availablePriorities.size(); j++) { > priorityCombos[i].add(availablePriorities.get(j)); > } >- priorityCombos[i].select(priorityCombos[i].indexOf(propertyText[priorities[i]])); >- availablePriorities.remove(propertyText[priorities[i]]); >- ascendingButtons[i].setSelection(directions[i] == 1); >- descendingButtons[i].setSelection(directions[i] == -1); >+ priorityCombos[i].select(priorityCombos[i].indexOf(propertyText[keyEntries[i].getKind().ordinal()])); >+ ascendingButtons[i].setSelection(keyEntries[i].getSortDirection() == 1); >+ descendingButtons[i].setSelection(keyEntries[i].getSortDirection() == -1); >+ if (keyEntries[i].getKind() != SortByIndex.NONE) { >+ availablePriorities.remove(propertyText[keyEntries[i].getKind().ordinal()]); >+ } else { >+ ascendingButtons[i].setEnabled(false); >+ descendingButtons[i].setEnabled(false); >+ for (int k = i + 1; k < keyEntries.length; k++) { >+ for (int j = 0; j < availablePriorities.size(); j++) { >+ priorityCombos[k].add(availablePriorities.get(j)); >+ } >+ priorityCombos[k].select(priorityCombos[k].indexOf(propertyText[SortByIndex.NONE.ordinal()])); >+ ascendingButtons[k].setSelection(keyEntries[k].getSortDirection() == 1); >+ descendingButtons[k].setSelection(keyEntries[k].getSortDirection() == -1); >+ priorityCombos[k].setEnabled(false); >+ ascendingButtons[k].setEnabled(false); >+ descendingButtons[k].setEnabled(false); >+ } >+ break; >+ } > } > } > >Index: src/org/eclipse/mylyn/internal/tasks/ui/dialogs/messages.properties >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.mylyn/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/dialogs/messages.properties,v >retrieving revision 1.3 >diff -u -r1.3 messages.properties >--- src/org/eclipse/mylyn/internal/tasks/ui/dialogs/messages.properties 26 Feb 2009 08:42:14 -0000 1.3 >+++ src/org/eclipse/mylyn/internal/tasks/ui/dialogs/messages.properties 17 May 2009 21:03:26 -0000 >@@ -1,12 +1,10 @@ > TaskCompareDialog_Ascending=Ascending >-TaskCompareDialog_DateCreated=Date Created > TaskCompareDialog_Descending=Descending >-TaskCompareDialog_Priority=Priority > TaskCompareDialog_Sorting=Sorting > TaskCompareDialog_SortOrder=Sort order: >-TaskCompareDialog_Summary=Summary >-TaskCompareDialog_TaskID=Task ID >-TaskListSortDialog_Sort_order=Sort order for tasks\: >+TaskListSortDialog_Queries_and_Categories=Queries and Categories >+TaskListSortDialog_Grouped_by=Group by: >+TaskListSortDialog_Tasks=\nTasks > TaskListSortDialog_Title=Task List Sorting > > TaskRepositoryCredentialsDialog_Enter_Credentials=Enter Credentials >Index: src/org/eclipse/mylyn/internal/tasks/ui/util/SortKindEntry.java >=================================================================== >RCS file: src/org/eclipse/mylyn/internal/tasks/ui/util/SortKindEntry.java >diff -N src/org/eclipse/mylyn/internal/tasks/ui/util/SortKindEntry.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/mylyn/internal/tasks/ui/util/SortKindEntry.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,117 @@ >+/******************************************************************************* >+ * Copyright (c) 2004, 2008 Tasktop Technologies 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: >+ * Tasktop Technologies - initial API and implementation >+ *******************************************************************************/ >+ >+package org.eclipse.mylyn.internal.tasks.ui.util; >+ >+import org.eclipse.ui.IMemento; >+ >+public class SortKindEntry { >+ public enum SortByIndex { >+ NONE, DATE_CREATED, PRIORITY, SUMMARY, TASK_ID; >+ >+ public static SortByIndex valueOfLabel(String label) { >+ for (SortByIndex value : values()) { >+ if (value.getLabel().equals(label)) { >+ return value; >+ } >+ } >+ return null; >+ } >+ >+ public String getLabel() { >+ switch (this) { >+ case NONE: >+ return Messages.SortKindEntry_None; >+ case PRIORITY: >+ return Messages.SortKindEntry_Priority; >+ case SUMMARY: >+ return Messages.SortKindEntry_Summary; >+ case DATE_CREATED: >+ return Messages.SortKindEntry_Date_Created; >+ case TASK_ID: >+ return Messages.SortKindEntry_Task_ID; >+ default: >+ return null; >+ } >+ } >+ >+ } >+ >+ private SortByIndex kind; >+ >+ private int sortDirection; >+ >+ private static final String MEMENTO_KEY_SORT_KIND = "sortKind"; //$NON-NLS-1$ >+ >+ private static final String MEMENTO_KEY_SORT_DIRECTION = "sortDirection"; //$NON-NLS-1$ >+ >+ private static final SortByIndex DEFAULT_SORT_KIND = SortByIndex.NONE; >+ >+ private static final int DEFAULT_SORT_DIRECTION = 1; >+ >+ public static final int kindCount = SortByIndex.values().length - 1; >+ >+ public SortKindEntry() { >+ kind = DEFAULT_SORT_KIND; >+ sortDirection = DEFAULT_SORT_DIRECTION; >+ } >+ >+ public SortKindEntry(SortByIndex kind, int sortDirection) { >+ this.kind = kind; >+ this.sortDirection = sortDirection; >+ } >+ >+ public SortByIndex getKind() { >+ return kind; >+ } >+ >+ public void setKind(SortByIndex kind) { >+ this.kind = kind; >+ } >+ >+ public int getSortDirection() { >+ return sortDirection; >+ } >+ >+ public void setSortDirection(int sortDirection) { >+ this.sortDirection = sortDirection; >+ } >+ >+ private SortByIndex getSortKind(IMemento memento, String key, SortByIndex defaultValue) { >+ String value = memento.getString(key); >+ if (value != null) { >+ try { >+ return SortByIndex.valueOf(value); >+ } catch (IllegalArgumentException e) { >+ // ignore >+ } >+ } >+ return defaultValue; >+ } >+ >+ private int getSortDirection(IMemento memento, String key, int defaultValue) { >+ Integer value = memento.getInteger(key); >+ if (value != null) { >+ return value >= 0 ? 1 : -1; >+ } >+ return defaultValue; >+ } >+ >+ public void restoreState(IMemento memento) { >+ setKind(getSortKind(memento, MEMENTO_KEY_SORT_KIND, DEFAULT_SORT_KIND)); >+ setSortDirection(getSortDirection(memento, MEMENTO_KEY_SORT_DIRECTION, DEFAULT_SORT_DIRECTION)); >+ } >+ >+ public void saveState(IMemento memento) { >+ memento.putString(MEMENTO_KEY_SORT_KIND, getKind().name()); >+ memento.putInteger(MEMENTO_KEY_SORT_DIRECTION, getSortDirection()); >+ } >+}
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 212967
:
127099
|
127100
|
129524
|
129525
|
134695
|
134696
|
134832
|
134833
|
134916
|
135034
|
135035
| 136130 |
136131
|
136261
|
136585
|
136586
|
136747