Commit 3cf47eb1 authored by Lucio Sandrini's avatar Lucio Sandrini

Implementação de Cadastro de Formulário.

parent 39a85144
...@@ -110,9 +110,6 @@ ...@@ -110,9 +110,6 @@
</Linking> </Linking>
<Other> <Other>
<CustomOptions Value="-dUseCThreads"/> <CustomOptions Value="-dUseCThreads"/>
<OtherDefines Count="1">
<Define0 Value="FullDebugMode"/>
</OtherDefines>
</Other> </Other>
</CompilerOptions> </CompilerOptions>
</Item3> </Item3>
......
...@@ -77,7 +77,7 @@ procedure cxCadastroDefinicaoClasse.rmIncluiObjeto(piField: utField; const piRes ...@@ -77,7 +77,7 @@ procedure cxCadastroDefinicaoClasse.rmIncluiObjeto(piField: utField; const piRes
var lRequestMessage: mxRequestMessage; var lRequestMessage: mxRequestMessage;
lResponseMessage: mxAnswerMessage; lResponseMessage: mxAnswerMessage;
begin begin
lRequestMessage := self.NewRequest('RM_INCLUI_OBJETO', piField); lRequestMessage := self.NewRequest('RM_INCLUIR', piField);
try try
lResponseMessage := self.Session.SendRequest(lRequestMessage); lResponseMessage := self.Session.SendRequest(lRequestMessage);
try try
......
object itCadastrarFormulario: TitCadastrarFormulario object itCadastrarFormulario: TitCadastrarFormulario
Left = 356 Left = 628
Height = 482 Height = 482
Top = 218 Top = 321
Width = 937 Width = 937
ClientHeight = 482 ClientHeight = 482
ClientWidth = 937 ClientWidth = 937
...@@ -134,12 +134,12 @@ object itCadastrarFormulario: TitCadastrarFormulario ...@@ -134,12 +134,12 @@ object itCadastrarFormulario: TitCadastrarFormulario
ClientHeight = 72 ClientHeight = 72
ClientWidth = 948 ClientWidth = 948
TabOrder = 4 TabOrder = 4
object lblCodigo: TLabel object lblForm: TLabel
Left = 232 Left = 177
Height = 18 Height = 18
Top = 16 Top = 16
Width = 157 Width = 85
Caption = 'CÓDIGO DO FORMULÁRIO:' Caption = 'FORMULÁRIO:'
Font.Color = clWindowText Font.Color = clWindowText
Font.Height = -13 Font.Height = -13
Font.Name = 'Trebuchet MS' Font.Name = 'Trebuchet MS'
...@@ -151,8 +151,8 @@ object itCadastrarFormulario: TitCadastrarFormulario ...@@ -151,8 +151,8 @@ object itCadastrarFormulario: TitCadastrarFormulario
Left = 16 Left = 16
Height = 18 Height = 18
Top = 16 Top = 16
Width = 107 Width = 49
Caption = 'NOME DA CLASSE:' Caption = 'CLASSE:'
Font.Color = clWindowText Font.Color = clWindowText
Font.Height = -13 Font.Height = -13
Font.Name = 'Trebuchet MS' Font.Name = 'Trebuchet MS'
...@@ -168,6 +168,63 @@ object itCadastrarFormulario: TitCadastrarFormulario ...@@ -168,6 +168,63 @@ object itCadastrarFormulario: TitCadastrarFormulario
Caption = 'lblNomeClasse' Caption = 'lblNomeClasse'
ParentColor = False ParentColor = False
end end
object cbbForm: TComboBox
Left = 272
Height = 24
Hint = 'Tipo'
Top = 13
Width = 140
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'Trebuchet MS'
ItemHeight = 16
OnSelect = cbbFormSelect
ParentFont = False
Style = csDropDownList
TabOrder = 0
end
object lblNomeForm: TLabel
Left = 467
Height = 18
Top = 16
Width = 145
Caption = 'NOME DO FORMULÁRIO:'
Font.Color = clWindowText
Font.Height = -13
Font.Name = 'Trebuchet MS'
Font.Style = [fsBold]
ParentColor = False
ParentFont = False
end
object edtNome1: TEdit
Left = 632
Height = 23
Top = 13
Width = 140
AutoSize = False
TabOrder = 1
end
object lblCodigoForm: TLabel
Left = 467
Height = 18
Top = 40
Width = 157
Caption = 'CÓDIGO DO FORMULÁRIO:'
Font.Color = clWindowText
Font.Height = -13
Font.Name = 'Trebuchet MS'
Font.Style = [fsBold]
ParentColor = False
ParentFont = False
end
object lblCodigoForm2: TLabel
Left = 632
Height = 15
Top = 40
Width = 80
Caption = 'lblCodigoForm'
ParentColor = False
end
end end
object lstAtributos: TValueListEditor object lstAtributos: TValueListEditor
Left = 634 Left = 634
...@@ -241,7 +298,7 @@ object itCadastrarFormulario: TitCadastrarFormulario ...@@ -241,7 +298,7 @@ object itCadastrarFormulario: TitCadastrarFormulario
object rbNao: TRadioButton object rbNao: TRadioButton
Left = 859 Left = 859
Height = 19 Height = 19
Top = 190 Top = 187
Width = 42 Width = 42
Caption = 'Não' Caption = 'Não'
OnChange = rbNaoChange OnChange = rbNaoChange
...@@ -250,7 +307,7 @@ object itCadastrarFormulario: TitCadastrarFormulario ...@@ -250,7 +307,7 @@ object itCadastrarFormulario: TitCadastrarFormulario
object rbSim: TRadioButton object rbSim: TRadioButton
Left = 813 Left = 813
Height = 19 Height = 19
Top = 190 Top = 187
Width = 40 Width = 40
Caption = 'Sim' Caption = 'Sim'
OnChange = rbSimChange OnChange = rbSimChange
......
...@@ -15,10 +15,15 @@ type ...@@ -15,10 +15,15 @@ type
{ TitCadastrarFormulario } { TitCadastrarFormulario }
TitCadastrarFormulario = class(TForm) TitCadastrarFormulario = class(TForm)
cbbForm: TComboBox;
edtNome: TEdit; edtNome: TEdit;
edtDisplayNome: TEdit; edtDisplayNome: TEdit;
edtNome1: TEdit;
lblCodigoForm: TLabel;
lblCodigoForm2: TLabel;
lblNomeForm: TLabel;
lblNomeClasse: TLabel; lblNomeClasse: TLabel;
lblCodigo: TLabel; lblForm: TLabel;
lblClasseName: TLabel; lblClasseName: TLabel;
lblOrdem: TLabel; lblOrdem: TLabel;
lblObrigatorio: TLabel; lblObrigatorio: TLabel;
...@@ -41,6 +46,7 @@ type ...@@ -41,6 +46,7 @@ type
edtCampo: TEdit; edtCampo: TEdit;
lblNovoCampo: TLabel; lblNovoCampo: TLabel;
btnAdd: TSpeedButton; btnAdd: TSpeedButton;
procedure cbbFormSelect(Sender: TObject);
procedure edtDisplayNomeChange(Sender: TObject); procedure edtDisplayNomeChange(Sender: TObject);
procedure edtNomeChange(Sender: TObject); procedure edtNomeChange(Sender: TObject);
procedure lstAtributosFill(piType: string); procedure lstAtributosFill(piType: string);
...@@ -64,18 +70,20 @@ type ...@@ -64,18 +70,20 @@ type
fUMLClass: IUMLClass; fUMLClass: IUMLClass;
fcxCadastroDefinicaoClasse: cxCadastroDefinicaoClasse; fcxCadastroDefinicaoClasse: cxCadastroDefinicaoClasse;
fClassPackage: IUMLPackage; fClassPackage: IUMLPackage;
fClassCode: string;
fFieldTypeList : utField; fForms: utField;
fFormFields: utField;
fTypesField: utField; fTypesField: utField;
fIdCount: Integer; fIdCount: Integer;
procedure Initialize; procedure Initialize;
procedure SendToInterface(piField: utField); procedure SendToInterface(piField: utField);
procedure AdicionarCampo (piName : string); function AdicionarCampo (piName : string) : TListItem;
public public
Constructor Create(Sender: TComponent; piCadastroClasse: cxCadastroDefinicaoClasse; piUMLClass: IUMLClass); reintroduce; Constructor Create(Sender: TComponent; piCadastroClasse: cxCadastroDefinicaoClasse; piUMLClass: IUMLClass); reintroduce;
property FieldTypeList: utField read fFieldTypeList write fFieldTypeList; property FieldTypeList: utField read fFormFields write fFormFields;
property UMLClass: IUMLClass read fUMLClass write fUMLClass; property UMLClass: IUMLClass read fUMLClass write fUMLClass;
property ClassPackage: IUMLPackage read fClassPackage write fClassPackage; property ClassPackage: IUMLPackage read fClassPackage write fClassPackage;
end; end;
...@@ -109,6 +117,7 @@ begin ...@@ -109,6 +117,7 @@ begin
begin begin
fUMLClass := piUMLClass; fUMLClass := piUMLClass;
lblNomeClasse.Caption := fUMLClass.Name; lblNomeClasse.Caption := fUMLClass.Name;
fClassCode := fUMLClass.GetTaggedValueAsString('DBMappings', 'DBClassMap', 'Cod');
//lblClassIDO.Caption := fUMLClass.GetTaggedValueAsString('DBMappings', 'DBClassMap', 'DBIDO'); //lblClassIDO.Caption := fUMLClass.GetTaggedValueAsString('DBMappings', 'DBClassMap', 'DBIDO');
//lblClasseName.Caption := fUMLClass.GetTaggedValueAsString('DBMappings', 'DBClassMap', 'Table'); //lblClasseName.Caption := fUMLClass.GetTaggedValueAsString('DBMappings', 'DBClassMap', 'Table');
end; end;
...@@ -124,11 +133,16 @@ begin ...@@ -124,11 +133,16 @@ begin
end; end;
procedure TitCadastrarFormulario.Initialize; procedure TitCadastrarFormulario.Initialize;
var lField, lResponseField: utField; var lField, lResponseField, lClassField: utField;
begin begin
lField := utField.Create; fForms := utField.Create;
fFormFields := utField.Create;
lResponseField := utField.Create; lResponseField := utField.Create;
fFieldTypeList := utField.Create;
lField := utField.Create;
lClassField := lField.AddField('Class');
lClassField.AddAttribute('name').AsString := fUMLClass.Name;
lClassField.AddAttribute('code').AsString := fClassCode;
fcxCadastroDefinicaoClasse.rmObtemContexto(lField, lResponseField); fcxCadastroDefinicaoClasse.rmObtemContexto(lField, lResponseField);
SendToInterface(lResponseField); SendToInterface(lResponseField);
...@@ -139,7 +153,7 @@ procedure TitCadastrarFormulario.SendToInterface(piField: utField); ...@@ -139,7 +153,7 @@ procedure TitCadastrarFormulario.SendToInterface(piField: utField);
var var
lFieldItem: utField; lFieldItem: utField;
lEnum: acEnumerator; lEnum: acEnumerator;
lClassCode, lRelationName: string; lRelationName: string;
lClass: acClassTicket; lClass: acClassTicket;
i: Integer; i: Integer;
begin begin
...@@ -153,18 +167,38 @@ begin ...@@ -153,18 +167,38 @@ begin
while not lEnum.EOL do {preenche a comboBox com os tipos de field } while not lEnum.EOL do {preenche a comboBox com os tipos de field }
begin begin
lFieldItem := lEnum.Current as utField; lFieldItem := lEnum.Current as utField;
cbbTipo.AddItem(lFieldItem.Name, Pointer(lFieldItem.AttributeByName('OID').AsInteger)); cbbTipo.AddItem(lFieldItem.Name, Pointer(lFieldItem.AttributeByName('OID').AsInteger));
lEnum.MoveNext;
end;
finally
lEnum.Free;
end;
end;
{preenche a combo box de opes de formulrio da classe}
if piField.HasField('Forms') then
begin
fForms.Assign(piField.FieldByName('Forms'));
lEnum := fForms.ChildFields.GetEnumerator;
try
while not lEnum.EOL do {preenche a comboBox com os tipos de field }
begin
lFieldItem := lEnum.Current as utField;
lFieldItem.Name := lFieldItem.AttributeByName('OID').AsString;
cbbForm.AddItem(lFieldItem.AttributeByName('code').AsString, Pointer(lFieldItem.AttributeByName('OID').AsInteger));
lEnum.MoveNext; lEnum.MoveNext;
end; end;
finally finally
lEnum.Free; lEnum.Free;
end; end;
end; end;
cbbForm.AddItem('Novo', nil);
cbbForm.ItemIndex := 0;
cbbFormSelect(nil);
lClassCode := fUMLClass.GetTaggedValueAsString('DBMappings', 'DBClassMap', 'Cod');
lClass := fUtil.MetaModel.ClassTicketByCode[lClassCode] as acClassTicket; {preenche a listview com os atributos e relaes da classe}
lClass := fUtil.MetaModel.ClassTicketByCode[fClassCode] as acClassTicket;
for i := 0 to lClass.Attributes.Count - 1 do for i := 0 to lClass.Attributes.Count - 1 do
begin begin
...@@ -182,6 +216,8 @@ begin ...@@ -182,6 +216,8 @@ begin
lRelationName := acRelationTicket(lClass.RelationTicketsOut.Objects[i]).OriginPropertyName; lRelationName := acRelationTicket(lClass.RelationTicketsOut.Objects[i]).OriginPropertyName;
if lRelationName <> '' then AdicionarCampo(lRelationName); if lRelationName <> '' then AdicionarCampo(lRelationName);
end; end;
lvCampos.Selected := nil;
end; end;
...@@ -189,7 +225,7 @@ procedure TitCadastrarFormulario.btnSalvarClick(Sender: TObject); ...@@ -189,7 +225,7 @@ procedure TitCadastrarFormulario.btnSalvarClick(Sender: TObject);
begin begin
end; end;
procedure TitCadastrarFormulario.AdicionarCampo (piName : string); function TitCadastrarFormulario.AdicionarCampo (piName : string) : TListItem;
var var
lItem : TListItem; lItem : TListItem;
begin begin
...@@ -198,11 +234,11 @@ begin ...@@ -198,11 +234,11 @@ begin
if lItem = nil then if lItem = nil then
begin begin
fIdCount := fIdCount + 1; fIdCount := fIdCount + 1;
fFieldTypeList.AddField(IntToStr(fIdCount)); fFormFields.AddField(IntToStr(fIdCount));
lItem := lvCampos.Items.Add; lItem := lvCampos.Items.Add;
lItem.Caption := piName; lItem.Caption := piName;
lItem.Checked := True; //lItem.Checked := True;
with lItem.SubItems do with lItem.SubItems do
begin begin
...@@ -212,7 +248,8 @@ begin ...@@ -212,7 +248,8 @@ begin
Add(''); //tipo Add(''); //tipo
end; end;
end end
else raise Exception.Create('Campo ''' + piName + ''' j existe.'); else lvCampos.Selected := lItem;
Result := lItem;
end; end;
procedure TitCadastrarFormulario.btnAddClick(Sender: TObject); procedure TitCadastrarFormulario.btnAddClick(Sender: TObject);
...@@ -279,6 +316,79 @@ begin ...@@ -279,6 +316,79 @@ begin
lvCampos.SetFocus; lvCampos.SetFocus;
end; end;
procedure TitCadastrarFormulario.cbbFormSelect(Sender: TObject);
var
lField, lResponseField, lFieldItem : utField;
lCode, lFieldName, lFormOID, teste: string;
lEnum : acEnumerator;
lItem: TListItem;
lPosition, lIndex, lId : Integer;
begin
if cbbForm.Text = 'Novo' then
begin
if not fForms.HasField('Novo') then
begin
fForms.AddField('Novo');
lField := utField.Create;
lResponseField := utField.Create;
fcxCadastroDefinicaoClasse.rmIncluiObjeto(lField, lResponseField);
cbbForm.Items.Objects[cbbForm.ItemIndex] := Pointer(lResponseField.FieldByName('Form').AttributeByName('OID').AsInteger);
end;
fFormFields := utField.Create;
lblCodigoForm2.Caption := IntToStr(Integer(cbbForm.Items.Objects[cbbForm.ItemIndex]));
end
else
begin
lFormOID := IntToStr(Integer(cbbForm.Items.Objects[cbbForm.ItemIndex]));
lblCodigoForm2.Caption := fForms.FieldByName(lFormOID).AttributeByName('OID').AsString;//lFormOID;
fFormFIelds := utField.Create;
fFormFields.Assign(fForms.FieldByName(lFormOID).FieldByName('Fields'));
lEnum := fFormFields.GetFieldsEnumerator;
try
while not lEnum.EOL do
begin
lFieldItem := lEnum.Current as utField;
teste := lFieldItem.GetXMLString;
if lFieldItem.Name <> 'Field' then Break;
lFieldName := lFieldItem.AttributeByName('name').AsString;
lId := lFieldItem.AttributeByName('id').AsInteger;
if lId > fIdCount then fIdCount := lId;
lItem := AdicionarCampo(lFieldName);
lItem.Checked := True;
lItem.SubItems[__DISPLAY_NAME] := lFieldItem.AttributeByName('displayName').AsString;
lItem.SubItems[__OBRIGATORIO] := lFieldItem.AttributeByName('required').AsString;
lItem.SubItems[__ID] := lFieldItem.AttributeByName('id').AsString;
lItem.SubItems[__TIPO] := lFieldItem.FieldByName('Type').AttributeByName('name').AsString;
//lPosition := lFieldItem.AttributeByName('order').AsInteger;
//lIndex := lItem.Index;
//
//while lIndex > lPosition do
//begin
// lvCampos.MoveUp(lIndex, False);
// lIndex := lIndex - 1;
//end;
//
//while lIndex < lPosition do
//begin
// lvCampos.MoveDown(lIndex, False);
// lIndex := lIndex + 1;
//end;
//
lFieldItem.Name := IntToStr(lId);
//fFormFields.AddField(IntToStr(lId));
//fFormFields.FieldByName(IntToStr(lId)).Assign(lFieldItem);
lEnum.MoveNext;
end;
finally
lEnum.Free;
end;
end;
end;
procedure TitCadastrarFormulario.cbbTipoChange(Sender: TObject); procedure TitCadastrarFormulario.cbbTipoChange(Sender: TObject);
var var
...@@ -286,7 +396,7 @@ var ...@@ -286,7 +396,7 @@ var
begin begin
lvCampos.Selected.SubItems[__TIPO] := cbbTipo.Text; lvCampos.Selected.SubItems[__TIPO] := cbbTipo.Text;
lField := fFieldTypeList.FieldByName(lvCampos.Selected.SubItems[__ID]); lField := fFormFields.FieldByName(lvCampos.Selected.SubItems[__ID]);
if lField.HasField('Type') then if lField.HasField('Type') then
lField.RemoveField(lField.FieldByName('Type')); lField.RemoveField(lField.FieldByName('Type'));
...@@ -318,9 +428,9 @@ begin ...@@ -318,9 +428,9 @@ begin
lAttribute := lFieldItem.Name; lAttribute := lFieldItem.Name;
lValue := ''; lValue := '';
if fFieldTypeList.FieldByName(lvCampos.Selected.SubItems[__ID]).HasField('Type') then if fFormFields.FieldByName(lvCampos.Selected.SubItems[__ID]).HasField('Type') then
begin begin
lTypeField := fFieldTypeList.FieldByName(lvCampos.Selected.SubItems[__ID]).FieldByName('Type'); lTypeField := fFormFields.FieldByName(lvCampos.Selected.SubItems[__ID]).FieldByName('Type');
if lTypeField.HasField(lAttribute) then if lTypeField.HasField(lAttribute) then
lValue := lTypeField.FieldByName(lAttribute).AttributeByName('value').AsString; lValue := lTypeField.FieldByName(lAttribute).AttributeByName('value').AsString;
end; end;
...@@ -368,7 +478,7 @@ var ...@@ -368,7 +478,7 @@ var
if NewValue = '' then if NewValue = '' then
begin begin
lField := fFieldTypeList.FieldByName(lvCampos.Selected.SubItems[__ID]).FieldByName('Type'); lField := fFormFields.FieldByName(lvCampos.Selected.SubItems[__ID]).FieldByName('Type');
if lField.HasField(lKeyName) then if lField.HasField(lKeyName) then
lField.RemoveField(lField.FieldByName(lKeyName)); lField.RemoveField(lField.FieldByName(lKeyName));
Exit; Exit;
...@@ -382,7 +492,7 @@ var ...@@ -382,7 +492,7 @@ var
//caso os dados estejam validos: //caso os dados estejam validos:
lOID := Integer(lstAtributos.Strings.Objects[lstAtributos.Strings.IndexOfName(lKeyName)]); lOID := Integer(lstAtributos.Strings.Objects[lstAtributos.Strings.IndexOfName(lKeyName)]);
lField := fFieldTypeList.FieldByName(lvCampos.Selected.SubItems[__ID]).FieldByName('Type'); lField := fFormFields.FieldByName(lvCampos.Selected.SubItems[__ID]).FieldByName('Type');
if lField.HasField(lKeyName) then if lField.HasField(lKeyName) then
begin begin
lAttributeField := lField.FieldByName(lKeyName); lAttributeField := lField.FieldByName(lKeyName);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment