-
Notifications
You must be signed in to change notification settings - Fork 4
/
ConfigurationSelectionForm.pas
175 lines (154 loc) · 5.32 KB
/
ConfigurationSelectionForm.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
175
{*****************************************************************************
The AddIDETools team (see file NOTICE.txt) licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. A copy of this licence is found in the root directory
of this project in the file LICENCE.txt or alternatively at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
*****************************************************************************}
unit ConfigurationSelectionForm;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.ComCtrls, Vcl.StdCtrls, AddIDETool;
type
/// <summary>
/// Form for selecting Rad Studio versions/configurations
/// </summary>
TConfigSelectionForm = class(TForm)
LabelDescription: TLabel;
ListViewConfigurations: TListView;
ButtonOK: TButton;
ButtonCancel: TButton;
ButtonSelectAll: TButton;
ButtonDeselectAll: TButton;
procedure ButtonSelectAllClick(Sender: TObject);
procedure ButtonDeselectAllClick(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure ButtonOKClick(Sender: TObject);
private
/// <summary>
/// Business logic for managing the registry entries
/// </summary>
FIDEToolMgr : TAddIDETool;
/// <summary>
/// Complete path and file name of the entry to add
/// </summary>
FEntryPath : string;
/// <summary>
/// Display name of the entry for the tools menu
/// </summary>
FEntryName : string;
/// <summary>
/// Command line params used when calling the entry
/// </summary>
FEntryParams : string;
/// <summary>
/// Working dir used when calling the entry
/// </summary>
FEntryWorkingDir : string;
public
/// <summary>
/// Initialize the displayed list
/// </summary>
/// <param name="AOwner">
/// Owner responsible for managing lifetime
/// </param>
/// <param name="EntryName">
/// Display name of the entry for the tools menu as to be shown in
/// description text
/// </param>
/// <param name="EntryPath">
/// Complete path and file name of the entry to add
/// </param>
/// <param name="EntryParams">
/// Command line params used when calling the entry
/// </param>
/// <param name="EntryWorkingDir">
/// Working dir used when calling the entry
/// </param>
constructor Create(AOwner : TComponent;
EntryName,
EntryPath,
EntryParams,
EntryWorkingDir : string); reintroduce;
end;
var
ConfigSelectionForm: TConfigSelectionForm;
implementation
{$R *.dfm}
procedure TConfigSelectionForm.ButtonDeselectAllClick(Sender: TObject);
var
Item : TListItem;
begin
for Item in ListViewConfigurations.Items do
Item.Checked := false;
end;
procedure TConfigSelectionForm.ButtonOKClick(Sender: TObject);
var
i : Integer;
Item : TListItem;
AddList : TIDEVersionList;
begin
// Delete all entries
AddList := FIDEToolMgr.GetIDEVersionsList;
// This would add it to all IDE configurations but...
FIDEToolMgr.DeleteTool(FEntryPath, AddList);
// here we remove those not selected from the list
for i := ListViewConfigurations.Items.Count - 1 downTo 0 do
begin
Item := ListViewConfigurations.Items[i];
if not Item.Checked then
AddList.Delete(Item.Index);
end;
FIDEToolMgr.AddTool(FEntryParams,
FEntryPath,
FEntryName,
FEntryWorkingDir,
AddList);
end;
procedure TConfigSelectionForm.ButtonSelectAllClick(Sender: TObject);
var
Item : TListItem;
begin
for Item in ListViewConfigurations.Items do
Item.Checked := true;
end;
constructor TConfigSelectionForm.Create(AOwner : TComponent;
EntryName,
EntryPath,
EntryParams,
EntryWorkingDir: string);
var
IDEConfigList : TIDEVersionList;
IDEConfig : TIDEVersionRec;
Item : TListItem;
begin
inherited Create(AOwner);
LabelDescription.Caption := Format(LabelDescription.Caption, [EntryName]);
FEntryName := EntryName;
FEntryPath := EntryPath;
FEntryParams := EntryParams;
FEntryWorkingDir := EntryWorkingDir;
FIDEToolMgr := TAddIDETool.Create;
IDEConfigList := FIDEToolMgr.GetIDEVersionsList;
for IDEConfig in IDEConfigList do
begin
Item := ListViewConfigurations.Items.Add;
Item.Caption := IDEConfig.GetIDEVersionName;
if (IDEConfig.ConfigRootKey <> 'BDS') then
Item.SubItems.Add(IDEConfig.ConfigRootKey);
Item.Checked := FIDEToolMgr.IsInMenu(EntryPath, IDECOnfig.GetConfigKey);
end;
end;
procedure TConfigSelectionForm.FormDestroy(Sender: TObject);
begin
FIDEToolMgr.Free;
end;
end.