Fix empty tabSettings when creating very first session. Do less what flickers in ValidateControls, move pagecontrol related stuff in ListSessions.FocusChanged. Also, call FocusChanged event explicitly in SelectNode() when focus did not effectively change.

This commit is contained in:
Ansgar Becker
2012-01-02 23:57:17 +00:00
parent e87e17ff4a
commit 7ccf8fde9f
2 changed files with 27 additions and 26 deletions

View File

@ -187,6 +187,7 @@ begin
ListSessions.RootNodeCount := FSessions.Count; ListSessions.RootNodeCount := FSessions.Count;
// Focus last session // Focus last session
SelectNode(ListSessions, nil);
LastSessions := Explode(DELIM, GetRegValue(REGNAME_LASTSESSIONS, '')); LastSessions := Explode(DELIM, GetRegValue(REGNAME_LASTSESSIONS, ''));
LastActiveSession := GetRegValue(REGNAME_LASTACTIVESESSION, ''); LastActiveSession := GetRegValue(REGNAME_LASTACTIVESESSION, '');
if (LastActiveSession = '') and (LastSessions.Count > 0) then if (LastActiveSession = '') and (LastSessions.Count > 0) then
@ -198,7 +199,6 @@ begin
SelectNode(ListSessions, Node); SelectNode(ListSessions, Node);
Node := ListSessions.GetNextSibling(Node); Node := ListSessions.GetNextSibling(Node);
end; end;
ValidateControls;
// Add own menu items to system menu // Add own menu items to system menu
hSysMenu := GetSystemMenu(Handle, False); hSysMenu := GetSystemMenu(Handle, False);
@ -397,11 +397,8 @@ begin
FSessions.Remove(Sess^); FSessions.Remove(Sess^);
if (not Assigned(ListSessions.FocusedNode)) and (ListSessions.RootNodeCount > 0) then if (not Assigned(ListSessions.FocusedNode)) and (ListSessions.RootNodeCount > 0) then
SelectNode(ListSessions, ListSessions.RootNodeCount-1) SelectNode(ListSessions, ListSessions.RootNodeCount-1)
else begin else
Node := ListSessions.FocusedNode; SelectNode(ListSessions, nil);
ListSessions.FocusedNode := nil;
ListSessions.FocusedNode := Node;
end;
end; end;
end; end;
@ -527,10 +524,25 @@ begin
Screen.Cursor := crHourglass; Screen.Cursor := crHourglass;
TimerStatistics.Enabled := False; TimerStatistics.Enabled := False;
SessionFocused := Assigned(Node); SessionFocused := Assigned(Node);
if SessionFocused then begin FLoaded := False;
tabStart.TabVisible := not SessionFocused;
tabSettings.TabVisible := SessionFocused;
tabSSHtunnel.TabVisible := SessionFocused;
tabSSLoptions.TabVisible := SessionFocused;
tabStatistics.TabVisible := SessionFocused;
if not SessionFocused then begin
PageControlDetails.ActivePage := tabStart;
if FSessions.Count = 0 then
lblHelp.Caption := 'New here? In order to connect to a server, you have to create a so called '+
'"session" at first. Just click the "New" button on the bottom left to create your first session.'+CRLF+CRLF+
'Give it a friendly name (e.g. "Local DB server") so you''ll recall it the next time you start '+APPNAME+'.'
else
lblHelp.Caption := 'Please click a session on the left list to edit parameters, doubleclick to open it.';
end else begin
PageControlDetails.ActivePage := tabSettings;
Sess := Sender.GetNodeData(Node); Sess := Sender.GetNodeData(Node);
FLoaded := False;
comboNetType.ItemIndex := Integer(Sess.NetType); comboNetType.ItemIndex := Integer(Sess.NetType);
editHost.Text := Sess.Hostname; editHost.Text := Sess.Hostname;
editUsername.Text := Sess.Username; editUsername.Text := Sess.Username;
@ -553,9 +565,9 @@ begin
editSSLCertificate.Text := Sess.SSLCertificate; editSSLCertificate.Text := Sess.SSLCertificate;
editSSLCACertificate.Text := Sess.SSLCACertificate; editSSLCACertificate.Text := Sess.SSLCACertificate;
FServerVersion := Sess.ServerVersion; FServerVersion := Sess.ServerVersion;
FLoaded := True;
end; end;
FLoaded := True;
FSessionModified := False; FSessionModified := False;
FSessionAdded := False; FSessionAdded := False;
ListSessions.Repaint; ListSessions.Repaint;
@ -778,27 +790,13 @@ var
begin begin
SessionFocused := Assigned(ListSessions.FocusedNode); SessionFocused := Assigned(ListSessions.FocusedNode);
LockWindowUpdate(PageControlDetails.Handle);
tabStart.TabVisible := not SessionFocused;
tabSettings.TabVisible := SessionFocused;
tabSSHtunnel.TabVisible := SessionFocused;
tabSSLoptions.TabVisible := SessionFocused;
tabStatistics.TabVisible := SessionFocused;
btnOpen.Enabled := SessionFocused; btnOpen.Enabled := SessionFocused;
btnNew.Enabled := not FSessionAdded; btnNew.Enabled := not FSessionAdded;
btnSave.Enabled := FSessionModified or FSessionAdded; btnSave.Enabled := FSessionModified or FSessionAdded;
btnDelete.Enabled := SessionFocused; btnDelete.Enabled := SessionFocused;
btnOpen.Enabled := SessionFocused; btnOpen.Enabled := SessionFocused;
if not SessionFocused then begin if SessionFocused then begin
PageControlDetails.ActivePage := tabStart;
if FSessions.Count = 0 then
lblHelp.Caption := 'New here? In order to connect to a server, you have to create a so called '+
'"session" at first. Just click the "New" button on the bottom left to create your first session.'+CRLF+CRLF+
'Give it a friendly name (e.g. "Local DB server") so you''ll recall it the next time you start '+APPNAME+'.'
else
lblHelp.Caption := 'Please click a session on the left list to edit parameters, doubleclick to open it.';
end else begin
// Validate session GUI stuff // Validate session GUI stuff
Params := CurrentParams; Params := CurrentParams;
if Params.NetType = ntMySQL_NamedPipe then if Params.NetType = ntMySQL_NamedPipe then
@ -814,12 +812,10 @@ begin
lblPort.Enabled := Params.NetType in [ntMySQL_TCPIP, ntMySQL_SSHtunnel, ntMSSQL_TCPIP]; lblPort.Enabled := Params.NetType in [ntMySQL_TCPIP, ntMySQL_SSHtunnel, ntMSSQL_TCPIP];
editPort.Enabled := lblPort.Enabled; editPort.Enabled := lblPort.Enabled;
updownPort.Enabled := lblPort.Enabled; updownPort.Enabled := lblPort.Enabled;
PageControlDetails.ActivePage := tabSettings;
tabSSLoptions.TabVisible := Params.NetType = ntMySQL_TCPIP; tabSSLoptions.TabVisible := Params.NetType = ntMySQL_TCPIP;
tabSSHtunnel.TabVisible := Params.NetType = ntMySQL_SSHtunnel; tabSSHtunnel.TabVisible := Params.NetType = ntMySQL_SSHtunnel;
FreeAndNil(Params); FreeAndNil(Params);
end; end;
LockWindowUpdate(0);
end; end;

View File

@ -1747,11 +1747,16 @@ end;
procedure SelectNode(VT: TVirtualStringTree; Node: PVirtualNode); overload; procedure SelectNode(VT: TVirtualStringTree; Node: PVirtualNode); overload;
var
OldFocus: PVirtualNode;
begin begin
OldFocus := VT.FocusedNode;
VT.ClearSelection; VT.ClearSelection;
VT.FocusedNode := Node; VT.FocusedNode := Node;
VT.Selected[Node] := True; VT.Selected[Node] := True;
VT.ScrollIntoView(Node, False); VT.ScrollIntoView(Node, False);
if (OldFocus = Node) and Assigned(VT.OnFocusChanged) then
VT.OnFocusChanged(VT, Node, VT.Header.MainColumn);
end; end;