@@ -59,7 +59,7 @@ public class LauncherPlugin extends AbstractUIPlugin {
59
59
LAUNCH_ITEMS_XML_ATTRIB_ENABLED = "enabled" ,
60
60
LAUNCH_ITEMS_XML_ATTRIB_CATEGORY = "category" ,
61
61
LAUNCH_ITEMS_XML_VALUE_TRUE = "true" ,
62
- LAUNCH_ITEMS_XML_VALUE_FALSE = "false" ;
62
+ LAUNCH_ITEMS_XML_VALUE_FALSE = "false" ;
63
63
64
64
static final int
65
65
liClosedFolder = 0 ,
@@ -84,7 +84,7 @@ public void start(BundleContext context) throws Exception {
84
84
super .start (context );
85
85
resourceBundle = Platform .getResourceBundle (getBundle ());
86
86
}
87
-
87
+
88
88
/**
89
89
* Clean up
90
90
*/
@@ -107,7 +107,7 @@ public static LauncherPlugin getDefault() {
107
107
public static void initResources () {
108
108
if (images == null ) {
109
109
images = new Image [imageLocations .length ];
110
-
110
+
111
111
for (int i = 0 ; i < imageLocations .length ; ++i ) {
112
112
images [i ] = getImageFromPlugin (plugin .getBundle (), imageLocations [i ]);
113
113
if (images [i ] == null ) {
@@ -116,7 +116,7 @@ public static void initResources() {
116
116
throw new IllegalStateException ();
117
117
}
118
118
}
119
- }
119
+ }
120
120
}
121
121
122
122
/**
@@ -133,7 +133,7 @@ public static void freeResources() {
133
133
134
134
/**
135
135
* Log an error to the ILog for this plugin
136
- *
136
+ *
137
137
* @param message the localized error message text
138
138
* @param exception the associated exception, or null
139
139
*/
@@ -154,7 +154,7 @@ public static String getResourceString(String key) {
154
154
return key ;
155
155
} catch (NullPointerException e ) {
156
156
return "!" + key + "!" ;
157
- }
157
+ }
158
158
}
159
159
160
160
/**
@@ -174,7 +174,7 @@ public static String getResourceString(String key, Object[] args) {
174
174
175
175
/**
176
176
* Constructs a list of available programs from registered extensions.
177
- *
177
+ *
178
178
* @return an ItemTreeNode representing the root of a tree of items (the root is not to be displayed)
179
179
*/
180
180
public static ItemTreeNode getLaunchItemTree () {
@@ -186,41 +186,41 @@ public static ItemTreeNode getLaunchItemTree() {
186
186
// retrieve all configuration elements registered at our launchItems extension-point
187
187
IConfigurationElement [] configurationElements =
188
188
extensionRegistry .getConfigurationElementsFor (LAUNCH_ITEMS_POINT_ID );
189
-
189
+
190
190
if (configurationElements == null || configurationElements .length == 0 ) {
191
191
logError (getResourceString ("error.CouldNotFindRegisteredExtensions" ), null );
192
192
return categoryTree ;
193
193
}
194
-
194
+
195
195
/* Collect all launch categories -- coalesce those with same ID */
196
196
HashMap <String , ItemTreeNode > idMap = new HashMap <>();
197
197
for (IConfigurationElement ce : configurationElements ) {
198
198
final String ceName = ce .getName ();
199
199
final String attribId = getItemAttribute (ce , LAUNCH_ITEMS_XML_ATTRIB_ID , null );
200
-
200
+
201
201
if (idMap .containsKey (attribId )) continue ;
202
202
if (ceName .equalsIgnoreCase (LAUNCH_ITEMS_XML_CATEGORY )) {
203
- final String attribName = getItemName (ce );
203
+ final String attribName = getItemName (ce );
204
204
ItemDescriptor theDescriptor = new ItemDescriptor (attribId , attribName ,
205
205
getItemDescription (ce ), null , null , null , null , ce );
206
206
idMap .put (attribId , new ItemTreeNode (theDescriptor ));
207
207
}
208
208
}
209
-
209
+
210
210
/* Generate launch category hierarchy */
211
211
Set <String > tempIdSet = new HashSet <>(); // used to prevent duplicates from being entered into the tree
212
212
for (IConfigurationElement ce : configurationElements ) {
213
213
final String ceName = ce .getName ();
214
214
final String attribId = getItemAttribute (ce , LAUNCH_ITEMS_XML_ATTRIB_ID , null );
215
-
215
+
216
216
if (tempIdSet .contains (attribId )) continue ;
217
217
if (ceName .equalsIgnoreCase (LAUNCH_ITEMS_XML_CATEGORY )) {
218
218
final ItemTreeNode theNode = idMap .get (attribId );
219
219
addItemByCategory (ce , categoryTree , theNode , idMap );
220
220
tempIdSet .add (attribId );
221
221
}
222
222
}
223
-
223
+
224
224
/* Generate program tree */
225
225
for (IConfigurationElement ce : configurationElements ) {
226
226
final String ceName = ce .getName ();
@@ -230,11 +230,11 @@ public static ItemTreeNode getLaunchItemTree() {
230
230
if (ceName .equalsIgnoreCase (LAUNCH_ITEMS_XML_CATEGORY )) {
231
231
// ignore
232
232
} else if (ceName .equalsIgnoreCase (LAUNCH_ITEMS_XML_ITEM )) {
233
- final String enabled = getItemAttribute (ce , LAUNCH_ITEMS_XML_ATTRIB_ENABLED ,
233
+ final String enabled = getItemAttribute (ce , LAUNCH_ITEMS_XML_ATTRIB_ENABLED ,
234
234
LAUNCH_ITEMS_XML_VALUE_TRUE );
235
235
if (enabled .equalsIgnoreCase (LAUNCH_ITEMS_XML_VALUE_FALSE )) continue ;
236
- ItemDescriptor theDescriptor = createItemDescriptor (ce , attribId );
237
-
236
+ ItemDescriptor theDescriptor = createItemDescriptor (ce , attribId );
237
+
238
238
if (theDescriptor != null ) {
239
239
final ItemTreeNode theNode = new ItemTreeNode (theDescriptor );
240
240
addItemByCategory (ce , categoryTree , theNode , idMap );
@@ -245,28 +245,28 @@ public static ItemTreeNode getLaunchItemTree() {
245
245
return categoryTree ;
246
246
}
247
247
248
-
248
+
249
249
/**
250
250
* Adds an item to the category tree.
251
251
*/
252
252
private static void addItemByCategory (IConfigurationElement ce , ItemTreeNode root ,
253
253
ItemTreeNode theNode , HashMap <String , ItemTreeNode > idMap ) {
254
254
final String attribCategory = getItemAttribute (ce , LAUNCH_ITEMS_XML_ATTRIB_CATEGORY , null );
255
-
255
+
256
256
// locate the parent node
257
257
ItemTreeNode parentNode = null ;
258
258
if (attribCategory != null ) {
259
259
parentNode = idMap .get (attribCategory );
260
260
}
261
261
if (parentNode == null ) parentNode = root ;
262
-
262
+
263
263
// add the item
264
264
parentNode .addSortedNode (theNode );
265
265
}
266
266
267
267
/**
268
268
* Creates an ItemDescriptor from an XML definition.
269
- *
269
+ *
270
270
* @param ce the IConfigurationElement describing the item
271
271
* @param attribId the attribute id
272
272
* @return a new ItemDescriptor, or null if an error occurs
@@ -279,7 +279,7 @@ private static ItemDescriptor createItemDescriptor(IConfigurationElement ce, Str
279
279
IConfigurationElement viewCE = getItemElement (ce , LAUNCH_ITEMS_XML_VIEW );
280
280
if (viewCE != null ) {
281
281
//Item is a view
282
- final String attribView = getItemAttribute (viewCE , LAUNCH_ITEMS_XML_VIEW_VIEWID , null );
282
+ final String attribView = getItemAttribute (viewCE , LAUNCH_ITEMS_XML_VIEW_VIEWID , null );
283
283
if (attribView == null ) {
284
284
logError (getResourceString ("error.IncompleteViewLaunchItem" ,
285
285
new Object [] { attribId } ), null );
@@ -310,7 +310,7 @@ private static ItemDescriptor createItemDescriptor(IConfigurationElement ce, Str
310
310
311
311
/**
312
312
* Returns the first instance of a particular child XML element.
313
- *
313
+ *
314
314
* @param ce the IConfigurationElement parent
315
315
* @param element the name of the element to fetch
316
316
* @return the element's IConfigurationElement, or null if not found
@@ -322,7 +322,7 @@ private static IConfigurationElement getItemElement(IConfigurationElement ce, St
322
322
323
323
/**
324
324
* Returns the value of an XML attribute for an item.
325
- *
325
+ *
326
326
* @param ce the IConfigurationElement describing the item
327
327
* @param attribute the attribute to fetch
328
328
* @param defaultValue the value to return if the attribute is not found
@@ -335,7 +335,7 @@ private static String getItemAttribute(IConfigurationElement ce, String attribut
335
335
336
336
/**
337
337
* Returns the description string given the IConfigurationElement for an item.
338
- *
338
+ *
339
339
* @param ce the IConfigurationElement describing the item
340
340
* @return a newline-delimited string that describes this item, or null if none
341
341
*/
@@ -346,7 +346,7 @@ private static String getItemDescription(IConfigurationElement ce) {
346
346
347
347
/**
348
348
* Returns the name of an item.
349
- *
349
+ *
350
350
* @param ce the IConfigurationElement describing the item
351
351
* @return the attribute value
352
352
*/
@@ -358,7 +358,7 @@ private static String getItemName(IConfigurationElement ce) {
358
358
359
359
/**
360
360
* Returns the icon for an item.
361
- *
361
+ *
362
362
* @param ce the IConfigurationElement describing the item
363
363
* @return an icon
364
364
*/
@@ -392,7 +392,7 @@ private static Image getImageFromPlugin(Bundle bundle, String iconPath) {
392
392
URL installUrl = bundle .getEntry ("/" );
393
393
URL url = new URL (installUrl , iconPath );
394
394
is = url .openConnection ().getInputStream ();
395
- ImageData source = new ImageData (is );
395
+ ImageData source = ImageData . load (is );
396
396
ImageData mask = source .getTransparencyMask ();
397
397
Image image = new Image (null , source , mask );
398
398
return image ;
0 commit comments