Implemented deletion of predefined graphs
authorVictor Kirhenshtein <victor@netxms.org>
Tue, 13 Feb 2007 21:47:18 +0000 (21:47 +0000)
committerVictor Kirhenshtein <victor@netxms.org>
Tue, 13 Feb 2007 21:47:18 +0000 (21:47 +0000)
.gitattributes
src/console/win32/GraphManagerDlg.cpp [new file with mode: 0644]
src/console/win32/GraphManagerDlg.h [new file with mode: 0644]
src/console/win32/Makefile.am
src/console/win32/nxcon.clw
src/console/win32/nxcon.cpp
src/console/win32/nxcon.dsp
src/console/win32/nxcon.h
src/console/win32/nxcon.rc
src/console/win32/resource.h
src/console/win32/tools.cpp

index 01d2ca5..3e94296 100644 (file)
@@ -751,6 +751,8 @@ src/console/win32/GraphDataPage.cpp -text
 src/console/win32/GraphDataPage.h -text
 src/console/win32/GraphFrame.cpp -text
 src/console/win32/GraphFrame.h -text
+src/console/win32/GraphManagerDlg.cpp -text
+src/console/win32/GraphManagerDlg.h -text
 src/console/win32/GraphSettingsPage.cpp -text
 src/console/win32/GraphSettingsPage.h -text
 src/console/win32/GroupPropDlg.cpp -text
