// SwimlaneInfoDlg.cpp : implementation file
//

#include "stdafx.h"
#include "AG_MDA.h"
#include "SwimlaneInfoDlg.h"

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

/////////////////////////////////////////////////////////////////////////////
// SwimlaneInfoDlg dialog


SwimlaneInfoDlg::SwimlaneInfoDlg(CWnd* pParent /*=NULL*/)
	: CDialog(SwimlaneInfoDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(SwimlaneInfoDlg)
	m_Name = _T("");
	m_BoolGet = FALSE;
	m_BoolSet = FALSE;
	m_ParamOrRef = 0;
	//}}AFX_DATA_INIT
	pClasses = NULL;
	pSelClass = NULL;
}


void SwimlaneInfoDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(SwimlaneInfoDlg)
	DDX_Control(pDX, IDC_COMBO_VISIBILITY, m_RefVisibility);
	DDX_Control(pDX, IDC_COMBO_TYPE, m_TypeCombo);
	DDX_Text(pDX, IDC_EDIT_NAME, m_Name);
	DDX_Check(pDX, IDC_CHECK_GET, m_BoolGet);
	DDX_Check(pDX, IDC_CHECK_SET, m_BoolSet);
	DDX_Radio(pDX, IDC_RADIO_MARK, m_ParamOrRef);
	//}}AFX_DATA_MAP
}


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

/////////////////////////////////////////////////////////////////////////////
// SwimlaneInfoDlg message handlers

BOOL SwimlaneInfoDlg::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	// TODO: Add extra initialization here
	if( pClasses )
	{
		int iSel = -1;
		for( int i = 0 ; i <= pClasses->GetUpperBound() ; i ++ )
		{
			UMLClass* p = pClasses->GetAt( i );
			m_TypeCombo.InsertString( i , p->UMLGeneralizableElement::name );
			if( p == pSelClass )iSel = i;
		}
		m_TypeCombo.SetCurSel( iSel );
	}
	m_RefVisibility.InsertString( 0 , "PUBLIC" );
	m_RefVisibility.InsertString( 1 , "PRIVATE" );
	m_RefVisibility.InsertString( 2 , "PROTECTED" );
	m_RefVisibility.InsertString( 3, "PACKAGE" );
	switch( m_Visibility )
	{
	case VISIBILITY_PUBLIC:
		m_RefVisibility.SetCurSel( 0 );
		break;
	case VISIBILITY_PRIVATE:
		m_RefVisibility.SetCurSel( 1 );
		break;
	case VISIBILITY_PROTECTED:
		m_RefVisibility.SetCurSel( 2 );
		break;
	case VISIBILITY_PACKAGE:
		m_RefVisibility.SetCurSel( 3 );
		break;
	}
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void SwimlaneInfoDlg::OnOK() 
{
	// TODO: Add extra validation here
	UpdateData();
	switch( m_RefVisibility.GetCurSel() )
	{
	case 0:
		m_Visibility = VISIBILITY_PUBLIC;
		break;
	case 1:
		m_Visibility = VISIBILITY_PRIVATE;
		break;
	case 2:
		m_Visibility = VISIBILITY_PROTECTED;
		break;
	case 3:
		m_Visibility = VISIBILITY_PACKAGE;
		break;
	}
	int iSel = m_TypeCombo.GetCurSel();
	if( iSel >= 0 )
	{
		pSelClass = pClasses->GetAt( iSel );
	}
	else pSelClass = NULL;
	CDialog::OnOK();
}
