1 //####COPYRIGHTBEGIN####
3 // ----------------------------------------------------------------------------
4 // Copyright (C) 1998, 1999, 2000 Red Hat, Inc.
6 // This program is part of the eCos host tools.
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)
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
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.
22 // ----------------------------------------------------------------------------
24 //####COPYRIGHTEND####
27 //===========================================================================
28 //#####DESCRIPTIONBEGIN####
31 // Contact(s): julians
35 // Description: Header file for ecConfigToolDoc
42 //####DESCRIPTIONEND####
44 //===========================================================================
46 #ifndef _ECOS_CONFIGTOOLDOC_H_
47 #define _ECOS_CONFIGTOOLDOC_H_
50 #pragma interface "configtooldoc.h"
55 #include "configitem.h"
63 // Tell OnCreate to prompt for a repository instead of just loading it silently
64 #define ecDOC_PROMPT_FOR_REPOSITORY 8
68 * Holds the saveable configtool information
71 class ecConfigToolDoc: public wxDocument
73 DECLARE_DYNAMIC_CLASS(ecConfigToolDoc)
79 virtual bool OnCreate(const wxString& path, long flags);
80 virtual bool OnOpenDocument(const wxString& filename);
81 virtual bool OnSaveDocument(const wxString& filename);
82 virtual bool OnNewDocument() { return TRUE; }
83 virtual bool OnCloseDocument() ;
84 virtual bool Save(); // Overridden only to correct bug in wxWindows, docview.cpp
86 //// Error and other handlers
87 static void CdlLoadErrorHandler(std::string message);
88 static void CdlLoadWarningHandler(std::string message);
89 static void CdlParseErrorHandler (std::string message);
90 static void CdlParseWarningHandler (std::string message);
91 static void CdlTransactionHandler (const CdlTransactionCallback & data);
92 static CdlInferenceCallbackResult CdlInferenceHandler (CdlTransaction data);
93 static CdlInferenceCallbackResult CdlGlobalInferenceHandler(CdlTransaction data);
96 CdlPackagesDatabase GetCdlPkgData () { return m_CdlPkgData; }
97 CdlConfiguration GetCdlConfig () { return m_CdlConfig; }
98 CdlInterpreter GetCdlInterpreter() { return m_CdlInterp; }
100 // Absolute path name to root of respository - parent of PackagesDir below
101 void SetRepository(const wxString& pszRepository) { m_strRepository = ecFileName(pszRepository); }
102 const ecFileName& GetRepository() const { return m_strRepository; }
104 wxString GetDefaultHardware () ;
105 const wxString& GetTemplateVersion() const { return m_templateVersion; }
106 wxString GetPackageName (const wxString & strAlias);
108 // Absolute path name to "packages" directory - i.e. the one under the repository
109 // named "packages" in a delivery or "ecc" in CVS:
110 const ecFileName& GetPackagesDir() const { return m_strPackagesDir; }
112 const wxString& GetInstallTree() const { return m_strInstallTree; }
113 const wxString& GetBuildTree() const { return m_strBuildTree; }
114 void SetInstallTree(const wxString& str) { m_strInstallTree = str; }
115 void SetBuildTree(const wxString& str) { m_strBuildTree = str; }
117 wxList& GetItems() { return m_items; }
118 ecConfigItem* GetItem(size_t i) { return (ecConfigItem*) m_items[i]; }
120 CdlBuildInfo& GetBuildInfo() { return m_BuildInfo; }
122 ecConfigItem* GetFirstItem() { return (m_items.Number() == 0 ? (ecConfigItem*) NULL : (ecConfigItem*) m_items.First()->Data()); }
124 const wxString GetCurrentTargetPrefix();
126 const wxString HTMLHelpLinkFileName();
128 const ecFileName MLTDir ();
129 const ecFileName CurrentLinkerScript();
130 const wxString CurrentMemoryLayout ();
132 const ecFileName GetDocBase() const { return GetRepository() + wxT("doc"); }
135 bool OpenRepository(const wxString& pszRepository = wxEmptyString, bool bPromptInitially=FALSE) ;
136 bool OpenRepository (ecFileName& strNewRepository, CdlPackagesDatabase &NewCdlPkgData,CdlInterpreter &NewCdlInterp,CdlConfiguration &NewCdlConfig, wxString &strNewPackagesDir);
137 void CloseRepository() ;
138 // Find a valid repository given a directory name
139 bool FindRepository (ecFileName& repositoryIn, ecFileName& repositoryOut) const;
140 void EnableCallbacks (bool bEnable=TRUE);
141 void AddContents (const CdlContainer container, ecConfigItem *pParent);
143 ecConfigItem* AddItem (const CdlUserVisible vitem, ecConfigItem * pParent);
146 // Use the wxHtmlHelpController
147 bool ShowInternalHtmlHelp (const wxString& strURL);
149 // Use an external browser
150 bool ShowExternalHtmlHelp (const wxString& strURL);
152 bool ShowURL(const wxString& strURL);
153 // If prefix is TRUE, add file:// to beginning
154 bool QualifyDocURL(wxString &strURL, bool prefix = TRUE);
156 bool GenerateHeaders();
161 // A standalone method for generating a build tree without saving first
162 bool GenerateBuildTree();
163 // Can we generate the build tree yet?
164 bool CanGenerateBuildTree() ;
166 void SelectTemplate (const wxString& newTemplate, const wxString& newTemplateVersion);
167 void SelectHardware (const wxString& newTemplate);
168 void SelectPackages ();
169 void RegenerateData();
170 bool UpdateBuildInfo(bool bFirstTime=FALSE);
171 int GetTestExeNames (wxArrayString& arTestExes, wxArrayString& arMissing) ;
172 bool SaveMemoryMap();
174 bool SwitchMemoryLayout (bool bNewTargetPlatform);
175 bool NewMemoryLayout (const wxString &strPrefix);
177 // Find the ecConfigItem referencing the given CdlValuable
178 ecConfigItem * Find (CdlValuable v);
179 ecConfigItem * Find(const wxString & strWhat, ecWhereType where = ecInMacro);
181 enum GlobalConflictOutcome {OK,Cancel,NotDone};
183 GlobalConflictOutcome ResolveGlobalConflicts(wxList *parConflictsOfInterest=NULL);
184 bool CheckConflictsBeforeSave();
185 void LogConflicts (const std::list<CdlConflict> & conflicts);
186 void UpdateFailingRuleCount();
188 bool SetValue(ecConfigItem &ti, long nValue, CdlTransaction transaction = NULL);
189 bool SetValue(ecConfigItem &ti, const wxString &strValue, CdlTransaction transaction = NULL);
190 bool SetValue (ecConfigItem &ti, double dValue, CdlTransaction transaction = NULL);
191 bool SetEnabled(ecConfigItem &ti, bool bEnabled, CdlTransaction transaction = NULL);
193 // Rebuild the .hhc, .hhp, .hhk files and reinitialize the help controller
194 bool RebuildHelpIndex(bool force = TRUE);
197 CdlPackagesDatabase m_CdlPkgData;
198 CdlInterpreter m_CdlInterp;
199 CdlConfiguration m_CdlConfig;
200 wxString m_templateVersion;
201 ecFileName m_strPackagesDir;
202 wxString m_strCdlErrorMessage;
203 wxString m_strMemoryLayoutFolder;
204 wxString m_strLinkerScriptFolder;
205 ecFileName m_strBuildTree;
206 ecFileName m_strInstallTree;
208 CdlBuildInfo m_BuildInfo;
210 // This data supports communication of information to the failing rules dialog invoked by CdlGlobalInferenceHandler():
211 GlobalConflictOutcome m_ConflictsOutcome;
212 wxList m_arConflictsOfInterest; // used by CRulesView::OnResolve (TODO change comment)
215 ecFileName m_strRepository;
216 bool m_bRepositoryOpen;
220 wxString m_strSelectedSection;
221 wxString m_strSelectedRegion;
227 // _ECOS_CONFIGTOOLDOC_H_