home *** CD-ROM | disk | FTP | other *** search
- {*******************************************************}
- { }
- { eXpert Development Kit }
- { }
- { Copyright (c) 1996,97 Sergey Orlik }
- { - product manager of Borland Russia }
- { }
- {*******************************************************}
- unit XDKNotif;
-
- interface
- uses
- Windows, SysUtils, Classes, Graphics, Forms,
- DsgnIntf, ExptIntf, EditIntf, FileIntf, ToolIntf, LibIntf;
-
- type
- TxdkFileEventWCancel = procedure (Sender:TObject; const FileName:string; var Cancel:boolean) of object;
- TxdkFileEvent = procedure (Sender:TObject; const FileName:string) of object;
- TxdkEventEvent = procedure (Sender:TObject; var Cancel:boolean) of object;
-
- TxdkAddInNotifier = class;
-
- TxdkINotifier = class(TIAddInNotifier)
- private
- FNotifier : TxdkAddInNotifier;
- public
- constructor Create(ANotifier:TxdkAddInNotifier);
- procedure FileNotification(NotifyCode: TFileNotification;
- const FileName: string; var Cancel: Boolean); override;
- procedure EventNotification(NotifyCode: TEventNotification;
- var Cancel: Boolean); override;
- end;
-
- TxdkAddInNotifier = class(TComponent)
- private
- FINotifier : TxdkINotifier;
- FOnFileOpening : TxdkFileEventWCancel;
- FOnFileOpened : TxdkFileEvent;
- FOnFileClosing : TxdkFileEventWCancel;
- FOnProjectOpening : TxdkFileEventWCancel;
- FOnProjectOpened : TxdkFileEvent;
- FOnProjectClosing : TxdkFileEventWCancel;
- FOnAddedToProject : TxdkFileEventWCancel;
- FOnRemovedFromProject: TxdkFileEventWCancel;
- FOnDefaultDesktopLoad: TxdkFileEvent;
- FOnDefaultDesktopSave: TxdkFileEvent;
- FOnProjectDesktopLoad: TxdkFileEvent;
- FOnProjectDesktopSave: TxdkFileEvent;
- FOnPackageInstalled : TxdkFileEvent;
- FOnPackageUnInstalled: TxdkFileEvent;
- FOnBeforeCompile : TxdkEventEvent;
- FOnAfterCompile : TxdkEventEvent;
- public
- constructor Create(AOwner:TComponent); override;
- destructor Destroy; override;
- procedure Loaded; override;
- published
- property OnFileOpening: TxdkFileEventWCancel read FOnFileOpening write FOnFileOpening;
- property OnFileOpened: TxdkFileEvent read FOnFileOpened write FOnFileOpened;
- property OnFileClosing: TxdkFileEventWCancel read FOnFileClosing write FOnFileClosing;
- property OnProjectOpening: TxdkFileEventWCancel read FOnProjectOpening write FOnProjectOpening;
- property OnProjectOpened: TxdkFileEvent read FOnProjectOpened write FOnProjectOpened;
- property OnProjectClosing: TxdkFileEventWCancel read FOnProjectClosing write FOnProjectClosing;
- property OnAddedToProject: TxdkFileEventWCancel read FOnAddedToProject write FOnAddedToProject;
- property OnRemovedFromProject: TxdkFileEventWCancel read FOnRemovedFromProject write FOnRemovedFromProject;
- property OnDefaultDesktopLoad: TxdkFileEvent read FOnDefaultDesktopLoad write FOnDefaultDesktopLoad;
- property OnDefaultDesktopSave: TxdkFileEvent read FOnDefaultDesktopSave write FOnDefaultDesktopSave;
- property OnProjectDesktopLoad: TxdkFileEvent read FOnProjectDesktopLoad write FOnProjectDesktopLoad;
- property OnProjectDesktopSave: TxdkFileEvent read FOnProjectDesktopSave write FOnProjectDesktopSave;
- property OnPackageInstalled: TxdkFileEvent read FOnPackageInstalled write FOnPackageInstalled;
- property OnPackageUnInstalled: TxdkFileEvent read FOnPackageUnInstalled write FOnPackageUnInstalled;
- property OnBeforeCompile: TxdkEventEvent read FOnBeforeCompile write FOnBeforeCompile;
- property OnAfterCompile: TxdkEventEvent read FOnAfterCompile write FOnAfterCompile;
- end;
-
- { *** will be implemented in next version ***
- TxdkProjectNotifier = class(TComponent)
-
- end;
-
- TxdkModuleNotifier = class(TComponent)
-
- end;
- }
-
- //================================================================
- implementation
- //================================================================
- // TxdkINotifier
-
- constructor TxdkINotifier.Create(ANotifier:TxdkAddInNotifier);
- begin
- inherited Create;
- FNotifier:=ANotifier;
- end;
-
- procedure TxdkINotifier.FileNotification(NotifyCode: TFileNotification;
- const FileName: string; var Cancel: Boolean);
- begin
- case NotifyCode of
- fnFileOpening : if Assigned(FNotifier.FOnFileOpening) then
- FNotifier.FOnFileOpening(FNotifier,FileName,Cancel);
- fnFileOpened : if Assigned(FNotifier.FOnFileOpened) then
- FNotifier.FOnFileOpened(FNotifier,FileName);
- fnFileClosing : if Assigned(FNotifier.FOnFileClosing) then
- FNotifier.FOnFileClosing(FNotifier,FileName,Cancel);
- fnProjectOpening : if Assigned(FNotifier.FOnProjectOpening) then
- FNotifier.FOnProjectOpening(FNotifier,FileName,Cancel);
- fnProjectOpened : if Assigned(FNotifier.FOnProjectOpened) then
- FNotifier.FOnProjectOpened(FNotifier,FileName);
- fnProjectClosing : if Assigned(FNotifier.FOnProjectClosing) then
- FNotifier.FOnProjectClosing(FNotifier,FileName,Cancel);
- fnAddedToProject : if Assigned(FNotifier.FOnAddedToProject) then
- FNotifier.FOnAddedToProject(FNotifier,FileName,Cancel);
- fnRemovedFromProject: if Assigned(FNotifier.FOnRemovedFromProject) then
- FNotifier.FOnRemovedFromProject(FNotifier,FileName,Cancel);
- fnDefaultDesktopLoad: if Assigned(FNotifier.FOnDefaultDesktopLoad) then
- FNotifier.FOnDefaultDesktopLoad(FNotifier,FileName);
- fnDefaultDesktopSave: if Assigned(FNotifier.FOnDefaultDesktopSave) then
- FNotifier.FOnDefaultDesktopSave(FNotifier,FileName);
- fnProjectDesktopLoad: if Assigned(FNotifier.FOnProjectDesktopLoad) then
- FNotifier.FOnProjectDesktopLoad(FNotifier,FileName);
- fnprojectDesktopSave: if Assigned(FNotifier.FOnProjectDesktopLoad) then
- FNotifier.FOnProjectDesktopLoad(FNotifier,FileName);
- fnPackageInstalled : if Assigned(FNotifier.FOnPackageInstalled) then
- FNotifier.FOnPackageInstalled(FNotifier,FileName);
- fnPackageUninstalled: if Assigned(FNotifier.FOnPackageUnInstalled) then
- FNotifier.FOnPackageUnInstalled(FNotifier,FileName);
- end;
- end;
-
- procedure TxdkINotifier.EventNotification(NotifyCode: TEventNotification;
- var Cancel: Boolean);
- begin
- case NotifyCode of
- enBeforeCompile : if Assigned(FNotifier.FOnBeforeCompile) then
- FNotifier.FOnBeforeCompile(FNotifier,Cancel);
- enAfterCompile : if Assigned(FNotifier.FOnAfterCompile) then
- FNotifier.FOnAfterCompile(FNotifier,Cancel);
- end;
- end;
-
- //================================================================
- // TxdkAddInNotifier
-
- constructor TxdkAddInNotifier.Create(AOwner:TComponent);
- begin
- inherited Create(AOwner);
- if not (csDesigning in ComponentState) then
- FINotifier:=TxdkINotifier.Create(Self);
- end;
-
- destructor TxdkAddInNotifier.Destroy;
- begin
- if not (csDesigning in ComponentState) then
- begin
- ToolServices.RemoveNotifier(FINotifier);
- FINotifier.Free;
- end;
- inherited Destroy;
- end;
-
- procedure TxdkAddInNotifier.Loaded;
- begin
- inherited Loaded;
- if not (csDesigning in ComponentState) then
- ToolServices.AddNotifierEx(FINotifier)
- end;
-
- //================================================================
-
- end.
-