- Database upgrade to V73
authorVictor Kirhenshtein <victor@netxms.org>
Mon, 28 Jan 2008 06:59:17 +0000 (06:59 +0000)
committerVictor Kirhenshtein <victor@netxms.org>
Mon, 28 Jan 2008 06:59:17 +0000 (06:59 +0000)
- Implemented font increase/decrease in alarm browser plugin

doc/internal/db_format_change.txt
include/netxmsdb.h
sql/schema.in
sql/setup.in
src/client/console/nxmc/mainfrm.cpp
src/client/console/nxmc/nxmc.dsp
src/client/console/nxmc/nxmc.rc
src/client/console/nxmc/resource.h
src/client/console/plugins/AlarmBrowser/alarm_browser.h
src/client/console/plugins/AlarmBrowser/view.cpp
src/server/tools/nxdbmgr/upgrade.cpp

index 44fd43e..d1ed36b 100644 (file)
@@ -5,7 +5,6 @@
 - New columns added to table "event_policy":
        ALTER TABLE event_policy ADD situation_id integer not null
        ALTER TABLE event_policy ADD situation_instance varchar(255) not null
-
 - New table added:
        CREATE TABLE policy_situation_attr_list
        (
@@ -23,7 +22,8 @@
                comments SQL_TEXT not null,
                PRIMARY KEY(id)
        ) TABLE_TYPE;
-- New configuration parameters added: RetainCustomInterfaceNames, AllowDirectSMS, EventStormThreshold
+- New configuration parameters added: RetainCustomInterfaceNames,
+  AllowDirectSMS, EventStormThreshold
 
 
 *************
index 51474f2..933fca7 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: netxmsdb.h,v 1.74 2007-11-06 12:36:01 victor Exp $ */
+/* $Id: netxmsdb.h,v 1.75 2008-01-28 06:59:17 victor Exp $ */
 /* 
 ** NetXMS - Network Management System
 ** Copyright (C) 2003, 2004, 2005, 2006, 2007 Victor Kirhenshtein
@@ -24,6 +24,6 @@
 #ifndef _netxmsdb_h
 #define _netxmsdb_h
 
-#define DB_FORMAT_VERSION      72
+#define DB_FORMAT_VERSION      73
 
 #endif
index 8c53002..793ca25 100644 (file)
@@ -1224,6 +1224,7 @@ CREATE TABLE situations
 ** Situations' data
 */
 
+/*
 CREATE TABLE situation_data
 (
        situation_id integer not null,
@@ -1232,3 +1233,4 @@ CREATE TABLE situation_data
        attr_data varchar(255) not null,
        PRIMARY KEY(situation_id,instance,attr_name)
 ) TABLE_TYPE;
+*/
index 47ff9cd..7122456 100644 (file)
@@ -169,7 +169,7 @@ INSERT INTO config (var_name,var_value,is_visible,need_server_restart)
 INSERT INTO config (var_name,var_value,is_visible,need_server_restart)
        VALUES ('RetainCustomInterfaceNames','0',1,0);
 INSERT INTO config (var_name,var_value,is_visible,need_server_restart)
-       VALUES ('AllowDirectSMS','1',1,0);
+       VALUES ('AllowDirectSMS','0',1,0);
 INSERT INTO config (var_name,var_value,is_visible,need_server_restart)
        VALUES ('EventStormThreshold','0',1,1);
 
