Skip to main content
summaryrefslogtreecommitdiffstats
blob: 9476d33bbdb1f1b37ed140ad07c425a6b60c6204 (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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/*******************************************************************************
 * Copyright (c) 2004, 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.views;

import org.eclipse.jface.viewers.DecoratingLabelProvider;
import org.eclipse.jface.viewers.ILabelDecorator;
import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.viewers.ITableLabelProvider;
import org.eclipse.mylyn.commons.ui.CommonImages;
import org.eclipse.mylyn.internal.tasks.core.AbstractTask;
import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin;
import org.eclipse.mylyn.tasks.core.IRepositoryQuery;
import org.eclipse.mylyn.tasks.core.ITask;
import org.eclipse.mylyn.tasks.core.ITaskContainer;
import org.eclipse.mylyn.tasks.ui.TasksUiImages;
import org.eclipse.swt.graphics.Image;

/**
 * @author Mik Kersten
 */
public class TableDecoratingLabelProvider extends DecoratingLabelProvider implements ITableLabelProvider {

	public TableDecoratingLabelProvider(ILabelProvider provider, ILabelDecorator decorator) {
		super(provider, decorator);
	}

	public Image getColumnImage(Object element, int columnIndex) {
		if (!(element instanceof ITaskContainer)) {
			return null;
		}
		if (columnIndex == 0) {
			if (element instanceof ITaskContainer && !(element instanceof ITask)) {
				return super.getImage(element);
			} else {
				if (element instanceof AbstractTask) {
					AbstractTask task = (AbstractTask) element;
					if (task.isActive()) {
						return CommonImages.getImage(TasksUiImages.CONTEXT_ACTIVE);
					} else {
						if (TasksUiPlugin.getContextStore().hasContext(task)) {
							return CommonImages.getImage(TasksUiImages.CONTEXT_INACTIVE);
						} else {
							return CommonImages.getImage(TasksUiImages.CONTEXT_INACTIVE_EMPTY);
						}
					}
				} else {
					return CommonImages.getImage(TasksUiImages.CONTEXT_INACTIVE_EMPTY);
				}
			}
		} else if (columnIndex == 1) {
			if (element instanceof ITaskContainer || element instanceof IRepositoryQuery) {
				return null;
			}
			return super.getImage(element);
		}
		return null;
	}

	public String getColumnText(Object element, int columnIndex) {
		return null;
	}

}

Back to the top