File tree Expand file tree Collapse file tree 12 files changed +52
-31
lines changed
Expand file tree Collapse file tree 12 files changed +52
-31
lines changed Original file line number Diff line number Diff line change 2020 * A callback object is provided for action to be executed after the class is
2121 * loaded.
2222 *
23- * @author josson smith
23+ * @author zhou renjian
2424 *
2525 * 2006-8-4
2626 */
Original file line number Diff line number Diff line change 1818 * give convenience for <code>AClass</code> or <code>ASWTClass</code>
1919 * to set and to get the class that is loaded.
2020 *
21- * @author josson smith
21+ * @author zhou renjian
2222 *
2323 * 2006-8-4
2424 */
Original file line number Diff line number Diff line change 3838 * This class can be considered as a bridge of Java's AJAX programming and
3939 * JavaScript/Browser's AJAX programming.
4040 *
41- * @author josson smith
41+ * @author zhou renjian
4242 *
4343 * 2006-2-11
4444 */
Original file line number Diff line number Diff line change 3030 * 4 Loaded<br>
3131 * The data transfer has been completed.<br>
3232 *
33- * @author josson smith
33+ * @author zhou renjian
3434 *
3535 * 2006-2-11
3636 */
Original file line number Diff line number Diff line change 1616/**
1717 * This adapter provides a default implementation of IXHRCallback.
1818 *
19- * @author josson smith
19+ * @author zhou renjian
2020 *
2121 * 2006-2-11
2222 */
Original file line number Diff line number Diff line change 1717import java .net .URLEncoder ;
1818
1919/**
20- * @author josson smith
20+ * @author zhou renjian
2121 *
2222 * 2006-10-10
2323 */
@@ -47,10 +47,21 @@ public static void switchToLocalJavaThreadMode() {
4747 * runnable.ajaxIn ();
4848 * net.sf.j2s.ajax.SimpleRPCRequest.ajaxRequest (runnable);
4949 */
50- public static void request (SimpleRPCRunnable runnable ) {
50+ public static void request (final SimpleRPCRunnable runnable ) {
5151 runnable .ajaxIn ();
5252 if (runningMode == MODE_LOCAL_JAVA_THREAD ) {
53- new Thread (runnable ).start ();
53+ new Thread (new Runnable () {
54+ public void run () {
55+ try {
56+ runnable .ajaxRun ();
57+ } catch (RuntimeException e ) {
58+ e .printStackTrace (); // should never fail in Java thread mode!
59+ runnable .ajaxFail ();
60+ return ;
61+ }
62+ runnable .ajaxOut ();
63+ }
64+ }).start ();
5465 } else {
5566 ajaxRequest (runnable );
5667 }
Original file line number Diff line number Diff line change 1919 *
2020 * 2006-10-10
2121 */
22- public abstract class SimpleRPCRunnable extends SimpleSerializable implements Runnable {
22+ public abstract class SimpleRPCRunnable extends SimpleSerializable {
2323
2424 public String getHttpURL () {
2525 return "simplerpc" ; // url is relative to the servlet!
@@ -51,19 +51,4 @@ public String getHttpMethod() {
5151 */
5252 public void ajaxFail () {};
5353
54- /**
55- * @j2sNative
56- * net.sf.j2s.ajax.ServletThread.call(this);
57- */
58- public void run () {
59- // ajaxIn(); // ajaxIn should be run outside of #run directly
60- try {
61- ajaxRun ();
62- } catch (RuntimeException e ) {
63- e .printStackTrace (); // should never fail in Java thread mode!
64- ajaxFail ();
65- return ;
66- }
67- ajaxOut ();
68- }
6954}
Original file line number Diff line number Diff line change 1818import org .eclipse .swt .widgets .Display ;
1919
2020/**
21- * @author josson smith
21+ * @author zhou renjian
2222 *
2323 * 2006-10-10
2424 */
@@ -29,10 +29,35 @@ public class SimpleRPCSWTRequest extends SimpleRPCRequest {
2929 * runnable.ajaxIn ();
3030 * net.sf.j2s.ajax.SimpleRPCRequest.ajaxRequest (runnable);
3131 */
32- public static void swtRequest (SimpleRPCRunnable runnable ) {
32+ public static void swtRequest (final SimpleRPCRunnable runnable ) {
3333 runnable .ajaxIn ();
3434 if (runningMode == MODE_LOCAL_JAVA_THREAD ) {
35- Display .getDefault ().asyncExec (runnable );
35+ new Thread (new Runnable (){
36+ public void run () {
37+ try {
38+ runnable .ajaxRun ();
39+ } catch (RuntimeException e ) {
40+ e .printStackTrace (); // should never fail in Java thread mode!
41+ Display disp = Display .getDefault ();
42+ if (disp != null ) {
43+ disp .syncExec (new Runnable () {
44+ public void run () {
45+ runnable .ajaxFail ();
46+ }
47+ });
48+ }
49+ return ;
50+ }
51+ Display disp = Display .getDefault ();
52+ if (disp != null ) {
53+ disp .syncExec (new Runnable () {
54+ public void run () {
55+ runnable .ajaxOut ();
56+ }
57+ });
58+ }
59+ }
60+ }).start ();
3661 } else {
3762 swtAJAXRequest (runnable );
3863 }
Original file line number Diff line number Diff line change 2222import java .util .Set ;
2323
2424/**
25- * @author josson smith
25+ * @author zhou renjian
2626 *
2727 * 2006-10-11
2828 */
Original file line number Diff line number Diff line change @@ -33,7 +33,7 @@ public void run() {
3333 * parameter as <code>AClass#load</code>. Or call <code>ASWTClass#shellLoad</code>
3434 * or <code>ASWTClass#displayLoad</code> with extra Shell/Display argument.
3535 *
36- * @author josson smith
36+ * @author zhou renjian
3737 *
3838 * 2006-8-4
3939 */
You can’t perform that action at this time.
0 commit comments