Place a "EXPLAIN" link label to the process viewer, which creates a new query tab and executes "EXPLAIN [selected process query]".

This commit is contained in:
Ansgar Becker
2010-02-22 08:56:13 +00:00
parent 962c0b3b44
commit 484fcdbd46
2 changed files with 35 additions and 0 deletions

View File

@@ -723,6 +723,22 @@ object MainForm: TMainForm
BevelOuter = bvNone
Caption = 'Process SQL:'
TabOrder = 0
object lblExplainProcess: TLabel
Left = 87
Top = 1
Width = 41
Height = 13
Cursor = crHandPoint
Hint = 'Analyze this query'
Caption = 'EXPLAIN'
Font.Charset = DEFAULT_CHARSET
Font.Color = clBlue
Font.Height = -11
Font.Name = 'Default'
Font.Style = []
ParentFont = False
OnClick = lblExplainProcessClick
end
end
object SynMemoProcessView: TSynMemo
Left = 0

View File

@@ -458,6 +458,7 @@ type
Findtext1: TMenuItem;
actQueryFindAgain1: TMenuItem;
Replacetext1: TMenuItem;
lblExplainProcess: TLabel;
procedure refreshMonitorConfig;
procedure loadWindowConfig;
procedure saveWindowConfig;
@@ -728,6 +729,7 @@ type
TransientType: TTransientType);
procedure actQueryFindAgainExecute(Sender: TObject);
procedure vstScroll(Sender: TBaseVirtualTree; DeltaX, DeltaY: Integer);
procedure lblExplainProcessClick(Sender: TObject);
private
ReachedEOT: Boolean;
FDelimiter: String;
@@ -1244,6 +1246,9 @@ begin
InheritFont(Font);
InheritFont(tabsetQueryHelpers.Font);
InheritFont(SynCompletionProposal.Font);
// Simulated link label, has non inherited blue font color
InheritFont(lblExplainProcess.Font);
StatusBar.Height := GetTextHeight(StatusBar.Font)+4;
// Upscale panels in non-96-DPI mode
DpiScaleFactor := Screen.PixelsPerInch / FORMS_DPI;
@@ -5898,6 +5903,7 @@ begin
enableSQLView := Assigned(Node);
SynMemoProcessView.Enabled := enableSQLView;
pnlProcessView.Enabled := enableSQLView;
lblExplainProcess.Enabled := enableSQLView;
if enableSQLView then begin
NodeData := ListProcesses.GetNodeData(Node);
SynMemoProcessView.Highlighter := SynSQLSyn1;
@@ -9342,5 +9348,18 @@ begin
end;
procedure TMainForm.lblExplainProcessClick(Sender: TObject);
var
Tab: TQueryTab;
begin
// Click on "Explain" link label, in process viewer
actNewQueryTabExecute(Sender);
Tab := QueryTabs[QueryTabs.Count-1];
Tab.Memo.Text := 'EXPLAIN'+CRLF+SynMemoProcessView.Text;
Tab.TabSheet.Show;
actExecuteQueryExecute(Sender);
end;
end.