Project

General

Profile

current_5.txt

Sergey Ivanovskiy, 03/10/2016 02:57 PM

Download (6.24 KB)

 
1
=== modified file 'src/com/goldencode/p2j/ui/client/TopLevelWindow.java'
2
--- src/com/goldencode/p2j/ui/client/TopLevelWindow.java	2016-02-25 06:13:23 +0000
3
+++ src/com/goldencode/p2j/ui/client/TopLevelWindow.java	2016-03-10 18:10:50 +0000
4
@@ -35,12 +35,14 @@
5
 **                  should be repainted after changing active window, not before. 
6
 ** 013 HC  20160203 Improved runtime support of KEEP-FRAME-Z-ORDER and TOP-ONLY attributes.
7
 ** 014 EVL 20160224 Javadoc fixes to make compatible with Oracle Java 8 for Solaris 10.
8
+** 015 SBI 20160310 Changed to reuse the common code
9
 */
10
 
11
 package com.goldencode.p2j.ui.client;
12
 
13
 import java.io.*;
14
 import java.util.*;
15
+import java.util.function.Predicate;
16
 
17
 import com.goldencode.p2j.ui.*;
18
 import com.goldencode.p2j.ui.chui.*;
19
@@ -667,19 +669,18 @@
20
          
21
          if (mouseSource != null && mouseSource.isDisplayed())
22
          {
23
-            WidgetId id = null;
24
-
25
             // search for a parent with a valid id
26
-            Widget<O> parent = mouseSource;
27
-            while (parent != null)
28
+            Widget<O> parent = WidgetRegistry.findAncestor(mouseSource, new Predicate<Widget>()
29
             {
30
-               id = parent.getId();
31
-               if (id != null)
32
+               @Override
33
+               public boolean test(Widget t)
34
                {
35
-                  break;
36
+                  return UiUtils.getWidgetId(t) != null;
37
                }
38
-               parent = parent.parent();
39
-            }
40
+            });
41
+            
42
+            WidgetId id = (parent != null) ? parent.getId() : null;
43
+            
44
             if (id != null)
45
             {
46
                // not all OS-widgets have an ID, skip those
47

    
48
=== modified file 'src/com/goldencode/p2j/ui/client/gui/driver/swing/SwingMouseHandler.java'
49
--- src/com/goldencode/p2j/ui/client/gui/driver/swing/SwingMouseHandler.java	2016-03-07 18:00:01 +0000
50
+++ src/com/goldencode/p2j/ui/client/gui/driver/swing/SwingMouseHandler.java	2016-03-10 19:44:15 +0000
51
@@ -18,8 +18,8 @@
52
 **                  window.
53
 ** 003 HC  20151013 NPE fix.
54
 ** 004 HC  20151024 Fixed race condition when dispatching mouse events.
55
-** 005 SBI 20160307 Changed processAction to deliver mouse events to the closest registered widget
56
-**                  in the source mouse widget parent's hierarchy.
57
+** 005 SBI 20160310 Changed processAction/findMouseSource to deliver mouse events to the closest
58
+**                  registered widget in the source mouse widget parent's hierarchy.
59
 */
60
 
61
 package com.goldencode.p2j.ui.client.gui.driver.swing;
62
@@ -37,6 +37,7 @@
63
 import com.goldencode.p2j.ui.WidgetId;
64
 import com.goldencode.p2j.ui.client.*;
65
 import com.goldencode.p2j.ui.client.event.*;
66
+import com.goldencode.p2j.ui.client.gui.LabelGuiImpl;
67
 import com.goldencode.p2j.ui.client.gui.ScrollBarGuiImpl;
68
 import com.goldencode.p2j.ui.client.gui.ScrollPaneGuiImpl;
69
 import com.goldencode.p2j.ui.client.gui.driver.*;
70
@@ -381,7 +382,35 @@
71
       
72
       Widget<?> mouseSource = window.findMouseSource(new MouseEvt(e, window));
73
       
74
-      return mouseSource;
75
+      // find widget in its ancestor's hierarchy that has an id 
76
+      Widget parent = WidgetRegistry.findAncestor(mouseSource, new Predicate<Widget>()
77
+      {
78
+         @Override
79
+         public boolean test(Widget t)
80
+         {
81
+            // TODO: to improve/simplify the mouse pointer is over a widget  
82
+            // work around to fix cursor changes over labels
83
+            return UiUtils.getWidgetId(t) != null && !(LabelGuiImpl.class.equals(t.getClass()));
84
+         }
85
+      });
86
+
87
+      // TODO: move this widget-specific logic into methods that are implemented in the widget
88
+      // hierarchy so that we do not have direct references to widget classes in this common code
89
+      
90
+      // if it is scroll bar then find its scroll pane parent
91
+      if (parent instanceof ScrollBarGuiImpl)
92
+      {
93
+         parent = WidgetRegistry.findAncestor(parent, new Predicate<Widget>()
94
+         {
95
+            @Override
96
+            public boolean test(Widget t)
97
+            {
98
+               return ScrollPaneGuiImpl.class.equals(t.getClass());
99
+            }
100
+         });
101
+      }
102
+
103
+      return parent;
104
    }
