diff --git a/Forms/MainFrm.dfm b/Forms/MainFrm.dfm
index 61c2b0a..db4cb74 100644
--- a/Forms/MainFrm.dfm
+++ b/Forms/MainFrm.dfm
@@ -3,7 +3,7 @@ object MainForm: TMainForm
Top = 81
BorderIcons = [biSystemMenu, biMinimize]
BorderStyle = bsDialog
- Caption = 'X'#178'Software XML Data Binding Wizard for Delphi'
+ Caption = 'X'#178'Software XML Data Binding for Delphi'
ClientHeight = 244
ClientWidth = 438
Color = clBtnFace
@@ -56,6 +56,7 @@ object MainForm: TMainForm
Checked = True
TabOrder = 0
TabStop = True
+ OnClick = OutputTypeClick
end
object rbFolder: TRadioButton
Left = 8
@@ -63,15 +64,15 @@ object MainForm: TMainForm
Width = 149
Height = 17
Caption = 'Output to separate &files'
- Enabled = False
TabOrder = 1
+ OnClick = OutputTypeClick
end
object plOutput: TJvPageList
Left = 3
Top = 72
Width = 416
Height = 87
- ActivePage = spFile
+ ActivePage = spFolder
PropagateEnable = False
ShowDesignCaption = sdcBottomRight
Anchors = [akLeft, akTop, akRight, akBottom]
@@ -135,7 +136,6 @@ object MainForm: TMainForm
DialogKind = dkWin32
Anchors = [akLeft, akTop, akRight]
TabOrder = 0
- Text = 'F:\XTxXSD\Output\'
end
object edtFolderPrefix: TEdit
Left = 88
@@ -151,6 +151,7 @@ object MainForm: TMainForm
Width = 121
Height = 21
TabOrder = 2
+ Text = '.pas'
end
end
end
diff --git a/Forms/MainFrm.pas b/Forms/MainFrm.pas
index 54f03d9..4c2c4cd 100644
--- a/Forms/MainFrm.pas
+++ b/Forms/MainFrm.pas
@@ -39,6 +39,9 @@ type
procedure btnCloseClick(Sender: TObject);
procedure btnGenerateClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
+ procedure OutputTypeClick(Sender: TObject);
+ private
+ procedure GetFileName(Sender: TObject; const SchemaName: String; var Path, FileName: String);
end;
@@ -47,6 +50,8 @@ uses
SysUtils,
Windows,
+ X2UtTempFile,
+
DelphiXMLDataBindingGenerator,
XMLDataBindingGenerator;
@@ -56,8 +61,32 @@ uses
{ TMainForm }
procedure TMainForm.FormCreate(Sender: TObject);
+var
+ schemaFile: String;
+
begin
plOutput.ActivePageIndex := 0;
+
+ if ParamCount() > 0 then
+ begin
+ schemaFile := ParamStr(1);
+
+ if FileExists(schemaFile) then
+ begin
+ feSchema.Text := schemaFile;
+ feFile.Text := ChangeFileExt(schemaFile, '.pas');
+ deFolder.Text := ExtractFilePath(schemaFile);
+ end;
+ end;
+end;
+
+
+procedure TMainForm.OutputTypeClick(Sender: TObject);
+begin
+ if Sender = rbFile then
+ plOutput.ActivePage := spFile
+ else if Sender = rbFolder then
+ plOutput.ActivePage := spFolder;
end;
@@ -74,9 +103,17 @@ begin
with TDelphiXMLDataBindingGenerator.Create() do
try
- OutputType := otSingle;
- OutputPath := feFile.FileName;
+ if rbFile.Checked then
+ begin
+ OutputType := otSingle;
+ OutputPath := feFile.FileName;
+ end else if rbFolder.Checked then
+ begin
+ OutputType := otMultiple;
+ OutputPath := deFolder.Text;
+ end;
+ OnGetFileName := GetFileName;
Execute(feSchema.FileName);
finally
Free();
@@ -89,4 +126,11 @@ begin
Close();
end;
+
+procedure TMainForm.GetFileName(Sender: TObject; const SchemaName: String; var Path, FileName: String);
+begin
+ FileName := edtFolderPrefix.Text + FileName + edtFolderPostfix.Text;
+ CheckValidFileName(FileName);
+end;
+
end.
diff --git a/Units/DelphiXMLDataBindingGenerator.pas b/Units/DelphiXMLDataBindingGenerator.pas
index a8bf6b9..65423c4 100644
--- a/Units/DelphiXMLDataBindingGenerator.pas
+++ b/Units/DelphiXMLDataBindingGenerator.pas
@@ -13,7 +13,7 @@ uses
type
- TGetFileNameEvent = procedure(Sender: TObject; const SchemaName: String; var Result: String) of object;
+ TGetFileNameEvent = procedure(Sender: TObject; const SchemaName: String; var Path, FileName: String) of object;
TDelphiXMLDataBindingGenerator = class(TXMLDataBindingGenerator)
@@ -1023,14 +1023,21 @@ end;
function TDelphiXMLDataBindingGenerator.DoGetFileName(const ASchemaName: String): String;
+var
+ path: String;
+ fileName: String;
begin
Result := OutputPath;
if OutputType = otMultiple then
begin
- Result := IncludeTrailingPathDelimiter(Result) + ASchemaName + '.pas';
+ path := IncludeTrailingPathDelimiter(Result);
+ fileName := ASchemaName + '.pas';
+
if Assigned(FOnGetFileName) then
- FOnGetFileName(Self, ASchemaName, Result);
+ FOnGetFileName(Self, ASchemaName, path, fileName);
+
+ Result := IncludeTrailingPathDelimiter(path) + fileName;
end;
end;
diff --git a/X2XMLDataBinding.bdsproj b/X2XMLDataBinding.bdsproj
index f8e576c..6d57e18 100644
--- a/X2XMLDataBinding.bdsproj
+++ b/X2XMLDataBinding.bdsproj
@@ -130,7 +130,7 @@
False
-
+ "F:\Archive\2007\XMLDataBinding\Tests\Data\02. Collection.xsd"
False
diff --git a/X2XMLDataBinding.dpr b/X2XMLDataBinding.dpr
index 9dcd426..a428c49 100644
--- a/X2XMLDataBinding.dpr
+++ b/X2XMLDataBinding.dpr
@@ -7,7 +7,8 @@ uses
MainFrm in 'Forms\MainFrm.pas' {MainForm},
XMLDataBindingGenerator in 'Units\XMLDataBindingGenerator.pas',
DelphiXMLDataBindingGenerator in 'Units\DelphiXMLDataBindingGenerator.pas',
- XMLDataBindingHelpers in 'Units\XMLDataBindingHelpers.pas';
+ XMLDataBindingHelpers in 'Units\XMLDataBindingHelpers.pas',
+ DelphiXMLDataBindingResources in 'Units\DelphiXMLDataBindingResources.pas';
{$R *.res}
@@ -20,7 +21,7 @@ begin
{$ENDIF}
Application.Initialize;
- Application.Title := 'X²Software XML Data Binding Wizard for Delphi';
+ Application.Title := 'X²Software XML Data Binding for Delphi';
Application.CreateForm(TMainForm, MainForm);
Application.Run;
end.