diff --git a/src/console/win32/GraphManagerDlg.cpp b/src/console/win32/GraphManagerDlg.cpp
new file mode 100644 (file)
index 0000000..ec958cc
--- /dev/null
@@ -0,0 +1,265 @@
+// GraphManagerDlg.cpp : implementation file
+//
+
+#include "stdafx.h"
+#include "nxcon.h"
+#include "GraphManagerDlg.h"
+
+#ifdef _DEBUG
+#define new DEBUG_NEW
+#undef THIS_FILE
+static char THIS_FILE[] = __FILE__;
+#endif
+
+/////////////////////////////////////////////////////////////////////////////
+// CGraphManagerDlg dialog
+
+
+CGraphManagerDlg::CGraphManagerDlg(CWnd* pParent /*=NULL*/)
+       : CDialog(CGraphManagerDlg::IDD, pParent)
+{
+       //{{AFX_DATA_INIT(CGraphManagerDlg)
+               // NOTE: the ClassWizard will add member initialization here
+       //}}AFX_DATA_INIT
+}
+
+
+void CGraphManagerDlg::DoDataExchange(CDataExchange* pDX)
+{
+       CDialog::DoDataExchange(pDX);
+       //{{AFX_DATA_MAP(CGraphManagerDlg)
+       DDX_Control(pDX, IDC_TREE_GRAPHS, m_wndTreeCtrl);
+       //}}AFX_DATA_MAP
+}
+
+
+BEGIN_MESSAGE_MAP(CGraphManagerDlg, CDialog)
+       //{{AFX_MSG_MAP(CGraphManagerDlg)
+       ON_NOTIFY(TVN_ITEMEXPANDED, IDC_TREE_GRAPHS, OnItemexpandedTreeGraphs)
+       ON_WM_CONTEXTMENU()
+       ON_BN_CLICKED(IDC_BUTTON_DELETE, OnButtonDelete)
+       //}}AFX_MSG_MAP
+END_MESSAGE_MAP()
+
+/////////////////////////////////////////////////////////////////////////////
+// CGraphManagerDlg message handlers
+
+
+//
+// WM_INITDIALOG message handler
+//
+
+BOOL CGraphManagerDlg::OnInitDialog() 
+{
+       DWORD dwTemp;
+
+       CDialog::OnInitDialog();
+       
+       m_imageList.Create(16, 16, ILC_COLOR24 | ILC_MASK, 3, 1);
+       m_imageList.Add(theApp.LoadIcon(IDI_GRAPH));
+       m_imageList.Add(theApp.LoadIcon(IDI_CLOSED_FOLDER));
+       m_imageList.Add(theApp.LoadIcon(IDI_OPEN_FOLDER));
+       m_wndTreeCtrl.SetImageList(&m_imageList, TVSIL_NORMAL);
+
+       dwTemp = 0;
+       CreateGraphTree(TVI_ROOT, _T(""), &dwTemp);
+       
+       return TRUE;
+}
+
+
+//
+// Create one level of graphs tree
+//
+
+void CGraphManagerDlg::CreateGraphTree(HTREEITEM hRoot, TCHAR *pszCurrPath, DWORD *pdwStart)
+{
+       DWORD i, j;
+   TCHAR szName[MAX_DB_STRING], szPath[MAX_DB_STRING];
+
+       for(i = *pdwStart; i < g_dwNumGraphs; i++)
+       {
+      // Separate item name and path
+      memset(szPath, 0, sizeof(TCHAR) * MAX_DB_STRING);
+      if (_tcsstr(g_pGraphList[i].pszName, _T("->")) != NULL)
+      {
+         for(j = _tcslen(g_pGraphList[i].pszName) - 1; j > 0; j--)
+            if ((g_pGraphList[i].pszName[j] == _T('>')) &&
+                (g_pGraphList[i].pszName[j - 1] == _T('-')))
+            {
+               _tcscpy(szName, &g_pGraphList[i].pszName[j + 1]);
+               j--;
+               break;
+            }
+         memcpy(szPath, g_pGraphList[i].pszName, j * sizeof(TCHAR));
+      }
+      else
+      {
+         _tcscpy(szName, g_pGraphList[i].pszName);
+      }
+
+               // Add menu item if we are on right level, otherwise create subtree or go one level up
+      if (!_tcsicmp(szPath, pszCurrPath))
+      {
+                       HTREEITEM hItem;
+
+         StrStrip(szName);
+                       hItem = m_wndTreeCtrl.InsertItem(szName, 0, 0, hRoot);
+                       m_wndTreeCtrl.SetItemData(hItem, g_pGraphList[i].dwId);
+      }
+      else
+      {
+         for(j = _tcslen(pszCurrPath); (szPath[j] == _T(' ')) || (szPath[j] == _T('\t')); j++);
+         if ((*pszCurrPath == 0) ||
+             ((!memicmp(szPath, pszCurrPath, _tcslen(pszCurrPath) * sizeof(TCHAR))) &&
+              (szPath[j] == _T('-')) && (szPath[j + 1] == _T('>'))))
+         {
+            HTREEITEM hSubTree;
+            TCHAR *pszName;
+
+            // Subtree of current tree
+            if (*pszCurrPath != 0)
+               j += 2;
+            pszName = &szPath[j];
+            for(; (szPath[j] != 0) && (memcmp(&szPath[j], _T("->"), sizeof(TCHAR) * 2)); j++);
+            szPath[j] = 0;
+            StrStrip(pszName);
+                               hSubTree = m_wndTreeCtrl.InsertItem(pszName, 1, 1, hRoot);
+                               m_wndTreeCtrl.SetItemData(hSubTree, 0);
+                               CreateGraphTree(hSubTree, szPath, &i);
+         }
+         else
+         {
+            i--;
+            break;
+         }
+               }
+       }
+   *pdwStart = i;
+}
+
+
+//
+// Handler for tree item expand/collapse
+//
+
+void CGraphManagerDlg::OnItemexpandedTreeGraphs(NMHDR* pNMHDR, LRESULT* pResult) 
+{
+       NMTREEVIEW* pNMTreeView = (NMTREEVIEW *)pNMHDR;
+
+       if (pNMTreeView->action == TVE_COLLAPSE)
+       {
+               m_wndTreeCtrl.SetItemImage(pNMTreeView->itemNew.hItem, 1, 1);
+       }
+       else if (pNMTreeView->action == TVE_EXPAND)
+       {
+               m_wndTreeCtrl.SetItemImage(pNMTreeView->itemNew.hItem, 2, 2);
+       }
+       *pResult = 0;
+}
+
+
+//
+// WM_CONTEXTMENU message handler
+//
+
+void CGraphManagerDlg::OnContextMenu(CWnd* pWnd, CPoint point) 
+{
+   CPoint pt;
+   HTREEITEM hItem;
+   UINT uFlags;
+       RECT rect;
+       CMenu *pMenu;
+
+       if (pWnd->GetDlgCtrlID() != IDC_TREE_GRAPHS)
+               return;
+
+       if (point.x >= 0)
+       {
+               pt = point;
+               pWnd->ScreenToClient(&pt);
+               hItem = m_wndTreeCtrl.HitTest(pt, &uFlags);
+               pt = point;
+       }
+       else
+       {
+               hItem = m_wndTreeCtrl.GetSelectedItem();
+               if (hItem != NULL)
+               {
+                       m_wndTreeCtrl.GetItemRect(hItem, &rect, TRUE);
+                       pt.x = rect.left;
+                       pt.y = rect.bottom;
+                       m_wndTreeCtrl.ClientToScreen(&pt);
+               }
+       }
+   if ((hItem != NULL) && ((uFlags & TVHT_ONITEM) || (point.x < 0)))
+   {
+      m_wndTreeCtrl.Select(hItem, TVGN_CARET);
+      pMenu = theApp.GetContextMenu(23);
+      pMenu->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, pt.x, pt.y, this, NULL);
+       }
+}
+
+
+//
+// Delete button handler
+//
+
+void CGraphManagerDlg::OnButtonDelete() 
+{
+       HTREEITEM hItem, hParent;
+
+       hItem = m_wndTreeCtrl.GetSelectedItem();
+       if (hItem == NULL)
+               return;
+
+       hParent = m_wndTreeCtrl.GetParentItem(hItem);
+       if (DeleteGraph(hItem))
+       {
+               while((hParent != NULL) && (m_wndTreeCtrl.GetChildItem(hParent) == NULL))
+               {
+                       hItem = hParent;
+                       hParent = m_wndTreeCtrl.GetParentItem(hItem);
+                       m_wndTreeCtrl.DeleteItem(hItem);
+               }
+       }
+}
+
+
+//
+// Delete graph or subtree of graphs
+//
+
+BOOL CGraphManagerDlg::DeleteGraph(HTREEITEM hItem)
+{
+       DWORD dwGraphId, dwResult;
+       HTREEITEM hChild;
+       BOOL bRet = TRUE;
+
+       dwGraphId = m_wndTreeCtrl.GetItemData(hItem);
+       if (dwGraphId == 0)     // Folder
+       {
+               while(((hChild = m_wndTreeCtrl.GetChildItem(hItem)) != NULL) && bRet)
+               {
+                       bRet = DeleteGraph(hChild);
+               }
+               if (bRet)
+               {
+                       m_wndTreeCtrl.DeleteItem(hItem);
+               }
+       }
+       else    // Leaf item
+       {
+               dwResult = DoRequestArg2(NXCDeleteGraph, g_hSession, (void *)dwGraphId, _T("Deleting graph..."));
+               if (dwResult == RCC_SUCCESS)
+               {
+                       m_wndTreeCtrl.DeleteItem(hItem);
+               }
+               else
+               {
+                       theApp.ErrorBox(dwResult, _T("Cannot delete predefined graph: %s"));
+                       bRet = FALSE;
+               }
+       }
+       return bRet;
+}
diff --git a/src/console/win32/GraphManagerDlg.h b/src/console/win32/GraphManagerDlg.h
new file mode 100644 (file)
index 0000000..c626e5e
--- /dev/null
@@ -0,0 +1,52 @@
+#if !defined(AFX_GRAPHMANAGERDLG_H__027BBA60_60D2_41CC_8E30_ACD183114302__INCLUDED_)
+#define AFX_GRAPHMANAGERDLG_H__027BBA60_60D2_41CC_8E30_ACD183114302__INCLUDED_
+
+#if _MSC_VER > 1000
+#pragma once
+#endif // _MSC_VER > 1000
+// GraphManagerDlg.h : header file
+//
+
+/////////////////////////////////////////////////////////////////////////////
+// CGraphManagerDlg dialog
+
+class CGraphManagerDlg : public CDialog
+{
+// Construction
+public:
+       CGraphManagerDlg(CWnd* pParent = NULL);   // standard constructor
+
+// Dialog Data
+       //{{AFX_DATA(CGraphManagerDlg)
+       enum { IDD = IDD_MANAGE_GRAPHS };
+       CTreeCtrl       m_wndTreeCtrl;
+       //}}AFX_DATA
+
+
+// Overrides
+       // ClassWizard generated virtual function overrides
+       //{{AFX_VIRTUAL(CGraphManagerDlg)
+       protected:
+       virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
+       //}}AFX_VIRTUAL
+
+// Implementation
+protected:
+       BOOL DeleteGraph(HTREEITEM hItem);
+       void CreateGraphTree(HTREEITEM hRoot, TCHAR *pszCurrPath, DWORD *pdwStart);
+       CImageList m_imageList;
+
+       // Generated message map functions
+       //{{AFX_MSG(CGraphManagerDlg)
+       virtual BOOL OnInitDialog();
+       afx_msg void OnItemexpandedTreeGraphs(NMHDR* pNMHDR, LRESULT* pResult);
+       afx_msg void OnContextMenu(CWnd* pWnd, CPoint point);
+       afx_msg void OnButtonDelete();
+       //}}AFX_MSG
+       DECLARE_MESSAGE_MAP()
+};
+
+//{{AFX_INSERT_LOCATION}}
+// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
+
+#endif // !defined(AFX_GRAPHMANAGERDLG_H__027BBA60_60D2_41CC_8E30_ACD183114302__INCLUDED_)
index f39674a..d1fc3dc 100644 (file)
@@ -76,6 +76,7 @@ EXTRA_DIST = \
        Graph.cpp Graph.h \
        GraphFrame.cpp GraphFrame.h \
        GraphDataPage.cpp GraphDataPage.h \
