Mercurial > projects > dwt-mac
comparison dwt/custom/TableTree.d @ 41:6337764516f1
Sync dwt/custom with dwt-linux (took copy of complete folder)
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Tue, 07 Oct 2008 16:29:55 +0200 |
parents | e831403a80a9 |
children |
comparison
equal
deleted
inserted
replaced
40:fbe68c33eeee | 41:6337764516f1 |
---|---|
5 * which accompanies this distribution, and is available at | 5 * which accompanies this distribution, and is available at |
6 * http://www.eclipse.org/legal/epl-v10.html | 6 * http://www.eclipse.org/legal/epl-v10.html |
7 * | 7 * |
8 * Contributors: | 8 * Contributors: |
9 * IBM Corporation - initial API and implementation | 9 * IBM Corporation - initial API and implementation |
10 * Port to the D programming language: | |
11 * Frank Benoit <benoit@tionex.de> | |
10 *******************************************************************************/ | 12 *******************************************************************************/ |
11 module dwt.custom; | 13 module dwt.custom.TableTree; |
12 | 14 |
13 | 15 |
14 import dwt.*; | 16 |
15 import dwt.events.*; | 17 import dwt.DWT; |
16 import dwt.graphics.*; | 18 import dwt.DWTException; |
17 import dwt.widgets.*; | 19 import dwt.events.SelectionEvent; |
18 | 20 import dwt.events.SelectionListener; |
19 /** | 21 import dwt.events.TreeListener; |
22 import dwt.graphics.Color; | |
23 import dwt.graphics.Font; | |
24 import dwt.graphics.GC; | |
25 import dwt.graphics.Image; | |
26 import dwt.graphics.ImageData; | |
27 import dwt.graphics.PaletteData; | |
28 import dwt.graphics.Point; | |
29 import dwt.graphics.RGB; | |
30 import dwt.graphics.Rectangle; | |
31 import dwt.widgets.Composite; | |
32 import dwt.widgets.Event; | |
33 import dwt.widgets.Listener; | |
34 import dwt.widgets.Menu; | |
35 import dwt.widgets.Table; | |
36 import dwt.widgets.TableItem; | |
37 import dwt.widgets.TypedListener; | |
38 import dwt.custom.TableTreeItem; | |
39 import dwt.dwthelper.utils; | |
40 | |
41 /** | |
20 * A TableTree is a selectable user interface object | 42 * A TableTree is a selectable user interface object |
21 * that displays a hierarchy of items, and issues | 43 * that displays a hierarchy of items, and issues |
22 * notification when an item is selected. | 44 * notification when an item is selected. |
23 * A TableTree may be single or multi select. | 45 * A TableTree may be single or multi select. |
24 * <p> | 46 * <p> |
34 * <dt><b>Events:</b> <dd> Selection, DefaultSelection, Collapse, Expand | 56 * <dt><b>Events:</b> <dd> Selection, DefaultSelection, Collapse, Expand |
35 * </dl> | 57 * </dl> |
36 * <p> | 58 * <p> |
37 * Note: Only one of the styles SINGLE, and MULTI may be specified. | 59 * Note: Only one of the styles SINGLE, and MULTI may be specified. |
38 * </p> | 60 * </p> |
39 * | 61 * |
40 * @deprecated As of 3.1 use Tree, TreeItem and TreeColumn | 62 * @deprecated As of 3.1 use Tree, TreeItem and TreeColumn |
41 */ | 63 */ |
42 public class TableTree : Composite { | 64 public class TableTree : Composite { |
65 | |
66 alias Composite.computeSize computeSize; | |
67 | |
43 Table table; | 68 Table table; |
44 TableTreeItem[] items = EMPTY_ITEMS; | 69 TableTreeItem[] items; |
45 Image plusImage, minusImage, sizeImage; | 70 Image plusImage, minusImage, sizeImage; |
46 | 71 |
47 /* | 72 /* |
48 * TableTreeItems are not treated as children but rather as items. | 73 * TableTreeItems are not treated as children but rather as items. |
49 * When the TableTree is disposed, all children are disposed because | 74 * When the TableTree is disposed, all children are disposed because |
50 * TableTree inherits this behaviour from Composite. The items | 75 * TableTree inherits this behaviour from Composite. The items |
51 * must be disposed separately. Because TableTree is not part of | 76 * must be disposed separately. Because TableTree is not part of |
52 * the dwt.widgets module, the method releaseWidget can | 77 * the org.eclipse.swt.widgets module, the method releaseWidget can |
53 * not be overridden (this is how items are disposed of in Table and Tree). | 78 * not be overridden (this is how items are disposed of in Table and Tree). |
54 * Instead, the items are disposed of in response to the dispose event on the | 79 * Instead, the items are disposed of in response to the dispose event on the |
55 * TableTree. The "inDispose" flag is used to distinguish between disposing | 80 * TableTree. The "inDispose" flag is used to distinguish between disposing |
56 * one TableTreeItem (e.g. when removing an entry from the TableTree) and | 81 * one TableTreeItem (e.g. when removing an entry from the TableTree) and |
57 * disposing the entire TableTree. | 82 * disposing the entire TableTree. |
58 */ | 83 */ |
59 bool inDispose = false; | 84 bool inDispose = false; |
60 | 85 |
61 static final TableTreeItem[] EMPTY_ITEMS = new TableTreeItem [0]; | 86 static final TableTreeItem[] EMPTY_ITEMS; |
62 static final String[] EMPTY_TEXTS = new String [0]; | 87 static final String[] EMPTY_TEXTS; |
63 static final Image[] EMPTY_IMAGES = new Image [0]; | 88 static final Image[] EMPTY_IMAGES; |
64 static final String ITEMID = "TableTreeItemID"; //$NON-NLS-1$ | 89 static final String ITEMID = "TableTreeItemID"; //$NON-NLS-1$ |
65 | 90 |
66 /** | 91 /** |
67 * Constructs a new instance of this class given its parent | 92 * Constructs a new instance of this class given its parent |
68 * and a style value describing its behavior and appearance. | 93 * and a style value describing its behavior and appearance. |
69 * <p> | 94 * <p> |
70 * The style value is either one of the style constants defined in | 95 * The style value is either one of the style constants defined in |
71 * class <code>DWT</code> which is applicable to instances of this | 96 * class <code>DWT</code> which is applicable to instances of this |
72 * class, or must be built by <em>bitwise OR</em>'ing together | 97 * class, or must be built by <em>bitwise OR</em>'ing together |
73 * (that is, using the <code>int</code> "|" operator) two or more | 98 * (that is, using the <code>int</code> "|" operator) two or more |
74 * of those <code>DWT</code> style constants. The class description | 99 * of those <code>DWT</code> style constants. The class description |
75 * lists the style constants that are applicable to the class. | 100 * lists the style constants that are applicable to the class. |
76 * Style bits are also inherited from superclasses. | 101 * Style bits are also inherited from superclasses. |
77 * </p> | 102 * </p> |
92 * @see DWT#FULL_SELECTION | 117 * @see DWT#FULL_SELECTION |
93 * @see #getStyle | 118 * @see #getStyle |
94 */ | 119 */ |
95 public this(Composite parent, int style) { | 120 public this(Composite parent, int style) { |
96 super(parent, checkStyle (style)); | 121 super(parent, checkStyle (style)); |
122 items = EMPTY_ITEMS; | |
97 table = new Table(this, style); | 123 table = new Table(this, style); |
98 Listener tableListener = new Listener() { | 124 Listener tableListener = new class() Listener { |
99 public void handleEvent(Event e) { | 125 public void handleEvent(Event e) { |
100 switch (e.type) { | 126 switch (e.type) { |
101 case DWT.MouseDown: onMouseDown(e); break; | 127 case DWT.MouseDown: onMouseDown(e); break; |
102 case DWT.Selection: onSelection(e); break; | 128 case DWT.Selection: onSelection(e); break; |
103 case DWT.DefaultSelection: onSelection(e); break; | 129 case DWT.DefaultSelection: onSelection(e); break; |
104 case DWT.KeyDown: onKeyDown(e); break; | 130 case DWT.KeyDown: onKeyDown(e); break; |
131 default: | |
105 } | 132 } |
106 } | 133 } |
107 }; | 134 }; |
108 int[] tableEvents = new int[]{DWT.MouseDown, | 135 int[] tableEvents = [DWT.MouseDown, |
109 DWT.Selection, | 136 DWT.Selection, |
110 DWT.DefaultSelection, | 137 DWT.DefaultSelection, |
111 DWT.KeyDown}; | 138 DWT.KeyDown]; |
112 for (int i = 0; i < tableEvents.length; i++) { | 139 for (int i = 0; i < tableEvents.length; i++) { |
113 table.addListener(tableEvents[i], tableListener); | 140 table.addListener(tableEvents[i], tableListener); |
114 } | 141 } |
115 | 142 |
116 Listener listener = new Listener() { | 143 Listener listener = new class() Listener { |
117 public void handleEvent(Event e) { | 144 public void handleEvent(Event e) { |
118 switch (e.type) { | 145 switch (e.type) { |
119 case DWT.Dispose: onDispose(e); break; | 146 case DWT.Dispose: onDispose(e); break; |
120 case DWT.Resize: onResize(e); break; | 147 case DWT.Resize: onResize(e); break; |
121 case DWT.FocusIn: onFocusIn(e); break; | 148 case DWT.FocusIn: onFocusIn(e); break; |
149 default: | |
122 } | 150 } |
123 } | 151 } |
124 }; | 152 }; |
125 int[] events = new int[]{DWT.Dispose, | 153 int[] events = [DWT.Dispose, |
126 DWT.Resize, | 154 DWT.Resize, |
127 DWT.FocusIn}; | 155 DWT.FocusIn]; |
128 for (int i = 0; i < events.length; i++) { | 156 for (int i = 0; i < events.length; i++) { |
129 addListener(events[i], listener); | 157 addListener(events[i], listener); |
130 } | 158 } |
131 } | 159 } |
132 | 160 |
133 int addItem(TableTreeItem item, int index) { | 161 int addItem(TableTreeItem item, int index) { |
134 if (index < 0 || index > items.length) DWT.error(DWT.ERROR_INVALID_ARGUMENT); | 162 if (index < 0 || index > items.length) DWT.error(DWT.ERROR_INVALID_ARGUMENT); |
135 TableTreeItem[] newItems = new TableTreeItem[items.length + 1]; | 163 TableTreeItem[] newItems = new TableTreeItem[items.length + 1]; |
136 System.arraycopy(items, 0, newItems, 0, index); | 164 System.arraycopy(items, 0, newItems, 0, index); |
137 newItems[index] = item; | 165 newItems[index] = item; |
138 System.arraycopy(items, index, newItems, index + 1, items.length - index); | 166 System.arraycopy(items, index, newItems, index + 1, items.length - index); |
139 items = newItems; | 167 items = newItems; |
140 | 168 |
141 /* Return the index in the table where this table should be inserted */ | 169 /* Return the index in the table where this table should be inserted */ |
142 if (index is items.length - 1 ) | 170 if (index is items.length - 1 ) |
143 return table.getItemCount(); | 171 return table.getItemCount(); |
144 else | 172 else |
145 return table.indexOf(items[index+1].tableItem); | 173 return table.indexOf(items[index+1].tableItem); |
146 } | 174 } |
147 | 175 |
148 /** | 176 /** |
149 * Adds the listener to the collection of listeners who will | 177 * Adds the listener to the collection of listeners who will |
205 TypedListener typedListener = new TypedListener (listener); | 233 TypedListener typedListener = new TypedListener (listener); |
206 addListener (DWT.Expand, typedListener); | 234 addListener (DWT.Expand, typedListener); |
207 addListener (DWT.Collapse, typedListener); | 235 addListener (DWT.Collapse, typedListener); |
208 } | 236 } |
209 private static int checkStyle (int style) { | 237 private static int checkStyle (int style) { |
210 int mask = DWT.LEFT_TO_RIGHT | DWT.RIGHT_TO_LEFT; | 238 int mask = DWT.LEFT_TO_RIGHT | DWT.RIGHT_TO_LEFT; |
211 style = style & mask; | 239 style = style & mask; |
212 return style; | 240 return style; |
213 } | 241 } |
214 public Point computeSize (int wHint, int hHint, bool changed) { | 242 public override Point computeSize (int wHint, int hHint, bool changed) { |
215 checkWidget(); | 243 checkWidget(); |
216 return table.computeSize (wHint, hHint, changed); | 244 return table.computeSize (wHint, hHint, changed); |
217 } | 245 } |
218 public Rectangle computeTrim (int x, int y, int width, int height) { | 246 public override Rectangle computeTrim (int x, int y, int width, int height) { |
219 checkWidget(); | 247 checkWidget(); |
220 return table.computeTrim(x, y, width, height); | 248 return table.computeTrim(x, y, width, height); |
221 } | 249 } |
222 | 250 |
223 /** | 251 /** |
246 Event event = new Event(); | 274 Event event = new Event(); |
247 event.item = item; | 275 event.item = item; |
248 notifyListeners(DWT.Expand, event); | 276 notifyListeners(DWT.Expand, event); |
249 } | 277 } |
250 } | 278 } |
251 public Color getBackground () { | 279 public override Color getBackground () { |
252 // This method must be overridden otherwise, in a TableTree in which the first | 280 // This method must be overridden otherwise, in a TableTree in which the first |
253 // item has no sub items, a grey (Widget background colour) square will appear in | 281 // item has no sub items, a grey (Widget background colour) square will appear in |
254 // the first column of the first item. | 282 // the first column of the first item. |
255 // It is not possible in the constructor to set the background of the TableTree | 283 // It is not possible in the constructor to set the background of the TableTree |
256 // to be the same as the background of the Table because this interferes with | 284 // to be the same as the background of the Table because this interferes with |
257 // the TableTree adapting to changes in the System color settings. | 285 // the TableTree adapting to changes in the System color settings. |
258 return table.getBackground(); | 286 return table.getBackground(); |
259 } | 287 } |
260 public Rectangle getClientArea () { | 288 public override Rectangle getClientArea () { |
261 return table.getClientArea(); | 289 return table.getClientArea(); |
262 } | 290 } |
263 public Color getForeground () { | 291 public override Color getForeground () { |
264 return table.getForeground(); | 292 return table.getForeground(); |
265 } | 293 } |
266 public Font getFont () { | 294 public override Font getFont () { |
267 return table.getFont(); | 295 return table.getFont(); |
268 } | 296 } |
269 /** | 297 /** |
270 * Gets the number of items. | 298 * Gets the number of items. |
271 * <p> | 299 * <p> |
345 public int getSelectionCount () { | 373 public int getSelectionCount () { |
346 checkWidget(); | 374 checkWidget(); |
347 return table.getSelectionCount(); | 375 return table.getSelectionCount(); |
348 } | 376 } |
349 | 377 |
350 public int getStyle () { | 378 public override int getStyle () { |
351 checkWidget(); | 379 checkWidget(); |
352 return table.getStyle(); | 380 return table.getStyle(); |
353 } | 381 } |
354 | 382 |
355 /** | 383 /** |
361 //checkWidget(); | 389 //checkWidget(); |
362 return table; | 390 return table; |
363 } | 391 } |
364 | 392 |
365 void createImages () { | 393 void createImages () { |
366 | 394 |
367 int itemHeight = sizeImage.getBounds().height; | 395 int itemHeight = sizeImage.getBounds().height; |
368 // Calculate border around image. | 396 // Calculate border around image. |
369 // At least 9 pixels are needed to draw the image | 397 // At least 9 pixels are needed to draw the image |
370 // Leave at least a 6 pixel border. | 398 // Leave at least a 6 pixel border. |
371 int indent = Math.min(6, (itemHeight - 9) / 2); | 399 int indent = Math.min(6, (itemHeight - 9) / 2); |
372 indent = Math.max(0, indent); | 400 indent = Math.max(0, indent); |
373 int size = Math.max (10, itemHeight - 2 * indent); | 401 int size = Math.max (10, itemHeight - 2 * indent); |
374 size = ((size + 1) / 2) * 2; // size must be an even number | 402 size = ((size + 1) / 2) * 2; // size must be an even number |
375 int midpoint = indent + size / 2; | 403 int midpoint = indent + size / 2; |
376 | 404 |
377 Color foreground = getForeground(); | 405 Color foreground = getForeground(); |
378 Color plusMinus = getDisplay().getSystemColor(DWT.COLOR_WIDGET_NORMAL_SHADOW); | 406 Color plusMinus = getDisplay().getSystemColor(DWT.COLOR_WIDGET_NORMAL_SHADOW); |
379 Color background = getBackground(); | 407 Color background = getBackground(); |
380 | 408 |
381 /* Plus image */ | 409 /* Plus image */ |
382 PaletteData palette = new PaletteData(new RGB[]{foreground.getRGB(), background.getRGB(), plusMinus.getRGB()}); | 410 PaletteData palette = new PaletteData( [ foreground.getRGB(), background.getRGB(), plusMinus.getRGB()]); |
383 ImageData imageData = new ImageData(itemHeight, itemHeight, 4, palette); | 411 ImageData imageData = new ImageData(itemHeight, itemHeight, 4, palette); |
384 imageData.transparentPixel = 1; | 412 imageData.transparentPixel = 1; |
385 plusImage = new Image(getDisplay(), imageData); | 413 plusImage = new Image(getDisplay(), imageData); |
386 GC gc = new GC(plusImage); | 414 GC gc = new GC(plusImage); |
387 gc.setBackground(background); | 415 gc.setBackground(background); |
390 gc.drawRectangle(indent, indent, size, size); | 418 gc.drawRectangle(indent, indent, size, size); |
391 gc.setForeground(foreground); | 419 gc.setForeground(foreground); |
392 gc.drawLine(midpoint, indent + 2, midpoint, indent + size - 2); | 420 gc.drawLine(midpoint, indent + 2, midpoint, indent + size - 2); |
393 gc.drawLine(indent + 2, midpoint, indent + size - 2, midpoint); | 421 gc.drawLine(indent + 2, midpoint, indent + size - 2, midpoint); |
394 gc.dispose(); | 422 gc.dispose(); |
395 | 423 |
396 /* Minus image */ | 424 /* Minus image */ |
397 palette = new PaletteData(new RGB[]{foreground.getRGB(), background.getRGB(), plusMinus.getRGB()}); | 425 palette = new PaletteData([foreground.getRGB(), background.getRGB(), plusMinus.getRGB()]); |
398 imageData = new ImageData(itemHeight, itemHeight, 4, palette); | 426 imageData = new ImageData(itemHeight, itemHeight, 4, palette); |
399 imageData.transparentPixel = 1; | 427 imageData.transparentPixel = 1; |
400 minusImage = new Image(getDisplay(), imageData); | 428 minusImage = new Image(getDisplay(), imageData); |
401 gc = new GC(minusImage); | 429 gc = new GC(minusImage); |
402 gc.setBackground(background); | 430 gc.setBackground(background); |
418 return minusImage; | 446 return minusImage; |
419 } | 447 } |
420 | 448 |
421 /** | 449 /** |
422 * Gets the index of an item. | 450 * Gets the index of an item. |
423 * | 451 * |
424 * <p>The widget is searched starting at 0 until an | 452 * <p>The widget is searched starting at 0 until an |
425 * item is found that is equal to the search item. | 453 * item is found that is equal to the search item. |
426 * If no item is found, -1 is returned. Indexing | 454 * If no item is found, -1 is returned. Indexing |
427 * is zero based. This index is relative to the parent only. | 455 * is zero based. This index is relative to the parent only. |
428 * | 456 * |
484 * </ul> | 512 * </ul> |
485 * @exception DWTException <ul> | 513 * @exception DWTException <ul> |
486 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> | 514 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> |
487 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | 515 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> |
488 * </ul> | 516 * </ul> |
489 * | 517 * |
490 * @since 3.1 | 518 * @since 3.1 |
491 */ | 519 */ |
492 public TableTreeItem getItem (int index) { | 520 public TableTreeItem getItem (int index) { |
493 checkWidget(); | 521 checkWidget(); |
494 int count = items.length; | 522 int count = items.length; |
515 public TableTreeItem getItem(Point point) { | 543 public TableTreeItem getItem(Point point) { |
516 checkWidget(); | 544 checkWidget(); |
517 TableItem item = table.getItem(point); | 545 TableItem item = table.getItem(point); |
518 if (item is null) return null; | 546 if (item is null) return null; |
519 return getItem(item); | 547 return getItem(item); |
520 | 548 |
521 } | 549 } |
522 TableTreeItem getItem(TableItem tableItem) { | 550 TableTreeItem getItem(TableItem tableItem) { |
523 if (tableItem is null) return null; | 551 if (tableItem is null) return null; |
524 for (int i = 0; i < items.length; i++) { | 552 for (int i = 0; i < items.length; i++) { |
525 TableTreeItem item = items[i].getItem(tableItem); | 553 TableTreeItem item = items[i].getItem(tableItem); |
540 int trailKey = (getStyle() & DWT.MIRRORED) !is 0 ? DWT.ARROW_LEFT : DWT.ARROW_RIGHT; | 568 int trailKey = (getStyle() & DWT.MIRRORED) !is 0 ? DWT.ARROW_LEFT : DWT.ARROW_RIGHT; |
541 if (e.keyCode is trailKey) { | 569 if (e.keyCode is trailKey) { |
542 if (item.getItemCount() is 0) return; | 570 if (item.getItemCount() is 0) return; |
543 if (item.getExpanded()) { | 571 if (item.getExpanded()) { |
544 TableTreeItem newSelection = item.getItems()[0]; | 572 TableTreeItem newSelection = item.getItems()[0]; |
545 table.setSelection(new TableItem[]{newSelection.tableItem}); | 573 table.setSelection([newSelection.tableItem]); |
546 showItem(newSelection); | 574 showItem(newSelection); |
547 type = DWT.Selection; | 575 type = DWT.Selection; |
548 } else { | 576 } else { |
549 item.setExpanded(true); | 577 item.setExpanded(true); |
550 type = DWT.Expand; | 578 type = DWT.Expand; |
556 } else { | 584 } else { |
557 TableTreeItem parent = item.getParentItem(); | 585 TableTreeItem parent = item.getParentItem(); |
558 if (parent !is null) { | 586 if (parent !is null) { |
559 int index = parent.indexOf(item); | 587 int index = parent.indexOf(item); |
560 if (index !is 0) return; | 588 if (index !is 0) return; |
561 table.setSelection(new TableItem[]{parent.tableItem}); | 589 table.setSelection([parent.tableItem]); |
562 type = DWT.Selection; | 590 type = DWT.Selection; |
563 } | 591 } |
564 } | 592 } |
565 } | 593 } |
566 } | 594 } |
576 if (e.character is '+') { | 604 if (e.character is '+') { |
577 if (item.getItemCount() > 0 && !item.getExpanded()) { | 605 if (item.getItemCount() > 0 && !item.getExpanded()) { |
578 item.setExpanded(true); | 606 item.setExpanded(true); |
579 type = DWT.Expand; | 607 type = DWT.Expand; |
580 } | 608 } |
581 } | 609 } |
582 if (type is 0) return; | 610 if (type is 0) return; |
583 Event event = new Event(); | 611 Event event = new Event(); |
584 event.item = item; | 612 event.item = item; |
585 notifyListeners(type, event); | 613 notifyListeners(type, event); |
586 } | 614 } |
695 */ | 723 */ |
696 public void selectAll () { | 724 public void selectAll () { |
697 checkWidget(); | 725 checkWidget(); |
698 table.selectAll(); | 726 table.selectAll(); |
699 } | 727 } |
700 public void setBackground (Color color) { | 728 public override void setBackground (Color color) { |
701 super.setBackground(color); | 729 super.setBackground(color); |
702 table.setBackground(color); | 730 table.setBackground(color); |
703 if (sizeImage !is null) { | 731 if (sizeImage !is null) { |
704 GC gc = new GC (sizeImage); | 732 GC gc = new GC (sizeImage); |
705 gc.setBackground(getBackground()); | 733 gc.setBackground(getBackground()); |
706 Rectangle size = sizeImage.getBounds(); | 734 Rectangle size = sizeImage.getBounds(); |
707 gc.fillRectangle(size); | 735 gc.fillRectangle(size); |
708 gc.dispose(); | 736 gc.dispose(); |
709 } | 737 } |
710 } | 738 } |
711 public void setEnabled (bool enabled) { | 739 public override void setEnabled (bool enabled) { |
712 super.setEnabled(enabled); | 740 super.setEnabled(enabled); |
713 table.setEnabled(enabled); | 741 table.setEnabled(enabled); |
714 } | 742 } |
715 public void setFont (Font font) { | 743 public override void setFont (Font font) { |
716 super.setFont(font); | 744 super.setFont(font); |
717 table.setFont(font); | 745 table.setFont(font); |
718 } | 746 } |
719 public void setForeground (Color color) { | 747 public override void setForeground (Color color) { |
720 super.setForeground(color); | 748 super.setForeground(color); |
721 table.setForeground(color); | 749 table.setForeground(color); |
722 } | 750 } |
723 public void setMenu (Menu menu) { | 751 public override void setMenu (Menu menu) { |
724 super.setMenu(menu); | 752 super.setMenu(menu); |
725 table.setMenu(menu); | 753 table.setMenu(menu); |
726 } | 754 } |
727 | 755 |
728 /** | 756 /** |
734 * then all items are ignored. | 762 * then all items are ignored. |
735 * | 763 * |
736 * @param items the array of items | 764 * @param items the array of items |
737 * | 765 * |
738 * @exception IllegalArgumentException <ul> | 766 * @exception IllegalArgumentException <ul> |
739 * <li>ERROR_NULL_ARGUMENT - if the array of items is null</li> | |
740 * <li>ERROR_INVALID_ARGUMENT - if one of the item has been disposed</li> | 767 * <li>ERROR_INVALID_ARGUMENT - if one of the item has been disposed</li> |
741 * </ul> | 768 * </ul> |
742 * @exception DWTException <ul> | 769 * @exception DWTException <ul> |
743 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> | 770 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> |
744 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | 771 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> |
746 * | 773 * |
747 * @see TableTree#deselectAll() | 774 * @see TableTree#deselectAll() |
748 */ | 775 */ |
749 public void setSelection (TableTreeItem[] items) { | 776 public void setSelection (TableTreeItem[] items) { |
750 checkWidget (); | 777 checkWidget (); |
751 if (items is null) DWT.error (DWT.ERROR_NULL_ARGUMENT); | 778 // DWT extension: allow null for zero length string |
779 //if (items is null) DWT.error (DWT.ERROR_NULL_ARGUMENT); | |
752 int length = items.length; | 780 int length = items.length; |
753 if (length is 0 || ((table.getStyle() & DWT.SINGLE) !is 0 && length > 1)) { | 781 if (length is 0 || ((table.getStyle() & DWT.SINGLE) !is 0 && length > 1)) { |
754 deselectAll(); | 782 deselectAll(); |
755 return; | 783 return; |
756 } | 784 } |
760 if (!items[i].getVisible()) expandItem (items[i]); | 788 if (!items[i].getVisible()) expandItem (items[i]); |
761 tableItems[i] = items[i].tableItem; | 789 tableItems[i] = items[i].tableItem; |
762 } | 790 } |
763 table.setSelection(tableItems); | 791 table.setSelection(tableItems); |
764 } | 792 } |
765 public void setToolTipText (String String) { | 793 public override void setToolTipText (String string) { |
766 super.setToolTipText(String); | 794 super.setToolTipText(string); |
767 table.setToolTipText(String); | 795 table.setToolTipText(string); |
768 } | 796 } |
769 | 797 |
770 /** | 798 /** |
771 * Shows the item. If the item is already showing in the receiver, | 799 * Shows the item. If the item is already showing in the receiver, |
772 * this method simply returns. Otherwise, the items are scrolled | 800 * this method simply returns. Otherwise, the items are scrolled |