Subversion Repository Public Repository

litesoft

Diff Revisions 947 vs 948 for /trunk/Java/GWT/Client/src/org/litesoft/GWT/client/widgets/nonpublic/TextBoxBaseChangeListenableHelper.java

Diff revisions: vs.
  @@ -9,58 +9,47 @@
9 9 import com.google.gwt.user.client.ui.*;
10 10
11 11 public class TextBoxBaseChangeListenableHelper implements FocusHandler,
12 - BlurHandler
13 - {
12 + BlurHandler {
14 13 private Timer mTimer = null;
15 14 private String mText = "";
16 15 private TextBoxBase mTextBoxBase;
17 16
18 - public TextBoxBaseChangeListenableHelper( TextBoxBase pTextBoxBase )
19 - {
17 + public TextBoxBaseChangeListenableHelper( TextBoxBase pTextBoxBase ) {
20 18 mTextBoxBase = pTextBoxBase;
21 19 pTextBoxBase.addFocusHandler( this );
22 20 pTextBoxBase.addBlurHandler( this );
23 21 }
24 22
25 - public void setText( String pText )
26 - {
23 + public void setText( String pText ) {
27 24 mText = Strings.deNull( pText );
28 25 }
29 26
30 - private void captureFieldValue()
31 - {
27 + private void captureFieldValue() {
32 28 mText = getCurrentText();
33 29 }
34 30
35 - private boolean textBoxBaseTextChanged()
36 - {
31 + private boolean textBoxBaseTextChanged() {
37 32 String value = getCurrentText();
38 - if ( !mText.equals( value ) )
39 - {
33 + if ( !mText.equals( value ) ) {
40 34 mText = value;
41 35 return true;
42 36 }
43 37 return false;
44 38 }
45 39
46 - private String getCurrentText()
47 - {
40 + private String getCurrentText() {
48 41 return Strings.deNull( mTextBoxBase.getText() );
49 42 }
50 43
51 - private void checkForChange()
52 - {
53 - if ( textBoxBaseTextChanged() )
54 - {
44 + private void checkForChange() {
45 + if ( textBoxBaseTextChanged() ) {
55 46 fireChangeListeners();
56 47 }
57 48 }
58 49
59 50 @Override
60 - public void onBlur( BlurEvent event )
61 - {
62 - if ( mWidgetIsFocused )
63 - {
51 + public void onBlur( BlurEvent event ) {
52 + if ( mWidgetIsFocused ) {
64 53 mWidgetIsFocused = false;
65 54 checkForChange();
66 55 stopTimer();
  @@ -70,32 +59,26 @@
70 59 private boolean mWidgetIsFocused = false;
71 60
72 61 @Override
73 - public void onFocus( FocusEvent event )
74 - {
62 + public void onFocus( FocusEvent event ) {
75 63 mWidgetIsFocused = true;
76 64 captureFieldValue();
77 65 startTimer();
78 66 }
79 67
80 - private void fireChangeListeners()
81 - {
68 + private void fireChangeListeners() {
82 69 NativeEvent zEvent = Document.get().createChangeEvent();
83 70 mTextBoxBase.getElement().dispatchEvent( zEvent );
84 71 }
85 72
86 - public void onDetach()
87 - {
73 + public void onDetach() {
88 74 stopTimer();
89 75 }
90 76
91 - private void startTimer()
92 - {
77 + private void startTimer() {
93 78 stopTimer();
94 - mTimer = new Timer()
95 - {
79 + mTimer = new Timer() {
96 80 @Override
97 - public void run()
98 - {
81 + public void run() {
99 82 checkForChange();
100 83 }
101 84 };
  @@ -103,10 +86,8 @@
103 86 mTimer.scheduleRepeating( 250 );
104 87 }
105 88
106 - private void stopTimer()
107 - {
108 - if ( mTimer != null )
109 - {
89 + private void stopTimer() {
90 + if ( mTimer != null ) {
110 91 mTimer.cancel();
111 92 mTimer = null;
112 93 }