Roll back parts of r4681 for getting the selected table into the trigger name, as this broke keeping the data tab active when switching tables. See http://www.heidisql.com/forum.php?t=14399 . Instead, introduce and make use of MainForm.FocusedTables. Fixes issue #3477.

This commit is contained in:
Ansgar Becker
2013-12-26 05:38:27 +00:00
parent 35e809ae32
commit fd63e5e840
3 changed files with 8 additions and 19 deletions

View File

@ -29,9 +29,7 @@ type
private
FModified: Boolean;
FDefiners: TStringList;
FFocusedTables: TDBObjectList;
procedure SetModified(Value: Boolean);
procedure SetFocusedTables(Value: TDBObjectList);
protected
public
DBObject: TDBObject;
@ -41,7 +39,6 @@ type
function DeInit: TModalResult;
function GetDefiners: TStringList;
property Modified: Boolean read FModified write SetModified;
property FocusedTables: TDBObjectList read FFocusedTables write SetFocusedTables;
function ApplyModifications: TModalResult; virtual; abstract;
end;
TDBObjectEditorClass = class of TDBObjectEditor;
@ -1803,12 +1800,10 @@ begin
Align := alClient;
InheritFont(Font);
ScaleControls(Screen.PixelsPerInch, FORMS_DPI);
FocusedTables := nil;
end;
destructor TDBObjectEditor.Destroy;
begin
FFocusedTables.Free;
inherited;
end;
@ -1817,14 +1812,6 @@ begin
FModified := Value;
end;
procedure TDBObjectEditor.SetFocusedTables(Value: TDBObjectList);
begin
if Value = nil then
FFocusedTables := TDBObjectList.Create(False)
else
FFocusedTables := Value;
end;
procedure TDBObjectEditor.Init(Obj: TDBObject);
var
editName: TWinControl;

View File

@ -973,6 +973,7 @@ type
FGridCopying: Boolean;
FGridPasting: Boolean;
FHasDonatedDatabaseCheck: TThreeStateBoolean;
FFocusedTables: TDBObjectList;
// Host subtabs backend structures
FHostListResults: TDBQueryList;
@ -1043,6 +1044,7 @@ type
property Connections: TDBConnectionList read FConnections;
property Delimiter: String read FDelimiter write SetDelimiter;
property IsWine: Boolean read FIsWine;
property FocusedTables: TDBObjectList read FFocusedTables;
procedure PaintColorBar(Value, Max: Extended; TargetCanvas: TCanvas; CellRect: TRect);
procedure CallSQLHelpWithKeyword( keyword: String );
procedure AddOrRemoveFromQueryLoadHistory(Filename: String; AddIt: Boolean; CheckIfFileExists: Boolean);
@ -3553,6 +3555,9 @@ var
a: TAction;
begin
// Create a new table, view, etc.
FFocusedTables := GetFocusedObjects(Sender, [lntTable]);
tabEditor.TabVisible := True;
SetMainTab(tabEditor);
a := Sender as TAction;
Obj := TDBObject.Create(ActiveConnection);
Obj.Database := ActiveDatabase;
@ -9396,9 +9401,6 @@ begin
ActiveObjectEditor.Parent := tabEditor;
MainForm.SetupSynEditors;
end;
// Prefill editor with selected items. See issue #3477.
ActiveObjectEditor.FocusedTables := GetFocusedObjects(Obj, [lntTable]);
SetMainTab(tabEditor);
ActiveObjectEditor.Init(Obj);
UpdateFilterPanel(Self);
end;
@ -10120,7 +10122,6 @@ procedure TMainForm.SetMainTab(Page: TTabSheet);
begin
// Safely switch main tab
if (Page <> nil) and (not FTreeRefreshInProgress) then begin
Page.TabVisible := True;
PagecontrolMain.ActivePage := Page;
PageControlMain.OnChange(Page);
end;

View File

@ -128,10 +128,11 @@ begin
Raise Exception.Create(_('Trigger definition not found!'));
end else begin
editName.Text := '';
if FocusedTables.Count > 0 then begin
if MainForm.FocusedTables.Count > 0 then begin
for i:=0 to comboTable.Items.Count-1 do begin
if comboTable.Items[i] = FocusedTables[0].Name then begin
if comboTable.Items[i] = MainForm.FocusedTables[0].Name then begin
comboTable.ItemIndex := i;
comboChange(comboTable);
Break;
end;
end;