Skip to content

Commit 52ec44a

Browse files
author
jossonsmith
committed
Take another loading try to make sure *.css are not missed.
1 parent eadad18 commit 52ec44a

File tree

24 files changed

+803
-657
lines changed

24 files changed

+803
-657
lines changed

sources/net.sf.j2s.java.org.eclipse.swt/src/org/eclipse/swt/custom/CTabFolder.css

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@
153153
background-color:menu;
154154
}
155155

156-
.ctab-item-attach-close-left{
156+
.ctab-item-attach-close-left {
157157
float: right;
158158
border-style:none none none none;
159159
background-image:url('images/ctab-simple-close.gif');
@@ -177,7 +177,7 @@
177177
font-size:8pt;
178178
}
179179

180-
.ctab-item-attach-close-right{
180+
.ctab-item-attach-close-right {
181181
float:right;
182182
width:15px;
183183
overflow:hidden;
@@ -188,7 +188,7 @@
188188
background-color:menu;
189189
}
190190
.ctab-item-attach-close-right-hover,
191-
.ctab-item-attach-close-right:hover{
191+
.ctab-item-attach-close-right:hover {
192192
background-image:url('images/ctab-simple-close-hover.gif');
193193
background-repeat:no-repeat;
194194
background-position:top right;
@@ -230,7 +230,7 @@
230230
background-color:menu;
231231
}
232232

233-
.ctab-item-attach-rounded-close-left{
233+
.ctab-item-attach-rounded-close-left {
234234
float: right;
235235
border-style:none none none none;
236236
background-image:url('images/ctab-simple-close.gif');
@@ -254,7 +254,7 @@
254254
font-size:8pt;
255255
}
256256

257-
.ctab-item-attach-rounded-close-right{
257+
.ctab-item-attach-rounded-close-right {
258258
float:right;
259259
width:15px;
260260
overflow:hidden;
@@ -265,7 +265,7 @@
265265
background-color:menu;
266266
}
267267
.ctab-item-attach-rounded-close-right-hover,
268-
.ctab-item-attach-rounded-close-right:hover{
268+
.ctab-item-attach-rounded-close-right:hover {
269269
background-image:url('images/ctab-simple-close-hover.gif');
270270
background-repeat:no-repeat;
271271
background-position:top right;
@@ -297,7 +297,7 @@
297297
background-position:top right;
298298
background-color:menu;
299299
}
300-
.ctab-item-selected .ctab-item-attach-default-right{
300+
.ctab-item-selected .ctab-item-attach-default-right {
301301
float:right;
302302
width:15px;
303303
overflow:hidden;
@@ -308,7 +308,7 @@
308308
background-color:menu;
309309
}
310310
.ctab-item-selected .ctab-item-attach-default-right-hover,
311-
.ctab-item-selected .ctab-item-attach-default-right:hover{
311+
.ctab-item-selected .ctab-item-attach-default-right:hover {
312312
float:right;
313313
width:15px;
314314
overflow:hidden;
@@ -319,7 +319,7 @@
319319
background-color:menu;
320320
}
321321
/*
322-
.ctab-item-selected .ctab-item-attach-close-rounded-right{
322+
.ctab-item-selected .ctab-item-attach-close-rounded-right {
323323
float:right;
324324
width:15px;
325325
overflow:hidden;
@@ -330,7 +330,7 @@
330330
background-color:blue;
331331
}
332332
333-
.ctab-item-selected .ctab-item-attach-default-rounded-right{
333+
.ctab-item-selected .ctab-item-attach-default-rounded-right {
334334
float:right;
335335
width:15px;
336336
overflow:hidden;
@@ -342,7 +342,7 @@
342342
}
343343
*/
344344

345-
.ctab-item-selected .ctab-item-attach-close-left{
345+
.ctab-item-selected .ctab-item-attach-close-left {
346346
float:right;
347347
width:15px;
348348
overflow:hidden;
@@ -353,7 +353,7 @@
353353
background-color:blue;
354354
}
355355

356-
.ctab-item-selected .ctab-item-attach-default-left{
356+
.ctab-item-selected .ctab-item-attach-default-left {
357357
float:right;
358358
width:15px;
359359
overflow:hidden;
@@ -364,7 +364,7 @@
364364
background-color:blue;
365365
}
366366
/*
367-
.ctab-item-selected .ctab-item-attach-close-rounded-left{
367+
.ctab-item-selected .ctab-item-attach-close-rounded-left {
368368
float:right;
369369
width:15px;
370370
overflow:hidden;
@@ -375,7 +375,7 @@
375375
background-color:blue;
376376
}
377377
378-
.ctab-item-selected .ctab-item-attach-default-rounded-left{
378+
.ctab-item-selected .ctab-item-attach-default-rounded-left {
379379
float:right;
380380
width:15px;
381381
overflow:hidden;
@@ -409,7 +409,7 @@
409409
}
410410

411411
.ctab-item-rounded-selected .ctab-item-attach-rounded-default-right-hover,
412-
.ctab-item-rounded-selected .ctab-item-attach-rounded-default-right:hover{
412+
.ctab-item-rounded-selected .ctab-item-attach-rounded-default-right:hover {
413413
float:right;
414414
width:37px;
415415
overflow:hidden;
@@ -444,7 +444,7 @@
444444
background-color:menu;
445445
}
446446

447-
.ctab-item-rounded-selected .ctab-item-attach-rounded-close-left{
447+
.ctab-item-rounded-selected .ctab-item-attach-rounded-close-left {
448448
float: right;
449449
border-style:none none none none;
450450
background-image:url('images/ctab-simple-close.gif');
@@ -468,7 +468,7 @@
468468
font-size:8pt;
469469
}
470470

471-
.ctab-item-rounded-selected .ctab-item-attach-rounded-close-right{
471+
.ctab-item-rounded-selected .ctab-item-attach-rounded-close-right {
472472
float:right;
473473
width:37px;
474474
overflow:hidden;
@@ -479,11 +479,14 @@
479479
background-color:menu;
480480
}
481481
.ctab-item-rounded-selected .ctab-item-attach-rounded-close-right-hover,
482-
.ctab-item-rounded-selected .ctab-item-attach-rounded-close-right:hover{
482+
.ctab-item-rounded-selected .ctab-item-attach-rounded-close-right:hover {
483483
background-image:url('images/ctab-simple-close-hover.gif');
484484
background-repeat:no-repeat;
485485
background-position:top right;
486486
background-color:menu;
487487
font-family:Arial, sans-serif;
488488
font-size:8pt;
489489
}
490+
.swt-custom-ctabfolder {
491+
width:324px;
492+
}

sources/net.sf.j2s.java.org.eclipse.swt/src/org/eclipse/swt/package.js

Lines changed: 128 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
/*
2-
* The following codes are moved from ClassExt.js, with modifications
3-
*/
4-
51
/*
62
* Standing for SWT CSS, with all "S" into "$". We love dollors. -zhou renjian
73
*
@@ -14,6 +10,124 @@ $WTC$$ = {};
1410
$WTC$$.cssAlreadyAggregated = false;
1511
$WTC$$.cssForcedUsingFile = false;
1612

13+
/* private */
14+
$WTC$$.timeouts = new Object ();
15+
$WTC$$.triedTimes = new Object ();
16+
$WTC$$.cssTestEls = [];
17+
/* private */
18+
$WTC$$.trackCSS = function (clazzName) {
19+
var el = document.createElement ("DIV");
20+
el.style.cssText = "position:absolute;left:-1000px;top:-100px;font-size:0;display:block;";
21+
var cssID = $WTC$$.getCSSRuleID (clazzName);
22+
el.className = cssID;
23+
if (document.body != null) {
24+
document.body.appendChild (el);
25+
}
26+
27+
var els = $WTC$$.cssTestEls;
28+
for (var i = 0; i < els.length; i++) {
29+
if (els[i] == el) {
30+
return;
31+
}
32+
}
33+
els[els.length] = el;
34+
var f = (function (e, name) {
35+
return function () {
36+
$WTC$$.removeTesting (name);
37+
var tts = $WTC$$.triedTimes;
38+
if (tts[e.className] > 1) { // already tried once
39+
alert ("[Java2Script] Error in loading CSS for " + name + "!");
40+
} else {
41+
// alert ("Try to load *.css " + name + " again.");
42+
/*
43+
* Remove existed *.css
44+
*/
45+
var head = document.getElementsByTagName ("HEAD")[0];
46+
var links = head.getElementsByTagName ("LINK");
47+
for (var i = 0; i < links.length; i++) {
48+
if (links[i].id == "c$$." + name) {
49+
head.removeChild (links[i]);
50+
break;
51+
}
52+
}
53+
$WTC$$.registerCSS (name);
54+
}
55+
};
56+
}) (el, clazzName);
57+
var handle = window.setTimeout (f, 15000); // 15 seconds, should be 30s
58+
59+
$WTC$$.timeouts[cssID] = handle;
60+
var tts = $WTC$$.triedTimes;
61+
if (tts[cssID] == null) {
62+
tts[cssID] = 1;
63+
} else {
64+
tts[cssID]++;
65+
}
66+
if (els.length == 1) { // start global checking
67+
$WTC$$.globalChecking ();
68+
}
69+
};
70+
/* protected */
71+
$WTC$$.cssLoaded = function (clazzName) {};
72+
/* protected */
73+
$WTC$$.globalLoaded = function () {};
74+
/* private */
75+
$WTC$$.removeTesting = function (clazzName) {
76+
var cssClassName = $WTC$$.getCSSRuleID (clazzName);
77+
var els = $WTC$$.cssTestEls;
78+
for (var i = 0; i < els.length; i++) {
79+
if (els[i].className == cssClassName) {
80+
var el = els[i];
81+
if (el.parentNode != null) {
82+
el.parentNode.removeChild (el);
83+
}
84+
for (var j = i; j < els.length - 1; j++) {
85+
els[j] = els[j + 1];
86+
}
87+
els.length--;
88+
return el;
89+
}
90+
}
91+
return null;
92+
};
93+
/* private */
94+
$WTC$$.globalChecking = function () {
95+
var els = $WTC$$.cssTestEls;
96+
for (var i = 0; i < els.length; i++) {
97+
var el = els[i];
98+
var w = Math.max(el.offsetWidth,Math.max(el.clientWidth,el.scrollWidth));
99+
if (w == 324) { // there are "width:324px;" rules in SWT's *.css
100+
//log ("CSS: " + el.className + " loaded!");
101+
$WTC$$.cssLoaded (el.className);
102+
window.clearTimeout ($WTC$$.timeouts[el.className]);
103+
if (el.parentNode != null) {
104+
el.parentNode.removeChild (el);
105+
}
106+
for (var j = i; j < els.length - 1; j++) {
107+
els[j] = els[j + 1];
108+
}
109+
els.length--;
110+
}
111+
}
112+
if (els.length != 0) {
113+
//alert ("continue checking ...");
114+
return window.setTimeout ($WTC$$.globalChecking, 100);
115+
} else {
116+
//log ("finished !");
117+
$WTC$$.globalLoaded ();
118+
}
119+
};
120+
121+
/* private */
122+
$WTC$$.getCSSRuleID = function (clazzName) {
123+
var cssRuleID = null;
124+
if (clazzName.indexOf ("org.eclipse.swt.") == 0 || clazzName.indexOf ("$wt.")) {
125+
var idx = clazzName.indexOf ("wt.") + 3;
126+
cssRuleID = "swt." + clazzName.substring (idx);
127+
}
128+
return cssRuleID.toLowerCase ().replace (/\./g, '-');
129+
};
130+
17131
/**
18132
* Register css for the given class. If the given css text is null, it will
19133
* try to find relative *.css file instead loading css text directly.
@@ -41,6 +155,10 @@ $WTC$$.registerCSS = function (clazzName, cssText) {
41155
cssLink.id = cssID;
42156
cssLink.href = cssPath;
43157
document.getElementsByTagName ("HEAD")[0].appendChild (cssLink);
158+
/*
159+
* register onload event callback
160+
*/
161+
$WTC$$.trackCSS (clazzName);
44162
} else {
45163
var prefix = "";
46164
var idx = cssPath.lastIndexOf ("/");
@@ -95,6 +213,9 @@ $WTC$$.registerCSS = function (clazzName, cssText) {
95213
}
96214
}
97215

216+
/*
217+
* This method will generated a lot non existed *.css resouce requests (404) for server.
218+
*/
98219
var len = $WTC$$.themes.length;
99220
for(var i = 0; i < len; i++){
100221
var themeName = $WTC$$.themes[i];
@@ -104,49 +225,13 @@ $WTC$$.registerCSS = function (clazzName, cssText) {
104225
cssLink.id = cssID + themeName;
105226
cssLink.href = themePath;
106227
document.getElementsByTagName ("HEAD")[0].appendChild (cssLink);
228+
/*
229+
* OK, theme *.css may be not essential. So no onload callbacks here.
230+
*/
107231
}
108232
}
109233
};
110234

111-
/*
112-
* The above codes are moved from ClassExt.js
113-
*/
114-
115-
/*
116-
* The following codes are moved from ClassLoader.js
117-
*/
118-
119-
/*
120-
* loadCSS may be considered part of SWT library. Should be packed with
121-
* SWT not with Java core.
122-
*
123-
* Not used in other *.js yet.
124-
* - Nov 8, 2006
125-
*/
126-
/* public */
127-
$WTC$$.loadCSS = function (cssName) {
128-
var cssKey = "";
129-
var idx = cssName.lastIndexOf (".");
130-
if (idx == -1) {
131-
cssKey = cssName + ".css";
132-
} else {
133-
cssKey = cssName.substring (idx + 1) + ".css";
134-
}
135-
var resLinks = document.getElementsByTagName ("LINK");
136-
for (var i = 0; i < resLinks.length; i++) {
137-
var cssPath = resLinks[i].href;
138-
if (cssPath.lastIndexOf (cssKey) == cssPath.length - cssKey.length) {
139-
return ;
140-
}
141-
}
142-
143-
/*-# cssLink -> rel #-*/
144-
var cssLink = document.createElement ("LINK");
145-
cssLink.rel = "stylesheet";
146-
var path = ClazzLoader.getClasspathFor (cssName);
147-
cssLink.href = path.substring (0, path.lastIndexOf (".js")) + ".css";
148-
document.getElementsByTagName ("HEAD")[0].appendChild (cssLink);
149-
};
150235
/*
151236
* This array will preserves the themes order.
152237
*/
@@ -177,10 +262,6 @@ $WTC$$.registerTheme = function(themeName, themePath){
177262
}
178263

179264
};
180-
181-
/*
182-
* The above codes are moved from ClassLoader.js
183-
*/
184265

185266
Clazz.declarePackage ("org.eclipse.swt");
186267
$wt = org.eclipse.swt;

sources/net.sf.j2s.java.org.eclipse.swt/src/org/eclipse/swt/widgets/Button.css

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,3 +181,6 @@
181181
.button-text-mnemonics {
182182
text-decoration:underline;
183183
}
184+
.swt-widgets-button {
185+
width:324px;
186+
}

0 commit comments

Comments
 (0)