// ParameterInfoDlg.cpp : implementation file
//

#include "stdafx.h"
#include "AG_MDA.h"
#include "ParameterInfoDlg.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// ParameterInfoDlg dialog


ParameterInfoDlg::ParameterInfoDlg(CWnd* pParent /*=NULL*/)
	: CDialog(ParameterInfoDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(ParameterInfoDlg)
	m_DefaultValue = _T("");
	m_Name = _T("");
	//}}AFX_DATA_INIT
}


void ParameterInfoDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(ParameterInfoDlg)
	DDX_Control(pDX, IDC_COMBO_TYPE, m_TypeCombo);
	DDX_Control(pDX, IDC_COMBO_DIR, m_DirCombo);
	DDX_Text(pDX, IDC_EDIT_DEFAULT_VALUE, m_DefaultValue);
	DDX_Text(pDX, IDC_EDIT_NAME, m_Name);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(ParameterInfoDlg, CDialog)
	//{{AFX_MSG_MAP(ParameterInfoDlg)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// ParameterInfoDlg message handlers

void ParameterInfoDlg::OnOK() 
{
	// TODO: Add extra validation here
	UpdateData();
	m_Parameter.m_DefaultValue = m_DefaultValue;
	m_Parameter.m_DirKind = UMLParameterDirKind( m_DirCombo.GetCurSel() );
	m_Parameter.m_pType = m_pClassList->GetAt( m_TypeCombo.GetCurSel() );
	m_Parameter.name = m_Name;
	CDialog::OnOK();
}

BOOL ParameterInfoDlg::OnInitDialog() 
{
	CDialog::OnInitDialog();
	int iSelType = -1;
	
	// TODO: Add extra initialization here
	m_DirCombo.InsertString( 0 , "IN" );
	m_DirCombo.InsertString( 1 , "OUT" );
	m_DirCombo.InsertString( 2 , "INOUT" );

	for( int i = 0 ; i < m_pClassList->GetSize() ; i ++ )
	{
		UMLClass *p = m_pClassList->GetAt( i );
		m_TypeCombo.InsertString( i , p->UMLGeneralizableElement::name );
		if( p == m_Parameter.m_pType )iSelType = i;
	}
	m_TypeCombo.SetCurSel( iSelType );
	m_Name = m_Parameter.name;
	m_DefaultValue = m_Parameter.m_DefaultValue;
	m_DirCombo.SetCurSel( int(m_Parameter.m_DirKind) );
	UpdateData( FALSE );
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}
