mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-07 22:58:14 +02:00
Project Inspector: A new button for adding files from file system easily. Issue #24337.
git-svn-id: trunk@46311 -
This commit is contained in:
parent
3cc9bd1361
commit
e187809d73
@ -90,7 +90,7 @@ object AddToProjectDialog: TAddToProjectDialog
|
||||
Anchors = [akTop, akLeft, akRight]
|
||||
AutoComplete = True
|
||||
AutoCompleteText = [cbactEnabled, cbactEndOfLineComplete, cbactSearchAscending]
|
||||
ItemHeight = 0
|
||||
ItemHeight = 15
|
||||
OnChange = DependPkgNameComboBoxChange
|
||||
TabOrder = 0
|
||||
Text = 'DependPkgNameComboBox'
|
||||
@ -136,12 +136,11 @@ object AddToProjectDialog: TAddToProjectDialog
|
||||
OnSelectItem = FilesListViewSelectItem
|
||||
end
|
||||
object FilesDirButton: TBitBtn
|
||||
AnchorSideLeft.Control = FilesBrowseButton
|
||||
AnchorSideLeft.Side = asrBottom
|
||||
Left = 142
|
||||
Height = 28
|
||||
Top = 221
|
||||
Width = 102
|
||||
Left = 6
|
||||
Height = 27
|
||||
Top = 233
|
||||
Width = 96
|
||||
Anchors = [akLeft, akBottom]
|
||||
AutoSize = True
|
||||
BorderSpacing.Left = 6
|
||||
@ -149,44 +148,33 @@ object AddToProjectDialog: TAddToProjectDialog
|
||||
OnClick = FilesDirButtonClick
|
||||
TabOrder = 1
|
||||
end
|
||||
object FilesBrowseButton: TBitBtn
|
||||
Left = 6
|
||||
Height = 28
|
||||
Top = 221
|
||||
Width = 130
|
||||
Anchors = [akLeft, akBottom]
|
||||
AutoSize = True
|
||||
Caption = 'FilesBrowseButton'
|
||||
OnClick = FilesBrowseButtonClick
|
||||
TabOrder = 2
|
||||
end
|
||||
object FilesShortenButton: TBitBtn
|
||||
AnchorSideLeft.Control = FilesDirButton
|
||||
AnchorSideLeft.Side = asrBottom
|
||||
Left = 250
|
||||
Height = 28
|
||||
Top = 221
|
||||
Width = 135
|
||||
Left = 108
|
||||
Height = 27
|
||||
Top = 233
|
||||
Width = 126
|
||||
Anchors = [akLeft, akBottom]
|
||||
AutoSize = True
|
||||
BorderSpacing.Left = 6
|
||||
Caption = 'FilesShortenButton'
|
||||
OnClick = FilesShortenButtonClick
|
||||
TabOrder = 3
|
||||
TabOrder = 2
|
||||
end
|
||||
object FilesDeleteButton: TBitBtn
|
||||
AnchorSideLeft.Control = FilesShortenButton
|
||||
AnchorSideLeft.Side = asrBottom
|
||||
Left = 391
|
||||
Height = 28
|
||||
Top = 221
|
||||
Width = 126
|
||||
Left = 240
|
||||
Height = 27
|
||||
Top = 233
|
||||
Width = 118
|
||||
Anchors = [akLeft, akBottom]
|
||||
AutoSize = True
|
||||
BorderSpacing.Left = 6
|
||||
Caption = 'FilesDeleteButton'
|
||||
OnClick = FilesDeleteButtonClick
|
||||
TabOrder = 4
|
||||
TabOrder = 3
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -60,7 +60,6 @@ type
|
||||
TAddToProjectDialog = class(TForm)
|
||||
AddFileListView: TListView;
|
||||
ButtonPanel: TButtonPanel;
|
||||
FilesBrowseButton: TBitBtn;
|
||||
FilesDeleteButton: TBitBtn;
|
||||
FilesDirButton: TBitBtn;
|
||||
FilesShortenButton: TBitBtn;
|
||||
@ -91,14 +90,12 @@ type
|
||||
Selected: Boolean);
|
||||
procedure NewDependButtonClick(Sender: TObject);
|
||||
procedure FilesAddButtonClick(Sender: TObject);
|
||||
procedure FilesBrowseButtonClick(Sender: TObject);
|
||||
procedure FilesDeleteButtonClick(Sender: TObject);
|
||||
procedure FilesShortenButtonClick(Sender: TObject);
|
||||
procedure NotebookChange(Sender: TObject);
|
||||
private
|
||||
fPackages: TAVLTree;// tree of TLazPackage or TPackageLink
|
||||
function CheckAddingFile(NewFiles: TStringList; var NewFilename: string
|
||||
): TModalResult;
|
||||
function CheckAddingFile(NewFiles: TStringList; var NewFilename: string): TModalResult;
|
||||
procedure SetupComponents;
|
||||
procedure SetupAddEditorFilePage;
|
||||
procedure SetupAddRequirementPage;
|
||||
@ -359,50 +356,6 @@ begin
|
||||
ModalResult:=mrOk;
|
||||
end;
|
||||
|
||||
procedure TAddToProjectDialog.FilesBrowseButtonClick(Sender: TObject);
|
||||
var
|
||||
OpenDialog: TOpenDialog;
|
||||
AFilename: string;
|
||||
i: Integer;
|
||||
NewListItem: TListItem;
|
||||
NewPgkFileType: TPkgFileType;
|
||||
ADirectory: String;
|
||||
begin
|
||||
OpenDialog:=TOpenDialog.Create(nil);
|
||||
try
|
||||
InputHistories.ApplyFileDialogSettings(OpenDialog);
|
||||
ADirectory:=TheProject.ProjectDirectory;
|
||||
if not FilenameIsAbsolute(ADirectory) then ADirectory:='';
|
||||
if ADirectory<>'' then
|
||||
OpenDialog.InitialDir:=ADirectory;
|
||||
OpenDialog.Title:=lisOpenFile;
|
||||
OpenDialog.Options:=OpenDialog.Options
|
||||
+[ofFileMustExist,ofPathMustExist,ofAllowMultiSelect];
|
||||
OpenDialog.Filter:=dlgAllFiles+' ('+GetAllFilesMask+')|'+GetAllFilesMask
|
||||
+'|'+lisLazarusUnit+' (*.pas;*.pp)|*.pas;*.pp'
|
||||
+'|'+lisLazarusInclude+' (*.inc)|*.inc'
|
||||
+'|'+lisLazarusForm+' (*.lfm;*.dfm)|*.lfm;*.dfm';
|
||||
if OpenDialog.Execute then begin
|
||||
for i:=0 to OpenDialog.Files.Count-1 do begin
|
||||
AFilename:=CleanAndExpandFilename(OpenDialog.Files[i]);
|
||||
if FileExistsUTF8(AFilename) then begin
|
||||
NewPgkFileType:=FileNameToPkgFileType(AFilename);
|
||||
if ADirectory<>'' then
|
||||
AFilename:=CreateRelativePath(AFilename,ADirectory);
|
||||
NewListItem:=FilesListView.Items.Add;
|
||||
NewListItem.Caption:=AFilename;
|
||||
NewListItem.SubItems.Add(GetPkgFileTypeLocalizedName(NewPgkFileType));
|
||||
NewListItem.Selected:=True;
|
||||
end;
|
||||
end;
|
||||
UpdateFilesButtons;
|
||||
end;
|
||||
InputHistories.StoreFileDialogSettings(OpenDialog);
|
||||
finally
|
||||
OpenDialog.Free;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TAddToProjectDialog.FilesDeleteButtonClick(Sender: TObject);
|
||||
var
|
||||
i: Integer;
|
||||
@ -503,11 +456,6 @@ begin
|
||||
CurColumn:=FilesListView.Columns.Add;
|
||||
CurColumn.Caption:=dlgEnvType;
|
||||
|
||||
with FilesBrowseButton do begin
|
||||
Caption:=lisA2PAddFiles;
|
||||
LoadGlyphFromResourceName(HInstance, 'laz_add');
|
||||
end;
|
||||
|
||||
with FilesDirButton do begin
|
||||
Caption:=lisAddFilesInDirectory;
|
||||
LoadGlyphFromResourceName(HInstance, 'pkg_files');
|
||||
|
@ -44,6 +44,7 @@ resourcestring
|
||||
lisLazarus = 'Lazarus';
|
||||
lisAdd = 'Add';
|
||||
lisBtnAdd = '&Add';
|
||||
lisDlgAdd = 'Add ...';
|
||||
lisBtnDlgAdd = '&Add ...';
|
||||
lisApply = 'Apply';
|
||||
lisInsert = 'Insert';
|
||||
@ -58,6 +59,7 @@ resourcestring
|
||||
lisBtnReplace = '&Replace';
|
||||
lisBtnDlgReplace = '&Replace ...';
|
||||
lisEdit = 'Edit';
|
||||
lisDlgEdit = 'Edit ...';
|
||||
lisClear = 'Clear';
|
||||
lisOpen = 'Open';
|
||||
lisSave = 'Save';
|
||||
@ -1703,8 +1705,6 @@ resourcestring
|
||||
lisCompletionLongLineHintTypeRightOnly = 'Extend right only';
|
||||
lisCompletionLongLineHintTypeLittleLeft = 'Extend some left';
|
||||
lisCompletionLongLineHintTypeFullLeft = 'Extend far left';
|
||||
dlgEdAdd = 'Add ...';
|
||||
dlgEdEdit = 'Edit ...';
|
||||
lisAutomaticFeatures = 'Completion and Hints';
|
||||
lisAutoMarkup = 'Markup and Matches';
|
||||
|
||||
@ -4191,7 +4191,8 @@ resourcestring
|
||||
lisPckEditCompilerOptionsForPackage = 'Compiler Options for Package %s';
|
||||
lisPckEditSavePackage = 'Save Package';
|
||||
lisPckEditCompilePackage = 'Compile package';
|
||||
lisPckEditAddAnItem = 'Add an item';
|
||||
lisPckEditAddFiles = 'Add files from the file system';
|
||||
lisPckEditAddOtherItems = 'Add other items';
|
||||
lisPckEditRemoveSelectedItem = 'Remove selected item';
|
||||
lisPckEditInstallPackageInTheIDE = 'Install package in the IDE';
|
||||
lisUseSub = 'Use >>';
|
||||
|
@ -63,7 +63,7 @@ uses
|
||||
PackageIntf,
|
||||
// IDE
|
||||
LazarusIDEStrConsts, IDEProcs, DialogProcs, IDEOptionDefs, EnvironmentOpts,
|
||||
PackageDefs, Project, MainIntf, PackageEditor, AddToProjectDlg;
|
||||
PackageDefs, Project, MainIntf, PackageEditor, AddToProjectDlg, InputHistory;
|
||||
|
||||
type
|
||||
TOnAddUnitToProject =
|
||||
@ -97,10 +97,12 @@ type
|
||||
ToolBar: TToolBar;
|
||||
// toolbuttons
|
||||
AddBitBtn: TToolButton;
|
||||
AddMoreBitBtn: TToolButton;
|
||||
RemoveBitBtn: TToolButton;
|
||||
OptionsBitBtn: TToolButton;
|
||||
HelpBitBtn: TToolButton;
|
||||
procedure AddBitBtnClick(Sender: TObject);
|
||||
procedure AddMoreBitBtnClick(Sender: TObject);
|
||||
procedure CopyMoveToDirMenuItemClick(Sender: TObject);
|
||||
procedure DirectoryHierarchyButtonClick(Sender: TObject);
|
||||
procedure FormDropFiles(Sender: TObject; const FileNames: array of String);
|
||||
@ -159,6 +161,7 @@ type
|
||||
ImageIndexDirectory: integer;
|
||||
FFlags: TProjectInspectorFlags;
|
||||
FProjectNodeDataList : array [TPENodeType] of TPENodeData;
|
||||
function AddOneFile(aFilename: string): TModalResult;
|
||||
procedure FreeNodeData(Typ: TPENodeType);
|
||||
function CreateNodeData(Typ: TPENodeType; aName: string; aRemoved: boolean): TPENodeData;
|
||||
procedure SetDependencyDefaultFilename(AsPreferred: boolean);
|
||||
@ -373,7 +376,62 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
function TProjectInspectorForm.AddOneFile(aFilename: string): TModalResult;
|
||||
var
|
||||
NewFile: TUnitInfo;
|
||||
begin
|
||||
Result := mrOK;
|
||||
aFilename:=CleanAndExpandFilename(aFilename);
|
||||
NewFile:=LazProject.UnitInfoWithFilename(aFilename);
|
||||
if NewFile<>nil then begin
|
||||
if NewFile.IsPartOfProject then Exit(mrIgnore);
|
||||
end else begin
|
||||
NewFile:=TUnitInfo.Create(nil);
|
||||
NewFile.Filename:=aFilename;
|
||||
LazProject.AddFile(NewFile,false);
|
||||
end;
|
||||
NewFile.IsPartOfProject:=true;
|
||||
if Assigned(OnAddUnitToProject) then begin
|
||||
Result:=OnAddUnitToProject(Self,NewFile);
|
||||
if Result<>mrOK then Exit;
|
||||
end;
|
||||
FNextSelectedPart:=NewFile;
|
||||
end;
|
||||
|
||||
procedure TProjectInspectorForm.AddBitBtnClick(Sender: TObject);
|
||||
var
|
||||
OpenDialog: TOpenDialog;
|
||||
AFilename: string;
|
||||
i: Integer;
|
||||
NewListItem: TListItem;
|
||||
NewPgkFileType: TPkgFileType;
|
||||
ADirectory: String;
|
||||
begin
|
||||
OpenDialog:=TOpenDialog.Create(nil);
|
||||
try
|
||||
InputHistories.ApplyFileDialogSettings(OpenDialog);
|
||||
ADirectory:=LazProject.ProjectDirectory;
|
||||
if not FilenameIsAbsolute(ADirectory) then ADirectory:='';
|
||||
if ADirectory<>'' then
|
||||
OpenDialog.InitialDir:=ADirectory;
|
||||
OpenDialog.Title:=lisOpenFile;
|
||||
OpenDialog.Options:=OpenDialog.Options
|
||||
+[ofFileMustExist,ofPathMustExist,ofAllowMultiSelect];
|
||||
OpenDialog.Filter:=dlgAllFiles+' ('+GetAllFilesMask+')|'+GetAllFilesMask
|
||||
+'|'+lisLazarusUnit+' (*.pas;*.pp)|*.pas;*.pp'
|
||||
+'|'+lisLazarusInclude+' (*.inc)|*.inc'
|
||||
+'|'+lisLazarusForm+' (*.lfm;*.dfm)|*.lfm;*.dfm';
|
||||
if OpenDialog.Execute then begin
|
||||
for i:=0 to OpenDialog.Files.Count-1 do
|
||||
if not (AddOneFile(OpenDialog.Files[i]) in [mrOk, mrIgnore]) then break;
|
||||
end;
|
||||
InputHistories.StoreFileDialogSettings(OpenDialog);
|
||||
finally
|
||||
OpenDialog.Free;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TProjectInspectorForm.AddMoreBitBtnClick(Sender: TObject);
|
||||
var
|
||||
AddResult: TAddToProjectResult;
|
||||
i: Integer;
|
||||
@ -381,31 +439,17 @@ var
|
||||
NewFile: TUnitInfo;
|
||||
begin
|
||||
if ShowAddToProjectDlg(LazProject,AddResult)<>mrOk then exit;
|
||||
|
||||
|
||||
case AddResult.AddType of
|
||||
a2pFiles:
|
||||
begin
|
||||
BeginUpdate;
|
||||
for i:=0 to AddResult.FileNames.Count-1 do begin
|
||||
NewFilename:=AddResult.FileNames[i];
|
||||
NewFile:=LazProject.UnitInfoWithFilename(NewFilename);
|
||||
if NewFile<>nil then begin
|
||||
if NewFile.IsPartOfProject then continue;
|
||||
end else begin
|
||||
NewFile:=TUnitInfo.Create(nil);
|
||||
NewFile.Filename:=NewFilename;
|
||||
LazProject.AddFile(NewFile,false);
|
||||
end;
|
||||
NewFile.IsPartOfProject:=true;
|
||||
if Assigned(OnAddUnitToProject) then begin
|
||||
if OnAddUnitToProject(Self,NewFile)<>mrOk then break;
|
||||
end;
|
||||
FNextSelectedPart:=NewFile;
|
||||
end;
|
||||
for i:=0 to AddResult.FileNames.Count-1 do
|
||||
if not (AddOneFile(AddResult.FileNames[i]) in [mrOk, mrIgnore]) then break;
|
||||
UpdateAll;
|
||||
EndUpdate;
|
||||
end;
|
||||
|
||||
|
||||
a2pRequiredPkg:
|
||||
begin
|
||||
BeginUpdate;
|
||||
@ -415,9 +459,9 @@ begin
|
||||
UpdateRequiredPackages;
|
||||
EndUpdate;
|
||||
end;
|
||||
|
||||
|
||||
end;
|
||||
|
||||
|
||||
AddResult.Free;
|
||||
end;
|
||||
|
||||
@ -444,24 +488,9 @@ begin
|
||||
if length(FileNames)=0 then exit;
|
||||
BeginUpdate;
|
||||
try
|
||||
for i:=0 to high(Filenames) do begin
|
||||
NewFilename:=CleanAndExpandFilename(FileNames[i]);
|
||||
if not FileExistsUTF8(NewFilename) then continue;
|
||||
if DirPathExists(NewFilename) then continue;
|
||||
NewFile:=LazProject.UnitInfoWithFilename(NewFilename);
|
||||
if (NewFile<>nil) and (NewFile.IsPartOfProject) then continue;
|
||||
{$IFDEF VerboseProjInspDrag}
|
||||
debugln(['TProjectInspectorForm.FormDropFiles Adding files: ',NewFilename]);
|
||||
{$ENDIF}
|
||||
if NewFile=nil then begin
|
||||
NewFile:=TUnitInfo.Create(nil);
|
||||
NewFile.Filename:=NewFilename;
|
||||
LazProject.AddFile(NewFile,false);
|
||||
end;
|
||||
if OnAddUnitToProject(Self,NewFile)<>mrOk then
|
||||
break;
|
||||
UpdateAll;
|
||||
end;
|
||||
for i:=0 to high(Filenames) do
|
||||
if not (AddOneFile(FileNames[i]) in [mrOk, mrIgnore]) then break;
|
||||
UpdateAll;
|
||||
finally
|
||||
EndUpdate;
|
||||
end;
|
||||
@ -914,7 +943,8 @@ begin
|
||||
ToolBar.Images := IDEImages.Images_16;
|
||||
FilterEdit.OnGetImageIndex:=@OnTreeViewGetImageIndex;
|
||||
|
||||
AddBitBtn := CreateToolButton('AddBitBtn', lisAdd, lisPckEditAddAnItem, 'laz_add', @AddBitBtnClick);
|
||||
AddBitBtn := CreateToolButton('AddBitBtn', lisAdd, lisPckEditAddFiles, 'laz_add', @AddBitBtnClick);
|
||||
AddMoreBitBtn := CreateToolButton('AddMoreBitBtn', lisDlgAdd, lisPckEditAddOtherItems, 'laz_addmore', @AddMoreBitBtnClick);
|
||||
RemoveBitBtn := CreateToolButton('RemoveBitBtn', lisRemove, lisPckEditRemoveSelectedItem, 'laz_delete', @RemoveBitBtnClick);
|
||||
CreateDivider;
|
||||
OptionsBitBtn := CreateToolButton('OptionsBitBtn', dlgFROpts, lisPckEditEditGeneralOptions, 'menu_environment_options', @OptionsBitBtnClick);
|
||||
|
@ -423,8 +423,8 @@ begin
|
||||
Columns.EndUpdate;
|
||||
end;
|
||||
|
||||
UserOverridesAddButton.Caption := dlgEdAdd;
|
||||
UserOverridesEditButton.Caption := dlgEdEdit;
|
||||
UserOverridesAddButton.Caption := lisDlgAdd;
|
||||
UserOverridesEditButton.Caption := lisDlgEdit;
|
||||
UserOverridesDeleteButton.Caption := lisDelete;
|
||||
IncludeSystemVariablesCheckBox.Caption := dlgIncludeSystemVariables;
|
||||
end;
|
||||
|
Binary file not shown.
@ -3,6 +3,7 @@ folder.png
|
||||
template.png
|
||||
mainiconproject.ico
|
||||
actions/laz_add.png
|
||||
actions/laz_addmore.png
|
||||
actions/arrow_down.png
|
||||
actions/arrow_left.png
|
||||
actions/arrow_right.png
|
||||
|
@ -1825,7 +1825,7 @@ begin
|
||||
CompileBitBtn := CreateToolButton('CompileBitBtn', lisCompile, lisPckEditCompilePackage, 'pkg_compile', @CompileBitBtnClick);
|
||||
UseBitBtn := CreateToolButton('UseBitBtn', lisPckEditInstall, lisPckEditInstallPackageInTheIDE, 'pkg_install', nil);
|
||||
CreateDivider;
|
||||
AddBitBtn := CreateToolButton('AddBitBtn', lisAdd, lisPckEditAddAnItem, 'laz_add', @AddBitBtnClick);
|
||||
AddBitBtn := CreateToolButton('AddBitBtn', lisAdd, lisPckEditAddOtherItems, 'laz_add', @AddBitBtnClick);
|
||||
RemoveBitBtn := CreateToolButton('RemoveBitBtn', lisRemove, lisPckEditRemoveSelectedItem, 'laz_delete', @RemoveBitBtnClick);
|
||||
CreateDivider;
|
||||
OptionsBitBtn := CreateToolButton('OptionsBitBtn', dlgFROpts, lisPckEditEditGeneralOptions, 'pkg_properties', @OptionsBitBtnClick);
|
||||
|
Loading…
Reference in New Issue
Block a user