Mercurial > projects > dwt-samples
comparison jface/snippets/Snippet026TreeViewerTabEditing.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 | 2b4e94cafb85 |
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 * Tom Schindl - initial API and implementation | 9 * Tom Schindl - 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.Snippet026TreeViewerTabEditing; | 14 module jface.snippets.Snippet026TreeViewerTabEditing; |
15 | 15 |
16 | 16 |
37 import dwt.widgets.Button; | 37 import dwt.widgets.Button; |
38 import dwt.widgets.Display; | 38 import dwt.widgets.Display; |
39 import dwt.widgets.Shell; | 39 import dwt.widgets.Shell; |
40 | 40 |
41 import dwt.dwthelper.utils; | 41 import dwt.dwthelper.utils; |
42 import dwtx.dwtxhelper.Collection; | |
42 | 43 |
43 import tango.util.Convert; | 44 import tango.util.Convert; |
44 import tango.util.container.LinkedList; | 45 |
46 version(JIVE) import jive.stacktrace; | |
45 | 47 |
46 | 48 |
47 void main(String[] args) { | 49 void main(String[] args) { |
48 Display display = new Display(); | 50 Display display = new Display(); |
49 Shell shell = new Shell(display); | 51 Shell shell = new Shell(display); |
59 display.dispose(); | 61 display.dispose(); |
60 } | 62 } |
61 | 63 |
62 /** | 64 /** |
63 * A simple TreeViewer to demonstrate usage | 65 * A simple TreeViewer to demonstrate usage |
64 * | 66 * |
65 * @author Tom Schindl <tom.schindl@bestsolution.at> | 67 * @author Tom Schindl <tom.schindl@bestsolution.at> |
66 * | 68 * |
67 */ | 69 */ |
68 public class Snippet026TreeViewerTabEditing { | 70 public class Snippet026TreeViewerTabEditing { |
69 alias LinkedList!(MyModel) ArrayList; | |
70 public this(Shell shell) { | 71 public this(Shell shell) { |
71 Button b = new Button(shell,DWT.PUSH); | 72 Button b = new Button(shell,DWT.PUSH); |
72 b.setText("Remove column"); | 73 b.setText("Remove column"); |
73 final TreeViewer v = new TreeViewer(shell, DWT.BORDER | 74 final TreeViewer v = new TreeViewer(shell, DWT.BORDER |
74 | DWT.FULL_SELECTION); | 75 | DWT.FULL_SELECTION); |
79 this(TreeViewer v_) | 80 this(TreeViewer v_) |
80 { | 81 { |
81 this.v = v_; | 82 this.v = v_; |
82 } | 83 } |
83 public void widgetDefaultSelected(SelectionEvent e) { | 84 public void widgetDefaultSelected(SelectionEvent e) { |
84 | 85 |
85 } | 86 } |
86 | 87 |
87 public void widgetSelected(SelectionEvent e) { | 88 public void widgetSelected(SelectionEvent e) { |
88 v.getTree().getColumn(1).dispose(); | 89 v.getTree().getColumn(1).dispose(); |
89 } | 90 } |
90 | 91 |
91 }); | 92 }); |
92 | 93 |
93 TreeViewerFocusCellManager focusCellManager = new TreeViewerFocusCellManager(v,new FocusCellOwnerDrawHighlighter(v)); | 94 TreeViewerFocusCellManager focusCellManager = new TreeViewerFocusCellManager(v,new FocusCellOwnerDrawHighlighter(v)); |
94 ColumnViewerEditorActivationStrategy actSupport = new class(v) ColumnViewerEditorActivationStrategy { | 95 ColumnViewerEditorActivationStrategy actSupport = new class(v) ColumnViewerEditorActivationStrategy { |
95 this(ColumnViewer v_) | 96 this(ColumnViewer v_) |
96 { | 97 { |
97 super(v_); | 98 super(v_); |
102 || event.eventType == ColumnViewerEditorActivationEvent.MOUSE_DOUBLE_CLICK_SELECTION | 103 || event.eventType == ColumnViewerEditorActivationEvent.MOUSE_DOUBLE_CLICK_SELECTION |
103 || (event.eventType == ColumnViewerEditorActivationEvent.KEY_PRESSED && event.keyCode == DWT.CR) | 104 || (event.eventType == ColumnViewerEditorActivationEvent.KEY_PRESSED && event.keyCode == DWT.CR) |
104 || event.eventType == ColumnViewerEditorActivationEvent.PROGRAMMATIC; | 105 || event.eventType == ColumnViewerEditorActivationEvent.PROGRAMMATIC; |
105 } | 106 } |
106 }; | 107 }; |
107 | 108 |
108 TreeViewerEditor.create(v, focusCellManager, actSupport, ColumnViewerEditor.TABBING_HORIZONTAL | 109 TreeViewerEditor.create(v, focusCellManager, actSupport, ColumnViewerEditor.TABBING_HORIZONTAL |
109 | ColumnViewerEditor.TABBING_MOVE_TO_ROW_NEIGHBOR | 110 | ColumnViewerEditor.TABBING_MOVE_TO_ROW_NEIGHBOR |
110 | ColumnViewerEditor.TABBING_VERTICAL | ColumnViewerEditor.KEYBOARD_ACTIVATION); | 111 | ColumnViewerEditor.TABBING_VERTICAL | ColumnViewerEditor.KEYBOARD_ACTIVATION); |
111 | 112 |
112 final TextCellEditor textCellEditor = new TextCellEditor(v.getTree()); | 113 final TextCellEditor textCellEditor = new TextCellEditor(v.getTree()); |
113 | 114 |
114 TreeViewerColumn column = new TreeViewerColumn(v, DWT.NONE); | 115 TreeViewerColumn column = new TreeViewerColumn(v, DWT.NONE); |
115 column.getColumn().setWidth(200); | 116 column.getColumn().setWidth(200); |
116 column.getColumn().setMoveable(true); | 117 column.getColumn().setMoveable(true); |
176 protected void setValue(Object element, Object value) { | 177 protected void setValue(Object element, Object value) { |
177 (cast(MyModel) element).counter = Integer.parseInt(value.toString()); | 178 (cast(MyModel) element).counter = Integer.parseInt(value.toString()); |
178 v.update(element, null); | 179 v.update(element, null); |
179 } | 180 } |
180 }); | 181 }); |
181 | 182 |
182 column = new TreeViewerColumn(v, DWT.NONE); | 183 column = new TreeViewerColumn(v, DWT.NONE); |
183 column.getColumn().setWidth(200); | 184 column.getColumn().setWidth(200); |
184 column.getColumn().setMoveable(true); | 185 column.getColumn().setMoveable(true); |
185 column.getColumn().setText("Column 3"); | 186 column.getColumn().setText("Column 3"); |
186 column.setLabelProvider(new class() ColumnLabelProvider { | 187 column.setLabelProvider(new class() ColumnLabelProvider { |
209 protected void setValue(Object element, Object value) { | 210 protected void setValue(Object element, Object value) { |
210 (cast(MyModel) element).counter = Integer.parseInt(value.toString()); | 211 (cast(MyModel) element).counter = Integer.parseInt(value.toString()); |
211 v.update(element, null); | 212 v.update(element, null); |
212 } | 213 } |
213 }); | 214 }); |
214 | 215 |
215 v.setContentProvider(new MyContentProvider()); | 216 v.setContentProvider(new MyContentProvider()); |
216 | 217 |
217 v.setInput(createModel()); | 218 v.setInput(createModel()); |
218 } | 219 } |
219 | 220 |
274 public int counter; | 275 public int counter; |
275 | 276 |
276 public this(int counter, MyModel parent) { | 277 public this(int counter, MyModel parent) { |
277 this.parent = parent; | 278 this.parent = parent; |
278 this.counter = counter; | 279 this.counter = counter; |
279 child = new ArrayList(); | 280 child = new ArrayList(); |
280 } | 281 } |
281 | 282 |
282 public String toString() { | 283 public String toString() { |
283 String rv = "Item "; | 284 String rv = "Item "; |
284 if (parent !is null) { | 285 if (parent !is null) { |