implemented Package Editor -> View package source

git-svn-id: trunk@5940 -
This commit is contained in:
mattias 2004-09-07 14:49:13 +00:00
parent bc8ccb5975
commit 0a089d1218
3 changed files with 38 additions and 1 deletions

View File

@ -2270,6 +2270,7 @@ resourcestring
lisPckEditRecompileAllRequired = 'Recompile all required'; lisPckEditRecompileAllRequired = 'Recompile all required';
lisPckEditInstall = 'Install'; lisPckEditInstall = 'Install';
lisPckEditUninstall = 'Uninstall'; lisPckEditUninstall = 'Uninstall';
lisPckEditViewPackgeSource = 'View Package Source';
lisPckEditGeneralOptions = 'General Options'; lisPckEditGeneralOptions = 'General Options';
lisPckEditSaveChanges = 'Save Changes?'; lisPckEditSaveChanges = 'Save Changes?';
lisPckEditPackageHasChangedSavePackage = 'Package %s%s%s has changed.%sSave ' lisPckEditPackageHasChangedSavePackage = 'Package %s%s%s has changed.%sSave '

View File

@ -63,6 +63,8 @@ type
function(Sender: TObject; APackage: TLazPackage): TModalResult of object; function(Sender: TObject; APackage: TLazPackage): TModalResult of object;
TOnUninstallPackage = TOnUninstallPackage =
function(Sender: TObject; APackage: TLazPackage): TModalResult of object; function(Sender: TObject; APackage: TLazPackage): TModalResult of object;
TOnViewPackageSource =
function(Sender: TObject; APackage: TLazPackage): TModalResult of object;
TOnCreateNewPkgFile = TOnCreateNewPkgFile =
function(Sender: TObject; Params: TAddToPkgResult): TModalResult of object; function(Sender: TObject; Params: TAddToPkgResult): TModalResult of object;
TOnDeleteAmbigiousFiles = TOnDeleteAmbigiousFiles =
@ -152,6 +154,7 @@ type
procedure SaveAsClick(Sender: TObject); procedure SaveAsClick(Sender: TObject);
procedure SortFilesMenuItemClick(Sender: TObject); procedure SortFilesMenuItemClick(Sender: TObject);
procedure UninstallClick(Sender: TObject); procedure UninstallClick(Sender: TObject);
procedure ViewPkgSourceClick(Sender: TObject);
procedure UseMaxVersionCheckBoxClick(Sender: TObject); procedure UseMaxVersionCheckBoxClick(Sender: TObject);
procedure UseMinVersionCheckBoxClick(Sender: TObject); procedure UseMinVersionCheckBoxClick(Sender: TObject);
private private
@ -211,6 +214,7 @@ type
FOnRevertPackage: TOnRevertPackage; FOnRevertPackage: TOnRevertPackage;
FOnSavePackage: TOnSavePackage; FOnSavePackage: TOnSavePackage;
FOnUninstallPackage: TOnUninstallPackage; FOnUninstallPackage: TOnUninstallPackage;
FOnViewPackageSource: TOnViewPackageSource;
function GetEditors(Index: integer): TPackageEditorForm; function GetEditors(Index: integer): TPackageEditorForm;
procedure ApplyLayout(AnEditor: TPackageEditorForm); procedure ApplyLayout(AnEditor: TPackageEditorForm);
procedure SaveLayout(AnEditor: TPackageEditorForm); procedure SaveLayout(AnEditor: TPackageEditorForm);
@ -239,6 +243,7 @@ type
procedure UpdateAllEditors; procedure UpdateAllEditors;
function InstallPackage(APackage: TLazPackage): TModalResult; function InstallPackage(APackage: TLazPackage): TModalResult;
function UninstallPackage(APackage: TLazPackage): TModalResult; function UninstallPackage(APackage: TLazPackage): TModalResult;
function ViewPkgSourcePackage(APackage: TLazPackage): TModalResult;
function DeleteAmbigiousFiles(APackage: TLazPackage; function DeleteAmbigiousFiles(APackage: TLazPackage;
const Filename: string): TModalResult; const Filename: string): TModalResult;
public public
@ -266,6 +271,8 @@ type
write FOnInstallPackage; write FOnInstallPackage;
property OnUninstallPackage: TOnUninstallPackage read FOnUninstallPackage property OnUninstallPackage: TOnUninstallPackage read FOnUninstallPackage
write FOnUninstallPackage; write FOnUninstallPackage;
property OnViewPackageSource: TOnViewPackageSource read FOnViewPackageSource
write FOnViewPackageSource;
property OnDeleteAmbigiousFiles: TOnDeleteAmbigiousFiles property OnDeleteAmbigiousFiles: TOnDeleteAmbigiousFiles
read FOnDeleteAmbigiousFiles write FOnDeleteAmbigiousFiles; read FOnDeleteAmbigiousFiles write FOnDeleteAmbigiousFiles;
property OnImExportCompilerOptions: TNotifyEvent property OnImExportCompilerOptions: TNotifyEvent
@ -539,7 +546,9 @@ begin
OptionsBitBtn.Enabled); OptionsBitBtn.Enabled);
AddPopupMenuItem(dlgCompilerOptions, @CompilerOptionsBitBtnClick, AddPopupMenuItem(dlgCompilerOptions, @CompilerOptionsBitBtnClick,
CompilerOptionsBitBtn.Enabled); CompilerOptionsBitBtn.Enabled);
AddPopupMenuItem(lisPckEditViewPackgeSource, @ViewPkgSourceClick,true);
// remove unneeded menu items
while FilesPopupMenu.Items.Count>ItemCnt do while FilesPopupMenu.Items.Count>ItemCnt do
FilesPopupMenu.Items.Delete(FilesPopupMenu.Items.Count-1); FilesPopupMenu.Items.Delete(FilesPopupMenu.Items.Count-1);
end; end;
@ -794,6 +803,11 @@ begin
PackageEditors.UninstallPackage(LazPackage); PackageEditors.UninstallPackage(LazPackage);
end; end;
procedure TPackageEditorForm.ViewPkgSourceClick(Sender: TObject);
begin
PackageEditors.ViewPkgSourcePackage(LazPackage);
end;
procedure TPackageEditorForm.UseMaxVersionCheckBoxClick(Sender: TObject); procedure TPackageEditorForm.UseMaxVersionCheckBoxClick(Sender: TObject);
begin begin
MaxVersionEdit.Enabled:=UseMaxVersionCheckBox.Checked; MaxVersionEdit.Enabled:=UseMaxVersionCheckBox.Checked;
@ -2105,6 +2119,13 @@ begin
Result:=OnUninstallPackage(Self,APackage); Result:=OnUninstallPackage(Self,APackage);
end; end;
function TPackageEditors.ViewPkgSourcePackage(APackage: TLazPackage
): TModalResult;
begin
if Assigned(OnViewPackageSource) then
Result:=OnViewPackageSource(Self,APackage);
end;
function TPackageEditors.DeleteAmbigiousFiles(APackage: TLazPackage; function TPackageEditors.DeleteAmbigiousFiles(APackage: TLazPackage;
const Filename: string): TModalResult; const Filename: string): TModalResult;
begin begin

