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