blob: 8b9f1ff0c4bd72ad41796620db36c09e1591ce5d (
plain) (
blame)
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
|
package NET.worlds.scape;
import NET.worlds.console.Console;
import NET.worlds.console.OkCancelDialog;
import java.awt.GridBagConstraints;
import java.awt.List;
public abstract class ListChooserDialog extends OkCancelDialog {
private List _listField = new List(5, false);
protected EditTile _parent;
protected ListChooserDialog(EditTile parent, String title) {
super(Console.getFrame(), parent, title);
this._parent = parent;
}
@Override
protected void build() {
GridBagConstraints c = new GridBagConstraints();
c.weightx = 1.0;
c.weighty = 1.0;
c.gridwidth = 0;
c.fill = 1;
this.add(this.gbag, this._listField, c);
super.build();
}
protected abstract String getEntry(int var1);
protected abstract int getSelected();
protected abstract boolean setValue(String var1, int var2);
@Override
protected boolean setValue() {
return this.setValue(this._listField.getSelectedItem(), this._listField.getSelectedIndex());
}
@Override
public void show() {
super.show();
int index = 0;
for (String entry = this.getEntry(index); entry != null; entry = this.getEntry(++index)) {
this._listField.addItem(entry, index);
}
index = this.getSelected();
if (index != -1) {
this._listField.select(index);
}
this._listField.requestFocus();
}
}
|