IDE: Improve ManageExamples dialog. Get list of dirs dynamically. Show README.txt.

git-svn-id: trunk@32956 -
This commit is contained in:
juha 2011-10-18 11:27:17 +00:00
parent 61a8bcf484
commit a9fc743264
3 changed files with 321 additions and 131 deletions

View File

@ -420,7 +420,9 @@ resourcestring
lisMenuBuildLazarusProf = 'Build Lazarus with profile: %s'; lisMenuBuildLazarusProf = 'Build Lazarus with profile: %s';
lisMenuConfigureBuildLazarus = 'Configure "Build Lazarus" ...'; lisMenuConfigureBuildLazarus = 'Configure "Build Lazarus" ...';
lisRootDirectoryForProjects = 'Root directory for projects'; lisSearchProjectsFrom = 'Search projects from';
lisIncludeExamples = 'Include Examples';
lisIncludeTestcases = 'Include Testcases';
lisMenuGeneralOptions = 'Options ...'; lisMenuGeneralOptions = 'Options ...';
lisMenuEditCodeTemplates = 'Code Templates ...'; lisMenuEditCodeTemplates = 'Code Templates ...';
lisMenuCodeToolsDefinesEditor = 'CodeTools defines editor ...'; lisMenuCodeToolsDefinesEditor = 'CodeTools defines editor ...';
@ -2837,6 +2839,7 @@ resourcestring
lisConfirmBuildAllProfiles = 'Lazarus will be rebuilt with the following profiles:%sContinue?'; lisConfirmBuildAllProfiles = 'Lazarus will be rebuilt with the following profiles:%sContinue?';
lisNoBuildProfilesSelected = 'No profiles are selected to be built.'; lisNoBuildProfilesSelected = 'No profiles are selected to be built.';
lisCleanLazarusSource = 'Clean Lazarus Source'; lisCleanLazarusSource = 'Clean Lazarus Source';
lisLazarusSource = 'Lazarus Source';
lisMakeNotFound = 'Make not found'; lisMakeNotFound = 'Make not found';
lisTheProgramMakeWasNotFoundThisToolIsNeededToBuildLa = 'The program %smake%' lisTheProgramMakeWasNotFoundThisToolIsNeededToBuildLa = 'The program %smake%'
+'s was not found.%sThis tool is needed to build lazarus.%s'; +'s was not found.%sThis tool is needed to build lazarus.%s';

View File

