Einzelnen Beitrag anzeigen

USchuster

Registriert seit: 12. Sep 2010
Ort: L.E.
120 Beiträge
 
Delphi XE3 Professional
 
#7

AW: OpenToolsAPI - Projektionfos

  Alt 1. Jun 2011, 22:51
Ist zufällig jemand da, der sich mit der OTA auskennt?
Auskennen wer übertrieben

Im Prinzip brauch ich nur recht "schnell" ein paar Tipps, wo man eine Notification herbekommt, wenn ein Projekt geladen wird und wie man an die Projekteinstellungen (Pfade) rankommt.
Nach dem Öffnen eines Projektes landet der Suchpfad der Basiskonfiguration im Meldungsfenster.

Delphi-Quellcode:
unit SimpleNotifierUnit;

interface

procedure Register;

implementation

uses
  SysUtils, ToolsAPI, DCCStrs;

type
  TSimpleNotifier = class(TNotifierObject, IOTAIDENotifier)
  public
    procedure AfterCompile(Succeeded: Boolean);
    procedure BeforeCompile(const Project: IOTAProject; var Cancel: Boolean);
    procedure FileNotification(NotifyCode: TOTAFileNotification;
      const FileName: string; var Cancel: Boolean);
  end;

var
  NotifierIndex: Integer = -1;

procedure Register;
begin
  NotifierIndex := (BorlandIDEServices as IOTAServices).AddNotifier(TSimpleNotifier.Create);
end;

{ TSimpleNotifier }

procedure TSimpleNotifier.AfterCompile(Succeeded: Boolean);
begin
//
end;

procedure TSimpleNotifier.BeforeCompile(const Project: IOTAProject;
  var Cancel: Boolean);
begin
//
end;

procedure TSimpleNotifier.FileNotification(NotifyCode: TOTAFileNotification;
  const FileName: string; var Cancel: Boolean);
var
  ProjModule: IOTAModule;
  Project: IOTAProject;
  BuildConfigs: IOTAProjectOptionsConfigurations;
  EnvOptions: IOTAEnvironmentOptions;
  Config: IOTABuildConfiguration;
  SearchPath, SearchPathConfig, SearchPathLib: string;
begin
  if (NotifyCode = ofnFileOpened) and
    {$IF COMPILERVERSION >= 22.0}
    (BorlandIDEServices as IOTAServices).IsProject(FileName)
    {$ELSE}
    SameText('.dproj', ExtractFileExt(FileName))
    {$IFEND}
  then
  begin
    ProjModule := (BorlandIDEServices as IOTAModuleServices).FindModule(FileName);
    if Supports(ProjModule, IOTAProject, Project) and
      Supports(Project.ProjectOptions, IOTAProjectOptionsConfigurations, BuildConfigs) then
    begin
      Config := BuildConfigs.BaseConfiguration;
      (BorlandIDEServices as IOTAMessageServices).AddTitleMessage(Format('Opened Project %s', [FileName]));
      SearchPathConfig := Config.Value[sUnitSearchPath];
      (BorlandIDEServices as IOTAMessageServices).AddTitleMessage(Format(' Base.SearchPath = %s', [SearchPathConfig]));
      EnvOptions := (BorlandIDEServices as IOTAServices).GetEnvironmentOptions;
      SearchPathLib := EnvOptions.Values['LibraryPath'];
      (BorlandIDEServices as IOTAMessageServices).AddTitleMessage(Format(' EnvironmentOptions.LibraryPath = %s', [SearchPathLib]));
      SearchPath := SearchPathConfig;
      if SearchPathLib <> 'then
      begin
        if SearchPath <> 'then
          SearchPath := SearchPath + ';';
        SearchPath := SearchPath + SearchPathLib;
      end;
      (BorlandIDEServices as IOTAMessageServices).AddTitleMessage(Format(' SearchPath = %s', [SearchPath]));
    end;
  end;
end;

initialization

finalization
  if NotifierIndex <> -1 then
    (BorlandIDEServices as IOTAServices).RemoveNotifier(NotifierIndex);

end.
Schön wäre es auch, wenn man die ToolsAPI.pas wieder kompilieren könnte, ohne rumgeeiere, wie fehlende Suchpfade und die blöde immernoch fehlende Unit DockForm.
Package Designide einbinden und spätestens wenn Du INTA Interfaces benutzen willst musst Du ohnehin mit Packages compilieren.

Ich glaub Emba will um jeden Preis verhindern, daß man Schwächen in der IDE selber ausbessert oder sonstwas darin veranstaltet.
Das schließt Du nochmal wo heraus?
  Mit Zitat antworten Zitat