15
15
import java .util .Properties ;
16
16
import java .util .Set ;
17
17
18
+ import net .sf .j2s .core .astvisitors .ASTTigerVisitor ;
19
+ import net .sf .j2s .core .astvisitors .ASTTypeVisitor ;
18
20
import net .sf .j2s .core .astvisitors .DependencyASTVisitor ;
19
21
import net .sf .j2s .core .hotspot .InnerHotspotServer ;
20
22
import net .sf .j2s .ui .Java2ScriptUIPlugin ;
@@ -152,10 +154,11 @@ public static void launchingJ2SUnit(ILaunchConfiguration configuration, String m
152
154
}
153
155
}
154
156
}
157
+ String mainTypeName = new ASTTypeVisitor ().assureQualifiedName (mainType );
155
158
if (isTestSuite ) {
156
- buf .append ("\t \t \t \t junit.textui.TestRunner.run (" + mainType + ".suite ());\r \n " );
159
+ buf .append ("\t \t \t \t junit.textui.TestRunner.run (" + mainTypeName + ".suite ());\r \n " );
157
160
} else {
158
- buf .append ("\t \t \t \t junit.textui.TestRunner.run (" + mainType + ");\r \n " );
161
+ buf .append ("\t \t \t \t junit.textui.TestRunner.run (" + mainTypeName + ");\r \n " );
159
162
}
160
163
buf .append ("\t \t \t });\r \n " );
161
164
buf .append ("\t \t });\r \n " );
@@ -183,10 +186,11 @@ public static void launchingJ2SUnit(ILaunchConfiguration configuration, String m
183
186
}
184
187
}
185
188
}
189
+ String mainTypeName = new ASTTypeVisitor ().assureQualifiedName (mainType );
186
190
if (isTestSuite ) {
187
- buf .append ("\t \t junit.textui.TestRunner.run (" + mainType + ".suite ());\r \n " );
191
+ buf .append ("\t \t junit.textui.TestRunner.run (" + mainTypeName + ".suite ());\r \n " );
188
192
} else {
189
- buf .append ("\t \t junit.textui.TestRunner.run (" + mainType + ");\r \n " );
193
+ buf .append ("\t \t junit.textui.TestRunner.run (" + mainTypeName + ");\r \n " );
190
194
}
191
195
buf .append ("\t });\r \n " );
192
196
buf .append ("});\r \n " );
@@ -292,7 +296,8 @@ public static void launchingJ2SApp(ILaunchConfiguration configuration, String mo
292
296
grelativePath , mainType , workingDir , configuration );
293
297
294
298
buf .append ("\t \t ClazzLoader.loadClass (\" " + mainType + "\" , function () {\r \n " );
295
- buf .append ("\t \t \t " + mainType + ".main(" + ArgsUtil .wrapAsArgumentArray (args , true ) + ");\r \n " );
299
+ String mainTypeName = new ASTTypeVisitor ().assureQualifiedName (mainType );
300
+ buf .append ("\t \t \t " + mainTypeName + ".main(" + ArgsUtil .wrapAsArgumentArray (args , true ) + ");\r \n " );
296
301
buf .append ("\t \t });\r \n " );
297
302
298
303
buf .append ("\t }\r \n " );
@@ -305,7 +310,8 @@ public static void launchingJ2SApp(ILaunchConfiguration configuration, String mo
305
310
isJUnit , grelativePath , workingDir , configuration );
306
311
307
312
buf .append ("ClazzLoader.loadClass (\" " + mainType + "\" , function () {\r \n " );
308
- buf .append ("\t " + mainType + ".main(" + ArgsUtil .wrapAsArgumentArray (args , true ) + ");\r \n " );
313
+ String mainTypeName = new ASTTypeVisitor ().assureQualifiedName (mainType );
314
+ buf .append ("\t " + mainTypeName + ".main(" + ArgsUtil .wrapAsArgumentArray (args , true ) + ");\r \n " );
309
315
buf .append ("});\r \n " );
310
316
}
311
317
@@ -443,7 +449,15 @@ private static void generateFirefoxAddonPreJavaScript(StringBuffer buf,
443
449
buf .append ("\t /*forward : true,*/\r \n " );
444
450
buf .append ("\t mode : \" dailybuild\" ,\r \n " );
445
451
buf .append ("\t onload : function () {\r \n " );
446
-
452
+ String j2xStr = J2SLaunchingUtil .generateClasspathJ2X (configuration , "j2slibPath" , workingDir );
453
+ if (j2xStr != null && j2xStr .length () != 0 ) {
454
+ buf .append ("\t \t var o = window[\" j2s.lib\" ];\r \n " );
455
+ buf .append ("\t \t var j2slibPath = o.base + (o.alias ? o.alias : o.version) + \" /\" ;\r \n " );
456
+ buf .append ("\t \t " );
457
+ buf .append (j2xStr .replaceAll ("\r \n " , "\r \n \t \t " ).trim ());
458
+ buf .append ("\r \n " );
459
+ }
460
+
447
461
buf .append ("\t \t ClazzLoader.setPrimaryFolder (\" " );
448
462
buf .append (grelativePath );
449
463
buf .append ("\" );\r \n " );
@@ -459,7 +473,9 @@ private static String generatePreJavaScript(StringBuffer buf, String args,
459
473
String grelativePath , String gj2sLibPath , boolean isJUnit , String mode ,
460
474
String mainType , File workingDir , ILaunchConfiguration configuration )
461
475
throws CoreException {
462
- buf .append ("<a class=\" alaa\" href=\" javascript:if(a='" );
476
+ buf .append ("<a class=\" alaa\" title=\" Launch " );
477
+ buf .append (mainType );
478
+ buf .append ("\" href=\" javascript:if(a='" );
463
479
buf .append (mainType );
464
480
buf .append ('@' );
465
481
buf .append (grelativePath );
@@ -481,6 +497,7 @@ private static String generatePreJavaScript(StringBuffer buf, String args,
481
497
buf .append (gj2sLibPath );
482
498
buf .append ("j2slib.z.js';(typeof x[t]=='undefined')?x.onload=f:x[t]=f;" +
483
499
"d.getElementsByTagName('HEAD')[0].appendChild(x);void(0);}\" >" );
500
+ buf .append ("<span class=\" alaa-icon\" ></span>" );
484
501
buf .append (mainType );
485
502
buf .append ("</a>\r \n \r \n " );
486
503
@@ -490,7 +507,7 @@ private static String generatePreJavaScript(StringBuffer buf, String args,
490
507
buf .append ("<script type=\" text/javascript\" >\r \n " );
491
508
492
509
J2SCyclicProjectUtils .emptyTracks ();
493
- String j2xStr = J2SLaunchingUtil .generateClasspathJ2X (configuration , mainType , workingDir );
510
+ String j2xStr = J2SLaunchingUtil .generateClasspathJ2X (configuration , null , workingDir );
494
511
495
512
if ("debug" .equals (mode )) {
496
513
buf .append ("window[\" j2s.script.debugging\" ] = true;\r \n " );
@@ -549,13 +566,20 @@ private static void generateJ2SHeaderHTML(StringBuffer buf,
549
566
"\t width:1em;\r \n " +
550
567
"\t overflow-x:visible;\r \n " +
551
568
"\t text-decoration:none;\r \n " +
552
- "\t border-left:1em solid rgb(57,61,254);\r \n " +
553
- "\t padding-left:4px;\r \n " +
569
+ "\t padding-left:32px;\r \n " +
554
570
"\t margin:2em;\r \n " +
555
571
"\t color:navy;\r \n " +
556
572
"\t cursor:pointer;\r \n " +
557
573
"\t cursor:hand;\r \n " );
558
574
buf .append ("}\r \n " );
575
+ buf .append ("span.alaa-icon {\r \n " );
576
+ buf .append ("\t display:block;\r \n " +
577
+ "\t position:absolute;\r \n " +
578
+ "\t width:16px;\r \n " +
579
+ "\t height:16px;\r \n " +
580
+ "\t margin:2px 8px 0 -24px;\r \n " +
581
+ "\t background-color:rgb(57,61,254);\r \n " );
582
+ buf .append ("}\r \n " );
559
583
buf .append ("</style>\r \n " );
560
584
buf .append ("</head>\r \n " );
561
585
buf .append ("<body>\r \n " );
@@ -667,7 +691,7 @@ static String generateClasspathHTML(
667
691
* Append the *.js in classpath
668
692
*/
669
693
static String generateClasspathJ2X (
670
- ILaunchConfiguration configuration , String mainType , File workingDir )
694
+ ILaunchConfiguration configuration , String varName , File workingDir )
671
695
throws CoreException {
672
696
boolean isUseGlobalURL = configuration .getAttribute (IJ2SLauchingConfiguration .USE_GLOBAL_ALAA_URL , false );
673
697
StringBuffer buf = new StringBuffer ();
@@ -783,7 +807,7 @@ public boolean accept(File pathname) {
783
807
keyPkg .add (pkg );
784
808
buf .append ("ClazzLoader.packageClasspath (\" " );
785
809
buf .append (pkg );
786
- buf .append ("\" , \" " );
810
+ buf .append ("\" , " );
787
811
String j2slibPath = FileUtil .toRelativePath (f .getParent (), workingDir .getAbsolutePath ());
788
812
String gj2sLibPath = j2slibPath ;
789
813
if (isUseGlobalURL ) {
@@ -795,8 +819,13 @@ public boolean accept(File pathname) {
795
819
gj2sLibPath += "/" ;
796
820
}
797
821
}
798
- buf .append (gj2sLibPath );
799
- buf .append ("\" " );
822
+ if (varName == null ) {
823
+ buf .append ("\" " );
824
+ buf .append (gj2sLibPath );
825
+ buf .append ("\" " );
826
+ } else {
827
+ buf .append (varName );
828
+ }
800
829
File pkgFile = new File (f .getParentFile (), pkg .replace ('.' , '/' ) + "/package.js" );
801
830
if (pkgFile .exists ()) {
802
831
buf .append (", true" );
0 commit comments