You can subscribe to this list here.
2006 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(44) |
Nov
(51) |
Dec
(30) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2007 |
Jan
(50) |
Feb
(9) |
Mar
(4) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <t-...@us...> - 2007-01-05 21:21:10
|
Revision: 254 http://svn.sourceforge.net/datagenerator/?rev=254&view=rev Author: t-hex Date: 2007-01-05 13:21:09 -0800 (Fri, 05 Jan 2007) Log Message: ----------- -degismis unit testler Modified Paths: -------------- trunk/src/dunit/DG_GeneratorsTests.pas trunk/src/dunit/DG_ValuesTests.pas trunk/src/dunit/DataGeneratorTests.dpr Modified: trunk/src/dunit/DG_GeneratorsTests.pas =================================================================== --- trunk/src/dunit/DG_GeneratorsTests.pas 2007-01-05 21:18:43 UTC (rev 253) +++ trunk/src/dunit/DG_GeneratorsTests.pas 2007-01-05 21:21:09 UTC (rev 254) @@ -4,14 +4,10 @@ uses DG_Generators, DG_Values, DG_Intfs, - TestFrameWork,Classes; + TestFrameWork, Classes, DG_AutoIncGenerator, DG_PascalScriptedGenerator, + DG_CachedGenerator, DG_SingleValue, DG_RangedGenerator, DG_FileLink; type - {TFixedGeneratorTests = class(TTestCase) - published - procedure TestGenerate; - end;} - TAutoIncGeneratorTests = class(TTestCase) private FAutoIncGenerator: TAutoIncGenerator; Modified: trunk/src/dunit/DG_ValuesTests.pas =================================================================== --- trunk/src/dunit/DG_ValuesTests.pas 2007-01-05 21:18:43 UTC (rev 253) +++ trunk/src/dunit/DG_ValuesTests.pas 2007-01-05 21:21:09 UTC (rev 254) @@ -3,9 +3,10 @@ interface uses - DG_Values, DG_Core, DG_Configuration, DG_Intfs, - TestFrameWork, SysUtils, Classes, ZConnection, ZDbcIntfs, DG_Types, - DG_Database; + DG_Values, DG_Core, DG_Project, DG_Intfs, + TestFrameWork, SysUtils, Classes, ZConnection, ZDbcIntfs, + DG_Types, DG_FileLink, DG_ListLink, DG_Datagenerator, + DG_SingleValue, DG_TableRule; type TSingleValueTests = class(TTestCase) @@ -40,17 +41,17 @@ TContextLinkTests = class(TTestCase,IExporter) private FGenerator: TDataGenerator; - FConfiguration: TDGConfiguration; + FProject: TProject; protected procedure SetUp; override; procedure TearDown; override; public - procedure FinishedTable(ATableRule : TDGTableRule); - procedure RowGenerated(ATableRule : TDGTableRule; + procedure FinishedTable(ATableRule : TObject); + procedure RowGenerated(ATableRule : TObject; const AProvider: IValueProvider); - procedure StartedTable(ATableRule : TDGTableRule); - function GetConnection: TZConnection; - procedure SetConnection(Value: TZConnection); + procedure StartedTable(ATableRule : TObject); + function GetConnection: IZConnection; + procedure SetConnection(Value: IZConnection); published // Test methods procedure TestGetValue; @@ -68,7 +69,7 @@ implementation -uses Variants, DG_Generators; +uses Variants, DG_Generators, DG_AutoIncRule, DG_RangeRule, DG_PatternValue; { TSingleValueTests } @@ -177,17 +178,17 @@ { TContextLinkTests } -procedure TContextLinkTests.FinishedTable(ATableRule: TDGTableRule); +procedure TContextLinkTests.FinishedTable(ATableRule: TObject); begin //Dummy end; -function TContextLinkTests.GetConnection: TZConnection; +function TContextLinkTests.GetConnection: IZConnection; begin //Dummy end; -procedure TContextLinkTests.RowGenerated(ATableRule:TDGTableRule;const AProvider: IValueProvider); +procedure TContextLinkTests.RowGenerated(ATableRule: TObject;const AProvider: IValueProvider); var val1,val2 : Integer; begin @@ -196,36 +197,38 @@ Check(val1 <= val2,'ContextLink went out of range'); end; -procedure TContextLinkTests.SetConnection(Value: TZConnection); +procedure TContextLinkTests.SetConnection(Value: IZConnection); begin end; procedure TContextLinkTests.SetUp; var - FTableRule: TDGTableRule; + FTableRule: TTableRule; + FAutoIncRule: TAutoIncRule; + FRangeRule : TRangeRule; begin inherited; - FConfiguration:= TDGConfiguration.Create; - FTableRule := TDGTableRule.Create('TEST'); + FProject:= TProject.Create; + FTableRule := TTableRule.Create; + FTableRule.table := 'TEST'; with FTableRule do begin Rows := 3; - with NewColumnRule('FDUMAN') do begin - Strategy := gtAutoInc; - Params.Add(TDGParam.Create('','0')); - Params.Add(TDGParam.Create('','1')); - end; - with NewColumnRule('CONTEXT') do begin - Strategy := gtRange; - Params.Add(TDGParam.Create('','1')); - Params.Add(TDGParam.Create('','3')); - end; + FAutoIncRule:= TAutoIncRule.Create(FTableRule); + FAutoIncRule.column := 'FDUMAN'; + FAutoIncRule.start := '0'; + FAutoIncRule.step := '1'; + + FRangeRule := TRangeRule.Create(FTableRule); + FRangeRule.column := 'RANGE'; + FRangeRule.start := '1'; + FRangeRule.stop := '3'; end; - FGenerator:= TDataGenerator.Create(FConfiguration); + FGenerator:= TDataGenerator.Create(FProject); FTableRule.Free; end; -procedure TContextLinkTests.StartedTable(ATableRule: TDGTableRule); +procedure TContextLinkTests.StartedTable(ATableRule: TObject); begin end; @@ -234,7 +237,7 @@ begin inherited; FGenerator:= nil; - FConfiguration.Free; + FProject.Free; end; procedure TContextLinkTests.TestGetValue; Modified: trunk/src/dunit/DataGeneratorTests.dpr =================================================================== --- trunk/src/dunit/DataGeneratorTests.dpr 2007-01-05 21:18:43 UTC (rev 253) +++ trunk/src/dunit/DataGeneratorTests.dpr 2007-01-05 21:21:09 UTC (rev 254) @@ -5,26 +5,48 @@ program DataGeneratorTests; uses - TestFramework {$IFDEF LINUX}, - QForms, - QGUITestRunner {$ELSE}, Forms, - GUITestRunner {$ENDIF}, + TestFramework, TextTestRunner, + GUITestRunner, + gnugettext in '..\..\3rdParty\GnuGettext\gnugettext.pas', DG_ValuesTests in 'DG_ValuesTests.pas', DG_GeneratorsTests in 'DG_GeneratorsTests.pas', - DG_Values in '..\lib\DG_Values.pas', + TestTools in 'TestTools.pas', + DG_ConnectionFactory in '..\lib\DG_ConnectionFactory.pas', + DG_Core in '..\lib\DG_Core.pas', + DG_Datagenerator in '..\lib\DG_Datagenerator.pas', + DG_Exporters in '..\lib\DG_Exporters.pas', DG_Intfs in '..\lib\DG_Intfs.pas', - DG_Generators in '..\lib\DG_Generators.pas', + DG_Types in '..\lib\DG_Types.pas', DG_Utils in '..\lib\DG_Utils.pas', - DG_Core in '..\lib\DG_Core.pas', - DG_Configuration in '..\lib\DG_Configuration.pas', - config in '..\lib\config.pas', - DG_Database in '..\lib\DG_Database.pas', - TestTools in 'TestTools.pas', - DG_Builders in '..\lib\DG_Builders.pas', - gnugettext in '..\..\3rdParty\GnuGettext\gnugettext.pas', - DG_Types in '..\lib\DG_Types.pas'; + DG_AutoIncGenerator in '..\lib\generators\DG_AutoIncGenerator.pas', + DG_CachedGenerator in '..\lib\generators\DG_CachedGenerator.pas', + DG_CompositeGenerator in '..\lib\generators\DG_CompositeGenerator.pas', + DG_Generators in '..\lib\generators\DG_Generators.pas', + DG_LinkedGenerator in '..\lib\generators\DG_LinkedGenerator.pas', + DG_PascalScriptedGenerator in '..\lib\generators\DG_PascalScriptedGenerator.pas', + DG_RangedGenerator in '..\lib\generators\DG_RangedGenerator.pas', + DG_AutoIncRule in '..\lib\rules\DG_AutoIncRule.pas', + DG_ColumnRule in '..\lib\rules\DG_ColumnRule.pas', + DG_ConnectionRule in '..\lib\rules\DG_ConnectionRule.pas', + DG_CopyRule in '..\lib\rules\DG_CopyRule.pas', + DG_FixedRule in '..\lib\rules\DG_FixedRule.pas', + DG_PascalScriptRule in '..\lib\rules\DG_PascalScriptRule.pas', + DG_PatternRule in '..\lib\rules\DG_PatternRule.pas', + DG_Project in '..\lib\rules\DG_Project.pas', + DG_RangeRule in '..\lib\rules\DG_RangeRule.pas', + DG_SequenceRule in '..\lib\rules\DG_SequenceRule.pas', + DG_SQLRule in '..\lib\rules\DG_SQLRule.pas', + DG_TableRule in '..\lib\rules\DG_TableRule.pas', + DG_ContextLink in '..\lib\values\DG_ContextLink.pas', + DG_FieldLink in '..\lib\values\DG_FieldLink.pas', + DG_FileLink in '..\lib\values\DG_FileLink.pas', + DG_ListLink in '..\lib\values\DG_ListLink.pas', + DG_PatternValue in '..\lib\values\DG_PatternValue.pas', + DG_SequenceLink in '..\lib\values\DG_SequenceLink.pas', + DG_SingleValue in '..\lib\values\DG_SingleValue.pas', + DG_Values in '..\lib\values\DG_Values.pas'; {$R *.RES} @@ -38,6 +60,5 @@ else GUITestRunner.RunRegisteredTests; {$ENDIF} - end. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <t-...@us...> - 2007-01-05 21:18:44
|
Revision: 253 http://svn.sourceforge.net/datagenerator/?rev=253&view=rev Author: t-hex Date: 2007-01-05 13:18:43 -0800 (Fri, 05 Jan 2007) Log Message: ----------- -jal k?\195?\188t?\195?\188phanesi Modified Paths: -------------- trunk/3rdParty/FastMM/FastMM4Options.inc trunk/3rdParty/jal/JALAlgorithms.pas trunk/3rdParty/jal/JALCollections.pas trunk/3rdParty/jal/JALExpressions.pas trunk/3rdParty/jal/JALFiles.pas trunk/3rdParty/jal/JALGeomModels.pas trunk/3rdParty/jal/JALGeometry.pas trunk/3rdParty/jal/JALMath.pas trunk/3rdParty/jal/JALMiniDOM.pas trunk/3rdParty/jal/JALOwnedTrees.pas trunk/3rdParty/jal/JALSAX.pas trunk/3rdParty/jal/JALStdIO.pas trunk/3rdParty/jal/JALStrings.pas trunk/3rdParty/jal/JALUIHandler.pas trunk/3rdParty/jal/JALXML.pas trunk/3rdParty/jal/JALXMLParser.pas trunk/3rdParty/jal/JalCRT.pas trunk/3rdParty/jal/JalDXF.pas trunk/3rdParty/jal/JalDebug.pas trunk/3rdParty/jal/JalLogging.pas trunk/3rdParty/jal/JalMessages.pas trunk/3rdParty/jal/JalParse.pas trunk/3rdParty/jal/JalPaths.pas trunk/3rdParty/jal/JalPorting.pas trunk/3rdParty/jal/JalProcesses.pas trunk/3rdParty/jal/JalProxyStreams.pas trunk/3rdParty/jal/JalUTM.pas trunk/3rdParty/jal/JalUtils.pas trunk/3rdParty/jal/JalXMLGenerator.pas Added Paths: ----------- trunk/3rdParty/jal/ Modified: trunk/3rdParty/FastMM/FastMM4Options.inc =================================================================== --- trunk/3rdParty/FastMM/FastMM4Options.inc 2007-01-05 21:17:47 UTC (rev 252) +++ trunk/3rdParty/FastMM/FastMM4Options.inc 2007-01-05 21:18:43 UTC (rev 253) @@ -97,7 +97,7 @@ Very important: If you enable this option your application will require the FastMM_FullDebugMode.dll library. If this library is not available you will get an error on startup.} -{$define FullDebugMode} +{.$define FullDebugMode} {Set this option to perform "raw" stack traces, i.e. check all entries on the stack for valid return addresses. Note that this is significantly slower @@ -133,7 +133,7 @@ {Set this option to enable reporting of memory leaks. Combine it with the two options below for further fine-tuning.} -{$define EnableMemoryLeakReporting} +{.$define EnableMemoryLeakReporting} {Set this option to suppress the display and logging of expected memory leaks that were registered by pointer. Leaks registered by size or class are often Copied: trunk/3rdParty/jal (from rev 238, branches/xmlrules/3rdParty/jal) Modified: trunk/3rdParty/jal/JALAlgorithms.pas =================================================================== Modified: trunk/3rdParty/jal/JALCollections.pas =================================================================== Modified: trunk/3rdParty/jal/JALExpressions.pas =================================================================== Modified: trunk/3rdParty/jal/JALFiles.pas =================================================================== Modified: trunk/3rdParty/jal/JALGeomModels.pas =================================================================== Modified: trunk/3rdParty/jal/JALGeometry.pas =================================================================== Modified: trunk/3rdParty/jal/JALMath.pas =================================================================== Modified: trunk/3rdParty/jal/JALMiniDOM.pas =================================================================== Modified: trunk/3rdParty/jal/JALOwnedTrees.pas =================================================================== Modified: trunk/3rdParty/jal/JALSAX.pas =================================================================== Modified: trunk/3rdParty/jal/JALStdIO.pas =================================================================== Modified: trunk/3rdParty/jal/JALStrings.pas =================================================================== Modified: trunk/3rdParty/jal/JALUIHandler.pas =================================================================== Modified: trunk/3rdParty/jal/JALXML.pas =================================================================== Modified: trunk/3rdParty/jal/JALXMLParser.pas =================================================================== Modified: trunk/3rdParty/jal/JalCRT.pas =================================================================== Modified: trunk/3rdParty/jal/JalDXF.pas =================================================================== Modified: trunk/3rdParty/jal/JalDebug.pas =================================================================== Modified: trunk/3rdParty/jal/JalLogging.pas =================================================================== Modified: trunk/3rdParty/jal/JalMessages.pas =================================================================== Modified: trunk/3rdParty/jal/JalParse.pas =================================================================== Modified: trunk/3rdParty/jal/JalPaths.pas =================================================================== Modified: trunk/3rdParty/jal/JalPorting.pas =================================================================== Modified: trunk/3rdParty/jal/JalProcesses.pas =================================================================== Modified: trunk/3rdParty/jal/JalProxyStreams.pas =================================================================== Modified: trunk/3rdParty/jal/JalUTM.pas =================================================================== Modified: trunk/3rdParty/jal/JalUtils.pas =================================================================== Modified: trunk/3rdParty/jal/JalXMLGenerator.pas =================================================================== This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <t-...@us...> - 2007-01-05 21:17:49
|
Revision: 252 http://svn.sourceforge.net/datagenerator/?rev=252&view=rev Author: t-hex Date: 2007-01-05 13:17:47 -0800 (Fri, 05 Jan 2007) Log Message: ----------- -yeni ui merge'i Modified Paths: -------------- trunk/src/ui/DataGeneratorUI.dpr trunk/src/ui/FormColumnRule.dfm trunk/src/ui/FormColumnRule.pas trunk/src/ui/FormConnectionProperties.pas trunk/src/ui/FormProgress.pas trunk/src/ui/FormTableRule.dfm trunk/src/ui/FormTableRule.pas trunk/src/ui/MainForm.pas Removed Paths: ------------- trunk/src/ui/help/ Modified: trunk/src/ui/DataGeneratorUI.dpr =================================================================== --- trunk/src/ui/DataGeneratorUI.dpr 2007-01-05 21:16:18 UTC (rev 251) +++ trunk/src/ui/DataGeneratorUI.dpr 2007-01-05 21:17:47 UTC (rev 252) @@ -1,7 +1,13 @@ program DataGeneratorUI; {%ToDo 'DataGeneratorUI.todo'} +{%TogetherDiagram 'ModelSupport_DataGeneratorUI\default.txaPackage'} +{$IFDEF DEBUG} + {$DEF FullDebugMode} + {$DEF EnableMemoryLeakReporting} +{$ENDIF} + uses FastMM4 in '..\..\3rdParty\FastMM\FastMM4.pas', FastMM4Messages in '..\..\3rdParty\FastMM\FastMM4Messages.pas', @@ -15,32 +21,45 @@ FormProgress in 'FormProgress.pas' {frmProgress}, FormMemoEditor in 'FormMemoEditor.pas' {frmEditor}, FormAbout in 'FormAbout.pas' {frmAbout}, - DG_Utils in '..\lib\DG_Utils.pas', - DG_Core in '..\lib\DG_Core.pas', - DG_Database in '..\lib\DG_Database.pas', - config in '..\lib\config.pas', - DG_Intfs in '..\lib\DG_Intfs.pas', - DG_Generators in '..\lib\DG_Generators.pas', - DG_Values in '..\lib\DG_Values.pas', - DG_Configuration in '..\lib\DG_Configuration.pas', - DG_Exporters in '..\lib\DG_Exporters.pas', uSettings in 'uSettings.pas', FormSettings in 'FormSettings.pas' {frmSettings}, - DG_Builders in '..\lib\DG_Builders.pas', UITools in 'UITools.pas', gnugettext in '..\..\3rdParty\GnuGettext\gnugettext.pas', + DG_Core in '..\lib\DG_Core.pas', + DG_Datagenerator in '..\lib\DG_Datagenerator.pas', + DG_Exporters in '..\lib\DG_Exporters.pas', + DG_Intfs in '..\lib\DG_Intfs.pas', DG_Types in '..\lib\DG_Types.pas', - AutoIncRuleController in 'controllers\AutoIncRuleController.pas', - CopyRuleController in 'controllers\CopyRuleController.pas', - PascalScriptRuleController in 'controllers\PascalScriptRuleController.pas', - PatternRuleController in 'controllers\PatternRuleController.pas', - RangeRuleController in 'controllers\RangeRuleController.pas', - RuleController in 'controllers\RuleController.pas', - SequenceRuleController in 'controllers\SequenceRuleController.pas', - SQLRuleController in 'controllers\SQLRuleController.pas', - FixedRuleController in 'controllers\FixedRuleController.pas', - CompositeRuleController in 'controllers\CompositeRuleController.pas', - VTEditLinks in 'VTEditLinks.pas'; + DG_Utils in '..\lib\DG_Utils.pas', + DG_AutoIncGenerator in '..\lib\generators\DG_AutoIncGenerator.pas', + DG_CachedGenerator in '..\lib\generators\DG_CachedGenerator.pas', + DG_CompositeGenerator in '..\lib\generators\DG_CompositeGenerator.pas', + DG_Generators in '..\lib\generators\DG_Generators.pas', + DG_LinkedGenerator in '..\lib\generators\DG_LinkedGenerator.pas', + DG_PascalScriptedGenerator in '..\lib\generators\DG_PascalScriptedGenerator.pas', + DG_RangedGenerator in '..\lib\generators\DG_RangedGenerator.pas', + DG_AutoIncRule in '..\lib\rules\DG_AutoIncRule.pas', + DG_ColumnRule in '..\lib\rules\DG_ColumnRule.pas', + DG_ConnectionRule in '..\lib\rules\DG_ConnectionRule.pas', + DG_CopyRule in '..\lib\rules\DG_CopyRule.pas', + DG_FixedRule in '..\lib\rules\DG_FixedRule.pas', + DG_PascalScriptRule in '..\lib\rules\DG_PascalScriptRule.pas', + DG_PatternRule in '..\lib\rules\DG_PatternRule.pas', + DG_Project in '..\lib\rules\DG_Project.pas', + DG_RangeRule in '..\lib\rules\DG_RangeRule.pas', + DG_SequenceRule in '..\lib\rules\DG_SequenceRule.pas', + DG_SQLRule in '..\lib\rules\DG_SQLRule.pas', + DG_TableRule in '..\lib\rules\DG_TableRule.pas', + DG_ContextLink in '..\lib\values\DG_ContextLink.pas', + DG_FieldLink in '..\lib\values\DG_FieldLink.pas', + DG_FileLink in '..\lib\values\DG_FileLink.pas', + DG_ListLink in '..\lib\values\DG_ListLink.pas', + DG_PatternValue in '..\lib\values\DG_PatternValue.pas', + DG_SequenceLink in '..\lib\values\DG_SequenceLink.pas', + DG_SingleValue in '..\lib\values\DG_SingleValue.pas', + DG_Values in '..\lib\values\DG_Values.pas', + DG_ConnectionFactory in '..\lib\DG_ConnectionFactory.pas', + uRuleController in 'uRuleController.pas'; {$R *.res} {$R dgver.res} // required Modified: trunk/src/ui/FormColumnRule.dfm =================================================================== --- trunk/src/ui/FormColumnRule.dfm 2007-01-05 21:16:18 UTC (rev 251) +++ trunk/src/ui/FormColumnRule.dfm 2007-01-05 21:17:47 UTC (rev 252) @@ -12,6 +12,8 @@ inherited Bevel1: TBevel Top = 317 Width = 370 + ExplicitTop = 317 + ExplicitWidth = 370 end object Label1: TLabel [1] Left = 8 @@ -22,10 +24,12 @@ end inherited btnOK: TButton Top = 326 + ExplicitTop = 326 end inherited btnCancel: TButton Top = 326 Cancel = True + ExplicitTop = 326 end object GroupBox1: TGroupBox Left = 8 Modified: trunk/src/ui/FormColumnRule.pas =================================================================== --- trunk/src/ui/FormColumnRule.pas 2007-01-05 21:16:18 UTC (rev 251) +++ trunk/src/ui/FormColumnRule.pas 2007-01-05 21:17:47 UTC (rev 252) @@ -5,7 +5,7 @@ uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, FormRule, StdCtrls, ExtCtrls, ComCtrls,DG_Core, VirtualTrees, - Menus,DG_Configuration, DG_Database, DG_Types, RuleController ; + Menus, Spin, DG_Types, DG_ColumnRule ; type PNodeData = ^TNodeData; @@ -86,7 +86,8 @@ implementation uses Types, FormMemoEditor, gnugettext, VTEditLinks, MainForm, - ZConnection, ZDbcIntfs, Math, UITools, DG_Generators; + ZDbcIntfs, Math, UITools, DG_Generators, DG_ConnectionRule, + DG_ConnectionFactory; {$R *.dfm} @@ -202,6 +203,7 @@ procedure TfrmColumnRule.cbGeneratorTypeChange(Sender: TObject); begin +{ TODO 5 : fix here } inherited; if assigned(FRuleController) then FreeRuleController; @@ -356,15 +358,17 @@ Items: TStringList; begin begin - ConnProp := frmMain.Configuration.FindConnectionProperty(connRef); + // Previous node gives the connection reference + ParamData := Sender.GetNodeData(Node.PrevSibling); + ConnProp := frmMain.Project.ConnectionRuleRef[ParamData.Value]; if Assigned(ConnProp) then begin //create connection - tmpConnection := CreateConnection(ConnProp); + tmpConnection := ConnectionFactory.CreateConnection(ConnProp); try - tmpConnection.Connect; + tmpConnection.Open; //get sequence list - SequenceRS := tmpConnection.DbcConnection.GetMetadata.GetSequences('', '', ''); + SequenceRS:=tmpConnection.GetMetadata.GetSequences('','',''); Items := TStringList.Create; try while SequenceRS.Next do @@ -374,8 +378,8 @@ Items.Free; end; finally - tmpConnection.Disconnect; - tmpConnection.Free; + tmpConnection.Close; + tmpConnection := nil; end; end; end; @@ -407,9 +411,10 @@ I: Integer; begin cbGeneratorType.Clear; + { TODO 5 : fix here } // Fill combo with localized generator names - for I:= Integer(Low(TGeneratorType)) to Integer(High(TGeneratorType)) do - cbGeneratorType.Items.Add(GeneratorLocalName(TGeneratorType(I))); +// for I:= Integer(Low(TGeneratorType)) to Integer(High(TGeneratorType)) do +// cbGeneratorType.Items.Add(TGeneratorType(I))); end; end. Modified: trunk/src/ui/FormConnectionProperties.pas =================================================================== --- trunk/src/ui/FormConnectionProperties.pas 2007-01-05 21:16:18 UTC (rev 251) +++ trunk/src/ui/FormConnectionProperties.pas 2007-01-05 21:17:47 UTC (rev 252) @@ -4,7 +4,7 @@ uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, - Dialogs, StdCtrls, ExtCtrls,DG_Database, ZConnection, DG_Core; + Dialogs, StdCtrls, ExtCtrls, DG_Core, ZConnection, DG_ConnectionRule; type TfrmConnectionProperties = class(TForm) @@ -37,15 +37,15 @@ procedure btnTestConnectionClick(Sender: TObject); procedure btnOKClick(Sender: TObject); private - FConnectionProperty: TDGConnectionProperty; - procedure SetConnectionProperty(const Value: TDGConnectionProperty); - function GetConnectionProperty: TDGConnectionProperty; + FConnectionRule: TConnectionRule; + procedure SetConnectionRule(const Value: TConnectionRule); + function GetConnectionRule: TConnectionRule; procedure ApplyChangesToConnection; procedure ValidateSettings; { Private declarations } public { Public declarations } - property ConnectionProperty : TDGConnectionProperty read GetConnectionProperty write SetConnectionProperty; + property ConnectionRule : TConnectionRule read GetConnectionRule write SetConnectionRule; end; var @@ -53,17 +53,17 @@ implementation -uses gnugettext; +uses gnugettext, DG_ConnectionFactory; {$R *.dfm} { TfrmConnectionProperties } -procedure TfrmConnectionProperties.SetConnectionProperty( - const Value: TDGConnectionProperty); +procedure TfrmConnectionProperties.SetConnectionRule( + const Value: TConnectionRule); begin - if Value <> nil then FConnectionProperty := Value; - with FConnectionProperty do begin + if Value <> nil then FConnectionRule := Value; + with FConnectionRule do begin edtRef.Text := Ref; cbProtocols.Text := Protocol; edtHost.Text := Host; @@ -95,7 +95,7 @@ procedure TfrmConnectionProperties.btnTestConnectionClick(Sender: TObject); begin ApplyChangesToConnection; - AssignConnectionProperties(ZConnection1, ConnectionProperty); + AssignConnectionRule(ZConnection1, ConnectionRule); try ZConnection1.Connect; except @@ -104,17 +104,17 @@ ShowMessage(_('Connection is successful')); end; -function TfrmConnectionProperties.GetConnectionProperty: TDGConnectionProperty; +function TfrmConnectionProperties.GetConnectionRule: TConnectionRule; begin ApplyChangesToConnection; - Result := FConnectionProperty; + Result := FConnectionRule; end; procedure TfrmConnectionProperties.ApplyChangesToConnection; begin - Assert(FConnectionProperty <> nil,_('Connection Property is nil')); + Assert(FConnectionRule <> nil,_('Connection Property is nil')); ValidateSettings; - with FConnectionProperty do begin + with FConnectionRule do begin Ref := edtRef.Text; Protocol := cbProtocols.Text; Host := edtHost.Text; Modified: trunk/src/ui/FormProgress.pas =================================================================== --- trunk/src/ui/FormProgress.pas 2007-01-05 21:16:18 UTC (rev 251) +++ trunk/src/ui/FormProgress.pas 2007-01-05 21:17:47 UTC (rev 252) @@ -5,7 +5,7 @@ uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, ComCtrls, StdCtrls, ExtCtrls,DG_Core,DG_Intfs, DG_Utils, ZDbcIntfs, - Math, ZConnection, DG_Database,DG_Configuration; + Math, ZConnection, DG_Project, DG_Datagenerator; type TGenerationThread = class; @@ -39,7 +39,7 @@ procedure FormCreate(Sender: TObject); procedure FormShow(Sender: TObject); private - FConfiguration: TDGConfiguration; + FConfiguration: TProject; FDG : TDatagenerator; FGThread : TGenerationThread; FObserver : TObserver; @@ -49,7 +49,7 @@ procedure StartThread; procedure StopThread; public - property Configuration : TDGConfiguration read FConfiguration write FConfiguration; + property Configuration : TProject read FConfiguration write FConfiguration; property Output: TOutputType read FOutput write FOutput; property OutputFilename: string read FOutputFilename write FOutputFilename; end; Modified: trunk/src/ui/FormTableRule.dfm =================================================================== --- trunk/src/ui/FormTableRule.dfm 2007-01-05 21:16:18 UTC (rev 251) +++ trunk/src/ui/FormTableRule.dfm 2007-01-05 21:17:47 UTC (rev 252) @@ -8,16 +8,20 @@ TextHeight = 13 inherited Bevel1: TBevel Top = 190 + ExplicitTop = 190 end inherited btnOK: TButton Left = 216 Top = 199 Default = True OnClick = btnOKClick + ExplicitLeft = 216 + ExplicitTop = 199 end inherited btnCancel: TButton Top = 198 Cancel = True + ExplicitTop = 198 end object GroupBox1: TGroupBox Left = 8 Modified: trunk/src/ui/FormTableRule.pas =================================================================== --- trunk/src/ui/FormTableRule.pas 2007-01-05 21:16:18 UTC (rev 251) +++ trunk/src/ui/FormTableRule.pas 2007-01-05 21:17:47 UTC (rev 252) @@ -4,8 +4,7 @@ uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, - Dialogs, FormRule, StdCtrls, ExtCtrls, DG_Configuration, ComCtrls, - DG_Database; + Dialogs, FormRule, StdCtrls, ExtCtrls, ComCtrls, DG_TableRule; type TfrmTableRule = class(TfrmRule) @@ -20,12 +19,12 @@ procedure btnOKClick(Sender: TObject); procedure NumberEditKeyPress(Sender: TObject; var Key: Char); private - FTableRule : TDGTableRule; - function GetTableRule: TDGTableRule; - procedure SetTableRule(const Value: TDGTableRule); + FTableRule : TTableRule; + function GetTableRule: TTableRule; + procedure SetTableRule(const Value: TTableRule); procedure Validate; public - property TableRule : TDGTableRule read GetTableRule write SetTableRule; + property TableRule : TTableRule read GetTableRule write SetTableRule; end; var @@ -39,12 +38,12 @@ { TfrmTableRule } -function TfrmTableRule.GetTableRule: TDGTableRule; +function TfrmTableRule.GetTableRule: TTableRule; begin Result := FTableRule; end; -procedure TfrmTableRule.SetTableRule(const Value: TDGTableRule); +procedure TfrmTableRule.SetTableRule(const Value: TTableRule); begin FTableRule := Value; with FTableRule do begin Modified: trunk/src/ui/MainForm.pas =================================================================== --- trunk/src/ui/MainForm.pas 2007-01-05 21:16:18 UTC (rev 251) +++ trunk/src/ui/MainForm.pas 2007-01-05 21:17:47 UTC (rev 252) @@ -4,9 +4,8 @@ uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, - Dialogs, VirtualTrees, StdCtrls, ExtCtrls, ZConnection, ZDBCIntfs, Types, - ImgList, Menus, ActnList, ComCtrls, ToolWin, DG_Core, DG_Database, - DG_Utils, DG_Configuration, FormAbout, FileCtrl; + Dialogs, VirtualTrees, StdCtrls, ExtCtrls, ZDBCIntfs, Types, + ImgList, Menus, ActnList, ComCtrls, ToolWin, DG_Core, DG_Utils, FormAbout, FileCtrl, DG_Project; type TfrmMain = class(TForm) @@ -138,13 +137,13 @@ private { Private declarations } FResultSet : IZResultSet; - FConfigurationFileName : string; - FConfiguration : TDGConfiguration; - procedure SetConfigurationFileName(const Value : string); + FProjectFileName : string; + FProject : TProject; + procedure SetProjectFileName(const Value : string); procedure EditConnectionProperties(Node : PVirtualNode); function CreateConnectionNodes : Integer; - function CreateTableNodes(Node : PVirtualNode; Connection : TZConnection) : Integer; - function CreateFieldNodes(Node : PVirtualNode; Connection : TZConnection) : Integer; + function CreateTableNodes(Node : PVirtualNode; Connection : IZConnection) : Integer; + function CreateFieldNodes(Node : PVirtualNode; Connection : IZConnection) : Integer; procedure AddorEditTableRule(Node : PVirtualNode); procedure AddOrEditColumnRule(Node : PVirtualNode); public @@ -153,8 +152,8 @@ procedure OpenProject(const AFilename: TFilename); procedure CloseProject; procedure UpdateRecentFileMenuItems; - property ConfigurationFileName : string read FConfigurationFileName write SetConfigurationFileName; - property Configuration: TDGConfiguration read FConfiguration; + property ProjectFileName : string read FProjectFileName write SetProjectFileName; + property Project: TProject read FProject; end; PNodeData = ^TNodeData; @@ -171,13 +170,14 @@ implementation uses FormColumnRule, FormTableRule, FormConnectionProperties, FormProgress, - gnugettext, FormSettings, uSettings, DG_Generators, DG_Types, RuleController; + gnugettext, FormSettings, uSettings, DG_Generators, DG_Types, + DG_ConnectionRule, DG_TableRule, DG_ColumnRule, DG_ConnectionFactory; {$R *.dfm} {$IFDEF VER150} // XP Manifest Hacking -{$R WindowsXP.res} + {$R WindowsXP.res} {$ENDIF} function GetParentNodeData(ASender : TBaseVirtualTree; @@ -189,12 +189,12 @@ constructor TfrmMain.Create(AOwner : TComponent); begin inherited Create(AOwner); - FConfiguration := TDGConfiguration.Create; + FProject := TProject.Create; end; destructor TfrmMain.Destroy; begin - FConfiguration.Free; + FProject.Free; inherited Destroy; end; @@ -211,11 +211,9 @@ TableName: string; ReferenceName: string; ColumnName: string; - sParams: String; - I : Integer; - ConnectionProperty: TDGConnectionProperty; - TableRule : TDGTableRule; - ColumnRule : TDGColumnRule; + ConnectionRule: TConnectionRule; + TableRule : TTableRule; + ColumnRule : TColumnRule; NodeData: PNodeData; begin NodeData:= Sender.GetNodeData(Node); @@ -229,17 +227,9 @@ ColumnName:= NodeData.Name; TableName:= GetParentNodeData(Sender, Node).Name; ReferenceName:= GetParentNodeData(Sender, Node.Parent).Name; - ColumnRule:= Configuration.FindColumnRule(ReferenceName, - TableName, ColumnName); - if Assigned(ColumnRule) then begin - Celltext := GeneratorLocalName(ColumnRule.Strategy); - if not (ColumnRule.Strategy in [gtScript,gtSQL]) then begin - for i:= 0 to ColumnRule.Params.count-1 do - sParams := sParams + ColumnRule.Params[i].Value +','; - Delete(sParams,length(sParams),1); - CellText := CellText + '(' + sParams + ')'; - end; - end; + ColumnRule:= Project.FindColumnRule(ReferenceName, TableName, ColumnName); + if Assigned(ColumnRule) then + Celltext := ColumnRule.ToString; end; end; @@ -248,17 +238,17 @@ case Sender.GetNodeLevel(Node) of 0 : begin ReferenceName:= NodeData.Name; - ConnectionProperty:= Configuration.FindConnectionProperty(ReferenceName); - if Assigned(ConnectionProperty) then + ConnectionRule:= Project.ConnectionRuleRef[ReferenceName]; + if Assigned(ConnectionRule) then begin - Celltext := '(' + ConnectionProperty.Protocol + ')'; - Celltext := Celltext + ' ' + ConnectionProperty.Database; + Celltext := '(' + ConnectionRule.Protocol + ')'; + Celltext := Celltext + ' ' + ConnectionRule.Database; end; end; 1 : begin ReferenceName:= GetParentNodeData(Sender, Node).Name; TableName:= NodeData.Name; - TableRule:= Configuration.FindTableRule(ReferenceName, TableName); + TableRule:= Project.FindTableRule(ReferenceName, TableName); if Assigned(TableRule) then Celltext := Format(_('%d rows'), [TableRule.Rows]); end; @@ -281,7 +271,7 @@ procedure TfrmMain.FieldTreeInitChildren(Sender : TBaseVirtualTree; Node : PVirtualNode; var ChildCount : Cardinal); var - Connection : TZConnection; + Connection : IZConnection; TopNode : PVirtualNode; begin ChildCount := 0; @@ -289,17 +279,16 @@ while TopNode.Parent <> FieldTree.RootNode do TopNode := TopNode.Parent; - Connection := CreateConnection(TDGConnectionProperty( - Configuration.ConnectionProperties[TopNode.Index])); + Connection := ConnectionFactory.CreateConnection(Project.ConnectionRule[TopNode.Index]); try - Connection.Connect; + Connection.Open; case FieldTree.GetNodeLevel(Node) of 0 : ChildCount := CreateTableNodes(Node, Connection); 1 : ChildCount := CreateFieldNodes(Node, Connection); end; finally - Connection.Disconnect; - Connection.Free; + Connection.Close; + Connection := nil; end; end; @@ -323,8 +312,8 @@ Assert(FieldTree.GetNodeLevel(Node) = 0, 'Node should be 0'); Application.CreateForm(TfrmConnectionProperties, frmConnectionProperties); try - frmConnectionProperties.ConnectionProperty := - Configuration.FindConnectionProperty(PNodeData(FieldTree.GetNodeData(Node)).Name); + frmConnectionProperties.ConnectionRule := + Project.ConnectionRuleRef[PNodeData(FieldTree.GetNodeData(Node)).Name]; frmConnectionProperties.ShowModal; finally frmConnectionProperties.Free; @@ -335,8 +324,8 @@ var TableName: string; ReferenceName: string; - TableRule : TDGTableRule; - Connection: TDGConnectionProperty; + TableRule : TTableRule; + Connection: TConnectionRule; NewTableRule: Boolean; ModalValue: Integer; begin @@ -350,14 +339,15 @@ TableName := PNodeData(FieldTree.GetNodeData(Node)).Name; // Get table rule - TableRule := Configuration.FindTableRule(ReferenceName, TableName); + TableRule := Project.FindTableRule(ReferenceName, TableName); Application.CreateForm(TfrmTableRule, frmTableRule); try // if not create a table rule before create one if not Assigned(TableRule) then begin - TableRule := TDGTableRule.Create(TableName); + TableRule := TTableRule.Create(FProject); + TableRule.table := TableName; NewTableRule:= True; end; try @@ -365,11 +355,11 @@ frmTableRule.lblFieldName.Caption := TableName; frmTableRule.TableRule := TableRule; ModalValue:= frmTableRule.ShowModal; - Connection:= Configuration.FindConnectionProperty(ReferenceName); + Connection:= Project.ConnectionRuleRef[ReferenceName]; if (ModalValue = mrOK) and - not Assigned(Configuration.FindTableRule(ReferenceName, TableName)) and + not Assigned(Project.FindTableRule(ReferenceName, TableName)) and Assigned(Connection) then - Connection.AddTableRule(TableRule); + Connection.Childs.Add(TableRule); finally if (ModalValue <> mrOK) and NewTableRule then TableRule.Free; @@ -386,9 +376,8 @@ ColumnName: string; ColumnType: string; ModalValue: Integer; - ConnectionProperty: TDGConnectionProperty; - TableRule : TDGTableRule; - ColumnRule : TDGColumnRule; + TableRule : TTableRule; + ColumnRule : TColumnRule; NewColumnRule : Boolean; begin Assert(FieldTree.GetNodeLevel(Node) = 2, 'Node should be 2'); @@ -403,9 +392,8 @@ ReferenceName:= GetParentNodeData(FieldTree, Node.Parent).Name; // Get table rule, column rule - ConnectionProperty:= Configuration.FindConnectionProperty(ReferenceName); - TableRule := Configuration.FindTableRule(ReferenceName, TableName); - ColumnRule:= Configuration.FindColumnRule(ReferenceName, + TableRule := Project.FindTableRule(ReferenceName, TableName); + ColumnRule:= Project.FindColumnRule(ReferenceName, TableName, ColumnName); Application.CreateForm(TfrmColumnRule, frmColumnRule); @@ -421,11 +409,12 @@ begin if not Assigned(TableRule) then begin - TableRule := ConnectionProperty.NewTableRule(TableName); + TableRule := TTableRule.Create(FProject); + TableRule.table := TableName; TableRule.Rows := UISettings.DefaultTableRows; end; if not Assigned(TableRule.FindColumnRule(ColumnName)) then - TableRule.AddColumnRule(ColumnRule); + TableRule.Childs.Add(ColumnRule); end; finally if (ModalValue <> mrOK) and NewColumnRule then @@ -477,17 +466,17 @@ NodeData : PNodeData; begin FieldTree.Clear; - for i := 0 to Configuration.ConnectionProperties.Count - 1 do begin + for i := 0 to Project.ChildCount - 1 do begin Node := FieldTree.AddChild(nil); Node.States := Node.States + [vsHasChildren]; NodeData := FieldTree.GetNodeData(Node); - NodeData.Name := TDGConnectionProperty(Configuration.ConnectionProperties[I]).Ref; + NodeData.Name := Project.ConnectionRule[I].Ref; NodeData.DataType := ''; end; Result := 0; end; -function TfrmMain.CreateFieldNodes(Node : PVirtualNode; Connection : TZConnection) : Integer; +function TfrmMain.CreateFieldNodes(Node : PVirtualNode; Connection : IZConnection) : Integer; var FPKeyList : TStringList; FResultSet : IZResultSet; @@ -501,13 +490,13 @@ try // Get primary key field names NodeData := FieldTree.GetNodeData(Node); - FResultSet := Connection.DbcConnection.GetMetadata.GetPrimaryKeys('', '', NodeData.Name); + FResultSet := Connection.GetMetadata.GetPrimaryKeys('', '', NodeData.Name); while FResultSet.Next do FPKeyList.Add(FResultSet.GetStringByName('COLUMN_NAME')); FResultSet.Close; // Get field name, type etc.. - FResultSet := Connection.DBCConnection.GetMetaData.GetColumns('', '', NodeData.Name, ''); + FResultSet := Connection.GetMetaData.GetColumns('', '', NodeData.Name, ''); while FResultSet.Next do begin @@ -534,7 +523,7 @@ end; function TfrmMain.CreateTableNodes(Node : PVirtualNode; - Connection : TZConnection) : Integer; + Connection : IZConnection) : Integer; var MetaData : IZDatabaseMetadata; TableTypes : TStringDynArray; @@ -545,7 +534,7 @@ Result := 0; Screen.Cursor := crSQLWait; try - MetaData := Connection.DbcConnection.GetMetadata; + MetaData := Connection.GetMetadata; SetLength(TableTypes, 1); TableTypes[0] := 'TABLE'; FResultSet := MetaData.GetTables('', '', '', TableTypes); @@ -570,24 +559,24 @@ procedure TfrmMain.actAddConnectionExecute(Sender : TObject); var - ConnectionProperty : TDGConnectionProperty; + ConnectionRule : TConnectionRule; ModalValue: Integer; begin ModalValue:= mrNone; Application.CreateForm(TfrmConnectionProperties, frmConnectionProperties); try - ConnectionProperty := TDGConnectionProperty.Create; + ConnectionRule := TConnectionRule.Create; try - frmConnectionProperties.ConnectionProperty := ConnectionProperty; + frmConnectionProperties.ConnectionRule := ConnectionRule; ModalValue:= frmConnectionProperties.ShowModal; if ModalValue = mrOK then begin - Configuration.ConnectionProperties.Add(ConnectionProperty); + Project.Childs.Add(ConnectionRule); CreateConnectionNodes; end; finally if ModalValue <> mrOK then - ConnectionProperty.Free; + ConnectionRule.Free; end; finally frmConnectionProperties.Free; @@ -648,7 +637,7 @@ begin Application.CreateForm(TfrmProgress, frmProgress); try - frmProgress.Configuration := Configuration; + frmProgress.Configuration := Project; if Database1.Checked then frmProgress.Output:= otDatabase; if SQL1.Checked then @@ -672,16 +661,16 @@ procedure TfrmMain.actCloseProjectUpdate(Sender : TObject); begin - TAction(Sender).Enabled := ConfigurationFileName <> ''; + TAction(Sender).Enabled := ProjectFileName <> ''; end; procedure TfrmMain.actSaveProjectExecute(Sender : TObject); begin - if ConfigurationFileName = '' then + if ProjectFileName = '' then actSaveAs.Execute else begin - Configuration.SaveToFile(ConfigurationFileName); - UISettings.AddRecentFile(ConfigurationFileName); + Project.SaveToFile(ProjectFileName); + UISettings.AddRecentFile(ProjectFileName); UpdateRecentFileMenuItems; end; end; @@ -690,7 +679,7 @@ var Node : PVirtualNode; ReferenceName: string; - Connection: TDGConnectionProperty; + Connection: TConnectionRule; begin Node := FieldTree.FocusedNode; while FieldTree.GetNodeLevel(Node) > 0 do @@ -701,8 +690,8 @@ mtWarning, [mbNo, mbYes], 0) = mrNo then Exit; - Connection:= Configuration.FindConnectionProperty(ReferenceName); - Configuration.RemoveConnectionProperty(Connection); + Connection:= Project.ConnectionRuleRef[ReferenceName]; + Project.Childs.Remove(Connection); FieldTree.DeleteNode(Node, True); FieldTree.Refresh; @@ -712,7 +701,7 @@ begin if SaveDialog.Execute then begin - ConfigurationFileName := SaveDialog.FileName; + ProjectFileName := SaveDialog.FileName; actSaveProject.Execute; end; end; @@ -722,9 +711,9 @@ TableName: string; ReferenceName: string; ColumnName: string; - ConnectionProperty: TDGConnectionProperty; - TableRule : TDGTableRule; - ColumnRule : TDGColumnRule; + ConnectionRule: TConnectionRule; + TableRule : TTableRule; + ColumnRule : TColumnRule; Node : PVirtualNode; begin Node := FieldTree.FocusedNode; @@ -737,18 +726,18 @@ ReferenceName:= GetParentNodeData(FieldTree, Node.Parent).Name; // Get table rule, column rule - ConnectionProperty:= Configuration.FindConnectionProperty(ReferenceName); - TableRule:= Configuration.FindTableRule(ReferenceName, TableName); - ColumnRule:= Configuration.FindColumnRule(ReferenceName, + ConnectionRule:= Project.ConnectionRuleRef[ReferenceName]; + TableRule:= Project.FindTableRule(ReferenceName, TableName); + ColumnRule:= Project.FindColumnRule(ReferenceName, TableName, ColumnName); // Remove column rule if Assigned(TableRule) then begin - TableRule.RemoveColumnRule(ColumnRule); + TableRule.Childs.Remove(ColumnRule); // if there is no column rule then remove table rule - if (TableRule.ColumnRules.Count = 0) and Assigned(ConnectionProperty) then - ConnectionProperty.RemoveTableRule(TableRule); + if (TableRule.ChildCount = 0) and Assigned(ConnectionRule) then + ConnectionRule.Childs.Remove(TableRule); end; FieldTree.Refresh; end; @@ -758,7 +747,7 @@ TableName: string; ReferenceName: string; ColumnName: string; - ColumnRule : TDGColumnRule; + ColumnRule : TColumnRule; Node : PVirtualNode; begin Node := FieldTree.FocusedNode; @@ -777,8 +766,8 @@ ReferenceName:= GetParentNodeData(FieldTree, Node.Parent).Name; // Get connection property, table rule, column rule - ColumnRule:= Configuration.FindColumnRule(ReferenceName, - TableName, ColumnName); + ColumnRule:= Project.FindColumnRule(ReferenceName, + TableName, ColumnName); TAction(Sender).Enabled := Assigned(ColumnRule); end; @@ -798,17 +787,17 @@ actCloseProject.Execute; end; -procedure TfrmMain.SetConfigurationFileName(const Value : string); +procedure TfrmMain.SetProjectFileName(const Value : string); begin - FConfigurationFileName := Value; + FProjectFileName := Value; Self.Caption := _('Datagenerator'); - if FConfigurationFileName <> '' then - Self.Caption := Format('%s [%s]', [Self.Caption, FConfigurationFileName]); + if FProjectFileName <> '' then + Self.Caption := Format('%s [%s]', [Self.Caption, FProjectFileName]); end; procedure TfrmMain.actCloseProjectExecute(Sender : TObject); begin - if (Configuration.ConnectionProperties.Count > 0) and + if (Project.ChildCount > 0) and (MessageDlg(_('Unsaved changes will be lost. Do you want to continue?'), mtWarning, [mbYes, mbNo], 0) = mrNo) then Exit; CloseProject; @@ -816,7 +805,7 @@ procedure TfrmMain.actRunUpdate(Sender : TObject); begin - TAction(Sender).Enabled := Configuration.ConnectionProperties.Count > 0; + TAction(Sender).Enabled := Project.ChildCount > 0; end; procedure TfrmMain.FormCreate(Sender : TObject); @@ -863,7 +852,7 @@ Node : PVirtualNode; TableName: string; ReferenceName: string; - TableRule : TDGTableRule; + TableRule : TTableRule; begin Node := FieldTree.FocusedNode; @@ -880,7 +869,7 @@ ReferenceName:= GetParentNodeData(FieldTree, Node).Name; // Get table rule - TableRule:= Configuration.FindTableRule(ReferenceName, TableName); + TableRule:= Project.FindTableRule(ReferenceName, TableName); TAction(Sender).Enabled := Assigned(TableRule); end; @@ -890,8 +879,8 @@ Node : PVirtualNode; TableName: string; ReferenceName: string; - ConnectionProperty: TDGConnectionProperty; - TableRule : TDGTableRule; + ConnectionRule: TConnectionRule; + TableRule : TTableRule; begin Node := FieldTree.FocusedNode; if not Assigned(Node) then Exit; @@ -901,16 +890,16 @@ ReferenceName:= GetParentNodeData(FieldTree, Node).Name; // Get connection property, table rule, column rule - ConnectionProperty:= Configuration.FindConnectionProperty(ReferenceName); - TableRule := ConnectionProperty.FindTableRule(TableName); + ConnectionRule:= Project.ConnectionRuleRef[ReferenceName]; + TableRule := ConnectionRule.FindTableRule(TableName); if MessageDlg(Format(_('Are you sure!' + #13 + 'You want to delete table rule : %s (and column rules) ?'), [TableName]), mtConfirmation, [mbYes, mbNo], 0) = mrNo then Exit; - if Assigned(ConnectionProperty) then - ConnectionProperty.RemoveTableRule(TableRule); + if Assigned(ConnectionRule) then + ConnectionRule.Childs.Remove(TableRule); FieldTree.Refresh; end; @@ -987,24 +976,25 @@ begin actCloseProject.Execute; // if Configuration file not clear then user choose to abort xml open action - if ConfigurationFileName <> '' then Exit; + if ProjectFileName <> '' then Exit; try - Configuration.LoadFromFile(AFilename); - ConfigurationFileName := AFileName; + FProject := TProject.LoadFromFile(AFilename); + ProjectFileName := AFileName; except CloseProject; raise; end; CreateConnectionNodes; - UISettings.AddRecentFile(ConfigurationFileName); + UISettings.AddRecentFile(ProjectFileName); UpdateRecentFileMenuItems; end; procedure TfrmMain.CloseProject; begin - Configuration.Clear; + Project.Childs.Clear; + Project.Free; FieldTree.Clear; - ConfigurationFilename:= ''; + ProjectFileName:= ''; end; procedure TfrmMain.FieldTreeGetHint(Sender: TBaseVirtualTree; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <t-...@us...> - 2007-01-05 21:16:22
|
Revision: 251 http://svn.sourceforge.net/datagenerator/?rev=251&view=rev Author: t-hex Date: 2007-01-05 13:16:18 -0800 (Fri, 05 Jan 2007) Log Message: ----------- -yeni xml lib merge'i Modified Paths: -------------- trunk/src/lib/DG_Core.pas trunk/src/lib/DG_Exporters.pas trunk/src/lib/DG_Intfs.pas trunk/src/lib/DG_Utils.pas trunk/src/lib/DataGenerator.dpk trunk/src/lib/generators/DG_AutoIncGenerator.pas trunk/src/lib/generators/DG_CachedGenerator.pas trunk/src/lib/generators/DG_CompositeGenerator.pas trunk/src/lib/generators/DG_LinkedGenerator.pas trunk/src/lib/generators/DG_PascalScriptedGenerator.pas trunk/src/lib/generators/DG_RangedGenerator.pas trunk/src/lib/rules/DG_AutoIncRule.pas trunk/src/lib/rules/DG_ColumnRule.pas trunk/src/lib/rules/DG_ConnectionRule.pas trunk/src/lib/rules/DG_CopyRule.pas trunk/src/lib/rules/DG_FixedRule.pas trunk/src/lib/rules/DG_PascalScriptRule.pas trunk/src/lib/rules/DG_PatternRule.pas trunk/src/lib/rules/DG_Project.pas trunk/src/lib/rules/DG_RangeRule.pas trunk/src/lib/rules/DG_SQLRule.pas trunk/src/lib/rules/DG_SequenceRule.pas trunk/src/lib/rules/DG_TableRule.pas trunk/src/lib/values/DG_ContextLink.pas trunk/src/lib/values/DG_FieldLink.pas trunk/src/lib/values/DG_FileLink.pas trunk/src/lib/values/DG_ListLink.pas trunk/src/lib/values/DG_PatternValue.pas trunk/src/lib/values/DG_SequenceLink.pas trunk/src/lib/values/DG_SingleValue.pas trunk/src/lib/values/DG_Values.pas Added Paths: ----------- trunk/src/lib/DG_ConnectionFactory.pas trunk/src/lib/DG_Datagenerator.pas trunk/src/lib/generators/ trunk/src/lib/rules/ trunk/src/lib/values/ Removed Paths: ------------- trunk/src/lib/DG_Builders.pas trunk/src/lib/DG_Configuration.pas trunk/src/lib/DG_Database.pas trunk/src/lib/DG_Generators.pas trunk/src/lib/DG_Values.pas trunk/src/lib/config.pas Property Changed: ---------------- trunk/src/lib/ Property changes on: trunk/src/lib ___________________________________________________________________ Name: svn:ignore + DG_Core.dcu DG_Database.dcu DG_Datagenerator.dcu DG_Exporters.dcu DG_Intfs.dcu DG_Types.dcu DG_Utils.dcu DG_Values.dcu Deleted: trunk/src/lib/DG_Builders.pas =================================================================== --- trunk/src/lib/DG_Builders.pas 2007-01-05 20:06:48 UTC (rev 250) +++ trunk/src/lib/DG_Builders.pas 2007-01-05 21:16:18 UTC (rev 251) @@ -1,512 +0,0 @@ -{---------------------------------------------------------} -{ DataGenerator Library } -{ Generator Builders } -{---------------------------------------------------------} -{ This library is free software; you can redistribute } -{ it and/or modify it under the terms of the GNU Lesser } -{ General Public License as published by the Free } -{ Software Foundation; either version 2.1 of the License, } -{ or (at your option) any later version. } -{ } -{ This library is distributed in the hope that it will be } -{ useful, but WITHOUT ANY WARRANTY; without even the } -{ implied warranty of MERCHANTABILITY or FITNESS FOR } -{ A PARTICULAR PURPOSE. See the GNU Lesser General } -{ Public License for more details. } -{---------------------------------------------------------} -unit DG_Builders; - -{**< Generator builders for column rule strategies} - -interface - -uses SysUtils, Classes, DG_Configuration, DG_Core, DG_Generators, - DG_Intfs, DG_Values, ZDBCIntfs,ZConnection, DG_Utils, DG_Types, DG_Database, - Variants; - -type - EInvalidColumnRule = class(Exception) - public - constructor Create(AStrategy: TGeneratorType; - AParamCount: Integer); overload; virtual; - end; - - {** Base class for all strategy builders. A Strategy builder is used to create - a generator for a column by using the parameters in the configuration} - TDGStrategyBuilder = class(TObject) - private - FDatagenerator: TDatagenerator; - protected - function GetStrategy: TGeneratorType; virtual; - public - constructor Create(ADatagenerator: TDatagenerator); virtual; - {**If there are many ways to interpret the parameter this method is called - @return an IValue implementor to be used with the generator} - function ProcessParameter(AParam: TDGParam): IValue; virtual; - {**Builds a @link(TGenerator) instance by using the @link(TDGColumnRule) instance. - The validity of the columnrule is also checked} - function BuildGenerator(AColumnRule: TDGColumnRule): TCustomGenerator; virtual; abstract; - property Strategy: TGeneratorType read GetStrategy; - end; - - TDGRangeBuilder = class(TDGStrategyBuilder) - protected - function GetStrategy: TGeneratorType; override; - public - function BuildGenerator(AColumnRule: TDGColumnRule): TCustomGenerator; override; - end; - - TDGFixedBuilder = class(TDGStrategyBuilder) - protected - function GetStrategy: TGeneratorType; override; - public - function BuildGenerator(AColumnRule: TDGColumnRule): TCustomGenerator; override; - end; - - TDGCopyBuilder = class(TDGStrategyBuilder) - protected - function GetStrategy: TGeneratorType; override; - public - function BuildGenerator(AColumnRule: TDGColumnRule): TCustomGenerator; override; - end; - - TDGVariableBuilder = class(TDGStrategyBuilder) - protected - function GetStrategy: TGeneratorType; override; - public - function BuildGenerator(AColumnRule: TDGColumnRule): TCustomGenerator; override; - end; - - TDGAutoIncBuilder = class(TDGStrategyBuilder) - protected - function GetStrategy: TGeneratorType; override; - public - function BuildGenerator(AColumnRule: TDGColumnRule): TCustomGenerator; override; - end; - - TDGSQLBuilder = class(TDGStrategyBuilder) - protected - function GetStrategy: TGeneratorType; override; - public - function BuildGenerator(AColumnRule: TDGColumnRule): TCustomGenerator; override; - end; - - TDGCompositeBuilder = class(TDGStrategyBuilder) - protected - function GetStrategy: TGeneratorType; override; - public - function BuildGenerator(AColumnRule: TDGColumnRule): TCustomGenerator; override; - end; - - TDGScriptBuilder = class(TDGStrategyBuilder) - protected - function GetStrategy: TGeneratorType; override; - public - function BuildGenerator(AColumnRule: TDGColumnRule): TCustomGenerator; override; - end; - - TDGSequenceBuilder = class(TDGStrategyBuilder) - protected - function GetStrategy: TGeneratorType; override; - public - function BuildGenerator(AColumnRule: TDGColumnRule): TCustomGenerator; override; - end; - - TDGPatternBuilder = class(TDGStrategyBuilder) - protected - function GetStrategy: TGeneratorType; override; - public - function BuildGenerator(AColumnRule: TDGColumnRule): TCustomGenerator; override; - end; - - TDGGeneratorFactory = class(TObject) - private - FBuilders : TList; - protected - function GetBuilderCount: Integer; - public - constructor Create(ADataGenerator: TDatagenerator); virtual; - destructor Destroy; override; - function BuildGenerator(AColumnRule: TDGColumnRule): TCustomGenerator; virtual; - procedure AddBuilder(ABuilder: TDGStrategyBuilder); - procedure RemoveBuilder(const Index: Integer); - function GetBuilder(const Index: Integer): TDGStrategyBuilder; overload; virtual; - function GetBuilder(const AStrategy: TGeneratorType): TDGStrategyBuilder; overload; virtual; - procedure Clear; virtual; - property BuilderCount: Integer read GetBuilderCount; - end; - -var - DefaultGeneratorBuilder : TDGStrategyBuilder; - -implementation - -uses gnugettext; - -{ EInvalidColumnRule } - -constructor EInvalidColumnRule.Create(AStrategy: TGeneratorType; - AParamCount: Integer); -begin - CreateFmt(_('%s strategy accepts exactly %d parameters'), - [GeneratorLocalName(AStrategy), AParamCount]); -end; - -{ TDGGeneratorFactory } - -constructor TDGGeneratorFactory.Create(ADataGenerator: TDatagenerator); -begin - FBuilders := TList.Create; - AddBuilder(TDGRangeBuilder.Create(ADatagenerator)); - AddBuilder(TDGSQLBuilder.Create(ADatagenerator)); - AddBuilder(TDGScriptBuilder.Create(ADatagenerator)); - AddBuilder(TDGAutoIncBuilder.Create(ADatagenerator)); - AddBuilder(TDGCompositeBuilder.Create(ADatagenerator)); - AddBuilder(TDGFixedBuilder.Create(ADatagenerator)); - AddBuilder(TDGCopyBuilder.Create(ADatagenerator)); - AddBuilder(TDGSequenceBuilder.Create(ADatagenerator)); - AddBuilder(TDGPatternBuilder.Create(ADatagenerator)); - AddBuilder(TDGVariableBuilder.Create(ADatagenerator)); -end; - -destructor TDGGeneratorFactory.Destroy; -begin - Clear; - FBuilders.Free; - inherited Destroy; -end; - -procedure TDGGeneratorFactory.AddBuilder(ABuilder: TDGStrategyBuilder); -var - Strategy : TDGStrategyBuilder; -begin - Assert(ABuilder <> nil, 'Builder is nil'); - Strategy := GetBuilder(ABuilder.Strategy); - Assert(Strategy = nil, Format('Builder for strategy %s is already in the list', - [GeneratorLocalName(ABuilder.Strategy)])); - FBuilders.Add(ABuilder); -end; - -function TDGGeneratorFactory.BuildGenerator( - AColumnRule: TDGColumnRule): TCustomGenerator; -var - ABuilder : TDGStrategyBuilder; -begin - Assert(AColumnRule <> nil, 'ColumnRule is nil'); - ABuilder := GetBuilder(AColumnRule.Strategy); - if not Assigned(ABuilder) then - raise Exception.Create(Format(_('Builder of strategy %s is not found'), - [GeneratorLocalName(AColumnRule.Strategy)])); - try - Result := ABuilder.BuildGenerator(AColumnRule); - except - on E:Exception do - raise Exception.Create( - Format(_('Generator for column %s couldn''t be initialized ' + - 'because of the following reason: %s'), - [AColumnRule.ColumnName, E.Message]) - ); - end; -end; - -procedure TDGGeneratorFactory.Clear; -var - I: Integer; -begin - for I:= 0 to FBuilders.Count - 1 do - if Assigned(FBuilders[I]) then - TDGStrategyBuilder(FBuilders[I]).Free; - FBuilders.Clear; -end; - -function TDGGeneratorFactory.GetBuilder( - const Index: Integer): TDGStrategyBuilder; -begin - if (Index < FBuilders.Count) and (Index >= 0) then - Result := TDGStrategyBuilder(FBuilders[Index]) - else - Result := nil; -end; - -function TDGGeneratorFactory.GetBuilder( - const AStrategy: TGeneratorType): TDGStrategyBuilder; -var - I : Integer; -begin - for I:= 0 to FBuilders.Count - 1 do - if Assigned(FBuilders[I]) and - (TDGStrategyBuilder(FBuilders[I]).Strategy = AStrategy) then - begin - Result := GetBuilder(I); - Exit; - end; - Result:= nil; -end; - -function TDGGeneratorFactory.GetBuilderCount: Integer; -begin - Result := FBuilders.Count; -end; - -procedure TDGGeneratorFactory.RemoveBuilder(const Index: Integer); -var - Builder: TDGStrategyBuilder; -begin - Builder:= GetBuilder(Index); - if Assigned(Builder) then - Builder.Free; - FBuilders.Delete(Index); -end; - -{ TDGStrategyBuilder } - -constructor TDGStrategyBuilder.Create(ADatagenerator: TDatagenerator); -begin - Assert(ADatagenerator <> nil, 'Datagenerator is nil'); - FDataGenerator := ADataGenerator; -end; - -function TDGStrategyBuilder.GetStrategy: TGeneratorType; -begin - raise Exception.CreateFmt(_('Strategy not defined for this builder %s'), - [Self.ClassName]); -end; - -function TDGStrategyBuilder.ProcessParameter(AParam: TDGParam): IValue; -var - t, b : string; -begin - { TODO : Date, time, timestamp, float values should store with a fixed - format not a locale dependent format. Otherwise configuration - xml's portability effects locale format and we may miss some - parameter types in here. - Dates should store like MM/DD/YYYY Eg: 10/23/2006 - Times should store like HH:MM:SS Eg: 13:11:00 - Float numbers should store like IIII.DDDD Eg: 123321.6764 - } - t := AParam.Type_; - b := AParam.Value; - { TODO : Also should work with SQL and script link } - if t = 'list' then - Result := TListLink.Create(b) - else - if t = 'file' then - Result := TFileLink.Create(b) - else - // if b is a numeric integer value - if IsInteger(b) then - begin - try - Result := TSingleValue.Create(StrToInt(b)); - except // if StrToInt cannot convert value b then value type is int64 - Result := TSingleValue.Create(StrToInt64(b)); - end; - end else - // if b is a numeric float value - if IsFloat(b) then - Result:= TSingleValue.Create(StrToFloat(b)) - else - // if b is date, time or timestamp - if isDate(b) then - Result := TSingleValue.Create(StrToDateTime(b)) - else - if not VarIsNull(FDatagenerator.GetValue(B)) then - Result := TContextLink.Create(b, FDataGenerator as IValueProvider) - else - // and finally it is a string - Result:= TSingleValue.Create(b); -end; - -{ TDGRangeBuilder } - -function TDGRangeBuilder.BuildGenerator(AColumnRule: TDGColumnRule): TCustomGenerator; -begin - if AColumnRule.Params.Count <> 2 then - raise EInvalidColumnRule.Create(Strategy, 2); - Result := TRangedGenerator.Create( - ProcessParameter(AColumnRule.Params[0]), - ProcessParameter(AColumnRule.Params[1])); -end; - -function TDGRangeBuilder.GetStrategy: TGeneratorType; -begin - Result:= gtRange; -end; - -{ TDGCompositeBuilder } - -function TDGCompositeBuilder.BuildGenerator( - AColumnRule: TDGColumnRule): TCustomGenerator; -var - I : Integer; - Param : IValue; -begin - if AColumnRule.Params.Count <= 0 then - raise EInvalidColumnRule.Create(Strategy, 1); - Result := TCompositeGenerator.Create; - for I := 0 to AColumnRule.Params.Count - 1 do - begin - Param := ProcessParameter(AColumnRule.Params[I]); - TCompositeGenerator(Result).AddGenerator(TCachedGenerator.Create(Param)); - end; -end; - -function TDGCompositeBuilder.GetStrategy: TGeneratorType; -begin - Result:= gtComposite; -end; - -{ TDGSQLBuilder } - -function TDGSQLBuilder.BuildGenerator( - AColumnRule: TDGColumnRule): TCustomGenerator; -var - Connection : TZConnection; - Statement : IZStatement; - FieldLink : IValue; -begin - if AColumnRule.Params.Count <= 0 then - raise EInvalidColumnRule.Create(Strategy, 2); - Connection := FDatagenerator.GetConnectionByRef(AColumnRule.Params[0].Value); - Statement := Connection.DbcConnection.CreateStatement; - FieldLink := TFieldLink.Create(Statement.ExecuteQuery( - AColumnRule.Params[1].Value)); - Result := TCachedGenerator.Create(FieldLink); -end; - -function TDGSQLBuilder.GetStrategy: TGeneratorType; -begin - Result:= gtSQL; -end; - -{ TDGAutoIncBuilder } - -function TDGAutoIncBuilder.BuildGenerator( - AColumnRule: TDGColumnRule): TCustomGenerator; -begin - if AColumnRule.Params.Count < 2 then - raise EInvalidColumnRule.Create(Strategy, 2); - Result := TAutoIncGenerator.Create( - ProcessParameter(AColumnRule.Params[0]), - ProcessParameter(AColumnRule.Params[1])); -end; - -function TDGAutoIncBuilder.GetStrategy: TGeneratorType; -begin - Result:= gtAutoInc; -end; - -{ TDGScriptBuilder } - -function TDGScriptBuilder.BuildGenerator( - AColumnRule: TDGColumnRule): TCustomGenerator; -begin - if AColumnRule.Params.Count <> 1 then - raise EInvalidColumnRule.Create(Strategy, 1); - Result := TScriptedGenerator.Create(ProcessParameter(AColumnRule.Params[0]), - FDataGenerator as IValueProvider); -end; - -function TDGScriptBuilder.GetStrategy: TGeneratorType; -begin - Result:= gtScript; -end; - -{ TDGFixedBuilder } - -function TDGFixedBuilder.BuildGenerator( - AColumnRule: TDGColumnRule): TCustomGenerator; -var - Value: TSingleValue; -begin - if AColumnRule.Params.Count <> 1 then - raise EInvalidColumnRule.Create(Strategy, 1); - Value:= TSingleValue.Create( - ProcessParameter(AColumnRule.Params[0]).GetValue); - Result := TLinkedGenerator.Create(Value); -end; - -function TDGFixedBuilder.GetStrategy: TGeneratorType; -begin - Result:= gtFixed; -end; - -{ TDGCopyBuilder } - -function TDGCopyBuilder.BuildGenerator(AColumnRule: TDGColumnRule): TCustomGenerator; -var - ContextLink: IValue; -begin - if AColumnRule.Params.Count < 1 then - raise EInvalidColumnRule.Create(Strategy, 1); - ContextLink := TContextLink.Create( - ProcessParameter(AColumnRule.Params[0]).GetValue, - FDataGenerator as IValueProvider); - Result := TLinkedGenerator.Create(ContextLink); -end; - -function TDGCopyBuilder.GetStrategy: TGeneratorType; -begin - Result:= gtCopy; -end; - -{ TDGSequenceBuilder } - -function TDGSequenceBuilder.BuildGenerator( - AColumnRule: TDGColumnRule): TCustomGenerator; -var - SequenceLink : IValue; - FSequence : IZSequence; - Connection : TZConnection; - SequenceName: String; - StepSize : Integer; -begin - if AColumnRule.Params.Count <> 3 then - raise EInvalidColumnRule.Create(Strategy, 3); - Connection := FDatagenerator.GetConnectionByRef(AColumnRule.Params[0].Value); - SequenceName := AColumnRule.Params[1].Value; - StepSize := StrToInt(AColumnRule.Params[2].Value); - FSequence := Connection.DbcConnection.CreateSequence(SequenceName, StepSize); - SequenceLink := TSequenceLink.Create(FSequence); - Result := TLinkedGenerator.Create(SequenceLink); -end; - -function TDGSequenceBuilder.GetStrategy: TGeneratorType; -begin - Result:= gtSequence; -end; - -{ TDGPatternBuilder } - -function TDGPatternBuilder.BuildGenerator( - AColumnRule: TDGColumnRule): TCustomGenerator; -var - Pattern : AnsiString; -begin - if AColumnRule.Params.Count <> 1 then - raise EInvalidColumnRule.Create(Strategy, 1); - Pattern := ProcessParameter(AColumnRule.Params[0]).GetValue; - Result := TLinkedGenerator.Create(TPatternValue.Create(Pattern)); -end; - -function TDGPatternBuilder.GetStrategy: TGeneratorType; -begin - Result:= gtPattern; -end; - -{ TDGVariableBuilder } - -function TDGVariableBuilder.BuildGenerator( - AColumnRule: TDGColumnRule): TCustomGenerator; -begin - if AColumnRule.Params.Count < 1 then - raise EInvalidColumnRule.Create(Strategy, 1); - Result := TLinkedGenerator.Create(ProcessParameter(AColumnRule.Params[0])); -end; - -function TDGVariableBuilder.GetStrategy: TGeneratorType; -begin - Result:= gtVariable; -end; - -end. Deleted: trunk/src/lib/DG_Configuration.pas =================================================================== --- trunk/src/lib/DG_Configuration.pas 2007-01-05 20:06:48 UTC (rev 250) +++ trunk/src/lib/DG_Configuration.pas 2007-01-05 21:16:18 UTC (rev 251) @@ -1,286 +0,0 @@ -{---------------------------------------------------------} -{ DataGenerator Library } -{ Configuration Persistence } -{ Initially coded by \xDDbrahim Dursun } -{ thex at thexpot net } -{---------------------------------------------------------} -{ This library is free software; you can redistribute } -{ it and/or modify it under the terms of the GNU Lesser } -{ General Public License as published by the Free } -{ Software Foundation; either version 2.1 of the License, } -{ or (at your option) any later version. } -{ } -{ This library is distributed in the hope that it will be } -{ useful, but WITHOUT ANY WARRANTY; without even the } -{ implied warranty of MERCHANTABILITY or FITNESS FOR } -{ A PARTICULAR PURPOSE. See the GNU Lesser General } -{ Public License for more details. } -{---------------------------------------------------------} -unit DG_Configuration; -{**< Classes for loading and saving the configuration } -interface - -uses xmldoc, xmlintf, Classes, SysUtils, config, DG_Database, Variants; - - -type - {** - Represents the configuration of data generation rules. Instances of this - class consists of TableRules and ColumnRules. @link(TDGConfiguration) - instance is passed as a parameter to the TDataGenerator's constructor. - } - TDGConfiguration = class(TObject) - private - FConnectionProperties: TDGConnectionPropertyList; - public - constructor Create(const AFileName: TFileName); overload; - constructor Create; overload; - destructor Destroy; override; - {** Saves the internal configuration to the specified file - @param AFileName name of the file to be saved} - procedure SaveToFile(const AFileName: string); overload; virtual; - {**Loads rules from the given file - @param AFileName file name to be loaded} - procedure LoadFromFile(const AFileName: string); virtual; - {** Clears all Connection Properties from the configuration} - procedure Clear; virtual; - {**Looks for a ConnectionProperty instance in the list using Referance - @param AReference Reference to be matched - @return Returns the ConnectionProperty if any is found else returns nil } - function FindConnectionProperty(const AReference: string): TDGConnectionProperty; - function FindTableRule(const AReference, ATableName: string): TDGTableRule; - function FindColumnRule(const AReference, ATableName, AColumnName: string): TDGColumnRule; - procedure AddConnectionProperty(AConnectionProperty: TDGConnectionProperty); - procedure RemoveConnectionProperty(AConnectionProperty: TDGConnectionProperty); - {**ConnectionProperties} - property ConnectionProperties : TDGConnectionPropertyList read FConnectionProperties; - end; - -implementation - -uses gnugettext; - -{ TDGConfiguration } - -constructor TDGConfiguration.Create; -begin - FConnectionProperties := TDGConnectionPropertyList.Create; -end; - -constructor TDGConfiguration.Create(const AFileName: TFileName); -begin - Create; - LoadFromFile(AFileName); -end; - -destructor TDGConfiguration.Destroy; -begin - FConnectionProperties.Free; - inherited Destroy; -end; - -procedure TDGConfiguration.LoadFromFile(const AFileName: string); -var - XML_DataGenerator : IXMLDatagenType; - I, J, K, L : Integer; - XML_ColumnRule : IXMLColumnRuleType; - XML_TableRule : IXMLTableRuleType; - XML_Configuration : IXMLConfigurationType; - TableRule : TDGTableRule; - ColumnRule : TDGColumnRule; - ConnectionProperty : TDGConnectionProperty; -begin - Clear; - XML_DataGenerator := Getdatagen(LoadXMLDocument(aFileName)); - try - // Create connection properties List - for I := 0 to XML_DataGenerator.ChildNodes.Count - 1 do - begin - XML_Configuration := XML_DataGenerator.Configuration[I]; - ConnectionProperty := TDGConnectionProperty.Create; - FConnectionProperties.Add(ConnectionProperty); - with ConnectionProperty do - begin - Ref := XML_Configuration.Ref; - Protocol := XML_Configuration.Protocol; - Host := XML_Configuration.Host; - Port := XML_Configuration.Port; - Catalog := XML_Configuration.Catalog; - Database := XML_Configuration.Database; - Username := XML_Configuration.Username; - Password := XML_Configuration.Password; - end; - - // Create table rules - for J := 0 to XML_Configuration.ChildNodes.Count - 1 do - begin - XML_TableRule := XML_Configuration.TableRule[J]; - TableRule:= ConnectionProperty.NewTableRule(XML_TableRule.Table); - with TableRule do - begin - Rows:= XML_TableRule.Rows; - CommitPeriod:= XML_TableRule.CommitPeriod; - EmptyTable:= XML_TableRule.EmptyTable; - end; - - // Create column rules - for K := 0 to XML_TableRule.ChildNodes.Count - 1 do - begin - XML_ColumnRule := XML_TableRule.ColumnRule[K]; - ColumnRule := TableRule.NewColumnRule(XML_ColumnRule.Column); - ColumnRule.Strategy := XML_ColumnRule.Strategy; - ColumnRule.NullPercentage := XML_ColumnRule.NullPercentage; - - // Create column params - for L := 0 to XML_ColumnRule.ChildNodes.Count - 1 do - if XML_ColumnRule.Param[L].NodeValue <> Null then - ColumnRule.NewParam(XML_ColumnRule.Param[L].Tip, - XML_ColumnRule.Param[L].NodeValue) - else - ColumnRule.NewParam(XML_ColumnRule.Param[L].Tip, ''); - end; - end; - end; - except on E: Exception do - raise Exception.CreateFmt(_('XML parse error on file %s: %s'), - [AFilename, E.Message]); - end; -end; - -procedure TDGConfiguration.SaveToFile(const AFileName: String); -var - I, J, K, L : Integer; - Document : IXMLDocument; - XML_Datagen : IXMLDatagenType; - XML_Configuration: IXMLConfigurationType; - XML_TableRule: IXMLTableRuleType; - XML_ColumnRule: IXMLColumnRuleType; - ConnectionProperty: TDGConnectionProperty; - TableRule : TDGTableRule; - ColumnRule : TDGColumnRule; -begin - XML_DataGen := Newdatagen; - // Save connection properties - for I := 0 to ConnectionProperties.Count - 1 do - begin - ConnectionProperty:= ConnectionProperties[I]; - XML_Configuration:= XML_DataGen.Add; - with XML_Configuration do - begin - Ref := ConnectionProperty.Ref; - Protocol := ConnectionProperty.Protocol; - Host := ConnectionProperty.Host; - Port := ConnectionProperty.Port; - Catalog := ConnectionProperty.Catalog; - Database := ConnectionProperty.Database; - Username := ConnectionProperty.Username; - Password := ConnectionProperty.Password; - end; - - // Save table rules - for J:= 0 to ConnectionProperty.TableRules.Count - 1 do - begin - TableRule:= ConnectionProperty.TableRules[J]; - XML_TableRule:= XML_Configuration.Add; - with XML_TableRule do - begin - Table := TableRule.TableName; - Rows := TableRule.Rows; - CommitPeriod := TableRule.CommitPeriod; - EmptyTable := TableRule.EmptyTable; - end; - - // Save column rules - for K := 0 to TableRule.ColumnRules.Count - 1 do - begin - ColumnRule := TableRule.ColumnRules[K]; - XML_ColumnRule:= XML_TableRule.Add; - with XML_ColumnRule do - begin - Column := ColumnRule.ColumnName; - Strategy := ColumnRule.Strategy; - NullPercentage := ColumnRule.NullPercentage; - end; - - // Save params - for L := 0 to ColumnRule.Params.Count - 1 do - begin - with XML_ColumnRule.Add do - begin - Tip := ColumnRule.Params[L].Type_; - NodeValue := ColumnRule.Params[L].Value; - end; - end; - end; - end; - end; - Document := XML_DataGen.OwnerDocument; - Document.Encoding:= 'UTF-8'; - Document.StandAlone:= 'yes'; - Document := LoadXMLData(FormatXMLData(Document.XML.Text)); // needed for identation/formatting - Document.SaveToFile(AFilename); -end; - -procedure TDGConfiguration.Clear; -begin - FConnectionProperties.Clear; -end; - -function TDGConfiguration.FindConnectionProperty( - const AReference: string): TDGConnectionProperty; -var - Index: Integer; -begin - Index:= FConnectionProperties.IndexOf(AReference); - if Index <> - 1 then - Result:= FConnectionProperties[Index] - else - Result:= nil; -end; - -function TDGConfiguration.FindTableRule(const AReference, - ATableName: string): TDGTableRule; -var - Connection: TDGConnectionProperty; -begin - Connection:= FindConnectionProperty(AReference); - if Assigned(Connection) then - Result:= Connection.FindTableRule(ATableName) - else - Result:= nil; -end; - -function TDGConfiguration.FindColumnRule(const AReference, ATableName, - AColumnName: string): TDGColumnRule; -var - Connection: TDGConnectionProperty; - TableRule: TDGTableRule; -begin - Result:= nil; - Connection:= FindConnectionProperty(AReference); - if Assigned(Connection) then - begin - TableRule:= Connection.FindTableRule(ATableName); - if Assigned(TableRule) then - Result:= TableRule.FindColumnRule(AColumnName); - end; -end; - -procedure TDGConfiguration.AddConnectionProperty( - AConnectionProperty: TDGConnectionProperty); -begin - if Assigned(AConnectionProperty) then - FConnectionProperties.Add(AConnectionProperty); -end; - -procedure TDGConfiguration.RemoveConnectionProperty( - AConnectionProperty: TDGConnectionProperty); -begin - if Assigned(AConnectionProperty) then - begin - AConnectionProperty.Free; - FConnectionProperties.Remove(AConnectionProperty); - end; -end; - -end. Added: trunk/src/lib/DG_ConnectionFactory.pas =================================================================== --- trunk/src/lib/DG_ConnectionFactory.pas (rev 0) +++ trunk/src/lib/DG_ConnectionFactory.pas 2007-01-05 21:16:18 UTC (rev 251) @@ -0,0 +1,57 @@ +unit DG_ConnectionFactory; + +interface +uses Classes, ZDbcIntfs, DG_ConnectionRule, ZConnection; +type + TConnectionFactory = class + public + function CreateConnection(const connRule: TConnectionRule): IZConnection; + end; + +function ConnectionFactory:TConnectionFactory; +procedure AssignConnectionRule(var conn: TZConnection; const connRule:TConnectionRule); + +implementation + +var + _ConnectionFactory : TConnectionFactory; + +function ConnectionFactory:TConnectionFactory; +begin + Result := _ConnectionFactory; +end; + +procedure AssignConnectionRule(var conn: TZConnection; const connRule:TConnectionRule); +begin + conn.Protocol := connRule.Protocol; + conn.User := connRule.Username; + conn.Password := connRule.Password; + conn.Catalog := connRule.Catalog; + conn.Port := connRule.Port; + conn.HostName := connRule.Host; + conn.Database := connRule.Database; +end; + +{ TConnectionFactory } + +function TConnectionFactory.CreateConnection( + const connRule: TConnectionRule): IZConnection; +var + conn : TZConnection; +begin + conn := TZConnection.Create(nil); + AssignConnectionRule(conn,connRule); + try + conn.Connect; + except + conn.Free; + raise; + end; + Result := conn.dbcconnection; +end; + +initialization + _ConnectionFactory := TConnectionFactory.Create; +finalization + _ConnectionFactory.Free; +end. Modified: trunk/src/lib/DG_Core.pas =================================================================== --- trunk/src/lib/DG_Core.pas 2007-01-05 20:06:48 UTC (rev 250) +++ trunk/src/lib/DG_Core.pas 2007-01-05 21:16:18 UTC (rev 251) @@ -21,402 +21,308 @@ interface -uses ZConnection, Classes, SysUtils, xmldoc, xmlintf, config, - DG_Intfs, DG_Generators, ZDbcIntfs, Variants, DG_Values, DG_Database, - DG_Configuration, Types; +uses ZConnection, Classes, SysUtils, + Variants, DG_Intfs, Types, TypInfo, JalMiniDom, JalXML, + JalCollections; + type EGeneratorException = class(Exception); - - {** - Main class which encapsulates the data generation process - } - TDataGenerator = class(TInterfacedObject, IObservable, IValueProvider) + EInvalidRuleException = Exception; + TXMLNodeClass = class of TXMLNode; + + {$TYPEINFO ON} + TXMLNode = class(TInterfacedPersistent) private - FGenerators : TStringList; - FExporter : IExporter; - FGenerationCount : Integer; - FObservers : TInterfaceList; - FConfiguration : TDGConfiguration; - FConnectionPool : TStringList; - FStopped: Boolean; + fParent : TXMLNode; + FChilds: TList; + protected - function _AddRef : Integer; stdcall; - function _Release : Integer; stdcall; - {** Creates TDGGenerator instances.} - procedure CreateGenerators(ATableRule : TDGTableRule); - procedure GenerateGenerators; - {** Frees the created generator objects} - procedure ClearGenerators; - procedure AddConnection(aConnProp : TDGConnectionProperty); - procedure CloseConnections; + function GetChild(I: Integer): TXMLNode; + function GetChildCount: Integer; + function ReadProperty(aPropertyName: String):Variant; + procedure WriteProperty(aPropertyName: String; Value: Variant); + function GetXMLBeginTag : String; virtual; + function GetXMLBody:String; virtual; + function GetXMLEndTag : String; virtual; + public - constructor Create(AConfiguration : TDGConfiguration); + constructor Create(AParent: TXMLNode); overload; virtual; + constructor Create; overload; virtual; destructor Destroy; override; - procedure SetExporter(anExporter : IExporter); virtual; - {** @link IObservable.AddObserver} - procedure AddObserver(const AnObserver : IObserver); - {** @link IObservable.RemoveObserver} - procedure RemoveObserver(const AnObserver : IObserver); - {** @link IObservable.GetObserver} - function GetObserver(const I : Integer) : IObserver; - {** @link IObservable.GetObserverCount} - function GetObserverCount : Integer; - {** @link IObservable.NotifyStart} - procedure NotifyStart(const AReference, ATableName : string; - ATotalRow : Integer); - {** @link IObservable.NotifyProgress} - procedure NotifyProgress(ACurrentRow : Integer); - {** @link IObservable.NotifyFailure} - procedure NotifyFailure(const AMessage : string); - {** @link IObservable.NotifyFinish} - procedure NotifyFinish(const AReference, ATableName : string); - {**@link IValueProvider.GetValue} - function GetValue(const Key : string) : Variant; overload; - {**@link IValueProvider.GetKey } - function GetKey(Index : Integer) : string; - {**@link IValueProvider.GetKeyCount } - function GetKeyCount : Integer; - {**Starts the data generation process} - procedure Generate; - {**Looks for a Connection in the connection pool - @param ref Reference of the connection - @return the connection with the requested ref. Returns nil if no connection - is found} - function GetConnectionByRef(const ref : string) : TZConnection; - procedure Stop; - property Stopped: Boolean read FStopped default False; + class function TagName: String;virtual; + function InitChild(anElement: IElement):TXMLNode; virtual; + procedure InitAttributes(anElement: IElement); virtual; + function ToString:String; virtual; + function ToXML:String; virtual; + function IsSingleNode: Boolean; virtual; + procedure ReadProperties(const aPropertyList: TStrings); virtual; + + property Parent: TXMLNode read fParent; + property Child[I: Integer]: TXMLNode read GetChild; + property Childs: TList read FChilds; + property ChildCount: Integer read GetChildCount; end; + +procedure RegisterRule(rule: TXMLNodeClass); +function RegisteredRuleCount:Integer; +function GetRegisteredRule(const i: Integer): TXMLNodeClass; +function FindRuleClass(const aTagName: String):TXMLNodeClass; - {**Creates a TZConnection instance using aConnProp. - @param aConnProp Properties to be assigned to the initialized connection.} -function CreateConnection(AConnProp : TDGConnectionProperty) : TZConnection; - - {**Assigns the properties of aConnProp to Connection. - @param Connection An instance of the class TZConnection. Connection is disconnected - if it is already active. - @param aConnProp An instance of the class TDGConnectionProperty.} -procedure AssignConnectionProperties(const Connection : TZConnection; - AConnProp : TDGConnectionProperty); - implementation -uses gnugettext, StrUtils, Math, DG_Utils, DG_Builders; +uses gnugettext, StrUtils, Math, DG_Utils; -procedure AssignConnectionProperties(const Connection : TZConnection; AConnProp : TDGConnectionProperty); -begin - Assert(Connection <> nil, 'Connection is nil'); - - if Connection.Connected then - Connection.Disconnect; - - with Connection do - begin - Protocol := AConnProp.Protocol; - Catalog := AConnProp.Catalog; - HostName := AConnProp.Host; - Port := AConnProp.Port; - Database := AConnProp.Database; - User := AConnProp.Username; - Password := AConnProp.Password; - AutoCommit := False; +type + TRegistryRec = record + ruleName: String; + ruleClass: TXMLNodeClass; end; -end; +var + RulesRegistry : array of TRegistryRec; -function CreateConnection(AConnProp : TDGConnectionProperty) : TZConnection; -begin - Result := TZConnection.Create(nil); - AssignConnectionProperties(Result, AConnProp); -end; - -{ TDataGenerator } - -constructor TDataGenerator.Create(AConfiguration : TDGConfiguration); +procedure RegisterRule(rule: TXMLNodeClass); var - I : integer; + registrySize : integer; begin - Assert(AConfiguration <> nil, 'Configuration is nil'); - FConfiguration := AConfiguration; - FConnectionPool := TStringList.Create; - FObservers := TInterfaceList.Create; - FGenerators := TStringList.Create; - FGenerationCount := 0; - - for I := 0 to FConfiguration.ConnectionProperties.Count - 1 do - AddConnection(FConfiguration.ConnectionProperties[I]); + registrySize := Length(RulesRegistry); + SetLength(RulesRegistry,registrySize+1); + with RulesRegistry[registrySize] do begin + ruleClass := rule; + ruleName := rule.TagName; + end; end; -procedure TDataGenerator.AddObserver(const AnObserver : IObserver); +function RegisteredRuleCount:Integer; begin - FObservers.Add(AnObserver); + Result := Length(RulesRegistry); end; -destructor TDataGenerator.Destroy; +function GetRegisteredRule(const i: Integer): TXMLNodeClass; begin - ClearGenerators; - FGenerators.Free; - - FObservers := nil; - FExporter := nil; - - CloseConnections; - FConnectionPool.Free; - - inherited Destroy; + Result := RulesRegistry[i].ruleClass; end; -procedure TDataGenerator.CreateGenerators(ATableRule : TDGTableRule); +function FindRuleClass(const aTagName: String):TXMLNodeClass; var - I : Integer; - Generator : TCustomGenerator; - GeneratorFactory : TDGGeneratorFactory; - ColumnRule : TDGColumnRule; + i: Integer; begin - ClearGenerators; - GeneratorFactory := TDGGeneratorFactory.Create(Self); - try - for I := 0 to ATableRule.ColumnRules.Count - 1 do - try - ColumnRule := ATableRule.ColumnRules[I]; - Generator := GeneratorFactory.BuildGenerator(ColumnRule); - Generator.NullPercentage := ColumnRule.NullPercentage; - FGenerators.AddObject(ColumnRule.ColumnName, Generator); - except on E : Exception do - NotifyFailure(Format(_('Error on generator creation on table %s: %s'), - [ATableRule.TableName, E.Message])); + Result := nil; + for I := low(RulesRegistry) to High(RulesRegistry) do + if RulesRegistry[I].ruleName = aTagName then begin + Result := RulesRegistry[I].ruleClass; + break; end; - finally - GeneratorFactory.Free; - end; end; -{** - Starts the data generation -} - -procedure TDataGenerator.Generate; +{ TXMLNode } +function TXMLNode.InitChild(anElement: IElement): TXMLNode; var - I, J : Integer; - TableRule : TDGTableRule; - ConnProp : TDGConnectionProperty; + ruleClass : TXMLNodeClass; + rule : TXMLNode; begin - FStopped:= False; - // Generate values - for I := 0 to FConfiguration.ConnectionProperties.Count - 1 do - begin - ConnProp := FConfiguration.ConnectionProperties[I]; - for J := 0 to ConnProp.TableRules.Count - 1 do - begin - TableRule := ConnProp.TableRules[J]; - FGenerationCount := 0; - - // Prepare generators for table - try - CreateGenerators(TableRule); - except - ClearGenerators; - Exit; - end; - - NotifyStart(ConnProp.Ref, TableRule.TableName, TableRule.Rows); - - if Assigned(FExporter) then - begin - FExporter.Connection := GetConnectionByRef(ConnProp.Ref); - FExporter.StartedTable(TableRule); - end; - - // Generate until specified rows count - while (FGenerationCount < TableRule.Rows) do - begin - if Stopped then - Break; - // Generate all generators on table - GenerateGenerators; - FGenerationCount := FGenerationCount + 1; - // Export - try - if Assigned(FExporter) then - FExporter.RowGenerated(TableRule, Self); - NotifyProgress(FGenerationCount); - except on E : Exception do - NotifyFailure(Format(_('Export failed on table %s:%s'), - [TableRule.TableName, E.Message])); - end; - end; - if Assigned(FExporter) then - FExporter.FinishedTable(TableRule); - NotifyFinish(ConnProp.Ref, TableRule.TableName); - end; - end; + ruleClass := FindRuleClass(anElement.name); + if assigned(ruleClass) then begin + rule := ruleClass.Create(self); + rule.InitAttributes(anElement); + FChilds.Add(rule); + Result := rule; + end else + raise EInvalidRuleException.CreateFmt('[%d:%d] Invalid rule %s',[anElement.Location.LineNumber,anElement.Location.ColumnNumber,anElement.name]); end; -function TDataGenerator.GetObserver(const I : Integer) : IObserver; +procedure TXMLNode.InitAttributes(anElement: IElement); +var + itr : IIterator; + attr: IAttribute; begin - Result := nil; - if Assigned(FObservers) then - Result := FObservers[I] as IObserver; + itr := anElement.attributes.iterator; + while itr.hasNext do begin + attr := itr.next as IAttribute; + WriteProperty(attr.name,attr.value); + end; end; -function TDataGenerator.GetObserverCount : Integer; +function TXMLNode.ToString: String; begin - if Assigned(FObservers) then - Result := FObservers.Count - else - Result := 0; + Result := 'rule'; end; -procedure TDataGenerator.RemoveObserver(const AnObserver : IObserver); +function TXMLNode.ToXML: String; +var + StrList: TStrings; begin - FObservers.Remove(AnObserver); + StrList := TStringList.Create; + try + StrList.Text := GetXMLBody; + StrList.Insert(0,GetXMLBeginTag); + if GetXMLEndTag <> '' then + StrList.Append(GetXMLEndTag); + Result := StrList.Text; + finally + StrList.Free; + end; end; -procedure TDataGenerator.SetExporter(anExporter : IExporter); +constructor TXMLNode.Create(AParent: TXMLNode); begin - FExporter := anExporter; + Create; + fParent := AParent; end; -function TDataGenerator.GetKey(Index : Integer) : string; +constructor TXMLNode.Create; begin - Result := FGenerators[Index]; + FChilds := TList.Create; end; -function TDataGenerator.GetKeyCount : Integer; +destructor TXMLNode.Destroy; begin - Result := FGenerators.Count; + FChilds.Free; + inherited; end; -function TDataGenerator.GetValue(const Key : string) : Variant; +function TXMLNode.GetXMLBeginTag: String; var + StrList : TStrings; I : Integer; begin - I := FGenerators.IndexOf(Key); - // If key not found, return Null - if I = -1 then - begin - Result := Null; - Exit; - end; - Result := TCustomGenerator(FGenerators.Objects[I]).Value; -end; - -procedure TDataGenerator.ClearGenerators; -var - I : Integer; -begin - for I := 0 to FGenerators.Count - 1 do - if Assigned(FGenerators.Objects[I]) then - TCustomGenerator(FGenerators.Objects[I]).Free; - FGenerators.Clear; -end; - -procedure TDataGenerator.AddConnection(AConnProp : TDGConnectionProperty); -var - Conn : TZConnection; -begin - Assert(AConnProp <> nil, 'AConnProp is nil'); - - Conn := CreateConnection(AConnProp); - FConnectionPool.AddObject(AConnProp.Ref, Conn); + Result := '<' + TagName; + StrList := TStringList.Create; try - Conn.Connect; - except - on E : Exception do - raise Exception.Create(Format('Error while connecting to database with connection name(%s) : %s ', - [AConnProp.Ref, E.Message])); + ReadProperties(StrList); + for I := 0 to StrList.Count - 1 do + Result := Result + Format(' %s="%s"',[LowerCase(StrList.Names[I]),LowerCase(StrList.ValueFromIndex[I])]); + if IsSingleNode then + Result := Result + ' />' + else + Result := Result + '>'; + finally + StrList.Free; end; end; -procedure TDataGenerator.CloseConnections; +function TXMLNode.GetXMLBody: String; var - I : Integer; + childStrList, strList: TStrings; + i,j : Integer; begin + childStrList := TStringList.Create; + strList := TStringList.Create; try - for I := 0 to FConnectionPool.Count - 1 do - with TZConnection(FConnectionPool.Objects[I]) do - begin - Disconnect; - Free; - end; + for i := 0 to ChildCount - 1 do begin + childStrList.Text := Child[i].ToXML; + for j := 0 to childStrList.Count - 1 do + childStrList[j] := ' '+ childStrList[j]; + StrList.AddStrings(childStrList); + end; + Result := StrList.Text; finally - FConnectionPool.Clear; - end; + strList.Free; + childStrList.Free; + end; end; -function TDataGenerator.GetConnectionByRef(const Ref : string) : TZConnection; -var - I : Integer; +function TXMLNode.GetChild(I: Integer): TXMLNode; begin - Result := nil; - I := FConnectionPool.IndexOf(Ref); - if I >= 0 then - Result := TZConnection(FConnectionPool.Objects[I]); + Result := TXMLNode(FChilds[I]); end; -procedure TDataGenerator.NotifyFinish(const AReference, ATableName : string); +procedure TXMLNode.ReadProperties(const aPropertyList: TStrings); var + propList: PPropList; + propCount: Integer; I : Integer; + val : String; begin - for I := 0 to GetObserverCount - 1 do - GetObserver(I).Finish(AReference, ATableName); + propCount := GetPropList(Self.ClassInfo,propList); + for i := 0 to propCount - 1 do begin + if not IsStoredProp(self,propList^[i].Name) then continue; + val := ReadProperty(propList^[i].Name); + aPropertyList.Values[propList^[i].Name] := val; + end; end; -procedure TDataGenerator.NotifyProgress(ACurrentRow : Integer); +function TXMLNode.ReadProperty(aPropertyName: String): Variant; var - I : Integer; + TypeInfo: PTypeInfo; + PropInfo: PPropInfo; begin - for I := 0 to Self.GetObserverCount - 1 do - GetObserver(I).Progress(ACurrentRow); + Result := null; + TypeInfo := Self.ClassInfo; + PropInfo := GetPropInfo(TypeInfo,aPropertyName); + if PropInfo <> nil then begin + case PropInfo^.PropType^.Kind of + tkInteger,tkChar,tkWChar: + Result := GetOrdProp(Self,PropInfo); + tkInt64: + Result := GetInt64Prop(self,propinfo); + tkFloat: + Result := GetFloatProp(self,propinfo); + tkString,tkLString: + Result := GetStrProp(Self,PropInfo); + tkWString: + Result := GetWideStrProp(self,propinfo); + tkVariant: + Result := GetVariantProp(self,propinfo); + tkEnumeration: + Result := VarAsType(GetEnumProp(Self,PropInfo),varBoolean); + else + raise Exception.Create('UnsupportedType'); + end; + end; end; -procedure TDataGenerator.NotifyFailure(const AMessage : string); +procedure TXMLNode.WriteProperty(aPropertyName: String; Value: Variant); var - I : Integer; + TypeInfo: PTypeInfo; + PropInfo: PPropInfo; begin - for I := 0 to Self.GetObserverCount - 1 do - GetObserver(I).Failure(AMessage); + TypeInfo := Self.ClassInfo; + PropInfo := GetPropInfo(TypeInfo,aPropertyName); + if (PropInfo <> nil) then + case PropType(self,aPropertyName) of + tkInteger,tkChar,tkWChar: + SetOrdProp(self,PropInfo,Value); + tkInt64: + SetInt64Prop(self,propinfo,strtoint64(value)); + tkFloat: + SetFloatProp(self,propinfo,value); + tkString,tkLString: + SetStrProp(self,PropInfo,Value); + tkWString: + SetWideStrProp(self,propinfo,value); + tkVariant: + SetVariantProp(self,propinfo,Value); + tkEnumeration: + SetEnumProp(self,PropInfo,Value); + end; end; -procedure TDataGenerator.NotifyStart(const AReference, ATableName : string; - ATotalRow : Integer); -var - I : Integer; -begin - for I := 0 to GetObserverCount - 1 do - GetObserver(I).Start(AReference, ATableName, ATotalRow); -end; -function TDataGenerator._AddRef : Integer; +class function TXMLNode.TagName: String; begin - Result := -1; + Result := ''; end; -function TDataGenerator._Release : Integer; +function TXMLNode.GetChildCount: Integer; begin - Result := -1; + Result := FChilds.Count; end; -procedure TDataGenerator.GenerateGenerators; -var - I : Integer; - Generator : TCustomGenerator; - +function TXMLNode.IsSingleNode: Boolean; begin - for I := 0 to FGenerators.Count - 1 do - try - Generator := TCustomGenerator(FGenerators.Objects[I]); - Generator.Generate; - except on E : Exception do - NotifyFailure(Format(_('%s generation failed:%s'), - [FGenerators[I], E.Message])); - end; + Result := ChildCount = 0; end; -procedure TDataGenerator.Stop; +function TXMLNode.GetXMLEndTag: String; begin - FStopped := True; + Result := ''; + if not IsSingleNode then + Result := '</' + TagName + '>'; end; + + initialization // Randomize should call only once at application startup Randomize; Deleted: trunk/src/lib/DG_Database.pas =================================================================== --- trunk/src/lib/DG_Database.pas 2007-01-05 20:06:48 UTC (rev 250) +++ trunk/src/lib/DG_Database.pas 2007-01-05 21:16:18 UTC (rev 251) @@ -1,504 +0,0 @@ -{---------------------------------------------------------} -{ DataGenerator Library } -{ Database related classes } -{ Initially coded by \xDDbrahim Dursun } -{ thex at thexpot net } -{---------------------------------------------------------} -{ This library is free software; you can redistribute } -{ it and/or modify it under the terms of the GNU Lesser } -{ General Public License as published by the Free } -{ Software Foundation; either version 2.1 of the License, } -{ or (at your option) any later version. } -{ } -{ This library is distributed in the hope that it will be } -{ useful, but WITHOUT ANY WARRANTY; without even the } -{ implied warranty of MERCHANTABILITY or FITNESS FOR } -{ A PARTICULAR PURPOSE. See the GNU Lesser General } -{ Public License for more details. } -{---------------------------------------------------------} -unit DG_Database; - -interface - -uses Classes, SysUtils, DG_Types; - -type - TDGTableRule = class; - TDGColumnRule = class; - TDGTableRuleList = class; - TDGColumnRuleList = class; - TDGParamList = class; - - {**Instances of TDGConnectionProperty contains the required information about - establishing a connection to a database. They neither represent nor aggregrate - the connection} - TDGConnectionProperty = class(TObject) - private - FPort: Integer; - FPassword: string; - FUsername: string; - FHost: string; - FProtocol: string; - FCatalog: string; - FDatabase: string; - FRef: string; - FTableRules: TDGTableRuleList; - public - constructor Create; virtual; - destructor Destroy; override; - {**Looks for a TableRule instance in the list using TableName - @param ATableName TableName to be matched - @return returns nil if none is found} - function FindTableRule(const ATableName: string): TDGTableRule; - {**Creates and add a new TableRule instance to the list - @param ATableName Table name of the new Tablerule - @return newly created TableRule} - function NewTableRule(const ATableName: string): TDGTableRule; - {**Adds the TableRule to the end of the TableRuleList - @param ATableRule TableRule instance to be added} - procedure AddTableRule(ATableRule: TDGTableRule); - {**Removes the given table rule from the list - @param ATableRule TableRule instance to be removed} - procedure RemoveTableRule(ATableRule: TDGTableRule); - {**Reference name of the connection. Every Connection is - mapped by a reference. Reference is taken from the configuration} - property Ref : string read FRef write FRef; - property Protocol : string read FProtocol write FProtocol; - property Host : string read FHost write FHost; - property Port : Integer read FPort write FPort; - property Catalog : string read FCatalog write FCatalog; - property Database : string read FDatabase write FDatabase; - property Username : string read FUsername write FUsername; - property Password : string read FPassword write FPassword; - {**TableRules} - property TableRules: TDGTableRuleList read FTableRules; - end; - - {** - Represents a rule composed of ColumnRules to create table data. - } - TDGTableRule = class(TObject) - private - FTableName : string; - FColumnRules: TDGColumnRuleList; - FRows: Integer; - FEmptyTable: Boolean; - FCommitPeriod: Integer; - procedure SetRows(const Value: Integer); - procedure SetCommitPeriod(const Value: Integer); - public - constructor Create(const ATableName : string); virtual; - destructor Destroy; override; - {** Creates, adds and returns a TDGColumnRule instance to the list. - @param AColumnName A ColumnName for the internally created instance. - @return returns the initialized TDGColumnRule instance.} - function NewColumnRule(const AColumnName: string): TDGColumnRule; - {**Adds the ColumnRule instance to the end of the list - @param aColumnRule instance to be added} - procedure AddColumnRule(AColumnRule: TDGColumnRule); - {**Removes the given ColumnRule from the list - @param aColumnRule instance to be removed} - procedure RemoveColumnRule(AColumnRule: TDGColumnRule); - {**Looks for a ColumnRule instance in the list using ColumnName - @param AColumnName ColumnName to be matched - @return returns nil if none is found} - function FindColumnRule(const AColumnName: string): TDGColumnRule; - {** Name of the table} - property TableName : string read FTableName; - {** Number of rows to be generated} - property Rows: Integer read FRows write SetRows; - {** Committing period } - property CommitPeriod : Integer read FCommitPeriod write SetCommitPeriod; - {** If it is true then before inserting data this table should be emptied } - property EmptyTable : Boolean read FEmptyTable write FEmptyTable; - {** ColumnRule aggregration} - property ColumnRules : TDGColumnRuleList read FColumnRules; - end; - - TDGParam = class(TObject) - private - FType: string; - FValue: string; - public - constructor Create(const AValue: String; const AType: string); - property Type_: string read FType write FType; - property Value: string read FValue write FValue; - end; - - {** - Represents a column rule which has the required information - about the generation of values for the given column. - } - TDGColumnRule = class(TObject) - private - FColumnName: string; - FStrategy: TGeneratorType; - FParams: TDGParamList; - FNullPercentage: TPercentage; - public - constructor Create(const AColumnName : string); virtual; - destructor Destroy; override; - {** Creates, adds and returns a TDGParam instance to the list. - @param AType A Type for the internally created instance. - @param AType A Value for the internally created instance. - @return returns the initialized TDGColumnRule instance.} - function NewParam(const AType, AValue: string): TDGParam; - {**Adds the Param instance to the end of the list - @param AParam instance to be added} - procedure AddParam(AParam: TDGParam); - {**Removes the given Param from the list - @param AParam instance to be removed} - procedure RemoveParam(AParam: TDGParam); - property ColumnName : string read FColumnName write FColumnName; - {** Parameters for the generator.} - property Params : TDGParamList read FParams; - {** Defines the type of the generator. Possible values are range, composite, sql, script.} - property Strategy: TGeneratorType read FStrategy write FStrategy; - {** Percentage between 0 (no null values) and 100 (all values are null)} - property NullPercentage: TPercentage read FNullPercentage write FNullPercentage default 0; - end; - - {**A list for the instances of the class TDGConnectionProperty.} - TDGConnectionPropertyList = class(TList) - private - function Get(const I: Integer): TDGConnectionProperty; - public - property Items[const I : Integer]: TDGConnectionProperty read Get; default; - function Add(const AConnectionProperty: TDGConnectionProperty): Integer; overload; - function IndexOf(const AReference: string): Integer; overload; - procedure Clear; override; - end; - - {**A list for the instances of the class TDGTableRule.} - TDGTableRuleList = class(TList) - private - function Get(const I: Integer): TDGTableRule; - public - property Items[const I : Integer] : TDGTableRule read Get; default; - function Add(ATableRule: TDGTableRule): Integer; overload; - function IndexOf(const ATableName: string): Integer; overload; - procedure Clear; override; - end; - - {**A list for the instances of the class TDGColumnRule.} - TDGColumnRuleList = class(TList) - private - function Get(const I: Integer): TDGColumnRule; - public - property Items[const I : Integer]: TDGColumnRule read Get; default; - function Add(AColumnRule: TDGColumnRule): Integer; overload; - function IndexOf(const AColumnName: string): Integer; overload; - procedure Clear; override; - end; - - {**A list for the instances of the @link TParam.} - TDGParamList = class(TList) - private - function Get(const I: Integer): TDGParam; - public - property Items[const I : Integer] : TDGParam read Get; default; - function Add(AParam: TDGParam): Integer; overload; - procedure Clear; override; - end; - -implementation - -uses gnugettext; - -{ TDGConnectionPropertyList } - -function TDGConnectionPropertyList.Add( - const AConnectionProperty: TDGConnectionProperty): Integer; -begin - if IndexOf(AConnectionProperty.Ref) <> -1 then - raise Exception.CreateFmt( - _('There is already a connection in the list with the same reference name: %s '), - [AConnectionProperty.Ref]); - Result := inherited Add(AConnectionProperty); -end; - -procedure TDGConnectionPropertyList.Clear; -var - I: Integer; -begin - for I:= 0 to Self.Count - 1 do - if Assigned(Self[I]) then - Self[I].Free; - inherited Clear; -end; - -function TDGConnectionPropertyList.Get(const I: Integer): TDGConnectionProperty; -begin - Result := TDGConnectionProperty(inherited Get(I)); -end; - -function TDGConnectionPropertyList.IndexOf( - const AReference: string): Integer; -var - I : Integer; -begin - for I := 0 to Self.Count - 1 do - if Assigned(Self[I]) and (UpperCase(Self[I].Ref) = UpperCase(AReference)) then - begin - Result:= I; - Exit; - end; - Result := -1; -end; - -{TDGTableRule} - -constructor TDGTableRule.Create(const ATableName: string); -begin - FColumnRules := TDGColumnRuleList.Create; - FTableName := ATableName; - { TODO : Explain why. } - // Default value is 1000. if this value is 0, "division by zero" occurs. - FCommitPeriod:= 1000; - FRows:= 1000; -end; - -destructor TDGTableRule.Destroy; -begin - FColumnRules.Free; - inherited Destroy; -end; - -procedure TDGTableRule.AddColumnRule(AColumnRule: TDGColumnRule); -begin - FColumnRules.Add(AColumnRule); -end; - -function TDGTableRule.NewColumnRule(const AColumnName: string): TDGColumnRule; -begin - Result := TDGColumnRule.Create(AColumnName); - try - FColumnRules.Add(Result); - except - FreeAndNil(Result); - end; -end; - -procedure TDGTableRule.RemoveColumnRule(AColumnRule: TDGColumnRule); -begin - // Dont forget free ColumnRule on remove - if Assigned(AColumnRule) then - AColumnRule.Free; - FColumnRules.Remove(AColumnRule); -end; - -procedure TDGTableRule.SetCommitPeriod(const Value: Integer); -begin - if Value < 1 then - raise Exception.Create(_('Commit period value must be higher than 0')); - FCommitPeriod := Value; -end; - -procedure TDGTableRule.SetRows(const Value: Integer); -begin - if Value < 1 then - raise Exception.Create(_('Numbers of generated rows must be higher than 0')); - FRows := Value; -end; - -function TDGTableRule.FindColumnRule( - const AColumnName: string): TDGColumnRule; -var - Index: Integer; -begin - Index:= FColumnRules.IndexOf(AColumnName); - if Index <> - 1 then - Result:= FColumnRules[Index] - else - Result:= nil; -end; - -{ TDGTableRuleList } - -function TDGTableRuleList.Add(ATableRule: TDGTableRule): Integer; -begin - if IndexOf(A... [truncated message content] |
From: <t-...@us...> - 2007-01-05 20:06:54
|
Revision: 250 http://svn.sourceforge.net/datagenerator/?rev=250&view=rev Author: t-hex Date: 2007-01-05 12:06:48 -0800 (Fri, 05 Jan 2007) Log Message: ----------- Modified Paths: -------------- trunk/src/ui/FormColumnRule.pas Modified: trunk/src/ui/FormColumnRule.pas =================================================================== --- trunk/src/ui/FormColumnRule.pas 2007-01-05 14:54:01 UTC (rev 249) +++ trunk/src/ui/FormColumnRule.pas 2007-01-05 20:06:48 UTC (rev 250) @@ -229,7 +229,8 @@ NodeData := ParamTreeList.GetNodeData(Node); EditorType := FRuleController.GetParamViewData(Node.Index).EditorType; case EditorType of - edtNone: ParamTreeList.EditNode(FCheckedNode, 1); + { TODO 1 -ot-hex : Fix. Doesnt edit the focused node } + //edtNone: ParamTreeList.EditNode(Node, 1); edtFile: begin ParamOpenDialog.FileName := FRuleController.GetParameterValue(NodeData.key); if ParamOpenDialog.Execute then @@ -310,6 +311,7 @@ connRef := FRuleController.GetParameterValue(paramdata.key); FillSequencesProposalList(EditLink,connRef); end; + if not assigned(EditLink) then EditLink := TStringEditLink.Create; end; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fd...@us...> - 2007-01-05 14:54:03
|
Revision: 249 http://svn.sourceforge.net/datagenerator/?rev=249&view=rev Author: fduman Date: 2007-01-05 06:54:01 -0800 (Fri, 05 Jan 2007) Log Message: ----------- It's a good practice to give unique numbers for checking comments. It simplifies detecting errors locations. (from Mono project ;) Modified Paths: -------------- trunk/src/dunit/DG_GeneratorsTests.pas trunk/src/dunit/DG_ValuesTests.pas Modified: trunk/src/dunit/DG_GeneratorsTests.pas =================================================================== --- trunk/src/dunit/DG_GeneratorsTests.pas 2007-01-03 13:50:29 UTC (rev 248) +++ trunk/src/dunit/DG_GeneratorsTests.pas 2007-01-05 14:54:01 UTC (rev 249) @@ -79,7 +79,7 @@ procedure TScriptedGeneratorTests.TestCreate; begin - CheckException(CreateException, EScriptException); + CheckException(CreateException, EScriptException, '#A01'); end; procedure TScriptedGeneratorTests.TestReturnScript; @@ -87,7 +87,7 @@ with GetScriptedValue('begin return(''thex''); end.') do begin Generate; - CheckEquals('thex', Value); + CheckEquals('thex', Value, '#A02'); Free; end; end; @@ -97,7 +97,7 @@ with GetScriptedValue('begin return(random(10)); end.') do begin Generate; - Check(Value < 10); + Check(Value < 10, '#A03'); Free; end; end; @@ -111,11 +111,9 @@ FAutoIncGenerator:= TAutoIncGenerator.Create(FStart, FStep); try FAutoIncGenerator.Generate(); - Check(CompareValue(57.513, FAutoIncGenerator.Value, 0.001) = 0, - 'Float value equality error'); + Check(CompareValue(57.513, FAutoIncGenerator.Value, 0.001) = 0, '#A04'); FAutoIncGenerator.Generate(); - Check(CompareValue(59.813, FAutoIncGenerator.Value, 0.001) = 0, - 'Float value equality error'); + Check(CompareValue(59.813, FAutoIncGenerator.Value, 0.001) = 0, '#A05'); finally FAutoIncGenerator.Free; end; @@ -132,9 +130,9 @@ FAutoIncGenerator:= TAutoIncGenerator.Create(FStart, FStep); try FAutoIncGenerator.Generate(); - CheckEquals(7, FAutoIncGenerator.Value, ''); + CheckEquals(7, FAutoIncGenerator.Value, '#A06'); FAutoIncGenerator.Generate(); - CheckEquals(9, FAutoIncGenerator.Value, ''); + CheckEquals(9, FAutoIncGenerator.Value, '#A07'); finally FAutoIncGenerator.Free; end; @@ -174,18 +172,15 @@ procedure TCachedGeneratorTests.TestCacheCount; begin FCachedGenerator2.Generate; - CheckEquals(2, FCachedGenerator2.FCache.Count, - 'Cachedgenerator cached more than 2 items'); + CheckEquals(2, FCachedGenerator2.FCache.Count, '#A08'); // First Cache should contain 1000 items FCachedGenerator1005.Generate; - CheckEquals(1000, FCachedGenerator1005.FCache.Count, - 'Cachedgenerator cached wrong'); + CheckEquals(1000, FCachedGenerator1005.FCache.Count, '#A09'); // Force generator to next cache while (FCachedGenerator1005.FFetchCount <= 751) do FCachedGenerator1005.Generate; // Next cache should contain 1000 items again - CheckEquals(1005, FCachedGenerator1005.FCache.Count, - 'Cachedgenerator cached wrong'); + CheckEquals(1005, FCachedGenerator1005.FCache.Count, '#A10'); end; procedure TCachedGeneratorTests.TestGenerate; @@ -194,7 +189,7 @@ begin FCachedGenerator2.Generate(); Value:= FCachedGenerator2.Value; - Check((Value = '1') or (Value = '2'), ''); + Check((Value = '1') or (Value = '2'), '#A11'); end; { TFixedGeneratorTests } @@ -238,7 +233,7 @@ FMax:= TSingleValue.Create(StrToDate('10.10.2009')); FRangedGen:= TRangedGenerator.Create(FMin, FMax); FRangedGen.Generate; - CheckEquals('13.11.2006', DateToStr(FRangedGen.Value), ''); + CheckEquals('13.11.2006', DateToStr(FRangedGen.Value), '#A12'); end; procedure TRangedGeneratorTests.TestFloat; @@ -251,8 +246,7 @@ FMax:= TSingleValue.Create(1.321); FRangedGen:= TRangedGenerator.Create(FMin, FMax); FRangedGen.Generate; - Check(CompareValue(1.129, FRangedGen.Value, 0.001) = 0, - 'Float value equality error'); + Check(CompareValue(1.129, FRangedGen.Value, 0.001) = 0, '#A13'); end; procedure TRangedGeneratorTests.TestInteger; @@ -265,7 +259,7 @@ FMax:= TSingleValue.Create(10000); FRangedGen:= TRangedGenerator.Create(FMin, FMax); FRangedGen.Generate; - CheckEquals(323, FRangedGen.Value, ''); + CheckEquals(323, FRangedGen.Value, '#A14'); end; procedure TRangedGeneratorTests.TestTime; @@ -277,7 +271,7 @@ FMax:= TSingleValue.Create(StrToTime('00:00')); FRangedGen:= TRangedGenerator.Create(FMin, FMax); FRangedGen.Generate; - CheckEquals('18:36', TimeToStr(FRangedGen.Value)) + CheckEquals('18:36', TimeToStr(FRangedGen.Value), '#A15') end; procedure TRangedGeneratorTests.TestTimeStamp; @@ -290,8 +284,7 @@ FMax:= TSingleValue.Create(StrToDateTime('12.10.2009 10:00')); FRangedGen:= TRangedGenerator.Create(FMin, FMax); FRangedGen.Generate; - CheckEquals('15.11.2006 19:25', - DateTimeToStr(FRangedGen.Value), ''); + CheckEquals('15.11.2006 19:25', DateTimeToStr(FRangedGen.Value), '#A16'); end; initialization Modified: trunk/src/dunit/DG_ValuesTests.pas =================================================================== --- trunk/src/dunit/DG_ValuesTests.pas 2007-01-03 13:50:29 UTC (rev 248) +++ trunk/src/dunit/DG_ValuesTests.pas 2007-01-05 14:54:01 UTC (rev 249) @@ -78,18 +78,15 @@ begin // Int FSingleValue := TSingleValue.Create(30); - CheckEquals(varByte, VarType(FSingleValue.GetValue), - 'Int type check failed'); + CheckEquals(varByte, VarType(FSingleValue.GetValue), '#A01'); FSingleValue.Free; //DateTime FSingleValue := TSingleValue.Create(StrToDate('25.10.1980')); - CheckEquals(varDate, VarType(FSingleValue.GetValue), - 'DateTime type check failed'); + CheckEquals(varDate, VarType(FSingleValue.GetValue), '#A02'); FSingleValue.Free; //String FSingleValue := TSingleValue.Create('t-hex'); - CheckEquals(varString, VarType(FSingleValue.GetValue), - 'String type check failed'); + CheckEquals(varString, VarType(FSingleValue.GetValue), '#A03'); FSingleValue.Free; end; @@ -109,9 +106,9 @@ procedure TFileLinkTests.TestGetValue; begin - CheckEquals('ITEM1', FFileLink.GetValue, ''); - CheckEquals('ITEM2', FFileLink.GetValue, ''); - CheckEquals('ITEM1', FFileLink.GetValue, ''); + CheckEquals('ITEM1', FFileLink.GetValue, '#A04'); + CheckEquals('ITEM2', FFileLink.GetValue, '#A05'); + CheckEquals('ITEM1', FFileLink.GetValue, '#A06'); end; { TFieldLinkTests } @@ -173,9 +170,9 @@ procedure TListLinkTests.TestGetValue; begin - CheckEquals('ITEM1', FListLink.GetValue, ''); - CheckEquals('ITEM2', FListLink.GetValue, ''); - CheckEquals('ITEM1', FListLink.GetValue, ''); + CheckEquals('ITEM1', FListLink.GetValue, '#A07'); + CheckEquals('ITEM2', FListLink.GetValue, '#A08'); + CheckEquals('ITEM1', FListLink.GetValue, '#A09'); end; { TContextLinkTests } @@ -266,31 +263,31 @@ begin // Test strings PatternValue := TPatternValue.Create('ABCD 4'); - CheckEquals('ADAB4', PatternValue.GetValue); + CheckEquals('ADAB4', PatternValue.GetValue, '#A10'); PatternValue.Free; PatternValue := TPatternValue.Create('ABC 4'); - CheckEquals('AAB4', PatternValue.GetValue); + CheckEquals('AAB4', PatternValue.GetValue, '#A11'); PatternValue.Free; // Special turkish lowercase and uppercase chars PatternValue := TPatternValue.Create('\xC7\xD0\xDD\xD6\xDE\xDC\xE7\xF0\xFD\xF6\xFE\xFC 5'); - CheckEquals('\xC7\xDC\xC7\xFE\xC7\xD6\xFC\xDE\xF6\xD6\xFD\xFE5', PatternValue.GetValue); + CheckEquals('\xC7\xDC\xC7\xFE\xC7\xD6\xFC\xDE\xF6\xD6\xFD\xFE5', PatternValue.GetValue, '#A12'); PatternValue.Free; PatternValue := TPatternValue.Create('*/-?=< 5'); - CheckEquals('/*/-/=5', PatternValue.GetValue); + CheckEquals('/*/-/=5', PatternValue.GetValue, '#A13'); PatternValue.Free; // Test numbers // 4 PatternValue := TPatternValue.Create('4 1'); - CheckEquals('41', PatternValue.GetValue); + CheckEquals('41', PatternValue.GetValue, '#A14'); PatternValue.Free; // 0-9 PatternValue := TPatternValue.Create('0123456789 9'); - CheckEquals('82794880119', PatternValue.GetValue); + CheckEquals('82794880119', PatternValue.GetValue, '#A15'); PatternValue.Free; end; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: ibrahim d. <ibr...@gm...> - 2007-01-04 16:25:11
|
RXZldCBmdXJrYW4sIGJpciBrYecgZWtzafBpIGthbGT9IGFtYSBi/Hn8ayBvcmFubGEgdGFtYW1s YW5k/S4KMSkgVmFyaWFibGUg/HJldGVjaSBp52luIGJpciBjb250cm9sbGVyIHlhem1hZP1tLiDH /G5r/CBvbnVuIG5lIGn+ZQp5YXJhZP3w/W79IGhhdP1ybGF5YW1hbf3+dP1rLgoyKSBBbGFu/W4g dmVyaSB0aXBpbmUgZ/ZyZSD8cmV0ZedsZXJpbiBjb21ib2JveCd0YSBmaWx0ZWxlbm1lc2luaQpo ZW78eiB5YXBtYWT9bSBhbWEgZ2VyZWtsaSBhbHR5YXD9ef0gb2x1/nR1cm1heWEg52Fs/f50/W0u CgreaW1kaWxpayBiaXIgaW5jZWxleWVsaW0sIHRhcnT9/mFs/W0sIGdlcmVrbGkgZPx6ZW5sZW1l bGVyaSB5YXBhcv16LgoKMjAwNy8xLzQsIEZ1cmthbiBEdW1hbiA8Y29kZXJsb3JkQGdtYWlsLmNv bT46Cj4gT24gMS8yLzA3LCB0LWhleEB1c2Vycy5zb3VyY2Vmb3JnZS5uZXQgPHQtaGV4QHVzZXJz LnNvdXJjZWZvcmdlLm5ldD4gd3JvdGU6Cj4gPiBSZXZpc2lvbjogMjQ2Cj4gPiAgICAgICAgICAg aHR0cDovL3N2bi5zb3VyY2Vmb3JnZS5uZXQvZGF0YWdlbmVyYXRvci8/cmV2PTI0NiZ2aWV3PXJl dgo+ID4gQXV0aG9yOiAgIHQtaGV4Cj4gPiBEYXRlOiAgICAgMjAwNy0wMS0wMiAwNjo1OToxOCAt MDgwMCAoVHVlLCAwMiBKYW4gMjAwNykKPiA+Cj4gPiBMb2cgTWVzc2FnZToKPiA+IC0tLS0tLS0t LS0tCj4gPiAtZ3VpIGJyYW5jaCdpIGlsZSBiaXJsZXN0aXJkaW0KPiA+IC1idXl1ayBvcmFubGEg dGFtYW1sYW5kaSwgYmlya2FjIGR1emVsdG1lIHlhcGlsYWNhawo+Cj4gRWxpbmUgc2HwbP1rLiBs aWInaSBkZSBtZXJnZSBldHRpbiBnYWxpYmEuIN1uY2VsZW1leWUgYmH+bP15b3J1bS4KPgo+IC0t Cj4gRnVya2FuIER1bWFuCj4gLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0t LS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLQo+IFRha2UgU3VydmV5cy4gRWFybiBD YXNoLiBJbmZsdWVuY2UgdGhlIEZ1dHVyZSBvZiBJVAo+IEpvaW4gU291cmNlRm9yZ2UubmV0J3Mg VGVjaHNheSBwYW5lbCBhbmQgeW91J2xsIGdldCB0aGUgY2hhbmNlIHRvIHNoYXJlIHlvdXIKPiBv cGluaW9ucyBvbiBJVCAmIGJ1c2luZXNzIHRvcGljcyB0aHJvdWdoIGJyaWVmIHN1cnZleXMgLSBh bmQgZWFybiBjYXNoCj4gaHR0cDovL3d3dy50ZWNoc2F5LmNvbS9kZWZhdWx0LnBocD9wYWdlPWpv aW4ucGhwJnA9c291cmNlZm9yZ2UmQ0lEPURFVkRFVgo+IF9fX19fX19fX19fX19fX19fX19fX19f X19fX19fX19fX19fX19fX19fX19fX19fCj4gRGF0YWdlbmVyYXRvci1jb21taXRzIG1haWxpbmcg bGlzdAo+IERhdGFnZW5lcmF0b3ItY29tbWl0c0BsaXN0cy5zb3VyY2Vmb3JnZS5uZXQKPiBodHRw czovL2xpc3RzLnNvdXJjZWZvcmdlLm5ldC9saXN0cy9saXN0aW5mby9kYXRhZ2VuZXJhdG9yLWNv bW1pdHMKPgo= |
From: Furkan D. <cod...@gm...> - 2007-01-04 06:41:38
|
T24gMS8yLzA3LCB0LWhleEB1c2Vycy5zb3VyY2Vmb3JnZS5uZXQgPHQtaGV4QHVzZXJzLnNvdXJj ZWZvcmdlLm5ldD4gd3JvdGU6Cj4gUmV2aXNpb246IDI0Ngo+ICAgICAgICAgICBodHRwOi8vc3Zu LnNvdXJjZWZvcmdlLm5ldC9kYXRhZ2VuZXJhdG9yLz9yZXY9MjQ2JnZpZXc9cmV2Cj4gQXV0aG9y OiAgIHQtaGV4Cj4gRGF0ZTogICAgIDIwMDctMDEtMDIgMDY6NTk6MTggLTA4MDAgKFR1ZSwgMDIg SmFuIDIwMDcpCj4KPiBMb2cgTWVzc2FnZToKPiAtLS0tLS0tLS0tLQo+IC1ndWkgYnJhbmNoJ2kg aWxlIGJpcmxlc3RpcmRpbQo+IC1idXl1ayBvcmFubGEgdGFtYW1sYW5kaSwgYmlya2FjIGR1emVs dG1lIHlhcGlsYWNhawoKRWxpbmUgc2HEn2zEsWsuIGxpYidpIGRlIG1lcmdlIGV0dGluIGdhbGli YS4gxLBuY2VsZW1leWUgYmHFn2zEsXlvcnVtLgoKLS0gCkZ1cmthbiBEdW1hbgo= |
From: <t-...@us...> - 2007-01-03 13:50:31
|
Revision: 248 http://svn.sourceforge.net/datagenerator/?rev=248&view=rev Author: t-hex Date: 2007-01-03 05:50:29 -0800 (Wed, 03 Jan 2007) Log Message: ----------- delphi 2006'nin bozdugu dfm dosyalari Modified Paths: -------------- trunk/src/ui/FormColumnRule.dfm trunk/src/ui/MainForm.dfm Modified: trunk/src/ui/FormColumnRule.dfm =================================================================== --- trunk/src/ui/FormColumnRule.dfm 2007-01-03 13:45:51 UTC (rev 247) +++ trunk/src/ui/FormColumnRule.dfm 2007-01-03 13:50:29 UTC (rev 248) @@ -22,12 +22,10 @@ end inherited btnOK: TButton Top = 326 - ExplicitTop = 326 end inherited btnCancel: TButton Top = 326 Cancel = True - ExplicitTop = 326 end object GroupBox1: TGroupBox Left = 8 @@ -156,8 +154,6 @@ Color = clBtnFace ParentColor = False WordWrap = True - ExplicitTop = 8 - ExplicitHeight = 37 end end object PopupMenu: TPopupMenu Modified: trunk/src/ui/MainForm.dfm =================================================================== --- trunk/src/ui/MainForm.dfm 2007-01-03 13:45:51 UTC (rev 247) +++ trunk/src/ui/MainForm.dfm 2007-01-03 13:50:29 UTC (rev 248) @@ -57,9 +57,7 @@ TreeOptions.SelectionOptions = [toExtendedFocus, toFullRowSelect, toRightClickSelect] TreeOptions.StringOptions = [toSaveCaptions, toShowStaticText, toAutoAcceptEditChange] OnAfterCellPaint = FieldTreeAfterCellPaint - OnCreateEditor = FieldTreeCreateEditor OnDblClick = FieldTreeDblClick - OnEditing = FieldTreeEditing OnGetCellIsEmpty = FieldTreeGetCellIsEmpty OnGetText = FieldTreeGetText OnPaintText = FieldTreePaintText This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <t-...@us...> - 2007-01-03 13:45:53
|
Revision: 247 http://svn.sourceforge.net/datagenerator/?rev=247&view=rev Author: t-hex Date: 2007-01-03 05:45:51 -0800 (Wed, 03 Jan 2007) Log Message: ----------- Modified Paths: -------------- trunk/src/ui/DataGeneratorUI.dpr trunk/src/ui/FormAbout.dfm trunk/src/ui/FormColumnRule.dfm trunk/src/ui/MainForm.dfm Modified: trunk/src/ui/DataGeneratorUI.dpr =================================================================== --- trunk/src/ui/DataGeneratorUI.dpr 2007-01-02 14:59:18 UTC (rev 246) +++ trunk/src/ui/DataGeneratorUI.dpr 2007-01-03 13:45:51 UTC (rev 247) @@ -39,7 +39,8 @@ SequenceRuleController in 'controllers\SequenceRuleController.pas', SQLRuleController in 'controllers\SQLRuleController.pas', FixedRuleController in 'controllers\FixedRuleController.pas', - CompositeRuleController in 'controllers\CompositeRuleController.pas'; + CompositeRuleController in 'controllers\CompositeRuleController.pas', + VTEditLinks in 'VTEditLinks.pas'; {$R *.res} {$R dgver.res} // required Modified: trunk/src/ui/FormAbout.dfm =================================================================== --- trunk/src/ui/FormAbout.dfm 2007-01-02 14:59:18 UTC (rev 246) +++ trunk/src/ui/FormAbout.dfm 2007-01-03 13:45:51 UTC (rev 247) @@ -32,7 +32,7 @@ Top = 8 Width = 289 Height = 169 - ActivePage = TabSheet1 + ActivePage = TabSheet4 TabOrder = 1 object TabSheet1: TTabSheet Caption = 'General' @@ -88,7 +88,7 @@ object Label4: TLabel Left = 72 Top = 48 - Width = 17 + Width = 24 Height = 13 Caption = '0.35' Font.Charset = DEFAULT_CHARSET @@ -147,7 +147,8 @@ 'SourceForge (<http://www.sourceforge.net>)' 'Zeoslib (<http://www.sf.net/projects/zeoslib>)' 'VirtualTreeView (<http://www.soft-gems.net>)' - 'PascalScript (<http://www.remobjects.net>)') + 'PascalScript (<http://www.remobjects.net>)' + 'dxgettext (<http://dybdahl.dk/dxgettext/>)') TabOrder = 0 end end Modified: trunk/src/ui/FormColumnRule.dfm =================================================================== --- trunk/src/ui/FormColumnRule.dfm 2007-01-02 14:59:18 UTC (rev 246) +++ trunk/src/ui/FormColumnRule.dfm 2007-01-03 13:45:51 UTC (rev 247) @@ -7,15 +7,11 @@ ClientWidth = 387 OldCreateOrder = True OnDestroy = FormDestroy - ExplicitWidth = 393 - ExplicitHeight = 386 PixelsPerInch = 96 TextHeight = 13 inherited Bevel1: TBevel Top = 317 Width = 370 - ExplicitTop = 317 - ExplicitWidth = 370 end object Label1: TLabel [1] Left = 8 Modified: trunk/src/ui/MainForm.dfm =================================================================== --- trunk/src/ui/MainForm.dfm 2007-01-02 14:59:18 UTC (rev 246) +++ trunk/src/ui/MainForm.dfm 2007-01-03 13:45:51 UTC (rev 247) @@ -1,9 +1,9 @@ object frmMain: TfrmMain Left = 257 Top = 155 - Width = 697 - Height = 480 Caption = 'Data Generator' + ClientHeight = 426 + ClientWidth = 689 Color = clBtnFace Font.Charset = TURKISH_CHARSET Font.Color = clWindowText @@ -19,9 +19,9 @@ TextHeight = 13 object FieldTree: TVirtualStringTree Left = 0 - Top = 27 + Top = 25 Width = 689 - Height = 380 + Height = 382 Align = alClient CheckImageKind = ckXP Colors.FocusedSelectionColor = clSkyBlue @@ -52,13 +52,14 @@ PopupMenu = PopupMenu ShowHint = True TabOrder = 0 - TreeOptions.AutoOptions = [toAutoDropExpand, toAutoScrollOnExpand, toAutoSpanColumns, toAutoTristateTracking, toAutoDeleteMovedNodes] - TreeOptions.MiscOptions = [toAcceptOLEDrop, toCheckSupport, toFullRepaintOnResize, toGridExtensions, toInitOnSave, toReportMode, toToggleOnDblClick, toWheelPanning] + TreeOptions.MiscOptions = [toAcceptOLEDrop, toCheckSupport, toEditable, toFullRepaintOnResize, toGridExtensions, toInitOnSave, toReportMode, toToggleOnDblClick, toWheelPanning] TreeOptions.PaintOptions = [toShowButtons, toShowDropmark, toShowHorzGridLines, toShowRoot, toShowTreeLines, toShowVertGridLines, toThemeAware, toUseBlendedImages, toFullVertGridLines] TreeOptions.SelectionOptions = [toExtendedFocus, toFullRowSelect, toRightClickSelect] TreeOptions.StringOptions = [toSaveCaptions, toShowStaticText, toAutoAcceptEditChange] OnAfterCellPaint = FieldTreeAfterCellPaint + OnCreateEditor = FieldTreeCreateEditor OnDblClick = FieldTreeDblClick + OnEditing = FieldTreeEditing OnGetCellIsEmpty = FieldTreeGetCellIsEmpty OnGetText = FieldTreeGetText OnPaintText = FieldTreePaintText @@ -100,12 +101,11 @@ Left = 0 Top = 0 Width = 689 - Height = 27 + Height = 25 AutoSize = True ButtonHeight = 25 ButtonWidth = 37 Caption = 'ToolBar' - Flat = True HotImages = imlHotImages Images = imlColdImages ParentShowHint = False This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <t-...@us...> - 2007-01-02 14:59:23
|
Revision: 246 http://svn.sourceforge.net/datagenerator/?rev=246&view=rev Author: t-hex Date: 2007-01-02 06:59:18 -0800 (Tue, 02 Jan 2007) Log Message: ----------- -gui branch'i ile birlestirdim -buyuk oranla tamamlandi, birkac duzeltme yapilacak Modified Paths: -------------- trunk/src/ui/DataGeneratorUI.dpr trunk/src/ui/DataGeneratorUI.res trunk/src/ui/FormColumnRule.dfm trunk/src/ui/FormColumnRule.pas trunk/src/ui/MainForm.pas Added Paths: ----------- trunk/src/ui/controllers/ trunk/src/ui/controllers/AutoIncRuleController.pas trunk/src/ui/controllers/CompositeRuleController.pas trunk/src/ui/controllers/CopyRuleController.pas trunk/src/ui/controllers/FixedRuleController.pas trunk/src/ui/controllers/PascalScriptRuleController.pas trunk/src/ui/controllers/PatternRuleController.pas trunk/src/ui/controllers/RangeRuleController.pas trunk/src/ui/controllers/RuleController.pas trunk/src/ui/controllers/SQLRuleController.pas trunk/src/ui/controllers/SequenceRuleController.pas Removed Paths: ------------- trunk/src/ui/controllers/AutoIncRuleController.pas trunk/src/ui/controllers/CopyRuleController.pas trunk/src/ui/controllers/FixedRuleController.pas trunk/src/ui/controllers/PascalScriptRuleController.pas trunk/src/ui/controllers/PatternRuleController.pas trunk/src/ui/controllers/RangeRuleController.pas trunk/src/ui/controllers/RuleController.pas trunk/src/ui/controllers/SQLRuleController.pas trunk/src/ui/controllers/SequenceRuleController.pas Modified: trunk/src/ui/DataGeneratorUI.dpr =================================================================== --- trunk/src/ui/DataGeneratorUI.dpr 2007-01-02 13:31:32 UTC (rev 245) +++ trunk/src/ui/DataGeneratorUI.dpr 2007-01-02 14:59:18 UTC (rev 246) @@ -29,7 +29,17 @@ DG_Builders in '..\lib\DG_Builders.pas', UITools in 'UITools.pas', gnugettext in '..\..\3rdParty\GnuGettext\gnugettext.pas', - DG_Types in '..\lib\DG_Types.pas'; + DG_Types in '..\lib\DG_Types.pas', + AutoIncRuleController in 'controllers\AutoIncRuleController.pas', + CopyRuleController in 'controllers\CopyRuleController.pas', + PascalScriptRuleController in 'controllers\PascalScriptRuleController.pas', + PatternRuleController in 'controllers\PatternRuleController.pas', + RangeRuleController in 'controllers\RangeRuleController.pas', + RuleController in 'controllers\RuleController.pas', + SequenceRuleController in 'controllers\SequenceRuleController.pas', + SQLRuleController in 'controllers\SQLRuleController.pas', + FixedRuleController in 'controllers\FixedRuleController.pas', + CompositeRuleController in 'controllers\CompositeRuleController.pas'; {$R *.res} {$R dgver.res} // required Modified: trunk/src/ui/DataGeneratorUI.res =================================================================== (Binary files differ) Modified: trunk/src/ui/FormColumnRule.dfm =================================================================== --- trunk/src/ui/FormColumnRule.dfm 2007-01-02 13:31:32 UTC (rev 245) +++ trunk/src/ui/FormColumnRule.dfm 2007-01-02 14:59:18 UTC (rev 246) @@ -6,33 +6,32 @@ ClientHeight = 362 ClientWidth = 387 OldCreateOrder = True + OnDestroy = FormDestroy + ExplicitWidth = 393 + ExplicitHeight = 386 PixelsPerInch = 96 TextHeight = 13 inherited Bevel1: TBevel Top = 317 Width = 370 + ExplicitTop = 317 + ExplicitWidth = 370 end object Label1: TLabel [1] - Left = 16 - Top = 56 + Left = 8 + Top = 55 Width = 49 Height = 13 Caption = 'Generator' end - object lblNullPercentage: TLabel [2] - Left = 16 - Top = 80 - Width = 75 - Height = 13 - Caption = 'Null Percentage' - end inherited btnOK: TButton Top = 326 - OnClick = btnOKClick + ExplicitTop = 326 end inherited btnCancel: TButton Top = 326 Cancel = True + ExplicitTop = 326 end object GroupBox1: TGroupBox Left = 8 @@ -72,9 +71,9 @@ end object ParamTreeList: TVirtualStringTree Left = 8 - Top = 104 + Top = 79 Width = 369 - Height = 153 + Height = 162 ButtonStyle = bsTriangle DefaultNodeHeight = 21 EditDelay = 100 @@ -104,7 +103,6 @@ OnGetText = ParamTreeListGetText OnGetHint = ParamTreeListGetHint OnGetNodeDataSize = ParamTreeListGetNodeDataSize - OnInitNode = ParamTreeListInitNode OnKeyAction = ParamTreeListKeyAction OnKeyUp = ParamTreeListKeyUp OnNewText = ParamTreeListNewText @@ -124,9 +122,9 @@ end> end object cbGeneratorType: TComboBox - Left = 120 + Left = 63 Top = 52 - Width = 257 + Width = 314 Height = 21 Style = csDropDownList DropDownCount = 16 @@ -145,9 +143,9 @@ end object Panel1: TPanel Left = 8 - Top = 264 + Top = 247 Width = 369 - Height = 47 + Height = 64 Alignment = taLeftJustify Anchors = [akLeft, akTop, akRight, akBottom] BevelInner = bvLowered @@ -156,30 +154,16 @@ Left = 2 Top = 2 Width = 365 - Height = 43 + Height = 60 Align = alClient AutoSize = False - Color = clCream + Color = clBtnFace ParentColor = False + WordWrap = True + ExplicitTop = 8 + ExplicitHeight = 37 end end - object edtNullPercentage: TEdit - Left = 120 - Top = 75 - Width = 49 - Height = 21 - TabOrder = 6 - Text = '0' - OnKeyPress = NumberEditKeyPress - end - object udsNullPercentage: TUpDown - Left = 169 - Top = 75 - Width = 16 - Height = 21 - Associate = edtNullPercentage - TabOrder = 7 - end object PopupMenu: TPopupMenu OnChange = PopupMenuChange Left = 288 Modified: trunk/src/ui/FormColumnRule.pas =================================================================== --- trunk/src/ui/FormColumnRule.pas 2007-01-02 13:31:32 UTC (rev 245) +++ trunk/src/ui/FormColumnRule.pas 2007-01-02 14:59:18 UTC (rev 246) @@ -5,12 +5,14 @@ uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, FormRule, StdCtrls, ExtCtrls, ComCtrls,DG_Core, VirtualTrees, - Menus,DG_Configuration, Spin, DG_Database, DG_Types ; + Menus,DG_Configuration, DG_Database, DG_Types, RuleController ; type - TListType = (ltNone, ltReference, ltSequence); - TActionType = (atNormal, atFile, atScript, atSQL, atList); - + PNodeData = ^TNodeData; + TNodeData = record + key : string; + end; + TfrmColumnRule = class(TfrmRule) GroupBox1: TGroupBox; lblFieldName: TLabel; @@ -27,11 +29,6 @@ Panel1: TPanel; lblInfo: TLabel; miList: TMenuItem; - lblNullPercentage: TLabel; - edtNullPercentage: TEdit; - udsNullPercentage: TUpDown; - procedure ParamTreeListInitNode(Sender: TBaseVirtualTree; ParentNode, - Node: PVirtualNode; var InitialStates: TVirtualNodeInitStates); procedure ParamTreeListGetText(Sender: TBaseVirtualTree; Node: PVirtualNode; Column: TColumnIndex; TextType: TVSTTextType; var CellText: WideString); @@ -46,11 +43,9 @@ Node: PVirtualNode; Column: TColumnIndex; NewText: WideString); procedure ParamTreeListKeyUp(Sender: TObject; var Key: Word; Shift: TShiftState); - procedure FormClose(Sender: TObject; var Action: TCloseAction); procedure cbGeneratorTypeChange(Sender: TObject); procedure ParamTreeListChange(Sender: TBaseVirtualTree; Node: PVirtualNode); - procedure btnOKClick(Sender: TObject); procedure ParamTreeListDblClick(Sender: TObject); procedure ParamTreeListKeyAction(Sender: TBaseVirtualTree; var CharCode: Word; var Shift: TShiftState; var DoDefault: Boolean); @@ -67,27 +62,24 @@ Node: PVirtualNode; Column: TColumnIndex; out EditLink: IVTEditLink); procedure NumberEditKeyPress(Sender: TObject; var Key: Char); procedure FormCreate(Sender: TObject); + procedure FormDestroy(Sender: TObject); private - FColumnRule : TDGColumnRule; + FRuleController : TRuleController; FCheckedNode : PVirtualNode; - function GetColumnRule: TDGColumnRule; - procedure SetColumnRule(const Value: TDGColumnRule); - procedure AddParamNode(Tip : String; Value: String;Info :String =''; AListType:TListType = ltNone); - procedure AddStrategyParameters(const AStrategy: TGeneratorType); + FColumnName: String; + procedure SetRuleController(const Value: TRuleController); + procedure SetColumnName(const Value: String); procedure FillGeneratorCombo; + procedure FillConnectionsProposalList(var EditLink: IVTEditLink); + procedure FillSequencesProposalList(var EditLink: IVTEditLink; const connRef: string); public - property ColumnRule : TDGColumnRule read GetColumnRule write SetColumnRule; - procedure PerformPopupAction(ActionType : TActionType; Node: PVirtualNode); + procedure FreeRuleController; + procedure UpdateView; + function GetColumnRule: TDGColumnRule; + property RuleController: TRuleController read FRuleController write SetRuleController; + property ColumnName: String read FColumnName write SetColumnName; end; - - PParamData = ^TParamData; - TParamData = record - Tip : String; - Value: String; - Info : String; - ListType: TListType; - end; - + var frmColumnRule: TfrmColumnRule; @@ -100,51 +92,18 @@ { TfrmColumnRule } -function TfrmColumnRule.GetColumnRule: TDGColumnRule; -begin - Result := FColumnRule; -end; - -procedure TfrmColumnRule.SetColumnRule(const Value: TDGColumnRule); -begin - FColumnRule := Value; - lblFieldName.Caption := FColumnRule.ColumnName; - ParamTreeList.Clear; - //Set strategy - { TODO : This should not be locale spesific } - cbGeneratorType.ItemIndex := - cbGeneratorType.Items.IndexOf(GeneratorLocalName(FColumnRule.Strategy)); - //Fire combobox change event - cbGeneratorTypeChange(Self); - - udsNullPercentage.Position := FColumnRule.NullPercentage; -end; - -procedure TfrmColumnRule.ParamTreeListInitNode(Sender: TBaseVirtualTree; - ParentNode, Node: PVirtualNode; - var InitialStates: TVirtualNodeInitStates); -var - ParamData : PParamData; -begin - inherited; - ParamData := Sender.GetNodeData(Node); - if ParamData.ListType = ltNone then - Node.CheckType := ctButton; -end; - procedure TfrmColumnRule.ParamTreeListGetText(Sender: TBaseVirtualTree; Node: PVirtualNode; Column: TColumnIndex; TextType: TVSTTextType; var CellText: WideString); var - ParamData : PParamData; + ParamData: PNodeData; begin inherited; ParamData := Sender.GetNodeData(Node); - Celltext := ''; if TextType = ttNormal then case Column of - 0 : Celltext := ParamData.Info; - 1 : Celltext := ParamData.Value; + 0 : Celltext := FRuleController.GetParamViewData(Node.Index).DisplayLabel; + 1 : Celltext := FRuleController.GetParameterValue(ParamData.key); end; end; @@ -170,35 +129,60 @@ FCheckedNode := nil; end; +procedure TfrmColumnRule.SetColumnName(const Value: String); +begin + FColumnName := Value; + lblFieldName.Caption := FColumnName; +end; + +procedure TfrmColumnRule.SetRuleController(const Value: TRuleController); +begin + FRuleController := Value; + UpdateView; +end; + +procedure TfrmColumnRule.UpdateView; +var + i: integer; + Node: PVirtualNode; + NodeData : PNodeData; +begin + cbGeneratorType.ItemIndex := Ord(FRuleController.GetColumnRule.Strategy); + ParamTreeList.Clear; + for i := 0 to FRuleController.GetParameterCount-1 do + with FRuleController do begin + Node := ParamTreeList.AddChild(nil); + NodeData := ParamTreeList.GetNodeData(Node); + NodeData.key := FRuleController.GetParamViewData(i).key; + end; +end; + procedure TfrmColumnRule.MenuItemClicked(Sender: TObject); var MenuIndex : Integer; begin inherited; - if FCheckedNode = nil then exit; - MenuIndex := TMenuItem(Sender).MenuIndex; - PerformPopupAction(TActionType(MenuIndex),FCheckedNode); - FCheckedNode := nil; +// if FCheckedNode = nil then exit; +// MenuIndex := TMenuItem(Sender).MenuIndex; +// PerformPopupAction(FCheckedNode); +// FCheckedNode := nil; end; procedure TfrmColumnRule.ParamTreeListGetNodeDataSize( Sender: TBaseVirtualTree; var NodeDataSize: Integer); begin inherited; - NodeDataSize := Sizeof(TParamData); + NodeDataSize := Sizeof(TNodeData); end; procedure TfrmColumnRule.ParamTreeListNewText(Sender: TBaseVirtualTree; Node: PVirtualNode; Column: TColumnIndex; NewText: WideString); var - ParamData : PParamData; + ParamData: PNodeData; begin inherited; - ParamData := Sender.GetNodeData(Node); - case Column of - 0: ParamData.Tip := NewText; - 1: ParamData.Value := NewText; - end; + ParamData := sender.GetNodeData(Node); + FRuleController.SetParameterValue(ParamData.key,Newtext); end; procedure TfrmColumnRule.ParamTreeListKeyUp(Sender: TObject; var Key: Word; @@ -216,152 +200,80 @@ end; end; -procedure TfrmColumnRule.FormClose(Sender: TObject; - var Action: TCloseAction); -begin - Action := caFree; -end; - procedure TfrmColumnRule.cbGeneratorTypeChange(Sender: TObject); begin inherited; - if ParamTreeList.RootNodeCount > 0 then - if MessageDlg(_('Remove current parameters?'),mtConfirmation,mbYesNoCancel,0) =mrYes then begin - FColumnRule.Params.Clear; - ParamTreeList.Clear; - end; - FColumnRule.Strategy := TGeneratorType(cbGeneratorType.ItemIndex); - AddStrategyParameters(FColumnRule.Strategy); + if assigned(FRuleController) then + FreeRuleController; + RuleController := TRuleController.CreateForColumn(ColumnName, TGeneratorType(cbGeneratorType.ItemIndex)); end; -procedure TfrmColumnRule.AddParamNode(Tip, Value: String; Info: string = ''; AListType: TListType = ltNone); -var - Node : PVirtualNode; - ParamData : PParamData; -begin - Node := ParamTreeList.AddChild(nil); - ParamData := ParamTreeList.GetNodeData(Node); - if FColumnRule.Params.Count > Node.Index then begin - ParamData.Tip := FColumnRule.Params[Node.Index].Type_; - ParamData.Value := FColumnRule.Params[Node.Index].Value; - end else begin - ParamData.Tip := Tip; - ParamData.Value := Value; - end; - ParamData.Info := Info; - ParamData.ListType := AListType; -end; - procedure TfrmColumnRule.ParamTreeListChange(Sender: TBaseVirtualTree; Node: PVirtualNode); -var - ParamData : PParamData; begin inherited; if Node = nil then exit; - ParamData := Sender.GetNodeData(Node); - lblInfo.Caption := ParamData.Info; + lblInfo.Caption := FRuleController.GetParamViewData(Node.Index).description; end; -procedure TfrmColumnRule.btnOKClick(Sender: TObject); -var - Node : PVirtualNode; - ParamData : PParamData; -begin - inherited; - FColumnRule.Params.Clear; - Node := ParamTreeList.RootNode.FirstChild; - while Node <> nil do begin - ParamData := ParamTreeList.GetNodeData(Node); - FColumnRule.NewParam(ParamData.Tip, ParamData.Value); - Node := Node.NextSibling; - end; - FColumnRule.Strategy := TGeneratorType(cbGeneratorType.ItemIndex); - FColumnRule.NullPercentage := udsNullPercentage.Position; -end; - procedure TfrmColumnRule.ParamTreeListDblClick(Sender: TObject); var Node: PVirtualNode; - NodeParamData : PParamData; + NodeData : PNodeData; + EditorType: TEditorType; begin inherited; if ParamTreeList.FocusedColumn <> 1 then exit; - Node := ParamTreeList.FocusedNode; if Node = nil then exit; - NodeParamData := ParamTreeList.GetNodeData(Node); - { TODO 1 -ot-hex : Somehow the following code should be more simple } - if NodeParamData.Tip = 'file' then PerformPopupAction(atFile,Node); - if NodeParamData.Tip = 'script' then PerformPopupAction(atScript,Node); - if NodeParamData.Tip = 'sql' then PerformPopupAction(atSQL,Node); - if NodeParamData.Tip = 'list' then PerformPopupAction(atList,Node); -end; - -procedure TfrmColumnRule.ParamTreeListKeyAction(Sender: TBaseVirtualTree; - var CharCode: Word; var Shift: TShiftState; var DoDefault: Boolean); -begin - inherited; - if CharCode = VK_RETURN then begin - Sender.EditNode(Sender.FocusedNode,Sender.FocusedColumn); - end; -end; - -procedure TfrmColumnRule.PerformPopupAction(ActionType: TActionType; - Node: PVirtualNode); -var - ParamData : PParamData; -begin - { DONE : FIXME: Paramdata.tip sometimes gets wrong type, not selected. } - ParamData := ParamTreeList.GetNodeData(Node); - case ActionType of - atNormal: begin - // ParamData.Tip := ''; - ParamTreeList.EditNode(FCheckedNode, 1); - end; - atFile : begin - ParamOpenDialog.FileName := ParamData.Value; + NodeData := ParamTreeList.GetNodeData(Node); + EditorType := FRuleController.GetParamViewData(Node.Index).EditorType; + case EditorType of + edtNone: ParamTreeList.EditNode(FCheckedNode, 1); + edtFile: begin + ParamOpenDialog.FileName := FRuleController.GetParameterValue(NodeData.key); if ParamOpenDialog.Execute then - begin - ParamData.Tip := 'file'; - ParamData.Value := ParamOpenDialog.FileName; - end; + FRuleController.SetParameterValue(NodeData.key,ParamOpenDialog.FileName); end; - atScript, atSQL, - atList : begin + edtSQL,edtScript,edtList: + begin Application.CreateForm(TfrmEditor, frmEditor); try - frmEditor.Text := ParamData.Value; - case ActionType of - atScript: frmEditor.TextType := ttPascalScript; - atSQL: frmEditor.TextType := ttSQL; - atList: frmEditor.TextType := ttList; + frmEditor.Text := FRuleController.GetParameterValue(NodeData.key); + case EditorType of + edtScript: frmEditor.TextType := ttPascalScript; + edtSQL: frmEditor.TextType := ttSQL; + edtList: frmEditor.TextType := ttList; end; if frmEditor.ShowModal = mrOk then - begin - if ActionType = atScript then ParamData.Tip := 'script'; - if ActionType = atSQL then ParamData.Tip := 'sql'; - if ActionType = atList then ParamData.Tip := 'list'; - ParamData.Value := frmEditor.Text; - end; + FRuleController.SetParameterValue(NodeData.key,frmEditor.Text); finally frmEditor.Free; end; end; - end; + end; //case ParamTreeList.Refresh; end; +procedure TfrmColumnRule.ParamTreeListKeyAction(Sender: TBaseVirtualTree; + var CharCode: Word; var Shift: TShiftState; var DoDefault: Boolean); +begin + inherited; + if CharCode = VK_RETURN then begin + Sender.EditNode(Sender.FocusedNode,Sender.FocusedColumn); + end; +end; + procedure TfrmColumnRule.ParamTreeListGetHint(Sender: TBaseVirtualTree; Node: PVirtualNode; Column: TColumnIndex; var LineBreakStyle: TVTTooltipLineBreakStyle; var HintText: WideString); var - ParamNodeData : PParamData; + ParamData: PNodeData; begin inherited; if Column <> 1 then exit; - ParamNodeData := Sender.GetNodeData(Node); - HintText := ParamNodeData.Value; + ParamData := sender.GetNodeData(Node); + HintText := FRuleController.GetParameterValue(ParamData.key); end; procedure TfrmColumnRule.ParamTreeListEditing(Sender: TBaseVirtualTree; @@ -379,92 +291,78 @@ Allowed := NewColumn = 1; end; -procedure TfrmColumnRule.AddStrategyParameters(const AStrategy: TGeneratorType); +procedure TfrmColumnRule.ParamTreeListCreateEditor( + Sender: TBaseVirtualTree; Node: PVirtualNode; Column: TColumnIndex; + out EditLink: IVTEditLink); var - I : Integer; - Node: PVirtualNode; - ParamData: PParamData; + ParamData : PNodeData; + ProposalLists: TProposalLists; + connRef: String; begin - if ParamTreeList.RootNodeCount <> 0 then exit; + inherited; + ProposalLists := FRuleController.GetParamViewData(Node.Index).ProposalLists; + if plConnections in ProposalLists then + FillConnectionsProposalList(EditLink); - case AStrategy of - gtAutoInc: begin - AddParamNode('', '0', _('Minimum value')); - AddParamNode('', '1', _('Increment value')); - end; - gtRange: begin - AddParamNode('', '0', _('Minimum value')); - AddParamNode('', '', _('Maximum value')); - end; - gtSQL: begin - AddParamNode('dbref', '', _('Database Reference'), ltReference); - AddParamNode('sql', '', _('SQL')); - end; - gtComposite: AddParamNode('file', '', _('File')); - gtScript: AddParamNode('script', '', _('Script')); - gtFixed: AddParamNode('', '', _('A value')); - gtCopy: AddParamNode('context', '', _('Column Name')); - gtSequence: begin - AddParamNode('dbref', '', _('Database Reference'), ltReference); - AddParamNode('sequence', '', _('Sequence Name'), ltSequence); - AddParamNode('', '', _('Sequence Step Size')); - end; - gtPattern : AddParamNode('Pattern', '', _('String Pattern')); - gtVariable: AddParamNode('', '', _('A value')); + if plSequences in ProposalLists then begin + // Previous node gives the connection reference + ParamData := Sender.GetNodeData(Node.PrevSibling); + connRef := FRuleController.GetParameterValue(paramdata.key); + FillSequencesProposalList(EditLink,connRef); end; - // Create nodes for the remainin parameters in the columnrule - if ParamTreeList.RootNodeCount < FColumnRule.Params.Count then - for i := ParamTreeList.RootNodeCount to FColumnRule.Params.Count-1 do begin - Node := ParamTreeList.AddChild(nil); - ParamData := ParamTreeList.GetNodeData(Node); - ParamData.Tip := FColumnRule.Params[I].Type_; - ParamData.Value := FColumnRule.Params[I].Value; - end; - ParamTreeList.Refresh; + if not assigned(EditLink) then + EditLink := TStringEditLink.Create; end; -procedure TfrmColumnRule.ParamTreeListCreateEditor( - Sender: TBaseVirtualTree; Node: PVirtualNode; Column: TColumnIndex; - out EditLink: IVTEditLink); -var - ParamData : PParamData; - Items : TStringList; - ConnProp : TDGConnectionProperty; - tmpConnection : TZConnection; - I : Integer; - SequenceRS : IZResultSet; +procedure TfrmColumnRule.NumberEditKeyPress(Sender: TObject; + var Key: Char); begin inherited; - ParamData := Sender.GetNodeData(Node); - if ParamData.ListType = ltReference then - begin - Items := TStringList.Create; - try - for i := 0 to frmMain.Configuration.ConnectionProperties.Count - 1 do - begin - ConnProp := TDGConnectionProperty(frmMain.Configuration.ConnectionProperties[I]); - Items.Add(ConnProp.Ref); - end; - EditLink := TComboBoxEditLink.Create(Items); - finally - Items.Free; - end; - end; + ForceToNumber(Key); +end; - if ParamData.ListType = ltSequence then +procedure TfrmColumnRule.FormCreate(Sender: TObject); +begin + inherited; + FillGeneratorCombo; +end; + +procedure TfrmColumnRule.FormDestroy(Sender: TObject); +begin + inherited; + FreeRuleController; +end; + +procedure TfrmColumnRule.FreeRuleController; +begin + if assigned(FRuleController) then + FRuleController.Free; +end; + +function TfrmColumnRule.GetColumnRule: TDGColumnRule; +begin + Result := nil; + if assigned(FRuleController) then + Result := FRuleController.GetColumnRule; +end; + +procedure TfrmColumnRule.FillSequencesProposalList(var EditLink: IVTEditLink; const connRef: string); +var + ConnProp: TDGConnectionProperty; + tmpConnection: TZConnection; + SequenceRS: IZResultSet; + Items: TStringList; +begin begin - // Previous node gives the connection reference - ParamData := Sender.GetNodeData(Node.PrevSibling); - ConnProp := frmMain.Configuration.FindConnectionProperty(ParamData.Value); + ConnProp := frmMain.Configuration.FindConnectionProperty(connRef); if Assigned(ConnProp) then begin //create connection tmpConnection := CreateConnection(ConnProp); try tmpConnection.Connect; - //get sequence list - SequenceRS:=tmpConnection.DbcConnection.GetMetadata.GetSequences('','',''); + SequenceRS := tmpConnection.DbcConnection.GetMetadata.GetSequences('', '', ''); Items := TStringList.Create; try while SequenceRS.Next do @@ -479,23 +377,29 @@ end; end; end; - if not assigned(EditLink) then - EditLink := TStringEditLink.Create; end; -procedure TfrmColumnRule.NumberEditKeyPress(Sender: TObject; - var Key: Char); +procedure TfrmColumnRule.FillConnectionsProposalList(var EditLink: IVTEditLink); +var + Items: TStringList; + I: Integer; + ConnProp: TDGConnectionProperty; begin - inherited; - ForceToNumber(Key); + begin + Items := TStringList.Create; + try + for i := 0 to frmMain.Configuration.ConnectionProperties.Count - 1 do + begin + ConnProp := TDGConnectionProperty(frmMain.Configuration.ConnectionProperties[I]); + Items.Add(ConnProp.Ref); + end; + EditLink := TComboBoxEditLink.Create(Items); + finally + Items.Free; + end; + end; end; -procedure TfrmColumnRule.FormCreate(Sender: TObject); -begin - inherited; - FillGeneratorCombo; -end; - procedure TfrmColumnRule.FillGeneratorCombo; var I: Integer; Modified: trunk/src/ui/MainForm.pas =================================================================== --- trunk/src/ui/MainForm.pas 2007-01-02 13:31:32 UTC (rev 245) +++ trunk/src/ui/MainForm.pas 2007-01-02 14:59:18 UTC (rev 246) @@ -171,7 +171,7 @@ implementation uses FormColumnRule, FormTableRule, FormConnectionProperties, FormProgress, - gnugettext, FormSettings, uSettings, DG_Generators, DG_Types; + gnugettext, FormSettings, uSettings, DG_Generators, DG_Types, RuleController; {$R *.dfm} @@ -410,16 +410,13 @@ Application.CreateForm(TfrmColumnRule, frmColumnRule); try - if not Assigned(ColumnRule) then - begin - ColumnRule := TDGColumnRule.Create(ColumnName); - NewColumnRule:= True; - end; try - frmColumnRule.ColumnRule := ColumnRule; - frmColumnRule.Caption := Format(_('Field : %s'), [ColumnName]); - frmColumnRule.lblDataType.Caption := ColumnType; - ModalValue:= frmColumnRule.ShowModal; + if assigned(ColumnRule) then + frmColumnRule.RuleController := TRuleController.CreateForRule(ColumnRule); + frmColumnRule.ColumnName := ColumnName; + + ModalValue := frmColumnRule.ShowModal; + ColumnRule := frmColumnRule.GetColumnRule; if ModalValue = mrOK then begin if not Assigned(TableRule) then @@ -443,13 +440,10 @@ procedure TfrmMain.FieldTreeDblClick(Sender : TObject); var Node : PVirtualNode; - NodeData : PNodeData; begin Node := FieldTree.FocusedNode; if not Assigned(Node) then Exit; - NodeData := FieldTree.GetNodeData(Node); - case FieldTree.GetNodeLevel(Node) of // Connection 0 : EditConnectionProperties(Node); Copied: trunk/src/ui/controllers (from rev 245, branches/gui/src/ui/controllers) Deleted: trunk/src/ui/controllers/AutoIncRuleController.pas =================================================================== --- branches/gui/src/ui/controllers/AutoIncRuleController.pas 2007-01-02 13:31:32 UTC (rev 245) +++ trunk/src/ui/controllers/AutoIncRuleController.pas 2007-01-02 14:59:18 UTC (rev 246) @@ -1,51 +0,0 @@ -unit AutoIncRuleController; - -interface -uses Classes, DG_Core, RuleController; -type - - TAutoIncRuleController = class(TColumnRuleController) - protected - procedure CreateColumnRule(const columnName: string); override; - public - procedure InitViewData; override; - function IsSupportedDataType(const dataType: TDataType): Boolean; override; - end; - -implementation -uses gnugettext, DG_Database, DG_Types; -{ TAutoIncRuleController } - -procedure TAutoIncRuleController.CreateColumnRule(const columnName: string); -begin - inherited; - FColumnRule := TDGColumnRule.Create(columnName); - FColumnRule.Strategy := gtAutoInc; - FColumnRule.NewParam('start','0'); - FColumnRule.NewParam('step','1'); -end; - -procedure TAutoIncRuleController.InitViewData; -begin - inherited; - with AddRuleParamViewData do begin - key := 'start'; - DisplayLabel:= _('Start'); - Description := _('Enter the starting value'); - ProposalLists := []; - end; - with AddRuleParamViewData do begin - key := 'step'; - DisplayLabel:= _('Step'); - Description := _('Enter the increment amount'); - ProposalLists := []; - end; -end; - -function TAutoIncRuleController.IsSupportedDataType( - const dataType: TDataType): Boolean; -begin - Result := dataType in [dtString,dtInteger,dtFloat,dtDate,dtTime]; -end; - -end. Copied: trunk/src/ui/controllers/AutoIncRuleController.pas (from rev 245, branches/gui/src/ui/controllers/AutoIncRuleController.pas) =================================================================== --- trunk/src/ui/controllers/AutoIncRuleController.pas (rev 0) +++ trunk/src/ui/controllers/AutoIncRuleController.pas 2007-01-02 14:59:18 UTC (rev 246) @@ -0,0 +1,51 @@ +unit AutoIncRuleController; + +interface +uses Classes, DG_Core, RuleController; +type + + TAutoIncRuleController = class(TColumnRuleController) + protected + procedure CreateColumnRule(const columnName: string); override; + public + procedure InitViewData; override; + function IsSupportedDataType(const dataType: TDataType): Boolean; override; + end; + +implementation +uses gnugettext, DG_Database, DG_Types; +{ TAutoIncRuleController } + +procedure TAutoIncRuleController.CreateColumnRule(const columnName: string); +begin + inherited; + FColumnRule := TDGColumnRule.Create(columnName); + FColumnRule.Strategy := gtAutoInc; + FColumnRule.NewParam('start','0'); + FColumnRule.NewParam('step','1'); +end; + +procedure TAutoIncRuleController.InitViewData; +begin + inherited; + with AddRuleParamViewData do begin + key := 'start'; + DisplayLabel:= _('Start'); + Description := _('Enter the starting value'); + ProposalLists := []; + end; + with AddRuleParamViewData do begin + key := 'step'; + DisplayLabel:= _('Step'); + Description := _('Enter the increment amount'); + ProposalLists := []; + end; +end; + +function TAutoIncRuleController.IsSupportedDataType( + const dataType: TDataType): Boolean; +begin + Result := dataType in [dtString,dtInteger,dtFloat,dtDate,dtTime]; +end; + +end. Added: trunk/src/ui/controllers/CompositeRuleController.pas =================================================================== --- trunk/src/ui/controllers/CompositeRuleController.pas (rev 0) +++ trunk/src/ui/controllers/CompositeRuleController.pas 2007-01-02 14:59:18 UTC (rev 246) @@ -0,0 +1,31 @@ +unit CompositeRuleController; + +interface +uses Classes, DG_Core, RuleController; +type + TCompositeRuleController = class(TColumnRuleController) + protected + procedure CreateColumnRule(const columnName: string); override; + public + procedure InitViewData; override; + end; + +implementation +uses gnugettext, DG_Database, DG_Types; + +{ TCompositeRuleController } + +procedure TCompositeRuleController.CreateColumnRule(const columnName: string); +begin + inherited; + FColumnRule := TDGColumnRule.Create(columnName); + FColumnRule.Strategy := gtComposite; +end; + +procedure TCompositeRuleController.InitViewData; +begin + inherited; + +end; + +end. Deleted: trunk/src/ui/controllers/CopyRuleController.pas =================================================================== --- branches/gui/src/ui/controllers/CopyRuleController.pas 2007-01-02 13:31:32 UTC (rev 245) +++ trunk/src/ui/controllers/CopyRuleController.pas 2007-01-02 14:59:18 UTC (rev 246) @@ -1,37 +0,0 @@ -unit CopyRuleController; - -interface -uses Classes, DG_Core, RuleController; -type - - TCopyRuleController = class(TColumnRuleController) - protected - procedure CreateColumnRule(const columnName: string); override; - public - procedure InitViewData; override; - end; - -implementation -uses gnugettext, DG_Database, DG_Types; -{ TCopyRuleController } - -procedure TCopyRuleController.CreateColumnRule(const columnName: string); -begin - inherited; - FColumnRule := TDGColumnRule.Create(columnName); - FColumnRule.Strategy := gtCopy; - FColumnRule.NewParam('',''); -end; - -procedure TCopyRuleController.InitViewData; -begin - inherited; - with AddRuleParamViewData do begin - key := 'column'; - DisplayLabel:= _('Start'); - Description := _('Enter the source column to be copied.'); - ProposalLists := [plColumns]; - end; -end; - -end. Copied: trunk/src/ui/controllers/CopyRuleController.pas (from rev 245, branches/gui/src/ui/controllers/CopyRuleController.pas) =================================================================== --- trunk/src/ui/controllers/CopyRuleController.pas (rev 0) +++ trunk/src/ui/controllers/CopyRuleController.pas 2007-01-02 14:59:18 UTC (rev 246) @@ -0,0 +1,37 @@ +unit CopyRuleController; + +interface +uses Classes, DG_Core, RuleController; +type + + TCopyRuleController = class(TColumnRuleController) + protected + procedure CreateColumnRule(const columnName: string); override; + public + procedure InitViewData; override; + end; + +implementation +uses gnugettext, DG_Database, DG_Types; +{ TCopyRuleController } + +procedure TCopyRuleController.CreateColumnRule(const columnName: string); +begin + inherited; + FColumnRule := TDGColumnRule.Create(columnName); + FColumnRule.Strategy := gtCopy; + FColumnRule.NewParam('',''); +end; + +procedure TCopyRuleController.InitViewData; +begin + inherited; + with AddRuleParamViewData do begin + key := 'column'; + DisplayLabel:= _('Start'); + Description := _('Enter the source column to be copied.'); + ProposalLists := [plColumns]; + end; +end; + +end. Deleted: trunk/src/ui/controllers/FixedRuleController.pas =================================================================== --- branches/gui/src/ui/controllers/FixedRuleController.pas 2007-01-02 13:31:32 UTC (rev 245) +++ trunk/src/ui/controllers/FixedRuleController.pas 2007-01-02 14:59:18 UTC (rev 246) @@ -1,37 +0,0 @@ -unit FixedRuleController; - -interface -uses Classes, DG_Core, RuleController; -type - TFixedRuleController = class(TColumnRuleController) - protected - procedure CreateColumnRule(const columnName: string); override; - public - procedure InitViewData; override; - end; -implementation -uses gnugettext, DG_Database, DG_Types; - -{ TFixedRuleController } - -procedure TFixedRuleController.CreateColumnRule(const columnName: string); -begin - inherited; - FColumnRule := TDGColumnRule.Create(columnName); - FColumnRule.Strategy := gtPattern; - FColumnRule.NewParam('',''); -end; - -procedure TFixedRuleController.InitViewData; -begin - inherited; - with AddRuleParamViewData do begin - key := 'value'; - DisplayLabel := _('Value'); - Description := _( - 'Enter the fixed value. All the generated rows will have the same value.'); - ProposalLists := []; - end; -end; - -end. Copied: trunk/src/ui/controllers/FixedRuleController.pas (from rev 245, branches/gui/src/ui/controllers/FixedRuleController.pas) =================================================================== --- trunk/src/ui/controllers/FixedRuleController.pas (rev 0) +++ trunk/src/ui/controllers/FixedRuleController.pas 2007-01-02 14:59:18 UTC (rev 246) @@ -0,0 +1,37 @@ +unit FixedRuleController; + +interface +uses Classes, DG_Core, RuleController; +type + TFixedRuleController = class(TColumnRuleController) + protected + procedure CreateColumnRule(const columnName: string); override; + public + procedure InitViewData; override; + end; +implementation +uses gnugettext, DG_Database, DG_Types; + +{ TFixedRuleController } + +procedure TFixedRuleController.CreateColumnRule(const columnName: string); +begin + inherited; + FColumnRule := TDGColumnRule.Create(columnName); + FColumnRule.Strategy := gtPattern; + FColumnRule.NewParam('',''); +end; + +procedure TFixedRuleController.InitViewData; +begin + inherited; + with AddRuleParamViewData do begin + key := 'value'; + DisplayLabel := _('Value'); + Description := _( + 'Enter the fixed value. All the generated rows will have the same value.'); + ProposalLists := []; + end; +end; + +end. Deleted: trunk/src/ui/controllers/PascalScriptRuleController.pas =================================================================== --- branches/gui/src/ui/controllers/PascalScriptRuleController.pas 2007-01-02 13:31:32 UTC (rev 245) +++ trunk/src/ui/controllers/PascalScriptRuleController.pas 2007-01-02 14:59:18 UTC (rev 246) @@ -1,38 +0,0 @@ -unit PascalScriptRuleController; - -interface -uses Classes, DG_Core, RuleController; -type - TPascalScriptRuleController = class(TColumnRuleController) - protected - procedure CreateColumnRule(const columnName: string); override; - public - procedure InitViewData; override; - end; -implementation -uses gnugettext, DG_Database, DG_Types; - -{ TPascalScriptRuleController } - -procedure TPascalScriptRuleController.CreateColumnRule(const columnName: string); -begin - inherited; - FColumnRule := TDGColumnRule.Create(columnName); - FColumnRule.Strategy := gtScript; - FColumnRule.NewParam('',''); -end; - -procedure TPascalScriptRuleController.InitViewData; -begin - inherited; - with AddRuleParamViewData do begin - key := 'script'; - DisplayLabel := _('Script'); - Description := _( - 'Enter Pascal Script. Double click to open Script editor.'); - ProposalLists := []; - EditorType := edtScript; - end; -end; - -end. Copied: trunk/src/ui/controllers/PascalScriptRuleController.pas (from rev 245, branches/gui/src/ui/controllers/PascalScriptRuleController.pas) =================================================================== --- trunk/src/ui/controllers/PascalScriptRuleController.pas (rev 0) +++ trunk/src/ui/controllers/PascalScriptRuleController.pas 2007-01-02 14:59:18 UTC (rev 246) @@ -0,0 +1,38 @@ +unit PascalScriptRuleController; + +interface +uses Classes, DG_Core, RuleController; +type + TPascalScriptRuleController = class(TColumnRuleController) + protected + procedure CreateColumnRule(const columnName: string); override; + public + procedure InitViewData; override; + end; +implementation +uses gnugettext, DG_Database, DG_Types; + +{ TPascalScriptRuleController } + +procedure TPascalScriptRuleController.CreateColumnRule(const columnName: string); +begin + inherited; + FColumnRule := TDGColumnRule.Create(columnName); + FColumnRule.Strategy := gtScript; + FColumnRule.NewParam('',''); +end; + +procedure TPascalScriptRuleController.InitViewData; +begin + inherited; + with AddRuleParamViewData do begin + key := 'script'; + DisplayLabel := _('Script'); + Description := _( + 'Enter Pascal Script. Double click to open Script editor.'); + ProposalLists := []; + EditorType := edtScript; + end; +end; + +end. Deleted: trunk/src/ui/controllers/PatternRuleController.pas =================================================================== --- branches/gui/src/ui/controllers/PatternRuleController.pas 2007-01-02 13:31:32 UTC (rev 245) +++ trunk/src/ui/controllers/PatternRuleController.pas 2007-01-02 14:59:18 UTC (rev 246) @@ -1,44 +0,0 @@ -unit PatternRuleController; - -interface -uses Classes, DG_Core, RuleController; -type - TPatternRuleController = class(TColumnRuleController) - protected - procedure CreateColumnRule(const columnName: string); override; - public - procedure InitViewData; override; - function IsSupportedDataType(const dataType: TDataType): Boolean; override; - end; -implementation -uses gnugettext, DG_Database, DG_Types; - -{ TPatternRuleController } - -procedure TPatternRuleController.CreateColumnRule(const columnName: string); -begin - inherited; - FColumnRule := TDGColumnRule.Create(columnName); - FColumnRule.Strategy := gtPattern; - FColumnRule.NewParam('',''); -end; - -procedure TPatternRuleController.InitViewData; -begin - inherited; - with AddRuleParamViewData do begin - key := 'pattern'; - DisplayLabel := _('Pattern'); - Description := _( - 'Enter the pattern that will be used to generate data.'); - ProposalLists := []; - end; -end; - -function TPatternRuleController.IsSupportedDataType( - const dataType: TDataType): Boolean; -begin - Result := dataType in [dtString]; -end; - -end. Copied: trunk/src/ui/controllers/PatternRuleController.pas (from rev 245, branches/gui/src/ui/controllers/PatternRuleController.pas) =================================================================== --- trunk/src/ui/controllers/PatternRuleController.pas (rev 0) +++ trunk/src/ui/controllers/PatternRuleController.pas 2007-01-02 14:59:18 UTC (rev 246) @@ -0,0 +1,44 @@ +unit PatternRuleController; + +interface +uses Classes, DG_Core, RuleController; +type + TPatternRuleController = class(TColumnRuleController) + protected + procedure CreateColumnRule(const columnName: string); override; + public + procedure InitViewData; override; + function IsSupportedDataType(const dataType: TDataType): Boolean; override; + end; +implementation +uses gnugettext, DG_Database, DG_Types; + +{ TPatternRuleController } + +procedure TPatternRuleController.CreateColumnRule(const columnName: string); +begin + inherited; + FColumnRule := TDGColumnRule.Create(columnName); + FColumnRule.Strategy := gtPattern; + FColumnRule.NewParam('',''); +end; + +procedure TPatternRuleController.InitViewData; +begin + inherited; + with AddRuleParamViewData do begin + key := 'pattern'; + DisplayLabel := _('Pattern'); + Description := _( + 'Enter the pattern that will be used to generate data.'); + ProposalLists := []; + end; +end; + +function TPatternRuleController.IsSupportedDataType( + const dataType: TDataType): Boolean; +begin + Result := dataType in [dtString]; +end; + +end. Deleted: trunk/src/ui/controllers/RangeRuleController.pas =================================================================== --- branches/gui/src/ui/controllers/RangeRuleController.pas 2007-01-02 13:31:32 UTC (rev 245) +++ trunk/src/ui/controllers/RangeRuleController.pas 2007-01-02 14:59:18 UTC (rev 246) @@ -1,50 +0,0 @@ -unit RangeRuleController; - -interface -uses Classes, DG_Core, RuleController; -type - TRangeRuleController = class(TColumnRuleController) - protected - procedure CreateColumnRule(const columnName: string); override; - public - procedure InitViewData; override; - end; - -implementation -uses gnugettext, DG_Database, DG_Types; - -{ TRangeRuleController } - -procedure TRangeRuleController.CreateColumnRule(const columnName: string); -begin - inherited; - FColumnRule := TDGColumnRule.Create(columnName); - FColumnRule.Strategy := gtRange; - FColumnRule.NewParam('','1'); - FColumnRule.NewParam('',''); -end; - -procedure TRangeRuleController.InitViewData; -begin - inherited; - with AddRuleParamViewData do begin - key := 'min'; - DisplayLabel := _('Minimum'); - Description := _( - 'Enter the possible minimum value. If you enter a column '+ - 'name then the minimum value will be the generated value '+ - 'for that column'); - ProposalLists := [plColumns]; - end; - with AddRuleParamViewData do begin - key := 'max'; - DisplayLabel := _('Maximum'); - Description := _( - 'Enter the possible maximum value. If you enter a column '+ - 'name then the maximum value will be the generated value '+ - 'for that column'); - ProposalLists := [plColumns]; - end; -end; - -end. Copied: trunk/src/ui/controllers/RangeRuleController.pas (from rev 245, branches/gui/src/ui/controllers/RangeRuleController.pas) =================================================================== --- trunk/src/ui/controllers/RangeRuleController.pas (rev 0) +++ trunk/src/ui/controllers/RangeRuleController.pas 2007-01-02 14:59:18 UTC (rev 246) @@ -0,0 +1,50 @@ +unit RangeRuleController; + +interface +uses Classes, DG_Core, RuleController; +type + TRangeRuleController = class(TColumnRuleController) + protected + procedure CreateColumnRule(const columnName: string); override; + public + procedure InitViewData; override; + end; + +implementation +uses gnugettext, DG_Database, DG_Types; + +{ TRangeRuleController } + +procedure TRangeRuleController.CreateColumnRule(const columnName: string); +begin + inherited; + FColumnRule := TDGColumnRule.Create(columnName); + FColumnRule.Strategy := gtRange; + FColumnRule.NewParam('','1'); + FColumnRule.NewParam('',''); +end; + +procedure TRangeRuleController.InitViewData; +begin + inherited; + with AddRuleParamViewData do begin + key := 'min'; + DisplayLabel := _('Minimum'); + Description := _( + 'Enter the possible minimum value. If you enter a column '+ + 'name then the minimum value will be the generated value '+ + 'for that column'); + ProposalLists := [plColumns]; + end; + with AddRuleParamViewData do begin + key := 'max'; + DisplayLabel := _('Maximum'); + Description := _( + 'Enter the possible maximum value. If you enter a column '+ + 'name then the maximum value will be the generated value '+ + 'for that column'); + ProposalLists := [plColumns]; + end; +end; + +end. Deleted: trunk/src/ui/controllers/RuleController.pas =================================================================== --- branches/gui/src/ui/controllers/RuleController.pas 2007-01-02 13:31:32 UTC (rev 245) +++ trunk/src/ui/controllers/RuleController.pas 2007-01-02 14:59:18 UTC (rev 246) @@ -1,264 +0,0 @@ -unit RuleController; - -interface -uses Classes, SysUtils, DG_Core, DG_Database, DG_Types; -type - TProposalList = (plConnections, plSequences, plColumns); - TProposalLists = set of TProposalList; - TEditorType = (edtNone, edtFile, edtSQL, edtScript, edtList); - //---- DG_Types i\xE7ine ta\xFE\xFDnacak ---- - TDataType = (dtUnknown, dtChar, dtString, dtInteger, dtFloat, dtDate, dtTime); - TDataTypes = set of TDataType; - //---------------------------------- - - //How-to view data for rule parameters - TRuleParamViewData = class - key: String; - DisplayLabel: String; - Description: String; - ProposalLists : TProposalLists; - EditorType : TEditorType; - end; - - IColumnRuleController = interface - ['{76D94F5E-B656-43DD-BD9E-D2ACE62C66B5}'] - function GetParameterCount: Integer; - function GetParamViewData(const i: integer): TRuleParamViewData; - function GetParameterValue(const name: string):Variant; - procedure SetParameterValue(const name: string; value: Variant); - function GetColumnRule: TDGColumnRule; - function GetDescription: String; - function IsSupportedDataType(const dataType: TDataType): Boolean; - end; - - //Rule Controller: Provides a connection between the GUI an and the rule objects - // Defines the - // * how many parameters do the rule have - // * how to handle parameters - // * Datatypes that are supported by rule - // Automatizes - // * reflection of the changes made to the rule object via GUI - // * Creation of rules using ColumnName and generatorType - TRuleController = class(TInterfacedObject, IColumnRuleController) - protected - FColumnRule : TDGColumnRule; - FRuleParamViewDatas: TList; - // creates columnRule if it is not given in the constructor - procedure CreateColumnRule(const columnName: string);virtual; abstract; - public - constructor Create(const columnRule: TDGColumnRule); overload; virtual; - constructor Create(const columnName: String); overload; virtual; - - class function CreateForColumn(const columnName: string; const ruleStrategy: TGeneratorType): TRuleController; - class function CreateForRule(const rule: TDGColumnRule): TRuleController; - destructor Destroy; override; - // Returns how many paramters to the rule have - function GetParameterCount: Integer; virtual; - // returns the value of the parameter. - function GetParameterValue(const name: string): Variant; virtual; - // changes the value of the parameter - procedure SetParameterValue(const name: string; value: Variant); virtual; - // returns the ColumnRule object being controlled - function GetColumnRule: TDGColumnRule; virtual; - //Any new rule parameter should be added using this method - //function returns the newly added empty ruleviewdata - function AddRuleParamViewData: TRuleParamViewData; virtual; - // Descendants should override this method to add their own viewdatas - // AddRuleParamViewData method - procedure InitViewData;virtual; - // Descendants should override Initviewdata. This method just returns - // the ViewData array - function GetParamViewData(const i: integer): TRuleParamViewData; - // Returns a brief description about the rule - function GetDescription: string; virtual; - // Checks if the dataType is supported by the rule. It is useful prior to - // eliminating unnecessary rules from the presentation - function IsSupportedDataType(const dataType: TDataType): Boolean; virtual; - end; - - TColumnRuleController = class(TRuleController) - public - function GetParameterValue(const name: string): Variant; override; - procedure SetParameterValue(const name: string; value: Variant); override; - procedure InitViewData; override; - end; - -implementation -uses gnugettext, DG_Generators, - AutoIncRuleController, CopyRuleController, - RangeRuleController, SQLRuleController, - PascalScriptRuleController, FixedRuleController, - SequenceRuleController,PatternRuleController, - CompositeRuleController; - -{ TRuleController } - -constructor TRuleController.Create(const columnRule: TDGColumnRule); -begin - if columnRule <> nil then - FColumnRule := columnRule; - Create(FColumnRule.ColumnName); -end; - -function TRuleController.AddRuleParamViewData: TRuleParamViewData; -var - itm : TRuleParamViewData; -begin - itm := TRuleParamViewData.Create; - FRuleParamViewDatas.Add(itm); - Result := itm; -end; - -constructor TRuleController.Create(const columnName: String); -begin - FRuleParamViewDatas := TList.Create; - if FColumnRule = nil then - CreateColumnRule(columnName); - InitViewData; -end; - -class function TRuleController.CreateForColumn(const columnName: string; - const ruleStrategy: TGeneratorType): TRuleController; -begin - case ruleStrategy of - gtRange: Result := TRangeRuleController.Create(ColumnName); - gtSQL: Result := TSQLRuleController.Create(ColumnName); - gtScript: Result := TPascalScriptRuleController.Create(ColumnName); - gtAutoInc: Result := TAutoIncRuleController.Create(ColumnName); - gtComposite: Result := TCompositeRuleController.Create(ColumnName); - gtFixed: Result := TFixedRuleController.Create(ColumnName); - gtCopy: Result := TCopyRuleController.Create(ColumnName); - gtSequence: Result := TSequenceRuleController.Create(ColumnName); - gtPattern: Result := TPatternRuleController.Create(ColumnName); -// gtVariable: ; - else - raise Exception.Create(Format(_('Cannot find controller for %s'),[GeneratorLocalName(ruleStrategy)])); - end; -end; - -class function TRuleController.CreateForRule( - const rule: TDGColumnRule): TRuleController; -begin - case rule.Strategy of - gtRange: Result := TRangeRuleController.Create(rule); - gtSQL: Result := TSQLRuleController.Create(rule); - gtScript: Result := TPascalScriptRuleController.Create(rule); - gtAutoInc: Result := TAutoIncRuleController.Create(rule); - gtComposite: Result := TCompositeRuleController.Create(rule); - gtFixed: Result := TFixedRuleController.Create(rule); - gtCopy: Result := TCopyRuleController.Create(rule); - gtSequence: Result := TSequenceRuleController.Create(rule); - gtPattern: Result := TPatternRuleController.Create(rule); -// gtVariable: ; - else - raise Exception.Create(Format(_('Cannot find controller for %s'),[GeneratorLocalName(rule.Strategy)])); - end; -end; - -destructor TRuleController.Destroy; -var - I: Integer; -begin - for I := 0 to FRuleParamViewDatas.Count - 1 do - TRuleParamViewData(FRuleParamViewDatas[i]).Free; - FRuleParamViewDatas.Free; - inherited; -end; - -function TRuleController.GetColumnRule: TDGColumnRule; -begin - Result := FColumnRule; -end; - -function TRuleController.GetDescription: string; -begin - Result := ''; -end; - -function TRuleController.GetParameterCount: Integer; -begin - Result := FRuleParamViewDatas.Count; -end; - -function TRuleController.GetParameterValue(const name: string): Variant; -var - i: Integer; -begin - for I := 0 to FRuleParamViewDatas.Count-1 do - if TRuleParamViewData(FRuleParamViewDatas[i]).key = name then - begin - Result := FColumnRule.Params[i-1].Value; - break; - end; -end; - -procedure TRuleController.SetParameterValue(const name: string; value: Variant); -var - i: Integer; -begin - for I := 0 to FRuleParamViewDatas.Count-1 do - if TRuleParamViewData(FRuleParamViewDatas[i]).key = name then begin - // i 1 azalt\xFDl\xFDyor \xE7\xFCnk\xFC sadece nullpercentage eklendi\xF0ini biliyoruz \xF6nceden - // bu d\xFCzeltilecek. - FColumnRule.Params[i-1].Value := Value; - exit; - end; -end; - -function TRuleController.GetParamViewData(const i: integer): TRuleParamViewData; -begin - Result := TRuleParamViewData(FRuleParamViewDatas[i]); -end; - -//function TRuleController.GetParamViewDatas: TRuleParamViewDatas; -//var -// i: Integer; -//begin -// SetLength(Result,FRuleParamViewDatas.Count); -// for i := 0 to FRuleParamViewDatas.Count - 1 do begin -// Result[i] := PRuleParamViewData(FRuleParamViewDatas[i])^; -// end; -//end; - -procedure TRuleController.InitViewData; -begin - -end; - -function TRuleController.IsSupportedDataType(const dataType: TDataType): Boolean; -begin - Result := True; -end; - -{ TColumnRuleController } - -function TColumnRuleController.GetParameterValue(const name: string): Variant; -begin - if name = 'nullpercentage' then - Result := FColumnRule.NullPercentage - else - Result := inherited GetParameterValue(name); -end; - -procedure TColumnRuleController.InitViewData; -begin - inherited; - with AddRuleParamViewData do - begin - key := 'nullpercentage'; - DisplayLabel := _('Null Percentage'); - Description:= _('Percentage of the null data. 100% means all ' + - 'generated data will be null'); - ProposalLists := []; - end; -end; - -procedure TColumnRuleController.SetParameterValue(const name: string; value: Variant); -begin - if name = 'nullpercentage' then - FColumnRule.NullPercentage := Value - else - inherited SetParameterValue(name,Value); -end; - -end. Copied: trunk/src/ui/controllers/RuleController.pas (from rev 245, branches/gui/src/ui/controllers/RuleController.pas) =================================================================== --- trunk/src/ui/controllers/RuleController.pas (rev 0) +++ trunk/src/ui/controllers/RuleController.pas 2007-01-02 14:59:18 UTC (rev 246) @@ -0,0 +1,264 @@ +unit RuleController; + +interface +uses Classes, SysUtils, DG_Core, DG_Database, DG_Types; +type + TProposalList = (plConnections, plSequences, plColumns); + TProposalLists = set of TProposalList; + TEditorType = (edtNone, edtFile, edtSQL, edtScript, edtList); + //---- DG_Types i\xE7ine ta\xFE\xFDnacak ---- + TDataType = (dtUnknown, dtChar, dtString, dtInteger, dtFloat, dtDate, dtTime); + TDataTypes = set of TDataType; + //---------------------------------- + + //How-to view data for rule parameters + TRuleParamViewData = class + key: String; + DisplayLabel: String; + Description: String; + ProposalLists : TProposalLists; + EditorType : TEditorType; + end; + + IColumnRuleController = interface + ['{76D94F5E-B656-43DD-BD9E-D2ACE62C66B5}'] + function GetParameterCount: Integer; + function GetParamViewData(const i: integer): TRuleParamViewData; + function GetParameterValue(const name: string):Variant; + procedure SetParameterValue(const name: string; value: Variant); + function GetColumnRule: TDGColumnRule; + function GetDescription: String; + function IsSupportedDataType(const dataType: TDataType): Boolean; + end; + + //Rule Controller: Provides a connection between the GUI an and the rule objects + // Defines the + // * how many parameters do the rule have + // * how to handle parameters + // * Datatypes that are supported by rule + // Automatizes + // * reflection of the changes made to the rule object via GUI + // * Creation of rules using ColumnName and generatorType + TRuleController = class(TInterfacedObject, IColumnRuleController) + protected + FColumnRule : TDGColumnRule; + FRuleParamViewDatas: TList; + // creates columnRule if it is not given in the constructor + procedure CreateColumnRule(const columnName: string);virtual; abstract; + public + constructor Create(const columnRule: TDGColumnRule); overload; virtual; + constructor Create(const columnName: String); overload; virtual; + + class function CreateForColumn(const columnName: string; const ruleStrategy: TGeneratorType): TRuleController; + class function CreateForRule(const rule: TDGColumnRule): TRuleController; + destructor Destroy; override; + // Returns how many paramters to the rule have + function GetParameterCount: Integer; virtual; + // returns the value of the parameter. + function GetParameterValue(const name: string): Variant; virtual; + // changes the value of the parameter + procedure SetParameterValue(const name: string; value: Variant); virtual; + // returns the ColumnRule object being controlled + function GetColumnRule: TDGColumnRule; virtual; + //Any new rule parameter should be added using this method + //function returns the newly added empty ruleviewdata + function AddRuleParamViewData: TRuleParamViewData; virtual; + // Descendants should override this method to add their own viewdatas + // AddRuleParamViewData method + procedure InitViewData;virtual; + // Descendants should override Initviewdata. This method just returns + // the ViewData array + function GetParamViewData(const i: integer): TRuleParamViewData; + // Returns a brief description about the rule + function GetDescription: string; virtual; + // Checks if the dataType is supported by the rule. It is useful prior to + // eliminating unnecessary rules from the presentation + function IsSupportedDataType(const dataType: TDataType): Boolean; virtual; + end; + + TColumnRuleController = class(TRuleController) + public + function GetParameterValue(const name: string): Variant; override; + procedure SetParameterValue(const name: string; value: Variant); override; + procedure InitViewData; override; + end; + +implementation +uses gnugettext, DG_Generators, + AutoIncRuleController, CopyRuleController, + RangeRuleController, SQLRuleController, + PascalScriptRuleController, FixedRuleController, + SequenceRuleController,PatternRuleController, + CompositeRuleController; + +{ TRuleController } + +constructor TRuleController.Create(const columnRule: TDGColumnRule); +begin + if columnRule <> nil then + FColumnRule := columnRule; + Create(FColumnRule.ColumnName); +end; + +function TRuleController.AddRuleParamViewData: TRuleParamViewData; +var + itm : TRuleParamViewData; +begin + itm := TRuleParamViewData.Create; + FRuleParamViewDatas.Add(itm); + Result := itm; +end; + +constructor TRuleController.Create(const columnName: String); +begin + FRuleParamViewDatas := TList.Create; + if FColumnRule = nil then + CreateColumnRule(columnName); + InitViewData; +end; + +class function TRuleController.CreateForColumn(const columnName: string; + const ruleStrategy: TGeneratorType): TRuleController; +begin + case ruleStrategy of + gtRange: Result := TRangeRuleController.Create(ColumnName); + gtSQL: Result := TSQLRuleController.Create(... [truncated message content] |
From: <t-...@us...> - 2007-01-02 13:31:34
|
Revision: 245 http://svn.sourceforge.net/datagenerator/?rev=245&view=rev Author: t-hex Date: 2007-01-02 05:31:32 -0800 (Tue, 02 Jan 2007) Log Message: ----------- - SQL Script File editorleri tekrar calisiyor Modified Paths: -------------- branches/gui/src/ui/FormColumnRule.dfm branches/gui/src/ui/FormColumnRule.pas branches/gui/src/ui/controllers/PascalScriptRuleController.pas branches/gui/src/ui/controllers/RuleController.pas branches/gui/src/ui/controllers/SQLRuleController.pas Modified: branches/gui/src/ui/FormColumnRule.dfm =================================================================== --- branches/gui/src/ui/FormColumnRule.dfm 2007-01-01 20:40:06 UTC (rev 244) +++ branches/gui/src/ui/FormColumnRule.dfm 2007-01-02 13:31:32 UTC (rev 245) @@ -103,7 +103,6 @@ OnGetText = ParamTreeListGetText OnGetHint = ParamTreeListGetHint OnGetNodeDataSize = ParamTreeListGetNodeDataSize - OnInitNode = ParamTreeListInitNode OnKeyAction = ParamTreeListKeyAction OnKeyUp = ParamTreeListKeyUp OnNewText = ParamTreeListNewText Modified: branches/gui/src/ui/FormColumnRule.pas =================================================================== --- branches/gui/src/ui/FormColumnRule.pas 2007-01-01 20:40:06 UTC (rev 244) +++ branches/gui/src/ui/FormColumnRule.pas 2007-01-02 13:31:32 UTC (rev 245) @@ -9,7 +9,7 @@ type TListType = (ltNone, ltReference, ltSequence); - TActionType = (atNormal, atFile, atScript, atSQL, atList); + //TActionType = (atNormal, atFile, atScript, atSQL, atList); PNodeData = ^TNodeData; TNodeData = record @@ -32,8 +32,6 @@ Panel1: TPanel; lblInfo: TLabel; miList: TMenuItem; - procedure ParamTreeListInitNode(Sender: TBaseVirtualTree; ParentNode, - Node: PVirtualNode; var InitialStates: TVirtualNodeInitStates); procedure ParamTreeListGetText(Sender: TBaseVirtualTree; Node: PVirtualNode; Column: TColumnIndex; TextType: TVSTTextType; var CellText: WideString); @@ -78,7 +76,6 @@ procedure FillConnectionsProposalList(var EditLink: IVTEditLink); procedure FillSequencesProposalList(var EditLink: IVTEditLink; const connRef: string); public - procedure PerformPopupAction(ActionType : TActionType; Node: PVirtualNode); procedure FreeRuleController; procedure UpdateView; function GetColumnRule: TDGColumnRule; @@ -98,18 +95,6 @@ { TfrmColumnRule } -procedure TfrmColumnRule.ParamTreeListInitNode(Sender: TBaseVirtualTree; - ParentNode, Node: PVirtualNode; - var InitialStates: TVirtualNodeInitStates); -var - ParamData : PNodeData; -begin - inherited; - ParamData := Sender.GetNodeData(Node); -// if ParamData.ListType = ltNone then -// Node.CheckType := ctButton; -end; - procedure TfrmColumnRule.ParamTreeListGetText(Sender: TBaseVirtualTree; Node: PVirtualNode; Column: TColumnIndex; TextType: TVSTTextType; var CellText: WideString); @@ -180,10 +165,10 @@ MenuIndex : Integer; begin inherited; - if FCheckedNode = nil then exit; - MenuIndex := TMenuItem(Sender).MenuIndex; - PerformPopupAction(TActionType(MenuIndex),FCheckedNode); - FCheckedNode := nil; +// if FCheckedNode = nil then exit; +// MenuIndex := TMenuItem(Sender).MenuIndex; +// PerformPopupAction(FCheckedNode); +// FCheckedNode := nil; end; procedure TfrmColumnRule.ParamTreeListGetNodeDataSize( @@ -238,72 +223,50 @@ var Node: PVirtualNode; NodeData : PNodeData; + EditorType: TEditorType; begin inherited; if ParamTreeList.FocusedColumn <> 1 then exit; - Node := ParamTreeList.FocusedNode; if Node = nil then exit; NodeData := ParamTreeList.GetNodeData(Node); - { TODO 1 -ot-hex : Somehow the following code should be more simple } -// if NodeParamData.Tip = 'file' then PerformPopupAction(atFile,Node); -// if NodeParamData.Tip = 'script' then PerformPopupAction(atScript,Node); -// if NodeParamData.Tip = 'sql' then PerformPopupAction(atSQL,Node); -// if NodeParamData.Tip = 'list' then PerformPopupAction(atList,Node); -end; - -procedure TfrmColumnRule.ParamTreeListKeyAction(Sender: TBaseVirtualTree; - var CharCode: Word; var Shift: TShiftState; var DoDefault: Boolean); -begin - inherited; - if CharCode = VK_RETURN then begin - Sender.EditNode(Sender.FocusedNode,Sender.FocusedColumn); - end; -end; - -procedure TfrmColumnRule.PerformPopupAction(ActionType: TActionType; - Node: PVirtualNode); -var - ParamData : PNodeData; -begin - { DONE : FIXME: Paramdata.tip sometimes gets wrong type, not selected. } - ParamData := ParamTreeList.GetNodeData(Node); - case ActionType of - atNormal: begin - ParamTreeList.EditNode(FCheckedNode, 1); - end; - atFile : begin - ParamOpenDialog.FileName := FRuleController.GetParameterValue(ParamData.key); + EditorType := FRuleController.GetParamViewData(Node.Index).EditorType; + case EditorType of + edtNone: ParamTreeList.EditNode(FCheckedNode, 1); + edtFile: begin + ParamOpenDialog.FileName := FRuleController.GetParameterValue(NodeData.key); if ParamOpenDialog.Execute then - begin - FRuleController.SetParameterValue(ParamData.key,ParamOpenDialog.FileName); - end; + FRuleController.SetParameterValue(NodeData.key,ParamOpenDialog.FileName); end; - atScript, atSQL, - atList : begin + edtSQL,edtScript,edtList: + begin Application.CreateForm(TfrmEditor, frmEditor); try - frmEditor.Text := FRuleController.GetParameterValue(ParamData.key); - case ActionType of - atScript: frmEditor.TextType := ttPascalScript; - atSQL: frmEditor.TextType := ttSQL; - atList: frmEditor.TextType := ttList; + frmEditor.Text := FRuleController.GetParameterValue(NodeData.key); + case EditorType of + edtScript: frmEditor.TextType := ttPascalScript; + edtSQL: frmEditor.TextType := ttSQL; + edtList: frmEditor.TextType := ttList; end; if frmEditor.ShowModal = mrOk then - begin -// if ActionType = atScript then ParamData.Tip := 'script'; -// if ActionType = atSQL then ParamData.Tip := 'sql'; -// if ActionType = atList then ParamData.Tip := 'list'; - FRuleController.SetParameterValue(ParamData.key,frmEditor.Text); - end; + FRuleController.SetParameterValue(NodeData.key,frmEditor.Text); finally frmEditor.Free; end; end; - end; + end; //case ParamTreeList.Refresh; end; +procedure TfrmColumnRule.ParamTreeListKeyAction(Sender: TBaseVirtualTree; + var CharCode: Word; var Shift: TShiftState; var DoDefault: Boolean); +begin + inherited; + if CharCode = VK_RETURN then begin + Sender.EditNode(Sender.FocusedNode,Sender.FocusedColumn); + end; +end; + procedure TfrmColumnRule.ParamTreeListGetHint(Sender: TBaseVirtualTree; Node: PVirtualNode; Column: TColumnIndex; var LineBreakStyle: TVTTooltipLineBreakStyle; var HintText: WideString); Modified: branches/gui/src/ui/controllers/PascalScriptRuleController.pas =================================================================== --- branches/gui/src/ui/controllers/PascalScriptRuleController.pas 2007-01-01 20:40:06 UTC (rev 244) +++ branches/gui/src/ui/controllers/PascalScriptRuleController.pas 2007-01-02 13:31:32 UTC (rev 245) @@ -31,6 +31,7 @@ Description := _( 'Enter Pascal Script. Double click to open Script editor.'); ProposalLists := []; + EditorType := edtScript; end; end; Modified: branches/gui/src/ui/controllers/RuleController.pas =================================================================== --- branches/gui/src/ui/controllers/RuleController.pas 2007-01-01 20:40:06 UTC (rev 244) +++ branches/gui/src/ui/controllers/RuleController.pas 2007-01-02 13:31:32 UTC (rev 245) @@ -5,16 +5,19 @@ type TProposalList = (plConnections, plSequences, plColumns); TProposalLists = set of TProposalList; + TEditorType = (edtNone, edtFile, edtSQL, edtScript, edtList); //---- DG_Types i\xE7ine ta\xFE\xFDnacak ---- TDataType = (dtUnknown, dtChar, dtString, dtInteger, dtFloat, dtDate, dtTime); TDataTypes = set of TDataType; //---------------------------------- - + + //How-to view data for rule parameters TRuleParamViewData = class key: String; DisplayLabel: String; Description: String; ProposalLists : TProposalLists; + EditorType : TEditorType; end; IColumnRuleController = interface @@ -27,7 +30,15 @@ function GetDescription: String; function IsSupportedDataType(const dataType: TDataType): Boolean; end; - + + //Rule Controller: Provides a connection between the GUI an and the rule objects + // Defines the + // * how many parameters do the rule have + // * how to handle parameters + // * Datatypes that are supported by rule + // Automatizes + // * reflection of the changes made to the rule object via GUI + // * Creation of rules using ColumnName and generatorType TRuleController = class(TInterfacedObject, IColumnRuleController) protected FColumnRule : TDGColumnRule; @@ -37,13 +48,17 @@ public constructor Create(const columnRule: TDGColumnRule); overload; virtual; constructor Create(const columnName: String); overload; virtual; + class function CreateForColumn(const columnName: string; const ruleStrategy: TGeneratorType): TRuleController; class function CreateForRule(const rule: TDGColumnRule): TRuleController; destructor Destroy; override; - + // Returns how many paramters to the rule have function GetParameterCount: Integer; virtual; + // returns the value of the parameter. function GetParameterValue(const name: string): Variant; virtual; + // changes the value of the parameter procedure SetParameterValue(const name: string; value: Variant); virtual; + // returns the ColumnRule object being controlled function GetColumnRule: TDGColumnRule; virtual; //Any new rule parameter should be added using this method //function returns the newly added empty ruleviewdata @@ -54,7 +69,10 @@ // Descendants should override Initviewdata. This method just returns // the ViewData array function GetParamViewData(const i: integer): TRuleParamViewData; + // Returns a brief description about the rule function GetDescription: string; virtual; + // Checks if the dataType is supported by the rule. It is useful prior to + // eliminating unnecessary rules from the presentation function IsSupportedDataType(const dataType: TDataType): Boolean; virtual; end; Modified: branches/gui/src/ui/controllers/SQLRuleController.pas =================================================================== --- branches/gui/src/ui/controllers/SQLRuleController.pas 2007-01-01 20:40:06 UTC (rev 244) +++ branches/gui/src/ui/controllers/SQLRuleController.pas 2007-01-02 13:31:32 UTC (rev 245) @@ -41,6 +41,7 @@ Description := _( 'Enter SQL. Double click to open the SQL Editor.'); ProposalLists := [plColumns]; + EditorType := edtSQL; end; end; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <t-...@us...> - 2007-01-01 20:40:08
|
Revision: 244 http://svn.sourceforge.net/datagenerator/?rev=244&view=rev Author: t-hex Date: 2007-01-01 12:40:06 -0800 (Mon, 01 Jan 2007) Log Message: ----------- -FillConnectionsProposalList ve FillSequencesProposalList metodlari ile combobox bilgileri guncelleniyor -TRuleControllerFactory sinifi kaldirildi -CreateRuleController metodlari TRuleController sinifina CreateForColumn ve CreateForRule olarak tasindi. Modified Paths: -------------- branches/gui/src/ui/DataGeneratorUI.dpr branches/gui/src/ui/FormColumnRule.dfm branches/gui/src/ui/FormColumnRule.pas branches/gui/src/ui/MainForm.pas branches/gui/src/ui/controllers/AutoIncRuleController.pas branches/gui/src/ui/controllers/CopyRuleController.pas branches/gui/src/ui/controllers/FixedRuleController.pas branches/gui/src/ui/controllers/PascalScriptRuleController.pas branches/gui/src/ui/controllers/PatternRuleController.pas branches/gui/src/ui/controllers/RangeRuleController.pas branches/gui/src/ui/controllers/RuleController.pas branches/gui/src/ui/controllers/SQLRuleController.pas branches/gui/src/ui/controllers/SequenceRuleController.pas Removed Paths: ------------- branches/gui/src/ui/controllers/RuleControllerFactory.pas Modified: branches/gui/src/ui/DataGeneratorUI.dpr =================================================================== --- branches/gui/src/ui/DataGeneratorUI.dpr 2006-12-30 17:42:00 UTC (rev 243) +++ branches/gui/src/ui/DataGeneratorUI.dpr 2007-01-01 20:40:06 UTC (rev 244) @@ -36,7 +36,6 @@ PatternRuleController in 'controllers\PatternRuleController.pas', RangeRuleController in 'controllers\RangeRuleController.pas', RuleController in 'controllers\RuleController.pas', - RuleControllerFactory in 'controllers\RuleControllerFactory.pas', SequenceRuleController in 'controllers\SequenceRuleController.pas', SQLRuleController in 'controllers\SQLRuleController.pas', FixedRuleController in 'controllers\FixedRuleController.pas', Modified: branches/gui/src/ui/FormColumnRule.dfm =================================================================== --- branches/gui/src/ui/FormColumnRule.dfm 2006-12-30 17:42:00 UTC (rev 243) +++ branches/gui/src/ui/FormColumnRule.dfm 2007-01-01 20:40:06 UTC (rev 244) @@ -7,6 +7,8 @@ ClientWidth = 387 OldCreateOrder = True OnDestroy = FormDestroy + ExplicitWidth = 393 + ExplicitHeight = 386 PixelsPerInch = 96 TextHeight = 13 inherited Bevel1: TBevel Modified: branches/gui/src/ui/FormColumnRule.pas =================================================================== --- branches/gui/src/ui/FormColumnRule.pas 2006-12-30 17:42:00 UTC (rev 243) +++ branches/gui/src/ui/FormColumnRule.pas 2007-01-01 20:40:06 UTC (rev 244) @@ -11,6 +11,11 @@ TListType = (ltNone, ltReference, ltSequence); TActionType = (atNormal, atFile, atScript, atSQL, atList); + PNodeData = ^TNodeData; + TNodeData = record + key : string; + end; + TfrmColumnRule = class(TfrmRule) GroupBox1: TGroupBox; lblFieldName: TLabel; @@ -70,6 +75,8 @@ procedure FillGeneratorCombo; procedure SetRuleController(const Value: TRuleController); procedure SetColumnName(const Value: String); + procedure FillConnectionsProposalList(var EditLink: IVTEditLink); + procedure FillSequencesProposalList(var EditLink: IVTEditLink; const connRef: string); public procedure PerformPopupAction(ActionType : TActionType; Node: PVirtualNode); procedure FreeRuleController; @@ -79,18 +86,13 @@ property ColumnName: String read FColumnName write SetColumnName; end; - PNodeData = ^TNodeData; - TNodeData = record - key : string; - end; - var frmColumnRule: TfrmColumnRule; implementation uses Types, FormMemoEditor, gnugettext, VTEditLinks, MainForm, - ZConnection, ZDbcIntfs, Math, UITools, DG_Generators, RuleControllerFactory; + ZConnection, ZDbcIntfs, Math, UITools, DG_Generators; {$R *.dfm} @@ -221,7 +223,7 @@ inherited; if assigned(FRuleController) then FreeRuleController; - RuleController := TRuleControllerFactory.CreateRuleController(ColumnName, TGeneratorType(cbGeneratorType.ItemIndex)); + RuleController := TRuleController.CreateForColumn(ColumnName, TGeneratorType(cbGeneratorType.ItemIndex)); end; procedure TfrmColumnRule.ParamTreeListChange(Sender: TBaseVirtualTree; @@ -235,14 +237,14 @@ procedure TfrmColumnRule.ParamTreeListDblClick(Sender: TObject); var Node: PVirtualNode; - NodeParamData : PNodeData; + NodeData : PNodeData; begin inherited; if ParamTreeList.FocusedColumn <> 1 then exit; Node := ParamTreeList.FocusedNode; if Node = nil then exit; - NodeParamData := ParamTreeList.GetNodeData(Node); + NodeData := ParamTreeList.GetNodeData(Node); { TODO 1 -ot-hex : Somehow the following code should be more simple } // if NodeParamData.Tip = 'file' then PerformPopupAction(atFile,Node); // if NodeParamData.Tip = 'script' then PerformPopupAction(atScript,Node); @@ -334,57 +336,20 @@ out EditLink: IVTEditLink); var ParamData : PNodeData; - Items : TStringList; - ConnProp : TDGConnectionProperty; - tmpConnection : TZConnection; - I : Integer; - SequenceRS : IZResultSet; + ProposalLists: TProposalLists; + connRef: String; begin inherited; - ParamData := Sender.GetNodeData(Node); -// if ParamData.ListType = ltReference then -// begin -// Items := TStringList.Create; -// try -// for i := 0 to frmMain.Configuration.ConnectionProperties.Count - 1 do -// begin -// ConnProp := TDGConnectionProperty(frmMain.Configuration.ConnectionProperties[I]); -// Items.Add(ConnProp.Ref); -// end; -// EditLink := TComboBoxEditLink.Create(Items); -// finally -// Items.Free; -// end; -// end; -// -// if ParamData.ListType = ltSequence then -// begin -// // Previous node gives the connection reference -// ParamData := Sender.GetNodeData(Node.PrevSibling); -// ConnProp := frmMain.Configuration.FindConnectionProperty(FRuleController.GetParameterValue((Node.Index))); -// if Assigned(ConnProp) then -// begin -// //create connection -// tmpConnection := CreateConnection(ConnProp); -// try -// tmpConnection.Connect; -// -// //get sequence list -// SequenceRS:=tmpConnection.DbcConnection.GetMetadata.GetSequences('','',''); -// Items := TStringList.Create; -// try -// while SequenceRS.Next do -// Items.Add(SequenceRS.GetString(3)); -// EditLink := TComboBoxEditLink.Create(Items); -// finally -// Items.Free; -// end; -// finally -// tmpConnection.Disconnect; -// tmpConnection.Free; -// end; -// end; -// end; + ProposalLists := FRuleController.GetParamViewData(Node.Index).ProposalLists; + if plConnections in ProposalLists then + FillConnectionsProposalList(EditLink); + + if plSequences in ProposalLists then begin + // Previous node gives the connection reference + ParamData := Sender.GetNodeData(Node.PrevSibling); + connRef := FRuleController.GetParameterValue(paramdata.key); + FillSequencesProposalList(EditLink,connRef); + end; if not assigned(EditLink) then EditLink := TStringEditLink.Create; end; @@ -421,6 +386,60 @@ Result := FRuleController.GetColumnRule; end; +procedure TfrmColumnRule.FillSequencesProposalList(var EditLink: IVTEditLink; const connRef: string); +var + ConnProp: TDGConnectionProperty; + tmpConnection: TZConnection; + SequenceRS: IZResultSet; + Items: TStringList; +begin + begin + ConnProp := frmMain.Configuration.FindConnectionProperty(connRef); + if Assigned(ConnProp) then + begin + //create connection + tmpConnection := CreateConnection(ConnProp); + try + tmpConnection.Connect; + //get sequence list + SequenceRS := tmpConnection.DbcConnection.GetMetadata.GetSequences('', '', ''); + Items := TStringList.Create; + try + while SequenceRS.Next do + Items.Add(SequenceRS.GetString(3)); + EditLink := TComboBoxEditLink.Create(Items); + finally + Items.Free; + end; + finally + tmpConnection.Disconnect; + tmpConnection.Free; + end; + end; + end; +end; + +procedure TfrmColumnRule.FillConnectionsProposalList(var EditLink: IVTEditLink); +var + Items: TStringList; + I: Integer; + ConnProp: TDGConnectionProperty; +begin + begin + Items := TStringList.Create; + try + for i := 0 to frmMain.Configuration.ConnectionProperties.Count - 1 do + begin + ConnProp := TDGConnectionProperty(frmMain.Configuration.ConnectionProperties[I]); + Items.Add(ConnProp.Ref); + end; + EditLink := TComboBoxEditLink.Create(Items); + finally + Items.Free; + end; + end; +end; + procedure TfrmColumnRule.FillGeneratorCombo; var I: Integer; Modified: branches/gui/src/ui/MainForm.pas =================================================================== --- branches/gui/src/ui/MainForm.pas 2006-12-30 17:42:00 UTC (rev 243) +++ branches/gui/src/ui/MainForm.pas 2007-01-01 20:40:06 UTC (rev 244) @@ -171,8 +171,7 @@ implementation uses FormColumnRule, FormTableRule, FormConnectionProperties, FormProgress, - gnugettext, FormSettings, uSettings, DG_Generators, DG_Types, - RuleControllerFactory; + gnugettext, FormSettings, uSettings, DG_Generators, DG_Types, RuleController; {$R *.dfm} @@ -413,7 +412,7 @@ try try if assigned(ColumnRule) then - frmColumnRule.RuleController := TRuleControllerFactory.CreateRuleController(ColumnRule); + frmColumnRule.RuleController := TRuleController.CreateForRule(ColumnRule); frmColumnRule.ColumnName := ColumnName; ModalValue := frmColumnRule.ShowModal; ColumnRule := frmColumnRule.GetColumnRule; Modified: branches/gui/src/ui/controllers/AutoIncRuleController.pas =================================================================== --- branches/gui/src/ui/controllers/AutoIncRuleController.pas 2006-12-30 17:42:00 UTC (rev 243) +++ branches/gui/src/ui/controllers/AutoIncRuleController.pas 2007-01-01 20:40:06 UTC (rev 244) @@ -9,6 +9,7 @@ procedure CreateColumnRule(const columnName: string); override; public procedure InitViewData; override; + function IsSupportedDataType(const dataType: TDataType): Boolean; override; end; implementation @@ -31,16 +32,20 @@ key := 'start'; DisplayLabel:= _('Start'); Description := _('Enter the starting value'); - DataTypes := 0; - ProposalLists := 0; + ProposalLists := []; end; with AddRuleParamViewData do begin key := 'step'; DisplayLabel:= _('Step'); Description := _('Enter the increment amount'); - DataTypes := 0; - ProposalLists := 0; + ProposalLists := []; end; end; +function TAutoIncRuleController.IsSupportedDataType( + const dataType: TDataType): Boolean; +begin + Result := dataType in [dtString,dtInteger,dtFloat,dtDate,dtTime]; +end; + end. Modified: branches/gui/src/ui/controllers/CopyRuleController.pas =================================================================== --- branches/gui/src/ui/controllers/CopyRuleController.pas 2006-12-30 17:42:00 UTC (rev 243) +++ branches/gui/src/ui/controllers/CopyRuleController.pas 2007-01-01 20:40:06 UTC (rev 244) @@ -30,8 +30,7 @@ key := 'column'; DisplayLabel:= _('Start'); Description := _('Enter the source column to be copied.'); - DataTypes := 0; - ProposalLists := PL_COLUMNS; + ProposalLists := [plColumns]; end; end; Modified: branches/gui/src/ui/controllers/FixedRuleController.pas =================================================================== --- branches/gui/src/ui/controllers/FixedRuleController.pas 2006-12-30 17:42:00 UTC (rev 243) +++ branches/gui/src/ui/controllers/FixedRuleController.pas 2007-01-01 20:40:06 UTC (rev 244) @@ -30,8 +30,7 @@ DisplayLabel := _('Value'); Description := _( 'Enter the fixed value. All the generated rows will have the same value.'); - ProposalLists := PL_COLUMNS; - DataTypes := 0; + ProposalLists := []; end; end; Modified: branches/gui/src/ui/controllers/PascalScriptRuleController.pas =================================================================== --- branches/gui/src/ui/controllers/PascalScriptRuleController.pas 2006-12-30 17:42:00 UTC (rev 243) +++ branches/gui/src/ui/controllers/PascalScriptRuleController.pas 2007-01-01 20:40:06 UTC (rev 244) @@ -30,8 +30,7 @@ DisplayLabel := _('Script'); Description := _( 'Enter Pascal Script. Double click to open Script editor.'); - ProposalLists := PL_COLUMNS; - DataTypes := 0; + ProposalLists := []; end; end; Modified: branches/gui/src/ui/controllers/PatternRuleController.pas =================================================================== --- branches/gui/src/ui/controllers/PatternRuleController.pas 2006-12-30 17:42:00 UTC (rev 243) +++ branches/gui/src/ui/controllers/PatternRuleController.pas 2007-01-01 20:40:06 UTC (rev 244) @@ -8,6 +8,7 @@ procedure CreateColumnRule(const columnName: string); override; public procedure InitViewData; override; + function IsSupportedDataType(const dataType: TDataType): Boolean; override; end; implementation uses gnugettext, DG_Database, DG_Types; @@ -30,9 +31,14 @@ DisplayLabel := _('Pattern'); Description := _( 'Enter the pattern that will be used to generate data.'); - ProposalLists := 0; - DataTypes := 0; + ProposalLists := []; end; end; +function TPatternRuleController.IsSupportedDataType( + const dataType: TDataType): Boolean; +begin + Result := dataType in [dtString]; +end; + end. Modified: branches/gui/src/ui/controllers/RangeRuleController.pas =================================================================== --- branches/gui/src/ui/controllers/RangeRuleController.pas 2006-12-30 17:42:00 UTC (rev 243) +++ branches/gui/src/ui/controllers/RangeRuleController.pas 2007-01-01 20:40:06 UTC (rev 244) @@ -34,8 +34,7 @@ 'Enter the possible minimum value. If you enter a column '+ 'name then the minimum value will be the generated value '+ 'for that column'); - ProposalLists := PL_COLUMNS; - DataTypes := 0; + ProposalLists := [plColumns]; end; with AddRuleParamViewData do begin key := 'max'; @@ -44,8 +43,7 @@ 'Enter the possible maximum value. If you enter a column '+ 'name then the maximum value will be the generated value '+ 'for that column'); - ProposalLists := PL_COLUMNS; - DataTypes := 0; + ProposalLists := [plColumns]; end; end; Modified: branches/gui/src/ui/controllers/RuleController.pas =================================================================== --- branches/gui/src/ui/controllers/RuleController.pas 2006-12-30 17:42:00 UTC (rev 243) +++ branches/gui/src/ui/controllers/RuleController.pas 2007-01-01 20:40:06 UTC (rev 244) @@ -1,21 +1,20 @@ unit RuleController; interface -uses Classes, SysUtils, DG_Core, DG_Database; -const - PL_CONNECTIONS = 1; - PL_SEQUENCES = 2; - PL_COLUMNS = 4; +uses Classes, SysUtils, DG_Core, DG_Database, DG_Types; type TProposalList = (plConnections, plSequences, plColumns); TProposalLists = set of TProposalList; - + //---- DG_Types i\xE7ine ta\xFE\xFDnacak ---- + TDataType = (dtUnknown, dtChar, dtString, dtInteger, dtFloat, dtDate, dtTime); + TDataTypes = set of TDataType; + //---------------------------------- + TRuleParamViewData = class key: String; DisplayLabel: String; Description: String; - DataTypes: integer; - ProposalLists : integer; + ProposalLists : TProposalLists; end; IColumnRuleController = interface @@ -25,6 +24,8 @@ function GetParameterValue(const name: string):Variant; procedure SetParameterValue(const name: string; value: Variant); function GetColumnRule: TDGColumnRule; + function GetDescription: String; + function IsSupportedDataType(const dataType: TDataType): Boolean; end; TRuleController = class(TInterfacedObject, IColumnRuleController) @@ -36,6 +37,8 @@ public constructor Create(const columnRule: TDGColumnRule); overload; virtual; constructor Create(const columnName: String); overload; virtual; + class function CreateForColumn(const columnName: string; const ruleStrategy: TGeneratorType): TRuleController; + class function CreateForRule(const rule: TDGColumnRule): TRuleController; destructor Destroy; override; function GetParameterCount: Integer; virtual; @@ -51,6 +54,8 @@ // Descendants should override Initviewdata. This method just returns // the ViewData array function GetParamViewData(const i: integer): TRuleParamViewData; + function GetDescription: string; virtual; + function IsSupportedDataType(const dataType: TDataType): Boolean; virtual; end; TColumnRuleController = class(TRuleController) @@ -61,7 +66,13 @@ end; implementation -uses gnugettext; +uses gnugettext, DG_Generators, + AutoIncRuleController, CopyRuleController, + RangeRuleController, SQLRuleController, + PascalScriptRuleController, FixedRuleController, + SequenceRuleController,PatternRuleController, + CompositeRuleController; + { TRuleController } constructor TRuleController.Create(const columnRule: TDGColumnRule); @@ -88,6 +99,44 @@ InitViewData; end; +class function TRuleController.CreateForColumn(const columnName: string; + const ruleStrategy: TGeneratorType): TRuleController; +begin + case ruleStrategy of + gtRange: Result := TRangeRuleController.Create(ColumnName); + gtSQL: Result := TSQLRuleController.Create(ColumnName); + gtScript: Result := TPascalScriptRuleController.Create(ColumnName); + gtAutoInc: Result := TAutoIncRuleController.Create(ColumnName); + gtComposite: Result := TCompositeRuleController.Create(ColumnName); + gtFixed: Result := TFixedRuleController.Create(ColumnName); + gtCopy: Result := TCopyRuleController.Create(ColumnName); + gtSequence: Result := TSequenceRuleController.Create(ColumnName); + gtPattern: Result := TPatternRuleController.Create(ColumnName); +// gtVariable: ; + else + raise Exception.Create(Format(_('Cannot find controller for %s'),[GeneratorLocalName(ruleStrategy)])); + end; +end; + +class function TRuleController.CreateForRule( + const rule: TDGColumnRule): TRuleController; +begin + case rule.Strategy of + gtRange: Result := TRangeRuleController.Create(rule); + gtSQL: Result := TSQLRuleController.Create(rule); + gtScript: Result := TPascalScriptRuleController.Create(rule); + gtAutoInc: Result := TAutoIncRuleController.Create(rule); + gtComposite: Result := TCompositeRuleController.Create(rule); + gtFixed: Result := TFixedRuleController.Create(rule); + gtCopy: Result := TCopyRuleController.Create(rule); + gtSequence: Result := TSequenceRuleController.Create(rule); + gtPattern: Result := TPatternRuleController.Create(rule); +// gtVariable: ; + else + raise Exception.Create(Format(_('Cannot find controller for %s'),[GeneratorLocalName(rule.Strategy)])); + end; +end; + destructor TRuleController.Destroy; var I: Integer; @@ -103,6 +152,11 @@ Result := FColumnRule; end; +function TRuleController.GetDescription: string; +begin + Result := ''; +end; + function TRuleController.GetParameterCount: Integer; begin Result := FRuleParamViewDatas.Count; @@ -153,6 +207,11 @@ end; +function TRuleController.IsSupportedDataType(const dataType: TDataType): Boolean; +begin + Result := True; +end; + { TColumnRuleController } function TColumnRuleController.GetParameterValue(const name: string): Variant; @@ -172,8 +231,7 @@ DisplayLabel := _('Null Percentage'); Description:= _('Percentage of the null data. 100% means all ' + 'generated data will be null'); - ProposalLists := 0; - DataTypes := 0; + ProposalLists := []; end; end; Deleted: branches/gui/src/ui/controllers/RuleControllerFactory.pas =================================================================== --- branches/gui/src/ui/controllers/RuleControllerFactory.pas 2006-12-30 17:42:00 UTC (rev 243) +++ branches/gui/src/ui/controllers/RuleControllerFactory.pas 2007-01-01 20:40:06 UTC (rev 244) @@ -1,60 +0,0 @@ -unit RuleControllerFactory; -interface -uses Classes, DG_Database, RuleController, DG_Types; -type - - TRuleControllerFactory = class - public - class function CreateRuleController(const columnName: string; const ruleStrategy: TGeneratorType): TRuleController; overload; - class function CreateRuleController(const rule: TDGColumnRule): TRuleController; overload; - end; - -implementation -uses gnugettext, SysUtils, DG_Generators, - AutoIncRuleController, CopyRuleController, - RangeRuleController, SQLRuleController, - PascalScriptRuleController, FixedRuleController, - SequenceRuleController,PatternRuleController, - CompositeRuleController; - -{ TRuleControllerFactory } -{ TODO 5 -ot-hex : Constructorlar\xFD teke d\xFC\xFE\xFCr } -class function TRuleControllerFactory.CreateRuleController( - const columnName: string; const ruleStrategy: TGeneratorType): TRuleController; -begin - case ruleStrategy of - gtRange: Result := TRangeRuleController.Create(ColumnName); - gtSQL: Result := TSQLRuleController.Create(ColumnName); - gtScript: Result := TPascalScriptRuleController.Create(ColumnName); - gtAutoInc: Result := TAutoIncRuleController.Create(ColumnName); - gtComposite: Result := TCompositeRuleController.Create(ColumnName); - gtFixed: Result := TFixedRuleController.Create(ColumnName); - gtCopy: Result := TCopyRuleController.Create(ColumnName); - gtSequence: Result := TSequenceRuleController.Create(ColumnName); - gtPattern: Result := TPatternRuleController.Create(ColumnName); -// gtVariable: ; - else - raise Exception.Create(Format(_('Cannot find controller for %s'),[GeneratorLocalName(ruleStrategy)])); - end; -end; - -class function TRuleControllerFactory.CreateRuleController( - const rule: TDGColumnRule): TRuleController; -begin - case rule.Strategy of - gtRange: Result := TRangeRuleController.Create(rule); - gtSQL: Result := TSQLRuleController.Create(rule); - gtScript: Result := TPascalScriptRuleController.Create(rule); - gtAutoInc: Result := TAutoIncRuleController.Create(rule); - gtComposite: Result := TCompositeRuleController.Create(rule); - gtFixed: Result := TFixedRuleController.Create(rule); - gtCopy: Result := TCopyRuleController.Create(rule); - gtSequence: Result := TSequenceRuleController.Create(rule); - gtPattern: Result := TPatternRuleController.Create(rule); -// gtVariable: ; - else - raise Exception.Create(Format(_('Cannot find controller for %s'),[GeneratorLocalName(rule.Strategy)])); - end; -end; - -end. Modified: branches/gui/src/ui/controllers/SQLRuleController.pas =================================================================== --- branches/gui/src/ui/controllers/SQLRuleController.pas 2006-12-30 17:42:00 UTC (rev 243) +++ branches/gui/src/ui/controllers/SQLRuleController.pas 2007-01-01 20:40:06 UTC (rev 244) @@ -33,16 +33,14 @@ Description := _( 'Enter or select the refence of the database '+ 'in which SQL will be run.'); - ProposalLists := PL_COLUMNS; - DataTypes := 0; + ProposalLists := [plColumns]; end; with AddRuleParamViewData do begin key := 'sql'; DisplayLabel := _('SQL'); Description := _( 'Enter SQL. Double click to open the SQL Editor.'); - ProposalLists := PL_COLUMNS; - DataTypes := 0; + ProposalLists := [plColumns]; end; end; Modified: branches/gui/src/ui/controllers/SequenceRuleController.pas =================================================================== --- branches/gui/src/ui/controllers/SequenceRuleController.pas 2006-12-30 17:42:00 UTC (rev 243) +++ branches/gui/src/ui/controllers/SequenceRuleController.pas 2007-01-01 20:40:06 UTC (rev 244) @@ -8,6 +8,7 @@ procedure CreateColumnRule(const columnName: string); override; public procedure InitViewData; override; + function IsSupportedDataType(const dataType: TDataType): Boolean; override; end; implementation @@ -34,26 +35,29 @@ Description := _( 'Enter or select the target connection reference. '+ 'Defined sequence should exist in the connection.'); - ProposalLists := PL_CONNECTIONS; - DataTypes := 0; + ProposalLists := [plConnections]; end; with AddRuleParamViewData do begin key := 'sequence'; DisplayLabel := _('Sequence'); Description := _( 'Enter or select the sequence to be used.'); - ProposalLists := PL_SEQUENCES; - DataTypes := 0; + ProposalLists := [plSequences]; end; with AddRuleParamViewData do begin key := 'step'; DisplayLabel := _('Increment'); Description := _( 'Sequence is increased by the increment value.'); - ProposalLists := 0; - DataTypes := 0; + ProposalLists := []; end; end; +function TSequenceRuleController.IsSupportedDataType( + const dataType: TDataType): Boolean; +begin + Result := dataType in [dtInteger]; +end; + end. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <t-...@us...> - 2006-12-30 17:42:03
|
Revision: 243 http://svn.sourceforge.net/datagenerator/?rev=243&view=rev Author: t-hex Date: 2006-12-30 09:42:00 -0800 (Sat, 30 Dec 2006) Log Message: ----------- -goruntuleme isi tamamlandi gibi -otomatik tamamlama listelerinin calismasi kaldi -bir kac kural icin RuleController yazilacak Modified Paths: -------------- branches/gui/src/ui/DataGeneratorUI.dpr branches/gui/src/ui/FormColumnRule.dfm branches/gui/src/ui/FormColumnRule.pas branches/gui/src/ui/MainForm.pas branches/gui/src/ui/controllers/AutoIncRuleController.pas branches/gui/src/ui/controllers/CopyRuleController.pas branches/gui/src/ui/controllers/FixedRuleController.pas branches/gui/src/ui/controllers/PascalScriptRuleController.pas branches/gui/src/ui/controllers/PatternRuleController.pas branches/gui/src/ui/controllers/RangeRuleController.pas branches/gui/src/ui/controllers/RuleController.pas branches/gui/src/ui/controllers/RuleControllerFactory.pas branches/gui/src/ui/controllers/SQLRuleController.pas branches/gui/src/ui/controllers/SequenceRuleController.pas Modified: branches/gui/src/ui/DataGeneratorUI.dpr =================================================================== --- branches/gui/src/ui/DataGeneratorUI.dpr 2006-12-29 23:45:45 UTC (rev 242) +++ branches/gui/src/ui/DataGeneratorUI.dpr 2006-12-30 17:42:00 UTC (rev 243) @@ -39,7 +39,8 @@ RuleControllerFactory in 'controllers\RuleControllerFactory.pas', SequenceRuleController in 'controllers\SequenceRuleController.pas', SQLRuleController in 'controllers\SQLRuleController.pas', - FixedRuleController in 'controllers\FixedRuleController.pas'; + FixedRuleController in 'controllers\FixedRuleController.pas', + CompositeRuleController in 'controllers\CompositeRuleController.pas'; {$R *.res} {$R dgver.res} // required Modified: branches/gui/src/ui/FormColumnRule.dfm =================================================================== --- branches/gui/src/ui/FormColumnRule.dfm 2006-12-29 23:45:45 UTC (rev 242) +++ branches/gui/src/ui/FormColumnRule.dfm 2006-12-30 17:42:00 UTC (rev 243) @@ -6,25 +6,30 @@ ClientHeight = 362 ClientWidth = 387 OldCreateOrder = True + OnDestroy = FormDestroy PixelsPerInch = 96 TextHeight = 13 inherited Bevel1: TBevel Top = 317 Width = 370 + ExplicitTop = 317 + ExplicitWidth = 370 end object Label1: TLabel [1] - Left = 16 - Top = 56 + Left = 8 + Top = 55 Width = 49 Height = 13 Caption = 'Generator' end inherited btnOK: TButton Top = 326 + ExplicitTop = 326 end inherited btnCancel: TButton Top = 326 Cancel = True + ExplicitTop = 326 end object GroupBox1: TGroupBox Left = 8 @@ -66,7 +71,7 @@ Left = 8 Top = 79 Width = 369 - Height = 178 + Height = 162 ButtonStyle = bsTriangle DefaultNodeHeight = 21 EditDelay = 100 @@ -137,9 +142,9 @@ end object Panel1: TPanel Left = 8 - Top = 264 + Top = 247 Width = 369 - Height = 47 + Height = 64 Alignment = taLeftJustify Anchors = [akLeft, akTop, akRight, akBottom] BevelInner = bvLowered @@ -148,12 +153,14 @@ Left = 2 Top = 2 Width = 365 - Height = 43 + Height = 60 Align = alClient AutoSize = False - Color = clCream + Color = clBtnFace ParentColor = False WordWrap = True + ExplicitTop = 8 + ExplicitHeight = 37 end end object PopupMenu: TPopupMenu Modified: branches/gui/src/ui/FormColumnRule.pas =================================================================== --- branches/gui/src/ui/FormColumnRule.pas 2006-12-29 23:45:45 UTC (rev 242) +++ branches/gui/src/ui/FormColumnRule.pas 2006-12-30 17:42:00 UTC (rev 243) @@ -43,7 +43,6 @@ Node: PVirtualNode; Column: TColumnIndex; NewText: WideString); procedure ParamTreeListKeyUp(Sender: TObject; var Key: Word; Shift: TShiftState); - procedure FormClose(Sender: TObject; var Action: TCloseAction); procedure cbGeneratorTypeChange(Sender: TObject); procedure ParamTreeListChange(Sender: TBaseVirtualTree; Node: PVirtualNode); @@ -63,17 +62,23 @@ Node: PVirtualNode; Column: TColumnIndex; out EditLink: IVTEditLink); procedure NumberEditKeyPress(Sender: TObject; var Key: Char); procedure FormCreate(Sender: TObject); + procedure FormDestroy(Sender: TObject); private FRuleController : TRuleController; FCheckedNode : PVirtualNode; + FColumnName: String; procedure FillGeneratorCombo; procedure SetRuleController(const Value: TRuleController); + procedure SetColumnName(const Value: String); public procedure PerformPopupAction(ActionType : TActionType; Node: PVirtualNode); procedure FreeRuleController; - procedure UpdateParameterList; + procedure UpdateView; + function GetColumnRule: TDGColumnRule; property RuleController: TRuleController read FRuleController write SetRuleController; + property ColumnName: String read FColumnName write SetColumnName; end; + PNodeData = ^TNodeData; TNodeData = record key : string; @@ -140,18 +145,25 @@ FCheckedNode := nil; end; +procedure TfrmColumnRule.SetColumnName(const Value: String); +begin + FColumnName := Value; + lblFieldName.Caption := FColumnName; +end; + procedure TfrmColumnRule.SetRuleController(const Value: TRuleController); begin FRuleController := Value; - UpdateParameterList; + UpdateView; end; -procedure TfrmColumnRule.UpdateParameterList; +procedure TfrmColumnRule.UpdateView; var i: integer; Node: PVirtualNode; NodeData : PNodeData; begin + cbGeneratorType.ItemIndex := Ord(FRuleController.GetColumnRule.Strategy); ParamTreeList.Clear; for i := 0 to FRuleController.GetParameterCount-1 do with FRuleController do begin @@ -204,19 +216,12 @@ end; end; -procedure TfrmColumnRule.FormClose(Sender: TObject; - var Action: TCloseAction); -begin - Action := caFree; - FreeRuleController; -end; - procedure TfrmColumnRule.cbGeneratorTypeChange(Sender: TObject); begin inherited; if assigned(FRuleController) then - FRuleController.Free; - RuleController := TRuleControllerFactory.CreateRuleController(TGeneratorType(cbGeneratorType.ItemIndex)); + FreeRuleController; + RuleController := TRuleControllerFactory.CreateRuleController(ColumnName, TGeneratorType(cbGeneratorType.ItemIndex)); end; procedure TfrmColumnRule.ParamTreeListChange(Sender: TBaseVirtualTree; @@ -397,12 +402,25 @@ FillGeneratorCombo; end; +procedure TfrmColumnRule.FormDestroy(Sender: TObject); +begin + inherited; + FreeRuleController; +end; + procedure TfrmColumnRule.FreeRuleController; begin if assigned(FRuleController) then FRuleController.Free; end; +function TfrmColumnRule.GetColumnRule: TDGColumnRule; +begin + Result := nil; + if assigned(FRuleController) then + Result := FRuleController.GetColumnRule; +end; + procedure TfrmColumnRule.FillGeneratorCombo; var I: Integer; Modified: branches/gui/src/ui/MainForm.pas =================================================================== --- branches/gui/src/ui/MainForm.pas 2006-12-29 23:45:45 UTC (rev 242) +++ branches/gui/src/ui/MainForm.pas 2006-12-30 17:42:00 UTC (rev 243) @@ -412,8 +412,11 @@ Application.CreateForm(TfrmColumnRule, frmColumnRule); try try - frmColumnRule.RuleController := TRuleControllerFactory.CreateRuleController(ColumnRule); + if assigned(ColumnRule) then + frmColumnRule.RuleController := TRuleControllerFactory.CreateRuleController(ColumnRule); + frmColumnRule.ColumnName := ColumnName; ModalValue := frmColumnRule.ShowModal; + ColumnRule := frmColumnRule.GetColumnRule; if ModalValue = mrOK then begin if not Assigned(TableRule) then Modified: branches/gui/src/ui/controllers/AutoIncRuleController.pas =================================================================== --- branches/gui/src/ui/controllers/AutoIncRuleController.pas 2006-12-29 23:45:45 UTC (rev 242) +++ branches/gui/src/ui/controllers/AutoIncRuleController.pas 2006-12-30 17:42:00 UTC (rev 243) @@ -6,7 +6,7 @@ TAutoIncRuleController = class(TColumnRuleController) protected - procedure CreateColumnRule; override; + procedure CreateColumnRule(const columnName: string); override; public procedure InitViewData; override; end; @@ -15,10 +15,10 @@ uses gnugettext, DG_Database, DG_Types; { TAutoIncRuleController } -procedure TAutoIncRuleController.CreateColumnRule; +procedure TAutoIncRuleController.CreateColumnRule(const columnName: string); begin inherited; - FColumnRule := TDGColumnRule.Create(''); + FColumnRule := TDGColumnRule.Create(columnName); FColumnRule.Strategy := gtAutoInc; FColumnRule.NewParam('start','0'); FColumnRule.NewParam('step','1'); Modified: branches/gui/src/ui/controllers/CopyRuleController.pas =================================================================== --- branches/gui/src/ui/controllers/CopyRuleController.pas 2006-12-29 23:45:45 UTC (rev 242) +++ branches/gui/src/ui/controllers/CopyRuleController.pas 2006-12-30 17:42:00 UTC (rev 243) @@ -6,7 +6,7 @@ TCopyRuleController = class(TColumnRuleController) protected - procedure CreateColumnRule; override; + procedure CreateColumnRule(const columnName: string); override; public procedure InitViewData; override; end; @@ -15,10 +15,10 @@ uses gnugettext, DG_Database, DG_Types; { TCopyRuleController } -procedure TCopyRuleController.CreateColumnRule; +procedure TCopyRuleController.CreateColumnRule(const columnName: string); begin inherited; - FColumnRule := TDGColumnRule.Create(''); + FColumnRule := TDGColumnRule.Create(columnName); FColumnRule.Strategy := gtCopy; FColumnRule.NewParam('',''); end; Modified: branches/gui/src/ui/controllers/FixedRuleController.pas =================================================================== --- branches/gui/src/ui/controllers/FixedRuleController.pas 2006-12-29 23:45:45 UTC (rev 242) +++ branches/gui/src/ui/controllers/FixedRuleController.pas 2006-12-30 17:42:00 UTC (rev 243) @@ -5,7 +5,7 @@ type TFixedRuleController = class(TColumnRuleController) protected - procedure CreateColumnRule; override; + procedure CreateColumnRule(const columnName: string); override; public procedure InitViewData; override; end; @@ -14,10 +14,10 @@ { TFixedRuleController } -procedure TFixedRuleController.CreateColumnRule; +procedure TFixedRuleController.CreateColumnRule(const columnName: string); begin inherited; - FColumnRule := TDGColumnRule.Create(''); + FColumnRule := TDGColumnRule.Create(columnName); FColumnRule.Strategy := gtPattern; FColumnRule.NewParam('',''); end; Modified: branches/gui/src/ui/controllers/PascalScriptRuleController.pas =================================================================== --- branches/gui/src/ui/controllers/PascalScriptRuleController.pas 2006-12-29 23:45:45 UTC (rev 242) +++ branches/gui/src/ui/controllers/PascalScriptRuleController.pas 2006-12-30 17:42:00 UTC (rev 243) @@ -5,7 +5,7 @@ type TPascalScriptRuleController = class(TColumnRuleController) protected - procedure CreateColumnRule; override; + procedure CreateColumnRule(const columnName: string); override; public procedure InitViewData; override; end; @@ -14,10 +14,10 @@ { TPascalScriptRuleController } -procedure TPascalScriptRuleController.CreateColumnRule; +procedure TPascalScriptRuleController.CreateColumnRule(const columnName: string); begin inherited; - FColumnRule := TDGColumnRule.Create(''); + FColumnRule := TDGColumnRule.Create(columnName); FColumnRule.Strategy := gtScript; FColumnRule.NewParam('',''); end; Modified: branches/gui/src/ui/controllers/PatternRuleController.pas =================================================================== --- branches/gui/src/ui/controllers/PatternRuleController.pas 2006-12-29 23:45:45 UTC (rev 242) +++ branches/gui/src/ui/controllers/PatternRuleController.pas 2006-12-30 17:42:00 UTC (rev 243) @@ -5,7 +5,7 @@ type TPatternRuleController = class(TColumnRuleController) protected - procedure CreateColumnRule; override; + procedure CreateColumnRule(const columnName: string); override; public procedure InitViewData; override; end; @@ -14,10 +14,10 @@ { TPatternRuleController } -procedure TPatternRuleController.CreateColumnRule; +procedure TPatternRuleController.CreateColumnRule(const columnName: string); begin inherited; - FColumnRule := TDGColumnRule.Create(''); + FColumnRule := TDGColumnRule.Create(columnName); FColumnRule.Strategy := gtPattern; FColumnRule.NewParam('',''); end; Modified: branches/gui/src/ui/controllers/RangeRuleController.pas =================================================================== --- branches/gui/src/ui/controllers/RangeRuleController.pas 2006-12-29 23:45:45 UTC (rev 242) +++ branches/gui/src/ui/controllers/RangeRuleController.pas 2006-12-30 17:42:00 UTC (rev 243) @@ -5,7 +5,7 @@ type TRangeRuleController = class(TColumnRuleController) protected - procedure CreateColumnRule; override; + procedure CreateColumnRule(const columnName: string); override; public procedure InitViewData; override; end; @@ -15,10 +15,10 @@ { TRangeRuleController } -procedure TRangeRuleController.CreateColumnRule; +procedure TRangeRuleController.CreateColumnRule(const columnName: string); begin inherited; - FColumnRule := TDGColumnRule.Create(''); + FColumnRule := TDGColumnRule.Create(columnName); FColumnRule.Strategy := gtRange; FColumnRule.NewParam('','1'); FColumnRule.NewParam('',''); Modified: branches/gui/src/ui/controllers/RuleController.pas =================================================================== --- branches/gui/src/ui/controllers/RuleController.pas 2006-12-29 23:45:45 UTC (rev 242) +++ branches/gui/src/ui/controllers/RuleController.pas 2006-12-30 17:42:00 UTC (rev 243) @@ -32,10 +32,10 @@ FColumnRule : TDGColumnRule; FRuleParamViewDatas: TList; // creates columnRule if it is not given in the constructor - procedure CreateColumnRule;virtual; abstract; + procedure CreateColumnRule(const columnName: string);virtual; abstract; public constructor Create(const columnRule: TDGColumnRule); overload; virtual; - constructor Create(const columnName: String =''); overload; virtual; + constructor Create(const columnName: String); overload; virtual; destructor Destroy; override; function GetParameterCount: Integer; virtual; @@ -68,7 +68,7 @@ begin if columnRule <> nil then FColumnRule := columnRule; - Create; + Create(FColumnRule.ColumnName); end; function TRuleController.AddRuleParamViewData: TRuleParamViewData; @@ -80,11 +80,11 @@ Result := itm; end; -constructor TRuleController.Create(const columnName: String =''); +constructor TRuleController.Create(const columnName: String); begin FRuleParamViewDatas := TList.Create; if FColumnRule = nil then - CreateColumnRule; + CreateColumnRule(columnName); InitViewData; end; @@ -93,7 +93,7 @@ I: Integer; begin for I := 0 to FRuleParamViewDatas.Count - 1 do - Dispose(FRuleParamViewDatas[i]); + TRuleParamViewData(FRuleParamViewDatas[i]).Free; FRuleParamViewDatas.Free; inherited; end; Modified: branches/gui/src/ui/controllers/RuleControllerFactory.pas =================================================================== --- branches/gui/src/ui/controllers/RuleControllerFactory.pas 2006-12-29 23:45:45 UTC (rev 242) +++ branches/gui/src/ui/controllers/RuleControllerFactory.pas 2006-12-30 17:42:00 UTC (rev 243) @@ -5,7 +5,7 @@ TRuleControllerFactory = class public - class function CreateRuleController(const ruleStrategy: TGeneratorType): TRuleController; overload; + class function CreateRuleController(const columnName: string; const ruleStrategy: TGeneratorType): TRuleController; overload; class function CreateRuleController(const rule: TDGColumnRule): TRuleController; overload; end; @@ -14,23 +14,24 @@ AutoIncRuleController, CopyRuleController, RangeRuleController, SQLRuleController, PascalScriptRuleController, FixedRuleController, - SequenceRuleController,PatternRuleController; + SequenceRuleController,PatternRuleController, + CompositeRuleController; { TRuleControllerFactory } { TODO 5 -ot-hex : Constructorlar\xFD teke d\xFC\xFE\xFCr } class function TRuleControllerFactory.CreateRuleController( - const ruleStrategy: TGeneratorType): TRuleController; + const columnName: string; const ruleStrategy: TGeneratorType): TRuleController; begin case ruleStrategy of - gtRange: Result := TRangeRuleController.Create; - gtSQL: Result := TSQLRuleController.Create; - gtScript: Result := TPascalScriptRuleController.Create; - gtAutoInc: Result := TAutoIncRuleController.Create; -// gtComposite: ; - gtFixed: Result := TFixedRuleController.Create; - gtCopy: Result := TCopyRuleController.Create; - gtSequence: Result := TSequenceRuleController.Create; - gtPattern: Result := TPatternRuleController.Create; + gtRange: Result := TRangeRuleController.Create(ColumnName); + gtSQL: Result := TSQLRuleController.Create(ColumnName); + gtScript: Result := TPascalScriptRuleController.Create(ColumnName); + gtAutoInc: Result := TAutoIncRuleController.Create(ColumnName); + gtComposite: Result := TCompositeRuleController.Create(ColumnName); + gtFixed: Result := TFixedRuleController.Create(ColumnName); + gtCopy: Result := TCopyRuleController.Create(ColumnName); + gtSequence: Result := TSequenceRuleController.Create(ColumnName); + gtPattern: Result := TPatternRuleController.Create(ColumnName); // gtVariable: ; else raise Exception.Create(Format(_('Cannot find controller for %s'),[GeneratorLocalName(ruleStrategy)])); @@ -45,7 +46,7 @@ gtSQL: Result := TSQLRuleController.Create(rule); gtScript: Result := TPascalScriptRuleController.Create(rule); gtAutoInc: Result := TAutoIncRuleController.Create(rule); -// gtComposite: ; + gtComposite: Result := TCompositeRuleController.Create(rule); gtFixed: Result := TFixedRuleController.Create(rule); gtCopy: Result := TCopyRuleController.Create(rule); gtSequence: Result := TSequenceRuleController.Create(rule); Modified: branches/gui/src/ui/controllers/SQLRuleController.pas =================================================================== --- branches/gui/src/ui/controllers/SQLRuleController.pas 2006-12-29 23:45:45 UTC (rev 242) +++ branches/gui/src/ui/controllers/SQLRuleController.pas 2006-12-30 17:42:00 UTC (rev 243) @@ -5,7 +5,7 @@ type TSQLRuleController = class(TColumnRuleController) protected - procedure CreateColumnRule; override; + procedure CreateColumnRule(const columnName: string); override; public procedure InitViewData; override; end; @@ -15,10 +15,10 @@ { TSQLRuleController } -procedure TSQLRuleController.CreateColumnRule; +procedure TSQLRuleController.CreateColumnRule(const columnName: string); begin inherited; - FColumnRule := TDGColumnRule.Create(''); + FColumnRule := TDGColumnRule.Create(columnName); FColumnRule.Strategy := gtSQL; FColumnRule.NewParam('dbref',''); FColumnRule.NewParam('sql',''); Modified: branches/gui/src/ui/controllers/SequenceRuleController.pas =================================================================== --- branches/gui/src/ui/controllers/SequenceRuleController.pas 2006-12-29 23:45:45 UTC (rev 242) +++ branches/gui/src/ui/controllers/SequenceRuleController.pas 2006-12-30 17:42:00 UTC (rev 243) @@ -5,7 +5,7 @@ type TSequenceRuleController = class(TColumnRuleController) protected - procedure CreateColumnRule; override; + procedure CreateColumnRule(const columnName: string); override; public procedure InitViewData; override; end; @@ -15,10 +15,10 @@ { TSequenceRuleController } -procedure TSequenceRuleController.CreateColumnRule; +procedure TSequenceRuleController.CreateColumnRule(const columnName: string); begin inherited; - FColumnRule := TDGColumnRule.Create(''); + FColumnRule := TDGColumnRule.Create(columnName); FColumnRule.Strategy := gtSequence; FColumnRule.NewParam('dbref',''); FColumnRule.NewParam('sequence',''); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <t-...@us...> - 2006-12-29 23:45:47
|
Revision: 242 http://svn.sourceforge.net/datagenerator/?rev=242&view=rev Author: t-hex Date: 2006-12-29 15:45:45 -0800 (Fri, 29 Dec 2006) Log Message: ----------- Modified Paths: -------------- branches/gui/src/ui/FormColumnRule.dfm branches/gui/src/ui/FormColumnRule.pas branches/gui/src/ui/MainForm.dfm branches/gui/src/ui/controllers/AutoIncRuleController.pas branches/gui/src/ui/controllers/CopyRuleController.pas branches/gui/src/ui/controllers/FixedRuleController.pas branches/gui/src/ui/controllers/PascalScriptRuleController.pas branches/gui/src/ui/controllers/PatternRuleController.pas branches/gui/src/ui/controllers/RangeRuleController.pas branches/gui/src/ui/controllers/RuleController.pas branches/gui/src/ui/controllers/SQLRuleController.pas branches/gui/src/ui/controllers/SequenceRuleController.pas Modified: branches/gui/src/ui/FormColumnRule.dfm =================================================================== --- branches/gui/src/ui/FormColumnRule.dfm 2006-12-29 18:09:36 UTC (rev 241) +++ branches/gui/src/ui/FormColumnRule.dfm 2006-12-29 23:45:45 UTC (rev 242) @@ -11,8 +11,6 @@ inherited Bevel1: TBevel Top = 317 Width = 370 - ExplicitTop = 317 - ExplicitWidth = 370 end object Label1: TLabel [1] Left = 16 @@ -21,21 +19,12 @@ Height = 13 Caption = 'Generator' end - object lblNullPercentage: TLabel [2] - Left = 16 - Top = 80 - Width = 75 - Height = 13 - Caption = 'Null Percentage' - end inherited btnOK: TButton Top = 326 - ExplicitTop = 326 end inherited btnCancel: TButton Top = 326 Cancel = True - ExplicitTop = 326 end object GroupBox1: TGroupBox Left = 8 @@ -75,9 +64,9 @@ end object ParamTreeList: TVirtualStringTree Left = 8 - Top = 104 + Top = 79 Width = 369 - Height = 153 + Height = 178 ButtonStyle = bsTriangle DefaultNodeHeight = 21 EditDelay = 100 @@ -167,23 +156,6 @@ WordWrap = True end end - object edtNullPercentage: TEdit - Left = 120 - Top = 75 - Width = 49 - Height = 21 - TabOrder = 6 - Text = '0' - OnKeyPress = NumberEditKeyPress - end - object udsNullPercentage: TUpDown - Left = 169 - Top = 75 - Width = 16 - Height = 21 - Associate = edtNullPercentage - TabOrder = 7 - end object PopupMenu: TPopupMenu OnChange = PopupMenuChange Left = 288 Modified: branches/gui/src/ui/FormColumnRule.pas =================================================================== --- branches/gui/src/ui/FormColumnRule.pas 2006-12-29 18:09:36 UTC (rev 241) +++ branches/gui/src/ui/FormColumnRule.pas 2006-12-29 23:45:45 UTC (rev 242) @@ -27,9 +27,6 @@ Panel1: TPanel; lblInfo: TLabel; miList: TMenuItem; - lblNullPercentage: TLabel; - edtNullPercentage: TEdit; - udsNullPercentage: TUpDown; procedure ParamTreeListInitNode(Sender: TBaseVirtualTree; ParentNode, Node: PVirtualNode; var InitialStates: TVirtualNodeInitStates); procedure ParamTreeListGetText(Sender: TBaseVirtualTree; @@ -77,11 +74,9 @@ procedure UpdateParameterList; property RuleController: TRuleController read FRuleController write SetRuleController; end; - - PParamData = ^TParamData; - TParamData = record - Tip : String; - ListType: TListType; + PNodeData = ^TNodeData; + TNodeData = record + key : string; end; var @@ -100,23 +95,26 @@ ParentNode, Node: PVirtualNode; var InitialStates: TVirtualNodeInitStates); var - ParamData : PParamData; + ParamData : PNodeData; begin inherited; ParamData := Sender.GetNodeData(Node); - if ParamData.ListType = ltNone then - Node.CheckType := ctButton; +// if ParamData.ListType = ltNone then +// Node.CheckType := ctButton; end; procedure TfrmColumnRule.ParamTreeListGetText(Sender: TBaseVirtualTree; Node: PVirtualNode; Column: TColumnIndex; TextType: TVSTTextType; var CellText: WideString); +var + ParamData: PNodeData; begin inherited; + ParamData := Sender.GetNodeData(Node); if TextType = ttNormal then case Column of - 0 : Celltext := FRuleController.GetParameterData(Node.Index).DisplayLabel; - 1 : Celltext := FRuleController.GetParameterValue(Node.Index); + 0 : Celltext := FRuleController.GetParamViewData(Node.Index).DisplayLabel; + 1 : Celltext := FRuleController.GetParameterValue(ParamData.key); end; end; @@ -151,16 +149,15 @@ procedure TfrmColumnRule.UpdateParameterList; var i: integer; - Node : PVirtualNode; - NodeData : PParamData; + Node: PVirtualNode; + NodeData : PNodeData; begin - for i := 0 to FRuleController.GetParameterCount - 1 do - with FRuleController,FRuleController.GetParameterData(i) do - begin + ParamTreeList.Clear; + for i := 0 to FRuleController.GetParameterCount-1 do + with FRuleController do begin Node := ParamTreeList.AddChild(nil); NodeData := ParamTreeList.GetNodeData(Node); - NodeData.Tip := Name; - NodeData.ListType:= ltNone; //TODO fix this + NodeData.key := FRuleController.GetParamViewData(i).key; end; end; @@ -179,14 +176,17 @@ Sender: TBaseVirtualTree; var NodeDataSize: Integer); begin inherited; - NodeDataSize := Sizeof(TParamData); + NodeDataSize := Sizeof(TNodeData); end; procedure TfrmColumnRule.ParamTreeListNewText(Sender: TBaseVirtualTree; Node: PVirtualNode; Column: TColumnIndex; NewText: WideString); +var + ParamData: PNodeData; begin inherited; - FRuleController.SetParameterValue(Node.Index,Newtext); + ParamData := sender.GetNodeData(Node); + FRuleController.SetParameterValue(ParamData.key,Newtext); end; procedure TfrmColumnRule.ParamTreeListKeyUp(Sender: TObject; var Key: Word; @@ -216,9 +216,7 @@ inherited; if assigned(FRuleController) then FRuleController.Free; - RuleController := TRuleControllerFactory.CreateRuleController(TGeneratorType(cbGeneratorType.ItemIndex)); - ParamTreeList.Clear; end; procedure TfrmColumnRule.ParamTreeListChange(Sender: TBaseVirtualTree; @@ -226,13 +224,13 @@ begin inherited; if Node = nil then exit; - lblInfo.Caption := FRuleController.GetParameterData(Node.Index).Description; + lblInfo.Caption := FRuleController.GetParamViewData(Node.Index).description; end; procedure TfrmColumnRule.ParamTreeListDblClick(Sender: TObject); var Node: PVirtualNode; - NodeParamData : PParamData; + NodeParamData : PNodeData; begin inherited; if ParamTreeList.FocusedColumn <> 1 then exit; @@ -241,10 +239,10 @@ if Node = nil then exit; NodeParamData := ParamTreeList.GetNodeData(Node); { TODO 1 -ot-hex : Somehow the following code should be more simple } - if NodeParamData.Tip = 'file' then PerformPopupAction(atFile,Node); - if NodeParamData.Tip = 'script' then PerformPopupAction(atScript,Node); - if NodeParamData.Tip = 'sql' then PerformPopupAction(atSQL,Node); - if NodeParamData.Tip = 'list' then PerformPopupAction(atList,Node); +// if NodeParamData.Tip = 'file' then PerformPopupAction(atFile,Node); +// if NodeParamData.Tip = 'script' then PerformPopupAction(atScript,Node); +// if NodeParamData.Tip = 'sql' then PerformPopupAction(atSQL,Node); +// if NodeParamData.Tip = 'list' then PerformPopupAction(atList,Node); end; procedure TfrmColumnRule.ParamTreeListKeyAction(Sender: TBaseVirtualTree; @@ -259,7 +257,7 @@ procedure TfrmColumnRule.PerformPopupAction(ActionType: TActionType; Node: PVirtualNode); var - ParamData : PParamData; + ParamData : PNodeData; begin { DONE : FIXME: Paramdata.tip sometimes gets wrong type, not selected. } ParamData := ParamTreeList.GetNodeData(Node); @@ -268,17 +266,17 @@ ParamTreeList.EditNode(FCheckedNode, 1); end; atFile : begin - ParamOpenDialog.FileName := FRuleController.GetParameterValue(Node.Index); + ParamOpenDialog.FileName := FRuleController.GetParameterValue(ParamData.key); if ParamOpenDialog.Execute then begin - FRuleController.SetParameterValue(Node.Index,ParamOpenDialog.FileName); + FRuleController.SetParameterValue(ParamData.key,ParamOpenDialog.FileName); end; end; atScript, atSQL, atList : begin Application.CreateForm(TfrmEditor, frmEditor); try - frmEditor.Text := FRuleController.GetParameterValue(Node.Index); + frmEditor.Text := FRuleController.GetParameterValue(ParamData.key); case ActionType of atScript: frmEditor.TextType := ttPascalScript; atSQL: frmEditor.TextType := ttSQL; @@ -286,10 +284,10 @@ end; if frmEditor.ShowModal = mrOk then begin - if ActionType = atScript then ParamData.Tip := 'script'; - if ActionType = atSQL then ParamData.Tip := 'sql'; - if ActionType = atList then ParamData.Tip := 'list'; - FRuleController.SetParameterValue(Node.Index,frmEditor.Text); +// if ActionType = atScript then ParamData.Tip := 'script'; +// if ActionType = atSQL then ParamData.Tip := 'sql'; +// if ActionType = atList then ParamData.Tip := 'list'; + FRuleController.SetParameterValue(ParamData.key,frmEditor.Text); end; finally frmEditor.Free; @@ -302,10 +300,13 @@ procedure TfrmColumnRule.ParamTreeListGetHint(Sender: TBaseVirtualTree; Node: PVirtualNode; Column: TColumnIndex; var LineBreakStyle: TVTTooltipLineBreakStyle; var HintText: WideString); +var + ParamData: PNodeData; begin inherited; if Column <> 1 then exit; - HintText := FRuleController.GetParameterValue(Node.Index); + ParamData := sender.GetNodeData(Node); + HintText := FRuleController.GetParameterValue(ParamData.key); end; procedure TfrmColumnRule.ParamTreeListEditing(Sender: TBaseVirtualTree; @@ -327,7 +328,7 @@ Sender: TBaseVirtualTree; Node: PVirtualNode; Column: TColumnIndex; out EditLink: IVTEditLink); var - ParamData : PParamData; + ParamData : PNodeData; Items : TStringList; ConnProp : TDGConnectionProperty; tmpConnection : TZConnection; @@ -336,49 +337,49 @@ begin inherited; ParamData := Sender.GetNodeData(Node); - if ParamData.ListType = ltReference then - begin - Items := TStringList.Create; - try - for i := 0 to frmMain.Configuration.ConnectionProperties.Count - 1 do - begin - ConnProp := TDGConnectionProperty(frmMain.Configuration.ConnectionProperties[I]); - Items.Add(ConnProp.Ref); - end; - EditLink := TComboBoxEditLink.Create(Items); - finally - Items.Free; - end; - end; - - if ParamData.ListType = ltSequence then - begin - // Previous node gives the connection reference - ParamData := Sender.GetNodeData(Node.PrevSibling); - ConnProp := frmMain.Configuration.FindConnectionProperty(FRuleController.GetParameterValue((Node.Index))); - if Assigned(ConnProp) then - begin - //create connection - tmpConnection := CreateConnection(ConnProp); - try - tmpConnection.Connect; - - //get sequence list - SequenceRS:=tmpConnection.DbcConnection.GetMetadata.GetSequences('','',''); - Items := TStringList.Create; - try - while SequenceRS.Next do - Items.Add(SequenceRS.GetString(3)); - EditLink := TComboBoxEditLink.Create(Items); - finally - Items.Free; - end; - finally - tmpConnection.Disconnect; - tmpConnection.Free; - end; - end; - end; +// if ParamData.ListType = ltReference then +// begin +// Items := TStringList.Create; +// try +// for i := 0 to frmMain.Configuration.ConnectionProperties.Count - 1 do +// begin +// ConnProp := TDGConnectionProperty(frmMain.Configuration.ConnectionProperties[I]); +// Items.Add(ConnProp.Ref); +// end; +// EditLink := TComboBoxEditLink.Create(Items); +// finally +// Items.Free; +// end; +// end; +// +// if ParamData.ListType = ltSequence then +// begin +// // Previous node gives the connection reference +// ParamData := Sender.GetNodeData(Node.PrevSibling); +// ConnProp := frmMain.Configuration.FindConnectionProperty(FRuleController.GetParameterValue((Node.Index))); +// if Assigned(ConnProp) then +// begin +// //create connection +// tmpConnection := CreateConnection(ConnProp); +// try +// tmpConnection.Connect; +// +// //get sequence list +// SequenceRS:=tmpConnection.DbcConnection.GetMetadata.GetSequences('','',''); +// Items := TStringList.Create; +// try +// while SequenceRS.Next do +// Items.Add(SequenceRS.GetString(3)); +// EditLink := TComboBoxEditLink.Create(Items); +// finally +// Items.Free; +// end; +// finally +// tmpConnection.Disconnect; +// tmpConnection.Free; +// end; +// end; +// end; if not assigned(EditLink) then EditLink := TStringEditLink.Create; end; Modified: branches/gui/src/ui/MainForm.dfm =================================================================== --- branches/gui/src/ui/MainForm.dfm 2006-12-29 18:09:36 UTC (rev 241) +++ branches/gui/src/ui/MainForm.dfm 2006-12-29 23:45:45 UTC (rev 242) @@ -70,7 +70,7 @@ item MinWidth = 280 Position = 0 - Width = 365 + Width = 369 WideText = 'Name' end item Modified: branches/gui/src/ui/controllers/AutoIncRuleController.pas =================================================================== --- branches/gui/src/ui/controllers/AutoIncRuleController.pas 2006-12-29 18:09:36 UTC (rev 241) +++ branches/gui/src/ui/controllers/AutoIncRuleController.pas 2006-12-29 23:45:45 UTC (rev 242) @@ -4,12 +4,11 @@ uses Classes, DG_Core, RuleController; type - TAutoIncRuleController = class(TRuleController) + TAutoIncRuleController = class(TColumnRuleController) protected procedure CreateColumnRule; override; public - function GetParameterCount: Integer; override; - function GetParameterData(const i: Integer): TRuleParamDisplayData; override; + procedure InitViewData; override; end; implementation @@ -25,30 +24,23 @@ FColumnRule.NewParam('step','1'); end; -function TAutoIncRuleController.GetParameterCount: Integer; +procedure TAutoIncRuleController.InitViewData; begin - Result := FColumnRule.Params.Count; + inherited; + with AddRuleParamViewData do begin + key := 'start'; + DisplayLabel:= _('Start'); + Description := _('Enter the starting value'); + DataTypes := 0; + ProposalLists := 0; + end; + with AddRuleParamViewData do begin + key := 'step'; + DisplayLabel:= _('Step'); + Description := _('Enter the increment amount'); + DataTypes := 0; + ProposalLists := 0; + end; end; -function TAutoIncRuleController.GetParameterData( - const i: Integer): TRuleParamDisplayData; -begin - case i of - 0: with Result do begin - Name := 'start'; - DisplayLabel:= _('Start'); - Description := _('Enter the starting value'); - DataTypes := 0; - ProposalLists := []; - end; - 1: with Result do begin - Name := 'step'; - DisplayLabel:= _('Step'); - Description := _('Enter the increment amount'); - DataTypes := 0; - ProposalLists := []; - end; - end; -end; - end. Modified: branches/gui/src/ui/controllers/CopyRuleController.pas =================================================================== --- branches/gui/src/ui/controllers/CopyRuleController.pas 2006-12-29 18:09:36 UTC (rev 241) +++ branches/gui/src/ui/controllers/CopyRuleController.pas 2006-12-29 23:45:45 UTC (rev 242) @@ -4,12 +4,11 @@ uses Classes, DG_Core, RuleController; type - TCopyRuleController = class(TRuleController) + TCopyRuleController = class(TColumnRuleController) protected procedure CreateColumnRule; override; public - function GetParameterCount: Integer; override; - function GetParameterData(const i: Integer): TRuleParamDisplayData; override; + procedure InitViewData; override; end; implementation @@ -24,23 +23,16 @@ FColumnRule.NewParam('',''); end; -function TCopyRuleController.GetParameterCount: Integer; +procedure TCopyRuleController.InitViewData; begin - Result := 1; + inherited; + with AddRuleParamViewData do begin + key := 'column'; + DisplayLabel:= _('Start'); + Description := _('Enter the source column to be copied.'); + DataTypes := 0; + ProposalLists := PL_COLUMNS; + end; end; -function TCopyRuleController.GetParameterData( - const i: Integer): TRuleParamDisplayData; -begin - case i of - 0: with Result do begin - Name := 'column'; - DisplayLabel:= _('Start'); - Description := _('Enter the source column to be copied.'); - DataTypes := 0; - ProposalLists := [plColumns]; - end; - end; -end; - end. Modified: branches/gui/src/ui/controllers/FixedRuleController.pas =================================================================== --- branches/gui/src/ui/controllers/FixedRuleController.pas 2006-12-29 18:09:36 UTC (rev 241) +++ branches/gui/src/ui/controllers/FixedRuleController.pas 2006-12-29 23:45:45 UTC (rev 242) @@ -3,13 +3,11 @@ interface uses Classes, DG_Core, RuleController; type - TFixedRuleController = class(TRuleController) + TFixedRuleController = class(TColumnRuleController) protected procedure CreateColumnRule; override; public - function GetParameterData(const i: Integer): TRuleParamDisplayData; - override; - function GetParameterCount: Integer; override; + procedure InitViewData; override; end; implementation uses gnugettext, DG_Database, DG_Types; @@ -24,23 +22,16 @@ FColumnRule.NewParam('',''); end; -function TFixedRuleController.GetParameterCount: Integer; +procedure TFixedRuleController.InitViewData; begin - Result := 1; -end; - -function TFixedRuleController.GetParameterData( - const i: Integer): TRuleParamDisplayData; -begin - case i of - 0: with Result do begin - Name := 'value'; - DisplayLabel := _('Value'); - Description := _( - 'Enter the fixed value. All the generated rows will have the same value.'); - ProposalLists := []; - DataTypes := 0; - end; + inherited; + with AddRuleParamViewData do begin + key := 'value'; + DisplayLabel := _('Value'); + Description := _( + 'Enter the fixed value. All the generated rows will have the same value.'); + ProposalLists := PL_COLUMNS; + DataTypes := 0; end; end; Modified: branches/gui/src/ui/controllers/PascalScriptRuleController.pas =================================================================== --- branches/gui/src/ui/controllers/PascalScriptRuleController.pas 2006-12-29 18:09:36 UTC (rev 241) +++ branches/gui/src/ui/controllers/PascalScriptRuleController.pas 2006-12-29 23:45:45 UTC (rev 242) @@ -3,13 +3,11 @@ interface uses Classes, DG_Core, RuleController; type - TPascalScriptRuleController = class(TRuleController) + TPascalScriptRuleController = class(TColumnRuleController) protected procedure CreateColumnRule; override; public - function GetParameterData(const i: Integer): TRuleParamDisplayData; - override; - function GetParameterCount: Integer; override; + procedure InitViewData; override; end; implementation uses gnugettext, DG_Database, DG_Types; @@ -24,23 +22,16 @@ FColumnRule.NewParam('',''); end; -function TPascalScriptRuleController.GetParameterCount: Integer; +procedure TPascalScriptRuleController.InitViewData; begin - Result := 1; -end; - -function TPascalScriptRuleController.GetParameterData( - const i: Integer): TRuleParamDisplayData; -begin - case i of - 0: with Result do begin - Name := 'script'; - DisplayLabel := _('Script'); - Description := _( - 'Enter Pascal Script. Double click to open Script editor.'); - ProposalLists := []; - DataTypes := 0; - end; + inherited; + with AddRuleParamViewData do begin + key := 'script'; + DisplayLabel := _('Script'); + Description := _( + 'Enter Pascal Script. Double click to open Script editor.'); + ProposalLists := PL_COLUMNS; + DataTypes := 0; end; end; Modified: branches/gui/src/ui/controllers/PatternRuleController.pas =================================================================== --- branches/gui/src/ui/controllers/PatternRuleController.pas 2006-12-29 18:09:36 UTC (rev 241) +++ branches/gui/src/ui/controllers/PatternRuleController.pas 2006-12-29 23:45:45 UTC (rev 242) @@ -3,13 +3,11 @@ interface uses Classes, DG_Core, RuleController; type - TPatternRuleController = class(TRuleController) + TPatternRuleController = class(TColumnRuleController) protected procedure CreateColumnRule; override; public - function GetParameterData(const i: Integer): TRuleParamDisplayData; - override; - function GetParameterCount: Integer; override; + procedure InitViewData; override; end; implementation uses gnugettext, DG_Database, DG_Types; @@ -24,23 +22,16 @@ FColumnRule.NewParam('',''); end; -function TPatternRuleController.GetParameterCount: Integer; +procedure TPatternRuleController.InitViewData; begin - Result := 1; -end; - -function TPatternRuleController.GetParameterData( - const i: Integer): TRuleParamDisplayData; -begin - case i of - 0: with Result do begin - Name := 'pattern'; - DisplayLabel := _('Pattern'); - Description := _( - 'Enter the pattern that will be used to generate data.'); - ProposalLists := []; - DataTypes := 0; - end; + inherited; + with AddRuleParamViewData do begin + key := 'pattern'; + DisplayLabel := _('Pattern'); + Description := _( + 'Enter the pattern that will be used to generate data.'); + ProposalLists := 0; + DataTypes := 0; end; end; Modified: branches/gui/src/ui/controllers/RangeRuleController.pas =================================================================== --- branches/gui/src/ui/controllers/RangeRuleController.pas 2006-12-29 18:09:36 UTC (rev 241) +++ branches/gui/src/ui/controllers/RangeRuleController.pas 2006-12-29 23:45:45 UTC (rev 242) @@ -3,13 +3,11 @@ interface uses Classes, DG_Core, RuleController; type - TRangeRuleController = class(TRuleController) + TRangeRuleController = class(TColumnRuleController) protected procedure CreateColumnRule; override; public - function GetParameterData(const i: Integer): TRuleParamDisplayData; - override; - function GetParameterCount: Integer; override; + procedure InitViewData; override; end; implementation @@ -26,36 +24,29 @@ FColumnRule.NewParam('',''); end; -function TRangeRuleController.GetParameterCount: Integer; +procedure TRangeRuleController.InitViewData; begin - Result := 2; + inherited; + with AddRuleParamViewData do begin + key := 'min'; + DisplayLabel := _('Minimum'); + Description := _( + 'Enter the possible minimum value. If you enter a column '+ + 'name then the minimum value will be the generated value '+ + 'for that column'); + ProposalLists := PL_COLUMNS; + DataTypes := 0; + end; + with AddRuleParamViewData do begin + key := 'max'; + DisplayLabel := _('Maximum'); + Description := _( + 'Enter the possible maximum value. If you enter a column '+ + 'name then the maximum value will be the generated value '+ + 'for that column'); + ProposalLists := PL_COLUMNS; + DataTypes := 0; + end; end; -function TRangeRuleController.GetParameterData( - const i: Integer): TRuleParamDisplayData; -begin - case i of - 0: with Result do begin - Name := 'min'; - DisplayLabel := _('Minimum'); - Description := _( - 'Enter the possible minimum value. If you enter a column '+ - 'name then the minimum value will be the generated value '+ - 'for that column'); - ProposalLists := [plColumns]; - DataTypes := 0; - end; - 1: with Result do begin - Name := 'max'; - DisplayLabel := _('Maximum'); - Description := _( - 'Enter the possible maximum value. If you enter a column '+ - 'name then the maximum value will be the generated value '+ - 'for that column'); - ProposalLists := [plColumns]; - DataTypes := 0; - end; - end; -end; - end. Modified: branches/gui/src/ui/controllers/RuleController.pas =================================================================== --- branches/gui/src/ui/controllers/RuleController.pas 2006-12-29 18:09:36 UTC (rev 241) +++ branches/gui/src/ui/controllers/RuleController.pas 2006-12-29 23:45:45 UTC (rev 242) @@ -2,62 +2,100 @@ interface uses Classes, SysUtils, DG_Core, DG_Database; +const + PL_CONNECTIONS = 1; + PL_SEQUENCES = 2; + PL_COLUMNS = 4; type TProposalList = (plConnections, plSequences, plColumns); TProposalLists = set of TProposalList; - - TRuleParamDisplayData = record - Name: String; + + TRuleParamViewData = class + key: String; DisplayLabel: String; + Description: String; DataTypes: integer; - Description: String; - ProposalLists : TProposalLists; + ProposalLists : integer; end; IColumnRuleController = interface ['{76D94F5E-B656-43DD-BD9E-D2ACE62C66B5}'] function GetParameterCount: Integer; - function GetParameterData(const i: integer):TRuleParamDisplayData; - function GetParameterValue(const i: integer):Variant; - procedure SetParameterValue(const i: integer; value: Variant); + function GetParamViewData(const i: integer): TRuleParamViewData; + function GetParameterValue(const name: string):Variant; + procedure SetParameterValue(const name: string; value: Variant); function GetColumnRule: TDGColumnRule; end; TRuleController = class(TInterfacedObject, IColumnRuleController) protected FColumnRule : TDGColumnRule; + FRuleParamViewDatas: TList; // creates columnRule if it is not given in the constructor - procedure CreateColumnRule;virtual; + procedure CreateColumnRule;virtual; abstract; public constructor Create(const columnRule: TDGColumnRule); overload; virtual; constructor Create(const columnName: String =''); overload; virtual; + destructor Destroy; override; + function GetParameterCount: Integer; virtual; - function GetParameterData(const i: Integer): TRuleParamDisplayData; virtual; - function GetParameterValue(const i: Integer): Variant; virtual; - procedure SetParameterValue(const i: Integer; value: Variant); virtual; + function GetParameterValue(const name: string): Variant; virtual; + procedure SetParameterValue(const name: string; value: Variant); virtual; function GetColumnRule: TDGColumnRule; virtual; + //Any new rule parameter should be added using this method + //function returns the newly added empty ruleviewdata + function AddRuleParamViewData: TRuleParamViewData; virtual; + // Descendants should override this method to add their own viewdatas + // AddRuleParamViewData method + procedure InitViewData;virtual; + // Descendants should override Initviewdata. This method just returns + // the ViewData array + function GetParamViewData(const i: integer): TRuleParamViewData; end; + + TColumnRuleController = class(TRuleController) + public + function GetParameterValue(const name: string): Variant; override; + procedure SetParameterValue(const name: string; value: Variant); override; + procedure InitViewData; override; + end; implementation - +uses gnugettext; { TRuleController } constructor TRuleController.Create(const columnRule: TDGColumnRule); begin - if columnRule = nil then - CreateColumnRule - else + if columnRule <> nil then FColumnRule := columnRule; Create; end; +function TRuleController.AddRuleParamViewData: TRuleParamViewData; +var + itm : TRuleParamViewData; +begin + itm := TRuleParamViewData.Create; + FRuleParamViewDatas.Add(itm); + Result := itm; +end; + constructor TRuleController.Create(const columnName: String =''); begin + FRuleParamViewDatas := TList.Create; + if FColumnRule = nil then + CreateColumnRule; + InitViewData; end; -procedure TRuleController.CreateColumnRule; +destructor TRuleController.Destroy; +var + I: Integer; begin - + for I := 0 to FRuleParamViewDatas.Count - 1 do + Dispose(FRuleParamViewDatas[i]); + FRuleParamViewDatas.Free; + inherited; end; function TRuleController.GetColumnRule: TDGColumnRule; @@ -67,23 +105,84 @@ function TRuleController.GetParameterCount: Integer; begin - // Result := FColumnRule.Params.Count; - Result := 0; + Result := FRuleParamViewDatas.Count; end; -function TRuleController.GetParameterData( - const i: Integer): TRuleParamDisplayData; +function TRuleController.GetParameterValue(const name: string): Variant; +var + i: Integer; begin + for I := 0 to FRuleParamViewDatas.Count-1 do + if TRuleParamViewData(FRuleParamViewDatas[i]).key = name then + begin + Result := FColumnRule.Params[i-1].Value; + break; + end; end; -function TRuleController.GetParameterValue(const i: Integer): Variant; +procedure TRuleController.SetParameterValue(const name: string; value: Variant); +var + i: Integer; begin - Result := FColumnRule.Params[i].Value; + for I := 0 to FRuleParamViewDatas.Count-1 do + if TRuleParamViewData(FRuleParamViewDatas[i]).key = name then begin + // i 1 azalt\xFDl\xFDyor \xE7\xFCnk\xFC sadece nullpercentage eklendi\xF0ini biliyoruz \xF6nceden + // bu d\xFCzeltilecek. + FColumnRule.Params[i-1].Value := Value; + exit; + end; end; -procedure TRuleController.SetParameterValue(const i: Integer; value: Variant); +function TRuleController.GetParamViewData(const i: integer): TRuleParamViewData; begin - FColumnRule.Params[i].Value := Value; + Result := TRuleParamViewData(FRuleParamViewDatas[i]); end; +//function TRuleController.GetParamViewDatas: TRuleParamViewDatas; +//var +// i: Integer; +//begin +// SetLength(Result,FRuleParamViewDatas.Count); +// for i := 0 to FRuleParamViewDatas.Count - 1 do begin +// Result[i] := PRuleParamViewData(FRuleParamViewDatas[i])^; +// end; +//end; + +procedure TRuleController.InitViewData; +begin + +end; + +{ TColumnRuleController } + +function TColumnRuleController.GetParameterValue(const name: string): Variant; +begin + if name = 'nullpercentage' then + Result := FColumnRule.NullPercentage + else + Result := inherited GetParameterValue(name); +end; + +procedure TColumnRuleController.InitViewData; +begin + inherited; + with AddRuleParamViewData do + begin + key := 'nullpercentage'; + DisplayLabel := _('Null Percentage'); + Description:= _('Percentage of the null data. 100% means all ' + + 'generated data will be null'); + ProposalLists := 0; + DataTypes := 0; + end; +end; + +procedure TColumnRuleController.SetParameterValue(const name: string; value: Variant); +begin + if name = 'nullpercentage' then + FColumnRule.NullPercentage := Value + else + inherited SetParameterValue(name,Value); +end; + end. Modified: branches/gui/src/ui/controllers/SQLRuleController.pas =================================================================== --- branches/gui/src/ui/controllers/SQLRuleController.pas 2006-12-29 18:09:36 UTC (rev 241) +++ branches/gui/src/ui/controllers/SQLRuleController.pas 2006-12-29 23:45:45 UTC (rev 242) @@ -3,13 +3,11 @@ interface uses Classes, DG_Core, RuleController; type - TSQLRuleController = class(TRuleController) + TSQLRuleController = class(TColumnRuleController) protected procedure CreateColumnRule; override; public - function GetParameterData(const i: Integer): TRuleParamDisplayData; - override; - function GetParameterCount: Integer; override; + procedure InitViewData; override; end; implementation @@ -26,33 +24,26 @@ FColumnRule.NewParam('sql',''); end; -function TSQLRuleController.GetParameterCount: Integer; +procedure TSQLRuleController.InitViewData; begin - Result := 2; -end; - -function TSQLRuleController.GetParameterData( - const i: Integer): TRuleParamDisplayData; -begin - case i of - 0: with Result do begin - Name := 'connref'; - DisplayLabel := _('Connection Reference'); - Description := _( - 'Enter or select the refence of the database '+ - 'in which SQL will be run.'); - ProposalLists := [plConnections]; - DataTypes := 0; - end; - 1: with Result do begin - Name := 'sql'; - DisplayLabel := _('SQL'); - Description := _( - 'Enter SQL. Double click to open the SQL Editor.'); - ProposalLists := []; - DataTypes := 0; - end; + inherited; + with AddRuleParamViewData do begin + key := 'connref'; + DisplayLabel := _('Connection Reference'); + Description := _( + 'Enter or select the refence of the database '+ + 'in which SQL will be run.'); + ProposalLists := PL_COLUMNS; + DataTypes := 0; end; + with AddRuleParamViewData do begin + key := 'sql'; + DisplayLabel := _('SQL'); + Description := _( + 'Enter SQL. Double click to open the SQL Editor.'); + ProposalLists := PL_COLUMNS; + DataTypes := 0; + end; end; end. Modified: branches/gui/src/ui/controllers/SequenceRuleController.pas =================================================================== --- branches/gui/src/ui/controllers/SequenceRuleController.pas 2006-12-29 18:09:36 UTC (rev 241) +++ branches/gui/src/ui/controllers/SequenceRuleController.pas 2006-12-29 23:45:45 UTC (rev 242) @@ -3,13 +3,11 @@ interface uses Classes, DG_Core, RuleController; type - TSequenceRuleController = class(TRuleController) + TSequenceRuleController = class(TColumnRuleController) protected procedure CreateColumnRule; override; public - function GetParameterData(const i: Integer): TRuleParamDisplayData; - override; - function GetParameterCount: Integer; override; + procedure InitViewData; override; end; implementation @@ -27,42 +25,35 @@ FColumnRule.NewParam('','1'); end; -function TSequenceRuleController.GetParameterCount: Integer; +procedure TSequenceRuleController.InitViewData; begin - Result := 3; + inherited; + with AddRuleParamViewData do begin + key := 'connection'; + DisplayLabel := _('Connection Reference'); + Description := _( + 'Enter or select the target connection reference. '+ + 'Defined sequence should exist in the connection.'); + ProposalLists := PL_CONNECTIONS; + DataTypes := 0; + end; + with AddRuleParamViewData do begin + key := 'sequence'; + DisplayLabel := _('Sequence'); + Description := _( + 'Enter or select the sequence to be used.'); + ProposalLists := PL_SEQUENCES; + DataTypes := 0; + end; + with AddRuleParamViewData do begin + key := 'step'; + DisplayLabel := _('Increment'); + Description := _( + 'Sequence is increased by the increment value.'); + ProposalLists := 0; + DataTypes := 0; + end; end; -function TSequenceRuleController.GetParameterData( - const i: Integer): TRuleParamDisplayData; -begin - case i of - 0: with Result do begin - Name := 'connection'; - DisplayLabel := _('Connection Reference'); - Description := _( - 'Enter or select the target connection reference. '+ - 'Defined sequence should exist in the connection.'); - ProposalLists := [plConnections]; - DataTypes := 0; - end; - 1: with Result do begin - Name := 'sequence'; - DisplayLabel := _('Sequence'); - Description := _( - 'Enter or select the sequence to be used.'); - ProposalLists := [plSequences]; - DataTypes := 0; - end; - 2: with Result do begin - Name := 'step'; - DisplayLabel := _('Increment'); - Description := _( - 'Sequence is increased by the increment value.'); - ProposalLists := []; - DataTypes := 0; - end; - end; -end; - end. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <t-...@us...> - 2006-12-29 18:09:40
|
Revision: 241 http://svn.sourceforge.net/datagenerator/?rev=241&view=rev Author: t-hex Date: 2006-12-29 10:09:36 -0800 (Fri, 29 Dec 2006) Log Message: ----------- Modified Paths: -------------- branches/gui/src/ui/DataGeneratorUI.dpr branches/gui/src/ui/DataGeneratorUI.res branches/gui/src/ui/FormColumnRule.dfm branches/gui/src/ui/FormColumnRule.pas branches/gui/src/ui/controllers/AutoIncRuleController.pas branches/gui/src/ui/controllers/RuleController.pas branches/gui/src/ui/controllers/RuleControllerFactory.pas Added Paths: ----------- branches/gui/src/ui/controllers/CopyRuleController.pas branches/gui/src/ui/controllers/FixedRuleController.pas branches/gui/src/ui/controllers/PascalScriptRuleController.pas branches/gui/src/ui/controllers/PatternRuleController.pas branches/gui/src/ui/controllers/RangeRuleController.pas branches/gui/src/ui/controllers/SQLRuleController.pas branches/gui/src/ui/controllers/SequenceRuleController.pas Modified: branches/gui/src/ui/DataGeneratorUI.dpr =================================================================== --- branches/gui/src/ui/DataGeneratorUI.dpr 2006-12-29 17:21:40 UTC (rev 240) +++ branches/gui/src/ui/DataGeneratorUI.dpr 2006-12-29 18:09:36 UTC (rev 241) @@ -30,9 +30,16 @@ UITools in 'UITools.pas', gnugettext in '..\..\3rdParty\GnuGettext\gnugettext.pas', DG_Types in '..\lib\DG_Types.pas', + AutoIncRuleController in 'controllers\AutoIncRuleController.pas', + CopyRuleController in 'controllers\CopyRuleController.pas', + PascalScriptRuleController in 'controllers\PascalScriptRuleController.pas', + PatternRuleController in 'controllers\PatternRuleController.pas', + RangeRuleController in 'controllers\RangeRuleController.pas', RuleController in 'controllers\RuleController.pas', - AutoIncRuleController in 'controllers\AutoIncRuleController.pas', - RuleControllerFactory in 'controllers\RuleControllerFactory.pas'; + RuleControllerFactory in 'controllers\RuleControllerFactory.pas', + SequenceRuleController in 'controllers\SequenceRuleController.pas', + SQLRuleController in 'controllers\SQLRuleController.pas', + FixedRuleController in 'controllers\FixedRuleController.pas'; {$R *.res} {$R dgver.res} // required Modified: branches/gui/src/ui/DataGeneratorUI.res =================================================================== (Binary files differ) Modified: branches/gui/src/ui/FormColumnRule.dfm =================================================================== --- branches/gui/src/ui/FormColumnRule.dfm 2006-12-29 17:21:40 UTC (rev 240) +++ branches/gui/src/ui/FormColumnRule.dfm 2006-12-29 18:09:36 UTC (rev 241) @@ -164,6 +164,7 @@ AutoSize = False Color = clCream ParentColor = False + WordWrap = True end end object edtNullPercentage: TEdit Modified: branches/gui/src/ui/FormColumnRule.pas =================================================================== --- branches/gui/src/ui/FormColumnRule.pas 2006-12-29 17:21:40 UTC (rev 240) +++ branches/gui/src/ui/FormColumnRule.pas 2006-12-29 18:09:36 UTC (rev 241) @@ -96,19 +96,6 @@ { TfrmColumnRule } -//procedure TfrmColumnRule.SetColumnRule(const Value: TDGColumnRule); -//begin -// FColumnRule := Value; -// lblFieldName.Caption := FColumnRule.ColumnName; -// ParamTreeList.Clear; -// cbGeneratorType.ItemIndex := -// cbGeneratorType.Items.IndexOf(GeneratorLocalName(FColumnRule.Strategy)); -// //Fire combobox change event -// cbGeneratorTypeChange(Self); -// -// udsNullPercentage.Position := FColumnRule.NullPercentage; -//end; - procedure TfrmColumnRule.ParamTreeListInitNode(Sender: TBaseVirtualTree; ParentNode, Node: PVirtualNode; var InitialStates: TVirtualNodeInitStates); @@ -336,50 +323,6 @@ Allowed := NewColumn = 1; end; -//procedure TfrmColumnRule.AddStrategyParameters(const AStrategy: TGeneratorType); -//var -// I : Integer; -// Node: PVirtualNode; -// ParamData: PParamData; -//begin -// if ParamTreeList.RootNodeCount <> 0 then exit; -// -// case AStrategy of -// gtAutoInc: begin -// AddParamNode('', '0', _('Minimum value')); -// AddParamNode('', '1', _('Increment value')); -// end; -// gtRange: begin -// AddParamNode('', '0', _('Minimum value')); -// AddParamNode('', '', _('Maximum value')); -// end; -// gtSQL: begin -// AddParamNode('dbref', '', _('Database Reference'), ltReference); -// AddParamNode('sql', '', _('SQL')); -// end; -// gtComposite: AddParamNode('file', '', _('File')); -// gtScript: AddParamNode('script', '', _('Script')); -// gtFixed: AddParamNode('', '', _('A value')); -// gtCopy: AddParamNode('context', '', _('Column Name')); -// gtSequence: begin -// AddParamNode('dbref', '', _('Database Reference'), ltReference); -// AddParamNode('sequence', '', _('Sequence Name'), ltSequence); -// AddParamNode('', '', _('Sequence Step Size')); -// end; -// gtPattern : AddParamNode('Pattern', '', _('String Pattern')); -// gtVariable: AddParamNode('', '', _('A value')); -// end; -// Create nodes for the remainin parameters in the columnrule -// if ParamTreeList.RootNodeCount < FColumnRule.Params.Count then -// for i := ParamTreeList.RootNodeCount to FColumnRule.Params.Count-1 do begin -// Node := ParamTreeList.AddChild(nil); -// ParamData := ParamTreeList.GetNodeData(Node); -// ParamData.Tip := FColumnRule.Params[I].Type_; -// ParamData.Value := FColumnRule.Params[I].Value; -// end; -// ParamTreeList.Refresh; -//end; - procedure TfrmColumnRule.ParamTreeListCreateEditor( Sender: TBaseVirtualTree; Node: PVirtualNode; Column: TColumnIndex; out EditLink: IVTEditLink); Modified: branches/gui/src/ui/controllers/AutoIncRuleController.pas =================================================================== --- branches/gui/src/ui/controllers/AutoIncRuleController.pas 2006-12-29 17:21:40 UTC (rev 240) +++ branches/gui/src/ui/controllers/AutoIncRuleController.pas 2006-12-29 18:09:36 UTC (rev 241) @@ -5,27 +5,24 @@ type TAutoIncRuleController = class(TRuleController) + protected + procedure CreateColumnRule; override; public function GetParameterCount: Integer; override; function GetParameterData(const i: Integer): TRuleParamDisplayData; override; - function GetParameterValue(const i: Integer): Variant; override; - procedure SetParameterValue(const i: Integer; value: Variant); override; - constructor Create(const columnName: String =''); override; end; implementation uses gnugettext, DG_Database, DG_Types; { TAutoIncRuleController } -constructor TAutoIncRuleController.Create(const columnName: String =''); +procedure TAutoIncRuleController.CreateColumnRule; begin inherited; - if FColumnRule = nil then begin - FColumnRule := TDGColumnRule.Create(columnName); - FColumnRule.Strategy := gtAutoInc; - FColumnRule.NewParam('start','0'); - FColumnRule.NewParam('step','1'); - end; + FColumnRule := TDGColumnRule.Create(''); + FColumnRule.Strategy := gtAutoInc; + FColumnRule.NewParam('start','0'); + FColumnRule.NewParam('step','1'); end; function TAutoIncRuleController.GetParameterCount: Integer; @@ -42,28 +39,16 @@ DisplayLabel:= _('Start'); Description := _('Enter the starting value'); DataTypes := 0; - Content := []; + ProposalLists := []; end; 1: with Result do begin Name := 'step'; DisplayLabel:= _('Step'); Description := _('Enter the increment amount'); DataTypes := 0; - Content := []; + ProposalLists := []; end; end; end; -function TAutoIncRuleController.GetParameterValue(const i: Integer): Variant; -begin - Result := FColumnRule.Params[i].Value; -end; - -procedure TAutoIncRuleController.SetParameterValue(const i: Integer; - value: Variant); -begin - inherited; - FColumnRule.Params[i].Value := Value; -end; - end. Added: branches/gui/src/ui/controllers/CopyRuleController.pas =================================================================== --- branches/gui/src/ui/controllers/CopyRuleController.pas (rev 0) +++ branches/gui/src/ui/controllers/CopyRuleController.pas 2006-12-29 18:09:36 UTC (rev 241) @@ -0,0 +1,46 @@ +unit CopyRuleController; + +interface +uses Classes, DG_Core, RuleController; +type + + TCopyRuleController = class(TRuleController) + protected + procedure CreateColumnRule; override; + public + function GetParameterCount: Integer; override; + function GetParameterData(const i: Integer): TRuleParamDisplayData; override; + end; + +implementation +uses gnugettext, DG_Database, DG_Types; +{ TCopyRuleController } + +procedure TCopyRuleController.CreateColumnRule; +begin + inherited; + FColumnRule := TDGColumnRule.Create(''); + FColumnRule.Strategy := gtCopy; + FColumnRule.NewParam('',''); +end; + +function TCopyRuleController.GetParameterCount: Integer; +begin + Result := 1; +end; + +function TCopyRuleController.GetParameterData( + const i: Integer): TRuleParamDisplayData; +begin + case i of + 0: with Result do begin + Name := 'column'; + DisplayLabel:= _('Start'); + Description := _('Enter the source column to be copied.'); + DataTypes := 0; + ProposalLists := [plColumns]; + end; + end; +end; + +end. Added: branches/gui/src/ui/controllers/FixedRuleController.pas =================================================================== --- branches/gui/src/ui/controllers/FixedRuleController.pas (rev 0) +++ branches/gui/src/ui/controllers/FixedRuleController.pas 2006-12-29 18:09:36 UTC (rev 241) @@ -0,0 +1,47 @@ +unit FixedRuleController; + +interface +uses Classes, DG_Core, RuleController; +type + TFixedRuleController = class(TRuleController) + protected + procedure CreateColumnRule; override; + public + function GetParameterData(const i: Integer): TRuleParamDisplayData; + override; + function GetParameterCount: Integer; override; + end; +implementation +uses gnugettext, DG_Database, DG_Types; + +{ TFixedRuleController } + +procedure TFixedRuleController.CreateColumnRule; +begin + inherited; + FColumnRule := TDGColumnRule.Create(''); + FColumnRule.Strategy := gtPattern; + FColumnRule.NewParam('',''); +end; + +function TFixedRuleController.GetParameterCount: Integer; +begin + Result := 1; +end; + +function TFixedRuleController.GetParameterData( + const i: Integer): TRuleParamDisplayData; +begin + case i of + 0: with Result do begin + Name := 'value'; + DisplayLabel := _('Value'); + Description := _( + 'Enter the fixed value. All the generated rows will have the same value.'); + ProposalLists := []; + DataTypes := 0; + end; + end; +end; + +end. Added: branches/gui/src/ui/controllers/PascalScriptRuleController.pas =================================================================== --- branches/gui/src/ui/controllers/PascalScriptRuleController.pas (rev 0) +++ branches/gui/src/ui/controllers/PascalScriptRuleController.pas 2006-12-29 18:09:36 UTC (rev 241) @@ -0,0 +1,47 @@ +unit PascalScriptRuleController; + +interface +uses Classes, DG_Core, RuleController; +type + TPascalScriptRuleController = class(TRuleController) + protected + procedure CreateColumnRule; override; + public + function GetParameterData(const i: Integer): TRuleParamDisplayData; + override; + function GetParameterCount: Integer; override; + end; +implementation +uses gnugettext, DG_Database, DG_Types; + +{ TPascalScriptRuleController } + +procedure TPascalScriptRuleController.CreateColumnRule; +begin + inherited; + FColumnRule := TDGColumnRule.Create(''); + FColumnRule.Strategy := gtScript; + FColumnRule.NewParam('',''); +end; + +function TPascalScriptRuleController.GetParameterCount: Integer; +begin + Result := 1; +end; + +function TPascalScriptRuleController.GetParameterData( + const i: Integer): TRuleParamDisplayData; +begin + case i of + 0: with Result do begin + Name := 'script'; + DisplayLabel := _('Script'); + Description := _( + 'Enter Pascal Script. Double click to open Script editor.'); + ProposalLists := []; + DataTypes := 0; + end; + end; +end; + +end. Added: branches/gui/src/ui/controllers/PatternRuleController.pas =================================================================== --- branches/gui/src/ui/controllers/PatternRuleController.pas (rev 0) +++ branches/gui/src/ui/controllers/PatternRuleController.pas 2006-12-29 18:09:36 UTC (rev 241) @@ -0,0 +1,47 @@ +unit PatternRuleController; + +interface +uses Classes, DG_Core, RuleController; +type + TPatternRuleController = class(TRuleController) + protected + procedure CreateColumnRule; override; + public + function GetParameterData(const i: Integer): TRuleParamDisplayData; + override; + function GetParameterCount: Integer; override; + end; +implementation +uses gnugettext, DG_Database, DG_Types; + +{ TPatternRuleController } + +procedure TPatternRuleController.CreateColumnRule; +begin + inherited; + FColumnRule := TDGColumnRule.Create(''); + FColumnRule.Strategy := gtPattern; + FColumnRule.NewParam('',''); +end; + +function TPatternRuleController.GetParameterCount: Integer; +begin + Result := 1; +end; + +function TPatternRuleController.GetParameterData( + const i: Integer): TRuleParamDisplayData; +begin + case i of + 0: with Result do begin + Name := 'pattern'; + DisplayLabel := _('Pattern'); + Description := _( + 'Enter the pattern that will be used to generate data.'); + ProposalLists := []; + DataTypes := 0; + end; + end; +end; + +end. Added: branches/gui/src/ui/controllers/RangeRuleController.pas =================================================================== --- branches/gui/src/ui/controllers/RangeRuleController.pas (rev 0) +++ branches/gui/src/ui/controllers/RangeRuleController.pas 2006-12-29 18:09:36 UTC (rev 241) @@ -0,0 +1,61 @@ +unit RangeRuleController; + +interface +uses Classes, DG_Core, RuleController; +type + TRangeRuleController = class(TRuleController) + protected + procedure CreateColumnRule; override; + public + function GetParameterData(const i: Integer): TRuleParamDisplayData; + override; + function GetParameterCount: Integer; override; + end; + +implementation +uses gnugettext, DG_Database, DG_Types; + +{ TRangeRuleController } + +procedure TRangeRuleController.CreateColumnRule; +begin + inherited; + FColumnRule := TDGColumnRule.Create(''); + FColumnRule.Strategy := gtRange; + FColumnRule.NewParam('','1'); + FColumnRule.NewParam('',''); +end; + +function TRangeRuleController.GetParameterCount: Integer; +begin + Result := 2; +end; + +function TRangeRuleController.GetParameterData( + const i: Integer): TRuleParamDisplayData; +begin + case i of + 0: with Result do begin + Name := 'min'; + DisplayLabel := _('Minimum'); + Description := _( + 'Enter the possible minimum value. If you enter a column '+ + 'name then the minimum value will be the generated value '+ + 'for that column'); + ProposalLists := [plColumns]; + DataTypes := 0; + end; + 1: with Result do begin + Name := 'max'; + DisplayLabel := _('Maximum'); + Description := _( + 'Enter the possible maximum value. If you enter a column '+ + 'name then the maximum value will be the generated value '+ + 'for that column'); + ProposalLists := [plColumns]; + DataTypes := 0; + end; + end; +end; + +end. Modified: branches/gui/src/ui/controllers/RuleController.pas =================================================================== --- branches/gui/src/ui/controllers/RuleController.pas 2006-12-29 17:21:40 UTC (rev 240) +++ branches/gui/src/ui/controllers/RuleController.pas 2006-12-29 18:09:36 UTC (rev 241) @@ -11,7 +11,7 @@ DisplayLabel: String; DataTypes: integer; Description: String; - Content : TProposalLists; + ProposalLists : TProposalLists; end; IColumnRuleController = interface @@ -26,6 +26,8 @@ TRuleController = class(TInterfacedObject, IColumnRuleController) protected FColumnRule : TDGColumnRule; + // creates columnRule if it is not given in the constructor + procedure CreateColumnRule;virtual; public constructor Create(const columnRule: TDGColumnRule); overload; virtual; constructor Create(const columnName: String =''); overload; virtual; @@ -42,7 +44,10 @@ constructor TRuleController.Create(const columnRule: TDGColumnRule); begin - FColumnRule := columnRule; + if columnRule = nil then + CreateColumnRule + else + FColumnRule := columnRule; Create; end; @@ -50,6 +55,11 @@ begin end; +procedure TRuleController.CreateColumnRule; +begin + +end; + function TRuleController.GetColumnRule: TDGColumnRule; begin Result := FColumnRule; @@ -57,8 +67,8 @@ function TRuleController.GetParameterCount: Integer; begin -// Result := FColumnRule.Params.Count; - Result := 0; + // Result := FColumnRule.Params.Count; + Result := 0; end; function TRuleController.GetParameterData( @@ -68,12 +78,12 @@ function TRuleController.GetParameterValue(const i: Integer): Variant; begin - Result := ''; + Result := FColumnRule.Params[i].Value; end; procedure TRuleController.SetParameterValue(const i: Integer; value: Variant); begin - + FColumnRule.Params[i].Value := Value; end; end. Modified: branches/gui/src/ui/controllers/RuleControllerFactory.pas =================================================================== --- branches/gui/src/ui/controllers/RuleControllerFactory.pas 2006-12-29 17:21:40 UTC (rev 240) +++ branches/gui/src/ui/controllers/RuleControllerFactory.pas 2006-12-29 18:09:36 UTC (rev 241) @@ -10,23 +10,27 @@ end; implementation -uses gnugettext, SysUtils, AutoIncRuleController, DG_Generators; +uses gnugettext, SysUtils, DG_Generators, + AutoIncRuleController, CopyRuleController, + RangeRuleController, SQLRuleController, + PascalScriptRuleController, FixedRuleController, + SequenceRuleController,PatternRuleController; { TRuleControllerFactory } - +{ TODO 5 -ot-hex : Constructorlar\xFD teke d\xFC\xFE\xFCr } class function TRuleControllerFactory.CreateRuleController( const ruleStrategy: TGeneratorType): TRuleController; begin case ruleStrategy of -// gtRange: ; -// gtSQL: ; -// gtScript: ; - gtAutoInc: Result := TAutoIncRuleController.Create ; + gtRange: Result := TRangeRuleController.Create; + gtSQL: Result := TSQLRuleController.Create; + gtScript: Result := TPascalScriptRuleController.Create; + gtAutoInc: Result := TAutoIncRuleController.Create; // gtComposite: ; -// gtFixed: ; -// gtCopy: ; -// gtSequence: ; -// gtPattern: ; + gtFixed: Result := TFixedRuleController.Create; + gtCopy: Result := TCopyRuleController.Create; + gtSequence: Result := TSequenceRuleController.Create; + gtPattern: Result := TPatternRuleController.Create; // gtVariable: ; else raise Exception.Create(Format(_('Cannot find controller for %s'),[GeneratorLocalName(ruleStrategy)])); @@ -37,15 +41,15 @@ const rule: TDGColumnRule): TRuleController; begin case rule.Strategy of -// gtRange: -// gtSQL: ; -// gtScript: ; + gtRange: Result := TRangeRuleController.Create(rule); + gtSQL: Result := TSQLRuleController.Create(rule); + gtScript: Result := TPascalScriptRuleController.Create(rule); gtAutoInc: Result := TAutoIncRuleController.Create(rule); // gtComposite: ; -// gtFixed: ; -// gtCopy: ; -// gtSequence: ; -// gtPattern: ; + gtFixed: Result := TFixedRuleController.Create(rule); + gtCopy: Result := TCopyRuleController.Create(rule); + gtSequence: Result := TSequenceRuleController.Create(rule); + gtPattern: Result := TPatternRuleController.Create(rule); // gtVariable: ; else raise Exception.Create(Format(_('Cannot find controller for %s'),[GeneratorLocalName(rule.Strategy)])); Added: branches/gui/src/ui/controllers/SQLRuleController.pas =================================================================== --- branches/gui/src/ui/controllers/SQLRuleController.pas (rev 0) +++ branches/gui/src/ui/controllers/SQLRuleController.pas 2006-12-29 18:09:36 UTC (rev 241) @@ -0,0 +1,58 @@ +unit SQLRuleController; + +interface +uses Classes, DG_Core, RuleController; +type + TSQLRuleController = class(TRuleController) + protected + procedure CreateColumnRule; override; + public + function GetParameterData(const i: Integer): TRuleParamDisplayData; + override; + function GetParameterCount: Integer; override; + end; + +implementation +uses gnugettext, DG_Database, DG_Types; + +{ TSQLRuleController } + +procedure TSQLRuleController.CreateColumnRule; +begin + inherited; + FColumnRule := TDGColumnRule.Create(''); + FColumnRule.Strategy := gtSQL; + FColumnRule.NewParam('dbref',''); + FColumnRule.NewParam('sql',''); +end; + +function TSQLRuleController.GetParameterCount: Integer; +begin + Result := 2; +end; + +function TSQLRuleController.GetParameterData( + const i: Integer): TRuleParamDisplayData; +begin + case i of + 0: with Result do begin + Name := 'connref'; + DisplayLabel := _('Connection Reference'); + Description := _( + 'Enter or select the refence of the database '+ + 'in which SQL will be run.'); + ProposalLists := [plConnections]; + DataTypes := 0; + end; + 1: with Result do begin + Name := 'sql'; + DisplayLabel := _('SQL'); + Description := _( + 'Enter SQL. Double click to open the SQL Editor.'); + ProposalLists := []; + DataTypes := 0; + end; + end; +end; + +end. Added: branches/gui/src/ui/controllers/SequenceRuleController.pas =================================================================== --- branches/gui/src/ui/controllers/SequenceRuleController.pas (rev 0) +++ branches/gui/src/ui/controllers/SequenceRuleController.pas 2006-12-29 18:09:36 UTC (rev 241) @@ -0,0 +1,68 @@ +unit SequenceRuleController; + +interface +uses Classes, DG_Core, RuleController; +type + TSequenceRuleController = class(TRuleController) + protected + procedure CreateColumnRule; override; + public + function GetParameterData(const i: Integer): TRuleParamDisplayData; + override; + function GetParameterCount: Integer; override; + end; + +implementation +uses gnugettext, DG_Database, DG_Types; + +{ TSequenceRuleController } + +procedure TSequenceRuleController.CreateColumnRule; +begin + inherited; + FColumnRule := TDGColumnRule.Create(''); + FColumnRule.Strategy := gtSequence; + FColumnRule.NewParam('dbref',''); + FColumnRule.NewParam('sequence',''); + FColumnRule.NewParam('','1'); +end; + +function TSequenceRuleController.GetParameterCount: Integer; +begin + Result := 3; +end; + +function TSequenceRuleController.GetParameterData( + const i: Integer): TRuleParamDisplayData; +begin + case i of + 0: with Result do begin + Name := 'connection'; + DisplayLabel := _('Connection Reference'); + Description := _( + 'Enter or select the target connection reference. '+ + 'Defined sequence should exist in the connection.'); + ProposalLists := [plConnections]; + DataTypes := 0; + end; + 1: with Result do begin + Name := 'sequence'; + DisplayLabel := _('Sequence'); + Description := _( + 'Enter or select the sequence to be used.'); + ProposalLists := [plSequences]; + DataTypes := 0; + end; + 2: with Result do begin + Name := 'step'; + DisplayLabel := _('Increment'); + Description := _( + 'Sequence is increased by the increment value.'); + ProposalLists := []; + DataTypes := 0; + end; + end; +end; + +end. + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <t-...@us...> - 2006-12-29 17:21:42
|
Revision: 240 http://svn.sourceforge.net/datagenerator/?rev=240&view=rev Author: t-hex Date: 2006-12-29 09:21:40 -0800 (Fri, 29 Dec 2006) Log Message: ----------- Modified Paths: -------------- branches/gui/src/ui/DataGeneratorUI.dpr branches/gui/src/ui/FormColumnRule.dfm branches/gui/src/ui/FormColumnRule.pas branches/gui/src/ui/MainForm.dfm branches/gui/src/ui/MainForm.pas Added Paths: ----------- branches/gui/src/ui/controllers/ branches/gui/src/ui/controllers/AutoIncRuleController.pas branches/gui/src/ui/controllers/RuleController.pas branches/gui/src/ui/controllers/RuleControllerFactory.pas Modified: branches/gui/src/ui/DataGeneratorUI.dpr =================================================================== --- branches/gui/src/ui/DataGeneratorUI.dpr 2006-12-27 13:36:53 UTC (rev 239) +++ branches/gui/src/ui/DataGeneratorUI.dpr 2006-12-29 17:21:40 UTC (rev 240) @@ -29,7 +29,10 @@ DG_Builders in '..\lib\DG_Builders.pas', UITools in 'UITools.pas', gnugettext in '..\..\3rdParty\GnuGettext\gnugettext.pas', - DG_Types in '..\lib\DG_Types.pas'; + DG_Types in '..\lib\DG_Types.pas', + RuleController in 'controllers\RuleController.pas', + AutoIncRuleController in 'controllers\AutoIncRuleController.pas', + RuleControllerFactory in 'controllers\RuleControllerFactory.pas'; {$R *.res} {$R dgver.res} // required Modified: branches/gui/src/ui/FormColumnRule.dfm =================================================================== --- branches/gui/src/ui/FormColumnRule.dfm 2006-12-27 13:36:53 UTC (rev 239) +++ branches/gui/src/ui/FormColumnRule.dfm 2006-12-29 17:21:40 UTC (rev 240) @@ -11,6 +11,8 @@ inherited Bevel1: TBevel Top = 317 Width = 370 + ExplicitTop = 317 + ExplicitWidth = 370 end object Label1: TLabel [1] Left = 16 @@ -28,11 +30,12 @@ end inherited btnOK: TButton Top = 326 - OnClick = btnOKClick + ExplicitTop = 326 end inherited btnCancel: TButton Top = 326 Cancel = True + ExplicitTop = 326 end object GroupBox1: TGroupBox Left = 8 Modified: branches/gui/src/ui/FormColumnRule.pas =================================================================== --- branches/gui/src/ui/FormColumnRule.pas 2006-12-27 13:36:53 UTC (rev 239) +++ branches/gui/src/ui/FormColumnRule.pas 2006-12-29 17:21:40 UTC (rev 240) @@ -5,7 +5,7 @@ uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, FormRule, StdCtrls, ExtCtrls, ComCtrls,DG_Core, VirtualTrees, - Menus,DG_Configuration, Spin, DG_Database, DG_Types ; + Menus,DG_Configuration, DG_Database, DG_Types, RuleController ; type TListType = (ltNone, ltReference, ltSequence); @@ -50,7 +50,6 @@ procedure cbGeneratorTypeChange(Sender: TObject); procedure ParamTreeListChange(Sender: TBaseVirtualTree; Node: PVirtualNode); - procedure btnOKClick(Sender: TObject); procedure ParamTreeListDblClick(Sender: TObject); procedure ParamTreeListKeyAction(Sender: TBaseVirtualTree; var CharCode: Word; var Shift: TShiftState; var DoDefault: Boolean); @@ -68,23 +67,20 @@ procedure NumberEditKeyPress(Sender: TObject; var Key: Char); procedure FormCreate(Sender: TObject); private - FColumnRule : TDGColumnRule; + FRuleController : TRuleController; FCheckedNode : PVirtualNode; - function GetColumnRule: TDGColumnRule; - procedure SetColumnRule(const Value: TDGColumnRule); - procedure AddParamNode(Tip : String; Value: String;Info :String =''; AListType:TListType = ltNone); - procedure AddStrategyParameters(const AStrategy: TGeneratorType); procedure FillGeneratorCombo; + procedure SetRuleController(const Value: TRuleController); public - property ColumnRule : TDGColumnRule read GetColumnRule write SetColumnRule; procedure PerformPopupAction(ActionType : TActionType; Node: PVirtualNode); + procedure FreeRuleController; + procedure UpdateParameterList; + property RuleController: TRuleController read FRuleController write SetRuleController; end; PParamData = ^TParamData; TParamData = record Tip : String; - Value: String; - Info : String; ListType: TListType; end; @@ -94,32 +90,25 @@ implementation uses Types, FormMemoEditor, gnugettext, VTEditLinks, MainForm, - ZConnection, ZDbcIntfs, Math, UITools, DG_Generators; + ZConnection, ZDbcIntfs, Math, UITools, DG_Generators, RuleControllerFactory; {$R *.dfm} { TfrmColumnRule } -function TfrmColumnRule.GetColumnRule: TDGColumnRule; -begin - Result := FColumnRule; -end; +//procedure TfrmColumnRule.SetColumnRule(const Value: TDGColumnRule); +//begin +// FColumnRule := Value; +// lblFieldName.Caption := FColumnRule.ColumnName; +// ParamTreeList.Clear; +// cbGeneratorType.ItemIndex := +// cbGeneratorType.Items.IndexOf(GeneratorLocalName(FColumnRule.Strategy)); +// //Fire combobox change event +// cbGeneratorTypeChange(Self); +// +// udsNullPercentage.Position := FColumnRule.NullPercentage; +//end; -procedure TfrmColumnRule.SetColumnRule(const Value: TDGColumnRule); -begin - FColumnRule := Value; - lblFieldName.Caption := FColumnRule.ColumnName; - ParamTreeList.Clear; - //Set strategy - { TODO : This should not be locale spesific } - cbGeneratorType.ItemIndex := - cbGeneratorType.Items.IndexOf(GeneratorLocalName(FColumnRule.Strategy)); - //Fire combobox change event - cbGeneratorTypeChange(Self); - - udsNullPercentage.Position := FColumnRule.NullPercentage; -end; - procedure TfrmColumnRule.ParamTreeListInitNode(Sender: TBaseVirtualTree; ParentNode, Node: PVirtualNode; var InitialStates: TVirtualNodeInitStates); @@ -135,16 +124,12 @@ procedure TfrmColumnRule.ParamTreeListGetText(Sender: TBaseVirtualTree; Node: PVirtualNode; Column: TColumnIndex; TextType: TVSTTextType; var CellText: WideString); -var - ParamData : PParamData; begin inherited; - ParamData := Sender.GetNodeData(Node); - Celltext := ''; if TextType = ttNormal then case Column of - 0 : Celltext := ParamData.Info; - 1 : Celltext := ParamData.Value; + 0 : Celltext := FRuleController.GetParameterData(Node.Index).DisplayLabel; + 1 : Celltext := FRuleController.GetParameterValue(Node.Index); end; end; @@ -170,6 +155,28 @@ FCheckedNode := nil; end; +procedure TfrmColumnRule.SetRuleController(const Value: TRuleController); +begin + FRuleController := Value; + UpdateParameterList; +end; + +procedure TfrmColumnRule.UpdateParameterList; +var + i: integer; + Node : PVirtualNode; + NodeData : PParamData; +begin + for i := 0 to FRuleController.GetParameterCount - 1 do + with FRuleController,FRuleController.GetParameterData(i) do + begin + Node := ParamTreeList.AddChild(nil); + NodeData := ParamTreeList.GetNodeData(Node); + NodeData.Tip := Name; + NodeData.ListType:= ltNone; //TODO fix this + end; +end; + procedure TfrmColumnRule.MenuItemClicked(Sender: TObject); var MenuIndex : Integer; @@ -190,15 +197,9 @@ procedure TfrmColumnRule.ParamTreeListNewText(Sender: TBaseVirtualTree; Node: PVirtualNode; Column: TColumnIndex; NewText: WideString); -var - ParamData : PParamData; begin inherited; - ParamData := Sender.GetNodeData(Node); - case Column of - 0: ParamData.Tip := NewText; - 1: ParamData.Value := NewText; - end; + FRuleController.SetParameterValue(Node.Index,Newtext); end; procedure TfrmColumnRule.ParamTreeListKeyUp(Sender: TObject; var Key: Word; @@ -220,66 +221,27 @@ var Action: TCloseAction); begin Action := caFree; + FreeRuleController; end; procedure TfrmColumnRule.cbGeneratorTypeChange(Sender: TObject); begin inherited; - if ParamTreeList.RootNodeCount > 0 then - if MessageDlg(_('Remove current parameters?'),mtConfirmation,mbYesNoCancel,0) =mrYes then begin - FColumnRule.Params.Clear; - ParamTreeList.Clear; - end; - FColumnRule.Strategy := TGeneratorType(cbGeneratorType.ItemIndex); - AddStrategyParameters(FColumnRule.Strategy); + if assigned(FRuleController) then + FRuleController.Free; + + RuleController := TRuleControllerFactory.CreateRuleController(TGeneratorType(cbGeneratorType.ItemIndex)); + ParamTreeList.Clear; end; -procedure TfrmColumnRule.AddParamNode(Tip, Value: String; Info: string = ''; AListType: TListType = ltNone); -var - Node : PVirtualNode; - ParamData : PParamData; -begin - Node := ParamTreeList.AddChild(nil); - ParamData := ParamTreeList.GetNodeData(Node); - if FColumnRule.Params.Count > Node.Index then begin - ParamData.Tip := FColumnRule.Params[Node.Index].Type_; - ParamData.Value := FColumnRule.Params[Node.Index].Value; - end else begin - ParamData.Tip := Tip; - ParamData.Value := Value; - end; - ParamData.Info := Info; - ParamData.ListType := AListType; -end; - procedure TfrmColumnRule.ParamTreeListChange(Sender: TBaseVirtualTree; Node: PVirtualNode); -var - ParamData : PParamData; begin inherited; if Node = nil then exit; - ParamData := Sender.GetNodeData(Node); - lblInfo.Caption := ParamData.Info; + lblInfo.Caption := FRuleController.GetParameterData(Node.Index).Description; end; -procedure TfrmColumnRule.btnOKClick(Sender: TObject); -var - Node : PVirtualNode; - ParamData : PParamData; -begin - inherited; - FColumnRule.Params.Clear; - Node := ParamTreeList.RootNode.FirstChild; - while Node <> nil do begin - ParamData := ParamTreeList.GetNodeData(Node); - FColumnRule.NewParam(ParamData.Tip, ParamData.Value); - Node := Node.NextSibling; - end; - FColumnRule.Strategy := TGeneratorType(cbGeneratorType.ItemIndex); - FColumnRule.NullPercentage := udsNullPercentage.Position; -end; - procedure TfrmColumnRule.ParamTreeListDblClick(Sender: TObject); var Node: PVirtualNode; @@ -316,22 +278,20 @@ ParamData := ParamTreeList.GetNodeData(Node); case ActionType of atNormal: begin - // ParamData.Tip := ''; ParamTreeList.EditNode(FCheckedNode, 1); end; atFile : begin - ParamOpenDialog.FileName := ParamData.Value; + ParamOpenDialog.FileName := FRuleController.GetParameterValue(Node.Index); if ParamOpenDialog.Execute then begin - ParamData.Tip := 'file'; - ParamData.Value := ParamOpenDialog.FileName; + FRuleController.SetParameterValue(Node.Index,ParamOpenDialog.FileName); end; end; atScript, atSQL, atList : begin Application.CreateForm(TfrmEditor, frmEditor); try - frmEditor.Text := ParamData.Value; + frmEditor.Text := FRuleController.GetParameterValue(Node.Index); case ActionType of atScript: frmEditor.TextType := ttPascalScript; atSQL: frmEditor.TextType := ttSQL; @@ -342,7 +302,7 @@ if ActionType = atScript then ParamData.Tip := 'script'; if ActionType = atSQL then ParamData.Tip := 'sql'; if ActionType = atList then ParamData.Tip := 'list'; - ParamData.Value := frmEditor.Text; + FRuleController.SetParameterValue(Node.Index,frmEditor.Text); end; finally frmEditor.Free; @@ -355,13 +315,10 @@ procedure TfrmColumnRule.ParamTreeListGetHint(Sender: TBaseVirtualTree; Node: PVirtualNode; Column: TColumnIndex; var LineBreakStyle: TVTTooltipLineBreakStyle; var HintText: WideString); -var - ParamNodeData : PParamData; begin inherited; if Column <> 1 then exit; - ParamNodeData := Sender.GetNodeData(Node); - HintText := ParamNodeData.Value; + HintText := FRuleController.GetParameterValue(Node.Index); end; procedure TfrmColumnRule.ParamTreeListEditing(Sender: TBaseVirtualTree; @@ -379,50 +336,50 @@ Allowed := NewColumn = 1; end; -procedure TfrmColumnRule.AddStrategyParameters(const AStrategy: TGeneratorType); -var - I : Integer; - Node: PVirtualNode; - ParamData: PParamData; -begin - if ParamTreeList.RootNodeCount <> 0 then exit; +//procedure TfrmColumnRule.AddStrategyParameters(const AStrategy: TGeneratorType); +//var +// I : Integer; +// Node: PVirtualNode; +// ParamData: PParamData; +//begin +// if ParamTreeList.RootNodeCount <> 0 then exit; +// +// case AStrategy of +// gtAutoInc: begin +// AddParamNode('', '0', _('Minimum value')); +// AddParamNode('', '1', _('Increment value')); +// end; +// gtRange: begin +// AddParamNode('', '0', _('Minimum value')); +// AddParamNode('', '', _('Maximum value')); +// end; +// gtSQL: begin +// AddParamNode('dbref', '', _('Database Reference'), ltReference); +// AddParamNode('sql', '', _('SQL')); +// end; +// gtComposite: AddParamNode('file', '', _('File')); +// gtScript: AddParamNode('script', '', _('Script')); +// gtFixed: AddParamNode('', '', _('A value')); +// gtCopy: AddParamNode('context', '', _('Column Name')); +// gtSequence: begin +// AddParamNode('dbref', '', _('Database Reference'), ltReference); +// AddParamNode('sequence', '', _('Sequence Name'), ltSequence); +// AddParamNode('', '', _('Sequence Step Size')); +// end; +// gtPattern : AddParamNode('Pattern', '', _('String Pattern')); +// gtVariable: AddParamNode('', '', _('A value')); +// end; +// Create nodes for the remainin parameters in the columnrule +// if ParamTreeList.RootNodeCount < FColumnRule.Params.Count then +// for i := ParamTreeList.RootNodeCount to FColumnRule.Params.Count-1 do begin +// Node := ParamTreeList.AddChild(nil); +// ParamData := ParamTreeList.GetNodeData(Node); +// ParamData.Tip := FColumnRule.Params[I].Type_; +// ParamData.Value := FColumnRule.Params[I].Value; +// end; +// ParamTreeList.Refresh; +//end; - case AStrategy of - gtAutoInc: begin - AddParamNode('', '0', _('Minimum value')); - AddParamNode('', '1', _('Increment value')); - end; - gtRange: begin - AddParamNode('', '0', _('Minimum value')); - AddParamNode('', '', _('Maximum value')); - end; - gtSQL: begin - AddParamNode('dbref', '', _('Database Reference'), ltReference); - AddParamNode('sql', '', _('SQL')); - end; - gtComposite: AddParamNode('file', '', _('File')); - gtScript: AddParamNode('script', '', _('Script')); - gtFixed: AddParamNode('', '', _('A value')); - gtCopy: AddParamNode('context', '', _('Column Name')); - gtSequence: begin - AddParamNode('dbref', '', _('Database Reference'), ltReference); - AddParamNode('sequence', '', _('Sequence Name'), ltSequence); - AddParamNode('', '', _('Sequence Step Size')); - end; - gtPattern : AddParamNode('Pattern', '', _('String Pattern')); - gtVariable: AddParamNode('', '', _('A value')); - end; - // Create nodes for the remainin parameters in the columnrule - if ParamTreeList.RootNodeCount < FColumnRule.Params.Count then - for i := ParamTreeList.RootNodeCount to FColumnRule.Params.Count-1 do begin - Node := ParamTreeList.AddChild(nil); - ParamData := ParamTreeList.GetNodeData(Node); - ParamData.Tip := FColumnRule.Params[I].Type_; - ParamData.Value := FColumnRule.Params[I].Value; - end; - ParamTreeList.Refresh; -end; - procedure TfrmColumnRule.ParamTreeListCreateEditor( Sender: TBaseVirtualTree; Node: PVirtualNode; Column: TColumnIndex; out EditLink: IVTEditLink); @@ -455,7 +412,7 @@ begin // Previous node gives the connection reference ParamData := Sender.GetNodeData(Node.PrevSibling); - ConnProp := frmMain.Configuration.FindConnectionProperty(ParamData.Value); + ConnProp := frmMain.Configuration.FindConnectionProperty(FRuleController.GetParameterValue((Node.Index))); if Assigned(ConnProp) then begin //create connection @@ -496,6 +453,12 @@ FillGeneratorCombo; end; +procedure TfrmColumnRule.FreeRuleController; +begin + if assigned(FRuleController) then + FRuleController.Free; +end; + procedure TfrmColumnRule.FillGeneratorCombo; var I: Integer; Modified: branches/gui/src/ui/MainForm.dfm =================================================================== --- branches/gui/src/ui/MainForm.dfm 2006-12-27 13:36:53 UTC (rev 239) +++ branches/gui/src/ui/MainForm.dfm 2006-12-29 17:21:40 UTC (rev 240) @@ -1,9 +1,9 @@ object frmMain: TfrmMain Left = 257 Top = 155 - Width = 697 - Height = 480 Caption = 'Data Generator' + ClientHeight = 426 + ClientWidth = 689 Color = clBtnFace Font.Charset = TURKISH_CHARSET Font.Color = clWindowText @@ -19,9 +19,9 @@ TextHeight = 13 object FieldTree: TVirtualStringTree Left = 0 - Top = 27 + Top = 25 Width = 689 - Height = 380 + Height = 382 Align = alClient CheckImageKind = ckXP Colors.FocusedSelectionColor = clSkyBlue @@ -100,12 +100,11 @@ Left = 0 Top = 0 Width = 689 - Height = 27 + Height = 25 AutoSize = True ButtonHeight = 25 ButtonWidth = 37 Caption = 'ToolBar' - Flat = True HotImages = imlHotImages Images = imlColdImages ParentShowHint = False Modified: branches/gui/src/ui/MainForm.pas =================================================================== --- branches/gui/src/ui/MainForm.pas 2006-12-27 13:36:53 UTC (rev 239) +++ branches/gui/src/ui/MainForm.pas 2006-12-29 17:21:40 UTC (rev 240) @@ -171,7 +171,8 @@ implementation uses FormColumnRule, FormTableRule, FormConnectionProperties, FormProgress, - gnugettext, FormSettings, uSettings, DG_Generators, DG_Types; + gnugettext, FormSettings, uSettings, DG_Generators, DG_Types, + RuleControllerFactory; {$R *.dfm} @@ -410,16 +411,9 @@ Application.CreateForm(TfrmColumnRule, frmColumnRule); try - if not Assigned(ColumnRule) then - begin - ColumnRule := TDGColumnRule.Create(ColumnName); - NewColumnRule:= True; - end; try - frmColumnRule.ColumnRule := ColumnRule; - frmColumnRule.Caption := Format(_('Field : %s'), [ColumnName]); - frmColumnRule.lblDataType.Caption := ColumnType; - ModalValue:= frmColumnRule.ShowModal; + frmColumnRule.RuleController := TRuleControllerFactory.CreateRuleController(ColumnRule); + ModalValue := frmColumnRule.ShowModal; if ModalValue = mrOK then begin if not Assigned(TableRule) then @@ -443,13 +437,10 @@ procedure TfrmMain.FieldTreeDblClick(Sender : TObject); var Node : PVirtualNode; - NodeData : PNodeData; begin Node := FieldTree.FocusedNode; if not Assigned(Node) then Exit; - NodeData := FieldTree.GetNodeData(Node); - case FieldTree.GetNodeLevel(Node) of // Connection 0 : EditConnectionProperties(Node); Added: branches/gui/src/ui/controllers/AutoIncRuleController.pas =================================================================== --- branches/gui/src/ui/controllers/AutoIncRuleController.pas (rev 0) +++ branches/gui/src/ui/controllers/AutoIncRuleController.pas 2006-12-29 17:21:40 UTC (rev 240) @@ -0,0 +1,69 @@ +unit AutoIncRuleController; + +interface +uses Classes, DG_Core, RuleController; +type + + TAutoIncRuleController = class(TRuleController) + public + function GetParameterCount: Integer; override; + function GetParameterData(const i: Integer): TRuleParamDisplayData; override; + function GetParameterValue(const i: Integer): Variant; override; + procedure SetParameterValue(const i: Integer; value: Variant); override; + constructor Create(const columnName: String =''); override; + end; + +implementation +uses gnugettext, DG_Database, DG_Types; +{ TAutoIncRuleController } + +constructor TAutoIncRuleController.Create(const columnName: String =''); +begin + inherited; + if FColumnRule = nil then begin + FColumnRule := TDGColumnRule.Create(columnName); + FColumnRule.Strategy := gtAutoInc; + FColumnRule.NewParam('start','0'); + FColumnRule.NewParam('step','1'); + end; +end; + +function TAutoIncRuleController.GetParameterCount: Integer; +begin + Result := FColumnRule.Params.Count; +end; + +function TAutoIncRuleController.GetParameterData( + const i: Integer): TRuleParamDisplayData; +begin + case i of + 0: with Result do begin + Name := 'start'; + DisplayLabel:= _('Start'); + Description := _('Enter the starting value'); + DataTypes := 0; + Content := []; + end; + 1: with Result do begin + Name := 'step'; + DisplayLabel:= _('Step'); + Description := _('Enter the increment amount'); + DataTypes := 0; + Content := []; + end; + end; +end; + +function TAutoIncRuleController.GetParameterValue(const i: Integer): Variant; +begin + Result := FColumnRule.Params[i].Value; +end; + +procedure TAutoIncRuleController.SetParameterValue(const i: Integer; + value: Variant); +begin + inherited; + FColumnRule.Params[i].Value := Value; +end; + +end. Added: branches/gui/src/ui/controllers/RuleController.pas =================================================================== --- branches/gui/src/ui/controllers/RuleController.pas (rev 0) +++ branches/gui/src/ui/controllers/RuleController.pas 2006-12-29 17:21:40 UTC (rev 240) @@ -0,0 +1,79 @@ +unit RuleController; + +interface +uses Classes, SysUtils, DG_Core, DG_Database; +type + TProposalList = (plConnections, plSequences, plColumns); + TProposalLists = set of TProposalList; + + TRuleParamDisplayData = record + Name: String; + DisplayLabel: String; + DataTypes: integer; + Description: String; + Content : TProposalLists; + end; + + IColumnRuleController = interface + ['{76D94F5E-B656-43DD-BD9E-D2ACE62C66B5}'] + function GetParameterCount: Integer; + function GetParameterData(const i: integer):TRuleParamDisplayData; + function GetParameterValue(const i: integer):Variant; + procedure SetParameterValue(const i: integer; value: Variant); + function GetColumnRule: TDGColumnRule; + end; + + TRuleController = class(TInterfacedObject, IColumnRuleController) + protected + FColumnRule : TDGColumnRule; + public + constructor Create(const columnRule: TDGColumnRule); overload; virtual; + constructor Create(const columnName: String =''); overload; virtual; + function GetParameterCount: Integer; virtual; + function GetParameterData(const i: Integer): TRuleParamDisplayData; virtual; + function GetParameterValue(const i: Integer): Variant; virtual; + procedure SetParameterValue(const i: Integer; value: Variant); virtual; + function GetColumnRule: TDGColumnRule; virtual; + end; + +implementation + +{ TRuleController } + +constructor TRuleController.Create(const columnRule: TDGColumnRule); +begin + FColumnRule := columnRule; + Create; +end; + +constructor TRuleController.Create(const columnName: String =''); +begin +end; + +function TRuleController.GetColumnRule: TDGColumnRule; +begin + Result := FColumnRule; +end; + +function TRuleController.GetParameterCount: Integer; +begin +// Result := FColumnRule.Params.Count; + Result := 0; +end; + +function TRuleController.GetParameterData( + const i: Integer): TRuleParamDisplayData; +begin +end; + +function TRuleController.GetParameterValue(const i: Integer): Variant; +begin + Result := ''; +end; + +procedure TRuleController.SetParameterValue(const i: Integer; value: Variant); +begin + +end; + +end. Added: branches/gui/src/ui/controllers/RuleControllerFactory.pas =================================================================== --- branches/gui/src/ui/controllers/RuleControllerFactory.pas (rev 0) +++ branches/gui/src/ui/controllers/RuleControllerFactory.pas 2006-12-29 17:21:40 UTC (rev 240) @@ -0,0 +1,55 @@ +unit RuleControllerFactory; +interface +uses Classes, DG_Database, RuleController, DG_Types; +type + + TRuleControllerFactory = class + public + class function CreateRuleController(const ruleStrategy: TGeneratorType): TRuleController; overload; + class function CreateRuleController(const rule: TDGColumnRule): TRuleController; overload; + end; + +implementation +uses gnugettext, SysUtils, AutoIncRuleController, DG_Generators; + +{ TRuleControllerFactory } + +class function TRuleControllerFactory.CreateRuleController( + const ruleStrategy: TGeneratorType): TRuleController; +begin + case ruleStrategy of +// gtRange: ; +// gtSQL: ; +// gtScript: ; + gtAutoInc: Result := TAutoIncRuleController.Create ; +// gtComposite: ; +// gtFixed: ; +// gtCopy: ; +// gtSequence: ; +// gtPattern: ; +// gtVariable: ; + else + raise Exception.Create(Format(_('Cannot find controller for %s'),[GeneratorLocalName(ruleStrategy)])); + end; +end; + +class function TRuleControllerFactory.CreateRuleController( + const rule: TDGColumnRule): TRuleController; +begin + case rule.Strategy of +// gtRange: +// gtSQL: ; +// gtScript: ; + gtAutoInc: Result := TAutoIncRuleController.Create(rule); +// gtComposite: ; +// gtFixed: ; +// gtCopy: ; +// gtSequence: ; +// gtPattern: ; +// gtVariable: ; + else + raise Exception.Create(Format(_('Cannot find controller for %s'),[GeneratorLocalName(rule.Strategy)])); + end; +end; + +end. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <t-...@us...> - 2006-12-27 13:36:58
|
Revision: 239 http://svn.sourceforge.net/datagenerator/?rev=239&view=rev Author: t-hex Date: 2006-12-27 05:36:53 -0800 (Wed, 27 Dec 2006) Log Message: ----------- made a copy Added Paths: ----------- branches/gui/ Copied: branches/gui (from rev 238, trunk) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <t-...@us...> - 2006-12-26 18:59:53
|
Revision: 238 http://svn.sourceforge.net/datagenerator/?rev=238&view=rev Author: t-hex Date: 2006-12-26 10:59:52 -0800 (Tue, 26 Dec 2006) Log Message: ----------- Modified Paths: -------------- branches/xmlrules/src/dunit/DG_GeneratorsTests.pas branches/xmlrules/src/dunit/DG_ValuesTests.pas branches/xmlrules/src/dunit/DataGeneratorTests.dpr Modified: branches/xmlrules/src/dunit/DG_GeneratorsTests.pas =================================================================== --- branches/xmlrules/src/dunit/DG_GeneratorsTests.pas 2006-12-25 22:58:43 UTC (rev 237) +++ branches/xmlrules/src/dunit/DG_GeneratorsTests.pas 2006-12-26 18:59:52 UTC (rev 238) @@ -4,14 +4,10 @@ uses DG_Generators, DG_Values, DG_Intfs, - TestFrameWork,Classes; + TestFrameWork, Classes, DG_AutoIncGenerator, DG_PascalScriptedGenerator, + DG_CachedGenerator, DG_SingleValue, DG_RangedGenerator, DG_FileLink; type - {TFixedGeneratorTests = class(TTestCase) - published - procedure TestGenerate; - end;} - TAutoIncGeneratorTests = class(TTestCase) private FAutoIncGenerator: TAutoIncGenerator; Modified: branches/xmlrules/src/dunit/DG_ValuesTests.pas =================================================================== --- branches/xmlrules/src/dunit/DG_ValuesTests.pas 2006-12-25 22:58:43 UTC (rev 237) +++ branches/xmlrules/src/dunit/DG_ValuesTests.pas 2006-12-26 18:59:52 UTC (rev 238) @@ -3,9 +3,10 @@ interface uses - DG_Values, DG_Core, DG_Configuration, DG_Intfs, - TestFrameWork, SysUtils, Classes, ZConnection, ZDbcIntfs, DG_Types, - DG_Database; + DG_Values, DG_Core, DG_Project, DG_Intfs, + TestFrameWork, SysUtils, Classes, ZConnection, ZDbcIntfs, + DG_Types, DG_FileLink, DG_ListLink, DG_Datagenerator, + DG_SingleValue, DG_TableRule; type TSingleValueTests = class(TTestCase) @@ -40,17 +41,17 @@ TContextLinkTests = class(TTestCase,IExporter) private FGenerator: TDataGenerator; - FConfiguration: TDGConfiguration; + FProject: TProject; protected procedure SetUp; override; procedure TearDown; override; public - procedure FinishedTable(ATableRule : TDGTableRule); - procedure RowGenerated(ATableRule : TDGTableRule; + procedure FinishedTable(ATableRule : TObject); + procedure RowGenerated(ATableRule : TObject; const AProvider: IValueProvider); - procedure StartedTable(ATableRule : TDGTableRule); - function GetConnection: TZConnection; - procedure SetConnection(Value: TZConnection); + procedure StartedTable(ATableRule : TObject); + function GetConnection: IZConnection; + procedure SetConnection(Value: IZConnection); published // Test methods procedure TestGetValue; @@ -68,7 +69,7 @@ implementation -uses Variants, DG_Generators; +uses Variants, DG_Generators, DG_AutoIncRule, DG_RangeRule, DG_PatternValue; { TSingleValueTests } @@ -180,17 +181,17 @@ { TContextLinkTests } -procedure TContextLinkTests.FinishedTable(ATableRule: TDGTableRule); +procedure TContextLinkTests.FinishedTable(ATableRule: TObject); begin //Dummy end; -function TContextLinkTests.GetConnection: TZConnection; +function TContextLinkTests.GetConnection: IZConnection; begin //Dummy end; -procedure TContextLinkTests.RowGenerated(ATableRule:TDGTableRule;const AProvider: IValueProvider); +procedure TContextLinkTests.RowGenerated(ATableRule: TObject;const AProvider: IValueProvider); var val1,val2 : Integer; begin @@ -199,36 +200,38 @@ Check(val1 <= val2,'ContextLink went out of range'); end; -procedure TContextLinkTests.SetConnection(Value: TZConnection); +procedure TContextLinkTests.SetConnection(Value: IZConnection); begin end; procedure TContextLinkTests.SetUp; var - FTableRule: TDGTableRule; + FTableRule: TTableRule; + FAutoIncRule: TAutoIncRule; + FRangeRule : TRangeRule; begin inherited; - FConfiguration:= TDGConfiguration.Create; - FTableRule := TDGTableRule.Create('TEST'); + FProject:= TProject.Create; + FTableRule := TTableRule.Create; + FTableRule.table := 'TEST'; with FTableRule do begin Rows := 3; - with NewColumnRule('FDUMAN') do begin - Strategy := gtAutoInc; - Params.Add(TDGParam.Create('','0')); - Params.Add(TDGParam.Create('','1')); - end; - with NewColumnRule('CONTEXT') do begin - Strategy := gtRange; - Params.Add(TDGParam.Create('','1')); - Params.Add(TDGParam.Create('','3')); - end; + FAutoIncRule:= TAutoIncRule.Create(FTableRule); + FAutoIncRule.column := 'FDUMAN'; + FAutoIncRule.start := '0'; + FAutoIncRule.step := '1'; + + FRangeRule := TRangeRule.Create(FTableRule); + FRangeRule.column := 'RANGE'; + FRangeRule.start := '1'; + FRangeRule.stop := '3'; end; - FGenerator:= TDataGenerator.Create(FConfiguration); + FGenerator:= TDataGenerator.Create(FProject); FTableRule.Free; end; -procedure TContextLinkTests.StartedTable(ATableRule: TDGTableRule); +procedure TContextLinkTests.StartedTable(ATableRule: TObject); begin end; @@ -237,7 +240,7 @@ begin inherited; FGenerator:= nil; - FConfiguration.Free; + FProject.Free; end; procedure TContextLinkTests.TestGetValue; Modified: branches/xmlrules/src/dunit/DataGeneratorTests.dpr =================================================================== --- branches/xmlrules/src/dunit/DataGeneratorTests.dpr 2006-12-25 22:58:43 UTC (rev 237) +++ branches/xmlrules/src/dunit/DataGeneratorTests.dpr 2006-12-26 18:59:52 UTC (rev 238) @@ -5,26 +5,48 @@ program DataGeneratorTests; uses - TestFramework {$IFDEF LINUX}, - QForms, - QGUITestRunner {$ELSE}, Forms, - GUITestRunner {$ENDIF}, + TestFramework, TextTestRunner, + GUITestRunner, + gnugettext in '..\..\3rdParty\GnuGettext\gnugettext.pas', DG_ValuesTests in 'DG_ValuesTests.pas', DG_GeneratorsTests in 'DG_GeneratorsTests.pas', - DG_Values in '..\lib\DG_Values.pas', + TestTools in 'TestTools.pas', + DG_ConnectionFactory in '..\lib\DG_ConnectionFactory.pas', + DG_Core in '..\lib\DG_Core.pas', + DG_Datagenerator in '..\lib\DG_Datagenerator.pas', + DG_Exporters in '..\lib\DG_Exporters.pas', DG_Intfs in '..\lib\DG_Intfs.pas', - DG_Generators in '..\lib\DG_Generators.pas', + DG_Types in '..\lib\DG_Types.pas', DG_Utils in '..\lib\DG_Utils.pas', - DG_Core in '..\lib\DG_Core.pas', - DG_Configuration in '..\lib\DG_Configuration.pas', - config in '..\lib\config.pas', - DG_Database in '..\lib\DG_Database.pas', - TestTools in 'TestTools.pas', - DG_Builders in '..\lib\DG_Builders.pas', - gnugettext in '..\..\3rdParty\GnuGettext\gnugettext.pas', - DG_Types in '..\lib\DG_Types.pas'; + DG_AutoIncGenerator in '..\lib\generators\DG_AutoIncGenerator.pas', + DG_CachedGenerator in '..\lib\generators\DG_CachedGenerator.pas', + DG_CompositeGenerator in '..\lib\generators\DG_CompositeGenerator.pas', + DG_Generators in '..\lib\generators\DG_Generators.pas', + DG_LinkedGenerator in '..\lib\generators\DG_LinkedGenerator.pas', + DG_PascalScriptedGenerator in '..\lib\generators\DG_PascalScriptedGenerator.pas', + DG_RangedGenerator in '..\lib\generators\DG_RangedGenerator.pas', + DG_AutoIncRule in '..\lib\rules\DG_AutoIncRule.pas', + DG_ColumnRule in '..\lib\rules\DG_ColumnRule.pas', + DG_ConnectionRule in '..\lib\rules\DG_ConnectionRule.pas', + DG_CopyRule in '..\lib\rules\DG_CopyRule.pas', + DG_FixedRule in '..\lib\rules\DG_FixedRule.pas', + DG_PascalScriptRule in '..\lib\rules\DG_PascalScriptRule.pas', + DG_PatternRule in '..\lib\rules\DG_PatternRule.pas', + DG_Project in '..\lib\rules\DG_Project.pas', + DG_RangeRule in '..\lib\rules\DG_RangeRule.pas', + DG_SequenceRule in '..\lib\rules\DG_SequenceRule.pas', + DG_SQLRule in '..\lib\rules\DG_SQLRule.pas', + DG_TableRule in '..\lib\rules\DG_TableRule.pas', + DG_ContextLink in '..\lib\values\DG_ContextLink.pas', + DG_FieldLink in '..\lib\values\DG_FieldLink.pas', + DG_FileLink in '..\lib\values\DG_FileLink.pas', + DG_ListLink in '..\lib\values\DG_ListLink.pas', + DG_PatternValue in '..\lib\values\DG_PatternValue.pas', + DG_SequenceLink in '..\lib\values\DG_SequenceLink.pas', + DG_SingleValue in '..\lib\values\DG_SingleValue.pas', + DG_Values in '..\lib\values\DG_Values.pas'; {$R *.RES} @@ -38,6 +60,5 @@ else GUITestRunner.RunRegisteredTests; {$ENDIF} - end. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <t-...@us...> - 2006-12-25 22:58:44
|
Revision: 237 http://svn.sourceforge.net/datagenerator/?rev=237&view=rev Author: t-hex Date: 2006-12-25 14:58:43 -0800 (Mon, 25 Dec 2006) Log Message: ----------- using interface causing access violation!!!!!!!!!! AARAGAHSDGJAHSG!_!'?\197?\158:?\195?\135QJFSa Modified Paths: -------------- branches/xmlrules/src/lib/DG_ConnectionFactory.pas Modified: branches/xmlrules/src/lib/DG_ConnectionFactory.pas =================================================================== --- branches/xmlrules/src/lib/DG_ConnectionFactory.pas 2006-12-25 22:51:58 UTC (rev 236) +++ branches/xmlrules/src/lib/DG_ConnectionFactory.pas 2006-12-25 22:58:43 UTC (rev 237) @@ -3,28 +3,22 @@ interface uses Classes, ZDbcIntfs, DG_ConnectionRule, ZConnection; type - IConnectionFactory = interface - ['{93947E83-BDF6-48EB-8DDB-1228D5973D43}'] - function CreateConnection(const connRule: TConnectionRule):IZConnection; + TConnectionFactory = class + public + function CreateConnection(const connRule: TConnectionRule): IZConnection; end; -function ConnectionFactory:IConnectionFactory; +function ConnectionFactory:TConnectionFactory; procedure AssignConnectionRule(var conn: TZConnection; const connRule:TConnectionRule); implementation -type - TConnectionFactory = class(TInterfacedObject,IConnectionFactory) - public - function CreateConnection(const connRule: TConnectionRule): IZConnection; - end; - var _ConnectionFactory : TConnectionFactory; -function ConnectionFactory:IConnectionFactory; +function ConnectionFactory:TConnectionFactory; begin - Result := _ConnectionFactory as IConnectionFactory; + Result := _ConnectionFactory; end; procedure AssignConnectionRule(var conn: TZConnection; const connRule:TConnectionRule); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <t-...@us...> - 2006-12-25 22:52:00
|
Revision: 236 http://svn.sourceforge.net/datagenerator/?rev=236&view=rev Author: t-hex Date: 2006-12-25 14:51:58 -0800 (Mon, 25 Dec 2006) Log Message: ----------- Modified Paths: -------------- branches/xmlrules/src/lib/DG_Core.pas branches/xmlrules/src/lib/DG_Datagenerator.pas branches/xmlrules/src/lib/DG_Intfs.pas branches/xmlrules/src/lib/rules/DG_AutoIncRule.pas branches/xmlrules/src/lib/rules/DG_ColumnRule.pas branches/xmlrules/src/lib/rules/DG_CopyRule.pas branches/xmlrules/src/lib/rules/DG_FixedRule.pas branches/xmlrules/src/lib/rules/DG_PascalScriptRule.pas branches/xmlrules/src/lib/rules/DG_PatternRule.pas branches/xmlrules/src/lib/rules/DG_Project.pas branches/xmlrules/src/lib/rules/DG_RangeRule.pas branches/xmlrules/src/lib/rules/DG_SQLRule.pas branches/xmlrules/src/lib/rules/DG_SequenceRule.pas Modified: branches/xmlrules/src/lib/DG_Core.pas =================================================================== --- branches/xmlrules/src/lib/DG_Core.pas 2006-12-25 20:33:30 UTC (rev 235) +++ branches/xmlrules/src/lib/DG_Core.pas 2006-12-25 22:51:58 UTC (rev 236) @@ -57,7 +57,6 @@ function ToXML:String; virtual; function IsSingleNode: Boolean; virtual; procedure ReadProperties(const aPropertyList: TStrings); virtual; - function Add(aClass: TXMLNodeClass):TXMLNode; virtual; property Parent: TXMLNode read fParent; property Child[I: Integer]: TXMLNode read GetChild; @@ -171,14 +170,9 @@ fParent := AParent; end; -function TXMLNode.Add(aClass: TXMLNodeClass): TXMLNode; -begin - Result := TXMLNodeClass.Create(self); -end; - constructor TXMLNode.Create; begin - FChilds := TList.Create; + FChilds := TList.Create; end; destructor TXMLNode.Destroy; @@ -312,7 +306,7 @@ function TXMLNode.GetChildCount: Integer; begin - Result := FChilds.Count; + Result := FChilds.Count; end; function TXMLNode.IsSingleNode: Boolean; Modified: branches/xmlrules/src/lib/DG_Datagenerator.pas =================================================================== --- branches/xmlrules/src/lib/DG_Datagenerator.pas 2006-12-25 20:33:30 UTC (rev 235) +++ branches/xmlrules/src/lib/DG_Datagenerator.pas 2006-12-25 22:51:58 UTC (rev 236) @@ -17,8 +17,6 @@ FConnectionPool : TInterfaceList; FStopped: Boolean; protected - function _AddRef : Integer; stdcall; - function _Release : Integer; stdcall; {** Creates TDGGenerator instances.} procedure CreateGenerators(ATableRule : TTableRule); procedure GenerateGenerators; @@ -338,16 +336,6 @@ Result:= TSingleValue.Create(param); end; -function TDataGenerator._AddRef : Integer; -begin - Result := -1; -end; - -function TDataGenerator._Release : Integer; -begin - Result := -1; -end; - procedure TDataGenerator.GenerateGenerators; var I : Integer; Modified: branches/xmlrules/src/lib/DG_Intfs.pas =================================================================== --- branches/xmlrules/src/lib/DG_Intfs.pas 2006-12-25 20:33:30 UTC (rev 235) +++ branches/xmlrules/src/lib/DG_Intfs.pas 2006-12-25 22:51:58 UTC (rev 236) @@ -68,6 +68,15 @@ function ProcessParameter(const param: String):IValue; end; + IConnectionPool = interface + ['{33039C16-CA41-48B1-BD54-666E6A9BC45C}'] + procedure AddConnection(const ref: String; const conn: IZConnection); + procedure RemoveConnection(const Ref:String);overload; + procedure RemoveConnection(const i : integer);overload; + function GetConnection(const Ref: String):IZConnection;overload; + function GetConnection(const i: integer):IZConnection;overload; + end; + {** An interface for the classes that wish to be notified on column and row values are generated. Modified: branches/xmlrules/src/lib/rules/DG_AutoIncRule.pas =================================================================== --- branches/xmlrules/src/lib/rules/DG_AutoIncRule.pas 2006-12-25 20:33:30 UTC (rev 235) +++ branches/xmlrules/src/lib/rules/DG_AutoIncRule.pas 2006-12-25 22:51:58 UTC (rev 236) @@ -8,8 +8,7 @@ FStart: string; FStep: string; public - function BuildGenerator(const valueProvider: IValueProvider): TCustomGenerator; - override; + function BuildGenerator(const valueProvider: IValueProvider; const connPool: IConnectionPool = nil): TCustomGenerator; override; function ToString: string; override; class function TagName: string; override; published @@ -22,8 +21,7 @@ uses SysUtils, DG_AutoIncGenerator; { TAutoIncColumnRule } -function TAutoIncRule.BuildGenerator( - const valueProvider: IValueProvider): TCustomGenerator; +function TAutoIncRule.BuildGenerator(const valueProvider: IValueProvider; const connPool: IConnectionPool = nil): TCustomGenerator; begin with valueProvider do Result := TAutoIncGenerator.Create( Modified: branches/xmlrules/src/lib/rules/DG_ColumnRule.pas =================================================================== --- branches/xmlrules/src/lib/rules/DG_ColumnRule.pas 2006-12-25 20:33:30 UTC (rev 235) +++ branches/xmlrules/src/lib/rules/DG_ColumnRule.pas 2006-12-25 22:51:58 UTC (rev 236) @@ -11,7 +11,7 @@ FColumn: String; public class function TagName: string; override; - function BuildGenerator(const valueProvider: IValueProvider): TCustomGenerator; virtual; abstract; + function BuildGenerator(const valueProvider: IValueProvider; const connPool: IConnectionPool = nil): TCustomGenerator; virtual; abstract; published property column: String read FColumn write fColumn; property nullpercentage: Integer read FNullPercentage write fNullPercentage default 0; Modified: branches/xmlrules/src/lib/rules/DG_CopyRule.pas =================================================================== --- branches/xmlrules/src/lib/rules/DG_CopyRule.pas 2006-12-25 20:33:30 UTC (rev 235) +++ branches/xmlrules/src/lib/rules/DG_CopyRule.pas 2006-12-25 22:51:58 UTC (rev 236) @@ -8,8 +8,7 @@ private ffrom: string; public - function BuildGenerator(const valueProvider: IValueProvider): TCustomGenerator; - override; + function BuildGenerator(const valueProvider: IValueProvider; const connPool: IConnectionPool = nil): TCustomGenerator; override; function ToString: string; override; class function TagName: string; override; published @@ -22,8 +21,7 @@ { TCopyRule } -function TCopyRule.BuildGenerator( - const valueProvider: IValueProvider): TCustomGenerator; +function TCopyRule.BuildGenerator(const valueProvider: IValueProvider; const connPool: IConnectionPool = nil): TCustomGenerator; var ContextLink: TContextLink; begin Modified: branches/xmlrules/src/lib/rules/DG_FixedRule.pas =================================================================== --- branches/xmlrules/src/lib/rules/DG_FixedRule.pas 2006-12-25 20:33:30 UTC (rev 235) +++ branches/xmlrules/src/lib/rules/DG_FixedRule.pas 2006-12-25 22:51:58 UTC (rev 236) @@ -7,8 +7,7 @@ private fvalue: string; public - function BuildGenerator(const valueProvider: IValueProvider): TCustomGenerator; - override; + function BuildGenerator(const valueProvider: IValueProvider; const connPool: IConnectionPool = nil): TCustomGenerator; function ToString: string; override; class function TagName: string; override; published @@ -20,8 +19,7 @@ { TFixedRule } -function TFixedRule.BuildGenerator( - const valueProvider: IValueProvider): TCustomGenerator; +function TFixedRule.BuildGenerator(const valueProvider: IValueProvider; const connPool: IConnectionPool = nil): TCustomGenerator; var val : IValue; begin Modified: branches/xmlrules/src/lib/rules/DG_PascalScriptRule.pas =================================================================== --- branches/xmlrules/src/lib/rules/DG_PascalScriptRule.pas 2006-12-25 20:33:30 UTC (rev 235) +++ branches/xmlrules/src/lib/rules/DG_PascalScriptRule.pas 2006-12-25 22:51:58 UTC (rev 236) @@ -5,18 +5,16 @@ type TPascalScriptRule = class(TContentColumnRule) public - function BuildGenerator(const valueProvider: IValueProvider): TCustomGenerator; - override; + function BuildGenerator(const valueProvider: IValueProvider; const connPool: IConnectionPool = nil): TCustomGenerator; function ToString: string; override; class function TagName: string; override; end; - + implementation uses SysUtils, DG_PascalScriptedGenerator; { TScriptRule } -function TPascalScriptRule.BuildGenerator( - const valueProvider: IValueProvider): TCustomGenerator; +function TPascalScriptRule.BuildGenerator(const valueProvider: IValueProvider; const connPool: IConnectionPool = nil): TCustomGenerator; begin Result := TScriptedGenerator.Create( valueProvider.ProcessParameter(content), Modified: branches/xmlrules/src/lib/rules/DG_PatternRule.pas =================================================================== --- branches/xmlrules/src/lib/rules/DG_PatternRule.pas 2006-12-25 20:33:30 UTC (rev 235) +++ branches/xmlrules/src/lib/rules/DG_PatternRule.pas 2006-12-25 22:51:58 UTC (rev 236) @@ -7,8 +7,7 @@ private fpattern: string; public - function BuildGenerator(const valueProvider: IValueProvider): TCustomGenerator; - override; + function BuildGenerator(const valueProvider: IValueProvider; const connPool: IConnectionPool = nil): TCustomGenerator; override; function ToString: string; override; class function TagName: string; override; published @@ -20,8 +19,7 @@ { TPatternRule } -function TPatternRule.BuildGenerator( - const valueProvider: IValueProvider): TCustomGenerator; +function TPatternRule.BuildGenerator(const valueProvider: IValueProvider; const connPool: IConnectionPool = nil): TCustomGenerator; begin Result := TLinkedGenerator.Create(TPatternValue.Create(Pattern)); end; Modified: branches/xmlrules/src/lib/rules/DG_Project.pas =================================================================== --- branches/xmlrules/src/lib/rules/DG_Project.pas 2006-12-25 20:33:30 UTC (rev 235) +++ branches/xmlrules/src/lib/rules/DG_Project.pas 2006-12-25 22:51:58 UTC (rev 236) @@ -52,7 +52,7 @@ connRule := GetConnectionByRef(connRef); if connRule <> nil then tableRule := connRule.FindTableRule(tableName); - if connRule <> nil then + if tableRule <> nil then Result := tableRule.FindColumnRule(columnName); end; Modified: branches/xmlrules/src/lib/rules/DG_RangeRule.pas =================================================================== --- branches/xmlrules/src/lib/rules/DG_RangeRule.pas 2006-12-25 20:33:30 UTC (rev 235) +++ branches/xmlrules/src/lib/rules/DG_RangeRule.pas 2006-12-25 22:51:58 UTC (rev 236) @@ -8,8 +8,7 @@ FStart: String; FStop: String; public - function BuildGenerator(const valueProvider: IValueProvider): TCustomGenerator; - override; + function BuildGenerator(const valueProvider: IValueProvider; const connPool: IConnectionPool = nil): TCustomGenerator; override; function ToString: string; override; class function TagName: string; override; published @@ -24,8 +23,7 @@ { TRangeColumnRule } -function TRangeRule.BuildGenerator( - const valueProvider: IValueProvider): TCustomGenerator; +function TRangeRule.BuildGenerator(const valueProvider: IValueProvider; const connPool: IConnectionPool = nil): TCustomGenerator; begin Result := TRangedGenerator.Create( valueProvider.ProcessParameter(start), Modified: branches/xmlrules/src/lib/rules/DG_SQLRule.pas =================================================================== --- branches/xmlrules/src/lib/rules/DG_SQLRule.pas 2006-12-25 20:33:30 UTC (rev 235) +++ branches/xmlrules/src/lib/rules/DG_SQLRule.pas 2006-12-25 22:51:58 UTC (rev 236) @@ -7,8 +7,7 @@ private fDbRef: String; public - function BuildGenerator(const valueProvider: IValueProvider): TCustomGenerator; - override; + function BuildGenerator(const valueProvider: IValueProvider; const connPool: IConnectionPool = nil): TCustomGenerator; override; function ToString: string; override; class function TagName: string; override; published @@ -16,25 +15,21 @@ end; implementation -uses SysUtils, ZDbcIntfs, DG_Values; +uses SysUtils, ZDbcIntfs, DG_Values, DG_FieldLink, DG_CachedGenerator; { TSQLRule } -function TSQLRule.BuildGenerator( - const valueProvider: IValueProvider): TCustomGenerator; +function TSQLRule.BuildGenerator(const valueProvider: IValueProvider; const connPool: IConnectionPool = nil): TCustomGenerator; var Connection : IZConnection; Statement : IZStatement; FieldLink : IValue; begin -{ TODO 5 : fix this } -(* - Connection := datagenerator.GetConnectionByRef(dbref) as IZConnection; - Statement := Connection.CreateStatement; - FieldLink := TFieldLink.Create(Statement.ExecuteQuery(content)); - Result := TCachedGenerator.Create(FieldLink); - -*)end; + Connection := ConnPool.GetConnection(Fdbref); + Statement := Connection.CreateStatement; + FieldLink := TFieldLink.Create(Statement.ExecuteQuery(content)); + Result := TCachedGenerator.Create(FieldLink); +end; class function TSQLRule.TagName: string; begin Modified: branches/xmlrules/src/lib/rules/DG_SequenceRule.pas =================================================================== --- branches/xmlrules/src/lib/rules/DG_SequenceRule.pas 2006-12-25 20:33:30 UTC (rev 235) +++ branches/xmlrules/src/lib/rules/DG_SequenceRule.pas 2006-12-25 22:51:58 UTC (rev 236) @@ -9,8 +9,7 @@ fSequence: string; fStep: integer; public - function BuildGenerator(const valueProvider: IValueProvider): TCustomGenerator; - override; + function BuildGenerator(const valueProvider: IValueProvider; const connPool: IConnectionPool = nil): TCustomGenerator; override; function ToString: string; override; class function TagName: string; override; published @@ -20,23 +19,20 @@ end; implementation -uses SysUtils, ZDbcIntfs, DG_Values; -{ TSequeceColumnRule } +uses SysUtils, ZDbcIntfs, DG_Values, DG_SequenceLink, + DG_LinkedGenerator; -function TSequenceRule.BuildGenerator( - const valueProvider: IValueProvider): TCustomGenerator; +{ TSequeceColumnRule } +function TSequenceRule.BuildGenerator(const valueProvider: IValueProvider; const connPool: IConnectionPool = nil): TCustomGenerator; var SequenceLink : IValue; FSequence : IZSequence; Connection : IZConnection; begin -{ TODO 5 : fix this } - (* - Connection := datagenerator.GetConnectionByRef(connref) as IZConnection; - FSequence := connection.CreateSequence(sequence,step); - SequenceLink := TSequenceLink.Create(FSequence); - Result := TLinkedGenerator.Create(SequenceLink); - *) + Connection := connPool.GetConnection(connref); + FSequence := connection.CreateSequence(sequence,step); + SequenceLink := TSequenceLink.Create(FSequence); + Result := TLinkedGenerator.Create(SequenceLink); end; class function TSequenceRule.TagName: string; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <t-...@us...> - 2006-12-25 20:33:33
|
Revision: 235 http://svn.sourceforge.net/datagenerator/?rev=235&view=rev Author: t-hex Date: 2006-12-25 12:33:30 -0800 (Mon, 25 Dec 2006) Log Message: ----------- Modified Paths: -------------- branches/xmlrules/src/lib/DG_Core.pas branches/xmlrules/src/lib/rules/DG_ConnectionRule.pas branches/xmlrules/src/lib/rules/DG_Project.pas branches/xmlrules/src/lib/rules/DG_TableRule.pas branches/xmlrules/src/ui/DataGeneratorUI.dpr branches/xmlrules/src/ui/FormColumnRule.pas branches/xmlrules/src/ui/MainForm.dfm branches/xmlrules/src/ui/MainForm.pas Added Paths: ----------- branches/xmlrules/src/ui/uRuleController.pas Modified: branches/xmlrules/src/lib/DG_Core.pas =================================================================== --- branches/xmlrules/src/lib/DG_Core.pas 2006-12-24 11:07:11 UTC (rev 234) +++ branches/xmlrules/src/lib/DG_Core.pas 2006-12-25 20:33:30 UTC (rev 235) @@ -65,21 +65,9 @@ property ChildCount: Integer read GetChildCount; end; - - - {**Creates a TZConnection instance using aConnProp. - @param aConnProp Properties to be assigned to the initialized connection.} -//function CreateConnection(AConnProp : TConnectionRule) : TZConnection; - - {**Assigns the properties of aConnProp to Connection. - @param Connection An instance of the class TZConnection. Connection is disconnected - if it is already active. - @param aConnProp An instance of the class TDGConnectionProperty.} - -//procedure AssignConnectionProperties(const Connection : TZConnection; -// AConnProp : TDGConnectionProperty); - procedure RegisterRule(rule: TXMLNodeClass); +function RegisteredRuleCount:Integer; +function GetRegisteredRule(const i: Integer): TXMLNodeClass; function FindRuleClass(const aTagName: String):TXMLNodeClass; implementation @@ -94,35 +82,6 @@ var RulesRegistry : array of TRegistryRec; -{ - procedure AssignConnectionProperties(const Connection : TZConnection; AConnProp : TDGConnectionProperty); - begin - Assert(Connection <> nil, 'Connection is nil'); - - if Connection.Connected then - Connection.Disconnect; - - with Connection do - begin - Protocol := AConnProp.Protocol; - Catalog := AConnProp.Catalog; - HostName := AConnProp.Host; - Port := AConnProp.Port; - Database := AConnProp.Database; - User := AConnProp.Username; - Password := AConnProp.Password; - AutoCommit := False; - end; - end; - - function CreateConnection(AConnProp : TDGConnectionProperty) : TZConnection; - begin - Result := TZConnection.Create(nil); - AssignConnectionProperties(Result, AConnProp); - end; - -} - procedure RegisterRule(rule: TXMLNodeClass); var registrySize : integer; @@ -135,6 +94,16 @@ end; end; +function RegisteredRuleCount:Integer; +begin + Result := Length(RulesRegistry); +end; + +function GetRegisteredRule(const i: Integer): TXMLNodeClass; +begin + Result := RulesRegistry[i].ruleClass; +end; + function FindRuleClass(const aTagName: String):TXMLNodeClass; var i: Integer; Modified: branches/xmlrules/src/lib/rules/DG_ConnectionRule.pas =================================================================== --- branches/xmlrules/src/lib/rules/DG_ConnectionRule.pas 2006-12-24 11:07:11 UTC (rev 234) +++ branches/xmlrules/src/lib/rules/DG_ConnectionRule.pas 2006-12-25 20:33:30 UTC (rev 235) @@ -37,8 +37,16 @@ { TConnectionRule } function TConnectionRule.FindTableRule(const tableName: String): TTableRule; +var + I: Integer; begin - { TODO 4 : implement } + Result := nil; + for I := 0 to childcount - 1 do + if TableRule[i].table = tableName then + begin + Result := TableRule[i]; + break; + end; end; function TConnectionRule.GetTableRule(I: Integer): TTableRule; Modified: branches/xmlrules/src/lib/rules/DG_Project.pas =================================================================== --- branches/xmlrules/src/lib/rules/DG_Project.pas 2006-12-24 11:07:11 UTC (rev 234) +++ branches/xmlrules/src/lib/rules/DG_Project.pas 2006-12-25 20:33:30 UTC (rev 235) @@ -21,7 +21,7 @@ class function LoadFromFile(const aFileName:String):TProject; virtual; class procedure SaveToFile(const aProject:TProject; const aFileName: String); overload;virtual; procedure SaveToFile(const aFileName:String); overload; virtual; - function FindColumnRule(const connRef: String; const tableName: String; const columnName):TColumnRule; + function FindColumnRule(const connRef: String; const tableName: String; const columnName:String):TColumnRule; function FindTableRule(const connRef: String; const tableName: String):TTableRule; function AddConnectionRule: TConnectionRule; virtual; property ConnectionRule[I: Integer]: TConnectionRule read GetConnectionRule; @@ -42,14 +42,28 @@ end; function TProject.FindColumnRule(const connRef, tableName: String; - const columnName): TColumnRule; + const columnName:string): TColumnRule; +var + I: Integer; + connRule : TConnectionRule; + tableRule : TTableRule; begin - { TODO 4 : implement } + Result := nil; + connRule := GetConnectionByRef(connRef); + if connRule <> nil then + tableRule := connRule.FindTableRule(tableName); + if connRule <> nil then + Result := tableRule.FindColumnRule(columnName); end; function TProject.FindTableRule(const connRef, tableName: String): TTableRule; +var + connRule : TConnectionRule; begin - { TODO 4 : implement } + Result := nil; + connRule := GetConnectionByRef(connRef); + if connRule <> nil then + Result := connRule.FindTableRule(tableName); end; function TProject.GetConnectionByRef(const ref: string): TConnectionRule; Modified: branches/xmlrules/src/lib/rules/DG_TableRule.pas =================================================================== --- branches/xmlrules/src/lib/rules/DG_TableRule.pas 2006-12-24 11:07:11 UTC (rev 234) +++ branches/xmlrules/src/lib/rules/DG_TableRule.pas 2006-12-25 20:33:30 UTC (rev 235) @@ -35,8 +35,16 @@ end; function TTableRule.FindColumnRule(const columnName: String): TColumnRule; +var + I: Integer; begin - { TODO 4 : implement } + Result := nil; + for I := 0 to ChildCount - 1 do + if ColumnRule[i].column = columnName then + begin + Result := ColumnRule[i]; + break; + end; end; function TTableRule.GetColumnRule(I: Integer): TColumnRule; Modified: branches/xmlrules/src/ui/DataGeneratorUI.dpr =================================================================== --- branches/xmlrules/src/ui/DataGeneratorUI.dpr 2006-12-24 11:07:11 UTC (rev 234) +++ branches/xmlrules/src/ui/DataGeneratorUI.dpr 2006-12-25 20:33:30 UTC (rev 235) @@ -58,7 +58,8 @@ DG_SequenceLink in '..\lib\values\DG_SequenceLink.pas', DG_SingleValue in '..\lib\values\DG_SingleValue.pas', DG_Values in '..\lib\values\DG_Values.pas', - DG_ConnectionFactory in '..\lib\DG_ConnectionFactory.pas'; + DG_ConnectionFactory in '..\lib\DG_ConnectionFactory.pas', + uRuleController in 'uRuleController.pas'; {$R *.res} {$R dgver.res} // required Modified: branches/xmlrules/src/ui/FormColumnRule.pas =================================================================== --- branches/xmlrules/src/ui/FormColumnRule.pas 2006-12-24 11:07:11 UTC (rev 234) +++ branches/xmlrules/src/ui/FormColumnRule.pas 2006-12-25 20:33:30 UTC (rev 235) @@ -80,8 +80,8 @@ procedure PerformPopupAction(ActionType : TActionType; Node: PVirtualNode); end; - PParamData = ^TParamData; - TParamData = record + PPropNodeData = ^TPropNodeData; + TPropNodeData = record Tip : String; Value: String; Info : String; @@ -125,7 +125,7 @@ ParentNode, Node: PVirtualNode; var InitialStates: TVirtualNodeInitStates); var - ParamData : PParamData; + ParamData : PPropNodeData; begin inherited; ParamData := Sender.GetNodeData(Node); @@ -137,7 +137,7 @@ Node: PVirtualNode; Column: TColumnIndex; TextType: TVSTTextType; var CellText: WideString); var - ParamData : PParamData; + ParamData : PPropNodeData; begin inherited; ParamData := Sender.GetNodeData(Node); @@ -186,13 +186,13 @@ Sender: TBaseVirtualTree; var NodeDataSize: Integer); begin inherited; - NodeDataSize := Sizeof(TParamData); + NodeDataSize := Sizeof(TPropNodeData); end; procedure TfrmColumnRule.ParamTreeListNewText(Sender: TBaseVirtualTree; Node: PVirtualNode; Column: TColumnIndex; NewText: WideString); var - ParamData : PParamData; + ParamData : PPropNodeData; begin inherited; ParamData := Sender.GetNodeData(Node); @@ -239,7 +239,7 @@ procedure TfrmColumnRule.AddParamNode(Tip, Value: String; Info: string = ''; AListType: TListType = ltNone); var Node : PVirtualNode; - ParamData : PParamData; + ParamData : PPropNodeData; begin { TODO 5 : fix here } // Node := ParamTreeList.AddChild(nil); @@ -258,7 +258,7 @@ procedure TfrmColumnRule.ParamTreeListChange(Sender: TBaseVirtualTree; Node: PVirtualNode); var - ParamData : PParamData; + ParamData : PPropNodeData; begin inherited; if Node = nil then exit; @@ -269,7 +269,7 @@ procedure TfrmColumnRule.btnOKClick(Sender: TObject); var Node : PVirtualNode; - ParamData : PParamData; + ParamData : PPropNodeData; begin inherited; { TODO 5 : fix here } @@ -287,7 +287,7 @@ procedure TfrmColumnRule.ParamTreeListDblClick(Sender: TObject); var Node: PVirtualNode; - NodeParamData : PParamData; + NodeParamData : PPropNodeData; begin inherited; if ParamTreeList.FocusedColumn <> 1 then exit; @@ -314,7 +314,7 @@ procedure TfrmColumnRule.PerformPopupAction(ActionType: TActionType; Node: PVirtualNode); var - ParamData : PParamData; + ParamData : PPropNodeData; begin { DONE : FIXME: Paramdata.tip sometimes gets wrong type, not selected. } ParamData := ParamTreeList.GetNodeData(Node); @@ -360,7 +360,7 @@ Node: PVirtualNode; Column: TColumnIndex; var LineBreakStyle: TVTTooltipLineBreakStyle; var HintText: WideString); var - ParamNodeData : PParamData; + ParamNodeData : PPropNodeData; begin inherited; if Column <> 1 then exit; @@ -387,7 +387,7 @@ var I : Integer; Node: PVirtualNode; - ParamData: PParamData; + ParamData: PPropNodeData; begin if ParamTreeList.RootNodeCount <> 0 then exit; @@ -432,7 +432,7 @@ Sender: TBaseVirtualTree; Node: PVirtualNode; Column: TColumnIndex; out EditLink: IVTEditLink); var - ParamData : PParamData; + ParamData : PPropNodeData; Items : TStringList; ConnProp : TConnectionRule; tmpConnection : IZConnection; Modified: branches/xmlrules/src/ui/MainForm.dfm =================================================================== --- branches/xmlrules/src/ui/MainForm.dfm 2006-12-24 11:07:11 UTC (rev 234) +++ branches/xmlrules/src/ui/MainForm.dfm 2006-12-25 20:33:30 UTC (rev 235) @@ -70,7 +70,7 @@ item MinWidth = 280 Position = 0 - Width = 369 + Width = 365 WideText = 'Name' end item Modified: branches/xmlrules/src/ui/MainForm.pas =================================================================== --- branches/xmlrules/src/ui/MainForm.pas 2006-12-24 11:07:11 UTC (rev 234) +++ branches/xmlrules/src/ui/MainForm.pas 2006-12-25 20:33:30 UTC (rev 235) @@ -177,7 +177,7 @@ {$IFDEF VER150} // XP Manifest Hacking -{$R WindowsXP.res} + {$R WindowsXP.res} {$ENDIF} function GetParentNodeData(ASender : TBaseVirtualTree; @@ -211,8 +211,6 @@ TableName: string; ReferenceName: string; ColumnName: string; - sParams: String; - I : Integer; ConnectionRule: TConnectionRule; TableRule : TTableRule; ColumnRule : TColumnRule; @@ -378,7 +376,6 @@ ColumnName: string; ColumnType: string; ModalValue: Integer; - ConnectionProperty: TConnectionRule; TableRule : TTableRule; ColumnRule : TColumnRule; NewColumnRule : Boolean; @@ -395,7 +392,6 @@ ReferenceName:= GetParentNodeData(FieldTree, Node.Parent).Name; // Get table rule, column rule - ConnectionProperty:= Project.ConnectionRuleRef[ReferenceName]; TableRule := Project.FindTableRule(ReferenceName, TableName); ColumnRule:= Project.FindColumnRule(ReferenceName, TableName, ColumnName); @@ -404,6 +400,7 @@ try if not Assigned(ColumnRule) then begin + { TODO 4 : TColumnRule yarat\xFDlmamal\xFD burada } ColumnRule := TColumnRule.Create(FProject); ColumnRule.column := ColumnName; NewColumnRule:= True; @@ -437,12 +434,10 @@ procedure TfrmMain.FieldTreeDblClick(Sender : TObject); var Node : PVirtualNode; - NodeData : PNodeData; begin Node := FieldTree.FocusedNode; if not Assigned(Node) then Exit; - NodeData := FieldTree.GetNodeData(Node); case FieldTree.GetNodeLevel(Node) of // Connection @@ -989,7 +984,7 @@ // if Configuration file not clear then user choose to abort xml open action if ProjectFileName <> '' then Exit; try - Project.LoadFromFile(AFilename); + FProject := TProject.LoadFromFile(AFilename); ProjectFileName := AFileName; except CloseProject; @@ -1003,6 +998,7 @@ procedure TfrmMain.CloseProject; begin Project.Childs.Clear; + Project.Free; FieldTree.Clear; ProjectFileName:= ''; end; Added: branches/xmlrules/src/ui/uRuleController.pas =================================================================== --- branches/xmlrules/src/ui/uRuleController.pas (rev 0) +++ branches/xmlrules/src/ui/uRuleController.pas 2006-12-25 20:33:30 UTC (rev 235) @@ -0,0 +1,31 @@ +unit uRuleController; + +interface +uses Variants; + +type + TPropertyEditorType = (pctStandart, pctDate, pctConnectionList, pctFieldList, + pctScriptEditor, pctMemoEditor); + TPropertyEditorTypes = array of TPropertyEditorType; + + TEditableProperty = record + Name : String; + Value : Variant; + DataType : TVarType; + EditorTypes : TPropertyEditorTypes; + end; + + TEditableProperties = array of TEditableProperty; + IRulePropertyController = interface + ['{CE87E228-58B7-44F2-9153-83D431B51A9B}'] + {** + Should returns the TEditableProperty array defining which properties to be + edited.} + function getEditableProperties: TEditableProperties; + procedure setProperty(const propIndex: Integer; const value: Variant); + function getProperty(const propIndex: Integer): Variant; + end; + +implementation + +end. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <t-...@us...> - 2006-12-24 11:07:12
|
Revision: 234 http://svn.sourceforge.net/datagenerator/?rev=234&view=rev Author: t-hex Date: 2006-12-24 03:07:11 -0800 (Sun, 24 Dec 2006) Log Message: ----------- Modified Paths: -------------- branches/xmlrules/3rdParty/FastMM/FastMM4Options.inc Modified: branches/xmlrules/3rdParty/FastMM/FastMM4Options.inc =================================================================== --- branches/xmlrules/3rdParty/FastMM/FastMM4Options.inc 2006-12-24 11:06:25 UTC (rev 233) +++ branches/xmlrules/3rdParty/FastMM/FastMM4Options.inc 2006-12-24 11:07:11 UTC (rev 234) @@ -97,7 +97,7 @@ Very important: If you enable this option your application will require the FastMM_FullDebugMode.dll library. If this library is not available you will get an error on startup.} -{$define FullDebugMode} +{.$define FullDebugMode} {Set this option to perform "raw" stack traces, i.e. check all entries on the stack for valid return addresses. Note that this is significantly slower @@ -133,7 +133,7 @@ {Set this option to enable reporting of memory leaks. Combine it with the two options below for further fine-tuning.} -{$define EnableMemoryLeakReporting} +{.$define EnableMemoryLeakReporting} {Set this option to suppress the display and logging of expected memory leaks that were registered by pointer. Leaks registered by size or class are often This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <t-...@us...> - 2006-12-24 11:06:29
|
Revision: 233 http://svn.sourceforge.net/datagenerator/?rev=233&view=rev Author: t-hex Date: 2006-12-24 03:06:25 -0800 (Sun, 24 Dec 2006) Log Message: ----------- Modified Paths: -------------- branches/xmlrules/src/lib/rules/DG_ConnectionRule.pas branches/xmlrules/src/lib/rules/DG_Project.pas branches/xmlrules/src/lib/rules/DG_TableRule.pas branches/xmlrules/src/ui/DataGeneratorUI.dpr branches/xmlrules/src/ui/FormColumnRule.dfm branches/xmlrules/src/ui/FormTableRule.dfm branches/xmlrules/src/ui/MainForm.dfm branches/xmlrules/src/ui/MainForm.pas Modified: branches/xmlrules/src/lib/rules/DG_ConnectionRule.pas =================================================================== --- branches/xmlrules/src/lib/rules/DG_ConnectionRule.pas 2006-12-23 11:10:33 UTC (rev 232) +++ branches/xmlrules/src/lib/rules/DG_ConnectionRule.pas 2006-12-24 11:06:25 UTC (rev 233) @@ -18,6 +18,7 @@ public function ToString: string; override; function GetTableRule(I: Integer): TTableRule; + function FindTableRule(const tableName: String): TTableRule; class function TagName: string; override; property TableRule[I: Integer]: TTableRule read GetTableRule; published @@ -35,6 +36,11 @@ implementation { TConnectionRule } +function TConnectionRule.FindTableRule(const tableName: String): TTableRule; +begin + { TODO 4 : implement } +end; + function TConnectionRule.GetTableRule(I: Integer): TTableRule; begin Result := TTableRule(Child[I]); Modified: branches/xmlrules/src/lib/rules/DG_Project.pas =================================================================== --- branches/xmlrules/src/lib/rules/DG_Project.pas 2006-12-23 11:10:33 UTC (rev 232) +++ branches/xmlrules/src/lib/rules/DG_Project.pas 2006-12-24 11:06:25 UTC (rev 233) @@ -1,7 +1,8 @@ unit DG_Project; interface -uses SysUtils, Classes, DG_Core, DG_ConnectionRule, JalMiniDom, JalSAX, JalCollections; +uses SysUtils, Classes, DG_Core, DG_ConnectionRule, JalMiniDom, JalSAX, + JalCollections, DG_ColumnRule, DG_TableRule; type TProject = class(TXMLNode) @@ -20,6 +21,8 @@ class function LoadFromFile(const aFileName:String):TProject; virtual; class procedure SaveToFile(const aProject:TProject; const aFileName: String); overload;virtual; procedure SaveToFile(const aFileName:String); overload; virtual; + function FindColumnRule(const connRef: String; const tableName: String; const columnName):TColumnRule; + function FindTableRule(const connRef: String; const tableName: String):TTableRule; function AddConnectionRule: TConnectionRule; virtual; property ConnectionRule[I: Integer]: TConnectionRule read GetConnectionRule; property ConnectionRuleRef[const ref:string]:TConnectionRule read GetConnectionByRef; @@ -38,6 +41,17 @@ Result := TConnectionRule.Create(self); end; +function TProject.FindColumnRule(const connRef, tableName: String; + const columnName): TColumnRule; +begin + { TODO 4 : implement } +end; + +function TProject.FindTableRule(const connRef, tableName: String): TTableRule; +begin + { TODO 4 : implement } +end; + function TProject.GetConnectionByRef(const ref: string): TConnectionRule; var i: Integer; Modified: branches/xmlrules/src/lib/rules/DG_TableRule.pas =================================================================== --- branches/xmlrules/src/lib/rules/DG_TableRule.pas 2006-12-23 11:10:33 UTC (rev 232) +++ branches/xmlrules/src/lib/rules/DG_TableRule.pas 2006-12-24 11:06:25 UTC (rev 233) @@ -17,7 +17,7 @@ class function TagName: string; override; function AddColumnRule(aClass: TColumnRuleClass): TColumnRule; virtual; property ColumnRule[I: Integer]: TColumnRule read GetColumnRule; - + function FindColumnRule(const columnName: String):TColumnRule; published property table: string read ftable write ftable; property rows: Integer read frows write frows; @@ -34,6 +34,11 @@ Result := TColumnRuleClass.Create(self); end; +function TTableRule.FindColumnRule(const columnName: String): TColumnRule; +begin + { TODO 4 : implement } +end; + function TTableRule.GetColumnRule(I: Integer): TColumnRule; begin Result := TColumnRule(GetChild(I)); Modified: branches/xmlrules/src/ui/DataGeneratorUI.dpr =================================================================== --- branches/xmlrules/src/ui/DataGeneratorUI.dpr 2006-12-23 11:10:33 UTC (rev 232) +++ branches/xmlrules/src/ui/DataGeneratorUI.dpr 2006-12-24 11:06:25 UTC (rev 233) @@ -3,6 +3,11 @@ {%ToDo 'DataGeneratorUI.todo'} {%TogetherDiagram 'ModelSupport_DataGeneratorUI\default.txaPackage'} +{$IFDEF DEBUG} + {$DEF FullDebugMode} + {$DEF EnableMemoryLeakReporting} +{$ENDIF} + uses FastMM4 in '..\..\3rdParty\FastMM\FastMM4.pas', FastMM4Messages in '..\..\3rdParty\FastMM\FastMM4Messages.pas', Modified: branches/xmlrules/src/ui/FormColumnRule.dfm =================================================================== --- branches/xmlrules/src/ui/FormColumnRule.dfm 2006-12-23 11:10:33 UTC (rev 232) +++ branches/xmlrules/src/ui/FormColumnRule.dfm 2006-12-24 11:06:25 UTC (rev 233) @@ -11,6 +11,8 @@ inherited Bevel1: TBevel Top = 317 Width = 370 + ExplicitTop = 317 + ExplicitWidth = 370 end object Label1: TLabel [1] Left = 16 @@ -29,10 +31,12 @@ inherited btnOK: TButton Top = 326 OnClick = btnOKClick + ExplicitTop = 326 end inherited btnCancel: TButton Top = 326 Cancel = True + ExplicitTop = 326 end object GroupBox1: TGroupBox Left = 8 Modified: branches/xmlrules/src/ui/FormTableRule.dfm =================================================================== --- branches/xmlrules/src/ui/FormTableRule.dfm 2006-12-23 11:10:33 UTC (rev 232) +++ branches/xmlrules/src/ui/FormTableRule.dfm 2006-12-24 11:06:25 UTC (rev 233) @@ -8,16 +8,20 @@ TextHeight = 13 inherited Bevel1: TBevel Top = 190 + ExplicitTop = 190 end inherited btnOK: TButton Left = 216 Top = 199 Default = True OnClick = btnOKClick + ExplicitLeft = 216 + ExplicitTop = 199 end inherited btnCancel: TButton Top = 198 Cancel = True + ExplicitTop = 198 end object GroupBox1: TGroupBox Left = 8 Modified: branches/xmlrules/src/ui/MainForm.dfm =================================================================== --- branches/xmlrules/src/ui/MainForm.dfm 2006-12-23 11:10:33 UTC (rev 232) +++ branches/xmlrules/src/ui/MainForm.dfm 2006-12-24 11:06:25 UTC (rev 233) @@ -66,13 +66,11 @@ OnGetHint = FieldTreeGetHint OnGetNodeDataSize = FieldTreeGetNodeDataSize OnInitChildren = FieldTreeInitChildren - ExplicitTop = 27 - ExplicitHeight = 380 Columns = < item MinWidth = 280 Position = 0 - Width = 365 + Width = 369 WideText = 'Name' end item Modified: branches/xmlrules/src/ui/MainForm.pas =================================================================== --- branches/xmlrules/src/ui/MainForm.pas 2006-12-23 11:10:33 UTC (rev 232) +++ branches/xmlrules/src/ui/MainForm.pas 2006-12-24 11:06:25 UTC (rev 233) @@ -229,21 +229,9 @@ ColumnName:= NodeData.Name; TableName:= GetParentNodeData(Sender, Node).Name; ReferenceName:= GetParentNodeData(Sender, Node.Parent).Name; - { TODO 5 : fix here } - //ColumnRule:= Project.FindColumnRule(ReferenceName, TableName, ColumnName); - - if Assigned(ColumnRule) then begin - Celltext := ColumnRule.TagName; - { TODO 5 : fix here } -{ - if not (ColumnRule.Strategy in [gtScript,gtSQL]) then begin - for i:= 0 to ColumnRule.Params.count-1 do - sParams := sParams + ColumnRule.Params[i].Value +','; - Delete(sParams,length(sParams),1); - CellText := CellText + '(' + sParams + ')'; - end; - -} end; + ColumnRule:= Project.FindColumnRule(ReferenceName, TableName, ColumnName); + if Assigned(ColumnRule) then + Celltext := ColumnRule.ToString; end; end; @@ -262,8 +250,7 @@ 1 : begin ReferenceName:= GetParentNodeData(Sender, Node).Name; TableName:= NodeData.Name; - { TODO 5 : fix here } - //TableRule:= Project.FindTableRule(ReferenceName, TableName); + TableRule:= Project.FindTableRule(ReferenceName, TableName); if Assigned(TableRule) then Celltext := Format(_('%d rows'), [TableRule.Rows]); end; @@ -354,8 +341,7 @@ TableName := PNodeData(FieldTree.GetNodeData(Node)).Name; // Get table rule - { TODO 5 : fix here } - //TableRule := Project.FindTableRule(ReferenceName, TableName); + TableRule := Project.FindTableRule(ReferenceName, TableName); Application.CreateForm(TfrmTableRule, frmTableRule); try @@ -372,11 +358,10 @@ frmTableRule.TableRule := TableRule; ModalValue:= frmTableRule.ShowModal; Connection:= Project.ConnectionRuleRef[ReferenceName]; - { TODO 5 : fix here } -// if (ModalValue = mrOK) and -// not Assigned(Project.FindTableRule(ReferenceName, TableName)) and -// Assigned(Connection) then -// Connection.AddTableRule(TableRule); + if (ModalValue = mrOK) and + not Assigned(Project.FindTableRule(ReferenceName, TableName)) and + Assigned(Connection) then + Connection.Childs.Add(TableRule); finally if (ModalValue <> mrOK) and NewTableRule then TableRule.Free; @@ -411,10 +396,9 @@ // Get table rule, column rule ConnectionProperty:= Project.ConnectionRuleRef[ReferenceName]; - { TODO 5 : fix here } -// TableRule := Project.FindTableRule(ReferenceName, TableName); -// ColumnRule:= Project.FindColumnRule(ReferenceName, -// TableName, ColumnName); + TableRule := Project.FindTableRule(ReferenceName, TableName); + ColumnRule:= Project.FindColumnRule(ReferenceName, + TableName, ColumnName); Application.CreateForm(TfrmColumnRule, frmColumnRule); try @@ -437,9 +421,8 @@ TableRule.table := TableName; TableRule.Rows := UISettings.DefaultTableRows; end; - { TODO 5 : fix here } -// if not Assigned(TableRule.FindColumnRule(ColumnName)) then -// TableRule.AddColumnRule(ColumnRule); + if not Assigned(TableRule.FindColumnRule(ColumnName)) then + TableRule.Childs.Add(ColumnRule); end; finally if (ModalValue <> mrOK) and NewColumnRule then @@ -755,10 +738,9 @@ // Get table rule, column rule ConnectionRule:= Project.ConnectionRuleRef[ReferenceName]; - { TODO 5 : fix here } -// TableRule:= Project.FindTableRule(ReferenceName, TableName); -// ColumnRule:= Project.FindColumnRule(ReferenceName, -// TableName, ColumnName); + TableRule:= Project.FindTableRule(ReferenceName, TableName); + ColumnRule:= Project.FindColumnRule(ReferenceName, + TableName, ColumnName); // Remove column rule if Assigned(TableRule) then @@ -795,9 +777,8 @@ ReferenceName:= GetParentNodeData(FieldTree, Node.Parent).Name; // Get connection property, table rule, column rule - { TODO 5 : fix here } -// ColumnRule:= Project.FindColumnRule(ReferenceName, -// TableName, ColumnName); + ColumnRule:= Project.FindColumnRule(ReferenceName, + TableName, ColumnName); TAction(Sender).Enabled := Assigned(ColumnRule); end; @@ -899,8 +880,7 @@ ReferenceName:= GetParentNodeData(FieldTree, Node).Name; // Get table rule - { TODO 5 : fix here } -// TableRule:= Project.FindTableRule(ReferenceName, TableName); + TableRule:= Project.FindTableRule(ReferenceName, TableName); TAction(Sender).Enabled := Assigned(TableRule); end; @@ -910,7 +890,7 @@ Node : PVirtualNode; TableName: string; ReferenceName: string; - ConnectionProperty: TConnectionRule; + ConnectionRule: TConnectionRule; TableRule : TTableRule; begin Node := FieldTree.FocusedNode; @@ -921,17 +901,16 @@ ReferenceName:= GetParentNodeData(FieldTree, Node).Name; // Get connection property, table rule, column rule - ConnectionProperty:= Project.ConnectionRuleRef[ReferenceName]; - { TODO 5 : fix here } -// TableRule := ConnectionProperty.FindTableRule(TableName); + ConnectionRule:= Project.ConnectionRuleRef[ReferenceName]; + TableRule := ConnectionRule.FindTableRule(TableName); if MessageDlg(Format(_('Are you sure!' + #13 + 'You want to delete table rule : %s (and column rules) ?'), [TableName]), mtConfirmation, [mbYes, mbNo], 0) = mrNo then Exit; - if Assigned(ConnectionProperty) then - ConnectionProperty.Childs.Remove(TableRule); + if Assigned(ConnectionRule) then + ConnectionRule.Childs.Remove(TableRule); FieldTree.Refresh; end; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: ibrahim d. <ibr...@gm...> - 2006-12-23 11:18:21
|
QXJrYWRh/mxhciwKCkhp52JpciBha3Rpdml0ZSBvbG1hZP3w/SBp52luIGJ1IGJyYW5jaGxlcmkg c2lsZGltLiBaYXRlbiBvCmJyYW5jaGxlcmluIGHn/WxtYXP9bmRhbiBidSB5YW5hIGtvZCDnb2sg ZGXwaf5taf50aS4gRfBlciB5ZW5pIGJyYW5jaAph521hayBpc3RlcnNlbml6IFNWTiA+IEFkZCBC cmFuY2ggaWxlIHlhcGFiaWxpcnNpbml6CgoyMDA2LzEyLzIzLCB0LWhleEB1c2Vycy5zb3VyY2Vm b3JnZS5uZXQgPHQtaGV4QHVzZXJzLnNvdXJjZWZvcmdlLm5ldD46Cj4gUmV2aXNpb246IDIzMgo+ ICAgICAgICAgICBodHRwOi8vc3ZuLnNvdXJjZWZvcmdlLm5ldC9kYXRhZ2VuZXJhdG9yLz9yZXY9 MjMyJnZpZXc9cmV2Cj4gQXV0aG9yOiAgIHQtaGV4Cj4gRGF0ZTogICAgIDIwMDYtMTItMjMgMDM6 MTA6MzMgLTA4MDAgKFNhdCwgMjMgRGVjIDIwMDYpCj4KPiBMb2cgTWVzc2FnZToKPiAtLS0tLS0t LS0tLQo+IFJlbW92ZWQgZmlsZS9mb2xkZXIKPgo+IFJlbW92ZWQgUGF0aHM6Cj4gLS0tLS0tLS0t LS0tLQo+ICAgICBicmFuY2hlcy9MYXppb19Xb3Jrcy8KPiAgICAgYnJhbmNoZXMvYXNsYW5nZXJp X2RlLwo+ICAgICBicmFuY2hlcy9leHBlcmltYW50YWxfMC40Lwo+Cj4KPiBUaGlzIHdhcyBzZW50 IGJ5IHRoZSBTb3VyY2VGb3JnZS5uZXQgY29sbGFib3JhdGl2ZSBkZXZlbG9wbWVudCBwbGF0Zm9y bSwgdGhlIHdvcmxkJ3MgbGFyZ2VzdCBPcGVuIFNvdXJjZSBkZXZlbG9wbWVudCBzaXRlLgo+Cj4g LS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0t LS0tLS0tLS0tLS0tLS0tLQo+IFRha2UgU3VydmV5cy4gRWFybiBDYXNoLiBJbmZsdWVuY2UgdGhl IEZ1dHVyZSBvZiBJVAo+IEpvaW4gU291cmNlRm9yZ2UubmV0J3MgVGVjaHNheSBwYW5lbCBhbmQg eW91J2xsIGdldCB0aGUgY2hhbmNlIHRvIHNoYXJlIHlvdXIKPiBvcGluaW9ucyBvbiBJVCAmIGJ1 c2luZXNzIHRvcGljcyB0aHJvdWdoIGJyaWVmIHN1cnZleXMgLSBhbmQgZWFybiBjYXNoCj4gaHR0 cDovL3d3dy50ZWNoc2F5LmNvbS9kZWZhdWx0LnBocD9wYWdlPWpvaW4ucGhwJnA9c291cmNlZm9y Z2UmQ0lEPURFVkRFVgo+IF9fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19f X19fX19fCj4gRGF0YWdlbmVyYXRvci1jb21taXRzIG1haWxpbmcgbGlzdAo+IERhdGFnZW5lcmF0 b3ItY29tbWl0c0BsaXN0cy5zb3VyY2Vmb3JnZS5uZXQKPiBodHRwczovL2xpc3RzLnNvdXJjZWZv cmdlLm5ldC9saXN0cy9saXN0aW5mby9kYXRhZ2VuZXJhdG9yLWNvbW1pdHMKPgo= |