1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
|
package NET.worlds.scape;
import NET.worlds.core.IniFile;
import java.awt.List;
import java.util.Enumeration;
import java.util.Vector;
public class PropList extends List {
private Object obj;
private Vector properties;
private static String[] sortOrder = new String[]{
"Name",
"Tilesize",
"Transform",
"From",
"To",
"Extent",
"Bumpable",
"Collision Extent",
"Visible",
"Optimizable",
"DrawFirstOnIntersection",
"DrawOrderUnimportant"
};
static {
int numUserPreferences = IniFile.gamma().getIniInt("PropertyOrderCount", -1);
if (numUserPreferences >= 0) {
sortOrder = new String[numUserPreferences];
for (int i = 0; i < numUserPreferences; i++) {
sortOrder[i] = IniFile.gamma().getIniString("PropertyOrder" + i, "");
}
}
}
public static void setPreferences(String[] prefs) {
sortOrder = prefs;
}
public Object getObject() {
return this.obj;
}
public void setObject(Object obj) {
int selected = this.getSelectedIndex();
if (obj != this.obj) {
selected = -1;
}
this.obj = obj;
int count = this.countItems();
if (count != 0) {
this.delItems(0, count - 1);
}
Vector unsorted = new Vector();
Enumeration e = new EnumProperties(obj);
for (int var11 = 0; e.hasMoreElements(); var11++) {
Property p = (Property)e.nextElement();
if (!(p instanceof VectorProperty) && (p.getEditor() != null || !(p.get() instanceof Properties))) {
unsorted.addElement(p);
}
}
this.properties = new Vector(unsorted.size());
for (int sortItem = 0; sortItem < sortOrder.length; sortItem++) {
String s = sortOrder[sortItem];
int size = unsorted.size();
for (int i = 0; i < size; i++) {
Property p = (Property)unsorted.elementAt(i);
if (p.getName().equals(s)) {
this.properties.addElement(p);
unsorted.removeElementAt(i);
break;
}
}
}
int size = unsorted.size();
for (int ix = 0; ix < size; ix++) {
this.properties.addElement(unsorted.elementAt(ix));
}
size = this.properties.size();
for (int ix = 0; ix < size; ix++) {
Property prop = (Property)this.properties.elementAt(ix);
this.addItem(prop.getName() + " (" + prop.getPropertyType() + ")" + " (" + prop.get() + ")");
}
count = this.countItems();
if (count != 0 && selected != -1) {
if (selected >= count) {
selected = count - 1;
}
this.select(selected);
}
}
public Property getSelectedProperty() {
int i = this.getSelectedIndex();
return i != -1 ? (Property)this.properties.elementAt(i) : null;
}
@Override
public void addItem(String s) {
if (s.length() > 128) {
s = s.substring(0, 125) + "...";
}
super.addItem(s);
}
}
|