From 8cbbf11678cb13ed44c562c8e93782bfaa0ac3ea Mon Sep 17 00:00:00 2001 From: Korobenkov Vladimir Date: Wed, 19 Dec 2018 13:13:47 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9D=D0=B5=D0=B1=D0=BE=D0=BB=D1=8C=D1=88?= =?UTF-8?q?=D0=B8=D0=B5=20=D0=B8=D0=B7=D0=BC=D0=B5=D0=BD=D0=B5=D0=BD=D0=B8?= =?UTF-8?q?=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Запрос теперь исполняется в конкретную вкладку. Во время ожидания исполнения результатов запроса на вкладке крутится анимация --- PrFormUnit.pas | 12 ++++++ SqlThreadUnit.pas | 7 ++- logFormUnit.dfm | 13 ++++-- logFormUnit.pas | 106 ++++++++++++++++++++++++++++++---------------- 4 files changed, 96 insertions(+), 42 deletions(-) diff --git a/PrFormUnit.pas b/PrFormUnit.pas index ccc8e59..3c382c7 100644 --- a/PrFormUnit.pas +++ b/PrFormUnit.pas @@ -431,8 +431,20 @@ procedure TPrForm.OnClickHistoryPopupMenu(Sender: TObject); end; procedure TPrForm.OnClearHistoryPopupMenu(Sender: TObject); +var + Registry : TRegistry; begin +//ShowMessage('aa'); + HistoryPopupMenu.Items.Clear; + FPathHistory.Clear; + Registry := TRegistry.Create(KEY_ALL_ACCESS); + try + Registry.RootKey := HKEY_CURRENT_USER; + Registry.DeleteKey(cnstDllKey + '\' + cnstPrHistKey); + finally + Registry.Free; + end; end; procedure TPrForm.SetExternalServer(const Value: String); diff --git a/SqlThreadUnit.pas b/SqlThreadUnit.pas index 0adcbdd..2b3edf7 100644 --- a/SqlThreadUnit.pas +++ b/SqlThreadUnit.pas @@ -5,7 +5,8 @@ interface uses Winapi.Windows, System.SysUtils, System.Classes, System.StrUtils, System.Win.ComObj, Data.DB, Data.Win.ADODB, WinApi.ADOInt, Vcl.Dialogs, - ConstUnit, Variants, ThreadUnit, StringGridsUnit, StringGridExUnit; + ConstUnit, Variants, ThreadUnit, StringGridsUnit, StringGridExUnit, + ExtScrollingWinControlUnit; type TSqlThreadObject = class(TThreadExecObject) @@ -47,12 +48,14 @@ TSqlQueryObject = class(TSqlThreadObject) TSqlExecutorObject = class(TSqlThreadObject) private FGrids: TStringGrids; + FScrollBox: TExScrollBox; protected procedure Execute; override; public constructor Create; destructor Destroy; override; property Grids: TStringGrids read FGrids; + property ScrollBox: TExScrollBox read FScrollBox write FScrollBox; end; TSqlIndexObject = class(TSqlThreadObject) @@ -594,7 +597,7 @@ procedure TSqlIndexObject.Execute; Sk := VarToStr(V); end; end; - FIndexes.Add(Format(cnstIndexTemplate,[S,StringReplace(Sk,' ','',[rfReplaceAll])])); + FIndexes.Add(Format(cnstIndexTemplate,[StringReplace(S,' ','',[rfReplaceAll]),StringReplace(Sk,' ','',[rfReplaceAll])])); rs.MoveNext; end; finally diff --git a/logFormUnit.dfm b/logFormUnit.dfm index 7efd961..02eac03 100644 --- a/logFormUnit.dfm +++ b/logFormUnit.dfm @@ -84,6 +84,13 @@ inherited logForm: TlogForm Align = alClient BevelOuter = bvNone TabOrder = 0 + object ActivityIndicator1: TActivityIndicator + Left = 0 + Top = 2 + Animate = True + IndicatorSize = aisLarge + IndicatorType = aitRotatingSector + end end object invGrid: TStringGrid Left = 708 @@ -170,9 +177,9 @@ inherited logForm: TlogForm end object Images: TImageList Left = 208 - Top = 64 + Top = 112 Bitmap = { - 494C010116009000600110001000FFFFFFFFFF10FFFFFFFFFFFFFFFF424D3600 + 494C010116009000680110001000FFFFFFFFFF10FFFFFFFFFFFFFFFF424D3600 0000000000003600000028000000400000006000000001002000000000000060 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 @@ -1178,7 +1185,7 @@ inherited logForm: TlogForm Left = 32 Top = 552 Bitmap = { - 494C010106001D00400010001000FFFFFFFFFF10FFFFFFFFFFFFFFFF424D3600 + 494C010106001D00480010001000FFFFFFFFFF10FFFFFFFFFFFFFFFF424D3600 0000000000003600000028000000400000002000000001002000000000000020 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 diff --git a/logFormUnit.pas b/logFormUnit.pas index 5338b33..1e02b27 100644 --- a/logFormUnit.pas +++ b/logFormUnit.pas @@ -67,6 +67,7 @@ TlogForm = class(TNppDockingForm) tabPopupMenu: TPopupMenu; DeleteTabAction: TAction; N6: TMenuItem; + ActivityIndicator1: TActivityIndicator; procedure FormCreate(Sender: TObject); procedure SQLActionExecute(Sender: TObject); procedure CopyAllGridActionExecute(Sender: TObject); @@ -110,15 +111,15 @@ TlogForm = class(TNppDockingForm) const MaxTabIndex = 10; procedure WMThreadMessage(var Msg: TMessage); message WM_USER_MESSAGE_FROM_THREAD; - procedure FillResultGrid(Results: TObjectStrings); + procedure FillResultGrid(ScrollBox: TExScrollBox; Results: TObjectStrings); procedure GridButtonClick(Sender: TObject); procedure SetCurrentNode(const Value: TTreeNode); - function GetResultPanel: TExScrollBox; + function GetCurrentPanel: TExScrollBox; protected property CurrentNode: TTreeNode read FCurrentNode write SetCurrentNode; - property ResultPanel: TExScrollBox read GetResultPanel; + property CurrentPanel: TExScrollBox read GetCurrentPanel; public procedure DoSql(const SqlText: string); procedure DoSqlIndex(const SqlText: string); @@ -307,7 +308,7 @@ procedure TlogForm.AfterSQLActionExecute(Sender: TObject); Obj := TSqlExecutorObject(TAction(Sender).Tag); if Obj.ErrMessage = '' then begin - FillResultGrid(Obj.Grids); + FillResultGrid(Obj.ScrollBox,Obj.Grids); SetItem(Obj.Description);// Show; end @@ -404,10 +405,24 @@ procedure TlogForm.DoConnect; end; procedure TlogForm.DoSql(const SqlText: string); + function GetNumberActivityIndicator: string; + var + j,k: integer; + begin + k := 0; + for j := 0 to Self.ComponentCount - 1 do + if Components[j] is TActivityIndicator then inc(k); + Result := IntToStr(k); + end; var SqlThread: TSqlExecutorObject; CString,CName: string; + FResultPanel: TExScrollBox; + i: integer; + ActivityIndicator: TActivityIndicator; begin + FResultPanel := CurrentPanel; + CString := BasesPanel.ConnectionString; CName := Format(cnstSqlExec,[ BasesPanel.CurrentServer, @@ -416,12 +431,26 @@ procedure TlogForm.DoSql(const SqlText: string); ]); if CString = '' then begin - CString := ResultPanel.ConnectionString; - CName := ResultPanel.Description; + CString := FResultPanel.ConnectionString; + CName := FResultPanel.Description; end; if CString <> '' then begin + FResultPanel.ClearComponents; + + ActivityIndicator := TActivityIndicator.Create(nil); + ActivityIndicator.Parent := FResultPanel; + ActivityIndicator.Name := 'Indicator' + GetNumberActivityIndicator; + ActivityIndicator.Left := 5; + ActivityIndicator.Top := 5; + ActivityIndicator.IndicatorSize := aisLarge; + ActivityIndicator.Visible := True; + ActivityIndicator.Animate := True; + FResultPanel.InsertComponent(ActivityIndicator); + FResultPanel.Hint := SqlText.Trim; + FResultPanel.ShowHint := True; + SqlThread := TSqlExecutorObject.Create; SqlThread.Description := SqlText.Trim; SqlThread.BdType := BasesPanel.BdType; @@ -430,6 +459,7 @@ procedure TlogForm.DoSql(const SqlText: string); SqlThread.ConnectionString := CString; SqlThread.OnAfterAction := AfterSQLAction; SqlThread.WinHandle := self.Handle; + SqlThread.ScrollBox := FResultPanel; SqlThread.Start; end else @@ -449,8 +479,8 @@ procedure TlogForm.DoSqlIndex(const SqlText: string); ]); if CString = '' then begin - CString := ResultPanel.ConnectionString; - CName := ResultPanel.Description; + CString := CurrentPanel.ConnectionString; + CName := CurrentPanel.Description; end; if CString <> '' then @@ -514,41 +544,42 @@ procedure TlogForm.FormDestroy(Sender: TObject); end; end; -procedure TlogForm.FillResultGrid(Results: TObjectStrings); +procedure TlogForm.FillResultGrid(ScrollBox: TExScrollBox; Results: TObjectStrings); var i,j,k,maxWidthGrid,aTop: integer; - Temp: TComponent; Grid: TStringGridEx; + FResultPanel: TExScrollBox; begin + FResultPanel := CurrentPanel; + for i := 0 to TabControl.Tabs.Count-2 do + if TExScrollBox(TabControl.Tabs.Objects[i]) = ScrollBox then + begin + FResultPanel := ScrollBox; + TabControl.TabIndex := i; + break; + end; + ResultLabel.Caption := Results.Name; maxWidthGrid := 0; Grid := nil; try - for i := ResultPanel.ControlCount - 1 downto 0 do - begin - Temp := ResultPanel.Controls[i]; - if (Temp is TStringGrid) or (Temp is TButton) then - begin - ResultPanel.RemoveComponent(Temp); - Temp.Free; - end; - end; - - ResultPanel.HorzScrollBar.Range := MaxInt; - ResultPanel.VertScrollBar.Range:= MaxInt; - ResultPanel.DisableAlign; - ResultPanel.Description := Results.Name; - ResultPanel.ConnectionString := Results.ConnectionString; - + FResultPanel.ClearComponents; + FResultPanel.Hint := ''; + FResultPanel.ShowHint := False; + FResultPanel.HorzScrollBar.Range := MaxInt; + FResultPanel.VertScrollBar.Range:= MaxInt; + FResultPanel.DisableAlign; + FResultPanel.Description := Results.Name; + FResultPanel.ConnectionString := Results.ConnectionString; Results.OwnsObjects := False; aTop := 0; for i := 0 to Results.Count - 1 do begin Grid := TStringGridEx(Results[i]); - Grid.Parent := ResultPanel; - ResultPanel.InsertComponent(Grid); + Grid.Parent := FResultPanel; + FResultPanel.InsertComponent(Grid); Grid.Align := alTop; //Grid.Color := clBlue; @@ -597,7 +628,7 @@ procedure TlogForm.FillResultGrid(Results: TObjectStrings); Grid.Height := k+18; - //Max(k,ResultPanel.Width); + //Max(k,CurrentPanel.Width); maxWidthGrid := Max(maxWidthGrid,Grid.Width); //Grid.Top := aTop; @@ -612,10 +643,10 @@ procedure TlogForm.FillResultGrid(Results: TObjectStrings); end; - ResultPanel.HorzScrollBar.Position := 0; - ResultPanel.HorzScrollBar.Range := maxWidthGrid; - ResultPanel.VertScrollBar.Position := 0; - ResultPanel.VertScrollBar.Range := aTop; + FResultPanel.HorzScrollBar.Position := 0; + FResultPanel.HorzScrollBar.Range := maxWidthGrid; + FResultPanel.VertScrollBar.Position := 0; + FResultPanel.VertScrollBar.Range := aTop; for k := Results.Count-1 downto 0 do begin @@ -626,13 +657,14 @@ procedure TlogForm.FillResultGrid(Results: TObjectStrings); if Assigned(Grid) and Grid.CanFocus then Grid.SetFocus; finally - ResultPanel.EnableAlign; - ResultPanel.ShowMe; - //ResultPanel.Perform(WM_SETREDRAW, 1, 0); + FResultPanel.EnableAlign; + HideAllExcept(TabControl.TabIndex); + + //FResultPanel.ShowMe; end; end; -function TlogForm.GetResultPanel: TExScrollBox; +function TlogForm.GetCurrentPanel: TExScrollBox; begin Result := TExScrollBox(TabControl.Tabs.Objects[TabControl.TabIndex]); end;