various changes
authorVictor Kirhenshtein <victor@netxms.org>
Mon, 30 Jul 2007 08:03:00 +0000 (08:03 +0000)
committerVictor Kirhenshtein <victor@netxms.org>
Mon, 30 Jul 2007 08:03:00 +0000 (08:03 +0000)
16 files changed:
src/client/console/include/nxmc_api.h
src/client/console/libnxmc/libnxmc.dsp
src/client/console/libnxmc/libnxmc.h
src/client/console/libnxmc/main.cpp
src/client/console/libnxmc/nxview.cpp
src/client/console/libnxmc/nxview.h
src/client/console/libnxmc/tools.cpp
src/client/console/nxmc/comm.cpp
src/client/console/nxmc/logindlg.h
src/client/console/nxmc/nxmc.cpp
src/client/console/nxmc/nxmc.h
src/client/console/nxmc/rc/nxmc.fbp
src/client/console/nxmc/rc/wxfb_code.xrc
src/client/console/plugins/AlarmBrowser/view.cpp
src/client/console/plugins/ObjectBrowser/browser.cpp
src/client/console/plugins/ObjectBrowser/object_browser.h

index 5bee05d..b53ea01 100644 (file)
@@ -278,11 +278,23 @@ struct CODE_TO_TEXT
 };
 
 
+//
+// libnxcl object index structure
+//
+
+struct NXC_OBJECT_INDEX
+{
+   DWORD key;
+   NXC_OBJECT *object;
+};
+
+
 //
 // Additional array and hash types
 //
 
 WX_DECLARE_HASH_MAP(DWORD, NXC_ALARM*, wxIntegerHash, wxIntegerEqual, nxAlarmList);
+WX_DECLARE_HASH_MAP_WITH_DECL(int, TCHAR*, wxIntegerHash, wxIntegerEqual, nxIntToStringHash, class LIBNXMC_EXPORTABLE);
 
 
 //
