newntui/discovermdi/src/dockablebrowser.cpp
//---------------------------------------------------------------------------------------
// This callback will process all CM menu items.
//---------------------------------------------------------------------------------------
This callback will process all CM menu items.
This callback will process all CM menu items .
void CDockableBrowser::OnCMAction(int id) {
    CCMIntegrator* integrator=(CCMIntegrator*) GetDlgItem(IDC_CMINTEGRATORCTRL);
	if(integrator==NULL) return;
	int nCmdIdx = id-ID_CM_ACTIONS;
	CCMCommand* pCommand = m_pCMCommands->GetCommand(nCmdIdx);
	if(pCommand) {
		CStringList filesList;
		if(pCommand->HasAttribute(CString("file")) || 
		   pCommand->HasAttribute(CString("files"))) {
			bool bCheckWritable = false; 
			CString res;
			CString cmd;
			BSTR sysCmd;
			int elements;
			CDataSource* pDataSource = (CDataSource *) GetDlgItem(IDC_DATASOURCE);
			if(bCheckWritable)
				cmd="set __cm_files__ [filter {kind==\"module\" && writable==1} [where defined $DiscoverSelection]]";
			else
				cmd="set __cm_files__ [filter {kind==\"module\"} [where defined $DiscoverSelection]]";
			sysCmd=cmd.AllocSysString();
			DataSourceAccessSync(pDataSource, &sysCmd);
			::SysFreeString(sysCmd);
			cmd="size $__cm_files__";
			sysCmd=cmd.AllocSysString();
			res=DataSourceAccessSync(pDataSource, &sysCmd);
			elements=atoi(res);
			::SysFreeString(sysCmd);
			cmd = "get_pref_value SubmissionCheck.Enabled";
			sysCmd=cmd.AllocSysString();
			res=DataSourceAccessSync(pDataSource, &sysCmd);
			::SysFreeString(sysCmd);
			for(int i=0;i<elements;i++) {
				cmd.Format("fname $__cm_files__ %d",i+1);
				sysCmd=cmd.AllocSysString();
				res=DataSourceAccessSync(pDataSource, &sysCmd);
				::SysFreeString(sysCmd);
				filesList.AddHead(res);
			}
			cmd="unset __cm_files__";
			sysCmd=cmd.AllocSysString();
			res=DataSourceAccessSync(pDataSource, &sysCmd);
			elements=atoi(res);
			::SysFreeString(sysCmd);
			if(filesList.GetCount()==0) {
				MessageBox("No writable files found to perform the CM command.","Warning",MB_OK|MB_ICONINFORMATION);
				return;
			}
		} else {
			CDataSource* pDataSource = (CDataSource *) GetDlgItem(IDC_DATASOURCE);
			CString cmd="fname " + m_CurrentProject;
			BSTR sysCmd=cmd.AllocSysString();
			CString szResult = DataSourceAccessSync(pDataSource, &sysCmd);
			::SysFreeString(sysCmd);
			filesList.AddHead(szResult);
		}
        DoCMAction(pCommand->GetKey(), filesList);
    }
}
void CDockableBrowser :: OnCMAction ( int id ) { CCMIntegrator * integrator = ( CCMIntegrator * ) GetDlgItem ( IDC_CMINTEGRATORCTRL ) ; if ( integrator == NULL ) return ; int nCmdIdx = id - ID_CM_ACTIONS ; CCMCommand * pCommand = m_pCMCommands -> GetCommand ( nCmdIdx ) ; if ( pCommand ) { CStringList filesList ; if ( pCommand -> HasAttribute ( CString ( " " ) ) || pCommand -> HasAttribute ( CString ( " " ) ) ) { bool bCheckWritable = false ; CString res ; CString cmd ; BSTR sysCmd ; int elements ; CDataSource * pDataSource = ( CDataSource * ) GetDlgItem ( IDC_DATASOURCE ) ; if ( bCheckWritable ) cmd = " \" \" " ; else cmd = " \" \" " ; sysCmd = cmd . AllocSysString ( ) ; DataSourceAccessSync ( pDataSource , & sysCmd ) ; :: SysFreeString ( sysCmd ) ; cmd = " " ; sysCmd = cmd . AllocSysString ( ) ; res = DataSourceAccessSync ( pDataSource , & sysCmd ) ; elements = atoi ( res ) ; :: SysFreeString ( sysCmd ) ; cmd = " " ; sysCmd = cmd . AllocSysString ( ) ; res = DataSourceAccessSync ( pDataSource , & sysCmd ) ; :: SysFreeString ( sysCmd ) ; for ( int i = 0 ; i < elements ; i ++ ) { cmd . Format ( " " , i + 1 ) ; sysCmd = cmd . AllocSysString ( ) ; res = DataSourceAccessSync ( pDataSource , & sysCmd ) ; :: SysFreeString ( sysCmd ) ; filesList . AddHead ( res ) ; } cmd = " " ; sysCmd = cmd . AllocSysString ( ) ; res = DataSourceAccessSync ( pDataSource , & sysCmd ) ; elements = atoi ( res ) ; :: SysFreeString ( sysCmd ) ; if ( filesList . GetCount ( ) == 0 ) { MessageBox ( " " , " " , MB_OK | MB_ICONINFORMATION ) ; return ; } } else { CDataSource * pDataSource = ( CDataSource * ) GetDlgItem ( IDC_DATASOURCE ) ; CString cmd = " " + m_CurrentProject ; BSTR sysCmd = cmd . AllocSysString ( ) ; CString szResult = DataSourceAccessSync ( pDataSource , & sysCmd ) ; :: SysFreeString ( sysCmd ) ; filesList . AddHead ( szResult ) ; } DoCMAction ( pCommand -> GetKey ( ) , filesList ) ; } }
This callback will process all CM menu items.
This callback will process all CM menu items .
// Forming file list  for submission // if you do not want the user be able // to perform CM commands against not writable  // projects set this variable to true // Extracting file name //---------------------------------------------------	