|
Lines 11-18
Link Here
|
| 11 |
|
11 |
|
| 12 |
package org.eclipse.mylyn.internal.tasks.ui.commands; |
12 |
package org.eclipse.mylyn.internal.tasks.ui.commands; |
| 13 |
|
13 |
|
|
|
14 |
import java.util.Collection; |
| 14 |
import java.util.Collections; |
15 |
import java.util.Collections; |
| 15 |
import java.util.Date; |
16 |
import java.util.Date; |
|
|
17 |
import java.util.Iterator; |
| 16 |
|
18 |
|
| 17 |
import org.eclipse.core.commands.ExecutionEvent; |
19 |
import org.eclipse.core.commands.ExecutionEvent; |
| 18 |
import org.eclipse.core.commands.ExecutionException; |
20 |
import org.eclipse.core.commands.ExecutionException; |
|
Lines 21-31
Link Here
|
| 21 |
import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin; |
23 |
import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin; |
| 22 |
import org.eclipse.mylyn.internal.tasks.ui.actions.ClearOutgoingAction; |
24 |
import org.eclipse.mylyn.internal.tasks.ui.actions.ClearOutgoingAction; |
| 23 |
import org.eclipse.mylyn.internal.tasks.ui.editors.Messages; |
25 |
import org.eclipse.mylyn.internal.tasks.ui.editors.Messages; |
|
|
26 |
import org.eclipse.mylyn.internal.tasks.ui.notifications.TaskAttributeDiff; |
| 27 |
import org.eclipse.mylyn.internal.tasks.ui.notifications.TaskDataDiff; |
| 28 |
import org.eclipse.mylyn.internal.tasks.ui.notifications.TaskListNotifier; |
| 24 |
import org.eclipse.mylyn.internal.tasks.ui.util.TasksUiInternal; |
29 |
import org.eclipse.mylyn.internal.tasks.ui.util.TasksUiInternal; |
| 25 |
import org.eclipse.mylyn.internal.tasks.ui.views.TaskListView; |
30 |
import org.eclipse.mylyn.internal.tasks.ui.views.TaskListView; |
| 26 |
import org.eclipse.mylyn.monitor.ui.MonitorUi; |
31 |
import org.eclipse.mylyn.monitor.ui.MonitorUi; |
| 27 |
import org.eclipse.mylyn.tasks.core.IRepositoryElement; |
32 |
import org.eclipse.mylyn.tasks.core.IRepositoryElement; |
| 28 |
import org.eclipse.mylyn.tasks.core.ITask; |
33 |
import org.eclipse.mylyn.tasks.core.ITask; |
|
|
34 |
import org.eclipse.mylyn.tasks.core.ITask.SynchronizationState; |
| 29 |
|
35 |
|
| 30 |
/** |
36 |
/** |
| 31 |
* @author Steffen Pingel |
37 |
* @author Steffen Pingel |
|
Lines 115-118
Link Here
|
| 115 |
} |
121 |
} |
| 116 |
} |
122 |
} |
| 117 |
|
123 |
|
|
|
124 |
public static class MarkSimilarTasksReadHandler extends AbstractTaskHandler { |
| 125 |
public static final String ID_COMMAND = "org.eclipse.mylyn.tasks.ui.command.markAllSimilarTasksRead"; //$NON-NLS-1$ |
| 126 |
|
| 127 |
@Override |
| 128 |
protected void execute(ExecutionEvent event, ITask currentTask) throws ExecutionException { |
| 129 |
//get incomings of the current task (only first level attributes) |
| 130 |
TaskListNotifier currentNotifier = new TaskListNotifier(TasksUiPlugin.getRepositoryModel(), |
| 131 |
TasksUiPlugin.getTaskDataManager()); |
| 132 |
TaskDataDiff currentDiff = currentNotifier.getDiff(currentTask); |
| 133 |
if (currentDiff != null && TasksUiPlugin.getTaskList() != null) { |
| 134 |
//go through all tasks in tasklist of the given repository |
| 135 |
for (ITask otherTask : TasksUiPlugin.getTaskList().getTasks(currentTask.getRepositoryUrl())) { |
| 136 |
if (otherTask != currentTask |
| 137 |
&& otherTask.getSynchronizationState() == SynchronizationState.INCOMING) { |
| 138 |
boolean isSameChange = false; |
| 139 |
isSameChange = isEqualChangedAttributesSet(currentDiff, otherTask, isSameChange); |
| 140 |
if (isSameChange) { |
| 141 |
TasksUiPlugin.getTaskDataManager().setTaskRead(otherTask, true); |
| 142 |
} |
| 143 |
} |
| 144 |
} |
| 145 |
} |
| 146 |
TasksUiPlugin.getTaskDataManager().setTaskRead(currentTask, true); |
| 147 |
} |
| 148 |
|
| 149 |
private boolean isEqualChangedAttributesSet(TaskDataDiff currentDiff, ITask otherTask, boolean isSameChange) { |
| 150 |
//only check other tasks which have incomings for exactly the same set of changed attributes |
| 151 |
TaskListNotifier otherNotifier = new TaskListNotifier(TasksUiPlugin.getRepositoryModel(), |
| 152 |
TasksUiPlugin.getTaskDataManager()); |
| 153 |
TaskDataDiff otherDiff = otherNotifier.getDiff(otherTask); |
| 154 |
Collection<TaskAttributeDiff> otherChangedAttributes = otherDiff.getChangedAttributes(); |
| 155 |
if (otherDiff != null && currentDiff.getChangedAttributes().size() == otherChangedAttributes.size()) { |
| 156 |
//same diff size, compare individual changed attributes |
| 157 |
Iterator<TaskAttributeDiff> currentIterator = currentDiff.getChangedAttributes().iterator(); |
| 158 |
while (currentIterator.hasNext()) { |
| 159 |
TaskAttributeDiff currentAttributeDiff = currentIterator.next(); |
| 160 |
Iterator<TaskAttributeDiff> otherIterator = otherChangedAttributes.iterator(); |
| 161 |
while (otherIterator.hasNext()) { |
| 162 |
TaskAttributeDiff otherAttributeDiff = otherIterator.next(); |
| 163 |
if (currentAttributeDiff.getNewAttribute() |
| 164 |
.getId() |
| 165 |
.equals(otherAttributeDiff.getNewAttribute().getId())) { |
| 166 |
//found a match, remove from other diff |
| 167 |
otherChangedAttributes.remove(otherAttributeDiff); |
| 168 |
break; |
| 169 |
} |
| 170 |
} |
| 171 |
} |
| 172 |
//if sets are equal, otherChangedAttributes should be empty now |
| 173 |
isSameChange = otherChangedAttributes.isEmpty(); |
| 174 |
//now check comments |
| 175 |
isSameChange = currentDiff.getNewComments().size() == otherDiff.getNewComments().size(); |
| 176 |
} |
| 177 |
return isSameChange; |
| 178 |
} |
| 179 |
} |
| 118 |
} |
180 |
} |