+       GraphManagerDlg.cpp GraphManagerDlg.h \
        GraphSettingsPage.cpp GraphSettingsPage.h \
        LastValuesView.cpp LastValuesView.h \
        LPPList.cpp LPPList.h \
index f72a813..786c66b 100644 (file)
@@ -2,35 +2,35 @@
 
 [General Info]
 Version=1
-LastClass=CDefineGraphDlg
+LastClass=CGraphManagerDlg
 LastTemplate=CDialog
 NewFileInclude1=#include "stdafx.h"
 NewFileInclude2=#include "nxcon.h"
 LastPage=0
 
-ClassCount=153
+ClassCount=154
 Class1=CConsoleApp
 Class3=CMainFrame
 Class4=CChildFrame
 Class7=CEventBrowser
 Class9=CMapView
 
-ResourceCount=195
+ResourceCount=196
 Resource1=IDD_CP_GENERAL (English (U.S.))
-Resource2=IDD_SELECT_INTERNAL_ITEM
+Resource2=IDA_OBJECT_BROWSER
 Resource3=IDD_DCI_DATA_EXPORT (English (U.S.))
-Resource4=IDA_TRAP_EDITOR
-Resource5=IDD_LASTVAL_PROP
+Resource4=IDM_CONTEXT
+Resource5=IDA_SERVER_CFG_EDITOR
 Class2=CChildView
 Class5=CAboutDlg
 Class6=CControlPanel
 Class8=CMapFrame
 Class10=CLoginDialog
-Resource6=IDD_OBJECT_NETSRV_GENERAL
+Resource6=IDA_EVENT_EDITOR
 Class11=CProgressDialog
-Resource7=IDD_DCI_COLLECTION
+Resource7=IDD_OBJECT_COND_SCRIPT
 Class12=CAddrEntryDlg
-Resource8=IDD_EDIT_TRAP_ARG
+Resource8=IDA_MDI_DEFAULT
 Class13=CObjectPropDlg
 Resource9=IDD_THRESHOLD (English (U.S.))
 Resource10=IDD_SELECT_OBJECT (English (U.S.))
@@ -46,45 +46,45 @@ Resource17=IDD_NEW_USER (English (U.S.))
 Class16=CDebugFrame
 Resource18=IDD_NEW_ACTION (English (U.S.))
 Resource19=IDD_OBJECT_PROPERTIES (English (U.S.))
-Resource20=IDD_EDIT_RULE_SEVERITY
+Resource20=IDD_DISCOVERY_RANGES
 Class17=CObjectPreview
 Resource21=IDA_OBJECT_BROWSER (English (U.S.))
 Class18=CToolBox
 Class19=CObjectInfoBox
 Class20=CObjectSearchBox
-Resource22=IDD_COND_DCI_PROP
+Resource22=IDD_MIB_BROWSER
 Class21=CEditBox
 Class22=COPGeneral
 Class23=CNodePropsGeneral
 Resource23=IDD_GRAPH_PROPERTIES (English (U.S.))
 Class24=CObjectPropCaps
 Class25=CObjectPropSheet
-Resource24=IDD_SELECT_MP
+Resource24=IDD_NEW_ACTION
 Class26=CRequestProcessingDlg
 Resource25=IDD_SELECT_USER (English (U.S.))
 Resource26=IDD_PROGRESS (English (U.S.))
-Resource27=IDD_ADD_DCI
+Resource27=IDD_THRESHOLD
 Resource28=IDD_DCI_COLLECTION (English (U.S.))
 Class27=CObjectPropsGeneral
 Resource29=IDR_MAINFRAME (English (U.S.))
 Class28=CObjectPropsSecurity
 Resource30=IDD_SAVE_AGENT_CFG (English (U.S.))
-Resource31=IDA_ALARM_BROWSER
-Resource32=IDD_OBJECT_SECURITY
+Resource31=IDD_INPUT_BOX
+Resource32=IDD_OBJTOOL_COLUMNS
 Class29=CUserSelectDlg
