* Project wizards for client/server openapi projects

This commit is contained in:
Michaël Van Canneyt 2025-01-05 23:16:49 +01:00
parent 55123014f7
commit 21de341ae2
11 changed files with 2439 additions and 285 deletions

View File

@ -0,0 +1,110 @@
object LazOpenAPIProjectOptions: TLazOpenAPIProjectOptions
Left = 0
Height = 302
Top = 0
Width = 567
ClientHeight = 302
ClientWidth = 567
TabOrder = 0
DesignLeft = 468
DesignTop = 287
object lblOpenAPIFile: TLabel
AnchorSideTop.Control = FEOpenAPI
AnchorSideRight.Control = FEOpenAPI
AnchorSideBottom.Control = FEOpenAPI
AnchorSideBottom.Side = asrBottom
Left = 104
Height = 28
Top = 16
Width = 80
Alignment = taRightJustify
Anchors = [akTop, akLeft, akRight, akBottom]
AutoSize = False
BorderSpacing.Right = 8
Caption = 'Open API File'
Layout = tlCenter
end
object lblBaseUnitFile: TLabel
AnchorSideTop.Control = FEBaseUnitFile
AnchorSideRight.Control = FEBaseUnitFile
AnchorSideBottom.Control = FEBaseUnitFile
AnchorSideBottom.Side = asrBottom
Left = 67
Height = 28
Top = 88
Width = 117
Alignment = taRightJustify
Anchors = [akTop, akLeft, akRight, akBottom]
AutoSize = False
BorderSpacing.Right = 8
Caption = 'Base unit filename'
Layout = tlCenter
end
object lblConfig: TLabel
AnchorSideTop.Control = FEConfig
AnchorSideRight.Control = FEConfig
AnchorSideBottom.Control = FEConfig
AnchorSideBottom.Side = asrBottom
Left = 32
Height = 28
Top = 52
Width = 152
Alignment = taRightJustify
Anchors = [akTop, akLeft, akRight, akBottom]
AutoSize = False
BorderSpacing.Right = 8
Caption = 'Generator configuration'
Layout = tlCenter
end
object FEOpenAPI: TFileNameEdit
AnchorSideTop.Control = Owner
Left = 192
Height = 28
Top = 16
Width = 360
FilterIndex = 0
HideDirectories = False
ButtonWidth = 23
NumGlyphs = 1
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Top = 16
MaxLength = 0
TabOrder = 0
end
object FEConfig: TFileNameEdit
AnchorSideTop.Control = FEOpenAPI
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = FEOpenAPI
AnchorSideRight.Side = asrBottom
Left = 192
Height = 28
Top = 52
Width = 360
FilterIndex = 0
HideDirectories = False
ButtonWidth = 23
NumGlyphs = 1
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Top = 8
MaxLength = 0
TabOrder = 1
end
object FEBaseUnitFile: TFileNameEdit
AnchorSideTop.Control = FEConfig
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = FEConfig
AnchorSideRight.Side = asrBottom
Left = 192
Height = 28
Top = 88
Width = 360
FilterIndex = 0
HideDirectories = False
ButtonWidth = 23
NumGlyphs = 1
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Top = 8
MaxLength = 0
TabOrder = 2
end
end

View File

@ -0,0 +1,85 @@
unit fraopenapiprojectsettings;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, Forms, Controls, StdCtrls, EditBtn,
// IdeIntf
LazIDEIntf, ProjectIntf, CompOptsIntf, IDEOptionsIntf, IDEOptEditorIntf,
// Openapi
lazopenapistr, lazopenapictrl
;
type
{ TLazOpenAPIProjectOptions }
TLazOpenAPIProjectOptions = class(TAbstractIDEOptionsEditor)
FEOpenAPI: TFileNameEdit;
FEBaseUnitFile: TFileNameEdit;
FEConfig: TFileNameEdit;
lblBaseUnitFile: TLabel;
lblConfig: TLabel;
lblOpenAPIFile: TLabel;
private
public
function GetTitle: string; override;
procedure Setup({%H-}ADialog: TAbstractOptionsEditorDialog); override;
procedure ReadSettings(AOptions: TAbstractIDEOptions); override;
procedure WriteSettings(AOptions: TAbstractIDEOptions); override;
class function SupportedOptionsClass: TAbstractIDEOptionsClass; override;
end;
implementation
{$R *.lfm}
{ TLazOpenAPIProjectOptions }
function TLazOpenAPIProjectOptions.GetTitle: string;
begin
Result:=SOpenAPIProjectOptionsCaption;
end;
procedure TLazOpenAPIProjectOptions.Setup(ADialog: TAbstractOptionsEditorDialog);
var
lPath : String;
begin
lPath:=ExtractFilePath(LazarusIDE.ActiveProject.ProjectInfoFile);
FEConfig.InitialDir:=lPath;
FEBaseUnitFile.InitialDir:=lPath;
FEOpenAPI.InitialDir:=lPath;
end;
procedure TLazOpenAPIProjectOptions.ReadSettings(AOptions: TAbstractIDEOptions);
var
lOpenAPI,lConfig,lBaseFile : String;
begin
OpenAPIHandler.GetProjectData(LazarusIDE.ActiveProject,lConfig,lOpenAPI,lBaseFile);
FEConfig.FileName:=lConfig;
FEOpenAPI.FileName:=lOpenAPI;
FEBaseUnitFile.FileName:=lBaseFile;
end;
procedure TLazOpenAPIProjectOptions.WriteSettings(AOptions: TAbstractIDEOptions);
var
lOpenAPI,lConfig,lBaseFile : String;
begin
lConfig:=FEConfig.FileName;
lOpenAPI:=FEOpenAPI.FileName;
lBaseFile:=FEBaseUnitFile.FileName;
OpenAPIHandler.SetProjectData(LazarusIDE.ActiveProject,lConfig,lOpenAPI,lBaseFile);
end;
class function TLazOpenAPIProjectOptions.SupportedOptionsClass: TAbstractIDEOptionsClass;
begin
Result:=TAbstractIDEProjectOptions;
end;
end.

View File

