type_lib_edtr : Persistent options across sessions.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@4193 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
inoussa
2015-06-26 15:44:09 +00:00
parent 77c38e6788
commit de6c82440d
2 changed files with 61 additions and 2 deletions

View File

@ -6,15 +6,19 @@ interface
uses uses
Classes, SysUtils, LResources, Forms, Controls, Dialogs, IniFiles, Classes, SysUtils, LResources, Forms, Controls, Dialogs, IniFiles,
pascal_parser_intf; {$IFDEF WST_IDE}LazConfigStorage, BaseIDEIntf, LCLProc,{$ENDIF WST_IDE}
pascal_parser_intf, wst_consts;
const const
SECTION_OPTIONS = 'Options'; SECTION_OPTIONS = 'Options';
CASE_SENSITIVE = 'CaseSensitive'; CASE_SENSITIVE = 'CaseSensitive';
STRING_MAPPING = 'StringMapping'; STRING_MAPPING = 'StringMapping';
{$IFNDEF WST_IDE} {$IFNDEF WST_IDE}
sLAST_PATH = 'LastPath'; sLAST_PATH = 'LastPath';
{$ENDIF WST_IDE} {$ENDIF WST_IDE}
{$IFDEF WST_IDE}
sCONFIG_FILE_NAME = 'wstsettings.xml';
{$ENDIF WST_IDE}
type type
@ -26,6 +30,10 @@ type
{$IFNDEF WST_IDE} {$IFNDEF WST_IDE}
FOptions : TMemIniFile; FOptions : TMemIniFile;
function GetOtions: TCustomIniFile; function GetOtions: TCustomIniFile;
{$ENDIF WST_IDE}
{$IFDEF WST_IDE}
procedure SaveOptionsToIDEStore();
procedure LoadOptionsFromIDEStore();
{$ENDIF WST_IDE} {$ENDIF WST_IDE}
private private
FXsdStringMaping : TXSDStringMaping; FXsdStringMaping : TXSDStringMaping;
@ -59,6 +67,50 @@ begin
end; end;
{$ENDIF WST_IDE} {$ENDIF WST_IDE}
{$IFDEF WST_IDE}
procedure TDM.SaveOptionsToIDEStore();
var
store : TConfigStorage;
begin
try
store := GetIDEConfigStorage(sCONFIG_FILE_NAME,True);
try
store.SetDeleteValue('Options/Version',WST_VERSION_INTEGER,0);
store.SetDeleteValue('Options/'+CASE_SENSITIVE,Self.CaseSensitive,CASE_SENSITIVE_DEFAULT);
store.SetDeleteValue('Options/'+STRING_MAPPING,Ord(Self.XsdStringMaping),Ord(xsmUnicodeString));
finally
store.Free();
end;
except
on e : Exception do begin
DebugLn([Format('Saving %s failed: ',[sCONFIG_FILE_NAME]),e.Message]);
end;
end;
end;
procedure TDM.LoadOptionsFromIDEStore();
var
store : TConfigStorage;
i : Integer;
begin
try
store := GetIDEConfigStorage(sCONFIG_FILE_NAME,True);
try
Self.CaseSensitive := store.GetValue('Options/'+CASE_SENSITIVE,Self.CaseSensitive);
i := store.GetValue('Options/'+STRING_MAPPING,Ord(Self.XsdStringMaping));
if (i >= Ord(Low(TXSDStringMaping))) and (i <= Ord(High(TXSDStringMaping))) then
Self.XsdStringMaping := TXSDStringMaping(i);
finally
store.Free();
end;
except
on e : Exception do begin
DebugLn([Format('Loading %s failed: ',[sCONFIG_FILE_NAME]),e.Message]);
end;
end;
end;
{$ENDIF WST_IDE}
procedure TDM.LoadOptions(AStore: TCustomIniFile); procedure TDM.LoadOptions(AStore: TCustomIniFile);
var var
i : Integer; i : Integer;
@ -84,10 +136,16 @@ begin
FOptions := TMemIniFile.Create(ChangeFileExt(GetAppConfigFile(False),'.ini')); FOptions := TMemIniFile.Create(ChangeFileExt(GetAppConfigFile(False),'.ini'));
LoadOptions(FOptions); LoadOptions(FOptions);
{$ENDIF WST_IDE} {$ENDIF WST_IDE}
{$IFDEF WST_IDE}
LoadOptionsFromIDEStore();
{$ENDIF WST_IDE}
end; end;
destructor TDM.Destroy(); destructor TDM.Destroy();
begin begin
{$IFDEF WST_IDE}
SaveOptionsToIDEStore();
{$ENDIF WST_IDE}
{$IFNDEF WST_IDE} {$IFNDEF WST_IDE}
if ( FOptions <> nil ) then begin if ( FOptions <> nil ) then begin
SaveOptions(FOptions); SaveOptions(FOptions);

View File

@ -19,6 +19,7 @@ interface
const const
WST_BLOCK_TYPE = LongInt(56789); WST_BLOCK_TYPE = LongInt(56789);
sWST_SIGNATURE = 'WST_METADATA_0.6'; sWST_SIGNATURE = 'WST_METADATA_0.6';
WST_VERSION_INTEGER = LongInt(10000*0 + 100*6);
resourcestring resourcestring
SERR_BaseTypeNotSpecfifiedForSimpleType = 'Base type is not specified for the simple type, parsing : "%s".'; SERR_BaseTypeNotSpecfifiedForSimpleType = 'Base type is not specified for the simple type, parsing : "%s".';