diff --git a/Forms/MainFrm.dfm b/Forms/MainFrm.dfm index d859bea..adf8064 100644 --- a/Forms/MainFrm.dfm +++ b/Forms/MainFrm.dfm @@ -69,6 +69,9 @@ object MainForm: TMainForm TabOrder = 2 object spFile: TTabSheet TabVisible = False + DesignSize = ( + 408 + 83) object lblFile: TLabel Left = 4 Top = 7 @@ -76,13 +79,15 @@ object MainForm: TMainForm Height = 13 Caption = 'Output file:' end - object feFile: TEdit - Left = 76 + object feFile: TJvFilenameEdit + Left = 89 Top = 3 Width = 316 Height = 21 + DialogOptions = [ofHideReadOnly, ofCreatePrompt] + Anchors = [akLeft, akTop, akRight] TabOrder = 0 - Text = 'D:\Temp\test.pas' + Text = '' end end object spFolder: TTabSheet @@ -114,7 +119,6 @@ object MainForm: TMainForm Width = 316 Height = 21 TabOrder = 0 - Text = 'Edit1' end object edtFolderPostfix: TEdit Left = 89 @@ -122,22 +126,22 @@ object MainForm: TMainForm Width = 316 Height = 21 TabOrder = 1 - Text = 'Edit1' end object deFolder: TEdit Left = 89 Top = 4 - Width = 256 + Width = 245 Height = 21 TabOrder = 2 end - object BrowseOutputFolderButton: TButton - Left = 351 - Top = 4 - Width = 64 + object deFolderPropertiesButton: TButton + Left = 340 + Top = 3 + Width = 65 Height = 22 - Caption = 'BrowseOutputFolderButton' + Caption = 'Properties' TabOrder = 3 + OnClick = deFolderPropertiesButtonClick end end end @@ -202,19 +206,21 @@ object MainForm: TMainForm Top = 8 Width = 316 Height = 21 + OnAfterDialog = feSchemaAfterDialog + DialogOptions = [ofHideReadOnly, ofFileMustExist] TabOrder = 4 - Text = 'feSchema' + Text = '' end object dlgSchema: TOpenDialog Filter = 'W3C XML Schema files (*.xsd)|*.xsd|All files (*.*)|*.*' Options = [ofHideReadOnly, ofFileMustExist, ofEnableSizing] - Left = 212 + Left = 284 Top = 40 end object dlgOutputFile: TSaveDialog Filter = 'Delphi source files (*.pas)|*.pas|All files (*.*)|*.*' Options = [ofHideReadOnly, ofPathMustExist, ofEnableSizing] - Left = 323 - Top = 45 + Left = 387 + Top = 37 end end diff --git a/Forms/MainFrm.pas b/Forms/MainFrm.pas index b45d313..5bbfecc 100644 --- a/Forms/MainFrm.pas +++ b/Forms/MainFrm.pas @@ -50,20 +50,22 @@ type cbGenerateGetOptionalOrDefault: TCheckBox; edtFolderPrefix: TEdit; edtFolderPostfix: TEdit; - feFile: TEdit; deFolder: TEdit; feSchema: TJvFilenameEdit; - BrowseOutputFolderButton: TButton; + deFolderPropertiesButton: TButton; + feFile: TJvFilenameEdit; procedure btnCloseClick(Sender: TObject); procedure btnGenerateClick(Sender: TObject); procedure FormCreate(Sender: TObject); procedure OutputTypeClick(Sender: TObject); procedure feFilePropertiesButtonClick(Sender: TObject; AButtonIndex: Integer); - procedure deFolderPropertiesButtonClick(Sender: TObject; AButtonIndex: Integer); + procedure deFolderPropertiesButtonClick(Sender: TObject); procedure feSchemaPropertiesButtonClick(Sender: TObject; AButtonIndex: Integer); procedure feSchemaPropertiesChange(Sender: TObject); procedure btnHintsClick(Sender: TObject); + procedure feSchemaAfterDialog(Sender: TObject; var AName: string; + var AAction: Boolean); private function CheckValidSchemaFile: Boolean; function CheckReadOnly(const AFileName: String): Boolean; @@ -174,11 +176,11 @@ begin if rbFile.Checked then begin - if not CheckReadOnly(feFile.Text) then + if not CheckReadOnly(feFile.FileName) then Exit; generator.OutputType := otSingle; - generator.OutputPath := feFile.Text; + generator.OutputPath := feFile.FileName; end else if rbFolder.Checked then begin generator.OutputType := otMultiple; @@ -188,9 +190,9 @@ begin generator.HasChecksEmpty := cbHasChecksEmpty.Checked; generator.HasGenerateGetOptionalOrDefault := cbGenerateGetOptionalOrDefault.Checked; generator.OnGetFileName := GetFileName; - generator.Execute(feSchema.Text); + generator.Execute(feSchema.Filename); - SaveSettings(feSchema.Text); + SaveSettings(feSchema.FileName); ShowMessage('The data binding has been generated.'); finally @@ -223,7 +225,7 @@ begin end; -procedure TMainForm.deFolderPropertiesButtonClick(Sender: TObject; AButtonIndex: Integer); +procedure TMainForm.deFolderPropertiesButtonClick(Sender: TObject); var directory: String; @@ -233,6 +235,12 @@ begin end; +procedure TMainForm.feSchemaAfterDialog(Sender: TObject; var AName: string; + var AAction: Boolean); +begin + feFile.FileName := ChangeFileExt(AName, '.pas'); +end; + procedure TMainForm.feSchemaPropertiesButtonClick(Sender: TObject; AButtonIndex: Integer); begin if dlgSchema.Execute then @@ -331,7 +339,7 @@ end; function TMainForm.CheckValidSchemaFile: Boolean; begin - Result := FileExists(feSchema.Text); + Result := FileExists(feSchema.FileName); if not Result then begin