@@ -291,6 +303,7 @@ WX_DECLARE_HASH_MAP(DWORD, NXC_ALARM*, wxIntegerHash, wxIntegerEqual, nxAlarmLis
 
 #include "../libnxmc/nxview.h"
 #include "../libnxmc/heading.h"
+#include "../libnxmc/objseldlg.h"
 
 
 //
@@ -305,10 +318,13 @@ typedef nxView* (*nxViewCreator)(wxWindow *, const TCHAR *, NXC_OBJECT *, void *
 //
 
 void LIBNXMC_EXPORTABLE NXMCInitAUI(wxAuiManager *mgr, wxAuiNotebook *nb, wxWindow *defParent);
+void LIBNXMC_EXPORTABLE NXMCSetMainFrame(wxFrame *frame);
 void LIBNXMC_EXPORTABLE NXMCInitializationComplete();
 
 nxmcArrayOfRegItems LIBNXMC_EXPORTABLE &NXMCGetRegistrations();
 
+void LIBNXMC_EXPORTABLE NXMCShowClientError(DWORD rcc, TCHAR *msgTemplate);
+
 bool LIBNXMC_EXPORTABLE NXMCLoadResources(const TCHAR *name, NXMC_LIB_INSTANCE instance, TCHAR *resName);
 
 bool LIBNXMC_EXPORTABLE NXMCAddControlPanelItem(NXMC_PLUGIN_HANDLE handle, const TCHAR *name, int id);
index 5e6639d..dfd3570 100644 (file)
@@ -112,7 +112,7 @@ LINK32=link.exe
 # Begin Special Build Tool
 SOURCE="$(InputPath)"
 PostBuild_Desc=Copy files
-PostBuild_Cmds=copy         Release_UNICODE\libnxmc.dll         C:\NetXMS\bin\ 
+PostBuild_Cmds=copy          Release_UNICODE\libnxmc.dll          C:\NetXMS\bin\ 
 # End Special Build Tool
 
 !ELSEIF  "$(CFG)" == "libnxmc - Win32 Debug UNICODE"
@@ -184,6 +184,10 @@ SOURCE=.\nxview.cpp
 # End Source File
 # Begin Source File
 
+SOURCE=.\objseldlg.cpp
+# End Source File
+# Begin Source File
+
 SOURCE=.\tools.cpp
 # End Source File
 # Begin Source File
@@ -242,6 +246,10 @@ SOURCE=..\include\nxmc_api.h
 
 SOURCE=.\nxview.h
 # End Source File
+# Begin Source File
+
+SOURCE=.\objseldlg.h
+# End Source File
 # End Group
 # Begin Group "Resource Files"
 
index 5efeb4e..8989470 100644 (file)
@@ -66,6 +66,7 @@ WX_DECLARE_STRING_HASH_MAP(nxViewCreator, nxViewCreatorsHash);
 
 extern wxAuiNotebook *g_auiNotebook;
 extern wxAuiManager *g_auiManager;
+extern wxFrame *g_appMainFrame;
 
 
 #endif
index d06d071..d38f26c 100644 (file)
@@ -31,6 +31,7 @@
 wxAuiNotebook *g_auiNotebook = NULL;
 wxAuiManager *g_auiManager = NULL;
 wxWindow *g_auiDefaultParent = NULL;
+wxFrame *g_appMainFrame = NULL;
 
 
 //
@@ -140,6 +141,16 @@ void LIBNXMC_EXPORTABLE NXMCInitAUI(wxAuiManager *mgr, wxAuiNotebook *nb, wxWind
 }
 
 
+//
+// Set app main frame window
+//
+
+void LIBNXMC_EXPORTABLE NXMCSetMainFrame(wxFrame *frame)
+{
+       g_appMainFrame = frame;
+}
+
+
 //
 // Get default parent window
 //
index 6b807f4..1f94c5b 100644 (file)
@@ -148,7 +148,7 @@ static THREAD_RESULT THREAD_CALL RequestThread(void *arg)
 // Execute async request
 //
 
-int nxView::DoRequest(RqData *data)
+int nxView::DoRequest(RqData *data, TCHAR *errMsg)
 {
        if (m_activeRequestCount == 0)
                m_timer->Start(300, true);
@@ -230,6 +230,18 @@ void nxView::OnRequestCompleted(wxCommandEvent &event)
 
 void nxView::RequestCompletionHandler(int rqId, DWORD rcc)
 {
+       nxIntToStringHash::iterator it;
+
+       it = m_requestErrorMessages.find(rqId);
+       if (it != m_requestErrorMessages.end())
+       {
+               if (rcc != RCC_SUCCESS)
+               {
+                       NXMCShowClientError(rcc, it->second);
+               }
+               free(it->second);
+               m_requestErrorMessages.erase(it);
+       }
 }
 
 
@@ -240,4 +252,3 @@ void nxView::RequestCompletionHandler(int rqId, DWORD rcc)
 void nxView::RefreshView()
 {
 }
-
index 13a3be7..73e5c01 100644 (file)
@@ -62,6 +62,7 @@ private:
        int m_activeRequestCount;
        int m_freeRqId; // First free request id
        bool m_isBusy;
+       nxIntToStringHash m_rqErrorMessages;    // Error messages for active requests
        
        int DoRequest(RqData *data);
        
index 7c2de82..02214bb 100644 (file)
@@ -149,3 +149,17 @@ void LIBNXMC_EXPORTABLE NXMCLoadListCtrlColumns(wxConfigBase *cfg, wxListCtrl &w
 
        cfg->SetPath(path);
 }
+
+
+//
+// Show client library error
+//
+
+void LIBNXMC_EXPORTABLE NXMCShowClientError(DWORD rcc, TCHAR *msgTemplate)
+{
+       TCHAR msg[4096];
+
+       _sntprintf(msg, 4096, msgTemplate, NXCGetErrorText(rcc));
+       wxLogMessage(msg);
+       wxMessageBox(msg, _T("NetXMS Console - Error"), wxOK | wxICON_ERROR, g_appMainFrame);
+}
index afa6838..0769667 100644 (file)
@@ -163,7 +163,7 @@ static THREAD_RESULT THREAD_CALL LoginThread(void *arg)
          rcc = NXCDownloadMIBFile(g_hSession, mibFile.c_str());
          if (rcc != RCC_SUCCESS)
          {
-            wxGetApp().ShowClientError(rcc, _T("Error downloading MIB file from server: %s"));
+            NXMCShowClientError(rcc, _T("Error downloading MIB file from server: %s"));
             rcc = RCC_SUCCESS;
          }
       }
index 1a619fc..2240290 100644 (file)
@@ -1,3 +1,27 @@
+/* $Id: logindlg.h,v 1.2 2007-07-30 08:03:00 victor Exp $ */
+/* 
+** NetXMS - Network Management System
+** Portable management console
+** Copyright (C) 2007 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
+** the Free Software Foundation; either version 2 of the License, or
+** (at your option) any later version.
+**
+** This program is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+** GNU General Public License for more details.
+**
+** You should have received a copy of the GNU General Public License
+** along with this program; if not, write to the Free Software
+** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+**
+** File: logindlg.h
+**
+**/
+
 #ifndef _logindlg_h_
 #define _logindlg_h_
 
index 9a65934..3a9fb26 100644 (file)
@@ -140,20 +140,6 @@ int nxApp::OnExit()
 }
 
 
-//
-// Show client library error
-//
-
-void nxApp::ShowClientError(DWORD rcc, TCHAR *msgTemplate)
-{
-       TCHAR msg[4096];
-
-       _sntprintf(msg, 4096, msgTemplate, NXCGetErrorText(rcc));
-       wxLogMessage(msg);
-       wxMessageBox(msg, _T("NetXMS Console - Error"), wxOK | wxICON_ERROR, m_mainFrame);
-}
-
-
 //
 // Connect to server
 //
@@ -199,7 +185,7 @@ bool nxApp::Connect()
                }
                else
                {
-                       wxGetApp().ShowClientError(rcc, _T("Cannot establish session with management server: %s"));
+                       NXMCShowClientError(rcc, _T("Cannot establish session with management server: %s"));
                }
        } while(rcc != RCC_SUCCESS);
 
