diff options
author | schmidt <douglascraigschmidt@users.noreply.github.com> | 1999-12-21 18:20:32 +0000 |
---|---|---|
committer | schmidt <douglascraigschmidt@users.noreply.github.com> | 1999-12-21 18:20:32 +0000 |
commit | 7ec2da4c782dce0486cb763b5f23c2b73636054c (patch) | |
tree | f0de331ba9d12a77ac3921c9b59e332f215a38ac /TAO/utils | |
parent | 050b3c596d140de0c3236ce7cae927a5864c969b (diff) | |
download | ATCD-7ec2da4c782dce0486cb763b5f23c2b73636054c.tar.gz |
ChangeLogTag:Tue Dec 21 08:02:43 1999 Douglas C. Schmidt <schmidt@tango.cs.wustl.edu>
Diffstat (limited to 'TAO/utils')
28 files changed, 2661 insertions, 0 deletions
diff --git a/TAO/utils/NamingViewer/AddNameServerDlg.cpp b/TAO/utils/NamingViewer/AddNameServerDlg.cpp new file mode 100644 index 00000000000..37f62ab53bb --- /dev/null +++ b/TAO/utils/NamingViewer/AddNameServerDlg.cpp @@ -0,0 +1,51 @@ +// $Id$ +// AddNameServerDlg.cpp : implementation file + +#include "stdafx.h" +#include "NamingViewer.h" +#include "AddNameServerDlg.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +///////////////////////////////////////////////////////////////////////////// +// CAddNameServerDlg dialog + + +CAddNameServerDlg::CAddNameServerDlg(CWnd* pParent /*=NULL*/) + : CDialog(CAddNameServerDlg::IDD, pParent) +{ + //{{AFX_DATA_INIT(CAddNameServerDlg) + m_IOR = _T(""); + m_Name = _T(""); + //}}AFX_DATA_INIT +} + + +void CAddNameServerDlg::DoDataExchange(CDataExchange* pDX) +{ + CDialog::DoDataExchange(pDX); + //{{AFX_DATA_MAP(CAddNameServerDlg) + DDX_Text(pDX, IDC_IOR, m_IOR); + DDX_Text(pDX, IDC_NAME, m_Name); + //}}AFX_DATA_MAP +} + + +BEGIN_MESSAGE_MAP(CAddNameServerDlg, CDialog) + //{{AFX_MSG_MAP(CAddNameServerDlg) + //}}AFX_MSG_MAP +END_MESSAGE_MAP() + +///////////////////////////////////////////////////////////////////////////// +// CAddNameServerDlg message handlers + +void CAddNameServerDlg::OnOK() +{ + // TODO: Add extra validation here + UpdateData(); + CDialog::OnOK(); +} diff --git a/TAO/utils/NamingViewer/AddNameServerDlg.h b/TAO/utils/NamingViewer/AddNameServerDlg.h new file mode 100644 index 00000000000..bba44188d47 --- /dev/null +++ b/TAO/utils/NamingViewer/AddNameServerDlg.h @@ -0,0 +1,48 @@ +// $Id$ +#if !defined(AFX_ADDNAMESERVERDLG_H__2AF5C355_B440_11D3_BF2C_00C0F03C565A__INCLUDED_) +#define AFX_ADDNAMESERVERDLG_H__2AF5C355_B440_11D3_BF2C_00C0F03C565A__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 +// AddNameServerDlg.h : header file +// + +///////////////////////////////////////////////////////////////////////////// +// CAddNameServerDlg dialog + +class CAddNameServerDlg : public CDialog +{ +// Construction +public: + CAddNameServerDlg(CWnd* pParent = NULL); // standard constructor + +// Dialog Data + //{{AFX_DATA(CAddNameServerDlg) + enum { IDD = IDD_ADD_NAME_SERVER }; + CString m_IOR; + CString m_Name; + //}}AFX_DATA + + +// Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CAddNameServerDlg) + protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support + //}}AFX_VIRTUAL + +// Implementation +protected: + + // Generated message map functions + //{{AFX_MSG(CAddNameServerDlg) + virtual void OnOK(); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_ADDNAMESERVERDLG_H__2AF5C355_B440_11D3_BF2C_00C0F03C565A__INCLUDED_) diff --git a/TAO/utils/NamingViewer/BindDialog.cpp b/TAO/utils/NamingViewer/BindDialog.cpp new file mode 100644 index 00000000000..e48f9cc3624 --- /dev/null +++ b/TAO/utils/NamingViewer/BindDialog.cpp @@ -0,0 +1,103 @@ +// $Id$ +// BindDialog.cpp : implementation file + +#include "stdafx.h" +#include "NamingViewer.h" +#include "BindDialog.h" +#include "ViewIORDialog.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +///////////////////////////////////////////////////////////////////////////// +// CBindDialog dialog + + +CBindDialog::CBindDialog(bool Context, CORBA::ORB_ptr pORB, CWnd* pParent /*=NULL*/) + : CDialog(CBindDialog::IDD, pParent) +{ + //{{AFX_DATA_INIT(CBindDialog) + m_IOR = _T(""); + m_ID = _T(""); + m_Kind = _T(""); + //}}AFX_DATA_INIT + m_pORB = pORB; + m_Context = Context; +} + + +void CBindDialog::DoDataExchange(CDataExchange* pDX) +{ + CDialog::DoDataExchange(pDX); + //{{AFX_DATA_MAP(CBindDialog) + DDX_Text(pDX, IDC_IOR, m_IOR); + DDX_Text(pDX, IDC_ID, m_ID); + DDX_Text(pDX, IDC_KIND, m_Kind); + //}}AFX_DATA_MAP +} + + +BEGIN_MESSAGE_MAP(CBindDialog, CDialog) + //{{AFX_MSG_MAP(CBindDialog) + ON_BN_CLICKED(IDC_VIEWIOR, OnViewior) + //}}AFX_MSG_MAP +END_MESSAGE_MAP() + +///////////////////////////////////////////////////////////////////////////// +// CBindDialog message handlers + +void CBindDialog::OnViewior() +{ + // TODO: Add your control notification handler code here + try + { + UpdateData(); + m_Object = m_pORB->string_to_object(m_IOR); + } + catch(CORBA::Exception& ex) + { + MessageBox(ex._id(), "CORBA::Exception"); + return; + } + ViewIORDialog Dialog(m_pORB, m_Object); + Dialog.DoModal(); +} + +BOOL CBindDialog::OnInitDialog() +{ + CDialog::OnInitDialog(); + + // TODO: Add extra initialization here + if(m_Context) + { + SetWindowText("Bind Context"); + } + else + { + SetWindowText("Bind Object"); + } + return TRUE; // return TRUE unless you set the focus to a control + // EXCEPTION: OCX Property Pages should return FALSE +} + +void CBindDialog::OnOK() +{ + // TODO: Add extra validation here + UpdateData(); + m_Name.length(1); + m_Name[0].id = CORBA::string_dup(m_ID); + m_Name[0].kind = CORBA::string_dup(m_Kind); + try + { + m_Object = m_pORB->string_to_object(m_IOR); + } + catch(CORBA::Exception& ex) + { + MessageBox(ex._id(), "Invalid IOR"); + return; + } + CDialog::OnOK(); +} diff --git a/TAO/utils/NamingViewer/BindDialog.h b/TAO/utils/NamingViewer/BindDialog.h new file mode 100644 index 00000000000..afb39a5739f --- /dev/null +++ b/TAO/utils/NamingViewer/BindDialog.h @@ -0,0 +1,58 @@ +// $Id$ +#if !defined(AFX_BINDDIALOG_H__1F34ADC5_B0D8_11D3_BF27_00C0F03C565A__INCLUDED_) +#define AFX_BINDDIALOG_H__1F34ADC5_B0D8_11D3_BF27_00C0F03C565A__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 +// BindDialog.h : header file +// +#include "tao/corba.h" +#include "orbsvcs/CosNamingC.h" +///////////////////////////////////////////////////////////////////////////// +// CBindDialog dialog + +class CBindDialog : public CDialog +{ +// Construction +public: + CBindDialog(bool Context, CORBA::ORB_ptr pORB, CWnd* pParent = NULL); // standard constructor + +// Dialog Data + //{{AFX_DATA(CBindDialog) + enum { IDD = IDD_BIND }; + CString m_IOR; + CString m_ID; + CString m_Kind; + //}}AFX_DATA + CORBA::Object_ptr GetObject() {return m_Object;}; + + CosNaming::Name& GetName() {return m_Name;}; + +// Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CBindDialog) + protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support + //}}AFX_VIRTUAL + +// Implementation +protected: + + // Generated message map functions + //{{AFX_MSG(CBindDialog) + afx_msg void OnViewior(); + virtual BOOL OnInitDialog(); + virtual void OnOK(); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() + CORBA::Object_var m_Object; + CORBA::ORB_ptr m_pORB; + CosNaming::Name m_Name; + bool m_Context; +}; + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_BINDDIALOG_H__1F34ADC5_B0D8_11D3_BF27_00C0F03C565A__INCLUDED_) diff --git a/TAO/utils/NamingViewer/BindNewContext.cpp b/TAO/utils/NamingViewer/BindNewContext.cpp new file mode 100644 index 00000000000..66d7f942ca3 --- /dev/null +++ b/TAO/utils/NamingViewer/BindNewContext.cpp @@ -0,0 +1,54 @@ +// $Id$ +// BindNewContext.cpp : implementation file + +#include "stdafx.h" +#include "NamingViewer.h" +#include "BindNewContext.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +///////////////////////////////////////////////////////////////////////////// +// CBindNewContext dialog + + +CBindNewContext::CBindNewContext(CWnd* pParent /*=NULL*/) + : CDialog(CBindNewContext::IDD, pParent) +{ + //{{AFX_DATA_INIT(CBindNewContext) + m_ID = _T(""); + m_Kind = _T(""); + //}}AFX_DATA_INIT +} + + +void CBindNewContext::DoDataExchange(CDataExchange* pDX) +{ + CDialog::DoDataExchange(pDX); + //{{AFX_DATA_MAP(CBindNewContext) + DDX_Text(pDX, IDC_ID, m_ID); + DDX_Text(pDX, IDC_KIND, m_Kind); + //}}AFX_DATA_MAP +} + + +BEGIN_MESSAGE_MAP(CBindNewContext, CDialog) + //{{AFX_MSG_MAP(CBindNewContext) + //}}AFX_MSG_MAP +END_MESSAGE_MAP() + +///////////////////////////////////////////////////////////////////////////// +// CBindNewContext message handlers + +void CBindNewContext::OnOK() +{ + // TODO: Add extra validation here + UpdateData(); + m_Name.length(1); + m_Name[0].id = CORBA::string_dup(m_ID); + m_Name[0].kind = CORBA::string_dup(m_Kind); + CDialog::OnOK(); +} diff --git a/TAO/utils/NamingViewer/BindNewContext.h b/TAO/utils/NamingViewer/BindNewContext.h new file mode 100644 index 00000000000..8c76dcdfc1e --- /dev/null +++ b/TAO/utils/NamingViewer/BindNewContext.h @@ -0,0 +1,50 @@ +// $Id$ +#if !defined(AFX_BINDNEWCONTEXT_H__2AF5C352_B440_11D3_BF2C_00C0F03C565A__INCLUDED_) +#define AFX_BINDNEWCONTEXT_H__2AF5C352_B440_11D3_BF2C_00C0F03C565A__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 +// BindNewContext.h : header file +// +#include "orbsvcs/CosNamingC.H" +///////////////////////////////////////////////////////////////////////////// +// CBindNewContext dialog + +class CBindNewContext : public CDialog +{ +// Construction +public: + CBindNewContext(CWnd* pParent = NULL); // standard constructor + +// Dialog Data + //{{AFX_DATA(CBindNewContext) + enum { IDD = IDD_BIND_NEW_CONTEXT }; + CString m_ID; + CString m_Kind; + //}}AFX_DATA + CosNaming::Name& GetName() {return m_Name;}; + +// Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CBindNewContext) + protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support + //}}AFX_VIRTUAL + +// Implementation +protected: + + // Generated message map functions + //{{AFX_MSG(CBindNewContext) + virtual void OnOK(); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() + + CosNaming::Name m_Name; +}; + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_BINDNEWCONTEXT_H__2AF5C352_B440_11D3_BF2C_00C0F03C565A__INCLUDED_) diff --git a/TAO/utils/NamingViewer/NamingObject.cpp b/TAO/utils/NamingViewer/NamingObject.cpp new file mode 100644 index 00000000000..31cc829598b --- /dev/null +++ b/TAO/utils/NamingViewer/NamingObject.cpp @@ -0,0 +1,49 @@ +// $Id$ +// NamingObject.cpp: implementation of the CNamingObject class. +// +////////////////////////////////////////////////////////////////////// + +#include "stdafx.h" +#include "NamingViewer.h" +#include "NamingObject.h" + +#ifdef _DEBUG +#undef THIS_FILE +static char THIS_FILE[]=__FILE__; +#define new DEBUG_NEW +#endif + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + +CNamingObject::CNamingObject(CosNaming::Name& Name, CORBA::Object_ptr pObject, bool Context) +: m_Name(Name), m_Object(CORBA::Object::_duplicate(pObject)), m_Context(Context) +{ + +} + + +CNamingObject::CNamingObject(CORBA::Object_ptr pObject) +: m_Object(CORBA::Object::_duplicate(pObject)) +{ +} + +CNamingObject::~CNamingObject() +{ +} + +CosNaming::NamingContext_ptr CNamingObject::NamingContext() +{ + return CosNaming::NamingContext::_narrow(m_Object); +} + +CORBA::Object_ptr CNamingObject::Object() +{ + return m_Object; +} + +CosNaming::Name& CNamingObject::Name() +{ + return m_Name; +} diff --git a/TAO/utils/NamingViewer/NamingObject.h b/TAO/utils/NamingViewer/NamingObject.h new file mode 100644 index 00000000000..209696b20e7 --- /dev/null +++ b/TAO/utils/NamingViewer/NamingObject.h @@ -0,0 +1,36 @@ +// $Id$ +// NamingObject.h: interface for the CNamingObject class. +// +////////////////////////////////////////////////////////////////////// + +#if !defined(AFX_NAMINGOBJECT_H__1F34ADC4_B0D8_11D3_BF27_00C0F03C565A__INCLUDED_) +#define AFX_NAMINGOBJECT_H__1F34ADC4_B0D8_11D3_BF27_00C0F03C565A__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 + +#include "orbsvcs/CosNamingC.h" + +class CNamingObject +{ +public: + CNamingObject(CosNaming::Name& Name, CORBA::Object_ptr pObject, bool Context); + CNamingObject(CORBA::Object_ptr pObject); + ~CNamingObject(); + + CosNaming::NamingContext_ptr NamingContext(); + // Returns a duplicated naming context ptr if this is a context or nil if its not + CORBA::Object_ptr Object(); + // returns a non duplicated object reference + CosNaming::Name& Name(); + // returns the name of the object + bool IsContext() {return m_Context;}; + // Returns true if this is a context +private: + CORBA::Object_var m_Object; + CosNaming::Name m_Name; + bool m_Context; +}; + +#endif // !defined(AFX_NAMINGOBJECT_H__1F34ADC4_B0D8_11D3_BF27_00C0F03C565A__INCLUDED_) diff --git a/TAO/utils/NamingViewer/NamingTreeCtrl.cpp b/TAO/utils/NamingViewer/NamingTreeCtrl.cpp new file mode 100644 index 00000000000..f83423d32d0 --- /dev/null +++ b/TAO/utils/NamingViewer/NamingTreeCtrl.cpp @@ -0,0 +1,505 @@ +// $Id$ +// NamingTreeCtrl.cpp : implementation file +// + +#include "stdafx.h" +#include "NamingViewer.h" +#include "NamingTreeCtrl.h" +#include "ViewIORDialog.h" +#include "NamingObject.h" +#include "BindDialog.h" +#include "BindNewContext.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +///////////////////////////////////////////////////////////////////////////// +// CNamingTreeCtrl + +CNamingTreeCtrl::CNamingTreeCtrl() +{ + m_ContextPopup.LoadMenu(IDR_CONTEXT_POPUP); + m_ObjectPopup.LoadMenu(IDR_OBJECT_POPUP); +} + +CNamingTreeCtrl::~CNamingTreeCtrl() +{ +} + + +BEGIN_MESSAGE_MAP(CNamingTreeCtrl, CTreeCtrl) + //{{AFX_MSG_MAP(CNamingTreeCtrl) + ON_WM_RBUTTONDOWN() + ON_COMMAND(ID_CONTEXT_POPUP_VIEWREFERENCE, OnContextPopupViewreference) + ON_NOTIFY_REFLECT(TVN_ITEMEXPANDING, OnItemexpanding) + ON_COMMAND(ID_CONTEXT_POPUP_REFRESH, OnContextPopupRefresh) + ON_COMMAND(ID_CONTEXT_POPUP_UNBIND, OnContextPopupUnbind) + ON_COMMAND(ID_CONTEXT_POPUP_DESTROY, OnContextPopupDestroy) + ON_COMMAND(ID_CONTEXT_POPUP_BIND_CONTEXT, OnContextPopupBindContext) + ON_COMMAND(ID_CONTEXT_POPUP_BINDOBJECT, OnContextPopupBindobject) + ON_WM_DESTROY() + ON_COMMAND(ID_CONTEXTPOPUP_BINDNEWCONTEXT, OnContextpopupBindnewcontext) + ON_NOTIFY_REFLECT(NM_DBLCLK, OnDblclk) + ON_COMMAND(ID_OBJECTPOPUP_UNBIND, OnObjectpopupUnbind) + ON_COMMAND(ID_OBJECTPOPUP_VIEWREFRENCE, OnObjectpopupViewrefrence) + //}}AFX_MSG_MAP +END_MESSAGE_MAP() + +///////////////////////////////////////////////////////////////////////////// +// CNamingTreeCtrl message handlers + +void CNamingTreeCtrl::OnRButtonDown(UINT nFlags, CPoint point) +{ + // TODO: Add your message handler code here and/or call default + // Special case here - this causes the entry to be selected when the right button + // is the first to be hit. strange + OnLButtonDown(nFlags, point); + + // Now find the item were hitting + HTREEITEM hItem = HitTest(point); + if(!hItem) + { + return; + } + SelectItem(hItem); + + POINT Point = point; + ClientToScreen(&Point); + CNamingObject* pObject = GetTreeObject(hItem); + CosNaming::NamingContext_var Context = pObject->NamingContext(); + if(CORBA::is_nil(Context)) + { + if(!m_ObjectPopup.GetSubMenu(0)->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, Point.x, Point.y, this)) + { + TRACE0("TrackPopupMenu Failed"); + } + } + else + { + if(!m_ContextPopup.GetSubMenu(0)->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, Point.x, Point.y, this)) + { + TRACE0("TrackPopupMenu Failed"); + } + } +} + +void CNamingTreeCtrl::OnContextPopupViewreference() +{ + // TODO: Add your command handler code here + ViewIORDialog Dialog(m_pORB, GetTreeObject()->Object()); + Dialog.DoModal(); +} + +void CNamingTreeCtrl::SetpORB(CORBA::ORB_ptr pORB) +{ + m_pORB = pORB; +} + +CNamingObject* CNamingTreeCtrl::GetTreeObject(HTREEITEM hItem) +{ + if(hItem == NULL) + { + hItem = GetSelectedItem(); + if(!hItem) + { + return 0; + } + } + CNamingObject* pObject = (CNamingObject*)GetItemData(hItem); + return pObject; +} + +void CNamingTreeCtrl::ClearChildren(HTREEITEM hItem) +{ + if(hItem == NULL) + { + HTREEITEM hItem = GetRootItem(); + if(hItem) + { + + //CORBA::Object_var Object = (CORBA::Object_ptr)GetItemData(hItem); + ClearChildren(hItem); + delete GetTreeObject(hItem); + DeleteItem(hItem); + } + return; + } + + HTREEITEM hChild; + while(hChild = GetNextItem(hItem, TVGN_CHILD)) + { + // Remove our reference count on the object reference + ClearChildren(hChild); + delete GetTreeObject(hChild); + DeleteItem(hChild); + } +} + + +#define LISTQUANTUM 40 + +void CNamingTreeCtrl::ListContext(HTREEITEM hItem) +{ + CWaitCursor Waiter; + try + { + // Get the items object and make sure we have a context + CNamingObject* pObject = GetTreeObject(hItem); + CosNaming::NamingContext_var Context = pObject->NamingContext(); + if(CORBA::is_nil(Context)) + { + return; + } + + // List the contexts entries + CosNaming::BindingList_var bl; + CosNaming::BindingIterator_var bi; + Context->list(LISTQUANTUM, bl, bi); + ListBindingList(hItem, Context, bl); + + if(!CORBA::is_nil(bi)) + { + while(bl->length()) + { + CString Text; + Text.Format("This context contains more than %d entries, list the next %d?", LISTQUANTUM, LISTQUANTUM); + if(MessageBox(Text, "Question", MB_YESNO) == IDNO) + { + return; + } + bi->next_n(LISTQUANTUM, bl); + ListBindingList(hItem, Context, bl); + } + bi->destroy(); + } + } + catch(CORBA::Exception& ex) + { + MessageBox(ex._id(), "CORBA::Exception"); + } +} + +void CNamingTreeCtrl::OnItemexpanding(NMHDR* pNMHDR, LRESULT* pResult) +{ + NM_TREEVIEW* pNMTreeView = (NM_TREEVIEW*)pNMHDR; + // TODO: Add your control notification handler code here + *pResult = 0; + // If this item has a child, it has already been listed so nothing to do.. + if(GetChildItem(pNMTreeView->itemNew.hItem)) + { + return; + } + ListContext(pNMTreeView->itemNew.hItem); +} + +void CNamingTreeCtrl::OnContextPopupRefresh() +{ + // TODO: Add your command handler code here + HTREEITEM hItem = GetSelectedItem(); + ClearChildren(hItem); + ListContext(hItem); +} + +void CNamingTreeCtrl::OnContextPopupUnbind() +{ + // TODO: Add your command handler code here + if(MessageBox("Are you sure you want to unbind this object?", "Confirm", MB_YESNO | MB_ICONEXCLAMATION) != IDYES) + { + return; + } + HTREEITEM hItem = GetSelectedItem(); + HTREEITEM hParent = GetParentItem(hItem); + if(!hParent) + { + return; + } + CNamingObject* pObject = GetTreeObject(hItem); + CNamingObject* pParent= GetTreeObject(hParent); + CosNaming::NamingContext_var Context = pParent->NamingContext(); + try + { + Context->unbind(pObject->Name()); + ClearChildren(hItem); + delete pObject; + DeleteItem(hItem); + } + catch(CORBA::Exception& ex) + { + MessageBox(ex._id(), "CORBA::Exception"); + } +} + +void CNamingTreeCtrl::Resolve(CosNaming::NamingContext_ptr pRootContext) +{ + ClearChildren(); + if(!CORBA::is_nil(pRootContext)) + { + HTREEITEM hItem = InsertItem("Root"); + SetItemData(hItem, (DWORD)new CNamingObject(pRootContext)); + ListContext(hItem); + } +} + +void CNamingTreeCtrl::OnContextPopupDestroy() +{ + // TODO: Add your command handler code here + if(MessageBox("Are you sure you want to destroy this context?", "Confirm", MB_YESNO | MB_ICONEXCLAMATION) != IDYES) + { + return; + } + HTREEITEM hItem = GetSelectedItem(); + HTREEITEM hParent = GetParentItem(hItem); + if(!hParent) + { + return; + } + CNamingObject* pObject = GetTreeObject(hItem); + CNamingObject* pParent= GetTreeObject(hParent); + CosNaming::NamingContext_var Parent = pParent->NamingContext(); + try + { + // First try to destroy, it will raise exception if its not empty + CosNaming::NamingContext_var Context = pObject->NamingContext(); + Context->destroy(); + // Ok its destroyed, clean up any children we might have laying around + ClearChildren(hItem); + DeleteItem(hItem); + // do the unbind + Parent->unbind(pObject->Name()); + delete pObject; + } + catch(CORBA::Exception& ex) + { + MessageBox(ex._id(), "CORBA::Exception"); + } +} + +void CNamingTreeCtrl::OnContextPopupBindContext() +{ + // TODO: Add your command handler code here + CBindDialog Dialog(true, m_pORB); + if(Dialog.DoModal() != IDOK) + { + return; + } + try + { + CNamingObject* pObject = GetTreeObject(); + CosNaming::NamingContext_var Context = pObject->NamingContext(); + if(CORBA::is_nil(Context)) + { + return; + } + CosNaming::NamingContext_var NewContext = CosNaming::NamingContext::_narrow(Dialog.GetObject()); + if(CORBA::is_nil(NewContext)) + { + AfxMessageBox("Object is not a CosNaming::NamingContext"); + return; + } + Context->bind_context(Dialog.GetName(), NewContext); + OnContextPopupRefresh(); + } + catch(CORBA::Exception& ex) + { + MessageBox(ex._id(), "CORBA::Exception"); + } +} + +void CNamingTreeCtrl::OnContextPopupBindobject() +{ + // TODO: Add your command handler code here + CBindDialog Dialog(false, m_pORB); + if(Dialog.DoModal() != IDOK) + { + return; + } + try + { + HTREEITEM hItem = GetSelectedItem(); + CNamingObject* pObject = GetTreeObject(hItem); + CosNaming::NamingContext_var Context = pObject->NamingContext(); + if(CORBA::is_nil(Context)) + { + return; + } + Context->bind(Dialog.GetName(), Dialog.GetObject()); + OnContextPopupRefresh(); + } + catch(CORBA::Exception& ex) + { + MessageBox(ex._id(), "CORBA::Exception"); + } +} + +void CNamingTreeCtrl::OnDestroy() +{ + CTreeCtrl::OnDestroy(); + + // TODO: Add your message handler code here + ClearChildren(); + +} + + +void CNamingTreeCtrl::OnContextpopupBindnewcontext() +{ + // TODO: Add your command handler code here + HTREEITEM hItem = GetSelectedItem(); + CNamingObject* pObject = GetTreeObject(hItem); + CosNaming::NamingContext_var Context = pObject->NamingContext(); + if(CORBA::is_nil(Context)) + { + return; + } + CBindNewContext Dialog; + if(Dialog.DoModal() != IDOK) + { + return; + } + try + { + CosNaming::NamingContext_var NewContext; + NewContext = Context->new_context(); + Context->bind_context(Dialog.GetName(), NewContext); + OnContextPopupRefresh(); + } + catch(CORBA::Exception& ex) + { + MessageBox(ex._id(), "CORBA::Exception"); + } +} + +void CNamingTreeCtrl::OnDblclk(NMHDR* pNMHDR, LRESULT* pResult) +{ + // TODO: Add your control notification handler code here + CNamingObject* pObject = GetTreeObject(); + // Only display non contexts + if(!pObject->IsContext()) + { + ViewIORDialog Dialog(m_pORB, pObject->Object()); + Dialog.DoModal(); + } + + *pResult = 0; +} + +void CNamingTreeCtrl::OnCopy() +{ + // TODO: Add your command handler code here + CNamingObject* pObject = GetTreeObject(); + try + { + CString IOR = m_pORB->object_to_string(pObject->Object()); + // Copy to the clipboard by using the CEdit control. This is easier + // that doing it the right way + CEdit Temp; + CRect None(0,0, 1, 1); + Temp.Create(0, None, this, 0); + Temp.SetWindowText(IOR); + Temp.SetSel(0, IOR.GetLength()); + Temp.Copy(); + Temp.PostMessage(WM_CLOSE); + } + catch(CORBA::Exception& ex) + { + MessageBox(ex._id(), "CORBA::Exception"); + } +} + +LRESULT CNamingTreeCtrl::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) +{ + // TODO: Add your specialized code here and/or call the base class + if(message == WM_HOTKEY) + { + // To trap control-c (for copying) we registered a hotkey. For some reason + // MFC wasn't calling my OnHotKey() function that I registered so I am forcing + // it this way. Anyone know the right way to do this? + OnCopy(); + } + return CTreeCtrl::WindowProc(message, wParam, lParam); +} + +void CNamingTreeCtrl::OnObjectpopupUnbind() +{ + // TODO: Add your command handler code here + if(MessageBox("Are you sure you want to unbind this object?", "Confirm", MB_YESNO | MB_ICONEXCLAMATION) != IDYES) + { + return; + } + HTREEITEM hItem = GetSelectedItem(); + HTREEITEM hParent = GetParentItem(hItem); + if(!hParent) + { + return; + } + CNamingObject* pObject = GetTreeObject(hItem); + CNamingObject* pParent= GetTreeObject(hParent); + CosNaming::NamingContext_var Context = pParent->NamingContext(); + try + { + Context->unbind(pObject->Name()); + ClearChildren(hItem); + delete pObject; + DeleteItem(hItem); + } + catch(CORBA::Exception& ex) + { + MessageBox(ex._id(), "CORBA::Exception"); + } +} + +void CNamingTreeCtrl::OnObjectpopupViewrefrence() +{ + // TODO: Add your command handler code here + ViewIORDialog Dialog(m_pORB, GetTreeObject()->Object()); + Dialog.DoModal(); +} + +void CNamingTreeCtrl::ListBindingList(HTREEITEM hItem, CosNaming::NamingContext_ptr pContext, CosNaming::BindingList_var& bl) +{ + try + { + for(unsigned int i=0; i < bl->length(); i++) + { + // Add each entry into the tree control + CORBA::Object_var Object = pContext->resolve(bl[i].binding_name); + bool Context = (bl[i].binding_type == CosNaming::ncontext); + CNamingObject* pNewObject = new CNamingObject(bl[i].binding_name, Object, Context); + CString Name; + const char* pKind = (bl[i].binding_name[0]).kind; + if(*pKind) + { + Name.Format("%s | %s", (bl[i].binding_name[0]).id, pKind); + } + else + { + Name.Format("%s", (bl[i].binding_name[0]).id); + } + HTREEITEM hContext = InsertItem(Name, hItem); + SetItemData(hContext, (DWORD)pNewObject); + switch(bl[i].binding_type) + { + case CosNaming::ncontext: + { + // Set the children flag so the + button is displayed + TV_ITEM Item; + Item.mask = TVIF_CHILDREN | TVIF_HANDLE; + Item.cChildren = 1; + Item.hItem = hContext; + SetItem(&Item); + } + break; + case CosNaming::nobject: + break; + } + } + } + catch(CORBA::Exception& ex) + { + MessageBox(ex._id(), "CORBA::Exception"); + } +} + diff --git a/TAO/utils/NamingViewer/NamingTreeCtrl.h b/TAO/utils/NamingViewer/NamingTreeCtrl.h new file mode 100644 index 00000000000..8c871ad3792 --- /dev/null +++ b/TAO/utils/NamingViewer/NamingTreeCtrl.h @@ -0,0 +1,75 @@ +// $Id$ +#if !defined(AFX_NAMINGTREECTRL_H__1F34ADC2_B0D8_11D3_BF27_00C0F03C565A__INCLUDED_) +#define AFX_NAMINGTREECTRL_H__1F34ADC2_B0D8_11D3_BF27_00C0F03C565A__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 +// NamingTreeCtrl.h : header file +// +#include "orbsvcs/CosNamingC.h" +class CNamingObject; + +///////////////////////////////////////////////////////////////////////////// +// CNamingTreeCtrl window + +class CNamingTreeCtrl : public CTreeCtrl +{ +// Construction +public: + CNamingTreeCtrl(); + +// Attributes +public: + void SetpORB(CORBA::ORB_ptr pORB); +// Operations +public: + CNamingObject* GetTreeObject(HTREEITEM hItem = NULL); + void ClearChildren(HTREEITEM hItem = NULL); + void ListContext(HTREEITEM hItem); + void Resolve(CosNaming::NamingContext_ptr pRootContext); +// Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CNamingTreeCtrl) + protected: + virtual LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam); + //}}AFX_VIRTUAL + +// Implementation +public: + virtual ~CNamingTreeCtrl(); + + // Generated message map functions +protected: + //{{AFX_MSG(CNamingTreeCtrl) + afx_msg void OnRButtonDown(UINT nFlags, CPoint point); + afx_msg void OnContextPopupViewreference(); + afx_msg void OnItemexpanding(NMHDR* pNMHDR, LRESULT* pResult); + afx_msg void OnContextPopupRefresh(); + afx_msg void OnContextPopupUnbind(); + afx_msg void OnContextPopupDestroy(); + afx_msg void OnContextPopupBindContext(); + afx_msg void OnContextPopupBindobject(); + afx_msg void OnDestroy(); + afx_msg void OnContextpopupBindnewcontext(); + afx_msg void OnDblclk(NMHDR* pNMHDR, LRESULT* pResult); + afx_msg void OnObjectpopupUnbind(); + afx_msg void OnObjectpopupViewrefrence(); + //}}AFX_MSG + + DECLARE_MESSAGE_MAP() + + void Refresh(HTREEITEM hItem); + void OnCopy(); + void ListBindingList(HTREEITEM hItem, CosNaming::NamingContext_ptr pContext, CosNaming::BindingList_var& bl); + CMenu m_ContextPopup; + CMenu m_ObjectPopup; + CORBA::ORB_ptr m_pORB; +}; + +///////////////////////////////////////////////////////////////////////////// + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_NAMINGTREECTRL_H__1F34ADC2_B0D8_11D3_BF27_00C0F03C565A__INCLUDED_) diff --git a/TAO/utils/NamingViewer/NamingViewer.cpp b/TAO/utils/NamingViewer/NamingViewer.cpp new file mode 100644 index 00000000000..78007a11783 --- /dev/null +++ b/TAO/utils/NamingViewer/NamingViewer.cpp @@ -0,0 +1,84 @@ +// $Id$ +// NamingViewer.cpp : Defines the class behaviors for the application. +// + +#include "stdafx.h" +#include "NamingViewer.h" +#include "NamingViewerDlg.h" +#include "ace/ARGV.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +///////////////////////////////////////////////////////////////////////////// +// CNamingViewerApp + +BEGIN_MESSAGE_MAP(CNamingViewerApp, CWinApp) + //{{AFX_MSG_MAP(CNamingViewerApp) + // NOTE - the ClassWizard will add and remove mapping macros here. + // DO NOT EDIT what you see in these blocks of generated code! + //}}AFX_MSG + ON_COMMAND(ID_HELP, CWinApp::OnHelp) +END_MESSAGE_MAP() + +///////////////////////////////////////////////////////////////////////////// +// CNamingViewerApp construction + +CNamingViewerApp::CNamingViewerApp() +{ + // TODO: add construction code here, + // Place all significant initialization in InitInstance +} + +///////////////////////////////////////////////////////////////////////////// +// The one and only CNamingViewerApp object + +CNamingViewerApp theApp; + +///////////////////////////////////////////////////////////////////////////// +// CNamingViewerApp initialization + +BOOL CNamingViewerApp::InitInstance() +{ + // Standard initialization + // If you are not using these features and wish to reduce the size + // of your final executable, you should remove from the following + // the specific initialization routines you do not need. + +#ifdef _AFXDLL + Enable3dControls(); // Call this when using MFC in a shared DLL +#else + Enable3dControlsStatic(); // Call this when linking to MFC statically +#endif + + // Parse command line arguments so we can initialize ORB with them + ACE_ARGV Argv(m_lpCmdLine); + + ACE::init(); + { + + int argc = Argv.argc(); + char** argv = Argv.argv(); + CORBA::ORB_var ORB = CORBA::ORB_init(argc, argv); + CNamingViewerDlg dlg(ORB); + m_pMainWnd = &dlg; + int nResponse = dlg.DoModal(); + if (nResponse == IDOK) + { + // TODO: Place code here to handle when the dialog is + // dismissed with OK + } + else if (nResponse == IDCANCEL) + { + // TODO: Place code here to handle when the dialog is + // dismissed with Cancel + } + } + ACE::fini(); + // Since the dialog has been closed, return FALSE so that we exit the + // application, rather than start the application's message pump. + return FALSE; +} diff --git a/TAO/utils/NamingViewer/NamingViewer.dsp b/TAO/utils/NamingViewer/NamingViewer.dsp new file mode 100644 index 00000000000..d50c122b9e3 --- /dev/null +++ b/TAO/utils/NamingViewer/NamingViewer.dsp @@ -0,0 +1,204 @@ +# Microsoft Developer Studio Project File - Name="NamingViewer" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Application" 0x0101
+
+CFG=NamingViewer - Win32 Debug
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE
+!MESSAGE NMAKE /f "NamingViewer.mak".
+!MESSAGE
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE
+!MESSAGE NMAKE /f "NamingViewer.mak" CFG="NamingViewer - Win32 Debug"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "NamingViewer - Win32 Release" (based on "Win32 (x86) Application")
+!MESSAGE "NamingViewer - Win32 Debug" (based on "Win32 (x86) Application")
+!MESSAGE
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+MTL=midl.exe
+RSC=rc.exe
+
+!IF "$(CFG)" == "NamingViewer - Win32 Release"
+
+# PROP BASE Use_MFC 6
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 6
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release"
+# PROP Intermediate_Dir "Release"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_AFXDLL" /Yu"stdafx.h" /FD /c
+# ADD CPP /nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_AFXDLL" /D "_MBCS" /Yu"stdafx.h" /FD /c
+# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x409 /d "NDEBUG" /d "_AFXDLL"
+# ADD RSC /l 0x409 /d "NDEBUG" /d "_AFXDLL"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 /nologo /subsystem:windows /machine:I386
+# ADD LINK32 tao.lib ace.lib orbsvcs.lib /nologo /subsystem:windows /machine:I386
+
+!ELSEIF "$(CFG)" == "NamingViewer - Win32 Debug"
+
+# PROP BASE Use_MFC 6
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Debug"
+# PROP BASE Intermediate_Dir "Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 6
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "Debug"
+# PROP Intermediate_Dir "Debug"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_AFXDLL" /Yu"stdafx.h" /FD /c
+# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_AFXDLL" /D "_MBCS" /Yu"stdafx.h" /FD /c
+# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x409 /d "_DEBUG" /d "_AFXDLL"
+# ADD RSC /l 0x409 /d "_DEBUG" /d "_AFXDLL"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 taod.lib aced.lib orbsvcsd.lib /nologo /subsystem:windows /debug /machine:I386 /out:"Debug/NamingViewerd.exe" /pdbtype:sept
+
+!ENDIF
+
+# Begin Target
+
+# Name "NamingViewer - Win32 Release"
+# Name "NamingViewer - Win32 Debug"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Source File
+
+SOURCE=.\AddNameServerDlg.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\BindDialog.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\BindNewContext.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\NamingObject.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\NamingTreeCtrl.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\NamingViewer.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\NamingViewer.rc
+# End Source File
+# Begin Source File
+
+SOURCE=.\NamingViewerDlg.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\SelectNSDialog.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\StdAfx.cpp
+# ADD CPP /Yc"stdafx.h"
+# End Source File
+# Begin Source File
+
+SOURCE=.\ViewIORDialog.cpp
+# End Source File
+# End Group
+# Begin Group "Header Files"
+
+# PROP Default_Filter "h;hpp;hxx;hm;inl"
+# Begin Source File
+
+SOURCE=.\AddNameServerDlg.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\BindDialog.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\BindNewContext.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\NamingObject.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\NamingTreeCtrl.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\NamingViewer.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\NamingViewerDlg.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\Resource.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\SelectNSDialog.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\StdAfx.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\ViewIORDialog.h
+# End Source File
+# End Group
+# Begin Group "Resource Files"
+
+# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
+# Begin Source File
+
+SOURCE=.\res\NamingViewer.ico
+# End Source File
+# Begin Source File
+
+SOURCE=.\res\NamingViewer.rc2
+# End Source File
+# End Group
+# Begin Source File
+
+SOURCE=.\ReadMe.txt
+# End Source File
+# End Target
+# End Project
diff --git a/TAO/utils/NamingViewer/NamingViewer.dsw b/TAO/utils/NamingViewer/NamingViewer.dsw new file mode 100644 index 00000000000..229fa03398e --- /dev/null +++ b/TAO/utils/NamingViewer/NamingViewer.dsw @@ -0,0 +1,29 @@ +Microsoft Developer Studio Workspace File, Format Version 6.00
+# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
+
+###############################################################################
+
+Project: "NamingViewer"=.\NamingViewer.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+}}}
+
+###############################################################################
+
+Global:
+
+Package=<5>
+{{{
+}}}
+
+Package=<3>
+{{{
+}}}
+
+###############################################################################
+
diff --git a/TAO/utils/NamingViewer/NamingViewer.h b/TAO/utils/NamingViewer/NamingViewer.h new file mode 100644 index 00000000000..84853ad13cd --- /dev/null +++ b/TAO/utils/NamingViewer/NamingViewer.h @@ -0,0 +1,50 @@ +// $Id$ +// NamingViewer.h : main header file for the NAMINGVIEWER application +// + +#if !defined(AFX_NAMINGVIEWER_H__B9C0EB96_AD28_11D3_BF1F_00C0F03C565A__INCLUDED_) +#define AFX_NAMINGVIEWER_H__B9C0EB96_AD28_11D3_BF1F_00C0F03C565A__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 + +#ifndef __AFXWIN_H__ + #error include 'stdafx.h' before including this file for PCH +#endif + +#include "resource.h" // main symbols + +///////////////////////////////////////////////////////////////////////////// +// CNamingViewerApp: +// See NamingViewer.cpp for the implementation of this class +// + +class CNamingViewerApp : public CWinApp +{ +public: + CNamingViewerApp(); + +// Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CNamingViewerApp) + public: + virtual BOOL InitInstance(); + //}}AFX_VIRTUAL + +// Implementation + + //{{AFX_MSG(CNamingViewerApp) + // NOTE - the ClassWizard will add and remove member functions here. + // DO NOT EDIT what you see in these blocks of generated code ! + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; + + +///////////////////////////////////////////////////////////////////////////// + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_NAMINGVIEWER_H__B9C0EB96_AD28_11D3_BF1F_00C0F03C565A__INCLUDED_) diff --git a/TAO/utils/NamingViewer/NamingViewer.rc b/TAO/utils/NamingViewer/NamingViewer.rc new file mode 100644 index 00000000000..7f85193a752 --- /dev/null +++ b/TAO/utils/NamingViewer/NamingViewer.rc @@ -0,0 +1,355 @@ +//Microsoft Developer Studio generated resource script. +// +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#include "afxres.h" + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// English (U.S.) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +#ifdef _WIN32 +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US +#pragma code_page(1252) +#endif //_WIN32 + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE DISCARDABLE +BEGIN + "resource.h\0" +END + +2 TEXTINCLUDE DISCARDABLE +BEGIN + "#include ""afxres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE DISCARDABLE +BEGIN + "#define _AFX_NO_SPLITTER_RESOURCES\r\n" + "#define _AFX_NO_OLE_RESOURCES\r\n" + "#define _AFX_NO_TRACKER_RESOURCES\r\n" + "#define _AFX_NO_PROPERTY_RESOURCES\r\n" + "\r\n" + "#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)\r\n" + "#ifdef _WIN32\r\n" + "LANGUAGE 9, 1\r\n" + "#pragma code_page(1252)\r\n" + "#endif //_WIN32\r\n" + "#include ""res\\NamingViewer.rc2"" // non-Microsoft Visual C++ edited resources\r\n" + "#include ""afxres.rc"" // Standard components\r\n" + "#endif\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// Icon +// + +// Icon with lowest ID value placed first to ensure application icon +// remains consistent on all systems. +IDR_MAINFRAME ICON DISCARDABLE "res\\NamingViewer.ico" + +///////////////////////////////////////////////////////////////////////////// +// +// Dialog +// + +IDD_ABOUTBOX DIALOG DISCARDABLE 0, 0, 235, 62 +STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU +CAPTION "About NamingViewer" +FONT 8, "MS Sans Serif" +BEGIN + ICON IDR_MAINFRAME,IDC_STATIC,11,17,21,20 + LTEXT "NamingViewer Version 1.0",IDC_STATIC,40,10,119,8, + SS_NOPREFIX + LTEXT "Copyright (C) 1999",IDC_STATIC,40,25,119,8 + DEFPUSHBUTTON "OK",IDOK,178,7,50,14,WS_GROUP + LTEXT "Author: Chris Hafey (chris@stentorsoft.com)",IDC_STATIC, + 40,41,138,8 +END + +IDD_NAMINGVIEWER_DIALOG DIALOGEX 0, 0, 248, 198 +STYLE WS_MINIMIZEBOX | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU | + WS_THICKFRAME +EXSTYLE WS_EX_APPWINDOW +CAPTION "NamingViewer" +FONT 8, "MS Sans Serif" +BEGIN + CONTROL "Tree1",IDC_TREE,"SysTreeView32",TVS_HASBUTTONS | + TVS_HASLINES | TVS_LINESATROOT | WS_BORDER | WS_TABSTOP, + 7,42,234,149 + GROUPBOX "Name Server",IDC_NS,7,7,234,30 + PUSHBUTTON "Select",IDC_SELECT_NS,184,18,50,12 + EDITTEXT IDC_SERVER,13,18,158,12,ES_AUTOHSCROLL | ES_READONLY +END + +IDD_VIEWIOR_DIALOG DIALOG DISCARDABLE 0, 0, 399, 127 +STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU +CAPTION "View IOR" +FONT 8, "MS Sans Serif" +BEGIN + PUSHBUTTON "OK",IDOK,342,26,50,14 + LTEXT "IOR:",IDC_STATIC,7,9,16,8 + EDITTEXT IDC_IOR,27,7,304,12,ES_AUTOHSCROLL + LTEXT "Repository ID:",IDC_STATIC,7,30,46,8 + EDITTEXT IDC_TYPE_ID,57,27,274,12,ES_AUTOHSCROLL | ES_READONLY + DEFPUSHBUTTON "Apply",IDC_APPLY,342,7,50,14 + CONTROL "Tree1",IDC_PROFILES,"SysTreeView32",TVS_HASBUTTONS | + TVS_HASLINES | TVS_LINESATROOT | WS_BORDER | WS_TABSTOP, + 7,49,385,70 +END + +IDD_BIND DIALOG DISCARDABLE 0, 0, 279, 66 +STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU +CAPTION "Bind Object/Context" +FONT 8, "MS Sans Serif" +BEGIN + DEFPUSHBUTTON "OK",IDOK,77,45,50,14 + PUSHBUTTON "Cancel",IDCANCEL,152,45,50,14 + LTEXT "Id:",IDC_STATIC,7,9,9,8 + EDITTEXT IDC_ID,35,7,115,12,ES_AUTOHSCROLL + LTEXT "Kind:",IDC_STATIC,163,9,17,8 + LTEXT "IOR:",IDC_STATIC,7,28,22,8 + EDITTEXT IDC_IOR,35,26,174,12,ES_AUTOHSCROLL + EDITTEXT IDC_KIND,185,7,87,12,ES_AUTOHSCROLL + PUSHBUTTON "View IOR",IDC_VIEWIOR,222,26,50,12 +END + +IDD_BIND_NEW_CONTEXT DIALOG DISCARDABLE 0, 0, 159, 76 +STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU +CAPTION "Bind New Context" +FONT 8, "MS Sans Serif" +BEGIN + EDITTEXT IDC_ID,27,7,125,12,ES_AUTOHSCROLL + EDITTEXT IDC_KIND,27,31,125,12,ES_AUTOHSCROLL + DEFPUSHBUTTON "OK",IDOK,18,55,50,14 + PUSHBUTTON "Cancel",IDCANCEL,91,55,50,14 + LTEXT "Id:",IDC_STATIC,7,10,16,8 + LTEXT "Kind:",IDC_STATIC,7,34,17,8 +END + +IDD_SELECT_NS DIALOG DISCARDABLE 0, 0, 186, 94 +STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU +CAPTION "Select Naming Service" +FONT 8, "MS Sans Serif" +BEGIN + LISTBOX IDC_SERVERS,7,7,107,80,LBS_SORT | LBS_NOINTEGRALHEIGHT | + WS_VSCROLL | WS_TABSTOP + DEFPUSHBUTTON "OK",IDOK,129,7,50,14 + PUSHBUTTON "Add",IDC_ADD,129,29,50,14 + PUSHBUTTON "Remove",IDC_REMOVE,129,51,50,14 + PUSHBUTTON "Cancel",IDCANCEL,129,73,50,14 +END + +IDD_ADD_NAME_SERVER DIALOG DISCARDABLE 0, 0, 186, 69 +STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU +CAPTION "Add Name Server" +FONT 8, "MS Sans Serif" +BEGIN + DEFPUSHBUTTON "OK",IDOK,26,48,50,14 + PUSHBUTTON "Cancel",IDCANCEL,109,48,50,14 + LTEXT "Name:",IDC_STATIC,7,10,22,8 + LTEXT "IOR:",IDC_STATIC,7,30,24,8 + EDITTEXT IDC_NAME,36,7,143,12,ES_AUTOHSCROLL + EDITTEXT IDC_IOR,37,27,142,12,ES_AUTOHSCROLL +END + + +#ifndef _MAC +///////////////////////////////////////////////////////////////////////////// +// +// Version +// + +VS_VERSION_INFO VERSIONINFO + FILEVERSION 1,0,0,1 + PRODUCTVERSION 1,0,0,1 + FILEFLAGSMASK 0x3fL +#ifdef _DEBUG + FILEFLAGS 0x1L +#else + FILEFLAGS 0x0L +#endif + FILEOS 0x4L + FILETYPE 0x1L + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904B0" + BEGIN + VALUE "CompanyName", "\0" + VALUE "FileDescription", "NamingViewer MFC Application\0" + VALUE "FileVersion", "1, 0, 0, 1\0" + VALUE "InternalName", "NamingViewer\0" + VALUE "LegalCopyright", "Copyright (C) 1999\0" + VALUE "LegalTrademarks", "\0" + VALUE "OriginalFilename", "NamingViewer.EXE\0" + VALUE "ProductName", "NamingViewer Application\0" + VALUE "ProductVersion", "1, 0, 0, 1\0" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1200 + END +END + +#endif // !_MAC + + +///////////////////////////////////////////////////////////////////////////// +// +// DESIGNINFO +// + +#ifdef APSTUDIO_INVOKED +GUIDELINES DESIGNINFO DISCARDABLE +BEGIN + IDD_ABOUTBOX, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 228 + TOPMARGIN, 7 + BOTTOMMARGIN, 55 + END + + IDD_NAMINGVIEWER_DIALOG, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 241 + TOPMARGIN, 7 + BOTTOMMARGIN, 191 + END + + IDD_VIEWIOR_DIALOG, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 392 + TOPMARGIN, 7 + BOTTOMMARGIN, 120 + END + + IDD_BIND, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 272 + TOPMARGIN, 7 + BOTTOMMARGIN, 59 + END + + IDD_BIND_NEW_CONTEXT, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 152 + TOPMARGIN, 7 + BOTTOMMARGIN, 69 + END + + IDD_SELECT_NS, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 179 + TOPMARGIN, 7 + BOTTOMMARGIN, 87 + END + + IDD_ADD_NAME_SERVER, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 179 + TOPMARGIN, 7 + BOTTOMMARGIN, 62 + END +END +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// Menu +// + +IDR_CONTEXT_POPUP MENU DISCARDABLE +BEGIN + POPUP "Context_Popup" + BEGIN + MENUITEM "Bind Context", ID_CONTEXT_POPUP_BIND_CONTEXT + + MENUITEM "Bind New Context", ID_CONTEXTPOPUP_BINDNEWCONTEXT + + MENUITEM "Bind Object", ID_CONTEXT_POPUP_BINDOBJECT + MENUITEM "Unbind", ID_CONTEXT_POPUP_UNBIND + MENUITEM "Destroy", ID_CONTEXT_POPUP_DESTROY + MENUITEM "View Reference", ID_CONTEXT_POPUP_VIEWREFERENCE + + MENUITEM "Refresh", ID_CONTEXT_POPUP_REFRESH + END +END + +IDR_OBJECT_POPUP MENU DISCARDABLE +BEGIN + POPUP "Object_Popup" + BEGIN + MENUITEM "Unbind", ID_OBJECTPOPUP_UNBIND + MENUITEM "View Refrence", ID_OBJECTPOPUP_VIEWREFRENCE + END +END + + +///////////////////////////////////////////////////////////////////////////// +// +// String Table +// + +STRINGTABLE DISCARDABLE +BEGIN + IDS_ABOUTBOX "&About NamingViewer..." +END + +#endif // English (U.S.) resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// +#define _AFX_NO_SPLITTER_RESOURCES +#define _AFX_NO_OLE_RESOURCES +#define _AFX_NO_TRACKER_RESOURCES +#define _AFX_NO_PROPERTY_RESOURCES + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +#ifdef _WIN32 +LANGUAGE 9, 1 +#pragma code_page(1252) +#endif //_WIN32 +#include "res\NamingViewer.rc2" // non-Microsoft Visual C++ edited resources +#include "afxres.rc" // Standard components +#endif + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/TAO/utils/NamingViewer/NamingViewerDlg.cpp b/TAO/utils/NamingViewer/NamingViewerDlg.cpp new file mode 100644 index 00000000000..214169ab395 --- /dev/null +++ b/TAO/utils/NamingViewer/NamingViewerDlg.cpp @@ -0,0 +1,262 @@ +// $Id$ +// NamingViewerDlg.cpp : implementation file +// + +#include "stdafx.h" +#include "NamingViewer.h" +#include "NamingViewerDlg.h" +#include "ViewIORDialog.h" +#include "ORBSvcs/Naming/Naming_Utils.h" +#include "SelectNSDialog.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +///////////////////////////////////////////////////////////////////////////// +// CAboutDlg dialog used for App About + +class CAboutDlg : public CDialog +{ +public: + CAboutDlg(); + +// Dialog Data + //{{AFX_DATA(CAboutDlg) + enum { IDD = IDD_ABOUTBOX }; + //}}AFX_DATA + + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CAboutDlg) + protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support + //}}AFX_VIRTUAL + +// Implementation +protected: + //{{AFX_MSG(CAboutDlg) + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; + +CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD) +{ + //{{AFX_DATA_INIT(CAboutDlg) + //}}AFX_DATA_INIT +} + +void CAboutDlg::DoDataExchange(CDataExchange* pDX) +{ + CDialog::DoDataExchange(pDX); + //{{AFX_DATA_MAP(CAboutDlg) + //}}AFX_DATA_MAP +} + +BEGIN_MESSAGE_MAP(CAboutDlg, CDialog) + //{{AFX_MSG_MAP(CAboutDlg) + // No message handlers + //}}AFX_MSG_MAP +END_MESSAGE_MAP() + +///////////////////////////////////////////////////////////////////////////// +// CNamingViewerDlg dialog + +CNamingViewerDlg::CNamingViewerDlg(CORBA::ORB_ptr pORB, CWnd* pParent /*=NULL*/) + : CDialog(CNamingViewerDlg::IDD, pParent) +{ + //{{AFX_DATA_INIT(CNamingViewerDlg) + m_Server = _T(""); + //}}AFX_DATA_INIT + // Note that LoadIcon does not require a subsequent DestroyIcon in Win32 + m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME); + + m_pORB = pORB; + +} + +void CNamingViewerDlg::DoDataExchange(CDataExchange* pDX) +{ + CDialog::DoDataExchange(pDX); + //{{AFX_DATA_MAP(CNamingViewerDlg) + DDX_Control(pDX, IDC_TREE, m_Tree); + DDX_Text(pDX, IDC_SERVER, m_Server); + //}}AFX_DATA_MAP +} + +BEGIN_MESSAGE_MAP(CNamingViewerDlg, CDialog) + //{{AFX_MSG_MAP(CNamingViewerDlg) + ON_WM_SYSCOMMAND() + ON_WM_PAINT() + ON_WM_QUERYDRAGICON() + ON_BN_CLICKED(IDC_SELECT_NS, OnSelectNs) + ON_WM_SIZE() + //}}AFX_MSG_MAP + ON_WM_GETMINMAXINFO() +END_MESSAGE_MAP() + +///////////////////////////////////////////////////////////////////////////// +// CNamingViewerDlg message handlers + +BOOL CNamingViewerDlg::OnInitDialog() +{ + CDialog::OnInitDialog(); + + // Add "About..." menu item to system menu. + + // IDM_ABOUTBOX must be in the system command range. + ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX); + ASSERT(IDM_ABOUTBOX < 0xF000); + + CMenu* pSysMenu = GetSystemMenu(FALSE); + if (pSysMenu != NULL) + { + CString strAboutMenu; + strAboutMenu.LoadString(IDS_ABOUTBOX); + if (!strAboutMenu.IsEmpty()) + { + pSysMenu->AppendMenu(MF_SEPARATOR); + pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu); + } + } + + // Set the icon for this dialog. The framework does this automatically + // when the application's main window is not a dialog + SetIcon(m_hIcon, TRUE); // Set big icon + SetIcon(m_hIcon, FALSE); // Set small icon + + // TODO: Add extra initialization here + m_Tree.SetpORB(m_pORB); + + // Initialize the naming client and get the root context + TAO_Naming_Client Client; + if(!Client.init(m_pORB)) + { + m_RootContext = Client.get_context(); + m_Server = "Default"; + // For debugging, sets up some initial contexts in the NS + /* + CosNaming::Name Name; + Name.length(1); + Name[0].id = CORBA::string_dup("test"); + CORBA::Object_var Object = CORBA::Object::_nil(); + m_RootContext->rebind(Name, Object); + CosNaming::NamingContext_var Context = m_RootContext->new_context(); + Name[0].id = CORBA::string_dup("test context"); + m_RootContext->rebind_context(Name, Context); + Context->rebind_context(Name, Context); + */ + } + Resolve(); + UpdateData(FALSE); + return TRUE; // return TRUE unless you set the focus to a control +} + +void CNamingViewerDlg::OnSysCommand(UINT nID, LPARAM lParam) +{ + if ((nID & 0xFFF0) == IDM_ABOUTBOX) + { + CAboutDlg dlgAbout; + dlgAbout.DoModal(); + } + else + { + CDialog::OnSysCommand(nID, lParam); + } +} + +// If you add a minimize button to your dialog, you will need the code below +// to draw the icon. For MFC applications using the document/view model, +// this is automatically done for you by the framework. + +void CNamingViewerDlg::OnPaint() +{ + if (IsIconic()) + { + CPaintDC dc(this); // device context for painting + + SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0); + + // Center icon in client rectangle + int cxIcon = GetSystemMetrics(SM_CXICON); + int cyIcon = GetSystemMetrics(SM_CYICON); + CRect rect; + GetClientRect(&rect); + int x = (rect.Width() - cxIcon + 1) / 2; + int y = (rect.Height() - cyIcon + 1) / 2; + + // Draw the icon + dc.DrawIcon(x, y, m_hIcon); + } + else + { + CDialog::OnPaint(); + } +} + +// The system calls this to obtain the cursor to display while the user drags +// the minimized window. +HCURSOR CNamingViewerDlg::OnQueryDragIcon() +{ + return (HCURSOR) m_hIcon; +} + +void CNamingViewerDlg::Resolve() +{ + m_Tree.Resolve(m_RootContext); +} + +void CNamingViewerDlg::OnSelectNs() +{ + // TODO: Add your control notification handler code here + CSelectNSDialog Dialog; + if(Dialog.DoModal() != IDOK) + { + return; + } + try + { + CORBA::Object_var Object = m_pORB->string_to_object(Dialog.GetIOR()); + m_RootContext = CosNaming::NamingContext::_narrow(Object); + m_Server = Dialog.GetName(); + UpdateData(FALSE); + Resolve(); + } + catch(CORBA::Exception& ex) + { + MessageBox(ex._id(), "CORBA::Exception"); + } +} + +void CNamingViewerDlg::OnSize(UINT nType, int cx, int cy) +{ + CDialog::OnSize(nType, cx, cy); + // TODO: Add your message handler code here + + // Resize the tree control + if(m_Tree.m_hWnd) + { + CRect Size; + m_Tree.GetWindowRect(Size); + ScreenToClient(Size); + int Border = Size.left; + Size.right = cx - Border; + Size.bottom = cy - Border; + m_Tree.MoveWindow(Size, TRUE); + } +} + +void CNamingViewerDlg::OnGetMinMaxInfo( MINMAXINFO FAR* lpMMI ) +{ + // Prevent the window from being resized too small + CWnd* pSelect = GetDlgItem(IDC_NS); + if(pSelect) + { + CRect Size; + pSelect->GetWindowRect(Size); + ScreenToClient(Size); + lpMMI->ptMinTrackSize.x = Size.right + Size.left + 7; + lpMMI->ptMinTrackSize.y = 200; + } +} diff --git a/TAO/utils/NamingViewer/NamingViewerDlg.h b/TAO/utils/NamingViewer/NamingViewerDlg.h new file mode 100644 index 00000000000..fbda6676e4d --- /dev/null +++ b/TAO/utils/NamingViewer/NamingViewerDlg.h @@ -0,0 +1,61 @@ +// $Id$ +// NamingViewerDlg.h : header file +// + +#if !defined(AFX_NAMINGVIEWERDLG_H__B9C0EB98_AD28_11D3_BF1F_00C0F03C565A__INCLUDED_) +#define AFX_NAMINGVIEWERDLG_H__B9C0EB98_AD28_11D3_BF1F_00C0F03C565A__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 + +#include "orbsvcs/CosNamingC.h" +#include "NamingTreeCtrl.h" +///////////////////////////////////////////////////////////////////////////// +// CNamingViewerDlg dialog + +class CNamingViewerDlg : public CDialog +{ +// Construction +public: + CNamingViewerDlg(CORBA::ORB_ptr pORB, CWnd* pParent = NULL); // standard constructor + +// Dialog Data + //{{AFX_DATA(CNamingViewerDlg) + enum { IDD = IDD_NAMINGVIEWER_DIALOG }; + CNamingTreeCtrl m_Tree; + CString m_Server; + //}}AFX_DATA + + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CNamingViewerDlg) + protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support + //}}AFX_VIRTUAL + +// Implementation +protected: + HICON m_hIcon; + + // Generated message map functions + //{{AFX_MSG(CNamingViewerDlg) + virtual BOOL OnInitDialog(); + afx_msg void OnSysCommand(UINT nID, LPARAM lParam); + afx_msg void OnPaint(); + afx_msg HCURSOR OnQueryDragIcon(); + afx_msg void OnSelectNs(); + afx_msg void OnSize(UINT nType, int cx, int cy); + //}}AFX_MSG + afx_msg void OnGetMinMaxInfo( MINMAXINFO FAR* lpMMI ); + DECLARE_MESSAGE_MAP() + + void Resolve(); + + CORBA::ORB_ptr m_pORB; + CosNaming::NamingContext_var m_RootContext; +}; + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_NAMINGVIEWERDLG_H__B9C0EB98_AD28_11D3_BF1F_00C0F03C565A__INCLUDED_) diff --git a/TAO/utils/NamingViewer/README b/TAO/utils/NamingViewer/README new file mode 100644 index 00000000000..000c94ad24e --- /dev/null +++ b/TAO/utils/NamingViewer/README @@ -0,0 +1,74 @@ +$Id$ + +This directory contains an MFC-based CosNaming viewer that that allows +users to manipulate a Naming Context visually. + +Features +-------- + + . Displays the entries of a naming context graphically in a + tree control. + + . Supports configuration of different naming servers. + Configuration is stored in the registry. + + . Double clicking on an object in the tree will open a dialog to + examine the object reference. This dialog will display the + stringified object reference, repository ID and profile + information. + + . Supports binding, unbinding, context creation and context + destroying. User the right mouse button to pull up the + context menu. + + . Supports iterator returned from listing a context + + . Initializes ORB with the command line arguments passed into + the executable. + + . Supports resizing of the main window. + + . Control-c copies the IOR of the currently selected object to + the clipboard. + +TO-DO List +---------- + + . Add support for showing the components in an IOR's profile + (need a patch in TAO before we can do this). + + . Display the object key for a profile. + + . Add support for recursive destroys of contexts. + + . Add support for "pingable" objects. Pingable objects would + be pinged and the viewer could then graphically display + those objects that were "alive" and those that were not + available. + + . Add configuration options like number of objects to fetch + per list, auto expanding of the tree, default naming + service, etc. + + . Add support for cutting/moving/copying objects in the tree? + + . Add ability to configure what is displayed for each entry in + a context. + + . Right now its just the id and kind, but we could also add in + the repository id and primary profile. + +Issues/Bugs +----------- + + . Need to find a better way of displaying the kind attribute + in a Name. Right now we use "." which is ambiguous. + Perhaps a different color? + + . Consider getting rid of the Select NS button and the name of + the name service from the main window. Put the name of the + server in the window title and allow the user to select a + new NS from the system menu. + +If you have any questions, please contact the author, Chris Hafey +<chris@stentorsoft.com>. diff --git a/TAO/utils/NamingViewer/SelectNSDialog.cpp b/TAO/utils/NamingViewer/SelectNSDialog.cpp new file mode 100644 index 00000000000..968ce45c7c7 --- /dev/null +++ b/TAO/utils/NamingViewer/SelectNSDialog.cpp @@ -0,0 +1,137 @@ +// $Id$ +// SelectNSDialog.cpp : implementation file +// + +#include "stdafx.h" +#include "NamingViewer.h" +#include "SelectNSDialog.h" +#include "AddNameServerDlg.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +///////////////////////////////////////////////////////////////////////////// +// CSelectNSDialog dialog + + +CSelectNSDialog::CSelectNSDialog(CWnd* pParent /*=NULL*/) + : CDialog(CSelectNSDialog::IDD, pParent) +{ + //{{AFX_DATA_INIT(CSelectNSDialog) + // NOTE: the ClassWizard will add member initialization here + //}}AFX_DATA_INIT + m_pConfig = 0; +} + + +void CSelectNSDialog::DoDataExchange(CDataExchange* pDX) +{ + CDialog::DoDataExchange(pDX); + //{{AFX_DATA_MAP(CSelectNSDialog) + DDX_Control(pDX, IDC_SERVERS, m_Servers); + //}}AFX_DATA_MAP +} + + +BEGIN_MESSAGE_MAP(CSelectNSDialog, CDialog) + //{{AFX_MSG_MAP(CSelectNSDialog) + ON_BN_CLICKED(IDC_ADD, OnAdd) + ON_BN_CLICKED(IDC_REMOVE, OnRemove) + ON_WM_DESTROY() + //}}AFX_MSG_MAP +END_MESSAGE_MAP() + +///////////////////////////////////////////////////////////////////////////// +// CSelectNSDialog message handlers + +void CSelectNSDialog::OnOK() +{ + // TODO: Add extra validation here + int index = m_Servers.GetCurSel(); + if(index == LB_ERR) + { + AfxMessageBox("You must select a server or cancel"); + return; + } + char* pIOR = (char*)m_Servers.GetItemData(index); + m_IOR = pIOR; + m_Servers.GetText(index, m_Name); + CDialog::OnOK(); +} + +void CSelectNSDialog::OnAdd() +{ + // TODO: Add your control notification handler code here + CAddNameServerDlg Dialog; + if(Dialog.DoModal() != IDOK) + { + return; + } + ACE_Configuration_Section_Key Section = m_pConfig->root_section(); + ACE_TString Value = Dialog.m_IOR; + m_pConfig->set_string_value(Section, Dialog.m_Name, Value); + int pos = m_Servers.AddString(Dialog.m_Name); + char* pIOR = new char[Value.length() + 1]; + strcpy(pIOR, Value.c_str()); + m_Servers.SetItemData(pos, (DWORD)pIOR); + +} + +void CSelectNSDialog::OnRemove() +{ + // TODO: Add your control notification handler code here + int index = m_Servers.GetCurSel(); + if(index == LB_ERR) + { + return; + } + delete (char*)m_Servers.GetItemData(index); + CString Name; + m_Servers.GetText(index, Name); + ACE_Configuration_Section_Key Section = m_pConfig->root_section();; + m_pConfig->remove_value(Section, Name); + m_Servers.DeleteString(index); +} + +BOOL CSelectNSDialog::OnInitDialog() +{ + CDialog::OnInitDialog(); + + // TODO: Add extra initialization here + HKEY hKey = ACE_Configuration_Win32Registry::resolve_key(HKEY_LOCAL_MACHINE, "Software\\TAO\\NamingViewer\\Servers"); + m_pConfig = new ACE_Configuration_Win32Registry(hKey); + ACE_Configuration_Section_Key Section = m_pConfig->root_section();; + int index = 0; + ACE_TString name; + ACE_Configuration::VALUETYPE type; + while(m_pConfig->enumerate_values(Section, index, name, type) == 0) + { + ACE_TString value; + if(m_pConfig->get_string_value(Section, name.c_str(), value) == 0) + { + int pos = m_Servers.AddString(name.c_str()); + char* pIOR = new char[value.length() + 1]; + strcpy(pIOR, value.c_str()); + m_Servers.SetItemData(pos, (DWORD)pIOR); + } + index++; + } + + return TRUE; // return TRUE unless you set the focus to a control + // EXCEPTION: OCX Property Pages should return FALSE +} + +void CSelectNSDialog::OnDestroy() +{ + CDialog::OnDestroy(); + + // TODO: Add your message handler code here + int count = m_Servers.GetCount(); + for(int i=0; i < count; i++) + { + delete (char*)m_Servers.GetItemData(i); + } +} diff --git a/TAO/utils/NamingViewer/SelectNSDialog.h b/TAO/utils/NamingViewer/SelectNSDialog.h new file mode 100644 index 00000000000..28d3520a9be --- /dev/null +++ b/TAO/utils/NamingViewer/SelectNSDialog.h @@ -0,0 +1,58 @@ +// $Id$ +#if !defined(AFX_SELECTNSDIALOG_H__2AF5C353_B440_11D3_BF2C_00C0F03C565A__INCLUDED_) +#define AFX_SELECTNSDIALOG_H__2AF5C353_B440_11D3_BF2C_00C0F03C565A__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 +// SelectNSDialog.h : header file +// +#include "ace/Configuration.h" + +///////////////////////////////////////////////////////////////////////////// +// CSelectNSDialog dialog + +class CSelectNSDialog : public CDialog +{ +// Construction +public: + CSelectNSDialog(CWnd* pParent = NULL); // standard constructor + +// Dialog Data + //{{AFX_DATA(CSelectNSDialog) + enum { IDD = IDD_SELECT_NS }; + CListBox m_Servers; + //}}AFX_DATA + + const CString& GetIOR() const {return m_IOR;}; + const CString& GetName() const {return m_Name;}; +// Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CSelectNSDialog) + protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support + //}}AFX_VIRTUAL + +// Implementation +protected: + + // Generated message map functions + //{{AFX_MSG(CSelectNSDialog) + virtual void OnOK(); + afx_msg void OnAdd(); + afx_msg void OnRemove(); + virtual BOOL OnInitDialog(); + afx_msg void OnDestroy(); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() + + + ACE_Configuration_Win32Registry* m_pConfig; + CString m_IOR; + CString m_Name; +}; + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_SELECTNSDIALOG_H__2AF5C353_B440_11D3_BF2C_00C0F03C565A__INCLUDED_) diff --git a/TAO/utils/NamingViewer/StdAfx.cpp b/TAO/utils/NamingViewer/StdAfx.cpp new file mode 100644 index 00000000000..80fcb464de7 --- /dev/null +++ b/TAO/utils/NamingViewer/StdAfx.cpp @@ -0,0 +1,9 @@ +// $Id$ +// stdafx.cpp : source file that includes just the standard includes +// NamingViewer.pch will be the pre-compiled header +// stdafx.obj will contain the pre-compiled type information + +#include "stdafx.h" + + + diff --git a/TAO/utils/NamingViewer/StdAfx.h b/TAO/utils/NamingViewer/StdAfx.h new file mode 100644 index 00000000000..a5806cbee3b --- /dev/null +++ b/TAO/utils/NamingViewer/StdAfx.h @@ -0,0 +1,29 @@ +// $Id$ +// stdafx.h : include file for standard system include files, +// or project specific include files that are used frequently, but +// are changed infrequently +// + +#if !defined(AFX_STDAFX_H__B9C0EB9A_AD28_11D3_BF1F_00C0F03C565A__INCLUDED_) +#define AFX_STDAFX_H__B9C0EB9A_AD28_11D3_BF1F_00C0F03C565A__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 + +#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers + +#include <afxwin.h> // MFC core and standard components +#include <afxext.h> // MFC extensions +#include <afxdtctl.h> // MFC support for Internet Explorer 4 Common Controls +#ifndef _AFX_NO_AFXCMN_SUPPORT +#include <afxcmn.h> // MFC support for Windows Common Controls +#endif // _AFX_NO_AFXCMN_SUPPORT + +#include "tao/corba.h" + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + + +#endif // !defined(AFX_STDAFX_H__B9C0EB9A_AD28_11D3_BF1F_00C0F03C565A__INCLUDED_) diff --git a/TAO/utils/NamingViewer/ViewIORDialog.cpp b/TAO/utils/NamingViewer/ViewIORDialog.cpp new file mode 100644 index 00000000000..751b1758aac --- /dev/null +++ b/TAO/utils/NamingViewer/ViewIORDialog.cpp @@ -0,0 +1,156 @@ +// $Id$ +// ViewIORDialog.cpp : implementation file +// + +#include "stdafx.h" +#include "NamingViewer.h" +#include "ViewIORDialog.h" +#include "tao/IIOP_Profile.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +///////////////////////////////////////////////////////////////////////////// +// ViewIORDialog dialog + + +ViewIORDialog::ViewIORDialog(CORBA::ORB_ptr pORB, CORBA::Object_ptr pObject, CWnd* pParent /*=NULL*/) + : CDialog(ViewIORDialog::IDD, pParent) +{ + //{{AFX_DATA_INIT(ViewIORDialog) + m_TypeID = _T(""); + m_IOR = _T(""); + //}}AFX_DATA_INIT + m_pORB = pORB; + if(pObject) + { + m_Object = CORBA::Object::_duplicate(pObject); + } + CORBA::String_var IOR = pORB->object_to_string(pObject); + m_IOR = IOR; +} + + +void ViewIORDialog::DoDataExchange(CDataExchange* pDX) +{ + CDialog::DoDataExchange(pDX); + //{{AFX_DATA_MAP(ViewIORDialog) + DDX_Control(pDX, IDC_PROFILES, m_Profiles); + DDX_Text(pDX, IDC_TYPE_ID, m_TypeID); + DDX_Text(pDX, IDC_IOR, m_IOR); + //}}AFX_DATA_MAP +} + + +BEGIN_MESSAGE_MAP(ViewIORDialog, CDialog) + //{{AFX_MSG_MAP(ViewIORDialog) + ON_BN_CLICKED(IDC_APPLY, OnApply) + //}}AFX_MSG_MAP +END_MESSAGE_MAP() + +///////////////////////////////////////////////////////////////////////////// +// ViewIORDialog message handlers + +BOOL ViewIORDialog::OnInitDialog() +{ + CDialog::OnInitDialog(); + + // TODO: Add extra initialization here + DecodeIOR(); + return TRUE; // return TRUE unless you set the focus to a control + // EXCEPTION: OCX Property Pages should return FALSE +} + +void ViewIORDialog::OnApply() +{ + // TODO: Add your control notification handler code here + UpdateData(); + try + { + m_Object = m_pORB->string_to_object(m_IOR); + DecodeIOR(); + } + catch(CORBA::Exception& ex) + { + MessageBox(ex._id(), "CORBA::Exception"); + } +} + +void ViewIORDialog::DecodeIOR() +{ + // Reset the fields + m_Profiles.DeleteAllItems(); + m_TypeID = ""; + UpdateData(FALSE); + + // if object is nil, return out + if(CORBA::is_nil(m_Object)) + { + return; + } + + // Get the stub + TAO_Stub* pStub = m_Object->_stubobj(); + const char* pType = pStub->type_id; + m_TypeID = pType ? pType : ""; // special case for INS objects, tao doesn't get the type id + UpdateData(FALSE); + + // Iterate through each profile and add an entry to the tree control + const TAO_MProfile& BaseProfiles= pStub->base_profiles(); + CORBA::ULong Count = BaseProfiles.profile_count(); + for(CORBA::ULong Slot = 0; Slot < Count; Slot++) + { + const TAO_Profile* pProfile = BaseProfiles.get_profile(Slot); + HTREEITEM hProfile; + switch(pProfile->tag()) + { + case 0://IOP::TAG_INTERNET_IOP: + { + TAO_IIOP_Profile* pIIOPProfile = (TAO_IIOP_Profile*)pProfile; + CString ProfileString; + ProfileString.Format("IOP %d.%d@%s:%d", + pIIOPProfile->version().major, + pIIOPProfile->version().minor, + pIIOPProfile->host(), + pIIOPProfile->port()); + hProfile = m_Profiles.InsertItem(ProfileString); + } + break; + default: + { + CString ProfileString; + ProfileString.Format("Unknown %X", pProfile->tag()); + hProfile = m_Profiles.InsertItem(ProfileString); + } + break; + } + + // XXX Add in the components + //const TAO_Tagged_Components& Compoents = pProfile->tagged_components(); + + } +/* + TAO_ObjectKey* pKey = pIIOPP->_key(); + if(pKey) + { + m_TextKey.resize(pKey->length() + 1); + for(int i=0; i < pKey->length(); i++) + { + if(isprint((*pKey)[i])) + { + m_TextKey[i] = (*pKey)[i]; + } + else + { + m_TextKey[i] = '.'; + } + char Digit[4]; + sprintf(Digit, "%02X ", (*pKey)[i]); + m_HexKey += Digit; + } + } +*/ +} diff --git a/TAO/utils/NamingViewer/ViewIORDialog.h b/TAO/utils/NamingViewer/ViewIORDialog.h new file mode 100644 index 00000000000..6c29fba45d2 --- /dev/null +++ b/TAO/utils/NamingViewer/ViewIORDialog.h @@ -0,0 +1,54 @@ +// $Id$ +#if !defined(AFX_VIEWIORDIALOG_H__A010D782_AF86_11D3_BF23_00C0F03C565A__INCLUDED_) +#define AFX_VIEWIORDIALOG_H__A010D782_AF86_11D3_BF23_00C0F03C565A__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 +// ViewIORDialog.h : header file +// + +///////////////////////////////////////////////////////////////////////////// +// ViewIORDialog dialog + +class ViewIORDialog : public CDialog +{ +// Construction +public: + ViewIORDialog(CORBA::ORB_ptr pORB, CORBA::Object_ptr pObject, CWnd* pParent = NULL); // standard constructor + +// Dialog Data + //{{AFX_DATA(ViewIORDialog) + enum { IDD = IDD_VIEWIOR_DIALOG }; + CTreeCtrl m_Profiles; + CString m_TypeID; + CString m_IOR; + //}}AFX_DATA + +// Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(ViewIORDialog) + protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support + //}}AFX_VIRTUAL + +// Implementation +protected: + + // Generated message map functions + //{{AFX_MSG(ViewIORDialog) + virtual BOOL OnInitDialog(); + afx_msg void OnApply(); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() + + void DecodeIOR(); + + CORBA::Object_var m_Object; + CORBA::ORB_ptr m_pORB; +}; + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_VIEWIORDIALOG_H__A010D782_AF86_11D3_BF23_00C0F03C565A__INCLUDED_) diff --git a/TAO/utils/NamingViewer/res/NamingViewer.ico b/TAO/utils/NamingViewer/res/NamingViewer.ico Binary files differnew file mode 100644 index 00000000000..878ca59f85d --- /dev/null +++ b/TAO/utils/NamingViewer/res/NamingViewer.ico diff --git a/TAO/utils/NamingViewer/res/NamingViewer.rc2 b/TAO/utils/NamingViewer/res/NamingViewer.rc2 new file mode 100644 index 00000000000..196a5f10a56 --- /dev/null +++ b/TAO/utils/NamingViewer/res/NamingViewer.rc2 @@ -0,0 +1,13 @@ +// +// NAMINGVIEWER.RC2 - resources Microsoft Visual C++ does not edit directly +// + +#ifdef APSTUDIO_INVOKED + #error this file is not editable by Microsoft Visual C++ +#endif //APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// Add manually edited resources here... + +///////////////////////////////////////////////////////////////////////////// diff --git a/TAO/utils/NamingViewer/resource.h b/TAO/utils/NamingViewer/resource.h new file mode 100644 index 00000000000..d2788078a96 --- /dev/null +++ b/TAO/utils/NamingViewer/resource.h @@ -0,0 +1,52 @@ +// $Id$ +//{{NO_DEPENDENCIES}} +// Microsoft Developer Studio generated include file. +// Used by NamingViewer.rc +// +#define IDM_ABOUTBOX 0x0010 +#define IDD_ABOUTBOX 100 +#define IDS_ABOUTBOX 101 +#define IDD_NAMINGVIEWER_DIALOG 102 +#define IDR_MAINFRAME 128 +#define IDD_VIEWIOR_DIALOG 129 +#define IDR_CONTEXT_POPUP 131 +#define IDR_OBJECT_POPUP 132 +#define IDD_BIND 133 +#define IDD_BIND_NEW_CONTEXT 134 +#define IDD_SELECT_NS 135 +#define IDD_ADD_NAME_SERVER 136 +#define IDC_TREE 1000 +#define IDC_IOR 1002 +#define IDC_TYPE_ID 1007 +#define IDC_APPLY 1011 +#define IDC_PROFILES 1012 +#define IDC_SELECT_NS 1013 +#define IDC_SERVER 1014 +#define IDC_ID 1015 +#define IDC_KIND 1017 +#define IDC_VIEWIOR 1018 +#define IDC_ADD 1022 +#define IDC_REMOVE 1023 +#define IDC_SERVERS 1024 +#define IDC_NAME 1025 +#define IDC_NS 1027 +#define ID_CONTEXT_POPUP_BIND_CONTEXT 32771 +#define ID_CONTEXT_POPUP_DESTROY 32772 +#define ID_CONTEXT_POPUP_VIEWREFERENCE 32773 +#define ID_CONTEXT_POPUP_REFRESH 32774 +#define ID_OBJECTPOPUP_UNBIND 32775 +#define ID_OBJECTPOPUP_VIEWREFRENCE 32776 +#define ID_CONTEXT_POPUP_UNBIND 32777 +#define ID_CONTEXT_POPUP_BINDOBJECT 32778 +#define ID_CONTEXTPOPUP_BINDNEWCONTEXT 32779 + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 138 +#define _APS_NEXT_COMMAND_VALUE 32782 +#define _APS_NEXT_CONTROL_VALUE 1028 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif diff --git a/TAO/utils/README b/TAO/utils/README index 1f17904c9cb..2660043e9d9 100644 --- a/TAO/utils/README +++ b/TAO/utils/README @@ -11,3 +11,8 @@ with TAO. . nslist -- This utility lists the current entries in the Naming Service in a nicely formatter manner. + + . NamingViewer -- This utility is an MFC-based CosNaming + viewer that allows users to manipulate a Naming Context + visually. + |