summaryrefslogtreecommitdiff
path: root/Tools/Source/GenBuild/org/tianocore/build/pcd/action/ShowPCDDatabaseAction.java
blob: 8af812347fc448e7ca08e45dc2ea9f888e3125c9 (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
/** @file
  ShowPCDDatabase class.

  This class is the action to diplay the PCD database.
 
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.action;

import java.io.File;

import org.tianocore.build.global.GlobalData;
import org.tianocore.build.pcd.exception.UIException;
import org.tianocore.build.pcd.ui.PCDDatabaseFrame;

/** This class is the action to show PCD database.
**/
public class ShowPCDDatabaseAction extends UIAction {
    ///
    /// The workspace path parameter.
    ///
    private String workspacePath;
    ///
    /// The FpdfileName parameter.
    ///
    private String fpdFilePath;

    /**
     set workspace path parameter for this action.
      
     @param workspacePath the string of workspace path.
    **/
    public void setWorkspacePath(String workspacePath) {
        this.workspacePath = workspacePath;
    }

    /**
      set fpd file path parameter for this action.

      @param fpdFilePath file path string
    **/
    public void setFPDFilePath(String fpdFilePath) {
        this.fpdFilePath = "./" + fpdFilePath;
    }

    /**
      check paramter for this action.
      
      @throw UIException wrong paramter.
    **/
    void checkParamter() throws UIException {
        File file = null;

        if((fpdFilePath    == null) ||(workspacePath  == null)) {
            throw new UIException("WorkspacePath and FPDFileName should be blank for CollectPCDAtion!");
        }

        if(fpdFilePath.length() == 0 || workspacePath.length() == 0) {
            throw new UIException("WorkspacePath and FPDFileName should be blank for CollectPCDAtion!");
        }

        file = new File(workspacePath);
        if(!file.exists()) {
            throw new UIException("WorkpacePath " + workspacePath + " does not exist!");
        }

        file = new File(fpdFilePath);

        if(!file.exists()) {
            throw new UIException("FPD File " + fpdFilePath + " does not exist!");
        }
    }

    /**
      Core workflow function.
      
      @throw UIException Fail to show PCD database.
    **/
    void performAction() throws UIException {
        CollectPCDAction  collectAction = null;
        PCDDatabaseFrame  dbFrame       = null;

        //
        // Initialize global data.
        //
        GlobalData.initInfo("Tools" + File.separator + "Conf" + File.separator + "FrameworkDatabase.db",
                            workspacePath);

        //
        // Collect PCD information.
        //
        collectAction = new CollectPCDAction();

        try {
            collectAction.perform(workspacePath,
                                  fpdFilePath,
                                  ActionMessage.LOG_MESSAGE_LEVEL);
        } catch(Exception exp) {
            throw new UIException(exp.getMessage());
        }

        //
        // Start tree windows.
        //
        dbFrame = new PCDDatabaseFrame(GlobalData.getPCDMemoryDBManager());
    }

    /**
      Entry function.
      
      The action is run from command line.
     
      @param argv command line parameter.
    **/
    public static void main(String[] argv) throws UIException {
        ShowPCDDatabaseAction showAction = new ShowPCDDatabaseAction();
        //showAction.setWorkspacePath(argv[0]);
        //showAction.setFPDFilePath(argv[1]);
        showAction.setWorkspacePath("M:/tianocore/edk2/trunk/edk2");
        showAction.setFPDFilePath("EdkNt32Pkg/Nt32.fpd");
        showAction.execute();
    }
}