Subversion Repository Public Repository

litesoft

Diff Revisions 947 vs 948 for /trunk/Java/GWT/OldClient/src/org/litesoft/GWT/forms/client/nonpublic/AbstractNumericRequireableAttributeAdapter.java

Diff revisions: vs.
  @@ -1,8 +1,6 @@
1 1 // This Source Code is in the Public Domain per: http://unlicense.org
2 2 package org.litesoft.GWT.forms.client.nonpublic;
3 3
4 - import java.io.*;
5 -
6 4 import org.litesoft.GWT.client.*;
7 5 import org.litesoft.GWT.forms.client.components.impls.input.*;
8 6 import org.litesoft.commonfoundation.typeutils.*;
  @@ -12,28 +10,25 @@
12 10 import org.litesoft.ui.def.nonpublic.support.*;
13 11 import org.litesoft.uispecification.*;
14 12
13 + import java.io.*;
14 +
15 15 public abstract class AbstractNumericRequireableAttributeAdapter
16 - extends AbstractNonStringRequireableAttributeAdapter
17 - {
16 + extends AbstractNonStringRequireableAttributeAdapter {
18 17 private Integer mDecimalPlaces;
19 18 private NumericFormatControl mFormatControl;
20 19
21 20 public AbstractNumericRequireableAttributeAdapter( FormInstanceComponentHandler pComponentHandler,
22 - UiInputDef pUiDef, NumericMetaData pMD )
23 - {
21 + UiInputDef pUiDef, NumericMetaData pMD ) {
24 22 super( pComponentHandler, pMD, createFC( pUiDef, pMD ) );
25 - if ( null != (mDecimalPlaces = pMD.getDecimalPlaces()) )
26 - {
27 - mDecimalPlaces = Math.min( Math.abs( mDecimalPlaces.intValue() ), 20);
23 + if ( null != (mDecimalPlaces = pMD.getDecimalPlaces()) ) {
24 + mDecimalPlaces = Math.min( Math.abs( mDecimalPlaces.intValue() ), 20 );
28 25 }
29 - if ( null == (mFormatControl = pMD.getFormatControl()) )
30 - {
26 + if ( null == (mFormatControl = pMD.getFormatControl()) ) {
31 27 mFormatControl = NumericFormatControl.JUST_DOT;
32 28 }
33 29 }
34 30
35 - private static FormRightAlignTextField createFC( UiInputDef pUiDef, NumericMetaData pMD )
36 - {
31 + private static FormRightAlignTextField createFC( UiInputDef pUiDef, NumericMetaData pMD ) {
37 32 String zLabelText = !pUiDef.isLabelLess() ? pMD.getExternalText() : null;
38 33 UiFont zLabelFont = pUiDef.getLabelFont();
39 34 String zTooltip = pMD.getTooltip();
  @@ -44,42 +39,33 @@
44 39 return new FormRightAlignTextField( zLabelText, zLabelFont, zTooltip, zPreferredWidth, zMaxChars );
45 40 }
46 41
47 - protected Object getComponentCurrentValue()
48 - {
42 + protected Object getComponentCurrentValue() {
49 43 Object value = super.getComponentCurrentValue();
50 - if ( value != null )
51 - {
44 + if ( value != null ) {
52 45 value = Strings.noEmpty( value.toString() );
53 46 }
54 47 return value;
55 48 }
56 49
57 - public void blurOccurred()
58 - {
50 + public void blurOccurred() {
59 51 super.blurOccurred();
60 - if ( !isErrorState() )
61 - {
62 - try
63 - {
52 + if ( !isErrorState() ) {
53 + try {
64 54 DecimalToStringParts zSP = convert( mComponent.getCurrentText() );
65 - if ( zSP != null )
66 - {
55 + if ( zSP != null ) {
67 56 mComponent.setCurrentValue(
68 57 mLastErrorComponentCurrentValue = zSP.toString( mFormatControl ) );
69 58 }
70 59 }
71 - catch ( IllegalArgumentException e )
72 - {
60 + catch ( IllegalArgumentException e ) {
73 61 // Already in Error State
74 62 }
75 63 }
76 64 }
77 65
78 66 protected String transformErrorText( String pErrorText, Serializable pSendableCurrentValue,
79 - Object pComponentCurrentValue )
80 - {
81 - if ( null == (pErrorText = Strings.noEmpty( pErrorText )) )
82 - {
67 + Object pComponentCurrentValue ) {
68 + if ( null == (pErrorText = Strings.noEmpty( pErrorText )) ) {
83 69 pErrorText = getCurrentValueErrorText( pComponentCurrentValue );
84 70 }
85 71 return super.transformErrorText( pErrorText, //
  @@ -87,35 +73,27 @@
87 73 pComponentCurrentValue );
88 74 }
89 75
90 - protected Object convertSendableToComponentValue( Serializable pValue )
91 - {
92 - try
93 - {
76 + protected Object convertSendableToComponentValue( Serializable pValue ) {
77 + try {
94 78 DecimalToStringParts zSP = convert( pValue );
95 - if ( zSP != null )
96 - {
79 + if ( zSP != null ) {
97 80 return mLastErrorComponentCurrentValue = zSP.toString( mFormatControl );
98 81 }
99 82 }
100 - catch ( IllegalArgumentException e )
101 - {
83 + catch ( IllegalArgumentException e ) {
102 84 AlertManager.alert( "DataConversion", null, "Unable to convert value", "Value:" + pValue, e );
103 85 }
104 86 return null;
105 87 }
106 88
107 - protected Serializable convertComponentValueToSendable( Object pValue )
108 - {
109 - try
110 - {
89 + protected Serializable convertComponentValueToSendable( Object pValue ) {
90 + try {
111 91 DecimalToStringParts zSP = convert( pValue );
112 - if ( zSP != null )
113 - {
92 + if ( zSP != null ) {
114 93 return LLconvertNonNullComponentValueToSendable( zSP.toString() );
115 94 }
116 95 }
117 - catch ( IllegalArgumentException e )
118 - {
96 + catch ( IllegalArgumentException e ) {
119 97 mLastErrorText = e.getMessage();
120 98 setErrorTextAndPublish( null, null, mLastErrorComponentCurrentValue );
121 99 }
  @@ -125,11 +103,9 @@
125 103 abstract protected Serializable LLconvertNonNullComponentValueToSendable( String pCleanedValue );
126 104
127 105 private DecimalToStringParts convert( Object pValue )
128 - throws IllegalArgumentException
129 - {
106 + throws IllegalArgumentException {
130 107 mLastErrorText = null;
131 - if ( null != (mLastErrorComponentCurrentValue = conversionHelper( pValue )) )
132 - {
108 + if ( null != (mLastErrorComponentCurrentValue = conversionHelper( pValue )) ) {
133 109 DecimalToStringParts zSP = new DecimalToStringParts( mLastErrorComponentCurrentValue, //
134 110 mFormatControl.getDecimalSeparator() );
135 111 return zSP.forceDecimalPlaces( mDecimalPlaces, false );
  @@ -137,15 +113,12 @@
137 113 return null;
138 114 }
139 115
140 - private String conversionHelper( Object pValue )
141 - {
116 + private String conversionHelper( Object pValue ) {
142 117 return (pValue != null) ? Strings.noEmpty( pValue.toString() ) : null;
143 118 }
144 119
145 - private String getCurrentValueErrorText( Object pComponentCurrentValue )
146 - {
147 - if ( !Objects.areNonArraysEqual( pComponentCurrentValue, mLastErrorComponentCurrentValue ) )
148 - {
120 + private String getCurrentValueErrorText( Object pComponentCurrentValue ) {
121 + if ( !Objects.areNonArraysEqual( pComponentCurrentValue, mLastErrorComponentCurrentValue ) ) {
149 122 convertComponentValueToSendable( mComponent.getCurrentText() );
150 123 }
151 124 return mLastErrorText;