blob: 661260d7bb945575a8fd29a2b920565466a47d79 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
|
/** @file
PCDDatabaseFrame class.
The class is the frame class for displaying PCD database in tree method.
Copyright (c) 2006, Intel Corporation
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
package org.tianocore.build.pcd.ui;
import java.awt.*;
import java.awt.event.*;
import java.util.Map;
import javax.swing.*;
import javax.swing.tree.DefaultMutableTreeNode;
import org.tianocore.build.pcd.action.ActionMessage;
import org.tianocore.build.pcd.entity.MemoryDatabaseManager;
import org.tianocore.build.pcd.entity.Token;
import org.tianocore.build.pcd.entity.UsageInstance;
/**
The class is the frame class for displaying PCD database in tree method.
**/
public class PCDDatabaseFrame extends JFrame {
static final long serialVersionUID = -7034897190740068939L;
///
/// Database instance
///
private MemoryDatabaseManager dbManager;
///
/// The token and module tree
///
private JTree databaseTree;
/**
Constructure function.
Create the UI component and display frame.
@param dbManager databaase manager instance.
**/
public PCDDatabaseFrame(MemoryDatabaseManager dbManager) {
if (dbManager != null) {
this.dbManager = dbManager;
}
//
// Put the frame into center of desktop.
//
setLocation(100, 100);
initializeComponent();
setTitle("PCD View Tool");
pack();
setVisible(true);
}
/**
Initliaze the UI component in Display frame.
**/
public void initializeComponent() {
JScrollPane scrollPane = new JScrollPane();
Container contentPane = getContentPane();
contentPane.setLayout(new BorderLayout());
scrollPane.setViewportView(initializeTree());
contentPane.add(scrollPane);
addWindowListener(new PCDDatabaseFrameAdapter());
}
/**
Initiliaze the TREE control.
**/
public JTree initializeTree() {
Token[] tokenArray = null;
Token token = null;
DefaultMutableTreeNode root = new DefaultMutableTreeNode("PCDTreeRoot");
DefaultMutableTreeNode rootByPCD = new DefaultMutableTreeNode("By PCD");
DefaultMutableTreeNode rootByModule = new DefaultMutableTreeNode("By Module");
DefaultMutableTreeNode tokenNode = null;
DefaultMutableTreeNode usageNode = null;
DefaultMutableTreeNode moduleNode = null;
java.util.List<String> moduleNames = null;
int index = 0;
int usageIndex = 0;
int moduleIndex = 0;
Object[] objectArray = null;
java.util.List<UsageInstance> usageArray = null;
UsageInstance usageInstance = null;
root.add(rootByPCD);
//
// By PCD Node
//
tokenArray = dbManager.getRecordArray();
for (index = 0; index < tokenArray.length; index ++) {
token = tokenArray[index];
ActionMessage.debug(this, token.cName);
tokenNode = new DefaultMutableTreeNode(token.cName);
tokenNode.add(new DefaultMutableTreeNode(String.format("TOKEN NUMBER: 0x%08x", token.tokenNumber)));
tokenNode.add(new DefaultMutableTreeNode("TOKEN SPACE NAME: " + token.tokenSpaceName.toString()));
tokenNode.add(new DefaultMutableTreeNode("PCD TYPE: " + Token.getStringOfpcdType(token.pcdType)));
tokenNode.add(new DefaultMutableTreeNode("DATUM TYPE: " +Token.getStringOfdatumType(token.datumType)));
tokenNode.add(new DefaultMutableTreeNode("DATUM: " + token.datum.toString()));
tokenNode.add(new DefaultMutableTreeNode("HIIENABLE: " +(token.hiiEnabled?"true":"false")));
tokenNode.add(new DefaultMutableTreeNode("VARIABLE NAME: " + token.variableName));
//tokenNode.add(new DefaultMutableTreeNode("VARIABLE GUID: " + token.variableGuid.toString()));
tokenNode.add(new DefaultMutableTreeNode("SKUENABLE: " +(token.skuEnabled?"true":"false")));
tokenNode.add(new DefaultMutableTreeNode(String.format("SKUID: %d", token.skuId)));
tokenNode.add(new DefaultMutableTreeNode(String.format("MAX SKU COUNT: %d", token.maxSkuCount)));
tokenNode.add(new DefaultMutableTreeNode("VPDENABLE: " +(token.vpdEnabled?"true":"false")));
usageNode = new DefaultMutableTreeNode("PRODUCER");
tokenNode.add(usageNode);
//
// Prepare consumer's leaf node
//
usageNode = new DefaultMutableTreeNode("CONSUMER");
tokenNode.add(usageNode);
objectArray = token.consumers.entrySet().toArray();
for (usageIndex = 0; usageIndex < token.consumers.size(); usageIndex ++) {
usageInstance = (UsageInstance) ((Map.Entry)objectArray[usageIndex]).getValue();
usageNode.add(new DefaultMutableTreeNode(usageInstance.getPrimaryKey()));
}
rootByPCD.add(tokenNode);
}
//
// BY MODULE Node
//
root.add(rootByModule);
moduleNames = dbManager.getAllModuleArray();
for (moduleIndex = 0; moduleIndex < moduleNames.size(); moduleIndex ++) {
ActionMessage.debug(this, "ModuleName:" + moduleNames.get(moduleIndex));
}
for (moduleIndex = 0; moduleIndex < moduleNames.size(); moduleIndex ++) {
moduleNode = new DefaultMutableTreeNode(moduleNames.get(moduleIndex));
usageArray = dbManager.getUsageInstanceArrayByKeyString(moduleNames.get(moduleIndex));
for (usageIndex = 0; usageIndex < usageArray.size(); usageIndex ++) {
usageInstance = usageArray.get(usageIndex);
usageNode = new DefaultMutableTreeNode(usageInstance.parentToken.cName);
usageNode.add(new DefaultMutableTreeNode("MODULE PCD TYPE: " + Token.getStringOfpcdType(usageInstance.modulePcdType)));
moduleNode.add(usageNode);
}
rootByModule.add(moduleNode);
}
databaseTree = new JTree(root);
return databaseTree;
}
}
/**
The adatper class for PCDDatabaseFrame. This class instance many windows message
callback function.
**/
class PCDDatabaseFrameAdapter extends WindowAdapter {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
}
|