Skip to content

Commit ad3230e

Browse files
DPM Editor view reacts to active project and active platform changes.
Still an issue with detecting when platforms added to a project.
1 parent 5bd5ece commit ad3230e

12 files changed

Lines changed: 852 additions & 681 deletions

Build/BuildDPM.fbp8

Lines changed: 74 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,11 @@ begin
1919
propertysetname = DPMVersion
2020
propertyset.win32.info
2121
begin
22+
legalcopyright = "© 2019 -2024 Vincent Parrett and Contributors"
23+
linkproductversion = false
24+
minorversion = 2
2225
name = DPMVersion
23-
productversion = 0.0.0.0
26+
productname = "DPM IDE Support for Delphi12"
2427
productversionstring = 0.2.0-alpha
2528
end
2629
end
@@ -733,6 +736,11 @@ begin
733736
variablename = CompilerVersion
734737
end
735738
target.argvalue
739+
begin
740+
value = Win32
741+
variablename = DelphiPlatform
742+
end
743+
target.argvalue
736744
begin
737745
value = DPM.IDE.XE2.dpr
738746
variablename = ProjectFile
@@ -752,6 +760,11 @@ begin
752760
variablename = CompilerVersion
753761
end
754762
target.argvalue
763+
begin
764+
value = Win32
765+
variablename = DelphiPlatform
766+
end
767+
target.argvalue
755768
begin
756769
value = DPM.IDE.XE3.dpr
757770
variablename = ProjectFile
@@ -771,6 +784,11 @@ begin
771784
variablename = CompilerVersion
772785
end
773786
target.argvalue
787+
begin
788+
value = Win32
789+
variablename = DelphiPlatform
790+
end
791+
target.argvalue
774792
begin
775793
value = DPM.IDE.XE4.dpr
776794
variablename = ProjectFile
@@ -790,6 +808,11 @@ begin
790808
variablename = CompilerVersion
791809
end
792810
target.argvalue
811+
begin
812+
value = Win32
813+
variablename = DelphiPlatform
814+
end
815+
target.argvalue
793816
begin
794817
value = DPM.IDE.XE5.dpr
795818
variablename = ProjectFile
@@ -809,6 +832,11 @@ begin
809832
variablename = CompilerVersion
810833
end
811834
target.argvalue
835+
begin
836+
value = Win32
837+
variablename = DelphiPlatform
838+
end
839+
target.argvalue
812840
begin
813841
value = DPM.IDE.XE6.dpr
814842
variablename = ProjectFile
@@ -828,6 +856,11 @@ begin
828856
variablename = CompilerVersion
829857
end
830858
target.argvalue
859+
begin
860+
value = Win32
861+
variablename = DelphiPlatform
862+
end
863+
target.argvalue
831864
begin
832865
value = DPM.IDE.XE7.dpr
833866
variablename = ProjectFile
@@ -847,6 +880,11 @@ begin
847880
variablename = CompilerVersion
848881
end
849882
target.argvalue
883+
begin
884+
value = Win32
885+
variablename = DelphiPlatform
886+
end
887+
target.argvalue
850888
begin
851889
value = DPM.IDE.XE8.dpr
852890
variablename = ProjectFile
@@ -866,6 +904,11 @@ begin
866904
variablename = CompilerVersion
867905
end
868906
target.argvalue
907+
begin
908+
value = Win32
909+
variablename = DelphiPlatform
910+
end
911+
target.argvalue
869912
begin
870913
value = DPM.IDE.D100.dpr
871914
variablename = ProjectFile
@@ -885,6 +928,11 @@ begin
885928
variablename = CompilerVersion
886929
end
887930
target.argvalue
931+
begin
932+
value = Win32
933+
variablename = DelphiPlatform
934+
end
935+
target.argvalue
888936
begin
889937
value = DPM.IDE.D101.dpr
890938
variablename = ProjectFile
@@ -904,6 +952,11 @@ begin
904952
variablename = CompilerVersion
905953
end
906954
target.argvalue
955+
begin
956+
value = Win32
957+
variablename = DelphiPlatform
958+
end
959+
target.argvalue
907960
begin
908961
value = DPM.IDE.D102.dpr
909962
variablename = ProjectFile
@@ -923,6 +976,11 @@ begin
923976
variablename = CompilerVersion
924977
end
925978
target.argvalue
979+
begin
980+
value = Win32
981+
variablename = DelphiPlatform
982+
end
983+
target.argvalue
926984
begin
927985
value = DPM.IDE.D103.dpr
928986
variablename = ProjectFile
@@ -942,6 +1000,11 @@ begin
9421000
variablename = CompilerVersion
9431001
end
9441002
target.argvalue
1003+
begin
1004+
value = Win32
1005+
variablename = DelphiPlatform
1006+
end
1007+
target.argvalue
9451008
begin
9461009
value = DPM.IDE.D104.dpr
9471010
variablename = ProjectFile
@@ -961,6 +1024,11 @@ begin
9611024
variablename = CompilerVersion
9621025
end
9631026
target.argvalue
1027+
begin
1028+
value = Win32
1029+
variablename = DelphiPlatform
1030+
end
1031+
target.argvalue
9641032
begin
9651033
value = DPM.IDE.D110.dpr
9661034
variablename = ProjectFile
@@ -1463,6 +1531,7 @@ begin
14631531
apikey = %SignotaurAPIKey%
14641532
contentdescription = "DPM command line"
14651533
contentdescriptionurl = https://docs.delphi.dev
1534+
enabled = false
14661535
enabletimeout = false
14671536
expandimpersonationtoken = false
14681537
filespecs = "%FileToSign%" +
@@ -1481,6 +1550,10 @@ begin
14811550
timestampserverurl = http://timestamp.sectigo.com
14821551
useerrordialogmonitor = false
14831552
end
1553+
action.group
1554+
begin
1555+
id = {3248FFDC-AB6C-452A-999D-EE54ABFFF9A1}
1556+
end
14841557
end
14851558
end
14861559
variable