@ -1,10 +1,10 @@
object GeneratorSettingsFrame: TGeneratorSettingsFrame object GeneratorSettingsFrame: TGeneratorSettingsFrame
Left = 0 Left = 0
Height = 500 Height = 479
Top = 0 Top = 0
Width = 711 Width = 753
ClientHeight = 500 ClientHeight = 479
ClientWidth = 711 ClientWidth = 753
TabOrder = 0 TabOrder = 0
DesignLeft = 495 DesignLeft = 495
DesignTop = 272 DesignTop = 272
@ -12,7 +12,7 @@ object GeneratorSettingsFrame: TGeneratorSettingsFrame
Left = 104 Left = 104
Height = 28 Height = 28
Top = 8 Top = 8
Width = 591 Width = 633
FileName = 'edtFile' FileName = 'edtFile'
DialogOptions = [ofFileMustExist, ofEnableSizing, ofViewDetail] DialogOptions = [ofFileMustExist, ofEnableSizing, ofViewDetail]
Filter = 'JSON files|*.json|All files|*.*' Filter = 'JSON files|*.json|All files|*.*'
@ -76,21 +76,22 @@ object GeneratorSettingsFrame: TGeneratorSettingsFrame
AnchorSideBottom.Control = Owner AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom AnchorSideBottom.Side = asrBottom
Left = 16 Left = 16
Height = 409 Height = 388
Top = 75 Top = 75
Width = 679 Width = 721
ActivePage = TSGeneral ActivePage = TSServiceMap
Anchors = [akTop, akLeft, akRight, akBottom] Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Left = 16 BorderSpacing.Left = 16
BorderSpacing.Top = 8 BorderSpacing.Top = 8
BorderSpacing.Right = 16 BorderSpacing.Right = 16
BorderSpacing.Bottom = 16 BorderSpacing.Bottom = 16
TabIndex = 0 TabIndex = 5
TabOrder = 3 TabOrder = 3
object TSGeneral: TTabSheet object TSGeneral: TTabSheet
Caption = 'General' Caption = 'General'
ClientHeight = 379 ClientHeight = 358
ClientWidth = 669 ClientWidth = 711
OnContextPopup = TSGeneralContextPopup
object CBDelphiCode: TCheckBox object CBDelphiCode: TCheckBox
AnchorSideLeft.Control = TSGeneral AnchorSideLeft.Control = TSGeneral
AnchorSideTop.Control = TSGeneral AnchorSideTop.Control = TSGeneral
@ -132,21 +133,20 @@ object GeneratorSettingsFrame: TGeneratorSettingsFrame
AnchorSideTop.Control = CBEnums AnchorSideTop.Control = CBEnums
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
Left = 16 Left = 16
Height = 147 Height = 99
Top = 101 Top = 101
Width = 560 Width = 683
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Top = 8 BorderSpacing.Top = 8
Caption = 'Automatic file naming' Caption = 'Automatic file naming'
ClientHeight = 130 ClientHeight = 82
ClientWidth = 558 ClientWidth = 681
TabOrder = 3 TabOrder = 3
object edtUnitSuffix: TEdit object edtUnitSuffix: TEdit
AnchorSideLeft.Control = lblUnitSuffix AnchorSideTop.Control = GBAutoNaming
AnchorSideTop.Control = lblUnitSuffix Left = 180
AnchorSideTop.Side = asrBottom
Left = 16
Height = 28 Height = 28
Top = 32 Top = 8
Width = 176 Width = 176
BorderSpacing.Top = 8 BorderSpacing.Top = 8
TabOrder = 0 TabOrder = 0
@ -154,141 +154,179 @@ object GeneratorSettingsFrame: TGeneratorSettingsFrame
end end
object lblUnitSuffix: TLabel object lblUnitSuffix: TLabel
AnchorSideLeft.Control = GBAutoNaming AnchorSideLeft.Control = GBAutoNaming
AnchorSideTop.Control = GBAutoNaming AnchorSideTop.Control = edtUnitSuffix
Left = 16 AnchorSideRight.Control = edtUnitSuffix
Height = 16 AnchorSideBottom.Control = edtUnitSuffix
AnchorSideBottom.Side = asrBottom
Left = 8
Height = 28
Top = 8 Top = 8
Width = 156 Width = 164
BorderSpacing.Left = 16 Alignment = taRightJustify
BorderSpacing.Top = 8 Anchors = [akTop, akLeft, akRight, akBottom]
AutoSize = False
BorderSpacing.Left = 8
BorderSpacing.Right = 8
Caption = 'Unit name suffix template' Caption = 'Unit name suffix template'
Layout = tlCenter
end end
object edtUnitExtension: TEdit object edtUnitExtension: TEdit
AnchorSideLeft.Control = lblUnitNameExtension AnchorSideLeft.Control = edtUnitSuffix
AnchorSideTop.Control = lblUnitNameExtension AnchorSideTop.Control = edtUnitSuffix
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
Left = 16 Left = 180
Height = 28 Height = 28
Top = 92 Top = 44
Width = 80 Width = 176
BorderSpacing.Top = 8 BorderSpacing.Top = 8
TabOrder = 1 TabOrder = 1
Text = 'edtUnitExtension' Text = 'edtUnitExtension'
end end
object lblUnitNameExtension: TLabel object lblUnitNameExtension: TLabel
AnchorSideLeft.Control = edtUnitSuffix AnchorSideLeft.Control = GBAutoNaming
AnchorSideTop.Control = edtUnitSuffix AnchorSideTop.Control = edtUnitExtension
AnchorSideTop.Side = asrBottom AnchorSideRight.Control = edtUnitExtension
Left = 16 AnchorSideBottom.Control = edtUnitExtension
Height = 16 AnchorSideBottom.Side = asrBottom
Top = 68 Left = 0
Width = 123 Height = 28
BorderSpacing.Top = 8 Top = 44
Width = 172
Alignment = taRightJustify
Anchors = [akTop, akLeft, akRight, akBottom]
AutoSize = False
BorderSpacing.Right = 8
Caption = 'Unit name extension' Caption = 'Unit name extension'
Layout = tlCenter
end end
end end
object edtServiceNameSuffix: TEdit object edtServiceNameSuffix: TEdit
AnchorSideLeft.Control = lblServiceNameSuffix AnchorSideTop.Control = GBAutoNaming
AnchorSideTop.Control = lblServiceNameSuffix
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
Left = 16 Left = 198
Height = 28 Height = 28
Top = 280 Top = 208
Width = 136 Width = 136
BorderSpacing.Top = 8 BorderSpacing.Top = 8
TabOrder = 4 TabOrder = 4
Text = 'edtServiceNameSuffix' Text = 'edtServiceNameSuffix'
end end
object edtServiceNamePrefix: TEdit object edtServiceNamePrefix: TEdit
AnchorSideLeft.Control = Label1 AnchorSideLeft.Control = edtServiceNameSuffix
AnchorSideTop.Control = Label1 AnchorSideTop.Control = edtServiceNameSuffix
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
Left = 16 Left = 198
Height = 28 Height = 28
Top = 340 Top = 244
Width = 144 Width = 134
BorderSpacing.Top = 8 BorderSpacing.Top = 8
TabOrder = 5 TabOrder = 5
Text = 'edtServiceNamePrefix' Text = 'edtServiceNamePrefix'
end end
object lblServiceNameSuffix: TLabel object lblServiceNameSuffix: TLabel
AnchorSideLeft.Control = GBAutoNaming AnchorSideLeft.Control = GBAutoNaming
AnchorSideTop.Control = GBAutoNaming
AnchorSideTop.Side = asrBottom
Left = 16
Height = 16
Top = 256
Width = 116
BorderSpacing.Top = 8
Caption = 'Service name suffix'
end
object Label1: TLabel
AnchorSideLeft.Control = edtServiceNameSuffix
AnchorSideTop.Control = edtServiceNameSuffix AnchorSideTop.Control = edtServiceNameSuffix
AnchorSideTop.Side = asrBottom AnchorSideRight.Control = edtServiceNameSuffix
AnchorSideBottom.Control = edtServiceNameSuffix
AnchorSideBottom.Side = asrBottom
Left = 16 Left = 16
Height = 16 Height = 28
Top = 316 Top = 208
Width = 117 Width = 174
BorderSpacing.Top = 8 Alignment = taRightJustify
Anchors = [akTop, akLeft, akRight, akBottom]
AutoSize = False
BorderSpacing.Right = 8
Caption = 'Service name suffix'
Layout = tlCenter
end
object lblServiceNamePrefix: TLabel
AnchorSideLeft.Control = GBAutoNaming
AnchorSideTop.Control = edtServiceNamePrefix
AnchorSideRight.Control = edtServiceNamePrefix
AnchorSideBottom.Control = edtServiceNamePrefix
AnchorSideBottom.Side = asrBottom
Left = 16
Height = 28
Top = 244
Width = 174
Alignment = taRightJustify
Anchors = [akTop, akLeft, akRight, akBottom]
AutoSize = False
BorderSpacing.Right = 8
Caption = 'Service name prefix' Caption = 'Service name prefix'
Layout = tlCenter
end end
end end
object TSData: TTabSheet object TSData: TTabSheet
Caption = 'Data' Caption = 'Data'
ClientHeight = 379 ClientHeight = 358
ClientWidth = 669 ClientWidth = 711
object edtDtoUnit: TEdit object edtDtoUnit: TEdit
AnchorSideLeft.Control = lblDtoUnitName
AnchorSideTop.Control = lblDtoUnitName
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
Left = 16 Left = 160
Height = 28 Height = 28
Top = 32 Top = 8
Width = 160 Width = 160
BorderSpacing.Top = 8 BorderSpacing.Top = 8
TabOrder = 0 TabOrder = 0
Text = 'edtDtoUnit' Text = 'edtDtoUnit'
end end
object edtSerializeUnit: TEdit object edtSerializeUnit: TEdit
AnchorSideLeft.Control = lblDtoUnitName AnchorSideLeft.Control = edtDtoUnit
AnchorSideTop.Control = lblSerializeUnit AnchorSideTop.Control = edtDtoUnit
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
Left = 16 AnchorSideRight.Control = edtDtoUnit
AnchorSideRight.Side = asrBottom
Left = 160
Height = 28 Height = 28
Top = 92 Top = 44
Width = 160 Width = 160
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Top = 8 BorderSpacing.Top = 8
TabOrder = 1 TabOrder = 1
Text = 'edtSerializeUnit' Text = 'edtSerializeUnit'
end end
object lblDtoUnitName: TLabel object lblDtoUnitName: TLabel
AnchorSideLeft.Control = TSData AnchorSideLeft.Control = TSData
AnchorSideTop.Control = TSData AnchorSideTop.Control = edtDtoUnit
AnchorSideRight.Control = edtDtoUnit
AnchorSideBottom.Control = edtDtoUnit
AnchorSideBottom.Side = asrBottom
Left = 16 Left = 16
Height = 16 Height = 28
Top = 8 Top = 8
Width = 86 Width = 136
Alignment = taRightJustify
Anchors = [akTop, akLeft, akRight, akBottom]
AutoSize = False
BorderSpacing.Left = 16 BorderSpacing.Left = 16
BorderSpacing.Top = 8 BorderSpacing.Right = 8
Caption = 'Dto unit name' Caption = 'Dto unit name'
Layout = tlCenter
end end
object lblSerializeUnit: TLabel object lblSerializeUnit: TLabel
AnchorSideLeft.Control = lblDtoUnitName AnchorSideLeft.Control = lblDtoUnitName
AnchorSideTop.Control = edtDtoUnit AnchorSideTop.Control = edtSerializeUnit
AnchorSideTop.Side = asrBottom AnchorSideRight.Control = edtSerializeUnit
AnchorSideBottom.Control = edtSerializeUnit
AnchorSideBottom.Side = asrBottom
Left = 16 Left = 16
Height = 16 Height = 28
Top = 68 Top = 44
Width = 81 Width = 136
BorderSpacing.Top = 8 Alignment = taRightJustify
Anchors = [akTop, akLeft, akRight, akBottom]
AutoSize = False
BorderSpacing.Right = 8
Caption = 'Serializer unit' Caption = 'Serializer unit'
Layout = tlCenter
end end
end end
object TSClient: TTabSheet object TSClient: TTabSheet
Caption = 'Client' Caption = 'Client'
ClientHeight = 379 ClientHeight = 358
ClientWidth = 669 ClientWidth = 711
object CBAsyncService: TCheckBox object CBAsyncService: TCheckBox
AnchorSideLeft.Control = TSClient AnchorSideLeft.Control = TSClient
AnchorSideTop.Control = TSClient AnchorSideTop.Control = TSClient
@ -316,24 +354,26 @@ object GeneratorSettingsFrame: TGeneratorSettingsFrame
TabOrder = 1 TabOrder = 1
end end
object edtClientServiceImplementationUnit: TEdit object edtClientServiceImplementationUnit: TEdit
AnchorSideLeft.Control = CBAsyncService AnchorSideLeft.Control = edtClientServiceInterfaceUnit
AnchorSideTop.Control = lblClientServiceImplementationUnit AnchorSideTop.Control = edtClientServiceInterfaceUnit
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
Left = 16 AnchorSideRight.Control = edtClientServiceInterfaceUnit
AnchorSideRight.Side = asrBottom
Left = 340
Height = 28 Height = 28
Top = 154 Top = 168
Width = 208 Width = 208
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Top = 8 BorderSpacing.Top = 8
TabOrder = 2 TabOrder = 2
Text = 'edtClientServiceImplementationUnit' Text = 'edtClientServiceImplementationUnit'
end end
object edtClientServiceInterfaceUnit: TEdit object edtClientServiceInterfaceUnit: TEdit
AnchorSideLeft.Control = CBAsyncService AnchorSideTop.Control = cbProxyModuleFormFile
AnchorSideTop.Control = lblClientServiceInterfaceUnit
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
Left = 16 Left = 340
Height = 28 Height = 28
Top = 94 Top = 132
Width = 208 Width = 208
BorderSpacing.Top = 8 BorderSpacing.Top = 8
TabOrder = 3 TabOrder = 3
@ -341,77 +381,193 @@ object GeneratorSettingsFrame: TGeneratorSettingsFrame
end end
object lblClientServiceInterfaceUnit: TLabel object lblClientServiceInterfaceUnit: TLabel
AnchorSideLeft.Control = CBAsyncService AnchorSideLeft.Control = CBAsyncService
AnchorSideTop.Control = cbCancelRequest AnchorSideTop.Control = edtClientServiceInterfaceUnit
AnchorSideTop.Side = asrBottom AnchorSideRight.Control = edtClientServiceInterfaceUnit
Left = 16 AnchorSideBottom.Control = edtClientServiceInterfaceUnit
Height = 16 AnchorSideBottom.Side = asrBottom
Top = 70 Left = 102
Width = 198 Height = 28
BorderSpacing.Top = 8 Top = 132
Width = 230
Alignment = taRightJustify
Anchors = [akTop, akRight, akBottom]
AutoSize = False
BorderSpacing.Right = 8
Caption = 'Client service interface unit name' Caption = 'Client service interface unit name'
Layout = tlCenter
end end
object lblClientServiceImplementationUnit: TLabel object lblClientServiceImplementationUnit: TLabel
AnchorSideLeft.Control = CBAsyncService AnchorSideLeft.Control = CBAsyncService
AnchorSideTop.Control = edtClientServiceInterfaceUnit AnchorSideTop.Control = edtClientServiceImplementationUnit
AnchorSideTop.Side = asrBottom AnchorSideRight.Control = edtClientServiceImplementationUnit
Left = 16 AnchorSideBottom.Control = edtClientServiceImplementationUnit
Height = 16 AnchorSideBottom.Side = asrBottom
Top = 130
Width = 278
BorderSpacing.Top = 8
Caption = 'Client service proxy implementation unit name'
end
object edtClientServiceParentClass: TEdit
AnchorSideLeft.Control = CBAsyncService
AnchorSideTop.Control = lblClientServiceParentClass
AnchorSideTop.Side = asrBottom
Left = 16 Left = 16
Height = 28 Height = 28
Top = 214 Top = 168
Width = 316
Alignment = taRightJustify
Anchors = [akTop, akLeft, akRight, akBottom]
AutoSize = False
BorderSpacing.Right = 8
Caption = 'Client service proxy implementation unit name'
Layout = tlCenter
end
object edtClientServiceParentClass: TEdit
AnchorSideLeft.Control = edtClientServiceImplementationUnit
AnchorSideTop.Control = edtClientServiceImplementationUnit
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = edtClientServiceImplementationUnit
AnchorSideRight.Side = asrBottom
Left = 340
Height = 28
Top = 204
Width = 208 Width = 208
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Top = 8 BorderSpacing.Top = 8
TabOrder = 4 TabOrder = 4
Text = 'edtClientServiceParentClass' Text = 'edtClientServiceParentClass'
end end
object edtClientServiceParentUnit: TEdit object edtClientServiceParentUnit: TEdit
AnchorSideLeft.Control = CBAsyncService AnchorSideLeft.Control = edtClientServiceParentClass
AnchorSideTop.Control = lblClientServiceParentUnit AnchorSideTop.Control = edtClientServiceParentClass
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
Left = 16 AnchorSideRight.Control = edtClientServiceParentClass
AnchorSideRight.Side = asrBottom
Left = 340
Height = 28 Height = 28
Top = 274 Top = 240
Width = 208 Width = 208
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Top = 8 BorderSpacing.Top = 8
TabOrder = 5 TabOrder = 5
Text = 'edtClientServiceParentUnit' Text = 'edtClientServiceParentUnit'
end end
object lblClientServiceParentClass: TLabel object lblClientServiceParentClass: TLabel
AnchorSideLeft.Control = CBAsyncService AnchorSideLeft.Control = CBAsyncService
AnchorSideTop.Control = edtClientServiceImplementationUnit AnchorSideTop.Control = edtClientServiceParentClass
AnchorSideTop.Side = asrBottom AnchorSideRight.Control = edtClientServiceParentClass
AnchorSideBottom.Control = edtClientServiceParentClass
AnchorSideBottom.Side = asrBottom
Left = 16 Left = 16
Height = 16 Height = 28
Top = 190 Top = 204
Width = 154 Width = 316
BorderSpacing.Top = 8 Alignment = taRightJustify
Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Right = 8
Caption = 'Client service parent class' Caption = 'Client service parent class'
Layout = tlCenter
end end
object lblClientServiceParentUnit: TLabel object lblClientServiceParentUnit: TLabel
AnchorSideLeft.Control = CBAsyncService AnchorSideLeft.Control = CBAsyncService
AnchorSideTop.Control = edtClientServiceParentClass AnchorSideTop.Control = edtClientServiceParentUnit
AnchorSideRight.Control = edtClientServiceParentUnit
AnchorSideBottom.Control = edtClientServiceParentUnit
AnchorSideBottom.Side = asrBottom
Left = 16
Height = 28
Top = 240
Width = 316
Alignment = taRightJustify
Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Right = 8
Caption = 'Client service parent unit name'
Layout = tlCenter
end
object cbGenerateServerProxyModule: TCheckBox
AnchorSideLeft.Control = CBAsyncService
AnchorSideTop.Control = cbCancelRequest
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
Left = 16 Left = 16
Height = 16 Height = 23
Top = 250 Top = 70
Width = 185 Width = 208
BorderSpacing.Top = 8 BorderSpacing.Top = 8
Caption = 'Client service parent unit name' Caption = 'Generate server proxy module'
TabOrder = 6
OnChange = cbGenerateServerProxyModuleChange
end
object Label2: TLabel
AnchorSideLeft.Control = CBAsyncService
AnchorSideTop.Control = edtServerProxyModule
AnchorSideRight.Control = edtServerProxyModule
AnchorSideBottom.Control = edtServerProxyModule
AnchorSideBottom.Side = asrBottom
Left = 16
Height = 28
Top = 276
Width = 316
Alignment = taRightJustify
Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Right = 8
Caption = 'Client Serverproxy module unit'
Layout = tlCenter
end
object edtServerProxyModule: TEdit
AnchorSideLeft.Control = edtClientServiceParentUnit
AnchorSideTop.Control = edtClientServiceParentUnit
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = edtClientServiceParentUnit
AnchorSideRight.Side = asrBottom
Left = 340
Height = 28
Top = 276
Width = 208
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Top = 8
TabOrder = 7
Text = 'edtServerProxyModule'
end
object lblServerProxyUnit: TLabel
AnchorSideLeft.Control = CBAsyncService
AnchorSideTop.Control = edtServerProxyUnit
AnchorSideRight.Control = edtServerProxyUnit
AnchorSideBottom.Control = edtServerProxyUnit
AnchorSideBottom.Side = asrBottom
Left = 16
Height = 28
Top = 312
Width = 316
Alignment = taRightJustify
Anchors = [akTop, akLeft, akRight, akBottom]
AutoSize = False
BorderSpacing.Right = 8
Caption = 'Server Proxy unit name'
Layout = tlCenter
end
object edtServerProxyUnit: TEdit
AnchorSideLeft.Control = edtServerProxyModule
AnchorSideTop.Control = edtServerProxyModule
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = edtServerProxyModule
AnchorSideRight.Side = asrBottom
Left = 340
Height = 28
Top = 312
Width = 208
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Top = 8
TabOrder = 8
Text = 'edtServerProxyUnit'
end
object cbProxyModuleFormFile: TCheckBox
AnchorSideLeft.Control = cbCancelRequest
AnchorSideTop.Control = cbGenerateServerProxyModule
AnchorSideTop.Side = asrBottom
Left = 40
Height = 23
Top = 101
Width = 212
BorderSpacing.Top = 8
Caption = 'Generate datamodule form file'
TabOrder = 9
end end
end end
object TSServer: TTabSheet object TSServer: TTabSheet
Caption = 'Server' Caption = 'Server'
ClientHeight = 379 ClientHeight = 358
ClientWidth = 669 ClientWidth = 711
object CBSkipImplementation: TCheckBox object CBSkipImplementation: TCheckBox
AnchorSideLeft.Control = CBAbstractCalls AnchorSideLeft.Control = CBAbstractCalls
AnchorSideTop.Control = CBAbstractCalls AnchorSideTop.Control = CBAbstractCalls
@ -439,107 +595,139 @@ object GeneratorSettingsFrame: TGeneratorSettingsFrame
OnChange = HandleAbstract OnChange = HandleAbstract
end end
object edtServerHandlerUnitName: TEdit object edtServerHandlerUnitName: TEdit
AnchorSideLeft.Control = CBAbstractCalls AnchorSideTop.Control = CBSkipImplementation
AnchorSideTop.Control = lblServerHandlerUnitName
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
Left = 16 Left = 240
Height = 28 Height = 28
Top = 94 Top = 70
Width = 242 Width = 242
BorderSpacing.Top = 8 BorderSpacing.Top = 8
TabOrder = 2 TabOrder = 2
Text = 'edtServerHandlerUnitName' Text = 'edtServerHandlerUnitName'
end end
object edtServerImplementationUnitName: TEdit object edtServerImplementationUnitName: TEdit
AnchorSideLeft.Control = CBAbstractCalls AnchorSideLeft.Control = edtServerHandlerUnitName
AnchorSideTop.Control = lblServerImplementationUnitName AnchorSideTop.Control = edtServerHandlerUnitName
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
Left = 16 AnchorSideRight.Control = edtServerHandlerUnitName
AnchorSideRight.Side = asrBottom
Left = 240
Height = 28 Height = 28
Top = 154 Top = 106
Width = 240 Width = 242
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Top = 8 BorderSpacing.Top = 8
TabOrder = 3 TabOrder = 3
Text = 'edtServerImplementationUnitName' Text = 'edtServerImplementationUnitName'
end end
object edtServerServiceParentClass: TEdit object edtServerServiceParentClass: TEdit
AnchorSideLeft.Control = CBAbstractCalls AnchorSideLeft.Control = edtServerImplementationUnitName
AnchorSideTop.Control = lblServerServiceParentClass AnchorSideTop.Control = edtServerImplementationUnitName
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
Left = 16 AnchorSideRight.Control = edtServerHandlerUnitName
AnchorSideRight.Side = asrBottom
Left = 240
Height = 28 Height = 28
Top = 214 Top = 142
Width = 216 Width = 242
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Top = 8 BorderSpacing.Top = 8
TabOrder = 4 TabOrder = 4
Text = 'edtServerServiceParentClass' Text = 'edtServerServiceParentClass'
end end
object edtServerServiceParentUnit: TEdit object edtServerServiceParentUnit: TEdit
AnchorSideLeft.Control = CBAbstractCalls AnchorSideLeft.Control = edtServerServiceParentClass
AnchorSideTop.Control = lblServerServiceParentUnit AnchorSideTop.Control = edtServerServiceParentClass
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
Left = 16 AnchorSideRight.Control = edtServerHandlerUnitName
AnchorSideRight.Side = asrBottom
Left = 240
Height = 28 Height = 28
Top = 275 Top = 178
Width = 208 Width = 242
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Top = 8 BorderSpacing.Top = 8
TabOrder = 5 TabOrder = 5
Text = 'edtServerServiceParentUnit' Text = 'edtServerServiceParentUnit'
end end
object lblServerHandlerUnitName: TLabel object lblServerHandlerUnitName: TLabel
AnchorSideLeft.Control = CBAbstractCalls AnchorSideLeft.Control = CBAbstractCalls
AnchorSideTop.Control = CBSkipImplementation AnchorSideTop.Control = edtServerHandlerUnitName
AnchorSideTop.Side = asrBottom AnchorSideRight.Control = edtServerHandlerUnitName
AnchorSideBottom.Control = edtServerHandlerUnitName
AnchorSideBottom.Side = asrBottom
Left = 16 Left = 16
Height = 16 Height = 28
Top = 70 Top = 70
Width = 151 Width = 216
BorderSpacing.Top = 8 Alignment = taRightJustify
Anchors = [akTop, akLeft, akRight, akBottom]
AutoSize = False
BorderSpacing.Right = 8
Caption = 'Server handler unit name' Caption = 'Server handler unit name'
Layout = tlCenter
end end
object lblServerImplementationUnitName: TLabel object lblServerImplementationUnitName: TLabel
AnchorSideLeft.Control = CBAbstractCalls AnchorSideLeft.Control = CBAbstractCalls
AnchorSideTop.Control = edtServerHandlerUnitName AnchorSideTop.Control = edtServerImplementationUnitName
AnchorSideTop.Side = asrBottom AnchorSideRight.Control = edtServerImplementationUnitName
AnchorSideBottom.Control = edtServerImplementationUnitName
AnchorSideBottom.Side = asrBottom
Left = 16 Left = 16
Height = 16 Height = 28
Top = 130 Top = 106
Width = 199 Width = 216
BorderSpacing.Top = 8 Alignment = taRightJustify
Anchors = [akTop, akLeft, akRight, akBottom]
AutoSize = False
BorderSpacing.Right = 8
Caption = 'Server implementation unit name' Caption = 'Server implementation unit name'
Layout = tlCenter
end end
object lblServerServiceParentClass: TLabel object lblServerServiceParentClass: TLabel
AnchorSideLeft.Control = CBAbstractCalls AnchorSideLeft.Control = CBAbstractCalls
AnchorSideTop.Control = edtServerImplementationUnitName AnchorSideTop.Control = edtServerServiceParentClass
AnchorSideTop.Side = asrBottom AnchorSideRight.Control = edtServerServiceParentClass
AnchorSideBottom.Control = edtServerServiceParentClass
AnchorSideBottom.Side = asrBottom
Left = 16 Left = 16
Height = 16 Height = 28
Top = 190 Top = 142
Width = 157 Width = 216
BorderSpacing.Top = 8 Alignment = taRightJustify
Anchors = [akTop, akLeft, akRight, akBottom]
AutoSize = False
BorderSpacing.Right = 8
Caption = 'Server service parent class' Caption = 'Server service parent class'
Layout = tlCenter
end end
object lblServerServiceParentUnit: TLabel object lblServerServiceParentUnit: TLabel
AnchorSideLeft.Control = CBAbstractCalls AnchorSideLeft.Control = CBAbstractCalls
AnchorSideTop.Control = edtServerServiceParentClass AnchorSideTop.Control = edtServerServiceParentUnit
AnchorSideTop.Side = asrBottom AnchorSideRight.Control = edtServerServiceParentUnit
AnchorSideBottom.Control = edtServerServiceParentUnit
AnchorSideBottom.Side = asrBottom
Left = 16 Left = 16
Height = 16 Height = 28
Top = 251 Top = 178
Width = 187 Width = 216
BorderSpacing.Top = 9 Alignment = taRightJustify
Anchors = [akTop, akLeft, akRight, akBottom]
AutoSize = False
BorderSpacing.Right = 8
Caption = 'server service parent unit name' Caption = 'server service parent unit name'
Layout = tlCenter
end end
end end
object TSUUIDMap: TTabSheet object TSUUIDMap: TTabSheet
Caption = 'GUID map' Caption = 'GUID map'
ClientHeight = 379 ClientHeight = 358
ClientWidth = 669 ClientWidth = 711
object VLEUUIDMap: TValueListEditor object VLEUUIDMap: TValueListEditor
Left = 8 Left = 8
Height = 316 Height = 298
Top = 16 Top = 16
Width = 653 Width = 695
Anchors = [akTop, akLeft, akRight, akBottom] Anchors = [akTop, akLeft, akRight, akBottom]
DefaultColWidth = 200 DefaultColWidth = 200
FixedCols = 0 FixedCols = 0
@ -553,15 +741,15 @@ object GeneratorSettingsFrame: TGeneratorSettingsFrame
'GUID' 'GUID'
) )
ColWidths = ( ColWidths = (
325 346
324 345
) )
end end
object edtUUIDMap: TFileNameEdit object edtUUIDMap: TFileNameEdit
Left = 112 Left = 112
Height = 28 Height = 28
Top = 343 Top = 325
Width = 461 Width = 503
DialogKind = dkSave DialogKind = dkSave
DialogOptions = [ofPathMustExist, ofEnableSizing, ofViewDetail] DialogOptions = [ofPathMustExist, ofEnableSizing, ofViewDetail]
FilterIndex = 0 FilterIndex = 0
@ -580,7 +768,7 @@ object GeneratorSettingsFrame: TGeneratorSettingsFrame
AnchorSideBottom.Side = asrBottom AnchorSideBottom.Side = asrBottom
Left = 8 Left = 8
Height = 28 Height = 28
Top = 343 Top = 325
Width = 96 Width = 96
Alignment = taRightJustify Alignment = taRightJustify
Anchors = [akTop, akLeft, akRight, akBottom] Anchors = [akTop, akLeft, akRight, akBottom]
@ -589,9 +777,9 @@ object GeneratorSettingsFrame: TGeneratorSettingsFrame
Layout = tlCenter Layout = tlCenter
end end
object btnLoadUUIDMap: TButton object btnLoadUUIDMap: TButton
Left = 586 Left = 628
Height = 25 Height = 25
Top = 343 Top = 325
Width = 75 Width = 75
Anchors = [akRight, akBottom] Anchors = [akRight, akBottom]
Caption = 'Load' Caption = 'Load'
@ -601,13 +789,13 @@ object GeneratorSettingsFrame: TGeneratorSettingsFrame
end end
object TSServiceMap: TTabSheet object TSServiceMap: TTabSheet
Caption = 'Service name map' Caption = 'Service name map'
ClientHeight = 379 ClientHeight = 358
ClientWidth = 669 ClientWidth = 711
object VLEServiceMap: TValueListEditor object VLEServiceMap: TValueListEditor
Left = 8 Left = 8
Height = 316 Height = 298
Top = 16 Top = 16
Width = 653 Width = 695
Anchors = [akTop, akLeft, akRight, akBottom] Anchors = [akTop, akLeft, akRight, akBottom]
DefaultColWidth = 200 DefaultColWidth = 200
FixedCols = 0 FixedCols = 0
@ -617,12 +805,12 @@ object GeneratorSettingsFrame: TGeneratorSettingsFrame
KeyOptions = [keyEdit, keyAdd, keyDelete, keyUnique] KeyOptions = [keyEdit, keyAdd, keyDelete, keyUnique]
Options = [goFixedVertLine, goFixedHorzLine, goVertLine, goHorzLine, goColSizing, goEditing, goAutoAddRows, goAlwaysShowEditor, goThumbTracking] Options = [goFixedVertLine, goFixedHorzLine, goVertLine, goHorzLine, goColSizing, goEditing, goAutoAddRows, goAlwaysShowEditor, goThumbTracking]
TitleCaptions.Strings = ( TitleCaptions.Strings = (
'Interface' 'ServiceOperation'
'GUID' 'Service.Method'
) )
ColWidths = ( ColWidths = (
325 347
324 346
) )
end end
object lblUUIDMap1: TLabel object lblUUIDMap1: TLabel
@ -632,7 +820,7 @@ object GeneratorSettingsFrame: TGeneratorSettingsFrame
AnchorSideBottom.Side = asrBottom AnchorSideBottom.Side = asrBottom
Left = 8 Left = 8
Height = 28 Height = 28
Top = 343 Top = 325
Width = 96 Width = 96
Alignment = taRightJustify Alignment = taRightJustify
Anchors = [akTop, akLeft, akRight, akBottom] Anchors = [akTop, akLeft, akRight, akBottom]
@ -643,8 +831,8 @@ object GeneratorSettingsFrame: TGeneratorSettingsFrame
object edtServiceMapFile: TFileNameEdit object edtServiceMapFile: TFileNameEdit
Left = 112 Left = 112
Height = 28 Height = 28
Top = 343 Top = 325
Width = 461 Width = 503
DialogKind = dkSave DialogKind = dkSave
DialogOptions = [ofPathMustExist, ofEnableSizing, ofViewDetail] DialogOptions = [ofPathMustExist, ofEnableSizing, ofViewDetail]
FilterIndex = 0 FilterIndex = 0
@ -657,9 +845,9 @@ object GeneratorSettingsFrame: TGeneratorSettingsFrame
TabOrder = 1 TabOrder = 1
end end
object btnLoadUUIDMap1: TButton object btnLoadUUIDMap1: TButton
Left = 586 Left = 628
Height = 25 Height = 25
Top = 343 Top = 325
Width = 75 Width = 75
Anchors = [akRight, akBottom] Anchors = [akRight, akBottom]
Caption = 'Load' Caption = 'Load'

