Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorspingel2011-03-01 09:08:47 +0000
committerspingel2011-03-01 09:08:47 +0000
commit641bae63d3bcc1df5ee5173007128f8b6e57eca9 (patch)
tree7713c0a93fc812c0a3f369b27f39ebbb4ede92f6 /org.eclipse.mylyn.tasks.core
parentba8aaff78aadbc9f6e833e03fa64552e09bbc532 (diff)
downloadorg.eclipse.mylyn.tasks-641bae63d3bcc1df5ee5173007128f8b6e57eca9.tar.gz
org.eclipse.mylyn.tasks-641bae63d3bcc1df5ee5173007128f8b6e57eca9.tar.xz
org.eclipse.mylyn.tasks-641bae63d3bcc1df5ee5173007128f8b6e57eca9.zip
NEW - bug 286963: [api] add support for ignoring incoming notification on specified fields
https://bugs.eclipse.org/bugs/show_bug.cgi?id=286963
Diffstat (limited to 'org.eclipse.mylyn.tasks.core')
-rw-r--r--org.eclipse.mylyn.tasks.core/plugin.xml1
-rw-r--r--org.eclipse.mylyn.tasks.core/schema/synchronizationParticipants.exsd116
-rw-r--r--org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/ITasksCoreConstants.java2
-rw-r--r--org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/data/SynchronizationManger.java117
-rw-r--r--org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/data/TaskAttributeDiff.java133
-rw-r--r--org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/data/TaskDataDiff.java149
-rw-r--r--org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/data/TaskDataManager.java25
-rw-r--r--org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/data/TaskDataStore.java6
-rw-r--r--org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/data/ITaskAttributeDiff.java26
-rw-r--r--org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/data/ITaskDataDiff.java36
-rw-r--r--org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/sync/SynchronizationParticipant.java41
11 files changed, 647 insertions, 5 deletions
diff --git a/org.eclipse.mylyn.tasks.core/plugin.xml b/org.eclipse.mylyn.tasks.core/plugin.xml
index 266cc1c0d..8d2161501 100644
--- a/org.eclipse.mylyn.tasks.core/plugin.xml
+++ b/org.eclipse.mylyn.tasks.core/plugin.xml
@@ -12,6 +12,7 @@
<plugin>
<extension-point id="templates" name="templates" schema="schema/templates.exsd"/>
+ <extension-point id="synchronizationParticipants" name="Synchronization Participants" schema="schema/synchronizationParticipants.exsd"/>
<!--
<extension
diff --git a/org.eclipse.mylyn.tasks.core/schema/synchronizationParticipants.exsd b/org.eclipse.mylyn.tasks.core/schema/synchronizationParticipants.exsd
new file mode 100644
index 000000000..e80ab468b
--- /dev/null
+++ b/org.eclipse.mylyn.tasks.core/schema/synchronizationParticipants.exsd
@@ -0,0 +1,116 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.eclipse.mylyn.tasks.core" xmlns="http://www.w3.org/2001/XMLSchema">
+<annotation>
+ <appInfo>
+ <meta.schema plugin="org.eclipse.mylyn.tasks.core" id="synchronizationParticipants" name="Synchronization Participants"/>
+ </appInfo>
+ <documentation>
+ [Enter description of this extension point.]
+ </documentation>
+ </annotation>
+
+ <element name="extension">
+ <annotation>
+ <appInfo>
+ <meta.element />
+ </appInfo>
+ </annotation>
+ <complexType>
+ <choice>
+ <element ref="participant" minOccurs="1" maxOccurs="unbounded"/>
+ </choice>
+ <attribute name="point" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appInfo>
+ <meta.attribute translatable="true"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="participant">
+ <complexType>
+ <attribute name="id" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="connectorKind" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="class" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appInfo>
+ <meta.attribute kind="java" basedOn="org.eclipse.mylyn.tasks.core.sync.TaskSynchronizationParticipant:"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="since"/>
+ </appInfo>
+ <documentation>
+ 3.5
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="examples"/>
+ </appInfo>
+ <documentation>
+ [Enter extension point usage example here.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="apiinfo"/>
+ </appInfo>
+ <documentation>
+ [Enter API information here.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="implementation"/>
+ </appInfo>
+ <documentation>
+ [Enter information about supplied implementation of this extension point.]
+ </documentation>
+ </annotation>
+
+
+</schema>
diff --git a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/ITasksCoreConstants.java b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/ITasksCoreConstants.java
index 7f3894a69..62e61444d 100644
--- a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/ITasksCoreConstants.java
+++ b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/ITasksCoreConstants.java
@@ -61,6 +61,8 @@ public interface ITasksCoreConstants {
public static final String ATTRIBUTE_TASK_EXTENDED_TOOLTIP = "task.common.extended.tooltip"; //$NON-NLS-1$
+ public static final String ATTRIBUTE_TASK_SUPPRESS_INCOMING = "task.common.suppress.incoming"; //$NON-NLS-1$
+
public static final String PROPERTY_USE_SECURE_STORAGE = "org.eclipse.mylyn.tasklist.repositories.configuration.securestorage"; //$NON-NLS-1$
/**
diff --git a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/data/SynchronizationManger.java b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/data/SynchronizationManger.java
new file mode 100644
index 000000000..a31a5a3d9
--- /dev/null
+++ b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/data/SynchronizationManger.java
@@ -0,0 +1,117 @@
+/*******************************************************************************
+ * Copyright (c) 2011 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.core.data;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtension;
+import org.eclipse.core.runtime.IExtensionPoint;
+import org.eclipse.core.runtime.IExtensionRegistry;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.MultiStatus;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.mylyn.commons.core.StatusHandler;
+import org.eclipse.mylyn.internal.tasks.core.ITasksCoreConstants;
+import org.eclipse.mylyn.internal.tasks.core.RepositoryModel;
+import org.eclipse.mylyn.tasks.core.data.TaskData;
+import org.eclipse.mylyn.tasks.core.sync.SynchronizationParticipant;
+import org.eclipse.osgi.util.NLS;
+
+/**
+ * @author Steffen Pingel
+ */
+public class SynchronizationManger {
+
+ private final Map<String, List<SynchronizationParticipant>> participantsByConnectorKind = new HashMap<String, List<SynchronizationParticipant>>();
+
+ private final RepositoryModel model;
+
+ public SynchronizationManger(RepositoryModel model) {
+ Assert.isNotNull(model);
+ this.model = model;
+ }
+
+ private List<SynchronizationParticipant> loadParticipants(String connectorKind) {
+ Assert.isNotNull(connectorKind);
+ MultiStatus status = new MultiStatus(ITasksCoreConstants.ID_PLUGIN, 0,
+ "Synchronization participants failed to load.", null); //$NON-NLS-1$
+
+ List<SynchronizationParticipant> result = new ArrayList<SynchronizationParticipant>();
+
+ IExtensionRegistry registry = Platform.getExtensionRegistry();
+ IExtensionPoint connectorsExtensionPoint = registry.getExtensionPoint(ITasksCoreConstants.ID_PLUGIN
+ + ".synchronizationParticipants"); //$NON-NLS-1$
+ IExtension[] extensions = connectorsExtensionPoint.getExtensions();
+ for (IExtension extension : extensions) {
+ IConfigurationElement[] elements = extension.getConfigurationElements();
+ for (IConfigurationElement element : elements) {
+ String value = element.getAttribute("connectorKind"); //$NON-NLS-1$
+ if (value == null || connectorKind.equals(value)) {
+ try {
+ Object object = element.createExecutableExtension("class"); //$NON-NLS-1$
+ if (object instanceof SynchronizationParticipant) {
+ result.add((SynchronizationParticipant) object);
+ } else {
+ status.add(new Status(
+ IStatus.ERROR,
+ ITasksCoreConstants.ID_PLUGIN,
+ NLS.bind(
+ "Connector core ''{0}'' does not extend expected class for extension contributed by {1}", //$NON-NLS-1$
+ object.getClass().getCanonicalName(), element.getContributor().getName())));
+ }
+ } catch (Throwable e) {
+ status.add(new Status(
+ IStatus.ERROR,
+ ITasksCoreConstants.ID_PLUGIN,
+ NLS.bind(
+ "Connector core failed to load for extension contributed by {0}", element.getContributor().getName()), e)); //$NON-NLS-1$
+ }
+ }
+ }
+ }
+
+ if (!status.isOK()) {
+ StatusHandler.log(status);
+ }
+
+ return result;
+ }
+
+ public synchronized boolean hasParticipants(String connectorKind) {
+ return getParticipants(connectorKind) != null;
+ }
+
+ public synchronized List<SynchronizationParticipant> getParticipants(String connectorKind) {
+ List<SynchronizationParticipant> participants = participantsByConnectorKind.get(connectorKind);
+ if (participants == null) {
+ participants = loadParticipants(connectorKind);
+ participantsByConnectorKind.put(connectorKind, participants);
+ }
+ return participants;
+ }
+
+ public TaskDataDiff processUpdate(TaskData newTaskData, TaskData oldTaskData, IProgressMonitor monitor) {
+ TaskDataDiff diff = new TaskDataDiff(model, newTaskData, oldTaskData);
+ for (SynchronizationParticipant participant : getParticipants(newTaskData.getConnectorKind())) {
+ participant.processUpdate(diff, monitor);
+ }
+ return diff;
+ }
+
+}
diff --git a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/data/TaskAttributeDiff.java b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/data/TaskAttributeDiff.java
new file mode 100644
index 000000000..ff75814dc
--- /dev/null
+++ b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/data/TaskAttributeDiff.java
@@ -0,0 +1,133 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2008 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.core.data;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.mylyn.tasks.core.data.ITaskAttributeDiff;
+import org.eclipse.mylyn.tasks.core.data.TaskAttribute;
+
+/**
+ * @author Steffen Pingel
+ */
+public class TaskAttributeDiff implements ITaskAttributeDiff {
+
+ private String attributeId;
+
+ private final TaskAttribute newAttribute;
+
+ private final List<String> newValues;
+
+ private final TaskAttribute oldAttribute;
+
+ private final List<String> oldValues;
+
+ public TaskAttributeDiff(TaskAttribute oldAttribute, TaskAttribute newAttribute) {
+ Assert.isTrue(oldAttribute != null || newAttribute != null);
+ this.oldAttribute = oldAttribute;
+ this.newAttribute = newAttribute;
+ if (oldAttribute != null) {
+ this.oldValues = oldAttribute.getTaskData().getAttributeMapper().getValueLabels(oldAttribute);
+ this.attributeId = oldAttribute.getId();
+ } else {
+ this.oldValues = Collections.emptyList();
+ }
+ if (newAttribute != null) {
+ this.newValues = newAttribute.getTaskData().getAttributeMapper().getValueLabels(newAttribute);
+ this.attributeId = newAttribute.getId();
+ } else {
+ this.newValues = Collections.emptyList();
+ }
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ TaskAttributeDiff other = (TaskAttributeDiff) obj;
+ if (attributeId == null) {
+ if (other.attributeId != null) {
+ return false;
+ }
+ } else if (!attributeId.equals(other.attributeId)) {
+ return false;
+ }
+ return true;
+ }
+
+ public List<String> getAddedValues() {
+ List<String> result = new ArrayList<String>(getNewValues());
+ if (getOldValues() != null) {
+ result.removeAll(getOldValues());
+ }
+ return result;
+ }
+
+ public TaskAttribute getNewAttribute() {
+ return newAttribute;
+ }
+
+ public List<String> getNewValues() {
+ return newValues;
+ }
+
+ public TaskAttribute getOldAttribute() {
+ return oldAttribute;
+ }
+
+ public List<String> getOldValues() {
+ return oldValues;
+ }
+
+ public List<String> getRemovedValues() {
+ List<String> result = new ArrayList<String>(getOldValues());
+ if (getNewValues() != null) {
+ result.removeAll(getNewValues());
+ }
+ return result;
+ }
+
+ public boolean hasChanges() {
+ return !oldValues.equals(newValues);
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((attributeId == null) ? 0 : attributeId.hashCode());
+ return result;
+ }
+
+ public String getLabel() {
+ if (newAttribute != null) {
+ return newAttribute.getTaskData().getAttributeMapper().getLabel(newAttribute);
+ } else {
+ return oldAttribute.getTaskData().getAttributeMapper().getLabel(oldAttribute);
+ }
+ }
+
+ public String getAttributeId() {
+ return attributeId;
+ }
+
+} \ No newline at end of file
diff --git a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/data/TaskDataDiff.java b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/data/TaskDataDiff.java
new file mode 100644
index 000000000..10ec04c25
--- /dev/null
+++ b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/data/TaskDataDiff.java
@@ -0,0 +1,149 @@
+/*******************************************************************************
+ * 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.core.data;
+
+import java.util.Collection;
+import java.util.LinkedHashSet;
+import java.util.Set;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.mylyn.internal.tasks.core.RepositoryModel;
+import org.eclipse.mylyn.tasks.core.ITaskComment;
+import org.eclipse.mylyn.tasks.core.TaskRepository;
+import org.eclipse.mylyn.tasks.core.data.ITaskAttributeDiff;
+import org.eclipse.mylyn.tasks.core.data.ITaskDataDiff;
+import org.eclipse.mylyn.tasks.core.data.TaskAttribute;
+import org.eclipse.mylyn.tasks.core.data.TaskData;
+
+/**
+ * @author Steffen Pingel
+ */
+public class TaskDataDiff implements ITaskDataDiff {
+
+ private final String[] ATTRIBUTES_IDS = new String[] { TaskAttribute.SUMMARY, TaskAttribute.DESCRIPTION,
+ TaskAttribute.PRODUCT, TaskAttribute.PRIORITY, TaskAttribute.USER_ASSIGNED, TaskAttribute.STATUS, };
+
+ private final TaskData newTaskData;
+
+ private final TaskData oldTaskData;
+
+ private final Set<ITaskComment> newComments = new LinkedHashSet<ITaskComment>();
+
+ private final Set<ITaskAttributeDiff> changedAttributes = new LinkedHashSet<ITaskAttributeDiff>();
+
+ private final RepositoryModel repositoryModel;
+
+ public boolean hasChanged;
+
+ private final TaskRepository repository;
+
+ public TaskDataDiff(RepositoryModel repositoryModel, TaskData newTaskData, TaskData oldTaskData) {
+ Assert.isNotNull(repositoryModel);
+ Assert.isNotNull(newTaskData);
+ this.repositoryModel = repositoryModel;
+ this.repository = newTaskData.getAttributeMapper().getTaskRepository();
+ this.newTaskData = newTaskData;
+ this.oldTaskData = oldTaskData;
+ this.hasChanged = true;
+ parse();
+ }
+
+ public boolean hasChanged() {
+ return hasChanged;
+ }
+
+ public void setHasChanged(boolean hasChanged) {
+ this.hasChanged = hasChanged;
+ }
+
+ public TaskRepository getRepository() {
+ return repository;
+ }
+
+ public TaskData getOldTaskData() {
+ return oldTaskData;
+ }
+
+ public TaskData getNewTaskData() {
+ return newTaskData;
+ }
+
+ public Collection<ITaskComment> getNewComments() {
+ return newComments;
+ }
+
+ public Collection<ITaskAttributeDiff> getChangedAttributes() {
+ return changedAttributes;
+ }
+
+ private void parse() {
+ for (String attributeId : ATTRIBUTES_IDS) {
+ TaskAttribute newAttribute = newTaskData.getRoot().getMappedAttribute(attributeId);
+ TaskAttribute oldAttribute = null;
+ if (oldTaskData != null) {
+ oldAttribute = oldTaskData.getRoot().getMappedAttribute(attributeId);
+ }
+ if (oldAttribute == null && newAttribute == null) {
+ continue;
+ }
+ addChangedAttribute(oldAttribute, newAttribute, true);
+ }
+
+ // other attributes that have changed on newTaskData
+ for (TaskAttribute newAttribute : newTaskData.getRoot().getAttributes().values()) {
+ TaskAttribute oldAttribute = null;
+ if (oldTaskData != null) {
+ oldAttribute = oldTaskData.getRoot().getMappedAttribute(newAttribute.getPath());
+ }
+ addChangedAttribute(oldAttribute, newAttribute, false);
+ }
+ // other attributes that have been removed from newTaskData
+ if (oldTaskData != null) {
+ for (TaskAttribute oldAttribute : oldTaskData.getRoot().getAttributes().values()) {
+ TaskAttribute newAttribute = newTaskData.getRoot().getMappedAttribute(oldAttribute.getPath());
+ if (newAttribute == null) {
+ addChangedAttribute(oldAttribute, newAttribute, false);
+ }
+ }
+ }
+ }
+
+ private void addChangedAttribute(TaskAttribute oldAttribute, TaskAttribute newAttribute, boolean ignoreKind) {
+ TaskAttribute attribute;
+ if (newAttribute != null) {
+ attribute = newAttribute;
+ } else {
+ attribute = oldAttribute;
+ }
+ String type = attribute.getMetaData().getType();
+ if (TaskAttribute.TYPE_COMMENT.equals(type)) {
+ addChangedComment(oldAttribute, newAttribute);
+ } else if (TaskAttribute.TYPE_OPERATION.equals(type)) {
+ // ignore
+ } else if (ignoreKind || attribute.getMetaData().getKind() != null) {
+ TaskAttributeDiff diff = new TaskAttributeDiff(oldAttribute, newAttribute);
+ if (diff.hasChanges()) {
+ changedAttributes.add(diff);
+ }
+ }
+ }
+
+ private void addChangedComment(TaskAttribute oldAttribute, TaskAttribute newAttribute) {
+ if (oldAttribute == null) {
+ ITaskComment comment = repositoryModel.createTaskComment(newAttribute);
+ if (comment != null) {
+ newComments.add(comment);
+ }
+ }
+ }
+
+}
diff --git a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/data/TaskDataManager.java b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/data/TaskDataManager.java
index bf4113219..129910e8a 100644
--- a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/data/TaskDataManager.java
+++ b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/data/TaskDataManager.java
@@ -35,8 +35,8 @@ import org.eclipse.mylyn.internal.tasks.core.TaskTask;
import org.eclipse.mylyn.tasks.core.AbstractRepositoryConnector;
import org.eclipse.mylyn.tasks.core.IRepositoryManager;
import org.eclipse.mylyn.tasks.core.ITask;
-import org.eclipse.mylyn.tasks.core.TaskRepository;
import org.eclipse.mylyn.tasks.core.ITask.SynchronizationState;
+import org.eclipse.mylyn.tasks.core.TaskRepository;
import org.eclipse.mylyn.tasks.core.data.ITaskDataManager;
import org.eclipse.mylyn.tasks.core.data.ITaskDataWorkingCopy;
import org.eclipse.mylyn.tasks.core.data.TaskData;
@@ -72,12 +72,15 @@ public class TaskDataManager implements ITaskDataManager {
private final List<ITaskDataManagerListener> listeners = new CopyOnWriteArrayList<ITaskDataManagerListener>();
+ private final SynchronizationManger synchronizationManger;
+
public TaskDataManager(TaskDataStore taskDataStore, IRepositoryManager repositoryManager, TaskList taskList,
- TaskActivityManager taskActivityManager) {
+ TaskActivityManager taskActivityManager, SynchronizationManger synchronizationManger) {
this.taskDataStore = taskDataStore;
this.repositoryManager = repositoryManager;
this.taskList = taskList;
this.taskActivityManager = taskActivityManager;
+ this.synchronizationManger = synchronizationManger;
}
public void addListener(ITaskDataManagerListener listener) {
@@ -188,9 +191,11 @@ public class TaskDataManager implements ITaskDataManager {
if (taskDataChanged || user) {
taskList.run(new ITaskListRunnable() {
public void execute(IProgressMonitor monitor) throws CoreException {
+ TaskDataState state = null;
if (!taskData.isPartial()) {
File file = getMigratedFile(task, task.getConnectorKind());
- taskDataStore.putTaskData(ensurePathExists(file), taskData, task.isMarkReadPending(), user);
+ state = taskDataStore.putTaskData(ensurePathExists(file), taskData, task.isMarkReadPending(),
+ user);
task.setMarkReadPending(false);
event.setTaskDataUpdated(true);
}
@@ -199,12 +204,26 @@ public class TaskDataManager implements ITaskDataManager {
event.setTaskChanged(taskChanged);
if (taskDataChanged) {
+ String suppressIncoming = null;
+ if (synchronizationManger.hasParticipants(task.getConnectorKind())) {
+ // determine whether to show an incoming
+ if (state == null) {
+ File file = getMigratedFile(task, task.getConnectorKind());
+ state = taskDataStore.getTaskDataState(ensurePathExists(file));
+ }
+ TaskData lastReadData = (state != null) ? state.getLastReadData() : null;
+ TaskDataDiff diff = synchronizationManger.processUpdate(taskData, lastReadData, monitor);
+ suppressIncoming = Boolean.toString(!diff.hasChanged());
+ }
+
switch (task.getSynchronizationState()) {
case OUTGOING:
task.setSynchronizationState(SynchronizationState.CONFLICT);
+ task.setAttribute(ITasksCoreConstants.ATTRIBUTE_TASK_SUPPRESS_INCOMING, suppressIncoming);
break;
case SYNCHRONIZED:
task.setSynchronizationState(SynchronizationState.INCOMING);
+ task.setAttribute(ITasksCoreConstants.ATTRIBUTE_TASK_SUPPRESS_INCOMING, suppressIncoming);
break;
}
}
diff --git a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/data/TaskDataStore.java b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/data/TaskDataStore.java
index b08ef73d9..66dd96a81 100644
--- a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/data/TaskDataStore.java
+++ b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/data/TaskDataStore.java
@@ -68,7 +68,7 @@ public class TaskDataStore {
writeState(file, state);
}
- public synchronized void putTaskData(File file, TaskData data, boolean setLastRead, boolean user)
+ public synchronized TaskDataState putTaskData(File file, TaskData data, boolean setLastRead, boolean user)
throws CoreException {
Assert.isNotNull(file);
Assert.isNotNull(data);
@@ -93,9 +93,10 @@ public class TaskDataStore {
}
state.setRepositoryData(data);
writeState(file, state);
+ return state;
}
- public synchronized void setTaskData(File file, TaskData data) throws CoreException {
+ public synchronized TaskDataState setTaskData(File file, TaskData data) throws CoreException {
Assert.isNotNull(file);
Assert.isNotNull(data);
@@ -106,6 +107,7 @@ public class TaskDataStore {
state.setEditsData(null);
state.setLastReadData(data);
writeState(file, state);
+ return state;
}
private TaskDataState readStateInternal(File file, boolean xml11) throws IOException, SAXException {
diff --git a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/data/ITaskAttributeDiff.java b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/data/ITaskAttributeDiff.java
new file mode 100644
index 000000000..6e7f4ff0b
--- /dev/null
+++ b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/data/ITaskAttributeDiff.java
@@ -0,0 +1,26 @@
+/*******************************************************************************
+ * Copyright (c) 2011 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.tasks.core.data;
+
+/**
+ * Describes differences between two {@link TaskAttribute} objects.
+ *
+ * @author Steffen Pingel
+ * @noextend This interface is not intended to be extended by clients.
+ * @noimplement This interface is not intended to be implemented by clients.
+ * @since 3.5
+ */
+public interface ITaskAttributeDiff {
+
+ public String getAttributeId();
+
+}
diff --git a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/data/ITaskDataDiff.java b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/data/ITaskDataDiff.java
new file mode 100644
index 000000000..5ad1ac457
--- /dev/null
+++ b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/data/ITaskDataDiff.java
@@ -0,0 +1,36 @@
+/*******************************************************************************
+ * Copyright (c) 2011 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.tasks.core.data;
+
+import java.util.Collection;
+
+import org.eclipse.mylyn.tasks.core.TaskRepository;
+
+/**
+ * Describes differences between two {@link TaskData} objects.
+ *
+ * @author Steffen Pingel
+ * @noextend This interface is not intended to be extended by clients.
+ * @noimplement This interface is not intended to be implemented by clients.
+ * @since 3.5
+ */
+public interface ITaskDataDiff {
+
+ public boolean hasChanged();
+
+ public void setHasChanged(boolean hasChanged);
+
+ public TaskRepository getRepository();
+
+ public Collection<ITaskAttributeDiff> getChangedAttributes();
+
+}
diff --git a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/sync/SynchronizationParticipant.java b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/sync/SynchronizationParticipant.java
new file mode 100644
index 000000000..deece8a53
--- /dev/null
+++ b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/sync/SynchronizationParticipant.java
@@ -0,0 +1,41 @@
+/*******************************************************************************
+ * Copyright (c) 2011 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.tasks.core.sync;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.mylyn.tasks.core.data.ITaskDataDiff;
+
+/**
+ * @author Steffen Pingel
+ * @since 3.5
+ */
+public abstract class SynchronizationParticipant {
+
+ private String id;
+
+ public SynchronizationParticipant() {
+ }
+
+ public final String getId() {
+ return id;
+ }
+
+ public abstract void processUpdate(ITaskDataDiff diff, IProgressMonitor monitor);
+
+ public final void setId(String id) {
+ Assert.isNotNull(id);
+ Assert.isNotNull(this.id);
+ this.id = id;
+ }
+
+}

Back to the top