void CUIControler::OnDeleteTest()
{
	CMainFrame* pMainFrame=(CMainFrame*)AfxGetMainWnd();
	CMFCRibbonComboBox* pTestsCombo = DYNAMIC_DOWNCAST(CMFCRibbonComboBox,pMainFrame->GetRibbonBar()->FindByID(WM_SELECT_TEST));

	if (pTestsCombo->GetCurSel()==-1)
		return;

	CString strPath=pTestsCombo->GetItem(pTestsCombo->GetCurSel());
	CTest* pTest= (CTest*) pTestsCombo->GetItemData(pTestsCombo->GetCurSel());
	//
	//

	CTestsFile* pFile=pTest->GetTestsFile();
	pHistoryTree->deleteTest(pTest);
	removeTestFromRibbonCombos(pTest);

	//Will also finally delete the mem reference.
	pFile->removeTestFromXML(pTest);
	/*
CString displayText;
	displayText.Format(_T("region name=%S\ndescription=%S"),pTest->getName().c_str(),pTest->getDescription().c_str());
	AfxMessageBox(displayText);
*/

}
void CUIControler::OnUpdateFileFolder()
{
	CMainFrame* pMainFrame=(CMainFrame*)AfxGetMainWnd();
	CMFCRibbonComboBox* pFileFoldersCombo = DYNAMIC_DOWNCAST(CMFCRibbonComboBox,pMainFrame->GetRibbonBar()->FindByID(WM_SELECT_FILEFOLDER));


	if (pFileFoldersCombo->GetCurSel()==-1)
		return;

	CString strPath=pFileFoldersCombo->GetItem(pFileFoldersCombo->GetCurSel());

	if ( pFileFoldersCombo->GetItemData(pFileFoldersCombo->GetCurSel())==0 )
	{
		AfxMessageBox(_T("Updating Folder :\n")+strPath);
		//It is a folder.
		std::string folderPath=CCommonUtilities::toBasicString(strPath);

		HTREEITEM hSuiteItem=pHistoryTree->findSuiteTreeItem(folderPath);

		CFileFind finder;
		BOOL bWorking = finder.FindFile(strPath+_T("/*.xml"));
		while (bWorking)
		{
			bWorking = finder.FindNextFile();
			std::string filePath=CCommonUtilities::toBasicString(finder.GetFilePath());
			//
			testsFilesMapT::iterator myIt=testsFilesMap.find(filePath);
			if(myIt==testsFilesMap.end())
			{
				CTestsFile* pTests=openFile(filePath);
				if (pTests)
				{
					pTests->setParentFolder(folderPath);
					pHistoryTree->renderFile(pTests,hSuiteItem);
				}
			}
		} 
		return;
	}
	else
	{
		AfxMessageBox(_T("Updating File :\n")+strPath);
		std::string filePath=CCommonUtilities::toBasicString(strPath);
		//Close the file then reopen it :
		CloseTestsFile(filePath);
		
		//Reopen it :

		CTestsFile* pTests=openFile(filePath);
		if (pTests)
		{
			pHistoryTree->renderFile(pTests,pHistoryTree->hRoot);
			addFileToHomeCombo(strPath);
		}

	}
}
Exemple #3
0
	void CSimPetriDoc::OnOmppInitial()
	{
		//Obtenir la combo box
		CMFCRibbonBar* pRibbon = ((CMDIFrameWndEx *) AfxGetMainWnd())->GetRibbonBar();
		if(!pRibbon->FindByID(ID_OMPP_INITIAL))
			return;
		CMFCRibbonComboBox* mkComboBox = static_cast<CMFCRibbonComboBox*>(pRibbon->FindByID(ID_OMPP_INITIAL));

		//Déterminer la place
		for(auto it=places.begin(); it!=places.end(); ++it)
			if((*it).first->shortID == mkComboBox->GetItem(mkComboBox->GetCurSel()))
			{
				static_cast<pm::TrackableStepper*>(stepper)->setDeparture((*it).second);
				UpdateAllViews(NULL);
				return;
			}
	}
