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 2014/02/20 20:17:30 UTC

svn commit: r1570316 - in /pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra: TerraAlertSkin.java terra_alert_skin.bxml

Author: rwhitcomb
Date: Thu Feb 20 19:17:30 2014
New Revision: 1570316

URL: http://svn.apache.org/r1570316
Log:
PIVOT-935: Allow changes to styles in the predefined Alert class without
having to change the global theme colors.

This change exposes the internal Border component to TerraAlertSkin.java
and then adds accessor methods for that Border's background and foreground
colors (which are accessed via the normal "style" mechanisms).

Modified:
    pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraAlertSkin.java
    pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/terra_alert_skin.bxml

Modified: pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraAlertSkin.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraAlertSkin.java?rev=1570316&r1=1570315&r2=1570316&view=diff
==============================================================================
--- pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraAlertSkin.java (original)
+++ pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraAlertSkin.java Thu Feb 20 19:17:30 2014
@@ -16,14 +16,17 @@
  */
 package org.apache.pivot.wtk.skin.terra;
 
+import java.awt.Color;
 import org.apache.pivot.beans.BXMLSerializer;
 import org.apache.pivot.collections.Sequence;
 import org.apache.pivot.wtk.Alert;
 import org.apache.pivot.wtk.AlertListener;
+import org.apache.pivot.wtk.Border;
 import org.apache.pivot.wtk.BoxPane;
 import org.apache.pivot.wtk.Button;
 import org.apache.pivot.wtk.ButtonPressListener;
 import org.apache.pivot.wtk.Component;
+import org.apache.pivot.wtk.GraphicsUtilities;
 import org.apache.pivot.wtk.ImageView;
 import org.apache.pivot.wtk.Label;
 import org.apache.pivot.wtk.MessageType;
@@ -37,8 +40,11 @@ import org.apache.pivot.wtk.Window;
 public class TerraAlertSkin extends TerraDialogSkin implements AlertListener {
     private ImageView typeImageView = null;
     private Label messageLabel = null;
+    private Border messageBorder = null;
     private BoxPane messageBoxPane = null;
     private BoxPane optionButtonBoxPane = null;
+    private Color borderBackgroundColor = null;
+    private Color borderColor = null;
 
     private ButtonPressListener optionButtonPressListener = new ButtonPressListener() {
         @Override
@@ -56,6 +62,8 @@ public class TerraAlertSkin extends Terr
     public TerraAlertSkin() {
         TerraTheme theme = (TerraTheme) Theme.getTheme();
         setBackgroundColor(theme.getColor(9));
+        setBorderBackgroundColor(theme.getColor(10));
+        setBorderColor(theme.getColor(7));
     }
 
     @Override
@@ -83,9 +91,15 @@ public class TerraAlertSkin extends Terr
 
         typeImageView = (ImageView) bxmlSerializer.getNamespace().get("typeImageView");
         messageLabel = (Label) bxmlSerializer.getNamespace().get("messageLabel");
+        messageBorder = (Border) bxmlSerializer.getNamespace().get("messageBorder");
         messageBoxPane = (BoxPane) bxmlSerializer.getNamespace().get("messageBoxPane");
         optionButtonBoxPane = (BoxPane) bxmlSerializer.getNamespace().get("optionButtonBoxPane");
 
+        // Explicitly set the message border color and background color, this can't be done properly in the constructor
+        // as messageBorder is null at that point.
+        setBorderBackgroundColor(borderBackgroundColor);
+        setBorderColor(borderColor);
+
         for (Object option : alert.getOptions()) {
             PushButton optionButton = new PushButton(option);
             optionButton.setStyleName(TerraAlertSkin.class.getPackage().getName() + "."
@@ -162,4 +176,62 @@ public class TerraAlertSkin extends Terr
             optionButtonBoxPane.get(index).requestFocus();
         }
     }
+
+    public void setBorderBackgroundColor(Color borderBackgroundColor) {
+        if (borderBackgroundColor == null) {
+            throw new IllegalArgumentException("borderBackgroundColor is null.");
+        }
+
+        this.borderBackgroundColor = borderBackgroundColor;
+
+        if (messageBorder != null){
+            messageBorder.getStyles().put("backgroundColor", borderBackgroundColor);
+        }
+    }
+
+    public final void setBorderBackgroundColor(String borderBackgroundColor) {
+        if (borderBackgroundColor == null) {
+            throw new IllegalArgumentException("borderBackgroundColor is null.");
+        }
+
+        setBorderBackgroundColor(GraphicsUtilities.decodeColor(borderBackgroundColor));
+    }
+
+    public final void setBorderBackgroundColor(int borderBackgroundColor) {
+        TerraTheme theme = (TerraTheme) Theme.getTheme();
+        setBorderBackgroundColor(theme.getColor(borderBackgroundColor));
+    }
+
+    public Color getBorderBackgroundColor() {
+        return borderBackgroundColor;
+    }
+
+    public void setBorderColor(Color borderColor) {
+        if (borderColor == null) {
+            throw new IllegalArgumentException("messageBorderColor is null.");
+        }
+
+        this.borderColor = borderColor;
+
+        if (messageBorder != null){
+            messageBorder.getStyles().put("color", borderColor);
+        }
+    }
+
+    public final void setBorderColor(String borderColor) {
+        if (borderColor == null) {
+            throw new IllegalArgumentException("borderColor is null.");
+        }
+
+        setBorderColor(GraphicsUtilities.decodeColor(borderColor));
+    }
+
+    public final void setBorderColor(int borderColor) {
+        TerraTheme theme = (TerraTheme) Theme.getTheme();
+        setBorderColor(theme.getColor(borderColor));
+    }
+
+    public Color getBorderColor() {
+        return borderColor;
+    }
 }

Modified: pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/terra_alert_skin.bxml
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/terra_alert_skin.bxml?rev=1570316&r1=1570315&r2=1570316&view=diff
==============================================================================
--- pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/terra_alert_skin.bxml (original)
+++ pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/terra_alert_skin.bxml Thu Feb 20 19:17:30 2014
@@ -19,7 +19,7 @@ limitations under the License.
 <BoxPane orientation="vertical" styles="{spacing:8, fill:true}"
     xmlns:bxml="http://pivot.apache.org/bxml"
     xmlns="org.apache.pivot.wtk">
-    <Border styles="{padding:12, backgroundColor:10, color:7}">
+    <Border bxml:id="messageBorder" styles="{padding:12}">
         <TablePane styles="{horizontalSpacing:12, verticalSpacing:12}">
             <columns>
                 <TablePane.Column width="-1"/>