-
Notifications
You must be signed in to change notification settings - Fork 0
/
PageSelectFolders.pas
174 lines (145 loc) · 5.07 KB
/
PageSelectFolders.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
{**
DelphiPI (Delphi Package Installer)
Author : ibrahim dursun (ibrahimdursun gmail)
License : GNU General Public License 2.0
**}
unit PageSelectFolders;
interface
uses
CompilationData, Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, PageBase, StdCtrls, ExtCtrls, WizardIntfs, JclIDEUtils, ActnList;
type
TSelectFoldersPage = class(TWizardPage)
grpPackagePattern: TGroupBox;
Label3: TLabel;
cbPattern: TComboBox;
grpBaseFolder: TGroupBox;
Label1: TLabel;
btnSelectFolder: TButton;
edtBaseFolder: TEdit;
Label2: TLabel;
grpDelphiVersion: TGroupBox;
cbDelphiVersions: TComboBox;
procedure btnSelectFolderClick(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure FormCreate(Sender: TObject);
procedure cbDelphiVersionsChange(Sender: TObject);
procedure edtBaseFolderChange(Sender: TObject);
private
FPatternsFileName: string;
fInstallations : TJclBorRADToolInstallations;
procedure AddDelphiInstallation(const installation: TJclBorRADToolInstallation);
function GetInstallations: TJclBorRADToolInstallations;
protected
property Installations: TJclBorRADToolInstallations read GetInstallations;
public
constructor Create(Owner: TComponent; const compilationData: TCompilationData); override;
procedure UpdateWizardState; override;
function CanShowPage: Boolean; override;
end;
var
SelectFoldersPage: TSelectFoldersPage;
implementation
uses FileCtrl, gnugettext, FormWizard, JclSysInfo, JclFileUtils;
{$R *.dfm}
{ TSelectFoldersPage }
constructor TSelectFoldersPage.Create(Owner: TComponent;
const compilationData: TCompilationData);
begin
inherited;
fCompilationData := compilationData;
end;
procedure TSelectFoldersPage.edtBaseFolderChange(Sender: TObject);
begin
inherited;
UpdateWizardState;
end;
procedure TSelectFoldersPage.FormCreate(Sender: TObject);
var
i: integer;
dataFolder: string;
begin
inherited;
TranslateComponent(self);
dataFolder := PathAppend(GetAppdataFolder, 'DelphiPI');
if not DirectoryExists(dataFolder) then
CreateDir(dataFolder);
FPatternsFileName := PathAppend(dataFolder, 'patterns.txt');
edtBaseFolder.Text := FCompilationData.BaseFolder;
cbPattern.Text := FCompilationData.Pattern;
if (FileExists(FPatternsFileName)) then
cbPattern.Items.LoadFromFile(FPatternsFileName);
for i := 0 to Installations.Count - 1 do
AddDelphiInstallation(Installations.Installations[i]);
if cbDelphiVersions.Items.Count > 0 then
cbDelphiVersionsChange(cbDelphiVersions)
else begin
cbDelphiVersions.AddItem('[No Delphi Version Installed]', nil);
cbDelphiVersions.ItemIndex := 0;
end;
end;
procedure TSelectFoldersPage.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
inherited;
if cbPattern.Items.IndexOf(cbPattern.Text) = -1 then
cbPattern.Items.Add(cbPattern.Text);
FCompilationData.BaseFolder := edtBaseFolder.Text;
FCompilationData.Pattern := cbPattern.Text;
fCompilationData.PackageList.Clear;
if FileExists(FPatternsFileName) then
JclFileUtils.CreateEmptyFile(FPatternsFileName);
cbPattern.Items.SaveToFile(FPatternsFileName);
end;
procedure TSelectFoldersPage.AddDelphiInstallation(const installation: TJclBorRADToolInstallation);
var
i: integer;
begin
i := cbDelphiVersions.Items.Add(installation.Description);
cbDelphiVersions.Items.Objects[i] := installation;
if not Assigned(fCompilationData.Installation) then
exit;
if installation.VersionNumberStr = fCompilationData.Installation.VersionNumberStr then
cbDelphiVersions.ItemIndex := i;
end;
procedure TSelectFoldersPage.UpdateWizardState;
var
action: TAction;
begin
inherited;
wizard.SetHeader(_('Select Folders'));
wizard.SetDescription(_('Please select folders which contains the packages that you want to install'));
action := wizard.GetAction(wbtNext);
action.Enabled := (edtBaseFolder.Text <> '') and (Installations.Count > 0) ;
end;
procedure TSelectFoldersPage.btnSelectFolderClick(Sender: TObject);
var
directory: string;
begin
inherited;
directory := edtBaseFolder.Text;
if SelectDirectory(_('Select the folder where packages are'),'',directory) then
begin
edtBaseFolder.Text := directory;
UpdateWizardState;
end;
end;
function TSelectFoldersPage.CanShowPage: Boolean;
begin
Result := not(fCompilationData.Scripting);
end;
procedure TSelectFoldersPage.cbDelphiVersionsChange(Sender: TObject);
begin
inherited;
if (cbDelphiVersions.ItemIndex = -1) then
cbDelphiVersions.ItemIndex := 0;
if cbDelphiVersions.Items.Count > 0 then
fCompilationData.Installation := cbDelphiVersions.Items.Objects[cbDelphiVersions.ItemIndex] as TJclBorRADToolInstallation;
end;
function TSelectFoldersPage.GetInstallations: TJclBorRADToolInstallations;
begin
if fInstallations = nil then
fInstallations := TJclBorRADToolInstallations.Create;
Result := fInstallations;
end;
end.