View File

@ -5,7 +5,7 @@ unit fraopenapisettings;
interface interface
uses uses
Classes, SysUtils, Forms, Controls, EditBtn, StdCtrls, ComCtrls, ValEdit, fpopenapi.codegen; Classes, SysUtils, Forms, Controls, EditBtn, StdCtrls, ComCtrls, ValEdit, fpopenapi.codegen, Types;
type type
@ -25,6 +25,10 @@ type
CBSkipImplementation: TCheckBox; CBSkipImplementation: TCheckBox;
CBAbstractCalls: TCheckBox; CBAbstractCalls: TCheckBox;
cbAddToProject: TCheckBox; cbAddToProject: TCheckBox;
cbGenerateServerProxyModule: TCheckBox;
cbProxyModuleFormFile: TCheckBox;
edtServerProxyUnit: TEdit;
edtServerProxyModule: TEdit;
edtClientServiceImplementationUnit: TEdit; edtClientServiceImplementationUnit: TEdit;
edtClientServiceInterfaceUnit: TEdit; edtClientServiceInterfaceUnit: TEdit;
edtClientServiceParentClass: TEdit; edtClientServiceParentClass: TEdit;
@ -42,7 +46,9 @@ type
edtUUIDMap: TFileNameEdit; edtUUIDMap: TFileNameEdit;
edtServiceMapFile: TFileNameEdit; edtServiceMapFile: TFileNameEdit;
GBAutoNaming: TGroupBox; GBAutoNaming: TGroupBox;
Label1: TLabel; lblServerProxyUnit: TLabel;
lblServiceNamePrefix: TLabel;
Label2: TLabel;
lblUUIDMap: TLabel; lblUUIDMap: TLabel;
lblServerServiceParentUnit: TLabel; lblServerServiceParentUnit: TLabel;
lblServerServiceParentClass: TLabel; lblServerServiceParentClass: TLabel;
@ -71,12 +77,15 @@ type
VLEServiceMap: TValueListEditor; VLEServiceMap: TValueListEditor;
procedure btnLoadUUIDMap1Click(Sender: TObject); procedure btnLoadUUIDMap1Click(Sender: TObject);
procedure btnLoadUUIDMapClick(Sender: TObject); procedure btnLoadUUIDMapClick(Sender: TObject);
procedure cbGenerateServerProxyModuleChange(Sender: TObject);
procedure HandleAbstract(Sender: TObject); procedure HandleAbstract(Sender: TObject);
procedure HandleSyncCheck(Sender: TObject); procedure HandleSyncCheck(Sender: TObject);
procedure TSGeneralContextPopup(Sender: TObject; MousePos: TPoint; var Handled: Boolean);
private private
FGenerator: TOpenAPICodeGen; FGenerator: TOpenAPICodeGen;
procedure CheckAbstract; procedure CheckAbstract;
procedure CheckAsync; procedure CheckAsync;
procedure CheckProxyModule;
function GetAddToProject: Boolean; function GetAddToProject: Boolean;
function GetOpenAPIFileName: String; function GetOpenAPIFileName: String;
function GetOpenGeneratedFiles: Boolean; function GetOpenGeneratedFiles: Boolean;
@ -85,9 +94,11 @@ type
procedure SetOpenAPIFileName(AValue: String); procedure SetOpenAPIFileName(AValue: String);
procedure SetOpenGeneratedFiles(AValue: Boolean); procedure SetOpenGeneratedFiles(AValue: Boolean);
public public
procedure Clear;
procedure InitFileNameEdits(Const aBaseDir : string); procedure InitFileNameEdits(Const aBaseDir : string);
Procedure SaveSettings; Procedure SaveSettings;
procedure ShowSettings; procedure ShowSettings;
procedure HideAdditionalControls(ShowClient: Boolean;ShowServer: Boolean);
function Modified : Boolean; function Modified : Boolean;
Property OpenAPIFileName : String Read GetOpenAPIFileName Write SetOpenAPIFileName; Property OpenAPIFileName : String Read GetOpenAPIFileName Write SetOpenAPIFileName;
Property OpenGeneratedFiles : Boolean Read GetOpenGeneratedFiles Write SetOpenGeneratedFiles; Property OpenGeneratedFiles : Boolean Read GetOpenGeneratedFiles Write SetOpenGeneratedFiles;
@ -132,6 +143,30 @@ begin
edtDtoUnit.Text:=DtoUnit; edtDtoUnit.Text:=DtoUnit;
edtUnitExtension.Text:=UnitExtension; edtUnitExtension.Text:=UnitExtension;
edtUnitSuffix.Text:=UnitSuffix; edtUnitSuffix.Text:=UnitSuffix;
cbGenerateServerProxyModule.Checked:=GenerateServerProxyModule;
edtServerProxyModule.Text:=ServerProxyModuleName;
edtServerProxyUnit.Text:=ServerProxyUnit;
cbProxyModuleFormFile.Checked:=ServerProxyFormFile;
CheckProxyModule;
end;
end;
procedure TGeneratorSettingsFrame.HideAdditionalControls(ShowClient: Boolean; ShowServer: Boolean);
begin
PCSettings.AnchorSideTop.Control:=edtFile;
CBGenClient.Visible:=False;
CBGenServer.Visible:=False;
cbOpenFiles.Visible:=False;
cbAddToProject.Visible:=False;
if not ShowClient then
begin
PCSettings.ActivePage:=TSServer;
TSClient.TabVisible:=False;
end;
if Not ShowServer then
begin
PCSettings.ActivePage:=TSClient;
TSServer.TabVisible:=False;
end; end;
end; end;
@ -162,6 +197,13 @@ begin
Result:=Result or (edtDtoUnit.Text<>DtoUnit); Result:=Result or (edtDtoUnit.Text<>DtoUnit);
Result:=Result or (edtUnitExtension.Text<>UnitExtension); Result:=Result or (edtUnitExtension.Text<>UnitExtension);
Result:=Result or (edtUnitSuffix.Text<>UnitSuffix); Result:=Result or (edtUnitSuffix.Text<>UnitSuffix);
Result:=Result or (cbGenerateServerProxyModule.Checked<>GenerateServerProxyModule);
if GenerateServerProxyModule then
begin
Result:=Result or (edtServerProxyModule.Text<>ServerProxyModuleName);
Result:=Result or (ServerProxyUnit<>edtServerProxyUnit.Text);
Result:=Result or (ServerProxyFormFile<>cbProxyModuleFormFile.Checked);
end;
end; end;
end; end;
@ -197,6 +239,11 @@ begin
CheckAsync CheckAsync
end; end;
procedure TGeneratorSettingsFrame.TSGeneralContextPopup(Sender: TObject; MousePos: TPoint; var Handled: Boolean);
begin
end;
procedure TGeneratorSettingsFrame.HandleAbstract(Sender: TObject); procedure TGeneratorSettingsFrame.HandleAbstract(Sender: TObject);
begin begin
CheckAbstract; CheckAbstract;
@ -225,6 +272,28 @@ begin
cbOpenFiles.Checked:=aValue; cbOpenFiles.Checked:=aValue;
end; end;
procedure TGeneratorSettingsFrame.Clear;
begin
edtFile.FileName:='';
edtUUIDMap.FileName:='';
edtServiceMapFile.FileName:='';
edtClientServiceImplementationUnit.Text:='';
edtClientServiceInterfaceUnit.Text:='';
edtClientServiceParentClass.Text:='';
edtClientServiceParentUnit.Text:='';
edtServerHandlerUnitName.Text:='';
edtServerImplementationUnitName.Text:='';
edtServerServiceParentClass.Text:='';
edtServerServiceParentUnit.Text:='';
edtServerProxyModule.Text:='';
edtServiceNameSuffix.Text:='';
edtServiceNamePrefix.Text:='';
edtSerializeUnit.Text:='';
edtDtoUnit.Text:='';
edtUnitExtension.Text:='';
edtUnitSuffix.Text:='';
end;
procedure TGeneratorSettingsFrame.InitFileNameEdits(const aBaseDir: string); procedure TGeneratorSettingsFrame.InitFileNameEdits(const aBaseDir: string);
begin begin
edtFile.InitialDir:=aBaseDir; edtFile.InitialDir:=aBaseDir;
@ -237,6 +306,25 @@ begin
LoadFileToEditor(VLEUUIDMap,edtUUIDMap.FileName,'GUID map'); LoadFileToEditor(VLEUUIDMap,edtUUIDMap.FileName,'GUID map');
end; end;
procedure TGeneratorSettingsFrame.cbGenerateServerProxyModuleChange(Sender: TObject);
begin
CheckProxyModule;
end;
procedure TGeneratorSettingsFrame.CheckProxyModule;
begin
edtServerProxyModule.Enabled:=cbGenerateServerProxyModule.Checked;
if not edtServerProxyModule.Enabled then
edtServerProxyModule.Text:='';
edtServerProxyUnit.Enabled:=cbGenerateServerProxyModule.Checked;
if not edtServerProxyUnit.Enabled then
edtServerProxyUnit.Text:='';
cbProxyModuleFormFile.Enabled:=cbGenerateServerProxyModule.Checked;
if not cbProxyModuleFormFile.Enabled then
cbProxyModuleFormFile.Checked:=False;
end;
procedure TGeneratorSettingsFrame.btnLoadUUIDMap1Click(Sender: TObject); procedure TGeneratorSettingsFrame.btnLoadUUIDMap1Click(Sender: TObject);
begin begin
LoadFileToEditor(VLEServiceMap,edtServiceMapFile.FileName,'service map'); LoadFileToEditor(VLEServiceMap,edtServiceMapFile.FileName,'service map');
@ -269,6 +357,10 @@ begin
DtoUnit:=edtDtoUnit.Text; DtoUnit:=edtDtoUnit.Text;
UnitExtension:=edtUnitExtension.Text; UnitExtension:=edtUnitExtension.Text;
UnitSuffix:=edtUnitSuffix.Text; UnitSuffix:=edtUnitSuffix.Text;
GenerateServerProxyModule:=cbGenerateServerProxyModule.Checked;
ServerProxyModuleName:=edtServerProxyModule.Text;
ServerProxyUnit:=edtServerProxyUnit.Text;
ServerProxyFormFile:=cbProxyModuleFormFile.Checked;
end; end;
end; end;