index 0843c62..65cbcc7 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: mainfrm.cpp,v 1.17 2008-01-07 09:41:02 victor Exp $ */
+/* $Id: mainfrm.cpp,v 1.18 2008-01-28 06:59:17 victor Exp $ */
 /* 
 ** NetXMS - Network Management System
 ** Portable management console
@@ -63,6 +63,11 @@ END_EVENT_TABLE()
 nxMainFrame::nxMainFrame(const wxPoint &pos, const wxSize &size)
             :wxFrame((wxWindow *)NULL, wxID_ANY, _T("NetXMS Management Console"), pos, size)
 {
+#ifdef _WIN32
+       wxIcon icon(_T("NXMC_ICON"), wxBITMAP_TYPE_ICO_RESOURCE);
+       SetIcon(icon);
+#endif
+
        m_currPane = NULL;
        m_currTab = NULL;
 
index 571fa07..4ac9df8 100644 (file)
@@ -283,6 +283,10 @@ SOURCE=.\vareditdlg.h
 # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
 # Begin Source File
 
+SOURCE=.\rc\nxmc.ico
+# End Source File
+# Begin Source File
+
 SOURCE=.\nxmc.rc
 # End Source File
 # Begin Source File
index 5cd01fb..d3e24a0 100644 (file)
@@ -99,6 +99,15 @@ END
 
 #endif    // !_MAC
 
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Icon
+//
+
+// Icon with lowest ID value placed first to ensure application icon
+// remains consistent on all systems.
+NXMC_ICON            ICON    DISCARDABLE     "rc\\nxmc.ico"
 #endif    // English (U.S.) resources
 /////////////////////////////////////////////////////////////////////////////
 
index 35c9a52..f7222ed 100644 (file)
@@ -3,12 +3,13 @@
 // Used by nxmc.rc
 //
 #define IDR_XRS                         101
+#define IDI_APP_ICON                    102
 
 // Next default values for new objects
 // 
 #ifdef APSTUDIO_INVOKED
 #ifndef APSTUDIO_READONLY_SYMBOLS
-#define _APS_NEXT_RESOURCE_VALUE        102
+#define _APS_NEXT_RESOURCE_VALUE        103
 #define _APS_NEXT_COMMAND_VALUE         40001
 #define _APS_NEXT_CONTROL_VALUE         1000
 #define _APS_NEXT_SYMED_VALUE           101
index 4397888..265514f 100644 (file)
@@ -59,10 +59,16 @@ protected:
        void OnSize(wxSizeEvent &event);
        void OnListItemRightClick(wxListEvent &event);
        void OnListColumnClick(wxListEvent &event);
+       void OnContextMenu(wxContextMenuEvent &event);
        void OnAlarmChange(wxCommandEvent &event);
        void OnAlarmAck(wxCommandEvent &event);
+       void OnUpdateAlarmAck(wxUpdateUIEvent &event);
        void OnAlarmTerminate(wxCommandEvent &event);
+       void OnUpdateAlarmTerminate(wxUpdateUIEvent &event);
        void OnAlarmDelete(wxCommandEvent &event);
+       void OnUpdateAlarmDelete(wxUpdateUIEvent &event);
+       void OnAlarmIncreaseFont(wxCommandEvent &event);
+       void OnAlarmDecreaseFont(wxCommandEvent &event);
 
        DECLARE_EVENT_TABLE()
 };
index ebade24..e4fceff 100644 (file)
 
 BEGIN_EVENT_TABLE(nxAlarmView, nxView)
        EVT_SIZE(nxAlarmView::OnSize)
-       EVT_LIST_ITEM_RIGHT_CLICK(wxID_LIST_CTRL, nxAlarmView::OnListItemRightClick)
+//     EVT_LIST_ITEM_RIGHT_CLICK(wxID_LIST_CTRL, nxAlarmView::OnListItemRightClick)
        EVT_LIST_COL_CLICK(wxID_LIST_CTRL, nxAlarmView::OnListColumnClick)
+       EVT_CONTEXT_MENU(nxAlarmView::OnContextMenu)
        EVT_MENU(XRCID("menuAlarmAck"), nxAlarmView::OnAlarmAck)
+       EVT_UPDATE_UI(XRCID("menuAlarmAck"), nxAlarmView::OnUpdateAlarmAck)
        EVT_MENU(XRCID("menuAlarmTerminate"), nxAlarmView::OnAlarmTerminate)
+       EVT_UPDATE_UI(XRCID("menuAlarmTerminate"), nxAlarmView::OnUpdateAlarmTerminate)
        EVT_MENU(XRCID("menuAlarmDelete"), nxAlarmView::OnAlarmDelete)
+       EVT_UPDATE_UI(XRCID("menuAlarmDelete"), nxAlarmView::OnUpdateAlarmDelete)
+       EVT_MENU(XRCID("menuAlarmIncreaseFont"), nxAlarmView::OnAlarmIncreaseFont)
+       EVT_MENU(XRCID("menuAlarmDecreaseFont"), nxAlarmView::OnAlarmDecreaseFont)
 END_EVENT_TABLE()
 
 
@@ -45,6 +51,8 @@ END_EVENT_TABLE()
 nxAlarmView::nxAlarmView(wxWindow *parent, const TCHAR *context, NXC_OBJECT *object)
             : nxView(parent)
 {
+       int fontSize;
+
        wxConfigBase *cfg = wxConfig::Get();
        wxString path = cfg->GetPath();
 
@@ -54,6 +62,7 @@ nxAlarmView::nxAlarmView(wxWindow *parent, const TCHAR *context, NXC_OBJECT *obj
        cfg->SetPath(m_context);
        cfg->Read(_T("AlarmView/SortMode"), &m_sortMode, 0);
        cfg->Read(_T("AlarmView/SortDir"), &m_sortDir, -1);
+       cfg->Read(_T("AlarmView/FontSize"), &fontSize, -1);
 
        m_wndListCtrl = new wxListView(this, wxID_LIST_CTRL, wxDefaultPosition, wxDefaultSize,
                                       wxLC_REPORT | wxLC_HRULES | wxLC_VRULES);
@@ -73,6 +82,15 @@ nxAlarmView::nxAlarmView(wxWindow *parent, const TCHAR *context, NXC_OBJECT *obj
        m_wndListCtrl->AssignImageList(imgList, wxIMAGE_LIST_SMALL);
        NXMCLoadListCtrlColumns(cfg, *m_wndListCtrl, _T("AlarmView"));
 
+       if (fontSize != -1)
+       {
+               wxFont font;
+
+               font = m_wndListCtrl->GetFont();
+               font.SetPointSize(fontSize);
+               m_wndListCtrl->SetFont(font);
+       }
+
        cfg->SetPath(path);
        
        SetIcon(wxXmlResource::Get()->LoadIcon(_T("icoAlarmView")));
@@ -94,6 +112,7 @@ nxAlarmView::~nxAlarmView()
        cfg->SetPath(m_context);
        cfg->Write(_T("AlarmView/SortMode"), m_sortMode);
        cfg->Write(_T("AlarmView/SortDir"), m_sortDir);
+       cfg->Write(_T("AlarmView/FontSize"), m_wndListCtrl->GetFont().GetPointSize());
        NXMCSaveListCtrlColumns(cfg, *m_wndListCtrl, _T("AlarmView"));
        cfg->SetPath(path);
 }
@@ -380,7 +399,13 @@ void nxAlarmView::OnAlarmAck(wxCommandEvent &event)
                        break;
                idList[i] = m_wndListCtrl->GetItemData(item);
        }
-       DoRequestArg2((void *)AckAlarms, count, CAST_FROM_POINTER(idList, wxUIntPtr), _T("Cannot acknowledge alarm: %s"));
+       if (count > 0)
+               DoRequestArg2((void *)AckAlarms, count, CAST_FROM_POINTER(idList, wxUIntPtr), _T("Cannot acknowledge alarm: %s"));
+}
+
+void nxAlarmView::OnUpdateAlarmAck(wxUpdateUIEvent &event)
+{
+       event.Enable(m_wndListCtrl->GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED) != -1);
 }
 
 
@@ -417,7 +442,13 @@ void nxAlarmView::OnAlarmTerminate(wxCommandEvent &event)
                        break;
                idList[i] = m_wndListCtrl->GetItemData(item);
        }
-       DoRequestArg2((void *)TerminateAlarms, count, CAST_FROM_POINTER(idList, wxUIntPtr), _T("Cannot terminate alarm: %s"));
+       if (count > 0)
+               DoRequestArg2((void *)TerminateAlarms, count, CAST_FROM_POINTER(idList, wxUIntPtr), _T("Cannot terminate alarm: %s"));
+}
+
+void nxAlarmView::OnUpdateAlarmTerminate(wxUpdateUIEvent &event)
+{
+       event.Enable(m_wndListCtrl->GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED) != -1);
 }
 
 
@@ -454,5 +485,65 @@ void nxAlarmView::OnAlarmDelete(wxCommandEvent &event)
                        break;
                idList[i] = m_wndListCtrl->GetItemData(item);
        }
-       DoRequestArg2((void *)DeleteAlarms, count, CAST_FROM_POINTER(idList, wxUIntPtr), _T("Cannot delete alarm: %s"));
+       if (count > 0)
+               DoRequestArg2((void *)DeleteAlarms, count, CAST_FROM_POINTER(idList, wxUIntPtr), _T("Cannot delete alarm: %s"));
+}
+
+void nxAlarmView::OnUpdateAlarmDelete(wxUpdateUIEvent &event)
+{
+       event.Enable(m_wndListCtrl->GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED) != -1);
+}
+
+
+//
+// Increase font
+//
+
+void nxAlarmView::OnAlarmIncreaseFont(wxCommandEvent &event)
+{
+       wxFont font;
+
+       font = m_wndListCtrl->GetFont();
+       if (font.GetPointSize() < 100)
+       {
+               font.SetPointSize(font.GetPointSize() + 1);
+               m_wndListCtrl->SetFont(font);
+       }
+}
+
+
+//
+// Decrease font
+//
+
+void nxAlarmView::OnAlarmDecreaseFont(wxCommandEvent &event)
+{
+       wxFont font;
+
+       font = m_wndListCtrl->GetFont();
+       if (font.GetPointSize() > 4)
+       {
+               font.SetPointSize(font.GetPointSize() - 1);
+               m_wndListCtrl->SetFont(font);
+       }
+}
+
+
+//
+// Context menu handler
+//
+
+void nxAlarmView::OnContextMenu(wxContextMenuEvent &event)
+{
+       wxMenu *menu;
+
+       if (!IsBusy())
+       {
+               menu = wxXmlResource::Get()->LoadMenu(_T("menuCtxAlarm"));
+               if (menu != NULL)
+               {
+                       PopupMenu(menu);
+                       delete menu;
+               }
+       }
 }
index 7beeed7..94f1168 100644 (file)
@@ -1,6 +1,6 @@
 /* 
 ** nxdbmgr - NetXMS database manager
-** Copyright (C) 2004, 2005, 2006, 2007 Victor Kirhenshtein
+** Copyright (C) 2004, 2005, 2006, 2007, 2008 Victor Kirhenshtein
 **
 ** This program is free software; you can redistribute it and/or modify
 ** it under the terms of the GNU General Public License as published by
@@ -86,6 +86,54 @@ static BOOL CreateConfigParam(const TCHAR *pszName, const TCHAR *pszValue,
 }
 
 
+//
+// Upgrade from V72 to V73
+//
+
+static BOOL H_UpgradeFromV72(void)
+{
+   static TCHAR m_szBatch[] =
+               _T("ALTER TABLE event_policy ADD situation_id integer\n")
+               _T("ALTER TABLE event_policy ADD situation_instance varchar(255)\n")
+      _T("<END>");
+
+       if (!CreateTable(_T("CREATE TABLE policy_situation_attr_list (")
+                        _T("rule_id integer not null,")
+                        _T("situation_id integer not null,")
+                        _T("attr_name varchar(255) not null,")
+                        _T("attr_value varchar(255) not null,")
+                        _T("PRIMARY KEY(rule_id,situation_id,attr_name))")))
+      if (!g_bIgnoreErrors)
+         return FALSE;
+
+       if (!CreateTable(_T("CREATE TABLE situations (")
+                        _T("id integer not null,")
+                        _T("name varchar(127) not null,")
+                        _T("comments $SQL:TEXT not null,")
+                        _T("PRIMARY KEY(id))")))
+      if (!g_bIgnoreErrors)
+         return FALSE;
+
+   if (!CreateConfigParam(_T("RetainCustomInterfaceNames"), _T("0"), 1, 0))
+      if (!g_bIgnoreErrors)
+         return FALSE;
+
+   if (!CreateConfigParam(_T("AllowDirectSMS"), _T("0"), 1, 0))
+      if (!g_bIgnoreErrors)
+         return FALSE;
+
+   if (!CreateConfigParam(_T("EventStormThreshold"), _T("0"), 1, 1))
+      if (!g_bIgnoreErrors)
+         return FALSE;
+
+       if (!SQLQuery(_T("UPDATE config SET var_value='73' WHERE var_name='DBFormatVersion'")))
+      if (!g_bIgnoreErrors)
+         return FALSE;
+
+   return TRUE;
+}
+
+
 //
 // Upgrade from V71 to V72
 //
@@ -93,7 +141,7 @@ static BOOL CreateConfigParam(const TCHAR *pszName, const TCHAR *pszValue,
 static BOOL H_UpgradeFromV71(void)
 {
    static TCHAR m_szBatch[] =
-               _T("ALTER TABLE items ADD proxy_node integer\n")
+               _T("ALTER TABLE items ADD proxy_node integer not null\n")
                _T("UPDATE items SET proxy_node=0\n")
       _T("<END>");
 
@@ -3176,6 +3224,7 @@ static struct
    { 69, H_UpgradeFromV69 },
    { 70, H_UpgradeFromV70 },
    { 71, H_UpgradeFromV71 },
+   { 72, H_UpgradeFromV72 },
    { 0, NULL }
 };