-Resource33=IDA_DATA_VIEW
+Resource33=IDD_EDIT_IP_SUBNET
 Class30=CUserEditor
 Resource34=IDD_DCI_PROPERTIES
 Class31=CNewUserDlg
-Resource35=IDD_OBJECT_RELATIONS
-Resource36=IDD_OBJECT_COND_SCRIPT
+Resource35=IDA_TRAP_EDITOR
+Resource36=IDD_DCI_COLLECTION
 Class32=CUserPropDlg
 Resource37=IDD_EDIT_VARIABLE (English (U.S.))
-Resource38=IDD_CREATE_NETSRV
+Resource38=IDA_NETMAP
 Class33=CGroupPropDlg
-Resource39=IDD_UPGRADE
-Resource40=IDA_OBJECT_TOOLS_EDITOR
-Resource41=IDA_AGENT_CFG_EDITOR
+Resource39=IDD_SELECT_ACTION
+Resource40=IDD_CREATE_VPNC
+Resource41=IDD_DCI_DATA_EXPORT
 Resource42=IDA_ACTION_EDITOR (English (U.S.))
 Class34=CPasswordChangeDlg
 Class35=CNodeSummary
@@ -100,55 +100,55 @@ Class41=CGraphFrame
 Class42=CDCIThresholdsPage
 Resource46=IDA_OBJECT_TOOLS_EDITOR (English (U.S.))
 Resource47=IDM_CONTEXT (English (U.S.))
-Resource48=IDD_EDIT_IP_SUBNET
+Resource48=IDA_DATA_VIEW
 Class43=CThresholdDlg
 Resource49=IDD_DESKTOP_SAVE_AS (English (U.S.))
-Resource50=IDD_SELECT_USER
+Resource50=IDD_SNMP_WALK
 Class44=CMIBBrowserDlg
 Class45=CEventPolicyEditor
 Class46=CRuleList
 Class47=CRuleHeader
 Resource51=IDD_SELECT_AGENT_PARAM (English (U.S.))
-Resource52=IDD_DESKTOP_SAVE_AS
+Resource52=IDA_GRAPH
 Class48=CObjectSelDlg
-Resource53=IDD_SAVE_AGENT_CFG
-Resource54=IDD_EDIT_RULE_ALARM
+Resource53=IDA_AGENT_CONFIG_MANAGER
+Resource54=IDD_ADDR_ENTRY
 Class49=CRuleCommentDlg
-Resource55=IDA_MDI_DEFAULT
+Resource55=IDD_EDIT_TRAP_ARG
 Class50=CEventSelDlg
-Resource56=IDD_SELECT_ACTION
+Resource56=IDD_UPGRADE
 Resource57=IDA_EPP (English (U.S.))
-Resource58=IDD_CLUSTER_RESOURCE
+Resource58=IDD_CREATE_TG
 Resource59=IDA_PACKAGE_MGR (English (U.S.))
 Resource60=IDD_OBJTOOL_GENERAL (English (U.S.))
 Class51=CObjectPropsPresentation
 Resource61=IDD_CREATE_TEMPLATE (English (U.S.))
-Resource62=IDA_LAST_VALUES
+Resource62=IDD_GRAPH_PROP_DATA
 Class52=CRuleSeverityDlg
-Resource63=IDD_CREATE_MP
+Resource63=IDD_CP_GENERAL
 Class53=CRuleAlarmDlg
 Class54=CAlarmBrowser
 Resource64=IDA_MDI_DEFAULT (English (U.S.))
-Resource65=IDA_OBJECT_COMMENTS
+Resource65=IDD_DCI_SCHEDULE
 Resource66=IDD_EDIT_IP_SUBNET (English (U.S.))
 Resource67=IDD_EDIT_RULE_SEVERITY (English (U.S.))
 Resource68=IDD_ACTION_PROPERTIES (English (U.S.))
 Class55=CConsolePropsGeneral
 Class56=CActionEditor
-Resource69=IDA_SCRIPT_MANAGER
-Resource70=IDD_DATA_QUERY
+Resource69=IDD_OBJECT_VPNC_GENERAL
+Resource70=IDD_DEFINE_GRAPH
 Class57=CNewActionDlg
-Resource71=IDD_CHANGE_PASSWORD
+Resource71=IDD_USER_PROPERTIES
 Class58=CEditActionDlg
-Resource72=IDD_ACTION_PROPERTIES
+Resource72=IDD_SELECT_TRAP
 Class59=CActionSelDlg
-Resource73=IDD_OBJECT_COND_DATA
+Resource73=IDD_DCI_THRESHOLDS
 Resource74=IDD_EDIT_TRAP (English (U.S.))
 Resource75=IDD_USER_PROPERTIES (English (U.S.))
-Resource76=IDD_ABOUTBOX
+Resource76=IDD_OBJECT_STATUS
 Class60=CCreateObjectDlg
 Class61=CCreateContainerDlg
-Resource77=IDD_OBJTOOL_GENERAL
+Resource77=IDD_EDIT_EVENT
 Class62=CCreateNodeDlg
 Resource78=IDD_OBJECT_NODE_GENERAL (English (U.S.))
 Resource79=IDT_MAP (English (U.S.))
@@ -158,31 +158,31 @@ Resource81=IDD_LASTVAL_PROP (English (U.S.))
 Class64=CPollNodeDlg
 Resource82=IDD_POLL_NODE (English (U.S.))
 Class65=CNodePoller
-Resource83=IDD_ADDR_ENTRY
-Resource84=IDD_INPUT_BOX
+Resource83=IDD_EDIT_RULE_ALARM
+Resource84=IDA_ALARM_BROWSER
 Class66=CCreateTemplateDlg
 Class67=CCreateTGDlg
-Resource85=IDD_SET_PASSWORD
-Resource86=IDR_MAINFRAME
+Resource85=IDD_OBJECT_COND_GENERAL
+Resource86=IDD_EDIT_TRAP
 Class68=CTrapEditor
