\r
import org.apache.tools.ant.Task;\r
import org.tianocore.build.pcd.action.BuildAction;\r
-import org.tianocore.build.pcd.action.UIAction;\r
\r
/** ActionMessage class take over all message for loging and waning. This class \r
should dispatch message into different Action class according to instance \r
\r
if(thisClass instanceof Task) {\r
BuildAction.logMsg(thisClass, "$$LOG$$:" + logStr);\r
- } else if(thisClass instanceof UIAction) {\r
- UIAction.logMsg(thisClass, "$$LOG$$:" + logStr);\r
} else {\r
System.out.println("$$LOG$$:" + logStr);\r
}\r
\r
if(thisClass instanceof Task) {\r
BuildAction.warningMsg(thisClass, "**WARNING**:" + warningStr);\r
- } else if(thisClass instanceof UIAction) {\r
- UIAction.warningMsg(thisClass, "**WARNING**:" + warningStr);\r
} else {\r
System.out.println("**WARNING**:" + warningStr);\r
}\r
\r
if(thisClass instanceof Task) {\r
BuildAction.logMsg(thisClass, "%%DEBUG%%:" + debugStr);\r
- } else if(thisClass instanceof UIAction) {\r
- UIAction.logMsg(thisClass, "%%DEBUG%%:" + debugStr);\r
} else {\r
System.out.println("%%DEBUG%%:" + debugStr);\r
}\r
+++ /dev/null
-/** @file\r
- ShowPCDDatabase class.\r
-\r
- This class is the action to diplay the PCD database.\r
- \r
-Copyright (c) 2006, Intel Corporation\r
-All rights reserved. This program and the accompanying materials\r
-are licensed and made available under the terms and conditions of the BSD License\r
-which accompanies this distribution. The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
- \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-**/\r
-package org.tianocore.build.pcd.action;\r
-\r
-import java.io.File;\r
-\r
-import org.tianocore.build.global.GlobalData;\r
-import org.tianocore.build.pcd.exception.UIException;\r
-import org.tianocore.build.pcd.ui.PCDDatabaseFrame;\r
-\r
-/** This class is the action to show PCD database.\r
-**/\r
-public class ShowPCDDatabaseAction extends UIAction {\r
- ///\r
- /// The workspace path parameter.\r
- ///\r
- private String workspacePath;\r
- ///\r
- /// The FpdfileName parameter.\r
- ///\r
- private String fpdFilePath;\r
-\r
- /**\r
- set workspace path parameter for this action.\r
- \r
- @param workspacePath the string of workspace path.\r
- **/\r
- public void setWorkspacePath(String workspacePath) {\r
- this.workspacePath = workspacePath;\r
- }\r
-\r
- /**\r
- set fpd file path parameter for this action.\r
-\r
- @param fpdFilePath file path string\r
- **/\r
- public void setFPDFilePath(String fpdFilePath) {\r
- this.fpdFilePath = "./" + fpdFilePath;\r
- }\r
-\r
- /**\r
- check paramter for this action.\r
- \r
- @throw UIException wrong paramter.\r
- **/\r
- void checkParamter() throws UIException {\r
- File file = null;\r
-\r
- if((fpdFilePath == null) ||(workspacePath == null)) {\r
- throw new UIException("WorkspacePath and FPDFileName should be blank for CollectPCDAtion!");\r
- }\r
-\r
- if(fpdFilePath.length() == 0 || workspacePath.length() == 0) {\r
- throw new UIException("WorkspacePath and FPDFileName should be blank for CollectPCDAtion!");\r
- }\r
-\r
- file = new File(workspacePath);\r
- if(!file.exists()) {\r
- throw new UIException("WorkpacePath " + workspacePath + " does not exist!");\r
- }\r
-\r
- file = new File(fpdFilePath);\r
-\r
- if(!file.exists()) {\r
- throw new UIException("FPD File " + fpdFilePath + " does not exist!");\r
- }\r
- }\r
-\r
- /**\r
- Core workflow function.\r
- \r
- @throw UIException Fail to show PCD database.\r
- **/\r
- void performAction() throws UIException {\r
- CollectPCDAction collectAction = null;\r
- PCDDatabaseFrame dbFrame = null;\r
-\r
- //\r
- // Initialize global data.\r
- //\r
- GlobalData.initInfo("Tools" + File.separator + "Conf" + File.separator + "FrameworkDatabase.db",\r
- workspacePath,null);\r
-\r
- //\r
- // Collect PCD information.\r
- //\r
- collectAction = new CollectPCDAction();\r
-\r
- try {\r
- collectAction.perform(workspacePath,\r
- fpdFilePath,\r
- ActionMessage.LOG_MESSAGE_LEVEL);\r
- } catch(Exception exp) {\r
- throw new UIException(exp.getMessage());\r
- }\r
-\r
- //\r
- // Start tree windows.\r
- //\r
- dbFrame = new PCDDatabaseFrame(GlobalData.getPCDMemoryDBManager());\r
- }\r
-\r
- /**\r
- Entry function.\r
- \r
- The action is run from command line.\r
- \r
- @param argv command line parameter.\r
- **/\r
- public static void main(String[] argv) throws UIException {\r
- ShowPCDDatabaseAction showAction = new ShowPCDDatabaseAction();\r
- //showAction.setWorkspacePath(argv[0]);\r
- //showAction.setFPDFilePath(argv[1]);\r
- showAction.setWorkspacePath("e:/tianocore/edk2");\r
- showAction.setFPDFilePath("EdkNt32Pkg/Nt32.fpd");\r
- showAction.execute();\r
- }\r
-}\r
+++ /dev/null
-/** @file\r
- UIAction class.\r
-\r
- This class is the parent action class of UI wizard.\r
- \r
-Copyright (c) 2006, Intel Corporation\r
-All rights reserved. This program and the accompanying materials\r
-are licensed and made available under the terms and conditions of the BSD License\r
-which accompanies this distribution. The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
- \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-**/\r
-\r
-package org.tianocore.build.pcd.action;\r
-\r
-import org.tianocore.build.pcd.exception.UIException;\r
-\r
-/** This class is the parent class for all UI wizard action.\r
-**/\r
-public abstract class UIAction {\r
- ///\r
- /// original message level. when finish this action, original \r
- /// message level will be restored.\r
- ///\r
- private int originalMessageLevel;\r
-\r
- /**\r
- Check the parameter for this aciton.\r
- \r
- This function will be overrided by child class.\r
- **/\r
- abstract void checkParamter() throws UIException;\r
-\r
- /**\r
- Perform action.\r
- \r
- This function will be overrided by child class.\r
- **/\r
- abstract void performAction() throws UIException;\r
-\r
- /**\r
- set the message level for this action.\r
-\r
- @param messageLevel message level wanted.\r
- **/\r
- public void setMessageLevel(int messageLevel) {\r
- originalMessageLevel = ActionMessage.messageLevel;\r
- ActionMessage.messageLevel = messageLevel;\r
- }\r
-\r
- /**\r
- log message for UI wizard aciton.\r
-\r
- @param actionObj aciton instance object.\r
- @param logStr log message string\r
- **/\r
- public static void logMsg(Object actionObj, String logStr) {\r
- System.out.println(logStr);\r
- }\r
-\r
- /**\r
- Warning message for UI wizard action.\r
-\r
- @param warningObj action instance object.\r
- @param warningStr warning message string.\r
- **/\r
- public static void warningMsg(Object warningObj, String warningStr) {\r
- System.out.println(warningStr);\r
- }\r
-\r
- /**\r
- Entry function for all UI wizard actions.\r
- **/\r
- public void execute() throws UIException {\r
- checkParamter();\r
- performAction();\r
-\r
- ActionMessage.messageLevel = originalMessageLevel;\r
- }\r
-}\r
usageInstance.arch,\r
usageInstance.version)) {\r
exceptionStr = String.format("PCD %s for module %s has already exist in database, Please check all PCD build entries "+\r
- "in modules PcdPeim in <ModuleSA> to make sure no duplicated definitions!",\r
+ "in modules %s in <ModuleSA> to make sure no duplicated definitions!",\r
usageInstance.parentToken.cName,\r
+ usageInstance.moduleName,\r
usageInstance.moduleName);\r
throw new EntityException(exceptionStr);\r
}\r
+++ /dev/null
-/** @file\r
- PCDDatabaseFrame class.\r
-\r
- The class is the frame class for displaying PCD database in tree method.\r
- \r
-Copyright (c) 2006, Intel Corporation\r
-All rights reserved. This program and the accompanying materials\r
-are licensed and made available under the terms and conditions of the BSD License\r
-which accompanies this distribution. The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
- \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-**/ \r
-package org.tianocore.build.pcd.ui;\r
-\r
-import java.awt.*;\r
-import java.awt.event.*;\r
-import java.util.Map;\r
-\r
-import javax.swing.*;\r
-import javax.swing.tree.DefaultMutableTreeNode;\r
-\r
-import org.tianocore.build.pcd.action.ActionMessage;\r
-import org.tianocore.build.pcd.entity.MemoryDatabaseManager;\r
-import org.tianocore.build.pcd.entity.Token;\r
-import org.tianocore.build.pcd.entity.UsageInstance;\r
-\r
-/**\r
- The class is the frame class for displaying PCD database in tree method.\r
-**/\r
-public class PCDDatabaseFrame extends JFrame {\r
- static final long serialVersionUID = -7034897190740068939L;\r
- ///\r
- /// Database instance \r
- ///\r
- private MemoryDatabaseManager dbManager;\r
- ///\r
- /// The token and module tree\r
- ///\r
- private JTree databaseTree;\r
-\r
- /**\r
- Constructure function. \r
- \r
- Create the UI component and display frame.\r
-\r
- @param dbManager databaase manager instance.\r
- **/\r
- public PCDDatabaseFrame(MemoryDatabaseManager dbManager) {\r
- if (dbManager != null) {\r
- this.dbManager = dbManager;\r
- }\r
- //\r
- // Put the frame into center of desktop.\r
- //\r
- setLocation(100, 100);\r
- initializeComponent();\r
-\r
- setTitle("PCD View Tool");\r
- pack();\r
- setVisible(true);\r
- }\r
-\r
- /**\r
- Initliaze the UI component in Display frame.\r
- **/\r
- public void initializeComponent() {\r
- JScrollPane scrollPane = new JScrollPane();\r
- Container contentPane = getContentPane();\r
-\r
- contentPane.setLayout(new BorderLayout());\r
- scrollPane.setViewportView(initializeTree());\r
- contentPane.add(scrollPane);\r
-\r
- addWindowListener(new PCDDatabaseFrameAdapter());\r
- }\r
-\r
- /**\r
- Initiliaze the TREE control.\r
- **/\r
- public JTree initializeTree() {\r
- Token[] tokenArray = null;\r
- Token token = null;\r
- DefaultMutableTreeNode root = new DefaultMutableTreeNode("PCDTreeRoot");\r
- DefaultMutableTreeNode rootByPCD = new DefaultMutableTreeNode("By PCD");\r
- DefaultMutableTreeNode rootByModule = new DefaultMutableTreeNode("By Module");\r
- DefaultMutableTreeNode tokenNode = null;\r
- DefaultMutableTreeNode usageNode = null;\r
- DefaultMutableTreeNode moduleNode = null;\r
- java.util.List<String> moduleNames = null;\r
- int index = 0; \r
- int usageIndex = 0;\r
- int moduleIndex = 0;\r
- Object[] objectArray = null;\r
- java.util.List<UsageInstance> usageArray = null;\r
- UsageInstance usageInstance = null;\r
-\r
- root.add(rootByPCD);\r
- //\r
- // By PCD Node\r
- //\r
-\r
- tokenArray = dbManager.getRecordArray();\r
- for (index = 0; index < tokenArray.length; index ++) {\r
- token = tokenArray[index];\r
- ActionMessage.debug(this, token.cName);\r
- tokenNode = new DefaultMutableTreeNode(token.cName);\r
- tokenNode.add(new DefaultMutableTreeNode(String.format("TOKEN NUMBER: 0x%08x", token.tokenNumber)));\r
- tokenNode.add(new DefaultMutableTreeNode("TOKEN SPACE NAME: " + token.tokenSpaceName.toString()));\r
- tokenNode.add(new DefaultMutableTreeNode("DATUM TYPE: " +Token.getStringOfdatumType(token.datumType)));\r
- //tokenNode.add(new DefaultMutableTreeNode("VARIABLE GUID: " + token.variableGuid.toString()));\r
-\r
- usageNode = new DefaultMutableTreeNode("PRODUCER");\r
- tokenNode.add(usageNode);\r
-\r
-\r
- //\r
- // Prepare consumer's leaf node\r
- //\r
- usageNode = new DefaultMutableTreeNode("CONSUMER");\r
- tokenNode.add(usageNode);\r
- objectArray = token.consumers.entrySet().toArray();\r
- for (usageIndex = 0; usageIndex < token.consumers.size(); usageIndex ++) {\r
- usageInstance = (UsageInstance) ((Map.Entry)objectArray[usageIndex]).getValue();\r
- usageNode.add(new DefaultMutableTreeNode(usageInstance.getPrimaryKey()));\r
- }\r
-\r
- rootByPCD.add(tokenNode);\r
- }\r
-\r
- //\r
- // BY MODULE Node\r
- //\r
- root.add(rootByModule);\r
- moduleNames = dbManager.getAllModuleArray();\r
- for (moduleIndex = 0; moduleIndex < moduleNames.size(); moduleIndex ++) {\r
- ActionMessage.debug(this, "ModuleName:" + moduleNames.get(moduleIndex));\r
- }\r
- for (moduleIndex = 0; moduleIndex < moduleNames.size(); moduleIndex ++) {\r
- moduleNode = new DefaultMutableTreeNode(moduleNames.get(moduleIndex));\r
- usageArray = dbManager.getUsageInstanceArrayByKeyString(moduleNames.get(moduleIndex));\r
- for (usageIndex = 0; usageIndex < usageArray.size(); usageIndex ++) {\r
- usageInstance = usageArray.get(usageIndex);\r
- usageNode = new DefaultMutableTreeNode(usageInstance.parentToken.cName);\r
- usageNode.add(new DefaultMutableTreeNode("MODULE PCD TYPE: " + Token.getStringOfpcdType(usageInstance.modulePcdType)));\r
- moduleNode.add(usageNode);\r
- }\r
- rootByModule.add(moduleNode);\r
- }\r
-\r
- databaseTree = new JTree(root);\r
- return databaseTree;\r
- }\r
-}\r
-\r
-/**\r
- The adatper class for PCDDatabaseFrame. This class instance many windows message \r
- callback function.\r
-**/\r
-class PCDDatabaseFrameAdapter extends WindowAdapter {\r
- public void windowClosing(WindowEvent e) {\r
- System.exit(0);\r
- }\r
-}\r