blob: 308c35755a1fbf8a851024d1cd44fced459f7b14 (
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
|
/*******************************************************************************
* Copyright (c) 2004 - 2005 University Of British Columbia 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:
* University Of British Columbia - initial API and implementation
*******************************************************************************/
/*
* Created on Feb 18, 2005
*/
package org.eclipse.mylar.tasks.ui.views;
import org.eclipse.jface.viewers.IColorProvider;
import org.eclipse.jface.viewers.IFontProvider;
import org.eclipse.jface.viewers.ITableLabelProvider;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.mylar.tasks.BugzillaTask;
import org.eclipse.mylar.tasks.ITask;
import org.eclipse.mylar.ui.MylarImages;
import org.eclipse.mylar.ui.MylarUiPlugin;
import org.eclipse.mylar.ui.internal.UiUtil;
import org.eclipse.mylar.ui.internal.views.Highlighter;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.Image;
/**
* @author Mik Kersten
*/
public class TaskListLabelProvider extends LabelProvider implements ITableLabelProvider, IColorProvider, IFontProvider {
private Color backgroundColor = null;
public String getColumnText(Object obj, int columnIndex) {
if (obj instanceof ITask) {
ITask task = (ITask) obj;
switch (columnIndex) {
case 0: return " "; // padding for background
case 1: return "";
case 2:
if (task.isCategory()) {
return "";
} else {
return task.getPriority();
}
case 3:
return task.getLabel();
case 4:
return task.getHandle();
}
}
return null;
}
public Font getFont(Object element) {
if (element instanceof ITask) {
ITask task = (ITask)element;
if (task.isCategory()) {
for (ITask child : task.getChildren()) {
if (child.isActive()) return UiUtil.BOLD;
}
}
if (task.isActive()) return UiUtil.BOLD;
if (task.isCompleted()) return UiUtil.ITALIC;
}
return null;
}
public Image getColumnImage(Object element, int columnIndex) {
if (!(element instanceof ITask)) {
return null;
}
if (columnIndex == 0) {
if (((ITask) element).isCategory()) {
return null;
}
if (((ITask) element).isActive()) {
return MylarImages.getImage(MylarImages.TASK_ACTIVE);
} else {
return MylarImages.getImage(MylarImages.TASK_INACTIVE);
}
} else if (columnIndex == 1) {
if (((ITask) element).isCategory()) {
return null;
// return MylarImages.getImage(MylarImages.CATEGORY);
} else if (element instanceof BugzillaTask) {
return MylarImages.getImage(MylarImages.TASK_BUGZILLA);
} else {
return MylarImages.getImage(MylarImages.TASK);
}
} else {
return null;
}
}
public Color getBackground(Object element) {
if (element instanceof ITask) {
ITask task = (ITask)element;
if (task.isCategory()) {
return backgroundColor;
}
Highlighter highlighter = MylarUiPlugin.getDefault().getHighlighterForTaskId("" + task.getHandle());
if (highlighter != null) return highlighter.getHighlightColor();
}
return null;
}
public Color getForeground(Object element) {
if (element instanceof ITask) {
ITask task = (ITask)element;
if (task.isCompleted()) return MylarUiPlugin.getDefault().getColorMap().GRAY_VERY_LIGHT;
}
return null;
}
public void setBackgroundColor(Color c) {
this.backgroundColor = c;
}
}
//public Image getColumnImage(Object obj, int columnIndex) {
//if (obj instanceof Highlighter) {
// Highlighter h = (Highlighter) obj;
// switch (columnIndex) {
// case 1:
// HighlighterImageDescriptor des;
// if (h.isGradient()) {
// des = new HighlighterImageDescriptor(h.getBase(), h
// .getLandmarkColor());
// } else {
// des = new HighlighterImageDescriptor(h
// .getLandmarkColor(), h.getLandmarkColor());
// }
// return des.getImage();
// default:
// break;
// }
// }
// return null;
//}
//public Color getBackground(Object element) {
//if (element instanceof Task) {
// Task task = (Task)element;
// if (task.isActive()) {
// Highlighter highlighter = MylarUiPlugin.getDefault().getHighlighterForTaskId(((Task)task).getId());
// if (highlighter != null) {
// return highlighter.getHighlightColor();
// } else {
// return null;
// }
// }
//}
//return null;
//}
//public class TaskListLabelProvider extends LabelProvider implements IColorProvider, IFontProvider {
//
// public String getText(Object obj) {
// if (obj instanceof BugzillaTask) {
// String desc = MylarTasksPlugin.getDefault().getBugzillaProvider().getBugzillaDescription(
// ((BugzillaTask)obj));
// return desc;
// } else if (obj instanceof Task) {
// Task task = (Task)obj;
// return task.toString();// + " [" + task.getId() + "]";
// } else {
// return obj.toString();
// }
// }
//
// public Image getImage(Object obj) {
// String imageKey = ISharedImages.IMG_OBJ_ELEMENT;
// if (obj instanceof BugzillaTask) {
// return MylarImages.getImage(MylarImages.TASK_BUGZILLA);
// } else if (obj instanceof Task) {
// return MylarImages.getImage(MylarImages.TASK);
// } else {
// return null;
// }
// }
// public Color getForeground(Object element) {
// return null;
// }
//
// public Color getBackground(Object element) {
// if (element instanceof Task) {
// Task task = (Task)element;
// if (task.isActive()) {
// Highlighter highlighter = MylarUiPlugin.getDefault().getHighlighterForTaskId(((Task)task).getId());
// if (highlighter != null) {
// return highlighter.getHighlightColor();
// } else {
// return null;
// }
// }
// }
// return null;
// }
//
// public Font getFont(Object element) {
// if (element instanceof Task) {
// if (((Task)element).isActive()) {
// return UiUtil.BOLD;
// }
// }
// return null;
// }
//}
|