Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSam Davis2012-05-29 16:50:02 -0400
committerSam Davis2012-06-04 14:27:32 -0400
commit19ad3705b613a9238847eea385fda36cc3474a41 (patch)
tree1f5356705fc28ad6fdf7fbc3d6bb1404e57adaef
parent87a55743c4752c4c89690f8b6e7b41b826ae6dbf (diff)
downloadorg.eclipse.mylyn.tasks-19ad3705b613a9238847eea385fda36cc3474a41.tar.gz
org.eclipse.mylyn.tasks-19ad3705b613a9238847eea385fda36cc3474a41.tar.xz
org.eclipse.mylyn.tasks-19ad3705b613a9238847eea385fda36cc3474a41.zip
NEW - bug 338013: [patch] mark as read on incoming folder ignores
working sets https://bugs.eclipse.org/bugs/show_bug.cgi?id=338013 Change-Id: Ib06b4fa49989634f045d1b9a66c31e3a5d79e428
-rw-r--r--org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/ui/MarkTaskHandlerTest.java98
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/commands/AbstractTaskHandler.java32
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/commands/MarkTaskHandler.java29
3 files changed, 158 insertions, 1 deletions
diff --git a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/ui/MarkTaskHandlerTest.java b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/ui/MarkTaskHandlerTest.java
index 8a7e9d6f4..fb9124a3f 100644
--- a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/ui/MarkTaskHandlerTest.java
+++ b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/ui/MarkTaskHandlerTest.java
@@ -11,22 +11,39 @@
package org.eclipse.mylyn.tasks.tests.ui;
+import java.util.ArrayList;
+import java.util.Arrays;
import java.util.HashSet;
+import java.util.List;
import junit.framework.TestCase;
import org.eclipse.core.commands.NotEnabledException;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.jface.viewers.IContentProvider;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.mylyn.internal.tasks.core.AbstractTaskContainer;
import org.eclipse.mylyn.internal.tasks.core.LocalTask;
+import org.eclipse.mylyn.internal.tasks.core.RepositoryQuery;
import org.eclipse.mylyn.internal.tasks.core.TaskTask;
+import org.eclipse.mylyn.internal.tasks.ui.ScheduledPresentation;
import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin;
import org.eclipse.mylyn.internal.tasks.ui.commands.MarkTaskHandler.MarkTaskCompleteHandler;
+import org.eclipse.mylyn.internal.tasks.ui.commands.MarkTaskHandler.MarkTaskReadHandler;
+import org.eclipse.mylyn.internal.tasks.ui.views.AbstractTaskListPresentation;
+import org.eclipse.mylyn.internal.tasks.ui.views.TaskListView;
+import org.eclipse.mylyn.internal.tasks.ui.views.TaskScheduleContentProvider.Incoming;
import org.eclipse.mylyn.internal.tasks.ui.workingsets.TaskWorkingSetUpdater;
+import org.eclipse.mylyn.tasks.core.ITask.SynchronizationState;
import org.eclipse.mylyn.tasks.core.TaskRepository;
import org.eclipse.mylyn.tasks.tests.TaskTestUtil;
import org.eclipse.mylyn.tasks.tests.connector.MockRepositoryConnector;
import org.eclipse.ui.IWorkingSet;
+import org.eclipse.ui.IWorkingSetManager;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.handlers.IHandlerService;
+import org.eclipse.ui.internal.Workbench;
/**
* @author Steffen Pingel
@@ -35,6 +52,10 @@ public class MarkTaskHandlerTest extends TestCase {
private IHandlerService handlerService;
+ private IWorkingSet workingSet;
+
+ private IWorkingSetManager workingSetManager;
+
@Override
protected void setUp() throws Exception {
TaskTestUtil.resetTaskListAndRepositories();
@@ -47,11 +68,16 @@ public class MarkTaskHandlerTest extends TestCase {
// TODO figure out which test leaves a filter enabled
TaskWorkingSetUpdater.applyWorkingSetsToAllWindows(new HashSet<IWorkingSet>(0));
TaskTestUtil.openTasksViewInActivePerspective().clearFilters();
+ workingSetManager = Workbench.getInstance().getWorkingSetManager();
}
@Override
protected void tearDown() throws Exception {
TaskTestUtil.resetTaskListAndRepositories();
+ if (workingSet != null) {
+ workingSetManager.removeWorkingSet(workingSet);
+ workingSet = null;
+ }
}
public void testMarkTaskCompleted() throws Exception {
@@ -87,4 +113,76 @@ public class MarkTaskHandlerTest extends TestCase {
}
}
+ public void testMarkWorkingSetIncomingRead() throws Exception {
+ workingSet = createAndSelectWorkingSet();
+ Incoming incoming = setScheduledPresentationAndSelectIncoming();
+ TaskTask taskInWorkingSet = createIncomingTask("1", incoming, workingSet);
+ TaskTask taskNotInWorkingSet = createIncomingTask("2", incoming, null);
+ assertTrue(workingSetContainsTask(taskInWorkingSet));
+ assertFalse(workingSetContainsTask(taskNotInWorkingSet));
+
+ assertTrue(taskInWorkingSet.getSynchronizationState().isIncoming());
+ assertTrue(taskNotInWorkingSet.getSynchronizationState().isIncoming());
+ handlerService.executeCommand(MarkTaskReadHandler.ID_COMMAND, null);
+ assertFalse(taskInWorkingSet.getSynchronizationState().isIncoming());
+ assertTrue(taskNotInWorkingSet.getSynchronizationState().isIncoming());
+ }
+
+ protected boolean workingSetContainsTask(TaskTask taskInWorkingSet) {
+ List<IAdaptable> elements = Arrays.asList(workingSet.getElements());
+ for (AbstractTaskContainer parent : taskInWorkingSet.getParentContainers()) {
+ if (elements.contains(parent)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ protected Incoming setScheduledPresentationAndSelectIncoming() throws Exception {
+ TaskListView taskListView = TaskTestUtil.openTasksViewInActivePerspective();
+ for (AbstractTaskListPresentation presentation : TaskListView.getPresentations()) {
+ if (presentation.getId().equals(ScheduledPresentation.ID)) {
+ taskListView.applyPresentation(presentation);
+ break;
+ }
+ }
+ taskListView.setFocusedMode(true);
+ taskListView.refresh();
+ assertTrue(taskListView.getCurrentPresentation().getId().equals(ScheduledPresentation.ID));
+ // select incoming container
+ IContentProvider contentProvider = taskListView.getViewer().getContentProvider();
+ assertTrue(contentProvider instanceof ITreeContentProvider);
+ for (Object element : ((ITreeContentProvider) contentProvider).getElements(taskListView.getViewSite())) {
+ if (element instanceof Incoming) {
+ taskListView.getViewer().setSelection(new StructuredSelection(element), true);
+ }
+ }
+ assertEquals(taskListView.getSelectedTaskContainers().size(), 1);
+ assertTrue(taskListView.getSelectedTaskContainers().get(0) instanceof Incoming);
+ return (Incoming) taskListView.getSelectedTaskContainers().get(0);
+ }
+
+ protected TaskTask createIncomingTask(String id, Incoming incoming, IWorkingSet workingSet) throws Exception {
+ RepositoryQuery query = TaskTestUtil.createMockQuery("query." + id);
+ TasksUiPlugin.getTaskList().addQuery(query);
+ if (workingSet != null) {
+ workingSet.setElements(new IAdaptable[] { query });
+ }
+ TaskTask task = TaskTestUtil.createMockTask(id);
+ TasksUiPlugin.getTaskList().addTask(task, query);
+ task.setSynchronizationState(SynchronizationState.INCOMING);
+ assertTrue(incoming.getChildren().contains(task));
+ return task;
+ }
+
+ protected IWorkingSet createAndSelectWorkingSet() {
+ IWorkingSet workingSet = workingSetManager.createWorkingSet("Task Working Set", new IAdaptable[] {});
+ workingSet.setId(TaskWorkingSetUpdater.ID_TASK_WORKING_SET);
+ ArrayList<IWorkingSet> list = new ArrayList<IWorkingSet>();
+ list.add(workingSet);
+ TaskWorkingSetUpdater.applyWorkingSetsToAllWindows(list);
+ assertTrue(TaskWorkingSetUpdater.isWorkingSetEnabled(workingSet));
+ return workingSet;
+ }
+
}
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/commands/AbstractTaskHandler.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/commands/AbstractTaskHandler.java
index 976c7f366..6a7a0468b 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/commands/AbstractTaskHandler.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/commands/AbstractTaskHandler.java
@@ -11,6 +11,8 @@
package org.eclipse.mylyn.internal.tasks.ui.commands;
+import java.util.Set;
+
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
@@ -19,6 +21,8 @@ import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.mylyn.internal.tasks.core.AbstractTask;
+import org.eclipse.mylyn.internal.tasks.ui.AbstractTaskListFilter;
+import org.eclipse.mylyn.internal.tasks.ui.views.TaskListView;
import org.eclipse.mylyn.tasks.core.IRepositoryElement;
import org.eclipse.mylyn.tasks.core.ITask;
import org.eclipse.mylyn.tasks.core.ITaskContainer;
@@ -35,6 +39,8 @@ public abstract class AbstractTaskHandler extends AbstractHandler {
protected boolean singleTask;
+ private boolean filterBasedOnActiveTaskList;
+
public AbstractTaskHandler() {
}
@@ -89,11 +95,35 @@ public abstract class AbstractTaskHandler extends AbstractHandler {
protected void execute(ExecutionEvent event, ITaskContainer item) throws ExecutionException {
for (ITask task : item.getChildren()) {
- process(event, task, true);
+ if (!filterBasedOnActiveTaskList || isVisibleInTaskList(item, task)) {
+ process(event, task, true);
+ }
+ }
+ }
+
+ public static boolean isVisibleInTaskList(ITaskContainer item, ITask task) {
+ TaskListView taskListView = TaskListView.getFromActivePerspective();
+ if (taskListView == null) {
+ return false;
}
+ Set<AbstractTaskListFilter> filters = taskListView.getFilters();
+ for (AbstractTaskListFilter filter : filters) {
+ if (!filter.select(item, task)) {
+ return false;
+ }
+ }
+ return true;
}
protected void execute(ExecutionEvent event, ITask task) throws ExecutionException {
}
+ public boolean getFilterBasedOnActiveTaskList() {
+ return filterBasedOnActiveTaskList;
+ }
+
+ protected void setFilterBasedOnActiveTaskList(boolean filterBasedOnActiveTaskList) {
+ this.filterBasedOnActiveTaskList = filterBasedOnActiveTaskList;
+ }
+
}
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/commands/MarkTaskHandler.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/commands/MarkTaskHandler.java
index 7709ec6ee..6fe921b22 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/commands/MarkTaskHandler.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/commands/MarkTaskHandler.java
@@ -33,6 +33,11 @@ import org.eclipse.mylyn.tasks.core.ITask;
public abstract class MarkTaskHandler extends AbstractTaskHandler {
public static class ClearOutgoingHandler extends AbstractTaskHandler {
+
+ public ClearOutgoingHandler() {
+ setFilterBasedOnActiveTaskList(true);
+ }
+
@Override
protected void execute(ExecutionEvent event, ITask task) throws ExecutionException {
ClearOutgoingAction action = new ClearOutgoingAction(Collections.singletonList((IRepositoryElement) task));
@@ -43,6 +48,10 @@ public abstract class MarkTaskHandler extends AbstractTaskHandler {
}
public static class ClearActiveTimeHandler extends AbstractTaskHandler {
+ public ClearActiveTimeHandler() {
+ setFilterBasedOnActiveTaskList(true);
+ }
+
@Override
protected void execute(ExecutionEvent event, ITask task) throws ExecutionException {
if (MessageDialog.openConfirm(WorkbenchUtil.getShell(),
@@ -58,6 +67,10 @@ public abstract class MarkTaskHandler extends AbstractTaskHandler {
public static final String ID_COMMAND = "org.eclipse.mylyn.tasks.ui.command.markTaskComplete"; //$NON-NLS-1$
+ public MarkTaskCompleteHandler() {
+ setFilterBasedOnActiveTaskList(true);
+ }
+
@Override
protected void execute(ExecutionEvent event, ITask task) throws ExecutionException {
if (TasksUiInternal.hasLocalCompletionState(task)) {
@@ -68,6 +81,11 @@ public abstract class MarkTaskHandler extends AbstractTaskHandler {
}
public static class MarkTaskIncompleteHandler extends AbstractTaskHandler {
+
+ public MarkTaskIncompleteHandler() {
+ setFilterBasedOnActiveTaskList(true);
+ }
+
@Override
protected void execute(ExecutionEvent event, ITask task) throws ExecutionException {
if (TasksUiInternal.hasLocalCompletionState(task)) {
@@ -78,6 +96,12 @@ public abstract class MarkTaskHandler extends AbstractTaskHandler {
}
public static class MarkTaskReadHandler extends AbstractTaskHandler {
+ public static final String ID_COMMAND = "org.eclipse.mylyn.tasks.ui.command.markTaskRead"; //$NON-NLS-1$
+
+ public MarkTaskReadHandler() {
+ setFilterBasedOnActiveTaskList(true);
+ }
+
@Override
protected void execute(ExecutionEvent event, ITask task) throws ExecutionException {
TasksUiPlugin.getTaskDataManager().setTaskRead(task, true);
@@ -85,6 +109,11 @@ public abstract class MarkTaskHandler extends AbstractTaskHandler {
}
public static class MarkTaskUnreadHandler extends AbstractTaskHandler {
+
+ public MarkTaskUnreadHandler() {
+ setFilterBasedOnActiveTaskList(true);
+ }
+
@Override
protected void execute(ExecutionEvent event, ITask task) throws ExecutionException {
TasksUiPlugin.getTaskDataManager().setTaskRead(task, false);

Back to the top