View File

@ -0,0 +1,309 @@
object OpenAPIProjectForm: TOpenAPIProjectForm
Left = 405
Height = 641
Top = 268
Width = 802
Caption = 'OpenAPI project'
ClientHeight = 641
ClientWidth = 802
LCLVersion = '4.99.0.0'
OnClose = FormClose
OnCloseQuery = FormCloseQuery
OnCreate = FormCreate
object PCProjects: TPageControl
AnchorSideTop.Control = edtUnitsBaseName
AnchorSideTop.Side = asrBottom
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = BPOpenAPIProject
Left = 16
Height = 501
Top = 88
Width = 754
ActivePage = TSServer
Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Top = 8
BorderSpacing.Bottom = 8
TabIndex = 2
TabOrder = 0
object TSAPI: TTabSheet
Caption = 'API definitions'
ClientHeight = 471
ClientWidth = 744
inline fraSettings: TGeneratorSettingsFrame
Height = 471
Width = 744
Align = alClient
ClientHeight = 471
ClientWidth = 744
inherited edtFile: TFileNameEdit
Width = 602
end
inherited lblOpenAPIFile: TLabel
AnchorSideLeft.Control = fraSettings
end
inherited PCSettings: TPageControl
AnchorSideLeft.Control = fraSettings
AnchorSideRight.Control = fraSettings
AnchorSideBottom.Control = fraSettings
Height = 380
Width = 712
inherited TSGeneral: TTabSheet
ClientHeight = 347
ClientWidth = 702
inherited GBAutoNaming: TGroupBox
Width = 674
ClientWidth = 672
end
end
inherited TSData: TTabSheet
ClientHeight = 347
ClientWidth = 702
end
inherited TSClient: TTabSheet
ClientHeight = 347
ClientWidth = 702
inherited edtClientServiceImplementationUnit: TEdit
Left = 334
end
inherited edtClientServiceInterfaceUnit: TEdit
Left = 334
end
inherited lblClientServiceInterfaceUnit: TLabel
Left = 108
Width = 218
end
inherited lblClientServiceImplementationUnit: TLabel
Width = 310
end
inherited edtClientServiceParentClass: TEdit
Left = 334
end
inherited edtClientServiceParentUnit: TEdit
Left = 334
end
inherited lblClientServiceParentClass: TLabel
Width = 310
end
inherited lblClientServiceParentUnit: TLabel
Width = 310
end
inherited Label2: TLabel
Width = 310
end
inherited edtServerProxyModule: TEdit
Left = 334
end
inherited lblServerProxyUnit: TLabel
Width = 310
end
inherited edtServerProxyUnit: TEdit
Left = 334
end
end
inherited TSServer: TTabSheet
ClientHeight = 347
ClientWidth = 702
end
inherited TSUUIDMap: TTabSheet
ClientHeight = 347
ClientWidth = 702
inherited VLEUUIDMap: TValueListEditor
Height = 284
Width = 686
ColWidths = (
341
341
)
end
inherited edtUUIDMap: TFileNameEdit
Top = 311
Width = 494
end
inherited lblUUIDMap: TLabel
Top = 311
end
inherited btnLoadUUIDMap: TButton
Left = 619
Top = 311
end
end
inherited TSServiceMap: TTabSheet
ClientHeight = 347
ClientWidth = 702
inherited VLEServiceMap: TValueListEditor
Height = 284
Width = 686
ColWidths = (
341
341
)
end
inherited lblUUIDMap1: TLabel
Top = 311
end
inherited edtServiceMapFile: TFileNameEdit
Top = 311
Width = 494
end
inherited btnLoadUUIDMap1: TButton
Left = 619
Top = 311
end
end
end
end
end
object TSClient: TTabSheet
Caption = 'Client'
ClientHeight = 471
ClientWidth = 744
object rbClientGUI: TRadioButton
Left = 8
Height = 23
Top = 8
Width = 93
Caption = 'GUI project'
Checked = True
TabOrder = 0
TabStop = True
end
object rbClientCommandLine: TRadioButton
Left = 8
Height = 23
Top = 40
Width = 120
Caption = 'Console project'
TabOrder = 1
end
end
object TSServer: TTabSheet
Caption = 'Server'
ClientHeight = 471
ClientWidth = 744
object SEPort: TSpinEdit
Left = 81
Height = 28
Top = 112
Width = 112
MinValue = 1024
TabOrder = 0
Value = 8080
end
object lblPort: TLabel
Left = 8
Height = 16
Top = 120
Width = 62
Caption = 'HTTP Port'
end
object RBServerHTTP: TRadioButton
Left = 8
Height = 23
Top = 16
Width = 144
Caption = 'HTTP server project'
Checked = True
TabOrder = 1
TabStop = True
end
object RBServerGUI: TRadioButton
Left = 8
Height = 23
Top = 48
Width = 93
Caption = 'GUI Project'
TabOrder = 2
end
object CBServerConsole: TRadioButton
Left = 8
Height = 23
Top = 80
Width = 120
Caption = 'Console project'
TabOrder = 3
end
object cbThreadedServer: TCheckBox
Left = 7
Height = 23
Top = 152
Width = 125
Caption = 'Threaded Server'
Checked = True
State = cbChecked
TabOrder = 4
end
end
end
object BPOpenAPIProject: TButtonPanel
Left = 6
Height = 38
Top = 597
Width = 790
OKButton.Name = 'OKButton'
OKButton.DefaultCaption = True
HelpButton.Name = 'HelpButton'
HelpButton.DefaultCaption = True
CloseButton.Name = 'CloseButton'
CloseButton.DefaultCaption = True
CancelButton.Name = 'CancelButton'
CancelButton.DefaultCaption = True
TabOrder = 1
ShowButtons = [pbOK, pbCancel]
end
object DEBaseDir: TDirectoryEdit
Left = 200
Height = 28
Top = 16
Width = 574
DialogOptions = [ofCreatePrompt, ofEnableSizing, ofViewDetail]
ShowHidden = False
ButtonWidth = 23
NumGlyphs = 1
Anchors = [akTop, akLeft, akRight]
MaxLength = 0
TabOrder = 2
OnEditingDone = DEBaseDirEditingDone
end
object lblBaseDir: TLabel
AnchorSideTop.Control = DEBaseDir
AnchorSideRight.Control = DEBaseDir
AnchorSideBottom.Control = DEBaseDir
AnchorSideBottom.Side = asrBottom
Left = 16
Height = 28
Top = 16
Width = 176
Alignment = taRightJustify
Anchors = [akTop, akLeft, akRight, akBottom]
AutoSize = False
BorderSpacing.Right = 8
Caption = 'Project base directory'
Layout = tlCenter
end
object edtUnitsBaseName: TEdit
AnchorSideTop.Control = DEBaseDir
AnchorSideTop.Side = asrBottom
Left = 200
Height = 28
Top = 52
Width = 128
BorderSpacing.Top = 8
TabOrder = 3
end
object lblUnitsBaseName: TLabel
AnchorSideTop.Control = edtUnitsBaseName
AnchorSideRight.Control = edtUnitsBaseName
AnchorSideBottom.Control = edtUnitsBaseName
AnchorSideBottom.Side = asrBottom
Left = 72
Height = 28
Top = 52
Width = 120
Alignment = taRightJustify
Anchors = [akTop, akLeft, akRight, akBottom]
AutoSize = False
BorderSpacing.Right = 8
Caption = 'Base name for units'
Layout = tlCenter
end
end

