File: dlgeditsqldbrestschema.pp

package info (click to toggle)
lazarus 2.2.6%2Bdfsg2-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 219,980 kB
  • sloc: pascal: 1,944,919; xml: 357,634; makefile: 270,608; cpp: 57,115; sh: 3,249; java: 609; perl: 297; sql: 222; ansic: 137
file content (132 lines) | stat: -rw-r--r-- 3,345 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
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.