01: /*
02: * Copyright 2005 Paul Hinds
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
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.tp23.antinstaller.renderer.text;
17:
18: import java.io.BufferedReader;
19: import java.io.IOException;
20: import java.io.PrintStream;
21:
22: import org.tp23.antinstaller.InstallerContext;
23: import org.tp23.antinstaller.input.OutputField;
24: import org.tp23.antinstaller.input.UnvalidatedTextInput;
25: import org.tp23.antinstaller.renderer.AIResourceBundle;
26:
27: public class UnvalidatedTextInputRenderer implements
28: TextOutputFieldRenderer {
29:
30: private static final AIResourceBundle res = new AIResourceBundle();
31:
32: protected InstallerContext ctx;
33:
34: public UnvalidatedTextInputRenderer() {
35: }
36:
37: public void setContext(InstallerContext ctx) {
38: this .ctx = ctx;
39: }
40:
41: public void renderOutput(OutputField field, BufferedReader reader,
42: PrintStream out) throws IOException {
43: UnvalidatedTextInput iField = (UnvalidatedTextInput) field;
44: out.print(field.getDisplayText());
45:
46: out.print(" [");
47: out.print(res.getString("selection.default"));
48: out.print(":");
49: out.print(iField.getDefaultValue());
50: out.print("]");
51:
52: //BufferedReader reader = new BufferedReader(new InputStreamReader(in));
53: out.println();
54: String input = reader.readLine();
55: out.println();
56: if (input == null || input.equals(""))
57: input = iField.getDefaultValue();
58: iField.setInputResult(input);
59: }
60:
61: public boolean isAbort() {
62: return false;
63: }
64:
65: /**
66: * renderError
67: *
68: * @param field InputField
69: * @param in InputStream
70: * @param out PrintStream
71: */
72: public void renderError(OutputField field, BufferedReader reader,
73: PrintStream out) {
74: }
75: }
|