Mercurial > projects > dwt-samples
comparison jface/snippets/Snippet031TableViewerCustomTooltipsMultiSelection.d @ 143:42c3056512ba
redirect the jface examples to the new collection wrappers
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Thu, 07 Aug 2008 22:21:50 +0200 |
parents | bf8adb3de664 |
children |
comparison
equal
deleted
inserted
replaced
142:7dca96709d29 | 143:42c3056512ba |
---|---|
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 * Adam Neal - initial API and implementation | 9 * Adam Neal - initial API and implementation |
10 * Port to the D programming language: | 10 * Port to the D programming language: |
11 * yidabu at gmail dot com ( D China http://www.d-programming-language-china.org/ ) | 11 * yidabu at gmail dot com ( D China http://www.d-programming-language-china.org/ ) |
12 *******************************************************************************/ | 12 *******************************************************************************/ |
13 | 13 |
14 module jface.snippets.Snippet031TableViewerCustomTooltipsMultiSelection; | 14 module jface.snippets.Snippet031TableViewerCustomTooltipsMultiSelection; |
15 | 15 |
16 // http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.jface.snippets/Eclipse%20JFace%20Snippets/org/eclipse/jface/snippets/viewers/Snippet031TableViewerCustomTooltipsMultiSelection.java?view=markup | 16 // http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.jface.snippets/Eclipse%20JFace%20Snippets/org/eclipse/jface/snippets/viewers/Snippet031TableViewerCustomTooltipsMultiSelection.java?view=markup |
17 | 17 |
18 import tango.util.collection.ArrayBag; | 18 import dwtx.dwtxhelper.Collection; |
19 alias ArrayBag!(MyModel) ArrayList; | |
20 import tango.util.Convert; | 19 import tango.util.Convert; |
21 | 20 |
22 import dwtx.jface.viewers.ArrayContentProvider; | 21 import dwtx.jface.viewers.ArrayContentProvider; |
23 import dwtx.jface.viewers.ILabelProviderListener; | 22 import dwtx.jface.viewers.ILabelProviderListener; |
24 import dwtx.jface.viewers.ITableLabelProvider; | 23 import dwtx.jface.viewers.ITableLabelProvider; |
44 { | 43 { |
45 Snippet031TableViewerCustomTooltipsMultiSelection.main(args); | 44 Snippet031TableViewerCustomTooltipsMultiSelection.main(args); |
46 } | 45 } |
47 | 46 |
48 /** | 47 /** |
49 * A simple TableViewer to demonstrate how custom tooltips could be created easily while preserving | 48 * A simple TableViewer to demonstrate how custom tooltips could be created easily while preserving |
50 * the multiple selection. | 49 * the multiple selection. |
51 * | 50 * |
52 * This is a modified example taken from Tom Schindl's Snippet023TreeViewerCustomTooltips.java | 51 * This is a modified example taken from Tom Schindl's Snippet023TreeViewerCustomTooltips.java |
53 * | 52 * |
54 * This code is for users pre 3.3 others could use newly added tooltip support in {@link CellLabelProvider} | 53 * This code is for users pre 3.3 others could use newly added tooltip support in {@link CellLabelProvider} |
55 * @author Adam Neal <Adam_Neal@ca.ibm.com> | 54 * @author Adam Neal <Adam_Neal@ca.ibm.com> |
56 * | 55 * |
57 */ | 56 */ |
58 public class Snippet031TableViewerCustomTooltipsMultiSelection { | 57 public class Snippet031TableViewerCustomTooltipsMultiSelection { |
59 public class MyLableProvider : ITableLabelProvider { | 58 public class MyLableProvider : ITableLabelProvider { |
60 | 59 |
61 public Image getColumnImage(Object element, int columnIndex) { | 60 public Image getColumnImage(Object element, int columnIndex) { |
62 return null; | 61 return null; |
63 } | 62 } |
64 | 63 |
65 public String getColumnText(Object element, int columnIndex) { | 64 public String getColumnText(Object element, int columnIndex) { |
66 //if (element instanceof MyModel) { | 65 //if (element instanceof MyModel) { |
67 switch (columnIndex) { | 66 switch (columnIndex) { |
68 case 0: return (cast(MyModel)element).col1; | 67 case 0: return (cast(MyModel)element).col1; |
69 case 1: return (cast(MyModel)element).col2; | 68 case 1: return (cast(MyModel)element).col2; |
70 } | 69 } |
71 //} | 70 //} |
224 Table table = (cast(TableItem) e.item).getParent(); | 223 Table table = (cast(TableItem) e.item).getParent(); |
225 | 224 |
226 /* Construct the new Selection[] to show */ | 225 /* Construct the new Selection[] to show */ |
227 TableItem [] newSelection = null; | 226 TableItem [] newSelection = null; |
228 if (isCTRLDown(event)) { | 227 if (isCTRLDown(event)) { |
229 /* We have 2 scenario's. | 228 /* We have 2 scenario's. |
230 * 1) We are selecting an already selected element - so remove it from the selected indices | 229 * 1) We are selecting an already selected element - so remove it from the selected indices |
231 * 2) We are selecting a non-selected element - so add it to the selected indices | 230 * 2) We are selecting a non-selected element - so add it to the selected indices |
232 */ | 231 */ |
233 TableItem[] sel = table.getSelection(); | 232 TableItem[] sel = table.getSelection(); |
234 for (int i = 0; i < sel.length; ++i) { | 233 for (int i = 0; i < sel.length; ++i) { |