Event editor added
authorVictor Kirhenshtein <victor@netxms.org>
Tue, 16 Mar 2004 21:56:48 +0000 (21:56 +0000)
committerVictor Kirhenshtein <victor@netxms.org>
Tue, 16 Mar 2004 21:56:48 +0000 (21:56 +0000)
13 files changed:
.gitattributes
src/console/win32/ControlPanel.cpp
src/console/win32/ControlPanel.h
src/console/win32/EventEditor.cpp [new file with mode: 0644]
src/console/win32/EventEditor.h [new file with mode: 0644]
src/console/win32/globals.h
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/res/nxcon.rc2 [new file with mode: 0644]
src/console/win32/resource.h

index d7da9c7..ca2d4f7 100644 (file)
@@ -24,6 +24,8 @@ src/console/win32/ControlPanel.cpp -text
 src/console/win32/ControlPanel.h -text
 src/console/win32/EventBrowser.cpp -text
 src/console/win32/EventBrowser.h -text
+src/console/win32/EventEditor.cpp -text
+src/console/win32/EventEditor.h -text
 src/console/win32/LoginDialog.cpp -text
 src/console/win32/LoginDialog.h -text
 src/console/win32/MainFrm.cpp -text
@@ -62,6 +64,7 @@ src/console/win32/nxcon.rc -text
 src/console/win32/res/Toolbar.bmp -text
 src/console/win32/res/login.bmp -text
 src/console/win32/res/nxcon.ico -text
+src/console/win32/res/nxcon.rc2 -text
 src/console/win32/resource.h -text
 src/libnxcl/comm.cpp -text
 src/libnxcl/eventdb.cpp -text
index a06de4e..2e3687d 100644 (file)
 static char THIS_FILE[] = __FILE__;
 #endif
 
-/////////////////////////////////////////////////////////////////////////////
+
+//
+// Control panel items
+//
+
+#define CP_ITEM_EPP     0
+#define CP_ITEM_USERS   1
+#define CP_ITEM_EVENTS  2
+
+
+//
 // CControlPanel
+//
 
 IMPLEMENT_DYNCREATE(CControlPanel, CMDIChildWnd)
 
@@ -33,6 +44,7 @@ BEGIN_MESSAGE_MAP(CControlPanel, CMDIChildWnd)
        ON_WM_DESTROY()
        ON_WM_SIZE()
        ON_WM_SETFOCUS()
+   ON_NOTIFY(NM_DBLCLK, ID_LIST_VIEW, OnListViewDoubleClick)
        //}}AFX_MSG_MAP
 END_MESSAGE_MAP()
 
@@ -67,11 +79,13 @@ int CControlPanel::OnCreate(LPCREATESTRUCT lpCreateStruct)
    m_pImageList->Create(32, 32, ILC_COLOR8 | ILC_MASK, 8, 8);
    m_pImageList->Add(AfxGetApp()->LoadIcon(IDI_USERS));
    m_pImageList->Add(AfxGetApp()->LoadIcon(IDI_RULEMGR));
+   m_pImageList->Add(AfxGetApp()->LoadIcon(IDI_EVENT));
    m_wndListCtrl.SetImageList(m_pImageList, LVSIL_NORMAL);
 
    // Populate list with items
-   m_wndListCtrl.InsertItem(0, "Event Processing Policy", 1);
-   m_wndListCtrl.InsertItem(1, "Users", 0);
+   m_wndListCtrl.InsertItem(CP_ITEM_EPP, "Event Processing Policy", 1);
+   m_wndListCtrl.InsertItem(CP_ITEM_USERS, "Users", 0);
+   m_wndListCtrl.InsertItem(CP_ITEM_EVENTS, "Events", 2);
 
    ((CConsoleApp *)AfxGetApp())->OnViewCreate(IDR_CTRLPANEL, this);
        return 0;
@@ -111,3 +125,23 @@ void CControlPanel::OnSetFocus(CWnd* pOldWnd)
        
    m_wndListCtrl.SetFocus();
 }
