|
1
|
|
package abbot.editor;
|
|
2
|
|
|
|
3
|
|
import java.awt.Component;
|
|
4
|
|
import javax.swing.*;
|
|
5
|
|
import java.util.*;
|
|
6
|
|
import java.net.URL;
|
|
7
|
|
|
|
8
|
|
|
|
9
|
|
|
|
10
|
|
class ComponentTreeIcons {
|
|
11
|
|
private Map icons = new HashMap();
|
|
12
|
145
|
public Icon getIcon(Class cls) {
|
|
13
|
145
|
String className = cls.getName();
|
|
14
|
145
|
int lastdot = className.lastIndexOf(".");
|
|
15
|
145
|
String simpleName = lastdot != -1
|
|
16
|
|
? className.substring(lastdot+1).toLowerCase() : className;
|
|
17
|
145
|
Icon icon = (Icon)icons.get(className);
|
|
18
|
145
|
if (icon == null) {
|
|
19
|
29
|
URL url = getClass().getResource("icons/" + className + ".gif");
|
|
20
|
29
|
if (url == null) {
|
|
21
|
29
|
url = getClass().getResource("icons/" + simpleName + ".gif");
|
|
22
|
|
}
|
|
23
|
29
|
if (url == null) {
|
|
24
|
10
|
if (Component.class.equals(cls))
|
|
25
|
0
|
return null;
|
|
26
|
10
|
icon = getIcon(cls.getSuperclass());
|
|
27
|
|
}
|
|
28
|
|
else {
|
|
29
|
19
|
icon = new ImageIcon(url);
|
|
30
|
|
}
|
|
31
|
29
|
if (icon != null) {
|
|
32
|
29
|
icons.put(className, icon);
|
|
33
|
|
}
|
|
34
|
|
}
|
|
35
|
145
|
return icon;
|
|
36
|
|
}
|
|
37
|
|
}
|
|
38
|
|
|