// DGDlg.cpp : implementation file // #include "stdafx.h" #include "kbeditors.h" #include "KBEditorsDoc.h" #include "DGDlg.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CDGDlg dialog CDGDlg::CDGDlg(CWnd* pParent /*=NULL*/) : CDialog(CDGDlg::IDD, pParent) { //{{AFX_DATA_INIT(CDGDlg) //}}AFX_DATA_INIT CString Linkname; } void CDGDlg::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CDGDlg) DDX_Control(pDX, IDC_LINKLIST, m_LinkList); DDX_Control(pDX, IDC_CONDITION, m_ConditionEdit); DDX_Control(pDX, IDC_COMBO1, m_SVTypeList); DDX_Control(pDX, IDC_SVLIST, m_SVList); DDX_Control(pDX, IDC_PropertyLstCtrl, m_PropertyLstCtrl); DDX_Control(pDX, IDC_ConceptLstCtrl, m_ConceptLstCtrl); //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(CDGDlg, CDialog) //{{AFX_MSG_MAP(CDGDlg) ON_LBN_SELCHANGE(IDC_ConceptLstCtrl, OnSelchangeConceptLstCtrl) ON_CBN_SELCHANGE(IDC_COMBO1, OnSelchangeCombo1) ON_BN_CLICKED(IDC_ADDLINK, OnAddlink) ON_LBN_SELCHANGE(IDC_PropertyLstCtrl, OnSelchangePropertyLstCtrl) ON_CBN_SELCHANGE(IDC_LINKLIST, OnSelchangeLinklist) ON_BN_CLICKED(IDC_BUTTON1, OnButton1) //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CDGDlg message handlers BOOL CDGDlg::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); } return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE } void CDGDlg::SeeDoc(CKBEditorsDoc*Doc) { m_Doc = Doc; } void CDGDlg::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 CDGDlg::OnSelchangeCombo1() { m_SVList.ResetContent(); int Sel= m_SVTypeList.GetCurSel(); if (Sel < 0 ) return; CString SelectedSVType; m_SVTypeList.GetLBText(Sel,SelectedSVType); if (SelectedSVType == "Cluster"){ POSITION posCluster =m_Doc->m_ClusterList.GetStartPosition(); while (posCluster) { CCluster * Cluster; CString str ; m_Doc->m_ClusterList.GetNextAssoc(posCluster,str,Cluster); m_SVList.AddString(str); } } else if (SelectedSVType == "Function"){ POSITION posCluster =m_Doc->m_FunctionList.GetStartPosition(); while (posCluster) { CObArray * FunCluster; CString str ; m_Doc->m_FunctionList.GetNextAssoc(posCluster,str,FunCluster); m_SVList.AddString(str); } } /*else if (SelectedSVType == "Table"){ POSITION posTable =m_Doc->m_TableList.GetStartPosition(); while (posTable) { CTable *TableObj; CString str ; m_Doc->m_TableList.GetNextAssoc(posTable,str,TableObj); m_SVList.AddString(str); } }*/ } void CDGDlg::OnAddlink() { // TODO: Add your control notification handler code here int Sel= m_ConceptLstCtrl.GetCurSel (); if(Sel<0){ AfxMessageBox ("You Must Select Concept Name"); return ; } CString SelectedConceptName; m_ConceptLstCtrl.GetText(Sel,SelectedConceptName); Sel= m_PropertyLstCtrl.GetCurSel (); if(Sel<0){ AfxMessageBox ("You Must Select Property Name"); return ; } CString SelectedPropertyName; m_PropertyLstCtrl.GetText(Sel,SelectedPropertyName); CString NodeName; m_LinkList.GetWindowText (NodeName); if(NodeName==""){ AfxMessageBox ("You Must Enter Node Name"); return; } Sel= m_SVTypeList.GetCurSel(); if (Sel < 0 ){ AfxMessageBox ("You Must Select Source Value Type"); return; } CString SelectedSVType; m_SVTypeList.GetLBText(Sel,SelectedSVType); Sel= m_SVList.GetCurSel (); if(Sel<0){ AfxMessageBox ("You Must Select Source Value "); return ; } CString SelectedSourceValue; m_SVList.GetText(Sel,SelectedSourceValue); CString NodeCondition; m_ConditionEdit.GetWindowText (NodeCondition); if(NodeCondition==""){ AfxMessageBox ("You Must Enter Node Condition"); return; } CLink *newClink=new CLink; newClink->Condition =NodeCondition; newClink->LinkName =NodeName; newClink->SV= SelectedSourceValue; newClink->SVType=SelectedSVType; CDGNode *DGNode; if(!m_Doc->m_DGNodeList.Lookup(SelectedConceptName+"-"+SelectedPropertyName,DGNode)){ DGNode = new CDGNode; DGNode->CptName =SelectedConceptName; DGNode->PropName =SelectedPropertyName; m_Doc->m_DGNodeList.SetAt(SelectedConceptName+"-"+SelectedPropertyName,DGNode); DGNode->m_LinkList.SetAt(newClink->LinkName,newClink); m_LinkList.AddString(newClink->LinkName); }else{ CLink *oldClink; if(DGNode->m_LinkList.Lookup(newClink->LinkName,oldClink)){ if(AfxMessageBox("Do you want to update existing Link ?",MB_YESNO) == IDYES){ DGNode->m_LinkList.SetAt(newClink->LinkName,newClink); AfxMessageBox("Operation done"); }else AfxMessageBox("Operation canceld"); }else{ DGNode->m_LinkList.SetAt(newClink->LinkName,newClink); m_LinkList.AddString(newClink->LinkName); } } } void CDGDlg::OnSelchangePropertyLstCtrl() { m_LinkList.ResetContent(); int Sel= m_ConceptLstCtrl.GetCurSel (); if(Sel<0){ AfxMessageBox ("You Must Select Concept Name"); return ; } CString SelectedConceptName; m_ConceptLstCtrl.GetText(Sel,SelectedConceptName); Sel= m_PropertyLstCtrl.GetCurSel (); if(Sel<0){ AfxMessageBox ("You Must Select Property Name"); return ; } CString SelectedPropertyName; m_PropertyLstCtrl.GetText(Sel,SelectedPropertyName); CDGNode *DGNode; if(m_Doc->m_DGNodeList.Lookup(SelectedConceptName+"-"+SelectedPropertyName,DGNode)){ POSITION pos = DGNode->m_LinkList.GetStartPosition(); while(pos){ CLink *newClink; CString str; DGNode->m_LinkList.GetNextAssoc(pos,str,newClink); m_LinkList.AddString(str); } } } void CDGDlg::OnSelchangeLinklist() { // TODO: Add your control notification handler code here int Sel= m_ConceptLstCtrl.GetCurSel (); if(Sel<0){ return ; } CString SelectedConceptName; m_ConceptLstCtrl.GetText(Sel,SelectedConceptName); Sel= m_PropertyLstCtrl.GetCurSel (); if(Sel<0){ return ; } CString SelectedPropertyName; m_PropertyLstCtrl.GetText(Sel,SelectedPropertyName); CString LinkName; Sel= m_LinkList.GetCurSel (); if(Sel<0){ return ; } m_LinkList.GetLBText(Sel,LinkName); CDGNode *DGNode; if(!m_Doc->m_DGNodeList.Lookup(SelectedConceptName+"-"+SelectedPropertyName,DGNode)) return; CLink *oldClink; if(!DGNode->m_LinkList.Lookup(LinkName,oldClink)) return; Sel= m_SVTypeList.FindString(-1,oldClink->SVType); m_SVTypeList.SetCurSel(Sel); CDGDlg::OnSelchangeCombo1(); Sel= m_SVList.FindString(-1,oldClink->SV); m_SVList.SetCurSel(Sel); m_ConditionEdit.SetWindowText(oldClink->Condition); } void CDGDlg::OnButton1() { // TODO: Add your control notification handler code here }