evl_upd20151126a.diff
src/com/goldencode/p2j/ui/client/gui/ComboBoxGuiImpl.java 2015-11-24 23:01:14 +0000 | ||
---|---|---|
48 | 48 |
** GUI mode ignoring SESSION:DATA-ENTRY-RETURN value. The combo-box does not |
49 | 49 |
** react to the ENTER key in GUI. Key processsing fixes for GUI mode. |
50 | 50 |
** 014 EVL 20151120 Fix for drop-down line spacing issue. And fix for button incorrect drawing |
51 |
** over 3d border. |
|
51 |
** over 3d border. Drop-down button fix for pressed state drawing. Pressing |
|
52 |
** the drop-down button need to be painted accordingly. |
|
52 | 53 |
*/ |
53 | 54 | |
54 | 55 |
package com.goldencode.p2j.ui.client.gui; |
... | ... | |
396 | 397 |
{ |
397 | 398 |
requestFocus(); |
398 | 399 |
pressed = true; |
400 | ||
399 | 401 |
// drop-down is opening on mouse press |
400 | 402 |
if (config.mode != ComboBoxConfig.Mode.SIMPLE) |
401 | 403 |
{ |
404 |
// first need to display the button pressing effect |
|
405 |
ThinClient.getInstance().independentEventDrawingBracket(this, new Runnable() |
|
406 |
{ |
|
407 |
public void run() |
|
408 |
{ |
|
409 |
repaint(); |
|
410 |
} |
|
411 |
}); |
|
412 | ||
413 |
// depending on current state activate or dismiss drop-down |
|
402 | 414 |
if (dropDownActive) |
403 | 415 |
{ |
404 | 416 |
// second click to drop-down button or area dismisses the active drop-down |
src/com/goldencode/p2j/ui/client/gui/ScrollBarGuiButton.java 2015-11-26 19:26:58 +0000 | ||
---|---|---|
24 | 24 |
** 010 EVL 20151010 Fix for thumb drawing issues. Also reworked image loader specifically for |
25 | 25 |
** small images. Optimization for button painting on mouse press, release. In |
26 | 26 |
** these cases we do not need to repaint whole window. |
27 |
** 011 EVL 20151124 The button pressed state needs repaint() call to properly display pressed mode |
|
28 |
** when running indide drop-down life cycle. Improved mouse handling, in 4GL |
|
29 |
** if to press mouse, move inside button and release - this generates click. So |
|
30 |
** we have to track the mouse release, not click. Adding auto-scroll feature on |
|
31 |
** press and hold mouse button. The mouse executor shoule be stopped on widget |
|
32 |
** destroy to free the resources. Changing static executor to be instance based. |
|
27 | 33 |
*/ |
28 | 34 | |
29 | 35 |
package com.goldencode.p2j.ui.client.gui; |
... | ... | |
31 | 37 |
// this usage of AWT events is intentional, they are being used separately from the |
32 | 38 |
// AWT/Swing event model itself; no other AWT/Swing usage is occurring in this class |
33 | 39 |
import java.awt.event.MouseEvent; |
40 |
import java.util.concurrent.*; |
|
34 | 41 | |
35 | 42 |
import com.goldencode.p2j.ui.*; |
36 | 43 |
import com.goldencode.p2j.ui.chui.ThinClient; |
37 | 44 |
import com.goldencode.p2j.ui.client.*; |
45 |
import com.goldencode.p2j.ui.client.event.*; |
|
38 | 46 |
import com.goldencode.p2j.ui.client.ScrollBar.Orientation; |
39 | 47 |
import com.goldencode.p2j.ui.client.ScrollBar.Position; |
40 | 48 |
import com.goldencode.p2j.ui.client.gui.driver.*; |
... | ... | |
65 | 73 |
private ImageWrapper<?> img_d; |
66 | 74 |
|
67 | 75 |
/** Button state */ |
68 |
boolean up = true; |
|
76 |
private volatile boolean up = true;
|
|
69 | 77 |
|
78 |
/** Executor for handling mouse input. */ |
|
79 |
private ExecutorService mouseInputExecutor = Executors.newSingleThreadExecutor(); |
|
80 |
|
|
70 | 81 |
/** |
71 | 82 |
* This constructor creates a scroll bar button. |
72 | 83 |
* |
... | ... | |
198 | 209 |
} |
199 | 210 | |
200 | 211 |
/** |
201 |
* Notification of a mouse clicked event occurred for this widget. |
|
202 |
* |
|
203 |
* @param e |
|
204 |
* The mouse event. |
|
205 |
*/ |
|
206 |
@Override |
|
207 |
public void mouseClicked(MouseEvent e) |
|
208 |
{ |
|
209 |
// check if the scrollbar widget is enabled |
|
210 |
if (owner.isEnabled()) |
|
211 |
{ |
|
212 |
// call scroll bar |
|
213 |
owner.onButtonClick(position, false); |
|
214 |
} |
|
215 |
} |
|
216 | ||
217 |
/** |
|
218 | 212 |
* Notification of a mouse pressed event occurred for this widget. |
219 | 213 |
* |
220 | 214 |
* @param e |
... | ... | |
227 | 221 |
if (owner.isEnabled()) |
228 | 222 |
{ |
229 | 223 |
up = false; |
230 |
refresh(); |
|
224 |
// need to use repaint() here instead of refresh() because for example inside combo-box |
|
225 |
// drop-down standalone event loop the screen synchronization is not happening |
|
226 |
repaint(); |
|
227 | ||
228 |
// for holding mouse we need to genereate scroll events |
|
229 |
mouseInputExecutor.execute(new Runnable() |
|
230 |
{ |
|
231 | ||
232 |
@Override |
|
233 |
public void run() |
|
234 |
{ |
|
235 |
ThinClient tc = ThinClient.getInstance(); |
|
236 |
// finish on mouse release |
|
237 |
while (!up) |
|
238 |
{ |
|
239 |
try |
|
240 |
{ |
|
241 |
// wait to see if the mouse is still pressed |
|
242 |
Thread.sleep(GuiConstants.REPEAT_MILLIS); |
|
243 | ||
244 |
if (!up) |
|
245 |
{ |
|
246 |
// emit the sequential scroll events |
|
247 |
ScrollEvent evt = |
|
248 |
((ScrollBarGuiImpl)owner).createAutoScrollEvent(position); |
|
249 |
|
|
250 |
tc.postOSEvent(evt); |
|
251 |
} |
|
252 |
} |
|
253 |
catch (InterruptedException ex) |
|
254 |
{ |
|
255 |
// nop |
|
256 |
} |
|
257 |
} |
|
258 |
} |
|
259 |
}); |
|
231 | 260 |
} |
232 | 261 |
} |
233 | 262 | |
... | ... | |
244 | 273 |
if (owner.isEnabled()) |
245 | 274 |
{ |
246 | 275 |
up = true; |
247 |
refresh(); |
|
276 |
repaint(); |
|
277 |
// call scroll bar |
|
278 |
owner.onButtonClick(position, false); |
|
248 | 279 |
} |
249 | 280 |
} |
250 | 281 |
|
251 | 282 |
/** |
283 |
* Destroy this widget. Cleans up all including widgets before destruction. |
|
284 |
*/ |
|
285 |
@Override |
|
286 |
public void destroy() |
|
287 |
{ |
|
288 |
// stop the mouse related thread if it is active |
|
289 |
if (!mouseInputExecutor.isShutdown()) |
|
290 |
{ |
|
291 |
mouseInputExecutor.shutdownNow(); |
|
292 |
} |
|
293 | ||
294 |
// call superclass for main destruction |
|
295 |
super.destroy(); |
|
296 |
} |
|
297 |
|
|
298 |
/** |
|
252 | 299 |
* Refresh the scrollbar button not repainting full window. |
253 | 300 |
*/ |
254 | 301 |
@Override |
src/com/goldencode/p2j/ui/client/gui/ScrollBarGuiImpl.java 2015-11-26 19:29:44 +0000 | ||
---|---|---|
38 | 38 |
** 018 SVL 20151029 Added support for scroll bar controllers. |
39 | 39 |
** EVL 20151111 Fix for scrollbar thumb size calculation. The minimum size is 8. When nothing |
40 | 40 |
** to scroll - it is not required to draw the thumb. Fix for background drawing. |
41 |
** 019 EVL 20151125 Adding executor shutdown to prevent resource leak. Changing static executor |
|
42 |
** to be instance based. |
|
41 | 43 |
*/ |
42 | 44 |
|
43 | 45 |
package com.goldencode.p2j.ui.client.gui; |
... | ... | |
73 | 75 |
public static final int SCROLLBAR_SIZE = 16; |
74 | 76 |
|
75 | 77 |
/** Executor for handling mouse input. */ |
76 |
private static ExecutorService mouseInputExecutor = Executors.newSingleThreadExecutor();
|
|
78 |
private ExecutorService mouseInputExecutor = Executors.newSingleThreadExecutor(); |
|
77 | 79 |
|
78 | 80 |
/** Screen driver */ |
79 | 81 |
private GuiDriver gd; |
... | ... | |
629 | 631 |
@Override |
630 | 632 |
public void run() |
631 | 633 |
{ |
634 |
ThinClient tc = ThinClient.getInstance(); |
|
632 | 635 |
while (pressed) |
633 | 636 |
{ |
634 | 637 |
try |
... | ... | |
653 | 656 |
|
654 | 657 |
ScrollEvent event = createScrollEvent(pos); |
655 | 658 |
|
656 |
EventManager.postEvent(event);
|
|
659 |
tc.postOSEvent(event);
|
|
657 | 660 |
} |
658 | 661 |
} |
659 | 662 |
catch (InterruptedException ex) |
... | ... | |
730 | 733 |
} |
731 | 734 |
|
732 | 735 |
/** |
736 |
* Destroy this widget. Cleans up all including widgets before destruction. |
|
737 |
*/ |
|
738 |
@Override |
|
739 |
public void destroy() |
|
740 |
{ |
|
741 |
// stop the mouse related thread if it is active |
|
742 |
if (!mouseInputExecutor.isShutdown()) |
|
743 |
{ |
|
744 |
mouseInputExecutor.shutdownNow(); |
|
745 |
} |
|
746 |
|
|
747 |
// call superclass for main destruction |
|
748 |
super.destroy(); |
|
749 |
} |
|
750 |
|
|
751 |
/** |
|
752 |
* Create GUI specific auto-scroll event. |
|
753 |
* |
|
754 |
* @param btn |
|
755 |
* The source button that caused the event. |
|
756 |
*/ |
|
757 |
public ScrollEvent createAutoScrollEvent(Position btn) |
|
758 |
{ |
|
759 |
// start with the current position |
|
760 |
int newPos = position; |
|
761 |
|
|
762 |
if (btn == ScrollBar.Position.RIGHT) |
|
763 |
{ |
|
764 |
newPos += shortStep; |
|
765 |
} |
|
766 |
else |
|
767 |
{ |
|
768 |
newPos -= shortStep; |
|
769 |
} |
|
770 |
|
|
771 |
return createScrollEvent(newPos); |
|
772 |
} |
|
773 |
|
|
774 |
/** |
|
733 | 775 |
* Get size of the travel area available for thumb scrolling. |
734 | 776 |
* |
735 | 777 |
* @return size of travel area, in pixels. |