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 134922 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
clipboard.txt (text/plain), 37.65 KB, created by
Steffen Pingel
on 2009-05-08 02:12:22 EDT
(
hide
)
Description:
updated patch
Filename:
MIME Type:
Creator:
Steffen Pingel
Created:
2009-05-08 02:12:22 EDT
Size:
37.65 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.mylyn.tasks.ui >Index: src/org/eclipse/mylyn/internal/tasks/ui/editors/messages.properties >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.mylyn/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/messages.properties,v >retrieving revision 1.11 >diff -u -r1.11 messages.properties >--- src/org/eclipse/mylyn/internal/tasks/ui/editors/messages.properties 5 Mar 2009 23:49:11 -0000 1.11 >+++ src/org/eclipse/mylyn/internal/tasks/ui/editors/messages.properties 8 May 2009 06:12:00 -0000 >@@ -29,12 +29,6 @@ > > PlanningPageFactory_Planning=Planning > >-PreviewAttributeEditor_Edit=Edit >-PreviewAttributeEditor_Error=Error >-PreviewAttributeEditor_Formatting_Wiki_Text=Formatting Wiki Text >-PreviewAttributeEditor_Loading_preview_=Loading preview... >-PreviewAttributeEditor_Preview=Preview >- > RichTextAttributeEditor_Viewer_Source=View Unformatted Text > > TaskAttachmentDropListener_Note_that_only_the_first_file_dragged_will_be_attached=Note that only the first file dragged will be attached. >Index: src/org/eclipse/mylyn/internal/tasks/ui/editors/Messages.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.mylyn/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/Messages.java,v >retrieving revision 1.7 >diff -u -r1.7 Messages.java >--- src/org/eclipse/mylyn/internal/tasks/ui/editors/Messages.java 26 Feb 2009 23:56:39 -0000 1.7 >+++ src/org/eclipse/mylyn/internal/tasks/ui/editors/Messages.java 8 May 2009 06:12:00 -0000 >@@ -71,16 +71,6 @@ > > public static String PlanningPageFactory_Planning; > >- public static String PreviewAttributeEditor_Edit; >- >- public static String PreviewAttributeEditor_Error; >- >- public static String PreviewAttributeEditor_Formatting_Wiki_Text; >- >- public static String PreviewAttributeEditor_Loading_preview_; >- >- public static String PreviewAttributeEditor_Preview; >- > public static String RichTextAttributeEditor_Viewer_Source; > > public static String TaskAttachmentDropListener_Note_that_only_the_first_file_dragged_will_be_attached; >Index: src/org/eclipse/mylyn/internal/tasks/ui/search/Messages.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.mylyn/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/search/Messages.java,v >retrieving revision 1.4 >diff -u -r1.4 Messages.java >--- src/org/eclipse/mylyn/internal/tasks/ui/search/Messages.java 16 Jan 2009 06:14:44 -0000 1.4 >+++ src/org/eclipse/mylyn/internal/tasks/ui/search/Messages.java 8 May 2009 06:12:00 -0000 >@@ -47,12 +47,6 @@ > > public static String RepositorySearchResultView_Refine_Search_; > >- public static String RepositorySearchResultView_Sort_by; >- >- public static String RepositorySearchResultView_Task_Priority; >- >- public static String RepositorySearchResultView_Task_Summary; >- > public static String SearchHitCollector_Max_allowed_number_of_hits_returned_exceeded; > > public static String SearchHitCollector_Querying_Repository_; >@@ -72,4 +66,6 @@ > public static String SearchResultTreeContentProvider_Incomplete; > > public static String SearchResultTreeContentProvider__unknown_; >+ >+ public static String SearchResultSortAction_Sort_Label; > } >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.7 >diff -u -r1.7 SearchResultSortAction.java >--- src/org/eclipse/mylyn/internal/tasks/ui/search/SearchResultSortAction.java 13 Jan 2009 07:07:36 -0000 1.7 >+++ src/org/eclipse/mylyn/internal/tasks/ui/search/SearchResultSortAction.java 8 May 2009 06:12:00 -0000 >@@ -12,48 +12,27 @@ > package org.eclipse.mylyn.internal.tasks.ui.search; > > import org.eclipse.jface.action.Action; >+import org.eclipse.jface.window.Window; >+import org.eclipse.mylyn.internal.tasks.ui.dialogs.TaskCompareDialog; > > /** >- * This class sorts search results by a supplied category. >- * >- * @author Rob Elves (moved to tasks.ui) >+ * @author Steffen Pingel > */ > public class SearchResultSortAction extends Action { > >- /** The category that this class sorts Bugzilla search results by. */ >- private final int bugSortOrder; >+ private final RepositorySearchResultView view; > >- /** The view where the Bugzilla search results are displayed. */ >- private final RepositorySearchResultView bugPage; >- >- /** >- * 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 SearchResultSortAction(String label, RepositorySearchResultView page, int sortOrder) { >- super(label); >- bugPage = page; >- bugSortOrder = sortOrder; >+ public SearchResultSortAction(RepositorySearchResultView view) { >+ super(Messages.SearchResultSortAction_Sort_Label); >+ this.view = view; >+ setEnabled(true); > } > >- /** >- * Reorder the Bugzilla search results. >- */ > @Override > public void run() { >- bugPage.setSortOrder(bugSortOrder); >- } >- >- /** >- * Returns the category that this class sorts Bugzilla search results by. >- */ >- public int getSortOrder() { >- return bugSortOrder; >+ TaskCompareDialog dialog = new TaskCompareDialog(view.getSite(), view.getSorter().getTaskComparator()); >+ if (dialog.open() == Window.OK) { >+ view.getViewer().refresh(); >+ } > } > } >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 13 Jan 2009 07:07:36 -0000 1.11 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,65 +0,0 @@ >-/******************************************************************************* >- * 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.search; >- >-import org.eclipse.jface.viewers.Viewer; >-import org.eclipse.jface.viewers.ViewerSorter; >-import org.eclipse.mylyn.tasks.core.ITask; >- >-/** >- * 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 { >- ITask hit1 = (ITask) e1; >- ITask hit2 = (ITask) 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 { >- ITask hit = (ITask) 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/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 13 Jan 2009 07:07:36 -0000 1.10 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,73 +0,0 @@ >-/******************************************************************************* >- * 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.search; >- >-import org.eclipse.jface.viewers.Viewer; >-import org.eclipse.jface.viewers.ViewerSorter; >-import org.eclipse.mylyn.tasks.core.ITask; >- >-/** >- * 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 >- ITask entry1 = (ITask) e1; >- Integer id1 = Integer.parseInt(entry1.getTaskId()); >- >- // cast the other object and get its bug taskId >- ITask entry2 = (ITask) 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 { >- ITask hit = (ITask) 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/search/SearchResultSorter.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.mylyn/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/search/SearchResultSorter.java,v >retrieving revision 1.1 >diff -u -r1.1 SearchResultSorter.java >--- src/org/eclipse/mylyn/internal/tasks/ui/search/SearchResultSorter.java 18 Jan 2009 08:53:02 -0000 1.1 >+++ src/org/eclipse/mylyn/internal/tasks/ui/search/SearchResultSorter.java 8 May 2009 06:12:00 -0000 >@@ -7,71 +7,44 @@ > * > * Contributors: > * Tasktop Technologies - initial API and implementation >+ * Frank Becker - fix for bug 216150 > *******************************************************************************/ > > 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.core.AbstractTask; > import org.eclipse.mylyn.internal.tasks.ui.util.TaskComparator; >-import org.eclipse.mylyn.internal.tasks.ui.views.TaskKeyComparator; > import org.eclipse.mylyn.tasks.core.ITask; > > /** >- * Sorts search results by summary. >+ * Sorts search results. > * >+ * @see TaskComparator > * @author Rob Elves >+ * @author Frank Becker > */ > public class SearchResultSorter extends ViewerSorter { > >- private final TaskKeyComparator taskKeyComparator = new TaskKeyComparator(); >+ private final TaskComparator taskComparator; >+ >+ public SearchResultSorter() { >+ taskComparator = new TaskComparator(); >+ } > >- /** >- * 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(TaskComparator.getSortableFromElement(entry1), >- TaskComparator.getSortableFromElement(entry2)); >- // return taskKeyComparator.compare(entry1.getDescription(), >- // entry2.getDescription()); >- } catch (Exception ignored) { >- // do nothing >+ if (e1 instanceof ITask && e2 instanceof ITask) { >+ ITask entry1 = (ITask) e1; >+ ITask entry2 = (ITask) e2; >+ return taskComparator.compare(entry1, entry2); >+ } else { >+ return super.compare(viewer, e1, e2); > } >- >- // 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 { >- ITask hit = (ITask) 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); >+ public TaskComparator getTaskComparator() { >+ return taskComparator; > } >+ > } >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.64 >diff -u -r1.64 RepositorySearchResultView.java >--- src/org/eclipse/mylyn/internal/tasks/ui/search/RepositorySearchResultView.java 30 Apr 2009 18:00:10 -0000 1.64 >+++ src/org/eclipse/mylyn/internal/tasks/ui/search/RepositorySearchResultView.java 8 May 2009 06:12:00 -0000 >@@ -37,7 +37,6 @@ > import org.eclipse.mylyn.internal.tasks.core.TaskGroup; > import org.eclipse.mylyn.internal.tasks.core.UnmatchedTaskContainer; > import org.eclipse.mylyn.internal.tasks.ui.AddExistingTaskJob; >-import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin; > import org.eclipse.mylyn.internal.tasks.ui.actions.OpenTaskSearchAction; > import org.eclipse.mylyn.internal.tasks.ui.actions.OpenWithBrowserAction; > import org.eclipse.mylyn.internal.tasks.ui.search.SearchResultTreeContentProvider.GroupBy; >@@ -60,6 +59,7 @@ > import org.eclipse.swt.widgets.Composite; > import org.eclipse.swt.widgets.Event; > import org.eclipse.swt.widgets.Layout; >+import org.eclipse.ui.IMemento; > import org.eclipse.ui.PartInitException; > import org.eclipse.ui.PlatformUI; > import org.eclipse.ui.dialogs.FilteredTree; >@@ -89,10 +89,6 @@ > groupingActions.add(this); > } > >- public GroupBy getGroupBy() { >- return groupBy; >- } >- > @Override > public void run() { > for (GroupingAction action : groupingActions) { >@@ -130,28 +126,10 @@ > } > } > >- public static final int ORDER_PRIORITY = 1; >- >- 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_DEFAULT = ORDER_PRIORITY; >- >- private static final String KEY_SORTING = TasksUiPlugin.ID_PLUGIN + ".search.resultpage.sorting"; //$NON-NLS-1$ >+ private static final String MEMENTO_KEY_SORT = "sort"; //$NON-NLS-1$ > > private SearchResultContentProvider searchResultProvider; > >- private int currentSortOrder; >- >- private final SearchResultSortAction sortByPriorityAction; >- >- private final SearchResultSortAction sortByDescriptionAction; >- > private final OpenSearchResultAction openInEditorAction; > > private final CreateQueryFromSearchAction createQueryAction; >@@ -168,6 +146,10 @@ > > private final OpenWithBrowserAction openSearchWithBrowserAction; > >+ private final SearchResultSorter searchResultSorter; >+ >+ private SearchResultSortAction sortByDialogAction; >+ > private static final IShowInTargetList SHOW_IN_TARGET_LIST = new IShowInTargetList() { > public String[] getShowInTargetIds() { > return SHOW_IN_TARGETS; >@@ -178,12 +160,6 @@ > // Only use the table layout. > super(FLAG_LAYOUT_TREE); > >- sortByPriorityAction = new SearchResultSortAction(Messages.RepositorySearchResultView_Task_Priority, this, >- ORDER_PRIORITY); >- sortByDescriptionAction = new SearchResultSortAction(Messages.RepositorySearchResultView_Task_Summary, this, >- ORDER_DESCRIPTION); >- currentSortOrder = ORDER_DEFAULT; >- > openInEditorAction = new OpenSearchResultAction(Messages.RepositorySearchResultView_Open_in_Editor, this); > createQueryAction = new CreateQueryFromSearchAction( > Messages.RepositorySearchResultView_Create_Query_from_Search_, this); >@@ -194,7 +170,7 @@ > > groupingActions = new ArrayList<GroupingAction>(); > new GroupingAction(Messages.RepositorySearchResultView_Group_By_Owner, GroupBy.OWNER); >- //new GroupingAction("Group By Complete", GroupBy.COMPLETION); >+// new GroupingAction(Messages.RepositorySearchResultView_Group_By_Complete, GroupBy.COMPLETION); > > filterActions = new ArrayList<FilteringAction>(); > new FilteringAction(Messages.RepositorySearchResultView_Filter_Completed_Tasks, new ViewerFilter() { >@@ -209,6 +185,9 @@ > return true; > } > }); >+ >+ // construct early since to be ready when restoreState() is invoked >+ searchResultSorter = new SearchResultSorter(); > } > > @Override >@@ -242,10 +221,8 @@ > DecoratingLabelProvider labelProvider = new DecoratingLabelProvider(new SearchResultsLabelProvider( > searchResultProvider, viewer), PlatformUI.getWorkbench().getDecoratorManager().getLabelDecorator()); > viewer.setLabelProvider(labelProvider); >- >- // Set the order when the search view is loading so that the items are >- // sorted right away >- setSortOrder(currentSortOrder); >+ viewer.setSorter(searchResultSorter); >+ sortByDialogAction = new SearchResultSortAction(this); > > toolTip = new TaskListToolTip(viewer.getControl()); > } >@@ -319,36 +296,6 @@ > super.dispose(); > } > >- /** >- * Sets the new sorting category, and reorders all of the tasks. >- * >- * @param sortOrder >- * 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 SearchResultSorter()); >- break; >- case ORDER_PRIORITY: >- viewer.setSorter(new SearchResultSorterPriority()); >- 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()); >- break; >- } >- currentSortOrder = sortOrder; >- getSettings().put(KEY_SORTING, currentSortOrder); >- } >- > @SuppressWarnings("unchecked") > public Object getAdapter(Class adapter) { > return getAdapterDelegate(adapter); >@@ -373,7 +320,6 @@ > super.fillContextMenu(menuManager); > > // open actions >- > menuManager.appendToGroup(IContextMenuConstants.GROUP_OPEN, openInEditorAction); > > // Add to Task List menu >@@ -405,16 +351,7 @@ > menuManager.appendToGroup(IContextMenuConstants.GROUP_SEARCH, refineSearchAction); > menuManager.appendToGroup(IContextMenuConstants.GROUP_SEARCH, openSearchWithBrowserAction); > >- // sort actions >- >- MenuManager sortMenuManager = new MenuManager(Messages.RepositorySearchResultView_Sort_by); >- sortMenuManager.add(sortByPriorityAction); >- sortMenuManager.add(sortByDescriptionAction); >- >- sortByPriorityAction.setChecked(currentSortOrder == sortByPriorityAction.getSortOrder()); >- sortByDescriptionAction.setChecked(currentSortOrder == sortByDescriptionAction.getSortOrder()); >- >- menuManager.appendToGroup(IContextMenuConstants.GROUP_VIEWER_SETUP, sortMenuManager); >+ menuManager.appendToGroup(IContextMenuConstants.GROUP_VIEWER_SETUP, sortByDialogAction); > for (Action action : groupingActions) { > menuManager.appendToGroup(IContextMenuConstants.GROUP_VIEWER_SETUP, action); > } >@@ -469,4 +406,26 @@ > } > } > >+ public SearchResultSorter getSorter() { >+ return searchResultSorter; >+ } >+ >+ @Override >+ public void restoreState(IMemento memento) { >+ super.restoreState(memento); >+ IMemento child = memento.getChild(MEMENTO_KEY_SORT); >+ if (child != null && searchResultSorter != null) { >+ searchResultSorter.getTaskComparator().restoreState(child); >+ } >+ } >+ >+ @Override >+ public void saveState(IMemento memento) { >+ super.saveState(memento); >+ IMemento child = memento.createChild(MEMENTO_KEY_SORT); >+ if (searchResultSorter != null) { >+ searchResultSorter.getTaskComparator().saveState(child); >+ } >+ } >+ > } >Index: src/org/eclipse/mylyn/internal/tasks/ui/search/messages.properties >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.mylyn/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/search/messages.properties,v >retrieving revision 1.4 >diff -u -r1.4 messages.properties >--- src/org/eclipse/mylyn/internal/tasks/ui/search/messages.properties 16 Jan 2009 06:14:44 -0000 1.4 >+++ src/org/eclipse/mylyn/internal/tasks/ui/search/messages.properties 8 May 2009 06:12:00 -0000 >@@ -9,9 +9,6 @@ > RepositorySearchResultView_Open_in_Editor=Open in Editor > RepositorySearchResultView_Open_Search_with_Browser_Label=Open Search with Browser > RepositorySearchResultView_Refine_Search_=Refine Search... >-RepositorySearchResultView_Sort_by=S&ort by >-RepositorySearchResultView_Task_Priority=Task Priority >-RepositorySearchResultView_Task_Summary=Task Summary > > SearchHitCollector_Max_allowed_number_of_hits_returned_exceeded=Max allowed number of hits returned exceeded. Some hits may not be displayed. Please narrow query scope. > SearchHitCollector_Querying_Repository_=Querying Repository... >@@ -25,3 +22,5 @@ > SearchResultTreeContentProvider_Complete=Complete > SearchResultTreeContentProvider_Incomplete=Incomplete > SearchResultTreeContentProvider__unknown_=<unknown> >+ >+SearchResultSortAction_Sort_Label=Sort... >Index: src/org/eclipse/mylyn/internal/tasks/ui/messages.properties >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.mylyn/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/messages.properties,v >retrieving revision 1.5 >diff -u -r1.5 messages.properties >--- src/org/eclipse/mylyn/internal/tasks/ui/messages.properties 19 Feb 2009 17:41:10 -0000 1.5 >+++ src/org/eclipse/mylyn/internal/tasks/ui/messages.properties 8 May 2009 06:12:00 -0000 >@@ -35,10 +35,8 @@ > > TaskLabelDecorator____unknown_host___=\ \ \ [ <unknown host> ] > >-TaskListBackupManager_Could_not_backup_task_data=Could not backup task data. Check backup preferences.\n > TaskListBackupManager_Error_occured_during_scheduled_tasklist_backup=Error occured during scheduled tasklist backup.\nCheck settings on Tasklist preferences page. > TaskListBackupManager_Scheduled_task_data_backup=Scheduled task data backup >-TaskListBackupManager_Tasklist_Backup=Tasklist Backup > > TaskListNotificationManager_Open_Notification_Job=Open Notification Job > >@@ -79,8 +77,6 @@ > TasksUiUtil_Browser_could_not_be_initiated=Browser could not be initiated > TasksUiUtil_Browser_init_error=Browser init error > TasksUiUtil_Could_not_open_URL_=Could not open URL: >-TasksUiUtil_create_task=Create Task >-TasksUiUtil_failed_to_create_new_task=Failed to create new task:\n\n > TasksUiUtil_No_URL_to_open=No URL to open. > > AbstractRetrieveTitleFromUrlJob_Retrieving_summary_from_URL=Retrieving summary from URL >Index: src/org/eclipse/mylyn/internal/tasks/ui/Messages.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.mylyn/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/Messages.java,v >retrieving revision 1.3 >diff -u -r1.3 Messages.java >--- src/org/eclipse/mylyn/internal/tasks/ui/Messages.java 19 Feb 2009 17:41:10 -0000 1.3 >+++ src/org/eclipse/mylyn/internal/tasks/ui/Messages.java 8 May 2009 06:12:00 -0000 >@@ -71,14 +71,10 @@ > > public static String TaskLabelDecorator____unknown_host___; > >- public static String TaskListBackupManager_Could_not_backup_task_data; >- > public static String TaskListBackupManager_Error_occured_during_scheduled_tasklist_backup; > > public static String TaskListBackupManager_Scheduled_task_data_backup; > >- public static String TaskListBackupManager_Tasklist_Backup; >- > public static String TaskListNotificationManager_Open_Notification_Job; > > public static String TaskRepositoryLocationUi_Enter_HTTP_password; >@@ -139,10 +135,6 @@ > > public static String TasksUiUtil_Could_not_open_URL_; > >- public static String TasksUiUtil_create_task; >- >- public static String TasksUiUtil_failed_to_create_new_task; >- > public static String TasksUiUtil_No_URL_to_open; > > public static String AbstractRetrieveTitleFromUrlJob_Retrieving_summary_from_URL; >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.6 >diff -u -r1.6 TaskComparator.java >--- src/org/eclipse/mylyn/internal/tasks/ui/util/TaskComparator.java 3 May 2009 19:50:17 -0000 1.6 >+++ src/org/eclipse/mylyn/internal/tasks/ui/util/TaskComparator.java 8 May 2009 06:12:00 -0000 >@@ -13,12 +13,14 @@ > package org.eclipse.mylyn.internal.tasks.ui.util; > > import java.util.Comparator; >+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.views.TaskKeyComparator; > import org.eclipse.mylyn.tasks.core.IRepositoryElement; > import org.eclipse.mylyn.tasks.core.ITask; >+import org.eclipse.ui.IMemento; > > /** > * @author Mik Kersten >@@ -26,10 +28,17 @@ > */ > public class TaskComparator implements Comparator<ITask> { > >- private final TaskKeyComparator taskKeyComparator = new TaskKeyComparator(); >- > public enum SortByIndex { >- PRIORITY, SUMMARY, DATE_CREATED, TASK_ID; >+ 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) { >@@ -46,19 +55,22 @@ > } > } > >- public static SortByIndex valueOfLabel(String label) { >- for (SortByIndex value : values()) { >- if (value.getLabel().equals(label)) { >- return value; >- } >- } >- return null; >- } >- > } > > public static final int DEFAULT_SORT_DIRECTION = 1; > >+ private static final SortByIndex DEFAULT_SORT_INDEX = SortByIndex.PRIORITY; >+ >+ private static final SortByIndex DEFAULT_SORT_INDEX2 = SortByIndex.DATE_CREATED; >+ >+ private static final String MEMENTO_KEY_SORT_DIRECTION = "sortDirection"; //$NON-NLS-1$ >+ >+ private static final String MEMENTO_KEY_SORT_DIRECTION2 = "sortDirection2"; //$NON-NLS-1$ >+ >+ private static final String MEMENTO_KEY_SORT_INDEX = "sortIndex"; //$NON-NLS-1$ >+ >+ private static final String MEMENTO_KEY_SORT_INDEX2 = "sortIndex2"; //$NON-NLS-1$ >+ > /** > * Return a array of values to pass to taskKeyComparator.compare() for sorting > * >@@ -78,25 +90,27 @@ > return a; > } > >- private int sortDirection = DEFAULT_SORT_DIRECTION; >+ private SortByIndex sortByIndex = DEFAULT_SORT_INDEX; > >- private SortByIndex sortByIndex = SortByIndex.PRIORITY; >+ private SortByIndex sortByIndex2 = DEFAULT_SORT_INDEX2; >+ >+ private int sortDirection = DEFAULT_SORT_DIRECTION; > > private int sortDirection2 = DEFAULT_SORT_DIRECTION; > >- private SortByIndex sortByIndex2 = SortByIndex.DATE_CREATED; >+ private final TaskKeyComparator taskKeyComparator = new TaskKeyComparator(); > > public TaskComparator() { > } > > public int compare(ITask element1, ITask element2) { >- if (SortByIndex.PRIORITY.equals(sortByIndex)) { >+ if (DEFAULT_SORT_INDEX.equals(sortByIndex)) { > int result = sortByPriority(element1, element2, sortDirection); > if (result != 0) { > return result; > } > >- if (SortByIndex.DATE_CREATED.equals(sortByIndex2)) { >+ if (DEFAULT_SORT_INDEX2.equals(sortByIndex2)) { > return sortByDate(element1, element2, sortDirection2); > } else { > if (SortByIndex.SUMMARY.equals(sortByIndex2)) { >@@ -107,12 +121,12 @@ > return result; > } > } >- } else if (SortByIndex.DATE_CREATED.equals(sortByIndex)) { >+ } else if (DEFAULT_SORT_INDEX2.equals(sortByIndex)) { > int result = sortByDate(element1, element2, sortDirection); > if (result != 0) { > return result; > } >- if (SortByIndex.PRIORITY.equals(sortByIndex2)) { >+ if (DEFAULT_SORT_INDEX.equals(sortByIndex2)) { > return sortByPriority(element1, element2, sortDirection2); > } else { > if (SortByIndex.SUMMARY.equals(sortByIndex2)) { >@@ -128,10 +142,10 @@ > if (result != 0) { > return result; > } >- if (SortByIndex.DATE_CREATED.equals(sortByIndex2)) { >+ if (DEFAULT_SORT_INDEX2.equals(sortByIndex2)) { > return sortByDate(element1, element2, sortDirection2); > } else { >- if (SortByIndex.PRIORITY.equals(sortByIndex2)) { >+ if (DEFAULT_SORT_INDEX.equals(sortByIndex2)) { > return sortByPriority(element1, element2, sortDirection2); > } else if (SortByIndex.TASK_ID.equals(sortByIndex2)) { > return sortByID(element1, element2, sortDirection2); >@@ -144,10 +158,10 @@ > if (result != 0) { > return result; > } >- if (SortByIndex.DATE_CREATED.equals(sortByIndex2)) { >+ if (DEFAULT_SORT_INDEX2.equals(sortByIndex2)) { > return sortByDate(element1, element2, sortDirection2); > } else { >- if (SortByIndex.PRIORITY.equals(sortByIndex2)) { >+ if (DEFAULT_SORT_INDEX.equals(sortByIndex2)) { > return sortByPriority(element1, element2, sortDirection2); > } else if (SortByIndex.SUMMARY.equals(sortByIndex2)) { > return sortBySummary(element1, element2, sortDirection2); >@@ -158,43 +172,54 @@ > } > } > >- private int sortBySummary(ITask element1, ITask element2, int sortDirection) { >- String key1 = element1.getSummary(); >- String key2 = element2.getSummary(); >- if (key1 == null) { >- return (key2 != null) ? sortDirection : 0; >- } else if (key2 == null) { >- return -sortDirection; >- } >- return sortDirection * key1.compareToIgnoreCase(key2); >+ public SortByIndex getSortByIndex() { >+ return sortByIndex; > } > >- private int sortByID(ITask element1, ITask element2, int sortDirection) { >- String key1 = element1.getTaskKey(); >- String key2 = element2.getTaskKey(); >- if (key1 == null) { >- return (key2 != null) ? sortDirection : 0; >- } else if (key2 == null) { >- return -sortDirection; >+ public SortByIndex getSortByIndex2() { >+ return sortByIndex2; >+ } >+ >+ public int getSortDirection() { >+ return sortDirection; >+ } >+ >+ private int getSortDirection(IMemento memento, String key, int defaultValue) { >+ Integer value = memento.getInteger(key); >+ if (value != null) { >+ return value >= 0 ? 1 : -1; > } >- return sortDirection * taskKeyComparator.compare2(key1, key2); >+ return defaultValue; > } > >- private int sortByPriority(ITask element1, ITask element2, int sortDirection) { >- return sortDirection * (element1.getPriority().compareToIgnoreCase(element2.getPriority())); >+ public int getSortDirection2() { >+ return sortDirection2; > } > >- private int sortByDate(ITask element1, ITask element2, int sortDirection) { >- if (element1.getCreationDate() == null) { >- return (element2.getCreationDate() != null) ? sortDirection : 0; >- } else if (element2.getCreationDate() == null) { >- return -sortDirection; >+ private SortByIndex getSortIndex(IMemento memento, String key, SortByIndex defaultValue) { >+ String value = memento.getString(key); >+ if (value != null) { >+ try { >+ return SortByIndex.valueOf(value); >+ } catch (IllegalArgumentException e) { >+ // ignore >+ } > } >- return sortDirection * (element1.getCreationDate().compareTo(element2.getCreationDate())); >+ return defaultValue; > } > >- public SortByIndex getSortByIndex() { >- return sortByIndex; >+ 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)); >+ } >+ >+ 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()); > } > > public void setSortByIndex(SortByIndex sortByIndex) { >@@ -202,29 +227,56 @@ > this.sortByIndex = sortByIndex; > } > >- public int getSortDirection() { >- return sortDirection; >+ public void setSortByIndex2(SortByIndex sortByIndex) { >+ Assert.isNotNull(sortByIndex); >+ this.sortByIndex2 = sortByIndex; > } > > public void setSortDirection(int sortDirection) { >+ Assert.isTrue(sortDirection == -1 || sortDirection == 1); > this.sortDirection = sortDirection; > } > >- public SortByIndex getSortByIndex2() { >- return sortByIndex2; >+ public void setSortDirection2(int sortDirection) { >+ Assert.isTrue(sortDirection == -1 || sortDirection == 1); >+ this.sortDirection2 = sortDirection; > } > >- public void setSortByIndex2(SortByIndex sortByIndex) { >- Assert.isNotNull(sortByIndex); >- this.sortByIndex2 = sortByIndex; >+ private int sortByDate(ITask element1, ITask element2, int sortDirection) { >+ Date date1 = element1.getCreationDate(); >+ Date date2 = element2.getCreationDate(); >+ if (date1 == null) { >+ return (date2 != null) ? sortDirection : 0; >+ } else if (date2 == null) { >+ return -sortDirection; >+ } >+ return sortDirection * date1.compareTo(date2); > } > >- public int getSortDirection2() { >- return sortDirection2; >+ private int sortByID(ITask element1, ITask element2, int sortDirection) { >+ String key1 = element1.getTaskKey(); >+ String key2 = element2.getTaskKey(); >+ if (key1 == null) { >+ return (key2 != null) ? sortDirection : 0; >+ } else if (key2 == null) { >+ return -sortDirection; >+ } >+ return sortDirection * taskKeyComparator.compare2(key1, key2); > } > >- public void setSortDirection2(int sortDirection) { >- this.sortDirection2 = sortDirection; >+ private int sortByPriority(ITask element1, ITask element2, int sortDirection) { >+ return sortDirection * element1.getPriority().compareToIgnoreCase(element2.getPriority()); >+ } >+ >+ private int sortBySummary(ITask element1, ITask element2, int sortDirection) { >+ String key1 = element1.getSummary(); >+ String key2 = element2.getSummary(); >+ if (key1 == null) { >+ return (key2 != null) ? sortDirection : 0; >+ } else if (key2 == null) { >+ return -sortDirection; >+ } >+ return sortDirection * key1.compareToIgnoreCase(key2); > } > > } >Index: .refactorings/2009/3/13/refactorings.history >=================================================================== >RCS file: .refactorings/2009/3/13/refactorings.history >diff -N .refactorings/2009/3/13/refactorings.history >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ .refactorings/2009/3/13/refactorings.history 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,4 @@ >+<?xml version="1.0" encoding="UTF-8"?> >+<session version="1.0"> >+<refactoring accessors="true" comment="Delete 2 element(s) from project 'org.eclipse.mylyn.tasks.ui'
- Original project: 'org.eclipse.mylyn.tasks.ui'
- Original elements:
 org.eclipse.mylyn.internal.tasks.ui.search.SearchResultSorterId.java
 org.eclipse.mylyn.internal.tasks.ui.search.SearchResultSorterPriority.java" description="Delete elements" element1="/src<org.eclipse.mylyn.internal.tasks.ui.search{SearchResultSorterId.java" element2="/src<org.eclipse.mylyn.internal.tasks.ui.search{SearchResultSorterPriority.java" elements="2" flags="589830" id="org.eclipse.jdt.ui.delete" resources="0" stamp="1238277505401" subPackages="false" version="1.0"/> >+</session> >\ No newline at end of file >Index: .refactorings/2009/3/13/refactorings.index >=================================================================== >RCS file: .refactorings/2009/3/13/refactorings.index >diff -N .refactorings/2009/3/13/refactorings.index >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ .refactorings/2009/3/13/refactorings.index 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,1 @@ >+1238277505401 Delete elements
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