Subversion Repository Public Repository

litesoft

Diff Revisions 947 vs 948 for /trunk/Java/GWT/OldServer/src/org/litesoft/GWT/forms/server/support/CreateAMDParamsPlus.java

Diff revisions: vs.
  @@ -9,8 +9,7 @@
9 9 import org.litesoft.ui_1_5.def.*;
10 10 import org.litesoft.util.*;
11 11
12 - public class CreateAMDParamsPlus extends CreateAMDParams
13 - {
12 + public class CreateAMDParamsPlus extends CreateAMDParams {
14 13 public static final Configuration.CachedConfigInt DEFAULT_SHORT_DISPLAY_CHARS_WIDTH = //
15 14 new Configuration.CachedConfigInt( "DefaultShortDisplayCharsWidth", 3 );
16 15
  @@ -59,16 +58,14 @@
59 58
60 59 protected void apply( HintManager pAttributeHintManager, //
61 60 boolean pRequired, boolean pDisabled, boolean pHide, //
62 - Integer pMaxChars, Integer pDisplayLines, Integer pDisplayCharsWidth )
63 - {
61 + Integer pMaxChars, Integer pDisplayLines, Integer pDisplayCharsWidth ) {
64 62 mHintManager = HintController.getGlobalHintManager().addAll( pAttributeHintManager ).addAll(
65 63 getUsage().getHints() );
66 64
67 65 mRequired = mergeRequired( pRequired, getUsage().getRequired() );
68 66 mDisabled = pDisabled || getUsage().shouldComponentBeDisabled();
69 67 mHide = pHide || getUsage().shouldDataBeHiden();
70 - switch ( getField() )
71 - {
68 + switch ( getField() ) {
72 69 default:
73 70 case ViewHide:
74 71 mHide = true;
  @@ -84,37 +81,32 @@
84 81 }
85 82
86 83 mMaxChars = pMaxChars;
87 - if ( (mMaxChars != null) && (mMaxChars < 1) )
88 - {
84 + if ( (mMaxChars != null) && (mMaxChars < 1) ) {
89 85 mMaxChars = null;
90 86 }
91 87
92 88 mDisplayLines = pDisplayLines;
93 89
94 - if ( (mDisplayCharsWidth != null) && (mDisplayCharsWidth < 1) )
95 - {
90 + if ( (mDisplayCharsWidth != null) && (mDisplayCharsWidth < 1) ) {
96 91 mDisplayCharsWidth = null;
97 92 }
98 93 mDisplayCharsWidth = pDisplayCharsWidth;
99 94 }
100 95
101 - protected boolean mergeRequired( boolean pServiceSaysRequired, Boolean pUsageSaysRequired )
102 - {
96 + protected boolean mergeRequired( boolean pServiceSaysRequired, Boolean pUsageSaysRequired ) {
103 97 return (pUsageSaysRequired == null) ? pServiceSaysRequired : pUsageSaysRequired;
104 98 }
105 99
106 100 public CreateAMDParamsPlus( CreateAMDParams pParams, HintManager pAttributeHintManager, //
107 101 boolean pRequired, boolean pDisabled, boolean pHide, //
108 - Integer pMaxChars, Integer pDisplayLines, Integer pDisplayCharsWidth )
109 - {
102 + Integer pMaxChars, Integer pDisplayLines, Integer pDisplayCharsWidth ) {
110 103 super( pParams );
111 104 apply( pAttributeHintManager, //
112 105 pRequired, pDisabled, pHide, //
113 106 pMaxChars, pDisplayLines, pDisplayCharsWidth );
114 107 }
115 108
116 - public CreateAMDParamsPlus( CreateAMDParams pParams, AttributeAccessorSCD pSCD )
117 - {
109 + public CreateAMDParamsPlus( CreateAMDParams pParams, AttributeAccessorSCD pSCD ) {
118 110 super( pParams );
119 111 // todo: translate:
120 112 // apply( pSCD.getHintManager(), //
  @@ -126,125 +118,100 @@
126 118 // pSCD.getIntegerProperty( AttributeAccessorSCD.DISPLAY_COLUMNS_PROPERTY ) );
127 119 }
128 120
129 - public boolean isRequired()
130 - {
121 + public boolean isRequired() {
131 122 return mRequired;
132 123 }
133 124
134 - public boolean isDisabled()
135 - {
125 + public boolean isDisabled() {
136 126 return mDisabled;
137 127 }
138 128
139 - public boolean isHide()
140 - {
129 + public boolean isHide() {
141 130 return mHide;
142 131 }
143 132
144 - public Hintable.Hint[] getHints()
145 - {
133 + public Hintable.Hint[] getHints() {
146 134 return mHintManager.getHints();
147 135 }
148 136
149 - public String getHintValue( String pName )
150 - {
137 + public String getHintValue( String pName ) {
151 138 return mHintManager.getHintValue( pName );
152 139 }
153 140
154 - public String getHintValue( String pName, String pDefaultIfNullOrEmpty )
155 - {
141 + public String getHintValue( String pName, String pDefaultIfNullOrEmpty ) {
156 142 return mHintManager.getHintValue( pName, pDefaultIfNullOrEmpty );
157 143 }
158 144
159 - public boolean isEditRequired()
160 - {
145 + public boolean isEditRequired() {
161 146 return isRequired() && getUsage().getIntendedUse().isEdit();
162 147 }
163 148
164 - public String resolveAction( String pActionID )
165 - {
149 + public String resolveAction( String pActionID ) {
166 150 return mExternalization.resolveAction( pActionID );
167 151 }
168 152
169 - public String getErrorTextForRequired()
170 - {
153 + public String getErrorTextForRequired() {
171 154 return isRequired() ? error( FormServicePeer.IS_REQUIRED_ERROR_KEY, getFieldLabel() ) : null;
172 155 }
173 156
174 - public String error( String pErrorKey, String... pToInject )
175 - {
157 + public String error( String pErrorKey, String... pToInject ) {
176 158 return SimpleMessage.format( mExternalization.resolveError( pErrorKey ), (Object[]) pToInject );
177 159 }
178 160
179 - public Integer getMaxChars()
180 - {
161 + public Integer getMaxChars() {
181 162 return mMaxChars;
182 163 }
183 164
184 - public Integer getDisplayLines()
185 - {
165 + public Integer getDisplayLines() {
186 166 return mDisplayLines;
187 167 }
188 168
189 - public Integer getDisplayCharsWidth()
190 - {
169 + public Integer getDisplayCharsWidth() {
191 170 return mDisplayCharsWidth;
192 171 }
193 172
194 - public boolean shouldBeTextArea()
195 - {
173 + public boolean shouldBeTextArea() {
196 174 return ((mMaxChars == null) || (mMaxChars > MAX_CHARS_FOR_TEXT_FIELD.getInteger()) ||
197 175 UI.Hints.CF_TEXT_AREA.equals( getHintValue( UI.Hints.COMPONENT_FORM ) ));
198 176 }
199 177
200 - public Integer getPasswordDisplayCharsWidth()
201 - {
178 + public Integer getPasswordDisplayCharsWidth() {
202 179 return oneLineHintOveride( DEFAULT_PASSWORD_FIELD_DISPLAY_CHARS_WIDTH );
203 180 }
204 181
205 - public Integer getTextFieldDisplayCharsWidth()
206 - {
182 + public Integer getTextFieldDisplayCharsWidth() {
207 183 return oneLineHintOveride( DEFAULT_TEXT_FIELD_DISPLAY_CHARS_WIDTH );
208 184 }
209 185
210 - public Integer oneLineHintOveride( Configuration.CachedConfigInt pCachedConfigInt )
211 - {
186 + public Integer oneLineHintOveride( Configuration.CachedConfigInt pCachedConfigInt ) {
212 187 Integer width = hintOveride( UI.Hints.TEXT_FIELD_WIDTH, mDisplayCharsWidth );
213 - if ( width == null )
214 - {
188 + if ( width == null ) {
215 189 width = (mMaxChars == null) ? pCachedConfigInt.getInteger() : (mMaxChars + 1);
216 190 }
217 191 return (width <= MAX_DEFAULT_DISPLAY_CHARS_WIDTH_FOR_TEXT_FIELD_BEFORE_FLOODX.getInteger()) ? //
218 192 width : null;
219 193 }
220 194
221 - public Integer getTextAreaInitialDisplayCharsWidth()
222 - {
195 + public Integer getTextAreaInitialDisplayCharsWidth() {
223 196 return hintOveride( UI.Hints.TEXT_AREA_WIDTH, mDisplayLines );
224 197 }
225 198
226 - public Integer getTextAreaInitialDisplayLines()
227 - {
199 + public Integer getTextAreaInitialDisplayLines() {
228 200 return hintOveride( UI.Hints.TEXT_AREA_LINES, mDisplayLines );
229 201 }
230 202
231 - private Integer hintOveride( String pHintName, Integer pCurValue )
232 - {
203 + private Integer hintOveride( String pHintName, Integer pCurValue ) {
233 204 Integer override = getIntegerHint( pHintName );
234 205 return (override != null) ? override : pCurValue;
235 206 }
236 207
237 - public Integer getIntegerHint( String pHintName )
238 - {
208 + public Integer getIntegerHint( String pHintName ) {
239 209 String value = Strings.noEmpty( getHintValue( pHintName ) );
240 - if ( value != null )
241 - {
242 - try
243 - {
210 + if ( value != null ) {
211 + try {
244 212 return Integer.valueOf( value );
245 213 }
246 - catch ( NumberFormatException e )
247 - {
214 + catch ( NumberFormatException e ) {
248 215 System.err.println( "Hint '" + pHintName + "' Not an Integer: " + value );
249 216 }
250 217 }