unit IdeNotifier;
interface
procedure Register;
implementation
uses SysUtils, TypInfo, ToolsApi;
var
NotifierIndex: Integer;
type
TIdeNotifier =
class(TNotifierObject, IOTANotifier, IOTAIDENotifier)
protected
procedure AfterCompile(Succeeded: Boolean);
procedure BeforeCompile(
const Project: IOTAProject;
var Cancel: Boolean);
procedure FileNotification(NotifyCode: TOTAFileNotification;
const FileName:
string;
var Cancel: Boolean);
end;
function VariantToString(V: Variant):
String;
begin
Result := V;
end;
procedure Register;
var
Services: IOTAServices;
begin
Services := BorlandIDEServices
as IOTAServices;
Assert(Assigned(Services), '
IOTAServices not available');
NotifierIndex := Services.AddNotifier(TIdeNotifier.Create);
end;
procedure RemoveNotifier;
var
Services: IOTAServices;
begin
if NotifierIndex <> -1
then
begin
Services := BorlandIDEServices
as IOTAServices;
Assert(Assigned(Services), '
IOTAServices not available');
Services.RemoveNotifier(NotifierIndex);
end;
end;
function MsgServices: IOTAMessageServices;
begin
Result := (BorlandIDEServices
as IOTAMessageServices);
Assert(Result <>
nil, '
IOTAMessageServices not available');
end;
procedure TIdeNotifier.AfterCompile(Succeeded: Boolean);
begin
MsgServices.AddTitleMessage('
After Compile');
MsgServices.AddTitleMessage('
Platform : ' + (BorlandIDEServices
as IOTAModuleServices).GetActiveProject.GetPlatform);
MsgServices.AddTitleMessage('
Configuration : ' + (BorlandIDEServices
as IOTAModuleServices).GetActiveProject.GetConfiguration);
(BorlandIDEServices
as IOTAModuleServices).GetActiveProject.SetPlatform('
Win32');
(BorlandIDEServices
as IOTAModuleServices).GetActiveProject.SetConfiguration('
Debug');
MsgServices.AddTitleMessage('
Release : ' + VariantToString((BorlandIDEServices
as IOTAModuleServices).GetActiveProject.ProjectOptions.Values['
Release']));
MsgServices.AddTitleMessage('
BuildNo : ' + VariantToString((BorlandIDEServices
as IOTAModuleServices).GetActiveProject.ProjectOptions.Values['
Build']));
end;
procedure TIdeNotifier.BeforeCompile(
const Project: IOTAProject;
var Cancel: Boolean);
var
ReleaseNo: Double;
BuildNo: Double;
begin
MsgServices.AddTitleMessage('
Before Compile');
MsgServices.AddTitleMessage('
Platform : ' + Project.GetPlatform);
MsgServices.AddTitleMessage('
Configuration : ' + Project.GetConfiguration);
Project.SetPlatform('
Win32');
Project.SetConfiguration('
Debug');
MsgServices.AddTitleMessage('
Release : ' + VariantToString(Project.ProjectOptions.Values['
Release']));
MsgServices.AddTitleMessage('
BuildNo : ' + VariantToString(Project.ProjectOptions.Values['
Build']));
end;
procedure TIdeNotifier.FileNotification(NotifyCode: TOTAFileNotification;
const FileName:
string;
var Cancel: Boolean);
begin
MsgServices.AddTitleMessage(Format('
%s: %s',
[GetEnumName(TypeInfo(TOTAFIleNotification), Ord(NotifyCode)), FileName]));
end;
initialization
finalization
RemoveNotifier;
end.