|
@@ -13,40 +13,33 @@ |
13 |
13 |
|
import com.google.gwt.user.client.*; |
14 |
14 |
|
import com.google.gwt.user.client.ui.*; |
15 |
15 |
|
|
16 |
|
- |
public abstract class Button extends ButtonBase implements Enableable |
17 |
|
- |
{ |
|
16 |
+ |
public abstract class Button extends ButtonBase implements Enableable { |
18 |
17 |
|
public static final Logger LOGGER = LoggerFactory.getLogger( Button.class ); |
19 |
18 |
|
|
20 |
19 |
|
private final String mName; |
21 |
20 |
|
|
22 |
|
- |
protected Button( String pName, Element pElement ) |
23 |
|
- |
{ |
|
21 |
+ |
protected Button( String pName, Element pElement ) { |
24 |
22 |
|
super( pElement ); |
25 |
23 |
|
mName = Strings.assertNotNullNotEmpty( "Name", pName ); |
26 |
24 |
|
} |
27 |
25 |
|
|
28 |
|
- |
public static DefButtonNamed named( String pName ) |
29 |
|
- |
{ |
|
26 |
+ |
public static DefButtonNamed named( String pName ) { |
30 |
27 |
|
return new DefButtonNamed( pName ); |
31 |
28 |
|
} |
32 |
29 |
|
|
33 |
|
- |
public Button disable() |
34 |
|
- |
{ |
|
30 |
+ |
public Button disable() { |
35 |
31 |
|
setEnabled( false ); |
36 |
32 |
|
return this; |
37 |
33 |
|
} |
38 |
34 |
|
|
39 |
35 |
|
public abstract void setColorStyleClass( String pNewColorStyleClassName ); |
40 |
36 |
|
|
41 |
|
- |
public String getName() |
42 |
|
- |
{ |
|
37 |
+ |
public String getName() { |
43 |
38 |
|
return mName; |
44 |
39 |
|
} |
45 |
40 |
|
|
46 |
|
- |
public void simulateUserClick( KeyboardKeyModifier pModifiers ) |
47 |
|
- |
{ |
48 |
|
- |
if ( pModifiers == null ) |
49 |
|
- |
{ |
|
41 |
+ |
public void simulateUserClick( KeyboardKeyModifier pModifiers ) { |
|
42 |
+ |
if ( pModifiers == null ) { |
50 |
43 |
|
pModifiers = KeyboardKeyModifier.None; |
51 |
44 |
|
} |
52 |
45 |
|
NativeEvent event = Document.get().createClickEvent( 0, 0, 0, 0, 0, // |
|
@@ -58,47 +51,37 @@ |
58 |
51 |
|
} |
59 |
52 |
|
|
60 |
53 |
|
@Override |
61 |
|
- |
public String getHTML() |
62 |
|
- |
{ |
|
54 |
+ |
public String getHTML() { |
63 |
55 |
|
throw badOperation( "getHTML" ); |
64 |
56 |
|
} |
65 |
57 |
|
|
66 |
58 |
|
@Override |
67 |
|
- |
public String getText() |
68 |
|
- |
{ |
|
59 |
+ |
public String getText() { |
69 |
60 |
|
throw badOperation( "getText" ); |
70 |
61 |
|
} |
71 |
62 |
|
|
72 |
63 |
|
@Override |
73 |
|
- |
public void setHTML( String html ) |
74 |
|
- |
{ |
|
64 |
+ |
public void setHTML( String html ) { |
75 |
65 |
|
throw badOperation( "setHTML" ); |
76 |
66 |
|
} |
77 |
67 |
|
|
78 |
68 |
|
@Override |
79 |
|
- |
public void setText( String text ) |
80 |
|
- |
{ |
|
69 |
+ |
public void setText( String text ) { |
81 |
70 |
|
throw badOperation( "setText" ); |
82 |
71 |
|
} |
83 |
72 |
|
|
84 |
|
- |
protected void simulateMouseMove( Event pEvent ) |
85 |
|
- |
{ |
|
73 |
+ |
protected void simulateMouseMove( Event pEvent ) { |
86 |
74 |
|
final MousePoint zMP = new MousePoint( pEvent ); |
87 |
75 |
|
|
88 |
|
- |
if ( !zMP.over( WindowSizingPanel.get() ) ) |
89 |
|
- |
{ |
|
76 |
+ |
if ( !zMP.over( WindowSizingPanel.get() ) ) { |
90 |
77 |
|
return; |
91 |
78 |
|
} |
92 |
79 |
|
|
93 |
|
- |
Widget zWidget = WidgetFinder.find( new WidgetSelector() |
94 |
|
- |
{ |
|
80 |
+ |
Widget zWidget = WidgetFinder.find( new WidgetSelector() { |
95 |
81 |
|
@Override |
96 |
|
- |
public boolean isAcceptable( Widget pWidget ) |
97 |
|
- |
{ |
98 |
|
- |
if ( pWidget instanceof Button ) |
99 |
|
- |
{ |
100 |
|
- |
if ( zMP.over( pWidget ) ) |
101 |
|
- |
{ |
|
82 |
+ |
public boolean isAcceptable( Widget pWidget ) { |
|
83 |
+ |
if ( pWidget instanceof Button ) { |
|
84 |
+ |
if ( zMP.over( pWidget ) ) { |
102 |
85 |
|
return true; |
103 |
86 |
|
} |
104 |
87 |
|
} |
|
@@ -106,8 +89,7 @@ |
106 |
89 |
|
} |
107 |
90 |
|
} ); |
108 |
91 |
|
|
109 |
|
- |
if ( zWidget != null ) |
110 |
|
- |
{ |
|
92 |
+ |
if ( zWidget != null ) { |
111 |
93 |
|
LOGGER.trace.log( "Attempting to Fake MouseMove on: ", zWidget ); |
112 |
94 |
|
zWidget.getElement().dispatchEvent( Document.get().createMouseMoveEvent( 0, // |
113 |
95 |
|
pEvent.getScreenX(), pEvent.getScreenY(), // |
|
@@ -117,54 +99,44 @@ |
117 |
99 |
|
} |
118 |
100 |
|
} |
119 |
101 |
|
|
120 |
|
- |
private static class MousePoint |
121 |
|
- |
{ |
|
102 |
+ |
private static class MousePoint { |
122 |
103 |
|
private int mClientX, mClientY; |
123 |
104 |
|
|
124 |
|
- |
public MousePoint( Event pEvent ) |
125 |
|
- |
{ |
|
105 |
+ |
public MousePoint( Event pEvent ) { |
126 |
106 |
|
mClientX = pEvent.getClientX(); |
127 |
107 |
|
mClientY = pEvent.getClientY(); |
128 |
108 |
|
} |
129 |
109 |
|
|
130 |
|
- |
public int getClientX() |
131 |
|
- |
{ |
|
110 |
+ |
public int getClientX() { |
132 |
111 |
|
return mClientX; |
133 |
112 |
|
} |
134 |
113 |
|
|
135 |
|
- |
public int getClientY() |
136 |
|
- |
{ |
|
114 |
+ |
public int getClientY() { |
137 |
115 |
|
return mClientY; |
138 |
116 |
|
} |
139 |
117 |
|
|
140 |
|
- |
public boolean over( Widget pWidget ) |
141 |
|
- |
{ |
|
118 |
+ |
public boolean over( Widget pWidget ) { |
142 |
119 |
|
return over( mClientX, pWidget.getAbsoluteLeft(), pWidget.getOffsetWidth() ) && // |
143 |
120 |
|
over( mClientY, pWidget.getAbsoluteTop(), pWidget.getOffsetHeight() ); |
144 |
121 |
|
} |
145 |
122 |
|
|
146 |
|
- |
private boolean over( int pClientPoint, int pWidgetAt, int pOffsetSize ) |
147 |
|
- |
{ |
|
123 |
+ |
private boolean over( int pClientPoint, int pWidgetAt, int pOffsetSize ) { |
148 |
124 |
|
return (pWidgetAt <= pClientPoint) && (pClientPoint < (pWidgetAt + pOffsetSize)); |
149 |
125 |
|
} |
150 |
126 |
|
} |
151 |
127 |
|
|
152 |
|
- |
protected static class MyMouseMoveEvent extends MouseMoveEvent |
153 |
|
- |
{ |
154 |
|
- |
public MyMouseMoveEvent( Event pEvent ) |
155 |
|
- |
{ |
|
128 |
+ |
protected static class MyMouseMoveEvent extends MouseMoveEvent { |
|
129 |
+ |
public MyMouseMoveEvent( Event pEvent ) { |
156 |
130 |
|
setNativeEvent( pEvent ); |
157 |
131 |
|
} |
158 |
132 |
|
} |
159 |
133 |
|
|
160 |
|
- |
private UnsupportedOperationException badOperation( String pWhat ) |
161 |
|
- |
{ |
|
134 |
+ |
private UnsupportedOperationException badOperation( String pWhat ) { |
162 |
135 |
|
return new UnsupportedOperationException( "LiteSoft Button's do not support the '" + pWhat + "' method!" ); |
163 |
136 |
|
} |
164 |
137 |
|
|
165 |
138 |
|
@Override |
166 |
|
- |
public String toString() |
167 |
|
- |
{ |
|
139 |
+ |
public String toString() { |
168 |
140 |
|
return Objects.justClassNameOf( this ) + "( " + mName + " )"; |
169 |
141 |
|
} |
170 |
142 |
|
} |