1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
|
/*******************************************************************************
* Copyright (c) 2004, 2009 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.commands;
import java.util.Collections;
import java.util.Date;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.mylyn.internal.provisional.commons.ui.WorkbenchUtil;
import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin;
import org.eclipse.mylyn.internal.tasks.ui.actions.ClearOutgoingAction;
import org.eclipse.mylyn.internal.tasks.ui.editors.Messages;
import org.eclipse.mylyn.internal.tasks.ui.util.TasksUiInternal;
import org.eclipse.mylyn.internal.tasks.ui.views.TaskListView;
import org.eclipse.mylyn.monitor.ui.MonitorUi;
import org.eclipse.mylyn.tasks.core.IRepositoryElement;
import org.eclipse.mylyn.tasks.core.ITask;
/**
* @author Steffen Pingel
*/
public abstract class MarkTaskHandler extends AbstractTaskHandler {
public static class ClearOutgoingHandler extends AbstractTaskHandler {
@Override
protected void execute(ExecutionEvent event, ITask task) throws ExecutionException {
ClearOutgoingAction action = new ClearOutgoingAction(Collections.singletonList((IRepositoryElement) task));
if (action.isEnabled()) {
action.run();
}
}
}
public static class ClearActiveTimeHandler extends AbstractTaskHandler {
@Override
protected void execute(ExecutionEvent event, ITask task) throws ExecutionException {
if (MessageDialog.openConfirm(WorkbenchUtil.getShell(),
Messages.TaskEditorPlanningPart_Confirm_Activity_Time_Deletion,
Messages.TaskEditorPlanningPart_Do_you_wish_to_reset_your_activity_time_on_this_task_)) {
MonitorUi.getActivityContextManager().removeActivityTime(task.getHandleIdentifier(), 0l,
System.currentTimeMillis());
}
}
}
public static class MarkTaskCompleteHandler extends AbstractTaskHandler {
public static final String ID_COMMAND = "org.eclipse.mylyn.tasks.ui.command.markTaskComplete"; //$NON-NLS-1$
@Override
protected void execute(ExecutionEvent event, ITask task) throws ExecutionException {
if (TasksUiInternal.hasLocalCompletionState(task)) {
task.setCompletionDate(new Date());
TasksUiPlugin.getTaskList().notifyElementChanged(task);
}
}
}
public static class MarkTaskIncompleteHandler extends AbstractTaskHandler {
@Override
protected void execute(ExecutionEvent event, ITask task) throws ExecutionException {
if (TasksUiInternal.hasLocalCompletionState(task)) {
task.setCompletionDate(null);
TasksUiPlugin.getTaskList().notifyElementChanged(task);
}
}
}
public static class MarkTaskReadHandler extends AbstractTaskHandler {
@Override
protected void execute(ExecutionEvent event, ITask task) throws ExecutionException {
TasksUiPlugin.getTaskDataManager().setTaskRead(task, true);
}
}
public static class MarkTaskUnreadHandler extends AbstractTaskHandler {
@Override
protected void execute(ExecutionEvent event, ITask task) throws ExecutionException {
TasksUiPlugin.getTaskDataManager().setTaskRead(task, false);
}
}
public static class MarkTaskReadGoToNextUnreadTaskHandler extends AbstractTaskListViewHandler {
@Override
protected void execute(ExecutionEvent event, TaskListView taskListView, IRepositoryElement item)
throws ExecutionException {
if (item instanceof ITask) {
ITask task = (ITask) item;
TasksUiPlugin.getTaskDataManager().setTaskRead(task, true);
GoToUnreadTaskHandler.execute(event, org.eclipse.mylyn.internal.tasks.ui.util.TreeWalker.Direction.DOWN);
}
}
}
public static class MarkTaskReadGoToPreviousUnreadTaskHandler extends AbstractTaskListViewHandler {
@Override
protected void execute(ExecutionEvent event, TaskListView taskListView, IRepositoryElement item)
throws ExecutionException {
if (item instanceof ITask) {
ITask task = (ITask) item;
TasksUiPlugin.getTaskDataManager().setTaskRead(task, true);
GoToUnreadTaskHandler.execute(event, org.eclipse.mylyn.internal.tasks.ui.util.TreeWalker.Direction.UP);
}
}
}
}
|