Fix issue #1151: Items in main database view (tables/procedures/etc) think they're something else

This commit is contained in:
Ansgar Becker
2009-05-23 07:31:10 +00:00
parent e3367d53de
commit fcebc2697c

View File

@ -4933,8 +4933,8 @@ end;
procedure TMainForm.popupDBPopup(Sender: TObject); procedure TMainForm.popupDBPopup(Sender: TObject);
var var
L: Cardinal; L: Cardinal;
ds: TDataset;
HasFocus, InDBTree: Boolean; HasFocus, InDBTree: Boolean;
NodeData: PVTreeData;
begin begin
// DBtree and ListTables both use popupDB as menu. Find out which of them was rightclicked. // DBtree and ListTables both use popupDB as menu. Find out which of them was rightclicked.
if Sender is TPopupMenu then if Sender is TPopupMenu then
@ -4973,14 +4973,14 @@ begin
actDropObjects.Enabled := ListTables.SelectedCount > 0; actDropObjects.Enabled := ListTables.SelectedCount > 0;
actEmptyTables.Enabled := False; actEmptyTables.Enabled := False;
if HasFocus then begin if HasFocus then begin
ds := FetchDbTableList(ActiveDatabase); NodeData := ListTables.GetNodeData(ListTables.FocusedNode);
ds.RecNo := ListTables.FocusedNode.Index+1; actEmptyTables.Enabled := NodeData.NodeType in [NODETYPE_TABLE, NODETYPE_CRASHED_TABLE, NODETYPE_VIEW];
actEmptyTables.Enabled := GetDBObjectType(ds.Fields) in [NODETYPE_TABLE, NODETYPE_CRASHED_TABLE, NODETYPE_VIEW];
end; end;
actEditObject.Enabled := HasFocus; actEditObject.Enabled := HasFocus;
// Show certain items which are valid only here // Show certain items which are valid only here
actViewData.Visible := True; actViewData.Visible := True;
actViewData.Enabled := actEmptyTables.Enabled; actViewData.Enabled := actEmptyTables.Enabled;
actCopyTable.Enabled := actEmptyTables.Enabled;
menuTreeExpandAll.Visible := False; menuTreeExpandAll.Visible := False;
menuTreeCollapseAll.Visible := False; menuTreeCollapseAll.Visible := False;
menuShowSizeColumn.Visible := False; menuShowSizeColumn.Visible := False;
@ -8834,7 +8834,7 @@ var
InDBTree: Boolean; InDBTree: Boolean;
ObjectType: Byte; ObjectType: Byte;
ObjectName: WideString; ObjectName: WideString;
ds: TDataset; NodeData: PVTreeData;
begin begin
Act := Sender as TAction; Act := Sender as TAction;
InDBTree := (Act.ActionComponent is TMenuItem) InDBTree := (Act.ActionComponent is TMenuItem)
@ -8844,9 +8844,8 @@ begin
ObjectType := GetSelectedNodeType; ObjectType := GetSelectedNodeType;
ObjectName := DBTree.Text[DBTree.FocusedNode, DBTree.FocusedColumn]; ObjectName := DBTree.Text[DBTree.FocusedNode, DBTree.FocusedColumn];
end else begin end else begin
ds := FetchDbTableList(ActiveDatabase); NodeData := ListTables.GetNodeData(ListTables.FocusedNode);
ds.RecNo := ListTables.FocusedNode.Index +1; ObjectType := NodeData.NodeType;
ObjectType := GetDBObjectType(ds.Fields);
ObjectName := ListTables.Text[ListTables.FocusedNode, ListTables.FocusedColumn]; ObjectName := ListTables.Text[ListTables.FocusedNode, ListTables.FocusedColumn];
end; end;