[GME-commit] GMESRC/GME/Gme GMEApp.cpp,1.110,1.111

gme-commit at list.isis.vanderbilt.edu gme-commit at list.isis.vanderbilt.edu
Thu Apr 8 14:02:58 CDT 2004


Update of /var/lib/gme/GMESRC/GME/Gme
In directory braindrain:/tmp/cvs-serv26784/Gme

Modified Files:
	GMEApp.cpp 
Log Message:
Adding XSLT related files into MgaUtil and Parser.
Interfaces changed: Parser.idl, MgaUtil.idl
Modified Files:
 	Common/CommonError.h Gme/GMEApp.cpp 
 	Interfaces/InterfaceVersion.h Interfaces/MgaUtil.idl 
 	Interfaces/Parser.idl MgaUtil/MgaUtil.dsp MgaUtil/MgaUtil.rc 
 	MgaUtil/MgaUtilApp.cpp MgaUtil/MgaUtilLib.idl 
 	MgaUtil/resource.h Parser/Parser.cpp Parser/Parser.dsp 
 	Parser/Parser.rc Parser/ParserLib.idl Parser/resource.h 
Added Files:
 	MgaUtil/MgaXsltFileSel.rgs MgaUtil/XsltDial.cpp 
 	MgaUtil/XsltDial.h MgaUtil/XsltFileSel.cpp 
 	MgaUtil/XsltFileSel.h Parser/MgaXslt.cpp Parser/MgaXslt.h 
 	Parser/MgaXslt.rgs 


CVS User: zolmol

