GME
13
|
00001 // AggregateContextMenu.cpp: implementation of the CAggregateContextMenu class. 00002 // 00004 00005 #include "stdafx.h" 00006 #include "gmeactivebrowser.h" 00007 #include "AggregateContextMenu.h" 00008 #include "GMEActiveBrowserCtl.h" 00009 #include "AggregateOptionsDlg.h" 00010 #include "..\Gme\GMEOLEData.h" 00011 00012 #ifdef _DEBUG 00013 #undef THIS_FILE 00014 static char THIS_FILE[]=__FILE__; 00015 #define new DEBUG_NEW 00016 #endif 00017 00019 // Construction/Destruction 00021 00022 CAggregateContextMenu::CAggregateContextMenu(CAggregatePropertyPage* pParent) 00023 { 00024 m_pParent=pParent; 00025 00026 // Menu IDs for the custom (dynamically inserted) items 00027 m_InsertionMinID=m_InsertionMaxID=33000; 00028 } 00029 00030 CAggregateContextMenu::~CAggregateContextMenu() 00031 { 00032 00033 } 00034 00035 BOOL CAggregateContextMenu::Run(CPoint point) 00036 { 00037 00038 m_nSelectionCount=m_pParent->m_TreeAggregate.GetSelectedCount(); 00039 switch (m_nSelectionCount) 00040 { 00041 case 0: 00042 { 00043 VERIFY(LoadMenu(CG_IDR_POPUP_AGGREGATE_PROPERTY_PAGE_GENERAL)); 00044 }break; 00045 case 1: 00046 { 00047 CreateForSingleItem(); 00048 }break; 00049 00050 default: 00051 { 00052 VERIFY(LoadMenu(CG_IDR_POPUP_AGGREGATE_PROPERTY_PAGE_MULTIPLE_ITEMS)); 00053 } 00054 } 00055 00056 /* Initialization for all type of context menus */ 00057 CreateForAll(); 00058 00059 CMenu* pPopup =GetSubMenu(0); 00060 ASSERT(pPopup != NULL); 00061 00062 00063 UINT nItemID=pPopup->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON |TPM_NONOTIFY|TPM_RETURNCMD, point.x, point.y, 00064 m_pParent); 00065 00066 TRACE1("Selected menu item ID: %d\n",nItemID); 00067 return DispatchCommand(nItemID); 00068 } 00069 00070 00071 BOOL CAggregateContextMenu::DispatchCommand(UINT nSelectedID) 00072 { 00073 if( nSelectedID>=m_InsertionMinID && nSelectedID<m_InsertionMaxID) 00074 { 00075 OnCustomItems(nSelectedID); 00076 } 00077 else 00078 { 00079 switch(nSelectedID) 00080 { 00081 case ID_EDIT_CUT: OnEditCut();break; 00082 case ID_EDIT_COPY: OnEditCopy();break; 00083 case ID_EDIT_COPYCLOSURE: OnEditCopyClosure();break; 00084 case ID_EDIT_COPYSMART: OnEditCopySmart();break; 00085 case ID_EDIT_PASTE: OnEditPaste();break; 00086 case ID_EDIT_PASTESPECIAL_ASREFERENCE: OnEditPasteSpecialAsReference();break; 00087 case ID_EDIT_PASTESPECIAL_ASSUBTYPE: OnEditPasteSpecialAsSubtype();break; 00088 case ID_EDIT_PASTESPECIAL_ASINSTANCE: OnEditPasteSpecialAsInstance();break; 00089 case ID_EDIT_PASTECLOSURE: OnEditPasteClosure();break; 00090 case ID_EDIT_PASTESPECIAL_SMART_ADDITIVE: OnEditPasteClosure();break; 00091 case ID_EDIT_PASTESPECIAL_SMART_MERGE: OnEditPasteClosure(true);break; 00092 case ID_POPUP_EDIT_DELETE: OnEditDelete();break; 00093 00094 case ID_POPUP_ATTACH_LIBRARY: OnAttachLibrary();break; 00095 case ID_POPUP_REFRESH_LIBRARY: OnRefreshLibrary();break; 00096 case ID_POPUP_LIBRARY_DEPENDENCIES: OnLibraryDependencies();break; 00097 case ID_POPUP_LIBRARY_AMBIGUITYCHK: OnLibraryAmbiguityChk();break; 00098 case ID_USERS_SOURCECONTROLSTATUS: OnMFSourceControlUpdate();break; 00099 case ID_USERS_ACTIVE: OnUsersActive(); break; 00100 case ID_USERS_OWNER: OnUsersOwner(); break; 00101 00102 case ID_POPUP_SORT_CONSTRAINTS_CHECKALL: OnCheckAllConstraint();break; 00103 case ID_POPUP_CONSTRAINTS_CHECK: OnCheckConstraint();break; 00104 case ID_POPUP_INTERPRET: OnInterpret();break; 00105 00106 case ID_POPUP_SORT_NAME: OnSortName();break; 00107 case ID_POPUP_SORT_TYPE: OnSortType();break; 00108 case ID_POPUP_SORT_CREATION:OnSortCreation();break; 00109 00110 case ID_POPUP_PROPERTIES: OnProperties();break; 00111 case ID_POPUP_ATTRIBUTES: OnAttributes();break; 00112 case ID_POPUP_PREFERENCES: OnPreferences();break; 00113 case ID_POPUP_REGISTRY: OnRegistry();break; 00114 00115 case ID_POPUP_DISPLAYOPTIONS: OnOptions();break; 00116 case ID_POPUP_HELP: OnHelp();break; 00117 case ID_POPUP_SHOWINPARENT: OnShowInParent();break; 00118 case ID_POPUP_FOLLOWREF: OnFollowRef();break; 00119 case ID_POPUP_READONLY: OnReadOnly( true);break; 00120 case ID_POPUP_READWRITE: OnReadOnly( false);break; 00121 00122 00123 default: 00124 return FALSE; 00125 } 00126 } 00127 return TRUE; 00128 } 00129 00130 00131 void CAggregateContextMenu::OnCustomItems(UINT nID) 00132 { 00133 UINT nCmd=nID-m_InsertionMinID; 00134 00135 /********************* Custom insertions ************************/ 00136 // The meta object of the insertable items has been stored in the 00137 // m_MenuItem2MetaObjArray. The the index of the selected meta 00138 // can be found in the array at the position nCmd 00139 if(m_nSelectionCount==1) 00140 { 00141 m_pParent->m_bIsBrowserCreatedNewObject=TRUE; 00142 HTREEITEM hItem=m_pParent->m_TreeAggregate.GetSelectedItem(); 00143 CAggregateMgaObjectProxy MgaObjectProxy; 00144 00145 if(m_pParent->m_TreeAggregate.m_MgaMap.LookupObjectProxy(hItem,MgaObjectProxy)) 00146 { 00147 // The selected type to be parent is of the type... 00148 switch(MgaObjectProxy.m_TypeInfo) 00149 { 00150 case OBJTYPE_FOLDER: 00151 { 00152 CComQIPtr<IMgaMetaFolder> ccpMetaFolder((CComPtr<IMgaMetaBase>)m_MenuItem2MetaObjArray.GetAt(nCmd)); 00153 if(ccpMetaFolder) // The type to create is a folder 00154 { 00155 CComQIPtr<IMgaFolder>ccpParentFolder(MgaObjectProxy.m_pMgaObject); 00156 if(ccpParentFolder) 00157 { 00158 CComPtr<IMgaFolder> ccpNewFolder; 00159 00160 CComBSTR bszDispName; 00161 ccpMetaFolder->get_DisplayedName(&bszDispName); 00162 bszDispName = CString(bszDispName); 00163 00164 00165 // Starting transaction 00166 CGMEActiveBrowserApp* pApp=(CGMEActiveBrowserApp*)AfxGetApp(); 00167 CMgaContext* pMgaContext=&pApp->m_CurrentProject.m_MgaContext; 00168 pMgaContext->BeginTransaction(false); 00169 COMTHROW( ccpParentFolder->CreateFolder(ccpMetaFolder,&ccpNewFolder) ); 00170 COMTHROW( ccpNewFolder->put_Name(bszDispName) ); 00171 // Ending transaction 00172 pMgaContext->CommitTransaction(); 00173 00174 } 00175 } 00176 else // The type to create is an FCO 00177 { 00178 CComQIPtr<IMgaMetaFCO> ccpMetaFCO((CComPtr<IMgaMetaBase>)m_MenuItem2MetaObjArray.GetAt(nCmd)); 00179 if(!ccpMetaFCO)break; 00180 00181 CComQIPtr<IMgaFolder>ccpParentFolder(MgaObjectProxy.m_pMgaObject); 00182 if(ccpParentFolder) 00183 { 00184 CComPtr<IMgaFCO> ccpNewFCO; 00185 00186 // Setting name to the newly created object 00187 CComBSTR bszDispName; 00188 ccpMetaFCO->get_DisplayedName(&bszDispName); 00189 bszDispName = CString(bszDispName); 00190 00191 // Starting transaction 00192 CGMEActiveBrowserApp* pApp=(CGMEActiveBrowserApp*)AfxGetApp(); 00193 CMgaContext* pMgaContext=&pApp->m_CurrentProject.m_MgaContext; 00194 pMgaContext->BeginTransaction(false); 00195 00196 // Creating and naming the new FCO 00197 COMTHROW( ccpParentFolder->CreateRootObject(ccpMetaFCO,&ccpNewFCO) ); 00198 COMTHROW( ccpNewFCO->put_Name(bszDispName) ); 00199 // Ending transaction 00200 pMgaContext->CommitTransaction(); 00201 } 00202 00203 } 00204 }break; 00205 00206 case OBJTYPE_MODEL: 00207 { 00208 CComQIPtr<IMgaMetaRole> ccpMetaRole((CComPtr<IMgaMetaBase>)m_MenuItem2MetaObjArray.GetAt(nCmd)); 00209 if(!ccpMetaRole)break; 00210 00211 CComQIPtr<IMgaModel>ccpParentModel(MgaObjectProxy.m_pMgaObject); 00212 if(ccpParentModel) 00213 { 00214 CComPtr<IMgaFCO> ccpNewFCO; 00215 00216 // Starting transaction 00217 CGMEActiveBrowserApp* pApp=(CGMEActiveBrowserApp*)AfxGetApp(); 00218 CMgaContext* pMgaContext=&pApp->m_CurrentProject.m_MgaContext; 00219 pMgaContext->BeginTransaction(false); 00220 00221 COMTHROW( ccpParentModel->CreateChildObject(ccpMetaRole,&ccpNewFCO) ); 00222 // Setting name to the newly created object 00223 if (ccpMetaRole->Name == ccpMetaRole->Kind->Name) 00224 { 00225 ccpNewFCO->Name = ccpMetaRole->Kind->DisplayedName; 00226 } 00227 else 00228 { 00229 ccpNewFCO->Name = ccpMetaRole->DisplayedName; 00230 } 00231 00232 // Ending transaction 00233 pMgaContext->CommitTransaction(); 00234 } 00235 00236 }break; 00237 } 00238 } 00239 } 00240 00241 } 00242 00243 void CAggregateContextMenu::OnEditCut() 00244 { 00245 00246 } 00247 00248 void CAggregateContextMenu::OnEditCopy() 00249 { 00250 00251 CPoint ptDummy; 00252 m_pParent->DoCopy(); 00253 } 00254 00255 void CAggregateContextMenu::OnEditCopyClosure() 00256 { 00257 CPoint ptDummy; 00258 m_pParent->DoCopyClosure(); 00259 } 00260 00261 void CAggregateContextMenu::OnEditCopySmart() 00262 { 00263 CPoint ptDummy; 00264 m_pParent->DoCopySmart(); 00265 } 00266 00267 void CAggregateContextMenu::OnEditPaste() 00268 { 00269 COleDataObject OleDataObject; 00270 00271 if (OleDataObject.AttachClipboard() == FALSE) 00272 { 00273 m_pParent->MessageBox(_T("Cannot recover data from the clipboard."),_T("Paste Error"),MB_ICONERROR); 00274 } 00275 else 00276 { 00277 if(!m_pParent->m_TreeAggregate.DoDrop(DRAGOP_COPY,&OleDataObject,CPoint(0,0))) 00278 { 00279 m_pParent->MessageBox(_T("Cannot paste data from the clipboard. Please select valid target item."),_T("Paste Error"),MB_ICONERROR); 00280 } 00281 } 00282 } 00283 00284 void CAggregateContextMenu::OnEditPasteSpecialAsReference() 00285 { 00286 COleDataObject OleDataObject; 00287 00288 if (OleDataObject.AttachClipboard() == FALSE) 00289 { 00290 m_pParent->MessageBox(_T("Cannot recover data from the clipboard."),_T("Paste Error"),MB_ICONERROR); 00291 } 00292 else 00293 { 00294 if(!m_pParent->m_TreeAggregate.DoDrop(DRAGOP_REFERENCE,&OleDataObject,CPoint(0,0))) 00295 { 00296 m_pParent->MessageBox(_T("Cannot paste data from the clipboard. Please select valid target item."),_T("Paste Error"),MB_ICONERROR); 00297 } 00298 } 00299 } 00300 00301 void CAggregateContextMenu::OnEditPasteSpecialAsSubtype() 00302 { 00303 COleDataObject OleDataObject; 00304 00305 if (OleDataObject.AttachClipboard() == FALSE) 00306 { 00307 m_pParent->MessageBox(_T("Cannot recover data from the clipboard."),_T("Paste Error"),MB_ICONERROR); 00308 } 00309 else 00310 { 00311 if(!m_pParent->m_TreeAggregate.DoDrop(DRAGOP_SUBTYPE,&OleDataObject,CPoint(0,0))) 00312 { 00313 m_pParent->MessageBox(_T("Cannot paste data from the clipboard. Please select valid target item."),_T("Paste Error"),MB_ICONERROR); 00314 } 00315 } 00316 } 00317 00318 void CAggregateContextMenu::OnEditPasteSpecialAsInstance() 00319 { 00320 COleDataObject OleDataObject; 00321 00322 if (OleDataObject.AttachClipboard() == FALSE) 00323 { 00324 m_pParent->MessageBox(_T("Cannot recover data from the clipboard."),_T("Paste Error"),MB_ICONERROR); 00325 } 00326 else 00327 { 00328 if(!m_pParent->m_TreeAggregate.DoDrop(DRAGOP_INSTANCE,&OleDataObject,CPoint(0,0))) 00329 { 00330 m_pParent->MessageBox(_T("Cannot paste data from the clipboard. Please select valid target item."),_T("Paste Error"),MB_ICONERROR); 00331 } 00332 } 00333 } 00334 00335 void CAggregateContextMenu::OnEditPasteClosure( bool merge) 00336 { 00337 COleDataObject OleDataObject; 00338 00339 if (OleDataObject.AttachClipboard() == FALSE) 00340 { 00341 m_pParent->MessageBox(_T("Cannot recover data from the clipboard."),_T("Paste Error"),MB_ICONERROR); 00342 } 00343 else 00344 { 00345 if(!m_pParent->m_TreeAggregate.DoDropWithoutChecking( merge?DRAGOP_CLOSURE_MERGE:DRAGOP_CLOSURE, &OleDataObject,CPoint(0,0))) 00346 { 00347 m_pParent->MessageBox(_T("Cannot paste data from the clipboard. Please select valid target item."),_T("Paste Error"),MB_ICONERROR); 00348 } 00349 } 00350 } 00351 void CAggregateContextMenu::OnEditDelete() 00352 { 00353 bool detach_answered = false; 00354 CMgaContext * pMgaContext = NULL; 00355 try 00356 { 00357 HTREEITEM hSelItem=m_pParent->m_TreeAggregate.GetFirstSelectedItem(); 00358 LPUNKNOWN pUnknown; 00359 00360 // Starting transaction 00361 CGMEActiveBrowserApp* pApp=(CGMEActiveBrowserApp*)AfxGetApp(); 00362 pMgaContext = &pApp->m_CurrentProject.m_MgaContext; 00363 pMgaContext->BeginTransaction(TRANSACTION_NON_NESTED); 00364 00365 while(hSelItem) 00366 { 00368 // The MGA layer does not send consistent messages with its actual state 00369 // So we collapse the item to be deleted, to avoid the inconsistency 00370 // caused by the order of deleting the child items and the parents in MGA 00371 if( m_pParent->m_TreeAggregate.m_MgaMap.LookupObjectUnknown(hSelItem,pUnknown)) 00372 { 00373 bool has_dependency = true; 00374 // deletion of libraries which have some dependency 00375 // (either _includes or _includedBy) is confirmed 00376 if( m_pParent->m_TreeAggregate.IsLibrary(pUnknown, &has_dependency) && has_dependency) 00377 { 00378 CComQIPtr<IMgaFolder> ccpMgaFolder(pUnknown); 00379 bool deld = m_pParent->askUserAndDeleteLibrary( ccpMgaFolder); 00380 if( deld) m_pParent->m_TreeAggregate.DeleteAllChildren(hSelItem); 00381 } 00382 else 00383 { 00384 m_pParent->m_TreeAggregate.DeleteAllChildren(hSelItem); 00385 CComQIPtr<IMgaObject> ccpMgaObject(pUnknown); 00386 // throws E_MGA_MUST_ABORT if user selects CANCEL 00387 detach_answered = m_pParent->askUserAndDetach( ccpMgaObject); 00388 // Deleting object 00389 COMTHROW(ccpMgaObject->DestroyObject()); 00390 } 00391 } 00392 hSelItem=m_pParent->m_TreeAggregate.GetNextSelectedItem(hSelItem); 00393 } 00394 // Ending transaction 00395 pMgaContext->CommitTransaction(); 00396 } 00397 catch(hresult_exception &) 00398 { 00399 pMgaContext->AbortTransaction(); 00400 } 00401 if( detach_answered) 00402 m_pParent->Refresh(); 00403 } 00404 00405 void CAggregateContextMenu::OnCheckAllConstraint() 00406 { 00407 CGMEActiveBrowserApp* pApp = (CGMEActiveBrowserApp*)AfxGetApp(); 00408 CMgaContext* pMgaContext = &pApp->m_CurrentProject.m_MgaContext; 00409 00410 CComPtr<IMgaComponentEx> constrMgr; 00411 if (pMgaContext) 00412 constrMgr = pMgaContext->FindConstraintManager(); 00413 ASSERT(constrMgr); 00414 if (constrMgr) // Invoke constraint manager 00415 COMTHROW(constrMgr->ObjectsInvokeEx(pMgaContext->m_ccpProject, NULL, NULL, GME_BROWSER_START)); 00416 } 00417 00418 void CAggregateContextMenu::OnInterpret() 00419 { 00420 00421 CGMEActiveBrowserApp* pApp=(CGMEActiveBrowserApp*)AfxGetApp(); 00422 CMgaContext* pMgaContext=&pApp->m_CurrentProject.m_MgaContext; 00423 00424 HTREEITEM hSelItem=NULL; 00425 LPUNKNOWN pUnknown=NULL; 00426 00427 // Collection for the selected FCOs 00428 CComPtr<IMgaFCOs> ccpSelFCOs; 00429 COMTHROW(ccpSelFCOs.CoCreateInstance(L"Mga.MgaFCOs")); 00430 00431 00432 /* Iterating through the selected items in the tree control creating an FCO collection*/ 00433 // Starting transaction 00434 pMgaContext->BeginTransaction(); 00435 // Iteration 00436 hSelItem=m_pParent->m_TreeAggregate.GetFirstSelectedItem(); 00437 while(hSelItem) 00438 { 00439 00440 if(m_pParent->m_TreeAggregate.m_MgaMap.LookupObjectUnknown(hSelItem,pUnknown)) 00441 { 00442 CComQIPtr<IMgaFCO> ccpMgaFCO(pUnknown); 00443 if(ccpMgaFCO!=NULL) // If the selected object is FCO, add to the collection 00444 { 00445 COMTHROW(ccpSelFCOs->Append(ccpMgaFCO)); 00446 // BUGFIX by PETER 00447 // COMTHROW(ccpMgaFCO->CreateCollection(&ccpSelFCOs)); 00448 } 00449 } 00450 00451 hSelItem=m_pParent->m_TreeAggregate.GetNextSelectedItem(hSelItem); 00452 } 00453 // Ending transaction 00454 pMgaContext->CommitTransaction(); 00455 00456 00457 // Creating launcher 00458 CComObjPtr<IMgaLauncher> ccpMgaLauncher; 00459 COMTHROW( ccpMgaLauncher.CoCreateInstance(L"Mga.MgaLauncher") ); 00460 00461 // Calling the interpreter via MGA 00462 // Disable the DCOM wait dialogs: if interpreters want them, they can do it themselves; but if they don't want them, they need to link to GME's mfc1xxu.dll 00463 COleMessageFilter* messageFilter = AfxOleGetMessageFilter(); 00464 std::shared_ptr<COleMessageFilter> busyRestore; 00465 std::shared_ptr<COleMessageFilter> notRespondingRestore; 00466 if (messageFilter) 00467 { 00468 messageFilter->EnableBusyDialog(FALSE); 00469 messageFilter->EnableNotRespondingDialog(FALSE); 00470 busyRestore = std::shared_ptr<COleMessageFilter>(messageFilter, [](COleMessageFilter* filter){ filter->EnableBusyDialog(TRUE); } ); 00471 notRespondingRestore = std::shared_ptr<COleMessageFilter>(messageFilter, [](COleMessageFilter* filter){ filter->EnableNotRespondingDialog(TRUE); } ); 00472 } 00473 COMTHROW( ccpMgaLauncher->RunComponent(NULL,pMgaContext->m_ccpProject, NULL, 00474 ccpSelFCOs,GME_BROWSER_START) ); 00475 } 00476 00477 void CAggregateContextMenu::OnSortName() 00478 { 00479 m_pParent->m_Options.m_soSortOptions=SORT_BYNAME; 00480 m_pParent->m_TreeAggregate.SortItems(); 00481 } 00482 00483 void CAggregateContextMenu::OnSortType() 00484 { 00485 m_pParent->m_Options.m_soSortOptions=SORT_BYTYPE; 00486 m_pParent->m_TreeAggregate.SortItems(); 00487 } 00488 00489 void CAggregateContextMenu::OnSortCreation() 00490 { 00491 CGMEActiveBrowserApp* pApp=(CGMEActiveBrowserApp*)AfxGetApp(); 00492 CMgaContext* pMgaContext=&pApp->m_CurrentProject.m_MgaContext; 00493 00494 m_pParent->m_Options.m_soSortOptions=SORT_BYCREATION; 00495 00496 // Starting transaction 00497 pMgaContext->BeginTransaction(); 00498 m_pParent->m_TreeAggregate.SortItems(); 00499 // Ending transaction 00500 pMgaContext->CommitTransaction(); 00501 } 00502 00503 void CAggregateContextMenu::OnProperties() 00504 { 00505 00506 HTREEITEM hItem=m_pParent->m_TreeAggregate.GetSelectedItem(); 00507 LPUNKNOWN pUnknown=NULL; 00508 00509 if(m_pParent->m_TreeAggregate.m_MgaMap.LookupObjectUnknown(hItem,pUnknown)) 00510 { 00511 // Firing the event 00512 CGMEActiveBrowserApp* pApp=(CGMEActiveBrowserApp*)AfxGetApp(); 00513 pApp->GetCtrl()->FireShowProperties(); 00514 } 00515 } 00516 00517 void CAggregateContextMenu::OnAttributes() 00518 { 00519 HTREEITEM hItem=m_pParent->m_TreeAggregate.GetSelectedItem(); 00520 00521 LPUNKNOWN pUnknown=NULL; 00522 00523 if(m_pParent->m_TreeAggregate.m_MgaMap.LookupObjectUnknown(hItem,pUnknown)) 00524 { 00525 TRACE(m_pParent->m_TreeAggregate.GetItemText(hItem)); 00526 00527 // Firing the event 00528 CGMEActiveBrowserApp* pApp=(CGMEActiveBrowserApp*)AfxGetApp(); 00529 pApp->GetCtrl()->FireShowAttributes(pUnknown); 00530 } 00531 } 00532 00533 void CAggregateContextMenu::OnPreferences() 00534 { 00535 HTREEITEM hItem=m_pParent->m_TreeAggregate.GetSelectedItem(); 00536 LPUNKNOWN pUnknown=NULL; 00537 00538 if(m_pParent->m_TreeAggregate.m_MgaMap.LookupObjectUnknown(hItem,pUnknown)) 00539 { 00540 TRACE(m_pParent->m_TreeAggregate.GetItemText(hItem)); 00541 00542 // Firing the event 00543 CGMEActiveBrowserApp* pApp=(CGMEActiveBrowserApp*)AfxGetApp(); 00544 pApp->GetCtrl()->FireShowPreferences(pUnknown); 00545 } 00546 } 00547 00548 void CAggregateContextMenu::OnRegistry() 00549 { 00550 HTREEITEM hItem=m_pParent->m_TreeAggregate.GetSelectedItem(); 00551 LPUNKNOWN pUnknown=NULL; 00552 00553 if(m_pParent->m_TreeAggregate.m_MgaMap.LookupObjectUnknown(hItem,pUnknown)) 00554 { 00555 CComQIPtr<IMgaObject> ccpMgaObject(pUnknown); 00556 if(ccpMgaObject!=NULL) 00557 { 00558 // Creating launcher 00559 CComObjPtr<IMgaLauncher> ccpMgaLauncher; 00560 COMTHROW( ccpMgaLauncher.CoCreateInstance(L"Mga.MgaLauncher") ); 00561 00562 CGMEActiveBrowserApp* pApp=(CGMEActiveBrowserApp*)AfxGetApp(); 00563 CMgaContext* pMgaContext=&pApp->m_CurrentProject.m_MgaContext; 00564 00565 // Starting transaction 00566 pMgaContext->BeginTransaction(false); 00567 COMTHROW( ccpMgaLauncher->RegistryBrowser(ccpMgaObject)); 00568 // Ending transaction 00569 pMgaContext->CommitTransaction(); 00570 } 00571 } 00572 } 00573 00574 00575 void CAggregateContextMenu::OnHelp() 00576 { 00577 HTREEITEM hItem=m_pParent->m_TreeAggregate.GetSelectedItem(); 00578 LPUNKNOWN pUnknown=NULL; 00579 00580 if(m_pParent->m_TreeAggregate.m_MgaMap.LookupObjectUnknown(hItem,pUnknown)) 00581 { 00582 CComQIPtr<IMgaObject> ccpMgaObject(pUnknown); 00583 if(ccpMgaObject!=NULL) 00584 { 00585 // Creating launcher 00586 CComObjPtr<IMgaLauncher> ccpMgaLauncher; 00587 COMTHROW( ccpMgaLauncher.CoCreateInstance(L"Mga.MgaLauncher") ); 00588 00589 CGMEActiveBrowserApp* pApp=(CGMEActiveBrowserApp*)AfxGetApp(); 00590 CMgaContext* pMgaContext=&pApp->m_CurrentProject.m_MgaContext; 00591 00592 // Starting transaction 00593 pMgaContext->BeginTransaction(); 00594 COMTHROW( ccpMgaLauncher->ShowHelp(ccpMgaObject)); 00595 // Ending transaction 00596 pMgaContext->CommitTransaction(); 00597 00598 } 00599 } 00600 } 00601 00602 void CAggregateContextMenu::CreateForSingleItem() 00603 { 00604 VERIFY(LoadMenu(CG_IDR_POPUP_AGGREGATE_PROPERTY_PAGE_SINGLE_ITEM)); 00605 00606 // Check constraint 00607 CGMEActiveBrowserApp* pApp = (CGMEActiveBrowserApp*)AfxGetApp(); 00608 CMgaContext* pMgaContext = &pApp->m_CurrentProject.m_MgaContext; 00609 CComPtr<IMgaComponentEx> constrMgr = pMgaContext->FindConstraintManager(); 00610 if (!constrMgr) 00611 EnableMenuItem(ID_POPUP_CONSTRAINTS_CHECK, MF_GRAYED); 00612 00613 // Setting Paste 00614 COleDataObject OleDataObj; 00615 BOOL bEnable = OleDataObj.AttachClipboard() && 00616 ( CGMEDataSource::IsGmeNativeDataAvailable(&OleDataObj,pMgaContext->m_ccpProject) || 00617 CGMEDataSource::IsXMLDataAvailable(&OleDataObj) ); 00618 if(bEnable) 00619 { 00620 EnableMenuItem(ID_EDIT_PASTE,MF_ENABLED); 00621 } 00622 else 00623 { 00624 EnableMenuItem(ID_EDIT_PASTE,MF_GRAYED); 00625 } 00626 00627 00628 HTREEITEM hItem=m_pParent->m_TreeAggregate.GetSelectedItem(); 00629 CAggregateMgaObjectProxy MgaObjectProxy; 00630 00631 if(m_pParent->m_TreeAggregate.m_MgaMap.LookupObjectProxy(hItem,MgaObjectProxy)) 00632 { 00633 { // Remove Multi-user submenu if not an mgx 00634 CGMEActiveBrowserApp* pApp=(CGMEActiveBrowserApp*)AfxGetApp(); 00635 CMgaContext* pMgaContext=&pApp->m_CurrentProject.m_MgaContext; 00636 CComBSTR connStr; 00637 if (SUCCEEDED(pMgaContext->m_ccpProject->get_ProjectConnStr(&connStr))) { 00638 if (wmemcmp(L"MGX=", connStr.m_str, 4) != 0) { 00639 GetSubMenu(0)->DeleteMenu(21, MF_BYPOSITION); 00640 } 00641 } 00642 } 00643 00644 int insertionsSeparatorPosition = 6; 00645 switch(MgaObjectProxy.m_TypeInfo) 00646 { 00647 case OBJTYPE_FOLDER: 00648 { 00649 // Folder is not FCO - limited operations 00650 DeleteMenu(ID_POPUP_PREFERENCES, MF_BYCOMMAND); 00651 00652 if( hItem == m_pParent->m_TreeAggregate.GetRootItem()) // RootFolder 00653 { 00654 ModifyMenu( ID_POPUP_REFRESH_LIBRARY, MF_BYCOMMAND, ID_POPUP_LIBRARY_AMBIGUITYCHK, _T("Chec&k GUID ambiguity...")); 00655 ModifyMenu( ID_POPUP_ATTRIBUTES, MF_BYCOMMAND|MF_STRING, ID_POPUP_ATTRIBUTES, _T("&Project Preferences")); 00656 } 00657 else 00658 { 00659 DeleteMenu( ID_POPUP_ATTRIBUTES, MF_BYCOMMAND); // no Attributes 00660 00661 // it is a regular folder or library folder 00662 bool has_dependency; 00663 if( m_pParent->m_TreeAggregate.IsLibrary(MgaObjectProxy.m_pMgaObject, &has_dependency)) 00664 { // library folder 00665 if( has_dependency) 00666 InsertMenu( ID_POPUP_REFRESH_LIBRARY, MF_BYCOMMAND|MF_STRING, ID_POPUP_LIBRARY_DEPENDENCIES, _T("D&ependencies...")); 00667 00668 DeleteMenu( ID_POPUP_ATTACH_LIBRARY, MF_BYCOMMAND); 00669 } 00670 else 00671 { // regular folder 00672 DeleteMenu( ID_POPUP_REFRESH_LIBRARY, MF_BYCOMMAND); 00673 DeleteMenu( ID_POPUP_ATTACH_LIBRARY, MF_BYCOMMAND); 00674 } 00675 } 00676 00677 00678 00679 00680 EnableMenuItem(ID_POPUP_CONSTRAINTS_CHECK,MF_GRAYED); 00681 00682 SetFolderChildren(MgaObjectProxy.m_pMgaObject); 00683 00684 // Deleting INSERTIONS menu item 00685 CMenu* pPopup=GetSubMenu(0); 00686 if(m_InsertionMinID==m_InsertionMaxID) // There were no insertions 00687 { // deleting INSERTIONS 00688 pPopup->DeleteMenu(ID_POPUP_INSERTIONS,MF_BYCOMMAND); 00689 pPopup->DeleteMenu(insertionsSeparatorPosition, MF_BYPOSITION); // deleting separator 00690 } 00691 else 00692 { 00693 // deleting INSERTIONS 00694 pPopup->DeleteMenu(ID_POPUP_INSERTIONS,MF_BYCOMMAND); 00695 } 00696 00697 // a folder can't be viewed in its parent 00698 // EnableMenuItem(ID_POPUP_SHOWINPARENT,MF_GRAYED); 00699 pPopup->DeleteMenu( ID_POPUP_SHOWINPARENT, MF_BYCOMMAND); 00700 00701 }break; 00702 00703 case OBJTYPE_MODEL: 00704 { 00705 SetModelChildren(MgaObjectProxy.m_pMgaObject); 00706 00707 // Deleting INSERTIONS menu item 00708 CMenu* pPopup=GetSubMenu(0); 00709 if(m_InsertionMinID==m_InsertionMaxID) 00710 { 00711 pPopup->DeleteMenu(ID_POPUP_INSERTIONS,MF_BYCOMMAND); // deleting INSERTIONS 00712 pPopup->DeleteMenu(insertionsSeparatorPosition, MF_BYPOSITION); // deleting separator 00713 } 00714 else 00715 { 00716 // deleting INSERTIONS 00717 pPopup->DeleteMenu(ID_POPUP_INSERTIONS,MF_BYCOMMAND); 00718 } 00719 00720 DeleteMenu( ID_POPUP_REFRESH_LIBRARY, MF_BYCOMMAND); 00721 DeleteMenu( ID_POPUP_ATTACH_LIBRARY, MF_BYCOMMAND); 00722 00723 }break; 00724 00725 case OBJTYPE_REFERENCE: 00726 { 00727 InsertMenu( ID_POPUP_REFRESH_LIBRARY, MF_BYCOMMAND, ID_POPUP_FOLLOWREF, _T("&Follow Reference")); 00728 insertionsSeparatorPosition++; 00729 }// no break here! 00730 default: 00731 { 00732 // Delete "INSERTIONS" item plus one separator 00733 CMenu* pPopup=GetSubMenu(0); 00734 pPopup->DeleteMenu(ID_POPUP_INSERTIONS,MF_BYCOMMAND); 00735 pPopup->DeleteMenu(insertionsSeparatorPosition, MF_BYPOSITION); 00736 00737 DeleteMenu( ID_POPUP_REFRESH_LIBRARY, MF_BYCOMMAND); 00738 DeleteMenu( ID_POPUP_ATTACH_LIBRARY, MF_BYCOMMAND); 00739 } 00740 } 00741 00742 // determining whether to enable/disable the 'ShowInParent' menuitem 00743 if( OBJTYPE_FOLDER != MgaObjectProxy.m_TypeInfo) // for folders we already deleted the feature 00744 { 00745 HTREEITEM hItemsParent = m_pParent->m_TreeAggregate.GetParentItem( hItem); 00746 CAggregateMgaObjectProxy MgaParentProxy; // if parent is a model, then enable 00747 if(m_pParent->m_TreeAggregate.m_MgaMap.LookupObjectProxy(hItemsParent,MgaParentProxy)) 00748 EnableMenuItem( ID_POPUP_SHOWINPARENT, OBJTYPE_MODEL == MgaParentProxy.m_TypeInfo?MF_ENABLED:MF_GRAYED); 00749 } 00750 } 00751 } 00752 00753 /*************** Adding dynamic submenus to the selected folder *************/ 00754 // Mmodifies the list named m_MenuItem2MetaObjArray, and the allowed 00755 // insertions will be stored in the same order as they are inserted 00756 // into the menu 00757 void CAggregateContextMenu::SetFolderChildren(LPUNKNOWN pUnknown) 00758 { 00759 00760 CComQIPtr<IMgaFolder> ccpMgaFolder(pUnknown); 00761 00762 // Getting the meta of the selected folder 00763 CComPtr<IMgaMetaFolder> ccpMgaMetaFolder; 00764 // Starting transaction 00765 CGMEActiveBrowserApp* pApp=(CGMEActiveBrowserApp*)AfxGetApp(); 00766 CMgaContext* pMgaContext=&pApp->m_CurrentProject.m_MgaContext; 00767 pMgaContext->BeginTransaction(); 00768 COMTHROW( ccpMgaFolder->get_MetaFolder(&ccpMgaMetaFolder) ); 00769 // Ending transaction 00770 pMgaContext->CommitTransaction(); 00771 00772 00773 /**** Getting legal child folders and iterating through them ****/ 00774 CComPtr<IMgaMetaFolders> ccpMetaFolders; 00775 COMTHROW( ccpMgaMetaFolder->get_LegalChildFolders(&ccpMetaFolders) ); 00776 00777 CMenu mnuInsertFolder; 00778 VERIFY( mnuInsertFolder.CreatePopupMenu() ); 00779 00780 MGACOLL_ITERATE(IMgaMetaFolder, ccpMetaFolders) 00781 { 00782 // Getting displayed name 00783 CComBSTR bszDispName; 00784 COMTHROW( MGACOLL_ITER->get_DisplayedName(&bszDispName) ); 00785 // Add displayed name to the menu 00786 mnuInsertFolder.AppendMenu(MF_STRING,m_InsertionMaxID++,CString(bszDispName)); 00787 // Add ptr to the list 00788 CComPtr<IMgaMetaBase> ccpMetaBase(MGACOLL_ITER); 00789 m_MenuItem2MetaObjArray.Add(ADAPT(ccpMetaBase)); 00790 }MGACOLL_ITERATE_END; 00791 00792 // If the menu is not empty add to the popup, otherwise the destructor 00793 // will automatically destroy it 00794 if(mnuInsertFolder.GetMenuItemCount()!=NULL) 00795 { 00796 InsertMenu(ID_POPUP_INSERTIONS,MF_POPUP|MF_STRING,(UINT)mnuInsertFolder.GetSafeHmenu(),_T("Insert &Folder")); 00797 mnuInsertFolder.Detach(); 00798 } 00799 00800 /**** Searching for allowed child FCOs ****/ 00801 // Creating submenus 00802 CMenu mnuInsertAtom; 00803 CMenu mnuInsertModel; 00804 CMenu mnuInsertReference; 00805 CMenu mnuInsertSet; 00806 // Initialize submenus 00807 VERIFY( mnuInsertAtom.CreatePopupMenu() ); 00808 VERIFY( mnuInsertModel.CreatePopupMenu() ); 00809 VERIFY( mnuInsertReference.CreatePopupMenu() ); 00810 VERIFY( mnuInsertSet.CreatePopupMenu() ); 00811 00812 // Getting legal children 00813 CComPtr<IMgaMetaFCOs> ccpChildFCOs; 00814 COMTHROW( ccpMgaMetaFolder->get_LegalRootObjects(&ccpChildFCOs) ); 00815 00816 // Iterate through the children FCO list 00817 MGACOLL_ITERATE(IMgaMetaFCO, ccpChildFCOs) 00818 { 00819 // Get displayed name 00820 CComBSTR bszDispName; 00821 COMTHROW( MGACOLL_ITER->get_DisplayedName(&bszDispName) ); 00822 00823 objtype_enum otChildType = OBJTYPE_NULL; 00824 COMTHROW( MGACOLL_ITER->get_ObjType(&otChildType) ); 00825 00826 switch(otChildType) 00827 { 00828 case OBJTYPE_ATOM: 00829 { 00830 mnuInsertAtom.AppendMenu(MF_STRING,m_InsertionMaxID++, 00831 CString(bszDispName)); 00832 // Add ptr to the list 00833 CComPtr<IMgaMetaBase> ccpMetaBase(MGACOLL_ITER); 00834 m_MenuItem2MetaObjArray.Add(ADAPT(ccpMetaBase)); 00835 }break; 00836 case OBJTYPE_MODEL: 00837 { 00838 mnuInsertModel.AppendMenu(MF_STRING,m_InsertionMaxID++, 00839 CString(bszDispName)); 00840 // Add ptr to the list 00841 CComPtr<IMgaMetaBase> ccpMetaBase(MGACOLL_ITER); 00842 m_MenuItem2MetaObjArray.Add(ADAPT(ccpMetaBase)); 00843 }break; 00844 case OBJTYPE_REFERENCE: 00845 { 00846 mnuInsertReference.AppendMenu(MF_STRING,m_InsertionMaxID++, 00847 CString(bszDispName)); 00848 // Add ptr to the list 00849 CComPtr<IMgaMetaBase> ccpMetaBase(MGACOLL_ITER); 00850 m_MenuItem2MetaObjArray.Add(ADAPT(ccpMetaBase)); 00851 00852 }break; 00853 case OBJTYPE_SET: 00854 { 00855 mnuInsertSet.AppendMenu(MF_STRING,m_InsertionMaxID++, 00856 CString(bszDispName)); 00857 // Add ptr to the list 00858 CComPtr<IMgaMetaBase> ccpMetaBase(MGACOLL_ITER); 00859 m_MenuItem2MetaObjArray.Add(ADAPT(ccpMetaBase)); 00860 }break; 00861 } 00862 00863 }MGACOLL_ITERATE_END; 00864 00865 // Appending the submenus created above 00866 // If the menu is not empty add to the popup, otherwise the destructor 00867 // will automatically destroy it 00868 // Append Atom 00869 if(mnuInsertAtom.GetMenuItemCount()!=NULL) 00870 { 00871 InsertMenu(ID_POPUP_INSERTIONS,MF_POPUP|MF_STRING,(UINT)mnuInsertAtom.GetSafeHmenu(),_T("Insert &Atom")); 00872 mnuInsertAtom.Detach(); 00873 } 00874 00875 // Append Model 00876 if(mnuInsertModel.GetMenuItemCount()!=NULL) 00877 { 00878 InsertMenu(ID_POPUP_INSERTIONS,MF_POPUP|MF_STRING,(UINT)mnuInsertModel.GetSafeHmenu(),_T("Insert &Model")); 00879 mnuInsertModel.Detach(); 00880 } 00881 00882 // Append Reference 00883 if(mnuInsertReference.GetMenuItemCount()!=NULL) 00884 { 00885 InsertMenu(ID_POPUP_INSERTIONS,MF_POPUP|MF_STRING,(UINT)mnuInsertReference.GetSafeHmenu(),_T("Insert &Reference")); 00886 mnuInsertReference.Detach(); 00887 } 00888 00889 // Append Set 00890 if(mnuInsertSet.GetMenuItemCount()!=NULL) 00891 { 00892 InsertMenu(ID_POPUP_INSERTIONS,MF_POPUP|MF_STRING,(UINT)mnuInsertSet.GetSafeHmenu(),_T("Insert &Set")); 00893 mnuInsertSet.Detach(); 00894 } 00895 00896 } 00897 00898 00899 00900 /*************** Adding dynamic submenus to the selected folder *************/ 00901 // Mmodifies the list named m_MenuItem2MetaObjArray, and the allowed 00902 // insertions will be stored in the same order as they are inserted 00903 // into the menu 00904 00905 void CAggregateContextMenu::SetModelChildren(LPUNKNOWN pUnknown) 00906 { 00907 CComQIPtr<IMgaModel> ccpMgaModel(pUnknown); 00908 00909 // Getting the meta of the selected model 00910 CComPtr<IMgaMetaFCO> ccpMgaMetaFCO; 00911 // Starting transaction 00912 CGMEActiveBrowserApp* pApp=(CGMEActiveBrowserApp*)AfxGetApp(); 00913 CMgaContext* pMgaContext=&pApp->m_CurrentProject.m_MgaContext; 00914 pMgaContext->BeginTransaction(); 00915 COMTHROW( ccpMgaModel->get_Meta(&ccpMgaMetaFCO) ); 00916 // Ending transaction 00917 pMgaContext->CommitTransaction(); 00918 00919 // Converting meta FCO to metamodel 00920 CComQIPtr<IMgaMetaModel> ccpMgaMetaModel(ccpMgaMetaFCO); 00921 if(!ccpMgaMetaModel)return; 00922 00923 /**** Searching for allowed child FCOs ****/ 00924 // Creating submenus 00925 CMenu mnuInsertAtom; 00926 CMenu mnuInsertModel; 00927 CMenu mnuInsertReference; 00928 CMenu mnuInsertSet; 00929 // Initialize submenus 00930 VERIFY( mnuInsertAtom.CreatePopupMenu() ); 00931 VERIFY( mnuInsertModel.CreatePopupMenu() ); 00932 VERIFY( mnuInsertReference.CreatePopupMenu() ); 00933 VERIFY( mnuInsertSet.CreatePopupMenu() ); 00934 00935 // Getting role list 00936 CComPtr<IMgaMetaRoles> ccpMetaRoles; 00937 COMTHROW( ccpMgaMetaModel->get_Roles(&ccpMetaRoles) ); 00938 00939 // Iterate through the role list 00940 MGACOLL_ITERATE(IMgaMetaRole, ccpMetaRoles) 00941 { 00942 // Get displayed name 00943 CComBSTR bszDispName; 00944 00945 CComPtr<IMgaMetaFCO> kind; 00946 COMTHROW(MGACOLL_ITER->get_Kind(&kind)); 00947 CComBSTR bstrKindName; 00948 COMTHROW(kind->get_Name(&bstrKindName)); 00949 CComBSTR bstrRoleName; 00950 COMTHROW(MGACOLL_ITER->get_Name(&bstrRoleName)); 00951 if (bstrKindName == bstrRoleName) { 00952 COMTHROW(kind->get_DisplayedName(&bszDispName)); 00953 } 00954 else { 00955 bszDispName = bstrRoleName; 00956 } 00957 00958 00959 // Getting object type 00960 CComPtr<IMgaMetaFCO> ccpMetaFCO; 00961 COMTHROW( MGACOLL_ITER->get_Kind(&ccpMetaFCO)); 00962 objtype_enum otChildType = OBJTYPE_NULL; 00963 if(ccpMetaFCO) 00964 { 00965 COMTHROW( ccpMetaFCO->get_ObjType(&otChildType) ); 00966 } 00967 00968 switch(otChildType) 00969 { 00970 case OBJTYPE_ATOM: 00971 { 00972 mnuInsertAtom.AppendMenu(MF_STRING,m_InsertionMaxID++, 00973 CString(bszDispName)); 00974 // Add ptr to the list 00975 CComPtr<IMgaMetaBase> ccpMetaBase(MGACOLL_ITER); 00976 m_MenuItem2MetaObjArray.Add(ADAPT(ccpMetaBase)); 00977 00978 00979 }break; 00980 case OBJTYPE_MODEL: 00981 { 00982 mnuInsertModel.AppendMenu(MF_STRING,m_InsertionMaxID++, 00983 CString(bszDispName)); 00984 // Add ptr to the list 00985 CComPtr<IMgaMetaBase> ccpMetaBase(MGACOLL_ITER); 00986 m_MenuItem2MetaObjArray.Add(ADAPT(ccpMetaBase)); 00987 00988 }break; 00989 case OBJTYPE_REFERENCE: 00990 { 00991 mnuInsertReference.AppendMenu(MF_STRING,m_InsertionMaxID++, 00992 CString(bszDispName)); 00993 // Add ptr to the list 00994 CComPtr<IMgaMetaBase> ccpMetaBase(MGACOLL_ITER); 00995 m_MenuItem2MetaObjArray.Add(ADAPT(ccpMetaBase)); 00996 00997 }break; 00998 case OBJTYPE_SET: 00999 { 01000 mnuInsertSet.AppendMenu(MF_STRING,m_InsertionMaxID++, 01001 CString(bszDispName)); 01002 // Add ptr to the list 01003 CComPtr<IMgaMetaBase> ccpMetaBase(MGACOLL_ITER); 01004 m_MenuItem2MetaObjArray.Add(ADAPT(ccpMetaBase)); 01005 01006 }break; 01007 } 01008 01009 }MGACOLL_ITERATE_END; 01010 01011 // Appending the submenus created above 01012 // If the menu is not empty add to the popup, otherwise the destructor 01013 // will automatically destroy it 01014 // Append Atom 01015 if(mnuInsertAtom.GetMenuItemCount()!=NULL) 01016 { 01017 InsertMenu(ID_POPUP_INSERTIONS,MF_POPUP|MF_STRING,(UINT)mnuInsertAtom.GetSafeHmenu(),_T("Insert &Atom")); 01018 mnuInsertAtom.Detach(); 01019 } 01020 01021 // Append Model 01022 if(mnuInsertModel.GetMenuItemCount()!=NULL) 01023 { 01024 InsertMenu(ID_POPUP_INSERTIONS,MF_POPUP|MF_STRING,(UINT)mnuInsertModel.GetSafeHmenu(),_T("Insert &Model")); 01025 mnuInsertModel.Detach(); 01026 } 01027 01028 // Append Reference 01029 if(mnuInsertReference.GetMenuItemCount()!=NULL) 01030 { 01031 InsertMenu(ID_POPUP_INSERTIONS,MF_POPUP|MF_STRING,(UINT)mnuInsertReference.GetSafeHmenu(),_T("Insert &Reference")); 01032 mnuInsertReference.Detach(); 01033 } 01034 01035 // Append Set 01036 if(mnuInsertSet.GetMenuItemCount()!=NULL) 01037 { 01038 InsertMenu(ID_POPUP_INSERTIONS,MF_POPUP|MF_STRING,(UINT)mnuInsertSet.GetSafeHmenu(),_T("Insert &Set")); 01039 mnuInsertSet.Detach(); 01040 } 01041 } 01042 01043 void CAggregateContextMenu::CreateForAll() 01044 { 01045 /* Initialization for all type of context menus */ 01046 01047 // Edit - Undo/Redo functions 01048 CGMEActiveBrowserApp* pApp=(CGMEActiveBrowserApp*)AfxGetApp(); 01049 CMgaContext* pMgaContext=&pApp->m_CurrentProject.m_MgaContext; 01050 short nRedoSize,nUndoSize; 01051 COMTHROW(pMgaContext->m_ccpProject->UndoRedoSize(&nUndoSize,&nRedoSize)); 01052 01053 // Check all constraint 01054 CComPtr<IMgaComponentEx> constrMgr = pMgaContext->FindConstraintManager(); 01055 if (!constrMgr) 01056 EnableMenuItem(ID_POPUP_SORT_CONSTRAINTS_CHECKALL, MF_GRAYED); 01057 01058 // Sort options 01059 CheckMenuRadioItem(ID_POPUP_SORT_NAME, 01060 ID_POPUP_SORT_CREATION, 01061 ID_POPUP_SORT_NAME+m_pParent->m_Options.m_soSortOptions, 01062 MF_BYCOMMAND 01063 ); 01064 01065 } 01066 01067 void CAggregateContextMenu::OnCheckConstraint() 01068 { 01069 CGMEActiveBrowserApp* pApp = (CGMEActiveBrowserApp*)AfxGetApp(); 01070 CMgaContext* pMgaContext = &pApp->m_CurrentProject.m_MgaContext; 01071 01072 CComPtr<IMgaComponentEx> constrMgr; 01073 if (pMgaContext) 01074 constrMgr = pMgaContext->FindConstraintManager(); 01075 if (!constrMgr) 01076 return; 01077 01078 HTREEITEM hItem = m_pParent->m_TreeAggregate.GetSelectedItem(); 01079 LPUNKNOWN pUnknown = NULL; 01080 01081 if (m_pParent->m_TreeAggregate.m_MgaMap.LookupObjectUnknown(hItem, pUnknown)) 01082 { 01083 CComQIPtr<IMgaObject> ccpMgaObject(pUnknown); 01084 if (ccpMgaObject != NULL) 01085 { 01086 // Invoke constraint manager 01087 COMTHROW(constrMgr->ObjectsInvokeEx(pMgaContext->m_ccpProject, ccpMgaObject, NULL, GME_BROWSER_START)); 01088 } 01089 } 01090 } 01091 01092 void CAggregateContextMenu::OnOptions() 01093 { 01094 CAggregateOptionsDlg dlg(m_pParent); 01095 01096 if(dlg.DoModal()==IDOK) 01097 { 01098 if(dlg.m_bIsRefreshNeeded) 01099 { 01100 m_pParent->Refresh(); 01101 } 01102 if(dlg.m_bIsResortNeeded) 01103 { 01104 if(m_pParent->m_Options.m_soSortOptions==SORT_BYCREATION) 01105 { 01106 OnSortCreation(); 01107 } 01108 else 01109 { 01110 m_pParent->m_TreeAggregate.SortItems(); 01111 } 01112 01113 } 01114 01115 } 01116 } 01117 01118 void CAggregateContextMenu::OnAttachLibrary() 01119 { 01120 m_pParent->AttachLibrary(); 01121 01122 } 01123 01124 void CAggregateContextMenu::OnRefreshLibrary() 01125 { 01126 01127 m_pParent->RefreshLibrary(); 01128 } 01129 01130 void CAggregateContextMenu::OnLibraryDependencies() 01131 { 01132 m_pParent->LibraryDependencies(); 01133 } 01134 01135 void CAggregateContextMenu::OnLibraryAmbiguityChk() 01136 { 01137 m_pParent->LibraryAmbiguityChk(); 01138 } 01139 01140 void CAggregateContextMenu::OnMFSourceControlUpdate() 01141 { 01142 HTREEITEM hItem=m_pParent->m_TreeAggregate.GetSelectedItem(); 01143 LPUNKNOWN pUnknown=NULL; 01144 01145 if( hItem == m_pParent->m_TreeAggregate.GetRootItem()) // RootFolder 01146 { 01147 MSGTRY 01148 { 01149 m_pParent->ProjectSourceControlUpdate(0); 01150 } 01151 MSGCATCH(_T("Error while updating source control info for the project!"),;) 01152 } 01153 else if(m_pParent->m_TreeAggregate.m_MgaMap.LookupObjectUnknown(hItem,pUnknown)) 01154 { 01155 CComQIPtr<IMgaFolder> ccpMgaFolder( pUnknown); 01156 CComQIPtr<IMgaModel> ccpMgaModel( pUnknown); 01157 CComBSTR id; 01158 01159 // preparing for a transaction 01160 CGMEActiveBrowserApp* pApp=(CGMEActiveBrowserApp*)AfxGetApp(); 01161 CMgaContext* pMgaContext=&pApp->m_CurrentProject.m_MgaContext; 01162 01163 MSGTRY 01164 { 01165 // Starting transaction 01166 pMgaContext->BeginTransaction(true); // it is readonly 01167 01168 if( ccpMgaModel) 01169 COMTHROW( ccpMgaModel->get_ID( &id)); 01170 else if( ccpMgaFolder) 01171 COMTHROW( ccpMgaFolder->get_ID( &id)); 01172 01173 // Ending transaction 01174 pMgaContext->CommitTransaction(); 01175 01176 } 01177 MSGCATCH(_T("Error while updating source control info!"),pMgaContext->AbortTransaction();) 01178 01179 MSGTRY 01180 { 01181 // it will open and commit its own transaction 01182 m_pParent->ProjectSourceControlUpdate( id); 01183 } 01184 MSGCATCH(_T("Error while updating source control info!"),;) 01185 01186 //if( ccpMgaModel || ccpMgaFolder) 01187 // m_pParent->Refresh(); 01188 } 01189 } 01190 01191 void CAggregateContextMenu::OnUsersActive() 01192 { 01193 MSGTRY 01194 { 01195 // it will open and commit its own transaction 01196 m_pParent->SourceControlActiveUsers(); 01197 } 01198 MSGCATCH(_T("Error while updating source control info!"),;) 01199 } 01200 01201 void CAggregateContextMenu::OnUsersOwner() 01202 { 01203 HTREEITEM hItem=m_pParent->m_TreeAggregate.GetSelectedItem(); 01204 LPUNKNOWN pUnknown=NULL; 01205 01206 if(m_pParent->m_TreeAggregate.m_MgaMap.LookupObjectUnknown(hItem,pUnknown)) 01207 { 01208 CComQIPtr<IMgaFolder> ccpMgaFolder( pUnknown); 01209 CComQIPtr<IMgaModel> ccpMgaModel( pUnknown); 01210 CComBSTR id; 01211 01212 // preparing for a transaction 01213 CGMEActiveBrowserApp* pApp=(CGMEActiveBrowserApp*)AfxGetApp(); 01214 CMgaContext* pMgaContext=&pApp->m_CurrentProject.m_MgaContext; 01215 01216 01217 MSGTRY 01218 { 01219 // Starting transaction 01220 pMgaContext->BeginTransaction(true); // it is readonly 01221 01222 if( ccpMgaModel) 01223 COMTHROW( ccpMgaModel->get_ID( &id)); 01224 else if( ccpMgaFolder) 01225 COMTHROW( ccpMgaFolder->get_ID( &id)); 01226 01227 // Ending transaction 01228 pMgaContext->CommitTransaction(); 01229 } 01230 MSGCATCH(_T("Error while updating source control info!"),pMgaContext->AbortTransaction();) 01231 01232 MSGTRY 01233 { 01234 // it will open and commit its own transaction 01235 m_pParent->SourceControlObjectOwner( id); 01236 } 01237 MSGCATCH(_T("Error while updating source control info!"),;) 01238 01239 01240 //if( ccpMgaModel || ccpMgaFolder) 01241 // m_pParent->Refresh(); 01242 } 01243 } 01244 01245 // ShowInParentMgaObject event fired also when Shift is pressed while DoubleClick or Enter 01246 void CAggregateContextMenu::OnShowInParent() 01247 { 01248 HTREEITEM hItem=m_pParent->m_TreeAggregate.GetSelectedItem(); 01249 LPUNKNOWN pUnknown=NULL; 01250 01251 if(m_pParent->m_TreeAggregate.m_MgaMap.LookupObjectUnknown(hItem,pUnknown)) 01252 { 01253 TRACE(m_pParent->m_TreeAggregate.GetItemText(hItem)); 01254 01255 // Firing the event 01256 CGMEActiveBrowserApp* pApp=(CGMEActiveBrowserApp*)AfxGetApp(); 01257 pApp->GetCtrl()->FireShowInParentMgaObject( pUnknown); 01258 } 01259 } 01260 01261 void CAggregateContextMenu::OnFollowRef() 01262 { 01264 //CGMEActiveBrowserApp* pApp=(CGMEActiveBrowserApp*)AfxGetApp(); 01265 //pApp->GetCtrl()->FireShowInParentMgaObject( pUnknown); 01266 01267 HTREEITEM hItem = m_pParent->m_TreeAggregate.GetSelectedItem(); 01268 LPUNKNOWN pUnknown = NULL; 01269 01270 if( m_pParent->m_TreeAggregate.m_MgaMap.LookupObjectUnknown( hItem, pUnknown)) 01271 { 01272 CComQIPtr<IMgaReference> ccpMgaRef( pUnknown); 01273 CComPtr<IMgaFCO> ccpTgt; 01274 01275 // preparing for a transaction 01276 CGMEActiveBrowserApp* pApp = (CGMEActiveBrowserApp*) AfxGetApp(); 01277 CMgaContext* pMgaContext = &pApp->m_CurrentProject.m_MgaContext; 01278 01279 MSGTRY 01280 { 01281 // Starting transaction 01282 pMgaContext->BeginTransaction(true); // it is readonly 01283 01284 01285 if( ccpMgaRef) 01286 { 01287 COMTHROW( ccpMgaRef->get_Referred( &ccpTgt)); 01288 } 01289 01290 01291 // Ending transaction 01292 pMgaContext->CommitTransaction(); 01293 } 01294 MSGCATCH( _T("Error while following reference!"), pMgaContext->AbortTransaction();) 01295 01296 MSGTRY 01297 { 01298 if( !ccpTgt) AfxMessageBox( _T("Null reference can't be followed!")); 01299 else m_pParent->GotoIUnkPtr( ccpTgt); 01300 } 01301 MSGCATCH( _T("Error while following reference!"), ;) 01302 } 01303 } 01304 01305 void CAggregateContextMenu::OnReadOnly( bool pProtectMe) 01306 { 01307 m_pParent->accessRights( pProtectMe); 01308 }