Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTimur Achmetow2012-09-11 22:04:05 +0000
committerSteffen Pingel2012-09-12 18:05:34 +0000
commit2ae43597001255763babb158ef43b1e96d48b166 (patch)
tree39ee03d9b64376a4df0f8a46c218065723050b2b /org.eclipse.mylyn.tasks.activity.ui
parent8e0212d19495b6827fae5b4354775437d9a1ebf9 (diff)
downloadorg.eclipse.mylyn.tasks-2ae43597001255763babb158ef43b1e96d48b166.tar.gz
org.eclipse.mylyn.tasks-2ae43597001255763babb158ef43b1e96d48b166.tar.xz
org.eclipse.mylyn.tasks-2ae43597001255763babb158ef43b1e96d48b166.zip
378101: add activity provider for related tasks such as reviews
Task-Url: https://bugs.eclipse.org/bugs/show_bug.cgi?id=378101 Change-Id: Ib63e5f52780d82cf90364921edecb0ac5c38e627
Diffstat (limited to 'org.eclipse.mylyn.tasks.activity.ui')
-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
4 files changed, 81 insertions, 18 deletions
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 a2be9016c..1fbc7a739 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 e04927acc..f87d4ae9b 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 6763e6b15..308cb1252 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 000000000..42dfeabd8
--- /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

Back to the top