Prefill table combobox in trigger editor with currently selected table name. See issue #3477.

This commit is contained in:
Ansgar Becker
2013-12-20 05:36:37 +00:00
parent 9eb7c6cdb5
commit 2269d67fbb
3 changed files with 25 additions and 2 deletions

View File

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

View File

@ -3576,8 +3576,6 @@ var
a: TAction; a: TAction;
begin begin
// Create a new table, view, etc. // Create a new table, view, etc.
tabEditor.TabVisible := True;
SetMainTab(tabEditor);
a := Sender as TAction; a := Sender as TAction;
Obj := TDBObject.Create(ActiveConnection); Obj := TDBObject.Create(ActiveConnection);
Obj.Database := ActiveDatabase; Obj.Database := ActiveDatabase;
@ -9421,6 +9419,9 @@ begin
ActiveObjectEditor.Parent := tabEditor; ActiveObjectEditor.Parent := tabEditor;
MainForm.SetupSynEditors; MainForm.SetupSynEditors;
end; end;
// Prefill editor with selected items. See issue #3477.
ActiveObjectEditor.FocusedTables := GetFocusedObjects(Obj, [lntTable]);
SetMainTab(tabEditor);
ActiveObjectEditor.Init(Obj); ActiveObjectEditor.Init(Obj);
UpdateFilterPanel(Self); UpdateFilterPanel(Self);
end; end;
@ -10142,6 +10143,7 @@ procedure TMainForm.SetMainTab(Page: TTabSheet);
begin begin
// Safely switch main tab // Safely switch main tab
if (Page <> nil) and (not FTreeRefreshInProgress) then begin if (Page <> nil) and (not FTreeRefreshInProgress) then begin
Page.TabVisible := True;
PagecontrolMain.ActivePage := Page; PagecontrolMain.ActivePage := Page;
PageControlMain.OnChange(Page); PageControlMain.OnChange(Page);
end; end;

View File

@ -127,6 +127,14 @@ begin
Raise Exception.Create(_('Trigger definition not found!')); Raise Exception.Create(_('Trigger definition not found!'));
end else begin end else begin
editName.Text := ''; editName.Text := '';
if FocusedTables.Count > 0 then begin
for i:=0 to comboTable.Items.Count-1 do begin
if comboTable.Items[i] = FocusedTables[0].Name then begin
comboTable.ItemIndex := i;
Break;
end;
end;
end;
end; end;
Modification(Self); Modification(Self);
Modified := False; Modified := False;