-
Notifications
You must be signed in to change notification settings - Fork 1
/
untFrmPrincipal.pas
116 lines (99 loc) · 2.42 KB
/
untFrmPrincipal.pas
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
unit untFrmPrincipal;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, untGerador, Clipbrd;
type
TfrmPrincipal = class(TForm)
Label1: TLabel;
edtNome: TEdit;
Label2: TLabel;
Label3: TLabel;
edtJson: TEdit;
Label4: TLabel;
edtComentario: TEdit;
ckbSomenteLeitura: TCheckBox;
btnAdicionar: TButton;
lstPropriedades: TListBox;
memoResult: TMemo;
btnGerar: TButton;
btnLimpar: TButton;
btnClipbrd: TButton;
Label5: TLabel;
edtNomeClasse: TEdit;
cbbDominio: TComboBox;
procedure btnAdicionarClick(Sender: TObject);
procedure btnLimparClick(Sender: TObject);
procedure btnClipbrdClick(Sender: TObject);
procedure btnGerarClick(Sender: TObject);
procedure FormShow(Sender: TObject);
private
gerador: TGerador;
procedure limpaEdits();
procedure limparGerador();
public
procedure novoGerador;
end;
var
frmPrincipal: TfrmPrincipal;
implementation
{$R *.dfm}
{ TForm1 }
procedure TfrmPrincipal.btnAdicionarClick(Sender: TObject);
var
atb: TAtributo;
begin
//adiciona novo atributo
atb := TAtributo.Create;
atb.Nome := edtNome.Text;
atb.Dominio := cbbDominio.Text;
atb.JsonAlias := edtJson.Text;
atb.SomenteLeitura := ckbSomenteLeitura.Checked;
atb.Comentario := edtComentario.Text;
gerador.addAtributo(atb);
lstPropriedades.Items.Add(atb.Nome);
limpaEdits();
edtNome.SetFocus;
end;
procedure TfrmPrincipal.btnClipbrdClick(Sender: TObject);
begin
Clipboard.AsText := memoResult.Lines.Text;
end;
procedure TfrmPrincipal.btnGerarClick(Sender: TObject);
begin
//gera a classe
gerador.Nome := edtNomeClasse.Text;
memoResult.Lines.Text := gerador.montarClasse();
end;
procedure TfrmPrincipal.btnLimparClick(Sender: TObject);
begin
limparGerador();
end;
procedure TfrmPrincipal.FormShow(Sender: TObject);
begin
novoGerador();
edtNomeClasse.SetFocus();
end;
procedure TfrmPrincipal.limpaEdits;
begin
edtNome.Clear;
cbbDominio.ItemIndex := -1;
edtJson.Clear;
edtComentario.Clear;
ckbSomenteLeitura.Checked := False;
end;
procedure TfrmPrincipal.limparGerador;
begin
limpaEdits;
lstPropriedades.Clear;
memoResult.Clear;
edtNomeClasse.Clear;
novoGerador;
end;
procedure TfrmPrincipal.novoGerador;
begin
if (gerador <> nil) then
FreeAndNil(gerador);
gerador := TGerador.Create;
end;
end.