1 | // License: GPL. For details, see LICENSE file.
|
---|
2 | package org.openstreetmap.josm.gui.tagging.ac;
|
---|
3 |
|
---|
4 | import java.awt.AWTEvent;
|
---|
5 |
|
---|
6 | /**
|
---|
7 | * This event is generated by an AutoCompTextField when an autocomplete occurred.
|
---|
8 | *
|
---|
9 | * @see AutoCompTextField
|
---|
10 | * @see AutoCompListener
|
---|
11 | * @since 18221
|
---|
12 | */
|
---|
13 | public class AutoCompEvent extends AWTEvent {
|
---|
14 |
|
---|
15 | /**
|
---|
16 | * The first number in the range of ids used for autoComp events.
|
---|
17 | */
|
---|
18 | public static final int AUTOCOMP_FIRST = 5900;
|
---|
19 |
|
---|
20 | /**
|
---|
21 | * The last number in the range of ids used for autoComp events.
|
---|
22 | */
|
---|
23 | public static final int AUTOCOMP_LAST = 5901;
|
---|
24 |
|
---|
25 | /**
|
---|
26 | * This event id indicates that an autocomp is about to start.
|
---|
27 | */
|
---|
28 | public static final int AUTOCOMP_BEFORE = AUTOCOMP_FIRST;
|
---|
29 |
|
---|
30 | /**
|
---|
31 | * This event id indicates that an autocomp completed.
|
---|
32 | */
|
---|
33 | public static final int AUTOCOMP_DONE = AUTOCOMP_FIRST + 1;
|
---|
34 |
|
---|
35 | /*
|
---|
36 | * JDK 1.1 serialVersionUID
|
---|
37 | */
|
---|
38 | private static final long serialVersionUID = 3745384758753475838L;
|
---|
39 |
|
---|
40 | /** the selected autocomplete item */
|
---|
41 | private Object item;
|
---|
42 |
|
---|
43 | /**
|
---|
44 | * Constructs a <code>AutoCompEvent</code> object.
|
---|
45 | * <p> This method throws an
|
---|
46 | * <code>IllegalArgumentException</code> if <code>source</code>
|
---|
47 | * is <code>null</code>.
|
---|
48 | *
|
---|
49 | * @param source The (<code>AutoCompTextField</code>) object that
|
---|
50 | * originated the event
|
---|
51 | * @param id An integer that identifies the event type.
|
---|
52 | * For information on allowable values, see
|
---|
53 | * the class description for {@link AutoCompEvent}
|
---|
54 | * @param item The item selected for autocompletion.
|
---|
55 | * @throws IllegalArgumentException if <code>source</code> is null
|
---|
56 | * @see #getSource()
|
---|
57 | * @see #getID()
|
---|
58 | */
|
---|
59 | public AutoCompEvent(Object source, int id, Object item) {
|
---|
60 | super(source, id);
|
---|
61 | this.item = item;
|
---|
62 | }
|
---|
63 |
|
---|
64 | /**
|
---|
65 | * Returns the item selected for autocompletion.
|
---|
66 | *
|
---|
67 | * @return the item selected for autocompletion
|
---|
68 | */
|
---|
69 | public Object getItem() {
|
---|
70 | return item;
|
---|
71 | }
|
---|
72 |
|
---|
73 | /**
|
---|
74 | * Returns a parameter string identifying this text event.
|
---|
75 | * This method is useful for event-logging and for debugging.
|
---|
76 | *
|
---|
77 | * @return a string identifying the event and its attributes
|
---|
78 | */
|
---|
79 | @Override
|
---|
80 | public String paramString() {
|
---|
81 | String typeStr;
|
---|
82 | switch(id) {
|
---|
83 | case AUTOCOMP_BEFORE:
|
---|
84 | typeStr = "AUTOCOMP_BEFORE";
|
---|
85 | break;
|
---|
86 | case AUTOCOMP_DONE:
|
---|
87 | typeStr = "AUTOCOMP_DONE";
|
---|
88 | break;
|
---|
89 | default:
|
---|
90 | typeStr = "unknown type";
|
---|
91 | }
|
---|
92 | return typeStr;
|
---|
93 | }
|
---|
94 | }
|
---|