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 @@
20191027191514
20191031001912
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 @@
20191027191514
20191031001912
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public class CorePlugin extends Plugin {
*
*/
public static String VERSION = "3.2.4.09";
// BH 2019.10.30 -- 3.2.4.09 fixes problem with team...show history...compare having null project.getProject().getLocation()
// BH 2019.10.27 -- 3.2.4.09 fixes problem with method of name c() becoming c$() -- constructor
// BH 2019.10.25 -- 3.2.4.09 adds j2s.compiler.java.version (default 8)
// BH 2019.10.25 -- 3.2.4.09 adds j2s.break.on.error (default false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,12 @@ public Java2ScriptCompilationParticipant() {
*/
@Override
public boolean isActive(IJavaProject project) {
if (project.getProject().getLocation() == null) {
// happens when comparing to team...show history item
return false;
}
boolean isj2s = Java2ScriptCompiler.isActive(project);
String loc = " " + project.getProject().getLocation().toString() + " ";
String loc = " " + project.getProject().getLocation() + " ";
// notify only if changed
if (isActiveNotified.indexOf(isj2s + loc) < 0) {
System.out.println("J2S isActive " + isj2s + loc);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ boolean compileToJavaScript(IFile javaSource) {
packageName = packageName.substring(0, pt);
if (!copyResources.contains(packageName)) {
copyResources.add(packageName);
String sourceDir = sourceLocation.substring(0, sourceLocation.indexOf("/" + packageName + "/"));
String sourceDir = sourceLocation.substring(0, sourceLocation.lastIndexOf("/" + packageName + "/"));
File src = new File(sourceDir, packageName);
File dest = new File(j2sPath, packageName);
copySiteResources(src, dest);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1204,9 +1204,11 @@ private void addMethodInvocation(SimpleName javaQualifier, List<?> arguments, IM
}
} else {
appendFinalMethodQualifier(expression, declaringClass, bname,
(isStatic && !isPrivate ? FINAL_ESCAPECACHE : FINAL_CACHE));
(isStatic && !isPrivate ? FINAL_ESCAPECACHE : FINAL_CACHE)
| (isStatic ? FINAL_STATIC : 0));
buffer.append(".");
}

// keep a pointer, because we may rewrite this
int ptLog = (doLog ? buffer.length() : 0);

Expand Down Expand Up @@ -1247,10 +1249,11 @@ private void addMethodInvocation(SimpleName javaQualifier, List<?> arguments, IM

String j2sName = getFinalDotQualifiedNameForMethod(javaQualifier, mBinding,
(expression == null ? METHOD_NULLEXPRESSION : 0) | METHOD_ISQUALIFIED
| (lambdaArity >= 0 ? LAMBDA_METHOD : 0));
| (lambdaArity >= 0 ? LAMBDA_METHOD : 0) | (isStatic ? FINAL_STATIC : 0));

String finalMethodNameWith$Params = getFinalMethodNameWith$Params(j2sName, declaringClassJavaClassName,
mBinding, null, true, METHOD_NOTSPECIAL);

if (lambdaArity >= 0) {
// The problem here is that we cannot apply a method from an interface
// because those methods are not present in JavaScript.
Expand Down Expand Up @@ -1323,8 +1326,12 @@ private void appendFinalMethodQualifier(Expression qualifier, ITypeBinding decla
}
} else if (qualifier instanceof Name && !isVariableBinding(qualifier)) {
buffer.append(getFinalJ2SClassNameQualifier((Name) qualifier, declaringClass, null, flags));
} else if ((flags & FINAL_STATIC) != 0) {
// ensure even if field.method(), as long as method is static, we use Class.method()
// otherwise a null value for field will throw an exception.
buffer.append(getFinalJ2SClassNameQualifier(null, declaringClass, null, flags));
} else {
// xxxx.field.foo()
// xxxx.field.foo() -- but only if foo is not static
// (x ? y : z).foo()
// xxx.this.foo()
qualifier.accept(this);
Expand Down Expand Up @@ -1593,7 +1600,7 @@ public boolean visit(WhileStatement node) {
private static final int FIELD_DECL_STATIC_NONDEFAULT = 1;
private static final int FIELD_DECL_STATIC_DEFAULTS = 2;
private static final int FIELD_DECL_NONSTATIC_ALL = 3;

private void addAnonymousFunctionWrapper(boolean isOpen) {
buffer.append(
isOpen ? (buffer.lastIndexOf(")") >= buffer.length() - 3 ? ";" : "") + "\r\n(function(){" : "})()\r\n");
Expand Down Expand Up @@ -4543,6 +4550,9 @@ private String getFinalNameForNode(SimpleName node, char lastBufferChar, IVariab

private static final int FINAL_LAMBDA = 32;

private static final int FINAL_STATIC = 64;


/**
* Provide access to C$.$clinit$ when a static method is called or a static
* field is accessed.
Expand All @@ -4565,9 +4575,9 @@ String getFinalJ2SClassNameQualifier(Name methodQualifier, ITypeBinding declarin

if (declaringJavaClassName == null)
declaringJavaClassName = getJavaClassNameQualified(declaringJavaClass);
boolean doEscape = ((flags & FINAL_ESCAPE) == FINAL_ESCAPE);
boolean isStatic = ((flags & FINAL_STATIC) == FINAL_STATIC);
boolean doEscape = isStatic || ((flags & FINAL_ESCAPE) == FINAL_ESCAPE);
boolean doCache = ((flags & FINAL_CACHE) == FINAL_CACHE);

String name = removeBracketsAndFixNullPackageName(declaringJavaClassName);
doEscape &= !NameMapper.isClassKnown(name);
if (!doEscape) {
Expand All @@ -4585,7 +4595,6 @@ String getFinalJ2SClassNameQualifier(Name methodQualifier, ITypeBinding declarin
// lambda classes will always be defined at this point. No need to cache them
if (name.indexOf("$lambda") >= 0)
return getFinalJ2SClassName(name, FINAL_P);

return getFinalClazzLoadI$Reference(declaringJavaClass, name, doCache);
}

Expand Down
Binary file modified sources/net.sf.j2s.java.core/dist/SwingJS-site.zip
Binary file not shown.
5 changes: 3 additions & 2 deletions sources/net.sf.j2s.java.core/src/java/awt/Container.java
Original file line number Diff line number Diff line change
Expand Up @@ -1081,7 +1081,8 @@ protected void addImpl(Component comp, Object constraints, int index) {
protected void addImplCont(Component comp, Object constraints, int index) {
synchronized (getTreeLock()) {

if (/** @j2sNative comp.getWrap$ && !this.isWrapper$ || */ false) {
// AWT a2s.List alone right now has getWrap
if (/** @j2sNative comp.秘getWrap$ && !this.秘isWrapper$ || */ false) {
comp = ((A2SWrappedComponent) comp).秘getWrap();
comp.background = comp.foreground = null; // this parent should not set the background color
}
Expand Down Expand Up @@ -1262,7 +1263,7 @@ public void remove(int index) {
public void remove(Component comp) {
synchronized (getTreeLock()) {

if (/** @j2sNative comp.getWrap$ && !this.isWrapper$ || */ false) {
if (/** @j2sNative comp.秘getWrap$ && !this.秘isWrapper$ || */ false) {
comp = ((A2SWrappedComponent) comp).秘getWrap();
}

Expand Down
12 changes: 10 additions & 2 deletions sources/net.sf.j2s.java.core/src/swingjs/plaf/JSListUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,8 @@ protected void fillDOM() {
*/
boolean isLeftToRight = true;

private boolean awtScrollPaneNeedsLayout;

/*
* The bits below define JList property changes that affect layout. When one
* of these properties changes we set a bit in updateLayoutStateNeeded. The
Expand Down Expand Up @@ -399,7 +401,6 @@ public void paint(Graphics g, JComponent c) {
}

private void paintImpl(Graphics g, JComponent c) {

// It is the responsibility of the JScrollPane scrollbar will move the JList
// to new x,y coordinates.

Expand Down Expand Up @@ -431,7 +432,6 @@ private void paintImpl(Graphics g, JComponent c) {
if ((renderer == null) || (size = dataModel.getSize()) == 0) {
return;
}

// Determine how many columns we need to paint
Rectangle paintBounds = g.getClipBounds();
int startColumn, endColumn;
Expand Down Expand Up @@ -477,6 +477,12 @@ private void paintImpl(Graphics g, JComponent c) {
rendererPane.removeAll();
// no -- this will paint the background over the painted backgrounds
// updateDOMNode();
if (awtScrollPaneNeedsLayout) {
awtScrollPaneNeedsLayout = false;
scrollPaneUI.jc.layout();
}


}

// private void paintDropLine(Graphics g) {
Expand Down Expand Up @@ -1422,6 +1428,8 @@ int convertModelToColumn(int index) {
*/
protected void maybeUpdateLayoutState() {
if (updateLayoutStateNeeded != 0) {
if (isAWT && scrollPaneUI != null)
awtScrollPaneNeedsLayout = true;
updateLayoutStateNeeded = 0; // SwingJS switch of order here for getting
// actual size
updateLayoutState();
Expand Down
13 changes: 13 additions & 0 deletions sources/net.sf.j2s.java.core/src/swingjs/plaf/JSTextAreaUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import java.beans.PropertyChangeEvent;

import javax.swing.JTextArea;
import javax.swing.event.CaretEvent;
import javax.swing.text.Element;
import javax.swing.text.PlainView;
import javax.swing.text.View;
Expand Down Expand Up @@ -173,4 +174,16 @@ protected boolean handleTab(Object jqEvent) {
}


@Override
public void caretUpdatedByProgram(CaretEvent e) {
if (!jc.isVisible() || !isAWT) // for now, AWT only
return;
@SuppressWarnings("unused")
int pt = e.getDot();
// Unfortunately, not MacOS, Edge, or MS Explorer
/**
* @j2sNative this.domNode.scrollTo && this.domNode.scrollTo(0, pt);
*/
}

}
5 changes: 5 additions & 0 deletions sources/net.sf.j2s.java.core/src/test/Test_Class.java
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,11 @@ String hello() {

}

public static void testStatic() {
// TODO Auto-generated method stub

}

}

class Test_class1 {
Expand Down
Loading