2cde9b24ec17e9ecf46a731d80f8000c2c9f3899
[mirror_edk2.git] / Tools / Source / GenBuild / org / tianocore / build / pcd / action / UIAction.java
1 /** @file
2 UIAction class.
3
4 This class is the parent action class of UI wizard.
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
17 package org.tianocore.build.pcd.action;
18
19 import org.tianocore.build.pcd.exception.UIException;
20
21 /** This class is the parent class for all UI wizard action.
22 **/
23 public abstract class UIAction {
24 ///
25 /// original message level. when finish this action, original
26 /// message level will be restored.
27 ///
28 private int originalMessageLevel;
29
30 /**
31 Check the parameter for this aciton.
32
33 This function will be overrided by child class.
34 **/
35 abstract void checkParamter() throws UIException;
36
37 /**
38 Perform action.
39
40 This function will be overrided by child class.
41 **/
42 abstract void performAction() throws UIException;
43
44 /**
45 set the message level for this action.
46
47 @param messageLevel message level wanted.
48 **/
49 public void setMessageLevel(int messageLevel) {
50 originalMessageLevel = ActionMessage.messageLevel;
51 ActionMessage.messageLevel = messageLevel;
52 }
53
54 /**
55 log message for UI wizard aciton.
56
57 @param actionObj aciton instance object.
58 @param logStr log message string
59 **/
60 public static void logMsg(Object actionObj, String logStr) {
61 System.out.println(logStr);
62 }
63
64 /**
65 Warning message for UI wizard action.
66
67 @param warningObj action instance object.
68 @param warningStr warning message string.
69 **/
70 public static void warningMsg(Object warningObj, String warningStr) {
71 System.out.println(warningStr);
72 }
73
74 /**
75 Entry function for all UI wizard actions.
76 **/
77 public void execute() throws UIException {
78 checkParamter();
79 performAction();
80
81 ActionMessage.messageLevel = originalMessageLevel;
82 }
83 }