+
+
+//
+// Process double click on list control
+//
+
+void CControlPanel::OnListViewDoubleClick(NMITEMACTIVATE *pInfo, LRESULT *pResult)
+{
+   switch(pInfo->iItem)
+   {
+      case CP_ITEM_EVENTS:
+         PostMessage(WM_COMMAND, ID_CONTROLPANEL_EVENTS, 0);
+         break;
+      case CP_ITEM_USERS:
+         PostMessage(WM_COMMAND, ID_CONTROLPANEL_USERS, 0);
+         break;
+      default:
+         break;
+   }
+}
index 0f0c27f..67ddcb7 100644 (file)
@@ -31,6 +31,7 @@ public:
 
 // Implementation
 protected:
+       void OnListViewDoubleClick(NMITEMACTIVATE *pInfo, LRESULT* pResult);
        CImageList *m_pImageList;
        CListCtrl m_wndListCtrl;
        virtual ~CControlPanel();
diff --git a/src/console/win32/EventEditor.cpp b/src/console/win32/EventEditor.cpp
new file mode 100644 (file)
index 0000000..bc09cfd
--- /dev/null
@@ -0,0 +1,80 @@
+// EventEditor.cpp : implementation file
+//
+
+#include "stdafx.h"
+#include "nxcon.h"
+#include "EventEditor.h"
+
+#ifdef _DEBUG
+#define new DEBUG_NEW
+#undef THIS_FILE
+static char THIS_FILE[] = __FILE__;
+#endif
+
+/////////////////////////////////////////////////////////////////////////////
+// CEventEditor
+
+IMPLEMENT_DYNCREATE(CEventEditor, CMDIChildWnd)
+
+CEventEditor::CEventEditor()
+{
+}
+
+CEventEditor::~CEventEditor()
+{
+}
+
+
+BEGIN_MESSAGE_MAP(CEventEditor, CMDIChildWnd)
+       //{{AFX_MSG_MAP(CEventEditor)
+       ON_WM_CREATE()
+       ON_WM_DESTROY()
+       //}}AFX_MSG_MAP
+END_MESSAGE_MAP()
+
+//
+// CEventEditor message handlers
+//
+
+int CEventEditor::OnCreate(LPCREATESTRUCT lpCreateStruct) 
+{
+   RECT rect;
+   HREQUEST hRequest;
+
+       if (CMDIChildWnd::OnCreate(lpCreateStruct) == -1)
+               return -1;
+
+   // Create list view control
+   GetClientRect(&rect);
+   m_wndListCtrl.Create(WS_CHILD | WS_VISIBLE | LVS_REPORT, rect, this, ID_LIST_VIEW);
+   m_wndListCtrl.SetExtendedStyle(LVS_EX_TRACKSELECT | LVS_EX_UNDERLINEHOT | 
+                                  LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES);
+   m_wndListCtrl.SetHoverTime(0x7FFFFFFF);
+
+   // Setup columns
+   m_wndListCtrl.InsertColumn(0, "ID", LVCFMT_LEFT, 40);
+   m_wndListCtrl.InsertColumn(1, "Name", LVCFMT_LEFT, 100);
+   m_wndListCtrl.InsertColumn(2, "Severity", LVCFMT_LEFT, 70);
+   m_wndListCtrl.InsertColumn(3, "Flags", LVCFMT_LEFT, 40);
+   m_wndListCtrl.InsertColumn(4, "Message", LVCFMT_LEFT, 150);
+   m_wndListCtrl.InsertColumn(5, "Description", LVCFMT_LEFT, 300);
+       
+   ((CConsoleApp *)AfxGetApp())->OnViewCreate(IDR_EVENT_EDITOR, this);
+
+   hRequest = NXCOpenEventDB();
+   if (hRequest != INVALID_REQUEST_HANDLE)
+      ((CConsoleApp *)AfxGetApp())->RegisterRequest(hRequest, this);
+       return 0;
+}
+
+
+//
+// WM_DESTROY message handler
+//
+
+void CEventEditor::OnDestroy() 
+{
+   NXCCloseEventDB();
+   ((CConsoleApp *)AfxGetApp())->OnViewDestroy(IDR_EVENT_EDITOR, this);
+       CMDIChildWnd::OnDestroy();
+}
diff --git a/src/console/win32/EventEditor.h b/src/console/win32/EventEditor.h
new file mode 100644 (file)
index 0000000..fd1ba4e
--- /dev/null
@@ -0,0 +1,48 @@
+#if !defined(AFX_EVENTEDITOR_H__A45B4A38_99BC_4277_B600_742C39D58310__INCLUDED_)
+#define AFX_EVENTEDITOR_H__A45B4A38_99BC_4277_B600_742C39D58310__INCLUDED_
+
+#if _MSC_VER > 1000
+#pragma once
+#endif // _MSC_VER > 1000
+// EventEditor.h : header file
+//
+
+/////////////////////////////////////////////////////////////////////////////
+// CEventEditor frame
+
+class CEventEditor : public CMDIChildWnd
+{
+       DECLARE_DYNCREATE(CEventEditor)
+protected:
+       CEventEditor();           // protected constructor used by dynamic creation
+
+// Attributes
+public:
+
+// Operations
+public:
+
+// Overrides
+       // ClassWizard generated virtual function overrides
+       //{{AFX_VIRTUAL(CEventEditor)
+       //}}AFX_VIRTUAL
+
+// Implementation
+protected:
+       CListCtrl m_wndListCtrl;
+       virtual ~CEventEditor();
+
+       // Generated message map functions
+       //{{AFX_MSG(CEventEditor)
+       afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
+       afx_msg void OnDestroy();
+       //}}AFX_MSG
+       DECLARE_MESSAGE_MAP()
+};
+
+/////////////////////////////////////////////////////////////////////////////
+
+//{{AFX_INSERT_LOCATION}}
+// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
+
+#endif // !defined(AFX_EVENTEDITOR_H__A45B4A38_99BC_4277_B600_742C39D58310__INCLUDED_)
index 8966281..373b02f 100644 (file)
@@ -42,6 +42,13 @@ extern CConsoleApp theApp;
 #define MAX_PASSWORD_LEN      64
 
 
