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/24/2018 -- synchronized(a = new Object()) {...} ---> ...; only if an assignment or not a simple function call to Object.getTreeLock()
// BH 6/23/2018 -- synchronized(a = new Object()) {...} ---> if(!(a = new Object()) {throw new NullPointerException()}else{...}
// BH 6/21/2018 -- CharSequence.subSequence() should be defined both subSequence$I$I and subSequence
// BH 6/20/2018 -- fixes for (int var : new int[] {3,4,5}) becoming for var var
Expand Down Expand Up @@ -910,11 +911,30 @@ public boolean visit(SwitchCase node) {
}

public boolean visit(SynchronizedStatement node) {
// we wrap this with a simple if() statement,
// checking that it is not null
buffer.append("if(!(");
node.getExpression().accept(this);
buffer.append(")){throw new NullPointerException()}else");
// we could wrap this with a simple if() statement,
// checking that it is not null, but that seems to me
// to be unnecessary. When would one ever intentionally
// produce a null pointer exception from synchronized(...)?

Expression e = node.getExpression();
if (e instanceof Name
|| e instanceof TypeLiteral
|| e instanceof ThisExpression)
return false;
buffer.append("/*sync " + e.getClass().getName() + "*/");
// get actual JavaScript code
int pt = buffer.length();
e.accept(this);
String expr = buffer.substring(pt, buffer.length());
buffer.setLength(pt);
// ignore (treeLock())
if (e instanceof MethodInvocation && expr.indexOf(".getTreeLock()") >= 0){
MethodInvocation m = (MethodInvocation) e;
m.getExpression().getName();
return false;
}
buffer.append(expr);
buffer.append(";");
node.getBody().accept(this);
return false;
}
Expand Down
Binary file modified sources/net.sf.j2s.java.core/dist/SwingJS-site.zip
Binary file not shown.
27 changes: 18 additions & 9 deletions sources/net.sf.j2s.java.core/src/java/awt/Container.java
Original file line number Diff line number Diff line change
Expand Up @@ -1649,6 +1649,10 @@ public Dimension getPreferredSize() {
@Override
@Deprecated
public Dimension preferredSize() {
return preferredSizeContainer();
}

protected Dimension preferredSizeContainer() {
/* Avoid grabbing the lock if a reasonable cached size value
* is available.
*/
Expand All @@ -1662,9 +1666,9 @@ public Dimension preferredSize() {
}
}
return (dim == null ? null : new Dimension(dim));
}
}

/**
/**
* Returns the minimum size of this container. If the minimum size has
* not been set explicitly by {@link Component#setMinimumSize(Dimension)}
* and this {@code Container} has a {@code non-null} {@link LayoutManager},
Expand Down Expand Up @@ -1858,12 +1862,7 @@ public void paintContainer(Graphics g) {
*/
@Override
public void update(Graphics g) {
if (isShowing()) {
// if (! (peer instanceof LightweightPeer)) {
g.clearRect(0, 0, width, height);
// }
paint(g);
}
updateContainer(g);
}