@ -1,48 +1,82 @@
object ManageExamplesForm: TManageExamplesForm object ManageExamplesForm: TManageExamplesForm
Left = 378 Left = 326
Height = 416 Height = 490
Top = 161 Top = 102
Width = 790 Width = 798
Caption = 'ManageExamplesForm' Caption = 'ManageExamplesForm'
ClientHeight = 416 ClientHeight = 490
ClientWidth = 790 ClientWidth = 798
Position = poDesktopCenter Position = poDesktopCenter
LCLVersion = '0.9.31' LCLVersion = '0.9.31'
object ProjectsGroupBox: TGroupBox object ProjectsGroupBox: TGroupBox
AnchorSideLeft.Control = RootRadioGroup AnchorSideTop.Control = RootRadioGroup
AnchorSideTop.Control = RootDirectoryEdit
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = ActionGroupBox AnchorSideRight.Control = ActionGroupBox
AnchorSideBottom.Control = ButtonPanel1 AnchorSideBottom.Control = ButtonPanel1
Left = 1 Left = 1
Height = 227 Height = 351
Top = 143 Top = 93
Width = 564 Width = 444
Anchors = [akTop, akLeft, akRight, akBottom] Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Top = 13 BorderSpacing.Top = 5
Caption = 'Projects' Caption = 'Projects'
ClientHeight = 210 ClientHeight = 334
ClientWidth = 560 ClientWidth = 440
TabOrder = 0 TabOrder = 0
object ProjectsListBox: TListBox object ProjectsListBox: TListBox
AnchorSideLeft.Control = ProjectsGroupBox
AnchorSideTop.Control = ProjectFilter
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = ProjectsGroupBox
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = ProjectsGroupBox
AnchorSideBottom.Side = asrBottom
Left = 0 Left = 0
Height = 210 Height = 305
Top = 0 Top = 29
Width = 560 Width = 440
Align = alClient Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Top = 5
ItemHeight = 0 ItemHeight = 0
MultiSelect = True MultiSelect = True
OnSelectionChange = ProjectsListBoxSelectionChange OnSelectionChange = ProjectsListBoxSelectionChange
ScrollWidth = 556 ScrollWidth = 436
TabOrder = 0 TabOrder = 0
TopIndex = -1 TopIndex = -1
end end
object ProjectFilter: TListFilterEdit
AnchorSideLeft.Control = ProjectsListBox
Left = 0
Height = 23
Top = 1
Width = 197
ButtonWidth = 23
NumGlyphs = 0
MaxLength = 0
TabOrder = 1
FilteredListbox = ProjectsListBox
end
object RelativeCheckBox: TCheckBox
AnchorSideLeft.Control = ProjectFilter
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = ProjectFilter
AnchorSideTop.Side = asrCenter
Left = 270
Height = 26
Top = -1
Width = 116
BorderSpacing.Left = 73
Caption = 'Relative paths'
OnClick = RelativeCheckBoxClick
TabOrder = 2
Visible = False
end
end end
object ButtonPanel1: TButtonPanel object ButtonPanel1: TButtonPanel
Left = 6 Left = 6
Height = 34 Height = 34
Top = 376 Top = 450
Width = 778 Width = 786
OKButton.Name = 'OKButton' OKButton.Name = 'OKButton'
OKButton.DefaultCaption = True OKButton.DefaultCaption = True
HelpButton.Name = 'HelpButton' HelpButton.Name = 'HelpButton'
@ -57,26 +91,27 @@ object ManageExamplesForm: TManageExamplesForm
object ActionGroupBox: TGroupBox object ActionGroupBox: TGroupBox
AnchorSideLeft.Side = asrBottom AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = ProjectsGroupBox AnchorSideTop.Control = ProjectsGroupBox
AnchorSideRight.Control = RootRadioGroup
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = ProjectsGroupBox AnchorSideBottom.Control = ProjectsGroupBox
AnchorSideBottom.Side = asrBottom AnchorSideBottom.Side = asrBottom
Left = 568 Left = 448
Height = 227 Height = 351
Top = 143 Top = 93
Width = 216 Width = 344
Anchors = [akTop, akRight, akBottom] Anchors = [akTop, akRight, akBottom]
BorderSpacing.Left = 3 BorderSpacing.Left = 3
Caption = 'Action' Caption = 'Action'
ClientHeight = 210 ClientHeight = 334
ClientWidth = 212 ClientWidth = 340
TabOrder = 2 TabOrder = 2
object Label1: TLabel object Label1: TLabel
AnchorSideTop.Control = BuildAllSelectedButton
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = BuildAllSelectedButton
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
Left = 66 Left = 195
Height = 16 Height = 16
Top = 61 Top = 55
Width = 131 Width = 131
Anchors = [akTop, akRight] Anchors = [akTop, akRight]
BorderSpacing.Right = 7 BorderSpacing.Right = 7
@ -84,55 +119,119 @@ object ManageExamplesForm: TManageExamplesForm
ParentColor = False ParentColor = False
end end
object OpenSelectedButton: TBitBtn object OpenSelectedButton: TBitBtn
Left = 9 AnchorSideLeft.Control = ActionGroupBox
AnchorSideTop.Control = ActionGroupBox
AnchorSideRight.Control = ActionGroupBox
AnchorSideRight.Side = asrBottom
Left = 7
Height = 25 Height = 25
Top = 8 Top = 2
Width = 195 Width = 326
BorderSpacing.Top = 4 Anchors = [akTop, akLeft, akRight]
BorderSpacing.Left = 7
BorderSpacing.Top = 2
BorderSpacing.Right = 7
Caption = 'Open First Selected' Caption = 'Open First Selected'
Enabled = False Enabled = False
OnClick = OpenSelectedButtonClick OnClick = OpenSelectedButtonClick
TabOrder = 0 TabOrder = 0
end end
object BuildAllSelectedButton: TBitBtn object BuildAllSelectedButton: TBitBtn
Left = 9 AnchorSideLeft.Control = OpenSelectedButton
AnchorSideTop.Control = OpenSelectedButton
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = OpenSelectedButton
AnchorSideRight.Side = asrBottom
Left = 7
Height = 25 Height = 25
Top = 36 Top = 30
Width = 195 Width = 326
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Top = 3
Caption = 'Build All Selected' Caption = 'Build All Selected'
Enabled = False Enabled = False
OnClick = BuildAllSelectedButtonClick OnClick = BuildAllSelectedButtonClick
TabOrder = 1 TabOrder = 1
end end
object SelectAllButton: TBitBtn object SelectAllButton: TBitBtn
Left = 9 AnchorSideLeft.Control = OpenSelectedButton
AnchorSideTop.Control = BuildAllSelectedButton
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = OpenSelectedButton
AnchorSideRight.Side = asrBottom
Left = 7
Height = 25 Height = 25
Top = 88 Top = 72
Width = 195 Width = 326
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Top = 17
Caption = 'Select All' Caption = 'Select All'
OnClick = SelectAllButtonClick OnClick = SelectAllButtonClick
TabOrder = 2 TabOrder = 2
end end
object SelectNoneButton: TBitBtn object SelectNoneButton: TBitBtn
Left = 9 AnchorSideLeft.Control = OpenSelectedButton
AnchorSideTop.Control = SelectAllButton
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = OpenSelectedButton
AnchorSideRight.Side = asrBottom
Left = 7
Height = 25 Height = 25
Top = 116 Top = 100
Width = 195 Width = 326
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Top = 3
Caption = 'Select None' Caption = 'Select None'
Enabled = False Enabled = False
OnClick = SelectNoneButtonClick OnClick = SelectNoneButtonClick
TabOrder = 3 TabOrder = 3
end end
object DescriptionMemo: TMemo
AnchorSideLeft.Control = ActionGroupBox
AnchorSideTop.Control = SelectNoneButton
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = ActionGroupBox
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = ActionGroupBox
AnchorSideBottom.Side = asrBottom
Left = 2
Height = 202
Top = 130
Width = 336
Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Top = 3
BorderSpacing.Around = 2
ScrollBars = ssAutoBoth
TabOrder = 4
end
end
object RootDirectoryEdit: TDirectoryEdit
AnchorSideLeft.Control = DirectoryComboBox
AnchorSideTop.Control = DirectoryComboBox
AnchorSideTop.Side = asrBottom
AnchorSideRight.Side = asrBottom
Left = 269
Height = 23
Top = 65
Width = 488
ShowHidden = False
ButtonWidth = 23
NumGlyphs = 0
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Top = 3
MaxLength = 0
TabOrder = 3
OnChange = RootDirectoryEditChange
end end
object RootRadioGroup: TRadioGroup object RootRadioGroup: TRadioGroup
Left = 1 Left = 1
Height = 97 Height = 86
Top = 5 Top = 2
Width = 783 Width = 263
Anchors = [akTop, akLeft, akRight] Anchors = [akTop, akLeft, akRight]
AutoFill = True AutoFill = True
BorderSpacing.Top = 5 BorderSpacing.Top = 5
Caption = 'Root directory for projects' Caption = 'Search projects from'
ChildSizing.LeftRightSpacing = 6 ChildSizing.LeftRightSpacing = 6
ChildSizing.TopBottomSpacing = 6 ChildSizing.TopBottomSpacing = 6
ChildSizing.EnlargeHorizontal = crsHomogenousChildResize ChildSizing.EnlargeHorizontal = crsHomogenousChildResize
@ -140,28 +239,54 @@ object ManageExamplesForm: TManageExamplesForm
ChildSizing.ShrinkHorizontal = crsScaleChilds ChildSizing.ShrinkHorizontal = crsScaleChilds
ChildSizing.ShrinkVertical = crsScaleChilds ChildSizing.ShrinkVertical = crsScaleChilds
ChildSizing.Layout = cclLeftToRightThenTopToBottom ChildSizing.Layout = cclLeftToRightThenTopToBottom
ChildSizing.ControlsPerLine = 2 ChildSizing.ControlsPerLine = 1
Columns = 2
OnClick = RootRadioGroupClick OnClick = RootRadioGroupClick
TabOrder = 3 TabOrder = 4
end end
object RootDirectoryEdit: TDirectoryEdit object DirectoryComboBox: TComboBox
AnchorSideLeft.Control = RootRadioGroup AnchorSideLeft.Control = RootRadioGroup
AnchorSideTop.Control = RootRadioGroup AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = ExamplesCheckBox
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
Left = 4 Left = 269
Height = 23 Height = 23
Top = 107 Top = 39
Width = 743 Width = 488
ShowHidden = False
ButtonWidth = 23
NumGlyphs = 0
Anchors = [akTop, akLeft, akRight] Anchors = [akTop, akLeft, akRight]
BorderSpacing.Left = 3 BorderSpacing.Left = 5
BorderSpacing.Top = 5 BorderSpacing.Top = 3
MaxLength = 0 ItemHeight = 0
TabOrder = 4 OnChange = DirectoryComboBoxChange
OnChange = RootDirectoryEditChange TabOrder = 5
end
object ExamplesCheckBox: TCheckBox
AnchorSideLeft.Control = DirectoryComboBox
AnchorSideTop.Side = asrBottom
Left = 269
Height = 26
Top = 10
Width = 136
Anchors = [akLeft]
BorderSpacing.Top = 3
Caption = 'Include Examples'
Checked = True
OnChange = ExamplesCheckBoxChange
State = cbChecked
TabOrder = 6
end
object TestCaseCheckBox: TCheckBox
AnchorSideLeft.Control = ExamplesCheckBox
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = ExamplesCheckBox
AnchorSideTop.Side = asrCenter
Left = 438
Height = 26
Top = 10
Width = 139
BorderSpacing.Left = 33
Caption = 'Include Testcases'
OnChange = ExamplesCheckBoxChange
TabOrder = 7
end end
end end

