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("DATUM TYPE: " +Token
.getStringOfdatumType(token
.datumType
)));
113 //tokenNode.add(new DefaultMutableTreeNode("VARIABLE GUID: " + token.variableGuid.toString()));
115 usageNode
= new DefaultMutableTreeNode("PRODUCER");
116 tokenNode
.add(usageNode
);
120 // Prepare consumer's leaf node
122 usageNode
= new DefaultMutableTreeNode("CONSUMER");
123 tokenNode
.add(usageNode
);
124 objectArray
= token
.consumers
.entrySet().toArray();
125 for (usageIndex
= 0; usageIndex
< token
.consumers
.size(); usageIndex
++) {
126 usageInstance
= (UsageInstance
) ((Map
.Entry
)objectArray
[usageIndex
]).getValue();
127 usageNode
.add(new DefaultMutableTreeNode(usageInstance
.getPrimaryKey()));
130 rootByPCD
.add(tokenNode
);
136 root
.add(rootByModule
);
137 moduleNames
= dbManager
.getAllModuleArray();
138 for (moduleIndex
= 0; moduleIndex
< moduleNames
.size(); moduleIndex
++) {
139 ActionMessage
.debug(this, "ModuleName:" + moduleNames
.get(moduleIndex
));
141 for (moduleIndex
= 0; moduleIndex
< moduleNames
.size(); moduleIndex
++) {
142 moduleNode
= new DefaultMutableTreeNode(moduleNames
.get(moduleIndex
));
143 usageArray
= dbManager
.getUsageInstanceArrayByKeyString(moduleNames
.get(moduleIndex
));
144 for (usageIndex
= 0; usageIndex
< usageArray
.size(); usageIndex
++) {
145 usageInstance
= usageArray
.get(usageIndex
);
146 usageNode
= new DefaultMutableTreeNode(usageInstance
.parentToken
.cName
);
147 usageNode
.add(new DefaultMutableTreeNode("MODULE PCD TYPE: " + Token
.getStringOfpcdType(usageInstance
.modulePcdType
)));
148 moduleNode
.add(usageNode
);
150 rootByModule
.add(moduleNode
);
153 databaseTree
= new JTree(root
);
159 The adatper class for PCDDatabaseFrame. This class instance many windows message
162 class PCDDatabaseFrameAdapter
extends WindowAdapter
{
163 public void windowClosing(WindowEvent e
) {