private ButtonGroup messageTypeGroup = null;
@Override
public Vote previewExpandedChange(Rollup rollup) {
if (component == null) {
WTKXSerializer wtkxSerializer = new WTKXSerializer();
try {
component = (Component)wtkxSerializer.readObject(this, "alerts.wtkx");
} catch(IOException exception) {
throw new RuntimeException(exception);
} catch(SerializationException exception) {
throw new RuntimeException(exception);
}
alertButton = (PushButton)wtkxSerializer.get("alertButton");
promptButton = (PushButton)wtkxSerializer.get("promptButton");
messageTypeGroup = (ButtonGroup)wtkxSerializer.get("messageTypeGroup");
rollup.setContent(component);
alertButton.getButtonPressListeners().add(new ButtonPressListener() {
@Override
public void buttonPressed(Button button) {
Button selection = messageTypeGroup.getSelection();
Map<String, ?> userData;
try {
userData = JSONSerializer.parseMap((String)selection.getUserData().get("messageInfo"));
} catch (SerializationException exception) {
throw new RuntimeException(exception);
}
String messageType = (String)userData.get("messageType");
if (messageType == null) {
ArrayList<String> options = new ArrayList<String>();
options.add("OK");
options.add("Cancel");
Component body = null;
WTKXSerializer wtkxSerializer = new WTKXSerializer();
try {
body = (Component)wtkxSerializer.readObject(this, "alert.wtkx");
} catch(Exception exception) {
System.err.println(exception);
}
Alert alert = new Alert(MessageType.QUESTION, "Please select your favorite icon:",
options, body);
alert.setTitle("Select Icon");
alert.setSelectedOption(0);
alert.getDecorators().update(0, new ReflectionDecorator());
alert.open(window);
} else {
String message = (String)userData.get("message");
Alert.alert(MessageType.valueOf(messageType.toUpperCase()), message, window);
}
}
});
promptButton.getButtonPressListeners().add(new ButtonPressListener() {
@Override
public void buttonPressed(Button button) {
Button selection = messageTypeGroup.getSelection();
Map<String, ?> userData;
try {
userData = JSONSerializer.parseMap((String)selection.getUserData().get("messageInfo"));
} catch (SerializationException exception) {
throw new RuntimeException(exception);
}
String messageType = (String)userData.get("messageType");
if (messageType == null) {
ArrayList<String> options = new ArrayList<String>();
options.add("OK");
options.add("Cancel");
Component body = null;
WTKXSerializer wtkxSerializer = new WTKXSerializer();
try {
body = (Component)wtkxSerializer.readObject(this, "alert.wtkx");
} catch(Exception exception) {
System.err.println(exception);
}
Prompt prompt = new Prompt(MessageType.QUESTION, "Please select your favorite icon:",