Source/IDE/DPM.IDE.IDENotifier.pas

Lines changed: 86 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ interface
3131
uses
3232
ToolsApi,
3333
Spring.Collections,
34+
DPM.IDE.Types,
3435
DPM.IDE.Logger,
3536
DPM.IDE.ProjectController;
3637

@@ -44,13 +45,13 @@ interface
4445
// need the StorageNotifier
4546

4647
type
47-
TDPMIDENotifier = class(TInterfacedObject, IOTANotifier, IOTAIDENotifier)
48+
TDPMIDENotifier = class(TInterfacedObject, IOTANotifier, IOTAIDENotifier, IDPMIDENotifier)
4849
private
4950
FLogger : IDPMIDELogger;
5051
FLoadingGroup : boolean;
5152
FGroupProjects : IList<string>;
5253
FProjectController : IDPMIDEProjectController;
53-
54+
FProjectNotifiers : IDictionary<string, IOTAProjectNotifier>;
5455
protected
5556
//IOTANotifier
5657
procedure AfterSave;
@@ -65,6 +66,17 @@ TDPMIDENotifier = class(TInterfacedObject, IOTANotifier, IOTAIDENotifier)
6566
procedure FileNotification(NotifyCode : TOTAFileNotification; const FileName : string; var Cancel : Boolean);
6667

6768
function LoadProjectGroup(const fileName : string) : boolean;
69+
70+
procedure AddProjectNotifier(const fileName : string);
71+
procedure RemoveProjectNotifier(const fileName : string);
72+
73+
74+
//IDPMIDENotifier;
75+
procedure ProjectActivePlatformChanged(const platform : string);
76+
procedure ProjectRenamed(const oldFileName : string; const newFileName : string);
77+
procedure ActiveProjectChanged;
78+
79+
6880
public
6981
constructor Create(const logger : IDPMIDELogger; const projectController : IDPMIDEProjectController);
7082
destructor Destroy; override;
@@ -77,10 +89,38 @@ implementation
7789
DPM.Core.Utils.Path,
7890
DPM.Core.Utils.System,
7991
DPM.Core.Project.Interfaces,
80-
DPM.Core.Project.GroupProjReader;
92+
DPM.Core.Project.GroupProjReader,
93+
DPM.IDE.ProjectNotifier;
8194

8295
{ TDPMIDENotifier }
8396

