source: other-projects/trunk/realistic-books/packages/AntInstaller/src/org/tp23/antinstaller/input/CheckboxInput.java@ 19253

Last change on this file since 19253 was 19253, checked in by davidb, 15 years ago

Establishing a source code repository for Veronica's Realistic Book's software

File size: 2.1 KB
Line 
1/*
2 * Copyright 2005 Paul Hinds
3 *
4 * Licensed under the Apache 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.apache.org/licenses/LICENSE-2.0
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 */
16package org.tp23.antinstaller.input;
17
18
19import org.tp23.antinstaller.InstallerContext;
20import org.tp23.antinstaller.ValidationException;
21
22
23
24/**
25 *
26 * <p>Input type for boolean choices represented as a checkbox in swing and a yes/no option
27 * on the command line </p>
28 * @author Paul Hinds
29 * @version $Id: CheckboxInput.java,v 1.3 2006/12/07 02:42:22 teknopaul Exp $
30 */
31public class CheckboxInput
32 extends InputField{
33
34
35 private String force;
36
37 public CheckboxInput() {
38 }
39
40 public String getForce() {
41 return force;
42 }
43
44 public void setForce(String force) {
45 this.force = force;
46 }
47
48 public void setValue(String trueOrFalse){
49 setInputResult(trueOrFalse);
50 }
51 /**
52 * Called to validate the user input
53 * @TODO should validate against non internationalized true or false flags
54 */
55 public boolean validate(InstallerContext cxt) throws ValidationException{
56 return true;
57 }
58
59
60 /**
61 * Used by checkConfig to validate the configuration file.
62 * Not used at runtime.
63 * @return boolean
64 */
65 public boolean validateObject() {
66 if(getProperty()==null){
67 System.out.println("Checkbox:property must be set");
68 return false;
69 }
70 if(getDisplayText()==null){
71 System.out.println("Checkbox:displayText must be set");
72 return false;
73 }
74 if(!InputField.requiredBoolean(getDefaultValue())){
75 System.out.println("Checkbox:defaultValue must be true or false");
76 return false;
77 }
78 if(!InputField.optionalBoolean(getForce())){
79 System.out.println("Checkbox:defaultValue must be true or false or null");
80 return false;
81 }
82 return true;
83 }
84
85
86}
Note: See TracBrowser for help on using the repository browser.