| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| TextControl |
|
| 1.125;1.125 |
| 1 | /* | |
| 2 | * Copyright 2007 The Kuali Foundation | |
| 3 | * | |
| 4 | * Licensed under the Educational Community License, Version 1.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/ecl1.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.kns.uif.control; | |
| 17 | ||
| 18 | import java.util.List; | |
| 19 | ||
| 20 | import org.apache.commons.lang.StringUtils; | |
| 21 | import org.kuali.rice.kns.uif.core.Component; | |
| 22 | import org.kuali.rice.kns.uif.widget.DatePicker; | |
| 23 | ||
| 24 | /** | |
| 25 | * Represents a HTML Text control, generally rendered as a input field of type | |
| 26 | * 'text'. This can display and receive a single value | |
| 27 | * | |
| 28 | * @author Kuali Rice Team (rice.collab@kuali.org) | |
| 29 | */ | |
| 30 | public class TextControl extends ControlBase { | |
| 31 | private static final long serialVersionUID = -8267606288443759880L; | |
| 32 | ||
| 33 | private int size; | |
| 34 | ||
| 35 | private DatePicker datePicker; | |
| 36 | 0 | private String watermarkText = StringUtils.EMPTY; |
| 37 | ||
| 38 | public TextControl() { | |
| 39 | 0 | super(); |
| 40 | 0 | } |
| 41 | ||
| 42 | /** | |
| 43 | * @see org.kuali.rice.kns.uif.core.ComponentBase#getNestedComponents() | |
| 44 | */ | |
| 45 | @Override | |
| 46 | public List<Component> getNestedComponents() { | |
| 47 | 0 | List<Component> components = super.getNestedComponents(); |
| 48 | ||
| 49 | 0 | components.add(datePicker); |
| 50 | ||
| 51 | 0 | return components; |
| 52 | } | |
| 53 | ||
| 54 | /** | |
| 55 | * Horizontal display size of the control (in number of characters) | |
| 56 | * | |
| 57 | * @return int size | |
| 58 | */ | |
| 59 | public int getSize() { | |
| 60 | 0 | return this.size; |
| 61 | } | |
| 62 | ||
| 63 | public void setSize(int size) { | |
| 64 | 0 | this.size = size; |
| 65 | 0 | } |
| 66 | ||
| 67 | /** | |
| 68 | * Renders a calendar that can be used to select a date value for the text | |
| 69 | * control. The <code>Calendar</code> instance contains configuration such | |
| 70 | * as the date format string | |
| 71 | * | |
| 72 | * @return Calendar | |
| 73 | */ | |
| 74 | public DatePicker getDatePicker() { | |
| 75 | 0 | return this.datePicker; |
| 76 | } | |
| 77 | ||
| 78 | public void setDatePicker(DatePicker datePicker) { | |
| 79 | 0 | this.datePicker = datePicker; |
| 80 | 0 | } |
| 81 | ||
| 82 | /** | |
| 83 | * @return the watermarkText | |
| 84 | */ | |
| 85 | public String getWatermarkText() { | |
| 86 | 0 | return this.watermarkText; |
| 87 | } | |
| 88 | ||
| 89 | /** | |
| 90 | * @param watermarkText the watermarkText to set | |
| 91 | */ | |
| 92 | public void setWatermarkText(String watermarkText) { | |
| 93 | //to avoid users from putting in the same value as the watermark adding some spaces here | |
| 94 | //see watermark troubleshooting for more info | |
| 95 | 0 | if (StringUtils.isNotEmpty(watermarkText)) { |
| 96 | 0 | watermarkText = watermarkText + " "; |
| 97 | } | |
| 98 | 0 | this.watermarkText = watermarkText; |
| 99 | 0 | } |
| 100 | } |