1515import java .util .Properties ;
1616import java .util .Set ;
1717
18+ import net .sf .j2s .core .astvisitors .ASTTigerVisitor ;
19+ import net .sf .j2s .core .astvisitors .ASTTypeVisitor ;
1820import net .sf .j2s .core .astvisitors .DependencyASTVisitor ;
1921import net .sf .j2s .core .hotspot .InnerHotspotServer ;
2022import net .sf .j2s .ui .Java2ScriptUIPlugin ;
@@ -152,10 +154,11 @@ public static void launchingJ2SUnit(ILaunchConfiguration configuration, String m
152154 }
153155 }
154156 }
157+ String mainTypeName = new ASTTypeVisitor ().assureQualifiedName (mainType );
155158 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 " );
157160 } 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 " );
159162 }
160163 buf .append ("\t \t \t });\r \n " );
161164 buf .append ("\t \t });\r \n " );
@@ -183,10 +186,11 @@ public static void launchingJ2SUnit(ILaunchConfiguration configuration, String m
183186 }
184187 }
185188 }
189+ String mainTypeName = new ASTTypeVisitor ().assureQualifiedName (mainType );
186190 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 " );
188192 } 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 " );
190194 }
191195 buf .append ("\t });\r \n " );
192196 buf .append ("});\r \n " );
@@ -292,7 +296,8 @@ public static void launchingJ2SApp(ILaunchConfiguration configuration, String mo
292296 grelativePath , mainType , workingDir , configuration );
293297
294298 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 " );
296301 buf .append ("\t \t });\r \n " );
297302
298303 buf .append ("\t }\r \n " );
@@ -305,7 +310,8 @@ public static void launchingJ2SApp(ILaunchConfiguration configuration, String mo
305310 isJUnit , grelativePath , workingDir , configuration );
306311
307312 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 " );
309315 buf .append ("});\r \n " );
310316 }
311317
@@ -443,7 +449,15 @@ private static void generateFirefoxAddonPreJavaScript(StringBuffer buf,
443449 buf .append ("\t /*forward : true,*/\r \n " );
444450 buf .append ("\t mode : \" dailybuild\" ,\r \n " );
445451 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+
447461 buf .append ("\t \t ClazzLoader.setPrimaryFolder (\" " );
448462 buf .append (grelativePath );
449463 buf .append ("\" );\r \n " );
@@ -459,7 +473,9 @@ private static String generatePreJavaScript(StringBuffer buf, String args,
459473 String grelativePath , String gj2sLibPath , boolean isJUnit , String mode ,
460474 String mainType , File workingDir , ILaunchConfiguration configuration )
461475 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='" );
463479 buf .append (mainType );
464480 buf .append ('@' );
465481 buf .append (grelativePath );
@@ -481,6 +497,7 @@ private static String generatePreJavaScript(StringBuffer buf, String args,
481497 buf .append (gj2sLibPath );
482498 buf .append ("j2slib.z.js';(typeof x[t]=='undefined')?x.onload=f:x[t]=f;" +
483499 "d.getElementsByTagName('HEAD')[0].appendChild(x);void(0);}\" >" );
500+ buf .append ("<span class=\" alaa-icon\" ></span>" );
484501 buf .append (mainType );
485502 buf .append ("</a>\r \n \r \n " );
486503
@@ -490,7 +507,7 @@ private static String generatePreJavaScript(StringBuffer buf, String args,
490507 buf .append ("<script type=\" text/javascript\" >\r \n " );
491508
492509 J2SCyclicProjectUtils .emptyTracks ();
493- String j2xStr = J2SLaunchingUtil .generateClasspathJ2X (configuration , mainType , workingDir );
510+ String j2xStr = J2SLaunchingUtil .generateClasspathJ2X (configuration , null , workingDir );
494511
495512 if ("debug" .equals (mode )) {
496513 buf .append ("window[\" j2s.script.debugging\" ] = true;\r \n " );
@@ -549,13 +566,20 @@ private static void generateJ2SHeaderHTML(StringBuffer buf,
549566 "\t width:1em;\r \n " +
550567 "\t overflow-x:visible;\r \n " +
551568 "\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 " +
554570 "\t margin:2em;\r \n " +
555571 "\t color:navy;\r \n " +
556572 "\t cursor:pointer;\r \n " +
557573 "\t cursor:hand;\r \n " );
558574 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 " );
559583 buf .append ("</style>\r \n " );
560584 buf .append ("</head>\r \n " );
561585 buf .append ("<body>\r \n " );
@@ -667,7 +691,7 @@ static String generateClasspathHTML(
667691 * Append the *.js in classpath
668692 */
669693 static String generateClasspathJ2X (
670- ILaunchConfiguration configuration , String mainType , File workingDir )
694+ ILaunchConfiguration configuration , String varName , File workingDir )
671695 throws CoreException {
672696 boolean isUseGlobalURL = configuration .getAttribute (IJ2SLauchingConfiguration .USE_GLOBAL_ALAA_URL , false );
673697 StringBuffer buf = new StringBuffer ();
@@ -783,7 +807,7 @@ public boolean accept(File pathname) {
783807 keyPkg .add (pkg );
784808 buf .append ("ClazzLoader.packageClasspath (\" " );
785809 buf .append (pkg );
786- buf .append ("\" , \" " );
810+ buf .append ("\" , " );
787811 String j2slibPath = FileUtil .toRelativePath (f .getParent (), workingDir .getAbsolutePath ());
788812 String gj2sLibPath = j2slibPath ;
789813 if (isUseGlobalURL ) {
@@ -795,8 +819,13 @@ public boolean accept(File pathname) {
795819 gj2sLibPath += "/" ;
796820 }
797821 }
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+ }
800829 File pkgFile = new File (f .getParentFile (), pkg .replace ('.' , '/' ) + "/package.js" );
801830 if (pkgFile .exists ()) {
802831 buf .append (", true" );
0 commit comments