index 2046df7..3f7bd60 100644 (file)
@@ -105,8 +105,6 @@ public:
        virtual int OnExit();
 
        nxMainFrame *GetMainFrame(void) { return m_mainFrame; }
-
-       void ShowClientError(DWORD rcc, TCHAR *msgTemplate);
 };
 
 DECLARE_APP(nxApp)
index 69a4f10..a658ce9 100644 (file)
@@ -19,7 +19,7 @@
         <property name="relative_path">1</property>
         <property name="use_enum">0</property>
         <property name="use_microsoft_bom">0</property>
-        <object class="Frame" expanded="1">
+        <object class="Frame" expanded="0">
             <property name="bg"></property>
             <property name="center"></property>
             <property name="context_help"></property>
                 </object>
             </object>
         </object>
+        <object class="Dialog" expanded="1">
+            <property name="bg"></property>
+            <property name="center">wxBOTH</property>
+            <property name="context_help"></property>
+            <property name="enabled">1</property>
+            <property name="extra_style"></property>
+            <property name="fg"></property>
+            <property name="font"></property>
+            <property name="hidden">0</property>
+            <property name="id">wxID_ANY</property>
+            <property name="maximum_size"></property>
+            <property name="minimum_size"></property>
+            <property name="name">nxObjectSelDlg</property>
+            <property name="pos"></property>
+            <property name="size">508,387</property>
+            <property name="style">wxDEFAULT_DIALOG_STYLE</property>
+            <property name="subclass"></property>
+            <property name="title">Select Object</property>
+            <property name="tooltip"></property>
+            <property name="window_extra_style"></property>
+            <property name="window_style"></property>
+            <event name="OnActivate"></event>
+            <event name="OnActivateApp"></event>
+            <event name="OnChar"></event>
+            <event name="OnClose"></event>
+            <event name="OnEnterWindow"></event>
+            <event name="OnEraseBackground"></event>
+            <event name="OnHibernate"></event>
+            <event name="OnIconize"></event>
+            <event name="OnIdle"></event>
+            <event name="OnInitDialog"></event>
+            <event name="OnKeyDown"></event>
+            <event name="OnKeyUp"></event>
+            <event name="OnKillFocus"></event>
+            <event name="OnLeaveWindow"></event>
+            <event name="OnLeftDClick"></event>
+            <event name="OnLeftDown"></event>
+            <event name="OnLeftUp"></event>
+            <event name="OnMiddleDClick"></event>
+            <event name="OnMiddleDown"></event>
+            <event name="OnMiddleUp"></event>
+            <event name="OnMotion"></event>
+            <event name="OnMouseEvents"></event>
+            <event name="OnMouseWheel"></event>
+            <event name="OnPaint"></event>
+            <event name="OnRightDClick"></event>
+            <event name="OnRightDown"></event>
+            <event name="OnRightUp"></event>
+            <event name="OnSetFocus"></event>
+            <event name="OnSize"></event>
+            <event name="OnUpdateUI"></event>
+            <object class="wxBoxSizer" expanded="1">
+                <property name="minimum_size"></property>
+                <property name="name">bSizer5</property>
+                <property name="orient">wxHORIZONTAL</property>
+                <property name="permission">none</property>
+                <object class="sizeritem" expanded="1">
+                    <property name="border">5</property>
+                    <property name="flag">wxEXPAND</property>
+                    <property name="proportion">1</property>
+                    <object class="wxBoxSizer" expanded="1">
+                        <property name="minimum_size"></property>
+                        <property name="name">bSizer6</property>
+                        <property name="orient">wxVERTICAL</property>
+                        <property name="permission">none</property>
+                        <object class="sizeritem" expanded="1">
+                            <property name="border">7</property>
+                            <property name="flag">wxALL</property>
+                            <property name="proportion">0</property>
+                            <object class="wxStaticText" expanded="1">
+                                <property name="bg"></property>
+                                <property name="context_help"></property>
+                                <property name="enabled">1</property>
+                                <property name="fg"></property>
+                                <property name="font"></property>
+                                <property name="hidden">0</property>
+                                <property name="id">wxID_ANY</property>
+                                <property name="label">Object list</property>
+                                <property name="maximum_size"></property>
+                                <property name="minimum_size"></property>
+                                <property name="name">m_staticText7</property>
+                                <property name="permission">protected</property>
+                                <property name="pos"></property>
+                                <property name="size"></property>
+                                <property name="style"></property>
+                                <property name="subclass"></property>
+                                <property name="tooltip"></property>
+                                <property name="window_extra_style"></property>
+                                <property name="window_style"></property>
+                                <property name="wrap">-1</property>
+                                <event name="OnUpdateUI"></event>
+                            </object>
+                        </object>
+                        <object class="sizeritem" expanded="1">
+                            <property name="border">7</property>
+                            <property name="flag">wxBOTTOM|wxEXPAND|wxLEFT|wxRIGHT</property>
+                            <property name="proportion">1</property>
+                            <object class="wxListCtrl" expanded="1">
+                                <property name="bg"></property>
+                                <property name="context_help"></property>
+                                <property name="enabled">1</property>
+                                <property name="fg"></property>
+                                <property name="font"></property>
+                                <property name="hidden">0</property>
+                                <property name="id">wxID_ANY</property>
+                                <property name="maximum_size"></property>
+                                <property name="minimum_size">-1,-1</property>
+                                <property name="name">wndListCtrl</property>
+                                <property name="permission">protected</property>
+                                <property name="pos"></property>
+                                <property name="size">400,320</property>
+                                <property name="style">wxLC_REPORT</property>
+                                <property name="subclass"></property>
+                                <property name="tooltip"></property>
+                                <property name="window_extra_style"></property>
+                                <property name="window_style"></property>
+                                <event name="OnListBeginDrag"></event>
+                                <event name="OnListBeginLabelEdit"></event>
+                                <event name="OnListBeginRDrag"></event>
+                                <event name="OnListCacheHint"></event>
+                                <event name="OnListColBeginDrag"></event>
+                                <event name="OnListColClick"></event>
+                                <event name="OnListColDragging"></event>
+                                <event name="OnListColEndDrag"></event>
+                                <event name="OnListColRightClick"></event>
+                                <event name="OnListDeleteAllItems"></event>
+                                <event name="OnListDeleteItem"></event>
+                                <event name="OnListEndLabelEdit"></event>
+                                <event name="OnListInsertItem"></event>
+                                <event name="OnListItemActivated"></event>
+                                <event name="OnListItemDeselected"></event>
+                                <event name="OnListItemFocused"></event>
+                                <event name="OnListItemMiddleClick"></event>
+                                <event name="OnListItemRightClick"></event>
+                                <event name="OnListItemSelected"></event>
+                                <event name="OnListKeyDown"></event>
+                                <event name="OnUpdateUI"></event>
+                            </object>
+                        </object>
+                    </object>
+                </object>
+                <object class="sizeritem" expanded="1">
+                    <property name="border">5</property>
+                    <property name="flag">wxEXPAND</property>
+                    <property name="proportion">0</property>
+                    <object class="wxBoxSizer" expanded="1">
+                        <property name="minimum_size"></property>
+                        <property name="name">bSizer7</property>
+                        <property name="orient">wxVERTICAL</property>
+                        <property name="permission">none</property>
+                        <object class="sizeritem" expanded="1">
+                            <property name="border">5</property>
+                            <property name="flag">wxALL</property>
+                            <property name="proportion">0</property>
+                            <object class="wxButton" expanded="1">
+                                <property name="bg"></property>
+                                <property name="context_help"></property>
+                                <property name="enabled">1</property>
+                                <property name="fg"></property>
+                                <property name="font"></property>
+                                <property name="hidden">0</property>
+                                <property name="id">wxID_OK</property>
+                                <property name="label">&amp;OK</property>
+                                <property name="maximum_size"></property>
+                                <property name="minimum_size"></property>
+                                <property name="name">wxID_OK</property>
+                                <property name="permission">protected</property>
+                                <property name="pos"></property>
+                                <property name="size"></property>
+                                <property name="style"></property>
+                                <property name="subclass"></property>
+                                <property name="tooltip"></property>
+                                <property name="window_extra_style"></property>
+                                <property name="window_style"></property>
+                                <event name="OnButtonClick"></event>
+                                <event name="OnUpdateUI"></event>
+                            </object>
+                        </object>
+                        <object class="sizeritem" expanded="1">
+                            <property name="border">5</property>
+                            <property name="flag">wxALL</property>
+                            <property name="proportion">0</property>
+                            <object class="wxButton" expanded="1">
+                                <property name="bg"></property>
+                                <property name="context_help"></property>
+                                <property name="enabled">1</property>
+                                <property name="fg"></property>
+                                <property name="font"></property>
+                                <property name="hidden">0</property>
+                                <property name="id">wxID_CANCEL</property>
+                                <property name="label">&amp;Cancel</property>
+                                <property name="maximum_size"></property>
+                                <property name="minimum_size"></property>
+                                <property name="name">wxID_CANCEL</property>
+                                <property name="permission">protected</property>
+                                <property name="pos"></property>
+                                <property name="size"></property>
+                                <property name="style"></property>
+                                <property name="subclass"></property>
+                                <property name="tooltip"></property>
+                                <property name="window_extra_style"></property>
+                                <property name="window_style"></property>
+                                <event name="OnButtonClick"></event>
+                                <event name="OnUpdateUI"></event>
+                            </object>
+                        </object>
+                        <object class="sizeritem" expanded="1">
+                            <property name="border">5</property>
+                            <property name="flag">wxALL</property>
+                            <property name="proportion">0</property>
+                            <object class="wxButton" expanded="1">
+                                <property name="bg"></property>
+                                <property name="context_help"></property>
+                                <property name="enabled">1</property>
+                                <property name="fg"></property>
+                                <property name="font"></property>
+                                <property name="hidden">0</property>
+                                <property name="id">wxID_ANY</property>
+                                <property name="label">&amp;None</property>
+                                <property name="maximum_size"></property>
+                                <property name="minimum_size"></property>
+                                <property name="name">btnNone</property>
+                                <property name="permission">protected</property>
+                                <property name="pos"></property>
+                                <property name="size"></property>
+                                <property name="style"></property>
+                                <property name="subclass"></property>
+                                <property name="tooltip"></property>
+                                <property name="window_extra_style"></property>
+                                <property name="window_style"></property>
+                                <event name="OnButtonClick"></event>
+                                <event name="OnUpdateUI"></event>
+                            </object>
+                        </object>
+                    </object>
+                </object>
+            </object>
+        </object>
     </object>
 </wxFormBuilder_Project>