-Resource87=IDD_OBJECT_NODE_GENERAL
-Resource88=IDD_CREATE_TG
-Resource89=IDD_CP_GENERAL
+Resource87=IDD_NEW_OBJECT_TOOL
+Resource88=IDD_CLUSTER_RESOURCE
+Resource89=IDD_CREATE_MP
 Class69=CDataQueryDlg
-Resource90=IDD_NEW_ACTION
+Resource90=IDD_SELECT_MP
 Class70=CTrapEditDlg
 Resource91=IDM_VIEW_SPECIFIC (English (U.S.))
 Class71=CTrapParamDlg
-Resource92=IDD_REQUEST_PROCESSING
-Resource93=IDD_THRESHOLD
+Resource92=IDD_CHANGE_IP
+Resource93=IDD_ADD_DCI
 Class72=CGraphPropDlg
 Class73=CColorSelector
 Class74=CPackageMgr
-Resource94=IDA_ACTION_EDITOR
+Resource94=IDD_OBJECT_NODE_POLL
 Resource95=IDA_SCRIPT_MANAGER (English (U.S.))
 Resource96=IDD_SET_PASSWORD (English (U.S.))
 Resource97=IDD_DCI_TRANSFORM (English (U.S.))
-Resource98=IDD_OBJECT_NODE_POLL
+Resource98=IDA_ACTION_EDITOR
 Resource99=IDD_OBJECT_NETSRV_GENERAL (English (U.S.))
 Resource100=IDD_OBJTOOL_OPTIONS (English (U.S.))
 Resource101=IDA_LAST_VALUES (English (U.S.))
@@ -244,7 +244,7 @@ Class102=CWaitView
 Class103=CWebBrowser
 Class104=CSyslogBrowser
 Class105=CLPPList
-Resource129=IDD_OBJECT_CAPS
+Resource129=IDD_OBJTOOL_OPTIONS
 Class106=CDCISchedulePage
 Resource130=IDD_OBJECT_CAPS (English (U.S.))
 Class107=CObjectPropsStatus
@@ -270,95 +270,97 @@ Class119=CMapControlBox
 Resource138=IDD_OBJECT_GENERAL (English (U.S.))
 Class120=CSubmapBkgndDlg
 Resource139=IDD_SUBMAP_BKGND (English (U.S.))
-Resource140=IDD_DISCOVERY_GENERAL
-Resource141=IDA_OBJECT_BROWSER
-Resource142=IDD_CREATE_VPNC
-Resource143=IDD_EDIT_EVENT
-Resource144=IDD_OBJECT_GENERAL
-Resource145=IDD_CREATE_CONDITION
-Resource146=IDD_EDIT_RULE_COMMENT
-Resource147=IDD_OBJECT_COND_GENERAL
-Resource148=IDD_DCI_THRESHOLDS
-Resource149=IDD_OBJECT_CLUSTER_GENERAL
-Resource150=IDM_CONTEXT
-Resource151=IDD_DISCOVERY_TARGETS
-Resource152=IDD_SELECT_AGENT_PARAM
-Resource153=IDD_DCI_SCHEDULE
-Resource154=IDD_SELECT_EVENT
-Resource155=IDD_NEW_USER
-Resource156=IDD_SNMP_WALK
-Resource157=IDA_DC_EDITOR
-Resource158=IDA_EVENT_EDITOR
-Resource159=IDD_OBJECT_STATUS
-Resource160=IDD_EDIT_VARIABLE
-Resource161=IDD_OBJECT_CLUSTER_RESOURCES
-Resource162=IDA_AGENT_CONFIG_MANAGER
-Resource163=IDD_CREATE_CONTAINER
-Resource164=IDD_DISCOVERY_RANGES
-Resource165=IDA_PACKAGE_MGR
-Resource166=IDD_CREATE_TEMPLATE
-Resource167=IDD_CREATE_NODE
-Resource168=IDA_EPP
-Resource169=IDD_REMOVE_TEMPLATE
-Resource170=IDD_GROUP_PROPERTIES
-Resource171=IDD_OBJECT_VPNC_GENERAL
+Resource140=IDD_SELECT_EVENT
+Resource141=IDD_SELECT_INTERNAL_ITEM
+Resource142=IDA_OBJECT_TOOLS_EDITOR
+Resource143=IDD_OBJTOOL_GENERAL
+Resource144=IDD_REMOVE_TEMPLATE
+Resource145=IDD_GROUP_PROPERTIES
+Resource146=IDD_EDIT_RULE_SCRIPT
+Resource147=IDD_SET_PASSWORD
+Resource148=IDD_OBJECT_COND_DATA
+Resource149=IDD_CREATE_NODE
+Resource150=IDD_OBJECT_RELATIONS
+Resource151=IDD_OBJECT_PRESENTATION
+Resource152=IDA_EPP
+Resource153=IDA_OBJECT_COMMENTS
+Resource154=IDD_DISCOVERY_GENERAL
+Resource155=IDD_SUBMAP_BKGND
+Resource156=IDD_SELECT_USER
+Resource157=IDD_EDIT_VARIABLE
+Resource158=IDD_OBJECT_NETSRV_GENERAL
+Resource159=IDD_ABOUTBOX
+Resource160=IDA_DC_EDITOR
+Resource161=IDD_DCI_TRANSFORM
+Resource162=IDD_SAVE_AGENT_CFG
+Resource163=IDD_CREATE_CLUSTER
+Resource164=IDD_EDIT_RULE_SEVERITY
+Resource165=IDD_GRAPH_PROP_SETTINGS
+Resource166=IDD_FATAL_ERROR
+Resource167=IDD_OBJECT_CLUSTER_GENERAL
+Resource168=IDD_SELECT_AGENT_PARAM
+Resource169=IDD_OBJECT_GENERAL
+Resource170=IDD_CREATE_CONDITION
+Resource171=IDA_SCRIPT_MANAGER
 Class121=CModuleManager
 Class122=CDesktopManager
