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.
|
27 |
32 |
*/
|
28 |
33 |
|
29 |
34 |
package com.goldencode.p2j.ui.client.gui;
|
... | ... | |
31 |
36 |
// this usage of AWT events is intentional, they are being used separately from the
|
32 |
37 |
// AWT/Swing event model itself; no other AWT/Swing usage is occurring in this class
|
33 |
38 |
import java.awt.event.MouseEvent;
|
|
39 |
import java.util.concurrent.*;
|
34 |
40 |
|
35 |
41 |
import com.goldencode.p2j.ui.*;
|
36 |
42 |
import com.goldencode.p2j.ui.chui.ThinClient;
|
... | ... | |
67 |
73 |
/** Button state */
|
68 |
74 |
boolean up = true;
|
69 |
75 |
|
|
76 |
/** Executor for handling mouse input. */
|
|
77 |
private static ExecutorService mouseInputExecutor = Executors.newSingleThreadExecutor();
|
|
78 |
|
70 |
79 |
/**
|
71 |
80 |
* This constructor creates a scroll bar button.
|
72 |
81 |
*
|
... | ... | |
198 |
207 |
}
|
199 |
208 |
|
200 |
209 |
/**
|
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 |
210 |
* Notification of a mouse pressed event occurred for this widget.
|
219 |
211 |
*
|
220 |
212 |
* @param e
|
... | ... | |
227 |
219 |
if (owner.isEnabled())
|
228 |
220 |
{
|
229 |
221 |
up = false;
|
230 |
|
refresh();
|
|
222 |
// need to use repaint() here instead of refresh() because for example inside combo-box
|
|
223 |
// drop-down standalone event loop the screen synchronization is not happening
|
|
224 |
repaint();
|
|
225 |
|
|
226 |
// for holding mouse we need to genereate scroll events
|
|
227 |
mouseInputExecutor.execute(new Runnable()
|
|
228 |
{
|
|
229 |
|
|
230 |
@Override
|
|
231 |
public void run()
|
|
232 |
{
|
|
233 |
// finisho on mouse release
|
|
234 |
while (!up)
|
|
235 |
{
|
|
236 |
try
|
|
237 |
{
|
|
238 |
// wait to see if the mouse is still pressed
|
|
239 |
Thread.sleep(GuiConstants.REPEAT_MILLIS);
|
|
240 |
|
|
241 |
if (!up)
|
|
242 |
{
|
|
243 |
// emit the sequential click events
|
|
244 |
ThinClient.getInstance().independentEventDrawingBracket(owner,
|
|
245 |
new Runnable()
|
|
246 |
{
|
|
247 |
public void run()
|
|
248 |
{
|
|
249 |
owner.onButtonClick(position, false);
|
|
250 |
}
|
|
251 |
});
|
|
252 |
|
|
253 |
}
|
|
254 |
}
|
|
255 |
catch (InterruptedException ex)
|
|
256 |
{
|
|
257 |
// nop
|
|
258 |
}
|
|
259 |
}
|
|
260 |
}
|
|
261 |
});
|
231 |
262 |
}
|
232 |
263 |
}
|
233 |
264 |
|
... | ... | |
244 |
275 |
if (owner.isEnabled())
|
245 |
276 |
{
|
246 |
277 |
up = true;
|
247 |
|
refresh();
|
|
278 |
repaint();
|
|
279 |
// call scroll bar
|
|
280 |
owner.onButtonClick(position, false);
|
248 |
281 |
}
|
249 |
282 |
}
|
250 |
283 |
|