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/driver/swing/SwingMouseHandler.java'
|
44
|
--- src/com/goldencode/p2j/ui/client/gui/driver/swing/SwingMouseHandler.java 2016-02-18 11:36:28 +0000
|
45
|
+++ src/com/goldencode/p2j/ui/client/gui/driver/swing/SwingMouseHandler.java 2016-03-04 21:26:55 +0000
|
46
|
@@ -29,6 +29,7 @@
|
47
|
import java.util.HashMap;
|
48
|
import java.util.List;
|
49
|
import java.util.Map;
|
50
|
+import java.util.function.Predicate;
|
51
|
|
52
|
import com.goldencode.p2j.security.*;
|
53
|
import com.goldencode.p2j.ui.WidgetId;
|
54
|
@@ -161,7 +162,7 @@
|
55
|
{
|
56
|
Widget<?> mouseSource = findMouseSource(e);
|
57
|
lastHoveredWidget = mouseSource;
|
58
|
-
|
59
|
+
|
60
|
if (!processAction(e))
|
61
|
{
|
62
|
SwingMouseHandler.super.mouseEntered(e);
|
63
|
@@ -375,6 +376,7 @@
|
64
|
}
|
65
|
|
66
|
Widget<?> mouseSource = window.findMouseSource(new MouseEvt(e, window));
|
67
|
+
|
68
|
return mouseSource;
|
69
|
}
|
70
|
|
71
|
@@ -415,7 +417,17 @@
|
72
|
return false;
|
73
|
}
|
74
|
|
75
|
- WidgetId wid = UiUtils.getWidgetId(widget);
|
76
|
+ // find widget in its ancestor's hierarchy that has an id
|
77
|
+ Widget parent = WidgetRegistry.findAncestor(widget, new Predicate<Widget>()
|
78
|
+ {
|
79
|
+ @Override
|
80
|
+ public boolean test(Widget t)
|
81
|
+ {
|
82
|
+ return UiUtils.getWidgetId(t) != null;
|
83
|
+ }
|
84
|
+ });
|
85
|
+
|
86
|
+ WidgetId wid = UiUtils.getWidgetId(parent);
|
87
|
|
88
|
if (wid == null)
|
89
|
{
|
90
|
|
91
|
=== modified file 'src/com/goldencode/p2j/ui/client/gui/driver/web/WebMouseHandler.java'
|
92
|
--- src/com/goldencode/p2j/ui/client/gui/driver/web/WebMouseHandler.java 2016-03-03 16:10:57 +0000
|
93
|
+++ src/com/goldencode/p2j/ui/client/gui/driver/web/WebMouseHandler.java 2016-03-04 20:57:16 +0000
|
94
|
@@ -20,6 +20,7 @@
|
95
|
package com.goldencode.p2j.ui.client.gui.driver.web;
|
96
|
|
97
|
import java.awt.event.MouseEvent;
|
98
|
+import java.util.function.Predicate;
|
99
|
|
100
|
import com.goldencode.p2j.ui.client.*;
|
101
|
import com.goldencode.p2j.ui.client.gui.*;
|
102
|
@@ -63,7 +64,14 @@
|
103
|
}
|
104
|
else
|
105
|
{
|
106
|
- Widget editor = WidgetRegistry.findAncestor(target, EditorGuiImpl.class);
|
107
|
+ Widget editor = WidgetRegistry.findAncestor(target, new Predicate<Widget>()
|
108
|
+ {
|
109
|
+ @Override
|
110
|
+ public boolean test(Widget t)
|
111
|
+ {
|
112
|
+ return EditorGuiImpl.class.equals(t.getClass());
|
113
|
+ }
|
114
|
+ });
|
115
|
if (editor != null && editor.getId() != null)
|
116
|
{
|
117
|
widgetId = editor.getId().asInt();
|
118
|
|