Skip to content

Commit 5e4fe8c

Browse files
authored
Merge pull request #91 from BobHanson/hanson1
?j2snocore fix; Frame/JFrame setUndecorated(true) fix
2 parents 7ee4fcf + 5c20bd6 commit 5e4fe8c

File tree

17 files changed

+121
-85
lines changed

17 files changed

+121
-85
lines changed

sources/net.sf.j2s.core/dist/build-site.xml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,12 @@
2828
<!-- location of third-party jar contents as precompiled zipped .js files to copy to site/ -->
2929
<property name="libjs.dir" value="libjs" />
3030

31-
<!-- non-Java resources to copy to site/ -->
31+
<!-- non-Java resources to copy to site/swingjs/j2s -->
3232
<property name="resource.dir" value="resources" />
3333

34+
<!-- non-Java resources to copy to site/ -->
35+
<property name="site-resource.dir" value="site-resources" />
36+
3437
<!-- output directories -->
3538

3639
<property name="site.dir" value="site" />
@@ -75,6 +78,14 @@
7578
</fileset>
7679
</copy>
7780

81+
<echo> Copying ${site-resource.dir} files into ${site.dir} </echo>
82+
<copy todir="${site.dir}">
83+
<fileset dir="${site-resource.dir}">
84+
<include name="**"/>
85+
</fileset>
86+
</copy>
87+
88+
7889
</target>
7990

8091

sources/net.sf.j2s.core/dist/resources/README.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ SwingJS distribution -- resources directory
22

33
This directory can be used to hold non-Java files that your program
44
needs to run -- data files, for instance. Files in it will be copied to
5-
the site/ directory by build-site.xml.
5+
the site/swingjs/j2s directory by build-site.xml.
66

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
SwingJS distribution -- site-resources directory
2+
3+
This directory can be used to hold non-Java files that your program
4+
needs to run -- data files, for instance. Files in it will be copied to
5+
the site/ directory by build-site.xml.
6+
353 Bytes
Binary file not shown.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20190324055304
1+
20190326062559
353 Bytes
Binary file not shown.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20190324055304
1+
20190326062559

sources/net.sf.j2s.core/src/net/sf/j2s/core/Java2ScriptCompiler.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ class Java2ScriptCompiler {
6767

6868
private String siteFolder;
6969

70+
private boolean testing;
71+
7072
private List<String> lstExcludedPaths;
7173

7274
private boolean isCleanBuild;
@@ -187,6 +189,8 @@ boolean initializeProject(IJavaProject project, boolean isCompilationParticipant
187189
lstExcludedPaths = null;
188190
}
189191

192+
testing = "true".equals(getProperty("j2s.testing"));
193+
190194
String prop = getProperty("j2s.compiler.nonqualified.packages");
191195
// older version of the name
192196
String nonqualifiedPackages = getProperty("j2s.compiler.nonqualified.classes");
@@ -249,7 +253,7 @@ boolean compileToJavaScript(IFile javaSource) {
249253
CompilationUnit root = (CompilationUnit) astParser.createAST(null);
250254
// If the Java2ScriptVisitor is ever extended, it is important to set the project.
251255
// Java2ScriptVisitor#addClassOrInterface uses getClass().newInstance().setproject(project).
252-
Java2ScriptVisitor visitor = new Java2ScriptVisitor().setProject(project);
256+
Java2ScriptVisitor visitor = new Java2ScriptVisitor().setProject(project, testing);
253257

254258
try {
255259

sources/net.sf.j2s.core/src/net/sf/j2s/core/Java2ScriptVisitor.java

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,21 @@ public class Java2ScriptVisitor extends ASTVisitor {
198198

199199
private IJavaProject global_project;
200200

201+
/**
202+
* multipurpose flag for testing development ideas.
203+
*
204+
*/
205+
private boolean global_testing;
206+
// make private fields properties of p1$ ?
207+
// the problem only shows up with a2s subclasses of Swing components
208+
// because they could declare the same private variable and not get
209+
// caught by the compiler, since they do not subclass that class.
210+
//
211+
// possible issues:
212+
// 1) We may have changed some awt, sun, and javax fields from private to public
213+
// 2) Is there an issue with inner classes referencing outer-class private fields?
214+
215+
201216
private String package_name;
202217
private int package_blockLevel = 0;
203218
private int package_currentBlockForVisit = -1;
@@ -305,6 +320,7 @@ private Java2ScriptVisitor setInnerGlobals(Java2ScriptVisitor parent, ASTNode no
305320
*/
306321
private boolean haveDefaultConstructor;
307322

323+
308324
private static IType appletType;
309325

310326
public Java2ScriptVisitor() {
@@ -318,7 +334,8 @@ public Java2ScriptVisitor() {
318334
// }
319335
}
320336

321-
public Java2ScriptVisitor setProject(IJavaProject project) {
337+
public Java2ScriptVisitor setProject(IJavaProject project, boolean testing) {
338+
this.global_testing = testing;
322339
this.global_project = project;
323340
return this;
324341
}
@@ -1626,7 +1643,7 @@ private void addClassOrInterface(ASTNode node, ITypeBinding binding, List<?> bod
16261643

16271644
Java2ScriptVisitor tempVisitor = null;
16281645
try {
1629-
tempVisitor = getClass().newInstance().setProject(global_project).setInnerGlobals(this, node);
1646+
tempVisitor = getClass().newInstance().setProject(global_project, global_testing).setInnerGlobals(this, node);
16301647
} catch (@SuppressWarnings("unused") Exception e) {
16311648
// impossible
16321649
}
353 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)