|
@@ -1,247 +1,247 @@ |
1 |
|
- |
// This Source Code is in the Public Domain per: http://unlicense.org |
2 |
|
- |
package org.litesoft.GWT.forms.client.components.nonpublic; |
3 |
|
- |
|
4 |
|
- |
import org.litesoft.GWT.client.widgets.*; |
5 |
|
- |
import org.litesoft.GWT.client.widgets.nonpublic.*; |
6 |
|
- |
import org.litesoft.commonfoundation.typeutils.gregorian.*; |
7 |
|
- |
import org.litesoft.core.*; |
8 |
|
- |
import org.litesoft.core.simpletypes.temporal.*; |
9 |
|
- |
|
10 |
|
- |
import com.google.gwt.user.client.*; |
11 |
|
- |
import com.google.gwt.user.client.ui.*; |
12 |
|
- |
|
13 |
|
- |
public class TimePickerFieldsPanel extends HorizontalPanel { |
14 |
|
- |
private MyTimeField mHrs; |
15 |
|
- |
private MyTimeField mMins = null; |
16 |
|
- |
private MyTimeField mSecs = null; |
17 |
|
- |
private MyTimeField mMilliSecs = null; |
18 |
|
- |
|
19 |
|
- |
public TimePickerFieldsPanel( String pPanelStyle, int pRequiredParts, HigherOrderAdjustable pAdjustable ) { |
20 |
|
- |
addStyleName( pPanelStyle ); |
21 |
|
- |
|
22 |
|
- |
add( mHrs = new MyTimeField( 2, 24, pAdjustable ) ); |
23 |
|
- |
if ( pRequiredParts > 1 ) { |
24 |
|
- |
add( new Label( ":" ) ); |
25 |
|
- |
add( mMins = new MyTimeField( 2, 60, mHrs ) ); |
26 |
|
- |
if ( pRequiredParts > 2 ) { |
27 |
|
- |
add( new Label( ":" ) ); |
28 |
|
- |
add( mSecs = new MyTimeField( 2, 60, mMins ) ); |
29 |
|
- |
if ( pRequiredParts > 3 ) { |
30 |
|
- |
add( new Label( "." ) ); |
31 |
|
- |
add( mMilliSecs = new MyTimeField( 3, 1000, mSecs ) ); |
32 |
|
- |
} |
33 |
|
- |
} |
34 |
|
- |
} |
35 |
|
- |
} |
36 |
|
- |
|
37 |
|
- |
public SimpleTime getSimpleTime() { |
38 |
|
- |
if ( mMilliSecs != null ) { |
39 |
|
- |
return new SimpleTime( mHrs.getIntValue(), mMins.getIntValue(), mSecs.getIntValue(), mMilliSecs.getIntValue() ); |
40 |
|
- |
} |
41 |
|
- |
if ( mSecs != null ) { |
42 |
|
- |
return new SimpleTime( mHrs.getIntValue(), mMins.getIntValue(), mSecs.getIntValue() ); |
43 |
|
- |
} |
44 |
|
- |
if ( mMins != null ) { |
45 |
|
- |
return new SimpleTime( mHrs.getIntValue(), mMins.getIntValue() ); |
46 |
|
- |
} |
47 |
|
- |
return new SimpleTime( mHrs.getIntValue() ); |
48 |
|
- |
} |
49 |
|
- |
|
50 |
|
- |
public void setTimeFields( UtilDateAdaptor pTime ) { |
51 |
|
- |
mHrs.setIntValue( pTime.getHour() ); |
52 |
|
- |
if ( mMins != null ) { |
53 |
|
- |
mMins.setIntValue( pTime.getMin() ); |
54 |
|
- |
if ( mSecs != null ) { |
55 |
|
- |
mSecs.setIntValue( pTime.getSec() ); |
56 |
|
- |
if ( mMilliSecs != null ) { |
57 |
|
- |
mMilliSecs.setIntValue( pTime.getMilliSec() ); |
58 |
|
- |
} |
59 |
|
- |
} |
60 |
|
- |
} |
61 |
|
- |
} |
62 |
|
- |
|
63 |
|
- |
private static class MyTimeField extends Composite implements HigherOrderAdjustable { |
64 |
|
- |
private MyTextBox zField; |
65 |
|
- |
private int mUpperLimit; |
66 |
|
- |
private HigherOrderAdjustable mHigherPart; |
67 |
|
- |
|
68 |
|
- |
public MyTimeField( int pDigits, int pUpperLimit, HigherOrderAdjustable pHigherPart ) { |
69 |
|
- |
mHigherPart = (pHigherPart != null) ? pHigherPart : HigherOrderAdjustable.NULL; |
70 |
|
- |
mUpperLimit = (pUpperLimit > 0) ? pUpperLimit : 0; |
71 |
|
- |
|
72 |
|
- |
HorizontalPanel zHpanel = new HorizontalPanel(); |
73 |
|
- |
|
74 |
|
- |
int zUniqueID = StaticSimpleIdSource.getNext(); |
75 |
|
- |
|
76 |
|
- |
String upCellId = "upId" + zUniqueID; |
77 |
|
- |
String downCellId = "downId" + zUniqueID; |
78 |
|
- |
HTMLPanel zButtonsPanel = new HTMLPanel( |
79 |
|
- |
"<div class='litesoft-TimeFieldUpArrowImageButton_border'><div class='litesoft-TimeFieldUpArrowImageButton' id=" + upCellId + |
80 |
|
- |
"></div></div><div class='litesoft-TimeFieldUpArrowImageButton_border'><div class='litesoft-TimeFieldUpArrowImageButton' id=" + downCellId + |
81 |
|
- |
"></div></div>" ); |
82 |
|
- |
|
83 |
|
- |
zButtonsPanel.add( new UpDownButton( 1 ), upCellId ); |
84 |
|
- |
zButtonsPanel.add( new UpDownButton( -1 ), downCellId ); |
85 |
|
- |
|
86 |
|
- |
zHpanel.add( zField = new MyTextBox( pDigits ) ); |
87 |
|
- |
zHpanel.add( zButtonsPanel ); |
88 |
|
- |
|
89 |
|
- |
initWidget( zHpanel ); |
90 |
|
- |
} |
91 |
|
- |
|
92 |
|
- |
public int getIntValue() { |
93 |
|
- |
return zField.getIntValue(); |
94 |
|
- |
} |
95 |
|
- |
|
96 |
|
- |
public void setIntValue( int pValue ) { |
97 |
|
- |
zField.setIntValue( pValue ); |
98 |
|
- |
} |
99 |
|
- |
|
100 |
|
- |
@Override |
101 |
|
- |
public void adjustValue( int pAdjustBy ) { |
102 |
|
- |
int tmp = getIntValue() + pAdjustBy; |
103 |
|
- |
while ( tmp < 0 ) { |
104 |
|
- |
tmp += mUpperLimit; |
105 |
|
- |
if ( mHigherPart != null ) { |
106 |
|
- |
mHigherPart.adjustValue( -1 ); |
107 |
|
- |
} |
108 |
|
- |
} |
109 |
|
- |
while ( mUpperLimit <= tmp ) { |
110 |
|
- |
tmp -= mUpperLimit; |
111 |
|
- |
if ( mHigherPart != null ) { |
112 |
|
- |
mHigherPart.adjustValue( 1 ); |
113 |
|
- |
} |
114 |
|
- |
} |
115 |
|
- |
setIntValue( tmp ); |
116 |
|
- |
} |
117 |
|
- |
|
118 |
|
- |
private class UpDownButton extends TransparentImage implements MouseListener { |
119 |
|
- |
private int mAdjustBy; |
120 |
|
- |
private String mTimeFieldArrowImageButton_over, mTimeFieldArrowImageButton_border_over, // |
121 |
|
- |
mTimeFieldArrowImageButton, mTimeFieldArrowImageButton_border; |
122 |
|
- |
|
123 |
|
- |
public UpDownButton( int pAdjustBy ) { |
124 |
|
- |
mAdjustBy = pAdjustBy; |
125 |
|
- |
String zBaseStyle; |
126 |
|
- |
if ( mAdjustBy < 0 ) { |
127 |
|
- |
zBaseStyle = "litesoft-TimeFieldDownArrowImage"; |
128 |
|
- |
mTimeFieldArrowImageButton_over = "litesoft-TimeFieldDownArrowImageButton-over"; |
129 |
|
- |
mTimeFieldArrowImageButton_border_over = "litesoft-TimeFieldDownArrowImageButton_border-over"; |
130 |
|
- |
mTimeFieldArrowImageButton = "litesoft-TimeFieldDownArrowImageButton"; |
131 |
|
- |
mTimeFieldArrowImageButton_border = "litesoft-TimeFieldDownArrowImageButton_border"; |
132 |
|
- |
} else { |
133 |
|
- |
zBaseStyle = "litesoft-TimeFieldUpArrowImage"; |
134 |
|
- |
mTimeFieldArrowImageButton_over = "litesoft-TimeFieldUpArrowImageButton-over"; |
135 |
|
- |
mTimeFieldArrowImageButton_border_over = "litesoft-TimeFieldUpArrowImageButton_border-over"; |
136 |
|
- |
mTimeFieldArrowImageButton = "litesoft-TimeFieldUpArrowImageButton"; |
137 |
|
- |
mTimeFieldArrowImageButton_border = "litesoft-TimeFieldUpArrowImageButton_border"; |
138 |
|
- |
} |
139 |
|
- |
setStyleName( zBaseStyle ); |
140 |
|
- |
setWidth( "11" ); |
141 |
|
- |
setHeight( "6" ); |
142 |
|
- |
addMouseListener( this ); |
143 |
|
- |
} |
144 |
|
- |
|
145 |
|
- |
@Override |
146 |
|
- |
public void onMouseDown( Widget sender, int x, int y ) { |
147 |
|
- |
Element innerBorderBox = DOM.getParent( getElement() ); |
148 |
|
- |
Element outerBorderBox = DOM.getParent( innerBorderBox ); |
149 |
|
- |
|
150 |
|
- |
CommonElementHelper.setStyleClass( innerBorderBox, mTimeFieldArrowImageButton_over ); |
151 |
|
- |
CommonElementHelper.setStyleClass( outerBorderBox, mTimeFieldArrowImageButton_border_over ); |
152 |
|
- |
|
153 |
|
- |
adjustValue( mAdjustBy ); |
154 |
|
- |
startTimer(); |
155 |
|
- |
} |
156 |
|
- |
|
157 |
|
- |
@Override |
158 |
|
- |
public void onMouseEnter( Widget sender ) { |
159 |
|
- |
} |
160 |
|
- |
|
161 |
|
- |
@Override |
162 |
|
- |
public void onMouseLeave( Widget sender ) { |
163 |
|
- |
} |
164 |
|
- |
|
165 |
|
- |
@Override |
166 |
|
- |
public void onMouseMove( Widget sender, int x, int y ) { |
167 |
|
- |
} |
168 |
|
- |
|
169 |
|
- |
@Override |
170 |
|
- |
public void onMouseUp( Widget sender, int x, int y ) { |
171 |
|
- |
Element innerBorderBox = DOM.getParent( getElement() ); |
172 |
|
- |
Element outerBorderBox = DOM.getParent( innerBorderBox ); |
173 |
|
- |
|
174 |
|
- |
CommonElementHelper.setStyleClass( innerBorderBox, mTimeFieldArrowImageButton ); |
175 |
|
- |
CommonElementHelper.setStyleClass( outerBorderBox, mTimeFieldArrowImageButton_border ); |
176 |
|
- |
|
177 |
|
- |
stopTimer(); |
178 |
|
- |
} |
179 |
|
- |
|
180 |
|
- |
@Override |
181 |
|
- |
protected void onDetach() { |
182 |
|
- |
stopTimer(); |
183 |
|
- |
super.onDetach(); |
184 |
|
- |
} |
185 |
|
- |
|
186 |
|
- |
private MyTimer mTimer = null; |
187 |
|
- |
|
188 |
|
- |
private void startTimer() { |
189 |
|
- |
if ( mTimer == null ) { |
190 |
|
- |
mTimer = new MyTimer(); |
191 |
|
- |
} |
192 |
|
- |
mTimer.init(); |
193 |
|
- |
} |
194 |
|
- |
|
195 |
|
- |
private void stopTimer() { |
196 |
|
- |
if ( mTimer != null ) { |
197 |
|
- |
mTimer.cancel(); |
198 |
|
- |
} |
199 |
|
- |
} |
200 |
|
- |
|
201 |
|
- |
private class MyTimer extends Timer { |
202 |
|
- |
public static final int MIN_DELAY = 25; |
203 |
|
- |
public static final int DELAY_ADJUST = 10; |
204 |
|
- |
|
205 |
|
- |
private int mDelay; |
206 |
|
- |
|
207 |
|
- |
public void init() { |
208 |
|
- |
schedule( mDelay = 200 ); |
209 |
|
- |
} |
210 |
|
- |
|
211 |
|
- |
@Override |
212 |
|
- |
public void run() { |
213 |
|
- |
adjustValue( mAdjustBy ); |
214 |
|
- |
if ( (mDelay -= DELAY_ADJUST) < MIN_DELAY ) { |
215 |
|
- |
mDelay = MIN_DELAY; |
216 |
|
- |
} |
217 |
|
- |
schedule( mDelay ); |
218 |
|
- |
} |
219 |
|
- |
} |
220 |
|
- |
} |
221 |
|
- |
} |
222 |
|
- |
|
223 |
|
- |
private static class MyTextBox extends TextBox { |
224 |
|
- |
private int mDigits; |
225 |
|
- |
|
226 |
|
- |
public MyTextBox( int pDigits ) { |
227 |
|
- |
mDigits = pDigits; |
228 |
|
- |
setWidth( mDigits + "em" ); |
229 |
|
- |
setEnabled( false ); |
230 |
|
- |
//noinspection GWTStyleCheck |
231 |
|
- |
addStyleName( "litesoft-TimeField" ); |
232 |
|
- |
setIntValue( 0 ); |
233 |
|
- |
} |
234 |
|
- |
|
235 |
|
- |
public int getIntValue() { |
236 |
|
- |
return Integer.parseInt( getText() ); |
237 |
|
- |
} |
238 |
|
- |
|
239 |
|
- |
public void setIntValue( int pValue ) { |
240 |
|
- |
String zText = Integer.toString( pValue ); |
241 |
|
- |
while ( mDigits > zText.length() ) { |
242 |
|
- |
zText = "0" + zText; |
243 |
|
- |
} |
244 |
|
- |
setText( zText ); |
245 |
|
- |
} |
246 |
|
- |
} |
247 |
|
- |
} |
|
1 |
+ |
// This Source Code is in the Public Domain per: http://unlicense.org |
|
2 |
+ |
package org.litesoft.GWT.forms.client.components.nonpublic; |
|
3 |
+ |
|
|
4 |
+ |
import org.litesoft.GWT.client.widgets.*; |
|
5 |
+ |
import org.litesoft.GWT.client.widgets.nonpublic.*; |
|
6 |
+ |
import org.litesoft.commonfoundation.typeutils.gregorian.*; |
|
7 |
+ |
import org.litesoft.core.*; |
|
8 |
+ |
import org.litesoft.core.simpletypes.temporal.*; |
|
9 |
+ |
|
|
10 |
+ |
import com.google.gwt.user.client.*; |
|
11 |
+ |
import com.google.gwt.user.client.ui.*; |
|
12 |
+ |
|
|
13 |
+ |
public class TimePickerFieldsPanel extends HorizontalPanel { |
|
14 |
+ |
private MyTimeField mHrs; |
|
15 |
+ |
private MyTimeField mMins = null; |
|
16 |
+ |
private MyTimeField mSecs = null; |
|
17 |
+ |
private MyTimeField mMilliSecs = null; |
|
18 |
+ |
|
|
19 |
+ |
public TimePickerFieldsPanel( String pPanelStyle, int pRequiredParts, HigherOrderAdjustable pAdjustable ) { |
|
20 |
+ |
addStyleName( pPanelStyle ); |
|
21 |
+ |
|
|
22 |
+ |
add( mHrs = new MyTimeField( 2, 24, pAdjustable ) ); |
|
23 |
+ |
if ( pRequiredParts > 1 ) { |
|
24 |
+ |
add( new Label( ":" ) ); |
|
25 |
+ |
add( mMins = new MyTimeField( 2, 60, mHrs ) ); |
|
26 |
+ |
if ( pRequiredParts > 2 ) { |
|
27 |
+ |
add( new Label( ":" ) ); |
|
28 |
+ |
add( mSecs = new MyTimeField( 2, 60, mMins ) ); |
|
29 |
+ |
if ( pRequiredParts > 3 ) { |
|
30 |
+ |
add( new Label( "." ) ); |
|
31 |
+ |
add( mMilliSecs = new MyTimeField( 3, 1000, mSecs ) ); |
|
32 |
+ |
} |
|
33 |
+ |
} |
|
34 |
+ |
} |
|
35 |
+ |
} |
|
36 |
+ |
|
|
37 |
+ |
public SimpleTime getSimpleTime() { |
|
38 |
+ |
if ( mMilliSecs != null ) { |
|
39 |
+ |
return new SimpleTime( mHrs.getIntValue(), mMins.getIntValue(), mSecs.getIntValue(), mMilliSecs.getIntValue() ); |
|
40 |
+ |
} |
|
41 |
+ |
if ( mSecs != null ) { |
|
42 |
+ |
return new SimpleTime( mHrs.getIntValue(), mMins.getIntValue(), mSecs.getIntValue() ); |
|
43 |
+ |
} |
|
44 |
+ |
if ( mMins != null ) { |
|
45 |
+ |
return new SimpleTime( mHrs.getIntValue(), mMins.getIntValue() ); |
|
46 |
+ |
} |
|
47 |
+ |
return new SimpleTime( mHrs.getIntValue() ); |
|
48 |
+ |
} |
|
49 |
+ |
|
|
50 |
+ |
public void setTimeFields( UtilDateAdaptor pTime ) { |
|
51 |
+ |
mHrs.setIntValue( pTime.getHour() ); |
|
52 |
+ |
if ( mMins != null ) { |
|
53 |
+ |
mMins.setIntValue( pTime.getMin() ); |
|
54 |
+ |
if ( mSecs != null ) { |
|
55 |
+ |
mSecs.setIntValue( pTime.getSec() ); |
|
56 |
+ |
if ( mMilliSecs != null ) { |
|
57 |
+ |
mMilliSecs.setIntValue( pTime.getMilliSec() ); |
|
58 |
+ |
} |
|
59 |
+ |
} |
|
60 |
+ |
} |
|
61 |
+ |
} |
|
62 |
+ |
|
|
63 |
+ |
private static class MyTimeField extends Composite implements HigherOrderAdjustable { |
|
64 |
+ |
private MyTextBox zField; |
|
65 |
+ |
private int mUpperLimit; |
|
66 |
+ |
private HigherOrderAdjustable mHigherPart; |
|
67 |
+ |
|
|
68 |
+ |
public MyTimeField( int pDigits, int pUpperLimit, HigherOrderAdjustable pHigherPart ) { |
|
69 |
+ |
mHigherPart = (pHigherPart != null) ? pHigherPart : HigherOrderAdjustable.NULL; |
|
70 |
+ |
mUpperLimit = (pUpperLimit > 0) ? pUpperLimit : 0; |
|
71 |
+ |
|
|
72 |
+ |
HorizontalPanel zHpanel = new HorizontalPanel(); |
|
73 |
+ |
|
|
74 |
+ |
int zUniqueID = StaticSimpleIdSource.getNext(); |
|
75 |
+ |
|
|
76 |
+ |
String upCellId = "upId" + zUniqueID; |
|
77 |
+ |
String downCellId = "downId" + zUniqueID; |
|
78 |
+ |
HTMLPanel zButtonsPanel = new HTMLPanel( |
|
79 |
+ |
"<div class='litesoft-TimeFieldUpArrowImageButton_border'><div class='litesoft-TimeFieldUpArrowImageButton' id=" + upCellId + |
|
80 |
+ |
"></div></div><div class='litesoft-TimeFieldUpArrowImageButton_border'><div class='litesoft-TimeFieldUpArrowImageButton' id=" + downCellId + |
|
81 |
+ |
"></div></div>" ); |
|
82 |
+ |
|
|
83 |
+ |
zButtonsPanel.add( new UpDownButton( 1 ), upCellId ); |
|
84 |
+ |
zButtonsPanel.add( new UpDownButton( -1 ), downCellId ); |
|
85 |
+ |
|
|
86 |
+ |
zHpanel.add( zField = new MyTextBox( pDigits ) ); |
|
87 |
+ |
zHpanel.add( zButtonsPanel ); |
|
88 |
+ |
|
|
89 |
+ |
initWidget( zHpanel ); |
|
90 |
+ |
} |
|
91 |
+ |
|
|
92 |
+ |
public int getIntValue() { |
|
93 |
+ |
return zField.getIntValue(); |
|
94 |
+ |
} |
|
95 |
+ |
|
|
96 |
+ |
public void setIntValue( int pValue ) { |
|
97 |
+ |
zField.setIntValue( pValue ); |
|
98 |
+ |
} |
|
99 |
+ |
|
|
100 |
+ |
@Override |
|
101 |
+ |
public void adjustValue( int pAdjustBy ) { |
|
102 |
+ |
int tmp = getIntValue() + pAdjustBy; |
|
103 |
+ |
while ( tmp < 0 ) { |
|
104 |
+ |
tmp += mUpperLimit; |
|
105 |
+ |
if ( mHigherPart != null ) { |
|
106 |
+ |
mHigherPart.adjustValue( -1 ); |
|
107 |
+ |
} |
|
108 |
+ |
} |
|
109 |
+ |
while ( mUpperLimit <= tmp ) { |
|
110 |
+ |
tmp -= mUpperLimit; |
|
111 |
+ |
if ( mHigherPart != null ) { |
|
112 |
+ |
mHigherPart.adjustValue( 1 ); |
|
113 |
+ |
} |
|
114 |
+ |
} |
|
115 |
+ |
setIntValue( tmp ); |
|
116 |
+ |
} |
|
117 |
+ |
|
|
118 |
+ |
private class UpDownButton extends TransparentImage implements MouseListener { |
|
119 |
+ |
private int mAdjustBy; |
|
120 |
+ |
private String mTimeFieldArrowImageButton_over, mTimeFieldArrowImageButton_border_over, // |
|
121 |
+ |
mTimeFieldArrowImageButton, mTimeFieldArrowImageButton_border; |
|
122 |
+ |
|
|
123 |
+ |
public UpDownButton( int pAdjustBy ) { |
|
124 |
+ |
mAdjustBy = pAdjustBy; |
|
125 |
+ |
String zBaseStyle; |
|
126 |
+ |
if ( mAdjustBy < 0 ) { |
|
127 |
+ |
zBaseStyle = "litesoft-TimeFieldDownArrowImage"; |
|
128 |
+ |
mTimeFieldArrowImageButton_over = "litesoft-TimeFieldDownArrowImageButton-over"; |
|
129 |
+ |
mTimeFieldArrowImageButton_border_over = "litesoft-TimeFieldDownArrowImageButton_border-over"; |
|
130 |
+ |
mTimeFieldArrowImageButton = "litesoft-TimeFieldDownArrowImageButton"; |
|
131 |
+ |
mTimeFieldArrowImageButton_border = "litesoft-TimeFieldDownArrowImageButton_border"; |
|
132 |
+ |
} else { |
|
133 |
+ |
zBaseStyle = "litesoft-TimeFieldUpArrowImage"; |
|
134 |
+ |
mTimeFieldArrowImageButton_over = "litesoft-TimeFieldUpArrowImageButton-over"; |
|
135 |
+ |
mTimeFieldArrowImageButton_border_over = "litesoft-TimeFieldUpArrowImageButton_border-over"; |
|
136 |
+ |
mTimeFieldArrowImageButton = "litesoft-TimeFieldUpArrowImageButton"; |
|
137 |
+ |
mTimeFieldArrowImageButton_border = "litesoft-TimeFieldUpArrowImageButton_border"; |
|
138 |
+ |
} |
|
139 |
+ |
setStyleName( zBaseStyle ); |
|
140 |
+ |
setWidth( "11" ); |
|
141 |
+ |
setHeight( "6" ); |
|
142 |
+ |
addMouseListener( this ); |
|
143 |
+ |
} |
|
144 |
+ |
|
|
145 |
+ |
@Override |
|
146 |
+ |
public void onMouseDown( Widget sender, int x, int y ) { |
|
147 |
+ |
Element innerBorderBox = DOM.getParent( getElement() ); |
|
148 |
+ |
Element outerBorderBox = DOM.getParent( innerBorderBox ); |
|
149 |
+ |
|
|
150 |
+ |
CommonElementHelper.setStyleClass( innerBorderBox, mTimeFieldArrowImageButton_over ); |
|
151 |
+ |
CommonElementHelper.setStyleClass( outerBorderBox, mTimeFieldArrowImageButton_border_over ); |
|
152 |
+ |
|
|
153 |
+ |
adjustValue( mAdjustBy ); |
|
154 |
+ |
startTimer(); |
|
155 |
+ |
} |
|
156 |
+ |
|
|
157 |
+ |
@Override |
|
158 |
+ |
public void onMouseEnter( Widget sender ) { |
|
159 |
+ |
} |
|
160 |
+ |
|
|
161 |
+ |
@Override |
|
162 |
+ |
public void onMouseLeave( Widget sender ) { |
|
163 |
+ |
} |
|
164 |
+ |
|
|
165 |
+ |
@Override |
|
166 |
+ |
public void onMouseMove( Widget sender, int x, int y ) { |
|
167 |
+ |
} |
|
168 |
+ |
|
|
169 |
+ |
@Override |
|
170 |
+ |
public void onMouseUp( Widget sender, int x, int y ) { |
|
171 |
+ |
Element innerBorderBox = DOM.getParent( getElement() ); |
|
172 |
+ |
Element outerBorderBox = DOM.getParent( innerBorderBox ); |
|
173 |
+ |
|
|
174 |
+ |
CommonElementHelper.setStyleClass( innerBorderBox, mTimeFieldArrowImageButton ); |
|
175 |
+ |
CommonElementHelper.setStyleClass( outerBorderBox, mTimeFieldArrowImageButton_border ); |
|
176 |
+ |
|
|
177 |
+ |
stopTimer(); |
|
178 |
+ |
} |
|
179 |
+ |
|
|
180 |
+ |
@Override |
|
181 |
+ |
protected void onDetach() { |
|
182 |
+ |
stopTimer(); |
|
183 |
+ |
super.onDetach(); |
|
184 |
+ |
} |
|
185 |
+ |
|
|
186 |
+ |
private MyTimer mTimer = null; |
|
187 |
+ |
|
|
188 |
+ |
private void startTimer() { |
|
189 |
+ |
if ( mTimer == null ) { |
|
190 |
+ |
mTimer = new MyTimer(); |
|
191 |
+ |
} |
|
192 |
+ |
mTimer.init(); |
|
193 |
+ |
} |
|
194 |
+ |
|
|
195 |
+ |
private void stopTimer() { |
|
196 |
+ |
if ( mTimer != null ) { |
|
197 |
+ |
mTimer.cancel(); |
|
198 |
+ |
} |
|
199 |
+ |
} |
|
200 |
+ |
|
|
201 |
+ |
private class MyTimer extends Timer { |
|
202 |
+ |
public static final int MIN_DELAY = 25; |
|
203 |
+ |
public static final int DELAY_ADJUST = 10; |
|
204 |
+ |
|
|
205 |
+ |
private int mDelay; |
|
206 |
+ |
|
|
207 |
+ |
public void init() { |
|
208 |
+ |
schedule( mDelay = 200 ); |
|
209 |
+ |
} |
|
210 |
+ |
|
|
211 |
+ |
@Override |
|
212 |
+ |
public void run() { |
|
213 |
+ |
adjustValue( mAdjustBy ); |
|
214 |
+ |
if ( (mDelay -= DELAY_ADJUST) < MIN_DELAY ) { |
|
215 |
+ |
mDelay = MIN_DELAY; |
|
216 |
+ |
} |
|
217 |
+ |
schedule( mDelay ); |
|
218 |
+ |
} |
|
219 |
+ |
} |
|
220 |
+ |
} |
|
221 |
+ |
} |
|
222 |
+ |
|
|
223 |
+ |
private static class MyTextBox extends TextBox { |
|
224 |
+ |
private int mDigits; |
|
225 |
+ |
|
|
226 |
+ |
public MyTextBox( int pDigits ) { |
|
227 |
+ |
mDigits = pDigits; |
|
228 |
+ |
setWidth( mDigits + "em" ); |
|
229 |
+ |
setEnabled( false ); |
|
230 |
+ |
//noinspection GWTStyleCheck |
|
231 |
+ |
addStyleName( "litesoft-TimeField" ); |
|
232 |
+ |
setIntValue( 0 ); |
|
233 |
+ |
} |
|
234 |
+ |
|
|
235 |
+ |
public int getIntValue() { |
|
236 |
+ |
return Integer.parseInt( getText() ); |
|
237 |
+ |
} |
|
238 |
+ |
|
|
239 |
+ |
public void setIntValue( int pValue ) { |
|
240 |
+ |
String zText = Integer.toString( pValue ); |
|
241 |
+ |
while ( mDigits > zText.length() ) { |
|
242 |
+ |
zText = "0" + zText; |
|
243 |
+ |
} |
|
244 |
+ |
setText( zText ); |
|
245 |
+ |
} |
|
246 |
+ |
} |
|
247 |
+ |
} |