001: package com.memoire.vainstall.tui;
002:
003: import com.memoire.vainstall.*;
004:
005: public class TuiInstallStep extends TuiDefaultStep implements
006: VAInstallStep {
007: private int progres_ = 0;
008: private String detail_ = "";
009: private String status_ = "";
010: private boolean first_ = true;
011:
012: public TuiInstallStep() {
013: TuiWizard.clear();
014: TuiWizard.title();
015:
016: switch (VAGlobals.OPERATION) {
017: case VAGlobals.INSTALL:
018: TuiWizard.println(VAGlobals.i18n("TuiInstallStep_Step5In"));
019: break;
020: case VAGlobals.UPDATE:
021: TuiWizard.println(VAGlobals.i18n("TuiInstallStep_Step5Up"));
022: break;
023: case VAGlobals.UNINSTALL:
024: TuiWizard.println(VAGlobals.i18n("TuiInstallStep_Step2Un"));
025: break;
026: default:
027: TuiWizard.println(VAGlobals.i18n("TuiInstallStep_StepN"));
028: break;
029: }
030:
031: TuiWizard.separator();
032: TuiWizard.println("");
033: TuiWizard.println(VAGlobals.i18n("TuiInstallStep_AllReady"));
034:
035: switch (VAGlobals.OPERATION) {
036: case VAGlobals.UPDATE:
037: case VAGlobals.INSTALL:
038: TuiWizard.println(VAGlobals.i18n("TuiInstallStep_NowCopy"));
039: break;
040: case VAGlobals.UNINSTALL:
041: TuiWizard.println(VAGlobals
042: .i18n("TuiInstallStep_NowRemove"));
043: break;
044: default:
045: TuiWizard.println(VAGlobals.i18n("UI_Unknown"));
046: break;
047: }
048:
049: for (int i = 6; i < 22; i++)
050: TuiWizard.println("");
051: TuiWizard.info();
052:
053: switch (VAGlobals.OPERATION) {
054: case VAGlobals.UPDATE:
055: case VAGlobals.INSTALL:
056: TuiWizard.println(VAGlobals
057: .i18n("TuiInstallStep_StartCopy"));
058: break;
059: case VAGlobals.UNINSTALL:
060: TuiWizard.println(VAGlobals
061: .i18n("TuiInstallStep_StartRemove"));
062: break;
063: default:
064: TuiWizard.println(VAGlobals.i18n("UI_Unknown"));
065: break;
066: }
067: }
068:
069: private void refresh() {
070: if (first_)
071: TuiWizard.clear();
072: else if (TuiWizard.ansi)
073: TuiWizard.print("\033[00;00H");
074:
075: if (first_ || !TuiWizard.ansi) {
076: TuiWizard.title();
077:
078: switch (VAGlobals.OPERATION) {
079: case VAGlobals.INSTALL:
080: TuiWizard.println(VAGlobals
081: .i18n("TuiInstallStep_Step5In"));
082: break;
083: case VAGlobals.UPDATE:
084: TuiWizard.println(VAGlobals
085: .i18n("TuiInstallStep_Step5Up"));
086: break;
087: case VAGlobals.UNINSTALL:
088: TuiWizard.println(VAGlobals
089: .i18n("TuiInstallStep_Step2Un"));
090: break;
091: default:
092: TuiWizard.println(VAGlobals
093: .i18n("TuiInstallStep_StepN"));
094: break;
095: }
096:
097: TuiWizard.separator();
098: TuiWizard.println("");
099:
100: switch (VAGlobals.OPERATION) {
101: case VAGlobals.INSTALL:
102: TuiWizard.println(VAGlobals
103: .i18n("TuiInstallStep_InstallInProgress"));
104: break;
105: case VAGlobals.UPDATE:
106: TuiWizard.println(VAGlobals
107: .i18n("TuiInstallStep_UpdateInProgress"));
108: break;
109: case VAGlobals.UNINSTALL:
110: TuiWizard
111: .println(VAGlobals
112: .i18n("TuiInstallStep_UninstallationInProgress"));
113: break;
114: default:
115: TuiWizard.println("");
116: break;
117: }
118:
119: TuiWizard.println("");
120: } else {
121: TuiWizard.print("\033[06;00H");
122: TuiWizard.normal();
123: }
124:
125: // if(TuiWizard.ansi) TuiWizard.print("\033[K");
126:
127: String p = " " + progres_ + "% ";
128: TuiWizard.print(p.substring(p.length() - 5));
129:
130: int v = progres_ / 2;
131: for (int i = 0; i <= 50; i++) {
132: if (i <= v)
133: TuiWizard.print("*");
134: else if (first_ || !TuiWizard.ansi) {
135: if (i % 5 == 0)
136: TuiWizard.print("|");
137: else
138: TuiWizard.print("-");
139: }
140: }
141:
142: if (first_ || !TuiWizard.ansi) {
143: TuiWizard.println("");
144: for (int i = 8; i < 21; i++)
145: TuiWizard.println("");
146: } else
147: TuiWizard.print("\033[20;00H");
148:
149: TuiWizard.info();
150: if (TuiWizard.ansi)
151: TuiWizard.print("\033[K");
152: TuiWizard.println(status_);
153: if (TuiWizard.ansi)
154: TuiWizard.print("\033[K");
155: TuiWizard.println(detail_);
156:
157: if (first_ || !TuiWizard.ansi) {
158: TuiWizard.println("");
159: TuiWizard.separator();
160: }
161:
162: try {
163: Thread.currentThread().sleep(TuiWizard.ansi ? 50 : 250);
164: } catch (Exception ex) {
165: }
166:
167: first_ = false;
168: }
169:
170: public void details(String msg) {
171: int index = msg.lastIndexOf(System
172: .getProperty("file.separator"));
173: if (index > -1)
174: msg = msg.substring(index + 1);
175: detail_ = msg;
176: // TuiWizard.println(msg);
177: refresh();
178: }
179:
180: public void status(String msg) {
181: status_ = msg;
182: refresh();
183: // TuiWizard.println("\r"+msg);
184: }
185:
186: public void setProgression(int n) {
187: progres_ = n;
188: refresh();
189: // TuiWizard.print(""+n+"% ");
190: }
191:
192: public int getProgression() {
193: return progres_;
194: }
195: }
|