-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathGDK.ToolsApi.Notifiers.ProjectStorage.pas
More file actions
81 lines (68 loc) · 2.59 KB
/
GDK.ToolsApi.Notifiers.ProjectStorage.pas
File metadata and controls
81 lines (68 loc) · 2.59 KB
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
unit GDK.ToolsApi.Notifiers.ProjectStorage;
interface
uses
ToolsApi,
GDK.ToolsAPI.Notifiers.Base,
System.SysUtils,
Xml.XMLIntf;
type
TToolsApiProjectStorageNotifier = class(TToolsApiNotifier, IOTAProjectFileStorageNotifier)
private
FNodeName: string;
FOnCreatingProject: TProc<IOTAModule>;
FOnProjectClosing: TProc<IOTAModule>;
FOnProjectLoaded: TProc<IOTAModule, IXMLNode>;
FOnProjectSaving: TProc<IOTAModule, IXMLNode>;
public
constructor Create(const NodeName: string);
/// <summary>
/// This function will return the name of your node in the project file.
/// </summary>
function GetName: string;
/// <summary>
/// Called when a project is loaded and there is a node that matches the
/// result of GetName. You may keep a reference to Node and edit the contents
/// but you must free the reference when ProjectClosing is called.
/// </summary>
procedure ProjectLoaded(const ProjectOrGroup: IOTAModule; const Node: IXMLNode);
procedure CreatingProject(const ProjectOrGroup: IOTAModule);
procedure ProjectSaving(const ProjectOrGroup: IOTAModule; const Node: IXMLNode);
procedure ProjectClosing(const ProjectOrGroup: IOTAModule);
property Name: string read GetName;
property OnCreatingProject: TProc<IOTAModule> write FOnCreatingProject;
property OnProjectClosing: TProc<IOTAModule> write FOnProjectClosing;
property OnProjectLoaded: TProc<IOTAModule, IXMLNode> write FOnProjectLoaded;
property OnProjectSaving: TProc<IOTAModule, IXMLNode> write FOnProjectSaving;
end;
implementation
{ TToolsApiProjectStorageNotifier }
constructor TToolsApiProjectStorageNotifier.Create(const NodeName: string);
begin
inherited Create;
FNodeName := NodeName;
end;
function TToolsApiProjectStorageNotifier.GetName: string;
begin
Result := FNodeName;
end;
procedure TToolsApiProjectStorageNotifier.CreatingProject(const ProjectOrGroup: IOTAModule);
begin
if Assigned(FOnCreatingProject) then
FOnCreatingProject(ProjectOrGroup);
end;
procedure TToolsApiProjectStorageNotifier.ProjectClosing(const ProjectOrGroup: IOTAModule);
begin
if Assigned(FOnProjectClosing) then
FOnProjectClosing(ProjectOrGroup);
end;
procedure TToolsApiProjectStorageNotifier.ProjectLoaded(const ProjectOrGroup: IOTAModule; const Node: IXMLNode);
begin
if Assigned(FOnProjectLoaded) then
FOnProjectLoaded(ProjectOrGroup, Node);
end;
procedure TToolsApiProjectStorageNotifier.ProjectSaving(const ProjectOrGroup: IOTAModule; const Node: IXMLNode);
begin
if Assigned(FOnProjectSaving) then
FOnProjectSaving(ProjectOrGroup, Node);
end;
end.