index 848f2f5..40892c3 100644 (file)
@@ -60,7 +60,7 @@
                        <style>normal</style>
                        <weight>normal</weight>
                        <underlined>0</underlined>
-                       <face>sans</face>
+                       <face>MS Sans Serif</face>
                </font>
                <title>About</title>
                <centered>1</centered>
                                                <style>normal</style>
                                                <weight>normal</weight>
                                                <underlined>0</underlined>
-                                               <face>sans</face>
+                                               <face>MS Sans Serif</face>
                                        </font>
                                        <bitmap>login.png</bitmap>
                                </object>
                        </object>
                </object>
        </object>
+       <object class="wxDialog" name="nxObjectSelDlg">
+               <style>wxDEFAULT_DIALOG_STYLE</style>
+               <size>508,387</size>
+               <title>Select Object</title>
+               <centered>1</centered>
+               <object class="wxBoxSizer">
+                       <orient>wxHORIZONTAL</orient>
+                       <object class="sizeritem">
+                               <option>1</option>
+                               <flag>wxEXPAND</flag>
+                               <border>5</border>
+                               <object class="wxBoxSizer">
+                                       <orient>wxVERTICAL</orient>
+                                       <object class="sizeritem">
+                                               <option>0</option>
+                                               <flag>wxALL</flag>
+                                               <border>7</border>
+                                               <object class="wxStaticText" name="m_staticText7">
+                                                       <label>Object list</label>
+                                               </object>
+                                       </object>
+                                       <object class="sizeritem">
+                                               <option>1</option>
+                                               <flag>wxBOTTOM|wxEXPAND|wxLEFT|wxRIGHT</flag>
+                                               <border>7</border>
+                                               <object class="wxListCtrl" name="wndListCtrl">
+                                                       <style>wxLC_REPORT</style>
+                                                       <size>400,320</size>
+                                               </object>
+                                       </object>
+                               </object>
+                       </object>
+                       <object class="sizeritem">
+                               <option>0</option>
+                               <flag>wxEXPAND</flag>
+                               <border>5</border>
+                               <object class="wxBoxSizer">
+                                       <orient>wxVERTICAL</orient>
+                                       <object class="sizeritem">
+                                               <option>0</option>
+                                               <flag>wxALL</flag>
+                                               <border>5</border>
+                                               <object class="wxButton" name="wxID_OK">
+                                                       <label>_OK</label>
+                                                       <default>0</default>
+                                               </object>
+                                       </object>
+                                       <object class="sizeritem">
+                                               <option>0</option>
+                                               <flag>wxALL</flag>
+                                               <border>5</border>
+                                               <object class="wxButton" name="wxID_CANCEL">
+                                                       <label>_Cancel</label>
+                                                       <default>0</default>
+                                               </object>
+                                       </object>
+                                       <object class="sizeritem">
+                                               <option>0</option>
+                                               <flag>wxALL</flag>
+                                               <border>5</border>
+                                               <object class="wxButton" name="btnNone">
+                                                       <label>_None</label>
+                                                       <default>0</default>
+                                               </object>
+                                       </object>
+                               </object>
+                       </object>
+               </object>
+       </object>
 </resource>
