- Added selection of internal parameters in DCI configuration dialog
[public/netxms.git] / src / console / win32 / InternalItemSelDlg.cpp
CommitLineData
b6af0366
VK
1// InternalItemSelDlg.cpp : implementation file
2//
3
4#include "stdafx.h"
5#include "nxcon.h"
6#include "InternalItemSelDlg.h"
7#include "DataQueryDlg.h"
8
9#ifdef _DEBUG
10#define new DEBUG_NEW
11#undef THIS_FILE
12static char THIS_FILE[] = __FILE__;
13#endif
14
15
16//
17// Static data
18//
19
20static struct __item_info
21{
22 DWORD dwMatchFlags;
23 int iDataType;
24 TCHAR *pszName;
25 TCHAR *pszDescription;
26} m_itemList[] =
27{
28 { NF_IS_LOCAL_MGMT, DCI_DT_FLOAT, _T("Server.AverageConfigurationPollerQueueSize"), _T("Average length of configuration poller queue for last minute") },
29 { NF_IS_LOCAL_MGMT, DCI_DT_FLOAT, _T("Server.AverageDBWriterQueueSize"), _T("Average length of database writer's request queue for last minute") },
30 { NF_IS_LOCAL_MGMT, DCI_DT_UINT, _T("Server.AverageDCIQueuingTime"), _T("Average time to queue DCI for polling for last minute") },
31 { NF_IS_LOCAL_MGMT, DCI_DT_FLOAT, _T("Server.AverageDCPollerQueueSize"), _T("Average length of data collection poller's request queue for last minute") },
32 { NF_IS_LOCAL_MGMT, DCI_DT_FLOAT, _T("Server.AverageStatusPollerQueueSize"), _T("Average length of status poller queue for last minute") },
33 { 0, DCI_DT_INT, _T("Status"), _T("Status") },
34 { 0, 0, NULL, NULL }
35};
36
37
38/////////////////////////////////////////////////////////////////////////////
39// CInternalItemSelDlg dialog
40
41
42CInternalItemSelDlg::CInternalItemSelDlg(CWnd* pParent /*=NULL*/)
43 : CDialog(CInternalItemSelDlg::IDD, pParent)
44{
45 //{{AFX_DATA_INIT(CInternalItemSelDlg)
46 // NOTE: the ClassWizard will add member initialization here
47 //}}AFX_DATA_INIT
48}
49
50
51void CInternalItemSelDlg::DoDataExchange(CDataExchange* pDX)
52{
53 CDialog::DoDataExchange(pDX);
54 //{{AFX_DATA_MAP(CInternalItemSelDlg)
55 DDX_Control(pDX, IDC_LIST_PARAMETERS, m_wndListCtrl);
56 //}}AFX_DATA_MAP
57}
58
59
60BEGIN_MESSAGE_MAP(CInternalItemSelDlg, CDialog)
61 //{{AFX_MSG_MAP(CInternalItemSelDlg)
62 ON_BN_CLICKED(IDC_BUTTON_GET, OnButtonGet)
63 //}}AFX_MSG_MAP
64END_MESSAGE_MAP()
65
66/////////////////////////////////////////////////////////////////////////////
67// CInternalItemSelDlg message handlers
68
69BOOL CInternalItemSelDlg::OnInitDialog()
70{
71 DWORD i;
72 int iItem;
73 RECT rect;
74
75 CDialog::OnInitDialog();
76
77 m_wndListCtrl.SetExtendedStyle(LVS_EX_FULLROWSELECT | LVS_EX_UNDERLINEHOT);
78 m_wndListCtrl.SetHoverTime(0x7FFFFFFF);
79 m_wndListCtrl.GetClientRect(&rect);
80 m_wndListCtrl.InsertColumn(0, _T("Parameter name"), LVCFMT_LEFT, 220);
81 m_wndListCtrl.InsertColumn(1, _T("Type"), LVCFMT_LEFT, 80);
82 m_wndListCtrl.InsertColumn(2, _T("Description"), LVCFMT_LEFT,
83 rect.right - 300 - GetSystemMetrics(SM_CXVSCROLL));
84
85 for(i = 0; m_itemList[i].pszName != NULL; i++)
86 if ((m_pNode->node.dwFlags & m_itemList[i].dwMatchFlags) ||
87 (m_itemList[i].dwMatchFlags == 0))
88 {
89 iItem = m_wndListCtrl.InsertItem(0x7FFFFFFF, m_itemList[i].pszName);
90 if (iItem != -1)
91 {
92 m_wndListCtrl.SetItemData(iItem, i);
93 m_wndListCtrl.SetItemText(iItem, 1, g_pszItemDataType[m_itemList[i].iDataType]);
94 m_wndListCtrl.SetItemText(iItem, 2, m_itemList[i].pszDescription);
95 }
96 }
97
98 return TRUE;
99}
100
101
102//
103// Handler for OK button
104//
105
106void CInternalItemSelDlg::OnOK()
107{
108 if (m_wndListCtrl.GetSelectedCount() == 0)
109 {
110 MessageBox(_T("You must select parameter from the list before pressing OK!"),
111 _T("Warning"), MB_OK | MB_ICONEXCLAMATION);
112 }
113 else
114 {
115 DWORD dwIndex;
116
117 dwIndex = m_wndListCtrl.GetItemData(m_wndListCtrl.GetSelectionMark());
118 _tcsncpy(m_szItemName, m_itemList[dwIndex].pszName, MAX_DB_STRING);
119 _tcsncpy(m_szItemDescription, m_itemList[dwIndex].pszDescription, MAX_DB_STRING);
120 m_iDataType = m_itemList[dwIndex].iDataType;
121 CDialog::OnOK();
122 }
123}
124
125
126//
127// Handler for "Get..." button
128//
129
130void CInternalItemSelDlg::OnButtonGet()
131{
132 if (m_wndListCtrl.GetSelectedCount() != 0)
133 {
134 CDataQueryDlg dlg;
135 DWORD dwIndex;
136
137 dwIndex = m_wndListCtrl.GetItemData(m_wndListCtrl.GetSelectionMark());
138 dlg.m_dwObjectId = m_pNode->dwId;
139 dlg.m_strNode = (LPCTSTR)m_pNode->szName;
140 dlg.m_strParameter = (LPCTSTR)m_itemList[dwIndex].pszName;
141 dlg.m_iOrigin = DS_INTERNAL;
142 dlg.DoModal();
143 }
144}