mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-08 09:38:12 +02:00
IDE: Remove the "Add files in directory" feature for projects and packages. It is messy, inconsistent and broken. Issue #33845.
git-svn-id: trunk@58821 -
This commit is contained in:
parent
aad4e0c4e2
commit
d35a69cd0c
2
.gitattributes
vendored
2
.gitattributes
vendored
@ -10251,8 +10251,6 @@ lcl/widgetset/wstoolwin.pp svneol=native#text/pascal
|
||||
lcl/xmlpropstorage.pas svneol=native#text/pascal
|
||||
/localize.bat svneol=native#text/x-msdos-program
|
||||
/localize.sh svneol=native#text/plain
|
||||
packager/adddirtopkgdlg.lfm svneol=native#text/plain
|
||||
packager/adddirtopkgdlg.pas svneol=native#text/plain
|
||||
packager/addfiletoapackagedlg.lfm svneol=native#text/plain
|
||||
packager/addfiletoapackagedlg.pas svneol=native#text/pascal
|
||||
packager/addfpmakedependencydlg.lfm svneol=native#text/plain
|
||||
|
@ -1,134 +1,20 @@
|
||||
object AddToProjectDialog: TAddToProjectDialog
|
||||
Left = 312
|
||||
Left = 279
|
||||
Height = 358
|
||||
Top = 231
|
||||
Width = 658
|
||||
ActiveControl = Notebook
|
||||
Top = 224
|
||||
Width = 579
|
||||
BorderIcons = [biSystemMenu, biMaximize]
|
||||
Caption = 'AddToProjectDialog'
|
||||
ClientHeight = 358
|
||||
ClientWidth = 658
|
||||
ClientWidth = 579
|
||||
OnClose = AddToProjectDialogClose
|
||||
OnShow = AddToProjectDialogShow
|
||||
Position = poScreenCenter
|
||||
LCLVersion = '1.7'
|
||||
object Notebook: TPageControl
|
||||
Left = 0
|
||||
Height = 317
|
||||
Top = 0
|
||||
Width = 658
|
||||
ActivePage = AddEditorFilePage
|
||||
Align = alClient
|
||||
TabIndex = 0
|
||||
TabOrder = 0
|
||||
OnChange = NotebookChange
|
||||
object AddEditorFilePage: TTabSheet
|
||||
Caption = 'AddEditorFilePage'
|
||||
ClientHeight = 282
|
||||
ClientWidth = 650
|
||||
object AddFileLabel: TLabel
|
||||
Left = 6
|
||||
Height = 18
|
||||
Top = 6
|
||||
Width = 638
|
||||
Align = alTop
|
||||
BorderSpacing.Around = 6
|
||||
Caption = 'AddFileLabel'
|
||||
ParentColor = False
|
||||
end
|
||||
object AddFileListView: TListView
|
||||
Left = 6
|
||||
Height = 244
|
||||
Top = 30
|
||||
Width = 638
|
||||
Align = alTop
|
||||
Anchors = [akTop, akLeft, akRight, akBottom]
|
||||
AutoWidthLastColumn = True
|
||||
BorderSpacing.Around = 6
|
||||
Columns = <>
|
||||
MultiSelect = True
|
||||
ReadOnly = True
|
||||
RowSelect = True
|
||||
SortType = stText
|
||||
TabOrder = 0
|
||||
ViewStyle = vsReport
|
||||
OnSelectItem = AddFileListViewSelectItem
|
||||
end
|
||||
end
|
||||
object AddFilesPage: TTabSheet
|
||||
Caption = 'AddFilesPage'
|
||||
ClientHeight = 282
|
||||
ClientWidth = 650
|
||||
object FilesListView: TListView
|
||||
AnchorSideBottom.Control = FilesDirButton
|
||||
Left = 6
|
||||
Height = 235
|
||||
Top = 6
|
||||
Width = 638
|
||||
Anchors = [akTop, akLeft, akRight, akBottom]
|
||||
AutoWidthLastColumn = True
|
||||
BorderSpacing.Around = 6
|
||||
Columns = <>
|
||||
MultiSelect = True
|
||||
ReadOnly = True
|
||||
RowSelect = True
|
||||
SortType = stText
|
||||
TabOrder = 0
|
||||
ViewStyle = vsReport
|
||||
OnSelectItem = FilesListViewSelectItem
|
||||
end
|
||||
object FilesDirButton: TBitBtn
|
||||
AnchorSideLeft.Side = asrBottom
|
||||
AnchorSideBottom.Control = AddFilesPage
|
||||
AnchorSideBottom.Side = asrBottom
|
||||
Left = 6
|
||||
Height = 29
|
||||
Top = 247
|
||||
Width = 101
|
||||
Anchors = [akLeft, akBottom]
|
||||
AutoSize = True
|
||||
BorderSpacing.Around = 6
|
||||
Caption = 'FilesDirButton'
|
||||
OnClick = FilesDirButtonClick
|
||||
TabOrder = 1
|
||||
end
|
||||
object FilesShortenButton: TBitBtn
|
||||
AnchorSideLeft.Control = FilesDirButton
|
||||
AnchorSideLeft.Side = asrBottom
|
||||
AnchorSideTop.Control = FilesDirButton
|
||||
AnchorSideTop.Side = asrCenter
|
||||
Left = 113
|
||||
Height = 29
|
||||
Top = 247
|
||||
Width = 132
|
||||
AutoSize = True
|
||||
BorderSpacing.Around = 6
|
||||
Caption = 'FilesShortenButton'
|
||||
OnClick = FilesShortenButtonClick
|
||||
TabOrder = 2
|
||||
end
|
||||
object FilesDeleteButton: TBitBtn
|
||||
AnchorSideLeft.Control = FilesShortenButton
|
||||
AnchorSideLeft.Side = asrBottom
|
||||
AnchorSideTop.Control = FilesShortenButton
|
||||
AnchorSideTop.Side = asrCenter
|
||||
Left = 251
|
||||
Height = 29
|
||||
Top = 247
|
||||
Width = 123
|
||||
AutoSize = True
|
||||
BorderSpacing.Around = 6
|
||||
Caption = 'FilesDeleteButton'
|
||||
OnClick = FilesDeleteButtonClick
|
||||
TabOrder = 3
|
||||
end
|
||||
end
|
||||
end
|
||||
LCLVersion = '1.9.0.0'
|
||||
object ButtonPanel: TButtonPanel
|
||||
Left = 6
|
||||
Height = 29
|
||||
Top = 323
|
||||
Width = 646
|
||||
Height = 26
|
||||
Top = 326
|
||||
Width = 567
|
||||
OKButton.Name = 'OKButton'
|
||||
OKButton.DefaultCaption = True
|
||||
HelpButton.Name = 'HelpButton'
|
||||
@ -141,4 +27,21 @@ object AddToProjectDialog: TAddToProjectDialog
|
||||
ShowButtons = [pbOK, pbCancel]
|
||||
ShowBevel = False
|
||||
end
|
||||
object AddFileListView: TListView
|
||||
Left = 6
|
||||
Height = 314
|
||||
Top = 6
|
||||
Width = 567
|
||||
Align = alClient
|
||||
AutoWidthLastColumn = True
|
||||
BorderSpacing.Around = 6
|
||||
Columns = <>
|
||||
MultiSelect = True
|
||||
ReadOnly = True
|
||||
RowSelect = True
|
||||
SortType = stText
|
||||
TabOrder = 0
|
||||
ViewStyle = vsReport
|
||||
OnSelectItem = AddFileListViewSelectItem
|
||||
end
|
||||
end
|
||||
|
@ -46,183 +46,93 @@ uses
|
||||
ProjPackChecks;
|
||||
|
||||
type
|
||||
TAddToProjectType = (
|
||||
a2pFiles,
|
||||
a2pEditorFiles
|
||||
);
|
||||
|
||||
TAddToProjectResult = class
|
||||
public
|
||||
AddType: TAddToProjectType;
|
||||
FileNames: TStrings;
|
||||
destructor Destroy; override;
|
||||
end;
|
||||
|
||||
{ TAddToProjectDialog }
|
||||
|
||||
TAddToProjectDialog = class(TForm)
|
||||
AddFileListView: TListView;
|
||||
ButtonPanel: TButtonPanel;
|
||||
FilesDeleteButton: TBitBtn;
|
||||
FilesDirButton: TBitBtn;
|
||||
FilesShortenButton: TBitBtn;
|
||||
// notebook
|
||||
NoteBook: TPageControl;
|
||||
AddEditorFilePage: TTabSheet;
|
||||
AddFilesPage: TTabSheet;
|
||||
// add file page
|
||||
AddFileLabel: TLabel;
|
||||
// add files page
|
||||
FilesListView: TListView;
|
||||
procedure AddFileButtonClick(Sender: TObject);
|
||||
procedure AddFileListViewSelectItem(Sender: TObject; {%H-}Item: TListItem;
|
||||
{%H-}Selected: Boolean);
|
||||
procedure AddToProjectDialogClose(Sender: TObject;
|
||||
var {%H-}CloseAction: TCloseAction);
|
||||
procedure AddToProjectDialogShow(Sender: TObject);
|
||||
procedure FilesDirButtonClick(Sender: TObject);
|
||||
procedure FilesListViewSelectItem(Sender: TObject; {%H-}Item: TListItem;
|
||||
{%H-}Selected: Boolean);
|
||||
procedure FilesAddButtonClick(Sender: TObject);
|
||||
procedure FilesDeleteButtonClick(Sender: TObject);
|
||||
procedure FilesShortenButtonClick(Sender: TObject);
|
||||
procedure NotebookChange(Sender: TObject);
|
||||
private
|
||||
fPackages: TAVLTree;// tree of TLazPackage or TPackageLink
|
||||
fProject: TProject;
|
||||
procedure SetupComponents;
|
||||
procedure SetupAddEditorFilePage;
|
||||
procedure SetupAddFilesPage;
|
||||
fFileNames: TStrings;
|
||||
procedure UpdateAvailableFiles;
|
||||
procedure UpdateFilesButtons;
|
||||
public
|
||||
AddResult: TAddToProjectResult;
|
||||
constructor Create(TheOwner: TComponent); override;
|
||||
destructor Destroy; override;
|
||||
end;
|
||||
|
||||
function ShowAddToProjectDlg(AProject: TProject;
|
||||
var AddResult: TAddToProjectResult;
|
||||
AInitTab: TAddToProjectType): TModalResult;
|
||||
function ShowAddToProjectDlg(AProject: TProject; AFileNames: TStrings): TModalResult;
|
||||
|
||||
|
||||
implementation
|
||||
|
||||
{$R *.lfm}
|
||||
|
||||
function ShowAddToProjectDlg(AProject: TProject;
|
||||
var AddResult: TAddToProjectResult; AInitTab: TAddToProjectType): TModalResult;
|
||||
function ShowAddToProjectDlg(AProject: TProject; AFileNames: TStrings): TModalResult;
|
||||
var
|
||||
AddToProjectDialog: TAddToProjectDialog;
|
||||
begin
|
||||
AddToProjectDialog:=TAddToProjectDialog.Create(nil);
|
||||
AddToProjectDialog.fProject:=AProject;
|
||||
AddToProjectDialog.UpdateAvailableFiles;
|
||||
|
||||
case AInitTab of
|
||||
a2pFiles: AddToProjectDialog.NoteBook.ActivePageIndex:=1;
|
||||
a2pEditorFiles: AddToProjectDialog.NoteBook.ActivePageIndex:=0;
|
||||
try
|
||||
AddToProjectDialog.fProject:=AProject;
|
||||
AddToProjectDialog.fFileNames:=AFileNames;
|
||||
AddToProjectDialog.UpdateAvailableFiles;
|
||||
Result:=AddToProjectDialog.ShowModal;
|
||||
finally
|
||||
AddToProjectDialog.Free;
|
||||
end;
|
||||
// hide tabs for simple look
|
||||
AddToProjectDialog.NoteBook.ShowTabs:=false;
|
||||
AddToProjectDialog.NoteBook.TabStop:=false;
|
||||
// press "Add files" btn
|
||||
if AInitTab=a2pFiles then
|
||||
AddToProjectDialog.FilesDirButton.Click;
|
||||
|
||||
Result:=AddToProjectDialog.ShowModal;
|
||||
if Result=mrOk then begin
|
||||
AddResult:=AddToProjectDialog.AddResult;
|
||||
AddToProjectDialog.AddResult:=nil;
|
||||
end else begin
|
||||
AddResult:=nil;
|
||||
end;
|
||||
AddToProjectDialog.Free;
|
||||
end;
|
||||
|
||||
{ TAddToProjectDialog }
|
||||
|
||||
constructor TAddToProjectDialog.Create(TheOwner: TComponent);
|
||||
var
|
||||
CurColumn: TListColumn;
|
||||
begin
|
||||
inherited Create(TheOwner);
|
||||
Caption:=lisProjAddEditorFile;
|
||||
IDEDialogLayoutList.ApplyLayout(Self,500,300);
|
||||
ButtonPanel.OKButton.ModalResult := mrNone;
|
||||
ButtonPanel.OKButton.OnClick := @AddFileButtonClick;
|
||||
ButtonPanel.OKButton.Caption:=lisA2PAddFiles;
|
||||
ButtonPanel.OkButton.Enabled:=AddFileListView.SelCount>0;
|
||||
CurColumn:=AddFileListView.Columns.Add;
|
||||
CurColumn.Caption:=lisA2PFilename2;
|
||||
end;
|
||||
|
||||
destructor TAddToProjectDialog.Destroy;
|
||||
begin
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
procedure TAddToProjectDialog.AddToProjectDialogClose(Sender: TObject;
|
||||
var CloseAction: TCloseAction);
|
||||
begin
|
||||
IDEDialogLayoutList.SaveLayout(Self);
|
||||
end;
|
||||
|
||||
procedure TAddToProjectDialog.AddToProjectDialogShow(Sender: TObject);
|
||||
begin
|
||||
SelectNext(NoteBook.ActivePage, True, True);
|
||||
end;
|
||||
|
||||
procedure TAddToProjectDialog.FilesDirButtonClick(Sender: TObject);
|
||||
var
|
||||
DirDlg: TSelectDirectoryDialog;
|
||||
sl: TStringList;
|
||||
NewListItem: TListItem;
|
||||
NewPgkFileType: TPkgFileType;
|
||||
AFileName: String;
|
||||
i: Integer;
|
||||
begin
|
||||
sl:=Nil;
|
||||
DirDlg:=TSelectDirectoryDialog.Create(nil);
|
||||
try
|
||||
DirDlg.InitialDir:=fProject.Directory;
|
||||
DirDlg.Options:=DirDlg.Options+[ofPathMustExist];
|
||||
InputHistories.ApplyFileDialogSettings(DirDlg);
|
||||
if DirDlg.Execute then begin
|
||||
sl:=FindAllFiles(DirDlg.FileName, '*.pas;*.pp;*.p;*.inc', False);
|
||||
for i := 0 to sl.Count-1 do begin
|
||||
AFilename:=CleanAndExpandFilename(sl[i]);
|
||||
NewPgkFileType:=FileNameToPkgFileType(AFilename);
|
||||
if fProject.Directory<>'' then
|
||||
AFilename:=CreateRelativePath(AFilename,fProject.Directory);
|
||||
NewListItem:=FilesListView.Items.Add;
|
||||
NewListItem.Caption:=AFilename;
|
||||
NewListItem.SubItems.Add(GetPkgFileTypeLocalizedName(NewPgkFileType));
|
||||
NewListItem.Selected:=True;
|
||||
end;
|
||||
UpdateFilesButtons;
|
||||
end;
|
||||
InputHistories.StoreFileDialogSettings(DirDlg);
|
||||
finally
|
||||
sl.Free;
|
||||
DirDlg.Free;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TAddToProjectDialog.FilesListViewSelectItem(Sender: TObject;
|
||||
Item: TListItem; Selected: Boolean);
|
||||
begin
|
||||
UpdateFilesButtons;
|
||||
end;
|
||||
|
||||
procedure TAddToProjectDialog.AddFileButtonClick(Sender: TObject);
|
||||
var
|
||||
i: Integer;
|
||||
NewFilename: string;
|
||||
NewFiles: TStringList;
|
||||
begin
|
||||
try
|
||||
NewFiles:=TStringList.Create;
|
||||
for i:=0 to AddFileListView.Items.Count-1 do
|
||||
if AddFileListView.Items[i].Selected then begin
|
||||
NewFilename:=AddFileListView.Items[i].Caption;
|
||||
case CheckAddingProjectFile(fProject, NewFiles, NewFilename) of
|
||||
mrOk: ;
|
||||
mrIgnore: continue;
|
||||
else
|
||||
exit;
|
||||
end;
|
||||
NewFiles.Add(NewFilename);
|
||||
for i:=0 to AddFileListView.Items.Count-1 do
|
||||
if AddFileListView.Items[i].Selected then
|
||||
begin
|
||||
NewFilename:=AddFileListView.Items[i].Caption;
|
||||
case CheckAddingProjectFile(fProject, fFileNames, NewFilename) of
|
||||
mrOk: ;
|
||||
mrIgnore: continue;
|
||||
else
|
||||
exit;
|
||||
end;
|
||||
// everything ok
|
||||
AddResult:=TAddToProjectResult.Create;
|
||||
AddResult.AddType:=a2pFiles;
|
||||
AddResult.FileNames:=NewFiles;
|
||||
NewFiles:=nil;
|
||||
finally
|
||||
NewFiles.Free;
|
||||
end;
|
||||
ModalResult:=mrOk;
|
||||
fFileNames.Add(NewFilename);
|
||||
end;
|
||||
ModalResult:=mrOk; // everything ok
|
||||
end;
|
||||
|
||||
procedure TAddToProjectDialog.AddFileListViewSelectItem(Sender: TObject;
|
||||
@ -231,152 +141,6 @@ begin
|
||||
ButtonPanel.OkButton.Enabled:=AddFileListView.SelCount>0;
|
||||
end;
|
||||
|
||||
procedure TAddToProjectDialog.FilesAddButtonClick(Sender: TObject);
|
||||
var
|
||||
i: Integer;
|
||||
NewFilename: string;
|
||||
NewFiles: TStringList;
|
||||
begin
|
||||
try
|
||||
NewFiles:=TStringList.Create;
|
||||
for i:=0 to FilesListView.Items.Count-1 do
|
||||
if FilesListView.Items[i].Selected then begin
|
||||
NewFilename:=FilesListView.Items[i].Caption;
|
||||
case CheckAddingProjectFile(fProject, NewFiles, NewFilename) of
|
||||
mrOk: ;
|
||||
mrIgnore: continue;
|
||||
else
|
||||
exit;
|
||||
end;
|
||||
NewFiles.Add(NewFilename);
|
||||
end;
|
||||
// everything ok
|
||||
AddResult:=TAddToProjectResult.Create;
|
||||
AddResult.AddType:=a2pFiles;
|
||||
AddResult.FileNames:=NewFiles;
|
||||
NewFiles:=nil;
|
||||
finally
|
||||
NewFiles.Free;
|
||||
end;
|
||||
ModalResult:=mrOk;
|
||||
end;
|
||||
|
||||
procedure TAddToProjectDialog.FilesDeleteButtonClick(Sender: TObject);
|
||||
var
|
||||
i: Integer;
|
||||
begin
|
||||
for i:=FilesListView.Items.Count-1 downto 0 do
|
||||
if FilesListView.Items[i].Selected then
|
||||
FilesListView.Items.Delete(i);
|
||||
UpdateFilesButtons;
|
||||
end;
|
||||
|
||||
procedure TAddToProjectDialog.FilesShortenButtonClick(Sender: TObject);
|
||||
var
|
||||
SwitchToAbsolute: Boolean;
|
||||
i: Integer;
|
||||
Filename: String;
|
||||
ADirectory: String;
|
||||
begin
|
||||
if FilesListView.Items.Count=0 then exit;
|
||||
if (fProject=nil) or (not FilenameIsAbsolute(fProject.Directory)) then exit;
|
||||
ADirectory:=fProject.Directory;
|
||||
SwitchToAbsolute:=not FilenameIsAbsolute(FilesListView.Items[0].Caption);
|
||||
for i:=0 to FilesListView.Items.Count-1 do begin
|
||||
Filename:=FilesListView.Items[i].Caption;
|
||||
if SwitchToAbsolute then
|
||||
Filename:=CreateAbsolutePath(Filename,ADirectory)
|
||||
else
|
||||
Filename:=CreateRelativePath(Filename,ADirectory);
|
||||
FilesListView.Items[i].Caption:=Filename;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TAddToProjectDialog.NotebookChange(Sender: TObject);
|
||||
begin
|
||||
case NoteBook.PageIndex of
|
||||
0: begin // Add Editor Files
|
||||
ButtonPanel.OKButton.Caption:=lisA2PAddFiles;
|
||||
ButtonPanel.OkButton.OnClick:=@AddFileButtonClick;
|
||||
ButtonPanel.OkButton.Enabled:=AddFileListView.SelCount>0;
|
||||
end;
|
||||
1: begin // Add Files
|
||||
ButtonPanel.OkButton.Caption:=lisProjAddAddFilesToProject;
|
||||
ButtonPanel.OkButton.OnClick:=@FilesAddButtonClick;
|
||||
UpdateFilesButtons;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TAddToProjectDialog.SetupComponents;
|
||||
begin
|
||||
ButtonPanel.OKButton.ModalResult := mrNone;
|
||||
ButtonPanel.OKButton.OnClick := @AddFileButtonClick;
|
||||
NoteBook.PageIndex:=0;
|
||||
NotebookChange(NoteBook);
|
||||
|
||||
SetupAddEditorFilePage;
|
||||
SetupAddFilesPage;
|
||||
end;
|
||||
|
||||
procedure TAddToProjectDialog.SetupAddEditorFilePage;
|
||||
var
|
||||
CurColumn: TListColumn;
|
||||
begin
|
||||
AddEditorFilePage.Caption := lisProjAddEditorFile;
|
||||
AddFileLabel.Caption:=lisProjFiles;
|
||||
CurColumn:=AddFileListView.Columns.Add;
|
||||
CurColumn.Caption:=lisA2PFilename2;
|
||||
end;
|
||||
|
||||
procedure TAddToProjectDialog.SetupAddFilesPage;
|
||||
var
|
||||
CurColumn: TListColumn;
|
||||
begin
|
||||
AddFilesPage.Caption := lisA2PAddFiles;
|
||||
|
||||
CurColumn:=FilesListView.Columns.Add;
|
||||
CurColumn.Width:=200;
|
||||
CurColumn.Caption:=lisA2PFilename2;
|
||||
CurColumn:=FilesListView.Columns.Add;
|
||||
CurColumn.Caption:=dlgEnvType;
|
||||
|
||||
with FilesDirButton do begin
|
||||
Caption:=lisAddFilesInDirectory;
|
||||
IDEImages.AssignImage(FilesDirButton, 'pkg_files');
|
||||
end;
|
||||
|
||||
with FilesShortenButton do begin
|
||||
Caption:=lisA2PSwitchPaths;
|
||||
ShowHint:=true;
|
||||
Hint:=lisToggleShowingFilenamesWithFullPathOrWithRelativePa;
|
||||
end;
|
||||
|
||||
with FilesDeleteButton do begin
|
||||
Caption:=lisDelete;
|
||||
ShowHint:=true;
|
||||
Hint:=lisDeleteSelectedFiles;
|
||||
IDEImages.AssignImage(FilesDeleteButton, 'laz_delete');
|
||||
end;
|
||||
|
||||
UpdateFilesButtons;
|
||||
end;
|
||||
|
||||
constructor TAddToProjectDialog.Create(TheOwner: TComponent);
|
||||
begin
|
||||
inherited Create(TheOwner);
|
||||
Caption:=lisProjAddToProject;
|
||||
fPackages:=TAVLTree.Create(@CompareLazPackageIDNames);
|
||||
IDEDialogLayoutList.ApplyLayout(Self,500,300);
|
||||
SetupComponents;
|
||||
end;
|
||||
|
||||
destructor TAddToProjectDialog.Destroy;
|
||||
begin
|
||||
FreeAndNil(fPackages);
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
procedure TAddToProjectDialog.UpdateAvailableFiles;
|
||||
var
|
||||
CurFile: TUnitInfo;
|
||||
@ -400,20 +164,5 @@ begin
|
||||
ButtonPanel.OkButton.Enabled:=AddFileListView.SelCount>0;
|
||||
end;
|
||||
|
||||
procedure TAddToProjectDialog.UpdateFilesButtons;
|
||||
begin
|
||||
FilesShortenButton.Enabled:=FilesListView.Items.Count>0;
|
||||
FilesDeleteButton.Enabled:=FilesListView.SelCount>0;
|
||||
ButtonPanel.OKButton.Enabled:=FilesListView.SelCount>0;
|
||||
end;
|
||||
|
||||
{ TAddToProjectResult }
|
||||
|
||||
destructor TAddToProjectResult.Destroy;
|
||||
begin
|
||||
FileNames.Free;
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
end.
|
||||
|
||||
|
@ -156,7 +156,6 @@ begin
|
||||
|
||||
T := P.Targets.AddProgram('lazarus.pp');
|
||||
t.Dependencies.AddUnit('packagesystem');
|
||||
t.Dependencies.AddUnit('adddirtopkgdlg');
|
||||
t.Dependencies.AddUnit('addfiletoapackagedlg');
|
||||
t.Dependencies.AddUnit('addtopackagedlg');
|
||||
t.Dependencies.AddUnit('basepkgmanager');
|
||||
|
@ -3878,7 +3878,6 @@ resourcestring
|
||||
+'syntax *.pas;*.pp corresponds to ^(.*\.pas|.*\.pp)$';
|
||||
lisUseFilterForExtraFiles = 'Use filter for extra files';
|
||||
lisIncludeFilter = 'Include filter';
|
||||
lisExcludeFilter = 'Exclude filter';
|
||||
lisInvalidPublishingDirectory = 'Invalid publishing Directory';
|
||||
lisSourceDirectoryAndDestinationDirectoryAreTheSameMa = 'Source directory "%s"'
|
||||
+'%sand destination directory "%s"'
|
||||
@ -3896,7 +3895,6 @@ resourcestring
|
||||
lisIssues = 'Issues';
|
||||
lisRegularExpression = 'Regular expression';
|
||||
lisInvalidFilter = 'Invalid filter';
|
||||
lisInvalidExpression = 'Invalid expression:%s%s%s%s';
|
||||
|
||||
// project options
|
||||
lisProjOptsUnableToChangeTheAutoCreateFormList = 'Unable to change the auto '
|
||||
@ -4018,12 +4016,9 @@ resourcestring
|
||||
+'already exists in the project%swith file: "%s".';
|
||||
lisProjAddTheUnitNameAlreadyExistsInTheSelection = 'The unit name "%s" '
|
||||
+'already exists in the selection%swith file: "%s".';
|
||||
lisProjAddToProject = 'Add to Project';
|
||||
lisProjAddNewRequirement = 'New Requirement';
|
||||
lisProjAddNewFPMakeRequirement = 'New FPMake Requirement';
|
||||
lisProjAddEditorFile = 'Add Editor Files';
|
||||
lisProjFiles = 'Files:';
|
||||
lisProjAddAddFilesToProject = 'Add Files to Project';
|
||||
lisProjAddPackageName = 'Package Name:';
|
||||
lisProjAddPackageType = 'Package Type:';
|
||||
lisProjAddLocalPkg = 'Local (%s)';
|
||||
@ -4195,7 +4190,6 @@ resourcestring
|
||||
lisDirectories = 'Directories';
|
||||
lisFindFileFileMask = 'Fi&le mask';
|
||||
lisFindFileIncludeSubDirectories = 'Include &sub directories';
|
||||
lisFindFileOnlyTextFiles = 'Only text files';
|
||||
|
||||
// package manager
|
||||
lisPkgMangPackage = 'Package: %s';
|
||||
@ -4549,7 +4543,6 @@ resourcestring
|
||||
+'%sPlease use the format major.minor.release.build'
|
||||
+'%sFor example: 1.0.20.10';
|
||||
lisA2PNewFile = 'New File';
|
||||
lisA2PNewComponent = 'New Component';
|
||||
lisA2PAddFiles = 'Add Files';
|
||||
lisA2PAncestorType = 'Ancestor Type';
|
||||
lisA2PShowAll = 'Show all';
|
||||
@ -5089,9 +5082,6 @@ resourcestring
|
||||
lisLFMFile = 'LFM file';
|
||||
lisRemoveAllInvalidProperties = 'Remove all invalid properties';
|
||||
|
||||
lisA2PSwitchPaths = 'Switch Paths';
|
||||
lisA2PAddFilesToPackage = 'Add Files to Package';
|
||||
lisA2PAddToPackage = 'Add to package';
|
||||
lisA2PCreateNewFile = 'Create New File';
|
||||
lisA2PCreateNewComp = 'Create New Component';
|
||||
lisA2PCreateNewReq = 'Create New Requirement';
|
||||
@ -5612,8 +5602,6 @@ resourcestring
|
||||
lisVerifyMethodCalls = 'Verify method calls';
|
||||
lisToggleShowingFilenamesWithFullPathOrWithRelativePa = 'Toggle showing '
|
||||
+'filenames with full path or with relative path';
|
||||
lisDeleteSelectedFiles = 'Delete selected files';
|
||||
lisAddFilesInDirectory = 'Add Files in Directory';
|
||||
lisUnableToCreateLinkWithTarget = 'Unable to create link "%s" with target "%s"';
|
||||
lisBuildAllFilesOfProjectPackageIDE =
|
||||
'build all files of project/package/IDE';
|
||||
|
@ -10,7 +10,7 @@ object ProjectInspectorForm: TProjectInspectorForm
|
||||
ClientWidth = 299
|
||||
OnCreate = FormCreate
|
||||
OnDropFiles = FormDropFiles
|
||||
LCLVersion = '1.7'
|
||||
LCLVersion = '1.9.0.0'
|
||||
object ItemsTreeView: TTreeView
|
||||
Left = 0
|
||||
Height = 378
|
||||
@ -19,7 +19,6 @@ object ProjectInspectorForm: TProjectInspectorForm
|
||||
Align = alClient
|
||||
Anchors = [akTop, akLeft, akBottom]
|
||||
BorderSpacing.Top = 2
|
||||
DefaultItemHeight = 18
|
||||
DragMode = dmAutomatic
|
||||
MultiSelect = True
|
||||
PopupMenu = ItemsPopupMenu
|
||||
@ -107,14 +106,13 @@ object ProjectInspectorForm: TProjectInspectorForm
|
||||
AnchorSideTop.Control = SortAlphabeticallyButton
|
||||
AnchorSideTop.Side = asrCenter
|
||||
Left = 95
|
||||
Height = 23
|
||||
Top = 3
|
||||
Height = 25
|
||||
Top = 2
|
||||
Width = 201
|
||||
UseFormActivate = True
|
||||
ButtonWidth = 23
|
||||
NumGlyphs = 1
|
||||
Anchors = [akTop, akLeft, akRight]
|
||||
BorderSpacing.Left = 3
|
||||
NumGlyphs = 1
|
||||
MaxLength = 0
|
||||
ParentFont = False
|
||||
TabOrder = 0
|
||||
@ -129,6 +127,7 @@ object ProjectInspectorForm: TProjectInspectorForm
|
||||
Width = 299
|
||||
AutoSize = True
|
||||
ButtonHeight = 46
|
||||
ButtonWidth = 23
|
||||
ShowCaptions = True
|
||||
TabOrder = 2
|
||||
end
|
||||
@ -151,10 +150,6 @@ object ProjectInspectorForm: TProjectInspectorForm
|
||||
object MenuItem2: TMenuItem
|
||||
Caption = '-'
|
||||
end
|
||||
object mnuAddDiskFiles: TMenuItem
|
||||
Caption = 'Add files'
|
||||
OnClick = mnuAddDiskFilesClick
|
||||
end
|
||||
object mnuAddEditorFiles: TMenuItem
|
||||
Caption = 'Add editor files'
|
||||
OnClick = mnuAddEditorFilesClick
|
||||
|
@ -99,7 +99,6 @@ type
|
||||
mnuAddFPMakeReq: TMenuItem;
|
||||
mnuAddEditorFiles: TMenuItem;
|
||||
mnuAddDiskFile: TMenuItem;
|
||||
mnuAddDiskFiles: TMenuItem;
|
||||
mnuAddReq: TMenuItem;
|
||||
OpenButton: TSpeedButton;
|
||||
ItemsTreeView: TTreeView;
|
||||
@ -128,7 +127,6 @@ type
|
||||
procedure ItemsTreeViewKeyDown(Sender: TObject; var Key: Word; {%H-}Shift: TShiftState);
|
||||
procedure ItemsTreeViewSelectionChanged(Sender: TObject);
|
||||
procedure mnuAddBitBtnClick(Sender: TObject);
|
||||
procedure mnuAddDiskFilesClick(Sender: TObject);
|
||||
procedure mnuAddEditorFilesClick(Sender: TObject);
|
||||
procedure mnuAddFPMakeReqClick(Sender: TObject);
|
||||
procedure mnuAddReqClick(Sender: TObject);
|
||||
@ -180,7 +178,7 @@ type
|
||||
FProjectNodeDataList : array [TPENodeType] of TPENodeData;
|
||||
procedure AddMenuItemClick(Sender: TObject);
|
||||
function AddOneFile(aFilename: string): TModalResult;
|
||||
procedure DoAddMoreDialog(AInitTab: TAddToProjectType);
|
||||
procedure DoAddMoreDialog;
|
||||
procedure DoAddDepDialog;
|
||||
procedure DoAddFPMakeDepDialog;
|
||||
procedure FreeNodeData(Typ: TPENodeType);
|
||||
@ -373,14 +371,9 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TProjectInspectorForm.mnuAddDiskFilesClick(Sender: TObject);
|
||||
begin
|
||||
DoAddMoreDialog(a2pFiles);
|
||||
end;
|
||||
|
||||
procedure TProjectInspectorForm.mnuAddEditorFilesClick(Sender: TObject);
|
||||
begin
|
||||
DoAddMoreDialog(a2pEditorFiles);
|
||||
DoAddMoreDialog;
|
||||
end;
|
||||
|
||||
procedure TProjectInspectorForm.mnuAddFPMakeReqClick(Sender: TObject);
|
||||
@ -490,28 +483,23 @@ begin
|
||||
mnuAddBitBtnClick(Sender);
|
||||
end;
|
||||
|
||||
procedure TProjectInspectorForm.DoAddMoreDialog(AInitTab: TAddToProjectType);
|
||||
procedure TProjectInspectorForm.DoAddMoreDialog;
|
||||
var
|
||||
AddResult: TAddToProjectResult;
|
||||
Files: TStringList;
|
||||
i: Integer;
|
||||
begin
|
||||
AddResult:=nil;
|
||||
if ShowAddToProjectDlg(LazProject,AddResult,AInitTab)<>mrOk then exit;
|
||||
|
||||
case AddResult.AddType of
|
||||
a2pFiles:
|
||||
begin
|
||||
BeginUpdate;
|
||||
for i:=0 to AddResult.FileNames.Count-1 do
|
||||
if not (AddOneFile(AddResult.FileNames[i]) in [mrOk, mrIgnore]) then break;
|
||||
UpdateAll;
|
||||
EndUpdate;
|
||||
end;
|
||||
else
|
||||
Showmessage('Not implemented');
|
||||
Files:=TStringList.Create;
|
||||
try
|
||||
if ShowAddToProjectDlg(LazProject,Files)<>mrOk then
|
||||
exit;
|
||||
BeginUpdate;
|
||||
for i:=0 to Files.Count-1 do
|
||||
if not (AddOneFile(Files[i]) in [mrOk, mrIgnore]) then break;
|
||||
UpdateAll;
|
||||
EndUpdate;
|
||||
finally
|
||||
Files.Free;
|
||||
end;
|
||||
|
||||
AddResult.Free;
|
||||
end;
|
||||
|
||||
procedure TProjectInspectorForm.DoAddDepDialog;
|
||||
@ -1105,7 +1093,6 @@ begin
|
||||
|
||||
AddBitBtn.DropdownMenu:=AddPopupMenu;
|
||||
mnuAddDiskFile.Caption:=lisPckEditAddFilesFromFileSystem;
|
||||
mnuAddDiskFiles.Caption:=lisAddFilesInDirectory;
|
||||
mnuAddEditorFiles.Caption:=lisProjAddEditorFile;
|
||||
mnuAddReq.Caption:=lisProjAddNewRequirement;
|
||||
mnuAddFPMakeReq.Caption:=lisProjAddNewFPMakeRequirement;
|
||||
|
@ -1,151 +0,0 @@
|
||||
object AddDirToPkgDialog: TAddDirToPkgDialog
|
||||
Left = 411
|
||||
Height = 348
|
||||
Top = 297
|
||||
Width = 454
|
||||
BorderStyle = bsDialog
|
||||
Caption = 'AddDirToPkgDialog'
|
||||
ClientHeight = 348
|
||||
ClientWidth = 454
|
||||
OnClose = FormClose
|
||||
OnCreate = FormCreate
|
||||
OnDestroy = FormDestroy
|
||||
Position = poScreenCenter
|
||||
LCLVersion = '1.9.0.0'
|
||||
object DirGroupBox: TGroupBox
|
||||
Left = 6
|
||||
Height = 80
|
||||
Top = 6
|
||||
Width = 442
|
||||
Align = alTop
|
||||
AutoSize = True
|
||||
BorderSpacing.Around = 6
|
||||
Caption = 'DirGroupBox'
|
||||
ClientHeight = 60
|
||||
ClientWidth = 438
|
||||
TabOrder = 0
|
||||
object SubDirCheckBox: TCheckBox
|
||||
AnchorSideTop.Control = DirEdit
|
||||
AnchorSideTop.Side = asrBottom
|
||||
Left = 6
|
||||
Height = 19
|
||||
Top = 35
|
||||
Width = 107
|
||||
BorderSpacing.Around = 6
|
||||
Caption = 'SubDirCheckBox'
|
||||
Checked = True
|
||||
State = cbChecked
|
||||
TabOrder = 1
|
||||
end
|
||||
object DirEdit: TDirectoryEdit
|
||||
Left = 6
|
||||
Height = 23
|
||||
Top = 6
|
||||
Width = 426
|
||||
ShowHidden = False
|
||||
ButtonWidth = 25
|
||||
NumGlyphs = 1
|
||||
Align = alTop
|
||||
BorderSpacing.Around = 6
|
||||
MaxLength = 0
|
||||
TabOrder = 0
|
||||
end
|
||||
end
|
||||
object IncludeGroupBox: TGroupBox
|
||||
Left = 6
|
||||
Height = 105
|
||||
Top = 92
|
||||
Width = 442
|
||||
Align = alTop
|
||||
AutoSize = True
|
||||
BorderSpacing.Around = 6
|
||||
Caption = 'IncludeGroupBox'
|
||||
ClientHeight = 85
|
||||
ClientWidth = 438
|
||||
TabOrder = 1
|
||||
object IncludeRegExCheckBox: TCheckBox
|
||||
Left = 6
|
||||
Height = 19
|
||||
Top = 35
|
||||
Width = 426
|
||||
Align = alClient
|
||||
BorderSpacing.Around = 6
|
||||
Caption = 'IncludeRegExCheckBox'
|
||||
TabOrder = 1
|
||||
end
|
||||
object IncludeFilterCombobox: TComboBox
|
||||
Left = 6
|
||||
Height = 23
|
||||
Top = 6
|
||||
Width = 426
|
||||
Align = alTop
|
||||
BorderSpacing.Around = 6
|
||||
ItemHeight = 15
|
||||
TabOrder = 0
|
||||
Text = 'IncludeFilterCombobox'
|
||||
end
|
||||
object OnlyTextCheckBox: TCheckBox
|
||||
Left = 6
|
||||
Height = 19
|
||||
Top = 60
|
||||
Width = 426
|
||||
Align = alBottom
|
||||
BorderSpacing.Around = 6
|
||||
Caption = 'OnlyTextCheckBox'
|
||||
Checked = True
|
||||
State = cbChecked
|
||||
TabOrder = 2
|
||||
end
|
||||
end
|
||||
object ExcludeGroupBox: TGroupBox
|
||||
Left = 6
|
||||
Height = 80
|
||||
Top = 203
|
||||
Width = 442
|
||||
Align = alTop
|
||||
AutoSize = True
|
||||
BorderSpacing.Around = 6
|
||||
Caption = 'ExcludeGroupBox'
|
||||
ClientHeight = 60
|
||||
ClientWidth = 438
|
||||
TabOrder = 2
|
||||
object ExcludeRegExCheckBox: TCheckBox
|
||||
Left = 6
|
||||
Height = 19
|
||||
Top = 35
|
||||
Width = 426
|
||||
Align = alClient
|
||||
BorderSpacing.Around = 6
|
||||
Caption = 'ExcludeRegExCheckBox'
|
||||
TabOrder = 1
|
||||
end
|
||||
object ExcludeFilterCombobox: TComboBox
|
||||
Left = 6
|
||||
Height = 23
|
||||
Top = 6
|
||||
Width = 426
|
||||
Align = alTop
|
||||
BorderSpacing.Around = 6
|
||||
ItemHeight = 15
|
||||
TabOrder = 0
|
||||
Text = 'ExcludeFilterCombobox'
|
||||
end
|
||||
end
|
||||
object ButtonPanel1: TButtonPanel
|
||||
Left = 6
|
||||
Height = 26
|
||||
Top = 316
|
||||
Width = 442
|
||||
OKButton.Name = 'OKButton'
|
||||
OKButton.DefaultCaption = True
|
||||
HelpButton.Name = 'HelpButton'
|
||||
HelpButton.DefaultCaption = True
|
||||
CloseButton.Name = 'CloseButton'
|
||||
CloseButton.DefaultCaption = True
|
||||
CancelButton.Name = 'CancelButton'
|
||||
CancelButton.DefaultCaption = True
|
||||
TabOrder = 3
|
||||
ShowButtons = [pbOK, pbCancel]
|
||||
ShowBevel = False
|
||||
end
|
||||
end
|
@ -1,265 +0,0 @@
|
||||
{
|
||||
***************************************************************************
|
||||
* *
|
||||
* This source is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This code is distributed in the hope that it will be useful, but *
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
|
||||
* General Public License for more details. *
|
||||
* *
|
||||
* A copy of the GNU General Public License is available on the World *
|
||||
* Wide Web at <http://www.gnu.org/copyleft/gpl.html>. You can also *
|
||||
* obtain it by writing to the Free Software Foundation, *
|
||||
* Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1335, USA. *
|
||||
* *
|
||||
***************************************************************************
|
||||
}
|
||||
unit AddDirToPkgDlg;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, RegExpr,
|
||||
// LCL
|
||||
Forms, Controls, Dialogs, StdCtrls, ButtonPanel, EditBtn,
|
||||
// LazUtils
|
||||
FileProcs, LazFileUtils, LazStringUtils,
|
||||
// IdeIntf
|
||||
IDEWindowIntf,
|
||||
// IDE
|
||||
LazarusIDEStrConsts, PackageDefs;
|
||||
|
||||
type
|
||||
|
||||
{ TAddDirToPkgDialog }
|
||||
|
||||
TAddDirToPkgDialog = class(TForm)
|
||||
ButtonPanel1: TButtonPanel;
|
||||
DirEdit: TDirectoryEdit;
|
||||
OnlyTextCheckBox: TCheckBox;
|
||||
ExcludeFilterCombobox: TComboBox;
|
||||
ExcludeRegExCheckBox: TCheckBox;
|
||||
ExcludeGroupBox: TGroupBox;
|
||||
IncludeFilterCombobox: TComboBox;
|
||||
IncludeRegExCheckBox: TCheckBox;
|
||||
IncludeGroupBox: TGroupBox;
|
||||
SubDirCheckBox: TCheckBox;
|
||||
DirGroupBox: TGroupBox;
|
||||
procedure ButtonPanel1CancelClick(Sender: TObject);
|
||||
procedure ButtonPanel1OkClick(Sender: TObject);
|
||||
procedure FormClose(Sender: TObject; var {%H-}CloseAction: TCloseAction);
|
||||
procedure FormCreate(Sender: TObject);
|
||||
procedure FormDestroy(Sender: TObject);
|
||||
private
|
||||
FFiles: TStrings;
|
||||
FLazPackage: TLazPackage;
|
||||
fIncludeFilterRE, fExcludeFilterRE: TRegExpr;
|
||||
procedure SetLazPackage(const AValue: TLazPackage);
|
||||
function GatherFiles(Directory: string; WithSubDirs: boolean;
|
||||
OnlyTextFiles: boolean): boolean;
|
||||
function UpdateFilter: boolean;
|
||||
public
|
||||
property LazPackage: TLazPackage read FLazPackage write SetLazPackage;
|
||||
property Files: TStrings read FFiles write FFiles;
|
||||
end;
|
||||
|
||||
function ShowAddDirToPkgDialog(APackage: TLazPackage; out Files: TStrings): TModalResult;
|
||||
|
||||
implementation
|
||||
|
||||
{$R *.lfm}
|
||||
|
||||
function ShowAddDirToPkgDialog(APackage: TLazPackage; out Files: TStrings): TModalResult;
|
||||
var
|
||||
AddDirToPkgDialog: TAddDirToPkgDialog;
|
||||
begin
|
||||
Files:=TStringList.Create;
|
||||
AddDirToPkgDialog:=TAddDirToPkgDialog.Create(nil);
|
||||
try
|
||||
AddDirToPkgDialog.LazPackage:=APackage;
|
||||
AddDirToPkgDialog.Files:=Files;
|
||||
Result:=AddDirToPkgDialog.ShowModal;
|
||||
finally
|
||||
AddDirToPkgDialog.Free;
|
||||
end;
|
||||
end;
|
||||
|
||||
{ TAddDirToPkgDialog }
|
||||
|
||||
procedure TAddDirToPkgDialog.FormCreate(Sender: TObject);
|
||||
begin
|
||||
Caption:=lisAddFilesInDirectory;
|
||||
DirGroupBox.Caption:=lisCodeToolsDefsInsertBehindDirectory;
|
||||
SubDirCheckBox.Caption:=lisFindFileIncludeSubDirectories;
|
||||
IncludeGroupBox.Caption:=lisFilter;
|
||||
IncludeRegExCheckBox.Caption:=lisRegularExpression;
|
||||
OnlyTextCheckBox.Caption:=lisFindFileOnlyTextFiles;
|
||||
ExcludeGroupBox.Caption:=lisExcludeFilter;
|
||||
ExcludeRegExCheckBox.Caption:=lisRegularExpression;
|
||||
ButtonPanel1.OKButton.OnClick:=@ButtonPanel1OkClick;
|
||||
ButtonPanel1.CancelButton.OnClick:=@ButtonPanel1CancelClick;
|
||||
|
||||
with IncludeFilterCombobox.Items do begin
|
||||
BeginUpdate;
|
||||
Clear;
|
||||
Add('*.pas;*.pp;*.p;*.inc;*.lfm;*.dfm;*.lrs;*.txt;*.xml');
|
||||
Add('*.pas;*.pp;*.p;*.inc');
|
||||
EndUpdate;
|
||||
end;
|
||||
IncludeFilterCombobox.ItemIndex:=0;
|
||||
|
||||
with ExcludeFilterCombobox.Items do begin
|
||||
BeginUpdate;
|
||||
Clear;
|
||||
Add('*.o;*.ppu;*.dcu;*.a;*.so;*.dll;*.compiled;*.po');
|
||||
EndFormUpdate;
|
||||
end;
|
||||
ExcludeFilterCombobox.ItemIndex:=0;
|
||||
|
||||
// not needed for borderstyle dialog
|
||||
//IDEDialogLayoutList.ApplyLayout(Self,400,350);
|
||||
|
||||
fIncludeFilterRE:=TRegExpr.Create;
|
||||
fExcludeFilterRE:=TRegExpr.Create;
|
||||
end;
|
||||
|
||||
procedure TAddDirToPkgDialog.FormDestroy(Sender: TObject);
|
||||
begin
|
||||
FreeAndNil(fIncludeFilterRE);
|
||||
FreeAndNil(fExcludeFilterRE);
|
||||
end;
|
||||
|
||||
procedure TAddDirToPkgDialog.ButtonPanel1CancelClick(Sender: TObject);
|
||||
begin
|
||||
ModalResult:=mrCancel;
|
||||
end;
|
||||
|
||||
procedure TAddDirToPkgDialog.ButtonPanel1OkClick(Sender: TObject);
|
||||
begin
|
||||
if not GatherFiles(DirEdit.Text,SubDirCheckBox.Checked,
|
||||
OnlyTextCheckBox.Checked) then exit;
|
||||
ModalResult:=mrOk;
|
||||
end;
|
||||
|
||||
procedure TAddDirToPkgDialog.FormClose(Sender: TObject; var CloseAction: TCloseAction);
|
||||
begin
|
||||
IDEDialogLayoutList.SaveLayout(Self);
|
||||
end;
|
||||
|
||||
procedure TAddDirToPkgDialog.SetLazPackage(const AValue: TLazPackage);
|
||||
begin
|
||||
if FLazPackage=AValue then exit;
|
||||
FLazPackage:=AValue;
|
||||
DirEdit.Text:=FLazPackage.Directory;
|
||||
end;
|
||||
|
||||
function TAddDirToPkgDialog.GatherFiles(Directory: string;
|
||||
WithSubDirs: boolean; OnlyTextFiles: boolean): boolean;
|
||||
|
||||
function FileCanBeAdded(AFilename: string): boolean;
|
||||
begin
|
||||
Result:=false;
|
||||
|
||||
// check include filter
|
||||
if (fIncludeFilterRE.Expression<>'')
|
||||
and (not fIncludeFilterRE.Exec(ExtractFilename(AFilename))) then
|
||||
exit;
|
||||
|
||||
// check exclude filter
|
||||
if (fExcludeFilterRE.Expression<>'')
|
||||
and (fExcludeFilterRE.Exec(ExtractFilename(AFilename))) then
|
||||
exit;
|
||||
|
||||
// check binaries
|
||||
if OnlyTextFiles and (not FileIsText(AFilename)) then exit;
|
||||
|
||||
Result:=true;
|
||||
end;
|
||||
|
||||
function SearchDir(CurDir: string): boolean;
|
||||
var
|
||||
FileInfo: TSearchRec;
|
||||
CurFilename: String;
|
||||
begin
|
||||
Result:=false;
|
||||
CurDir:=TrimAndExpandDirectory(CurDir);
|
||||
if not DirPathExists(CurDir) then begin
|
||||
MessageDlg(lisEnvOptDlgDirectoryNotFound,
|
||||
Format(lisTheDirectoryWasNotFound, [CurDir]), mtError, [mbCancel], 0);
|
||||
exit;
|
||||
end;
|
||||
if FindFirstUTF8(CurDir+FileMask,faAnyFile,FileInfo)=0 then begin
|
||||
repeat
|
||||
// check if special file
|
||||
if (FileInfo.Name='.') or (FileInfo.Name='..') or (FileInfo.Name='') then
|
||||
continue;
|
||||
CurFilename:=CurDir+FileInfo.Name;
|
||||
if (FileInfo.Attr and faDirectory)>0 then begin
|
||||
if WithSubDirs and not SearchDir(CurFilename) then exit;
|
||||
end else begin
|
||||
if FileCanBeAdded(CurFilename) then
|
||||
Files.Add(CurFilename);
|
||||
end;
|
||||
until FindNextUTF8(FileInfo)<>0;
|
||||
end;
|
||||
FindCloseUTF8(FileInfo);
|
||||
|
||||
Result:=true;
|
||||
end;
|
||||
|
||||
begin
|
||||
Files.Clear;
|
||||
Result:=false;
|
||||
if not UpdateFilter then exit;
|
||||
Result:=SearchDir(Directory);
|
||||
end;
|
||||
|
||||
function TAddDirToPkgDialog.UpdateFilter: boolean;
|
||||
var
|
||||
Expr: String;
|
||||
begin
|
||||
Expr:=IncludeFilterCombobox.Text;
|
||||
if not IncludeRegExCheckBox.Checked then
|
||||
Expr:=SimpleSyntaxToRegExpr(Expr);
|
||||
if Expr<>'' then begin
|
||||
Result:=false;
|
||||
try
|
||||
fIncludeFilterRE.Expression:=Expr;
|
||||
Result:=true;
|
||||
except
|
||||
on E: Exception do begin
|
||||
MessageDlg(lisInvalidFilter,
|
||||
Format(lisInvalidExpression, [LineEnding, Expr, LineEnding, E.Message]),
|
||||
mtError, [mbCancel], 0);
|
||||
end;
|
||||
end;
|
||||
if not Result then exit;
|
||||
end;
|
||||
Expr:=ExcludeFilterCombobox.Text;
|
||||
if not ExcludeRegExCheckBox.Checked then
|
||||
Expr:=SimpleSyntaxToRegExpr(Expr);
|
||||
if Expr<>'' then begin
|
||||
Result:=false;
|
||||
try
|
||||
fExcludeFilterRE.Expression:=Expr;
|
||||
Result:=true;
|
||||
except
|
||||
on E: Exception do begin
|
||||
MessageDlg(lisInvalidFilter,
|
||||
Format(lisInvalidExpression, [LineEnding, Expr, LineEnding, E.Message]),
|
||||
mtError, [mbCancel], 0);
|
||||
end;
|
||||
end;
|
||||
if not Result then exit;
|
||||
end;
|
||||
Result:=true;
|
||||
end;
|
||||
|
||||
end.
|
||||
|
@ -1,333 +1,23 @@
|
||||
object AddToPackageDlg: TAddToPackageDlg
|
||||
Left = 383
|
||||
Height = 357
|
||||
Height = 263
|
||||
Top = 297
|
||||
Width = 658
|
||||
Width = 606
|
||||
BorderIcons = [biSystemMenu, biMaximize]
|
||||
Caption = 'Add to package'
|
||||
ClientHeight = 357
|
||||
ClientWidth = 658
|
||||
Caption = 'New component'
|
||||
ClientHeight = 263
|
||||
ClientWidth = 606
|
||||
KeyPreview = True
|
||||
OnClose = AddToPackageDlgClose
|
||||
OnCreate = FormCreate
|
||||
OnDestroy = FormDestroy
|
||||
OnKeyDown = AddToPackageDlgKeyDown
|
||||
OnShow = FormShow
|
||||
Position = poScreenCenter
|
||||
LCLVersion = '1.9.0.0'
|
||||
object PageControl1: TPageControl
|
||||
Left = 0
|
||||
Height = 319
|
||||
Top = 0
|
||||
Width = 658
|
||||
ActivePage = NewComponentPage
|
||||
Align = alClient
|
||||
TabIndex = 0
|
||||
TabOrder = 0
|
||||
OnChange = PageControl1Change
|
||||
object NewComponentPage: TTabSheet
|
||||
Caption = 'New Component'
|
||||
ClientHeight = 291
|
||||
ClientWidth = 650
|
||||
OnResize = NewComponentPageResize
|
||||
object AncestorTypeLabel: TLabel
|
||||
AnchorSideTop.Control = AncestorComboBox
|
||||
AnchorSideTop.Side = asrCenter
|
||||
Left = 5
|
||||
Height = 15
|
||||
Top = 10
|
||||
Width = 100
|
||||
Caption = 'AncestorTypeLabel'
|
||||
ParentColor = False
|
||||
end
|
||||
object ClassNameLabel: TLabel
|
||||
AnchorSideTop.Control = ClassNameEdit
|
||||
AnchorSideTop.Side = asrCenter
|
||||
Left = 5
|
||||
Height = 15
|
||||
Top = 39
|
||||
Width = 87
|
||||
Caption = 'ClassNameLabel'
|
||||
ParentColor = False
|
||||
end
|
||||
object PalettePageLabel: TLabel
|
||||
AnchorSideTop.Control = PalettePageCombobox
|
||||
AnchorSideTop.Side = asrCenter
|
||||
Left = 5
|
||||
Height = 15
|
||||
Top = 68
|
||||
Width = 90
|
||||
Caption = 'PalettePageLabel'
|
||||
ParentColor = False
|
||||
end
|
||||
object ComponentUnitFileLabel: TLabel
|
||||
AnchorSideTop.Control = ComponentUnitFileEdit
|
||||
AnchorSideTop.Side = asrCenter
|
||||
Left = 5
|
||||
Height = 15
|
||||
Top = 97
|
||||
Width = 132
|
||||
Caption = 'ComponentUnitFileLabel'
|
||||
ParentColor = False
|
||||
end
|
||||
object ComponentUnitNameLabel: TLabel
|
||||
AnchorSideTop.Control = ComponentUnitNameEdit
|
||||
AnchorSideTop.Side = asrCenter
|
||||
Left = 5
|
||||
Height = 15
|
||||
Top = 126
|
||||
Width = 146
|
||||
Caption = 'ComponentUnitNameLabel'
|
||||
ParentColor = False
|
||||
end
|
||||
object AncestorComboBox: TComboBox
|
||||
AnchorSideLeft.Side = asrBottom
|
||||
AnchorSideTop.Control = NewComponentPage
|
||||
Left = 184
|
||||
Height = 23
|
||||
Top = 6
|
||||
Width = 200
|
||||
BorderSpacing.Top = 6
|
||||
ItemHeight = 15
|
||||
OnChange = AncestorComboBoxChange
|
||||
OnCloseUp = AncestorComboBoxCloseUp
|
||||
TabOrder = 0
|
||||
Text = 'AncestorComboBox'
|
||||
end
|
||||
object AncestorShowAllCheckBox: TCheckBox
|
||||
AnchorSideLeft.Control = AncestorComboBox
|
||||
AnchorSideLeft.Side = asrBottom
|
||||
AnchorSideTop.Control = AncestorComboBox
|
||||
AnchorSideTop.Side = asrCenter
|
||||
Left = 390
|
||||
Height = 19
|
||||
Top = 8
|
||||
Width = 162
|
||||
BorderSpacing.Left = 6
|
||||
Caption = 'AncestorShowAllCheckBox'
|
||||
Checked = True
|
||||
OnClick = AncestorShowAllCheckBoxClick
|
||||
State = cbChecked
|
||||
TabOrder = 1
|
||||
end
|
||||
object ClassNameEdit: TEdit
|
||||
AnchorSideLeft.Control = AncestorComboBox
|
||||
AnchorSideTop.Control = AncestorComboBox
|
||||
AnchorSideTop.Side = asrBottom
|
||||
AnchorSideRight.Control = AncestorComboBox
|
||||
AnchorSideRight.Side = asrBottom
|
||||
Left = 184
|
||||
Height = 23
|
||||
Top = 35
|
||||
Width = 200
|
||||
Anchors = [akTop, akLeft, akRight]
|
||||
BorderSpacing.Top = 6
|
||||
OnChange = ClassNameEditChange
|
||||
TabOrder = 2
|
||||
Text = 'ClassNameEdit'
|
||||
end
|
||||
object PalettePageCombobox: TComboBox
|
||||
AnchorSideLeft.Control = AncestorComboBox
|
||||
AnchorSideTop.Control = ClassNameEdit
|
||||
AnchorSideTop.Side = asrBottom
|
||||
AnchorSideRight.Control = AncestorComboBox
|
||||
AnchorSideRight.Side = asrBottom
|
||||
Left = 184
|
||||
Height = 23
|
||||
Top = 64
|
||||
Width = 200
|
||||
BorderSpacing.Top = 6
|
||||
ItemHeight = 15
|
||||
TabOrder = 3
|
||||
Text = 'PalettePageCombobox'
|
||||
end
|
||||
object ComponentUnitFileEdit: TEdit
|
||||
AnchorSideLeft.Control = AncestorComboBox
|
||||
AnchorSideTop.Control = PalettePageCombobox
|
||||
AnchorSideTop.Side = asrBottom
|
||||
AnchorSideRight.Control = ComponentUnitFileBrowseButton
|
||||
Left = 184
|
||||
Height = 23
|
||||
Top = 93
|
||||
Width = 393
|
||||
Anchors = [akTop, akLeft, akRight]
|
||||
BorderSpacing.Top = 6
|
||||
TabOrder = 4
|
||||
Text = 'ComponentUnitFileEdit'
|
||||
end
|
||||
object ComponentUnitFileBrowseButton: TButton
|
||||
AnchorSideLeft.Side = asrBottom
|
||||
AnchorSideTop.Control = ComponentUnitFileEdit
|
||||
AnchorSideTop.Side = asrCenter
|
||||
AnchorSideRight.Control = ComponentUnitFileShortenButton
|
||||
Left = 577
|
||||
Height = 25
|
||||
Hint = 'Save file dialog'
|
||||
Top = 92
|
||||
Width = 25
|
||||
Anchors = [akTop, akRight]
|
||||
Caption = '...'
|
||||
OnClick = ComponentUnitFileBrowseButtonClick
|
||||
ParentShowHint = False
|
||||
ShowHint = True
|
||||
TabOrder = 5
|
||||
end
|
||||
object ComponentUnitFileShortenButton: TButton
|
||||
AnchorSideLeft.Side = asrBottom
|
||||
AnchorSideTop.Control = ComponentUnitFileEdit
|
||||
AnchorSideTop.Side = asrCenter
|
||||
AnchorSideRight.Control = NewComponentPage
|
||||
AnchorSideRight.Side = asrBottom
|
||||
Left = 602
|
||||
Height = 25
|
||||
Hint = 'Shorten or expand filename'
|
||||
Top = 92
|
||||
Width = 42
|
||||
Anchors = [akTop, akRight]
|
||||
AutoSize = True
|
||||
BorderSpacing.Right = 6
|
||||
Caption = '<>'
|
||||
OnClick = ComponentUnitFileShortenButtonClick
|
||||
ParentShowHint = False
|
||||
ShowHint = True
|
||||
TabOrder = 6
|
||||
end
|
||||
object ComponentUnitNameEdit: TEdit
|
||||
AnchorSideLeft.Control = AncestorComboBox
|
||||
AnchorSideTop.Control = ComponentUnitFileEdit
|
||||
AnchorSideTop.Side = asrBottom
|
||||
AnchorSideRight.Control = AncestorComboBox
|
||||
AnchorSideRight.Side = asrBottom
|
||||
Left = 184
|
||||
Height = 23
|
||||
Top = 122
|
||||
Width = 200
|
||||
Anchors = [akTop, akLeft, akRight]
|
||||
BorderSpacing.Top = 6
|
||||
OnChange = ComponentUnitNameEditChange
|
||||
TabOrder = 7
|
||||
Text = 'ComponentUnitNameEdit'
|
||||
end
|
||||
object ComponentIconLabel: TLabel
|
||||
AnchorSideLeft.Control = ComponentUnitNameLabel
|
||||
AnchorSideTop.Control = ComponentIconBitBtn
|
||||
AnchorSideTop.Side = asrCenter
|
||||
Left = 5
|
||||
Height = 15
|
||||
Top = 160
|
||||
Width = 115
|
||||
Caption = 'ComponentIconLabel'
|
||||
ParentColor = False
|
||||
end
|
||||
object ComponentIconBitBtn: TBitBtn
|
||||
AnchorSideLeft.Control = ComponentUnitNameEdit
|
||||
AnchorSideTop.Control = ComponentUnitNameEdit
|
||||
AnchorSideTop.Side = asrBottom
|
||||
Left = 184
|
||||
Height = 32
|
||||
Top = 151
|
||||
Width = 50
|
||||
BorderSpacing.Top = 6
|
||||
Constraints.MinWidth = 50
|
||||
GlyphShowMode = gsmAlways
|
||||
OnClick = ComponentIconBitBtnClick
|
||||
TabOrder = 8
|
||||
end
|
||||
object LabelIconInfo: TLabel
|
||||
AnchorSideLeft.Control = ComponentIconBitBtn
|
||||
AnchorSideLeft.Side = asrBottom
|
||||
AnchorSideTop.Control = ComponentIconLabel
|
||||
AnchorSideTop.Side = asrCenter
|
||||
Left = 240
|
||||
Height = 15
|
||||
Top = 160
|
||||
Width = 5
|
||||
BorderSpacing.Around = 6
|
||||
Caption = '?'
|
||||
ParentColor = False
|
||||
end
|
||||
end
|
||||
object AddFilesPage: TTabSheet
|
||||
Caption = 'Add Files'
|
||||
ClientHeight = 281
|
||||
ClientWidth = 650
|
||||
object FilesListView: TListView
|
||||
Left = 6
|
||||
Height = 228
|
||||
Top = 6
|
||||
Width = 638
|
||||
Align = alClient
|
||||
BorderSpacing.Around = 6
|
||||
Columns = <
|
||||
item
|
||||
Caption = 'Filename'
|
||||
Width = 200
|
||||
end
|
||||
item
|
||||
Caption = 'Type'
|
||||
Width = 436
|
||||
end>
|
||||
MultiSelect = True
|
||||
SortType = stText
|
||||
TabOrder = 0
|
||||
ViewStyle = vsReport
|
||||
OnSelectItem = FilesListViewSelectItem
|
||||
end
|
||||
object AddFilesBtnPanel: TPanel
|
||||
Left = 0
|
||||
Height = 41
|
||||
Top = 240
|
||||
Width = 650
|
||||
Align = alBottom
|
||||
AutoSize = True
|
||||
BevelOuter = bvNone
|
||||
ClientHeight = 41
|
||||
ClientWidth = 650
|
||||
TabOrder = 1
|
||||
object FilesShortenButton: TBitBtn
|
||||
Left = 113
|
||||
Height = 29
|
||||
Top = 6
|
||||
Width = 132
|
||||
Align = alLeft
|
||||
AutoSize = True
|
||||
BorderSpacing.Around = 6
|
||||
Caption = 'FilesShortenButton'
|
||||
OnClick = FilesShortenButtonClick
|
||||
TabOrder = 0
|
||||
end
|
||||
object FilesDeleteButton: TBitBtn
|
||||
Left = 251
|
||||
Height = 29
|
||||
Top = 6
|
||||
Width = 123
|
||||
Align = alLeft
|
||||
AutoSize = True
|
||||
BorderSpacing.Around = 6
|
||||
Caption = 'FilesDeleteButton'
|
||||
OnClick = FilesDeleteButtonClick
|
||||
TabOrder = 1
|
||||
end
|
||||
object FilesDirButton: TBitBtn
|
||||
Left = 6
|
||||
Height = 29
|
||||
Top = 6
|
||||
Width = 101
|
||||
Align = alLeft
|
||||
AutoSize = True
|
||||
BorderSpacing.Around = 6
|
||||
Caption = 'FilesDirButton'
|
||||
OnClick = FilesDirButtonClick
|
||||
TabOrder = 2
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
object ButtonPanel1: TButtonPanel
|
||||
Left = 6
|
||||
Height = 26
|
||||
Top = 325
|
||||
Width = 646
|
||||
Top = 231
|
||||
Width = 594
|
||||
OKButton.Name = 'OKButton'
|
||||
OKButton.DefaultCaption = True
|
||||
HelpButton.Name = 'HelpButton'
|
||||
@ -336,8 +26,222 @@ object AddToPackageDlg: TAddToPackageDlg
|
||||
CloseButton.DefaultCaption = True
|
||||
CancelButton.Name = 'CancelButton'
|
||||
CancelButton.DefaultCaption = True
|
||||
TabOrder = 1
|
||||
TabOrder = 9
|
||||
ShowButtons = [pbOK, pbCancel]
|
||||
ShowBevel = False
|
||||
end
|
||||
object AncestorComboBox: TComboBox
|
||||
AnchorSideLeft.Side = asrBottom
|
||||
Left = 184
|
||||
Height = 31
|
||||
Top = 6
|
||||
Width = 200
|
||||
BorderSpacing.Top = 6
|
||||
ItemHeight = 0
|
||||
OnChange = AncestorComboBoxChange
|
||||
OnCloseUp = AncestorComboBoxCloseUp
|
||||
TabOrder = 0
|
||||
Text = 'AncestorComboBox'
|
||||
end
|
||||
object ClassNameEdit: TEdit
|
||||
AnchorSideLeft.Control = AncestorComboBox
|
||||
AnchorSideTop.Control = AncestorComboBox
|
||||
AnchorSideTop.Side = asrBottom
|
||||
AnchorSideRight.Control = AncestorComboBox
|
||||
AnchorSideRight.Side = asrBottom
|
||||
Left = 184
|
||||
Height = 25
|
||||
Top = 43
|
||||
Width = 200
|
||||
Anchors = [akTop, akLeft, akRight]
|
||||
BorderSpacing.Top = 6
|
||||
OnChange = ClassNameEditChange
|
||||
TabOrder = 2
|
||||
Text = 'ClassNameEdit'
|
||||
end
|
||||
object PalettePageCombobox: TComboBox
|
||||
AnchorSideLeft.Control = AncestorComboBox
|
||||
AnchorSideTop.Control = ClassNameEdit
|
||||
AnchorSideTop.Side = asrBottom
|
||||
AnchorSideRight.Control = AncestorComboBox
|
||||
AnchorSideRight.Side = asrBottom
|
||||
Left = 184
|
||||
Height = 31
|
||||
Top = 74
|
||||
Width = 200
|
||||
BorderSpacing.Top = 6
|
||||
ItemHeight = 0
|
||||
TabOrder = 3
|
||||
Text = 'PalettePageCombobox'
|
||||
end
|
||||
object ComponentUnitFileEdit: TEdit
|
||||
AnchorSideLeft.Control = AncestorComboBox
|
||||
AnchorSideTop.Control = PalettePageCombobox
|
||||
AnchorSideTop.Side = asrBottom
|
||||
AnchorSideRight.Control = ComponentUnitFileBrowseButton
|
||||
Left = 184
|
||||
Height = 25
|
||||
Top = 111
|
||||
Width = 359
|
||||
Anchors = [akTop, akLeft, akRight]
|
||||
BorderSpacing.Top = 6
|
||||
TabOrder = 4
|
||||
Text = 'ComponentUnitFileEdit'
|
||||
end
|
||||
object ComponentUnitNameEdit: TEdit
|
||||
AnchorSideLeft.Control = AncestorComboBox
|
||||
AnchorSideTop.Control = ComponentUnitFileEdit
|
||||
AnchorSideTop.Side = asrBottom
|
||||
AnchorSideRight.Control = AncestorComboBox
|
||||
AnchorSideRight.Side = asrBottom
|
||||
Left = 184
|
||||
Height = 25
|
||||
Top = 142
|
||||
Width = 200
|
||||
Anchors = [akTop, akLeft, akRight]
|
||||
BorderSpacing.Top = 6
|
||||
OnChange = ComponentUnitNameEditChange
|
||||
TabOrder = 7
|
||||
Text = 'ComponentUnitNameEdit'
|
||||
end
|
||||
object ComponentIconBitBtn: TBitBtn
|
||||
AnchorSideLeft.Control = ComponentUnitNameEdit
|
||||
AnchorSideTop.Control = ComponentUnitNameEdit
|
||||
AnchorSideTop.Side = asrBottom
|
||||
Left = 184
|
||||
Height = 32
|
||||
Top = 173
|
||||
Width = 50
|
||||
BorderSpacing.Top = 6
|
||||
Constraints.MinWidth = 50
|
||||
GlyphShowMode = gsmAlways
|
||||
OnClick = ComponentIconBitBtnClick
|
||||
TabOrder = 8
|
||||
end
|
||||
object LabelIconInfo: TLabel
|
||||
AnchorSideLeft.Control = ComponentIconBitBtn
|
||||
AnchorSideLeft.Side = asrBottom
|
||||
AnchorSideTop.Control = ComponentIconLabel
|
||||
AnchorSideTop.Side = asrCenter
|
||||
Left = 240
|
||||
Height = 19
|
||||
Top = 180
|
||||
Width = 6
|
||||
BorderSpacing.Around = 6
|
||||
Caption = '?'
|
||||
ParentColor = False
|
||||
end
|
||||
object AncestorShowAllCheckBox: TCheckBox
|
||||
AnchorSideLeft.Control = AncestorComboBox
|
||||
AnchorSideLeft.Side = asrBottom
|
||||
AnchorSideTop.Control = AncestorComboBox
|
||||
AnchorSideTop.Side = asrCenter
|
||||
Left = 390
|
||||
Height = 21
|
||||
Top = 11
|
||||
Width = 190
|
||||
BorderSpacing.Left = 6
|
||||
Caption = 'AncestorShowAllCheckBox'
|
||||
Checked = True
|
||||
OnClick = AncestorShowAllCheckBoxClick
|
||||
State = cbChecked
|
||||
TabOrder = 1
|
||||
end
|
||||
object ComponentUnitFileBrowseButton: TButton
|
||||
AnchorSideLeft.Side = asrBottom
|
||||
AnchorSideTop.Control = ComponentUnitFileEdit
|
||||
AnchorSideTop.Side = asrCenter
|
||||
AnchorSideRight.Control = ComponentUnitFileShortenButton
|
||||
Left = 543
|
||||
Height = 25
|
||||
Hint = 'Save file dialog'
|
||||
Top = 111
|
||||
Width = 25
|
||||
Anchors = [akTop, akRight]
|
||||
Caption = '...'
|
||||
OnClick = ComponentUnitFileBrowseButtonClick
|
||||
ParentShowHint = False
|
||||
ShowHint = True
|
||||
TabOrder = 5
|
||||
end
|
||||
object ComponentUnitFileShortenButton: TButton
|
||||
AnchorSideLeft.Side = asrBottom
|
||||
AnchorSideTop.Control = ComponentUnitFileEdit
|
||||
AnchorSideTop.Side = asrCenter
|
||||
AnchorSideRight.Side = asrBottom
|
||||
Left = 568
|
||||
Height = 25
|
||||
Hint = 'Shorten or expand filename'
|
||||
Top = 111
|
||||
Width = 22
|
||||
Anchors = [akTop, akRight]
|
||||
AutoSize = True
|
||||
BorderSpacing.Right = 6
|
||||
Caption = '<>'
|
||||
OnClick = ComponentUnitFileShortenButtonClick
|
||||
ParentShowHint = False
|
||||
ShowHint = True
|
||||
TabOrder = 6
|
||||
end
|
||||
object ComponentIconLabel: TLabel
|
||||
AnchorSideLeft.Control = ComponentUnitNameLabel
|
||||
AnchorSideTop.Control = ComponentIconBitBtn
|
||||
AnchorSideTop.Side = asrCenter
|
||||
Left = 5
|
||||
Height = 19
|
||||
Top = 180
|
||||
Width = 135
|
||||
Caption = 'ComponentIconLabel'
|
||||
ParentColor = False
|
||||
end
|
||||
object ComponentUnitNameLabel: TLabel
|
||||
AnchorSideTop.Control = ComponentUnitNameEdit
|
||||
AnchorSideTop.Side = asrCenter
|
||||
Left = 5
|
||||
Height = 19
|
||||
Top = 145
|
||||
Width = 173
|
||||
Caption = 'ComponentUnitNameLabel'
|
||||
ParentColor = False
|
||||
end
|
||||
object ComponentUnitFileLabel: TLabel
|
||||
AnchorSideTop.Control = ComponentUnitFileEdit
|
||||
AnchorSideTop.Side = asrCenter
|
||||
Left = 5
|
||||
Height = 19
|
||||
Top = 114
|
||||
Width = 155
|
||||
Caption = 'ComponentUnitFileLabel'
|
||||
ParentColor = False
|
||||
end
|
||||
object PalettePageLabel: TLabel
|
||||
AnchorSideTop.Control = PalettePageCombobox
|
||||
AnchorSideTop.Side = asrCenter
|
||||
Left = 5
|
||||
Height = 19
|
||||
Top = 80
|
||||
Width = 111
|
||||
Caption = 'PalettePageLabel'
|
||||
ParentColor = False
|
||||
end
|
||||
object ClassNameLabel: TLabel
|
||||
AnchorSideTop.Control = ClassNameEdit
|
||||
AnchorSideTop.Side = asrCenter
|
||||
Left = 5
|
||||
Height = 19
|
||||
Top = 46
|
||||
Width = 104
|
||||
Caption = 'ClassNameLabel'
|
||||
ParentColor = False
|
||||
end
|
||||
object AncestorTypeLabel: TLabel
|
||||
AnchorSideTop.Control = AncestorComboBox
|
||||
AnchorSideTop.Side = asrCenter
|
||||
Left = 5
|
||||
Height = 19
|
||||
Top = 12
|
||||
Width = 120
|
||||
Caption = 'AncestorTypeLabel'
|
||||
ParentColor = False
|
||||
end
|
||||
end
|
||||
|
@ -41,7 +41,7 @@ uses
|
||||
IDEDialogs, IDEImagesIntf,
|
||||
// IDE
|
||||
LazarusIDEStrConsts, InputHistory, IDEDefs, EnvironmentOpts,
|
||||
PackageSystem, PackageDefs, AddDirToPkgDlg, ProjPackChecks;
|
||||
PackageSystem, PackageDefs, ProjPackChecks;
|
||||
|
||||
type
|
||||
|
||||
@ -50,7 +50,6 @@ type
|
||||
TAddToPkgResult = class
|
||||
public
|
||||
Pkg: TLazPackage;
|
||||
AddType: TAddToPkgType;
|
||||
Dependency: TPkgDependency;
|
||||
UnitFilename: string;
|
||||
Unit_Name: string;
|
||||
@ -75,54 +74,35 @@ type
|
||||
{ TAddToPackageDlg }
|
||||
|
||||
TAddToPackageDlg = class(TForm)
|
||||
AddFilesBtnPanel: TPanel;
|
||||
AddFilesPage: TTabSheet;
|
||||
AncestorComboBox: TComboBox;
|
||||
AncestorShowAllCheckBox: TCheckBox;
|
||||
AncestorTypeLabel: TLabel;
|
||||
ButtonPanel1: TButtonPanel;
|
||||
ClassNameEdit: TEdit;
|
||||
ClassNameLabel: TLabel;
|
||||
ComponentIconLabel: TLabel;
|
||||
ComponentIconBitBtn: TBitBtn;
|
||||
ComponentIconLabel: TLabel;
|
||||
ComponentUnitFileBrowseButton: TButton;
|
||||
ComponentUnitFileEdit: TEdit;
|
||||
ComponentUnitFileLabel: TLabel;
|
||||
ComponentUnitFileShortenButton: TButton;
|
||||
ComponentUnitNameEdit: TEdit;
|
||||
ComponentUnitNameLabel: TLabel;
|
||||
FilesDeleteButton: TBitBtn;
|
||||
FilesDirButton: TBitBtn;
|
||||
FilesListView: TListView;
|
||||
FilesShortenButton: TBitBtn;
|
||||
LabelIconInfo: TLabel;
|
||||
NewComponentPage: TTabSheet;
|
||||
PageControl1: TPageControl;
|
||||
PalettePageCombobox: TComboBox;
|
||||
PalettePageLabel: TLabel;
|
||||
procedure AddToPackageDlgClose(Sender: TObject; var {%H-}CloseAction: TCloseAction);
|
||||
procedure AddToPackageDlgKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
|
||||
procedure AncestorComboBoxChange(Sender: TObject);
|
||||
procedure AncestorComboBoxCloseUp(Sender: TObject);
|
||||
procedure AncestorShowAllCheckBoxClick(Sender: TObject);
|
||||
procedure CancelAddFileButtonClick(Sender: TObject);
|
||||
procedure CancelAddUnitButtonClick(Sender: TObject);
|
||||
procedure ClassNameEditChange(Sender: TObject);
|
||||
procedure ComponentIconBitBtnClick(Sender: TObject);
|
||||
procedure ComponentUnitFileBrowseButtonClick(Sender: TObject);
|
||||
procedure ComponentUnitFileShortenButtonClick(Sender: TObject);
|
||||
procedure ComponentUnitNameEditChange(Sender: TObject);
|
||||
procedure FilesAddButtonClick(Sender: TObject);
|
||||
procedure FilesDeleteButtonClick(Sender: TObject);
|
||||
procedure FilesDirButtonClick(Sender: TObject);
|
||||
procedure FilesListViewSelectItem(Sender: TObject; {%H-}Item: TListItem; {%H-}Selected: Boolean);
|
||||
procedure FilesShortenButtonClick(Sender: TObject);
|
||||
procedure FormCreate(Sender: TObject);
|
||||
procedure FormDestroy(Sender: TObject);
|
||||
procedure FormShow(Sender: TObject);
|
||||
procedure NewComponentButtonClick(Sender: TObject);
|
||||
procedure NewComponentPageResize(Sender: TObject);
|
||||
procedure PageControl1Change(Sender: TObject);
|
||||
private
|
||||
fLastNewComponentAncestorType: string;
|
||||
fLastNewComponentClassName: string;
|
||||
@ -132,22 +112,15 @@ type
|
||||
fPkgComponents: TAVLTree;// tree of TPkgComponent
|
||||
fPackages: TAVLTree;// tree of TLazPackage or TPackageLink
|
||||
FComponentIconFilename: string;
|
||||
function GetActivatePage: TAddToPkgType;
|
||||
procedure SetActivatePage(AValue: TAddToPkgType);
|
||||
fParams: TAddToPkgResult;
|
||||
procedure SetLazPackage(const AValue: TLazPackage);
|
||||
procedure SetupComponents;
|
||||
procedure SetupNewComponentPage;
|
||||
procedure SetupAddFilesPage;
|
||||
procedure OnIterateComponentClasses(PkgComponent: TPkgComponent);
|
||||
function CheckNewCompOk: Boolean;
|
||||
function CheckFilesButtonsOk: Boolean;
|
||||
procedure AutoCompleteNewComponent;
|
||||
procedure AutoCompleteNewComponentUnitName;
|
||||
function SwitchRelativeAbsoluteFilename(const Filename: string): string;
|
||||
function FindFileInFilesList(AFilename: string): Integer;
|
||||
procedure LoadComponentIcon(AFilename: string);
|
||||
public
|
||||
Params: TAddToPkgResult;
|
||||
procedure UpdateAvailableAncestorTypes;
|
||||
procedure UpdateAvailablePageNames;
|
||||
public
|
||||
@ -156,13 +129,11 @@ type
|
||||
write FOnGetIDEFileInfo;
|
||||
property OnGetUnitRegisterInfo: TOnGetUnitRegisterInfo
|
||||
read FOnGetUnitRegisterInfo write FOnGetUnitRegisterInfo;
|
||||
property ActivatePage: TAddToPkgType read GetActivatePage write SetActivatePage;
|
||||
end;
|
||||
|
||||
function ShowAddToPackageDlg(Pkg: TLazPackage; out Params: TAddToPkgResult;
|
||||
OnGetIDEFileInfo: TGetIDEFileStateEvent;
|
||||
OnGetUnitRegisterInfo: TOnGetUnitRegisterInfo;
|
||||
var Page: TAddToPkgType): TModalResult;
|
||||
OnGetUnitRegisterInfo: TOnGetUnitRegisterInfo): TModalResult;
|
||||
|
||||
|
||||
implementation
|
||||
@ -171,49 +142,78 @@ implementation
|
||||
|
||||
function ShowAddToPackageDlg(Pkg: TLazPackage; out Params: TAddToPkgResult;
|
||||
OnGetIDEFileInfo: TGetIDEFileStateEvent;
|
||||
OnGetUnitRegisterInfo: TOnGetUnitRegisterInfo; var Page: TAddToPkgType
|
||||
): TModalResult;
|
||||
OnGetUnitRegisterInfo: TOnGetUnitRegisterInfo): TModalResult;
|
||||
var
|
||||
AddDlg: TAddToPackageDlg;
|
||||
begin
|
||||
Params:=nil;
|
||||
AddDlg:=TAddToPackageDlg.Create(nil);
|
||||
AddDlg.OnGetIDEFileInfo:=OnGetIDEFileInfo;
|
||||
AddDlg.OnGetUnitRegisterInfo:=OnGetUnitRegisterInfo;
|
||||
AddDlg.LazPackage:=Pkg;
|
||||
AddDlg.ActivatePage:=Page;
|
||||
|
||||
//auto press AddFiles if called with "Add files" page
|
||||
if Page=d2ptFiles then
|
||||
AddDlg.FilesDirButton.Click;
|
||||
//hide tabs for simpler use
|
||||
AddDlg.PageControl1.ShowTabs:=false;
|
||||
AddDlg.PageControl1.TabStop:=false;
|
||||
|
||||
Result:=AddDlg.ShowModal;
|
||||
Page:=AddDlg.ActivatePage;
|
||||
if Result=mrOk then begin
|
||||
Params:=AddDlg.Params;
|
||||
AddDlg.Params:=nil;
|
||||
try
|
||||
AddDlg.OnGetIDEFileInfo:=OnGetIDEFileInfo;
|
||||
AddDlg.OnGetUnitRegisterInfo:=OnGetUnitRegisterInfo;
|
||||
AddDlg.LazPackage:=Pkg;
|
||||
Result:=AddDlg.ShowModal;
|
||||
if Result=mrOk then begin
|
||||
Params:=AddDlg.fParams;
|
||||
AddDlg.fParams:=nil;
|
||||
end;
|
||||
finally
|
||||
AddDlg.Free;
|
||||
end;
|
||||
AddDlg.Free;
|
||||
end;
|
||||
|
||||
{ TAddToPackageDlg }
|
||||
|
||||
procedure TAddToPackageDlg.FormCreate(Sender: TObject);
|
||||
begin
|
||||
Caption:=lisMenuNewComponent;
|
||||
fPkgComponents:=TAVLTree.Create(@CompareIDEComponentByClassName);
|
||||
fPackages:=TAVLTree.Create(@CompareLazPackageID);
|
||||
fParams:=TAddToPkgResult.Create;
|
||||
IDEDialogLayoutList.ApplyLayout(Self,500,260);
|
||||
// Setup Components
|
||||
ButtonPanel1.OkButton.Caption:=lisA2PCreateNewComp;
|
||||
ButtonPanel1.OkButton.OnClick:=@NewComponentButtonClick;
|
||||
CheckNewCompOk;
|
||||
AncestorTypeLabel.Caption:=lisA2PAncestorType;
|
||||
AncestorComboBox.Text:='';
|
||||
AncestorShowAllCheckBox.Caption:=lisA2PShowAll;
|
||||
ClassNameLabel.Caption:=lisA2PNewClassName;
|
||||
ClassNameEdit.Text:='';
|
||||
PalettePageLabel.Caption:=lisA2PPalettePage;
|
||||
PalettePageCombobox.Text:='';
|
||||
ComponentUnitFileLabel.Caption:=lisA2PUnitFileName2;
|
||||
ComponentUnitFileEdit.Text:='';
|
||||
with ComponentUnitFileBrowseButton do begin
|
||||
Caption:='...';
|
||||
ShowHint:=true;
|
||||
Hint:=lisA2PSaveFileDialog;
|
||||
end;
|
||||
with ComponentUnitFileShortenButton do begin
|
||||
Caption:='<>';
|
||||
ShowHint:=true;
|
||||
Hint:=lisA2PShortenOrExpandFilename;
|
||||
end;
|
||||
ComponentUnitNameLabel.Caption:=lisA2PUnitName;
|
||||
ComponentUnitNameEdit.Text:='';
|
||||
ComponentIconLabel.Caption:=lisA2PIconAndSize;
|
||||
ComponentIconBitBtn.Width:=ComponentPaletteBtnWidth;
|
||||
ComponentIconBitBtn.Height:=ComponentPaletteBtnHeight;
|
||||
end;
|
||||
|
||||
procedure TAddToPackageDlg.FormDestroy(Sender: TObject);
|
||||
begin
|
||||
FreeAndNil(fPkgComponents);
|
||||
FreeAndNil(fPackages);
|
||||
FreeAndNil(fParams);
|
||||
end;
|
||||
|
||||
procedure TAddToPackageDlg.AddToPackageDlgClose(Sender: TObject;
|
||||
var CloseAction: TCloseAction);
|
||||
begin
|
||||
IDEDialogLayoutList.SaveLayout(Self);
|
||||
end;
|
||||
|
||||
procedure TAddToPackageDlg.AddToPackageDlgKeyDown(Sender: TObject;
|
||||
var Key: Word; Shift: TShiftState);
|
||||
begin
|
||||
if (Key=VK_ESCAPE) and (Shift=[]) then
|
||||
ModalResult:=mrCancel;
|
||||
end;
|
||||
|
||||
procedure TAddToPackageDlg.AncestorComboBoxChange(Sender: TObject);
|
||||
begin
|
||||
CheckNewCompOk;
|
||||
@ -230,16 +230,6 @@ begin
|
||||
UpdateAvailableAncestorTypes;
|
||||
end;
|
||||
|
||||
procedure TAddToPackageDlg.CancelAddFileButtonClick(Sender: TObject);
|
||||
begin
|
||||
ModalResult:=mrCancel;
|
||||
end;
|
||||
|
||||
procedure TAddToPackageDlg.CancelAddUnitButtonClick(Sender: TObject);
|
||||
begin
|
||||
ModalResult:=mrCancel;
|
||||
end;
|
||||
|
||||
procedure TAddToPackageDlg.ClassNameEditChange(Sender: TObject);
|
||||
begin
|
||||
AutoCompleteNewComponentUnitName;
|
||||
@ -311,271 +301,91 @@ begin
|
||||
CheckNewCompOk;
|
||||
end;
|
||||
|
||||
procedure TAddToPackageDlg.FilesAddButtonClick(Sender: TObject);
|
||||
var
|
||||
i: Integer;
|
||||
Filename: String;
|
||||
NewFileType: TPkgFileType;
|
||||
HasRegisterProc: boolean;
|
||||
CurParams, LastParams: TAddToPkgResult;
|
||||
ok: Boolean;
|
||||
begin
|
||||
ok:=false;
|
||||
try
|
||||
LastParams:=nil;
|
||||
i:=0;
|
||||
while i<FilesListView.Items.Count do begin
|
||||
if not FilesListView.Items[i].Selected then begin
|
||||
Inc(i);
|
||||
Continue;
|
||||
end;
|
||||
Filename:=FilesListView.Items[i].Caption;
|
||||
LazPackage.LongenFilename(Filename);
|
||||
Assert(not DirPathExists(Filename));
|
||||
if LazPackage.FindPkgFile(Filename,true,false)<>nil then begin
|
||||
FilesListView.Items.Delete(i); // file already in package
|
||||
continue;
|
||||
end;
|
||||
|
||||
if LastParams<>nil then begin
|
||||
LastParams.Next:=TAddToPkgResult.Create;
|
||||
CurParams:=LastParams.Next;
|
||||
end else
|
||||
CurParams:=Params;
|
||||
CurParams.Clear;
|
||||
CurParams.AddType:=d2ptFile;
|
||||
CurParams.UnitFilename:=Filename;
|
||||
NewFileType:=FileNameToPkgFileType(Filename);
|
||||
CurParams.FileType:=NewFileType;
|
||||
if NewFileType=pftUnit then begin
|
||||
CurParams.AddType:=d2ptUnit;
|
||||
Include(CurParams.PkgFileFlags,pffAddToPkgUsesSection);
|
||||
|
||||
// check filename
|
||||
if not CheckAddingPackageUnit(LazPackage,CurParams.AddType,
|
||||
OnGetIDEFileInfo,CurParams.UnitFilename)
|
||||
then begin
|
||||
FilesListView.Items.Delete(i);
|
||||
exit;
|
||||
end;
|
||||
|
||||
CurParams.AutoAddLFMFile:=true;
|
||||
CurParams.AutoAddLRSFile:=true;
|
||||
if Assigned(OnGetUnitRegisterInfo) then begin
|
||||
OnGetUnitRegisterInfo(Self,Filename,CurParams.Unit_Name,HasRegisterProc);
|
||||
if HasRegisterProc then
|
||||
Include(CurParams.PkgFileFlags,pffHasRegisterProc);
|
||||
end;
|
||||
|
||||
// check unitname
|
||||
if CompareText(CurParams.Unit_Name,
|
||||
ExtractFileNameOnly(CurParams.UnitFilename))<>0
|
||||
then begin
|
||||
if IDEMessageDialog(lisA2PInvalidUnitName,
|
||||
Format(lisA2PTheUnitNameAndFilenameDiffer,
|
||||
[CurParams.Unit_Name, LineEnding, CurParams.UnitFilename]),
|
||||
mtError,[mbIgnore,mbCancel])<>mrIgnore
|
||||
then begin
|
||||
FilesListView.Items.Delete(i);
|
||||
exit;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
LastParams:=CurParams;
|
||||
inc(i);
|
||||
end;
|
||||
ButtonPanel1.OKButton.Enabled:=FilesListView.SelCount>0;
|
||||
ok:=LastParams<>nil;
|
||||
finally
|
||||
if not ok then Params.Clear;
|
||||
end;
|
||||
if LastParams=nil then begin
|
||||
exit;
|
||||
end;
|
||||
ModalResult:=mrOk;
|
||||
end;
|
||||
|
||||
procedure TAddToPackageDlg.FilesDeleteButtonClick(Sender: TObject);
|
||||
var
|
||||
i: Integer;
|
||||
begin
|
||||
for i:=FilesListView.Items.Count-1 downto 0 do
|
||||
if FilesListView.Items[i].Selected then
|
||||
FilesListView.Items.Delete(i);
|
||||
CheckFilesButtonsOk;
|
||||
end;
|
||||
|
||||
procedure TAddToPackageDlg.FilesDirButtonClick(Sender: TObject);
|
||||
var
|
||||
i: Integer;
|
||||
Files: TStrings;
|
||||
AFilename: string;
|
||||
NewListItem: TListItem;
|
||||
NewPgkFileType: TPkgFileType;
|
||||
begin
|
||||
Files:=nil;
|
||||
try
|
||||
if ShowAddDirToPkgDialog(LazPackage,Files)<>mrOk then exit;
|
||||
for i:=0 to Files.Count-1 do begin
|
||||
AFilename:=Files[i];
|
||||
if FindFileInFilesList(AFilename)<0 then begin
|
||||
LazPackage.ShortenFilename(AFilename,true);
|
||||
NewListItem:=FilesListView.Items.Add;
|
||||
NewListItem.Caption:=AFilename;
|
||||
NewPgkFileType:=FileNameToPkgFileType(AFilename);
|
||||
NewListItem.SubItems.Add(GetPkgFileTypeLocalizedName(NewPgkFileType));
|
||||
NewListItem.Selected:=True;
|
||||
end;
|
||||
end;
|
||||
CheckFilesButtonsOk;
|
||||
finally
|
||||
Files.Free;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TAddToPackageDlg.FilesListViewSelectItem(Sender: TObject;
|
||||
Item: TListItem; Selected: Boolean);
|
||||
begin
|
||||
CheckFilesButtonsOk;
|
||||
end;
|
||||
|
||||
procedure TAddToPackageDlg.FilesShortenButtonClick(Sender: TObject);
|
||||
var
|
||||
SwitchToAbsolute: Boolean;
|
||||
i: Integer;
|
||||
Filename: String;
|
||||
begin
|
||||
if FilesListView.Items.Count=0 then exit;
|
||||
if (not LazPackage.HasDirectory)
|
||||
or (not FilenameIsAbsolute(LazPackage.Directory)) then exit;
|
||||
SwitchToAbsolute:=not FilenameIsAbsolute(FilesListView.Items[0].Caption);
|
||||
for i:=0 to FilesListView.Items.Count-1 do begin
|
||||
Filename:=FilesListView.Items[i].Caption;
|
||||
if SwitchToAbsolute then
|
||||
Filename:=CreateAbsolutePath(Filename,LazPackage.Directory)
|
||||
else
|
||||
Filename:=CreateRelativePath(Filename,LazPackage.Directory);
|
||||
FilesListView.Items[i].Caption:=Filename;
|
||||
end;
|
||||
end;
|
||||
|
||||
function TAddToPackageDlg.CheckFilesButtonsOk: Boolean;
|
||||
begin
|
||||
FilesDeleteButton.Enabled:=FilesListView.SelCount>0;
|
||||
Result:=FilesListView.Items.Count>0;
|
||||
FilesShortenButton.Enabled:=Result;
|
||||
ButtonPanel1.OKButton.Enabled:=FilesListView.SelCount>0;
|
||||
end;
|
||||
|
||||
procedure TAddToPackageDlg.FormCreate(Sender: TObject);
|
||||
begin
|
||||
Caption:=lisA2PAddToPackage;
|
||||
fPkgComponents:=TAVLTree.Create(@CompareIDEComponentByClassName);
|
||||
fPackages:=TAVLTree.Create(@CompareLazPackageID);
|
||||
Params:=TAddToPkgResult.Create;
|
||||
|
||||
IDEDialogLayoutList.ApplyLayout(Self,500,300);
|
||||
SetupComponents;
|
||||
end;
|
||||
|
||||
procedure TAddToPackageDlg.FormDestroy(Sender: TObject);
|
||||
begin
|
||||
FreeAndNil(fPkgComponents);
|
||||
FreeAndNil(fPackages);
|
||||
FreeAndNil(Params);
|
||||
end;
|
||||
|
||||
procedure TAddToPackageDlg.FormShow(Sender: TObject);
|
||||
begin
|
||||
SelectNext(PageControl1.ActivePage, True, True);
|
||||
end;
|
||||
|
||||
procedure TAddToPackageDlg.NewComponentButtonClick(Sender: TObject);
|
||||
var
|
||||
PkgFile: TPkgFile;
|
||||
PkgComponent: TPkgComponent;
|
||||
ARequiredPackage: TLazPackage;
|
||||
begin
|
||||
Params.Clear;
|
||||
Params.AddType:=d2ptNewComponent;
|
||||
Params.FileType:=pftUnit;
|
||||
Params.PkgFileFlags:=[pffHasRegisterProc,pffAddToPkgUsesSection];
|
||||
Params.AncestorType:=AncestorComboBox.Text;
|
||||
Params.NewClassName:=ClassNameEdit.Text;
|
||||
Params.PageName:=PalettePageCombobox.Text;
|
||||
Params.Unit_Name:=ComponentUnitNameEdit.Text;
|
||||
Params.UnitFilename:=ComponentUnitFileEdit.Text;
|
||||
Params.UsedUnitname:='';
|
||||
Params.IconFile:=FComponentIconFilename;
|
||||
fParams.Clear;
|
||||
fParams.FileType:=pftUnit;
|
||||
fParams.PkgFileFlags:=[pffHasRegisterProc,pffAddToPkgUsesSection];
|
||||
fParams.AncestorType:=AncestorComboBox.Text;
|
||||
fParams.NewClassName:=ClassNameEdit.Text;
|
||||
fParams.PageName:=PalettePageCombobox.Text;
|
||||
fParams.Unit_Name:=ComponentUnitNameEdit.Text;
|
||||
fParams.UnitFilename:=ComponentUnitFileEdit.Text;
|
||||
fParams.UsedUnitname:='';
|
||||
fParams.IconFile:=FComponentIconFilename;
|
||||
|
||||
// check Ancestor Type
|
||||
if not IsValidIdent(Params.AncestorType) then begin
|
||||
if not IsValidIdent(fParams.AncestorType) then begin
|
||||
IDEMessageDialog(lisA2PInvalidAncestorType,
|
||||
Format(lisA2PTheAncestorTypeIsNotAValidPascalIdentifier, [Params.AncestorType]),
|
||||
Format(lisA2PTheAncestorTypeIsNotAValidPascalIdentifier, [fParams.AncestorType]),
|
||||
mtError,[mbCancel]);
|
||||
exit;
|
||||
end;
|
||||
|
||||
// check pagename
|
||||
if length(Params.PageName)>100 then begin
|
||||
if length(fParams.PageName)>100 then begin
|
||||
IDEMessageDialog(lisA2PPageNameTooLong,
|
||||
Format(lisA2PThePageNameIsTooLongMax100Chars, [Params.PageName]),
|
||||
Format(lisA2PThePageNameIsTooLongMax100Chars, [fParams.PageName]),
|
||||
mtError,[mbCancel]);
|
||||
exit;
|
||||
end;
|
||||
|
||||
// check unitname - filename redundancy
|
||||
if CompareText(Params.Unit_name,ExtractFileNameOnly(Params.UnitFilename))<>0
|
||||
if CompareText(fParams.Unit_name,ExtractFileNameOnly(fParams.UnitFilename))<>0
|
||||
then begin
|
||||
IDEMessageDialog(lisA2PUnitNameInvalid,
|
||||
Format(lisA2PTheUnitNameDoesNotCorrespondToTheFilename, [Params.Unit_Name]),
|
||||
Format(lisA2PTheUnitNameDoesNotCorrespondToTheFilename, [fParams.Unit_Name]),
|
||||
mtError,[mbCancel]);
|
||||
exit;
|
||||
end;
|
||||
|
||||
// check classname
|
||||
if not IsValidIdent(Params.NewClassName) then begin
|
||||
if not IsValidIdent(fParams.NewClassName) then begin
|
||||
IDEMessageDialog(lisA2PInvalidClassName,
|
||||
Format(lisA2PTheClassNameIsNotAValidPascalIdentifier, [Params.NewClassName]),
|
||||
Format(lisA2PTheClassNameIsNotAValidPascalIdentifier, [fParams.NewClassName]),
|
||||
mtError,[mbCancel]);
|
||||
exit;
|
||||
end;
|
||||
|
||||
// check classname<>ancestortype
|
||||
if CompareText(Params.NewClassName,Params.AncestorType)=0 then begin
|
||||
if CompareText(fParams.NewClassName,fParams.AncestorType)=0 then begin
|
||||
IDEMessageDialog(lisA2PInvalidCircularDependency,
|
||||
Format(lisA2PTheClassNameAndAncestorTypeAreTheSame,[Params.NewClassName,Params.AncestorType]),
|
||||
Format(lisA2PTheClassNameAndAncestorTypeAreTheSame,[fParams.NewClassName,fParams.AncestorType]),
|
||||
mtError,[mbCancel]);
|
||||
exit;
|
||||
end;
|
||||
|
||||
// check ancestor type is not unitname
|
||||
PkgFile:=PackageGraph.FindUnit(LazPackage,Params.AncestorType,true,true);
|
||||
PkgFile:=PackageGraph.FindUnit(LazPackage,fParams.AncestorType,true,true);
|
||||
if PkgFile<>nil then begin
|
||||
if IDEMessageDialog(lisA2PAmbiguousAncestorType,
|
||||
Format(lisA2PTheAncestorTypeHasTheSameNameAsTheUnit,
|
||||
[Params.AncestorType, LineEnding, PkgFile.Filename]),
|
||||
[fParams.AncestorType, LineEnding, PkgFile.Filename]),
|
||||
mtError,[mbCancel,mbIgnore])<>mrIgnore
|
||||
then
|
||||
exit;
|
||||
end;
|
||||
|
||||
// check classname does not interfere with an existing unitname
|
||||
PkgFile:=PackageGraph.FindUnit(LazPackage,Params.NewClassName,true,true);
|
||||
PkgFile:=PackageGraph.FindUnit(LazPackage,fParams.NewClassName,true,true);
|
||||
if PkgFile<>nil then begin
|
||||
if IDEMessageDialog(lisA2PAmbiguousClassName,
|
||||
Format(lisA2PTheClassNameHasTheSameNameAsTheUnit,
|
||||
[Params.AncestorType, LineEnding, PkgFile.Filename]),
|
||||
[fParams.AncestorType, LineEnding, PkgFile.Filename]),
|
||||
mtError,[mbCancel,mbIgnore])<>mrIgnore
|
||||
then
|
||||
exit;
|
||||
end;
|
||||
|
||||
// check if classname already exists
|
||||
PkgComponent:=TPkgComponent(IDEComponentPalette.FindComponent(Params.NewClassname));
|
||||
PkgComponent:=TPkgComponent(IDEComponentPalette.FindComponent(fParams.NewClassname));
|
||||
if PkgComponent<>nil then begin
|
||||
if IDEMessageDialog(lisA2PClassNameAlreadyExists,
|
||||
Format(lisA2PTheClassNameExistsAlreadyInPackageFile, [Params.NewClassName, LineEnding,
|
||||
Format(lisA2PTheClassNameExistsAlreadyInPackageFile, [fParams.NewClassName, LineEnding,
|
||||
PkgComponent.PkgFile.LazPackage.IDAsString, LineEnding, PkgComponent.PkgFile.Filename]),
|
||||
mtError,[mbCancel,mbIgnore])<>mrIgnore
|
||||
then
|
||||
@ -583,160 +393,38 @@ begin
|
||||
end;
|
||||
|
||||
// check filename
|
||||
if not CheckAddingPackageUnit(LazPackage,Params.AddType,
|
||||
OnGetIDEFileInfo,Params.UnitFilename) then exit;
|
||||
if not CheckAddingPackageUnit(LazPackage, d2ptNewComponent,
|
||||
OnGetIDEFileInfo, fParams.UnitFilename) then exit;
|
||||
|
||||
// create dependency if needed
|
||||
PkgComponent:=TPkgComponent(IDEComponentPalette.FindComponent(Params.AncestorType));
|
||||
PkgComponent:=TPkgComponent(IDEComponentPalette.FindComponent(fParams.AncestorType));
|
||||
if PkgComponent<>nil then begin
|
||||
Params.UsedUnitname:=PkgComponent.GetUnitName;
|
||||
fParams.UsedUnitname:=PkgComponent.GetUnitName;
|
||||
ARequiredPackage:=PkgComponent.PkgFile.LazPackage;
|
||||
ARequiredPackage:=TLazPackage(PackageEditingInterface.RedirectPackageDependency(ARequiredPackage));
|
||||
if (LazPackage<>ARequiredPackage)
|
||||
and (not LazPackage.Requires(PkgComponent.PkgFile.LazPackage))
|
||||
then
|
||||
Params.Dependency:=ARequiredPackage.CreateDependencyWithOwner(nil);
|
||||
fParams.Dependency:=ARequiredPackage.CreateDependencyWithOwner(nil);
|
||||
end;
|
||||
ModalResult:=mrOk;
|
||||
end;
|
||||
|
||||
procedure TAddToPackageDlg.NewComponentPageResize(Sender: TObject);
|
||||
var
|
||||
x: Integer;
|
||||
begin
|
||||
x:=0;
|
||||
x:=Max(x,AncestorTypeLabel.Left+AncestorTypeLabel.Width);
|
||||
x:=Max(x,ClassNameLabel.Left+ClassNameLabel.Width);
|
||||
x:=Max(x,PalettePageLabel.Left+PalettePageLabel.Width);
|
||||
x:=Max(x,ComponentUnitFileLabel.Left+ComponentUnitFileLabel.Width);
|
||||
x:=Max(x,ComponentUnitNameLabel.Left+ComponentUnitNameLabel.Width);
|
||||
x:=Max(x,ComponentIconLabel.Left+ComponentIconLabel.Width);
|
||||
AncestorComboBox.Left:=x+6;
|
||||
end;
|
||||
|
||||
procedure TAddToPackageDlg.SetLazPackage(const AValue: TLazPackage);
|
||||
begin
|
||||
if FLazPackage=AValue then exit;
|
||||
FLazPackage:=AValue;
|
||||
Params.Pkg:=FLazPackage;
|
||||
fParams.Pkg:=FLazPackage;
|
||||
UpdateAvailableAncestorTypes;
|
||||
UpdateAvailablePageNames;
|
||||
end;
|
||||
|
||||
function TAddToPackageDlg.GetActivatePage: TAddToPkgType;
|
||||
begin
|
||||
if PageControl1.ActivePage=NewComponentPage then
|
||||
Result:=d2ptNewComponent
|
||||
else {if PageControl1.ActivePage=AddFilesPage then } begin
|
||||
Assert(PageControl1.ActivePage=AddFilesPage,
|
||||
'TAddToPackageDlg.GetActivatePage: PageControl1.ActivePage <> AddFilesPage');
|
||||
Result:=d2ptFiles;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TAddToPackageDlg.SetActivatePage(AValue: TAddToPkgType);
|
||||
begin
|
||||
case AValue of
|
||||
d2ptNewComponent: PageControl1.ActivePage:=NewComponentPage;
|
||||
d2ptFiles: PageControl1.ActivePage:=AddFilesPage;
|
||||
else raise Exception.Create('TAddToPackageDlg.SetActivatePage: invalid value.');
|
||||
end;
|
||||
end;
|
||||
|
||||
function TAddToPackageDlg.CheckNewCompOk: Boolean;
|
||||
begin
|
||||
Result:=(AncestorComboBox.Text<>'') and (ClassNameEdit.Text<>'') and (ComponentUnitNameEdit.Text<>'');
|
||||
ButtonPanel1.OKButton.Enabled:=Result;
|
||||
end;
|
||||
|
||||
procedure TAddToPackageDlg.PageControl1Change(Sender: TObject);
|
||||
begin
|
||||
case PageControl1.PageIndex of
|
||||
0: begin // New Component
|
||||
ButtonPanel1.OkButton.Caption:=lisA2PCreateNewComp;
|
||||
ButtonPanel1.OkButton.OnClick:=@NewComponentButtonClick;
|
||||
CheckNewCompOk;
|
||||
end;
|
||||
1: begin // Add Files
|
||||
ButtonPanel1.OkButton.Caption:=lisA2PAddFilesToPackage;
|
||||
ButtonPanel1.OkButton.OnClick:=@FilesAddButtonClick;
|
||||
CheckFilesButtonsOk;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TAddToPackageDlg.SetupComponents;
|
||||
begin
|
||||
NewComponentPage.Caption:=lisA2PNewComponent;
|
||||
AddFilesPage.Caption:=lisA2PAddFiles;
|
||||
ButtonPanel1.CancelButton.Caption:=lisCancel;
|
||||
PageControl1.PageIndex:=0;
|
||||
PageControl1Change(PageControl1);
|
||||
SetupNewComponentPage;
|
||||
SetupAddFilesPage;
|
||||
end;
|
||||
|
||||
procedure TAddToPackageDlg.SetupNewComponentPage;
|
||||
begin
|
||||
AncestorTypeLabel.Caption:=lisA2PAncestorType;
|
||||
AncestorComboBox.Text:='';
|
||||
AncestorShowAllCheckBox.Caption:=lisA2PShowAll;
|
||||
ClassNameLabel.Caption:=lisA2PNewClassName;
|
||||
ClassNameEdit.Text:='';
|
||||
PalettePageLabel.Caption:=lisA2PPalettePage;
|
||||
PalettePageCombobox.Text:='';
|
||||
ComponentUnitFileLabel.Caption:=lisA2PUnitFileName2;
|
||||
ComponentUnitFileEdit.Text:='';
|
||||
with ComponentUnitFileBrowseButton do begin
|
||||
Caption:='...';
|
||||
ShowHint:=true;
|
||||
Hint:=lisA2PSaveFileDialog;
|
||||
end;
|
||||
with ComponentUnitFileShortenButton do begin
|
||||
Caption:='<>';
|
||||
ShowHint:=true;
|
||||
Hint:=lisA2PShortenOrExpandFilename;
|
||||
end;
|
||||
ComponentUnitNameLabel.Caption:=lisA2PUnitName;
|
||||
ComponentUnitNameEdit.Text:='';
|
||||
ComponentIconLabel.Caption:=lisA2PIconAndSize;
|
||||
ComponentIconBitBtn.Width:=ComponentPaletteBtnWidth;
|
||||
ComponentIconBitBtn.Height:=ComponentPaletteBtnHeight;
|
||||
end;
|
||||
|
||||
procedure TAddToPackageDlg.SetupAddFilesPage;
|
||||
var
|
||||
CurColumn: TListColumn;
|
||||
begin
|
||||
with FilesListView do begin
|
||||
CurColumn:=Columns[0];
|
||||
CurColumn.Width:=200;
|
||||
CurColumn.Caption:=lisA2PFilename2;
|
||||
CurColumn:=Columns[1];
|
||||
CurColumn.Caption:=dlgEnvType;
|
||||
end;
|
||||
|
||||
with FilesDirButton do begin
|
||||
Caption:=lisAddFilesInDirectory;
|
||||
IDEImages.AssignImage(FilesDirButton, 'pkg_files');
|
||||
end;
|
||||
|
||||
with FilesShortenButton do begin
|
||||
Caption:=lisA2PSwitchPaths;
|
||||
ShowHint:=true;
|
||||
Hint:=lisToggleShowingFilenamesWithFullPathOrWithRelativePa;
|
||||
end;
|
||||
|
||||
with FilesDeleteButton do begin
|
||||
Caption:=lisDelete;
|
||||
ShowHint:=true;
|
||||
Hint:=lisDeleteSelectedFiles;
|
||||
IDEImages.AssignImage(FilesDeleteButton, 'laz_delete');
|
||||
end;
|
||||
|
||||
LabelIconInfo.Caption:=lisNoneClickToChooseOne;
|
||||
end;
|
||||
|
||||
procedure TAddToPackageDlg.OnIterateComponentClasses(PkgComponent: TPkgComponent);
|
||||
begin
|
||||
if fPkgComponents.Find(PkgComponent)=nil then
|
||||
@ -812,27 +500,6 @@ begin
|
||||
Result:=TrimFilename(CreateAbsoluteSearchPath(Filename,LazPackage.Directory));
|
||||
end;
|
||||
|
||||
function TAddToPackageDlg.FindFileInFilesList(AFilename: string): Integer;
|
||||
var
|
||||
i: Integer;
|
||||
Item: TListItem;
|
||||
OtherFilename: String;
|
||||
begin
|
||||
if not FilenameIsAbsolute(AFilename) then
|
||||
LazPackage.LongenFilename(AFilename);
|
||||
for i:=0 to FilesListView.Items.Count-1 do begin
|
||||
Item:=FilesListView.Items[i];
|
||||
OtherFilename:=Item.Caption;
|
||||
if not FilenameIsAbsolute(OtherFilename) then
|
||||
LazPackage.LongenFilename(OtherFilename);
|
||||
if CompareFilenames(AFilename,OtherFilename)=0 then begin
|
||||
Result:=i;
|
||||
exit;
|
||||
end;
|
||||
end;
|
||||
Result:=-1;
|
||||
end;
|
||||
|
||||
procedure TAddToPackageDlg.LoadComponentIcon(AFilename: string);
|
||||
var
|
||||
ShortFilename: String;
|
||||
@ -917,7 +584,6 @@ end;
|
||||
|
||||
procedure TAddToPkgResult.Clear;
|
||||
begin
|
||||
AddType:=d2ptUnit;
|
||||
Dependency:=nil;
|
||||
UnitFilename:='';
|
||||
Unit_Name:='';
|
||||
|
@ -15,7 +15,7 @@ object PackageEditorForm: TPackageEditorForm
|
||||
OnCreate = FormCreate
|
||||
OnDestroy = FormDestroy
|
||||
OnDropFiles = FormDropFiles
|
||||
LCLVersion = '1.7'
|
||||
LCLVersion = '1.9.0.0'
|
||||
object ToolBar: TToolBar
|
||||
Left = 0
|
||||
Height = 48
|
||||
@ -23,24 +23,25 @@ object PackageEditorForm: TPackageEditorForm
|
||||
Width = 464
|
||||
AutoSize = True
|
||||
ButtonHeight = 46
|
||||
ButtonWidth = 23
|
||||
ShowCaptions = True
|
||||
TabOrder = 0
|
||||
end
|
||||
object PropsGroupBox: TGroupBox
|
||||
Left = 0
|
||||
Height = 118
|
||||
Top = 314
|
||||
Top = 316
|
||||
Width = 464
|
||||
Align = alBottom
|
||||
Caption = 'PropsGroupBox'
|
||||
ClientHeight = 98
|
||||
ClientWidth = 460
|
||||
ClientWidth = 462
|
||||
TabOrder = 3
|
||||
object CallRegisterProcCheckBox: TCheckBox
|
||||
Left = 0
|
||||
Height = 19
|
||||
Height = 21
|
||||
Top = 0
|
||||
Width = 158
|
||||
Width = 187
|
||||
Caption = 'CallRegisterProcCheckBox'
|
||||
OnChange = CallRegisterProcCheckBoxChange
|
||||
ParentShowHint = False
|
||||
@ -50,10 +51,10 @@ object PackageEditorForm: TPackageEditorForm
|
||||
object AddToUsesPkgSectionCheckBox: TCheckBox
|
||||
AnchorSideLeft.Control = CallRegisterProcCheckBox
|
||||
AnchorSideLeft.Side = asrBottom
|
||||
Left = 168
|
||||
Height = 19
|
||||
Left = 197
|
||||
Height = 21
|
||||
Top = 0
|
||||
Width = 191
|
||||
Width = 222
|
||||
BorderSpacing.Left = 10
|
||||
Caption = 'AddToUsesPkgSectionCheckBox'
|
||||
OnChange = AddToUsesPkgSectionCheckBoxChange
|
||||
@ -66,9 +67,9 @@ object PackageEditorForm: TPackageEditorForm
|
||||
AnchorSideTop.Control = MinVersionEdit
|
||||
AnchorSideTop.Side = asrCenter
|
||||
Left = 0
|
||||
Height = 19
|
||||
Height = 21
|
||||
Top = 2
|
||||
Width = 151
|
||||
Width = 179
|
||||
Caption = 'UseMinVersionCheckBox'
|
||||
OnChange = UseMinVersionCheckBoxChange
|
||||
TabOrder = 2
|
||||
@ -77,8 +78,8 @@ object PackageEditorForm: TPackageEditorForm
|
||||
AnchorSideLeft.Control = UseMinVersionCheckBox
|
||||
AnchorSideLeft.Side = asrBottom
|
||||
AnchorSideTop.Control = PropsGroupBox
|
||||
Left = 161
|
||||
Height = 23
|
||||
Left = 189
|
||||
Height = 25
|
||||
Top = 0
|
||||
Width = 100
|
||||
BorderSpacing.Left = 10
|
||||
@ -91,9 +92,9 @@ object PackageEditorForm: TPackageEditorForm
|
||||
AnchorSideTop.Control = MaxVersionEdit
|
||||
AnchorSideTop.Side = asrCenter
|
||||
Left = 0
|
||||
Height = 19
|
||||
Top = 27
|
||||
Width = 152
|
||||
Height = 21
|
||||
Top = 29
|
||||
Width = 183
|
||||
Caption = 'UseMaxVersionCheckBox'
|
||||
OnChange = UseMaxVersionCheckBoxChange
|
||||
TabOrder = 4
|
||||
@ -103,9 +104,9 @@ object PackageEditorForm: TPackageEditorForm
|
||||
AnchorSideLeft.Side = asrBottom
|
||||
AnchorSideTop.Control = MinVersionEdit
|
||||
AnchorSideTop.Side = asrBottom
|
||||
Left = 162
|
||||
Height = 23
|
||||
Top = 25
|
||||
Left = 193
|
||||
Height = 25
|
||||
Top = 27
|
||||
Width = 100
|
||||
BorderSpacing.Left = 10
|
||||
BorderSpacing.Top = 2
|
||||
@ -119,8 +120,8 @@ object PackageEditorForm: TPackageEditorForm
|
||||
AnchorSideTop.Side = asrBottom
|
||||
Left = 0
|
||||
Height = 25
|
||||
Top = 54
|
||||
Width = 159
|
||||
Top = 58
|
||||
Width = 163
|
||||
AutoSize = True
|
||||
BorderSpacing.Top = 6
|
||||
Caption = 'ApplyDependencyButton'
|
||||
@ -131,36 +132,38 @@ object PackageEditorForm: TPackageEditorForm
|
||||
AnchorSideTop.Control = CallRegisterProcCheckBox
|
||||
AnchorSideTop.Side = asrBottom
|
||||
Left = 0
|
||||
Height = 73
|
||||
Top = 25
|
||||
Width = 460
|
||||
Height = 71
|
||||
Top = 27
|
||||
Width = 462
|
||||
Align = alBottom
|
||||
Anchors = [akTop, akLeft, akRight, akBottom]
|
||||
BorderSpacing.Top = 6
|
||||
Caption = 'RegisteredPluginsGroupBox'
|
||||
ClientHeight = 53
|
||||
ClientWidth = 456
|
||||
ClientHeight = 51
|
||||
ClientWidth = 460
|
||||
TabOrder = 7
|
||||
object RegisteredListBox: TListBox
|
||||
Left = 0
|
||||
Height = 53
|
||||
Height = 51
|
||||
Top = 0
|
||||
Width = 456
|
||||
Width = 460
|
||||
Align = alClient
|
||||
ItemHeight = 0
|
||||
OnDrawItem = RegisteredListBoxDrawItem
|
||||
ScrollWidth = 458
|
||||
Style = lbOwnerDrawFixed
|
||||
TabOrder = 0
|
||||
TopIndex = -1
|
||||
end
|
||||
end
|
||||
object DisableI18NForLFMCheckBox: TCheckBox
|
||||
AnchorSideLeft.Control = AddToUsesPkgSectionCheckBox
|
||||
AnchorSideLeft.Side = asrBottom
|
||||
AnchorSideTop.Control = AddToUsesPkgSectionCheckBox
|
||||
Left = 365
|
||||
Height = 19
|
||||
Left = 425
|
||||
Height = 21
|
||||
Top = 0
|
||||
Width = 174
|
||||
Width = 209
|
||||
BorderSpacing.Left = 6
|
||||
Caption = 'DisableI18NForLFMCheckBox'
|
||||
OnChange = DisableI18NForLFMCheckBoxChange
|
||||
@ -171,8 +174,8 @@ object PackageEditorForm: TPackageEditorForm
|
||||
end
|
||||
object StatusBar: TStatusBar
|
||||
Left = 0
|
||||
Height = 23
|
||||
Top = 432
|
||||
Height = 21
|
||||
Top = 434
|
||||
Width = 464
|
||||
Panels = <>
|
||||
end
|
||||
@ -180,7 +183,7 @@ object PackageEditorForm: TPackageEditorForm
|
||||
Cursor = crVSplit
|
||||
Left = 0
|
||||
Height = 5
|
||||
Top = 309
|
||||
Top = 311
|
||||
Width = 464
|
||||
Align = alBottom
|
||||
ResizeAnchor = akBottom
|
||||
@ -243,14 +246,13 @@ object PackageEditorForm: TPackageEditorForm
|
||||
AnchorSideTop.Side = asrCenter
|
||||
AnchorSideRight.Side = asrBottom
|
||||
Left = 163
|
||||
Height = 23
|
||||
Top = 3
|
||||
Height = 25
|
||||
Top = 2
|
||||
Width = 300
|
||||
UseFormActivate = True
|
||||
ButtonWidth = 23
|
||||
NumGlyphs = 1
|
||||
Anchors = [akTop, akLeft, akRight]
|
||||
BorderSpacing.Left = 11
|
||||
NumGlyphs = 1
|
||||
MaxLength = 0
|
||||
ParentFont = False
|
||||
TabOrder = 0
|
||||
@ -313,12 +315,11 @@ object PackageEditorForm: TPackageEditorForm
|
||||
end
|
||||
object ItemsTreeView: TTreeView
|
||||
Left = 0
|
||||
Height = 232
|
||||
Height = 234
|
||||
Top = 77
|
||||
Width = 464
|
||||
Align = alClient
|
||||
BorderSpacing.Top = 1
|
||||
DefaultItemHeight = 18
|
||||
DragMode = dmAutomatic
|
||||
MultiSelect = True
|
||||
PopupMenu = ItemsPopupMenu
|
||||
@ -359,10 +360,6 @@ object PackageEditorForm: TPackageEditorForm
|
||||
object MenuItem1: TMenuItem
|
||||
Caption = '-'
|
||||
end
|
||||
object mnuAddDiskFiles: TMenuItem
|
||||
Caption = 'Add multiple files...'
|
||||
OnClick = mnuAddDiskFilesClick
|
||||
end
|
||||
object mnuAddNewFile: TMenuItem
|
||||
Caption = 'New file of type...'
|
||||
OnClick = mnuAddNewFileClick
|
||||
|
@ -58,7 +58,6 @@ var
|
||||
// General actions for the Files and Required packages root nodes.
|
||||
// Duplicates actions found under the "Add" button.
|
||||
PkgEditMenuAddDiskFile: TIDEMenuCommand;
|
||||
PkgEditMenuAddDiskFiles: TIDEMenuCommand;
|
||||
PkgEditMenuAddNewFile: TIDEMenuCommand;
|
||||
PkgEditMenuAddNewComp: TIDEMenuCommand;
|
||||
PkgEditMenuAddNewReqr: TIDEMenuCommand;
|
||||
@ -189,7 +188,6 @@ type
|
||||
MenuItem1: TMenuItem;
|
||||
mnuAddFPMakeReq: TMenuItem;
|
||||
mnuAddDiskFile: TMenuItem;
|
||||
mnuAddDiskFiles: TMenuItem;
|
||||
mnuAddNewFile: TMenuItem;
|
||||
mnuAddNewComp: TMenuItem;
|
||||
mnuAddNewReqr: TMenuItem;
|
||||
@ -267,7 +265,6 @@ type
|
||||
State: TDragState; var Accept: Boolean);
|
||||
procedure ItemsTreeViewKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
|
||||
procedure mnuAddDiskFileClick(Sender: TObject);
|
||||
procedure mnuAddDiskFilesClick(Sender: TObject);
|
||||
procedure mnuAddFPMakeReqClick(Sender: TObject);
|
||||
procedure mnuAddNewCompClick(Sender: TObject);
|
||||
procedure mnuAddNewReqrClick(Sender: TObject);
|
||||
@ -336,7 +333,6 @@ type
|
||||
procedure SetSortAlphabetically(const AValue: boolean);
|
||||
procedure SetupComponents;
|
||||
function OnTreeViewGetImageIndex({%H-}Str: String; Data: TObject; var {%H-}AIsEnabled: Boolean): Integer;
|
||||
procedure ShowAddDialogEx(AType: TAddToPkgType);
|
||||
procedure UpdateNodeImage(TVNode: TTreeNode);
|
||||
procedure UpdateNodeImage(TVNode: TTreeNode; NodeData: TPENodeData; Item: TObject);
|
||||
procedure UpdatePending;
|
||||
@ -358,7 +354,6 @@ type
|
||||
function CanBeAddedToProject: boolean;
|
||||
protected
|
||||
fFlags: TPEFlags;
|
||||
fLastDlgPage: TAddToPkgType;
|
||||
procedure SetLazPackage(const AValue: TLazPackage); override;
|
||||
property IdleConnected: boolean read FIdleConnected write SetIdleConnected;
|
||||
public
|
||||
@ -378,7 +373,7 @@ type
|
||||
procedure DoSave(SaveAs: boolean);
|
||||
procedure DoSortFiles;
|
||||
function DoOpenPkgFile(PkgFile: TPkgFile): TModalResult;
|
||||
function ShowAddDialog(var DlgPage: TAddToPkgType): TModalResult;
|
||||
function ShowAddDialog: TModalResult;
|
||||
function ShowAddDepDialog: TModalResult;
|
||||
function ShowAddFPMakeDepDialog: TModalResult;
|
||||
function PkgNameToFormName(const PkgName: string): string;
|
||||
@ -572,9 +567,8 @@ begin
|
||||
PkgEditMenuSectionFile:=RegisterIDEMenuSection(PackageEditorMenuFilesRoot,'File');
|
||||
AParent:=PkgEditMenuSectionFile;
|
||||
PkgEditMenuAddDiskFile:=RegisterIDEMenuCommand(AParent,'Add disk file',lisPckEditAddFilesFromFileSystem);
|
||||
PkgEditMenuAddDiskFiles:=RegisterIDEMenuCommand(AParent,'Add disk files',lisAddFilesInDirectory);
|
||||
PkgEditMenuAddNewFile:=RegisterIDEMenuCommand(AParent,'New file',lisA2PNewFile);
|
||||
PkgEditMenuAddNewComp:=RegisterIDEMenuCommand(AParent,'New component',lisA2PNewComponent);
|
||||
PkgEditMenuAddNewComp:=RegisterIDEMenuCommand(AParent,'New component',lisMenuNewComponent);
|
||||
PkgEditMenuAddNewReqr:=RegisterIDEMenuCommand(AParent,'New requirement',lisProjAddNewRequirement);
|
||||
PkgEditMenuAddNewFPMakeReqr:=RegisterIDEMenuCommand(AParent,'New FPMake requirement',lisProjAddNewFPMakeRequirement);
|
||||
//
|
||||
@ -841,8 +835,6 @@ begin
|
||||
// Files root node
|
||||
SetItem(PkgEditMenuAddDiskFile, @mnuAddDiskFileClick, UserSelection=[pstFilesNode],
|
||||
Writable);
|
||||
SetItem(PkgEditMenuAddDiskFiles, @mnuAddDiskFilesClick, UserSelection=[pstFilesNode],
|
||||
Writable);
|
||||
SetItem(PkgEditMenuAddNewFile, @mnuAddNewFileClick, UserSelection=[pstFilesNode],
|
||||
Writable);
|
||||
SetItem(PkgEditMenuAddNewComp, @mnuAddNewCompClick, UserSelection=[pstFilesNode],
|
||||
@ -1075,22 +1067,6 @@ begin
|
||||
Key := VK_UNKNOWN;
|
||||
end;
|
||||
|
||||
procedure TPackageEditorForm.ShowAddDialogEx(AType: TAddToPkgType);
|
||||
begin
|
||||
if LazPackage=nil then exit;
|
||||
BeginUpdate;
|
||||
try
|
||||
ShowAddDialog(AType);
|
||||
finally
|
||||
EndUpdate;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TPackageEditorForm.mnuAddDiskFilesClick(Sender: TObject);
|
||||
begin
|
||||
ShowAddDialogEx(d2ptFiles);
|
||||
end;
|
||||
|
||||
procedure TPackageEditorForm.mnuAddFPMakeReqClick(Sender: TObject);
|
||||
begin
|
||||
ShowAddFPMakeDepDialog
|
||||
@ -1098,7 +1074,7 @@ end;
|
||||
|
||||
procedure TPackageEditorForm.mnuAddNewCompClick(Sender: TObject);
|
||||
begin
|
||||
ShowAddDialogEx(d2ptNewComponent);
|
||||
ShowAddDialog;
|
||||
end;
|
||||
|
||||
procedure TPackageEditorForm.mnuAddNewReqrClick(Sender: TObject);
|
||||
@ -1980,9 +1956,8 @@ begin
|
||||
MoreBitBtn.DropdownMenu := MorePopupMenu;
|
||||
|
||||
mnuAddDiskFile.Caption := lisPckEditAddFilesFromFileSystem;
|
||||
mnuAddDiskFiles.Caption := lisAddFilesInDirectory;
|
||||
mnuAddNewFile.Caption := lisA2PNewFile;
|
||||
mnuAddNewComp.Caption := lisA2PNewComponent;
|
||||
mnuAddNewComp.Caption := lisMenuNewComponent;
|
||||
mnuAddNewReqr.Caption := lisProjAddNewRequirement;
|
||||
mnuAddFPMakeReq.Caption := lisProjAddNewFPMakeRequirement;
|
||||
|
||||
@ -2153,9 +2128,9 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
function TPackageEditorForm.ShowAddDialog(var DlgPage: TAddToPkgType): TModalResult;
|
||||
function TPackageEditorForm.ShowAddDialog: TModalResult;
|
||||
var
|
||||
IgnoreUnitPaths, IgnoreIncPaths: TFilenameToStringTree;
|
||||
IgnoreUnitPaths: TFilenameToStringTree;
|
||||
|
||||
function PkgDependsOn(PkgName: string): boolean;
|
||||
begin
|
||||
@ -2163,50 +2138,6 @@ var
|
||||
Result:=PackageGraph.FindDependencyRecursively(LazPackage.FirstRequiredDependency,PkgName)<>nil;
|
||||
end;
|
||||
|
||||
procedure AddUnit(AddParams: TAddToPkgResult);
|
||||
var
|
||||
NewLFMFilename: String;
|
||||
NewLRSFilename: String;
|
||||
begin
|
||||
NewLFMFilename:='';
|
||||
NewLRSFilename:='';
|
||||
// add lfm file
|
||||
if AddParams.AutoAddLFMFile then begin
|
||||
NewLFMFilename:=ChangeFileExt(AddParams.UnitFilename,'.lfm');
|
||||
if FileExistsUTF8(NewLFMFilename)
|
||||
and (LazPackage.FindPkgFile(NewLFMFilename,true,false)=nil) then
|
||||
LazPackage.AddFile(NewLFMFilename,'',pftLFM,[],cpNormal)
|
||||
else
|
||||
NewLFMFilename:='';
|
||||
end;
|
||||
// add lrs file
|
||||
if AddParams.AutoAddLRSFile then begin
|
||||
NewLRSFilename:=ChangeFileExt(AddParams.UnitFilename,'.lrs');
|
||||
if FileExistsUTF8(NewLRSFilename)
|
||||
and (LazPackage.FindPkgFile(NewLRSFilename,true,false)=nil) then
|
||||
LazPackage.AddFile(NewLRSFilename,'',pftLRS,[],cpNormal)
|
||||
else
|
||||
NewLRSFilename:='';
|
||||
end;
|
||||
ExtendUnitIncPathForNewUnit(AddParams.UnitFilename,NewLRSFilename,
|
||||
IgnoreUnitPaths);
|
||||
// add unit file
|
||||
with AddParams do
|
||||
LazPackage.AddFile(UnitFilename,Unit_Name,FileType,PkgFileFlags,cpNormal);
|
||||
FreeAndNil(FNextSelectedPart);
|
||||
FNextSelectedPart:=TPENodeData.Create(penFile,AddParams.UnitFilename,false);
|
||||
PackageEditors.DeleteAmbiguousFiles(LazPackage,AddParams.UnitFilename);
|
||||
end;
|
||||
|
||||
procedure AddVirtualUnit(AddParams: TAddToPkgResult);
|
||||
begin
|
||||
with AddParams do
|
||||
LazPackage.AddFile(UnitFilename,Unit_Name,FileType,PkgFileFlags,cpNormal);
|
||||
FreeAndNil(FNextSelectedPart);
|
||||
FNextSelectedPart:=TPENodeData.Create(penFile,AddParams.UnitFilename,false);
|
||||
PackageEditors.DeleteAmbiguousFiles(LazPackage,AddParams.UnitFilename);
|
||||
end;
|
||||
|
||||
procedure AddNewComponent(AddParams: TAddToPkgResult);
|
||||
begin
|
||||
ExtendUnitIncPathForNewUnit(AddParams.UnitFilename,'',IgnoreUnitPaths);
|
||||
@ -2227,44 +2158,24 @@ var
|
||||
PackageEditors.CreateNewFile(Self,AddParams);
|
||||
end;
|
||||
|
||||
procedure AddFile(AddParams: TAddToPkgResult);
|
||||
begin
|
||||
// add file
|
||||
with AddParams do begin
|
||||
if (CompareFileExt(UnitFilename,'.inc',false)=0)
|
||||
or (CompareFileExt(UnitFilename,'.lrs',false)=0) then
|
||||
ExtendIncPathForNewIncludeFile(UnitFilename,IgnoreIncPaths);
|
||||
LazPackage.AddFile(UnitFilename,Unit_Name,FileType,PkgFileFlags,cpNormal);
|
||||
end;
|
||||
FreeAndNil(FNextSelectedPart);
|
||||
FNextSelectedPart:=TPENodeData.Create(penFile,AddParams.UnitFilename,false);
|
||||
end;
|
||||
|
||||
var
|
||||
AddParams: TAddToPkgResult;
|
||||
OldParams: TAddToPkgResult;
|
||||
AddParams, OldParams: TAddToPkgResult;
|
||||
begin
|
||||
if LazPackage.ReadOnly then begin
|
||||
UpdateButtons;
|
||||
exit(mrCancel);
|
||||
end;
|
||||
|
||||
Result:=ShowAddToPackageDlg(LazPackage,AddParams,PackageEditors.OnGetIDEFileInfo,
|
||||
PackageEditors.OnGetUnitRegisterInfo,DlgPage);
|
||||
fLastDlgPage:=DlgPage;
|
||||
Result:=ShowAddToPackageDlg(LazPackage, AddParams,
|
||||
PackageEditors.OnGetIDEFileInfo,
|
||||
PackageEditors.OnGetUnitRegisterInfo);
|
||||
if Result<>mrOk then exit;
|
||||
|
||||
PackageGraph.BeginUpdate(false);
|
||||
IgnoreUnitPaths:=nil;
|
||||
IgnoreIncPaths:=nil;
|
||||
try
|
||||
while AddParams<>nil do begin
|
||||
case AddParams.AddType of
|
||||
d2ptUnit: AddUnit(AddParams);
|
||||
d2ptVirtualUnit: AddVirtualUnit(AddParams);
|
||||
d2ptNewComponent: AddNewComponent(AddParams);
|
||||
d2ptFile: AddFile(AddParams);
|
||||
end;
|
||||
AddNewComponent(AddParams);
|
||||
OldParams:=AddParams;
|
||||
AddParams:=AddParams.Next;
|
||||
OldParams.Next:=nil;
|
||||
@ -2274,7 +2185,6 @@ begin
|
||||
Assert(LazPackage.Modified, 'TPackageEditorForm.ShowAddDialog: LazPackage.Modified = False');
|
||||
finally
|
||||
IgnoreUnitPaths.Free;
|
||||
IgnoreIncPaths.Free;
|
||||
PackageGraph.EndUpdate;
|
||||
end;
|
||||
end;
|
||||
|
@ -5208,7 +5208,6 @@ function TPkgManager.DoNewPackageComponent: TModalResult;
|
||||
var
|
||||
APackage: TLazPackage;
|
||||
SaveFlags: TPkgSaveFlags;
|
||||
Page: TAddToPkgType;
|
||||
CurEditor: TPackageEditorForm;
|
||||
begin
|
||||
Result:=ShowNewPkgComponentDialog(APackage);
|
||||
@ -5228,9 +5227,7 @@ begin
|
||||
// save
|
||||
Result:=DoSavePackage(APackage,SaveFlags);
|
||||
if Result<>mrOk then exit;
|
||||
// show new component dialog
|
||||
Page:=d2ptNewComponent;
|
||||
Result:=CurEditor.ShowAddDialog(Page);
|
||||
Result:=CurEditor.ShowAddDialog; // show new component dialog
|
||||
end;
|
||||
|
||||
function TPkgManager.SavePackageFiles(APackage: TLazPackage): TModalResult;
|
||||
|
@ -21,8 +21,7 @@ type
|
||||
d2ptUnit,
|
||||
d2ptVirtualUnit,
|
||||
d2ptNewComponent,
|
||||
d2ptFile,
|
||||
d2ptFiles
|
||||
d2ptFile
|
||||
);
|
||||
|
||||
function CheckAddingPackageUnit(LazPackage: TLazPackage;
|
||||
@ -35,7 +34,7 @@ function CheckAddingPackageDependency(LazPackage: TLazPackage;
|
||||
|
||||
// Projects:
|
||||
|
||||
function CheckAddingProjectFile(AProject: TProject; NewFiles: TStringList;
|
||||
function CheckAddingProjectFile(AProject: TProject; NewFiles: TStrings;
|
||||
var NewFilename: string): TModalResult;
|
||||
|
||||
function CheckAddingProjectDependency(AProject: TProject;
|
||||
@ -280,7 +279,7 @@ end;
|
||||
|
||||
// Project:
|
||||
|
||||
function CheckAddingProjectFile(AProject: TProject; NewFiles: TStringList;
|
||||
function CheckAddingProjectFile(AProject: TProject; NewFiles: TStrings;
|
||||
var NewFilename: string): TModalResult;
|
||||
var
|
||||
ConflictFile: TUnitInfo;
|
||||
|
Loading…
Reference in New Issue
Block a user