Drop dialog for selecting databases to display. As discussed it has no performance problem any longer to handle more than 50 dbs.

This commit is contained in:
Ansgar Becker
2007-07-03 05:53:29 +00:00
parent 003f0956aa
commit ce0956bf8f
6 changed files with 1 additions and 256 deletions

View File

@ -19,7 +19,6 @@ uses
loaddata in '..\..\source\loaddata.pas' {loaddataform},
usermanager in '..\..\source\usermanager.pas' {UserManagerForm},
options in '..\..\source\options.pas' {optionsform},
selectsomedatabases in '..\..\source\selectsomedatabases.pas' {SelectFromManyDatabases},
optimizetables in '..\..\source\optimizetables.pas' {optimize},
printlist in '..\..\source\printlist.pas' {printlistForm},
copytable in '..\..\source\copytable.pas' {CopyTableForm},

View File

@ -18,7 +18,6 @@ uses
loaddata in '..\..\source\loaddata.pas' {loaddataform},
usermanager in '..\..\source\usermanager.pas' {UserManagerForm},
options in '..\..\source\options.pas' {optionsform},
selectsomedatabases in '..\..\source\selectsomedatabases.pas' {SelectFromManyDatabases},
optimizetables in '..\..\source\optimizetables.pas' {optimize},
printlist in '..\..\source\printlist.pas' {printlistForm},
copytable in '..\..\source\copytable.pas' {CopyTableForm},

View File

@ -16,7 +16,6 @@ uses
loaddata in '..\..\source\loaddata.pas' {loaddataform},
usermanager in '..\..\source\usermanager.pas' {UserManagerForm},
options in '..\..\source\options.pas' {optionsform},
selectsomedatabases in '..\..\source\selectsomedatabases.pas' {SelectFromManyDatabases},
optimizetables in '..\..\source\optimizetables.pas' {optimize},
printlist in '..\..\source\printlist.pas' {printlistForm},
copytable in '..\..\source\copytable.pas' {CopyTableForm},

View File

@ -527,7 +527,7 @@ implementation
uses
Main, createtable, fieldeditor, tbl_properties, tblcomment,
selectsomedatabases, optimizetables, copytable, sqlhelp, printlist,
optimizetables, copytable, sqlhelp, printlist,
column_selection;
@ -1108,11 +1108,6 @@ begin
SynSQLSyn1.TableNames.AddStrings( OnlyDBs2 );
SynSQLSyn1.TableNames.EndUpdate();
if ( ( OnlyDBs.Count = 0 ) and ( OnlyDBs2.Count > 50 ) ) then
begin
SelectFromManyDatabasesWindow( Self, OnlyDBs2 );
end;
// List Databases and Tables-Names
tmpSelected := nil;
for i := 0 to ( OnlyDBs2.Count - 1 ) do

View File

@ -1,96 +0,0 @@
object SelectFromManyDatabases: TSelectFromManyDatabases
Left = 217
Top = 105
BorderStyle = bsDialog
BorderWidth = 3
Caption = 'Select Databases...'
ClientHeight = 343
ClientWidth = 335
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = False
Position = poMainFormCenter
OnShow = FormShow
PixelsPerInch = 96
TextHeight = 13
object lblSelectDB: TLabel
Left = 8
Top = 64
Width = 87
Height = 13
Caption = 'Select Databases:'
end
object lblWarning: TLabel
Left = 48
Top = 8
Width = 235
Height = 39
Caption =
'Found more than 50 Databases on this host. This can take some mi' +
'nutes to display them all (depending on your network-connection)'
WordWrap = True
end
object imgWarning: TImage
Left = 8
Top = 8
Width = 33
Height = 33
Picture.Data = {
07544269746D617076020000424D760200000000000076000000280000002000
0000200000000100040000000000000200000000000000000000100000001000
000000000000000080000080000000808000800000008000800080800000C0C0
C000808080000000FF0000FF000000FFFF00FF000000FF00FF00FFFF0000FFFF
FF00777778888888888888888888888888777777888888888888888888888888
88877730000000000000000000000008888873BBBBBBBBBBBBBBBBBBBBBBBB70
88883BBBBBBBBBBBBBBBBBBBBBBBBBB708883BBBBBBBBBBBBBBBBBBBBBBBBBBB
08883BBBBBBBBBBBB7007BBBBBBBBBBB08873BBBBBBBBBBBB0000BBBBBBBBBB7
088773BBBBBBBBBBB0000BBBBBBBBBB0887773BBBBBBBBBBB7007BBBBBBBBB70
8877773BBBBBBBBBBBBBBBBBBBBBBB088777773BBBBBBBBBBB0BBBBBBBBBB708
87777773BBBBBBBBB707BBBBBBBBB08877777773BBBBBBBBB303BBBBBBBB7088
777777773BBBBBBBB000BBBBBBBB0887777777773BBBBBBB70007BBBBBB70887
7777777773BBBBBB30003BBBBBB088777777777773BBBBBB00000BBBBB708877
77777777773BBBBB00000BBBBB08877777777777773BBBBB00000BBBB7088777
777777777773BBBB00000BBBB0887777777777777773BBBB00000BBB70887777
7777777777773BBB70007BBB088777777777777777773BBBBBBBBBB708877777
77777777777773BBBBBBBBB08877777777777777777773BBBBBBBB7088777777
777777777777773BBBBBBB0887777777777777777777773BBBBBB70887777777
7777777777777773BBBBB088777777777777777777777773BBBB708777777777
77777777777777773BB707777777777777777777777777777333777777777777
7777}
Transparent = True
end
object btnShowAll: TButton
Left = 216
Top = 80
Width = 105
Height = 25
Cancel = True
Caption = 'Show all'
Default = True
TabOrder = 0
OnClick = btnShowAllClick
end
object CheckListBoxDBs: TCheckListBox
Left = 8
Top = 80
Width = 201
Height = 257
OnClickCheck = CheckListBoxDBsClickCheck
ItemHeight = 13
TabOrder = 1
end
object btnSave: TButton
Left = 216
Top = 112
Width = 105
Height = 25
Caption = 'Save'
Enabled = False
TabOrder = 2
OnClick = btnSaveClick
end
end

