01: /*
02: #IFNDEF ALT_LICENSE
03: ThinWire(R) RIA Ajax Framework
04: Copyright (C) 2003-2007 Custom Credit Systems
05:
06: This library is free software; you can redistribute it and/or modify it under
07: the terms of the GNU Lesser General Public License as published by the Free
08: Software Foundation; either version 2.1 of the License, or (at your option) any
09: later version.
10:
11: This library is distributed in the hope that it will be useful, but WITHOUT ANY
12: WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
13: PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
14:
15: You should have received a copy of the GNU Lesser General Public License along
16: with this library; if not, write to the Free Software Foundation, Inc., 59
17: Temple Place, Suite 330, Boston, MA 02111-1307 USA
18:
19: Users who would rather have a commercial license, warranty or support should
20: contact the following company who invented, built and supports the technology:
21:
22: Custom Credit Systems, Richardson, TX 75081, USA.
23: email: info@thinwire.com ph: +1 (888) 644-6405
24: http://www.thinwire.com
25: #ENDIF
26: [ v1.2_RC2 ]
27: */
28: package thinwire.render.web;
29:
30: import java.util.EventObject;
31:
32: /**
33: * @author David J. Vriend
34: */
35: public final class UserActionEvent extends EventObject {
36: private String name;
37: private Object value;
38: private long delay;
39:
40: public UserActionEvent(Integer source, String name, Object value) {
41: super (source);
42: this .name = name;
43: this .value = value;
44: this .delay = 0;
45: }
46:
47: public UserActionEvent(WebComponentEvent evt) {
48: super (evt.getSource());
49: this .name = evt.getName();
50: this .value = evt.getValue();
51: }
52:
53: public String getName() {
54: return name;
55: }
56:
57: public Object getValue() {
58: return value;
59: }
60:
61: public long getDelay() {
62: return this .delay;
63: }
64:
65: public void setDelay(long delay) {
66: this .delay = delay;
67: }
68:
69: public String toString() {
70: return "[delay=" + this .delay + ",source=" + this .source
71: + ",name=" + this .name + ",value="
72: + this .valueToString() + "]";
73: }
74:
75: private String valueToString() {
76: String result = "";
77:
78: if (this .value instanceof String[]) {
79: String[] arr = (String[]) this .value;
80:
81: for (int i = 0; i < arr.length; i++) {
82: result += arr[i] + "@@@";
83: }
84: } else {
85: result = this .value.toString();
86: }
87: return result;
88: }
89:
90: public String toXML() {
91: return "<event delay=\"" + this .delay + "\"" + " source=\""
92: + this .source + "\"" + " name=\"" + this .name + "\""
93: + " value=\"" + this .valueToString() + "\""
94: + " type=\"" + this .value.getClass().getName() + "\"/>";
95: }
96: }
|