Skip to main content
summaryrefslogtreecommitdiffstats
blob: 42dfeabd8784b35cd508a4286ba7e8d3aebeab23 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
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();
	}
}

Back to the top