- CFlatButton moved to UI library
authorVictor Kirhenshtein <victor@netxms.org>
Mon, 9 Jan 2006 21:48:10 +0000 (21:48 +0000)
committerVictor Kirhenshtein <victor@netxms.org>
Mon, 9 Jan 2006 21:48:10 +0000 (21:48 +0000)
- Half-finished script manager

34 files changed:
.gitattributes
include/nxwinui.h
sql/Makefile.am
src/console/nxav/InfoLine.h
src/console/nxav/globals.cpp
src/console/nxav/globals.h
src/console/nxav/nxav.clw
src/console/nxav/nxav.dsp
src/console/nxuilib/FlatButton.cpp [moved from src/console/nxav/FlatButton.cpp with 99% similarity]
src/console/nxuilib/FlatButton.h [moved from src/console/nxav/FlatButton.h with 90% similarity]
src/console/nxuilib/Makefile.am
src/console/nxuilib/nxuilib.clw
src/console/nxuilib/nxuilib.cpp
src/console/nxuilib/nxuilib.dsp
src/console/win32/ControlPanel.cpp
src/console/win32/Makefile.am
src/console/win32/ScriptManager.cpp [new file with mode: 0644]
src/console/win32/ScriptManager.h [new file with mode: 0644]
src/console/win32/ScriptView.cpp [new file with mode: 0644]
src/console/win32/ScriptView.h [new file with mode: 0644]
src/console/win32/globals.h
src/console/win32/icons/Makefile.am
src/console/win32/icons/folder_c.ico [new file with mode: 0644]
src/console/win32/icons/folder_o.ico [new file with mode: 0644]
src/console/win32/icons/script.ico [new file with mode: 0644]
src/console/win32/icons/script_library.ico [new file with mode: 0644]
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
src/server/core/session.cpp

index 69966ae..9220fe6 100644 (file)
@@ -384,8 +384,6 @@ src/console/cmdline/nxcmd.dsw -text
 src/console/cmdline/nxcmd.h -text
 src/console/nxav/AlarmBrowser.cpp -text
 src/console/nxav/AlarmBrowser.h -text
-src/console/nxav/FlatButton.cpp -text
-src/console/nxav/FlatButton.h -text
 src/console/nxav/InfoLine.cpp -text
 src/console/nxav/InfoLine.h -text
 src/console/nxav/MainFrm.cpp -text
@@ -427,6 +425,8 @@ src/console/nxav/resource.h -text
 src/console/nxav/tools.cpp -text
 src/console/nxuilib/AlarmSoundDlg.cpp -text
 src/console/nxuilib/AlarmSoundDlg.h -text
+src/console/nxuilib/FlatButton.cpp -text
+src/console/nxuilib/FlatButton.h -text
 src/console/nxuilib/LoginDialog.cpp -text
 src/console/nxuilib/LoginDialog.h -text
 src/console/nxuilib/Makefile.am -text
@@ -632,6 +632,10 @@ src/console/win32/RuleSeverityDlg.cpp -text
 src/console/win32/RuleSeverityDlg.h -text
 src/console/win32/SaveDesktopDlg.cpp -text
 src/console/win32/SaveDesktopDlg.h -text
+src/console/win32/ScriptManager.cpp -text
+src/console/win32/ScriptManager.h -text
+src/console/win32/ScriptView.cpp -text
+src/console/win32/ScriptView.h -text
 src/console/win32/ServerCfgEditor.cpp -text
 src/console/win32/ServerCfgEditor.h -text
 src/console/win32/StdAfx.cpp -text
@@ -692,6 +696,8 @@ src/console/win32/icons/document.ico -text
 src/console/win32/icons/e-mail.ico -text
 src/console/win32/icons/editor.ico -text
 src/console/win32/icons/exec.ico -text
+src/console/win32/icons/folder_c.ico -text
+src/console/win32/icons/folder_o.ico -text
 src/console/win32/icons/graph.ico -text
 src/console/win32/icons/iexplore.ico -text
 src/console/win32/icons/log.ico -text
@@ -712,6 +718,8 @@ src/console/win32/icons/pending.ico -text
 src/console/win32/icons/question.ico -text
 src/console/win32/icons/rexec.ico -text
 src/console/win32/icons/running.ico -text
+src/console/win32/icons/script.ico -text
+src/console/win32/icons/script_library.ico -text
 src/console/win32/icons/setup.ico -text
 src/console/win32/icons/sms.ico -text
 src/console/win32/icons/sort_up.ico -text
index 39f7207..69a6b3a 100644 (file)
@@ -67,6 +67,7 @@ typedef struct
 
 #include "../src/console/nxuilib/resource.h"
 #include "../src/console/nxuilib/LoginDialog.h"
+#include "../src/console/nxuilib/FlatButton.h"
 
 
 //
index 2cdcead..300acc3 100644 (file)
@@ -35,4 +35,4 @@ clean:
 EXTRA_DIST = \
        $(sql_DATA) \
        dbinit.in events.in images.in \
-       policy.in schema.in setup.in traps.in objtools.in
+       policy.in schema.in setup.in traps.in objtools.in scripts.in
index d44eb11..5e1f498 100644 (file)
@@ -6,7 +6,6 @@
 #endif // _MSC_VER > 1000
 // InfoLine.h : header file
 //
-#include "FlatButton.h"
 
 /////////////////////////////////////////////////////////////////////////////
 // CInfoLine window
index 318c3c5..946096c 100644 (file)
@@ -61,6 +61,4 @@ TCHAR g_szWorkDir[MAX_PATH];
 // Colors
 //
 
-COLORREF g_rgbInfoLineButtons = RGB(130, 70, 210);
-COLORREF g_rgbInfoLineBackground = RGB(255, 255, 255);
 COLORREF g_rgbInfoLineTimer = RGB(0, 0, 0);
index 7e62b3c..6e94c28 100644 (file)
@@ -69,8 +69,6 @@ extern TCHAR g_szPassword[];
 extern TCHAR *g_szStatusText[];
 extern TCHAR *g_szStatusTextSmall[];
 extern TCHAR g_szWorkDir[];
-extern COLORREF g_rgbInfoLineButtons;
-extern COLORREF g_rgbInfoLineBackground;
 extern COLORREF g_rgbInfoLineTimer;
 extern DWORD g_dwOptions;
 extern MONITORINFOEX *g_pMonitorList;
index b713a3f..c692f23 100644 (file)
@@ -8,7 +8,7 @@ NewFileInclude1=#include "stdafx.h"
 NewFileInclude2=#include "nxav.h"
 LastPage=0
 
-ClassCount=10
+ClassCount=9
 Class1=CAlarmViewApp
 Class3=CMainFrame
 Class4=CAboutDlg
@@ -22,8 +22,7 @@ Class6=CInfoLine
 Class7=CRequestProcessingDlg
 Resource3=IDD_ABOUTBOX (English (U.S.))
 Resource4=IDR_MAINFRAME
-Class9=CFlatButton
-Class10=CSettingsDlg
+Class9=CSettingsDlg
 Resource5=IDM_CONTEXT
 Resource7=IDD_REQUEST_WAIT (English (U.S.))
 Resource8=IDR_MAINFRAME (English (U.S.))
@@ -135,15 +134,6 @@ BaseClass=CHtmlView
 Filter=W
 VirtualFilter=7VWC
 
-[CLS:CFlatButton]
-Type=0
-HeaderFile=FlatButton.h
-ImplementationFile=FlatButton.cpp
-BaseClass=CWnd
-Filter=W
-VirtualFilter=WC
-LastObject=CFlatButton
-
 [ACL:IDR_MAINFRAME (English (U.S.))]
 Type=1
 Class=?
index ebb1c6c..4a4316f 100644 (file)
@@ -110,10 +110,6 @@ SOURCE=.\comm.cpp
 # End Source File
 # Begin Source File
 
-SOURCE=.\FlatButton.cpp
-# End Source File
-# Begin Source File
-
 SOURCE=.\globals.cpp
 # End Source File
 # Begin Source File
@@ -159,10 +155,6 @@ SOURCE=.\AlarmBrowser.h
 # End Source File
 # Begin Source File
 
-SOURCE=.\FlatButton.h
-# End Source File
-# Begin Source File
-
 SOURCE=.\globals.h
 # End Source File
 # Begin Source File
similarity index 99%
rename from src/console/nxav/FlatButton.cpp
rename to src/console/nxuilib/FlatButton.cpp
index a0f2519..320bce4 100644 (file)
@@ -2,7 +2,7 @@
 //
 
 #include "stdafx.h"
-#include "nxav.h"
+#include "nxuilib.h"
 #include "FlatButton.h"
 
 #ifdef _DEBUG
similarity index 90%
rename from src/console/nxav/FlatButton.h
rename to src/console/nxuilib/FlatButton.h
index 7769966..0813018 100644 (file)
@@ -7,10 +7,14 @@
 // FlatButton.h : header file
 //
 
+extern NXUILIB_EXPORTABLE COLORREF g_rgbInfoLineButtons;
+extern NXUILIB_EXPORTABLE COLORREF g_rgbInfoLineBackground;
+
+
 /////////////////////////////////////////////////////////////////////////////
 // CFlatButton window
 
