|
1 /******************************************************************************* |
|
2 * Copyright (c) 2004, 2009 Tasktop Technologies and others. |
|
3 * All rights reserved. This program and the accompanying materials |
|
4 * are made available under the terms of the Eclipse Public License v1.0 |
|
5 * which accompanies this distribution, and is available at |
|
6 * http://www.eclipse.org/legal/epl-v10.html |
|
7 * |
|
8 * Contributors: |
|
9 * Tasktop Technologies - initial API and implementation |
|
10 *******************************************************************************/ |
|
11 |
|
12 package com.nokia.carbide.remoteconnections.internal.ui.mylyn; |
|
13 |
|
14 import java.net.MalformedURLException; |
|
15 import java.net.URL; |
|
16 |
|
17 import org.eclipse.jface.resource.ImageDescriptor; |
|
18 import org.eclipse.jface.resource.ImageRegistry; |
|
19 import org.eclipse.swt.graphics.Image; |
|
20 |
|
21 import com.nokia.carbide.remoteconnections.RemoteConnectionsActivator; |
|
22 |
|
23 /** |
|
24 * @author Mik Kersten |
|
25 * @since 3.0 |
|
26 */ |
|
27 public class CommonImages { |
|
28 |
|
29 private static final URL baseURL = |
|
30 RemoteConnectionsActivator.getDefault().getBundle().getEntry("/icons/mylyn/"); //$NON-NLS-1$ |
|
31 |
|
32 private static ImageRegistry imageRegistry; |
|
33 |
|
34 private static final String T_ELCL = "elcl16"; //$NON-NLS-1$ |
|
35 |
|
36 private static final String T_EVIEW = "eview16"; //$NON-NLS-1$ |
|
37 |
|
38 private static final String T_TOOL = "etool16"; //$NON-NLS-1$ |
|
39 |
|
40 private static final String T_OBJ = "obj16"; //$NON-NLS-1$ |
|
41 |
|
42 private static final String T_OBJ_32 = "obj32"; //$NON-NLS-1$ |
|
43 |
|
44 private static final String T_WIZBAN = "wizban"; //$NON-NLS-1$ |
|
45 |
|
46 private static final String T_OVR = "ovr16"; //$NON-NLS-1$ |
|
47 |
|
48 // Priorities |
|
49 |
|
50 public static final ImageDescriptor PRIORITY_1 = create(T_OBJ, "priority-1.gif"); //$NON-NLS-1$ |
|
51 |
|
52 public static final ImageDescriptor PRIORITY_2 = create(T_OBJ, "priority-2.gif"); //$NON-NLS-1$ |
|
53 |
|
54 public static final ImageDescriptor PRIORITY_3 = create(T_OBJ, "priority-3.gif"); //$NON-NLS-1$ |
|
55 |
|
56 public static final ImageDescriptor PRIORITY_4 = create(T_OBJ, "priority-4.gif"); //$NON-NLS-1$ |
|
57 |
|
58 public static final ImageDescriptor PRIORITY_5 = create(T_OBJ, "priority-5.gif"); //$NON-NLS-1$ |
|
59 |
|
60 public static final ImageDescriptor PRIORITY_1_LARGE = create(T_OBJ_32, "priority-critical.png"); //$NON-NLS-1$ |
|
61 |
|
62 public static final ImageDescriptor PRIORITY_2_LARGE = create(T_OBJ_32, "priority-high.png"); //$NON-NLS-1$ |
|
63 |
|
64 public static final ImageDescriptor PRIORITY_3_LARGE = create(T_OBJ_32, "priority-normal.png"); //$NON-NLS-1$ |
|
65 |
|
66 public static final ImageDescriptor PRIORITY_4_LARGE = create(T_OBJ_32, "priority-low.png"); //$NON-NLS-1$ |
|
67 |
|
68 public static final ImageDescriptor PRIORITY_5_LARGE = create(T_OBJ_32, "priority-very-low.png"); //$NON-NLS-1$ |
|
69 |
|
70 // Calendars, people and notifications |
|
71 |
|
72 public static final ImageDescriptor CALENDAR = create(T_TOOL, "calendar.gif"); //$NON-NLS-1$ |
|
73 |
|
74 public static final ImageDescriptor CALENDAR_SMALL = create(T_OBJ, "calendar-small.gif"); //$NON-NLS-1$ |
|
75 |
|
76 public static final ImageDescriptor SCHEDULE = create(T_TOOL, "schedule.png"); //$NON-NLS-1$ |
|
77 |
|
78 public static final ImageDescriptor SCHEDULE_DAY = create(T_TOOL, "schedule-day.png"); //$NON-NLS-1$ |
|
79 |
|
80 public static final ImageDescriptor SCHEDULE_WEEK = create(T_TOOL, "schedule-week.png"); //$NON-NLS-1$ |
|
81 |
|
82 public static final ImageDescriptor PERSON = create(T_TOOL, "person.gif"); //$NON-NLS-1$ |
|
83 |
|
84 public static final ImageDescriptor PERSON_NARROW = create(T_TOOL, "person-narrow.gif"); //$NON-NLS-1$ |
|
85 |
|
86 public static final ImageDescriptor PERSON_ME = create(T_TOOL, "person-me.gif"); //$NON-NLS-1$ |
|
87 |
|
88 public static final ImageDescriptor PERSON_ME_SMALL = create(T_TOOL, "person-me-small.png"); //$NON-NLS-1$ |
|
89 |
|
90 public static final ImageDescriptor PERSON_ME_NARROW = create(T_TOOL, "person-me-narrow.gif"); //$NON-NLS-1$ |
|
91 |
|
92 public static final ImageDescriptor NOTIFICATION_CLOSE = create(T_EVIEW, "notification-close.gif"); //$NON-NLS-1$ |
|
93 |
|
94 public static final ImageDescriptor NOTIFICATION_CLOSE_HOVER = create(T_EVIEW, "notification-close-active.gif"); //$NON-NLS-1$ |
|
95 |
|
96 // Date and synchronization overlays |
|
97 |
|
98 public static final ImageDescriptor OVERLAY_DATE_DUE = create(T_EVIEW, "overlay-has-due.gif"); //$NON-NLS-1$ |
|
99 |
|
100 public static final ImageDescriptor OVERLAY_DATE_OVERDUE = create(T_EVIEW, "overlay-overdue.gif"); //$NON-NLS-1$ |
|
101 |
|
102 public static final ImageDescriptor OVERLAY_SYNC_IN_PROGRESS = create(T_EVIEW, "overlay-synchronizing.gif"); //$NON-NLS-1$ |
|
103 |
|
104 public static final ImageDescriptor OVERLAY_SYNC_INCOMMING = create(T_EVIEW, "overlay-incoming.gif"); //$NON-NLS-1$ |
|
105 |
|
106 public static final ImageDescriptor OVERLAY_SYNC_INCOMMING_NEW = create(T_EVIEW, "overlay-incoming-new.gif"); //$NON-NLS-1$ |
|
107 |
|
108 public static final ImageDescriptor OVERLAY_SYNC_OUTGOING = create(T_EVIEW, "overlay-outgoing.gif"); //$NON-NLS-1$ |
|
109 |
|
110 public static final ImageDescriptor OVERLAY_SYNC_OUTGOING_NEW = create(T_EVIEW, "overlay-outgoing-new.gif"); //$NON-NLS-1$ |
|
111 |
|
112 public static final ImageDescriptor OVERLAY_SYNC_CONFLICT = create(T_EVIEW, "overlay-conflict.gif"); //$NON-NLS-1$ |
|
113 |
|
114 public static final ImageDescriptor OVERLAY_SYNC_WARNING = create(T_OVR, "overlay-warning.gif"); //$NON-NLS-1$ |
|
115 |
|
116 public static final ImageDescriptor OVERLAY_SYNC_OLD_INCOMMING = create(T_EVIEW, "overlay-synch-incoming.gif"); //$NON-NLS-1$ |
|
117 |
|
118 public static final ImageDescriptor OVERLAY_SYNC_OLD_INCOMMING_NEW = create(T_EVIEW, |
|
119 "overlay-synch-incoming-new.gif"); //$NON-NLS-1$ |
|
120 |
|
121 public static final ImageDescriptor OVERLAY_SYNC_OLD_OUTGOING = create(T_EVIEW, "overlay-synch-outgoing.gif"); //$NON-NLS-1$ |
|
122 |
|
123 public static final ImageDescriptor OVERLAY_CLEAR = create(T_OVR, "overlay-blank.gif"); //$NON-NLS-1$ |
|
124 |
|
125 public static final ImageDescriptor OVERLAY_WHITE = create(T_OVR, "solid-white.gif"); //$NON-NLS-1$ |
|
126 |
|
127 // Wizard banners |
|
128 |
|
129 public static final ImageDescriptor BANNER_SCREENSHOT = create(T_WIZBAN, "banner-screenshot.png"); //$NON-NLS-1$ |
|
130 |
|
131 public static final ImageDescriptor BANNER_IMPORT = create(T_WIZBAN, "banner-import.gif"); //$NON-NLS-1$ |
|
132 |
|
133 public static final ImageDescriptor BANNER_EXPORT = create(T_WIZBAN, "banner-export.gif"); //$NON-NLS-1$ |
|
134 |
|
135 // Discovery |
|
136 |
|
137 public static final ImageDescriptor DISCOVERY = create(T_TOOL, "discovery.png"); //$NON-NLS-1$ |
|
138 |
|
139 public static final ImageDescriptor BANNER_DISOVERY = create(T_WIZBAN, "banner-discovery.png"); //$NON-NLS-1$ |
|
140 |
|
141 // Miscellaneous |
|
142 // TODO: some of the common images below come from the workbench |
|
143 |
|
144 public static final ImageDescriptor COMPLETE = create(T_OBJ, "complete.gif"); //$NON-NLS-1$ |
|
145 |
|
146 public static final ImageDescriptor REMOVE = create(T_ELCL, "remove.gif"); //$NON-NLS-1$ |
|
147 |
|
148 public static final ImageDescriptor DELETE = create(T_ELCL, "delete.gif"); //$NON-NLS-1$ |
|
149 |
|
150 public static final ImageDescriptor WARNING = create(T_ELCL, "warning.gif"); //$NON-NLS-1$ |
|
151 |
|
152 public static final ImageDescriptor FILTER_COMPLETE = create(T_ELCL, "filter-complete.gif"); //$NON-NLS-1$ |
|
153 |
|
154 public static final ImageDescriptor FILTER_ARCHIVE = create(T_ELCL, "filter-archive.gif"); //$NON-NLS-1$ |
|
155 |
|
156 public static final ImageDescriptor FILTER_PRIORITY = create(T_ELCL, "filter-priority.gif"); //$NON-NLS-1$ |
|
157 |
|
158 public static final ImageDescriptor COLOR_PALETTE = create(T_ELCL, "color-palette.gif"); //$NON-NLS-1$ |
|
159 |
|
160 public static final ImageDescriptor FILTER = create(T_TOOL, "view-filter.gif"); //$NON-NLS-1$ |
|
161 |
|
162 public static final ImageDescriptor FIND_CLEAR = create(T_TOOL, "find-clear.gif"); //$NON-NLS-1$ |
|
163 |
|
164 public static final ImageDescriptor FIND_CLEAR_DISABLED = create(T_TOOL, "find-clear-disabled.gif"); //$NON-NLS-1$ |
|
165 |
|
166 public static final ImageDescriptor BROWSER_SMALL = create(T_OBJ, "browser-small.gif"); //$NON-NLS-1$ |
|
167 |
|
168 public static final ImageDescriptor BROWSER_OPEN_TASK = create(T_TOOL, "open-browser.gif"); //$NON-NLS-1$ |
|
169 |
|
170 public static final ImageDescriptor TOOLBAR_ARROW_RIGHT = create(T_TOOL, "toolbar-arrow-right.gif"); //$NON-NLS-1$ |
|
171 |
|
172 public static final ImageDescriptor TOOLBAR_ARROW_DOWN = create(T_TOOL, "toolbar-arrow-down.gif"); //$NON-NLS-1$ |
|
173 |
|
174 public static final ImageDescriptor LINK_EDITOR = create(T_TOOL, "link-editor.gif"); //$NON-NLS-1$ |
|
175 |
|
176 public static final ImageDescriptor CLEAR = create(T_TOOL, "clear.gif"); //$NON-NLS-1$ |
|
177 |
|
178 public static final ImageDescriptor EDIT = create(T_TOOL, "edit.gif"); //$NON-NLS-1$ |
|
179 |
|
180 public static final ImageDescriptor EDIT_SMALL = create(T_TOOL, "edit-small.png"); //$NON-NLS-1$ |
|
181 |
|
182 public static final ImageDescriptor CUT = create(T_TOOL, "cut.gif"); //$NON-NLS-1$ |
|
183 |
|
184 public static final ImageDescriptor UNDO = create(T_TOOL, "undo_edit.gif"); //$NON-NLS-1$ |
|
185 |
|
186 public static final ImageDescriptor REDO = create(T_TOOL, "redo_edit.gif"); //$NON-NLS-1$ |
|
187 |
|
188 public static final ImageDescriptor STATUS_NORMAL = create(T_EVIEW, "status-normal.gif"); //$NON-NLS-1$ |
|
189 |
|
190 public static final ImageDescriptor STATUS_CONTEXT = create(T_EVIEW, "status-server-context.gif"); //$NON-NLS-1$ |
|
191 |
|
192 public static final ImageDescriptor PRESENTATION = create(T_TOOL, "presentation.gif"); //$NON-NLS-1$ |
|
193 |
|
194 public static final ImageDescriptor GROUPING = create(T_TOOL, "grouping.gif"); //$NON-NLS-1$ |
|
195 |
|
196 public static final ImageDescriptor COPY = create(T_TOOL, "copy.png"); //$NON-NLS-1$ |
|
197 |
|
198 public static final ImageDescriptor GO_UP = create(T_TOOL, "go-up.gif"); //$NON-NLS-1$ |
|
199 |
|
200 public static final ImageDescriptor GO_INTO = create(T_TOOL, "go-into.gif"); //$NON-NLS-1$ |
|
201 |
|
202 public static final ImageDescriptor REFRESH = create(T_ELCL, "refresh.gif"); //$NON-NLS-1$ |
|
203 |
|
204 public static final ImageDescriptor REFRESH_SMALL = create(T_ELCL, "refresh-small.gif"); //$NON-NLS-1$ |
|
205 |
|
206 public static final ImageDescriptor COLLAPSE_ALL = create(T_ELCL, "collapseall.png"); //$NON-NLS-1$ |
|
207 |
|
208 public static final ImageDescriptor COLLAPSE_ALL_SMALL = create(T_ELCL, "collapseall-small.png"); //$NON-NLS-1$ |
|
209 |
|
210 public static final ImageDescriptor EXPAND_ALL = create(T_ELCL, "expandall.gif"); //$NON-NLS-1$ |
|
211 |
|
212 public static final ImageDescriptor EXPAND_ALL_SMALL = create(T_ELCL, "expandall-small.png"); //$NON-NLS-1$ |
|
213 |
|
214 public static final ImageDescriptor BLANK = create(T_ELCL, "blank.gif"); //$NON-NLS-1$ |
|
215 |
|
216 public static final ImageDescriptor IMAGE_CAPTURE = create(T_TOOL, "capture-screen.png"); //$NON-NLS-1$ |
|
217 |
|
218 public static final ImageDescriptor IMAGE_FIT = create(T_TOOL, "capture-fit.png"); //$NON-NLS-1$ |
|
219 |
|
220 public static final ImageDescriptor IMAGE_FILE = create(T_OBJ, "file-image.gif"); //$NON-NLS-1$ |
|
221 |
|
222 public static final ImageDescriptor FILE_PLAIN = create(T_OBJ, "file-plain.png"); //$NON-NLS-1$ |
|
223 |
|
224 public static final ImageDescriptor FILE_PLAIN_SMALL = create(T_OBJ, "file-small.png"); //$NON-NLS-1$ |
|
225 |
|
226 public static final ImageDescriptor NOTES_SMALL = create(T_OBJ, "notes-small.png"); //$NON-NLS-1$ |
|
227 |
|
228 public static final ImageDescriptor QUESTION = create(T_OBJ, "question.gif"); //$NON-NLS-1$ |
|
229 |
|
230 public static final ImageDescriptor INFORMATION = create(T_OBJ, "message_info.gif"); //$NON-NLS-1$ |
|
231 |
|
232 public static final ImageDescriptor SEPARATOR_LIST = create(T_TOOL, "content-assist-separator.gif"); //$NON-NLS-1$ |
|
233 |
|
234 public static final ImageDescriptor PART_MAXIMIZE = create(T_TOOL, "maximize.png"); //$NON-NLS-1$ |
|
235 |
|
236 public static final ImageDescriptor PREVIEW_WEB = create(T_TOOL, "preview-web.png"); //$NON-NLS-1$ |
|
237 |
|
238 public static final ImageDescriptor WEB = create(T_TOOL, "web.png"); //$NON-NLS-1$ |
|
239 |
|
240 public static final ImageDescriptor FIND = create(T_TOOL, "find.gif"); //$NON-NLS-1$ |
|
241 |
|
242 public static final ImageDescriptor SAVE = create(T_TOOL, "save.gif"); //$NON-NLS-1$; |
|
243 |
|
244 private static ImageDescriptor create(String prefix, String name) { |
|
245 try { |
|
246 return ImageDescriptor.createFromURL(makeIconFileURL(prefix, name)); |
|
247 } catch (MalformedURLException e) { |
|
248 return ImageDescriptor.getMissingImageDescriptor(); |
|
249 } |
|
250 } |
|
251 |
|
252 /** |
|
253 * Lazily initializes image map. |
|
254 * |
|
255 * @param imageDescriptor |
|
256 * @return Image |
|
257 */ |
|
258 public static Image getImage(ImageDescriptor imageDescriptor) { |
|
259 ImageRegistry imageRegistry = getImageRegistry(); |
|
260 Image image = imageRegistry.get("" + imageDescriptor.hashCode()); //$NON-NLS-1$ |
|
261 if (image == null) { |
|
262 image = imageDescriptor.createImage(true); |
|
263 imageRegistry.put("" + imageDescriptor.hashCode(), image); //$NON-NLS-1$ |
|
264 } |
|
265 return image; |
|
266 } |
|
267 |
|
268 public static Image getImageWithOverlay(ImageDescriptor icon, ImageDescriptor overlay, boolean top, boolean left) { |
|
269 if (icon == null) { |
|
270 return null; |
|
271 } |
|
272 String key = "" + icon.hashCode(); //$NON-NLS-1$ |
|
273 if (overlay != null) { |
|
274 key += overlay.hashCode(); |
|
275 } |
|
276 key += new Boolean(top).hashCode(); |
|
277 key += new Boolean(left).hashCode(); |
|
278 |
|
279 Image image = getImageRegistry().get(key); |
|
280 |
|
281 if (image == null) { |
|
282 TaskListImageDescriptor imageDescriptor = new TaskListImageDescriptor(icon, overlay, top, left); |
|
283 image = imageDescriptor.createImage(true); |
|
284 getImageRegistry().put(key, image); |
|
285 } |
|
286 return image; |
|
287 } |
|
288 |
|
289 /** |
|
290 * Lazily initializes image map. |
|
291 * |
|
292 * @param icon |
|
293 * cannot be null |
|
294 * @param overlayKind |
|
295 * @param wide |
|
296 * @return Image |
|
297 */ |
|
298 public static Image getCompositeTaskImage(ImageDescriptor icon, ImageDescriptor overlayKind, boolean wide) { |
|
299 if (icon == null) { |
|
300 return null; |
|
301 } |
|
302 String key = "" + icon.hashCode(); //$NON-NLS-1$ |
|
303 if (overlayKind != null) { |
|
304 key += overlayKind.hashCode(); |
|
305 } |
|
306 if (wide) { |
|
307 key += ".wide"; //$NON-NLS-1$ |
|
308 } |
|
309 Image image = getImageRegistry().get(key); |
|
310 |
|
311 if (image == null) { |
|
312 CompositeElementImageDescriptor imageDescriptor = new CompositeElementImageDescriptor(icon, overlayKind, |
|
313 wide); |
|
314 image = imageDescriptor.createImage(true); |
|
315 getImageRegistry().put(key, image); |
|
316 } |
|
317 return image; |
|
318 } |
|
319 |
|
320 public static Image getCompositeContainerImage(ImageDescriptor icon, boolean wide) { |
|
321 if (icon == null) { |
|
322 return null; |
|
323 } |
|
324 String key = "" + icon.hashCode(); //$NON-NLS-1$ |
|
325 if (wide) { |
|
326 key += ".wide"; //$NON-NLS-1$ |
|
327 } |
|
328 Image image = getImageRegistry().get(key); |
|
329 if (image == null) { |
|
330 CompositeContainerImageDescriptor imageDescriptor = new CompositeContainerImageDescriptor(icon, |
|
331 OVERLAY_CLEAR, wide); |
|
332 image = imageDescriptor.createImage(true); |
|
333 getImageRegistry().put(key, image); |
|
334 } |
|
335 return image; |
|
336 } |
|
337 |
|
338 public static Image getCompositeSynchImage(ImageDescriptor icon, boolean background) { |
|
339 String key = "" + icon.hashCode(); //$NON-NLS-1$ |
|
340 if (background) { |
|
341 key += ".background"; //$NON-NLS-1$ |
|
342 } |
|
343 |
|
344 Image image = getImageRegistry().get(key); |
|
345 if (image == null) { |
|
346 CompositeSyncImageDescriptor imageDescriptor = new CompositeSyncImageDescriptor(icon, background); |
|
347 image = imageDescriptor.createImage(true); |
|
348 getImageRegistry().put(key, image); |
|
349 } |
|
350 return image; |
|
351 } |
|
352 |
|
353 private static ImageRegistry getImageRegistry() { |
|
354 if (imageRegistry == null) { |
|
355 imageRegistry = new ImageRegistry(); |
|
356 } |
|
357 |
|
358 return imageRegistry; |
|
359 } |
|
360 |
|
361 private static URL makeIconFileURL(String prefix, String name) throws MalformedURLException { |
|
362 if (baseURL == null) { |
|
363 throw new MalformedURLException(); |
|
364 } |
|
365 |
|
366 StringBuffer buffer = new StringBuffer(prefix); |
|
367 buffer.append('/'); |
|
368 buffer.append(name); |
|
369 return new URL(baseURL, buffer.toString()); |
|
370 } |
|
371 |
|
372 private static Image[] progressImages; |
|
373 |
|
374 public static Image[] getProgressImages() { |
|
375 |
|
376 if (progressImages != null) { |
|
377 return progressImages; |
|
378 } |
|
379 |
|
380 progressImages = new Image[8]; |
|
381 |
|
382 for (int i = 1; i <= 8; i++) { |
|
383 ImageDescriptor imageDescriptor = create(T_EVIEW + "/progress", i + ".png"); //$NON-NLS-1$ //$NON-NLS-2$ |
|
384 progressImages[i - 1] = getImage(imageDescriptor); |
|
385 } |
|
386 |
|
387 return progressImages; |
|
388 |
|
389 } |
|
390 } |