source: Network/CoolWeb/LazIDEReg.pas

Last change on this file was 255, checked in by george, 13 years ago
File size: 3.8 KB
Line 
1unit LazIDEReg;
2
3{$mode objfpc}{$H+}
4
5interface
6
7uses
8 Classes, SysUtils, LazIDEIntf, ProjectIntf, FormEditingIntf, UWebPage, Forms, Controls;
9
10type
11 { TFileDescWebPage }
12
13 TFileDescWebPage = class(TFileDescPascalUnitWithResource)
14 public
15 constructor Create; override;
16 function GetInterfaceUsesSection: string; override;
17 function GetLocalizedName: string; override;
18 function GetLocalizedDescription: string; override;
19 end;
20
21 TCGIApplicationDescriptor = class(TProjectDescriptor)
22 public
23 constructor Create; override;
24 function GetLocalizedName: string; override;
25 function GetLocalizedDescription: string; override;
26 function InitProject(AProject: TLazProject): TModalResult; override;
27 function CreateStartFiles(AProject: TLazProject): TModalResult; override;
28 end;
29
30
31resourcestring
32 SWebPageTitle = 'CoolWeb page';
33 SWebPageDescription = '';
34 SCGIAppTitle = 'CoolWeb application';
35 SCGIAppDescription = '';
36
37var
38 FileDescriptorWebPage: TFileDescWebPage;
39 CGIAppDescriptor: TCGIApplicationDescriptor;
40
41
42procedure Register;
43
44implementation
45
46procedure Register;
47begin
48 FileDescriptorWebPage := TFileDescWebPage.Create;
49 RegisterProjectFileDescriptor(FileDescriptorWebPage);
50 CGIAppDescriptor := TCGIApplicationDescriptor.Create;
51 RegisterProjectDescriptor(CGIAppDescriptor);
52 FormEditingHook.RegisterDesignerBaseClass(TWebPage);
53end;
54
55{ TFileDescWebPage }
56
57constructor TFileDescWebPage.Create;
58begin
59 inherited Create;
60 Name := 'CoolWeb page';
61 ResourceClass := TWebPage;
62 UseCreateFormStatements := False;
63end;
64
65function TFileDescWebPage.GetInterfaceUsesSection: string;
66begin
67 Result := inherited GetInterfaceUsesSection;
68 Result := Result + ', UWebPage, UHTTPServer';
69end;
70
71function TFileDescWebPage.GetLocalizedName: string;
72begin
73 Result := SWebPageTitle;
74end;
75
76function TFileDescWebPage.GetLocalizedDescription: string;
77begin
78 Result := SWebPageDescription;
79end;
80
81
82{ TCGIApplicationDescriptor }
83
84constructor TCGIApplicationDescriptor.Create;
85begin
86 inherited Create;
87 Name := 'CoolWeb CGI Application';
88end;
89
90function TCGIApplicationDescriptor.GetLocalizedName: string;
91begin
92 Result := SCGIAppTitle;
93end;
94
95function TCGIApplicationDescriptor.GetLocalizedDescription: string;
96begin
97 Result := SCGIAppDescription;
98end;
99
100function TCGIApplicationDescriptor.InitProject(AProject: TLazProject): TModalResult;
101var
102 le: string;
103 NewSource: TStringList;
104 MainFile: TLazProjectFile;
105begin
106 inherited InitProject(AProject);
107
108 MainFile := AProject.CreateProjectFile('cgiapp1.lpr');
109 MainFile.IsPartOfProject := True;
110 AProject.AddFile(MainFile, False);
111 AProject.MainFileID := 0;
112
113 // Create program source
114 try
115 NewSource := TStringList.Create;
116 with NewSource do begin
117 Add('program CGIApp1;');
118 Add('');
119 Add('{$mode objfpc}{$H+}');
120 Add('');
121 Add('uses');
122 Add(' Interfaces, Forms, UWebApp, UWebPage;');
123 Add('');
124 Add('var');
125 Add(' Application: TWebApp;');
126 Add('begin');
127 Add(' Application := TWebApp.Create(nil);');
128 Add(' with Application do');
129 Add(' try');
130 Add(' Initialize;');
131 Add(' RegisterPage(TWebPage1, WebPage1, '''');');
132 Add(' Run;');
133 Add(' finally');
134 Add(' Free;');
135 Add(' end;');
136 Add('end.');
137 Add('');
138 end;
139 AProject.MainFile.SetSourceText(NewSource.Text);
140 finally
141 NewSource.Free;
142 end;
143
144 // add
145 AProject.AddPackageDependency('FCL');
146 AProject.AddPackageDependency('LCL');
147 AProject.AddPackageDependency('CoolWeb');
148
149 // compiler options
150 AProject.LazCompilerOptions.UseLineInfoUnit := True;
151 Result := mrOK;
152end;
153
154function TCGIApplicationDescriptor.CreateStartFiles(AProject: TLazProject): TModalResult;
155begin
156 LazarusIDE.DoNewEditorFile(FileDescriptorWebPage, '', '',
157 [nfIsPartOfProject, nfOpenInEditor, nfCreateDefaultSrc]);
158 Result := mrOK;
159end;
160
161
162end.
163
Note: See TracBrowser for help on using the repository browser.