Index: GMEApp.cpp
===================================================================
RCS file: /var/lib/gme/GMESRC/GME/Gme/GMEApp.cpp,v
retrieving revision 1.110
retrieving revision 1.111
diff -C2 -d -r1.110 -r1.111
*** GMEApp.cpp	12 Mar 2004 19:57:06 -0000	1.110
--- GMEApp.cpp	8 Apr 2004 18:02:55 -0000	1.111
***************
*** 1490,1649 ****
  void CGMEApp::OnFileImportxml() 
  {
- 
  	CGMEEventLogger::LogGMEEvent("CGMEApp::OnFileImportxml ");
-  MSGTRY
-  {
- 	CComPtr<IMgaParser> parser;
- 	COMTHROW( parser.CoCreateInstance(L"Mga.MgaParser") );
- 	ASSERT( parser != NULL );
  
! 	CFileDialog dlg(TRUE, "xme", NULL,
! 		OFN_EXPLORER | OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT |
! 		OFN_FILEMUSTEXIST,
! 		"GME Exported Files (*.xme;*.xml)|*.xme; *.xml|All Files (*.*)|*.*||");
! 	if( dlg.DoModal() != IDOK )
  	{
! 		CGMEEventLogger::LogGMEEvent("Cancelled\r\n");
! 		return;
! 	}
! 	CGMEEventLogger::LogGMEEvent(dlg.GetPathName()+"\r\n");
  
! 	if (dlg.GetFileExt().CompareNoCase("xml") == 0 ) {
! 		AfxMessageBox(
! 				"Newer versions of GME use the \".xme.\" filename extension\n"
! 				"for exported XML data files.\n"
! 				"Please, rename your existing files to avoid further problems!\n", 
! 				MB_OK | MB_ICONINFORMATION);
! 	}
  
! 	bool newproject = !mgaProject;
! 	if (newproject) {
! 	  CString dataconn;
! 	  COMTRY {
! 		CComBstrObj paradigm, basename;
! 		CComVariant parguid;
  
! 	   COMTHROW( parser->GetXMLInfo(PutInBstr(dlg.GetPathName()), PutOut(paradigm),&parguid, PutOut(basename)) );
  
! 	   CMgaOpenDlg opdlg(CMgaOpenDlg::ImportDialog);
! 	   opdlg.filenamehint = basename;
! 	   dataconn = opdlg.AskConnectionString(false);
! 	   if (dataconn.IsEmpty()) {
! 		   return;
! 	   }
  
! 	   {
! 			CComPtr<IMgaRegistrar> reg;
! 			COMTHROW( reg.CoCreateInstance(L"Mga.MgaRegistrar") );
! 			CComBstrObj conn;
! 			HRESULT h1 = reg->QueryParadigm(paradigm, PutOut(conn), &parguid, REGACCESS_PRIORITY);
! 			CComVariant pg2;
! 			conn.Empty();
! 			HRESULT h2 = reg->QueryParadigm(paradigm, PutOut(conn), &pg2, REGACCESS_PRIORITY);
! 		    char buf[300];
! 			if(h2 != S_OK) {
! 				ASSERT(h1 != S_OK);
! 				CString msg = "Could not find paradigm paradigm '" + CString(paradigm) + "'\n" 
! 						" (Eg.: In GME3 the MetaGME2000 paradigm was renamed to MetaGME)\n"
! 						"Do you want to import with an other registered paradigm ?";
! 				if (AfxMessageBox(msg ,MB_OKCANCEL) == IDOK) {	
! 					CComObjPtr<IMgaLauncher> launcher;
! 					COMTHROW( launcher.CoCreateInstance(CComBSTR(L"Mga.MgaLauncher")) );
! 					if (SUCCEEDED(launcher->MetaDlg(METADLG_NONE))) {
! 						// parguid = true;
! 						parguid.Clear();
! 						paradigm.Empty();
! 						COMTHROW( launcher->get_ParadigmName(PutOut(paradigm)) );
! 					}
! 					else {
! 						return;   // safe before create
  					}
- 				}
- 				else {
- 					return;   // safe before create
- 				}
- 			}
- 			else {
- 				CComBstrObj parguid1, parguid2;
- 				GUID gg;
  
! 				CopyTo(parguid,gg);
! 				CopyTo(gg, parguid1);
  
! 				CopyTo(pg2,gg);
! 				CopyTo(gg, parguid2);
  
! 				if(h1 != S_OK) {
! 				    sprintf(buf, "Could not locate paradigm %s\nVersion ID: %s\n"
! 								 "Do you want to upgrade to the current version instead?\nCurrent ID: %s", 
! 								 PutInCString(paradigm), PutInCString(parguid1), PutInCString(parguid2));
! 								 if(AfxMessageBox(buf,MB_OKCANCEL | MB_ICONQUESTION) == IDOK) {
! 									parguid = pg2;
! 								 }
! 								 else {
! 									AfxMessageBox("Import canceled");
! 									return; // safe before create
! 								 }	
  
! 				}
! 				else if(parguid1.Compare(parguid2)) {
! 				    sprintf(buf, "This model was exported using paradigm %s\nVersion ID: %s\n"
! 								 "Do you want to upgrade to the current version?\nCurrent ID: %s", 
! 								 PutInCString(paradigm), PutInCString(parguid1), PutInCString(parguid2));
! 								 int answer = AfxMessageBox(buf,MB_YESNOCANCEL | MB_ICONQUESTION);
! 								 if(answer == IDYES) {
! 									parguid = pg2;
! 								 }
! 								 else if(answer == IDCANCEL) {
! 									AfxMessageBox("Import canceled");
! 									return;  // safe before create
! 								 }
! 				}
! 			}
! 	   }
! 	   COMTHROW( mgaProject.CoCreateInstance(L"Mga.MgaProject") );
  #pragma warning(disable: 4310) // cast truncates constant value
! 	   COMTHROW( mgaProject->EnableAutoAddOns(VARIANT_TRUE));
  #pragma warning(default: 4310) // cast truncates constant value
! 	   HRESULT hr = mgaProject->CreateEx(PutInBstr(dataconn), PutInBstr(paradigm), parguid);
! 	   if(hr == E_MGA_PARADIGM_NOTREG || hr == E_MGA_PARADIGM_INVALID) {
! 		    char buf[300];
! 			CComBstrObj parguid1;
! 			GUID gg;
! 			CopyTo(parguid,gg);
! 			CopyTo(gg, parguid1);
! 		    sprintf(buf, "Could not open paradigm %s\nVersion ID: %s", 
! 				PutInCString(paradigm), PutInCString(parguid1));
  
! 			AfxMessageBox(buf);
! 	   }
! 	   if(hr == E_MGA_COMPONENT_ERROR) {
! 			AfxMessageBox("ERROR: Some automatic addon components could not start up\n");
! 	   }
! 	   COMTHROW(hr);
! 	   AfterOpenOrCreateProject(dataconn); 
!        } catch(hresult_exception &e) {
!  		CloseProject();
!  		DisplayError("Could not create the project", e.hr); 
!  		throw;
!  	  }
  
! 	}
  
! 	UpdateProjectName();
  
!     CWaitCursor wait;
!     if(mgaConstMgr) COMTHROW(mgaConstMgr->Enable(false));
  
!     COMTHROW(parser->ParseProject(theApp.mgaProject,PutInBstr(dlg.GetPathName())) );
  
!  	if(newproject && proj_type_is_mga) {
! 		OnFileSave();
! 	}
!     AfxMessageBox("The XML file was successfully imported.");
!  }
!  MSGCATCH("Error importing XML file",;)
  
!  if (mgaConstMgr) COMTHROW(mgaConstMgr->Enable(true));
  }
  
