[GME-commit] GMESRC/GME/GMEActiveBrowser ActiveBrowserPropertyPage.cpp,1.44,1.45 ActiveBrowserPropertyPage.h,1.13,1.14 AggregateContextMenu.cpp,1.22,1.23 AggregateTreeCtrl.cpp,1.25,1.26 AggregateTreeCtrl.h,1.7,1.8

gme-commit at list.isis.vanderbilt.edu gme-commit at list.isis.vanderbilt.edu
Wed Aug 31 20:24:14 CDT 2005


Update of /project/gme-repository/GMESRC/GME/GMEActiveBrowser
In directory escher:/tmp/cvs-serv26453

Modified Files:
	ActiveBrowserPropertyPage.cpp ActiveBrowserPropertyPage.h 
	AggregateContextMenu.cpp AggregateTreeCtrl.cpp 
	AggregateTreeCtrl.h 
Log Message:
DetachFromArcheType
and
SmartCopy (change the existing guids upon in-project copy) 
related changes.


CVS User: Zoltan Molnar, ISIS (zolmol)

Index: ActiveBrowserPropertyPage.h
===================================================================
RCS file: /project/gme-repository/GMESRC/GME/GMEActiveBrowser/ActiveBrowserPropertyPage.h,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -d -r1.13 -r1.14
*** ActiveBrowserPropertyPage.h	19 Jan 2005 23:47:23 -0000	1.13
--- ActiveBrowserPropertyPage.h	31 Aug 2005 19:24:11 -0000	1.14
***************
*** 34,37 ****
--- 34,39 ----
  	void DoCopyClosure();
  	void DoCopySmart( int k = 0);
+ 	bool askUserAndDetach( CComPtr<IMgaObject> obj); // called when archetype is deleted
+ 
  	
  	CComboEdit m_ComboEditCtrl;

Index: AggregateContextMenu.cpp
===================================================================
RCS file: /project/gme-repository/GMESRC/GME/GMEActiveBrowser/AggregateContextMenu.cpp,v
retrieving revision 1.22
retrieving revision 1.23
diff -C2 -d -r1.22 -r1.23
*** AggregateContextMenu.cpp	19 Jul 2005 17:42:11 -0000	1.22
--- AggregateContextMenu.cpp	31 Aug 2005 19:24:11 -0000	1.23
***************
*** 368,374 ****
  	}
  }
- 
  void CAggregateContextMenu::OnEditDelete()
  {
      CMgaContext * pMgaContext = NULL;
      try
--- 368,374 ----
  	}
  }
  void CAggregateContextMenu::OnEditDelete()
  {
+     bool detach_answered = false;
      CMgaContext * pMgaContext = NULL;
      try
***************
*** 392,395 ****
--- 392,397 ----
  		    {
  			    CComQIPtr<IMgaObject> ccpMgaObject(pUnknown);
+ 			    // throws E_MGA_MUST_ABORT if user selects CANCEL
+ 			    detach_answered = m_pParent->askUserAndDetach( ccpMgaObject);
  			    // Deleting object
  			    COMTHROW(ccpMgaObject->DestroyObject());
***************
*** 404,407 ****
--- 406,411 ----
          pMgaContext->AbortTransaction();
      }
+     if( detach_answered)
+         m_pParent->Refresh();
  }
  
***************
*** 1084,1085 ****
--- 1088,1090 ----
  	m_pParent->RefreshLibrary();
  }
+ 

Index: AggregateTreeCtrl.h
===================================================================
RCS file: /project/gme-repository/GMESRC/GME/GMEActiveBrowser/AggregateTreeCtrl.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** AggregateTreeCtrl.h	10 May 2005 18:09:12 -0000	1.7
--- AggregateTreeCtrl.h	31 Aug 2005 19:24:11 -0000	1.8
***************
*** 28,31 ****
--- 28,32 ----
  	BOOL DoDrop(eDragOperation doDragOp, COleDataObject *pDataObject, CPoint point);
  	BOOL DoDropWithoutChecking(eDragOperation doDragOp, COleDataObject *pDataObject, CPoint point);
+ 	void MakeSureGUIDIsUniqueForSmartCopy( CComPtr<IMgaFCO>& fco);
  	BOOL IsRelevantDropTarget(CPoint point,CImageList*);
  	void RestoreState();

Index: ActiveBrowserPropertyPage.cpp
===================================================================
RCS file: /project/gme-repository/GMESRC/GME/GMEActiveBrowser/ActiveBrowserPropertyPage.cpp,v
retrieving revision 1.44
retrieving revision 1.45
diff -C2 -d -r1.44 -r1.45
*** ActiveBrowserPropertyPage.cpp	19 Jul 2005 17:42:11 -0000	1.44
--- ActiveBrowserPropertyPage.cpp	31 Aug 2005 19:24:11 -0000	1.45
***************
*** 3455,3456 ****
--- 3455,3504 ----
  	
  }
