annotate jface/snippets/Snippet007FullSelection.d @ 89:cbba80cceb7a

Port of jface Snippets 1,2,4,5,7
author Bill Baxter <bill@billbaxter.com>
date Mon, 19 May 2008 23:42:48 +0900
parents
children 42c3056512ba
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
89
cbba80cceb7a Port of jface Snippets 1,2,4,5,7
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
1 /*******************************************************************************
cbba80cceb7a Port of jface Snippets 1,2,4,5,7
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
2 * Copyright (c) 2006 Tom Schindl and others.
cbba80cceb7a Port of jface Snippets 1,2,4,5,7
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
3 * All rights reserved. This program and the accompanying materials
cbba80cceb7a Port of jface Snippets 1,2,4,5,7
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
4 * are made available under the terms of the Eclipse Public License v1.0
cbba80cceb7a Port of jface Snippets 1,2,4,5,7
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
5 * which accompanies this distribution, and is available at
cbba80cceb7a Port of jface Snippets 1,2,4,5,7
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
6 * http://www.eclipse.org/legal/epl-v10.html
cbba80cceb7a Port of jface Snippets 1,2,4,5,7
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
7 *
cbba80cceb7a Port of jface Snippets 1,2,4,5,7
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
8 * Contributors:
cbba80cceb7a Port of jface Snippets 1,2,4,5,7
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
9 * Tom Schindl - initial API and implementation
cbba80cceb7a Port of jface Snippets 1,2,4,5,7
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
10 *******************************************************************************/
cbba80cceb7a Port of jface Snippets 1,2,4,5,7
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
11
cbba80cceb7a Port of jface Snippets 1,2,4,5,7
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
12 module jface.snippets.Snippet007FullSelection;
cbba80cceb7a Port of jface Snippets 1,2,4,5,7
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
13
cbba80cceb7a Port of jface Snippets 1,2,4,5,7
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
14 import dwtx.jface.viewers.CellEditor;
cbba80cceb7a Port of jface Snippets 1,2,4,5,7
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
15 import dwtx.jface.viewers.ICellModifier;
cbba80cceb7a Port of jface Snippets 1,2,4,5,7
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
16 import dwtx.jface.viewers.IStructuredContentProvider;
cbba80cceb7a Port of jface Snippets 1,2,4,5,7
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
17 import dwtx.jface.viewers.LabelProvider;
cbba80cceb7a Port of jface Snippets 1,2,4,5,7
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
18 import dwtx.jface.viewers.TableViewer;
cbba80cceb7a Port of jface Snippets 1,2,4,5,7
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
19 import dwtx.jface.viewers.TextCellEditor;
cbba80cceb7a Port of jface Snippets 1,2,4,5,7
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
20 import dwtx.jface.viewers.Viewer;
cbba80cceb7a Port of jface Snippets 1,2,4,5,7
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
21 import dwt.DWT;
cbba80cceb7a Port of jface Snippets 1,2,4,5,7
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
22 import dwt.graphics.Color;
cbba80cceb7a Port of jface Snippets 1,2,4,5,7
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
23 import dwt.graphics.GC;
cbba80cceb7a Port of jface Snippets 1,2,4,5,7
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
24 import dwt.graphics.Point;
cbba80cceb7a Port of jface Snippets 1,2,4,5,7
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
25 import dwt.graphics.Rectangle;
cbba80cceb7a Port of jface Snippets 1,2,4,5,7
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
26 import dwt.layout.FillLayout;
cbba80cceb7a Port of jface Snippets 1,2,4,5,7
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
27 import dwt.widgets.Display;
cbba80cceb7a Port of jface Snippets 1,2,4,5,7
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
28 import dwt.widgets.Event;
cbba80cceb7a Port of jface Snippets 1,2,4,5,7
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
29 import dwt.widgets.Listener;
cbba80cceb7a Port of jface Snippets 1,2,4,5,7
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
30 import dwt.widgets.Shell;
cbba80cceb7a Port of jface Snippets 1,2,4,5,7
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
31 import dwt.widgets.TableColumn;
cbba80cceb7a Port of jface Snippets 1,2,4,5,7
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
32 import dwt.widgets.TableItem;
cbba80cceb7a Port of jface Snippets 1,2,4,5,7
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
33
cbba80cceb7a Port of jface Snippets 1,2,4,5,7
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
34 import dwt.dwthelper.utils;
cbba80cceb7a Port of jface Snippets 1,2,4,5,7
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
35
cbba80cceb7a Port of jface Snippets 1,2,4,5,7
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
36 import tango.util.Convert;
cbba80cceb7a Port of jface Snippets 1,2,4,5,7
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
37 import tango.util.collection.ArraySeq;
cbba80cceb7a Port of jface Snippets 1,2,4,5,7
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
38
cbba80cceb7a Port of jface Snippets 1,2,4,5,7
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
39 /**
cbba80cceb7a Port of jface Snippets 1,2,4,5,7
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
40 * TableViewer: Hide full selection
cbba80cceb7a Port of jface Snippets 1,2,4,5,7
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
41 *
cbba80cceb7a Port of jface Snippets 1,2,4,5,7
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
42 * @author Tom Schindl <tom.schindl@bestsolution.at>
cbba80cceb7a Port of jface Snippets 1,2,4,5,7
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
43 *
cbba80cceb7a Port of jface Snippets 1,2,4,5,7
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
44 */
cbba80cceb7a Port of jface Snippets 1,2,4,5,7
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
45 public class Snippet007FullSelection {
cbba80cceb7a Port of jface Snippets 1,2,4,5,7
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
46 alias ArraySeq!(MyModel) MyModelArray;
cbba80cceb7a Port of jface Snippets 1,2,4,5,7
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
47
cbba80cceb7a Port of jface Snippets 1,2,4,5,7
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
48 private class MyContentProvider : IStructuredContentProvider {
cbba80cceb7a Port of jface Snippets 1,2,4,5,7
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
49
cbba80cceb7a Port of jface Snippets 1,2,4,5,7
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
50 /* (non-Javadoc)
cbba80cceb7a Port of jface Snippets 1,2,4,5,7
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
51 * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object)
cbba80cceb7a Port of jface Snippets 1,2,4,5,7
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
52 */
cbba80cceb7a Port of jface Snippets 1,2,4,5,7
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
53 public Object[] getElements(Object inputElement) {
cbba80cceb7a Port of jface Snippets 1,2,4,5,7
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
54 return (cast(MyModelArray)inputElement).toArray;
cbba80cceb7a Port of jface Snippets 1,2,4,5,7
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
55 }
cbba80cceb7a Port of jface Snippets 1,2,4,5,7
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
56
cbba80cceb7a Port of jface Snippets 1,2,4,5,7
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
57 /* (non-Javadoc)
cbba80cceb7a Port of jface Snippets 1,2,4,5,7
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
58 * @see org.eclipse.jface.viewers.IContentProvider#dispose()
cbba80cceb7a Port of jface Snippets 1,2,4,5,7
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
59 */
cbba80cceb7a Port of jface Snippets 1,2,4,5,7
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
60 public void dispose() {
cbba80cceb7a Port of jface Snippets 1,2,4,5,7
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
61
cbba80cceb7a Port of jface Snippets 1,2,4,5,7
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
62 }
cbba80cceb7a Port of jface Snippets 1,2,4,5,7
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
63
cbba80cceb7a Port of jface Snippets 1,2,4,5,7
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
64 /* (non-Javadoc)
cbba80cceb7a Port of jface Snippets 1,2,4,5,7
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
65 * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
cbba80cceb7a Port of jface Snippets 1,2,4,5,7
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
66 */
cbba80cceb7a Port of jface Snippets 1,2,4,5,7
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
67 public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
cbba80cceb7a Port of jface Snippets 1,2,4,5,7
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
68
cbba80cceb7a Port of jface Snippets 1,2,4,5,7
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
69 }
cbba80cceb7a Port of jface Snippets 1,2,4,5,7
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
70
cbba80cceb7a Port of jface Snippets 1,2,4,5,7
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
71 }
cbba80cceb7a Port of jface Snippets 1,2,4,5,7
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
72
cbba80cceb7a Port of jface Snippets 1,2,4,5,7
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
73 public class MyModel {
cbba80cceb7a Port of jface Snippets 1,2,4,5,7
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
74 public int counter;
cbba80cceb7a Port of jface Snippets 1,2,4,5,7
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
75
cbba80cceb7a Port of jface Snippets 1,2,4,5,7
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
76 public this(int counter) {
cbba80cceb7a Port of jface Snippets 1,2,4,5,7
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
77 this.counter = counter;
cbba80cceb7a Port of jface Snippets 1,2,4,5,7
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
78 }
cbba80cceb7a Port of jface Snippets 1,2,4,5,7
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
79
cbba80cceb7a Port of jface Snippets 1,2,4,5,7
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
80 public String toString() {
cbba80cceb7a Port of jface Snippets 1,2,4,5,7
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
81 return "Item " ~ to!(char[])(this.counter);
cbba80cceb7a Port of jface Snippets 1,2,4,5,7
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
82 }
cbba80cceb7a Port of jface Snippets 1,2,4,5,7
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
83 }
cbba80cceb7a Port of jface Snippets 1,2,4,5,7
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
84
cbba80cceb7a Port of jface Snippets 1,2,4,5,7
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
85 public this(Shell shell) {
cbba80cceb7a Port of jface Snippets 1,2,4,5,7
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
86 final TableViewer v = new TableViewer(shell,DWT.BORDER|DWT.FULL_SELECTION);
cbba80cceb7a Port of jface Snippets 1,2,4,5,7
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
87 v.setLabelProvider(new LabelProvider());
cbba80cceb7a Port of jface Snippets 1,2,4,5,7
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
88 v.setContentProvider(new MyContentProvider());
cbba80cceb7a Port of jface Snippets 1,2,4,5,7
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
89 v.setCellModifier(new class(v) ICellModifier {
cbba80cceb7a Port of jface Snippets 1,2,4,5,7
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
90 TableViewer v;
cbba80cceb7a Port of jface Snippets 1,2,4,5,7
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
91 this(TableViewer v_) { this.v=v_; }
cbba80cceb7a Port of jface Snippets 1,2,4,5,7
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
92
cbba80cceb7a Port of jface Snippets 1,2,4,5,7
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
93 public bool canModify(Object element, String property) {
cbba80cceb7a Port of jface Snippets 1,2,4,5,7
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
94 return true;
cbba80cceb7a Port of jface Snippets 1,2,4,5,7
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
95 }
cbba80cceb7a Port of jface Snippets 1,2,4,5,7
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
96
cbba80cceb7a Port of jface Snippets 1,2,4,5,7
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
97 public Object getValue(Object element, String property) {
cbba80cceb7a Port of jface Snippets 1,2,4,5,7
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
98 return new ArrayWrapperString( to!(char[])((cast(MyModel)element).counter) );
cbba80cceb7a Port of jface Snippets 1,2,4,5,7
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
99 }
cbba80cceb7a Port of jface Snippets 1,2,4,5,7
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
100
cbba80cceb7a Port of jface Snippets 1,2,4,5,7
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
101 public void modify(Object element, String property, Object value) {
cbba80cceb7a Port of jface Snippets 1,2,4,5,7
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
102 auto item = cast(TableItem)element;
cbba80cceb7a Port of jface Snippets 1,2,4,5,7
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
103 auto valuestr = cast(ArrayWrapperString)value;
cbba80cceb7a Port of jface Snippets 1,2,4,5,7
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
104 (cast(MyModel)item.getData()).counter = to!(int)(valuestr.array);
cbba80cceb7a Port of jface Snippets 1,2,4,5,7
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
105 v.update(item.getData(), null);
cbba80cceb7a Port of jface Snippets 1,2,4,5,7
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
106 }
cbba80cceb7a Port of jface Snippets 1,2,4,5,7
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
107
cbba80cceb7a Port of jface Snippets 1,2,4,5,7
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
108 });
cbba80cceb7a Port of jface Snippets 1,2,4,5,7
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
109 v.setColumnProperties(["column1", "column2" ]);
cbba80cceb7a Port of jface Snippets 1,2,4,5,7
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
110 v.setCellEditors([ new TextCellEditor(v.getTable()),new TextCellEditor(v.getTable()) ]);
cbba80cceb7a Port of jface Snippets 1,2,4,5,7
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
111
cbba80cceb7a Port of jface Snippets 1,2,4,5,7
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
112 TableColumn column = new TableColumn(v.getTable(),DWT.NONE);
cbba80cceb7a Port of jface Snippets 1,2,4,5,7
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
113 column.setWidth(100);
cbba80cceb7a Port of jface Snippets 1,2,4,5,7
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
114 column.setText("Column 1");
cbba80cceb7a Port of jface Snippets 1,2,4,5,7
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
115
cbba80cceb7a Port of jface Snippets 1,2,4,5,7
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
116 column = new TableColumn(v.getTable(),DWT.NONE);
cbba80cceb7a Port of jface Snippets 1,2,4,5,7
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
117 column.setWidth(100);
cbba80cceb7a Port of jface Snippets 1,2,4,5,7
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
118 column.setText("Column 2");
cbba80cceb7a Port of jface Snippets 1,2,4,5,7
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
119
cbba80cceb7a Port of jface Snippets 1,2,4,5,7
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
120 MyModelArray model = createModel();
cbba80cceb7a Port of jface Snippets 1,2,4,5,7
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
121 v.setInput(model);
cbba80cceb7a Port of jface Snippets 1,2,4,5,7
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
122 v.getTable().setLinesVisible(true);
cbba80cceb7a Port of jface Snippets 1,2,4,5,7
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
123 v.getTable().setHeaderVisible(true);
cbba80cceb7a Port of jface Snippets 1,2,4,5,7
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
124
cbba80cceb7a Port of jface Snippets 1,2,4,5,7
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
125 v.getTable().addListener(DWT.EraseItem, new class Listener {
cbba80cceb7a Port of jface Snippets 1,2,4,5,7
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
126
cbba80cceb7a Port of jface Snippets 1,2,4,5,7
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
127 /* (non-Javadoc)
cbba80cceb7a Port of jface Snippets 1,2,4,5,7
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
128 * @see org.eclipse.swt.widgets.Listener#handleEvent(org.eclipse.swt.widgets.Event)
cbba80cceb7a Port of jface Snippets 1,2,4,5,7
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
129 */
cbba80cceb7a Port of jface Snippets 1,2,4,5,7
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
130 public void handleEvent(Event event) {
cbba80cceb7a Port of jface Snippets 1,2,4,5,7
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
131 event.detail &= ~DWT.SELECTED;
cbba80cceb7a Port of jface Snippets 1,2,4,5,7
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
132 }
cbba80cceb7a Port of jface Snippets 1,2,4,5,7
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
133 });
cbba80cceb7a Port of jface Snippets 1,2,4,5,7
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
134
cbba80cceb7a Port of jface Snippets 1,2,4,5,7
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
135 }
cbba80cceb7a Port of jface Snippets 1,2,4,5,7
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
136
cbba80cceb7a Port of jface Snippets 1,2,4,5,7
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
137 private MyModelArray createModel() {
cbba80cceb7a Port of jface Snippets 1,2,4,5,7
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
138 auto elements = new MyModelArray;
cbba80cceb7a Port of jface Snippets 1,2,4,5,7
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
139 elements.capacity = 10;
cbba80cceb7a Port of jface Snippets 1,2,4,5,7
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
140
cbba80cceb7a Port of jface Snippets 1,2,4,5,7
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
141 for( int i = 0; i < 10; i++ ) {
cbba80cceb7a Port of jface Snippets 1,2,4,5,7
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
142 elements ~= new MyModel(i);
cbba80cceb7a Port of jface Snippets 1,2,4,5,7
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
143 }
cbba80cceb7a Port of jface Snippets 1,2,4,5,7
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
144
cbba80cceb7a Port of jface Snippets 1,2,4,5,7
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
145 return elements;
cbba80cceb7a Port of jface Snippets 1,2,4,5,7
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
146 }
cbba80cceb7a Port of jface Snippets 1,2,4,5,7
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
147
cbba80cceb7a Port of jface Snippets 1,2,4,5,7
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
148 }
cbba80cceb7a Port of jface Snippets 1,2,4,5,7
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
149
cbba80cceb7a Port of jface Snippets 1,2,4,5,7
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
150
cbba80cceb7a Port of jface Snippets 1,2,4,5,7
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
151 void main() {
cbba80cceb7a Port of jface Snippets 1,2,4,5,7
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
152 Display display = new Display ();
cbba80cceb7a Port of jface Snippets 1,2,4,5,7
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
153 Shell shell = new Shell(display);
cbba80cceb7a Port of jface Snippets 1,2,4,5,7
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
154 shell.setLayout(new FillLayout());
cbba80cceb7a Port of jface Snippets 1,2,4,5,7
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
155 new Snippet007FullSelection(shell);
cbba80cceb7a Port of jface Snippets 1,2,4,5,7
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
156 shell.open ();
cbba80cceb7a Port of jface Snippets 1,2,4,5,7
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
157
cbba80cceb7a Port of jface Snippets 1,2,4,5,7
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
158 while (!shell.isDisposed ()) {
cbba80cceb7a Port of jface Snippets 1,2,4,5,7
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
159 if (!display.readAndDispatch ()) display.sleep ();
cbba80cceb7a Port of jface Snippets 1,2,4,5,7
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
160 }
cbba80cceb7a Port of jface Snippets 1,2,4,5,7
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
161
cbba80cceb7a Port of jface Snippets 1,2,4,5,7
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
162 display.dispose ();
cbba80cceb7a Port of jface Snippets 1,2,4,5,7
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
163
cbba80cceb7a Port of jface Snippets 1,2,4,5,7
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
164 }
cbba80cceb7a Port of jface Snippets 1,2,4,5,7
Bill Baxter <bill@billbaxter.com>
parents:
diff changeset
165