File D:\maven-qcr-plugin-testsunitaires\qcr4java\jenkins-master\target\site\qc\ui-samples-plugin\src\main\java\jenkins\plugins\ui_samples\AutoCompleteTextBox.java.html

1 /*
2 * The MIT License
3 *
4 * Copyright (c) 2010, InfraDNA, Inc.
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights
9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 * copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 * THE SOFTWARE.
23 */
24
25 package jenkins.plugins.ui_samples;
26
27 import hudson.Extension;
28 import hudson.model.AutoCompletionCandidates;
29 import org.kohsuke.stapler.QueryParameter;
30
31 /**
32 * Adding auto-completion to the text box.
33 *
34 * @author Kohsuke Kawaguchi
35 */
36 @Extension
37 public class AutoCompleteTextBox extends UISample {
38 @Override
39 public String getDescription() {
40 return "Provide auto-completion to the text box";
41 }
42
43 @Extension
44 public static final class DescriptorImpl extends UISampleDescriptor {
45 /**
46 * This method provides auto-completion items for the 'state' field.
47 * Stapler finds this method via the naming convention.
48 *
49 * @param value
50 * The text that the user entered.
51 */
52 public AutoCompletionCandidates doAutoCompleteState(@QueryParameter String value) {
53 AutoCompletionCandidates c = new AutoCompletionCandidates();
54 for (String state : STATES)
55 if (state.toLowerCase().startsWith(value.toLowerCase()))
56 c.add(state);
57 return c;
58 }
59 }
60
61 private static final String[] STATES = new String[]{
62 "Alabama",
63 "Alaska",
64 "Arizona",
65 "Arkansas",
66 "California",
67 "Colorado",
68 "Connecticut",
69 "Delaware",
70 "Florida",
71 "Georgia",
72 "Hawaii",
73 "Idaho",
74 "Illinois",
75 "Indiana",
76 "Iowa",
77 "Kansas",
78 "Kentucky",
79 "Louisiana",
80 "Maine",
81 "Maryland",
82 "Massachusetts",
83 "Michigan",
84 "Minnesota",
85 "Mississippi",
86 "Missouri",
87 "Montana",
88 "Nebraska",
89 "Nevada",
90 "New Hampshire",
91 "New Jersey",
92 "New Mexico",
93 "New York",
94 "North Carolina",
95 "North Dakota",
96 "Ohio",
97 "Oklahoma",
98 "Oregon",
99 "Pennsylvania",
100 "Rhode Island",
101 "South Carolina",
102 "South Dakota",
103 "Tennessee",
104 "Texas",
105 "Utah",
106 "Vermont",
107 "Virginia",
108 "Washington",
109 "West Virginia",
110 "Wisconsin",
111 "Wyoming"
112 };
113 }
114