UPD: Remove counter of operations and queue combo box from operations viewer.

This commit is contained in:
cobines 2012-03-22 01:03:06 +00:00
commit 6b5699a4e0
3 changed files with 126 additions and 269 deletions

View file

@ -1,11 +1,12 @@
object frmViewOperations: TfrmViewOperations
Left = 12
Height = 232
Top = 118
Width = 561
Left = 18
Height = 229
Top = 117
Width = 458
ActiveControl = tvOperations
Caption = 'File operations'
ClientHeight = 232
ClientWidth = 561
ClientHeight = 229
ClientWidth = 458
FormStyle = fsStayOnTop
OnClose = FormClose
OnCreate = FormCreate
@ -14,166 +15,65 @@ object frmViewOperations: TfrmViewOperations
LCLVersion = '0.9.31'
object pnlHeader: TPanel
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = Owner
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
Left = 0
Height = 56
Height = 40
Top = 0
Width = 132
Width = 458
Anchors = [akTop, akLeft, akRight]
AutoSize = True
BevelOuter = bvNone
ClientHeight = 56
ClientWidth = 132
ChildSizing.HorizontalSpacing = 10
ChildSizing.EnlargeVertical = crsHomogenousChildResize
ChildSizing.ShrinkVertical = crsHomogenousChildResize
ChildSizing.Layout = cclTopToBottomThenLeftToRight
ClientHeight = 40
ClientWidth = 458
TabOrder = 0
object lblOperationsCount: TLabel
AnchorSideLeft.Control = pnlHeader
AnchorSideTop.Control = pnlHeader
Left = 8
Height = 22
Top = 4
Width = 120
BorderSpacing.Left = 4
BorderSpacing.Around = 4
Caption = 'Operations count:'
ParentColor = False
end
object lblActiveOperations: TLabel
AnchorSideLeft.Control = pnlHeader
AnchorSideTop.Control = lblOperationsCount
AnchorSideTop.Side = asrBottom
Left = 8
Height = 22
Top = 30
Width = 120
BorderSpacing.Left = 4
BorderSpacing.Around = 4
Caption = 'Active operations:'
ParentColor = False
end
end
object pnlCurrentOperation: TPanel
AnchorSideLeft.Control = tbPauseAll
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = pnlHeader
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = pnlHeader
AnchorSideBottom.Side = asrBottom
Left = 258
Height = 56
Top = 0
Width = 303
Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Left = 10
ClientHeight = 56
ClientWidth = 303
TabOrder = 2
object cbCurrentQueue: TComboBox
AnchorSideLeft.Control = pnlCurrentOperation
AnchorSideTop.Control = pnlCurrentOperation
AnchorSideTop.Side = asrCenter
Left = 7
Height = 29
Top = 14
Width = 140
BorderSpacing.Around = 6
ItemHeight = 21
Items.Strings = (
'Not in queue'
'Queue #1'
'Queue #2'
'Queue #3'
'Queue #4'
'Queue #5'
)
OnChange = cbCurrentQueueChange
Style = csDropDownList
object tbPauseAll: TToggleBox
Left = 0
Height = 40
Top = 0
Width = 100
AutoSize = True
BorderSpacing.Right = 50
Caption = '&Pause all'
Constraints.MinHeight = 40
Constraints.MinWidth = 100
OnChange = tbPauseAllChange
TabOrder = 0
end
object btnCancelCurOp: TBitBtn
AnchorSideLeft.Control = btnStartPause
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = pnlCurrentOperation
AnchorSideRight.Control = pnlCurrentOperation
object btnStop: TBitBtn
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = pnlCurrentOperation
AnchorSideBottom.Side = asrBottom
Left = 221
Height = 42
Top = 7
Width = 71
Anchors = [akTop, akLeft, akBottom]
Left = 150
Height = 40
Top = 0
Width = 80
AutoSize = True
BorderSpacing.Around = 6
Caption = 'Cancel'
Constraints.MinWidth = 60
Caption = 'S&top'
Constraints.MinWidth = 80
Enabled = False
NumGlyphs = 0
OnClick = btnCancelCurOpClick
TabOrder = 2
end
object btnStartPause: TBitBtn
AnchorSideLeft.Control = cbCurrentQueue
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = pnlCurrentOperation
AnchorSideBottom.Control = pnlCurrentOperation
AnchorSideBottom.Side = asrBottom
Left = 153
Height = 42
Top = 7
Width = 60
Anchors = [akTop, akLeft, akBottom]
AutoSize = True
BorderSpacing.Right = 2
BorderSpacing.Around = 6
Caption = 'Start'
Constraints.MinWidth = 60
NumGlyphs = 0
OnClick = btnStartPauseClick
OnClick = btnStopClick
TabOrder = 1
end
end
object lblOperationsCountNumber: TLabel
AnchorSideLeft.Control = pnlHeader
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = pnlHeader
Left = 132
Height = 22
Top = 5
Width = 10
BorderSpacing.Top = 5
Caption = '0'
ParentColor = False
end
object lblActiveOperationsNumber: TLabel
AnchorSideLeft.Control = pnlHeader
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = lblOperationsCountNumber
AnchorSideTop.Side = asrBottom
Left = 132
Height = 22
Top = 31
Width = 10
BorderSpacing.Top = 4
Caption = '0'
ParentColor = False
end
object tbPauseAll: TToggleBox
AnchorSideLeft.Control = lblActiveOperationsNumber
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = pnlHeader
AnchorSideBottom.Control = pnlHeader
AnchorSideBottom.Side = asrBottom
Left = 156
Height = 48
Top = 4
Width = 92
Anchors = [akTop, akLeft, akBottom]
AutoSize = True
BorderSpacing.Left = 10
BorderSpacing.Around = 4
Caption = 'Pause All'
OnChange = tbPauseAllChange
TabOrder = 1
object btnStartPause: TBitBtn
AnchorSideBottom.Side = asrBottom
Left = 240
Height = 40
Top = 0
Width = 80
AutoSize = True
Caption = '&Start'
Constraints.MinWidth = 80
Enabled = False
NumGlyphs = 0
OnClick = btnStartPauseClick
TabOrder = 2
end
end
object tvOperations: TTreeView
AnchorSideLeft.Control = Owner
@ -184,9 +84,9 @@ object frmViewOperations: TfrmViewOperations
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 0
Height = 176
Top = 56
Width = 561
Height = 189
Top = 40
Width = 458
Anchors = [akTop, akLeft, akRight, akBottom]
AutoExpand = True
DefaultItemHeight = 24
@ -199,7 +99,7 @@ object frmViewOperations: TfrmViewOperations
RowSelect = True
ScrollBars = ssAutoVertical
ShowLines = False
TabOrder = 3
TabOrder = 1
OnCustomDrawItem = tvOperationsCustomDrawItem
OnDeletion = tvOperationsDeletion
OnDragDrop = tvOperationsDragDrop
@ -258,7 +158,7 @@ object frmViewOperations: TfrmViewOperations
end
object mnuCancel: TMenuItem
Caption = 'Cancel'
OnClick = btnCancelCurOpClick
OnClick = btnStopClick
end
end
end

