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
.*;
23 import javax
.swing
.tree
.DefaultMutableTreeNode
;
25 import org
.tianocore
.build
.pcd
.action
.ActionMessage
;
26 import org
.tianocore
.build
.pcd
.entity
.MemoryDatabaseManager
;
27 import org
.tianocore
.build
.pcd
.entity
.Token
;
28 import org
.tianocore
.build
.pcd
.entity
.UsageInstance
;
31 The class is the frame class for displaying PCD database in tree method.
33 public class PCDDatabaseFrame
extends JFrame
{
34 static final long serialVersionUID
= -7034897190740068939L;
38 private MemoryDatabaseManager dbManager
;
40 /// The token and module tree
42 private JTree databaseTree
;
45 Constructure function.
47 Create the UI component and display frame.
49 @param dbManager databaase manager instance.
51 public PCDDatabaseFrame(MemoryDatabaseManager dbManager
) {
52 if (dbManager
!= null) {
53 this.dbManager
= dbManager
;
56 // Put the frame into center of desktop.
58 setLocation(100, 100);
59 initializeComponent();
61 setTitle("PCD View Tool");
67 Initliaze the UI component in Display frame.
69 public void initializeComponent() {
70 JScrollPane scrollPane
= new JScrollPane();
71 Container contentPane
= getContentPane();
73 contentPane
.setLayout(new BorderLayout());
74 scrollPane
.setViewportView(initializeTree());
75 contentPane
.add(scrollPane
);
77 addWindowListener(new PCDDatabaseFrameAdapter());
81 Initiliaze the TREE control.
83 public JTree
initializeTree() {
84 Token
[] tokenArray
= null;
86 DefaultMutableTreeNode root
= new DefaultMutableTreeNode("PCDTreeRoot");
87 DefaultMutableTreeNode rootByPCD
= new DefaultMutableTreeNode("By PCD");
88 DefaultMutableTreeNode rootByModule
= new DefaultMutableTreeNode("By Module");
89 DefaultMutableTreeNode tokenNode
= null;
90 DefaultMutableTreeNode usageNode
= null;
91 DefaultMutableTreeNode moduleNode
= null;
92 java
.util
.List
<String
> moduleNames
= null;
96 Object
[] objectArray
= null;
97 java
.util
.List
<UsageInstance
> usageArray
= null;
98 UsageInstance usageInstance
= null;
105 tokenArray
= dbManager
.getRecordArray();
106 for (index
= 0; index
< tokenArray
.length
; index
++) {
107 token
= tokenArray
[index
];
108 ActionMessage
.debug(this, token
.cName
);
109 tokenNode
= new DefaultMutableTreeNode(token
.cName
);
110 tokenNode
.add(new DefaultMutableTreeNode(String
.format("TOKEN NUMBER: 0x%08x", token
.tokenNumber
)));
111 tokenNode
.add(new DefaultMutableTreeNode("TOKEN SPACE NAME: " + token
.tokenSpaceName
.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(String
.format("SKUID: %d", token
.skuId
)));
120 tokenNode
.add(new DefaultMutableTreeNode(String
.format("MAX SKU COUNT: %d", token
.maxSkuCount
)));
121 tokenNode
.add(new DefaultMutableTreeNode("VPDENABLE: " +(token
.vpdEnabled?
"true":"false")));
123 usageNode
= new DefaultMutableTreeNode("PRODUCER");
124 tokenNode
.add(usageNode
);
128 // Prepare consumer's leaf node
130 usageNode
= new DefaultMutableTreeNode("CONSUMER");
131 tokenNode
.add(usageNode
);
132 objectArray
= token
.consumers
.entrySet().toArray();
133 for (usageIndex
= 0; usageIndex
< token
.consumers
.size(); usageIndex
++) {
134 usageInstance
= (UsageInstance
) ((Map
.Entry
)objectArray
[usageIndex
]).getValue();
135 usageNode
.add(new DefaultMutableTreeNode(usageInstance
.getPrimaryKey()));
138 rootByPCD
.add(tokenNode
);
144 root
.add(rootByModule
);
145 moduleNames
= dbManager
.getAllModuleArray();
146 for (moduleIndex
= 0; moduleIndex
< moduleNames
.size(); moduleIndex
++) {
147 ActionMessage
.debug(this, "ModuleName:" + moduleNames
.get(moduleIndex
));
149 for (moduleIndex
= 0; moduleIndex
< moduleNames
.size(); moduleIndex
++) {
150 moduleNode
= new DefaultMutableTreeNode(moduleNames
.get(moduleIndex
));
151 usageArray
= dbManager
.getUsageInstanceArrayByKeyString(moduleNames
.get(moduleIndex
));
152 for (usageIndex
= 0; usageIndex
< usageArray
.size(); usageIndex
++) {
153 usageInstance
= usageArray
.get(usageIndex
);
154 usageNode
= new DefaultMutableTreeNode(usageInstance
.parentToken
.cName
);
155 usageNode
.add(new DefaultMutableTreeNode("MODULE PCD TYPE: " + Token
.getStringOfpcdType(usageInstance
.modulePcdType
)));
156 moduleNode
.add(usageNode
);
158 rootByModule
.add(moduleNode
);
161 databaseTree
= new JTree(root
);
167 The adatper class for PCDDatabaseFrame. This class instance many windows message
170 class PCDDatabaseFrameAdapter
extends WindowAdapter
{
171 public void windowClosing(WindowEvent e
) {