|
Lines 16-21
Link Here
|
| 16 |
import org.eclipse.jface.action.Action; |
16 |
import org.eclipse.jface.action.Action; |
| 17 |
import org.eclipse.jface.action.IMenuManager; |
17 |
import org.eclipse.jface.action.IMenuManager; |
| 18 |
import org.eclipse.jface.action.MenuManager; |
18 |
import org.eclipse.jface.action.MenuManager; |
|
|
19 |
import org.eclipse.jface.action.Separator; |
| 19 |
import org.eclipse.jface.viewers.DecoratingLabelProvider; |
20 |
import org.eclipse.jface.viewers.DecoratingLabelProvider; |
| 20 |
import org.eclipse.jface.viewers.StructuredSelection; |
21 |
import org.eclipse.jface.viewers.StructuredSelection; |
| 21 |
import org.eclipse.jface.viewers.StructuredViewer; |
22 |
import org.eclipse.jface.viewers.StructuredViewer; |
|
Lines 23-28
Link Here
|
| 23 |
import org.eclipse.jface.viewers.TreeViewer; |
24 |
import org.eclipse.jface.viewers.TreeViewer; |
| 24 |
import org.eclipse.mylyn.internal.tasks.core.UnmatchedTaskContainer; |
25 |
import org.eclipse.mylyn.internal.tasks.core.UnmatchedTaskContainer; |
| 25 |
import org.eclipse.mylyn.internal.tasks.ui.AddExistingTaskJob; |
26 |
import org.eclipse.mylyn.internal.tasks.ui.AddExistingTaskJob; |
|
|
27 |
import org.eclipse.mylyn.internal.tasks.ui.TaskComparator; |
| 26 |
import org.eclipse.mylyn.internal.tasks.ui.TaskListPatternFilter; |
28 |
import org.eclipse.mylyn.internal.tasks.ui.TaskListPatternFilter; |
| 27 |
import org.eclipse.mylyn.internal.tasks.ui.TasksUiImages; |
29 |
import org.eclipse.mylyn.internal.tasks.ui.TasksUiImages; |
| 28 |
import org.eclipse.mylyn.internal.tasks.ui.views.TaskListView; |
30 |
import org.eclipse.mylyn.internal.tasks.ui.views.TaskListView; |
|
Lines 31-37
Link Here
|
| 31 |
import org.eclipse.mylyn.tasks.core.TaskRepository; |
33 |
import org.eclipse.mylyn.tasks.core.TaskRepository; |
| 32 |
import org.eclipse.mylyn.tasks.ui.TasksUiPlugin; |
34 |
import org.eclipse.mylyn.tasks.ui.TasksUiPlugin; |
| 33 |
import org.eclipse.mylyn.tasks.ui.TasksUiUtil; |
35 |
import org.eclipse.mylyn.tasks.ui.TasksUiUtil; |
| 34 |
import org.eclipse.search.internal.ui.SearchMessages; |
|
|
| 35 |
import org.eclipse.search.ui.IContextMenuConstants; |
36 |
import org.eclipse.search.ui.IContextMenuConstants; |
| 36 |
import org.eclipse.search.ui.text.AbstractTextSearchViewPage; |
37 |
import org.eclipse.search.ui.text.AbstractTextSearchViewPage; |
| 37 |
import org.eclipse.search.ui.text.Match; |
38 |
import org.eclipse.search.ui.text.Match; |
|
Lines 54-59
Link Here
|
| 54 |
* @author Rob Elves |
55 |
* @author Rob Elves |
| 55 |
* @author Mik Kersten |
56 |
* @author Mik Kersten |
| 56 |
* @author Shawn Minto |
57 |
* @author Shawn Minto |
|
|
58 |
* @author Frank Becker (https://bugs.eclipse.org/bugs/show_bug.cgi?taskId=216150) |
| 57 |
*/ |
59 |
*/ |
| 58 |
public class RepositorySearchResultView extends AbstractTextSearchViewPage implements IAdaptable { |
60 |
public class RepositorySearchResultView extends AbstractTextSearchViewPage implements IAdaptable { |
| 59 |
|
61 |
|
|
Lines 63-94
Link Here
|
| 63 |
|
65 |
|
| 64 |
public static final int ORDER_DESCRIPTION = 2; |
66 |
public static final int ORDER_DESCRIPTION = 2; |
| 65 |
|
67 |
|
| 66 |
public static final int ORDER_SEVERITY = 3; |
68 |
public static final int ORDER_DATE_CREATED = 3; |
| 67 |
|
|
|
| 68 |
public static final int ORDER_STATUS = 4; |
| 69 |
|
| 70 |
public static final int ORDER_ID = 5; |
| 71 |
|
69 |
|
| 72 |
public static final int ORDER_DEFAULT = ORDER_PRIORITY; |
70 |
public static final int ORDER_DEFAULT = ORDER_PRIORITY; |
| 73 |
|
71 |
|
|
|
72 |
public static final int ORDER2_DEFAULT = ORDER_DESCRIPTION; |
| 73 |
|
| 74 |
private static final String KEY_SORTING = TasksUiPlugin.ID_PLUGIN + ".search.resultpage.sorting"; //$NON-NLS-1$ |
74 |
private static final String KEY_SORTING = TasksUiPlugin.ID_PLUGIN + ".search.resultpage.sorting"; //$NON-NLS-1$ |
| 75 |
|
75 |
|
|
|
76 |
private static final String KEY_SORTING2 = TasksUiPlugin.ID_PLUGIN + ".search.resultpage.sorting.then"; //$NON-NLS-1$ |
| 77 |
|
| 76 |
private SearchResultContentProvider searchResultProvider; |
78 |
private SearchResultContentProvider searchResultProvider; |
| 77 |
|
79 |
|
| 78 |
private int currentSortOrder; |
80 |
private int currentSortOrder; |
| 79 |
|
81 |
|
|
|
82 |
private int currentSortOrder2; |
| 83 |
|
| 80 |
private final SearchResultSortAction sortByPriorityAction; |
84 |
private final SearchResultSortAction sortByPriorityAction; |
| 81 |
|
85 |
|
| 82 |
private final SearchResultSortAction sortByDescriptionAction; |
86 |
private final SearchResultSortAction sortByDescriptionAction; |
| 83 |
|
87 |
|
|
|
88 |
private final SearchResultSortAction sortByDateCreated; |
| 89 |
|
| 90 |
private final SearchResultSortAction sortByPriorityAction2; |
| 91 |
|
| 92 |
private final SearchResultSortAction sortByDescriptionAction2; |
| 93 |
|
| 94 |
private final SearchResultSortAction sortByDateCreated2; |
| 95 |
|
| 84 |
private final OpenSearchResultAction openInEditorAction; |
96 |
private final OpenSearchResultAction openInEditorAction; |
| 85 |
|
97 |
|
| 86 |
private final CreateQueryFromSearchAction addTaskListAction; |
98 |
private final CreateQueryFromSearchAction addTaskListAction; |
| 87 |
|
99 |
|
|
|
100 |
private final SearchResultSortDirection sortDirection; |
| 101 |
|
| 102 |
private final SearchResultSortDirection sortDirection2; |
| 103 |
|
| 88 |
private static final String[] SHOW_IN_TARGETS = new String[] { IPageLayout.ID_RES_NAV }; |
104 |
private static final String[] SHOW_IN_TARGETS = new String[] { IPageLayout.ID_RES_NAV }; |
| 89 |
|
105 |
|
| 90 |
private final Action groupByAction; |
106 |
private final Action groupByAction; |
| 91 |
|
107 |
|
|
|
108 |
private TaskSearchResultSorter taskSearchResultSorter; |
| 109 |
|
| 92 |
private static final IShowInTargetList SHOW_IN_TARGET_LIST = new IShowInTargetList() { |
110 |
private static final IShowInTargetList SHOW_IN_TARGET_LIST = new IShowInTargetList() { |
| 93 |
public String[] getShowInTargetIds() { |
111 |
public String[] getShowInTargetIds() { |
| 94 |
return SHOW_IN_TARGETS; |
112 |
return SHOW_IN_TARGETS; |
|
Lines 99-107
Link Here
|
| 99 |
// Only use the table layout. |
117 |
// Only use the table layout. |
| 100 |
super(FLAG_LAYOUT_TREE); |
118 |
super(FLAG_LAYOUT_TREE); |
| 101 |
|
119 |
|
| 102 |
sortByPriorityAction = new SearchResultSortAction("Task Priority", this, ORDER_PRIORITY); |
120 |
sortByPriorityAction = new SearchResultSortAction("Priority", this, ORDER_PRIORITY, false); |
| 103 |
sortByDescriptionAction = new SearchResultSortAction("Task Summary", this, ORDER_DESCRIPTION); |
121 |
sortByPriorityAction.setImageDescriptor(TasksUiImages.PRIORITY_1); |
|
|
122 |
sortByDescriptionAction = new SearchResultSortAction("Summary", this, ORDER_DESCRIPTION, false); |
| 123 |
sortByDateCreated = new SearchResultSortAction("Date Created", this, ORDER_DATE_CREATED, false); |
| 124 |
sortByDateCreated.setImageDescriptor(TasksUiImages.CALENDAR_SMALL); |
| 104 |
currentSortOrder = ORDER_DEFAULT; |
125 |
currentSortOrder = ORDER_DEFAULT; |
|
|
126 |
sortByPriorityAction2 = new SearchResultSortAction("Priority", this, ORDER_PRIORITY, true); |
| 127 |
sortByPriorityAction2.setImageDescriptor(TasksUiImages.PRIORITY_1); |
| 128 |
sortByDescriptionAction2 = new SearchResultSortAction("Summary", this, ORDER_DESCRIPTION, true); |
| 129 |
sortByDateCreated2 = new SearchResultSortAction("Date Created", this, ORDER_DATE_CREATED, true); |
| 130 |
sortByDateCreated2.setImageDescriptor(TasksUiImages.CALENDAR_SMALL); |
| 131 |
currentSortOrder2 = ORDER2_DEFAULT; |
| 132 |
sortDirection = new SearchResultSortDirection("Descending", this, false); |
| 133 |
sortDirection2 = new SearchResultSortDirection("Descending", this, true); |
| 105 |
|
134 |
|
| 106 |
openInEditorAction = new OpenSearchResultAction("Open in Editor", this); |
135 |
openInEditorAction = new OpenSearchResultAction("Open in Editor", this); |
| 107 |
addTaskListAction = new CreateQueryFromSearchAction("Create Query from Search...", this); |
136 |
addTaskListAction = new CreateQueryFromSearchAction("Create Query from Search...", this); |
|
Lines 159-165
Link Here
|
| 159 |
|
188 |
|
| 160 |
// Set the order when the search view is loading so that the items are |
189 |
// Set the order when the search view is loading so that the items are |
| 161 |
// sorted right away |
190 |
// sorted right away |
|
|
191 |
taskSearchResultSorter = new TaskSearchResultSorter(); |
| 192 |
viewer.setSorter(taskSearchResultSorter); |
| 162 |
setSortOrder(currentSortOrder); |
193 |
setSortOrder(currentSortOrder); |
|
|
194 |
setSortOrder2(currentSortOrder2); |
| 163 |
} |
195 |
} |
| 164 |
|
196 |
|
| 165 |
@Override |
197 |
@Override |
|
Lines 230-256
Link Here
|
| 230 |
* The new category to sort by |
262 |
* The new category to sort by |
| 231 |
*/ |
263 |
*/ |
| 232 |
public void setSortOrder(int sortOrder) { |
264 |
public void setSortOrder(int sortOrder) { |
| 233 |
StructuredViewer viewer = getViewer(); |
|
|
| 234 |
|
| 235 |
switch (sortOrder) { |
265 |
switch (sortOrder) { |
| 236 |
case ORDER_ID: |
|
|
| 237 |
viewer.setSorter(new SearchResultSorterId()); |
| 238 |
break; |
| 239 |
case ORDER_DESCRIPTION: |
266 |
case ORDER_DESCRIPTION: |
| 240 |
viewer.setSorter(new SearchResultSorterDescription()); |
267 |
taskSearchResultSorter.setSortByIndex(TaskComparator.SortByIndex.SUMMARY); |
| 241 |
break; |
268 |
break; |
| 242 |
case ORDER_PRIORITY: |
269 |
case ORDER_PRIORITY: |
| 243 |
viewer.setSorter(new SearchResultSorterPriority()); |
270 |
taskSearchResultSorter.setSortByIndex(TaskComparator.SortByIndex.PRIORITY); |
|
|
271 |
break; |
| 272 |
case ORDER_DATE_CREATED: |
| 273 |
taskSearchResultSorter.setSortByIndex(TaskComparator.SortByIndex.DATE_CREATED); |
| 244 |
break; |
274 |
break; |
| 245 |
default: |
275 |
default: |
| 246 |
// If the setting is not one of the four valid ones, |
276 |
// If the setting is not one of the four valid ones, |
| 247 |
// use the default order setting. |
277 |
// use the default order setting. |
| 248 |
sortOrder = ORDER_DEFAULT; |
278 |
sortOrder = ORDER_DEFAULT; |
| 249 |
viewer.setSorter(new SearchResultSorterPriority()); |
279 |
taskSearchResultSorter.setSortByIndex(TaskComparator.SortByIndex.PRIORITY); |
| 250 |
break; |
280 |
break; |
| 251 |
} |
281 |
} |
| 252 |
currentSortOrder = sortOrder; |
282 |
currentSortOrder = sortOrder; |
| 253 |
getSettings().put(KEY_SORTING, currentSortOrder); |
283 |
getSettings().put(KEY_SORTING, currentSortOrder); |
|
|
284 |
|
| 285 |
getViewer().refresh(); |
| 286 |
} |
| 287 |
|
| 288 |
public void setSortOrder2(int sortOrder) { |
| 289 |
switch (sortOrder) { |
| 290 |
case ORDER_DESCRIPTION: |
| 291 |
taskSearchResultSorter.setSortByIndex2(TaskComparator.SortByIndex.SUMMARY); |
| 292 |
break; |
| 293 |
case ORDER_PRIORITY: |
| 294 |
taskSearchResultSorter.setSortByIndex2(TaskComparator.SortByIndex.PRIORITY); |
| 295 |
break; |
| 296 |
case ORDER_DATE_CREATED: |
| 297 |
taskSearchResultSorter.setSortByIndex2(TaskComparator.SortByIndex.DATE_CREATED); |
| 298 |
break; |
| 299 |
default: |
| 300 |
// If the setting is not one of the four valid ones, |
| 301 |
// use the default order setting. |
| 302 |
sortOrder = ORDER_DEFAULT; |
| 303 |
taskSearchResultSorter.setSortByIndex2(TaskComparator.SortByIndex.PRIORITY); |
| 304 |
break; |
| 305 |
} |
| 306 |
currentSortOrder2 = sortOrder; |
| 307 |
getSettings().put(KEY_SORTING2, currentSortOrder2); |
| 308 |
getViewer().refresh(); |
| 309 |
} |
| 310 |
|
| 311 |
public void setSortDirection(int sortDirection) { |
| 312 |
taskSearchResultSorter.setSortDirection(sortDirection); |
| 313 |
getViewer().refresh(); |
| 314 |
} |
| 315 |
|
| 316 |
public int getSortDirection() { |
| 317 |
return taskSearchResultSorter.getSortDirection(); |
| 318 |
} |
| 319 |
|
| 320 |
public void setSortDirection2(int sortDirection) { |
| 321 |
taskSearchResultSorter.setSortDirection2(sortDirection); |
| 322 |
getViewer().refresh(); |
| 323 |
} |
| 324 |
|
| 325 |
public int getSortDirection2() { |
| 326 |
return taskSearchResultSorter.getSortDirection2(); |
| 254 |
} |
327 |
} |
| 255 |
|
328 |
|
| 256 |
@SuppressWarnings("unchecked") |
329 |
@SuppressWarnings("unchecked") |
|
Lines 276-290
Link Here
|
| 276 |
@Override |
349 |
@Override |
| 277 |
protected void fillContextMenu(IMenuManager menuManager) { |
350 |
protected void fillContextMenu(IMenuManager menuManager) { |
| 278 |
super.fillContextMenu(menuManager); |
351 |
super.fillContextMenu(menuManager); |
| 279 |
MenuManager sortMenuManager = new MenuManager(SearchMessages.SortDropDownAction_label); |
352 |
MenuManager sortMenuManager = new MenuManager("First Sort by"); |
| 280 |
sortMenuManager.add(sortByPriorityAction); |
353 |
sortMenuManager.add(sortByPriorityAction); |
| 281 |
sortMenuManager.add(sortByDescriptionAction); |
354 |
sortMenuManager.add(sortByDescriptionAction); |
|
|
355 |
sortMenuManager.add(sortByDateCreated); |
| 356 |
sortMenuManager.add(new Separator()); |
| 357 |
sortMenuManager.add(sortDirection); |
| 282 |
|
358 |
|
| 283 |
sortByPriorityAction.setChecked(currentSortOrder == sortByPriorityAction.getSortOrder()); |
359 |
sortByPriorityAction.setChecked(currentSortOrder == sortByPriorityAction.getSortOrder()); |
| 284 |
sortByDescriptionAction.setChecked(currentSortOrder == sortByDescriptionAction.getSortOrder()); |
360 |
sortByDescriptionAction.setChecked(currentSortOrder == sortByDescriptionAction.getSortOrder()); |
|
|
361 |
sortByDateCreated.setChecked(currentSortOrder == sortByDateCreated.getSortOrder()); |
| 362 |
sortDirection.setChecked(getSortDirection() < 0); |
| 363 |
|
| 364 |
MenuManager sortMenuManager2 = new MenuManager("Then Sort by"); |
| 365 |
sortMenuManager2.add(sortByPriorityAction2); |
| 366 |
sortMenuManager2.add(sortByDescriptionAction2); |
| 367 |
sortMenuManager2.add(sortByDateCreated2); |
| 368 |
sortMenuManager2.add(new Separator()); |
| 369 |
sortMenuManager2.add(sortDirection2); |
| 370 |
|
| 371 |
sortByPriorityAction2.setChecked(currentSortOrder2 == sortByPriorityAction2.getSortOrder()); |
| 372 |
sortByDescriptionAction2.setChecked(currentSortOrder2 == sortByDescriptionAction2.getSortOrder()); |
| 373 |
sortByDateCreated2.setChecked(currentSortOrder2 == sortByDateCreated2.getSortOrder()); |
| 374 |
sortDirection2.setChecked(getSortDirection2() < 0); |
| 285 |
|
375 |
|
| 286 |
// Add the new context menu items |
376 |
// Add the new context menu items |
| 287 |
menuManager.appendToGroup(IContextMenuConstants.GROUP_VIEWER_SETUP, sortMenuManager); |
377 |
menuManager.appendToGroup(IContextMenuConstants.GROUP_VIEWER_SETUP, sortMenuManager); |
|
|
378 |
menuManager.appendToGroup(IContextMenuConstants.GROUP_VIEWER_SETUP, sortMenuManager2); |
| 288 |
menuManager.appendToGroup(IContextMenuConstants.GROUP_VIEWER_SETUP, groupByAction); |
379 |
menuManager.appendToGroup(IContextMenuConstants.GROUP_VIEWER_SETUP, groupByAction); |
| 289 |
|
380 |
|
| 290 |
menuManager.appendToGroup(IContextMenuConstants.GROUP_OPEN, openInEditorAction); |
381 |
menuManager.appendToGroup(IContextMenuConstants.GROUP_OPEN, openInEditorAction); |