-Resource172=IDA_GRAPH
-Resource173=IDD_FATAL_ERROR
+Resource172=IDD_DESKTOP_SAVE_AS
+Resource173=IDD_CREATE_TEMPLATE
 Class123=CCreateCondDlg
 Class124=CCondPropsGeneral
 Class125=CCondPropsScript
 Class126=CCondPropsData
-Resource174=IDD_CHANGE_IP
+Resource174=IDD_REQUEST_PROCESSING
 Class127=CAddDCIDlg
-Resource175=IDD_OBJTOOL_OPTIONS
+Resource175=IDD_OBJECT_CAPS
 Class128=CCondDCIPropDlg
-Resource176=IDD_AGENT_CONFIG
+Resource176=IDD_SELECT_OBJECT
 Class129=CAgentConfigMgr
-Resource177=IDD_EDIT_RULE_SCRIPT
-Resource178=IDD_SELECT_OBJECT
+Resource177=IDD_EDIT_RULE_COMMENT
+Resource178=IDD_AGENT_CONFIG
 Class130=CAgentCfgDlg
 Class131=CObjectCommentsEditor
-Resource179=IDD_GRAPH_PROP_SETTINGS
+Resource179=IDA_PACKAGE_MGR
 Class132=CRuleScriptDlg
 Class133=CDetailsView
-Resource180=IDD_EDIT_TRAP
+Resource180=IDR_MAINFRAME
 Class134=CDiscoveryPropGeneral
-Resource181=IDD_DCI_DATA_EXPORT
+Resource181=IDA_AGENT_CFG_EDITOR
 Class135=CDiscoveryPropTargets
-Resource182=IDD_SELECT_TRAP
+Resource182=IDD_ACTION_PROPERTIES
 Class136=CDiscoveryPropAddrList
-Resource183=IDD_OBJECT_PRESENTATION
+Resource183=IDD_DISCOVERY_TARGETS
 Class138=CObjectView
 Class139=CObjectOverview
 Class140=CAlarmView
 Class141=CObjectDepView
-Resource184=IDD_DCI_TRANSFORM
+Resource184=IDD_OBJECT_CLUSTER_RESOURCES
 Class137=CObjectBrowser
 Class142=CCreateMPDlg
-Resource185=IDD_SUBMAP_BKGND
+Resource185=IDD_NEW_USER
 Class143=CSelectMPDlg
 Resource186=IDM_VIEW_SPECIFIC
 Class144=CTrapSelDlg
-Resource187=IDA_NETMAP
+Resource187=IDD_CREATE_NETSRV
 Class145=CConsoleUpgradeDlg
-Resource188=IDD_GRAPH_PROP_DATA
+Resource188=IDA_LAST_VALUES
 Class146=CCreateClusterDlg
-Resource189=IDD_OBJTOOL_COLUMNS
+Resource189=IDD_OBJECT_SECURITY
 Class147=CClusterPropsGeneral
-Resource190=IDD_NEW_OBJECT_TOOL
+Resource190=IDD_OBJECT_NODE_GENERAL
 Class148=CClusterPropsResources
-Resource191=IDD_MIB_BROWSER
+Resource191=IDD_COND_DCI_PROP
 Class149=CClusterResDlg
-Resource192=IDA_SERVER_CFG_EDITOR
+Resource192=IDD_LASTVAL_PROP
 Class150=CClusterView
 Class151=CExtEditCtrl
-Resource193=IDD_USER_PROPERTIES
+Resource193=IDD_CHANGE_PASSWORD
 Class152=CFatalErrorDlg
-Resource194=IDD_CREATE_CLUSTER
+Resource194=IDD_CREATE_CONTAINER
 Class153=CDefineGraphDlg
-Resource195=IDD_DEFINE_GRAPH
+Resource195=IDD_DATA_QUERY
+Class154=CGraphManagerDlg
+Resource196=IDD_MANAGE_GRAPHS
 
 [CLS:CConsoleApp]
 Type=0
@@ -1811,7 +1813,10 @@ Command169=ID_CONFIG_EDIT
 Command170=ID_CONFIG_DELETE
 Command171=ID_CONFIG_MOVEUP
 Command172=ID_CONFIG_MOVEDOWN
-CommandCount=172
+Command173=ID_GRAPHMANAGER_EDIT
+Command174=ID_GRAPHMANAGER_RENAME
+Command175=ID_GRAPHMANAGER_DELETE
+CommandCount=175
 
 [MNU:IDM_CONTEXT (English (U.S.))]
 Type=1
@@ -5324,3 +5329,21 @@ Filter=D
 VirtualFilter=dWC
 LastObject=CDefineGraphDlg
 
+[DLG:IDD_MANAGE_GRAPHS]
+Type=1
+Class=CGraphManagerDlg
+ControlCount=4
+Control1=IDC_TREE_GRAPHS,SysTreeView32,1342244919
+Control2=IDC_BUTTON_PROPERTIES,button,1342242816
+Control3=IDC_BUTTON_DELETE,button,1342242816
+Control4=IDCANCEL,button,1342242816
+
+[CLS:CGraphManagerDlg]
+Type=0
+HeaderFile=GraphManagerDlg.h
+ImplementationFile=GraphManagerDlg.cpp
+BaseClass=CDialog
+Filter=D
+VirtualFilter=dWC
+LastObject=CGraphManagerDlg
+
index 644d580..67f539c 100644 (file)
@@ -73,6 +73,7 @@
 #include "SelectMPDlg.h"
 #include "ConsoleUpgradeDlg.h"
 #include "FatalErrorDlg.h"
+#include "GraphManagerDlg.h"
 
 #ifdef _DEBUG
 #define new DEBUG_NEW
@@ -129,6 +130,7 @@ BEGIN_MESSAGE_MAP(CConsoleApp, CWinApp)
        ON_COMMAND(ID_TOOLS_CREATEMP, OnToolsCreatemp)
        ON_COMMAND(ID_FILE_PAGESETUP, OnFilePagesetup)
        ON_COMMAND(ID_TOOLS_IMPORTMP, OnToolsImportmp)
