001: /*
002: * Copyright 2005-2007 The Kuali Foundation.
003: *
004: * Licensed under the Educational Community License, Version 1.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/ecl1.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:
017: package org.kuali.core.datadictionary.control;
018:
019: import org.apache.commons.logging.Log;
020: import org.apache.commons.logging.LogFactory;
021: import org.kuali.core.datadictionary.DataDictionaryDefinitionBase;
022: import org.kuali.core.datadictionary.ValidationCompletionUtils;
023: import org.kuali.core.datadictionary.exception.CompletionException;
024:
025: /**
026: * A single HTML control definition in the DataDictionary, which contains information relating to the HTML control used to realize a
027: * specific attribute. All types of controls are represented by an instance of this class; you have to call one of the is* methods
028: * to figure out which of the other accessors should return useful values.
029: *
030: *
031: */
032: public abstract class ControlDefinitionBase extends
033: DataDictionaryDefinitionBase implements ControlDefinition {
034:
035: // logger
036: private static Log LOG = LogFactory
037: .getLog(ControlDefinitionBase.class);
038:
039: private boolean datePicker;
040: private String script;
041: private Class valuesFinderClass;
042: private Integer size;
043: private Integer rows;
044: private Integer cols;
045:
046: public ControlDefinitionBase() {
047: LOG.debug("creating new ControlDefinition");
048: }
049:
050: public boolean isDatePicker() {
051: return datePicker;
052: }
053:
054: public void setDatePicker(boolean datePicker) {
055: this .datePicker = datePicker;
056: }
057:
058: /**
059: * @see org.kuali.core.datadictionary.control.ControlDefinition#isCheckbox()
060: */
061: public boolean isCheckbox() {
062: return false;
063: }
064:
065: /**
066: * @see org.kuali.core.datadictionary.control.ControlDefinition#isHidden()
067: */
068: public boolean isHidden() {
069: return false;
070: }
071:
072: /**
073: * @see org.kuali.core.datadictionary.control.ControlDefinition#isRadio()
074: */
075: public boolean isRadio() {
076: return false;
077: }
078:
079: /**
080: * @see org.kuali.core.datadictionary.control.ControlDefinition#isSelect()
081: */
082: public boolean isSelect() {
083: return false;
084: }
085:
086: /**
087: *
088: * @see org.kuali.core.datadictionary.control.ControlDefinition#isApcSelect()
089: */
090:
091: public boolean isApcSelect() {
092: return false;
093: }
094:
095: /**
096: * @see org.kuali.core.datadictionary.control.ControlDefinition#isText()
097: */
098: public boolean isText() {
099: return false;
100: }
101:
102: /**
103: * @see org.kuali.core.datadictionary.control.ControlDefinition#isTextarea()
104: */
105: public boolean isTextarea() {
106: return false;
107: }
108:
109: /**
110: * @see org.kuali.core.datadictionary.control.ControlDefinition#isCurrency()
111: */
112: public boolean isCurrency() {
113: return false;
114: }
115:
116: /**
117: *
118: * @see org.kuali.core.datadictionary.control.ControlDefinition#isKualiUser()
119: */
120: public boolean isKualiUser() {
121: return false;
122: }
123:
124: /**
125: * @see org.kuali.core.datadictionary.control.ControlDefinition#isWorkgroup()
126: */
127: public boolean isWorkflowWorkgroup() {
128: return false;
129: }
130:
131: /**
132: * @see org.kuali.core.datadictionary.control.ControlDefinition#isLookupHidden()
133: */
134: public boolean isLookupHidden() {
135: return false;
136: }
137:
138: /**
139: * @see org.kuali.core.datadictionary.control.ControlDefinition#isLookupReadonly()
140: */
141: public boolean isLookupReadonly() {
142: return false;
143: }
144:
145: /**
146: * @see org.kuali.core.datadictionary.control.ControlDefinition#setKeyValuesFinder(java.lang.String)
147: */
148: public void setValuesFinderClass(Class valuesFinderClass) {
149: if (valuesFinderClass == null) {
150: throw new IllegalArgumentException(
151: "invalid (null) valuesFinderClass");
152: }
153: LOG.debug("calling setValuesKey '"
154: + valuesFinderClass.getName() + "'");
155:
156: this .valuesFinderClass = valuesFinderClass;
157: }
158:
159: /**
160: * @see org.kuali.core.datadictionary.control.ControlDefinition#getKeyValuesFinder()
161: */
162: public Class getValuesFinderClass() {
163: return valuesFinderClass;
164: }
165:
166: /**
167: * @see org.kuali.core.datadictionary.control.ControlDefinition#setSize(int)
168: */
169: public void setSize(Integer size) {
170: LOG.debug("calling setSize '" + size + "'");
171:
172: this .size = size;
173: }
174:
175: /**
176: * @see org.kuali.core.datadictionary.control.ControlDefinition#getSize()
177: */
178: public Integer getSize() {
179: return size;
180: }
181:
182: /**
183: * @see org.kuali.core.datadictionary.control.ControlDefinition#hasScript()
184: */
185: public boolean hasScript() {
186: return false;
187: }
188:
189: /**
190: * @see org.kuali.core.datadictionary.control.ControlDefinition#setRows(int)
191: */
192: public void setRows(Integer rows) {
193: LOG.debug("calling setRows '" + rows + "'");
194:
195: this .rows = rows;
196: }
197:
198: /**
199: * @see org.kuali.core.datadictionary.control.ControlDefinition#getRows()
200: */
201: public Integer getRows() {
202: return rows;
203: }
204:
205: /**
206: * @see org.kuali.core.datadictionary.control.ControlDefinition#setCols(int)
207: */
208: public void setCols(Integer cols) {
209: LOG.debug("calling setCols '" + cols + "'");
210:
211: this .cols = cols;
212: }
213:
214: /**
215: * @see org.kuali.core.datadictionary.control.ControlDefinition#getCols()
216: */
217: public Integer getCols() {
218: return cols;
219: }
220:
221: /**
222: * Directly validate simple fields.
223: *
224: * @see org.kuali.core.datadictionary.DataDictionaryDefinition#completeValidation(java.lang.Class, java.lang.Object)
225: */
226: public void completeValidation(Class rootBusinessObjectClass,
227: Class otherBusinessObjectClass,
228: ValidationCompletionUtils validationCompletionUtils) {
229: if (!isCheckbox() && !isHidden() && !isRadio() && !isSelect()
230: && !isApcSelect() && !isText() && !isTextarea()
231: && !isCurrency() && !isKualiUser() && !isLookupHidden()
232: && !isLookupReadonly() && !isWorkflowWorkgroup()) {
233: throw new CompletionException(
234: "error validating "
235: + rootBusinessObjectClass.getName()
236: + " control: unknown control type in control definition ("
237: + getParseLocation() + ")");
238: }
239: }
240:
241: /**
242: * @see org.kuali.core.datadictionary.control.ControlDefinition#getScript()
243: */
244: public String getScript() {
245: return script;
246: }
247:
248: /**
249: * @see org.kuali.core.datadictionary.control.ControlDefinition#setScript()
250: */
251:
252: public void setScript(String script) {
253: this.script = script;
254: }
255: }
|