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
120
121
122
|
package NET.worlds.scape;
import NET.worlds.console.Console;
import NET.worlds.console.PolledDialog;
import NET.worlds.core.Sort;
import java.awt.Button;
import java.awt.Choice;
import java.awt.Font;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Label;
import java.awt.Panel;
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.Vector;
class EditRoomDialog extends PolledDialog {
private Choice roomChoice = new Choice();
private Choice musicChoice = new Choice();
private Button okButton = new Button(Console.message("OK"));
private Button cancelButton = new Button(Console.message("Cancel"));
private MusicManagerDialog parent;
private MusicRoom room;
private String startSelect;
private static String lastMusic;
private static Font font = new Font(Console.message("MenuFont"), 0, 12);
private static Font bfont = new Font(Console.message("ButtonFont"), 0, 12);
public EditRoomDialog(MusicManagerDialog parent, MusicRoom room, String startSelect) {
super(parent, parent, Console.message("Assign-Music"), true);
this.parent = parent;
this.room = room;
this.startSelect = startSelect;
this.ready();
}
@Override
protected void build() {
GridBagLayout gbag = new GridBagLayout();
this.setLayout(gbag);
GridBagConstraints c = new GridBagConstraints();
c.fill = 0;
c.anchor = 13;
Label lName = new Label(Console.message("Room-name"), 2);
lName.setFont(font);
this.add(gbag, lName, c);
c.gridwidth = 0;
c.anchor = 17;
this.roomChoice.setFont(font);
this.add(gbag, this.roomChoice, c);
c.gridwidth = 1;
c.anchor = 13;
Label lMusic = new Label(Console.message("Music"), 2);
lMusic.setFont(font);
this.add(gbag, lMusic, c);
c.gridwidth = 0;
c.anchor = 17;
this.musicChoice.setFont(font);
this.add(gbag, this.musicChoice, c);
c.anchor = 10;
Panel p = new Panel();
p.setFont(bfont);
p.add(this.okButton);
p.add(this.cancelButton);
this.add(gbag, p, c);
this.roomChoice.setFont(font);
this.musicChoice.setFont(font);
if (this.room != null) {
this.roomChoice.add(this.room.getRoomName());
}
Enumeration e = this.parent.getAllRooms().elements();
Hashtable roomsWithMusic = this.parent.getManager().getRooms();
Vector v = new Vector();
while (e.hasMoreElements()) {
String name = (String)e.nextElement();
if (!roomsWithMusic.containsKey(name)) {
v.addElement(name);
}
}
Sort.sortInto(this.roomChoice, v);
Sort.sortInto(this.musicChoice, this.parent.getManager().getMusic());
if (this.room != null) {
this.roomChoice.select(this.room.getRoomName());
this.musicChoice.select(this.room.getMusicName());
} else {
this.roomChoice.select(this.startSelect);
if (lastMusic != null) {
this.musicChoice.select(lastMusic);
}
}
}
@Override
public boolean action(java.awt.Event event, Object what) {
Object target = event.target;
if (target == this.okButton) {
return this.done(true);
} else {
return target == this.cancelButton ? this.done(false) : false;
}
}
public boolean isEditor() {
return this.room != null;
}
public MusicRoom getMusicRoom() {
String roomName = this.roomChoice.getSelectedItem();
String musicName = this.musicChoice.getSelectedItem();
lastMusic = musicName;
if (this.room == null) {
return new MusicRoom(roomName, musicName);
} else {
this.room.setRoomName(roomName);
this.room.setMusicName(musicName);
return this.room;
}
}
}
|