01: package org.wings.event;
02:
03: import org.wings.SPoint;
04: import org.wings.SComponent;
05:
06: import java.util.EventObject;
07:
08: /**
09: * A 'virtual' mouse event. To convert the inner <code>SPoint</code> to a sensefule meaning you should use the
10: * according converions methods like {@link org.wings.STree#rowAtPoint(org.wings.SPoint)} or
11: * {@link org.wings.STable#columnAtPoint(org.wings.SPoint)} .
12: *
13: * @author hengels
14: * @author Benjamin Schmid <B.Schmid@exxcellent.de>
15: */
16: public class SMouseEvent extends EventObject {
17: protected int id;
18: protected boolean consumed;
19: protected SComponent component;
20: protected SPoint point;
21:
22: /**
23: * Constructs a new mouse event
24: * @param component source component
25: * @param id id
26: * @param point An SPoint. Intepretation is component dependent.
27: */
28: public SMouseEvent(SComponent component, int id, SPoint point) {
29: super (component);
30: this .component = component;
31: this .id = id;
32: this .point = point;
33: }
34:
35: public int getId() {
36: return id;
37: }
38:
39: /**
40: * Denotes if this event was already consumed.
41: * @return <code>true</code> if the mouse event was consumed an no furter event processing should occur.
42: */
43: public boolean isConsumed() {
44: return consumed;
45: }
46:
47: /**
48: * Call of this method inhibits the further dispatching of this mouse event.
49: * I.e. if you want to avoid the default actions for a mouse click (like call of
50: * normal table cell editor.
51: */
52: public void consume() {
53: consumed = true;
54: }
55:
56: /**
57: * Gets the mouse event source component
58: * @return The mouse event source component
59: */
60: public SComponent getComponent() {
61: return component;
62: }
63:
64: /**
65: * Sets the mouse event source component.
66: * @param component The mouse event source component
67: */
68: public void setComponent(SComponent component) {
69: this .component = component;
70: }
71:
72: /**
73: * The object denoting where inside the source component a mouse click occured.
74: * @return An virtual mouse click point. Intepretation is component dependent.
75: */
76: public SPoint getPoint() {
77: return point;
78: }
79:
80: /**
81: * The object denoting where inside the source component a mouse click occured.
82: * @param point An virtual mouse click point. Intepretation is component dependent.
83: */
84: public void setPoint(SPoint point) {
85: this .point = point;
86: }
87:
88: public String toString() {
89: return getClass().getName() + "[" + point + "] on "
90: + component.getName();
91: }
92: }
|