-class CFlatButton : public CWnd
+class NXUILIB_EXPORTABLE CFlatButton : public CWnd
 {
 // Construction
 public:
index 23ec5fd..1bb65e6 100644 (file)
@@ -11,6 +11,7 @@
 SUBDIRS = res sounds
 EXTRA_DIST = \
        AlarmSoundDlg.cpp AlarmSoundDlg.h \
+       FlatButton.cpp FlatButton.h \
        LoginDialog.cpp LoginDialog.h \
        nxuilib.clw \
        nxuilib.cpp \
index 587e523..978ddc5 100644 (file)
@@ -2,15 +2,16 @@
 
 [General Info]
 Version=1
-ClassCount=2
+ClassCount=3
 ResourceCount=2
 NewFileInclude1=#include "stdafx.h"
 Class1=CLoginDialog
-LastClass=CAlarmSoundDlg
+LastClass=CFlatButton
 Resource1=IDD_LOGIN (English (U.S.))
 Class2=CAlarmSoundDlg
 LastTemplate=CDialog
 Resource2=IDD_ALARM_SOUNDS (English (U.S.))
+Class3=CFlatButton
 
 [DLG:IDD_LOGIN (English (U.S.))]
 Type=1
@@ -78,3 +79,12 @@ Filter=D
 LastObject=CAlarmSoundDlg
 VirtualFilter=dWC
 
+[CLS:CFlatButton]
+Type=0
+HeaderFile=FlatButton.h
+ImplementationFile=FlatButton.cpp
+BaseClass=CWnd
+Filter=W
+VirtualFilter=WC
+LastObject=CFlatButton
+
index a46a2c7..9d3db3f 100644 (file)
@@ -26,6 +26,8 @@ int g_nSoundId[] = { IDR_SND_ALARM1, IDR_SND_ALARM2, IDR_SND_BEEP,
                      IDR_SND_MISC4, IDR_SND_MISC5, IDR_SND_RING1,
                      IDR_SND_RING2, IDR_SND_SIREN1, IDR_SND_SIREN2, 0 };
 HINSTANCE g_hInstance;
+COLORREF g_rgbInfoLineButtons = RGB(130, 70, 210);
+COLORREF g_rgbInfoLineBackground = RGB(255, 255, 255);
 
 
 //
index ff67f17..a9b459d 100644 (file)
@@ -106,6 +106,10 @@ SOURCE=.\AlarmSoundDlg.cpp
 # End Source File
 # Begin Source File
 
+SOURCE=.\FlatButton.cpp
+# End Source File
+# Begin Source File
+
 SOURCE=.\LoginDialog.cpp
 # End Source File
 # Begin Source File
@@ -143,6 +147,10 @@ SOURCE=.\AlarmSoundDlg.h
 # End Source File
 # Begin Source File
 
+SOURCE=.\FlatButton.h
+# End Source File
+# Begin Source File
+
 SOURCE=.\LoginDialog.h
 # End Source File
 # Begin Source File
index cefc9e5..31865bf 100644 (file)
@@ -95,6 +95,7 @@ int CControlPanel::OnCreate(LPCREATESTRUCT lpCreateStruct)
    m_pImageList->Add(AfxGetApp()->LoadIcon(IDI_SETUP));
    m_pImageList->Add(AfxGetApp()->LoadIcon(IDI_LPP));
    m_pImageList->Add(AfxGetApp()->LoadIcon(IDI_OBJTOOLS));
+   m_pImageList->Add(AfxGetApp()->LoadIcon(IDI_SCRIPT_LIBRARY));
    m_wndListCtrl.SetImageList(m_pImageList, LVSIL_NORMAL);
 
    // Populate list with items
@@ -107,6 +108,7 @@ int CControlPanel::OnCreate(LPCREATESTRUCT lpCreateStruct)
    AddItem("Server Configuration", 6, ID_CONTROLPANEL_SERVERCFG);
    //AddItem("Log Processing", 7, ID_CONTROLPANEL_LOGPROCESSING);
    AddItem("Object Tools", 8, ID_CONTROLPANEL_OBJECTTOOLS);
+   AddItem("Script Library", 9, ID_CONTROLPANEL_SCRIPTLIBRARY);
 
    m_wndListCtrl.SortItems(CompareItems, (DWORD)&m_wndListCtrl);
 
index bf4d105..cdf3853 100644 (file)
@@ -94,6 +94,8 @@ EXTRA_DIST = \
        RuleHeader.cpp RuleHeader.h \
        RuleList.cpp RuleList.h \
        RuleSeverityDlg.cpp RuleSeverityDlg.h \
+       ScriptManager.cpp ScriptManager.h \
+       ScriptView.cpp ScriptView.h \
        ServerCfgEditor.cpp ServerCfgEditor.h \
        StdAfx.cpp StdAfx.h \
        SyslogBrowser.cpp SyslogBrowser.h \
diff --git a/src/console/win32/ScriptManager.cpp b/src/console/win32/ScriptManager.cpp
new file mode 100644 (file)
index 0000000..6b06931
--- /dev/null
@@ -0,0 +1,195 @@
+// ScriptManager.cpp : implementation file
+//
+
+#include "stdafx.h"
+#include "nxcon.h"
+#include "ScriptManager.h"
+
+#ifdef _DEBUG
+#define new DEBUG_NEW
+#undef THIS_FILE
+static char THIS_FILE[] = __FILE__;
+#endif
+
+/////////////////////////////////////////////////////////////////////////////
+// CScriptManager
+
+IMPLEMENT_DYNCREATE(CScriptManager, CMDIChildWnd)
+
+CScriptManager::CScriptManager()
+{
+}
+
+CScriptManager::~CScriptManager()
+{
+}
+
+
+BEGIN_MESSAGE_MAP(CScriptManager, CMDIChildWnd)
+       //{{AFX_MSG_MAP(CScriptManager)
+       ON_WM_CREATE()
+       ON_WM_DESTROY()
+       ON_WM_SIZE()
+       ON_WM_SETFOCUS()
+       ON_COMMAND(ID_VIEW_REFRESH, OnViewRefresh)
+       //}}AFX_MSG_MAP
+   ON_NOTIFY(TVN_SELCHANGED, AFX_IDW_PANE_FIRST, OnTreeViewSelChange)
+END_MESSAGE_MAP()
+
+/////////////////////////////////////////////////////////////////////////////
+// CScriptManager message handlers
+
+BOOL CScriptManager::PreCreateWindow(CREATESTRUCT& cs) 
+{
+   if (cs.lpszClass == NULL)
+      cs.lpszClass = AfxRegisterWndClass(CS_HREDRAW | CS_VREDRAW, 
+                                         NULL, 
+                                         GetSysColorBrush(COLOR_WINDOW), 
+                                         AfxGetApp()->LoadIcon(IDI_SCRIPT_LIBRARY));
+       return CMDIChildWnd::PreCreateWindow(cs);
+}
+
+
+//
+// WM_CREATE message handler
+//
+
+int CScriptManager::OnCreate(LPCREATESTRUCT lpCreateStruct) 
+{
+   RECT rect = { 0, 0, 100, 100 };
+
+       if (CMDIChildWnd::OnCreate(lpCreateStruct) == -1)
+               return -1;
+       
+   theApp.OnViewCreate(IDR_SCRIPT_MANAGER, this);
+
+   // Create image list
+   m_imageList.Create(16, 16, ILC_COLOR8 | ILC_MASK, 4, 4);
+   m_imageList.Add(AfxGetApp()->LoadIcon(IDI_SCRIPT_LIBRARY));
+   m_imageList.Add(AfxGetApp()->LoadIcon(IDI_CLOSED_FOLDER));
+   m_imageList.Add(AfxGetApp()->LoadIcon(IDI_OPEN_FOLDER));
+   m_imageList.Add(AfxGetApp()->LoadIcon(IDI_SCRIPT));
+
+   // Create splitter
+   m_wndSplitter.CreateStatic(this, 1, 2, WS_CHILD | WS_VISIBLE, IDC_SPLITTER);
+
+   // Create tree view control
+   m_wndTreeCtrl.Create(WS_CHILD | WS_VISIBLE | TVS_HASLINES | TVS_LINESATROOT | TVS_HASBUTTONS | TVS_SHOWSELALWAYS,
+                        rect, &m_wndSplitter, m_wndSplitter.IdFromRowCol(0, 0));
+   m_wndTreeCtrl.SetImageList(&m_imageList, TVSIL_NORMAL);
+
+   // Create script view
+   m_wndScriptView.Create(NULL, NULL, WS_CHILD | WS_VISIBLE, rect,
+                          &m_wndSplitter, m_wndSplitter.IdFromRowCol(0, 1));
+       
+   // Finish splitter setup
+   m_wndSplitter.SetColumnInfo(0, 150, 50);
+   m_wndSplitter.InitComplete();
+   m_wndSplitter.RecalcLayout();
+
+   PostMessage(WM_COMMAND, ID_VIEW_REFRESH, 0);
+
+       return 0;
+}
+
+
+//
+// WM_DESTROY message handler
+//
+
+void CScriptManager::OnDestroy() 
+{
+   theApp.OnViewDestroy(IDR_SCRIPT_MANAGER, this);
+       CMDIChildWnd::OnDestroy();
+}
+
+
+//
+// WM_SIZE message handler
+//
+
+void CScriptManager::OnSize(UINT nType, int cx, int cy) 
+{
+       CMDIChildWnd::OnSize(nType, cx, cy);
+   m_wndSplitter.SetWindowPos(NULL, 0, 0, cx, cy, SWP_NOZORDER);
+}
+
+
+//
+// WM_SETFOCUS message handler
+//
+
+void CScriptManager::OnSetFocus(CWnd* pOldWnd) 
+{
+       CMDIChildWnd::OnSetFocus(pOldWnd);
+       
+       // TODO: Add your message handler code here
+       
+}
+
+
+//
+// WM_COMMAND::ID_VIEW_REFRESH message handler
+//
+
+void CScriptManager::OnViewRefresh() 
+{
+   DWORD i, dwResult, dwNumScripts;
+   TCHAR *pszCurr, *pszNext;
+   HTREEITEM hRoot, hItem, hNextItem;
+   NXC_SCRIPT_INFO *pList;
+
+   m_wndTreeCtrl.DeleteAllItems();
+   hRoot = m_wndTreeCtrl.InsertItem(_T("[root]"), 0, 0);
+
+   dwResult = DoRequestArg3(NXCGetScriptList, g_hSession, &dwNumScripts,
+                            &pList, _T("Loading list of scripts..."));
+   if (dwResult == RCC_SUCCESS)
+   {
+      for(i = 0; i < dwNumScripts; i++)
+      {
+         for(pszCurr = pList[i].szName, hItem = hRoot; ;
+             pszCurr = pszNext + 2, hItem = hNextItem)
+         {
+            pszNext = _tcsstr(pszCurr, _T("::"));
+            if (pszNext == NULL)
+               break;
+            *pszNext = 0;
+            hNextItem = FindTreeCtrlItem(m_wndTreeCtrl, hItem, pszCurr);
+            if (hNextItem == NULL)
+            {
+               hNextItem = m_wndTreeCtrl.InsertItem(pszCurr, 1, 1, hItem);
+               m_wndTreeCtrl.SetItemData(hNextItem, 0);
+            }
+         }
+         hItem = m_wndTreeCtrl.InsertItem(pszCurr, 3, 3, hItem);
+         m_wndTreeCtrl.SetItemData(hItem, pList[i].dwId);
+      }
+      safe_free(pList);
+   }
+   else
+   {
+      theApp.ErrorBox(dwResult, _T("Cannot load list of scripts: %s"));
+   }
+}
+
+
+//
+// WM_NOTIFY::TVN_SELCHANGED message handler
+//
+
+void CScriptManager::OnTreeViewSelChange(LPNMTREEVIEW lpnmt, LRESULT *pResult)
+{
+   DWORD dwId;
+
+   dwId = m_wndTreeCtrl.GetItemData(lpnmt->itemNew.hItem);
+   if (dwId != 0)
+   {
+      m_wndScriptView.SetEditMode(dwId);
+   }
+   else
+   {
+      m_wndScriptView.SetListMode(m_wndTreeCtrl, lpnmt->itemNew.hItem);
+   }
+   *pResult = 0;
+}
diff --git a/src/console/win32/ScriptManager.h b/src/console/win32/ScriptManager.h
new file mode 100644 (file)
index 0000000..f62b04c
--- /dev/null
@@ -0,0 +1,59 @@
+#if !defined(AFX_SCRIPTMANAGER_H__CC6DCB34_1291_4DC4_9137_47CFCFF95555__INCLUDED_)
+#define AFX_SCRIPTMANAGER_H__CC6DCB34_1291_4DC4_9137_47CFCFF95555__INCLUDED_
+
+#include "AdvSplitter.h"       // Added by ClassView
+#include "ScriptView.h"        // Added by ClassView
+#if _MSC_VER > 1000
+#pragma once
+#endif // _MSC_VER > 1000
+// ScriptManager.h : header file
+//
+
+/////////////////////////////////////////////////////////////////////////////
+// CScriptManager frame
+
+class CScriptManager : public CMDIChildWnd
+{
+       DECLARE_DYNCREATE(CScriptManager)
+protected:
+       CScriptManager();           // protected constructor used by dynamic creation
+
+// Attributes
+public:
+
+// Operations
+public:
+
+// Overrides
+       // ClassWizard generated virtual function overrides
+       //{{AFX_VIRTUAL(CScriptManager)
+       protected:
+       virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
+       //}}AFX_VIRTUAL
+
+// Implementation
+protected:
+       CImageList m_imageList;
+       CScriptView m_wndScriptView;
+       CTreeCtrl m_wndTreeCtrl;
+       CAdvSplitter m_wndSplitter;
+       virtual ~CScriptManager();
+
+       // Generated message map functions
+       //{{AFX_MSG(CScriptManager)
+       afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
+       afx_msg void OnDestroy();
+       afx_msg void OnSize(UINT nType, int cx, int cy);
+       afx_msg void OnSetFocus(CWnd* pOldWnd);
+       afx_msg void OnViewRefresh();
+       //}}AFX_MSG
+   afx_msg void OnTreeViewSelChange(LPNMTREEVIEW lpnmt, LRESULT *pResult);
+       DECLARE_MESSAGE_MAP()
+};
+
+/////////////////////////////////////////////////////////////////////////////
+
+//{{AFX_INSERT_LOCATION}}
+// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
+
+#endif // !defined(AFX_SCRIPTMANAGER_H__CC6DCB34_1291_4DC4_9137_47CFCFF95555__INCLUDED_)
diff --git a/src/console/win32/ScriptView.cpp b/src/console/win32/ScriptView.cpp
new file mode 100644 (file)
index 0000000..6f0f3ce
--- /dev/null
@@ -0,0 +1,125 @@
+// ScriptView.cpp : implementation file
+//
+
+#include "stdafx.h"
+#include "nxcon.h"
+#include "ScriptView.h"
+
+#ifdef _DEBUG
+#define new DEBUG_NEW
+#undef THIS_FILE
+static char THIS_FILE[] = __FILE__;
+#endif
+
+
+//
+// Operation modes
+//
+
+#define MODE_LIST    0
+#define MODE_VIEW    1
+#define MODE_EDIT    2
+
+
+/////////////////////////////////////////////////////////////////////////////
+// CScriptView
+
+CScriptView::CScriptView()
+{
+}
+
+CScriptView::~CScriptView()
+{
+}
+
+
+BEGIN_MESSAGE_MAP(CScriptView, CWnd)
+       //{{AFX_MSG_MAP(CScriptView)
+       ON_WM_CREATE()
+       ON_WM_SIZE()
+       //}}AFX_MSG_MAP
+END_MESSAGE_MAP()
+
+
+/////////////////////////////////////////////////////////////////////////////
+// CScriptView message handlers
+
+
+//
+// WM_CREATE message handler
+//
+
+int CScriptView::OnCreate(LPCREATESTRUCT lpCreateStruct) 
+{
+   RECT rect;
+
+       if (CWnd::OnCreate(lpCreateStruct) == -1)
+               return -1;
+       
+   GetClientRect(&rect);
+
+   // Create image list
+   m_imageList.Create(32, 32, ILC_COLOR8 | ILC_MASK, 4, 4);
+   m_imageList.Add(AfxGetApp()->LoadIcon(IDI_CLOSED_FOLDER));
+   m_imageList.Add(AfxGetApp()->LoadIcon(IDI_SCRIPT));
+
+   // Create list control
+   m_wndListCtrl.Create(WS_CHILD | WS_VISIBLE, rect, this, ID_LIST_VIEW);
+   m_wndListCtrl.SetImageList(&m_imageList, LVSIL_NORMAL);
+   m_wndListCtrl.InsertColumn(0, _T("Name"));
+
+   // Create editor
+   m_wndEditor.Create(WS_CHILD | WS_VISIBLE | ES_MULTILINE, rect, this, ID_EDIT_BOX);
+   m_wndEditor.SetFont(&g_fontCode);
+       
+       return 0;
+}
+
+
+//
+// WM_SIZE message handler
+//
+
+void CScriptView::OnSize(UINT nType, int cx, int cy) 
+{
+       CWnd::OnSize(nType, cx, cy);
+   m_wndListCtrl.SetWindowPos(NULL, 0, 0, cx, cy, SWP_NOZORDER);
+   m_wndEditor.SetWindowPos(NULL, 0, 0, cx, cy, SWP_NOZORDER);
+}
+
+
+//
+// Switch script view to list mode
+//
+
+void CScriptView::SetListMode(CTreeCtrl &wndTreeCtrl, HTREEITEM hRoot)
+{
+   HTREEITEM hItem;
+   DWORD dwId;
+
+   m_nMode = MODE_LIST;
+
+   m_wndListCtrl.DeleteAllItems();
+   hItem = wndTreeCtrl.GetChildItem(hRoot);
+   while(hItem != NULL)
+   {
+      dwId = wndTreeCtrl.GetItemData(hItem);
+      m_wndListCtrl.InsertItem(0x7FFFFFFF, (LPCTSTR)wndTreeCtrl.GetItemText(hItem),
+                               (dwId == 0) ? 0 : 1);
+      hItem = wndTreeCtrl.GetNextItem(hItem, TVGN_NEXT);
+   }
+
+   m_wndListCtrl.ShowWindow(SW_SHOW);
+   m_wndEditor.ShowWindow(SW_HIDE);
+}
+
+
+//
+// Switch script view to edit mode
+//
+
+void CScriptView::SetEditMode(DWORD dwScriptId)
+{
+   m_wndEditor.ShowWindow(SW_HIDE);
+   m_wndListCtrl.ShowWindow(SW_HIDE);
+}
diff --git a/src/console/win32/ScriptView.h b/src/console/win32/ScriptView.h
new file mode 100644 (file)
index 0000000..707cd77
--- /dev/null
@@ -0,0 +1,54 @@
+#if !defined(AFX_SCRIPTVIEW_H__94A483F2_760D_44BD_A6E0_230B202CAE13__INCLUDED_)
+#define AFX_SCRIPTVIEW_H__94A483F2_760D_44BD_A6E0_230B202CAE13__INCLUDED_
+
+#if _MSC_VER > 1000
+#pragma once
+#endif // _MSC_VER > 1000
+// ScriptView.h : header file
+//
+
+/////////////////////////////////////////////////////////////////////////////
+// CScriptView window
+
+class CScriptView : public CWnd
+{
+// Construction
+public:
+       CScriptView();
+
+// Attributes
+public:
+
+// Operations
+public:
+
+// Overrides
+       // ClassWizard generated virtual function overrides
+       //{{AFX_VIRTUAL(CScriptView)
+       //}}AFX_VIRTUAL
+
+// Implementation
+public:
+       void SetEditMode(DWORD dwScriptId);
+       void SetListMode(CTreeCtrl &wndTreeCtrl, HTREEITEM hRoot);
+       virtual ~CScriptView();
+
+       // Generated message map functions
+protected:
+       int m_nMode;
+       CImageList m_imageList;
+       CEdit m_wndEditor;
+       CListCtrl m_wndListCtrl;
+       //{{AFX_MSG(CScriptView)
+       afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
+       afx_msg void OnSize(UINT nType, int cx, int cy);
+       //}}AFX_MSG
+       DECLARE_MESSAGE_MAP()
+};
+
+/////////////////////////////////////////////////////////////////////////////
+
+//{{AFX_INSERT_LOCATION}}
+// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
+
+#endif // !defined(AFX_SCRIPTVIEW_H__94A483F2_760D_44BD_A6E0_230B202CAE13__INCLUDED_)
index 3505baf..efacad3 100644 (file)
@@ -287,6 +287,7 @@ DWORD ExtractWindowParamULong(TCHAR *pszStr, TCHAR *pszParam, DWORD dwDefault);
 void CopyMenuItems(CMenu *pDst, CMenu *pSrc);
 TCHAR **CopyStringList(TCHAR **ppList, DWORD dwSize);
 void DestroyStringList(TCHAR **ppList, DWORD dwSize);
+HTREEITEM FindTreeCtrlItem(CTreeCtrl &ctrl, HTREEITEM hRoot, TCHAR *pszText);
 
 
 //
index 9c4b9d1..9dea447 100644 (file)
@@ -20,4 +20,5 @@ EXTRA_DIST = \
        SeverityNormal.ico SeverityWarning.ico sms.ico sortdown.ico \
        sort_up.ico tree.ico unsupported.ico user.ico users.ico \
        nack.ico running.ico pending.ico Tips.ico objtools.ico \
-       command.ico
+       command.ico script_library.ico script.ico folder_c.ico \
+       folder_o.ico
diff --git a/src/console/win32/icons/folder_c.ico b/src/console/win32/icons/folder_c.ico
new file mode 100644 (file)
index 0000000..adfd173
Binary files /dev/null and b/src/console/win32/icons/folder_c.ico differ
diff --git a/src/console/win32/icons/folder_o.ico b/src/console/win32/icons/folder_o.ico
new file mode 100644 (file)
index 0000000..d36827b
Binary files /dev/null and b/src/console/win32/icons/folder_o.ico differ
diff --git a/src/console/win32/icons/script.ico b/src/console/win32/icons/script.ico
new file mode 100644 (file)
index 0000000..5294fb5
Binary files /dev/null and b/src/console/win32/icons/script.ico differ
diff --git a/src/console/win32/icons/script_library.ico b/src/console/win32/icons/script_library.ico
new file mode 100644 (file)
index 0000000..e3588c3
Binary files /dev/null and b/src/console/win32/icons/script_library.ico differ
index 8f8a425..8f2b066 100644 (file)
@@ -2,13 +2,13 @@
 
 [General Info]
 Version=1
-LastClass=CDCITransformPage
-LastTemplate=CPropertyPage
+LastClass=CScriptView
+LastTemplate=generic CWnd
 NewFileInclude1=#include "stdafx.h"
 NewFileInclude2=#include "nxcon.h"
 LastPage=0
 
-ClassCount=112
+ClassCount=114
 Class1=CConsoleApp
 Class3=CMainFrame
 Class4=CChildFrame
@@ -16,9 +16,9 @@ Class7=CEventBrowser
 Class9=CMapView
 
 ResourceCount=135
-Resource1=IDD_SELECT_EVENT (English (U.S.))
+Resource1=IDD_DESKTOP_SAVE_AS (English (U.S.))
 Resource2=IDD_OBJECT_NODE_GENERAL
-Resource3=IDD_DATA_QUERY (English (U.S.))
+Resource3=IDD_NEW_OBJECT_TOOL (English (U.S.))
 Resource4=IDD_SELECT_OBJECT
 Resource5=IDD_SELECT_ACTION
 Class2=CChildView
@@ -32,9 +32,9 @@ Resource7=IDD_NEW_USER
 Class12=CObjectBrowser
 Resource8=IDD_CREATE_CONTAINER
 Class13=CObjectPropDlg
-Resource9=IDD_EDIT_IP_SUBNET (English (U.S.))
-Resource10=IDD_CREATE_TEMPLATE (English (U.S.))
-Resource11=IDA_AGENT_CFG_EDITOR (English (U.S.))
+Resource9=IDA_DC_EDITOR (English (U.S.))
+Resource10=IDD_OBJTOOL_GENERAL (English (U.S.))
+Resource11=IDD_EDIT_RULE_SEVERITY (English (U.S.))
 Resource12=IDR_CTRLPANEL (English (U.S.))
 Resource13=IDR_EVENTS (English (U.S.))
 Resource14=IDR_MAPFRAME (English (U.S.))
@@ -42,17 +42,17 @@ Resource15=IDR_OBJECTS (English (U.S.))
 Resource16=IDD_DUMMY (English (U.S.))
 Class14=CEventEditor
 Class15=CEditEventDlg
-Resource17=IDD_CREATE_VPNC (English (U.S.))
+Resource17=IDA_SERVER_CFG_EDITOR (English (U.S.))
 Class16=CDebugFrame
-Resource18=IDD_OBJECT_NODE_GENERAL (English (U.S.))
+Resource18=IDD_SELECT_ACTION (English (U.S.))
 Resource19=IDD_OBJECT_PROPERTIES (English (U.S.))
 Resource20=IDD_SELECT_EVENT
 Class17=CObjectPreview
-Resource21=IDD_CP_GENERAL (English (U.S.))
+Resource21=IDD_DCI_DATA_EXPORT (English (U.S.))
 Class18=CToolBox
 Class19=CObjectInfoBox
 Class20=CObjectSearchBox
-Resource22=IDD_NEW_USER (English (U.S.))
+Resource22=IDD_DATA_QUERY (English (U.S.))
 Class21=CEditBox
 Class22=COPGeneral
 Class23=CNodePropsGeneral
@@ -61,14 +61,14 @@ Class24=CObjectPropCaps
 Class25=CObjectPropSheet
 Resource24=IDA_MDI_DEFAULT
 Class26=CRequestProcessingDlg
-Resource25=IDA_EPP (English (U.S.))
+Resource25=IDD_GROUP_PROPERTIES (English (U.S.))
 Resource26=IDD_PROGRESS (English (U.S.))
 Resource27=IDD_EDIT_RULE_ALARM
-Resource28=IDA_LAST_VALUES (English (U.S.))
+Resource28=IDD_SELECT_EVENT (English (U.S.))
 Class27=CObjectPropsGeneral
-Resource29=IDD_SELECT_ACTION (English (U.S.))
+Resource29=IDD_OBJECT_VPNC_GENERAL (English (U.S.))
 Class28=CObjectPropsSecurity
-Resource30=IDD_EDIT_TRAP_ARG (English (U.S.))
+Resource30=IDD_REMOVE_TEMPLATE
 Resource31=IDD_SELECT_USER
 Resource32=IDD_OBJECT_SECURITY
 Class29=CUserSelectDlg
@@ -79,36 +79,36 @@ Class31=CNewUserDlg
 Resource35=IDD_THRESHOLD
 Resource36=IDA_EPP
 Class32=CUserPropDlg
-Resource37=IDD_CREATE_TG (English (U.S.))
+Resource37=IDD_OBJECT_STATUS (English (U.S.))
 Resource38=IDD_ABOUTBOX
 Class33=CGroupPropDlg
 Resource39=IDD_CP_GENERAL
 Resource40=IDA_TRAP_EDITOR
 Resource41=IDM_VIEW_SPECIFIC
-Resource42=IDD_CREATE_NODE (English (U.S.))
+Resource42=IDD_SAVE_AGENT_CFG (English (U.S.))
 Class34=CPasswordChangeDlg
 Class35=CNodeSummary
 Class36=CNetSummaryFrame
 Class37=CDataCollectionEditor
-Resource43=IDD_OBJECT_NODE_POLL (English (U.S.))
+Resource43=IDA_ALARM_BROWSER (English (U.S.))
 Class38=CDCIPropPage
-Resource44=IDD_NEW_ACTION (English (U.S.))
+Resource44=IDD_EDIT_VARIABLE (English (U.S.))
 Class39=CDCIDataView
-Resource45=IDA_ACTION_EDITOR (English (U.S.))
+Resource45=IDM_VIEW_SPECIFIC (English (U.S.))
 Class40=CGraph
 Class41=CGraphFrame
 Class42=CDCIThresholdsPage
-Resource46=IDD_OBJECT_NETSRV_GENERAL (English (U.S.))
-Resource47=IDA_TRAP_EDITOR (English (U.S.))
+Resource46=IDA_EPP (English (U.S.))
+Resource47=IDD_MIB_BROWSER (English (U.S.))
 Resource48=IDM_CONTEXT
 Class43=CThresholdDlg
-Resource49=IDD_SELECT_USER (English (U.S.))
+Resource49=IDD_CREATE_TEMPLATE (English (U.S.))
 Resource50=IDD_EDIT_TRAP_ARG
 Class44=CMIBBrowserDlg
 Class45=CEventPolicyEditor
 Class46=CRuleList
 Class47=CRuleHeader
-Resource51=IDD_THRESHOLD (English (U.S.))
+Resource51=IDD_CREATE_NETSRV (English (U.S.))
 Resource52=IDD_CREATE_NODE
 Class48=CObjectSelDlg
 Resource53=IDD_OBJECT_CAPS
@@ -117,22 +117,22 @@ Class49=CRuleCommentDlg
 Resource55=IDD_DCI_COLLECTION
 Class50=CEventSelDlg
 Resource56=IDD_DATA_QUERY
-Resource57=IDD_CHANGE_IP
+Resource57=IDD_OBJECT_SECURITY (English (U.S.))
 Resource58=IDD_CREATE_TG
-Resource59=IDD_REQUEST_PROCESSING (English (U.S.))
-Resource60=IDD_EDIT_EVENT (English (U.S.))
+Resource59=IDD_CREATE_NODE (English (U.S.))
+Resource60=IDD_ACTION_PROPERTIES (English (U.S.))
 Class51=CObjectPropsPresentation
-Resource61=IDD_EDIT_RULE_COMMENT (English (U.S.))
+Resource61=IDD_OBJECT_RELATIONS (English (U.S.))
 Resource62=IDD_EDIT_RULE_COMMENT
 Class52=CRuleSeverityDlg
 Resource63=IDD_ACTION_PROPERTIES
 Class53=CRuleAlarmDlg
 Class54=CAlarmBrowser
-Resource64=IDD_DCI_TRANSFORM (English (U.S.))
+Resource64=IDD_DCI_SCHEDULE (English (U.S.))
 Resource65=IDD_DCI_TRANSFORM
-Resource66=IDD_CREATE_CONTAINER (English (U.S.))
-Resource67=IDA_OBJECT_TOOLS_EDITOR (English (U.S.))
-Resource68=IDD_SELECT_INTERNAL_ITEM (English (U.S.))
+Resource66=IDD_EDIT_IP_SUBNET (English (U.S.))
+Resource67=IDD_CP_GENERAL (English (U.S.))
+Resource68=IDD_CHANGE_IP
 Class55=CConsolePropsGeneral
 Class56=CActionEditor
 Resource69=IDA_ACTION_EDITOR
@@ -143,18 +143,18 @@ Class58=CEditActionDlg
 Resource72=IDA_NETMAP
 Class59=CActionSelDlg
 Resource73=IDD_MIB_BROWSER
-Resource74=IDA_GRAPH (English (U.S.))
-Resource75=IDD_EDIT_TRAP (English (U.S.))
+Resource74=IDD_SELECT_OBJECT (English (U.S.))
+Resource75=IDD_OBJTOOL_OPTIONS (English (U.S.))
 Resource76=IDD_USER_PROPERTIES
 Class60=CCreateObjectDlg
 Class61=CCreateContainerDlg
 Resource77=IDR_MAINFRAME
 Class62=CCreateNodeDlg
-Resource78=IDD_EDIT_RULE_ALARM (English (U.S.))
-Resource79=IDD_CREATE_NETSRV (English (U.S.))
-Resource80=IDD_OBJTOOL_GENERAL (English (U.S.))
+Resource78=IDD_LASTVAL_PROP (English (U.S.))
+Resource79=IDA_OBJECT_BROWSER (English (U.S.))
+Resource80=IDD_OBJECT_NODE_GENERAL (English (U.S.))
 Class63=CDCITransformPage
-Resource81=IDD_ACTION_PROPERTIES (English (U.S.))
+Resource81=IDD_CREATE_VPNC (English (U.S.))
 Class64=CPollNodeDlg
 Resource82=IDD_POLL_NODE (English (U.S.))
 Class65=CNodePoller
@@ -171,7 +171,7 @@ Resource89=IDA_ALARM_BROWSER
 Class69=CDataQueryDlg
 Resource90=IDD_EDIT_RULE_SEVERITY
 Class70=CTrapEditDlg
-Resource91=IDA_NETMAP (English (U.S.))
+Resource91=IDD_DCI_COLLECTION (English (U.S.))
 Class71=CTrapParamDlg
 Resource92=IDD_EDIT_EVENT
 Resource93=IDD_CREATE_TEMPLATE
@@ -179,84 +179,86 @@ Class72=CGraphPropDlg
 Class73=CColorSelector
 Class74=CPackageMgr
 Resource94=IDD_GROUP_PROPERTIES
-Resource95=IDA_SERVER_CFG_EDITOR (English (U.S.))
-Resource96=IDM_CONTEXT (English (U.S.))
-Resource97=IDD_OBJECT_CAPS (English (U.S.))
-Resource98=IDD_REMOVE_TEMPLATE
-Resource99=IDD_SELECT_OBJECT (English (U.S.))
-Resource100=IDD_OBJECT_STATUS (English (U.S.))
-Resource101=IDD_SELECT_AGENT_PARAM (English (U.S.))
-Resource102=IDD_DCI_DATA_EXPORT (English (U.S.))
-Resource103=IDD_OBJTOOL_OPTIONS (English (U.S.))
-Resource104=IDA_MDI_DEFAULT (English (U.S.))
-Resource105=IDD_SET_PASSWORD (English (U.S.))
-Resource106=IDD_MIB_BROWSER (English (U.S.))
-Resource107=IDA_ALARM_BROWSER (English (U.S.))
+Resource95=IDD_OBJECT_PRESENTATION (English (U.S.))
+Resource96=IDD_THRESHOLD (English (U.S.))
+Resource97=IDD_CREATE_CONTAINER (English (U.S.))
+Resource98=IDD_OBJECT_GENERAL (English (U.S.))
+Resource99=IDD_OBJECT_NODE_POLL (English (U.S.))
+Resource100=IDD_EDIT_EVENT (English (U.S.))
+Resource101=IDR_MAINFRAME (English (U.S.))
+Resource102=IDA_PACKAGE_MGR (English (U.S.))
+Resource103=IDD_REQUEST_PROCESSING (English (U.S.))
+Resource104=IDD_NEW_USER (English (U.S.))
+Resource105=IDD_SELECT_INTERNAL_ITEM (English (U.S.))
+Resource106=IDD_OBJECT_NETSRV_GENERAL (English (U.S.))
+Resource107=IDD_SET_PASSWORD (English (U.S.))
 Class75=CInternalItemSelDlg
-Resource108=IDD_GRAPH_PROP_SETTINGS (English (U.S.))
+Resource108=IDA_ACTION_EDITOR (English (U.S.))
 Class76=CAgentParamSelDlg
-Resource109=IDA_EVENT_EDITOR (English (U.S.))
+Resource109=IDM_CONTEXT (English (U.S.))
 Class77=CInputBox
-Resource110=IDD_EDIT_RULE_SEVERITY (English (U.S.))
+Resource110=IDD_GRAPH_PROP_DATA (English (U.S.))
 Class78=CCreateNetSrvDlg
-Resource111=IDD_OBJECT_GENERAL (English (U.S.))
+Resource111=IDD_DCI_TRANSFORM (English (U.S.))
 Class79=CNetSrvPropsGeneral
 Resource112=IDD_LOGIN (English (U.S.))
 Class80=CNodePropsPolling
 Class81=CDeploymentView
 Class82=CLastValuesView
 Class83=CValueList
-Resource113=IDD_DESKTOP_SAVE_AS (English (U.S.))
+Resource113=IDA_EVENT_EDITOR (English (U.S.))
 Class84=CObjectPropsRelations
-Resource114=IDD_DCI_SCHEDULE (English (U.S.))
+Resource114=IDD_ABOUTBOX (English (U.S.))
 Class85=CSaveDesktopDlg
-Resource115=IDD_OBJECT_VPNC_GENERAL (English (U.S.))
+Resource115=IDA_AGENT_CFG_EDITOR (English (U.S.))
 Class86=CGraphSettingsPage
-Resource116=IDD_LASTVAL_PROP (English (U.S.))
+Resource116=IDA_GRAPH (English (U.S.))
 Class87=CGraphDataPage
-Resource117=IDD_DCI_COLLECTION (English (U.S.))
+Resource117=IDD_SELECT_AGENT_PARAM (English (U.S.))
 Class88=CRemoveTemplateDlg
-Resource118=IDA_OBJECT_BROWSER (English (U.S.))
+Resource118=IDD_USER_PROPERTIES (English (U.S.))
 Class89=CAddrChangeDlg
-Resource119=IDD_USER_PROPERTIES (English (U.S.))
+Resource119=IDD_EDIT_TRAP (English (U.S.))
 Class90=CLastValuesPropDlg
 Class91=CAgentCfgEditor
-Resource120=IDD_OBJECT_PRESENTATION (English (U.S.))
+Resource120=IDD_GRAPH_PROP_SETTINGS (English (U.S.))
 Class92=CDataExportDlg
 Class93=CServerCfgEditor
-Resource121=IDA_PACKAGE_MGR (English (U.S.))
-Resource122=IDD_ABOUTBOX (English (U.S.))
+Resource121=IDD_EDIT_RULE_COMMENT (English (U.S.))
+Resource122=IDD_NEW_ACTION (English (U.S.))
 Class94=CEditVariableDlg
-Resource123=IDD_INPUT_BOX (English (U.S.))
+Resource123=IDA_MDI_DEFAULT (English (U.S.))
 Class95=CCreateVPNConnDlg
-Resource124=IDD_SAVE_AGENT_CFG (English (U.S.))
+Resource124=IDA_OBJECT_TOOLS_EDITOR (English (U.S.))
 Class96=CVPNCPropsGeneral
-Resource125=IDA_DC_EDITOR (English (U.S.))
+Resource125=IDD_EDIT_RULE_ALARM (English (U.S.))
 Class97=CEditSubnetDlg
-Resource126=IDM_VIEW_SPECIFIC (English (U.S.))
-Resource127=IDR_MAINFRAME (English (U.S.))
+Resource126=IDD_DCI_THRESHOLDS (English (U.S.))
+Resource127=IDD_SELECT_USER (English (U.S.))
 Class98=CModifiedAgentCfgDlg
 Class99=CSimpleSplitter
 Class100=CAdvSplitter
-Resource128=IDD_DCI_THRESHOLDS (English (U.S.))
+Resource128=IDD_INPUT_BOX (English (U.S.))
 Class101=CTableView
 Class102=CWaitView
 Class103=CWebBrowser
 Class104=CSyslogBrowser
 Class105=CLPPList
-Resource129=IDD_EDIT_VARIABLE (English (U.S.))
+Resource129=IDA_LAST_VALUES (English (U.S.))
 Class106=CDCISchedulePage
-Resource130=IDD_OBJECT_RELATIONS (English (U.S.))
+Resource130=IDA_NETMAP (English (U.S.))
 Class107=CObjectPropsStatus
 Class108=CObjectToolsEditor
-Resource131=IDD_NEW_OBJECT_TOOL (English (U.S.))
-Resource132=IDD_GROUP_PROPERTIES (English (U.S.))
+Resource131=IDD_OBJECT_CAPS (English (U.S.))
+Resource132=IDD_EDIT_TRAP_ARG (English (U.S.))
 Class109=CObjToolPropGeneral
-Resource133=IDD_OBJECT_SECURITY (English (U.S.))
+Resource133=IDD_CREATE_TG (English (U.S.))
 Class110=CObjToolPropColumns
-Resource134=IDD_GRAPH_PROP_DATA (English (U.S.))
+Resource134=IDA_TRAP_EDITOR (English (U.S.))
 Class111=CNewObjectToolDlg
 Class112=CObjToolPropOptions
+Class113=CScriptManager
+Class114=CScriptView
 Resource135=IDD_OBJTOOL_COLUMNS
 
 [CLS:CConsoleApp]
@@ -830,75 +832,76 @@ Command69=ID_CONTROLPANEL_EVENTS
 Command70=ID_CONTROLPANEL_EVENTPOLICY
 Command71=ID_CONTROLPANEL_LOGPROCESSING
 Command72=ID_CONTROLPANEL_OBJECTTOOLS
-Command73=ID_CONTROLPANEL_SERVERCFG
-Command74=ID_CONTROLPANEL_SNMPTRAPS
-Command75=ID_CONTROLPANEL_USERS
-Command76=ID_OBJECT_OPEN
-Command77=ID_OBJECT_OPENPARENT
-Command78=ID_OBJECT_FIND
-Command79=ID_OBJECT_CREATE_NODE
-Command80=ID_OBJECT_CREATE_CONTAINER
-Command81=ID_OBJECT_CREATE_TEMPLATEGROUP
-Command82=ID_OBJECT_CREATE_TEMPLATE
-Command83=ID_OBJECT_CREATE_SERVICE
-Command84=ID_OBJECT_CREATE_VPNCONNECTOR
-Command85=ID_OBJECT_BIND
-Command86=ID_OBJECT_UNBIND
-Command87=ID_OBJECT_RENAME
-Command88=ID_OBJECT_DELETE
-Command89=ID_OBJECT_MOVE
-Command90=ID_OBJECT_CHANGEIPADDRESS
-Command91=ID_OBJECT_AGENTCFG
-Command92=ID_OBJECT_APPLY
-Command93=ID_OBJECT_MANAGE
-Command94=ID_OBJECT_UNMANAGE
-Command95=ID_OBJECT_POLL_STATUS
-Command96=ID_OBJECT_POLL_CONFIGURATION
-Command97=ID_OBJECT_DATACOLLECTION
-Command98=ID_OBJECT_LASTDCIVALUES
-Command99=ID_OBJECT_PROPERTIES
-Command100=ID_EVENT_NEW
-Command101=ID_EVENT_EDIT
-Command102=ID_EVENT_DELETE
-Command103=ID_ACTION_NEW
-Command104=ID_ACTION_RENAME
-Command105=ID_ACTION_DELETE
-Command106=ID_ACTION_PROPERTIES
-Command107=ID_TRAP_NEW
-Command108=ID_TRAP_EDIT
-Command109=ID_TRAP_DELETE
-Command110=ID_GRAPH_PRESETS_LAST10MINUTES
-Command111=ID_GRAPH_PRESETS_LAST30MINUTES
-Command112=ID_GRAPH_PRESETS_LASTHOUR
-Command113=ID_GRAPH_PRESETS_LAST2HOURS
-Command114=ID_GRAPH_PRESETS_LAST4HOURS
-Command115=ID_GRAPH_PRESETS_LASTDAY
-Command116=ID_GRAPH_PRESETS_LASTWEEK
-Command117=ID_GRAPH_AUTOSCALE
-Command118=ID_GRAPH_FREEZE
-Command119=ID_GRAPH_PROPERTIES
-Command120=ID_PACKAGE_INSTALL
-Command121=ID_PACKAGE_REMOVE
-Command122=ID_PACKAGE_DEPLOY
-Command123=ID_ITEM_SHOWDATA
-Command124=ID_ITEM_GRAPH
-Command125=ID_ITEM_EXPORTDATA
-Command126=ID_LASTVALUES_PROPERTIES
-Command127=ID_VARIABLE_NEW
-Command128=ID_VARIABLE_EDIT
-Command129=ID_VARIABLE_DELETE
-Command130=ID_EDIT_UNDO
-Command131=ID_EDIT_CUT
-Command132=ID_EDIT_COPY
-Command133=ID_EDIT_PASTE
-Command134=ID_EDIT_DELETE
-Command135=ID_EDIT_SELECT_ALL
-Command136=ID_CONFIG_SAVE
-Command137=ID_CONFIG_SAVEANDAPPLY
-Command138=ID_OBJECTTOOLS_NEW
-Command139=ID_OBJECTTOOLS_EDIT
-Command140=ID_OBJECTTOOLS_DELETE
-CommandCount=140
+Command73=ID_CONTROLPANEL_SCRIPTLIBRARY
+Command74=ID_CONTROLPANEL_SERVERCFG
+Command75=ID_CONTROLPANEL_SNMPTRAPS
+Command76=ID_CONTROLPANEL_USERS
+Command77=ID_OBJECT_OPEN
+Command78=ID_OBJECT_OPENPARENT
+Command79=ID_OBJECT_FIND
+Command80=ID_OBJECT_CREATE_NODE
+Command81=ID_OBJECT_CREATE_CONTAINER
+Command82=ID_OBJECT_CREATE_TEMPLATEGROUP
+Command83=ID_OBJECT_CREATE_TEMPLATE
+Command84=ID_OBJECT_CREATE_SERVICE
+Command85=ID_OBJECT_CREATE_VPNCONNECTOR
+Command86=ID_OBJECT_BIND
+Command87=ID_OBJECT_UNBIND
+Command88=ID_OBJECT_RENAME
+Command89=ID_OBJECT_DELETE
+Command90=ID_OBJECT_MOVE
+Command91=ID_OBJECT_CHANGEIPADDRESS
+Command92=ID_OBJECT_AGENTCFG
+Command93=ID_OBJECT_APPLY
+Command94=ID_OBJECT_MANAGE
+Command95=ID_OBJECT_UNMANAGE
+Command96=ID_OBJECT_POLL_STATUS
+Command97=ID_OBJECT_POLL_CONFIGURATION
+Command98=ID_OBJECT_DATACOLLECTION
+Command99=ID_OBJECT_LASTDCIVALUES
+Command100=ID_OBJECT_PROPERTIES
+Command101=ID_EVENT_NEW
+Command102=ID_EVENT_EDIT
+Command103=ID_EVENT_DELETE
+Command104=ID_ACTION_NEW
+Command105=ID_ACTION_RENAME
+Command106=ID_ACTION_DELETE
+Command107=ID_ACTION_PROPERTIES
+Command108=ID_TRAP_NEW
+Command109=ID_TRAP_EDIT
+Command110=ID_TRAP_DELETE
+Command111=ID_GRAPH_PRESETS_LAST10MINUTES
+Command112=ID_GRAPH_PRESETS_LAST30MINUTES
+Command113=ID_GRAPH_PRESETS_LASTHOUR
+Command114=ID_GRAPH_PRESETS_LAST2HOURS
+Command115=ID_GRAPH_PRESETS_LAST4HOURS
+Command116=ID_GRAPH_PRESETS_LASTDAY
+Command117=ID_GRAPH_PRESETS_LASTWEEK
+Command118=ID_GRAPH_AUTOSCALE
+Command119=ID_GRAPH_FREEZE
+Command120=ID_GRAPH_PROPERTIES
+Command121=ID_PACKAGE_INSTALL
+Command122=ID_PACKAGE_REMOVE
+Command123=ID_PACKAGE_DEPLOY
+Command124=ID_ITEM_SHOWDATA
+Command125=ID_ITEM_GRAPH
+Command126=ID_ITEM_EXPORTDATA
+Command127=ID_LASTVALUES_PROPERTIES
+Command128=ID_VARIABLE_NEW
+Command129=ID_VARIABLE_EDIT
+Command130=ID_VARIABLE_DELETE
+Command131=ID_EDIT_UNDO
+Command132=ID_EDIT_CUT
+Command133=ID_EDIT_COPY
+Command134=ID_EDIT_PASTE
+Command135=ID_EDIT_DELETE
+Command136=ID_EDIT_SELECT_ALL
+Command137=ID_CONFIG_SAVE
+Command138=ID_CONFIG_SAVEANDAPPLY
+Command139=ID_OBJECTTOOLS_NEW
+Command140=ID_OBJECTTOOLS_EDIT
+Command141=ID_OBJECTTOOLS_DELETE
+CommandCount=141
 
 [ACL:IDA_MDI_DEFAULT (English (U.S.))]
 Type=1
@@ -3690,3 +3693,19 @@ Filter=D
 LastObject=CObjToolPropOptions
 VirtualFilter=idWC
 
+[CLS:CScriptManager]
+Type=0
+HeaderFile=ScriptManager.h
+ImplementationFile=ScriptManager.cpp
+BaseClass=CMDIChildWnd
+Filter=M
+VirtualFilter=mfWC
+
+[CLS:CScriptView]
+Type=0
+HeaderFile=ScriptView.h
+ImplementationFile=ScriptView.cpp
+BaseClass=CWnd
+Filter=W
+VirtualFilter=WC
+
index a385c9e..5bf5d4f 100644 (file)
@@ -71,6 +71,7 @@ BEGIN_MESSAGE_MAP(CConsoleApp, CWinApp)
        ON_COMMAND(ID_VIEW_SYSLOG, OnViewSyslog)
        ON_COMMAND(ID_CONTROLPANEL_LOGPROCESSING, OnControlpanelLogprocessing)
        ON_COMMAND(ID_CONTROLPANEL_OBJECTTOOLS, OnControlpanelObjecttools)
+       ON_COMMAND(ID_CONTROLPANEL_SCRIPTLIBRARY, OnControlpanelScriptlibrary)
        //}}AFX_MSG_MAP
 END_MESSAGE_MAP()
 
@@ -97,6 +98,7 @@ CConsoleApp::CConsoleApp()
    m_bPackageMgrActive = FALSE;
    m_bServerCfgEditorActive = FALSE;
    m_bObjToolsEditorActive = FALSE;
+   m_bScriptManagerActive = FALSE;
    m_dwClientState = STATE_DISCONNECTED;
    m_hwndEventBrowser = NULL;
    memset(m_openDCEditors, 0, sizeof(DC_EDITOR) * MAX_DC_EDITORS);
@@ -329,6 +331,10 @@ BOOL CConsoleApp::InitInstance()
    InsertMenu(m_hObjToolsEditorMenu, LAST_APP_MENU, MF_BYPOSITION | MF_POPUP, (UINT_PTR)GetSubMenu(hMenu, 0), "&Window");
    InsertMenu(m_hObjToolsEditorMenu, LAST_APP_MENU - 1, MF_BYPOSITION | MF_POPUP, (UINT_PTR)GetSubMenu(hMenu, 19), "&Object tools");
 
+   m_hScriptManagerMenu = LoadAppMenu(hMenu);
+   InsertMenu(m_hScriptManagerMenu, LAST_APP_MENU, MF_BYPOSITION | MF_POPUP, (UINT_PTR)GetSubMenu(hMenu, 0), "&Window");
+   //InsertMenu(m_hScriptManagerMenu, LAST_APP_MENU - 1, MF_BYPOSITION | MF_POPUP, (UINT_PTR)GetSubMenu(hMenu, 19), "&Script");
+
        m_hMDIAccel = ::LoadAccelerators(hInstance, MAKEINTRESOURCE(IDA_MDI_DEFAULT));
        m_hAlarmBrowserAccel = ::LoadAccelerators(hInstance, MAKEINTRESOURCE(IDA_ALARM_BROWSER));
        m_hEventBrowserAccel = ::LoadAccelerators(hInstance, MAKEINTRESOURCE(IDA_MDI_DEFAULT));
@@ -347,6 +353,7 @@ BOOL CConsoleApp::InitInstance()
        m_hAgentCfgEditorAccel = ::LoadAccelerators(hInstance, MAKEINTRESOURCE(IDA_AGENT_CFG_EDITOR));
        m_hLPPEditorAccel = ::LoadAccelerators(hInstance, MAKEINTRESOURCE(IDA_MDI_DEFAULT));
        m_hObjToolsEditorAccel = ::LoadAccelerators(hInstance, MAKEINTRESOURCE(IDA_OBJECT_TOOLS_EDITOR));
+       m_hScriptManagerAccel = ::LoadAccelerators(hInstance, MAKEINTRESOURCE(IDA_MDI_DEFAULT));
 
        // The main window has been initialized, so show and update it.
    if (bSetWindowPos)
@@ -425,6 +432,8 @@ int CConsoleApp::ExitInstance()
    SafeFreeResource(m_hAgentCfgEditorAccel);
    SafeFreeResource(m_hLPPEditorMenu);
    SafeFreeResource(m_hLPPEditorAccel);
+   SafeFreeResource(m_hScriptManagerMenu);
+   SafeFreeResource(m_hScriptManagerAccel);
 
    CloseHandle(g_mutexActionListAccess);
 
@@ -600,6 +609,10 @@ void CConsoleApp::OnViewCreate(DWORD dwView, CWnd *pWnd, DWORD dwArg)
          m_bLPPEditorActive = TRUE;
          m_pwndLPPEditor = (CLPPList *)pWnd;
          break;
+      case IDR_SCRIPT_MANAGER:
+         m_bScriptManagerActive = TRUE;
+         m_pwndScriptManager = (CScriptManager *)pWnd;
+         break;
       default:
          break;
    }
