source: release-kits/shared/ant-installer/src/org/tp23/antinstaller/renderer/text/CheckboxInputRenderer.java@ 15353

Last change on this file since 15353 was 15353, checked in by oranfry, 16 years ago

debugging lines added

File size: 2.4 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.renderer.text;
17
18import java.io.BufferedReader;
19import java.io.IOException;
20import java.io.PrintStream;
21import java.util.ResourceBundle;
22
23import org.tp23.antinstaller.InstallerContext;
24import org.tp23.antinstaller.input.CheckboxInput;
25import org.tp23.antinstaller.input.InputField;
26import org.tp23.antinstaller.input.OutputField;
27
28
29public class CheckboxInputRenderer
30 implements TextOutputFieldRenderer {
31
32 private static final ResourceBundle res = ResourceBundle.getBundle("resources.LanguagePack");
33
34 protected InstallerContext ctx;
35
36 public CheckboxInputRenderer() {
37 }
38
39 public void setContext(InstallerContext ctx) {
40 this.ctx = ctx;
41 }
42
43 public void renderOutput(OutputField field, BufferedReader reader, PrintStream out) throws IOException {
44 CheckboxInput iField = (CheckboxInput) field;
45 out.print(iField.getDisplayText());
46 out.print(" [");
47 out.print(res.getString("_default_"));
48 out.print(":");
49 out.print(iField.getDefaultValue());
50 out.print("]");
51 if (InputField.isTrue(iField.getForce())) {
52 out.println(res.getString("_required_"));
53 iField.setValue(iField.getDefaultValue());
54 return;
55 }
56 else {
57 out.println();
58 }
59
60
61 String input = reader.readLine();
62 out.println();
63 if (input == null || input.trim().equals("")) {
64 input = iField.getDefaultValue();
65 }
66 if(InputField.isTrue(input)){
67 iField.setValue("true");
68 }
69 //@TODO should accept true or false only and complain toher wise looping till sensible input
70 //else if (InputField.isFalse(input)){
71 // iField.setValue("false");
72 //}
73 else{
74 iField.setValue("false");
75 }
76 }
77
78 public boolean isAbort() {
79 return false;
80 }
81
82
83
84 /**
85 * renderError
86 *
87 * @param field InputField
88 * @param in InputStream
89 * @param out PrintStream
90 */
91 public void renderError(OutputField field, BufferedReader reader, PrintStream out) {
92 }
93}
Note: See TracBrowser for help on using the repository browser.