Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified sources/net.sf.j2s.core/dist/swingjs/SwingJS-site.zip
Binary file not shown.
Binary file modified sources/net.sf.j2s.core/dist/swingjs/net.sf.j2s.core.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion sources/net.sf.j2s.core/dist/swingjs/timestamp
Original file line number Diff line number Diff line change
@@ -1 +1 @@
20191103225630
20191105122130
Binary file modified sources/net.sf.j2s.core/dist/swingjs/ver/3.2.4/SwingJS-site.zip
Binary file not shown.
Binary file modified sources/net.sf.j2s.core/dist/swingjs/ver/3.2.4/net.sf.j2s.core.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion sources/net.sf.j2s.core/dist/swingjs/ver/3.2.4/timestamp
Original file line number Diff line number Diff line change
@@ -1 +1 @@
20191103225630
20191105122130
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ public void buildFinished(IJavaProject project) {
int ntotal = 0, nerror = 0;
for (int j = 0; j < contexts.size(); j++) {
BuildContext[] files = contexts.get(j);
System.out.println("J2S building JavaScript for " + files.length + " file"+plural(files.length));
System.out.println("J2S building JavaScript for " + files.length + " file" + plural(files.length));

for (int i = 0, n = files.length; i < n; i++) {
// trying to keep the progess monitor running - didn't work
Expand All @@ -157,23 +157,29 @@ public void buildFinished(IJavaProject project) {
System.out.println("J2S excluded " + filePath);
} else {
System.out.println("J2S transpiling (" + (i + 1) + "/" + n + ") " + filePath);
if (j2sCompiler.compileToJavaScript(f)) {
ntotal++;
} else {
nerror++;
System.out.println("J2S Error processing " + filePath);
if (breakOnError)
break;
try {
if (j2sCompiler.compileToJavaScript(f)) {
ntotal++;
} else {
nerror++;
System.out.println("J2S Error processing " + filePath);
if (breakOnError)
break;
}
} catch (Exception e) {
System.out.println("J2S Exception " + e);
e.printStackTrace(System.out);
e.printStackTrace(System.err);
}
}
}
}
j2sCompiler.finalizeProject();
contexts = null;
System.out.println(
"J2S buildFinished " + ntotal + " file"+plural(ntotal) + " transpiled for " + project.getProject().getLocation());
System.out.println("J2S buildFinished " + ntotal + " file" + plural(ntotal) + " transpiled for "
+ project.getProject().getLocation());
System.out.println("J2S buildFinished nerror = " + nerror + " " + new Date());
}
}
isCleanBuild = false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -390,11 +390,18 @@ boolean compileToJavaScript(IFile javaSource) {
if (pt >= 0)
packageName = packageName.substring(0, pt);
if (!copyResources.contains(packageName)) {
copyResources.add(packageName);
String sourceDir = sourceLocation.substring(0, sourceLocation.lastIndexOf("/" + packageName + "/"));
File src = new File(sourceDir, packageName);
File dest = new File(j2sPath, packageName);
copySiteResources(src, dest);
copyResources.add(packageName);
pt = sourceLocation.lastIndexOf("/" + packageName + "/");
if (pt <= 0) {
// also don't allow "" root directory
if (!"_".equals(packageName))
System.out.println("J2S ignoring bad sourceLocation for package \"" + packageName + "\": " + sourceLocation);
} else {
String sourceDir = sourceLocation.substring(0, pt);
File src = new File(sourceDir, packageName);
File dest = new File(j2sPath, packageName);
copySiteResources(src, dest);
}
}
}
return true;
Expand Down
Binary file modified sources/net.sf.j2s.java.core/dist/SwingJS-site.zip
Binary file not shown.
60 changes: 60 additions & 0 deletions sources/net.sf.j2s.java.core/doc/Differences.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,26 @@
Notes
=====

---IMPORTANT CHARACTER SET NOTE---

It is critical that all development work in Java2Script
be done in UTF-8. This means:

- making sure your Exclipse project is set up for UTF-8 (not the Eclipse default?)
- making sure your server can serve up UTF-8 by default for any browser-loaded files
- making sure you don't edit a Java2Script class file or one of the site .js files
using a non-UTF-8 editor. It may replace non-Latin characters with "?" or garbage.

In particular, the Mandarin character 秘 (mi; "secret") is used extensively throughout
the SwingJS class files to distinguish j2s-specific fields and methods that must not
ever be overridden by subclasses. As in java.lang.Thread.java:

public static JSThread 秘thisThread;


----------------------------------


updated 11/03/19 -- adds information about File.exists() and points to src/test/async
updated 10/26/19 -- adds information about File.createTempFile()
updated 8/16/19 -- minor typos and added summary paragraph
Expand Down Expand Up @@ -557,6 +577,46 @@ closed, just as for Java.

Developers are encouraged to create a separate class that handles general calls.
An example class can be found in the SwingJS distribution as src/test/async/AsyncDialog.java.
Very simple modifications to the Java allows asynchronous operation using AsyncDialog. Here
is a simple "do you want to close this frame" example, where you can see that what we have
done is to set the reply into an ActionListener that is defined in the constructor of
the AsyncDisplay object:

