KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > clif > scenario > util > isac > gui > Icons


1 /*
2  * CLIF is a Load Injection Framework
3  * Copyright (C) 2004 France Telecom R&D
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  *
19  * CLIF
20  *
21  * Contact: clif@objectweb.org
22  */

23 package org.objectweb.clif.scenario.util.isac.gui;
24 /**
25  * Implementation of a image registry, which load the icons files
26  *
27  * @author JC Meillaud
28  * @author A Peyrard
29  */

30 import java.net.MalformedURLException JavaDoc;
31 import java.net.URL JavaDoc;
32 import java.util.Hashtable JavaDoc;
33
34 import org.eclipse.jface.resource.ImageDescriptor;
35 import org.eclipse.jface.resource.ImageRegistry;
36 import org.objectweb.clif.scenario.util.isac.FileName;
37 import org.objectweb.clif.scenario.util.isac.util.tree.Node;
38
39 public class Icons {
40     private static ImageRegistry imageRegistry;
41     private static Hashtable JavaDoc imageDescriptorFileName;
42
43     /**
44      * Create a new URL with the given string in parameters
45      *
46      * @param url
47      * The string which contains the URL
48      * @return The URL created
49      */

50     public static URL JavaDoc newURL(String JavaDoc url) {
51         try {
52             return new URL JavaDoc("file:" + url);
53         } catch (MalformedURLException JavaDoc e) {
54             throw new RuntimeException JavaDoc("Malformed URL " + url, e);
55         }
56     }
57
58     public static Hashtable JavaDoc getImageDescriptorFileName() {
59         if (imageDescriptorFileName == null) {
60             imageDescriptorFileName = new Hashtable JavaDoc();
61             // ICONS FOR THE BEHAVIORS TREE
62
imageDescriptorFileName.put(Node.BEHAVIOR, FileName.BEHAVIOR_ICON);
63             imageDescriptorFileName.put(Node.PLUGINS, FileName.PLUGINS_ICON);
64             imageDescriptorFileName.put(Node.USE, FileName.USE_ICON);
65             imageDescriptorFileName.put(Node.SAMPLE, FileName.SAMPLE_ICON);
66             imageDescriptorFileName.put(Node.TIMER, FileName.TIMER_ICON);
67             imageDescriptorFileName.put(Node.IF, FileName.IF_ICON);
68             imageDescriptorFileName.put(Node.NCHOICE, FileName.NCHOICE_ICON);
69         }
70         return imageDescriptorFileName;
71     }
72
73     public static ImageRegistry getImageRegistry() {
74         if (imageRegistry == null) {
75             imageRegistry = new ImageRegistry();
76             // put all the icons file
77
imageRegistry.put(FileName.EXIT_ICON, ImageDescriptor
78                     .createFromURL(newURL(FileName.EXIT_ICON)));
79             imageRegistry.put(FileName.ABOUT_ICON, ImageDescriptor
80                     .createFromURL(newURL(FileName.ABOUT_ICON)));
81             imageRegistry.put(FileName.NEW_ICON, ImageDescriptor
82                     .createFromURL(newURL(FileName.NEW_ICON)));
83             imageRegistry.put(FileName.OPEN_ICON, ImageDescriptor
84                     .createFromURL(newURL(FileName.OPEN_ICON)));
85             imageRegistry.put(FileName.SAVE_ICON, ImageDescriptor
86                     .createFromURL(newURL(FileName.SAVE_ICON)));
87             imageRegistry.put(FileName.SAVE_AS_ICON, ImageDescriptor
88                     .createFromURL(newURL(FileName.SAVE_AS_ICON)));
89             imageRegistry.put(FileName.HELP_SHOW_ICON, ImageDescriptor
90                     .createFromURL(newURL(FileName.HELP_SHOW_ICON)));
91             imageRegistry.put(FileName.HELP_HIDE_ICON, ImageDescriptor
92                     .createFromURL(newURL(FileName.HELP_HIDE_ICON)));
93             imageRegistry.put(FileName.UP_ARROW_ICON, ImageDescriptor
94                     .createFromURL(newURL(FileName.UP_ARROW_ICON)));
95             imageRegistry.put(FileName.DOWN_ARROW_ICON, ImageDescriptor
96                     .createFromURL(newURL(FileName.DOWN_ARROW_ICON)));
97             imageRegistry.put(FileName.DELETE_ICON, ImageDescriptor
98                     .createFromURL(newURL(FileName.DELETE_ICON)));
99             imageRegistry.put(FileName.COPY_ICON, ImageDescriptor
100                     .createFromURL(newURL(FileName.COPY_ICON)));
101             imageRegistry.put(FileName.CUT_ICON, ImageDescriptor
102                     .createFromURL(newURL(FileName.CUT_ICON)));
103             imageRegistry.put(FileName.PASTE_ICON, ImageDescriptor
104                     .createFromURL(newURL(FileName.PASTE_ICON)));
105             imageRegistry.put(FileName.ADD_ICON, ImageDescriptor
106                     .createFromURL(newURL(FileName.ADD_ICON)));
107             imageRegistry.put(FileName.EXPAND_ICON, ImageDescriptor
108                     .createFromURL(newURL(FileName.EXPAND_ICON)));
109             imageRegistry.put(FileName.COLLAPSE_ICON, ImageDescriptor
110                     .createFromURL(newURL(FileName.COLLAPSE_ICON)));
111             imageRegistry.put(FileName.GENERATE_ICON, ImageDescriptor
112                     .createFromURL(newURL(FileName.GENERATE_ICON)));
113             // ICONS FOR THE LOAD PROFILE VIEW
114
imageRegistry.put(FileName.ADDPOINT_ICON, ImageDescriptor
115                     .createFromURL(newURL(FileName.ADDPOINT_ICON)));
116             imageRegistry.put(FileName.DELPOINT_ICON, ImageDescriptor
117                     .createFromURL(newURL(FileName.DELPOINT_ICON)));
118             imageRegistry.put(FileName.MAXIMIZEVIEW_ICON, ImageDescriptor
119                     .createFromURL(newURL(FileName.MAXIMIZEVIEW_ICON)));
120             imageRegistry.put(FileName.NORMALVIEW_ICON, ImageDescriptor
121                     .createFromURL(newURL(FileName.NORMALVIEW_ICON)));
122             imageRegistry.put(FileName.DRAW_NOTHING_ICON, ImageDescriptor.createFromURL(newURL(FileName.DRAW_NOTHING_ICON))) ;
123             // ICONS FOR THE BEHAVIORS TREE
124
imageRegistry.put(Node.BEHAVIOR, ImageDescriptor
125                     .createFromURL(newURL(FileName.BEHAVIOR_ICON)));
126             imageRegistry.put(Node.PLUGINS, ImageDescriptor
127                     .createFromURL(newURL(FileName.PLUGINS_ICON)));
128             imageRegistry.put(Node.USE, ImageDescriptor
129                     .createFromURL(newURL(FileName.USE_ICON)));
130             imageRegistry.put(Node.SAMPLE, ImageDescriptor
131                     .createFromURL(newURL(FileName.SAMPLE_ICON)));
132             imageRegistry.put(Node.TIMER, ImageDescriptor
133                     .createFromURL(newURL(FileName.TIMER_ICON)));
134             imageRegistry.put(Node.IF, ImageDescriptor
135                     .createFromURL(newURL(FileName.IF_ICON)));
136             imageRegistry.put(Node.NCHOICE, ImageDescriptor
137                     .createFromURL(newURL(FileName.NCHOICE_ICON)));
138             
139         }
140         return imageRegistry;
141     }
142
143 }
Popular Tags