8d4243f1 |
1 | #!/usr/bin/env python |
2 | |
3 | # An EDK II Build System Framework Database Utility maintains FrameworkDatabase.db |
4 | # settings in an EDK II Workspace. |
5 | |
6 | import wx, os, sys, copy |
7 | from EdkIIWorkspace import * |
8 | |
9 | class FrameworkDatabaseModel(EdkIIWorkspace): |
10 | def __init__(self): |
11 | self.WorkspaceStatus = EdkIIWorkspace.__init__(self) |
12 | self.Database = {} |
13 | self.OriginalDatabase = {} |
14 | |
15 | def AddFile (self, DirName, FileName, FileType, Enabled): |
16 | if DirName != '': |
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') |
26 | else: |
27 | return |
28 | FileName = FileName.replace('\\','/') |
29 | if Name == '' and Version == '': |
30 | ValidType = 'Invalid' |
31 | OtherType = 'Valid' |
32 | UiName = FileName |
33 | else: |
34 | ValidType = 'Valid' |
35 | OtherType = 'Invalid' |
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 |
40 | if Enabled: |
41 | self.Database[FileType][ValidType]['EnabledSettings'][FileName] = UiName |
42 | return |
43 | |
44 | def NewModel(self): |
45 | self.Database['Platform'] = {'Valid': {'PossibleSettings':{}, 'EnabledSettings':{}},'Invalid': {'PossibleSettings':{}, 'EnabledSettings':{}}} |
46 | self.Database['Package'] = {'Valid': {'PossibleSettings':{}, 'EnabledSettings':{}},'Invalid': {'PossibleSettings':{}, 'EnabledSettings':{}}} |
47 | |
48 | def RevertModel(self): |
49 | self.Database = copy.deepcopy(self.OriginalDatabase) |
50 | |
51 | def RescanModel(self): |
52 | self.NewModel() |
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) |
63 | |
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']) |
70 | return True |
71 | |
72 | def ModelModified(self): |
73 | if self.Database['Package']['Valid']['EnabledSettings'] != self.OriginalDatabase['Package']['Valid']['EnabledSettings']: |
74 | return True |
75 | if self.Database['Package']['Invalid']['EnabledSettings'] != self.OriginalDatabase['Package']['Invalid']['EnabledSettings']: |
76 | return True |
77 | if self.Database['Platform']['Valid']['EnabledSettings'] != self.OriginalDatabase['Platform']['Valid']['EnabledSettings']: |
78 | return True |
79 | if self.Database['Platform']['Invalid']['EnabledSettings'] != self.OriginalDatabase['Platform']['Invalid']['EnabledSettings']: |
80 | return True |
81 | return False |
82 | |
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) |
91 | continue |
92 | XmlRemoveElement(File) |
93 | |
94 | ParentNode = XmlList (self.Fd, '/FrameworkDatabase/PackageList')[0] |
95 | for SpdFileName in EnabledList: |
96 | XmlAppendChildElement(ParentNode, u'Filename', SpdFileName) |
97 | |
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) |
105 | continue |
106 | XmlRemoveElement(File) |
107 | |
108 | ParentNode = XmlList (self.Fd, '/FrameworkDatabase/PlatformList')[0] |
109 | for FpdFileName in EnabledList: |
110 | XmlAppendChildElement(ParentNode, u'Filename', FpdFileName) |
111 | |
112 | self.XmlSaveFile (self.Fd, Filename) |
113 | self.OriginalDatabase = copy.deepcopy(self.Database) |
114 | |
115 | def CloseModel(self): |
116 | pass |
117 | |
118 | class Frame(wx.Frame): |
119 | def __init__(self): |
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()) |
123 | |
124 | self.Model = FrameworkDatabaseModel() |
125 | |
126 | # |
127 | # Help text |
128 | # |
129 | PackagesHelpText = ( |
130 | "The set of packages that are active in the current WORKSPACE." |
131 | ) |
132 | |
133 | PlatformsHelpText = ( |
134 | "The set of platforms that are active in the current WORKSPACE." |
135 | ) |
136 | |
137 | InvalidPackagesHelpText = ( |
138 | "The set of packages that are in Framework Database, but not in the current WORKSPACE." |
139 | ) |
140 | |
141 | InvalidPlatformsHelpText = ( |
142 | "The set of platforms that are in Framework Database, but not in the current WORKSPACE." |
143 | ) |
144 | |
145 | # |
146 | # Status Bar |
147 | # |
148 | self.StatusBar = self.CreateStatusBar() |
149 | |
150 | # |
151 | # Build Menus |
152 | # |
153 | MenuBar = wx.MenuBar() |
154 | |
155 | FileMenu = wx.Menu() |
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) |
170 | |
171 | EditMenu = wx.Menu() |
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) |
189 | |
190 | ViewMenu = wx.Menu() |
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) |
197 | |
198 | HelpMenu = wx.Menu() |
199 | AboutMenuItem = HelpMenu.Append (-1, "&About...", "About") |
200 | MenuBar.Append(HelpMenu, "&Help") |
201 | self.Bind(wx.EVT_MENU, self.OnAboutClick, AboutMenuItem) |
202 | |
203 | self.SetMenuBar (MenuBar) |
204 | |
205 | # |
206 | # Build Toolbar |
207 | # |
208 | self.ShowToolBar = False |
209 | self.OnShowToolBarClick(self) |
210 | |
211 | # |
212 | # Target, ToolChain, and Arch Check List Boxes |
213 | # |
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) |
217 | |
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) |
221 | |
222 | # |
223 | # Buttons |
224 | # |
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) |
229 | |
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) |
235 | |
236 | |
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) |
241 | |
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) |
247 | |
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) |
251 | |
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) |
255 | |
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) |
260 | |
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) |
266 | |
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) |
271 | |
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) |
277 | |
278 | # |
279 | # Define layout using sizers |
280 | # |
281 | self.mainSizer = wx.BoxSizer(wx.VERTICAL) |
282 | |
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) |
292 | |
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) |
301 | |
302 | listSizer.AddGrowableRow(2) |
303 | listSizer.AddGrowableRow(5) |
304 | listSizer.AddGrowableCol(0) |
305 | listSizer.AddGrowableCol(1) |
306 | listSizer.AddGrowableCol(2) |
307 | listSizer.AddGrowableCol(3) |
308 | |
309 | self.mainSizer.Add (listSizer, wx.EXPAND | wx.ALL, wx.EXPAND | wx.ALL, 10) |
310 | |
311 | panel.SetSizer (self.mainSizer) |
312 | |
313 | self.OnViewRefreshClick(self) |
314 | |
315 | def CheckListFocus(self, CheckListBox, Set): |
316 | Index = 0 |
317 | while Index < CheckListBox.GetCount(): |
318 | CheckListBox.SetSelection(Index, False) |
319 | Index += 1 |
320 | if Set and CheckListBox.GetCount() > 0: |
321 | CheckListBox.SetSelection(0, True) |
322 | |
323 | def CheckListClick(self, CheckListBox, Database): |
324 | Index = 0 |
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] |
331 | Index += 1 |
332 | |
333 | def OnPackagesCheckListClick(self, event): |
334 | self.CheckListClick(self.PackagesCheckListBox, self.Model.Database['Package']['Valid']) |
335 | |
336 | def OnPackagesSetFocus(self, event): |
337 | self.CheckListFocus(self.PackagesCheckListBox, True) |
338 | |
339 | def OnPackagesKillFocus(self, event): |
340 | self.CheckListFocus(self.PackagesCheckListBox, False) |
341 | |
342 | def OnPlatformsCheckListClick(self, event): |
343 | self.CheckListClick(self.PlatformsCheckListBox, self.Model.Database['Platform']['Valid']) |
344 | |
345 | def OnPlatformsSetFocus(self, event): |
346 | self.CheckListFocus(self.PlatformsCheckListBox, True) |
347 | |
348 | def OnPlatformsKillFocus(self, event): |
349 | self.CheckListFocus(self.PlatformsCheckListBox, False) |
350 | |
351 | def OnInvalidPackagesCheckListClick(self, event): |
352 | self.CheckListClick(self.InvalidPackagesCheckListBox, self.Model.Database['Package']['Invalid']) |
353 | |
354 | def OnInvalidPackagesSetFocus(self, event): |
355 | self.CheckListFocus(self.InvalidPackagesCheckListBox, True) |
356 | |
357 | def OnInvalidPackagesKillFocus(self, event): |
358 | self.CheckListFocus(self.InvalidPackagesCheckListBox, False) |
359 | |
360 | def OnInvalidPlatformsCheckListClick(self, event): |
361 | self.CheckListClick(self.InvalidPlatformsCheckListBox, self.Model.Database['Platform']['Invalid']) |
362 | |
363 | def OnInvalidPlatformsSetFocus(self, event): |
364 | self.CheckListFocus(self.InvalidPlatformsCheckListBox, True) |
365 | |
366 | def OnInvalidPlatformsKillFocus(self, event): |
367 | self.CheckListFocus(self.InvalidPlatformsCheckListBox, False) |
368 | |
369 | def OnRevertClick(self, event): |
370 | self.Model.RevertModel() |
371 | self.StatusBar.SetFocus() |
372 | self.OnRefreshClick(self) |
373 | |
374 | def RefreshCheckListBox(self, CheckListBox, SelectAllButton, ClearAllButton, Database): |
375 | NameList = [] |
376 | for Item in Database['PossibleSettings']: |
377 | NameList.append(Database['PossibleSettings'][Item]) |
378 | NameList.sort() |
379 | CheckListBox.Set(NameList) |
380 | Index = 0 |
381 | MaximumString = '.' |
382 | while Index < CheckListBox.GetCount(): |
383 | String = CheckListBox.GetString(Index) |
384 | if len(String) > len(MaximumString): |
385 | MaximumString = String |
386 | Enabled = False |
387 | for Item in Database['EnabledSettings']: |
388 | if String == Database['EnabledSettings'][Item]: |
389 | Enabled = True |
390 | if Enabled: |
391 | CheckListBox.Check(Index, True) |
392 | else: |
393 | CheckListBox.Check(Index, False) |
394 | Index += 1 |
395 | Extents = CheckListBox.GetFullTextExtent (MaximumString) |
396 | CheckListBox.SetMinSize((Extents[0] + 30,(CheckListBox.GetCount()+2) * (Extents[1]+Extents[2]))) |
397 | if NameList == []: |
398 | CheckListBox.Disable() |
399 | SelectAllButton.Disable() |
400 | ClearAllButton.Disable() |
401 | else: |
402 | CheckListBox.Enable() |
403 | SelectAllButton.Enable() |
404 | ClearAllButton.Enable() |
405 | |
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) |
414 | self.Update() |
415 | |
416 | def OnViewRefreshClick(self, event): |
417 | self.Model.RescanModel() |
418 | self.StatusBar.SetFocus() |
419 | self.OnRefreshClick(self) |
420 | |
421 | def AddTool (self, Handler, ArtId, Label, HelpText): |
422 | Tool = self.ToolBar.AddSimpleTool( |
423 | -1, |
424 | wx.ArtProvider.GetBitmap(ArtId, wx.ART_TOOLBAR, self.ToolSize), |
425 | Label, |
426 | HelpText |
427 | ) |
428 | self.Bind(wx.EVT_MENU, Handler, Tool) |
429 | |
430 | def OnShowToolBarClick(self, event): |
431 | if self.ShowToolBar: |
432 | self.ShowToolBar = False |
433 | self.ToolBar.Destroy() |
434 | else: |
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() |
447 | |
448 | def OnNewClick(self, event): |
449 | self.Model.NewModel() |
450 | self.OnRefreshClick(self) |
451 | |
452 | def ScanDirectory(self, Data, DirName, FilesInDir): |
453 | WorkspaceDirName = self.Model.WorkspaceRelativePath(DirName) |
454 | self.StatusBar.SetStatusText('Scanning: ' + WorkspaceDirName) |
455 | RemoveList = [] |
456 | for File in FilesInDir: |
457 | if File[0] == '.': |
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) |
468 | |
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) |
474 | |
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) |
485 | |
486 | def OnSelectAllPackagesClick(self, event): |
487 | self.Model.Database['Package']['Valid']['EnabledSettings'] = self.Model.Database['Package']['Valid']['PossibleSettings'] |
488 | self.OnRefreshClick(self) |
489 | |
490 | def OnClearAllPackagesClick(self, event): |
491 | self.Model.Database['Package']['Valid']['EnabledSettings'] = {} |
492 | self.OnRefreshClick(self) |
493 | |
494 | def OnSelectAllPlatformsClick(self, event): |
495 | self.Model.Database['Platform']['Valid']['EnabledSettings'] = self.Model.Database['Platform']['Valid']['PossibleSettings'] |
496 | self.OnRefreshClick(self) |
497 | |
498 | def OnClearAllPlatformsClick(self, event): |
499 | self.Model.Database['Platform']['Valid']['EnabledSettings'] = {} |
500 | self.OnRefreshClick(self) |
501 | |
502 | def OnSelectAllInvalidPackagesClick(self, event): |
503 | self.Model.Database['Package']['Invalid']['EnabledSettings'] = self.Model.Database['Package']['Invalid']['PossibleSettings'] |
504 | self.OnRefreshClick(self) |
505 | |
506 | def OnClearAllInvalidPackagesClick(self, event): |
507 | self.Model.Database['Package']['Invalid']['EnabledSettings'] = {} |
508 | self.OnRefreshClick(self) |
509 | |
510 | def OnSelectAllInvalidPlatformsClick(self, event): |
511 | self.Model.Database['Platform']['Invalid']['EnabledSettings'] = self.Model.Database['Platform']['Invalid']['PossibleSettings'] |
512 | self.OnRefreshClick(self) |
513 | |
514 | def OnClearAllInvalidPlatformsClick(self, event): |
515 | self.Model.Database['Platform']['Invalid']['EnabledSettings'] = {} |
516 | self.OnRefreshClick(self) |
517 | |
518 | def OnSaveClick(self, event): |
519 | self.Model.SaveModel() |
520 | |
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) |
529 | dialog.Destroy() |
530 | |
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() |
535 | dialog.Destroy() |
536 | if Status == wx.ID_YES: |
537 | self.OnSaveClick (self) |
538 | elif Status == wx.ID_CANCEL: |
539 | return |
540 | self.Model.CloseModel() |
541 | self.Close() |
542 | |
543 | def OnHelpClick(self, event): |
544 | wx.ContextHelp().BeginContextHelp() |
545 | |
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 |
560 | |
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) |
567 | |
568 | if __name__ == '__main__': |
569 | app = wx.PySimpleApp() |
570 | frame = Frame() |
571 | frame.Show() |
572 | app.MainLoop() |
573 | |