1
0
mirror of synced 2024-11-22 05:43:49 +00:00

Fixed: GUI

This commit is contained in:
Mark van Renswoude 2008-04-14 19:20:55 +00:00
parent dba905ace4
commit e1f35e9999
5 changed files with 65 additions and 12 deletions

View File

@ -3,7 +3,7 @@ object MainForm: TMainForm
Top = 81 Top = 81
BorderIcons = [biSystemMenu, biMinimize] BorderIcons = [biSystemMenu, biMinimize]
BorderStyle = bsDialog BorderStyle = bsDialog
Caption = 'X'#178'Software XML Data Binding Wizard for Delphi' Caption = 'X'#178'Software XML Data Binding for Delphi'
ClientHeight = 244 ClientHeight = 244
ClientWidth = 438 ClientWidth = 438
Color = clBtnFace Color = clBtnFace
@ -56,6 +56,7 @@ object MainForm: TMainForm
Checked = True Checked = True
TabOrder = 0 TabOrder = 0
TabStop = True TabStop = True
OnClick = OutputTypeClick
end end
object rbFolder: TRadioButton object rbFolder: TRadioButton
Left = 8 Left = 8
@ -63,15 +64,15 @@ object MainForm: TMainForm
Width = 149 Width = 149
Height = 17 Height = 17
Caption = 'Output to separate &files' Caption = 'Output to separate &files'
Enabled = False
TabOrder = 1 TabOrder = 1
OnClick = OutputTypeClick
end end
object plOutput: TJvPageList object plOutput: TJvPageList
Left = 3 Left = 3
Top = 72 Top = 72
Width = 416 Width = 416
Height = 87 Height = 87
ActivePage = spFile ActivePage = spFolder
PropagateEnable = False PropagateEnable = False
ShowDesignCaption = sdcBottomRight ShowDesignCaption = sdcBottomRight
Anchors = [akLeft, akTop, akRight, akBottom] Anchors = [akLeft, akTop, akRight, akBottom]
@ -135,7 +136,6 @@ object MainForm: TMainForm
DialogKind = dkWin32 DialogKind = dkWin32
Anchors = [akLeft, akTop, akRight] Anchors = [akLeft, akTop, akRight]
TabOrder = 0 TabOrder = 0
Text = 'F:\XTxXSD\Output\'
end end
object edtFolderPrefix: TEdit object edtFolderPrefix: TEdit
Left = 88 Left = 88
@ -151,6 +151,7 @@ object MainForm: TMainForm
Width = 121 Width = 121
Height = 21 Height = 21
TabOrder = 2 TabOrder = 2
Text = '.pas'
end end
end end
end end

View File

@ -39,6 +39,9 @@ type
procedure btnCloseClick(Sender: TObject); procedure btnCloseClick(Sender: TObject);
procedure btnGenerateClick(Sender: TObject); procedure btnGenerateClick(Sender: TObject);
procedure FormCreate(Sender: TObject); procedure FormCreate(Sender: TObject);
procedure OutputTypeClick(Sender: TObject);
private
procedure GetFileName(Sender: TObject; const SchemaName: String; var Path, FileName: String);
end; end;
@ -47,6 +50,8 @@ uses
SysUtils, SysUtils,
Windows, Windows,
X2UtTempFile,
DelphiXMLDataBindingGenerator, DelphiXMLDataBindingGenerator,
XMLDataBindingGenerator; XMLDataBindingGenerator;
@ -56,8 +61,32 @@ uses
{ TMainForm } { TMainForm }
procedure TMainForm.FormCreate(Sender: TObject); procedure TMainForm.FormCreate(Sender: TObject);
var
schemaFile: String;
begin begin
plOutput.ActivePageIndex := 0; 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; end;
@ -74,9 +103,17 @@ begin
with TDelphiXMLDataBindingGenerator.Create() do with TDelphiXMLDataBindingGenerator.Create() do
try try
OutputType := otSingle; if rbFile.Checked then
OutputPath := feFile.FileName; begin
OutputType := otSingle;
OutputPath := feFile.FileName;
end else if rbFolder.Checked then
begin
OutputType := otMultiple;
OutputPath := deFolder.Text;
end;
OnGetFileName := GetFileName;
Execute(feSchema.FileName); Execute(feSchema.FileName);
finally finally
Free(); Free();
@ -89,4 +126,11 @@ begin
Close(); Close();
end; end;
procedure TMainForm.GetFileName(Sender: TObject; const SchemaName: String; var Path, FileName: String);
begin
FileName := edtFolderPrefix.Text + FileName + edtFolderPostfix.Text;
CheckValidFileName(FileName);
end;
end. end.

View File

@ -13,7 +13,7 @@ uses
type 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) TDelphiXMLDataBindingGenerator = class(TXMLDataBindingGenerator)
@ -1023,14 +1023,21 @@ end;
function TDelphiXMLDataBindingGenerator.DoGetFileName(const ASchemaName: String): String; function TDelphiXMLDataBindingGenerator.DoGetFileName(const ASchemaName: String): String;
var
path: String;
fileName: String;
begin begin
Result := OutputPath; Result := OutputPath;
if OutputType = otMultiple then if OutputType = otMultiple then
begin begin
Result := IncludeTrailingPathDelimiter(Result) + ASchemaName + '.pas'; path := IncludeTrailingPathDelimiter(Result);
fileName := ASchemaName + '.pas';
if Assigned(FOnGetFileName) then if Assigned(FOnGetFileName) then
FOnGetFileName(Self, ASchemaName, Result); FOnGetFileName(Self, ASchemaName, path, fileName);
Result := IncludeTrailingPathDelimiter(path) + fileName;
end; end;
end; end;

View File

@ -130,7 +130,7 @@
<Directories Name="UsePackages">False</Directories> <Directories Name="UsePackages">False</Directories>
</Directories> </Directories>
<Parameters> <Parameters>
<Parameters Name="RunParams"></Parameters> <Parameters Name="RunParams">"F:\Archive\2007\XMLDataBinding\Tests\Data\02. Collection.xsd"</Parameters>
<Parameters Name="HostApplication"></Parameters> <Parameters Name="HostApplication"></Parameters>
<Parameters Name="Launcher"></Parameters> <Parameters Name="Launcher"></Parameters>
<Parameters Name="UseLauncher">False</Parameters> <Parameters Name="UseLauncher">False</Parameters>

View File

@ -7,7 +7,8 @@ uses
MainFrm in 'Forms\MainFrm.pas' {MainForm}, MainFrm in 'Forms\MainFrm.pas' {MainForm},
XMLDataBindingGenerator in 'Units\XMLDataBindingGenerator.pas', XMLDataBindingGenerator in 'Units\XMLDataBindingGenerator.pas',
DelphiXMLDataBindingGenerator in 'Units\DelphiXMLDataBindingGenerator.pas', DelphiXMLDataBindingGenerator in 'Units\DelphiXMLDataBindingGenerator.pas',
XMLDataBindingHelpers in 'Units\XMLDataBindingHelpers.pas'; XMLDataBindingHelpers in 'Units\XMLDataBindingHelpers.pas',
DelphiXMLDataBindingResources in 'Units\DelphiXMLDataBindingResources.pas';
{$R *.res} {$R *.res}
@ -20,7 +21,7 @@ begin
{$ENDIF} {$ENDIF}
Application.Initialize; 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.CreateForm(TMainForm, MainForm);
Application.Run; Application.Run;
end. end.