Project

General

Profile

2849a_1.txt

Sergey Ivanovskiy, 03/08/2016 03:11 PM

Download (9.19 KB)

 
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-08 19:39:00 +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-08 19:36:03 +0000
53
@@ -1386,11 +1386,14 @@
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
+      // Exclude the mouse source component if it is unregistered ~ it have no id. (editor)
61
+      if (src == null || src.getId() == null)
62
+      {
63
+         return null;
64
+      }
65
+      
66
+      return (src == contentPane) ? this : src;
67
    }
68
-   
69
 
70
    /**
71
     * Get the widget's actual bounds
72

    
73
=== modified file 'src/com/goldencode/p2j/ui/client/gui/FrameGuiImpl.java'
74
--- src/com/goldencode/p2j/ui/client/gui/FrameGuiImpl.java	2016-02-24 17:44:15 +0000
75
+++ src/com/goldencode/p2j/ui/client/gui/FrameGuiImpl.java	2016-03-08 19:39:00 +0000
76
@@ -61,6 +61,7 @@
77
 ** 030 HC  20160203 Improved runtime support of FRAME:VIRTUAL* and FRAME:SCROLLABLE attributes.
78
 **                  Frame layout improvements.
79
 ** 031 IAS 20160217 LOAD-MOUSE-POINTER support.
80
+** 032 SBI 20160307 Changed an effective widget id for the frame's hover action.
81
 */
82
 
83
 package com.goldencode.p2j.ui.client.gui;
84
@@ -742,7 +743,8 @@
85
   @Override
86
    protected MouseHoverAction createMouseHoverAction()
