source: trunk/StudioPackage/Forms/UFormModuleList.pas

Last change on this file was 11, checked in by chronos, 12 years ago
  • Modified: Project management as separated module.
File size: 4.3 KB
Line 
1unit UFormModuleList;
2
3{$mode delphi}
4
5interface
6
7uses
8 Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
9 ComCtrls, ExtCtrls, Menus, ActnList, SpecializedList, UModularSystem;
10
11type
12
13 { TFormModuleList }
14
15 TFormModuleList = class(TForm)
16 AInstall: TAction;
17 AUninstall: TAction;
18 AModuleUnregister: TAction;
19 ActionList1: TActionList;
20 ListViewModules: TListView;
21 MenuItem1: TMenuItem;
22 MenuItem2: TMenuItem;
23 MenuItem3: TMenuItem;
24 PopupMenu1: TPopupMenu;
25 TimerRedraw: TTimer;
26 ToolBar1: TToolBar;
27 ToolButton1: TToolButton;
28 ToolButton2: TToolButton;
29 ToolButton3: TToolButton;
30 procedure AInstallExecute(Sender: TObject);
31 procedure AModuleUnregisterExecute(Sender: TObject);
32 procedure AUninstallExecute(Sender: TObject);
33 procedure FormCreate(Sender: TObject);
34 procedure FormHide(Sender: TObject);
35 procedure FormShow(Sender: TObject);
36 procedure ListViewModulesData(Sender: TObject; Item: TListItem);
37 procedure ListViewModulesSelectItem(Sender: TObject; Item: TListItem;
38 Selected: Boolean);
39 procedure TimerRedrawTimer(Sender: TObject);
40 private
41 FModuleManager: TModuleManager;
42 procedure SetModuleManager(AValue: TModuleManager);
43 { private declarations }
44 public
45 property ModuleManager: TModuleManager read FModuleManager
46 write SetModuleManager;
47 procedure Reload;
48 procedure UpdateInterface;
49 end;
50
51var
52 FormModuleList: TFormModuleList;
53
54implementation
55
56resourcestring
57 SNotInstalled = 'Not installed';
58 SInstalled = 'Installed';
59
60{ TFormModuleList }
61
62procedure TFormModuleList.ListViewModulesData(Sender: TObject; Item: TListItem);
63begin
64 if (Item.Index >= 0) and (Item.Index < FModuleManager.Modules.Count) then
65 with TModule(FModuleManager.Modules[Item.Index]) do begin
66 Item.Caption := Identification;
67 Item.Data := FModuleManager.Modules[Item.Index];
68 Item.SubItems.Add(Title);
69 if Installed then Item.SubItems.Add(SInstalled)
70 else Item.SubItems.Add(SNotInstalled);
71 Item.SubItems.Add(Author);
72 Item.SubItems.Add(License);
73 Item.SubItems.Add(Version);
74 Item.SubItems.Add(StringReplace(Dependencies.Text, LineEnding, ', ', [rfReplaceAll]));
75 end;
76end;
77
78procedure TFormModuleList.ListViewModulesSelectItem(Sender: TObject;
79 Item: TListItem; Selected: Boolean);
80begin
81 UpdateInterface;
82end;
83
84procedure TFormModuleList.FormCreate(Sender: TObject);
85begin
86 DoubleBuffered := True;
87 ControlStyle := ControlStyle + [csOpaque];
88 ListViewModules.DoubleBuffered := True;
89 ListViewModules.ControlStyle := ListViewModules.ControlStyle + [csOpaque];
90end;
91
92procedure TFormModuleList.AModuleUnregisterExecute(Sender: TObject);
93begin
94 if Assigned(ListViewModules.Selected) then begin
95 FModuleManager.UnregisterModule(TModule(ListViewModules.Selected.Data));
96 UpdateInterface;
97 end;
98end;
99
100procedure TFormModuleList.AUninstallExecute(Sender: TObject);
101begin
102 if Assigned(ListViewModules.Selected) then begin
103 TModule(ListViewModules.Selected.Data).Uninstall;
104 UpdateInterface;
105 end;
106end;
107
108procedure TFormModuleList.AInstallExecute(Sender: TObject);
109begin
110 if Assigned(ListViewModules.Selected) then begin
111 TModule(ListViewModules.Selected.Data).Install;
112 UpdateInterface;
113 end
114end;
115
116procedure TFormModuleList.FormHide(Sender: TObject);
117begin
118 TimerRedraw.Enabled := False;
119end;
120
121procedure TFormModuleList.FormShow(Sender: TObject);
122begin
123 Reload;
124 UpdateInterface;
125 TimerRedraw.Enabled := True;
126end;
127
128procedure TFormModuleList.TimerRedrawTimer(Sender: TObject);
129begin
130 Reload;
131end;
132
133procedure TFormModuleList.SetModuleManager(AValue: TModuleManager);
134begin
135 if FModuleManager = AValue then Exit;
136 FModuleManager := AValue;
137 Reload;
138end;
139
140procedure TFormModuleList.Reload;
141begin
142 ListViewModules.Items.Count := FModuleManager.Modules.Count;
143 ListViewModules.Refresh;
144end;
145
146procedure TFormModuleList.UpdateInterface;
147begin
148 AModuleUnregister.Enabled := Assigned(ListViewModules.Selected);
149 AInstall.Enabled := Assigned(ListViewModules.Selected) and
150 not TModule(ListViewModules.Selected.Data).Installed;
151 AUninstall.Enabled := Assigned(ListViewModules.Selected) and
152 TModule(ListViewModules.Selected.Data).Installed;
153end;
154
155initialization
156 {$I UFormModuleList.lrs}
157
158end.
159
Note: See TracBrowser for help on using the repository browser.