Skip to content

Commit b097771

Browse files
hansonrhansonr
authored andcommitted
focus, events, menu accelerators and rewrite of ui-menu
1 parent eef61d4 commit b097771

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+3207
-1737
lines changed
3.72 KB
Binary file not shown.
93 Bytes
Binary file not shown.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20190114011334
1+
20190116234645
3.72 KB
Binary file not shown.
93 Bytes
Binary file not shown.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20190114011334
1+
20190116234645

sources/net.sf.j2s.core/src/net/sf/j2s/core/Java2ScriptCompiler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -503,7 +503,7 @@ private String getDefaultHTMLTemplate() {
503503
"getClassList = function(){J2S._saveFile('_j2sclasslist.txt', Clazz.ClassFilesLoaded.sort().join('\\n'))}\n" +
504504
"</script>\n" +
505505
"<div style=\"position:absolute;left:900px;top:30px;width:600px;height:300px;\">\n" +
506-
"<div id=\"sysoutdiv\" style=\"border:1px solid green;width:100%;height:95%;overflow:auto\"></div>\n" +
506+
"<div id=\"sysoutdiv\" contentEditable=\"true\" style=\"border:1px solid green;width:100%;height:95%;overflow:auto\"></div>\n" +
507507
"This is System.out. <a href=\"javascript:testApplet._clearConsole()\">clear it</a> <br>Add ?j2snocore to URL to see full class list; ?j2sdebug to use uncompressed j2s/core files <br><a href=\"javascript:getClassList()\">get _j2sClassList.txt</a>\n" +
508508
"</div>\n" +
509509
"</body>\n" +

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

Lines changed: 33 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3009,7 +3009,7 @@ public boolean visit(InfixExpression node) {
30093009
Expression right = node.getRightOperand();
30103010
List<?> extendedOperands = node.extendedOperands();
30113011

3012-
if (getConstantValue(node, true)) {
3012+
if (noDocProblem(left) && noDocProblem(right) && getConstantValue(node, true)) {
30133013
return false;
30143014
}
30153015
ITypeBinding expTypeBinding = node.resolveTypeBinding();
@@ -3105,9 +3105,12 @@ public boolean visit(InfixExpression node) {
31053105
}
31063106
buffer.append(' ');
31073107
// right
3108-
if (right instanceof ParenthesizedExpression && getJ2sJavadoc(right, DOC_CHECK_ONLY) != null) {
3108+
if (right instanceof ParenthesizedExpression || getJ2sJavadoc(right, DOC_CHECK_ONLY) != null) {
31093109
buffer.append("(");
3110-
addOperand(((ParenthesizedExpression) right).getExpression(), isToString && !isBitwise);
3110+
addJ2SDoc(right);
3111+
if (right instanceof ParenthesizedExpression)
3112+
right = ((ParenthesizedExpression) right).getExpression();
3113+
addOperand(right, isToString && !isBitwise);
31113114
buffer.append(")");
31123115
} else {
31133116
addOperand(right, isToString && !isBitwise);
@@ -4233,6 +4236,7 @@ private boolean appendBoxingNode(ASTNode element, boolean toCharCode) {
42334236
// Double > x will be unboxed
42344237
// Character == 'c' will be unboxed
42354238
// f$Integer(int) will be boxed
4239+
//buffer.append("/* ?? " + (element instanceof Expression) + " " + element.getClass().getName() + " " + element + " ?? */");
42364240
if (element instanceof Expression) {
42374241
Expression exp = (Expression) element;
42384242
if (exp.resolveBoxing()) {
@@ -4261,11 +4265,20 @@ private boolean appendBoxingNode(ASTNode element, boolean toCharCode) {
42614265
return true;
42624266
}
42634267
}
4264-
if (!(element instanceof ParenthesizedExpression) && !(element instanceof PrefixExpression) && getConstantValue(exp, true)) {
4268+
if (!(exp instanceof ParenthesizedExpression)
4269+
&& !(exp instanceof PrefixExpression)
4270+
&& !(exp instanceof InfixExpression)
4271+
&& !(exp instanceof PostfixExpression)
4272+
&& getConstantValue(exp, true)) {
4273+
4274+
// buffer.append("/* !!! */");
4275+
42654276
return false;
42664277
}
42674278
}
4279+
//buffer.append("/* >>> "+ element.getClass().getName() + "*/");
42684280
element.accept(this);
4281+
//buffer.append("/* <<< */");
42694282
return false;
42704283
}
42714284

@@ -5178,12 +5191,17 @@ private static boolean hasSuperClass(ITypeBinding typeBinding) {
51785191
}
51795192

51805193
private Object getConstant(Expression exp) {
5181-
boolean isOK = (getJ2sJavadoc(exp, DOC_CHECK_ONLY) == null);
5182-
if (!isOK) {
5183-
isOK = !(exp instanceof InfixExpression || exp instanceof PrefixExpression || exp instanceof ParenthesizedExpression);
5184-
}
5185-
return (isOK ? exp.resolveConstantExpressionValue() : null);
5194+
return (noDocProblem(exp) ? exp.resolveConstantExpressionValue() : null);
51865195
}
5196+
private boolean noDocProblem(Expression exp) {
5197+
return (getJ2sJavadoc(exp, DOC_CHECK_ONLY) == null
5198+
|| !(exp instanceof PrefixExpression
5199+
|| exp instanceof InfixExpression
5200+
|| exp instanceof PostfixExpression
5201+
|| exp instanceof ParenthesizedExpression)
5202+
);
5203+
}
5204+
51875205
/**
51885206
* If given expression is constant value expression, return its value string; or
51895207
* character or return null.
@@ -5303,10 +5321,10 @@ private void setMapJavaDoc(PackageDeclaration node) {
53035321
// normal termination from item after last j2sjavadoc
53045322
}
53055323

5306-
//System.out.println("/**** list ****/");
5307-
//for (int i = 0, n = list.size(); i < n; i++) {
5308-
// System. out.println(i + " " + (list.get(i) == null ? null : list.get(i).getClass().getName() + " " + list.get(i).getStartPosition() + "..." + (list.get(i).getStartPosition() + list.get(i).getLength())));
5309-
//}
5324+
//?? System.out.println("/**** list ****/");
5325+
//?? for (int i = 0, n = list.size(); i < n; i++) {
5326+
//?? System. out.println(i + " " + (list.get(i) == null ? null : list.get(i).getClass().getName() + " " + list.get(i).getStartPosition() + "..." + (list.get(i).getStartPosition() + list.get(i).getLength())));
5327+
//?? }
53105328

53115329
// and link javadoc to its closest block
53125330

@@ -5377,8 +5395,8 @@ private List<Javadoc> getJ2sJavadoc(ASTNode node, int mode) {
53775395
NativeDoc.addJ2sJavadocs(buffer, docs, false);
53785396
} else {
53795397
docs = package_mapBlockJavadoc.get(Integer.valueOf(node.getStartPosition()));
5380-
// buffer.append("\n/** looking for " + node + " " + Integer.valueOf(node.getStartPosition())
5381-
// + " " + (docs != null) + " " + node.getClass().getName() + "*/\n");
5398+
//?? buffer.append("\n/** looking for " + node + " " + Integer.valueOf(node.getStartPosition())
5399+
//?? + " " + (docs != null) + " " + node.getClass().getName() + "*/\n");
53825400
}
53835401
return docs;
53845402
}
3.72 KB
Binary file not shown.

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

Lines changed: 51 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -3777,6 +3777,7 @@ protected void dispatchEventImplComp(AWTEvent e) {
37773777
* 4. Allow input methods to process the event
37783778
*/
37793779
// if (areInputMethodsEnabled()) {
3780+
// SwingJS - Nah...
37803781
// // We need to pass on InputMethodEvents since some host
37813782
// // input method adapters send them through the Java
37823783
// // event queue instead of directly to the component,
@@ -3837,6 +3838,7 @@ protected void dispatchEventImplComp(AWTEvent e) {
38373838
break;
38383839

38393840
case WindowEvent.WINDOW_CLOSING:
3841+
// SwingJS could do this, but it doesn't seem to be necessary
38403842
// if (toolkit instanceof WindowClosingListener) {
38413843
// windowClosingException = ((WindowClosingListener)
38423844
// toolkit).windowClosingNotify((WindowEvent)e);
@@ -3854,6 +3856,8 @@ protected void dispatchEventImplComp(AWTEvent e) {
38543856
* 6. Deliver event for normal processing
38553857
*/
38563858
if (newEventsOnly) {
3859+
// that is -- we have some sort of listener attached
3860+
38573861
// Filtering needs to really be moved to happen at a lower
38583862
// level in order to get maximum performance gain; it is
38593863
// here temporarily to ensure the API spec is honored.
@@ -3866,7 +3870,10 @@ protected void dispatchEventImplComp(AWTEvent e) {
38663870
// MouseWheelEvents still need to be dispatched to it so scrolling
38673871
// can be done.
38683872
autoProcessMouseWheel((MouseWheelEvent) e);
3869-
} else if (!(e instanceof MouseEvent && !postsOldMouseEvents())) {
3873+
}
3874+
3875+
//else if (!(e instanceof MouseEvent) || postsOldMouseEvents()) {
3876+
// SwingJS could be useful? Backward meaning what, exactly? Really old?
38703877
// //
38713878
// // backward compatibility
38723879
// //
@@ -3898,45 +3905,46 @@ protected void dispatchEventImplComp(AWTEvent e) {
38983905
// break;
38993906
// }
39003907
// }
3901-
}
3902-
3903-
/*
3904-
* 8. Special handling for 4061116 : Hook for browser to close modal dialogs.
3905-
*/
3906-
if (id == WindowEvent.WINDOW_CLOSING && !e.isConsumed()) {
3907-
// if (toolkit instanceof WindowClosingListener) {
3908-
// windowClosingException =
3909-
// ((WindowClosingListener)toolkit).
3910-
// windowClosingDelivered((WindowEvent)e);
3911-
// if (checkWindowClosingException()) {
3912-
// return;
3913-
// }
3914-
// }
3915-
}
3916-
3917-
/*
3918-
* 9. Allow the peer to process the event. Except KeyEvents, they will be
3919-
* processed by peer after all KeyEventPostProcessors (see
3920-
* DefaultKeyboardFocusManager.dispatchKeyEvent())
3921-
*/
3922-
if (!(e instanceof KeyEvent)) {
3923-
// ComponentPeer tpeer = peer;
3924-
// if (e instanceof FocusEvent && (tpeer == null || tpeer instanceof
3925-
// LightweightPeer)) {
3926-
// // if focus owner is lightweight then its native container
3927-
// // processes event
3928-
// Component source = (Component)e.getSource();
3929-
// if (source != null) {
3930-
// Container target = source.getNativeContainer();
3931-
// if (target != null) {
3932-
// tpeer = target.getPeer();
3933-
// }
3934-
// }
3935-
// }
3936-
// if (tpeer != null) {
3937-
// tpeer.handleEvent(e);
3938-
// }
3939-
}
3908+
//}
3909+
3910+
// /*
3911+
// * 8. Special handling for 4061116 : Hook for browser to close modal dialogs.
3912+
// */
3913+
// if (id == WindowEvent.WINDOW_CLOSING && !e.isConsumed()) {
3914+
// // if (toolkit instanceof WindowClosingListener) {
3915+
// // windowClosingException =
3916+
// // ((WindowClosingListener)toolkit).
3917+
// // windowClosingDelivered((WindowEvent)e);
3918+
// // if (checkWindowClosingException()) {
3919+
// // return;
3920+
// // }
3921+
// // }
3922+
// }
3923+
//
3924+
// /*
3925+
// * 9. Allow the peer to process the event. Except KeyEvents, they will be
3926+
// * processed by peer after all KeyEventPostProcessors (see
3927+
// * DefaultKeyboardFocusManager.dispatchKeyEvent())
3928+
// */
3929+
// if (!(e instanceof KeyEvent)) {
3930+
// // SwingJS -- no need for this?
3931+
// // ComponentPeer tpeer = peer;
3932+
// // if (e instanceof FocusEvent && (tpeer == null || tpeer instanceof
3933+
// // LightweightPeer)) {
3934+
// // // if focus owner is lightweight then its native container
3935+
// // // processes event
3936+
// // Component source = (Component)e.getSource();
3937+
// // if (source != null) {
3938+
// // Container target = source.getNativeContainer();
3939+
// // if (target != null) {
3940+
// // tpeer = target.getPeer();
3941+
// // }
3942+
// // }
3943+
// // }
3944+
// // if (tpeer != null) {
3945+
// // tpeer.handleEvent(e);
3946+
// // }
3947+
// }
39403948
} // dispatchEventImpl()
39413949

39423950
/*
@@ -4366,13 +4374,13 @@ public void addHierarchyBoundsListener(HierarchyBoundsListener l) {
43664374
return;
43674375
}
43684376
boolean notifyAncestors;
4369-
synchronized (this) {
4377+
// synchronized (this) {
43704378
notifyAncestors = (hierarchyBoundsListener == null
43714379
&& (eventMask & AWTEvent.HIERARCHY_BOUNDS_EVENT_MASK) == 0);
43724380
hierarchyBoundsListener = AWTEventMulticaster.add(hierarchyBoundsListener, l);
43734381
notifyAncestors = (notifyAncestors && hierarchyBoundsListener != null);
43744382
newEventsOnly = true;
4375-
}
4383+
// }
43764384
if (notifyAncestors) {
43774385
synchronized (getTreeLock()) {
43784386
adjustListeningChildrenOnParent(AWTEvent.HIERARCHY_BOUNDS_EVENT_MASK, 1);
@@ -5529,6 +5537,7 @@ protected void processMouseWheelEvent(MouseWheelEvent e) {
55295537
}
55305538

55315539
boolean postsOldMouseEvents() {
5540+
// SwingJS - this could be used for a2s method.
55325541
return false;
55335542
}
55345543

0 commit comments

Comments
 (0)