Mercurial > projects > dwt2
comparison org.eclipse.jface.snippets/EclipseJfaceSnippets/org/eclipse/jface/snippets/wizard/Snippet047WizardWithLongRunningOperation.d @ 32:c4b36186a9bc
Renamings
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Mon, 23 Mar 2009 11:25:49 +0100 |
parents | 5d87d4191adf |
children | a8a838017920 |
comparison
equal
deleted
inserted
replaced
31:5d87d4191adf | 32:c4b36186a9bc |
---|---|
10 * Port to the D programming language: | 10 * Port to the D programming language: |
11 * Frank Benoit <benoit@tionex.de> | 11 * Frank Benoit <benoit@tionex.de> |
12 *******************************************************************************/ | 12 *******************************************************************************/ |
13 module jface.snippets.wizard.Snippet047WizardWithLongRunningOperation; | 13 module jface.snippets.wizard.Snippet047WizardWithLongRunningOperation; |
14 | 14 |
15 import dwtx.jface.viewers.ArrayContentProvider; | 15 import org.eclipse.jface.viewers.ArrayContentProvider; |
16 import dwtx.jface.viewers.ISelectionChangedListener; | 16 import org.eclipse.jface.viewers.ISelectionChangedListener; |
17 import dwtx.jface.viewers.SelectionChangedEvent; | 17 import org.eclipse.jface.viewers.SelectionChangedEvent; |
18 import dwtx.jface.viewers.TableViewer; | 18 import org.eclipse.jface.viewers.TableViewer; |
19 import dwtx.jface.wizard.IWizardPage; | 19 import org.eclipse.jface.wizard.IWizardPage; |
20 import dwtx.jface.wizard.Wizard; | 20 import org.eclipse.jface.wizard.Wizard; |
21 import dwtx.jface.wizard.WizardDialog; | 21 import org.eclipse.jface.wizard.WizardDialog; |
22 import dwtx.jface.wizard.WizardPage; | 22 import org.eclipse.jface.wizard.WizardPage; |
23 import dwt.DWT; | 23 import org.eclipse.swt.SWT; |
24 import dwt.events.SelectionAdapter; | 24 import org.eclipse.swt.events.SelectionAdapter; |
25 import dwt.events.SelectionEvent; | 25 import org.eclipse.swt.events.SelectionEvent; |
26 import dwt.layout.FillLayout; | 26 import org.eclipse.swt.layout.FillLayout; |
27 import dwt.layout.GridData; | 27 import org.eclipse.swt.layout.GridData; |
28 import dwt.layout.GridLayout; | 28 import org.eclipse.swt.layout.GridLayout; |
29 import dwt.widgets.Button; | 29 import org.eclipse.swt.widgets.Button; |
30 import dwt.widgets.Composite; | 30 import org.eclipse.swt.widgets.Composite; |
31 import dwt.widgets.Display; | 31 import org.eclipse.swt.widgets.Display; |
32 import dwt.widgets.Label; | 32 import org.eclipse.swt.widgets.Label; |
33 import dwt.widgets.ProgressBar; | 33 import org.eclipse.swt.widgets.ProgressBar; |
34 import dwt.widgets.Shell; | 34 import org.eclipse.swt.widgets.Shell; |
35 | 35 |
36 import dwt.dwthelper.utils; | 36 import java.lang.all; |
37 import dwt.dwthelper.Runnable; | 37 import java.utils.ArrayList; |
38 import dwtx.dwtxhelper.Collection; | 38 |
39 import tango.core.Thread; | 39 import java.lang.Thread; |
40 import tango.text.convert.Format; | 40 import tango.text.convert.Format; |
41 import tango.util.log.Trace; | 41 |
42 | 42 import org.eclipse.jface.operation.ModalContext; |
43 import dwtx.jface.operation.ModalContext; | |
44 | 43 |
45 /** | 44 /** |
46 * Example how to load data from a background thread into a TableViewer | 45 * Example how to load data from a background thread into a TableViewer |
47 * | 46 * |
48 * @author Tom Schindl <tom.schindl@bestsolution.at> | 47 * @author Tom Schindl <tom.schindl@bestsolution.at> |
59 } | 58 } |
60 | 59 |
61 /* | 60 /* |
62 * (non-Javadoc) | 61 * (non-Javadoc) |
63 * | 62 * |
64 * @see dwtx.jface.wizard.Wizard#addPages() | 63 * @see org.eclipse.jface.wizard.Wizard#addPages() |
65 */ | 64 */ |
66 public void addPages() { | 65 public void addPages() { |
67 addPage(new MyWizardPageThread("Thread Page", loadingType)); | 66 addPage(new MyWizardPageThread("Thread Page", loadingType)); |
68 addPage(new MyWizardPage("Standard Page")); | 67 addPage(new MyWizardPage("Standard Page")); |
69 } | 68 } |
73 } | 72 } |
74 | 73 |
75 /* | 74 /* |
76 * (non-Javadoc) | 75 * (non-Javadoc) |
77 * | 76 * |
78 * @see dwtx.jface.wizard.Wizard#canFinish() | 77 * @see org.eclipse.jface.wizard.Wizard#canFinish() |
79 */ | 78 */ |
80 public bool canFinish() { | 79 public bool canFinish() { |
81 IWizardPage[] pages = getPages(); | 80 IWizardPage[] pages = getPages(); |
82 for (int i = 0; i < pages.length; i++) { | 81 for (int i = 0; i < pages.length; i++) { |
83 if (!pages[i].isPageComplete()) { | 82 if (!pages[i].isPageComplete()) { |
96 super(pageName); | 95 super(pageName); |
97 setTitle(pageName); | 96 setTitle(pageName); |
98 } | 97 } |
99 | 98 |
100 public /+override+/ void createControl(Composite parent) { | 99 public /+override+/ void createControl(Composite parent) { |
101 Composite comp = new Composite(parent, DWT.NONE); | 100 Composite comp = new Composite(parent, SWT.NONE); |
102 setControl(comp); | 101 setControl(comp); |
103 } | 102 } |
104 } | 103 } |
105 | 104 |
106 private static class MyWizardPageThread : WizardPage { | 105 private static class MyWizardPageThread : WizardPage { |
116 | 115 |
117 public /+override+/ void createControl(Composite parent) { | 116 public /+override+/ void createControl(Composite parent) { |
118 auto mt = new MyThread(); | 117 auto mt = new MyThread(); |
119 mt.parent = parent; | 118 mt.parent = parent; |
120 | 119 |
121 mt.comp = new Composite(parent, DWT.NONE); | 120 mt.comp = new Composite(parent, SWT.NONE); |
122 mt.comp.setLayout(new GridLayout(1, false)); | 121 mt.comp.setLayout(new GridLayout(1, false)); |
123 | 122 |
124 v = new TableViewer(mt.comp, DWT.FULL_SELECTION); | 123 v = new TableViewer(mt.comp, SWT.FULL_SELECTION); |
125 v.setContentProvider(new ArrayContentProvider!(Object)()); | 124 v.setContentProvider(new ArrayContentProvider!(Object)()); |
126 v.getTable().setLayoutData(new GridData(GridData.FILL_BOTH)); | 125 v.getTable().setLayoutData(new GridData(GridData.FILL_BOTH)); |
127 v.addSelectionChangedListener(new class ISelectionChangedListener { | 126 v.addSelectionChangedListener(new class ISelectionChangedListener { |
128 | 127 |
129 public void selectionChanged(SelectionChangedEvent event) { | 128 public void selectionChanged(SelectionChangedEvent event) { |
130 getWizard().getContainer().updateButtons(); | 129 getWizard().getContainer().updateButtons(); |
131 } | 130 } |
132 | 131 |
133 }); | 132 }); |
134 | 133 |
135 mt.barContainer = new Composite(mt.comp, DWT.NONE); | 134 mt.barContainer = new Composite(mt.comp, SWT.NONE); |
136 mt.barContainer.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); | 135 mt.barContainer.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); |
137 mt.barContainer.setLayout(new GridLayout(2, false)); | 136 mt.barContainer.setLayout(new GridLayout(2, false)); |
138 | 137 |
139 Label l = new Label(mt.barContainer, DWT.NONE); | 138 Label l = new Label(mt.barContainer, SWT.NONE); |
140 l.setText("Loading Data"); | 139 l.setText("Loading Data"); |
141 | 140 |
142 mt.bar = new ProgressBar(mt.barContainer, | 141 mt.bar = new ProgressBar(mt.barContainer, |
143 (loadingType == 1) ? DWT.INDETERMINATE : DWT.NONE); | 142 (loadingType == 1) ? SWT.INDETERMINATE : SWT.NONE); |
144 mt.bar.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); | 143 mt.bar.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); |
145 | 144 |
146 if (loadingType == 2) { | 145 if (loadingType == 2) { |
147 mt.bar.setMaximum(10); | 146 mt.bar.setMaximum(10); |
148 } | 147 } |
162 private ProgressBar bar; | 161 private ProgressBar bar; |
163 | 162 |
164 private void threadWork(){ | 163 private void threadWork(){ |
165 if (loadingType == 1) { | 164 if (loadingType == 1) { |
166 try { | 165 try { |
167 Thread.sleep(10.000); | 166 Thread.sleep(10_000); |
168 ArrayList ms = new ArrayList(); | 167 ArrayList ms = new ArrayList(); |
169 for (int i = 0; i < 10; i++) { | 168 for (int i = 0; i < 10; i++) { |
170 ms.add(new MyModel(i)); | 169 ms.add(new MyModel(i)); |
171 } | 170 } |
172 | 171 |
200 ms.add(tmp); | 199 ms.add(tmp); |
201 bar.setSelection(j_ + 1); | 200 bar.setSelection(j_ + 1); |
202 }, j )); | 201 }, j )); |
203 | 202 |
204 try { | 203 try { |
205 Thread.sleep(1.000); | 204 Thread.sleep(1_000); |
206 } catch (InterruptedException e) { | 205 } catch (InterruptedException e) { |
207 // TODO Auto-generated catch block | 206 // TODO Auto-generated catch block |
208 ExceptionPrintStackTrace(e); | 207 ExceptionPrintStackTrace(e); |
209 } | 208 } |
210 } | 209 } |
245 Display display = new Display(); | 244 Display display = new Display(); |
246 | 245 |
247 shell = new Shell(display); | 246 shell = new Shell(display); |
248 shell.setLayout(new FillLayout()); | 247 shell.setLayout(new FillLayout()); |
249 | 248 |
250 Button b = new Button(shell, DWT.PUSH); | 249 Button b = new Button(shell, SWT.PUSH); |
251 b.setText("Load in one Chunk"); | 250 b.setText("Load in one Chunk"); |
252 b.addSelectionListener(new class SelectionAdapter { | 251 b.addSelectionListener(new class SelectionAdapter { |
253 | 252 |
254 public void widgetSelected(SelectionEvent e) { | 253 public void widgetSelected(SelectionEvent e) { |
255 WizardDialog dialog = new WizardDialog(shell, new MyWizard(1)); | 254 WizardDialog dialog = new WizardDialog(shell, new MyWizard(1)); |
256 dialog.open(); | 255 dialog.open(); |
257 } | 256 } |
258 | 257 |
259 }); | 258 }); |
260 | 259 |
261 b = new Button(shell, DWT.PUSH); | 260 b = new Button(shell, SWT.PUSH); |
262 b.setText("Load Item by Item"); | 261 b.setText("Load Item by Item"); |
263 b.addSelectionListener(new class SelectionAdapter { | 262 b.addSelectionListener(new class SelectionAdapter { |
264 | 263 |
265 public void widgetSelected(SelectionEvent e) { | 264 public void widgetSelected(SelectionEvent e) { |
266 WizardDialog dialog = new WizardDialog(shell, new MyWizard(2)); | 265 WizardDialog dialog = new WizardDialog(shell, new MyWizard(2)); |