📄 configtooldoc.cpp
字号:
//####COPYRIGHTBEGIN####//// ----------------------------------------------------------------------------// Copyright (C) 1998, 1999, 2000 Red Hat, Inc.// Copyright (C) 2003 John Dallaway//// 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 :////===========================================================================//#####DESCRIPTIONBEGIN####//// Author(s): julians, jld// Contact(s): julians, jld// Date: 2000/10/05// Version: $Id: configtooldoc.cpp,v 1.43 2002/02/13 13:58:18 julians Exp $// Purpose:// Description: Implementation file for the ecConfigToolDoc class// Requires:// Provides:// See also:// Known bugs:// Usage:////####DESCRIPTIONEND####////===========================================================================// ============================================================================// declarations// ============================================================================// ----------------------------------------------------------------------------// headers// ----------------------------------------------------------------------------#ifdef __GNUG__#pragma implementation "configtooldoc.h"#endif// Includes other headers for precompiled compilation#include "ecpch.h"#include "wx/config.h"#include "wx/textfile.h"#include "wx/process.h"#include "wx/mimetype.h"#ifdef __BORLANDC__#pragma hdrstop#endif#ifdef __WXMSW__#include <windows.h>#ifndef __CYGWIN__#include <shlobj.h>#endif#include "wx/msw/winundef.h"#ifdef CreateDirectory#undef CreateDirectory#endif#endif#include "configtooldoc.h"#include "configtoolview.h"#include "configtree.h"#include "mainwin.h"#include "ecutils.h"#include "filename.h"#include "choosereposdlg.h"#include "packagesdlg.h"#include "conflictsdlg.h"#include "conflictwin.h"#include "mltwin.h"#include "build.hxx"#include "platformeditordlg.h"#include "runtestsdlg.h"#include "propertywin.h"#include "docsystem.h"IMPLEMENT_DYNAMIC_CLASS(ecConfigToolDoc, wxDocument)ecConfigToolDoc::ecConfigToolDoc(){ m_bRepositoryOpen = FALSE; m_CdlPkgData = NULL; m_CdlInterp = NULL; m_CdlConfig = NULL; m_ConflictsOutcome = OK; m_strRepository = wxGetApp().GetSettings().m_strRepository;}ecConfigToolDoc::~ecConfigToolDoc(){ wxGetApp().m_currentDoc = NULL; wxGetApp().GetSettings().m_strRepository = m_strRepository; CloseRepository(); // Delete remaining items -- most (if not all) should already // have been deleted via the tree item client data DeleteItems();}void ecConfigToolDoc::DeleteItems(){ // Delete any remaining items wxNode* node = m_items.First(); while (node) { ecConfigItem* item = wxDynamicCast(node->Data(), ecConfigItem); wxNode* next = node->Next(); // Note: automatically removes itself from this list in ~ecConfigItem delete item; node = next; }}bool ecConfigToolDoc::OnCloseDocument(){ if (wxDocument::OnCloseDocument()) { DeleteItems(); return TRUE; } else { return FALSE; }}bool ecConfigToolDoc::Save(){ bool ret = FALSE; if (!IsModified() && m_savedYet) return TRUE; if (m_documentFile == wxT("") || !m_savedYet) ret = SaveAs(); else ret = OnSaveDocument(m_documentFile); if ( ret ) SetDocumentSaved(TRUE); return ret;}bool ecConfigToolDoc::OnCreate(const wxString& path, long flags){ wxGetApp().m_currentDoc = this; if (flags & wxDOC_NEW) { m_bRepositoryOpen = FALSE; bool prompt = FALSE; if (flags & ecDOC_PROMPT_FOR_REPOSITORY) prompt = TRUE; if(!OpenRepository(wxEmptyString, prompt)) { wxGetApp().m_currentDoc = NULL; return FALSE; } Modify(FALSE); SetDocumentSaved(FALSE); wxString rootName(wxT("untitled")); wxStripExtension(rootName); SetFilename(wxGetApp().GetSettings().GenerateFilename(rootName)); } // Creates the view, so do any view updating after this bool success = wxDocument::OnCreate(path, flags); if (success) { if (flags & wxDOC_NEW) { wxBusyCursor wait; ecConfigToolHint hint(NULL, ecSelChanged); UpdateAllViews (NULL, & hint); SetFilename(GetFilename(), TRUE); // load the memory layout for the default target-platform-startup from the current repository // TODO // m_memoryMap.set_map_size (0xFFFFFFFF); // set the maximum memory map size // NewMemoryLayout (CFileName (m_strPackagesDir, m_strMemoryLayoutFolder, _T("include\\pkgconf"))); // Why should we generate the names at this point, when we only have a temporary filename? // Don't do it!#if 0 wxGetApp().SetStatusText(wxT("Updating build information..."), FALSE); UpdateBuildInfo();#endif } } return success;}bool ecConfigToolDoc::OnSaveDocument(const wxString& filename){ wxBusyCursor cursor; const wxString strOldPath(GetFilename());#if 0 bool bSaveAs=(filename!=strOldPath); if(!IsModified() && wxFileExists(filename)) { return TRUE; }#endif bool rc=FALSE; if (CheckConflictsBeforeSave()) { // errors already emitted const wxString strPathName(filename); wxString str; str.Printf(_("Saving configuration %s"), (const wxChar*) filename); /* TODO CIdleMessage IM(str); if(CConfigTool::GetCellView()){ CConfigTool::GetCellView()->CancelCellEdit(); } */ // check the configuration wxASSERT (m_CdlConfig->check_this (cyg_extreme)); // save the configuration try { m_CdlConfig->save ((const wxChar*) filename); rc=TRUE; } catch (CdlStringException exception) { wxString msg; msg.Printf(_("Error saving eCos configuration:\n\n%s"), exception.get_message ().c_str ()); wxMessageBox(msg, wxGetApp().GetSettings().GetAppName(), wxICON_EXCLAMATION|wxOK); } catch (...) { wxString msg; msg.Printf(_("Error saving eCos configuration")); wxMessageBox(msg, wxGetApp().GetSettings().GetAppName(), wxICON_EXCLAMATION|wxOK); } if(rc){ rc=FALSE; SetFilename (filename); // called to ensure that MLTDir() will work in this function TODO?? // save the memory layout files to the build tree and copy to the install tree /* TODO if (bSaveAs || MemoryMap.map_modified ()) { SaveMemoryMap(); } */ ecConfigToolHint hint(NULL, ecAllSaved); UpdateAllViews (NULL, & hint); wxASSERT( !m_strBuildTree.IsEmpty() ); wxASSERT( !m_strInstallTree.IsEmpty() ); ecFileName buildFilename(m_strBuildTree); ecFileName installFilename(m_strInstallTree); if (!wxGetApp().GetSettings().m_editSaveFileOnly) { if (!buildFilename.CreateDirectory(FALSE) || !installFilename.CreateDirectory(FALSE)) { wxString msg; msg.Printf(_("Failed to save %s"), (const wxChar*) filename); wxMessageBox(msg, wxGetApp().GetSettings().GetAppName(), wxICON_EXCLAMATION); rc = FALSE; } else if (GenerateHeaders() && CopyMLTFiles()) { // in each case errors already emitted // copy new MLT files to the build tree as necessary rc=generate_build_tree (GetCdlConfig(), ecUtils::UnicodeToStdStr(m_strBuildTree), ecUtils::UnicodeToStdStr(m_strInstallTree)); rc = TRUE; } } else { rc = TRUE; } } } if(rc) { Modify(FALSE); SetDocumentSaved(TRUE); SetFilename(filename); wxGetApp().GetSettings().m_lastFilename = filename; } else { SetFilename(strOldPath); } wxGetApp().GetMainFrame()->UpdateFrameTitle(); return rc;}// Can we generate the build tree yet?bool ecConfigToolDoc::CanGenerateBuildTree(){ if (m_strBuildTree.IsEmpty() || m_strInstallTree.IsEmpty() ) return FALSE; int nCount=0; if (GetCdlConfig ()) { // calculate the number of conflicts int nCount = GetCdlConfig ()->get_all_conflicts ().size (); if (nCount > 0) return FALSE; } else return FALSE; return TRUE;}// A standalone method for generating a build tree without saving firstbool ecConfigToolDoc::GenerateBuildTree(){ wxBusyCursor wait; if (CanGenerateBuildTree()) { ecFileName buildFilename(m_strBuildTree); ecFileName installFilename(m_strInstallTree); if (!buildFilename.CreateDirectory() || !installFilename.CreateDirectory()) { wxString msg; msg.Printf(_("Failed to create build tree")); wxMessageBox(msg, wxGetApp().GetSettings().GetAppName(), wxICON_EXCLAMATION); return FALSE; } else if (GenerateHeaders() && CopyMLTFiles()) { // in each case errors already emitted // copy new MLT files to the build tree as necessary bool rc = generate_build_tree (GetCdlConfig(), ecUtils::UnicodeToStdStr(m_strBuildTree), ecUtils::UnicodeToStdStr(m_strInstallTree)); rc = TRUE; }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -