Skip to content

Commit

Permalink
Небольшие изменения
Browse files Browse the repository at this point in the history
Запрос теперь исполняется в конкретную вкладку.
Во время ожидания исполнения результатов запроса на вкладке крутится анимация
  • Loading branch information
vladk1973 committed Dec 19, 2018
1 parent 8929cc9 commit 8cbbf11
Show file tree
Hide file tree
Showing 4 changed files with 96 additions and 42 deletions.
12 changes: 12 additions & 0 deletions PrFormUnit.pas
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
7 changes: 5 additions & 2 deletions SqlThreadUnit.pas
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
13 changes: 10 additions & 3 deletions logFormUnit.dfm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -170,9 +177,9 @@ inherited logForm: TlogForm
end
object Images: TImageList
Left = 208
Top = 64
Top = 112
Bitmap = {
494C010116009000600110001000FFFFFFFFFF10FFFFFFFFFFFFFFFF424D3600
494C010116009000680110001000FFFFFFFFFF10FFFFFFFFFFFFFFFF424D3600
0000000000003600000028000000400000006000000001002000000000000060
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
Expand Down Expand Up @@ -1178,7 +1185,7 @@ inherited logForm: TlogForm
Left = 32
Top = 552
Bitmap = {
494C010106001D00400010001000FFFFFFFFFF10FFFFFFFFFFFFFFFF424D3600
494C010106001D00480010001000FFFFFFFFFF10FFFFFFFFFFFFFFFF424D3600
0000000000003600000028000000400000002000000001002000000000000020
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
Expand Down
106 changes: 69 additions & 37 deletions logFormUnit.pas
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand All @@ -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;
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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
Expand All @@ -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;
Expand Down

0 comments on commit 8cbbf11

Please sign in to comment.