You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pivot.apache.org by rw...@apache.org on 2017/05/01 19:08:59 UTC

svn commit: r1793399 - /pivot/trunk/wtk/src/org/apache/pivot/wtk/Alert.java

Author: rwhitcomb
Date: Mon May  1 19:08:58 2017
New Revision: 1793399

URL: http://svn.apache.org/viewvc?rev=1793399&view=rev
Log:
Add some new convenience methods for the Alert class -- a new "error"
alert that sets MessageType.ERROR, and overrides to set the preferred
width of the window also.

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=1793399&r1=1793398&r2=1793399&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/Alert.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/Alert.java Mon May  1 19:08:58 2017
@@ -332,6 +332,32 @@ public class Alert extends Dialog {
         alert(MessageType.INFO, message, null, null, owner, null);
     }
 
+    /**
+     * An alert with a type of {@link MessageType#INFO}.
+     *
+     * @param message The main message of this alert.
+     * @param owner   The owner window.
+     * @param width   The preferred width of the alert.
+     */
+    public static void alert(String message, Window owner, int width) {
+        alert(MessageType.INFO, message, null, null, owner, width, null);
+    }
+
+    public static void error(String message, Window owner) {
+        alert(MessageType.ERROR, message, null, null, owner, null);
+    }
+
+    /**
+     * An alert with a type of {@link MessageType#ERROR}.
+     *
+     * @param message The main message of this error.
+     * @param owner   The owner window.
+     * @param width   The preferred width of the alert.
+     */
+    public static void error(String message, Window owner, int width) {
+        alert(MessageType.ERROR, message, null, null, owner, width, null);
+    }
+
     public static void alert(MessageType messageType, String message, Window owner) {
         alert(messageType, message, null, null, owner, null);
     }
@@ -346,17 +372,32 @@ public class Alert extends Dialog {
     }
 
     public static void alert(MessageType messageType, String message, Component body, Window owner,
+        int width) {
+        alert(messageType, message, null, body, owner, width, null);
+    }
+
+    public static void alert(MessageType messageType, String message, Component body, Window owner,
         DialogCloseListener dialogCloseListener) {
         alert(messageType, message, null, body, owner, dialogCloseListener);
     }
 
     public static void alert(MessageType messageType, String message, String title, Component body,
         Window owner, DialogCloseListener dialogCloseListener) {
+        alert(messageType, message, title, body, owner, -1, dialogCloseListener);
+    }
+
+    public static void alert(MessageType messageType, String message, String title, Component body,
+        Window owner, int width, DialogCloseListener dialogCloseListener) {
         Alert alert = new Alert(messageType, message, null, body);
+
         if (title != null) {
             alert.setTitle(title);
         }
+        if (width > 0) {
+            alert.setPreferredWidth(width);
+        }
 
         alert.open(owner.getDisplay(), owner, dialogCloseListener);
     }
+
 }