// AddDeleteDlg.cpp : implementation file // #include "stdafx.h" #include "KBEditors.h" #include "KBEditorsDoc.h" #include "AddDeleteDlg.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // AddDeleteDlg dialog AddDeleteDlg::AddDeleteDlg(CWnd* pParent /*=NULL*/) : CDialog(AddDeleteDlg::IDD, pParent) { //{{AFX_DATA_INIT(AddDeleteDlg) m_Result = _T(""); FlxResultChanged = FALSE; //}}AFX_DATA_INIT } void AddDeleteDlg::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(AddDeleteDlg) DDX_Control(pDX, IDC_ValueLstCtrl, m_ValueLstCtrl); DDX_Control(pDX, IDC_PropertyLstCtrl, m_PropertyLstCtrl); DDX_Control(pDX, IDC_ConceptLstCtrl, m_ConceptLstCtrl); DDX_Text(pDX, IDC_Result, m_Result); //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(AddDeleteDlg, CDialog) //{{AFX_MSG_MAP(AddDeleteDlg) ON_LBN_SELCHANGE(IDC_ConceptLstCtrl, OnSelchangeConceptLstCtrl) ON_BN_CLICKED(IDC_AddSchema, OnAddSchema) ON_BN_CLICKED(IDC_AddResult, OnAddResult) //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // AddDeleteDlg message handlers void AddDeleteDlg::SeeDoc(CKBEditorsDoc*Doc,CTable *TObj) { m_Doc = Doc; TableObj =TObj; } BOOL AddDeleteDlg::OnInitDialog() { CDialog::OnInitDialog(); POSITION pos =m_Doc->m_CptList.GetStartPosition(); CString ConceptKey; CConcept *CptOj; // =new CConcept; while (pos != NULL) { m_Doc->m_CptList.GetNextAssoc( pos, ConceptKey, CptOj ); m_ConceptLstCtrl.AddString(ConceptKey); } CString str; for (int i=0;i < TableObj->Schema.GetSize();i++) { str = TableObj->Schema.GetAt(i); m_ValueLstCtrl.AddString(str); } TableObj->ResultList.Lookup(0,str); m_Result = str; UpdateData(FALSE); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE } void AddDeleteDlg::OnSelchangeConceptLstCtrl() { m_PropertyLstCtrl.ResetContent(); int Sel= m_ConceptLstCtrl.GetCurSel(); if (Sel < 0 ) return; CString SelectedConcept; CConcept *CptOj; m_ConceptLstCtrl.GetText(Sel,SelectedConcept); m_Doc->m_CptList.Lookup(SelectedConcept,CptOj); CString PropertyKey; CProperty* PropOj; POSITION pos =CptOj->m_PropList.GetStartPosition(); while (pos != NULL) { CptOj->m_PropList.GetNextAssoc( pos, PropertyKey, PropOj ); m_PropertyLstCtrl.AddString(PropertyKey); } } void AddDeleteDlg::OnAddSchema() { int Sel1= m_ConceptLstCtrl.GetCurSel(); if (Sel1 <0 ) return; int Sel2= m_PropertyLstCtrl.GetCurSel(); if (Sel2 <0 ) return; CString SelectedConcept; CString SelectedProperty; m_ConceptLstCtrl.GetText(Sel1,SelectedConcept); m_PropertyLstCtrl.GetText(Sel2,SelectedProperty); SelectedConcept=SelectedConcept+"."+ SelectedProperty; /*for (int i=0;i < TableObj->Schema.GetSize();i++) { CString str = TableObj->Schema.GetAt(i); if(str == SelectedConcept) { if (AfxMessageBox("Schema found in the table, would you like to add another?",MB_YESNO)==IDNO ) return; else break; } }*/ m_ValueLstCtrl.AddString(SelectedConcept ); TableObj->Schema.Add(SelectedConcept); } //DEL void AddDeleteDlg::OnDeleteSchema() //DEL { //DEL int Sel= m_ValueLstCtrl.GetCurSel(); //DEL if (Sel >= 0 ) //DEL { //DEL CString SelectedScehma; //DEL m_ValueLstCtrl.GetText(Sel,SelectedScehma); //DEL m_ValueLstCtrl.DeleteString(Sel); //DEL for (int i=0;i < TableObj->Schema.GetSize();i++) //DEL { //DEL CString str = TableObj->Schema.GetAt(i); //DEL if(str== SelectedScehma) //DEL { //DEL TableObj->Schema.RemoveAt(i); //DEL return; //DEL } //DEL } //DEL //DEL } //DEL } //DEL void AddDeleteDlg::ClearAllCtrl() //DEL { //DEL m_ConceptLstCtrl.ResetContent(); //DEL m_PropertyLstCtrl.ResetContent(); //DEL m_ValueLstCtrl.ResetContent(); //DEL } void AddDeleteDlg::OnAddResult() { int Sel1= m_ConceptLstCtrl.GetCurSel(); if (Sel1 <0 ) return; int Sel2= m_PropertyLstCtrl.GetCurSel(); if (Sel2 <0 ) return; CString SelectedConcept; CString SelectedProperty; m_ConceptLstCtrl.GetText(Sel1,SelectedConcept); m_PropertyLstCtrl.GetText(Sel2,SelectedProperty); SelectedConcept = SelectedConcept+"."+ SelectedProperty; if (m_Result != SelectedConcept && ! m_Result.IsEmpty()) { TableObj->ResultList.RemoveAll(); FlxResultChanged = TRUE ; } m_Result = SelectedConcept; TableObj->ResultList.SetAt(0,m_Result); UpdateData(FALSE); }