You've already forked lazarus-ccr
tvplanit: Add cancel button to FieldMapping editor
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@5027 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -59,6 +59,7 @@ type
|
||||
public
|
||||
VPField: string;
|
||||
DBField: string;
|
||||
procedure Assign(Source: TPersistent); override;
|
||||
end;
|
||||
|
||||
{ The TVpDataSources class is simply for clustering the FlexDataStore's }
|
||||
@ -203,6 +204,18 @@ implementation
|
||||
uses
|
||||
{$IFDEF VERSION6} Variants, {$ELSE} FileCtrl, {$ENDIF} VpConst;
|
||||
|
||||
{*****************************************************************************}
|
||||
{ TVpFieldMapping }
|
||||
|
||||
procedure TVpFieldMapping.Assign(Source: TPersistent);
|
||||
begin
|
||||
if Source is TVpFieldMapping then begin
|
||||
VPField := TVpFieldMapping(Source).VPField;
|
||||
DBField := TVpFieldMapping(Source).DBField;
|
||||
end else
|
||||
inherited Assign(Source);
|
||||
end;
|
||||
|
||||
(*****************************************************************************)
|
||||
{ TVpFlexDataStore }
|
||||
|
||||
|
@ -22,15 +22,24 @@ object frmFieldMapper: TfrmFieldMapper
|
||||
ClientHeight = 45
|
||||
ClientWidth = 409
|
||||
TabOrder = 1
|
||||
object BtnClose: TButton
|
||||
Left = 325
|
||||
object BtnOK: TButton
|
||||
Left = 240
|
||||
Height = 25
|
||||
Top = 8
|
||||
Width = 75
|
||||
Caption = 'Close'
|
||||
OnClick = BtnCloseClick
|
||||
Caption = 'OK'
|
||||
ModalResult = 1
|
||||
TabOrder = 0
|
||||
end
|
||||
object BtnCancel: TButton
|
||||
Left = 320
|
||||
Height = 25
|
||||
Top = 8
|
||||
Width = 75
|
||||
Caption = 'Cancel'
|
||||
ModalResult = 2
|
||||
TabOrder = 1
|
||||
end
|
||||
end
|
||||
object PageControl1: TPageControl
|
||||
Left = 0
|
||||
|
@ -52,8 +52,9 @@ type
|
||||
{ TfrmFieldMapper }
|
||||
|
||||
TfrmFieldMapper = class(TForm)
|
||||
BtnCancel: TButton;
|
||||
Panel1: TPanel;
|
||||
BtnClose: TButton;
|
||||
BtnOK: TButton;
|
||||
PageControl1: TPageControl;
|
||||
TabSheet1: TTabSheet;
|
||||
Bevel1: TBevel;
|
||||
@ -75,7 +76,6 @@ type
|
||||
procedure VpFieldSelected(Sender: TObject);
|
||||
procedure VPFieldLBKeyPress(Sender: TObject; var Key: Char);
|
||||
procedure btnAddMappingClick(Sender: TObject);
|
||||
procedure BtnCloseClick(Sender: TObject);
|
||||
procedure Button5Click(Sender: TObject);
|
||||
procedure btnDeleteMappingClick(Sender: TObject);
|
||||
procedure btnClearMappingsClick(Sender: TObject);
|
||||
@ -168,9 +168,24 @@ procedure MapDatabaseFields(Designer: IFormDesigner;
|
||||
{$ENDIF}{$ENDIF}
|
||||
var
|
||||
frmFieldMapper: TfrmFieldMapper;
|
||||
savedResourceMappings: TCollection;
|
||||
savedContactMappings: TCollection;
|
||||
savedEventMappings: TCollection;
|
||||
savedTaskMappings: TCollection;
|
||||
begin
|
||||
if FlexDS = nil then
|
||||
Exit;
|
||||
|
||||
savedResourceMappings := TCollection.Create(TVpFieldMapping);
|
||||
savedContactMappings := TCollection.Create(TVpFieldMapping);
|
||||
savedEventMappings := TCollection.Create(TVpFieldMapping);
|
||||
savedTaskMappings := TCollection.Create(TVpFieldMapping);
|
||||
try
|
||||
savedResourceMappings.Assign(FlexDS.ResourceMappings);
|
||||
savedContactMappings.Assign(FlexDS.ContactMappings);
|
||||
savedEventMappings.Assign(FlexDS.EventMappings);
|
||||
savedTaskMappings.Assign(FlexDS.TaskMappings);
|
||||
|
||||
Application.CreateForm(TfrmFieldMapper, frmFieldMapper);
|
||||
try
|
||||
frmFieldMapper.FlexDS := FlexDS;
|
||||
@ -182,11 +197,23 @@ begin
|
||||
frmFieldMapper.ContactsDS := FlexDS.ContactsDataSource.DataSet;
|
||||
if FlexDS.TasksDataSource <> nil then
|
||||
frmFieldMapper.TasksDS := FlexDS.TasksDataSource.DataSet;
|
||||
frmFieldMapper.ShowModal;
|
||||
if frmFieldMapper.ShowModal <> mrOK then begin
|
||||
FlexDS.ResourceMappings.Assign(savedResourceMappings);
|
||||
FlexDS.ContactMappings.Assign(savedContactMappings);
|
||||
FlexDS.EventMappings.Assign(savedEventMappings);
|
||||
FlexDS.TaskMappings.Assign(savedTaskMappings);
|
||||
end;
|
||||
finally
|
||||
frmFieldMapper.Release;
|
||||
end;
|
||||
Designer.Modified;
|
||||
|
||||
finally
|
||||
savedResourceMappings.Free;
|
||||
savedContactMappings.Free;
|
||||
savedEventMappings.Free;
|
||||
savedTaskMappings.Free;
|
||||
end;
|
||||
end;
|
||||
{=====}
|
||||
|
||||
@ -305,7 +332,8 @@ begin
|
||||
Application.MessageBox(PChar('There was an error opening the following '
|
||||
+ 'datasets'#13#10#10 + ErrorStr + #10
|
||||
+ 'Field mapping for these tables will not be available until the '
|
||||
+ 'errors are corrected.'), 'Error Opening Dataset(s)', 0);
|
||||
+ 'errors are corrected. Any previously assigned mappings will be kept.'),
|
||||
'Error Opening Dataset(s)', 0);
|
||||
end;
|
||||
{=====}
|
||||
|
||||
@ -329,7 +357,8 @@ begin
|
||||
lblFieldMappings.Left := FieldMappingsLB.Left;
|
||||
btnDeleteMapping.Left := ClientWidth - DatasetFieldLB.Left - btnDeleteMapping.Width;
|
||||
btnClearMappings.Left := btnDeleteMapping.Left;
|
||||
btnClose.Left := w - DatasetFieldLB.Width - btnClose.Width;
|
||||
BtnCancel.Left := w - DatasetFieldLB.Width - BtnCancel.Width;
|
||||
BtnOK.Left := BtnCancel.Left - DELTA - BtnOK.Width;
|
||||
end;
|
||||
lblVPFieldsAvail.Left := RightOf(VPFieldLB) - GetLabelWidth(lblVPFieldsAvail);
|
||||
end;
|
||||
@ -557,12 +586,6 @@ begin
|
||||
end;
|
||||
{=====}
|
||||
|
||||
procedure TfrmFieldMapper.BtnCloseClick(Sender: TObject);
|
||||
begin
|
||||
Close;
|
||||
end;
|
||||
{=====}
|
||||
|
||||
procedure TfrmFieldMapper.Button5Click(Sender: TObject);
|
||||
begin
|
||||
// Help;
|
||||
|
Reference in New Issue
Block a user