Import BaseMemoryLibMmx;
[mirror_edk2.git] / Tools / Python / Fd.py
CommitLineData
8d4243f1 1#!/usr/bin/env python
2
3b7a53b6 3# Copyright (c) 2007, Intel Corporation
4# All rights reserved. This program and the accompanying materials
5# are licensed and made available under the terms and conditions of the BSD License
6# which accompanies this distribution. The full text of the license may be found at
7# http://opensource.org/licenses/bsd-license.php
8#
9# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
11
12"""An EDK II Build System Framework Database Utility maintains
13FrameworkDatabase.db settings in an EDK II Workspace."""
8d4243f1 14
15import wx, os, sys, copy
16from EdkIIWorkspace import *
17
18class FrameworkDatabaseModel(EdkIIWorkspace):
19 def __init__(self):
20 self.WorkspaceStatus = EdkIIWorkspace.__init__(self)
21 self.Database = {}
22 self.OriginalDatabase = {}
23
24 def AddFile (self, DirName, FileName, FileType, Enabled):
25 if DirName != '':
26 FileName = os.path.join(DirName,FileName)
27 if FileType == 'Package':
28 Header = self.XmlParseFileSection (FileName, 'SpdHeader')
29 Name = XmlElement (Header, '/SpdHeader/PackageName')
30 Version = XmlElement (Header, '/SpdHeader/Version')
31 elif FileType == 'Platform':
32 Header = self.XmlParseFileSection (FileName, 'PlatformHeader')
33 Name = XmlElement (Header, '/PlatformHeader/PlatformName')
34 Version = XmlElement (Header, '/PlatformHeader/Version')
35 else:
36 return
37 FileName = FileName.replace('\\','/')
38 if Name == '' and Version == '':
39 ValidType = 'Invalid'
40 OtherType = 'Valid'
41 UiName = FileName
42 else:
43 ValidType = 'Valid'
44 OtherType = 'Invalid'
45 UiName = Name + ' [' + Version + ']'
46 self.Database[FileType][OtherType]['PossibleSettings'].pop(FileName, None)
47 self.Database[FileType][OtherType]['EnabledSettings'].pop(FileName, None)
48 self.Database[FileType][ValidType]['PossibleSettings'][FileName] = UiName
49 if Enabled:
50 self.Database[FileType][ValidType]['EnabledSettings'][FileName] = UiName
51 return
52
53 def NewModel(self):
54 self.Database['Platform'] = {'Valid': {'PossibleSettings':{}, 'EnabledSettings':{}},'Invalid': {'PossibleSettings':{}, 'EnabledSettings':{}}}
55 self.Database['Package'] = {'Valid': {'PossibleSettings':{}, 'EnabledSettings':{}},'Invalid': {'PossibleSettings':{}, 'EnabledSettings':{}}}
56
57 def RevertModel(self):
58 self.Database = copy.deepcopy(self.OriginalDatabase)
59
60 def RescanModel(self):
61 self.NewModel()
62 self.Fd = self.XmlParseFile ('Tools/Conf/FrameworkDatabase.db')
63 PackageList = XmlList (self.Fd, '/FrameworkDatabase/PackageList/Filename')
64 for File in PackageList:
65 SpdFileName = XmlElementData(File)
66 self.AddFile ('', SpdFileName, 'Package', True)
67 PlatformList = XmlList (self.Fd, '/FrameworkDatabase/PlatformList/Filename')
68 for File in PlatformList:
69 FpdFileName = XmlElementData(File)
70 self.AddFile ('', FpdFileName, 'Platform', True)
71 self.OriginalDatabase = copy.deepcopy(self.Database)
72
73 def RefreshModel(self):
74 Temp = copy.deepcopy(self.Database)
75 for FileType in ['Package','Platform']:
76 for Valid in ['Valid','Invalid']:
77 for Item in Temp[FileType][Valid]['PossibleSettings']:
78 self.AddFile('',Item, FileType, Item in Temp[FileType][Valid]['EnabledSettings'])
79 return True
80
81 def ModelModified(self):
82 if self.Database['Package']['Valid']['EnabledSettings'] != self.OriginalDatabase['Package']['Valid']['EnabledSettings']:
83 return True
84 if self.Database['Package']['Invalid']['EnabledSettings'] != self.OriginalDatabase['Package']['Invalid']['EnabledSettings']:
85 return True
86 if self.Database['Platform']['Valid']['EnabledSettings'] != self.OriginalDatabase['Platform']['Valid']['EnabledSettings']:
87 return True
88 if self.Database['Platform']['Invalid']['EnabledSettings'] != self.OriginalDatabase['Platform']['Invalid']['EnabledSettings']:
89 return True
90 return False
91
92 def SaveModel(self, Filename='Tools/Conf/FrameworkDatabase.db'):
93 EnabledList = self.Database['Package']['Valid']['EnabledSettings'].keys()
94 EnabledList += self.Database['Package']['Invalid']['EnabledSettings'].keys()
95 PackageList = XmlList (self.Fd, '/FrameworkDatabase/PackageList/Filename')
96 for File in PackageList:
97 SpdFileName = XmlElementData(File)
98 if SpdFileName in EnabledList:
99 EnabledList.remove(SpdFileName)
100 continue
101 XmlRemoveElement(File)
102
103 ParentNode = XmlList (self.Fd, '/FrameworkDatabase/PackageList')[0]
104 for SpdFileName in EnabledList:
105 XmlAppendChildElement(ParentNode, u'Filename', SpdFileName)
106
107 EnabledList = self.Database['Platform']['Valid']['EnabledSettings'].keys()
108 EnabledList += self.Database['Platform']['Invalid']['EnabledSettings'].keys()
109 PlatformList = XmlList (self.Fd, '/FrameworkDatabase/PlatformList/Filename')
110 for File in PlatformList:
111 FpdFileName = XmlElementData(File)
112 if FpdFileName in EnabledList:
113 EnabledList.remove(FpdFileName)
114 continue
115 XmlRemoveElement(File)
116
117 ParentNode = XmlList (self.Fd, '/FrameworkDatabase/PlatformList')[0]
118 for FpdFileName in EnabledList:
119 XmlAppendChildElement(ParentNode, u'Filename', FpdFileName)
120
121 self.XmlSaveFile (self.Fd, Filename)
122 self.OriginalDatabase = copy.deepcopy(self.Database)
123
124 def CloseModel(self):
125 pass
126
127class Frame(wx.Frame):
128 def __init__(self):
129 wx.Frame.__init__(self,None,-1,'EDK II Build System Framework Database Utility')
130 panel = wx.Panel(self, style=wx.SUNKEN_BORDER | wx.TAB_TRAVERSAL)
131 wx.HelpProvider_Set(wx.SimpleHelpProvider())
132
133 self.Model = FrameworkDatabaseModel()
134
135 #
136 # Help text
137 #
138 PackagesHelpText = (
139 "The set of packages that are active in the current WORKSPACE."
140 )
141
142 PlatformsHelpText = (
143 "The set of platforms that are active in the current WORKSPACE."
144 )
145
146 InvalidPackagesHelpText = (
147 "The set of packages that are in Framework Database, but not in the current WORKSPACE."
148 )
149
150 InvalidPlatformsHelpText = (
151 "The set of platforms that are in Framework Database, but not in the current WORKSPACE."
152 )
153
154 #
155 # Status Bar
156 #
157 self.StatusBar = self.CreateStatusBar()
158
159 #
160 # Build Menus
161 #
162 MenuBar = wx.MenuBar()
163
164 FileMenu = wx.Menu()
165 NewMenuItem = FileMenu.Append(-1, "&New\tCtrl+N", "New FrameworkDatabase.db")
166 SaveMenuItem = FileMenu.Append(-1, "&Save\tCtrl+S", "Save FramdworkDatabase.db")
167 SaveAsMenuItem = FileMenu.Append(-1, "Save &As...", "Save FrameworkDatabase.db as...")
168 RevertMenuItem = FileMenu.Append(-1, "&Revert", "Revert to the original FrameworkDatabase.db")
169 ScanMenuItem = FileMenu.Append(-1, "Scan &WORKSPACE\tCtrl+W", "Scan WORKSPACE for additional packages and platforms")
170 ScanAndSyncMenuItem = FileMenu.Append(-1, "Scan &WORKSPACE and Sync\tCtrl+W", "Scan WORKSPACE for additional packages and platforms and sync FramdworkDatabase.db")
171 ExitMenuItem = FileMenu.Append(-1, "E&xit\tAlt+F4", "Exit Framework Database Tool")
172 MenuBar.Append(FileMenu, "&File")
173 self.Bind(wx.EVT_MENU, self.OnSaveClick, SaveMenuItem)
174 self.Bind(wx.EVT_MENU, self.OnSaveAsClick, SaveAsMenuItem)
175 self.Bind(wx.EVT_MENU, self.OnRevertClick, RevertMenuItem)
176 self.Bind(wx.EVT_MENU, self.OnScanClick, ScanMenuItem)
177 self.Bind(wx.EVT_MENU, self.OnScanAndSyncClick, ScanAndSyncMenuItem)
178 self.Bind(wx.EVT_MENU, self.OnExitClick, ExitMenuItem)
179
180 EditMenu = wx.Menu()
181 SelectAllPlatformsMenuItem = EditMenu.Append (-1, "Select All Platforms", "Select all platforms")
182 ClearAllPlatformsMenuItem = EditMenu.Append (-1, "Clear All Platforms", "Clear all platforms")
183 SelectAllPackagesMenuItem = EditMenu.Append (-1, "Select All Packages", "Select all packages")
184 ClearAllPackagesMenuItem = EditMenu.Append (-1, "Clear All Packages", "Clear all packages")
185 SelectAllInvalidPlatformsMenuItem = EditMenu.Append (-1, "Select All Invalid Platforms", "Select all invalid platforms")
186 ClearAllInvalidPlatformsMenuItem = EditMenu.Append (-1, "Clear All Invalid Platforms", "Clear all invalid platforms")
187 SelectAllInvalidPackagesMenuItem = EditMenu.Append (-1, "Select All Invalid Packages", "Select all invalid packages")
188 ClearAllInvalidPackagesMenuItem = EditMenu.Append (-1, "Clear All Invalid Packages", "Clear all invalid packages")
189 MenuBar.Append(EditMenu, "&Edit")
190 self.Bind(wx.EVT_MENU, self.OnSelectAllPlatformsClick, SelectAllPlatformsMenuItem)
191 self.Bind(wx.EVT_MENU, self.OnClearAllPlatformsClick, ClearAllPlatformsMenuItem)
192 self.Bind(wx.EVT_MENU, self.OnSelectAllPackagesClick, SelectAllPackagesMenuItem)
193 self.Bind(wx.EVT_MENU, self.OnClearAllPackagesClick, ClearAllPackagesMenuItem)
194 self.Bind(wx.EVT_MENU, self.OnSelectAllInvalidPlatformsClick, SelectAllInvalidPlatformsMenuItem)
195 self.Bind(wx.EVT_MENU, self.OnClearAllInvalidPlatformsClick, ClearAllInvalidPlatformsMenuItem)
196 self.Bind(wx.EVT_MENU, self.OnSelectAllInvalidPackagesClick, SelectAllInvalidPackagesMenuItem)
197 self.Bind(wx.EVT_MENU, self.OnClearAllInvalidPackagesClick, ClearAllInvalidPackagesMenuItem)
198
199 ViewMenu = wx.Menu()
200 RefreshMenuItem = ViewMenu.Append (-1, "&Refresh\tF5", "Rescan FrameworkDatabase.db")
201 ShowToolBarMenuItem = ViewMenu.AppendCheckItem (-1, "Show &Toolbar", "Shows or hides the toolbar")
202 ShowToolBarMenuItem.Check(True)
203 MenuBar.Append(ViewMenu, "&View")
204 self.Bind(wx.EVT_MENU, self.OnViewRefreshClick, RefreshMenuItem)
205 self.Bind(wx.EVT_MENU, self.OnShowToolBarClick, ShowToolBarMenuItem)
206
207 HelpMenu = wx.Menu()
208 AboutMenuItem = HelpMenu.Append (-1, "&About...", "About")
209 MenuBar.Append(HelpMenu, "&Help")
210 self.Bind(wx.EVT_MENU, self.OnAboutClick, AboutMenuItem)
211
212 self.SetMenuBar (MenuBar)
213
214 #
215 # Build Toolbar
216 #
217 self.ShowToolBar = False
218 self.OnShowToolBarClick(self)
219
220 #
221 # Target, ToolChain, and Arch Check List Boxes
222 #
223 PackagesLabel = wx.StaticText(panel, -1, 'Packages')
224 PackagesLabel.SetFont(wx.Font(12, wx.FONTFAMILY_DEFAULT, wx.NORMAL, wx.FONTWEIGHT_BOLD))
225 PackagesLabel.SetHelpText(PackagesHelpText)
226
227 PlatformsLabel = wx.StaticText(panel, -1, 'Platforms')
228 PlatformsLabel.SetFont(wx.Font(12, wx.FONTFAMILY_DEFAULT, wx.NORMAL, wx.FONTWEIGHT_BOLD))
229 PlatformsLabel.SetHelpText(PlatformsHelpText)
230
231 #
232 # Buttons
233 #
234 self.SelectAllPackagesButton = wx.Button(panel, -1, 'Select All')
235 self.ClearAllPackagesButton = wx.Button(panel, -1, 'Clear All')
236 self.SelectAllPackagesButton.Bind (wx.EVT_BUTTON, self.OnSelectAllPackagesClick)
237 self.ClearAllPackagesButton.Bind (wx.EVT_BUTTON, self.OnClearAllPackagesClick)
238
239 self.PackagesCheckListBox = wx.CheckListBox(panel, -1)
240 self.PackagesCheckListBox.Bind(wx.EVT_CHECKLISTBOX, self.OnPackagesCheckListClick)
241 self.PackagesCheckListBox.Bind(wx.EVT_SET_FOCUS, self.OnPackagesSetFocus)
242 self.PackagesCheckListBox.Bind(wx.EVT_KILL_FOCUS, self.OnPackagesKillFocus)
243 self.PackagesCheckListBox.SetHelpText(PackagesHelpText)
244
245
246 self.SelectAllPlatformsButton = wx.Button(panel, -1, 'Select All')
247 self.ClearAllPlatformsButton = wx.Button(panel, -1, 'Clear All')
248 self.SelectAllPlatformsButton.Bind(wx.EVT_BUTTON, self.OnSelectAllPlatformsClick)
249 self.ClearAllPlatformsButton.Bind (wx.EVT_BUTTON, self.OnClearAllPlatformsClick)
250
251 self.PlatformsCheckListBox = wx.CheckListBox(panel, -1)
252 self.PlatformsCheckListBox.Bind(wx.EVT_CHECKLISTBOX, self.OnPlatformsCheckListClick)
253 self.PlatformsCheckListBox.Bind(wx.EVT_SET_FOCUS, self.OnPlatformsSetFocus)
254 self.PlatformsCheckListBox.Bind(wx.EVT_KILL_FOCUS, self.OnPlatformsKillFocus)
255 self.PlatformsCheckListBox.SetHelpText(PlatformsHelpText)
256
257 InvalidPackagesLabel = wx.StaticText(panel, -1, 'Invalid Packages')
258 InvalidPackagesLabel.SetFont(wx.Font(12, wx.FONTFAMILY_DEFAULT, wx.NORMAL, wx.FONTWEIGHT_BOLD))
259 InvalidPackagesLabel.SetHelpText(InvalidPackagesHelpText)
260
261 InvalidPlatformsLabel = wx.StaticText(panel, -1, 'Invalid Platforms')
262 InvalidPlatformsLabel.SetFont(wx.Font(12, wx.FONTFAMILY_DEFAULT, wx.NORMAL, wx.FONTWEIGHT_BOLD))
263 InvalidPlatformsLabel.SetHelpText(InvalidPlatformsHelpText)
264
265 self.SelectAllInvalidPackagesButton = wx.Button(panel, -1, 'Select All')
266 self.ClearAllInvalidPackagesButton = wx.Button(panel, -1, 'Clear All')
267 self.SelectAllInvalidPackagesButton.Bind (wx.EVT_BUTTON, self.OnSelectAllInvalidPackagesClick)
268 self.ClearAllInvalidPackagesButton.Bind (wx.EVT_BUTTON, self.OnClearAllInvalidPackagesClick)
269
270 self.InvalidPackagesCheckListBox = wx.CheckListBox(panel, -1)
271 self.InvalidPackagesCheckListBox.Bind(wx.EVT_CHECKLISTBOX, self.OnInvalidPackagesCheckListClick)
272 self.InvalidPackagesCheckListBox.Bind(wx.EVT_SET_FOCUS, self.OnInvalidPackagesSetFocus)
273 self.InvalidPackagesCheckListBox.Bind(wx.EVT_KILL_FOCUS, self.OnInvalidPackagesKillFocus)
274 self.InvalidPackagesCheckListBox.SetHelpText(PackagesHelpText)
275
276 self.SelectAllInvalidPlatformsButton = wx.Button(panel, -1, 'Select All')
277 self.ClearAllInvalidPlatformsButton = wx.Button(panel, -1, 'Clear All')
278 self.SelectAllInvalidPlatformsButton.Bind(wx.EVT_BUTTON, self.OnSelectAllInvalidPlatformsClick)
279 self.ClearAllInvalidPlatformsButton.Bind (wx.EVT_BUTTON, self.OnClearAllInvalidPlatformsClick)
280
281 self.InvalidPlatformsCheckListBox = wx.CheckListBox(panel, -1)
282 self.InvalidPlatformsCheckListBox.Bind(wx.EVT_CHECKLISTBOX, self.OnInvalidPlatformsCheckListClick)
283 self.InvalidPlatformsCheckListBox.Bind(wx.EVT_SET_FOCUS, self.OnInvalidPlatformsSetFocus)
284 self.InvalidPlatformsCheckListBox.Bind(wx.EVT_KILL_FOCUS, self.OnInvalidPlatformsKillFocus)
285 self.InvalidPlatformsCheckListBox.SetHelpText(PlatformsHelpText)
286
287 #
288 # Define layout using sizers
289 #
290 self.mainSizer = wx.BoxSizer(wx.VERTICAL)
291
292 listSizer = wx.GridBagSizer(hgap=5, vgap=5)
293 listSizer.Add(PackagesLabel, pos=(0,0), span=(1,2), flag=wx.ALIGN_CENTER)
294 listSizer.Add(PlatformsLabel, pos=(0,2), span=(1,2), flag=wx.ALIGN_CENTER)
295 listSizer.Add(self.SelectAllPackagesButton, pos=(1,0), flag=wx.ALIGN_CENTER)
296 listSizer.Add(self.ClearAllPackagesButton, pos=(1,1), flag=wx.ALIGN_CENTER)
297 listSizer.Add(self.SelectAllPlatformsButton, pos=(1,2), flag=wx.ALIGN_CENTER)
298 listSizer.Add(self.ClearAllPlatformsButton, pos=(1,3), flag=wx.ALIGN_CENTER)
299 listSizer.Add(self.PackagesCheckListBox, pos=(2,0), span=(1,2), flag=wx.ALL | wx.EXPAND)
300 listSizer.Add(self.PlatformsCheckListBox, pos=(2,2), span=(1,2), flag=wx.ALL | wx.EXPAND)
301
302 listSizer.Add(InvalidPackagesLabel, pos=(3,0), span=(1,2), flag=wx.ALIGN_CENTER)
303 listSizer.Add(InvalidPlatformsLabel, pos=(3,2), span=(1,2), flag=wx.ALIGN_CENTER)
304 listSizer.Add(self.SelectAllInvalidPackagesButton, pos=(4,0), flag=wx.ALIGN_CENTER)
305 listSizer.Add(self.ClearAllInvalidPackagesButton, pos=(4,1), flag=wx.ALIGN_CENTER)
306 listSizer.Add(self.SelectAllInvalidPlatformsButton, pos=(4,2), flag=wx.ALIGN_CENTER)
307 listSizer.Add(self.ClearAllInvalidPlatformsButton, pos=(4,3), flag=wx.ALIGN_CENTER)
308 listSizer.Add(self.InvalidPackagesCheckListBox, pos=(5,0), span=(1,2), flag=wx.ALL | wx.EXPAND)
309 listSizer.Add(self.InvalidPlatformsCheckListBox, pos=(5,2), span=(1,2), flag=wx.ALL | wx.EXPAND)
310
311 listSizer.AddGrowableRow(2)
312 listSizer.AddGrowableRow(5)
313 listSizer.AddGrowableCol(0)
314 listSizer.AddGrowableCol(1)
315 listSizer.AddGrowableCol(2)
316 listSizer.AddGrowableCol(3)
317
318 self.mainSizer.Add (listSizer, wx.EXPAND | wx.ALL, wx.EXPAND | wx.ALL, 10)
319
320 panel.SetSizer (self.mainSizer)
321
322 self.OnViewRefreshClick(self)
323
324 def CheckListFocus(self, CheckListBox, Set):
325 Index = 0
326 while Index < CheckListBox.GetCount():
327 CheckListBox.SetSelection(Index, False)
328 Index += 1
329 if Set and CheckListBox.GetCount() > 0:
330 CheckListBox.SetSelection(0, True)
331
332 def CheckListClick(self, CheckListBox, Database):
333 Index = 0
334 Database['EnabledSettings'] = {}
335 while Index < CheckListBox.GetCount():
336 if CheckListBox.IsChecked(Index):
337 for Item in Database['PossibleSettings']:
338 if Database['PossibleSettings'][Item] == CheckListBox.GetString(Index):
339 Database['EnabledSettings'][Item] = Database['PossibleSettings'][Item]
340 Index += 1
341
342 def OnPackagesCheckListClick(self, event):
343 self.CheckListClick(self.PackagesCheckListBox, self.Model.Database['Package']['Valid'])
344
345 def OnPackagesSetFocus(self, event):
346 self.CheckListFocus(self.PackagesCheckListBox, True)
347
348 def OnPackagesKillFocus(self, event):
349 self.CheckListFocus(self.PackagesCheckListBox, False)
350
351 def OnPlatformsCheckListClick(self, event):
352 self.CheckListClick(self.PlatformsCheckListBox, self.Model.Database['Platform']['Valid'])
353
354 def OnPlatformsSetFocus(self, event):
355 self.CheckListFocus(self.PlatformsCheckListBox, True)
356
357 def OnPlatformsKillFocus(self, event):
358 self.CheckListFocus(self.PlatformsCheckListBox, False)
359
360 def OnInvalidPackagesCheckListClick(self, event):
361 self.CheckListClick(self.InvalidPackagesCheckListBox, self.Model.Database['Package']['Invalid'])
362
363 def OnInvalidPackagesSetFocus(self, event):
364 self.CheckListFocus(self.InvalidPackagesCheckListBox, True)
365
366 def OnInvalidPackagesKillFocus(self, event):
367 self.CheckListFocus(self.InvalidPackagesCheckListBox, False)
368
369 def OnInvalidPlatformsCheckListClick(self, event):
370 self.CheckListClick(self.InvalidPlatformsCheckListBox, self.Model.Database['Platform']['Invalid'])
371
372 def OnInvalidPlatformsSetFocus(self, event):
373 self.CheckListFocus(self.InvalidPlatformsCheckListBox, True)
374
375 def OnInvalidPlatformsKillFocus(self, event):
376 self.CheckListFocus(self.InvalidPlatformsCheckListBox, False)
377
378 def OnRevertClick(self, event):
379 self.Model.RevertModel()
380 self.StatusBar.SetFocus()
381 self.OnRefreshClick(self)
382
383 def RefreshCheckListBox(self, CheckListBox, SelectAllButton, ClearAllButton, Database):
384 NameList = []
385 for Item in Database['PossibleSettings']:
386 NameList.append(Database['PossibleSettings'][Item])
387 NameList.sort()
388 CheckListBox.Set(NameList)
389 Index = 0
390 MaximumString = '.'
391 while Index < CheckListBox.GetCount():
392 String = CheckListBox.GetString(Index)
393 if len(String) > len(MaximumString):
394 MaximumString = String
395 Enabled = False
396 for Item in Database['EnabledSettings']:
397 if String == Database['EnabledSettings'][Item]:
398 Enabled = True
399 if Enabled:
400 CheckListBox.Check(Index, True)
401 else:
402 CheckListBox.Check(Index, False)
403 Index += 1
404 Extents = CheckListBox.GetFullTextExtent (MaximumString)
405 CheckListBox.SetMinSize((Extents[0] + 30,(CheckListBox.GetCount()+2) * (Extents[1]+Extents[2])))
406 if NameList == []:
407 CheckListBox.Disable()
408 SelectAllButton.Disable()
409 ClearAllButton.Disable()
410 else:
411 CheckListBox.Enable()
412 SelectAllButton.Enable()
413 ClearAllButton.Enable()
414
415 def OnRefreshClick(self, event):
416 self.Model.RefreshModel()
417 self.RefreshCheckListBox (self.PackagesCheckListBox, self.SelectAllPackagesButton, self.ClearAllPackagesButton, self.Model.Database['Package']['Valid'])
418 self.RefreshCheckListBox (self.PlatformsCheckListBox, self.SelectAllPlatformsButton, self.ClearAllPlatformsButton, self.Model.Database['Platform']['Valid'])
419 self.RefreshCheckListBox (self.InvalidPackagesCheckListBox, self.SelectAllInvalidPackagesButton, self.ClearAllInvalidPackagesButton, self.Model.Database['Package']['Invalid'])
420 self.RefreshCheckListBox (self.InvalidPlatformsCheckListBox, self.SelectAllInvalidPlatformsButton, self.ClearAllInvalidPlatformsButton, self.Model.Database['Platform']['Invalid'])
421 self.mainSizer.SetSizeHints(self)
422 self.mainSizer.Fit(self)
423 self.Update()
424
425 def OnViewRefreshClick(self, event):
426 self.Model.RescanModel()
427 self.StatusBar.SetFocus()
428 self.OnRefreshClick(self)
429
430 def AddTool (self, Handler, ArtId, Label, HelpText):
431 Tool = self.ToolBar.AddSimpleTool(
432 -1,
433 wx.ArtProvider.GetBitmap(ArtId, wx.ART_TOOLBAR, self.ToolSize),
434 Label,
435 HelpText
436 )
437 self.Bind(wx.EVT_MENU, Handler, Tool)
438
439 def OnShowToolBarClick(self, event):
440 if self.ShowToolBar:
441 self.ShowToolBar = False
442 self.ToolBar.Destroy()
443 else:
444 self.ShowToolBar = True
445 self.ToolBar = self.CreateToolBar()
446 self.ToolSize = (24,24)
447 self.ToolBar.SetToolBitmapSize(self.ToolSize)
448 self.AddTool (self.OnNewClick, wx.ART_NEW, "New", "New FrameworkDatabase.db")
449 self.AddTool (self.OnScanAndSyncClick, wx.ART_HARDDISK, "Scan WORKSPACE and Sync", "Scan WORKSPACE for new Packages and Platforms and sync FrameworkDatabase.db")
450 self.AddTool (self.OnSaveClick, wx.ART_FILE_SAVE, "Save", "Save FrameworkDatabase.db")
451 self.AddTool (self.OnSaveAsClick, wx.ART_FILE_SAVE_AS, "Save As...", "Save FrameworkDatabase.db as...")
452 self.AddTool (self.OnRevertClick, wx.ART_UNDO, "Revert", "Revert to original FrameworkDatabase.db")
453 self.AddTool (self.OnHelpClick, wx.ART_HELP, "Help", "Context Sensitive Help")
454 self.AddTool (self.OnExitClick, wx.ART_QUIT, "Exit", "Exit EDK II Build System Framework Database Utility")
455 self.ToolBar.Realize()
456
457 def OnNewClick(self, event):
458 self.Model.NewModel()
459 self.OnRefreshClick(self)
460
461 def ScanDirectory(self, Data, DirName, FilesInDir):
462 WorkspaceDirName = self.Model.WorkspaceRelativePath(DirName)
463 self.StatusBar.SetStatusText('Scanning: ' + WorkspaceDirName)
464 RemoveList = []
465 for File in FilesInDir:
466 if File[0] == '.':
467 RemoveList.insert(0, File)
468 for File in RemoveList:
469 FilesInDir.remove(File)
470 for File in FilesInDir:
471 if os.path.splitext(File)[1].lower() == '.spd':
472 self.Model.AddFile (WorkspaceDirName, File, 'Package', False)
473 self.OnRefreshClick(self)
474 if os.path.splitext(File)[1].lower() == '.fpd':
475 self.Model.AddFile (WorkspaceDirName, File, 'Platform', False)
476 self.OnRefreshClick(self)
477
478 def OnScanClick(self, event):
479 os.path.walk(self.Model.WorkspaceFile(''), self.ScanDirectory, None)
480 self.StatusBar.SetStatusText('Scanning: Complete')
481 self.StatusBar.SetFocus()
482 self.OnRefreshClick(self)
483
484 def OnScanAndSyncClick(self, event):
485 self.OnSelectAllPackagesClick(self)
486 self.OnSelectAllPlatformsClick(self)
487 self.OnClearAllInvalidPackagesClick(self)
488 self.OnClearAllInvalidPlatformsClick(self)
489 self.OnScanClick(self)
490 self.OnSelectAllPackagesClick(self)
491 self.OnSelectAllPlatformsClick(self)
492 self.OnClearAllInvalidPackagesClick(self)
493 self.OnClearAllInvalidPlatformsClick(self)
494
495 def OnSelectAllPackagesClick(self, event):
496 self.Model.Database['Package']['Valid']['EnabledSettings'] = self.Model.Database['Package']['Valid']['PossibleSettings']
497 self.OnRefreshClick(self)
498
499 def OnClearAllPackagesClick(self, event):
500 self.Model.Database['Package']['Valid']['EnabledSettings'] = {}
501 self.OnRefreshClick(self)
502
503 def OnSelectAllPlatformsClick(self, event):
504 self.Model.Database['Platform']['Valid']['EnabledSettings'] = self.Model.Database['Platform']['Valid']['PossibleSettings']
505 self.OnRefreshClick(self)
506
507 def OnClearAllPlatformsClick(self, event):
508 self.Model.Database['Platform']['Valid']['EnabledSettings'] = {}
509 self.OnRefreshClick(self)
510
511 def OnSelectAllInvalidPackagesClick(self, event):
512 self.Model.Database['Package']['Invalid']['EnabledSettings'] = self.Model.Database['Package']['Invalid']['PossibleSettings']
513 self.OnRefreshClick(self)
514
515 def OnClearAllInvalidPackagesClick(self, event):
516 self.Model.Database['Package']['Invalid']['EnabledSettings'] = {}
517 self.OnRefreshClick(self)
518
519 def OnSelectAllInvalidPlatformsClick(self, event):
520 self.Model.Database['Platform']['Invalid']['EnabledSettings'] = self.Model.Database['Platform']['Invalid']['PossibleSettings']
521 self.OnRefreshClick(self)
522
523 def OnClearAllInvalidPlatformsClick(self, event):
524 self.Model.Database['Platform']['Invalid']['EnabledSettings'] = {}
525 self.OnRefreshClick(self)
526
527 def OnSaveClick(self, event):
528 self.Model.SaveModel()
529
530 def OnSaveAsClick(self, event):
531 wildcard = "Text Documents (*.db)|*.db|" \
532 "All files (*.*)|*.*"
533 dialog = wx.FileDialog (None, 'Save As', self.Model.WorkspaceFile('Tools/Conf'), '', wildcard, wx.SAVE | wx.OVERWRITE_PROMPT)
534 if dialog.ShowModal() == wx.ID_OK:
535 FrameworkDatabaseDbFile = self.Model.WorkspaceRelativePath(dialog.GetPath())
536 if FrameworkDatabaseDbFile != '':
537 self.Model.SaveModel(FrameworkDatabaseDbFile)
538 dialog.Destroy()
539
540 def OnExitClick(self, event):
541 if self.Model.ModelModified():
542 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)
543 Status = dialog.ShowModal()
544 dialog.Destroy()
545 if Status == wx.ID_YES:
546 self.OnSaveClick (self)
547 elif Status == wx.ID_CANCEL:
548 return
549 self.Model.CloseModel()
550 self.Close()
551
552 def OnHelpClick(self, event):
553 wx.ContextHelp().BeginContextHelp()
554
555 def OnAboutClick(self, event):
556 AboutInfo = wx.AboutDialogInfo()
557 AboutInfo.Name = 'EDK II Build System Framework Database Utility'
558 AboutInfo.Version = '0.3'
559 AboutInfo.Copyright = 'Copyright (c) 2006, Intel Corporation'
560 AboutInfo.Description = """
561 The EDK II Build System Framework Database Utility maintains FrameworkDatabase.db
562 settings in an EDK II Workspace."""
563 AboutInfo.WebSite = ("http://tianocore.org", "Tiano Core home page")
564 AboutInfo.License = """
565 All rights reserved. This program and the accompanying materials are
566 licensed and made available under the terms and conditions of the BSD
567 License which accompanies this distribution. The full text of the
568 license may be found at http://opensource.org/licenses/bsd-license.php
569
570 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS"
571 BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND,
572 EITHER EXPRESS OR IMPLIED."""
573 if self.Model.Icon != None:
574 AboutInfo.Icon = self.Model.Icon
575 wx.AboutBox(AboutInfo)
576
577if __name__ == '__main__':
578 app = wx.PySimpleApp()
579 frame = Frame()
580 frame.Show()
581 app.MainLoop()
3b7a53b6 582