Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormkersten2007-06-24 21:18:58 +0000
committermkersten2007-06-24 21:18:58 +0000
commit3db476cfab36b6910675e5355d7ba4df6eed95b8 (patch)
treebc2c0f6557f49e7a6b08c64386cff7815dd9845e
parenta7b588864eea784293269f87f4928f26a7406f44 (diff)
downloadorg.eclipse.mylyn.tasks-3db476cfab36b6910675e5355d7ba4df6eed95b8.tar.gz
org.eclipse.mylyn.tasks-3db476cfab36b6910675e5355d7ba4df6eed95b8.tar.xz
org.eclipse.mylyn.tasks-3db476cfab36b6910675e5355d7ba4df6eed95b8.zip
RESOLVED - bug 165732: Can't mark multiple local and web tasks completed
https://bugs.eclipse.org/bugs/show_bug.cgi?id=165732
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/actions/AbstractChangeCompletionAction.java54
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/actions/MarkTaskCompleteAction.java46
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/actions/MarkTaskIncompleteAction.java43
3 files changed, 118 insertions, 25 deletions
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/actions/AbstractChangeCompletionAction.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/actions/AbstractChangeCompletionAction.java
new file mode 100644
index 000000000..c91172d28
--- /dev/null
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/actions/AbstractChangeCompletionAction.java
@@ -0,0 +1,54 @@
+/*******************************************************************************
+ * Copyright (c) 2004 - 2006 Mylar committers 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
+ *******************************************************************************/
+
+package org.eclipse.mylyn.internal.tasks.ui.actions;
+
+import java.util.List;
+
+import org.eclipse.jface.action.Action;
+import org.eclipse.mylyn.tasks.core.AbstractTask;
+import org.eclipse.mylyn.tasks.core.AbstractTaskContainer;
+
+/**
+ * @author Mik Kersten
+ */
+public class AbstractChangeCompletionAction extends Action {
+
+ protected boolean shouldEnable(List<AbstractTaskContainer> selectedElements) {
+ boolean allLocalTasks = true;
+ for (AbstractTaskContainer abstractTaskContainer : selectedElements) {
+ if (!(abstractTaskContainer instanceof AbstractTask)) {
+ allLocalTasks = false;
+ break;
+ } else if (!((AbstractTask)abstractTaskContainer).isLocal()) {
+ allLocalTasks = false;
+ break;
+ }
+ }
+ return allLocalTasks;
+ }
+
+ protected String generateMessage(List<AbstractTask> toComplete, String status) {
+ String message = "Mark selected local tasks " + status + "?\n\n";
+ int i = 0;
+ for (AbstractTask task : toComplete) {
+ i++;
+ if (i < 20) {
+ message += " ";
+ if (task.getTaskKey() != null) {
+ message += task.getTaskKey() + ": ";
+ }
+ message += task.getSummary() + "\n";
+ } else {
+ message += "...";
+ break;
+ }
+ }
+ return message;
+ }
+}
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/actions/MarkTaskCompleteAction.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/actions/MarkTaskCompleteAction.java
index aaab8ee19..2a634d09e 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/actions/MarkTaskCompleteAction.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/actions/MarkTaskCompleteAction.java
@@ -11,18 +11,23 @@
package org.eclipse.mylyn.internal.tasks.ui.actions;
+import java.util.ArrayList;
import java.util.List;
import org.eclipse.jface.action.Action;
+import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.mylyn.internal.tasks.ui.TasksUiImages;
import org.eclipse.mylyn.tasks.core.AbstractTask;
import org.eclipse.mylyn.tasks.core.AbstractTaskContainer;
+import org.eclipse.mylyn.tasks.core.TaskList;
import org.eclipse.mylyn.tasks.ui.TasksUiPlugin;
+import org.eclipse.ui.PlatformUI;
/**
* @author Mik Kersten
+ * @author Eugene Kuleshov
*/
-public class MarkTaskCompleteAction extends Action {
+public class MarkTaskCompleteAction extends AbstractChangeCompletionAction {
public static final String ID = "org.eclipse.mylyn.tasklist.actions.mark.completed";
@@ -36,26 +41,39 @@ public class MarkTaskCompleteAction extends Action {
setToolTipText("Mark " + ACTION_NAME);
setId(ID);
setImageDescriptor(TasksUiImages.TASK_COMPLETE);
- if (selectedElements.size() == 1 && (selectedElements.get(0) instanceof AbstractTask)) {
- AbstractTask task = (AbstractTask) selectedElements.get(0);
-// if (task instanceof WebTask) {
-// setEnabled(true);
-// } else {
- setEnabled(task.isLocal());
-// }
-// } else if (selectedElements.size() == 1 && (selectedElements.get(0) instanceof WebQueryHit)) {
-// setEnabled(true);
- } else {
- setEnabled(false);
- }
+
+ setEnabled(shouldEnable(selectedElements));
+// if (allLocalTasks) {
+// setEnabled(selectedElements.size() > 0);
+// }
}
@Override
public void run() {
+ List<AbstractTask> toComplete = new ArrayList<AbstractTask>();
for (Object selectedObject : selectedElements) {
if (selectedObject instanceof AbstractTask) {
- TasksUiPlugin.getTaskListManager().getTaskList().markComplete(((AbstractTask) selectedObject), true);
+ AbstractTask task = (AbstractTask) selectedObject;
+ if (task.isLocal()) {
+ toComplete.add(task);
+ }
+ }
+ }
+ if (toComplete.isEmpty()) {
+ return;
+ } else if (toComplete.size() > 1) {
+ String message = generateMessage(toComplete, ACTION_NAME);
+ boolean markConfirmed = MessageDialog.openQuestion(PlatformUI.getWorkbench()
+ .getActiveWorkbenchWindow()
+ .getShell(), "Confirm Mark Completed", message);
+ if (!markConfirmed) {
+ return;
}
}
+
+ TaskList taskList = TasksUiPlugin.getTaskListManager().getTaskList();
+ for (AbstractTask task : toComplete) {
+ taskList.markComplete(task, true);
+ }
}
}
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/actions/MarkTaskIncompleteAction.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/actions/MarkTaskIncompleteAction.java
index 221092865..2340a58b0 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/actions/MarkTaskIncompleteAction.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/actions/MarkTaskIncompleteAction.java
@@ -11,18 +11,24 @@
package org.eclipse.mylyn.internal.tasks.ui.actions;
+import java.util.ArrayList;
import java.util.List;
import org.eclipse.jface.action.Action;
+import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.mylyn.internal.tasks.ui.TasksUiImages;
import org.eclipse.mylyn.tasks.core.AbstractTask;
import org.eclipse.mylyn.tasks.core.AbstractTaskContainer;
+import org.eclipse.mylyn.tasks.core.TaskList;
import org.eclipse.mylyn.tasks.ui.TasksUiPlugin;
+import org.eclipse.ui.PlatformUI;
/**
- * @author Mik Kersten and Ken Sueda
+ * @author Mik Kersten and
+ * @author Ken Sueda
+ * @author Eugene Kuleshov
*/
-public class MarkTaskIncompleteAction extends Action {
+public class MarkTaskIncompleteAction extends AbstractChangeCompletionAction {
private static final String ACTION_NAME = "Incomplete";
@@ -36,22 +42,37 @@ public class MarkTaskIncompleteAction extends Action {
setToolTipText("Mark " + ACTION_NAME);
setId(ID);
setImageDescriptor(TasksUiImages.TASK_INCOMPLETE);
- if (selectedElements.size() == 1 && (selectedElements.get(0) instanceof AbstractTask)) {
- AbstractTask task = (AbstractTask) selectedElements.get(0);
- setEnabled(task.isLocal());
-// } else if (selectedElements.size() == 1 && (selectedElements.get(0) instanceof WebQueryHit)) {
-// setEnabled(true);
- } else {
- setEnabled(false);
- }
+
+ setEnabled(shouldEnable(selectedElements));
}
@Override
public void run() {
+ List<AbstractTask> toComplete = new ArrayList<AbstractTask>();
for (Object selectedObject : selectedElements) {
if (selectedObject instanceof AbstractTask) {
- TasksUiPlugin.getTaskListManager().getTaskList().markComplete(((AbstractTask) selectedObject), false);
+ AbstractTask task = (AbstractTask) selectedObject;
+ if (task.isLocal()) {
+ toComplete.add(task);
+ }
}
}
+ if (toComplete.isEmpty()) {
+ return;
+ } else if (toComplete.size() > 1) {
+
+ String message = generateMessage(toComplete, ACTION_NAME);
+ boolean markConfirmed = MessageDialog.openQuestion(PlatformUI.getWorkbench()
+ .getActiveWorkbenchWindow()
+ .getShell(), "Confirm Mark Incompleted", message);
+ if (!markConfirmed) {
+ return;
+ }
+ }
+
+ TaskList taskList = TasksUiPlugin.getTaskListManager().getTaskList();
+ for (AbstractTask task : toComplete) {
+ taskList.markComplete(task, false);
+ }
}
}

Back to the top