01: package com.quantum.flatfiles;
02:
03: import java.lang.reflect.Field;
04: import java.lang.reflect.Modifier;
05: import java.net.URL;
06:
07: import org.eclipse.ui.plugin.AbstractUIPlugin;
08:
09: import com.quantum.ImageStore;
10:
11: /**
12: * @author BC
13: */
14: class ImageStoreInitializer {
15:
16: static void initialize(AbstractUIPlugin plugin, URL url) {
17:
18: Class imageStoreKeysClass = ImageStoreKeys.class;
19:
20: Field[] fields = imageStoreKeysClass.getFields();
21: for (int i = 0, length = fields == null ? 0 : fields.length; i < length; i++) {
22: if (fields[i].getType() == String.class
23: && Modifier.isPublic(fields[i].getModifiers())
24: && Modifier.isStatic(fields[i].getModifiers())
25: && Modifier.isFinal(fields[i].getModifiers())) {
26: try {
27: ImageStore.addImage(plugin, plugin
28: .getImageRegistry(), url,
29: (String) fields[i].get(null));
30: } catch (IllegalArgumentException e) {
31: // ignore it
32: } catch (IllegalAccessException e) {
33: // ignore it
34: }
35: }
36: }
37: }
38: }
|