Skip to content

Commit c867ee5

Browse files
author
zhourenjian
committed
1. Adjust packing order of j2slib.z.js to provide a faster loading
2. Add console support to SWT's Console window. 3. Provide another way to load images basing on classpath
1 parent 096e44a commit c867ee5

File tree

5 files changed

+65
-23
lines changed

5 files changed

+65
-23
lines changed

sources/net.sf.j2s.java.core/src/java/lang/Class.js

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1507,20 +1507,24 @@ Clazz.innerFunctions = {
15071507
if (name.indexOf ('/') == 0) {
15081508
//is.url = name.substring (1);
15091509
if (arguments.length == 2) { // additional argument
1510-
baseFolder = ClazzLoader.binaryFolders[0];
1510+
baseFolder = arguments[1];
1511+
if (baseFolder == null) {
1512+
baseFolder = ClazzLoader.binaryFolders[0];
1513+
}
15111514
} else if (window["ClazzLoader"] != null) {
15121515
baseFolder = ClazzLoader.getClasspathFor (clazzName, true);
15131516
}
15141517
if (baseFolder == null || baseFolder.length == 0) {
15151518
is.url = name.substring (1);
1519+
} else {
1520+
baseFolder = baseFolder.replace (/\\/g, '/');
1521+
var length = baseFolder.length;
1522+
var lastChar = baseFolder.charAt (length - 1);
1523+
if (lastChar != '/') {
1524+
baseFolder += "/";
1525+
}
1526+
is.url = baseFolder + name.substring (1);
15161527
}
1517-
baseFolder = baseFolder.replace (/\\/g, '/');
1518-
var length = baseFolder.length;
1519-
var lastChar = baseFolder.charAt (length - 1);
1520-
if (lastChar != '/') {
1521-
baseFolder += "/";
1522-
}
1523-
is.url = baseFolder + name.substring (1);
15241528
} else {
15251529
if (window["ClazzLoader"] != null) {
15261530
baseFolder = ClazzLoader.getClasspathFor (clazzName);

sources/net.sf.j2s.java.core/src/java/lang/ClassExt.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ Clazz.makeFunction = function (jsr) {
337337
jsr.setEvent (e);
338338
}
339339
jsr.run ();
340-
if (e != null) {
340+
if (e != null && jsr.isReturned != null && jsr.isReturned()) {
341341
// Is it correct to stopPropagation here? --Feb 19, 2006
342342
e.cancelBubble = true;
343343
if (e.stopPropagation) {

sources/net.sf.j2s.java.core/src/java/lang/ClassLoaderProgressMonitor.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ clpm.DEFAULT_OPACITY = 55;
7777
var div = document.createElement ("DIV");
7878
div.style.cssText = "position:absolute;top:4px;left:4px;padding:2px 8px;"
7979
+ "z-index:3333;background-color:#8e0000;color:yellow;"
80-
+ "font-family:Arial, sans-serif;white-space:nowrap;";
80+
+ "font-family:Arial, sans-serif;font-size:10pt;white-space:nowrap;";
8181
div.onmouseover = function () {
8282
this.style.display = "none";
8383
};

sources/net.sf.j2s.java.core/src/java/lang/Console.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,9 +358,35 @@ Console.consoleOutput = function (s, color, isBuffered) {
358358
}
359359
}
360360

361+
var cssClazzName = console.parentNode.className;
362+
if (!Console.pinning && cssClazzName != null
363+
&& cssClazzName.indexOf ("composite") != -1) {
364+
console.parentNode.scrollTop = console.parentNode.scrollHeight;
365+
}
361366
Console.lastOutputTime = new Date ().getTime ();
362367
};
363368

369+
/*
370+
* Clear all contents inside the console.
371+
*/
372+
/* public */
373+
Console.clear = function () {
374+
Console.metLineBreak = true;
375+
var console = document.getElementById ("_console_");;
376+
if (console == null) {
377+
if (document.body == null) {
378+
Console.consoleBuffer = [];
379+
}
380+
return;
381+
}
382+
Console.consoleBuffer = [];
383+
var childNodes = console.childNodes;
384+
for (var i = childNodes.length - 1; i >= 0; i--) {
385+
console.removeChild (childNodes[i]);
386+
}
387+
Console.linesCount = 0;
388+
};
389+
364390
/**
365391
* popup is caching the original alert
366392
*/

sources/net.sf.j2s.java.core/src/java/package.js

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,23 +18,11 @@ window["java.registered"] = false;
1818
ClazzLoader.jarClasspath (base + "core.z.js", [
1919
"java.net.URLEncoder",
2020
"java.net.URLDecoder",
21-
21+
2222
"net.sf.j2s.ajax.HttpRequest",
23-
"$.IXHRCallback",
24-
"$.XHRCallbackAdapter",
25-
"$.XHRCallbackSWTAdapter",
2623
"$.ARunnable",
2724
"$.AClass",
2825
"$.ASWTClass",
29-
30-
"$.SimpleSerializable",
31-
"$.SimpleRPCRunnable",
32-
"$.SimpleRPCRequest",
33-
"$.SimpleRPCSWTRequest",
34-
35-
"$.SimplePipeRunnable",
36-
"$.SimplePipeRequest",
37-
"$.SimplePipeSWTRequest"
3826
]);
3927

4028
ClazzLoader.jarClasspath (base + "util/AbstractList.js", [
@@ -102,6 +90,30 @@ window["java.registered"] = false;
10290
"$.Field",
10391
"$.Method"
10492
]);
93+
94+
/* ajax library */
95+
ClazzLoader.jarClasspath (ClazzLoader.getClasspathFor ("net.sf.j2s.ajax.*") + "simple.z.js", [
96+
"net.sf.j2s.ajax.IXHRCallback",
97+
"$.XHRCallbackAdapter",
98+
"$.XHRCallbackSWTAdapter",
99+
100+
"$.SimpleSerializable",
101+
"$.SimpleRPCRunnable",
102+
"$.SimpleRPCRequest",
103+
"$.SimpleRPCSWTRequest",
104+
105+
"$.SimplePipeRunnable",
106+
"$.SimplePipeHelper",
107+
"$.SimplePipeRequest",
108+
"$.SimplePipeSWTRequest",
109+
110+
"$.CompoundSerializable",
111+
"$.CompoundPipeSession",
112+
"$.CompoundPipeRunnable",
113+
"$.CompoundPipeRequest",
114+
"$.CompoundPipeSWTRequest"
115+
]);
116+
105117
ClazzLoader.jarClasspath (base + "lang/StringBuilder.z.js",
106118
["java.lang.AbstractStringBuilder", "$.StringBuilder"]);
107119
base = base.substring (0, base.lastIndexOf ("java/"));

0 commit comments

Comments
 (0)