103 lines
3.4 KiB
ObjectPascal
103 lines
3.4 KiB
ObjectPascal
unit uDAScriptingProvider;
|
|
|
|
{----------------------------------------------------------------------------}
|
|
{ Data Abstract Library - Core Library }
|
|
{ }
|
|
{ compiler: Delphi 6 and up, Kylix 3 and up }
|
|
{ platform: Win32, Linux }
|
|
{ }
|
|
{ (c)opyright RemObjects Software. all rights reserved. }
|
|
{ }
|
|
{ Using this code requires a valid license of the Data Abstract }
|
|
{ which can be obtained at http://www.remobjects.com. }
|
|
{----------------------------------------------------------------------------}
|
|
|
|
{$I DataAbstract.inc}
|
|
|
|
interface
|
|
|
|
uses
|
|
Classes, SysUtils;
|
|
|
|
type
|
|
TScriptableComponent = class;
|
|
TDAScriptingProvider = class(TComponent)
|
|
private
|
|
FScriptableComponent: TScriptableComponent;
|
|
procedure SetScriptableComponent(const Value: TScriptableComponent);
|
|
protected
|
|
procedure Notification(AComponent: TComponent; Operation: TOperation); override;
|
|
published
|
|
property ScriptableComponent: TScriptableComponent read FScriptableComponent write SetScriptableComponent;
|
|
end;
|
|
|
|
IDAScriptingProvider = interface
|
|
['{6D19A2F9-233A-4EE6-95EC-CDFCD7410C15}']
|
|
end;
|
|
|
|
EDAScriptError = class(Exception);
|
|
EDAScriptCompileError = class(EDAScriptError);
|
|
|
|
TScriptableComponent = class(TComponent)
|
|
private
|
|
fScriptingProvider: TDAScriptingProvider;
|
|
procedure SetScriptingProvider(const Value: TDAScriptingProvider);
|
|
protected
|
|
procedure Notification(AComponent: TComponent; Operation: TOperation); override;
|
|
published
|
|
property ScriptingProvider: TDAScriptingProvider read fScriptingProvider write SetScriptingProvider;
|
|
end;
|
|
|
|
|
|
|
|
implementation
|
|
|
|
{ TScriptableComponent }
|
|
|
|
procedure TScriptableComponent.Notification(AComponent: TComponent;
|
|
Operation: TOperation);
|
|
begin
|
|
inherited;
|
|
if (Operation = opRemove) then begin
|
|
if (AComponent = fScriptingProvider) then fScriptingProvider := nil;
|
|
end;
|
|
end;
|
|
|
|
procedure TScriptableComponent.SetScriptingProvider(const Value: TDAScriptingProvider);
|
|
begin
|
|
if fScriptingProvider <> Value then begin
|
|
if fScriptingProvider <> nil then fScriptingProvider.ScriptableComponent:=nil;
|
|
if Value <> nil then Value.ScriptableComponent := Self;
|
|
if Assigned(fScriptingProvider) then fScriptingProvider.FreeNotification(self);
|
|
end;
|
|
end;
|
|
|
|
{ TDAScriptingProvider }
|
|
|
|
procedure TDAScriptingProvider.Notification(AComponent: TComponent;
|
|
Operation: TOperation);
|
|
begin
|
|
inherited;
|
|
if (Operation = opRemove) then begin
|
|
if (AComponent = FScriptableComponent) then FScriptableComponent := nil;
|
|
end;
|
|
end;
|
|
|
|
procedure TDAScriptingProvider.SetScriptableComponent(
|
|
const Value: TScriptableComponent);
|
|
begin
|
|
if FScriptableComponent <> Value then begin
|
|
if FScriptableComponent <> nil then begin
|
|
FScriptableComponent.fScriptingProvider:=nil;
|
|
FScriptableComponent.RemoveFreeNotification(Self);
|
|
end;
|
|
FScriptableComponent := Value;
|
|
if Assigned(FScriptableComponent) then begin
|
|
FScriptableComponent.fScriptingProvider := Self;
|
|
FScriptableComponent.FreeNotification(Self);
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
end.
|