af07e55165b8dcc95975805f069bc7ad16143b89
[mirror_edk2.git] / Tools / Source / GenBuild / org / tianocore / build / pcd / action / ShowPCDDatabaseAction.java
1 /** @file
2 ShowPCDDatabase class.
3
4 This class is the action to diplay the PCD database.
5
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
11
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.
14
15 **/
16 package org.tianocore.build.pcd.action;
17
18 import java.io.File;
19
20 import org.tianocore.build.global.GlobalData;
21 import org.tianocore.build.pcd.exception.UIException;
22 import org.tianocore.build.pcd.ui.PCDDatabaseFrame;
23
24 /** This class is the action to show PCD database.
25 **/
26 public class ShowPCDDatabaseAction extends UIAction {
27 ///
28 /// The workspace path parameter.
29 ///
30 private String workspacePath;
31 ///
32 /// The FpdfileName parameter.
33 ///
34 private String fpdFilePath;
35
36 /**
37 set workspace path parameter for this action.
38
39 @param workspacePath the string of workspace path.
40 **/
41 public void setWorkspacePath(String workspacePath) {
42 this.workspacePath = workspacePath;
43 }
44
45 /**
46 set fpd file path parameter for this action.
47
48 @param fpdFilePath file path string
49 **/
50 public void setFPDFilePath(String fpdFilePath) {
51 this.fpdFilePath = "./" + fpdFilePath;
52 }
53
54 /**
55 check paramter for this action.
56
57 @throw UIException wrong paramter.
58 **/
59 void checkParamter() throws UIException {
60 File file = null;
61
62 if((fpdFilePath == null) ||(workspacePath == null)) {
63 throw new UIException("WorkspacePath and FPDFileName should be blank for CollectPCDAtion!");
64 }
65
66 if(fpdFilePath.length() == 0 || workspacePath.length() == 0) {
67 throw new UIException("WorkspacePath and FPDFileName should be blank for CollectPCDAtion!");
68 }
69
70 file = new File(workspacePath);
71 if(!file.exists()) {
72 throw new UIException("WorkpacePath " + workspacePath + " does not exist!");
73 }
74
75 file = new File(fpdFilePath);
76
77 if(!file.exists()) {
78 throw new UIException("FPD File " + fpdFilePath + " does not exist!");
79 }
80 }
81
82 /**
83 Core workflow function.
84
85 @throw UIException Fail to show PCD database.
86 **/
87 void performAction() throws UIException {
88 CollectPCDAction collectAction = null;
89 PCDDatabaseFrame dbFrame = null;
90
91 //
92 // Initialize global data.
93 //
94 GlobalData.initInfo("Tools" + File.separator + "Conf" + File.separator + "FrameworkDatabase.db",
95 workspacePath,null);
96
97 //
98 // Collect PCD information.
99 //
100 collectAction = new CollectPCDAction();
101
102 try {
103 collectAction.perform(workspacePath,
104 fpdFilePath,
105 ActionMessage.LOG_MESSAGE_LEVEL);
106 } catch(Exception exp) {
107 throw new UIException(exp.getMessage());
108 }
109
110 //
111 // Start tree windows.
112 //
113 dbFrame = new PCDDatabaseFrame(GlobalData.getPCDMemoryDBManager());
114 }
115
116 /**
117 Entry function.
118
119 The action is run from command line.
120
121 @param argv command line parameter.
122 **/
123 public static void main(String[] argv) throws UIException {
124 ShowPCDDatabaseAction showAction = new ShowPCDDatabaseAction();
125 //showAction.setWorkspacePath(argv[0]);
126 //showAction.setFPDFilePath(argv[1]);
127 showAction.setWorkspacePath("e:/tianocore/edk2");
128 showAction.setFPDFilePath("EdkNt32Pkg/Nt32.fpd");
129 showAction.execute();
130 }
131 }