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