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