@@ -677,6 +690,9 @@ void CConsoleApp::OnViewDestroy(DWORD dwView, CWnd *pWnd, DWORD dwArg)
       case IDR_LPP_EDITOR:
          m_bLPPEditorActive = FALSE;
          break;
+      case IDR_SCRIPT_MANAGER:
+         m_bScriptManagerActive = FALSE;
+         break;
       default:
          break;
    }
@@ -997,6 +1013,28 @@ void CConsoleApp::OnControlpanelObjecttools()
 }
 
 
+//
+// Handler for WM_COMMAND::ID_CONTROLPANEL_SCRIPTLIBRARY message
+//
+
+void CConsoleApp::OnControlpanelScriptlibrary() 
+{
+       CMainFrame* pFrame = STATIC_DOWNCAST(CMainFrame, m_pMainWnd);
+
+       // create a new MDI child window or open existing
+   if (m_bScriptManagerActive)
+   {
+      m_pwndScriptManager->BringWindowToTop();
+   }
+   else
+   {
+          pFrame->CreateNewChild(RUNTIME_CLASS(CScriptManager),
+                             IDR_SCRIPT_MANAGER,
+                             m_hScriptManagerMenu, m_hScriptManagerAccel);
+   }
+}
+
+
 //
 // Handler for WM_COMMAND::ID_VIEW_DEBUG message
 //
