Ignore:
Timestamp:
Jun 4, 2024, 12:22:49 AM (6 months ago)
Author:
chronos
Message:
  • Modified: Removed U prefix from unit names.
  • Modified: Updated Common package.
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}
     1unit FormModuleList;
    42
    53interface
     
    75uses
    86  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;
    119
    1210type
     
    8785function ModuleToStr(Module: TObject): string;
    8886
     87
    8988implementation
    9089
     
    130129    if Version <> '' then Item.SubItems.Add(Version)
    131130      else Item.SubItems.Add(' ');
    132     Item.SubItems.Add(Dependencies.Implode(',', StrToStr));
     131    Item.SubItems.Add(Implode(',', Dependencies));
    133132    if FileName <> '' then Item.SubItems.Add(FileName)
    134133      else Item.SubItems.Add(' ');
     
    150149    if (mloShowLicense in FOptions) and (License <> '') then Memo1.Lines.Add(SLicense + ': ' + License);
    151150    if (mloShowDependencies in FOptions) and (Dependencies.Count > 0) then
    152       Memo1.Lines.Add(SDependencies + ': ' + Dependencies.Implode(', ', StrToStr));
     151      Memo1.Lines.Add(SDependencies + ': ' + Implode(', ', Dependencies));
    153152    if (mloShowDescription in FOptions) and (Description.Count > 0) then
    154       Memo1.Lines.Add(SDescription + ': ' + Description.Implode(', ', StrToStr));
     153      Memo1.Lines.Add(SDescription + ': ' + Implode(', ', Description));
    155154  end;
    156155end;
     
    191190procedure TFormModuleList.AStartExecute(Sender: TObject);
    192191var
    193   Modules: TListModule;
     192  Modules: TModules;
    194193  I: Integer;
    195194begin
     
    199198  if not Running then
    200199  try
    201     Modules := TListModule.Create;
     200    Modules := TModules.Create;
    202201    Modules.OwnsObjects := False;
    203202    EnumDependenciesCascade(Modules, [mcNotRunning]);
    204203    if Modules.Count > 0 then begin
    205204      if MessageDlg(Format(SAdditionalModulesStart, [
    206       Identification, Modules.Implode(',', ModuleToStr)]),
     205      Identification, Modules.GetNames]),
    207206      mtConfirmation, [mbYes, mbNo], 0) = mrYes then
    208207        Start;
     
    216215procedure TFormModuleList.AStopExecute(Sender: TObject);
    217216var
    218   Modules: TListModule;
     217  Modules: TModules;
    219218  I: Integer;
    220219begin
     
    224223  if Running then
    225224  try
    226     Modules := TListModule.Create;
     225    Modules := TModules.Create;
    227226    Modules.OwnsObjects := False;
    228227    EnumSuperiorDependenciesCascade(Modules, [mcRunning]);
    229228    if Modules.Count > 0 then begin
    230229      if MessageDlg(Format(SAdditionalModulesStop, [
    231       Identification,
    232       Modules.Implode(',', ModuleToStr)]),
     230      Identification, Modules.GetNames]),
    233231      mtConfirmation, [mbYes, mbNo], 0) = mrYes then
    234232        Stop;
     
    242240procedure TFormModuleList.AUninstallExecute(Sender: TObject);
    243241var
    244   Modules: TListModule;
     242  Modules: TModules;
    245243  I: Integer;
    246244begin
     
    250248  if Installed then
    251249  try
    252     Modules := TListModule.Create;
     250    Modules := TModules.Create;
    253251    Modules.OwnsObjects := False;
    254252    EnumSuperiorDependenciesCascade(Modules, [mcInstalled]);
    255253    if Modules.Count > 0 then begin
    256254      if MessageDlg(Format(SAdditionalModulesUninstall, [
    257       Identification,
    258       Modules.Implode(',', ModuleToStr)]),
     255      Identification, Modules.GetNames]),
    259256      mtConfirmation, [mbYes, mbNo], 0) = mrYes then
    260257        Uninstall;
     
    275272procedure TFormModuleList.AInstallExecute(Sender: TObject);
    276273var
    277   Modules: TListModule;
     274  Modules: TModules;
    278275  I: Integer;
    279276begin
     
    283280  if not Installed then
    284281  try
    285     Modules := TListModule.Create;
     282    Modules := TModules.Create;
    286283    Modules.OwnsObjects := False;
    287284    EnumDependenciesCascade(Modules, [mcNotInstalled]);
    288285    if Modules.Count > 0 then begin
    289286      if MessageDlg(Format(SAdditionalModulesInstall, [
    290       Identification,
    291       Modules.Implode(',', ModuleToStr)]),
     287      Identification, Modules.GetNames]),
    292288      mtConfirmation, [mbYes, mbNo], 0) = mrYes then
    293289        Install;
     
    301297procedure TFormModuleList.AEnableExecute(Sender: TObject);
    302298var
    303   Modules: TListModule;
     299  Modules: TModules;
    304300  I: Integer;
    305301begin
     
    309305  if not Enabled then
    310306  try
    311     Modules := TListModule.Create;
     307    Modules := TModules.Create;
    312308    Modules.OwnsObjects := False;
    313309    EnumDependenciesCascade(Modules, [mcNotRunning]);
    314310    if Modules.Count > 0 then begin
    315311      if MessageDlg(Format(SAdditionalModulesStart, [
    316       Identification, Modules.Implode(',', ModuleToStr)]),
     312      Identification, Modules.GetNames]),
    317313      mtConfirmation, [mbYes, mbNo], 0) = mrYes then begin
    318314        Enable;
     
    331327procedure TFormModuleList.ADisableExecute(Sender: TObject);
    332328var
    333   Modules: TListModule;
     329  Modules: TModules;
    334330  I: Integer;
    335331begin
     
    339335  if Enabled then
    340336  try
    341     Modules := TListModule.Create;
     337    Modules := TModules.Create;
    342338    Modules.OwnsObjects := False;
    343339    EnumSuperiorDependenciesCascade(Modules, [mcInstalled]);
    344340    if Modules.Count > 0 then begin
    345341      if MessageDlg(Format(SAdditionalModulesUninstall, [
    346       Identification,
    347       Modules.Implode(',', ModuleToStr)]),
     342      Identification, Modules.GetNames]),
    348343      mtConfirmation, [mbYes, mbNo], 0) = mrYes then begin
    349344        Stop;
     
    400395      7: Result := CompareString(TModule(Item1).Version, TModule(
    401396        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));
    404399      9: Result := CompareString(TModule(Item1).FileName,
    405400        TModule(Item2).FileName);
     
    500495
    501496initialization
    502   {$I UFormModuleList.lrs}
     497  {$I FormModuleList.lrs}
    503498
    504499end.
  • trunk/Packages/ModularSystem/Language/ModularSystem.cs.po

    r74 r75  
    1010"Content-Transfer-Encoding: 8bit\n"
    1111
    12 #: umodularsystem.smodulenotfound
     12#: modularsystem.smodulenotfound
     13#, object-pascal-format
     14msgctxt "modularsystem.smodulenotfound"
    1315msgid "Module \"%1:s\" not found as dependency for module \"%0:s\""
    14 msgstr "Pro modul \"%0:s\" nenalezen závislý modul \"%1:s\""
     16msgstr ""
    1517
  • trunk/Packages/ModularSystem/Language/ModularSystem.pot

    r74 r75  
    22msgstr "Content-Type: text/plain; charset=UTF-8"
    33
    4 #: umodularsystem.smodulenotfound
     4#: modularsystem.smodulenotfound
     5#, object-pascal-format
     6msgctxt "modularsystem.smodulenotfound"
    57msgid "Module \"%1:s\" not found as dependency for module \"%0:s\""
    68msgstr ""
  • trunk/Packages/ModularSystem/ModularSystem.lpk

    r73 r75  
    1 <?xml version="1.0"?>
     1<?xml version="1.0" encoding="UTF-8"?>
    22<CONFIG>
    3   <Package Version="4">
     3  <Package Version="5">
    44    <PathDelim Value="\"/>
    55    <Name Value="ModularSystem"/>
     6    <Type Value="RunAndDesignTime"/>
    67    <Author Value="Chronos (robie@centrum.cz)"/>
    78    <CompilerOptions>
     
    1112        <UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
    1213      </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>
    1919    </CompilerOptions>
    2020    <Description Value="Modular system"/>
    2121    <License Value="GNU/LGPLv3"/>
    2222    <Version Minor="2"/>
    23     <Files Count="2">
     23    <Files Count="3">
    2424      <Item1>
    25         <Filename Value="UModularSystem.pas"/>
     25        <Filename Value="ModularSystem.pas"/>
    2626        <HasRegisterProc Value="True"/>
    27         <UnitName Value="UModularSystem"/>
     27        <UnitName Value="ModularSystem"/>
    2828      </Item1>
    2929      <Item2>
    30         <Filename Value="UFormModuleList.pas"/>
    31         <UnitName Value="UFormModuleList"/>
     30        <Filename Value="FormModuleList.pas"/>
     31        <UnitName Value="FormModuleList"/>
    3232      </Item2>
     33      <Item3>
     34        <Filename Value="ModularSystemPackage.pas"/>
     35        <Type Value="Main Unit"/>
     36        <UnitName Value="ModularSystemPackage"/>
     37      </Item3>
    3338    </Files>
     39    <CompatibilityMode Value="True"/>
    3440    <i18n>
    3541      <EnableI18N Value="True"/>
     
    3743      <EnableI18NForLFM Value="True"/>
    3844    </i18n>
    39     <Type Value="RunAndDesignTime"/>
    4045    <RequiredPkgs Count="3">
    4146      <Item1>
  • trunk/Packages/ModularSystem/ModularSystem.pas

    r74 r75  
    1 unit UModularSystem;
    2 
    3 {$mode Delphi}{$H+}
     1unit ModularSystem;
    42
    53interface
    64
    75uses
    8   Classes, SysUtils, URegistry, SpecializedList;
     6  Classes, SysUtils, RegistryEx, Generics.Collections;
    97
    108type
    119  TModuleManager = class;
    1210  TModule = class;
    13   TListModule = class;
     11  TModules = class;
    1412
    1513  TAPI = class(TComponent)
    16 
    1714  end;
    1815
     
    3936    FLicense: string;
    4037    FAuthor: string;
    41     FDependencies: TListString;
    42     FDescription: TListString;
     38    FDependencies: TStringList;
     39    FDescription: TStringList;
    4340    FFileName: string;
    4441    FWebSite: string;
     
    6562    procedure Reinstall;
    6663    procedure Upgrade;
    67     procedure EnumDependenciesCascade(ModuleList: TListModule;
     64    procedure EnumDependenciesCascade(ModuleList: TModules;
    6865      Conditions: TModuleConditions = [mcAll]);
    69     procedure EnumSuperiorDependenciesCascade(ModuleList: TListModule;
     66    procedure EnumSuperiorDependenciesCascade(ModuleList: TModules;
    7067      Conditions: TModuleConditions = [mcAll]);
    7168    procedure SetInstalledState(Value: Boolean);
     
    8481    property License: string read FLicense write FLicense;
    8582    property Author: string read FAuthor write FAuthor;
    86     property Dependencies: TListString read FDependencies write FDependencies;
    87     property Description: TListString read FDescription write FDescription;
     83    property Dependencies: TStringList read FDependencies write FDependencies;
     84    property Description: TStringList read FDescription write FDescription;
    8885    property FileName: string read FFileName write FFileName;
    8986    property Category: string read FCategory write FCategory;
     
    9289  end;
    9390
    94   { TListModule }
    95 
    96   TListModule = class(TListObject)
    97   private
     91  { TModules }
     92
     93  TModules = class(TObjectList<TModule>)
    9894  public
    9995    procedure Perform(Actions: array of TModuleAction; Conditions: TModuleConditions = [mcAll]);
    10096    function FindByName(Name: string): TModule;
     97    function GetNames: string;
    10198  end;
    10299
    103100  TModuleManagerOption = (moAutoInstallOnRun, moAuto);
    104101  TModuleManagerOptions = set of TModuleManagerOption;
     102
    105103  { TModuleManager }
    106104
     
    114112    procedure DoUpdate(Sender: TObject);
    115113  public
    116     Modules: TListModule; // TObjectList<TModule>
     114    Modules: TModules;
    117115    function ModuleRunning(Name: string): Boolean;
    118     procedure EnumDependenciesCascade(Module: TModule; ModuleList: TListModule;
     116    procedure EnumDependenciesCascade(Module: TModule; ModuleList: TModules;
    119117      Conditions: TModuleConditions = [mcAll]);
    120118    procedure EnumSuperiorDependenciesCascade(Module: TModule;
    121       ModuleList: TListModule; Conditions: TModuleConditions = [mcAll]);
     119      ModuleList: TModules; Conditions: TModuleConditions = [mcAll]);
    122120    procedure RegisterModule(Module: TModule);
    123121    procedure UnregisterModule(Module: TModule);
     
    145143end;
    146144
    147 { TListModule }
    148 
    149 procedure TListModule.Perform(Actions:  array of TModuleAction;
     145{ TModules }
     146
     147procedure TModules.Perform(Actions:  array of TModuleAction;
    150148  Conditions: TModuleConditions = [mcAll]);
    151149var
     
    153151  A: Integer;
    154152begin
    155   try
    156     BeginUpdate;
    157153  for I := 0 to Count - 1 do
    158154  with TModule(Items[I]) do
     
    173169      if Actions[A] = maDisable then Disable;
    174170    end;
    175   finally
    176     EndUpdate;
    177   end;
    178 end;
    179 
    180 function TListModule.FindByName(Name: string): TModule;
     171end;
     172
     173function TModules.FindByName(Name: string): TModule;
    181174var
    182175  I: Integer;
     
    188181end;
    189182
     183function TModules.GetNames: string;
     184var
     185  I: Integer;
     186begin
     187  Result := '';
     188  for I := 0 to Count - 1 do
     189    Result := Result + ', ' + Items[I].Identification;
     190  Result := Copy(Result, 3, MaxInt);
     191end;
     192
    190193{ TModuleManager }
    191194
     
    216219
    217220procedure TModuleManager.EnumDependenciesCascade(Module: TModule;
    218   ModuleList: TListModule; Conditions: TModuleConditions = [mcAll]);
     221  ModuleList: TModules; Conditions: TModuleConditions = [mcAll]);
    219222var
    220223  DepModule: TModule;
     224  DepModuleName: string;
    221225  I: Integer;
    222226begin
    223227  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);
    225230    if Assigned(DepModule) then
    226231    with DepModule do begin
     
    236241          Self.EnumDependenciesCascade(DepModule, ModuleList);
    237242        end;
    238     end else raise Exception.CreateFmt(SModuleNotFound, [DepModule.Identification]);
     243    end else raise Exception.CreateFmt(SModuleNotFound, [Module.Dependencies[I], Module.Identification]);
    239244  end;
    240245end;
    241246
    242247procedure TModuleManager.EnumSuperiorDependenciesCascade(Module: TModule;
    243   ModuleList: TListModule; Conditions: TModuleConditions = [mcAll]);
     248  ModuleList: TModules; Conditions: TModuleConditions = [mcAll]);
    244249var
    245250  I: Integer;
     
    267272  Module.FManager := Self;
    268273  Module.API := API;
    269   Modules.Update;
     274  //Modules.Update;
    270275end;
    271276
     
    273278begin
    274279  Modules.Remove(Module);
    275   Modules.Update;
     280  //Modules.Update;
    276281end;
    277282
     
    279284begin
    280285  inherited;
    281   Modules := TListModule.Create;
     286  Modules := TModules.Create;
    282287  Modules.OwnsObjects := False;
    283   Modules.OnUpdate := DoUpdate;
     288  //Modules.OnUpdate := DoUpdate;
    284289end;
    285290
     
    362367procedure TModule.Enable;
    363368var
    364   List: TListModule;
     369  List: TModules;
    365370begin
    366371  if Enabled then Exit;
    367372  FEnabled := True;
    368373  try
    369     List := TListModule.Create;
     374    List := TModules.Create;
    370375    List.OwnsObjects := False;
    371376    EnumDependenciesCascade(List, [mcNotEnabled]);
     
    380385procedure TModule.Disable;
    381386var
    382   List: TListModule;
     387  List: TModules;
    383388begin
    384389  if not Enabled then Exit;
     
    386391  FEnabled := False;
    387392  try
    388     List := TListModule.Create;
     393    List := TModules.Create;
    389394    List.OwnsObjects := False;
    390395    EnumSuperiorDependenciesCascade(List, [mcEnabled]);
     
    393398    List.Free;
    394399  end;
    395   Manager.Modules.Update;
     400  //Manager.Modules.Update;
    396401end;
    397402
     
    418423procedure TModule.Start;
    419424var
    420   List: TListModule;
     425  List: TModules;
    421426  StartTime: TDateTime;
    422427begin
     
    424429  if not Installed then Install;  // Auto install not installed modules
    425430  try
    426     List := TListModule.Create;
     431    List := TModules.Create;
    427432    List.OwnsObjects := False;
    428433    EnumDependenciesCascade(List, [mcNotRunning]);
     
    435440  FStartUpTime := Now - StartTime;
    436441  FRunning := True;
    437   Manager.Modules.Update;
     442  //Manager.Modules.Update;
    438443end;
    439444
    440445procedure TModule.Stop;
    441446var
    442   List: TListModule;
     447  List: TModules;
    443448begin
    444449  if not Running then Exit;
    445450  FRunning := False;
    446451  try
    447     List := TListModule.Create;
     452    List := TModules.Create;
    448453    List.OwnsObjects := False;
    449454    EnumSuperiorDependenciesCascade(List, [mcRunning]);
     
    453458  end;
    454459  DoStop;
    455   Manager.Modules.Update;
     460  //Manager.Modules.Update;
    456461end;
    457462
     
    464469procedure TModule.Install;
    465470var
    466   List: TListModule;
     471  List: TModules;
    467472begin
    468473  if Installed then Exit;
    469474  try
    470     List := TListModule.Create;
     475    List := TModules.Create;
    471476    List.OwnsObjects := False;
    472477    EnumDependenciesCascade(List, [mcNotInstalled]);
     
    478483  DoInstall;
    479484  //Enable; // Auto enable installed module
    480   Manager.Modules.Update;
     485  //Manager.Modules.Update;
    481486end;
    482487
    483488procedure TModule.Uninstall;
    484489var
    485   List: TListModule;
     490  List: TModules;
    486491begin
    487492  if not Installed then Exit;
    488493  if Enabled then Disable; // Auto disable uninstalled module
    489494  try
    490     List := TListModule.Create;
     495    List := TModules.Create;
    491496    List.OwnsObjects := False;
    492497    EnumSuperiorDependenciesCascade(List, [mcInstalled]);
     
    497502  FInstalled := False;
    498503  DoUninstall;
    499   Manager.Modules.Update;
     504  //Manager.Modules.Update;
    500505end;
    501506
     
    515520    Start;
    516521  end else DoUpgrade;
    517   Manager.Modules.Update;
    518 end;
    519 
    520 procedure TModule.EnumDependenciesCascade(ModuleList: TListModule;
     522  //Manager.Modules.Update;
     523end;
     524
     525procedure TModule.EnumDependenciesCascade(ModuleList: TModules;
    521526  Conditions: TModuleConditions = [mcAll]);
    522527begin
     
    525530end;
    526531
    527 procedure TModule.EnumSuperiorDependenciesCascade(ModuleList: TListModule;
     532procedure TModule.EnumSuperiorDependenciesCascade(ModuleList: TModules;
    528533  Conditions: TModuleConditions = [mcAll]);
    529534begin
     
    535540begin
    536541  FInstalled := Value;
    537   Manager.Modules.Update;
     542  //Manager.Modules.Update;
    538543end;
    539544
     
    541546begin
    542547  inherited;
    543   Dependencies := TListString.Create;
    544   Description := TListString.Create;
     548  Dependencies := TStringList.Create;
     549  Description := TStringList.Create;
    545550end;
    546551
  • trunk/Packages/ModularSystem/ModularSystemPackage.pas

    r74 r75  
    33 }
    44
    5 unit ModularSystem;
     5unit ModularSystemPackage;
    66
     7{$warn 5023 off : no warning about unused units}
    78interface
    89
    910uses
    10   UModularSystem, UFormModuleList, LazarusPackageIntf;
     11  ModularSystem, FormModuleList, LazarusPackageIntf;
    1112
    1213implementation
     
    1415procedure Register;
    1516begin
    16   RegisterUnit('UModularSystem', @UModularSystem.Register);
     17  RegisterUnit('ModularSystem', @ModularSystem.Register);
    1718end;
    1819
Note: See TracChangeset for help on using the changeset viewer.