1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
package org.apache.tapestry.event; |
15 |
|
|
16 |
|
import java.util.HashMap; |
17 |
|
import java.util.Map; |
18 |
|
|
19 |
|
import org.apache.commons.lang.builder.ToStringBuilder; |
20 |
|
import org.apache.commons.lang.builder.ToStringStyle; |
21 |
|
import org.apache.hivemind.util.Defense; |
22 |
|
import org.apache.tapestry.IRequestCycle; |
23 |
|
|
24 |
|
|
25 |
|
|
26 |
|
|
27 |
|
|
28 |
|
|
29 |
|
|
30 |
|
public class BrowserEvent |
31 |
|
{ |
32 |
|
public static final String NAME="beventname"; |
33 |
|
public static final String TYPE="beventtype"; |
34 |
|
public static final String KEYS="beventkeys"; |
35 |
|
public static final String CHAR_CODE="beventcharCode"; |
36 |
|
public static final String PAGE_X="beventpageX"; |
37 |
|
public static final String PAGE_Y="beventpageY"; |
38 |
|
public static final String LAYER_X="beventlayerX"; |
39 |
|
public static final String LAYER_Y="beventlayerY"; |
40 |
|
|
41 |
|
public static final String TARGET="beventtarget"; |
42 |
|
public static final String TARGET_ATTR_ID="id"; |
43 |
|
|
44 |
|
private String _name; |
45 |
|
private String _type; |
46 |
|
private String[] _keys; |
47 |
|
private String _charCode; |
48 |
|
private String _pageX; |
49 |
|
private String _pageY; |
50 |
|
private String _layerX; |
51 |
|
private String _layerY; |
52 |
|
private EventTarget _target; |
53 |
|
|
54 |
|
|
55 |
|
|
56 |
|
|
57 |
|
|
58 |
|
|
59 |
|
|
60 |
|
|
61 |
|
public BrowserEvent(IRequestCycle cycle) |
62 |
10 |
{ |
63 |
10 |
Defense.notNull(cycle, "cycle"); |
64 |
|
|
65 |
10 |
_name = cycle.getParameter(NAME); |
66 |
10 |
_type = cycle.getParameter(TYPE); |
67 |
10 |
_keys = cycle.getParameters(KEYS); |
68 |
10 |
_charCode = cycle.getParameter(CHAR_CODE); |
69 |
10 |
_pageX = cycle.getParameter(PAGE_X); |
70 |
10 |
_pageY = cycle.getParameter(PAGE_Y); |
71 |
10 |
_layerX = cycle.getParameter(LAYER_X); |
72 |
10 |
_layerY = cycle.getParameter(LAYER_Y); |
73 |
|
|
74 |
10 |
Map props = new HashMap(); |
75 |
10 |
_target = new EventTarget(props); |
76 |
|
|
77 |
10 |
String targetId = cycle.getParameter(TARGET + "." + TARGET_ATTR_ID); |
78 |
10 |
if (targetId != null) { |
79 |
10 |
props.put(TARGET_ATTR_ID, targetId); |
80 |
|
} |
81 |
10 |
} |
82 |
|
|
83 |
|
|
84 |
|
|
85 |
|
|
86 |
|
|
87 |
|
|
88 |
|
|
89 |
|
|
90 |
|
public BrowserEvent(String name, EventTarget target) |
91 |
9 |
{ |
92 |
9 |
_name = name; |
93 |
9 |
_target = target; |
94 |
9 |
} |
95 |
|
|
96 |
|
|
97 |
|
|
98 |
|
|
99 |
|
|
100 |
|
|
101 |
|
|
102 |
|
|
103 |
|
|
104 |
|
public String getName() |
105 |
|
{ |
106 |
5 |
return _name; |
107 |
|
} |
108 |
|
|
109 |
|
|
110 |
|
|
111 |
|
|
112 |
|
|
113 |
|
|
114 |
|
public EventTarget getTarget() |
115 |
|
{ |
116 |
6 |
return _target; |
117 |
|
} |
118 |
|
|
119 |
|
|
120 |
|
|
121 |
|
|
122 |
|
public String getCharCode() |
123 |
|
{ |
124 |
0 |
return _charCode; |
125 |
|
} |
126 |
|
|
127 |
|
|
128 |
|
|
129 |
|
|
130 |
|
public String[] getKeys() |
131 |
|
{ |
132 |
0 |
return _keys; |
133 |
|
} |
134 |
|
|
135 |
|
|
136 |
|
|
137 |
|
|
138 |
|
public String getLayerX() |
139 |
|
{ |
140 |
0 |
return _layerX; |
141 |
|
} |
142 |
|
|
143 |
|
|
144 |
|
|
145 |
|
|
146 |
|
public String getLayerY() |
147 |
|
{ |
148 |
0 |
return _layerY; |
149 |
|
} |
150 |
|
|
151 |
|
|
152 |
|
|
153 |
|
|
154 |
|
public String getPageX() |
155 |
|
{ |
156 |
0 |
return _pageX; |
157 |
|
} |
158 |
|
|
159 |
|
|
160 |
|
|
161 |
|
|
162 |
|
public String getPageY() |
163 |
|
{ |
164 |
0 |
return _pageY; |
165 |
|
} |
166 |
|
|
167 |
|
|
168 |
|
|
169 |
|
|
170 |
|
public String getType() |
171 |
|
{ |
172 |
0 |
return _type; |
173 |
|
} |
174 |
|
|
175 |
|
|
176 |
|
|
177 |
|
|
178 |
|
|
179 |
|
|
180 |
|
|
181 |
|
|
182 |
|
public static boolean hasBrowserEvent(IRequestCycle cycle) |
183 |
|
{ |
184 |
8 |
Defense.notNull(cycle, "cycle"); |
185 |
|
|
186 |
8 |
return cycle.getParameter(NAME) != null; |
187 |
|
} |
188 |
|
|
189 |
|
public String toString() |
190 |
|
{ |
191 |
0 |
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE) |
192 |
|
.append("name", _name) |
193 |
|
.append("type", _type) |
194 |
|
.append("keys", _keys) |
195 |
|
.append("charCode", _charCode) |
196 |
|
.append("pageX", _pageX) |
197 |
|
.append("pageY", _pageY) |
198 |
|
.append("layerX", _layerX) |
199 |
|
.append("layerY", _layerY) |
200 |
|
.append("target", _target) |
201 |
|
.toString(); |
202 |
|
} |
203 |
|
} |