Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskListUiTest.java19
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/MoveToCategoryMenuContributor.java30
2 files changed, 48 insertions, 1 deletions
diff --git a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskListUiTest.java b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskListUiTest.java
index bdb8feca3..1a029b081 100644
--- a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskListUiTest.java
+++ b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskListUiTest.java
@@ -18,6 +18,7 @@ import junit.framework.TestCase;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.mylar.internal.tasks.core.WebTask;
+import org.eclipse.mylar.internal.tasks.ui.MoveToCategoryMenuContributor;
import org.eclipse.mylar.internal.tasks.ui.TaskPriorityFilter;
import org.eclipse.mylar.internal.tasks.ui.TaskUiUtil;
import org.eclipse.mylar.internal.tasks.ui.actions.MarkTaskCompleteAction;
@@ -239,6 +240,24 @@ public class TaskListUiTest extends TestCase {
assertEquals(numListenersBefore, numListenersAfter);
}
+
+ public void testCategoryNameIsShownInMoveToCategoryAction() {
+ String catNameWithAtBefore = "@CatName";
+ String catNameWithAtExpected = "@CatName@";
+ String catNameWithAtActual = "";
+
+ String catNameNoAtBefore = "CatName";
+ String catNameNoAtExpected = "CatName";
+ String catNameNoAtActual = "";
+
+ MoveToCategoryMenuContributor menuContrib = new MoveToCategoryMenuContributor();
+
+ catNameWithAtActual = menuContrib.handleAcceleratorKeys(catNameWithAtBefore);
+ catNameNoAtActual = menuContrib.handleAcceleratorKeys(catNameNoAtBefore);
+
+ assertEquals(catNameWithAtExpected, catNameWithAtActual);
+ assertEquals(catNameNoAtExpected, catNameNoAtActual);
+ }
public boolean checkFilter(int type, TreeItem[] items) {
switch (type) {
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 10108a9f0..ca27c82b5 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
@@ -51,7 +51,8 @@ public class MoveToCategoryMenuContributor implements IDynamicSubMenuContributor
}
}
};
- action.setText(category.getDescription());
+ String text = handleAcceleratorKeys(category.getDescription());
+ action.setText(text);
action.setImageDescriptor(TaskListImages.CATEGORY);
if (selectedElements.size() == 1 && selectedElements.get(0) instanceof AbstractQueryHit) {
AbstractQueryHit hit = (AbstractQueryHit) selectedElements.get(0);
@@ -64,5 +65,32 @@ public class MoveToCategoryMenuContributor implements IDynamicSubMenuContributor
}
return subMenuManager;
}
+
+ /**
+ * public for testing
+ *
+ * Deals with text where user has entered a '@' or tab character but which are not meant to be accelerators.
+ * from: Action#setText:
+ * Note that if you want to insert a '@' character into the text (but no accelerator,
+ * you can simply insert a '@' or a tab at the end of the text.
+ * see Action#setText
+ */
+ public String handleAcceleratorKeys(String text) {
+ if (text == null) {
+ return null;
+ }
+
+ int index = text.lastIndexOf('\t');
+ if (index == -1) {
+ index = text.lastIndexOf('@');
+ }
+ if (index >= 0) {
+ return text.concat("@");
+ }
+ return text;
+ }
+
+
+
}

Back to the top