You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pivot.apache.org by gb...@apache.org on 2010/09/14 15:22:27 UTC
svn commit: r996888 - in /pivot/trunk: core/src/org/apache/pivot/json/
tutorials/src/org/apache/pivot/tutorials/webqueries/
wtk-terra/src/org/apache/pivot/wtk/skin/terra/ wtk/src/org/apache/pivot/wtk/
Author: gbrown
Date: Tue Sep 14 13:22:26 2010
New Revision: 996888
URL: http://svn.apache.org/viewvc?rev=996888&view=rev
Log:
Re-add numeric primitive getters to JSON class because casting to the desired type does not work (it must be explicitly determined via Number#intValue(), longValue(), etc.).
Modified:
pivot/trunk/core/src/org/apache/pivot/json/JSON.java
pivot/trunk/tutorials/src/org/apache/pivot/tutorials/webqueries/ExpensesWindow.java
pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraAccordionSkin.java
pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraCalendarSkin.java
pivot/trunk/wtk/src/org/apache/pivot/wtk/GraphicsUtilities.java
Modified: pivot/trunk/core/src/org/apache/pivot/json/JSON.java
URL: http://svn.apache.org/viewvc/pivot/trunk/core/src/org/apache/pivot/json/JSON.java?rev=996888&r1=996887&r2=996888&view=diff
==============================================================================
--- pivot/trunk/core/src/org/apache/pivot/json/JSON.java (original)
+++ pivot/trunk/core/src/org/apache/pivot/json/JSON.java Tue Sep 14 13:22:26 2010
@@ -88,6 +88,36 @@ public class JSON {
return (T)value;
}
+ public static byte getByte(Object root, String path) {
+ Number value = get(root, path);
+ return value.byteValue();
+ }
+
+ public static short getShort(Object root, String path) {
+ Number value = get(root, path);
+ return value.shortValue();
+ }
+
+ public static int getInt(Object root, String path) {
+ Number value = get(root, path);
+ return value.intValue();
+ }
+
+ public static long getLong(Object root, String path) {
+ Number value = get(root, path);
+ return value.longValue();
+ }
+
+ public static float getFloat(Object root, String path) {
+ Number value = get(root, path);
+ return value.floatValue();
+ }
+
+ public static double getDouble(Object root, String path) {
+ Number value = get(root, path);
+ return value.doubleValue();
+ }
+
/**
* Sets the value at the given path.
*
Modified: pivot/trunk/tutorials/src/org/apache/pivot/tutorials/webqueries/ExpensesWindow.java
URL: http://svn.apache.org/viewvc/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/webqueries/ExpensesWindow.java?rev=996888&r1=996887&r2=996888&view=diff
==============================================================================
--- pivot/trunk/tutorials/src/org/apache/pivot/tutorials/webqueries/ExpensesWindow.java (original)
+++ pivot/trunk/tutorials/src/org/apache/pivot/tutorials/webqueries/ExpensesWindow.java Tue Sep 14 13:22:26 2010
@@ -237,7 +237,7 @@ public class ExpensesWindow extends Wind
@SuppressWarnings("unchecked")
private void updateSelectedExpense() {
Object expense = expenseTableView.getSelectedRow();
- final int id = (Integer)JSON.get(expense, "id");
+ final int id = JSON.getInt(expense, "id");
expenseSheet.load(expense);
expenseSheet.open(this, new SheetCloseListener() {
@@ -290,7 +290,7 @@ public class ExpensesWindow extends Wind
@SuppressWarnings("unchecked")
private void deleteSelectedExpense() {
Object expense = expenseTableView.getSelectedRow();
- final int id = (Integer)JSON.get(expense, "id");
+ final int id = JSON.getInt(expense, "id");
deleteConfirmationPrompt.open(this, new SheetCloseListener() {
@Override
Modified: pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraAccordionSkin.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraAccordionSkin.java?rev=996888&r1=996887&r2=996888&view=diff
==============================================================================
--- pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraAccordionSkin.java (original)
+++ pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraAccordionSkin.java Tue Sep 14 13:22:26 2010
@@ -291,7 +291,6 @@ public class TerraAccordionSkin extends
private Color buttonBackgroundColor;
private Insets buttonPadding;
- // Derived colors
private Color buttonBevelColor;
private SelectionChangeTransition selectionChangeTransition = null;
@@ -655,6 +654,64 @@ public class TerraAccordionSkin extends
setButtonColor(GraphicsUtilities.decodeColor(buttonColor));
}
+ public final void setButtonColor(int buttonColor) {
+ TerraTheme theme = (TerraTheme)Theme.getTheme();
+ setButtonColor(theme.getColor(buttonColor));
+ }
+
+ public Color getDisabledButtonColor() {
+ return disabledButtonColor;
+ }
+
+ public void setDisabledButtonColor(Color disabledButtonColor) {
+ if (disabledButtonColor == null) {
+ throw new IllegalArgumentException("disabledButtonColor is null.");
+ }
+
+ this.disabledButtonColor = disabledButtonColor;
+ repaintComponent();
+ }
+
+ public final void setDisabledButtonColor(String disabledButtonColor) {
+ if (disabledButtonColor == null) {
+ throw new IllegalArgumentException("disabledButtonColor is null.");
+ }
+
+ setDisabledButtonColor(GraphicsUtilities.decodeColor(disabledButtonColor));
+ }
+
+ public final void setDisabledButtonColor(int disabledButtonColor) {
+ TerraTheme theme = (TerraTheme)Theme.getTheme();
+ setDisabledButtonColor(theme.getColor(disabledButtonColor));
+ }
+
+ public Color getButtonBackgroundColor() {
+ return buttonBackgroundColor;
+ }
+
+ public void setButtonBackgroundColor(Color buttonBackgroundColor) {
+ if (buttonBackgroundColor == null) {
+ throw new IllegalArgumentException("buttonBackgroundColor is null.");
+ }
+
+ this.buttonBackgroundColor = buttonBackgroundColor;
+ buttonBevelColor = TerraTheme.brighten(buttonBackgroundColor);
+ repaintComponent();
+ }
+
+ public final void setButtonBackgroundColor(String buttonBackgroundColor) {
+ if (buttonBackgroundColor == null) {
+ throw new IllegalArgumentException("buttonBackgroundColor is null.");
+ }
+
+ setButtonBackgroundColor(GraphicsUtilities.decodeColor(buttonBackgroundColor));
+ }
+
+ public final void setButtonBackgroundColor(int buttonBackgroundColor) {
+ TerraTheme theme = (TerraTheme)Theme.getTheme();
+ setButtonBackgroundColor(theme.getColor(buttonBackgroundColor));
+ }
+
public Insets getButtonPadding() {
return buttonPadding;
}
Modified: pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraCalendarSkin.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraCalendarSkin.java?rev=996888&r1=996887&r2=996888&view=diff
==============================================================================
--- pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraCalendarSkin.java (original)
+++ pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraCalendarSkin.java Tue Sep 14 13:22:26 2010
@@ -521,7 +521,7 @@ public class TerraCalendarSkin extends C
throw new RuntimeException(exception);
}
- weekdayCharacterIndex = (Integer)JSON.get(resources, "weekdayCharacterIndex");
+ weekdayCharacterIndex = JSON.getInt(resources, "weekdayCharacterIndex");
}
@Override
Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/GraphicsUtilities.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/GraphicsUtilities.java?rev=996888&r1=996887&r2=996888&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/GraphicsUtilities.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/GraphicsUtilities.java Tue Sep 14 13:22:26 2010
@@ -258,10 +258,10 @@ public final class GraphicsUtilities {
}
case GRADIENT: {
- float startX = (Float)JSON.get(dictionary, START_X_KEY);
- float startY = (Float)JSON.get(dictionary, START_Y_KEY);
- float endX = (Float)JSON.get(dictionary, END_X_KEY);
- float endY = (Float)JSON.get(dictionary, END_Y_KEY);
+ float startX = JSON.getFloat(dictionary, START_X_KEY);
+ float startY = JSON.getFloat(dictionary, START_Y_KEY);
+ float endX = JSON.getFloat(dictionary, END_X_KEY);
+ float endY = JSON.getFloat(dictionary, END_Y_KEY);
Color startColor = decodeColor((String)JSON.get(dictionary, START_COLOR_KEY));
Color endColor = decodeColor((String)JSON.get(dictionary, END_COLOR_KEY));
paint = new GradientPaint(startX, startY, startColor, endX, endY, endColor);
@@ -269,10 +269,10 @@ public final class GraphicsUtilities {
}
case LINEAR_GRADIENT: {
- float startX = (Float)JSON.get(dictionary, START_X_KEY);
- float startY = (Float)JSON.get(dictionary, START_Y_KEY);
- float endX = (Float)JSON.get(dictionary, END_X_KEY);
- float endY = (Float)JSON.get(dictionary, END_Y_KEY);
+ float startX = JSON.getFloat(dictionary, START_X_KEY);
+ float startY = JSON.getFloat(dictionary, START_Y_KEY);
+ float endX = JSON.getFloat(dictionary, END_X_KEY);
+ float endY = JSON.getFloat(dictionary, END_Y_KEY);
List<Dictionary<String, ?>> stops =
(List<Dictionary<String, ?>>)JSON.get(dictionary, STOPS_KEY);
@@ -283,7 +283,7 @@ public final class GraphicsUtilities {
for (int i = 0; i < n; i++) {
Dictionary<String, ?> stop = stops.get(i);
- float offset = (Float)JSON.get(stop, OFFSET_KEY);
+ float offset = JSON.getFloat(stop, OFFSET_KEY);
fractions[i] = offset;
Color color = decodeColor((String)JSON.get(stop, COLOR_KEY));
@@ -295,9 +295,9 @@ public final class GraphicsUtilities {
}
case RADIAL_GRADIENT: {
- float centerX = (Float)JSON.get(dictionary, CENTER_X_KEY);
- float centerY = (Float)JSON.get(dictionary, CENTER_Y_KEY);
- float radius = (Float)JSON.get(dictionary, RADIUS_KEY);
+ float centerX = JSON.getFloat(dictionary, CENTER_X_KEY);
+ float centerY = JSON.getFloat(dictionary, CENTER_Y_KEY);
+ float radius = JSON.getFloat(dictionary, RADIUS_KEY);
List<Dictionary<String, ?>> stops =
(List<Dictionary<String, ?>>)JSON.get(dictionary, STOPS_KEY);
@@ -308,7 +308,7 @@ public final class GraphicsUtilities {
for (int i = 0; i < n; i++) {
Dictionary<String, ?> stop = stops.get(i);
- float offset = (Float)JSON.get(stop, OFFSET_KEY);
+ float offset = JSON.getFloat(stop, OFFSET_KEY);
fractions[i] = offset;
Color color = decodeColor((String)JSON.get(stop, COLOR_KEY));