1414import org .eclipse .swt .*;
1515import org .eclipse .swt .events .SelectionAdapter ;
1616import org .eclipse .swt .events .SelectionEvent ;
17- import org .eclipse .swt .graphics .Image ;
1817import org .eclipse .swt .graphics .Point ;
1918import org .eclipse .swt .internal .ResizeSystem ;
20- import org .eclipse .swt .internal .xhtml .document ;
2119import org .eclipse .swt .layout .GridData ;
2220import org .eclipse .swt .layout .GridLayout ;
2321
4543 * public Object open () {
4644 * Shell parent = getParent();
4745 * Shell shell = new Shell(parent, SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL);
46+ * // remove following "-"
47+ * /-**
48+ * * @-j2sNative
49+ * * this.dialogShell = shell;
50+ * *-/ {}
4851 * shell.setText(getText());
4952 * // Your code goes here (widget creation, set result, etc).
5053 * shell.open();
5154 * Display display = parent.getDisplay();
5255 * while (!shell.isDisposed()) {
5356 * if (!display.readAndDispatch()) display.sleep();
5457 * }
58+ * // remove following "-"
59+ * /-**
60+ * * @-j2sNative
61+ * * this.dialogReturn = this.result;
62+ * *-/ {}
5563 * return result;
5664 * }
5765 * }
7987 * </p>
8088 *
8189 * @see Shell
90+ * @j2sSuffix
91+ DialogSync2Async = {};
92+ DialogSync2Async.block = function (dialog, oThis, runnable) {
93+ if (dialog == null) return;
94+ dialog.open();
95+ var shell = dialog.dialogShell;
96+ if (shell == null) return;
97+ shell.addDisposeListener ((function (innerThis, finalVars) {
98+ if (!Clazz.isClassDefined ("DialogSync2Async$1")) {
99+ Clazz.pu$h ();
100+ cla$$ = DialogSync2Async$1 = function () {
101+ Clazz.prepareCallback (this, arguments);
102+ Clazz.instantialize (this, arguments);
103+ };
104+ Clazz.decorateAsType (cla$$, "DialogSync2Async$1", null, $wt.events.DisposeListener);
105+ Clazz.defineMethod (cla$$, "widgetDisposed",
106+ function (e) {
107+ var $runnable = this.f$.runnable;
108+ var $oThis = this.f$.oThis;
109+ window.setTimeout (function () {
110+ $runnable.apply ($oThis);
111+ }, 0);
112+ //this.f$.runnable.apply (this.f$.oThis);
113+ }, "$wt.events.DisposeEvent");
114+ cla$$ = Clazz.p0p ();
115+ }
116+ return Clazz.innerTypeInstance (DialogSync2Async$1, innerThis, finalVars);
117+ }) (this, Clazz.cloneFinals ("runnable", runnable, "oThis", oThis)));
118+ shell.getDisplay ().readAndDispatch ();
119+ };
82120 */
83121
84122public abstract class Dialog {
85123 int style ;
86124 Shell parent ;
87125 String title ;
126+ Shell dialogShell ;
127+ Object dialogReturn ;
88128
89129/**
90130 * Constructs a new instance of this class given only its
@@ -257,7 +297,7 @@ public void setText (String string) {
257297
258298
259299protected void dialogUnimplemented () {
260- final Shell dialogShell = new Shell (parent .display , style | SWT .CLOSE | SWT .BORDER );
300+ dialogShell = new Shell (parent .display , style | SWT .CLOSE | SWT .BORDER | SWT . SHELL_TRIM );
261301 dialogShell .addListener (SWT .Close , new Listener () {
262302 public void handleEvent (Event event ) {
263303 //updateReturnCode();
@@ -267,7 +307,7 @@ public void handleEvent(Event event) {
267307 dialogShell .setLayout (new GridLayout (2 , false ));
268308
269309 Label icon = new Label (dialogShell , SWT .NONE );
270- icon .setImage (new Image ( dialogShell .display , "j2slib/images/warning.png" ));
310+ icon .setImage (parent .display . getSystemImage ( SWT . ICON_WARNING ));
271311 GridData gridData = new GridData (32 , 32 );
272312 icon .setLayoutData (gridData );
273313
0 commit comments