summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteffen Kriese2010-10-07 09:42:43 (EDT)
committerSteffen Kriese2010-10-07 09:42:43 (EDT)
commit4b60c7f6e9c54ceaa6dda3fca20f8009c0230318 (patch)
tree1183b2d10e674a6ddfb7c01e2a85d543307a19df
parent15768567d93fb0ae677d4b00f72e7f7e1df34704 (diff)
downloadorg.eclipse.riena-4b60c7f6e9c54ceaa6dda3fca20f8009c0230318.zip
org.eclipse.riena-4b60c7f6e9c54ceaa6dda3fca20f8009c0230318.tar.gz
org.eclipse.riena-4b60c7f6e9c54ceaa6dda3fca20f8009c0230318.tar.bz2
Fix for https://bugs.eclipse.org/bugs/show_bug.cgi?id=327232 NumericTextRidget setMaxLength to unlimited
-rw-r--r--org.eclipse.riena.tests/src/org/eclipse/riena/internal/ui/ridgets/swt/NumericTextRidgetTest.java25
-rw-r--r--org.eclipse.riena.ui.ridgets.swt/src/org/eclipse/riena/internal/ui/ridgets/swt/NumericTextRidget.java3
2 files changed, 20 insertions, 8 deletions
diff --git a/org.eclipse.riena.tests/src/org/eclipse/riena/internal/ui/ridgets/swt/NumericTextRidgetTest.java b/org.eclipse.riena.tests/src/org/eclipse/riena/internal/ui/ridgets/swt/NumericTextRidgetTest.java
index e26d3e5..4a2d18e 100644
--- a/org.eclipse.riena.tests/src/org/eclipse/riena/internal/ui/ridgets/swt/NumericTextRidgetTest.java
+++ b/org.eclipse.riena.tests/src/org/eclipse/riena/internal/ui/ridgets/swt/NumericTextRidgetTest.java
@@ -1159,13 +1159,6 @@ public class NumericTextRidgetTest extends TextRidgetTest {
ok();
}
- try {
- ridget.setMaxLength(-1);
- fail();
- } catch (final RuntimeException rex) {
- ok();
- }
-
final Integer oldValue = Integer.valueOf(ridget.getMaxLength());
expectPropertyChangeEvent(INumericTextRidget.PROPERTY_MAXLENGTH, oldValue, Integer.valueOf(5));
ridget.setMaxLength(5);
@@ -1179,6 +1172,24 @@ public class NumericTextRidgetTest extends TextRidgetTest {
verifyPropertyChangeEvents();
}
+ public void testResetMaxLengthToUnlimited() {
+ final INumericTextRidget ridget = getRidget();
+
+ Integer oldValue = Integer.valueOf(ridget.getMaxLength());
+ expectPropertyChangeEvent(INumericTextRidget.PROPERTY_MAXLENGTH, oldValue, Integer.valueOf(5));
+ ridget.setMaxLength(5);
+ verifyPropertyChangeEvents();
+ assertEquals(5, ridget.getMaxLength());
+
+ oldValue = Integer.valueOf(ridget.getMaxLength());
+ expectPropertyChangeEvent(INumericTextRidget.PROPERTY_MAXLENGTH, oldValue, Integer.valueOf(-1));
+
+ ridget.setMaxLength(-1);
+ assertEquals(-1, ridget.getMaxLength());
+
+ verifyPropertyChangeEvents();
+ }
+
public void testMaxLength() {
final INumericTextRidget ridget = getRidget();
final Text control = getWidget();
diff --git a/org.eclipse.riena.ui.ridgets.swt/src/org/eclipse/riena/internal/ui/ridgets/swt/NumericTextRidget.java b/org.eclipse.riena.ui.ridgets.swt/src/org/eclipse/riena/internal/ui/ridgets/swt/NumericTextRidget.java
index f944c32..3cf970e 100644
--- a/org.eclipse.riena.ui.ridgets.swt/src/org/eclipse/riena/internal/ui/ridgets/swt/NumericTextRidget.java
+++ b/org.eclipse.riena.ui.ridgets.swt/src/org/eclipse/riena/internal/ui/ridgets/swt/NumericTextRidget.java
@@ -359,7 +359,8 @@ public class NumericTextRidget extends TextRidget implements INumericTextRidget
}
public final synchronized void setMaxLength(final int maxLength) {
- Assert.isLegal(maxLength > 0, "maxLength must be greater than zero: " + maxLength); //$NON-NLS-1$
+ Assert.isLegal(maxLength == -1 || maxLength > 0,
+ "maxLength must be greater than zero or -1 (unlimited): " + maxLength); //$NON-NLS-1$
final int oldValue = this.maxLength;
if (oldValue != maxLength) {
this.maxLength = maxLength;