GME  13
ProjectPropertiesDlg.cpp
Go to the documentation of this file.
00001 // ProjectPropertiesDlg.cpp : implementation file
00002 //
00003 
00004 #include "stdafx.h"
00005 #include "GMEApp.h"
00006 #include "GMEstd.h"
00007 #include "ProjectPropertiesDlg.h"
00008 #include "ParadigmPropertiesDlg.h"
00009 
00010 #ifdef _DEBUG
00011 #define new DEBUG_NEW
00012 #undef THIS_FILE
00013 static char THIS_FILE[] = __FILE__;
00014 #endif
00015 
00017 // CProjectPropertiesDlg dialog
00018 
00019 
00020 CProjectPropertiesDlg::CProjectPropertiesDlg(CWnd* pParent /*=NULL*/)
00021         : CDialog(CProjectPropertiesDlg::IDD, pParent)
00022 {
00023         //{{AFX_DATA_INIT(CProjectPropertiesDlg)
00024         //}}AFX_DATA_INIT
00025 }
00026 
00027 
00028 void CProjectPropertiesDlg::DoDataExchange(CDataExchange* pDX)
00029 {
00030         CDialog::DoDataExchange(pDX);
00031         //{{AFX_DATA_MAP(CProjectPropertiesDlg)
00032         DDX_Control(pDX, IDC_PROJECT_GUID, guid);
00033         DDX_Control(pDX, IDC_PROJECT_VERSION, version);
00034         DDX_Control(pDX, IDC_PROJECT_PARVERSION, m_parversion);
00035         DDX_Control(pDX, IDC_PROJECT_PARGUID, m_parguid);
00036         DDX_Control(pDX, IDC_PROJECT_PARADIGM, m_parname);
00037         DDX_Control(pDX, IDC_PROJECT_MODIFIED, modified);
00038         DDX_Control(pDX, IDC_PROJECT_CREATED, created);
00039         DDX_Control(pDX, IDC_PROJECT_COMMENT, comment);
00040         DDX_Control(pDX, IDC_PROJECT_AUTHOR, author);
00041         DDX_Control(pDX, IDC_PROJECT_NAME, name);
00042         DDX_Control(pDX, IDC_PROJECT_CONNECTION, conn);
00043         //}}AFX_DATA_MAP
00044 }
00045 
00046 
00047 BEGIN_MESSAGE_MAP(CProjectPropertiesDlg, CDialog)
00048         //{{AFX_MSG_MAP(CProjectPropertiesDlg)
00049         ON_BN_CLICKED(IDC_BUTTON_PARADIGM, OnButtonParadigm)
00050         //}}AFX_MSG_MAP
00051 END_MESSAGE_MAP()
00052 
00054 // CProjectPropertiesDlg message handlers
00055 
00056 void CProjectPropertiesDlg::OnOK() 
00057 {
00058         CComObjPtr<IMgaTerritory> terry;
00059         COMTHROW( theApp.mgaProject->CreateTerritory(NULL, PutOut(terry), NULL) );
00060         try {
00061                 COMTHROW(theApp.mgaProject->BeginTransaction(terry,TRANSACTION_GENERAL));
00062                 {
00063                         CComBSTR bstr;
00064                         CString str;
00065                         name.GetWindowText(str);
00066                         CopyTo(str,bstr);
00067                         COMTHROW(theApp.mgaProject->put_Name(bstr));
00068                         CComPtr<IMgaFolder>     rootFolder;
00069                         COMTHROW(theApp.mgaProject->get_RootFolder(&rootFolder));
00070                         COMTHROW(rootFolder->put_Name(bstr));
00071                         theApp.projectName = str;
00072                 }
00073                 {
00074                         CComBSTR bstr;
00075                         CString str;
00076                         author.GetWindowText(str);
00077                         CopyTo(str,bstr);
00078                         COMTHROW(theApp.mgaProject->put_Author(bstr));
00079                 }
00080                 {
00081                         CComBSTR bstr;
00082                         CString str;
00083                         comment.GetWindowText(str);
00084                         str.Replace(_T("\r\n"),_T("\n"));
00085                         CopyTo(str,bstr);
00086                         COMTHROW(theApp.mgaProject->put_Comment(bstr));
00087                 }
00088                 {
00089                         CComBSTR bstr;
00090                         CString str;
00091                         version.GetWindowText(str);
00092                         CopyTo(str,bstr);
00093                         COMTHROW(theApp.mgaProject->put_Version(bstr));
00094                 }
00095                 COMTHROW(theApp.mgaProject->CommitTransaction());
00096         }
00097         catch(hresult_exception e) {
00098                 theApp.mgaProject->AbortTransaction();
00099                 AfxMessageBox(_T("Error writing project properties"));
00100         }
00101         CDialog::OnOK();
00102 }
00103 
00104 BOOL CProjectPropertiesDlg::OnInitDialog() 
00105 {
00106         CDialog::OnInitDialog();
00107 
00108         CComObjPtr<IMgaTerritory> terry;
00109         try {
00110                 COMTHROW( theApp.mgaProject->CreateTerritory(NULL, PutOut(terry), NULL) );
00111                 theApp.mgaProject->BeginTransaction(terry,TRANSACTION_READ_ONLY);
00112                 {
00113                         CComBSTR bstr;
00114                         COMTHROW(theApp.mgaProject->get_Name(&bstr));
00115                         CString str;
00116                         CopyTo(bstr,str);
00117                         name.SetWindowText(str);
00118                 }
00119                 {
00120                         CComBSTR bstr;
00121                         COMTHROW(theApp.mgaProject->get_ProjectConnStr(&bstr));
00122                         CString str;
00123                         CopyTo(bstr,str);
00124                         conn.SetWindowText(str.Mid(4));
00125                 }
00126                 {
00127                         CComBSTR bstr;
00128                         COMTHROW(theApp.mgaProject->get_Author(&bstr));
00129                         CString str;
00130                         CopyTo(bstr,str);
00131                         author.SetWindowText(str);
00132                 }
00133                 {
00134                         CComBSTR bstr;
00135                         COMTHROW(theApp.mgaProject->get_Version(&bstr));
00136                         CString str;
00137                         CopyTo(bstr,str);
00138                         version.SetWindowText(str);
00139                 }
00140                 {
00141                         CComBSTR bstr;
00142                         COMTHROW(theApp.mgaProject->get_CreateTime(&bstr));
00143                         CString str;
00144                         CopyTo(bstr,str);
00145                         created.SetWindowText(str);
00146                 }
00147                 {
00148                         CComBSTR bstr;
00149                         COMTHROW(theApp.mgaProject->get_ChangeTime(&bstr));
00150                         CString str;
00151                         CopyTo(bstr,str);
00152                         modified.SetWindowText(str);
00153                 }
00154                 {
00155                         CComBSTR bstr;
00156                         COMTHROW(theApp.mgaProject->get_Comment(&bstr));
00157                         CString str;
00158                         CopyTo(bstr,str);
00159                         str.Replace(_T("\n"), _T("\r\n"));
00160                         comment.SetWindowText(str);
00161                 }
00162                 {
00163                         CComVariant vguid;
00164                         COMTHROW(theApp.mgaProject->get_GUID(&vguid));
00165                         GUID guid1;
00166                         CopyTo(vguid, guid1);
00167                         CComBstrObj bstro;
00168                         CopyTo(guid1, bstro);
00169                         CString str;
00170                         CopyTo(bstro, str);
00171 
00172                         guid.SetWindowText(str);
00173                 }
00174                 {
00175                         CComBSTR bstr;
00176                         COMTHROW(theApp.mgaProject->get_MetaName(&bstr));
00177                         CString str;
00178                         CopyTo(bstr,str);
00179                         m_parname.SetWindowText(str);
00180                 }
00181                 {
00182                         CComBSTR bstr;
00183                         COMTHROW(theApp.mgaProject->get_MetaVersion(&bstr));
00184                         CString str;
00185                         CopyTo(bstr,str);
00186                         m_parversion.SetWindowText(str);
00187                 }
00188                 {
00189                         CComVariant guid;
00190                         COMTHROW(theApp.mgaProject->get_MetaGUID(&guid));
00191                         GUID guid1;
00192                         CopyTo(guid, guid1);
00193                         CComBstrObj bstro;
00194                         CopyTo(guid1, bstro);
00195                         CString str;
00196                         CopyTo(bstro, str);
00197 
00198                         m_parguid.SetWindowText(str);
00199                 }
00200 
00201 
00202                 theApp.mgaProject->CommitTransaction();
00203         }
00204         catch(hresult_exception e) {
00205                 theApp.mgaProject->AbortTransaction();
00206                 AfxMessageBox(_T("Error reading project properties"));
00207         }
00208         
00209         return TRUE;  // return TRUE unless you set the focus to a control
00210                       // EXCEPTION: OCX Property Pages should return FALSE
00211 }
00212 
00213 void CProjectPropertiesDlg::OnButtonParadigm() 
00214 {
00215         CParadigmPropertiesDlg dlg;
00216         dlg.DoModal();
00217 }
00218 
00219 BOOL CProjectPropertiesDlg::PreTranslateMessage(MSG* pMsg)
00220 {
00221         if (pMsg->message == WM_KEYDOWN)
00222         {
00223                 switch (pMsg->wParam)
00224                 {
00225                 case 'A':
00226                         {
00227                                 if (GetKeyState(VK_CONTROL) & 0x8000)
00228                                 {
00229                                         CWnd* focus = GetFocus();
00230                                         if (focus && focus->IsKindOf(RUNTIME_CLASS(CEdit)))
00231                                         {
00232                                                 ((CEdit*)GetFocus())->SetSel(0, 1000);
00233                                                 return TRUE;
00234                                         }
00235                                 }
00236                         }
00237                         break;
00238                 }
00239         }
00240         return __super::PreTranslateMessage(pMsg);
00241 }