View file

@ -1,11 +1,7 @@
TFRMVIEWOPERATIONS.CAPTION=File operations
TFRMVIEWOPERATIONS.LBLOPERATIONSCOUNT.CAPTION=Operations count:
TFRMVIEWOPERATIONS.LBLACTIVEOPERATIONS.CAPTION=Active operations:
TFRMVIEWOPERATIONS.BTNCANCELCUROP.CAPTION=Cancel
TFRMVIEWOPERATIONS.BTNSTARTPAUSE.CAPTION=Start
TFRMVIEWOPERATIONS.LBLOPERATIONSCOUNTNUMBER.CAPTION=0
TFRMVIEWOPERATIONS.LBLACTIVEOPERATIONSNUMBER.CAPTION=0
TFRMVIEWOPERATIONS.TBPAUSEALL.CAPTION=Pause All
TFRMVIEWOPERATIONS.TBPAUSEALL.CAPTION=&Pause all
TFRMVIEWOPERATIONS.BTNSTOP.CAPTION=S&top
TFRMVIEWOPERATIONS.BTNSTARTPAUSE.CAPTION=&Start
TFRMVIEWOPERATIONS.MNUQUEUE.CAPTION=Queue
TFRMVIEWOPERATIONS.MNUQUEUE0.CAPTION=Out of queue
TFRMVIEWOPERATIONS.MNUQUEUE1.CAPTION=Queue 1

