mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-06-01 01:32:31 +02:00
+ Added menu integration and a README file
git-svn-id: trunk@7861 -
This commit is contained in:
parent
14919eb9e7
commit
8aa081ebd9
1
.gitattributes
vendored
1
.gitattributes
vendored
@ -189,6 +189,7 @@ components/printers/win32/winprinters.inc svneol=native#text/pascal
|
||||
components/printers/win32/winprinters_h.inc svneol=native#text/pascal
|
||||
components/printers/win32/winutilprn.pas svneol=native#text/pascal
|
||||
components/printers/win32/winutilprnconst.inc svneol=native#text/pascal
|
||||
components/projecttemplates/README svneol=native#text/plain
|
||||
components/projecttemplates/frmtemplatesettings.lfm svneol=native#text/plain
|
||||
components/projecttemplates/frmtemplatesettings.lrs svneol=native#text/plain
|
||||
components/projecttemplates/frmtemplatesettings.pas svneol=native#text/plain
|
||||
|
50
components/projecttemplates/README
Normal file
50
components/projecttemplates/README
Normal file
@ -0,0 +1,50 @@
|
||||
This package implements project templates.
|
||||
|
||||
Installing this package in the IDE adds a category to the 'File-New' dialog:
|
||||
'Template projects'
|
||||
|
||||
It also adds a 'New project from Template' menu item to the 'File' menu, as
|
||||
well as a 'project template options' menu under the 'Tools' menu.
|
||||
|
||||
In the 'Project template options', a directory can be selected. This project
|
||||
should contain a subdirectory per template. Each template directory contains
|
||||
a template for a project: A collection of files which will be copied and
|
||||
used as a new project.
|
||||
|
||||
During the copy, the package will scan the file/directory names and the
|
||||
contents of the files for variable substitution: $(VARNAME) will be
|
||||
replaced by the value of a variable $(VARNAME).
|
||||
|
||||
By default, the engine knows 2 variables:
|
||||
ProjDir : The directory where the new project will be created.
|
||||
ProjName : The name of the project.
|
||||
|
||||
Additional variables must be defined in a file called 'project.ini' in the
|
||||
directory of the project. This is a file in Windows INI format.
|
||||
|
||||
The section [Variables] will be scanned for variable names:
|
||||
[Variables]
|
||||
VarName1=Description 1
|
||||
VarName2=Description 2
|
||||
|
||||
The variables found will be presented with their description in a dialog,
|
||||
and the user must present a value for the variables.
|
||||
|
||||
The 'project.ini' file can contain a second section, called 'Project', which
|
||||
can contain some info about the project. The following keywords can be found
|
||||
there:
|
||||
|
||||
Name
|
||||
Name of the template
|
||||
Author
|
||||
Author of the template
|
||||
Description
|
||||
Short (one-line) description of the project
|
||||
Recurse
|
||||
A boolean value (1/0) which tells the engine to recurse in subdirectories
|
||||
or not.
|
||||
Exclude
|
||||
Comma separated list of filename extensions which should not be searched
|
||||
for keyword subsitution.
|
||||
|
||||
The Name,Author and description will be presented in the 'File-New' dialog.
|
@ -12,7 +12,6 @@ object TemplateSettingsForm: TTemplateSettingsForm
|
||||
Width = 400
|
||||
object Label1: TLabel
|
||||
AutoSize = False
|
||||
BorderSpacing.OnChange = nil
|
||||
Caption = '&Directory with templates:'
|
||||
Color = clNone
|
||||
FocusControl = DETemplates
|
||||
@ -23,7 +22,6 @@ object TemplateSettingsForm: TTemplateSettingsForm
|
||||
Width = 160
|
||||
end
|
||||
object BOK: TButton
|
||||
BorderSpacing.OnChange = nil
|
||||
Caption = '&OK'
|
||||
Default = True
|
||||
ModalResult = 1
|
||||
@ -35,9 +33,9 @@ object TemplateSettingsForm: TTemplateSettingsForm
|
||||
Width = 91
|
||||
end
|
||||
object BCancel: TButton
|
||||
BorderSpacing.OnChange = nil
|
||||
Cancel = True
|
||||
Caption = '&Cancel'
|
||||
ModalResult = 2
|
||||
TabOrder = 1
|
||||
Left = 192
|
||||
Height = 25
|
||||
@ -47,9 +45,7 @@ object TemplateSettingsForm: TTemplateSettingsForm
|
||||
object DETemplates: TDirectoryEdit
|
||||
ButtonWidth = 23
|
||||
NumGlyphs = 1
|
||||
BorderSpacing.OnChange = nil
|
||||
TabOrder = 2
|
||||
BorderSpacing.OnChange = nil
|
||||
TabOrder = 2
|
||||
Left = 8
|
||||
Height = 23
|
||||
|
@ -5,16 +5,14 @@ LazarusResources.Add('TTemplateSettingsForm','FORMDATA',[
|
||||
+'ject templates settings'#12'ClientHeight'#2''#11'ClientWidth'#3#144#1#13'P'
|
||||
+'ixelsPerInch'#2'Z'#8'Position'#7#15'poDesktopCenter'#18'HorzScrollBar.Page'
|
||||
+#3#143#1#18'VertScrollBar.Page'#2'~'#4'Left'#3#214#1#6'Height'#2''#3'Top'#3
|
||||
+#175#0#5'Width'#3#144#1#0#6'TLabel'#6'Label1'#8'AutoSize'#8#22'BorderSpacing'
|
||||
+'.OnChange'#13#7'Caption'#6#26'&Directory with templates:'#5'Color'#7#6'clNo'
|
||||
+'ne'#12'FocusControl'#7#11'DETemplates'#6'Layout'#7#8'tlCenter'#4'Left'#2#8#6
|
||||
+'Height'#2#24#3'Top'#2#16#5'Width'#3#160#0#0#0#7'TButton'#3'BOK'#22'BorderSp'
|
||||
+'acing.OnChange'#13#7'Caption'#6#3'&OK'#7'Default'#9#11'ModalResult'#2#1#7'O'
|
||||
+'nClick'#7#8'BOKClick'#8'TabOrder'#2#0#4'Left'#3'('#1#6'Height'#2#25#3'Top'#2
|
||||
+'`'#5'Width'#2'['#0#0#7'TButton'#7'BCancel'#22'BorderSpacing.OnChange'#13#6
|
||||
+'Cancel'#9#7'Caption'#6#7'&Cancel'#8'TabOrder'#2#1#4'Left'#3#192#0#6'Height'
|
||||
+#2#25#3'Top'#2'`'#5'Width'#2'`'#0#0#14'TDirectoryEdit'#11'DETemplates'#11'Bu'
|
||||
+'ttonWidth'#2#23#9'NumGlyphs'#2#1#22'BorderSpacing.OnChange'#13#8'TabOrder'#2
|
||||
+#2#22'BorderSpacing.OnChange'#13#8'TabOrder'#2#2#4'Left'#2#8#6'Height'#2#23#3
|
||||
+'Top'#2')'#5'Width'#3'h'#1#0#0#0
|
||||
+#175#0#5'Width'#3#144#1#0#6'TLabel'#6'Label1'#8'AutoSize'#8#7'Caption'#6#26
|
||||
+'&Directory with templates:'#5'Color'#7#6'clNone'#12'FocusControl'#7#11'DETe'
|
||||
+'mplates'#6'Layout'#7#8'tlCenter'#4'Left'#2#8#6'Height'#2#24#3'Top'#2#16#5'W'
|
||||
+'idth'#3#160#0#0#0#7'TButton'#3'BOK'#7'Caption'#6#3'&OK'#7'Default'#9#11'Mod'
|
||||
+'alResult'#2#1#7'OnClick'#7#8'BOKClick'#8'TabOrder'#2#0#4'Left'#3'('#1#6'Hei'
|
||||
+'ght'#2#25#3'Top'#2'`'#5'Width'#2'['#0#0#7'TButton'#7'BCancel'#6'Cancel'#9#7
|
||||
+'Caption'#6#7'&Cancel'#11'ModalResult'#2#2#8'TabOrder'#2#1#4'Left'#3#192#0#6
|
||||
+'Height'#2#25#3'Top'#2'`'#5'Width'#2'`'#0#0#14'TDirectoryEdit'#11'DETemplate'
|
||||
+'s'#11'ButtonWidth'#2#23#9'NumGlyphs'#2#1#8'TabOrder'#2#2#8'TabOrder'#2#2#4
|
||||
+'Left'#2#8#6'Height'#2#23#3'Top'#2')'#5'Width'#3'h'#1#0#0#0
|
||||
]);
|
||||
|
@ -14,7 +14,6 @@ object ProjectVariablesForm: TProjectVariablesForm
|
||||
object Label1: TLabel
|
||||
Alignment = taRightJustify
|
||||
AutoSize = False
|
||||
BorderSpacing.OnChange = nil
|
||||
Caption = '&Name for new project:'
|
||||
Color = clNone
|
||||
Layout = tlCenter
|
||||
@ -26,7 +25,6 @@ object ProjectVariablesForm: TProjectVariablesForm
|
||||
object Label2: TLabel
|
||||
Alignment = taRightJustify
|
||||
AutoSize = False
|
||||
BorderSpacing.OnChange = nil
|
||||
Caption = 'Create in &directory:'
|
||||
Color = clNone
|
||||
Layout = tlCenter
|
||||
@ -37,7 +35,6 @@ object ProjectVariablesForm: TProjectVariablesForm
|
||||
end
|
||||
object PDescription: TPanel
|
||||
Anchors = [akTop, akLeft, akRight]
|
||||
BorderSpacing.OnChange = nil
|
||||
BevelInner = bvRaised
|
||||
BevelOuter = bvLowered
|
||||
Caption = 'This project contains some additional variables. Please provide values for these variables'
|
||||
@ -53,7 +50,6 @@ object ProjectVariablesForm: TProjectVariablesForm
|
||||
object SGVariables: TStringGrid
|
||||
Anchors = [akTop, akLeft, akRight, akBottom]
|
||||
AutoFillColumns = True
|
||||
BorderSpacing.OnChange = nil
|
||||
ColCount = 3
|
||||
DefaultColWidth = 120
|
||||
FixedColor = clBtnFace
|
||||
@ -70,7 +66,6 @@ object ProjectVariablesForm: TProjectVariablesForm
|
||||
end
|
||||
object BOK: TButton
|
||||
Anchors = [akRight, akBottom]
|
||||
BorderSpacing.OnChange = nil
|
||||
Caption = '&OK'
|
||||
Default = True
|
||||
ModalResult = 1
|
||||
@ -83,7 +78,6 @@ object ProjectVariablesForm: TProjectVariablesForm
|
||||
end
|
||||
object BCancel: TButton
|
||||
Anchors = [akRight, akBottom]
|
||||
BorderSpacing.OnChange = nil
|
||||
Cancel = True
|
||||
Caption = '&Cancel'
|
||||
ModalResult = 2
|
||||
@ -95,7 +89,6 @@ object ProjectVariablesForm: TProjectVariablesForm
|
||||
end
|
||||
object EProjectName: TEdit
|
||||
Anchors = [akTop, akLeft, akRight]
|
||||
BorderSpacing.OnChange = nil
|
||||
TabOrder = 3
|
||||
Left = 152
|
||||
Height = 23
|
||||
@ -106,24 +99,12 @@ object ProjectVariablesForm: TProjectVariablesForm
|
||||
ButtonWidth = 23
|
||||
NumGlyphs = 1
|
||||
Anchors = [akTop, akLeft, akRight]
|
||||
BorderSpacing.OnChange = nil
|
||||
TabOrder = 4
|
||||
Anchors = [akTop, akLeft, akRight]
|
||||
BorderSpacing.OnChange = nil
|
||||
TabOrder = 4
|
||||
Left = 152
|
||||
Height = 23
|
||||
Top = 48
|
||||
Width = 317
|
||||
end
|
||||
object BConfig1: TButton
|
||||
BorderSpacing.OnChange = nil
|
||||
Caption = 'C&onfigure...'
|
||||
OnClick = BConfig1Click
|
||||
TabOrder = 5
|
||||
Left = 10
|
||||
Height = 25
|
||||
Top = 292
|
||||
Width = 94
|
||||
end
|
||||
end
|
||||
|
@ -6,39 +6,33 @@ LazarusResources.Add('TProjectVariablesForm','FORMDATA',[
|
||||
+'nShow'#7#24'ProjectVariablesFormShow'#13'PixelsPerInch'#2'Z'#8'Position'#7
|
||||
+#15'poDesktopCenter'#18'HorzScrollBar.Page'#3#242#1#18'VertScrollBar.Page'#3
|
||||
+'G'#1#4'Left'#3#175#1#6'Height'#3'H'#1#3'Top'#3#245#1#5'Width'#3#243#1#0#6'T'
|
||||
+'Label'#6'Label1'#9'Alignment'#7#14'taRightJustify'#8'AutoSize'#8#22'BorderS'
|
||||
+'pacing.OnChange'#13#7'Caption'#6#22'&Name for new project:'#5'Color'#7#6'cl'
|
||||
+'None'#6'Layout'#7#8'tlCenter'#4'Left'#2#8#6'Height'#2#23#3'Top'#2#16#5'Widt'
|
||||
+'h'#3#131#0#0#0#6'TLabel'#6'Label2'#9'Alignment'#7#14'taRightJustify'#8'Auto'
|
||||
+'Size'#8#22'BorderSpacing.OnChange'#13#7'Caption'#6#21'Create in &directory:'
|
||||
+#5'Color'#7#6'clNone'#6'Layout'#7#8'tlCenter'#4'Left'#2#8#6'Height'#2#22#3'T'
|
||||
+'op'#2'0'#5'Width'#3#131#0#0#0#6'TPanel'#12'PDescription'#7'Anchors'#11#5'ak'
|
||||
+'Top'#6'akLeft'#7'akRight'#0#22'BorderSpacing.OnChange'#13#10'BevelInner'#7#8
|
||||
+'bvRaised'#10'BevelOuter'#7#9'bvLowered'#7'Caption'#6'ZThis project contains'
|
||||
+' some additional variables. Please provide values for these variables'#12'C'
|
||||
+'lientHeight'#2':'#11'ClientWidth'#3#229#1#11'FullRepaint'#8#8'TabOrder'#2#0
|
||||
+#4'Left'#2#8#6'Height'#2':'#3'Top'#2'P'#5'Width'#3#229#1#0#0#11'TStringGrid'
|
||||
+#11'SGVariables'#7'Anchors'#11#5'akTop'#6'akLeft'#7'akRight'#8'akBottom'#0#15
|
||||
+'AutoFillColumns'#9#22'BorderSpacing.OnChange'#13#8'ColCount'#2#3#15'Default'
|
||||
+'ColWidth'#2'x'#10'FixedColor'#7#9'clBtnFace'#13'GridLineWidth'#2#0#7'Option'
|
||||
+'s'#11#15'goFixedVertLine'#15'goFixedHorzLine'#10'goVertLine'#10'goHorzLine'
|
||||
+#13'goRangeSelect'#11'goColSizing'#9'goEditing'#18'goAlwaysShowEditor'#18'go'
|
||||
+'DblClickAutoSize'#14'goSmoothScroll'#0#8'RowCount'#2#5#10'ScrollBars'#7#10
|
||||
+'ssAutoBoth'#15'VisibleColCount'#2#2#15'VisibleRowCount'#2#4#4'Left'#2#10#6
|
||||
+'Height'#3#140#0#3'Top'#3#144#0#5'Width'#3#227#1#0#0#7'TButton'#3'BOK'#7'Anc'
|
||||
+'hors'#11#7'akRight'#8'akBottom'#0#22'BorderSpacing.OnChange'#13#7'Caption'#6
|
||||
+#3'&OK'#7'Default'#9#11'ModalResult'#2#1#7'OnClick'#7#8'BOKClick'#8'TabOrder'
|
||||
+#2#1#4'Left'#3#155#1#6'Height'#2#25#3'Top'#3'$'#1#5'Width'#2'K'#0#0#7'TButto'
|
||||
+'n'#7'BCancel'#7'Anchors'#11#7'akRight'#8'akBottom'#0#22'BorderSpacing.OnCha'
|
||||
+'nge'#13#6'Cancel'#9#7'Caption'#6#7'&Cancel'#11'ModalResult'#2#2#8'TabOrder'
|
||||
+#2#2#4'Left'#3'C'#1#6'Height'#2#25#3'Top'#3'$'#1#5'Width'#2'K'#0#0#5'TEdit'
|
||||
+#12'EProjectName'#7'Anchors'#11#5'akTop'#6'akLeft'#7'akRight'#0#22'BorderSpa'
|
||||
+'cing.OnChange'#13#8'TabOrder'#2#3#4'Left'#3#152#0#6'Height'#2#23#3'Top'#2#16
|
||||
+#5'Width'#3#237#0#0#0#14'TDirectoryEdit'#9'DEProject'#11'ButtonWidth'#2#23#9
|
||||
+'NumGlyphs'#2#1#7'Anchors'#11#5'akTop'#6'akLeft'#7'akRight'#0#22'BorderSpaci'
|
||||
+'ng.OnChange'#13#8'TabOrder'#2#4#7'Anchors'#11#5'akTop'#6'akLeft'#7'akRight'
|
||||
+#0#22'BorderSpacing.OnChange'#13#8'TabOrder'#2#4#4'Left'#3#152#0#6'Height'#2
|
||||
+#23#3'Top'#2'0'#5'Width'#3'='#1#0#0#7'TButton'#8'BConfig1'#22'BorderSpacing.'
|
||||
+'OnChange'#13#7'Caption'#6#13'C&onfigure...'#7'OnClick'#7#13'BConfig1Click'#8
|
||||
+'TabOrder'#2#5#4'Left'#2#10#6'Height'#2#25#3'Top'#3'$'#1#5'Width'#2'^'#0#0#0
|
||||
+'Label'#6'Label1'#9'Alignment'#7#14'taRightJustify'#8'AutoSize'#8#7'Caption'
|
||||
+#6#22'&Name for new project:'#5'Color'#7#6'clNone'#6'Layout'#7#8'tlCenter'#4
|
||||
+'Left'#2#8#6'Height'#2#23#3'Top'#2#16#5'Width'#3#131#0#0#0#6'TLabel'#6'Label'
|
||||
+'2'#9'Alignment'#7#14'taRightJustify'#8'AutoSize'#8#7'Caption'#6#21'Create i'
|
||||
+'n &directory:'#5'Color'#7#6'clNone'#6'Layout'#7#8'tlCenter'#4'Left'#2#8#6'H'
|
||||
+'eight'#2#22#3'Top'#2'0'#5'Width'#3#131#0#0#0#6'TPanel'#12'PDescription'#7'A'
|
||||
+'nchors'#11#5'akTop'#6'akLeft'#7'akRight'#0#10'BevelInner'#7#8'bvRaised'#10
|
||||
+'BevelOuter'#7#9'bvLowered'#7'Caption'#6'ZThis project contains some additio'
|
||||
+'nal variables. Please provide values for these variables'#12'ClientHeight'#2
|
||||
+':'#11'ClientWidth'#3#229#1#11'FullRepaint'#8#8'TabOrder'#2#0#4'Left'#2#8#6
|
||||
+'Height'#2':'#3'Top'#2'P'#5'Width'#3#229#1#0#0#11'TStringGrid'#11'SGVariable'
|
||||
+'s'#7'Anchors'#11#5'akTop'#6'akLeft'#7'akRight'#8'akBottom'#0#15'AutoFillCol'
|
||||
+'umns'#9#8'ColCount'#2#3#15'DefaultColWidth'#2'x'#10'FixedColor'#7#9'clBtnFa'
|
||||
+'ce'#13'GridLineWidth'#2#0#7'Options'#11#15'goFixedVertLine'#15'goFixedHorzL'
|
||||
+'ine'#10'goVertLine'#10'goHorzLine'#13'goRangeSelect'#11'goColSizing'#9'goEd'
|
||||
+'iting'#18'goAlwaysShowEditor'#18'goDblClickAutoSize'#14'goSmoothScroll'#0#8
|
||||
+'RowCount'#2#5#10'ScrollBars'#7#10'ssAutoBoth'#15'VisibleColCount'#2#2#15'Vi'
|
||||
+'sibleRowCount'#2#4#4'Left'#2#10#6'Height'#3#140#0#3'Top'#3#144#0#5'Width'#3
|
||||
+#227#1#0#0#7'TButton'#3'BOK'#7'Anchors'#11#7'akRight'#8'akBottom'#0#7'Captio'
|
||||
+'n'#6#3'&OK'#7'Default'#9#11'ModalResult'#2#1#7'OnClick'#7#8'BOKClick'#8'Tab'
|
||||
+'Order'#2#1#4'Left'#3#155#1#6'Height'#2#25#3'Top'#3'$'#1#5'Width'#2'K'#0#0#7
|
||||
+'TButton'#7'BCancel'#7'Anchors'#11#7'akRight'#8'akBottom'#0#6'Cancel'#9#7'Ca'
|
||||
+'ption'#6#7'&Cancel'#11'ModalResult'#2#2#8'TabOrder'#2#2#4'Left'#3'C'#1#6'He'
|
||||
+'ight'#2#25#3'Top'#3'$'#1#5'Width'#2'K'#0#0#5'TEdit'#12'EProjectName'#7'Anch'
|
||||
+'ors'#11#5'akTop'#6'akLeft'#7'akRight'#0#8'TabOrder'#2#3#4'Left'#3#152#0#6'H'
|
||||
+'eight'#2#23#3'Top'#2#16#5'Width'#3#237#0#0#0#14'TDirectoryEdit'#9'DEProject'
|
||||
+#11'ButtonWidth'#2#23#9'NumGlyphs'#2#1#7'Anchors'#11#5'akTop'#6'akLeft'#7'ak'
|
||||
+'Right'#0#8'TabOrder'#2#4#7'Anchors'#11#5'akTop'#6'akLeft'#7'akRight'#0#8'Ta'
|
||||
+'bOrder'#2#4#4'Left'#3#152#0#6'Height'#2#23#3'Top'#2'0'#5'Width'#3'='#1#0#0#0
|
||||
]);
|
||||
|
@ -6,14 +6,13 @@ interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, LResources, Forms, Controls, Graphics, Dialogs, ExtCtrls,
|
||||
Grids, ProjectTemplates, Buttons, StdCtrls, EditBtn, frmTemplateSettings;
|
||||
Grids, ProjectTemplates, Buttons, StdCtrls, EditBtn;
|
||||
|
||||
type
|
||||
|
||||
{ TProjectVariablesForm }
|
||||
|
||||
TProjectVariablesForm = class(TForm)
|
||||
BConfig1: TButton;
|
||||
BOK: TButton;
|
||||
BCancel: TButton;
|
||||
DEProject: TDirectoryEdit;
|
||||
@ -22,7 +21,6 @@ type
|
||||
Label2: TLabel;
|
||||
PDescription: TPanel;
|
||||
SGVariables: TStringGrid;
|
||||
procedure BConfig1Click(Sender: TObject);
|
||||
procedure BOKClick(Sender: TObject);
|
||||
procedure ProjectVariablesFormShow(Sender: TObject);
|
||||
private
|
||||
@ -77,17 +75,6 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TProjectVariablesForm.BConfig1Click(Sender: TObject);
|
||||
begin
|
||||
With TTemplateSettingsForm.Create(Self) do
|
||||
try
|
||||
Templates:=Self.Templates;
|
||||
If ShowModal=MROK then
|
||||
SettingsChanged:=True;
|
||||
Finally
|
||||
Free;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TProjectVariablesForm.SetVariables(const AValue: TStrings);
|
||||
|
||||
|
@ -36,30 +36,48 @@ procedure Register;
|
||||
|
||||
implementation
|
||||
|
||||
uses frmtemplateVariables,ConfigStorage,newitemintf;
|
||||
uses
|
||||
contnrs,frmTemplateSettings,frmtemplateVariables,ConfigStorage,newitemintf,
|
||||
menuintf,idecommands;
|
||||
|
||||
Var
|
||||
TemplateProjectDescriptor : TTemplateProjectDescriptor;
|
||||
IDETemplates : TProjectTemplates;
|
||||
|
||||
itmFileNewFromTemplate : TIDEMenuSection;
|
||||
MenuList : TObjectList;
|
||||
|
||||
Type
|
||||
{ TIDEObject }
|
||||
|
||||
TIDEObject=Class(TObject)
|
||||
FProjDesc : TTemplateProjectDescriptor;
|
||||
FProjMenu : TIDEMenuCommand;
|
||||
Constructor Create(AProjDesc : TTemplateProjectDescriptor;
|
||||
AProjMenu : TIDEMenuCommand);
|
||||
end;
|
||||
|
||||
{ TIDEObject }
|
||||
|
||||
constructor TIDEObject.Create(AProjDesc: TTemplateProjectDescriptor;
|
||||
AProjMenu: TIDEMenuCommand);
|
||||
|
||||
begin
|
||||
FPRojDesc:=AProjDesc;
|
||||
FPRojMenu:=AProjMenu;
|
||||
end;
|
||||
|
||||
Const
|
||||
STemplateCategory = 'Template projects';
|
||||
STemplateSettings = 'itmTemplateSettings';
|
||||
SItmtemplate = 'itmTemplate';
|
||||
|
||||
Procedure RegisterTemplateCategory;
|
||||
Resourcestring
|
||||
SProjectTemplateSettings = 'Project templates options';
|
||||
SNewFromTemplate = 'New project from template';
|
||||
|
||||
begin
|
||||
NewIDEItems.Add(STemplateCategory);
|
||||
end;
|
||||
|
||||
procedure RegisterTemplateProject(ATemplate : TProjectTemplate);
|
||||
|
||||
var
|
||||
ProjDesc: TTemplateProjectDescriptor;
|
||||
|
||||
begin
|
||||
ProjDesc:=TTemplateProjectDescriptor.Create(Atemplate);
|
||||
RegisterProjectDescriptor(ProjDesc,STemplateCategory);
|
||||
end;
|
||||
{ ---------------------------------------------------------------------
|
||||
Configuration
|
||||
---------------------------------------------------------------------}
|
||||
|
||||
Function GetTemplateDir : String;
|
||||
|
||||
@ -72,20 +90,6 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure Register;
|
||||
|
||||
Var
|
||||
I : Integer;
|
||||
D : String;
|
||||
|
||||
begin
|
||||
D:=GetTemplateDir;
|
||||
IDETemplates:=TProjectTemplates.Create(D);
|
||||
RegisterTemplateCategory;
|
||||
For I:=0 to IDETemplates.Count-1 do
|
||||
RegisterTemplateProject(IDETemplates[i]);
|
||||
end;
|
||||
|
||||
procedure SaveTemplateSettings;
|
||||
|
||||
begin
|
||||
@ -98,6 +102,104 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
{ ---------------------------------------------------------------------
|
||||
Registration
|
||||
---------------------------------------------------------------------}
|
||||
|
||||
Procedure RegisterTemplateCategory;
|
||||
|
||||
begin
|
||||
NewIDEItems.Add(STemplateCategory);
|
||||
end;
|
||||
|
||||
Procedure DoProject(Sender : TObject);
|
||||
|
||||
Var
|
||||
I : Integer;
|
||||
Desc : TTemplateProjectDescriptor;
|
||||
|
||||
begin
|
||||
I:=MenuList.count-1;
|
||||
Desc:=Nil;
|
||||
While (Desc=Nil) and (I>=0) do
|
||||
begin
|
||||
With TIDEObject(MenuList[i]) do
|
||||
if FProjMenu=Sender then
|
||||
Desc:=FProjDesc;
|
||||
Dec(i);
|
||||
end;
|
||||
If Desc<>Nil then
|
||||
LazarusIDE.DoNewProject(Desc);
|
||||
end;
|
||||
|
||||
procedure RegisterKnowntemplates;
|
||||
|
||||
Var
|
||||
I : Integer;
|
||||
ATemplate : TProjectTemplate;
|
||||
ProjDesc : TTemplateProjectDescriptor;
|
||||
ProjMenu : TIDEMenuCommand;
|
||||
|
||||
begin
|
||||
For I:=0 to IDETemplates.Count-1 do
|
||||
begin
|
||||
Atemplate:=IDETemplates[i];
|
||||
ProjDesc:=TTemplateProjectDescriptor.Create(Atemplate);
|
||||
RegisterProjectDescriptor(ProjDesc,STemplateCategory);
|
||||
ProjMenu:=RegisterIDEMenuCommand(itmFileNewFromTemplate,
|
||||
SItmtemplate+Atemplate.Name,
|
||||
ATemplate.Name,
|
||||
Nil,@DoProject,Nil);
|
||||
MenuList.Add(TIDEObject.Create(ProjDesc,ProjMenu));
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure UnRegisterKnowntemplates;
|
||||
|
||||
Var
|
||||
I : Integer;
|
||||
|
||||
begin
|
||||
For I:=MenuList.Count-1 downto 0 do
|
||||
begin
|
||||
With TIDEObject(MenuList[i]) do
|
||||
begin
|
||||
ProjectDescriptors.UnregisterDescriptor(FProjDesc);
|
||||
FreeAndNil(FProjMenu);
|
||||
end;
|
||||
MenuList.Delete(I);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure ChangeSettings(Sender : TObject);
|
||||
|
||||
begin
|
||||
With TTemplateSettingsForm.Create(Application) do
|
||||
Try
|
||||
Templates:=IDETemplates;
|
||||
if ShowModal=mrOK then
|
||||
begin
|
||||
SaveTemplateSettings;
|
||||
UnRegisterKnownTemplates;
|
||||
RegisterKnownTemplates;
|
||||
end;
|
||||
Finally
|
||||
Free;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure Register;
|
||||
|
||||
begin
|
||||
RegisterIdeMenuCommand(itmCustomTools,STemplateSettings,SProjectTemplateSettings,nil,@ChangeSettings);
|
||||
itmFileNewFromTemplate:=RegisterIDESubMenu(itmFileNew,
|
||||
'itmFileFromtemplate',
|
||||
SNewFromTemplate);
|
||||
IDETemplates:=TProjectTemplates.Create(GetTemplateDir);
|
||||
RegisterTemplateCategory;
|
||||
RegisterKnownTemplates;
|
||||
end;
|
||||
|
||||
|
||||
{ TTemplateProjectDescriptor }
|
||||
|
||||
@ -109,6 +211,7 @@ var
|
||||
begin
|
||||
With TProjectVariablesForm.Create(Application) do
|
||||
try
|
||||
Caption:=Caption+' '+FTemplate.Name;
|
||||
FVariables.Assign(FTemplate.Variables);
|
||||
I:=FVariables.IndexOfName('ProjName');
|
||||
if (I<>-1) then
|
||||
@ -126,8 +229,6 @@ begin
|
||||
FVariables.Values['ProjName']:=FProjectName;
|
||||
FVariables.Values['ProjDir']:=FProjectDirectory;
|
||||
end;
|
||||
if SettingsChanged then
|
||||
SaveTemplateSettings;
|
||||
finally
|
||||
Free;
|
||||
end;
|
||||
@ -244,4 +345,8 @@ begin
|
||||
Result:=mrCancel;
|
||||
end;
|
||||
|
||||
Initialization
|
||||
MenuList:=TObjectList.Create;
|
||||
Finalization
|
||||
FreeAndNil(MenuList);
|
||||
end.
|
||||
|
Loading…
Reference in New Issue
Block a user