|
Lines 51-57
Link Here
|
| 51 |
= new JSListenerInfo( "focusout", |
51 |
= new JSListenerInfo( "focusout", |
| 52 |
"org.eclipse.swt.EventUtil.focusLost", |
52 |
"org.eclipse.swt.EventUtil.focusLost", |
| 53 |
JSListenerType.ACTION ); |
53 |
JSListenerType.ACTION ); |
| 54 |
|
54 |
|
| 55 |
private static final JSListenerInfo MOUSE_DOWN_LISTENER_INFO |
55 |
private static final JSListenerInfo MOUSE_DOWN_LISTENER_INFO |
| 56 |
= new JSListenerInfo( "mousedown", |
56 |
= new JSListenerInfo( "mousedown", |
| 57 |
"org.eclipse.swt.EventUtil.mouseDown", |
57 |
"org.eclipse.swt.EventUtil.mouseDown", |
|
Lines 124-129
Link Here
|
| 124 |
controlAdapter.getBackgroundTransparency() ); |
124 |
controlAdapter.getBackgroundTransparency() ); |
| 125 |
preserveBackgroundImage( control ); |
125 |
preserveBackgroundImage( control ); |
| 126 |
WidgetLCAUtil.preserveFont( control, controlAdapter.getUserFont() ); |
126 |
WidgetLCAUtil.preserveFont( control, controlAdapter.getUserFont() ); |
|
|
127 |
adapter.preserve( Props.CURSOR, control.getCursor() ); |
| 127 |
adapter.preserve( Props.CONTROL_LISTENERS, |
128 |
adapter.preserve( Props.CONTROL_LISTENERS, |
| 128 |
Boolean.valueOf( ControlEvent.hasListener( control ) ) ); |
129 |
Boolean.valueOf( ControlEvent.hasListener( control ) ) ); |
| 129 |
adapter.preserve( PROP_ACTIVATE_LISTENER, |
130 |
adapter.preserve( PROP_ACTIVATE_LISTENER, |
|
Lines 310-315
Link Here
|
| 310 |
writeBackground( control ); |
311 |
writeBackground( control ); |
| 311 |
writeBackgroundImage( control ); |
312 |
writeBackgroundImage( control ); |
| 312 |
writeFont( control ); |
313 |
writeFont( control ); |
|
|
314 |
writeCursor( control ); |
| 313 |
// TODO [rst] missing: writeControlListener( control ); |
315 |
// TODO [rst] missing: writeControlListener( control ); |
| 314 |
writeActivateListener( control ); |
316 |
writeActivateListener( control ); |
| 315 |
writeFocusListener( control ); |
317 |
writeFocusListener( control ); |
|
Lines 634-639
Link Here
|
| 634 |
WidgetLCAUtil.resetFont(); |
636 |
WidgetLCAUtil.resetFont(); |
| 635 |
} |
637 |
} |
| 636 |
|
638 |
|
|
|
639 |
/** |
| 640 |
* Determines whether the property <code>cursor</code> of the given control |
| 641 |
* has changed during the processing of the current request and if so, writes |
| 642 |
* JavaScript code to the response that updates the client-side cursor property. |
| 643 |
* |
| 644 |
* @param control the control whose font property to write |
| 645 |
* @throws IOException |
| 646 |
*/ |
| 647 |
public static void writeCursor( final Control control ) throws IOException { |
| 648 |
Cursor newValue = control.getCursor(); |
| 649 |
if( WidgetLCAUtil.hasChanged( control, Props.CURSOR, newValue, null ) ) { |
| 650 |
String qxCursor = null; |
| 651 |
if( newValue != null ) { |
| 652 |
int hashCode = newValue.hashCode(); |
| 653 |
if( hashCode >= 0 && hashCode < JSConst.QX_CURSOR_VALUES.length ) { |
| 654 |
qxCursor = JSConst.QX_CURSOR_VALUES[ hashCode ]; |
| 655 |
if( "null".equals( qxCursor ) ) { |
| 656 |
qxCursor = null; |
| 657 |
} |
| 658 |
} |
| 659 |
} |
| 660 |
JSWriter writer = JSWriter.getWriterFor( control ); |
| 661 |
writer.set( JSConst.QX_FIELD_CURSOR, qxCursor ); |
| 662 |
} |
| 663 |
} |
| 664 |
|
| 665 |
/** |
| 666 |
* Writes JavaScript code to the response that resets the property |
| 667 |
* <code>cursor</code> of a control. This method is intended to be used by |
| 668 |
* implementations of the method |
| 669 |
* {@link AbstractWidgetLCA#createResetHandlerCalls(String)}. |
| 670 |
* |
| 671 |
* @throws IOException |
| 672 |
*/ |
| 673 |
public static void resetCursor() throws IOException { |
| 674 |
JSWriter writer = JSWriter.getWriterForResetHandler(); |
| 675 |
writer.reset( JSConst.QX_FIELD_CURSOR ); |
| 676 |
} |
| 677 |
|
| 637 |
public static void writeActivateListener( final Control control ) |
678 |
public static void writeActivateListener( final Control control ) |
| 638 |
throws IOException |
679 |
throws IOException |
| 639 |
{ |
680 |
{ |
|
Lines 697-705
Link Here
|
| 697 |
writer.removeListener( FOCUS_LOST_LISTENER_INFO.getEventType(), |
738 |
writer.removeListener( FOCUS_LOST_LISTENER_INFO.getEventType(), |
| 698 |
FOCUS_LOST_LISTENER_INFO.getJSListener() ); |
739 |
FOCUS_LOST_LISTENER_INFO.getJSListener() ); |
| 699 |
} |
740 |
} |
| 700 |
|
741 |
|
| 701 |
private static void writeMouseListener( final Control control ) |
742 |
private static void writeMouseListener( final Control control ) |
| 702 |
throws IOException |
743 |
throws IOException |
| 703 |
{ |
744 |
{ |
| 704 |
boolean hasListener = MouseEvent.hasListener( control ); |
745 |
boolean hasListener = MouseEvent.hasListener( control ); |
| 705 |
JSWriter writer = JSWriter.getWriterFor( control ); |
746 |
JSWriter writer = JSWriter.getWriterFor( control ); |
|
Lines 863-879
Link Here
|
| 863 |
true, |
904 |
true, |
| 864 |
SWT.NONE ); |
905 |
SWT.NONE ); |
| 865 |
} |
906 |
} |
| 866 |
|
907 |
|
| 867 |
public static void processMouseEvents( final Control control ) { |
908 |
public static void processMouseEvents( final Control control ) { |
| 868 |
if( WidgetLCAUtil.wasEventSent( control, JSConst.EVENT_MOUSE_DOWN ) ) { |
909 |
if( WidgetLCAUtil.wasEventSent( control, JSConst.EVENT_MOUSE_DOWN ) ) { |
| 869 |
MouseEvent event = new MouseEvent( control, MouseEvent.MOUSE_DOWN ); |
910 |
MouseEvent event = new MouseEvent( control, MouseEvent.MOUSE_DOWN ); |
| 870 |
event.button |
911 |
event.button |
| 871 |
= readIntParam( control, JSConst.EVENT_MOUSE_DOWN_BUTTON ); |
912 |
= readIntParam( control, JSConst.EVENT_MOUSE_DOWN_BUTTON ); |
| 872 |
Point point = readXYParams( control, |
913 |
Point point = readXYParams( control, |
| 873 |
JSConst.EVENT_MOUSE_DOWN_X, |
914 |
JSConst.EVENT_MOUSE_DOWN_X, |
| 874 |
JSConst.EVENT_MOUSE_DOWN_Y ); |
915 |
JSConst.EVENT_MOUSE_DOWN_Y ); |
| 875 |
event.x = point.x; |
916 |
event.x = point.x; |
| 876 |
event.y = point.y; |
917 |
event.y = point.y; |
| 877 |
event.processEvent(); |
918 |
event.processEvent(); |
| 878 |
} |
919 |
} |
| 879 |
String eventId = JSConst.EVENT_MOUSE_DOUBLE_CLICK; |
920 |
String eventId = JSConst.EVENT_MOUSE_DOUBLE_CLICK; |
|
Lines 882-917
Link Here
|
| 882 |
= new MouseEvent( control, MouseEvent.MOUSE_DOUBLE_CLICK ); |
923 |
= new MouseEvent( control, MouseEvent.MOUSE_DOUBLE_CLICK ); |
| 883 |
event.button |
924 |
event.button |
| 884 |
= readIntParam( control, JSConst.EVENT_MOUSE_DOUBLE_CLICK_BUTTON ); |
925 |
= readIntParam( control, JSConst.EVENT_MOUSE_DOUBLE_CLICK_BUTTON ); |
| 885 |
Point point = readXYParams( control, |
926 |
Point point = readXYParams( control, |
| 886 |
JSConst.EVENT_MOUSE_DOUBLE_CLICK_X, |
927 |
JSConst.EVENT_MOUSE_DOUBLE_CLICK_X, |
| 887 |
JSConst.EVENT_MOUSE_DOUBLE_CLICK_Y ); |
928 |
JSConst.EVENT_MOUSE_DOUBLE_CLICK_Y ); |
| 888 |
event.x = point.x; |
929 |
event.x = point.x; |
| 889 |
event.y = point.y; |
930 |
event.y = point.y; |
| 890 |
event.processEvent(); |
931 |
event.processEvent(); |
| 891 |
} |
932 |
} |
| 892 |
if( WidgetLCAUtil.wasEventSent( control, JSConst.EVENT_MOUSE_UP ) ) { |
933 |
if( WidgetLCAUtil.wasEventSent( control, JSConst.EVENT_MOUSE_UP ) ) { |
| 893 |
MouseEvent event = new MouseEvent( control, MouseEvent.MOUSE_UP ); |
934 |
MouseEvent event = new MouseEvent( control, MouseEvent.MOUSE_UP ); |
| 894 |
event.button = readIntParam( control, JSConst.EVENT_MOUSE_UP_BUTTON ); |
935 |
event.button = readIntParam( control, JSConst.EVENT_MOUSE_UP_BUTTON ); |
| 895 |
Point point = readXYParams( control, |
936 |
Point point = readXYParams( control, |
| 896 |
JSConst.EVENT_MOUSE_UP_X, |
937 |
JSConst.EVENT_MOUSE_UP_X, |
| 897 |
JSConst.EVENT_MOUSE_UP_Y ); |
938 |
JSConst.EVENT_MOUSE_UP_Y ); |
| 898 |
event.x = point.x; |
939 |
event.x = point.x; |
| 899 |
event.y = point.y; |
940 |
event.y = point.y; |
| 900 |
event.processEvent(); |
941 |
event.processEvent(); |
| 901 |
} |
942 |
} |
| 902 |
} |
943 |
} |
| 903 |
|
944 |
|
| 904 |
private static int readIntParam( final Control control, |
945 |
private static int readIntParam( final Control control, |
| 905 |
final String paramName ) |
946 |
final String paramName ) |
| 906 |
{ |
947 |
{ |
| 907 |
HttpServletRequest request = ContextProvider.getRequest(); |
948 |
HttpServletRequest request = ContextProvider.getRequest(); |
| 908 |
String value = request.getParameter( paramName ); |
949 |
String value = request.getParameter( paramName ); |
| 909 |
return Integer.parseInt( value ); |
950 |
return Integer.parseInt( value ); |
| 910 |
} |
951 |
} |
| 911 |
|
952 |
|
| 912 |
private static Point readXYParams( final Control control, |
953 |
private static Point readXYParams( final Control control, |
| 913 |
final String paramNameX, |
954 |
final String paramNameX, |
| 914 |
final String paramNameY ) |
955 |
final String paramNameY ) |
| 915 |
{ |
956 |
{ |
| 916 |
int x = readIntParam( control, paramNameX ); |
957 |
int x = readIntParam( control, paramNameX ); |
| 917 |
int y = readIntParam( control, paramNameY ); |
958 |
int y = readIntParam( control, paramNameY ); |