You've already forked lazarus-ccr
tvplanit: Use ZConnection in VpZeosDatastore directly (instead of duplicating is properties)
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@4753 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -15,7 +15,7 @@ uses
|
|||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
ZPropertyEditor,
|
ZPropertyEditor,
|
||||||
Classes, Controls, TypInfo;
|
Classes, Controls, TypInfo;
|
||||||
|
(*
|
||||||
type
|
type
|
||||||
{ Implements a property editor for VpZEOSDatastore.Database property. }
|
{ Implements a property editor for VpZEOSDatastore.Database property. }
|
||||||
TVPZeosDatabasePropertyEditor = class(TZDatabasePropertyEditor)
|
TVPZeosDatabasePropertyEditor = class(TZDatabasePropertyEditor)
|
||||||
@ -34,7 +34,7 @@ type
|
|||||||
public
|
public
|
||||||
function GetZComponent: TPersistent; override;
|
function GetZComponent: TPersistent; override;
|
||||||
end;
|
end;
|
||||||
|
*)
|
||||||
|
|
||||||
procedure Register;
|
procedure Register;
|
||||||
|
|
||||||
@ -46,14 +46,15 @@ uses
|
|||||||
procedure Register;
|
procedure Register;
|
||||||
begin
|
begin
|
||||||
RegisterComponents('Visual PlanIt', [TVpZeosDatastore]);
|
RegisterComponents('Visual PlanIt', [TVpZeosDatastore]);
|
||||||
|
(*
|
||||||
RegisterPropertyEditor(TypeInfo(string), TVpZEOSDatastore, 'Protocol', TZProtocolPropertyEditor);
|
RegisterPropertyEditor(TypeInfo(string), TVpZEOSDatastore, 'Protocol', TZProtocolPropertyEditor);
|
||||||
RegisterPropertyEditor(TypeInfo(string), TVpZEOSDatastore, 'Database', TVpZeosDatabasePropertyEditor);
|
RegisterPropertyEditor(TypeInfo(string), TVpZEOSDatastore, 'Database', TVpZeosDatabasePropertyEditor);
|
||||||
RegisterPropertyEditor(TypeInfo(string), TVpZEOSDatastore, 'LibraryLocation', TVpZeosLibLocationPropertyEditor);
|
RegisterPropertyEditor(TypeInfo(string), TVpZEOSDatastore, 'LibraryLocation', TVpZeosLibLocationPropertyEditor);
|
||||||
RegisterPropertyEditor(TypeInfo(string), TVpZEOSDatastore, 'ClientCodepage', TVpZeosClientCodePagePropertyEditor);
|
RegisterPropertyEditor(TypeInfo(string), TVpZEOSDatastore, 'ClientCodepage', TVpZeosClientCodePagePropertyEditor);
|
||||||
|
*)
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
(*
|
||||||
{ TVpZeosDatabasePropertyEditor }
|
{ TVpZeosDatabasePropertyEditor }
|
||||||
|
|
||||||
function TVpZeosDatabasePropertyEditor.GetZComponent: TPersistent;
|
function TVpZeosDatabasePropertyEditor.GetZComponent: TPersistent;
|
||||||
@ -77,6 +78,6 @@ begin
|
|||||||
if (GetComponent(0) is TVpZeosDatastore) then
|
if (GetComponent(0) is TVpZeosDatastore) then
|
||||||
Result := (GetComponent(0) as TVpZeosDatastore).Connection;
|
Result := (GetComponent(0) as TVpZeosDatastore).Connection;
|
||||||
end;
|
end;
|
||||||
|
*)
|
||||||
|
|
||||||
end.
|
end.
|
||||||
|
@ -3,7 +3,7 @@ unit VpZeosDs;
|
|||||||
interface
|
interface
|
||||||
|
|
||||||
uses
|
uses
|
||||||
Classes, DB,
|
SysUtils, Classes, DB,
|
||||||
VpBaseDS, VpDBDS,
|
VpBaseDS, VpDBDS,
|
||||||
ZCompatibility, ZConnection, ZDataset;
|
ZCompatibility, ZConnection, ZDataset;
|
||||||
|
|
||||||
@ -15,26 +15,7 @@ type
|
|||||||
FEventsTable: TZTable;
|
FEventsTable: TZTable;
|
||||||
FResourceTable: TZTable;
|
FResourceTable: TZTable;
|
||||||
FTasksTable: TZTable;
|
FTasksTable: TZTable;
|
||||||
function GetClientCodepage: String;
|
procedure SetConnection(const AValue: TZConnection);
|
||||||
function GetControlsCodePage: TZControlsCodePage;
|
|
||||||
function GetDatabase: String;
|
|
||||||
function GetHostname: String;
|
|
||||||
function GetLibLocation: String;
|
|
||||||
function GetLoginPrompt: Boolean;
|
|
||||||
function GetPassword: String;
|
|
||||||
function GetPort: Integer;
|
|
||||||
function GetProtocol: String;
|
|
||||||
function GetUser: String;
|
|
||||||
procedure SetClientCodepage(const AValue: String);
|
|
||||||
procedure SetControlsCodePage(const AValue: TZControlsCodePage);
|
|
||||||
procedure SetDatabase(const AValue: String);
|
|
||||||
procedure SetHostName(const AValue: String);
|
|
||||||
procedure SetLibLocation(const AValue: String);
|
|
||||||
procedure SetLoginPrompt(const AValue: Boolean);
|
|
||||||
procedure SetPassword(const AValue: String);
|
|
||||||
procedure SetPort(const AValue: Integer);
|
|
||||||
procedure SetProtocol(const AValue: String);
|
|
||||||
procedure SetUser(const AValue: String);
|
|
||||||
|
|
||||||
protected
|
protected
|
||||||
procedure CreateTable(const ATableName: String);
|
procedure CreateTable(const ATableName: String);
|
||||||
@ -44,29 +25,20 @@ type
|
|||||||
function GetResourceTable: TDataset; override;
|
function GetResourceTable: TDataset; override;
|
||||||
function GetTasksTable: TDataset; override;
|
function GetTasksTable: TDataset; override;
|
||||||
procedure Loaded; override;
|
procedure Loaded; override;
|
||||||
|
procedure Notification(AComponent: TComponent; Operation: TOperation); override;
|
||||||
procedure SetConnected(const AValue: Boolean); override;
|
procedure SetConnected(const AValue: Boolean); override;
|
||||||
|
|
||||||
public
|
public
|
||||||
constructor Create(AOwner: TComponent); override;
|
constructor Create(AOwner: TComponent); override;
|
||||||
procedure CreateTables;
|
procedure CreateTables;
|
||||||
|
|
||||||
property Connection: TZConnection read FConnection;
|
|
||||||
property ResourceTable;
|
property ResourceTable;
|
||||||
property EventsTable;
|
property EventsTable;
|
||||||
property ContactsTable;
|
property ContactsTable;
|
||||||
property TasksTable;
|
property TasksTable;
|
||||||
|
|
||||||
published
|
published
|
||||||
property HostName: string read GetHostName write SetHostName;
|
property Connection: TZConnection read FConnection write SetConnection;
|
||||||
property Port: Integer read GetPort write SetPort;
|
|
||||||
property Database: string read GetDatabase write SetDatabase;
|
|
||||||
property User: string read GetUser write SetUser;
|
|
||||||
property Password: string read GetPassword write SetPassword;
|
|
||||||
property Protocol: string read GetProtocol write SetProtocol;
|
|
||||||
property LibraryLocation: string read GetLibLocation write SetLibLocation;
|
|
||||||
property LoginPrompt: Boolean read GetLoginPrompt write SetLoginPrompt;
|
|
||||||
property ControlsCodePage: TZControlsCodepage read GetControlsCodepage write SetControlsCodepage;
|
|
||||||
property ClientCodePage: String read GetClientCodePage write SetClientCodepage;
|
|
||||||
|
|
||||||
// inherited
|
// inherited
|
||||||
property AutoConnect;
|
property AutoConnect;
|
||||||
@ -87,28 +59,22 @@ constructor TVpZeosDatastore.Create(AOwner: TComponent);
|
|||||||
begin
|
begin
|
||||||
inherited;
|
inherited;
|
||||||
|
|
||||||
FConnection := TZConnection.Create(self);
|
|
||||||
|
|
||||||
FContactsTable := TZTable.Create(self);
|
FContactsTable := TZTable.Create(self);
|
||||||
FContactsTable.Connection := FConnection;
|
|
||||||
FContactsTable.TableName := 'Contacts';
|
FContactsTable.TableName := 'Contacts';
|
||||||
|
|
||||||
FEventsTable := TZTable.Create(Self);
|
FEventsTable := TZTable.Create(Self);
|
||||||
FEventsTable.Connection := FConnection;
|
|
||||||
FEventsTable.TableName := 'Events';
|
FEventsTable.TableName := 'Events';
|
||||||
|
|
||||||
FResourceTable := TZTable.Create(self);
|
FResourceTable := TZTable.Create(self);
|
||||||
FResourceTable.Connection := FConnection;
|
|
||||||
FResourceTable.TableName := 'Resources';
|
FResourceTable.TableName := 'Resources';
|
||||||
|
|
||||||
FTasksTable := TZTable.Create(self);
|
FTasksTable := TZTable.Create(self);
|
||||||
FTasksTable.Connection := FConnection;
|
|
||||||
FTasksTable.TableName := 'Tasks';
|
FTasksTable.TableName := 'Tasks';
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TVpZeosDatastore.CreateTables;
|
procedure TVpZeosDatastore.CreateTables;
|
||||||
begin
|
begin
|
||||||
if FileExistsUTF8(Database) then
|
if FileExistsUTF8(FConnection.Database) then
|
||||||
exit;
|
exit;
|
||||||
|
|
||||||
CreateTable(ContactsTableName);
|
CreateTable(ContactsTableName);
|
||||||
@ -245,41 +211,11 @@ begin
|
|||||||
Result := FContactsTable;
|
Result := FContactsTable;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TVpZeosDatastore.GetClientCodePage: string;
|
|
||||||
begin
|
|
||||||
Result := FConnection.ClientCodePage;
|
|
||||||
end;
|
|
||||||
|
|
||||||
function TVpZeosDatastore.GetControlsCodePage: TZControlsCodePage;
|
|
||||||
begin
|
|
||||||
Result := FConnection.ControlsCodePage;
|
|
||||||
end;
|
|
||||||
|
|
||||||
function TVpZeosDatastore.GetDatabase: String;
|
|
||||||
begin
|
|
||||||
Result := FConnection.Database;
|
|
||||||
end;
|
|
||||||
|
|
||||||
function TVpZeosDatastore.GetEventsTable: TDataset;
|
function TVpZeosDatastore.GetEventsTable: TDataset;
|
||||||
begin
|
begin
|
||||||
Result := FEventsTable;
|
Result := FEventsTable;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TVpZeosDatastore.GetHostname: String;
|
|
||||||
begin
|
|
||||||
Result := FConnection.Hostname;
|
|
||||||
end;
|
|
||||||
|
|
||||||
function TVpZeosDatastore.GetLibLocation: String;
|
|
||||||
begin
|
|
||||||
Result := FConnection.LibLocation;
|
|
||||||
end;
|
|
||||||
|
|
||||||
function TVpZeosDatastore.GetLoginPrompt: Boolean;
|
|
||||||
begin
|
|
||||||
Result := FConnection.LoginPrompt;
|
|
||||||
end;
|
|
||||||
|
|
||||||
function TVpZeosDataStore.GetNextID(TableName: string): int64;
|
function TVpZeosDataStore.GetNextID(TableName: string): int64;
|
||||||
begin
|
begin
|
||||||
{ This is not needed in the ZEOS datastore as these tables use
|
{ This is not needed in the ZEOS datastore as these tables use
|
||||||
@ -287,21 +223,6 @@ begin
|
|||||||
result := -1;
|
result := -1;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TVpZeosDatastore.GetPassword: String;
|
|
||||||
begin
|
|
||||||
Result := FConnection.Password;
|
|
||||||
end;
|
|
||||||
|
|
||||||
function TVpZeosDatastore.GetPort: Integer;
|
|
||||||
begin
|
|
||||||
Result := FConnection.Port;
|
|
||||||
end;
|
|
||||||
|
|
||||||
function TVpZeosDatastore.GetProtocol: String;
|
|
||||||
begin
|
|
||||||
Result := FConnection.Protocol;
|
|
||||||
end;
|
|
||||||
|
|
||||||
function TVpZeosDatastore.GetResourceTable : TDataset;
|
function TVpZeosDatastore.GetResourceTable : TDataset;
|
||||||
begin
|
begin
|
||||||
Result := FResourceTable;
|
Result := FResourceTable;
|
||||||
@ -312,11 +233,6 @@ begin
|
|||||||
Result := FTasksTable;
|
Result := FTasksTable;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TVpZeosDatastore.GetUser: String;
|
|
||||||
begin
|
|
||||||
Result := FConnection.User;
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TVpZeosDatastore.Loaded;
|
procedure TVpZeosDatastore.Loaded;
|
||||||
begin
|
begin
|
||||||
inherited;
|
inherited;
|
||||||
@ -324,6 +240,14 @@ begin
|
|||||||
Connected := AutoConnect;
|
Connected := AutoConnect;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TVpZeosDatastore.Notification(AComponent: TComponent;
|
||||||
|
Operation: TOperation);
|
||||||
|
begin
|
||||||
|
inherited Notification(AComponent, Operation);
|
||||||
|
if (Operation = opRemove) and (AComponent = FConnection) then
|
||||||
|
FConnection := nil;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TVpZeosDatastore.SetConnected(const AValue: Boolean);
|
procedure TVpZeosDatastore.SetConnected(const AValue: Boolean);
|
||||||
begin
|
begin
|
||||||
if AValue = Connected then
|
if AValue = Connected then
|
||||||
@ -341,76 +265,29 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
inherited SetConnected(AValue);
|
inherited SetConnected(AValue);
|
||||||
|
|
||||||
|
if FConnection.Connected then
|
||||||
|
Load;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TVpZeosDatastore.SetClientCodePage(const AValue: string);
|
procedure TVpZeosDatastore.SetConnection(const AValue: TZConnection);
|
||||||
|
var
|
||||||
|
wasConnected: Boolean;
|
||||||
begin
|
begin
|
||||||
if AValue = ClientCodePage then exit;
|
if AValue = FConnection then
|
||||||
FConnection.Connected := false;
|
exit;
|
||||||
FConnection.ClientCodePage := AValue;
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TVpZeosDatastore.SetControlsCodePage(const AValue: TZControlsCodePage);
|
// To do: clear planit lists...
|
||||||
begin
|
if FConnection <> nil then begin
|
||||||
if AValue = ControlsCodePage then exit;
|
wasConnected := FConnection.Connected;
|
||||||
FConnection.Connected := false;
|
Connected := false;
|
||||||
FConnection.ControlsCodePage := AValue;
|
|
||||||
end;
|
end;
|
||||||
|
FConnection := AValue;
|
||||||
procedure TVpZeosDatastore.SetDatabase(const AValue: String);
|
FContactsTable.Connection := FConnection;
|
||||||
begin
|
FEventsTable.Connection := FConnection;
|
||||||
if AValue = GetDatabase then exit;
|
FResourceTable.Connection := FConnection;
|
||||||
FConnection.Connected := false;
|
FTasksTable.Connection := FConnection;
|
||||||
FConnection.Database := AValue;
|
if wasConnected then Connected := true;
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TVpZeosDatastore.SetHostName(const AValue: String);
|
|
||||||
begin
|
|
||||||
if AValue = HostName then exit;
|
|
||||||
FConnection.Connected := false;
|
|
||||||
FConnection.HostName := AValue;
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TVpZeosDatastore.SetLibLocation(const AValue: String);
|
|
||||||
begin
|
|
||||||
if AValue = LibraryLocation then exit;
|
|
||||||
FConnection.Connected := false;
|
|
||||||
FConnection.LibraryLocation := AValue;
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TVpZeosDatastore.SetLoginPrompt(const AValue: Boolean);
|
|
||||||
begin
|
|
||||||
if AValue = LoginPrompt then exit;
|
|
||||||
FConnection.Connected := false;
|
|
||||||
FConnection.LoginPrompt := AValue;
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TVpZeosDatastore.SetPassword(const AValue: String);
|
|
||||||
begin
|
|
||||||
if AValue = Password then exit;
|
|
||||||
FConnection.Connected := false;
|
|
||||||
FConnection.Password := AValue;
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TVpZeosDatastore.SetPort(const AValue: Integer);
|
|
||||||
begin
|
|
||||||
if AValue = Port then exit;
|
|
||||||
FConnection.Connected := false;
|
|
||||||
FConnection.Port := AValue;
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TVpZeosDatastore.SetProtocol(const AValue: String);
|
|
||||||
begin
|
|
||||||
if AValue = Protocol then exit;
|
|
||||||
FConnection.Connected := false;
|
|
||||||
FConnection.Protocol := AValue;
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TVpZeosDatastore.SetUser(const AValue: String);
|
|
||||||
begin
|
|
||||||
if AValue = User then exit;
|
|
||||||
FConnection.Connected := false;
|
|
||||||
FConnection.User := AValue;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
end.
|
end.
|
||||||
|
Reference in New Issue
Block a user