Source Code Cross Referenced for WorkbenchImages.java in  » IDE-Eclipse » ui-workbench » org » eclipse » ui » internal » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » IDE Eclipse » ui workbench » org.eclipse.ui.internal 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*******************************************************************************
002:         * Copyright (c) 2000, 2007 IBM Corporation and others.
003:         * All rights reserved. This program and the accompanying materials
004:         * are made available under the terms of the Eclipse Public License v1.0
005:         * which accompanies this distribution, and is available at
006:         * http://www.eclipse.org/legal/epl-v10.html
007:         *
008:         * Contributors:
009:         *     IBM Corporation - initial API and implementation
010:         *******************************************************************************/package org.eclipse.ui.internal;
011:
012:        import java.net.URL;
013:        import java.util.HashMap;
014:        import java.util.Map;
015:
016:        import org.eclipse.core.runtime.Assert;
017:        import org.eclipse.jface.resource.ImageDescriptor;
018:        import org.eclipse.jface.resource.ImageRegistry;
019:        import org.eclipse.swt.SWT;
020:        import org.eclipse.swt.graphics.Color;
021:        import org.eclipse.swt.graphics.GC;
022:        import org.eclipse.swt.graphics.Image;
023:        import org.eclipse.swt.graphics.ImageData;
024:        import org.eclipse.swt.widgets.Display;
025:        import org.eclipse.ui.ISharedImages;
026:        import org.eclipse.ui.PlatformUI;
027:        import org.eclipse.ui.internal.misc.Policy;
028:        import org.eclipse.ui.internal.misc.ProgramImageDescriptor;
029:        import org.eclipse.ui.internal.util.BundleUtility;
030:
031:        /**
032:         * This class provides convenience access to many of the resources required
033:         * by the workbench. The class stores some images as descriptors, and
034:         * some are stored as real Images in the registry.  This is a pure
035:         * speed-space tradeoff.  The trick for users of this class is that
036:         * images obtained from the registry (using getImage()), don't require
037:         * disposal since they are shared, while images obtained using
038:         * getImageDescriptor() will require disposal.  Consult the declareImages
039:         * method to see if a given image is declared as a registry image or
040:         * just as a descriptor.  If you change an image from being stored
041:         * as a descriptor to a registry image, or vice-versa, make sure to
042:         * check all users of the image to ensure they are calling
043:         * the correct getImage... method and handling disposal correctly.
044:         *
045:         *  Images:
046:         *      - use getImage(key) to access cached images from the registry.
047:         *      - Less common images are found by calling getImageDescriptor(key)
048:         *          where key can be found in IWorkbenchGraphicConstants
049:         *
050:         *      This class initializes the image registry by declaring all of the required
051:         *      graphics. This involves creating image descriptors describing
052:         *      how to create/find the image should it be needed.
053:         *      The image is not actually allocated until requested.
054:         *
055:         *      Some Images are also made available to other plugins by being
056:         *      placed in the descriptor table of the SharedImages class.
057:         *
058:         *      Where are the images?
059:         *          The images (typically gifs) are found the plugins install directory
060:         *
061:         *      How to add a new image
062:         *          Place the gif file into the appropriate directories.
063:         *          Add a constant to IWorkbenchGraphicConstants following the conventions
064:         *          Add the declaration to this file
065:         */
066:        public/*final*/class WorkbenchImages {
067:
068:            private static Map descriptors;
069:
070:            private static ImageRegistry imageRegistry;
071:
072:            /* Declare Common paths */
073:
074:            public final static String ICONS_PATH = "$nl$/icons/full/";//$NON-NLS-1$
075:
076:            private final static String PATH_ETOOL = ICONS_PATH + "etool16/"; //Enabled toolbar icons.//$NON-NLS-1$
077:
078:            private final static String PATH_DTOOL = ICONS_PATH + "dtool16/"; //Disabled toolbar icons.//$NON-NLS-1$
079:
080:            private final static String PATH_ELOCALTOOL = ICONS_PATH
081:                    + "elcl16/"; //Enabled local toolbar icons.//$NON-NLS-1$
082:
083:            private final static String PATH_DLOCALTOOL = ICONS_PATH
084:                    + "dlcl16/"; //Disabled local toolbar icons.//$NON-NLS-1$
085:
086:            private final static String PATH_EVIEW = ICONS_PATH + "eview16/"; //View icons//$NON-NLS-1$
087:
088:            //private final static String PATH_PROD = ICONS_PATH+"prod/";	//Product images
089:            private final static String PATH_OBJECT = ICONS_PATH + "obj16/"; //Model object icons//$NON-NLS-1$
090:
091:            private final static String PATH_POINTER = ICONS_PATH + "pointer/"; //Pointer icons//$NON-NLS-1$
092:
093:            private final static String PATH_WIZBAN = ICONS_PATH + "wizban/"; //Wizard icons//$NON-NLS-1$
094:
095:            //private final static String PATH_STAT = ICONS_PATH+"stat/";
096:            //private final static String PATH_MISC = ICONS_PATH+"misc/";
097:            //private final static String PATH_OVERLAY = ICONS_PATH+"ovr16/";
098:
099:            /**
100:             * Declares a workbench image given the path of the image file (relative to
101:             * the workbench plug-in). This is a helper method that creates the image
102:             * descriptor and passes it to the main <code>declareImage</code> method.
103:             * 
104:             * @param key the symbolic name of the image
105:             * @param path the path of the image file relative to the base of the workbench
106:             * plug-ins install directory
107:             * @param shared <code>true</code> if this is a shared image, and
108:             * <code>false</code> if this is not a shared image
109:             */
110:            private final static void declareImage(String key, String path,
111:                    boolean shared) {
112:                URL url = BundleUtility.find(PlatformUI.PLUGIN_ID, path);
113:                ImageDescriptor desc = ImageDescriptor.createFromURL(url);
114:                declareImage(key, desc, shared);
115:            }
116:
117:            private static void drawViewMenu(GC gc, GC maskgc) {
118:                Display display = Display.getCurrent();
119:
120:                gc.setForeground(display
121:                        .getSystemColor(SWT.COLOR_WIDGET_DARK_SHADOW));
122:                gc.setBackground(display
123:                        .getSystemColor(SWT.COLOR_LIST_BACKGROUND));
124:
125:                int[] shapeArray = new int[] { 1, 1, 10, 1, 6, 5, 5, 5 };
126:                gc.fillPolygon(shapeArray);
127:                gc.drawPolygon(shapeArray);
128:
129:                Color black = display.getSystemColor(SWT.COLOR_BLACK);
130:                Color white = display.getSystemColor(SWT.COLOR_WHITE);
131:
132:                maskgc.setBackground(black);
133:                maskgc.fillRectangle(0, 0, 12, 16);
134:
135:                maskgc.setBackground(white);
136:                maskgc.setForeground(white);
137:                maskgc.fillPolygon(shapeArray);
138:                maskgc.drawPolygon(shapeArray);
139:            }
140:
141:            /**
142:             * Declares all the workbench's images, including both "shared" ones and
143:             * internal ones.
144:             */
145:            private final static void declareImages() {
146:
147:                declareImage(IWorkbenchGraphicConstants.IMG_ETOOL_PIN_EDITOR,
148:                        PATH_ETOOL + "pin_editor.gif", false); //$NON-NLS-1$
149:                declareImage(
150:                        IWorkbenchGraphicConstants.IMG_ETOOL_PIN_EDITOR_DISABLED,
151:                        PATH_DTOOL + "pin_editor.gif", false); //$NON-NLS-1$
152:
153:                // other toolbar buttons
154:
155:                declareImage(IWorkbenchGraphicConstants.IMG_ETOOL_SAVE_EDIT,
156:                        PATH_ETOOL + "save_edit.gif", false); //$NON-NLS-1$
157:                declareImage(
158:                        IWorkbenchGraphicConstants.IMG_ETOOL_SAVE_EDIT_DISABLED,
159:                        PATH_DTOOL + "save_edit.gif", false); //$NON-NLS-1$
160:
161:                declareImage(IWorkbenchGraphicConstants.IMG_ETOOL_SAVEAS_EDIT,
162:                        PATH_ETOOL + "saveas_edit.gif", false); //$NON-NLS-1$
163:                declareImage(
164:                        IWorkbenchGraphicConstants.IMG_ETOOL_SAVEAS_EDIT_DISABLED,
165:                        PATH_DTOOL + "saveas_edit.gif", false); //$NON-NLS-1$
166:
167:                declareImage(IWorkbenchGraphicConstants.IMG_ETOOL_SAVEALL_EDIT,
168:                        PATH_ETOOL + "saveall_edit.gif", false); //$NON-NLS-1$
169:                declareImage(
170:                        IWorkbenchGraphicConstants.IMG_ETOOL_SAVEALL_EDIT_DISABLED,
171:                        PATH_DTOOL + "saveall_edit.gif", false); //$NON-NLS-1$
172:
173:                declareImage(ISharedImages.IMG_TOOL_UNDO, PATH_ETOOL
174:                        + "undo_edit.gif", true); //$NON-NLS-1$
175:                declareImage(ISharedImages.IMG_TOOL_UNDO_HOVER, PATH_ETOOL
176:                        + "undo_edit.gif", true); //$NON-NLS-1$
177:                declareImage(ISharedImages.IMG_TOOL_UNDO_DISABLED, PATH_DTOOL
178:                        + "undo_edit.gif", true); //$NON-NLS-1$
179:
180:                declareImage(ISharedImages.IMG_TOOL_REDO, PATH_ETOOL
181:                        + "redo_edit.gif", true); //$NON-NLS-1$
182:                declareImage(ISharedImages.IMG_TOOL_REDO_HOVER, PATH_ETOOL
183:                        + "redo_edit.gif", true); //$NON-NLS-1$
184:                declareImage(ISharedImages.IMG_TOOL_REDO_DISABLED, PATH_DTOOL
185:                        + "redo_edit.gif", true); //$NON-NLS-1$
186:
187:                declareImage(ISharedImages.IMG_TOOL_CUT, PATH_ETOOL
188:                        + "cut_edit.gif", true); //$NON-NLS-1$
189:                declareImage(ISharedImages.IMG_TOOL_CUT_HOVER, PATH_ETOOL
190:                        + "cut_edit.gif", true); //$NON-NLS-1$
191:                declareImage(ISharedImages.IMG_TOOL_CUT_DISABLED, PATH_DTOOL
192:                        + "cut_edit.gif", true); //$NON-NLS-1$
193:
194:                declareImage(ISharedImages.IMG_TOOL_COPY, PATH_ETOOL
195:                        + "copy_edit.gif", true); //$NON-NLS-1$
196:                declareImage(ISharedImages.IMG_TOOL_COPY_HOVER, PATH_ETOOL
197:                        + "copy_edit.gif", true); //$NON-NLS-1$
198:                declareImage(ISharedImages.IMG_TOOL_COPY_DISABLED, PATH_DTOOL
199:                        + "copy_edit.gif", true); //$NON-NLS-1$
200:
201:                declareImage(ISharedImages.IMG_TOOL_PASTE, PATH_ETOOL
202:                        + "paste_edit.gif", true); //$NON-NLS-1$
203:                declareImage(ISharedImages.IMG_TOOL_PASTE_HOVER, PATH_ETOOL
204:                        + "paste_edit.gif", true); //$NON-NLS-1$
205:                declareImage(ISharedImages.IMG_TOOL_PASTE_DISABLED, PATH_DTOOL
206:                        + "paste_edit.gif", true); //$NON-NLS-1$
207:
208:                declareImage(ISharedImages.IMG_TOOL_DELETE, PATH_ETOOL
209:                        + "delete_edit.gif", true); //$NON-NLS-1$
210:                declareImage(ISharedImages.IMG_TOOL_DELETE_HOVER, PATH_ETOOL
211:                        + "delete_edit.gif", true); //$NON-NLS-1$
212:                declareImage(ISharedImages.IMG_TOOL_DELETE_DISABLED, PATH_DTOOL
213:                        + "delete_edit.gif", true); //$NON-NLS-1$
214:                declareImage(ISharedImages.IMG_TOOL_NEW_WIZARD, PATH_ETOOL
215:                        + "new_wiz.gif", true); //$NON-NLS-1$
216:                declareImage(ISharedImages.IMG_TOOL_NEW_WIZARD_HOVER,
217:                        PATH_ETOOL + "new_wiz.gif", true); //$NON-NLS-1$
218:                declareImage(ISharedImages.IMG_TOOL_NEW_WIZARD_DISABLED,
219:                        PATH_DTOOL + "new_wiz.gif", true); //$NON-NLS-1$
220:
221:                declareImage(IWorkbenchGraphicConstants.IMG_ETOOL_PRINT_EDIT,
222:                        PATH_ETOOL + "print_edit.gif", false); //$NON-NLS-1$
223:                declareImage(
224:                        IWorkbenchGraphicConstants.IMG_ETOOL_PRINT_EDIT_DISABLED,
225:                        PATH_DTOOL + "print_edit.gif", false); //$NON-NLS-1$
226:
227:                declareImage(
228:                        IWorkbenchGraphicConstants.IMG_ETOOL_HELP_CONTENTS,
229:                        PATH_ETOOL + "help_contents.gif", true); //$NON-NLS-1$
230:                declareImage(IWorkbenchGraphicConstants.IMG_ETOOL_HELP_SEARCH,
231:                        PATH_ETOOL + "help_search.gif", true); //$NON-NLS-1$
232:
233:                declareImage(IWorkbenchGraphicConstants.IMG_ETOOL_NEW_FASTVIEW,
234:                        PATH_ETOOL + "new_fastview.gif", true); //$NON-NLS-1$
235:                declareImage(IWorkbenchGraphicConstants.IMG_DTOOL_NEW_FASTVIEW,
236:                        PATH_DTOOL + "new_fastview.gif", true); //$NON-NLS-1$
237:
238:                declareImage(
239:                        IWorkbenchGraphicConstants.IMG_ETOOL_RESTORE_TRIMPART,
240:                        PATH_ETOOL + "fastview_restore.gif", true); //$NON-NLS-1$
241:                declareImage(
242:                        IWorkbenchGraphicConstants.IMG_ETOOL_EDITOR_TRIMPART,
243:                        PATH_ETOOL + "editor_area.gif", true); //$NON-NLS-1$
244:
245:                declareImage(ISharedImages.IMG_TOOL_FORWARD, PATH_ELOCALTOOL
246:                        + "forward_nav.gif", true); //$NON-NLS-1$
247:                declareImage(ISharedImages.IMG_TOOL_FORWARD_HOVER,
248:                        PATH_ELOCALTOOL + "forward_nav.gif", true); //$NON-NLS-1$
249:                declareImage(ISharedImages.IMG_TOOL_FORWARD_DISABLED,
250:                        PATH_DLOCALTOOL + "forward_nav.gif", true); //$NON-NLS-1$
251:
252:                declareImage(ISharedImages.IMG_TOOL_BACK, PATH_ELOCALTOOL
253:                        + "backward_nav.gif", true); //$NON-NLS-1$
254:                declareImage(ISharedImages.IMG_TOOL_BACK_HOVER, PATH_ELOCALTOOL
255:                        + "backward_nav.gif", true); //$NON-NLS-1$
256:                declareImage(ISharedImages.IMG_TOOL_BACK_DISABLED,
257:                        PATH_DLOCALTOOL + "backward_nav.gif", true); //$NON-NLS-1$
258:
259:                declareImage(ISharedImages.IMG_TOOL_UP, PATH_ELOCALTOOL
260:                        + "up_nav.gif", true); //$NON-NLS-1$
261:                declareImage(ISharedImages.IMG_TOOL_UP_HOVER, PATH_ELOCALTOOL
262:                        + "up_nav.gif", true); //$NON-NLS-1$
263:                declareImage(ISharedImages.IMG_TOOL_UP_DISABLED,
264:                        PATH_DLOCALTOOL + "up_nav.gif", true); //$NON-NLS-1$
265:
266:                declareImage(IWorkbenchGraphicConstants.IMG_ETOOL_NEW_PAGE,
267:                        PATH_EVIEW + "new_persp.gif", false); //$NON-NLS-1$
268:
269:                declareImage(IWorkbenchGraphicConstants.IMG_ETOOL_HOME_NAV,
270:                        PATH_ELOCALTOOL + "home_nav.gif", false); //$NON-NLS-1$
271:
272:                declareImage(
273:                        IWorkbenchGraphicConstants.IMG_ETOOL_DEF_PERSPECTIVE,
274:                        PATH_EVIEW + "default_persp.gif", false); //$NON-NLS-1$
275:
276:                declareImage(IWorkbenchGraphicConstants.IMG_WIZBAN_NEW_WIZ,
277:                        PATH_WIZBAN + "new_wiz.png", false); //$NON-NLS-1$
278:
279:                // testing PNG images cross platform, allows designers to pickup nightly builds
280:                //        declareImage(IWorkbenchGraphicConstants.IMG_WIZBAN_NEW_WIZ, PATH_WIZBAN
281:                //                + "new_wiz.png", false); //$NON-NLS-1$
282:
283:                declareImage(IWorkbenchGraphicConstants.IMG_ETOOL_IMPORT_WIZ,
284:                        PATH_ETOOL + "import_wiz.gif", false); //$NON-NLS-1$
285:                declareImage(IWorkbenchGraphicConstants.IMG_ETOOL_EXPORT_WIZ,
286:                        PATH_ETOOL + "export_wiz.gif", false); //$NON-NLS-1$
287:                declareImage(IWorkbenchGraphicConstants.IMG_WIZBAN_IMPORT_WIZ,
288:                        PATH_WIZBAN + "import_wiz.png", false); //$NON-NLS-1$
289:                declareImage(IWorkbenchGraphicConstants.IMG_WIZBAN_EXPORT_WIZ,
290:                        PATH_WIZBAN + "export_wiz.png", false); //$NON-NLS-1$
291:                declareImage(
292:                        IWorkbenchGraphicConstants.IMG_WIZBAN_IMPORT_PREF_WIZ,
293:                        PATH_WIZBAN + "importpref_wiz.png", false); //$NON-NLS-1$
294:                declareImage(
295:                        IWorkbenchGraphicConstants.IMG_WIZBAN_EXPORT_PREF_WIZ,
296:                        PATH_WIZBAN + "exportpref_wiz.png", false); //$NON-NLS-1$
297:
298:                declareImage(
299:                        IWorkbenchGraphicConstants.IMG_WIZBAN_WORKINGSET_WIZ,
300:                        PATH_WIZBAN + "workset_wiz.png", false); //$NON-NLS-1$
301:
302:                declareImage(
303:                        IWorkbenchGraphicConstants.IMG_VIEW_DEFAULTVIEW_MISC,
304:                        PATH_EVIEW + "defaultview_misc.gif", false); //$NON-NLS-1$
305:
306:                declareImage(IWorkbenchGraphicConstants.IMG_OBJ_FONT,
307:                        PATH_OBJECT + "font.gif", true); //$NON-NLS-1$
308:                declareImage(IWorkbenchGraphicConstants.IMG_OBJ_THEME_CATEGORY,
309:                        PATH_OBJECT + "theme_category.gif", true); //$NON-NLS-1$
310:                declareImage(IWorkbenchGraphicConstants.IMG_OBJ_ACTIVITY,
311:                        PATH_OBJECT + "activity.gif", true); //$NON-NLS-1$
312:                declareImage(
313:                        IWorkbenchGraphicConstants.IMG_OBJ_ACTIVITY_CATEGORY,
314:                        PATH_OBJECT + "activity_category.gif", true); //$NON-NLS-1$
315:                declareImage(IWorkbenchGraphicConstants.IMG_OBJ_WORKING_SETS,
316:                        PATH_OBJECT + "workingsets.gif", true); //$NON-NLS-1$
317:
318:                declareImage(IWorkbenchGraphicConstants.IMG_OBJ_SEPARATOR,
319:                        PATH_OBJECT + "separator.gif", true); //$NON-NLS-1$
320:
321:                declareImage(IWorkbenchGraphicConstants.IMG_OBJ_NODE,
322:                        PATH_OBJECT + "generic_elements.gif", true); //$NON-NLS-1$
323:                declareImage(IWorkbenchGraphicConstants.IMG_OBJ_ELEMENT,
324:                        PATH_OBJECT + "generic_element.gif", true); //$NON-NLS-1$
325:
326:                declareImage(ISharedImages.IMG_OBJ_FILE, PATH_OBJECT
327:                        + "file_obj.gif", true); //$NON-NLS-1$
328:                declareImage(ISharedImages.IMG_OBJ_FOLDER, PATH_OBJECT
329:                        + "fldr_obj.gif", true); //$NON-NLS-1$
330:                declareImage(ISharedImages.IMG_OBJ_ELEMENT, PATH_OBJECT
331:                        + "elements_obj.gif", true); //$NON-NLS-1$
332:                declareImage(ISharedImages.IMG_DEF_VIEW, PATH_EVIEW
333:                        + "defaultview_misc.gif", true); //$NON-NLS-1$
334:
335:                declareImage(IWorkbenchGraphicConstants.IMG_LCL_CLOSE_VIEW,
336:                        PATH_ELOCALTOOL + "close_view.gif", true); //$NON-NLS-1$
337:                declareImage(IWorkbenchGraphicConstants.IMG_LCL_PIN_VIEW,
338:                        PATH_ELOCALTOOL + "pin_view.gif", true); //$NON-NLS-1$
339:                declareImage(IWorkbenchGraphicConstants.IMG_LCL_MIN_VIEW,
340:                        PATH_ELOCALTOOL + "min_view.gif", true); //$NON-NLS-1$
341:                declareImage(IWorkbenchGraphicConstants.IMG_LCL_VIEW_MENU,
342:                        PATH_ELOCALTOOL + "view_menu.gif", true); //$NON-NLS-1$
343:                declareImage(IWorkbenchGraphicConstants.IMG_LCL_LINKTO_HELP,
344:                        PATH_ELOCALTOOL + "linkto_help.gif", true); //$NON-NLS-1$
345:
346:                declareImage(
347:                        IWorkbenchGraphicConstants.IMG_LCL_CLOSE_VIEW_THIN,
348:                        PATH_ELOCALTOOL + "thin_close_view.gif", true); //$NON-NLS-1$
349:                declareImage(
350:                        IWorkbenchGraphicConstants.IMG_LCL_HIDE_TOOLBAR_THIN,
351:                        PATH_ELOCALTOOL + "thin_hide_toolbar.gif", true); //$NON-NLS-1$
352:                declareImage(IWorkbenchGraphicConstants.IMG_LCL_MAX_VIEW_THIN,
353:                        PATH_ELOCALTOOL + "thin_max_view.gif", true); //$NON-NLS-1$
354:                declareImage(IWorkbenchGraphicConstants.IMG_LCL_MIN_VIEW_THIN,
355:                        PATH_ELOCALTOOL + "thin_min_view.gif", true); //$NON-NLS-1$
356:                declareImage(
357:                        IWorkbenchGraphicConstants.IMG_LCL_RESTORE_VIEW_THIN,
358:                        PATH_ELOCALTOOL + "thin_restore_view.gif", true); //$NON-NLS-1$
359:                declareImage(
360:                        IWorkbenchGraphicConstants.IMG_LCL_SHOW_TOOLBAR_THIN,
361:                        PATH_ELOCALTOOL + "thin_show_toolbar.gif", true); //$NON-NLS-1$
362:                declareImage(IWorkbenchGraphicConstants.IMG_LCL_VIEW_MENU_THIN,
363:                        PATH_ELOCALTOOL + "thin_view_menu.gif", true); //$NON-NLS-1$
364:
365:                declareImage(ISharedImages.IMG_OBJS_ERROR_TSK, PATH_OBJECT
366:                        + "error_tsk.gif", true); //$NON-NLS-1$
367:                declareImage(ISharedImages.IMG_OBJS_WARN_TSK, PATH_OBJECT
368:                        + "warn_tsk.gif", true); //$NON-NLS-1$
369:                declareImage(ISharedImages.IMG_OBJS_INFO_TSK, PATH_OBJECT
370:                        + "info_tsk.gif", true); //$NON-NLS-1$
371:
372:                declareImage(
373:                        IWorkbenchGraphicConstants.IMG_OBJS_DND_LEFT_SOURCE,
374:                        PATH_POINTER + "left_source.bmp", true); //$NON-NLS-1$
375:                declareImage(IWorkbenchGraphicConstants.IMG_OBJS_DND_LEFT_MASK,
376:                        PATH_POINTER + "left_mask.bmp", true); //$NON-NLS-1$
377:                declareImage(
378:                        IWorkbenchGraphicConstants.IMG_OBJS_DND_RIGHT_SOURCE,
379:                        PATH_POINTER + "right_source.bmp", true); //$NON-NLS-1$
380:                declareImage(
381:                        IWorkbenchGraphicConstants.IMG_OBJS_DND_RIGHT_MASK,
382:                        PATH_POINTER + "right_mask.bmp", true); //$NON-NLS-1$
383:                declareImage(
384:                        IWorkbenchGraphicConstants.IMG_OBJS_DND_TOP_SOURCE,
385:                        PATH_POINTER + "top_source.bmp", true); //$NON-NLS-1$
386:                declareImage(IWorkbenchGraphicConstants.IMG_OBJS_DND_TOP_MASK,
387:                        PATH_POINTER + "top_mask.bmp", true); //$NON-NLS-1$
388:                declareImage(
389:                        IWorkbenchGraphicConstants.IMG_OBJS_DND_BOTTOM_SOURCE,
390:                        PATH_POINTER + "bottom_source.bmp", true); //$NON-NLS-1$
391:                declareImage(
392:                        IWorkbenchGraphicConstants.IMG_OBJS_DND_BOTTOM_MASK,
393:                        PATH_POINTER + "bottom_mask.bmp", true); //$NON-NLS-1$
394:                declareImage(
395:                        IWorkbenchGraphicConstants.IMG_OBJS_DND_INVALID_SOURCE,
396:                        PATH_POINTER + "invalid_source.bmp", true); //$NON-NLS-1$
397:                declareImage(
398:                        IWorkbenchGraphicConstants.IMG_OBJS_DND_INVALID_MASK,
399:                        PATH_POINTER + "invalid_mask.bmp", true); //$NON-NLS-1$
400:                declareImage(
401:                        IWorkbenchGraphicConstants.IMG_OBJS_DND_STACK_SOURCE,
402:                        PATH_POINTER + "stack_source.bmp", true); //$NON-NLS-1$
403:                declareImage(
404:                        IWorkbenchGraphicConstants.IMG_OBJS_DND_STACK_MASK,
405:                        PATH_POINTER + "stack_mask.bmp", true); //$NON-NLS-1$
406:                declareImage(
407:                        IWorkbenchGraphicConstants.IMG_OBJS_DND_OFFSCREEN_SOURCE,
408:                        PATH_POINTER + "offscreen_source.bmp", true); //$NON-NLS-1$
409:                declareImage(
410:                        IWorkbenchGraphicConstants.IMG_OBJS_DND_OFFSCREEN_MASK,
411:                        PATH_POINTER + "offscreen_mask.bmp", true); //$NON-NLS-1$
412:                declareImage(
413:                        IWorkbenchGraphicConstants.IMG_OBJS_DND_TOFASTVIEW_SOURCE,
414:                        PATH_POINTER + "tofastview_source.bmp", true); //$NON-NLS-1$
415:                declareImage(
416:                        IWorkbenchGraphicConstants.IMG_OBJS_DND_TOFASTVIEW_MASK,
417:                        PATH_POINTER + "tofastview_mask.bmp", true); //$NON-NLS-1$
418:
419:                // signed jar images
420:                declareImage(IWorkbenchGraphicConstants.IMG_OBJ_SIGNED_YES,
421:                        PATH_OBJECT + "signed_yes_tbl.gif", true); //$NON-NLS-1$
422:                declareImage(IWorkbenchGraphicConstants.IMG_OBJ_SIGNED_NO,
423:                        PATH_OBJECT + "signed_no_tbl.gif", true); //$NON-NLS-1$
424:                declareImage(IWorkbenchGraphicConstants.IMG_OBJ_SIGNED_UNKNOWN,
425:                        PATH_OBJECT + "signed_unkn_tbl.gif", true); //$NON-NLS-1$
426:
427:                // Manually create the view menu
428:
429:                Display d = Display.getCurrent();
430:
431:                Image viewMenu = new Image(d, 11, 16);
432:                Image viewMenuMask = new Image(d, 11, 16);
433:
434:                GC gc = new GC(viewMenu);
435:                GC maskgc = new GC(viewMenuMask);
436:                drawViewMenu(gc, maskgc);
437:                gc.dispose();
438:                maskgc.dispose();
439:
440:                ImageData data = viewMenu.getImageData();
441:                data.transparentPixel = data.getPixel(0, 0);
442:
443:                Image vm2 = new Image(d, viewMenu.getImageData(), viewMenuMask
444:                        .getImageData());
445:                viewMenu.dispose();
446:                viewMenuMask.dispose();
447:
448:                getImageRegistry().put(
449:                        IWorkbenchGraphicConstants.IMG_LCL_RENDERED_VIEW_MENU,
450:                        vm2);
451:
452:            }
453:
454:            /**
455:             * Declares a workbench image.
456:             * <p>
457:             * The workbench remembers the given image descriptor under the given name,
458:             * and makes the image available to plug-ins via
459:             * {@link org.eclipse.ui.ISharedImages IWorkbench.getSharedImages()}.
460:             * For "shared" images, the workbench remembers the image descriptor and
461:             * will manages the image object create from it; clients retrieve "shared"
462:             * images via
463:             * {@link org.eclipse.ui.ISharedImages#getImage ISharedImages.getImage()}.
464:             * For the other, "non-shared" images, the workbench remembers only the
465:             * image descriptor; clients retrieve the image descriptor via
466:             * {@link org.eclipse.ui.ISharedImages#getImageDescriptor
467:             * ISharedImages.getImageDescriptor()} and are entirely
468:             * responsible for managing the image objects they create from it.
469:             * (This is made confusing by the historical fact that the API interface
470:             *  is called "ISharedImages".)
471:             * </p>
472:             * 
473:             * @param symbolicName the symbolic name of the image
474:             * @param descriptor the image descriptor
475:             * @param shared <code>true</code> if this is a shared image, and
476:             * <code>false</code> if this is not a shared image
477:             * @see org.eclipse.ui.ISharedImages#getImage
478:             * @see org.eclipse.ui.ISharedImages#getImageDescriptor
479:             */
480:            public static void declareImage(String symbolicName,
481:                    ImageDescriptor descriptor, boolean shared) {
482:                if (Policy.DEBUG_DECLARED_IMAGES) {
483:                    Image image = descriptor.createImage(false);
484:                    if (image == null) {
485:                        WorkbenchPlugin
486:                                .log(
487:                                        "Image not found in WorkbenchImages.declaredImage().  symbolicName=" + symbolicName + " descriptor=" + descriptor, new Exception("stack dump")); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
488:                    } else {
489:                        image.dispose();
490:                    }
491:                }
492:                getDescriptors().put(symbolicName, descriptor);
493:                if (shared) {
494:                    getImageRegistry().put(symbolicName, descriptor);
495:                }
496:            }
497:
498:            /**
499:             * Returns the map from symbolic name to ImageDescriptor.
500:             * 
501:             * @return the map from symbolic name to ImageDescriptor.
502:             */
503:            private static Map getDescriptors() {
504:                if (descriptors == null) {
505:                    initializeImageRegistry();
506:                }
507:                return descriptors;
508:            }
509:
510:            /**
511:             * Returns the image stored in the workbench plugin's image registry 
512:             * under the given symbolic name.  If there isn't any value associated 
513:             * with the name then <code>null</code> is returned.  
514:             *
515:             * The returned Image is managed by the workbench plugin's image registry.  
516:             * Callers of this method must not dispose the returned image.
517:             *
518:             * This method is essentially a convenient short form of
519:             * WorkbenchImages.getImageRegistry.get(symbolicName).
520:             */
521:            public static Image getImage(String symbolicName) {
522:                return getImageRegistry().get(symbolicName);
523:            }
524:
525:            /**
526:             * Returns the image descriptor stored under the given symbolic name.
527:             * If there isn't any value associated with the name then <code>null
528:             * </code> is returned.
529:             *
530:             * The class also "caches" commonly used images in the image registry.
531:             * If you are looking for one of these common images it is recommended you use 
532:             * the getImage() method instead.
533:             */
534:            public static ImageDescriptor getImageDescriptor(String symbolicName) {
535:                return (ImageDescriptor) getDescriptors().get(symbolicName);
536:            }
537:
538:            /**
539:             * Convenience Method.
540:             * Returns an ImageDescriptor obtained from an external program.
541:             * If there isn't any image then <code>null</code> is returned.
542:             *
543:             * This method is convenience and only intended for use by the workbench because it
544:             * explicitly uses the workbench's registry for caching/retrieving images from other
545:             * extensions -- other plugins must user their own registry. 
546:             * This convenience method is subject to removal.
547:             *
548:             * Note:
549:             * This consults the plugin for extension and obtains its installation location.
550:             * all requested images are assumed to be in a directory below and relative to that
551:             * plugins installation directory.
552:             */
553:
554:            public static ImageDescriptor getImageDescriptorFromProgram(
555:                    String filename, int offset) {
556:                Assert.isNotNull(filename);
557:                String key = filename + "*" + offset; //use * as it is not a valid filename character//$NON-NLS-1$
558:                ImageDescriptor desc = getImageDescriptor(key);
559:                if (desc == null) {
560:                    desc = new ProgramImageDescriptor(filename, offset);
561:                    getDescriptors().put(key, desc);
562:                }
563:                return desc;
564:            }
565:
566:            /**
567:             * Returns the ImageRegistry.
568:             */
569:            public static ImageRegistry getImageRegistry() {
570:                if (imageRegistry == null) {
571:                    initializeImageRegistry();
572:                }
573:                return imageRegistry;
574:            }
575:
576:            /**
577:             *  Initialize the image registry by declaring all of the required
578:             *  graphics. This involves creating JFace image descriptors describing
579:             *  how to create/find the image should it be needed.
580:             *  The image is not actually allocated until requested.
581:             *
582:             *  Prefix conventions
583:             *      Wizard Banners          WIZBAN_
584:             *      Preference Banners      PREF_BAN_
585:             *      Property Page Banners   PROPBAN_
586:             *      Enable toolbar          ETOOL_
587:             *      Disable toolbar         DTOOL_
588:             *      Local enabled toolbar   ELCL_
589:             *      Local Disable toolbar   DLCL_
590:             *      Object large            OBJL_
591:             *      Object small            OBJS_
592:             *      View                    VIEW_
593:             *      Product images          PROD_
594:             *      Misc images             MISC_
595:             *
596:             *  Where are the images?
597:             *      The images (typically gifs) are found in the same location as this plugin class.
598:             *      This may mean the same package directory as the package holding this class.
599:             *      The images are declared using this.getClass() to ensure they are looked up via
600:             *      this plugin class.
601:             *  @see ImageRegistry
602:             */
603:            private static void initializeImageRegistry() {
604:                imageRegistry = new ImageRegistry();
605:                descriptors = new HashMap();
606:                declareImages();
607:            }
608:
609:            /**
610:             * Disposes and clears the workbench images.
611:             * Called when the workbench is shutting down.
612:             *
613:             * @since 3.1
614:             */
615:            public static void dispose() {
616:                if (imageRegistry != null) {
617:                    imageRegistry.dispose();
618:                    imageRegistry = null;
619:                    descriptors = null;
620:                }
621:            }
622:
623:            /**
624:             * Get the workbench image with the given path relative to
625:             * ICON_PATH.
626:             * @param relativePath
627:             * @return ImageDescriptor
628:             */
629:            public static ImageDescriptor getWorkbenchImageDescriptor(
630:                    String relativePath) {
631:                return ImageDescriptor.createFromURL(BundleUtility.find(
632:                        PlatformUI.PLUGIN_ID, ICONS_PATH + relativePath));
633:            }
634:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.