index d295691..50fd4b0 100644 (file)
@@ -465,6 +465,14 @@ SOURCE=.\SaveDesktopDlg.cpp
 # End Source File
 # Begin Source File
 
+SOURCE=.\ScriptManager.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\ScriptView.cpp
+# End Source File
+# Begin Source File
+
 SOURCE=.\ServerCfgEditor.cpp
 # End Source File
 # Begin Source File
@@ -918,6 +926,14 @@ SOURCE=.\SaveDesktopDlg.h
 # End Source File
 # Begin Source File
 
+SOURCE=.\ScriptManager.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\ScriptView.h
+# End Source File
+# Begin Source File
+
 SOURCE=.\ServerCfgEditor.h
 # End Source File
 # Begin Source File
@@ -1074,6 +1090,14 @@ SOURCE=.\icons\exec.ico
 # End Source File
 # Begin Source File
 
+SOURCE=.\icons\folder_c.ico
+# End Source File
+# Begin Source File
+
+SOURCE=.\icons\folder_o.ico
+# End Source File
+# Begin Source File
+
 SOURCE=.\icons\graph.ico
 # End Source File
 # Begin Source File
@@ -1194,6 +1218,14 @@ SOURCE=.\icons\running.ico
 # End Source File
 # Begin Source File
 
