mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-31 17:20:37 +02:00
project groups: de/activate recursively
git-svn-id: trunk@50392 -
This commit is contained in:
parent
80d795b245
commit
39907a035d
@ -37,6 +37,8 @@ type
|
||||
function ProjectAction(AAction: TPGTargetAction): TPGActionResult;
|
||||
function PackageAction(AAction: TPGTargetAction): TPGActionResult;
|
||||
function ProjectGroupAction(AAction: TPGTargetAction): TPGActionResult;
|
||||
function PascalFileAction(AAction: TPGTargetAction): TPGActionResult;
|
||||
function ExternalToolAction(AAction: TPGTargetAction): TPGActionResult;
|
||||
function PerformAction(AAction: TPGTargetAction): TPGActionResult; override;
|
||||
public
|
||||
procedure LoadTarget(Recursively: boolean); virtual;
|
||||
@ -1021,18 +1023,59 @@ end;
|
||||
function TIDECompileTarget.ProjectGroupAction(AAction: TPGTargetAction
|
||||
): TPGActionResult;
|
||||
begin
|
||||
if AAction=taOpen then
|
||||
ProjectGroupManager.LoadProjectGroup(FileName,[])
|
||||
else
|
||||
Result:=ParentProjectGroup.PerformFrom(0,AAction);
|
||||
Result:=arFailed;
|
||||
|
||||
case AAction of
|
||||
taOpen: ProjectGroupManager.LoadProjectGroup(FileName,[]);
|
||||
taSettings: ;
|
||||
taCompile: ;
|
||||
taCompileClean: ;
|
||||
taRun: ;
|
||||
taInstall: ;
|
||||
taUninstall: ;
|
||||
end;
|
||||
end;
|
||||
|
||||
function TIDECompileTarget.PascalFileAction(AAction: TPGTargetAction
|
||||
): TPGActionResult;
|
||||
begin
|
||||
Result:=arFailed;
|
||||
debugln(['TIDECompileTarget.PascalFileAction ToDo']);
|
||||
case AAction of
|
||||
taOpen: ;
|
||||
taSettings: ;
|
||||
taCompile: ;
|
||||
taCompileClean: ;
|
||||
taRun: ;
|
||||
taInstall: ;
|
||||
taUninstall: ;
|
||||
end;
|
||||
end;
|
||||
|
||||
function TIDECompileTarget.ExternalToolAction(AAction: TPGTargetAction
|
||||
): TPGActionResult;
|
||||
begin
|
||||
Result:=arFailed;
|
||||
debugln(['TIDECompileTarget.ExternalToolAction ToDo']);
|
||||
case AAction of
|
||||
taOpen: ;
|
||||
taSettings: ;
|
||||
taCompile: ;
|
||||
taCompileClean: ;
|
||||
taRun: ;
|
||||
taInstall: ;
|
||||
taUninstall: ;
|
||||
end;
|
||||
end;
|
||||
|
||||
function TIDECompileTarget.PerformAction(AAction: TPGTargetAction): TPGActionResult;
|
||||
begin
|
||||
case TargetType of
|
||||
ttProject: Result:=ProjectAction(AAction);
|
||||
ttPackage: Result:=PackageAction(AAction);
|
||||
ttProjectGroup: Result:=ProjectGroupAction(AAction);
|
||||
ttProject: Result:=ProjectAction(AAction);
|
||||
ttPackage: Result:=PackageAction(AAction);
|
||||
ttProjectGroup: Result:=ProjectGroupAction(AAction);
|
||||
ttPascalFile: Result:=PascalFileAction(AAction);
|
||||
ttExternalTool: Result:=ExternalToolAction(AAction);
|
||||
end;
|
||||
end;
|
||||
|
||||
|
@ -358,9 +358,9 @@ Var
|
||||
PG: TProjectGroup;
|
||||
begin
|
||||
T:=SelectedNodeData;
|
||||
if (T=nil) or (T.Target=nil) then
|
||||
if (T=nil) or (T.Target=nil) or (T.Target.Parent=nil) then
|
||||
exit;
|
||||
PG:=T.Target.ParentProjectGroup;
|
||||
PG:=T.Target.Parent.ProjectGroup;
|
||||
if PG=nil then exit;
|
||||
I:=PG.IndexOfTarget(T.Target);
|
||||
J:=I-1;
|
||||
@ -376,9 +376,9 @@ Var
|
||||
begin
|
||||
I:=-1;
|
||||
T:=SelectedNodeData;
|
||||
if (T=nil) or (T.Target=nil) then
|
||||
if (T=nil) or (T.Target=nil) or (T.Target.Parent=nil) then
|
||||
exit;
|
||||
PG:=T.Target.ParentProjectGroup;
|
||||
PG:=T.Target.Parent.ProjectGroup;
|
||||
if PG=nil then exit;
|
||||
I:=PG.IndexOfTarget(T.Target);
|
||||
(Sender as TAction).Enabled:=I>0;
|
||||
@ -392,9 +392,9 @@ Var
|
||||
PG: TProjectGroup;
|
||||
begin
|
||||
T:=SelectedNodeData;
|
||||
if (T=nil) or (T.Target=nil) then
|
||||
if (T=nil) or (T.Target=nil) or (T.Target.Parent=nil) then
|
||||
exit;
|
||||
PG:=T.Target.ParentProjectGroup;
|
||||
PG:=T.Target.Parent.ProjectGroup;
|
||||
if PG=nil then exit;
|
||||
I:=PG.IndexOfTarget(T.Target);
|
||||
J:=I+1;
|
||||
@ -409,9 +409,9 @@ Var
|
||||
PG: TProjectGroup;
|
||||
begin
|
||||
T:=SelectedNodeData;
|
||||
if (T=nil) or (T.Target=nil) then
|
||||
if (T=nil) or (T.Target=nil) or (T.Target.Parent=nil) then
|
||||
exit;
|
||||
PG:=T.Target.ParentProjectGroup;
|
||||
PG:=T.Target.Parent.ProjectGroup;
|
||||
if PG=nil then exit;
|
||||
I:=PG.IndexOfTarget(T.Target);
|
||||
(Sender as TAction).Enabled:=I+1<PG.TargetCount;
|
||||
@ -503,28 +503,48 @@ procedure TProjectGroupEditorForm.TVPGDblClick(Sender: TObject);
|
||||
Var
|
||||
ND: TNodeData;
|
||||
aFilename: String;
|
||||
PG: TProjectGroup;
|
||||
begin
|
||||
ND:=SelectedNodeData;
|
||||
//debugln(['TProjectGroupEditorForm.TVPGDblClick ',DbgSName(Sender),' ',TVPG.Selected.Text,' ',ND<>nil]);
|
||||
if ND=nil then exit;
|
||||
case ND.NodeType of
|
||||
ntUnknown: ;
|
||||
ntProjectGroup: ;
|
||||
ntTargets: ;
|
||||
ntRemovedTargets: ;
|
||||
ntTarget: ;
|
||||
ntRemovedTarget: ;
|
||||
ntTarget:
|
||||
begin
|
||||
// activate target and open in IDE
|
||||
PG:=ND.Target.Parent.ProjectGroup;
|
||||
if PG=nil then exit;
|
||||
PG.ActivateTarget(ND.Target);
|
||||
case ND.Target.TargetType of
|
||||
ttProject,ttPackage,ttPascalFile:
|
||||
PG.Perform(ND.Target,taOpen);
|
||||
end;
|
||||
end;
|
||||
ntRemovedTarget:
|
||||
begin
|
||||
PG:=ND.Target.Parent.ProjectGroup;
|
||||
if PG=nil then exit;
|
||||
case ND.Target.TargetType of
|
||||
ttProject,ttPackage,ttPascalFile:
|
||||
PG.Perform(ND.Target,taOpen);
|
||||
end;
|
||||
end;
|
||||
ntFiles: ;
|
||||
ntFile:
|
||||
begin
|
||||
// open file in source editor
|
||||
aFilename:=ND.Value;
|
||||
//debugln(['TProjectGroupEditorForm.TVPGDblClick File=',aFilename]);
|
||||
if aFilename='' then exit;
|
||||
LazarusIDE.DoOpenEditorFile(aFilename,-1,-1,[ofAddToRecent,
|
||||
ofRegularFile,ofDoNotLoadResource,ofOnlyIfExists]);
|
||||
end;
|
||||
ntDependencies: ;
|
||||
ntDependency: ;
|
||||
ntDependency:
|
||||
begin
|
||||
// ToDo: open package editor
|
||||
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
@ -645,7 +665,7 @@ begin
|
||||
ND:=SelectedNodeData;
|
||||
if (ND=nil) or (ND.Target=nil) then
|
||||
exit;
|
||||
ND.Target.ParentProjectGroup.ActivateTarget(ND.Target);
|
||||
ND.Target.Activate(true);
|
||||
end;
|
||||
|
||||
procedure TProjectGroupEditorForm.ATargetCompileCleanExecute(Sender: TObject);
|
||||
@ -675,7 +695,10 @@ Var
|
||||
begin
|
||||
ND:=SelectedNodeData;
|
||||
if (ND=nil) or (ND.Target=nil) then exit;
|
||||
ND.Target.ParentProjectGroup.Perform(ND.Target,ATargetAction);
|
||||
if ND.Target.ProjectGroup<>nil then
|
||||
ND.Target.ProjectGroup.Perform(ND.Target,ATargetAction)
|
||||
else if ND.Target.Parent.ProjectGroup<>nil then
|
||||
ND.Target.Parent.ProjectGroup.Perform(ND.Target,ATargetAction);
|
||||
end;
|
||||
|
||||
procedure TProjectGroupEditorForm.ATargetCompileExecute(Sender: TObject);
|
||||
@ -1145,7 +1168,7 @@ begin
|
||||
Case T.TargetType of
|
||||
ttProject: FillProjectNode(AParent,T);
|
||||
ttPackage: FillPackageNode(AParent,T);
|
||||
ttProjectGroup: FillProjectgroupNode(AParent,T.ParentProjectGroup,PN);
|
||||
ttProjectGroup: FillProjectgroupNode(AParent,T.ProjectGroup,PN);
|
||||
end;
|
||||
finally
|
||||
TVPG.EndUpdate;
|
||||
|
@ -54,7 +54,6 @@ Type
|
||||
FRemoved: boolean;
|
||||
protected
|
||||
FParent: TPGCompileTarget;
|
||||
FParentProjectGroup: TProjectGroup;
|
||||
FProjectGroup: TProjectGroup;
|
||||
function GetAllowedActions: TPGTargetActions; virtual; // By default, return all allowed actions for target type.
|
||||
function GetFileCount: integer; virtual; abstract;
|
||||
@ -63,13 +62,14 @@ Type
|
||||
function GetRequiredPackages(Index: integer): TPGDependency; virtual; abstract;
|
||||
function Perform(AAction: TPGTargetAction): TPGActionResult;
|
||||
function PerformAction(AAction: TPGTargetAction): TPGActionResult; virtual; abstract;
|
||||
procedure Activate; virtual;
|
||||
procedure DeActivate; virtual;
|
||||
procedure SetFilename(const AValue: string); virtual;
|
||||
procedure SetRemoved(const AValue: boolean); virtual;
|
||||
procedure SetTargetType(AValue: TPGTargetType); virtual;
|
||||
procedure DoDeactivateChildren;
|
||||
public
|
||||
constructor Create(aParent: TPGCompileTarget);
|
||||
procedure Activate(DeactivateChildren: boolean); virtual;
|
||||
procedure DeActivate(DeactivateParents: boolean); virtual;
|
||||
property Parent: TPGCompileTarget read FParent;
|
||||
property Filename: string read FFilename write SetFilename; // Absolute, not relative. (ToDo: store them relative)
|
||||
property Removed: boolean read FRemoved write SetRemoved;
|
||||
@ -78,7 +78,6 @@ Type
|
||||
// Currently allowed actions.
|
||||
property AllowedActions: TPGTargetActions Read GetAllowedActions;
|
||||
//
|
||||
property ParentProjectGroup: TProjectGroup Read FParentProjectGroup;
|
||||
property ProjectGroup: TProjectGroup read FProjectGroup; // set if TargetType is ttProjectGroup
|
||||
property Files[Index: integer]: string read GetFiles;
|
||||
property FileCount: integer read GetFileCount;
|
||||
@ -250,7 +249,6 @@ end;
|
||||
procedure TProjectGroup.SetActiveTarget(AValue: TPGCompileTarget);
|
||||
begin
|
||||
ActivateTarget(AValue);
|
||||
IncreaseChangeStamp;
|
||||
end;
|
||||
|
||||
procedure TProjectGroup.SetModified(AValue: Boolean);
|
||||
@ -385,18 +383,8 @@ begin
|
||||
end;
|
||||
|
||||
procedure TProjectGroup.ActivateTarget(Target: TPGCompileTarget);
|
||||
var
|
||||
I: Integer;
|
||||
TD: TPGCompileTarget;
|
||||
begin
|
||||
if Target.Active then exit;
|
||||
for I:=0 to TargetCount-1 do
|
||||
begin
|
||||
TD:=GetTarget(I);
|
||||
if TD.Active then
|
||||
TD.Deactivate;
|
||||
end;
|
||||
Target.Activate;
|
||||
Target.Activate(true);
|
||||
end;
|
||||
|
||||
procedure TProjectGroup.IncreaseChangeStamp;
|
||||
@ -436,6 +424,14 @@ begin
|
||||
FTargetType:=AValue;
|
||||
end;
|
||||
|
||||
procedure TPGCompileTarget.DoDeactivateChildren;
|
||||
var
|
||||
i: Integer;
|
||||
begin
|
||||
for i:=0 to ProjectGroup.TargetCount-1 do
|
||||
ProjectGroup.Targets[i].DeActivate(false);
|
||||
end;
|
||||
|
||||
constructor TPGCompileTarget.Create(aParent: TPGCompileTarget);
|
||||
begin
|
||||
FParent:=aParent;
|
||||
@ -447,25 +443,51 @@ begin
|
||||
FFileName:=AValue;
|
||||
TargetType:=TargetTypeFromExtenstion(ExtractFileExt(AValue));
|
||||
if ProjectGroup<>nil then
|
||||
ProjectGroup.FileName:=Filename;
|
||||
ProjectGroup.FileName:=Filename;
|
||||
end;
|
||||
|
||||
procedure TPGCompileTarget.SetRemoved(const AValue: boolean);
|
||||
begin
|
||||
if Removed=AValue then exit;
|
||||
FRemoved:=AValue;
|
||||
If FRemoved then
|
||||
Deactivate;
|
||||
if FRemoved then
|
||||
Deactivate(true);
|
||||
end;
|
||||
|
||||
procedure TPGCompileTarget.Activate;
|
||||
procedure TPGCompileTarget.Activate(DeactivateChildren: boolean);
|
||||
var
|
||||
OldActive: TPGCompileTarget;
|
||||
PG: TProjectGroup;
|
||||
begin
|
||||
if DeactivateChildren then
|
||||
DoDeactivateChildren;
|
||||
if Active then exit;
|
||||
if Parent<>nil then
|
||||
begin
|
||||
PG:=Parent.ProjectGroup;
|
||||
if PG<>nil then
|
||||
begin
|
||||
OldActive:=PG.ActiveTarget;
|
||||
if OldActive<>nil then
|
||||
OldActive.DeActivate(false);
|
||||
end;
|
||||
Parent.Activate(false);
|
||||
PG.IncreaseChangeStamp;
|
||||
end;
|
||||
FActive:=True;
|
||||
end;
|
||||
|
||||
procedure TPGCompileTarget.DeActivate;
|
||||
procedure TPGCompileTarget.DeActivate(DeactivateParents: boolean);
|
||||
begin
|
||||
if not Active then exit;
|
||||
if ProjectGroup<>nil then
|
||||
begin
|
||||
ProjectGroup.IncreaseChangeStamp;
|
||||
DoDeactivateChildren;
|
||||
end;
|
||||
FActive:=False;
|
||||
if DeactivateParents and (Parent<>nil) then
|
||||
Parent.DeActivate(true);
|
||||
end;
|
||||
|
||||
function TPGCompileTarget.Perform(AAction: TPGTargetAction): TPGActionResult;
|
||||
|
Loading…
Reference in New Issue
Block a user