View File

@ -0,0 +1,175 @@
unit frmopenapiproject;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls, EditBtn, ComCtrls, ButtonPanel, Spin,
fpopenapi.codegen, fraopenapisettings, lazopenapictrl;
type
{ TOpenAPIProjectForm }
TOpenAPIProjectForm = class(TForm)
BPOpenAPIProject: TButtonPanel;
cbThreadedServer: TCheckBox;
DEBaseDir: TDirectoryEdit;
edtUnitsBaseName: TEdit;
fraSettings: TGeneratorSettingsFrame;
lblUnitsBaseName: TLabel;
lblBaseDir: TLabel;
lblPort: TLabel;
PCProjects: TPageControl;
RBServerHTTP: TRadioButton;
CBServerConsole: TRadioButton;
rbClientGUI: TRadioButton;
rbClientCommandLine: TRadioButton;
RBServerGUI: TRadioButton;
SEPort: TSpinEdit;
TSClient: TTabSheet;
TSServer: TTabSheet;
TSAPI: TTabSheet;
procedure DEBaseDirEditingDone(Sender: TObject);
procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
procedure FormCreate(Sender: TObject);
private
FallowedTypes: TOpenAPIProjectTypes;
FGenerator: TOpenAPICodeGen;
function GetBaseDir: String;
function GetClientProjectType: TIDEProjectType;
function GetHTTPPort: Word;
function GetOpenAPIFileName: String;
function GetServerProjectType: TIDEProjectType;
function GetThreadedServer: Boolean;
function GetUnitsBaseName: String;
procedure SetAllowedTypes(AValue: TOpenAPIProjectTypes);
procedure SetBaseDir(AValue: String);
procedure SetGenerator(AValue: TOpenAPICodeGen);
procedure SetOpenAPIFileName(AValue: String);
procedure SetUnitsBaseName(AValue: String);
public
Property Generator : TOpenAPICodeGen read FGenerator Write SetGenerator;
Property BaseDir : String Read GetBaseDir Write SetBaseDir;
Property UnitsBaseName : String Read GetUnitsBaseName Write SetUnitsBaseName;
Property OpenAPIFileName : String Read GetOpenAPIFileName Write SetOpenAPIFileName;
Property AllowedTypes : TOpenAPIProjectTypes Read FallowedTypes Write SetAllowedTypes;
Property ClientProjectType : TIDEProjectType Read GetClientProjectType;
Property ServerProjectType : TIDEProjectType Read GetServerProjectType;
Property HTTPPort : Word Read GetHTTPPort;
Property ThreadedServer : Boolean Read GetThreadedServer;
end;
var
OpenAPIProjectForm: TOpenAPIProjectForm;
implementation
{$R *.lfm}
{ TOpenAPIProjectForm }
procedure TOpenAPIProjectForm.FormClose(Sender: TObject; var CloseAction: TCloseAction);
begin
if ModalResult=mrOK then
FraSettings.SaveSettings;
end;
procedure TOpenAPIProjectForm.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
begin
CanClose:=(ModalResult<>mrOK);
CanClose:=CanClose or ((DEBaseDir.Directory<>'') and (fraSettings.OpenAPIFileName<>''))
end;
procedure TOpenAPIProjectForm.FormCreate(Sender: TObject);
begin
fraSettings.Clear;
end;
procedure TOpenAPIProjectForm.DEBaseDirEditingDone(Sender: TObject);
begin
fraSettings.InitFileNameEdits(BaseDir);
end;
function TOpenAPIProjectForm.GetOpenAPIFileName: String;
begin
Result:=fraSettings.OpenAPIFileName;
end;
function TOpenAPIProjectForm.GetClientProjectType: TIDEProjectType;
begin
if rbClientGUI.Checked then
Result:=iptGUI
else
Result:=iptCmdLine;
end;
function TOpenAPIProjectForm.GetHTTPPort: Word;
begin
Result:=SEPort.Value;
end;
function TOpenAPIProjectForm.GetBaseDir: String;
begin
Result:=DEBaseDir.Directory;
end;
function TOpenAPIProjectForm.GetServerProjectType: TIDEProjectType;
begin
if rbServerGUI.Checked then
Result:=iptGUI
else if RBServerHTTP.Checked then
Result:=iptHTTPServer
else
Result:=iptCmdLine;
end;
function TOpenAPIProjectForm.GetThreadedServer: Boolean;
begin
Result:=cbThreadedServer.Checked;
end;
function TOpenAPIProjectForm.GetUnitsBaseName: String;
begin
Result:=edtUnitsBaseName.Text;
end;
procedure TOpenAPIProjectForm.SetAllowedTypes(AValue: TOpenAPIProjectTypes);
var
lClient,lServer : Boolean;
begin
FallowedTypes:=AValue;
lClient:=optClient in aValue;
lServer:=optServer in aValue;
TSServer.TabVisible:=lServer;
TSClient.TabVisible:=lClient;
fraSettings.HideAdditionalControls(lClient,lServer);
end;
procedure TOpenAPIProjectForm.SetBaseDir(AValue: String);
begin
DEBaseDir.Directory:=aValue;
fraSettings.InitFileNameEdits(aValue);
end;
procedure TOpenAPIProjectForm.SetGenerator(AValue: TOpenAPICodeGen);
begin
if FGenerator=AValue then Exit;
FGenerator:=AValue;
fraSettings.Generator:=AValue;
fraSettings.ShowSettings;
end;
procedure TOpenAPIProjectForm.SetOpenAPIFileName(AValue: String);
begin
fraSettings.OpenAPIFileName:=aValue;
end;
procedure TOpenAPIProjectForm.SetUnitsBaseName(AValue: String);
begin
edtUnitsBaseName.Text:=aValue;
end;
end.

