View Javadoc
1   /**
2    * Copyright 2005-2016 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.kuali.rice.krad.demo.uif.components;
17  
18  import java.util.ArrayList;
19  import java.util.Arrays;
20  import java.util.List;
21  
22  public class ComponentSuggestClass {
23      public static class TestLabelValue {
24          private String label;
25          private String value;
26  
27          public TestLabelValue() {
28          }
29  
30          public TestLabelValue(String value, String label) {
31              this.value = value;
32              this.label = label;
33          }
34  
35          public String getLabel() {
36              return label;
37          }
38  
39          public void setLabel(String label) {
40              this.label = label;
41          }
42  
43          public String getValue() {
44              return value;
45          }
46  
47          public void setValue(String value) {
48              this.value = value;
49          }
50      }
51  
52      public static class TestSuggestObject extends TestLabelValue {
53          private String description;
54  
55          public TestSuggestObject(String value, String label, String description) {
56              super(value, label);
57              this.description = description;
58          }
59  
60          public String getDescription() {
61              return description;
62          }
63  
64          public void setDescription(String description) {
65              this.description = description;
66          }
67      }
68  
69      public static class TestViewObject extends TestLabelValue{
70  
71          private String id;
72  
73          public TestViewObject(String value, String id){
74              super(value, value);
75              this.id = id;
76          }
77  
78          public TestViewObject(String value, String label, String id) {
79              super(value, label);
80              this.id = id;
81          }
82  
83          public String getId() {
84              return id;
85          }
86  
87          public void setId(String id) {
88              this.id = id;
89          }
90      }
91  
92      public static List<String> getLanguages(String term) {
93          List<String> matchingLanguages = new ArrayList<String>();
94  
95          String[] languageArray =
96                  {"ActionScript", "AppleScript", "Asp", "BASIC", "C", "C++", "Clojure", "COBOL", "ColdFusion", "Erlang",
97                          "Fortran", "Groovy", "Haskell", "Java", "JavaScript", "Lisp", "Perl", "PHP", "Python", "Ruby",
98                          "Scala", "Scheme"};
99  
100         for (int i = 0; i < languageArray.length; i++) {
101             String language = languageArray[i];
102             if (language.toLowerCase().startsWith(term.toLowerCase())) {
103                 matchingLanguages.add(language);
104             }
105         }
106 
107         return matchingLanguages;
108     }
109 
110     public static List<String> getAllLanguages() {
111         String[] languageArray =
112                 {"ActionScript", "AppleScript", "Asp", "BASIC", "C", "C++", "Clojure", "COBOL", "ColdFusion", "Erlang",
113                         "Fortran", "Groovy", "Haskell", "Java", "JavaScript", "Lisp", "Perl", "PHP", "Python", "Ruby",
114                         "Scala", "Scheme"};
115 
116         return Arrays.asList(languageArray);
117     }
118 
119     public static List<TestLabelValue> getRichOptions() {
120         List<TestLabelValue> options = new ArrayList<TestLabelValue>();
121 
122         options.add(new TestLabelValue("r1", "<b>Rich Option 1</b><br/><i>this is a desc for option 1</i>"));
123         options.add(new TestLabelValue("r1", "<b>Rich Option 2</b><br/><i>this is a desc for option 2</i>"));
124         options.add(new TestLabelValue("r1", "<b>Rich Option 3</b><br/><i>this is a desc for option 3</i>"));
125 
126         return options;
127     }
128 
129     public static List<TestSuggestObject> getComplexOptions() {
130         List<TestSuggestObject> options = new ArrayList<TestSuggestObject>();
131 
132         options.add(new TestSuggestObject("1", "jhbon", "Bohan, Jack"));
133         options.add(new TestSuggestObject("2", "jmcross", "Cross, Jeff"));
134         options.add(new TestSuggestObject("3", "jomot", "Mot, Joe"));
135 
136         return options;
137     }
138 
139     public static List<TestViewObject> getViewOptions() {
140         List<TestViewObject> options = new ArrayList<TestViewObject>();
141 
142         options.add(new TestViewObject("Input Field", "Demo-InputField-View"));
143         options.add(new TestViewObject("Suggest", "Demo-Suggest-View"));
144         options.add(new TestViewObject("Select Control", "Demo-SelectControl-View"));
145         options.add(new TestViewObject("TextControl","Demo-TextControl-View"));
146         options.add(new TestViewObject("Sticky Header","Demo-StickyHeader-View"));
147 
148         return options;
149     }
150 }