--- 1490,1685 ----
  void CGMEApp::OnFileImportxml() 
  {
  	CGMEEventLogger::LogGMEEvent("CGMEApp::OnFileImportxml ");
  
! 	bool keep_on( true); // if true then keep working even after a failed import: try to apply an xslt script
! 	CString file_name;
! 	CString new_file_name = "";
! 
! 	while (keep_on)
  	{
! 		keep_on = false;
! 		MSGTRY
! 		{
! 			CComPtr<IMgaParser> parser;
! 			COMTHROW( parser.CoCreateInstance(L"Mga.MgaParser") );
! 			ASSERT( parser != NULL );
  
! 			CFileDialog dlg(TRUE, "xme", (LPCTSTR) new_file_name,
! 				OFN_EXPLORER | OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT |
! 				OFN_FILEMUSTEXIST,
! 				"GME Exported Files (*.xme;*.xml)|*.xme; *.xml|All Files (*.*)|*.*||");
! 			if( dlg.DoModal() != IDOK )
! 			{
! 				CGMEEventLogger::LogGMEEvent("Cancelled\r\n");
! 				return;
! 			}
! 			CGMEEventLogger::LogGMEEvent(dlg.GetPathName()+"\r\n");
  
! 			if (dlg.GetFileExt().CompareNoCase("xml") == 0 ) {
! 				AfxMessageBox(
! 						"Newer versions of GME use the \".xme.\" filename extension\n"
! 						"for exported XML data files.\n"
! 						"Please, rename your existing files to avoid further problems!\n", 
! 						MB_OK | MB_ICONINFORMATION);
! 			}
  
! 			bool newproject = !mgaProject;
! 			if (newproject) {
! 				CString dataconn;
! 				COMTRY {
! 					CComBstrObj paradigm, basename;
! 					CComVariant parguid;
  
! 					COMTHROW( parser->GetXMLInfo(PutInBstr(dlg.GetPathName()), PutOut(paradigm),&parguid, PutOut(basename)) );
  
! 					CMgaOpenDlg opdlg(CMgaOpenDlg::ImportDialog);
! 					opdlg.filenamehint = basename;
! 					dataconn = opdlg.AskConnectionString(false);
! 					if (dataconn.IsEmpty()) {
! 					   return;
  					}
  
! 					{
! 						CComPtr<IMgaRegistrar> reg;
! 						COMTHROW( reg.CoCreateInstance(L"Mga.MgaRegistrar") );
! 						CComBstrObj conn;
! 						HRESULT h1 = reg->QueryParadigm(paradigm, PutOut(conn), &parguid, REGACCESS_PRIORITY);
! 						CComVariant pg2;
! 						conn.Empty();
! 						HRESULT h2 = reg->QueryParadigm(paradigm, PutOut(conn), &pg2, REGACCESS_PRIORITY);
! 						char buf[300];
! 						if(h2 != S_OK) {
! 							ASSERT(h1 != S_OK);
! 							CString msg = "Could not find paradigm paradigm '" + CString(paradigm) + "'\n" 
! 									" (Eg.: In GME3 the MetaGME2000 paradigm was renamed to MetaGME)\n"
! 									"Do you want to import with an other registered paradigm ?";
! 							if (AfxMessageBox(msg ,MB_OKCANCEL) == IDOK) {	
! 								CComObjPtr<IMgaLauncher> launcher;
! 								COMTHROW( launcher.CoCreateInstance(CComBSTR(L"Mga.MgaLauncher")) );
! 								if (SUCCEEDED(launcher->MetaDlg(METADLG_NONE))) {
! 									// parguid = true;
! 									parguid.Clear();
! 									paradigm.Empty();
! 									COMTHROW( launcher->get_ParadigmName(PutOut(paradigm)) );
! 								}
! 								else {
! 									return;   // safe before create
! 								}
! 							}
! 							else {
! 								return;   // safe before create
! 							}
! 						}
! 						else {
! 							CComBstrObj parguid1, parguid2;
! 							GUID gg;
  
! 							CopyTo(parguid,gg);
! 							CopyTo(gg, parguid1);
  
! 							CopyTo(pg2,gg);
! 							CopyTo(gg, parguid2);
  
! 							if(h1 != S_OK) {
! 								sprintf(buf, "Could not locate paradigm %s\nVersion ID: %s\n"
! 											 "Do you want to upgrade to the current version instead?\nCurrent ID: %s", 
! 											 PutInCString(paradigm), PutInCString(parguid1), PutInCString(parguid2));
! 											 if(AfxMessageBox(buf,MB_OKCANCEL | MB_ICONQUESTION) == IDOK) {
! 												parguid = pg2;
! 											 }
! 											 else {
! 												AfxMessageBox("Import canceled");
! 												return; // safe before create
! 											 }	
! 
! 							}
! 							else if(parguid1.Compare(parguid2)) {
! 								sprintf(buf, "This model was exported using paradigm %s\nVersion ID: %s\n"
! 											 "Do you want to upgrade to the current version?\nCurrent ID: %s", 
! 											 PutInCString(paradigm), PutInCString(parguid1), PutInCString(parguid2));
! 											 int answer = AfxMessageBox(buf,MB_YESNOCANCEL | MB_ICONQUESTION);
! 											 if(answer == IDYES) {
! 												parguid = pg2;
! 											 }
! 											 else if(answer == IDCANCEL) {
! 												AfxMessageBox("Import canceled");
! 												return;  // safe before create
! 											 }
! 							}
! 						}
! 					}
! 					COMTHROW( mgaProject.CoCreateInstance(L"Mga.MgaProject") );
  #pragma warning(disable: 4310) // cast truncates constant value
! 					COMTHROW( mgaProject->EnableAutoAddOns(VARIANT_TRUE));
  #pragma warning(default: 4310) // cast truncates constant value
! 					HRESULT hr = mgaProject->CreateEx(PutInBstr(dataconn), PutInBstr(paradigm), parguid);
! 					if(hr == E_MGA_PARADIGM_NOTREG || hr == E_MGA_PARADIGM_INVALID) {
! 						char buf[300];
! 						CComBstrObj parguid1;
! 						GUID gg;
! 						CopyTo(parguid,gg);
! 						CopyTo(gg, parguid1);
! 						sprintf(buf, "Could not open paradigm %s\nVersion ID: %s", 
! 							PutInCString(paradigm), PutInCString(parguid1));
  
! 						AfxMessageBox(buf);
! 					}
! 					if(hr == E_MGA_COMPONENT_ERROR) {
! 						AfxMessageBox("ERROR: Some automatic addon components could not start up\n");
! 					}
! 					COMTHROW(hr);
! 					AfterOpenOrCreateProject(dataconn); 
! 				} catch(hresult_exception &e) {
! 					CloseProject();
! 					DisplayError("Could not create the project", e.hr); 
! 					throw;
! 				}
! 			}
  
! 			UpdateProjectName();
  
! 			CWaitCursor wait;
! 			if(mgaConstMgr) COMTHROW(mgaConstMgr->Enable(false));
  
! 			keep_on = true;
! 			file_name = dlg.GetPathName();
! 			COMTHROW(parser->ParseProject(theApp.mgaProject,PutInBstr(dlg.GetPathName())) );
  
! 			if(newproject && proj_type_is_mga) {
! 				OnFileSave();
! 			}
! 			AfxMessageBox("The XML file was successfully imported.");
! 			keep_on = false;
! 		}
! 		MSGCATCH("Error importing XML file",;)
  
! 		if ( keep_on)
! 		{
! 			keep_on = false;
! 			if( 0) {
! 			int answer = AfxMessageBox("Do you want to apply an XSLT script on the .xme file?",MB_YESNO | MB_ICONQUESTION);
! 			if( answer == IDYES) 
! 			{
! 				MSGTRY
! 				{
! 					CComObjPtr<IMgaXsltFileSel> xslt;
! 					COMTHROW( xslt.CoCreateInstance( L"Mga.MgaXsltFileSel"));
! 					ASSERT( xslt != NULL );
  
! 					CComBstrObj result;
! 					HRESULT hr = xslt->StartXslt( PutInBstr( file_name.GetBuffer( file_name.GetLength())), PutOut(result));
! 					if ( hr == S_OK)
! 					{
! 						CopyTo( result, new_file_name);
! 						keep_on = true;
! 					}
! 				} 
! 				MSGCATCH("Error during XSLT transformation",;)
! 			}
! 			}
! 		}
! 	} // while keep_on
! 
! 	if (mgaConstMgr) COMTHROW(mgaConstMgr->Enable(true));
  }
  



More information about the GME-commit mailing list