Skip to content

Commit

Permalink
Made Alert more BXML-friendly (same changes as was made to Prompt)
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.apache.org/repos/asf/pivot/trunk@987627 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
Todd Volkert committed Aug 20, 2010
1 parent 2637fb6 commit 42bef23
Showing 1 changed file with 21 additions and 14 deletions.
35 changes: 21 additions & 14 deletions wtk/src/org/apache/pivot/wtk/Alert.java
Expand Up @@ -209,16 +209,7 @@ public Alert(MessageType messageType, String message, Sequence<?> options, Compo
setMessageType(messageType);
setMessage(message);
setBody(body);

if (options != null
&& options.getLength() > 0) {
for (int i = 0, n = options.getLength(); i < n; i++) {
optionSequence.add(options.get(i));
}

setSelectedOptionIndex(0);
}

setOptions(options);
setTitle((String)resources.get("defaultTitle"));

installThemeSkin(Alert.class);
Expand All @@ -240,6 +231,14 @@ public void setMessageType(MessageType messageType) {
}
}

public void setMessageType(String messageType) {
if (messageType == null) {
throw new IllegalArgumentException("messageType is null.");
}

setMessageType(MessageType.valueOf(messageType.toUpperCase()));
}

public String getMessage() {
return message;
}
Expand Down Expand Up @@ -268,13 +267,21 @@ public OptionSequence getOptions() {
return optionSequence;
}

public void setOptions(String options) {
public void setOptions(Sequence<?> options) {
optionSequence.remove(0, optionSequence.getLength());

try {
for (Object option : JSONSerializer.parseList(options)) {
optionSequence.add(option);
if (options != null) {
for (int i = 0, n = options.getLength(); i < n; i++) {
optionSequence.add(options.get(i));
}

setSelectedOptionIndex(0);
}
}

public void setOptions(String options) {
try {
setOptions(JSONSerializer.parseList(options));
} catch (SerializationException exception) {
throw new IllegalArgumentException(exception);
}
Expand Down

0 comments on commit 42bef23

Please sign in to comment.