diff --git a/source/helpers.pas b/source/helpers.pas index d0f2caf5..5dd0480d 100644 --- a/source/helpers.pas +++ b/source/helpers.pas @@ -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; diff --git a/source/main.pas b/source/main.pas index 1a8d3193..8a3d99f9 100644 --- a/source/main.pas +++ b/source/main.pas @@ -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; diff --git a/source/trigger_editor.pas b/source/trigger_editor.pas index 17af8e86..677c7958 100644 --- a/source/trigger_editor.pas +++ b/source/trigger_editor.pas @@ -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;