+       ON_COMMAND(ID_TOOLS_GRAPHS_MANAGE, OnToolsGraphsManage)
        //}}AFX_MSG_MAP
        ON_THREAD_MESSAGE(NXCM_GRAPH_LIST_UPDATED, OnGraphListUpdate)
        ON_COMMAND_RANGE(GRAPH_MENU_FIRST_ID, GRAPH_MENU_LAST_ID, OnPredefinedGraph)
@@ -3584,6 +3586,78 @@ void CConsoleApp::OnPredefinedGraph(UINT nCmd)
 }
 
 
+//
+// Create graph submenu
+//
+
+static void CreateGraphSubmenu(CMenu *pMenu, TCHAR *pszCurrPath, DWORD *pdwStart)
+{
+       DWORD i, j;
+   TCHAR szName[MAX_DB_STRING], szPath[MAX_DB_STRING];
+       int nPos; 
+
+       for(i = *pdwStart, nPos = 0; i < g_dwNumGraphs; i++, nPos++)
+       {
+      // Separate item name and path
+      memset(szPath, 0, sizeof(TCHAR) * MAX_DB_STRING);
+      if (_tcsstr(g_pGraphList[i].pszName, _T("->")) != NULL)
+      {
+         for(j = _tcslen(g_pGraphList[i].pszName) - 1; j > 0; j--)
+            if ((g_pGraphList[i].pszName[j] == _T('>')) &&
+                (g_pGraphList[i].pszName[j - 1] == _T('-')))
+            {
+               _tcscpy(szName, &g_pGraphList[i].pszName[j + 1]);
+               j--;
+               break;
+            }
+         memcpy(szPath, g_pGraphList[i].pszName, j * sizeof(TCHAR));
+      }
+      else
+      {
+         _tcscpy(szName, g_pGraphList[i].pszName);
+      }
+
+               // Add menu item if we are on right level, otherwise create submenu or go one level up
+      if (!_tcsicmp(szPath, pszCurrPath))
+      {
+         StrStrip(szName);
+         pMenu->InsertMenu(nPos, MF_BYPOSITION, GRAPH_MENU_FIRST_ID + i, szName);
+      }
+      else
+      {
+         for(j = _tcslen(pszCurrPath); (szPath[j] == _T(' ')) || (szPath[j] == _T('\t')); j++);
+         if ((*pszCurrPath == 0) ||
+             ((!memicmp(szPath, pszCurrPath, _tcslen(pszCurrPath) * sizeof(TCHAR))) &&
+              (szPath[j] == _T('-')) && (szPath[j + 1] == _T('>'))))
+         {
+            CMenu *pSubMenu;
+            TCHAR *pszName;
+
+            // Submenu of current menu
+            if (*pszCurrPath != 0)
+               j += 2;
+            pszName = &szPath[j];
+            for(; (szPath[j] != 0) && (memcmp(&szPath[j], _T("->"), sizeof(TCHAR) * 2)); j++);
+            szPath[j] = 0;
+            pSubMenu = new CMenu;
+                               pSubMenu->CreatePopupMenu();
+                               CreateGraphSubmenu(pSubMenu, szPath, &i);
+            StrStrip(pszName);
+            pMenu->InsertMenu(nPos, MF_ENABLED | MF_STRING | MF_POPUP | MF_BYPOSITION,
+                              (UINT)pSubMenu->Detach(), pszName);
+            delete pSubMenu;
+         }
+         else
+         {
+            i--;
+            break;
+         }
+               }
+       }
+   *pdwStart = i;
+}
+
+
 //
 // Update Tools->Graph submenu
 //
@@ -3606,8 +3680,8 @@ static void UpdateGraphSubmenu(CMenu *pToolsMenu)
                // Add new items
                if (g_dwNumGraphs > 0)
                {
-                       for(i = 0; i < g_dwNumGraphs; i++)
-                               pMenu->InsertMenu(i, MF_BYPOSITION, GRAPH_MENU_FIRST_ID + i, g_pGraphList[i].pszName);
+                       i = 0;
+                       CreateGraphSubmenu(pMenu, _T(""), &i);
                }
                else
                {
@@ -3617,6 +3691,23 @@ static void UpdateGraphSubmenu(CMenu *pToolsMenu)
 }
 
 
+//
+// Callback for qsort() which compares graph names
+//
+
+static int CompareGraphNames(const void *elem1, const void *elem2)
+{
+       int nRet;
+
+       TranslateStr(((NXC_GRAPH *)elem1)->pszName, _T("->"), _T("\x01\x02"));
+       TranslateStr(((NXC_GRAPH *)elem2)->pszName, _T("->"), _T("\x01\x02"));
+       nRet = _tcsicmp(((NXC_GRAPH *)elem1)->pszName, ((NXC_GRAPH *)elem2)->pszName);
+       TranslateStr(((NXC_GRAPH *)elem1)->pszName, _T("\x01\x02"), _T("->"));
+       TranslateStr(((NXC_GRAPH *)elem2)->pszName, _T("\x01\x02"), _T("->"));
+       return nRet;
+}
+
+
 //
 // Update UI after graph list update
 //
@@ -3634,6 +3725,10 @@ void CConsoleApp::OnGraphListUpdate(WPARAM wParam, LPARAM lParam)
 
        LockGraphs();
 
+       // Sort graph entries
+       qsort(g_pGraphList, g_dwNumGraphs, sizeof(NXC_GRAPH), CompareGraphNames);
+
+       // Update menus
        UPDATE_MENU(m_hMainMenu, 3);
        UPDATE_MENU(m_hMDIMenu, 3);
        UPDATE_MENU(m_hAlarmBrowserMenu, 4);
@@ -3846,3 +3941,15 @@ int CConsoleApp::Run()
 
        return nRet;
 }
+
+
+//
+// Start graph manager
+//
+
+void CConsoleApp::OnToolsGraphsManage() 
+{
+       CGraphManagerDlg dlg;
+
+       dlg.DoModal();
+}
index 1b2fafe..d295005 100644 (file)
@@ -436,6 +436,10 @@ SOURCE=.\GraphFrame.cpp
 # End Source File
 # Begin Source File
 