+SOURCE=.\icons\script.ico
+# End Source File
+# Begin Source File
+
+SOURCE=.\icons\script_library.ico
+# End Source File
+# Begin Source File
+
 SOURCE=.\icons\setup.ico
 # End Source File
 # Begin Source File
index 35d8b38..edf48e9 100644 (file)
@@ -57,6 +57,7 @@ inline BOOL SafeFreeResource(HGLOBAL hRes)
 #include "ObjectToolsEditor.h"
 #include "SyslogBrowser.h"
 #include "LPPList.h"
+#include "ScriptManager.h"
 
 
 //
@@ -138,6 +139,7 @@ protected:
    CPackageMgr *m_pwndPackageMgr;
    CServerCfgEditor *m_pwndServerCfgEditor;
    CObjectToolsEditor *m_pwndObjToolsEditor;
+   CScriptManager *m_pwndScriptManager;
    CLPPList *m_pwndLPPEditor;
 
    HMENU m_hMDIMenu;             // Default menu for MDI
@@ -176,6 +178,8 @@ protected:
        HACCEL m_hAgentCfgEditorAccel;// Accelerator for agent configuration editor
        HMENU m_hObjToolsEditorMenu;  // Menu for object tools editor
        HACCEL m_hObjToolsEditorAccel;// Accelerator for object tools editor
