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