Changeset 428 for ModularSystem/Demo
- Timestamp:
- Oct 9, 2012, 11:48:44 AM (12 years ago)
- Location:
- ModularSystem/Demo
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
ModularSystem/Demo/Demo.lpi
r397 r428 35 35 <Item1> 36 36 <PackageName Value="ModularSystem"/> 37 <DefaultFilename Value="..\ModularSystem.lpk" Prefer="True"/> 37 38 </Item1> 38 39 <Item2> -
ModularSystem/Demo/UMainForm.lfm
r394 r428 10 10 OnDestroy = FormDestroy 11 11 OnShow = FormShow 12 LCLVersion = '1. 1'12 LCLVersion = '1.0.1.3' 13 13 object ListViewModules: TListView 14 14 Left = 8 … … 30 30 end 31 31 item 32 Caption = 'State' 32 Caption = 'Installed' 33 Width = 80 34 end 35 item 36 Caption = 'Running' 33 37 Width = 80 34 38 end … … 80 84 TabOrder = 3 81 85 end 86 object ButtonUpdate1: TButton 87 Left = 248 88 Height = 25 89 Top = 281 90 Width = 75 91 Action = AModuleStart 92 Anchors = [akLeft, akBottom] 93 TabOrder = 4 94 end 95 object ButtonUpdate2: TButton 96 Left = 328 97 Height = 25 98 Top = 281 99 Width = 75 100 Action = AModuleStop 101 Anchors = [akLeft, akBottom] 102 TabOrder = 5 103 end 82 104 object PopupMenu1: TPopupMenu 83 105 left = 183 … … 92 114 Action = AModuleUpdate 93 115 end 116 object MenuItem4: TMenuItem 117 Action = AModuleStart 118 end 119 object MenuItem5: TMenuItem 120 Action = AModuleStop 121 end 94 122 end 95 123 object ActionList1: TActionList 96 left = 1 3797 top = 1 65124 left = 184 125 top = 136 98 126 object AModuleInstall: TAction 99 127 Caption = 'Install' … … 108 136 OnExecute = ButtonUpdateClick 109 137 end 138 object AModuleStart: TAction 139 Caption = 'Start' 140 OnExecute = AModuleStartExecute 141 end 142 object AModuleStop: TAction 143 Caption = 'Stop' 144 OnExecute = AModuleStopExecute 145 end 110 146 end 111 147 end -
ModularSystem/Demo/UMainForm.pas
r397 r428 15 15 TMainForm = class(TForm) 16 16 published 17 AModuleStart: TAction; 18 AModuleStop: TAction; 17 19 AModuleInstall: TAction; 18 20 AModuleUninstall: TAction; … … 22 24 ButtonUninstall: TButton; 23 25 ButtonInstall: TButton; 26 ButtonUpdate1: TButton; 27 ButtonUpdate2: TButton; 24 28 ListViewModules: TListView; 25 29 MenuItem1: TMenuItem; 26 30 MenuItem2: TMenuItem; 27 31 MenuItem3: TMenuItem; 32 MenuItem4: TMenuItem; 33 MenuItem5: TMenuItem; 28 34 PopupMenu1: TPopupMenu; 35 procedure AModuleStartExecute(Sender: TObject); 36 procedure AModuleStopExecute(Sender: TObject); 29 37 procedure ButtonInstallClick(Sender: TObject); 30 38 procedure ButtonUninstallClick(Sender: TObject); … … 44 52 45 53 const 46 InstalledText: array[Boolean] of string = ('Not installed', 'Installed');54 BoolText: array[Boolean] of string = ('No', 'Yes'); 47 55 48 56 var … … 66 74 Item.Caption := Title; 67 75 Item.Data := ModuleManager.Modules[Item.Index]; 68 Item.SubItems.Add( Name);76 Item.SubItems.Add(Identification); 69 77 Item.SubItems.Add(Version); 70 Item.SubItems.Add(InstalledText[Installed]); 78 Item.SubItems.Add(BoolText[Installed]); 79 Item.SubItems.Add(BoolText[Running]); 71 80 Item.SubItems.Add(License); 72 81 Item.SubItems.Add(StringReplace(Dependencies.Text, LineEnding, ', ', [rfReplaceAll])); … … 79 88 var 80 89 Installed: Boolean; 90 Running: Boolean; 81 91 begin 82 92 if Assigned(ListViewModules.Selected) then Installed := TModule(ListViewModules.Selected.Data).Installed; 93 if Assigned(ListViewModules.Selected) then Running := TModule(ListViewModules.Selected.Data).Running; 83 94 AModuleInstall.Enabled := Assigned(ListViewModules.Selected) and not Installed; 84 95 AModuleUninstall.Enabled := Assigned(ListViewModules.Selected) and Installed; 85 96 AModuleUpdate.Enabled := Assigned(ListViewModules.Selected) and Installed; 97 AModuleStart.Enabled := Assigned(ListViewModules.Selected) and not Running; 98 AModuleStop.Enabled := Assigned(ListViewModules.Selected) and Running; 86 99 end; 87 100 88 101 procedure TMainForm.RegisterModules; 89 102 begin 90 ModuleManager.RegisterModule(TModuleUser.Create );91 ModuleManager.RegisterModule(TModuleBase.Create );92 ModuleManager.RegisterModule(TModuleACL.Create );103 ModuleManager.RegisterModule(TModuleUser.Create(nil)); 104 ModuleManager.RegisterModule(TModuleBase.Create(nil)); 105 ModuleManager.RegisterModule(TModuleACL.Create(nil)); 93 106 end; 94 107 … … 129 142 end; 130 143 144 procedure TMainForm.AModuleStartExecute(Sender: TObject); 145 var 146 ModuleList: TStringList; 147 begin 148 if Assigned(ListViewModules.Selected) then begin 149 try 150 ModuleList := TStringList.Create; 151 TModule(ListViewModules.Selected.Data).EnumModulesStart(ModuleList); 152 if ModuleList.Count > 0 then begin 153 if MessageDlg('These modules will be started in addition to ' + 154 TModule(ListViewModules.Selected.Data).Name + ': ' + 155 StringReplace(ModuleList.Text, LineEnding, ', ', [rfReplaceAll]), 156 mtConfirmation, [mbYes, mbNo], 0) = mrYes then 157 TModule(ListViewModules.Selected.Data).Start; 158 end else TModule(ListViewModules.Selected.Data).Start; 159 finally 160 ModuleList.Free; 161 end; 162 RefreshList; 163 end; 164 end; 165 166 procedure TMainForm.AModuleStopExecute(Sender: TObject); 167 var 168 ModuleList: TStringList; 169 begin 170 if Assigned(ListViewModules.Selected) then begin 171 try 172 ModuleList := TStringList.Create; 173 TModule(ListViewModules.Selected.Data).EnumModulesStop(ModuleList); 174 if ModuleList.Count > 0 then begin 175 if MessageDlg('These modules will be stopped in addition to ' + 176 TModule(ListViewModules.Selected.Data).Name + ': ' + 177 StringReplace(ModuleList.Text, LineEnding, ', ', [rfReplaceAll]), 178 mtConfirmation, [mbYes, mbNo], 0) = mrYes then 179 TModule(ListViewModules.Selected.Data).Stop; 180 end else TModule(ListViewModules.Selected.Data).Stop; 181 finally 182 ModuleList.Free; 183 end; 184 185 RefreshList; 186 end; 187 end; 188 131 189 procedure TMainForm.ButtonUninstallClick(Sender: TObject); 132 190 var … … 155 213 begin 156 214 if Assigned(ListViewModules.Selected) then begin 157 TModule(ListViewModules.Selected.Data).Up date;215 TModule(ListViewModules.Selected.Data).Upgrade; 158 216 RefreshList; 159 217 end; … … 162 220 procedure TMainForm.FormDestroy(Sender: TObject); 163 221 begin 164 ModuleManager.Free;222 FreeAndNil(ModuleManager); 165 223 end; 166 224 -
ModularSystem/Demo/UModuleACL.pas
r394 r428 12 12 13 13 TModuleACL = class(TModule) 14 constructor Create ; override;14 constructor Create(AOwner: TComponent); override; 15 15 destructor Destroy; override; 16 16 end; … … 21 21 { TModuleACL } 22 22 23 constructor TModuleACL.Create ;23 constructor TModuleACL.Create(AOwner: TComponent); 24 24 begin 25 25 inherited; 26 Name:= 'UserACL';26 Identification := 'UserACL'; 27 27 Title := 'User ACL'; 28 28 Version := '1.0'; -
ModularSystem/Demo/UModuleBase.pas
r394 r428 10 10 type 11 11 TModuleBase = class(TModule) 12 constructor Create ; override;12 constructor Create(AOwner: TComponent); override; 13 13 destructor Destroy; override; 14 14 end; … … 19 19 { TModuleUser } 20 20 21 constructor TModuleBase.Create ;21 constructor TModuleBase.Create(AOwner: TComponent); 22 22 begin 23 23 inherited; 24 Name:= 'Base';24 Identification := 'Base'; 25 25 Title := 'Base'; 26 26 Version := '1.0'; -
ModularSystem/Demo/UModuleUser.pas
r394 r428 13 13 14 14 TModuleUser = class(TModule) 15 constructor Create ; override;15 constructor Create(AOwner: TComponent); override; 16 16 destructor Destroy; override; 17 17 end; … … 21 21 { TModuleUser } 22 22 23 constructor TModuleUser.Create ;23 constructor TModuleUser.Create(AOwner: TComponent); 24 24 begin 25 25 inherited; 26 Name:= 'User';26 Identification := 'User'; 27 27 Title := 'User'; 28 28 Version := '1.0';
Note:
See TracChangeset
for help on using the changeset viewer.