Mercurial > projects > dwt-win
comparison dwt/custom/CCombo.d @ 244:a59d51c12b42
work on allow null strings and arrays
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Sat, 28 Jun 2008 20:27:21 +0200 |
parents | 36f5cb12e1a2 |
children | fd9c62a2998e |
comparison
equal
deleted
inserted
replaced
243:ecb80b2a89e1 | 244:a59d51c12b42 |
---|---|
190 /** | 190 /** |
191 * Adds the argument to the end of the receiver's list. | 191 * Adds the argument to the end of the receiver's list. |
192 * | 192 * |
193 * @param string the new item | 193 * @param string the new item |
194 * | 194 * |
195 * @exception IllegalArgumentException <ul> | |
196 * <li>ERROR_NULL_ARGUMENT - if the string is null</li> | |
197 * </ul> | |
198 * @exception DWTException <ul> | 195 * @exception DWTException <ul> |
199 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> | 196 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> |
200 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | 197 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> |
201 * </ul> | 198 * </ul> |
202 * | 199 * |
203 * @see #add(String,int) | 200 * @see #add(String,int) |
204 */ | 201 */ |
205 public void add (String string) { | 202 public void add (String string) { |
206 checkWidget(); | 203 checkWidget(); |
207 if (string is null) DWT.error (DWT.ERROR_NULL_ARGUMENT); | 204 // DWT extension: allow null string |
205 //if (string is null) DWT.error (DWT.ERROR_NULL_ARGUMENT); | |
208 list.add (string); | 206 list.add (string); |
209 } | 207 } |
210 /** | 208 /** |
211 * Adds the argument to the receiver's list at the given | 209 * Adds the argument to the receiver's list at the given |
212 * zero-relative index. | 210 * zero-relative index. |
218 * | 216 * |
219 * @param string the new item | 217 * @param string the new item |
220 * @param index the index for the item | 218 * @param index the index for the item |
221 * | 219 * |
222 * @exception IllegalArgumentException <ul> | 220 * @exception IllegalArgumentException <ul> |
223 * <li>ERROR_NULL_ARGUMENT - if the string is null</li> | |
224 * <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list (inclusive)</li> | 221 * <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list (inclusive)</li> |
225 * </ul> | 222 * </ul> |
226 * @exception DWTException <ul> | 223 * @exception DWTException <ul> |
227 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> | 224 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> |
228 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | 225 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> |
230 * | 227 * |
231 * @see #add(String) | 228 * @see #add(String) |
232 */ | 229 */ |
233 public void add (String string, int index) { | 230 public void add (String string, int index) { |
234 checkWidget(); | 231 checkWidget(); |
235 if (string is null) DWT.error (DWT.ERROR_NULL_ARGUMENT); | 232 // DWT extension: allow null string |
233 //if (string is null) DWT.error (DWT.ERROR_NULL_ARGUMENT); | |
236 list.add (string, index); | 234 list.add (string, index); |
237 } | 235 } |
238 /** | 236 /** |
239 * Adds the listener to the collection of listeners who will | 237 * Adds the listener to the collection of listeners who will |
240 * be notified when the receiver's text is modified, by sending | 238 * be notified when the receiver's text is modified, by sending |
867 * is found, returns -1. | 865 * is found, returns -1. |
868 * | 866 * |
869 * @param string the search item | 867 * @param string the search item |
870 * @return the index of the item | 868 * @return the index of the item |
871 * | 869 * |
872 * @exception IllegalArgumentException <ul> | |
873 * <li>ERROR_NULL_ARGUMENT - if the string is null</li> | |
874 * </ul> | |
875 * @exception DWTException <ul> | 870 * @exception DWTException <ul> |
876 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> | 871 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> |
877 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | 872 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> |
878 * </ul> | 873 * </ul> |
879 */ | 874 */ |
880 public int indexOf (String string) { | 875 public int indexOf (String string) { |
881 checkWidget (); | 876 checkWidget (); |
882 if (string is null) DWT.error (DWT.ERROR_NULL_ARGUMENT); | 877 // DWT extension: allow null string |
878 //if (string is null) DWT.error (DWT.ERROR_NULL_ARGUMENT); | |
883 return list.indexOf (string); | 879 return list.indexOf (string); |
884 } | 880 } |
885 /** | 881 /** |
886 * Searches the receiver's list starting at the given, | 882 * Searches the receiver's list starting at the given, |
887 * zero-relative index until an item is found that is equal | 883 * zero-relative index until an item is found that is equal |
891 * | 887 * |
892 * @param string the search item | 888 * @param string the search item |
893 * @param start the zero-relative index at which to begin the search | 889 * @param start the zero-relative index at which to begin the search |
894 * @return the index of the item | 890 * @return the index of the item |
895 * | 891 * |
896 * @exception IllegalArgumentException <ul> | |
897 * <li>ERROR_NULL_ARGUMENT - if the string is null</li> | |
898 * </ul> | |
899 * @exception DWTException <ul> | 892 * @exception DWTException <ul> |
900 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> | 893 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> |
901 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | 894 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> |
902 * </ul> | 895 * </ul> |
903 */ | 896 */ |
904 public int indexOf (String string, int start) { | 897 public int indexOf (String string, int start) { |
905 checkWidget (); | 898 checkWidget (); |
906 if (string is null) DWT.error (DWT.ERROR_NULL_ARGUMENT); | 899 // DWT extension: allow null string |
900 //if (string is null) DWT.error (DWT.ERROR_NULL_ARGUMENT); | |
907 return list.indexOf (string, start); | 901 return list.indexOf (string, start); |
908 } | 902 } |
909 | 903 |
910 void initAccessible() { | 904 void initAccessible() { |
911 AccessibleAdapter accessibleAdapter = new class() AccessibleAdapter { | 905 AccessibleAdapter accessibleAdapter = new class() AccessibleAdapter { |
1235 * and removes that item from the list. | 1229 * and removes that item from the list. |
1236 * | 1230 * |
1237 * @param string the item to remove | 1231 * @param string the item to remove |
1238 * | 1232 * |
1239 * @exception IllegalArgumentException <ul> | 1233 * @exception IllegalArgumentException <ul> |
1240 * <li>ERROR_NULL_ARGUMENT - if the string is null</li> | |
1241 * <li>ERROR_INVALID_ARGUMENT - if the string is not found in the list</li> | 1234 * <li>ERROR_INVALID_ARGUMENT - if the string is not found in the list</li> |
1242 * </ul> | 1235 * </ul> |
1243 * @exception DWTException <ul> | 1236 * @exception DWTException <ul> |
1244 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> | 1237 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> |
1245 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | 1238 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> |
1246 * </ul> | 1239 * </ul> |
1247 */ | 1240 */ |
1248 public void remove (String string) { | 1241 public void remove (String string) { |
1249 checkWidget(); | 1242 checkWidget(); |
1250 if (string is null) DWT.error (DWT.ERROR_NULL_ARGUMENT); | 1243 // DWT extension: allow null string |
1244 //if (string is null) DWT.error (DWT.ERROR_NULL_ARGUMENT); | |
1251 list.remove (string); | 1245 list.remove (string); |
1252 } | 1246 } |
1253 /** | 1247 /** |
1254 * Removes all of the items from the receiver's list and clear the | 1248 * Removes all of the items from the receiver's list and clear the |
1255 * contents of receiver's text field. | 1249 * contents of receiver's text field. |
1419 * @param index the index for the item | 1413 * @param index the index for the item |
1420 * @param string the new text for the item | 1414 * @param string the new text for the item |
1421 * | 1415 * |
1422 * @exception IllegalArgumentException <ul> | 1416 * @exception IllegalArgumentException <ul> |
1423 * <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)</li> | 1417 * <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)</li> |
1424 * <li>ERROR_NULL_ARGUMENT - if the string is null</li> | |
1425 * </ul> | 1418 * </ul> |
1426 * @exception DWTException <ul> | 1419 * @exception DWTException <ul> |
1427 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> | 1420 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> |
1428 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | 1421 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> |
1429 * </ul> | 1422 * </ul> |
1528 * display incorrectly. | 1521 * display incorrectly. |
1529 * </p> | 1522 * </p> |
1530 * | 1523 * |
1531 * @param string the new text | 1524 * @param string the new text |
1532 * | 1525 * |
1533 * @exception IllegalArgumentException <ul> | |
1534 * <li>ERROR_NULL_ARGUMENT - if the string is null</li> | |
1535 * </ul> | |
1536 * @exception DWTException <ul> | 1526 * @exception DWTException <ul> |
1537 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> | 1527 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> |
1538 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | 1528 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> |
1539 * </ul> | 1529 * </ul> |
1540 */ | 1530 */ |
1541 public void setText (String string) { | 1531 public void setText (String string) { |
1542 checkWidget(); | 1532 checkWidget(); |
1543 if (string is null) DWT.error (DWT.ERROR_NULL_ARGUMENT); | 1533 // DWT extension: allow null string |
1534 //if (string is null) DWT.error (DWT.ERROR_NULL_ARGUMENT); | |
1544 int index = list.indexOf (string); | 1535 int index = list.indexOf (string); |
1545 if (index is -1) { | 1536 if (index is -1) { |
1546 list.deselectAll (); | 1537 list.deselectAll (); |
1547 text.setText (string); | 1538 text.setText (string); |
1548 return; | 1539 return; |