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-10 10:42:49 +0000
|
4
|
@@ -49,12 +49,14 @@
|
5
|
** 025 CA 20151123 Replaced root frame check with dedicated API.
|
6
|
** SBI 20151201 Added findAncestor/findDescendant for a given widget and a target widget type.
|
7
|
** 026 IAS 20160211 Thread-safe access to the widgetList.
|
8
|
+** 027 SBI 20160307 Changed findAncestor method to accept a target filter predicate.
|
9
|
*/
|
10
|
|
11
|
package com.goldencode.p2j.ui.client;
|
12
|
|
13
|
import java.util.*;
|
14
|
import java.util.concurrent.locks.*;
|
15
|
+import java.util.function.Predicate;
|
16
|
import java.util.logging.*;
|
17
|
|
18
|
import com.goldencode.p2j.ui.*;
|
19
|
@@ -84,22 +86,22 @@
|
20
|
private final ReadWriteLock lock = new ReentrantReadWriteLock();
|
21
|
|
22
|
/**
|
23
|
- * Returns a nearest widget's ancestor having a given type.
|
24
|
+ * Returns a nearest widget's ancestor that satisfies the target filter condition.
|
25
|
*
|
26
|
* @param w
|
27
|
* The target widget that can have an ancestor of a given type.
|
28
|
- * @param type
|
29
|
- * The specified type condition.
|
30
|
+ * @param filter
|
31
|
+ * The target filter condition.
|
32
|
*
|
33
|
- * @return The ancestor having the specified type or null if there are no widgets
|
34
|
- * satisfied this condition.
|
35
|
+ * @return The ancestor satisfied the target filter condition or null if there are no
|
36
|
+ * widgets satisfied this condition.
|
37
|
*/
|
38
|
- public static Widget findAncestor(Widget w, Class type)
|
39
|
+ public static Widget findAncestor(Widget w, Predicate<Widget> filter)
|
40
|
{
|
41
|
Widget c = w;
|
42
|
while (c != null)
|
43
|
{
|
44
|
- if (c.getClass().equals(type))
|
45
|
+ if (filter.test(c))
|
46
|
{
|
47
|
return c;
|
48
|
}
|
49
|
|
50
|
=== modified file 'src/com/goldencode/p2j/ui/client/gui/EditorGuiImpl.java'
|
51
|
--- src/com/goldencode/p2j/ui/client/gui/EditorGuiImpl.java 2016-03-08 18:14:25 +0000
|
52
|
+++ src/com/goldencode/p2j/ui/client/gui/EditorGuiImpl.java 2016-03-10 10:45:29 +0000
|
53
|
@@ -1386,11 +1386,8 @@
|
54
|
{
|
55
|
Widget<GuiOutputManager> src = super.findMouseSource(p);
|
56
|
|
57
|
- return (src == editor || src == contentPane || src == editorScroll
|
58
|
- /* TODO: this will be removed: this == src.parent(EditorGuiImpl.class) */ ) ?
|
59
|
- this : src;
|
60
|
+ return (src == editor || src == contentPane) ? this : src;
|
61
|
}
|
62
|
-
|
63
|
|
64
|
/**
|
65
|
* Get the widget's actual bounds
|
66
|
|
67
|
=== modified file 'src/com/goldencode/p2j/ui/client/gui/FrameGuiImpl.java'
|
68
|
--- src/com/goldencode/p2j/ui/client/gui/FrameGuiImpl.java 2016-02-24 17:44:15 +0000
|
69
|
+++ src/com/goldencode/p2j/ui/client/gui/FrameGuiImpl.java 2016-03-10 10:42:49 +0000
|
70
|
@@ -61,6 +61,7 @@
|
71
|
** 030 HC 20160203 Improved runtime support of FRAME:VIRTUAL* and FRAME:SCROLLABLE attributes.
|
72
|
** Frame layout improvements.
|
73
|
** 031 IAS 20160217 LOAD-MOUSE-POINTER support.
|
74
|
+** 032 SBI 20160307 Changed an effective widget id for the frame's hover action.
|
75
|
*/
|
76
|
|
77
|
package com.goldencode.p2j.ui.client.gui;
|
78
|
@@ -742,7 +743,8 @@
|
79
|
@Override
|
80
|
protected MouseHoverAction createMouseHoverAction()
|
81
|
{
|
82
|
- return new MouseHoverAction(this)
|
83
|
+ // frame scroll component is the smallest widget that catch the mouse input and has an id.
|
84
|
+ return new MouseHoverAction(this, this.frameScroll.getId().asInt())
|
85
|
{
|
86
|
@Override
|
87
|
protected MousePtrWrapper parentCursor()
|
88
|
|
89
|
=== modified file 'src/com/goldencode/p2j/ui/client/gui/driver/swing/SwingMouseHandler.java'
|
90
|
--- src/com/goldencode/p2j/ui/client/gui/driver/swing/SwingMouseHandler.java 2016-02-18 11:36:28 +0000
|
91
|
+++ src/com/goldencode/p2j/ui/client/gui/driver/swing/SwingMouseHandler.java 2016-03-10 10:42:49 +0000
|
92
|
@@ -2,7 +2,7 @@
|
93
|
** Module : WebMouseHandler.java
|
94
|
** Abstract : Provides mouse event support for the swing GUI driver.
|
95
|
**
|
96
|
-** Copyright (c) 2015, Golden Code Development Corporation.
|
97
|
+** Copyright (c) 2015-2016, Golden Code Development Corporation.
|
98
|
** ALL RIGHTS RESERVED. Use is subject to license terms.
|
99
|
**
|
100
|
** Golden Code Development Corporation
|
101
|
@@ -18,6 +18,8 @@
|
102
|
** window.
|
103
|
** 003 HC 20151013 NPE fix.
|
104
|
** 004 HC 20151024 Fixed race condition when dispatching mouse events.
|
105
|
+** 005 SBI 20160307 Changed processAction to deliver mouse events to the closest registered widget
|
106
|
+** in the source mouse widget parent's hierarchy.
|
107
|
*/
|
108
|
|
109
|
package com.goldencode.p2j.ui.client.gui.driver.swing;
|
110
|
@@ -29,11 +31,14 @@
|
111
|
import java.util.HashMap;
|
112
|
import java.util.List;
|
113
|
import java.util.Map;
|
114
|
+import java.util.function.Predicate;
|
115
|
|
116
|
import com.goldencode.p2j.security.*;
|
117
|
import com.goldencode.p2j.ui.WidgetId;
|
118
|
import com.goldencode.p2j.ui.client.*;
|
119
|
import com.goldencode.p2j.ui.client.event.*;
|
120
|
+import com.goldencode.p2j.ui.client.gui.ScrollBarGuiImpl;
|
121
|
+import com.goldencode.p2j.ui.client.gui.ScrollPaneGuiImpl;
|
122
|
import com.goldencode.p2j.ui.client.gui.driver.*;
|
123
|
import com.goldencode.p2j.ui.client.widget.*;
|
124
|
|
125
|
@@ -161,7 +166,7 @@
|
126
|
{
|
127
|
Widget<?> mouseSource = findMouseSource(e);
|
128
|
lastHoveredWidget = mouseSource;
|
129
|
-
|
130
|
+
|
131
|
if (!processAction(e))
|
132
|
{
|
133
|
SwingMouseHandler.super.mouseEntered(e);
|
134
|
@@ -375,6 +380,7 @@
|
135
|
}
|
136
|
|
137
|
Widget<?> mouseSource = window.findMouseSource(new MouseEvt(e, window));
|
138
|
+
|
139
|
return mouseSource;
|
140
|
}
|
141
|
|
142
|
@@ -415,7 +421,33 @@
|
143
|
return false;
|
144
|
}
|
145
|
|
146
|
- WidgetId wid = UiUtils.getWidgetId(widget);
|
147
|
+ // find widget in its ancestor's hierarchy that has an id
|
148
|
+ Widget parent = WidgetRegistry.findAncestor(widget, new Predicate<Widget>()
|
149
|
+ {
|
150
|
+ @Override
|
151
|
+ public boolean test(Widget t)
|
152
|
+ {
|
153
|
+ return UiUtils.getWidgetId(t) != null;
|
154
|
+ }
|
155
|
+ });
|
156
|
+
|
157
|
+ // TODO: move this widget-specific logic into methods that are implemented in the widget
|
158
|
+ // hierarchy so that we do not have direct references to widget classes in this common code
|
159
|
+
|
160
|
+ // if it is scroll bar then find its scroll pane parent
|
161
|
+ if (parent instanceof ScrollBarGuiImpl)
|
162
|
+ {
|
163
|
+ parent = WidgetRegistry.findAncestor(parent, new Predicate<Widget>()
|
164
|
+ {
|
165
|
+ @Override
|
166
|
+ public boolean test(Widget t)
|
167
|
+ {
|
168
|
+ return ScrollPaneGuiImpl.class.equals(t.getClass());
|
169
|
+ }
|
170
|
+ });
|
171
|
+ }
|
172
|
+
|
173
|
+ WidgetId wid = UiUtils.getWidgetId(parent);
|
174
|
|
175
|
if (wid == null)
|
176
|
{
|
177
|
|
178
|
=== modified file 'src/com/goldencode/p2j/ui/client/gui/driver/web/WebMouseHandler.java'
|
179
|
--- src/com/goldencode/p2j/ui/client/gui/driver/web/WebMouseHandler.java 2016-02-29 18:42:34 +0000
|
180
|
+++ src/com/goldencode/p2j/ui/client/gui/driver/web/WebMouseHandler.java 2016-03-10 10:42:49 +0000
|
181
|
@@ -19,6 +19,7 @@
|
182
|
package com.goldencode.p2j.ui.client.gui.driver.web;
|
183
|
|
184
|
import java.awt.event.MouseEvent;
|
185
|
+import java.util.function.Predicate;
|
186
|
|
187
|
import com.goldencode.p2j.ui.client.*;
|
188
|
import com.goldencode.p2j.ui.client.gui.*;
|
189
|
@@ -62,7 +63,18 @@
|
190
|
}
|
191
|
else
|
192
|
{
|
193
|
- Widget editor = WidgetRegistry.findAncestor(w, EditorGuiImpl.class);
|
194
|
+ // TODO: move this widget-specific logic into methods that are implemented in
|
195
|
+ // the widget hierarchy so that we do not have direct references to widget classes
|
196
|
+ // in this common code
|
197
|
+
|
198
|
+ Widget editor = WidgetRegistry.findAncestor(target, new Predicate<Widget>()
|
199
|
+ {
|
200
|
+ @Override
|
201
|
+ public boolean test(Widget t)
|
202
|
+ {
|
203
|
+ return EditorGuiImpl.class.equals(t.getClass());
|
204
|
+ }
|
205
|
+ });
|
206
|
if (editor != null && editor.getId() != null)
|
207
|
{
|
208
|
widgetId = editor.getId().asInt();
|
209
|
|
210
|
=== modified file 'src/com/goldencode/p2j/ui/client/widget/AbstractContainer.java'
|
211
|
--- src/com/goldencode/p2j/ui/client/widget/AbstractContainer.java 2016-03-07 12:46:23 +0000
|
212
|
+++ src/com/goldencode/p2j/ui/client/widget/AbstractContainer.java 2016-03-10 10:42:49 +0000
|
213
|
@@ -372,8 +372,7 @@
|
214
|
continue;
|
215
|
}
|
216
|
|
217
|
- return (found != null && found.getId() != null) ? found :
|
218
|
- (w.getId() == null ? null : w);
|
219
|
+ return (found == null) ? w : found;
|
220
|
}
|
221
|
|
222
|
return null;
|
223
|
|