index 7fe90d8..7549a61 100644 (file)
@@ -273,7 +273,7 @@ static int wxCALLBACK CompareAlarms(long item1, long item2, long sortData)
 
 
 //
-// Sort aarm list
+// Sort alarm list
 //
 
 void nxAlarmView::SortAlarmList()
@@ -456,4 +456,3 @@ void nxAlarmView::OnAlarmDelete(wxCommandEvent &event)
        }
        DoRequestArg2((void *)DeleteAlarms, count, CAST_FROM_POINTER(idList, wxUIntPtr));
 }
-
index 6d9027e..7f4fc9e 100644 (file)
@@ -43,6 +43,8 @@ BEGIN_EVENT_TABLE(nxObjectBrowser, nxView)
        EVT_TREE_SEL_CHANGED(wxID_TREE_CTRL, nxObjectBrowser::OnTreeSelChanged)
        EVT_TREE_DELETE_ITEM(wxID_TREE_CTRL, nxObjectBrowser::OnTreeDeleteItem)
        EVT_TREE_ITEM_MENU(wxID_TREE_CTRL, nxObjectBrowser::OnTreeItemMenu)
+       EVT_MENU(XRCID("menuObjectBind"), nxObjectBrowser::OnObjectBind)
+       EVT_UPDATE_UI(XRCID("menuObjectBind"), nxObjectBrowser::OnUpdateUIObjectBind)
 END_EVENT_TABLE()
 
 
