[commit] r1169 - trunk/GME/Gme
GMESRC Repository Notifications
gme-commit at list.isis.vanderbilt.edu
Thu Feb 10 10:12:08 CST 2011
Author: ksmyth
Date: Thu Feb 10 10:12:07 2011
New Revision: 1169
Log:
Accept .xme files on File>Open. Still asks you to create an mga
Modified:
trunk/GME/Gme/GMEApp.cpp
trunk/GME/Gme/GMEApp.h
trunk/GME/Gme/MgaOpenDlg.cpp
trunk/GME/Gme/MgaOpenDlg.h
Modified: trunk/GME/Gme/GMEApp.cpp
==============================================================================
--- trunk/GME/Gme/GMEApp.cpp Wed Feb 9 16:48:09 2011 (r1168)
+++ trunk/GME/Gme/GMEApp.cpp Thu Feb 10 10:12:07 2011 (r1169)
@@ -1687,7 +1687,7 @@
void CGMEApp::OnFileOpen()
{
CMgaOpenDlg dlg(CMgaOpenDlg::OpenDialog);
- CString conn = dlg.AskConnectionString(false);
+ CString conn = dlg.AskConnectionString(true);
CGMEEventLogger::LogGMEEvent("CGMEApp::OnFileOpen "+conn+"\r\n");
@@ -1699,7 +1699,24 @@
if( mgaProject != NULL )
CloseProject();
- OpenProject(conn);
+ if (conn.Left(4) == "XML=") {
+ //wer
+ MSGTRY {
+ CString fullPath = conn.Right(conn.GetLength() - 4);
+ TCHAR buffer[MAX_PATH];
+ TCHAR* filepart = NULL;
+ GetFullPathName(fullPath, MAX_PATH, buffer, &filepart);
+ if (filepart == NULL) {
+ COMTHROW(E_FILEOPEN);
+ }
+ CString fname = conn.Right(conn.ReverseFind('\\'));
+ CString filename = filepart;
+ CString title = filename.Left(filename.ReverseFind('.'));
+ Importxml(fullPath, filepart, title);
+ } MSGCATCH("Error opening XML file",;)
+ } else {
+ OpenProject(conn);
+ }
}
@@ -1901,7 +1918,7 @@
if (!GetFullPathName(zsConn, MAX_PATH, currentMgaPath, &filename) || filename == 0) {
} else {
initialFile = filename;
- if (initialFile.Left(3) == "mga") {
+ if (initialFile.Right(3) == "mga") {
initialFile.Truncate(initialFile.GetLength() - 3);
initialFile += "xme";
}
@@ -1938,15 +1955,10 @@
{
CGMEEventLogger::LogGMEEvent("CGMEApp::OnFileImportxml ");
- CString file_name;
CString new_file_name = "";
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,
@@ -1959,10 +1971,21 @@
CGMEEventLogger::LogGMEEvent(dlg.GetPathName()+"\r\n");
CString fullPath = dlg.GetPathName();
CString fname = dlg.GetFileName();
- CString folderPath = fullPath.Left(fullPath.GetLength() - fname.GetLength());
CString ftitle = dlg.GetFileTitle();
+ Importxml(fullPath, fname, ftitle);
+ }
+ MSGCATCH("Error importing XML file",;)
+}
+
+void CGMEApp::Importxml(CString fullPath, CString fname, CString ftitle)
+{
+ CComPtr<IMgaParser> parser;
+ COMTHROW( parser.CoCreateInstance(L"Mga.MgaParser") );
+ ASSERT( parser != NULL );
- if (dlg.GetFileExt().CompareNoCase("xml") == 0 ) {
+ CString folderPath = fullPath.Left(fullPath.GetLength() - fname.GetLength());
+
+ if (fullPath.Right(3).CompareNoCase("xml") == 0 ) {
AfxMessageBox(
"Newer versions of GME use the \".xme.\" filename extension\n"
"for exported XML data files.\n"
@@ -1977,7 +2000,7 @@
CComBstrObj paradigm, parversion, basename, version;
CComVariant parguid;
- COMTHROW( parser->GetXMLInfo(PutInBstr(dlg.GetPathName()), PutOut(paradigm), PutOut(parversion), &parguid, PutOut(basename), PutOut(version)) );
+ COMTHROW( parser->GetXMLInfo(PutInBstr(fullPath), PutOut(paradigm), PutOut(parversion), &parguid, PutOut(basename), PutOut(version)) );
CMgaOpenDlg opdlg(CMgaOpenDlg::ImportDialog);
if (ftitle.IsEmpty())
@@ -2097,9 +2120,9 @@
CWaitCursor wait;
if(mgaConstMgr) COMTHROW(mgaConstMgr->Enable(false));
- file_name = dlg.GetPathName();
+ CString file_name = fullPath;
if( CMainFrame::theInstance) CMainFrame::theInstance->m_console.Message( CString( "Importing ") + file_name + "...", 1);
- COMTHROW(parser->ParseProject(theApp.mgaProject,PutInBstr(dlg.GetPathName())) );
+ COMTHROW(parser->ParseProject(theApp.mgaProject,PutInBstr(fullPath)) );
// mgaproject has been filled with data, let's update title:
UpdateProjectName();
@@ -2108,10 +2131,8 @@
OnFileSave();
}
- if( CMainFrame::theInstance) CMainFrame::theInstance->m_console.Message( dlg.GetPathName() + " was successfully imported.", 1);
- else AfxMessageBox(dlg.GetPathName() + " was successfully imported.");
- }
- MSGCATCH("Error importing XML file",;)
+ if( CMainFrame::theInstance) CMainFrame::theInstance->m_console.Message( fullPath + " was successfully imported.", 1);
+ else AfxMessageBox(fullPath + " was successfully imported.");
if (mgaConstMgr) COMTHROW(mgaConstMgr->Enable(true));
}
Modified: trunk/GME/Gme/GMEApp.h
==============================================================================
--- trunk/GME/Gme/GMEApp.h Wed Feb 9 16:48:09 2011 (r1168)
+++ trunk/GME/Gme/GMEApp.h Thu Feb 10 10:12:07 2011 (r1169)
@@ -139,6 +139,7 @@
bool SafeCloseProject();
void CloseProject(bool updateStatusBar = true);
void OpenProject(const CString &conn);
+ void Importxml(CString fullPath, CString fname, CString ftitle);
void SaveProject(const CString &conn);
void CreateProject(const CString &metaname, const CString &dataconn);
void UpdateProjectName(bool retrievePath = false);
Modified: trunk/GME/Gme/MgaOpenDlg.cpp
==============================================================================
--- trunk/GME/Gme/MgaOpenDlg.cpp Wed Feb 9 16:48:09 2011 (r1168)
+++ trunk/GME/Gme/MgaOpenDlg.cpp Thu Feb 10 10:12:07 2011 (r1169)
@@ -87,6 +87,9 @@
static char mgafilter[] = "MGA Files (*.mga)|*.mga|Exported Files (*.xme;*.xml)|*.xme; *.xml|"
"Microsoft Access Files (*.mdb)|*.mdb|All files (*.*)|*.*||";
+static char xmemgafilter[] = "GME Model Files(*.mga;*.xme)|*.mga; *.xme|MGA Files (*.mga)|*.mga|Exported Files (*.xme;*.xml)|*.xme; *.xml|"
+ "Microsoft Access Files (*.mdb)|*.mdb|All files (*.*)|*.*||";
+
/*static char mgafilter[] = "MGA Files (*.mga)|*.mga|Exported Files (*.xme;*.xml)|*.xme; *.xml|"
"Microsoft Access Files (*.mdb)|*.mdb||";*/
@@ -153,7 +156,7 @@
return conn;
}
-CString CMgaOpenDlg::AskConnectionString(bool meta)
+CString CMgaOpenDlg::AskConnectionString(bool allowXme)
{
CString conn;
@@ -182,7 +185,7 @@
{
CFileDialog dlg(true, NULL, fileNameHint.IsEmpty() ? NULL : (LPCSTR)fileNameHint,
OFN_EXPLORER | OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT |
- (flag_create ? 0 : OFN_FILEMUSTEXIST), meta ? metafilter : mgafilter);
+ (flag_create ? 0 : OFN_FILEMUSTEXIST), allowXme ? xmemgafilter : mgafilter);
if (!folderPathHint.IsEmpty())
dlg.m_ofn.lpstrInitialDir = folderPathHint.GetBuffer(_MAX_PATH);
@@ -205,11 +208,11 @@
{
case 4:
case 1:
- conn = CString("MGA=") + dlg.GetPathName() + (meta ? ".mta" : ".mga");
+ conn = CString("MGA=") + dlg.GetPathName() + ".mga";
break;
case 2:
- conn = CString("XML=") + dlg.GetPathName() + (meta ? ".xmp" : ".xme");
+ conn = CString("XML=") + dlg.GetPathName() + ".xme";
break;
case 3:
Modified: trunk/GME/Gme/MgaOpenDlg.h
==============================================================================
--- trunk/GME/Gme/MgaOpenDlg.h Wed Feb 9 16:48:09 2011 (r1168)
+++ trunk/GME/Gme/MgaOpenDlg.h Thu Feb 10 10:12:07 2011 (r1169)
@@ -31,7 +31,7 @@
bool pressed_back;
- CString AskConnectionString(bool meta);
+ CString AskConnectionString(bool allowXme);
CString AskMGAConnectionString(const CString& spec_ext = "");
private:
CString PruneConnectionString(const CString& conn);
More information about the gme-commit
mailing list