Skip to content

Commit 80be262

Browse files
author
jossonsmith
committed
Remove class dependency of org.eclipse.swt.widgets.Display so net.sf.j2s.ajax can
be packed into SWT-independent *.z.js file
1 parent 2aba265 commit 80be262

1 file changed

Lines changed: 16 additions & 7 deletions

File tree

sources/net.sf.j2s.ajax/ajaxswt/net/sf/j2s/ajax/ASWTClass.java

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,17 @@ protected ASWTClass() {
3131
}
3232

3333
public static void swtLoad(String clazzName, Runnable afterLoaded) {
34-
Display display = Display.getCurrent();
35-
if (display == null) {
36-
display = Display.getDefault();
34+
Display display = null;
35+
/**
36+
* @j2sIgnore
37+
*/
38+
{
39+
Display.getCurrent();
40+
if (display == null) {
41+
display = Display.getDefault();
42+
}
3743
}
38-
displayLoad(display, clazzName, afterLoaded);
44+
objectLoad(display, clazzName, afterLoaded);
3945
}
4046

4147

@@ -61,8 +67,8 @@ public static void swtLoad(String clazzName, Runnable afterLoaded) {
6167
* c.run ();
6268
* }, false, true);
6369
*/
64-
public static void displayLoad(Display display, final String clazzName, final Runnable afterLoaded) {
65-
display.asyncExec(new Runnable() {
70+
static void objectLoad(Object display, final String clazzName, final Runnable afterLoaded) {
71+
((Display) display).asyncExec(new Runnable() {
6672
public void run() {
6773
try {
6874
Class clz = Class.forName(clazzName);
@@ -80,7 +86,10 @@ public void run() {
8086
});
8187
}
8288

89+
public static void displayLoad(Display display, final String clazzName, final Runnable afterLoaded) {
90+
objectLoad(display, clazzName, afterLoaded);
91+
}
8392
public static void shellLoad(Shell shell, String clazzName, Runnable afterLoaded) {
84-
displayLoad(shell.getDisplay(), clazzName, afterLoaded);
93+
objectLoad(shell.getDisplay(), clazzName, afterLoaded);
8594
}
8695
}

0 commit comments

Comments
 (0)