View file

@ -13,12 +13,14 @@ type
TViewBaseItem = class;
TViewBaseItemClick = procedure(Item: TViewBaseItem; Button: TMouseButton; Shift: TShiftState; const Pt: TPoint) of object;
TViewBaseItemSelected = procedure(Item: TViewBaseItem) of object;
{ TViewBaseItem }
TViewBaseItem = class
private
FOnClick: TViewBaseItemClick;
FOnSelected: TViewBaseItemSelected;
FTreeNode: TTreeNode;
procedure DrawThemedBackground(Canvas: TCanvas; Element: TThemedTreeview; ARect: TRect);
procedure DrawThemedText(Canvas: TCanvas; Element: TThemedTreeview; NodeRect: TRect; Center: Boolean; AText: String);
@ -29,8 +31,10 @@ type
procedure Draw(Canvas: TCanvas; NodeRect: TRect); virtual; abstract;
function GetBackgroundColor: TColor; virtual; abstract;
function GetHeight(Canvas: TCanvas): Integer; virtual; abstract;
procedure Selected; virtual;
property Height: Integer read GetHeight;
property OnClick: TViewBaseItemClick read FOnClick write FOnClick;
property OnSelected: TViewBaseItemSelected read FOnSelected write FOnSelected;
end;
{ TViewQueueItem }
@ -68,12 +72,8 @@ type
{ TfrmViewOperations }
TfrmViewOperations = class(TForm)
btnCancelCurOp: TBitBtn;
btnStop: TBitBtn;
btnStartPause: TBitBtn;
cbCurrentQueue: TComboBox;
lblActiveOperations: TLabel;
lblOperationsCountNumber: TLabel;
lblActiveOperationsNumber: TLabel;
mnuCancel: TMenuItem;
mnuPutFirstInQueue: TMenuItem;
mnuPutLastInQueue: TMenuItem;
@ -85,17 +85,13 @@ type
mnuQueue1: TMenuItem;
mnuQueue0: TMenuItem;
mnuQueue: TMenuItem;
lblOperationsCount: TLabel;
Cntr_running: TPanel;
pnlCurrentOperation: TPanel;
pnlHeader: TPanel;
pmOperationPopup: TPopupMenu;
tbPauseAll: TToggleBox;
tvOperations: TTreeView;
UpdateTimer: TTimer;
procedure btnCancelCurOpClick(Sender: TObject);
procedure cbCurrentQueueChange(Sender: TObject);
procedure btnStopClick(Sender: TObject);
procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
@ -103,6 +99,8 @@ type
procedure mnuPutLastInQueueClick(Sender: TObject);
procedure mnuShowDetachedClick(Sender: TObject);
procedure OnOperationItemClick(Item: TViewBaseItem; Button: TMouseButton; Shift: TShiftState; const Pt: TPoint);
procedure OnOperationItemSelected(Item: TViewBaseItem);
procedure OnQueueItemSelected(Item: TViewBaseItem);
procedure OnItemStatusIconClick(Item: TViewOperationItem);
procedure OnUpdateTimer(Sender: TObject);
procedure btnStartPauseClick(Sender: TObject);
@ -121,8 +119,6 @@ type
procedure SetFocusItem(AOperationHandle: TOperationHandle);
procedure SetNewQueue(Item: TViewOperationItem; NewQueue: TOperationsManagerQueueIdentifier);
procedure UpdateView(Item: TOperationsManagerItem; Event: TOperationManagerEvent);
procedure UpdateCounters;
procedure UpdateControls;
procedure UpdateItems;
end;
@ -228,6 +224,12 @@ begin
FOnClick(Self, Button, Shift, Pt);
end;
procedure TViewBaseItem.Selected;
begin
if Assigned(FOnSelected) then
FOnSelected(Self);
end;
{ TViewOperationItem }
constructor TViewOperationItem.Create(ANode: TTreeNode; AOperationHandle: TOperationHandle);
@ -375,8 +377,6 @@ begin
FMenuOperation := InvalidOperationHandle;
tvOperations.DoubleBuffered := True;
UpdateCounters;
UpdateControls;
UpdateItems;
OperationsManager.AddEventsListener(
@ -384,7 +384,7 @@ begin
@UpdateView);
end;
procedure TfrmViewOperations.btnCancelCurOpClick(Sender: TObject);
procedure TfrmViewOperations.btnStopClick(Sender: TObject);
var
OpManItem: TOperationsManagerItem;
Item: TViewBaseItem;
@ -398,22 +398,6 @@ begin
end;
end;
procedure TfrmViewOperations.cbCurrentQueueChange(Sender: TObject);
var
Item: TViewBaseItem;
NewQueue: TOperationsManagerQueueIdentifier;
begin
Item := GetFocusedItem;
if Assigned(Item) and (Item is TViewOperationItem) then
begin
if cbCurrentQueue.ItemIndex = 0 then
NewQueue := FreeOperationsQueueId
else
NewQueue := cbCurrentQueue.ItemIndex;
SetNewQueue(TViewOperationItem(Item), NewQueue);
end;
end;
procedure TfrmViewOperations.FormClose(Sender: TObject; var CloseAction: TCloseAction);
begin
CloseAction := caFree;
@ -464,30 +448,65 @@ procedure TfrmViewOperations.OnOperationItemClick(Item: TViewBaseItem; Button: T
var
OpManItem: TOperationsManagerItem;
PopupPoint: TPoint;
i: Integer;
begin
case Button of
mbLeft:
if ssDouble in Shift then
begin
OpManItem := OperationsManager.GetItemByHandle((Item as TViewOperationItem).FOperationHandle);
if Assigned(OpManItem) then
OpManItem := OperationsManager.GetItemByHandle((Item as TViewOperationItem).FOperationHandle);
if Assigned(OpManItem) then
begin
case Button of
mbLeft:
if ssDouble in Shift then
begin
if (OpManItem.Operation.State in [fsosStarting, fsosRunning, fsosWaitingForConnection]) then
if OpManItem.Operation.State in [fsosStarting, fsosRunning, fsosWaitingForConnection] then
OpManItem.Operation.Pause
else
OpManItem.Operation.Start;
OpManItem.PauseRunning := False;
end;
end;
mbRight:
begin
FMenuOperation := (Item as TViewOperationItem).FOperationHandle;
PopupPoint := tvOperations.ClientToScreen(Pt);
pmOperationPopup.PopUp(PopupPoint.x, PopupPoint.y);
end;
mbRight:
begin
for i := 0 to mnuQueue.Count - 1 do
if i = OpManItem.Queue.Identifier then
mnuQueue.Items[i].Checked:=True
else
mnuQueue.Items[i].Checked:=False;
FMenuOperation := (Item as TViewOperationItem).FOperationHandle;
PopupPoint := tvOperations.ClientToScreen(Pt);
pmOperationPopup.PopUp(PopupPoint.x, PopupPoint.y);
end;
end;
end;
end;
procedure TfrmViewOperations.OnOperationItemSelected(Item: TViewBaseItem);
var
OpManItem: TOperationsManagerItem;
begin
OpManItem := OperationsManager.GetItemByHandle(TViewOperationItem(Item).FOperationHandle);
if Assigned(OpManItem) then
begin
if OpManItem.Operation.State in [fsosStarting, fsosRunning, fsosWaitingForConnection] then
btnStartPause.Caption := rsDlgOpPause
else
btnStartPause.Caption := rsDlgOpStart;
btnStartPause.Enabled := True;
end
else
begin
btnStartPause.Enabled := False;
end;
btnStop.Enabled := btnStartPause.Enabled;
end;
procedure TfrmViewOperations.OnQueueItemSelected(Item: TViewBaseItem);
begin
// Pause/start queue not implemented yet.
btnStartPause.Enabled := False;
btnStop.Enabled := False;
end;
procedure TfrmViewOperations.OnItemStatusIconClick(Item: TViewOperationItem);
var
OpManItem: TOperationsManagerItem;
@ -505,6 +524,7 @@ end;
procedure TfrmViewOperations.OnUpdateTimer(Sender: TObject);
begin
tvOperationsSelectionChanged(tvOperations);
tvOperations.Invalidate;
end;
@ -685,8 +705,12 @@ begin
end;
procedure TfrmViewOperations.tvOperationsSelectionChanged(Sender: TObject);
var
Node: TTreeNode;
begin
UpdateControls;
Node := tvOperations.Selected;
if Assigned(Node) then
TViewBaseItem(Node.Data).Selected;
end;
function TfrmViewOperations.GetFocusedItem: TViewBaseItem;
@ -744,70 +768,6 @@ begin
end;
end;
procedure TfrmViewOperations.UpdateCounters;
var
ActiveOperationsCount: Integer = 0;
TotalOperationsCount: Integer = 0;
OpManItem: TOperationsManagerItem;
OperIndex, QueueIndex: Integer;
Queue: TOperationsManagerQueue;
begin
for QueueIndex := 0 to OperationsManager.QueuesCount - 1 do
begin
Queue := OperationsManager.QueueByIndex[QueueIndex];
for OperIndex := 0 to Queue.Count - 1 do
begin
OpManItem := Queue.Items[OperIndex];
if OpManItem.Operation.State in [fsosStarting, fsosRunning, fsosPausing, fsosStopping] then
Inc(ActiveOperationsCount);
Inc(TotalOperationsCount);
end;
end;
lblActiveOperationsNumber.Caption := IntToStr(ActiveOperationsCount);
lblOperationsCountNumber.Caption := IntToStr(TotalOperationsCount);
end;
procedure TfrmViewOperations.UpdateControls;
var
i: integer;
OpManItem: TOperationsManagerItem;
Item: TViewBaseItem;
begin
Item := GetFocusedItem;
if Assigned(Item) and (Item is TViewOperationItem) then
begin
OpManItem := OperationsManager.GetItemByHandle(TViewOperationItem(Item).FOperationHandle);
if Assigned(OpManItem) then
begin
for i := 0 to mnuQueue.Count - 1 do
if (i = OpManItem.Queue.Identifier) then
mnuQueue.Items[i].Checked:=True
else
mnuQueue.Items[i].Checked:=False;
if (OpManItem.Operation.State in [fsosStarting, fsosRunning, fsosWaitingForConnection]) then
btnStartPause.Caption := rsDlgOpPause
else
btnStartPause.Caption := rsDlgOpStart;
If (not cbCurrentQueue.DroppedDown) and (cbCurrentQueue.ItemIndex <> OpManItem.Queue.Identifier) Then
cbCurrentQueue.ItemIndex:=OpManItem.Queue.Identifier;
cbCurrentQueue.Enabled := True;
btnCancelCurOp.Enabled := True;
mnuShowDetached.Enabled := True;
end
else
begin
btnStartPause.Enabled := False;
btnCancelCurOp.Enabled := False;
cbCurrentQueue.ItemIndex := -1;
cbCurrentQueue.Enabled := False;
mnuShowDetached.Enabled := False;
end;
end;
end;
procedure TfrmViewOperations.UpdateItems;
procedure AddOperations(Queue: TOperationsManagerQueue; QueueNode: TTreeNode);
var
@ -825,6 +785,7 @@ procedure TfrmViewOperations.UpdateItems;
OperNode.Height := Item.GetHeight(tvOperations.Canvas);
TViewOperationItem(Item).OnStatusIconClick := @OnItemStatusIconClick;
Item.OnClick := @OnOperationItemClick;
Item.OnSelected := @OnOperationItemSelected;
end;
end;
var
@ -849,6 +810,7 @@ begin
Item := TViewQueueItem.Create(QueueNode, Queue.Identifier);
QueueNode.Data := Item;
QueueNode.Height := Item.GetHeight(tvOperations.Canvas);
Item.OnSelected := @OnQueueItemSelected;
AddOperations(Queue, QueueNode);
end;
end;
@ -856,7 +818,6 @@ end;
procedure TfrmViewOperations.UpdateView(Item: TOperationsManagerItem; Event: TOperationManagerEvent);
begin
UpdateCounters;
UpdateItems;
tvOperations.Invalidate;
end;