[GME-commit]
GMESRC/GME/Gme GMEApp.cpp,1.131,1.132 GMEApp.h,1.28,1.29
MainFrm.cpp,1.30,1.31 MainFrm.h,1.23,1.24
gme-commit at list.isis.vanderbilt.edu
gme-commit at list.isis.vanderbilt.edu
Mon Jul 11 18:42:22 CDT 2005
- Previous message: [GME-commit] GMESRC/GME/Gme GMEDoc.cpp,1.27,1.28
- Next message: [GME-commit]
GMESRC/GME/ConstraintManager ConstraintManager.vcproj,1.1,1.2
OCLCommon.h,1.6,1.7 OCLConfig.h,1.2,1.3 OCLContext.h,1.6,1.7
OCLException.h,1.9,1.10 OCLFactory.h,1.3,1.4 OCLFeature.cpp,1.2,1.3
OCLFeature.h,1.4,1.5 OCLFeatureImplementation.h,1.7,1.8
OCLFormalParameter.h,1.2,1.3 OCLObject.cpp,1.8,1.9
OCLObject.h,1.5,1.6 OCLRefCount.h,1.2,1.3 OCLTree.cpp,1.32,1.33
OCLTree.h,1.16,1.17 OCLType.cpp,1.8,1.9 OCLType.h,1.4,1.5
OclConstraint.cpp,1.9,1.10 OclViolation.h,1.4,1.5 ocl.g,1.16,1.17
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /project/gme-repository/GMESRC/GME/Gme
In directory escher:/tmp/cvs-serv27486
Modified Files:
GMEApp.cpp GMEApp.h MainFrm.cpp MainFrm.h
Log Message:
Enabling file drag and drop.
Mga file can be dropped if project not open.
XME files can be dropped anytime.
CVS User: Zoltan Molnar, ISIS (zolmol)
Index: GMEApp.h
===================================================================
RCS file: /project/gme-repository/GMESRC/GME/Gme/GMEApp.h,v
retrieving revision 1.28
retrieving revision 1.29
diff -C2 -d -r1.28 -r1.29
*** GMEApp.h 21 Jun 2005 19:47:54 -0000 1.28
--- GMEApp.h 11 Jul 2005 17:42:19 -0000 1.29
***************
*** 79,82 ****
--- 79,83 ----
public:
+ void ImportDroppedFile(const CString& fname);
bool SafeCloseProject();
void CloseProject(bool updateStatusBar = true);
Index: GMEApp.cpp
===================================================================
RCS file: /project/gme-repository/GMESRC/GME/Gme/GMEApp.cpp,v
retrieving revision 1.131
retrieving revision 1.132
diff -C2 -d -r1.131 -r1.132
*** GMEApp.cpp 24 Jun 2005 17:58:01 -0000 1.131
--- GMEApp.cpp 11 Jul 2005 17:42:19 -0000 1.132
***************
*** 349,352 ****
--- 349,353 ----
GetSettings();
+ m_pMainWnd->DragAcceptFiles();
return TRUE;
***************
*** 2270,2272 ****
--- 2271,2452 ----
setup.m_pd.lpSetupTemplateName = MAKEINTRESOURCE(PRNSETUPDLGORD);
DoPrintDialog(&setup);
+ }
+
+ void CGMEApp::ImportDroppedFile( const CString& fname)
+ {
+ CGMEEventLogger::LogGMEEvent("CGMEApp::ImportFile ");
+
+ bool keep_on( true); // if true then keep working even after a failed import: try to apply an xslt script
+ CString file_name = fname;
+
+ while (keep_on)
+ {
+ keep_on = false;
+ MSGTRY
+ {
+ CComPtr<IMgaParser> parser;
+ COMTHROW( parser.CoCreateInstance(L"Mga.MgaParser") );
+ ASSERT( parser != NULL );
+
+ bool newproject = !mgaProject;
+ if (newproject) {
+ CString dataconn;
+ COMTRY {
+ CComBstrObj paradigm, parversion, basename, version;
+ CComVariant parguid;
+
+ COMTHROW( parser->GetXMLInfo(PutInBstr(file_name), PutOut(paradigm), PutOut(parversion), &parguid, PutOut(basename), PutOut(version)) );
+
+ CMgaOpenDlg opdlg(CMgaOpenDlg::ImportDialog);
+ opdlg.SetFileNameHint( PutInCString( basename));//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;
+ COMTHROW(parser->ParseProject(theApp.mgaProject,PutInBstr(file_name)) );
+
+ if(newproject && (proj_type_is_mga||proj_type_is_xmlbackend)) {
+ OnFileSave();
+ }
+ CMainFrame *p = (CMainFrame *) this->m_pMainWnd;
+ if(p) p->m_console.Message( file_name + " was successfully imported.", 1);
+ else AfxMessageBox(file_name + " was successfully imported.");
+ keep_on = false;
+ }
+ MSGCATCH("Error importing XML file",;)
+
+ if ( keep_on)
+ {
+ keep_on = false;
+ int answer = AfxMessageBox("Do you want to apply an XSLT script on the .xme file?",MB_YESNO | MB_ICONQUESTION);
+ if( answer == IDYES)
+ {
+ try
+ {
+ 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, file_name);
+ AfxMessageBox("Continuing to Import XML...");
+ keep_on = true;
+ }
+ }
+ catch( ...)
+ {
+ keep_on = false;
+ }
+ }
+ }
+ } // while keep_on
+
+ if (mgaConstMgr) COMTHROW(mgaConstMgr->Enable(true));
}
Index: MainFrm.cpp
===================================================================
RCS file: /project/gme-repository/GMESRC/GME/Gme/MainFrm.cpp,v
retrieving revision 1.30
retrieving revision 1.31
diff -C2 -d -r1.30 -r1.31
*** MainFrm.cpp 15 Apr 2005 20:02:08 -0000 1.30
--- MainFrm.cpp 11 Jul 2005 17:42:19 -0000 1.31
***************
*** 9,12 ****
--- 9,13 ----
#include "GMEDoc.h"
#include "Splash.h"
+ #include "GMEEventLogger.h"
#ifdef _DEBUG
***************
*** 79,82 ****
--- 80,84 ----
ON_UPDATE_COMMAND_UI(ID_VIEW_REFRESH_SOURCECONTROL, OnUpdateViewRefreshSourcecontrol)
ON_WM_CLOSE()
+ ON_WM_DROPFILES()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
***************
*** 176,180 ****
}
m_wndToolBar.SetBarStyle(m_wndToolBar.GetBarStyle() | CBRS_TOOLTIPS | CBRS_FLYBY);
-
if(!m_wndComponentBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_ALIGN_TOP, CRect(0, 0, 0, 0), AFX_IDW_CONTROLBAR_LAST - 1) ||
--- 178,181 ----
***************
*** 286,290 ****
m_pFloatingFrameClass = RUNTIME_CLASS(CSCBMiniDockFrameWnd);
! DockControlBar(&m_browser, AFX_IDW_DOCKBAR_RIGHT);
// terge
--- 287,291 ----
m_pFloatingFrameClass = RUNTIME_CLASS(CSCBMiniDockFrameWnd);
! DockControlBar(&m_browser, AFX_IDW_DOCKBAR_RIGHT);
// terge
***************
*** 829,831 ****
--- 830,880 ----
{
pCmdUI->Enable(CGMEDoc::theInstance != 0);
+ }
+
+ void CMainFrame::OnDropFiles(HDROP p_hDropInfo)
+ {
+ CGMEEventLogger::LogGMEEvent("MainFrame:OnDropFiles\r\n");
+
+ // get the number of files dropped
+ UINT nFiles = DragQueryFile( p_hDropInfo, 0xFFFFFFFF, NULL, 0);
+ if( nFiles < 1)
+ {
+ CGMEEventLogger::LogGMEEvent("Can't inquire file information!\r\n");
+ m_console.Message( "No file dropped or can't inquire file information!", 3);
+ }
+
+ bool one_just_opened = false; // we opened/imported one project just now -> disables opening of more .mga files
+ for( UINT iF = 0; iF < nFiles; ++iF)
+ {
+ TCHAR szFileName[_MAX_PATH];
+ UINT res = DragQueryFile( p_hDropInfo, iF, szFileName, _MAX_PATH);
+ if (res > 0)
+ {
+ CString conn( szFileName);
+ if( conn.Right(4).CompareNoCase(".mga") == 0)
+ {
+ if( one_just_opened)
+ m_console.Message( "Project already open. No other MGA file can be dropped!", 3);
+ else if( theApp.guiMetaProject == NULL && theApp.mgaProject == 0)
+ {
+ m_console.Message( "Opening " + conn + ".", 1);
+ conn = "MGA=" + conn;
+ theApp.OpenProject(conn);
+ one_just_opened = true;
+ }
+ else
+ m_console.Message( "Another MGA file can't be opened while a project is open.", 3);
+ }
+ else if( conn.Right(4).CompareNoCase(".xme")==0)
+ {
+ m_console.Message( "Importing " + conn + ".", 1);
+ theApp.ImportDroppedFile(conn);
+ one_just_opened = true;
+ }
+ else
+ m_console.Message( "Can't read file: " + conn + "!", 3);
+ }
+ else
+ m_console.Message( "Can't inquire file information!", 3);
+ }
}
Index: MainFrm.h
===================================================================
RCS file: /project/gme-repository/GMESRC/GME/Gme/MainFrm.h,v
retrieving revision 1.23
retrieving revision 1.24
diff -C2 -d -r1.23 -r1.24
*** MainFrm.h 15 Apr 2005 18:24:10 -0000 1.23
--- MainFrm.h 11 Jul 2005 17:42:19 -0000 1.24
***************
*** 127,130 ****
--- 127,131 ----
afx_msg void OnUpdateViewRefreshSourcecontrol(CCmdUI* pCmdUI);
afx_msg void CMainFrame::OnClose();
+ afx_msg void OnDropFiles(HDROP);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
- Previous message: [GME-commit] GMESRC/GME/Gme GMEDoc.cpp,1.27,1.28
- Next message: [GME-commit]
GMESRC/GME/ConstraintManager ConstraintManager.vcproj,1.1,1.2
OCLCommon.h,1.6,1.7 OCLConfig.h,1.2,1.3 OCLContext.h,1.6,1.7
OCLException.h,1.9,1.10 OCLFactory.h,1.3,1.4 OCLFeature.cpp,1.2,1.3
OCLFeature.h,1.4,1.5 OCLFeatureImplementation.h,1.7,1.8
OCLFormalParameter.h,1.2,1.3 OCLObject.cpp,1.8,1.9
OCLObject.h,1.5,1.6 OCLRefCount.h,1.2,1.3 OCLTree.cpp,1.32,1.33
OCLTree.h,1.16,1.17 OCLType.cpp,1.8,1.9 OCLType.h,1.4,1.5
OclConstraint.cpp,1.9,1.10 OclViolation.h,1.4,1.5 ocl.g,1.16,1.17
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the GME-commit
mailing list