You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pivot.apache.org by sm...@apache.org on 2013/02/21 18:30:06 UTC
svn commit: r1448729 - in /pivot/branches/2.0.x:
tutorials/src/org/apache/pivot/tutorials/bxmlexplorer/
tutorials/src/org/apache/pivot/tutorials/layout/
tutorials/src/org/apache/pivot/tutorials/webqueries/ tutorials/www/
wtk/src/org/apache/pivot/wtk/
Author: smartini
Date: Thu Feb 21 17:30:06 2013
New Revision: 1448729
URL: http://svn.apache.org/r1448729
Log:
PIVOT-893 (part 2): do not allow text == null in Label anymore
Modified:
pivot/branches/2.0.x/tutorials/src/org/apache/pivot/tutorials/bxmlexplorer/FakeWindowSkin.java
pivot/branches/2.0.x/tutorials/src/org/apache/pivot/tutorials/layout/Forms.java
pivot/branches/2.0.x/tutorials/src/org/apache/pivot/tutorials/webqueries/ResultItemRenderer.java
pivot/branches/2.0.x/tutorials/www/data-binding.xml
pivot/branches/2.0.x/tutorials/www/forms.xml
pivot/branches/2.0.x/tutorials/www/web-queries.xml
pivot/branches/2.0.x/wtk/src/org/apache/pivot/wtk/Label.java
Modified: pivot/branches/2.0.x/tutorials/src/org/apache/pivot/tutorials/bxmlexplorer/FakeWindowSkin.java
URL: http://svn.apache.org/viewvc/pivot/branches/2.0.x/tutorials/src/org/apache/pivot/tutorials/bxmlexplorer/FakeWindowSkin.java?rev=1448729&r1=1448728&r2=1448729&view=diff
==============================================================================
--- pivot/branches/2.0.x/tutorials/src/org/apache/pivot/tutorials/bxmlexplorer/FakeWindowSkin.java (original)
+++ pivot/branches/2.0.x/tutorials/src/org/apache/pivot/tutorials/bxmlexplorer/FakeWindowSkin.java Thu Feb 21 17:30:06 2013
@@ -413,7 +413,7 @@ public class FakeWindowSkin extends Cont
public void titleChanged(FakeWindow window, String previousTitle) {
String title = window.getTitle();
titleLabel.setVisible(title != null);
- titleLabel.setText(title);
+ titleLabel.setText(title != null ? title : "");
}
@Override
Modified: pivot/branches/2.0.x/tutorials/src/org/apache/pivot/tutorials/layout/Forms.java
URL: http://svn.apache.org/viewvc/pivot/branches/2.0.x/tutorials/src/org/apache/pivot/tutorials/layout/Forms.java?rev=1448729&r1=1448728&r2=1448729&view=diff
==============================================================================
--- pivot/branches/2.0.x/tutorials/src/org/apache/pivot/tutorials/layout/Forms.java (original)
+++ pivot/branches/2.0.x/tutorials/src/org/apache/pivot/tutorials/layout/Forms.java Thu Feb 21 17:30:06 2013
@@ -62,7 +62,7 @@ public class Forms extends Window implem
Form.setFlag(nameBoxPane, flag);
if (flag == null) {
- errorLabel.setText(null);
+ errorLabel.setText("");
Prompt.prompt("Pretending to submit...", Forms.this);
} else {
errorLabel.setText("Some required information is missing.");
Modified: pivot/branches/2.0.x/tutorials/src/org/apache/pivot/tutorials/webqueries/ResultItemRenderer.java
URL: http://svn.apache.org/viewvc/pivot/branches/2.0.x/tutorials/src/org/apache/pivot/tutorials/webqueries/ResultItemRenderer.java?rev=1448729&r1=1448728&r2=1448729&view=diff
==============================================================================
--- pivot/branches/2.0.x/tutorials/src/org/apache/pivot/tutorials/webqueries/ResultItemRenderer.java (original)
+++ pivot/branches/2.0.x/tutorials/src/org/apache/pivot/tutorials/webqueries/ResultItemRenderer.java Thu Feb 21 17:30:06 2013
@@ -66,7 +66,7 @@ public class ResultItemRenderer extends
Map<String, ?> location = JSON.get(item, "['y:location']");
if (location == null) {
- addressLabel.setText(null);
+ addressLabel.setText("");
} else {
String street = JSON.get(location, "street");
String city = JSON.get(location, "city");
Modified: pivot/branches/2.0.x/tutorials/www/data-binding.xml
URL: http://svn.apache.org/viewvc/pivot/branches/2.0.x/tutorials/www/data-binding.xml?rev=1448729&r1=1448728&r2=1448729&view=diff
==============================================================================
--- pivot/branches/2.0.x/tutorials/www/data-binding.xml (original)
+++ pivot/branches/2.0.x/tutorials/www/data-binding.xml Thu Feb 21 17:30:06 2013
@@ -187,7 +187,7 @@ limitations under the License.
@Override
public void buttonPressed(Button button) {
form.clear();
- sourceLabel.setText(null);
+ sourceLabel.setText("");
}
});
}
Modified: pivot/branches/2.0.x/tutorials/www/forms.xml
URL: http://svn.apache.org/viewvc/pivot/branches/2.0.x/tutorials/www/forms.xml?rev=1448729&r1=1448728&r2=1448729&view=diff
==============================================================================
--- pivot/branches/2.0.x/tutorials/www/forms.xml (original)
+++ pivot/branches/2.0.x/tutorials/www/forms.xml Thu Feb 21 17:30:06 2013
@@ -222,7 +222,7 @@ limitations under the License.
Form.setFlag(nameBoxPane, flag);
if (flag == null) {
- errorLabel.setText(null);
+ errorLabel.setText("");
Prompt.prompt("Pretending to submit...", Forms.this);
} else {
errorLabel.setText("Some required information is missing.");
Modified: pivot/branches/2.0.x/tutorials/www/web-queries.xml
URL: http://svn.apache.org/viewvc/pivot/branches/2.0.x/tutorials/www/web-queries.xml?rev=1448729&r1=1448728&r2=1448729&view=diff
==============================================================================
--- pivot/branches/2.0.x/tutorials/www/web-queries.xml (original)
+++ pivot/branches/2.0.x/tutorials/www/web-queries.xml Thu Feb 21 17:30:06 2013
@@ -261,7 +261,7 @@ limitations under the License.
Map<String, ?> location = JSON.get(item, "['y:location']");
if (location == null) {
- addressLabel.setText(null);
+ addressLabel.setText("");
} else {
String street = JSON.get(location, "street");
String city = JSON.get(location, "city");
Modified: pivot/branches/2.0.x/wtk/src/org/apache/pivot/wtk/Label.java
URL: http://svn.apache.org/viewvc/pivot/branches/2.0.x/wtk/src/org/apache/pivot/wtk/Label.java?rev=1448729&r1=1448728&r2=1448729&view=diff
==============================================================================
--- pivot/branches/2.0.x/wtk/src/org/apache/pivot/wtk/Label.java (original)
+++ pivot/branches/2.0.x/wtk/src/org/apache/pivot/wtk/Label.java Thu Feb 21 17:30:06 2013
@@ -97,11 +97,11 @@ public class Label extends Component {
private LabelBindingListenerList labelBindingListeners = new LabelBindingListenerList();
public Label() {
- this(null);
+ this("");
}
public Label(String text) {
- this.text = text;
+ setText(text);
installSkin(Label.class);
}
@@ -111,13 +111,11 @@ public class Label extends Component {
}
public void setText(String text) {
- // TODO: in 2.1 verify if enable this constraint (like in other classes)
- // if (text == null) {
- // throw new IllegalArgumentException();
- // }
- //
- // if (text.length() > maximumLength) {
- if (text != null && text.length() > maximumLength) {
+ if (text == null) {
+ throw new IllegalArgumentException();
+ }
+
+ if (text.length() > maximumLength) {
throw new IllegalArgumentException("Text length is greater than maximum length.");
}
@@ -163,13 +161,9 @@ public class Label extends Component {
if (previousMaximumLength != maximumLength) {
this.maximumLength = maximumLength;
- if (text != null) {
- // Truncate the text, if necessary (do not allow listeners to vote on this change)
- int length = text.length();
- if (length > maximumLength) {
- setText(text.substring(0, maximumLength));
- }
-
+ // Truncate the text, if necessary (do not allow listeners to vote on this change)
+ if (text.length() > maximumLength) {
+ setText(text.substring(0, maximumLength));
}
labelListeners.maximumLengthChanged(this, previousMaximumLength);
@@ -234,7 +228,7 @@ public class Label extends Component {
value = textBindMapping.toString(value);
}
- setText((String)value);
+ setText(value != null ? (String)value : "");
}
}
@@ -251,7 +245,7 @@ public class Label extends Component {
@Override
public void clear() {
if (textKey != null) {
- setText(null);
+ setText("");
}
}