IDE: started using configstorage for package custom options

git-svn-id: trunk@24735 -
This commit is contained in:
mattias 2010-04-20 12:21:04 +00:00
parent b7a54325ee
commit f66c5b9bd3
4 changed files with 75 additions and 25 deletions

View File

@ -61,6 +61,7 @@ type
constructor Create(TheXMLConfig: TXMLConfig);
constructor Create(TheXMLConfig: TXMLConfig; const StartPath: string);
destructor Destroy; override;
procedure Clear; override;
property XMLConfig: TXMLConfig read FXMLConfig;
property FreeXMLConfig: boolean read FFreeXMLConfig write FFreeXMLConfig;
procedure WriteToDisk; override;
@ -946,6 +947,11 @@ begin
inherited Destroy;
end;
procedure TXMLOptionsStorage.Clear;
begin
FXMLConfig.Clear;
end;
procedure TXMLOptionsStorage.WriteToDisk;
begin
FXMLConfig.Flush;

View File

@ -23,7 +23,7 @@ unit PackageIntf;
interface
uses
Classes, SysUtils, Forms, NewItemIntf, AvgLvlTree;
Classes, SysUtils, Forms, LazConfigStorage, NewItemIntf, AvgLvlTree;
const
PkgDescGroupName = 'Package';
@ -91,7 +91,7 @@ type
TIDEPackage = class(TLazPackageID)
protected
FCustomOptions: TStringToStringTree;
FCustomOptions: TConfigStorage;
FFilename: string;
function GetDirectoryExpanded: string; virtual; abstract;
function GetModified: boolean; virtual; abstract;
@ -100,11 +100,14 @@ type
public
function IsVirtual: boolean; virtual; abstract;
function ReadOnly: boolean; virtual; abstract;
constructor Create;
destructor Destroy; override;
procedure ClearCustomOptions;
public
property Filename: string read FFilename write SetFilename;//the .lpk filename
property Modified: boolean read GetModified write SetModified;
property DirectoryExpanded: string read GetDirectoryExpanded;
property CustomOptions: TStringToStringTree read FCustomOptions;
property CustomOptions: TConfigStorage read FCustomOptions;
end;
type
@ -544,6 +547,25 @@ begin
Version.Assign(Source.Version);
end;
{ TIDEPackage }
constructor TIDEPackage.Create;
begin
inherited Create;
FCustomOptions:=TConfigMemStorage.Create('',false);
end;
destructor TIDEPackage.Destroy;
begin
FreeAndNil(FCustomOptions);
inherited Destroy;
end;
procedure TIDEPackage.ClearCustomOptions;
begin
TConfigMemStorage(FCustomOptions).Clear;
end;
initialization
PackageEditingInterface:=nil;

View File

@ -46,6 +46,7 @@ type
public
constructor Create(const Filename: string; LoadFromDisk: Boolean); virtual;
destructor Destroy; override;
procedure Clear; virtual; abstract;
function GetValue(const APath, ADefault: String): String;
function GetValue(const APath: String; ADefault: Integer): Integer;
function GetValue(const APath: String; ADefault: Boolean): Boolean;
@ -121,6 +122,9 @@ type
function GetFilename: string; override;
procedure WriteToDisk; override;
destructor Destroy; override;
procedure Clear; override;
procedure SaveToConfig(Config: TConfigStorage; const APath: string);
procedure LoadFromToConfig(Config: TConfigStorage; const APath: string);
end;
function CompareConfigMemStorageNames(p1, p2: PChar): integer;
@ -538,6 +542,23 @@ begin
inherited Destroy;
end;
procedure TConfigMemStorage.Clear;
begin
FreeAndNil(Root);
end;
procedure TConfigMemStorage.SaveToConfig(Config: TConfigStorage;
const APath: string);
begin
end;
procedure TConfigMemStorage.LoadFromToConfig(Config: TConfigStorage;
const APath: string);
begin
end;
{ TConfigMemStorageNode }
procedure TConfigMemStorageNode.ClearChilds;

View File

