Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorspingel2011-04-10 17:08:11 +0000
committerspingel2011-04-10 17:08:11 +0000
commit41258b5f77fa9770d0e091a9ddd1bd7f9b2da4fd (patch)
treee570c09fe5e0c23aa650e1cb7d58d484b0391f0c
parent8967c23bd9ad89aa97613c0d03da60605fc3a11f (diff)
downloadorg.eclipse.mylyn.tasks-41258b5f77fa9770d0e091a9ddd1bd7f9b2da4fd.tar.gz
org.eclipse.mylyn.tasks-41258b5f77fa9770d0e091a9ddd1bd7f9b2da4fd.tar.xz
org.eclipse.mylyn.tasks-41258b5f77fa9770d0e091a9ddd1bd7f9b2da4fd.zip
NEW - bug 142906: Use History view to show repository task history
https://bugs.eclipse.org/bugs/show_bug.cgi?id=142906
-rw-r--r--org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/data/TaskDataState.java6
-rw-r--r--org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/sync/GetTaskHistoryJob.java87
-rw-r--r--org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/AbstractRepositoryConnector.java47
-rw-r--r--org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/data/TaskHistory.java80
-rw-r--r--org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/data/TaskRevision.java129
-rw-r--r--org.eclipse.mylyn.tasks.ui/META-INF/MANIFEST.MF1
-rw-r--r--org.eclipse.mylyn.tasks.ui/plugin.xml2
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/actions/RepositoryElementActionGroup.java7
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/compare/Messages.java27
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/compare/TaskDataDiffNode.java86
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/compare/messages.properties1
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/util/TaskPropertyTester.java4
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/util/TasksUiInternal.java57
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/views/TaskListView.java14
14 files changed, 542 insertions, 6 deletions
diff --git a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/data/TaskDataState.java b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/data/TaskDataState.java
index 016e0f776..523562086 100644
--- a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/data/TaskDataState.java
+++ b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/data/TaskDataState.java
@@ -189,12 +189,12 @@ public class TaskDataState implements ITaskDataWorkingCopy {
setRepositoryData(createCopy(oldState.getRepositoryData()));
}
- private TaskData createCopy(TaskData oldData) {
+ public static TaskData createCopy(TaskData oldData) {
if (oldData == null) {
return null;
}
- TaskData newData = new TaskData(oldData.getAttributeMapper(), getConnectorKind(), getRepositoryUrl(),
- getTaskId());
+ TaskData newData = new TaskData(oldData.getAttributeMapper(), oldData.getConnectorKind(),
+ oldData.getRepositoryUrl(), oldData.getTaskId());
newData.setVersion(oldData.getVersion());
for (TaskAttribute child : oldData.getRoot().getAttributes().values()) {
newData.getRoot().deepAddCopy(child);
diff --git a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/sync/GetTaskHistoryJob.java b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/sync/GetTaskHistoryJob.java
new file mode 100644
index 000000000..67c34af1c
--- /dev/null
+++ b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/sync/GetTaskHistoryJob.java
@@ -0,0 +1,87 @@
+/*******************************************************************************
+ * 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.sync;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.OperationCanceledException;
+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.tasks.core.AbstractRepositoryConnector;
+import org.eclipse.mylyn.tasks.core.ITask;
+import org.eclipse.mylyn.tasks.core.TaskRepository;
+import org.eclipse.mylyn.tasks.core.data.TaskHistory;
+import org.eclipse.mylyn.tasks.core.sync.TaskJob;
+
+/**
+ * @author Steffen Pingel
+ */
+public class GetTaskHistoryJob extends TaskJob {
+
+ private final TaskRepository repository;
+
+ private final ITask task;
+
+ private final AbstractRepositoryConnector connector;
+
+ private IStatus errorStatus;
+
+ private TaskHistory history;
+
+ public GetTaskHistoryJob(AbstractRepositoryConnector connector, TaskRepository repository, ITask task) {
+ super("Retrieving History");
+ this.connector = connector;
+ this.repository = repository;
+ this.task = task;
+ }
+
+ @Override
+ protected IStatus run(IProgressMonitor jobMonitor) {
+ try {
+ monitor.setCanceled(false);
+ monitor.attach(jobMonitor);
+ try {
+ history = connector.getTaskHistory(repository, task, monitor);
+ } catch (CoreException e) {
+ errorStatus = e.getStatus();
+ } catch (OperationCanceledException e) {
+ errorStatus = Status.CANCEL_STATUS;
+ } catch (Exception e) {
+ StatusHandler.log(new Status(IStatus.ERROR, ITasksCoreConstants.ID_PLUGIN,
+ "Unexpected error while retrieving task history", e)); //$NON-NLS-1$
+ errorStatus = new Status(IStatus.ERROR, ITasksCoreConstants.ID_PLUGIN, "Unexpected error: " //$NON-NLS-1$
+ + e.getMessage(), e);
+ } finally {
+ monitor.done();
+ }
+ return (errorStatus == Status.CANCEL_STATUS) ? Status.CANCEL_STATUS : Status.OK_STATUS;
+ } finally {
+ monitor.detach(jobMonitor);
+ }
+ }
+
+ public TaskHistory getHistory() {
+ return history;
+ }
+
+ @Override
+ public IStatus getStatus() {
+ return errorStatus;
+ }
+
+ public ITask getTask() {
+ return task;
+ }
+
+}
diff --git a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/AbstractRepositoryConnector.java b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/AbstractRepositoryConnector.java
index 7404967fb..2136df56a 100644
--- a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/AbstractRepositoryConnector.java
+++ b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/AbstractRepositoryConnector.java
@@ -25,6 +25,7 @@ import org.eclipse.mylyn.tasks.core.data.AbstractTaskAttachmentHandler;
import org.eclipse.mylyn.tasks.core.data.AbstractTaskDataHandler;
import org.eclipse.mylyn.tasks.core.data.TaskData;
import org.eclipse.mylyn.tasks.core.data.TaskDataCollector;
+import org.eclipse.mylyn.tasks.core.data.TaskHistory;
import org.eclipse.mylyn.tasks.core.data.TaskMapper;
import org.eclipse.mylyn.tasks.core.data.TaskRelation;
import org.eclipse.mylyn.tasks.core.sync.ISynchronizationSession;
@@ -58,6 +59,16 @@ public abstract class AbstractRepositoryConnector {
public abstract boolean canCreateTaskFromKey(TaskRepository repository);
/**
+ * Returns true, if the connector supports retrieval of task history for <code>task</code>.
+ *
+ * @see #getHistory(TaskRepository, ITask, IProgressMonitor)
+ * @since 3.6
+ */
+ public boolean canGetTaskHistory(TaskRepository repository, ITask task) {
+ return false;
+ }
+
+ /**
* @since 3.0
*/
public boolean canQuery(TaskRepository repository) {
@@ -386,4 +397,40 @@ public abstract class AbstractRepositoryConnector {
return false;
}
+ /**
+ * Retrieves the history for <code>task</code>. Throws {@link UnsupportedOperationException} by default.
+ *
+ * @param repository
+ * the repository
+ * @param task
+ * the task to retrieve history for
+ * @param monitor
+ * a progress monitor
+ * @return the history for <code>task</code>
+ * @throws CoreException
+ * thrown in case retrieval fails
+ * @see #canGetHistory(TaskRepository, ITask)
+ * @since 3.6
+ */
+ public TaskHistory getTaskHistory(TaskRepository repository, ITask task, IProgressMonitor monitor)
+ throws CoreException {
+ throw new UnsupportedOperationException();
+ }
+
+// /**
+// * Returns a specific revision of a task. Sub-classes may override.
+// *
+// * @return null, if the revision is not found
+// * @since 3.6
+// * @see TaskHistory
+// * @see #getTaskHistory(TaskRepository, ITask, IProgressMonitor)
+// */
+// public TaskData getTaskData(TaskRepository repository, ITask task, String revisionId, IProgressMonitor monitor)
+// throws CoreException {
+// Assert.isNotNull(repository);
+// Assert.isNotNull(task);
+// Assert.isNotNull(revisionId);
+// return null;
+// }
+
}
diff --git a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/data/TaskHistory.java b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/data/TaskHistory.java
new file mode 100644
index 000000000..715bb9c77
--- /dev/null
+++ b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/data/TaskHistory.java
@@ -0,0 +1,80 @@
+/*******************************************************************************
+ * 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.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.mylyn.tasks.core.ITask;
+import org.eclipse.mylyn.tasks.core.TaskRepository;
+
+/**
+ * A model that describes the history of changes to a task.
+ *
+ * @author Steffen Pingel
+ * @since 3.6
+ */
+public class TaskHistory {
+
+ private final TaskRepository repository;
+
+ private final List<TaskRevision> revisions;
+
+ private final ITask task;
+
+ public TaskHistory(TaskRepository repository, ITask task) {
+ Assert.isNotNull(repository);
+ Assert.isNotNull(task);
+ this.repository = repository;
+ this.task = task;
+ this.revisions = new ArrayList<TaskRevision>();
+ }
+
+ public void add(TaskRevision entry) {
+ revisions.add(entry);
+ }
+
+ public TaskRepository getRepository() {
+ return repository;
+ }
+
+ public List<TaskRevision> getRevisions() {
+ return new ArrayList<TaskRevision>(revisions);
+ }
+
+ /**
+ * Returns a specific revision for this task history.
+ *
+ * @param id
+ * the id of the revision
+ * @return the revision matching <code>id</code> or null, if no matching revision was found
+ * @see TaskRevision#getId()
+ */
+ public TaskRevision getRevision(String id) {
+ for (TaskRevision revision : revisions) {
+ if (revision.getId().equals(id)) {
+ return revision;
+ }
+ }
+ return null;
+ }
+
+ public ITask getTask() {
+ return task;
+ }
+
+ public void remove(TaskRevision entry) {
+ revisions.remove(entry);
+ }
+
+}
diff --git a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/data/TaskRevision.java b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/data/TaskRevision.java
new file mode 100644
index 000000000..cef4c925e
--- /dev/null
+++ b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/data/TaskRevision.java
@@ -0,0 +1,129 @@
+/*******************************************************************************
+ * 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.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.mylyn.tasks.core.IRepositoryPerson;
+
+/**
+ * Describes a revision of a task in its history.
+ *
+ * @author Steffen Pingel
+ * @since 3.6
+ */
+public class TaskRevision {
+
+ /**
+ * @author Steffen Pingel
+ */
+ public static class Change {
+
+ private final String added;
+
+ private final String attributeId;
+
+ private final String field;
+
+ private final String removed;
+
+ /**
+ * Constructs a field change.
+ *
+ * @param attributeId
+ * the id of the attribute that has changed, must not be null
+ * @param field
+ * the label of the attribute that has changed, must not be null
+ * @param removed
+ * the values that were removed
+ * @param added
+ * the values that were added
+ */
+ public Change(String attributeId, String field, String removed, String added) {
+ Assert.isNotNull(attributeId);
+ Assert.isNotNull(field);
+ this.attributeId = attributeId;
+ this.field = field;
+ this.removed = removed;
+ this.added = added;
+ }
+
+ public String getAdded() {
+ return added;
+ }
+
+ public String getAttributeId() {
+ return attributeId;
+ }
+
+ public String getField() {
+ return field;
+ }
+
+ public String getRemoved() {
+ return removed;
+ }
+
+ }
+
+ private final IRepositoryPerson author;
+
+ private final List<TaskRevision.Change> changes;
+
+ private final Date date;
+
+ private final String id;
+
+ /**
+ * @param id
+ * id that identifies the revisions, it must be unique on a per task basis
+ * @param date
+ * the time the revision was created
+ * @param author
+ * the person that made changes for this revision
+ */
+ public TaskRevision(String id, Date date, IRepositoryPerson author) {
+ Assert.isNotNull(id);
+ this.id = id;
+ this.date = date;
+ this.author = author;
+ this.changes = new ArrayList<TaskRevision.Change>();
+ }
+
+ public void add(TaskRevision.Change change) {
+ changes.add(change);
+ }
+
+ public IRepositoryPerson getAuthor() {
+ return author;
+ }
+
+ public List<TaskRevision.Change> getChanges() {
+ return new ArrayList<TaskRevision.Change>(changes);
+ }
+
+ public Date getDate() {
+ return date;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void remove(TaskRevision.Change change) {
+ changes.remove(change);
+ }
+
+} \ No newline at end of file
diff --git a/org.eclipse.mylyn.tasks.ui/META-INF/MANIFEST.MF b/org.eclipse.mylyn.tasks.ui/META-INF/MANIFEST.MF
index a8e5195a3..a97f2218d 100644
--- a/org.eclipse.mylyn.tasks.ui/META-INF/MANIFEST.MF
+++ b/org.eclipse.mylyn.tasks.ui/META-INF/MANIFEST.MF
@@ -31,6 +31,7 @@ Export-Package: org.eclipse.mylyn.internal.provisional.tasks.ui.wizards;x-intern
org.eclipse.mylyn.internal.tasks.ui;x-internal:=true,
org.eclipse.mylyn.internal.tasks.ui.actions;x-internal:=true,
org.eclipse.mylyn.internal.tasks.ui.commands;x-internal:=true,
+ org.eclipse.mylyn.internal.tasks.ui.compare;x-internal:=true,
org.eclipse.mylyn.internal.tasks.ui.dialogs;x-internal:=true,
org.eclipse.mylyn.internal.tasks.ui.editors;x-internal:=true,
org.eclipse.mylyn.internal.tasks.ui.editors.outline;x-internal:=true,
diff --git a/org.eclipse.mylyn.tasks.ui/plugin.xml b/org.eclipse.mylyn.tasks.ui/plugin.xml
index 7a34ebb2d..5da35a966 100644
--- a/org.eclipse.mylyn.tasks.ui/plugin.xml
+++ b/org.eclipse.mylyn.tasks.ui/plugin.xml
@@ -1868,7 +1868,7 @@
class="org.eclipse.mylyn.internal.tasks.ui.util.TaskPropertyTester"
id="org.eclipse.mylyn.tasks.ui.propertyTester.task"
namespace="org.eclipse.mylyn.task"
- properties="canGetAttachment,canPostAttachment,connectorKind,hasActiveTime,hasEdits,hasLocalContext,hasLocalCompletionState,hasRepositoryContext,isCompleted,isLocal,"
+ properties="canGetAttachment,canGetHistory,canPostAttachment,connectorKind,hasActiveTime,hasEdits,hasLocalContext,hasLocalCompletionState,hasRepositoryContext,isCompleted,isLocal,"
type="org.eclipse.mylyn.tasks.core.ITask">
</propertyTester>
<propertyTester
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/actions/RepositoryElementActionGroup.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/actions/RepositoryElementActionGroup.java
index 694bc393d..fe7821f34 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/actions/RepositoryElementActionGroup.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/actions/RepositoryElementActionGroup.java
@@ -68,6 +68,8 @@ public class RepositoryElementActionGroup {
private static final String ID_SEPARATOR_OPEN = "open"; //$NON-NLS-1$
+ private static final String ID_SEPARATOR_SHOW_IN = "showIn"; //$NON-NLS-1$
+
protected static final String ID_SEPARATOR_EDIT = "edit"; //$NON-NLS-1$
private final CopyTaskDetailsAction copyUrlAction;
@@ -161,6 +163,7 @@ public class RepositoryElementActionGroup {
manager.add(new Separator(ID_SEPARATOR_NEW)); // new, schedule
manager.add(new GroupMarker(ID_SEPARATOR_NAVIGATE)); // mark, go into, go up
manager.add(new Separator(ID_SEPARATOR_OPEN)); // open, activate
+ manager.add(new GroupMarker(ID_SEPARATOR_SHOW_IN)); // open, activate
manager.add(new Separator(ID_SEPARATOR_EDIT)); // cut, copy paste, delete, rename
manager.add(new Separator(ID_SEPARATOR_TASKS)); // move to
manager.add(new GroupMarker(ID_SEPARATOR_OPERATIONS)); // repository properties, import/export, context
@@ -210,9 +213,9 @@ public class RepositoryElementActionGroup {
}
if (task != null) {
if (task.isActive()) {
- manager.appendToGroup(ID_SEPARATOR_OPEN, deactivateAction);
+ manager.appendToGroup(ID_SEPARATOR_SHOW_IN, deactivateAction);
} else {
- manager.appendToGroup(ID_SEPARATOR_OPEN, activateAction);
+ manager.appendToGroup(ID_SEPARATOR_SHOW_IN, activateAction);
}
}
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/compare/Messages.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/compare/Messages.java
new file mode 100644
index 000000000..a0849a322
--- /dev/null
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/compare/Messages.java
@@ -0,0 +1,27 @@
+/*******************************************************************************
+ * 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.ui.compare;
+
+import org.eclipse.osgi.util.NLS;
+
+public class Messages extends NLS {
+ private static final String BUNDLE_NAME = "org.eclipse.mylyn.internal.tasks.ui.compare.messages"; //$NON-NLS-1$
+
+ public static String TaskDataDiffNode_New_Comment_Label;
+ static {
+ // initialize resource bundle
+ NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+ }
+
+ private Messages() {
+ }
+}
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/compare/TaskDataDiffNode.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/compare/TaskDataDiffNode.java
new file mode 100644
index 000000000..5d0100896
--- /dev/null
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/compare/TaskDataDiffNode.java
@@ -0,0 +1,86 @@
+/*******************************************************************************
+ * 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.ui.compare;
+
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+
+import org.eclipse.compare.IStreamContentAccessor;
+import org.eclipse.compare.ITypedElement;
+import org.eclipse.compare.structuremergeviewer.DiffNode;
+import org.eclipse.compare.structuremergeviewer.Differencer;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.mylyn.internal.tasks.core.data.TaskAttributeDiff;
+import org.eclipse.mylyn.internal.tasks.core.data.TaskDataDiff;
+import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin;
+import org.eclipse.mylyn.tasks.core.ITaskComment;
+import org.eclipse.mylyn.tasks.core.data.ITaskAttributeDiff;
+import org.eclipse.mylyn.tasks.core.data.TaskData;
+import org.eclipse.swt.graphics.Image;
+
+/**
+ * A model element for comparing two {@link TaskData} objects.
+ *
+ * @author Steffen Pingel
+ */
+public class TaskDataDiffNode extends DiffNode {
+
+ static class ByteArrayInput implements ITypedElement, IStreamContentAccessor {
+
+ String content;
+
+ private final String name;
+
+ public ByteArrayInput(String content, String name) {
+ this.content = content;
+ this.name = name;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public Image getImage() {
+ return null;
+ }
+
+ public String getType() {
+ return ITypedElement.TEXT_TYPE;
+ }
+
+ public InputStream getContents() throws CoreException {
+ return new ByteArrayInputStream(content.getBytes());
+ }
+
+ }
+
+ public TaskDataDiffNode(int change, TaskData oldData, TaskData newData) {
+ super(change);
+ TaskDataDiff diff = new TaskDataDiff(TasksUiPlugin.getRepositoryModel(), newData, oldData);
+ for (ITaskAttributeDiff attribute : diff.getChangedAttributes()) {
+ TaskAttributeDiff attr = (TaskAttributeDiff) attribute;
+ String label = attr.getLabel();
+ if (label.endsWith(":")) { //$NON-NLS-1$
+ label = label.substring(0, label.length() - 1);
+ }
+ DiffNode node = new DiffNode(Differencer.CHANGE, this, new ByteArrayInput(attr.getOldValues().toString(),
+ null), new ByteArrayInput(attr.getNewValues().toString(), label));
+ add(node);
+ }
+ for (ITaskComment attribute : diff.getNewComments()) {
+ DiffNode node = new DiffNode(Differencer.CHANGE, this, new ByteArrayInput("", null), new ByteArrayInput( //$NON-NLS-1$
+ attribute.getText(), Messages.TaskDataDiffNode_New_Comment_Label));
+ add(node);
+ }
+ }
+
+}
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/compare/messages.properties b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/compare/messages.properties
new file mode 100644
index 000000000..be299b79f
--- /dev/null
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/compare/messages.properties
@@ -0,0 +1 @@
+TaskDataDiffNode_New_Comment_Label=New Comment
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/util/TaskPropertyTester.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/util/TaskPropertyTester.java
index 5c302b15e..e32a3996c 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/util/TaskPropertyTester.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/util/TaskPropertyTester.java
@@ -23,6 +23,8 @@ public class TaskPropertyTester extends PropertyTester {
private static final String PROPERTY_CAN_GET_ATTACHMENT = "canGetAttachment"; //$NON-NLS-1$
+ private static final String PROPERTY_CAN_GET_HISTORY = "canGetHistory"; //$NON-NLS-1$
+
private static final String PROPERTY_CAN_POST_ATTACHMENT = "canPostAttachment"; //$NON-NLS-1$
private static final String PROPERTY_CONNECTOR_KIND = "connectorKind"; //$NON-NLS-1$
@@ -55,6 +57,8 @@ public class TaskPropertyTester extends PropertyTester {
return equals(AttachmentUtil.canUploadAttachment(task), expectedValue);
} else if (PROPERTY_CAN_GET_ATTACHMENT.equals(property)) {
return equals(AttachmentUtil.canDownloadAttachment(task), expectedValue);
+ } else if (PROPERTY_CAN_GET_HISTORY.equals(property)) {
+ return TasksUiInternal.canGetTaskHistory(task);
} else if (PROPERTY_HAS_ACTIVE_TIME.equals(property)) {
return equals(TasksUiInternal.getActiveTime(task) > 0, expectedValue);
} else if (PROPERTY_HAS_EDITS.equals(property)) {
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/util/TasksUiInternal.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/util/TasksUiInternal.java
index 44c60b881..44f3ade84 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/util/TasksUiInternal.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/util/TasksUiInternal.java
@@ -77,6 +77,7 @@ import org.eclipse.mylyn.internal.tasks.core.TaskCategory;
import org.eclipse.mylyn.internal.tasks.core.TaskList;
import org.eclipse.mylyn.internal.tasks.core.UncategorizedTaskContainer;
import org.eclipse.mylyn.internal.tasks.core.UnsubmittedTaskContainer;
+import org.eclipse.mylyn.internal.tasks.core.data.TaskDataState;
import org.eclipse.mylyn.internal.tasks.core.sync.SynchronizationScheduler;
import org.eclipse.mylyn.internal.tasks.core.sync.SynchronizationScheduler.Synchronizer;
import org.eclipse.mylyn.internal.tasks.ui.ITasksUiPreferenceConstants;
@@ -100,9 +101,14 @@ import org.eclipse.mylyn.tasks.core.TaskRepository;
import org.eclipse.mylyn.tasks.core.data.AbstractTaskAttachmentSource;
import org.eclipse.mylyn.tasks.core.data.AbstractTaskDataHandler;
import org.eclipse.mylyn.tasks.core.data.ITaskDataWorkingCopy;
+import org.eclipse.mylyn.tasks.core.data.TaskAttachmentMapper;
import org.eclipse.mylyn.tasks.core.data.TaskAttribute;
import org.eclipse.mylyn.tasks.core.data.TaskAttributeMapper;
+import org.eclipse.mylyn.tasks.core.data.TaskCommentMapper;
import org.eclipse.mylyn.tasks.core.data.TaskData;
+import org.eclipse.mylyn.tasks.core.data.TaskHistory;
+import org.eclipse.mylyn.tasks.core.data.TaskRevision;
+import org.eclipse.mylyn.tasks.core.data.TaskRevision.Change;
import org.eclipse.mylyn.tasks.core.sync.SynchronizationJob;
import org.eclipse.mylyn.tasks.core.sync.TaskJob;
import org.eclipse.mylyn.tasks.ui.AbstractRepositoryConnectorUi;
@@ -1368,4 +1374,55 @@ public class TasksUiInternal {
return false;
}
+ public static TaskData computeTaskData(TaskData taskData, TaskHistory history, String revisionId,
+ IProgressMonitor monitor) throws CoreException {
+ TaskData newTaskData = TaskDataState.createCopy(taskData);
+ List<TaskRevision> revisions = history.getRevisions();
+ Collections.reverse(revisions);
+ TaskRevision lastRevision = null;
+ for (TaskRevision revision : revisions) {
+ for (Change change : revision.getChanges()) {
+ TaskAttribute attribute = newTaskData.getRoot().getAttribute(change.getAttributeId());
+ if (attribute != null) {
+ attribute.setValue(change.getRemoved());
+ }
+ }
+ // only apply changes up to this revision
+ if (revisionId.equals(revision.getId())) {
+ lastRevision = revision;
+ break;
+ }
+ }
+
+ if (lastRevision != null && lastRevision.getDate() != null) {
+ // remove attachments and comments that are newer than lastRevision
+ List<TaskAttribute> attributes = new ArrayList<TaskAttribute>(newTaskData.getRoot()
+ .getAttributes()
+ .values());
+ for (TaskAttribute attribute : attributes) {
+ if (TaskAttribute.TYPE_COMMENT.equals(attribute.getMetaData().getType())) {
+ TaskCommentMapper mapper = TaskCommentMapper.createFrom(attribute);
+ if (mapper.getCreationDate() != null && mapper.getCreationDate().after(lastRevision.getDate())) {
+ newTaskData.getRoot().removeAttribute(attribute.getId());
+ }
+ } else if (TaskAttribute.TYPE_ATTACHMENT.equals(attribute.getMetaData().getType())) {
+ TaskAttachmentMapper mapper = TaskAttachmentMapper.createFrom(attribute);
+ if (mapper.getCreationDate() != null && mapper.getCreationDate().after(lastRevision.getDate())) {
+ newTaskData.getRoot().removeAttribute(attribute.getId());
+ }
+ }
+ }
+ }
+
+ return newTaskData;
+ }
+
+ public static boolean canGetTaskHistory(ITask task) {
+ TaskRepository repository = TasksUi.getRepositoryManager().getRepository(task.getConnectorKind(),
+ task.getRepositoryUrl());
+ AbstractRepositoryConnector connector = TasksUi.getRepositoryManager().getRepositoryConnector(
+ repository.getConnectorKind());
+ return connector.canGetTaskHistory(repository, task);
+ }
+
}
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/views/TaskListView.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/views/TaskListView.java
index 6551ca7f5..c4245266f 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/views/TaskListView.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/views/TaskListView.java
@@ -177,7 +177,9 @@ import org.eclipse.ui.contexts.IContextService;
import org.eclipse.ui.handlers.CollapseAllHandler;
import org.eclipse.ui.handlers.IHandlerService;
import org.eclipse.ui.part.DrillDownAdapter;
+import org.eclipse.ui.part.IShowInSource;
import org.eclipse.ui.part.IShowInTarget;
+import org.eclipse.ui.part.IShowInTargetList;
import org.eclipse.ui.part.ShowInContext;
import org.eclipse.ui.part.ViewPart;
import org.eclipse.ui.progress.IWorkbenchSiteProgressService;
@@ -1759,6 +1761,18 @@ public class TaskListView extends ViewPart implements IPropertyChangeListener, I
return preferredResult;
}
};
+ } else if (adapter == IShowInTargetList.class) {
+ return new IShowInTargetList() {
+ public String[] getShowInTargetIds() {
+ return new String[] { "org.eclipse.team.ui.GenericHistoryView" }; //$NON-NLS-1$
+ }
+ };
+ } else if (adapter == IShowInSource.class) {
+ return new IShowInSource() {
+ public ShowInContext getShowInContext() {
+ return new ShowInContext(getViewer().getInput(), getViewer().getSelection());
+ }
+ };
}
return super.getAdapter(adapter);
}

Back to the top