View File

@ -1,151 +0,0 @@
unit selectsomedatabases;
// -------------------------------------
// Select some or all databases to view
// -------------------------------------
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, CheckLst, ExtCtrls, Registry;
type
TSelectFromManyDatabases = class(TForm)
lblSelectDB: TLabel;
btnShowAll: TButton;
lblWarning: TLabel;
CheckListBoxDBs: TCheckListBox;
imgWarning: TImage;
btnSave: TButton;
procedure btnShowAllClick(Sender: TObject);
procedure CheckListBoxDBsClickCheck(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure btnSaveClick(Sender: TObject);
private
FDbList : TStringList;
procedure SetDbList(const Value: TStringList);
public
property DbList : TStringList read FDbList write SetDbList;
end;
function SelectFromManyDatabasesWindow (AOwner : TComponent; ADbList : TStringList; Flags : String = '') : Boolean;
implementation
uses main, childwin, connections;
{$R *.DFM}
function SelectFromManyDatabasesWindow (AOwner : TComponent; ADbList : TStringList; Flags : String = '') : Boolean;
var
f : TSelectFromManyDatabases;
begin
f := TSelectFromManyDatabases.Create(AOwner);
f.DbList := ADbList;
Result := (f.ShowModal=mrOK);
FreeAndNil (f);
end;
procedure TSelectFromManyDatabases.btnShowAllClick(Sender: TObject);
var
i : Integer;
someselected : Boolean;
begin
someselected := false;
for i:=0 to CheckListBoxDBs.Items.Count -1 do
begin
if CheckListBoxDBs.Checked[i] then
begin
someselected := true;
break;
end;
end;
if someselected then
//OnlyDBs2.clear;
FDbList.Clear;
with CheckListBoxDBs do
for i:=0 to Items.Count -1 do
begin
if Checked[i] then
FDbList.Add(Items[i]);
end;
close;
end;
procedure TSelectFromManyDatabases.CheckListBoxDBsClickCheck(
Sender: TObject);
var
i : Integer;
someselected : Boolean;
begin
someselected := false;
for i:=0 to CheckListBoxDBs.Items.Count -1 do
begin
if CheckListBoxDBs.Checked[i] then
begin
someselected := true;
break;
end;
end;
if someselected then
begin
btnShowAll.Caption := 'Show selected';
btnSave.Enabled := true;
end
else
begin
btnShowAll.Caption := 'Show all';
btnSave.Enabled := false;
end
end;
procedure TSelectFromManyDatabases.FormShow(Sender: TObject);
begin
btnShowAll.Caption := 'Show all';
btnSave.Enabled := false;
end;
procedure TSelectFromManyDatabases.SetDbList(const Value: TStringList);
begin
FDbList := Value;
//CheckListBoxDBs.Items.Clear;
if Value<>nil then
CheckListBoxDBs.Items := Value;
end;
procedure TSelectFromManyDatabases.btnSaveClick(Sender: TObject);
var
i : Integer;
odbs : String;
begin
for i:=0 to CheckListBoxDBs.Items.Count -1 do
if CheckListBoxDBs.Checked[i] then
begin
if odbs <> '' then
odbs := odbs + ';';
odbs := odbs + CheckListBoxDBs.Items[i];
end;
// save settings:
with TRegistry.Create do
begin
openkey(REGPATH + '\Servers\' + Mainform.Childwin.Conn.Description, true);
WriteString('OnlyDBs', odbs);
closekey();
end;
btnSave.Enabled := false;
MessageDlg('Saved selected Databases to your local settings.', mtInformation, [mbOK], 0);
end;
end.