Mercurial > ecos
comparison host/tools/configtool/standalone/win32/ConfigToolDoc.cpp @ 76:435cced73e2f ecos-v1_3_1-release
eCos v1.3.1 merged from eCos master repository on 2000-03-27-23:22:51-BST
| author | jlarmour |
|---|---|
| date | Tue, 28 Mar 2000 14:10:45 +0000 |
| parents | |
| children | 6736c52df507 |
comparison
equal
deleted
inserted
replaced
| 75:41bf073c0c32 | 76:435cced73e2f |
|---|---|
| 1 //####COPYRIGHTBEGIN#### | |
| 2 // | |
| 3 // ---------------------------------------------------------------------------- | |
| 4 // Copyright (C) 1998, 1999, 2000 Red Hat, Inc. | |
| 5 // | |
| 6 // This program is part of the eCos host tools. | |
| 7 // | |
| 8 // This program is free software; you can redistribute it and/or modify it | |
| 9 // under the terms of the GNU General Public License as published by the Free | |
| 10 // Software Foundation; either version 2 of the License, or (at your option) | |
| 11 // any later version. | |
| 12 // | |
| 13 // This program is distributed in the hope that it will be useful, but WITHOUT | |
| 14 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
| 15 // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | |
| 16 // more details. | |
| 17 // | |
| 18 // You should have received a copy of the GNU General Public License along with | |
| 19 // this program; if not, write to the Free Software Foundation, Inc., | |
| 20 // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |
| 21 // | |
| 22 // ---------------------------------------------------------------------------- | |
| 23 // | |
| 24 //####COPYRIGHTEND#### | |
| 25 // ConfigToolDoc.cpp : implementation of the CConfigToolDoc class | |
| 26 // | |
| 27 // | |
| 28 //=========================================================================== | |
| 29 //=========================================================================== | |
| 30 //#####DESCRIPTIONBEGIN#### | |
| 31 // | |
| 32 // Author(s): sdf | |
| 33 // Contact(s): sdf | |
| 34 // Date: 1998/08/11 | |
| 35 // Version: 0.01 | |
| 36 // Purpose: | |
| 37 // Description: This is the implementation of the document class | |
| 38 // Requires: | |
| 39 // Provides: | |
| 40 // See also: | |
| 41 // Known bugs: | |
| 42 // Usage: | |
| 43 // | |
| 44 //####DESCRIPTIONEND#### | |
| 45 // | |
| 46 //=========================================================================== | |
| 47 | |
| 48 #include "stdafx.h" | |
| 49 | |
| 50 #include "CTUtils.h" | |
| 51 #include "CdlTemplatesDialog.h" | |
| 52 #include "CellView.h" | |
| 53 #include "ConfigItem.h" | |
| 54 #include "ConfigTool.h" | |
| 55 #include "ConfigToolDoc.h" | |
| 56 #include "eCosTest.h" | |
| 57 #include "IdleMessage.h" | |
| 58 #include "MainFrm.h" | |
| 59 #include "PlatformDialog.h" | |
| 60 #include "PkgAdminDlg.h" | |
| 61 #include "RegKeyEx.h" | |
| 62 #include "RunTestsSheet.h" | |
| 63 #include "Thermometer.h" | |
| 64 | |
| 65 #define INCLUDEFILE "build.hxx" | |
| 66 #include "IncludeSTL.h" | |
| 67 | |
| 68 #ifdef _DEBUG | |
| 69 #define new DEBUG_NEW | |
| 70 #undef THIS_FILE | |
| 71 static char THIS_FILE[] = __FILE__; | |
| 72 #endif | |
| 73 | |
| 74 // a trivial CDL parse error handler | |
| 75 | |
| 76 ///////////////////////////////////////////////////////////////////////////// | |
| 77 // CConfigToolDoc | |
| 78 | |
| 79 IMPLEMENT_DYNCREATE(CConfigToolDoc, CDocument) | |
| 80 | |
| 81 BEGIN_MESSAGE_MAP(CConfigToolDoc, CDocument) | |
| 82 //{{AFX_MSG_MAP(CConfigToolDoc) | |
| 83 ON_COMMAND(ID_CONFIGURATION_REPOSITORY, OnConfigurationRepository) | |
| 84 ON_COMMAND(ID_BUILD_TEMPLATES, OnBuildTemplates) | |
| 85 ON_COMMAND(ID_BUILD_PACKAGES, OnBuildPackages) | |
| 86 ON_COMMAND(ID_TOOLS_ADMINISTRATION, OnToolsAdministration) | |
| 87 ON_COMMAND(ID_FILE_EXPORT, OnFileExport) | |
| 88 ON_COMMAND(ID_FILE_IMPORT, OnFileImport) | |
| 89 //}}AFX_MSG_MAP | |
| 90 END_MESSAGE_MAP() | |
| 91 | |
| 92 ///////////////////////////////////////////////////////////////////////////// | |
| 93 // CConfigToolDoc construction/destruction | |
| 94 | |
| 95 | |
| 96 CConfigToolDoc::CConfigToolDoc(): | |
| 97 m_bUseCustomViewer(false), | |
| 98 m_nFindFlags(0), | |
| 99 m_nFindWhere(InMacro), | |
| 100 m_bUseExternalBrowser(false), | |
| 101 m_bAutoExpand(false), | |
| 102 m_bMacroNames(false), | |
| 103 m_bHex(false), | |
| 104 m_CdlConfig(NULL), | |
| 105 m_CdlPkgData(NULL), | |
| 106 m_CdlInterp(NULL), | |
| 107 m_template_version(""), | |
| 108 m_bRepositoryOpen(false) | |
| 109 { | |
| 110 CConfigTool::SetDocument(this); | |
| 111 LoadProfileSettings(); | |
| 112 } | |
| 113 | |
| 114 CConfigToolDoc::~CConfigToolDoc() | |
| 115 { | |
| 116 CConfigTool::SetDocument(0); | |
| 117 SaveProfileSettings(); | |
| 118 } | |
| 119 | |
| 120 ///////////////////////////////////////////////////////////////////////////// | |
| 121 // CConfigToolDoc serialization | |
| 122 | |
| 123 void CConfigToolDoc::Serialize(CArchive& ar) | |
| 124 { | |
| 125 if (ar.IsStoring()) | |
| 126 { | |
| 127 // TODO: add storing code here | |
| 128 } | |
| 129 else | |
| 130 { | |
| 131 // TODO: add loading code here | |
| 132 } | |
| 133 } | |
| 134 | |
| 135 ///////////////////////////////////////////////////////////////////////////// | |
| 136 // CConfigToolDoc diagnostics | |
| 137 | |
| 138 #ifdef _DEBUG | |
| 139 void CConfigToolDoc::AssertValid() const | |
| 140 { | |
| 141 CDocument::AssertValid(); | |
| 142 } | |
| 143 | |
| 144 void CConfigToolDoc::Dump(CDumpContext& dc) const | |
| 145 { | |
| 146 CDocument::Dump(dc); | |
| 147 } | |
| 148 #endif //_DEBUG | |
| 149 | |
| 150 ///////////////////////////////////////////////////////////////////////////// | |
| 151 // CConfigToolDoc commands | |
| 152 | |
| 153 bool CConfigToolDoc::SwitchMemoryLayout (BOOL bNewTargetPlatform) | |
| 154 { | |
| 155 bool rc=true; | |
| 156 if (bNewTargetPlatform && ! m_strBuildTree.IsEmpty ()) // the user has changed target/platform within a build tree | |
| 157 { | |
| 158 // copy default MLT save files for the selected target/platform from the repository to the build tree if they do not already exist | |
| 159 | |
| 160 CFileFind ffFileFind; | |
| 161 BOOL bLastFile = ffFileFind.FindFile (CFileName (m_strPackagesDir, m_strMemoryLayoutFolder, _T("include\\pkgconf\\*.mlt"))); | |
| 162 while (bLastFile) | |
| 163 { | |
| 164 bLastFile = ffFileFind.FindNextFile (); | |
| 165 if (! CFileName(MLTDir (), ffFileFind.GetFileName ()).Exists () && | |
| 166 !CUtils::CopyFile (ffFileFind.GetFilePath (), CFileName(MLTDir (), ffFileFind.GetFileName ()))){ | |
| 167 return false; // message already emitted | |
| 168 } | |
| 169 } | |
| 170 } | |
| 171 | |
| 172 if (m_strBuildTree.IsEmpty ()) // load the memory layout from the repository | |
| 173 rc&=NewMemoryLayout (CFileName (m_strPackagesDir, m_strMemoryLayoutFolder, _T("include\\pkgconf"))); | |
| 174 else // load the memory layout from the build tree | |
| 175 rc&=NewMemoryLayout (MLTDir ()); | |
| 176 | |
| 177 return true; // FIXME | |
| 178 } | |
| 179 | |
| 180 void CConfigToolDoc::OnCloseDocument() | |
| 181 { | |
| 182 MemoryMap.new_memory_layout (); // called to free up memory | |
| 183 CloseRepository(); | |
| 184 CDocument::OnCloseDocument(); | |
| 185 } | |
| 186 | |
| 187 | |
| 188 BOOL CConfigToolDoc::OnNewDocument() | |
| 189 { | |
| 190 m_strBuildTree=_T(""); | |
| 191 if (!CDocument::OnNewDocument()){ | |
| 192 return FALSE; | |
| 193 } | |
| 194 m_bRepositoryOpen = false; | |
| 195 if(!OpenRepository()){ | |
| 196 PostQuitMessage (1); | |
| 197 return FALSE; | |
| 198 } | |
| 199 // load the memory layout for the default target-platform-startup from the current repository | |
| 200 | |
| 201 MemoryMap.set_map_size (0xFFFFFFFF); // set the maximum memory map size | |
| 202 NewMemoryLayout (CFileName (m_strPackagesDir, m_strMemoryLayoutFolder, _T("include\\pkgconf"))); | |
| 203 UpdateBuildInfo(); | |
| 204 return TRUE; | |
| 205 } | |
| 206 | |
| 207 BOOL CConfigToolDoc::OnOpenDocument(LPCTSTR lpszPathName) | |
| 208 { | |
| 209 BOOL rc=FALSE; // Assume the worst | |
| 210 CString strFileName; | |
| 211 CdlInterpreter NewCdlInterp = NULL; | |
| 212 CdlConfiguration NewCdlConfig = NULL; | |
| 213 | |
| 214 | |
| 215 CFileName strFolder (lpszPathName); | |
| 216 strFolder = strFolder.Left (strFolder.ReverseFind (_TCHAR('\\'))); // extract folder from file path | |
| 217 | |
| 218 if(CConfigTool::GetMain()){ | |
| 219 CString str; | |
| 220 str.Format(_T("Opening save file %s"),lpszPathName); | |
| 221 CConfigTool::GetMain()->m_wndStatusBar.SetPaneText(CMainFrame::StatusPane,str); | |
| 222 CConfigTool::GetMain()->m_wndStatusBar.SetPaneText(CMainFrame::FailRulePane,_T("")); | |
| 223 } | |
| 224 | |
| 225 TRACE(_T("###Open document - save file=%s\n"), lpszPathName); | |
| 226 | |
| 227 // disable the transaction callback before attempting changes | |
| 228 | |
| 229 EnableCallbacks(false); | |
| 230 | |
| 231 // load the new configuration | |
| 232 | |
| 233 try | |
| 234 { | |
| 235 NewCdlInterp = CdlInterpreterBody::make (); | |
| 236 NewCdlConfig = CdlConfigurationBody::load (CUtils::UnicodeToStdStr (lpszPathName), m_CdlPkgData, NewCdlInterp, &CdlLoadErrorHandler, &CdlLoadWarningHandler); | |
| 237 rc = TRUE; | |
| 238 } | |
| 239 catch (CdlStringException exception) | |
| 240 { | |
| 241 CUtils::MessageBoxF(_T("Error opening eCos configuration:\n\n%s"), CString (exception.get_message ().c_str ())); | |
| 242 } | |
| 243 catch (...) | |
| 244 { | |
| 245 CUtils::MessageBoxF(_T("Error opening eCos configuration")); | |
| 246 } | |
| 247 | |
| 248 if (rc) | |
| 249 { | |
| 250 rc=false; | |
| 251 // check the new configuration | |
| 252 | |
| 253 ASSERT (NewCdlConfig->check_this (cyg_extreme)); | |
| 254 | |
| 255 // switch to the new configuration | |
| 256 | |
| 257 deleteZ(m_CdlConfig); | |
| 258 deleteZ(m_CdlInterp); | |
| 259 m_CdlInterp = NewCdlInterp; | |
| 260 m_CdlConfig = NewCdlConfig; | |
| 261 SetPathName (lpszPathName, TRUE); // called to ensure that MLTDir() will work in this function | |
| 262 | |
| 263 AddAllItems (); // must precede NewMemoryLayout() [CurrentLinkerScript() calls Find()] | |
| 264 | |
| 265 // load the memory layout from the build tree | |
| 266 NewMemoryLayout (MLTDir ()); | |
| 267 | |
| 268 // generate the CConfigItems from their CDL descriptions | |
| 269 | |
| 270 | |
| 271 UpdateAllViews (NULL,AllSaved,0); | |
| 272 UpdateFailingRuleCount(); | |
| 273 UpdateBuildInfo(); | |
| 274 rc=true; | |
| 275 } | |
| 276 | |
| 277 // re-enable the transaction callback | |
| 278 | |
| 279 EnableCallbacks(true); | |
| 280 | |
| 281 return rc; | |
| 282 } | |
| 283 | |
| 284 BOOL CConfigToolDoc::OnSaveDocument(LPCTSTR lpszPathName) | |
| 285 { | |
| 286 const CString strOldPath(GetPathName()); | |
| 287 bool bSaveAs=(lpszPathName!=strOldPath); | |
| 288 if(!bSaveAs && !IsModified()){ | |
| 289 return true; | |
| 290 } | |
| 291 | |
| 292 bool rc=false; | |
| 293 if(CheckConflictsBeforeSave()){ // errors already emitted | |
| 294 | |
| 295 const CFileName strPathName(lpszPathName); | |
| 296 | |
| 297 TRACE(_T("###Save document %s\n"),lpszPathName); | |
| 298 | |
| 299 CString str; | |
| 300 str.Format(_T("Saving configuration %s"), lpszPathName); | |
| 301 CIdleMessage IM(str); | |
| 302 if(CConfigTool::GetCellView()){ | |
| 303 CConfigTool::GetCellView()->CancelCellEdit(); | |
| 304 } | |
| 305 | |
| 306 // check the configuration | |
| 307 | |
| 308 ASSERT (m_CdlConfig->check_this (cyg_extreme)); | |
| 309 | |
| 310 // save the configuration | |
| 311 | |
| 312 try | |
| 313 { | |
| 314 m_CdlConfig->save (CUtils::UnicodeToStdStr (lpszPathName)); | |
| 315 rc=true; | |
| 316 } | |
| 317 | |
| 318 catch (CdlStringException exception) | |
| 319 { | |
| 320 CUtils::MessageBoxF(_T("Error saving eCos configuration:\n\n%s"), CString (exception.get_message ().c_str ())); | |
| 321 } | |
| 322 | |
| 323 catch (...) | |
| 324 { | |
| 325 CUtils::MessageBoxF(_T("Error saving eCos configuration")); | |
| 326 } | |
| 327 | |
| 328 if(rc){ | |
| 329 rc=false; | |
| 330 SetPathName (lpszPathName, FALSE); // called to ensure that MLTDir() will work in this function | |
| 331 | |
| 332 // save the memory layout files to the build tree and copy to the install tree | |
| 333 | |
| 334 if (bSaveAs || MemoryMap.map_modified ()) { | |
| 335 SaveMemoryMap(); | |
| 336 } else { | |
| 337 TRACE(_T("Memory layout not modified\n")); | |
| 338 } | |
| 339 | |
| 340 UpdateAllViews (NULL,AllSaved,0); | |
| 341 | |
| 342 if(!m_strBuildTree.CreateDirectory() || !m_strInstallTree.CreateDirectory()){ | |
| 343 CUtils::MessageBoxF(_T("Failed to save %s - %s"),lpszPathName,CUtils::GetLastErrorMessageString()); | |
| 344 } else if(GenerateHeaders() && CopyMLTFiles()){ // in each case errors already emitted | |
| 345 // copy new MLT files to the build tree as necessary | |
| 346 rc=generate_build_tree (GetCdlConfig(), CUtils::UnicodeToStdStr(m_strBuildTree), CUtils::UnicodeToStdStr(m_strInstallTree)); | |
| 347 } | |
| 348 } | |
| 349 } | |
| 350 if(rc){ | |
| 351 SetModifiedFlag (false); | |
| 352 SetPathName (lpszPathName, TRUE); // add to MRU | |
| 353 } else { | |
| 354 SetPathName (strOldPath, FALSE); | |
| 355 } | |
| 356 return rc; | |
| 357 } | |
| 358 | |
| 359 BOOL CConfigToolDoc::Reload() | |
| 360 { | |
| 361 TRACE(_T("###ReOpen document - build tree=%s\n"),m_strBuildTree); | |
| 362 UpdateAllViews (NULL,AllSaved,0); | |
| 363 UpdateAllViews (NULL,ExternallyChanged,0); | |
| 364 UpdateFailingRuleCount(); | |
| 365 | |
| 366 return TRUE; | |
| 367 } | |
| 368 | |
| 369 void CConfigToolDoc::OnConfigurationRepository() | |
| 370 { | |
| 371 SaveModified (); | |
| 372 m_bRepositoryOpen=false; | |
| 373 if(OpenRepository(Repository(),true)){ | |
| 374 // reset the document title as shown in the frame window | |
| 375 GetDocTemplate ()->SetDefaultTitle (this); | |
| 376 | |
| 377 // load the memory layout for the default target-platform-startup from the new repository | |
| 378 NewMemoryLayout (CFileName (m_strPackagesDir, m_strMemoryLayoutFolder, _T("include\\pkgconf"))); | |
| 379 UpdateAllViews(NULL); | |
| 380 UpdateFailingRuleCount(); | |
| 381 } else { | |
| 382 m_bRepositoryOpen=true; // keep what we had | |
| 383 } | |
| 384 | |
| 385 } | |
| 386 | |
| 387 ////////////////////////////////////////////////////////////// | |
| 388 // MLT-specific member functions | |
| 389 | |
| 390 void CConfigToolDoc::OnUpdateEditDelete(CCmdUI* pCmdUI) | |
| 391 { | |
| 392 // enable the 'delete' menu item and toolbar button only if there is a region or section selected | |
| 393 | |
| 394 pCmdUI->Enable ((strSelectedRegion != _T("")) || (strSelectedSection != _T(""))); | |
| 395 } | |
| 396 | |
| 397 | |
| 398 void CConfigToolDoc::OnUpdateEditNewSection(CCmdUI* pCmdUI) | |
| 399 { | |
| 400 // enable the 'new section' menu item and toolbar button only if there is at least one memory region defined | |
| 401 | |
| 402 pCmdUI->Enable (MemoryMap.region_list.size () > 0); | |
| 403 } | |
| 404 | |
| 405 void CConfigToolDoc::OnUpdateEditProperties(CCmdUI* pCmdUI) | |
| 406 { | |
| 407 // enable the 'properties' menu item and toolbar button if there is a memory region or section selected | |
| 408 pCmdUI->Enable ((strSelectedRegion != _T("")) || (strSelectedSection != _T(""))); | |
| 409 } | |
| 410 | |
| 411 void CConfigToolDoc::LoadProfileSettings() | |
| 412 { | |
| 413 CConfigToolApp *pApp=(CConfigToolApp *)AfxGetApp(); | |
| 414 m_eUseCustomBrowser=(BrowserType)pApp->GetProfileInt (_T("View"), _T("CustomBrowser"), Internal); | |
| 415 m_bHex= pApp->GetProfileInt (_T("Format"),_T("Hex"), 0); | |
| 416 m_bMacroNames= pApp->GetProfileInt (_T("Format"),_T("MacroNames"), 0); | |
| 417 m_nFindFlags= pApp->GetProfileInt (_T("Find"), _T("Flags"), FR_DOWN); | |
| 418 m_strFind= pApp->GetProfileString(_T("Find"), _T("String")); | |
| 419 m_nFindWhere=(WhereType)pApp->GetProfileInt (_T("Find"), _T("Where"),0); | |
| 420 m_bUseCustomViewer= pApp->GetProfileInt (_T("View"), _T("CustomViewer"), 0); | |
| 421 m_bAutoExpand= pApp->GetProfileInt (_T("View"), _T("Auto-expand"), 1); | |
| 422 m_nRuleChecking= pApp->GetProfileInt (_T("Rule"), _T("Checking"), Immediate|Deferred|SuggestFixes); | |
| 423 | |
| 424 CRegKeyEx k(HKEY_CURRENT_USER,CUtils::LoadString(IDS_REPOSITORY_REGKEY), KEY_READ); | |
| 425 | |
| 426 if(!k.QueryValue(CUtils::LoadString(IDS_REPOSITORY_REGVALUE), m_strRepository)){ | |
| 427 CStringArray arstr; | |
| 428 switch(pApp->GetRepositoryRegistryClues(arstr,_T("eCos"))){ | |
| 429 case 0: | |
| 430 break; | |
| 431 case 1: | |
| 432 default: | |
| 433 SetRepository(arstr[0]); | |
| 434 break; | |
| 435 } | |
| 436 } | |
| 437 } | |
| 438 | |
| 439 void CConfigToolDoc::SaveProfileSettings() | |
| 440 { | |
| 441 CConfigToolApp *pApp=(CConfigToolApp *)AfxGetApp(); | |
| 442 pApp->WriteProfileInt (_T("Find"), _T("Where"),m_nFindWhere); | |
| 443 pApp->WriteProfileString(_T("View"), _T("Viewer"), m_strViewer); | |
| 444 pApp->WriteProfileInt (_T("View"), _T("CustomViewer"), m_bUseCustomViewer); | |
| 445 pApp->WriteProfileInt (_T("View"), _T("CustomBrowser"), m_eUseCustomBrowser); | |
| 446 pApp->WriteProfileInt (_T("View"), _T("Auto-expand"), m_bAutoExpand); | |
| 447 | |
| 448 pApp->WriteProfileInt (_T("Format"), _T("Hex"), m_bHex); | |
| 449 pApp->WriteProfileInt (_T("Format"), _T("MacroNames"), m_bMacroNames); | |
| 450 | |
| 451 pApp->WriteProfileInt (_T("Find"), _T("Flags"), m_nFindFlags); | |
| 452 pApp->WriteProfileString(_T("Find"), _T("String"), m_strFind); | |
| 453 | |
| 454 pApp->WriteProfileInt (_T("Rule"), _T("Checking"), m_nRuleChecking); | |
| 455 | |
| 456 CRegKeyEx k(HKEY_CURRENT_USER,CUtils::LoadString(IDS_REPOSITORY_REGKEY), KEY_WRITE); | |
| 457 k.SetValue(m_strRepository, CUtils::LoadString(IDS_REPOSITORY_REGVALUE)); | |
| 458 } | |
| 459 | |
| 460 void CConfigToolDoc::OnBuildTemplates () | |
| 461 { | |
| 462 CCdlTemplatesDialog dlg (FALSE); | |
| 463 | |
| 464 if (IDOK == dlg.DoModal ()){ | |
| 465 SelectHardware(dlg.GetSelectedHardware()); | |
| 466 SelectTemplate(dlg.GetSelectedTemplate(), dlg.GetSelectedTemplateVersion()); | |
| 467 } | |
| 468 } | |
| 469 | |
| 470 void CConfigToolDoc::OnBuildPackages() | |
| 471 { | |
| 472 SelectPackages (); | |
| 473 } | |
| 474 | |
| 475 | |
| 476 bool CConfigToolDoc::ShowURL(LPCTSTR pszURL) | |
| 477 { | |
| 478 bool rc=true; | |
| 479 | |
| 480 CString strURL(pszURL); | |
| 481 if(!QualifyDocURL(strURL)){ | |
| 482 return false; // error message already output | |
| 483 } | |
| 484 | |
| 485 CConfigToolApp*pApp=(CConfigToolApp*)AfxGetApp(); | |
| 486 | |
| 487 switch(m_eUseCustomBrowser){ | |
| 488 case Internal: | |
| 489 rc=CConfigToolDoc::ShowHtmlHelp(strURL); | |
| 490 break; | |
| 491 case AssociatedExternal: | |
| 492 { | |
| 493 // A bit of a problem here: we can't execute the document, because this doesn't work with "file" schemes or | |
| 494 // with URL fragments (#...). So we'll launch the associated program and hope there aren't too many interesting | |
| 495 // flags specified with the association | |
| 496 CString strBrowser; | |
| 497 if(DefaultExternalBrowser().IsEmpty()){ | |
| 498 CUtils::MessageBoxF(_T("Failed to to determine associated external browser to open %s"),strURL); | |
| 499 } else { | |
| 500 pApp->Launch(strURL,DefaultExternalBrowser()); | |
| 501 } | |
| 502 } | |
| 503 break; | |
| 504 case CustomExternal: | |
| 505 pApp->Launch(strURL,m_strBrowser); | |
| 506 break; | |
| 507 default: | |
| 508 ASSERT(FALSE); | |
| 509 } | |
| 510 return rc; | |
| 511 } | |
| 512 | |
| 513 const CString CConfigToolDoc::CurrentTargetPrefix() | |
| 514 { | |
| 515 CConfigItem *pItem=Find(_T("CYGBLD_GLOBAL_COMMAND_PREFIX")); | |
| 516 return pItem?pItem->StringValue():_T(""); | |
| 517 } | |
| 518 | |
| 519 int CConfigToolDoc::GetCompilationCount(LPCTSTR psz) | |
| 520 { | |
| 521 int rc=0; | |
| 522 CStringArray arstr; | |
| 523 const CString strPrefix(CurrentTargetPrefix()); | |
| 524 for(int i=CUtils::Chop(psz,arstr,_T("\n"))-1;i>=0;--i){ | |
| 525 if(-1!=arstr[i].Find(strPrefix)){ | |
| 526 rc++; | |
| 527 } | |
| 528 } | |
| 529 return rc; | |
| 530 } | |
| 531 | |
| 532 void CConfigToolDoc::RunTests() | |
| 533 { | |
| 534 const CString strTarget(CurrentTestingIdentifier()); | |
| 535 TRACE (_T("OnRunSim(): test target ID = '%s'\n"), strTarget); | |
| 536 | |
| 537 if (!CeCosTest::IsValid (strTarget)) { | |
| 538 if(IDNO==CUtils::MessageBoxFT(MB_YESNO,_T("%s is not a recognized platform - do you wish to add it?"),strTarget)){ | |
| 539 return; | |
| 540 } | |
| 541 CPlatformDialog dlg; | |
| 542 dlg.m_strPlatform=strTarget; | |
| 543 dlg.m_strPrefix=CurrentTargetPrefix(); | |
| 544 dlg.m_strCaption=_T("New Platform"); | |
| 545 if(IDCANCEL==dlg.DoModal()){ | |
| 546 return; | |
| 547 } | |
| 548 CeCosTest::AddPlatform(CeCosTest::TargetInfo(dlg.m_strPlatform,dlg.m_strPrefix,dlg.m_nType,dlg.m_strGDB)); | |
| 549 CeCosTest::SaveTargetInfo(); | |
| 550 } | |
| 551 | |
| 552 CFileNameArray ar; | |
| 553 CFileNameArray arTestsMissing; | |
| 554 int nTests=GetTestExeNames(ar,arTestsMissing); | |
| 555 CRunTestsSheet sheet(_T("Run Tests"), NULL, 0, 0); | |
| 556 sheet.SetTarget(strTarget); | |
| 557 sheet.HideRemoteControls(); | |
| 558 if(arTestsMissing.GetSize()){ | |
| 559 if(IDYES==CUtils::MessageBoxFT(MB_YESNO,_T("Not all tests are built. Do you wish to build them now?"))){ | |
| 560 CConfigTool::GetMain()->SendMessage(WM_COMMAND,ID_BUILD_TESTS); | |
| 561 return; | |
| 562 } | |
| 563 } | |
| 564 if(CConfigTool::GetMain()->PrepareEnvironment()){ | |
| 565 for(int i=0;i<nTests;i++){ | |
| 566 sheet.Populate(ar[i],true); | |
| 567 } | |
| 568 for(i=0;i<arTestsMissing.GetSize();i++){ | |
| 569 sheet.Populate(arTestsMissing[i],false); | |
| 570 } | |
| 571 sheet.DoModal(); | |
| 572 } | |
| 573 } | |
| 574 | |
| 575 void CConfigToolDoc::OnToolsAdministration() | |
| 576 { | |
| 577 if(IDYES==CUtils::MessageBoxFT(MB_YESNO,_T("This command will close the current document.\n\nDo you wish to continue?"))){ | |
| 578 // ensure that the user tools are on the path for use by ecosadmin.tcl | |
| 579 if(CConfigTool::GetMain()->PrepareEnvironment(/* bWithBuildTools = */ false)){ | |
| 580 CConfigToolApp *pApp=(CConfigToolApp *)AfxGetApp(); | |
| 581 CPkgAdminDlg dlg(PackagesDir(),pApp->m_strUserToolsDir); // make sure we use doc data before the doc is destroyed | |
| 582 CMainFrame *pMain=CConfigTool::GetMain(); | |
| 583 if(IDOK==dlg.DoModal()){ | |
| 584 pMain->PostMessage(WM_COMMAND,ID_FILE_NEW); | |
| 585 } | |
| 586 } | |
| 587 } | |
| 588 } |