+       HMENU m_hScriptManagerMenu;   // Menu for script manager
+       HACCEL m_hScriptManagerAccel; // Accelerator for script manager
        
 public:
        void EventHandler(DWORD dwEvent, DWORD dwCode, void *pArg);
@@ -205,6 +209,7 @@ public:
        afx_msg void OnViewSyslog();
        afx_msg void OnControlpanelLogprocessing();
        afx_msg void OnControlpanelObjecttools();
+       afx_msg void OnControlpanelScriptlibrary();
        //}}AFX_MSG
        DECLARE_MESSAGE_MAP()
 private:
@@ -224,6 +229,7 @@ private:
    BOOL m_bPackageMgrActive;
    BOOL m_bServerCfgEditorActive;
    BOOL m_bObjToolsEditorActive;
+   BOOL m_bScriptManagerActive;
 
    DC_EDITOR m_openDCEditors[MAX_DC_EDITORS];
 
index 8d0c425..42656e4 100644 (file)
@@ -120,6 +120,10 @@ IDI_DOCUMENT            ICON    DISCARDABLE     "icons\\document.ico"
 IDI_LPP                 ICON    DISCARDABLE     "icons\\lpp.ico"
 IDI_OBJTOOLS            ICON    DISCARDABLE     "icons\\objtools.ico"
 IDI_COMMAND             ICON    DISCARDABLE     "icons\\command.ico"
