2 * (C) Copyright IBM Corp. 1998-2007. All Rights Reserved.
\r
4 * The program is provided "as is" without any warranty express or
\r
5 * implied, including the warranty of non-infringement and the implied
\r
6 * warranties of merchantibility and fitness for a particular purpose.
\r
7 * IBM will not be liable for any damages suffered by you as a result
\r
8 * of using the Program. In no event will IBM be liable for any
\r
9 * special, indirect or consequential damages or lost profits even if
\r
10 * IBM has been advised of the possibility of their occurrence. IBM
\r
11 * will not be liable for any third party claims against you.
\r
13 package com.ibm.richtext.textpanel;
\r
15 import java.util.EventObject;
\r
18 * TextPanelEvent is generated by an MTextPanel to notify listeners
\r
19 * of changes. To receive TextPanelEvents from an MTextPanel, clients
\r
20 * must implement TextPanelListener and add themselves to the MTextPanel's
\r
21 * list of listeners.
\r
23 * Some event types are special cases of others. This is intentional - it
\r
24 * allows notifications to be sent less often in certain common cases. For
\r
25 * example, a change in the selection range generates a SELECTION_RANGE_CHANGED
\r
26 * event. This is a very common occurrance, and if many clients listen for this
\r
27 * event, there may be a significant performance penalty. By
\r
28 * listening for a more specialized event (such as SELECTION_EMPTY_CHANGED), clients
\r
29 * can reduce the number of notifications sent.
\r
32 * @see TextPanelListener
\r
34 public final class TextPanelEvent extends EventObject {
\r
39 private static final long serialVersionUID = 6971512969738427763L;
\r
42 * The lower bound of TextPanelEvent ID's.
\r
44 public static final int TEXT_PANEL_FIRST = 11;
\r
47 * Events of this type indicate a change in the selection range.
\r
48 * This occurs quite often. Most clients do not need to be
\r
49 * notified every time the selection range changes.
\r
51 public static final int SELECTION_RANGE_CHANGED = 11;
\r
54 * Events of this type are sent when the selection range becomes
\r
55 * 0-length after not being 0-length, or vice versa. This event
\r
56 * is a special case of SELECTION_RANGE_CHANGED.
\r
58 public static final int SELECTION_EMPTY_CHANGED = 12;
\r
61 * Events of this type indicate that the text in the TextPanel changed.
\r
62 * This type of event occurs often.
\r
64 public static final int TEXT_CHANGED = 13;
\r
67 * Events of this type are sent when the styles in the current
\r
70 public static final int SELECTION_STYLES_CHANGED = 14;
\r
73 * Events of this type are sent when the undo/redo state changes.
\r
75 public static final int UNDO_STATE_CHANGED = 15;
\r
78 * Events of this type are sent when the clipboard state changes.
\r
80 public static final int CLIPBOARD_CHANGED = 16;
\r
83 * Events of this type are sent when
\r
84 * the wrap width of the text changes.
\r
86 public static final int FORMAT_WIDTH_CHANGED = 17;
\r
89 * Events of this type are sent when the key remap changes.
\r
91 public static final int KEYREMAP_CHANGED = 18;
\r
94 * The upper bound of TextPanelEvent ID's.
\r
96 public static final int TEXT_PANEL_LAST = 18;
\r
101 * Create a new TextPanelEvent.
\r
102 * @param source the MTextPanel which generated the event
\r
103 * @param id the ID for this event. Must be within
\r
104 * [TEXT_PANEL_FIRST, TEXT_PANEL_LAST].
\r
106 TextPanelEvent(MTextPanel source, int id) {
\r
109 if (id < TEXT_PANEL_FIRST || id > TEXT_PANEL_LAST) {
\r
110 throw new IllegalArgumentException("id out of range");
\r
116 * Return the event ID for this event. Event ID's are
\r
117 * one of the class constants.
\r
118 * @return the event ID for this event
\r
120 public int getID() {
\r
125 public String toString() {
\r
127 String desc = null;
\r
130 case SELECTION_RANGE_CHANGED:
\r
131 desc = "SELECTION_RANGE_CHANGED";
\r
133 case SELECTION_EMPTY_CHANGED:
\r
134 desc = "SELECTION_EMPTY_CHANGED";
\r
137 desc = "TEXT_CHANGED";
\r
139 case SELECTION_STYLES_CHANGED:
\r
140 desc = "SELECTION_STYLES_CHANGED";
\r
142 case UNDO_STATE_CHANGED:
\r
143 desc = "UNDO_STATE_CHANGED";
\r
145 case CLIPBOARD_CHANGED:
\r
146 desc = "CLIPBOARD_CHANGED";
\r
148 case FORMAT_WIDTH_CHANGED:
\r
149 desc = "FORMAT_WIDTH_CHANGED";
\r
151 case KEYREMAP_CHANGED:
\r
152 desc = "KEYREMAP_CHANGED";
\r
155 return "[TextPanelEvent:"+desc+"]";
\r