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.input;
17:
18: import java.util.MissingResourceException;
19:
20: /**
21: *
22: * <p>Object representation of an inputField XML Element </p>
23: * <p>Also used to hold data of the results of the installer questions </p>
24: * @author Paul Hinds
25: * @version $Id: InputField.java,v 1.4 2006/12/07 02:50:27 teknopaul Exp $
26: */
27: public abstract class InputField extends OutputField {
28:
29: private String property;
30: protected String defaultValue;
31:
32: /**
33: * Flag to indicate that the user has already editted this field
34: */
35: private boolean editted = false;
36:
37: public InputField() {
38: }
39:
40: public String getDisplayText() {
41: if (langPack.isI18n()) {
42: return langPack.getString(getProperty() + ".displayText");
43: }
44: return displayText;
45: }
46:
47: public String getExplanatoryText() {
48: if (langPack.isI18n()) {
49: try {
50: return langPack.getString(getProperty()
51: + ".explanatoryText");
52: } catch (MissingResourceException e) {
53: // ignore and return null explanatoryText is optional
54: }
55: }
56: return explanatoryText;
57: }
58:
59: /**
60: * Returns the input result if there is one and if this is a PropertyField
61: * @return String
62: */
63: public String getInputResult() {
64: return resultContainer.getProperty(property);
65: }
66:
67: public void setInputResult(String inputResult) {
68: resultContainer.setProperty(property, inputResult);
69: }
70:
71: public boolean isEditted() {
72: return editted;
73: }
74:
75: public void setEditted(boolean editted) {
76: this .editted = editted;
77: }
78:
79: public void setResultContainer(ResultContainer resultContainer) {
80: this .resultContainer = resultContainer;
81: }
82:
83: public String getProperty() {
84: return property;
85: }
86:
87: public void setProperty(String property) {
88: this .property = property;
89: }
90:
91: public String getDefaultValue() {
92: return resultContainer.getDefaultValue(defaultValue);
93: }
94:
95: public void setDefaultValue(String defaultValue) {
96: this.defaultValue = defaultValue;
97: }
98:
99: }
|