|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.springframework.richclient.application.support.ApplicationServicesAccessor
org.springframework.richclient.form.binding.support.AbstractBinder
org.springframework.richclient.form.binding.swing.NumberBinder
public class NumberBinder
Binder for numeric fields. Constructs a NumberBinding
which holds
a special inputfield org.springframework.richclient.swing.BigDecimalTextField
.
This binder comes with a set of configuration properties which makes this easy reusable.
Examples:
<bean id="euroBinder" class="org.springframework.richclient.form.binding.swing.NumberBinder" lazy-init="true"> <property name="format"> <value>###,###,###,##0.00</value> </property> <property name="nrOfDecimals"> <value type="int">2</value> </property> <property name="leftDecoration"> <value>€</value> </property> </bean>
<bean id="percentageBinder" class="org.springframework.richclient.form.binding.swing.NumberBinder" lazy-init="true"> <property name="nrOfNonDecimals"> <value type="int">3</value> </property> <property name="nrOfDecimals"> <value type="int">4</value> </property> <property name="rightDecoration"> <value>%</value> </property> <property name="shiftFactor"> <value type="java.math.BigDecimal">100</value> </property> </bean>TODO it might be better to get the number of decimals/nonDecimals from the format
Field Summary | |
---|---|
protected int |
alignment
|
protected String |
format
|
protected String |
leftDecoration
|
protected boolean |
negativeSign
|
protected int |
nrOfDecimals
|
protected int |
nrOfNonDecimals
|
protected boolean |
readOnly
|
protected String |
rightDecoration
|
protected Integer |
scale
|
protected BigDecimal |
shiftFactor
|
protected String |
unformat
|
Fields inherited from class org.springframework.richclient.form.binding.support.AbstractBinder |
---|
BINDING_CLIENT_PROPERTY_KEY, log |
Fields inherited from class org.springframework.richclient.application.support.ApplicationServicesAccessor |
---|
logger |
Constructor Summary | |
---|---|
NumberBinder()
Default constructor. |
|
NumberBinder(Class requiredSourceClass)
Constructor taking the requiredSourceClass for this binder. |
Method Summary | |
---|---|
protected JComponent |
createControl(Map context)
|
protected Binding |
doBind(JComponent control,
FormModel formModel,
String formPropertyPath,
Map context)
|
void |
setAlignment(int alignment)
Sets the horizontal aligment of the BigDecimalTextField. |
void |
setFormat(String format)
Format that will be used to show this number. |
void |
setLeftDecoration(String leftDecoration)
Set a decoration to the left of the inputField. |
void |
setNegativeSign(boolean negativeSign)
Allow negative numbers. |
void |
setNrOfDecimals(int nrOfDecimals)
Maximum number of decimals. |
void |
setNrOfNonDecimals(int nrOfNonDecimals)
Maximum number of non-decimals. |
void |
setReadOnly(boolean readOnly)
Force this inputField to be readOnly. |
void |
setRightDecoration(String rightDecoration)
Set a decoration to the right of the inputField. |
void |
setScale(Integer scale)
Enforce a given scale for the result. |
void |
setShiftFactor(BigDecimal shiftFactor)
BigDecimals can be shifted right/left when storing. |
void |
setUnformat(String unformat)
Format that will be used when user is editing the field. |
Methods inherited from class org.springframework.richclient.form.binding.support.AbstractBinder |
---|
bind, bind, getPropertyType, getRequiredSourceClass, validateContextKeys |
Methods inherited from class org.springframework.richclient.application.support.ApplicationServicesAccessor |
---|
getActiveWindow, getApplication, getApplicationContext, getApplicationName, getApplicationServices, getCommandConfigurer, getComponentFactory, getConversionService, getIconSource, getImageSource, getMessage, getMessage, getMessage, getMessage, getMessages, getMessageSource, getObjectConfigurer, getService |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected boolean readOnly
protected String format
protected String unformat
protected int nrOfDecimals
protected int nrOfNonDecimals
protected boolean negativeSign
protected String leftDecoration
protected String rightDecoration
protected BigDecimal shiftFactor
protected Integer scale
protected int alignment
Constructor Detail |
---|
public NumberBinder()
Default constructor.
Sets BigDecimal as requiredSourceClass.
public NumberBinder(Class requiredSourceClass)
requiredSourceClass
- Required source class.Method Detail |
---|
public void setReadOnly(boolean readOnly)
readOnly
- public void setLeftDecoration(String leftDecoration)
leftDecoration
- Decoration to be placed.public void setRightDecoration(String rightDecoration)
rightDecoration
- Decoration to be placed.public void setFormat(String format)
format
- NumberFormat.public void setUnformat(String unformat)
Format that will be used when user is editing the field.
eg. when inputField gets focus, all formatting can be disabled. If focus is shifted, number will be formatted.
unformat
- NumberFormatpublic void setNrOfDecimals(int nrOfDecimals)
nrOfDecimals
- public void setNrOfNonDecimals(int nrOfNonDecimals)
nrOfNonDecimals
- public void setNegativeSign(boolean negativeSign)
true
.
negativeSign
- True if negative numbers are used.public void setShiftFactor(BigDecimal shiftFactor)
BigDecimals can be shifted right/left when storing.
Eg. percentages may be shown as ###.##
and saved as
#.####
.
shiftFactor
- Factor to shift number when saved.public void setScale(Integer scale)
scale
- The scale to set.BigDecimal.setScale(int)
public void setAlignment(int alignment)
alignment
- Horizontal alignment to set.protected JComponent createControl(Map context)
createControl
in class AbstractBinder
protected Binding doBind(JComponent control, FormModel formModel, String formPropertyPath, Map context)
doBind
in class AbstractBinder
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |