* GUI SQLDB Rest Schema editor, in IDE and standalone

git-svn-id: trunk@61174 -
This commit is contained in:
michael 2019-05-07 15:38:19 +00:00
parent 357ea31186
commit 7bee5358e4
66 changed files with 11082 additions and 18 deletions

61
.gitattributes vendored
View File

@ -1726,6 +1726,8 @@ components/fpweb/demo/restmodule/demorestmodule.lpr svneol=native#text/plain
components/fpweb/demo/restmodule/demorestmodule.res -text
components/fpweb/demo/restmodule/dmmyrest.lfm svneol=native#text/plain
components/fpweb/demo/restmodule/dmmyrest.pp svneol=native#text/plain
components/fpweb/dlgeditsqldbrestschema.lfm svneol=native#text/plain
components/fpweb/dlgeditsqldbrestschema.pp svneol=native#text/plain
components/fpweb/fpideexteditorinsertfilenameunit.lfm svneol=native#text/plain
components/fpweb/fpideexteditorinsertfilenameunit.pas svneol=native#text/plain
components/fpweb/fpweb_images.inc svneol=native#text/plain
@ -1860,6 +1862,58 @@ components/fpweb/lazweb.pp svneol=native#text/plain
components/fpweb/lazwebextra.lpk svneol=native#text/plain
components/fpweb/reglazsqldbrest.pp svneol=native#text/plain
components/fpweb/reslazsqldbrest.pp svneol=native#text/plain
components/fpweb/restdesign/dlgrestfieldoptions.lfm svneol=native#text/plain
components/fpweb/restdesign/dlgrestfieldoptions.pp svneol=native#text/plain
components/fpweb/restdesign/dlgsqldbrestconnection.lfm svneol=native#text/plain
components/fpweb/restdesign/dlgsqldbrestconnection.pp svneol=native#text/plain
components/fpweb/restdesign/fraconnections.lfm svneol=native#text/plain
components/fpweb/restdesign/fraconnections.pp svneol=native#text/plain
components/fpweb/restdesign/fraschematableseditor.lfm svneol=native#text/plain
components/fpweb/restdesign/fraschematableseditor.pp svneol=native#text/plain
components/fpweb/restdesign/frasqldbfullrestschemaaditor.lfm svneol=native#text/plain
components/fpweb/restdesign/frasqldbfullrestschemaaditor.pp svneol=native#text/plain
components/fpweb/restdesign/frasqldbresourcefields.lfm svneol=native#text/plain
components/fpweb/restdesign/frasqldbresourcefields.pp svneol=native#text/plain
components/fpweb/restdesign/frasqldbrestfieldedit.lfm svneol=native#text/plain
components/fpweb/restdesign/frasqldbrestfieldedit.pp svneol=native#text/plain
components/fpweb/restdesign/frasqldbrestresourceedit.lfm svneol=native#text/plain
components/fpweb/restdesign/frasqldbrestresourceedit.pp svneol=native#text/plain
components/fpweb/restdesign/frasqldbrestschemaeditor.lfm svneol=native#text/plain
components/fpweb/restdesign/frasqldbrestschemaeditor.pp svneol=native#text/plain
components/fpweb/restdesign/frmeditframedialog.lfm svneol=native#text/plain
components/fpweb/restdesign/frmeditframedialog.pp svneol=native#text/plain
components/fpweb/restdesign/images/checked.png -text svneol=unset#image/png
components/fpweb/restdesign/images/connection-add.png -text svneol=unset#image/png
components/fpweb/restdesign/images/connection-delete.png -text svneol=unset#image/png
components/fpweb/restdesign/images/connection-edit.png -text svneol=unset#image/png
components/fpweb/restdesign/images/connection-expose.png -text svneol=unset#image/png
components/fpweb/restdesign/images/connection-refresh.png -text svneol=unset#image/png
components/fpweb/restdesign/images/connection.png -text svneol=unset#image/png
components/fpweb/restdesign/images/connections-hide.png -text svneol=unset#image/png
components/fpweb/restdesign/images/connections-load.png -text svneol=unset#image/png
components/fpweb/restdesign/images/connections-save.png -text svneol=unset#image/png
components/fpweb/restdesign/images/connections-show.png -text svneol=unset#image/png
components/fpweb/restdesign/images/exit.png -text svneol=unset#image/png
components/fpweb/restdesign/images/field-add.png -text svneol=unset#image/png
components/fpweb/restdesign/images/field-delete.png -text svneol=unset#image/png
components/fpweb/restdesign/images/field-edit.png -text svneol=unset#image/png
components/fpweb/restdesign/images/field-key.png -text svneol=unset#image/png
components/fpweb/restdesign/images/field.png -text svneol=unset#image/png
components/fpweb/restdesign/images/fields.png -text svneol=unset#image/png
components/fpweb/restdesign/images/schema-load.png -text svneol=unset#image/png
components/fpweb/restdesign/images/schema-new.png -text svneol=unset#image/png
components/fpweb/restdesign/images/schema-save.png -text svneol=unset#image/png
components/fpweb/restdesign/images/schema-saveas.png -text svneol=unset#image/png
components/fpweb/restdesign/images/table-add.png -text svneol=unset#image/png
components/fpweb/restdesign/images/table-delete.png -text svneol=unset#image/png
components/fpweb/restdesign/images/table-edit.png -text svneol=unset#image/png
components/fpweb/restdesign/images/table-info.png -text svneol=unset#image/png
components/fpweb/restdesign/images/table.png -text svneol=unset#image/png
components/fpweb/restdesign/images/unchecked.png -text svneol=unset#image/png
components/fpweb/restdesign/sqldbrestschemadesigner.lpk svneol=native#text/plain
components/fpweb/restdesign/sqldbrestschemadesigner.pas svneol=native#text/plain
components/fpweb/restdesign/sqldbschemaedittools.lfm svneol=native#text/plain
components/fpweb/restdesign/sqldbschemaedittools.pp svneol=native#text/plain
components/fpweb/restimages/filelist.txt svneol=native#text/plain
components/fpweb/restimages/genimages.bat svneol=native#text/plain
components/fpweb/restimages/genimages.sh svneol=native#text/plain
@ -1867,6 +1921,13 @@ components/fpweb/restimages/trestbasicauthenticator.png -text svneol=unset#image
components/fpweb/restimages/tsqldbrestbusinessprocessor.png -text svneol=unset#image/png
components/fpweb/restimages/tsqldbrestdispatcher.png -text svneol=unset#image/png
components/fpweb/restimages/tsqldbrestschema.png -text svneol=unset#image/png
components/fpweb/schemaeditor/frmmain.lfm svneol=native#text/plain
components/fpweb/schemaeditor/frmmain.pp svneol=native#text/plain
components/fpweb/schemaeditor/schemaconns.pp svneol=native#text/plain
components/fpweb/schemaeditor/schemaeditor.ico -text
components/fpweb/schemaeditor/schemaeditor.lpi svneol=native#text/plain
components/fpweb/schemaeditor/schemaeditor.lpr svneol=native#text/plain
components/fpweb/schemaeditor/schemaeditor.res -text
components/fpweb/weblaz.lpk svneol=native#text/plain
components/fpweb/weblaz.pas svneol=native#text/plain
components/fpweb/weblazideintf.pp svneol=native#text/plain

View File

@ -0,0 +1,127 @@
object SQLDBRestSchemaEditorForm: TSQLDBRestSchemaEditorForm
Left = 573
Height = 515
Top = 284
Width = 809
Caption = 'Edit Schema'
ClientHeight = 515
ClientWidth = 809
OnCloseQuery = FormCloseQuery
OnCreate = FormCreate
OnShow = FormShow
LCLVersion = '2.1.0.0'
object BPSchema: TButtonPanel
Left = 6
Height = 42
Top = 467
Width = 797
OKButton.Name = 'OKButton'
OKButton.DefaultCaption = True
HelpButton.Name = 'HelpButton'
HelpButton.DefaultCaption = True
CloseButton.Name = 'CloseButton'
CloseButton.DefaultCaption = True
CancelButton.Name = 'CancelButton'
CancelButton.DefaultCaption = True
TabOrder = 0
ShowButtons = [pbOK, pbCancel]
end
inline fraEditor: TSchemaEditorFrame
Height = 461
Width = 809
Align = alClient
ClientHeight = 461
ClientWidth = 809
TabOrder = 1
inherited fraConn: TfraConnections
Height = 461
Width = 203
Align = alLeft
ClientHeight = 461
ClientWidth = 203
inherited TVConnections: TTreeView
Height = 404
Width = 203
end
inherited ToolBar1: TToolBar
Width = 203
inherited TBSep1: TToolButton
Height = 30
end
inherited ToolButton1: TToolButton
Height = 30
end
end
inherited Label1: TLabel
Width = 203
end
end
inherited splConnection: TSplitter
Height = 461
end
inherited fraSchema: TSQLDBRestSchemaEditorFrame
Left = 208
Height = 461
Width = 601
Align = alClient
ClientHeight = 461
ClientWidth = 601
TabOrder = 2
inherited PResources: TPanel
Height = 461
Width = 170
ClientHeight = 461
ClientWidth = 170
inherited TBResources: TToolBar
Width = 170
EdgeInner = esRaised
EdgeOuter = esLowered
inherited ToolButton1: TToolButton
Height = 30
end
inherited ToolButton2: TToolButton
Height = 30
end
inherited ToolButton4: TToolButton
Left = 1
Top = 30
end
inherited ToolButton5: TToolButton
Left = 31
Top = 30
end
end
inherited TVResources: TTreeView
Height = 404
Width = 170
end
inherited LResources: TLabel
Width = 170
end
end
inherited Splitter1: TSplitter
Left = 170
Height = 461
end
inherited PDock: TPanel
Left = 175
Height = 461
Width = 426
ClientHeight = 461
ClientWidth = 426
inherited LFrame: TLabel
Width = 426
end
end
end
end
object PSSchema: TXMLPropStorage
StoredValues = <>
RootNodePath = 'Editor'
Active = False
OnSaveProperties = PSSchemaSaveProperties
OnRestoreProperties = PSSchemaRestoreProperties
left = 464
top = 296
end
end

View File

