01: /*
02: * Copyright 2007 Google Inc.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License"); you may not
05: * use this file except in compliance with the License. You may obtain a copy of
06: * the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12: * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13: * License for the specific language governing permissions and limitations under
14: * the License.
15: */
16: package com.google.gwt.user.client.ui;
17:
18: import java.util.EventObject;
19:
20: /**
21: * Event object containing information about the selection of a
22: * {@link SuggestOracle.Suggestion} displayed by a {@link SuggestBox}.
23: *
24: * @see SuggestBox#addEventHandler(SuggestionHandler)
25: */
26: public class SuggestionEvent extends EventObject {
27:
28: private SuggestOracle.Suggestion selectedSuggestion;
29:
30: public SuggestionEvent(SuggestBox sender,
31: SuggestOracle.Suggestion selectedSuggestion) {
32: super (sender);
33: this .selectedSuggestion = selectedSuggestion;
34: }
35:
36: /**
37: * Gets the <code>Suggestion</code> object for the suggestion chosen by the
38: * user.
39: *
40: * @return the <code>Suggestion</code> object for the selected suggestion
41: */
42: public SuggestOracle.Suggestion getSelectedSuggestion() {
43: return selectedSuggestion;
44: }
45:
46: /**
47: * Returns the string representation of this event object. The string contains
48: * the string representation of the SuggestBox from which the event originated
49: * (the source), and the string representation of the Suggestion that was
50: * selected.
51: *
52: * @return the string representation of this event object containing the
53: * source SuggestBox and the selected Suggestion
54: */
55: @Override
56: public String toString() {
57: return "[source=" + getSource() + ", selectedSuggestion="
58: + getSelectedSuggestion() + "]";
59: }
60: }
|