3 # An EDK II Build System Framework Database Utility maintains FrameworkDatabase.db
4 # settings in an EDK II Workspace.
6 import wx
, os
, sys
, copy
7 from EdkIIWorkspace
import *
9 class FrameworkDatabaseModel(EdkIIWorkspace
):
11 self
.WorkspaceStatus
= EdkIIWorkspace
.__init
__(self
)
13 self
.OriginalDatabase
= {}
15 def AddFile (self
, DirName
, FileName
, FileType
, Enabled
):
17 FileName
= os
.path
.join(DirName
,FileName
)
18 if FileType
== 'Package':
19 Header
= self
.XmlParseFileSection (FileName
, 'SpdHeader')
20 Name
= XmlElement (Header
, '/SpdHeader/PackageName')
21 Version
= XmlElement (Header
, '/SpdHeader/Version')
22 elif FileType
== 'Platform':
23 Header
= self
.XmlParseFileSection (FileName
, 'PlatformHeader')
24 Name
= XmlElement (Header
, '/PlatformHeader/PlatformName')
25 Version
= XmlElement (Header
, '/PlatformHeader/Version')
28 FileName
= FileName
.replace('\\','/')
29 if Name
== '' and Version
== '':
36 UiName
= Name
+ ' [' + Version
+ ']'
37 self
.Database
[FileType
][OtherType
]['PossibleSettings'].pop(FileName
, None)
38 self
.Database
[FileType
][OtherType
]['EnabledSettings'].pop(FileName
, None)
39 self
.Database
[FileType
][ValidType
]['PossibleSettings'][FileName
] = UiName
41 self
.Database
[FileType
][ValidType
]['EnabledSettings'][FileName
] = UiName
45 self
.Database
['Platform'] = {'Valid': {'PossibleSettings':{}, 'EnabledSettings':{}},'Invalid': {'PossibleSettings':{}, 'EnabledSettings':{}}}
46 self
.Database
['Package'] = {'Valid': {'PossibleSettings':{}, 'EnabledSettings':{}},'Invalid': {'PossibleSettings':{}, 'EnabledSettings':{}}}
48 def RevertModel(self
):
49 self
.Database
= copy
.deepcopy(self
.OriginalDatabase
)
51 def RescanModel(self
):
53 self
.Fd
= self
.XmlParseFile ('Tools/Conf/FrameworkDatabase.db')
54 PackageList
= XmlList (self
.Fd
, '/FrameworkDatabase/PackageList/Filename')
55 for File
in PackageList
:
56 SpdFileName
= XmlElementData(File
)
57 self
.AddFile ('', SpdFileName
, 'Package', True)
58 PlatformList
= XmlList (self
.Fd
, '/FrameworkDatabase/PlatformList/Filename')
59 for File
in PlatformList
:
60 FpdFileName
= XmlElementData(File
)
61 self
.AddFile ('', FpdFileName
, 'Platform', True)
62 self
.OriginalDatabase
= copy
.deepcopy(self
.Database
)
64 def RefreshModel(self
):
65 Temp
= copy
.deepcopy(self
.Database
)
66 for FileType
in ['Package','Platform']:
67 for Valid
in ['Valid','Invalid']:
68 for Item
in Temp
[FileType
][Valid
]['PossibleSettings']:
69 self
.AddFile('',Item
, FileType
, Item
in Temp
[FileType
][Valid
]['EnabledSettings'])
72 def ModelModified(self
):
73 if self
.Database
['Package']['Valid']['EnabledSettings'] != self
.OriginalDatabase
['Package']['Valid']['EnabledSettings']:
75 if self
.Database
['Package']['Invalid']['EnabledSettings'] != self
.OriginalDatabase
['Package']['Invalid']['EnabledSettings']:
77 if self
.Database
['Platform']['Valid']['EnabledSettings'] != self
.OriginalDatabase
['Platform']['Valid']['EnabledSettings']:
79 if self
.Database
['Platform']['Invalid']['EnabledSettings'] != self
.OriginalDatabase
['Platform']['Invalid']['EnabledSettings']:
83 def SaveModel(self
, Filename
='Tools/Conf/FrameworkDatabase.db'):
84 EnabledList
= self
.Database
['Package']['Valid']['EnabledSettings'].keys()
85 EnabledList
+= self
.Database
['Package']['Invalid']['EnabledSettings'].keys()
86 PackageList
= XmlList (self
.Fd
, '/FrameworkDatabase/PackageList/Filename')
87 for File
in PackageList
:
88 SpdFileName
= XmlElementData(File
)
89 if SpdFileName
in EnabledList
:
90 EnabledList
.remove(SpdFileName
)
92 XmlRemoveElement(File
)
94 ParentNode
= XmlList (self
.Fd
, '/FrameworkDatabase/PackageList')[0]
95 for SpdFileName
in EnabledList
:
96 XmlAppendChildElement(ParentNode
, u
'Filename', SpdFileName
)
98 EnabledList
= self
.Database
['Platform']['Valid']['EnabledSettings'].keys()
99 EnabledList
+= self
.Database
['Platform']['Invalid']['EnabledSettings'].keys()
100 PlatformList
= XmlList (self
.Fd
, '/FrameworkDatabase/PlatformList/Filename')
101 for File
in PlatformList
:
102 FpdFileName
= XmlElementData(File
)
103 if FpdFileName
in EnabledList
:
104 EnabledList
.remove(FpdFileName
)
106 XmlRemoveElement(File
)
108 ParentNode
= XmlList (self
.Fd
, '/FrameworkDatabase/PlatformList')[0]
109 for FpdFileName
in EnabledList
:
110 XmlAppendChildElement(ParentNode
, u
'Filename', FpdFileName
)
112 self
.XmlSaveFile (self
.Fd
, Filename
)
113 self
.OriginalDatabase
= copy
.deepcopy(self
.Database
)
115 def CloseModel(self
):
118 class Frame(wx
.Frame
):
120 wx
.Frame
.__init
__(self
,None,-1,'EDK II Build System Framework Database Utility')
121 panel
= wx
.Panel(self
, style
=wx
.SUNKEN_BORDER | wx
.TAB_TRAVERSAL
)
122 wx
.HelpProvider_Set(wx
.SimpleHelpProvider())
124 self
.Model
= FrameworkDatabaseModel()
130 "The set of packages that are active in the current WORKSPACE."
133 PlatformsHelpText
= (
134 "The set of platforms that are active in the current WORKSPACE."
137 InvalidPackagesHelpText
= (
138 "The set of packages that are in Framework Database, but not in the current WORKSPACE."
141 InvalidPlatformsHelpText
= (
142 "The set of platforms that are in Framework Database, but not in the current WORKSPACE."
148 self
.StatusBar
= self
.CreateStatusBar()
153 MenuBar
= wx
.MenuBar()
156 NewMenuItem
= FileMenu
.Append(-1, "&New\tCtrl+N", "New FrameworkDatabase.db")
157 SaveMenuItem
= FileMenu
.Append(-1, "&Save\tCtrl+S", "Save FramdworkDatabase.db")
158 SaveAsMenuItem
= FileMenu
.Append(-1, "Save &As...", "Save FrameworkDatabase.db as...")
159 RevertMenuItem
= FileMenu
.Append(-1, "&Revert", "Revert to the original FrameworkDatabase.db")
160 ScanMenuItem
= FileMenu
.Append(-1, "Scan &WORKSPACE\tCtrl+W", "Scan WORKSPACE for additional packages and platforms")
161 ScanAndSyncMenuItem
= FileMenu
.Append(-1, "Scan &WORKSPACE and Sync\tCtrl+W", "Scan WORKSPACE for additional packages and platforms and sync FramdworkDatabase.db")
162 ExitMenuItem
= FileMenu
.Append(-1, "E&xit\tAlt+F4", "Exit Framework Database Tool")
163 MenuBar
.Append(FileMenu
, "&File")
164 self
.Bind(wx
.EVT_MENU
, self
.OnSaveClick
, SaveMenuItem
)
165 self
.Bind(wx
.EVT_MENU
, self
.OnSaveAsClick
, SaveAsMenuItem
)
166 self
.Bind(wx
.EVT_MENU
, self
.OnRevertClick
, RevertMenuItem
)
167 self
.Bind(wx
.EVT_MENU
, self
.OnScanClick
, ScanMenuItem
)
168 self
.Bind(wx
.EVT_MENU
, self
.OnScanAndSyncClick
, ScanAndSyncMenuItem
)
169 self
.Bind(wx
.EVT_MENU
, self
.OnExitClick
, ExitMenuItem
)
172 SelectAllPlatformsMenuItem
= EditMenu
.Append (-1, "Select All Platforms", "Select all platforms")
173 ClearAllPlatformsMenuItem
= EditMenu
.Append (-1, "Clear All Platforms", "Clear all platforms")
174 SelectAllPackagesMenuItem
= EditMenu
.Append (-1, "Select All Packages", "Select all packages")
175 ClearAllPackagesMenuItem
= EditMenu
.Append (-1, "Clear All Packages", "Clear all packages")
176 SelectAllInvalidPlatformsMenuItem
= EditMenu
.Append (-1, "Select All Invalid Platforms", "Select all invalid platforms")
177 ClearAllInvalidPlatformsMenuItem
= EditMenu
.Append (-1, "Clear All Invalid Platforms", "Clear all invalid platforms")
178 SelectAllInvalidPackagesMenuItem
= EditMenu
.Append (-1, "Select All Invalid Packages", "Select all invalid packages")
179 ClearAllInvalidPackagesMenuItem
= EditMenu
.Append (-1, "Clear All Invalid Packages", "Clear all invalid packages")
180 MenuBar
.Append(EditMenu
, "&Edit")
181 self
.Bind(wx
.EVT_MENU
, self
.OnSelectAllPlatformsClick
, SelectAllPlatformsMenuItem
)
182 self
.Bind(wx
.EVT_MENU
, self
.OnClearAllPlatformsClick
, ClearAllPlatformsMenuItem
)
183 self
.Bind(wx
.EVT_MENU
, self
.OnSelectAllPackagesClick
, SelectAllPackagesMenuItem
)
184 self
.Bind(wx
.EVT_MENU
, self
.OnClearAllPackagesClick
, ClearAllPackagesMenuItem
)
185 self
.Bind(wx
.EVT_MENU
, self
.OnSelectAllInvalidPlatformsClick
, SelectAllInvalidPlatformsMenuItem
)
186 self
.Bind(wx
.EVT_MENU
, self
.OnClearAllInvalidPlatformsClick
, ClearAllInvalidPlatformsMenuItem
)
187 self
.Bind(wx
.EVT_MENU
, self
.OnSelectAllInvalidPackagesClick
, SelectAllInvalidPackagesMenuItem
)
188 self
.Bind(wx
.EVT_MENU
, self
.OnClearAllInvalidPackagesClick
, ClearAllInvalidPackagesMenuItem
)
191 RefreshMenuItem
= ViewMenu
.Append (-1, "&Refresh\tF5", "Rescan FrameworkDatabase.db")
192 ShowToolBarMenuItem
= ViewMenu
.AppendCheckItem (-1, "Show &Toolbar", "Shows or hides the toolbar")
193 ShowToolBarMenuItem
.Check(True)
194 MenuBar
.Append(ViewMenu
, "&View")
195 self
.Bind(wx
.EVT_MENU
, self
.OnViewRefreshClick
, RefreshMenuItem
)
196 self
.Bind(wx
.EVT_MENU
, self
.OnShowToolBarClick
, ShowToolBarMenuItem
)
199 AboutMenuItem
= HelpMenu
.Append (-1, "&About...", "About")
200 MenuBar
.Append(HelpMenu
, "&Help")
201 self
.Bind(wx
.EVT_MENU
, self
.OnAboutClick
, AboutMenuItem
)
203 self
.SetMenuBar (MenuBar
)
208 self
.ShowToolBar
= False
209 self
.OnShowToolBarClick(self
)
212 # Target, ToolChain, and Arch Check List Boxes
214 PackagesLabel
= wx
.StaticText(panel
, -1, 'Packages')
215 PackagesLabel
.SetFont(wx
.Font(12, wx
.FONTFAMILY_DEFAULT
, wx
.NORMAL
, wx
.FONTWEIGHT_BOLD
))
216 PackagesLabel
.SetHelpText(PackagesHelpText
)
218 PlatformsLabel
= wx
.StaticText(panel
, -1, 'Platforms')
219 PlatformsLabel
.SetFont(wx
.Font(12, wx
.FONTFAMILY_DEFAULT
, wx
.NORMAL
, wx
.FONTWEIGHT_BOLD
))
220 PlatformsLabel
.SetHelpText(PlatformsHelpText
)
225 self
.SelectAllPackagesButton
= wx
.Button(panel
, -1, 'Select All')
226 self
.ClearAllPackagesButton
= wx
.Button(panel
, -1, 'Clear All')
227 self
.SelectAllPackagesButton
.Bind (wx
.EVT_BUTTON
, self
.OnSelectAllPackagesClick
)
228 self
.ClearAllPackagesButton
.Bind (wx
.EVT_BUTTON
, self
.OnClearAllPackagesClick
)
230 self
.PackagesCheckListBox
= wx
.CheckListBox(panel
, -1)
231 self
.PackagesCheckListBox
.Bind(wx
.EVT_CHECKLISTBOX
, self
.OnPackagesCheckListClick
)
232 self
.PackagesCheckListBox
.Bind(wx
.EVT_SET_FOCUS
, self
.OnPackagesSetFocus
)
233 self
.PackagesCheckListBox
.Bind(wx
.EVT_KILL_FOCUS
, self
.OnPackagesKillFocus
)
234 self
.PackagesCheckListBox
.SetHelpText(PackagesHelpText
)
237 self
.SelectAllPlatformsButton
= wx
.Button(panel
, -1, 'Select All')
238 self
.ClearAllPlatformsButton
= wx
.Button(panel
, -1, 'Clear All')
239 self
.SelectAllPlatformsButton
.Bind(wx
.EVT_BUTTON
, self
.OnSelectAllPlatformsClick
)
240 self
.ClearAllPlatformsButton
.Bind (wx
.EVT_BUTTON
, self
.OnClearAllPlatformsClick
)
242 self
.PlatformsCheckListBox
= wx
.CheckListBox(panel
, -1)
243 self
.PlatformsCheckListBox
.Bind(wx
.EVT_CHECKLISTBOX
, self
.OnPlatformsCheckListClick
)
244 self
.PlatformsCheckListBox
.Bind(wx
.EVT_SET_FOCUS
, self
.OnPlatformsSetFocus
)
245 self
.PlatformsCheckListBox
.Bind(wx
.EVT_KILL_FOCUS
, self
.OnPlatformsKillFocus
)
246 self
.PlatformsCheckListBox
.SetHelpText(PlatformsHelpText
)
248 InvalidPackagesLabel
= wx
.StaticText(panel
, -1, 'Invalid Packages')
249 InvalidPackagesLabel
.SetFont(wx
.Font(12, wx
.FONTFAMILY_DEFAULT
, wx
.NORMAL
, wx
.FONTWEIGHT_BOLD
))
250 InvalidPackagesLabel
.SetHelpText(InvalidPackagesHelpText
)
252 InvalidPlatformsLabel
= wx
.StaticText(panel
, -1, 'Invalid Platforms')
253 InvalidPlatformsLabel
.SetFont(wx
.Font(12, wx
.FONTFAMILY_DEFAULT
, wx
.NORMAL
, wx
.FONTWEIGHT_BOLD
))
254 InvalidPlatformsLabel
.SetHelpText(InvalidPlatformsHelpText
)
256 self
.SelectAllInvalidPackagesButton
= wx
.Button(panel
, -1, 'Select All')
257 self
.ClearAllInvalidPackagesButton
= wx
.Button(panel
, -1, 'Clear All')
258 self
.SelectAllInvalidPackagesButton
.Bind (wx
.EVT_BUTTON
, self
.OnSelectAllInvalidPackagesClick
)
259 self
.ClearAllInvalidPackagesButton
.Bind (wx
.EVT_BUTTON
, self
.OnClearAllInvalidPackagesClick
)
261 self
.InvalidPackagesCheckListBox
= wx
.CheckListBox(panel
, -1)
262 self
.InvalidPackagesCheckListBox
.Bind(wx
.EVT_CHECKLISTBOX
, self
.OnInvalidPackagesCheckListClick
)
263 self
.InvalidPackagesCheckListBox
.Bind(wx
.EVT_SET_FOCUS
, self
.OnInvalidPackagesSetFocus
)
264 self
.InvalidPackagesCheckListBox
.Bind(wx
.EVT_KILL_FOCUS
, self
.OnInvalidPackagesKillFocus
)
265 self
.InvalidPackagesCheckListBox
.SetHelpText(PackagesHelpText
)
267 self
.SelectAllInvalidPlatformsButton
= wx
.Button(panel
, -1, 'Select All')
268 self
.ClearAllInvalidPlatformsButton
= wx
.Button(panel
, -1, 'Clear All')
269 self
.SelectAllInvalidPlatformsButton
.Bind(wx
.EVT_BUTTON
, self
.OnSelectAllInvalidPlatformsClick
)
270 self
.ClearAllInvalidPlatformsButton
.Bind (wx
.EVT_BUTTON
, self
.OnClearAllInvalidPlatformsClick
)
272 self
.InvalidPlatformsCheckListBox
= wx
.CheckListBox(panel
, -1)
273 self
.InvalidPlatformsCheckListBox
.Bind(wx
.EVT_CHECKLISTBOX
, self
.OnInvalidPlatformsCheckListClick
)
274 self
.InvalidPlatformsCheckListBox
.Bind(wx
.EVT_SET_FOCUS
, self
.OnInvalidPlatformsSetFocus
)
275 self
.InvalidPlatformsCheckListBox
.Bind(wx
.EVT_KILL_FOCUS
, self
.OnInvalidPlatformsKillFocus
)
276 self
.InvalidPlatformsCheckListBox
.SetHelpText(PlatformsHelpText
)
279 # Define layout using sizers
281 self
.mainSizer
= wx
.BoxSizer(wx
.VERTICAL
)
283 listSizer
= wx
.GridBagSizer(hgap
=5, vgap
=5)
284 listSizer
.Add(PackagesLabel
, pos
=(0,0), span
=(1,2), flag
=wx
.ALIGN_CENTER
)
285 listSizer
.Add(PlatformsLabel
, pos
=(0,2), span
=(1,2), flag
=wx
.ALIGN_CENTER
)
286 listSizer
.Add(self
.SelectAllPackagesButton
, pos
=(1,0), flag
=wx
.ALIGN_CENTER
)
287 listSizer
.Add(self
.ClearAllPackagesButton
, pos
=(1,1), flag
=wx
.ALIGN_CENTER
)
288 listSizer
.Add(self
.SelectAllPlatformsButton
, pos
=(1,2), flag
=wx
.ALIGN_CENTER
)
289 listSizer
.Add(self
.ClearAllPlatformsButton
, pos
=(1,3), flag
=wx
.ALIGN_CENTER
)
290 listSizer
.Add(self
.PackagesCheckListBox
, pos
=(2,0), span
=(1,2), flag
=wx
.ALL | wx
.EXPAND
)
291 listSizer
.Add(self
.PlatformsCheckListBox
, pos
=(2,2), span
=(1,2), flag
=wx
.ALL | wx
.EXPAND
)
293 listSizer
.Add(InvalidPackagesLabel
, pos
=(3,0), span
=(1,2), flag
=wx
.ALIGN_CENTER
)
294 listSizer
.Add(InvalidPlatformsLabel
, pos
=(3,2), span
=(1,2), flag
=wx
.ALIGN_CENTER
)
295 listSizer
.Add(self
.SelectAllInvalidPackagesButton
, pos
=(4,0), flag
=wx
.ALIGN_CENTER
)
296 listSizer
.Add(self
.ClearAllInvalidPackagesButton
, pos
=(4,1), flag
=wx
.ALIGN_CENTER
)
297 listSizer
.Add(self
.SelectAllInvalidPlatformsButton
, pos
=(4,2), flag
=wx
.ALIGN_CENTER
)
298 listSizer
.Add(self
.ClearAllInvalidPlatformsButton
, pos
=(4,3), flag
=wx
.ALIGN_CENTER
)
299 listSizer
.Add(self
.InvalidPackagesCheckListBox
, pos
=(5,0), span
=(1,2), flag
=wx
.ALL | wx
.EXPAND
)
300 listSizer
.Add(self
.InvalidPlatformsCheckListBox
, pos
=(5,2), span
=(1,2), flag
=wx
.ALL | wx
.EXPAND
)
302 listSizer
.AddGrowableRow(2)
303 listSizer
.AddGrowableRow(5)
304 listSizer
.AddGrowableCol(0)
305 listSizer
.AddGrowableCol(1)
306 listSizer
.AddGrowableCol(2)
307 listSizer
.AddGrowableCol(3)
309 self
.mainSizer
.Add (listSizer
, wx
.EXPAND | wx
.ALL
, wx
.EXPAND | wx
.ALL
, 10)
311 panel
.SetSizer (self
.mainSizer
)
313 self
.OnViewRefreshClick(self
)
315 def CheckListFocus(self
, CheckListBox
, Set
):
317 while Index
< CheckListBox
.GetCount():
318 CheckListBox
.SetSelection(Index
, False)
320 if Set
and CheckListBox
.GetCount() > 0:
321 CheckListBox
.SetSelection(0, True)
323 def CheckListClick(self
, CheckListBox
, Database
):
325 Database
['EnabledSettings'] = {}
326 while Index
< CheckListBox
.GetCount():
327 if CheckListBox
.IsChecked(Index
):
328 for Item
in Database
['PossibleSettings']:
329 if Database
['PossibleSettings'][Item
] == CheckListBox
.GetString(Index
):
330 Database
['EnabledSettings'][Item
] = Database
['PossibleSettings'][Item
]
333 def OnPackagesCheckListClick(self
, event
):
334 self
.CheckListClick(self
.PackagesCheckListBox
, self
.Model
.Database
['Package']['Valid'])
336 def OnPackagesSetFocus(self
, event
):
337 self
.CheckListFocus(self
.PackagesCheckListBox
, True)
339 def OnPackagesKillFocus(self
, event
):
340 self
.CheckListFocus(self
.PackagesCheckListBox
, False)
342 def OnPlatformsCheckListClick(self
, event
):
343 self
.CheckListClick(self
.PlatformsCheckListBox
, self
.Model
.Database
['Platform']['Valid'])
345 def OnPlatformsSetFocus(self
, event
):
346 self
.CheckListFocus(self
.PlatformsCheckListBox
, True)
348 def OnPlatformsKillFocus(self
, event
):
349 self
.CheckListFocus(self
.PlatformsCheckListBox
, False)
351 def OnInvalidPackagesCheckListClick(self
, event
):
352 self
.CheckListClick(self
.InvalidPackagesCheckListBox
, self
.Model
.Database
['Package']['Invalid'])
354 def OnInvalidPackagesSetFocus(self
, event
):
355 self
.CheckListFocus(self
.InvalidPackagesCheckListBox
, True)
357 def OnInvalidPackagesKillFocus(self
, event
):
358 self
.CheckListFocus(self
.InvalidPackagesCheckListBox
, False)
360 def OnInvalidPlatformsCheckListClick(self
, event
):
361 self
.CheckListClick(self
.InvalidPlatformsCheckListBox
, self
.Model
.Database
['Platform']['Invalid'])
363 def OnInvalidPlatformsSetFocus(self
, event
):
364 self
.CheckListFocus(self
.InvalidPlatformsCheckListBox
, True)
366 def OnInvalidPlatformsKillFocus(self
, event
):
367 self
.CheckListFocus(self
.InvalidPlatformsCheckListBox
, False)
369 def OnRevertClick(self
, event
):
370 self
.Model
.RevertModel()
371 self
.StatusBar
.SetFocus()
372 self
.OnRefreshClick(self
)
374 def RefreshCheckListBox(self
, CheckListBox
, SelectAllButton
, ClearAllButton
, Database
):
376 for Item
in Database
['PossibleSettings']:
377 NameList
.append(Database
['PossibleSettings'][Item
])
379 CheckListBox
.Set(NameList
)
382 while Index
< CheckListBox
.GetCount():
383 String
= CheckListBox
.GetString(Index
)
384 if len(String
) > len(MaximumString
):
385 MaximumString
= String
387 for Item
in Database
['EnabledSettings']:
388 if String
== Database
['EnabledSettings'][Item
]:
391 CheckListBox
.Check(Index
, True)
393 CheckListBox
.Check(Index
, False)
395 Extents
= CheckListBox
.GetFullTextExtent (MaximumString
)
396 CheckListBox
.SetMinSize((Extents
[0] + 30,(CheckListBox
.GetCount()+2) * (Extents
[1]+Extents
[2])))
398 CheckListBox
.Disable()
399 SelectAllButton
.Disable()
400 ClearAllButton
.Disable()
402 CheckListBox
.Enable()
403 SelectAllButton
.Enable()
404 ClearAllButton
.Enable()
406 def OnRefreshClick(self
, event
):
407 self
.Model
.RefreshModel()
408 self
.RefreshCheckListBox (self
.PackagesCheckListBox
, self
.SelectAllPackagesButton
, self
.ClearAllPackagesButton
, self
.Model
.Database
['Package']['Valid'])
409 self
.RefreshCheckListBox (self
.PlatformsCheckListBox
, self
.SelectAllPlatformsButton
, self
.ClearAllPlatformsButton
, self
.Model
.Database
['Platform']['Valid'])
410 self
.RefreshCheckListBox (self
.InvalidPackagesCheckListBox
, self
.SelectAllInvalidPackagesButton
, self
.ClearAllInvalidPackagesButton
, self
.Model
.Database
['Package']['Invalid'])
411 self
.RefreshCheckListBox (self
.InvalidPlatformsCheckListBox
, self
.SelectAllInvalidPlatformsButton
, self
.ClearAllInvalidPlatformsButton
, self
.Model
.Database
['Platform']['Invalid'])
412 self
.mainSizer
.SetSizeHints(self
)
413 self
.mainSizer
.Fit(self
)
416 def OnViewRefreshClick(self
, event
):
417 self
.Model
.RescanModel()
418 self
.StatusBar
.SetFocus()
419 self
.OnRefreshClick(self
)
421 def AddTool (self
, Handler
, ArtId
, Label
, HelpText
):
422 Tool
= self
.ToolBar
.AddSimpleTool(
424 wx
.ArtProvider
.GetBitmap(ArtId
, wx
.ART_TOOLBAR
, self
.ToolSize
),
428 self
.Bind(wx
.EVT_MENU
, Handler
, Tool
)
430 def OnShowToolBarClick(self
, event
):
432 self
.ShowToolBar
= False
433 self
.ToolBar
.Destroy()
435 self
.ShowToolBar
= True
436 self
.ToolBar
= self
.CreateToolBar()
437 self
.ToolSize
= (24,24)
438 self
.ToolBar
.SetToolBitmapSize(self
.ToolSize
)
439 self
.AddTool (self
.OnNewClick
, wx
.ART_NEW
, "New", "New FrameworkDatabase.db")
440 self
.AddTool (self
.OnScanAndSyncClick
, wx
.ART_HARDDISK
, "Scan WORKSPACE and Sync", "Scan WORKSPACE for new Packages and Platforms and sync FrameworkDatabase.db")
441 self
.AddTool (self
.OnSaveClick
, wx
.ART_FILE_SAVE
, "Save", "Save FrameworkDatabase.db")
442 self
.AddTool (self
.OnSaveAsClick
, wx
.ART_FILE_SAVE_AS
, "Save As...", "Save FrameworkDatabase.db as...")
443 self
.AddTool (self
.OnRevertClick
, wx
.ART_UNDO
, "Revert", "Revert to original FrameworkDatabase.db")
444 self
.AddTool (self
.OnHelpClick
, wx
.ART_HELP
, "Help", "Context Sensitive Help")
445 self
.AddTool (self
.OnExitClick
, wx
.ART_QUIT
, "Exit", "Exit EDK II Build System Framework Database Utility")
446 self
.ToolBar
.Realize()
448 def OnNewClick(self
, event
):
449 self
.Model
.NewModel()
450 self
.OnRefreshClick(self
)
452 def ScanDirectory(self
, Data
, DirName
, FilesInDir
):
453 WorkspaceDirName
= self
.Model
.WorkspaceRelativePath(DirName
)
454 self
.StatusBar
.SetStatusText('Scanning: ' + WorkspaceDirName
)
456 for File
in FilesInDir
:
458 RemoveList
.insert(0, File
)
459 for File
in RemoveList
:
460 FilesInDir
.remove(File
)
461 for File
in FilesInDir
:
462 if os
.path
.splitext(File
)[1].lower() == '.spd':
463 self
.Model
.AddFile (WorkspaceDirName
, File
, 'Package', False)
464 self
.OnRefreshClick(self
)
465 if os
.path
.splitext(File
)[1].lower() == '.fpd':
466 self
.Model
.AddFile (WorkspaceDirName
, File
, 'Platform', False)
467 self
.OnRefreshClick(self
)
469 def OnScanClick(self
, event
):
470 os
.path
.walk(self
.Model
.WorkspaceFile(''), self
.ScanDirectory
, None)
471 self
.StatusBar
.SetStatusText('Scanning: Complete')
472 self
.StatusBar
.SetFocus()
473 self
.OnRefreshClick(self
)
475 def OnScanAndSyncClick(self
, event
):
476 self
.OnSelectAllPackagesClick(self
)
477 self
.OnSelectAllPlatformsClick(self
)
478 self
.OnClearAllInvalidPackagesClick(self
)
479 self
.OnClearAllInvalidPlatformsClick(self
)
480 self
.OnScanClick(self
)
481 self
.OnSelectAllPackagesClick(self
)
482 self
.OnSelectAllPlatformsClick(self
)
483 self
.OnClearAllInvalidPackagesClick(self
)
484 self
.OnClearAllInvalidPlatformsClick(self
)
486 def OnSelectAllPackagesClick(self
, event
):
487 self
.Model
.Database
['Package']['Valid']['EnabledSettings'] = self
.Model
.Database
['Package']['Valid']['PossibleSettings']
488 self
.OnRefreshClick(self
)
490 def OnClearAllPackagesClick(self
, event
):
491 self
.Model
.Database
['Package']['Valid']['EnabledSettings'] = {}
492 self
.OnRefreshClick(self
)
494 def OnSelectAllPlatformsClick(self
, event
):
495 self
.Model
.Database
['Platform']['Valid']['EnabledSettings'] = self
.Model
.Database
['Platform']['Valid']['PossibleSettings']
496 self
.OnRefreshClick(self
)
498 def OnClearAllPlatformsClick(self
, event
):
499 self
.Model
.Database
['Platform']['Valid']['EnabledSettings'] = {}
500 self
.OnRefreshClick(self
)
502 def OnSelectAllInvalidPackagesClick(self
, event
):
503 self
.Model
.Database
['Package']['Invalid']['EnabledSettings'] = self
.Model
.Database
['Package']['Invalid']['PossibleSettings']
504 self
.OnRefreshClick(self
)
506 def OnClearAllInvalidPackagesClick(self
, event
):
507 self
.Model
.Database
['Package']['Invalid']['EnabledSettings'] = {}
508 self
.OnRefreshClick(self
)
510 def OnSelectAllInvalidPlatformsClick(self
, event
):
511 self
.Model
.Database
['Platform']['Invalid']['EnabledSettings'] = self
.Model
.Database
['Platform']['Invalid']['PossibleSettings']
512 self
.OnRefreshClick(self
)
514 def OnClearAllInvalidPlatformsClick(self
, event
):
515 self
.Model
.Database
['Platform']['Invalid']['EnabledSettings'] = {}
516 self
.OnRefreshClick(self
)
518 def OnSaveClick(self
, event
):
519 self
.Model
.SaveModel()
521 def OnSaveAsClick(self
, event
):
522 wildcard
= "Text Documents (*.db)|*.db|" \
523 "All files (*.*)|*.*"
524 dialog
= wx
.FileDialog (None, 'Save As', self
.Model
.WorkspaceFile('Tools/Conf'), '', wildcard
, wx
.SAVE | wx
.OVERWRITE_PROMPT
)
525 if dialog
.ShowModal() == wx
.ID_OK
:
526 FrameworkDatabaseDbFile
= self
.Model
.WorkspaceRelativePath(dialog
.GetPath())
527 if FrameworkDatabaseDbFile
!= '':
528 self
.Model
.SaveModel(FrameworkDatabaseDbFile
)
531 def OnExitClick(self
, event
):
532 if self
.Model
.ModelModified():
533 dialog
= wx
.MessageDialog(None, 'The contents have changed.\nDo you want to save changes?', 'EDK II Build System Framework Databsase Utility', style
= wx
.YES_NO | wx
.YES_DEFAULT | wx
.CANCEL | wx
.ICON_EXCLAMATION
)
534 Status
= dialog
.ShowModal()
536 if Status
== wx
.ID_YES
:
537 self
.OnSaveClick (self
)
538 elif Status
== wx
.ID_CANCEL
:
540 self
.Model
.CloseModel()
543 def OnHelpClick(self
, event
):
544 wx
.ContextHelp().BeginContextHelp()
546 def OnAboutClick(self
, event
):
547 AboutInfo
= wx
.AboutDialogInfo()
548 AboutInfo
.Name
= 'EDK II Build System Framework Database Utility'
549 AboutInfo
.Version
= '0.3'
550 AboutInfo
.Copyright
= 'Copyright (c) 2006, Intel Corporation'
551 AboutInfo
.Description
= """
552 The EDK II Build System Framework Database Utility maintains FrameworkDatabase.db
553 settings in an EDK II Workspace."""
554 AboutInfo
.WebSite
= ("http://tianocore.org", "Tiano Core home page")
555 AboutInfo
.License
= """
556 All rights reserved. This program and the accompanying materials are
557 licensed and made available under the terms and conditions of the BSD
558 License which accompanies this distribution. The full text of the
559 license may be found at http://opensource.org/licenses/bsd-license.php
561 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS"
562 BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND,
563 EITHER EXPRESS OR IMPLIED."""
564 if self
.Model
.Icon
!= None:
565 AboutInfo
.Icon
= self
.Model
.Icon
566 wx
.AboutBox(AboutInfo
)
568 if __name__
== '__main__':
569 app
= wx
.PySimpleApp()