+IDI_SCRIPT_LIBRARY      ICON    DISCARDABLE     "icons\\script_library.ico"
+IDI_SCRIPT              ICON    DISCARDABLE     "icons\\script.ico"
+IDI_CLOSED_FOLDER       ICON    DISCARDABLE     "icons\\folder_c.ico"
+IDI_OPEN_FOLDER         ICON    DISCARDABLE     "icons\\folder_o.ico"
 
 /////////////////////////////////////////////////////////////////////////////
 //
@@ -348,6 +352,8 @@ BEGIN
         MENUITEM "&Log processing",             ID_CONTROLPANEL_LOGPROCESSING
 
         MENUITEM "&Object Tools",               ID_CONTROLPANEL_OBJECTTOOLS
+        MENUITEM "Script &Library",             ID_CONTROLPANEL_SCRIPTLIBRARY
+
         MENUITEM "Server &configuration",       ID_CONTROLPANEL_SERVERCFG
         MENUITEM "&SNMP Traps",                 ID_CONTROLPANEL_SNMPTRAPS
         MENUITEM "&Users",                      ID_CONTROLPANEL_USERS
@@ -2821,6 +2827,7 @@ BEGIN
     IDR_SYSLOG_BROWSER      "\nSyslog\nSyslog"
     IDR_LPP_EDITOR          "\nLog Processing Configuration\nLog Processing Configuration"
     IDR_OBJECT_TOOLS_EDITOR "\nObject Tools\nObject Tools"
