001: /*
002: #IFNDEF ALT_LICENSE
003: ThinWire(R) RIA Ajax Framework
004: Copyright (C) 2003-2007 Custom Credit Systems
005:
006: This library is free software; you can redistribute it and/or modify it under
007: the terms of the GNU Lesser General Public License as published by the Free
008: Software Foundation; either version 2.1 of the License, or (at your option) any
009: later version.
010:
011: This library is distributed in the hope that it will be useful, but WITHOUT ANY
012: WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
013: PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
014:
015: You should have received a copy of the GNU Lesser General Public License along
016: with this library; if not, write to the Free Software Foundation, Inc., 59
017: Temple Place, Suite 330, Boston, MA 02111-1307 USA
018:
019: Users who would rather have a commercial license, warranty or support should
020: contact the following company who invented, built and supports the technology:
021:
022: Custom Credit Systems, Richardson, TX 75081, USA.
023: email: info@thinwire.com ph: +1 (888) 644-6405
024: http://www.thinwire.com
025: #ENDIF
026: [ v1.2_RC2 ]
027: */
028: package thinwire.ui.event;
029:
030: import java.util.EventObject;
031:
032: import thinwire.ui.Component;
033:
034: /**
035: * @author Joshua J. Gertzen
036: * @author Ted C. Howard
037: */
038: public final class DropEvent extends EventObject {
039: private String stringValue;
040: private Component sourceComponent;
041: private Component dragComponent;
042: private Object dragObject;
043: private int sourceComponentX;
044: private int sourceComponentY;
045: private int sourceX;
046: private int sourceY;
047: private int dragComponentX;
048: private int dragComponentY;
049: private int dragX;
050: private int dragY;
051:
052: public DropEvent(Component sourceComponent, Component dragComponent) {
053: this (sourceComponent, null, -1, -1, -1, -1, dragComponent,
054: null, -1, -1, -1, -1, true);
055: }
056:
057: public DropEvent(Component sourceComponent, int sourceComponentX,
058: int sourceComponentY, Component dragComponent,
059: int dragComponentX, int dragComponentY) {
060: this (sourceComponent, null, sourceComponentX, sourceComponentY,
061: -1, -1, dragComponent, null, dragComponentX,
062: dragComponentY, -1, -1, true);
063: }
064:
065: public DropEvent(Component sourceComponent, Object source,
066: Component dragComponent, Object dragObject) {
067: this (sourceComponent, source, -1, -1, -1, -1, dragComponent,
068: dragObject, -1, -1, -1, -1, true);
069: }
070:
071: public DropEvent(Component sourceComponent, Object source,
072: int sourceComponentX, int sourceComponentY, int sourceX,
073: int sourceY, Component dragComponent, Object dragObject,
074: int dragComponentX, int dragComponentY, int dragX, int dragY) {
075: this (sourceComponent, source, sourceComponentX,
076: sourceComponentY, sourceX, sourceY, dragComponent,
077: dragObject, dragComponentX, dragComponentY, dragX,
078: dragY, true);
079: }
080:
081: private DropEvent(Component sourceComponent, Object source,
082: int sourceComponentX, int sourceComponentY, int sourceX,
083: int sourceY, Component dragComponent, Object dragObject,
084: int dragComponentX, int dragComponentY, int dragX,
085: int dragY, boolean init) {
086: super (source == null ? sourceComponent : source);
087: if (sourceComponent == null)
088: throw new IllegalArgumentException(
089: "sourceComponent == null");
090: if (init && sourceComponentX == -1)
091: sourceComponentX = 0;
092: if (init && sourceComponentY == -1)
093: sourceComponentY = 0;
094: if (sourceComponentX < 0)
095: throw new IllegalArgumentException("sourceComponentX{"
096: + sourceComponentX + "} < 0");
097: if (sourceComponentY < 0)
098: throw new IllegalArgumentException("sourceComponentY{"
099: + sourceComponentY + "} < 0");
100: if (init && sourceX == -1)
101: sourceX = sourceComponentX;
102: if (init && sourceY == -1)
103: sourceY = sourceComponentY;
104: if (sourceX < 0)
105: throw new IllegalArgumentException("sourceX{" + sourceX
106: + "} < 0");
107: if (sourceY < 0)
108: throw new IllegalArgumentException("sourceY{" + sourceY
109: + "} < 0");
110:
111: if (dragComponent == null)
112: throw new IllegalArgumentException("dragComponent == null");
113: if (dragObject == null)
114: dragObject = dragComponent;
115: if (init && dragComponentX == -1)
116: dragComponentX = 0;
117: if (init && dragComponentY == -1)
118: dragComponentY = 0;
119: if (dragComponentX < 0)
120: throw new IllegalArgumentException("dragComponentX{"
121: + dragComponentX + "} < 0");
122: if (dragComponentY < 0)
123: throw new IllegalArgumentException("dragComponentY{"
124: + dragComponentY + "} < 0");
125: if (init && dragX == -1)
126: dragX = dragComponentX;
127: if (init && dragY == -1)
128: dragY = dragComponentY;
129: if (dragX < 0)
130: throw new IllegalArgumentException("dragX{" + dragX
131: + "} < 0");
132: if (dragY < 0)
133: throw new IllegalArgumentException("dragY{" + dragY
134: + "} < 0");
135:
136: this .sourceComponent = sourceComponent;
137: this .sourceComponentX = sourceComponentX;
138: this .sourceComponentY = sourceComponentY;
139: this .sourceX = sourceX;
140: this .sourceY = sourceY;
141:
142: this .dragComponent = dragComponent;
143: this .dragObject = dragObject;
144: this .dragComponentX = dragComponentX;
145: this .dragComponentY = dragComponentY;
146: this .dragX = dragX;
147: this .dragY = dragY;
148: }
149:
150: public Component getSourceComponent() {
151: return sourceComponent;
152: }
153:
154: public Component getDragComponent() {
155: return dragComponent;
156: }
157:
158: public Object getDragObject() {
159: return dragObject;
160: }
161:
162: public int getSourceComponentX() {
163: return sourceComponentX;
164: }
165:
166: public int getSourceComponentY() {
167: return sourceComponentY;
168: }
169:
170: public int getSourceX() {
171: return sourceX;
172: }
173:
174: public int getSourceY() {
175: return sourceY;
176: }
177:
178: public int getDragComponentX() {
179: return dragComponentX;
180: }
181:
182: public int getDragComponentY() {
183: return dragComponentY;
184: }
185:
186: public int getDragX() {
187: return dragX;
188: }
189:
190: public int getDragY() {
191: return dragY;
192: }
193:
194: public boolean equals(Object o) {
195: return o instanceof DropEvent
196: && toString().equals(o.toString());
197: }
198:
199: public int hashCode() {
200: return toString().hashCode();
201: }
202:
203: public String toString() {
204: if (stringValue == null)
205: stringValue = "DropEvent{" + "sourceComponent:"
206: + sourceComponent.getClass().getName() + "@"
207: + System.identityHashCode(sourceComponent)
208: + ",source:" + source + "@"
209: + System.identityHashCode(source)
210: + ",sourceComponentX:" + sourceComponentX
211: + ",sourceComponentY:" + sourceComponentY
212: + ",sourceX:" + sourceX + ",sourceY:" + sourceY
213: + ",dragComponent:"
214: + dragComponent.getClass().getName() + "@"
215: + System.identityHashCode(dragComponent)
216: + ",dragObject:" + dragObject + "@"
217: + System.identityHashCode(dragObject)
218: + ",dragComponentX:" + dragComponentX
219: + ",dragComponentY:" + dragComponentY + ",dragX:"
220: + dragX + ",dragY:" + dragY + "}";
221: return stringValue;
222: }
223: }
|