+SOURCE=.\GraphManagerDlg.cpp
+# End Source File
+# Begin Source File
+
 SOURCE=.\GraphSettingsPage.cpp
 # End Source File
 # Begin Source File
@@ -1017,6 +1021,10 @@ SOURCE=.\GraphFrame.h
 # End Source File
 # Begin Source File
 
+SOURCE=.\GraphManagerDlg.h
+# End Source File
+# Begin Source File
+
 SOURCE=.\GraphSettingsPage.h
 # End Source File
 # Begin Source File
index 4232042..4d5fe68 100644 (file)
@@ -264,6 +264,7 @@ public:
        afx_msg void OnToolsCreatemp();
        afx_msg void OnFilePagesetup();
        afx_msg void OnToolsImportmp();
+       afx_msg void OnToolsGraphsManage();
        //}}AFX_MSG
        afx_msg void OnGraphListUpdate(WPARAM wParam, LPARAM lParam);
        afx_msg void OnPredefinedGraph(UINT nCmd);
index e8cd091..dfb2bc9 100644 (file)
@@ -928,6 +928,12 @@ BEGIN
         MENUITEM "Move &up",                    ID_CONFIG_MOVEUP
         MENUITEM "Move do&wn",                  ID_CONFIG_MOVEDOWN
     END
+    POPUP "Graph Manager"
+    BEGIN
+        MENUITEM "&Edit...",                    ID_GRAPHMANAGER_EDIT
+        MENUITEM "&Rename",                     ID_GRAPHMANAGER_RENAME
+        MENUITEM "&Delete",                     ID_GRAPHMANAGER_DELETE
+    END
 END
 
 
@@ -3000,6 +3006,20 @@ BEGIN
     GROUPBOX        "Access List",IDC_STATIC,7,38,265,130
 END
 
+IDD_MANAGE_GRAPHS DIALOGEX 0, 0, 327, 241
+STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
+CAPTION "Preconfigured Graphs Manager"
+FONT 8, "MS Sans Serif"
+BEGIN
+    CONTROL         "Tree1",IDC_TREE_GRAPHS,"SysTreeView32",TVS_HASBUTTONS | 
+                    TVS_HASLINES | TVS_LINESATROOT | TVS_DISABLEDRAGDROP | 
+                    TVS_SHOWSELALWAYS | TVS_INFOTIP | WS_TABSTOP,7,7,256,227,
+                    WS_EX_CLIENTEDGE
+    PUSHBUTTON      "&Edit...",IDC_BUTTON_PROPERTIES,270,7,50,14
+    PUSHBUTTON      "&Delete",IDC_BUTTON_DELETE,270,26,50,14
+    PUSHBUTTON      "Close",IDCANCEL,270,45,50,14
+END
+
 
 #ifndef _MAC
 /////////////////////////////////////////////////////////////////////////////
@@ -3723,6 +3743,14 @@ BEGIN
         TOPMARGIN, 7
         BOTTOMMARGIN, 189
     END
+
+    IDD_MANAGE_GRAPHS, DIALOG
+    BEGIN
+        LEFTMARGIN, 7
+        RIGHTMARGIN, 320
+        TOPMARGIN, 7
+        BOTTOMMARGIN, 234
+    END
 END
 #endif    // APSTUDIO_INVOKED
 
index a54bb2d..b775ad1 100644 (file)
 #define IDI_AGAIN                       357
 #define IDD_FATAL_ERROR                 358
 #define IDD_DEFINE_GRAPH                359
+#define IDD_MANAGE_GRAPHS               360
 #define ID_EDIT_BOX                     525
 #define IDC_STATIC_TITLE                1003
 #define IDC_STATIC_TEXT                 1004
 #define IDC_CHECK_HIDE_EMPTY            1431
 #define IDC_IPADDR                      1438
 #define IDC_COMBO_RESOURCES             1439
+#define IDC_TREE_GRAPHS                 1451
+#define IDC_BUTTON_PROPERTIES           1452
 #define IDR_WEB_BROWSER                 8100
 #define IDR_SYSLOG_BROWSER              8101
 #define IDR_LPP_EDITOR                  8102
 #define ID_OBJECT_CREATE_CLUSTER        33050
 #define ID_TOOLS_GRAPHS_MANAGE          33051
 #define ID_GRAPH_DEFINE                 33052
+#define ID_GRAPHMANAGER_RENAME          33053
+#define ID_GRAPHMANAGER_DELETE          33054
+#define ID_GRAPHMANAGER_EDIT            33055
 #define ID_ALWAYS_DISABLED              43210
 #define IDS_GETFOLDERPATH_FAILED        61216
 #define IDS_WORKDIR_CREATION_FAILED     61217
 #ifdef APSTUDIO_INVOKED
 #ifndef APSTUDIO_READONLY_SYMBOLS
 #define _APS_3D_CONTROLS                     1
-#define _APS_NEXT_RESOURCE_VALUE        360
-#define _APS_NEXT_COMMAND_VALUE         33053
-#define _APS_NEXT_CONTROL_VALUE         1451
+#define _APS_NEXT_RESOURCE_VALUE        361
+#define _APS_NEXT_COMMAND_VALUE         33056
+#define _APS_NEXT_CONTROL_VALUE         1455
 #define _APS_NEXT_SYMED_VALUE           134
 #endif
 #endif
index b27a237..6a7341c 100644 (file)
@@ -637,6 +637,7 @@ CMenu *CreateToolsSubmenu(NXC_OBJECT *pObject, TCHAR *pszCurrPath, DWORD *pdwSta
             _tcscpy(szName, g_pObjectToolList[i].szName);
          }
 
+                       // Add menu item if we are on right level, otherwise create submenu or go one level up
          if (!_tcsicmp(szPath, pszCurrPath))
          {
             StrStrip(szName);