Changeset 75 for trunk/Packages/ModularSystem
- Timestamp:
- Jun 4, 2024, 12:22:49 AM (6 months ago)
- Location:
- trunk/Packages/ModularSystem
- Files:
-
- 1 added
- 1 edited
- 1 copied
- 8 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/Packages/ModularSystem/FormModuleList.pas
r74 r75 1 unit UFormModuleList; 2 3 {$mode delphi} 1 unit FormModuleList; 4 2 5 3 interface … … 7 5 uses 8 6 Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs, 9 ComCtrls, ExtCtrls, Menus, ActnList, StdCtrls, SpecializedList, DateUtils,10 UListViewSort, UModularSystem;7 ComCtrls, ExtCtrls, Menus, ActnList, StdCtrls, Generics.Collections, DateUtils, 8 ListViewSort, ModularSystem, Common; 11 9 12 10 type … … 87 85 function ModuleToStr(Module: TObject): string; 88 86 87 89 88 implementation 90 89 … … 130 129 if Version <> '' then Item.SubItems.Add(Version) 131 130 else Item.SubItems.Add(' '); 132 Item.SubItems.Add( Dependencies.Implode(',', StrToStr));131 Item.SubItems.Add(Implode(',', Dependencies)); 133 132 if FileName <> '' then Item.SubItems.Add(FileName) 134 133 else Item.SubItems.Add(' '); … … 150 149 if (mloShowLicense in FOptions) and (License <> '') then Memo1.Lines.Add(SLicense + ': ' + License); 151 150 if (mloShowDependencies in FOptions) and (Dependencies.Count > 0) then 152 Memo1.Lines.Add(SDependencies + ': ' + Dependencies.Implode(', ', StrToStr));151 Memo1.Lines.Add(SDependencies + ': ' + Implode(', ', Dependencies)); 153 152 if (mloShowDescription in FOptions) and (Description.Count > 0) then 154 Memo1.Lines.Add(SDescription + ': ' + Description.Implode(', ', StrToStr));153 Memo1.Lines.Add(SDescription + ': ' + Implode(', ', Description)); 155 154 end; 156 155 end; … … 191 190 procedure TFormModuleList.AStartExecute(Sender: TObject); 192 191 var 193 Modules: T ListModule;192 Modules: TModules; 194 193 I: Integer; 195 194 begin … … 199 198 if not Running then 200 199 try 201 Modules := T ListModule.Create;200 Modules := TModules.Create; 202 201 Modules.OwnsObjects := False; 203 202 EnumDependenciesCascade(Modules, [mcNotRunning]); 204 203 if Modules.Count > 0 then begin 205 204 if MessageDlg(Format(SAdditionalModulesStart, [ 206 Identification, Modules. Implode(',', ModuleToStr)]),205 Identification, Modules.GetNames]), 207 206 mtConfirmation, [mbYes, mbNo], 0) = mrYes then 208 207 Start; … … 216 215 procedure TFormModuleList.AStopExecute(Sender: TObject); 217 216 var 218 Modules: T ListModule;217 Modules: TModules; 219 218 I: Integer; 220 219 begin … … 224 223 if Running then 225 224 try 226 Modules := T ListModule.Create;225 Modules := TModules.Create; 227 226 Modules.OwnsObjects := False; 228 227 EnumSuperiorDependenciesCascade(Modules, [mcRunning]); 229 228 if Modules.Count > 0 then begin 230 229 if MessageDlg(Format(SAdditionalModulesStop, [ 231 Identification, 232 Modules.Implode(',', ModuleToStr)]), 230 Identification, Modules.GetNames]), 233 231 mtConfirmation, [mbYes, mbNo], 0) = mrYes then 234 232 Stop; … … 242 240 procedure TFormModuleList.AUninstallExecute(Sender: TObject); 243 241 var 244 Modules: T ListModule;242 Modules: TModules; 245 243 I: Integer; 246 244 begin … … 250 248 if Installed then 251 249 try 252 Modules := T ListModule.Create;250 Modules := TModules.Create; 253 251 Modules.OwnsObjects := False; 254 252 EnumSuperiorDependenciesCascade(Modules, [mcInstalled]); 255 253 if Modules.Count > 0 then begin 256 254 if MessageDlg(Format(SAdditionalModulesUninstall, [ 257 Identification, 258 Modules.Implode(',', ModuleToStr)]), 255 Identification, Modules.GetNames]), 259 256 mtConfirmation, [mbYes, mbNo], 0) = mrYes then 260 257 Uninstall; … … 275 272 procedure TFormModuleList.AInstallExecute(Sender: TObject); 276 273 var 277 Modules: T ListModule;274 Modules: TModules; 278 275 I: Integer; 279 276 begin … … 283 280 if not Installed then 284 281 try 285 Modules := T ListModule.Create;282 Modules := TModules.Create; 286 283 Modules.OwnsObjects := False; 287 284 EnumDependenciesCascade(Modules, [mcNotInstalled]); 288 285 if Modules.Count > 0 then begin 289 286 if MessageDlg(Format(SAdditionalModulesInstall, [ 290 Identification, 291 Modules.Implode(',', ModuleToStr)]), 287 Identification, Modules.GetNames]), 292 288 mtConfirmation, [mbYes, mbNo], 0) = mrYes then 293 289 Install; … … 301 297 procedure TFormModuleList.AEnableExecute(Sender: TObject); 302 298 var 303 Modules: T ListModule;299 Modules: TModules; 304 300 I: Integer; 305 301 begin … … 309 305 if not Enabled then 310 306 try 311 Modules := T ListModule.Create;307 Modules := TModules.Create; 312 308 Modules.OwnsObjects := False; 313 309 EnumDependenciesCascade(Modules, [mcNotRunning]); 314 310 if Modules.Count > 0 then begin 315 311 if MessageDlg(Format(SAdditionalModulesStart, [ 316 Identification, Modules. Implode(',', ModuleToStr)]),312 Identification, Modules.GetNames]), 317 313 mtConfirmation, [mbYes, mbNo], 0) = mrYes then begin 318 314 Enable; … … 331 327 procedure TFormModuleList.ADisableExecute(Sender: TObject); 332 328 var 333 Modules: T ListModule;329 Modules: TModules; 334 330 I: Integer; 335 331 begin … … 339 335 if Enabled then 340 336 try 341 Modules := T ListModule.Create;337 Modules := TModules.Create; 342 338 Modules.OwnsObjects := False; 343 339 EnumSuperiorDependenciesCascade(Modules, [mcInstalled]); 344 340 if Modules.Count > 0 then begin 345 341 if MessageDlg(Format(SAdditionalModulesUninstall, [ 346 Identification, 347 Modules.Implode(',', ModuleToStr)]), 342 Identification, Modules.GetNames]), 348 343 mtConfirmation, [mbYes, mbNo], 0) = mrYes then begin 349 344 Stop; … … 400 395 7: Result := CompareString(TModule(Item1).Version, TModule( 401 396 Item2).Version); 402 8: Result := CompareString( TModule(Item1).Dependencies.Implode(',', StrToStr),403 TModule(Item2).Dependencies.Implode(',', StrToStr));397 8: Result := CompareString(Implode(',', TModule(Item1).Dependencies), 398 Implode(',', TModule(Item2).Dependencies)); 404 399 9: Result := CompareString(TModule(Item1).FileName, 405 400 TModule(Item2).FileName); … … 500 495 501 496 initialization 502 {$I UFormModuleList.lrs}497 {$I FormModuleList.lrs} 503 498 504 499 end. -
trunk/Packages/ModularSystem/Language/ModularSystem.cs.po
r74 r75 10 10 "Content-Transfer-Encoding: 8bit\n" 11 11 12 #: umodularsystem.smodulenotfound 12 #: modularsystem.smodulenotfound 13 #, object-pascal-format 14 msgctxt "modularsystem.smodulenotfound" 13 15 msgid "Module \"%1:s\" not found as dependency for module \"%0:s\"" 14 msgstr " Pro modul \"%0:s\" nenalezen závislý modul \"%1:s\""16 msgstr "" 15 17 -
trunk/Packages/ModularSystem/Language/ModularSystem.pot
r74 r75 2 2 msgstr "Content-Type: text/plain; charset=UTF-8" 3 3 4 #: umodularsystem.smodulenotfound 4 #: modularsystem.smodulenotfound 5 #, object-pascal-format 6 msgctxt "modularsystem.smodulenotfound" 5 7 msgid "Module \"%1:s\" not found as dependency for module \"%0:s\"" 6 8 msgstr "" -
trunk/Packages/ModularSystem/ModularSystem.lpk
r73 r75 1 <?xml version="1.0" ?>1 <?xml version="1.0" encoding="UTF-8"?> 2 2 <CONFIG> 3 <Package Version=" 4">3 <Package Version="5"> 4 4 <PathDelim Value="\"/> 5 5 <Name Value="ModularSystem"/> 6 <Type Value="RunAndDesignTime"/> 6 7 <Author Value="Chronos (robie@centrum.cz)"/> 7 8 <CompilerOptions> … … 11 12 <UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/> 12 13 </SearchPaths> 13 <Other> 14 <CompilerMessages> 15 <MsgFileName Value=""/> 16 </CompilerMessages> 17 <CompilerPath Value="$(CompPath)"/> 18 </Other> 14 <Parsing> 15 <SyntaxOptions> 16 <SyntaxMode Value="Delphi"/> 17 </SyntaxOptions> 18 </Parsing> 19 19 </CompilerOptions> 20 20 <Description Value="Modular system"/> 21 21 <License Value="GNU/LGPLv3"/> 22 22 <Version Minor="2"/> 23 <Files Count=" 2">23 <Files Count="3"> 24 24 <Item1> 25 <Filename Value=" UModularSystem.pas"/>25 <Filename Value="ModularSystem.pas"/> 26 26 <HasRegisterProc Value="True"/> 27 <UnitName Value=" UModularSystem"/>27 <UnitName Value="ModularSystem"/> 28 28 </Item1> 29 29 <Item2> 30 <Filename Value=" UFormModuleList.pas"/>31 <UnitName Value=" UFormModuleList"/>30 <Filename Value="FormModuleList.pas"/> 31 <UnitName Value="FormModuleList"/> 32 32 </Item2> 33 <Item3> 34 <Filename Value="ModularSystemPackage.pas"/> 35 <Type Value="Main Unit"/> 36 <UnitName Value="ModularSystemPackage"/> 37 </Item3> 33 38 </Files> 39 <CompatibilityMode Value="True"/> 34 40 <i18n> 35 41 <EnableI18N Value="True"/> … … 37 43 <EnableI18NForLFM Value="True"/> 38 44 </i18n> 39 <Type Value="RunAndDesignTime"/>40 45 <RequiredPkgs Count="3"> 41 46 <Item1> -
trunk/Packages/ModularSystem/ModularSystem.pas
r74 r75 1 unit UModularSystem; 2 3 {$mode Delphi}{$H+} 1 unit ModularSystem; 4 2 5 3 interface 6 4 7 5 uses 8 Classes, SysUtils, URegistry, SpecializedList;6 Classes, SysUtils, RegistryEx, Generics.Collections; 9 7 10 8 type 11 9 TModuleManager = class; 12 10 TModule = class; 13 T ListModule= class;11 TModules = class; 14 12 15 13 TAPI = class(TComponent) 16 17 14 end; 18 15 … … 39 36 FLicense: string; 40 37 FAuthor: string; 41 FDependencies: T ListString;42 FDescription: T ListString;38 FDependencies: TStringList; 39 FDescription: TStringList; 43 40 FFileName: string; 44 41 FWebSite: string; … … 65 62 procedure Reinstall; 66 63 procedure Upgrade; 67 procedure EnumDependenciesCascade(ModuleList: T ListModule;64 procedure EnumDependenciesCascade(ModuleList: TModules; 68 65 Conditions: TModuleConditions = [mcAll]); 69 procedure EnumSuperiorDependenciesCascade(ModuleList: T ListModule;66 procedure EnumSuperiorDependenciesCascade(ModuleList: TModules; 70 67 Conditions: TModuleConditions = [mcAll]); 71 68 procedure SetInstalledState(Value: Boolean); … … 84 81 property License: string read FLicense write FLicense; 85 82 property Author: string read FAuthor write FAuthor; 86 property Dependencies: T ListStringread FDependencies write FDependencies;87 property Description: T ListStringread FDescription write FDescription;83 property Dependencies: TStringList read FDependencies write FDependencies; 84 property Description: TStringList read FDescription write FDescription; 88 85 property FileName: string read FFileName write FFileName; 89 86 property Category: string read FCategory write FCategory; … … 92 89 end; 93 90 94 { TListModule } 95 96 TListModule = class(TListObject) 97 private 91 { TModules } 92 93 TModules = class(TObjectList<TModule>) 98 94 public 99 95 procedure Perform(Actions: array of TModuleAction; Conditions: TModuleConditions = [mcAll]); 100 96 function FindByName(Name: string): TModule; 97 function GetNames: string; 101 98 end; 102 99 103 100 TModuleManagerOption = (moAutoInstallOnRun, moAuto); 104 101 TModuleManagerOptions = set of TModuleManagerOption; 102 105 103 { TModuleManager } 106 104 … … 114 112 procedure DoUpdate(Sender: TObject); 115 113 public 116 Modules: T ListModule; // TObjectList<TModule>114 Modules: TModules; 117 115 function ModuleRunning(Name: string): Boolean; 118 procedure EnumDependenciesCascade(Module: TModule; ModuleList: T ListModule;116 procedure EnumDependenciesCascade(Module: TModule; ModuleList: TModules; 119 117 Conditions: TModuleConditions = [mcAll]); 120 118 procedure EnumSuperiorDependenciesCascade(Module: TModule; 121 ModuleList: T ListModule; Conditions: TModuleConditions = [mcAll]);119 ModuleList: TModules; Conditions: TModuleConditions = [mcAll]); 122 120 procedure RegisterModule(Module: TModule); 123 121 procedure UnregisterModule(Module: TModule); … … 145 143 end; 146 144 147 { T ListModule}148 149 procedure T ListModule.Perform(Actions: array of TModuleAction;145 { TModules } 146 147 procedure TModules.Perform(Actions: array of TModuleAction; 150 148 Conditions: TModuleConditions = [mcAll]); 151 149 var … … 153 151 A: Integer; 154 152 begin 155 try156 BeginUpdate;157 153 for I := 0 to Count - 1 do 158 154 with TModule(Items[I]) do … … 173 169 if Actions[A] = maDisable then Disable; 174 170 end; 175 finally 176 EndUpdate; 177 end; 178 end; 179 180 function TListModule.FindByName(Name: string): TModule; 171 end; 172 173 function TModules.FindByName(Name: string): TModule; 181 174 var 182 175 I: Integer; … … 188 181 end; 189 182 183 function TModules.GetNames: string; 184 var 185 I: Integer; 186 begin 187 Result := ''; 188 for I := 0 to Count - 1 do 189 Result := Result + ', ' + Items[I].Identification; 190 Result := Copy(Result, 3, MaxInt); 191 end; 192 190 193 { TModuleManager } 191 194 … … 216 219 217 220 procedure TModuleManager.EnumDependenciesCascade(Module: TModule; 218 ModuleList: T ListModule; Conditions: TModuleConditions = [mcAll]);221 ModuleList: TModules; Conditions: TModuleConditions = [mcAll]); 219 222 var 220 223 DepModule: TModule; 224 DepModuleName: string; 221 225 I: Integer; 222 226 begin 223 227 for I := 0 to Module.Dependencies.Count - 1 do begin 224 DepModule := Modules.FindByName(Module.Dependencies[I]); 228 DepModuleName := Module.Dependencies[I]; 229 DepModule := Modules.FindByName(DepModuleName); 225 230 if Assigned(DepModule) then 226 231 with DepModule do begin … … 236 241 Self.EnumDependenciesCascade(DepModule, ModuleList); 237 242 end; 238 end else raise Exception.CreateFmt(SModuleNotFound, [ DepModule.Identification]);243 end else raise Exception.CreateFmt(SModuleNotFound, [Module.Dependencies[I], Module.Identification]); 239 244 end; 240 245 end; 241 246 242 247 procedure TModuleManager.EnumSuperiorDependenciesCascade(Module: TModule; 243 ModuleList: T ListModule; Conditions: TModuleConditions = [mcAll]);248 ModuleList: TModules; Conditions: TModuleConditions = [mcAll]); 244 249 var 245 250 I: Integer; … … 267 272 Module.FManager := Self; 268 273 Module.API := API; 269 Modules.Update;274 //Modules.Update; 270 275 end; 271 276 … … 273 278 begin 274 279 Modules.Remove(Module); 275 Modules.Update;280 //Modules.Update; 276 281 end; 277 282 … … 279 284 begin 280 285 inherited; 281 Modules := T ListModule.Create;286 Modules := TModules.Create; 282 287 Modules.OwnsObjects := False; 283 Modules.OnUpdate := DoUpdate;288 //Modules.OnUpdate := DoUpdate; 284 289 end; 285 290 … … 362 367 procedure TModule.Enable; 363 368 var 364 List: T ListModule;369 List: TModules; 365 370 begin 366 371 if Enabled then Exit; 367 372 FEnabled := True; 368 373 try 369 List := T ListModule.Create;374 List := TModules.Create; 370 375 List.OwnsObjects := False; 371 376 EnumDependenciesCascade(List, [mcNotEnabled]); … … 380 385 procedure TModule.Disable; 381 386 var 382 List: T ListModule;387 List: TModules; 383 388 begin 384 389 if not Enabled then Exit; … … 386 391 FEnabled := False; 387 392 try 388 List := T ListModule.Create;393 List := TModules.Create; 389 394 List.OwnsObjects := False; 390 395 EnumSuperiorDependenciesCascade(List, [mcEnabled]); … … 393 398 List.Free; 394 399 end; 395 Manager.Modules.Update;400 //Manager.Modules.Update; 396 401 end; 397 402 … … 418 423 procedure TModule.Start; 419 424 var 420 List: T ListModule;425 List: TModules; 421 426 StartTime: TDateTime; 422 427 begin … … 424 429 if not Installed then Install; // Auto install not installed modules 425 430 try 426 List := T ListModule.Create;431 List := TModules.Create; 427 432 List.OwnsObjects := False; 428 433 EnumDependenciesCascade(List, [mcNotRunning]); … … 435 440 FStartUpTime := Now - StartTime; 436 441 FRunning := True; 437 Manager.Modules.Update;442 //Manager.Modules.Update; 438 443 end; 439 444 440 445 procedure TModule.Stop; 441 446 var 442 List: T ListModule;447 List: TModules; 443 448 begin 444 449 if not Running then Exit; 445 450 FRunning := False; 446 451 try 447 List := T ListModule.Create;452 List := TModules.Create; 448 453 List.OwnsObjects := False; 449 454 EnumSuperiorDependenciesCascade(List, [mcRunning]); … … 453 458 end; 454 459 DoStop; 455 Manager.Modules.Update;460 //Manager.Modules.Update; 456 461 end; 457 462 … … 464 469 procedure TModule.Install; 465 470 var 466 List: T ListModule;471 List: TModules; 467 472 begin 468 473 if Installed then Exit; 469 474 try 470 List := T ListModule.Create;475 List := TModules.Create; 471 476 List.OwnsObjects := False; 472 477 EnumDependenciesCascade(List, [mcNotInstalled]); … … 478 483 DoInstall; 479 484 //Enable; // Auto enable installed module 480 Manager.Modules.Update;485 //Manager.Modules.Update; 481 486 end; 482 487 483 488 procedure TModule.Uninstall; 484 489 var 485 List: T ListModule;490 List: TModules; 486 491 begin 487 492 if not Installed then Exit; 488 493 if Enabled then Disable; // Auto disable uninstalled module 489 494 try 490 List := T ListModule.Create;495 List := TModules.Create; 491 496 List.OwnsObjects := False; 492 497 EnumSuperiorDependenciesCascade(List, [mcInstalled]); … … 497 502 FInstalled := False; 498 503 DoUninstall; 499 Manager.Modules.Update;504 //Manager.Modules.Update; 500 505 end; 501 506 … … 515 520 Start; 516 521 end else DoUpgrade; 517 Manager.Modules.Update;518 end; 519 520 procedure TModule.EnumDependenciesCascade(ModuleList: T ListModule;522 //Manager.Modules.Update; 523 end; 524 525 procedure TModule.EnumDependenciesCascade(ModuleList: TModules; 521 526 Conditions: TModuleConditions = [mcAll]); 522 527 begin … … 525 530 end; 526 531 527 procedure TModule.EnumSuperiorDependenciesCascade(ModuleList: T ListModule;532 procedure TModule.EnumSuperiorDependenciesCascade(ModuleList: TModules; 528 533 Conditions: TModuleConditions = [mcAll]); 529 534 begin … … 535 540 begin 536 541 FInstalled := Value; 537 Manager.Modules.Update;542 //Manager.Modules.Update; 538 543 end; 539 544 … … 541 546 begin 542 547 inherited; 543 Dependencies := T ListString.Create;544 Description := T ListString.Create;548 Dependencies := TStringList.Create; 549 Description := TStringList.Create; 545 550 end; 546 551 -
trunk/Packages/ModularSystem/ModularSystemPackage.pas
r74 r75 3 3 } 4 4 5 unit ModularSystem ;5 unit ModularSystemPackage; 6 6 7 {$warn 5023 off : no warning about unused units} 7 8 interface 8 9 9 10 uses 10 UModularSystem, UFormModuleList, LazarusPackageIntf;11 ModularSystem, FormModuleList, LazarusPackageIntf; 11 12 12 13 implementation … … 14 15 procedure Register; 15 16 begin 16 RegisterUnit(' UModularSystem', @UModularSystem.Register);17 RegisterUnit('ModularSystem', @ModularSystem.Register); 17 18 end; 18 19
Note:
See TracChangeset
for help on using the changeset viewer.