View File

@ -32,8 +32,29 @@
<HasRegisterProc Value="True"/> <HasRegisterProc Value="True"/>
<UnitName Value="reglazopenapi"/> <UnitName Value="reglazopenapi"/>
</Item> </Item>
<Item>
<Filename Value="frmopenapiproject.pas"/>
<UnitName Value="frmopenapiproject"/>
<ResourceBaseClass Value="Form"/>
<ResourceBaseClassname Value=""/>
</Item>
<Item>
<Filename Value="lazopenapictrl.pas"/>
<UnitName Value="lazopenapictrl"/>
</Item>
<Item>
<Filename Value="lazopenapistr.pas"/>
<UnitName Value="lazopenapistr"/>
</Item>
<Item>
<Filename Value="fraopenapiprojectsettings.pas"/>
<UnitName Value="fraopenapiprojectsettings"/>
</Item>
</Files> </Files>
<RequiredPkgs> <RequiredPkgs>
<Item>
<PackageName Value="CodeTools"/>
</Item>
<Item> <Item>
<PackageName Value="IDEIntf"/> <PackageName Value="IDEIntf"/>
</Item> </Item>

View File

@ -8,7 +8,8 @@ unit lazopenapi;
interface interface
uses uses
fraopenapisettings, frmopenapiwizard, reglazopenapi, LazarusPackageIntf; fraopenapisettings, frmopenapiwizard, reglazopenapi, frmopenapiproject, lazopenapictrl, lazopenapistr,
fraopenapiprojectsettings, LazarusPackageIntf;
implementation implementation

