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/dropins/net.sf.j2s.core_3.1.1.jar
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -221,23 +221,24 @@ private void addApplication() {
apps.add(getQualifiedClassName());
}

private void checkAddApplet(ITypeBinding binding) {
private boolean checkAddApplet(ITypeBinding binding) {
if (Modifier.isAbstract(binding.getModifiers()))
return;
return false;
ITypeBinding b = binding;
while ((binding = binding.getSuperclass()) != null) {
String name = binding.getQualifiedName();
if (!("javax.swing.JApplet".equals(name))) {
if (name.startsWith("java.") || name.startsWith("javax"))
return;
return false;
continue;
}
if (applets == null)
applets = new ArrayList<String>();
name = b.getQualifiedName();
applets.add(name);
break;
return true;
}
return false;
}

public ArrayList<String> getAppList(boolean isApplets) {
Expand Down Expand Up @@ -265,6 +266,8 @@ private void setInnerGlobals(Java2ScriptVisitor parent, ASTNode node, String vis

private ASTNode innerTypeNode;

private boolean isUserApplet;

public boolean visit(PackageDeclaration node) {
setMapJavaDoc(node);
String name = node.getName().toString();
Expand Down Expand Up @@ -613,16 +616,18 @@ public boolean visit(MethodDeclaration node) {
if (key != null)
methodDeclareNameStack.push(key);

boolean isStatic = isStatic(node);
boolean isNative = Modifier.isNative(node.getModifiers());

int mods = node.getModifiers();
boolean isNative = Modifier.isNative(mods);
if (node.getBody() == null && !isNative) {
// Abstract method
return false;
}

boolean isStatic = Modifier.isStatic(mods);
boolean isConstructor = node.isConstructor();
String name = getMethodNameOrArrayForDeclaration(node, mBinding, isConstructor);
boolean addUnqualified = isUserApplet && !isConstructor && !isStatic && Modifier.isPublic(mods);
String name = getMethodNameOrArrayForDeclaration(node, mBinding, isConstructor, addUnqualified);
if (isConstructor && name.equals("'c$'") || mBinding.isVarargs() && mBinding.getParameterTypes().length == 1)
haveDefaultConstructor = true; // in case we are not qualifying
// names here
Expand Down Expand Up @@ -1100,7 +1105,7 @@ private boolean addClassOrInterface(ASTNode node, ITypeBinding binding, List<?>
// check for a JApplet

if (isTopLevel && !isEnum) {
checkAddApplet(binding);
isUserApplet = checkAddApplet(binding);
}

// add the anonymous wrapper if needed
Expand Down Expand Up @@ -2050,10 +2055,10 @@ public boolean visit(Assignment node) {
left.accept(this);
switch (op) {
case "|=":
buffer.append("||");
buffer.append("|"); // surprise! | not ||
break;
case "&=":
buffer.append("&&");
buffer.append("&"); // & not &&
break;
default:
case "^=":
Expand Down Expand Up @@ -3927,10 +3932,10 @@ private static void addGenericClassMethod(String classKey, String methodName, St
* @return j2s-qualified name or an array of j2s-qualified names
*/
private String getMethodNameOrArrayForDeclaration(MethodDeclaration node, IMethodBinding mBinding,
boolean isConstructor) {
boolean isConstructor, boolean addUnqualified) {
SimpleName nodeName = node.getName();
String methodName = (isConstructor ? "c$" : NameMapper.getJ2SName(nodeName));
String name = getJ2SQualifiedName(methodName, null, mBinding, null, false);
String qname = getJ2SQualifiedName(methodName, null, mBinding, null, false);
ITypeBinding methodClass = mBinding.getDeclaringClass();
List<String> names = null;
// System.err.println("checking methodList for " + nodeName.toString() +
Expand All @@ -3950,16 +3955,19 @@ private String getMethodNameOrArrayForDeclaration(MethodDeclaration node, IMetho
if (pname != null)
names.add(pname);
}
} else if (addUnqualified && !methodName.equals(qname)) {
names = new ArrayList<String>();
names.add(methodName);
}
if (names == null || names.size() == 0)
return "'" + name + "'";
name = ",'" + name + "'";
return "'" + qname + "'";
qname = ",'" + qname + "'";
for (int i = names.size(); --i >= 0;) {
String next = ",'" + names.get(i) + "'";
if (name.indexOf(next) < 0)
name += next;
if (qname.indexOf(next) < 0)
qname += next;
}
return "[" + name.substring(1) + "]";
return "[" + qname.substring(1) + "]";
}

/**
Expand Down
Binary file added sources/net.sf.j2s.java.core/SwingJS-site.zip
Binary file not shown.
16 changes: 16 additions & 0 deletions sources/net.sf.j2s.java.core/build_core_applet.xml
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,22 @@
${javaCoreAppletFiles}
" />
</antcall>

<echo>creating swingjs2.js</echo>
<concat destfile="srcjs/swingjs2.js">
<filelist dir="srcjs/js" files="jquery.js,j2sJQueryExt.js,j2sApplet.js,j2sClazz.js,SwingJSApplet.js" />
</concat>

<echo>copying srcjs files into site</echo>
<copy todir="site/swingjs/js">
<fileset dir="srcjs"/>
</copy>

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

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

</target>


Expand Down
6 changes: 5 additions & 1 deletion sources/net.sf.j2s.java.core/src/a2s/A2SEvent.java
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ static Event convertToOld(AWTEvent e) {
getOldEventKey(ke),
(ke.getModifiers() & ~InputEvent.BUTTON1_MASK));

case MouseEvent.MOUSE_CLICKED:
case MouseEvent.MOUSE_PRESSED:
case MouseEvent.MOUSE_RELEASED:
case MouseEvent.MOUSE_MOVED:
Expand Down Expand Up @@ -233,7 +234,10 @@ public static Component addListener(JComponent container, Component comp) {
if (top == null)
top = ((A2SContainer) ((JComponent) comp).getTopLevelAncestor());
if (top == null)
return comp;
if (comp instanceof A2SContainer)
top = (A2SContainer) comp;
else
return comp;
A2SListener listener = top.getA2SListener();
if (comp instanceof AbstractButton) {
if (!isListener(((AbstractButton) comp).getActionListeners(), listener))
Expand Down
7 changes: 6 additions & 1 deletion sources/net.sf.j2s.java.core/src/a2s/Applet.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,13 @@ public A2SListener getA2SListener() {
// public void init() {
// }

private boolean paintMeNotified;

protected void paintMe(Graphics g) {
System.out.println("paintMe has not been implemented!");
if (!paintMeNotified) {
System.out.println("paintMe has not been implemented for " + this);
paintMeNotified = true;
}
}


Expand Down
17 changes: 16 additions & 1 deletion sources/net.sf.j2s.java.core/src/a2s/Scrollbar.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,21 @@

import javax.swing.JScrollBar;

public class Scrollbar extends JScrollBar {
public class Scrollbar extends JScrollBar implements A2SContainer {

public Scrollbar(int direction) {
super(direction);
A2SEvent.addListener(null, this);
}

public Scrollbar() {
super();
A2SEvent.addListener(null, this);
}

public Scrollbar(int orientation, int value, int extent, int min, int max) {
super(orientation, value, extent, min, max);
A2SEvent.addListener(null, this);
}

@Override
Expand All @@ -36,6 +39,17 @@ public int getValue() {
return super.getValue();
}


// JCheckBox does not allow access to fireAdjustmentChanged.
// It really does not matter who holds the listener, actually.
A2SListener listener = null;
@Override
public A2SListener getA2SListener() {
if (listener == null)
listener = new A2SListener();
return listener;
}

// public void addMouseListener(MouseListener c) {
// //super.addMouseListener(c);
//
Expand All @@ -44,4 +58,5 @@ public int getValue() {
// //super.addMouseMotionListener(c);
// }


}
2 changes: 2 additions & 0 deletions sources/net.sf.j2s.java.core/src/java/awt/JSComponent.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ public static void ensurePropertyChangeListener(Component c, Component listener)
*
*/

public boolean isFramedApplet;

public String htmlName;
protected int num;
private static int incr;
Expand Down
Loading