mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-07 11:16:07 +02:00
IDE: select frame: search frames
git-svn-id: trunk@42315 -
This commit is contained in:
parent
17fe854c92
commit
50b4700212
@ -335,7 +335,6 @@ function FindLFMBaseClass(aFilename: string): TPFComponentBaseClass;
|
|||||||
var
|
var
|
||||||
LFMFilename: String;
|
LFMFilename: String;
|
||||||
LFMType: String;
|
LFMType: String;
|
||||||
LFMComponentName: String;
|
|
||||||
LFMClassName: String;
|
LFMClassName: String;
|
||||||
Code: TCodeBuffer;
|
Code: TCodeBuffer;
|
||||||
Tool: TCodeTool;
|
Tool: TCodeTool;
|
||||||
@ -344,6 +343,7 @@ var
|
|||||||
i: Integer;
|
i: Integer;
|
||||||
Context: PFindContext;
|
Context: PFindContext;
|
||||||
AClassName: String;
|
AClassName: String;
|
||||||
|
LFMCode: TCodeBuffer;
|
||||||
begin
|
begin
|
||||||
Result:=pfcbcNone;
|
Result:=pfcbcNone;
|
||||||
if not FilenameIsPascalUnit(aFilename) then exit;
|
if not FilenameIsPascalUnit(aFilename) then exit;
|
||||||
@ -351,8 +351,10 @@ begin
|
|||||||
LFMFilename:=ChangeFileExt(aFilename,'.lfm');
|
LFMFilename:=ChangeFileExt(aFilename,'.lfm');
|
||||||
if not FileExistsCached(LFMFilename) then exit;
|
if not FileExistsCached(LFMFilename) then exit;
|
||||||
if not FileExistsCached(aFilename) then exit;
|
if not FileExistsCached(aFilename) then exit;
|
||||||
if not ReadLFMHeaderFromFile(LFMFilename,LFMType,LFMComponentName,LFMClassName)
|
LFMCode:=CodeToolBoss.LoadFile(LFMFilename,true,false);
|
||||||
then exit;
|
if LFMCode=nil then exit;
|
||||||
|
ReadLFMHeader(LFMCode.Source,LFMClassName,LFMType);
|
||||||
|
if LFMClassName='' then exit;
|
||||||
Code:=CodeToolBoss.LoadFile(aFilename,true,false);
|
Code:=CodeToolBoss.LoadFile(aFilename,true,false);
|
||||||
if Code=nil then exit;
|
if Code=nil then exit;
|
||||||
if not CodeToolBoss.Explore(Code,Tool,false,true) then exit;
|
if not CodeToolBoss.Explore(Code,Tool,false,true) then exit;
|
||||||
|
32
ide/main.pp
32
ide/main.pp
@ -5634,8 +5634,8 @@ begin
|
|||||||
if (ItemType = piComponent) or
|
if (ItemType = piComponent) or
|
||||||
((ItemType = piFrame) and (CurUnitInfo.ResourceBaseClass = pfcbcFrame)) then
|
((ItemType = piFrame) and (CurUnitInfo.ResourceBaseClass = pfcbcFrame)) then
|
||||||
ItemList.AddObject(CurUnitInfo.Unit_Name,
|
ItemList.AddObject(CurUnitInfo.Unit_Name,
|
||||||
TViewUnitsEntry.Create(CurUnitInfo.ComponentName, i,
|
TViewUnitsEntry.Create(CurUnitInfo.ComponentName, CurUnitInfo.Filename,
|
||||||
CurUnitInfo = ActiveUnitInfo));
|
i, CurUnitInfo = ActiveUnitInfo));
|
||||||
end else if FilenameIsAbsolute(CurUnitInfo.Filename)
|
end else if FilenameIsAbsolute(CurUnitInfo.Filename)
|
||||||
and FilenameIsPascalSource(CurUnitInfo.Filename)
|
and FilenameIsPascalSource(CurUnitInfo.Filename)
|
||||||
and FileExistsCached(CurUnitInfo.Filename) then begin
|
and FileExistsCached(CurUnitInfo.Filename) then begin
|
||||||
@ -5649,7 +5649,7 @@ begin
|
|||||||
if anUnitName='' then
|
if anUnitName='' then
|
||||||
anUnitName:=ExtractFileNameOnly(LFMFilename);
|
anUnitName:=ExtractFileNameOnly(LFMFilename);
|
||||||
ItemList.AddObject(anUnitName,
|
ItemList.AddObject(anUnitName,
|
||||||
TViewUnitsEntry.Create(LFMComponentName, i,
|
TViewUnitsEntry.Create(LFMComponentName, CurUnitInfo.Filename, i,
|
||||||
CurUnitInfo = ActiveUnitInfo));
|
CurUnitInfo = ActiveUnitInfo));
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -5661,7 +5661,8 @@ begin
|
|||||||
AUnitName := ExtractFileName(CurUnitInfo.Filename);
|
AUnitName := ExtractFileName(CurUnitInfo.Filename);
|
||||||
if ItemList.IndexOf(AUnitName) = -1 then
|
if ItemList.IndexOf(AUnitName) = -1 then
|
||||||
ItemList.AddObject(AUnitName,
|
ItemList.AddObject(AUnitName,
|
||||||
TViewUnitsEntry.Create(AUnitName, i, CurUnitInfo = ActiveUnitInfo));
|
TViewUnitsEntry.Create(AUnitName, CurUnitInfo.Filename,
|
||||||
|
i, CurUnitInfo = ActiveUnitInfo));
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
if Project1.MainUnitID = i then
|
if Project1.MainUnitID = i then
|
||||||
@ -5673,7 +5674,8 @@ begin
|
|||||||
if (AUnitName <> '') and (ItemList.IndexOf(AUnitName) = -1) then
|
if (AUnitName <> '') and (ItemList.IndexOf(AUnitName) = -1) then
|
||||||
begin
|
begin
|
||||||
ItemList.AddObject(AUnitName,
|
ItemList.AddObject(AUnitName,
|
||||||
TViewUnitsEntry.Create(AUnitName, i, MainUnitInfo = ActiveUnitInfo));
|
TViewUnitsEntry.Create(AUnitName, MainUnitInfo.Filename,
|
||||||
|
i, MainUnitInfo = ActiveUnitInfo));
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -5762,6 +5764,7 @@ var
|
|||||||
AnUnitName: String;
|
AnUnitName: String;
|
||||||
AFilename: String;
|
AFilename: String;
|
||||||
UnitList: TStringList;
|
UnitList: TStringList;
|
||||||
|
Entry: TViewUnitsEntry;
|
||||||
begin
|
begin
|
||||||
Result:=mrCancel;
|
Result:=mrCancel;
|
||||||
GetCurrentUnit(ActiveSourceEditor, ActiveUnitInfo);
|
GetCurrentUnit(ActiveSourceEditor, ActiveUnitInfo);
|
||||||
@ -5818,19 +5821,19 @@ begin
|
|||||||
i:=0;
|
i:=0;
|
||||||
for S2SItem in UnitToFilename do begin
|
for S2SItem in UnitToFilename do begin
|
||||||
AnUnitName:=S2SItem^.Name;
|
AnUnitName:=S2SItem^.Name;
|
||||||
UnitList.AddObject(AnUnitName,TViewUnitsEntry.Create(AnUnitName,i,false));
|
AFilename:=S2SItem^.Value;
|
||||||
|
UnitList.AddObject(AnUnitName,TViewUnitsEntry.Create(AnUnitName,AFilename,i,false));
|
||||||
inc(i);
|
inc(i);
|
||||||
end;
|
end;
|
||||||
// show dialog
|
// show dialog
|
||||||
Result := ShowViewUnitsDlg(UnitList, MultiSelect, MultiSelectCheckedState, DlgCaption, ItemType, ActiveUnitInfo.Filename);
|
Result := ShowViewUnitsDlg(UnitList, MultiSelect, MultiSelectCheckedState,
|
||||||
|
DlgCaption, ItemType, ActiveUnitInfo.Filename);
|
||||||
|
|
||||||
// create list of selected files
|
// create list of selected files
|
||||||
i:=0;
|
for i:=0 to UnitList.Count-1 do begin
|
||||||
for S2SItem in UnitToFilename do begin
|
Entry:=TViewUnitsEntry(UnitList.Objects[i]);
|
||||||
AFilename:=S2SItem^.Value;
|
if Entry.Selected then
|
||||||
if TViewUnitsEntry(UnitList.Objects[i]).Selected then
|
Files.Add(Entry.Filename);
|
||||||
Files.Add(AFilename);
|
|
||||||
inc(i);
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
finally
|
finally
|
||||||
@ -6676,7 +6679,8 @@ Begin
|
|||||||
if (AnUnitInfo.IsPartOfProject) and (i<>Project1.MainUnitID) then
|
if (AnUnitInfo.IsPartOfProject) and (i<>Project1.MainUnitID) then
|
||||||
begin
|
begin
|
||||||
AName := Project1.RemoveProjectPathFromFilename(AnUnitInfo.FileName);
|
AName := Project1.RemoveProjectPathFromFilename(AnUnitInfo.FileName);
|
||||||
ViewUnitEntries.AddObject(AName, TViewUnitsEntry.Create(AName,i,false));
|
ViewUnitEntries.AddObject(AName,
|
||||||
|
TViewUnitsEntry.Create(AName,AnUnitInfo.FileName,i,false));
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
if ShowViewUnitsDlg(ViewUnitEntries, true, MultiSelectCheckedState,
|
if ShowViewUnitsDlg(ViewUnitEntries, true, MultiSelectCheckedState,
|
||||||
|
@ -42,7 +42,8 @@ uses
|
|||||||
LazarusIdeStrConsts, IDEProcs, CustomFormEditor, LCLType, LCLIntf, LMessages,
|
LazarusIdeStrConsts, IDEProcs, CustomFormEditor, LCLType, LCLIntf, LMessages,
|
||||||
ExtCtrls, ButtonPanel, Menus, StrUtils, AVL_Tree, ImgList, ComCtrls,
|
ExtCtrls, ButtonPanel, Menus, StrUtils, AVL_Tree, ImgList, ComCtrls,
|
||||||
PackageDefs, IDEWindowIntf, IDEHelpIntf, IDEImagesIntf, ListFilterEdit,
|
PackageDefs, IDEWindowIntf, IDEHelpIntf, IDEImagesIntf, ListFilterEdit,
|
||||||
CodeToolsStructs, CodeToolManager, lazutf8sysutils, LazFileUtils, LazLogger;
|
CodeToolsStructs, CodeToolManager, FileProcs, lazutf8sysutils, LazFileUtils,
|
||||||
|
LazLogger;
|
||||||
|
|
||||||
type
|
type
|
||||||
TIDEProjectItem = (
|
TIDEProjectItem = (
|
||||||
@ -51,12 +52,15 @@ type
|
|||||||
piFrame
|
piFrame
|
||||||
);
|
);
|
||||||
|
|
||||||
|
{ TViewUnitsEntry }
|
||||||
|
|
||||||
TViewUnitsEntry = class
|
TViewUnitsEntry = class
|
||||||
public
|
public
|
||||||
Name: string;
|
Name: string;
|
||||||
ID: integer;
|
ID: integer;
|
||||||
Selected: boolean;
|
Selected: boolean;
|
||||||
constructor Create(const AName: string; AnID: integer; ASelected: boolean);
|
Filename: string;
|
||||||
|
constructor Create(const AName, AFilename: string; AnID: integer; ASelected: boolean);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ TViewUnitDialog }
|
{ TViewUnitDialog }
|
||||||
@ -124,35 +128,35 @@ var
|
|||||||
i: integer;
|
i: integer;
|
||||||
begin
|
begin
|
||||||
ViewUnitDialog:=TViewUnitDialog.Create(nil);
|
ViewUnitDialog:=TViewUnitDialog.Create(nil);
|
||||||
with ViewUnitDialog do
|
|
||||||
try
|
try
|
||||||
Init(aCaption,AllowMultiSelect,CheckMultiSelect,ItemType,Entries,
|
ViewUnitDialog.Init(aCaption,AllowMultiSelect,CheckMultiSelect,ItemType,Entries,
|
||||||
StartFilename);
|
StartFilename);
|
||||||
// Show the dialog
|
// Show the dialog
|
||||||
Result:=ShowModal;
|
Result:=ViewUnitDialog.ShowModal;
|
||||||
if Result=mrOk then begin
|
if Result=mrOk then begin
|
||||||
// Return new selections from the dialog
|
// Return new selections from the dialog
|
||||||
FilterEdit.StoreSelection;
|
ViewUnitDialog.FilterEdit.StoreSelection;
|
||||||
for i:=0 to Entries.Count-1 do begin
|
for i:=0 to Entries.Count-1 do begin
|
||||||
UEntry:=TViewUnitsEntry(Entries.Objects[i]);
|
UEntry:=TViewUnitsEntry(Entries.Objects[i]);
|
||||||
UEntry.Selected:=FilterEdit.SelectionList.IndexOf(UEntry.Name)>-1;
|
UEntry.Selected:=ViewUnitDialog.FilterEdit.SelectionList.IndexOf(UEntry.Name)>-1;
|
||||||
end;
|
end;
|
||||||
CheckMultiSelect := mniMultiselect.Checked;
|
CheckMultiSelect := ViewUnitDialog.mniMultiselect.Checked;
|
||||||
end;
|
end;
|
||||||
finally
|
finally
|
||||||
Free;
|
ViewUnitDialog.Free;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ TViewUnitsEntry }
|
{ TViewUnitsEntry }
|
||||||
|
|
||||||
constructor TViewUnitsEntry.Create(const AName: string; AnID: integer;
|
constructor TViewUnitsEntry.Create(const AName, AFilename: string;
|
||||||
ASelected: boolean);
|
AnID: integer; ASelected: boolean);
|
||||||
begin
|
begin
|
||||||
inherited Create;
|
inherited Create;
|
||||||
Name := AName;
|
Name := AName;
|
||||||
ID := AnID;
|
ID := AnID;
|
||||||
Selected := ASelected;
|
Selected := ASelected;
|
||||||
|
Filename := AFilename;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ TViewUnitDialog }
|
{ TViewUnitDialog }
|
||||||
@ -229,6 +233,7 @@ procedure TViewUnitDialog.OnIdle(Sender: TObject; var Done: Boolean);
|
|||||||
var
|
var
|
||||||
CompClass: TPFComponentBaseClass;
|
CompClass: TPFComponentBaseClass;
|
||||||
begin
|
begin
|
||||||
|
//debugln(['CheckFile ',aFilename]);
|
||||||
case ItemType of
|
case ItemType of
|
||||||
piUnit:
|
piUnit:
|
||||||
begin
|
begin
|
||||||
@ -252,8 +257,29 @@ procedure TViewUnitDialog.OnIdle(Sender: TObject; var Done: Boolean);
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
procedure CheckDirectory(aDirectory: string);
|
procedure CheckDirectory(aDirectory: string);
|
||||||
|
var
|
||||||
|
Files: TStrings;
|
||||||
|
i: Integer;
|
||||||
|
aFilename: String;
|
||||||
begin
|
begin
|
||||||
DebugLn(['CheckDirectory ',aDirectory]);
|
aDirectory:=AppendPathDelim(aDirectory);
|
||||||
|
//DebugLn(['CheckDirectory ',aDirectory]);
|
||||||
|
Files:=nil;
|
||||||
|
try
|
||||||
|
CodeToolBoss.DirectoryCachePool.GetListing(aDirectory,Files,false);
|
||||||
|
if Files=nil then exit;
|
||||||
|
for i:=0 to Files.Count-1 do begin
|
||||||
|
aFilename:=Files[i];
|
||||||
|
if not FilenameIsPascalUnit(aFilename) then continue;
|
||||||
|
aFilename:=aDirectory+aFilename;
|
||||||
|
if (ItemType in [piComponent,piFrame])
|
||||||
|
and (not FileExistsCached(ChangeFileExt(aFilename,'.lfm'))) then
|
||||||
|
continue;
|
||||||
|
fSearchFiles[aFilename]:='';
|
||||||
|
end;
|
||||||
|
finally
|
||||||
|
Files.Free;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
var
|
var
|
||||||
@ -266,20 +292,21 @@ begin
|
|||||||
AVLNode:=fSearchFiles.Tree.FindLowest;
|
AVLNode:=fSearchFiles.Tree.FindLowest;
|
||||||
if AVLNode<>nil then begin
|
if AVLNode<>nil then begin
|
||||||
aFilename:=fSearchFiles.GetNodeData(AVLNode)^.Name;
|
aFilename:=fSearchFiles.GetNodeData(AVLNode)^.Name;
|
||||||
CheckFile(aFilename);
|
|
||||||
fSearchFiles.Remove(aFilename);
|
fSearchFiles.Remove(aFilename);
|
||||||
|
CheckFile(aFilename);
|
||||||
end else begin
|
end else begin
|
||||||
AVLNode:=fSearchDirectories.Tree.FindLowest;
|
AVLNode:=fSearchDirectories.Tree.FindLowest;
|
||||||
if AVLNode<>nil then begin
|
if AVLNode<>nil then begin
|
||||||
aFilename:=fSearchDirectories.GetNodeData(AVLNode)^.Name;
|
aFilename:=fSearchDirectories.GetNodeData(AVLNode)^.Name;
|
||||||
CheckDirectory(aFilename);
|
|
||||||
fSearchDirectories.Remove(aFilename);
|
fSearchDirectories.Remove(aFilename);
|
||||||
end else
|
CheckDirectory(aFilename);
|
||||||
break;
|
end else begin
|
||||||
|
// ToDo: update entries from fFoundFiles
|
||||||
|
IdleConnected:=false;
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
// ToDo: update entries from fFoundFiles
|
|
||||||
IdleConnected:=false;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TViewUnitDialog.FormDestroy(Sender: TObject);
|
procedure TViewUnitDialog.FormDestroy(Sender: TObject);
|
||||||
|
Loading…
Reference in New Issue
Block a user