bool CUIControler::getCompareFeatureTargetInfo( UINT comboID,CString& featureName,CFeature::Type& featureType )
{
	CMainFrame* pMainFrame=(CMainFrame*)AfxGetMainWnd();
	CMFCRibbonComboBox* pCombo = DYNAMIC_DOWNCAST(CMFCRibbonComboBox,pMainFrame->GetRibbonBar()->FindByID(comboID));
	if (pCombo == NULL)
	{
		return false;
	}
	int iSel=pCombo->GetCurSel();
	if (iSel==-1)
	{
		return false;
	}
	DWORD_PTR dwData=pCombo->GetItemData(iSel);

	featureType=(CFeature::Type)dwData;
	featureName=pCombo->GetItem(iSel);
	return true;
}
void CUIControler::OnCloseFileFolder()
{
	CMainFrame* pMainFrame=(CMainFrame*)AfxGetMainWnd();
	CMFCRibbonComboBox* pFileFoldersCombo = DYNAMIC_DOWNCAST(CMFCRibbonComboBox,pMainFrame->GetRibbonBar()->FindByID(WM_SELECT_FILEFOLDER));


	if (pFileFoldersCombo->GetCurSel()==-1)
		return;

	CString strPath=pFileFoldersCombo->GetItem(pFileFoldersCombo->GetCurSel());

	if ( pFileFoldersCombo->GetItemData(pFileFoldersCombo->GetCurSel())==1 )
	{
		std::string filePath=CCommonUtilities::toBasicString(strPath);
		CloseTestsFile(filePath);
	}
	else
	{
		std::string folderPath=CCommonUtilities::toBasicString(strPath);//Folder !
		//Loop on all files :

		std::vector<std::string> matchedFiles;
		for (testsFilesMapT::iterator myIt=testsFilesMap.begin();
			myIt!=testsFilesMap.end();
			myIt++)
		{
			CTestsFile* pFile=myIt->second;
			if(pFile->GetParentFolder()==folderPath)
				matchedFiles.push_back(pFile->GetFilePath());
		}

		for (std::vector<std::string>::iterator myIt=matchedFiles.begin();
			myIt!=matchedFiles.end();myIt++)
		{
			CloseTestsFile(*myIt);
		}
		pFileFoldersCombo->DeleteItem(pFileFoldersCombo->GetCurSel());
		
	}
}
void CUIControler::updateTestHomeCombo()
{
	CMainFrame* pMainFrame=(CMainFrame*)AfxGetMainWnd();
	CMFCRibbonComboBox* pFileFoldersCombo = DYNAMIC_DOWNCAST(CMFCRibbonComboBox,pMainFrame->GetRibbonBar()->FindByID(WM_SELECT_FILEFOLDER));
	CMFCRibbonComboBox* pTestsCombo = DYNAMIC_DOWNCAST(CMFCRibbonComboBox,pMainFrame->GetRibbonBar()->FindByID(WM_SELECT_TEST));

	pTestsCombo->RemoveAllItems();

	if (pFileFoldersCombo->GetCurSel()==-1)
		return;

	if ( pFileFoldersCombo->GetItemData(pFileFoldersCombo->GetCurSel())==0 )
	{
		//It is a folder.
		return;
	}

	CString strFilePath=pFileFoldersCombo->GetItem(pFileFoldersCombo->GetCurSel());
	//
	std::string filePath=CCommonUtilities::toBasicString(strFilePath);

	testsFilesMapT::iterator testsIt=testsFilesMap.find(filePath);
	//
	if(testsIt==testsFilesMap.end())
		return;//Nothing found.

	CTestsFile* pCollection=testsIt->second;

	for (TestsVector::iterator myIt = pCollection->getTestsVector().begin(); myIt != pCollection->getTestsVector().end(); myIt++ ){
		//
		CTest* pSession=*myIt;

		//AfxMessageBox(CCommonUtilities::toMFCString(pSession->getName()));
		CString dispName=CCommonUtilities::toMFCString(pSession->getName())+_T("[")+\
			CCommonUtilities::toMFCString(pSession->getDescription())+_T("]");

		pTestsCombo->AddItem(CCommonUtilities::toMFCString(dispName),(DWORD_PTR)pSession);
	}
}
void CUIControler::OnSetTestDescription()
{
	CMainFrame* pMainFrame=(CMainFrame*)AfxGetMainWnd();
	CMFCRibbonComboBox* pTestsCombo = DYNAMIC_DOWNCAST(CMFCRibbonComboBox,pMainFrame->GetRibbonBar()->FindByID(WM_SELECT_TEST));

	if (pTestsCombo->GetCurSel()==-1)
		return;

	CString strPath=pTestsCombo->GetItem(pTestsCombo->GetCurSel());
	CTest* pTest= (CTest*) pTestsCombo->GetItemData(pTestsCombo->GetCurSel());
	//
	//


	CSetDescriptionDlg m_dlg;
	if(m_dlg.DoModal()!=IDOK)
		return;

	
	std::string newDescription = CCommonUtilities::toBasicString(m_dlg.m_strDescription);

	CTestsFile* pTestsFile=pTest->GetTestsFile();
	pTestsFile->updateTestDescriptionInXML(pTest,newDescription);
	pHistoryTree->updateTestDisplayText(pTest);
	updateTestAtRibbonCombo(pTest);

	/*
	CString displayText;
		displayText.Format(_T("region name=%S\ndescription=%S"),pTest->getName().c_str(),pTest->getDescription().c_str());
		AfxMessageBox(displayText);
	
		displayText.Format(_T("parent test file is :%S"),pTest->GetTestsFile()->GetFilePath().c_str());
		AfxMessageBox(displayText);*/
	

}
void CUIControler::updateCompareFeatureTargetCombos()
{
	//Find the new test then populate combos with child features.
	CMainFrame* pMainFrame=(CMainFrame*)AfxGetMainWnd();
	CMFCRibbonComboBox* pAnalyseTestsCombo = DYNAMIC_DOWNCAST(CMFCRibbonComboBox,pMainFrame->GetRibbonBar()->FindByID(WM_COMPARE_FOCUS_SELTEST));
	if (pAnalyseTestsCombo == NULL)
	{
		return;
	}
	int iSel=pAnalyseTestsCombo->GetCurSel();
	if (iSel==-1)
	{
		return;
	}

	CString strRegionName=pAnalyseTestsCombo->GetItem(iSel);


	std::vector<CTest*> matchingTests=getMatchingTests(CCommonUtilities::toBasicString(strRegionName));
	std::vector<CTest*>::iterator testsIt;
	
	if(matchingTests.empty())
	{
		AfxMessageBox(_T("no matching test found"));
		return;
	}

	//Now First update the selection pane :
	pSelectionTestTree->updateTests(strRegionName,matchingTests);


	CTest* pSession=matchingTests.front();
	//AfxMessageBox(CCommonUtilities::toMFCString(pSession->getName()));
	
	CMFCRibbonComboBox* pAllItemsCombo = DYNAMIC_DOWNCAST(CMFCRibbonComboBox,pMainFrame->GetRibbonBar()->FindByID(WM_COMPARE_FOCUS_SELITEM));
	CMFCRibbonComboBox* pTasksForActivityCombo = DYNAMIC_DOWNCAST(CMFCRibbonComboBox,pMainFrame->GetRibbonBar()->FindByID(WM_COMPARE_SINGLEACTIVITY_SELTASK));
	CMFCRibbonComboBox* pWorkerForActivityCombo = DYNAMIC_DOWNCAST(CMFCRibbonComboBox,pMainFrame->GetRibbonBar()->FindByID(WM_COMPARE_SINGLEACTIVITY_SELWORKER));
	CMFCRibbonComboBox* pTaskForWorkerCombo = DYNAMIC_DOWNCAST(CMFCRibbonComboBox,pMainFrame->GetRibbonBar()->FindByID(WM_COMPARE_SINGLEWORKER_SELTASK));
	//
	pAllItemsCombo->RemoveAllItems();
	pTasksForActivityCombo->RemoveAllItems();
	pWorkerForActivityCombo->RemoveAllItems();
	pTaskForWorkerCombo->RemoveAllItems();
	//

	activityMapT& mainBlocsMap=pSession->getActivitiesMap();
	activityMapT::const_iterator itMain=mainBlocsMap.begin();

	for (; itMain != mainBlocsMap.end(); ++itMain) {
		CActivity* pActivity=itMain->second;
		pAllItemsCombo->AddItem(CCommonUtilities::toMFCString(pActivity->getName()),(DWORD_PTR)pActivity->getType());
	}

	taskMapT& subBlocsMap=pSession->getTasksMap();
	taskMapT::const_iterator it=subBlocsMap.begin();

	for (; it != subBlocsMap.end(); ++it) {
		CTask* pTask=it->second;
		pAllItemsCombo->AddItem(CCommonUtilities::toMFCString(pTask->getName()),(DWORD_PTR)pTask->getType());
		pTasksForActivityCombo->AddItem(CCommonUtilities::toMFCString(pTask->getName()),(DWORD_PTR)pTask->getType());
		pTaskForWorkerCombo->AddItem(CCommonUtilities::toMFCString(pTask->getName()),(DWORD_PTR)pTask->getType());
	}

	for (workerMapT::iterator wIt=pSession->getWorkersMap().begin();
		wIt!=pSession->getWorkersMap().end();
		wIt++)
	{
		CWorker* pWorker=wIt->second;
		//
		pAllItemsCombo->AddItem(CCommonUtilities::toMFCString(pWorker->getName()),(DWORD_PTR)pWorker->getType());
		pWorkerForActivityCombo->AddItem(CCommonUtilities::toMFCString(pWorker->getName()),(DWORD_PTR)pWorker->getType());
	}
}