|
Lines 41-46
Link Here
|
| 41 |
import org.eclipse.mylyn.internal.tasks.ui.actions.OpenTaskSearchAction; |
41 |
import org.eclipse.mylyn.internal.tasks.ui.actions.OpenTaskSearchAction; |
| 42 |
import org.eclipse.mylyn.internal.tasks.ui.actions.OpenWithBrowserAction; |
42 |
import org.eclipse.mylyn.internal.tasks.ui.actions.OpenWithBrowserAction; |
| 43 |
import org.eclipse.mylyn.internal.tasks.ui.search.SearchResultTreeContentProvider.GroupBy; |
43 |
import org.eclipse.mylyn.internal.tasks.ui.search.SearchResultTreeContentProvider.GroupBy; |
|
|
44 |
import org.eclipse.mylyn.internal.tasks.ui.util.TaskComparator; |
| 44 |
import org.eclipse.mylyn.internal.tasks.ui.util.TasksUiInternal; |
45 |
import org.eclipse.mylyn.internal.tasks.ui.util.TasksUiInternal; |
| 45 |
import org.eclipse.mylyn.internal.tasks.ui.views.TaskListToolTip; |
46 |
import org.eclipse.mylyn.internal.tasks.ui.views.TaskListToolTip; |
| 46 |
import org.eclipse.mylyn.internal.tasks.ui.views.TaskListView; |
47 |
import org.eclipse.mylyn.internal.tasks.ui.views.TaskListView; |
|
Lines 129-155
Link Here
|
| 129 |
} |
130 |
} |
| 130 |
} |
131 |
} |
| 131 |
|
132 |
|
| 132 |
public static final int ORDER_PRIORITY = 1; |
|
|
| 133 |
|
| 134 |
public static final int ORDER_DESCRIPTION = 2; |
| 135 |
|
| 136 |
public static final int ORDER_SEVERITY = 3; |
| 137 |
|
| 138 |
public static final int ORDER_STATUS = 4; |
| 139 |
|
| 140 |
public static final int ORDER_ID = 5; |
| 141 |
|
| 142 |
public static final int ORDER_DEFAULT = ORDER_PRIORITY; |
| 143 |
|
| 144 |
private static final String KEY_SORTING = TasksUiPlugin.ID_PLUGIN + ".search.resultpage.sorting"; //$NON-NLS-1$ |
133 |
private static final String KEY_SORTING = TasksUiPlugin.ID_PLUGIN + ".search.resultpage.sorting"; //$NON-NLS-1$ |
| 145 |
|
134 |
|
| 146 |
private SearchResultContentProvider searchResultProvider; |
135 |
private static final String KEY_SORTING2 = TasksUiPlugin.ID_PLUGIN + ".search.resultpage.sorting2"; //$NON-NLS-1$ |
| 147 |
|
136 |
|
| 148 |
private int currentSortOrder; |
137 |
private static final String KEY_SORTINGDIRECTION = TasksUiPlugin.ID_PLUGIN + ".search.resultpage.sortingdirection"; //$NON-NLS-1$ |
| 149 |
|
138 |
|
| 150 |
private final SearchResultSortAction sortByPriorityAction; |
139 |
private static final String KEY_SORTINGDIRECTION2 = TasksUiPlugin.ID_PLUGIN |
|
|
140 |
+ ".search.resultpage.sortingdirection2"; //$NON-NLS-1$ |
| 151 |
|
141 |
|
| 152 |
private final SearchResultSortAction sortByDescriptionAction; |
142 |
private SearchResultContentProvider searchResultProvider; |
| 153 |
|
143 |
|
| 154 |
private final OpenSearchResultAction openInEditorAction; |
144 |
private final OpenSearchResultAction openInEditorAction; |
| 155 |
|
145 |
|
|
Lines 167-172
Link Here
|
| 167 |
|
157 |
|
| 168 |
private final OpenWithBrowserAction openSearchWithBrowserAction; |
158 |
private final OpenWithBrowserAction openSearchWithBrowserAction; |
| 169 |
|
159 |
|
|
|
160 |
private SearchResultSorter searchResultSorter; |
| 161 |
|
| 162 |
private SearchResultSortAction sortByDialogAction; |
| 163 |
|
| 170 |
private static final IShowInTargetList SHOW_IN_TARGET_LIST = new IShowInTargetList() { |
164 |
private static final IShowInTargetList SHOW_IN_TARGET_LIST = new IShowInTargetList() { |
| 171 |
public String[] getShowInTargetIds() { |
165 |
public String[] getShowInTargetIds() { |
| 172 |
return SHOW_IN_TARGETS; |
166 |
return SHOW_IN_TARGETS; |
|
Lines 177-188
Link Here
|
| 177 |
// Only use the table layout. |
171 |
// Only use the table layout. |
| 178 |
super(FLAG_LAYOUT_TREE); |
172 |
super(FLAG_LAYOUT_TREE); |
| 179 |
|
173 |
|
| 180 |
sortByPriorityAction = new SearchResultSortAction(Messages.RepositorySearchResultView_Task_Priority, this, |
|
|
| 181 |
ORDER_PRIORITY); |
| 182 |
sortByDescriptionAction = new SearchResultSortAction(Messages.RepositorySearchResultView_Task_Summary, this, |
| 183 |
ORDER_DESCRIPTION); |
| 184 |
currentSortOrder = ORDER_DEFAULT; |
| 185 |
|
| 186 |
openInEditorAction = new OpenSearchResultAction(Messages.RepositorySearchResultView_Open_in_Editor, this); |
174 |
openInEditorAction = new OpenSearchResultAction(Messages.RepositorySearchResultView_Open_in_Editor, this); |
| 187 |
createQueryAction = new CreateQueryFromSearchAction( |
175 |
createQueryAction = new CreateQueryFromSearchAction( |
| 188 |
Messages.RepositorySearchResultView_Create_Query_from_Search_, this); |
176 |
Messages.RepositorySearchResultView_Create_Query_from_Search_, this); |
|
Lines 193-199
Link Here
|
| 193 |
|
181 |
|
| 194 |
groupingActions = new ArrayList<GroupingAction>(); |
182 |
groupingActions = new ArrayList<GroupingAction>(); |
| 195 |
new GroupingAction(Messages.RepositorySearchResultView_Group_By_Owner, GroupBy.OWNER); |
183 |
new GroupingAction(Messages.RepositorySearchResultView_Group_By_Owner, GroupBy.OWNER); |
| 196 |
//new GroupingAction("Group By Complete", GroupBy.COMPLETION); |
184 |
// new GroupingAction(Messages.RepositorySearchResultView_Group_By_Complete, GroupBy.COMPLETION); |
| 197 |
|
185 |
|
| 198 |
filterActions = new ArrayList<FilteringAction>(); |
186 |
filterActions = new ArrayList<FilteringAction>(); |
| 199 |
new FilteringAction(Messages.RepositorySearchResultView_Filter_Completed_Tasks, new ViewerFilter() { |
187 |
new FilteringAction(Messages.RepositorySearchResultView_Filter_Completed_Tasks, new ViewerFilter() { |
|
Lines 241-251
Link Here
|
| 241 |
DecoratingLabelProvider labelProvider = new DecoratingLabelProvider(new SearchResultsLabelProvider( |
229 |
DecoratingLabelProvider labelProvider = new DecoratingLabelProvider(new SearchResultsLabelProvider( |
| 242 |
searchResultProvider, viewer), PlatformUI.getWorkbench().getDecoratorManager().getLabelDecorator()); |
230 |
searchResultProvider, viewer), PlatformUI.getWorkbench().getDecoratorManager().getLabelDecorator()); |
| 243 |
viewer.setLabelProvider(labelProvider); |
231 |
viewer.setLabelProvider(labelProvider); |
|
|
232 |
searchResultSorter = new SearchResultSorter(this); |
| 233 |
viewer.setSorter(searchResultSorter); |
| 234 |
sortByDialogAction = new SearchResultSortAction(getSite(), searchResultSorter); |
| 244 |
|
235 |
|
| 245 |
// Set the order when the search view is loading so that the items are |
236 |
// Set the order when the search view is loading so that the items are |
| 246 |
// sorted right away |
237 |
// sorted right away |
| 247 |
setSortOrder(currentSortOrder); |
238 |
restoreCurrentSortOrder2Preference(); |
| 248 |
|
|
|
| 249 |
toolTip = new TaskListToolTip(viewer.getControl()); |
239 |
toolTip = new TaskListToolTip(viewer.getControl()); |
| 250 |
} |
240 |
} |
| 251 |
|
241 |
|
|
Lines 318-353
Link Here
|
| 318 |
super.dispose(); |
308 |
super.dispose(); |
| 319 |
} |
309 |
} |
| 320 |
|
310 |
|
| 321 |
/** |
|
|
| 322 |
* Sets the new sorting category, and reorders all of the tasks. |
| 323 |
* |
| 324 |
* @param sortOrder |
| 325 |
* The new category to sort by |
| 326 |
*/ |
| 327 |
public void setSortOrder(int sortOrder) { |
| 328 |
StructuredViewer viewer = getViewer(); |
| 329 |
|
| 330 |
switch (sortOrder) { |
| 331 |
case ORDER_ID: |
| 332 |
viewer.setSorter(new SearchResultSorterId()); |
| 333 |
break; |
| 334 |
case ORDER_DESCRIPTION: |
| 335 |
viewer.setSorter(new SearchResultSorter()); |
| 336 |
break; |
| 337 |
case ORDER_PRIORITY: |
| 338 |
viewer.setSorter(new SearchResultSorterPriority()); |
| 339 |
break; |
| 340 |
default: |
| 341 |
// If the setting is not one of the four valid ones, |
| 342 |
// use the default order setting. |
| 343 |
sortOrder = ORDER_DEFAULT; |
| 344 |
viewer.setSorter(new SearchResultSorterPriority()); |
| 345 |
break; |
| 346 |
} |
| 347 |
currentSortOrder = sortOrder; |
| 348 |
getSettings().put(KEY_SORTING, currentSortOrder); |
| 349 |
} |
| 350 |
|
| 351 |
@SuppressWarnings("unchecked") |
311 |
@SuppressWarnings("unchecked") |
| 352 |
public Object getAdapter(Class adapter) { |
312 |
public Object getAdapter(Class adapter) { |
| 353 |
return getAdapterDelegate(adapter); |
313 |
return getAdapterDelegate(adapter); |
|
Lines 372-378
Link Here
|
| 372 |
super.fillContextMenu(menuManager); |
332 |
super.fillContextMenu(menuManager); |
| 373 |
|
333 |
|
| 374 |
// open actions |
334 |
// open actions |
| 375 |
|
|
|
| 376 |
menuManager.appendToGroup(IContextMenuConstants.GROUP_OPEN, openInEditorAction); |
335 |
menuManager.appendToGroup(IContextMenuConstants.GROUP_OPEN, openInEditorAction); |
| 377 |
|
336 |
|
| 378 |
// Add to Task List menu |
337 |
// Add to Task List menu |
|
Lines 404-419
Link Here
|
| 404 |
menuManager.appendToGroup(IContextMenuConstants.GROUP_SEARCH, refineSearchAction); |
363 |
menuManager.appendToGroup(IContextMenuConstants.GROUP_SEARCH, refineSearchAction); |
| 405 |
menuManager.appendToGroup(IContextMenuConstants.GROUP_SEARCH, openSearchWithBrowserAction); |
364 |
menuManager.appendToGroup(IContextMenuConstants.GROUP_SEARCH, openSearchWithBrowserAction); |
| 406 |
|
365 |
|
| 407 |
// sort actions |
366 |
menuManager.appendToGroup(IContextMenuConstants.GROUP_VIEWER_SETUP, sortByDialogAction); |
| 408 |
|
|
|
| 409 |
MenuManager sortMenuManager = new MenuManager(Messages.RepositorySearchResultView_Sort_by); |
| 410 |
sortMenuManager.add(sortByPriorityAction); |
| 411 |
sortMenuManager.add(sortByDescriptionAction); |
| 412 |
|
| 413 |
sortByPriorityAction.setChecked(currentSortOrder == sortByPriorityAction.getSortOrder()); |
| 414 |
sortByDescriptionAction.setChecked(currentSortOrder == sortByDescriptionAction.getSortOrder()); |
| 415 |
|
| 416 |
menuManager.appendToGroup(IContextMenuConstants.GROUP_VIEWER_SETUP, sortMenuManager); |
| 417 |
for (Action action : groupingActions) { |
367 |
for (Action action : groupingActions) { |
| 418 |
menuManager.appendToGroup(IContextMenuConstants.GROUP_VIEWER_SETUP, action); |
368 |
menuManager.appendToGroup(IContextMenuConstants.GROUP_VIEWER_SETUP, action); |
| 419 |
} |
369 |
} |
|
Lines 468-471
Link Here
|
| 468 |
} |
418 |
} |
| 469 |
} |
419 |
} |
| 470 |
|
420 |
|
|
|
421 |
public void restoreCurrentSortOrder2Preference() { |
| 422 |
int restoredSortIndex = 0; |
| 423 |
int restoredSortDirection = 1; |
| 424 |
int restoredSortIndex2 = 2; |
| 425 |
int restoredSortDirection2 = 1; |
| 426 |
String preferenceString = getSettings().get(KEY_SORTING); |
| 427 |
|
| 428 |
if (preferenceString != null) { |
| 429 |
try { |
| 430 |
restoredSortIndex = Integer.parseInt(preferenceString); |
| 431 |
} catch (NumberFormatException e) { |
| 432 |
restoredSortIndex = 0; |
| 433 |
} |
| 434 |
} |
| 435 |
preferenceString = getSettings().get(KEY_SORTINGDIRECTION); |
| 436 |
if (preferenceString != null) { |
| 437 |
try { |
| 438 |
restoredSortDirection = Integer.parseInt(preferenceString); |
| 439 |
} catch (NumberFormatException e) { |
| 440 |
restoredSortDirection = 1; |
| 441 |
} |
| 442 |
} |
| 443 |
preferenceString = getSettings().get(KEY_SORTING2); |
| 444 |
if (preferenceString != null) { |
| 445 |
try { |
| 446 |
restoredSortIndex2 = Integer.parseInt(preferenceString); |
| 447 |
} catch (NumberFormatException e) { |
| 448 |
restoredSortIndex2 = 2; |
| 449 |
} |
| 450 |
} |
| 451 |
preferenceString = getSettings().get(KEY_SORTINGDIRECTION2); |
| 452 |
if (preferenceString != null) { |
| 453 |
try { |
| 454 |
restoredSortDirection2 = Integer.parseInt(preferenceString); |
| 455 |
} catch (NumberFormatException e) { |
| 456 |
restoredSortDirection2 = 1; |
| 457 |
} |
| 458 |
} |
| 459 |
|
| 460 |
switch (restoredSortIndex) { |
| 461 |
case 1: |
| 462 |
searchResultSorter.setSortByIndex(TaskComparator.SortByIndex.SUMMARY); |
| 463 |
break; |
| 464 |
case 2: |
| 465 |
searchResultSorter.setSortByIndex(TaskComparator.SortByIndex.DATE_CREATED); |
| 466 |
break; |
| 467 |
case 3: |
| 468 |
searchResultSorter.setSortByIndex(TaskComparator.SortByIndex.TASK_ID); |
| 469 |
break; |
| 470 |
default: |
| 471 |
searchResultSorter.setSortByIndex(TaskComparator.SortByIndex.PRIORITY); |
| 472 |
} |
| 473 |
|
| 474 |
searchResultSorter.setSortDirection(restoredSortDirection2); |
| 475 |
switch (restoredSortIndex2) { |
| 476 |
case 1: |
| 477 |
searchResultSorter.setSortByIndex2(TaskComparator.SortByIndex.SUMMARY); |
| 478 |
break; |
| 479 |
case 2: |
| 480 |
searchResultSorter.setSortByIndex2(TaskComparator.SortByIndex.DATE_CREATED); |
| 481 |
break; |
| 482 |
case 3: |
| 483 |
searchResultSorter.setSortByIndex2(TaskComparator.SortByIndex.TASK_ID); |
| 484 |
break; |
| 485 |
default: |
| 486 |
searchResultSorter.setSortByIndex2(TaskComparator.SortByIndex.PRIORITY); |
| 487 |
} |
| 488 |
searchResultSorter.setSortDirection(restoredSortDirection); |
| 489 |
searchResultSorter.setSortDirection2(restoredSortDirection2); |
| 490 |
} |
| 491 |
|
| 492 |
public void setCurrentSortOrder2Preference() { |
| 493 |
getSettings().put(KEY_SORTINGDIRECTION, searchResultSorter.getSortDirection()); |
| 494 |
switch (searchResultSorter.getSortByIndex()) { |
| 495 |
case SUMMARY: |
| 496 |
getSettings().put(KEY_SORTING, 1); |
| 497 |
break; |
| 498 |
case DATE_CREATED: |
| 499 |
getSettings().put(KEY_SORTING, 2); |
| 500 |
break; |
| 501 |
case TASK_ID: |
| 502 |
getSettings().put(KEY_SORTING, 3); |
| 503 |
break; |
| 504 |
default: |
| 505 |
getSettings().put(KEY_SORTING, 0); |
| 506 |
} |
| 507 |
|
| 508 |
getSettings().put(KEY_SORTINGDIRECTION2, searchResultSorter.getSortDirection2()); |
| 509 |
switch (searchResultSorter.getSortByIndex2()) { |
| 510 |
case SUMMARY: |
| 511 |
getSettings().put(KEY_SORTING2, 1); |
| 512 |
break; |
| 513 |
case DATE_CREATED: |
| 514 |
getSettings().put(KEY_SORTING2, 2); |
| 515 |
break; |
| 516 |
case TASK_ID: |
| 517 |
getSettings().put(KEY_SORTING2, 3); |
| 518 |
break; |
| 519 |
default: |
| 520 |
getSettings().put(KEY_SORTING2, 0); |
| 521 |
} |
| 522 |
} |
| 471 |
} |
523 |
} |