Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit6ae03ea

Browse files
author
jossonsmith
committed
Merging /trunk to [184]
Supporting dynamic loading of JavaScript
1 parent115a114 commit6ae03ea

File tree

3 files changed

+53
-7
lines changed

3 files changed

+53
-7
lines changed

‎src/net/sf/j2s/ui/generator/J2SView.java‎

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313

1414
importnet.sf.j2s.core.astvisitors.ASTScriptVisitor;
15+
importnet.sf.j2s.core.astvisitors.DependencyASTVisitor;
1516
importnet.sf.j2s.core.astvisitors.NameConverterUtil;
1617
importnet.sf.j2s.core.astvisitors.SWTScriptVisitor;
1718
importnet.sf.j2s.core.compiler.Java2ScriptCompiler;
@@ -324,7 +325,15 @@ public void setInput(ITextEditor editor) throws CoreException {
324325
}
325326
}
326327
fRoot.accept(visitor);
327-
outputJavaScript(visitor);
328+
DependencyASTVisitordvisitor =newDependencyASTVisitor();
329+
booleanerrorOccurs =false;
330+
try {
331+
fRoot.accept(dvisitor);
332+
}catch (Throwablee) {
333+
e.printStackTrace();
334+
errorOccurs =true;
335+
}
336+
outputJavaScript(visitor,dvisitor);
328337

329338
//DependencyASTVisitor dependencyASTVisitor = new DependencyASTVisitor();
330339
//fRoot.accept(dependencyASTVisitor);
@@ -359,8 +368,8 @@ private IStatus getErrorStatus(String message, Throwable th) {
359368
returnnewStatus(IStatus.ERROR,"net.sf.j2s.j2sview",IStatus.ERROR,message,th);
360369
}
361370