87
    {
88
-      return new MouseHoverAction(this)
89
+      // frame scroll component is the smallest widget that catch the mouse input and has an id. 
90
+      return new MouseHoverAction(this, this.frameScroll.getId().asInt())
91
       {
92
          @Override
93
          protected MousePtrWrapper parentCursor()
94

    
95
=== modified file 'src/com/goldencode/p2j/ui/client/gui/driver/swing/SwingMouseHandler.java'
96
--- src/com/goldencode/p2j/ui/client/gui/driver/swing/SwingMouseHandler.java	2016-02-18 11:36:28 +0000
97
+++ src/com/goldencode/p2j/ui/client/gui/driver/swing/SwingMouseHandler.java	2016-03-08 19:39:00 +0000
98
@@ -2,7 +2,7 @@
99
 ** Module   : WebMouseHandler.java
100
 ** Abstract : Provides mouse event support for the swing GUI driver.
101
 **
102
-** Copyright (c) 2015, Golden Code Development Corporation.
103
+** Copyright (c) 2015-2016, Golden Code Development Corporation.
104
 ** ALL RIGHTS RESERVED. Use is subject to license terms.
105
 **
106
 **           Golden Code Development Corporation
107
@@ -18,6 +18,8 @@
108
 **                  window.
109
 ** 003 HC  20151013 NPE fix.
110
 ** 004 HC  20151024 Fixed race condition when dispatching mouse events.
111
+** 005 SBI 20160307 Changed processAction to deliver mouse events to the closest registered widget
112
+**                  in the source mouse widget parent's hierarchy.
113
 */
114
 
115
 package com.goldencode.p2j.ui.client.gui.driver.swing;
116
@@ -29,11 +31,14 @@
117
 import java.util.HashMap;
118
 import java.util.List;
119
 import java.util.Map;
120
+import java.util.function.Predicate;
121
 
122
 import com.goldencode.p2j.security.*;
123
 import com.goldencode.p2j.ui.WidgetId;
124
 import com.goldencode.p2j.ui.client.*;
125
 import com.goldencode.p2j.ui.client.event.*;
126
+import com.goldencode.p2j.ui.client.gui.ScrollBarGuiImpl;
127
+import com.goldencode.p2j.ui.client.gui.ScrollPaneGuiImpl;
128
 import com.goldencode.p2j.ui.client.gui.driver.*;
129
 import com.goldencode.p2j.ui.client.widget.*;
130
 
131
@@ -161,7 +166,7 @@
132
          {
133
             Widget<?> mouseSource = findMouseSource(e);
134
             lastHoveredWidget = mouseSource;
135
-      
136
+            
137
             if (!processAction(e))
138
             {
139
                SwingMouseHandler.super.mouseEntered(e);
140
@@ -375,6 +380,7 @@
141
       }
142
       
143
       Widget<?> mouseSource = window.findMouseSource(new MouseEvt(e, window));
144
+      
145
       return mouseSource;
146
    }
147
 
148
@@ -415,7 +421,33 @@
149
          return false;
150
       }
151
       
152
-      WidgetId wid = UiUtils.getWidgetId(widget);
153
+      // find widget in its ancestor's hierarchy that has an id 
154
+      Widget parent = WidgetRegistry.findAncestor(widget, new Predicate<Widget>()
155
+      {
156
+         @Override
157
+         public boolean test(Widget t)
158
+         {
159
+            return UiUtils.getWidgetId(t) != null;
160
+         }
161
+      });
162
+
163
+      // TODO: move this widget-specific logic into methods that are implemented in the widget
164
+      // hierarchy so that we do not have direct references to widget classes in this common code
165
+      
166
+      // if it is scroll bar then find its scroll pane parent
167
+      if (parent instanceof ScrollBarGuiImpl)
168
+      {
169
+         parent = WidgetRegistry.findAncestor(parent, new Predicate<Widget>()
170
+         {
171
+            @Override
172
+            public boolean test(Widget t)
173
+            {
174
+               return ScrollPaneGuiImpl.class.equals(t.getClass());
175
+            }
176
+         });
177
+      }
178
+      
179
+      WidgetId wid = UiUtils.getWidgetId(parent);
180
       
181
       if (wid == null)
182
       {
183

    
184
=== modified file 'src/com/goldencode/p2j/ui/client/gui/driver/web/WebMouseHandler.java'
185
--- src/com/goldencode/p2j/ui/client/gui/driver/web/WebMouseHandler.java	2016-02-29 18:42:34 +0000
186
+++ src/com/goldencode/p2j/ui/client/gui/driver/web/WebMouseHandler.java	2016-03-08 19:39:00 +0000
187
@@ -19,6 +19,7 @@
188
 package com.goldencode.p2j.ui.client.gui.driver.web;
189
 
190
 import java.awt.event.MouseEvent;
191
+import java.util.function.Predicate;
192
 
193
 import com.goldencode.p2j.ui.client.*;
194
 import com.goldencode.p2j.ui.client.gui.*;
195
@@ -62,7 +63,18 @@
196
             }
197
             else
198
             {
199
-               Widget editor = WidgetRegistry.findAncestor(w, EditorGuiImpl.class);
200
+               // TODO: move this widget-specific logic into methods that are implemented in
201
+               // the widget hierarchy so that we do not have direct references to widget classes
202
+               // in this common code
203
+               
204
+               Widget editor = WidgetRegistry.findAncestor(target, new Predicate<Widget>()
205
+               {
206
+                  @Override
207
+                  public boolean test(Widget t)
208
+                  {
209
+                     return EditorGuiImpl.class.equals(t.getClass());
210
+                  }
211
+               });
212
                if (editor != null && editor.getId() != null)
213
                {
214
                   widgetId = editor.getId().asInt();
215

    
216
=== modified file 'src/com/goldencode/p2j/ui/client/gui/driver/web/res/p2j.mouse.js'
217
--- src/com/goldencode/p2j/ui/client/gui/driver/web/res/p2j.mouse.js	2016-02-29 15:15:12 +0000
218
+++ src/com/goldencode/p2j/ui/client/gui/driver/web/res/p2j.mouse.js	2016-03-08 20:01:20 +0000
219
@@ -920,7 +920,21 @@
220
    {
221
       removeListeners(win, mops, listeners);
222
    };
223
-
224
+   
225
+   this.getEvents = function()
226
+   {
227
+      var events = {};
228
+      for (var prop in mops)
229
+      {
230
+         if (mops.hasOwnProperty(prop))
231
+         {
232
+            events[prop] = true;
233
+         }
234
+      }
235
+      
236
+      return events;
237
+   };
238
+   
239
    function processMouseDragStop(mThis, mouseOp)
240
    {
241
       return function(evt)
242

    
243
=== modified file 'src/com/goldencode/p2j/ui/client/widget/AbstractContainer.java'
244
--- src/com/goldencode/p2j/ui/client/widget/AbstractContainer.java	2016-03-07 12:46:23 +0000
245
+++ src/com/goldencode/p2j/ui/client/widget/AbstractContainer.java	2016-03-08 19:30:14 +0000
246
@@ -372,8 +372,7 @@
247
             continue;
248
          }
249
 
250
-         return (found != null && found.getId() != null) ? found : 
251
-               (w.getId() == null ? null : w); 
252
+         return (found == null) ? w : found;
253
       }
254
 
255
       return null;
256