|
@@ -1,243 +1,243 @@ |
1 |
|
- |
// This Source Code is in the Public Domain per: http://unlicense.org |
2 |
|
- |
package org.litesoft.GWT.forms.client.components.impls.input; |
3 |
|
- |
|
4 |
|
- |
import org.litesoft.GWT.client.*; |
5 |
|
- |
import org.litesoft.GWT.client.widgets.*; |
6 |
|
- |
import org.litesoft.GWT.client.widgets.nonpublic.*; |
7 |
|
- |
import org.litesoft.commonfoundation.base.*; |
8 |
|
- |
import org.litesoft.core.simpletypes.*; |
9 |
|
- |
import org.litesoft.uispecification.*; |
10 |
|
- |
|
11 |
|
- |
import com.google.gwt.core.client.*; |
12 |
|
- |
import com.google.gwt.event.dom.client.*; |
13 |
|
- |
import com.google.gwt.user.client.*; |
14 |
|
- |
import com.google.gwt.user.client.ui.Button; |
15 |
|
- |
import com.google.gwt.user.client.ui.*; |
16 |
|
- |
|
17 |
|
- |
public class FormImageSelectOptions extends FormImageSelector implements ResourceKeyNameURLsAvailableCallback { |
18 |
|
- |
private ResourceKeyNameURLprovider mProvider; |
19 |
|
- |
private SimplePanel mPopupListWrapper; |
20 |
|
- |
private PointXY mPointXY; |
21 |
|
- |
|
22 |
|
- |
public FormImageSelectOptions( String pFieldLabel, UiFont pLabelFont, String pTooltip, boolean pViewOnly, ResourceKeyNameURLprovider pProvider, |
23 |
|
- |
Integer pInitialWidth, boolean pWidthNotStretchable, Integer pInitialHeight, boolean pHeightNotStretchable ) { |
24 |
|
- |
super( pFieldLabel, pLabelFont, pTooltip, pViewOnly, pInitialWidth, pWidthNotStretchable, pInitialHeight, pHeightNotStretchable ); |
25 |
|
- |
mProvider = pProvider; |
26 |
|
- |
mPickerButtonTooltip = "Select Image from List"; |
27 |
|
- |
|
28 |
|
- |
DialogBox zDialogBox = new DialogBox( true ); |
29 |
|
- |
zDialogBox.add( buildPickerPanel() ); |
30 |
|
- |
zDialogBox.setText( mPickerButtonTooltip ); |
31 |
|
- |
mPickerButton.setTitle( mPickerButtonTooltip ); |
32 |
|
- |
Cursor.Pointer.set( mPickerButton ); |
33 |
|
- |
setPicker( zDialogBox ); |
34 |
|
- |
} |
35 |
|
- |
|
36 |
|
- |
@Override |
37 |
|
- |
public Object getCurrentValue() { |
38 |
|
- |
return getCurrentResourceKeyNameURL(); |
39 |
|
- |
} |
40 |
|
- |
|
41 |
|
- |
@Override |
42 |
|
- |
public void setCurrentValue( Object pNewValue ) { |
43 |
|
- |
setCurrentResourceKeyNameURL( (pNewValue instanceof ResourceKeyNameURL) ? (ResourceKeyNameURL) pNewValue : null ); |
44 |
|
- |
} |
45 |
|
- |
|
46 |
|
- |
private Widget buildPickerPanel() { |
47 |
|
- |
VerticalPanel zListPanel = new VerticalPanel(); |
48 |
|
- |
zListPanel.setHorizontalAlignment( HasHorizontalAlignment.ALIGN_CENTER ); |
49 |
|
- |
mPopupListWrapper = new SimplePanel(); |
50 |
|
- |
mPopupListWrapper.setHeight( "200" ); |
51 |
|
- |
Element zElement = mPopupListWrapper.getElement(); |
52 |
|
- |
CommonElementHelper.setOverflowAuto( zElement ); |
53 |
|
- |
DOM.setStyleAttribute( zElement, "borderBottom", "solid 1px black" ); |
54 |
|
- |
|
55 |
|
- |
zListPanel.add( mPopupListWrapper ); |
56 |
|
- |
zListPanel.add( new Spacer( 5 ) ); |
57 |
|
- |
zListPanel.add( buildButtonPanel() ); |
58 |
|
- |
return zListPanel; |
59 |
|
- |
} |
60 |
|
- |
|
61 |
|
- |
private Widget buildButtonPanel() { |
62 |
|
- |
Button zCancel = new Button( "Cancel" ); |
63 |
|
- |
zCancel.addClickHandler( new ClickHandler() { |
64 |
|
- |
@Override |
65 |
|
- |
public void onClick( ClickEvent event ) { |
66 |
|
- |
mPicker.hide(); |
67 |
|
- |
} |
68 |
|
- |
} ); |
69 |
|
- |
|
70 |
|
- |
return zCancel; |
71 |
|
- |
} |
72 |
|
- |
|
73 |
|
- |
private int mSelectedIndx = -1; |
74 |
|
- |
|
75 |
|
- |
@Override |
76 |
|
- |
protected void LLshowPicker( PointXY pPointXY ) { |
77 |
|
- |
switchToLoading(); |
78 |
|
- |
|
79 |
|
- |
mPointXY = pPointXY; |
80 |
|
- |
|
81 |
|
- |
ResourceKeyNameURL[] zURLs = mProvider.getLocalResourceKeyNameURLs(); |
82 |
|
- |
|
83 |
|
- |
if ( zURLs != null ) { |
84 |
|
- |
resourceKeyNameURLsAvailable( zURLs ); |
85 |
|
- |
} else { |
86 |
|
- |
mProvider.requestResourceKeyNameURLs( this ); |
87 |
|
- |
} |
88 |
|
- |
} |
89 |
|
- |
|
90 |
|
- |
@Override |
91 |
|
- |
public void resourceKeyNameURLsAvailable( ResourceKeyNameURL[] pResourceKeyNameURLs ) { |
92 |
|
- |
ListGrid zListGrid = new ListGrid( pResourceKeyNameURLs ); |
93 |
|
- |
zListGrid.clearSelectedRow(); |
94 |
|
- |
HTMLTable.RowFormatter zRowFormatter = zListGrid.getOurRowFormatter(); |
95 |
|
- |
|
96 |
|
- |
if ( mSelectedIndx >= 0 ) { |
97 |
|
- |
zRowFormatter.addStyleName( mSelectedIndx, "ItemRow-Selected" ); |
98 |
|
- |
} |
99 |
|
- |
mPopupListWrapper.setWidget( zListGrid ); |
100 |
|
- |
|
101 |
|
- |
super.LLshowPicker( mPointXY ); |
102 |
|
- |
|
103 |
|
- |
restoreFromLoading(); |
104 |
|
- |
} |
105 |
|
- |
|
106 |
|
- |
@Override |
107 |
|
- |
public void resourceRequestFailed( ResourceOptionsErrorType pErrorType, String pErrorText ) { |
108 |
|
- |
restoreFromLoading(); |
109 |
|
- |
pickerClosed( true ); |
110 |
|
- |
String zNIA = "No Images Available"; |
111 |
|
- |
String zBody = zNIA; |
112 |
|
- |
String zDetail = null; |
113 |
|
- |
if ( pErrorType != null ) { |
114 |
|
- |
switch ( pErrorType ) { |
115 |
|
- |
default: |
116 |
|
- |
case ErrorReferenceNotFound: |
117 |
|
- |
case ErrorNullReturned: |
118 |
|
- |
case ErrorNotResourceOptions: |
119 |
|
- |
case ErrorNotImplemented: |
120 |
|
- |
pErrorText = DeCamelizer.resolve( pErrorType.toString() ); |
121 |
|
- |
// Fall Thru |
122 |
|
- |
case ErrorOther: |
123 |
|
- |
zDetail = pErrorText; |
124 |
|
- |
zBody += "\n\nServer Error"; |
125 |
|
- |
break; |
126 |
|
- |
case NoneAvailable: |
127 |
|
- |
zBody += "\n\nPlease Upload Image(s) to Server"; |
128 |
|
- |
break; |
129 |
|
- |
} |
130 |
|
- |
} |
131 |
|
- |
AlertManager.alert( "FISO", zNIA, zBody, zDetail ); |
132 |
|
- |
} |
133 |
|
- |
|
134 |
|
- |
private String mCurrentTooltip; |
135 |
|
- |
|
136 |
|
- |
private void switchToLoading() { |
137 |
|
- |
mCurrentTooltip = mPickerButtonTooltip; |
138 |
|
- |
mPickerButton.setTitle( "Loading..." ); |
139 |
|
- |
Cursor.Wait.set( mPickerButton ); |
140 |
|
- |
} |
141 |
|
- |
|
142 |
|
- |
private void restoreFromLoading() { |
143 |
|
- |
mPickerButton.setTitle( mCurrentTooltip ); |
144 |
|
- |
Cursor.Pointer.set( mPickerButton ); |
145 |
|
- |
} |
146 |
|
- |
|
147 |
|
- |
private class ListGrid extends TightGrid { |
148 |
|
- |
private ResourceKeyNameURL[] mResources; |
149 |
|
- |
private RowFormatter mRowFormatter; |
150 |
|
- |
private static final String STYLE = "FormSelectorImageRowLabel"; |
151 |
|
- |
|
152 |
|
- |
public ListGrid( ResourceKeyNameURL[] pURLs ) { |
153 |
|
- |
super( pURLs.length, 2 ); |
154 |
|
- |
mResources = pURLs; |
155 |
|
- |
|
156 |
|
- |
for ( int i = 0; i < pURLs.length; i++ ) { |
157 |
|
- |
ResourceKeyNameURL zURL = pURLs[i]; |
158 |
|
- |
|
159 |
|
- |
SizeableDualImage zImage = new SizeableDualImage( zURL.getURL() ); |
160 |
|
- |
zImage.setImageSize( 64, 48 ); |
161 |
|
- |
Label zLabel = new Label( zURL.getValue() ); |
162 |
|
- |
zLabel.addStyleName( STYLE ); |
163 |
|
- |
setWidget( i, 0, zImage ); |
164 |
|
- |
setWidget( i, 1, zLabel ); |
165 |
|
- |
|
166 |
|
- |
mRowFormatter = getRowFormatter(); |
167 |
|
- |
|
168 |
|
- |
if ( i % 2 == 0 ) { |
169 |
|
- |
mRowFormatter.addStyleName( i, "FormSelectorImageItem-reg" ); |
170 |
|
- |
} else { |
171 |
|
- |
mRowFormatter.addStyleName( i, "FormSelectorImageItem-alt" ); |
172 |
|
- |
} |
173 |
|
- |
} |
174 |
|
- |
|
175 |
|
- |
sinkEvents( Event.ONCLICK | Event.ONMOUSEOVER | Event.ONMOUSEOUT ); |
176 |
|
- |
} |
177 |
|
- |
|
178 |
|
- |
public RowFormatter getOurRowFormatter() { |
179 |
|
- |
return mRowFormatter; |
180 |
|
- |
} |
181 |
|
- |
|
182 |
|
- |
private ResourceKeyNameURL getResource( int pIndex ) { |
183 |
|
- |
if ( (pIndex >= 0) && (pIndex <= mResources.length) ) { |
184 |
|
- |
return mResources[pIndex]; |
185 |
|
- |
} else { |
186 |
|
- |
return null; |
187 |
|
- |
} |
188 |
|
- |
} |
189 |
|
- |
|
190 |
|
- |
private void clearSelectedRow() { |
191 |
|
- |
for ( int i = 0; i < getRowCount(); i++ ) { |
192 |
|
- |
String zStyle = mRowFormatter.getStyleName( i ); |
193 |
|
- |
if ( zStyle.contains( "ItemRow-Selected" ) ) { |
194 |
|
- |
mRowFormatter.removeStyleName( i, "ItemRow-Selected" ); |
195 |
|
- |
} |
196 |
|
- |
} |
197 |
|
- |
} |
198 |
|
- |
|
199 |
|
- |
@Override |
200 |
|
- |
public void onBrowserEvent( Event event ) { |
201 |
|
- |
int zIndx = getRowIndexForEvent( event ); |
202 |
|
- |
|
203 |
|
- |
switch ( DOM.eventGetType( event ) ) { |
204 |
|
- |
case Event.ONCLICK: { |
205 |
|
- |
mSelectedIndx = zIndx; |
206 |
|
- |
|
207 |
|
- |
mPicker.hide(); |
208 |
|
- |
mRowFormatter.removeStyleName( zIndx, "ItemRow-Mouseover" ); |
209 |
|
- |
final ResourceKeyNameURL zResource = getResource( zIndx ); |
210 |
|
- |
Scheduler.get().scheduleDeferred( new Command() { |
211 |
|
- |
@Override |
212 |
|
- |
public void execute() { |
213 |
|
- |
setCurrentValue( zResource ); |
214 |
|
- |
} |
215 |
|
- |
} ); |
216 |
|
- |
|
217 |
|
- |
break; |
218 |
|
- |
} |
219 |
|
- |
case Event.ONMOUSEOVER: { |
220 |
|
- |
mRowFormatter.addStyleName( zIndx, "ItemRow-Mouseover" ); |
221 |
|
- |
break; |
222 |
|
- |
} |
223 |
|
- |
case Event.ONMOUSEOUT: { |
224 |
|
- |
mRowFormatter.removeStyleName( zIndx, "ItemRow-Mouseover" ); |
225 |
|
- |
break; |
226 |
|
- |
} |
227 |
|
- |
default: { |
228 |
|
- |
// Do nothing |
229 |
|
- |
} |
230 |
|
- |
} |
231 |
|
- |
} |
232 |
|
- |
|
233 |
|
- |
private int getRowIndexForEvent( Event event ) { |
234 |
|
- |
Element td = getEventTargetCell( event ); |
235 |
|
- |
if ( td == null ) { |
236 |
|
- |
return -1; |
237 |
|
- |
} |
238 |
|
- |
Element tr = DOM.getParent( td ); |
239 |
|
- |
Element body = DOM.getParent( tr ); |
240 |
|
- |
return DOM.getChildIndex( body, tr ); |
241 |
|
- |
} |
242 |
|
- |
} |
243 |
|
- |
} |
|
1 |
+ |
// This Source Code is in the Public Domain per: http://unlicense.org |
|
2 |
+ |
package org.litesoft.GWT.forms.client.components.impls.input; |
|
3 |
+ |
|
|
4 |
+ |
import org.litesoft.GWT.client.*; |
|
5 |
+ |
import org.litesoft.GWT.client.widgets.*; |
|
6 |
+ |
import org.litesoft.GWT.client.widgets.nonpublic.*; |
|
7 |
+ |
import org.litesoft.commonfoundation.base.*; |
|
8 |
+ |
import org.litesoft.core.simpletypes.*; |
|
9 |
+ |
import org.litesoft.uispecification.*; |
|
10 |
+ |
|
|
11 |
+ |
import com.google.gwt.core.client.*; |
|
12 |
+ |
import com.google.gwt.event.dom.client.*; |
|
13 |
+ |
import com.google.gwt.user.client.*; |
|
14 |
+ |
import com.google.gwt.user.client.ui.Button; |
|
15 |
+ |
import com.google.gwt.user.client.ui.*; |
|
16 |
+ |
|
|
17 |
+ |
public class FormImageSelectOptions extends FormImageSelector implements ResourceKeyNameURLsAvailableCallback { |
|
18 |
+ |
private ResourceKeyNameURLprovider mProvider; |
|
19 |
+ |
private SimplePanel mPopupListWrapper; |
|
20 |
+ |
private PointXY mPointXY; |
|
21 |
+ |
|
|
22 |
+ |
public FormImageSelectOptions( String pFieldLabel, UiFont pLabelFont, String pTooltip, boolean pViewOnly, ResourceKeyNameURLprovider pProvider, |
|
23 |
+ |
Integer pInitialWidth, boolean pWidthNotStretchable, Integer pInitialHeight, boolean pHeightNotStretchable ) { |
|
24 |
+ |
super( pFieldLabel, pLabelFont, pTooltip, pViewOnly, pInitialWidth, pWidthNotStretchable, pInitialHeight, pHeightNotStretchable ); |
|
25 |
+ |
mProvider = pProvider; |
|
26 |
+ |
mPickerButtonTooltip = "Select Image from List"; |
|
27 |
+ |
|
|
28 |
+ |
DialogBox zDialogBox = new DialogBox( true ); |
|
29 |
+ |
zDialogBox.add( buildPickerPanel() ); |
|
30 |
+ |
zDialogBox.setText( mPickerButtonTooltip ); |
|
31 |
+ |
mPickerButton.setTitle( mPickerButtonTooltip ); |
|
32 |
+ |
Cursor.Pointer.set( mPickerButton ); |
|
33 |
+ |
setPicker( zDialogBox ); |
|
34 |
+ |
} |
|
35 |
+ |
|
|
36 |
+ |
@Override |
|
37 |
+ |
public Object getCurrentValue() { |
|
38 |
+ |
return getCurrentResourceKeyNameURL(); |
|
39 |
+ |
} |
|
40 |
+ |
|
|
41 |
+ |
@Override |
|
42 |
+ |
public void setCurrentValue( Object pNewValue ) { |
|
43 |
+ |
setCurrentResourceKeyNameURL( (pNewValue instanceof ResourceKeyNameURL) ? (ResourceKeyNameURL) pNewValue : null ); |
|
44 |
+ |
} |
|
45 |
+ |
|
|
46 |
+ |
private Widget buildPickerPanel() { |
|
47 |
+ |
VerticalPanel zListPanel = new VerticalPanel(); |
|
48 |
+ |
zListPanel.setHorizontalAlignment( HasHorizontalAlignment.ALIGN_CENTER ); |
|
49 |
+ |
mPopupListWrapper = new SimplePanel(); |
|
50 |
+ |
mPopupListWrapper.setHeight( "200" ); |
|
51 |
+ |
Element zElement = mPopupListWrapper.getElement(); |
|
52 |
+ |
CommonElementHelper.setOverflowAuto( zElement ); |
|
53 |
+ |
DOM.setStyleAttribute( zElement, "borderBottom", "solid 1px black" ); |
|
54 |
+ |
|
|
55 |
+ |
zListPanel.add( mPopupListWrapper ); |
|
56 |
+ |
zListPanel.add( new Spacer( 5 ) ); |
|
57 |
+ |
zListPanel.add( buildButtonPanel() ); |
|
58 |
+ |
return zListPanel; |
|
59 |
+ |
} |
|
60 |
+ |
|
|
61 |
+ |
private Widget buildButtonPanel() { |
|
62 |
+ |
Button zCancel = new Button( "Cancel" ); |
|
63 |
+ |
zCancel.addClickHandler( new ClickHandler() { |
|
64 |
+ |
@Override |
|
65 |
+ |
public void onClick( ClickEvent event ) { |
|
66 |
+ |
mPicker.hide(); |
|
67 |
+ |
} |
|
68 |
+ |
} ); |
|
69 |
+ |
|
|
70 |
+ |
return zCancel; |
|
71 |
+ |
} |
|
72 |
+ |
|
|
73 |
+ |
private int mSelectedIndx = -1; |
|
74 |
+ |
|
|
75 |
+ |
@Override |
|
76 |
+ |
protected void LLshowPicker( PointXY pPointXY ) { |
|
77 |
+ |
switchToLoading(); |
|
78 |
+ |
|
|
79 |
+ |
mPointXY = pPointXY; |
|
80 |
+ |
|
|
81 |
+ |
ResourceKeyNameURL[] zURLs = mProvider.getLocalResourceKeyNameURLs(); |
|
82 |
+ |
|
|
83 |
+ |
if ( zURLs != null ) { |
|
84 |
+ |
resourceKeyNameURLsAvailable( zURLs ); |
|
85 |
+ |
} else { |
|
86 |
+ |
mProvider.requestResourceKeyNameURLs( this ); |
|
87 |
+ |
} |
|
88 |
+ |
} |
|
89 |
+ |
|
|
90 |
+ |
@Override |
|
91 |
+ |
public void resourceKeyNameURLsAvailable( ResourceKeyNameURL[] pResourceKeyNameURLs ) { |
|
92 |
+ |
ListGrid zListGrid = new ListGrid( pResourceKeyNameURLs ); |
|
93 |
+ |
zListGrid.clearSelectedRow(); |
|
94 |
+ |
HTMLTable.RowFormatter zRowFormatter = zListGrid.getOurRowFormatter(); |
|
95 |
+ |
|
|
96 |
+ |
if ( mSelectedIndx >= 0 ) { |
|
97 |
+ |
zRowFormatter.addStyleName( mSelectedIndx, "ItemRow-Selected" ); |
|
98 |
+ |
} |
|
99 |
+ |
mPopupListWrapper.setWidget( zListGrid ); |
|
100 |
+ |
|
|
101 |
+ |
super.LLshowPicker( mPointXY ); |
|
102 |
+ |
|
|
103 |
+ |
restoreFromLoading(); |
|
104 |
+ |
} |
|
105 |
+ |
|
|
106 |
+ |
@Override |
|
107 |
+ |
public void resourceRequestFailed( ResourceOptionsErrorType pErrorType, String pErrorText ) { |
|
108 |
+ |
restoreFromLoading(); |
|
109 |
+ |
pickerClosed( true ); |
|
110 |
+ |
String zNIA = "No Images Available"; |
|
111 |
+ |
String zBody = zNIA; |
|
112 |
+ |
String zDetail = null; |
|
113 |
+ |
if ( pErrorType != null ) { |
|
114 |
+ |
switch ( pErrorType ) { |
|
115 |
+ |
default: |
|
116 |
+ |
case ErrorReferenceNotFound: |
|
117 |
+ |
case ErrorNullReturned: |
|
118 |
+ |
case ErrorNotResourceOptions: |
|
119 |
+ |
case ErrorNotImplemented: |
|
120 |
+ |
pErrorText = DeCamelizer.resolve( pErrorType.toString() ); |
|
121 |
+ |
// Fall Thru |
|
122 |
+ |
case ErrorOther: |
|
123 |
+ |
zDetail = pErrorText; |
|
124 |
+ |
zBody += "\n\nServer Error"; |
|
125 |
+ |
break; |
|
126 |
+ |
case NoneAvailable: |
|
127 |
+ |
zBody += "\n\nPlease Upload Image(s) to Server"; |
|
128 |
+ |
break; |
|
129 |
+ |
} |
|
130 |
+ |
} |
|
131 |
+ |
AlertManager.alert( "FISO", zNIA, zBody, zDetail ); |
|
132 |
+ |
} |
|
133 |
+ |
|
|
134 |
+ |
private String mCurrentTooltip; |
|
135 |
+ |
|
|
136 |
+ |
private void switchToLoading() { |
|
137 |
+ |
mCurrentTooltip = mPickerButtonTooltip; |
|
138 |
+ |
mPickerButton.setTitle( "Loading..." ); |
|
139 |
+ |
Cursor.Wait.set( mPickerButton ); |
|
140 |
+ |
} |
|
141 |
+ |
|
|
142 |
+ |
private void restoreFromLoading() { |
|
143 |
+ |
mPickerButton.setTitle( mCurrentTooltip ); |
|
144 |
+ |
Cursor.Pointer.set( mPickerButton ); |
|
145 |
+ |
} |
|
146 |
+ |
|
|
147 |
+ |
private class ListGrid extends TightGrid { |
|
148 |
+ |
private ResourceKeyNameURL[] mResources; |
|
149 |
+ |
private RowFormatter mRowFormatter; |
|
150 |
+ |
private static final String STYLE = "FormSelectorImageRowLabel"; |
|
151 |
+ |
|
|
152 |
+ |
public ListGrid( ResourceKeyNameURL[] pURLs ) { |
|
153 |
+ |
super( pURLs.length, 2 ); |
|
154 |
+ |
mResources = pURLs; |
|
155 |
+ |
|
|
156 |
+ |
for ( int i = 0; i < pURLs.length; i++ ) { |
|
157 |
+ |
ResourceKeyNameURL zURL = pURLs[i]; |
|
158 |
+ |
|
|
159 |
+ |
SizeableDualImage zImage = new SizeableDualImage( zURL.getURL() ); |
|
160 |
+ |
zImage.setImageSize( 64, 48 ); |
|
161 |
+ |
Label zLabel = new Label( zURL.getValue() ); |
|
162 |
+ |
zLabel.addStyleName( STYLE ); |
|
163 |
+ |
setWidget( i, 0, zImage ); |
|
164 |
+ |
setWidget( i, 1, zLabel ); |
|
165 |
+ |
|
|
166 |
+ |
mRowFormatter = getRowFormatter(); |
|
167 |
+ |
|
|
168 |
+ |
if ( i % 2 == 0 ) { |
|
169 |
+ |
mRowFormatter.addStyleName( i, "FormSelectorImageItem-reg" ); |
|
170 |
+ |
} else { |
|
171 |
+ |
mRowFormatter.addStyleName( i, "FormSelectorImageItem-alt" ); |
|
172 |
+ |
} |
|
173 |
+ |
} |
|
174 |
+ |
|
|
175 |
+ |
sinkEvents( Event.ONCLICK | Event.ONMOUSEOVER | Event.ONMOUSEOUT ); |
|
176 |
+ |
} |
|
177 |
+ |
|
|
178 |
+ |
public RowFormatter getOurRowFormatter() { |
|
179 |
+ |
return mRowFormatter; |
|
180 |
+ |
} |
|
181 |
+ |
|
|
182 |
+ |
private ResourceKeyNameURL getResource( int pIndex ) { |
|
183 |
+ |
if ( (pIndex >= 0) && (pIndex <= mResources.length) ) { |
|
184 |
+ |
return mResources[pIndex]; |
|
185 |
+ |
} else { |
|
186 |
+ |
return null; |
|
187 |
+ |
} |
|
188 |
+ |
} |
|
189 |
+ |
|
|
190 |
+ |
private void clearSelectedRow() { |
|
191 |
+ |
for ( int i = 0; i < getRowCount(); i++ ) { |
|
192 |
+ |
String zStyle = mRowFormatter.getStyleName( i ); |
|
193 |
+ |
if ( zStyle.contains( "ItemRow-Selected" ) ) { |
|
194 |
+ |
mRowFormatter.removeStyleName( i, "ItemRow-Selected" ); |
|
195 |
+ |
} |
|
196 |
+ |
} |
|
197 |
+ |
} |
|
198 |
+ |
|
|
199 |
+ |
@Override |
|
200 |
+ |
public void onBrowserEvent( Event event ) { |
|
201 |
+ |
int zIndx = getRowIndexForEvent( event ); |
|
202 |
+ |
|
|
203 |
+ |
switch ( DOM.eventGetType( event ) ) { |
|
204 |
+ |
case Event.ONCLICK: { |
|
205 |
+ |
mSelectedIndx = zIndx; |
|
206 |
+ |
|
|
207 |
+ |
mPicker.hide(); |
|
208 |
+ |
mRowFormatter.removeStyleName( zIndx, "ItemRow-Mouseover" ); |
|
209 |
+ |
final ResourceKeyNameURL zResource = getResource( zIndx ); |
|
210 |
+ |
Scheduler.get().scheduleDeferred( new Command() { |
|
211 |
+ |
@Override |
|
212 |
+ |
public void execute() { |
|
213 |
+ |
setCurrentValue( zResource ); |
|
214 |
+ |
} |
|
215 |
+ |
} ); |
|
216 |
+ |
|
|
217 |
+ |
break; |
|
218 |
+ |
} |
|
219 |
+ |
case Event.ONMOUSEOVER: { |
|
220 |
+ |
mRowFormatter.addStyleName( zIndx, "ItemRow-Mouseover" ); |
|
221 |
+ |
break; |
|
222 |
+ |
} |
|
223 |
+ |
case Event.ONMOUSEOUT: { |
|
224 |
+ |
mRowFormatter.removeStyleName( zIndx, "ItemRow-Mouseover" ); |
|
225 |
+ |
break; |
|
226 |
+ |
} |
|
227 |
+ |
default: { |
|
228 |
+ |
// Do nothing |
|
229 |
+ |
} |
|
230 |
+ |
} |
|
231 |
+ |
} |
|
232 |
+ |
|
|
233 |
+ |
private int getRowIndexForEvent( Event event ) { |
|
234 |
+ |
Element td = getEventTargetCell( event ); |
|
235 |
+ |
if ( td == null ) { |
|
236 |
+ |
return -1; |
|
237 |
+ |
} |
|
238 |
+ |
Element tr = DOM.getParent( td ); |
|
239 |
+ |
Element body = DOM.getParent( tr ); |
|
240 |
+ |
return DOM.getChildIndex( body, tr ); |
|
241 |
+ |
} |
|
242 |
+ |
} |
|
243 |
+ |
} |