summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTimur Achmetow2012-09-11 18:04:05 (EDT)
committerSteffen Pingel2012-09-12 14:05:34 (EDT)
commit2ae43597001255763babb158ef43b1e96d48b166 (patch)
tree39ee03d9b64376a4df0f8a46c218065723050b2b
parent8e0212d19495b6827fae5b4354775437d9a1ebf9 (diff)
downloadorg.eclipse.mylyn.tasks-2ae43597001255763babb158ef43b1e96d48b166.zip
org.eclipse.mylyn.tasks-2ae43597001255763babb158ef43b1e96d48b166.tar.gz
org.eclipse.mylyn.tasks-2ae43597001255763babb158ef43b1e96d48b166.tar.bz2
378101: add activity provider for related tasks such as reviewsrefs/changes/08/7008/17
Task-Url: https://bugs.eclipse.org/bugs/show_bug.cgi?id=378101 Change-Id: Ib63e5f52780d82cf90364921edecb0ac5c38e627
-rw-r--r--org.eclipse.mylyn.tasks.activity.core/META-INF/MANIFEST.MF7
-rw-r--r--org.eclipse.mylyn.tasks.activity.core/src/org/eclipse/mylyn/internal/tasks/activity/core/ActivityCoreInternal.java1
-rw-r--r--org.eclipse.mylyn.tasks.activity.core/src/org/eclipse/mylyn/internal/tasks/activity/core/ActivityManager.java16
-rw-r--r--org.eclipse.mylyn.tasks.activity.core/src/org/eclipse/mylyn/internal/tasks/activity/core/ActivityStream.java25
-rw-r--r--org.eclipse.mylyn.tasks.activity.core/src/org/eclipse/mylyn/internal/tasks/activity/core/TaskActivityProvider.java70
-rw-r--r--org.eclipse.mylyn.tasks.activity.core/src/org/eclipse/mylyn/tasks/activity/core/ActivityEvent.java16
-rw-r--r--org.eclipse.mylyn.tasks.activity.core/src/org/eclipse/mylyn/tasks/activity/core/IActivityStream.java17
-rw-r--r--org.eclipse.mylyn.tasks.activity.tests/META-INF/MANIFEST.MF4
-rw-r--r--org.eclipse.mylyn.tasks.activity.tests/src/org/eclipse/mylyn/tasks/activity/tests/TaskActivityProviderTest.java64
-rw-r--r--org.eclipse.mylyn.tasks.activity.ui/META-INF/MANIFEST.MF3
-rw-r--r--org.eclipse.mylyn.tasks.activity.ui/src/org/eclipse/mylyn/internal/tasks/activity/ui/ActivityPart.java8
-rw-r--r--org.eclipse.mylyn.tasks.activity.ui/src/org/eclipse/mylyn/internal/tasks/activity/ui/provider/ActivityRecordContentProvider.java (renamed from org.eclipse.mylyn.tasks.activity.ui/src/org/eclipse/mylyn/internal/tasks/activity/ui/ActivityRecordContentProvider.java)36
-rw-r--r--org.eclipse.mylyn.tasks.activity.ui/src/org/eclipse/mylyn/internal/tasks/activity/ui/provider/ActivityRecordLabelProvider.java52
13 files changed, 232 insertions, 87 deletions
diff --git a/org.eclipse.mylyn.tasks.activity.core/META-INF/MANIFEST.MF b/org.eclipse.mylyn.tasks.activity.core/META-INF/MANIFEST.MF
index 229008c..ae58bf8 100644
--- a/org.eclipse.mylyn.tasks.activity.core/META-INF/MANIFEST.MF
+++ b/org.eclipse.mylyn.tasks.activity.core/META-INF/MANIFEST.MF
@@ -6,8 +6,11 @@ Bundle-Version: 3.9.0.qualifier
Bundle-Vendor: %Bundle-Vendor
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Require-Bundle: org.eclipse.core.runtime,
- org.eclipse.mylyn.tasks.core;bundle-version="3.8.0"
+ org.eclipse.mylyn.tasks.core;bundle-version="3.8.0",
+ org.eclipse.mylyn.tasks.index.ui;bundle-version="3.9.0",
+ org.eclipse.mylyn.tasks.index.core;bundle-version="3.9.0",
+ org.eclipse.mylyn.commons.core;bundle-version="3.9.0"
Bundle-Localization: plugin
Export-Package: org.eclipse.mylyn.internal.tasks.activity.core;x-internal:=true,
org.eclipse.mylyn.tasks.activity.core;x-internal:=true,
- org.eclipse.mylyn.tasks.activity.core.spi
+ org.eclipse.mylyn.tasks.activity.core.spi
diff --git a/org.eclipse.mylyn.tasks.activity.core/src/org/eclipse/mylyn/internal/tasks/activity/core/ActivityCoreInternal.java b/org.eclipse.mylyn.tasks.activity.core/src/org/eclipse/mylyn/internal/tasks/activity/core/ActivityCoreInternal.java
index 78fbc93..0783e5c 100644
--- a/org.eclipse.mylyn.tasks.activity.core/src/org/eclipse/mylyn/internal/tasks/activity/core/ActivityCoreInternal.java
+++ b/org.eclipse.mylyn.tasks.activity.core/src/org/eclipse/mylyn/internal/tasks/activity/core/ActivityCoreInternal.java
@@ -11,7 +11,6 @@
package org.eclipse.mylyn.internal.tasks.activity.core;
-
/**
* @author Steffen Pingel
*/
diff --git a/org.eclipse.mylyn.tasks.activity.core/src/org/eclipse/mylyn/internal/tasks/activity/core/ActivityManager.java b/org.eclipse.mylyn.tasks.activity.core/src/org/eclipse/mylyn/internal/tasks/activity/core/ActivityManager.java
index ecb2786..17962ef 100644
--- a/org.eclipse.mylyn.tasks.activity.core/src/org/eclipse/mylyn/internal/tasks/activity/core/ActivityManager.java
+++ b/org.eclipse.mylyn.tasks.activity.core/src/org/eclipse/mylyn/internal/tasks/activity/core/ActivityManager.java
@@ -12,8 +12,9 @@
package org.eclipse.mylyn.internal.tasks.activity.core;
import java.util.Collection;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
+import java.util.Collections;
+import java.util.Set;
+import java.util.TreeSet;
import org.eclipse.mylyn.tasks.activity.core.ActivityEvent;
import org.eclipse.mylyn.tasks.activity.core.ActivityScope;
@@ -26,14 +27,14 @@ import org.eclipse.mylyn.tasks.activity.core.spi.IActivitySession;
*/
public class ActivityManager implements IActivityManager, IActivitySession {
- private final Map<String, ActivityEvent> events;
+ private final Set<ActivityEvent> events;
public ActivityManager() {
- this.events = new ConcurrentHashMap<String, ActivityEvent>();
+ this.events = Collections.synchronizedSet(new TreeSet<ActivityEvent>());
}
public Collection<ActivityEvent> getEvents(ActivityScope scope) {
- return events.values();
+ return events;
}
public IActivityStream getStream(ActivityScope scope) {
@@ -45,7 +46,6 @@ public class ActivityManager implements IActivityManager, IActivitySession {
}
public void fireActivityEvent(ActivityEvent event) {
- events.put(event.getHandle(), event);
+ events.add(event);
}
-
-}
+} \ No newline at end of file
diff --git a/org.eclipse.mylyn.tasks.activity.core/src/org/eclipse/mylyn/internal/tasks/activity/core/ActivityStream.java b/org.eclipse.mylyn.tasks.activity.core/src/org/eclipse/mylyn/internal/tasks/activity/core/ActivityStream.java
index cf5a421..90377e2 100644
--- a/org.eclipse.mylyn.tasks.activity.core/src/org/eclipse/mylyn/internal/tasks/activity/core/ActivityStream.java
+++ b/org.eclipse.mylyn.tasks.activity.core/src/org/eclipse/mylyn/internal/tasks/activity/core/ActivityStream.java
@@ -11,10 +11,13 @@
package org.eclipse.mylyn.internal.tasks.activity.core;
-import java.util.List;
-import java.util.concurrent.CopyOnWriteArrayList;
+import java.util.Collections;
+import java.util.Set;
+import java.util.TreeSet;
import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.mylyn.tasks.activity.core.ActivityEvent;
import org.eclipse.mylyn.tasks.activity.core.ActivityScope;
import org.eclipse.mylyn.tasks.activity.core.IActivityManager;
@@ -22,10 +25,11 @@ import org.eclipse.mylyn.tasks.activity.core.IActivityStream;
/**
* @author Steffen Pingel
+ * @author Timur Achmetow
*/
public class ActivityStream implements IActivityStream {
- private final List<ActivityEvent> events;
+ private final Set<ActivityEvent> events;
private final ActivityScope scope;
@@ -36,7 +40,7 @@ public class ActivityStream implements IActivityStream {
Assert.isNotNull(scope);
this.manager = manager;
this.scope = scope;
- this.events = new CopyOnWriteArrayList<ActivityEvent>();
+ this.events = Collections.synchronizedSet(new TreeSet<ActivityEvent>());
initialize();
}
@@ -44,11 +48,19 @@ public class ActivityStream implements IActivityStream {
events.addAll(manager.getEvents(scope));
}
+ public void query(IProgressMonitor monitor) throws CoreException {
+ TaskActivityProvider reviewTaskProvider = new TaskActivityProvider();
+ reviewTaskProvider.open(manager);
+ reviewTaskProvider.query(scope, monitor);
+
+ initialize();
+ }
+
public void addEvent(ActivityEvent event) {
events.add(event);
}
- public List<ActivityEvent> getEvents() {
+ public Set<ActivityEvent> getEvents() {
return events;
}
@@ -63,5 +75,4 @@ public class ActivityStream implements IActivityStream {
public void removeEvent(ActivityEvent event) {
events.remove(event);
}
-
-}
+} \ No newline at end of file
diff --git a/org.eclipse.mylyn.tasks.activity.core/src/org/eclipse/mylyn/internal/tasks/activity/core/TaskActivityProvider.java b/org.eclipse.mylyn.tasks.activity.core/src/org/eclipse/mylyn/internal/tasks/activity/core/TaskActivityProvider.java
index 0ddcd9c..3c97d4a 100644
--- a/org.eclipse.mylyn.tasks.activity.core/src/org/eclipse/mylyn/internal/tasks/activity/core/TaskActivityProvider.java
+++ b/org.eclipse.mylyn.tasks.activity.core/src/org/eclipse/mylyn/internal/tasks/activity/core/TaskActivityProvider.java
@@ -11,38 +11,32 @@
package org.eclipse.mylyn.internal.tasks.activity.core;
-import org.eclipse.core.runtime.Assert;
+import java.util.HashMap;
+import java.util.Map;
+
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.mylyn.internal.tasks.core.TaskList;
+import org.eclipse.mylyn.internal.tasks.index.core.TaskListIndex;
+import org.eclipse.mylyn.internal.tasks.index.core.TaskListIndex.TaskCollector;
+import org.eclipse.mylyn.internal.tasks.index.ui.IndexReference;
import org.eclipse.mylyn.tasks.activity.core.ActivityEvent;
import org.eclipse.mylyn.tasks.activity.core.ActivityScope;
import org.eclipse.mylyn.tasks.activity.core.TaskActivityScope;
import org.eclipse.mylyn.tasks.activity.core.spi.ActivityProvider;
import org.eclipse.mylyn.tasks.activity.core.spi.IActivitySession;
-import org.eclipse.mylyn.tasks.core.IRepositoryManager;
import org.eclipse.mylyn.tasks.core.ITask;
/**
* @author Steffen Pingel
+ * @author Timur Achmetow
*/
+@SuppressWarnings("restriction")
public class TaskActivityProvider extends ActivityProvider {
- public static final String ID_PROVIDER = "org.eclipse.mylyn.tasks.activity.core.providers.TaskActivityProvider"; //$NON-NLS-1$
+ private static final String UNKNOWN = "Unknown"; //$NON-NLS-1$
private IActivitySession session;
- private final IRepositoryManager repositoryManager;
-
- private final TaskList taskList;
-
- public TaskActivityProvider(IRepositoryManager repositoryManager, TaskList taskList) {
- Assert.isNotNull(repositoryManager);
- Assert.isNotNull(taskList);
- this.repositoryManager = repositoryManager;
- this.taskList = taskList;
- }
-
@Override
public void open(IActivitySession session) {
this.session = session;
@@ -52,12 +46,14 @@ public class TaskActivityProvider extends ActivityProvider {
public void query(ActivityScope scope, IProgressMonitor monitor) throws CoreException {
if (scope instanceof TaskActivityScope) {
ITask scopeTask = ((TaskActivityScope) scope).getTask();
- for (ITask task : taskList.getAllTasks()) {
- if (task.getSummary().contains(scopeTask.getTaskId())) {
- ActivityEvent event = new ActivityEvent(task.getHandleIdentifier(), ID_PROVIDER, task.getSummary(),
- task.getCreationDate(), null);
- session.fireActivityEvent(event);
- }
+
+ GetAssociatedTasks collector = new GetAssociatedTasks(session);
+ IndexReference reference = new IndexReference();
+ try {
+ TaskListIndex taskListIndex = reference.index();
+ taskListIndex.find(scopeTask.getTaskKey(), collector, 50);
+ } finally {
+ reference.dispose();
}
}
}
@@ -66,4 +62,36 @@ public class TaskActivityProvider extends ActivityProvider {
public void close() {
}
+ private static class GetAssociatedTasks extends TaskCollector {
+ private final IActivitySession session;
+
+ public GetAssociatedTasks(IActivitySession session) {
+ this.session = session;
+ }
+
+ @Override
+ public void collect(ITask task) {
+
+ Map<String, String> attrMap = new HashMap<String, String>();
+ attrMap.put("author", getAuthor(task)); //$NON-NLS-1$
+ attrMap.put("taskId", getTaskId(task)); //$NON-NLS-1$
+ ActivityEvent activityEvent = new ActivityEvent(task.getHandleIdentifier(), task.getConnectorKind(),
+ task.getSummary(), task.getCreationDate(), attrMap);
+ session.fireActivityEvent(activityEvent);
+ }
+
+ private String getTaskId(ITask task) {
+ if (task.getTaskId() == null) {
+ return UNKNOWN;
+ }
+ return task.getTaskId();
+ }
+
+ private String getAuthor(ITask task) {
+ if (task.getOwner() == null) {
+ return UNKNOWN;
+ }
+ return task.getOwner();
+ }
+ }
}
diff --git a/org.eclipse.mylyn.tasks.activity.core/src/org/eclipse/mylyn/tasks/activity/core/ActivityEvent.java b/org.eclipse.mylyn.tasks.activity.core/src/org/eclipse/mylyn/tasks/activity/core/ActivityEvent.java
index 05a81dd..6344f45 100644
--- a/org.eclipse.mylyn.tasks.activity.core/src/org/eclipse/mylyn/tasks/activity/core/ActivityEvent.java
+++ b/org.eclipse.mylyn.tasks.activity.core/src/org/eclipse/mylyn/tasks/activity/core/ActivityEvent.java
@@ -15,11 +15,13 @@ import java.util.Date;
import java.util.Map;
import org.eclipse.core.runtime.Assert;
+import org.eclipse.mylyn.commons.core.CoreUtil;
/**
* @author Steffen Pingel
+ * @author Timur Achmetow
*/
-public class ActivityEvent {
+public class ActivityEvent implements Comparable<ActivityEvent> {
private final String handle;
@@ -32,10 +34,9 @@ public class ActivityEvent {
private final Map<String, String> attributes;
public ActivityEvent(String handle, String kind, String summary, Date date, Map<String, String> attributes) {
- Assert.isNotNull(handle);
- Assert.isNotNull(kind);
- Assert.isNotNull(summary);
- Assert.isNotNull(date);
+ Assert.isNotNull("Handle must not be null", handle); //$NON-NLS-1$
+ Assert.isNotNull("Task kind must not be null", kind); //$NON-NLS-1$
+ Assert.isNotNull("Task summary must not be null", summary); //$NON-NLS-1$
this.handle = handle;
this.kind = kind;
this.summary = summary;
@@ -93,4 +94,7 @@ public class ActivityEvent {
return true;
}
-}
+ public int compareTo(ActivityEvent object) {
+ return CoreUtil.compare(date, object.getDate());
+ }
+} \ No newline at end of file
diff --git a/org.eclipse.mylyn.tasks.activity.core/src/org/eclipse/mylyn/tasks/activity/core/IActivityStream.java b/org.eclipse.mylyn.tasks.activity.core/src/org/eclipse/mylyn/tasks/activity/core/IActivityStream.java
index c48d588..9ce2137 100644
--- a/org.eclipse.mylyn.tasks.activity.core/src/org/eclipse/mylyn/tasks/activity/core/IActivityStream.java
+++ b/org.eclipse.mylyn.tasks.activity.core/src/org/eclipse/mylyn/tasks/activity/core/IActivityStream.java
@@ -1,7 +1,3 @@
-package org.eclipse.mylyn.tasks.activity.core;
-
-import java.util.List;
-
/*******************************************************************************
* Copyright (c) 2012 Tasktop Technologies and others.
* All rights reserved. This program and the accompanying materials
@@ -13,15 +9,24 @@ import java.util.List;
* Tasktop Technologies - initial API and implementation
*******************************************************************************/
+package org.eclipse.mylyn.tasks.activity.core;
+
+import java.util.Set;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+
/**
* Defines a stream of {@link ActivityEvent}s that
*
- * @author spingel
+ * @author Steffen Pingel
+ * @author Timur Achmetow
*/
public interface IActivityStream {
- List<ActivityEvent> getEvents();
+ Set<ActivityEvent> getEvents();
ActivityScope getScope();
+ void query(IProgressMonitor monitor) throws CoreException;
}
diff --git a/org.eclipse.mylyn.tasks.activity.tests/META-INF/MANIFEST.MF b/org.eclipse.mylyn.tasks.activity.tests/META-INF/MANIFEST.MF
index e2e12c1..1ec9035 100644
--- a/org.eclipse.mylyn.tasks.activity.tests/META-INF/MANIFEST.MF
+++ b/org.eclipse.mylyn.tasks.activity.tests/META-INF/MANIFEST.MF
@@ -9,8 +9,10 @@ Require-Bundle: org.junit;bundle-version="4.5.0",
org.eclipse.core.runtime,
org.eclipse.mylyn.commons.core,
org.eclipse.mylyn.commons.sdk.util,
+ org.eclipse.jface,
org.eclipse.mylyn.tasks.core,
org.eclipse.mylyn.tasks.activity.core,
org.eclipse.mylyn.tasks.activity.ui,
- org.eclipse.jface
+ org.eclipse.mylyn.tasks.index.core;bundle-version="3.9.0",
+ org.eclipse.mylyn.tasks.index.ui;bundle-version="3.9.0"
Export-Package: org.eclipse.mylyn.tasks.activity.tests;x-internal:=true
diff --git a/org.eclipse.mylyn.tasks.activity.tests/src/org/eclipse/mylyn/tasks/activity/tests/TaskActivityProviderTest.java b/org.eclipse.mylyn.tasks.activity.tests/src/org/eclipse/mylyn/tasks/activity/tests/TaskActivityProviderTest.java
index eed2b3f..b9734d5 100644
--- a/org.eclipse.mylyn.tasks.activity.tests/src/org/eclipse/mylyn/tasks/activity/tests/TaskActivityProviderTest.java
+++ b/org.eclipse.mylyn.tasks.activity.tests/src/org/eclipse/mylyn/tasks/activity/tests/TaskActivityProviderTest.java
@@ -19,35 +19,65 @@ import java.util.Date;
import java.util.List;
import org.eclipse.mylyn.internal.tasks.activity.core.TaskActivityProvider;
-import org.eclipse.mylyn.internal.tasks.core.LocalTask;
+import org.eclipse.mylyn.internal.tasks.core.LocalRepositoryConnector;
import org.eclipse.mylyn.internal.tasks.core.TaskList;
-import org.eclipse.mylyn.internal.tasks.core.TaskRepositoryManager;
+import org.eclipse.mylyn.internal.tasks.core.TaskTask;
+import org.eclipse.mylyn.internal.tasks.index.core.TaskListIndex;
+import org.eclipse.mylyn.internal.tasks.index.ui.IndexReference;
import org.eclipse.mylyn.tasks.activity.core.ActivityEvent;
import org.eclipse.mylyn.tasks.activity.core.IActivityManager;
import org.eclipse.mylyn.tasks.activity.core.TaskActivityScope;
import org.eclipse.mylyn.tasks.activity.core.spi.IActivitySession;
-import org.eclipse.mylyn.tasks.core.IRepositoryManager;
+import org.junit.After;
+import org.junit.Before;
import org.junit.Test;
/**
* @author Steffen Pingel
+ * @author Timur Achmetow
*/
+@SuppressWarnings("restriction")
public class TaskActivityProviderTest {
-
protected List<ActivityEvent> events = new ArrayList<ActivityEvent>();
- @Test
- public void testActivityStream() throws Exception {
- IRepositoryManager repositoryManager = new TaskRepositoryManager();
- TaskList taskList = new TaskList();
- LocalTask searchTask = new LocalTask("1", "summary");
- LocalTask task1 = new LocalTask("2", "1: hit");
+ private IndexReference reference;
+
+ private TaskTask task1;
+
+ @Before
+ public void setUp() throws Exception {
+ task1 = new TaskTask(LocalRepositoryConnector.CONNECTOR_KIND, LocalRepositoryConnector.REPOSITORY_URL, "2");
+ task1.setSummary("1: hit");
+ task1.setTaskKey("2");
task1.setCreationDate(new Date());
- LocalTask task2 = new LocalTask("3", "2: miss");
+
+ TaskTask task2 = new TaskTask(LocalRepositoryConnector.CONNECTOR_KIND, LocalRepositoryConnector.REPOSITORY_URL,
+ "3");
+ task2.setSummary("2: miss");
+ task2.setTaskKey("3");
task2.setCreationDate(new Date());
- taskList.addTask(task1);
- taskList.addTask(task2);
- TaskActivityProvider provider = new TaskActivityProvider(repositoryManager, taskList);
+
+ reference = new IndexReference();
+ TaskListIndex taskListIndex = reference.index();
+ taskListIndex.getTaskList().addTask(task1);
+ taskListIndex.getTaskList().addTask(task2);
+ taskListIndex.waitUntilIdle();
+ }
+
+ @After
+ public void tearDown() {
+ ((TaskList) reference.index().getTaskList()).reset();
+ reference.dispose();
+ }
+
+ @Test
+ public void testActivityStream() throws Exception {
+ TaskTask searchTask = new TaskTask(LocalRepositoryConnector.CONNECTOR_KIND,
+ LocalRepositoryConnector.REPOSITORY_URL, "1");
+ searchTask.setSummary("summary");
+ searchTask.setTaskKey("1");
+
+ TaskActivityProvider provider = new TaskActivityProvider();
IActivitySession session = new IActivitySession() {
public IActivityManager getManger() {
return null;
@@ -60,9 +90,9 @@ public class TaskActivityProviderTest {
provider.open(session);
provider.query(new TaskActivityScope(searchTask), null);
- ActivityEvent expected = new ActivityEvent(task1.getHandleIdentifier(), TaskActivityProvider.ID_PROVIDER,
+ ActivityEvent expected = new ActivityEvent(task1.getHandleIdentifier(), task1.getConnectorKind(),
task1.getSummary(), task1.getCreationDate(), null);
+
assertEquals(Collections.singletonList(expected), events);
}
-
-}
+} \ No newline at end of file
diff --git a/org.eclipse.mylyn.tasks.activity.ui/META-INF/MANIFEST.MF b/org.eclipse.mylyn.tasks.activity.ui/META-INF/MANIFEST.MF
index a2be901..1fbc7a7 100644
--- a/org.eclipse.mylyn.tasks.activity.ui/META-INF/MANIFEST.MF
+++ b/org.eclipse.mylyn.tasks.activity.ui/META-INF/MANIFEST.MF
@@ -10,5 +10,6 @@ Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
org.eclipse.mylyn.tasks.core;bundle-version="3.8.0",
org.eclipse.mylyn.tasks.ui;bundle-version="3.8.0",
- org.eclipse.mylyn.tasks.activity.core;bundle-version="3.9.0"
+ org.eclipse.mylyn.tasks.activity.core;bundle-version="3.9.0",
+ org.eclipse.mylyn.commons.core;bundle-version="3.9.0"
Bundle-Localization: plugin
diff --git a/org.eclipse.mylyn.tasks.activity.ui/src/org/eclipse/mylyn/internal/tasks/activity/ui/ActivityPart.java b/org.eclipse.mylyn.tasks.activity.ui/src/org/eclipse/mylyn/internal/tasks/activity/ui/ActivityPart.java
index e04927a..f87d4ae 100644
--- a/org.eclipse.mylyn.tasks.activity.ui/src/org/eclipse/mylyn/internal/tasks/activity/ui/ActivityPart.java
+++ b/org.eclipse.mylyn.tasks.activity.ui/src/org/eclipse/mylyn/internal/tasks/activity/ui/ActivityPart.java
@@ -12,8 +12,11 @@
package org.eclipse.mylyn.internal.tasks.activity.ui;
import org.eclipse.jface.layout.GridDataFactory;
+import org.eclipse.jface.viewers.DecoratingStyledCellLabelProvider;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.mylyn.internal.tasks.activity.core.ActivityManager;
+import org.eclipse.mylyn.internal.tasks.activity.ui.provider.ActivityRecordContentProvider;
+import org.eclipse.mylyn.internal.tasks.activity.ui.provider.ActivityRecordLabelProvider;
import org.eclipse.mylyn.tasks.activity.core.IActivityStream;
import org.eclipse.mylyn.tasks.activity.core.TaskActivityScope;
import org.eclipse.mylyn.tasks.ui.editors.AbstractTaskEditorPart;
@@ -52,11 +55,10 @@ public class ActivityPart extends AbstractTaskEditorPart {
private void createTreeViewer(FormToolkit toolkit, Composite activityComposite) {
TreeViewer viewer = new TreeViewer(toolkit.createTree(activityComposite, SWT.MULTI | SWT.H_SCROLL
- | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.BORDER));
+ | SWT.V_SCROLL | SWT.FULL_SELECTION));
GridDataFactory.fillDefaults().hint(500, 100).grab(true, true).applyTo(viewer.getControl());
- viewer.getTree().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
viewer.setContentProvider(new ActivityRecordContentProvider());
-// viewer.setLabelProvider(new DecoratingStyledCellLabelProvider(new ActivityRecordLabelProvider(), null, null));
+ viewer.setLabelProvider(new DecoratingStyledCellLabelProvider(new ActivityRecordLabelProvider(), null, null));
IActivityStream stream = new ActivityManager().getStream(new TaskActivityScope(getModel().getTask()));
viewer.setInput(stream);
}
diff --git a/org.eclipse.mylyn.tasks.activity.ui/src/org/eclipse/mylyn/internal/tasks/activity/ui/ActivityRecordContentProvider.java b/org.eclipse.mylyn.tasks.activity.ui/src/org/eclipse/mylyn/internal/tasks/activity/ui/provider/ActivityRecordContentProvider.java
index 6763e6b..308cb12 100644
--- a/org.eclipse.mylyn.tasks.activity.ui/src/org/eclipse/mylyn/internal/tasks/activity/ui/ActivityRecordContentProvider.java
+++ b/org.eclipse.mylyn.tasks.activity.ui/src/org/eclipse/mylyn/internal/tasks/activity/ui/provider/ActivityRecordContentProvider.java
@@ -9,13 +9,14 @@
* Timur Achmetow - initial API and implementation
*******************************************************************************/
-package org.eclipse.mylyn.internal.tasks.activity.ui;
-
-import java.util.List;
+package org.eclipse.mylyn.internal.tasks.activity.ui.provider;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.mylyn.tasks.activity.core.ActivityEvent;
+import org.eclipse.mylyn.commons.core.StatusHandler;
import org.eclipse.mylyn.tasks.activity.core.IActivityStream;
/**
@@ -23,28 +24,29 @@ import org.eclipse.mylyn.tasks.activity.core.IActivityStream;
*/
@SuppressWarnings("restriction")
public class ActivityRecordContentProvider implements ITreeContentProvider {
+ private static final String PLUGIN_ID = "org.eclipse.mylyn.tasks.activity.ui"; //$NON-NLS-1$
+
private static final Object[] NO_ELEMENTS = new Object[0];
- private List<ActivityEvent> eventList;
+ private IActivityStream activityStream;
public void dispose() {
- eventList = null;
+ activityStream = null;
}
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
if (newInput instanceof IActivityStream) {
- eventList = ((IActivityStream) newInput).getEvents();
+ IActivityStream activityStream = (IActivityStream) newInput;
+ querryProvider(activityStream);
+ this.activityStream = activityStream;
}
}
public Object[] getElements(Object inputElement) {
- return eventList.toArray();
+ return activityStream.getEvents().toArray();
}
public Object[] getChildren(Object parentElement) {
-// if (parentElement instanceof ActivityCommitEvent) {
-// return ((ActivityCommitEvent) parentElement).getChanges().toArray();
-// }
return NO_ELEMENTS;
}
@@ -53,9 +55,15 @@ public class ActivityRecordContentProvider implements ITreeContentProvider {
}
public boolean hasChildren(Object element) {
-// if (element instanceof ActivityCommitEvent) {
-// return true;
-// }
return false;
}
+
+ private void querryProvider(IActivityStream activityStream) {
+ try {
+ activityStream.query(null);
+ } catch (CoreException e) {
+ StatusHandler.log(new Status(IStatus.ERROR, PLUGIN_ID,
+ "Problem occured when querry the TaskActivityProvider.", e)); //$NON-NLS-1$
+ }
+ }
} \ No newline at end of file
diff --git a/org.eclipse.mylyn.tasks.activity.ui/src/org/eclipse/mylyn/internal/tasks/activity/ui/provider/ActivityRecordLabelProvider.java b/org.eclipse.mylyn.tasks.activity.ui/src/org/eclipse/mylyn/internal/tasks/activity/ui/provider/ActivityRecordLabelProvider.java
new file mode 100644
index 0000000..42dfeab
--- /dev/null
+++ b/org.eclipse.mylyn.tasks.activity.ui/src/org/eclipse/mylyn/internal/tasks/activity/ui/provider/ActivityRecordLabelProvider.java
@@ -0,0 +1,52 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Timur Achmetow 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:
+ * Timur Achmetow - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.mylyn.internal.tasks.activity.ui.provider;
+
+import org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider.IStyledLabelProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.StyledString;
+import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin;
+import org.eclipse.mylyn.tasks.activity.core.ActivityEvent;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.graphics.Image;
+
+/**
+ * @author Timur Achmetow
+ */
+@SuppressWarnings("restriction")
+public class ActivityRecordLabelProvider extends LabelProvider implements IStyledLabelProvider {
+
+ @Override
+ public Image getImage(Object element) {
+ return TasksUiPlugin.getDefault().getBrandingIcon(((ActivityEvent) element).getKind());
+ }
+
+ @Override
+ public String getText(Object element) {
+ return NLS.bind("Change {0}: {1}", ((ActivityEvent) element).getAttributes().get("taskId"), //$NON-NLS-1$ //$NON-NLS-2$
+ ((ActivityEvent) element).getSummary());
+ }
+
+ public StyledString getStyledText(Object element) {
+ String text = getText(element);
+ if (text != null) {
+ StyledString styledString = new StyledString(text);
+ String reviewText = NLS.bind(" ({0}, {1})", //$NON-NLS-1$
+ ((ActivityEvent) element).getAttributes().get("author"), ((ActivityEvent) element).getDate()); //$NON-NLS-1$
+
+ styledString.append(reviewText, StyledString.DECORATIONS_STYLER);
+
+ return styledString;
+ }
+ return new StyledString();
+ }
+} \ No newline at end of file