+//
+// Custom windows messages
+//
+
+#define WM_REQUEST_COMPLETED     (WM_USER + 1)
+
+
 //
 // Variables
 //
index a18649b..b1c9a0f 100644 (file)
@@ -2,13 +2,13 @@
 
 [General Info]
 Version=1
-LastClass=CObjectPropDlg
-LastTemplate=CDialog
+LastClass=CEventEditor
+LastTemplate=CMDIChildWnd
 NewFileInclude1=#include "stdafx.h"
 NewFileInclude2=#include "nxcon.h"
 LastPage=0
 
-ClassCount=13
+ClassCount=14
 Class1=CConsoleApp
 Class3=CMainFrame
 Class4=CChildFrame
@@ -16,24 +16,24 @@ Class7=CEventBrowser
 Class9=CMapView
 
 ResourceCount=20
-Resource1=IDR_MAPFRAME
-Resource2=IDR_MAINFRAME
-Resource3=IDR_CTRLPANEL
-Resource4=IDD_LOGIN
-Resource5=IDR_OBJECTS
+Resource1=IDR_CTRLPANEL
+Resource2=IDD_DUMMY (English (U.S.))
+Resource3=IDR_MAPFRAME
+Resource4=IDD_PROGRESS
+Resource5=IDR_EVENTS
 Class2=CChildView
 Class5=CAboutDlg
 Class6=CControlPanel
 Class8=CMapFrame
 Class10=CLoginDialog
-Resource6=IDD_ABOUTBOX
+Resource6=IDD_LOGIN
 Class11=CProgressDialog
-Resource7=IDR_EVENTS
+Resource7=IDR_OBJECTS
 Class12=CObjectBrowser