View File

@ -0,0 +1,246 @@
unit lazopenapictrl;
{$mode objfpc}{$H+}
interface
uses
Types, Classes, SysUtils, fpjson, fpopenapi.types, fpopenapi.pascaltypes, fpopenapi.objects, fpopenapi.codegen, IDECommands, ProjectIntf, MenuIntf;
Type
TOpenAPIProjectType = (optClient,optServer);
TOpenAPIProjectTypes = set of TOpenAPIProjectType;
TIDEProjectType = (iptGUI,iptCmdLine,iptHTTPServer);
{ TLazOpenAPICodeGen }
TLazOpenAPICodeGen = class(TOpenAPICodeGen)
private
FServerServiceModules,
FServerURLS: TStringDynArray;
Protected
procedure PrepareAPIData(aData: TAPIData); override;
Public
Function ResolveUnitName(aKind : TUnitKind; aFull: Boolean = True) : String;
Property ServerURLS : TStringDynArray Read FServerURLS;
Property ServerServiceModules : TStringDynArray Read FServerServiceModules;
end;
{ TOpenAPIHandler }
TOpenAPIHandler = Class(TObject)
public
CmdToolsMenu : TIDECommandCategory;
RefreshMenu : TIDEmenuCommand;
OpenAPIWizardCommand : TIDECommand;
procedure GenerateFiles(const aOpenAPIFile, aBaseOutputFile: string; aGenerator: TLazOpenAPICodeGen);
function GetJSONFromYAML(const aOpenAPIFile: string): TJSONStringType;
function OpenAPIConfigOK(out aOpenAPI, aConfig: string): Boolean;
procedure SetProjectData(aProject: TLazProject; const aConfig, aOpenAPIFileName, aBaseFileName: string);
procedure GetProjectData(aProject: TLazProject; out aConfig, aOpenAPIFileName, aBaseFileName: string);
Procedure HandleRefreshOpenAPI(Sender : TObject);
Procedure HandleProjectInspectorPopup(Sender : TObject);
Function IsOpenAPIProject : Boolean;
Function OpenAPIConfigOK : Boolean;
end;
var
OpenAPIHandler : TOpenAPIHandler;
implementation
uses
fpyaml.parser,
fpyaml.data,
fpyaml.json,
fpopenapi.reader,
lazopenapistr,
lazideintf,
ideintf,
IDEMsgIntf,
IDEExternToolIntf;
{ TLazOpenAPICodeGen }
procedure TLazOpenAPICodeGen.PrepareAPIData(aData: TAPIData);
var
I : Integer;
begin
Inherited;
SetLength(FServerURLS,0);
if API.HasKeyWord(oakServers) then
begin
SetLength(FServerURLS,API.Servers.Count);
For I:=0 to API.Servers.Count-1 do
FServerURLS[i]:=API.Servers[I].Url;
end;
if GenerateServer then
begin
SetLength(FServerServiceModules,aData.ServiceCount);
for I:=0 to aData.ServiceCount-1 do
FServerServiceModules[i]:='T'+aData.Services[i].ServiceName+'Module';
end;
end;
function TLazOpenAPICodeGen.ResolveUnitName(aKind: TUnitKind; aFull: Boolean): String;
begin
Result:=ResolveUnit(aKind,aFull);
end;
{ TOpenAPIHandler }
Function TOpenAPIHandler.GetJSONFromYAML(const aOpenAPIFile : string) : TJSONStringType;
var
lParser : TYAMLParser;
lYAML : TYAMLStream;
lJSON : TJSONData;
begin
lYAML:=Nil;
lJSON:=Nil;
lParser:=TYAMLParser.Create(aOpenAPIFile);
try
lYAML:=lParser.Parse;
lJSON:=YamlToJSON(lYAML);
Result:=lJSON.FormatJSON();
finally
lYAML.Free;
lJSON.Free;
lParser.Free;
end;
end;
Procedure TOpenAPIHandler.GenerateFiles(const aOpenAPIFile, aBaseOutputFile : string; aGenerator : TLazOpenAPICodeGen);
var
Loader : TOpenAPIReader;
API : TOpenAPI;
lJSON : String;
begin
Loader:=Nil;
API:=TOpenAPI.Create;
try
Loader:=TOpenAPIReader.Create(Nil);
if TYAMLParser.IsYamlFileName(aOpenAPIFile) then
begin
lJSON:=GetJSONFromYAML(aOpenAPIFile);
Loader.ReadFromString(API,lJSON);
end
else
// Assume JSON
Loader.ReadFromFile(API,aOpenAPIFile);
aGenerator.API:=API;
aGenerator.BaseOutputFileName:=aBaseOutputFile;
aGenerator.Execute;
finally
Loader.Free;
API.Free;
end;
end;
function TOpenAPIHandler.IsOpenAPIProject: Boolean;
begin
Result:=(LazarusIDE.ActiveProject.CustomData.Values[SDataOpenAPIFile]<>'');
end;
function TOpenAPIHandler.OpenAPIConfigOK: Boolean;
var
a,b : string;
begin
Result:=OpenAPIConfigOK(a,b);
end;
function TOpenAPIHandler.OpenAPIConfigOK(out aOpenAPI,aConfig : string) : Boolean;
var
lPath,lFileName : String;
begin
lFileName:=LazarusIDE.ActiveProject.CustomData.Values[SDataOpenAPIFile];
Result:=(lFileName<>'');
if Not Result then
Exit;
lPath:=ExtractFilePath(LazarusIDE.ActiveProject.ProjectInfoFile);
lFileName:=ExpandFileName(lPath+lFileName);
Result:=FileExists(lFileName);
if Not Result then
begin
AddIDEMessage(mluFatal,format(SErrInvalidOpenAPIFile,[lFileName]),'',0,0,SOpenAPICodeGenerator);
Exit;
end;
aOpenAPI:=lFileName;
lFileName:=LazarusIDE.ActiveProject.CustomData.Values[SDataOpenAPIConfig];
lFileName:=ExpandFileName(lPath+lFileName);
Result:=FileExists(lFileName);
if Not Result then
AddIDEMessage(mluFatal,format(SErrInvalidOpenAPIConfigFile,[lFileName]),'',0,0,SOpenAPICodeGenerator)
else
aConfig:=lFileName;
end;
procedure TOpenAPIHandler.GetProjectData(aProject: TLazProject; out aConfig, aOpenAPIFileName, aBaseFileName: string);
var
lPath: String;
begin
lPath:=ExtractFilePath(aProject.ProjectInfoFile);
With aProject.CustomData do
begin
aConfig:=ExpandFileName(lPath+Values[SDataOpenAPIConfig]);
aOpenAPIFileName:=ExpandFileName(lPath+Values[SDataOpenAPIFile]);
aBaseFileName:=ExpandFileName(lPath+Values[SDataOpenAPIBaseFileName]);
end;
end;
procedure TOpenAPIHandler.SetProjectData(aProject: TLazProject; const aConfig, aOpenAPIFileName, aBaseFileName: string);
var
lPath : String;
begin
lPath:=ExtractFilePath(aProject.ProjectInfoFile);
With aProject.CustomData do
begin
Add(SDataOpenAPIFile,ExtractRelativePath(lPath,aOpenAPIFileName));
Add(SDataOpenAPIConfig,ExtractRelativePath(lPath,aConfig));
Add(SDataOpenAPIBaseFileName,ExtractRelativePath(lPath,aBaseFileName));
end;
end;
procedure TOpenAPIHandler.HandleRefreshOpenAPI(Sender: TObject);
var
lPath,lBaseFileName,lOpenAPIFileName,lConfigFileName : String;
lGen : TLazOpenAPICodeGen;
begin
if not OpenAPIConfigOK(lOpenAPIFileName,lConfigFileName) then
exit;
lPath:=ExtractFilePath(LazarusIDE.ActiveProject.ProjectInfoFile);
lBaseFileName:=ExpandFileName(lPath+LazarusIDE.ActiveProject.CustomData.Values[SDataOpenAPIBaseFileName]);
lGen:=TLazOpenAPICodeGen.Create(Nil);
try
lGen.LoadConfig(lConfigFileName);
lGen.SkipServerServiceImplementationModule:=True;
GenerateFiles(lOpenAPIFileName,lBaseFileName,lGen);
finally
lGen.Free;
end;
end;
procedure TOpenAPIHandler.HandleProjectInspectorPopup(Sender: TObject);
begin
RefreshMenu.Visible:=IsOpenAPIProject;
end;
end.

