mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-07 17:20:55 +02:00
New files for a new EditorFilemanager feature
git-svn-id: trunk@35415 -
This commit is contained in:
parent
5f5da586dd
commit
baaab46a82
2
.gitattributes
vendored
2
.gitattributes
vendored
@ -4117,6 +4117,8 @@ ide/diskdiffsdialog.pas svneol=native#text/pascal
|
||||
ide/editdefinetree.pas svneol=native#text/pascal
|
||||
ide/editmsgscannersdlg.lfm svneol=native#text/plain
|
||||
ide/editmsgscannersdlg.pas svneol=native#text/plain
|
||||
ide/editorfilemanager.lfm svneol=native#text/plain
|
||||
ide/editorfilemanager.pas svneol=native#text/plain
|
||||
ide/editoroptions.pp svneol=native#text/pascal
|
||||
ide/editoroptions.rc svneol=native#text/plain
|
||||
ide/editoroptions.res -text
|
||||
|
135
ide/editorfilemanager.lfm
Normal file
135
ide/editorfilemanager.lfm
Normal file
@ -0,0 +1,135 @@
|
||||
object EditorFileManagerForm: TEditorFileManagerForm
|
||||
Left = 350
|
||||
Height = 336
|
||||
Top = 652
|
||||
Width = 589
|
||||
Caption = 'EditorFileManagerForm'
|
||||
ClientHeight = 336
|
||||
ClientWidth = 589
|
||||
OnCreate = FormCreate
|
||||
Position = poScreenCenter
|
||||
LCLVersion = '0.9.31'
|
||||
object CheckListBox1: TCheckListBox
|
||||
AnchorSideLeft.Control = FilterEdit
|
||||
AnchorSideTop.Control = FilterEdit
|
||||
AnchorSideTop.Side = asrBottom
|
||||
AnchorSideRight.Control = Panel1
|
||||
AnchorSideBottom.Control = ButtonPanel1
|
||||
Left = 6
|
||||
Height = 260
|
||||
Top = 30
|
||||
Width = 452
|
||||
Anchors = [akTop, akLeft, akRight, akBottom]
|
||||
ItemHeight = 0
|
||||
OnClick = CheckListBox1Click
|
||||
OnItemClick = CheckListBox1ItemClick
|
||||
PopupMenu = PopupMenu1
|
||||
TabOrder = 0
|
||||
end
|
||||
object FilterEdit: TListFilterEdit
|
||||
Left = 6
|
||||
Height = 22
|
||||
Top = 8
|
||||
Width = 224
|
||||
ButtonWidth = 23
|
||||
NumGlyphs = 0
|
||||
MaxLength = 0
|
||||
TabOrder = 1
|
||||
FilteredListbox = CheckListBox1
|
||||
end
|
||||
object ButtonPanel1: TButtonPanel
|
||||
Left = 6
|
||||
Height = 34
|
||||
Top = 296
|
||||
Width = 577
|
||||
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 = 2
|
||||
ShowButtons = [pbClose, pbHelp]
|
||||
end
|
||||
object Panel1: TPanel
|
||||
Left = 458
|
||||
Height = 290
|
||||
Top = 0
|
||||
Width = 131
|
||||
Align = alRight
|
||||
AutoSize = True
|
||||
ClientHeight = 290
|
||||
ClientWidth = 131
|
||||
TabOrder = 3
|
||||
object ActivateButton: TBitBtn
|
||||
Left = 23
|
||||
Height = 24
|
||||
Top = 43
|
||||
Width = 81
|
||||
Anchors = []
|
||||
AutoSize = True
|
||||
BorderSpacing.Around = 12
|
||||
Caption = 'Make Active'
|
||||
Enabled = False
|
||||
OnClick = ActivateButtonClick
|
||||
TabOrder = 0
|
||||
end
|
||||
object SelectAllCheckBox: TCheckBox
|
||||
AnchorSideLeft.Control = ActivateButton
|
||||
AnchorSideLeft.Side = asrCenter
|
||||
Left = -1
|
||||
Height = 21
|
||||
Top = 112
|
||||
Width = 129
|
||||
Anchors = [akLeft]
|
||||
BorderSpacing.Around = 12
|
||||
Caption = 'SelectAllCheckBox'
|
||||
OnClick = SelectAllCheckBoxClick
|
||||
TabOrder = 1
|
||||
end
|
||||
object SaveCheckedButton: TBitBtn
|
||||
AnchorSideLeft.Control = ActivateButton
|
||||
AnchorSideLeft.Side = asrCenter
|
||||
Left = 17
|
||||
Height = 24
|
||||
Top = 152
|
||||
Width = 93
|
||||
Anchors = [akLeft]
|
||||
AutoSize = True
|
||||
BorderSpacing.Around = 12
|
||||
Caption = 'Save Checked'
|
||||
Enabled = False
|
||||
OnClick = SaveCheckedButtonClick
|
||||
TabOrder = 2
|
||||
end
|
||||
object CloseCheckedButton: TBitBtn
|
||||
AnchorSideLeft.Control = ActivateButton
|
||||
AnchorSideLeft.Side = asrCenter
|
||||
Left = 15
|
||||
Height = 24
|
||||
Top = 200
|
||||
Width = 96
|
||||
Anchors = [akLeft]
|
||||
AutoSize = True
|
||||
BorderSpacing.Around = 12
|
||||
Caption = 'Close Checked'
|
||||
Enabled = False
|
||||
OnClick = CloseCheckedButtonClick
|
||||
TabOrder = 3
|
||||
end
|
||||
end
|
||||
object PopupMenu1: TPopupMenu
|
||||
left = 304
|
||||
top = 8
|
||||
object ActivateMenuItem: TMenuItem
|
||||
Caption = 'Activate'
|
||||
OnClick = ActivateMenuItemClick
|
||||
end
|
||||
object CloseMenuItem: TMenuItem
|
||||
Caption = 'Close'
|
||||
OnClick = CloseMenuItemClick
|
||||
end
|
||||
end
|
||||
end
|
219
ide/editorfilemanager.pas
Normal file
219
ide/editorfilemanager.pas
Normal file
@ -0,0 +1,219 @@
|
||||
unit EditorFileManager;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, FileUtil, ListFilterEdit, Forms, Controls, Graphics,
|
||||
Dialogs, CheckLst, ButtonPanel, StdCtrls, Buttons, ExtCtrls, Menus,
|
||||
IDEImagesIntf, SourceEditor, LazarusIDEStrConsts;
|
||||
|
||||
type
|
||||
|
||||
{ TEditorFileManagerForm }
|
||||
|
||||
TEditorFileManagerForm = class(TForm)
|
||||
ActivateMenuItem: TMenuItem;
|
||||
ActivateButton: TBitBtn;
|
||||
SaveCheckedButton: TBitBtn;
|
||||
ButtonPanel1: TButtonPanel;
|
||||
CloseCheckedButton: TBitBtn;
|
||||
CloseMenuItem: TMenuItem;
|
||||
Panel1: TPanel;
|
||||
PopupMenu1: TPopupMenu;
|
||||
SelectAllCheckBox: TCheckBox;
|
||||
CheckListBox1: TCheckListBox;
|
||||
FilterEdit: TListFilterEdit;
|
||||
procedure ActivateMenuItemClick(Sender: TObject);
|
||||
procedure CheckListBox1Click(Sender: TObject);
|
||||
procedure CheckListBox1ItemClick(Sender: TObject; Index: integer);
|
||||
procedure CloseCheckedButtonClick(Sender: TObject);
|
||||
procedure SaveCheckedButtonClick(Sender: TObject);
|
||||
procedure CloseMenuItemClick(Sender: TObject);
|
||||
procedure FormCreate(Sender: TObject);
|
||||
procedure ActivateButtonClick(Sender: TObject);
|
||||
procedure SelectAllCheckBoxClick(Sender: TObject);
|
||||
private
|
||||
procedure CloseListItem(ListIndex: integer);
|
||||
procedure UpdateButtons;
|
||||
public
|
||||
|
||||
end;
|
||||
|
||||
function ShowEditorFileManagerForm: TModalResult;
|
||||
|
||||
implementation
|
||||
|
||||
{$R *.lfm}
|
||||
|
||||
function ShowEditorFileManagerForm: TModalResult;
|
||||
begin
|
||||
with TEditorFileManagerForm.Create(Nil) do
|
||||
try
|
||||
Result:=ShowModal;
|
||||
finally
|
||||
Free;
|
||||
end;
|
||||
end;
|
||||
|
||||
{ TEditorFileManagerForm }
|
||||
|
||||
procedure TEditorFileManagerForm.FormCreate(Sender: TObject);
|
||||
var
|
||||
i: Integer;
|
||||
s: String;
|
||||
SrcEdit: TSourceEditor;
|
||||
begin
|
||||
// Populate the list
|
||||
with SourceEditorManager do
|
||||
for i:=0 to SourceEditorCount-1 do begin
|
||||
s:=SourceEditors[i].FileName;
|
||||
SrcEdit:=SourceEditorManager.SourceEditorIntfWithFilename(s);
|
||||
FilterEdit.Data.AddObject(s, SrcEdit);
|
||||
end;
|
||||
FilterEdit.InvalidateFilter;
|
||||
// Captions
|
||||
ActivateMenuItem.Caption:=lisActivateSelected;
|
||||
CloseMenuItem.Caption:=lisMenuClose;
|
||||
SelectAllCheckBox.Caption:=lisMenuSelectAll;
|
||||
ActivateButton.Caption:=lisActivateSelected;
|
||||
SaveCheckedButton.Caption:=lisSaveAllChecked;
|
||||
CloseCheckedButton.Caption:=lisCloseAllChecked;
|
||||
// Icons
|
||||
ActivateMenuItem.ImageIndex:=IDEImages.LoadImage(16, 'laz_open');
|
||||
CloseMenuItem.ImageIndex:=IDEImages.LoadImage(16, 'laz_close');
|
||||
ActivateButton.LoadGlyphFromLazarusResource('laz_open');
|
||||
CloseCheckedButton.LoadGlyphFromLazarusResource('menu_close_all');
|
||||
SaveCheckedButton.LoadGlyphFromLazarusResource('menu_save_all');
|
||||
end;
|
||||
|
||||
procedure TEditorFileManagerForm.CheckListBox1Click(Sender: TObject);
|
||||
var
|
||||
clb: TCheckListBox;
|
||||
HasSelected: Boolean;
|
||||
begin
|
||||
HasSelected:=(Sender as TCheckListBox).SelCount>0;
|
||||
// Enable ActivateButton when there is a selected item.
|
||||
ActivateButton.Enabled:=HasSelected;
|
||||
ActivateMenuItem.Enabled:=HasSelected;
|
||||
end;
|
||||
|
||||
procedure TEditorFileManagerForm.CheckListBox1ItemClick(Sender: TObject; Index: integer);
|
||||
var
|
||||
clb: TCheckListBox;
|
||||
i: Integer;
|
||||
HasChecked: Boolean;
|
||||
begin
|
||||
clb:=Sender as TCheckListBox;
|
||||
// Notify the filter edit that item's checked state has changed.
|
||||
if Index>-1 then
|
||||
FilterEdit.ItemWasClicked(clb.Items[Index], clb.Checked[Index]);
|
||||
// Enable save and close buttons when there are checked items.
|
||||
HasChecked:=False;
|
||||
for i:=clb.Count-1 downto 0 do
|
||||
if clb.Checked[i] then begin
|
||||
HasChecked:=True;
|
||||
Break;
|
||||
end;
|
||||
SaveCheckedButton.Enabled:=HasChecked;
|
||||
CloseCheckedButton.Enabled:=HasChecked;
|
||||
CloseMenuItem.Enabled:=HasChecked;
|
||||
CheckListBox1Click(CheckListBox1); // Call also OnClick handler for other controls.
|
||||
end;
|
||||
|
||||
procedure TEditorFileManagerForm.SelectAllCheckBoxClick(Sender: TObject);
|
||||
var
|
||||
cb: TCheckBox;
|
||||
i: Integer;
|
||||
begin
|
||||
cb:=Sender as TCheckBox;
|
||||
// Caption text : select all / unselect all
|
||||
if cb.Checked then
|
||||
cb.Caption:=lisMenuUnselectAll
|
||||
else
|
||||
cb.Caption:=lisMenuSelectAll;
|
||||
// Set / reset all CheckListBox1 items.
|
||||
for i:=0 to CheckListBox1.Count-1 do begin
|
||||
if CheckListBox1.Checked[i]<>cb.Checked then begin
|
||||
CheckListBox1.Checked[i]:=cb.Checked;
|
||||
FilterEdit.ItemWasClicked(CheckListBox1.Items[i], cb.Checked); // Notify the filter
|
||||
end;
|
||||
end;
|
||||
CheckListBox1ItemClick(CheckListBox1, 0);
|
||||
end;
|
||||
|
||||
procedure TEditorFileManagerForm.SaveCheckedButtonClick(Sender: TObject);
|
||||
var
|
||||
i: Integer;
|
||||
SrcEdit: TSourceEditor;
|
||||
begin
|
||||
ShowMessage('Under construction ...'); Exit;
|
||||
for i:=CheckListBox1.Count-1 downto 0 do
|
||||
if CheckListBox1.Checked[i] then begin
|
||||
SrcEdit:=SourceEditorManager.SourceEditorIntfWithFilename(CheckListBox1.Items[i]);
|
||||
// ToDo: save it somehow
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TEditorFileManagerForm.CloseCheckedButtonClick(Sender: TObject);
|
||||
var
|
||||
i: Integer;
|
||||
SrcEdit: TSourceEditor;
|
||||
begin
|
||||
for i:=CheckListBox1.Count-1 downto 0 do
|
||||
if CheckListBox1.Checked[i] then
|
||||
CloseListItem(i);
|
||||
UpdateButtons;
|
||||
end;
|
||||
|
||||
procedure TEditorFileManagerForm.CloseMenuItemClick(Sender: TObject);
|
||||
begin
|
||||
CloseListItem(CheckListBox1.ItemIndex);
|
||||
UpdateButtons;
|
||||
end;
|
||||
|
||||
procedure TEditorFileManagerForm.ActivateMenuItemClick(Sender: TObject);
|
||||
begin
|
||||
ActivateButtonClick(nil);
|
||||
end;
|
||||
|
||||
procedure TEditorFileManagerForm.ActivateButtonClick(Sender: TObject);
|
||||
var
|
||||
i: Integer;
|
||||
SrcEdit: TSourceEditor;
|
||||
begin
|
||||
for i:=0 to CheckListBox1.Count-1 do
|
||||
if CheckListBox1.Selected[i] then begin // Find first selected.
|
||||
SrcEdit:=SourceEditorManager.SourceEditorIntfWithFilename(
|
||||
CheckListBox1.Items[CheckListBox1.ItemIndex]);
|
||||
SrcEdit.Activate;
|
||||
Break;
|
||||
end;
|
||||
end;
|
||||
|
||||
// Private methods
|
||||
|
||||
procedure TEditorFileManagerForm.CloseListItem(ListIndex: integer);
|
||||
var
|
||||
SrcEdit: TSourceEditor;
|
||||
s: String;
|
||||
begin
|
||||
s:=CheckListBox1.Items[ListIndex];
|
||||
SrcEdit:=SourceEditorManager.SourceEditorIntfWithFilename(s);
|
||||
if Assigned(SrcEdit) then begin
|
||||
SrcEdit.SourceNotebook.CloseFile(SrcEdit.PageIndex);
|
||||
CheckListBox1.Items.Delete(ListIndex);
|
||||
FilterEdit.RemoveItem(s);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TEditorFileManagerForm.UpdateButtons;
|
||||
// Update the filter and buttons. Reuse event handlers for it.
|
||||
begin
|
||||
FilterEdit.InvalidateFilter;
|
||||
CheckListBox1ItemClick(CheckListBox1, 0);
|
||||
end;
|
||||
|
||||
end.
|
||||
|
Loading…
Reference in New Issue
Block a user