📄 configtooldoc.cpp
字号:
//####COPYRIGHTBEGIN####// // ----------------------------------------------------------------------------// Copyright (C) 1998, 1999, 2000 Red Hat, Inc.//// This program is part of the eCos host tools.//// This program is free software; you can redistribute it and/or modify it // under the terms of the GNU General Public License as published by the Free // Software Foundation; either version 2 of the License, or (at your option) // any later version.// // This program is distributed in the hope that it will be useful, but WITHOUT // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for // more details.// // You should have received a copy of the GNU General Public License along with// this program; if not, write to the Free Software Foundation, Inc., // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.//// ----------------------------------------------------------------------------// //####COPYRIGHTEND####// ConfigToolDoc.cpp : implementation of the CConfigToolDoc class//////===========================================================================//===========================================================================//#####DESCRIPTIONBEGIN####//// Author(s): sdf// Contact(s): sdf// Date: 1998/08/11// Version: 0.01// Purpose: // Description: This is the implementation of the document class// Requires: // Provides: // See also: // Known bugs: // Usage: ////####DESCRIPTIONEND####////===========================================================================#include "stdafx.h"#include "CTUtils.h"#include "CdlTemplatesDialog.h"#include "CellView.h"#include "ConfigItem.h"#include "ConfigTool.h"#include "ConfigToolDoc.h"#include "eCosTest.h"#include "IdleMessage.h"#include "MainFrm.h"#include "PlatformDialog.h"#include "PkgAdminDlg.h"#include "RegKeyEx.h"#include "RunTestsSheet.h"#include "Thermometer.h"#define INCLUDEFILE "build.hxx"#include "IncludeSTL.h"#ifdef _DEBUG#define new DEBUG_NEW#undef THIS_FILEstatic char THIS_FILE[] = __FILE__;#endif// a trivial CDL parse error handler/////////////////////////////////////////////////////////////////////////////// CConfigToolDocIMPLEMENT_DYNCREATE(CConfigToolDoc, CDocument)BEGIN_MESSAGE_MAP(CConfigToolDoc, CDocument)//{{AFX_MSG_MAP(CConfigToolDoc)ON_COMMAND(ID_CONFIGURATION_REPOSITORY, OnConfigurationRepository)ON_COMMAND(ID_BUILD_TEMPLATES, OnBuildTemplates)ON_COMMAND(ID_BUILD_PACKAGES, OnBuildPackages)ON_COMMAND(ID_TOOLS_ADMINISTRATION, OnToolsAdministration)ON_COMMAND(ID_FILE_EXPORT, OnFileExport)ON_COMMAND(ID_FILE_IMPORT, OnFileImport)//}}AFX_MSG_MAPEND_MESSAGE_MAP()/////////////////////////////////////////////////////////////////////////////// CConfigToolDoc construction/destructionCConfigToolDoc::CConfigToolDoc(): m_bUseCustomViewer(false), m_nFindFlags(0), m_nFindWhere(InMacro), m_bUseExternalBrowser(false), m_bAutoExpand(false), m_bMacroNames(false), m_bHex(false), m_CdlConfig(NULL), m_CdlPkgData(NULL), m_CdlInterp(NULL), m_template_version(""), m_bRepositoryOpen(false){ CConfigTool::SetDocument(this); LoadProfileSettings();}CConfigToolDoc::~CConfigToolDoc(){ CConfigTool::SetDocument(0); SaveProfileSettings();}/////////////////////////////////////////////////////////////////////////////// CConfigToolDoc serializationvoid CConfigToolDoc::Serialize(CArchive& ar){ if (ar.IsStoring()) { // TODO: add storing code here } else { // TODO: add loading code here }}/////////////////////////////////////////////////////////////////////////////// CConfigToolDoc diagnostics#ifdef _DEBUGvoid CConfigToolDoc::AssertValid() const{ CDocument::AssertValid();}void CConfigToolDoc::Dump(CDumpContext& dc) const{ CDocument::Dump(dc);}#endif //_DEBUG/////////////////////////////////////////////////////////////////////////////// CConfigToolDoc commandsbool CConfigToolDoc::SwitchMemoryLayout (BOOL bNewTargetPlatform){ bool rc=true; if (bNewTargetPlatform && ! m_strBuildTree.IsEmpty ()) // the user has changed target/platform within a build tree { // copy default MLT save files for the selected target/platform from the repository to the build tree if they do not already exist CFileFind ffFileFind; BOOL bLastFile = ffFileFind.FindFile (CFileName (m_strPackagesDir, m_strMemoryLayoutFolder, _T("include\\pkgconf\\*.mlt"))); while (bLastFile) { bLastFile = ffFileFind.FindNextFile (); if (! CFileName(MLTDir (), ffFileFind.GetFileName ()).Exists () && !CUtils::CopyFile (ffFileFind.GetFilePath (), CFileName(MLTDir (), ffFileFind.GetFileName ()))){ return false; // message already emitted } } } if (m_strBuildTree.IsEmpty ()) // load the memory layout from the repository rc&=NewMemoryLayout (CFileName (m_strPackagesDir, m_strMemoryLayoutFolder, _T("include\\pkgconf"))); else // load the memory layout from the build tree rc&=NewMemoryLayout (MLTDir ()); return true; // FIXME}void CConfigToolDoc::OnCloseDocument() { MemoryMap.new_memory_layout (); // called to free up memory CloseRepository(); CDocument::OnCloseDocument();}BOOL CConfigToolDoc::OnNewDocument(){ m_strBuildTree=_T(""); if (!CDocument::OnNewDocument()){ return FALSE; } m_bRepositoryOpen = false; if(!OpenRepository()){ PostQuitMessage (1); return FALSE; } // load the memory layout for the default target-platform-startup from the current repository MemoryMap.set_map_size (0xFFFFFFFF); // set the maximum memory map size NewMemoryLayout (CFileName (m_strPackagesDir, m_strMemoryLayoutFolder, _T("include\\pkgconf"))); UpdateBuildInfo(); return TRUE;}BOOL CConfigToolDoc::OnOpenDocument(LPCTSTR lpszPathName) { BOOL rc=FALSE; // Assume the worst CString strFileName; CdlInterpreter NewCdlInterp = NULL; CdlConfiguration NewCdlConfig = NULL; CFileName strFolder (lpszPathName); strFolder = strFolder.Left (strFolder.ReverseFind (_TCHAR('\\'))); // extract folder from file path if(CConfigTool::GetMain()){ CString str; str.Format(_T("Opening save file %s"),lpszPathName); CConfigTool::GetMain()->m_wndStatusBar.SetPaneText(CMainFrame::StatusPane,str); CConfigTool::GetMain()->m_wndStatusBar.SetPaneText(CMainFrame::FailRulePane,_T("")); } TRACE(_T("###Open document - save file=%s\n"), lpszPathName); // disable the transaction callback before attempting changes EnableCallbacks(false); // load the new configuration try { NewCdlInterp = CdlInterpreterBody::make (); NewCdlConfig = CdlConfigurationBody::load (CUtils::UnicodeToStdStr (lpszPathName), m_CdlPkgData, NewCdlInterp, &CdlLoadErrorHandler, &CdlLoadWarningHandler); rc = TRUE; } catch (CdlStringException exception) { CUtils::MessageBoxF(_T("Error opening eCos configuration:\n\n%s"), CString (exception.get_message ().c_str ())); } catch (...) { CUtils::MessageBoxF(_T("Error opening eCos configuration")); } if (rc) { rc=false; // check the new configuration ASSERT (NewCdlConfig->check_this (cyg_extreme)); // switch to the new configuration deleteZ(m_CdlConfig); deleteZ(m_CdlInterp); m_CdlInterp = NewCdlInterp; m_CdlConfig = NewCdlConfig; SetPathName (lpszPathName, TRUE); // called to ensure that MLTDir() will work in this function AddAllItems (); // must precede NewMemoryLayout() [CurrentLinkerScript() calls Find()] // load the memory layout from the build tree NewMemoryLayout (MLTDir ()); // generate the CConfigItems from their CDL descriptions UpdateAllViews (NULL,AllSaved,0); UpdateFailingRuleCount(); UpdateBuildInfo(); rc=true; } // re-enable the transaction callback EnableCallbacks(true); return rc;}BOOL CConfigToolDoc::OnSaveDocument(LPCTSTR lpszPathName) { const CString strOldPath(GetPathName()); bool bSaveAs=(lpszPathName!=strOldPath); if(!bSaveAs && !IsModified()){ return true; } bool rc=false; if(CheckConflictsBeforeSave()){ // errors already emitted const CFileName strPathName(lpszPathName);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -