source: release-kits/lirk3/bin/ant-installer/src/org/tp23/antinstaller/input/FileInput.java@ 14982

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

initial import of LiRK3

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.input;
17
18import java.io.File;
19
20import org.tp23.antinstaller.InstallerContext;
21import org.tp23.antinstaller.ValidationException;
22
23
24/**
25 *
26 * <p>Input type to select a directory </p>
27 * <p> </p>
28 * <p>Copyright: Copyright (c) 2004</p>
29 * <p>Company: tp23</p>
30 * @author Paul Hinds
31 * @version $Id: FileInput.java,v 1.2 2007/01/28 10:25:48 teknopaul Exp $
32 */
33public class FileInput
34 extends OSSpecific{
35
36 private boolean abort = false;
37 private String checkExists;
38
39 public FileInput() {
40 }
41
42 /**
43 * Called to validate the user input
44 */
45 public boolean validate(InstallerContext ctx) throws ValidationException{
46 if (getInputResult() == null) { // this does not happen
47 return false;
48 }
49 if(InputField.isTrue(checkExists)){
50 File file = new File(getInputResult());
51 if(!file.exists()){
52 return false;
53 }
54 }
55 return true;
56 }
57
58 public boolean isAbort() {
59 return abort;
60 }
61
62 public void setAbort(boolean abort) {
63 this.abort = abort;
64 }
65
66 public String getCheckExists() {
67 return checkExists;
68 }
69 public void setCheckExists(String checkExists) {
70 this.checkExists = checkExists;
71 }
72 public void setValue(String dir){
73 setInputResult(dir);
74 }
75
76 /**
77 * Used by checkConfig to validate the configuration file.
78 * Not used at runtime.
79 * @return boolean
80 */
81 public boolean validateObject() {
82 if(getDisplayText()==null){
83 System.out.println("File:displayText must be set");
84 return false;
85 }
86 if(getProperty()==null){
87 System.out.println("File:property must be set");
88 return false;
89 }
90 if(getDefaultValue()==null){
91 System.out.println("File:defaultValue must be set");
92 return false;
93 }
94 if(!InputField.optionalBoolean(getCheckExists())){
95 System.out.println("File:checkExists must be true or false or null");
96 return false;
97 }
98 return true;
99 }
100}
Note: See TracBrowser for help on using the repository browser.