@@ -65,6 +67,7 @@ nxObjectBrowser::nxObjectBrowser()
        m_wndSplitter->SplitVertically(m_wndTreeCtrl, m_wndObjectView, 250);
        RegisterUniqueView(_T("objectbrowser"), this);
        m_isFirstResize = true;
+       m_currentObject = NULL;
 
        wxCommandEvent event(nxEVT_REFRESH_VIEW);
        AddPendingEvent(event);
@@ -210,7 +213,8 @@ void nxObjectBrowser::OnTreeSelChanged(wxTreeEvent &event)
        wxTreeItemId item;
 
        item = event.GetItem();
-       m_wndObjectView->SetObject(((nxObjectTreeItemData *)m_wndTreeCtrl->GetItemData(item))->GetObject());
+       m_currentObject = ((nxObjectTreeItemData *)m_wndTreeCtrl->GetItemData(item))->GetObject();
+       m_wndObjectView->SetObject(m_currentObject);
        m_wndTreeCtrl->SetFocus();   // Return focus to tree control
 }
 
@@ -415,3 +419,54 @@ void nxObjectBrowser::OnTreeItemMenu(wxTreeEvent &event)
        }
 }
 
+
+//
+// Handlers for Object->Bind menu
+//
+
+static DWORD BindObjects(DWORD parentId, wxArrayLong *childList)
+{
+       size_t i, count;
+       DWORD rcc;
+       NXC_SESSION session = NXMCGetSession();
+
+       count = childList->GetCount();
+       for(i = 0; i < count; i++)
+       {
+               rcc = NXCBindObject(session, parentId, childList->Item(i));
+               if (rcc != RCC_SUCCESS)
+                       break;
+       }
+       delete childList;
+       return rcc;
+}
+
+void nxObjectBrowser::OnObjectBind(wxCommandEvent &event)
+{
+       if ((m_currentObject != NULL) &&
+                ((m_currentObject->iClass == OBJECT_SERVICEROOT) ||
+                 (m_currentObject->iClass == OBJECT_CONTAINER)))
+       {
+               nxObjectSelDlg dlg(this);
+
+               dlg.m_isSingleSelection = false;
+               dlg.m_allowedClasses = SCL_SUBNET | SCL_NODE | SCL_CONTAINER | SCL_CONDITION;
+               if (dlg.ShowModal() == wxID_OK)
+               {
+                       DoRequestArg2(BindObjects, m_currentObject->dwId, CAST_FROM_POINTER(new wxArrayLong(dlg.m_objectList), wxUIntPtr));
+               }
+       }
+}
+
+void nxObjectBrowser::OnUpdateUIObjectBind(wxUpdateUIEvent &event)
+{
+       if (m_currentObject == NULL)
+       {
+               event.Enable(false);
+       }
+       else
+       {
+               event.Enable((m_currentObject->iClass == OBJECT_SERVICEROOT) ||
+                            (m_currentObject->iClass == OBJECT_CONTAINER));
+       }
+}
index d766373..6b10196 100644 (file)
@@ -38,17 +38,6 @@ WX_DECLARE_OBJARRAY(wxTreeItemId, nxTreeItemList);
 WX_DECLARE_HASH_MAP(DWORD, nxTreeItemList*, wxIntegerHash, wxIntegerEqual, nxObjectItemsHash);
 
 
-//
-// libnxcl object index structure
-//
-
-struct NXC_OBJECT_INDEX
-{
-   DWORD key;
-   NXC_OBJECT *object;
-};
-
-
 //
 // Header for object overview
 //
@@ -153,6 +142,7 @@ private:
        nxObjectView *m_wndObjectView;
        bool m_isFirstResize;
        nxObjectItemsHash m_objectItemsHash;
+       NXC_OBJECT *m_currentObject;
        
        void AddObjectToTree(NXC_OBJECT *object, wxTreeItemId &root);
        void ClearObjectItemsHash();
@@ -170,9 +160,10 @@ protected:
        void OnTreeDeleteItem(wxTreeEvent &event);
        void OnTreeItemMenu(wxTreeEvent &event);
        void OnObjectChange(wxCommandEvent &event);
+       void OnObjectBind(wxCommandEvent &event);
+       void OnUpdateUIObjectBind(wxUpdateUIEvent &event);
 
        DECLARE_EVENT_TABLE()
 };
 
 #endif
-