View Javadoc
1   package org.vaadin.aceeditor;
2   
3   import org.vaadin.aceeditor.client.TransportSuggestion;
4   
5   /**
6    * A single suggestion.
7    * 
8    * Feel free to subclass.
9    */
10  public class Suggestion {
11  
12  	private final String displayText;
13  	private final String descriptionText;
14  	private final String suggestionText;
15  
16  	/**
17  	 * 
18  	 * @param displayText
19  	 *            the text shown in the popup list
20  	 * @param descriptionText
21  	 *            a longer description
22  	 */
23  	public Suggestion(String displayText,
24  			String descriptionText) {
25  		this(displayText, descriptionText, "");
26  	}
27  	
28  	/**
29  	 * 
30  	 * If suggestionText is "cat", the suggestion popup will stay there
31  	 * if user types "c" "ca" or "cat".
32  	 * 
33  	 * @param displayText
34  	 *            the text shown in the popup list
35  	 * @param descriptionText
36  	 *            a longer description
37  	 * @param suggestionText
38  	 */
39  	public Suggestion(String displayText,
40  			String descriptionText, String suggestionText) {
41  		this.displayText = displayText;
42  		this.descriptionText = descriptionText;
43  		this.suggestionText = suggestionText;
44  	}
45  	
46  	public TransportSuggestion asTransport(int index) {
47  		TransportSuggestion ts = new TransportSuggestion();
48  		ts.displayText = displayText;
49  		ts.descriptionText = descriptionText;
50  		ts.suggestionText = suggestionText;
51  		ts.index = index;
52  		return ts;
53  	}
54  
55  	public String getDisplayText() {
56  		return displayText;
57  	}
58  
59  	public String getDescriptionText() {
60  		return descriptionText;
61  	}
62  
63  	public String getSuggestionText() {
64  		return suggestionText;
65  	}
66  	
67  	
68  }