Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorspingel2009-02-26 18:58:41 -0500
committerspingel2009-02-26 18:58:41 -0500
commit472ac97c709a154893f320dcb0484c8ec59d6b07 (patch)
tree7418c68a7045a82ade5682279a1c99e082144a8b
parent963586f7cff598b709041780a22f1c6dd6598320 (diff)
downloadorg.eclipse.mylyn.tasks-472ac97c709a154893f320dcb0484c8ec59d6b07.tar.gz
org.eclipse.mylyn.tasks-472ac97c709a154893f320dcb0484c8ec59d6b07.tar.xz
org.eclipse.mylyn.tasks-472ac97c709a154893f320dcb0484c8ec59d6b07.zip
NEW - bug 266393: List of categories is out of order when moving tasks
https://bugs.eclipse.org/bugs/show_bug.cgi?id=266393
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/MoveToCategoryMenuContributor.java3
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/TaskEditorActionPart.java16
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/util/TaskContainerComparator.java34
3 files changed, 38 insertions, 15 deletions
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/MoveToCategoryMenuContributor.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/MoveToCategoryMenuContributor.java
index 40e11392d..5c3395654 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/MoveToCategoryMenuContributor.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/MoveToCategoryMenuContributor.java
@@ -25,6 +25,7 @@ import org.eclipse.mylyn.internal.tasks.core.AbstractTaskCategory;
import org.eclipse.mylyn.internal.tasks.core.TaskCategory;
import org.eclipse.mylyn.internal.tasks.core.UnmatchedTaskContainer;
import org.eclipse.mylyn.internal.tasks.ui.actions.NewCategoryAction;
+import org.eclipse.mylyn.internal.tasks.ui.util.TaskContainerComparator;
import org.eclipse.mylyn.internal.tasks.ui.util.TasksUiInternal;
import org.eclipse.mylyn.tasks.core.IRepositoryElement;
import org.eclipse.mylyn.tasks.core.ITask;
@@ -49,7 +50,7 @@ public class MoveToCategoryMenuContributor implements IDynamicSubMenuContributor
List<AbstractTaskCategory> categories = new ArrayList<AbstractTaskCategory>(TasksUiInternal.getTaskList()
.getCategories());
- Collections.sort(categories);
+ Collections.sort(categories, new TaskContainerComparator());
for (final AbstractTaskCategory category : categories) {
if (!(category instanceof UnmatchedTaskContainer)) {
String text = handleAcceleratorKeys(category.getSummary());
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/TaskEditorActionPart.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/TaskEditorActionPart.java
index 90c506c93..9ceca76c4 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/TaskEditorActionPart.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/TaskEditorActionPart.java
@@ -15,15 +15,13 @@ package org.eclipse.mylyn.internal.tasks.ui.editors;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Collections;
-import java.util.Comparator;
import java.util.List;
import org.eclipse.jface.layout.GridDataFactory;
import org.eclipse.mylyn.internal.provisional.commons.ui.CommonImages;
import org.eclipse.mylyn.internal.tasks.core.AbstractTaskCategory;
-import org.eclipse.mylyn.internal.tasks.core.AbstractTaskContainer;
import org.eclipse.mylyn.internal.tasks.core.ITaskList;
-import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin;
+import org.eclipse.mylyn.internal.tasks.ui.util.TaskContainerComparator;
import org.eclipse.mylyn.internal.tasks.ui.util.TasksUiInternal;
import org.eclipse.mylyn.internal.tasks.ui.views.TaskListView;
import org.eclipse.mylyn.tasks.core.IRepositoryElement;
@@ -188,17 +186,7 @@ public class TaskEditorActionPart extends AbstractTaskEditorPart {
categoryChooser.setFont(TEXT_FONT);
ITaskList taskList = TasksUiInternal.getTaskList();
final List<AbstractTaskCategory> categories = new ArrayList<AbstractTaskCategory>(taskList.getCategories());
- Collections.sort(categories, new Comparator<AbstractTaskContainer>() {
- public int compare(AbstractTaskContainer c1, AbstractTaskContainer c2) {
- if (c1.equals(TasksUiPlugin.getTaskList().getDefaultCategory())) {
- return -1;
- } else if (c2.equals(TasksUiPlugin.getTaskList().getDefaultCategory())) {
- return 1;
- } else {
- return c1.getSummary().compareToIgnoreCase(c2.getSummary());
- }
- }
- });
+ Collections.sort(categories, new TaskContainerComparator());
AbstractTaskCategory selectedCategory = TasksUiInternal.getSelectedCategory(TaskListView.getFromActivePerspective());
int i = 0;
int selectedIndex = 0;
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/util/TaskContainerComparator.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/util/TaskContainerComparator.java
new file mode 100644
index 000000000..0a1d866ba
--- /dev/null
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/util/TaskContainerComparator.java
@@ -0,0 +1,34 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2008 Tasktop Technologies and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Tasktop Technologies - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.mylyn.internal.tasks.ui.util;
+
+import java.util.Comparator;
+
+import org.eclipse.mylyn.internal.tasks.core.AbstractTaskContainer;
+import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin;
+
+/**
+ * @author Steffen Pingel
+ */
+public class TaskContainerComparator implements Comparator<AbstractTaskContainer> {
+
+ public int compare(AbstractTaskContainer c1, AbstractTaskContainer c2) {
+ if (c1.equals(TasksUiPlugin.getTaskList().getDefaultCategory())) {
+ return -1;
+ } else if (c2.equals(TasksUiPlugin.getTaskList().getDefaultCategory())) {
+ return 1;
+ } else {
+ return c1.getSummary().compareToIgnoreCase(c2.getSummary());
+ }
+ }
+
+}

Back to the top