diff options
author | spingel | 2009-01-09 23:52:44 +0000 |
---|---|---|
committer | spingel | 2009-01-09 23:52:44 +0000 |
commit | 41d012e3c9d705b43b66c2cf7b607fff76ee4164 (patch) | |
tree | 2a3b9b42cbae7b7d7fcc03f4d1ec6bf13b7b4597 | |
parent | 792afd23e21383085253d79b83e44545a011eac2 (diff) | |
download | org.eclipse.mylyn.tasks-41d012e3c9d705b43b66c2cf7b607fff76ee4164.tar.gz org.eclipse.mylyn.tasks-41d012e3c9d705b43b66c2cf7b607fff76ee4164.tar.xz org.eclipse.mylyn.tasks-41d012e3c9d705b43b66c2cf7b607fff76ee4164.zip |
ASSIGNED - bug 231336: Task List toggling sort by descending/ascending has no effect if sort option is date created
https://bugs.eclipse.org/bugs/show_bug.cgi?id=231336
19 files changed, 679 insertions, 601 deletions
diff --git a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TableSorterTest.java b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TableSorterTest.java index da9693ed3..12d3bca7d 100644 --- a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TableSorterTest.java +++ b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TableSorterTest.java @@ -13,21 +13,29 @@ package org.eclipse.mylyn.tasks.tests; import java.util.Calendar; +import java.util.Date; import junit.framework.TestCase; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.Viewer; +import org.eclipse.mylyn.internal.tasks.core.AbstractTask; +import org.eclipse.mylyn.internal.tasks.core.AbstractTaskContainer; import org.eclipse.mylyn.internal.tasks.core.DateRange; import org.eclipse.mylyn.internal.tasks.core.LocalTask; +import org.eclipse.mylyn.internal.tasks.core.RepositoryQuery; import org.eclipse.mylyn.internal.tasks.core.TaskActivityUtil; import org.eclipse.mylyn.internal.tasks.core.TaskCategory; +import org.eclipse.mylyn.internal.tasks.core.TaskGroup; +import org.eclipse.mylyn.internal.tasks.core.UncategorizedTaskContainer; +import org.eclipse.mylyn.internal.tasks.core.UnmatchedTaskContainer; +import org.eclipse.mylyn.internal.tasks.core.UnsubmittedTaskContainer; import org.eclipse.mylyn.internal.tasks.core.WeekDateRange; import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin; +import org.eclipse.mylyn.internal.tasks.ui.util.TaskComparator; import org.eclipse.mylyn.internal.tasks.ui.views.TaskListInterestSorter; import org.eclipse.mylyn.internal.tasks.ui.views.TaskListTableSorter; import org.eclipse.mylyn.internal.tasks.ui.views.TaskListView; -import org.eclipse.mylyn.internal.tasks.ui.views.TaskListTableSorter.SortByIndex; import org.eclipse.mylyn.tasks.core.ITask; import org.eclipse.mylyn.tasks.tests.connector.MockTask; import org.eclipse.swt.widgets.Control; @@ -35,18 +43,54 @@ import org.eclipse.swt.widgets.Control; /** * @author Mik Kersten * @author George Lindholm + * @author Frank Becker */ public class TableSorterTest extends TestCase { public void testRootTaskSorting() { TaskListTableSorter sorter = new TaskListTableSorter(TaskListView.getFromActivePerspective(), - TaskListTableSorter.SortByIndex.SUMMARY); + TaskComparator.SortByIndex.SUMMARY); - ITask task = new LocalTask("1", ""); + AbstractTask task = new LocalTask("1", ""); + UncategorizedTaskContainer uncategorizedTaskContainer = new UncategorizedTaskContainer(); + UnsubmittedTaskContainer unsubmittedTaskContainer = new UnsubmittedTaskContainer("connectorKind", + "repositoryUrl"); TaskCategory category = new TaskCategory("cat"); + RepositoryQuery repositoryQuery = new RepositoryQuery("connectorKind", "queryName"); + TaskGroup taskGroup = new TaskGroup("parentHandle", "summary", "groupBy"); + UnmatchedTaskContainer unmatchedTaskContainer = new UnmatchedTaskContainer("connectorKind", "repositoryUrl"); + + checkToRootElements(sorter, uncategorizedTaskContainer, unsubmittedTaskContainer); + checkToRootElements(sorter, uncategorizedTaskContainer, category); + checkToRootElements(sorter, uncategorizedTaskContainer, repositoryQuery); + checkToRootElements(sorter, uncategorizedTaskContainer, taskGroup); + checkToRootElements(sorter, uncategorizedTaskContainer, unmatchedTaskContainer); + + checkToRootElements(sorter, unsubmittedTaskContainer, category); + checkToRootElements(sorter, unsubmittedTaskContainer, repositoryQuery); + checkToRootElements(sorter, unsubmittedTaskContainer, taskGroup); + checkToRootElements(sorter, unsubmittedTaskContainer, unmatchedTaskContainer); + + checkToRootElements(sorter, category, repositoryQuery); + checkToRootElements(sorter, category, taskGroup); + checkToRootElements(sorter, category, unmatchedTaskContainer); + + checkToRootElements(sorter, repositoryQuery, taskGroup); + checkToRootElements(sorter, repositoryQuery, unmatchedTaskContainer); + + checkToRootElements(sorter, taskGroup, unmatchedTaskContainer); + + checkToRootElements(sorter, task, uncategorizedTaskContainer); + checkToRootElements(sorter, task, unsubmittedTaskContainer); + checkToRootElements(sorter, task, category); + checkToRootElements(sorter, task, repositoryQuery); + checkToRootElements(sorter, task, taskGroup); + checkToRootElements(sorter, task, unmatchedTaskContainer); + } - assertEquals(-1, sorter.compare(null, task, category)); - assertEquals(1, sorter.compare(null, category, task)); + private void checkToRootElements(TaskListTableSorter sorter, AbstractTaskContainer e1, AbstractTaskContainer e2) { + assertEquals(-1, sorter.compare(null, e1, e2)); + assertEquals(1, sorter.compare(null, e2, e1)); } public class EmptyViewer extends Viewer { @@ -112,17 +156,25 @@ public class TableSorterTest extends TestCase { tasks[3] = new MockTask("local", "11", "d"); tasks[4] = new MockTask("local", "3", "c"); tasks[5] = new MockTask("local", "5", "a"); + Date start = new Date(); + tasks[5].setCreationDate(start); + tasks[4].setCreationDate(new Date(start.getTime() - 1)); + tasks[3].setCreationDate(new Date(start.getTime() - 2)); + tasks[2].setCreationDate(new Date(start.getTime() - 3)); + tasks[1].setCreationDate(new Date(start.getTime() - 4)); + tasks[0].setCreationDate(new Date(start.getTime() - 5)); TaskListTableSorter sorter = new TaskListTableSorter(TaskListView.getFromActivePerspective()); - sorter.setSortByIndex(SortByIndex.SUMMARY); + sorter.setSortByIndex(TaskComparator.SortByIndex.SUMMARY); + sorter.setSortByIndex2(TaskComparator.SortByIndex.DATE_CREATED); sorter.sort(new EmptyViewer(), tasks); - assertEquals("1", tasks[0].getTaskKey()); - assertEquals("3", tasks[1].getTaskKey()); - assertEquals("4", tasks[2].getTaskKey()); - assertEquals("5", tasks[3].getTaskKey()); - assertEquals("11", tasks[4].getTaskKey()); - assertEquals("a", tasks[4].getSummary()); + assertEquals("11", tasks[0].getTaskKey()); + assertEquals("a", tasks[0].getSummary()); + assertEquals("5", tasks[1].getTaskKey()); + assertEquals("1", tasks[2].getTaskKey()); + assertEquals("4", tasks[3].getTaskKey()); + assertEquals("3", tasks[4].getTaskKey()); assertEquals("11", tasks[5].getTaskKey()); assertEquals("d", tasks[5].getSummary()); } @@ -134,18 +186,25 @@ public class TableSorterTest extends TestCase { tasks[2] = new MockTask("local", "MYLN:11", "a"); tasks[3] = new MockTask("local", "MYLN:11", "b"); tasks[4] = new MockTask("local", "MYLN:5", "a"); + Date start = new Date(); + tasks[4].setCreationDate(start); + tasks[3].setCreationDate(new Date(start.getTime() - 1)); + tasks[2].setCreationDate(new Date(start.getTime() - 2)); + tasks[1].setCreationDate(new Date(start.getTime() - 3)); + tasks[0].setCreationDate(new Date(start.getTime() - 4)); TaskListTableSorter sorter = new TaskListTableSorter(TaskListView.getFromActivePerspective()); - sorter.setSortByIndex(SortByIndex.SUMMARY); + sorter.setSortByIndex(TaskComparator.SortByIndex.SUMMARY); + sorter.setSortByIndex2(TaskComparator.SortByIndex.DATE_CREATED); sorter.sort(new EmptyViewer(), tasks); - assertEquals("MYLN:1", tasks[0].getTaskKey()); - assertEquals("MYLN:4", tasks[1].getTaskKey()); - assertEquals("MYLN:5", tasks[2].getTaskKey()); + assertEquals("MYLN:11", tasks[0].getTaskKey()); + assertEquals("a", tasks[0].getSummary()); + assertEquals("MYLN:5", tasks[1].getTaskKey()); + assertEquals("MYLN:1", tasks[2].getTaskKey()); assertEquals("MYLN:11", tasks[3].getTaskKey()); - assertEquals("a", tasks[3].getSummary()); - assertEquals("MYLN:11", tasks[4].getTaskKey()); - assertEquals("b", tasks[4].getSummary()); + assertEquals("b", tasks[3].getSummary()); + assertEquals("MYLN:4", tasks[4].getTaskKey()); } public void testLocalTaskSort() { @@ -154,6 +213,10 @@ public class TableSorterTest extends TestCase { ITask task2 = new LocalTask("2", "task2"); ITask task3 = new LocalTask("3", "task3"); ITask[] tasks = { task1, task2, task3 }; + Date start = new Date(); + task3.setCreationDate(start); + task2.setCreationDate(new Date(start.getTime() - 1)); + task1.setCreationDate(new Date(start.getTime() - 2)); sorter.sort(new EmptyViewer(), tasks); } diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/actions/Messages.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/actions/Messages.java index 0c25a90b6..73749bc73 100644 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/actions/Messages.java +++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/actions/Messages.java @@ -37,22 +37,10 @@ public class Messages extends NLS { public static String AddRepositoryAction_Add_a_query_to_the_Task_List; - public static String AddRepositoryAction_Add_Repository_Query; - public static String AddRepositoryAction_Add_Task_Repository; public static String AddRepositoryAction_Do_not_show_again; - public static String AddRepositoryTaskAction_Add_an_existing_repository_task_issue; - - public static String AttachAction_Attach_; - - public static String AttachAction_Submit_changes_or_synchronize_task_before_adding_attachments; - - public static String AttachScreenshotAction_Attach_Screenshot_; - - public static String AttachScreenshotAction_Submit_changes_or_synchronize_task_before_adding_attachments; - public static String ClearOutgoingAction_Clear_outgoing; public static String ClearOutgoingAction_Clear_outgoing_failed; @@ -115,8 +103,6 @@ public class Messages extends NLS { public static String ExpandAllAction_Expand_All; - public static String FilterArchiveContainerAction_Filter_Archives; - public static String FilterCompletedTasksAction_Filter_Completed_Tasks; public static String GoIntoAction_Go_Into; @@ -127,18 +113,6 @@ public class Messages extends NLS { public static String LinkWithEditorAction_Link_with_Editor; - public static String MarkTaskCompleteAction_Complete; - - public static String MarkTaskCompleteAction_Confirm_Mark_Completed; - - public static String MarkTaskCompleteAction_Mark_; - - public static String MarkTaskIncompleteAction_Confirm_Mark_Incompleted; - - public static String MarkTaskIncompleteAction_Incomplete; - - public static String MarkTaskIncompleteAction_Mark_; - public static String NewCategoryAction_A_category_with_this_name_already_exists; public static String NewCategoryAction_Enter_name; @@ -151,8 +125,6 @@ public class Messages extends NLS { public static String NewCategoryAction_A_query_with_this_name_already_exists; - public static String NewQueryAction_Add_or_modify_repository_query; - public static String NewSubTaskAction_The_connector_does_not_support_creating_subtasks_for_this_task; public static String NewSubTaskAction_Could_not_initialize_sub_task_data_for_task_; @@ -171,8 +143,6 @@ public class Messages extends NLS { public static String NewTaskFromSelectionAction____Created_from_Comment___; - public static String NewTaskFromSelectionAction____Created_from_Task___; - public static String NewTaskFromSelectionAction_New_Task_from_Selection; public static String NewTaskFromSelectionAction_Nothing_selected_to_create_task_from; @@ -235,8 +205,6 @@ public class Messages extends NLS { public static String RenameAction_Rename; - public static String RestoreTaskListAction_Restore_Tasks_from_History; - public static String ShowInTaskListAction_Show_In_Task_List; public static String SynchronizeAutomaticallyAction_Synchronize_Automatically; @@ -289,8 +257,6 @@ public class Messages extends NLS { public static String TaskSelectionDialog_Show_Completed_Tasks; - public static String TasksUiPlugin_Task_Repositories; - public static String TaskWorkingSetAction_All; public static String TaskWorkingSetAction_Deselect_All; diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/actions/messages.properties b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/actions/messages.properties index 1cd9e7a7b..735be24f8 100644 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/actions/messages.properties +++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/actions/messages.properties @@ -7,18 +7,9 @@ ActivateTaskHistoryDropDownAction_Activate_Previous_Task=Activate Previous Task AddRepositoryAction_Add_new_query=Add new query AddRepositoryAction_Add_a_query_to_the_Task_List=Would you like to add a query to the Task List for this repository? -AddRepositoryAction_Add_Repository_Query=Add Repository Query AddRepositoryAction_Add_Task_Repository=Add Task Repository AddRepositoryAction_Do_not_show_again=Do not show again -AddRepositoryTaskAction_Add_an_existing_repository_task_issue=Add an existing repository task/issue - -AttachAction_Attach_=Attach... -AttachAction_Submit_changes_or_synchronize_task_before_adding_attachments=Submit changes or synchronize task before adding attachments. - -AttachScreenshotAction_Attach_Screenshot_=Attach Screenshot... -AttachScreenshotAction_Submit_changes_or_synchronize_task_before_adding_attachments=Submit changes or synchronize task before adding attachments. - ClearOutgoingAction_Clear_outgoing=Clear outgoing ClearOutgoingAction_Clear_outgoing_failed=Clear outgoing failed ClearOutgoingAction_Confirm_discard=Confirm discard @@ -59,8 +50,6 @@ EditRepositoryPropertiesAction_Properties=Properties ExpandAllAction_Expand_All=Expand All -FilterArchiveContainerAction_Filter_Archives=Filter Archives - FilterCompletedTasksAction_Filter_Completed_Tasks=Filter Completed Tasks GoIntoAction_Go_Into=Go Into @@ -71,14 +60,6 @@ GroupSubTasksAction_Group_Subtasks=Group Subtasks LinkWithEditorAction_Link_with_Editor=&Link with Editor -MarkTaskCompleteAction_Complete=Complete -MarkTaskCompleteAction_Confirm_Mark_Completed=Confirm Mark Completed -MarkTaskCompleteAction_Mark_=Mark\ - -MarkTaskIncompleteAction_Confirm_Mark_Incompleted=Confirm Mark Incompleted -MarkTaskIncompleteAction_Incomplete=Incomplete -MarkTaskIncompleteAction_Mark_=Mark\ - NewCategoryAction_A_category_with_this_name_already_exists=A category with this name already exists, please choose another name. NewCategoryAction_Enter_name=Enter name NewCategoryAction_Enter_a_name_for_the_Category=Enter a name for the Category\:\ @@ -86,8 +67,6 @@ NewCategoryAction_New_Category=New Category NewCategoryAction_New_Category_=New Category... NewCategoryAction_A_query_with_this_name_already_exists=A query with this name already exists, please choose another name. -NewQueryAction_Add_or_modify_repository_query=Add or modify repository query - NewSubTaskAction_The_connector_does_not_support_creating_subtasks_for_this_task=The connector does not support creating subtasks for this task NewSubTaskAction_Could_not_initialize_sub_task_data_for_task_=Could not initialize sub task data for task\:\ NewSubTaskAction_Could_not_retrieve_task_data_for_task_=Could not retrieve task data for task: @@ -98,7 +77,6 @@ NewSubTaskAction_Unable_to_create_subtask=Unable to create subtask NewTaskFromSelectionAction_Comment_=Comment\:\ NewTaskFromSelectionAction____Created_from_Comment___=-- Created from Comment -- -NewTaskFromSelectionAction____Created_from_Task___=-- Created from Task -- NewTaskFromSelectionAction_New_Task_from_Selection=New Task from Selection NewTaskFromSelectionAction_Nothing_selected_to_create_task_from=Nothing selected to create task from. NewTaskFromSelectionAction_URL_=URL\:\ @@ -143,8 +121,6 @@ RemoveFromCategoryAction_Remove_From_Category=Remove From Category RenameAction_Rename=Rename -RestoreTaskListAction_Restore_Tasks_from_History=Restore Tasks from History - ShowInTaskListAction_Show_In_Task_List=&Show In Task List SynchronizeAutomaticallyAction_Synchronize_Automatically=Synchronize Automatically @@ -181,7 +157,6 @@ TaskSelectionDialog_Select_Working_Set_=Select &Working Set... TaskSelectionDialog_Selected_item_is_not_a_task=Selected item is not a task TaskSelectionDialog_Show_Completed_Tasks=Show &Completed Tasks -TasksUiPlugin_Task_Repositories=Task Repositories TaskWorkingSetAction_All=All TaskWorkingSetAction_Deselect_All=Deselect All TaskWorkingSetAction_Edit_Label=&Edit... diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/dialogs/Messages.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/dialogs/Messages.java index eda40ecfd..01a2c9dd6 100644 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/dialogs/Messages.java +++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/dialogs/Messages.java @@ -25,20 +25,26 @@ public class Messages extends NLS { NLS.initializeMessages(BUNDLE_NAME, Messages.class); } - public static String TaskListSortDialog_Ascending; + public static String TaskCompareDialog_Ascending; - public static String TaskListSortDialog_Date_Created; + public static String TaskCompareDialog_DateCreated; - public static String TaskListSortDialog_Descending; + public static String TaskCompareDialog_Descending; - public static String TaskListSortDialog_Priority; + public static String TaskCompareDialog_Priority; + + public static String TaskCompareDialog_Sorting; + + public static String TaskCompareDialog_SortOrder; + + public static String TaskCompareDialog_Summary; + + public static String TaskCompareDialog_TaskID; public static String TaskListSortDialog_Sort_order; public static String TaskListSortDialog_Sorting; - public static String TaskListSortDialog_Summary; - public static String TaskRepositoryCredentialsDialog_Enter_Credentials; public static String TaskRepositoryCredentialsDialog_Enter_repository_credentials; diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/dialogs/TaskCompareDialog.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/dialogs/TaskCompareDialog.java new file mode 100644 index 000000000..f6c7c19db --- /dev/null +++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/dialogs/TaskCompareDialog.java @@ -0,0 +1,281 @@ +/******************************************************************************* + * Copyright (c) 2004, 2008 Frank Becker 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: + * Frank Becker - initial API and implementation + *******************************************************************************/ + +package org.eclipse.mylyn.internal.tasks.ui.dialogs; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Comparator; + +import org.eclipse.jface.dialogs.Dialog; +import org.eclipse.jface.window.IShellProvider; +import org.eclipse.mylyn.internal.tasks.ui.util.TaskComparator; +import org.eclipse.mylyn.internal.tasks.ui.views.TaskListView; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Combo; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Label; +import org.eclipse.ui.dialogs.SelectionDialog; + +/** + * @author FrankBecker + */ +public class TaskCompareDialog extends SelectionDialog { + + private Combo[] priorityCombos; + + private Button[] ascendingButtons; + + private Button[] descendingButtons; + + private final String[] propertyText; + + private boolean dirty = false; + + private final TaskComparator taskComparator; + + public TaskCompareDialog(IShellProvider parentShell, TaskComparator taskComparator) { + super(parentShell.getShell()); + propertyText = new String[4]; + propertyText[0] = Messages.TaskCompareDialog_Priority; + propertyText[1] = Messages.TaskCompareDialog_Summary; + propertyText[2] = Messages.TaskCompareDialog_DateCreated; + propertyText[3] = Messages.TaskCompareDialog_TaskID; + this.taskComparator = taskComparator; + setTitle(TaskListView.LABEL_VIEW + Messages.TaskCompareDialog_Sorting); + } + + protected void createDialogStartArea(Composite parent) { + Label sortByLabel = new Label(parent, SWT.NULL); + sortByLabel.setText(Messages.TaskCompareDialog_SortOrder); + GridData data = new GridData(); + data.horizontalSpan = 3; + sortByLabel.setLayoutData(data); + } + + @Override + protected Control createDialogArea(Composite parent) { + Composite composite = (Composite) super.createDialogArea(parent); + + initializeDialogUnits(composite); + + Composite prioritiesArea = new Composite(composite, SWT.NULL); + prioritiesArea.setLayout(new GridLayout(3, false)); + + createDialogStartArea(prioritiesArea); + + ascendingButtons = new Button[2]; + descendingButtons = new Button[2]; + priorityCombos = new Combo[2]; + + for (int i = 0; i < 2; i++) { + final int index = i; + Label numberLabel = new Label(prioritiesArea, SWT.NULL); + numberLabel.setText("" + (i + 1) + "."); //$NON-NLS-1$ //$NON-NLS-2$ + priorityCombos[i] = new Combo(prioritiesArea, SWT.READ_ONLY); + priorityCombos[i].setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + + Composite directionGroup = new Composite(prioritiesArea, SWT.NONE); + directionGroup.setLayout(new GridLayout(2, false)); + ascendingButtons[i] = new Button(directionGroup, SWT.RADIO); + ascendingButtons[i].setText(Messages.TaskCompareDialog_Ascending); + ascendingButtons[i].addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + markDirty(); + } + }); + descendingButtons[i] = new Button(directionGroup, SWT.RADIO); + descendingButtons[i].setText(Messages.TaskCompareDialog_Descending); + descendingButtons[i].addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + markDirty(); + } + }); + if (i < priorityCombos.length - 1) { + priorityCombos[i].addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + int oldSelectionDirection = 1; + if (descendingButtons[index].getSelection()) { + oldSelectionDirection = -1; + } + ArrayList<String> oldSelectionList = new ArrayList<String>( + Arrays.asList(priorityCombos[index].getItems())); + oldSelectionList.removeAll(Arrays.asList(priorityCombos[index + 1].getItems())); + if (oldSelectionList.size() != 1) { + return; + } + String oldSelection = oldSelectionList.get(0); + String newSelection = priorityCombos[index].getItem(priorityCombos[index].getSelectionIndex()); + if (oldSelection.equals(newSelection)) { + return; + } + for (int j = index + 1; j < priorityCombos.length; j++) { + int newSelectionIndex = priorityCombos[j].indexOf(newSelection); + //this combo's current selection is equal to newSelection + if (priorityCombos[j].getSelectionIndex() == newSelectionIndex) { + priorityCombos[j].remove(newSelection); + int insertionPoint = -1 + - Arrays.binarySearch(priorityCombos[j].getItems(), oldSelection, + columnComparator); + if (insertionPoint >= 0 && insertionPoint <= priorityCombos[j].getItemCount()) { + priorityCombos[j].add(oldSelection, insertionPoint); + } else { + priorityCombos[j].add(oldSelection); + } + priorityCombos[j].select(priorityCombos[j].indexOf(oldSelection)); + ascendingButtons[index].setSelection(ascendingButtons[j].getSelection()); + descendingButtons[index].setSelection(descendingButtons[j].getSelection()); + ascendingButtons[j].setSelection(oldSelectionDirection == 1); + descendingButtons[j].setSelection(oldSelectionDirection == -1); + } + //this combo contains newSelection + else if (newSelectionIndex >= 0) { + String currentText = priorityCombos[j].getText(); + priorityCombos[j].remove(newSelection); + int insertionPoint = -1 + - Arrays.binarySearch(priorityCombos[j].getItems(), oldSelection, + columnComparator); + if (insertionPoint >= 0 && insertionPoint <= priorityCombos[j].getItemCount()) { + priorityCombos[j].add(oldSelection, insertionPoint); + priorityCombos[j].select(priorityCombos[j].indexOf(currentText)); + } else { + priorityCombos[j].add(oldSelection); + } + } + } + markDirty(); + } + }); + } else { + priorityCombos[i].addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + markDirty(); + } + }); + } + + } + int a[] = new int[2]; + int b[] = new int[2]; + switch (taskComparator.getSortByIndex()) { + case PRIORITY: + a[0] = 0; + break; + case SUMMARY: + a[0] = 1; + break; + case DATE_CREATED: + a[0] = 2; + break; + case TASK_ID: + a[0] = 3; + break; + } + + switch (taskComparator.getSortByIndex2()) { + case PRIORITY: + a[1] = 0; + break; + case SUMMARY: + a[1] = 1; + break; + case DATE_CREATED: + a[1] = 2; + break; + case TASK_ID: + a[1] = 3; + break; + } + b[0] = taskComparator.getSortDirection(); + b[1] = taskComparator.getSortDirection2(); + updateUI(a, b); + Dialog.applyDialogFont(composite); + return composite; + } + + @Override + protected void okPressed() { + if (isDirty()) { + taskComparator.setSortByIndex(TaskComparator.SortByIndex.valueOf(priorityCombos[0].getItem( + priorityCombos[0].getSelectionIndex()).replace(' ', '_').toUpperCase())); + taskComparator.setSortByIndex2(TaskComparator.SortByIndex.valueOf(priorityCombos[1].getItem( + priorityCombos[1].getSelectionIndex()).replace(' ', '_').toUpperCase())); + if (descendingButtons[0].getSelection()) { + taskComparator.setSortDirection(-1); + } else { + taskComparator.setSortDirection(1); + } + if (descendingButtons[1].getSelection()) { + taskComparator.setSortDirection2(-1); + } else { + taskComparator.setSortDirection2(1); + } + + } + super.okPressed(); + } + + /** + * @return boolean + */ + public boolean isDirty() { + return dirty; + } + + /** + * Sets the dirty flag to true. + */ + public void markDirty() { + dirty = true; + } + + private final Comparator<String> columnComparator = new Comparator<String>() { + public int compare(String arg0, String arg1) { + int index0 = -1; + int index1 = -1; + for (int i = 0; i < propertyText.length; i++) { + if (propertyText[i].equals(arg0)) { + index0 = i; + } + if (propertyText[i].equals(arg1)) { + index1 = i; + } + } + return index0 - index1; + } + }; + + protected void updateUI(int[] priorities, int[] directions) { + ArrayList<String> availablePriorities = new ArrayList<String>(Arrays.asList(propertyText)); + + for (int i = 0; i < priorityCombos.length; i++) { + priorityCombos[i].removeAll(); + for (int j = 0; j < availablePriorities.size(); j++) { + priorityCombos[i].add(availablePriorities.get(j)); + } + priorityCombos[i].select(priorityCombos[i].indexOf(propertyText[priorities[i]])); + availablePriorities.remove(propertyText[priorities[i]]); + ascendingButtons[i].setSelection(directions[i] == 1); + descendingButtons[i].setSelection(directions[i] == -1); + } + } + +} diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/dialogs/TaskListSortDialog.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/dialogs/TaskListSortDialog.java index 1729d75a5..6be04e7cf 100644 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/dialogs/TaskListSortDialog.java +++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/dialogs/TaskListSortDialog.java @@ -1,281 +1,41 @@ /******************************************************************************* - * Copyright (c) 2004, 2008 Tasktop Technologies and others. + * Copyright (c) 2004, 2008 Frank Becker 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 + * Frank Becker - initial API and implementation *******************************************************************************/ package org.eclipse.mylyn.internal.tasks.ui.dialogs; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Comparator; - +import org.eclipse.jface.dialogs.Dialog; import org.eclipse.jface.window.IShellProvider; import org.eclipse.mylyn.internal.tasks.ui.views.TaskListView; -import org.eclipse.mylyn.internal.tasks.ui.views.TaskListTableSorter.SortByIndex; import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Combo; import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Label; -import org.eclipse.ui.dialogs.SelectionDialog; - -public class TaskListSortDialog extends SelectionDialog { - private Combo[] priorityCombos; - - private Button[] ascendingButtons; - - private Button[] descendingButtons; - private final String[] propertyText; - - private boolean dirty = false; - - private final TaskListView taskListView; +/** + * @author Frank Becker + */ +public class TaskListSortDialog extends TaskCompareDialog { public TaskListSortDialog(IShellProvider parentShell, TaskListView taskListView) { - super(parentShell.getShell()); - propertyText = new String[3]; - propertyText[0] = Messages.TaskListSortDialog_Priority; - propertyText[1] = Messages.TaskListSortDialog_Summary; - propertyText[2] = Messages.TaskListSortDialog_Date_Created; - this.taskListView = taskListView; + super(parentShell, taskListView.getSorter().getTaskComparator()); setTitle(TaskListView.LABEL_VIEW + Messages.TaskListSortDialog_Sorting); } @Override - protected Control createDialogArea(Composite parent) { - Composite composite = (Composite) super.createDialogArea(parent); - - initializeDialogUnits(composite); - - Composite prioritiesArea = new Composite(composite, SWT.NULL); - prioritiesArea.setLayout(new GridLayout(3, false)); - - Label sortByLabel = new Label(prioritiesArea, SWT.NULL); + protected void createDialogStartArea(Composite parent) { + Label sortByLabel = new Label(parent, SWT.NULL); sortByLabel.setText(Messages.TaskListSortDialog_Sort_order); GridData data = new GridData(); data.horizontalSpan = 3; sortByLabel.setLayoutData(data); - - ascendingButtons = new Button[2]; - descendingButtons = new Button[2]; - priorityCombos = new Combo[2]; - - for (int i = 0; i < 2; i++) { - final int index = i; - Label numberLabel = new Label(prioritiesArea, SWT.NULL); - numberLabel.setText("" + (i + 1) + "."); //$NON-NLS-1$ //$NON-NLS-2$ - priorityCombos[i] = new Combo(prioritiesArea, SWT.READ_ONLY); - priorityCombos[i].setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - - Composite directionGroup = new Composite(prioritiesArea, SWT.NONE); - directionGroup.setLayout(new GridLayout(2, false)); - ascendingButtons[i] = new Button(directionGroup, SWT.RADIO); - ascendingButtons[i].setText(Messages.TaskListSortDialog_Ascending); - ascendingButtons[i].addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - markDirty(); - } - }); - descendingButtons[i] = new Button(directionGroup, SWT.RADIO); - descendingButtons[i].setText(Messages.TaskListSortDialog_Descending); - descendingButtons[i].addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - markDirty(); - } - }); - if (i < priorityCombos.length - 1) { - priorityCombos[i].addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - int oldSelectionDirection = 1; - if (descendingButtons[index].getSelection()) { - oldSelectionDirection = -1; - } - ArrayList<String> oldSelectionList = new ArrayList<String>( - Arrays.asList(priorityCombos[index].getItems())); - oldSelectionList.removeAll(Arrays.asList(priorityCombos[index + 1].getItems())); - if (oldSelectionList.size() != 1) { - return; - } - String oldSelection = oldSelectionList.get(0); - String newSelection = priorityCombos[index].getItem(priorityCombos[index].getSelectionIndex()); - if (oldSelection.equals(newSelection)) { - return; - } - for (int j = index + 1; j < priorityCombos.length; j++) { - int newSelectionIndex = priorityCombos[j].indexOf(newSelection); - //this combo's current selection is equal to newSelection - if (priorityCombos[j].getSelectionIndex() == newSelectionIndex) { - priorityCombos[j].remove(newSelection); - int insertionPoint = -1 - - Arrays.binarySearch(priorityCombos[j].getItems(), oldSelection, - columnComparator); - if (insertionPoint >= 0 && insertionPoint <= priorityCombos[j].getItemCount()) { - priorityCombos[j].add(oldSelection, insertionPoint); - } else { - priorityCombos[j].add(oldSelection); - } - priorityCombos[j].select(priorityCombos[j].indexOf(oldSelection)); - ascendingButtons[index].setSelection(ascendingButtons[j].getSelection()); - descendingButtons[index].setSelection(descendingButtons[j].getSelection()); - ascendingButtons[j].setSelection(oldSelectionDirection == 1); - descendingButtons[j].setSelection(oldSelectionDirection == -1); - } - //this combo contains newSelection - else if (newSelectionIndex >= 0) { - String currentText = priorityCombos[j].getText(); - priorityCombos[j].remove(newSelection); - int insertionPoint = -1 - - Arrays.binarySearch(priorityCombos[j].getItems(), oldSelection, - columnComparator); - if (insertionPoint >= 0 && insertionPoint <= priorityCombos[j].getItemCount()) { - priorityCombos[j].add(oldSelection, insertionPoint); - priorityCombos[j].select(priorityCombos[j].indexOf(currentText)); - } else { - priorityCombos[j].add(oldSelection); - } - } - } - markDirty(); - } - }); - } else { - priorityCombos[i].addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - markDirty(); - } - }); - } - - } - int a[] = new int[2]; - int b[] = new int[2]; - switch (taskListView.getSorter().getSortByIndex()) { - case PRIORITY: - a[0] = 0; - break; - case SUMMARY: - a[0] = 1; - break; - case DATE_CREATED: - a[0] = 2; - break; - } - - switch (taskListView.getSorter().getSortByIndex2()) { - case PRIORITY: - a[1] = 0; - break; - case SUMMARY: - a[1] = 1; - break; - case DATE_CREATED: - a[1] = 2; - break; - } - b[0] = taskListView.getSorter().getSortDirection(); - b[1] = taskListView.getSorter().getSortDirection2(); - updateUI(a, b); - - applyDialogFont(composite); - return composite; + Dialog.applyDialogFont(parent); } - - @Override - protected void okPressed() { - if (isDirty()) { - String select; - select = priorityCombos[0].getItem(priorityCombos[0].getSelectionIndex()); - if (propertyText[0].equals(select)) { - taskListView.getSorter().setSortByIndex(SortByIndex.PRIORITY); - } else if (propertyText[1].equals(select)) { - taskListView.getSorter().setSortByIndex(SortByIndex.SUMMARY); - } else { - taskListView.getSorter().setSortByIndex(SortByIndex.DATE_CREATED); - } - select = priorityCombos[1].getItem(priorityCombos[1].getSelectionIndex()); - if (propertyText[0].equals(select)) { - taskListView.getSorter().setSortByIndex2(SortByIndex.PRIORITY); - } else if (propertyText[1].equals(select)) { - taskListView.getSorter().setSortByIndex2(SortByIndex.SUMMARY); - } else { - taskListView.getSorter().setSortByIndex2(SortByIndex.DATE_CREATED); - } - - if (descendingButtons[0].getSelection()) { - taskListView.getSorter().setSortDirection(-1); - } else { - taskListView.getSorter().setSortDirection(1); - } - if (descendingButtons[1].getSelection()) { - taskListView.getSorter().setSortDirection2(-1); - } else { - taskListView.getSorter().setSortDirection2(1); - } - - } - super.okPressed(); - } - - /** - * @return boolean - */ - public boolean isDirty() { - return dirty; - } - - /** - * Sets the dirty flag to true. - */ - public void markDirty() { - dirty = true; - } - - private final Comparator<String> columnComparator = new Comparator<String>() { - public int compare(String arg0, String arg1) { - int index0 = -1; - int index1 = -1; - for (int i = 0; i < propertyText.length; i++) { - if (propertyText[i].equals(arg0)) { - index0 = i; - } - if (propertyText[i].equals(arg1)) { - index1 = i; - } - } - return index0 - index1; - } - }; - - private void updateUI(int[] priorities, int[] directions) { - ArrayList<String> availablePriorities = new ArrayList<String>(Arrays.asList(propertyText)); - - for (int i = 0; i < priorityCombos.length; i++) { - priorityCombos[i].removeAll(); - for (int j = 0; j < availablePriorities.size(); j++) { - priorityCombos[i].add(availablePriorities.get(j)); - } - priorityCombos[i].select(priorityCombos[i].indexOf(propertyText[priorities[i]])); - availablePriorities.remove(propertyText[priorities[i]]); - - ascendingButtons[i].setSelection(directions[i] == 1); - descendingButtons[i].setSelection(directions[i] == -1); - } - } - } diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/dialogs/messages.properties b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/dialogs/messages.properties index ec452df2a..0fb49295c 100644 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/dialogs/messages.properties +++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/dialogs/messages.properties @@ -1,10 +1,13 @@ -TaskListSortDialog_Ascending=Ascending -TaskListSortDialog_Date_Created=Date Created -TaskListSortDialog_Descending=Descending -TaskListSortDialog_Priority=Priority -TaskListSortDialog_Sort_order=Sort order\: +TaskCompareDialog_Ascending=Ascending +TaskCompareDialog_DateCreated=Date Created +TaskCompareDialog_Descending=Descending +TaskCompareDialog_Priority=Priority +TaskCompareDialog_Sorting=\ Sorting +TaskCompareDialog_SortOrder=Sort order: +TaskCompareDialog_Summary=Summary +TaskCompareDialog_TaskID=Task ID +TaskListSortDialog_Sort_order=Sort order for tasks\: TaskListSortDialog_Sorting=\ Sorting -TaskListSortDialog_Summary=Summary TaskRepositoryCredentialsDialog_Enter_Credentials=Enter Credentials TaskRepositoryCredentialsDialog_Enter_repository_credentials=Enter repository credentials diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/Messages.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/Messages.java index 091fc5c65..0a93f630b 100644 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/Messages.java +++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/Messages.java @@ -43,8 +43,6 @@ public class Messages extends NLS { public static String AttachmentTableLabelProvider_Task_Context; - public static String AttachmentTableLabelProvider_unrecognized_column; - public static String AttachmentTableLabelProvider_Type_; public static String BrowserPreviewViewer_Error; @@ -83,18 +81,6 @@ public class Messages extends NLS { public static String PreviewAttributeEditor_Preview; - public static String RepositoryAttachmentEditorInput_Repository_Attachment; - - public static String RepositoryTaskEditorDropListener_Note_that_only_the_first_file_dragged_will_be_attached; - - public static String RepositoryTaskOutlineNode_BugReport_Object; - - public static String RepositoryTaskOutlineNode_Comments; - - public static String RepositoryTaskOutlineNode_Description; - - public static String RepositoryTaskOutlineNode_New_Comment; - public static String RichTextAttributeEditor_Viewer_Source; public static String TaskAttachmentDropListener_Note_that_only_the_first_file_dragged_will_be_attached; @@ -285,8 +271,6 @@ public class Messages extends NLS { public static String AttributeEditorToolkit_Content_Assist_Available__X_; - public static String TaskEditor_New_; - public static String TaskEditor_Task_; public static String TaskEditor_Task_added_to_the_Uncategorized_container; diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/messages.properties b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/messages.properties index 4453e7103..7a23a356c 100644 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/messages.properties +++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/messages.properties @@ -10,7 +10,6 @@ AttachmentTableLabelProvider_File_=File: AttachmentTableLabelProvider_Patch=\ Patch AttachmentTableLabelProvider_Task_Context=\ Task Context AttachmentTableLabelProvider_Type_=Type: -AttachmentTableLabelProvider_unrecognized_column=unrecognized column BrowserPreviewViewer_Error=Error BrowserPreviewViewer_Formatting_Wiki_Text=Formatting Wiki Text BrowserPreviewViewer_Loading_preview_=Loading preview... @@ -36,13 +35,6 @@ PreviewAttributeEditor_Formatting_Wiki_Text=Formatting Wiki Text PreviewAttributeEditor_Loading_preview_=Loading preview... PreviewAttributeEditor_Preview=Preview -RepositoryAttachmentEditorInput_Repository_Attachment=Repository Attachment: -RepositoryTaskEditorDropListener_Note_that_only_the_first_file_dragged_will_be_attached=Note that only the first file dragged will be attached. -RepositoryTaskOutlineNode_BugReport_Object=BugReport Object -RepositoryTaskOutlineNode_Comments=Comments -RepositoryTaskOutlineNode_Description=Description -RepositoryTaskOutlineNode_New_Comment=New Comment - RichTextAttributeEditor_Viewer_Source=Viewer Source TaskAttachmentDropListener_Note_that_only_the_first_file_dragged_will_be_attached=Note that only the first file dragged will be attached. @@ -152,7 +144,6 @@ AbstractTaskEditorPage_Title=Title AbstractTaskEditorPage_Unable_to_submit_at_this_time=Unable to submit at this time. Check connectivity and retry. AttributeEditorToolkit_Content_Assist_Available__X_=Content Assist Available ({0}) -TaskEditor_New_=New TaskEditor_Task_=Task: TaskEditor_Task_added_to_the_Uncategorized_container=Task added to the Uncategorized container diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/search/Messages.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/search/Messages.java index 2c2922cb8..749e20949 100644 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/search/Messages.java +++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/search/Messages.java @@ -25,8 +25,6 @@ public class Messages extends NLS { NLS.initializeMessages(BUNDLE_NAME, Messages.class); } - public static String AbstractRepositorySearchQuery_Querying_Repository_; - public static String CreateQueryFromSearchAction_CLEAR_QUERY; public static String CreateQueryFromSearchAction_Name_of_query_to_be_added_to_the_X; @@ -55,8 +53,6 @@ public class Messages extends NLS { public static String SearchHitCollector_Max_allowed_number_of_hits_returned_exceeded; - public static String SearchHitCollector_Maximum_hits_reached; - public static String SearchHitCollector_Querying_Repository_; public static String SearchHitCollector_Repository_connector_could_not_be_found; diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/search/messages.properties b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/search/messages.properties index d4ea0188e..8c2bb35b4 100644 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/search/messages.properties +++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/search/messages.properties @@ -1,5 +1,3 @@ -AbstractRepositorySearchQuery_Querying_Repository_=Querying Repository... - CreateQueryFromSearchAction_CLEAR_QUERY=Create Query CreateQueryFromSearchAction_Name_of_query_to_be_added_to_the_X=Name of query to be added to the {0} RepositorySearchResult_Task_search_X_matches=Task search - {0} matches @@ -15,7 +13,6 @@ 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_Maximum_hits_reached=Maximum hits reached SearchHitCollector_Querying_Repository_=Querying Repository... SearchHitCollector_Repository_connector_could_not_be_found=Repository connector could not be found SearchHitCollector_Search_failed=Search failed diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/util/Messages.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/util/Messages.java index 0504dc196..a506d12d8 100644 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/util/Messages.java +++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/util/Messages.java @@ -25,8 +25,6 @@ public class Messages extends NLS { NLS.initializeMessages(BUNDLE_NAME, Messages.class); } - public static String AttachmentUtil_Attachments_not_supported_by_connector; - public static String AttachmentUtil_The_context_is_empty; public static String AttachmentUtil_Downloading_attachment; @@ -53,12 +51,8 @@ public class Messages extends NLS { public static String TasksUiInternal_Configuration_Refresh_Failed; - public static String TasksUiInternal_Creating_task; - public static String TasksUiInternal_Create_Task; - public static String TasksUiInternal_Edit_Repository_Query; - public static String TasksUiInternal_INPORT_TASK; public static String TasksUiInternal_The_new_task_will_be_added_to_the_X_container; diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/util/TaskComparator.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/util/TaskComparator.java new file mode 100644 index 000000000..e64893f9b --- /dev/null +++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/util/TaskComparator.java @@ -0,0 +1,156 @@ +/******************************************************************************* + * 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 + * Frank Becker - improvements for bug 231336 + *******************************************************************************/ + +package org.eclipse.mylyn.internal.tasks.ui.util; + +import java.util.Comparator; + +import org.eclipse.mylyn.tasks.core.ITask; + +/** + * @author Mik Kersten + * @author Frank Becker + */ +public class TaskComparator implements Comparator<ITask> { + + public enum SortByIndex { + PRIORITY, SUMMARY, DATE_CREATED, TASK_ID; + } + + public static final int DEFAULT_SORT_DIRECTION = 1; + + private int sortDirection = DEFAULT_SORT_DIRECTION; + + private SortByIndex sortByIndex = SortByIndex.PRIORITY; + + private int sortDirection2 = DEFAULT_SORT_DIRECTION; + + private SortByIndex sortByIndex2 = SortByIndex.DATE_CREATED; + + public int compare(ITask element1, ITask 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 if (SortByIndex.TASK_ID.equals(sortByIndex2)) { + return sortByID(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 if (SortByIndex.TASK_ID.equals(sortByIndex2)) { + return sortByID(element1, element2, sortDirection2); + } else { + return result; + } + } + } else if (SortByIndex.SUMMARY.equals(sortByIndex)) { + 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 if (SortByIndex.TASK_ID.equals(sortByIndex2)) { + return sortByID(element1, element2, sortDirection2); + } else { + return result; + } + } + } else { + int result = sortByID(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 if (SortByIndex.SUMMARY.equals(sortByIndex2)) { + return sortBySummary(element1, element2, sortDirection2); + } else { + return result; + } + } + } + } + + private int sortBySummary(ITask element1, ITask element2, int sortDirection) { + return sortDirection * (element1.getSummary().compareTo(element2.getSummary())); + } + + private int sortByID(ITask element1, ITask element2, int sortDirection) { + return sortDirection * (element1.getTaskId().compareTo(element2.getTaskId())); + } + + private int sortByPriority(ITask element1, ITask element2, int sortDirection) { + return sortDirection * (element1.getPriority().compareTo(element2.getPriority())); + } + + private int sortByDate(ITask element1, ITask element2, int sortDirection) { + return sortDirection * (element1.getCreationDate().compareTo(element2.getCreationDate())); + } + + public SortByIndex getSortByIndex() { + return sortByIndex; + } + + public void setSortByIndex(SortByIndex sortByIndex) { + this.sortByIndex = sortByIndex; + } + + public int getSortDirection() { + return sortDirection; + } + + public void setSortDirection(int sortDirection) { + this.sortDirection = sortDirection; + } + + public SortByIndex getSortByIndex2() { + return sortByIndex2; + } + + public void setSortByIndex2(SortByIndex sortByIndex) { + this.sortByIndex2 = sortByIndex; + } + + public int getSortDirection2() { + return sortDirection2; + } + + public void setSortDirection2(int sortDirection) { + this.sortDirection2 = sortDirection; + } + +} diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/util/messages.properties b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/util/messages.properties index 734711401..762e0ac14 100644 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/util/messages.properties +++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/util/messages.properties @@ -1,4 +1,3 @@ -AttachmentUtil_Attachments_not_supported_by_connector=Attachments not supported by connector: AttachmentUtil_The_context_is_empty=The context is empty. AttachmentUtil_Downloading_attachment=Downloading attachment AttachmentUtil_Mylyn_Information=Mylyn Information @@ -16,9 +15,7 @@ TaskListElementImporter_Unable_to_read_the_Mylyn_task_list=Unable to read the My TasksUiInternal_already_exists=' already exists. Do you want to override it's context with the source? TasksUiInternal_Configuration_Refresh_Failed=Configuration Refresh Failed -TasksUiInternal_Creating_task=Creating task TasksUiInternal_Create_Task=Create Task -TasksUiInternal_Edit_Repository_Query=Edit Repository Query TasksUiInternal_INPORT_TASK=Import Task TasksUiInternal_The_new_task_will_be_added_to_the_X_container=The new task will be added to the {0} container, since tasks can not be added to a query. TasksUiInternal_Query_Synchronization_Failed=Query Synchronization Failed diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/views/SortyByDropDownAction.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/views/SortyByDropDownAction.java index b9d4926e4..b64576716 100644 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/views/SortyByDropDownAction.java +++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/views/SortyByDropDownAction.java @@ -1,5 +1,5 @@ /******************************************************************************* -* Copyright (c) 2004, 2008 Tasktop Technologies and others. + * 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 @@ -16,7 +16,7 @@ import org.eclipse.jface.action.ActionContributionItem; import org.eclipse.jface.action.IMenuCreator; import org.eclipse.jface.action.Separator; import org.eclipse.mylyn.internal.provisional.commons.ui.CommonImages; -import org.eclipse.mylyn.internal.tasks.ui.views.TaskListTableSorter.SortByIndex; +import org.eclipse.mylyn.internal.tasks.ui.util.TaskComparator; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Menu; @@ -74,7 +74,7 @@ class SortyByDropDownAction extends Action implements IMenuCreator { byPriority = new Action("", AS_CHECK_BOX) { //$NON-NLS-1$ @Override public void run() { - taskListView.getSorter().setSortByIndex(SortByIndex.PRIORITY); + taskListView.getSorter().setSortByIndex(TaskComparator.SortByIndex.PRIORITY); byPriority.setChecked(true); bySummary.setChecked(false); byDateCreated.setChecked(false); @@ -88,7 +88,7 @@ class SortyByDropDownAction extends Action implements IMenuCreator { bySummary = new Action("", AS_CHECK_BOX) { //$NON-NLS-1$ @Override public void run() { - taskListView.getSorter().setSortByIndex(SortByIndex.SUMMARY); + taskListView.getSorter().setSortByIndex(TaskComparator.SortByIndex.SUMMARY); byPriority.setChecked(false); bySummary.setChecked(true); byDateCreated.setChecked(false); @@ -101,7 +101,7 @@ class SortyByDropDownAction extends Action implements IMenuCreator { byDateCreated = new Action("", AS_CHECK_BOX) { //$NON-NLS-1$ @Override public void run() { - taskListView.getSorter().setSortByIndex(SortByIndex.DATE_CREATED); + taskListView.getSorter().setSortByIndex(TaskComparator.SortByIndex.DATE_CREATED); byPriority.setChecked(false); bySummary.setChecked(false); byDateCreated.setChecked(true); diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/views/TaskListTableSorter.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/views/TaskListTableSorter.java index 55769f557..4227f6fea 100644 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/views/TaskListTableSorter.java +++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/views/TaskListTableSorter.java @@ -11,20 +11,21 @@ package org.eclipse.mylyn.internal.tasks.ui.views; -import java.util.Date; - import org.eclipse.jface.dialogs.MessageDialog; 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.core.AbstractTaskContainer; +import org.eclipse.mylyn.internal.tasks.core.RepositoryQuery; import org.eclipse.mylyn.internal.tasks.core.ScheduledTaskContainer; +import org.eclipse.mylyn.internal.tasks.core.TaskCategory; +import org.eclipse.mylyn.internal.tasks.core.TaskGroup; import org.eclipse.mylyn.internal.tasks.core.UncategorizedTaskContainer; import org.eclipse.mylyn.internal.tasks.core.UnmatchedTaskContainer; +import org.eclipse.mylyn.internal.tasks.core.UnsubmittedTaskContainer; +import org.eclipse.mylyn.internal.tasks.ui.util.TaskComparator; import org.eclipse.mylyn.tasks.core.IRepositoryElement; -import org.eclipse.mylyn.tasks.core.IRepositoryQuery; import org.eclipse.mylyn.tasks.core.ITask; -import org.eclipse.mylyn.tasks.core.ITaskContainer; import org.eclipse.ui.PlatformUI; /** @@ -32,33 +33,23 @@ import org.eclipse.ui.PlatformUI; */ public class TaskListTableSorter extends ViewerSorter { - public enum SortByIndex { - PRIORITY, SUMMARY, DATE_CREATED; - } - - private static final int DEFAULT_SORT_DIRECTION = 1; - - private int sortDirection = DEFAULT_SORT_DIRECTION; + public static final int DEFAULT_SORT_DIRECTION = 1; - private SortByIndex sortByIndex = SortByIndex.PRIORITY; - - private int sortDirection2 = DEFAULT_SORT_DIRECTION; - - private SortByIndex sortByIndex2 = SortByIndex.DATE_CREATED; + private int sortDirectionRootElement = DEFAULT_SORT_DIRECTION; private final TaskListView view; - private final TaskKeyComparator taskKeyComparator = new TaskKeyComparator(); + private final TaskComparator taskComparator = new TaskComparator(); public TaskListTableSorter(TaskListView view) { super(); this.view = view; } - public TaskListTableSorter(TaskListView view, SortByIndex index) { + public TaskListTableSorter(TaskListView view, TaskComparator.SortByIndex index) { super(); this.view = view; - this.sortByIndex = index; + taskComparator.setSortByIndex(index); } public void setColumn(String column) { @@ -75,170 +66,72 @@ public class TaskListTableSorter extends ViewerSorter { @Override public int compare(Viewer compareViewer, Object o1, Object o2) { - if (o1 instanceof ScheduledTaskContainer && o2 instanceof ScheduledTaskContainer) { + if (o1 instanceof AbstractTask && o2 instanceof AbstractTask) { + // sort of the tasks within the container using the setting from the Sortdialog + ITask element1 = (ITask) o1; + ITask element2 = (ITask) o2; + + return compareElements(element1, element2); + } else if (o1 instanceof ScheduledTaskContainer && o2 instanceof ScheduledTaskContainer) { + // scheduled Mode compare ScheduledTaskContainer dateRangeTaskContainer1 = (ScheduledTaskContainer) o1; ScheduledTaskContainer dateRangeTaskContainer2 = (ScheduledTaskContainer) o2; return dateRangeTaskContainer1.getDateRange().compareTo(dateRangeTaskContainer2.getDateRange()); -// if (dateRangeTaskContainer1.isCaptureFloating() && !dateRangeTaskContainer2.isCaptureFloating()) { -// return 1; -// } else if (!dateRangeTaskContainer1.isCaptureFloating() && dateRangeTaskContainer2.isCaptureFloating()) { -// return -1; -// } -// return -1 * dateRangeTaskContainer2.getStart().compareTo(dateRangeTaskContainer1.getStart()); - } else if (o1 instanceof ITaskContainer && o2 instanceof ScheduledTaskContainer) { - return -1; - } else if (o1 instanceof ScheduledTaskContainer && o2 instanceof ITaskContainer) { - return 1; - } - - if (o1 instanceof ITaskContainer && o2 instanceof UncategorizedTaskContainer) { - return 1; - } else if (o2 instanceof ITaskContainer && o1 instanceof UncategorizedTaskContainer) { - return -1; - } - - if (o1 instanceof ITaskContainer && o2 instanceof UnmatchedTaskContainer) { - return -1; - } else if (o2 instanceof ITaskContainer && o1 instanceof UnmatchedTaskContainer) { - return 1; - } - - if (!(o1 instanceof ITask) && o2 instanceof ITask) { - return 1; - } - - if (o1 instanceof ITask && !(o2 instanceof ITaskContainer)) { - return -1; - } - - // if (o1 instanceof AbstractTaskContainer || o1 instanceof - // AbstractRepositoryQuery) { - if (!(o1 instanceof ITask)) { - if (o2 instanceof ITaskContainer || o2 instanceof IRepositoryQuery) { - - return this.sortDirection - * ((IRepositoryElement) o1).getSummary().compareToIgnoreCase( - ((IRepositoryElement) o2).getSummary()); - } else { - return -1; - } - } else if (o1 instanceof ITaskContainer) { - if (!(o2 instanceof ITask)) { - return -1; - } else if (o2 instanceof ITaskContainer) { - IRepositoryElement element1 = (IRepositoryElement) o1; - IRepositoryElement element2 = (IRepositoryElement) o2; - - return compareElements(element1, element2); - } } else { - return 0; - } - return 0; - } - - private int compareElements(IRepositoryElement element1, IRepositoryElement 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); + int o1Type; + if (o1 instanceof AbstractTask) { + o1Type = 0; + } else if (o1 instanceof UncategorizedTaskContainer) { + o1Type = 1; + } else if (o1 instanceof UnsubmittedTaskContainer) { + o1Type = 2; + } else if (o1 instanceof TaskCategory) { + o1Type = 3; + } else if (o1 instanceof RepositoryQuery) { + o1Type = 4; + } else if (o1 instanceof TaskGroup) { // support for the experimental grouping of tasks + o1Type = 5; + } else if (o1 instanceof UnmatchedTaskContainer) { + o1Type = 6; } 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; + o1Type = 99; } - if (SortByIndex.PRIORITY.equals(sortByIndex2)) { - return sortByPriority(element1, element2, sortDirection2); + int o2Type; + if (o2 instanceof AbstractTask) { + o2Type = 0; + } else if (o2 instanceof UncategorizedTaskContainer) { + o2Type = 1; + } else if (o2 instanceof UnsubmittedTaskContainer) { + o2Type = 2; + } else if (o2 instanceof TaskCategory) { + o2Type = 3; + } else if (o2 instanceof RepositoryQuery) { + o2Type = 4; + } else if (o2 instanceof TaskGroup) { // support for the experimental grouping of tasks + o2Type = 5; + } else if (o2 instanceof UnmatchedTaskContainer) { + o2Type = 6; } else { - if (SortByIndex.SUMMARY.equals(sortByIndex2)) { - return sortBySummary(element1, element2, sortDirection2); - } else { - return result; - } + o2Type = 99; } - } else { - int result = sortBySummary(element1, element2, sortDirection); - if (result != 0) { - return result; + if (o1Type != o2Type) { + return o1Type - o2Type < 0 ? -1 : 1; } - 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; - } - } - } - } + if (o1Type < 7) { + AbstractTaskContainer taskContainer1 = (AbstractTaskContainer) o1; + AbstractTaskContainer taskContainer2 = (AbstractTaskContainer) o2; - /** - * Determine the sort order of two tasks by id/summary - * - * @param element1 - * @param element2 - * @return sort order - */ - private int sortBySummary(IRepositoryElement element1, IRepositoryElement element2, int sortDirection) { - return sortDirection - * taskKeyComparator.compare(getSortableFromElement(element1), getSortableFromElement(element2)); - } - - /** - * Determine the sort order of two tasks by priority - * - * @param element1 - * @param element2 - * @return sort order - */ - private int sortByPriority(IRepositoryElement element1, IRepositoryElement element2, int sortDirection) { - return sortDirection - * ((AbstractTaskContainer) element1).getPriority().compareTo( - ((AbstractTaskContainer) element2).getPriority()); - } - - /** - * Determine the sort order of two tasks by creation date - * - * @param element1 - * @param element2 - * @return sort order - */ - private int sortByDate(IRepositoryElement element1, IRepositoryElement 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) { - Date creationDate1 = t1.getCreationDate(); - if (creationDate1 != null) { - Date creationDate2 = t2.getCreationDate(); - if (creationDate2 != null) { - return sortDirection * creationDate1.compareTo(creationDate2); - } else { - return 1; - } + return this.sortDirectionRootElement + * taskContainer1.getSummary().compareToIgnoreCase(taskContainer2.getSummary()); } } return 0; } + private int compareElements(ITask element1, ITask element2) { + return taskComparator.compare(element1, element2); + } + /** * Return a array of values to pass to taskKeyComparator.compare() for sorting * @@ -257,54 +150,70 @@ public class TaskListTableSorter extends ViewerSorter { return a; } - public SortByIndex getSortByIndex() { - return sortByIndex; + public TaskComparator.SortByIndex getSortByIndex() { + return taskComparator.getSortByIndex(); } - public void setSortByIndex(SortByIndex sortByIndex) { - SortByIndex oldValue = this.sortByIndex; - this.sortByIndex = sortByIndex; + public void setSortByIndex(TaskComparator.SortByIndex sortByIndex) { + TaskComparator.SortByIndex oldValue = taskComparator.getSortByIndex(); if (!oldValue.equals(sortByIndex)) { + taskComparator.setSortByIndex(sortByIndex); view.getViewer().refresh(); } } public int getSortDirection() { - return sortDirection; + return taskComparator.getSortDirection(); } public void setSortDirection(int sortDirection) { - int oldValue = this.sortDirection; - this.sortDirection = sortDirection; - if (oldValue != this.sortDirection) { + int oldValue = taskComparator.getSortDirection(); + if (oldValue != sortDirection) { + taskComparator.setSortDirection(sortDirection); view.getViewer().refresh(); } } - public SortByIndex getSortByIndex2() { - return sortByIndex2; + public TaskComparator.SortByIndex getSortByIndex2() { + return taskComparator.getSortByIndex2(); } - public void setSortByIndex2(SortByIndex sortByIndex) { - SortByIndex oldValue = this.sortByIndex2; - this.sortByIndex2 = sortByIndex; + public void setSortByIndex2(TaskComparator.SortByIndex sortByIndex) { + TaskComparator.SortByIndex oldValue = taskComparator.getSortByIndex2(); if (!oldValue.equals(sortByIndex)) { + taskComparator.setSortByIndex2(sortByIndex); view.getViewer().refresh(); } } public int getSortDirection2() { - return sortDirection2; + return taskComparator.getSortDirection2(); } public void setSortDirection2(int sortDirection) { - int oldValue = this.sortDirection2; - this.sortDirection2 = sortDirection; - if (oldValue != this.sortDirection2) { + int oldValue = taskComparator.getSortDirection2(); + if (oldValue != sortDirection) { + taskComparator.setSortDirection2(sortDirection); + view.getViewer().refresh(); + } + } + + public int getSortDirectionRootElement() { + return sortDirectionRootElement; + } + + public void setSortDirectionRootElement(int sortDirection) { + int oldValue = this.sortDirectionRootElement; + this.sortDirectionRootElement = sortDirection; + if (oldValue != this.sortDirectionRootElement) { view.getViewer().refresh(); } } + public TaskComparator getTaskComparator() { + return taskComparator; + } + } diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/views/TaskListView.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/views/TaskListView.java index f6a23f300..8a8e31286 100644 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/views/TaskListView.java +++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/views/TaskListView.java @@ -103,11 +103,11 @@ import org.eclipse.mylyn.internal.tasks.ui.actions.TaskListSortAction; import org.eclipse.mylyn.internal.tasks.ui.commands.CollapseAllHandler; import org.eclipse.mylyn.internal.tasks.ui.editors.TaskListChangeAdapter; import org.eclipse.mylyn.internal.tasks.ui.util.PlatformUtil; +import org.eclipse.mylyn.internal.tasks.ui.util.TaskComparator; import org.eclipse.mylyn.internal.tasks.ui.util.TaskDragSourceListener; import org.eclipse.mylyn.internal.tasks.ui.util.TasksUiInternal; import org.eclipse.mylyn.internal.tasks.ui.util.TreeWalker; import org.eclipse.mylyn.internal.tasks.ui.util.TreeWalker.TreeVisitor; -import org.eclipse.mylyn.internal.tasks.ui.views.TaskListTableSorter.SortByIndex; import org.eclipse.mylyn.internal.tasks.ui.workingsets.TaskWorkingSetUpdater; import org.eclipse.mylyn.tasks.core.IRepositoryElement; import org.eclipse.mylyn.tasks.core.IRepositoryQuery; @@ -297,6 +297,8 @@ public class TaskListView extends ViewPart implements IPropertyChangeListener { private static final String MEMENTO_KEY_SORT_DIRECTION = "sortDirection"; //$NON-NLS-1$ + private static final String MEMENTO_KEY_ROOT_SORT_DIRECTION = "rootSortDirection"; //$NON-NLS-1$ + private static final String MEMENTO_KEY_SORTER = "sorter"; //$NON-NLS-1$ private static final String MEMENTO_KEY_SORTER2 = "sorter2"; //$NON-NLS-1$ @@ -758,6 +760,9 @@ public class TaskListView extends ViewPart implements IPropertyChangeListener { case DATE_CREATED: m.putInteger(MEMENTO_KEY_SORT_INDEX, 2); break; + case TASK_ID: + m.putInteger(MEMENTO_KEY_SORT_INDEX, 3); + break; default: m.putInteger(MEMENTO_KEY_SORT_INDEX, 0); } @@ -771,6 +776,9 @@ public class TaskListView extends ViewPart implements IPropertyChangeListener { case DATE_CREATED: m2.putInteger(MEMENTO_KEY_SORT_INDEX, 2); break; + case TASK_ID: + m2.putInteger(MEMENTO_KEY_SORT_INDEX, 3); + break; default: m2.putInteger(MEMENTO_KEY_SORT_INDEX, 0); } @@ -778,6 +786,7 @@ public class TaskListView extends ViewPart implements IPropertyChangeListener { m2.putInteger(MEMENTO_KEY_SORT_DIRECTION, tableSorter.getSortDirection2()); memento.putString(MEMENTO_LINK_WITH_EDITOR, Boolean.toString(linkWithEditor)); memento.putString(MEMENTO_PRESENTATION, currentPresentation.getId()); + memento.putInteger(MEMENTO_KEY_ROOT_SORT_DIRECTION, tableSorter.getSortDirectionRootElement()); } private void restoreState() { @@ -800,13 +809,16 @@ public class TaskListView extends ViewPart implements IPropertyChangeListener { tableSorter.setSortDirection(sortDirection); switch (restoredSortIndex) { case 1: - tableSorter.setSortByIndex(SortByIndex.SUMMARY); + tableSorter.setSortByIndex(TaskComparator.SortByIndex.SUMMARY); break; case 2: - tableSorter.setSortByIndex(SortByIndex.DATE_CREATED); + tableSorter.setSortByIndex(TaskComparator.SortByIndex.DATE_CREATED); + break; + case 3: + tableSorter.setSortByIndex(TaskComparator.SortByIndex.TASK_ID); break; default: - tableSorter.setSortByIndex(SortByIndex.PRIORITY); + tableSorter.setSortByIndex(TaskComparator.SortByIndex.PRIORITY); } } } @@ -823,18 +835,27 @@ public class TaskListView extends ViewPart implements IPropertyChangeListener { tableSorter.setSortDirection2(sortDirection); switch (restoredSortIndex) { case 1: - tableSorter.setSortByIndex2(SortByIndex.SUMMARY); + tableSorter.setSortByIndex2(TaskComparator.SortByIndex.SUMMARY); break; case 2: - tableSorter.setSortByIndex2(SortByIndex.DATE_CREATED); + tableSorter.setSortByIndex2(TaskComparator.SortByIndex.DATE_CREATED); + break; + case 3: + tableSorter.setSortByIndex2(TaskComparator.SortByIndex.TASK_ID); break; default: - tableSorter.setSortByIndex2(SortByIndex.PRIORITY); + tableSorter.setSortByIndex2(TaskComparator.SortByIndex.PRIORITY); } } } } applyPresentation(taskListMemento.getString(MEMENTO_PRESENTATION)); + Integer sortOrder = taskListMemento.getInteger(MEMENTO_KEY_ROOT_SORT_DIRECTION); + if (sortOrder != null) { + tableSorter.setSortDirectionRootElement(sortOrder); + } else { + tableSorter.setSortDirectionRootElement(TaskListTableSorter.DEFAULT_SORT_DIRECTION); + } } if (tableSorter == null) { diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/wizards/Messages.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/wizards/Messages.java index 2f66e1272..bcca4e213 100644 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/wizards/Messages.java +++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/wizards/Messages.java @@ -107,14 +107,8 @@ public class Messages extends NLS { public static String TaskDataExportWizard_The_zip_file_X_already_exists; - public static String TaskDataExportWizardPage_Activation_history_setting; - public static String TaskDataExportWizardPage_Browse_; - public static String TaskDataExportWizardPage_Contexts_setting; - - public static String TaskDataExportWizardPage_Destination_directory_setting; - public static String TaskDataExportWizardPage_Export_destination; public static String TaskDataExportWizardPage_Export_Mylyn_Task_Data; @@ -127,16 +121,12 @@ public class Messages extends NLS { public static String TaskDataExportWizardPage_Overwrite_existing_files_without_warning; - public static String TaskDataExportWizardPage_Overwrite_setting; - public static String TaskDataExportWizardPage_Please_choose_an_export_destination; public static String TaskDataExportWizardPage_Please_select_which_task_data_to_export; public static String TaskDataExportWizardPage_Select_data_to_export; - public static String TaskDataExportWizardPage_Settings_saved; - public static String TaskDataExportWizardPage_Specify_the_destination_folder_for_task_data; public static String TaskDataExportWizardPage_Task_Activity_History; @@ -145,8 +135,6 @@ public class Messages extends NLS { public static String TaskDataExportWizardPage_Task_List; - public static String TaskDataExportWizardPage_TaskList_setting; - public static String TaskDataImportWizard_could_not_be_found; public static String TaskDataImportWizard_File_exists_; @@ -289,8 +277,6 @@ public class Messages extends NLS { public static String NewTaskWizard_Failed_to_create_new_task_; - public static String NewTaskWizard_The_selected_repository_does_not_support_creating_new_tasks; - public static String NewWebTaskWizard_New_Task; public static String NewWebTaskWizard_This_connector_does_not_provide_a_rich_task_editor_for_creating_tasks; diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/wizards/messages.properties b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/wizards/messages.properties index c12a56f20..eafac8c04 100644 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/wizards/messages.properties +++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/wizards/messages.properties @@ -51,26 +51,20 @@ TaskDataExportWizard_Task_context_files_already_exist_in_X=Task context files al TaskDataExportWizard_The_task_activation_history_file_X_already_exists=The task activation history file {0} already exists. Do you want to overwrite it? TaskDataExportWizard_The_task_list_file_X_already_exists=The task list file {0} already exists. Do you want to overwrite it? TaskDataExportWizard_The_zip_file_X_already_exists=The zip file {0} already exists. Do you want to overwrite it? -TaskDataExportWizardPage_Activation_history_setting=Activation history setting TaskDataExportWizardPage_Browse_=Browse... -TaskDataExportWizardPage_Contexts_setting=Contexts setting -TaskDataExportWizardPage_Destination_directory_setting=Destination directory setting TaskDataExportWizardPage_Export_destination=Export destination TaskDataExportWizardPage_Export_Mylyn_Task_Data=Export Mylyn Task Data TaskDataExportWizardPage_File=File: TaskDataExportWizardPage_Folder=Folder: TaskDataExportWizardPage_Folder_Selection=Folder Selection TaskDataExportWizardPage_Overwrite_existing_files_without_warning=Overwrite existing files without warning -TaskDataExportWizardPage_Overwrite_setting=Overwrite setting TaskDataExportWizardPage_Please_choose_an_export_destination=Please choose an export destination TaskDataExportWizardPage_Please_select_which_task_data_to_export=Please select which task data to export TaskDataExportWizardPage_Select_data_to_export=Select data to export: -TaskDataExportWizardPage_Settings_saved=Settings saved TaskDataExportWizardPage_Specify_the_destination_folder_for_task_data=Specify the destination folder for task data TaskDataExportWizardPage_Task_Activity_History=Task Activity History TaskDataExportWizardPage_Task_Contexts=Task Contexts TaskDataExportWizardPage_Task_List=Task List -TaskDataExportWizardPage_TaskList_setting=TaskList setting TaskDataImportWizard_could_not_be_found=\ could not be found. TaskDataImportWizard_File_exists_=File exists\! @@ -146,7 +140,6 @@ AbstractRepositorySettingsPage_Validating_server_settings=Validating server sett NewTaskWizard_Create_Task=Create Task NewTaskWizard_Error_creating_new_task=Error creating new task NewTaskWizard_Failed_to_create_new_task_=Failed to create new task: -NewTaskWizard_The_selected_repository_does_not_support_creating_new_tasks=The selected repository does not support creating new tasks. NewWebTaskWizard_New_Task=New Task NewWebTaskWizard_This_connector_does_not_provide_a_rich_task_editor_for_creating_tasks=This connector does not provide a rich task editor for creating tasks.\n\nThe error contents have been placed in the clipboard so that you can paste them into the entry form. RepositoryQueryWizard_Edit_Repository_Query=Edit Repository Query |