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 89358 Details for
Bug 216150
2nd level sorting in Search view
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Patch with 2nd level sorting
patch216150.txt (text/plain), 11.26 KB, created by
Frank Becker
on 2008-02-10 16:40:07 EST
(
hide
)
Description:
Patch with 2nd level sorting
Filename:
MIME Type:
Creator:
Frank Becker
Created:
2008-02-10 16:40:07 EST
Size:
11.26 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.36 >diff -u -r1.36 TaskListTableSorter.java >--- src/org/eclipse/mylyn/internal/tasks/ui/views/TaskListTableSorter.java 29 Jan 2008 06:42:34 -0000 1.36 >+++ src/org/eclipse/mylyn/internal/tasks/ui/views/TaskListTableSorter.java 10 Feb 2008 21:37:12 -0000 >@@ -35,6 +35,12 @@ > > private SortByIndex sortByIndex = SortByIndex.PRIORITY; > >+ private static final int DEFAULT_SORT_DIRECTION2 = 1; >+ >+ private int sortDirection2 = DEFAULT_SORT_DIRECTION2; >+ >+ private SortByIndex sortByIndex2 = SortByIndex.SUMMARY; >+ > private final TaskListView view; > > private TaskKeyComparator taskKeyComparator = new TaskKeyComparator(); >@@ -127,30 +133,48 @@ > > private int compareElements(AbstractTaskContainer element1, AbstractTaskContainer element2) { > if (SortByIndex.PRIORITY.equals(sortByIndex)) { >- int result = this.sortDirection * element1.getPriority().compareTo(element2.getPriority()); >+ int result = sortByPriority(element1, element2, sortDirection); > if (result != 0) { > return result; > } >- return sortBySummary(element1, element2); >- >+ if (SortByIndex.DATE_CREATED.equals(sortByIndex2)) { >+ return sortByDate(element1, element2, sortDirection2); >+ } else { >+ if (SortByIndex.SUMMARY.equals(sortByIndex2)) { >+ return sortBySummary(element1, element2, sortDirection2); >+ } else { >+ return result; >+ } >+ } > } else if (SortByIndex.DATE_CREATED.equals(sortByIndex)) { >- AbstractTask t1 = null; >- AbstractTask t2 = null; >- if (element1 instanceof AbstractTask) { >- t1 = (AbstractTask) element1; >- } >- if (element2 instanceof AbstractTask) { >- t2 = (AbstractTask) element2; >- } >- if (t1 != null && t2 != null) { >- if (t1.getCreationDate() != null) { >- return t1.getCreationDate().compareTo(t2.getCreationDate()); >- } >+ int result = sortByDate(element1, element2, sortDirection); >+ if (result != 0) { >+ return result; >+ } >+ if (SortByIndex.PRIORITY.equals(sortByIndex2)) { >+ return sortByPriority(element1, element2, sortDirection2); >+ } else { >+ if (SortByIndex.SUMMARY.equals(sortByIndex2)) { >+ return sortBySummary(element1, element2, sortDirection2); >+ } else { >+ return result; >+ } > } > } else { >- return sortBySummary(element1, element2); >+ int result = sortBySummary(element1, element2, sortDirection); >+ if (result != 0) { >+ return result; >+ } >+ if (SortByIndex.DATE_CREATED.equals(sortByIndex2)) { >+ return sortByDate(element1, element2, sortDirection2); >+ } else { >+ if (SortByIndex.PRIORITY.equals(sortByIndex2)) { >+ return sortByPriority(element1, element2, sortDirection2); >+ } else { >+ return result; >+ } >+ } > } >- return 0; > } > > /** >@@ -160,9 +184,43 @@ > * @param element2 > * @return sort order > */ >- private int sortBySummary(AbstractTaskContainer element1, AbstractTaskContainer element2) { >- return this.sortDirection >- * taskKeyComparator.compare(getSortableFromElement(element1), getSortableFromElement(element2)); >+ private int sortBySummary(AbstractTaskContainer element1, AbstractTaskContainer element2, int sortDirection) { >+ return sortDirection * taskKeyComparator.compare(getSortableFromElement(element1), getSortableFromElement(element2)); >+ } >+ >+ /** >+ * Determine the sort order of two tasks by priority >+ * >+ * @param element1 >+ * @param element2 >+ * @return sort order >+ */ >+ private int sortByPriority(AbstractTaskContainer element1, AbstractTaskContainer element2, int sortDirection) { >+ return sortDirection * element1.getPriority().compareTo(element2.getPriority()); >+ } >+ >+ /** >+ * Determine the sort order of two tasks by creation date >+ * >+ * @param element1 >+ * @param element2 >+ * @return sort order >+ */ >+ private int sortByDate(AbstractTaskContainer element1, AbstractTaskContainer element2, int sortDirection) { >+ AbstractTask t1 = null; >+ AbstractTask t2 = null; >+ if (element1 instanceof AbstractTask) { >+ t1 = (AbstractTask) element1; >+ } >+ if (element2 instanceof AbstractTask) { >+ t2 = (AbstractTask) element2; >+ } >+ if (t1 != null && t2 != null) { >+ if (t1.getCreationDate() != null) { >+ return sortDirection * t1.getCreationDate().compareTo(t2.getCreationDate()); >+ } >+ } >+ return 0; > } > > /** >@@ -228,4 +286,30 @@ > } > } > >+ >+ public SortByIndex getSortByIndex2() { >+ return sortByIndex2; >+ } >+ >+ public void setSortByIndex2(SortByIndex sortByIndex) { >+ SortByIndex oldValue = this.sortByIndex2; >+ this.sortByIndex2 = sortByIndex; >+ if (!oldValue.equals(sortByIndex)) { >+ view.getViewer().refresh(); >+ } >+ >+ } >+ >+ public int getSortDirection2() { >+ return sortDirection2; >+ } >+ >+ public void setSortDirection2(int sortDirection) { >+ int oldValue = this.sortDirection2; >+ this.sortDirection2 = sortDirection; >+ if (oldValue != this.sortDirection2) { >+ 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.7 >diff -u -r1.7 SortyByDropDownAction.java >--- src/org/eclipse/mylyn/internal/tasks/ui/views/SortyByDropDownAction.java 26 Nov 2007 19:31:39 -0000 1.7 >+++ src/org/eclipse/mylyn/internal/tasks/ui/views/SortyByDropDownAction.java 10 Feb 2008 21:37:12 -0000 >@@ -14,8 +14,10 @@ > import org.eclipse.jface.action.Separator; > import org.eclipse.mylyn.internal.tasks.ui.TasksUiImages; > import org.eclipse.mylyn.internal.tasks.ui.views.TaskListTableSorter.SortByIndex; >+import org.eclipse.swt.SWT; > import org.eclipse.swt.widgets.Control; > import org.eclipse.swt.widgets.Menu; >+import org.eclipse.swt.widgets.MenuItem; > > /** > * @author Mik Kersten >@@ -32,8 +34,18 @@ > > private Action byDateCreated; > >+ private Action byPriority2; >+ >+ private Action bySummary2; >+ >+ private Action byDateCreated2; >+ > private Menu dropDownMenu = null; > >+ private Menu dropDownMenu1 = null; >+ >+ private Menu dropDownMenu2 = null; >+ > public SortyByDropDownAction(TaskListView taskListView) { > super(); > this.taskListView = taskListView; >@@ -53,7 +65,22 @@ > if (dropDownMenu != null) { > dropDownMenu.dispose(); > } >+ if (dropDownMenu1 != null) { >+ dropDownMenu1.dispose(); >+ } >+ if (dropDownMenu2 != null) { >+ dropDownMenu2.dispose(); >+ } > dropDownMenu = new Menu(parent); >+ >+ MenuItem item = new MenuItem (dropDownMenu, SWT.CASCADE); >+ item.setText ("1. Level"); >+ dropDownMenu1 = new Menu (dropDownMenu); >+ item.setMenu (dropDownMenu1); >+ item = new MenuItem (dropDownMenu, SWT.CASCADE); >+ item.setText ("2. Level"); >+ dropDownMenu2 = new Menu (dropDownMenu); >+ item.setMenu (dropDownMenu2); > addActionsToMenu(); > return dropDownMenu; > } >@@ -62,7 +89,22 @@ > if (dropDownMenu != null) { > dropDownMenu.dispose(); > } >+ if (dropDownMenu1 != null) { >+ dropDownMenu1.dispose(); >+ } >+ if (dropDownMenu2 != null) { >+ dropDownMenu2.dispose(); >+ } > dropDownMenu = new Menu(parent); >+ >+ MenuItem item = new MenuItem (dropDownMenu, SWT.CASCADE); >+ item.setText ("1. Level"); >+ dropDownMenu1 = new Menu (dropDownMenu); >+ item.setMenu (dropDownMenu1); >+ item = new MenuItem (dropDownMenu, SWT.CASCADE); >+ item.setText ("2. Level"); >+ dropDownMenu2 = new Menu (dropDownMenu); >+ item.setMenu (dropDownMenu2); > addActionsToMenu(); > return dropDownMenu; > } >@@ -80,7 +122,7 @@ > byPriority.setEnabled(true); > byPriority.setText("Priority"); > byPriority.setImageDescriptor(TasksUiImages.PRIORITY_1); >- new ActionContributionItem(byPriority).fill(dropDownMenu, -1); >+ new ActionContributionItem(byPriority).fill(dropDownMenu1, -1); > > bySummary = new Action("", AS_CHECK_BOX) { > @Override >@@ -93,7 +135,7 @@ > }; > bySummary.setEnabled(true); > bySummary.setText("Summary"); >- new ActionContributionItem(bySummary).fill(dropDownMenu, -1); >+ new ActionContributionItem(bySummary).fill(dropDownMenu1, -1); > > byDateCreated = new Action("", AS_CHECK_BOX) { > @Override >@@ -107,9 +149,9 @@ > byDateCreated.setEnabled(true); > byDateCreated.setText("Date Created"); > byDateCreated.setImageDescriptor(TasksUiImages.CALENDAR_SMALL); >- new ActionContributionItem(byDateCreated).fill(dropDownMenu, -1); >+ new ActionContributionItem(byDateCreated).fill(dropDownMenu1, -1); > >- new Separator().fill(dropDownMenu, -1); >+ new Separator().fill(dropDownMenu1, -1); > > Action reverse = new Action("", AS_CHECK_BOX) { > @Override >@@ -121,7 +163,7 @@ > reverse.setEnabled(true); > reverse.setText("Descending"); > reverse.setChecked(taskListView.getSorter().getSortDirection() < 0); >- new ActionContributionItem(reverse).fill(dropDownMenu, -1); >+ new ActionContributionItem(reverse).fill(dropDownMenu1, -1); > > switch (taskListView.getSorter().getSortByIndex()) { > case PRIORITY: >@@ -134,6 +176,73 @@ > byDateCreated.setChecked(true); > break; > } >+ >+ byPriority2 = new Action("", AS_CHECK_BOX) { >+ @Override >+ public void run() { >+ taskListView.getSorter().setSortByIndex2(SortByIndex.PRIORITY); >+ byPriority2.setChecked(true); >+ bySummary2.setChecked(false); >+ byDateCreated2.setChecked(false); >+ } >+ }; >+ byPriority2.setEnabled(true); >+ byPriority2.setText("Priority"); >+ byPriority2.setImageDescriptor(TasksUiImages.PRIORITY_1); >+ new ActionContributionItem(byPriority2).fill(dropDownMenu2, -1); >+ >+ bySummary2 = new Action("", AS_CHECK_BOX) { >+ @Override >+ public void run() { >+ taskListView.getSorter().setSortByIndex2(SortByIndex.SUMMARY); >+ byPriority2.setChecked(false); >+ bySummary2.setChecked(true); >+ byDateCreated2.setChecked(false); >+ } >+ }; >+ bySummary2.setEnabled(true); >+ bySummary2.setText("Summary"); >+ new ActionContributionItem(bySummary2).fill(dropDownMenu2, -1); >+ >+ byDateCreated2 = new Action("", AS_CHECK_BOX) { >+ @Override >+ public void run() { >+ taskListView.getSorter().setSortByIndex2(SortByIndex.DATE_CREATED); >+ byPriority2.setChecked(false); >+ bySummary2.setChecked(false); >+ byDateCreated2.setChecked(true); >+ } >+ }; >+ byDateCreated2.setEnabled(true); >+ byDateCreated2.setText("Date Created"); >+ byDateCreated2.setImageDescriptor(TasksUiImages.CALENDAR_SMALL); >+ new ActionContributionItem(byDateCreated2).fill(dropDownMenu2, -1); >+ >+ new Separator().fill(dropDownMenu2, -1); >+ >+ Action reverse2 = new Action("", AS_CHECK_BOX) { >+ @Override >+ public void run() { >+ taskListView.getSorter().setSortDirection2(taskListView.getSorter().getSortDirection2() * -1); >+ setChecked(taskListView.getSorter().getSortDirection2() < 0); >+ } >+ }; >+ reverse2.setEnabled(true); >+ reverse2.setText("Descending"); >+ reverse2.setChecked(taskListView.getSorter().getSortDirection2() < 0); >+ new ActionContributionItem(reverse2).fill(dropDownMenu2, -1); >+ >+ switch (taskListView.getSorter().getSortByIndex2()) { >+ case PRIORITY: >+ byPriority2.setChecked(true); >+ break; >+ case SUMMARY: >+ bySummary2.setChecked(true); >+ break; >+ case DATE_CREATED: >+ byDateCreated2.setChecked(true); >+ break; >+ } > } > > @Override
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 216150
:
89347
|
89348
| 89358 |
89359
|
90557
|
90558
|
90583
|
90584
|
95415
|
95416
|
116103
|
116104
|
130300
|
130301
|
134922