+ 
+ bool CAggregatePropertyPage::askUserAndDetach( CComPtr<IMgaObject> object)
+ {
+ 	CComQIPtr<IMgaFCO> fco( object);
+ 	if( !fco) return false;
+ 	// check whether dependends of fco exist
+ 	CComPtr<IMgaFCOs> der_objs;
+ 	COMTHROW(fco->get_DerivedObjects( &der_objs));
+ 	long cnt = 0;
+ 	if( der_objs) COMTHROW( der_objs->get_Count( &cnt));
+ 	if( cnt > 0) // if dependents exist should they be deleted?
+ 	{
+ 		bool question_asked = false;
+ 		bool detach_answered = false;
+ 		MGACOLL_ITERATE(IMgaFCO, der_objs) {
+ 			CComPtr<IMgaFCO> one_derived(MGACOLL_ITER);
+ 
+ 			VARIANT_BOOL prim_deriv;
+ 			COMTHROW( one_derived->get_IsPrimaryDerived( &prim_deriv));
+ 			if( prim_deriv == VARIANT_TRUE)
+ 			{
+ 				if( !question_asked) // pop up dialog only for the first time / per basetype
+ 				{
+ 					CComBSTR nm;
+ 					COMTHROW( fco->get_Name( &nm));
+ 					CString msg = "There are objects primary derived from: \"";
+ 					msg += nm;
+ 					msg += "\". Would you like to delete them as well?\n";
+ 					msg += "If you answer 'No' the derived objects will be detached, thus preserved.";
+ 
+ 					// this answer will be applied to all deriveds of this fco
+ 					int resp = AfxMessageBox( msg, MB_YESNOCANCEL);
+ 					if( resp == IDCANCEL) COMTHROW(E_MGA_MUST_ABORT);
+ 					else if( resp == IDNO) detach_answered = true;
+ 					
+ 					question_asked = true;
+ 				}
+ 
+ 				// if detach and preserve selected by the user:
+ 				if( detach_answered)
+ 					COMTHROW( one_derived->DetachFromArcheType());
+ 			}
+ 		}MGACOLL_ITERATE_END;
+ 
+ 		return detach_answered;
+ 	}
+ 	return false;
+ }

Index: AggregateTreeCtrl.cpp
===================================================================
RCS file: /project/gme-repository/GMESRC/GME/GMEActiveBrowser/AggregateTreeCtrl.cpp,v
retrieving revision 1.25
retrieving revision 1.26
diff -C2 -d -r1.25 -r1.26
*** AggregateTreeCtrl.cpp	19 Jul 2005 17:42:11 -0000	1.25
--- AggregateTreeCtrl.cpp	31 Aug 2005 19:24:11 -0000	1.26
***************
*** 676,679 ****
--- 676,706 ----
  
  
+ void CAggregateTreeCtrl::MakeSureGUIDIsUniqueForSmartCopy( CComPtr<IMgaFCO>& fco)
+ {
+ 	// this method prevents cloned objects having the same guid
+ 	// as their original ones
+ 	CComBSTR bstr;
+ 	COMTHROW( fco->get_RegistryValue( CComBSTR( "guid"), &bstr));
+ 	if( bstr == 0 || bstr == "") return; // no guid present, no need to replace it
+ 
+ 	GUID t_guid = GUID_NULL;
+ 	::CoCreateGuid(&t_guid);
+ 		
+ 	if (t_guid != GUID_NULL)
+ 	{
+ 		CString str_guid;
+ 		str_guid.Format("{%08lX-%04X-%04x-%02X%02X-%02X%02X%02X%02X%02X%02X}",
+ 			t_guid.Data1, t_guid.Data2, t_guid.Data3,
+ 			t_guid.Data4[0], t_guid.Data4[1], t_guid.Data4[2], t_guid.Data4[3],
+ 			t_guid.Data4[4], t_guid.Data4[5], t_guid.Data4[6], t_guid.Data4[7]);
+ 		
+ 		// thus replace the old guid with a new one
+ 		COMTHROW( fco->put_RegistryValue( CComBSTR( "guid"), CComBSTR(str_guid)));
+ 	}
+ 
+ 	// store the previous guid in prev subnode
+ 	COMTHROW( fco->put_RegistryValue( CComBSTR( "guid/prev"), bstr));
+ }
+ 
  
  
***************
*** 854,857 ****
--- 881,888 ----
  					COMTHROW(ccpTargetFolder->CopyFCOs(ccpDroppedFCOs,&ccpNewFCOs));
  					
+ 					MGACOLL_ITERATE(IMgaFCO, ccpNewFCOs) { // for smart copy related entries
+ 						MakeSureGUIDIsUniqueForSmartCopy( CComPtr<IMgaFCO>( MGACOLL_ITER) );
+ 					} MGACOLL_ITERATE_END;
+ 
  					bRetVal=TRUE;
  				}break;
***************
*** 997,1000 ****
--- 1028,1035 ----
  					MGACOLL_ITERATE_END;
  					COMTHROW( ccpTargetModel->CopyFCOs(ccpDroppedFCOs,ccpMetaRoles,&ccpNewFCOs) );
+ 
+ 					MGACOLL_ITERATE(IMgaFCO, ccpNewFCOs) { // for smart copy related entries
+ 						MakeSureGUIDIsUniqueForSmartCopy( CComPtr<IMgaFCO>( MGACOLL_ITER) );
+ 					} MGACOLL_ITERATE_END;
  					
  					bRetVal=TRUE;
***************
*** 1243,1244 ****
--- 1278,1280 ----
  
  }
+ 



More information about the GME-commit mailing list