| 1 | unit UFormModuleList;
|
|---|
| 2 |
|
|---|
| 3 | {$mode delphi}
|
|---|
| 4 |
|
|---|
| 5 | interface
|
|---|
| 6 |
|
|---|
| 7 | uses
|
|---|
| 8 | Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
|
|---|
| 9 | ComCtrls, ExtCtrls, Menus, ActnList, StdCtrls, SpecializedList, DateUtils,
|
|---|
| 10 | UListViewSort, UModularSystem;
|
|---|
| 11 |
|
|---|
| 12 | type
|
|---|
| 13 | TModuleListOption = (mloShowVersion, mloShowAuthor, mloShowFileName,
|
|---|
| 14 | mloShowIdentification, mloShowLicense, mloShowEnable, mloShowRunning,
|
|---|
| 15 | mloShowDependencies, mloShowInstalled, mloShowInfoBar, mloShowDescription,
|
|---|
| 16 | mloShowStartUpTime, mloAllowInstall, mloAllowEnable, mloAllowRegister, mloAllowStart);
|
|---|
| 17 | TModuleListOptions = set of TModuleListOption;
|
|---|
| 18 |
|
|---|
| 19 | { TFormModuleList }
|
|---|
| 20 |
|
|---|
| 21 | TFormModuleList = class(TForm)
|
|---|
| 22 | ARestart: TAction;
|
|---|
| 23 | ARegister: TAction;
|
|---|
| 24 | AEnable: TAction;
|
|---|
| 25 | ADisable: TAction;
|
|---|
| 26 | AStart: TAction;
|
|---|
| 27 | AStop: TAction;
|
|---|
| 28 | AInstall: TAction;
|
|---|
| 29 | AUninstall: TAction;
|
|---|
| 30 | AUnregister: TAction;
|
|---|
| 31 | ActionList1: TActionList;
|
|---|
| 32 | ImageList1: TImageList;
|
|---|
| 33 | ListViewModules: TListView;
|
|---|
| 34 | Memo1: TMemo;
|
|---|
| 35 | MenuItem1: TMenuItem;
|
|---|
| 36 | MenuItem2: TMenuItem;
|
|---|
| 37 | MenuItem3: TMenuItem;
|
|---|
| 38 | MenuItem4: TMenuItem;
|
|---|
| 39 | MenuItem5: TMenuItem;
|
|---|
| 40 | MenuItem6: TMenuItem;
|
|---|
| 41 | MenuItem7: TMenuItem;
|
|---|
| 42 | MenuItem8: TMenuItem;
|
|---|
| 43 | MenuItem9: TMenuItem;
|
|---|
| 44 | PopupMenu1: TPopupMenu;
|
|---|
| 45 | Splitter1: TSplitter;
|
|---|
| 46 | TimerRedraw: TTimer;
|
|---|
| 47 | ToolBar1: TToolBar;
|
|---|
| 48 | ToolButton1: TToolButton;
|
|---|
| 49 | ToolButton2: TToolButton;
|
|---|
| 50 | ToolButton3: TToolButton;
|
|---|
| 51 | ToolButton4: TToolButton;
|
|---|
| 52 | ToolButton5: TToolButton;
|
|---|
| 53 | ToolButton6: TToolButton;
|
|---|
| 54 | ToolButton7: TToolButton;
|
|---|
| 55 | ToolButton8: TToolButton;
|
|---|
| 56 | procedure ADisableExecute(Sender: TObject);
|
|---|
| 57 | procedure AEnableExecute(Sender: TObject);
|
|---|
| 58 | procedure AInstallExecute(Sender: TObject);
|
|---|
| 59 | procedure AUninstallExecute(Sender: TObject);
|
|---|
| 60 | procedure AUnregisterExecute(Sender: TObject);
|
|---|
| 61 | procedure AStartExecute(Sender: TObject);
|
|---|
| 62 | procedure AStopExecute(Sender: TObject);
|
|---|
| 63 | procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
|
|---|
| 64 | procedure FormCreate(Sender: TObject);
|
|---|
| 65 | procedure FormDestroy(Sender: TObject);
|
|---|
| 66 | procedure FormHide(Sender: TObject);
|
|---|
| 67 | procedure FormShow(Sender: TObject);
|
|---|
| 68 | procedure ListViewModulesData(Sender: TObject; Item: TListItem);
|
|---|
| 69 | procedure ListViewModulesSelectItem(Sender: TObject; Item: TListItem;
|
|---|
| 70 | Selected: Boolean);
|
|---|
| 71 | procedure TimerRedrawTimer(Sender: TObject);
|
|---|
| 72 | private
|
|---|
| 73 | FModuleManager: TModuleManager;
|
|---|
| 74 | FOptions: TModuleListOptions;
|
|---|
| 75 | ListViewSort: TListViewSort;
|
|---|
| 76 | function ListViewModulesCompare(Item1, Item2: TObject): Integer;
|
|---|
| 77 | procedure ModulesFilterExecute(ListViewSort: TListViewSort);
|
|---|
| 78 | procedure SetModuleManager(AValue: TModuleManager);
|
|---|
| 79 | procedure SetOptions(AValue: TModuleListOptions);
|
|---|
| 80 | public
|
|---|
| 81 | procedure Reload;
|
|---|
| 82 | procedure UpdateInterface;
|
|---|
| 83 | property Manager: TModuleManager read FModuleManager write SetModuleManager;
|
|---|
| 84 | property Options: TModuleListOptions read FOptions write SetOptions;
|
|---|
| 85 | end;
|
|---|
| 86 |
|
|---|
| 87 | function ModuleToStr(Module: TObject): string;
|
|---|
| 88 |
|
|---|
| 89 | implementation
|
|---|
| 90 |
|
|---|
| 91 | resourcestring
|
|---|
| 92 | SYes = 'Yes';
|
|---|
| 93 | SNo = 'No';
|
|---|
| 94 | SAdditionalModulesInstall = 'In addition to "%0:s" module also dependent modules will be installed: "%1:s"';
|
|---|
| 95 | SAdditionalModulesUninstall = 'In addition to "%0:s" module alse dependent modules will be uninstalled: "%1:s"';
|
|---|
| 96 | SAdditionalModulesStart = 'In addition to "%0:s" module also dependent modules will be started: "%1:s"';
|
|---|
| 97 | SAdditionalModulesStop = 'In addition to "%0:s" module also dependent modules will be stopped: "%1:s"';
|
|---|
| 98 | SIdentification = 'Identification';
|
|---|
| 99 | SName = 'Name';
|
|---|
| 100 | SVersion = 'Version';
|
|---|
| 101 | SLicense = 'License';
|
|---|
| 102 | SDescription = 'Description';
|
|---|
| 103 | SDependencies = 'Dependencies';
|
|---|
| 104 | SAuthor = 'Author';
|
|---|
| 105 |
|
|---|
| 106 | function ModuleToStr(Module: TObject): string;
|
|---|
| 107 | begin
|
|---|
| 108 | Result := TModule(Module).Title;
|
|---|
| 109 | end;
|
|---|
| 110 |
|
|---|
| 111 | { TFormModuleList }
|
|---|
| 112 |
|
|---|
| 113 | procedure TFormModuleList.ListViewModulesData(Sender: TObject; Item: TListItem);
|
|---|
| 114 | begin
|
|---|
| 115 | if (Item.Index >= 0) and (Item.Index < ListViewSort.List.Count) then
|
|---|
| 116 | with TModule(ListViewSort.List[Item.Index]) do begin
|
|---|
| 117 | Item.Caption := Identification;
|
|---|
| 118 | Item.Data := ListViewSort.List[Item.Index];
|
|---|
| 119 | Item.SubItems.Add(Title);
|
|---|
| 120 | if Enabled then Item.SubItems.Add(SYes)
|
|---|
| 121 | else Item.SubItems.Add(SNo);
|
|---|
| 122 | if Installed then Item.SubItems.Add(SYes)
|
|---|
| 123 | else Item.SubItems.Add(SNo);
|
|---|
| 124 | if Running then Item.SubItems.Add(SYes)
|
|---|
| 125 | else Item.SubItems.Add(SNo);
|
|---|
| 126 | if Author <> '' then Item.SubItems.Add(Author)
|
|---|
| 127 | else Item.SubItems.Add(' ');
|
|---|
| 128 | if License <> '' then Item.SubItems.Add(License)
|
|---|
| 129 | else Item.SubItems.Add(' ');
|
|---|
| 130 | if Version <> '' then Item.SubItems.Add(Version)
|
|---|
| 131 | else Item.SubItems.Add(' ');
|
|---|
| 132 | Item.SubItems.Add(Dependencies.Implode(',', StrToStr));
|
|---|
| 133 | if FileName <> '' then Item.SubItems.Add(FileName)
|
|---|
| 134 | else Item.SubItems.Add(' ');
|
|---|
| 135 | Item.SubItems.Add(FloatToStr(Trunc(StartUpTime / OneMillisecond)));
|
|---|
| 136 | end;
|
|---|
| 137 | end;
|
|---|
| 138 |
|
|---|
| 139 | procedure TFormModuleList.ListViewModulesSelectItem(Sender: TObject;
|
|---|
| 140 | Item: TListItem; Selected: Boolean);
|
|---|
| 141 | begin
|
|---|
| 142 | UpdateInterface;
|
|---|
| 143 | Memo1.Clear;
|
|---|
| 144 | if Assigned(ListViewModules.Selected) then
|
|---|
| 145 | with TModule(ListViewModules.Selected.Data) do begin
|
|---|
| 146 | Memo1.Lines.Add(SName + ': ' + Title);
|
|---|
| 147 | if (mloShowIdentification in FOptions) then Memo1.Lines.Add(SIdentification + ': ' + Identification);
|
|---|
| 148 | if (mloShowAuthor in FOptions) and (Author <> '') then Memo1.Lines.Add(SAuthor + ': ' + Author);
|
|---|
| 149 | if (mloShowVersion in FOptions) and (Version <> '') then Memo1.Lines.Add(SVersion + ': ' + Version);
|
|---|
| 150 | if (mloShowLicense in FOptions) and (License <> '') then Memo1.Lines.Add(SLicense + ': ' + License);
|
|---|
| 151 | if (mloShowDependencies in FOptions) and (Dependencies.Count > 0) then
|
|---|
| 152 | Memo1.Lines.Add(SDependencies + ': ' + Dependencies.Implode(', ', StrToStr));
|
|---|
| 153 | if (mloShowDescription in FOptions) and (Description.Count > 0) then
|
|---|
| 154 | Memo1.Lines.Add(SDescription + ': ' + Description.Implode(', ', StrToStr));
|
|---|
| 155 | end;
|
|---|
| 156 | end;
|
|---|
| 157 |
|
|---|
| 158 | procedure TFormModuleList.FormCreate(Sender: TObject);
|
|---|
| 159 | begin
|
|---|
| 160 | ListViewSort := TListViewSort.Create;
|
|---|
| 161 | ListViewSort.ListView := ListViewModules;
|
|---|
| 162 | ListViewSort.Column := 0;
|
|---|
| 163 | ListViewSort.Order := soDown;
|
|---|
| 164 | ListViewSort.OnCompareItem := ListViewModulesCompare;
|
|---|
| 165 | ListViewSort.OnFilter := ModulesFilterExecute;
|
|---|
| 166 |
|
|---|
| 167 | DoubleBuffered := True;
|
|---|
| 168 | ControlStyle := ControlStyle + [csOpaque];
|
|---|
| 169 | ListViewModules.DoubleBuffered := True;
|
|---|
| 170 | ListViewModules.ControlStyle := ListViewModules.ControlStyle + [csOpaque];
|
|---|
| 171 | end;
|
|---|
| 172 |
|
|---|
| 173 | procedure TFormModuleList.FormDestroy(Sender: TObject);
|
|---|
| 174 | begin
|
|---|
| 175 | ListViewModules.Clear;
|
|---|
| 176 | FreeAndNil(ListViewSort);
|
|---|
| 177 | end;
|
|---|
| 178 |
|
|---|
| 179 | procedure TFormModuleList.AUnregisterExecute(Sender: TObject);
|
|---|
| 180 | var
|
|---|
| 181 | I: Integer;
|
|---|
| 182 | begin
|
|---|
| 183 | for I := ListViewModules.Items.Count - 1 downto 0 do
|
|---|
| 184 | if ListViewModules.Items[I].Selected then
|
|---|
| 185 | with TModule(ListViewModules.Items[I].Data) do begin
|
|---|
| 186 | FModuleManager.UnregisterModule(TModule(ListViewModules.Items[I].Data));
|
|---|
| 187 | end;
|
|---|
| 188 | UpdateInterface;
|
|---|
| 189 | end;
|
|---|
| 190 |
|
|---|
| 191 | procedure TFormModuleList.AStartExecute(Sender: TObject);
|
|---|
| 192 | var
|
|---|
| 193 | Modules: TListModule;
|
|---|
| 194 | I: Integer;
|
|---|
| 195 | begin
|
|---|
| 196 | for I := 0 to ListViewModules.Items.Count - 1 do
|
|---|
| 197 | if ListViewModules.Items[I].Selected then
|
|---|
| 198 | with TModule(ListViewModules.Items[I].Data) do
|
|---|
| 199 | if not Running then
|
|---|
| 200 | try
|
|---|
| 201 | Modules := TListModule.Create;
|
|---|
| 202 | Modules.OwnsObjects := False;
|
|---|
| 203 | EnumDependenciesCascade(Modules, [mcNotRunning]);
|
|---|
| 204 | if Modules.Count > 0 then begin
|
|---|
| 205 | if MessageDlg(Format(SAdditionalModulesStart, [
|
|---|
| 206 | Identification, Modules.Implode(',', ModuleToStr)]),
|
|---|
| 207 | mtConfirmation, [mbYes, mbNo], 0) = mrYes then
|
|---|
| 208 | Start;
|
|---|
| 209 | end else Start;
|
|---|
| 210 | finally
|
|---|
| 211 | Modules.Free;
|
|---|
| 212 | end;
|
|---|
| 213 | UpdateInterface;
|
|---|
| 214 | end;
|
|---|
| 215 |
|
|---|
| 216 | procedure TFormModuleList.AStopExecute(Sender: TObject);
|
|---|
| 217 | var
|
|---|
| 218 | Modules: TListModule;
|
|---|
| 219 | I: Integer;
|
|---|
| 220 | begin
|
|---|
| 221 | for I := 0 to ListViewModules.Items.Count - 1 do
|
|---|
| 222 | if ListViewModules.Items[I].Selected then
|
|---|
| 223 | with TModule(ListViewModules.Items[I].Data) do
|
|---|
| 224 | if Running then
|
|---|
| 225 | try
|
|---|
| 226 | Modules := TListModule.Create;
|
|---|
| 227 | Modules.OwnsObjects := False;
|
|---|
| 228 | EnumSuperiorDependenciesCascade(Modules, [mcRunning]);
|
|---|
| 229 | if Modules.Count > 0 then begin
|
|---|
| 230 | if MessageDlg(Format(SAdditionalModulesStop, [
|
|---|
| 231 | Identification,
|
|---|
| 232 | Modules.Implode(',', ModuleToStr)]),
|
|---|
| 233 | mtConfirmation, [mbYes, mbNo], 0) = mrYes then
|
|---|
| 234 | Stop;
|
|---|
| 235 | end else Stop;
|
|---|
| 236 | finally
|
|---|
| 237 | FreeAndNil(Modules);
|
|---|
| 238 | end;
|
|---|
| 239 | UpdateInterface;
|
|---|
| 240 | end;
|
|---|
| 241 |
|
|---|
| 242 | procedure TFormModuleList.AUninstallExecute(Sender: TObject);
|
|---|
| 243 | var
|
|---|
| 244 | Modules: TListModule;
|
|---|
| 245 | I: Integer;
|
|---|
| 246 | begin
|
|---|
| 247 | for I := 0 to ListViewModules.Items.Count - 1 do
|
|---|
| 248 | if ListViewModules.Items[I].Selected then
|
|---|
| 249 | with TModule(ListViewModules.Items[I].Data) do
|
|---|
| 250 | if Installed then
|
|---|
| 251 | try
|
|---|
| 252 | Modules := TListModule.Create;
|
|---|
| 253 | Modules.OwnsObjects := False;
|
|---|
| 254 | EnumSuperiorDependenciesCascade(Modules, [mcInstalled]);
|
|---|
| 255 | if Modules.Count > 0 then begin
|
|---|
| 256 | if MessageDlg(Format(SAdditionalModulesUninstall, [
|
|---|
| 257 | Identification,
|
|---|
| 258 | Modules.Implode(',', ModuleToStr)]),
|
|---|
| 259 | mtConfirmation, [mbYes, mbNo], 0) = mrYes then
|
|---|
| 260 | Uninstall;
|
|---|
| 261 | end else Uninstall;
|
|---|
| 262 | finally
|
|---|
| 263 | Modules.Free;
|
|---|
| 264 | end;
|
|---|
| 265 | UpdateInterface;
|
|---|
| 266 | end;
|
|---|
| 267 |
|
|---|
| 268 | procedure TFormModuleList.FormClose(Sender: TObject;
|
|---|
| 269 | var CloseAction: TCloseAction);
|
|---|
| 270 | begin
|
|---|
| 271 | TimerRedraw.Enabled := False;
|
|---|
| 272 | //Core.PersistentForm.Save(Self);
|
|---|
| 273 | end;
|
|---|
| 274 |
|
|---|
| 275 | procedure TFormModuleList.AInstallExecute(Sender: TObject);
|
|---|
| 276 | var
|
|---|
| 277 | Modules: TListModule;
|
|---|
| 278 | I: Integer;
|
|---|
| 279 | begin
|
|---|
| 280 | for I := 0 to ListViewModules.Items.Count - 1 do
|
|---|
| 281 | if ListViewModules.Items[I].Selected then
|
|---|
| 282 | with TModule(ListViewModules.Items[I].Data) do
|
|---|
| 283 | if not Installed then
|
|---|
| 284 | try
|
|---|
| 285 | Modules := TListModule.Create;
|
|---|
| 286 | Modules.OwnsObjects := False;
|
|---|
| 287 | EnumDependenciesCascade(Modules, [mcNotInstalled]);
|
|---|
| 288 | if Modules.Count > 0 then begin
|
|---|
| 289 | if MessageDlg(Format(SAdditionalModulesInstall, [
|
|---|
| 290 | Identification,
|
|---|
| 291 | Modules.Implode(',', ModuleToStr)]),
|
|---|
| 292 | mtConfirmation, [mbYes, mbNo], 0) = mrYes then
|
|---|
| 293 | Install;
|
|---|
| 294 | end else Install;
|
|---|
| 295 | finally
|
|---|
| 296 | Modules.Free;
|
|---|
| 297 | end;
|
|---|
| 298 | UpdateInterface;
|
|---|
| 299 | end;
|
|---|
| 300 |
|
|---|
| 301 | procedure TFormModuleList.AEnableExecute(Sender: TObject);
|
|---|
| 302 | var
|
|---|
| 303 | Modules: TListModule;
|
|---|
| 304 | I: Integer;
|
|---|
| 305 | begin
|
|---|
| 306 | for I := 0 to ListViewModules.Items.Count - 1 do
|
|---|
| 307 | if ListViewModules.Items[I].Selected then
|
|---|
| 308 | with TModule(ListViewModules.Items[I].Data) do
|
|---|
| 309 | if not Enabled then
|
|---|
| 310 | try
|
|---|
| 311 | Modules := TListModule.Create;
|
|---|
| 312 | Modules.OwnsObjects := False;
|
|---|
| 313 | EnumDependenciesCascade(Modules, [mcNotRunning]);
|
|---|
| 314 | if Modules.Count > 0 then begin
|
|---|
| 315 | if MessageDlg(Format(SAdditionalModulesStart, [
|
|---|
| 316 | Identification, Modules.Implode(',', ModuleToStr)]),
|
|---|
| 317 | mtConfirmation, [mbYes, mbNo], 0) = mrYes then begin
|
|---|
| 318 | Enable;
|
|---|
| 319 | Start;
|
|---|
| 320 | end;
|
|---|
| 321 | end else begin
|
|---|
| 322 | Enable;
|
|---|
| 323 | Start;
|
|---|
| 324 | end;
|
|---|
| 325 | finally
|
|---|
| 326 | Modules.Free;
|
|---|
| 327 | end;
|
|---|
| 328 | UpdateInterface;
|
|---|
| 329 | end;
|
|---|
| 330 |
|
|---|
| 331 | procedure TFormModuleList.ADisableExecute(Sender: TObject);
|
|---|
| 332 | var
|
|---|
| 333 | Modules: TListModule;
|
|---|
| 334 | I: Integer;
|
|---|
| 335 | begin
|
|---|
| 336 | for I := 0 to ListViewModules.Items.Count - 1 do
|
|---|
| 337 | if ListViewModules.Items[I].Selected then
|
|---|
| 338 | with TModule(ListViewModules.Items[I].Data) do
|
|---|
| 339 | if Enabled then
|
|---|
| 340 | try
|
|---|
| 341 | Modules := TListModule.Create;
|
|---|
| 342 | Modules.OwnsObjects := False;
|
|---|
| 343 | EnumSuperiorDependenciesCascade(Modules, [mcInstalled]);
|
|---|
| 344 | if Modules.Count > 0 then begin
|
|---|
| 345 | if MessageDlg(Format(SAdditionalModulesUninstall, [
|
|---|
| 346 | Identification,
|
|---|
| 347 | Modules.Implode(',', ModuleToStr)]),
|
|---|
| 348 | mtConfirmation, [mbYes, mbNo], 0) = mrYes then begin
|
|---|
| 349 | Stop;
|
|---|
| 350 | Disable;
|
|---|
| 351 | end;
|
|---|
| 352 | end else begin
|
|---|
| 353 | TModule(ListViewModules.Selected.Data).Stop;
|
|---|
| 354 | TModule(ListViewModules.Selected.Data).Disable;
|
|---|
| 355 | end;
|
|---|
| 356 | finally
|
|---|
| 357 | Modules.Free;
|
|---|
| 358 | end;
|
|---|
| 359 | UpdateInterface;
|
|---|
| 360 | end;
|
|---|
| 361 |
|
|---|
| 362 | procedure TFormModuleList.FormHide(Sender: TObject);
|
|---|
| 363 | begin
|
|---|
| 364 | TimerRedraw.Enabled := False;
|
|---|
| 365 | end;
|
|---|
| 366 |
|
|---|
| 367 | procedure TFormModuleList.FormShow(Sender: TObject);
|
|---|
| 368 | begin
|
|---|
| 369 | Reload;
|
|---|
| 370 | UpdateInterface;
|
|---|
| 371 | //TimerRedraw.Enabled := True;
|
|---|
| 372 | //Core.PersistentForm.Load(Self);
|
|---|
| 373 | end;
|
|---|
| 374 |
|
|---|
| 375 | procedure TFormModuleList.TimerRedrawTimer(Sender: TObject);
|
|---|
| 376 | begin
|
|---|
| 377 | Reload;
|
|---|
| 378 | end;
|
|---|
| 379 |
|
|---|
| 380 | function TFormModuleList.ListViewModulesCompare(Item1, Item2: TObject): Integer;
|
|---|
| 381 | begin
|
|---|
| 382 | Result := 0;
|
|---|
| 383 | if Assigned(Item1) and Assigned(Item2) and (ListViewSort.Order <> soNone) then begin
|
|---|
| 384 | with ListViewSort do
|
|---|
| 385 | case Column of
|
|---|
| 386 | 0: Result := CompareString(TModule(Item1).Identification,
|
|---|
| 387 | TModule(Item2).Identification);
|
|---|
| 388 | 1: Result := CompareString(TModule(Item1).Title,
|
|---|
| 389 | TModule(Item2).Title);
|
|---|
| 390 | 2: Result := CompareBoolean(TModule(Item1).Enabled,
|
|---|
| 391 | TModule(Item2).Enabled);
|
|---|
| 392 | 3: Result := CompareBoolean(TModule(Item1).Installed,
|
|---|
| 393 | TModule(Item2).Installed);
|
|---|
| 394 | 4: Result := CompareBoolean(TModule(Item1).Running,
|
|---|
| 395 | TModule(Item2).Running);
|
|---|
| 396 | 5: Result := CompareString(TModule(Item1).Author,
|
|---|
| 397 | TModule(Item2).Author);
|
|---|
| 398 | 6: Result := CompareString(TModule(Item1).License, TModule(
|
|---|
| 399 | Item2).License);
|
|---|
| 400 | 7: Result := CompareString(TModule(Item1).Version, TModule(
|
|---|
| 401 | Item2).Version);
|
|---|
| 402 | 8: Result := CompareString(TModule(Item1).Dependencies.Implode(',', StrToStr),
|
|---|
| 403 | TModule(Item2).Dependencies.Implode(',', StrToStr));
|
|---|
| 404 | 9: Result := CompareString(TModule(Item1).FileName,
|
|---|
| 405 | TModule(Item2).FileName);
|
|---|
| 406 | 10: Result := CompareTime(TModule(Item1).StartUpTime,
|
|---|
| 407 | TModule(Item2).StartUpTime);
|
|---|
| 408 | end;
|
|---|
| 409 | if ListViewSort.Order = soDown then Result := -Result;
|
|---|
| 410 | end else Result := 0;
|
|---|
| 411 | end;
|
|---|
| 412 |
|
|---|
| 413 | procedure TFormModuleList.ModulesFilterExecute(ListViewSort: TListViewSort);
|
|---|
| 414 | var
|
|---|
| 415 | I: Integer;
|
|---|
| 416 | begin
|
|---|
| 417 | if Assigned(FModuleManager) then
|
|---|
| 418 | begin
|
|---|
| 419 | ListViewSort.Source := nil;
|
|---|
| 420 | ListViewSort.List.Clear;
|
|---|
| 421 | //ListViewSort.List.Assign(FModuleManager.Modules);
|
|---|
| 422 | for I := 0 to FModuleManager.Modules.Count - 1 do
|
|---|
| 423 | with TModule(FModuleManager.Modules[I]) do begin
|
|---|
| 424 | ListViewSort.List.Add(FModuleManager.Modules[I]);
|
|---|
| 425 | end;
|
|---|
| 426 | end else begin
|
|---|
| 427 | ListViewSort.Source := nil;
|
|---|
| 428 | ListViewSort.List.Clear;
|
|---|
| 429 | end;
|
|---|
| 430 | end;
|
|---|
| 431 |
|
|---|
| 432 | procedure TFormModuleList.SetModuleManager(AValue: TModuleManager);
|
|---|
| 433 | begin
|
|---|
| 434 | if FModuleManager = AValue then Exit;
|
|---|
| 435 | FModuleManager := AValue;
|
|---|
| 436 | if not (csDestroying in ComponentState) then Reload;
|
|---|
| 437 | end;
|
|---|
| 438 |
|
|---|
| 439 | procedure TFormModuleList.SetOptions(AValue: TModuleListOptions);
|
|---|
| 440 | begin
|
|---|
| 441 | if FOptions = AValue then Exit;
|
|---|
| 442 | FOptions := AValue;
|
|---|
| 443 | UpdateInterface;
|
|---|
| 444 | end;
|
|---|
| 445 |
|
|---|
| 446 | procedure TFormModuleList.Reload;
|
|---|
| 447 | begin
|
|---|
| 448 | if Assigned(ListViewSort) then
|
|---|
| 449 | ListViewSort.Refresh;
|
|---|
| 450 | end;
|
|---|
| 451 |
|
|---|
| 452 | procedure TFormModuleList.UpdateInterface;
|
|---|
| 453 | begin
|
|---|
| 454 | AUnregister.Enabled := Assigned(ListViewModules.Selected) and
|
|---|
| 455 | (mloAllowRegister in FOptions);
|
|---|
| 456 | AUnregister.Visible := (mloAllowRegister in FOptions);
|
|---|
| 457 | ARegister.Enabled := Assigned(ListViewModules.Selected) and
|
|---|
| 458 | (mloAllowRegister in FOptions);
|
|---|
| 459 | ARegister.Visible := (mloAllowRegister in FOptions);
|
|---|
| 460 | AInstall.Enabled := Assigned(ListViewModules.Selected) and
|
|---|
| 461 | not TModule(ListViewModules.Selected.Data).Installed and
|
|---|
| 462 | (mloAllowInstall in FOptions) and
|
|---|
| 463 | TModule(ListViewModules.Selected.Data).Enabled;
|
|---|
| 464 | AInstall.Visible := (mloAllowInstall in FOptions);
|
|---|
| 465 | AUninstall.Enabled := Assigned(ListViewModules.Selected) and
|
|---|
| 466 | TModule(ListViewModules.Selected.Data).Installed and
|
|---|
| 467 | (mloAllowInstall in FOptions);
|
|---|
| 468 | AUninstall.Visible := (mloAllowInstall in FOptions);
|
|---|
| 469 | AStart.Enabled := Assigned(ListViewModules.Selected) and
|
|---|
| 470 | not TModule(ListViewModules.Selected.Data).Running and
|
|---|
| 471 | (mloAllowStart in FOptions);
|
|---|
| 472 | AStart.Visible := (mloAllowStart in FOptions);
|
|---|
| 473 | AStop.Enabled := Assigned(ListViewModules.Selected) and
|
|---|
| 474 | TModule(ListViewModules.Selected.Data).Running and
|
|---|
| 475 | TModule(ListViewModules.Selected.Data).Installed and
|
|---|
| 476 | (mloAllowStart in FOptions);
|
|---|
| 477 | AStop.Visible := (mloAllowStart in FOptions);
|
|---|
| 478 | AEnable.Enabled := Assigned(ListViewModules.Selected) and
|
|---|
| 479 | not TModule(ListViewModules.Selected.Data).Enabled and
|
|---|
| 480 | (mloAllowEnable in FOptions);
|
|---|
| 481 | AEnable.Visible := (mloAllowEnable in FOptions);
|
|---|
| 482 | ADisable.Enabled := Assigned(ListViewModules.Selected) and
|
|---|
| 483 | TModule(ListViewModules.Selected.Data).Enabled and
|
|---|
| 484 | (mloAllowEnable in FOptions);
|
|---|
| 485 | ADisable.Visible := (mloAllowEnable in FOptions);
|
|---|
| 486 | ListViewModules.Column[0].Visible := (mloShowIdentification in FOptions);
|
|---|
| 487 | ListViewModules.Column[1].Visible := True;
|
|---|
| 488 | ListViewModules.Column[2].Visible := (mloShowEnable in FOptions);
|
|---|
| 489 | ListViewModules.Column[3].Visible := (mloShowInstalled in FOptions);
|
|---|
| 490 | ListViewModules.Column[4].Visible := (mloShowRunning in FOptions);
|
|---|
| 491 | ListViewModules.Column[5].Visible := (mloShowAuthor in FOptions);
|
|---|
| 492 | ListViewModules.Column[6].Visible := (mloShowLicense in FOptions);
|
|---|
| 493 | ListViewModules.Column[7].Visible := (mloShowVersion in FOptions);
|
|---|
| 494 | ListViewModules.Column[8].Visible := (mloShowDependencies in FOptions);
|
|---|
| 495 | ListViewModules.Column[9].Visible := (mloShowFileName in FOptions);
|
|---|
| 496 | ListViewModules.Column[10].Visible := (mloShowStartUpTime in FOptions);
|
|---|
| 497 | Memo1.Visible := (mloShowInfoBar in FOptions);
|
|---|
| 498 | Splitter1.Visible := (mloShowInfoBar in FOptions);
|
|---|
| 499 | end;
|
|---|
| 500 |
|
|---|
| 501 | initialization
|
|---|
| 502 | {$I UFormModuleList.lrs}
|
|---|
| 503 |
|
|---|
| 504 | end.
|
|---|
| 505 |
|
|---|