-Resource8=IDD_PROGRESS
+Resource8=IDD_OBJECT_PROPERTIES
 Class13=CObjectPropDlg
-Resource9=IDD_OBJECT_PROPERTIES
-Resource10=IDD_DUMMY
+Resource9=IDR_MAINFRAME
+Resource10=IDD_ABOUTBOX
 Resource11=IDD_OBJECT_PROPERTIES (English (U.S.))
 Resource12=IDR_MAPFRAME (English (U.S.))
 Resource13=IDR_OBJECTS (English (U.S.))
@@ -43,7 +43,8 @@ Resource16=IDR_MAINFRAME (English (U.S.))
 Resource17=IDD_ABOUTBOX (English (U.S.))
 Resource18=IDD_LOGIN (English (U.S.))
 Resource19=IDD_PROGRESS (English (U.S.))
-Resource20=IDD_DUMMY (English (U.S.))
+Class14=CEventEditor
+Resource20=IDD_DUMMY
 
 [CLS:CConsoleApp]
 Type=0
@@ -102,8 +103,10 @@ Command6=ID_VIEW_CONTROLPANEL
 Command7=ID_VIEW_TOOLBAR
 Command8=ID_VIEW_STATUS_BAR
 Command9=ID_VIEW_REFRESH
-Command10=ID_APP_ABOUT
-CommandCount=10
+Command10=ID_CONTROLPANEL_EVENTS
+Command11=ID_CONTROLPANEL_USERS
+Command12=ID_APP_ABOUT
+CommandCount=12
 
 [TB:IDR_MAINFRAME]
 Type=1
@@ -432,7 +435,7 @@ CommandCount=14
 
 [DLG:IDD_ABOUTBOX (English (U.S.))]
 Type=1
-Class=?
+Class=CAboutDlg
 ControlCount=4
 Control1=IDC_STATIC,static,1342177283
 Control2=IDC_STATIC,static,1342308480
@@ -441,7 +444,7 @@ Control4=IDOK,button,1342373889
 
 [DLG:IDD_LOGIN (English (U.S.))]
 Type=1
-Class=?
+Class=CLoginDialog
 ControlCount=11
 Control1=IDC_EDIT_SERVER,edit,1350631552
 Control2=IDC_EDIT_LOGIN,edit,1350631552
@@ -457,14 +460,14 @@ Control11=IDC_STATIC,static,1342308352
 
 [DLG:IDD_PROGRESS (English (U.S.))]
 Type=1
-Class=?
+Class=CProgressDialog
 ControlCount=2
 Control1=IDC_STATIC_TITLE,button,1342177287
 Control2=IDC_STATIC_TEXT,static,1342308865
 
 [DLG:IDD_OBJECT_PROPERTIES (English (U.S.))]
 Type=1
-Class=?
+Class=CObjectPropDlg
 ControlCount=1
 Control1=IDC_LIST_VIEW,SysListView32,1342275613
 
@@ -476,3 +479,11 @@ Control1=IDOK,button,1342242817
 Control2=IDCANCEL,button,1342242816
 Control3=IDC_TREE_VIEW,SysTreeView32,1350631424
 
+[CLS:CEventEditor]
+Type=0
+HeaderFile=EventEditor.h
+ImplementationFile=EventEditor.cpp
+BaseClass=CMDIChildWnd
+Filter=M
+VirtualFilter=mfWC
+
index 1f43a97..9072338 100644 (file)
@@ -36,6 +36,7 @@ BEGIN_MESSAGE_MAP(CConsoleApp, CWinApp)
        ON_COMMAND(ID_VIEW_MAP, OnViewMap)
        ON_COMMAND(ID_CONNECT_TO_SERVER, OnConnectToServer)
        ON_COMMAND(ID_VIEW_OBJECTBROWSER, OnViewObjectbrowser)
