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/dropins/net.sf.j2s.core.jar
Binary file not shown.
Binary file modified sources/net.sf.j2s.core/dist/net.sf.j2s.core_3.1.1.jar
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@
import org.eclipse.jdt.core.dom.WhileStatement;
import org.eclipse.jdt.core.dom.WildcardType;

// BH 6/19/2018 -- adds .j2s j2s.class.replacements=org.apache.log4j.->jalview.javascript.log4j.;
// BH 5/15/2018 -- fix for a[pt++] |= 3 incrementing pt twice and disregarding a[][] (see test/Test_Or.java)
// BH 3/27/2018 -- fix for anonymous inner classes of inner classes not having this.this$0
// BH 1/5/2018 -- @j2sKeep removed; refactored into one class
Expand Down Expand Up @@ -1450,7 +1451,9 @@ private boolean addClassOrInterface(ASTNode node, ITypeBinding binding, List<?>
buffer.append(trailingBuffer.getAssertString());
addDefaultConstructor();
buffer.append("var $vals=[];\r\n");
buffer.append("Clazz.newMeth(C$, 'values', function() { return $vals }, 1);\r\n");
// implicit Enum methods added as trailer
buffer.append("Clazz.newMeth(C$, 'values', function() { return $vals }, 1);\r\n");
buffer.append("Clazz.newMeth(C$, '$valueOf$S', function(name) { for (var val in $vals){ if ($vals[val].$name == name) return $vals[val]} return null }, 1);\r\n");
} else {
buffer.append(trailingBuffer); // also writes the assert string
if (isAnonymous) {
Expand Down Expand Up @@ -4359,9 +4362,10 @@ private static String j2sGetParamCode(ITypeBinding binding, boolean addAAA, bool
name = "S";
break;
default:
if (prefix != null)
if (prefix == null)
name = checkClassReplacement(name);
else
name = (asGenericObject ? "O" : prefix + name); // "O";//

name = name.replace("java.lang.", "").replace('.', '_');
break;
}
Expand Down Expand Up @@ -4653,6 +4657,54 @@ public void setDebugging(boolean isDebugging) {
}



private static Map<String, String> htClassReplacements;
private static List<String> lstPackageReplacements;

public static void setClassReplacements(String keyValues) {
// j2s.class.replacements=org.apache.log4j.*:jalview.jslogger.;
htClassReplacements = null;
if (keyValues == null)
return;
htClassReplacements = new Hashtable<String, String>();
lstPackageReplacements = new ArrayList<String>();
String[] pairs = keyValues.split(";");
for (int i = pairs.length; --i >= 0;) {
pairs[i] = pairs[i].trim();
if (pairs[i].length() == 0)
continue;
String[] kv = pairs[i].split("->");
htClassReplacements.put(kv[0], kv[1]);
if (kv[0].endsWith("."))
lstPackageReplacements.add(kv[0]);
System.err.println("class replacement " + kv[0] + " --> " + kv[1]);
}
}


private static String checkClassReplacement(String className) {
if (htClassReplacements != null) {
String rep = htClassReplacements.get(className);
if (rep == null && lstPackageReplacements != null) {
for (int i = lstPackageReplacements.size(); --i >= 0;) {
rep = lstPackageReplacements.get(i);
if (className.startsWith(rep)) {
rep = htClassReplacements.get(rep) + className.substring(rep.length());
break;
}
if (i == 0)
rep = null;
}

}
if (rep != null) {
System.out.println(className + " -> " + rep);
return rep;
}
}
return className;
}

/**
* tracks file byte pointers for @j2sNative, @j2sIgnore
*/
Expand Down Expand Up @@ -4714,7 +4766,7 @@ private String getNestedClazzLoads(String className, boolean doCache) {
// loop through packages and outer Class
while (i < parts.length && (i == 1 || !Character.isUpperCase(parts[i - 1].charAt(0))))
s += "." + parts[i++];
s = "'" + s + "'";
s = "'" + checkClassReplacement(s) + "'";
// int nlast = parts.length;
if (i < parts.length) {
s = "[" + s;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ public void process(ICompilationUnit sourceUnit, IContainer binaryFolder) {
Java2ScriptVisitor.setNoQualifiedNamePackages(getProperty("j2s.compiler.nonqualified.classes"));
boolean isDebugging = "debug".equals(getProperty("j2s.compiler.mode"));
visitor.setDebugging(isDebugging);
Java2ScriptVisitor.setClassReplacements(getProperty("j2s.class.replacements"));
String j2sPath = siteFolder + "/swingjs/j2s";
try {

Expand Down
Binary file removed sources/net.sf.j2s.java.core/SwingJS-site.zip
Binary file not shown.
4 changes: 2 additions & 2 deletions sources/net.sf.j2s.java.core/build_core_applet.xml
Original file line number Diff line number Diff line change
Expand Up @@ -294,8 +294,8 @@

<echo>TODO: Could delete demo html files? </echo>

<echo>creating SwingJS-site.zip </echo>
<zip destfile="SwingJS-site.zip" basedir="site" />
<echo>creating dist/SwingJS-site.zip </echo>
<zip destfile="dist/SwingJS-site.zip" basedir="site" />

</target>

Expand Down
Binary file not shown.
4 changes: 4 additions & 0 deletions sources/net.sf.j2s.java.core/src/a2s/TextArea.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ public TextArea(String text, int rows, int cols) {
setViewportView(ta = new JTextArea(text, rows, cols));
awtDefaults();
}

public void setCaretPosition(int pos) {
ta.setCaretPosition(pos);
}

void awtDefaults() {
// setAutoscrolls(true);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* Copyright (c) 1996, 1997, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/

package java.beans;

import java.util.EventListener;

/**
* A VetoableChange event gets fired whenever a bean changes a "constrained"
* property. You can register a VetoableChangeListener with a source bean
* so as to be notified of any constrained property updates.
*/
public interface VetoableChangeListener extends EventListener {
/**
* This method gets called when a constrained property is changed.
*
* @param evt a <code>PropertyChangeEvent</code> object describing the
* event source and the property that has changed.
* @exception PropertyVetoException if the recipient wishes the property
* change to be rolled back.
*/
void vetoableChange(PropertyChangeEvent evt)
throws PropertyVetoException;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
/*
* Copyright (c) 2000, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/

package java.beans;

import java.util.EventListenerProxy;

/**
* A class which extends the <code>EventListenerProxy</code> specifically
* for associating a <code>VetoableChangeListener</code> with a "constrained"
* property. Instances of this class can be added as a
* <code>VetoableChangeListener</code> to a bean which supports firing
* VetoableChange events.
* <p>
* If the object has a <code>getVetoableChangeListeners()</code>
* method then the array returned could be a mixture of
* <code>VetoableChangeListener</code> and
* <code>VetoableChangeListenerProxy</code> objects.
* <p>
* @see java.util.EventListenerProxy
* @see VetoableChangeListener
* @see VetoableChangeSupport#getVetoableChangeListeners
* @since 1.4
*/
public class VetoableChangeListenerProxy extends EventListenerProxy
implements VetoableChangeListener {

private String propertyName;

/**
* @param propertyName The name of the property to listen on.
* @param listener The listener object
*/
public VetoableChangeListenerProxy(String propertyName,
VetoableChangeListener listener) {
super(listener);
this.propertyName = propertyName;
}

/**
* Forwards the property change event to the listener delegate.
*
* @param evt the property change event
*
* @exception PropertyVetoException if the recipient wishes the property
* change to be rolled back.
*/
public void vetoableChange(PropertyChangeEvent evt) throws
PropertyVetoException{
((VetoableChangeListener)getListener()).vetoableChange(evt);
}

/**
* Returns the name of the named property associated with the
* listener.
*/
public String getPropertyName() {
return propertyName;
}
}
Loading