28
|
1 /*******************************************************************************
|
|
2 * Copyright (c) 2000, 2004 IBM Corporation and others.
|
|
3 * All rights reserved. This program and the accompanying materials
|
|
4 * are made available under the terms of the Eclipse Public License v1.0
|
|
5 * which accompanies this distribution, and is available at
|
|
6 * http://www.eclipse.org/legal/epl-v10.html
|
|
7 *
|
|
8 * Contributors:
|
|
9 * IBM Corporation - initial API and implementation
|
|
10 * D Port:
|
|
11 * Thomas Demmer <t_demmer AT web DOT de>
|
|
12 *******************************************************************************/
|
|
13 module org.eclipse.swt.snippets.Snippet44;
|
|
14
|
|
15 /*
|
|
16 * Cursor example snippet: set the hand cursor into a control
|
|
17 *
|
|
18 * For a list of all SWT example snippets see
|
|
19 * http://www.eclipse.org/swt/snippets/
|
|
20 */
|
|
21 import org.eclipse.swt.SWT;
|
|
22 import org.eclipse.swt.graphics.Cursor;
|
|
23 import org.eclipse.swt.widgets.Button;
|
|
24 import org.eclipse.swt.widgets.Display;
|
|
25 import org.eclipse.swt.widgets.Event;
|
|
26 import org.eclipse.swt.widgets.Listener;
|
|
27 import org.eclipse.swt.widgets.Shell;
|
|
28
|
|
29 import java.lang.all;
|
|
30
|
78
|
31 import org.eclipse.core.runtime.jobs.Job;
|
|
32 import org.eclipse.core.runtime.IProgressMonitor;
|
|
33 import org.eclipse.core.runtime.IStatus;
|
|
34 import org.eclipse.core.runtime.Status;
|
|
35 import org.eclipse.core.runtime.jobs.IJobChangeListener;
|
|
36 import tango.io.Stdout;
|
|
37
|
|
38 class MyJob : Job {
|
|
39 this(char[] name) {
|
|
40 super(name);
|
|
41 }
|
|
42 public IStatus run(IProgressMonitor monitor) {
|
|
43 Stdout.formatln("doing job");
|
|
44 return Status.OK_STATUS;
|
|
45 }
|
|
46 }
|
|
47
|
|
48
|
28
|
49 void main (String [] args) {
|
|
50 Display display = new Display ();
|
|
51 Cursor cursor = new Cursor (display, SWT.CURSOR_HAND);
|
|
52 Shell shell = new Shell (display);
|
|
53 shell.open ();
|
|
54 Button b = new Button (shell, 0);
|
|
55 b.setBounds (10, 10, 200, 200);
|
|
56 b.addListener (SWT.Selection, new class() Listener{
|
|
57 public void handleEvent (Event e) {
|
78
|
58 //b.setCursor (cursor);
|
|
59 auto job = new MyJob("test");
|
|
60 job.schedule();
|
|
61 job.join;
|
|
62 Stdout.formatln("job done");
|
28
|
63 }
|
|
64 });
|
|
65 while (!shell.isDisposed ()) {
|
|
66 if (!display.readAndDispatch ()) display.sleep ();
|
|
67 }
|
|
68 cursor.dispose ();
|
|
69 display.dispose ();
|
|
70 }
|
|
71
|