97+
procedure TDPMIDENotifier.ActiveProjectChanged;
98+
var
99+
activeProject : IOTAProject;
100+
begin
101+
activeProject := (BorlandIDEServices as IOTAModuleServices).GetActiveProject;
102+
if activeProject <> nil then
103+
FProjectController.ActiveProjectChanged(activeProject);
104+
105+
end;
106+
107+
procedure TDPMIDENotifier.AddProjectNotifier(const fileName: string);
108+
var
109+
notifier : IOTAProjectNotifier;
110+
Module: IOTAModule;
111+
project : IOTAProject;
112+
begin
113+
Module := (BorlandIDEServices as IOTAModuleServices).FindModule(FileName);
114+
if Supports(Module,IOTAProject, project) then
115+
begin
116+
notifier := TDPMProjectNotifier.Create(FLogger, Self, fileName, project);
117+
FProjectNotifiers.Add(LowerCase(fileName), notifier);
118+
119+
project.AddNotifier(notifier);
120+
121+
end;
122+
end;
123+
84124
procedure TDPMIDENotifier.AfterCompile(Succeeded : Boolean);
85125
begin
86126
end;
@@ -100,9 +140,9 @@ procedure TDPMIDENotifier.BeforeSave;
100140
constructor TDPMIDENotifier.Create(const logger : IDPMIDELogger; const projectController : IDPMIDEProjectController);
101141
begin
102142
FLogger := logger;
103-
FGroupProjects := TCollections.CreateList < string > ;
143+
FGroupProjects := TCollections.CreateList<string> ;
144+
FProjectNotifiers := TCollections.CreateDictionary<string, IOTAProjectNotifier>;
104145
FProjectController := projectController;
105-
106146
end;
107147

108148
destructor TDPMIDENotifier.Destroy;
@@ -215,7 +255,6 @@ procedure TDPMIDENotifier.FileNotification(NotifyCode : TOTAFileNotification; co
215255
end;
216256
ofnFileOpened :
217257
begin
218-
//make sire we ignore the groupproj here.
219258
if ext <> '.dproj' then
220259
exit;
221260
FLogger.Debug('TDPMIDENotifier ofnFileOpened ' + FileName);
@@ -236,6 +275,7 @@ procedure TDPMIDENotifier.FileNotification(NotifyCode : TOTAFileNotification; co
236275
if not FLoadingGroup then
237276
FProjectController.EndLoading(TProjectMode.pmSingle);
238277
{$IFEND}
278+
AddProjectNotifier(FileName);
239279

240280
end;
241281
ofnFileClosing :
@@ -246,7 +286,15 @@ procedure TDPMIDENotifier.FileNotification(NotifyCode : TOTAFileNotification; co
246286
FProjectController.ProjectClosed(FileName)
247287
else
248288
FProjectController.ProjectGroupClosed;
289+
RemoveProjectNotifier(FileName);
249290
end;
291+
292+
ofnActiveProjectChanged :
293+
begin
294+
if not FLoadingGroup then
295+
ActiveProjectChanged;
296+
end;
297+
250298
{$IF CompilerVersion >= 34.0 }
251299
//10.4 or later
252300
ofnBeginProjectGroupOpen :
@@ -269,7 +317,7 @@ procedure TDPMIDENotifier.FileNotification(NotifyCode : TOTAFileNotification; co
269317
exit;
270318

271319
FProjectController.EndLoading(TProjectMode.pmGroup);
272-
FLoadingGroup := true;
320+
FLoadingGroup := false;
273321
end;
274322
ofnBeginProjectGroupClose :
275323
begin
@@ -295,8 +343,39 @@ procedure TDPMIDENotifier.FileNotification(NotifyCode : TOTAFileNotification; co
295343

296344
procedure TDPMIDENotifier.Modified;
297345
begin
346+
TSystemUtils.OutputDebugString('TDPMIDENotifier.Modified');
298347
FLogger.Debug('TDPMIDENotifier.Modified');
299348
end;
300349

350+
procedure TDPMIDENotifier.ProjectActivePlatformChanged(const platform: string);
351+
begin
352+
TSystemUtils.OutputDebugString('TDPMIDENotifier.ProjectActivePlatformChanged : ' + platform);
353+
FProjectController.ActivePlatformChanged(platform);
354+
end;
355+
356+
procedure TDPMIDENotifier.ProjectRenamed(const oldFileName, newFileName: string);
357+
var
358+
key : string;
359+
notifier : IOTAProjectNotifier;
360+
begin
361+
key := LowerCase(oldFileName);
362+
if FProjectNotifiers.TryExtract(key, notifier) then
363+
begin
364+
FProjectNotifiers.Remove(key);
365+
key := LowerCase(newFileName);
366+
FProjectNotifiers.Add(key, notifier);
367+
end;
368+
end;
369+
370+
procedure TDPMIDENotifier.RemoveProjectNotifier(const fileName: string);
371+
var
372+
key : string;
373+
begin
374+
key := LowerCase(fileName);
375+
if FProjectNotifiers.ContainsKey(key) then
376+
FProjectNotifiers.Remove(key);
377+
378+
end;
379+
301380
end.
302381

0 commit comments

Comments
 (0)