+       ON_COMMAND(ID_CONTROLPANEL_EVENTS, OnControlpanelEvents)
        //}}AFX_MSG_MAP
 END_MESSAGE_MAP()
 
@@ -48,8 +49,10 @@ CConsoleApp::CConsoleApp()
 {
    m_bCtrlPanelActive = FALSE;
    m_bEventBrowserActive = FALSE;
+   m_bEventEditorActive = FALSE;
    m_bObjectBrowserActive = FALSE;
    m_dwClientState = STATE_DISCONNECTED;
+   m_pRqWaitList = NULL;
 }
 
 //
@@ -240,6 +243,10 @@ void CConsoleApp::OnViewCreate(DWORD dwView, CWnd *pWnd)
          m_bObjectBrowserActive = TRUE;
          m_pwndObjectBrowser = pWnd;
          break;
+      case IDR_EVENT_EDITOR:
+         m_bEventEditorActive = TRUE;
+         m_pwndEventEditor = (CEventEditor *)pWnd;
+         break;
       default:
          break;
    }
@@ -263,6 +270,9 @@ void CConsoleApp::OnViewDestroy(DWORD dwView, CWnd *pWnd)
       case IDR_OBJECTS:
          m_bObjectBrowserActive = FALSE;
          break;
+      case IDR_EVENT_EDITOR:
+         m_bEventEditorActive = FALSE;
+         break;
       default:
          break;
    }
@@ -398,7 +408,31 @@ void CConsoleApp::EventHandler(DWORD dwEvent, DWORD dwCode, void *pArg)
          MemFree(pArg);
 //         Sleep(0);
          break;
+      case NXC_EVENT_REQUEST_COMPLETED:
+         break;
       default:
          break;
    }
 }
+
+void CConsoleApp::OnControlpanelEvents() 
+{
+       CMainFrame* pFrame = STATIC_DOWNCAST(CMainFrame, m_pMainWnd);
+
+       // create a new MDI child window or open existing
+   if (m_bEventEditorActive)
+      m_pwndEventEditor->BringWindowToTop();
+   else
+          pFrame->CreateNewChild(
+                  RUNTIME_CLASS(CEventEditor), IDR_OBJECTS, m_hCtrlPanelMenu, m_hCtrlPanelAccel);      
+}
+
+
+//
+// Register callback for request completion
+//
+
+void CConsoleApp::RegisterRequest(HREQUEST hRequest, CWnd *pWnd)
+{
+
+}
index db42669..3527197 100644 (file)
@@ -104,6 +104,10 @@ SOURCE=.\EventBrowser.cpp
 # End Source File
 # Begin Source File
 
+SOURCE=.\EventEditor.cpp
+# End Source File
+# Begin Source File
+
 SOURCE=.\globals.cpp
 # End Source File
 # Begin Source File
@@ -161,11 +165,11 @@ SOURCE=.\EventBrowser.h
 # End Source File
 # Begin Source File
 
-SOURCE=.\globals.h
+SOURCE=.\EventEditor.h
 # End Source File
 # Begin Source File
 
-SOURCE=.\id.h
+SOURCE=.\globals.h
 # End Source File
 # Begin Source File
 
index c231b67..b89571c 100644 (file)
@@ -29,11 +29,23 @@ inline BOOL SafeFreeResource(HGLOBAL hRes)
 #include "globals.h"       // Global symbols
 #include "ControlPanel.h"
 #include "EventBrowser.h"
+#include "EventEditor.h"
 #include "ObjectBrowser.h"
 #include "MapFrame.h"
 #include "ProgressDialog.h"    // Added by ClassView
 
 
+//
+// Request waiting structure
+//
+
+struct RQ_WAIT_INFO
+{
+   HREQUEST hRequest;
+   CWnd *pWnd;
+};
+
+
 /////////////////////////////////////////////////////////////////////////////
 // CConsoleApp:
 // See nxcon.cpp for the implementation of this class
@@ -56,6 +68,7 @@ public:
 protected:
        DWORD m_dwClientState;
        CEventBrowser *m_pwndEventBrowser;