@ -46,7 +46,7 @@ interface
uses
Classes, SysUtils, LCLProc, LResources, Graphics, Forms, FileUtil,
AvgLvlTree, AVL_Tree,
AvgLvlTree, AVL_Tree, LazConfigStorage,
DefineTemplates, CodeToolManager, Laz_XMLWrite, Laz_XMLCfg, CodeCache,
PropEdits, LazIDEIntf, MacroIntf, PackageIntf,
EditDefineTree, CompilerOptions, CompOptsModes,
@ -2324,7 +2324,6 @@ begin
FDefineTemplates:=TLazPackageDefineTemplates.Create(Self);
fPublishOptions:=TPublishPackageOptions.Create(Self);
FProvides:=TStringList.Create;
FCustomOptions:=TStringToStringTree.Create(false);
Clear;
FUsageOptions.ParsedOpts.InvalidateParseOnChange:=true;
end;
@ -2333,7 +2332,6 @@ destructor TLazPackage.Destroy;
begin
Include(FFlags,lpfDestroying);
Clear;
FreeAndNil(FCustomOptions);
FreeAndNil(fPublishOptions);
FreeAndNil(FProvides);
FreeAndNil(FDefineTemplates);
@ -2375,28 +2373,31 @@ begin
// break and free required dependencies
while FFirstRequiredDependency<>nil do
DeleteRequiredDependency(FFirstRequiredDependency);
FAddToProjectUsesSection:=true;
FAuthor:='';
FAutoInstall:=pitNope;
if not (lpfDestroying in FFlags) then begin
FAddToProjectUsesSection:=true;
FAuthor:='';
FAutoInstall:=pitNope;
FComponents.Clear;
FCompilerOptions.Clear;
FDescription:='';
FDirectory:='';
FDirectoryExpandedChangeStamp:=InvalidParseStamp;
FHasDirectory:=false;
FHasStaticDirectory:=false;
FVersion.Clear;
FFilename:='';
FIconFile:='';
FInstalled:=pitNope;
FName:='';
FPackageType:=lptRunAndDesignTime;
FRegistered:=false;
ClearCustomOptions;
end;
for i:=FComponents.Count-1 downto 0 do Components[i].Free;
FComponents.Clear;
FCompilerOptions.Clear;
FDescription:='';
FDirectory:='';
FDirectoryExpandedChangeStamp:=InvalidParseStamp;
FHasDirectory:=false;
FHasStaticDirectory:=false;
FVersion.Clear;
FFilename:='';
for i:=FRemovedFiles.Count-1 downto 0 do RemovedFiles[i].Free;
FRemovedFiles.Clear;
for i:=FFiles.Count-1 downto 0 do Files[i].Free;
FFiles.Clear;
FIconFile:='';
FInstalled:=pitNope;
FName:='';
FPackageType:=lptRunAndDesignTime;
FRegistered:=false;
FUsageOptions.Clear;
fPublishOptions.Clear;
FProvides.Clear;
@ -2552,7 +2553,7 @@ begin
fPublishOptions.LoadFromXMLConfig(XMLConfig,Path+'PublishOptions/',
PathDelimChanged);
LoadStringList(XMLConfig,FProvides,Path+'Provides/');
LoadStringToStringTree(XMLConfig,FCustomOptions,Path+'CustomOptions');
//LoadStringToStringTree(XMLConfig,FCustomOptions,Path+'CustomOptions');
EndUpdate;
Modified:=false;
UnlockModified;
@ -2618,7 +2619,7 @@ begin
FUsageOptions.SaveToXMLConfig(XMLConfig,Path+'UsageOptions/',UsePathDelim);
fPublishOptions.SaveToXMLConfig(XMLConfig,Path+'PublishOptions/',UsePathDelim);
SaveStringList(XMLConfig,FProvides,Path+'Provides/');
SaveStringToStringTree(XMLConfig,FCustomOptions,Path+'CustomOptions');
//SaveStringToStringTree(XMLConfig,FCustomOptions,Path+'CustomOptions');
Modified:=false;
end;