// Original:
//
// private void promptQuit() {
// int sel = JOptionPane.showConfirmDialog(null, PROMPT_EXIT, NAME, JOptionPane.YES_NO_OPTION);
// switch (sel) {
// case JOptionPane.YES_OPTION:
// resultsTab.clean();
// seqs.dispose();
// if (fromMain) {
// System.exit(0);
// }
// break;
// }
// }

private void promptQuitAsync() {
new AsyncDialog(new ActionListener() {

@Override
public void actionPerformed(ActionEvent e) {
int sel = ((AsyncDialog)e.getSource()).getOption();
switch (sel) {
case JOptionPane.YES_OPTION:
resultsTab.clean();
seqs.dispose();
if (fromMain) {
System.exit(0);
}
break;
}
}}).showConfirmDialog(null, PROMPT_EXIT, NAME, JOptionPane.YES_NO_OPTION);
}

Very simple!


native methods
--------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@
public class JColorChooser extends JComponent {


static Component listener;

private ColorSelectionModel selectionModel;

private JComponent previewPanel;
Expand Down Expand Up @@ -172,7 +174,8 @@ static class ASYNCHRONOUS_COLOR extends Color implements UIResource {}
*/
public static Color showDialog(Component component, String title, Color initialColor) {

if (!(component instanceof PropertyChangeListener)) {
Component c = (listener == null ? component : listener);
if (!(c instanceof PropertyChangeListener)) {
System.err.println("JOptionPanel: parentComponent is not a PropertyChangeListener");
return null;
}
Expand Down Expand Up @@ -663,7 +666,7 @@ protected void initColorChooserDialog(Component c, JColorChooser chooserPane,
}

if (okListener == null && cancelListener == null)
秘ensurePropertyChangeListener(this, c);
秘ensurePropertyChangeListener(this, JColorChooser.listener == null ? c : JColorChooser.listener);

this.chooserPane = chooserPane;

Expand Down
17 changes: 11 additions & 6 deletions sources/net.sf.j2s.java.core/src/javax/swing/JOptionPane.java
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,8 @@ public class JOptionPane extends JComponent {

private static boolean USE_HTML5_MODAL_FOR_WARNINGS_AND_ERRORS = true;

private static Component listener;

/**
* Shows a question-message dialog requesting input from the user. The
* dialog uses the default frame, which usually means it is centered on the
Expand Down Expand Up @@ -640,7 +642,7 @@ public static Object showInputDialog(Component parentComponent, Object message,

Object value;

if (!(parentComponent instanceof PropertyChangeListener)) {
if (!isListener(parentComponent)) {

if (!(message instanceof String)) {
warnJSDeveloper();
Expand Down Expand Up @@ -754,9 +756,8 @@ public static void showMessageDialog(Component parentComponent, Object message,

boolean simplify = USE_HTML5_MODAL_FOR_WARNINGS_AND_ERRORS
&& (messageType == WARNING_MESSAGE || messageType == ERROR_MESSAGE);
boolean isPropertyListener = parentComponent instanceof PropertyChangeListener;

if (simplify || !isPropertyListener) {
if (simplify || !isListener(parentComponent)) {
if (!simplify && !(message instanceof String))
warnJSDeveloper();
String s = getMessageTypeString(messageType, ": ") + (title == "Message" ? "" : title + "\n\n")
Expand All @@ -767,6 +768,10 @@ public static void showMessageDialog(Component parentComponent, Object message,
showOptionDialog(parentComponent, message, title, DEFAULT_OPTION, messageType, icon, null, null);
}

private static boolean isListener(Component parentComponent) {
return (listener != null ? listener : parentComponent) instanceof PropertyChangeListener;
}

private static void warnJSDeveloper() {
System.err.println("JOptionPane: Component does not implement PropertyChangeListener.");
}
Expand Down Expand Up @@ -909,7 +914,7 @@ public static int showConfirmDialog(Component parentComponent, Object message, S

boolean jsReturn = true;

if (!(parentComponent instanceof PropertyChangeListener)) {
if (!isListener(parentComponent)) {
if (!(message instanceof String)) {
warnJSDeveloper();
message = "?";
Expand Down Expand Up @@ -985,7 +990,7 @@ public static int showConfirmDialog(Component parentComponent, Object message, S
public static int showOptionDialog(Component parentComponent, Object message, String title, int optionType,
int messageType, Icon icon, Object[] options, Object initialValue) {

if (!(parentComponent instanceof PropertyChangeListener)) {
if (!isListener(parentComponent)) {
warnJSDeveloper();
return CANCEL_OPTION;
}
Expand Down Expand Up @@ -1132,7 +1137,7 @@ public void componentShown(ComponentEvent ce) {
setValue(UNINITIALIZED_VALUE);
}
});
秘ensurePropertyChangeListener(this, parentComponent);
秘ensurePropertyChangeListener(this, (listener == null ? parentComponent : listener));

addPropertyChangeListener(new PropertyChangeListener() {
@Override
Expand Down
Loading