+   CEventEditor *m_pwndEventEditor;
        CWnd* m_pwndObjectBrowser;
        CWnd *m_pwndCtrlPanel;
        HMENU m_hCtrlPanelMenu;
@@ -64,9 +77,10 @@ protected:
        HACCEL m_hMDIAccel;
        BOOL m_bAuthFailed;
        CProgressDialog m_dlgProgress;
-
+   RQ_WAIT_INFO *m_pRqWaitList;
 
 public:
+       void RegisterRequest(HREQUEST hRequest, CWnd *pWnd);
        void EventHandler(DWORD dwEvent, DWORD dwCode, void *pArg);
        void OnViewDestroy(DWORD dwView, CWnd *pWnd);
        void OnViewCreate(DWORD dwView, CWnd *pWnd);
@@ -78,10 +92,12 @@ public:
        afx_msg void OnViewMap();
        afx_msg void OnConnectToServer();
        afx_msg void OnViewObjectbrowser();
+       afx_msg void OnControlpanelEvents();
        //}}AFX_MSG
        DECLARE_MESSAGE_MAP()
 private:
        BOOL m_bEventBrowserActive;
+       BOOL m_bEventEditorActive;
        BOOL m_bObjectBrowserActive;
        BOOL m_bCtrlPanelActive;
 };
index a8037e2..e4af007 100644 (file)
@@ -130,6 +130,11 @@ BEGIN
         MENUITEM SEPARATOR
         MENUITEM "&Refresh\tF5",                ID_VIEW_REFRESH
     END
+    POPUP "Control Panel"
+    BEGIN
+        MENUITEM "&Events\tCtrl+F2",            ID_CONTROLPANEL_EVENTS
+        MENUITEM "&Users\tCtrl+F3",             ID_CONTROLPANEL_USERS
+    END
     POPUP "&Help"
     BEGIN
         MENUITEM "&About nxcon...",             ID_APP_ABOUT
diff --git a/src/console/win32/res/nxcon.rc2 b/src/console/win32/res/nxcon.rc2
new file mode 100644 (file)
index 0000000..f707c89
--- /dev/null
@@ -0,0 +1,13 @@
+//
+// NXCON.RC2 - resources Microsoft Visual C++ does not edit directly
+//
+
+#ifdef APSTUDIO_INVOKED
+       #error this file is not editable by Microsoft Visual C++
+#endif //APSTUDIO_INVOKED
+
+
+/////////////////////////////////////////////////////////////////////////////
+// Add manually edited resources here...
+
+/////////////////////////////////////////////////////////////////////////////
index ef08117..c1b384c 100644 (file)
@@ -7,6 +7,7 @@
 #define ID_LIST_VIEW                    102
 #define ID_CONNECT_TO_SERVER            103
 #define IDP_SOCKETS_INIT_FAILED         104
+#define IDR_EVENT_EDITOR                104
 #define IDR_MAINFRAME                   128
 #define IDR_NXCONTYPE                   129
 #define IDI_ALARM                       130
@@ -42,6 +43,8 @@
 #define ID_VIEW_MAP                     32776
 #define ID_VIEW_OBJECTBROWSER           32779
 #define ID_VIEW_REFRESH                 32783
+#define ID_CONTROLPANEL_EVENTS          32784
+#define ID_CONTROLPANEL_USERS           32785
 
 // Next default values for new objects
 // 
@@ -49,8 +52,8 @@
 #ifndef APSTUDIO_READONLY_SYMBOLS
 #define _APS_3D_CONTROLS                     1
 #define _APS_NEXT_RESOURCE_VALUE        151
-#define _APS_NEXT_COMMAND_VALUE         32784
+#define _APS_NEXT_COMMAND_VALUE         32786
 #define _APS_NEXT_CONTROL_VALUE         1007
-#define _APS_NEXT_SYMED_VALUE           104
+#define _APS_NEXT_SYMED_VALUE           105
 #endif
 #endif