1
|
=== modified file 'src/com/goldencode/p2j/ui/client/WidgetRegistry.java'
|
2
|
--- src/com/goldencode/p2j/ui/client/WidgetRegistry.java 2016-02-17 19:32:15 +0000
|
3
|
+++ src/com/goldencode/p2j/ui/client/WidgetRegistry.java 2016-03-04 20:54:30 +0000
|
4
|
@@ -55,6 +55,7 @@
|
5
|
|
6
|
import java.util.*;
|
7
|
import java.util.concurrent.locks.*;
|
8
|
+import java.util.function.Predicate;
|
9
|
import java.util.logging.*;
|
10
|
|
11
|
import com.goldencode.p2j.ui.*;
|
12
|
@@ -84,22 +85,22 @@
|
13
|
private final ReadWriteLock lock = new ReentrantReadWriteLock();
|
14
|
|
15
|
/**
|
16
|
- * Returns a nearest widget's ancestor having a given type.
|
17
|
+ * Returns a nearest widget's ancestor that satisfies the target filter condition.
|
18
|
*
|
19
|
* @param w
|
20
|
* The target widget that can have an ancestor of a given type.
|
21
|
- * @param type
|
22
|
- * The specified type condition.
|
23
|
+ * @param filter
|
24
|
+ * The target filter condition.
|
25
|
*
|
26
|
- * @return The ancestor having the specified type or null if there are no widgets
|
27
|
- * satisfied this condition.
|
28
|
+ * @return The ancestor satisfied the target filter condition or null if there are no
|
29
|
+ * widgets satisfied this condition.
|
30
|
*/
|
31
|
- public static Widget findAncestor(Widget w, Class type)
|
32
|
+ public static Widget findAncestor(Widget w, Predicate<Widget> filter)
|
33
|
{
|
34
|
Widget c = w;
|
35
|
while (c != null)
|
36
|
{
|
37
|
- if (c.getClass().equals(type))
|
38
|
+ if (filter.test(c))
|
39
|
{
|
40
|
return c;
|
41
|
}
|
42
|
|
43
|
=== modified file 'src/com/goldencode/p2j/ui/client/gui/FrameGuiImpl.java'
|
44
|
--- src/com/goldencode/p2j/ui/client/gui/FrameGuiImpl.java 2016-02-24 17:44:15 +0000
|
45
|
+++ src/com/goldencode/p2j/ui/client/gui/FrameGuiImpl.java 2016-03-06 15:27:27 +0000
|
46
|
@@ -742,7 +742,8 @@
|
47
|
@Override
|
48
|
protected MouseHoverAction createMouseHoverAction()
|
49
|
{
|
50
|
- return new MouseHoverAction(this)
|
51
|
+ // frame scroll component is the smallest widget that catch the mouse input and has an id.
|
52
|
+ return new MouseHoverAction(this, this.frameScroll.getId().asInt())
|
53
|
{
|
54
|
@Override
|
55
|
protected MousePtrWrapper parentCursor()
|
56
|
|
57
|
=== modified file 'src/com/goldencode/p2j/ui/client/gui/driver/swing/SwingMouseHandler.java'
|
58
|
--- src/com/goldencode/p2j/ui/client/gui/driver/swing/SwingMouseHandler.java 2016-02-18 11:36:28 +0000
|
59
|
+++ src/com/goldencode/p2j/ui/client/gui/driver/swing/SwingMouseHandler.java 2016-03-06 15:19:42 +0000
|
60
|
@@ -29,11 +29,13 @@
|
61
|
import java.util.HashMap;
|
62
|
import java.util.List;
|
63
|
import java.util.Map;
|
64
|
+import java.util.function.Predicate;
|
65
|
|
66
|
import com.goldencode.p2j.security.*;
|
67
|
import com.goldencode.p2j.ui.WidgetId;
|
68
|
import com.goldencode.p2j.ui.client.*;
|
69
|
import com.goldencode.p2j.ui.client.event.*;
|
70
|
+import com.goldencode.p2j.ui.client.gui.FrameGuiImpl;
|
71
|
import com.goldencode.p2j.ui.client.gui.driver.*;
|
72
|
import com.goldencode.p2j.ui.client.widget.*;
|
73
|
|
74
|
@@ -161,7 +163,7 @@
|
75
|
{
|
76
|
Widget<?> mouseSource = findMouseSource(e);
|
77
|
lastHoveredWidget = mouseSource;
|
78
|
-
|
79
|
+
|
80
|
if (!processAction(e))
|
81
|
{
|
82
|
SwingMouseHandler.super.mouseEntered(e);
|
83
|
@@ -375,6 +377,7 @@
|
84
|
}
|
85
|
|
86
|
Widget<?> mouseSource = window.findMouseSource(new MouseEvt(e, window));
|
87
|
+
|
88
|
return mouseSource;
|
89
|
}
|
90
|
|
91
|
@@ -415,7 +418,17 @@
|
92
|
return false;
|
93
|
}
|
94
|
|
95
|
- WidgetId wid = UiUtils.getWidgetId(widget);
|
96
|
+ // find widget in its ancestor's hierarchy that has an id
|
97
|
+ Widget parent = WidgetRegistry.findAncestor(widget, new Predicate<Widget>()
|
98
|
+ {
|
99
|
+ @Override
|
100
|
+ public boolean test(Widget t)
|
101
|
+ {
|
102
|
+ return UiUtils.getWidgetId(t) != null;
|
103
|
+ }
|
104
|
+ });
|
105
|
+
|
106
|
+ WidgetId wid = UiUtils.getWidgetId(parent);
|
107
|
|
108
|
if (wid == null)
|
109
|
{
|
110
|
|
111
|
=== modified file 'src/com/goldencode/p2j/ui/client/gui/driver/web/WebMouseHandler.java'
|
112
|
--- src/com/goldencode/p2j/ui/client/gui/driver/web/WebMouseHandler.java 2016-03-03 16:10:57 +0000
|
113
|
+++ src/com/goldencode/p2j/ui/client/gui/driver/web/WebMouseHandler.java 2016-03-04 20:57:16 +0000
|
114
|
@@ -20,6 +20,7 @@
|
115
|
package com.goldencode.p2j.ui.client.gui.driver.web;
|
116
|
|
117
|
import java.awt.event.MouseEvent;
|
118
|
+import java.util.function.Predicate;
|
119
|
|
120
|
import com.goldencode.p2j.ui.client.*;
|
121
|
import com.goldencode.p2j.ui.client.gui.*;
|
122
|
@@ -63,7 +64,14 @@
|
123
|
}
|
124
|
else
|
125
|
{
|
126
|
- Widget editor = WidgetRegistry.findAncestor(target, EditorGuiImpl.class);
|
127
|
+ Widget editor = WidgetRegistry.findAncestor(target, new Predicate<Widget>()
|
128
|
+ {
|
129
|
+ @Override
|
130
|
+ public boolean test(Widget t)
|
131
|
+ {
|
132
|
+ return EditorGuiImpl.class.equals(t.getClass());
|
133
|
+ }
|
134
|
+ });
|
135
|
if (editor != null && editor.getId() != null)
|
136
|
{
|
137
|
widgetId = editor.getId().asInt();
|
138
|
|