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 95415 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]
updated patch
patch216150.txt (text/plain), 35.86 KB, created by
Frank Becker
on 2008-04-09 15:48:51 EDT
(
hide
)
Description:
updated patch
Filename:
MIME Type:
Creator:
Frank Becker
Created:
2008-04-09 15:48:51 EDT
Size:
35.86 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.mylyn.tasks.tests >Index: src/org/eclipse/mylyn/tasks/tests/AllTasksTests.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.mylyn/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/AllTasksTests.java,v >retrieving revision 1.48 >diff -u -r1.48 AllTasksTests.java >--- src/org/eclipse/mylyn/tasks/tests/AllTasksTests.java 6 Mar 2008 08:08:43 -0000 1.48 >+++ src/org/eclipse/mylyn/tasks/tests/AllTasksTests.java 9 Apr 2008 19:43:14 -0000 >@@ -63,6 +63,7 @@ > suite.addTestSuite(OrphanedTasksTest.class); > suite.addTestSuite(TaskWorkingSetTest.class); > suite.addTestSuite(TaskActivationHistoryTest.class); >+ suite.addTestSuite(TaskSearchResultSorterTest.class); > // $JUnit-END$ > > // suite.addTestSuite(BackgroundSaveTest.class); >Index: src/org/eclipse/mylyn/tasks/tests/TaskSearchResultSorterTest.java >=================================================================== >RCS file: src/org/eclipse/mylyn/tasks/tests/TaskSearchResultSorterTest.java >diff -N src/org/eclipse/mylyn/tasks/tests/TaskSearchResultSorterTest.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/mylyn/tasks/tests/TaskSearchResultSorterTest.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,101 @@ >+/******************************************************************************* >+ * Copyright (c) 2004, 2007 Mylyn project committers 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 >+ *******************************************************************************/ >+ >+package org.eclipse.mylyn.tasks.tests; >+ >+import junit.framework.TestCase; >+ >+import org.eclipse.jface.viewers.ISelection; >+import org.eclipse.jface.viewers.Viewer; >+import org.eclipse.mylyn.internal.tasks.ui.TaskComparator; >+import org.eclipse.mylyn.internal.tasks.ui.search.TaskSearchResultSorter; >+import org.eclipse.mylyn.tasks.tests.connector.MockTask; >+import org.eclipse.swt.widgets.Control; >+ >+public class TaskSearchResultSorterTest extends TestCase { >+ >+ 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 test2LevelSort() throws Exception { >+ final TaskSearchResultSorter sorter = new TaskSearchResultSorter(); >+ final MockTask[] tasks = new MockTask[5]; >+ tasks[0] = new MockTask("local", "4", "c"); >+ tasks[1] = new MockTask("local", "1", "b"); >+ tasks[2] = new MockTask("local", "11", "a"); >+ tasks[2].setPriority("P1"); >+ tasks[3] = new MockTask("local", "3", "c"); >+ tasks[4] = new MockTask("local", "5", "a"); >+ >+ // sort by PRIORITY then by SUMMARY >+ sorter.setSortByIndex(TaskComparator.SortByIndex.PRIORITY); >+ sorter.setSortByIndex2(TaskComparator.SortByIndex.SUMMARY); >+ sorter.sort(new EmptyViewer(), tasks); >+ assertTrue("11".equals(tasks[0].getTaskKey()) && "a".equals(tasks[0].getSummary())); >+ assertTrue("1".equals(tasks[1].getTaskKey()) && "b".equals(tasks[1].getSummary())); >+ assertTrue("3".equals(tasks[2].getTaskKey()) && "c".equals(tasks[2].getSummary())); >+ assertTrue("4".equals(tasks[3].getTaskKey()) && "c".equals(tasks[3].getSummary())); >+ assertTrue("5".equals(tasks[4].getTaskKey()) && "a".equals(tasks[4].getSummary())); >+ >+ // sort by PRIORITY then by SUMMARY descending >+ sorter.setSortDirection2(-1); >+ sorter.sort(new EmptyViewer(), tasks); >+ assertTrue("11".equals(tasks[0].getTaskKey()) && "a".equals(tasks[0].getSummary())); >+ assertTrue("1".equals(tasks[4].getTaskKey()) && "b".equals(tasks[4].getSummary())); >+ assertTrue("3".equals(tasks[3].getTaskKey()) && "c".equals(tasks[3].getSummary())); >+ assertTrue("4".equals(tasks[2].getTaskKey()) && "c".equals(tasks[2].getSummary())); >+ assertTrue("5".equals(tasks[1].getTaskKey()) && "a".equals(tasks[1].getSummary())); >+ >+ // sort by PRIORITY descending then by SUMMARY descending >+ sorter.setSortDirection(-1); >+ sorter.sort(new EmptyViewer(), tasks); >+ assertTrue("11".equals(tasks[4].getTaskKey()) && "a".equals(tasks[4].getSummary())); >+ assertTrue("1".equals(tasks[3].getTaskKey()) && "b".equals(tasks[3].getSummary())); >+ assertTrue("3".equals(tasks[2].getTaskKey()) && "c".equals(tasks[2].getSummary())); >+ assertTrue("4".equals(tasks[1].getTaskKey()) && "c".equals(tasks[1].getSummary())); >+ assertTrue("5".equals(tasks[0].getTaskKey()) && "a".equals(tasks[0].getSummary())); >+ >+ // sort by PRIORITY descending then by SUMMARY >+ sorter.setSortDirection2(1); >+ sorter.sort(new EmptyViewer(), tasks); >+ assertTrue("11".equals(tasks[4].getTaskKey()) && "a".equals(tasks[4].getSummary())); >+ assertTrue("1".equals(tasks[0].getTaskKey()) && "b".equals(tasks[0].getSummary())); >+ assertTrue("3".equals(tasks[1].getTaskKey()) && "c".equals(tasks[1].getSummary())); >+ assertTrue("4".equals(tasks[2].getTaskKey()) && "c".equals(tasks[2].getSummary())); >+ assertTrue("5".equals(tasks[3].getTaskKey()) && "a".equals(tasks[3].getSummary())); >+ } >+} >#P org.eclipse.mylyn.tasks.ui >Index: src/org/eclipse/mylyn/internal/tasks/ui/search/SearchResultSorterDescription.java >=================================================================== >RCS file: src/org/eclipse/mylyn/internal/tasks/ui/search/SearchResultSorterDescription.java >diff -N src/org/eclipse/mylyn/internal/tasks/ui/search/SearchResultSorterDescription.java >--- src/org/eclipse/mylyn/internal/tasks/ui/search/SearchResultSorterDescription.java 1 Mar 2008 21:38:52 -0000 1.11 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,73 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2004, 2007 Mylyn project committers 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 >- *******************************************************************************/ >- >-package org.eclipse.mylyn.internal.tasks.ui.search; >- >-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 { >- >- private final TaskKeyComparator taskKeyComparator = new TaskKeyComparator(); >- >- /** >- * 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) >- */ >- @Override >- public int compare(Viewer viewer, Object e1, Object e2) { >- try { >- >- AbstractTask entry1 = (AbstractTask) e1; >- 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(TaskListTableSorter.getSortableFromElement(entry1), >- TaskListTableSorter.getSortableFromElement(entry2)); >- // return taskKeyComparator.compare(entry1.getDescription(), >- // entry2.getDescription()); >- } catch (Exception ignored) { >- // do nothing >- } >- >- // if that didn't work, use the default compare method >- return super.compare(viewer, e1, e2); >- } >- >- /** >- * Returns the category of the given element. The category is a number used to allocate elements to bins; the bins >- * 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 >- public int category(Object element) { >- try { >- AbstractTask hit = (AbstractTask) element; >- return Integer.parseInt(hit.getTaskId()); >- } catch (Exception ignored) { >- // ignore if >- } >- // if that didn't work, use the default category method >- return super.category(element); >- } >-} >Index: src/org/eclipse/mylyn/internal/tasks/ui/search/SearchResultSortAction.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.mylyn/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/search/SearchResultSortAction.java,v >retrieving revision 1.5 >diff -u -r1.5 SearchResultSortAction.java >--- src/org/eclipse/mylyn/internal/tasks/ui/search/SearchResultSortAction.java 1 Mar 2008 21:38:52 -0000 1.5 >+++ src/org/eclipse/mylyn/internal/tasks/ui/search/SearchResultSortAction.java 9 Apr 2008 19:43:16 -0000 >@@ -23,6 +23,8 @@ > /** The view where the Bugzilla search results are displayed. */ > private final RepositorySearchResultView bugPage; > >+ private final boolean secondLevel; >+ > /** > * Constructor > * >@@ -33,10 +35,11 @@ > * @param sortOrder > * The category that this class sorts Bugzilla search results by > */ >- public SearchResultSortAction(String label, RepositorySearchResultView page, int sortOrder) { >+ public SearchResultSortAction(String label, RepositorySearchResultView page, int sortOrder, boolean level2) { > super(label); > bugPage = page; > bugSortOrder = sortOrder; >+ secondLevel = level2; > } > > /** >@@ -44,7 +47,11 @@ > */ > @Override > public void run() { >- bugPage.setSortOrder(bugSortOrder); >+ if (secondLevel) { >+ bugPage.setSortOrder2(bugSortOrder); >+ } else { >+ bugPage.setSortOrder(bugSortOrder); >+ } > } > > /** >Index: src/org/eclipse/mylyn/internal/tasks/ui/search/SearchResultSorterPriority.java >=================================================================== >RCS file: src/org/eclipse/mylyn/internal/tasks/ui/search/SearchResultSorterPriority.java >diff -N src/org/eclipse/mylyn/internal/tasks/ui/search/SearchResultSorterPriority.java >--- src/org/eclipse/mylyn/internal/tasks/ui/search/SearchResultSorterPriority.java 26 Jun 2007 01:16:41 -0000 1.8 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,62 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2004, 2007 Mylyn project committers 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 >- *******************************************************************************/ >- >-package org.eclipse.mylyn.internal.tasks.ui.search; >- >-import org.eclipse.jface.viewers.Viewer; >-import org.eclipse.jface.viewers.ViewerSorter; >-import org.eclipse.mylyn.tasks.core.AbstractTask; >- >-/** >- * Sorts results of Bugzilla search by bug priority. >- * >- * @author Rob Elves (modifications) >- */ >-public class SearchResultSorterPriority extends ViewerSorter { >- >- /** >- * Returns a negative, zero, or positive number depending on whether the first bug's priority goes before, is the >- * same as, or goes after the second element's priority. >- * <p> >- * >- * @see org.eclipse.jface.viewers.ViewerSorter#compare(org.eclipse.jface.viewers.Viewer, java.lang.Object, >- * java.lang.Object) >- */ >- @Override >- public int compare(Viewer viewer, Object e1, Object e2) { >- try { >- AbstractTask hit1 = (AbstractTask) e1; >- AbstractTask hit2 = (AbstractTask) e2; >- return hit1.getPriority().compareTo(hit2.getPriority()); >- } catch (Exception ignored) { >- // do nothing >- } >- // if that didn't work, use the default compare method >- return super.compare(viewer, e1, e2); >- } >- >- /** >- * Returns the category of the given element. The category is a number used to allocate elements to bins; the bins >- * 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 >- public int category(Object element) { >- try { >- AbstractTask hit = (AbstractTask) element; >- return Integer.parseInt(hit.getTaskId()); >- } catch (Exception ignored) { >- // ignore if there is a problem >- } >- // if that didn't work, use the default category method >- return super.category(element); >- } >-} >Index: src/org/eclipse/mylyn/internal/tasks/ui/search/RepositorySearchResultView.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.mylyn/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/search/RepositorySearchResultView.java,v >retrieving revision 1.37 >diff -u -r1.37 RepositorySearchResultView.java >--- src/org/eclipse/mylyn/internal/tasks/ui/search/RepositorySearchResultView.java 8 Apr 2008 23:47:19 -0000 1.37 >+++ src/org/eclipse/mylyn/internal/tasks/ui/search/RepositorySearchResultView.java 9 Apr 2008 19:43:16 -0000 >@@ -16,6 +16,7 @@ > import org.eclipse.jface.action.Action; > import org.eclipse.jface.action.IMenuManager; > import org.eclipse.jface.action.MenuManager; >+import org.eclipse.jface.action.Separator; > import org.eclipse.jface.viewers.DecoratingLabelProvider; > import org.eclipse.jface.viewers.StructuredSelection; > import org.eclipse.jface.viewers.StructuredViewer; >@@ -23,6 +24,7 @@ > import org.eclipse.jface.viewers.TreeViewer; > import org.eclipse.mylyn.internal.tasks.core.UnmatchedTaskContainer; > import org.eclipse.mylyn.internal.tasks.ui.AddExistingTaskJob; >+import org.eclipse.mylyn.internal.tasks.ui.TaskComparator; > import org.eclipse.mylyn.internal.tasks.ui.TaskListPatternFilter; > import org.eclipse.mylyn.internal.tasks.ui.TasksUiImages; > import org.eclipse.mylyn.internal.tasks.ui.views.TaskListView; >@@ -31,7 +33,6 @@ > import org.eclipse.mylyn.tasks.core.TaskRepository; > import org.eclipse.mylyn.tasks.ui.TasksUiPlugin; > import org.eclipse.mylyn.tasks.ui.TasksUiUtil; >-import org.eclipse.search.internal.ui.SearchMessages; > import org.eclipse.search.ui.IContextMenuConstants; > import org.eclipse.search.ui.text.AbstractTextSearchViewPage; > import org.eclipse.search.ui.text.Match; >@@ -54,6 +55,7 @@ > * @author Rob Elves > * @author Mik Kersten > * @author Shawn Minto >+ * @author Frank Becker (https://bugs.eclipse.org/bugs/show_bug.cgi?taskId=216150) > */ > public class RepositorySearchResultView extends AbstractTextSearchViewPage implements IAdaptable { > >@@ -63,32 +65,48 @@ > > public static final int ORDER_DESCRIPTION = 2; > >- public static final int ORDER_SEVERITY = 3; >- >- public static final int ORDER_STATUS = 4; >- >- public static final int ORDER_ID = 5; >+ public static final int ORDER_DATE_CREATED = 3; > > public static final int ORDER_DEFAULT = ORDER_PRIORITY; > >+ public static final int ORDER2_DEFAULT = ORDER_DESCRIPTION; >+ > private static final String KEY_SORTING = TasksUiPlugin.ID_PLUGIN + ".search.resultpage.sorting"; //$NON-NLS-1$ > >+ private static final String KEY_SORTING2 = TasksUiPlugin.ID_PLUGIN + ".search.resultpage.sorting.then"; //$NON-NLS-1$ >+ > private SearchResultContentProvider searchResultProvider; > > private int currentSortOrder; > >+ private int currentSortOrder2; >+ > private final SearchResultSortAction sortByPriorityAction; > > private final SearchResultSortAction sortByDescriptionAction; > >+ private final SearchResultSortAction sortByDateCreated; >+ >+ private final SearchResultSortAction sortByPriorityAction2; >+ >+ private final SearchResultSortAction sortByDescriptionAction2; >+ >+ private final SearchResultSortAction sortByDateCreated2; >+ > private final OpenSearchResultAction openInEditorAction; > > private final CreateQueryFromSearchAction addTaskListAction; > >+ private final SearchResultSortDirection sortDirection; >+ >+ private final SearchResultSortDirection sortDirection2; >+ > private static final String[] SHOW_IN_TARGETS = new String[] { IPageLayout.ID_RES_NAV }; > > private final Action groupByAction; > >+ private TaskSearchResultSorter taskSearchResultSorter; >+ > private static final IShowInTargetList SHOW_IN_TARGET_LIST = new IShowInTargetList() { > public String[] getShowInTargetIds() { > return SHOW_IN_TARGETS; >@@ -99,9 +117,20 @@ > // Only use the table layout. > super(FLAG_LAYOUT_TREE); > >- sortByPriorityAction = new SearchResultSortAction("Task Priority", this, ORDER_PRIORITY); >- sortByDescriptionAction = new SearchResultSortAction("Task Summary", this, ORDER_DESCRIPTION); >+ sortByPriorityAction = new SearchResultSortAction("Priority", this, ORDER_PRIORITY, false); >+ sortByPriorityAction.setImageDescriptor(TasksUiImages.PRIORITY_1); >+ sortByDescriptionAction = new SearchResultSortAction("Summary", this, ORDER_DESCRIPTION, false); >+ sortByDateCreated = new SearchResultSortAction("Date Created", this, ORDER_DATE_CREATED, false); >+ sortByDateCreated.setImageDescriptor(TasksUiImages.CALENDAR_SMALL); > currentSortOrder = ORDER_DEFAULT; >+ sortByPriorityAction2 = new SearchResultSortAction("Priority", this, ORDER_PRIORITY, true); >+ sortByPriorityAction2.setImageDescriptor(TasksUiImages.PRIORITY_1); >+ sortByDescriptionAction2 = new SearchResultSortAction("Summary", this, ORDER_DESCRIPTION, true); >+ sortByDateCreated2 = new SearchResultSortAction("Date Created", this, ORDER_DATE_CREATED, true); >+ sortByDateCreated2.setImageDescriptor(TasksUiImages.CALENDAR_SMALL); >+ currentSortOrder2 = ORDER2_DEFAULT; >+ sortDirection = new SearchResultSortDirection("Descending", this, false); >+ sortDirection2 = new SearchResultSortDirection("Descending", this, true); > > openInEditorAction = new OpenSearchResultAction("Open in Editor", this); > addTaskListAction = new CreateQueryFromSearchAction("Create Query from Search...", this); >@@ -159,7 +188,10 @@ > > // Set the order when the search view is loading so that the items are > // sorted right away >+ taskSearchResultSorter = new TaskSearchResultSorter(); >+ viewer.setSorter(taskSearchResultSorter); > setSortOrder(currentSortOrder); >+ setSortOrder2(currentSortOrder2); > } > > @Override >@@ -230,27 +262,68 @@ > * The new category to sort by > */ > public void setSortOrder(int sortOrder) { >- StructuredViewer viewer = getViewer(); >- > switch (sortOrder) { >- case ORDER_ID: >- viewer.setSorter(new SearchResultSorterId()); >- break; > case ORDER_DESCRIPTION: >- viewer.setSorter(new SearchResultSorterDescription()); >+ taskSearchResultSorter.setSortByIndex(TaskComparator.SortByIndex.SUMMARY); > break; > case ORDER_PRIORITY: >- viewer.setSorter(new SearchResultSorterPriority()); >+ taskSearchResultSorter.setSortByIndex(TaskComparator.SortByIndex.PRIORITY); >+ break; >+ case ORDER_DATE_CREATED: >+ taskSearchResultSorter.setSortByIndex(TaskComparator.SortByIndex.DATE_CREATED); > break; > default: > // If the setting is not one of the four valid ones, > // use the default order setting. > sortOrder = ORDER_DEFAULT; >- viewer.setSorter(new SearchResultSorterPriority()); >+ taskSearchResultSorter.setSortByIndex(TaskComparator.SortByIndex.PRIORITY); > break; > } > currentSortOrder = sortOrder; > getSettings().put(KEY_SORTING, currentSortOrder); >+ >+ getViewer().refresh(); >+ } >+ >+ public void setSortOrder2(int sortOrder) { >+ switch (sortOrder) { >+ case ORDER_DESCRIPTION: >+ taskSearchResultSorter.setSortByIndex2(TaskComparator.SortByIndex.SUMMARY); >+ break; >+ case ORDER_PRIORITY: >+ taskSearchResultSorter.setSortByIndex2(TaskComparator.SortByIndex.PRIORITY); >+ break; >+ case ORDER_DATE_CREATED: >+ taskSearchResultSorter.setSortByIndex2(TaskComparator.SortByIndex.DATE_CREATED); >+ break; >+ default: >+ // If the setting is not one of the four valid ones, >+ // use the default order setting. >+ sortOrder = ORDER_DEFAULT; >+ taskSearchResultSorter.setSortByIndex2(TaskComparator.SortByIndex.PRIORITY); >+ break; >+ } >+ currentSortOrder2 = sortOrder; >+ getSettings().put(KEY_SORTING2, currentSortOrder2); >+ getViewer().refresh(); >+ } >+ >+ public void setSortDirection(int sortDirection) { >+ taskSearchResultSorter.setSortDirection(sortDirection); >+ getViewer().refresh(); >+ } >+ >+ public int getSortDirection() { >+ return taskSearchResultSorter.getSortDirection(); >+ } >+ >+ public void setSortDirection2(int sortDirection) { >+ taskSearchResultSorter.setSortDirection2(sortDirection); >+ getViewer().refresh(); >+ } >+ >+ public int getSortDirection2() { >+ return taskSearchResultSorter.getSortDirection2(); > } > > @SuppressWarnings("unchecked") >@@ -276,15 +349,33 @@ > @Override > protected void fillContextMenu(IMenuManager menuManager) { > super.fillContextMenu(menuManager); >- MenuManager sortMenuManager = new MenuManager(SearchMessages.SortDropDownAction_label); >+ MenuManager sortMenuManager = new MenuManager("First Sort by"); > sortMenuManager.add(sortByPriorityAction); > sortMenuManager.add(sortByDescriptionAction); >+ sortMenuManager.add(sortByDateCreated); >+ sortMenuManager.add(new Separator()); >+ sortMenuManager.add(sortDirection); > > sortByPriorityAction.setChecked(currentSortOrder == sortByPriorityAction.getSortOrder()); > sortByDescriptionAction.setChecked(currentSortOrder == sortByDescriptionAction.getSortOrder()); >+ sortByDateCreated.setChecked(currentSortOrder == sortByDateCreated.getSortOrder()); >+ sortDirection.setChecked(getSortDirection() < 0); >+ >+ MenuManager sortMenuManager2 = new MenuManager("Then Sort by"); >+ sortMenuManager2.add(sortByPriorityAction2); >+ sortMenuManager2.add(sortByDescriptionAction2); >+ sortMenuManager2.add(sortByDateCreated2); >+ sortMenuManager2.add(new Separator()); >+ sortMenuManager2.add(sortDirection2); >+ >+ sortByPriorityAction2.setChecked(currentSortOrder2 == sortByPriorityAction2.getSortOrder()); >+ sortByDescriptionAction2.setChecked(currentSortOrder2 == sortByDescriptionAction2.getSortOrder()); >+ sortByDateCreated2.setChecked(currentSortOrder2 == sortByDateCreated2.getSortOrder()); >+ sortDirection2.setChecked(getSortDirection2() < 0); > > // Add the new context menu items > menuManager.appendToGroup(IContextMenuConstants.GROUP_VIEWER_SETUP, sortMenuManager); >+ menuManager.appendToGroup(IContextMenuConstants.GROUP_VIEWER_SETUP, sortMenuManager2); > menuManager.appendToGroup(IContextMenuConstants.GROUP_VIEWER_SETUP, groupByAction); > > menuManager.appendToGroup(IContextMenuConstants.GROUP_OPEN, openInEditorAction); >Index: src/org/eclipse/mylyn/internal/tasks/ui/search/SearchResultSorterId.java >=================================================================== >RCS file: src/org/eclipse/mylyn/internal/tasks/ui/search/SearchResultSorterId.java >diff -N src/org/eclipse/mylyn/internal/tasks/ui/search/SearchResultSorterId.java >--- src/org/eclipse/mylyn/internal/tasks/ui/search/SearchResultSorterId.java 26 Jun 2007 01:16:41 -0000 1.7 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,70 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2004, 2007 Mylyn project committers 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 >- *******************************************************************************/ >- >-package org.eclipse.mylyn.internal.tasks.ui.search; >- >-import org.eclipse.jface.viewers.Viewer; >-import org.eclipse.jface.viewers.ViewerSorter; >-import org.eclipse.mylyn.tasks.core.AbstractTask; >- >-/** >- * Sorts search results (AbstractQueryHit) by taskId. >- */ >-public class SearchResultSorterId extends ViewerSorter { >- >- /** >- * Returns a negative, zero, or positive number depending on whether the first bug's taskId is less than, equal to, >- * or greater than the second bug's taskId. >- * <p> >- * >- * @see org.eclipse.jface.viewers.ViewerSorter#compare(org.eclipse.jface.viewers.Viewer, java.lang.Object, >- * java.lang.Object) >- */ >- @Override >- public int compare(Viewer viewer, Object e1, Object e2) { >- try { >- // cast the object and get its bug taskId >- AbstractTask entry1 = (AbstractTask) e1; >- Integer id1 = Integer.parseInt(entry1.getTaskId()); >- >- // cast the other object and get its bug taskId >- AbstractTask entry2 = (AbstractTask) e2; >- Integer id2 = Integer.parseInt(entry2.getTaskId()); >- >- // if neither is null, compare the bug taskId's >- if (id1 != null && id2 != null) { >- return id1.compareTo(id2); >- } >- } catch (Exception ignored) { >- // ignore if there is a problem >- } >- >- // if that didn't work, use the default compare method >- return super.compare(viewer, e1, e2); >- } >- >- /** >- * Returns the category of the given element. The category is a number used to allocate elements to bins; the bins >- * 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 >- public int category(Object element) { >- try { >- AbstractTask hit = (AbstractTask) element; >- return Integer.parseInt(hit.getTaskId()); >- } catch (Exception ignored) { >- // ignore >- } >- // if that didn't work, use the default category method >- return super.category(element); >- } >-} >Index: src/org/eclipse/mylyn/internal/tasks/ui/TaskComparator.java >=================================================================== >RCS file: src/org/eclipse/mylyn/internal/tasks/ui/TaskComparator.java >diff -N src/org/eclipse/mylyn/internal/tasks/ui/TaskComparator.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/mylyn/internal/tasks/ui/TaskComparator.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,184 @@ >+/******************************************************************************* >+ * Copyright (c) 2004, 2007 Mylyn project committers 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 >+ *******************************************************************************/ >+ >+package org.eclipse.mylyn.internal.tasks.ui; >+ >+import java.util.Comparator; >+ >+import org.eclipse.mylyn.internal.tasks.ui.views.TaskKeyComparator; >+import org.eclipse.mylyn.tasks.core.AbstractTask; >+import org.eclipse.mylyn.tasks.core.AbstractTaskContainer; >+ >+/** >+ * @author Frank Becker >+ */ >+ >+public class TaskComparator implements Comparator<AbstractTaskContainer> { >+ public enum SortByIndex { >+ PRIORITY, SUMMARY, DATE_CREATED; >+ } >+ >+ private static final int DEFAULT_SORT_DIRECTION = 1; >+ >+ private int sortDirection = DEFAULT_SORT_DIRECTION; >+ >+ 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 TaskKeyComparator taskKeyComparator = new TaskKeyComparator(); >+ >+ public int compare(AbstractTaskContainer element1, AbstractTaskContainer element2) { >+ if (SortByIndex.PRIORITY.equals(sortByIndex)) { >+ int result = sortByPriority(element1, element2, sortDirection); >+ if (result != 0) { >+ return result; >+ } >+ 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)) { >+ 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 { >+ 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; >+ } >+ } >+ } >+ } >+ >+ /** >+ * Determine the sort order of two tasks by id/summary >+ * >+ * @param element1 >+ * @param element2 >+ * @return sort order >+ */ >+ private int sortBySummary(AbstractTaskContainer element1, AbstractTaskContainer element2, int sortDirection) { >+ return sortDirection >+ * taskKeyComparator.compare(getSortableFromElement(element1), getSortableFromElement(element2)); >+// return sortDirection * (element1.getSummary().compareTo(element2.getSummary())); >+ } >+ >+ /** >+ * 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; >+ } >+ >+ /** >+ * 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 int getSortDirection() { >+ return sortDirection; >+ } >+ >+ public void setSortDirection(int sortDirection) { >+ this.sortDirection = sortDirection; >+ } >+ >+ public SortByIndex getSortByIndex() { >+ return sortByIndex; >+ } >+ >+ public void setSortByIndex(SortByIndex sortByIndex) { >+ this.sortByIndex = sortByIndex; >+ } >+ >+ public int getSortDirection2() { >+ return sortDirection2; >+ } >+ >+ public void setSortDirection2(int sortDirection2) { >+ this.sortDirection2 = sortDirection2; >+ } >+ >+ public SortByIndex getSortByIndex2() { >+ return sortByIndex2; >+ } >+ >+ public void setSortByIndex2(SortByIndex sortByIndex2) { >+ this.sortByIndex2 = sortByIndex2; >+ } >+ >+} >Index: src/org/eclipse/mylyn/internal/tasks/ui/search/TaskSearchResultSorter.java >=================================================================== >RCS file: src/org/eclipse/mylyn/internal/tasks/ui/search/TaskSearchResultSorter.java >diff -N src/org/eclipse/mylyn/internal/tasks/ui/search/TaskSearchResultSorter.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/mylyn/internal/tasks/ui/search/TaskSearchResultSorter.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,68 @@ >+/******************************************************************************* >+ * Copyright (c) 2004, 2007 Mylyn project committers 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 >+ *******************************************************************************/ >+ >+package org.eclipse.mylyn.internal.tasks.ui.search; >+ >+import org.eclipse.jface.viewers.Viewer; >+import org.eclipse.jface.viewers.ViewerSorter; >+import org.eclipse.mylyn.internal.tasks.ui.TaskComparator; >+import org.eclipse.mylyn.internal.tasks.ui.TaskComparator.SortByIndex; >+import org.eclipse.mylyn.tasks.core.AbstractTaskContainer; >+ >+/** >+ * @author Frank Becker >+ */ >+ >+public class TaskSearchResultSorter extends ViewerSorter { >+ >+ private final TaskComparator taskComparator = new TaskComparator(); >+ >+ @Override >+ public int compare(Viewer viewer, Object e1, Object e2) { >+ if (e1 instanceof AbstractTaskContainer && e2 instanceof AbstractTaskContainer) { >+ AbstractTaskContainer entry1 = (AbstractTaskContainer) e1; >+ AbstractTaskContainer entry2 = (AbstractTaskContainer) e2; >+ return taskComparator.compare(entry1, entry2); >+ } else { >+ return super.compare(viewer, e1, e2); >+ } >+ } >+ >+ public int getSortDirection() { >+ return taskComparator.getSortDirection(); >+ } >+ >+ public void setSortDirection(int sortDirection) { >+ taskComparator.setSortDirection(sortDirection); >+ } >+ >+ public SortByIndex getSortByIndex() { >+ return taskComparator.getSortByIndex(); >+ } >+ >+ public void setSortByIndex(SortByIndex sortByIndex) { >+ taskComparator.setSortByIndex(sortByIndex); >+ } >+ >+ public int getSortDirection2() { >+ return taskComparator.getSortDirection2(); >+ } >+ >+ public void setSortDirection2(int sortDirection) { >+ taskComparator.setSortDirection2(sortDirection); >+ } >+ >+ public SortByIndex getSortByIndex2() { >+ return taskComparator.getSortByIndex2(); >+ } >+ >+ public void setSortByIndex2(SortByIndex sortByIndex) { >+ taskComparator.setSortByIndex2(sortByIndex); >+ } >+ >+} >Index: src/org/eclipse/mylyn/internal/tasks/ui/search/SearchResultSortDirection.java >=================================================================== >RCS file: src/org/eclipse/mylyn/internal/tasks/ui/search/SearchResultSortDirection.java >diff -N src/org/eclipse/mylyn/internal/tasks/ui/search/SearchResultSortDirection.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/mylyn/internal/tasks/ui/search/SearchResultSortDirection.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,54 @@ >+/******************************************************************************* >+ * Copyright (c) 2004, 2007 Mylyn project committers 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 >+ *******************************************************************************/ >+ >+package org.eclipse.mylyn.internal.tasks.ui.search; >+ >+import org.eclipse.jface.action.Action; >+ >+/** >+ * This class set the sorts direction of the search results. >+ * >+ * @author Frank Becker >+ */ >+public class SearchResultSortDirection extends Action { >+ >+ /** The view where the Bugzilla search results are displayed. */ >+ private final RepositorySearchResultView bugPage; >+ >+ private final boolean secondLevel; >+ >+ /** >+ * Constructor >+ * >+ * @param label >+ * The string used as the text for the action, or null if there is no text >+ * @param page >+ * The view where the Bugzilla search results are displayed. >+ * @param sortOrder >+ * The category that this class sorts Bugzilla search results by >+ */ >+ public SearchResultSortDirection(String label, RepositorySearchResultView page, boolean level2) { >+ super(label); >+ bugPage = page; >+ secondLevel = level2; >+ } >+ >+ /** >+ * Reorder the Bugzilla search results. >+ */ >+ @Override >+ public void run() { >+ if (secondLevel) { >+ bugPage.setSortDirection2(bugPage.getSortDirection2() * -1); >+ setChecked(bugPage.getSortDirection2() < 0); >+ } else { >+ bugPage.setSortDirection(bugPage.getSortDirection() * -1); >+ setChecked(bugPage.getSortDirection() < 0); >+ } >+ } >+}
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