|
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.TasksUiImages; |
28 |
import org.eclipse.mylyn.internal.tasks.ui.TasksUiImages; |
| 27 |
import org.eclipse.mylyn.internal.tasks.ui.views.TaskListView; |
29 |
import org.eclipse.mylyn.internal.tasks.ui.views.TaskListView; |
| 28 |
import org.eclipse.mylyn.tasks.core.AbstractTask; |
30 |
import org.eclipse.mylyn.tasks.core.AbstractTask; |
|
Lines 30-36
Link Here
|
| 30 |
import org.eclipse.mylyn.tasks.core.TaskRepository; |
32 |
import org.eclipse.mylyn.tasks.core.TaskRepository; |
| 31 |
import org.eclipse.mylyn.tasks.ui.TasksUiPlugin; |
33 |
import org.eclipse.mylyn.tasks.ui.TasksUiPlugin; |
| 32 |
import org.eclipse.mylyn.tasks.ui.TasksUiUtil; |
34 |
import org.eclipse.mylyn.tasks.ui.TasksUiUtil; |
| 33 |
import org.eclipse.search.internal.ui.SearchMessages; |
|
|
| 34 |
import org.eclipse.search.ui.IContextMenuConstants; |
35 |
import org.eclipse.search.ui.IContextMenuConstants; |
| 35 |
import org.eclipse.search.ui.text.AbstractTextSearchViewPage; |
36 |
import org.eclipse.search.ui.text.AbstractTextSearchViewPage; |
| 36 |
import org.eclipse.search.ui.text.Match; |
37 |
import org.eclipse.search.ui.text.Match; |
|
Lines 47-52
Link Here
|
| 47 |
* |
48 |
* |
| 48 |
* @author Rob Elves |
49 |
* @author Rob Elves |
| 49 |
* @author Mik Kersten |
50 |
* @author Mik Kersten |
|
|
51 |
* @author Frank Becker (https://bugs.eclipse.org/bugs/show_bug.cgi?taskId=216150) |
| 50 |
*/ |
52 |
*/ |
| 51 |
public class RepositorySearchResultView extends AbstractTextSearchViewPage implements IAdaptable { |
53 |
public class RepositorySearchResultView extends AbstractTextSearchViewPage implements IAdaptable { |
| 52 |
|
54 |
|
|
Lines 55-87
Link Here
|
| 55 |
public static final int ORDER_PRIORITY = 1; |
57 |
public static final int ORDER_PRIORITY = 1; |
| 56 |
|
58 |
|
| 57 |
public static final int ORDER_DESCRIPTION = 2; |
59 |
public static final int ORDER_DESCRIPTION = 2; |
| 58 |
|
60 |
|
| 59 |
public static final int ORDER_SEVERITY = 3; |
61 |
public static final int ORDER_DATE_CREATED = 3; |
| 60 |
|
|
|
| 61 |
public static final int ORDER_STATUS = 4; |
| 62 |
|
| 63 |
public static final int ORDER_ID = 5; |
| 64 |
|
62 |
|
| 65 |
public static final int ORDER_DEFAULT = ORDER_PRIORITY; |
63 |
public static final int ORDER_DEFAULT = ORDER_PRIORITY; |
| 66 |
|
64 |
|
|
|
65 |
public static final int ORDER2_DEFAULT = ORDER_DESCRIPTION; |
| 66 |
|
| 67 |
private static final String KEY_SORTING = TasksUiPlugin.ID_PLUGIN + ".search.resultpage.sorting"; //$NON-NLS-1$ |
67 |
private static final String KEY_SORTING = TasksUiPlugin.ID_PLUGIN + ".search.resultpage.sorting"; //$NON-NLS-1$ |
| 68 |
|
68 |
|
|
|
69 |
private static final String KEY_SORTING2 = TasksUiPlugin.ID_PLUGIN + ".search.resultpage.sorting.then"; //$NON-NLS-1$ |
| 70 |
|
| 69 |
private SearchResultContentProvider searchResultProvider; |
71 |
private SearchResultContentProvider searchResultProvider; |
| 70 |
|
72 |
|
| 71 |
private int currentSortOrder; |
73 |
private int currentSortOrder; |
| 72 |
|
74 |
|
|
|
75 |
private int currentSortOrder2; |
| 76 |
|
| 73 |
private SearchResultSortAction sortByPriorityAction; |
77 |
private SearchResultSortAction sortByPriorityAction; |
| 74 |
|
78 |
|
| 75 |
private SearchResultSortAction sortByDescriptionAction; |
79 |
private SearchResultSortAction sortByDescriptionAction; |
| 76 |
|
80 |
|
|
|
81 |
private SearchResultSortAction sortByDateCreated; |
| 82 |
|
| 83 |
private SearchResultSortAction sortByPriorityAction2; |
| 84 |
|
| 85 |
private SearchResultSortAction sortByDescriptionAction2; |
| 86 |
|
| 87 |
private SearchResultSortAction sortByDateCreated2; |
| 88 |
|
| 77 |
private OpenSearchResultAction openInEditorAction; |
89 |
private OpenSearchResultAction openInEditorAction; |
| 78 |
|
90 |
|
| 79 |
private CreateQueryFromSearchAction addTaskListAction; |
91 |
private CreateQueryFromSearchAction addTaskListAction; |
|
|
92 |
|
| 93 |
private SearchResultSortDirection sortDirection; |
| 94 |
|
| 95 |
private SearchResultSortDirection sortDirection2; |
| 80 |
|
96 |
|
| 81 |
private static final String[] SHOW_IN_TARGETS = new String[] { IPageLayout.ID_RES_NAV }; |
97 |
private static final String[] SHOW_IN_TARGETS = new String[] { IPageLayout.ID_RES_NAV }; |
| 82 |
|
98 |
|
| 83 |
private Action groupByAction; |
99 |
private Action groupByAction; |
| 84 |
|
100 |
|
|
|
101 |
private TaskSearchResultSorter taskSearchResultSorter; |
| 102 |
|
| 85 |
private static final IShowInTargetList SHOW_IN_TARGET_LIST = new IShowInTargetList() { |
103 |
private static final IShowInTargetList SHOW_IN_TARGET_LIST = new IShowInTargetList() { |
| 86 |
public String[] getShowInTargetIds() { |
104 |
public String[] getShowInTargetIds() { |
| 87 |
return SHOW_IN_TARGETS; |
105 |
return SHOW_IN_TARGETS; |
|
Lines 92-104
Link Here
|
| 92 |
// Only use the table layout. |
110 |
// Only use the table layout. |
| 93 |
super(FLAG_LAYOUT_TREE); |
111 |
super(FLAG_LAYOUT_TREE); |
| 94 |
|
112 |
|
| 95 |
sortByPriorityAction = new SearchResultSortAction("Task Priority", this, ORDER_PRIORITY); |
113 |
sortByPriorityAction = new SearchResultSortAction("Priority", this, ORDER_PRIORITY, false); |
| 96 |
sortByDescriptionAction = new SearchResultSortAction("Task Summary", this, ORDER_DESCRIPTION); |
114 |
sortByPriorityAction.setImageDescriptor(TasksUiImages.PRIORITY_1); |
|
|
115 |
sortByDescriptionAction = new SearchResultSortAction("Summary", this, ORDER_DESCRIPTION, false); |
| 116 |
sortByDateCreated = new SearchResultSortAction("Date Created", this, ORDER_DATE_CREATED, false); |
| 117 |
sortByDateCreated.setImageDescriptor(TasksUiImages.CALENDAR_SMALL); |
| 97 |
currentSortOrder = ORDER_DEFAULT; |
118 |
currentSortOrder = ORDER_DEFAULT; |
|
|
119 |
sortByPriorityAction2 = new SearchResultSortAction("Priority", this, ORDER_PRIORITY, true); |
| 120 |
sortByPriorityAction2.setImageDescriptor(TasksUiImages.PRIORITY_1); |
| 121 |
sortByDescriptionAction2 = new SearchResultSortAction("Summary", this, ORDER_DESCRIPTION, true); |
| 122 |
sortByDateCreated2 = new SearchResultSortAction("Date Created", this, ORDER_DATE_CREATED, true); |
| 123 |
sortByDateCreated2.setImageDescriptor(TasksUiImages.CALENDAR_SMALL); |
| 124 |
currentSortOrder2 = ORDER2_DEFAULT; |
| 125 |
sortDirection = new SearchResultSortDirection("Descending", this, false); |
| 126 |
sortDirection2 = new SearchResultSortDirection("Descending", this, true); |
| 98 |
|
127 |
|
| 99 |
openInEditorAction = new OpenSearchResultAction("Open in Editor", this); |
128 |
openInEditorAction = new OpenSearchResultAction("Open in Editor", this); |
| 100 |
addTaskListAction = new CreateQueryFromSearchAction("Create Query from Search...", this); |
129 |
addTaskListAction = new CreateQueryFromSearchAction("Create Query from Search...", this); |
| 101 |
|
130 |
|
| 102 |
groupByAction = new Action(){ |
131 |
groupByAction = new Action(){ |
| 103 |
|
132 |
|
| 104 |
@Override |
133 |
@Override |
|
Lines 152-158
Link Here
|
| 152 |
|
181 |
|
| 153 |
// Set the order when the search view is loading so that the items are |
182 |
// Set the order when the search view is loading so that the items are |
| 154 |
// sorted right away |
183 |
// sorted right away |
|
|
184 |
taskSearchResultSorter = new TaskSearchResultSorter(); |
| 185 |
viewer.setSorter(taskSearchResultSorter); |
| 155 |
setSortOrder(currentSortOrder); |
186 |
setSortOrder(currentSortOrder); |
|
|
187 |
setSortOrder2(currentSortOrder2); |
| 156 |
} |
188 |
} |
| 157 |
|
189 |
|
| 158 |
@Override |
190 |
@Override |
|
Lines 205-233
Link Here
|
| 205 |
* The new category to sort by |
237 |
* The new category to sort by |
| 206 |
*/ |
238 |
*/ |
| 207 |
public void setSortOrder(int sortOrder) { |
239 |
public void setSortOrder(int sortOrder) { |
| 208 |
StructuredViewer viewer = getViewer(); |
|
|
| 209 |
|
| 210 |
switch (sortOrder) { |
240 |
switch (sortOrder) { |
| 211 |
case ORDER_ID: |
|
|
| 212 |
viewer.setSorter(new SearchResultSorterId()); |
| 213 |
break; |
| 214 |
case ORDER_DESCRIPTION: |
241 |
case ORDER_DESCRIPTION: |
| 215 |
viewer.setSorter(new SearchResultSorterDescription()); |
242 |
taskSearchResultSorter.setSortByIndex(TaskComparator.SortByIndex.SUMMARY); |
| 216 |
break; |
243 |
break; |
| 217 |
case ORDER_PRIORITY: |
244 |
case ORDER_PRIORITY: |
| 218 |
viewer.setSorter(new SearchResultSorterPriority()); |
245 |
taskSearchResultSorter.setSortByIndex(TaskComparator.SortByIndex.PRIORITY); |
|
|
246 |
break; |
| 247 |
case ORDER_DATE_CREATED: |
| 248 |
taskSearchResultSorter.setSortByIndex(TaskComparator.SortByIndex.DATE_CREATED); |
| 219 |
break; |
249 |
break; |
| 220 |
default: |
250 |
default: |
| 221 |
// If the setting is not one of the four valid ones, |
251 |
// If the setting is not one of the four valid ones, |
| 222 |
// use the default order setting. |
252 |
// use the default order setting. |
| 223 |
sortOrder = ORDER_DEFAULT; |
253 |
sortOrder = ORDER_DEFAULT; |
| 224 |
viewer.setSorter(new SearchResultSorterPriority()); |
254 |
taskSearchResultSorter.setSortByIndex(TaskComparator.SortByIndex.PRIORITY); |
| 225 |
break; |
255 |
break; |
| 226 |
} |
256 |
} |
| 227 |
currentSortOrder = sortOrder; |
257 |
currentSortOrder = sortOrder; |
| 228 |
getSettings().put(KEY_SORTING, currentSortOrder); |
258 |
getSettings().put(KEY_SORTING, currentSortOrder); |
|
|
259 |
getViewer().refresh(); |
| 260 |
} |
| 261 |
|
| 262 |
public void setSortOrder2(int sortOrder) { |
| 263 |
switch (sortOrder) { |
| 264 |
case ORDER_DESCRIPTION: |
| 265 |
taskSearchResultSorter.setSortByIndex2(TaskComparator.SortByIndex.SUMMARY); |
| 266 |
break; |
| 267 |
case ORDER_PRIORITY: |
| 268 |
taskSearchResultSorter.setSortByIndex2(TaskComparator.SortByIndex.PRIORITY); |
| 269 |
break; |
| 270 |
case ORDER_DATE_CREATED: |
| 271 |
taskSearchResultSorter.setSortByIndex(TaskComparator.SortByIndex.DATE_CREATED); |
| 272 |
break; |
| 273 |
default: |
| 274 |
// If the setting is not one of the four valid ones, |
| 275 |
// use the default order setting. |
| 276 |
sortOrder = ORDER_DEFAULT; |
| 277 |
taskSearchResultSorter.setSortByIndex2(TaskComparator.SortByIndex.PRIORITY); |
| 278 |
break; |
| 279 |
} |
| 280 |
currentSortOrder2 = sortOrder; |
| 281 |
getSettings().put(KEY_SORTING2, currentSortOrder2); |
| 282 |
getViewer().refresh(); |
| 283 |
} |
| 284 |
|
| 285 |
public void setSortDirection(int sortDirection) { |
| 286 |
taskSearchResultSorter.setSortDirection(sortDirection); |
| 287 |
getViewer().refresh(); |
| 288 |
} |
| 289 |
|
| 290 |
public int getSortDirection() { |
| 291 |
return taskSearchResultSorter.getSortDirection(); |
| 292 |
} |
| 293 |
|
| 294 |
public void setSortDirection2(int sortDirection) { |
| 295 |
taskSearchResultSorter.setSortDirection2(sortDirection); |
| 296 |
getViewer().refresh(); |
| 229 |
} |
297 |
} |
| 230 |
|
298 |
|
|
|
299 |
public int getSortDirection2() { |
| 300 |
return taskSearchResultSorter.getSortDirection2(); |
| 301 |
} |
| 302 |
|
| 231 |
@SuppressWarnings("unchecked") |
303 |
@SuppressWarnings("unchecked") |
| 232 |
public Object getAdapter(Class adapter) { |
304 |
public Object getAdapter(Class adapter) { |
| 233 |
return getAdapterDelegate(adapter); |
305 |
return getAdapterDelegate(adapter); |
|
Lines 252-266
Link Here
|
| 252 |
@Override |
324 |
@Override |
| 253 |
protected void fillContextMenu(IMenuManager menuManager) { |
325 |
protected void fillContextMenu(IMenuManager menuManager) { |
| 254 |
super.fillContextMenu(menuManager); |
326 |
super.fillContextMenu(menuManager); |
| 255 |
MenuManager sortMenuManager = new MenuManager(SearchMessages.SortDropDownAction_label); |
327 |
MenuManager sortMenuManager = new MenuManager("First Sort by"); |
| 256 |
sortMenuManager.add(sortByPriorityAction); |
328 |
sortMenuManager.add(sortByPriorityAction); |
| 257 |
sortMenuManager.add(sortByDescriptionAction); |
329 |
sortMenuManager.add(sortByDescriptionAction); |
|
|
330 |
sortMenuManager.add(sortByDateCreated); |
| 331 |
sortMenuManager.add(new Separator()); |
| 332 |
sortMenuManager.add(sortDirection); |
| 258 |
|
333 |
|
| 259 |
sortByPriorityAction.setChecked(currentSortOrder == sortByPriorityAction.getSortOrder()); |
334 |
sortByPriorityAction.setChecked(currentSortOrder == sortByPriorityAction.getSortOrder()); |
| 260 |
sortByDescriptionAction.setChecked(currentSortOrder == sortByDescriptionAction.getSortOrder()); |
335 |
sortByDescriptionAction.setChecked(currentSortOrder == sortByDescriptionAction.getSortOrder()); |
|
|
336 |
sortByDateCreated.setChecked(currentSortOrder == sortByDateCreated.getSortOrder()); |
| 337 |
sortDirection.setChecked(getSortDirection() < 0); |
| 338 |
|
| 339 |
MenuManager sortMenuManager2 = new MenuManager("Then Sort by"); |
| 340 |
sortMenuManager2.add(sortByPriorityAction2); |
| 341 |
sortMenuManager2.add(sortByDescriptionAction2); |
| 342 |
sortMenuManager2.add(sortByDateCreated2); |
| 343 |
sortMenuManager2.add(new Separator()); |
| 344 |
sortMenuManager2.add(sortDirection2); |
| 345 |
|
| 346 |
sortByPriorityAction2.setChecked(currentSortOrder2 == sortByPriorityAction2.getSortOrder()); |
| 347 |
sortByDescriptionAction2.setChecked(currentSortOrder2 == sortByDescriptionAction2.getSortOrder()); |
| 348 |
sortByDateCreated2.setChecked(currentSortOrder2 == sortByDateCreated2.getSortOrder()); |
| 349 |
sortDirection2.setChecked(getSortDirection2() < 0); |
| 261 |
|
350 |
|
| 262 |
// Add the new context menu items |
351 |
// Add the new context menu items |
| 263 |
menuManager.appendToGroup(IContextMenuConstants.GROUP_VIEWER_SETUP, sortMenuManager); |
352 |
menuManager.appendToGroup(IContextMenuConstants.GROUP_VIEWER_SETUP, sortMenuManager); |
|
|
353 |
menuManager.appendToGroup(IContextMenuConstants.GROUP_VIEWER_SETUP, sortMenuManager2); |
| 264 |
menuManager.appendToGroup(IContextMenuConstants.GROUP_VIEWER_SETUP, groupByAction); |
354 |
menuManager.appendToGroup(IContextMenuConstants.GROUP_VIEWER_SETUP, groupByAction); |
| 265 |
|
355 |
|
| 266 |
menuManager.appendToGroup(IContextMenuConstants.GROUP_OPEN, openInEditorAction); |
356 |
menuManager.appendToGroup(IContextMenuConstants.GROUP_OPEN, openInEditorAction); |
|
Lines 309-312
Link Here
|
| 309 |
} |
399 |
} |
| 310 |
} |
400 |
} |
| 311 |
|
401 |
|
| 312 |
} |
402 |
} |