@ -0,0 +1,132 @@
unit dlgeditsqldbrestschema;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ButtonPanel, XMLPropStorage, frasqldbfullrestschemaaditor,
sqldbrestschema, sqldbrestbridge;
type
{ TSQLDBRestSchemaEditorForm }
TSQLDBRestSchemaEditorForm = class(TForm)
BPSchema: TButtonPanel;
fraEditor: TSchemaEditorFrame;
PSSchema: TXMLPropStorage;
procedure FormCloseQuery(Sender: TObject; var CanClose: boolean);
procedure FormCreate(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure PSSchemaRestoreProperties(Sender: TObject);
procedure PSSchemaSaveProperties(Sender: TObject);
private
procedure DoSchemaChanged(Sender: TObject);
function GetConnections: TSQLDBRestConnectionList;
function GetConnectionsModified: Boolean;
function GetSchema: TSQLDBRestSchema;
function GetSchemaModified: Boolean;
procedure SetConnections(AValue: TSQLDBRestConnectionList);
procedure SetSchema(AValue: TSQLDBRestSchema);
procedure UpdateCaption;
public
Property Schema : TSQLDBRestSchema Read GetSchema Write SetSchema;
Property Connections : TSQLDBRestConnectionList Read GetConnections Write SetConnections;
Property SchemaModified : Boolean Read GetSchemaModified;
Property ConnectionsModified : Boolean Read GetConnectionsModified;
end;
var
SQLDBRestSchemaEditorForm: TSQLDBRestSchemaEditorForm;
implementation
uses lazideintf;
{$R *.lfm}
{ TSQLDBRestSchemaEditorForm }
procedure TSQLDBRestSchemaEditorForm.FormCreate(Sender: TObject);
begin
PSSchema.FileName:=IncludeTrailingPathDelimiter(LazarusIDE.GetPrimaryConfigPath)+'sqldbrestschema.xml';
PSSchema.Active:=True;
PSSchema.Restore;
fraEditor.OnSchemaChanged:=@DoSchemaChanged;
end;
procedure TSQLDBRestSchemaEditorForm.FormCloseQuery(Sender: TObject; var CanClose: boolean);
begin
fraEditor.CheckSave;
end;
procedure TSQLDBRestSchemaEditorForm.FormShow(Sender: TObject);
begin
UpdateCaption;
end;
procedure TSQLDBRestSchemaEditorForm.PSSchemaRestoreProperties(Sender: TObject);
begin
fraEditor.LoadSession(PSSchema);
end;
procedure TSQLDBRestSchemaEditorForm.PSSchemaSaveProperties(Sender: TObject);
begin
fraEditor.SaveSession(PSSchema);
end;
procedure TSQLDBRestSchemaEditorForm.UpdateCaption;
Var
S : String;
begin
if Assigned(Schema) then
S:=Schema.Name
else
S:='No schema';
S:='Editing schema '+S;
if fraEditor.SchemaModified then
S:=S+' (modified)';
Caption:=S;
end;
procedure TSQLDBRestSchemaEditorForm.DoSchemaChanged(Sender: TObject);
begin
UpdateCaption;
end;
function TSQLDBRestSchemaEditorForm.GetConnections: TSQLDBRestConnectionList;
begin
Result:=fraEditor.Connections;
end;
function TSQLDBRestSchemaEditorForm.GetConnectionsModified: Boolean;
begin
Result:=fraEditor.ConnectionsModified;
end;
function TSQLDBRestSchemaEditorForm.GetSchema: TSQLDBRestSchema;
begin
Result:=fraEditor.Schema;
end;
function TSQLDBRestSchemaEditorForm.GetSchemaModified: Boolean;
begin
Result:=fraEditor.SchemaModified;
end;
procedure TSQLDBRestSchemaEditorForm.SetConnections(AValue: TSQLDBRestConnectionList);
begin
fraEditor.Connections:=aValue;
end;
procedure TSQLDBRestSchemaEditorForm.SetSchema(AValue: TSQLDBRestSchema);
begin
fraEditor.Schema:=aValue;
UpdateCaption;
end;
end.

View File

@ -10,7 +10,7 @@
<UnitOutputDirectory Value="lib/$(TargetCPU)-$(TargetOS)"/>
</SearchPaths>
</CompilerOptions>
<Files Count="5">
<Files Count="6">
<Item1>
<Filename Value="reglazsqldbrest.pp"/>
<HasRegisterProc Value="True"/>
@ -19,10 +19,12 @@
<Item2>
<Filename Value="frmsqldbrestdispatchini.pp"/>
<UnitName Value="frmsqldbrestdispatchini"/>
<ResourceBaseClass Value="Form"/>
</Item2>
<Item3>
<Filename Value="frmsqldbrestselectconn.pp"/>
<UnitName Value="frmsqldbrestselectconn"/>
<ResourceBaseClass Value="Form"/>
</Item3>
<Item4>
<Filename Value="reslazsqldbrest.pp"/>
@ -31,24 +33,32 @@
<Item5>
<Filename Value="frmsqldbrestselecttables.pp"/>
<UnitName Value="frmsqldbrestselecttables"/>
<ResourceBaseClass Value="Form"/>
</Item5>
<Item6>
<Filename Value="dlgeditsqldbrestschema.pp"/>
<UnitName Value="dlgeditsqldbrestschema"/>
</Item6>
</Files>
<RequiredPkgs Count="5">
<RequiredPkgs Count="6">
<Item1>
<PackageName Value="CodeTools"/>
<PackageName Value="sqldbrestschemadesigner"/>
</Item1>
<Item2>
<PackageName Value="IDEIntf"/>
<PackageName Value="CodeTools"/>
</Item2>
<Item3>
<PackageName Value="LCLBase"/>
<PackageName Value="IDEIntf"/>
</Item3>
<Item4>
<PackageName Value="LazUtils"/>
<PackageName Value="LCLBase"/>
</Item4>
<Item5>
<PackageName Value="FCL"/>
<PackageName Value="LazUtils"/>
</Item5>
<Item6>
<PackageName Value="FCL"/>
</Item6>
</RequiredPkgs>
<UsageOptions>
<UnitPath Value="$(PkgOutDir)"/>

View File

@ -8,8 +8,8 @@ unit lazsqldbrest;
interface
uses
reglazsqldbrest, frmsqldbrestdispatchini, frmsqldbrestselectconn,
reslazsqldbrest, frmsqldbrestselecttables, LazarusPackageIntf;
reglazsqldbrest, frmsqldbrestdispatchini, frmsqldbrestselectconn, reslazsqldbrest, frmsqldbrestselecttables,
dlgeditsqldbrestschema, LazarusPackageIntf;
implementation

View File

@ -75,7 +75,9 @@ Type
TSQLDBRestSchemaComponentEditor = class(TComponentEditor)
private
procedure DoLoadSchemaFromConnection(S: TSQLDBRestSchema);
procedure EditSchema(S: TSQLDBRestSchema);
procedure FillSchema(S: TSQLDBRestSchema; Conn: TSQLDBRestConnection; Opts: TRestFieldOptions; AllTables: Boolean);
function GetSchemaConnections(S: TSQLDBRestSchema): TSQLDBRestConnectionList;
function GetTableList(aConn: TSQLConnection; aList: TStrings): Boolean;
public
procedure ExecuteVerb(Index: Integer); override;
@ -121,6 +123,7 @@ uses
frmsqldbrestselectconn,
frmsqldbrestdispatchini,
frmsqldbrestselecttables,
dlgeditsqldbrestschema,
reslazsqldbrest;
Var
@ -307,6 +310,7 @@ begin
exit;
aSchema:=D.ExposeConnection(Designer.LookupRoot,C,Nil,aOptions);
aSchema.Name:=Designer.CreateUniqueComponentName(aSchema.ClassName);
Designer.Modified;
// Todo: add Aschema to form.
end;
@ -413,6 +417,7 @@ begin
aCount:=S.Resources.Count;
S.PopulateResources(SQLC,sTables,Opts);
ShowMessage(Format(SAddedNTables,[S.Resources.Count-aCount]));
Designer.Modified;
finally
T.Free;
if SQLC<>Conn.SingleConnection then
@ -460,6 +465,59 @@ begin
end;
end;
Function TSQLDBRestSchemaComponentEditor.GetSchemaConnections(S : TSQLDBRestSchema) : TSQLDBRestConnectionList;
Var
C : TComponent;
I : Integer;
D : TSQLDBRestDispatcher;
begin
C:=S.Owner;
Result:=Nil;
While (Result=Nil) and (C<>Nil) do
begin
I:=0;
While (Result=Nil) and (I<C.ComponentCount-1) do
begin
if C.Components[i] is TSQLDBRestDispatcher then
begin
D:=C.Components[i] as TSQLDBRestDispatcher;
if D.Schemas.IndexOfSchema(S.Name)<>-1 then
Result:=D.Connections;
end;
Inc(I)
end;
C:=C.Owner;
end;
end;
procedure TSQLDBRestSchemaComponentEditor.EditSchema(S : TSQLDBRestSchema);
Var
Frm : TSQLDBRestSchemaEditorForm;
cList : TSQLDBRestConnectionList;
begin
Frm:=TSQLDBRestSchemaEditorForm.Create(Application);
try
Frm.Schema:=S;
cList:=GetSchemaConnections(S);
Frm.Connections:=cList;
if Frm.ShowModal=mrOK then
begin
if Frm.SchemaModified then
S.Resources.Assign(frm.Schema.Resources);
if Frm.ConnectionsModified then
if MessageDlg(Format(SConnectionsChangedUpdateDispatcher, [LineEnding]), mtInformation, [mbYes, mbNo], 0) = mrYes then
cList.Assign(frm.Connections);
Designer.Modified;
end;
finally
frm.Free;
end;
end;
procedure TSQLDBRestSchemaComponentEditor.ExecuteVerb(Index: Integer);
Var
@ -469,7 +527,8 @@ Var
begin
S:=Component as TSQLDBRestSchema;
Case Index of
0,1 :
0 : EditSchema(S);
1,2 :
begin
FN:=Component.Name+'.json';
if GetFileName(FN, Format(SJSONFilesFilter, [allFilesMask]), Index=0) then
@ -481,12 +540,12 @@ begin
Designer.Modified;
end;
end;
2 :
3 :
begin
DoLoadSchemaFromConnection(S);
Designer.Modified;
end;
3 :
4 :
begin
S.Resources.Clear;
Designer.Modified;
@ -497,16 +556,17 @@ end;
function TSQLDBRestSchemaComponentEditor.GetVerb(Index: Integer): string;
begin
Case Index of
0 : Result:=SSaveSchemaToJSONFile;
1 : Result:=SLoadSchemaFromJSONFile;
2 : Result:=SLoadSchemaFromConnection;
3 : Result:=SClearSchema;
0 : Result:=SEditSchema;
1 : Result:=SSaveSchemaToJSONFile;
2 : Result:=SLoadSchemaFromJSONFile;
3 : Result:=SLoadSchemaFromConnection;
4 : Result:=SClearSchema;
end;
end;
function TSQLDBRestSchemaComponentEditor.GetVerbCount: Integer;
begin
Result:=4;
Result:=5;
end;
function TSQLDBConnectionTypePropertyEditor.GetAttributes: TPropertyAttributes;

View File

@ -13,13 +13,16 @@ Resourcestring
SExposeAConnection = 'Expose a connection';
SSaveSettingsToIni = 'Save settings to INI file';
SLoadSettingsFromIni = 'Load settings from INI file';
SJSONFilesFilter = 'JSON Files|*.json|All files|%s';
SJSONFilesFilter = 'Schema files|*.srs|JSON Files|*.json|All files|%s';
SSaveSchemaToJSONFile = 'Save schema to JSON file';
SLoadSchemaFromJSONFile = 'Load schema from JSON file';
SLoadSchemaFromConnection = 'Load schema from connection';
SErrNoConnectionsFound = 'No connections found on form/frame or datamodule';
SAddedNTables = 'Added %d tables as resources';
SClearSchema = 'Clear schema';
SEditSchema = 'Edit schema';
SConnectionsChangedUpdateDispatcher = 'The list of connections was modified. %s'+
'Do you wish to update the dispatcher connection list?';
implementation

View File

@ -0,0 +1,61 @@
object RestFieldOptionsDialog: TRestFieldOptionsDialog
Left = 459
Height = 176
Top = 264
Width = 367
Caption = 'Expose connection field options'
ClientHeight = 176
ClientWidth = 367
Position = poMainFormCenter
LCLVersion = '2.1.0.0'
object BPFieldOptions: TButtonPanel
Left = 6
Height = 42
Top = 128
Width = 355
OKButton.Name = 'OKButton'
OKButton.DefaultCaption = True
HelpButton.Name = 'HelpButton'
HelpButton.DefaultCaption = True
CloseButton.Name = 'CloseButton'
CloseButton.DefaultCaption = True
CancelButton.Name = 'CancelButton'
CancelButton.DefaultCaption = True
TabOrder = 0
ShowButtons = [pbOK, pbCancel]
end
object CGFieldOptions: TCheckGroup
Left = 0
Height = 122
Top = 0
Width = 367
Align = alClient
AutoFill = True
Caption = '&Minimal field Options'
ChildSizing.LeftRightSpacing = 6
ChildSizing.TopBottomSpacing = 6
ChildSizing.EnlargeHorizontal = crsHomogenousChildResize
ChildSizing.EnlargeVertical = crsHomogenousChildResize
ChildSizing.ShrinkHorizontal = crsScaleChilds
ChildSizing.ShrinkVertical = crsScaleChilds
ChildSizing.Layout = cclTopToBottomThenLeftToRight
ChildSizing.ControlsPerLine = 3
ClientHeight = 104
ClientWidth = 365
ColumnLayout = clVerticalThenHorizontal
Columns = 3
Items.Strings = (
'In Key'
'In Insert'
'In Update'
'Required'
'Filter'
'Order By'
'Order By Desc'
)
TabOrder = 1
Data = {
0700000002020202020202
}
end
end

View File

@ -0,0 +1,79 @@
unit dlgrestfieldoptions;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ExtCtrls, ButtonPanel, sqldbrestschema;
type
{ TRestFieldOptionsDialog }
TRestFieldOptionsDialog = class(TForm)
BPFieldOptions: TButtonPanel;
CGFieldOptions: TCheckGroup;
private
function GetOptions: TRestFieldOptions;
procedure Setoptions(AValue: TRestFieldOptions);
public
Property Options : TRestFieldOptions Read GetOptions Write Setoptions;
end;
Function GetRestFieldOptions(var aOptions : TRestFieldOptions) : Boolean;
implementation
Function GetRestFieldOptions(var aOptions : TRestFieldOptions) : Boolean;
begin
With TRestFieldOptionsDialog.Create(Application) do
try
Options:=aOptions;
Result:=ShowModal=mrOK;
if Result then
aOptions:=Options;
finally
Free;
end;
end;
{$R *.lfm}
function TRestFieldOptionsDialog.GetOptions: TRestFieldOptions;
Procedure DoOption(O : TRestFieldOption);
begin
if CGFieldOPtions.Checked[Ord(O)] then
Include(Result,O);
end;
Var
O : TRestFieldOption;
begin
Result:=[];
For O in TRestFieldOption do
DoOption(O);
end;
procedure TRestFieldOptionsDialog.Setoptions(AValue: TRestFieldOptions);
Procedure DoOption(O : TRestFieldOption);
begin
CGFieldOptions.Checked[Ord(O)]:=O in aValue;
end;
Var
O : TRestFieldOption;
begin
For O in TRestFieldOption do
DoOption(O);
end;
end.

View File

@ -0,0 +1,251 @@
object SQLDBRestConnectionEditorForm: TSQLDBRestConnectionEditorForm
Left = 386
Height = 540
Top = 256
Width = 368
Caption = 'SQL Connection'
ClientHeight = 540
ClientWidth = 368
OnCloseQuery = FormCloseQuery
OnCreate = FormCreate
OnDestroy = FormDestroy
Position = poMainFormCenter
LCLVersion = '2.1.0.0'
object EHostName: TEdit
Left = 89
Height = 27
Top = 79
Width = 185
Anchors = [akTop, akLeft, akRight]
TabOrder = 2
end
object EDatabaseName: TEdit
Left = 89
Height = 27
Top = 112
Width = 273
Anchors = [akTop, akLeft, akRight]
TabOrder = 3
end
object LEUserName: TLabel
Left = 8
Height = 24
Top = 150
Width = 72
Alignment = taRightJustify
AutoSize = False
Caption = 'User'
FocusControl = EUserName
Layout = tlCenter
ParentColor = False
end
object LCBType: TLabel
Left = 8
Height = 31
Top = 40
Width = 72
Alignment = taRightJustify
AutoSize = False
Caption = 'Type'
Layout = tlCenter
ParentColor = False
end
object LEHostName: TLabel
Left = 8
Height = 27
Top = 79
Width = 72
Alignment = taRightJustify
AutoSize = False
Caption = 'Hostname'
FocusControl = EHostName
Layout = tlCenter
ParentColor = False
end
object CBType: TComboBox
Left = 89
Height = 31
Top = 40
Width = 185
Anchors = [akTop, akLeft, akRight]
ItemHeight = 0
Style = csDropDownList
TabOrder = 1
end
object LEDatabaseName: TLabel
Left = 8
Height = 27
Top = 112
Width = 72
Alignment = taRightJustify
AutoSize = False
Caption = 'Database'
FocusControl = EDatabaseName
Layout = tlCenter
ParentColor = False
end
object EUserName: TEdit
Left = 89
Height = 27
Top = 147
Width = 185
Anchors = [akTop, akLeft, akRight]
TabOrder = 4
end
object EPassword: TEdit
Left = 89
Height = 27
Top = 184
Width = 185
Anchors = [akTop, akLeft, akRight]
EchoMode = emPassword
PasswordChar = '*'
TabOrder = 5
end
object LEPassword: TLabel
Left = 8
Height = 27
Top = 184
Width = 72
Alignment = taRightJustify
AutoSize = False
Caption = 'Password'
FocusControl = EPassword
Layout = tlCenter
ParentColor = False
end
object ERole: TEdit
Left = 89
Height = 27
Top = 223
Width = 185
Anchors = [akTop, akLeft, akRight]
TabOrder = 6
end
object BPConnection: TButtonPanel
Left = 6
Height = 42
Top = 492
Width = 356
OKButton.Name = 'OKButton'
OKButton.DefaultCaption = True
HelpButton.Name = 'HelpButton'
HelpButton.DefaultCaption = True
CloseButton.Name = 'CloseButton'
CloseButton.DefaultCaption = True
CancelButton.Name = 'CancelButton'
CancelButton.DefaultCaption = True
TabOrder = 8
ShowButtons = [pbOK, pbCancel]
end
object MParams: TMemo
Left = 8
Height = 160
Top = 320
Width = 348
Anchors = [akTop, akLeft, akRight, akBottom]
TabOrder = 7
end
object LERole: TLabel
Left = 8
Height = 27
Top = 223
Width = 72
Alignment = taRightJustify
AutoSize = False
Caption = 'Role'
FocusControl = ERole
Layout = tlCenter
ParentColor = False
end
object LMParams: TLabel
Left = 8
Height = 17
Top = 296
Width = 125
Caption = 'Additonal Parameters:'
FocusControl = MParams
ParentColor = False
end
object ECharset: TEdit
Left = 89
Height = 27
Top = 259
Width = 80
TabOrder = 9
end
object Label2: TLabel
Left = 32
Height = 17
Top = 264
Width = 50
Caption = 'Char. set'
FocusControl = ECharset
ParentColor = False
end
object SBTest: TSpeedButton
Left = 211
Height = 25
Top = 288
Width = 145
Anchors = [akTop, akRight]
Caption = 'Test connection'
Glyph.Data = {
36040000424D3604000000000000360000002800000010000000100000000100
2000000000000004000064000000640000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
000000000000527BC6FF00000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
000000000000317BEFFF527BC6FF296BC6FF0000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
000000000000397BE7FF007BFFFF0073F7FF527BC6FF00000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
00000000000000000000009CFFFF008CFFFF008CFFFF527BC6FF000000000000
0000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000B5FFFF008CFFFF0094FFFF527BC6FF527B
C6FF000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000B5FFFF08C6FFFF009CFFFF009C
FFFF527BC6FF0000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000B5FFFF08BDFFFF00AD
FFFF009CFFFF527BC6FF00000000000000000000000000000000000000000000
00000000000000000000527BC6FF527BC6FF527BC6FF00C6FFFF08FFFFFF31F7
FFFF10BDFFFF00ADFFFF527BC6FF527BC6FF0000000000000000000000000000
0000000000000000000029ADFFFF00C6FFFF00EFFFFF00F7FFFF00F7FFFF00FF
FFFF4AEFFFFF18CEFFFF00A5FFFF527BC6FF0000000000000000000000000000
0000000000000000000039A5FFFF00C6FFFF00EFFFFF00F7FFFF00EFFFFF00DE
FFFF00FFFFFF00FFFFFF39EFFFFF08C6FFFF527BC6FF00000000000000000000
000000000000000000000000000008C6FFFF39E7FFFF4AEFFFFF42F7FFFF18FF
FFFF00FFFFFF00FFFFFF08FFFFFF21FFFFFF527BC6FF00000000000000000000
0000000000000000000000000000000000000000000031D6FFFF08F7FFFF00FF
FFFF00F7FFFF00D6FFFF00B5FFFF527BC6FF0000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000031D6
FFFF00F7FFFF00EFFFFF00ADFFFF00A5FFFF527BC6FF00000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
00000000000031D6FFFF42DEFFFF10D6FFFF5AA5FFFF527BC6FF000000000000
0000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000031D6FFFF52A5FFFF527BC6FF
}
OnClick = SBTestClick
end
object EName: TEdit
Left = 89
Height = 27
Top = 8
Width = 185
Anchors = [akTop, akLeft, akRight]
TabOrder = 0
end
object LEHostName1: TLabel
Left = 8
Height = 27
Top = 8
Width = 72
Alignment = taRightJustify
AutoSize = False
Caption = 'Alias'
FocusControl = EName
Layout = tlCenter
ParentColor = False
end
end

View File

@ -0,0 +1,197 @@
{
This file is part of the Free Component Library.
Copyright (c) 2017 Michael Van Canneyt, member of the Free Pascal development team
Form to edit a SQLDB data connection, used in data management.
See the file COPYING.FPC, included in this distribution,
for details about the copyright.
This program 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.
**********************************************************************}
unit dlgsqldbrestconnection;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls, ButtonPanel, Buttons, sqldb, sqldbrestbridge;
type
{ TSQLDBRestConnectionEditorForm }
TSQLDBRestConnectionEditorForm = class(TForm)
BPConnection: TButtonPanel;
CBType: TComboBox;
ECharset: TEdit;
EName: TEdit;
ERole: TEdit;
EUserName: TEdit;
EPassword: TEdit;
EHostName: TEdit;
EDatabaseName: TEdit;
Label2: TLabel;
LEHostName1: TLabel;
LEUserName: TLabel;
LCBType: TLabel;
LEHostName: TLabel;
LEDatabaseName: TLabel;
LEPassword: TLabel;
LERole: TLabel;
LMParams: TLabel;
MParams: TMemo;
SBTest: TSpeedButton;
procedure FormCloseQuery(Sender: TObject; var CanClose: boolean);
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure SBTestClick(Sender: TObject);
private
FConnection: TSQLDBRestConnection;
Function TestConnection : String;
procedure FormToConnection;
procedure ConnectionToForm;
procedure SetConnection(AValue: TSQLDBRestConnection);
public
Property Connection : TSQLDBRestConnection Read FConnection Write SetConnection;
end;
Function EditSQLDBRestConnection(aConnection : TSQLDBRestConnection) : Boolean;
Resourcestring
SConnectionSuccesful = 'Connection to the database was succesfully made.';
SErrConnectionNotOK = 'Error connecting to the database';
SSuccess = 'Succesfully connected.';
implementation
{$R *.lfm}
Function EditSQLDBRestConnection(aConnection : TSQLDBRestConnection) : Boolean;
begin
With TSQLDBRestConnectionEditorForm.Create(Application) do
try
Connection:=aConnection;
result:= (ShowModal=mrOK);
if Result then
aConnection.Assign(Connection);
finally
end;
end;
procedure TSQLDBRestConnectionEditorForm.FormCreate(Sender: TObject);
begin
FConnection:=TSQLDBRestConnection.Create(Nil);
GetConnectionList(CBType.Items);
end;
procedure TSQLDBRestConnectionEditorForm.FormCloseQuery(Sender: TObject; var CanClose: boolean);
Var
S : String;
begin
if ModalResult=mrOK then
begin
FormToConnection;
S:=TestConnection;
if (S<>'') then
if MessageDlg(SErrConnectionNotOK,S,mtError,[mbIgnore,mbCancel],0)=mrIgnore then
S:='';
end;
CanClose:=(S='');
end;
procedure TSQLDBRestConnectionEditorForm.FormDestroy(Sender: TObject);
begin
FreeAndNil(FConnection);
end;
procedure TSQLDBRestConnectionEditorForm.SBTestClick(Sender: TObject);
Var
S : String;
begin
FormToConnection;
S:=TestConnection;
if (S<>'') then
MessageDlg(SErrConnectionNotOK,S,mtError,[mbOK],0)
else
MessageDlg(SSuccess,SConnectionSuccesful,mtInformation,[mbOK],0);
end;
function TSQLDBRestConnectionEditorForm.TestConnection: String;
Var
Conn : TSQLConnector;
TR : TSQLTransaction;
begin
Conn:=TSQLConnector.Create(Self);
try
TR:=TSQLTransaction.Create(Conn);
Conn.Transaction:=TR;
FConnection.ConfigConnection(Conn);
try
Conn.Connected:=true;
except
On E: Exception do
Result:=E.Message;
end;
finally
Conn.Free;
end;
end;
procedure TSQLDBRestConnectionEditorForm.SetConnection(AValue: TSQLDBRestConnection);
begin
if FConnection=AValue then Exit;
FConnection.Assign(AValue);
ConnectionToForm;
end;
procedure TSQLDBRestConnectionEditorForm.FormToConnection;
begin
With FConnection do
begin
Name:=EName.Text;
ConnectionType:=CBType.Text;
HostName:=EHostName.Text;
DatabaseName:=EDatabaseName.Text;
Params:=MParams.Lines;
UserName:=EUserName.Text;
Password:=EPassword.Text;
Role:=ERole.Text;
Charset:=ECharset.Text;
end;
end;
procedure TSQLDBRestConnectionEditorForm.ConnectionToForm;
begin
With FConnection do
begin
EName.Text:=Name;
CBType.Text:=ConnectionType;
EHostName.Text:=HostName;
EDatabaseName.Text:=DatabaseName;
MParams.Lines:=Params;
EUserName.Text:=UserName;
EPassword.Text:=Password;
ERole.Text:=Role;
ECharset.Text:=Charset;
end;
end;
end.

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,446 @@
unit fraconnections;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, Forms, Controls, ComCtrls, ActnList, StdCtrls, DB, sqldb, PropertyStorage, sqldbrestschema, sqldbrestbridge,sqldbschemaedittools;
type
{ TfraConnections }
TfraConnections = class(TFrame)
AConnectionAdd: TAction;
AConnectionDelete: TAction;
AConnectionEdit: TAction;
AConnectionExpose: TAction;
AConnectionRefresh: TAction;
AConnectionsHide: TAction;
aLConnections: TActionList;
ILConnections: TImageList;
Label1: TLabel;
ToolBar1: TToolBar;
TBConnectionAdd: TToolButton;
TBConnectionEdit: TToolButton;
TBConnectionDelete: TToolButton;
TBSep1: TToolButton;
TBConnectionRefresh: TToolButton;
TBConnectionExpose: TToolButton;
ToolButton1: TToolButton;
TBConnectionsHide: TToolButton;
TVConnections: TTreeView;
procedure AConnectionAddExecute(Sender: TObject);
procedure AConnectionDeleteExecute(Sender: TObject);
procedure AConnectionDeleteUpdate(Sender: TObject);
procedure AConnectionEditExecute(Sender: TObject);
procedure AConnectionEditUpdate(Sender: TObject);
procedure AConnectionExposeExecute(Sender: TObject);
procedure AConnectionExposeUpdate(Sender: TObject);
procedure AConnectionRefreshExecute(Sender: TObject);
procedure AConnectionRefreshUpdate(Sender: TObject);
procedure AConnectionsHideExecute(Sender: TObject);
procedure TVConnectionsEdited(Sender: TObject; Node: TTreeNode; var S: string);
procedure TVConnectionsEditing(Sender: TObject; Node: TTreeNode; var AllowEdit: Boolean);
procedure TVConnectionsStartDrag(Sender: TObject; var DragObject: TDragObject);
private
FConnections: TSQLDBRestConnectionList;
FFileName: String;
FModified: Boolean;
FOnImportSchema: TNotifyEvent;
function GetCurrentConnection: TMySQLDBRestConnection;
procedure SetConnections(AValue: TSQLDBRestConnectionList);
procedure ShowConnection(TN: TTreeNode; aConnection: TMySQLDBRestConnection; ShowTables: Boolean=True);
procedure ShowConnectionTables(TN: TTreeNode; aConnection: TMySQLDBRestConnection);
procedure ShowTable(TN: TTreeNode; aConnection: TMySQLDBRestConnection; const aTableName: string);
Protected
procedure ReadConnectionsFromIni(const aFileName, ASection: String);
procedure WriteConnectionsToIni(const aFileName, ASection: String);
Procedure Changed;
public
Constructor Create(AOwner : TComponent); override;
Destructor Destroy; override;
procedure DeleteConnection(aConnection: TSQLDBRestConnection);
procedure LoadConnections(const aFileName: string);
procedure SaveConnections(const aFileName: String);
Procedure ShowConnections;
Procedure LoadSession(aStorage : TCustomPropertyStorage); virtual;
Procedure SaveSession(aStorage : TCustomPropertyStorage); virtual;
Property Connections : TSQLDBRestConnectionList read FConnections write SetConnections;
Property CurrentConnection : TMySQLDBRestConnection Read GetCurrentConnection;
Property OnImportSchema : TNotifyEvent Read FOnImportSchema Write FOnImportSchema;
// Last used filename in Load/saveConnections
Property FileName : String Read FFileName;
Property Modified : Boolean Read FModified;
end;
implementation
uses dialogs, strutils, inifiles, sqldbrestini, dlgsqldbrestconnection;
{$R *.lfm}
Const
KeyConnections = 'Connections';
KeyLoadOptions = 'LoadOptions';
Resourcestring
SErrDuplicateConnection = 'Duplicate connection name: %s';
{ TfraConnections }
procedure TfraConnections.AConnectionsHideExecute(Sender: TObject);
begin
Self.Visible:=False;
end;
procedure TfraConnections.TVConnectionsEdited(Sender: TObject; Node: TTreeNode; var S: string);
Var
D,C : TMySQLDBRestConnection;
begin
C:=TObject(Node.Data) as TMySQLDBRestConnection;
D:=TMySQLDBRestConnection(Connections.FindConnection(S));
if (D<>Nil) and (D<>C) then
begin
ShowMessage(SErrDuplicateConnection);
S:=C.Name;
end
else
begin
C.Name:=S;
Changed;
end;
end;
procedure TfraConnections.TVConnectionsEditing(Sender: TObject;
Node: TTreeNode; var AllowEdit: Boolean);
begin
allowEdit:=(Node.ImageIndex=idxConnection);
end;
procedure TfraConnections.TVConnectionsStartDrag(Sender: TObject; var DragObject: TDragObject);
Var
SDO : TStringsDragObject;
I : Integer;
TN : TTreeNode;
begin
SDO:=TStringsDragObject.Create(TVConnections);
DragObject:=SDO;
for I:=0 to TVConnections.Items.Count-1 do
begin
TN:=TVConnections.Items[I];
if TN.Selected and (TN.ImageIndex=idxTable) then
SDO.Items.AddObject(TN.Text,TObject(TN.Data) as TMySQLDBRestConnection);
end;
end;
procedure TfraConnections.SetConnections(AValue: TSQLDBRestConnectionList);
begin
if FConnections=AValue then Exit;
FConnections.Assign(AValue);
ShowConnections;
end;
function TfraConnections.GetCurrentConnection: TMySQLDBRestConnection;
Var
N : TTreeNode;
begin
N:=TVConnections.Selected;
While (N<>nil) and (N.ImageIndex<>idxConnection) do
N:=N.Parent;
if N=nil then
Result:=nil
else
Result:=TObject(N.Data) as TMySQLDBRestConnection;
end;
constructor TfraConnections.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
FConnections:=TSQLDBRestConnectionList.Create(TMySQLDBRestConnection);
end;
destructor TfraConnections.Destroy;
begin
FreeAndNil(FConnections);
inherited Destroy;
end;
procedure TfraConnections.ShowTable(TN: TTreeNode; aConnection: TMySQLDBRestConnection;
const aTableName: string);
begin
TN.ImageIndex:=idxTable;
TN.SelectedIndex:=idxTable;
TN.Data:=aConnection;
TN.Text:=aTableName;
end;
procedure TfraConnections.ShowConnectionTables(TN : TTreeNode; aConnection : TMySQLDBRestConnection);
Var
L : TStringList;
S : String;
N : TTreeNode;
begin
TN.DeleteChildren;
if aConnection.MyConnection=Nil then
aConnection.CreateConnection;
try
aConnection.MyConnection.Connected:=True;
except
On E : EDatabaseError do
begin
ShowMessage(Format(SErrShowingTablesConnectingTo,[aConnection.Name,E.Message]));
exit;
end;
end;
L:=TStringList.Create;
try
aConnection.MyConnection.GetTableNames(L);
L.Sorted:=true;
For S in L do
begin
N:=TVConnections.Items.AddChild(Tn,S);
ShowTable(N,aConnection,S);
end;
finally
L.Free;
end;
end;
procedure TfraConnections.ShowConnection(TN: TTreeNode; aConnection: TMySQLDBRestConnection; ShowTables: Boolean);
begin
TN.Text:=aConnection.Name;
TN.ImageIndex:=idxConnection;
TN.SelectedIndex:=idxConnection;
TN.Data:=aConnection;
if ShowTables then
ShowConnectionTables(TN,aConnection);
end;
procedure TfraConnections.ShowConnections;
Var
TN : TTreeNode;
C : TMySQLDBRestConnection;
I : Integer;
begin
TVConnections.Items.BeginUpdate;
try
TVConnections.Items.Clear;
For I:=0 to Connections.Count-1 do
begin
C:=Connections[i] as TMySQLDBRestConnection;
TN:=TVConnections.Items.AddChild(Nil,C.Name);
ShowConnection(TN,C);
end;
finally
TVConnections.Items.EndUpdate;
end;
end;
procedure TfraConnections.LoadSession(aStorage: TCustomPropertyStorage);
begin
// Do nothing
end;
procedure TfraConnections.SaveSession(aStorage: TCustomPropertyStorage);
begin
// Do nothing
end;
procedure TfraConnections.DeleteConnection(aConnection : TSQLDBRestConnection);
Var
TN : TTreeNode;
begin
TN:=TVConnections.Items.FindNodeWithData(aConnection);
if Assigned(TN) then
TVConnections.Items.Delete(TN);
aConnection.Free;
Changed;
end;
procedure TfraConnections.AConnectionAddExecute(Sender: TObject);
Var
C : TMySQLDBRestConnection;
TN : TTreeNode;
begin
C:=FConnections.Add as TMySQLDBRestConnection;
if not EditSQLDBRestConnection(C) then
C.Free
else
begin
TN:=TVConnections.Items.AddChild(Nil,C.Name);
ShowConnection(Tn,C,True);
Changed;
end;
end;
procedure TfraConnections.AConnectionDeleteExecute(Sender: TObject);
begin
DeleteConnection(CurrentConnection);
end;
procedure TfraConnections.AConnectionDeleteUpdate(Sender: TObject);
begin
(Sender as TAction).Enabled:=Assigned(CurrentConnection);
end;
procedure TfraConnections.AConnectionEditExecute(Sender: TObject);
Var
C : TMySQLDBRestConnection;
TN : TTreeNode;
begin
C:=CurrentConnection;
if EditSQLDBRestConnection(C) then
begin
TN:=TVConnections.Items.FindNodeWithData(C);
if Assigned(TN) then
ShowConnection(Tn,C,True);
Changed;
end;
end;
procedure TfraConnections.AConnectionEditUpdate(Sender: TObject);
begin
(Sender as TAction).Enabled:=Assigned(CurrentConnection);
end;
procedure TfraConnections.AConnectionExposeExecute(Sender: TObject);
begin
if Assigned(OnImportSchema) then
OnImportSchema(CurrentConnection);
end;
procedure TfraConnections.AConnectionExposeUpdate(Sender: TObject);
begin
(Sender as TAction).Enabled:=Assigned(OnImportSchema);
end;
procedure TfraConnections.AConnectionRefreshExecute(Sender: TObject);
Var
C : TMySQLDBRestConnection;
TN : TTreeNode;
begin
C:=CurrentConnection;
if Assigned(C) then
begin
TN:=TVConnections.Items.FindNodeWithData(C);
if Assigned(TN) then
ShowConnectionTables(TN,C);
end;
end;
procedure TfraConnections.AConnectionRefreshUpdate(Sender: TObject);
begin
(Sender as TAction).Enabled:=Assigned(CurrentConnection);
end;
procedure TfraConnections.WriteConnectionsToIni(const aFileName,
ASection: String);
Var
S,L : String;
I : Integer;
aIni : TMemIniFile;
begin
aIni:=TMemIniFile.Create(aFileName);
try
L:='';
for I:=0 to Connections.Count-1 do
begin
if (L<>'') then
L:=L+',';
L:=L+Connections[i].Name;
end;
aIni.WriteString(aSection,KeyConnections,L);
for I:=0 to Connections.Count-1 do
begin
S:=Connections[i].Name;
L:=ConnectionIniOptionsToStr([]);
Connections[i].SaveToIni(aIni,S,[]);
aIni.WriteString(S,KeyLoadOptions,L);
end;
finally
aIni.Free;
end;
end;
procedure TfraConnections.Changed;
begin
FModified:=True;
end;
procedure TfraConnections.ReadConnectionsFromIni(const aFileName,
ASection: String);
Var
S,L : String;
I : Integer;
C : TSQLDBRestConnection;
CIO : TConnectionIniOptions;
aIni : TMemIniFile;
begin
// Read connections
aIni:=TMemIniFile.Create(aFileName);
try
L:=aIni.ReadString(aSection,KeyConnections,'');
For I:=1 to WordCount(L,[',']) do
begin
S:=ExtractWord(I,L,[',']);
C:=Connections.AddConnection('','','','','');
C.Name:=S;
CIO:=StrToConnectionIniOptions(aIni.ReadString(S,KeyLoadOptions,''));
C.LoadFromIni(aIni,S,CIO);
end;
finally
aIni.Free;
end;
end;
procedure TfraConnections.LoadConnections(const aFileName: string);
begin
case lowercase(ExtractFileExt(aFileName)) of
'.ini' : ReadConnectionsFromIni(aFileName,'Connections');
'.json' : Connections.LoadFromFile(aFileName)
end;
ShowConnections;
FModified:=False;
FFileName:=aFileName;
end;
procedure TfraConnections.SaveConnections(const aFileName: String);
begin
case lowercase(ExtractFileExt(aFileName)) of
'.ini' : WriteConnectionsToIni(aFileName,'Connections');
'.json' : Connections.SaveToFile(aFileName)
end;
FModified:=False;
FFileName:=aFileName;
end;
end.

View File

@ -0,0 +1,179 @@
object SQLDBRestSchemaTablesEditFrame: TSQLDBRestSchemaTablesEditFrame
Left = 0
Height = 346
Top = 0
Width = 696
ClientHeight = 346
ClientWidth = 696
TabOrder = 0
DesignLeft = 711
DesignTop = 443
object LVSchema: TListView
Left = 0
Height = 346
Top = 0
Width = 696
Align = alClient
Columns = <
item
AutoSize = True
Caption = 'Name'
Width = 42
end
item
AutoSize = True
Caption = 'Table name'
Width = 74
end
item
AutoSize = True
Caption = 'Connection'
Width = 71
end
item
Alignment = taCenter
Caption = 'Enabled'
end
item
Alignment = taCenter
Caption = 'Published'
end
item
Alignment = taCenter
Caption = 'Get'
end
item
Alignment = taCenter
Caption = 'Post'
end
item
Alignment = taCenter
Caption = 'Put'
end
item
Alignment = taCenter
Caption = 'Delete'
end
item
Alignment = taCenter
Caption = 'Options'
end
item
Alignment = taCenter
Caption = 'Head'
Width = 143
end>
LargeImages = ILSchema
ReadOnly = True
SmallImages = ILSchema
SortColumn = 0
SortType = stText
StateImages = ILSchema
TabOrder = 0
ViewStyle = vsReport
OnDblClick = LVSchemaDblClick
end
object ILSchema: TImageList
left = 144
top = 128
Bitmap = {
4C69030000001000000010000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0004000000330000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000040000
0084000000EC0000003400000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000004000000670000
00EC000000840000000400000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000400000084000000EC0000
0067000000040000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000400000067000000EC000000840000
000400000000000000000000000000000000000000000000004B0000006C0000
000400000000000000000000000400000084000000EC00000067000000040000
000000000000000000000000000000000000000000000000006C000000EC0000
0067000000040000000400000067000000EC0000008400000004000000000000
0000000000000000000000000000000000000000000000000004000000670000
00EC0000008400000084000000EC000000670000000400000000000000000000
0000000000000000000000000000000000000000000000000000000000040000
0084000000EC000000EC00000084000000040000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0004000000670000006700000004000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000040000000400000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0001000000270000007A0000009D0000009D0000007A00000027000000010000
00000000000000000000000000000000000000000000000000000000001F0000
00AB000000ED000000C7000000B1000000B1000000C8000000ED000000AA0000
001E00000000000000000000000000000000000000000000001F000000AF0000
00DB000000630000001D00000007000000070000001D00000063000000DB0000
00AE0000001E00000000000000000000000000000001000000AA000000DB0000
001C0000000000000000000000000000000000000000000000000000001D0000
00DB000000A800000001000000000000000000000027000000EE000000630000
0000000000000000000000000000000000000000000000000000000000000000
0064000000EE0000002600000000000000000000007A000000C70000001D0000
0000000000000000000000000000000000000000000000000000000000000000
001D000000C80000007900000000000000000000009C000000B2000000070000
0000000000000000000000000000000000000000000000000000000000000000
0007000000B20000009C00000000000000000000009C000000B2000000070000
0000000000000000000000000000000000000000000000000000000000000000
0007000000B20000009C00000000000000000000007A000000C80000001D0000
0000000000000000000000000000000000000000000000000000000000000000
001E000000C800000078000000000000000000000027000000EE000000630000
0000000000000000000000000000000000000000000000000000000000000000
0064000000EE00000026000000000000000000000001000000A9000000DB0000
001D0000000000000000000000000000000000000000000000000000001D0000
00DC000000A8000000010000000000000000000000000000001E000000AE0000
00DB000000640000001E00000007000000070000001E00000065000000DC0000
00AD0000001E00000000000000000000000000000000000000000000001E0000
00A8000000EE000000C8000000B2000000B2000000C8000000EE000000A80000
001E000000000000000000000000000000000000000000000000000000000000
000100000027000000790000009C0000009B0000007800000026000000010000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000926522AA926522AA9265
22AA926522AA926522AA926522AA926522AA926522AA926522AA926522AA9265
22AA926522AA00000000000000000000000000000000DB9834FFAB7628C79265
22AA926522AA926522AAC3872EE3C3872EE3926522AA926522AA926522AAAB76
28C7DB9834FF00000000000000000000000000000000DB9834FF493211550000
00000000000000000000926522AA926522AA0000000000000000000000004932
1155DB9834FF00000000000000000000000000000000DB9834FF493211550000
00000000000000000000926522AA926522AA0000000000000000000000004932
1155DB9834FF00000000000000000000000000000000DB9834FFAB7628C79265
22AA926522AA926522AAC3872EE3C3872EE3926522AA926522AA926522AAAB76
28C7DB9834FF00000000000000000000000000000000DB9834FFAB7628C79265
22AA926522AA926522AAC3872EE3C3872EE3926522AA926522AA926522AAAB76
28C7DB9834FF00000000000000000000000000000000DB9834FF493211550000
00000000000000000000926522AA926522AA0000000000000000000000004932
1155DB9834FF00000000000000000000000000000000DB9834FF493211550000
00000000000000000000926522AA926522AA0000000000000000000000004932
1155DB9834FF00000000000000000000000000000000DB9834FFAB7628C79265
22AA926522AA926522AAC3872EE3C3872EE3926522AA926522AA926522AAAB76
28C7DB9834FF00000000000000000000000000000000DB9834FFAB7628C79265
22AA926522AA926522AAC3872EE3C3872EE3926522AA926522AA926522AAAB76
28C7DB9834FF00000000000000000000000000000000DB9834FF493211550000
00000000000000000000926522AA926522AA0000000000000000000000004932
1155DB9834FF00000000000000000000000000000000DB9834FF493211550000
00000000000000000000926522AA926522AA0000000000000000000000004932
1155DB9834FF00000000000000000000000000000000DB9834FFAB7628C79265
22AA926522AA926522AAC3872EE3C3872EE3926522AA926522AA926522AAAB76
28C7DB9834FF00000000000000000000000000000000926522AA926522AA9265
22AA926522AA926522AA926522AA926522AA926522AA926522AA926522AA9265
22AA926522AA0000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000
}
end
end

View File

@ -0,0 +1,157 @@
unit fraschematableseditor;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, Forms, Controls, ComCtrls, sqldbrestschema, sqldbschemaedittools;
type
{ TSQLDBRestSchemaTablesEditFrame }
TSQLDBRestSchemaTablesEditFrame = class(TBaseEditFrame)
ILSchema: TImageList;
LVSchema: TListView;
procedure LVSchemaDblClick(Sender: TObject);
private
FOnSelectResource: TNotifyEvent;
FSchema: TSQLDBRestSchema;
procedure AddResourceToList(Res: TSQLDBRestResource);
procedure SetSchema(AValue: TSQLDBRestSchema);
procedure ShowResource(LI: TListItem; Res: TSQLDBRestResource);
Protected
procedure SetFrameData(aData: TObject); override;
public
Procedure ShowSchema;
Function Modified : Boolean; override;
Procedure SaveData; override;
Function FrameCaption : String; override;
Property Schema : TSQLDBRestSchema Read FSchema Write SetSchema;
Property OnSelectResource : TNotifyEvent Read FOnSelectResource Write FOnSelectResource;
end;
implementation
uses dialogs;
Const
idxChecked = 0;
idxUnChecked = 1;
idxTable = 2;
{$R *.lfm}
{ TSQLDBRestSchemaTablesEditFrame }
procedure TSQLDBRestSchemaTablesEditFrame.SetSchema(AValue: TSQLDBRestSchema);
begin
if FSchema=AValue then Exit;
FSchema:=AValue;
ShowSchema;
end;
procedure TSQLDBRestSchemaTablesEditFrame.ShowResource(LI: TListItem;
Res: TSQLDBRestResource);
procedure ShowBool(Idx : Integer; B : Boolean);
begin
LI.SubItems[Idx]:='';
if B then
LI.SubItemImages[Idx]:=idxChecked;
end;
Procedure ShowOp(idx : Integer; O : TRestOperation);
begin
ShowBool(Idx,O in Res.AllowedOperations);
end;
Var
i : Integer;
begin
// LI.StateIndex:=idxTable;
LI.Data:=Res;
LI.ImageIndex:=idxTable;
LI.Caption:=Res.ResourceName;
for I:=0 to LVSchema.ColumnCount-1 do
LI.SubItems.Add('');
LI.SubItems[0]:=Res.TableName;
LI.SubItems[1]:=Res.ConnectionName;
ShowBool(2,Res.Enabled);
ShowBool(3,Res.InMetadata);
ShowOp(4,roGet);
ShowOp(5,roPost);
ShowOp(6,roPut);
ShowOp(7,roDelete);
ShowOp(8,roOptions);
ShowOp(9,roHead);
end;
procedure TSQLDBRestSchemaTablesEditFrame.SetFrameData(aData: TObject);
begin
Schema:=aData as TSQLDBRestSchema;
end;
procedure TSQLDBRestSchemaTablesEditFrame.LVSchemaDblClick(Sender: TObject);
begin
if Assigned(OnSelectResource) and Assigned(LVSchema.Selected) And Assigned(LVSchema.Selected.Data) then
OnSelectResource(TSQLDBRestResource(LVSchema.Selected.Data));
end;
procedure TSQLDBRestSchemaTablesEditFrame.AddResourceToList(
Res: TSQLDBRestResource);
Var
LI : TListItem;
begin
LI:=LVSchema.Items.Add;
ShowResource(LI,Res);
end;
procedure TSQLDBRestSchemaTablesEditFrame.ShowSchema;
Var
I : Integer;
begin
With LVSchema.Items do
begin
BeginUpdate;
try
Clear;
if Not assigned(Schema) then
exit;
For I:=0 to Schema.Resources.Count-1 do
AddResourceToList(Schema.Resources[I]);
finally
EndUpdate;
end;
end;
end;
function TSQLDBRestSchemaTablesEditFrame.Modified: Boolean;
begin
Result:=False;
end;
procedure TSQLDBRestSchemaTablesEditFrame.SaveData;
begin
// nothing to do
end;
function TSQLDBRestSchemaTablesEditFrame.FrameCaption: String;
begin
if FSchema=Nil then
Result:=SUnknownObject
else
Result:=Schema.Name;
Result:=Format(SEditObject,[SSchema,Result]);
end;
end.

View File

@ -0,0 +1,84 @@
object SchemaEditorFrame: TSchemaEditorFrame
Left = 0
Height = 614
Top = 0
Width = 797
ClientHeight = 614
ClientWidth = 797
LCLVersion = '2.1.0.0'
TabOrder = 0
DesignLeft = 527
DesignTop = 287
inline fraConn: TfraConnections
Height = 614
Width = 203
Align = alLeft
ClientHeight = 614
ClientWidth = 203
inherited TVConnections: TTreeView
Height = 557
Width = 203
end
inherited ToolBar1: TToolBar
Width = 203
end
inherited Label1: TLabel
Width = 203
end
end
object splConnection: TSplitter
Left = 203
Height = 614
Top = 0
Width = 5
end
inline fraSchema: TSQLDBRestSchemaEditorFrame
Left = 208
Height = 614
Width = 589
Align = alClient
ClientHeight = 614
ClientWidth = 589
TabOrder = 2
inherited PResources: TPanel
Height = 614
Width = 170
ClientHeight = 614
ClientWidth = 170
inherited TBResources: TToolBar
Width = 170
EdgeInner = esRaised
EdgeOuter = esLowered
inherited ToolButton4: TToolButton
Left = 1
Top = 30
end
inherited ToolButton5: TToolButton
Left = 31
Top = 30
end
end
inherited TVResources: TTreeView
Height = 557
Width = 170
end
inherited LResources: TLabel
Width = 170
end
end
inherited Splitter1: TSplitter
Left = 170
Height = 614
end
inherited PDock: TPanel
Left = 175
Height = 614
Width = 414
ClientHeight = 614
ClientWidth = 414
inherited LFrame: TLabel
Width = 414
end
end
end
end

View File

@ -0,0 +1,173 @@
unit frasqldbfullrestschemaaditor;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, Forms, Controls, ExtCtrls, PropertyStorage, fraconnections, sqldb, sqldbrestschema, sqldbschemaedittools,
fraSQLDBRestSchemaEditor, sqldbrestbridge;
type
{ TSchemaEditorFrame }
TSchemaEditorFrame = class(TFrame)
fraConn: TfraConnections;
splConnection: TSplitter;
fraSchema: TSQLDBRestSchemaEditorFrame;
private
FOnSchemaChanged: TNotifyEvent;
procedure DoImportSchema(Sender: TObject);
procedure DoSchemaChanged(Sender: TObject);
function GetConnections: TSQLDBRestConnectionList;
function GetConnectionsFileName: String;
function GetConnectionsModified: Boolean;
function GetModified: Boolean;
function GetSchema: TSQLDBRestSchema;
procedure SetConnections(AValue: TSQLDBRestConnectionList);
procedure SetSchema(AValue: TSQLDBRestSchema);
public
Constructor Create(aOwner : TComponent);override;
Procedure ClearSchema;
Function CheckSave : Boolean;
Procedure LoadSchema(Const aFileName : String);
Procedure SaveSchema(Const aFileName : String);
Procedure LoadConnections(Const aFileName : String);
Procedure SaveConnections(Const aFileName : String);
Procedure LoadSession(aStorage : TCustomPropertyStorage);
Procedure SaveSession(aStorage : TCustomPropertyStorage);
Property ConnectionsFileName : String Read GetConnectionsFileName;
Property SchemaModified : Boolean Read GetModified;
Property ConnectionsModified : Boolean Read GetConnectionsModified;
Property OnSchemaChanged : TNotifyEvent Read FOnSchemaChanged Write FOnSchemaChanged;
Property Schema : TSQLDBRestSchema Read GetSchema Write SetSchema;
Property Connections : TSQLDBRestConnectionList Read GetConnections Write SetConnections;
end;
implementation
uses dlgrestfieldoptions;
{$R *.lfm}
{ TSchemaEditorFrame }
procedure TSchemaEditorFrame.DoImportSchema(Sender: TObject);
Var
RFO : TRestFieldOptions;
Conn : TSQLConnection;
begin
Conn:=(Sender as TMySQLDBRestConnection).MyConnection;
RFO:=fraSchema.ImportOpts;
if GetRestFieldOptions(RFO) then
FraSchema.Schema.PopulateResources(Conn,Nil,RFO);
end;
procedure TSchemaEditorFrame.DoSchemaChanged(Sender: TObject);
begin
if Assigned(FOnSchemaChanged) then
FOnSchemaChanged(Sender);
end;
function TSchemaEditorFrame.GetConnections: TSQLDBRestConnectionList;
begin
Result:=fraConn.Connections;
end;
function TSchemaEditorFrame.GetConnectionsFileName: String;
begin
Result:=fraConn.FileName;
end;
function TSchemaEditorFrame.GetConnectionsModified: Boolean;
begin
Result:=fraConn.Modified
end;
function TSchemaEditorFrame.GetModified: Boolean;
begin
Result:=fraSchema.Modified;
end;
function TSchemaEditorFrame.GetSchema: TSQLDBRestSchema;
begin
Result:=fraSchema.Schema;
end;
procedure TSchemaEditorFrame.SetConnections(AValue: TSQLDBRestConnectionList);
begin
FraConn.Connections:=aValue;
end;
procedure TSchemaEditorFrame.SetSchema(AValue: TSQLDBRestSchema);
begin
if Assigned(aValue) then
begin
Schema.Name:=aValue.Name;
Schema.Resources.Assign(aValue.Resources);
fraSchema.ShowResources;
end;
end;
constructor TSchemaEditorFrame.Create(aOwner: TComponent);
begin
inherited Create(aOwner);
fraConn.OnImportSchema:=@DoImportSchema;
fraSchema.ConnectionPane:=fraConn;
fraSchema.Connections:=fraConn.Connections;
fraSchema.OnChanged:=@DoSchemaChanged;
end;
procedure TSchemaEditorFrame.ClearSchema;
begin
FraSchema.ClearSchema;
end;
function TSchemaEditorFrame.CheckSave: Boolean;
begin
Result:=FraSchema.CheckSave;
end;
procedure TSchemaEditorFrame.LoadSchema(const aFileName: String);
begin
fraSchema.LoadFromFile(aFileName);
end;
procedure TSchemaEditorFrame.SaveSchema(const aFileName: String);
begin
fraSchema.SaveToFile(aFileName);
end;
procedure TSchemaEditorFrame.LoadConnections(const aFileName: String);
begin
fraConn.LoadConnections(aFileName);
end;
procedure TSchemaEditorFrame.SaveConnections(const aFileName: String);
begin
fraConn.SaveConnections(aFileName);
end;
procedure TSchemaEditorFrame.LoadSession(aStorage: TCustomPropertyStorage);
begin
fraConn.Width:=aStorage.ReadInteger('Connections_Width',fraConn.Width);
fraConn.Visible:=aStorage.ReadBoolean('Connections_Visible',fraConn.Visible);
fraConn.LoadSession(aStorage);
fraSchema.LoadSession(aStorage);
end;
procedure TSchemaEditorFrame.SaveSession(aStorage: TCustomPropertyStorage);
begin
aStorage.WriteInteger('Connections_Width',fraConn.Width);
aStorage.WriteBoolean('Connections_Visible',fraConn.Visible);
fraConn.SaveSession(aStorage);
fraSchema.SaveSession(aStorage);
end;
end.

View File

@ -0,0 +1,210 @@
object ResourceFieldsEditFrame: TResourceFieldsEditFrame
Left = 0
Height = 498
Top = 0
Width = 850
ClientHeight = 498
ClientWidth = 850
TabOrder = 0
DesignLeft = 417
DesignTop = 292
object LVFields: TListView
Left = 0
Height = 498
Top = 0
Width = 850
Align = alClient
Columns = <
item
AutoSize = True
Caption = 'Public name'
Width = 76
end
item
AutoSize = True
Caption = 'Native field name'
Width = 106
end
item
Caption = 'Type'
Width = 80
end
item
Caption = 'Native type'
Width = 120
end
item
AutoSize = True
Caption = 'Sequence'
Width = 63
end
item
Caption = 'Key'
Width = 40
end
item
Caption = 'Insert'
end
item
Caption = 'Update'
end
item
Caption = 'Required'
end
item
Caption = 'Filter'
end
item
Caption = 'Order by'
Width = 64
end
item
Caption = 'Order by Desc'
Width = 102
end>
LargeImages = ILFields
ReadOnly = True
SmallImages = ILFields
SortColumn = 1
SortType = stText
StateImages = ILFields
TabOrder = 0
ViewStyle = vsReport
OnDblClick = LVFieldsDblClick
end
object ILFields: TImageList
left = 178
top = 147
Bitmap = {
4C69040000001000000010000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0004000000330000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000040000
0084000000EC0000003400000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000004000000670000
00EC000000840000000400000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000400000084000000EC0000
0067000000040000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000400000067000000EC000000840000
000400000000000000000000000000000000000000000000004B0000006C0000
000400000000000000000000000400000084000000EC00000067000000040000
000000000000000000000000000000000000000000000000006C000000EC0000
0067000000040000000400000067000000EC0000008400000004000000000000
0000000000000000000000000000000000000000000000000004000000670000
00EC0000008400000084000000EC000000670000000400000000000000000000
0000000000000000000000000000000000000000000000000000000000040000
0084000000EC000000EC00000084000000040000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0004000000670000006700000004000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000040000000400000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0001000000270000007A0000009D0000009D0000007A00000027000000010000
00000000000000000000000000000000000000000000000000000000001F0000
00AB000000ED000000C7000000B1000000B1000000C8000000ED000000AA0000
001E00000000000000000000000000000000000000000000001F000000AF0000
00DB000000630000001D00000007000000070000001D00000063000000DB0000
00AE0000001E00000000000000000000000000000001000000AA000000DB0000
001C0000000000000000000000000000000000000000000000000000001D0000
00DB000000A800000001000000000000000000000027000000EE000000630000
0000000000000000000000000000000000000000000000000000000000000000
0064000000EE0000002600000000000000000000007A000000C70000001D0000
0000000000000000000000000000000000000000000000000000000000000000
001D000000C80000007900000000000000000000009C000000B2000000070000
0000000000000000000000000000000000000000000000000000000000000000
0007000000B20000009C00000000000000000000009C000000B2000000070000
0000000000000000000000000000000000000000000000000000000000000000
0007000000B20000009C00000000000000000000007A000000C80000001D0000
0000000000000000000000000000000000000000000000000000000000000000
001E000000C800000078000000000000000000000027000000EE000000630000
0000000000000000000000000000000000000000000000000000000000000000
0064000000EE00000026000000000000000000000001000000A9000000DB0000
001D0000000000000000000000000000000000000000000000000000001D0000
00DC000000A8000000010000000000000000000000000000001E000000AE0000
00DB000000640000001E00000007000000070000001E00000065000000DC0000
00AD0000001E00000000000000000000000000000000000000000000001E0000
00A8000000EE000000C8000000B2000000B2000000C8000000EE000000A80000
001E000000000000000000000000000000000000000000000000000000000000
000100000027000000790000009C0000009B0000007800000026000000010000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000003021
0B38926522AA926522AA926522AA926522AA926522AA926522AA30210B380000
0000000000000000000000000000000000000000000000000000000000004932
1155DB9834FF926522AA926522AA926522AA926522AADB9834FF493211550000
0000000000000000000000000000000000000000000000000000000000004932
1155DB9834FF00000000000000000000000000000000DB9834FF493211550000
0000000000000000000000000000000000000000000000000000000000004932
1155DB9834FF00000000000000000000000000000000DB9834FF493211550000
0000000000000000000000000000000000000000000000000000000000004932
1155DB9834FF00000000000000000000000000000000DB9834FF493211550000
0000000000000000000000000000000000000000000000000000000000004932
1155DB9834FF00000000000000000000000000000000DB9834FF493211550000
0000000000000000000000000000000000000000000000000000000000004932
1155DB9834FF00000000000000000000000000000000DB9834FF493211550000
0000000000000000000000000000000000000000000000000000000000004932
1155DB9834FF00000000000000000000000000000000DB9834FF493211550000
0000000000000000000000000000000000000000000000000000000000004932
1155DB9834FF00000000000000000000000000000000DB9834FF493211550000
0000000000000000000000000000000000000000000000000000000000004932
1155DB9834FF00000000000000000000000000000000DB9834FF493211550000
0000000000000000000000000000000000000000000000000000000000004932
1155DB9834FF00000000000000000000000000000000DB9834FF493211550000
0000000000000000000000000000000000000000000000000000000000004932
1155DB9834FF00000000000000000000000000000000DB9834FF493211550000
0000000000000000000000000000000000000000000000000000000000004932
1155DB9834FF926522AA926522AA926522AA926522AADB9834FF493211550000
0000000000000000000000000000000000000000000000000000000000003021
0B38926522AA926522AA926522AA926522AA926522AA926522AA30210B380000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000093652026926522769265
239D926623929265213F31210A04000000000000000000000000000000000000
000000000000000000000000000018110509AA77286ADB9834FBDB9834FFDB98
34FFDB9834FFDB9834FCDC9835AD30210B130000000000000000000000000000
0000000000000000000000000000AB792748DB9834E9DB9834FFDB9834FFDB98
34FFDB9834FFDB9834FFDB9834FFC3872D8331210A0400000000000000000000
0000000000000000000000000000DC9834BDDB9834FFDB9834EFAB77287A9463
20149365213CDB9834DFDB9834FFDB9834E37A541D7149321155493211554932
1155493211554932115549321155DB9834F0DB9834FFDA9833BD483311120000
000000000000D999337BDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB98
34FFDB9834FFDB9834FFDB9834FFDB9834F0DB9834FFDC9834BD4A3211120000
000000000000DA96337BDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB98
34FFDB9834FFDB9834FFDB9834FFDC9834BDDB9834FFDB9834EFAB77287A9269
200E9267213ADB9834DFDB9834FFDC9834E47A541D724932115549321155DB98
34FFDB9834FFAB7628C749321155AB792748DB9834E9DB9834FFDB9834FFDB98
34FFDB9834FFDB9834FFDB9834FFC3892D8030230A040000000000000000DB98
34FFDB9834FF926522AA0000000018110509AA77286ADB9834FBDB9834FFDB98
34FFDB9834FFDB9834FCDC9835AD31220B110000000000000000000000004932
11554932115530210B3800000000000000000000000093652026926522769265
22A4926622949265213F31210A04000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000
}
end
end

View File

@ -0,0 +1,157 @@
unit frasqldbresourcefields;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, Forms, Controls, ComCtrls, DB, sqldbrestschema, sqldbschemaedittools;
type
{ TResourceFieldsEditFrame }
TResourceFieldsEditFrame = class(TBaseEditFrame)
ILFields: TImageList;
LVFields: TListView;
procedure LVFieldsDblClick(Sender: TObject);
private
FOnSelectField: TNotifyEvent;
FResource: TSQLDBRestResource;
procedure AddFieldToList(Fld: TSQLDBRestField);
procedure SetResource(AValue: TSQLDBRestResource);
procedure ShowField(LI: TListItem; Fld: TSQLDBRestField);
Protected
procedure SetFrameData(aData: TObject); override;
public
Procedure ShowResource;
Function Modified : Boolean; override;
Procedure SaveData; override;
Function FrameCaption : String; override;
Property Resource : TSQLDBRestResource Read FResource Write SetResource;
Property OnSelectField : TNotifyEvent Read FOnSelectField Write FOnSelectField;
end;
implementation
uses typinfo;
{$R *.lfm}
Const
idxChecked = 0;
idxUnChecked = 1;
idxField = 2;
idxKey = 3;
{ TResourceFieldsEditFrame }
procedure TResourceFieldsEditFrame.SetResource(AValue: TSQLDBRestResource);
begin
if FResource=AValue then Exit;
FResource:=AValue;
ShowResource;
end;
procedure TResourceFieldsEditFrame.SetFrameData(aData: TObject);
begin
Resource:=aData as TSQLDBRestResource;
end;
procedure TResourceFieldsEditFrame.ShowField(LI: TListItem; Fld: TSQLDBRestField);
procedure ShowBool(Idx : Integer; B : Boolean; ImgIdx : Integer = idxChecked);
begin
LI.SubItems[Idx]:='';
if B then
LI.SubItemImages[Idx]:=ImgIdx;
end;
Procedure ShowOp(idx : Integer; O : TRestFieldOption);
begin
ShowBool(Idx,O in fld.Options);
end;
Var
i : Integer;
S : String;
begin
LI.Data:=Fld;
LI.ImageIndex:=idxField;
LI.Caption:=Fld.PublicName;
for I:=0 to LVFields.ColumnCount-1 do
LI.SubItems.Add('');
LI.SubItems[0]:=Fld.FieldName;
LI.SubItems[1]:=TypeNames[Fld.FieldType];
S:=GetEnumName(TypeInfo(TFieldType),Ord(Fld.NativeFieldType));
LI.SubItems[2]:=S;
LI.SubItems[3]:=Fld.GeneratorName;
ShowBool(4,foInKey in Fld.Options,idxKey);
ShowOp(5,foInInsert);
ShowOp(6,foInUpdate);
ShowOp(7,foRequired);
ShowOp(8,foFilter);
ShowOp(9,foOrderBy);
ShowOp(10,foOrderByDesc);
end;
procedure TResourceFieldsEditFrame.LVFieldsDblClick(Sender: TObject);
begin
if Assigned(OnSelectField) and Assigned(LVFields.Selected) And Assigned(LVFields.Selected.Data) then
OnSelectField(TSQLDBRestResource(LVFields.Selected.Data));
end;
procedure TResourceFieldsEditFrame.AddFieldToList(Fld: TSQLDBRestField);
Var
LI : TListItem;
begin
LI:=LVFields.Items.Add;
ShowField(LI,Fld);
end;
procedure TResourceFieldsEditFrame.ShowResource;
Var
I : Integer;
begin
With LVFields.Items do
begin
BeginUpdate;
try
Clear;
if Not assigned(Resource) then
exit;
For I:=0 to Resource.Fields.Count-1 do
AddFieldToList(Resource.Fields[I]);
finally
EndUpdate;
end;
end;
end;
function TResourceFieldsEditFrame.Modified: Boolean;
begin
Result:=False;
end;
procedure TResourceFieldsEditFrame.SaveData;
begin
// nothing to do
end;
function TResourceFieldsEditFrame.FrameCaption: String;
begin
if FResource=Nil then
Result:=SUnknownObject
else
Result:=Resource.ResourceName;
Result:=Format(SEditObjectFields,[Result]);
end;
end.

View File

@ -0,0 +1,196 @@
object SQLDBRestFieldEditFrame: TSQLDBRestFieldEditFrame
Left = 0
Height = 455
Top = 0
Width = 473
ClientHeight = 455
ClientWidth = 473
TabOrder = 0
DesignLeft = 499
DesignTop = 339
object LPublicName: TLabel
Left = 24
Height = 27
Top = 8
Width = 92
Alignment = taRightJustify
AutoSize = False
Caption = '&Public name'
FocusControl = EPublicName
Layout = tlCenter
ParentColor = False
end
object EGeneratorName: TEdit
Left = 120
Height = 27
Top = 72
Width = 200
TabOrder = 0
TextHint = 'Name of sequence to generate value'
end
object EPublicName: TEdit
Left = 120
Height = 27
Top = 8
Width = 200
TabOrder = 1
TextHint = 'Name as seen by users'
end
object EFieldName: TEdit
Left = 120
Height = 27
Top = 40
Width = 200
TabOrder = 2
TextHint = 'Fieldname in database'
end
object CBFieldType: TComboBox
Left = 120
Height = 31
Top = 104
Width = 152
ItemHeight = 0
Style = csDropDownList
TabOrder = 3
end
object CBNativeFieldType: TComboBox
Left = 120
Height = 31
Top = 136
Width = 152
ItemHeight = 0
Style = csDropDownList
TabOrder = 4
end
object SEMaxLen: TSpinEdit
Left = 120
Height = 27
Top = 168
Width = 50
TabOrder = 5
end
object CGFieldOptions: TCheckGroup
Left = 6
Height = 120
Top = 200
Width = 459
AutoFill = True
Caption = '&Options'
ChildSizing.LeftRightSpacing = 6
ChildSizing.TopBottomSpacing = 6
ChildSizing.EnlargeHorizontal = crsHomogenousChildResize
ChildSizing.EnlargeVertical = crsHomogenousChildResize
ChildSizing.ShrinkHorizontal = crsScaleChilds
ChildSizing.ShrinkVertical = crsScaleChilds
ChildSizing.Layout = cclTopToBottomThenLeftToRight
ChildSizing.ControlsPerLine = 3
ClientHeight = 102
ClientWidth = 457
ColumnLayout = clVerticalThenHorizontal
Columns = 3
Items.Strings = (
'In Key'
'In Insert'
'In Update'
'Required'
'Filter'
'Order By'
'Order By Desc'
)
OnItemClick = CGFieldOptionsItemClick
TabOrder = 6
Data = {
0700000002020202020202
}
end
object CGFilters: TCheckGroup
Left = 7
Height = 105
Top = 320
Width = 458
AutoFill = True
Caption = '&Allowed Filters'
ChildSizing.LeftRightSpacing = 6
ChildSizing.TopBottomSpacing = 6
ChildSizing.EnlargeHorizontal = crsHomogenousChildResize
ChildSizing.EnlargeVertical = crsHomogenousChildResize
ChildSizing.ShrinkHorizontal = crsScaleChilds
ChildSizing.ShrinkVertical = crsScaleChilds
ChildSizing.Layout = cclTopToBottomThenLeftToRight
ChildSizing.ControlsPerLine = 3
ClientHeight = 87
ClientWidth = 456
ColumnLayout = clVerticalThenHorizontal
Columns = 2
Items.Strings = (
'Equal (=)'
'Less than (<)'
'Greater than (>)'
'Less than or equal (<=)'
'Greater than or equal (>=)'
'Null (is null)'
)
TabOrder = 7
Data = {
06000000020202020202
}
end
object LPublicName1: TLabel
Left = 24
Height = 27
Top = 40
Width = 92
Alignment = taRightJustify
AutoSize = False
Caption = 'Field &name'
Layout = tlCenter
ParentColor = False
end
object LPublicName2: TLabel
Left = 8
Height = 27
Top = 72
Width = 108
Alignment = taRightJustify
AutoSize = False
Caption = 'Seq&uence name'
Layout = tlCenter
ParentColor = False
end
object LPublicName3: TLabel
Left = 6
Height = 27
Top = 104
Width = 108
Alignment = taRightJustify
AutoSize = False
Caption = '&Field type'
FocusControl = CBFieldType
Layout = tlCenter
ParentColor = False
end
object LPublicName4: TLabel
Left = 8
Height = 27
Top = 140
Width = 108
Alignment = taRightJustify
AutoSize = False
Caption = '&Native field type'
FocusControl = CBNativeFieldType
Layout = tlCenter
ParentColor = False
end
object LSEMaxLen: TLabel
Left = 6
Height = 27
Top = 168
Width = 108
Alignment = taRightJustify
AutoSize = False
Caption = 'Max length'
FocusControl = SEMaxLen
Layout = tlCenter
ParentColor = False
end
end

View File

@ -0,0 +1,217 @@
unit frasqldbrestfieldedit;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, Forms, Controls, StdCtrls, Spin, ExtCtrls, db, sqldbschemaedittools, sqldbrestschema;
type
{ TSQLDBRestFieldEditFrame }
TSQLDBRestFieldEditFrame = class(TBaseEditFrame)
CBFieldType: TComboBox;
CBNativeFieldType: TComboBox;
CGFieldOptions: TCheckGroup;
LPublicName1: TLabel;
LPublicName2: TLabel;
LPublicName3: TLabel;
LPublicName4: TLabel;
LSEMaxLen: TLabel;
CGFilters: TCheckGroup;
EGeneratorName: TEdit;
EPublicName: TEdit;
EFieldName: TEdit;
LPublicName: TLabel;
SEMaxLen: TSpinEdit;
procedure CGFieldOptionsItemClick(Sender: TObject; Index: integer);
private
FField: TSQLDBRestField;
procedure CheckFiltersEnabled;
procedure SetField(AValue: TSQLDBRestField);
Protected
Procedure SetFrameData(aData: TObject); override;
public
Constructor Create(aOwner : TComponent); override;
Function Modified : Boolean; override;
Procedure SaveData; override;
Procedure ShowField;
Function FrameCaption : String; override;
Property Field : TSQLDBRestField Read FField Write SetField;
end;
implementation
uses typinfo;
{$R *.lfm}
{ TSQLDBRestFieldEditFrame }
procedure TSQLDBRestFieldEditFrame.CGFieldOptionsItemClick(Sender: TObject;
Index: integer);
begin
if Index=ord(foFilter) then
CheckFiltersEnabled;
end;
procedure TSQLDBRestFieldEditFrame.CheckFiltersEnabled;
begin
CGFilters.Enabled:=CGFieldOptions.Checked[ord(foFilter)];
end;
procedure TSQLDBRestFieldEditFrame.SetField(AValue: TSQLDBRestField);
begin
if FField=AValue then Exit;
FField:=AValue;
ShowField;
end;
procedure TSQLDBRestFieldEditFrame.SetFrameData(aData: TObject);
begin
Field:=aData as TSQLDBRestField;
end;
constructor TSQLDBRestFieldEditFrame.Create(aOwner: TComponent);
Var
T : TRestFieldType;
FT : TFieldType;
begin
inherited Create(aOwner);
CBFieldType.Items.Clear;
For T in TRestFieldType do
if T<>rftUnknown then
CBFieldType.Items.Add(TypeNames[T]);
CBNativeFieldType.Items.Clear;
For FT in TFieldType do
if FT<>ftUnknown then
CBNativeFieldType.Items.Add(GetEnumName(TypeInfo(TFieldType),Ord(FT)))
end;
function TSQLDBRestFieldEditFrame.Modified: Boolean;
Procedure DoOption(O : TRestFieldOption);
begin
Result:=Result or (CGFieldOptions.Checked[Ord(O)]<> (O in Field.Options))
end;
Procedure DoFilter(F : TRestFieldFilter);
begin
Result:=Result or (CGFilters.Checked[Ord(F)]<> (F in Field.Filters));
end;
Var
O : TRestFieldOption;
FO : TRestFieldFilter;
begin
With FField do
begin
Result:=(PublicName <> EPublicName.Text) or
(FieldName <> EFieldName.Text) or
(GeneratorName <> EGeneratorName.Text) or
(FieldType <> TRestFieldType(CBFieldType.ItemIndex+1)) or
(NativeFieldType <> TFieldType(CBNativeFieldType.ItemIndex+1)) or
(MaxLen<>SEMaxLen.Value);
For O in TRestFieldOption do
DoOption(O);
For FO in TRestFieldFilter do
DoFilter(FO);
end;
end;
procedure TSQLDBRestFieldEditFrame.SaveData;
Procedure DoOption(O : TRestFieldOption);
begin
if CGFieldOptions.Checked[Ord(O)] then
Field.Options:=Field.Options+[O]
else
Field.Options:=Field.Options-[O]
end;
Procedure DoFilter(F : TRestFieldFilter);
begin
if CGFilters.Checked[Ord(F)] and (foFilter in Field.Options) then
Field.Filters:=Field.Filters+[F]
else
Field.Filters:=Field.Filters-[F];
end;
Var
O : TRestFieldOption;
FO : TRestFieldFilter;
begin
With FField do
begin
PublicName := EPublicName.Text;
FieldName := EFieldName.Text;
GeneratorName := EGeneratorName.Text;
FieldType := TRestFieldType(CBFieldType.ItemIndex+1);
NativeFieldType := TFieldType(CBNativeFieldType.ItemIndex+1);
MaxLen:=SEMaxLen.Value;
For O in TRestFieldOption do
DoOption(O);
For FO in TRestFieldFilter do
DoFilter(FO);
end;
end;
procedure TSQLDBRestFieldEditFrame.ShowField;
Procedure DoOption(O : TRestFieldOption);
begin
CGFieldOptions.Checked[Ord(O)]:=O in Field.Options;
end;
Procedure DoFilter(F : TRestFieldFilter);
begin
CGFilters.Checked[Ord(F)]:=(foFilter in Field.Options) and (F in Field.Filters);
end;
Var
O : TRestFieldOption;
FO : TRestFieldFilter;
begin
With FField do
begin
EPublicName.Text:=PublicName;
EFieldName.Text:=FieldName;
EGeneratorName.Text:=GeneratorName;
CBFieldType.ItemIndex:=Ord(FieldType)-1;
CBNativeFieldType.ItemIndex:=Ord(NativeFieldType)-1;
SEMaxLen.Value:=MaxLen;
For O in TRestFieldOption do
DoOption(O);
CheckFiltersEnabled;
For FO in TRestFieldFilter do
DoFilter(FO);
end;
end;
function TSQLDBRestFieldEditFrame.FrameCaption: String;
begin
if FField=Nil then
Result:=SUnknownObject
else
Result:=FField.PublicName;
Result:=Format(SEditObject,[SField,Result]);
end;
end.

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,312 @@
unit frasqldbrestresourceedit;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, Forms, Controls, StdCtrls, ExtCtrls, ComCtrls, ActnList, lresources,
sqldbrestbridge, sqldbRestSchema, SynEdit, SynHighlighterSQL, sqldbschemaedittools, frasqldbresourcefields;
type
{ TSQLDBRestResourceEditFrame }
TSQLDBRestResourceEditFrame = class(TBaseEditFrame)
AUpdateFields: TAction;
AValidateSQL: TAction;
AGenerateSQL: TAction;
aLResource: TActionList;
BFields1: TButton;
BGenerate: TButton;
BValidate: TButton;
BFields: TButton;
CBEnabled: TCheckBox;
CGOperations: TCheckGroup;
CBConnection: TComboBox;
CBInMetadata: TCheckBox;
EName: TEdit;
ETableName: TEdit;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
PageControl1: TPageControl;
PButtons: TPanel;
PButtons1: TPanel;
fraFields: TResourceFieldsEditFrame;
SESelect: TSynEdit;
SEInsert: TSynEdit;
SEupdate: TSynEdit;
SEDelete: TSynEdit;
SynSQLSyn1: TSynSQLSyn;
TSFields: TTabSheet;
TSSelect: TTabSheet;
TSInsert: TTabSheet;
TabSheet3: TTabSheet;
TSDelete: TTabSheet;
procedure AGenerateSQLExecute(Sender: TObject);
procedure AUpdateFieldsExecute(Sender: TObject);
procedure AUpdateFieldsUpdate(Sender: TObject);
procedure AValidateSQLExecute(Sender: TObject);
procedure AValidateSQLUpdate(Sender: TObject);
procedure ETableNameEditingDone(Sender: TObject);
private
FOnFieldsChanged: TNotifyEvent;
FResource: TSQLDBRestResource;
function GetOnFieldSelected: TNotifyEvent;
function HaveSelectSQL: Boolean;
procedure SetOnFieldSelected(AValue: TNotifyEvent);
procedure SetResource(AValue: TSQLDBRestResource);
Protected
procedure FieldsChanged;
Procedure UpdateFieldList;
procedure SetConnections(AValue: TSQLDBRestConnectionList); override;
Procedure SetFrameData(aData: TObject); override;
public
Function Modified : Boolean; override;
Procedure SaveData; override;
procedure ShowConnections;
Procedure ShowResource;
Function FrameCaption: String; override;
Property Resource : TSQLDBRestResource Read FResource Write SetResource;
Property OnFieldsChanged : TNotifyEvent Read FOnFieldsChanged Write FOnFieldsChanged;
Property OnSelectField : TNotifyEvent Read GetOnFieldSelected Write SetOnFieldSelected;
end;
implementation
uses dialogs, sqldb;
{$R *.lfm}
{ TSQLDBRestResourceEditFrame }
procedure TSQLDBRestResourceEditFrame.AGenerateSQLExecute(Sender: TObject);
begin
SESelect.Lines.Text:=Resource.GenerateDefaultSQL(skSelect);
end;
procedure TSQLDBRestResourceEditFrame.AUpdateFieldsExecute(Sender: TObject);
begin
if Resource.Fields.Count>0 then
if QuestionDlg(SResetFields, Format(SResetFieldsPrompt, [LineEnding, LineEnding]), mtWarning, [mrYes, SYesResetFields, mrNo,
SDoNotResetFields], 0) <> mrYes then exit;
UpdateFieldList;
end;
function TSQLDBRestResourceEditFrame.HaveSelectSQL: Boolean;
begin
Result:=(SESelect.Lines.Count>0) and (Trim(SESelect.Lines[0])<>'');
end;
function TSQLDBRestResourceEditFrame.GetOnFieldSelected: TNotifyEvent;
begin
Result:=FraFields.OnSelectField;
end;
procedure TSQLDBRestResourceEditFrame.SetOnFieldSelected(AValue: TNotifyEvent);
begin
FraFields.OnSelectField:=aValue;
end;
procedure TSQLDBRestResourceEditFrame.AUpdateFieldsUpdate(Sender: TObject);
begin
(Sender as Taction).Enabled:=(ETableName.Text<>'') or HaveSelectSQL;
end;
procedure TSQLDBRestResourceEditFrame.AValidateSQLExecute(Sender: TObject);
begin
With ExecuteSelect(CBConnection.Text,Resource.ProcessSQl(SESelect.Lines.text,'(1=0)','','')) do
Free;
ShowMessage(SSQLValidatesOK);
end;
procedure TSQLDBRestResourceEditFrame.AValidateSQLUpdate(Sender: TObject);
begin
(Sender as Taction).Enabled:=CanGetSQLConnection and HaveSelectSQL;
end;
procedure TSQLDBRestResourceEditFrame.ETableNameEditingDone(Sender: TObject);
begin
if Not SameText(ETableName.Text,Resource.TableName)
and (Resource.Fields.Count>0)
and Not HaveSelectSQL then
if MessageDlg(Format(STableNameChanged, [LineEnding]), mtWarning, [mbYes, mbNo], 0) = mrYes then
UpdateFieldList;
end;
procedure TSQLDBRestResourceEditFrame.SetResource(AValue: TSQLDBRestResource);
begin
if FResource=AValue then Exit;
FResource:=AValue;
ShowResource;
end;
procedure TSQLDBRestResourceEditFrame.FieldsChanged;
begin
FraFields.ShowResource;
If Assigned(FonFieldsChanged) then
FOnFieldsChanged(FResource);
end;
procedure TSQLDBRestResourceEditFrame.UpdateFieldList;
Var
Q : TSQLQuery;
SQL : String;
idxFields : TStringArray;
begin
SQL:=Trim(SESelect.Lines.Text);
if SQL='' then
SQL:=Resource.GenerateDefaultSQL(skSelect);
Q:=ExecuteSelect(CBConnection.Text,Resource.ProcessSQl(SQL,'(1=0)','',''));
try
Resource.Fields.Clear;
idxFields:=TSQLDBRestSchema.GetPrimaryIndexFields(Q);
Resource.PopulateFieldsFromFieldDefs(Q.FieldDefs,idxFields,Nil,MinFieldOptions);
FieldsChanged;
finally
Q.Free;
end;
end;
procedure TSQLDBRestResourceEditFrame.ShowConnections;
Var
I : Integer;
begin
With CBConnection.Items do
begin
BeginUpdate;
try
if Not assigned(Connections) then
For I:=0 to Connections.Count-1 do
AddObject(Connections[i].Name,Connections[i]);
finally
EndUpdate;
end;
end;
end;
procedure TSQLDBRestResourceEditFrame.SetConnections(AValue: TSQLDBRestConnectionList);
begin
inherited SetConnections(AValue);
ShowConnections;
end;
procedure TSQLDBRestResourceEditFrame.SetFrameData(aData: TObject);
begin
Resource:=aData as TMySQLDBRestResource;
end;
function TSQLDBRestResourceEditFrame.Modified: Boolean;
Function Diff(S1,S2 : TStrings) : Boolean;
begin
Result:=Trim(S1.Text)<>Trim(S2.Text);
end;
Procedure DoOperation(O : TRestOperation);
begin
Result:=Result or (CGOperations.Checked[Ord(O)-1] <> (O in Resource.AllowedOperations));
end;
Var
O : TRestOperation;
begin
Result:=False;
With Resource do
begin
Result:=(ResourceName<>eName.Text) Or
(TableName<>ETableName.Text) Or
(Enabled<>CBEnabled.Checked) Or
(InMetadata<>CBInMetadata.Checked) or
Diff(SQLSelect, SESelect.Lines) Or
Diff(SQLInsert,SEInsert.Lines) Or
Diff(SQLUpdate,SEUpdate.Lines) Or
Diff(SQLDelete,SEDelete.Lines);
for O in TRestOperation do
if o<>roUnknown then
DoOperation(O);
end;
end;
procedure TSQLDBRestResourceEditFrame.SaveData;
Procedure DoOperation(O : TRestOperation);
begin
if CGOperations.Checked[Ord(O)-1] then
Resource.AllowedOperations:=Resource.AllowedOperations+[O]
else
Resource.AllowedOperations:=Resource.AllowedOperations-[O]
end;
Var
O : TRestOperation;
begin
With Resource do
begin
ResourceName := eName.Text;
TableName := ETableName.Text;
SQLSelect := SESelect.Lines;
SQLInsert := SEInsert.Lines;
SQLUpdate := SEUpdate.Lines;
SQLDelete := SEDelete.Lines;
Enabled := CBEnabled.Checked;
InMetadata := CBInMetadata.Checked;
for O in TRestOperation do
if o<>roUnknown then
DoOperation(O);
end;
end;
procedure TSQLDBRestResourceEditFrame.ShowResource;
Procedure DoOperation(O : TRestOperation);
begin
CGOperations.Checked[Ord(O)-1]:=O in Resource.AllowedOperations;
end;
Var
O : TRestOperation;
begin
With Resource do
begin
eName.Text:=ResourceName;
ETableName.Text:=TableName;
SESelect.Lines:=SQLSelect;
SEInsert.Lines:=SQLInsert;
SEUpdate.Lines:=SQLUpdate;
SEDelete.Lines:=SQLDelete;
CBEnabled.Checked:=Enabled;
CBInMetadata.Checked:=InMetadata;
for O in TRestOperation do
if o<>roUnknown then
DoOperation(O);
end;
end;
function TSQLDBRestResourceEditFrame.FrameCaption: String;
begin
if FResource=Nil then
Result:=SUnknownObject
else
Result:=FResource.ResourceName;
Result:=Format(SEditObject,[SResource,Result]);
end;
end.

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,949 @@
unit fraSQLDBRestSchemaEditor;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, Forms, Controls, ExtCtrls, ComCtrls, StdCtrls, ActnList, PropertyStorage, sqldbschemaedittools, sqldbrestschema, sqldbrestbridge;
type
{ TSQLDBRestSchemaEditorFrame }
TSQLDBRestSchemaEditorFrame = class(TFrame)
AAddField: TAction;
ADeleteField: TAction;
AEditField: TAction;
AResourceEdit: TAction;
AResourceDelete: TAction;
AResourceAdd: TAction;
AShowConnections: TAction;
alResources: TActionList;
ILResources: TImageList;
LFrame: TLabel;
LResources: TLabel;
PDock: TPanel;
PResources: TPanel;
Splitter1: TSplitter;
TBResources: TToolBar;
TBShowConnectionsPane: TToolButton;
ToolButton1: TToolButton;
TBResourceAdd: TToolButton;
TBResourceEdit: TToolButton;
TBResourceDelete: TToolButton;
ToolButton2: TToolButton;
ToolButton3: TToolButton;
ToolButton4: TToolButton;
ToolButton5: TToolButton;
TVResources: TTreeView;
procedure AAddFieldExecute(Sender: TObject);
procedure AAddFieldUpdate(Sender: TObject);
procedure ADeleteFieldExecute(Sender: TObject);
procedure ADeleteFieldUpdate(Sender: TObject);
procedure AEditFieldExecute(Sender: TObject);
procedure AEditFieldUpdate(Sender: TObject);
procedure AResourceAddExecute(Sender: TObject);
procedure AResourceDeleteExecute(Sender: TObject);
procedure AResourceDeleteUpdate(Sender: TObject);
procedure AResourceEditExecute(Sender: TObject);
procedure AResourceEditUpdate(Sender: TObject);
procedure AShowConnectionsExecute(Sender: TObject);
procedure AShowConnectionsUpdate(Sender: TObject);
procedure TVResourcesChange(Sender: TObject; Node: TTreeNode);
procedure TVResourcesDblClick(Sender: TObject);
procedure TVResourcesDragDrop(Sender, Source: TObject; X, Y: Integer);
procedure TVResourcesDragOver(Sender, Source: TObject; X, Y: Integer; State: TDragState; var Accept: Boolean);
procedure TVResourcesEdited(Sender: TObject; Node: TTreeNode; var S: string);
procedure TVResourcesEditing(Sender: TObject; Node: TTreeNode; var AllowEdit: Boolean);
private
FConnectionPane: TWinControl;
FConnections: TSQLDBRestConnectionList;
FOnChanged: TNotifyEvent;
FSchema: TMySQLDBRestSchema;
FImportOpts : TRestFieldOptions;
FCurrentFrame : TBaseEditFrame;
FSchemaNode : TTreeNode;
FModified : Boolean;
// Data handling
Procedure Changed;
procedure DoFieldListChanged(Sender: TObject);
function GetModified: Boolean;
Function SelectedResource : TMySQLDBRestResource;
Function SelectedField : TSQLDBRestField;
function AddFieldToResource(aResource: TMySQLDBRestResource): TSQLDBRestField;
function AddResource: TMySQLDBRestResource;
Procedure DeleteResource(R : TMySQLDBRestResource);
Procedure DeleteField(F : TSQLDBRestField);
Function ImportResource(aConnection: TMySQLDBRestConnection; const ATableName: UTF8String; AMinFieldOptions : TRestFieldOptions = []) : TTreeNode;
// Various editors
procedure ConfigFrame(F: TBaseEditFrame; aData: TObject);
procedure RemoveCurrentFrame(DoRefreshNode: Boolean=True);
procedure ShowFieldEditor(aField: TSQLDBRestField);
procedure ShowSchemaEditor(aSchema : TSQLDBRestSchema);
procedure ShowResourceEditor(aResource: TMySQLDBRestResource);
procedure ShowFieldsEditor(aResource: TMySQLDBRestResource);
// Various dialogs
procedure ShowDialogForObject(aData : TObject);
function ShowEditFrameInForm(aFrame: TBaseEditFrame; aData : TObject): Boolean;
procedure ShowResourceDialog(aResource: TMySQLDBRestResource);
procedure ShowFieldDialog(aField: TSQLDBRestField);
// Tree node handling/filling
procedure ChangeResourceName(R: TMySQLDBRestResource; Node: TTreeNode; var S: string);
procedure ChangeRestFieldName(F: TSQLDBRestField; Node: TTreeNode; var S: string);
procedure DoOnSelectResource(Sender: TObject);
procedure DoOnSelectField(Sender: TObject);
procedure RefreshNode(aData: TObject);
Function AddResourceToTree(Res: TMySQLDBRestResource) : TTreeNode;
function FindFieldNode(aResource: TSQLDBRestField): TTreeNode;
function FindResourceNode(aResource: TSQLDBRestResource): TTreeNode;
function FindResourceFieldsNode(aResource: TSQLDBRestResource): TTreeNode;
procedure ShowResource(aNode: TTreeNode; aResource: TMySQLDBRestResource);
procedure ShowResourceFields(aNode: TTreeNode; aResource: TMySQLDBRestResource);
procedure ShowRestField(aNode: TTreeNode; aField: TSQLDBRestField);
Function DoCheckSave : Boolean;
public
Constructor Create(aOwner : TComponent); override;
Destructor Destroy; override;
Procedure LoadSession(aStorage : TCustomPropertyStorage); virtual;
Procedure SaveSession(aStorage : TCustomPropertyStorage); virtual;
Procedure ClearSchema;
Function CheckSave : Boolean;
Property Modified : Boolean Read GetModified;
Procedure LoadFromFile(const aFileName : String);
Procedure SaveToFile(const aFileName : String);
Procedure ShowResources;
Property ImportOpts : TRestFieldOptions Read FImportOpts;
Property ConnectionPane : TWinControl Read FConnectionPane Write FConnectionPane;
Property Schema : TMySQLDBRestSchema Read FSchema;
Property Connections : TSQLDBRestConnectionList Read FConnections Write FConnections;
Property OnChanged : TNotifyEvent Read FOnChanged Write FOnChanged;
end;
implementation
uses typinfo,dialogs, dlgrestfieldoptions, frasqldbrestresourceedit, frasqldbresourcefields, frasqldbrestfieldedit, fraschematableseditor, frmeditframedialog;
{$R *.lfm}
{ TSQLDBRestSchemaEditorFrame }
procedure TSQLDBRestSchemaEditorFrame.RefreshNode(aData : TObject);
Var
R : TMySQLDBRestResource;
F : TSQLDBRestField;
N : TTreeNode;
begin
if AData is TSQLDBRestSchema then
ShowResources
else if AData is TMySQLDBRestResource then
begin
R:=AData as TMySQLDBRestResource;
N:=FindResourceNode(R);
if Assigned(N) then
ShowResource(N,R);
end
else if (aData is TSQLDBRestField) then
begin
F:=aData as TSQLDBRestField;
N:=FindFieldNode(F);
If Assigned(N) then
ShowRestField(N,F);
end;
end;
procedure TSQLDBRestSchemaEditorFrame.RemoveCurrentFrame(DoRefreshNode : Boolean = True);
begin
// Dochecksave does no Changed, changed is called after node is refreshed
if DoCheckSave then
begin
if DoRefreshNode then
RefreshNode(FCurrentFrame.FrameData);
Changed;
end;
FreeAndNil(FCurrentFrame);
end;
procedure TSQLDBRestSchemaEditorFrame.ConfigFrame(F: TBaseEditFrame; aData : TObject);
begin
if aData=Nil then
Raise ESQLDBRest.CreateFmt(0,'Internalerror : no data passed for frame %s',[F.ClassName]);
With F do
begin
Parent:=PDock;
Align:=alClient;
Connections:=Self.Connections;
FrameData:=aData;
MinFieldOptions:=ImportOpts;
LFrame.Caption:=F.FrameCaption;
end;
FCurrentFrame:=F;
end;
procedure TSQLDBRestSchemaEditorFrame.ShowResourceEditor(aResource: TMySQLDBRestResource);
Var
F : TSQLDBRestResourceEditFrame;
begin
RemoveCurrentFrame;
F:=TSQLDBRestResourceEditFrame.Create(Self);
F.OnFieldsChanged:=@DoFieldListChanged;
F.OnSelectField:=@DoOnSelectField;
ConfigFrame(F,aResource);
end;
procedure TSQLDBRestSchemaEditorFrame.ShowFieldsEditor(aResource: TMySQLDBRestResource);
Var
F : TResourceFieldsEditFrame;
begin
RemoveCurrentFrame;
F:=TResourceFieldsEditFrame.Create(Self);
F.OnSelectField:=@DoOnSelectField;
ConfigFrame(F,aResource);
end;
function TSQLDBRestSchemaEditorFrame.ShowEditFrameInForm(aFrame: TBaseEditFrame; aData : TObject): Boolean;
Var
Frm : TEditFrameForm;
begin
Frm:=TEditFrameForm.Create(Self);
try
AFrame.Connections:=Self.Connections;
AFrame.FrameData:=aData;
Frm.EditFrame:=aFrame;
Result:=frm.ShowModal=mrOK;
aFrame.Free;
finally
Frm.Free;
end;
end;
procedure TSQLDBRestSchemaEditorFrame.ShowResourceDialog(aResource: TMySQLDBRestResource);
Var
F : TSQLDBRestResourceEditFrame;
N : TTreeNode;
begin
F:=TSQLDBRestResourceEditFrame.Create(Self);
if ShowEditFrameInForm(F,aResource) then
begin
N:=FindResourceNode(aResource);
if Assigned(N) then
begin
ShowResource(N,aResource);
TVResources.Selected:=N;
end;
Changed;
end;
end;
procedure TSQLDBRestSchemaEditorFrame.ShowFieldDialog(aField: TSQLDBRestField);
Var
F : TSQLDBRestFieldEditFrame;
N : TTreeNode;
begin
F:=TSQLDBRestFieldEditFrame.Create(Self);
if ShowEditFrameInForm(F,aField) then // Frees frame;
begin
N:=FindFieldNode(aField);
if Assigned(N) then
begin
ShowRestField(N,aField);
TVResources.Selected:=N;
end;
Changed;
end;
end;
procedure TSQLDBRestSchemaEditorFrame.ShowFieldEditor(aField: TSQLDBRestField);
Var
F : TSQLDBRestFieldEditFrame;
begin
RemoveCurrentFrame;
F:=TSQLDBRestFieldEditFrame.Create(Self);
ConfigFrame(F,aField);
F.Field:=aField;
end;
function TSQLDBRestSchemaEditorFrame.FindResourceNode(
aResource: TSQLDBRestResource): TTreeNode;
Var
N : TTreeNode;
begin
N:=TVResources.Items.FindNodeWithData(aResource);
if Assigned(N) then
if N.ImageIndex<>idxTable then
N:=N.Parent;
Result:=N;
end;
function TSQLDBRestSchemaEditorFrame.FindResourceFieldsNode(aResource: TSQLDBRestResource): TTreeNode;
begin
Result:=FindResourceNode(aResource);
if Result<>Nil then
begin
Result:=Result.GetFirstChild;
While (Result<>Nil) and (Result.ImageIndex<>idxFields) do
Result:=Result.GetNextSibling;
end;
end;
procedure TSQLDBRestSchemaEditorFrame.DoOnSelectResource(Sender : TObject);
Var
N : TTreeNode;
begin
if (Sender is TSQLDBRestResource) then
begin
N:=FindResourceNode(Sender as TSQLDBRestResource);
if Assigned(N) then
TVResources.Selected:=N;
end;
end;
procedure TSQLDBRestSchemaEditorFrame.DoOnSelectField(Sender: TObject);
Var
N : TTreeNode;
begin
if (Sender is TSQLDBRestField) then
begin
N:=FindFieldNode(Sender as TSQLDBRestField);
if Assigned(N) then
TVResources.Selected:=N;
end;
end;
procedure TSQLDBRestSchemaEditorFrame.ShowSchemaEditor(aSchema: TSQLDBRestSchema);
Var
F : TSQLDBRestSchemaTablesEditFrame;
begin
RemoveCurrentFrame;
F:=TSQLDBRestSchemaTablesEditFrame.Create(Self);
ConfigFrame(F,aSchema);
F.OnSelectResource:=@DoOnSelectResource;
end;
procedure TSQLDBRestSchemaEditorFrame.TVResourcesChange(Sender: TObject; Node: TTreeNode);
begin
Case Node.ImageIndex of
idxConnection : ShowSchemaEditor(TSQLDBRestSchema(Node.Data));
idxTableInfo,
idxTable : ShowResourceEditor(TMySQLDBRestResource(Node.Data));
idxField : ShowFieldEditor(TSQLDBRestField(Node.Data));
idxFields : ShowFieldsEditor(TMySQLDBRestResource(Node.Data));
end;
end;
procedure TSQLDBRestSchemaEditorFrame.ShowDialogForObject(aData : TObject);
begin
if aData is TMySQLDBRestResource then
ShowResourceDialog(aData as TMySQLDBRestResource)
else if aData is TSQLDBRestField then
ShowFieldDialog(aData as TSQLDBRestField);
end;
procedure TSQLDBRestSchemaEditorFrame.TVResourcesDblClick(Sender: TObject);
begin
if Assigned(TVResources.Selected) then
if Assigned(TVResources.Selected.Data) then
ShowDialogForObject(TObject(TVResources.Selected.Data));
end;
function TSQLDBRestSchemaEditorFrame.ImportResource(
aConnection: TMySQLDBRestConnection; const ATableName: UTF8String;
AMinFieldOptions: TRestFieldOptions): TTreeNode;
Var
Res : TSQLDBRestResource;
N : String;
i : Integer;
begin
N:=aTableName;
I:=0;
Res:=Schema.Resources.FindResourceByName(N);
While Res<>Nil do
begin
Inc(i);
N:=aTableName+IntToStr(I);
Res:=Schema.Resources.FindResourceByName(N);
end;
Res:=Schema.Resources.AddResource(aTableName,N);
Schema.PopulateResourceFields(aConnection.MyConnection,Res,AMinFieldOptions);
Result:=AddResourceToTree(Res as TMySQLDBRestResource);
Changed;
end;
procedure TSQLDBRestSchemaEditorFrame.TVResourcesDragDrop(Sender, Source: TObject; X, Y: Integer);
Var
I : Integer;
SDO : TStringsDragObject;
TN : TTreeNode;
begin
SDO:=Source as TStringsDragObject;
TN:=nil;
// FImportOpts so we reuse them
if GetRestFieldOptions(FimportOpts) then
For I:=SDO.Items.Count-1 downto 0 do
TN:=ImportResource(SDO.Items.Objects[i] as TMySQLDBRestConnection,SDO.Items[i],FimportOpts);
if TN<>Nil then
begin
TN.Expanded:=True;
TVResources.Selected:=TN;
end;
end;
procedure TSQLDBRestSchemaEditorFrame.TVResourcesDragOver(Sender,
Source: TObject; X, Y: Integer; State: TDragState; var Accept: Boolean);
begin
Accept:=(Source is TStringsDragObject) and (TStringsDragObject(Source).Items.Count>0);
end;
procedure TSQLDBRestSchemaEditorFrame.ChangeResourceName(R : TMySQLDBRestResource; Node: TTreeNode; var S: string);
Var
DR : TMySQLDBRestResource;
begin
DR:=TMySQLDBRestResource(Schema.Resources.FindResourceByName(S));
if (DR<>Nil) and (DR<>R) then
begin
ShowMessage(Format(SErrDuplicateResource,[DR.ResourceName]));
S:=R.ResourceName;
end
else
begin
if FCurrentFrame is TSQLDBRestResourceEditFrame then
RemoveCurrentFrame(True);
R.ResourceName:=S;
ShowResourceEditor(R);
end;
end;
procedure TSQLDBRestSchemaEditorFrame.ChangeRestFieldName(F : TSQLDBRestField; Node: TTreeNode; var S: string);
Var
DF : TSQLDBRestField;
begin
DF:=(F.Collection as TSQLDBRestFieldList).FindByPublicName(S);
if (DF<>Nil) and (DF<>F) then
begin
ShowMessage(Format(SErrDuplicateField,[DF.PublicName]));
S:=F.PublicName;
end
else
begin
if FCurrentFrame is TSQLDBRestFieldEditFrame then
RemoveCurrentFrame(True);
F.PublicName:=S;
ShowFieldEditor(F);
end;
end;
procedure TSQLDBRestSchemaEditorFrame.TVResourcesEdited(Sender: TObject; Node: TTreeNode; var S: string);
begin
if TObject(Node.Data) is TMySQLDBRestResource then
ChangeResourceName(TMySQLDBRestResource(Node.Data),Node,S)
else if TObject(Node.Data) is TSQLDBRestField then
ChangeRestFieldName(TSQLDBRestField(Node.Data),Node,S)
end;
procedure TSQLDBRestSchemaEditorFrame.TVResourcesEditing(Sender: TObject; Node: TTreeNode; var AllowEdit: Boolean);
begin
AllowEdit:=(Node.ImageIndex in [idxTable,idxField]);
end;
procedure TSQLDBRestSchemaEditorFrame.Changed;
begin
FModified:=True;
if Assigned(FOnChanged) then
FOnChanged(FSchema);
end;
procedure TSQLDBRestSchemaEditorFrame.DoFieldListChanged(Sender: TObject);
Var
N: TTreeNode;
R : TMySQLDBRestResource;
begin
// Sender is resource.
R:=Sender as TMySQLDBRestResource;
N:=FindResourceNode(R);
if Assigned(N) then
ShowResource(N,R);
end;
function TSQLDBRestSchemaEditorFrame.FindFieldNode(aResource: TSQLDBRestField): TTreeNode;
Var
N : TTreeNode;
begin
N:=TVResources.Items.FindNodeWithData(aResource);
if N.ImageIndex=idxField then
Result:=N
else
Result:=Nil;
end;
function TSQLDBRestSchemaEditorFrame.SelectedResource: TMySQLDBRestResource;
Var
N : TTreeNode;
begin
N:=TVResources.Selected;
While (N<>Nil) and (N.ImageIndex<>idxTable) do
N:=N.Parent;
if Assigned(N) and (TObject(N.Data) is TMySQLDBRestResource) then
Result:=TMySQLDBRestResource(N.Data)
else
Result:=Nil;
end;
function TSQLDBRestSchemaEditorFrame.GetModified: Boolean;
begin
Result:=FModified;
end;
function TSQLDBRestSchemaEditorFrame.SelectedField: TSQLDBRestField;
Var
N : TTreeNode;
begin
N:=TVResources.Selected;
While (N<>Nil) and (N.ImageIndex<>idxField) do
N:=N.Parent;
if Assigned(N) and (TObject(N.Data) is TSQLDBRestField) then
Result:=TSQLDBRestField(N.Data)
else
Result:=Nil;
end;
constructor TSQLDBRestSchemaEditorFrame.Create(aOwner: TComponent);
begin
inherited Create(aOwner);
FSchema:=TMySQLDBRestSchema.Create(Self);
ShowResources;
FImportOpts:=[foInInsert,foInUpdate,foFilter,foOrderBy,foOrderByDesc];
end;
destructor TSQLDBRestSchemaEditorFrame.Destroy;
begin
FreeAndNil(FSchema);
inherited Destroy;
end;
procedure TSQLDBRestSchemaEditorFrame.LoadSession(aStorage: TCustomPropertyStorage);
Var
S : String;
i : Integer;
begin
With aStorage do
begin
PResources.Width:=ReadInteger('ResourceWidth',PResources.Width);
S:=ReadString('ResourceImportFieldOpts','');
if S<>'' then
Try
I:=StringToSet(PTypeInfo(TypeInfo(TRestFieldOptions)),S);
FImportOpts:=TRestFieldOptions(I);
except
On E : EPropertyError do
begin
// Silently Ignore this one
end;
end;
end;
end;
procedure TSQLDBRestSchemaEditorFrame.SaveSession(aStorage: TCustomPropertyStorage);
begin
With aStorage do
begin
WriteInteger('ResourceWidth',PResources.Width);
WriteString('ResourceImportFieldOpts',SetToString(PTypeInfo(TypeInfo(TRestFieldOptions)),Integer(FImportOpts),False));
end;
end;
procedure TSQLDBRestSchemaEditorFrame.ClearSchema;
begin
Schema.Resources.Clear;
ShowResources;
end;
function TSQLDBRestSchemaEditorFrame.CheckSave: Boolean;
begin
Result:=DoCheckSave;
if Result then
Changed;
end;
procedure TSQLDBRestSchemaEditorFrame.LoadFromFile(const aFileName: String);
begin
Schema.LoadFromFile(aFilename);
ShowResources;
FModified:=False;
end;
procedure TSQLDBRestSchemaEditorFrame.SaveToFile(const aFileName: String);
begin
Schema.SaveToFile(aFilename);
FModified:=False;
end;
procedure TSQLDBRestSchemaEditorFrame.ShowRestField(aNode : TTreeNode; aField : TSQLDBRestField);
begin
aNode.DeleteChildren;
aNode.Text:=aField.PublicName;
aNode.ImageIndex:=idxField;
aNode.SelectedIndex:=idxField;
aNode.Data:=aField;
if (foInKey in aField.Options) then
aNode.StateIndex:=idxKeyField;
end;
function TSQLDBRestSchemaEditorFrame.DoCheckSave: Boolean;
begin
Result:=Assigned(FCurrentFrame) and FCurrentFrame.Modified;
if Result then
FCurrentFrame.SaveData;
end;
procedure TSQLDBRestSchemaEditorFrame.ShowResourceFields(aNode : TTreeNode; aResource : TMySQLDBRestResource);
Var
FN,PN : TTreeNode;
F : TSQLDBRestField;
I : Integer;
begin
PN:=aNode.TreeNodes.AddChild(aNode,SFields);
PN.Data:=aResource;
PN.ImageIndex:=idxFields;
PN.SelectedIndex:=idxFields;
For I:=0 to aResource.Fields.Count-1 do
begin
F:=aResource.Fields[i];
FN:=PN.TreeNodes.AddChild(PN,F.PublicName);
ShowRestField(FN,F);
end;
end;
procedure TSQLDBRestSchemaEditorFrame.ShowResource(aNode : TTreeNode; aResource : TMySQLDBRestResource);
Var
N : TTreeNode;
S : String;
begin
aNode.DeleteChildren;
aNode.Text:=aResource.ResourceName;
aNode.ImageIndex:=idxTable;
aNode.SelectedIndex:=idxTable;
aNode.Data:=aResource;
S:=Format(SPropTableName,[aResource.TableName]);
if (aResource.ConnectionName<>'') then
S:=S+', '+Format(SPropConnection,[aResource.ConnectionName]);
N:=aNode.TreeNodes.AddChild(aNode,S);
N.Data:=aResource;
N.ImageIndex:=idxTableInfo;
N.SelectedIndex:=idxTableInfo;
ShowResourceFields(aNode,aResource)
end;
function TSQLDBRestSchemaEditorFrame.AddResourceToTree(Res: TMySQLDBRestResource): TTreeNode;
begin
Result:=TVResources.Items.AddChild(FSchemaNode,Res.ResourceName);
ShowResource(Result,Res);
end;
procedure TSQLDBRestSchemaEditorFrame.ShowResources;
Var
I : integer;
S : String;
begin
if FSchemaNode=Nil then
begin
S:=Schema.Name;
if S='' then
S:=SSchema;
FSchemaNode:=TVResources.Items.AddChild(Nil,SSchema);
FSchemaNode.Data:=Schema;
FSchemaNode.ImageIndex:=idxConnection;
end
else
FSchemaNode.DeleteChildren;
With TVResources.Items do
try
BeginUpdate;
for I:=0 to Schema.Resources.Count-1 do
AddResourceToTree(Schema.Resources[i] as TMySQLDBRestResource);
finally
EndUpdate;
end;
FSchemaNode.Expand(False);
TVResources.Selected:=FSchemaNode;
end;
procedure TSQLDBRestSchemaEditorFrame.AShowConnectionsUpdate(Sender: TObject);
begin
With (Sender as TAction) do
begin
Visible:=Assigned(ConnectionPane);
if Visible then
Enabled:=not ConnectionPane.Visible;
end;
end;
procedure TSQLDBRestSchemaEditorFrame.AShowConnectionsExecute(Sender: TObject);
begin
if Assigned(ConnectionPane) then
ConnectionPane.Visible:=True;
end;
procedure TSQLDBRestSchemaEditorFrame.AResourceAddExecute(Sender: TObject);
begin
AddResource;
end;
procedure TSQLDBRestSchemaEditorFrame.AAddFieldUpdate(Sender: TObject);
begin
(Sender as TAction).Enabled:=(SelectedResource<>Nil)
end;
procedure TSQLDBRestSchemaEditorFrame.ADeleteFieldExecute(Sender: TObject);
Var
R : TMySQLDBRestResource;
F : TSQLDBRestField;
begin
F:=SelectedField;
R:=SelectedResource;
if Assigned(F) and (QuestionDlg(SDeleteFieldCaption, Format(SDeleteFieldMsg, [F.PublicName,R.ResourceName, LineEnding]),
mtWarning, [mrYes, SYesDelete, mrNo, SNoDoNotDelete], 0) = mrYes) then
DeleteField(F);
end;
procedure TSQLDBRestSchemaEditorFrame.ADeleteFieldUpdate(Sender: TObject);
begin
(Sender as Taction).Enabled:=(SelectedField<>Nil)
end;
procedure TSQLDBRestSchemaEditorFrame.AEditFieldExecute(Sender: TObject);
Var
F : TSQLDBRestField;
begin
F:=SelectedField;
if (F<>Nil) then
ShowFieldDialog(F);
end;
procedure TSQLDBRestSchemaEditorFrame.AEditFieldUpdate(Sender: TObject);
begin
(Sender as TAction).Enabled:=(SelectedField<>Nil);
end;
procedure TSQLDBRestSchemaEditorFrame.AAddFieldExecute(Sender: TObject);
begin
if (SelectedResource<>Nil) then
AddFieldToResource(SelectedResource);
end;
function TSQLDBRestSchemaEditorFrame.AddFieldToResource(aResource: TMySQLDBRestResource): TSQLDBRestField;
Var
N : String;
F : TSQLDBRestField;
PN,FN : TTreeNode;
begin
N:='Field'+IntToStr(aResource.Fields.Count+1);
Repeat
F:=Nil;
// Maybe ask field name ?
If Not InputQuery(SNewField,Format(SNameForField,[aResource.ResourceName]),N) then
N:=''
else
begin
F:=aResource.Fields.FindByPublicName(N);
if F<>Nil then
ShowMessage(Format(SErrDuplicateField,[N]));
end;
Until (F=nil) or (N='');
if N='' then
exit;
Result:=aResource.Fields.AddField(N,rftString,FImportOpts);
PN:=FindResourceFieldsNode(aResource);
if Not assigned(PN) then
Raise ESQLDBRest.CreateFmt(0,'Internal error: Cannot find node for fields for resource %s',[aResource.ResourceName]);
FN:=TVResources.Items.AddChild(PN,Result.PublicName);
ShowRestField(FN,Result);
TVResources.Selected:=FN;
Changed;
end;
procedure TSQLDBRestSchemaEditorFrame.AResourceDeleteExecute(Sender: TObject);
Var
R : TMySQLDBRestResource;
begin
R:=SelectedResource;
if Assigned(R) and (QuestionDlg(SDeleteResourceCaption, Format(SDeleteResourceMsg, [R.ResourceName, LineEnding]),
mtWarning, [mrYes, SYesDelete, mrNo, SNoDoNotDelete], 0) = mrYes) then
DeleteResource(R);
end;
procedure TSQLDBRestSchemaEditorFrame.AResourceDeleteUpdate(Sender: TObject);
begin
(Sender as Taction).Enabled:=(SelectedResource<>Nil)
end;
procedure TSQLDBRestSchemaEditorFrame.AResourceEditExecute(Sender: TObject);
Var
R : TMySQLDBRestResource;
begin
R:=SelectedResource;
if (R<>Nil) then
ShowResourceDialog(R);
end;
procedure TSQLDBRestSchemaEditorFrame.AResourceEditUpdate(Sender: TObject);
begin
(Sender as Taction).Enabled:=SelectedResource<>Nil;
end;
function TSQLDBRestSchemaEditorFrame.AddResource: TMySQLDBRestResource;
Var
N : String;
R : TSQLDBRestResource;
begin
N:='Resource'+IntToStr(Schema.Resources.Count+1);
Repeat
R:=Nil;
// Maybe ask table name ?
If Not InputQuery(SNewResource,SNameForResource,N) then
N:=''
else
begin
R:=Schema.Resources.FindResourceByName(N);
if R<>Nil then
ShowMessage(Format(SErrDuplicateResource,[N]));
end;
Until (R=nil) or (N='');
if N='' then
Result:=nil
else
begin
// Maybe check table name ?
Result:=Schema.Resources.AddResource(N,N) as TMySQLDBRestResource;
Changed;
TVResources.Selected:=AddResourceToTree(Result);
TVResources.Selected.Expanded:=True;
end;
end;
procedure TSQLDBRestSchemaEditorFrame.DeleteResource(R: TMySQLDBRestResource);
Var
NCurrent,NNext : TTreeNode;
begin
RemoveCurrentFrame(False);
NCurrent:=FindResourceNode(R);
if Assigned(NCurrent) then
begin
NNext:=NCurrent.GetNextSibling;
if NNext=Nil then
NNext:=NCurrent.GetPrevSibling;
end;
if NNext=Nil then
NNext:=FSchemaNode;
if Assigned(NCurrent) then
TVResources.Items.Delete(NCurrent);
TVResources.Selected:=NNext;
R.Free;
Changed;
end;
procedure TSQLDBRestSchemaEditorFrame.DeleteField(F: TSQLDBRestField);
Var
NCurrent,NNext : TTreeNode;
begin
RemoveCurrentFrame(False);
NCurrent:=FindFieldNode(F);
if Assigned(NCurrent) then
begin
NNext:=NCurrent.GetNextSibling;
if NNext=Nil then
NNext:=NCurrent.GetPrevSibling;
if NNext=Nil then
NNext:=NCurrent.Parent;
end;
if NNext=Nil then
begin
NNext:=TVResources.Selected;
While (NNext<>Nil) and Not(NNext.ImageIndex in [idxFields,idxTable]) do
NNext:=NNext.Parent;
if NNext=Nil then
NNext:=FSchemaNode;
end;
if Assigned(NCurrent) then
TVResources.Items.Delete(NCurrent);
TVResources.Selected:=NNext;
F.Free;
Changed;
end;
end.

View File

@ -0,0 +1,28 @@
object EditFrameForm: TEditFrameForm
Left = 588
Height = 361
Top = 294
Width = 455
Caption = 'Edit '
ClientHeight = 361
ClientWidth = 455
OnCloseQuery = FormCloseQuery
OnShow = FormShow
LCLVersion = '2.1.0.0'
object BPFrame: TButtonPanel
Left = 6
Height = 42
Top = 313
Width = 443
OKButton.Name = 'OKButton'
OKButton.DefaultCaption = True
HelpButton.Name = 'HelpButton'
HelpButton.DefaultCaption = True
CloseButton.Name = 'CloseButton'
CloseButton.DefaultCaption = True
CancelButton.Name = 'CancelButton'
CancelButton.DefaultCaption = True
TabOrder = 0
ShowButtons = [pbOK, pbCancel]
end
end

View File

@ -0,0 +1,58 @@
unit frmeditframedialog;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ButtonPanel, sqldbschemaedittools;
type
{ TEditFrameForm }
TEditFrameForm = class(TForm)
BPFrame: TButtonPanel;
procedure FormCloseQuery(Sender: TObject; var CanClose: boolean);
procedure FormShow(Sender: TObject);
private
FFrame: TBaseEditFrame;
procedure SetEditFrame(AValue: TBaseEditFrame);
public
Property EditFrame : TBaseEditFrame Read FFrame Write SetEditFrame;
end;
var
EditFrameForm: TEditFrameForm;
implementation
{$R *.lfm}
{ TEditFrameForm }
procedure TEditFrameForm.FormCloseQuery(Sender: TObject; var CanClose: boolean);
begin
CanClose:=True;
if (ModalResult=mrOK) then
If EditFrame.Modified then
EditFrame.SaveData;
end;
procedure TEditFrameForm.FormShow(Sender: TObject);
begin
if Assigned(FFrame) then
Caption:=SEdit+' '+FFrame.FrameCaption;
end;
procedure TEditFrameForm.SetEditFrame(AValue: TBaseEditFrame);
begin
if FFrame=AValue then Exit;
FFrame:=AValue;
Self.ClientWidth:=FFrame.Width;
Self.ClientHeight:=FFrame.Height+BPFrame.Height+1;
FFrame.Parent:=Self;
FFrame.Align:=alClient
end;
end.

Binary file not shown.

After

Width:  |  Height:  |  Size: 208 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 437 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 421 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 204 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 338 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 619 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 182 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 297 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 591 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 686 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 295 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 379 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 532 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 522 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 479 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 507 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 201 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 205 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 558 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 289 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 349 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 522 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 501 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 601 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 530 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 528 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 205 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 454 B

View File

@ -0,0 +1,121 @@
<?xml version="1.0" encoding="UTF-8"?>
<CONFIG>
<Package Version="4">
<Name Value="sqldbrestschemadesigner"/>
<Type Value="RunAndDesignTime"/>
<CompilerOptions>
<Version Value="11"/>
<SearchPaths>
<OtherUnitFiles Value="../src"/>
<UnitOutputDirectory Value="lib/$(TargetCPU)-$(TargetOS)"/>
</SearchPaths>
</CompilerOptions>
<Files Count="21">
<Item1>
<Filename Value="dlgrestfieldoptions.lfm"/>
<Type Value="LFM"/>
</Item1>
<Item2>
<Filename Value="dlgrestfieldoptions.pp"/>
<UnitName Value="dlgrestfieldoptions"/>
</Item2>
<Item3>
<Filename Value="dlgsqldbrestconnection.lfm"/>
<Type Value="LFM"/>
</Item3>
<Item4>
<Filename Value="dlgsqldbrestconnection.pp"/>
<UnitName Value="dlgsqldbrestconnection"/>
</Item4>
<Item5>
<Filename Value="fraconnections.lfm"/>
<Type Value="LFM"/>
</Item5>
<Item6>
<Filename Value="fraconnections.pp"/>
<UnitName Value="fraconnections"/>
</Item6>
<Item7>
<Filename Value="fraschematableseditor.lfm"/>
<Type Value="LFM"/>
</Item7>
<Item8>
<Filename Value="fraschematableseditor.pp"/>
<UnitName Value="fraschematableseditor"/>
</Item8>
<Item9>
<Filename Value="frasqldbfullrestschemaaditor.lfm"/>
<Type Value="LFM"/>
</Item9>
<Item10>
<Filename Value="frasqldbfullrestschemaaditor.pp"/>
<UnitName Value="frasqldbfullrestschemaaditor"/>
</Item10>
<Item11>
<Filename Value="frasqldbrestfieldedit.lfm"/>
<Type Value="LFM"/>
</Item11>
<Item12>
<Filename Value="frasqldbrestfieldedit.pp"/>
<UnitName Value="frasqldbrestfieldedit"/>
</Item12>
<Item13>
<Filename Value="frasqldbrestresourceedit.lfm"/>
<Type Value="LFM"/>
</Item13>
<Item14>
<Filename Value="frasqldbrestresourceedit.pp"/>
<UnitName Value="frasqldbrestresourceedit"/>
</Item14>
<Item15>
<Filename Value="frasqldbrestschemaeditor.lfm"/>
<Type Value="LFM"/>
</Item15>
<Item16>
<Filename Value="frasqldbrestschemaeditor.pp"/>
<UnitName Value="fraSQLDBRestSchemaEditor"/>
</Item16>
<Item17>
<Filename Value="frmeditframedialog.lfm"/>
<Type Value="LFM"/>
</Item17>
<Item18>
<Filename Value="frmeditframedialog.pp"/>
<UnitName Value="frmeditframedialog"/>
</Item18>
<Item19>
<Filename Value="sqldbschemaedittools.pp"/>
<UnitName Value="sqldbschemaedittools"/>
</Item19>
<Item20>
<Filename Value="frasqldbresourcefields.pp"/>
<UnitName Value="frasqldbresourcefields"/>
</Item20>
<Item21>
<Filename Value="sqldbschemaedittools.lfm"/>
<Type Value="LFM"/>
</Item21>
</Files>
<RequiredPkgs Count="3">
<Item1>
<PackageName Value="SynEdit"/>
</Item1>
<Item2>
<PackageName Value="LCL"/>
</Item2>
<Item3>
<PackageName Value="FCL"/>
</Item3>
</RequiredPkgs>
<UsageOptions>
<UnitPath Value="$(PkgOutDir)"/>
</UsageOptions>
<PublishOptions>
<Version Value="2"/>
<UseFileFilters Value="True"/>
</PublishOptions>
<CustomOptions Items="ExternHelp" Version="2">
<_ExternHelp Items="Count"/>
</CustomOptions>
</Package>
</CONFIG>

View File

@ -0,0 +1,23 @@
{ This file was automatically created by Lazarus. Do not edit!
This source is only used to compile and install the package.
}
unit sqldbrestschemadesigner;
{$warn 5023 off : no warning about unused units}
interface
uses
dlgrestfieldoptions, dlgsqldbrestconnection, fraconnections, fraschematableseditor, frasqldbfullrestschemaaditor,
frasqldbrestfieldedit, frasqldbrestresourceedit, fraSQLDBRestSchemaEditor, frmeditframedialog, sqldbschemaedittools,
frasqldbresourcefields, LazarusPackageIntf;
implementation
procedure Register;
begin
end;
initialization
RegisterPackage('sqldbrestschemadesigner', @Register);
end.

View File

@ -0,0 +1,9 @@
object BaseEditFrame: TBaseEditFrame
Left = 0
Height = 240
Top = 0
Width = 320
TabOrder = 0
DesignLeft = 568
DesignTop = 388
end

View File

@ -0,0 +1,266 @@
unit sqldbschemaedittools;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, sqldbrestschema, sqldbrestbridge, sqldb, controls, forms;
Const
// Index in imagelist.
idxConnection = 0;
idxConnectionAdd = 1;
idxConnectionDelete = 2;
idxConnectionEdit = 3;
idxConnectionExpose = 4;
idxConnectionRefresh = 5;
idxTable = 6;
idxTableAdd = 7;
idxTableDelete = 8;
idxTableEdit = 9;
idxField = 10;
idxFields = 11;
idxFieldAdd = 12;
idxFieldDelete = 13;
idxFieldEdit = 14;
idxKeyField = 15;
idxConnectionsHide = 16;
idxConnectionsShow = 17;
idxTableInfo = 18;
Type
TOnGetSQLConnection = Procedure (Sender : TObject; aConnName : String; Out aConn : TSQLConnection) of object;
{ TBaseEditFrame }
TBaseEditFrame = Class(TFrame)
private
FConnections: TSQLDBRestConnectionList;
FFrameData: TObject;
FMinFieldOptions: TRestFieldOptions;
Procedure DoSetFrameData(aData : TObject);
Protected
Procedure SetFrameData(aData : TObject); virtual; abstract;
Function CanGetSQLConnection : Boolean;
Function GetSQLConnection(Const aName : String) : TSQLConnection;
Function ExecuteSelect(const aConnection : String; aSQL : String) : TSQLQuery;
procedure SetConnections(AValue: TSQLDBRestConnectionList); virtual;
Public
Function Modified : Boolean; virtual; abstract;
Procedure SaveData; virtual; abstract;
Function FrameCaption : String; virtual; abstract;
// Must be set !
Property FrameData : TObject Read FFrameData Write DoSetFrameData;
Property Connections : TSQLDBRestConnectionList Read FConnections Write SetConnections;
Property MinFieldOptions : TRestFieldOptions Read FMinFieldOptions Write FMinFieldOptions;
end;
{ TStringsDragObject }
TStringsDragObject = Class(TDragObjectEx)
private
FItems: Tstrings; // to keep the items in.
procedure SetItems(const AValue: Tstrings);
Public
Constructor Create(AControl : TControl); override;
Destructor Destroy; override;
// Objects contain TMySQLDBRestConnection instance
Property Items : TStrings Read FItems Write SetItems;
end;
TMySQLDBRestResource = class(TSQLDBRestResource)
end;
{ TMySQLDBRestSchema }
TMySQLDBRestSchema = Class(TSQLDBRestSchema)
Protected
Function CreateResourceList: TSQLDBRestResourceList; override;
end;
{ TMySQLDBRestConnection }
TMySQLDBRestConnection = Class(TSQLDBRestConnection)
private
FMyConnection: TSQLConnection;
FMyTransaction : TSQLTransaction;
function getMyConnection: TSQLConnection;
Public
Destructor Destroy; override;
Procedure CreateConnection;
Property MyConnection : TSQLConnection read getMyConnection Write FMyConnection;
end;
{$r *.lfm}
Resourcestring
SSchema = 'Schema';
SFields = 'Fields';
SField = 'Field';
SResource = 'Resource';
SEdit = 'Edit';
SPropTableName = 'Table name: %s';
SPropConnection = 'Connection: %s';
SErrNoConnection = 'Cannot execute SQL: no connection available';
SSQLValidatesOK = 'SQL Statement validates OK!';
SNameForResource = 'Give a name for the new resource';
SNewResource = 'New resource';
SNameForField = 'Give a name for the new field for resource %s';
SNewField = 'New field';
SErrDuplicateResource = 'Duplicate resource name: %s';
SErrDuplicateField = 'Duplicate field name: %s';
SDeleteResourceCaption = 'Delete resource';
SDeleteResourceMsg = 'Delete resource %s ?%sThis action cannot be undone';
SDeleteFieldCaption = 'Delete Field';
SDeleteFieldMsg = 'Delete field %s from resource %s ?%sThis action cannot be undone';
SYesDelete = 'Yes, delete';
SNoDoNotDelete = 'No, do not delete';
SUnknownObject = 'Unknown';
SEditObject = '%s %s';
SSelectResource = 'Select a resource';
SResetFields = 'Reset fields';
SResetFieldsPrompt = 'There are already fields defined for this resource. %sThis action will remove the existing fields. %sAre '
+'you sure you want to reset the field list ?';
SYesResetFields = 'Reset fields';
SDoNotResetFields = 'Do not reset fields';
STableNameChanged = 'The table name changed, and a default SQL statement is used.%sDo you want to regenerate the field list '
+'based on the current table name ?';
SEditObjectFields = 'Fields of resource %s';
SErrConnectingTo = 'Error connecting to connection %s : %s';
SErrShowingTablesConnectingTo = 'Error connecting to connection %s trying to show the table list: %s';
implementation
{ TBaseEditFrame }
procedure TBaseEditFrame.SetConnections(AValue: TSQLDBRestConnectionList);
begin
if FConnections=AValue then Exit;
FConnections:=AValue;
end;
procedure TBaseEditFrame.DoSetFrameData(aData: TObject);
begin
FFrameData:=aData;
SetFrameData(FFrameData);
end;
function TBaseEditFrame.CanGetSQLConnection: Boolean;
begin
Result:=Assigned(FConnections)
end;
function TBaseEditFrame.GetSQLConnection(const aName: String): TSQLConnection;
Var
C : TSQLDBRestConnection;
begin
Result:=nil;
if Not CanGetSQLConnection then
exit;
if (aName<>'') then
C:=Connections.FindConnection(aName)
else if (Connections.Count=1) then
C:=Connections[0];
if C<>Nil then
begin
Result:=C.SingleConnection;
if Result=Nil then
begin
Result:=TSQLConnector.Create(Self.Owner);
Result.Transaction:=TSQLTransaction.Create(Self.Owner);
Result.Transaction.DataBase:=Result;
C.ConfigConnection(Result);
C.SingleConnection:=Result;
end;
end;
end;
function TBaseEditFrame.ExecuteSelect(const aConnection: String; aSQL: String): TSQLQuery;
Var
C : TSQLConnection;
begin
C:=GetSQLConnection(aConnection);
if C=Nil then
Raise ESQLDatabaseError.Create(SErrNoConnection);
Result:=TSQLQuery.Create(Self);
try
Result.SQLConnection:=C;
if Result.Transaction=Nil then
begin
Result.Transaction:=TSQLTransaction.Create(C);
Result.Transaction.DataBase:=C;
end;
Result.SQL.Text:=aSQL;
Result.PacketRecords:=1;
Result.ParseSQL:=True;
Result.UniDirectional:=True;
Result.Open;
except
Result.Free;
Raise;
end;
end;
{ TStringsDragObject }
procedure TStringsDragObject.SetItems(const AValue: Tstrings);
begin
if FItems=AValue then exit;
FItems.Assign(AValue);
end;
constructor TStringsDragObject.Create(AControl: TControl);
begin
inherited Create(AControl);
FItems:=TStringList.Create;
end;
destructor TStringsDragObject.Destroy;
begin
FreeAndNil(FItems);
inherited Destroy;
end;
{ TMySQLDBRestSchema }
function TMySQLDBRestSchema.CreateResourceList: TSQLDBRestResourceList;
begin
Result:=TSQLDBRestResourceList.Create(Self,TMySQLDBRestResource);
end;
{ TMySQLDBRestConnection }
function TMySQLDBRestConnection.getMyConnection: TSQLConnection;
begin
Result:=FMyConnection;
if (FMyConnection=Nil) then
Result:=SingleConnection;
end;
destructor TMySQLDBRestConnection.Destroy;
begin
FreeAndNil(FMyTransaction);
FreeAndNil(FMyConnection);
inherited Destroy;
end;
procedure TMySQLDBRestConnection.CreateConnection;
begin
FreeAndNil(FMyConnection);
FMyConnection:=TSQLConnector.Create(Nil);
FMyTransaction:=TSQLTransaction.Create(nil);
FMyConnection.Transaction:=FMyTransaction;
ConfigConnection(FMyConnection);
end;
end.

View File

@ -0,0 +1,742 @@
object MainForm: TMainForm
Left = 515
Height = 456
Top = 285
Width = 755
ActiveControl = fraEditor.fraConn.TVConnections
Caption = 'REST Schema designer'
ClientHeight = 433
ClientWidth = 755
Menu = MMain
OnCloseQuery = FormCloseQuery
OnCreate = FormCreate
Position = poDesktopCenter
SessionProperties = 'Width;Top;Left;Height'
LCLVersion = '2.1.0.0'
inline fraEditor: TSchemaEditorFrame
Height = 433
Width = 755
Align = alClient
ClientHeight = 433
ClientWidth = 755
DesignLeft = 546
DesignTop = 298
inherited fraConn: TfraConnections
Height = 433
Width = 203
Align = alLeft
ClientHeight = 433
ClientWidth = 203
inherited TVConnections: TTreeView
Height = 376
Width = 203
end
inherited ToolBar1: TToolBar
Width = 203
inherited TBSep1: TToolButton
Height = 30
end
inherited ToolButton1: TToolButton
Height = 30
end
end
inherited Label1: TLabel
Width = 203
end
end
inherited splConnection: TSplitter
Height = 433
end
inherited fraSchema: TSQLDBRestSchemaEditorFrame
Left = 208
Height = 433
Width = 547
Align = alClient
ClientHeight = 433
ClientWidth = 547
TabOrder = 2
inherited PResources: TPanel
Height = 433
Width = 170
ClientHeight = 433
ClientWidth = 170
inherited TBResources: TToolBar
Width = 170
EdgeInner = esRaised
EdgeOuter = esLowered
inherited ToolButton1: TToolButton
Height = 30
end
inherited ToolButton2: TToolButton
Height = 30
end
inherited ToolButton4: TToolButton
Left = 1
Top = 30
end
inherited ToolButton5: TToolButton
Left = 31
Top = 30
end
end
inherited TVResources: TTreeView
Height = 376
Width = 170
end
inherited LResources: TLabel
Width = 170
end
end
inherited Splitter1: TSplitter
Left = 170
Height = 433
end
inherited PDock: TPanel
Left = 175
Height = 433
Width = 372
ClientHeight = 433
ClientWidth = 372
inherited LFrame: TLabel
Width = 372
end
end
end
end
object alMain: TActionList
Images = ILMain
left = 10
top = 10
object AFileReadConnections: TAction
Category = 'Connections'
Caption = 'Read connections'
ImageIndex = 2
OnExecute = AFileReadConnectionsExecute
end
object AFileWriteConnections: TAction
Category = 'Connections'
Caption = 'Write Connections'
ImageIndex = 3
OnExecute = AFileWriteConnectionsExecute
end
object ALoadSchema: TAction
Category = 'Schema'
Caption = 'Load schema'
ImageIndex = 1
ShortCut = 16463
end
object ASaveSchema: TAction
Category = 'Schema'
Caption = 'Save schema'
ImageIndex = 0
ShortCut = 16467
end
object ASaveSchemaAs: TAction
Category = 'Schema'
Caption = 'Save schema as'
ImageIndex = 4
end
object ASchemaNew: TAction
Category = 'Schema'
Caption = 'New schema'
ImageIndex = 5
OnExecute = ASchemaNewExecute
ShortCut = 16462
end
object aQuit: TAction
Category = 'File'
Caption = 'Quit'
ImageIndex = 6
OnExecute = aQuitExecute
ShortCut = 16465
end
end
object MMain: TMainMenu
Images = ILMain
left = 39
top = 10
object MenuItem1: TMenuItem
Caption = 'File'
object MenuItem2: TMenuItem
Action = AFileReadConnections
end
object MenuItem3: TMenuItem
Action = AFileWriteConnections
end
object N1: TMenuItem
Caption = '-'
end
object MenuItem7: TMenuItem
Action = ASchemaNew
end
object MenuItem4: TMenuItem
Action = ALoadSchema
end
object MenuItem5: TMenuItem
Action = ASaveSchema
end
object MenuItem6: TMenuItem
Action = ASaveSchemaAs
end
object MenuItem8: TMenuItem
Caption = '-'
end
object MenuItem9: TMenuItem
Action = aQuit
end
end
end
object odConnection: TOpenDialog
Title = 'Read existing connections file'
DefaultExt = '.ini'
Filter = 'INI Files|*.ini|JSON files|*.json'
Options = [ofFileMustExist, ofEnableSizing]
left = 120
top = 352
end
object sdConnection: TSaveDialog
Title = 'Save connection definitions as'
DefaultExt = '.ini'
Filter = 'INI Files|*.ini|JSON files|*.json'
Options = [ofOverwritePrompt, ofPathMustExist, ofEnableSizing]
left = 120
top = 296
end
object IPSMain: TIniPropStorage
StoredValues = <>
Active = False
OnSaveProperties = IPSMainSaveProperties
OnRestoreProperties = IPSMainRestoreProperties
left = 432
top = 139
end
object ILMain: TImageList
Height = 24
Width = 24
left = 423
top = 63
Bitmap = {
4C69070000001800000018000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000DB9834FFDB98
34FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB98
34FFDB9834FFDB9834FFDB9834FFDB9834FFDB98337700000000000000000000
0000000000000000000000000000000000000000000000000000DB9834FFDB98
34FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB98
34FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB973480000000000000
0000000000000000000000000000000000000000000000000000DB9834FFDB98
34FF000000000000000000000000000000000000000000000000000000000000
00000000000000000000DB9834FFDB9834FFDB9834FFDB9834FFDB9833770000
0000000000000000000000000000000000000000000000000000DB9834FFDB98
34FF000000000000000000000000000000000000000000000000000000000000
00000000000000000000DB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB97
3480000000000000000000000000000000000000000000000000DB9834FFDB98
34FF000000000000000000000000000000000000000000000000000000000000
00000000000000000000DB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB98
34FF000000000000000000000000000000000000000000000000DB9834FFDB98
34FF000000000000000000000000000000000000000000000000000000000000
00000000000000000000DB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB98
34FF000000000000000000000000000000000000000000000000DB9834FFDB98
34FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB98
34FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB98
34FF000000000000000000000000000000000000000000000000DB9834FFDB98
34FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB98
34FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB98
34FF000000000000000000000000000000000000000000000000DB9834FFDB98
34FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB98
34FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB98
34FF000000000000000000000000000000000000000000000000DB9834FFDB98
34FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB98
34FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB98
34FF000000000000000000000000000000000000000000000000DB9834FFDB98
34FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834F9DB983377DE94311FDE94
311FDB993378DB9834FADB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB98
34FF000000000000000000000000000000000000000000000000DB9834FFDB98
34FFDB9834FFDB9834FFDB9834FFDB9834FFDB98337700000000000000000000
000000000000DB983579DB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB98
34FF000000000000000000000000000000000000000000000000DB9834FFDB98
34FFDB9834FFDB9834FFDB9834FFDB9834FFDF95351800000000000000000000
000000000000D6993319DB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB98
34FF000000000000000000000000000000000000000000000000DB9834FFDB98
34FFDB9834FFDB9834FFDB9834FFDB9834FFDF95351800000000000000000000
000000000000D893311ADB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB98
34FF000000000000000000000000000000000000000000000000DB9834FFDB98
34FFDB9834FFDB9834FFDB9834FFDB9834FFDB98337700000000000000000000
000000000000DB983579DB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB98
34FF000000000000000000000000000000000000000000000000DB9834FFDB98
34FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834F9DB983377DB9E3115DB9E
3115DB993378DB9834FADB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB98
34FF000000000000000000000000000000000000000000000000DB9834FFDB98
34FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB98
34FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB98
34FF000000000000000000000000000000000000000000000000DB9834FFDB98
34FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB98
34FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB98
34FF000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000DB98
34FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB98
34FFDB9834FFDB98337700000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000DB98
34FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB98
34FFDB9834D7DB9834FFDB983377000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000DB98
34FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB98
34FFDB9E3115DB9834D3DB9834FFDB9734800000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000DB98
34FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB98
34FF00000000DC972E16DB9833D5DB9834FFDB97348000000000000000000000
000000000000000000000000000000000000000000000000000000000000DB98
34FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB98
34FF0000000000000000DE9B3717DB9934D6DB9834FFDB973480000000000000
000000000000000000000000000000000000000000000000000000000000DB98
34FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB98
34FF000000000000000000000000DB9B371CDB9834DCDB9834FFDB9734800000
000000000000000000000000000000000000000000000000000000000000DB98
34FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB98
34FF00000000000000000000000000000000DB993323DB9834E3DB9834FF0000
000000000000000000000000000000000000000000000000000000000000DB98
34FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB98
34FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FF0000
000000000000000000000000000000000000000000000000000000000000DB98
34FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB98
34FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FF0000
000000000000000000000000000000000000000000000000000000000000DB98
34FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB98
34FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FF0000
000000000000000000000000000000000000000000000000000000000000DB98
34FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB98
34FFDB9834FFDB9834FFDB9834E3DB99347ADD9A3535E1962D11E1962D110000
000000000000000000000000000000000000000000000000000000000000DB98
34FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB98
34FFDB9834FFDB9834ABDB92370E000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000DB98
34FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB98
34FFDB9833A4FF80000200000000DA983552DB9834C1DB9835EEDB9835EEDB98
34C1DC973651000000000000000000000000000000000000000000000000DB98
34FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDC98
34E6D5952B0C00000000DB99347FDB9834FFDB9834FFDB9834FFDB9834FFDB98
34FFDB9834FFDB98357E0000000000000000000000000000000000000000DB98
34FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB99
347A00000000DA99334BDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB98
34FFDB9834FFDB9834FFDD98344A00000000000000000000000000000000DB98
34FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDD99
332D00000000DB9734C0DB9834FFDB9834FFDB9834FFDB983588DB983588DB98
34FFDB9834FFDB9834FFDB9834BF00000000000000000000000000000000DB98
34FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFE699
330A00000000DB9834F3DB9834FFDB9834FFDB9734800000000000000000DB97
3480DB9834FFDB9834FFDB9834F200000000000000000000000000000000DB98
34FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDF9F
400800000000DB9834F3DB9834FFDB9835880000000000000000000000000000
0000DB983588DB9834FFDB9834F200000000000000000000000000000000DB98
34FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDE96
322E00000000DB9734C0DB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB98
34FFDB9834FFDB9834FFDB9834BF00000000000000000000000000000000DB98
34FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB99
347A00000000DA99334BDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB98
34FFDB9834FFDB9834FFDD98344A000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
00000000000000000000DB99347FDB9834FFDB9834FFDB9834FFDB9834FFDB98
34FFDB9834FFDB98357E00000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000DA983552DB9834C1DB9834F7DB9834F7DB98
34C1DC9736510000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000E1962D11DB9934A2000000000000
0000000000000000000000000000000000000000000000000000DB9834FFDB98
34FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB98
34FF000000000000000000000000DB98354DDC9834E6DB9834FF000000000000
0000000000000000000000000000000000000000000000000000DB9834FFDB98
34FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB98
34FF000000000000000000000000DC98345EDB9835EEDB9834FF000000000000
0000000000000000000000000000000000000000000000000000DB9834FFDB98
34FF0000000000000000DB9834FFDB9834FF0000000000000000000000000000
000000000000000000000000000000000000D893311ADB9833B3000000000000
0000000000000000000000000000000000000000000000000000DB9834FFDB98
34FF0000000000000000DB9834FFDB9834FF0000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000DB9834FFDB98
34FFDB9834FFDB9834FFDB9834FFDB9834FF0000000000000000DB9834FFDB98
34FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB98
34FF000000000000000000000000000000000000000000000000DB9834FFDB98
34FFDB9834FFDB9834FFDB9834FFDB9834FF0000000000000000DB9834FFDB98
34FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB98
34FF000000000000000000000000000000000000000000000000DB9834FFDB98
34FF0000000000000000DB9834FFDB9834FF0000000000000000DB9834FFDB98
34FF0000000000000000DB9834FFDB9834FF0000000000000000DB9834FFDB98
34FF000000000000000000000000000000000000000000000000DB9834FFDB98
34FF0000000000000000DB9834FFDB9834FF0000000000000000DB9834FFDB98
34FF0000000000000000DB9834FFDB9834FF0000000000000000DB9834FFDB98
34FF000000000000000000000000000000000000000000000000DB9834FFDB98
34FFDB9834FFDB9834FFDB9834FFDB9834FF0000000000000000DB9834FFDB98
34FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB98
34FF000000000000000000000000000000000000000000000000DB9834FFDB98
34FFDB9834FFDB9834FFDB9834FFDB9834FF0000000000000000DB9834FFDB98
34FFDB9834FFDB9834FFDB9834FFDB9934ACCC9933050000000000000000DB98
34FF000000000000000000000000000000000000000000000000DB9834FFDB98
34FF0000000000000000DB9834FFDB9834FF0000000000000000DB9834FFDB98
34FF0000000000000000DB9834A8BF804004000000000000000000000000DB98
34FF000000000000000000000000000000000000000000000000DB9834FFDB98
34FF0000000000000000DB9834FFDB9834FF0000000000000000DB9834FFDB98
34FF0000000000000000FFAA550300000000DB9833770000000000000000DB98
34FF000000000000000000000000000000000000000000000000DB9834FFDB98
34FFDB9834FFDB9834FFDB9834FFDB9834FF0000000000000000DB9834FFDB98
34FFDB9934ACCC99330500000000DB973480DB9834FF0000000000000000DC96
3233000000000000000000000000000000000000000000000000DB9834FFDB98
34FFDB9834FFDB9834FFDB9834FFDB9834FF0000000000000000DB9834FFDC98
339FFFAA550300000000DB973480DB9834FFDB9834FF00000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000DB9834FFFFAA
550300000000DB983377DB9834FFDB9834FFDB9834FFDB9834FFDC9834E6DB98
34BEDC99335FFFFF000100000000000000000000000000000000000000000000
0000DB9834A1E1962D1100000000000000000000000000000000DB9834FFFFAA
550300000000DB983588DB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB98
34FFDB9834FFDA9735A0FFFF0001000000000000000000000000000000000000
0000DB9834FFDB9734EADB993355000000000000000000000000DB9834FFDC98
34ADCC99330500000000DB983588DB9834FFDB9834FF00000000D6993319DC97
3565DB9834F2DB9834FFDA983561000000000000000000000000000000000000
0000DB9834FFDB9835EEDB97345D000000000000000000000000DB9834FFDB98
34FFDB9934A2FF80000200000000DB983588DB9834FF00000000000000000000
0000DC98345EDB9834FFDB9834C8000000000000000000000000000000000000
0000DB9835AADB9E311500000000000000000000000000000000000000000000
000000000000000000000000000000000000DB98358800000000000000000000
0000DF9F3010DB9834FFDB9834F0000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
000000000000DB9834FFDB9834FF000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
000000000000DB9834FFDB9834FF000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000E1962D11DB9934A2000000000000
0000000000000000000000000000000000000000000000000000DB9834FFDB98
34FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB98
34FF000000000000000000000000DB98354DDC9834E6DB9834FF000000000000
0000000000000000000000000000000000000000000000000000DB9834FFDB98
34FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB98
34FF000000000000000000000000DC98345EDB9835EEDB9834FF000000000000
0000000000000000000000000000000000000000000000000000DB9834FFDB98
34FF0000000000000000DB9834FFDB9834FF0000000000000000000000000000
000000000000000000000000000000000000D893311ADB9833B3000000000000
0000000000000000000000000000000000000000000000000000DB9834FFDB98
34FF0000000000000000DB9834FFDB9834FF0000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000DB9834FFDB98
34FFDB9834FFDB9834FFDB9834FFDB9834FF0000000000000000DB9834FFDB98
34FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB98
34FF000000000000000000000000000000000000000000000000DB9834FFDB98
34FFDB9834FFDB9834FFDB9834FFDB9834FF0000000000000000DB9834FFDB98
34FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB98
34FF000000000000000000000000000000000000000000000000DB9834FFDB98
34FF0000000000000000DB9834FFDB9834FF0000000000000000DB9834FFDB98
34FF0000000000000000DB9834FFDB9834FF0000000000000000DB9834FFDB98
34FF000000000000000000000000000000000000000000000000DB9834FFDB98
34FF0000000000000000DB9834FFDB9834FF0000000000000000DB9834FFDB98
34FF0000000000000000DB9834FFDB9834FF0000000000000000DB9834FFDB98
34FF000000000000000000000000000000000000000000000000DB9834FFDB98
34FFDB9834FFDB9834FFDB9834FFDB9834FF0000000000000000DB9834FFDB98
34FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB98
34FF000000000000000000000000000000000000000000000000DB9834FFDB98
34FFDB9834FFDB9834FFDB9834FFDB9834FF0000000000000000DB9834FFDB98
34FFDB9834FFDB9834FFDB9834E3DC993373DD99332DE1962D11D893311ADD99
333C000000000000000000000000000000000000000000000000DB9834FFDB98
34FF0000000000000000DB9834FFDB9834FF0000000000000000DB9834FFDB98
34FF0000000000000000D1A22E0B000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000DB9834FFDB98
34FF0000000000000000DB9834FFDB9834FF0000000000000000DB9834FFDB98
34FF000000000000000000000000DA973453DC9835C2DB9835EEDB9835EEDB98
34C1DA9835520000000000000000000000000000000000000000DB9834FFDB98
34FFDB9834FFDB9834FFDB9834FFDB9834FF0000000000000000DB9834FFDB98
34E7DF9F301000000000DB98348FDB9834FFDB9834FFDB9834FFDB9834FFDB98
34FFDB9834FFDA98338B00000000000000000000000000000000DB9834FFDB98
34FFDB9834FFDB9834FFDB9834FFDB9834FF0000000000000000DB9834FFDA98
337C00000000DA973453DB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB98
34F2DB9734EADB9834FFDC993350000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000DB9834FFDE96
322E00000000DC9835C2DB9834FFDB9835E9DB9834F2DB9834FFDB9834F1DC9A
353ADC97342CDB9835E9DB9834BF000000000000000000000000000000000000
0000DB9834A1E1962D1100000000000000000000000000000000DB9834FFE38E
390900000000DB9834F3DB9835E9DB9A352BDC97343BDB9834E3DB9836390000
0000D89B3621DB9834E1DB9834F1000000000000000000000000000000000000
0000DB9834FFDB9734E5DA97324C000000000000000000000000DB9834FFE196
2D1100000000DB9834F4DB9834E1D797382000000000DB92240700000000DE94
311FDB9934E0DB9834FFDB9834F2000000000000000000000000000000000000
0000DB9834FFDB9835EEDB97345D000000000000000000000000DB9834FFD997
343600000000DC9835C2DB9834FFDC9833DFDD99331E00000000DD99331EDB98
34DEDB9834FFDB9834FFDB9834BF000000000000000000000000000000000000
0000DB9835AADB9E311500000000000000000000000000000000000000000000
000000000000DB98354DDB9834FFDB9834FFDB9834DCDB983639DB9834DCDB98
34FFDB9834FFDB9834FFDD98344A000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
00000000000000000000DB983381DB9834FFDB9834FFDB9834FFDB9834FFDB98
34FFDB9834FFDB98357E00000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000DA973453DC9835C2DB9834F7DB9834F7DB98
34C1DC9736510000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000DB9834FFDB98
34FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB98
34FFDB9834FFDB9834FFDB9834FFDB9834FFDB98337700000000000000000000
0000000000000000000000000000000000000000000000000000DB9834FFDB98
34FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB98
34FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB973480000000000000
0000000000000000000000000000000000000000000000000000DB9834FFDB98
34FF000000000000000000000000000000000000000000000000000000000000
00000000000000000000DB9834FFDB9834FFDB9834FFDB9834FFDB9833770000
0000000000000000000000000000000000000000000000000000DB9834FFDB98
34FF000000000000000000000000000000000000000000000000000000000000
00000000000000000000DB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB97
3480000000000000000000000000000000000000000000000000DB9834FFDB98
34FF000000000000000000000000000000000000000000000000000000000000
00000000000000000000DB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB98
34FF000000000000000000000000000000000000000000000000DB9834FFDB98
34FF000000000000000000000000000000000000000000000000000000000000
00000000000000000000DB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB98
34FF000000000000000000000000000000000000000000000000DB9834FFDB98
34FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB98
34FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB98
34FF000000000000000000000000000000000000000000000000DB9834FFDB98
34FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB98
34FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB98
34FF000000000000000000000000000000000000000000000000DB9834FFDB98
34FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB98
34FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB98
34FF000000000000000000000000000000000000000000000000DB9834FFDB98
34FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB98
34FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB98
34FF000000000000000000000000000000000000000000000000DB9834FFDB98
34FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834F9DB99347ADB9933230000
000000000000000000000000000000000000DA963522DB9934ACDB9834FFDB98
34FF000000000000000000000000000000000000000000000000DB9834FFDB98
34FFDB9834FFDB9834FFDB9834FFDB9834FFDA97347600000000000000000000
00000000000000000000000000000000000000000000FFAA5503DB9735A5DB98
34FF000000000000000000000000000000000000000000000000DB9834FFDB98
34FFDB9834FFDB9834FFDB9834FFDB9834FFDF9F301000000000000000000000
00000000000000000000DB9834FFDB9834FFDB98337700000000FFAA5503DC98
34A6000000000000000000000000000000000000000000000000DB9834FFDB98
34FFDB9834FFDB9834FFDB9834FFDB9834FFE1962D1100000000000000000000
00000000000000000000DB9834FFDB9834FFDB9834FFDB98337700000000FFAA
5503000000000000000000000000000000000000000000000000DB9834FFDB98
34FFDB9834FFDB9834FFDB9834FFDB9834FFDA99347500000000000000000000
00000000000000000000DB983588DB9834FFDB9834FFDB9834FFDB9933780000
0000000000000000000000000000000000000000000000000000DB9834FFDB98
34FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834F9DB983377DF953518D997
391BDB97355BFFAA550300000000DB983588DB9834FFDB9834FFDB9834FFDB99
3378000000000000000000000000000000000000000000000000DB9834FFDB98
34FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB98
34FFDB9834FFDC9834ADCC99330500000000DB983377DB9834FFDB9834FFDB98
34FFDC9934890000000000000000000000000000000000000000DB9834FFDB98
34FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB98
34FFDB9834FFDB9834FFDB9834A1FF80000200000000DB973587DB9834FFDB98
34FFDC9835C2D5952B0C00000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000DA973476DC97
34BBD997391BDB9834CDDB973485000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000D89D
3B0DDA9834C3DB9834FFDB983588000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000DB99347ADB97348000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000DB98
34FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB98
34FFDB9834FFDB98337700000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000DB98
34FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB98
34FFDB9934E0DB9834FFDB983377000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000DB98
34FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB98
34FFDB9B371CDB9934DBDB9834FFDB9734800000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000DB98
34FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB98
34FF00000000DB9B371CDB9834DCDB9834FFDB97348000000000000000000000
000000000000000000000000000000000000000000000000000000000000DB98
34FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB98
34FF0000000000000000DC95351DDB9834DCDB9834FFDB973480000000000000
000000000000000000000000000000000000000000000000000000000000DB98
34FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB98
34FF000000000000000000000000DC95351DDB9834DDDB9834FFDB9734800000
000000000000000000000000000000000000000000000000000000000000DB98
34FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB98
34FF00000000000000000000000000000000DC953224DB9834E3DB9834FF0000
000000000000000000000000000000000000000000000000000000000000DB98
34FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB98
34FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FF0000
000000000000000000000000000000000000000000000000000000000000DB98
34FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB98
34FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FF0000
000000000000000000000000000000000000000000000000000000000000DB98
34FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB98
34FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FF0000
000000000000000000000000000000000000000000000000000000000000DB98
34FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB98
34FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FF0000
000000000000000000000000000000000000000000000000000000000000DB98
34FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB98
34FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FF0000
000000000000000000000000000000000000000000000000000000000000DB98
34FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB98
34FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FF0000
000000000000000000000000000000000000000000000000000000000000DB98
34FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB98
34FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FF0000
000000000000000000000000000000000000000000000000000000000000DB98
34FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB98
34FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FF0000
000000000000000000000000000000000000000000000000000000000000DB98
34FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB98
34FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FF0000
000000000000000000000000000000000000000000000000000000000000DB98
34FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB98
34FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FF0000
000000000000000000000000000000000000000000000000000000000000DB98
34FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB98
34FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FF0000
000000000000000000000000000000000000000000000000000000000000DB98
34FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB98
34FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FF0000
000000000000000000000000000000000000000000000000000000000000DB98
34FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB98
34FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FF0000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000DB9834FFDB98
34FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB98
34FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB98
34FF000000000000000000000000000000000000000000000000DB9834FFDB98
34FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB98
34FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB98
34FF000000000000000000000000000000000000000000000000DB9834FFDB98
34FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB98
34FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB98
34FF000000000000000000000000000000000000000000000000DB9834FFDB98
34FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB98
34FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB98
34FF000000000000000000000000000000000000000000000000DB9834FFDB98
34FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB98
34FFDB9834FFDB9834FFDB9834FFDC983497DB9734EADB9834FFDB9834FFDB98
34FF000000000000000000000000000000000000000000000000DB9834FFDB98
34FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB98
34FFDB9834FFDB9834FFDB98349400000000DC97342CDB9835E9DB9834FFDB98
34FF000000000000000000000000000000000000000000000000DB9834FFDB98
34FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB98
34FFDB9834FFDB9834FFDB9834EFDC96323300000000DD983725DB9833E4DB98
34FF000000000000000000000000000000000000000000000000DB9834FFDB98
34FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB98
34FFDB9834FFDB9834FFDB9834FFDB9834EBDD99332D00000000DD983725DB98
33E4000000000000000000000000000000000000000000000000DB9834FFDB98
34FFDB9834FFDB9834FFDB9834FFDB9834FF0000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000DA95
3229000000000000000000000000000000000000000000000000DB9834FFDB98
34FFDB9834FFDB9834FFDB9834FFDB9834FF0000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000DA95
3229000000000000000000000000000000000000000000000000DB9834FFDB98
34FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB98
34FFDB9834FFDB9834FFDB9834FFDB9834EBDA9A353000000000DB98372ADB98
34E8000000000000000000000000000000000000000000000000DB9834FFDB98
34FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB98
34FFDB9834FFDB9834FFDB9734E5D896342700000000DD983634DB9834EFDB98
34FF000000000000000000000000000000000000000000000000DB9834FFDB98
34FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB98
34FFDB9834FFDB9834FFDB98339500000000DC97342CDB9835E9DB9834FFDB98
34FF000000000000000000000000000000000000000000000000DB9834FFDB98
34FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB98
34FFDB9834FFDB9834FFDB9834FFDC983497DB9734EADB9834FFDB9834FFDB98
34FF000000000000000000000000000000000000000000000000DB9834FFDB98
34FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB98
34FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB98
34FF000000000000000000000000000000000000000000000000DB9834FFDB98
34FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB98
34FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB98
34FF000000000000000000000000000000000000000000000000DB9834FFDB98
34FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB98
34FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB98
34FF000000000000000000000000000000000000000000000000DB9834FFDB98
34FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB98
34FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB9834FFDB98
34FF000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000
}
end
object SDSchema: TSaveDialog
Title = 'Save schema to file'
DefaultExt = '.srs'
Filter = 'SQLDB Rest Schema files|*.srs|All files|*.*'
Options = [ofOverwritePrompt, ofPathMustExist, ofEnableSizing]
left = 43
top = 293
end
object ODSchema: TOpenDialog
Title = 'Open existing schema file'
DefaultExt = '.srs'
Filter = 'SQLDB Rest Schema files|*.srs|All files|*.*'
Options = [ofFileMustExist, ofEnableSizing]
left = 40
top = 352
end
end

View File

@ -0,0 +1,237 @@
unit frmMain;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ExtCtrls, ComCtrls,
ActnList, Menus, IniPropStorage, frasqldbfullrestschemaaditor;
type
{ TMainForm }
TMainForm = class(TForm)
aQuit: TAction;
ASchemaNew: TAction;
ASaveSchemaAs: TAction;
ASaveSchema: TAction;
ALoadSchema: TAction;
AFileWriteConnections: TAction;
AFileReadConnections: TAction;
alMain: TActionList;
ILMain: TImageList;
IPSMain: TIniPropStorage;
MenuItem1: TMenuItem;
MenuItem2: TMenuItem;
MenuItem3: TMenuItem;
MenuItem4: TMenuItem;
MenuItem5: TMenuItem;
MenuItem6: TMenuItem;
MenuItem7: TMenuItem;
MenuItem8: TMenuItem;
MenuItem9: TMenuItem;
N1: TMenuItem;
MMain: TMainMenu;
fraEditor: TSchemaEditorFrame;
odConnection: TOpenDialog;
ODSchema: TOpenDialog;
SDSchema: TSaveDialog;
sdConnection: TSaveDialog;
TreeView1: TTreeView;
procedure AFileReadConnectionsExecute(Sender: TObject);
procedure AFileWriteConnectionsExecute(Sender: TObject);
procedure aQuitExecute(Sender: TObject);
procedure ASchemaNewExecute(Sender: TObject);
procedure FormCloseQuery(Sender: TObject; var CanClose: boolean);
procedure FormCreate(Sender: TObject);
procedure IPSMainRestoreProperties(Sender: TObject);
procedure IPSMainSaveProperties(Sender: TObject);
private
FBaseCaption,
FFileName : String;
procedure DoSchemaChanged(Sender: TObject);
function SaveSchema : Boolean;
function SaveSchemaAs : Boolean;
function LoadSchema : Boolean;
Function CheckSave : Boolean;
Procedure LoadSchemaFile(const aFileName : String);
Procedure SaveSchemaFile(const aFileName : String);
Procedure SetCaption;
public
end;
var
MainForm: TMainForm;
implementation
{$R *.lfm}
uses sqldbrestbridge, sqldbrestini;
resourcestring
SSchemaChanged = 'Schema changed';
SSchemaChangedSave = 'The schema has changed. %sDo you wish to save your changes?';
SSaveSchema = 'Save schema';
SDoNotSaveSchema = 'Do not save schema';
SCancel = 'Cancel';
SNewFile = 'New schema';
{ TMainForm }
procedure TMainForm.AFileReadConnectionsExecute(Sender: TObject);
begin
With ODConnection do
if Execute then
fraEditor.LoadConnections(FileName);
end;
procedure TMainForm.AFileWriteConnectionsExecute(Sender: TObject);
begin
With SDConnection do
if Execute then
fraEditor.SaveConnections(FileName);
end;
procedure TMainForm.aQuitExecute(Sender: TObject);
begin
Close
end;
function TMainForm.SaveSchema : Boolean;
begin
if FFileName='' then
Result:=SaveSchemaAs
else
begin
SaveSchemaFile(FFileName);
Result:=True;
end;
end;
procedure TMainForm.DoSchemaChanged(Sender: TObject);
begin
SetCaption;
end;
function TMainForm.SaveSchemaAs : Boolean;
begin
with SDSchema do
begin
FileName:=Self.FFileName;
Result:=Execute;
if Result then
begin
fraEditor.SaveSchema(FileName);
Self.FFileName:=FileName;
SetCaption;
end;
end;
end;
function TMainForm.LoadSchema: Boolean;
begin
Result:= CheckSave;
if not Result then
exit;
with ODSchema do
begin
Result:=Execute;
if Result then
LoadSchemaFile(FileName);
end;
end;
function TMainForm.CheckSave: Boolean;
begin
Result:=Not fraEditor.SchemaModified;
if Result then
exit;
case QuestionDlg(SSchemaChanged, Format(SSchemaChangedSave, [LineEnding]), mtWarning, [mrYes, SSaveSchema, mrNo,
SDoNotSaveSchema, mrCancel, SCancel], 0) of
mrYes: Result:=SaveSchema;
mrNo: Result:=True;
mrCancel: Result:=False;
end;
end;
procedure TMainForm.LoadSchemaFile(const aFileName: String);
begin
fraEditor.LoadSchema(aFileName);
FFileName:=aFileName;
SetCaption;
end;
procedure TMainForm.SaveSchemaFile(const aFileName: String);
begin
FraEditor.SaveSchema(aFileName);
FFileName:=aFileName;
SetCaption;
end;
procedure TMainForm.SetCaption;
Var
S : String;
begin
S:=FFileName;
If (S='') then
S:=SNewFile;
if fraEditor.SchemaModified then
S:=S+'*';
Caption:=FBaseCaption+' ['+S+']';
end;
procedure TMainForm.ASchemaNewExecute(Sender: TObject);
begin
if CheckSave then
fraEditor.ClearSchema;
end;
procedure TMainForm.FormCloseQuery(Sender: TObject; var CanClose: boolean);
begin
CanClose:=CheckSave;
end;
procedure TMainForm.FormCreate(Sender: TObject);
Var
FN : String;
begin
FBaseCaption:=Caption;
FN:=GetAppConfigFile(False,False);
IPSMain.IniFileName:=FN;
IPSMain.Active:=True;
IPSMain.Restore;
fraEditor.OnSchemaChanged:=@DoSchemaChanged;
if Application.HasOption('c','connections') then
fraEditor.LoadConnections(Application.GetOptionValue('c','connections'));
if Application.HasOption('s','schema') then
LoadSchemaFile(Application.GetOptionValue('s','schema'))
else
SetCaption;
end;
procedure TMainForm.IPSMainRestoreProperties(Sender: TObject);
begin
fraEditor.LoadSession(IPSMain);
end;
procedure TMainForm.IPSMainSaveProperties(Sender: TObject);
begin
fraEditor.SaveSession(IPSMain);
end;
end.

View File

@ -0,0 +1,75 @@
unit schemaconns;
// Connections to be included
{$DEFINE HASIBCONNECTION}
{$DEFINE HASMYSQL50CONNECTION}
{$DEFINE HASMYSQL55CONNECTION}
{$DEFINE HASMYSQL4CONNECTION}
{$DEFINE HASPQCONNECTION}
{$DEFINE HASSQLITE3CONNECTION}
{$IF (FPC_FULLVERSION>30302) or not defined(win64)}
{$DEFINE HASORACLECONNECTION}
{$ENDIF}
{$IF FPC_FULLVERSION >= 20601}
// MS SQL Server and Sybase ASE connectors were introduced in the FPC 2.7 development branch,
// and backported to 2.6.1. Operating systems should match FPC packages\fcl-db\fpmake.pp
{$IF DEFINED(BEOS) OR DEFINED(HAIKU) OR DEFINED(LINUX) OR DEFINED(FREEBSD) OR DEFINED (NETBSD) OR DEFINED(OPENBSD) OR DEFINED(WIN32) OR DEFINED(WIN64)}
{$DEFINE HASMSSQLCONNECTION}
{$DEFINE HASSYBASECONNECTION}
{$ENDIF}
{$ENDIF}
{$IF FPC_FULLVERSION >= 20603}
{$DEFINE HASMYSQL56CONNECTION}
{$ENDIF}
{$IF FPC_FULLVERSION >= 20701}
{$DEFINE HASMYSQL57CONNECTION}
{$ENDIF}
{$mode objfpc}{$H+}
interface
uses
{$IFDEF HASIBCONNECTION}
ibconnection,
{$ENDIF}
{$IFDEF HASMSSQLCONNECTION}
// mssqlconn provide both MS SQL Server and Sybase ASE connectors.
mssqlconn,
{$ENDIF}
odbcconn,
{$IFDEF HASPQCONNECTION}
pqconnection,
{$ENDIF}
{$IFDEF HASORACLECONNECTION}
oracleconnection,
{$ENDIF}
{$IFDEF HASMYSQL4CONNECTION}
mysql40conn, mysql41conn,
{$ENDIF}
{$IFDEF HASMYSQL50CONNECTION}
mysql50conn,
mysql51conn,
{$ENDIF}
{$IFDEF HASMYSQL55CONNECTION}
mysql55conn,
{$ENDIF}
{$IFDEF HASMYSQL56CONNECTION}
mysql56conn,
{$ENDIF}
{$IFDEF HASMYSQL57CONNECTION}
mysql57conn,
{$ENDIF}
{$IFDEF HASSQLITE3CONNECTION}
sqlite3conn,
{$ENDIF}
sqldb;
implementation
end.

Binary file not shown.

After

Width:  |  Height:  |  Size: 134 KiB

View File

@ -0,0 +1,95 @@
<?xml version="1.0" encoding="UTF-8"?>
<CONFIG>
<ProjectOptions>
<Version Value="11"/>
<General>
<Flags>
<SaveClosedFiles Value="False"/>
<SaveOnlyProjectUnits Value="True"/>
<SaveJumpHistory Value="False"/>
<SaveFoldState Value="False"/>
</Flags>
<SessionStorage Value="InProjectDir"/>
<MainUnit Value="0"/>
<Title Value="schemaeditor"/>
<Scaled Value="True"/>
<ResourceType Value="res"/>
<UseXPManifest Value="True"/>
<XPManifest>
<DpiAware Value="True"/>
</XPManifest>
<Icon Value="0"/>
</General>
<BuildModes Count="1">
<Item1 Name="Default" Default="True"/>
</BuildModes>
<PublishOptions>
<Version Value="2"/>
<UseFileFilters Value="True"/>
</PublishOptions>
<RunParams>
<FormatVersion Value="2"/>
<Modes Count="0"/>
</RunParams>
<RequiredPackages Count="3">
<Item1>
<PackageName Value="sqldbrestschemadesigner"/>
</Item1>
<Item2>
<PackageName Value="SynEdit"/>
</Item2>
<Item3>
<PackageName Value="LCL"/>
</Item3>
</RequiredPackages>
<Units Count="3">
<Unit0>
<Filename Value="schemaeditor.lpr"/>
<IsPartOfProject Value="True"/>
</Unit0>
<Unit1>
<Filename Value="frmmain.pp"/>
<IsPartOfProject Value="True"/>
<ComponentName Value="MainForm"/>
<HasResources Value="True"/>
<ResourceBaseClass Value="Form"/>
<UnitName Value="frmMain"/>
</Unit1>
<Unit2>
<Filename Value="schemaconns.pp"/>
<IsPartOfProject Value="True"/>
</Unit2>
</Units>
</ProjectOptions>
<CompilerOptions>
<Version Value="11"/>
<Target>
<Filename Value="schemaeditor"/>
</Target>
<SearchPaths>
<IncludeFiles Value="$(ProjOutDir)"/>
<OtherUnitFiles Value="../src"/>
<UnitOutputDirectory Value="lib/$(TargetCPU)-$(TargetOS)"/>
</SearchPaths>
<Linking>
<Options>
<Win32>
<GraphicApplication Value="True"/>
</Win32>
</Options>
</Linking>
</CompilerOptions>
<Debugging>
<Exceptions Count="3">
<Item1>
<Name Value="EAbort"/>
</Item1>
<Item2>
<Name Value="ECodetoolError"/>
</Item2>
<Item3>
<Name Value="EFOpenError"/>
</Item3>
</Exceptions>
</Debugging>
</CONFIG>

View File

@ -0,0 +1,21 @@
program schemaeditor;
{$mode objfpc}{$H+}
uses
{$IFDEF UNIX}{$IFDEF UseCThreads}
cthreads,
{$ENDIF}{$ENDIF}
Interfaces, // this includes the LCL widgetset
Forms, frmMain, schemaconns;
{$R *.res}
begin
RequireDerivedFormResource:=True;
Application.Scaled:=True;
Application.Initialize;
Application.CreateForm(TMainForm, MainForm);
Application.Run;
end.

Binary file not shown.