WMInstaller.Mod 43 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348
  1. MODULE WMInstaller; (** AUTHOR "staubesv"; PURPOSE "Graphical installer"; *)
  2. IMPORT
  3. KernelLog, Modules, Kernel, Streams, Strings, Texts, TextUtilities, Codecs,
  4. Disks, PartitionsLib, Installer,
  5. WMRectangles, WMWindowManager, WMGraphics, WMGraphicUtilities, WMComponents, WMStandardComponents, WMTextView, WMEditors,
  6. WMProgressComponents, WMPartitionsComponents, WMDialogs;
  7. CONST
  8. DefaultPackageFile = "InstallerPackages.XML";
  9. ImageLogo = "WMInstaller.tar://OberonLogoSmall.png";
  10. TitleText = "WMInstaller.tar://Title.Text";
  11. HelpText = "WMInstaller.tar://Help.Text";
  12. TextSelectPartition = "WMInstaller.tar://SelectPartition.Text";
  13. TextSelectPackages = "WMInstaller.tar://SelectPackages.Text";
  14. TextInstallSteps = "WMInstaller.tar://InstallSteps.Text";
  15. TextInstallLog = "WMInstaller.tar://InstallLog.Text";
  16. TextAdvancedOptions = "WMInstaller.tar://AdvancedOptions.Text";
  17. DefaultConfigFile = "WMInstaller.tar://DefaultConfig.Text"; (* MUST BE UTF-8 *)
  18. WindowTitle = "Installer";
  19. WindowWidth = 640;
  20. WindowHeight = 400;
  21. WindowMinWidth = 600;
  22. WindowMinHeight = 300;
  23. OberonColor = LONGINT(0D1616CAFH);
  24. UpperPanelHeight = 60;
  25. LowerPanelHeight = 60;
  26. ButtonPanelHeight = 20;
  27. ImageWidth = 150;
  28. PageSelectPartition = 0;
  29. PageSelectPackages = 1;
  30. PageShowSteps = 2;
  31. PageShowLog = 3;
  32. PageAdvancedOptions = 4;
  33. NofPages = 5;
  34. (* PackageSelector *)
  35. LineHeight = 20;
  36. MouseWheelMultiplier = LineHeight;
  37. TYPE
  38. (* Panel that can vertically scroll its content *)
  39. ScrollPanel = OBJECT(WMComponents.VisualComponent)
  40. VAR
  41. content : WMComponents.VisualComponent;
  42. scrollbar : WMStandardComponents.Scrollbar;
  43. scrollPanel : WMStandardComponents.Panel;
  44. PROCEDURE SetContent(content : WMComponents.VisualComponent);
  45. BEGIN
  46. ASSERT(content.alignment.Get() = WMComponents.AlignNone);
  47. IF (SELF.content # NIL) THEN scrollPanel.RemoveContent(SELF.content); END;
  48. scrollPanel.AddContent(content);
  49. SELF.content := content;
  50. END SetContent;
  51. PROCEDURE Resized*;
  52. BEGIN
  53. Resized^;
  54. IF (content # NIL) THEN
  55. CheckScrollbars;
  56. content.bounds.SetWidth(scrollPanel.bounds.GetWidth());
  57. END;
  58. END Resized;
  59. PROCEDURE CheckScrollbars;
  60. VAR availableHeight, neededHeight : LONGINT;
  61. BEGIN
  62. IF (content = NIL) THEN RETURN; END;
  63. availableHeight := scrollPanel.bounds.GetHeight();
  64. neededHeight := content.bounds.GetHeight();
  65. IF (availableHeight >= neededHeight) THEN
  66. content.bounds.SetTop(0);
  67. scrollbar.visible.Set(FALSE);
  68. ELSE
  69. scrollbar.min.Set(0);
  70. scrollbar.max.Set(neededHeight - availableHeight);
  71. scrollbar.visible.Set(TRUE);
  72. END;
  73. END CheckScrollbars;
  74. PROCEDURE ScrollbarChanged(sender, data : ANY);
  75. BEGIN
  76. IF (content # NIL) THEN content.bounds.SetTop(-scrollbar.pos.Get()); END;
  77. END ScrollbarChanged;
  78. PROCEDURE WheelMove*(dz : LONGINT);
  79. BEGIN
  80. IF (scrollbar.visible.Get()) THEN
  81. scrollbar.pos.Set(scrollbar.pos.Get() + dz * MouseWheelMultiplier);
  82. ScrollbarChanged(NIL, NIL);
  83. END;
  84. END WheelMove;
  85. PROCEDURE &Init*;
  86. BEGIN
  87. Init^;
  88. NEW(scrollbar); scrollbar.alignment.Set(WMComponents.AlignRight);
  89. scrollbar.vertical.Set(TRUE);
  90. scrollbar.onPositionChanged.Add(ScrollbarChanged);
  91. AddContent(scrollbar);
  92. NEW(scrollPanel); scrollPanel.alignment.Set(WMComponents.AlignClient);
  93. AddContent(scrollPanel);
  94. SetNameAsString(StrScrollPanel);
  95. END Init;
  96. END ScrollPanel;
  97. TYPE
  98. PackageSelector = OBJECT(WMComponents.VisualComponent)
  99. VAR
  100. packageList : Installer.PackageArray;
  101. scrollPanel : ScrollPanel;
  102. label : WMStandardComponents.Label;
  103. allBtn, noneBtn : WMStandardComponents.Button;
  104. PROCEDURE ClickHandler(sender, data : ANY);
  105. VAR checkbox : WMStandardComponents.Checkbox; msg : ARRAY 512 OF CHAR;i : LONGINT; install : BOOLEAN;
  106. BEGIN
  107. FOR i := 0 TO LEN(packageList)-1 DO
  108. checkbox := packageList[i].user (WMStandardComponents.Checkbox);
  109. IF (sender = checkbox) THEN
  110. install := (checkbox.state.Get() = WMStandardComponents.Checked);
  111. IF ~packageList[i].SetInstall(install, msg) THEN
  112. WMDialogs.Error(WindowTitle, msg);
  113. IF install THEN
  114. checkbox.state.Set(WMStandardComponents.Unchecked);
  115. ELSE
  116. checkbox.state.Set(WMStandardComponents.Checked);
  117. END;
  118. END;
  119. END;
  120. END;
  121. UpdateLabel;
  122. END ClickHandler;
  123. PROCEDURE GetTotalSize(VAR size, sizeOnDisk : LONGINT);
  124. VAR i : LONGINT;
  125. BEGIN
  126. size := 0; sizeOnDisk := 0;
  127. IF (packageList = NIL) THEN RETURN; END;
  128. FOR i := 0 TO LEN(packageList)-1 DO
  129. IF (packageList[i].install) THEN
  130. size := size + packageList[i].size;
  131. sizeOnDisk := sizeOnDisk + packageList[i].sizeOnDisk;
  132. END;
  133. END;
  134. size := (size DIV 1024); IF (size MOD 1024 # 0) THEN INC(size); END;
  135. sizeOnDisk := (sizeOnDisk DIV 1024); IF (sizeOnDisk MOD 1024 # 0) THEN INC(sizeOnDisk); END;
  136. END GetTotalSize;
  137. PROCEDURE UpdateLabel;
  138. VAR caption : ARRAY 128 OF CHAR; nbr : ARRAY 16 OF CHAR; size, sizeOnDisk : LONGINT;
  139. BEGIN
  140. caption := "Total Size: ";
  141. GetTotalSize(size, sizeOnDisk);
  142. Strings.IntToStr(size, nbr);
  143. Strings.Append(caption, nbr); Strings.Append(caption, " KB");
  144. Strings.IntToStr(sizeOnDisk, nbr);
  145. Strings.Append(caption, " (Size on disk: "); Strings.Append(caption, nbr); Strings.Append(caption, " KB)");
  146. label.caption.SetAOC(caption);
  147. END UpdateLabel;
  148. PROCEDURE GetSizeString(package : Installer.Package; VAR caption : ARRAY OF CHAR);
  149. BEGIN
  150. IF (package.file # NIL) THEN
  151. Strings.IntToStr((package.size DIV 1024) + 1, caption);
  152. Strings.Append(caption, " KB");
  153. ELSE
  154. caption := "n/a";
  155. END;
  156. END GetSizeString;
  157. PROCEDURE CreatePackagePanel(package : Installer.Package) : WMStandardComponents.Panel;
  158. VAR
  159. panel : WMStandardComponents.Panel; l : WMStandardComponents.Label; checkbox : WMStandardComponents.Checkbox; caption : ARRAY 64 OF CHAR;
  160. BEGIN
  161. NEW(panel); panel.alignment.Set(WMComponents.AlignTop);
  162. panel.bounds.SetHeight(LineHeight);
  163. NEW(checkbox); checkbox.alignment.Set(WMComponents.AlignLeft);
  164. checkbox.bearing.Set(WMRectangles.MakeRect(5, 5, 10, 5));
  165. checkbox.bounds.SetWidth(20);
  166. checkbox.onClick.Add(ClickHandler);
  167. IF package.install THEN checkbox.state.Set(WMStandardComponents.Checked);
  168. ELSE checkbox.state.Set(WMStandardComponents.Unchecked);
  169. END;
  170. panel.AddContent(checkbox);
  171. package.user := checkbox;
  172. NEW(l); l.alignment.Set(WMComponents.AlignRight);
  173. l.bounds.SetWidth(60);
  174. GetSizeString(package, caption); l.caption.SetAOC(caption);
  175. panel.AddContent(l);
  176. NEW(l); l.alignment.Set(WMComponents.AlignLeft);
  177. l.bounds.SetWidth(140);
  178. l.bearing.Set(WMRectangles.MakeRect(5, 0, 0, 0));
  179. l.caption.Set(package.filename);
  180. panel.AddContent(l);
  181. NEW(l); l.alignment.Set(WMComponents.AlignClient);
  182. l.caption.Set(package.description);
  183. panel.AddContent(l);
  184. RETURN panel;
  185. END CreatePackagePanel;
  186. PROCEDURE SetPackages(packages : Installer.Packages);
  187. VAR packagePanel : WMStandardComponents.Panel; panel : WMStandardComponents.Panel; height, i : LONGINT;
  188. BEGIN
  189. ASSERT(packages # NIL);
  190. height := 0;
  191. NEW(panel); panel.alignment.Set(WMComponents.AlignNone);
  192. packageList := packages.GetPackages();
  193. IF packageList # NIL THEN
  194. FOR i := 0 TO LEN(packageList)-1 DO
  195. packagePanel := CreatePackagePanel(packageList[i]);
  196. height := height + packagePanel.bounds.GetHeight();
  197. panel.AddContent(packagePanel);
  198. END;
  199. ELSE
  200. END;
  201. panel.bounds.SetHeight(height);
  202. panel.bounds.SetWidth(bounds.GetWidth());
  203. scrollPanel.SetContent(panel);
  204. UpdateLabel;
  205. END SetPackages;
  206. PROCEDURE HandleButtons(sender, data : ANY);
  207. VAR newState, i : LONGINT; checkbox : WMStandardComponents.Checkbox; ignore : ARRAY 512 OF CHAR; install : BOOLEAN;
  208. BEGIN
  209. IF (sender = allBtn) THEN
  210. newState := WMStandardComponents.Checked;
  211. ELSE (* sender = allBtn *)
  212. newState := WMStandardComponents.Unchecked;
  213. END;
  214. FOR i := 0 TO LEN(packageList)-1 DO
  215. checkbox := packageList[i].user (WMStandardComponents.Checkbox);
  216. install := (newState = WMStandardComponents.Checked);
  217. IF packageList[i].SetInstall(install, ignore) THEN
  218. checkbox.state.Set(newState);
  219. END;
  220. END;
  221. UpdateLabel;
  222. END HandleButtons;
  223. PROCEDURE &New*;
  224. VAR panel : BorderPanel;
  225. BEGIN
  226. Init;
  227. NEW(panel); panel.alignment.Set(WMComponents.AlignBottom);
  228. panel.bounds.SetHeight(LineHeight); panel.fillColor.Set(WMGraphics.White);
  229. AddContent(panel);
  230. NEW(noneBtn); noneBtn.alignment.Set(WMComponents.AlignRight);
  231. noneBtn.caption.SetAOC("None");
  232. noneBtn.onClick.Add(HandleButtons);
  233. panel.AddContent(noneBtn);
  234. NEW(allBtn); allBtn.alignment.Set(WMComponents.AlignRight);
  235. allBtn.caption.SetAOC("All");
  236. allBtn.onClick.Add(HandleButtons);
  237. panel.AddContent(allBtn);
  238. NEW(label); label.alignment.Set(WMComponents.AlignClient);
  239. label.bearing.Set(WMRectangles.MakeRect(5, 0, 0, 0));
  240. label.fillColor.Set(WMGraphics.White);
  241. panel.AddContent(label);
  242. NEW(scrollPanel); scrollPanel.alignment.Set(WMComponents.AlignClient);
  243. AddContent(scrollPanel);
  244. SetNameAsString(StrPackageSelector);
  245. END New;
  246. END PackageSelector;
  247. TYPE
  248. ConfigurationSettings = OBJECT(WMComponents.VisualComponent)
  249. VAR
  250. steps : ARRAY Installer.NofSteps OF WMStandardComponents.Checkbox;
  251. mbrFileEdit, bootLoaderEdit, bootFileEdit, bootFile2Edit,
  252. bootManMbrEdit, bootManRestEdit, prefixEdit : WMEditors.Editor;
  253. config : Installer.Configuration;
  254. scrollPanel : ScrollPanel;
  255. panel : WMStandardComponents.Panel;
  256. PROCEDURE CreateConfigPanel() : WMStandardComponents.Panel;
  257. VAR panel, line : WMStandardComponents.Panel; lineNbr, height : LONGINT;
  258. BEGIN
  259. NEW(panel); panel.alignment.Set(WMComponents.AlignNone);
  260. height := 0;
  261. FOR lineNbr := 1 TO Installer.NofSteps-1 DO
  262. line := CreateLine(lineNbr);
  263. panel.AddContent(line);
  264. height := height + line.bounds.GetHeight();
  265. END;
  266. panel.bounds.SetHeight(height);
  267. RETURN panel;
  268. END CreateConfigPanel;
  269. PROCEDURE SetConfiguration(config : Installer.Configuration);
  270. BEGIN
  271. ASSERT(config # NIL);
  272. SELF.config := config.Clone();
  273. panel := CreateConfigPanel();
  274. panel.bounds.SetWidth(scrollPanel.bounds.GetWidth());
  275. scrollPanel.SetContent(panel);
  276. END SetConfiguration;
  277. PROCEDURE GetConfiguration() : Installer.Configuration;
  278. BEGIN
  279. RETURN config;
  280. END GetConfiguration;
  281. PROCEDURE IsValidConfiguration(w : Streams.Writer) : BOOLEAN;
  282. BEGIN
  283. ASSERT(w # NIL);
  284. RETURN config.CheckConfiguration(w);
  285. END IsValidConfiguration;
  286. PROCEDURE CreateLine(lineNbr : LONGINT) : WMStandardComponents.Panel;
  287. VAR panel : WMStandardComponents.Panel;
  288. BEGIN
  289. NEW(panel); panel.alignment.Set(WMComponents.AlignTop);
  290. panel.bounds.SetHeight(LineHeight);
  291. NEW(steps[lineNbr]); steps[lineNbr].alignment.Set(WMComponents.AlignLeft);
  292. steps[lineNbr].bounds.SetWidth(LineHeight);
  293. steps[lineNbr].bearing.Set(WMRectangles.MakeRect(5, 5, 10, 5));
  294. steps[lineNbr].onClick.Add(ClickHandler);
  295. panel.AddContent(steps[lineNbr]);
  296. IF config.DoStep(lineNbr) THEN
  297. steps[lineNbr].state.Set(WMStandardComponents.Checked);
  298. ELSE
  299. steps[lineNbr].state.Set(WMStandardComponents.Unchecked);
  300. END;
  301. CASE lineNbr OF
  302. |Installer.WriteMBR:
  303. panel.AddContent(NewLabel("WriteMBR", 100));
  304. panel.AddContent(NewLabel("MBR filename:", 90)); NewEditor(mbrFileEdit, config.mbrFile, 0); panel.AddContent(mbrFileEdit);
  305. |Installer.CreatePartition:
  306. panel.AddContent(NewLabel("CreatePartition", 100));
  307. panel.AddContent(NewLabel("Create a new partition of type 76?", 0));
  308. |Installer.ChangeType:
  309. panel.AddContent(NewLabel("ChangeType", 100));
  310. panel.AddContent(NewLabel("Changes the partition type to 76 (AosFS)", 0));
  311. |Installer.Activate:
  312. panel.AddContent(NewLabel("Activate", 100));
  313. panel.AddContent(NewLabel("Set the active flag of the partition?", 0));
  314. |Installer.Format:
  315. panel.AddContent(NewLabel("Format", 100));
  316. panel.AddContent(NewLabel("Boot Loader:", 90)); NewEditor(bootLoaderEdit, config.bootloader, 100); panel.AddContent(bootLoaderEdit);
  317. panel.AddContent(NewLabel(" Boot File:", 60)); NewEditor(bootFileEdit, config.bootfile, 0); panel.AddContent(bootFileEdit);
  318. |Installer.UpdateBootfile:
  319. panel.AddContent(NewLabel("UpdateBootFile", 100));
  320. panel.AddContent(NewLabel("Boot File:", 90)); NewEditor(bootFile2Edit, config.bootfile, 0); panel.AddContent(bootFile2Edit);
  321. |Installer.SetConfig:
  322. panel.AddContent(NewLabel("SetConfig", 100));
  323. |Installer.InstallBootManager:
  324. panel.AddContent(NewLabel("BootManager", 100));
  325. panel.AddContent(NewLabel("Boot MBR: ", 90)); NewEditor(bootManMbrEdit, config.bootManMBR, 100); panel.AddContent(bootManMbrEdit);
  326. panel.AddContent(NewLabel("Boot Manager: ", 90)); NewEditor(bootManRestEdit, config.bootManRest, 0); panel.AddContent(bootManRestEdit);
  327. |Installer.Mount:
  328. panel.AddContent(NewLabel("Mount", 100));
  329. panel.AddContent(NewLabel("Prefix:", 90)); NewEditor(prefixEdit, config.mountPrefix, 0); panel.AddContent(prefixEdit);
  330. |Installer.InstallPackages:
  331. panel.AddContent(NewLabel("InstallPackages", 100));
  332. panel.AddContent(NewLabel("Should packages be installed?", 0));
  333. |Installer.Unmount:
  334. panel.AddContent(NewLabel("Unmount", 100));
  335. panel.AddContent(NewLabel("Unmount partition after installation", 0));
  336. ELSE
  337. END;
  338. RETURN panel;
  339. END CreateLine;
  340. PROCEDURE ClickHandler(sender, data : ANY);
  341. VAR checkbox : WMStandardComponents.Checkbox; msg : ARRAY 512 OF CHAR; i : LONGINT; doStep : BOOLEAN;
  342. BEGIN
  343. i := 0;
  344. LOOP
  345. IF (i >= LEN(steps)) OR (sender = steps[i]) THEN EXIT; END;
  346. INC(i);
  347. END;
  348. IF (i < LEN(steps)) THEN
  349. checkbox := sender (WMStandardComponents.Checkbox);
  350. doStep := (checkbox.state.Get() = WMStandardComponents.Checked);
  351. IF ~config.SetInstallStep(i, doStep, msg) THEN
  352. WMDialogs.Error(WindowTitle, msg);
  353. IF doStep THEN
  354. checkbox.state.Set(WMStandardComponents.Unchecked);
  355. ELSE
  356. checkbox.state.Set(WMStandardComponents.Checked);
  357. END;
  358. END;
  359. END;
  360. END ClickHandler;
  361. PROCEDURE ApplyConfiguration;
  362. VAR step : LONGINT;
  363. BEGIN
  364. ASSERT(config # NIL);
  365. FOR step := 1 TO Installer.NofSteps-1 DO
  366. CASE step OF
  367. |Installer.WriteMBR:
  368. mbrFileEdit.GetAsString(config.mbrFile);
  369. |Installer.CreatePartition:
  370. |Installer.ChangeType:
  371. |Installer.Activate:
  372. |Installer.Format:
  373. bootLoaderEdit.GetAsString(config.bootloader);
  374. bootFileEdit.GetAsString(config.bootfile);
  375. |Installer.UpdateBootfile:
  376. bootFileEdit.GetAsString(config.bootfile);
  377. |Installer.SetConfig:
  378. |Installer.InstallBootManager:
  379. bootManMbrEdit.GetAsString(config.bootManMBR);
  380. bootManRestEdit.GetAsString(config.bootManRest);
  381. |Installer.Mount:
  382. prefixEdit.GetAsString(config.mountPrefix);
  383. |Installer.InstallPackages:
  384. |Installer.Unmount:
  385. ELSE
  386. END;
  387. END;
  388. END ApplyConfiguration;
  389. PROCEDURE NewLabel(CONST caption : ARRAY OF CHAR; width : LONGINT) : WMStandardComponents.Label;
  390. VAR label : WMStandardComponents.Label;
  391. BEGIN
  392. NEW(label);
  393. IF (width > 0) THEN
  394. label.alignment.Set(WMComponents.AlignLeft);
  395. label.bounds.SetWidth(width);
  396. ELSE
  397. label.alignment.Set(WMComponents.AlignClient);
  398. END;
  399. label.caption.SetAOC(caption);
  400. RETURN label;
  401. END NewLabel;
  402. PROCEDURE NewEditor(VAR editor : WMEditors.Editor; CONST caption : ARRAY OF CHAR; width : LONGINT);
  403. BEGIN
  404. NEW(editor);
  405. IF (width > 0) THEN
  406. editor.alignment.Set(WMComponents.AlignLeft);
  407. editor.bounds.SetWidth(width);
  408. ELSE
  409. editor.alignment.Set(WMComponents.AlignClient);
  410. END;
  411. editor.SetAsString(caption);
  412. editor.multiLine.Set(FALSE);
  413. editor.tv.textAlignV.Set(WMGraphics.AlignCenter);
  414. editor.tv.showBorder.Set(TRUE);
  415. END NewEditor;
  416. PROCEDURE &Init*;
  417. BEGIN
  418. Init^;
  419. SetNameAsString(StrConfigurationSettings);
  420. config := NIL;
  421. NEW(scrollPanel); scrollPanel.alignment.Set(WMComponents.AlignClient);
  422. AddContent(scrollPanel);
  423. END Init;
  424. END ConfigurationSettings;
  425. TYPE
  426. InstallerBgPanel = OBJECT(WMComponents.VisualComponent)
  427. PROCEDURE DrawBackground*(canvas : WMGraphics.Canvas);
  428. VAR color : LONGINT; rect : WMRectangles.Rectangle;
  429. BEGIN
  430. DrawBackground^(canvas); (* fills background with fillColor *)
  431. rect := GetClientRect();
  432. color := OberonColor;
  433. rect.l := rect.l + 0;
  434. rect.r := rect.r - 0;
  435. rect.b := rect.b + 0;
  436. rect.t := rect.b - ButtonPanelHeight - LowerPanelHeight - 40;
  437. IF color # 0 THEN canvas.Fill(rect, color, WMGraphics.ModeSrcOverDst) END;
  438. END DrawBackground;
  439. PROCEDURE &Init*;
  440. BEGIN
  441. Init^;
  442. SetNameAsString(StrInstallerBgPanel);
  443. END Init;
  444. END InstallerBgPanel;
  445. BorderPanel = OBJECT(WMStandardComponents.Panel)
  446. PROCEDURE DrawForeground*(canvas : WMGraphics.Canvas);
  447. BEGIN
  448. DrawForeground^(canvas);
  449. WMGraphicUtilities.DrawBevel(canvas, GetClientRect(), 1, TRUE, LONGINT(0808080FFH), WMGraphics.ModeCopy);
  450. END DrawForeground;
  451. PROCEDURE &Init*;
  452. BEGIN
  453. Init^;
  454. SetNameAsString(StrBorderPanel);
  455. END Init;
  456. END BorderPanel;
  457. TYPE
  458. Window = OBJECT(WMComponents.FormWindow)
  459. VAR
  460. main : WMComponents.VisualComponent;
  461. buttonPanel : WMStandardComponents.Panel;
  462. upperText, lowerText : Texts.Text;
  463. logText, stepsText : Texts.Text;
  464. imagePanel : WMStandardComponents.ImagePanel;
  465. showDetailsBtn : WMStandardComponents.Button;
  466. showDetails : BOOLEAN;
  467. titleLabel : WMStandardComponents.Label;
  468. helpBtn, quickInstallBtn, backBtn, nextBtn : WMStandardComponents.Button;
  469. w, stepsW : TextUtilities.TextWriter;
  470. selectionLabel : WMStandardComponents.Label;
  471. progressBar : WMProgressComponents.ProgressBar;
  472. progressPoller : PollProgress;
  473. partitionSelector : WMPartitionsComponents.PartitionSelector;
  474. packageSelector : PackageSelector;
  475. configurationSettings : ConfigurationSettings;
  476. pages : ARRAY NofPages OF WMComponents.VisualComponent;
  477. currentPage : LONGINT;
  478. packages : Installer.Packages;
  479. installer : Installer.Installer;
  480. configuration : Installer.Configuration;
  481. selection, lockedSelection : WMPartitionsComponents.Selection;
  482. opened : BOOLEAN;
  483. PROCEDURE Resizing*(VAR width, height : LONGINT);
  484. BEGIN
  485. IF width < WindowMinWidth THEN width := WindowMinWidth; END;
  486. IF height < WindowMinHeight THEN height := WindowMinHeight; END;
  487. END Resizing;
  488. PROCEDURE ShowHelpText;
  489. VAR text : Texts.Text;
  490. BEGIN
  491. IF (helpWindow = NIL) THEN
  492. NEW(text);
  493. LoadText(text, HelpText);
  494. IF (text # NIL) THEN
  495. NEW(helpWindow, text);
  496. ELSE
  497. WMDialogs.Error(WindowTitle, "Could not load help text");
  498. END;
  499. END;
  500. END ShowHelpText;
  501. PROCEDURE GetDiskPartString(selection : WMPartitionsComponents.Selection) : Strings.String;
  502. VAR diskPartString : Strings.String; string, nbr : ARRAY 32 OF CHAR;
  503. BEGIN
  504. IF IsValidSelection(selection) THEN
  505. string := ""; Strings.Append(string, selection.disk.device.name);
  506. Strings.IntToStr(selection.partition, nbr);
  507. Strings.Append(string, "#"); Strings.Append(string, nbr);
  508. diskPartString := Strings.NewString(string);
  509. ELSE
  510. diskPartString := Strings.NewString("INVALID");
  511. END;
  512. ASSERT(diskPartString # NIL);
  513. RETURN diskPartString;
  514. END GetDiskPartString;
  515. PROCEDURE ReallyDoInstallation(selection : WMPartitionsComponents.Selection) : BOOLEAN;
  516. VAR res : WORD; string : ARRAY 256 OF CHAR; diskPartString : Strings.String;
  517. BEGIN
  518. ASSERT(IsValidSelection(selection));
  519. string := "The installation will delete all content on partition ";
  520. diskPartString := GetDiskPartString(selection);
  521. Strings.Append(string, diskPartString^); Strings.Append(string, ". Do you want to start the installation?");
  522. res := WMDialogs.Confirmation(WindowTitle, string);
  523. RETURN res = WMDialogs.ResYes;
  524. END ReallyDoInstallation;
  525. PROCEDURE HandleButtons(sender, data : ANY);
  526. VAR caption : Strings.String; errorWriter : Streams.StringWriter; errorString : ARRAY 1024 OF CHAR;
  527. BEGIN
  528. IF sender = showDetailsBtn THEN
  529. showDetails := ~showDetails;
  530. partitionSelector.showDetails.Set(showDetails);
  531. ELSIF sender = helpBtn THEN
  532. ShowHelpText;
  533. ELSIF sender = quickInstallBtn THEN
  534. IF (currentPage = PageSelectPartition) & QuickInstall() THEN
  535. SelectPage(PageShowLog);
  536. ELSIF (currentPage = PageShowSteps) THEN
  537. configurationSettings.SetConfiguration(configuration);
  538. SelectPage(PageAdvancedOptions);
  539. END;
  540. ELSIF sender = nextBtn THEN
  541. CASE currentPage OF
  542. |PageSelectPartition: (* next *)
  543. IF GetSelection(selection) THEN
  544. IF LockPartition(selection) THEN
  545. IF LoadPackages(DefaultPackageFile, packages) THEN
  546. packageSelector.SetPackages(packages);
  547. SelectPage(PageSelectPackages);
  548. END;
  549. END;
  550. END;
  551. |PageSelectPackages: (* next *)
  552. ClearText(stepsText);
  553. IF GetConfiguration(selection, packages, configuration) THEN
  554. configuration.ToStream(stepsW);
  555. SelectPage(PageShowSteps);
  556. END;
  557. |PageShowSteps: (* next *)
  558. ClearText(logText);
  559. IF CheckConfiguration(configuration) THEN
  560. SelectPage(PageShowLog);
  561. StartInstaller(selection, configuration);
  562. END;
  563. |PageShowLog: (* abort or done *)
  564. caption := nextBtn.caption.Get();
  565. IF (caption # NIL) & (caption^ = "Done") THEN
  566. Close;
  567. ELSE
  568. StopInstaller;
  569. END;
  570. |PageAdvancedOptions: (*ok *)
  571. configurationSettings.ApplyConfiguration;
  572. NEW(errorWriter, LEN(errorString));
  573. IF ~configurationSettings.IsValidConfiguration(errorWriter) THEN
  574. errorWriter.Get(errorString);
  575. WMDialogs.Error(WindowTitle, errorString);
  576. ELSE
  577. configuration := configurationSettings.GetConfiguration();
  578. ClearText(stepsText);
  579. configuration.ToStream(stepsW);
  580. SelectPage(PageShowSteps);
  581. END;
  582. ELSE
  583. END;
  584. ELSIF sender = backBtn THEN
  585. CASE currentPage OF
  586. |PageSelectPartition: (* btn2 not visible *)
  587. |PageSelectPackages: (* back*)
  588. SelectPage(PageSelectPartition);
  589. UnlockPartition(lockedSelection);
  590. |PageShowSteps: (* back *)
  591. SelectPage(PageSelectPackages);
  592. |PageShowLog: (* back, only visible after installer has been aborted or has finished *)
  593. installer := NIL;
  594. packages := NIL;
  595. configuration := NIL;
  596. IF (progressPoller # NIL) THEN progressPoller.Close; progressPoller := NIL; END;
  597. partitionSelector.ClearSelection;
  598. SelectPage(PageSelectPartition);
  599. |PageAdvancedOptions: (* abort *)
  600. SelectPage(PageShowSteps);
  601. ELSE
  602. END;
  603. END;
  604. END HandleButtons;
  605. PROCEDURE HandleSelection(sender, data : ANY);
  606. VAR selection : PartitionsLib.Selection; caption : ARRAY 128 OF CHAR; nbr : ARRAY 4 OF CHAR;
  607. BEGIN
  608. IF (data # NIL) & (data IS WMPartitionsComponents.SelectionWrapper) THEN
  609. selection := data(WMPartitionsComponents.SelectionWrapper).selection;
  610. caption := " Selection: ";
  611. IF (selection.disk.device # NIL) THEN
  612. Strings.Append(caption, selection.disk.device.name);
  613. Strings.Append(caption, "#");
  614. Strings.IntToStr(selection.partition, nbr); Strings.Append(caption, nbr);
  615. ELSE
  616. caption := "None";
  617. END;
  618. selectionLabel.caption.SetAOC(caption);
  619. END;
  620. END HandleSelection;
  621. (* Called by the ProgressPoller when the install operation has been aborted or is finished *)
  622. PROCEDURE HandleProgressNotification(aborted : BOOLEAN);
  623. BEGIN
  624. IF (currentPage = PageShowLog) THEN
  625. backBtn.visible.Set(TRUE);
  626. nextBtn.caption.SetAOC("Done");
  627. END;
  628. END HandleProgressNotification;
  629. PROCEDURE LockPartition(selection : WMPartitionsComponents.Selection) : BOOLEAN;
  630. BEGIN
  631. IF IsValidSelection(selection) THEN
  632. lockedSelection := selection;
  633. RETURN PartitionsLib.diskModel.AcquirePartition(selection.disk, selection.partition, PartitionsLib.WriterLock);
  634. END;
  635. RETURN FALSE;
  636. END LockPartition;
  637. PROCEDURE UnlockPartition(selection : WMPartitionsComponents.Selection);
  638. BEGIN
  639. IF IsValidSelection(selection) THEN
  640. PartitionsLib.diskModel.ReleasePartition(selection.disk, selection.partition);
  641. END;
  642. END UnlockPartition;
  643. PROCEDURE OpenDevice(device : Disks.Device) : BOOLEAN;
  644. VAR res : WORD;
  645. BEGIN
  646. IF (device # NIL) THEN
  647. device.Open(res);
  648. IF (res = Disks.Ok) THEN
  649. opened := TRUE;
  650. RETURN TRUE;
  651. END;
  652. END;
  653. RETURN FALSE;
  654. END OpenDevice;
  655. PROCEDURE CloseDevice(device : Disks.Device);
  656. VAR ignore : WORD;
  657. BEGIN
  658. IF opened & (device # NIL) THEN
  659. device.Close(ignore);
  660. END;
  661. END CloseDevice;
  662. PROCEDURE GetConfiguration(selection : WMPartitionsComponents.Selection; packages : Installer.Packages; VAR configuration : Installer.Configuration) : BOOLEAN;
  663. VAR reader : Streams.Reader; res : WORD; msg : ARRAY 128 OF CHAR;
  664. BEGIN
  665. IF IsValidSelection(selection) THEN
  666. NEW(configuration, selection.disk, selection.partition);
  667. configuration.SetPackages(packages);
  668. reader := Codecs.OpenInputStream(DefaultConfigFile);
  669. IF (reader # NIL) THEN
  670. configuration.configTable.LoadFromStream(reader, msg, res);
  671. IF (res = PartitionsLib.Ok) THEN
  672. RETURN TRUE;
  673. END;
  674. ELSE msg := "Could not open configuration file";
  675. END;
  676. ELSE msg := "Select partition not valid";
  677. END;
  678. configuration := NIL;
  679. WMDialogs.Error(WindowTitle, msg);
  680. RETURN FALSE;
  681. END GetConfiguration;
  682. PROCEDURE CheckConfiguration(configuration : Installer.Configuration) : BOOLEAN;
  683. VAR errorWriter : Streams.StringWriter; errorString : ARRAY 2048 OF CHAR;
  684. BEGIN
  685. NEW(errorWriter, LEN(errorString));
  686. IF configuration.CheckConfiguration(errorWriter) THEN
  687. RETURN TRUE;
  688. ELSE
  689. configuration := NIL;
  690. errorWriter.Get(errorString);
  691. WMDialogs.Error(WindowTitle, errorString);
  692. END;
  693. RETURN FALSE;
  694. END CheckConfiguration;
  695. PROCEDURE GetSelection(VAR selection : WMPartitionsComponents.Selection) : BOOLEAN;
  696. BEGIN
  697. selection := partitionSelector.GetSelection();
  698. IF IsValidSelection(selection) THEN
  699. RETURN TRUE;
  700. ELSE
  701. WMDialogs.Error(WindowTitle, "Selected partition is not valid");
  702. END;
  703. RETURN FALSE;
  704. END GetSelection;
  705. PROCEDURE LoadPackages(CONST filename : ARRAY OF CHAR; VAR packages : Installer.Packages) : BOOLEAN;
  706. VAR errorWriter : Streams.StringWriter; errorString : ARRAY 2048 OF CHAR;
  707. BEGIN
  708. NEW(packages); NEW(errorWriter, LEN(errorString));
  709. IF packages.OpenPackages(filename, errorWriter) THEN
  710. packages.GetPackageSizes();
  711. RETURN TRUE;
  712. END;
  713. errorWriter.Get(errorString);
  714. WMDialogs.Error(WindowTitle, errorString);
  715. RETURN FALSE;
  716. END LoadPackages;
  717. PROCEDURE IsValidSelection(selection : WMPartitionsComponents.Selection) : BOOLEAN;
  718. BEGIN
  719. RETURN (selection.disk.device # NIL) & (selection.partition > 0);
  720. END IsValidSelection;
  721. PROCEDURE StartInstaller(selection : WMPartitionsComponents.Selection; configuration : Installer.Configuration);
  722. BEGIN
  723. UnlockPartition(lockedSelection); (* installer operation will lock it again *)
  724. NEW(installer, selection.disk, selection.partition, NIL);
  725. installer.SetParameters(configuration);
  726. installer.SetInstallLog(w);
  727. installer.SetStart;
  728. IF (progressPoller # NIL) THEN progressPoller.Close; END;
  729. NEW(progressPoller, installer, progressBar);
  730. progressPoller.SetNotifyProc(HandleProgressNotification);
  731. END StartInstaller;
  732. PROCEDURE StopInstaller;
  733. BEGIN
  734. IF (installer # NIL) THEN installer.Abort; installer := NIL; configuration := NIL; END;
  735. END StopInstaller;
  736. PROCEDURE QuickInstall() : BOOLEAN;
  737. VAR
  738. selection : WMPartitionsComponents.Selection; configuration : Installer.Configuration;
  739. packages : Installer.Packages;
  740. errorString : ARRAY 2048 OF CHAR; errorWriter : Streams.StringWriter;
  741. BEGIN
  742. IF (installer = NIL) THEN
  743. IF GetSelection(selection) THEN
  744. IF LoadPackages(DefaultPackageFile, packages) THEN
  745. IF GetConfiguration(selection, packages, configuration) THEN
  746. NEW(errorWriter, LEN(errorString));
  747. IF configuration.CheckConfiguration(errorWriter) THEN
  748. IF ReallyDoInstallation(selection) THEN
  749. StartInstaller(selection, configuration);
  750. RETURN TRUE;
  751. END;
  752. ELSE
  753. configuration := NIL;
  754. errorWriter.Get(errorString);
  755. WMDialogs.Error(WindowTitle, errorString);
  756. END;
  757. END;
  758. END;
  759. END;
  760. END;
  761. RETURN FALSE;
  762. END QuickInstall;
  763. PROCEDURE SelectPage(pageNr : LONGINT);
  764. BEGIN
  765. ASSERT((pageNr >= 0) & (pageNr < LEN(pages)));
  766. DisableUpdate;
  767. IF (currentPage >= 0) THEN main.RemoveContent(pages[currentPage]); END;
  768. main.AddContent(pages[pageNr]);
  769. currentPage := pageNr;
  770. CASE pageNr OF
  771. |PageSelectPartition:
  772. titleLabel.caption.SetAOC("Select Partition");
  773. quickInstallBtn.caption.SetAOC("QuickInstall"); quickInstallBtn.visible.Set(TRUE);
  774. nextBtn.caption.SetAOC("Next"); nextBtn.visible.Set(TRUE);
  775. backBtn.visible.Set(FALSE);
  776. LoadText(lowerText, TextSelectPartition);
  777. |PageSelectPackages:
  778. titleLabel.caption.SetAOC("Select Packages");
  779. quickInstallBtn.visible.Set(FALSE);
  780. nextBtn.caption.SetAOC("Next"); nextBtn.visible.Set(TRUE);
  781. backBtn.caption.SetAOC("Back"); backBtn.visible.Set(TRUE);
  782. LoadText(lowerText, TextSelectPackages);
  783. |PageShowSteps:
  784. titleLabel.caption.SetAOC("Installation Steps");
  785. quickInstallBtn.caption.SetAOC("Advanced"); quickInstallBtn.visible.Set(TRUE);
  786. nextBtn.caption.SetAOC("Next"); nextBtn.visible.Set(TRUE);
  787. backBtn.caption.SetAOC("Back"); backBtn.visible.Set(TRUE);
  788. LoadText(lowerText, TextInstallSteps);
  789. |PageShowLog:
  790. titleLabel.caption.SetAOC("Installation Log");
  791. quickInstallBtn.visible.Set(FALSE);
  792. nextBtn.caption.SetAOC("Abort"); nextBtn.visible.Set(TRUE);
  793. backBtn.caption.SetAOC("Back"); backBtn.visible.Set(FALSE);
  794. LoadText(lowerText, TextInstallLog);
  795. |PageAdvancedOptions:
  796. titleLabel.caption.SetAOC("Advanced Options");
  797. quickInstallBtn.visible.Set(FALSE);
  798. nextBtn.caption.SetAOC("Ok"); nextBtn.visible.Set(TRUE);
  799. backBtn.caption.SetAOC("Abort"); backBtn.visible.Set(TRUE);
  800. LoadText(lowerText, TextAdvancedOptions);
  801. ELSE
  802. END;
  803. main.Reset(SELF, NIL);
  804. main.AlignSubComponents;
  805. EnableUpdate;
  806. main.Invalidate;
  807. END SelectPage;
  808. PROCEDURE ClearText(text : Texts.Text);
  809. BEGIN
  810. text.AcquireWrite;
  811. text.Delete(0, text.GetLength());
  812. text.ReleaseWrite;
  813. END ClearText;
  814. PROCEDURE LoadText(text : Texts.Text; CONST filename : ARRAY OF CHAR);
  815. VAR newText : Texts.Text;
  816. BEGIN
  817. ClearText(text);
  818. LoadOberonText(filename, newText);
  819. IF (newText # NIL) THEN
  820. newText.AcquireRead;
  821. text.AcquireWrite;
  822. text.CopyFromText(newText, 0, newText.GetLength(), 0);
  823. text.ReleaseWrite;
  824. newText.ReleaseRead;
  825. END;
  826. END LoadText;
  827. PROCEDURE CreatePageSelectPackages() : WMComponents.VisualComponent;
  828. VAR panel : BorderPanel;
  829. BEGIN
  830. NEW(panel); panel.alignment.Set(WMComponents.AlignClient);
  831. panel.bearing.Set(WMRectangles.MakeRect(20, 0, 20, 0));
  832. NEW(packageSelector); packageSelector.alignment.Set(WMComponents.AlignClient);
  833. panel.AddContent(packageSelector);
  834. RETURN panel;
  835. END CreatePageSelectPackages;
  836. PROCEDURE CreatePageAdvancedOptions() : WMComponents.VisualComponent;
  837. VAR panel : BorderPanel;
  838. BEGIN
  839. NEW(panel); panel.alignment.Set(WMComponents.AlignClient);
  840. panel.bearing.Set(WMRectangles.MakeRect(20, 0, 20, 0));
  841. NEW(configurationSettings); configurationSettings.alignment.Set(WMComponents.AlignClient);
  842. panel.AddContent(configurationSettings);
  843. RETURN panel;
  844. END CreatePageAdvancedOptions;
  845. PROCEDURE CreatePageShowSteps() : WMComponents.VisualComponent;
  846. VAR panel : WMStandardComponents.Panel; textView : WMTextView.TextView;
  847. BEGIN
  848. NEW(panel); panel.alignment.Set(WMComponents.AlignClient);
  849. panel.bearing.Set(WMRectangles.MakeRect(20, 0, 20, 0));
  850. NEW(textView); textView.alignment.Set(WMComponents.AlignClient);
  851. textView.isMultiLine.Set(TRUE); textView.showBorder.Set(TRUE);
  852. textView.defaultTextColor.Set(WMGraphics.Black);
  853. textView.alwaysShowCursor.Set(FALSE);
  854. NEW(stepsText); NEW(stepsW, stepsText);
  855. textView.SetText(stepsText);
  856. panel.AddContent(textView);
  857. RETURN panel;
  858. END CreatePageShowSteps;
  859. PROCEDURE CreatePageShowLog() : WMComponents.VisualComponent;
  860. VAR panel : WMStandardComponents.Panel; textView : WMTextView.TextView;
  861. BEGIN
  862. NEW(panel); panel.alignment.Set(WMComponents.AlignClient);
  863. panel.bearing.Set(WMRectangles.MakeRect(20, 0, 20, 0));
  864. NEW(progressBar); progressBar.alignment.Set(WMComponents.AlignBottom);
  865. progressBar.bounds.SetHeight(20);
  866. progressBar.fillColor.Set(WMGraphics.White);
  867. progressBar.borderColor.Set(WMGraphics.Black);
  868. progressBar.color.Set(OberonColor);
  869. progressBar.textColor.Set(WMGraphics.Black);
  870. progressBar.showPercents.Set(TRUE);
  871. progressBar.SetRange(0, 100);
  872. progressBar.SetCurrent(0);
  873. panel.AddContent(progressBar);
  874. NEW(textView); textView.alignment.Set(WMComponents.AlignClient);
  875. textView.isMultiLine.Set(TRUE); textView.showBorder.Set(TRUE);
  876. textView.defaultTextColor.Set(WMGraphics.Black);
  877. textView.alwaysShowCursor.Set(FALSE);
  878. NEW(logText); NEW(w, logText);
  879. textView.SetText(logText);
  880. panel.AddContent(textView);
  881. RETURN panel;
  882. END CreatePageShowLog;
  883. PROCEDURE CreatePageSelectPartition() : WMComponents.VisualComponent;
  884. VAR panel : BorderPanel; toolbar : WMStandardComponents.Panel;
  885. BEGIN
  886. NEW(panel); panel.alignment.Set(WMComponents.AlignClient);
  887. panel.bearing.Set(WMRectangles.MakeRect(20, 0, 20, 0));
  888. NEW(toolbar); toolbar.bounds.SetHeight(20);
  889. toolbar.alignment.Set(WMComponents.AlignBottom);
  890. panel.AddContent(toolbar);
  891. NEW(showDetailsBtn); showDetailsBtn.alignment.Set(WMComponents.AlignRight);
  892. showDetailsBtn.caption.SetAOC("Details");
  893. showDetailsBtn.onClick.Add(HandleButtons);
  894. showDetailsBtn.isToggle.Set(TRUE);
  895. showDetailsBtn.SetPressed(showDetails);
  896. toolbar.AddContent(showDetailsBtn);
  897. NEW(selectionLabel); selectionLabel.alignment.Set(WMComponents.AlignClient);
  898. selectionLabel.fillColor.Set(WMGraphics.White);
  899. selectionLabel.caption.SetAOC(" Selection : None");
  900. toolbar.AddContent(selectionLabel);
  901. NEW(partitionSelector); partitionSelector.alignment.Set(WMComponents.AlignClient);
  902. partitionSelector.fillColor.Set(WMGraphics.White);
  903. partitionSelector.clBackground.Set(LONGINT(0E0E0E0FFH) (* OberonColorLight *));
  904. partitionSelector.onSelection.Add(HandleSelection);
  905. panel.AddContent(partitionSelector);
  906. RETURN panel;
  907. END CreatePageSelectPartition;
  908. PROCEDURE CreateForm() : WMComponents.VisualComponent;
  909. VAR panel : InstallerBgPanel; upperpanel : WMStandardComponents.Panel; textView : WMTextView.TextView;
  910. BEGIN
  911. NEW(panel); panel.alignment.Set(WMComponents.AlignClient); panel.fillColor.Set(WMGraphics.White);
  912. NEW(upperpanel); upperpanel.alignment.Set(WMComponents.AlignTop);
  913. upperpanel.bearing.Set(WMRectangles.MakeRect(10, 10, 10, 0));
  914. upperpanel.bounds.SetHeight(UpperPanelHeight);
  915. upperpanel.fillColor.Set(WMGraphics.White);
  916. panel.AddContent(upperpanel);
  917. NEW(imagePanel); imagePanel.alignment.Set(WMComponents.AlignLeft);
  918. imagePanel.fillColor.Set(WMGraphics.White);
  919. imagePanel.bounds.SetWidth(ImageWidth);
  920. imagePanel.imgName.SetAOC(ImageLogo);
  921. upperpanel.AddContent(imagePanel);
  922. NEW(textView); textView.alignment.Set(WMComponents.AlignClient);
  923. textView.isMultiLine.Set(TRUE); textView.showBorder.Set(FALSE);
  924. textView.defaultTextBgColor.Set(WMGraphics.White);
  925. textView.alwaysShowCursor.Set(FALSE);
  926. textView.mouseWheelScrollSpeed.Set(0);
  927. textView.allowCommandExecution.Set(FALSE);
  928. textView.allowTextSelection.Set(FALSE);
  929. textView.allowPiemenu.Set(FALSE);
  930. textView.takesFocus.Set(FALSE);
  931. NEW(upperText);
  932. textView.SetText(upperText);
  933. upperpanel.AddContent(textView);
  934. NEW(titleLabel); titleLabel.alignment.Set(WMComponents.AlignTop);
  935. titleLabel.bounds.SetHeight(20);
  936. titleLabel.bearing.Set(WMRectangles.MakeRect(20, 0, 20, 0));
  937. panel.AddContent(titleLabel);
  938. NEW(buttonPanel); buttonPanel.alignment.Set(WMComponents.AlignBottom);
  939. buttonPanel.bearing.Set(WMRectangles.MakeRect(20, 0, 20, 20));
  940. buttonPanel.bounds.SetHeight(ButtonPanelHeight);
  941. panel.AddContent(buttonPanel);
  942. helpBtn := NewButton();
  943. helpBtn.alignment.Set(WMComponents.AlignLeft);
  944. helpBtn.caption.SetAOC("Help");
  945. buttonPanel.AddContent(helpBtn);
  946. quickInstallBtn := NewButton();
  947. quickInstallBtn.alignment.Set(WMComponents.AlignLeft);
  948. quickInstallBtn.bounds.SetWidth(80);
  949. quickInstallBtn.bearing.Set(WMRectangles.MakeRect(5, 0, 0, 0));
  950. quickInstallBtn.caption.SetAOC("QuickInstall");
  951. buttonPanel.AddContent(quickInstallBtn);
  952. nextBtn := NewButton(); buttonPanel.AddContent(nextBtn);
  953. backBtn := NewButton(); buttonPanel.AddContent(backBtn);
  954. backBtn.bearing.Set(WMRectangles.MakeRect(5, 0, 5, 0));
  955. NEW(textView); textView.alignment.Set(WMComponents.AlignBottom);
  956. textView.bearing.Set(WMRectangles.MakeRect(20, 20, 20, 10));
  957. textView.bounds.SetHeight(LowerPanelHeight);
  958. textView.isMultiLine.Set(TRUE); textView.showBorder.Set(TRUE);
  959. textView.alwaysShowCursor.Set(FALSE);
  960. textView.mouseWheelScrollSpeed.Set(0);
  961. textView.allowCommandExecution.Set(FALSE);
  962. textView.allowPiemenu.Set(FALSE);
  963. textView.takesFocus.Set(FALSE);
  964. NEW(lowerText);
  965. textView.SetText(lowerText);
  966. panel.AddContent(textView);
  967. RETURN panel;
  968. END CreateForm;
  969. PROCEDURE NewButton() : WMStandardComponents.Button;
  970. VAR button : WMStandardComponents.Button;
  971. BEGIN
  972. NEW(button); button.alignment.Set(WMComponents.AlignRight);
  973. button.onClick.Add(HandleButtons);
  974. RETURN button;
  975. END NewButton;
  976. PROCEDURE WheelMove*(dz: LONGINT);
  977. BEGIN
  978. CASE currentPage OF
  979. |PageSelectPartition:
  980. partitionSelector.WheelMove(dz);
  981. |PageSelectPackages:
  982. packageSelector.scrollPanel.WheelMove(dz);
  983. |PageShowSteps:
  984. |PageAdvancedOptions:
  985. configurationSettings.scrollPanel.WheelMove(dz);
  986. |PageShowLog:
  987. ELSE
  988. END;
  989. END WheelMove;
  990. PROCEDURE Close*;
  991. BEGIN
  992. Close^;
  993. WindowClosed;
  994. UnlockPartition(lockedSelection);
  995. IF (progressPoller # NIL) THEN progressPoller.Close; END;
  996. IF (installer # NIL) THEN installer.Abort; END;
  997. END Close;
  998. PROCEDURE &New*;
  999. BEGIN
  1000. showDetails := FALSE;
  1001. Init(WindowWidth, WindowHeight, FALSE);
  1002. main := CreateForm();
  1003. currentPage := -1;
  1004. pages[PageSelectPartition] := CreatePageSelectPartition();
  1005. pages[PageSelectPackages] := CreatePageSelectPackages();
  1006. pages[PageShowSteps] := CreatePageShowSteps();
  1007. pages[PageShowLog] := CreatePageShowLog();
  1008. pages[PageAdvancedOptions] := CreatePageAdvancedOptions();
  1009. LoadText(upperText, TitleText);
  1010. SetContent(main);
  1011. WMWindowManager.DefaultAddWindow(SELF);
  1012. SetTitle(Strings.NewString(WindowTitle));
  1013. SelectPage(0);
  1014. END New;
  1015. END Window;
  1016. TYPE
  1017. HelpWindow = OBJECT(WMComponents.FormWindow)
  1018. PROCEDURE Close*;
  1019. BEGIN
  1020. Close^;
  1021. helpWindow := NIL;
  1022. END Close;
  1023. PROCEDURE &New*(text : Texts.Text);
  1024. VAR editor : WMEditors.Editor;
  1025. BEGIN
  1026. Init(WindowWidth, WindowHeight, FALSE);
  1027. NEW(editor); editor.alignment.Set(WMComponents.AlignClient);
  1028. editor.multiLine.Set(TRUE);
  1029. editor.readOnly.Set(TRUE);
  1030. editor.SetText(text);
  1031. editor.fillColor.Set(WMGraphics.White);
  1032. SetContent(editor);
  1033. WMWindowManager.DefaultAddWindow(SELF);
  1034. SetTitle(Strings.NewString("Oberon Installer Help"));
  1035. END New;
  1036. END HelpWindow;
  1037. TYPE
  1038. (* Called when the installer operation has been aborted or is finished *)
  1039. NotifyProc = PROCEDURE {DELEGATE} (aborted : BOOLEAN);
  1040. (* Polls the progress of the installer operation *)
  1041. PollProgress = OBJECT
  1042. VAR
  1043. progressBar : WMProgressComponents.ProgressBar;
  1044. installer : Installer.Installer;
  1045. notifyProc : NotifyProc;
  1046. last : HUGEINT;
  1047. timer : Kernel.Timer;
  1048. alive, dead : BOOLEAN;
  1049. PROCEDURE Update;
  1050. VAR state : PartitionsLib.OperationState;
  1051. BEGIN
  1052. IF (last = 100) OR (state.status * (PartitionsLib.StatusFinished + PartitionsLib.StatusAborted) # {}) THEN alive := FALSE; END;
  1053. state := installer.GetState();
  1054. IF state.cur # last THEN
  1055. progressBar.SetCurrent(SHORT(state.cur));
  1056. last := state.cur;
  1057. END;
  1058. IF (alive = FALSE) & (notifyProc # NIL) THEN notifyProc(state.status * PartitionsLib.StatusAborted # {}); END;
  1059. END Update;
  1060. PROCEDURE SetNotifyProc(notifyProc : NotifyProc);
  1061. BEGIN
  1062. SELF.notifyProc := notifyProc;
  1063. END SetNotifyProc;
  1064. PROCEDURE &Init*(installer : Installer.Installer; progressBar : WMProgressComponents.ProgressBar);
  1065. BEGIN
  1066. ASSERT((installer # NIL) & (progressBar # NIL));
  1067. SELF.installer := installer; SELF.progressBar := progressBar;
  1068. alive := TRUE; dead := FALSE;
  1069. last := -1;
  1070. NEW(timer);
  1071. END Init;
  1072. PROCEDURE Close;
  1073. BEGIN {EXCLUSIVE}
  1074. alive := FALSE; timer.Wakeup;
  1075. AWAIT(dead);
  1076. END Close;
  1077. BEGIN {ACTIVE}
  1078. WHILE alive DO
  1079. Update;
  1080. timer.Sleep(200);
  1081. END;
  1082. BEGIN {EXCLUSIVE} dead := TRUE; END;
  1083. END PollProgress;
  1084. VAR
  1085. window : Window;
  1086. helpWindow : HelpWindow;
  1087. StrScrollPanel, StrPackageSelector, StrConfigurationSettings, StrInstallerBgPanel, StrBorderPanel : Strings.String;
  1088. PROCEDURE InitStrings;
  1089. BEGIN
  1090. StrScrollPanel := Strings.NewString("ScrollPanel");
  1091. StrPackageSelector := Strings.NewString("PackageSelector");
  1092. StrConfigurationSettings := Strings.NewString("ConfigurationSettings");
  1093. StrInstallerBgPanel := Strings.NewString("InstallerBgPanel");
  1094. StrBorderPanel := Strings.NewString("BorderPanel");
  1095. END InitStrings;
  1096. PROCEDURE LoadOberonText(CONST filename : ARRAY OF CHAR; VAR text : Texts.Text);
  1097. VAR reader : Streams.Reader; decoder : Codecs.TextDecoder; res : WORD;
  1098. BEGIN
  1099. text := NIL;
  1100. reader := Codecs.OpenInputStream(filename);
  1101. IF (reader # NIL) THEN
  1102. decoder := Codecs.GetTextDecoder("Oberon");
  1103. IF (decoder # NIL) THEN
  1104. decoder.Open(reader, res);
  1105. IF (res = Codecs.ResOk) THEN
  1106. text := decoder.GetText();
  1107. ELSE
  1108. KernelLog.String("WMInstaller: Could not decode file "); KernelLog.String(filename);
  1109. KernelLog.String(" (res: "); KernelLog.Int(res, 0); KernelLog.String(")"); KernelLog.Ln;
  1110. END;
  1111. ELSE KernelLog.String("WMInstaller: Could not get Oberon text decoder"); KernelLog.Ln;
  1112. END;
  1113. ELSE KernelLog.String("WMInstaller: Could not open file "); KernelLog.String(filename); KernelLog.Ln;
  1114. END;
  1115. END LoadOberonText;
  1116. PROCEDURE Open*;
  1117. BEGIN {EXCLUSIVE}
  1118. IF (window = NIL) THEN
  1119. NEW(window);
  1120. END;
  1121. END Open;
  1122. PROCEDURE WindowClosed;
  1123. BEGIN {EXCLUSIVE}
  1124. window := NIL;
  1125. END WindowClosed;
  1126. PROCEDURE Cleanup;
  1127. BEGIN
  1128. IF (window # NIL) THEN window.Close; END;
  1129. IF (helpWindow # NIL) THEN helpWindow.Close; END;
  1130. END Cleanup;
  1131. BEGIN
  1132. Modules.InstallTermHandler(Cleanup);
  1133. InitStrings;
  1134. window := NIL; helpWindow := NIL;
  1135. END WMInstaller.
  1136. WMInstaller.Open ~
  1137. System.Free WMInstaller ~
  1138. ~
  1139. FSTools.DeleteFiles WMInstaller.tar ~
  1140. ~
  1141. Tar.Create WMInstaller.tar
  1142. OberonLogoSmall.png
  1143. Title.Text
  1144. Help.Text
  1145. SelectPartition.Text
  1146. SelectPackages.Text
  1147. InstallSteps.Text
  1148. InstallLog.Text
  1149. AdvancedOptions.Text
  1150. DefaultConfig.Text
  1151. ~
  1152. Tar.Extract WMInstaller.tar ~
  1153. System.FreeDownTo PartitionsLib ~
  1154. PC.Compile \s
  1155. PartitionsLib.Mod
  1156. FATScavenger.Mod
  1157. Installer.Mod
  1158. Partitions.Mod
  1159. WMPartitionsComponents.Mod
  1160. WMPartitionsPlugins.Mod
  1161. WMPartitions.Mod
  1162. WMInstaller.Mod
  1163. ~