mirror of
https://github.com/HeidiSQL/HeidiSQL.git
synced 2025-08-06 18:24:26 +08:00
Convert database tree from TTreeView to TVirtualStringTree.
- Fixes bug #271 "F5 shortcut in database tree not working" - Fullfills rfe #519 "Highlight selected item in tree view when focus is elsewhere" - Fixes inconsistent expansion state of nodes after refreshing - Fixes plus sign staying when a db node with 0 tables was selected - Slightly enhances painting speed within the dbtree - Removes temporary storage of a rightclicked node (DBRightClickSelectItem). VirtualTree handles its right clicked selection exactly like the left clicked one, which makes makes coding a bit cleaner as we can always use the selected item instead of hacking with the right and left clicked node. On the other side it removes a quite user friendly feature. Well, we can reimplement this feature later, though it's not user UNfriendly currently. - Reasonably rename the StringList "OnlyDBs" to "DatabasesWanted" and "OnlyDBs2" to "Databases"
This commit is contained in:
@ -46,7 +46,7 @@ object MDIChild: TMDIChild
|
|||||||
Cursor = crSizeWE
|
Cursor = crSizeWE
|
||||||
ResizeStyle = rsUpdate
|
ResizeStyle = rsUpdate
|
||||||
end
|
end
|
||||||
object DBtree: TTreeView
|
object DBtree: TVirtualStringTree
|
||||||
Left = 0
|
Left = 0
|
||||||
Top = 0
|
Top = 0
|
||||||
Width = 169
|
Width = 169
|
||||||
@ -54,19 +54,33 @@ object MDIChild: TMDIChild
|
|||||||
Align = alLeft
|
Align = alLeft
|
||||||
Constraints.MinWidth = 40
|
Constraints.MinWidth = 40
|
||||||
DragMode = dmAutomatic
|
DragMode = dmAutomatic
|
||||||
HotTrack = True
|
DragType = dtVCL
|
||||||
|
Header.AutoSizeIndex = 0
|
||||||
|
Header.Font.Charset = DEFAULT_CHARSET
|
||||||
|
Header.Font.Color = clWindowText
|
||||||
|
Header.Font.Height = -11
|
||||||
|
Header.Font.Name = 'Tahoma'
|
||||||
|
Header.Font.Style = []
|
||||||
|
Header.MainColumn = -1
|
||||||
|
Header.Options = [hoColumnResize, hoDrag]
|
||||||
|
HotCursor = crHandPoint
|
||||||
Images = MainForm.PngImageListMain
|
Images = MainForm.PngImageListMain
|
||||||
Indent = 19
|
Indent = 16
|
||||||
ReadOnly = True
|
Margin = 2
|
||||||
RightClickSelect = True
|
PopupMenu = popupTreeView
|
||||||
RowSelect = True
|
|
||||||
ShowRoot = False
|
|
||||||
TabOrder = 0
|
TabOrder = 0
|
||||||
|
TextMargin = 2
|
||||||
|
TreeOptions.AutoOptions = [toAutoDropExpand, toAutoTristateTracking, toAutoDeleteMovedNodes]
|
||||||
|
TreeOptions.PaintOptions = [toHotTrack, toShowButtons, toShowDropmark, toShowTreeLines, toThemeAware, toUseBlendedImages]
|
||||||
|
TreeOptions.SelectionOptions = [toRightClickSelect]
|
||||||
OnChange = DBtreeChange
|
OnChange = DBtreeChange
|
||||||
OnChanging = DBtreeChanging
|
|
||||||
OnContextPopup = DBtreeContextPopup
|
|
||||||
OnDblClick = DBtreeDblClick
|
OnDblClick = DBtreeDblClick
|
||||||
OnExpanding = DBtreeExpanding
|
OnGetText = DBtreeGetText
|
||||||
|
OnGetImageIndex = DBtreeGetImageIndex
|
||||||
|
OnGetNodeDataSize = DBtreeGetNodeDataSize
|
||||||
|
OnInitChildren = DBtreeInitChildren
|
||||||
|
OnInitNode = DBtreeInitNode
|
||||||
|
Columns = <>
|
||||||
end
|
end
|
||||||
object TableShow: TPanel
|
object TableShow: TPanel
|
||||||
Left = 173
|
Left = 173
|
||||||
@ -562,6 +576,7 @@ object MDIChild: TMDIChild
|
|||||||
OnChange = ListTablesChange
|
OnChange = ListTablesChange
|
||||||
OnCompareNodes = vstCompareNodes
|
OnCompareNodes = vstCompareNodes
|
||||||
OnDblClick = ListTablesDblClick
|
OnDblClick = ListTablesDblClick
|
||||||
|
OnEdited = ListTablesEdited
|
||||||
OnFreeNode = vstFreeNode
|
OnFreeNode = vstFreeNode
|
||||||
OnGetText = vstGetText
|
OnGetText = vstGetText
|
||||||
OnGetImageIndex = vstGetImageIndex
|
OnGetImageIndex = vstGetImageIndex
|
||||||
@ -1781,11 +1796,11 @@ object MDIChild: TMDIChild
|
|||||||
object N5: TMenuItem
|
object N5: TMenuItem
|
||||||
Caption = '-'
|
Caption = '-'
|
||||||
end
|
end
|
||||||
object Drop1: TMenuItem
|
object menuRefreshDBTree: TMenuItem
|
||||||
Caption = 'Refresh'
|
Caption = 'Refresh'
|
||||||
ImageIndex = 0
|
ImageIndex = 0
|
||||||
ShortCut = 116
|
ShortCut = 116
|
||||||
OnClick = ReadDatabasesAndTables
|
OnClick = menuRefreshDBTreeClick
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
object popupDbGrid: TPopupMenu
|
object popupDbGrid: TPopupMenu
|
||||||
|
1044
source/childwin.pas
1044
source/childwin.pas
File diff suppressed because it is too large
Load Diff
@ -105,7 +105,6 @@ end;
|
|||||||
procedure TCopyTableForm.FormShow(Sender: TObject);
|
procedure TCopyTableForm.FormShow(Sender: TObject);
|
||||||
var
|
var
|
||||||
i : Integer;
|
i : Integer;
|
||||||
tn : TTreeNode;
|
|
||||||
struc_data : Byte;
|
struc_data : Byte;
|
||||||
ds: TDataSet;
|
ds: TDataSet;
|
||||||
NodeData: PVTreeData;
|
NodeData: PVTreeData;
|
||||||
@ -118,25 +117,11 @@ begin
|
|||||||
|
|
||||||
// Select TargetDatabase
|
// Select TargetDatabase
|
||||||
ComboSelectDatabase.Items.Clear;
|
ComboSelectDatabase.Items.Clear;
|
||||||
for i:=0 to Mainform.ChildWin.DBTree.Items.Count-1 do
|
ComboSelectDatabase.Items.Assign(Mainform.ChildWin.Databases);
|
||||||
begin
|
ComboSelectDatabase.ItemIndex := ComboSelectDatabase.Items.IndexOf( Mainform.ChildWin.ActiveDatabase );
|
||||||
tn := Mainform.ChildWin.DBTree.Items[i];
|
|
||||||
if tn.Level = 1 then
|
|
||||||
comboSelectDatabase.Items.Add(tn.Text);
|
|
||||||
end;
|
|
||||||
|
|
||||||
for i:=0 to comboSelectDatabase.Items.Count-1 do
|
|
||||||
begin
|
|
||||||
if (comboSelectDatabase.Items[i] = Mainform.ChildWin.ActiveDatabase) then
|
|
||||||
begin
|
|
||||||
comboSelectDatabase.ItemIndex := i;
|
|
||||||
break;
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
if comboSelectDatabase.ItemIndex = -1 then
|
if comboSelectDatabase.ItemIndex = -1 then
|
||||||
comboSelectDatabase.ItemIndex := 0;
|
comboSelectDatabase.ItemIndex := 0;
|
||||||
|
|
||||||
|
|
||||||
// fill columns:
|
// fill columns:
|
||||||
CheckListBoxFields.Items.Clear;
|
CheckListBoxFields.Items.Clear;
|
||||||
ds := Mainform.ChildWin.GetResults( 'SHOW FIELDS FROM ' + mainform.mask(oldTableName) );
|
ds := Mainform.ChildWin.GetResults( 'SHOW FIELDS FROM ' + mainform.mask(oldTableName) );
|
||||||
|
@ -221,12 +221,14 @@ end;
|
|||||||
procedure TCreateDatabaseForm.btnOKClick(Sender: TObject);
|
procedure TCreateDatabaseForm.btnOKClick(Sender: TObject);
|
||||||
var
|
var
|
||||||
sql : String;
|
sql : String;
|
||||||
|
cwin: TMDIChild;
|
||||||
begin
|
begin
|
||||||
|
cwin := Mainform.Childwin;
|
||||||
if modifyDB = '' then
|
if modifyDB = '' then
|
||||||
begin
|
begin
|
||||||
sql := GetCreateStatement;
|
sql := GetCreateStatement;
|
||||||
Try
|
Try
|
||||||
Mainform.Childwin.ExecUpdateQuery( sql );
|
cwin.ExecUpdateQuery( sql );
|
||||||
// Close form
|
// Close form
|
||||||
ModalResult := mrOK;
|
ModalResult := mrOK;
|
||||||
except
|
except
|
||||||
@ -236,7 +238,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
end
|
end
|
||||||
else begin
|
else begin
|
||||||
sql := 'ALTER DATABASE ' + Mainform.Childwin.mask( modifyDB );
|
sql := 'ALTER DATABASE ' + cwin.mask( modifyDB );
|
||||||
if comboCharset.Enabled and (comboCharset.Text <> '') then
|
if comboCharset.Enabled and (comboCharset.Text <> '') then
|
||||||
begin
|
begin
|
||||||
sql := sql + ' CHARACTER SET ' + comboCharset.Text;
|
sql := sql + ' CHARACTER SET ' + comboCharset.Text;
|
||||||
@ -244,12 +246,12 @@ begin
|
|||||||
sql := sql + ' COLLATE ' + comboCollation.Text;
|
sql := sql + ' COLLATE ' + comboCollation.Text;
|
||||||
end;
|
end;
|
||||||
Try
|
Try
|
||||||
Mainform.Childwin.ExecUpdateQuery( sql );
|
cwin.ExecUpdateQuery( sql );
|
||||||
if modifyDB <> editDBName.Text then
|
if modifyDB <> editDBName.Text then
|
||||||
begin
|
begin
|
||||||
Mainform.Childwin.ExecUpdateQuery( 'RENAME DATABASE ' + Mainform.Childwin.mask( modifyDB )
|
cwin.ExecUpdateQuery( 'RENAME DATABASE ' + cwin.mask( modifyDB )
|
||||||
+ ' TO ' + Mainform.Childwin.mask( editDBName.Text ) );
|
+ ' TO ' + cwin.mask( editDBName.Text ) );
|
||||||
Mainform.Childwin.ReadDatabasesAndTables( Sender );
|
cwin.DBtree.ResetNode(cwin.DBtree.GetFirst);
|
||||||
end;
|
end;
|
||||||
// Close form
|
// Close form
|
||||||
ModalResult := mrOK;
|
ModalResult := mrOK;
|
||||||
|
@ -89,7 +89,6 @@ type
|
|||||||
{ Private declarations }
|
{ Private declarations }
|
||||||
public
|
public
|
||||||
{ Public declarations }
|
{ Public declarations }
|
||||||
SelectedDatabase : String;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{$I const.inc}
|
{$I const.inc}
|
||||||
@ -251,7 +250,6 @@ begin
|
|||||||
Mainform.ChildWin.ExecUpdateQuery( createQuery, False, True );
|
Mainform.ChildWin.ExecUpdateQuery( createQuery, False, True );
|
||||||
Mainform.ChildWin.MenuRefreshClick(sender);
|
Mainform.ChildWin.MenuRefreshClick(sender);
|
||||||
Mainform.ChildWin.SelectedTable := EditTablename.Text;
|
Mainform.ChildWin.SelectedTable := EditTablename.Text;
|
||||||
Mainform.ChildWin.ShowTable(EditTablename.Text);
|
|
||||||
except on E: THandledSQLError do
|
except on E: THandledSQLError do
|
||||||
// Keep the form open so the user can fix his faulty input
|
// Keep the form open so the user can fix his faulty input
|
||||||
ModalResult := mrNone;
|
ModalResult := mrNone;
|
||||||
@ -509,23 +507,16 @@ end;
|
|||||||
|
|
||||||
procedure TCreateTableForm.FormShow(Sender: TObject);
|
procedure TCreateTableForm.FormShow(Sender: TObject);
|
||||||
var
|
var
|
||||||
i : Integer;
|
i: Integer;
|
||||||
tn : TTreeNode;
|
|
||||||
begin
|
begin
|
||||||
// FormShow!
|
// FormShow!
|
||||||
|
|
||||||
// read dbs and Tables from treeview
|
// read dbs and Tables from treeview
|
||||||
DBComboBox.Items.Clear;
|
DBComboBox.Items.Clear;
|
||||||
for i:=0 to Mainform.ChildWin.DBTree.Items.Count-1 do
|
DBComboBox.Items.Assign(Mainform.ChildWin.Databases);
|
||||||
begin
|
|
||||||
tn := Mainform.ChildWin.DBTree.Items[i];
|
|
||||||
if tn.Level = 1 then
|
|
||||||
DBComboBox.Items.Add(tn.Text);
|
|
||||||
end;
|
|
||||||
// Preselect relevant database in pulldown
|
// Preselect relevant database in pulldown
|
||||||
if SelectedDatabase <> '' then
|
DBComboBox.ItemIndex := DBComboBox.Items.IndexOf( Mainform.ChildWin.ActiveDatabase );
|
||||||
DBComboBox.ItemIndex := DBComboBox.Items.IndexOf( SelectedDatabase )
|
if (DBComboBox.ItemIndex = -1) and (DBComboBox.Items.Count > 0) then
|
||||||
else if DBComboBox.Items.Count > 0 then
|
|
||||||
DBComboBox.ItemIndex := 0;
|
DBComboBox.ItemIndex := 0;
|
||||||
|
|
||||||
if Mainform.ChildWin.mysql_version >= 32300 then
|
if Mainform.ChildWin.mysql_version >= 32300 then
|
||||||
|
@ -173,50 +173,25 @@ end;
|
|||||||
|
|
||||||
procedure TExportSQLForm.FormShow(Sender: TObject);
|
procedure TExportSQLForm.FormShow(Sender: TObject);
|
||||||
var
|
var
|
||||||
tn : TTreeNode;
|
|
||||||
i, OutputTo : Integer;
|
i, OutputTo : Integer;
|
||||||
dbtree_db : String;
|
|
||||||
list: TWindowDataArray;
|
list: TWindowDataArray;
|
||||||
|
CWin: TMDIChild;
|
||||||
begin
|
begin
|
||||||
|
CWin := Mainform.ChildWin;
|
||||||
barProgress.Position := 0;
|
barProgress.Position := 0;
|
||||||
lblProgress.Caption := '';
|
lblProgress.Caption := '';
|
||||||
PageControl1.ActivePageIndex := 0;
|
PageControl1.ActivePageIndex := 0;
|
||||||
SynMemoExampleSQL.Highlighter := Mainform.ChildWin.SynSQLSyn1;
|
SynMemoExampleSQL.Highlighter := CWin.SynSQLSyn1;
|
||||||
SynMemoExampleSQL.Font := Mainform.ChildWin.SynMemoQuery.Font;
|
SynMemoExampleSQL.Font := CWin.SynMemoQuery.Font;
|
||||||
|
|
||||||
// read dbs and Tables from treeview
|
// read dbs and Tables from treeview
|
||||||
comboSelectDatabase.Items.Clear;
|
comboSelectDatabase.Items.Clear;
|
||||||
Caption := Mainform.ChildWin.MysqlConn.SessionName + ' - Export Tables...';
|
Caption := CWin.MysqlConn.SessionName + ' - Export Tables...';
|
||||||
for i:=0 to Mainform.ChildWin.DBTree.Items.Count-1 do
|
comboSelectDatabase.Items.Assign(CWin.Databases);
|
||||||
begin
|
comboSelectDatabase.ItemIndex := comboSelectDatabase.Items.IndexOf(CWin.ActiveDatabase);
|
||||||
tn := Mainform.ChildWin.DBTree.Items[i];
|
|
||||||
if tn.Level = 1 then
|
|
||||||
comboSelectDatabase.Items.Add(tn.Text);
|
|
||||||
end;
|
|
||||||
|
|
||||||
if Mainform.ChildWin.DBRightClickSelectedItem <> nil then
|
|
||||||
begin
|
|
||||||
case Mainform.ChildWin.DBRightClickSelectedItem.Level of
|
|
||||||
1 : dbtree_db := Mainform.ChildWin.DBRightClickSelectedItem.Text;
|
|
||||||
2 : dbtree_db := Mainform.ChildWin.DBRightClickSelectedItem.Parent.Text;
|
|
||||||
3 : dbtree_db := Mainform.ChildWin.DBRightClickSelectedItem.Parent.Parent.Text;
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
|
|
||||||
for i:=0 to comboSelectDatabase.Items.Count-1 do
|
|
||||||
begin
|
|
||||||
if ((dbtree_db = '') and (comboSelectDatabase.Items[i] = Mainform.ChildWin.ActiveDatabase))
|
|
||||||
or ((dbtree_db <> '') and (comboSelectDatabase.Items[i] = dbtree_db)) then
|
|
||||||
begin
|
|
||||||
comboSelectDatabase.ItemIndex := i;
|
|
||||||
break;
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
|
|
||||||
// Select first database if at least one is available.
|
// Select first database if at least one is available.
|
||||||
if (comboSelectDatabase.ItemIndex = -1) and (comboSelectDatabase.Items.Count>0) then
|
if (comboSelectDatabase.ItemIndex = -1) and (comboSelectDatabase.Items.Count>0) then
|
||||||
comboSelectDatabase.ItemIndex := 0;
|
comboSelectDatabase.ItemIndex := 0;
|
||||||
|
|
||||||
comboSelectDatabaseChange(self);
|
comboSelectDatabaseChange(self);
|
||||||
|
|
||||||
// Initialize and fill list with target versions
|
// Initialize and fill list with target versions
|
||||||
@ -229,7 +204,7 @@ begin
|
|||||||
Add( '40100=MySQL 4.1' );
|
Add( '40100=MySQL 4.1' );
|
||||||
Add( '50000=MySQL 5.0' );
|
Add( '50000=MySQL 5.0' );
|
||||||
Add( '50100=MySQL 5.1' );
|
Add( '50100=MySQL 5.1' );
|
||||||
Add( IntToStr( Mainform.ChildWin.mysql_version ) + '=Same as source server (MySQL '+Mainform.ChildWin.GetVar('SELECT VERSION()') +')' );
|
Add( IntToStr( CWin.mysql_version ) + '=Same as source server (MySQL '+CWin.GetVar('SELECT VERSION()') +')' );
|
||||||
end;
|
end;
|
||||||
|
|
||||||
// Add all target versions to combobox and set default option
|
// Add all target versions to combobox and set default option
|
||||||
@ -371,42 +346,33 @@ end;
|
|||||||
procedure TExportSQLForm.comboSelectDatabaseChange(Sender: TObject);
|
procedure TExportSQLForm.comboSelectDatabaseChange(Sender: TObject);
|
||||||
var
|
var
|
||||||
i : Integer;
|
i : Integer;
|
||||||
dbtree_table : String;
|
|
||||||
Selected : TStringList;
|
Selected : TStringList;
|
||||||
sql: string;
|
sql: string;
|
||||||
|
CWin: TMDIChild;
|
||||||
|
CheckThisItem: Boolean;
|
||||||
begin
|
begin
|
||||||
|
CWin := Mainform.Childwin;
|
||||||
// read tables from db
|
// read tables from db
|
||||||
checkListTables.Items.Clear;
|
checkListTables.Items.Clear;
|
||||||
|
|
||||||
// Fetch tables from DB
|
// Fetch tables from DB
|
||||||
sql := 'FROM ' + MainForm.mask(comboSelectDatabase.Text);
|
sql := 'FROM ' + MainForm.mask(comboSelectDatabase.Text);
|
||||||
if Mainform.ChildWin.mysql_version > 50002 then sql := 'SHOW FULL TABLES ' + sql + ' WHERE table_type=''BASE TABLE'''
|
if CWin.mysql_version > 50002 then sql := 'SHOW FULL TABLES ' + sql + ' WHERE table_type=''BASE TABLE'''
|
||||||
else sql := 'SHOW TABLES ' + sql;
|
else sql := 'SHOW TABLES ' + sql;
|
||||||
checkListTables.Items := Mainform.ChildWin.GetCol( sql );
|
checkListTables.Items := CWin.GetCol( sql );
|
||||||
|
|
||||||
// Fetch selected tables in list
|
// Fetch selected tables in list
|
||||||
Selected := GetVTCaptions( Mainform.ChildWin.ListTables, True );
|
Selected := GetVTCaptions( CWin.ListTables, True );
|
||||||
|
|
||||||
// select all/some:
|
// select all/some:
|
||||||
for i:=0 to checkListTables.Items.Count-1 do
|
for i:=0 to checkListTables.Items.Count-1 do
|
||||||
begin
|
begin
|
||||||
if Mainform.ChildWin.DBRightClickSelectedItem <> nil then
|
if CWin.ActiveDatabase = comboSelectDatabase.Text then
|
||||||
begin
|
CheckThisItem := Selected.IndexOf( checkListTables.Items[i] ) > -1
|
||||||
case Mainform.ChildWin.DBRightClickSelectedItem.Level of
|
|
||||||
2 : dbtree_table := Mainform.ChildWin.DBRightClickSelectedItem.Text;
|
|
||||||
3 : dbtree_table := Mainform.ChildWin.DBRightClickSelectedItem.Parent.Text;
|
|
||||||
end;
|
|
||||||
case Mainform.ChildWin.DBRightClickSelectedItem.Level of
|
|
||||||
1 : checkListTables.checked[i] := true;
|
|
||||||
2,3 : checkListTables.checked[i] := dbtree_table = checkListTables.Items[i];
|
|
||||||
end;
|
|
||||||
end
|
|
||||||
else if Mainform.ChildWin.ActiveDatabase = comboSelectDatabase.Text then
|
|
||||||
checkListTables.checked[i] := Selected.IndexOf( checkListTables.Items[i] ) > -1
|
|
||||||
else
|
else
|
||||||
checkListTables.checked[i] := true;
|
CheckThisItem := true;
|
||||||
|
checkListTables.checked[i] := CheckThisItem;
|
||||||
end;
|
end;
|
||||||
Mainform.ChildWin.DBRightClickSelectedItem := nil;
|
|
||||||
|
|
||||||
// write items for "Another Databases":
|
// write items for "Another Databases":
|
||||||
fillcombo_anotherdb(self);
|
fillcombo_anotherdb(self);
|
||||||
|
@ -91,32 +91,13 @@ end;
|
|||||||
|
|
||||||
{ FormShow }
|
{ FormShow }
|
||||||
procedure TfrmInsertFiles.FormShow(Sender: TObject);
|
procedure TfrmInsertFiles.FormShow(Sender: TObject);
|
||||||
var
|
|
||||||
tn : TTreeNode;
|
|
||||||
i : Integer;
|
|
||||||
begin
|
begin
|
||||||
ComboBoxDBs.Items.Clear;
|
|
||||||
Caption := Mainform.ChildWin.MysqlConn.SessionName + ' - Insert files into table ...';
|
Caption := Mainform.ChildWin.MysqlConn.SessionName + ' - Insert files into table ...';
|
||||||
for i:=0 to Mainform.ChildWin.DBTree.Items.Count-1 do
|
ComboBoxDBs.Items.Clear;
|
||||||
begin
|
ComboBoxDBs.Items.Assign(Mainform.ChildWin.Databases);
|
||||||
tn := Mainform.ChildWin.DBTree.Items[i];
|
ComboBoxDBs.ItemIndex := ComboBoxDBs.Items.IndexOf( Mainform.ChildWin.ActiveDatabase );
|
||||||
if tn.Level = 1 then
|
|
||||||
ComboBoxDBs.Items.Add(tn.Text);
|
|
||||||
end;
|
|
||||||
|
|
||||||
for i:=0 to ComboBoxDBs.Items.Count-1 do
|
|
||||||
begin
|
|
||||||
if ComboBoxDBs.Items[i] = Mainform.ChildWin.ActiveDatabase then
|
|
||||||
begin
|
|
||||||
ComboBoxDBs.ItemIndex := i;
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
|
|
||||||
if ComboBoxDBs.ItemIndex = -1 then
|
if ComboBoxDBs.ItemIndex = -1 then
|
||||||
begin
|
|
||||||
ComboBoxDBs.ItemIndex := 0;
|
ComboBoxDBs.ItemIndex := 0;
|
||||||
end;
|
|
||||||
|
|
||||||
ComboBoxDBsChange(self);
|
ComboBoxDBsChange(self);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@ -104,27 +104,11 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
procedure Tloaddataform.FormShow(Sender: TObject);
|
procedure Tloaddataform.FormShow(Sender: TObject);
|
||||||
var
|
|
||||||
tn : TTreeNode;
|
|
||||||
i : Integer;
|
|
||||||
begin
|
begin
|
||||||
// read dbs and Tables from treeview
|
// read dbs and Tables from treeview
|
||||||
comboDatabase.Items.Clear;
|
comboDatabase.Items.Clear;
|
||||||
for i:=0 to Mainform.ChildWin.DBTree.Items.Count-1 do
|
comboDatabase.Items.Assign(Mainform.ChildWin.Databases);
|
||||||
begin
|
comboDatabase.ItemIndex := comboDatabase.Items.IndexOf( Mainform.ChildWin.ActiveDatabase );
|
||||||
tn := Mainform.ChildWin.DBTree.Items[i];
|
|
||||||
if tn.Level = 1 then
|
|
||||||
comboDatabase.Items.Add(tn.Text);
|
|
||||||
end;
|
|
||||||
|
|
||||||
for i:=0 to comboDatabase.Items.Count-1 do
|
|
||||||
begin
|
|
||||||
if comboDatabase.Items[i] = Mainform.ChildWin.ActiveDatabase then
|
|
||||||
begin
|
|
||||||
comboDatabase.ItemIndex := i;
|
|
||||||
break;
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
if comboDatabase.ItemIndex = -1 then
|
if comboDatabase.ItemIndex = -1 then
|
||||||
comboDatabase.ItemIndex := 0;
|
comboDatabase.ItemIndex := 0;
|
||||||
|
|
||||||
|
@ -203,7 +203,6 @@ type
|
|||||||
procedure HandleWMComplete(var msg: TMessage); message WM_COMPLETED;
|
procedure HandleWMComplete(var msg: TMessage); message WM_COMPLETED;
|
||||||
procedure HandleWMCopyData(var msg: TWMCopyData); message WM_COPYDATA;
|
procedure HandleWMCopyData(var msg: TWMCopyData); message WM_COPYDATA;
|
||||||
procedure HandleWMProcessLog(var msg: TMessage); message WM_PROCESSLOG;
|
procedure HandleWMProcessLog(var msg: TMessage); message WM_PROCESSLOG;
|
||||||
procedure HandleWMClearRightClickPointer(var msg: TMessage); message WM_CLEAR_RIGHTCLICK_POINTER;
|
|
||||||
procedure menuUpdateCheckClick(Sender: TObject);
|
procedure menuUpdateCheckClick(Sender: TObject);
|
||||||
private
|
private
|
||||||
regMain : TRegistry;
|
regMain : TRegistry;
|
||||||
@ -298,12 +297,6 @@ begin
|
|||||||
ChildWin.ProcessSqlLog;
|
ChildWin.ProcessSqlLog;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TMainForm.HandleWMClearRightClickPointer(var msg: TMessage);
|
|
||||||
begin
|
|
||||||
debug('clearing stored right click item');
|
|
||||||
ChildWin.DBRightClickSelectedItem := nil;
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TMainForm.EnsureConnected;
|
procedure TMainForm.EnsureConnected;
|
||||||
begin
|
begin
|
||||||
if ActiveMDIChild = nil then raise Exception.Create('Not connected.');
|
if ActiveMDIChild = nil then raise Exception.Create('Not connected.');
|
||||||
@ -590,6 +583,8 @@ end;
|
|||||||
procedure TMainForm.ButtonRefreshClick(Sender: TObject);
|
procedure TMainForm.ButtonRefreshClick(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
// Refresh
|
// Refresh
|
||||||
|
// Force data tab update when appropriate.
|
||||||
|
Childwin.dataselected := false;
|
||||||
if ChildWin.PageControlMain.ActivePage = ChildWin.tabHost then
|
if ChildWin.PageControlMain.ActivePage = ChildWin.tabHost then
|
||||||
ChildWin.ShowVariablesAndProcesses(self)
|
ChildWin.ShowVariablesAndProcesses(self)
|
||||||
else if ChildWin.PageControlMain.ActivePage = ChildWin.tabDatabase then
|
else if ChildWin.PageControlMain.ActivePage = ChildWin.tabDatabase then
|
||||||
@ -598,7 +593,8 @@ begin
|
|||||||
ChildWin.ShowTableProperties(ChildWin.SelectedTable)
|
ChildWin.ShowTableProperties(ChildWin.SelectedTable)
|
||||||
else if ChildWin.PageControlMain.ActivePage = ChildWin.tabData then
|
else if ChildWin.PageControlMain.ActivePage = ChildWin.tabData then
|
||||||
ChildWin.viewdata(self)
|
ChildWin.viewdata(self)
|
||||||
else ChildWin.ReadDatabasesAndTables(self);
|
else
|
||||||
|
ChildWin.RefreshTree(True);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TMainForm.ButtonCreateDatabaseClick(Sender: TObject);
|
procedure TMainForm.ButtonCreateDatabaseClick(Sender: TObject);
|
||||||
@ -750,30 +746,27 @@ end;
|
|||||||
procedure TMainForm.actCreateViewExecute(Sender: TObject);
|
procedure TMainForm.actCreateViewExecute(Sender: TObject);
|
||||||
var
|
var
|
||||||
NodeData: PVTreeData;
|
NodeData: PVTreeData;
|
||||||
|
ds: TDataset;
|
||||||
begin
|
begin
|
||||||
if ViewForm = nil then
|
if ViewForm = nil then
|
||||||
ViewForm := TfrmView.Create(Self);
|
ViewForm := TfrmView.Create(Self);
|
||||||
ViewForm.EditViewName := '';
|
ViewForm.EditViewName := '';
|
||||||
ViewForm.DBNode := nil;
|
|
||||||
if (Sender as TAction) = actEditView then begin
|
if (Sender as TAction) = actEditView then begin
|
||||||
// Edit mode
|
// Edit mode
|
||||||
if Assigned(Childwin.ListTables.FocusedNode) then begin
|
if Assigned(Childwin.ListTables.FocusedNode) then begin
|
||||||
// "Edit view" was clicked in ListTables' context menu
|
// "Edit view" was clicked in ListTables' context menu
|
||||||
NodeData := Childwin.ListTables.GetNodeData(Childwin.ListTables.FocusedNode);
|
NodeData := Childwin.ListTables.GetNodeData(Childwin.ListTables.FocusedNode);
|
||||||
ViewForm.EditViewName := NodeData.Captions[0];
|
ViewForm.EditViewName := NodeData.Captions[0];
|
||||||
end else if Assigned(Childwin.DBRightClickSelectedItem) then begin
|
end else if Childwin.DBtree.GetFirstSelected <> nil then begin
|
||||||
// "Edit view" was clicked in DBTree's context menu
|
// "Edit view" was clicked in DBTree's context menu
|
||||||
ViewForm.EditViewName := Childwin.DBRightClickSelectedItem.Text;
|
ds := Childwin.FetchDbTableList(Childwin.ActiveDatabase);
|
||||||
ViewForm.DBNode := Childwin.DBRightClickSelectedItem.Parent;
|
ds.RecNo := Childwin.DBtree.GetFirstSelected.Index+1;
|
||||||
|
ViewForm.EditViewName := ds.Fields[0].AsString;
|
||||||
end else
|
end else
|
||||||
// If we're here, there's a menu item "Edit/Create view" in an unknown location
|
// If we're here, there's a menu item "Edit/Create view" in an unknown location
|
||||||
raise Exception.Create('Internal error in actCreateViewExexute.');
|
raise Exception.Create('Internal error in actCreateViewExexute.');
|
||||||
end else begin
|
end else begin
|
||||||
// Create mode
|
// Create mode. Nothing special here.
|
||||||
if Assigned(Childwin.DBRightClickSelectedItem) then case Childwin.DBRightClickSelectedItem.Level of
|
|
||||||
1: ViewForm.DBNode := Childwin.DBRightClickSelectedItem;
|
|
||||||
2: ViewForm.DBNode := Childwin.DBRightClickSelectedItem.Parent;
|
|
||||||
end;
|
|
||||||
end;
|
end;
|
||||||
ViewForm.ShowModal;
|
ViewForm.ShowModal;
|
||||||
end;
|
end;
|
||||||
@ -1096,48 +1089,25 @@ end;
|
|||||||
procedure TMainForm.DropTablesAndViewsExecute(Sender: TObject);
|
procedure TMainForm.DropTablesAndViewsExecute(Sender: TObject);
|
||||||
var
|
var
|
||||||
i : Integer;
|
i : Integer;
|
||||||
tndb : TTreeNode;
|
Tables, Views : TStringList;
|
||||||
Objects, Tables, Views : TStringList;
|
msg, sql, activeDB : String;
|
||||||
db, msg, sql, activeDB : String;
|
|
||||||
ds: TDataSet;
|
|
||||||
begin
|
begin
|
||||||
debug('drop table activated');
|
debug('drop table activated');
|
||||||
// Set default database name to to ActiveDatabase.
|
// Set default database name to to ActiveDatabase.
|
||||||
// Can be overwritten when someone selects a table in dbtree from different database
|
// Can be overwritten when someone selects a table in dbtree from different database
|
||||||
activeDB := Childwin.ActiveDatabase;
|
activeDB := Childwin.ActiveDatabase;
|
||||||
db := activeDB;
|
|
||||||
tndb := nil;
|
|
||||||
|
|
||||||
// Fill "Objects" and leave "Tables" and "Views" empty to postpone detection
|
|
||||||
// of views|tables to below this IF statement
|
|
||||||
Objects := TStringlist.Create;
|
|
||||||
Tables := TStringlist.Create;
|
Tables := TStringlist.Create;
|
||||||
Views := TStringlist.Create;
|
Views := TStringlist.Create;
|
||||||
if (Sender as TBasicAction).ActionComponent = Childwin.PopupMenuDropTable then begin
|
if Childwin.PageControlMain.ActivePage = Childwin.tabDatabase then begin
|
||||||
// Invoked by tree menu popup.
|
|
||||||
tndb := Childwin.DBRightClickSelectedItem.Parent;
|
|
||||||
db := tndb.Text;
|
|
||||||
Objects.add( Childwin.DBRightClickSelectedItem.Text );
|
|
||||||
end else if Childwin.PageControlMain.ActivePage = Childwin.tabDatabase then begin
|
|
||||||
// Invoked from one of the various buttons, SheetDatabase is the active page, drop highlighted table(s).
|
// Invoked from one of the various buttons, SheetDatabase is the active page, drop highlighted table(s).
|
||||||
Tables := GetVTCaptions(Childwin.ListTables, True, 0, NODETYPE_BASETABLE);
|
Tables := GetVTCaptions(Childwin.ListTables, True, 0, NODETYPE_BASETABLE);
|
||||||
Views := GetVTCaptions(Childwin.ListTables, True, 0, NODETYPE_VIEW);
|
Views := GetVTCaptions(Childwin.ListTables, True, 0, NODETYPE_VIEW);
|
||||||
end else begin
|
end else begin
|
||||||
// Invoked from one of the various buttons, drop table selected in tree view.
|
// Invoked from one of the various buttons, drop table selected in tree view.
|
||||||
Objects.add( Childwin.SelectedTable );
|
case Childwin.GetSelectedNodeType of
|
||||||
end;
|
NODETYPE_BASETABLE: Tables.Add(Childwin.SelectedTable);
|
||||||
|
NODETYPE_VIEW: Views.Add(Childwin.SelectedTable)
|
||||||
// Split Objects into Tables + Views if not already done
|
|
||||||
if (Tables.Count = 0) and (Views.Count = 0) and (Objects.Count > 0) then begin
|
|
||||||
ds := Childwin.GetResults('SHOW TABLE STATUS FROM '+Childwin.mask(db));
|
|
||||||
for i := 0 to Objects.Count - 1 do begin
|
|
||||||
while not ds.Eof do begin
|
|
||||||
case GetDBObjectType( ds.Fields ) of
|
|
||||||
NODETYPE_BASETABLE: begin Tables.Add(Objects[i]); break; end;
|
|
||||||
NODETYPE_VIEW: begin Views.Add(Objects[i]); break; end;
|
|
||||||
end;
|
|
||||||
ds.Next;
|
|
||||||
end;
|
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -1149,12 +1119,10 @@ begin
|
|||||||
Exit;
|
Exit;
|
||||||
|
|
||||||
// Ask user for confirmation to drop selected objects
|
// Ask user for confirmation to drop selected objects
|
||||||
Objects.Clear;
|
msg := 'Drop ' + IntToStr(Tables.Count+Views.Count) + ' table(s) and/or view(s) in database "'+activeDB+'"?'
|
||||||
Objects.AddStrings(Tables);
|
+ CRLF;
|
||||||
Objects.AddStrings(Views);
|
if Tables.Count > 0 then msg := msg + CRLF + 'Tables: ' + ImplodeStr(', ', Tables);
|
||||||
msg := 'Drop ' + IntToStr(Objects.Count) + ' table(s) and/or view(s) in database "'+db+'"?'
|
if Views.Count > 0 then msg := msg + CRLF + 'Views: ' + ImplodeStr(', ', Views);
|
||||||
+ CRLF + CRLF + ImplodeStr(', ', Objects);
|
|
||||||
FreeAndNil(Objects);
|
|
||||||
if MessageDlg(msg, mtConfirmation, [mbok,mbcancel], 0) <> mrok then
|
if MessageDlg(msg, mtConfirmation, [mbok,mbcancel], 0) <> mrok then
|
||||||
Exit;
|
Exit;
|
||||||
|
|
||||||
@ -1165,8 +1133,6 @@ begin
|
|||||||
begin
|
begin
|
||||||
if i > 0 then
|
if i > 0 then
|
||||||
sql := sql + ', ';
|
sql := sql + ', ';
|
||||||
if db <> activeDB then
|
|
||||||
sql := sql + Childwin.mask(db) + '.';
|
|
||||||
sql := sql + Childwin.mask(Tables[i]);
|
sql := sql + Childwin.mask(Tables[i]);
|
||||||
end;
|
end;
|
||||||
Childwin.ExecUpdateQuery( sql );
|
Childwin.ExecUpdateQuery( sql );
|
||||||
@ -1180,8 +1146,6 @@ begin
|
|||||||
begin
|
begin
|
||||||
if i > 0 then
|
if i > 0 then
|
||||||
sql := sql + ', ';
|
sql := sql + ', ';
|
||||||
if db <> activeDB then
|
|
||||||
sql := sql + Childwin.mask(db) + '.';
|
|
||||||
sql := sql + Childwin.mask(Views[i]);
|
sql := sql + Childwin.mask(Views[i]);
|
||||||
end;
|
end;
|
||||||
Childwin.ExecUpdateQuery( sql );
|
Childwin.ExecUpdateQuery( sql );
|
||||||
@ -1189,10 +1153,7 @@ begin
|
|||||||
FreeAndNil(Views);
|
FreeAndNil(Views);
|
||||||
|
|
||||||
// Refresh ListTables + dbtree so the dropped tables are gone:
|
// Refresh ListTables + dbtree so the dropped tables are gone:
|
||||||
if db = activeDB then
|
Childwin.MenuRefreshClick(Sender)
|
||||||
Childwin.MenuRefreshClick(Sender)
|
|
||||||
else
|
|
||||||
Childwin.PopulateTreeTableList( tndb, True );
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
@ -95,24 +95,12 @@ end;
|
|||||||
}
|
}
|
||||||
procedure Toptimize.FormShow(Sender: TObject);
|
procedure Toptimize.FormShow(Sender: TObject);
|
||||||
var
|
var
|
||||||
i : Integer;
|
|
||||||
tn : TTreeNode;
|
|
||||||
Selected: TStringList;
|
Selected: TStringList;
|
||||||
begin
|
begin
|
||||||
// read dbs and Tables from treeview
|
// read dbs and Tables from treeview
|
||||||
DBComboBox.Items.Clear;
|
DBComboBox.Items.Clear;
|
||||||
for i:=0 to Mainform.ChildWin.DBTree.Items.Count-1 do
|
DBComboBox.Items.Assign(Mainform.ChildWin.Databases);
|
||||||
begin
|
DBComboBox.ItemIndex := DBComboBox.Items.IndexOf( Mainform.ChildWin.ActiveDatabase );
|
||||||
tn := Mainform.ChildWin.DBTree.Items[i];
|
|
||||||
if tn.Level = 1 then
|
|
||||||
DBComboBox.Items.Add(tn.Text);
|
|
||||||
end;
|
|
||||||
DBComboBox.ItemIndex := 0;
|
|
||||||
for i:=0 to DBComboBox.Items.Count-1 do
|
|
||||||
begin
|
|
||||||
if DBComboBox.Items[i] = Mainform.ChildWin.ActiveDatabase then
|
|
||||||
DBComboBox.ItemIndex := i;
|
|
||||||
end;
|
|
||||||
if DBComboBox.ItemIndex = -1 then
|
if DBComboBox.ItemIndex = -1 then
|
||||||
DBComboBox.ItemIndex := 0;
|
DBComboBox.ItemIndex := 0;
|
||||||
DBComboBox.OnChange(self);
|
DBComboBox.OnChange(self);
|
||||||
|
@ -39,7 +39,6 @@ type
|
|||||||
PVirtualNode; var InitialStates: TVirtualNodeInitStates);
|
PVirtualNode; var InitialStates: TVirtualNodeInitStates);
|
||||||
private
|
private
|
||||||
{ Private declarations }
|
{ Private declarations }
|
||||||
FDatabases: TStringList;
|
|
||||||
FColumns: Array of Array of TStringList;
|
FColumns: Array of Array of TStringList;
|
||||||
function GetSelectedObject: TStringList;
|
function GetSelectedObject: TStringList;
|
||||||
public
|
public
|
||||||
@ -111,19 +110,11 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TfrmSelectDBObject.FormShow(Sender: TObject);
|
procedure TfrmSelectDBObject.FormShow(Sender: TObject);
|
||||||
var
|
|
||||||
i: Integer;
|
|
||||||
begin
|
begin
|
||||||
CWin := Mainform.Childwin;
|
CWin := Mainform.Childwin;
|
||||||
TreeDBO.Clear;
|
TreeDBO.Clear;
|
||||||
FDatabases := TStringList.Create;
|
TreeDBO.RootNodeCount := CWin.Databases.Count;
|
||||||
for i := 0 to CWin.DBtree.Items.Count - 1 do begin
|
SetLength(FColumns, CWin.Databases.Count);
|
||||||
if CWin.DBtree.Items[i].Level <> 1 then
|
|
||||||
continue;
|
|
||||||
FDatabases.Add(CWin.DBtree.Items[i].Text);
|
|
||||||
end;
|
|
||||||
TreeDBO.RootNodeCount := FDatabases.Count;
|
|
||||||
SetLength(FColumns, FDatabases.Count);
|
|
||||||
// TreeDBO.OnFocusChanged(TreeDBO, TreeDBO.FocusedNode, 0);
|
// TreeDBO.OnFocusChanged(TreeDBO, TreeDBO.FocusedNode, 0);
|
||||||
editDB.Clear;
|
editDB.Clear;
|
||||||
editTable.Clear;
|
editTable.Clear;
|
||||||
@ -186,7 +177,7 @@ begin
|
|||||||
case Sender.GetNodeLevel(Node) of
|
case Sender.GetNodeLevel(Node) of
|
||||||
0: ImageIndex := ICONINDEX_DB;
|
0: ImageIndex := ICONINDEX_DB;
|
||||||
1: begin
|
1: begin
|
||||||
ds := CWin.FetchDbTableList(FDatabases[Node.Parent.Index]);
|
ds := CWin.FetchDbTableList(CWin.Databases[Node.Parent.Index]);
|
||||||
ds.RecNo := Node.Index+1;
|
ds.RecNo := Node.Index+1;
|
||||||
case GetDBObjectType(ds.Fields) of
|
case GetDBObjectType(ds.Fields) of
|
||||||
NODETYPE_BASETABLE: ImageIndex := ICONINDEX_TABLE;
|
NODETYPE_BASETABLE: ImageIndex := ICONINDEX_TABLE;
|
||||||
@ -214,15 +205,15 @@ begin
|
|||||||
// Fetch sub nodes
|
// Fetch sub nodes
|
||||||
case Sender.GetNodeLevel(Node) of
|
case Sender.GetNodeLevel(Node) of
|
||||||
0: begin // DB expanding
|
0: begin // DB expanding
|
||||||
ds := CWin.FetchDbTableList(FDatabases[Node.Index]);
|
ds := CWin.FetchDbTableList(CWin.Databases[Node.Index]);
|
||||||
ChildCount := ds.RecordCount;
|
ChildCount := ds.RecordCount;
|
||||||
SetLength(FColumns[Node.Index], ds.RecordCount);
|
SetLength(FColumns[Node.Index], ds.RecordCount);
|
||||||
end;
|
end;
|
||||||
1: begin // Table expanding
|
1: begin // Table expanding
|
||||||
ds := CWin.FetchDbTableList(FDatabases[Node.Parent.Index]);
|
ds := CWin.FetchDbTableList(CWin.Databases[Node.Parent.Index]);
|
||||||
ds.RecNo := Node.Index+1;
|
ds.RecNo := Node.Index+1;
|
||||||
cols := CWin.GetCol('SHOW COLUMNS FROM '
|
cols := CWin.GetCol('SHOW COLUMNS FROM '
|
||||||
+ Mainform.mask(FDatabases[Node.Parent.Index])+'.'
|
+ Mainform.mask(CWin.Databases[Node.Parent.Index])+'.'
|
||||||
+ Mainform.Mask(ds.Fields[0].AsString));
|
+ Mainform.Mask(ds.Fields[0].AsString));
|
||||||
FColumns[Node.Parent.Index][Node.Index] := cols;
|
FColumns[Node.Parent.Index][Node.Index] := cols;
|
||||||
ChildCount := cols.Count;
|
ChildCount := cols.Count;
|
||||||
@ -239,9 +230,9 @@ var
|
|||||||
ds: TDataset;
|
ds: TDataset;
|
||||||
begin
|
begin
|
||||||
case Sender.GetNodeLevel(Node) of
|
case Sender.GetNodeLevel(Node) of
|
||||||
0: CellText := FDatabases[Node.Index];
|
0: CellText := CWin.Databases[Node.Index];
|
||||||
1: begin
|
1: begin
|
||||||
ds := CWin.FetchDbTableList(FDatabases[Node.Parent.Index]);
|
ds := CWin.FetchDbTableList(CWin.Databases[Node.Parent.Index]);
|
||||||
ds.RecNo := Node.Index+1;
|
ds.RecNo := Node.Index+1;
|
||||||
CellText := ds.Fields[0].AsString;
|
CellText := ds.Fields[0].AsString;
|
||||||
end;
|
end;
|
||||||
|
@ -52,7 +52,6 @@ type
|
|||||||
currentCollation,
|
currentCollation,
|
||||||
currentAutoincrement : String;
|
currentAutoincrement : String;
|
||||||
public
|
public
|
||||||
DatabaseName,
|
|
||||||
TableName : String;
|
TableName : String;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -128,8 +127,6 @@ var
|
|||||||
begin
|
begin
|
||||||
// Fetch table properties
|
// Fetch table properties
|
||||||
sql := 'SHOW TABLE STATUS ';
|
sql := 'SHOW TABLE STATUS ';
|
||||||
if DatabaseName <> '' then
|
|
||||||
sql := sql + ' FROM ' + Mainform.mask(DatabaseName)+' ';
|
|
||||||
sql := sql + 'LIKE '+esc(TableName);
|
sql := sql + 'LIKE '+esc(TableName);
|
||||||
ds := Mainform.Childwin.GetResults(sql);
|
ds := Mainform.Childwin.GetResults(sql);
|
||||||
|
|
||||||
@ -183,8 +180,6 @@ begin
|
|||||||
|
|
||||||
// SQL preview
|
// SQL preview
|
||||||
sql := 'SHOW CREATE TABLE ';
|
sql := 'SHOW CREATE TABLE ';
|
||||||
if DatabaseName <> '' then
|
|
||||||
sql := sql + Mainform.mask(DatabaseName)+'.';
|
|
||||||
sql := sql + Mainform.Childwin.mask(currentName);
|
sql := sql + Mainform.Childwin.mask(currentName);
|
||||||
SynMemoCreate.Lines.Text := Mainform.Childwin.GetVar( sql, 1 );
|
SynMemoCreate.Lines.Text := Mainform.Childwin.GetVar( sql, 1 );
|
||||||
|
|
||||||
@ -278,8 +273,6 @@ begin
|
|||||||
if currentName <> editName.Text then
|
if currentName <> editName.Text then
|
||||||
begin
|
begin
|
||||||
tmp := 'RENAME ';
|
tmp := 'RENAME ';
|
||||||
if DatabaseName <> '' then
|
|
||||||
tmp := tmp + Mainform.mask(DatabaseName)+'.';
|
|
||||||
tmp := tmp + Mainform.mask(editName.Text);
|
tmp := tmp + Mainform.mask(editName.Text);
|
||||||
AlterSpecs.Add( tmp );
|
AlterSpecs.Add( tmp );
|
||||||
end;
|
end;
|
||||||
@ -306,16 +299,9 @@ begin
|
|||||||
|
|
||||||
if AlterSpecs.Count > 0 then
|
if AlterSpecs.Count > 0 then
|
||||||
begin
|
begin
|
||||||
sql := 'ALTER TABLE ';
|
sql := 'ALTER TABLE ' + Mainform.Childwin.mask(currentName) + ' ' + ImplodeStr(', ', AlterSpecs);
|
||||||
if DatabaseName <> '' then
|
|
||||||
sql := sql + Mainform.mask(DatabaseName)+'.';
|
|
||||||
sql := sql + Mainform.Childwin.mask(currentName) + ' ' + ImplodeStr(', ', AlterSpecs);
|
|
||||||
try
|
try
|
||||||
Mainform.ChildWin.ExecUpdateQuery( sql );
|
Mainform.ChildWin.ExecUpdateQuery( sql );
|
||||||
if DatabaseName = '' then
|
|
||||||
Mainform.ChildWin.MenuRefreshClick( Sender )
|
|
||||||
else
|
|
||||||
Mainform.ChildWin.PopulateTreeTableList( Mainform.ChildWin.DBRightClickSelectedItem.Parent, True );
|
|
||||||
except
|
except
|
||||||
On E:Exception do
|
On E:Exception do
|
||||||
begin
|
begin
|
||||||
@ -324,6 +310,7 @@ begin
|
|||||||
ModalResult := mrNone;
|
ModalResult := mrNone;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
Mainform.ChildWin.MenuRefreshClick( Sender )
|
||||||
end;
|
end;
|
||||||
|
|
||||||
end;
|
end;
|
||||||
|
@ -28,7 +28,6 @@ type
|
|||||||
public
|
public
|
||||||
{ Public declarations }
|
{ Public declarations }
|
||||||
EditViewName: String;
|
EditViewName: String;
|
||||||
DBNode: TTreeNode;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
@ -83,10 +82,7 @@ begin
|
|||||||
// Edit mode
|
// Edit mode
|
||||||
Caption := 'Edit view ...';
|
Caption := 'Edit view ...';
|
||||||
editName.Text := EditViewName;
|
editName.Text := EditViewName;
|
||||||
if not Assigned(DBNode) then
|
db := Mainform.ChildWin.ActiveDatabase;
|
||||||
db := Mainform.ChildWin.ActiveDatabase
|
|
||||||
else
|
|
||||||
db := DBNode.Text;
|
|
||||||
ds := Mainform.ChildWin.GetResults('SELECT * FROM '+Mainform.mask(DBNAME_INFORMATION_SCHEMA)+'.VIEWS ' +
|
ds := Mainform.ChildWin.GetResults('SELECT * FROM '+Mainform.mask(DBNAME_INFORMATION_SCHEMA)+'.VIEWS ' +
|
||||||
'WHERE TABLE_SCHEMA = '+esc(db)+' AND TABLE_NAME = '+esc(EditViewName));
|
'WHERE TABLE_SCHEMA = '+esc(db)+' AND TABLE_NAME = '+esc(EditViewName));
|
||||||
if ds.RecordCount = 0 then
|
if ds.RecordCount = 0 then
|
||||||
@ -167,8 +163,6 @@ begin
|
|||||||
viewname := EditViewName;
|
viewname := EditViewName;
|
||||||
end;
|
end;
|
||||||
viewname := Mainform.mask(viewname);
|
viewname := Mainform.mask(viewname);
|
||||||
if Assigned(DBNode) then
|
|
||||||
viewname := Mainform.mask(DBNode.Text) + '.' + viewname;
|
|
||||||
if rgAlgorithm.Enabled and (rgAlgorithm.ItemIndex > -1) then
|
if rgAlgorithm.Enabled and (rgAlgorithm.ItemIndex > -1) then
|
||||||
sql := sql + 'ALGORITHM = '+Uppercase(rgAlgorithm.Items[rgAlgorithm.ItemIndex])+' ';
|
sql := sql + 'ALGORITHM = '+Uppercase(rgAlgorithm.Items[rgAlgorithm.ItemIndex])+' ';
|
||||||
sql := sql + 'VIEW ' + viewname+' AS '+SynMemoSelect.Text+' ';
|
sql := sql + 'VIEW ' + viewname+' AS '+SynMemoSelect.Text+' ';
|
||||||
@ -181,15 +175,10 @@ begin
|
|||||||
// Probably rename view
|
// Probably rename view
|
||||||
if (EditViewName <> '') and (EditViewName <> editName.Text) then begin
|
if (EditViewName <> '') and (EditViewName <> editName.Text) then begin
|
||||||
renamed := Mainform.mask(editName.Text);
|
renamed := Mainform.mask(editName.Text);
|
||||||
if Assigned(DBNode) then
|
|
||||||
renamed := Mainform.mask(DBNode.Text) + '.' + renamed;
|
|
||||||
Mainform.Childwin.ExecUpdateQuery('ALTER TABLE '+viewname
|
Mainform.Childwin.ExecUpdateQuery('ALTER TABLE '+viewname
|
||||||
+ ' RENAME '+renamed);
|
+ ' RENAME '+renamed);
|
||||||
end;
|
end;
|
||||||
if (not Assigned(DBNode)) or (DBNode.Text = Mainform.Childwin.ActiveDatabase) then
|
Mainform.ChildWin.RefreshTreeDB(Mainform.ChildWin.ActiveDatabase);
|
||||||
Mainform.ChildWin.MenuRefreshClick( Sender )
|
|
||||||
else
|
|
||||||
Mainform.ChildWin.PopulateTreeTableList( DBNode, True );
|
|
||||||
except
|
except
|
||||||
on E: THandledSQLError do begin
|
on E: THandledSQLError do begin
|
||||||
MessageDlg(E.Message, mtError, [mbOK], 0);
|
MessageDlg(E.Message, mtError, [mbOK], 0);
|
||||||
|
Reference in New Issue
Block a user