+    IDR_SCRIPT_MANAGER      "\nScript Library\nScript Library"
     IDR_EVENT_EDITOR        "\nEvent Editor\nEvent Editor"
     IDR_USER_EDITOR         "\nUsers and Groups\nUsers and Groups"
     IDR_NETWORK_SUMMARY     "\nNetwork Summary\nNetwork Summary"
index 286bf55..df0aced 100644 (file)
 #define IDD_NEW_OBJECT_TOOL             294
 #define IDI_COMMAND                     295
 #define IDD_OBJTOOL_OPTIONS             296
+#define IDI_SCRIPT_LIBRARY              297
+#define IDI_SCRIPT                      298
+#define IDI_CLOSED_FOLDER               299
+#define IDI_OPEN_FOLDER                 300
 #define ID_EDIT_BOX                     525
 #define IDC_STATIC_TITLE                1003
 #define IDC_STATIC_TEXT                 1004
 #define IDR_SYSLOG_BROWSER              8101
 #define IDR_LPP_EDITOR                  8102
 #define IDR_OBJECT_TOOLS_EDITOR         8103
+#define IDR_SCRIPT_MANAGER              8104
 #define IDR_EVENT_EDITOR                8105
 #define IDR_USER_EDITOR                 8106
 #define IDR_NETWORK_SUMMARY             8107
 #define ID_OBJECTTOOLS_DELETE           32962
 #define ID_ALARM_ENABLE_SPEAKER         32966
 #define ID_ALARM_SOUNDCONFIGURATION     32967
+#define ID_CONTROLPANEL_SCRIPTLIBRARY   32968
 #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        297
-#define _APS_NEXT_COMMAND_VALUE         32968
+#define _APS_NEXT_RESOURCE_VALUE        301
+#define _APS_NEXT_COMMAND_VALUE         32969
 #define _APS_NEXT_CONTROL_VALUE         1337
 #define _APS_NEXT_SYMED_VALUE           126
 #endif
index 745c5a2..dbe4502 100644 (file)
@@ -672,3 +672,22 @@ void DestroyStringList(TCHAR **ppList, DWORD dwSize)
       free(ppList[i]);
    safe_free(ppList);
 }
+
+
+//
+// Find item by text in tree control's subtree
+//
+
+HTREEITEM FindTreeCtrlItem(CTreeCtrl &ctrl, HTREEITEM hRoot, TCHAR *pszText)
+{
+   HTREEITEM hItem;
+
+   hItem = ctrl.GetChildItem(hRoot);
+   while(hItem != NULL)
+   {
+      if (!_tcsicmp(ctrl.GetItemText(hItem), pszText))
+         return hItem;
+      hItem = ctrl.GetNextItem(hItem, TVGN_NEXT);
+   }
+   return NULL;
+}
index 0a91ee0..297f71e 100644 (file)
@@ -5910,7 +5910,7 @@ void ClientSession::SendScript(CSCPMessage *pRequest)
 void ClientSession::UpdateScript(CSCPMessage *pRequest)
 {
    CSCPMessage msg;
-   TCHAR *pszCode, *pszEscCode, *pszQuery, szName[MAX_OBJECT_NAME];
+   TCHAR *pszCode, *pszEscCode, *pszQuery, szName[MAX_DB_STRING];
    DWORD dwScriptId;
 
    msg.SetCode(CMD_REQUEST_COMPLETED);
@@ -5918,7 +5918,7 @@ void ClientSession::UpdateScript(CSCPMessage *pRequest)
    if (m_dwSystemAccess & SYSTEM_ACCESS_MANAGE_SCRIPTS)
    {
       dwScriptId = pRequest->GetVariableLong(VID_SCRIPT_ID);
-      pRequest->GetVariableStr(VID_NAME, szName, MAX_OBJECT_NAME);
+      pRequest->GetVariableStr(VID_NAME, szName, MAX_DB_STRING);
       if (IsValidScriptName(szName))
       {
          pszCode = pRequest->GetVariableStr(VID_SCRIPT_CODE);
@@ -5926,7 +5926,7 @@ void ClientSession::UpdateScript(CSCPMessage *pRequest)
          {
             pszEscCode = EncodeSQLString(pszCode);
             free(pszCode);
-            pszQuery = (TCHAR *)malloc((_tcslen(pszEscCode) + 256) * sizeof(TCHAR));
+            pszQuery = (TCHAR *)malloc((_tcslen(pszEscCode) + MAX_DB_STRING + 256) * sizeof(TCHAR));
             if (dwScriptId == 0)
             {
                // New script