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
1 change: 1 addition & 0 deletions sources/net.sf.j2s.core/dist/README.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
This is the main README file for the Java2Script/SwingJS distribution


https://github.com/BobHanson/java2script/blob/master/sources/net.sf.j2s.core/dist/README.txt

8/14/2018 Bob Hanson hansonr@stolaf.edu
Expand Down
Binary file modified sources/net.sf.j2s.core/dist/swingjs/SwingJS-site.zip
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 @@
20180827160909
20180901005436
Binary file modified sources/net.sf.j2s.core/dist/swingjs/ver/3.2.2/SwingJS-site.zip
Binary file not shown.
2 changes: 1 addition & 1 deletion sources/net.sf.j2s.core/dist/swingjs/ver/3.2.2/timestamp
Original file line number Diff line number Diff line change
@@ -1 +1 @@
20180827160909
20180901005436
Binary file modified sources/net.sf.j2s.java.core/dist/SwingJS-site.zip
Binary file not shown.
1 change: 1 addition & 0 deletions sources/net.sf.j2s.java.core/src/java/awt/Component.java
Original file line number Diff line number Diff line change
Expand Up @@ -7217,6 +7217,7 @@ protected String paramString() {
protected String paramStringComp() {
String thisName = getName();
String str = (thisName != null ? thisName : "");
str += (/** @j2sNative this.__JSID__ + */"");
if (!isValid()) {
str += ",invalid";
}
Expand Down
200 changes: 115 additions & 85 deletions sources/net.sf.j2s.java.core/src/java/awt/Container.java
Original file line number Diff line number Diff line change
Expand Up @@ -2691,6 +2691,9 @@ public void addNotify() {
* SwingJS set by JSAppletViewer
*/
public void setDispatcher() {
if (dispatcher != null)
return;
System.err.println("LWD dispatch for "+ this);
dispatcher = new LightweightDispatcher(this);
}
/**
Expand Down Expand Up @@ -4291,6 +4294,8 @@ class LightweightDispatcher implements AWTEventListener {
*/
private static final int LWD_MOUSE_DRAGGED_OVER = 1500;

private Component targetLastDown, targetLastKnown;

// private static final Logger eventLog = Logger.getLogger("java.awt.event.LightweightDispatcher");

LightweightDispatcher(Container nativeContainer) {
Expand All @@ -4304,7 +4309,6 @@ class LightweightDispatcher implements AWTEventListener {
* should be called from Container.removeNotify
*/
void dispose() {
//System.out.println("Disposing lw dispatcher");
stopListeningForOtherDrags();
mouseEventTarget = null;
}
Expand Down Expand Up @@ -4387,35 +4391,51 @@ private boolean isMouseGrab(MouseEvent e) {
private boolean processMouseEvent(MouseEvent e) {
int id = e.getID();

Component mouseOver = mouseEventTarget;
if (id != 505) {
// see swingjs.plaf.JSButtionUI
mouseOver = (/** @j2sNative e.bdata.jqevent && e.bdata.jqevent.target["data-component"] || */null);

// sensitive to mouse events
// sensitive to mouse events

if (mouseOver == null)
mouseOver = (id == MouseEvent.MOUSE_EXITED ? targetLastEntered
: nativeContainer.getMouseEventTarget(e.getX(), e.getY(), Container.INCLUDE_SELF));
Component mouseOver = targetLastKnown = nativeContainer.getMouseEventTarget(e.getX(), e.getY(), Container.INCLUDE_SELF);

// >>>>??trackMouseEnterExit(mouseOver, e);
trackMouseEnterExit(mouseOver, e);

// 4508327 : MOUSE_CLICKED should only go to the recipient of
// the accompanying MOUSE_PRESSED, so don't reset mouseEventTarget on a
// MOUSE_CLICKED.
if (!isMouseGrab(e) && id != MouseEvent.MOUSE_CLICKED) {
mouseEventTarget = (mouseOver != nativeContainer) ? mouseOver : null;
}
Component actualTarget;

switch (id) {
case MouseEvent.MOUSE_DRAGGED:
case MouseEvent.MOUSE_RELEASED:
actualTarget = targetLastDown;
break;
case MouseEvent.MOUSE_EXITED:
actualTarget = targetLastKnown;
break;
default:
// see swingjs.plaf.JSButtionUI
actualTarget = (/** @j2sNative e.bdata.jqevent && e.bdata.jqevent.target["data-component"] || */
null);
break;
}

// 4508327 : MOUSE_CLICKED should only go to the recipient of
// the accompanying MOUSE_PRESSED, so don't reset mouseEventTarget on a
// MOUSE_CLICKED.

if (actualTarget != null)
mouseEventTarget = actualTarget;
else if (!isMouseGrab(e) && id != MouseEvent.MOUSE_CLICKED) {
mouseEventTarget = (mouseOver != nativeContainer) ? mouseOver : null;
}

if (mouseEventTarget != null) {
switch (id) {
case MouseEvent.MOUSE_ENTERED:
case MouseEvent.MOUSE_EXITED:
break;
case MouseEvent.MOUSE_PRESSED:
checkInternalFrameMouseDown((JSComponent) e.getSource());
targetLastDown = mouseEventTarget;
retargetMouseEvent(mouseEventTarget, id, e);
break;
case MouseEvent.MOUSE_RELEASED:
targetLastDown = null;
retargetMouseEvent(mouseEventTarget, id, e);
break;
case MouseEvent.MOUSE_CLICKED:
Expand All @@ -4424,19 +4444,11 @@ private boolean processMouseEvent(MouseEvent e) {
// mouse is now over a different Component, don't dispatch the event.
// The previous fix for a similar problem was associated with bug
// 4155217.
targetLastDown = null;
if (mouseOver == mouseEventTarget) {
retargetMouseEvent(mouseOver, id, e);
}
break;
case MouseEvent.MOUSE_ENTERED:
targetLastEntered = mouseEventTarget;
System.out.println("LWD entered " + mouseEventTarget);
retargetMouseEvent(mouseEventTarget, id, e);
break;
case MouseEvent.MOUSE_EXITED:
System.out.println("LWD exited " + mouseEventTarget);
retargetMouseEvent(mouseEventTarget, id, e);
break;
case MouseEvent.MOUSE_MOVED:
retargetMouseEvent(mouseEventTarget, id, e);
break;
Expand Down Expand Up @@ -4515,13 +4527,15 @@ public void checkInternalFrameMouseDown(JSComponent c) {
}

/*
* Generates enter/exit events as mouse moves over lw components
* @param targetOver Target mouse is over (including native container)
* @param e Mouse event in native container
*/
private void trackMouseEnterExit(Component targetOver, MouseEvent e) {
Component targetEnter = null;
int id = e.getID();
* Generates enter/exit events as mouse moves over lw components
*
* @param targetOver Target mouse is over (including native container)
*
* @param e Mouse event in native container
*/
private void trackMouseEnterExit(Component targetOver, MouseEvent e) {
Component targetEnter = null;
int id = e.getID();

// if (e instanceof SunDropTargetEvent &&
// id == MouseEvent.MOUSE_ENTERED &&
Expand All @@ -4533,52 +4547,49 @@ private void trackMouseEnterExit(Component targetOver, MouseEvent e) {
// targetLastEntered = null;
// } else
//
if ( id != MouseEvent.MOUSE_EXITED &&
id != MouseEvent.MOUSE_DRAGGED &&
id != LWD_MOUSE_DRAGGED_OVER &&
isMouseInNativeContainer == false ) {
// any event but an exit or drag means we're in the native container
isMouseInNativeContainer = true;
startListeningForOtherDrags();
} else if ( id == MouseEvent.MOUSE_EXITED ) {
isMouseInNativeContainer = false;
stopListeningForOtherDrags();
}

if (isMouseInNativeContainer) {
targetEnter = targetOver;
}
if (id == MouseEvent.MOUSE_EXITED) {
isMouseInNativeContainer = false;
stopListeningForOtherDrags();
} else if (id != MouseEvent.MOUSE_DRAGGED && id != LWD_MOUSE_DRAGGED_OVER
&& isMouseInNativeContainer == false) {
// any event but an exit or drag means we're in the native container
isMouseInNativeContainer = true;
startListeningForOtherDrags();
}

if (isMouseInNativeContainer) {
targetEnter = targetOver;
}

if (targetLastEntered == targetEnter) {
return;
}
if (targetLastEntered == targetEnter) {
return;
}

if (targetLastEntered != null) {
retargetMouseEvent(targetLastEntered, MouseEvent.MOUSE_EXITED, e);
}
if (id == MouseEvent.MOUSE_EXITED) {
// consume native exit event if we generate one
e.consume();
}
if (targetLastEntered != null) {
retargetMouseEvent(targetLastEntered, MouseEvent.MOUSE_EXITED, e);
}
if (id == MouseEvent.MOUSE_EXITED) {
// consume native exit event if we generate one
e.consume();
}

if (targetEnter != null) {
retargetMouseEvent(targetEnter, MouseEvent.MOUSE_ENTERED, e);
}
if (id == MouseEvent.MOUSE_ENTERED) {
// consume native enter event if we generate one
e.consume();
}
if (targetEnter != null) {
retargetMouseEvent(targetEnter, MouseEvent.MOUSE_ENTERED, e);
}
if (id == MouseEvent.MOUSE_ENTERED) {
// consume native enter event if we generate one
e.consume();
}

targetLastEntered = targetEnter;
}
targetLastEntered = targetEnter;
}

/*
* Listens to global mouse drag events so even drags originating
* from other heavyweight containers will generate enter/exit
* events in this container
*/
private void startListeningForOtherDrags() {
// //System.out.println("Adding AWTEventListener");
// java.security.AccessController.doPrivileged(
// new java.security.PrivilegedAction() {
// public Object run() {
Expand All @@ -4593,7 +4604,6 @@ private void startListeningForOtherDrags() {
}

private void stopListeningForOtherDrags() {
// //System.out.println("Removing AWTEventListener");
// java.security.AccessController.doPrivileged(
// new java.security.PrivilegedAction() {
// public Object run() {
Expand Down Expand Up @@ -4691,24 +4701,24 @@ public void eventDispatched(AWTEvent e) {
// me.translatePoint( ptSrcOrigin.x - ptDstOrigin.x, ptSrcOrigin.y - ptDstOrigin.y );
// }
}
//System.out.println("Track event: " + me);
// feed the 'dragged-over' event directly to the enter/exit
// code (not a real event so don't pass it to dispatchEvent)
Component targetOver =
nativeContainer.getMouseEventTarget(me.getX(), me.getY(),
Container.INCLUDE_SELF);
//>>>??trackMouseEnterExit(targetOver, me);
trackMouseEnterExit(targetOver, me);
}

/**
* Sends a mouse event to the current mouse event recipient using the given
* event (sent to the windowed host) as a srcEvent. If the mouse event target is
* still in the component tree, the coordinates of the event are translated to
* those of the target. If the target has been removed, we don't bother to send
* the message.
* Sends a mouse event to the current mouse event recipient using
* the given event (sent to the windowed host) as a srcEvent. If
* the mouse event target is still in the component tree, the
* coordinates of the event are translated to those of the target.
* If the target has been removed, we don't bother to send the
* message.
*
* Except for SwingJS we are using the parent frame as the native container, and
* the PopupMenu does not have that as a parent.
* Except for SwingJS we are using the parent frame as the native container,
* and the PopupMenu does not have that as a parent.
*/
void retargetMouseEvent(Component target, int id, MouseEvent e) {
if (target == null) {
Expand Down Expand Up @@ -4740,13 +4750,33 @@ void retargetMouseEvent(Component target, int id, MouseEvent e) {
// } else
//
if (id == MouseEvent.MOUSE_WHEEL) {
retargeted = new MouseWheelEvent(target, id, e.getWhen(), e.getModifiersEx() | e.getModifiers(), x, y,
e.getXOnScreen(), e.getYOnScreen(), e.getClickCount(), e.isPopupTrigger(),
((MouseWheelEvent) e).getScrollType(), ((MouseWheelEvent) e).getScrollAmount(),
((MouseWheelEvent) e).getWheelRotation(), ((MouseWheelEvent) e).getPreciseWheelRotation());
} else {
retargeted = new MouseEvent(target, id, e.getWhen(), e.getModifiersEx() | e.getModifiers(), x, y,
e.getXOnScreen(), e.getYOnScreen(), e.getClickCount(), e.isPopupTrigger(), e.getButton());
retargeted = new MouseWheelEvent(target,
id,
e.getWhen(),
e.getModifiersEx() | e.getModifiers(),
x,
y,
e.getXOnScreen(),
e.getYOnScreen(),
e.getClickCount(),
e.isPopupTrigger(),
((MouseWheelEvent)e).getScrollType(),
((MouseWheelEvent)e).getScrollAmount(),
((MouseWheelEvent)e).getWheelRotation(),
((MouseWheelEvent)e).getPreciseWheelRotation());
}
else {
retargeted = new MouseEvent(target,
id,
e.getWhen(),
e.getModifiersEx() | e.getModifiers(),
x,
y,
e.getXOnScreen(),
e.getYOnScreen(),
e.getClickCount(),
e.isPopupTrigger(),
e.getButton());
}

((AWTEvent) e).copyPrivateDataInto(retargeted);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,6 @@ private void initiateToolTip(MouseEvent event) {
* @param event the event in question
*/
public void mouseExited(MouseEvent event) {
System.out.println("mouse exit " + event.getSource());
hasFired = true;
boolean shouldHide = true;
if (insideComponent == null) {
Expand Down
14 changes: 9 additions & 5 deletions sources/net.sf.j2s.java.core/src/swingjs/JSMouse.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,15 @@ public boolean processEvent(int id, int x, int y, int modifiers, long time, Obje
case MouseEvent.MOUSE_RELEASED:
released(time, x, y, modifiers);
// simulate a mouseClicked event for us
if (x == xWhenPressed && y == yWhenPressed
&& modifiers == modifiersWhenPressed10) {
// the underlying code will turn this into dbl clicks for us
clicked(time, x, y, modifiers, 1);
}
// if (x == xWhenPressed && y == yWhenPressed
// && modifiers == modifiersWhenPressed10) {
// // the underlying code will turn this into dbl clicks for us
// clicked(time, x, y, modifiers, 1);
// }
break;
case MouseEvent.MOUSE_CLICKED:
int n = /** @j2sNative jqevent.originalEvent.detail || */ 0;
clicked(time, x, y, modifiers, n);
break;
default:
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,11 @@

public class JSEditorPaneUI extends JSTextUI {

/**
* the radio or check-box or simple button
*
*/
protected DOMNode domBtn;

@Override
@Override
public DOMNode updateDOMNode() {
if (domNode == null) {
allowPaintedBackground = false;
domBtn = focusNode = enableNode = textNode = valueNode = domNode =
focusNode = enableNode = textNode = valueNode = domNode =
newDOMObject("div", id);
DOMNode.setStyles(domNode, "resize", "none");
setDataUI(domNode);
Expand Down
Loading