Changeset 394


Ignore:
Timestamp:
Jul 31, 2012, 8:53:58 AM (12 years ago)
Author:
chronos
Message:
  • Added: ModuleSystem package which helps manage available module instalation/uninstallation and their dependencies.
Location:
ModularSystem
Files:
7 added
10 edited

Legend:

Unmodified
Added
Removed
  • ModularSystem

    • Property svn:ignore set to
      lib
  • ModularSystem/Demo

    • Property svn:ignore
      •  

        old new  
        22project1.exe
        33project1
         4Demo.exe
         5Demo.lps
  • ModularSystem/Demo/UMainForm.lfm

    r316 r394  
    11object MainForm: TMainForm
    2   Left = 463
     2  Left = 283
    33  Height = 316
    44  Top = 182
    5   Width = 398
     5  Width = 649
    66  Caption = 'Module test'
    77  ClientHeight = 316
    8   ClientWidth = 398
     8  ClientWidth = 649
    99  OnCreate = FormCreate
    1010  OnDestroy = FormDestroy
    1111  OnShow = FormShow
    12   LCLVersion = '0.9.31'
     12  LCLVersion = '1.1'
    1313  object ListViewModules: TListView
    1414    Left = 8
    1515    Height = 265
    1616    Top = 8
    17     Width = 381
     17    Width = 632
    1818    Anchors = [akTop, akLeft, akRight, akBottom]
    1919    Columns = <   
    2020      item
    2121        Caption = 'Name'
     22        Width = 70
     23      end   
     24      item
     25        Caption = 'System name'
    2226        Width = 70
    2327      end   
     
    3034      end   
    3135      item
     36        Caption = 'License'
     37        Width = 70
     38      end   
     39      item
    3240        Caption = 'Dependencies'
    3341        Width = 162
     42      end   
     43      item
     44        Caption = 'Description'
     45        Width = 200
    3446      end>
    3547    OwnerData = True
  • ModularSystem/Demo/UMainForm.pas

    r316 r394  
    77uses
    88  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ComCtrls,
    9   StdCtrls, Menus, ActnList, UModularSystem, UModuleUser, UModuleBase;
     9  StdCtrls, Menus, ActnList, UModularSystem;
    1010
    1111type
     
    3737      Selected: Boolean);
    3838  private
    39     { private declarations }
     39    procedure RegisterModules;
    4040  public
    4141    ModuleManager: TModuleManager;
     
    4949  MainForm: TMainForm;
    5050
     51
    5152implementation
    5253
    5354{$R *.lfm}
     55
     56uses
     57  UModuleUser, UModuleBase, UModuleACL;
     58
    5459
    5560{ TMainForm }
     
    5964  if (Item.Index >= 0) and (Item.Index < ModuleManager.Modules.Count) then
    6065  with TModule(ModuleManager.Modules[Item.Index]) do begin
    61     Item.Caption := Name;
     66    Item.Caption := Title;
    6267    Item.Data := ModuleManager.Modules[Item.Index];
     68    Item.SubItems.Add(Name);
    6369    Item.SubItems.Add(Version);
    6470    Item.SubItems.Add(InstalledText[Installed]);
    65     Item.SubItems.Add(Dependencies.Text);
     71    Item.SubItems.Add(License);
     72    Item.SubItems.Add(StringReplace(Dependencies.Text, LineEnding, ', ', [rfReplaceAll]));
     73    Item.SubItems.Add(StringReplace(Description.Text, LineEnding, ', ', [rfReplaceAll]));
    6674  end;
    6775end;
     
    7886end;
    7987
     88procedure TMainForm.RegisterModules;
     89begin
     90  ModuleManager.RegisterModule(TModuleUser.Create);
     91  ModuleManager.RegisterModule(TModuleBase.Create);
     92  ModuleManager.RegisterModule(TModuleACL.Create);
     93end;
     94
    8095procedure TMainForm.RefreshList;
    8196begin
     
    87102
    88103procedure TMainForm.FormCreate(Sender: TObject);
    89 var
    90   UserModule: TModuleUser;
    91   BaseModule: TModuleBase;
    92104begin
    93   UserModule := TModuleUser.Create;
    94   BaseModule := TModuleBase.Create;
    95 
    96105  ModuleManager := TModuleManager.Create;
    97   ModuleManager.RegisterModule(UserModule);
    98   ModuleManager.RegisterModule(BaseModule);
     106  RegisterModules;
    99107end;
    100108
     
    109117      if ModuleList.Count > 0 then begin
    110118        if MessageDlg('These modules will be installed in addition to ' +
    111           TModule(ListViewModules.Selected.Data).Name + ': ' + ModuleList.Text,
     119          TModule(ListViewModules.Selected.Data).Name + ': ' +
     120          StringReplace(ModuleList.Text, LineEnding, ', ', [rfReplaceAll]),
    112121          mtConfirmation, [mbYes, mbNo], 0) = mrYes then
    113122           TModule(ListViewModules.Selected.Data).Install;
     
    130139      if ModuleList.Count > 0 then begin
    131140        if MessageDlg('These modules will be uninstalled in addition to ' +
    132           TModule(ListViewModules.Selected.Data).Name + ': ' + ModuleList.Text,
     141          TModule(ListViewModules.Selected.Data).Name + ': ' +
     142          StringReplace(ModuleList.Text, LineEnding, ', ', [rfReplaceAll]),
    133143          mtConfirmation, [mbYes, mbNo], 0) = mrYes then
    134144            TModule(ListViewModules.Selected.Data).Uninstall;
  • ModularSystem/Demo/UModuleBase.pas

    r314 r394  
    2323inherited;
    2424  Name := 'Base';
     25  Title := 'Base';
    2526  Version := '1.0';
     27  License := 'GNU/LGPLv3';
    2628end;
    2729
  • ModularSystem/Demo/UModuleUser.pas

    r314 r394  
    2525  inherited;
    2626  Name := 'User';
     27  Title := 'User';
    2728  Version := '1.0';
     29  License := 'GNU/LGPLv3';
    2830  Dependencies.Add('Base');
    2931end;
  • ModularSystem/Demo/project1.lpi

    r316 r394  
    3131      </local>
    3232    </RunParams>
    33     <RequiredPackages Count="1">
     33    <RequiredPackages Count="2">
    3434      <Item1>
     35        <PackageName Value="ModularSystem"/>
     36      </Item1>
     37      <Item2>
    3538        <PackageName Value="LCL"/>
    36       </Item1>
     39      </Item2>
    3740    </RequiredPackages>
    3841    <Units Count="5">
     
    4649        <IsPartOfProject Value="True"/>
    4750        <ComponentName Value="MainForm"/>
     51        <HasResources Value="True"/>
    4852        <ResourceBaseClass Value="Form"/>
    4953        <UnitName Value="UMainForm"/>
     
    6064      </Unit3>
    6165      <Unit4>
    62         <Filename Value="..\UModularSystem.pas"/>
     66        <Filename Value="UModuleACL.pas"/>
    6367        <IsPartOfProject Value="True"/>
    64         <UnitName Value="UModularSystem"/>
     68        <UnitName Value="UModuleACL"/>
    6569      </Unit4>
    6670    </Units>
     
    7478    <SearchPaths>
    7579      <IncludeFiles Value="$(ProjOutDir)"/>
    76       <OtherUnitFiles Value=".."/>
    7780      <UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
    7881    </SearchPaths>
  • ModularSystem/Demo/project1.lpr

    r314 r394  
    88  {$ENDIF}{$ENDIF}
    99  Interfaces, // this includes the LCL widgetset
    10   Forms, UMainForm, UModuleUser, UModuleBase, UModularSystem
    11   { you can add units after this };
     10  Forms, UMainForm, UModuleUser, UModuleBase, UModuleACL;
    1211
    1312{$R *.res}
  • ModularSystem/Demo/project1.lps

    r316 r394  
    55    <Version Value="9"/>
    66    <BuildModes Active="Default"/>
    7     <Units Count="10">
     7    <Units Count="12">
    88      <Unit0>
    99        <Filename Value="project1.lpr"/>
     
    1616        <IsPartOfProject Value="True"/>
    1717        <ComponentName Value="MainForm"/>
     18        <HasResources Value="True"/>
    1819        <ResourceBaseClass Value="Form"/>
    1920        <UnitName Value="UMainForm"/>
    20         <IsVisibleTab Value="True"/>
    2121        <EditorIndex Value="0"/>
    2222        <WindowIndex Value="0"/>
    23         <TopLine Value="59"/>
    24         <CursorPos X="40" Y="69"/>
     23        <TopLine Value="53"/>
     24        <CursorPos X="23" Y="68"/>
    2525        <UsageCount Value="29"/>
    2626        <Loaded Value="True"/>
     
    3131        <IsPartOfProject Value="True"/>
    3232        <UnitName Value="UModuleUser"/>
    33         <EditorIndex Value="4"/>
    34         <WindowIndex Value="0"/>
    35         <TopLine Value="11"/>
    36         <CursorPos X="27" Y="28"/>
     33        <EditorIndex Value="5"/>
     34        <WindowIndex Value="0"/>
     35        <TopLine Value="2"/>
     36        <CursorPos X="3" Y="14"/>
    3737        <UsageCount Value="29"/>
    3838        <Loaded Value="True"/>
     
    4242        <IsPartOfProject Value="True"/>
    4343        <UnitName Value="UModuleBase"/>
    44         <EditorIndex Value="3"/>
    45         <WindowIndex Value="0"/>
    46         <TopLine Value="1"/>
    47         <CursorPos X="36" Y="8"/>
     44        <EditorIndex Value="4"/>
     45        <WindowIndex Value="0"/>
     46        <TopLine Value="10"/>
     47        <CursorPos X="1" Y="27"/>
    4848        <UsageCount Value="27"/>
    4949        <Loaded Value="True"/>
     
    5151      <Unit4>
    5252        <Filename Value="..\UModularSystem.pas"/>
    53         <IsPartOfProject Value="True"/>
    5453        <UnitName Value="UModularSystem"/>
    55         <EditorIndex Value="2"/>
    56         <WindowIndex Value="0"/>
    57         <TopLine Value="142"/>
    58         <CursorPos X="68" Y="154"/>
     54        <IsVisibleTab Value="True"/>
     55        <EditorIndex Value="3"/>
     56        <WindowIndex Value="0"/>
     57        <TopLine Value="15"/>
     58        <CursorPos X="16" Y="29"/>
    5959        <UsageCount Value="25"/>
    6060        <Loaded Value="True"/>
     
    9191      </Unit8>
    9292      <Unit9>
    93         <Filename Value="..\..\..\..\other\lazarus\lcl\include\customlistview.inc"/>
    94         <EditorIndex Value="1"/>
     93        <Filename Value="H:\other\lazarus\lcl\include\customlistview.inc"/>
    9594        <WindowIndex Value="0"/>
    9695        <TopLine Value="434"/>
    9796        <CursorPos X="24" Y="448"/>
    9897        <UsageCount Value="10"/>
    99         <Loaded Value="True"/>
    10098      </Unit9>
     99      <Unit10>
     100        <Filename Value="H:\Lazarus\1.1_2.6.0\fpc\2.6.0\source\rtl\objpas\sysutils\sysstrh.inc"/>
     101        <EditorIndex Value="2"/>
     102        <WindowIndex Value="0"/>
     103        <TopLine Value="212"/>
     104        <CursorPos X="10" Y="224"/>
     105        <UsageCount Value="10"/>
     106        <Loaded Value="True"/>
     107      </Unit10>
     108      <Unit11>
     109        <Filename Value="UModuleACL.pas"/>
     110        <IsPartOfProject Value="True"/>
     111        <UnitName Value="UModuleACL"/>
     112        <EditorIndex Value="1"/>
     113        <WindowIndex Value="0"/>
     114        <TopLine Value="10"/>
     115        <CursorPos X="23" Y="27"/>
     116        <UsageCount Value="20"/>
     117        <Loaded Value="True"/>
     118      </Unit11>
    101119    </Units>
    102120    <General>
    103121      <ActiveWindowIndexAtStart Value="0"/>
    104122    </General>
    105     <JumpHistory Count="21" HistoryIndex="20">
     123    <JumpHistory Count="28" HistoryIndex="27">
    106124      <Position1>
    107125        <Filename Value="UMainForm.pas"/>
     
    181199      </Position19>
    182200      <Position20>
    183         <Filename Value="..\..\..\..\other\lazarus\lcl\include\customlistview.inc"/>
    184         <Caret Line="448" Column="24" TopLine="434"/>
     201        <Filename Value="UMainForm.pas"/>
     202        <Caret Line="67" Column="23" TopLine="59"/>
    185203      </Position20>
    186204      <Position21>
    187205        <Filename Value="UMainForm.pas"/>
    188         <Caret Line="67" Column="23" TopLine="59"/>
     206        <Caret Line="65" Column="87" TopLine="57"/>
    189207      </Position21>
     208      <Position22>
     209        <Filename Value="UModuleACL.pas"/>
     210        <Caret Line="14" Column="29" TopLine="1"/>
     211      </Position22>
     212      <Position23>
     213        <Filename Value="UModuleUser.pas"/>
     214        <Caret Line="28" Column="3" TopLine="13"/>
     215      </Position23>
     216      <Position24>
     217        <Filename Value="UModuleACL.pas"/>
     218        <Caret Line="26" Column="16" TopLine="10"/>
     219      </Position24>
     220      <Position25>
     221        <Filename Value="UMainForm.pas"/>
     222        <Caret Line="68" Column="23" TopLine="53"/>
     223      </Position25>
     224      <Position26>
     225        <Filename Value="UModuleUser.pas"/>
     226        <Caret Line="30" Column="1" TopLine="13"/>
     227      </Position26>
     228      <Position27>
     229        <Filename Value="UModuleUser.pas"/>
     230        <Caret Line="27" Column="9" TopLine="15"/>
     231      </Position27>
     232      <Position28>
     233        <Filename Value="UModuleUser.pas"/>
     234        <Caret Line="14" Column="3" TopLine="2"/>
     235      </Position28>
    190236    </JumpHistory>
    191237  </ProjectSession>
     238  <EditorMacros Count="0"/>
    192239</CONFIG>
  • ModularSystem/UModularSystem.pas

    r315 r394  
    2020    Version: string;
    2121    Name: string;
     22    Title: string;
    2223    Dependencies: TStringList;
    2324    Author: string;
    24     Description: string;
     25    Description: TStringList;
     26    License: string;
    2527    procedure Install; virtual;
    2628    procedure Uninstall; virtual;
     
    9799    Module := FindModuleByName(Dependencies[I]);
    98100    if Assigned(Module) then begin
    99       if not Module.Installed and (ModuleList.IndexOf(Module.Name) = -1) then
     101      if not Module.Installed and (ModuleList.IndexOf(Module.Name) = -1) then begin
    100102        ModuleList.Add(Module.Name);
     103        EnumModulesInstall(Module.Dependencies, ModuleList);
     104      end;
    101105    end else raise Exception.CreateFmt(SModuleNotFound, [Module.Name]);
    102106  end;
     
    111115  with TModule(Modules[I]) do begin
    112116    if (Dependencies.IndexOf(ModuleName) <> -1) and Installed and
    113       (ModuleList.IndexOf(Name) = -1) then
     117      (ModuleList.IndexOf(Name) = -1) then begin
    114118      ModuleList.Add(Name);
     119      Self.EnumModulesUninstall(Name, ModuleList);
     120    end;
    115121  end;
    116122end;
     
    169175begin
    170176  Dependencies := TStringList.Create;
     177  Description := TStringList.Create;
    171178end;
    172179
    173180destructor TModule.Destroy;
    174181begin
     182  Description.Free;
    175183  Dependencies.Free;
    176184  inherited Destroy;
Note: See TracChangeset for help on using the changeset viewer.