105
 
106
    /**
107
@@ -421,33 +450,8 @@
108
          return false;
109
       }
110
       
111
-      // find widget in its ancestor's hierarchy that has an id 
112
-      Widget parent = WidgetRegistry.findAncestor(widget, new Predicate<Widget>()
113
-      {
114
-         @Override
115
-         public boolean test(Widget t)
116
-         {
117
-            return UiUtils.getWidgetId(t) != null;
118
-         }
119
-      });
120
-
121
-      // TODO: move this widget-specific logic into methods that are implemented in the widget
122
-      // hierarchy so that we do not have direct references to widget classes in this common code
123
-      
124
-      // if it is scroll bar then find its scroll pane parent
125
-      if (parent instanceof ScrollBarGuiImpl)
126
-      {
127
-         parent = WidgetRegistry.findAncestor(parent, new Predicate<Widget>()
128
-         {
129
-            @Override
130
-            public boolean test(Widget t)
131
-            {
132
-               return ScrollPaneGuiImpl.class.equals(t.getClass());
133
-            }
134
-         });
135
-      }
136
-      
137
-      WidgetId wid = UiUtils.getWidgetId(parent);
138
+      
139
+      WidgetId wid = UiUtils.getWidgetId(widget);
140
       
141
       if (wid == null)
142
       {
143

    
144
=== modified file 'src/com/goldencode/p2j/ui/client/gui/driver/web/res/p2j.mouse.js'
145
--- src/com/goldencode/p2j/ui/client/gui/driver/web/res/p2j.mouse.js	2016-02-03 21:22:52 +0000
146
+++ src/com/goldencode/p2j/ui/client/gui/driver/web/res/p2j.mouse.js	2016-03-10 19:47:15 +0000
147
@@ -21,7 +21,7 @@
148
 ** 006 IAS 20160217 LOAD-MOUSE-POINTER ans SET-WAIT-STATE support
149
 ** 007 SBI 20151217 Changed to resize the offscreen canvas first and then to blast the offscreen
150
 **                  image to the original canvas.
151
-**     SBI 20160104 Fixed the window location.
152
+**     SBI 20160310 Added getEvents() to MouseMovable.
153
 */
154
 
155
 "use strict";
156
@@ -923,6 +923,20 @@
157
       removeListeners(win, mops, listeners);
158
    };
159
 
160
+   this.getEvents = function()
161
+   {
162
+      var events = {};
163
+      for (var prop in mops)
164
+      {
165
+         if (mops.hasOwnProperty(prop))
166
+         {
167
+            events[prop] = true;
168
+         }
169
+      }
170
+      
171
+      return events;
172
+   };
173
+
174
    function processMouseDragStop(mThis, mouseOp)
175
    {
176
       return function(evt)
177