View File

@ -1,13 +1,14 @@
unit ManageExamples; unit ManageExamples;
{$mode objfpc}{$H+} {$mode objfpc}{$H+}
interface interface
uses uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls, Classes, SysUtils, FileUtil, ListFilterEdit, Forms, Controls, Graphics,
ExtCtrls, CheckLst, ButtonPanel, PairSplitter, EditBtn, LCLProc, AvgLvlTree, Dialogs, StdCtrls, ExtCtrls, ButtonPanel, //FileUtil,
Buttons, LazIDEIntf, MainIntf, EnvironmentOpts, LazarusIDEStrConsts; LCLProc, Buttons, EditBtn, LazIDEIntf, MainIntf, EnvironmentOpts, //AvgLvlTree,
LazarusIDEStrConsts;
type type
@ -15,6 +16,12 @@ type
TManageExamplesForm = class(TForm) TManageExamplesForm = class(TForm)
BuildAllSelectedButton: TBitBtn; BuildAllSelectedButton: TBitBtn;
RelativeCheckBox: TCheckBox;
DescriptionMemo: TMemo;
TestCaseCheckBox: TCheckBox;
ExamplesCheckBox: TCheckBox;
DirectoryComboBox: TComboBox;
ProjectFilter: TListFilterEdit;
OpenSelectedButton: TBitBtn; OpenSelectedButton: TBitBtn;
Label1: TLabel; Label1: TLabel;
ProjectsListBox: TListBox; ProjectsListBox: TListBox;
@ -28,18 +35,23 @@ type
procedure BuildAllSelectedButtonClick(Sender: TObject); procedure BuildAllSelectedButtonClick(Sender: TObject);
procedure OpenSelectedButtonClick(Sender: TObject); procedure OpenSelectedButtonClick(Sender: TObject);
procedure ProjectsListBoxSelectionChange(Sender: TObject; User: boolean); procedure ProjectsListBoxSelectionChange(Sender: TObject; User: boolean);
procedure RootDirectoryEditChange(Sender: TObject); procedure RelativeCheckBoxClick(Sender: TObject);
procedure RootRadioGroupClick(Sender: TObject); procedure RootRadioGroupClick(Sender: TObject);
procedure DirectoryComboBoxChange(Sender: TObject);
procedure RootDirectoryEditChange(Sender: TObject);
procedure SelectAllButtonClick(Sender: TObject); procedure SelectAllButtonClick(Sender: TObject);
procedure SelectNoneButtonClick(Sender: TObject); procedure SelectNoneButtonClick(Sender: TObject);
procedure ShowPathCheckBoxChange(Sender: TObject); procedure ExamplesCheckBoxChange(Sender: TObject);
private private
fOtherPathIndex: Integer;
fSelectedFilename: string; fSelectedFilename: string;
fFirstSelectedIndex: Integer;
fChangingSelections: Boolean; fChangingSelections: Boolean;
fNeedsFindDirectories: Boolean;
fNeedsFindProjects: Boolean;
fUpdating: Boolean; fUpdating: Boolean;
fIdleConnected: boolean; fIdleConnected: boolean;
procedure FillProjectList(Immediately: boolean); procedure FillDirectoriesBending;
procedure FillProjectsBending;
procedure SetIdleConnected(const AValue: boolean); procedure SetIdleConnected(const AValue: boolean);
procedure OnIdle(Sender: TObject; var Done: Boolean); procedure OnIdle(Sender: TObject; var Done: Boolean);
public public
@ -89,7 +101,7 @@ type
procedure TListFileSearcher.DoFileFound; procedure TListFileSearcher.DoFileFound;
begin begin
fForm.ProjectsListBox.Items.Add(FileName) fForm.ProjectFilter.Data.Add(FileName) // fForm.ProjectsListBox.Items.Add(FileName)
end; end;
constructor TListFileSearcher.Create(aForm: TManageExamplesForm); constructor TListFileSearcher.Create(aForm: TManageExamplesForm);
@ -104,27 +116,23 @@ var
path: String; path: String;
begin begin
inherited Create(AnOwner); inherited Create(AnOwner);
fFirstSelectedIndex:=-1;
fChangingSelections:=False; fChangingSelections:=False;
fUpdating:=False; fUpdating:=False;
fNeedsFindDirectories:=False;
fNeedsFindProjects:=False;
Caption:=lisKMExampleProjects; Caption:=lisKMExampleProjects;
RootRadioGroup.Caption:=lisRootDirectoryForProjects; ExamplesCheckBox.Caption:=lisIncludeExamples;
TestCaseCheckBox.Caption:=lisIncludeTestcases;
// Add some paths for example projects RootRadioGroup.Caption:=lisSearchProjectsFrom;
RootRadioGroup.Items.Add(EnvironmentOptions.LazarusDirectory); // Lazarus root RootRadioGroup.Items.Add(lisLazarusSource);
RootRadioGroup.Items.Add(dlgCOOther); // could use lisCEOtherGroup
path:=EnvironmentOptions.LazarusDirectory+'examples'; RootRadioGroup.ItemIndex:=0;
if DirectoryExistsUTF8(path) then // Select this one RootRadioGroupClick(RootRadioGroup);
RootRadioGroup.ItemIndex:=RootRadioGroup.Items.Add(path);
path:=EnvironmentOptions.LazarusDirectory+'components/codetools/examples/';
if DirectoryExistsUTF8(path) then
RootRadioGroup.Items.Add(path);
fOtherPathIndex:=RootRadioGroup.Items.Add('Other');
RootDirectoryEdit.Text:=RootRadioGroup.Items[RootRadioGroup.ItemIndex];
FillProjectList(False);
RelativeCheckBox.Caption:=lisRelativePaths;
OpenSelectedButton.Caption:=lisExamplesOpenFirstSelected; OpenSelectedButton.Caption:=lisExamplesOpenFirstSelected;
BuildAllSelectedButton.Caption:=lisExamplesBuildAllSelected; BuildAllSelectedButton.Caption:=lisExamplesBuildAllSelected;
SelectAllButton.Caption:=lisMenuSelectAll; SelectAllButton.Caption:=lisMenuSelectAll;
@ -134,6 +142,9 @@ begin
BuildAllSelectedButton.LoadGlyphFromLazarusResource('menu_build_all'); BuildAllSelectedButton.LoadGlyphFromLazarusResource('menu_build_all');
SelectAllButton.LoadGlyphFromLazarusResource('menu_select_all'); SelectAllButton.LoadGlyphFromLazarusResource('menu_select_all');
SelectNoneButton.LoadGlyphFromLazarusResource('ce_default'); SelectNoneButton.LoadGlyphFromLazarusResource('ce_default');
FillDirectoriesBending;
FillProjectsBending;
end; end;
destructor TManageExamplesForm.Destroy; destructor TManageExamplesForm.Destroy;
@ -141,25 +152,16 @@ begin
inherited Destroy; inherited Destroy;
end; end;
procedure TManageExamplesForm.FillProjectList(Immediately: boolean); procedure TManageExamplesForm.FillDirectoriesBending;
var
Searcher: TListFileSearcher;
begin begin
if not Immediately then begin fNeedsFindDirectories:=True;
IdleConnected:=true; IdleConnected:=True;
exit; end;
end;
if fUpdating then Exit; procedure TManageExamplesForm.FillProjectsBending;
if RootDirectoryEdit.Text<>'' then begin
try fNeedsFindProjects:=True;
fUpdating:=True; IdleConnected:=True;
ProjectsListBox.Items.Clear;
Searcher:=TListFileSearcher.Create(Self);
Searcher.Search(RootDirectoryEdit.Text, '*.lpi');
finally
Searcher.Free;
fUpdating:=False;
end;
end; end;
procedure TManageExamplesForm.SetIdleConnected(const AValue: boolean); procedure TManageExamplesForm.SetIdleConnected(const AValue: boolean);
@ -173,44 +175,82 @@ begin
end; end;
procedure TManageExamplesForm.OnIdle(Sender: TObject; var Done: Boolean); procedure TManageExamplesForm.OnIdle(Sender: TObject; var Done: Boolean);
var
Searcher: TListFileSearcher;
AllDirs: TStringList;
i: Integer;
LastDir: String;
begin begin
IdleConnected:=false; IdleConnected:=false;
FillProjectList(true); if fUpdating then Exit;
end; fUpdating:=True;
if fNeedsFindDirectories then begin
procedure TManageExamplesForm.RootDirectoryEditChange(Sender: TObject); DirectoryComboBox.Items.Clear;
begin DirectoryComboBox.Text:='';
FillProjectList(False); RootDirectoryEdit.Text:='';
AllDirs:=FindAllDirectories(EnvironmentOptions.LazarusDirectory);
try
for i:=0 to AllDirs.Count-1 do begin
LastDir:=ExtractFileName(AllDirs[i]);
if (ExamplesCheckBox.Checked and (LastDir='examples'))
or (TestCaseCheckBox.Checked and (LastDir='tests')) then
DirectoryComboBox.Items.Add(AllDirs[i]);
end;
// Add something to combobox to prevent crash with GTK2.
if DirectoryComboBox.Items.Count = 0 then
DirectoryComboBox.Items.Add('[empty]');
DirectoryComboBox.ItemIndex:=0;
DirectoryComboBoxChange(DirectoryComboBox);
finally
AllDirs.Free;
fNeedsFindDirectories:=False;
end;
end;
if fNeedsFindProjects and (RootDirectoryEdit.Text<>'') then
try
ProjectFilter.Data.Clear; // ProjectsListBox.Items.Clear;
Searcher:=TListFileSearcher.Create(Self);
Searcher.Search(RootDirectoryEdit.Text, '*.lpi');
ProjectFilter.InvalidateFilter;
finally
Searcher.Free;
fNeedsFindProjects:=False;
end;
fUpdating:=False;
end; end;
procedure TManageExamplesForm.RootRadioGroupClick(Sender: TObject); procedure TManageExamplesForm.RootRadioGroupClick(Sender: TObject);
begin begin
if RootRadioGroup.ItemIndex=fOtherPathIndex then DirectoryComboBox.Enabled:=RootRadioGroup.ItemIndex=0;
RootDirectoryEdit.Enabled:=True RootDirectoryEdit.Enabled:=RootRadioGroup.ItemIndex=1;
else begin end;
RootDirectoryEdit.Enabled:=False;
RootDirectoryEdit.Text:=RootRadioGroup.Items[RootRadioGroup.ItemIndex]; procedure TManageExamplesForm.DirectoryComboBoxChange(Sender: TObject);
begin
if DirectoryExists(DirectoryComboBox.Text) then begin
RootDirectoryEdit.Text:=DirectoryComboBox.Text;
FillProjectsBending;
end; end;
end; end;
procedure TManageExamplesForm.ShowPathCheckBoxChange(Sender: TObject); procedure TManageExamplesForm.RootDirectoryEditChange(Sender: TObject);
begin begin
FillProjectList(False); FillProjectsBending;
end;
procedure TManageExamplesForm.ExamplesCheckBoxChange(Sender: TObject);
begin
FillDirectoriesBending;
end; end;
procedure TManageExamplesForm.OpenSelectedButtonClick(Sender: TObject); procedure TManageExamplesForm.OpenSelectedButtonClick(Sender: TObject);
var
i: Integer;
begin begin
for i:=0 to ProjectsListBox.Items.Count-1 do begin if fFirstSelectedIndex <> -1 then begin
if ProjectsListBox.Selected[i] then begin if FileExistsUTF8(ProjectsListBox.Items[fFirstSelectedIndex]) then begin
if FileExistsUTF8(ProjectsListBox.Items[i]) then begin fSelectedFilename:=ProjectsListBox.Items[fFirstSelectedIndex];
fSelectedFilename:=ProjectsListBox.Items[i]; ModalResult:=mrYes; // mrYes means the selected file will be opened.
ModalResult:=mrYes; // mrYes means the selected file will be opened. end else begin
Break; ShowMessage(Format(lisFileNotFound3, [ProjectsListBox.Items[fFirstSelectedIndex]]));
end else begin
ShowMessage(Format(lisFileNotFound3, [ProjectsListBox.Items[i]]));
end;
end; end;
end; end;
end; end;
@ -245,17 +285,39 @@ begin
ProjectsListBoxSelectionChange(ProjectsListBox, False); ProjectsListBoxSelectionChange(ProjectsListBox, False);
end; end;
procedure TManageExamplesForm.RelativeCheckBoxClick(Sender: TObject);
begin
;
end;
// Project list selection changes. Adjust buttons. // Project list selection changes. Adjust buttons.
procedure TManageExamplesForm.ProjectsListBoxSelectionChange(Sender: TObject; User: boolean); procedure TManageExamplesForm.ProjectsListBoxSelectionChange(Sender: TObject; User: boolean);
var var
HasSelected: Boolean; HasSelected: Boolean;
ReadMe, RealReadMe: String;
i: Integer;
begin begin
if not fChangingSelections then begin if not fChangingSelections then begin
HasSelected := ProjectsListBox.SelCount > 0; HasSelected := ProjectsListBox.SelCount > 0;
OpenSelectedButton.Enabled := HasSelected; OpenSelectedButton.Enabled := HasSelected;
// BuildAllSelectedButton.Enabled := HasSelected; // BuildAllSelectedButton.Enabled := HasSelected;
SelectNoneButton.Enabled := HasSelected; SelectNoneButton.Enabled := HasSelected;
// Find the first selected item and show README.txt contents.
if HasSelected then
for i:=0 to ProjectsListBox.Items.Count-1 do
if ProjectsListBox.Selected[i] then begin
fFirstSelectedIndex:=i;
ReadMe:=ExtractFilePath(ProjectsListBox.Items[i])+'README.txt';
RealReadMe:=FindDiskFileCaseInsensitive(ReadMe);
if RealReadMe <> '' then
DescriptionMemo.Lines.LoadFromFile(RealReadMe)
else
DescriptionMemo.Clear;
Break;
end
else
fFirstSelectedIndex:=-1;
end; end;
end; end;