mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-10-01 11:09:40 +02:00
ideintf: added handler loadsavecustomdata
This commit is contained in:
parent
511afcb021
commit
caaedde1b2
@ -20,7 +20,7 @@ uses
|
||||
// LCL
|
||||
Forms, Controls, LazHelpHTML,
|
||||
// LazUtils
|
||||
UITypes, LazMethodList,
|
||||
UITypes, LazMethodList, AvgLvlTree,
|
||||
// BuildIntf
|
||||
BaseIDEIntf, IDEOptionsIntf, CompOptsIntf, ProjectIntf, IDEExternToolIntf,
|
||||
// IdeIntf
|
||||
@ -245,6 +245,7 @@ type
|
||||
lihtProjectBuildingFinished, // called after IDE builds the project
|
||||
lihtLazarusBuilding, // called before IDE builds Lazarus IDE
|
||||
lihtLazarusBuildingFinished, // called after IDE builds Lazarus IDE
|
||||
lihtLoadSafeCustomData, // called before saving and after loading CustomData
|
||||
lihtQuickSyntaxCheck, // called when quick syntax check is clicked (menu item or shortcut)
|
||||
lihtGetFPCFrontEndParams, // called when the IDE gets the parameters of the 'fpc' front end tool
|
||||
lihtGetFPCFrontEndPath, // called when the IDE gets the path of the 'fpc' front end tool
|
||||
@ -272,6 +273,7 @@ type
|
||||
TLazToolStatusChangeEvent = procedure(Sender: TObject; OldStatus, NewStatus: TLazToolStatus) of object;
|
||||
|
||||
TLazBuildingFinishedEvent = procedure(Sender: TObject; BuildSuccessful: Boolean) of object;
|
||||
TLazLoadSaveCustomDataEvent = procedure(Sender: TObject; Load: boolean; CustomData: TStringToStringTree; PathDelimChanged: boolean) of object;
|
||||
|
||||
{ TLazIDEInterface }
|
||||
|
||||
@ -520,6 +522,10 @@ type
|
||||
AsLast: boolean = false);
|
||||
procedure RemoveHandlerOnLazarusBuildingFinished(
|
||||
const OnLazBuildingFinishedEvent: TLazBuildingFinishedEvent);
|
||||
procedure AddHandlerOnLoadSaveCustomData(const OnLoadSaveEvent: TLazLoadSaveCustomDataEvent;
|
||||
AsLast: boolean = false);
|
||||
procedure RemoveHandlerOnLoadSaveCustomData(const OnLoadSaveEvent: TLazLoadSaveCustomDataEvent;
|
||||
AsLast: boolean = false);
|
||||
procedure AddHandlerOnQuickSyntaxCheck(
|
||||
const OnQuickSyntaxCheckEvent: TModalHandledFunction;
|
||||
AsLast: boolean = false);
|
||||
@ -919,6 +925,18 @@ begin
|
||||
RemoveHandler(lihtLazarusBuildingFinished,TMethod(OnLazBuildingFinishedEvent));
|
||||
end;
|
||||
|
||||
procedure TLazIDEInterface.AddHandlerOnLoadSaveCustomData(
|
||||
const OnLoadSaveEvent: TLazLoadSaveCustomDataEvent; AsLast: boolean);
|
||||
begin
|
||||
AddHandler(lihtLoadSafeCustomData,TMethod(OnLoadSaveEvent),AsLast);
|
||||
end;
|
||||
|
||||
procedure TLazIDEInterface.RemoveHandlerOnLoadSaveCustomData(
|
||||
const OnLoadSaveEvent: TLazLoadSaveCustomDataEvent; AsLast: boolean);
|
||||
begin
|
||||
RemoveHandler(lihtLoadSafeCustomData,TMethod(OnLoadSaveEvent));
|
||||
end;
|
||||
|
||||
procedure TLazIDEInterface.AddHandlerOnIDEClose(
|
||||
const OnIDECloseEvent: TNotifyEvent; AsLast: boolean);
|
||||
begin
|
||||
|
16
ide/main.pp
16
ide/main.pp
@ -717,6 +717,8 @@ type
|
||||
// methods for creating a project
|
||||
procedure OnLoadProjectInfoFromXMLConfig(TheProject: TProject;
|
||||
XMLConfig: TXMLConfig; Merge: boolean);
|
||||
procedure OnLoadSaveCustomData(Sender: TObject; Load: boolean;
|
||||
Data: TStringToStringTree; PathDelimChanged: boolean);
|
||||
procedure OnSaveProjectInfoToXMLConfig(TheProject: TProject;
|
||||
XMLConfig: TXMLConfig; WriteFlags: TProjectWriteFlags);
|
||||
procedure OnProjectChangeInfoFile(TheProject: TProject);
|
||||
@ -5652,6 +5654,19 @@ begin
|
||||
EditorMacroListViewer.LoadProjectSpecificInfo(XMLConfig);
|
||||
end;
|
||||
|
||||
procedure TMainIDE.OnLoadSaveCustomData(Sender: TObject; Load: boolean;
|
||||
Data: TStringToStringTree; PathDelimChanged: boolean);
|
||||
var
|
||||
Handler: TMethodList;
|
||||
i: Integer;
|
||||
begin
|
||||
Handler:=FLazarusIDEHandlers[lihtLoadSafeCustomData];
|
||||
i := Handler.Count;
|
||||
while Handler.NextDownIndex(i) do begin
|
||||
TLazLoadSaveCustomDataEvent(Handler[i])(Sender,Load,Data,PathDelimChanged);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TMainIDE.OnSaveProjectInfoToXMLConfig(TheProject: TProject;
|
||||
XMLConfig: TXMLConfig; WriteFlags: TProjectWriteFlags);
|
||||
begin
|
||||
@ -6302,6 +6317,7 @@ begin
|
||||
Result.MainProject:=true;
|
||||
Result.OnFileBackup:=@MainBuildBoss.BackupFileForWrite;
|
||||
Result.OnLoadProjectInfo:=@OnLoadProjectInfoFromXMLConfig;
|
||||
Result.OnLoadSafeCustomData:=@OnLoadSaveCustomData;
|
||||
Result.OnSaveProjectInfo:=@OnSaveProjectInfoToXMLConfig;
|
||||
Result.OnSaveUnitSessionInfo:=@OnSaveProjectUnitSessionInfo;
|
||||
Result.OnChangeProjectInfoFile:=@OnProjectChangeInfoFile;
|
||||
|
@ -55,7 +55,7 @@ uses
|
||||
LinkScanner, CodeToolManager, CodeCache, CodeTree, FileProcs, StdCodeTools,
|
||||
// LazUtils
|
||||
FPCAdds, LazUtilities, FileUtil, LazFileUtils, LazFileCache, LazMethodList,
|
||||
LazLoggerBase, FileReferenceList, LazUTF8, Laz2_XMLCfg, Maps,
|
||||
LazLoggerBase, FileReferenceList, LazUTF8, Laz2_XMLCfg, Maps, AvgLvlTree,
|
||||
// IDEIntf
|
||||
PropEdits, UnitResources, EditorSyntaxHighlighterDef,
|
||||
CompOptsIntf, ProjectIntf, MacroIntf, MacroDefIntf, SrcEditorIntf,
|
||||
@ -725,6 +725,7 @@ type
|
||||
FHistoryLists: THistoryLists;
|
||||
FLastCompileComplete: boolean;
|
||||
FMacroEngine: TTransferMacroList;
|
||||
FOnLoadSafeCustomData: TLazLoadSaveCustomDataEvent;
|
||||
FTmpAutoCreatedForms: TStrings; // temporary, used to apply auto create forms changes
|
||||
FAutoOpenDesignerFormsDisabled: boolean;
|
||||
FBookmarks: TProjectBookmarkList;
|
||||
@ -842,6 +843,8 @@ type
|
||||
function LoadOldProjectType(const Path: string): TOldProjectType;
|
||||
procedure LoadFlags(const Path: string);
|
||||
procedure LoadOtherDefines(const Path: string);
|
||||
procedure LoadCustomData(Sender: TObject; Data: TStringToStringTree;
|
||||
XMLConfig: TXMLConfig; const Path: string);
|
||||
procedure LoadSessionInfo(const Path: string; Merge: boolean);
|
||||
procedure LoadFromLPI;
|
||||
procedure LoadFromSession;
|
||||
@ -852,6 +855,8 @@ type
|
||||
procedure SaveFlags(const Path: string);
|
||||
procedure SaveUnits(const Path: string; SaveSession: boolean);
|
||||
procedure SaveOtherDefines(const Path: string);
|
||||
procedure SaveCustomData(Sender: TObject; Data: TStringToStringTree;
|
||||
XMLConfig: TXMLConfig; const Path: string);
|
||||
procedure SaveSessionInfo(const Path: string);
|
||||
procedure SaveToLPI;
|
||||
procedure SaveToSession;
|
||||
@ -1113,6 +1118,7 @@ type
|
||||
write FOnSaveProjectInfo;
|
||||
property OnSaveUnitSessionInfo: TOnSaveUnitSessionInfoInfo
|
||||
read FOnSaveUnitSessionInfo write FOnSaveUnitSessionInfo;
|
||||
property OnLoadSafeCustomData: TLazLoadSaveCustomDataEvent read FOnLoadSafeCustomData write FOnLoadSafeCustomData;
|
||||
property POOutputDirectory: string read FPOOutputDirectory write SetPOOutputDirectory;
|
||||
property PublishOptions: TPublishProjectOptions read FPublishOptions write FPublishOptions;
|
||||
property ProjResources: TProjectResources read GetProjResources;
|
||||
@ -1817,7 +1823,7 @@ begin
|
||||
if (s<>'') and (ExtractFileNameOnly(Filename)=s) then s:=''; // only save if UnitName differs from filename
|
||||
XMLConfig.SetDeleteValue(Path+'UnitName/Value',s,'');
|
||||
// save custom data
|
||||
SaveStringToStringTree(XMLConfig,CustomData,Path+'CustomData/');
|
||||
Project.SaveCustomData(Self,CustomData,XMLConfig,Path+'CustomData/');
|
||||
end;
|
||||
|
||||
// session data
|
||||
@ -1903,7 +1909,7 @@ begin
|
||||
FUnitName:='';
|
||||
|
||||
// save custom data
|
||||
LoadStringToStringTree(XMLConfig,CustomData,Path+'CustomData/');
|
||||
Project.LoadCustomData(Self,CustomData,XMLConfig,Path+'CustomData/');
|
||||
end;
|
||||
|
||||
// session data
|
||||
@ -2901,6 +2907,14 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TProject.LoadCustomData(Sender: TObject; Data: TStringToStringTree;
|
||||
XMLConfig: TXMLConfig; const Path: string);
|
||||
begin
|
||||
LoadStringToStringTree(XMLConfig,Data,Path);
|
||||
if Assigned(OnLoadSafeCustomData) then
|
||||
OnLoadSafeCustomData(Sender,true,Data,fPathDelimChanged);
|
||||
end;
|
||||
|
||||
procedure TProject.LoadSessionInfo(const Path: string; Merge: boolean);
|
||||
// Note: the session can be stored in the lpi as well
|
||||
// So this method is used for loading the lpi units as well
|
||||
@ -3008,7 +3022,7 @@ begin
|
||||
{$IFDEF IDE_MEM_CHECK}CheckHeapWrtMemCnt('TProject.ReadProject E reading comp sets');{$ENDIF}
|
||||
|
||||
// load custom data
|
||||
LoadStringToStringTree(FXMLConfig,CustomData,Path+'CustomData/');
|
||||
LoadCustomData(Self,CustomData,FXMLConfig,Path+'CustomData/');
|
||||
{$IFDEF IDE_MEM_CHECK}CheckHeapWrtMemCnt('TProject.ReadProject update ct boss');{$ENDIF}
|
||||
CodeToolBoss.GlobalValues.Variables[ExternalMacroStart+'ProjPath']:=Directory;
|
||||
CodeToolBoss.DefineTree.ClearCache;
|
||||
@ -3274,6 +3288,26 @@ begin
|
||||
FXMLConfig.SetDeleteValue(Path+'OtherDefines/Count',FOtherDefines.Count,0);
|
||||
end;
|
||||
|
||||
procedure TProject.SaveCustomData(Sender: TObject; Data: TStringToStringTree;
|
||||
XMLConfig: TXMLConfig; const Path: string);
|
||||
var
|
||||
NewData: TStringToStringTree;
|
||||
begin
|
||||
if Assigned(OnLoadSafeCustomData) and (Data.Count>0) then
|
||||
begin
|
||||
NewData:=TStringToStringTree.Create(Data.CompareItemsFunc,Data.CompareKeyItemFunc,Data.CaseSensitive);
|
||||
try
|
||||
NewData.Assign(Data);
|
||||
OnLoadSafeCustomData(Sender,false,NewData,fPathDelimChanged);
|
||||
SaveStringToStringTree(XMLConfig,NewData,Path);
|
||||
finally
|
||||
NewData.Free;
|
||||
end;
|
||||
end else begin
|
||||
SaveStringToStringTree(XMLConfig,Data,Path);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TProject.SaveSessionInfo(const Path: string);
|
||||
begin
|
||||
FXMLConfig.DeleteValue(Path+'General/ActiveEditorIndexAtStart/Value');
|
||||
@ -3341,7 +3375,7 @@ begin
|
||||
// Resources
|
||||
ProjResources.WriteToProjectFile(FXMLConfig, Path);
|
||||
// save custom data
|
||||
SaveStringToStringTree(FXMLConfig,CustomData,Path+'CustomData/');
|
||||
SaveCustomData(Self,CustomData,FXMLConfig,Path+'CustomData/');
|
||||
// Save the macro values and compiler options
|
||||
BuildModes.SaveProjOptsToXMLConfig(FXMLConfig, Path, FSaveSessionInLPI, UseLegacyLists);
|
||||
BuildModes.SaveSharedMatrixOptions(Path);
|
||||
|
Loading…
Reference in New Issue
Block a user