Changeset 244:a59d51c12b42
- Timestamp:
- 06/28/08 14:27:21
(4 months ago)
- Author:
- Frank Benoit <benoit@tionex.de>
- branch:
- default
- Message:
work on allow null strings and arrays
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| r213 |
r244 |
|
| 193 | 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 | 195 | * @exception DWTException <ul> |
|---|
| 199 | 196 | * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> |
|---|
| … | … | |
| 205 | 202 | public void add (String string) { |
|---|
| 206 | 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 | 206 | list.add (string); |
|---|
| 209 | 207 | } |
|---|
| … | … | |
| 221 | 219 | * |
|---|
| 222 | 220 | * @exception IllegalArgumentException <ul> |
|---|
| 223 | | * <li>ERROR_NULL_ARGUMENT - if the string is null</li> |
|---|
| 224 | 221 | * <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list (inclusive)</li> |
|---|
| 225 | 222 | * </ul> |
|---|
| … | … | |
| 233 | 230 | public void add (String string, int index) { |
|---|
| 234 | 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 | 234 | list.add (string, index); |
|---|
| 237 | 235 | } |
|---|
| … | … | |
| 870 | 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 | 870 | * @exception DWTException <ul> |
|---|
| 876 | 871 | * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> |
|---|
| … | … | |
| 880 | 875 | public int indexOf (String string) { |
|---|
| 881 | 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 | 879 | return list.indexOf (string); |
|---|
| 884 | 880 | } |
|---|
| … | … | |
| 894 | 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 | 892 | * @exception DWTException <ul> |
|---|
| 900 | 893 | * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> |
|---|
| … | … | |
| 904 | 897 | public int indexOf (String string, int start) { |
|---|
| 905 | 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 | 901 | return list.indexOf (string, start); |
|---|
| 908 | 902 | } |
|---|
| … | … | |
| 1238 | 1232 | * |
|---|
| 1239 | 1233 | * @exception IllegalArgumentException <ul> |
|---|
| 1240 | | * <li>ERROR_NULL_ARGUMENT - if the string is null</li> |
|---|
| 1241 | 1234 | * <li>ERROR_INVALID_ARGUMENT - if the string is not found in the list</li> |
|---|
| 1242 | 1235 | * </ul> |
|---|
| … | … | |
| 1248 | 1241 | public void remove (String string) { |
|---|
| 1249 | 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 | 1245 | list.remove (string); |
|---|
| 1252 | 1246 | } |
|---|
| … | … | |
| 1422 | 1416 | * @exception IllegalArgumentException <ul> |
|---|
| 1423 | 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 | 1418 | * </ul> |
|---|
| 1426 | 1419 | * @exception DWTException <ul> |
|---|
| … | … | |
| 1531 | 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 | 1526 | * @exception DWTException <ul> |
|---|
| 1537 | 1527 | * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> |
|---|
| … | … | |
| 1541 | 1531 | public void setText (String string) { |
|---|
| 1542 | 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 | 1535 | int index = list.indexOf (string); |
|---|
| 1545 | 1536 | if (index is -1) { |
|---|
| r213 |
r244 |
|
| 1040 | 1040 | public override void setText (String string) { |
|---|
| 1041 | 1041 | checkWidget(); |
|---|
| 1042 | | if (string is null) DWT.error (DWT.ERROR_NULL_ARGUMENT); |
|---|
| | 1042 | // DWT extension: allow null string |
|---|
| | 1043 | //if (string is null) DWT.error (DWT.ERROR_NULL_ARGUMENT); |
|---|
| 1043 | 1044 | if (string==getText()) return; |
|---|
| 1044 | 1045 | super.setText(string); |
|---|
| r212 |
r244 |
|
| 264 | 264 | * |
|---|
| 265 | 265 | * @exception IllegalArgumentException <ul> |
|---|
| 266 | | * <li>ERROR_NULL_ARGUMENT - if the items array is null</li> |
|---|
| 267 | 266 | * <li>ERROR_INVALID_ARGUMENT - if an item in the items array is null</li> |
|---|
| 268 | 267 | * </ul> |
|---|
| r214 |
r244 |
|
| 1606 | 1606 | public void append(String string) { |
|---|
| 1607 | 1607 | checkWidget(); |
|---|
| 1608 | | if (string is null) { |
|---|
| 1609 | | DWT.error(DWT.ERROR_NULL_ARGUMENT); |
|---|
| 1610 | | } |
|---|
| | 1608 | // DWT extension: allow null string |
|---|
| | 1609 | //if (string is null) { |
|---|
| | 1610 | // DWT.error(DWT.ERROR_NULL_ARGUMENT); |
|---|
| | 1611 | //} |
|---|
| 1611 | 1612 | int lastChar = Math.max(getCharCount(), 0); |
|---|
| 1612 | 1613 | replaceTextRange(lastChar, 0, string); |
|---|
| … | … | |
| 4937 | 4938 | * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> |
|---|
| 4938 | 4939 | * </ul> |
|---|
| 4939 | | * @exception IllegalArgumentException <ul> |
|---|
| 4940 | | * <li>ERROR_NULL_ARGUMENT when string is null</li> |
|---|
| 4941 | | * </ul> |
|---|
| 4942 | 4940 | */ |
|---|
| 4943 | 4941 | public void insert(String string) { |
|---|
| 4944 | 4942 | checkWidget(); |
|---|
| 4945 | | if (string is null) { |
|---|
| 4946 | | DWT.error(DWT.ERROR_NULL_ARGUMENT); |
|---|
| 4947 | | } |
|---|
| | 4943 | // DWT extension: allow null string |
|---|
| | 4944 | //if (string is null) { |
|---|
| | 4945 | // DWT.error(DWT.ERROR_NULL_ARGUMENT); |
|---|
| | 4946 | //} |
|---|
| 4948 | 4947 | Point sel = getSelectionRange(); |
|---|
| 4949 | 4948 | replaceTextRange(sel.x, sel.y, string); |
|---|
| … | … | |
| 6461 | 6460 | * @exception IllegalArgumentException <ul> |
|---|
| 6462 | 6461 | * <li>ERROR_INVALID_RANGE when either start or end is outside the valid range (0 <= offset <= getCharCount())</li> |
|---|
| 6463 | | * <li>ERROR_NULL_ARGUMENT when ranges is null</li> |
|---|
| 6464 | 6462 | * </ul> |
|---|
| 6465 | 6463 | * |
|---|
| … | … | |
| 6471 | 6469 | checkWidget(); |
|---|
| 6472 | 6470 | if (isListening(LineGetStyle)) return; |
|---|
| 6473 | | if (ranges is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); |
|---|
| | 6471 | // DWT extension: allow null array |
|---|
| | 6472 | //if (ranges is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); |
|---|
| 6474 | 6473 | setStyleRanges(start, length, null, ranges, false); |
|---|
| 6475 | 6474 | } |
|---|
| … | … | |
| 6504 | 6503 | * <li>ERROR_INVALID_ARGUMENT when either start or end is inside a multi byte line delimiter. |
|---|
| 6505 | 6504 | * Splitting a line delimiter for example by inserting text in between the CR and LF and deleting part of a line delimiter is not supported</li> |
|---|
| 6506 | | * <li>ERROR_NULL_ARGUMENT when string is null</li> |
|---|
| 6507 | 6505 | * </ul> |
|---|
| 6508 | 6506 | */ |
|---|
| 6509 | 6507 | public void replaceTextRange(int start, int length, String text) { |
|---|
| 6510 | 6508 | checkWidget(); |
|---|
| 6511 | | if (text is null) { |
|---|
| 6512 | | DWT.error(DWT.ERROR_NULL_ARGUMENT); |
|---|
| 6513 | | } |
|---|
| | 6509 | // DWT extension: allow null string |
|---|
| | 6510 | //if (text is null) { |
|---|
| | 6511 | // DWT.error(DWT.ERROR_NULL_ARGUMENT); |
|---|
| | 6512 | //} |
|---|
| 6514 | 6513 | int contentLength = getCharCount(); |
|---|
| 6515 | 6514 | int end = start + length; |
|---|
| … | … | |
| 7927 | 7926 | * </ul> |
|---|
| 7928 | 7927 | * @exception IllegalArgumentException <ul> |
|---|
| 7929 | | * <li>ERROR_NULL_ARGUMENT when an element in the styles array is null</li> |
|---|
| 7930 | 7928 | * <li>ERROR_INVALID_RANGE when the number of ranges and style do not match (ranges.length * 2 is styles.length)</li> |
|---|
| 7931 | 7929 | * <li>ERROR_INVALID_RANGE when a range is outside the valid range (> getCharCount() or less than zero)</li> |
|---|
| … | … | |
| 7969 | 7967 | * </ul> |
|---|
| 7970 | 7968 | * @exception IllegalArgumentException <ul> |
|---|
| 7971 | | * <li>ERROR_NULL_ARGUMENT when an element in the styles array is null</li> |
|---|
| 7972 | 7969 | * <li>ERROR_INVALID_RANGE when the number of ranges and style do not match (ranges.length * 2 is styles.length)</li> |
|---|
| 7973 | 7970 | * <li>ERROR_INVALID_RANGE when a range is outside the valid range (> getCharCount() or less than zero)</li> |
|---|
| … | … | |
| 8097 | 8094 | * </ul> |
|---|
| 8098 | 8095 | * @exception IllegalArgumentException <ul> |
|---|
| 8099 | | * <li>ERROR_NULL_ARGUMENT when the list of ranges is null</li> |
|---|
| 8100 | 8096 | * <li>ERROR_INVALID_RANGE when the last of the style ranges is outside the valid range (> getCharCount())</li> |
|---|
| 8101 | 8097 | * </ul> |
|---|
| … | … | |
| 8106 | 8102 | checkWidget(); |
|---|
| 8107 | 8103 | if (isListening(LineGetStyle)) return; |
|---|
| 8108 | | if (ranges is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); |
|---|
| | 8104 | // DWT extension: allow null array |
|---|
| | 8105 | //if (ranges is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); |
|---|
| 8109 | 8106 | setStyleRanges(0, 0, null, ranges, true); |
|---|
| 8110 | 8107 | } |
|---|
| … | … | |
| 8144 | 8141 | * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> |
|---|
| 8145 | 8142 | * </ul> |
|---|
| 8146 | | * @exception IllegalArgumentException <ul> |
|---|
| 8147 | | * <li>ERROR_NULL_ARGUMENT when string is null</li> |
|---|
| 8148 | | * </ul> |
|---|
| 8149 | 8143 | */ |
|---|
| 8150 | 8144 | public void setText(String text) { |
|---|
| 8151 | 8145 | checkWidget(); |
|---|
| 8152 | | if (text is null) { |
|---|
| 8153 | | DWT.error(DWT.ERROR_NULL_ARGUMENT); |
|---|
| 8154 | | } |
|---|
| | 8146 | // DWT extension: allow null string |
|---|
| | 8147 | //if (text is null) { |
|---|
| | 8148 | // DWT.error(DWT.ERROR_NULL_ARGUMENT); |
|---|
| | 8149 | //} |
|---|
| 8155 | 8150 | Event event = new Event(); |
|---|
| 8156 | 8151 | event.start = 0; |
|---|
| r212 |
r244 |
|
| 766 | 766 | * |
|---|
| 767 | 767 | * @exception IllegalArgumentException <ul> |
|---|
| 768 | | * <li>ERROR_NULL_ARGUMENT - if the array of items is null</li> |
|---|
| 769 | 768 | * <li>ERROR_INVALID_ARGUMENT - if one of the item has been disposed</li> |
|---|
| 770 | 769 | * </ul> |
|---|
| … | … | |
| 778 | 777 | public void setSelection (TableTreeItem[] items) { |
|---|
| 779 | 778 | checkWidget (); |
|---|
| 780 | | if (items is null) DWT.error (DWT.ERROR_NULL_ARGUMENT); |
|---|
| | 779 | // DWT extension: allow null array |
|---|
| | 780 | //if (items is null) DWT.error (DWT.ERROR_NULL_ARGUMENT); |
|---|
| 781 | 781 | int length = items.length; |
|---|
| 782 | 782 | if (length is 0 || ((table.getStyle() & DWT.SINGLE) !is 0 && length > 1)) { |
|---|
| r213 |
r244 |
|
| 820 | 820 | * @param text the new text |
|---|
| 821 | 821 | * |
|---|
| 822 | | * @exception IllegalArgumentException <ul> |
|---|
| 823 | | * <li>ERROR_NULL_ARGUMENT - if the text is null</li> |
|---|
| 824 | | * </ul> |
|---|
| 825 | 822 | * @exception DWTException <ul> |
|---|
| 826 | 823 | * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li> |
|---|
| … | … | |
| 830 | 827 | public void setText(int index, String text) { |
|---|
| 831 | 828 | checkWidget(); |
|---|
| 832 | | if (text is null) DWT.error (DWT.ERROR_NULL_ARGUMENT); |
|---|
| | 829 | // DWT extension: allow null string |
|---|
| | 830 | //if (text is null) DWT.error (DWT.ERROR_NULL_ARGUMENT); |
|---|
| 833 | 831 | int columnCount = Math.max(parent.getTable().getColumnCount(), 1); |
|---|
| 834 | 832 | if (index < 0 || index >= columnCount) return; |
|---|