mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-11-07 13:37:44 +01:00
IDE ProjectInspector&PackageEditor: select active editor file
This commit is contained in:
parent
5864b5984c
commit
aae7ed1f94
@ -9,12 +9,12 @@ object ProjectInspectorForm: TProjectInspectorForm
|
||||
Caption = 'ProjectInspectorForm'
|
||||
ClientHeight = 485
|
||||
ClientWidth = 463
|
||||
LCLVersion = '3.99.0.0'
|
||||
OnActivate = FormActivate
|
||||
OnCreate = FormCreate
|
||||
OnDeactivate = FormDeactivate
|
||||
OnDestroy = FormDestroy
|
||||
OnDropFiles = FormDropFiles
|
||||
LCLVersion = '2.3.0.0'
|
||||
object ItemsTreeView: TTreeView
|
||||
Left = 0
|
||||
Height = 261
|
||||
@ -30,12 +30,12 @@ object ProjectInspectorForm: TProjectInspectorForm
|
||||
ReadOnly = True
|
||||
RightClickSelect = True
|
||||
TabOrder = 0
|
||||
Options = [tvoAllowMultiselect, tvoAutoItemHeight, tvoHideSelection, tvoKeepCollapsedNodes, tvoReadOnly, tvoRightClickSelect, tvoShowButtons, tvoShowLines, tvoShowRoot, tvoToolTips, tvoThemedDraw]
|
||||
OnAdvancedCustomDrawItem = ItemsTreeViewAdvancedCustomDrawItem
|
||||
OnDblClick = ItemsTreeViewDblClick
|
||||
OnDragDrop = ItemsTreeViewDragDrop
|
||||
OnDragOver = ItemsTreeViewDragOver
|
||||
OnKeyDown = ItemsTreeViewKeyDown
|
||||
Options = [tvoAllowMultiselect, tvoAutoItemHeight, tvoHideSelection, tvoKeepCollapsedNodes, tvoReadOnly, tvoRightClickSelect, tvoShowButtons, tvoShowLines, tvoShowRoot, tvoToolTips, tvoThemedDraw]
|
||||
end
|
||||
object FilterPanel: TPanel
|
||||
Left = 0
|
||||
@ -61,9 +61,9 @@ object ProjectInspectorForm: TProjectInspectorForm
|
||||
BorderSpacing.Around = 2
|
||||
Constraints.MinHeight = 25
|
||||
Constraints.MinWidth = 25
|
||||
OnClick = OpenButtonClick
|
||||
ShowHint = True
|
||||
ParentShowHint = False
|
||||
OnClick = OpenButtonClick
|
||||
end
|
||||
object DirectoryHierarchyButton: TSpeedButton
|
||||
AnchorSideLeft.Control = OpenButton
|
||||
@ -81,9 +81,9 @@ object ProjectInspectorForm: TProjectInspectorForm
|
||||
Constraints.MinHeight = 25
|
||||
Constraints.MinWidth = 25
|
||||
GroupIndex = 1
|
||||
OnClick = DirectoryHierarchyButtonClick
|
||||
ShowHint = True
|
||||
ParentShowHint = False
|
||||
OnClick = DirectoryHierarchyButtonClick
|
||||
end
|
||||
object SortAlphabeticallyButton: TSpeedButton
|
||||
AnchorSideLeft.Control = DirectoryHierarchyButton
|
||||
@ -100,9 +100,9 @@ object ProjectInspectorForm: TProjectInspectorForm
|
||||
Constraints.MinHeight = 25
|
||||
Constraints.MinWidth = 25
|
||||
GroupIndex = 2
|
||||
OnClick = SortAlphabeticallyButtonClick
|
||||
ShowHint = True
|
||||
ParentShowHint = False
|
||||
OnClick = SortAlphabeticallyButtonClick
|
||||
end
|
||||
object FilterEdit: TTreeFilterEdit
|
||||
AnchorSideLeft.Control = SortAlphabeticallyButton
|
||||
@ -110,9 +110,10 @@ object ProjectInspectorForm: TProjectInspectorForm
|
||||
AnchorSideTop.Control = SortAlphabeticallyButton
|
||||
AnchorSideTop.Side = asrCenter
|
||||
Left = 95
|
||||
Height = 30
|
||||
Top = -1
|
||||
Height = 23
|
||||
Top = 3
|
||||
Width = 365
|
||||
OnAfterFilter = FilterEditAfterFilter
|
||||
ButtonWidth = 23
|
||||
Anchors = [akTop, akLeft, akRight]
|
||||
BorderSpacing.Left = 3
|
||||
|
||||
@ -69,7 +69,7 @@ uses
|
||||
ProjectIntf, PackageIntf, PackageLinkIntf, PackageDependencyIntf,
|
||||
// IDEIntf
|
||||
IDEHelpIntf, IDECommands, IDEDialogs, IDEImagesIntf, LazIDEIntf, ToolBarIntf,
|
||||
IdeIntfStrConsts, MenuIntf, FormEditingIntf, InputHistory,
|
||||
IdeIntfStrConsts, MenuIntf, FormEditingIntf, SrcEditorIntf, InputHistory,
|
||||
// IdeConfig
|
||||
EnvironmentOpts, IDEOptionDefs, TransferMacros, IDEProcs,
|
||||
// IDE
|
||||
@ -140,6 +140,7 @@ type
|
||||
procedure AddPopupMenuPopup(Sender: TObject);
|
||||
procedure CopyMoveToDirMenuItemClick(Sender: TObject);
|
||||
procedure DirectoryHierarchyButtonClick(Sender: TObject);
|
||||
procedure FilterEditAfterFilter(Sender: TObject);
|
||||
procedure FilterEditKeyDown(Sender: TObject; var Key: Word; {%H-}Shift: TShiftState);
|
||||
procedure FormActivate(Sender: TObject);
|
||||
procedure FormCreate(Sender: TObject);
|
||||
@ -202,6 +203,7 @@ type
|
||||
ImageIndexDirectory: integer;
|
||||
FFlags: TPEFlags;
|
||||
FPropGui: TProjPackFilePropGui;
|
||||
procedure ActiveEditorChanged(Sender: TObject);
|
||||
procedure AddMenuItemClick(Sender: TObject);
|
||||
function AddOneFile(aFilename: string): TModalResult;
|
||||
procedure DoAddMoreDialog;
|
||||
@ -230,6 +232,7 @@ type
|
||||
procedure UpdateProperties(Immediately: boolean = false);
|
||||
procedure UpdateButtons(Immediately: boolean = false);
|
||||
procedure UpdatePending;
|
||||
procedure SelectFileNode(const AFileName: string);
|
||||
protected
|
||||
procedure KeyDown(var Key: Word; Shift: TShiftState); override;
|
||||
procedure IdleHandler(Sender: TObject; var {%H-}Done: Boolean);
|
||||
@ -848,12 +851,16 @@ begin
|
||||
end;
|
||||
if OPMInterface <> nil then
|
||||
OPMInterface.AddPackageListNotification(@PackageListAvailable);
|
||||
if SourceEditorManagerIntf <> nil then
|
||||
SourceEditorManagerIntf.RegisterChangeEvent(semEditorActivate,@ActiveEditorChanged);
|
||||
end;
|
||||
|
||||
procedure TProjectInspectorForm.FormDestroy(Sender: TObject);
|
||||
begin
|
||||
if OPMInterface <> nil then
|
||||
OPMInterface.RemovePackageListNotification(@PackageListAvailable);
|
||||
if SourceEditorManagerIntf <> nil then
|
||||
SourceEditorManagerIntf.UnRegisterChangeEvent(semEditorActivate,@ActiveEditorChanged);
|
||||
end;
|
||||
|
||||
procedure TProjectInspectorForm.FormActivate(Sender: TObject);
|
||||
@ -1193,6 +1200,52 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TProjectInspectorForm.SelectFileNode(const AFileName: string);
|
||||
function _FindInChildren(_Parent: TTreeNode): TTreeNode;
|
||||
var
|
||||
TVNode: TTreeNode;
|
||||
NodeData: TPENodeData;
|
||||
Item: TObject;
|
||||
UInfo: TUnitInfo;
|
||||
begin
|
||||
Result := nil;
|
||||
|
||||
TVNode:=_Parent.GetFirstChild;
|
||||
while Assigned(TVNode) do
|
||||
begin
|
||||
if GetNodeDataItem(TVNode,NodeData,Item) and (Item is TUnitInfo) then
|
||||
begin
|
||||
UInfo := TUnitInfo(Item);
|
||||
if SameFileName(UInfo.GetFullFilename, AFileName) then
|
||||
Exit(TVNode);
|
||||
end;
|
||||
if TVNode.HasChildren then
|
||||
begin
|
||||
Result := _FindInChildren(TVNode);
|
||||
if Assigned(Result) then
|
||||
Exit;
|
||||
end;
|
||||
TVNode := TVNode.GetNextSibling;
|
||||
end;
|
||||
end;
|
||||
var
|
||||
FileNode: TTreeNode;
|
||||
begin
|
||||
if not Assigned(FFilesNode) then
|
||||
Exit;
|
||||
FileNode := _FindInChildren(FFilesNode);
|
||||
if Assigned(FileNode) then
|
||||
begin
|
||||
ItemsTreeView.BeginUpdate;
|
||||
try
|
||||
ItemsTreeView.ClearSelection;
|
||||
ItemsTreeView.Selected := FileNode;
|
||||
finally
|
||||
ItemsTreeView.EndUpdate;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TProjectInspectorForm.SortAlphabeticallyButtonClick(Sender: TObject);
|
||||
begin
|
||||
SortAlphabetically:=SortAlphabeticallyButton.Down;
|
||||
@ -1591,6 +1644,12 @@ begin
|
||||
ShowDirectoryHierarchy := EnvironmentOptions.ProjInspShowDirHierarchy;
|
||||
end;
|
||||
|
||||
procedure TProjectInspectorForm.ActiveEditorChanged(Sender: TObject);
|
||||
begin
|
||||
if Assigned(SourceEditorManagerIntf.ActiveEditor) then
|
||||
SelectFileNode(SourceEditorManagerIntf.ActiveEditor.FileName);
|
||||
end;
|
||||
|
||||
destructor TProjectInspectorForm.Destroy;
|
||||
begin
|
||||
IdleConnected:=false;
|
||||
@ -1644,6 +1703,11 @@ begin
|
||||
Result:=false;
|
||||
end;
|
||||
|
||||
procedure TProjectInspectorForm.FilterEditAfterFilter(Sender: TObject);
|
||||
begin
|
||||
ActiveEditorChanged(Sender);
|
||||
end;
|
||||
|
||||
function TProjectInspectorForm.FirstRequiredDependency: TPkgDependency;
|
||||
begin
|
||||
if LazProject<>nil then
|
||||
|
||||
@ -11,12 +11,12 @@ object PackageEditorForm: TPackageEditorForm
|
||||
Constraints.MinHeight = 300
|
||||
Constraints.MinWidth = 400
|
||||
KeyPreview = True
|
||||
LCLVersion = '3.99.0.0'
|
||||
OnClose = PackageEditorFormClose
|
||||
OnCloseQuery = PackageEditorFormCloseQuery
|
||||
OnCreate = FormCreate
|
||||
OnDestroy = FormDestroy
|
||||
OnDropFiles = FormDropFiles
|
||||
LCLVersion = '3.99.0.0'
|
||||
object ToolBar: TToolBar
|
||||
Left = 0
|
||||
Height = 48
|
||||
@ -32,19 +32,19 @@ object PackageEditorForm: TPackageEditorForm
|
||||
object PropsGroupBox: TGroupBox
|
||||
Left = 0
|
||||
Height = 216
|
||||
Top = 222
|
||||
Top = 216
|
||||
Width = 464
|
||||
Align = alBottom
|
||||
Caption = 'PropsGroupBox'
|
||||
ClientHeight = 200
|
||||
ClientWidth = 462
|
||||
ClientHeight = 196
|
||||
ClientWidth = 460
|
||||
ParentFont = False
|
||||
TabOrder = 3
|
||||
object PropsPageControl: TPageControl
|
||||
Left = 0
|
||||
Height = 200
|
||||
Height = 196
|
||||
Top = 0
|
||||
Width = 462
|
||||
Width = 460
|
||||
ActivePage = CommonOptionsTabSheet
|
||||
Align = alClient
|
||||
ParentFont = False
|
||||
@ -59,8 +59,8 @@ object PackageEditorForm: TPackageEditorForm
|
||||
end
|
||||
object StatusBar: TStatusBar
|
||||
Left = 0
|
||||
Height = 17
|
||||
Top = 438
|
||||
Height = 23
|
||||
Top = 432
|
||||
Width = 464
|
||||
Panels = <>
|
||||
ParentFont = False
|
||||
@ -69,7 +69,7 @@ object PackageEditorForm: TPackageEditorForm
|
||||
Cursor = crVSplit
|
||||
Left = 0
|
||||
Height = 5
|
||||
Top = 217
|
||||
Top = 211
|
||||
Width = 464
|
||||
Align = alBottom
|
||||
ResizeAnchor = akBottom
|
||||
@ -102,10 +102,10 @@ object PackageEditorForm: TPackageEditorForm
|
||||
Constraints.MinHeight = 25
|
||||
Constraints.MinWidth = 25
|
||||
GroupIndex = 1
|
||||
OnClick = DirectoryHierarchyButtonClick
|
||||
ShowHint = True
|
||||
ParentFont = False
|
||||
ParentShowHint = False
|
||||
OnClick = DirectoryHierarchyButtonClick
|
||||
end
|
||||
object SortAlphabeticallyButton: TSpeedButton
|
||||
AnchorSideLeft.Control = DirectoryHierarchyButton
|
||||
@ -123,10 +123,10 @@ object PackageEditorForm: TPackageEditorForm
|
||||
Constraints.MinHeight = 25
|
||||
Constraints.MinWidth = 25
|
||||
GroupIndex = 2
|
||||
OnClick = SortAlphabeticallyButtonClick
|
||||
ShowHint = True
|
||||
ParentFont = False
|
||||
ParentShowHint = False
|
||||
OnClick = SortAlphabeticallyButtonClick
|
||||
end
|
||||
object FilterEdit: TTreeFilterEdit
|
||||
AnchorSideLeft.Control = MoveDownBtn
|
||||
@ -135,9 +135,10 @@ object PackageEditorForm: TPackageEditorForm
|
||||
AnchorSideTop.Side = asrCenter
|
||||
AnchorSideRight.Side = asrBottom
|
||||
Left = 163
|
||||
Height = 32
|
||||
Top = -2
|
||||
Height = 23
|
||||
Top = 3
|
||||
Width = 300
|
||||
OnAfterFilter = FilterEditAfterFilter
|
||||
ButtonWidth = 23
|
||||
Anchors = [akTop, akLeft, akRight]
|
||||
BorderSpacing.Left = 11
|
||||
@ -163,10 +164,10 @@ object PackageEditorForm: TPackageEditorForm
|
||||
BorderSpacing.Left = 3
|
||||
Constraints.MinHeight = 25
|
||||
Constraints.MinWidth = 25
|
||||
OnClick = OpenButtonClick
|
||||
ShowHint = True
|
||||
ParentFont = False
|
||||
ParentShowHint = False
|
||||
OnClick = OpenButtonClick
|
||||
end
|
||||
object MoveUpBtn: TSpeedButton
|
||||
AnchorSideLeft.Control = SortAlphabeticallyButton
|
||||
@ -181,10 +182,10 @@ object PackageEditorForm: TPackageEditorForm
|
||||
Constraints.MinHeight = 25
|
||||
Constraints.MinWidth = 25
|
||||
Enabled = False
|
||||
OnClick = MoveUpBtnClick
|
||||
ShowHint = True
|
||||
ParentFont = False
|
||||
ParentShowHint = False
|
||||
OnClick = MoveUpBtnClick
|
||||
end
|
||||
object MoveDownBtn: TSpeedButton
|
||||
AnchorSideLeft.Control = MoveUpBtn
|
||||
@ -199,15 +200,15 @@ object PackageEditorForm: TPackageEditorForm
|
||||
Constraints.MinHeight = 25
|
||||
Constraints.MinWidth = 25
|
||||
Enabled = False
|
||||
OnClick = MoveDownBtnClick
|
||||
ShowHint = True
|
||||
ParentFont = False
|
||||
ParentShowHint = False
|
||||
OnClick = MoveDownBtnClick
|
||||
end
|
||||
end
|
||||
object ItemsTreeView: TTreeView
|
||||
Left = 0
|
||||
Height = 140
|
||||
Height = 134
|
||||
Top = 77
|
||||
Width = 464
|
||||
Align = alClient
|
||||
@ -220,13 +221,13 @@ object PackageEditorForm: TPackageEditorForm
|
||||
ReadOnly = True
|
||||
RightClickSelect = True
|
||||
TabOrder = 2
|
||||
Options = [tvoAllowMultiselect, tvoAutoItemHeight, tvoHideSelection, tvoKeepCollapsedNodes, tvoReadOnly, tvoRightClickSelect, tvoShowButtons, tvoShowLines, tvoShowRoot, tvoToolTips, tvoThemedDraw]
|
||||
OnAdvancedCustomDrawItem = ItemsTreeViewAdvancedCustomDrawItem
|
||||
OnDblClick = ItemsTreeViewDblClick
|
||||
OnDragDrop = ItemsTreeViewDragDrop
|
||||
OnDragOver = ItemsTreeViewDragOver
|
||||
OnKeyDown = ItemsTreeViewKeyDown
|
||||
OnSelectionChanged = ItemsTreeViewSelectionChanged
|
||||
Options = [tvoAllowMultiselect, tvoAutoItemHeight, tvoHideSelection, tvoKeepCollapsedNodes, tvoReadOnly, tvoRightClickSelect, tvoShowButtons, tvoShowLines, tvoShowRoot, tvoToolTips, tvoThemedDraw]
|
||||
end
|
||||
object ItemsPopupMenu: TPopupMenu
|
||||
OnPopup = ItemsPopupMenuPopup
|
||||
|
||||
@ -48,7 +48,7 @@ uses
|
||||
IDEOptionsIntf, NewItemIntf, ComponentReg,
|
||||
// IDEIntf
|
||||
IDEImagesIntf, MenuIntf, LazIDEIntf, FormEditingIntf, IDEHelpIntf, InputHistory,
|
||||
IdeIntfStrConsts, IDEWindowIntf, IDEDialogs, IDEOptEditorIntf,
|
||||
IdeIntfStrConsts, IDEWindowIntf, IDEDialogs, IDEOptEditorIntf, SrcEditorIntf,
|
||||
// IdeConfig
|
||||
EnvironmentOpts, SearchPathProcs, ParsedCompilerOpts, CompilerOptions,
|
||||
// IDE
|
||||
@ -210,6 +210,7 @@ type
|
||||
procedure DirectoryHierarchyButtonClick(Sender: TObject);
|
||||
procedure EditVirtualUnitMenuItemClick(Sender: TObject);
|
||||
procedure ExpandDirectoryMenuItemClick(Sender: TObject);
|
||||
procedure FilterEditAfterFilter(Sender: TObject);
|
||||
procedure FilterEditKeyDown(Sender: TObject; var Key: Word; {%H-}Shift: TShiftState);
|
||||
procedure FindInFilesMenuItemClick(Sender: TObject);
|
||||
procedure FormCreate(Sender: TObject);
|
||||
@ -278,6 +279,7 @@ type
|
||||
FOptionsShownOfFile: TPkgFile;
|
||||
fUpdateLock: integer;
|
||||
fForcedFlags: TPEFlags;
|
||||
procedure ActiveEditorChanged(Sender: TObject);
|
||||
procedure DoAddNewFile(NewItem: TNewIDEItemTemplate);
|
||||
function CreateToolButton(AName, ACaption, AHint, AImageName: String;
|
||||
AOnClick: TNotifyEvent): TToolButton;
|
||||
@ -320,6 +322,7 @@ type
|
||||
procedure RegisteredListBoxDrawItem({%H-}Control: TWinControl; Index: Integer;
|
||||
ARect: TRect; {%H-}State: TOwnerDrawState);
|
||||
procedure DisableI18NForLFMCheckBoxChange(Sender: TObject);
|
||||
procedure SelectFileNode(const AFileName: string);
|
||||
protected
|
||||
fFlags: TPEFlags;
|
||||
procedure SetLazPackage(const AValue: TLazPackage); override;
|
||||
@ -1474,12 +1477,16 @@ begin
|
||||
ShowDirectoryHierarchy := EnvironmentOptions.PackageEditorShowDirHierarchy;
|
||||
if OPMInterface <> nil then
|
||||
OPMInterface.AddPackageListNotification(@PackageListAvailable);
|
||||
if SourceEditorManagerIntf <> nil then
|
||||
SourceEditorManagerIntf.RegisterChangeEvent(semEditorActivate,@ActiveEditorChanged);
|
||||
end;
|
||||
|
||||
procedure TPackageEditorForm.FormDestroy(Sender: TObject);
|
||||
begin
|
||||
if OPMInterface <> nil then
|
||||
OPMInterface.RemovePackageListNotification(@PackageListAvailable);
|
||||
if SourceEditorManagerIntf <> nil then
|
||||
SourceEditorManagerIntf.UnRegisterChangeEvent(semEditorActivate,@ActiveEditorChanged);
|
||||
IdleConnected:=false;
|
||||
FreeAndNil(FNextSelectedPart);
|
||||
EnvironmentOptions.PackageEditorSortAlphabetically := SortAlphabetically;
|
||||
@ -1540,6 +1547,52 @@ begin
|
||||
DoSave(false);
|
||||
end;
|
||||
|
||||
procedure TPackageEditorForm.SelectFileNode(const AFileName: string);
|
||||
function _FindInChildren(_Parent: TTreeNode): TTreeNode;
|
||||
var
|
||||
TVNode: TTreeNode;
|
||||
NodeData: TPENodeData;
|
||||
Item: TObject;
|
||||
PFile: TPkgFile;
|
||||
begin
|
||||
Result := nil;
|
||||
|
||||
TVNode:=_Parent.GetFirstChild;
|
||||
while Assigned(TVNode) do
|
||||
begin
|
||||
if GetNodeDataItem(TVNode,NodeData,Item) and (Item is TPkgFile) then
|
||||
begin
|
||||
PFile := TPkgFile(Item);
|
||||
if SameFileName(PFile.GetFullFilename, AFileName) then
|
||||
Exit(TVNode);
|
||||
end;
|
||||
if TVNode.HasChildren then
|
||||
begin
|
||||
Result := _FindInChildren(TVNode);
|
||||
if Assigned(Result) then
|
||||
Exit;
|
||||
end;
|
||||
TVNode := TVNode.GetNextSibling;
|
||||
end;
|
||||
end;
|
||||
var
|
||||
FileNode: TTreeNode;
|
||||
begin
|
||||
if not Assigned(FFilesNode) then
|
||||
Exit;
|
||||
FileNode := _FindInChildren(FFilesNode);
|
||||
if Assigned(FileNode) then
|
||||
begin
|
||||
ItemsTreeView.BeginUpdate;
|
||||
try
|
||||
ItemsTreeView.ClearSelection;
|
||||
ItemsTreeView.Selected := FileNode;
|
||||
finally
|
||||
ItemsTreeView.EndUpdate;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TPackageEditorForm.SaveAsClick(Sender: TObject);
|
||||
begin
|
||||
DoSave(true);
|
||||
@ -3038,6 +3091,11 @@ begin
|
||||
Result:=LazPackage.ReadOnly;
|
||||
end;
|
||||
|
||||
procedure TPackageEditorForm.FilterEditAfterFilter(Sender: TObject);
|
||||
begin
|
||||
ActiveEditorChanged(Sender)
|
||||
end;
|
||||
|
||||
function TPackageEditorForm.FirstRequiredDependency: TPkgDependency;
|
||||
begin
|
||||
Result:=LazPackage.FirstRequiredDependency;
|
||||
@ -3245,6 +3303,12 @@ begin
|
||||
inherited Create(TheOwner);
|
||||
end;
|
||||
|
||||
procedure TPackageEditorForm.ActiveEditorChanged(Sender: TObject);
|
||||
begin
|
||||
if Assigned(SourceEditorManagerIntf.ActiveEditor) then
|
||||
SelectFileNode(SourceEditorManagerIntf.ActiveEditor.FileName);
|
||||
end;
|
||||
|
||||
destructor TPackageEditorForm.Destroy;
|
||||
begin
|
||||
inherited Destroy;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user