001    /**
002     * Copyright 2005-2013 The Kuali Foundation
003     *
004     * Licensed under the Educational Community License, Version 2.0 (the "License");
005     * you may not use this file except in compliance with the License.
006     * You may obtain a copy of the License at
007     *
008     * http://www.opensource.org/licenses/ecl2.php
009     *
010     * Unless required by applicable law or agreed to in writing, software
011     * distributed under the License is distributed on an "AS IS" BASIS,
012     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013     * See the License for the specific language governing permissions and
014     * limitations under the License.
015     */
016    package org.kuali.rice.krad.demo.uif.components;
017    
018    import java.util.ArrayList;
019    import java.util.Arrays;
020    import java.util.List;
021    
022    public class ComponentSuggestClass {
023        public static class TestLabelValue {
024            private String label;
025            private String value;
026    
027            public TestLabelValue() {
028            }
029    
030            public TestLabelValue(String value, String label) {
031                this.value = value;
032                this.label = label;
033            }
034    
035            public String getLabel() {
036                return label;
037            }
038    
039            public void setLabel(String label) {
040                this.label = label;
041            }
042    
043            public String getValue() {
044                return value;
045            }
046    
047            public void setValue(String value) {
048                this.value = value;
049            }
050        }
051    
052        public static class TestSuggestObject extends TestLabelValue {
053            private String description;
054    
055            public TestSuggestObject(String value, String label, String description) {
056                super(value, label);
057                this.description = description;
058            }
059    
060            public String getDescription() {
061                return description;
062            }
063    
064            public void setDescription(String description) {
065                this.description = description;
066            }
067        }
068    
069        public static class TestViewObject extends TestLabelValue{
070    
071            private String id;
072    
073            public TestViewObject(String value, String id){
074                super(value, value);
075                this.id = id;
076            }
077    
078            public TestViewObject(String value, String label, String id) {
079                super(value, label);
080                this.id = id;
081            }
082    
083            public String getId() {
084                return id;
085            }
086    
087            public void setId(String id) {
088                this.id = id;
089            }
090        }
091    
092        public static List<String> getLanguages(String term) {
093            List<String> matchingLanguages = new ArrayList<String>();
094    
095            String[] languageArray =
096                    {"ActionScript", "AppleScript", "Asp", "BASIC", "C", "C++", "Clojure", "COBOL", "ColdFusion", "Erlang",
097                            "Fortran", "Groovy", "Haskell", "Java", "JavaScript", "Lisp", "Perl", "PHP", "Python", "Ruby",
098                            "Scala", "Scheme"};
099    
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    }