2 PCDDatabaseFrame class.
4 The class is the frame class for displaying PCD database in tree method.
6 Copyright (c) 2006, Intel Corporation
7 All rights reserved. This program and the accompanying materials
8 are licensed and made available under the terms and conditions of the BSD License
9 which accompanies this distribution. The full text of the license may be found at
10 http://opensource.org/licenses/bsd-license.php
12 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
13 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
16 package org
.tianocore
.build
.pcd
.ui
;
19 import java
.awt
.event
.*;
22 import javax
.swing
.tree
.DefaultMutableTreeNode
;
24 import org
.tianocore
.build
.pcd
.action
.ActionMessage
;
25 import org
.tianocore
.build
.pcd
.entity
.MemoryDatabaseManager
;
26 import org
.tianocore
.build
.pcd
.entity
.Token
;
27 import org
.tianocore
.build
.pcd
.entity
.UsageInstance
;
30 The class is the frame class for displaying PCD database in tree method.
32 public class PCDDatabaseFrame
extends JFrame
{
33 static final long serialVersionUID
= -7034897190740068939L;
37 private MemoryDatabaseManager dbManager
;
39 /// The token and module tree
41 private JTree databaseTree
;
44 Constructure function.
46 Create the UI component and display frame.
48 @param dbManager databaase manager instance.
50 public PCDDatabaseFrame(MemoryDatabaseManager dbManager
) {
51 if (dbManager
!= null) {
52 this.dbManager
= dbManager
;
55 // Put the frame into center of desktop.
57 setLocation(100, 100);
58 initializeComponent();
60 setTitle("PCD View Tool");
66 Initliaze the UI component in Display frame.
68 public void initializeComponent() {
69 JScrollPane scrollPane
= new JScrollPane();
70 Container contentPane
= getContentPane();
72 contentPane
.setLayout(new BorderLayout());
73 scrollPane
.setViewportView(initializeTree());
74 contentPane
.add(scrollPane
);
76 addWindowListener(new PCDDatabaseFrameAdapter());
80 Initiliaze the TREE control.
82 public JTree
initializeTree() {
83 Token
[] tokenArray
= null;
85 DefaultMutableTreeNode root
= new DefaultMutableTreeNode(dbManager
.getLogFileName());
86 DefaultMutableTreeNode rootByPCD
= new DefaultMutableTreeNode("By PCD");
87 DefaultMutableTreeNode rootByModule
= new DefaultMutableTreeNode("By Module");
88 DefaultMutableTreeNode tokenNode
= null;
89 DefaultMutableTreeNode usageNode
= null;
90 DefaultMutableTreeNode moduleNode
= null;
91 java
.util
.List
<String
> moduleNames
= null;
95 java
.util
.List
<UsageInstance
> usageArray
= null;
96 UsageInstance usageInstance
= null;
103 tokenArray
= dbManager
.getRecordArray();
104 for (index
= 0; index
< tokenArray
.length
; index
++) {
105 token
= tokenArray
[index
];
106 ActionMessage
.debug(this, token
.cName
);
107 tokenNode
= new DefaultMutableTreeNode(token
.cName
);
108 tokenNode
.add(new DefaultMutableTreeNode(String
.format("TOKEN NUMBER: 0x%08x", token
.tokenNumber
)));
109 tokenNode
.add(new DefaultMutableTreeNode(String
.format("ASSIGNED TOKEN NUMBER: 0x%08x", token
.assignedtokenNumber
)));
110 tokenNode
.add(new DefaultMutableTreeNode("TOKEN SPACE NAME: " + token
.tokenSpaceName
.toString()));
111 tokenNode
.add(new DefaultMutableTreeNode("ASSIGNED TOKEN SPACE NAME: " + token
.assignedtokenSpaceName
.toString()));
112 tokenNode
.add(new DefaultMutableTreeNode("PCD TYPE: " + Token
.getStringOfpcdType(token
.pcdType
)));
113 tokenNode
.add(new DefaultMutableTreeNode("DATUM TYPE: " +Token
.getStringOfdatumType(token
.datumType
)));
114 tokenNode
.add(new DefaultMutableTreeNode("DATUM: " + token
.datum
.toString()));
115 tokenNode
.add(new DefaultMutableTreeNode("HIIENABLE: " +(token
.hiiEnabled?
"true":"false")));
116 tokenNode
.add(new DefaultMutableTreeNode("VARIABLE NAME: " + token
.variableName
));
117 tokenNode
.add(new DefaultMutableTreeNode("VARIABLE GUID: " + token
.variableGuid
.toString()));
118 tokenNode
.add(new DefaultMutableTreeNode("SKUENABLE: " +(token
.skuEnabled?
"true":"false")));
119 tokenNode
.add(new DefaultMutableTreeNode("SKUDATA ARRAY ENABLE: " +(token
.skuDataArrayEnabled?
"true":"false")));
120 tokenNode
.add(new DefaultMutableTreeNode(String
.format("SKUID: %d", token
.skuId
)));
121 tokenNode
.add(new DefaultMutableTreeNode(String
.format("MAX SKU COUNT: %d", token
.maxSkuCount
)));
122 tokenNode
.add(new DefaultMutableTreeNode("VPDENABLE: " +(token
.vpdEnabled?
"true":"false")));
124 usageNode
= new DefaultMutableTreeNode("PRODUCER");
125 tokenNode
.add(usageNode
);
128 // Prepare producer's leaf node
131 for (usageIndex
= 0; usageIndex
< token
.producers
.size(); usageIndex
++) {
132 usageNode
.add(new DefaultMutableTreeNode(token
.producers
.get(usageIndex
).moduleName
));
136 // Prepare consumer's leaf node
138 usageNode
= new DefaultMutableTreeNode("CONSUMER");
139 tokenNode
.add(usageNode
);
141 for (usageIndex
= 0; usageIndex
< token
.consumers
.size(); usageIndex
++) {
142 usageNode
.add(new DefaultMutableTreeNode(token
.consumers
.get(usageIndex
).moduleName
));
145 rootByPCD
.add(tokenNode
);
151 root
.add(rootByModule
);
152 moduleNames
= dbManager
.getAllModuleArray();
153 for (moduleIndex
= 0; moduleIndex
< moduleNames
.size(); moduleIndex
++) {
154 ActionMessage
.debug(this, "ModuleName:" + moduleNames
.get(moduleIndex
));
156 for (moduleIndex
= 0; moduleIndex
< moduleNames
.size(); moduleIndex
++) {
157 moduleNode
= new DefaultMutableTreeNode(moduleNames
.get(moduleIndex
));
158 usageArray
= dbManager
.getUsageInstanceArrayByModuleName(moduleNames
.get(moduleIndex
));
159 for (usageIndex
= 0; usageIndex
< usageArray
.size(); usageIndex
++) {
160 usageInstance
= usageArray
.get(usageIndex
);
161 usageNode
= new DefaultMutableTreeNode(usageInstance
.parentToken
.cName
);
162 usageNode
.add(new DefaultMutableTreeNode("MODULE PCD TYPE: " + Token
.getStringOfpcdType(usageInstance
.modulePcdType
)));
163 usageNode
.add(new DefaultMutableTreeNode("HELP TEXT: " + usageInstance
.helpTextInMSA
));
164 usageNode
.add(new DefaultMutableTreeNode("IS INHERIT: " +(usageInstance
.isInherit?
"true":"false")));
165 usageNode
.add(new DefaultMutableTreeNode("USAGE: " + Token
.getStringOfUsage(usageInstance
.usage
)));
166 moduleNode
.add(usageNode
);
168 rootByModule
.add(moduleNode
);
171 databaseTree
= new JTree(root
);
177 The adatper class for PCDDatabaseFrame. This class instance many windows message
180 class PCDDatabaseFrameAdapter
extends WindowAdapter
{
181 public void windowClosing(WindowEvent e
) {