You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pivot.apache.org by tv...@apache.org on 2010/08/20 22:25:13 UTC
svn commit: r987627 - /pivot/trunk/wtk/src/org/apache/pivot/wtk/Alert.java
Author: tvolkert
Date: Fri Aug 20 20:25:12 2010
New Revision: 987627
URL: http://svn.apache.org/viewvc?rev=987627&view=rev
Log:
Made Alert more BXML-friendly (same changes as was made to Prompt)
Modified:
pivot/trunk/wtk/src/org/apache/pivot/wtk/Alert.java
Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/Alert.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/Alert.java?rev=987627&r1=987626&r2=987627&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/Alert.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/Alert.java Fri Aug 20 20:25:12 2010
@@ -209,16 +209,7 @@ public class Alert extends Dialog {
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);
@@ -240,6 +231,14 @@ public class Alert extends Dialog {
}
}
+ public void setMessageType(String messageType) {
+ if (messageType == null) {
+ throw new IllegalArgumentException("messageType is null.");
+ }
+
+ setMessageType(MessageType.valueOf(messageType.toUpperCase()));
+ }
+
public String getMessage() {
return message;
}
@@ -268,13 +267,21 @@ public class Alert extends Dialog {
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);
}