Skip to main content
summaryrefslogtreecommitdiffstats
blob: d6ee294427ba85f912c08ca2b5ad90fdb35064f2 (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
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
/*******************************************************************************
 * Copyright (c) 2004 - 2006 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 Apr 20, 2004
 */
package org.eclipse.mylyn.internal.tasks.ui;

import java.net.MalformedURLException;
import java.net.URL;

import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.resource.ImageRegistry;
import org.eclipse.mylyn.tasks.core.AbstractTask.PriorityLevel;
import org.eclipse.mylyn.tasks.ui.TasksUiPlugin;
import org.eclipse.swt.graphics.Image;

/**
 * NOTE: if you create your own image descriptors you are responsible for disposing them.
 * 
 * @author Mik Kersten
 */
public class TasksUiImages {

	private static ImageRegistry imageRegistry;

	private static final String T_ELCL = "elcl16";

	private static final String T_EVIEW = "eview16";

	private static final String T_TOOL = "etool16";

	private static final String T_OBJ = "obj16";

	private static final String T_WIZBAN = "wizban";

	private static final String T_OVR = "ovr16";

	private static final URL baseURL = TasksUiPlugin.getDefault().getBundle().getEntry("/icons/");

	public static final ImageDescriptor TASK_ACTIVE = create(T_TOOL, "task-active.gif");

	public static final ImageDescriptor TASK_ACTIVE_CENTERED = create(T_TOOL, "task-active-centered.gif");

	public static final ImageDescriptor TASK_INACTIVE = create(T_TOOL, "task-inactive.gif");

	public static final ImageDescriptor TASK_INACTIVE_CONTEXT = create(T_TOOL, "task-context.gif");

	public static final ImageDescriptor TASK_COMPLETE = create(T_TOOL, "task-complete.gif");

	public static final ImageDescriptor TASK_INCOMPLETE = create(T_TOOL, "task-incomplete.gif");

	public static final ImageDescriptor TASK = create(T_TOOL, "task.gif");

	public static final ImageDescriptor TASK_COMPLETED = create(T_TOOL, "task-completed.gif");

	public static final ImageDescriptor TASK_NOTES = create(T_TOOL, "task-notes.gif");

	public static final ImageDescriptor TASK_NEW = create(T_TOOL, "task-new.gif");

	public static final ImageDescriptor TASK_REPOSITORY_HISTORY = create(T_TOOL, "task-repository-history.gif");

	public static final ImageDescriptor TASK_REPOSITORY_NOTES = create(T_TOOL, "task-repository-notes.gif");

	public static final ImageDescriptor TASK_REPOSITORY_COMPLETED = create(T_TOOL, "task-repository-completed.gif");

	public static final ImageDescriptor TASK_REMOTE = create(T_TOOL, "task-remote.gif");

	public static final ImageDescriptor TASK_WORKING_SET = create(T_TOOL, "open-task.gif");

	public static final ImageDescriptor TASKLIST = create("eview16", "task-list.gif");

	public static final ImageDescriptor REPOSITORY = create("eview16", "repository.gif");

	public static final ImageDescriptor REPOSITORY_SUBMIT = create(T_TOOL, "repository-submit.gif");

	public static final ImageDescriptor REPOSITORY_SMALL = create(T_OBJ, "repository-small.gif");

	public static final ImageDescriptor REPOSITORY_NEW = create("etool16", "repository-new.gif");

	public static final ImageDescriptor REPOSITORIES = create("eview16", "repositories.gif");

	public static final ImageDescriptor REMOVE = create(T_ELCL, "remove.gif");

	public static final ImageDescriptor DELETE = create(T_ELCL, "delete.gif");

	public static final ImageDescriptor FILTER_COMPLETE = create(T_ELCL, "filter-complete.gif");

	public static final ImageDescriptor FILTER_ARCHIVE = create(T_ELCL, "filter-archive.gif");

	public static final ImageDescriptor FILTER_PRIORITY = create(T_ELCL, "filter-priority.gif");

	public static final ImageDescriptor COLOR_PALETTE = create(T_ELCL, "color-palette.gif");

	public static final ImageDescriptor FILTER = create(T_TOOL, "view-filter.gif");

	public static final ImageDescriptor FIND_CLEAR = create(T_TOOL, "find-clear.gif");

	public static final ImageDescriptor FIND_CLEAR_DISABLED = create(T_TOOL, "find-clear-disabled.gif");

	public static final ImageDescriptor WARNING = create(T_ELCL, "warning.gif");

	public static final ImageDescriptor OVERLAY_WEB = create(T_TOOL, "overlay-web.gif");

	public static final ImageDescriptor OVERLAY_OFFLINE = create(T_EVIEW, "overlay-offline.gif");

	public static final ImageDescriptor BROWSER_SMALL = create(T_OBJ, "browser-small.gif");

	public static final ImageDescriptor BROWSER_OPEN_TASK = create(T_TOOL, "open-browser.gif");

	public static final ImageDescriptor OVERLAY_SYNCHRONIZING = create(T_EVIEW, "overlay-synchronizing.gif");

	public static final ImageDescriptor OVERLAY_HAS_DUE = create(T_EVIEW, "overlay-has-due.gif");

	public static final ImageDescriptor OVERLAY_OVER_DUE = create(T_EVIEW, "overlay-overdue.gif");

	public static final ImageDescriptor OVERLAY_SOLID_WHITE = create(T_OVR, "solid-white.gif");

	public static final ImageDescriptor TASK_WEB_REMOTE = create(T_TOOL, "overlay-web.gif");

	public static final ImageDescriptor CATEGORY = create(T_TOOL, "category.gif");

	public static final ImageDescriptor CATEGORY_NEW = create(T_TOOL, "category-new.gif");

	public static final ImageDescriptor CATEGORY_ARCHIVE = create(T_TOOL, "category-archive.gif");

	public static final ImageDescriptor TASK_REPOSITORY = create(T_TOOL, "task-repository.gif");

	public static final ImageDescriptor TASK_REPOSITORY_NEW = create(T_TOOL, "task-repository-new.gif");

	public static final ImageDescriptor TOOLBAR_ARROW_RIGHT = create(T_TOOL, "toolbar-arrow-right.gif");

	public static final ImageDescriptor TOOLBAR_ARROW_DOWN = create(T_TOOL, "toolbar-arrow-down.gif");

	public static final ImageDescriptor COMMENT = create(T_TOOL, "comment.gif");

	public static final ImageDescriptor LINK_EDITOR = create(T_TOOL, "link-editor.gif");

	public static final ImageDescriptor PERSON = create(T_TOOL, "person.gif");

	public static final ImageDescriptor PERSON_NARROW = create(T_TOOL, "person-narrow.gif");

	public static final ImageDescriptor PERSON_ME = create(T_TOOL, "person-me.gif");

	public static final ImageDescriptor PERSON_ME_NARROW = create(T_TOOL, "person-me-narrow.gif");

	public static final ImageDescriptor CONTEXT_ATTACH = create(T_TOOL, "context-attach.gif");

	public static final ImageDescriptor CONTEXT_RETRIEVE = create(T_TOOL, "context-retrieve.gif");

	public static final ImageDescriptor CONTEXT_TRANSFER = create(T_TOOL, "context-transfer.gif");

	public static final ImageDescriptor CONTEXT_CLEAR = create(T_TOOL, "context-clear.gif");

	public static final ImageDescriptor ATTACHMENT_PATCH = create(T_OBJ, "attachment-patch.gif");

	public static final ImageDescriptor TASK_RETRIEVE = create(T_TOOL, "task-retrieve.gif");

	public static final ImageDescriptor OVERLAY_INCOMMING = create(T_EVIEW, "overlay-incoming.gif");

	public static final ImageDescriptor OVERLAY_INCOMMING_NEW = create(T_EVIEW, "overlay-incoming-new.gif");

	public static final ImageDescriptor OVERLAY_OUTGOING = create(T_EVIEW, "overlay-outgoing.gif");

	public static final ImageDescriptor OVERLAY_SYNCH_INCOMMING = create(T_EVIEW, "overlay-synch-incoming.gif");

	public static final ImageDescriptor OVERLAY_SYNCH_INCOMMING_NEW = create(T_EVIEW, "overlay-synch-incoming-new.gif");

	public static final ImageDescriptor OVERLAY_SYNCH_OUTGOING = create(T_EVIEW, "overlay-synch-outgoing.gif");

	public static final ImageDescriptor OVERLAY_CONFLICT = create(T_EVIEW, "overlay-conflicting.gif");

	public static final ImageDescriptor OVERLAY_REPOSITORY = create(T_EVIEW, "overlay-repository.gif");

	public static final ImageDescriptor OVERLAY_REPOSITORY_CONTEXT = create(T_EVIEW, "overlay-repository-context.gif");

	public static final ImageDescriptor OVERLAY_WARNING = create(T_OVR, "overlay-warning.gif");

	public static final ImageDescriptor OVERLAY_BLANK = create(T_OVR, "overlay-blank.gif");

	public static final ImageDescriptor STATUS_NORMAL = create(T_EVIEW, "status-normal.gif");

	public static final ImageDescriptor STATUS_CONTEXT = create(T_EVIEW, "status-server-context.gif");

	public static final ImageDescriptor QUERY = create(T_TOOL, "query.gif");

	public static final ImageDescriptor QUERY_NEW = create(T_TOOL, "query-new.gif");

	public static final ImageDescriptor REPOSITORY_SYNCHRONIZE = create(T_TOOL, "repository-synchronize.gif");

	public static final ImageDescriptor NAVIGATE_PREVIOUS = create(T_TOOL, "navigate-previous.gif");

	public static final ImageDescriptor NAVIGATE_NEXT = create(T_TOOL, "navigate-next.gif");

	public static final ImageDescriptor TASKLIST_MODE = create(T_TOOL, "tasklist-mode.gif");

	public static final ImageDescriptor COPY = create(T_TOOL, "copy.png");

	public static final ImageDescriptor GO_UP = create(T_TOOL, "go-up.gif");

	public static final ImageDescriptor GO_INTO = create(T_TOOL, "go-into.gif");

	public static final ImageDescriptor REFRESH = create(T_ELCL, "refresh.gif");

	public static final ImageDescriptor REFRESH_SMALL = create(T_ELCL, "refresh-small.gif");

	public static final ImageDescriptor COLLAPSE_ALL = create(T_ELCL, "collapseall.png");

	public static final ImageDescriptor NOTIFICATION_CLOSE = create(T_EVIEW, "notification-close.gif");

	public static final ImageDescriptor EXPAND_ALL = create(T_ELCL, "expandall.gif");

	public static final ImageDescriptor REPLY = create(T_ELCL, "reply.gif");

	public static final ImageDescriptor PRIORITY_1 = create(T_EVIEW, "priority-1.gif");

	public static final ImageDescriptor PRIORITY_2 = create(T_EVIEW, "priority-2.gif");

	public static final ImageDescriptor PRIORITY_3 = create(T_EVIEW, "priority-3.gif");

	public static final ImageDescriptor PRIORITY_4 = create(T_EVIEW, "priority-4.gif");

	public static final ImageDescriptor PRIORITY_5 = create(T_EVIEW, "priority-5.gif");

	public static final ImageDescriptor CALENDAR = create(T_TOOL, "calendar.gif");

	public static final ImageDescriptor CALENDAR_SMALL = create(T_OBJ, "calendar-small.gif");

	public static final ImageDescriptor BANNER_REPOSITORY = create(T_WIZBAN, "banner-repository.gif");

	public static final ImageDescriptor BANNER_WORKING_SET = create(T_WIZBAN, "workset_wiz.png");

	public static final ImageDescriptor BANNER_REPOSITORY_SETTINGS = create(T_WIZBAN, "banner-repository-settings.gif");

	public static final ImageDescriptor BANNER_REPOSITORY_CONTEXT = create(T_WIZBAN, "banner-repository-context.gif");

	public static final ImageDescriptor BANNER_IMPORT = create(T_WIZBAN, "banner-import.gif");

	public static final ImageDescriptor BLANK_TINY = create(T_ELCL, "clearDot.gif");

	public static final ImageDescriptor BLANK = create(T_ELCL, "blank.gif");

	private static ImageDescriptor create(String prefix, String name) {
		try {
			return ImageDescriptor.createFromURL(makeIconFileURL(prefix, name));
		} catch (MalformedURLException e) {
			return ImageDescriptor.getMissingImageDescriptor();
		}
	}

//	private static ImageDescriptor createSize(ImageDescriptor base, Point size) {
//		return new TaskListImageDescriptor(base, size);
//	}

	/**
	 * Lazily initializes image map.
	 */
	public static Image getImage(ImageDescriptor imageDescriptor) {
		ImageRegistry imageRegistry = getImageRegistry();
		Image image = imageRegistry.get("" + imageDescriptor.hashCode());
		if (image == null) {
			image = imageDescriptor.createImage(true);
			imageRegistry.put("" + imageDescriptor.hashCode(), image);
		}
		return image;
	}

	public static Image getImageWithOverlay(ImageDescriptor icon, ImageDescriptor overlay, boolean top, boolean left) {
		if (icon == null) {
			return null;
		}
		String key = "" + icon.hashCode();
		if (overlay != null) {
			key += overlay.hashCode();
		}
		key += new Boolean(top).hashCode();
		key += new Boolean(left).hashCode();

		Image image = getImageRegistry().get(key);

		if (image == null) {
			TaskListImageDescriptor imageDescriptor = new TaskListImageDescriptor(icon, overlay, top, left);
			image = imageDescriptor.createImage(true);
			getImageRegistry().put(key, image);
		}
		return image;
	}

	/**
	 * Lazily initializes image map.
	 * 
	 * @param icon
	 *            cannot be null
	 */
	public static Image getCompositeTaskImage(ImageDescriptor icon, ImageDescriptor overlayKind, boolean wide) {
		if (icon == null) {
			return null;
		}
		String key = "" + icon.hashCode();
		if (overlayKind != null) {
			key += overlayKind.hashCode();
		}
		if (wide) {
			key += ".wide";
		}
		Image image = getImageRegistry().get(key);

		if (image == null) {
			CompositeTaskImageDescriptor imageDescriptor = new CompositeTaskImageDescriptor(icon, overlayKind, wide);
			image = imageDescriptor.createImage(true);
			getImageRegistry().put(key, image);
		}
		return image;
	}

	public static Image getCompositeContainerImage(ImageDescriptor icon, boolean wide) {
		if (icon == null) {
			return null;
		}
		String key = "" + icon.hashCode();
		if (wide) {
			key += ".wide";
		}
		Image image = getImageRegistry().get(key);
		if (image == null) {
			CompositeContainerImageDescriptor imageDescriptor = new CompositeContainerImageDescriptor(icon,
					OVERLAY_BLANK, wide);
			image = imageDescriptor.createImage(true);
			getImageRegistry().put(key, image);
		}
		return image;
	}

	public static Image getCompositeSynchImage(ImageDescriptor icon, boolean background) {
		String key = "" + icon.hashCode();
		if (background) {
			key += ".background";
		}

		Image image = getImageRegistry().get(key);
		if (image == null) {
			CompositeSynchImageDescriptor imageDescriptor = new CompositeSynchImageDescriptor(icon, background);
			image = imageDescriptor.createImage(true);
			getImageRegistry().put(key, image);
		}
		return image;
	}

	private static ImageRegistry getImageRegistry() {
		if (imageRegistry == null) {
			imageRegistry = new ImageRegistry();
		}

		return imageRegistry;
	}

	private static URL makeIconFileURL(String prefix, String name) throws MalformedURLException {
		if (baseURL == null)
			throw new MalformedURLException();

		StringBuffer buffer = new StringBuffer(prefix);
		buffer.append('/');
		buffer.append(name);
		return new URL(baseURL, buffer.toString());
	}

	private static Image[] progressImages;

	public static Image[] getProgressImages() {

		if (progressImages != null)
			return progressImages;

		progressImages = new Image[8];

		for (int i = 1; i <= 8; i++) {
			ImageDescriptor imageDescriptor = create(T_EVIEW + "/progress", i + ".png");
			progressImages[i - 1] = getImage(imageDescriptor);
		}

		return progressImages;

	}

	public static Image getImageForPriority(PriorityLevel priorityLevel) {
		if (priorityLevel == null) {
			return null;
		} else {
			ImageDescriptor imageDescriptor = getImageDescriptorForPriority(priorityLevel);
			if (imageDescriptor != null) {
				return TasksUiImages.getImage(imageDescriptor);
			}
		}
		return null;
	}

	public static ImageDescriptor getImageDescriptorForPriority(PriorityLevel priorityLevel) {
		if (priorityLevel == null) {
			return null;
		}
		switch (priorityLevel) {
		case P1:
			return TasksUiImages.PRIORITY_1;
		case P2:
			return TasksUiImages.PRIORITY_2;
		case P3:
			return TasksUiImages.PRIORITY_3;
		case P4:
			return TasksUiImages.PRIORITY_4;
		case P5:
			return TasksUiImages.PRIORITY_5;
		default:
			return null;
		}
	}

}

Back to the top