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 2009/09/18 21:10:05 UTC
svn commit: r816749 - in
/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra:
TerraAlertSkin.java TerraPromptSkin.java command_button.json
Author: tvolkert
Date: Fri Sep 18 19:10:05 2009
New Revision: 816749
URL: http://svn.apache.org/viewvc?rev=816749&view=rev
Log:
Unified the "command button" style in terra theme (used in both alerts and prompts)
Added:
incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/command_button.json (with props)
Modified:
incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraAlertSkin.java
incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraPromptSkin.java
Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraAlertSkin.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraAlertSkin.java?rev=816749&r1=816748&r2=816749&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraAlertSkin.java (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraAlertSkin.java Fri Sep 18 19:10:05 2009
@@ -16,8 +16,15 @@
*/
package org.apache.pivot.wtk.skin.terra;
+import java.io.InputStream;
+import java.io.IOException;
+import java.net.URL;
+
import org.apache.pivot.collections.ArrayList;
import org.apache.pivot.collections.HashMap;
+import org.apache.pivot.collections.Map;
+import org.apache.pivot.serialization.JSONSerializer;
+import org.apache.pivot.serialization.SerializationException;
import org.apache.pivot.wtk.Alert;
import org.apache.pivot.wtk.AlertListener;
import org.apache.pivot.wtk.Button;
@@ -32,14 +39,35 @@
import org.apache.pivot.wtk.Window;
import org.apache.pivot.wtkx.WTKXSerializer;
-
/**
* Alert skin.
*/
+@SuppressWarnings("unchecked")
public class TerraAlertSkin extends TerraDialogSkin
implements AlertListener {
private ArrayList<Button> optionButtons = new ArrayList<Button>();
+ private static Map<String, ?> commandButtonStyles;
+
+ static {
+ URL location = TerraAlertSkin.class.getResource("command_button.json");
+
+ try {
+ InputStream inputStream = location.openStream();
+
+ try {
+ JSONSerializer serializer = new JSONSerializer();
+ commandButtonStyles = (Map<String, ?>)serializer.readObject(inputStream);
+ } finally {
+ inputStream.close();
+ }
+ } catch (IOException exception) {
+ throw new RuntimeException(exception);
+ } catch (SerializationException exception) {
+ throw new RuntimeException(exception);
+ }
+ }
+
public TerraAlertSkin() {
setResizable(false);
@@ -91,14 +119,7 @@
Object option = alert.getOption(i);
PushButton optionButton = new PushButton(option);
- HashMap<String, Object> optionButtonStyles = new HashMap<String, Object>();
- optionButtonStyles.put("color", theme.getColor(4));
- optionButtonStyles.put("backgroundColor", theme.getColor(16));
- optionButtonStyles.put("borderColor", theme.getColor(13));
- optionButtonStyles.put("padding", new Insets(3, 4, 3, 4));
-
- optionButton.setStyles(optionButtonStyles);
- optionButton.getStyles().put("minimumAspectRatio", 3);
+ optionButton.setStyles(commandButtonStyles);
optionButton.getButtonPressListeners().add(new ButtonPressListener() {
@Override
Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraPromptSkin.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraPromptSkin.java?rev=816749&r1=816748&r2=816749&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraPromptSkin.java (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraPromptSkin.java Fri Sep 18 19:10:05 2009
@@ -16,8 +16,15 @@
*/
package org.apache.pivot.wtk.skin.terra;
+import java.io.InputStream;
+import java.io.IOException;
+import java.net.URL;
+
import org.apache.pivot.collections.ArrayList;
import org.apache.pivot.collections.HashMap;
+import org.apache.pivot.collections.Map;
+import org.apache.pivot.serialization.JSONSerializer;
+import org.apache.pivot.serialization.SerializationException;
import org.apache.pivot.wtk.Button;
import org.apache.pivot.wtk.ButtonPressListener;
import org.apache.pivot.wtk.Component;
@@ -36,10 +43,32 @@
/**
* Prompt skin.
*/
+@SuppressWarnings("unchecked")
public class TerraPromptSkin extends TerraSheetSkin
implements PromptListener {
private ArrayList<Button> optionButtons = new ArrayList<Button>();
+ private static Map<String, ?> commandButtonStyles;
+
+ static {
+ URL location = TerraPromptSkin.class.getResource("command_button.json");
+
+ try {
+ InputStream inputStream = location.openStream();
+
+ try {
+ JSONSerializer serializer = new JSONSerializer();
+ commandButtonStyles = (Map<String, ?>)serializer.readObject(inputStream);
+ } finally {
+ inputStream.close();
+ }
+ } catch (IOException exception) {
+ throw new RuntimeException(exception);
+ } catch (SerializationException exception) {
+ throw new RuntimeException(exception);
+ }
+ }
+
public TerraPromptSkin() {
setResizable(false);
setPadding(0);
@@ -89,14 +118,7 @@
Object option = prompt.getOption(i);
PushButton optionButton = new PushButton(option);
- HashMap<String, Object> optionButtonStyles = new HashMap<String, Object>();
- optionButtonStyles.put("color", theme.getColor(4));
- optionButtonStyles.put("backgroundColor", theme.getColor(16));
- optionButtonStyles.put("borderColor", theme.getColor(13));
- optionButtonStyles.put("padding", new Insets(3, 4, 3, 4));
-
- optionButton.setStyles(optionButtonStyles);
- optionButton.getStyles().put("minimumAspectRatio", 3);
+ optionButton.setStyles(commandButtonStyles);
optionButton.getButtonPressListeners().add(new ButtonPressListener() {
@Override
Added: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/command_button.json
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/command_button.json?rev=816749&view=auto
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/command_button.json (added)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/command_button.json Fri Sep 18 19:10:05 2009
@@ -0,0 +1,7 @@
+{
+ color: "#ffffff",
+ backgroundColor: "#336699",
+ borderColor: "#2b5580",
+ padding: {top:3, left:4, bottom:3, right:4},
+ minimumAspectRatio: 3
+}
Propchange: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/command_button.json
------------------------------------------------------------------------------
svn:eol-style = native