Skip to content

Commit a811459

Browse files
authored
Merge pull request #50 from BobHanson/yadav1
Yadav1
2 parents 40bae9d + f363aa8 commit a811459

File tree

12 files changed

+79
-18
lines changed

12 files changed

+79
-18
lines changed
165 Bytes
Binary file not shown.
165 Bytes
Binary file not shown.

sources/net.sf.j2s.core/src/net/sf/j2s/core/astvisitors/Java2ScriptVisitor.java

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@
122122
import org.eclipse.jdt.core.dom.WhileStatement;
123123
import org.eclipse.jdt.core.dom.WildcardType;
124124

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

912913
public boolean visit(SynchronizedStatement node) {
913-
// we wrap this with a simple if() statement,
914-
// checking that it is not null
915-
buffer.append("if(!(");
916-
node.getExpression().accept(this);
917-
buffer.append(")){throw new NullPointerException()}else");
914+
// we could wrap this with a simple if() statement,
915+
// checking that it is not null, but that seems to me
916+
// to be unnecessary. When would one ever intentionally
917+
// produce a null pointer exception from synchronized(...)?
918+
919+
Expression e = node.getExpression();
920+
if (e instanceof Name
921+
|| e instanceof TypeLiteral
922+
|| e instanceof ThisExpression)
923+
return false;
924+
buffer.append("/*sync " + e.getClass().getName() + "*/");
925+
// get actual JavaScript code
926+
int pt = buffer.length();
927+
e.accept(this);
928+
String expr = buffer.substring(pt, buffer.length());
929+
buffer.setLength(pt);
930+
// ignore (treeLock())
931+
if (e instanceof MethodInvocation && expr.indexOf(".getTreeLock()") >= 0){
932+
MethodInvocation m = (MethodInvocation) e;
933+
m.getExpression().getName();
934+
return false;
935+
}
936+
buffer.append(expr);
937+
buffer.append(";");
918938
node.getBody().accept(this);
919939
return false;
920940
}
1.16 KB
Binary file not shown.

sources/net.sf.j2s.java.core/src/java/awt/Container.java

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1649,6 +1649,10 @@ public Dimension getPreferredSize() {
16491649
@Override
16501650
@Deprecated
16511651
public Dimension preferredSize() {
1652+
return preferredSizeContainer();
1653+
}
1654+
1655+
protected Dimension preferredSizeContainer() {
16521656
/* Avoid grabbing the lock if a reasonable cached size value
16531657
* is available.
16541658
*/
@@ -1662,9 +1666,9 @@ public Dimension preferredSize() {
16621666
}
16631667
}
16641668
return (dim == null ? null : new Dimension(dim));
1665-
}
1669+
}
16661670

1667-
/**
1671+
/**
16681672
* Returns the minimum size of this container. If the minimum size has
16691673
* not been set explicitly by {@link Component#setMinimumSize(Dimension)}
16701674
* and this {@code Container} has a {@code non-null} {@link LayoutManager},
@@ -1858,12 +1862,7 @@ public void paintContainer(Graphics g) {
18581862
*/
18591863
@Override
18601864
public void update(Graphics g) {
1861-
if (isShowing()) {
1862-
// if (! (peer instanceof LightweightPeer)) {
1863-
g.clearRect(0, 0, width, height);
1864-
// }
1865-
paint(g);
1866-
}
1865+
updateContainer(g);
18671866
}
18681867

18691868
// /**
@@ -1901,7 +1900,17 @@ public void update(Graphics g) {
19011900
// }
19021901
// }
19031902

1904-
/**
1903+
protected void updateContainer(Graphics g) {
1904+
1905+
if (isShowing()) {
1906+
// if (! (peer instanceof LightweightPeer)) {
1907+
g.clearRect(0, 0, width, height);
1908+
// }
1909+
paint(g);
1910+
}
1911+
}
1912+
1913+
/**
19051914
* Paints each of the components in this container.
19061915
* @param g the graphics context.
19071916
* @see Component#paint

sources/net.sf.j2s.java.core/src/java/awt/Window.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -830,6 +830,23 @@ public void paint(Graphics g) {
830830
paintContainer(g);
831831
}
832832

833+
@Override
834+
public void update(Graphics g) {
835+
updateContainer(g);
836+
}
837+
838+
@Override
839+
public void printAll(Graphics g) {
840+
// untested
841+
super.printAll(g);
842+
}
843+
844+
@Override
845+
public Dimension getPreferredSize() {
846+
return preferredSizeContainer();
847+
}
848+
849+
833850
/**
834851
* Shows or hides this {@code Window} depending on the value of parameter
835852
* {@code b}.

sources/net.sf.j2s.java.core/src/swingjs/api/js/JQueryObject.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ public interface JQueryObject {
2626

2727
public abstract JQueryObject addClass(String name);
2828

29+
public abstract JQueryObject removeClass(String name);
30+
2931
public abstract void empty();
3032

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

sources/net.sf.j2s.java.core/src/swingjs/jquery/JQueryUI.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sources/net.sf.j2s.java.core/src/swingjs/jquery/j2sMenu.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ try{
4949
_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")},
5050
_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()},
5151
_activate:function(e){this.active.is(".ui-state-disabled")||(this.active.children("a[aria-haspopup='true']").length?this.expand(e):this.select(e))},
52-
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()},
52+
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);/[^\-+GG+GG\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()},
5353
_itemRole:function(){return{menu:"menuitem",listbox:"option"}[this.options.role]},
5454
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})},
5555
_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))},

sources/net.sf.j2s.java.core/src/swingjs/plaf/HTML5LookAndFeel.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ protected void initSystemColorDefaults(UIDefaults table) {
376376
"window", "#FFFFFF", /* Default color for the interior of windows */
377377
"windowBorder", "#000000", /* ??? */
378378
"windowText", "#333333", /* ??? */
379-
"menu", "#C0C0C0", /* Background color for menus */
379+
"menu", "#EEEEEE",//"#C0C0C0", /* Background color for menus */
380380
"menuText", "#333333", /* Text color for menus */
381381
"text", "#C0C0C0", /* Text background color */
382382
"textText", "#333333", /* Text foreground color */

0 commit comments

Comments
 (0)