01: /*
02: * Copyright 2000,2005 wingS development team.
03: *
04: * This file is part of wingS (http://wingsframework.org).
05: *
06: * wingS is free software; you can redistribute it and/or modify
07: * it under the terms of the GNU Lesser General Public License
08: * as published by the Free Software Foundation; either version 2.1
09: * of the License, or (at your option) any later version.
10: *
11: * Please see COPYING for the complete licence.
12: */
13: package org.wings.event;
14:
15: import org.wings.text.SDocument;
16:
17: import java.awt.*;
18:
19: /**
20: * A document event fire on any document change (i.e. change of a text in a {@link org.wings.STextField}).
21: *
22: * @author hengels
23: */
24: public class SDocumentEvent extends AWTEvent {
25: /**
26: * An style attribute changed. <b>DO NOT EXPECT CHARACTER CHANGES HERE!</b> This event type will not occur inside wings!
27: */
28: public final static int CHANGE = 1;
29: /**
30: * A string has been inserted.
31: */
32: public final static int INSERT = 2;
33: /**
34: * A string has been removed.
35: */
36: public final static int REMOVE = 3;
37:
38: private int offset;
39: private int length;
40:
41: public SDocumentEvent(SDocument document, int offset, int length,
42: int type) {
43: super (document, type);
44: this .offset = offset;
45: this .length = length;
46: }
47:
48: /**
49: * Gets the source document of the change event.
50: * @return the document
51: */
52: public SDocument getDocument() {
53: return (SDocument) getSource();
54: }
55:
56: /**
57: * Returns the offset where the change in the document starts.
58: * @return Offset where remove/insert occured (0 = first letter)
59: */
60: public int getOffset() {
61: return offset;
62: }
63:
64: /**
65: * Returns the length of the change.
66: * @return The length of the insert/remove
67: */
68: public int getLength() {
69: return length;
70: }
71:
72: /**
73: * Gets the type of the Event.
74: * @return {@link #INSERT} or {@link #REMOVE}
75: */
76: public int getType() {
77: return getID();
78: }
79: }
|