View File

@ -0,0 +1,34 @@
unit lazopenapistr;
{$mode objfpc}{$H+}
interface
const
SProjectRefreshOpenAPIName = 'PrjRefreshOpenAPI';
SDataOpenAPIFile = 'OpenAPIFile';
SDataOpenAPIConfig = 'OpenAPIConfig';
SDataOpenAPIBaseFileName = 'OpenAPIBase';
SConfigFileName = 'lazopenapi.cfg';
Resourcestring
SCMDOpenAPIWizard = 'ShowOpenAPICodeGenerator';
SCMDOpenAPIWizardCaption = 'OpenAPI code generator...';
SOpenAPICodeGenerator = 'OpenAPI code generation';
SErrFailedToGenerateAPI = 'Failed to generate OpenAPI files. Unexpected error %s with message: %s';
SProjectOpenAPIClient = 'OpenAPI client application';
SProjectOpenAPIClientDescription = 'A client application to consume a REST service described by an OpenAPI file.';
SProjectOpenAPIServer = 'OpenAPI server application';
SProjectOpenAPIServerDescription = 'A server application to offer an REST service consume a REST service described by an OpenAPI file.';
SProjectOpenAPIClientServer = 'OpenAPI client and server applications';
SProjectOpenAPIClientServerDescription = 'Client and server applications to consume and offer a REST service described by an OpenAPI file.';
SErrFailedToCreateProjectDir = 'Failed to create project directory "%s"';
SErrInvalidOpenAPIFile = 'Invalid OpenAPI description file: "%s"';
SErrInvalidOpenAPIConfigFile = 'Invalid OpenAPI code generation config file: "%s"';
SRegenerateOpenAPI = 'Regenerate OpenAPI units';
SOpenAPIProjectOptionsCaption = 'Open API options';
implementation
end.

File diff suppressed because it is too large Load Diff