diff --git a/components/projectgroups/prjgrpoptionsfrm.pas b/components/projectgroups/prjgrpoptionsfrm.pas index 92a478494f..6ebb694cf1 100644 --- a/components/projectgroups/prjgrpoptionsfrm.pas +++ b/components/projectgroups/prjgrpoptionsfrm.pas @@ -75,8 +75,11 @@ begin Opts.OpenLastGroupOnStart:=OpenLastGroupOnStartCheckBox.Checked; Opts.ShowTargetPaths:=ShowTargetPathsCheckBox.Checked; - if Opts.Modified then + if Opts.Modified then begin Opts.SaveSafe; + if IDEProjectGroupManager.Editor<>nil then + IDEProjectGroupManager.Editor.Invalidate; + end; end; procedure TProjGrpOptionsFrame.RestoreSettings(AOptions: TAbstractIDEOptions); diff --git a/components/projectgroups/projectgroup.pp b/components/projectgroups/projectgroup.pp index cbeba9c557..5921ab16ef 100644 --- a/components/projectgroups/projectgroup.pp +++ b/components/projectgroups/projectgroup.pp @@ -139,6 +139,7 @@ type procedure RemoveTarget(Index: Integer); override; procedure ExchangeTargets(OldIndex, NewIndex: Integer); override; procedure ActiveTargetChanged(T: TPGCompileTarget); + function UpdateMissing: boolean; override; function LoadFromFile(Options: TProjectGroupLoadOptions): Boolean; function SaveToFile: Boolean; property OnFileNameChange: TNotifyEvent Read FOnFileNameChange Write FOnFileNameChange; @@ -1001,6 +1002,28 @@ begin Root.OnTargetActiveChanged(Self,T); end; +function TIDEProjectGroup.UpdateMissing: boolean; +var + i: Integer; + Target: TPGCompileTarget; + Missing: Boolean; +begin + Result:=false; + for i:=0 to TargetCount-1 do + begin + Target:=Targets[i]; + Missing:=not FileExistsCached(Target.Filename); + if Target.Missing<>Missing then begin + Target.Missing:=Missing; + Result:=true; + end; + // todo sub groups + end; + if Result then + if ProjectGroupManager.Editor<>nil then + ProjectGroupManager.Editor.Invalidate; +end; + function TIDEProjectGroup.LoadFromFile(Options: TProjectGroupLoadOptions ): Boolean; Var diff --git a/components/projectgroups/projectgroupeditor.lfm b/components/projectgroups/projectgroupeditor.lfm index e6c4864202..fff2343438 100644 --- a/components/projectgroups/projectgroupeditor.lfm +++ b/components/projectgroups/projectgroupeditor.lfm @@ -9,6 +9,7 @@ object ProjectGroupEditorForm: TProjectGroupEditorForm OnCloseQuery = FormCloseQuery OnCreate = FormCreate OnDestroy = FormDestroy + OnShow = FormShow LCLVersion = '2.1.0.0' object TBProjectGroup: TToolBar Left = 0 @@ -101,6 +102,7 @@ object ProjectGroupEditorForm: TProjectGroupEditorForm RightClickSelect = True StateImages = ImageListMain TabOrder = 1 + OnAdvancedCustomDrawItem = TVPGAdvancedCustomDrawItem OnDblClick = TVPGDblClick OnMouseDown = TVPGMouseDown OnSelectionChanged = TVPGSelectionChanged diff --git a/components/projectgroups/projectgroupeditor.pas b/components/projectgroups/projectgroupeditor.pas index ec154ba688..fa2dae6309 100644 --- a/components/projectgroups/projectgroupeditor.pas +++ b/components/projectgroups/projectgroupeditor.pas @@ -140,7 +140,11 @@ type procedure FormCloseQuery(Sender: TObject; var CanClose: boolean); procedure FormCreate(Sender: TObject); procedure FormDestroy(Sender: TObject); + procedure FormShow(Sender: TObject); procedure PopupMenuMorePopup(Sender: TObject); + procedure TVPGAdvancedCustomDrawItem(Sender: TCustomTreeView; + Node: TTreeNode; {%H-}State: TCustomDrawState; Stage: TCustomDrawStage; + var {%H-}PaintImages, {%H-}DefaultDraw: Boolean); procedure TVPGDblClick(Sender: TObject); procedure TVPGMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); @@ -152,6 +156,7 @@ type // Project group callbacks procedure InitTVNode(Node: TTreeNode; Const ACaption: String; ANodeData: TNodeData); + procedure OnApplicationActivate(Sender: TObject); procedure OnIDEClose(Sender: TObject); procedure OnProjectGroupDestroy(Sender: TObject); procedure OnProjectGroupFileNameChanged(Sender: TObject); @@ -513,6 +518,7 @@ procedure TProjectGroupEditorForm.FormCreate(Sender: TObject); begin if ProjectGroupEditorForm=nil then ProjectGroupEditorForm:=Self; + ProjectGroupManager.Editor:=Self; PGEditMenuSectionMisc.MenuItem:=PopupMenuMore.Items; SetItem(MnuCmdTargetAdd,@AProjectGroupAddExistingExecute); SetItem(MnuCmdTargetRemove,@AProjectGroupDeleteExecute); @@ -528,18 +534,25 @@ begin SetItem(MnuCmdProjGrpRedo,@AProjectGroupRedoExecute); LazarusIDE.AddHandlerOnIDEClose(@OnIDEClose); + Application.AddOnActivateHandler(@OnApplicationActivate); end; procedure TProjectGroupEditorForm.FormDestroy(Sender: TObject); begin - debugln(['TProjectGroupEditorForm.FormDestroy START ',ProjectGroup<>nil]); + //debugln(['TProjectGroupEditorForm.FormDestroy START ',ProjectGroup<>nil]); ProjectGroup:=nil; if ProjectGroupEditorForm=Self then ProjectGroupEditorForm:=nil; + ProjectGroupManager.Editor:=Self; if (PGEditMenuSectionMisc<>nil) and (PGEditMenuSectionMisc.MenuItem=PopupMenuMore.Items) then PGEditMenuSectionMisc.MenuItem:=nil; - debugln(['TProjectGroupEditorForm.FormDestroy END ',ProjectGroup<>nil]); + //debugln(['TProjectGroupEditorForm.FormDestroy END ',ProjectGroup<>nil]); +end; + +procedure TProjectGroupEditorForm.FormShow(Sender: TObject); +begin + end; procedure TProjectGroupEditorForm.PopupMenuMorePopup(Sender: TObject); @@ -560,6 +573,26 @@ begin PMIRunMenuItem.Visible:=taRun in AllowedActions; end; +procedure TProjectGroupEditorForm.TVPGAdvancedCustomDrawItem( + Sender: TCustomTreeView; Node: TTreeNode; State: TCustomDrawState; + Stage: TCustomDrawStage; var PaintImages, DefaultDraw: Boolean); +var + ND: TNodeData; + r: TRect; + y: LongInt; +begin + if Stage=cdPostPaint then begin + ND:=TNodeData(Node.Data); + if (ND.Target<>nil) and ND.Target.Missing then begin + // Missing target file: draw red line strike through text + r:=Node.DisplayRect(true); + TVPG.Canvas.Pen.Color:=clRed; + y:=(r.Top+r.Bottom) div 2; + TVPG.Canvas.Line(r.Left,y,r.Right,y); + end; + end; +end; + procedure TProjectGroupEditorForm.TVPGDblClick(Sender: TObject); Var ND: TNodeData; @@ -800,6 +833,7 @@ begin // ToDo: revert IDEMessageDialog(lisNeedSave, lisPleaseSaveYourChangesBeforeReloadingTheProjectGrou, mtError,[mbOK]); + PG.UpdateMissing; exit; end; ProjectGroup:=nil; @@ -808,7 +842,8 @@ begin finally ProjectGroup:=PG; end; - end; + end else + PG.UpdateMissing; end; procedure TProjectGroupEditorForm.AProjectGroupSaveAsUpdate(Sender: TObject); @@ -1139,6 +1174,12 @@ begin Node.StateIndex:=-1; end; +procedure TProjectGroupEditorForm.OnApplicationActivate(Sender: TObject); +begin + if ProjectGroup<>nil then + ProjectGroup.UpdateMissing; +end; + procedure TProjectGroupEditorForm.OnIDEClose(Sender: TObject); var Opts: TIDEProjectGroupOptions; @@ -1296,10 +1337,10 @@ begin if (NodeData.Target<>nil) and (not IDEProjectGroupManager.Options.ShowTargetPaths) then begin - if NodeData.Target.TargetType in [ttPascalFile] then - Result:=ExtractFileName(NodeData.Target.Filename) + if NodeData.Target.TargetType in [ttProject,ttPackage,ttProjectGroup] then + Result:=ExtractFileNameOnly(NodeData.Target.Filename) else - Result:=ExtractFileNameOnly(NodeData.Target.Filename); + Result:=ExtractFileName(NodeData.Target.Filename); end else begin Result:=''; if NodeData.ParentTarget<>nil then diff --git a/components/projectgroups/projectgroupintf.pp b/components/projectgroups/projectgroupintf.pp index bdf85e7478..34d6f9d2fd 100644 --- a/components/projectgroups/projectgroupintf.pp +++ b/components/projectgroups/projectgroupintf.pp @@ -8,7 +8,7 @@ interface uses Classes, SysUtils, IDEOptionsIntf, PackageIntf, ProjectIntf, LazFileUtils, - LazFileCache, LazMethodList, LazLoggerBase; + LazFileCache, LazMethodList, LazLoggerBase, Forms; Type TPGTargetType = ( @@ -173,6 +173,7 @@ Type property Targets[Index: Integer]: TPGCompileTarget Read GetTarget; property TargetCount: Integer Read GetTargetCount; property ActiveTarget: TPGCompileTarget Read GetActiveTarget Write SetActiveTarget; + function UpdateMissing: boolean; virtual; abstract; // true if something changed public // modified procedure IncreaseChangeStamp; @@ -198,6 +199,7 @@ Type TProjectGroupManager = Class(TPersistent) protected + FEditor: TForm; function GetCurrentProjectGroup: TProjectGroup; virtual; abstract; public procedure LoadProjectGroup(AFileName: string; AOptions: TProjectGroupLoadOptions); virtual; abstract; @@ -207,6 +209,7 @@ Type procedure Undo; virtual; abstract; procedure Redo; virtual; abstract; property CurrentProjectGroup: TProjectGroup Read GetCurrentProjectGroup; // Always top-level. + property Editor: TForm read FEditor write FEditor; end; var