// /**
Expand Down Expand Up @@ -1901,7 +1900,17 @@ public void update(Graphics g) {
// }
// }

/**
protected void updateContainer(Graphics g) {

if (isShowing()) {
// if (! (peer instanceof LightweightPeer)) {
g.clearRect(0, 0, width, height);
// }
paint(g);
}
}

/**
* Paints each of the components in this container.
* @param g the graphics context.
* @see Component#paint
Expand Down
17 changes: 17 additions & 0 deletions sources/net.sf.j2s.java.core/src/java/awt/Window.java
Original file line number Diff line number Diff line change
Expand Up @@ -830,6 +830,23 @@ public void paint(Graphics g) {
paintContainer(g);
}

@Override
public void update(Graphics g) {
updateContainer(g);
}

@Override
public void printAll(Graphics g) {
// untested
super.printAll(g);
}

@Override
public Dimension getPreferredSize() {
return preferredSizeContainer();
}


/**
* Shows or hides this {@code Window} depending on the value of parameter
* {@code b}.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ public interface JQueryObject {

public abstract JQueryObject addClass(String name);

public abstract JQueryObject removeClass(String name);

public abstract void empty();

public abstract void on(String eventName, Object f);
Expand Down

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion sources/net.sf.j2s.java.core/src/swingjs/jquery/j2sMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ try{
_destroy:function(){this.element.removeAttr("aria-activedescendant").find(".ui-menu").andSelf().removeClass("ui-menu ui-widget ui-widget-content ui-corner-all ui-menu-icons").removeAttr("role").removeAttr("tabIndex").removeAttr("aria-labelledby").removeAttr("aria-expanded").removeAttr("aria-hidden").removeAttr("aria-disabled").removeUniqueId().show(),this.element.find(".ui-menu-item").removeClass("ui-menu-item").removeAttr("role").removeAttr("aria-disabled").children("a").removeUniqueId().removeClass("ui-corner-all ui-state-hover").removeAttr("tabIndex").removeAttr("role").removeAttr("aria-haspopup").children().each(function(){var t=e(this);t.data("ui-menu-submenu-carat")&&t.remove()}),this.element.find(".ui-menu-divider").removeClass("ui-menu-divider ui-widget-content")},
_keydown:function(t){function a(e){return e.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,"\\$&")}var n,r,i,s,o,u=!0;switch(t.keyCode){case e.ui.keyCode.PAGE_UP:this.previousPage(t);break;case e.ui.keyCode.PAGE_DOWN:this.nextPage(t);break;case e.ui.keyCode.HOME:this._move("first","first",t);break;case e.ui.keyCode.END:this._move("last","last",t);break;case e.ui.keyCode.UP:this.previous(t);break;case e.ui.keyCode.DOWN:this.next(t);break;case e.ui.keyCode.LEFT:this.collapse(t);break;case e.ui.keyCode.RIGHT:this.active&&!this.active.is(".ui-state-disabled")&&this.expand(t);break;case e.ui.keyCode.ENTER:case e.ui.keyCode.SPACE:this._activate(t);break;case e.ui.keyCode.ESCAPE:this.collapse(t);break;default:u=!1,r=this.previousFilter||"",i=String.fromCharCode(t.keyCode),s=!1,clearTimeout(this.filterTimer),i===r?s=!0:i=r+i,o=new RegExp("^"+a(i),"i"),n=this.activeMenu.children(".ui-menu-item").filter(function(){return o.test(e(this).children("a").text())}),n=s&&n.index(this.active.next())!==-1?this.active.nextAll(".ui-menu-item"):n,n.length||(i=String.fromCharCode(t.keyCode),o=new RegExp("^"+a(i),"i"),n=this.activeMenu.children(".ui-menu-item").filter(function(){return o.test(e(this).children("a").text())})),n.length?(this.focus(t,n),n.length>1?(this.previousFilter=i,this.filterTimer=this._delay(function(){delete this.previousFilter},1e3)):delete this.previousFilter):delete this.previousFilter}u&&t.preventDefault()},
_activate:function(e){this.active.is(".ui-state-disabled")||(this.active.children("a[aria-haspopup='true']").length?this.expand(e):this.select(e))},
refresh:function(){var t,n=this.options.icons.submenu,r=this.element.find(this.options.menus);r.filter(":not(.ui-menu)").addClass("ui-menu ui-widget ui-widget-content ui-corner-all").hide().attr({role:this.options.role,"aria-hidden":"true","aria-expanded":"false"}).each(function(){var t=e(this),r=t.prev("a"),i=e("<span>").addClass("ui-menu-icon ui-icon "+n).data("ui-menu-submenu-carat",!0);r.attr("aria-haspopup","true").prepend(i),t.attr("aria-labelledby",r.attr("id"))}),t=r.add(this.element),t.children(":not(.ui-menu-item):has(a)").addClass("ui-menu-item").attr("role","presentation").children("a").uniqueId().addClass("ui-corner-all").attr({tabIndex:-1,role:this._itemRole()}),t.children(":not(.ui-menu-item)").each(function(){var t=e(this);/[^\-+�G��G��+�G��G��\s]/.test(t.text())||t.addClass("ui-widget-content ui-menu-divider")}),t.children(".ui-state-disabled").attr("aria-disabled","true"),this.active&&!e.contains(this.element[0],this.active[0])&&this.blur()},
refresh:function(){var t,n=this.options.icons.submenu,r=this.element.find(this.options.menus);r.filter(":not(.ui-menu)").addClass("ui-menu ui-widget ui-widget-content ui-corner-all").hide().attr({role:this.options.role,"aria-hidden":"true","aria-expanded":"false"}).each(function(){var t=e(this),r=t.prev("a"),i=e("<span>").addClass("ui-menu-icon ui-icon "+n).data("ui-menu-submenu-carat",!0);r.attr("aria-haspopup","true").prepend(i),t.attr("aria-labelledby",r.attr("id"))}),t=r.add(this.element),t.children(":not(.ui-menu-item):has(a)").addClass("ui-menu-item").attr("role","presentation").children("a").uniqueId().addClass("ui-corner-all").attr({tabIndex:-1,role:this._itemRole()}),t.children(":not(.ui-menu-item)").each(function(){var t=e(this);/[^\-+�G��G��+�G��G��\s]/.test(t.text())||t.addClass("ui-widget-content ui-menu-divider")}),t.children(".ui-state-disabled").attr("aria-disabled","true"),this.active&&!e.contains(this.element[0],this.active[0])&&this.blur()},
_itemRole:function(){return{menu:"menuitem",listbox:"option"}[this.options.role]},
focus:function(e,t){var n,r;this.blur(e,e&&e.type==="focus"),this._scrollIntoView(t),this.active=t.first(),r=this.active.children("a").addClass("ui-state-focus"),this.options.role&&this.element.attr("aria-activedescendant",r.attr("id")),this.active.parent().closest(".ui-menu-item").children("a:first").addClass("ui-state-active"),e&&e.type==="keydown"?this._close():this.timer=this._delay(function(){this._close()},this.delay),n=t.children(".ui-menu"),n.length&&/^mouse/.test(e.type)&&this._startOpening(n),this.activeMenu=t.parent(),this._trigger("focus",e,{item:t})},
_scrollIntoView:function(t){var n,r,i,s,o,u;this._hasScroll()&&(n=parseFloat(e.css(this.activeMenu[0],"borderTopWidth"))||0,r=parseFloat(e.css(this.activeMenu[0],"paddingTop"))||0,i=t.offset().top-this.activeMenu.offset().top-n-r,s=this.activeMenu.scrollTop(),o=this.activeMenu.height(),u=t.height(),i<0?this.activeMenu.scrollTop(s+i):i+u>o&&this.activeMenu.scrollTop(s+i-o+u))},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ protected void initSystemColorDefaults(UIDefaults table) {
"window", "#FFFFFF", /* Default color for the interior of windows */
"windowBorder", "#000000", /* ??? */
"windowText", "#333333", /* ??? */
"menu", "#C0C0C0", /* Background color for menus */
"menu", "#EEEEEE",//"#C0C0C0", /* Background color for menus */
"menuText", "#333333", /* Text color for menus */
"text", "#C0C0C0", /* Text background color */
"textText", "#333333", /* Text foreground color */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1489,7 +1489,7 @@ else if (enableNodes != null)

private boolean enabled = true;

private void enableNode(DOMNode node, boolean b) {
protected void enableNode(DOMNode node, boolean b) {
if (node == null)
return;
DOMNode.setAttr(node, "disabled", (b ? null : "TRUE"));
Expand Down
13 changes: 13 additions & 0 deletions sources/net.sf.j2s.java.core/src/swingjs/plaf/JSMenuItemUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

public class JSMenuItemUI extends JSButtonUI {


/**
* Just a simple menu item -- not radio or checkbox
*/
Expand Down Expand Up @@ -47,4 +48,16 @@ public void installUI(JComponent jc) {
"MenuItem.font");
}


@Override
protected void enableNode(DOMNode node, boolean b) {
if (node == null)
return;
if (b) {
$(node).removeClass("ui-menu-disabled ui-state-disabled");
} else {
$(node).addClass("ui-menu-disabled ui-state-disabled");
}
}

}