View File

@ -82,6 +82,8 @@ type
): TModalResult; ): TModalResult;
function OnPackageEditorSavePackage(Sender: TObject; APackage: TLazPackage; function OnPackageEditorSavePackage(Sender: TObject; APackage: TLazPackage;
SaveAs: boolean): TModalResult; SaveAs: boolean): TModalResult;
function OnPackageEditorViewPkgSourcePackage(Sender: TObject;
APackage: TLazPackage): TModalResult;
procedure OnPackageEditorFreeEditor(APackage: TLazPackage); procedure OnPackageEditorFreeEditor(APackage: TLazPackage);
procedure OnPackageEditorGetUnitRegisterInfo(Sender: TObject; procedure OnPackageEditorGetUnitRegisterInfo(Sender: TObject;
const AFilename: string; var TheUnitName: string; const AFilename: string; var TheUnitName: string;
@ -227,6 +229,7 @@ type
function ShowConfigureCustomComponents: TModalResult; override; function ShowConfigureCustomComponents: TModalResult; override;
function DoInstallPackage(APackage: TLazPackage): TModalResult; function DoInstallPackage(APackage: TLazPackage): TModalResult;
function DoUninstallPackage(APackage: TLazPackage): TModalResult; function DoUninstallPackage(APackage: TLazPackage): TModalResult;
function DoOpenPackageSource(APackage: TLazPackage): TModalResult;
function DoCompileAutoInstallPackages(Flags: TPkgCompileFlags function DoCompileAutoInstallPackages(Flags: TPkgCompileFlags
): TModalResult; override; ): TModalResult; override;
function DoSaveAutoInstallConfig: TModalResult; override; function DoSaveAutoInstallConfig: TModalResult; override;
@ -482,6 +485,12 @@ begin
Result:=DoSavePackage(APackage,[]); Result:=DoSavePackage(APackage,[]);
end; end;
function TPkgManager.OnPackageEditorViewPkgSourcePackage(Sender: TObject;
APackage: TLazPackage): TModalResult;
begin
Result:=DoOpenPackageSource(APackage);
end;
procedure TPkgManager.PackageGraphBeginUpdate(Sender: TObject); procedure TPkgManager.PackageGraphBeginUpdate(Sender: TObject);
begin begin
if PackageGraphExplorer<>nil then PackageGraphExplorer.BeginUpdate; if PackageGraphExplorer<>nil then PackageGraphExplorer.BeginUpdate;
@ -1517,6 +1526,7 @@ begin
PackageEditors.OnCompilePackage:=@OnPackageEditorCompilePackage; PackageEditors.OnCompilePackage:=@OnPackageEditorCompilePackage;
PackageEditors.OnInstallPackage:=@OnPackageEditorInstallPackage; PackageEditors.OnInstallPackage:=@OnPackageEditorInstallPackage;
PackageEditors.OnUninstallPackage:=@OnPackageEditorUninstallPackage; PackageEditors.OnUninstallPackage:=@OnPackageEditorUninstallPackage;
PackageEditors.OnViewPackageSource:=@OnPackageEditorViewPkgSourcePackage;
PackageEditors.OnDeleteAmbigiousFiles:=@OnPackageEditorDeleteAmbigiousFiles; PackageEditors.OnDeleteAmbigiousFiles:=@OnPackageEditorDeleteAmbigiousFiles;
PackageEditors.OnImExportCompilerOptions:=@OnPackageEditorImExportCompilerOptions; PackageEditors.OnImExportCompilerOptions:=@OnPackageEditorImExportCompilerOptions;
@ -2416,7 +2426,7 @@ begin
+RegistrationCode +RegistrationCode
+'end.'+e; +'end.'+e;
Src:=CodeToolBoss.SourceChangeCache.BeautifyCodeOptions. Src:=CodeToolBoss.SourceChangeCache.BeautifyCodeOptions.
BeautifyStatement(Src,0); BeautifyStatement(Src,0);
Src:=HeaderSrc+Src; Src:=HeaderSrc+Src;
// check if old code is already uptodate // check if old code is already uptodate
@ -3013,6 +3023,11 @@ begin
Result:=mrOk; Result:=mrOk;
end; end;
function TPkgManager.DoOpenPackageSource(APackage: TLazPackage): TModalResult;
begin
Result:=MainIDE.DoOpenEditorFile(APackage.GetSrcFilename,-1,[ofRegularFile]);
end;
function TPkgManager.DoCompileAutoInstallPackages( function TPkgManager.DoCompileAutoInstallPackages(
Flags: TPkgCompileFlags): TModalResult; Flags: TPkgCompileFlags): TModalResult;
var var