362-
privatevoidoutputJavaScript(ASTScriptVisitorvisitor) {
363-
Stringjs =visitor.getBuffer().toString();
371+
privatevoidoutputJavaScript(ASTScriptVisitorvisitor,DependencyASTVisitordvisitor) {
372+
Stringjs =dvisitor.getDependencyScript(visitor.getBuffer());
364373
js =js.replaceAll("cla\\$\\$","c\\$")
365374
.replaceAll("innerThis","i\\$")
366375
.replaceAll("finalVars","v\\$")

‎src/net/sf/j2s/ui/launching/J2SLaunchingUtil.java‎

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
importnet.sf.j2s.ui.classpath.CompositeResources;
1313
importnet.sf.j2s.ui.classpath.IRuntimeClasspathEntry;
1414
importnet.sf.j2s.ui.classpath.Resource;
15+
importnet.sf.j2s.ui.property.FileUtil;
16+
importnet.sf.j2s.ui.resources.ExternalResources;
1517

1618
importorg.eclipse.core.resources.IContainer;
1719
importorg.eclipse.core.resources.IProject;
@@ -206,14 +208,26 @@ private static String generateHTML(ILaunchConfiguration configuration,
206208
buf.append(configuration.getAttribute(
207209
IJ2SLauchingConfiguration.HEAD_HEADER_HTML,""));
208210

209-
buf.append(generateClasspathHTML(configuration,mainType,workingDir));
211+
//buf.append(generateClasspathHTML(configuration, mainType, workingDir));
212+
String[][]allResources =ExternalResources.getAllResources();
213+
Stringj2sLibPath =null;
214+
if (allResources !=null &&allResources.length !=0 &&allResources[0].length !=0) {
215+
if ((allResources[0][0]).startsWith("|")) {
216+
allResources[0][0] =FileUtil.toRelativePath(allResources[0][0].substring(1),
217+
workingDir.getAbsolutePath());;
218+
}
219+
j2sLibPath =allResources[0][0].substring(0,allResources[0][0].lastIndexOf("/") +1);
220+
}else {
221+
j2sLibPath ="../net.sf.j2s.lib/j2slib/";
222+
}
223+
buf.append("<script type=\"text/javascript\" src=\"" +j2sLibPath +"j2slib.z.js\"></script>\r\n");
210224

211225
buf.append(configuration.getAttribute(
212226
IJ2SLauchingConfiguration.TAIL_HEADER_HTML,""));
213227
buf.append("</head>\r\n");
214228
buf.append("<body>\r\n");
215229
if (useInnerConsole) {
216-
buf.append("<div id=\"_console_\" class=\"consolewindow\"></div>\r\n");
230+
//buf.append("<div id=\"_console_\" class=\"consolewindow\"></div>\r\n");
217231
}
218232
buf.append(configuration.getAttribute(
219233
IJ2SLauchingConfiguration.HEAD_BODY_HTML,""));
@@ -229,17 +243,27 @@ private static String generateHTML(ILaunchConfiguration configuration,
229243
}
230244
Stringpath =javaProject.getOutputLocation().toString();
231245
intidx =path.indexOf('/',2);
232-
StringrelativePath =null;
246+
StringrelativePath ="";
233247
if (idx != -1) {
234248
relativePath =path.substring(idx +1);
235249
}
236250
/*
237251
* MainType Class may already included in the header section
238252
*/
239253
//buf.append(wrapTypeJS(mainType, relativePath));
254+
240255
buf.append("<script type=\"text/javascript\">\r\n");
256+
buf.append("ClazzLoader.j2slibClasspath (\"");
257+
buf.append(j2sLibPath);
258+
buf.append("\");\r\n");
259+
buf.append("ClazzLoader.setPrimaryFolder (\"");
260+
buf.append(relativePath);
261+
buf.append("\");\r\n");
262+
241263
Stringargs =configuration.getAttribute(IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, (String)null);
264+
buf.append("ClazzLoader.loadClass (\"" +mainType +"\", function () {\r\n");
242265
buf.append("" +mainType +".main(" +ArgsUtil.wrapAsArgumentArray(args) +");\r\n");
266+
buf.append("});\r\n");
243267
buf.append("</script>\r\n");
244268

245269
buf.append(configuration.getAttribute(

‎src/net/sf/j2s/ui/text/javadoc/IJavaDocTagConstants.java‎

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,20 @@
2626
publicinterfaceIJavaDocTagConstants {
2727

2828
/** Javadoc general tags */
29-
publicstaticfinalString[]JAVADOC_GENERAL_TAGS=newString[] {"@j2sIgnore","@j2sDebug","@j2sKeep","@j2sNative","@j2sNativeSrc","@j2sOverride","@j2sIgnoreSuperConstructor","@j2sPrefix","@j2sSuffix" };//"@author", "@deprecated", "@docRoot", "@exception", "@inheritDoc", "@link", "@linkplain", "@param", "@return", "@see", "@serial", "@serialData", "@serialField", "@since", "@throws", "@value", "@version" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$ //$NON-NLS-10$ //$NON-NLS-11$ //$NON-NLS-12$ //$NON-NLS-13$ //$NON-NLS-14$ //$NON-NLS-15$ //$NON-NLS-16$ //$NON-NLS-17$ //$NON-NLS-18$
29+
publicstaticfinalString[]JAVADOC_GENERAL_TAGS=newString[] {
30+
"@j2sIgnore",//$NON-NLS-1$
31+
"@j2sDebug",//$NON-NLS-1$
32+
"@j2sKeep",//$NON-NLS-1$
33+
"@j2sNative",//$NON-NLS-1$
34+
"@j2sNativeSrc",//$NON-NLS-1$
35+
"@j2sOverride",//$NON-NLS-1$
36+
"@j2sIgnoreSuperConstructor",//$NON-NLS-1$
37+
"@j2sRequireImport",//$NON-NLS-1$
38+
"@j2sOptionalImport",//$NON-NLS-1$
39+
"@j2sIgnoreImport",//$NON-NLS-1$
40+
"@j2sPrefix",//$NON-NLS-1$
41+
"@j2sSuffix" };//$NON-NLS-1$
42+
//"@author", "@deprecated", "@docRoot", "@exception", "@inheritDoc", "@link", "@linkplain", "@param", "@return", "@see", "@serial", "@serialData", "@serialField", "@since", "@throws", "@value", "@version" };
3043

3144
/** Javadoc link tags */
3245
publicstaticfinalString[]JAVADOC_LINK_TAGS=newString[] { };//"@docRoot", "@inheritDoc", "@link", "@linkplain" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp