Community
Participate
Working Groups
What should happen when the precision is less than the digits after comma on setText / updateFromModel ? r.setPrecision(2); r.updateFromModel(); // 3,1415 results in? Carsten: Since it is considered to be an error in the application code I think instead of not showing the value a much better solution would be to throw an exception. Another option would be to set a rounding mode on the Ridget like ROUND,FLOOR,CEIL,...? Christian: +1 for what carsten is saying, except that we should not have a rounding option at this point in time.....maybe later.... Ekke: +1 for having a rounding option later - would be great for read-only or listing in table-columns etc As discussed in this thread: http://dev.eclipse.org/mhonarc/lists/riena-dev/msg00536.html
This is something we will consider after 1.1.0. The default mode should be 'throw exception'. Other modes should possible too (ROUDN, FLOOR, CEIL). My preferred way of implementing this is do allow setting a rounding strategy (strategy pattern): DecimalTextRidget.setRoundingStrategy(IRoundingStrategy s); IRoundingStrategy: #X round(X value, int precision) (X is the input/output type, not sure what this should be without investigating, leaving open for now) This would allow the app developer to decide what to do based on the value and precision. The strategy would return the result of the rounding or throw an exception. If this is not set, the default strategy is to throw a new RuntimeException. The strategy would only be invoked if necessary (i.e. if the number of digits behind the decimal separator exceeds the precision).
Bug 274378 (closely related to this) fulfills one of the requirements described in comment #1, it throws an exception if there are more fraction digits than allowed. Lowering priority.