001: package com.memoire.vainstall.tui;
002:
003: import java.io.*;
004: import com.memoire.vainstall.*;
005:
006: public class TuiDirectoryStep extends TuiDefaultStep implements
007: VADirectoryStep {
008: private String dir_ = null;
009:
010: public TuiDirectoryStep() {
011: /* if(dir_==null)
012: {
013: if(Setup.IS_UNIX)
014: {
015: if(Setup.IS_ROOT)
016: dir_=new File("/usr/local/",
017: VAGlobals.DEST_PATH).getAbsolutePath();
018: else
019: dir_=new File(System.getProperty("user.home"),
020: VAGlobals.DEST_PATH).getAbsolutePath();
021: }
022: else
023: dir_=new File(VAGlobals.DEST_PATH).getAbsolutePath();
024: }*/
025: }
026:
027: /* private File correct(String f)
028: {
029: File d=new File(f);
030: File parent=d.getParentFile();
031:
032: if((parent!=null)&&((!parent.exists())||(!parent.canWrite())))
033: {
034: TuiWizard.error
035: ("This directory ["+f+"] is not writable.");
036: d=null;
037: }
038:
039: return d;
040: }*/
041:
042: public void setDirectory(File _dir) {
043: dir_ = _dir.getAbsolutePath();
044: browse();
045: }
046:
047: public File getDirectory() {
048: return new File(dir_);
049: //return correct(dir_);
050: }
051:
052: public void roDirectory(File d) {
053: TuiWizard.error(VAGlobals.i18n("Setup_NoWritableDirectory")
054: + d.getAbsolutePath() + "\n"
055: + VAGlobals.i18n("Setup_NoWritableDirectoryInfos"));
056: }
057:
058: public void rejectDirectory() {
059: TuiWizard.error(VAGlobals.i18n("UI_NotChooseDirectory"));
060: }
061:
062: public boolean acceptDirectory() {
063: TuiWizard.clear();
064: TuiWizard.title();
065: TuiWizard.println(VAGlobals.i18n("TuiDirectoryStep_Step4"));
066: TuiWizard.separator();
067: TuiWizard.println("");
068: TuiWizard.println(VAGlobals.i18n("UI_InstallationDirectory"));
069: TuiWizard.println(" " + dir_);
070: for (int i = 7; i < 23; i++)
071: TuiWizard.println("");
072: TuiWizard.info();
073: TuiWizard.println(VAGlobals.i18n("UI_IsThatRight"));
074: TuiWizard.separator();
075: return TuiWizard.confirm();
076: }
077:
078: private void browse() {
079: String f = dir_;
080:
081: //do
082: //{
083: TuiWizard.clear();
084: TuiWizard.title();
085: TuiWizard.println(VAGlobals.i18n("TuiDirectoryStep_Step4"));
086: TuiWizard.separator();
087: TuiWizard.println("");
088:
089: //TuiWizard.println(System.getProperty("user.dir"));
090: //TuiWizard.println("");
091: //TuiWizard.println("Current position for relative directories is :");
092:
093: TuiWizard.println(VAGlobals
094: .i18n("TuiDirectoryStep_DefaultInstallationDirectory"));
095: TuiWizard.println(dir_);
096:
097: TuiWizard.println("");
098: TuiWizard.println("");
099: TuiWizard.println("");
100:
101: for (int i = 9; i < 23; i++)
102: TuiWizard.println("");
103: TuiWizard.info();
104: TuiWizard.println(VAGlobals
105: .i18n("TuiDirectoryStep_EnterInstallationDirectory"));
106: TuiWizard.user();
107: f = TuiWizard.input();
108: if ("".equals(f))
109: f = dir_;
110: //}
111: //while(correct(f)==null);
112: dir_ = new File(f).getAbsolutePath();
113: }
114: }
|