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 );
155158if (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}
160163buf .append ("\t \t \t });\r \n " );
161164buf .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 );
186190if (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}
191195buf .append ("\t });\r \n " );
192196buf .append ("});\r \n " );
@@ -292,7 +296,8 @@ public static void launchingJ2SApp(ILaunchConfiguration configuration, String mo
292296grelativePath ,mainType ,workingDir ,configuration );
293297
294298buf .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 " );
296301buf .append ("\t \t });\r \n " );
297302
298303buf .append ("\t }\r \n " );
@@ -305,7 +310,8 @@ public static void launchingJ2SApp(ILaunchConfiguration configuration, String mo
305310isJUnit ,grelativePath ,workingDir ,configuration );
306311
307312buf .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 " );
309315buf .append ("});\r \n " );
310316}
311317
@@ -443,7 +449,15 @@ private static void generateFirefoxAddonPreJavaScript(StringBuffer buf,
443449buf .append ("\t /*forward : true,*/\r \n " );
444450buf .append ("\t mode :\" dailybuild\" ,\r \n " );
445451buf .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+
447461buf .append ("\t \t ClazzLoader.setPrimaryFolder (\" " );
448462buf .append (grelativePath );
449463buf .append ("\" );\r \n " );
@@ -459,7 +473,9 @@ private static String generatePreJavaScript(StringBuffer buf, String args,
459473String grelativePath ,String gj2sLibPath ,boolean isJUnit ,String mode ,
460474String mainType ,File workingDir ,ILaunchConfiguration configuration )
461475throws CoreException {
462- buf .append ("<a class=\" alaa\" href=\" #"diff-1e6af5394313451ff7b8dbb93b07fbe10b2419cf605eb85a535fc714985524e8-462-476-0" data-selected="false" role="gridcell" tabindex="-1" valign="top">
476+ buf .append ("<a class=\" alaa\" title=\" Launch " );
477+ buf .append (mainType );
478+ buf .append ("\" href=\" #"diff-1e6af5394313451ff7b8dbb93b07fbe10b2419cf605eb85a535fc714985524e8-463-479-0" data-selected="false" role="gridcell" tabindex="-1" valign="top">463
479buf .append (mainType );
464480buf .append ('@' );
465481buf .append (grelativePath );
@@ -481,6 +497,7 @@ private static String generatePreJavaScript(StringBuffer buf, String args,
481497buf .append (gj2sLibPath );
482498buf .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>" );
484501buf .append (mainType );
485502buf .append ("</a>\r \n \r \n " );
486503
@@ -490,7 +507,7 @@ private static String generatePreJavaScript(StringBuffer buf, String args,
490507buf .append ("<script type=\" text/javascript\" >\r \n " );
491508
492509J2SCyclicProjectUtils .emptyTracks ();
493- String j2xStr =J2SLaunchingUtil .generateClasspathJ2X (configuration ,mainType ,workingDir );
510+ String j2xStr =J2SLaunchingUtil .generateClasspathJ2X (configuration ,null ,workingDir );
494511
495512if ("debug" .equals (mode )) {
496513buf .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 " );
558574buf .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 " );
559583buf .append ("</style>\r \n " );
560584buf .append ("</head>\r \n " );
561585buf .append ("<body>\r \n " );
@@ -667,7 +691,7 @@ static String generateClasspathHTML(
667691 * Append the *.js in classpath
668692 */
669693static String generateClasspathJ2X (
670- ILaunchConfiguration configuration ,String mainType ,File workingDir )
694+ ILaunchConfiguration configuration ,String varName ,File workingDir )
671695throws CoreException {
672696boolean isUseGlobalURL =configuration .getAttribute (IJ2SLauchingConfiguration .USE_GLOBAL_ALAA_URL ,false );
673697StringBuffer buf =new StringBuffer ();
@@ -783,7 +807,7 @@ public boolean accept(File pathname) {
783807keyPkg .add (pkg );
784808buf .append ("ClazzLoader.packageClasspath (\" " );
785809buf .append (pkg );
786- buf .append ("\" ,\" " );
810+ buf .append ("\" , " );
787811String j2slibPath =FileUtil .toRelativePath (f .getParent (),workingDir .getAbsolutePath ());
788812String gj2sLibPath =j2slibPath ;
789813if (isUseGlobalURL ) {
@@ -795,8 +819,13 @@ public boolean accept(File pathname) {
795819gj2sLibPath +="/" ;
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+ }
800829File pkgFile =new File (f .getParentFile (),pkg .replace ('.' ,'/' ) +"/package.js" );
801830if (pkgFile .exists ()) {
802831buf .append (", true" );