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

1 package jenkins.plugins.ui_samples;
2
3 import hudson.Extension;
4 import hudson.util.ComboBoxModel;
5 import hudson.util.ListBoxModel;
6 import org.kohsuke.stapler.QueryParameter;
7
8 /**
9 * Combo box that changes the contents based on the values of other controls.
10 *
11 * @author Kohsuke Kawaguchi
12 */
13 @Extension
14 public class DynamicComboBox extends UISample {
15
16 @Override
17 public String getDescription() {
18 return "Updates the contents of a combo box control dynamically based on selections of other controls";
19 }
20
21 // these getter methods should return the current value, which form the initial selection.
22
23 public String getAlbum() {
24 return "3";
25 }
26
27 public String getTitle() {
28 return "Rocker";
29 }
30
31 @Extension
32 public static final class DescriptorImpl extends UISampleDescriptor {
33 /**
34 * This method determines the values of the album drop-down list box.
35 */
36 public ListBoxModel doFillAlbumItems() {
37 ListBoxModel m = new ListBoxModel();
38 m.add("Yellow Submarine","1");
39 m.add("Abbey Road","2");
40 m.add("Let It Be","3");
41 return m;
42 }
43
44 /**
45 * This method determines the values of the song title combo box.
46 * Note that it takes the album information as a parameter, so the contents
47 * of the combo box changes depending on the currently selected album.
48 */
49 public ComboBoxModel doFillTitleItems(@QueryParameter int album) {
50 switch (album) {
51 case 1:
52 return new ComboBoxModel("Yellow Submarine","Only a Northern Song","All You Need Is Love");
53 case 2:
54 return new ComboBoxModel("Come Together","Something","I Want You");
55 case 3:
56 return new ComboBoxModel("The One After 909","Rocker","Get Back");
57 default:
58 // if no value is selected in the album, we'll get 0
59 return new ComboBoxModel();
60 }
61 }
62
63 }
64 }