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/NamingViewer/SelectNSDialog.cpp | |
| 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/NamingViewer/SelectNSDialog.cpp')
| -rw-r--r-- | TAO/utils/NamingViewer/SelectNSDialog.cpp | 137 |
1 files changed, 137 insertions, 0 deletions
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); + } +} |
