Initial import.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@3 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
bbahnsen
2006-04-21 22:54:32 +00:00
commit 878ddf1fc3
2651 changed files with 624620 additions and 0 deletions

View File

@ -0,0 +1,3 @@
Manifest-Version: 1.0
Main-Class: org.tianocore.packaging.module.ui.ModuleMain
Class-Path: ../Jars/SurfaceArea.jar ../bin/xmlbeans/lib/jsr173_1.0_api.jar ../bin/xmlbeans/lib/xbean.jar ../bin/xmlbeans/lib/xbean_xpath.jar ../bin/xmlbeans/lib/xmlpublic.jar ../bin/xmlbeans/lib/saxon8.jar ../bin/xmlbeans/lib/saxon8-jdom.jar ../bin/xmlbeans/lib/saxon8-sql.jar ../bin/xmlbeans/lib/resolver.jar

View File

@ -0,0 +1,44 @@
<?xml version="1.0"?>
<!--
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.
-->
<project name="ModuleEditor" default="all" basedir=".">
<taskdef resource="net/sf/antcontrib/antlib.xml"/>
<property environment="env"/>
<property name="WORKSPACE" value="${env.WORKSPACE}"/>
<path id="classpath">
<fileset dir="${WORKSPACE}/Tools/Jars" includes="*.jar"/>
<fileset dir="${WORKSPACE}/Tools/bin/xmlbeans/lib" includes="*.jar"/>
</path>
<property name="buildDir" value="build"/>
<property name="installLocation" value="${WORKSPACE}/Tools/bin"/>
<target name="all" depends="install"/>
<target name="source">
<mkdir dir="${buildDir}"/>
<javac srcdir="src" destdir="${buildDir}">
<classpath refid="classpath"/>
<!-- <compilerarg value="-Xlint"/> -->
</javac>
</target>
<target name="clean">
<delete dir="${buildDir}"/>
</target>
<target name="cleanall">
<delete dir="${buildDir}"/>
<delete file="${installLocation}/ModuleEditor.jar"/>
</target>
<target name="install" depends="source">
<jar destfile="${installLocation}/ModuleEditor.jar"
basedir="${buildDir}"
includes="**"
manifest="MANIFEST.MF"
/>
</target>
</project>

View File

@ -0,0 +1,44 @@
/** @file
The file is used to define all used final variables
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.common;
/**
The class is used to define all used final variables
@since ModuleEditor 1.0
**/
public class DataType {
/**
@param args
**/
public static void main(String[] args) {
// TODO Auto-generated method stub
}
//
// Define all used final variables
//
public static final String DOS_LINE_SEPARATOR = "\r\n";
public static final String UNXI_LINE_SEPARATOR = "\n";
public static final String EMPTY_SELECT_ITEM = "----";
}

View File

@ -0,0 +1,905 @@
/** @file
The file is used to provides all kinds of Data Validation interface
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.common;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
The class is used to provides all kinds of data validation interface
<p>All provided interfaces are in static mode</p>
@since ModuleEditor 1.0
**/
public class DataValidation {
/**
Reserved for test
@param args
**/
public static void main(String[] args) {
// TODO Auto-generated method stub
}
//
// The below is used to check common data types
//
/**
Check if the imput data is int
@param strInt The input string which needs validation
@retval true - The input is Int
@retval false - The input is not Int
**/
public static boolean isInt(String strInt) {
return isMatch("^-?[0-9]\\d*$", strInt);
}
/**
Check if the input data is int and it is in the valid scope
The scope is provided by String
@param strNumber The input string which needs validation
@param BeginNumber The left boundary of the scope
@param EndNumber The right boundary of the scope
@retval true - The input is Int and in the scope;
@retval false - The input is not Int or not in the scope
**/
public static boolean isInt(String strNumber, int BeginNumber, int EndNumber) {
//
//Check if the input data is int first
//
if (!isInt(strNumber)) {
return false;
}
//
//And then check if the data is between the scope
//
Integer intTemp = new Integer(strNumber);
if ((intTemp.intValue() < BeginNumber) || (intTemp.intValue() > EndNumber)) {
return false;
}
return true;
}
/**
Check if the input data is int and it is in the valid scope
The scope is provided by String
@param strNumber The input string which needs validation
@param strBeginNumber The left boundary of the scope
@param strEndNumber The right boundary of the scope
@retval true - The input is Int and in the scope;
@retval false - The input is not Int or not in the scope
**/
public static boolean isInt(String strNumber, String strBeginNumber, String strEndNumber) {
//
//Check if all input data are int
//
if (!isInt(strNumber)) {
return false;
}
if (!isInt(strBeginNumber)) {
return false;
}
if (!isInt(strEndNumber)) {
return false;
}
//
//And then check if the data is between the scope
//
Integer intI = new Integer(strNumber);
Integer intJ = new Integer(strBeginNumber);
Integer intK = new Integer(strEndNumber);
if ((intI.intValue() < intJ.intValue()) || (intI.intValue() > intK.intValue())) {
return false;
}
return true;
}
/**
Use regex to check if the input data is in valid format
@param strPattern The input regex
@param strMatcher The input data need be checked
@retval true - The data matches the regex
@retval false - The data doesn't match the regex
**/
public static boolean isMatch(String strPattern, String strMatcher) {
Pattern pattern = Pattern.compile(strPattern);
Matcher matcher = pattern.matcher(strMatcher);
return matcher.find();
}
//
// The below is used to check common customized data types
//
/**
Check if the input data is BaseNameConvention
@param strBaseNameConvention The input string need be checked
@retval true - The input is BaseNameConvention
@retval false - The input is not BaseNameConvention
**/
public static boolean isBaseNameConvention(String strBaseNameConvention) {
return isMatch("[A-Z]([a-zA-Z0-9])*(_)?([a-zA-Z0-9])*", strBaseNameConvention);
}
/**
Check if the input data is GuidArrayType
@param strGuidArrayType The input string need be checked
@retval true - The input is GuidArrayType
@retval false - The input is not GuidArrayType
**/
public static boolean isGuidArrayType(String strGuidArrayType) {
return isMatch(
"0x[a-fA-F0-9]{1,8},( )*0x[a-fA-F0-9]{1,4},( )*0x[a-fA-F0-9]{1,4}(,( )*\\{)?(,?( )*0x[a-fA-F0-9]{1,2}){8}( )*(\\})?",
strGuidArrayType);
}
/**
Check if the input data is GuidNamingConvention
@param strGuidNamingConvention The input string need be checked
@retval true - The input is GuidNamingConvention
@retval false - The input is not GuidNamingConvention
**/
public static boolean isGuidNamingConvention(String strGuidNamingConvention) {
return isMatch("[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}",
strGuidNamingConvention);
}
/**
Check if the input data is GuidType
@param strGuidType The input string need be checked
@retval true - The input is GuidType
@reture false is not GuidType
**/
public static boolean isGuidType(String strGuidType) {
return (isGuidArrayType(strGuidType) || isGuidNamingConvention(strGuidType));
}
/**
Check if the input data is Guid
@param strGuid The input string need be checked
@retval true - The input is Guid
@retval false - The input is not Guid
**/
public static boolean isGuid(String strGuid) {
return isGuidType(strGuid);
}
/**
Check if the input data is Sentence
@param strSentence The input string need be checked
@retval true - The input is Sentence
@retval false - The input is not Sentence
**/
public static boolean isSentence(String strSentence) {
return isMatch("(\\w+\\W*)+( )+(\\W*\\w*\\W*\\s*)*", strSentence);
}
/**
Check if the input data is DateType
@param strDateType The input string need be checked
@retval true - The input is DateType
@retval false - The input is not DateType
**/
public static boolean isDateType(String strDateType) {
return isMatch("[1-9][0-9][0-9][0-9]-[0-1][0-9]-[0-3][0-9] [0-2][0-9]:[0-5][0-9]", strDateType);
}
/**
Check if the input data is DosPath
@param strDosPath The input string need be checked
@retval true - The input is DosPath
@retval false - The input is not DosPath
**/
public static boolean isDosPath(String strDosPath) {
return isMatch("([a-zA-Z]:\\\\)?(((\\\\?_*-*.*[a-zA-Z0-9]*)*(_*-*.*[a-zA-Z0-9])*)+(\\\\)?)*", strDosPath);
}
/**
Check if the input data is UnixPath
@param strUnixPath The input string need be checked
@retval true - The input is UnixPath
@retval false - The input is not UnixPath
**/
public static boolean isUnixPath(String strUnixPath) {
return isMatch("(\\/)?(((_*-*.*[a-zA-Z0-9]*)*(_*-*.*[a-zA-Z0-9])*)+(\\/)?)*", strUnixPath);
}
/**
Check if the input data is DirectoryNamingConvention
@param strDirectoryNamingConvention The input string need be checked
@retval true - The input is DirectoryNamingConvention
@retval false - The input is not DirectoryNamingConvention
**/
public static boolean isDirectoryNamingConvention(String strDirectoryNamingConvention) {
return (isDosPath(strDirectoryNamingConvention) || isUnixPath(strDirectoryNamingConvention));
}
/**
Check if the input data is HexDoubleWordDataType
@param strHexDoubleWordDataType The input string need be checked
@retval true - The input is HexDoubleWordDataType
@retval false - The input is not HexDoubleWordDataType
**/
public static boolean isHexDoubleWordDataType(String strHexDoubleWordDataType) {
return isMatch("0x[a-fA-F0-9]{1,8}", strHexDoubleWordDataType);
}
/**
Check if the input data is V1
@param strV1 The input string need be checked
@retval true - The input is V1
@retval false - The input is not V1
**/
public static boolean isV1(String strV1) {
return isMatch("((%[A-Z](_*[A-Z0-9]*)*%)+((((\\\\)?_*-*.*[a-zA-Z0-9]*)*(_*-*.*[a-zA-Z0-9])*)+(\\\\)?)*)", strV1);
}
/**
Check if the input data is V2
@param strV2 The input string need be checked
@retval true - The input is V2
@retval false - The input is not V2
**/
public static boolean isV2(String strV2) {
return isMatch(
"(($[A-Z](_*[A-Z0-9]*)*)+||($\\([A-Z](_*[A-Z0-9]*)*\\))+||($\\{[A-Z](_*[A-Z0-9]*)*\\})+)+(\\/)?(((((_*-*.*[a-zA-Z0-9]*)*(_*-*.*[a-zA-Z0-9])*)+(\\/)?)*)*)",
strV2);
}
/**
Check if the input data is VariableConvention
@param strVariableConvention The input string need be checked
@retval true - The input is VariableConvention
@retval false - The input is not VariableConvention
**/
public static boolean isVariableConvention(String strVariableConvention) {
return (isV1(strVariableConvention) || isV2(strVariableConvention));
}
/**
Check if the input data is UCName
@param strUCName The input string need be checked
@retval true - The input is UCName
@retval false - The input is not UCName
**/
public static boolean isUCName(String strUCName) {
return isMatch("[A-Z]+(_*[A-Z0-9]*( )*)*", strUCName);
}
/**
Check if the input data is HexByteDataType
@param strHex64BitDataType The input string need be checked
@retval true - The input is HexByteDataType
@retval false - The input is not HexByteDataType
**/
public static boolean isHexByteDataType(String strHex64BitDataType) {
return isMatch("(0x)?[a-fA-F0-9]{1,2}", strHex64BitDataType);
}
/**
Check if the input data is Hex64BitDataType
@param strHex64BitDataType The input string need be checked
@retval true - The input is Hex64BitDataType
@retval false - The input is not Hex64BitDataType
**/
public static boolean isHex64BitDataType(String strHex64BitDataType) {
return isMatch("(0x)?[a-fA-F0-9]{1,16}", strHex64BitDataType);
}
/**
Check if the input data is HexWordDataType
@param strHexWordDataType The input string need be checked
@retval true - The input is HexWordDataType
@retval false - The input is not HexWordDataType
**/
public static boolean isHexWordDataType(String strHexWordDataType) {
return isMatch("0x[a-fA-F0-9]{1,4}", strHexWordDataType);
}
/**
Check if the input data is CName
@param strCName The input string need be checked
@retval true - The input is CName
@retval false - The input is not CName
**/
public static boolean isCName(String strCName) {
return isMatch("((_)*([a-zA-Z])+((_)*[a-zA-Z0-9]*))*", strCName);
}
/**
Check if the input data is OverrideID
@param strOverrideID The input string need be checked
@retval true - The input is OverrideID
@retval false - The input is not OverrideID
**/
public static boolean isOverrideID(String strOverrideID) {
return isInt(strOverrideID);
}
//
//The below is used to check msaheader data type
//
/**
Check if the input data is BaseName
@param strBaseName The input string need be checked
@retval true - The input is BaseName
@retval false - The input is not BaseName
**/
public static boolean isBaseName(String strBaseName) {
return isBaseNameConvention(strBaseName);
}
/**
Check if the input data is Abstract
@param strAbstract The input string need be checked
@retval true - The input is Abstract
@retval false - The input is not Abstract
**/
public static boolean isAbstract(String strAbstract) {
return isSentence(strAbstract);
}
/**
Check if the input data is Copyright
@param strCopyright The input string need be checked
@retval true - The input is Copyright
@retval false - The input is not Copyright
**/
public static boolean isCopyright(String strCopyright) {
return isSentence(strCopyright);
}
/**
Check if the input data is Created
@param strCreated The input string need be checked
@retval true - The input is Created
@retval false - The input is not Created
**/
public static boolean isCreated(String strCreated) {
return isDateType(strCreated);
}
/**
Check if the input data is Updated
@param strUpdated The input string need be checked
@retval true - The input is Updated
@retval false - The input is not Updated
**/
public static boolean isUpdated(String strUpdated) {
return isDateType(strUpdated);
}
//
// The below is used to check LibraryClass data types
//
/**
Check if the input data is LibraryClass
@param strLibraryClass The input string need be checked
@retval true - The input is LibraryClass
@retval false - The input is not LibraryClass
**/
public static boolean isLibraryClass(String strLibraryClass) {
return isBaseNameConvention(strLibraryClass);
}
//
// The below is used to check sourcefiles data types
//
/**
Check if the input data is Path
@param strPath The input string need be checked
@retval true - The input is Path
@retval false - The input is not Path
**/
public static boolean isPath(String strPath) {
return isDirectoryNamingConvention(strPath);
}
/**
Check if the input data is FileName
@param strFileName The input string need be checked
@retval true - The input is FileName
@retval false - The input is not FileName
**/
public static boolean isFileName(String strFileName) {
return isVariableConvention(strFileName);
}
//
// The below is used to check includes data types
//
/**
Check if the input data is UpdatedDate
@param strUpdatedDate The input string need be checked
@retval true - The input is UpdatedDate
@retval false - The input is not UpdatedDate
**/
public static boolean isUpdatedDate(String strUpdatedDate) {
return isDateType(strUpdatedDate);
}
/**
Check if the input data is PackageName
@param strPackageName The input string need be checked
@retval true - The input is PackageName
@retval false - The input is not PackageName
**/
public static boolean isPackageName(String strPackageName) {
return isBaseNameConvention(strPackageName);
}
//
// The below is used to check protocols data types
//
/**
Check if the input data is ProtocolName
@param strProtocolName The input string need be checked
@retval true - The input is ProtocolName
@retval false - The input is not ProtocolName
**/
public static boolean isProtocolName(String strProtocolName) {
return isCName(strProtocolName);
}
/**
Check if the input data is ProtocolNotifyName
@param strProtocolNotifyName The input string need be checked
@retval true - The input is ProtocolNotifyName
@retval false - The input is not ProtocolNotifyName
**/
public static boolean isProtocolNotifyName(String strProtocolNotifyName) {
return isCName(strProtocolNotifyName);
}
//
// The below is used to check ppis data types
//
/**
Check if the input data is PpiName
@param strPpiName The input string need be checked
@retval true - The input is PpiName
@retval false - The input is not PpiName
**/
public static boolean isPpiName(String strPpiName) {
return isCName(strPpiName);
}
/**
Check if the input data is PpiNotifyName
@param strPpiNotifyName The input string need be checked
@retval true - The input is PpiNotifyName
@retval false - The input is not PpiNotifyName
**/
public static boolean isPpiNotifyName(String strPpiNotifyName) {
return isCName(strPpiNotifyName);
}
/**
Check if the input data is FeatureFlag
@param strFeatureFlag The input string need be checked
@retval true - The input is FeatureFlag
@retval false - The input is not FeatureFlag
**/
public static boolean isFeatureFlag(String strFeatureFlag) {
return isCName(strFeatureFlag);
}
//
// The below is used to check variable data types
//
/**
Check if the input data is ByteOffset
@param strByteOffset The input string need be checked
@retval true - The input is ByteOffset
@retval false - The input is not ByteOffset
**/
public static boolean isByteOffset(String strByteOffset) {
return isByteOffset(strByteOffset);
}
/**
Check if the input data is BitOffset
@param strBitOffset The input string need be checked
@retval true - The input is BitOffset
@retval false - The input is not BitOffset
**/
public static boolean isBitOffset(String strBitOffset) {
return isInt(strBitOffset, 0, 8);
}
/**
Check if the input data is OffsetBitSize
@param strOffsetBitSize The input string need be checked
@retval true - The input is OffsetBitSize
@retval false - The input is not OffsetBitSize
**/
public static boolean isOffsetBitSize(String strOffsetBitSize) {
return isInt(strOffsetBitSize, 0, 7);
}
//
// The below is used to check formsets data types
//
/**
Check if the input data is Formsets
@param strFormsets The input string need be checked
@retval true - The input is Formsets
@retval false - The input is not Formsets
**/
public static boolean isFormsets(String strFormsets) {
return isCName(strFormsets);
}
//
// The below is used to check externs data types
//
/**
Check if the input data is Constructor
@param strConstructor The input string need be checked
@retval true - The input is Constructor
@retval false - The input is not Constructor
**/
public static boolean isConstructor(String strConstructor) {
return isCName(strConstructor);
}
/**
Check if the input data is Destructor
@param strDestructor The input string need be checked
@retval true - The input is Destructor
@retval false - The input is not Destructor
**/
public static boolean isDestructor(String strDestructor) {
return isCName(strDestructor);
}
/**
Check if the input data is DriverBinding
@param strDriverBinding The input string need be checked
@retval true - The input is DriverBinding
@retval false - The input is not DriverBinding
**/
public static boolean isDriverBinding(String strDriverBinding) {
return isCName(strDriverBinding);
}
/**
Check if the input data is ComponentName
@param strComponentName The input string need be checked
@retval true - The input is ComponentName
@retval false - The input is not ComponentName
**/
public static boolean isComponentName(String strComponentName) {
return isCName(strComponentName);
}
/**
Check if the input data is DriverConfig
@param strDriverConfig The input string need be checked
@retval true - The input is DriverConfig
@retval false - The input is not DriverConfig
**/
public static boolean isDriverConfig(String strDriverConfig) {
return isCName(strDriverConfig);
}
/**
Check if the input data is DriverDiag
@param strDriverDiag The input string need be checked
@retval true - The input is DriverDiag
@retval false - The input is not DriverDiag
**/
public static boolean isDriverDiag(String strDriverDiag) {
return isCName(strDriverDiag);
}
/**
Check if the input data is SetVirtualAddressMapCallBack
@param strSetVirtualAddressMapCallBack The input string need be checked
@retval true - The input is SetVirtualAddressMapCallBack
@retval false - The input is not SetVirtualAddressMapCallBack
**/
public static boolean isSetVirtualAddressMapCallBack(String strSetVirtualAddressMapCallBack) {
return isCName(strSetVirtualAddressMapCallBack);
}
/**
Check if the input data is ExitBootServicesCallBack
@param strExitBootServicesCallBack The input string need be checked
@retval true - The input is ExitBootServicesCallBack
@retval false - The input is not ExitBootServicesCallBack
**/
public static boolean isExitBootServicesCallBack(String strExitBootServicesCallBack) {
return isCName(strExitBootServicesCallBack);
}
/**
Check if the input data is UserDefined
@param strUserDefined The input string need be checked
@retval true - The input is UserDefined
@retval false - The input is not UserDefined
**/
public static boolean isUserDefined(String strUserDefined) {
return isCName(strUserDefined);
}
//
// The below is used to check PCDs data types
//
/**
Check if the input data is Token
@param strToken The input string need be checked
@retval true - The input is Token
@retval false - The input is not Token
**/
public static boolean isToken(String strToken) {
return isHexDoubleWordDataType(strToken);
}
/**
Check if the input data is MaxSku
@param strMaxSku The input string need be checked
@retval true - The input is MaxSku
@retval false - The input is not MaxSku
**/
public static boolean isMaxSku(String strMaxSku) {
return isHexByteDataType(strMaxSku);
}
/**
Check if the input data is SkuId
@param strSkuId The input string need be checked
@retval true - The input is SkuId
@retval false - The input is not SkuId
**/
public static boolean isSkuId(String strSkuId) {
return isHexByteDataType(strSkuId);
}
/**
Check if the input data is DatumSize
@param strDatumSize The input string need be checked
@retval true - The input is DatumSize
@retval false - The input is not DatumSize
**/
public static boolean isDatumSize(String strDatumSize) {
return isInt(strDatumSize, 1, 16777215);
}
/**
Check if the input data is VariableGuid
@param strVariableGuid The input string need be checked
@retval true - The input is VariableGuid
@retval false - The input is not VariableGuid
**/
public static boolean isVariableGuid(String strVariableGuid) {
return (isGuid(strVariableGuid) || strVariableGuid.equals("0"));
}
/**
Check if the input data is DataOffset
@param strDataOffset The input string need be checked
@retval true - The input is DataOffset
@retval false - The input is not DataOffset
**/
public static boolean isDataOffset(String strDataOffset) {
return isHex64BitDataType(strDataOffset);
}
/**
Check if the input data is GuidOffset
@param strGuidOffset The input string need be checked
@retval true - The input is GuidOffset
@retval false - The input is not GuidOffset
**/
public static boolean isGuidOffset(String strGuidOffset) {
return isHex64BitDataType(strGuidOffset);
}
}

View File

@ -0,0 +1,87 @@
/** @file
The file is used to override FileFilter to provides customized interfaces
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.common;
import java.io.File;
import javax.swing.filechooser.FileFilter;
/**
The class is used to override FileFilter to provides customized interfaces
@since ModuleEditor 1.0
**/
public class IFileFilter extends FileFilter {
private String strExt;
/**
Reserved for test
@param args
**/
public static void main(String[] args) {
// TODO Auto-generated method stub
}
/**
This is the default constructor
@param ext
**/
public IFileFilter(String ext) {
this.strExt = ext;
}
/* (non-Javadoc)
* @see javax.swing.filechooser.FileFilter#accept(java.io.File)
*
* Override method "accept"
*
*/
public boolean accept(File file) {
if (file.isDirectory()) {
return true;
}
String strFileName = file.getName();
int intIndex = strFileName.lastIndexOf('.');
if (intIndex > 0 && intIndex < strFileName.length() - 1) {
String strExtension = strFileName.substring(intIndex + 1).toLowerCase();
if (strExtension.equals(strExt))
return true;
}
return false;
}
/* (non-Javadoc)
* @see javax.swing.filechooser.FileFilter#getDescription()
*
* Override method "getDescription" to config description via different file type
*
*/
public String getDescription() {
if (strExt.equals("msa"))
return "Module Surface Area File(*.msa)";
if (strExt.equals("mbd"))
return "Module Build Description File(*.mbd)";
return "";
}
}

View File

@ -0,0 +1,211 @@
/** @file
The file is used to provides static interfaces to save log and error information
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.common;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import javax.swing.JOptionPane;
/**
The class is used to provides static interfaces to save log and error information
@since ModuleEditor 1.0
**/
public class Log {
//
//Log file
//
private static File fleLogFile = null;
//
//Err file
//
private static File fleErrFile = null;
//
//Log file name
//
static String strLogFileName = "Log.log";
//
//Err file name
//
static String strErrFileName = "Err.log";
/**
Main class, used for test
@param args
**/
public static void main(String[] args) {
try {
Log.log("Test", "test");
Log.err("Test1", "test1");
Log.err("sdfsdfsd fsdfsdfsdfsdfj dsfksdjflsdjf sdkfjsdklfjsdkf dskfsjdkfjks dskfjsdklfjsdkf sdkfjsdlf sdkfjsdk kdfjskdf sdkfjsdkf ksdjfksdfjskdf sdkfsjdfksd fskdfjsdf", "dfsdf sdfksdf sd sdfksd fsdf");
} catch (Exception e) {
e.printStackTrace();
}
}
/**
This is the default constructor
Do nothing
**/
public Log() {
}
/**
Call writeToLogFile to save log item and log information to log file
@param strItem The log item
@param strLog The log information
**/
public static void log(String strItem, String strLog) {
try {
writeToLogFile(strItem + ":" + strLog);
} catch (IOException e) {
e.printStackTrace();
}
}
/**
Call writeToLogFile to save log information to log file
@param strLog The log information
**/
public static void log(String strLog) {
try {
writeToLogFile(strLog);
} catch (IOException e) {
e.printStackTrace();
}
}
/**
Call writeToErrFile to save err item and err information to err file
@param strItem The err item
@param strLog The err information
**/
public static void err(String strItem, String strErr) {
try {
writeToErrFile("Error when " + strItem + "::" + strErr);
showErrMessage("Error when " + strItem + "::" + strErr);
} catch (IOException e) {
e.printStackTrace();
}
}
/**
Call writeToErrFile to save err information to err file
@param strLog The err information
**/
public static void err(String strErr) {
try {
writeToErrFile("Error::" + strErr);
showErrMessage("Error::" + strErr);
} catch (IOException e) {
e.printStackTrace();
}
}
/**
Brings up a dialog to show err message
When the message's length > defined max length, wrap the text to the next line.
@param strErr The input data of err message
**/
private static void showErrMessage(String strErr) {
int intMaxLength = 40;
String strReturn = "";
String strTemp = "";
while (strErr.length() > 0) {
if (strErr.length() > intMaxLength) {
strTemp = strErr.substring(0, intMaxLength);
strErr = strErr.substring(strTemp.length());
strReturn = strReturn + strTemp + DataType.UNXI_LINE_SEPARATOR;
} else if (strErr.length() <= intMaxLength) {
strReturn = strReturn + strErr;
strErr = "";
}
}
JOptionPane.showConfirmDialog(null, strReturn, "Error", JOptionPane.DEFAULT_OPTION, JOptionPane.ERROR_MESSAGE);
}
/**
Open log file and write log information
@param strLog The log information
@throws IOException
**/
private static void writeToLogFile(String strLog) throws IOException {
try {
if (fleLogFile == null) {
fleLogFile = new File(strLogFileName);
fleLogFile.createNewFile();
}
FileOutputStream fos = new FileOutputStream(fleLogFile, true);
fos.write((Tools.getCurrentDateTime() + DataType.DOS_LINE_SEPARATOR).getBytes());
fos.write((strLog + DataType.DOS_LINE_SEPARATOR).getBytes());
fos.flush();
fos.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
/**
Open err file and write err information
@param strLog The log information
@throws IOException
**/
private static void writeToErrFile(String strLog) throws IOException {
try {
if (fleErrFile == null) {
fleErrFile = new File(strErrFileName);
fleErrFile.createNewFile();
}
FileOutputStream fos = new FileOutputStream(fleErrFile, true);
fos.write((Tools.getCurrentDateTime() + DataType.DOS_LINE_SEPARATOR).getBytes());
fos.write((strLog + DataType.DOS_LINE_SEPARATOR).getBytes());
fos.flush();
fos.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
}

View File

@ -0,0 +1,120 @@
/** @file
The file is used to provides some useful interfaces
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.common;
import java.io.File;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.UUID;
/**
The class is used to provides some useful interfaces
@since ModuleEditor 1.0
**/
public class Tools {
/**
Used for test
@param args
**/
public static void main(String[] args) {
System.out.println(getCurrentDateTime());
}
/**
Get current date and time and format it as "yyyy-MM-dd HH:mm"
@return formatted current date and time
**/
public static String getCurrentDateTime() {
Date now = new Date(System.currentTimeMillis());
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
return sdf.format(now);
}
/**
Delete a folder and all its files
@param fleFolderName The name of the folder which need be deleted
@retval true - Delete successfully
@retval false - Delete successfully
**/
public static boolean deleteFolder(File fleFolderName) {
boolean blnIsDeleted = true;
File[] aryAllFiles = fleFolderName.listFiles();
for (int indexI = 0; indexI < aryAllFiles.length; indexI++) {
if (blnIsDeleted) {
if (aryAllFiles[indexI].isDirectory()) {
//
//If is a directory, recursively call this function to delete sub folders
//
blnIsDeleted = deleteFolder(aryAllFiles[indexI]);
} else if (aryAllFiles[indexI].isFile()) {
//
//If is a file, delete it
//
if (!aryAllFiles[indexI].delete()) {
blnIsDeleted = false;
}
}
}
}
if (blnIsDeleted) {
fleFolderName.delete();
}
return blnIsDeleted;
}
/**
Generate a UUID
@return the created UUID
**/
public static String generateUuidString() {
return UUID.randomUUID().toString();
}
/**
Get all system properties and output to the console
**/
public static void getSystemProperties() {
System.out.println(System.getProperty("java.class.version"));
System.out.println(System.getProperty("java.class.path"));
System.out.println(System.getProperty("java.ext.dirs"));
System.out.println(System.getProperty("os.name"));
System.out.println(System.getProperty("os.arch"));
System.out.println(System.getProperty("os.version"));
System.out.println(System.getProperty("file.separator"));
System.out.println(System.getProperty("path.separator"));
System.out.println(System.getProperty("line.separator"));
System.out.println(System.getProperty("user.name"));
System.out.println(System.getProperty("user.home"));
System.out.println(System.getProperty("user.dir"));
System.out.println(System.getProperty("PATH"));
System.out.println(System.getenv("PROCESSOR_REVISION"));
}
}

View File

@ -0,0 +1,265 @@
/** @file
The file is used to popup a exit confirmation window when program exists
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.packaging.common.ui;
import java.awt.Dimension;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
/**
The class is used to popup a exit confirmation window when program exists
It extends JDialog and implements ActionListener and WindowListener
@since ModuleEditor 1.0
**/
public class ExitConfirm extends JDialog implements ActionListener, WindowListener {
///
/// Define class Serial Version UID
///
private static final long serialVersionUID = -5875921789385911029L;
private JPanel jContentPane = null;
private JLabel jLabelMessage = null;
private JLabel jLabelResume = null;
private JLabel jLabelExit = null;
private JButton jButtonResume = null;
private JButton jButtonExit = null;
public boolean isCancel = false;
/**
This method initializes jButtonResume
@return javax.swing.JButton jButtonResume
**/
private JButton getJButtonResume() {
if (jButtonResume == null) {
jButtonResume = new JButton();
jButtonResume.setText("Resume");
jButtonResume.setSize(new java.awt.Dimension(90, 20));
jButtonResume.setLocation(new java.awt.Point(150, 105));
jButtonResume.setMnemonic('R');
jButtonResume.addActionListener(this);
}
return jButtonResume;
}
/**
This method initializes jButtonExit
@return javax.swing.JButton jButtonExit
**/
private JButton getJButtonExit() {
if (jButtonExit == null) {
jButtonExit = new JButton();
jButtonExit.setText("Exit");
jButtonExit.setSize(new java.awt.Dimension(90, 20));
jButtonExit.setLocation(new java.awt.Point(260, 105));
jButtonExit.setMnemonic('x');
jButtonExit.addActionListener(this);
}
return jButtonExit;
}
/**
Main clasee, reserved for test
@param args
**/
public static void main(String[] args) {
// TODO Auto-generated method stub
}
/**
This is the default constructor
**/
public ExitConfirm(IFrame parentFrame, boolean modal) {
super(parentFrame, modal);
initialize();
}
/**
This method initializes this
@return void
**/
private void initialize() {
this.setSize(500, 170);
this.setTitle("Exit");
this.setResizable(false);
this.setContentPane(getJContentPane());
this.addWindowListener(this);
//
//Set DO_NOTHING_ON_CLOSE when click Close button on title bar
//
this.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
centerWindow();
}
/**
This method initializes jContentPane
@return javax.swing.JPanel jContentPane
**/
private JPanel getJContentPane() {
if (jContentPane == null) {
jLabelExit = new JLabel();
jLabelExit.setSize(new java.awt.Dimension(450, 20));
jLabelExit.setLocation(new java.awt.Point(25, 70));
jLabelResume = new JLabel();
jLabelResume.setSize(new java.awt.Dimension(450, 20));
jLabelResume.setLocation(new java.awt.Point(25, 40));
jLabelMessage = new JLabel();
jLabelMessage.setSize(new java.awt.Dimension(450, 20));
jLabelMessage.setLocation(new java.awt.Point(25, 10));
jContentPane = new JPanel();
jContentPane.setLayout(null);
jContentPane.add(jLabelMessage, null);
jContentPane.add(jLabelResume, null);
jContentPane.add(jLabelExit, null);
jContentPane.add(getJButtonResume(), null);
jContentPane.add(getJButtonExit(), null);
}
return jContentPane;
}
/**
Call setWarningMessage to set messages of frame when it is used for Setup
**/
public void setSetupMessage() {
String strTitle = "Exit Setup";
String strMessage = "Setup is not complete. If you quit now, the program will not be installed.";
String strResume = "You may run the setup program at a later time to complete the installation.";
String strExit = "To continue installing, click Resume. To quit the Setup program, click Exit.";
setWarningMessage(strTitle, strMessage, strResume, strExit);
}
/**
Call setWarningMessage to set messages of frame when it is used for Module Main GUI
**/
public void setModuleMessage() {
String strTitle = "Exit";
String strMessage = "Do you really want to quit now?";
String strResume = "All unsaved module information will be lost.";
String strExit = "To continue editing module, click Resume. To quit the program, click Exit.";
setWarningMessage(strTitle, strMessage, strResume, strExit);
}
/**
Set message information via input data
@param strTitle The title value
@param strMessage The main message value
@param strResume The resume message value
@param strExit The exit message value
**/
private void setWarningMessage(String strTitle, String strMessage, String strResume, String strExit) {
this.setTitle(strTitle);
jLabelMessage.setText(strMessage);
jLabelResume.setText(strResume);
jLabelExit.setText(strExit);
}
/* (non-Javadoc)
* @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
*
* Override actionPerformed to listern all actions
*
*/
public void actionPerformed(ActionEvent arg0) {
//
//Set isCancel true when click button "Exit"
//
Object obj = arg0.getSource();
if (obj == jButtonResume) {
isCancel = false;
}
if (obj == jButtonExit) {
isCancel = true;
}
this.setVisible(false);
}
/**
Make the window in the center of the screen
**/
private void centerWindow() {
Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
this.setLocation((d.width - this.getSize().width) / 2, (d.height - this.getSize().height) / 2);
}
public void windowActivated(WindowEvent arg0) {
// TODO Auto-generated method stub
}
public void windowClosed(WindowEvent arg0) {
// TODO Auto-generated method stub
}
public void windowClosing(WindowEvent arg0) {
isCancel = false;
this.setVisible(false);
}
public void windowDeactivated(WindowEvent arg0) {
// TODO Auto-generated method stub
}
public void windowDeiconified(WindowEvent arg0) {
// TODO Auto-generated method stub
}
public void windowIconified(WindowEvent arg0) {
// TODO Auto-generated method stub
}
public void windowOpened(WindowEvent arg0) {
// TODO Auto-generated method stub
}
}

View File

@ -0,0 +1,196 @@
/** @file
The file is used to override JComboBox to provides customized interfaces
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.packaging.common.ui;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JPanel;
/**
The class is used to override JComboBox to provides customized interfaces
It extends JComboBox implements KeyListener, MouseListener and FocusListener
@since ModuleEditor 1.0
**/
public class IComboBox extends JComboBox implements KeyListener, MouseListener, FocusListener {
///
/// Define class Serial Version UID
///
private static final long serialVersionUID = -1940262568168458911L;
public void focusGained(FocusEvent arg0) {
// TODO Auto-generated method stub
}
/* (non-Javadoc)
* @see java.awt.event.FocusListener#focusLost(java.awt.event.FocusEvent)
*
* Override focusLost to exit edit mode
*
*/
public void focusLost(FocusEvent arg0) {
this.closeEdit();
}
/**
Main class, used for test
@param args
**/
public static void main(String[] args) {
JFrame jf = new JFrame();
jf.setSize(500, 200);
JPanel jp = new JPanel();
jp.setLayout(null);
IComboBox icb = new IComboBox();
jp.add(icb, null);
jf.setContentPane(jp);
jf.setVisible(true);
}
/**
This is the default constructor
**/
public IComboBox() {
super();
init();
}
/**
This method initializes this
**/
private void init() {
this.setSize(320, 20);
this.setEditable(false);
this.editor.addActionListener(this);
this.addMouseListener(this);
this.addKeyListener(this);
this.getEditor().getEditorComponent().addKeyListener(this);
this.getEditor().getEditorComponent().addFocusListener(this);
}
public void keyPressed(KeyEvent arg0) {
// TODO Auto-generated method stub
}
/* (non-Javadoc)
* @see java.awt.event.KeyListener#keyReleased(java.awt.event.KeyEvent)
*
* Override keyReleased to listen key action
*
*/
public void keyReleased(KeyEvent arg0) {
//
//Add new item to list when press ENTER
//
if (arg0.getSource() == this.getEditor().getEditorComponent()) {
if (arg0.getKeyCode() == KeyEvent.VK_ENTER) {
String strCurrentText = this.getEditor().getItem().toString().trim();
if (strCurrentText.length() == 0) {
if (this.getItemCount() > 0) {
this.setSelectedIndex(0);
}
} else {
this.addItem(strCurrentText);
this.setSelectedItem(strCurrentText);
}
this.setEditable(false);
}
if (arg0.getKeyCode() == KeyEvent.VK_ESCAPE) {
closeEdit();
}
}
if (arg0.getSource() == this) {
//
//Remove item from the list when press DEL
//
if (arg0.getKeyCode() == KeyEvent.VK_DELETE) {
int intSelected = this.getSelectedIndex();
if (intSelected > -1) {
this.removeItemAt(this.getSelectedIndex());
if (this.getItemCount() > 0) {
this.setSelectedIndex(0);
} else {
this.removeAllItems();
}
}
}
}
}
public void keyTyped(KeyEvent arg0) {
// TODO Auto-generated method stub
}
/* (non-Javadoc)
* @see java.awt.event.MouseListener#mouseClicked(java.awt.event.MouseEvent)
*
* Override mouseClicked to enter edit mode when double click mouse
*
*/
public void mouseClicked(MouseEvent arg0) {
if (arg0.getClickCount() == 2) {
this.setEditable(true);
this.getEditor().setItem("");
}
}
public void mouseEntered(MouseEvent arg0) {
// TODO Auto-generated method stub
}
public void mouseExited(MouseEvent arg0) {
// TODO Auto-generated method stub
}
public void mousePressed(MouseEvent arg0) {
// TODO Auto-generated method stub
}
public void mouseReleased(MouseEvent arg0) {
// TODO Auto-generated method stub
}
/**
Exit edit mode
**/
private void closeEdit() {
this.setEditable(false);
this.getEditor().setItem("");
if (this.getItemCount() > 0) {
this.setSelectedIndex(0);
}
}
}

View File

@ -0,0 +1,307 @@
/** @file
The file is used to override DefaultMutableTreeNode to provides customized interfaces
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.packaging.common.ui;
import javax.swing.tree.DefaultMutableTreeNode;
/**
The class is used to override DefaultMutableTreeNode to provides customized interfaces
It extends DefaultMutableTreeNode
@since ModuleEditor 1.0
**/
public class IDefaultMutableTreeNode extends DefaultMutableTreeNode {
///
/// Define class Serial Version UID
///
private static final long serialVersionUID = -1947340717458069548L;
//
//Static final definitions for all kinds of node
//
public static final int MSA_HEADER = 0;
public static final int LIBRARYCLASSDEFINITIONS = 1;
public static final int SOURCEFILES = 2;
public static final int INCLUDES = 3;
public static final int PROTOCOLS = 4;
public static final int EVENTS = 5;
public static final int HOBS = 6;
public static final int PPIS = 7;
public static final int VARIABLES = 8;
public static final int BOOTMODES = 9;
public static final int SYSTEMTABLES = 10;
public static final int DATAHUBS = 11;
public static final int FORMSETS = 12;
public static final int GUIDS = 13;
public static final int EXTERNS = 14;
public static final int PCDS = 15;
public static final int MBD_HEADER = 20;
public static final int MLSA_HEADER = 21;
public static final int MLBD_HEADER = 22;
public static final int LIBRARIES = 23;
public static final int LIBRARY_CLASS_DEFINITION = 101;
public static final int SOURCEFILES_FILENAME = 210;
public static final int SOURCEFILES_FILENAME_ITEM = 211;
public static final int SOURCEFILES_ARCH = 220;
public static final int SOURCEFILES_ARCH_ITEM = 221;
public static final int INCLUDES_PACKAGENAME = 310;
public static final int INCLUDES_PACKAGENAME_ITEM = 311;
public static final int INCLUDES_ARCH = 320;
public static final int INCLUDES_ARCH_ITEM = 321;
public static final int PROTOCOLS_PROTOCOL = 410;
public static final int PROTOCOLS_PROTOCOL_ITEM = 411;
public static final int PROTOCOLS_PROTOCOLNOTIFY = 420;
public static final int PROTOCOLS_PROTOCOLNOTIFY_ITEM = 421;
public static final int EVENTS_CREATEEVENTS = 510;
public static final int EVENTS_CREATEEVENTS_ITEM = 511;
public static final int EVENTS_SIGNALEVENTS = 520;
public static final int EVENTS_SIGNALEVENTS_ITEM = 521;
public static final int HOBS_HOB_ITEM = 611;
public static final int PPIS_PPI = 710;
public static final int PPIS_PPI_ITEM = 711;
public static final int PPIS_PPINOTIFY = 720;
public static final int PPIS_PPINOTIFY_ITEM = 721;
public static final int VARIABLES_VARIABLE_ITEM = 811;
public static final int BOOTMODES_BOOTMODE_ITEM = 911;
public static final int SYSTEMTABLES_SYSTEMTABLE_ITEM = 1011;
public static final int DATAHUBS_DATAHUB_ITEM = 1111;
public static final int FORMSETS_FORMSET_ITEM = 1211;
public static final int GUIDS_GUIDENTRY_ITEM = 1311;
public static final int EXTERNS_EXTERN_ITEM = 1411;
public static final int PCDS_PCDDATA_ITEM = 1511;
public static final int LIBRARIES_LIBRARY = 2310;
public static final int LIBRARIES_LIBRARY_ITEM = 2311;
public static final int LIBRARIES_ARCH = 2320;
public static final int LIBRARIES_ARCH_ITEM = 2321;
//
//Static final definitions for operation
//
public static final int OPERATION_NULL = 0;
public static final int OPERATION_ADD = 1;
public static final int OPERATION_UPDATE = 2;
public static final int OPERATION_DELETE = 4;
public static final int OPERATION_ADD_UPDATE = 3;
public static final int OPERATION_ADD_DELETE = 5;
public static final int OPERATION_UPDATE_DELETE = 6;
public static final int OPERATION_ADD_UPDATE_DELETE = 7;
//
//Define 4 node attributes
//
private int category = 0;
private int operation = 0;
private int location = 0;
private String nodeName = "";
/**
Main class, reserved for test
@param args
**/
public static void main(String[] args) {
// TODO Auto-generated method stub
}
/**
This is the default constructor
**/
public IDefaultMutableTreeNode() {
super();
}
/**
This is the overrided constructor
Init clase members with input data
@param strNodeName The name of node
@param intCategory The category of node
@param intOperation The operation of node
**/
public IDefaultMutableTreeNode(String strNodeName, int intCategory, int intOperation) {
super(strNodeName);
this.nodeName = strNodeName;
this.category = intCategory;
this.operation = intOperation;
}
/**
This is the overrided constructor
Init clase members with input data
@param strNodeName The name of node
@param intCategory The category of node
@param intOperation The operation of node
@param intLocation The location of node
**/
public IDefaultMutableTreeNode(String strNodeName, int intCategory, int intOperation, int intLocation) {
super(strNodeName);
this.nodeName = strNodeName;
this.category = intCategory;
this.operation = intOperation;
this.location = intLocation;
}
/**
Get category of node
@return The category of node
**/
public int getCategory() {
return category;
}
/**
Set category of node
@param category The input data of node category
**/
public void setCategory(int category) {
this.category = category;
}
/**
Get name of node
@return The name of node
**/
public String getNodeName() {
return nodeName;
}
/**
Set name of node
@param nodeName The input data of node name
**/
public void setNodeName(String nodeName) {
this.nodeName = nodeName;
}
/**
Get operation of node
@return The operation of node
**/
public int getOperation() {
return operation;
}
/**
Set operation of node
@param operation The input data of node operation
**/
public void setOperation(int operation) {
this.operation = operation;
}
/**
Get location of node
@return The location of node
**/
public int getLocation() {
return location;
}
/**
Set location of node
@param location The input data of node location
**/
public void setLocation(int location) {
this.location = location;
}
}

View File

@ -0,0 +1,76 @@
/** @file
The file is used to override DefaultDesktopManager to provides customized interfaces
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.packaging.common.ui;
import javax.swing.DefaultDesktopManager;
import javax.swing.JComponent;
/**
The class is used to override DefaultDesktopManager to provides customized interfaces
It extends DefaultDesktopManager
@since ModuleEditor 1.0
**/
public class IDesktopManager extends DefaultDesktopManager {
///
/// Define class Serial Version UID
///
private static final long serialVersionUID = -4596986878722011062L;
/**
Main class, reserved for test
@param args
**/
public static void main(String[] args) {
// TODO Auto-generated method stub
}
/* (non-Javadoc)
* @see javax.swing.DesktopManager#dragFrame(javax.swing.JComponent, int, int)
*
* Override dragFrame to do nothing to forbid internalframe to be draged
*
*/
public void dragFrame(JComponent f, int newX, int newY) {
}
/* (non-Javadoc)
* @see javax.swing.DesktopManager#endDraggingFrame(javax.swing.JComponent)
*
* Override endDraggingFrame to do nothing to forbid internalframe to be draged
*
*/
public void endDraggingFrame(JComponent f) {
}
/* (non-Javadoc)
* @see javax.swing.DesktopManager#beginResizingFrame(javax.swing.JComponent, int)
*
* Override beginResizingFrame to do nothing to forbid internalframe to be draged
*
*/
public void beginResizingFrame(JComponent f, int direction) {
}
}

View File

@ -0,0 +1,144 @@
/** @file
The file is used to override Dialog to provides customized interfaces
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.packaging.common.ui;
import java.awt.Dimension;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JDialog;
/**
The class is used to override Dialog to provides customized interfaces
It extends JDialog implements ActionListener
@since ModuleEditor 1.0
**/
public class IDialog extends JDialog implements ActionListener {
///
/// Define class Serial Version UID
///
private static final long serialVersionUID = -7692623863358631984L;
//
//Define class members
//
private boolean isEdited = false;
public void actionPerformed(ActionEvent arg0) {
// TODO Auto-generated method stub
}
/**
Main class, used for test
@param args
**/
public static void main(String[] args) {
IDialog id = new IDialog();
id.setVisible(true);
}
/**
This is the default constructor
**/
public IDialog() {
super();
initialize();
}
/**
* This is the override constructor
*/
/**
This is the override constructor
@param parentFrame The parent frame which open the dialog
@param modal true means the dialog is modal dialog; false means the dialog is not modal dialog
**/
public IDialog(IFrame parentFrame, boolean modal) {
super(parentFrame, modal);
initialize();
}
/**
This method initializes this
**/
private void initialize() {
this.setResizable(false);
}
/**
Start the dialog at the center of screen
@param intWidth The width of the dialog
@param intHeight The height of the dialog
**/
protected void centerWindow(int intWidth, int intHeight) {
Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
this.setLocation((d.width - intWidth) / 2, (d.height - intHeight) / 2);
}
/**
Start the dialog at the center of screen
**/
protected void centerWindow() {
centerWindow(this.getSize().width, this.getSize().height);
}
/**
Get if the dialog has been edited
@retval true - The dialog has been edited
@retval false - The dialog hasn't been edited
**/
public boolean isEdited() {
return isEdited;
}
/**
Set if the dialog has been edited
@param isEdited The input data which identify if the dialog has been edited
**/
public void setEdited(boolean isEdited) {
this.isEdited = isEdited;
}
/**
Check the input data is empty or not
@param strValue The input data which need be checked
@retval true - The input data is empty
@retval fals - The input data is not empty
**/
public boolean isEmpty(String strValue) {
if (strValue.length() > 0) {
return false;
}
return true;
}
}

View File

@ -0,0 +1,204 @@
/** @file
The file is used to override Frame to provides customized interfaces
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.packaging.common.ui;
import java.awt.Dimension;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import javax.swing.JFrame;
/**
The class is used to override Frame to provides customized interfaces
It extends JFrame implements ActionListener and WindowListener
@since ModuleEditor 1.0
**/
public class IFrame extends JFrame implements ActionListener, WindowListener {
///
/// Define class Serial Version UID
///
private static final long serialVersionUID = -3324138961029300427L;
//
//Define class members
//
private ExitConfirm ec = null;
//
// To indicate the status while quit
// 0 - When setup (Default)
// 1 - Whne editing module
//
private int intExitType = 0;
/**
Main class, used for test
@param args
**/
public static void main(String[] args) {
IFrame i = new IFrame();
i.setVisible(true);
}
/**
This is the default constructor
**/
public IFrame() {
super();
initialize();
}
/**
This method initializes this
**/
public void initialize() {
this.setResizable(false);
this.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
this.addWindowListener(this);
}
/**
Start the dialog at the center of screen
@param intWidth The width of the dialog
@param intHeight The height of the dialog
**/
protected void centerWindow(int intWidth, int intHeight) {
Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
this.setLocation((d.width - intWidth) / 2, (d.height - intHeight) / 2);
}
/**
Start the dialog at the center of screen
**/
protected void centerWindow() {
centerWindow(this.getSize().width, this.getSize().height);
}
/**
Set the exit window type
@param ExitType The input data of ExitType
**/
protected void setExitType(int ExitType) {
this.intExitType = ExitType;
}
/* (non-Javadoc)
* @see java.awt.event.WindowListener#windowClosing(java.awt.event.WindowEvent)
*
* Override windowClosing to call this.onDisvisible()
*
*/
public void windowClosing(WindowEvent arg0) {
this.onDisvisible();
}
public void windowOpened(WindowEvent arg0) {
// TODO Auto-generated method stub
}
public void windowClosed(WindowEvent arg0) {
// TODO Auto-generated method stub
}
public void windowIconified(WindowEvent arg0) {
// TODO Auto-generated method stub
}
public void windowDeiconified(WindowEvent arg0) {
// TODO Auto-generated method stub
}
public void windowActivated(WindowEvent arg0) {
// TODO Auto-generated method stub
}
public void windowDeactivated(WindowEvent arg0) {
// TODO Auto-generated method stub
}
public void actionPerformed(ActionEvent arg0) {
// TODO Auto-generated method stub
}
/**
Define the actions when exit
**/
public void onExit() {
ec = new ExitConfirm(this, true);
//
//Show different warning message via different ExitType
//
switch (intExitType) {
case 0:
ec.setSetupMessage();
break;
case 1:
ec.setModuleMessage();
break;
}
ec.setVisible(true);
if (ec.isCancel) {
this.dispose();
System.exit(0);
}
}
/**
Define the actions when disvisible
**/
public void onDisvisible() {
ec = new ExitConfirm(this, true);
//
//Show different warning message via different ExitType
//
switch (intExitType) {
case 0:
ec.setSetupMessage();
break;
case 1:
ec.setModuleMessage();
break;
}
ec.setVisible(true);
if (ec.isCancel) {
this.dispose();
}
}
}

View File

@ -0,0 +1,109 @@
/** @file
The file is used to override JInternalFrame to provides customized interfaces
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.packaging.common.ui;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JInternalFrame;
/**
The class is used to override JInternalFrame to provides customized interfaces
It extends JInternalFrame implements ActionListener
@since ModuleEditor 1.0
**/
public class IInternalFrame extends JInternalFrame implements ActionListener {
///
/// Define class Serial Version UID
///
private static final long serialVersionUID = -609841772384875886L;
//
//Define class members
//
private boolean isEdited = false;
/**
Main class, reserved for test
@param args
**/
public static void main(String[] args) {
// TODO Auto-generated method stub
}
/**
This is the default constructor
**/
public IInternalFrame() {
super();
initialize();
}
/**
This method initializes this
**/
private void initialize() {
this.setBounds(new java.awt.Rectangle(0, 0, 500, 500));
}
/**
Get if the InternalFrame has been edited
@retval true - The InternalFrame has been edited
@retval false - The InternalFrame hasn't been edited
**/
public boolean isEdited() {
return isEdited;
}
/**
Set if the InternalFrame has been edited
@param isEdited The input data which identify if the InternalFrame has been edited
**/
public void setEdited(boolean isEdited) {
this.isEdited = isEdited;
}
/**
Check the input data is empty or not
@param strValue The input data which need be checked
@retval true - The input data is empty
@retval fals - The input data is not empty
**/
public boolean isEmpty(String strValue) {
if (strValue.length() > 0) {
return false;
}
return true;
}
public void actionPerformed(ActionEvent arg0) {
// TODO Auto-generated method stub
}
}

View File

@ -0,0 +1,204 @@
/** @file
The file is used to override JTree to provides customized interfaces
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.packaging.common.ui;
import javax.swing.JTree;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.DefaultTreeModel;
import javax.swing.tree.TreeNode;
import javax.swing.tree.TreePath;
/**
The class is used to override JTree to provides customized interfaces
It extends JTree
@since ModuleEditor 1.0
**/
public class ITree extends JTree {
///
/// Define class Serial Version UID
///
private static final long serialVersionUID = -7907086164518295327L;
//
// Define class members
//
DefaultTreeModel treeModel = null;
/**
This is the default constructor
**/
public ITree() {
super();
}
/**
This is the overrided constructor
Init class members with input data
@param iDmtRoot The root node of the tree
**/
public ITree(IDefaultMutableTreeNode iDmtRoot) {
super(iDmtRoot);
}
/**
Get category of selected node
@return The category of selected node
**/
public int getSelectCategory() {
int intCategory = 0;
TreePath path = this.getSelectionPath();
IDefaultMutableTreeNode node = (IDefaultMutableTreeNode) path.getLastPathComponent();
intCategory = node.getCategory();
return intCategory;
}
/**
Get operation of selected node
@return The operation of selected node
**/
public int getSelectOperation() {
int intOperation = 0;
TreePath path = this.getSelectionPath();
IDefaultMutableTreeNode node = (IDefaultMutableTreeNode) path.getLastPathComponent();
intOperation = node.getOperation();
return intOperation;
}
/**
Get selectLoaction of selected node
@return The selectLoaction of selected node
**/
public int getSelectLoaction() {
int intLocation = 0;
TreePath path = this.getSelectionPath();
IDefaultMutableTreeNode node = (IDefaultMutableTreeNode) path.getLastPathComponent();
intLocation = node.getLocation();
return intLocation;
}
/**
Main class, reserved for test
@param args
**/
public static void main(String[] args) {
// TODO Auto-generated method stub
}
/**
Add input node as child node for current selected node
@param strNewNode The name of the node which need be added
**/
public void addNode(String strNewNode) {
DefaultMutableTreeNode parentNode = null;
DefaultMutableTreeNode newNode = new DefaultMutableTreeNode(strNewNode);
newNode.setAllowsChildren(true);
TreePath parentPath = this.getSelectionPath();
/**
* Get parent node of new node
*/
parentNode = (DefaultMutableTreeNode) (parentPath.getLastPathComponent());
/**
* Insert new node
*/
treeModel.insertNodeInto(newNode, parentNode, parentNode.getChildCount());
this.scrollPathToVisible(new TreePath(newNode.getPath()));
}
/**
Add input node as child node for current selected node
@param newNode The node need be added
**/
public void addNode(IDefaultMutableTreeNode newNode) {
IDefaultMutableTreeNode parentNode = null;
newNode.setAllowsChildren(true);
TreePath parentPath = this.getSelectionPath();
parentNode = (IDefaultMutableTreeNode) (parentPath.getLastPathComponent());
treeModel.insertNodeInto(newNode, parentNode, parentNode.getChildCount());
this.scrollPathToVisible(new TreePath(newNode.getPath()));
}
/**
Remove current selectd node
**/
public void removeNode() {
TreePath treepath = this.getSelectionPath();
if (treepath != null) {
DefaultMutableTreeNode selectionNode = (DefaultMutableTreeNode) treepath.getLastPathComponent();
TreeNode parent = (TreeNode) selectionNode.getParent();
if (parent != null) {
treeModel.removeNodeFromParent(selectionNode);
}
}
}
/**
Remove all node on a same level
**/
public void removeNodeOnSameLevel() {
TreePath treepath = this.getSelectionPath();
IDefaultMutableTreeNode parentNode = (IDefaultMutableTreeNode) treepath.getLastPathComponent();
parentNode.removeAllChildren();
treeModel.reload();
}
/**
Remove the input node by name
@param strRemovedNode
**/
public void removeNode(String strRemovedNode) {
TreePath treepath = this.getSelectionPath();
if (treepath != null) {
DefaultMutableTreeNode selectionNode = (DefaultMutableTreeNode) treepath.getLastPathComponent();
TreeNode parent = (TreeNode) selectionNode.getParent();
if (parent != null) {
treeModel.removeNodeFromParent(selectionNode);
}
}
}
/**
Remove all nodes of the tree
**/
public void removeAllNode() {
DefaultMutableTreeNode rootNode = (DefaultMutableTreeNode) treeModel.getRoot();
rootNode.removeAllChildren();
treeModel.reload();
}
}

View File

@ -0,0 +1,64 @@
/** @file
The file is used to override JLabel to provides customized interfaces
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.packaging.common.ui;
import javax.swing.JLabel;
/**
The class is used to override JLabel to provides customized interfaces
@since ModuleEditor 1.0
**/
public class StarLabel extends JLabel {
///
/// Define class Serial Version UID
///
private static final long serialVersionUID = -6702981027831543919L;
/**
Main class, reserved for test
@param args
**/
public static void main(String[] args) {
// TODO Auto-generated method stub
}
/**
This is the default constructor
**/
public StarLabel() {
super();
init();
}
/**
To create a RED, BOLD and 14 size "*"
**/
private void init() {
this.setText("*");
this.setSize(new java.awt.Dimension(10, 20));
this.setForeground(java.awt.Color.red);
this.setFont(new java.awt.Font("DialogInput", java.awt.Font.BOLD, 14));
this.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
}
}

View File

@ -0,0 +1,602 @@
/** @file
This file is used to create, update MbdHeader of a MBD file
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.packaging.module.ui;
import java.awt.event.ActionEvent;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import org.tianocore.BaseNameDocument;
import org.tianocore.GuidDocument;
import org.tianocore.LicenseDocument;
import org.tianocore.MbdHeaderDocument;
import org.tianocore.common.DataValidation;
import org.tianocore.common.Log;
import org.tianocore.common.Tools;
import org.tianocore.packaging.common.ui.IInternalFrame;
import org.tianocore.packaging.common.ui.StarLabel;
/**
This class is used to create, update MbdHeader of a MBD file
It extends IInternalFrame
@since ModuleEditor 1.0
**/
public class MbdHeader extends IInternalFrame {
///
/// Define class Serial Version UID
///
private static final long serialVersionUID = -2015726615436197378L;
//
// Define class members
//
private JPanel jContentPane = null;
private JLabel jLabelBaseName = null;
private JTextField jTextFieldBaseName = null;
private JLabel jLabelGuid = null;
private JTextField jTextFieldGuid = null;
private JLabel jLabelVersion = null;
private JTextField jTextFieldVersion = null;
private JButton jButtonGenerateGuid = null;
private JLabel jLabelLicense = null;
private JTextArea jTextAreaLicense = null;
private JLabel jLabelCopyright = null;
private JTextArea jTextAreaCopyright = null;
private JLabel jLabelDescription = null;
private JTextArea jTextAreaDescription = null;
private JButton jButtonOk = null;
private JButton jButtonCancel = null;
private JScrollPane jScrollPaneLicense = null;
private JScrollPane jScrollPaneCopyright = null;
private JScrollPane jScrollPaneDescription = null;
private StarLabel jStarLabel1 = null;
private StarLabel jStarLabel2 = null;
private StarLabel jStarLabel3 = null;
private StarLabel jStarLabel4 = null;
private StarLabel jStarLabel5 = null;
private StarLabel jStarLabel6 = null;
private MbdHeaderDocument.MbdHeader mbdHeader = null;
/**
This method initializes jTextFieldBaseName
@return javax.swing.JTextField jTextFieldBaseName
**/
private JTextField getJTextFieldBaseName() {
if (jTextFieldBaseName == null) {
jTextFieldBaseName = new JTextField();
jTextFieldBaseName.setBounds(new java.awt.Rectangle(160, 10, 320, 20));
}
return jTextFieldBaseName;
}
/**
This method initializes jTextFieldGuid
@return javax.swing.JTextField jTextFieldGuid
**/
private JTextField getJTextFieldGuid() {
if (jTextFieldGuid == null) {
jTextFieldGuid = new JTextField();
jTextFieldGuid.setBounds(new java.awt.Rectangle(160, 35, 240, 20));
}
return jTextFieldGuid;
}
/**
This method initializes jTextFieldVersion
@return javax.swing.JTextField jTextFieldVersion
**/
private JTextField getJTextFieldVersion() {
if (jTextFieldVersion == null) {
jTextFieldVersion = new JTextField();
jTextFieldVersion.setBounds(new java.awt.Rectangle(160, 60, 320, 20));
}
return jTextFieldVersion;
}
/**
This method initializes jButtonGenerateGuid
@return javax.swing.JButton jButtonGenerateGuid
**/
private JButton getJButtonGenerateGuid() {
if (jButtonGenerateGuid == null) {
jButtonGenerateGuid = new JButton();
jButtonGenerateGuid.setBounds(new java.awt.Rectangle(405, 35, 75, 20));
jButtonGenerateGuid.setText("GEN");
jButtonGenerateGuid.addActionListener(this);
}
return jButtonGenerateGuid;
}
/**
This method initializes jTextAreaLicense
@return javax.swing.JTextArea jTextAreaLicense
**/
private JTextArea getJTextAreaLicense() {
if (jTextAreaLicense == null) {
jTextAreaLicense = new JTextArea();
jTextAreaLicense.setText("");
jTextAreaLicense.setLineWrap(true);
}
return jTextAreaLicense;
}
/**
This method initializes jTextAreaCopyright
@return javax.swing.JTextArea jTextAreaCopyright
**/
private JTextArea getJTextAreaCopyright() {
if (jTextAreaCopyright == null) {
jTextAreaCopyright = new JTextArea();
jTextAreaCopyright.setLineWrap(true);
}
return jTextAreaCopyright;
}
/**
This method initializes jTextAreaDescription
@return javax.swing.JTextArea jTextAreaDescription
**/
private JTextArea getJTextAreaDescription() {
if (jTextAreaDescription == null) {
jTextAreaDescription = new JTextArea();
jTextAreaDescription.setLineWrap(true);
}
return jTextAreaDescription;
}
/**
This method initializes jButtonOk
@return javax.swing.JButton jButtonOk
**/
private JButton getJButtonOk() {
if (jButtonOk == null) {
jButtonOk = new JButton();
jButtonOk.setText("OK");
jButtonOk.setBounds(new java.awt.Rectangle(290, 345, 90, 20));
jButtonOk.addActionListener(this);
}
return jButtonOk;
}
/**
This method initializes jButtonCancel
@return javax.swing.JButton jButtonCancel
**/
private JButton getJButtonCancel() {
if (jButtonCancel == null) {
jButtonCancel = new JButton();
jButtonCancel.setText("Cancel");
jButtonCancel.setBounds(new java.awt.Rectangle(390, 345, 90, 20));
jButtonCancel.addActionListener(this);
}
return jButtonCancel;
}
/**
This method initializes jScrollPaneLicense
@return javax.swing.JScrollPane jScrollPaneLicense
**/
private JScrollPane getJScrollPaneLicense() {
if (jScrollPaneLicense == null) {
jScrollPaneLicense = new JScrollPane();
jScrollPaneLicense.setBounds(new java.awt.Rectangle(160, 85, 320, 80));
jScrollPaneLicense.setHorizontalScrollBarPolicy(javax.swing.JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
jScrollPaneLicense.setViewportView(getJTextAreaLicense());
}
return jScrollPaneLicense;
}
/**
This method initializes jScrollPaneCopyright
@return javax.swing.JScrollPane jScrollPaneCopyright
**/
private JScrollPane getJScrollPaneCopyright() {
if (jScrollPaneCopyright == null) {
jScrollPaneCopyright = new JScrollPane();
jScrollPaneCopyright.setBounds(new java.awt.Rectangle(160, 170, 320, 80));
jScrollPaneCopyright.setHorizontalScrollBarPolicy(javax.swing.JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
jScrollPaneCopyright.setViewportView(getJTextAreaCopyright());
}
return jScrollPaneCopyright;
}
/**
This method initializes jScrollPaneDescription
@return javax.swing.JScrollPane jScrollPaneDescription
**/
private JScrollPane getJScrollPaneDescription() {
if (jScrollPaneDescription == null) {
jScrollPaneDescription = new JScrollPane();
jScrollPaneDescription.setBounds(new java.awt.Rectangle(160, 255, 320, 80));
jScrollPaneDescription.setHorizontalScrollBarPolicy(javax.swing.JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
jScrollPaneDescription.setViewportView(getJTextAreaDescription());
}
return jScrollPaneDescription;
}
public static void main(String[] args) {
}
/**
This is the default constructor
**/
public MbdHeader() {
super();
init();
this.setVisible(true);
}
/**
This is the override edit constructor
**/
public MbdHeader(MbdHeaderDocument.MbdHeader inMbdHeader) {
super();
init(inMbdHeader);
this.setVisible(true);
this.setViewMode(false);
}
/**
This method initializes this
**/
private void init() {
this.setSize(500, 515);
this.setContentPane(getJContentPane());
this.setTitle("Module Build Description Header");
initFrame();
}
/**
This method initializes this
Fill values to all fields if these values are not empty
@param inMbdHeader The input MbdHeaderDocument.MbdHeader
**/
private void init(MbdHeaderDocument.MbdHeader inMbdHeader) {
init();
setMbdHeader(inMbdHeader);
if (inMbdHeader != null) {
if (this.mbdHeader.getBaseName() != null) {
this.jTextFieldBaseName.setText(this.mbdHeader.getBaseName().getStringValue());
}
if (this.mbdHeader.getGuid() != null) {
this.jTextFieldGuid.setText(this.mbdHeader.getGuid().getStringValue());
}
if (this.mbdHeader.getVersion() != null) {
this.jTextFieldVersion.setText(this.mbdHeader.getVersion());
}
if (this.mbdHeader.getLicense() != null) {
this.jTextAreaLicense.setText(this.mbdHeader.getLicense().getStringValue());
}
if (this.mbdHeader.getCopyright() != null) {
this.jTextAreaCopyright.setText(this.mbdHeader.getCopyright());
}
if (this.mbdHeader.getDescription() != null) {
this.jTextAreaDescription.setText(this.mbdHeader.getDescription());
}
}
}
/**
Disable all components when the mode is view
@param isView true - The view mode; false - The non-view mode
**/
public void setViewMode(boolean isView) {
this.jButtonOk.setVisible(false);
this.jButtonCancel.setVisible(false);
if (isView) {
this.jTextFieldBaseName.setEnabled(!isView);
this.jTextFieldGuid.setEnabled(!isView);
this.jTextFieldVersion.setEnabled(!isView);
this.jTextAreaLicense.setEnabled(!isView);
this.jTextAreaCopyright.setEnabled(!isView);
this.jTextAreaDescription.setEnabled(!isView);
this.jButtonCancel.setEnabled(!isView);
this.jButtonGenerateGuid.setEnabled(!isView);
this.jButtonOk.setEnabled(!isView);
}
}
/**
This method initializes jContentPane
@return javax.swing.JPanel jContentPane
**/
private JPanel getJContentPane() {
if (jContentPane == null) {
jLabelDescription = new JLabel();
jLabelDescription.setText("Description");
jLabelDescription.setBounds(new java.awt.Rectangle(15, 255, 140, 20));
jLabelCopyright = new JLabel();
jLabelCopyright.setText("Copyright");
jLabelCopyright.setBounds(new java.awt.Rectangle(15, 170, 140, 20));
jLabelLicense = new JLabel();
jLabelLicense.setText("License");
jLabelLicense.setBounds(new java.awt.Rectangle(15, 85, 140, 20));
jLabelVersion = new JLabel();
jLabelVersion.setText("Version");
jLabelVersion.setBounds(new java.awt.Rectangle(15, 60, 140, 20));
jLabelGuid = new JLabel();
jLabelGuid.setPreferredSize(new java.awt.Dimension(25, 15));
jLabelGuid.setBounds(new java.awt.Rectangle(15, 35, 140, 20));
jLabelGuid.setText("Guid");
jLabelBaseName = new JLabel();
jLabelBaseName.setText("Base Name");
jLabelBaseName.setBounds(new java.awt.Rectangle(15, 10, 140, 20));
jContentPane = new JPanel();
jContentPane.setLayout(null);
jContentPane.setLocation(new java.awt.Point(0, 0));
jContentPane.setSize(new java.awt.Dimension(500, 524));
jContentPane.add(jLabelBaseName, null);
jContentPane.add(getJTextFieldBaseName(), null);
jContentPane.add(jLabelGuid, null);
jContentPane.add(getJTextFieldGuid(), null);
jContentPane.add(jLabelVersion, null);
jContentPane.add(getJTextFieldVersion(), null);
jContentPane.add(getJButtonGenerateGuid(), null);
jContentPane.add(jLabelLicense, null);
jContentPane.add(jLabelCopyright, null);
jContentPane.add(jLabelDescription, null);
jContentPane.add(getJButtonOk(), null);
jContentPane.add(getJButtonCancel(), null);
jContentPane.add(getJScrollPaneLicense(), null);
jContentPane.add(getJScrollPaneCopyright(), null);
jContentPane.add(getJScrollPaneDescription(), null);
jStarLabel1 = new StarLabel();
jStarLabel1.setLocation(new java.awt.Point(0, 10));
jStarLabel2 = new StarLabel();
jStarLabel2.setLocation(new java.awt.Point(0, 35));
jStarLabel3 = new StarLabel();
jStarLabel3.setLocation(new java.awt.Point(0, 60));
jStarLabel4 = new StarLabel();
jStarLabel4.setLocation(new java.awt.Point(0, 85));
jStarLabel5 = new StarLabel();
jStarLabel5.setLocation(new java.awt.Point(0, 170));
jStarLabel6 = new StarLabel();
jStarLabel6.setLocation(new java.awt.Point(0, 255));
jContentPane.add(jStarLabel1, null);
jContentPane.add(jStarLabel2, null);
jContentPane.add(jStarLabel3, null);
jContentPane.add(jStarLabel4, null);
jContentPane.add(jStarLabel5, null);
jContentPane.add(jStarLabel6, null);
}
return jContentPane;
}
/* (non-Javadoc)
* @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
*
* Override actionPerformed to listen all actions
*
*/
public void actionPerformed(ActionEvent arg0) {
if (arg0.getSource() == jButtonOk) {
this.dispose();
this.save();
this.setEdited(true);
}
if (arg0.getSource() == jButtonCancel) {
this.dispose();
this.setEdited(false);
}
//
// Generate GUID
//
if (arg0.getSource() == jButtonGenerateGuid) {
jTextFieldGuid.setText(Tools.generateUuidString());
}
}
/**
Data validation for all fields
@retval true - All datas are valid
@retval false - At least one data is invalid
**/
public boolean check() {
//
// Check if all required fields are not empty
//
if (isEmpty(this.jTextFieldBaseName.getText())) {
Log.err("Base Name couldn't be empty");
return false;
}
if (isEmpty(this.jTextFieldGuid.getText())) {
Log.err("Guid couldn't be empty");
return false;
}
if (isEmpty(this.jTextFieldVersion.getText())) {
Log.err("Version couldn't be empty");
return false;
}
if (isEmpty(this.jTextAreaLicense.getText())) {
Log.err("License couldn't be empty");
return false;
}
if (isEmpty(this.jTextAreaCopyright.getText())) {
Log.err("Copyright couldn't be empty");
return false;
}
if (isEmpty(this.jTextAreaDescription.getText())) {
Log.err("Description couldn't be empty");
return false;
}
//
// Check if all fields have correct data types
//
if (!DataValidation.isBaseName(this.jTextFieldBaseName.getText())) {
Log.err("Incorrect data type for Base Name");
return false;
}
if (!DataValidation.isGuid((this.jTextFieldGuid).getText())) {
Log.err("Incorrect data type for Guid");
return false;
}
if (!DataValidation.isCopyright(this.jTextAreaCopyright.getText())) {
Log.err("Incorrect data type for Copyright");
return false;
}
return true;
}
/**
Save all components of Mbd Header
if exists mbdHeader, set the value directly
if not exists mbdHeader, new an instance first
**/
public void save() {
try {
if (this.mbdHeader == null) {
mbdHeader = MbdHeaderDocument.MbdHeader.Factory.newInstance();
}
if (this.mbdHeader.getBaseName() != null) {
this.mbdHeader.getBaseName().setStringValue(this.jTextFieldBaseName.getText());
} else {
BaseNameDocument.BaseName mBaseName = BaseNameDocument.BaseName.Factory.newInstance();
mBaseName.setStringValue(this.jTextFieldBaseName.getText());
this.mbdHeader.setBaseName(mBaseName);
}
if (this.mbdHeader.getGuid() != null) {
this.mbdHeader.getGuid().setStringValue(this.jTextFieldGuid.getText());
} else {
GuidDocument.Guid mGuid = GuidDocument.Guid.Factory.newInstance();
mGuid.setStringValue(this.jTextFieldGuid.getText());
this.mbdHeader.setGuid(mGuid);
}
this.mbdHeader.setVersion(this.jTextFieldVersion.getText());
if (this.mbdHeader.getLicense() != null) {
this.mbdHeader.getLicense().setStringValue(this.jTextAreaLicense.getText());
} else {
LicenseDocument.License mLicense = LicenseDocument.License.Factory.newInstance();
mLicense.setStringValue(this.jTextAreaLicense.getText());
this.mbdHeader.setLicense(mLicense);
}
this.mbdHeader.setCopyright(this.jTextAreaCopyright.getText());
this.mbdHeader.setDescription(this.jTextAreaDescription.getText());
if (this.mbdHeader.getCreated() == null) {
this.mbdHeader.setCreated(Tools.getCurrentDateTime());
} else {
this.mbdHeader.setModified(Tools.getCurrentDateTime());
}
} catch (Exception e) {
Log.err("Save Module Buid Description", e.getMessage());
}
}
/**
This method initializes module type and compontent type
**/
private void initFrame() {
}
/**
Get MbdHeaderDocument.MbdHeader
@return MbdHeaderDocument.MbdHeader mbdHeader
**/
public MbdHeaderDocument.MbdHeader getMbdHeader() {
return mbdHeader;
}
/**
Set MbdHeaderDocument.MbdHeader
@param mbdHeader The input MbdHeaderDocument.MbdHeader
**/
public void setMbdHeader(MbdHeaderDocument.MbdHeader mbdHeader) {
this.mbdHeader = mbdHeader;
}
}

View File

@ -0,0 +1,599 @@
/** @file
The file is used to create, update MbdLibHeader of a MBD file
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.packaging.module.ui;
import java.awt.event.ActionEvent;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import org.tianocore.BaseNameDocument;
import org.tianocore.GuidDocument;
import org.tianocore.LicenseDocument;
import org.tianocore.MbdLibHeaderDocument;
import org.tianocore.common.DataValidation;
import org.tianocore.common.Log;
import org.tianocore.common.Tools;
import org.tianocore.packaging.common.ui.IInternalFrame;
import org.tianocore.packaging.common.ui.StarLabel;
/**
The class is used to create, update MbdLibHeader of a MBD file
It extends IInternalFrame
@since ModuleEditor 1.0
**/
public class MbdLibHeader extends IInternalFrame {
///
/// Define class Serial Version UID
///
private static final long serialVersionUID = -4881447351274201866L;
//
//Define class members
//
private JPanel jContentPane = null;
private JLabel jLabelBaseName = null;
private JTextField jTextFieldBaseName = null;
private JLabel jLabelGuid = null;
private JTextField jTextFieldGuid = null;
private JLabel jLabelVersion = null;
private JTextField jTextFieldVersion = null;
private JButton jButtonGenerateGuid = null;
private JLabel jLabelLicense = null;
private JTextArea jTextAreaLicense = null;
private JLabel jLabelCopyright = null;
private JTextArea jTextAreaCopyright = null;
private JLabel jLabelDescription = null;
private JTextArea jTextAreaDescription = null;
private JButton jButtonOk = null;
private JButton jButtonCancel = null;
private JScrollPane jScrollPaneLicense = null;
private JScrollPane jScrollPaneCopyright = null;
private JScrollPane jScrollPaneDescription = null;
private StarLabel jStarLabel1 = null;
private StarLabel jStarLabel2 = null;
private StarLabel jStarLabel3 = null;
private StarLabel jStarLabel4 = null;
private StarLabel jStarLabel5 = null;
private StarLabel jStarLabel6 = null;
private MbdLibHeaderDocument.MbdLibHeader mbdLibHeader = null;
/**
This method initializes jTextFieldBaseName
@return javax.swing.JTextField jTextFieldBaseName
**/
private JTextField getJTextFieldBaseName() {
if (jTextFieldBaseName == null) {
jTextFieldBaseName = new JTextField();
jTextFieldBaseName.setBounds(new java.awt.Rectangle(160, 10, 320, 20));
}
return jTextFieldBaseName;
}
/**
This method initializes jTextFieldGuid
@return javax.swing.JTextField jTextFieldGuid
**/
private JTextField getJTextFieldGuid() {
if (jTextFieldGuid == null) {
jTextFieldGuid = new JTextField();
jTextFieldGuid.setBounds(new java.awt.Rectangle(160, 35, 240, 20));
}
return jTextFieldGuid;
}
/**
This method initializes jTextFieldVersion
@return javax.swing.JTextField jTextFieldVersion
**/
private JTextField getJTextFieldVersion() {
if (jTextFieldVersion == null) {
jTextFieldVersion = new JTextField();
jTextFieldVersion.setBounds(new java.awt.Rectangle(160, 60, 320, 20));
}
return jTextFieldVersion;
}
/**
This method initializes jButtonGenerateGuid
@return javax.swing.JButton jButtonGenerateGuid
**/
private JButton getJButtonGenerateGuid() {
if (jButtonGenerateGuid == null) {
jButtonGenerateGuid = new JButton();
jButtonGenerateGuid.setBounds(new java.awt.Rectangle(405, 35, 75, 20));
jButtonGenerateGuid.setText("GEN");
jButtonGenerateGuid.addActionListener(this);
}
return jButtonGenerateGuid;
}
/**
This method initializes jTextAreaLicense
@return javax.swing.JTextArea jTextAreaLicense
**/
private JTextArea getJTextAreaLicense() {
if (jTextAreaLicense == null) {
jTextAreaLicense = new JTextArea();
jTextAreaLicense.setText("");
jTextAreaLicense.setLineWrap(true);
}
return jTextAreaLicense;
}
/**
This method initializes jTextAreaCopyright
@return javax.swing.JTextArea jTextAreaCopyright
**/
private JTextArea getJTextAreaCopyright() {
if (jTextAreaCopyright == null) {
jTextAreaCopyright = new JTextArea();
jTextAreaCopyright.setLineWrap(true);
}
return jTextAreaCopyright;
}
/**
This method initializes jTextAreaDescription
@return javax.swing.JTextArea jTextAreaDescription
**/
private JTextArea getJTextAreaDescription() {
if (jTextAreaDescription == null) {
jTextAreaDescription = new JTextArea();
jTextAreaDescription.setLineWrap(true);
}
return jTextAreaDescription;
}
/**
This method initializes jButtonOk
@return javax.swing.JButton jButtonOk
**/
private JButton getJButtonOk() {
if (jButtonOk == null) {
jButtonOk = new JButton();
jButtonOk.setText("OK");
jButtonOk.setBounds(new java.awt.Rectangle(290, 345, 90, 20));
jButtonOk.addActionListener(this);
}
return jButtonOk;
}
/**
This method initializes jButtonCancel
@return javax.swing.JButton jButtonCancel
**/
private JButton getJButtonCancel() {
if (jButtonCancel == null) {
jButtonCancel = new JButton();
jButtonCancel.setText("Cancel");
jButtonCancel.setBounds(new java.awt.Rectangle(390, 345, 90, 20));
jButtonCancel.addActionListener(this);
}
return jButtonCancel;
}
/**
This method initializes jScrollPaneLicense
@return javax.swing.JScrollPane jScrollPaneLicense
**/
private JScrollPane getJScrollPaneLicense() {
if (jScrollPaneLicense == null) {
jScrollPaneLicense = new JScrollPane();
jScrollPaneLicense.setBounds(new java.awt.Rectangle(160, 85, 320, 80));
jScrollPaneLicense.setHorizontalScrollBarPolicy(javax.swing.JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
jScrollPaneLicense.setViewportView(getJTextAreaLicense());
}
return jScrollPaneLicense;
}
/**
This method initializes jScrollPaneCopyright
@return javax.swing.JScrollPane jScrollPaneCopyright
**/
private JScrollPane getJScrollPaneCopyright() {
if (jScrollPaneCopyright == null) {
jScrollPaneCopyright = new JScrollPane();
jScrollPaneCopyright.setBounds(new java.awt.Rectangle(160, 170, 320, 80));
jScrollPaneCopyright.setHorizontalScrollBarPolicy(javax.swing.JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
jScrollPaneCopyright.setViewportView(getJTextAreaCopyright());
}
return jScrollPaneCopyright;
}
/**
This method initializes jScrollPaneDescription
@return javax.swing.JScrollPane jScrollPaneDescription
**/
private JScrollPane getJScrollPaneDescription() {
if (jScrollPaneDescription == null) {
jScrollPaneDescription = new JScrollPane();
jScrollPaneDescription.setBounds(new java.awt.Rectangle(160, 255, 320, 80));
jScrollPaneDescription.setHorizontalScrollBarPolicy(javax.swing.JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
jScrollPaneDescription.setViewportView(getJTextAreaDescription());
}
return jScrollPaneDescription;
}
public static void main(String[] args) {
}
/**
This is the default constructor
**/
public MbdLibHeader() {
super();
init();
this.setVisible(true);
}
/**
This is the override edit constructor
@param inMbdLibHeader The input MbdLibHeaderDocument.MbdLibHeader
**/
public MbdLibHeader(MbdLibHeaderDocument.MbdLibHeader inMbdLibHeader) {
super();
init(inMbdLibHeader);
this.setVisible(true);
this.setViewMode(false);
}
/**
This method initializes this
**/
private void init() {
this.setSize(500, 515);
this.setContentPane(getJContentPane());
this.setTitle("Library Module Build Description Header");
initFrame();
}
/**
This method initializes this
Fill values to all fields if these values are not empty
@param inMbdLibHeader The input MbdLibHeaderDocument.MbdLibHeader
**/
private void init(MbdLibHeaderDocument.MbdLibHeader inMbdLibHeader) {
init();
setMbdLibHeader(inMbdLibHeader);
if (inMbdLibHeader != null) {
if (this.mbdLibHeader.getBaseName() != null) {
this.jTextFieldBaseName.setText(this.mbdLibHeader.getBaseName().getStringValue());
}
if (this.mbdLibHeader.getGuid() != null) {
this.jTextFieldGuid.setText(this.mbdLibHeader.getGuid().getStringValue());
}
if (this.mbdLibHeader.getVersion() != null) {
this.jTextFieldVersion.setText(this.mbdLibHeader.getVersion());
}
if (this.mbdLibHeader.getLicense() != null) {
this.jTextAreaLicense.setText(this.mbdLibHeader.getLicense().getStringValue());
}
if (this.mbdLibHeader.getCopyright() != null) {
this.jTextAreaCopyright.setText(this.mbdLibHeader.getCopyright());
}
if (this.mbdLibHeader.getDescription() != null) {
this.jTextAreaDescription.setText(this.mbdLibHeader.getDescription());
}
}
}
/**
Disable all components when the mode is view
@param isView true - The view mode; false - The non-view mode
**/
public void setViewMode(boolean isView) {
this.jButtonOk.setVisible(false);
this.jButtonCancel.setVisible(false);
if (isView) {
this.jTextFieldBaseName.setEnabled(!isView);
this.jTextFieldGuid.setEnabled(!isView);
this.jTextFieldVersion.setEnabled(!isView);
this.jTextAreaLicense.setEnabled(!isView);
this.jTextAreaCopyright.setEnabled(!isView);
this.jTextAreaDescription.setEnabled(!isView);
this.jButtonCancel.setEnabled(!isView);
this.jButtonGenerateGuid.setEnabled(!isView);
this.jButtonOk.setEnabled(!isView);
}
}
/**
This method initializes jContentPane
@return javax.swing.JPanel jContentPane
**/
private JPanel getJContentPane() {
if (jContentPane == null) {
jLabelDescription = new JLabel();
jLabelDescription.setText("Description");
jLabelDescription.setBounds(new java.awt.Rectangle(15, 255, 140, 20));
jLabelCopyright = new JLabel();
jLabelCopyright.setText("Copyright");
jLabelCopyright.setBounds(new java.awt.Rectangle(15, 170, 140, 20));
jLabelLicense = new JLabel();
jLabelLicense.setText("License");
jLabelLicense.setBounds(new java.awt.Rectangle(15, 85, 140, 20));
jLabelVersion = new JLabel();
jLabelVersion.setText("Version");
jLabelVersion.setBounds(new java.awt.Rectangle(15, 60, 140, 20));
jLabelGuid = new JLabel();
jLabelGuid.setPreferredSize(new java.awt.Dimension(25, 15));
jLabelGuid.setBounds(new java.awt.Rectangle(15, 35, 140, 20));
jLabelGuid.setText("Guid");
jLabelBaseName = new JLabel();
jLabelBaseName.setText("Base Name");
jLabelBaseName.setBounds(new java.awt.Rectangle(15, 10, 140, 20));
jContentPane = new JPanel();
jContentPane.setLayout(null);
jContentPane.setLocation(new java.awt.Point(0, 0));
jContentPane.setSize(new java.awt.Dimension(500, 524));
jContentPane.add(jLabelBaseName, null);
jContentPane.add(getJTextFieldBaseName(), null);
jContentPane.add(jLabelGuid, null);
jContentPane.add(getJTextFieldGuid(), null);
jContentPane.add(jLabelVersion, null);
jContentPane.add(getJTextFieldVersion(), null);
jContentPane.add(getJButtonGenerateGuid(), null);
jContentPane.add(jLabelLicense, null);
jContentPane.add(jLabelCopyright, null);
jContentPane.add(jLabelDescription, null);
jContentPane.add(getJButtonOk(), null);
jContentPane.add(getJButtonCancel(), null);
jContentPane.add(getJScrollPaneLicense(), null);
jContentPane.add(getJScrollPaneCopyright(), null);
jContentPane.add(getJScrollPaneDescription(), null);
jStarLabel1 = new StarLabel();
jStarLabel1.setLocation(new java.awt.Point(0, 10));
jStarLabel2 = new StarLabel();
jStarLabel2.setLocation(new java.awt.Point(0, 35));
jStarLabel3 = new StarLabel();
jStarLabel3.setLocation(new java.awt.Point(0, 60));
jStarLabel4 = new StarLabel();
jStarLabel4.setLocation(new java.awt.Point(0, 85));
jStarLabel5 = new StarLabel();
jStarLabel5.setLocation(new java.awt.Point(0, 170));
jStarLabel6 = new StarLabel();
jStarLabel6.setLocation(new java.awt.Point(0, 255));
jContentPane.add(jStarLabel1, null);
jContentPane.add(jStarLabel2, null);
jContentPane.add(jStarLabel3, null);
jContentPane.add(jStarLabel4, null);
jContentPane.add(jStarLabel5, null);
jContentPane.add(jStarLabel6, null);
}
return jContentPane;
}
/* (non-Javadoc)
* @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
*
* Override actionPerformed to listen all actions
*
*/
public void actionPerformed(ActionEvent arg0) {
if (arg0.getSource() == jButtonOk) {
this.dispose();
this.save();
this.setEdited(true);
}
if (arg0.getSource() == jButtonCancel) {
this.dispose();
this.setEdited(false);
}
if (arg0.getSource() == jButtonGenerateGuid) {
jTextFieldGuid.setText(Tools.generateUuidString());
}
}
/**
Data validation for all fields
@retval true - All datas are valid
@retval false - At least one data is invalid
**/
public boolean check() {
//
// Check if all required fields are not empty
//
if (isEmpty(this.jTextFieldBaseName.getText())) {
Log.err("Base Name couldn't be empty");
return false;
}
if (isEmpty(this.jTextFieldGuid.getText())) {
Log.err("Guid couldn't be empty");
return false;
}
if (isEmpty(this.jTextFieldVersion.getText())) {
Log.err("Version couldn't be empty");
return false;
}
if (isEmpty(this.jTextAreaLicense.getText())) {
Log.err("License couldn't be empty");
return false;
}
if (isEmpty(this.jTextAreaCopyright.getText())) {
Log.err("Copyright couldn't be empty");
return false;
}
if (isEmpty(this.jTextAreaDescription.getText())) {
Log.err("Description couldn't be empty");
return false;
}
//
// Check if all fields have correct data types
//
if (!DataValidation.isBaseName(this.jTextFieldBaseName.getText())) {
Log.err("Incorrect data type for Base Name");
return false;
}
if (!DataValidation.isGuid((this.jTextFieldGuid).getText())) {
Log.err("Incorrect data type for Guid");
return false;
}
if (!DataValidation.isCopyright(this.jTextAreaCopyright.getText())) {
Log.err("Incorrect data type for Copyright");
return false;
}
return true;
}
/**
Save all components of Mbd Lib Header
if exists mbdLibHeader, set the value directly
if not exists mbdLibHeader, new an instance first
**/
public void save() {
try {
if (this.mbdLibHeader == null) {
mbdLibHeader = MbdLibHeaderDocument.MbdLibHeader.Factory.newInstance();
}
if (this.mbdLibHeader.getBaseName() != null) {
this.mbdLibHeader.getBaseName().setStringValue(this.jTextFieldBaseName.getText());
} else {
BaseNameDocument.BaseName mBaseName = BaseNameDocument.BaseName.Factory.newInstance();
mBaseName.setStringValue(this.jTextFieldBaseName.getText());
this.mbdLibHeader.setBaseName(mBaseName);
}
if (this.mbdLibHeader.getGuid() != null) {
this.mbdLibHeader.getGuid().setStringValue(this.jTextFieldGuid.getText());
} else {
GuidDocument.Guid mGuid = GuidDocument.Guid.Factory.newInstance();
mGuid.setStringValue(this.jTextFieldGuid.getText());
this.mbdLibHeader.setGuid(mGuid);
}
this.mbdLibHeader.setVersion(this.jTextFieldVersion.getText());
if (this.mbdLibHeader.getLicense() != null) {
this.mbdLibHeader.getLicense().setStringValue(this.jTextAreaLicense.getText());
} else {
LicenseDocument.License mLicense = LicenseDocument.License.Factory.newInstance();
mLicense.setStringValue(this.jTextAreaLicense.getText());
this.mbdLibHeader.setLicense(mLicense);
}
this.mbdLibHeader.setCopyright(this.jTextAreaCopyright.getText());
this.mbdLibHeader.setDescription(this.jTextAreaDescription.getText());
if (this.mbdLibHeader.getCreated() == null) {
this.mbdLibHeader.setCreated(Tools.getCurrentDateTime());
} else {
this.mbdLibHeader.setModified(Tools.getCurrentDateTime());
}
} catch (Exception e) {
Log.err("Save Module Buid Description", e.getMessage());
}
}
/**
This method initializes module type and compontent type
**/
private void initFrame() {
}
/**
Get MbdLibHeaderDocument.MbdLibHeader
@return MbdLibHeaderDocument.MbdLibHeader
**/
public MbdLibHeaderDocument.MbdLibHeader getMbdLibHeader() {
return mbdLibHeader;
}
/**
Set MbdLibHeaderDocument.MbdLibHeader
@param mbdLibHeader The input MbdLibHeaderDocument.MbdLibHeader
**/
public void setMbdLibHeader(MbdLibHeaderDocument.MbdLibHeader mbdLibHeader) {
this.mbdLibHeader = mbdLibHeader;
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,146 @@
/** @file
To show a about window with copyright information
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.packaging.module.ui;
import java.awt.event.ActionEvent;
import java.awt.event.WindowEvent;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import org.tianocore.packaging.common.ui.IDialog;
/**
The class is used to show a about window with copyright information
It extends IDialog
@since ModuleEditor 1.0
**/
public class ModuleAbout extends IDialog {
///
/// Define class Serial Version UID
///
private static final long serialVersionUID = 2958136136667310962L;
//
//Define class members
//
private JPanel jContentPane = null;
private JLabel jLabel = null;
private JLabel jLabel1 = null;
private JLabel jLabel2 = null;
private JButton jButtonOK = null;
/**
This method initializes jButtonOK
@return javax.swing.JButton jButtonOK
**/
private JButton getJButtonOK() {
if (jButtonOK == null) {
jButtonOK = new JButton();
jButtonOK.setBounds(new java.awt.Rectangle(105, 120, 90, 20));
jButtonOK.setText("OK");
jButtonOK.addActionListener(this);
}
return jButtonOK;
}
public static void main(String[] args) {
}
/**
This is the default constructor
**/
public ModuleAbout() {
super();
init();
}
/**
This method initializes this
**/
private void init() {
this.setSize(300, 200);
this.setContentPane(getJContentPane());
this.setTitle("About...");
this.getRootPane().setDefaultButton(jButtonOK);
this.centerWindow();
this.setVisible(true);
}
/**
This method initializes jContentPane
@return javax.swing.JPanel jContentPane
**/
private JPanel getJContentPane() {
if (jContentPane == null) {
jLabel2 = new JLabel();
jLabel2.setBounds(new java.awt.Rectangle(15, 80, 270, 20));
jLabel2.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
jLabel2.setText("All rights reserved");
jLabel1 = new JLabel();
jLabel1.setBounds(new java.awt.Rectangle(15, 50, 270, 20));
jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
jLabel1.setText("Copyright (c) 2006, Intel Corporation");
jLabel = new JLabel();
jLabel.setToolTipText("");
jLabel.setBounds(new java.awt.Rectangle(15, 20, 270, 20));
jLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
jLabel.setText("Framework Development Package System 1.0");
jContentPane = new JPanel();
jContentPane.setLayout(null);
jContentPane.add(jLabel, null);
jContentPane.add(jLabel1, null);
jContentPane.add(jLabel2, null);
jContentPane.add(getJButtonOK(), null);
}
return jContentPane;
}
/* (non-Javadoc)
* @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
*
* Override actionPerformed to listen all actions
*/
public void actionPerformed(ActionEvent arg0) {
if (arg0.getSource() == jButtonOK) {
this.dispose();
}
}
/**
Dispose when windows is closing
@param arg0
**/
public void windowClosing(WindowEvent arg0) {
this.dispose();
}
}

View File

@ -0,0 +1,456 @@
/** @file
The file is used to create, update BootModes of MSA/MBD file
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.packaging.module.ui;
import java.awt.event.ActionEvent;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import org.tianocore.BootModeNames;
import org.tianocore.BootModeUsage;
import org.tianocore.BootModesDocument;
import org.tianocore.common.DataValidation;
import org.tianocore.common.Log;
import org.tianocore.common.Tools;
import org.tianocore.packaging.common.ui.IInternalFrame;
import org.tianocore.packaging.common.ui.StarLabel;
/**
The class is used to create, update BootModes of MSA/MBD file
It extends IInternalFrame
@since ModuleEditor 1.0
**/
public class ModuleBootModes extends IInternalFrame {
///
/// Define class Serial Version UID
///
private static final long serialVersionUID = -3888558623432442561L;
//
//Define class members
//
private BootModesDocument.BootModes bootModes = null;
private int location = -1;
private JPanel jContentPane = null;
private JLabel jLabelGuid = null;
private JTextField jTextFieldGuid = null;
private JLabel jLabelBootModeName = null;
private JComboBox jComboBoxBootModeName = null;
private JLabel jLabelUsage = null;
private JComboBox jComboBoxUsage = null;
private JButton jButtonOk = null;
private JButton jButtonCancel = null;
private JLabel jLabelOverrideID = null;
private JTextField jTextFieldOverrideID = null;
private JButton jButtonGenerateGuid = null;
private StarLabel jStarLabel1 = null;
/**
This method initializes jTextFieldGuid
@return javax.swing.JTextField jTextFieldGuid
**/
private JTextField getJTextFieldGuid() {
if (jTextFieldGuid == null) {
jTextFieldGuid = new JTextField();
jTextFieldGuid.setBounds(new java.awt.Rectangle(160, 35, 240, 20));
}
return jTextFieldGuid;
}
/**
This method initializes jComboBoxBootModeName
@return javax.swing.JComboBox jComboBoxBootModeName
**/
private JComboBox getJComboBoxBootModeName() {
if (jComboBoxBootModeName == null) {
jComboBoxBootModeName = new JComboBox();
jComboBoxBootModeName.setBounds(new java.awt.Rectangle(160, 10, 320, 20));
}
return jComboBoxBootModeName;
}
/**
This method initializes jComboBoxUsage
@return javax.swing.JComboBox jComboBoxUsage
**/
private JComboBox getJComboBoxUsage() {
if (jComboBoxUsage == null) {
jComboBoxUsage = new JComboBox();
jComboBoxUsage.setBounds(new java.awt.Rectangle(160, 60, 320, 20));
}
return jComboBoxUsage;
}
/**
This method initializes jButtonOk
@return javax.swing.JButton jButtonOk
**/
private JButton getJButtonOk() {
if (jButtonOk == null) {
jButtonOk = new JButton();
jButtonOk.setText("OK");
jButtonOk.setBounds(new java.awt.Rectangle(280, 115, 90, 20));
jButtonOk.addActionListener(this);
}
return jButtonOk;
}
/**
This method initializes jButtonCancel
@return javax.swing.JButton jButtonCancel
**/
private JButton getJButtonCancel() {
if (jButtonCancel == null) {
jButtonCancel = new JButton();
jButtonCancel.setText("Cancel");
jButtonCancel.setBounds(new java.awt.Rectangle(390, 115, 90, 20));
jButtonCancel.addActionListener(this);
}
return jButtonCancel;
}
/**
This method initializes jTextFieldOverrideID
@return javax.swing.JTextField jTextFieldOverrideID
**/
private JTextField getJTextFieldOverrideID() {
if (jTextFieldOverrideID == null) {
jTextFieldOverrideID = new JTextField();
jTextFieldOverrideID.setBounds(new java.awt.Rectangle(160, 85, 320, 20));
}
return jTextFieldOverrideID;
}
/**
This method initializes jButtonGenerateGuid
@return javax.swing.JButton jButtonGenerateGuid
**/
private JButton getJButtonGenerateGuid() {
if (jButtonGenerateGuid == null) {
jButtonGenerateGuid = new JButton();
jButtonGenerateGuid.setBounds(new java.awt.Rectangle(405, 35, 75, 20));
jButtonGenerateGuid.setText("GEN");
jButtonGenerateGuid.addActionListener(this);
}
return jButtonGenerateGuid;
}
public static void main(String[] args) {
}
/**
This is the default constructor
**/
public ModuleBootModes() {
super();
init();
this.setVisible(true);
}
/**
This is the override edit constructor
@param inBootModes The input BootModesDocument.BootModes
**/
public ModuleBootModes(BootModesDocument.BootModes inBootModes) {
super();
init(inBootModes);
this.setVisible(true);
}
/**
This is the override edit constructor
@param inBootModes The input BootModesDocument.BootModes
@param type The input data of node type
@param index The input data of node index
**/
public ModuleBootModes(BootModesDocument.BootModes inBootModes, int type, int index) {
super();
init(inBootModes, type, index);
this.setVisible(true);
}
/**
This method initializes this
@param inBootModes BootModesDocument.BootModes
**/
private void init(BootModesDocument.BootModes inBootModes) {
init();
this.setBootModes(inBootModes);
}
/**
This method initializes this
Fill values to all fields if these values are not empty
@param inBootModes The input BootModesDocument.BootModes
@param type The input data of node type
@param index The input data of node index
**/
private void init(BootModesDocument.BootModes inBootModes, int type, int index) {
init(inBootModes);
this.location = index;
if (this.bootModes.getBootModeList().size() > 0) {
if (this.bootModes.getBootModeArray(index).getBootModeName() != null) {
this.jComboBoxBootModeName.setSelectedItem(this.bootModes.getBootModeArray(index).getBootModeName()
.toString());
}
if (this.bootModes.getBootModeArray(index).getGuid() != null) {
this.jTextFieldGuid.setText(this.bootModes.getBootModeArray(index).getGuid());
}
if (this.bootModes.getBootModeArray(index).getUsage() != null) {
this.jComboBoxUsage.setSelectedItem(this.bootModes.getBootModeArray(index).getUsage().toString());
}
this.jTextFieldOverrideID.setText(String.valueOf(this.bootModes.getBootModeArray(index).getOverrideID()));
}
}
/**
* This method initializes this
*
* @return void
*/
private void init() {
this.setContentPane(getJContentPane());
this.setTitle("Boot Mode");
this.setBounds(new java.awt.Rectangle(0, 0, 500, 515));
initFrame();
this.setViewMode(false);
}
/**
Disable all components when the mode is view
@param isView true - The view mode; false - The non-view mode
**/
public void setViewMode(boolean isView) {
this.jButtonOk.setVisible(false);
this.jButtonCancel.setVisible(false);
if (isView) {
this.jComboBoxBootModeName.setEnabled(!isView);
this.jTextFieldGuid.setEnabled(!isView);
this.jComboBoxUsage.setEnabled(!isView);
this.jTextFieldOverrideID.setEnabled(!isView);
this.jButtonCancel.setEnabled(!isView);
this.jButtonGenerateGuid.setEnabled(!isView);
this.jButtonOk.setEnabled(!isView);
}
}
/**
This method initializes jContentPane
@return javax.swing.JPanel jContentPane
**/
private JPanel getJContentPane() {
if (jContentPane == null) {
jLabelOverrideID = new JLabel();
jLabelOverrideID.setBounds(new java.awt.Rectangle(15, 85, 140, 20));
jLabelOverrideID.setText("Override ID");
jLabelUsage = new JLabel();
jLabelUsage.setText("Usage");
jLabelUsage.setBounds(new java.awt.Rectangle(15, 60, 140, 20));
jLabelBootModeName = new JLabel();
jLabelBootModeName.setText("Boot Mode Name");
jLabelBootModeName.setBounds(new java.awt.Rectangle(15, 10, 140, 20));
jLabelGuid = new JLabel();
jLabelGuid.setText("Guid");
jLabelGuid.setBounds(new java.awt.Rectangle(15, 35, 140, 20));
jContentPane = new JPanel();
jContentPane.setLayout(null);
jContentPane.add(jLabelGuid, null);
jContentPane.add(getJTextFieldGuid(), null);
jContentPane.add(jLabelBootModeName, null);
jContentPane.add(getJComboBoxBootModeName(), null);
jContentPane.add(jLabelUsage, null);
jContentPane.add(getJComboBoxUsage(), null);
jContentPane.add(getJButtonOk(), null);
jContentPane.add(getJButtonCancel(), null);
jContentPane.add(jLabelOverrideID, null);
jContentPane.add(getJTextFieldOverrideID(), null);
jContentPane.add(getJButtonGenerateGuid(), null);
jStarLabel1 = new StarLabel();
jStarLabel1.setLocation(new java.awt.Point(0, 10));
jContentPane.add(jStarLabel1, null);
}
return jContentPane;
}
/**
This method initializes BootModeName groups and Usage type
**/
private void initFrame() {
jComboBoxUsage.addItem("ALWAYS_CONSUMED");
jComboBoxUsage.addItem("SOMETIMES_CONSUMED");
jComboBoxUsage.addItem("ALWAYS_PRODUCED");
jComboBoxUsage.addItem("SOMETIMES_PRODUCED");
jComboBoxBootModeName.addItem("FULL");
jComboBoxBootModeName.addItem("MINIMAL");
jComboBoxBootModeName.addItem("NO_CHANGE");
jComboBoxBootModeName.addItem("DIAGNOSTICS");
jComboBoxBootModeName.addItem("DEFAULT");
jComboBoxBootModeName.addItem("S2_RESUME");
jComboBoxBootModeName.addItem("S3_RESUME");
jComboBoxBootModeName.addItem("S4_RESUME");
jComboBoxBootModeName.addItem("S5_RESUME");
jComboBoxBootModeName.addItem("FLASH_UPDATE");
jComboBoxBootModeName.addItem("RECOVERY");
}
/* (non-Javadoc)
* @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
*
* Override actionPerformed to listen all actions
*
*/
public void actionPerformed(ActionEvent arg0) {
if (arg0.getSource() == jButtonOk) {
this.setEdited(true);
this.save();
this.dispose();
}
if (arg0.getSource() == jButtonCancel) {
this.dispose();
}
if (arg0.getSource() == jButtonGenerateGuid) {
jTextFieldGuid.setText(Tools.generateUuidString());
}
}
/**
Get BootModesDocument.BootModes
@return BootModesDocument.BootModes
**/
public BootModesDocument.BootModes getBootModes() {
return bootModes;
}
/**
Set BootModesDocument.BootModes
@param bootModes BootModesDocument.BootModes
**/
public void setBootModes(BootModesDocument.BootModes bootModes) {
this.bootModes = bootModes;
}
/**
Data validation for all fields
@retval true - All datas are valid
@retval false - At least one data is invalid
**/
public boolean check() {
//
// Check if all fields have correct data types
//
if (!isEmpty(this.jTextFieldGuid.getText()) && !DataValidation.isGuid(this.jTextFieldGuid.getText())) {
Log.err("Incorrect data type for Guid");
return false;
}
if (!isEmpty(this.jTextFieldOverrideID.getText())
&& !DataValidation.isOverrideID(this.jTextFieldOverrideID.getText())) {
Log.err("Incorrect data type for Override ID");
return false;
}
return true;
}
/**
Save all components of Mbd Header
if exists bootModes, set the value directly
if not exists bootModes, new an instance first
**/
public void save() {
try {
if (this.bootModes == null) {
bootModes = BootModesDocument.BootModes.Factory.newInstance();
}
BootModesDocument.BootModes.BootMode bootMode = BootModesDocument.BootModes.BootMode.Factory.newInstance();
bootMode.setBootModeName(BootModeNames.Enum.forString(jComboBoxBootModeName.getSelectedItem().toString()));
if (!isEmpty(this.jTextFieldGuid.getText())) {
bootMode.setGuid(this.jTextFieldGuid.getText());
}
bootMode.setUsage(BootModeUsage.Enum.forString(jComboBoxUsage.getSelectedItem().toString()));
if (!isEmpty(this.jTextFieldOverrideID.getText())) {
bootMode.setOverrideID(Integer.parseInt(this.jTextFieldOverrideID.getText()));
}
if (location > -1) {
bootModes.setBootModeArray(location, bootMode);
} else {
bootModes.addNewBootMode();
bootModes.setBootModeArray(bootModes.getBootModeList().size() - 1, bootMode);
}
} catch (Exception e) {
Log.err("Update Boot Modes", e.getMessage());
}
}
}

View File

@ -0,0 +1,457 @@
/** @file
The file is used to create, update DataHub of MSA/MBD file
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.packaging.module.ui;
import java.awt.event.ActionEvent;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import org.tianocore.DataHubUsage;
import org.tianocore.DataHubsDocument;
import org.tianocore.common.DataValidation;
import org.tianocore.common.Log;
import org.tianocore.common.Tools;
import org.tianocore.packaging.common.ui.IInternalFrame;
import org.tianocore.packaging.common.ui.StarLabel;
/**
The class is used to create, update DataHub of MSA/MBD file
It extends IInternalFrame
@since ModuleEditor 1.0
**/
public class ModuleDataHubs extends IInternalFrame {
///
/// Define class Serial Version UID
///
private static final long serialVersionUID = -3667906991966638892L;
//
//Define class members
//
private DataHubsDocument.DataHubs dataHubs = null;
private int location = -1;
private JPanel jContentPane = null;
private JLabel jLabelGuid = null;
private JTextField jTextFieldGuid = null;
private JLabel jLabelUsage = null;
private JComboBox jComboBoxUsage = null;
private JButton jButtonOk = null;
private JButton jButtonCancel = null;
private JLabel jLabelDataHubRecord = null;
private JTextField jTextFieldDataHubRecord = null;
private JButton jButtonGenerateGuid = null;
private JLabel jLabelOverrideID = null;
private JTextField jTextFieldOverrideID = null;
private StarLabel jStarLabel1 = null;
/**
This method initializes jTextFieldGuid
@return javax.swing.JTextField jTextFieldGuid
**/
private JTextField getJTextFieldGuid() {
if (jTextFieldGuid == null) {
jTextFieldGuid = new JTextField();
jTextFieldGuid.setBounds(new java.awt.Rectangle(160, 35, 240, 20));
}
return jTextFieldGuid;
}
/**
This method initializes jComboBoxUsage
@return javax.swing.JComboBox jComboBoxUsage
**/
private JComboBox getJComboBoxUsage() {
if (jComboBoxUsage == null) {
jComboBoxUsage = new JComboBox();
jComboBoxUsage.setBounds(new java.awt.Rectangle(160, 60, 320, 20));
}
return jComboBoxUsage;
}
/**
This method initializes jButtonOk
@return javax.swing.JButton jButtonOk
**/
private JButton getJButtonOk() {
if (jButtonOk == null) {
jButtonOk = new JButton();
jButtonOk.setText("OK");
jButtonOk.setBounds(new java.awt.Rectangle(280, 115, 90, 20));
jButtonOk.addActionListener(this);
}
return jButtonOk;
}
/**
This method initializes jButtonCancel
@return javax.swing.JButton jButtonCancel
**/
private JButton getJButtonCancel() {
if (jButtonCancel == null) {
jButtonCancel = new JButton();
jButtonCancel.setText("Cancel");
jButtonCancel.setBounds(new java.awt.Rectangle(390, 115, 90, 20));
jButtonCancel.addActionListener(this);
}
return jButtonCancel;
}
/**
This method initializes jTextFieldDataHubRecord
@return javax.swing.JTextField jTextFieldDataHubRecord
**/
private JTextField getJTextFieldDataHubRecord() {
if (jTextFieldDataHubRecord == null) {
jTextFieldDataHubRecord = new JTextField();
jTextFieldDataHubRecord.setBounds(new java.awt.Rectangle(160, 10, 320, 20));
}
return jTextFieldDataHubRecord;
}
/**
This method initializes jButtonGenerateGuid
@return javax.swing.JButton jButtonGenerateGuid
**/
private JButton getJButtonGenerateGuid() {
if (jButtonGenerateGuid == null) {
jButtonGenerateGuid = new JButton();
jButtonGenerateGuid.setBounds(new java.awt.Rectangle(405, 35, 75, 20));
jButtonGenerateGuid.setText("GEN");
jButtonGenerateGuid.addActionListener(this);
}
return jButtonGenerateGuid;
}
/**
This method initializes jTextFieldOverrideID
@return javax.swing.JTextField jTextFieldOverrideID
**/
private JTextField getJTextFieldOverrideID() {
if (jTextFieldOverrideID == null) {
jTextFieldOverrideID = new JTextField();
jTextFieldOverrideID.setBounds(new java.awt.Rectangle(160, 85, 320, 20));
}
return jTextFieldOverrideID;
}
public static void main(String[] args) {
}
/**
This is the default constructor
**/
public ModuleDataHubs() {
super();
init();
this.setVisible(true);
}
/**
This is the override edit constructor
@param inDataHubs The input DataHubsDocument.DataHubs
**/
public ModuleDataHubs(DataHubsDocument.DataHubs inDataHubs) {
super();
init(inDataHubs);
this.setVisible(true);
}
/**
This is the override edit constructor
@param inDataHubs DataHubsDocument.DataHubs
@param type The input data of node type
@param index The input data of node index
**/
public ModuleDataHubs(DataHubsDocument.DataHubs inDataHubs, int type, int index) {
super();
init(inDataHubs, type, index);
this.setVisible(true);
}
/**
This method initializes this
@param inDataHubs The input DataHubsDocument.DataHubs
**/
private void init(DataHubsDocument.DataHubs inDataHubs) {
init();
this.setDataHubs(inDataHubs);
}
/**
This method initializes this
Fill values to all fields if these values are not empty
@param inDataHubs The input DataHubsDocument.DataHubs
@param type The input data of node type
@param index The input data of node index
**/
private void init(DataHubsDocument.DataHubs inDataHubs, int type, int index) {
init(inDataHubs);
this.location = index;
if (this.dataHubs.getDataHubRecordList().size() > 0) {
if (this.dataHubs.getDataHubRecordArray(index).getStringValue() != null) {
this.jTextFieldDataHubRecord.setText(this.dataHubs.getDataHubRecordArray(index).getStringValue()
.toString());
}
if (this.dataHubs.getDataHubRecordArray(index).getGuid() != null) {
this.jTextFieldGuid.setText(this.dataHubs.getDataHubRecordArray(index).getGuid());
}
if (this.dataHubs.getDataHubRecordArray(index).getUsage() != null) {
this.jComboBoxUsage.setSelectedItem(this.dataHubs.getDataHubRecordArray(index).getUsage().toString());
}
this.jTextFieldOverrideID
.setText(String
.valueOf(this.dataHubs.getDataHubRecordArray(index).getOverrideID()));
}
}
/**
Disable all components when the mode is view
@param isView true - The view mode; false - The non-view mode
**/
public void setViewMode(boolean isView) {
this.jButtonOk.setVisible(false);
this.jButtonCancel.setVisible(false);
if (isView) {
this.jTextFieldDataHubRecord.setEnabled(!isView);
this.jTextFieldGuid.setEnabled(!isView);
this.jComboBoxUsage.setEnabled(!isView);
this.jTextFieldOverrideID.setEnabled(!isView);
this.jButtonCancel.setEnabled(!isView);
this.jButtonGenerateGuid.setEnabled(!isView);
this.jButtonOk.setEnabled(!isView);
}
}
/**
This method initializes this
**/
private void init() {
this.setSize(500, 515);
this.setContentPane(getJContentPane());
this.setTitle("Data Hubs");
initFrame();
this.setViewMode(false);
}
/**
This method initializes jContentPane
@return javax.swing.JPanel jContentPane
**/
private JPanel getJContentPane() {
if (jContentPane == null) {
jLabelOverrideID = new JLabel();
jLabelOverrideID.setBounds(new java.awt.Rectangle(15, 85, 140, 20));
jLabelOverrideID.setText("Override ID");
jLabelDataHubRecord = new JLabel();
jLabelDataHubRecord.setBounds(new java.awt.Rectangle(15, 10, 140, 20));
jLabelDataHubRecord.setText("Data Hub Record");
jLabelGuid = new JLabel();
jLabelGuid.setText("Guid");
jLabelGuid.setBounds(new java.awt.Rectangle(15, 35, 140, 20));
jLabelUsage = new JLabel();
jLabelUsage.setText("Usage");
jLabelUsage.setBounds(new java.awt.Rectangle(15, 60, 140, 20));
jContentPane = new JPanel();
jContentPane.setLayout(null);
jContentPane.add(jLabelGuid, null);
jContentPane.add(getJTextFieldGuid(), null);
jContentPane.add(jLabelUsage, null);
jContentPane.add(getJComboBoxUsage(), null);
jContentPane.add(getJButtonOk(), null);
jContentPane.add(getJButtonCancel(), null);
jContentPane.add(jLabelDataHubRecord, null);
jContentPane.add(getJTextFieldDataHubRecord(), null);
jContentPane.add(getJButtonGenerateGuid(), null);
jContentPane.add(jLabelOverrideID, null);
jContentPane.add(getJTextFieldOverrideID(), null);
jStarLabel1 = new StarLabel();
jStarLabel1.setLocation(new java.awt.Point(0, 10));
jContentPane.add(jStarLabel1, null);
}
return jContentPane;
}
/**
This method initializes Usage type
**/
private void initFrame() {
jComboBoxUsage.addItem("ALWAYS_CONSUMED");
jComboBoxUsage.addItem("SOMETIMES_CONSUMED");
jComboBoxUsage.addItem("ALWAYS_PRODUCED");
jComboBoxUsage.addItem("SOMETIMES_PRODUCED");
jComboBoxUsage.addItem("PRIVATE");
}
/* (non-Javadoc)
* @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
*
* Override actionPerformed to listen all actions
*
*/
public void actionPerformed(ActionEvent arg0) {
if (arg0.getSource() == jButtonOk) {
this.setEdited(true);
this.save();
this.dispose();
}
if (arg0.getSource() == jButtonCancel) {
this.dispose();
}
if (arg0.getSource() == jButtonGenerateGuid) {
jTextFieldGuid.setText(Tools.generateUuidString());
}
}
/**
Get DataHubsDocument.DataHubs
@return DataHubsDocument.DataHubs
**/
public DataHubsDocument.DataHubs getDataHubs() {
return dataHubs;
}
/**
Set DataHubsDocument.DataHubs
@param dataHubs DataHubsDocument.DataHubs
**/
public void setDataHubs(DataHubsDocument.DataHubs dataHubs) {
this.dataHubs = dataHubs;
}
/**
Data validation for all fields
@retval true - All datas are valid
@retval false - At least one data is invalid
**/
public boolean check() {
//
// Check if all required fields are not empty
//
if (isEmpty(this.jTextFieldDataHubRecord.getText())) {
Log.err("Data Hub Record couldn't be empty");
return false;
}
//
// Check if all fields have correct data types
//
if (!isEmpty(this.jTextFieldGuid.getText()) && !DataValidation.isGuid(this.jTextFieldGuid.getText())) {
Log.err("Incorrect data type for Guid");
return false;
}
if (!isEmpty(this.jTextFieldOverrideID.getText())
&& !DataValidation.isOverrideID(this.jTextFieldOverrideID.getText())) {
Log.err("Incorrect data type for Override ID");
return false;
}
return true;
}
/**
Save all components of DataHubs
if exists dataHubs, set the value directly
if not exists dataHubs, new an instance first
**/
public void save() {
try {
if (this.dataHubs == null) {
dataHubs = DataHubsDocument.DataHubs.Factory.newInstance();
}
DataHubsDocument.DataHubs.DataHubRecord dataHubRecord = DataHubsDocument.DataHubs.DataHubRecord.Factory
.newInstance();
if (!isEmpty(this.jTextFieldDataHubRecord.getText())) {
dataHubRecord.setStringValue(this.jTextFieldDataHubRecord.getText());
}
if (!isEmpty(this.jTextFieldGuid.getText())) {
dataHubRecord.setGuid(this.jTextFieldGuid.getText());
}
dataHubRecord.setUsage(DataHubUsage.Enum.forString(jComboBoxUsage.getSelectedItem().toString()));
if (!isEmpty(this.jTextFieldOverrideID.getText())) {
dataHubRecord.setOverrideID(Integer.parseInt(this.jTextFieldOverrideID.getText()));
}
if (location > -1) {
dataHubs.setDataHubRecordArray(location, dataHubRecord);
} else {
dataHubs.addNewDataHubRecord();
dataHubs.setDataHubRecordArray(dataHubs.getDataHubRecordList().size() - 1, dataHubRecord);
}
} catch (Exception e) {
Log.err("Update Data Hubs", e.getMessage());
}
}
}

View File

@ -0,0 +1,626 @@
/** @file
The file is used to create, update Event of MSA/MBD file
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.packaging.module.ui;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.JTextField;
import org.tianocore.EventTypes;
import org.tianocore.EventUsage;
import org.tianocore.EventsDocument;
import org.tianocore.GuidDocument;
import org.tianocore.common.DataValidation;
import org.tianocore.common.Log;
import org.tianocore.common.Tools;
import org.tianocore.packaging.common.ui.IDefaultMutableTreeNode;
import org.tianocore.packaging.common.ui.IInternalFrame;
import org.tianocore.packaging.common.ui.StarLabel;
/**
The class is used to create, update Event of MSA/MBD file
It extends IInternalFrame
@since ModuleEditor 1.0
**/
public class ModuleEvents extends IInternalFrame {
///
/// Define class Serial Version UID
///
private static final long serialVersionUID = -4396143706422842331L;
//
//Define class members
//
private EventsDocument.Events events = null;
private EventsDocument.Events.CreateEvents createEvent = null;
private EventsDocument.Events.SignalEvents signalEvent = null;
private int location = -1;
private JPanel jContentPane = null;
private JLabel jLabelEventType = null;
private JRadioButton jRadioButtonEventCreate = null;
private JRadioButton jRadioButtonEventSignal = null;
private JLabel jLabelC_Name = null;
private JTextField jTextFieldC_Name = null;
private JLabel jLabelGuid = null;
private JTextField jTextFieldGuid = null;
private JLabel jLabelEventGroup = null;
private JComboBox jComboBoxEventGroup = null;
private JLabel jLabelUsage = null;
private JComboBox jComboBoxUsage = null;
private JButton jButtonOk = null;
private JButton jButtonCancel = null;
private JButton jButtonGenerateGuid = null;
private JLabel jLabelOverrideID = null;
private JTextField jTextFieldOverrideID = null;
private StarLabel jStarLabel1 = null;
private StarLabel jStarLabel2 = null;
/**
This method initializes jRadioButtonEnentType
@return javax.swing.JRadioButton jRadioButtonEventCreate
**/
private JRadioButton getJRadioButtonEventCreate() {
if (jRadioButtonEventCreate == null) {
jRadioButtonEventCreate = new JRadioButton();
jRadioButtonEventCreate.setText("Create");
jRadioButtonEventCreate.setBounds(new java.awt.Rectangle(160, 10, 90, 20));
jRadioButtonEventCreate.addActionListener(this);
jRadioButtonEventCreate.setSelected(true);
}
return jRadioButtonEventCreate;
}
/**
This method initializes jRadioButtonEventSignal
@return javax.swing.JRadioButton jRadioButtonEventSignal
**/
private JRadioButton getJRadioButtonEventSignal() {
if (jRadioButtonEventSignal == null) {
jRadioButtonEventSignal = new JRadioButton();
jRadioButtonEventSignal.setText("Signal");
jRadioButtonEventSignal.setBounds(new java.awt.Rectangle(320, 10, 90, 20));
jRadioButtonEventSignal.addActionListener(this);
}
return jRadioButtonEventSignal;
}
/**
This method initializes jTextFieldC_Name
@return javax.swing.JTextField jTextFieldC_Name
**/
private JTextField getJTextFieldC_Name() {
if (jTextFieldC_Name == null) {
jTextFieldC_Name = new JTextField();
jTextFieldC_Name.setBounds(new java.awt.Rectangle(160, 35, 320, 20));
}
return jTextFieldC_Name;
}
/**
This method initializes jTextFieldGuid
@return javax.swing.JTextField jTextFieldGuid
**/
private JTextField getJTextFieldGuid() {
if (jTextFieldGuid == null) {
jTextFieldGuid = new JTextField();
jTextFieldGuid.setBounds(new java.awt.Rectangle(160, 60, 240, 20));
}
return jTextFieldGuid;
}
/**
This method initializes jComboBoxEventGroup
@return javax.swing.JComboBox jComboBoxEventGroup
**/
private JComboBox getJComboBoxEventGroup() {
if (jComboBoxEventGroup == null) {
jComboBoxEventGroup = new JComboBox();
jComboBoxEventGroup.setBounds(new java.awt.Rectangle(160, 85, 320, 20));
}
return jComboBoxEventGroup;
}
/**
This method initializes jComboBoxUsage
@return javax.swing.JComboBox jComboBoxUsage
**/
private JComboBox getJComboBoxUsage() {
if (jComboBoxUsage == null) {
jComboBoxUsage = new JComboBox();
jComboBoxUsage.setBounds(new java.awt.Rectangle(160, 110, 320, 20));
}
return jComboBoxUsage;
}
/**
This method initializes jButtonOk
@return javax.swing.JButton jButtonOk
**/
private JButton getJButton() {
if (jButtonOk == null) {
jButtonOk = new JButton();
jButtonOk.setText("OK");
jButtonOk.setBounds(new java.awt.Rectangle(290, 165, 90, 20));
jButtonOk.addActionListener(this);
}
return jButtonOk;
}
/**
This method initializes jButtonCancel
@return javax.swing.JButton jButtonCancel
**/
private JButton getJButtonCancel() {
if (jButtonCancel == null) {
jButtonCancel = new JButton();
jButtonCancel.setText("Cancel");
jButtonCancel.setBounds(new java.awt.Rectangle(390, 165, 90, 20));
jButtonCancel.setPreferredSize(new Dimension(90, 20));
jButtonCancel.addActionListener(this);
}
return jButtonCancel;
}
/**
This method initializes jButtonGenerateGuid
@return javax.swing.JButton jButtonGenerateGuid
**/
private JButton getJButtonGenerateGuid() {
if (jButtonGenerateGuid == null) {
jButtonGenerateGuid = new JButton();
jButtonGenerateGuid.setBounds(new java.awt.Rectangle(405, 60, 75, 20));
jButtonGenerateGuid.setText("GEN");
jButtonGenerateGuid.addActionListener(this);
}
return jButtonGenerateGuid;
}
/**
This method initializes jTextFieldOverrideID
@return javax.swing.JTextField jTextFieldOverrideID
**/
private JTextField getJTextFieldOverrideID() {
if (jTextFieldOverrideID == null) {
jTextFieldOverrideID = new JTextField();
jTextFieldOverrideID.setBounds(new java.awt.Rectangle(160, 135, 320, 20));
}
return jTextFieldOverrideID;
}
public static void main(String[] args) {
}
/**
This is the default constructor
**/
public ModuleEvents() {
super();
init();
this.setVisible(true);
}
/**
This is the override edit constructor
@param inEvents The input EventsDocument.Events
**/
public ModuleEvents(EventsDocument.Events inEvents) {
super();
init(inEvents);
this.setVisible(true);
}
/**
This is the override edit constructor
@param inEvents The input EventsDocument.Events
@param type The input data of node type
@param index The input data of node index
**/
public ModuleEvents(EventsDocument.Events inEvents, int type, int index) {
super();
init(inEvents, type, index);
this.setVisible(true);
}
/**
This method initializes this
@param inEvents The input EventsDocument.Events
**/
private void init(EventsDocument.Events inEvents) {
init();
this.setEvents(inEvents);
}
/**
This method initializes this
Fill values to all fields if these values are not empty
@param inEvents EventsDocument.Events
@param type The input data of node type
@param index The input data of node index
**/
private void init(EventsDocument.Events inEvents, int type, int index) {
init(inEvents);
this.location = index;
if (type == IDefaultMutableTreeNode.EVENTS_CREATEEVENTS_ITEM) {
this.jRadioButtonEventCreate.setSelected(true);
this.jRadioButtonEventSignal.setSelected(false);
if (this.events.getCreateEvents().getEventArray(index).getCName() != null) {
this.jTextFieldC_Name.setText(this.events.getCreateEvents().getEventArray(index).getCName());
}
if (this.events.getCreateEvents().getEventArray(index).getGuid() != null) {
this.jTextFieldGuid.setText(this.events.getCreateEvents().getEventArray(index).getGuid()
.getStringValue());
}
if (this.events.getCreateEvents().getEventArray(index).getEventGroup() != null) {
this.jComboBoxEventGroup.setSelectedItem(this.events.getCreateEvents().getEventArray(index)
.getEventGroup().toString());
}
if (this.events.getCreateEvents().getEventArray(index).getUsage() != null) {
this.jComboBoxUsage.setSelectedItem(this.events.getCreateEvents().getEventArray(index).getUsage()
.toString());
}
this.jTextFieldOverrideID.setText(String.valueOf(this.events.getCreateEvents().getEventArray(index)
.getOverrideID()));
} else if (type == IDefaultMutableTreeNode.EVENTS_SIGNALEVENTS_ITEM) {
this.jRadioButtonEventCreate.setSelected(false);
this.jRadioButtonEventSignal.setSelected(true);
this.jComboBoxUsage.setEnabled(false);
if (this.events.getSignalEvents().getEventArray(index).getCName() != null) {
this.jTextFieldC_Name.setText(this.events.getSignalEvents().getEventArray(index).getCName());
}
if (this.events.getSignalEvents().getEventArray(index).getGuid() != null) {
this.jTextFieldGuid.setText(this.events.getSignalEvents().getEventArray(index).getGuid().toString());
}
if (this.events.getSignalEvents().getEventArray(index).getEventGroup() != null) {
this.jComboBoxEventGroup.setSelectedItem(this.events.getSignalEvents().getEventArray(index)
.getEventGroup().toString());
}
if (this.events.getSignalEvents().getEventArray(index).getUsage() != null) {
this.jComboBoxUsage.setSelectedItem(this.events.getSignalEvents().getEventArray(index).getUsage()
.toString());
}
this.jTextFieldOverrideID.setText(String.valueOf(this.events.getSignalEvents().getEventArray(index)
.getOverrideID()));
}
this.jRadioButtonEventCreate.setEnabled(false);
this.jRadioButtonEventSignal.setEnabled(false);
}
/**
This method initializes this
**/
private void init() {
this.setSize(500, 515);
this.setContentPane(getJContentPane());
this.setTitle("Events");
initFrame();
this.setViewMode(false);
}
/**
Disable all components when the mode is view
@param isView true - The view mode; false - The non-view mode
**/
public void setViewMode(boolean isView) {
this.jButtonOk.setVisible(false);
this.jButtonCancel.setVisible(false);
if (isView) {
this.jRadioButtonEventCreate.setEnabled(!isView);
this.jRadioButtonEventSignal.setEnabled(!isView);
this.jTextFieldC_Name.setEnabled(!isView);
this.jTextFieldGuid.setEnabled(!isView);
this.jComboBoxEventGroup.setEnabled(!isView);
this.jComboBoxUsage.setEnabled(!isView);
this.jTextFieldOverrideID.setEnabled(!isView);
this.jButtonCancel.setEnabled(!isView);
this.jButtonGenerateGuid.setEnabled(!isView);
this.jButtonOk.setEnabled(!isView);
}
}
/**
This method initializes jContentPane
@return javax.swing.JPanel jContentPane
**/
private JPanel getJContentPane() {
if (jContentPane == null) {
jLabelOverrideID = new JLabel();
jLabelOverrideID.setBounds(new java.awt.Rectangle(15, 135, 140, 20));
jLabelOverrideID.setText("Override ID");
jLabelUsage = new JLabel();
jLabelUsage.setText("Usage");
jLabelUsage.setBounds(new java.awt.Rectangle(15, 110, 140, 20));
jLabelEventGroup = new JLabel();
jLabelEventGroup.setText("Event Group");
jLabelEventGroup.setBounds(new java.awt.Rectangle(15, 85, 140, 20));
jLabelGuid = new JLabel();
jLabelGuid.setText("Guid");
jLabelGuid.setBounds(new java.awt.Rectangle(15, 60, 140, 20));
jLabelC_Name = new JLabel();
jLabelC_Name.setText("C_Name");
jLabelC_Name.setBounds(new java.awt.Rectangle(15, 35, 140, 20));
jLabelEventType = new JLabel();
jLabelEventType.setText("Event Type");
jLabelEventType.setBounds(new java.awt.Rectangle(15, 10, 140, 20));
jContentPane = new JPanel();
jContentPane.setLayout(null);
jContentPane.add(jLabelEventType, null);
jContentPane.add(getJRadioButtonEventCreate(), null);
jContentPane.add(getJRadioButtonEventSignal(), null);
jContentPane.add(jLabelC_Name, null);
jContentPane.add(getJTextFieldC_Name(), null);
jContentPane.add(jLabelGuid, null);
jContentPane.add(getJTextFieldGuid(), null);
jContentPane.add(jLabelEventGroup, null);
jContentPane.add(getJComboBoxEventGroup(), null);
jContentPane.add(jLabelUsage, null);
jContentPane.add(getJComboBoxUsage(), null);
jContentPane.add(getJButton(), null);
jContentPane.add(getJButtonCancel(), null);
jContentPane.add(getJButtonGenerateGuid(), null);
jContentPane.add(jLabelOverrideID, null);
jContentPane.add(getJTextFieldOverrideID(), null);
jStarLabel1 = new StarLabel();
jStarLabel1.setBounds(new java.awt.Rectangle(0, 10, 10, 20));
jStarLabel2 = new StarLabel();
jStarLabel2.setBounds(new java.awt.Rectangle(0, 35, 10, 20));
jContentPane.add(jStarLabel1, null);
jContentPane.add(jStarLabel2, null);
}
return jContentPane;
}
/**
This method initializes events groups and usage type
**/
private void initFrame() {
jComboBoxEventGroup.addItem("EVENT_GROUP_EXIT_BOOT_SERVICES");
jComboBoxEventGroup.addItem("EVENT_GROUP_VIRTUAL_ADDRESS_CHANGE");
jComboBoxEventGroup.addItem("EVENT_GROUP_MEMORY_MAP_CHANGE");
jComboBoxEventGroup.addItem("EVENT_GROUP_READY_TO_BOOT");
jComboBoxEventGroup.addItem("EVENT_GROUP_LEGACY_BOOT");
jComboBoxUsage.addItem("ALWAYS_CONSUMED");
jComboBoxUsage.addItem("SOMETIMES_CONSUMED");
jComboBoxUsage.addItem("ALWAYS_PRODUCED");
jComboBoxUsage.addItem("SOMETIMES_PRODUCED");
jComboBoxUsage.addItem("PRIVATE");
}
/* (non-Javadoc)
* @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
*
* Override actionPerformed to listen all actions
*
*/
public void actionPerformed(ActionEvent arg0) {
if (arg0.getSource() == jButtonOk) {
this.setEdited(true);
this.save();
this.dispose();
}
if (arg0.getSource() == jButtonCancel) {
this.dispose();
}
if (arg0.getSource() == jRadioButtonEventCreate) {
if (jRadioButtonEventCreate.isSelected()) {
jRadioButtonEventSignal.setSelected(false);
}
if (!jRadioButtonEventSignal.isSelected() && !jRadioButtonEventCreate.isSelected()) {
jRadioButtonEventCreate.setSelected(true);
}
}
if (arg0.getSource() == jRadioButtonEventSignal) {
if (jRadioButtonEventSignal.isSelected()) {
jRadioButtonEventCreate.setSelected(false);
}
if (!jRadioButtonEventSignal.isSelected() && !jRadioButtonEventCreate.isSelected()) {
jRadioButtonEventSignal.setSelected(true);
}
}
if (arg0.getSource() == jButtonGenerateGuid) {
jTextFieldGuid.setText(Tools.generateUuidString());
}
}
public EventsDocument.Events getEvents() {
return events;
}
public void setEvents(EventsDocument.Events events) {
this.events = events;
}
/**
Data validation for all fields
@retval true - All datas are valid
@retval false - At least one data is invalid
**/
public boolean check() {
//
// Check if all required fields are not empty
//
if (isEmpty(this.jTextFieldC_Name.getText())) {
Log.err("C_Name couldn't be empty");
return false;
}
//
// Check if all fields have correct data types
//
if (!DataValidation.isCName(this.jTextFieldC_Name.getText())) {
Log.err("Incorrect data type for C_Name");
return false;
}
if (!isEmpty(this.jTextFieldGuid.getText()) && !DataValidation.isGuid(this.jTextFieldGuid.getText())) {
Log.err("Incorrect data type for Guid");
return false;
}
if (!isEmpty(this.jTextFieldOverrideID.getText())
&& !DataValidation.isOverrideID(this.jTextFieldOverrideID.getText())) {
Log.err("Incorrect data type for Override ID");
return false;
}
return true;
}
/**
Save all components of Events
if exists events, set the value directly
if not exists events, new an instance first
**/
public void save() {
try {
if (this.events == null) {
events = EventsDocument.Events.Factory.newInstance();
createEvent = EventsDocument.Events.CreateEvents.Factory.newInstance();
signalEvent = EventsDocument.Events.SignalEvents.Factory.newInstance();
} else {
if (events.getCreateEvents() != null) {
createEvent = events.getCreateEvents();
} else {
createEvent = EventsDocument.Events.CreateEvents.Factory.newInstance();
}
if (events.getSignalEvents() != null) {
signalEvent = events.getSignalEvents();
} else {
signalEvent = EventsDocument.Events.SignalEvents.Factory.newInstance();
}
}
if (this.jRadioButtonEventCreate.isSelected()) {
EventsDocument.Events.CreateEvents.Event event = EventsDocument.Events.CreateEvents.Event.Factory
.newInstance();
event.setCName(this.jTextFieldC_Name.getText());
if (!isEmpty(this.jTextFieldGuid.getText())) {
GuidDocument.Guid guid = GuidDocument.Guid.Factory.newInstance();
guid.setStringValue(this.jTextFieldGuid.getText());
event.setGuid(guid);
}
event.setEventGroup(EventTypes.Enum.forString(jComboBoxEventGroup.getSelectedItem().toString()));
event.setUsage(EventUsage.Enum.forString(jComboBoxUsage.getSelectedItem().toString()));
if (!isEmpty(this.jTextFieldOverrideID.getText())) {
event.setOverrideID(Integer.parseInt(this.jTextFieldOverrideID.getText()));
}
if (location > -1) {
createEvent.setEventArray(location, event);
} else {
createEvent.addNewEvent();
createEvent.setEventArray(createEvent.getEventList().size() - 1, event);
}
events.setCreateEvents(createEvent);
}
if (this.jRadioButtonEventSignal.isSelected()) {
EventsDocument.Events.SignalEvents.Event event = EventsDocument.Events.SignalEvents.Event.Factory
.newInstance();
event.setCName(this.jTextFieldC_Name.getText());
if (!isEmpty(this.jTextFieldGuid.getText())) {
GuidDocument.Guid guid = GuidDocument.Guid.Factory.newInstance();
guid.setStringValue(this.jTextFieldGuid.getText());
event.setGuid(guid);
}
event.setEventGroup(EventTypes.Enum.forString(jComboBoxEventGroup.getSelectedItem().toString()));
event.setUsage(EventUsage.Enum.forString(jComboBoxUsage.getSelectedItem().toString()));
if (!isEmpty(this.jTextFieldOverrideID.getText())) {
event.setOverrideID(Integer.parseInt(this.jTextFieldOverrideID.getText()));
}
if (location > -1) {
signalEvent.setEventArray(location, event);
} else {
signalEvent.addNewEvent();
signalEvent.setEventArray(signalEvent.getEventList().size() - 1, event);
}
events.setSignalEvents(signalEvent);
}
} catch (Exception e) {
Log.err("Update Events", e.getMessage());
}
}
}

View File

@ -0,0 +1,457 @@
/** @file
The file is used to create, update Formset of MSA/MBD file
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.packaging.module.ui;
import java.awt.event.ActionEvent;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import org.tianocore.FormSetUsage;
import org.tianocore.FormsetsDocument;
import org.tianocore.common.DataValidation;
import org.tianocore.common.Log;
import org.tianocore.common.Tools;
import org.tianocore.packaging.common.ui.IInternalFrame;
import org.tianocore.packaging.common.ui.StarLabel;
/**
The class is used to create, update Formset of MSA/MBD file
It extends IInternalFrame
@since ModuleEditor 1.0
**/
public class ModuleFormsets extends IInternalFrame {
///
/// Define class Serial Version UID
///
private static final long serialVersionUID = -6851574146786158116L;
//
//Define class members
//
private FormsetsDocument.Formsets formsets = null;
private int location = -1;
private JPanel jContentPane = null;
private JLabel jLabelName = null;
private JTextField jTextFieldName = null;
private JLabel jLabelGuid = null;
private JTextField jTextFieldGuid = null;
private JLabel jLabelUsage = null;
private JButton jButtonOk = null;
private JButton jButtonCancel = null;
private JComboBox jComboBoxUsage = null;
private JButton jButtonGenerateGuid = null;
private JLabel jLabelOverrideID = null;
private JTextField jTextFieldOverrideID = null;
private StarLabel jStarLabel1 = null;
/**
This method initializes jTextFieldName
@return javax.swing.JTextField jTextFieldName
**/
private JTextField getJTextFieldName() {
if (jTextFieldName == null) {
jTextFieldName = new JTextField();
jTextFieldName.setBounds(new java.awt.Rectangle(160, 10, 320, 20));
}
return jTextFieldName;
}
/**
This method initializes jTextFieldGuid
@return javax.swing.JTextField jTextFieldGuid
**/
private JTextField getJTextFieldGuid() {
if (jTextFieldGuid == null) {
jTextFieldGuid = new JTextField();
jTextFieldGuid.setBounds(new java.awt.Rectangle(160, 35, 240, 20));
}
return jTextFieldGuid;
}
/**
This method initializes jButtonOk
@return javax.swing.JButton jButtonOk
**/
private JButton getJButtonOk() {
if (jButtonOk == null) {
jButtonOk = new JButton();
jButtonOk.setText("OK");
jButtonOk.setBounds(new java.awt.Rectangle(280, 115, 90, 20));
jButtonOk.addActionListener(this);
}
return jButtonOk;
}
/**
This method initializes jButtonCancel
@return javax.swing.JButton jButtonCancel
**/
private JButton getJButtonCancel() {
if (jButtonCancel == null) {
jButtonCancel = new JButton();
jButtonCancel.setText("Cancel");
jButtonCancel.setBounds(new java.awt.Rectangle(390, 115, 90, 20));
jButtonCancel.addActionListener(this);
}
return jButtonCancel;
}
/**
This method initializes jComboBoxUsage
@return javax.swing.JComboBox jComboBoxUsage
**/
private JComboBox getJComboBoxUsage() {
if (jComboBoxUsage == null) {
jComboBoxUsage = new JComboBox();
jComboBoxUsage.setBounds(new java.awt.Rectangle(160, 60, 320, 20));
}
return jComboBoxUsage;
}
/**
This method initializes jButtonGenerateGuid
@return javax.swing.JButton jButtonGenerateGuid
**/
private JButton getJButtonGenerateGuid() {
if (jButtonGenerateGuid == null) {
jButtonGenerateGuid = new JButton();
jButtonGenerateGuid.setBounds(new java.awt.Rectangle(405, 35, 75, 20));
jButtonGenerateGuid.setText("GEN");
jButtonGenerateGuid.addActionListener(this);
}
return jButtonGenerateGuid;
}
/**
This method initializes jTextFieldOverrideID
@return javax.swing.JTextField jTextFieldOverrideID
**/
private JTextField getJTextFieldOverrideID() {
if (jTextFieldOverrideID == null) {
jTextFieldOverrideID = new JTextField();
jTextFieldOverrideID.setBounds(new java.awt.Rectangle(160, 85, 320, 20));
}
return jTextFieldOverrideID;
}
public static void main(String[] args) {
}
/**
This is the default constructor
**/
public ModuleFormsets() {
super();
init();
this.setVisible(true);
}
/**
*
*/
/**
This is the override edit constructor
@param inFormsets The input data of FormsetsDocument.Formsets
**/
public ModuleFormsets(FormsetsDocument.Formsets inFormsets) {
super();
init(inFormsets);
this.setVisible(true);
}
/**
This is the override edit constructor
@param inFormsets The input data of FormsetsDocument.Formsets
@param type The input data of node type
@param index The input data of node index
**/
public ModuleFormsets(FormsetsDocument.Formsets inFormsets, int type, int index) {
super();
init(inFormsets, type, index);
this.setVisible(true);
}
/**
This method initializes this
@param inFormsets The input data of FormsetsDocument.Formsets
**/
private void init(FormsetsDocument.Formsets inFormsets) {
init();
this.setFormsets(inFormsets);
}
/**
This method initializes this
Fill values to all fields if these values are not empty
@param inFormsets The input data of FormsetsDocument.Formsets
@param type The input data of node type
@param index The input data of node index
**/
private void init(FormsetsDocument.Formsets inFormsets, int type, int index) {
init(inFormsets);
this.location = index;
if (this.formsets.getFormsetList().size() > 0) {
if (this.formsets.getFormsetArray(index).getStringValue() != null) {
this.jTextFieldName.setText(this.formsets.getFormsetArray(index).getStringValue().toString());
}
if (this.formsets.getFormsetArray(index).getGuid() != null) {
this.jTextFieldGuid.setText(this.formsets.getFormsetArray(index).getGuid());
}
if (this.formsets.getFormsetArray(index).getUsage() != null) {
this.jComboBoxUsage.setSelectedItem(this.formsets.getFormsetArray(index).getUsage().toString());
}
this.jTextFieldOverrideID.setText(String.valueOf(this.formsets.getFormsetArray(index).getOverrideID()));
}
}
/**
This method initializes this
**/
private void init() {
this.setContentPane(getJContentPane());
this.setTitle("Form Sets");
this.setBounds(new java.awt.Rectangle(0, 0, 500, 515));
initFrame();
this.setViewMode(false);
}
/**
Disable all components when the mode is view
@param isView true - The view mode; false - The non-view mode
**/
public void setViewMode(boolean isView) {
this.jButtonOk.setVisible(false);
this.jButtonCancel.setVisible(false);
if (isView) {
this.jTextFieldName.setEnabled(!isView);
this.jTextFieldGuid.setEnabled(!isView);
this.jComboBoxUsage.setEnabled(!isView);
this.jTextFieldOverrideID.setEnabled(!isView);
this.jButtonCancel.setEnabled(!isView);
this.jButtonGenerateGuid.setEnabled(!isView);
this.jButtonOk.setEnabled(!isView);
}
}
/**
This method initializes jContentPane
@return javax.swing.JPanel jContentPane
**/
private JPanel getJContentPane() {
if (jContentPane == null) {
jLabelOverrideID = new JLabel();
jLabelOverrideID.setBounds(new java.awt.Rectangle(15, 85, 140, 20));
jLabelOverrideID.setText("Override ID");
jLabelUsage = new JLabel();
jLabelUsage.setText("Usage");
jLabelUsage.setBounds(new java.awt.Rectangle(15, 60, 140, 20));
jLabelGuid = new JLabel();
jLabelGuid.setText("Guid");
jLabelGuid.setBounds(new java.awt.Rectangle(15, 35, 140, 20));
jLabelName = new JLabel();
jLabelName.setText("Name");
jLabelName.setBounds(new java.awt.Rectangle(15, 10, 140, 20));
jContentPane = new JPanel();
jContentPane.setLayout(null);
jContentPane.add(jLabelName, null);
jContentPane.add(getJTextFieldName(), null);
jContentPane.add(jLabelGuid, null);
jContentPane.add(getJTextFieldGuid(), null);
jContentPane.add(jLabelUsage, null);
jContentPane.add(getJButtonOk(), null);
jContentPane.add(getJButtonCancel(), null);
jContentPane.add(getJComboBoxUsage(), null);
jContentPane.add(getJButtonGenerateGuid(), null);
jContentPane.add(jLabelOverrideID, null);
jContentPane.add(getJTextFieldOverrideID(), null);
jStarLabel1 = new StarLabel();
jStarLabel1.setLocation(new java.awt.Point(0, 10));
jContentPane.add(jStarLabel1, null);
}
return jContentPane;
}
/**
This method initializes Usage type
**/
private void initFrame() {
jComboBoxUsage.addItem("ALWAYS_PRODUCED");
jComboBoxUsage.addItem("SOMETIMES_PRODUCED");
jComboBoxUsage.addItem("PRIVATE");
}
/* (non-Javadoc)
* @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
*
* Override actionPerformed to listen all actions
*
*/
public void actionPerformed(ActionEvent arg0) {
if (arg0.getSource() == jButtonOk) {
this.setEdited(true);
this.save();
this.dispose();
}
if (arg0.getSource() == jButtonCancel) {
this.dispose();
}
if (arg0.getSource() == jButtonGenerateGuid) {
jTextFieldGuid.setText(Tools.generateUuidString());
}
}
/**
Set FormsetsDocument.Formsets
@return FormsetsDocument.Formsets
**/
public FormsetsDocument.Formsets getFormsets() {
return formsets;
}
/**
Get FormsetsDocument.Formsets
@param formsets The input FormsetsDocument.Formsets
**/
public void setFormsets(FormsetsDocument.Formsets formsets) {
this.formsets = formsets;
}
/**
Data validation for all fields
@retval true - All datas are valid
@retval false - At least one data is invalid
**/
public boolean check() {
//
// Check if all required fields are not empty
//
if (isEmpty(this.jTextFieldName.getText())) {
Log.err("Name couldn't be empty");
return false;
}
//
// Check if all fields have correct data types
//
if (!DataValidation.isCName(this.jTextFieldName.getText())) {
Log.err("Incorrect data type for Name");
return false;
}
if (!isEmpty(this.jTextFieldGuid.getText()) && !DataValidation.isGuid(this.jTextFieldGuid.getText())) {
Log.err("Incorrect data type for Guid");
return false;
}
if (!isEmpty(this.jTextFieldOverrideID.getText())
&& !DataValidation.isOverrideID(this.jTextFieldOverrideID.getText())) {
Log.err("Incorrect data type for Override ID");
return false;
}
return true;
}
/**
Save all components of Formsets
if exists formset, set the value directly
if not exists formset, new an instance first
**/
public void save() {
try {
if (this.formsets == null) {
formsets = FormsetsDocument.Formsets.Factory.newInstance();
}
FormsetsDocument.Formsets.Formset formset = FormsetsDocument.Formsets.Formset.Factory.newInstance();
if (!isEmpty(this.jTextFieldName.getText())) {
formset.setStringValue(this.jTextFieldName.getText());
}
if (!isEmpty(this.jTextFieldGuid.getText())) {
formset.setGuid(this.jTextFieldGuid.getText());
}
formset.setUsage(FormSetUsage.Enum.forString(jComboBoxUsage.getSelectedItem().toString()));
if (!isEmpty(this.jTextFieldOverrideID.getText())) {
formset.setOverrideID(Integer.parseInt(this.jTextFieldOverrideID.getText()));
}
if (location > -1) {
formsets.setFormsetArray(location, formset);
} else {
formsets.addNewFormset();
formsets.setFormsetArray(formsets.getFormsetList().size() - 1, formset);
}
} catch (Exception e) {
Log.err("Update Formsets", e.getMessage());
}
}
}

View File

@ -0,0 +1,675 @@
/** @file
The file is used to create, update Guids of MSA/MBD file
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.packaging.module.ui;
import java.awt.event.ActionEvent;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.JTextField;
import org.tianocore.ConditionalExpressionDocument;
import org.tianocore.DefaultValueDocument;
import org.tianocore.GuidUsage;
import org.tianocore.GuidsDocument;
import org.tianocore.common.DataValidation;
import org.tianocore.common.Log;
import org.tianocore.common.Tools;
import org.tianocore.packaging.common.ui.IComboBox;
import org.tianocore.packaging.common.ui.IInternalFrame;
import org.tianocore.packaging.common.ui.StarLabel;
/**
The class is used to create, update Guids of MSA/MBD file
It extends IInternalFrame
@since ModuleEditor 1.0
**/
public class ModuleGuids extends IInternalFrame {
///
/// Define class Serial Version UID
///
private static final long serialVersionUID = 6710858997766979803L;
//
//Define class members
//
private GuidsDocument.Guids guids = null;
private int location = -1;
private JPanel jContentPane = null;
private JLabel jLabelC_Name = null;
private JTextField jTextFieldC_Name = null;
private JLabel jLabelGuidValue = null;
private JTextField jTextFieldGuidValue = null;
private JLabel jLabelFeatureFlag = null;
private IComboBox iComboBoxFeatureFlag = null;
private JLabel jLabelConditionalExpression = null;
private IComboBox iComboBoxConditionalExpression = null;
private JLabel jLabelDefault = null;
private JTextField jTextFieldDefaultValue = null;
private JLabel jLabelHelpText = null;
private JTextField jTextFieldHelpText = null;
private JLabel jLabelEnableFeature = null;
private JRadioButton jRadioButtonEnableFeature = null;
private JRadioButton jRadioButtonDisableFeature = null;
private JLabel jLabelUsage = null;
private JComboBox jComboBoxUsage = null;
private JButton jButtonOk = null;
private JButton jButtonCancel = null;
private JButton jButtonGenerateGuid = null;
private JLabel jLabelOverrideID = null;
private JTextField jTextFieldOverrideID = null;
/**
This method initializes jTextFieldC_Name
@return javax.swing.JTextField jTextFieldC_Name
**/
private JTextField getJTextFieldC_Name() {
if (jTextFieldC_Name == null) {
jTextFieldC_Name = new JTextField();
jTextFieldC_Name.setBounds(new java.awt.Rectangle(160, 10, 320, 20));
}
return jTextFieldC_Name;
}
/**
This method initializes jTextFieldGuidValsue
@return javax.swing.JTextField jTextFieldGuidValue
**/
private JTextField getJTextFieldGuidValsue() {
if (jTextFieldGuidValue == null) {
jTextFieldGuidValue = new JTextField();
jTextFieldGuidValue.setBounds(new java.awt.Rectangle(160, 35, 240, 20));
}
return jTextFieldGuidValue;
}
/**
This method initializes jTextFieldFeatureFlag
@return javax.swing.JTextField iComboBoxFeatureFlag
**/
private IComboBox getIComboBoxFeatureFlag() {
if (iComboBoxFeatureFlag == null) {
iComboBoxFeatureFlag = new IComboBox();
iComboBoxFeatureFlag.setBounds(new java.awt.Rectangle(160, 60, 320, 20));
}
return iComboBoxFeatureFlag;
}
/**
This method initializes jTextFieldConditionalExpression
@return javax.swing.JTextField iComboBoxConditionalExpression
**/
private IComboBox getIComboBoxConditionalExpression() {
if (iComboBoxConditionalExpression == null) {
iComboBoxConditionalExpression = new IComboBox();
iComboBoxConditionalExpression.setBounds(new java.awt.Rectangle(160, 85, 320, 20));
}
return iComboBoxConditionalExpression;
}
/**
This method initializes jTextFieldDefault
@return javax.swing.JTextField jTextFieldDefaultValue
**/
private JTextField getJTextFieldDefaultValue() {
if (jTextFieldDefaultValue == null) {
jTextFieldDefaultValue = new JTextField();
jTextFieldDefaultValue.setBounds(new java.awt.Rectangle(160, 110, 320, 20));
}
return jTextFieldDefaultValue;
}
/**
This method initializes jTextFieldHelpText
@return javax.swing.JTextField jTextFieldHelpText
**/
private JTextField getJTextFieldHelpText() {
if (jTextFieldHelpText == null) {
jTextFieldHelpText = new JTextField();
jTextFieldHelpText.setBounds(new java.awt.Rectangle(160, 135, 320, 20));
}
return jTextFieldHelpText;
}
/**
This method initializes jRadioButtonEnableFeature
@return javax.swing.JRadioButton jRadioButtonEnableFeature
**/
private JRadioButton getJRadioButtonEnableFeature() {
if (jRadioButtonEnableFeature == null) {
jRadioButtonEnableFeature = new JRadioButton();
jRadioButtonEnableFeature.setText("Enable");
jRadioButtonEnableFeature.setBounds(new java.awt.Rectangle(160, 160, 90, 20));
jRadioButtonEnableFeature.setSelected(true);
jRadioButtonEnableFeature.addActionListener(this);
}
return jRadioButtonEnableFeature;
}
/**
This method initializes jRadioButtonDisableFeature
@return javax.swing.JRadioButton jRadioButtonDisableFeature
**/
private JRadioButton getJRadioButtonDisableFeature() {
if (jRadioButtonDisableFeature == null) {
jRadioButtonDisableFeature = new JRadioButton();
jRadioButtonDisableFeature.setText("Disable");
jRadioButtonDisableFeature.setBounds(new java.awt.Rectangle(320, 160, 90, 20));
jRadioButtonDisableFeature.addActionListener(this);
}
return jRadioButtonDisableFeature;
}
/**
This method initializes jComboBoxUsage
@return javax.swing.JComboBox jComboBoxUsage
**/
private JComboBox getJComboBoxUsage() {
if (jComboBoxUsage == null) {
jComboBoxUsage = new JComboBox();
jComboBoxUsage.setBounds(new java.awt.Rectangle(160, 185, 320, 20));
}
return jComboBoxUsage;
}
/**
This method initializes jButtonOk
@return javax.swing.JButton jButtonOk
**/
private JButton getJButtonOk() {
if (jButtonOk == null) {
jButtonOk = new JButton();
jButtonOk.setText("OK");
jButtonOk.setBounds(new java.awt.Rectangle(290, 240, 90, 20));
jButtonOk.addActionListener(this);
}
return jButtonOk;
}
/**
This method initializes jButtonCancel
@return javax.swing.JButton jButtonCancel
**/
private JButton getJButtonCancel() {
if (jButtonCancel == null) {
jButtonCancel = new JButton();
jButtonCancel.setText("Cancel");
jButtonCancel.setBounds(new java.awt.Rectangle(390, 240, 90, 20));
jButtonCancel.addActionListener(this);
}
return jButtonCancel;
}
/**
This method initializes jButtonGenerateGuid
@return javax.swing.JButton jButtonGenerateGuid
**/
private JButton getJButtonGenerateGuid() {
if (jButtonGenerateGuid == null) {
jButtonGenerateGuid = new JButton();
jButtonGenerateGuid.setBounds(new java.awt.Rectangle(405, 35, 75, 20));
jButtonGenerateGuid.setText("GEN");
jButtonGenerateGuid.addActionListener(this);
}
return jButtonGenerateGuid;
}
/**
This method initializes jTextFieldOverrideID
@return javax.swing.JTextField jTextFieldOverrideID
**/
private JTextField getJTextFieldOverrideID() {
if (jTextFieldOverrideID == null) {
jTextFieldOverrideID = new JTextField();
jTextFieldOverrideID.setBounds(new java.awt.Rectangle(160, 210, 320, 20));
}
return jTextFieldOverrideID;
}
public static void main(String[] args) {
}
/**
This is the default constructor
**/
public ModuleGuids() {
super();
init();
this.setVisible(true);
}
/**
This is the override edit constructor
@param inGuids The input data of GuidsDocument.Guids
**/
public ModuleGuids(GuidsDocument.Guids inGuids) {
super();
init(inGuids);
this.setVisible(true);
}
/**
This is the override edit constructor
@param inGuids The input data of GuidsDocument.Guids
@param type The input data of node type
@param index The input data of node index
**/
public ModuleGuids(GuidsDocument.Guids inGuids, int type, int index) {
super();
init(inGuids, type, index);
this.setVisible(true);
}
/**
This method initializes this
@param inGuids The input data of GuidsDocument.Guids
**/
private void init(GuidsDocument.Guids inGuids) {
init();
this.setGuids(inGuids);
}
/**
This method initializes this
Fill values to all fields if these values are not empty
@param inGuids The input data of GuidsDocument.Guids
@param type The input data of node type
@param index The input data of node index
**/
private void init(GuidsDocument.Guids inGuids, int type, int index) {
init(inGuids);
this.location = index;
if (this.guids.getGuidEntryList().size() > 0) {
if (this.guids.getGuidEntryArray(index).getCName() != null) {
this.jTextFieldC_Name.setText(this.guids.getGuidEntryArray(index).getCName());
}
if (this.guids.getGuidEntryArray(index).getGuidValue() != null) {
this.jTextFieldGuidValue.setText(this.guids.getGuidEntryArray(index).getGuidValue());
}
if (this.guids.getGuidEntryArray(index).getFeatureFlagList().size() > 0) {
for (int indexI = 0; indexI < this.guids.getGuidEntryArray(index).getFeatureFlagList().size(); indexI++) {
this.iComboBoxFeatureFlag.addItem(this.guids.getGuidEntryArray(index).getFeatureFlagArray(indexI));
}
}
if (this.guids.getGuidEntryArray(index).getConditionalExpressionList().size() > 0) {
for (int indexI = 0; indexI < this.guids.getGuidEntryArray(index).getConditionalExpressionArray(0)
.getConditionList().size(); indexI++) {
this.iComboBoxConditionalExpression.addItem(this.guids.getGuidEntryArray(index)
.getConditionalExpressionArray(0)
.getConditionArray(indexI));
}
}
if (this.guids.getGuidEntryArray(index).getDefaultValue() != null) {
this.jTextFieldDefaultValue.setText(this.guids.getGuidEntryArray(index).getDefaultValue()
.getStringValue());
}
if (this.guids.getGuidEntryArray(index).getHelpText() != null) {
this.jTextFieldHelpText.setText(this.guids.getGuidEntryArray(index).getHelpText());
}
if (this.guids.getGuidEntryArray(index).getUsage() != null) {
this.jComboBoxUsage.setSelectedItem(this.guids.getGuidEntryArray(index).getUsage().toString());
}
this.jRadioButtonEnableFeature.setSelected(this.guids.getGuidEntryArray(index).getEnableFeature());
this.jRadioButtonDisableFeature.setSelected(!this.guids.getGuidEntryArray(index).getEnableFeature());
this.jTextFieldOverrideID.setText(String.valueOf(this.guids.getGuidEntryArray(index).getOverrideID()));
}
}
/**
This method initializes this
**/
private void init() {
this.setSize(500, 515);
this.setContentPane(getJContentPane());
this.setTitle("Guids");
initFrame();
this.setViewMode(false);
}
/**
Disable all components when the mode is view
@param isView true - The view mode; false - The non-view mode
**/
public void setViewMode(boolean isView) {
this.jButtonOk.setVisible(false);
this.jButtonCancel.setVisible(false);
if (isView) {
this.jTextFieldC_Name.setEnabled(!isView);
this.jTextFieldGuidValue.setEnabled(!isView);
this.iComboBoxFeatureFlag.setEnabled(!isView);
this.iComboBoxConditionalExpression.setEnabled(!isView);
this.jTextFieldDefaultValue.setEnabled(!isView);
this.jTextFieldHelpText.setEnabled(!isView);
this.jComboBoxUsage.setEnabled(!isView);
this.jRadioButtonEnableFeature.setEnabled(!isView);
this.jRadioButtonDisableFeature.setEnabled(!isView);
this.jTextFieldOverrideID.setEnabled(!isView);
this.jButtonCancel.setEnabled(!isView);
this.jButtonGenerateGuid.setEnabled(!isView);
this.jButtonOk.setEnabled(!isView);
}
}
/**
This method initializes jContentPane
@return javax.swing.JPanel jContentPane
**/
private JPanel getJContentPane() {
if (jContentPane == null) {
jLabelOverrideID = new JLabel();
jLabelOverrideID.setBounds(new java.awt.Rectangle(15, 210, 140, 20));
jLabelOverrideID.setText("Override ID");
jLabelUsage = new JLabel();
jLabelUsage.setText("Usage");
jLabelUsage.setBounds(new java.awt.Rectangle(15, 185, 140, 20));
jLabelEnableFeature = new JLabel();
jLabelEnableFeature.setText("Enable Feature");
jLabelEnableFeature.setBounds(new java.awt.Rectangle(15, 160, 140, 20));
jLabelHelpText = new JLabel();
jLabelHelpText.setText("Help Text");
jLabelHelpText.setBounds(new java.awt.Rectangle(15, 135, 140, 20));
jLabelDefault = new JLabel();
jLabelDefault.setText("Default Value");
jLabelDefault.setBounds(new java.awt.Rectangle(15, 110, 140, 20));
jLabelConditionalExpression = new JLabel();
jLabelConditionalExpression.setText("Conditional Expression");
jLabelConditionalExpression.setBounds(new java.awt.Rectangle(15, 85, 140, 20));
jLabelFeatureFlag = new JLabel();
jLabelFeatureFlag.setText("Feature Flag");
jLabelFeatureFlag.setBounds(new java.awt.Rectangle(15, 60, 140, 20));
jLabelGuidValue = new JLabel();
jLabelGuidValue.setText("Guid Value");
jLabelGuidValue.setBounds(new java.awt.Rectangle(15, 35, 140, 20));
jLabelC_Name = new JLabel();
jLabelC_Name.setText("C_Name");
jLabelC_Name.setBounds(new java.awt.Rectangle(15, 10, 140, 20));
jContentPane = new JPanel();
jContentPane.setLayout(null);
jContentPane.add(jLabelC_Name, null);
jContentPane.add(getJTextFieldC_Name(), null);
jContentPane.add(jLabelGuidValue, null);
jContentPane.add(getJTextFieldGuidValsue(), null);
jContentPane.add(jLabelFeatureFlag, null);
jContentPane.add(getIComboBoxFeatureFlag(), null);
jContentPane.add(jLabelConditionalExpression, null);
jContentPane.add(getIComboBoxConditionalExpression(), null);
jContentPane.add(jLabelDefault, null);
jContentPane.add(getJTextFieldDefaultValue(), null);
jContentPane.add(jLabelHelpText, null);
jContentPane.add(getJTextFieldHelpText(), null);
jContentPane.add(jLabelEnableFeature, null);
jContentPane.add(getJRadioButtonEnableFeature(), null);
jContentPane.add(getJRadioButtonDisableFeature(), null);
jContentPane.add(jLabelUsage, null);
jContentPane.add(getJComboBoxUsage(), null);
jContentPane.add(getJButtonOk(), null);
jContentPane.add(getJButtonCancel(), null);
jContentPane.add(getJButtonGenerateGuid(), null);
jContentPane.add(jLabelOverrideID, null);
jContentPane.add(getJTextFieldOverrideID(), null);
StarLabel jStarLabel1 = new StarLabel();
jStarLabel1.setLocation(new java.awt.Point(0, 10));
jContentPane.add(jStarLabel1, null);
initFrame();
}
return jContentPane;
}
/**
This method initializes Usage type
**/
private void initFrame() {
jComboBoxUsage.addItem("ALWAYS_CONSUMED");
jComboBoxUsage.addItem("SOMETIMES_CONSUMED");
jComboBoxUsage.addItem("ALWAYS_PRODUCED");
jComboBoxUsage.addItem("SOMETIMES_PRODUCED");
jComboBoxUsage.addItem("DEFAULT");
}
/* (non-Javadoc)
* @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
*
* Override actionPerformed to listen all actions
*
*/
public void actionPerformed(ActionEvent arg0) {
if (arg0.getSource() == jButtonOk) {
this.setEdited(true);
this.save();
this.dispose();
}
if (arg0.getSource() == jButtonCancel) {
this.dispose();
}
if (arg0.getSource() == jButtonGenerateGuid) {
jTextFieldGuidValue.setText(Tools.generateUuidString());
}
//
//Contorl the selected status when click RadionButton
//Do not use Radio Button Group
//
if (arg0.getSource() == jRadioButtonEnableFeature) {
if (jRadioButtonEnableFeature.isSelected()) {
jRadioButtonDisableFeature.setSelected(false);
}
if (!jRadioButtonDisableFeature.isSelected() && !jRadioButtonEnableFeature.isSelected()) {
jRadioButtonEnableFeature.setSelected(true);
}
}
if (arg0.getSource() == jRadioButtonDisableFeature) {
if (jRadioButtonDisableFeature.isSelected()) {
jRadioButtonEnableFeature.setSelected(false);
}
if (!jRadioButtonDisableFeature.isSelected() && !jRadioButtonEnableFeature.isSelected()) {
jRadioButtonDisableFeature.setSelected(true);
}
}
}
/**
Get GuidsDocument.Guids
@return GuidsDocument.Guids
**/
public GuidsDocument.Guids getGuids() {
return guids;
}
/**
Set GuidsDocument.Guids
@param guids The input GuidsDocument.Guids
**/
public void setGuids(GuidsDocument.Guids guids) {
this.guids = guids;
}
/**
Data validation for all fields
@retval true - All datas are valid
@retval false - At least one data is invalid
**/
public boolean check() {
//
// Check if all required fields are not empty
//
if (isEmpty(this.jTextFieldC_Name.getText())) {
Log.err("C_Name couldn't be empty");
return false;
}
//
// Check if all fields have correct data types
//
if (!DataValidation.isCName(this.jTextFieldC_Name.getText())) {
Log.err("Incorrect data type for C_Name");
return false;
}
if (!isEmpty(this.jTextFieldGuidValue.getText()) && !DataValidation.isGuid(this.jTextFieldGuidValue.getText())) {
Log.err("Incorrect data type for Guid Value");
return false;
}
if (!isEmpty(this.jTextFieldOverrideID.getText())
&& !DataValidation.isOverrideID(this.jTextFieldOverrideID.getText())) {
Log.err("Incorrect data type for Override ID");
return false;
}
return true;
}
/**
Save all components of Guids
if exists guids, set the value directly
if not exists guids, new an instance first
**/
public void save() {
try {
if (this.guids == null) {
guids = GuidsDocument.Guids.Factory.newInstance();
}
GuidsDocument.Guids.GuidEntry guid = GuidsDocument.Guids.GuidEntry.Factory.newInstance();
if (!isEmpty(this.jTextFieldC_Name.getText())) {
guid.setCName(this.jTextFieldC_Name.getText());
}
if (!isEmpty(this.jTextFieldGuidValue.getText())) {
guid.setGuidValue(this.jTextFieldGuidValue.getText());
}
if (this.iComboBoxFeatureFlag.getItemCount() > 0) {
for (int index = 0; index < this.iComboBoxFeatureFlag.getItemCount(); index++) {
guid.addNewFeatureFlag();
guid.setFeatureFlagArray(index, this.iComboBoxFeatureFlag.getItemAt(index).toString());
}
}
if (this.iComboBoxConditionalExpression.getItemCount() > 0) {
ConditionalExpressionDocument.ConditionalExpression ce = ConditionalExpressionDocument.ConditionalExpression.Factory
.newInstance();
for (int index = 0; index < this.iComboBoxConditionalExpression.getItemCount(); index++) {
ce.addCondition(this.iComboBoxConditionalExpression.getItemAt(index).toString());
}
if (guid.getConditionalExpressionList().size() < 1) {
guid.addNewConditionalExpression();
}
guid.setConditionalExpressionArray(0, ce);
}
if (!isEmpty(this.jTextFieldDefaultValue.getText())) {
DefaultValueDocument.DefaultValue dv = DefaultValueDocument.DefaultValue.Factory.newInstance();
dv.setStringValue(this.jTextFieldDefaultValue.getText());
guid.setDefaultValue(dv);
}
if (!isEmpty(this.jTextFieldHelpText.getText())) {
guid.setHelpText(this.jTextFieldHelpText.getText());
}
guid.setUsage(GuidUsage.Enum.forString(jComboBoxUsage.getSelectedItem().toString()));
guid.setEnableFeature(this.jRadioButtonEnableFeature.isSelected());
if (!isEmpty(this.jTextFieldOverrideID.getText())) {
guid.setOverrideID(Integer.parseInt(this.jTextFieldOverrideID.getText()));
}
if (location > -1) {
guids.setGuidEntryArray(location, guid);
} else {
guids.addNewGuidEntry();
guids.setGuidEntryArray(guids.getGuidEntryList().size() - 1, guid);
}
} catch (Exception e) {
Log.err("Update Guids", e.getMessage());
}
}
}

View File

@ -0,0 +1,596 @@
/** @file
The file is used to create, update Hob of MSA/MBD file
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.packaging.module.ui;
import java.awt.event.ActionEvent;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.JTextField;
import org.tianocore.GuidDocument;
import org.tianocore.HobTypes;
import org.tianocore.HobUsage;
import org.tianocore.HobsDocument;
import org.tianocore.common.DataValidation;
import org.tianocore.common.Log;
import org.tianocore.common.Tools;
import org.tianocore.packaging.common.ui.IInternalFrame;
import org.tianocore.packaging.common.ui.StarLabel;
/**
The class is used to create, update Hob of MSA/MBD file
It extends IInternalFrame
@since ModuleEditor 1.0
**/
public class ModuleHobs extends IInternalFrame {
///
/// Define class Serial Version UID
///
private static final long serialVersionUID = -553473437579358325L;
//
//Define class members
//
private HobsDocument.Hobs hobs = null;
private int location = -1;
private JPanel jContentPane = null;
private JLabel jLabel = null;
private JTextField jTextFieldC_Name = null;
private JLabel jLabelGuid = null;
private JTextField jTextFieldGuid = null;
private JLabel jLabelName = null;
private JTextField jTextFieldName = null;
private JLabel jLabelUsage = null;
private JLabel jLabelHobType = null;
private JComboBox jComboBoxUsage = null;
private JComboBox jComboBoxHobType = null;
private JLabel jLabelHobEnabled = null;
private JRadioButton jRadioButtonHobEnable = null;
private JRadioButton jRadioButtonHobDisable = null;
private JButton jButtonOk = null;
private JButton jButtonCancel = null;
private JButton jButtonGenerateGuid = null;
private JLabel jLabelOverrideID = null;
private JTextField jTextFieldOverrideID = null;
private StarLabel jStarLabel1 = null;
/**
This method initializes jTextField
@return javax.swing.JTextField jTextFieldC_Name
**/
private JTextField getJTextFieldC_Name() {
if (jTextFieldC_Name == null) {
jTextFieldC_Name = new JTextField();
jTextFieldC_Name.setBounds(new java.awt.Rectangle(160, 35, 320, 20));
}
return jTextFieldC_Name;
}
/**
This method initializes jTextField
@return javax.swing.JTextField jTextFieldGuid
**/
private JTextField getJTextFieldGuid() {
if (jTextFieldGuid == null) {
jTextFieldGuid = new JTextField();
jTextFieldGuid.setBounds(new java.awt.Rectangle(160, 60, 240, 20));
}
return jTextFieldGuid;
}
/**
This method initializes jTextFieldName
@return javax.swing.JTextField jTextFieldName
**/
private JTextField getJTextFieldName() {
if (jTextFieldName == null) {
jTextFieldName = new JTextField();
jTextFieldName.setBounds(new java.awt.Rectangle(160, 10, 320, 20));
}
return jTextFieldName;
}
/**
This method initializes jComboBoxUsage
@return javax.swing.JComboBox jComboBoxUsage
**/
private JComboBox getJComboBoxUsage() {
if (jComboBoxUsage == null) {
jComboBoxUsage = new JComboBox();
jComboBoxUsage.setBounds(new java.awt.Rectangle(160, 85, 320, 20));
}
return jComboBoxUsage;
}
/**
This method initializes jComboBoxHobType
@return javax.swing.JComboBox jComboBoxHobType
**/
private JComboBox getJComboBoxHobType() {
if (jComboBoxHobType == null) {
jComboBoxHobType = new JComboBox();
jComboBoxHobType.setBounds(new java.awt.Rectangle(160, 110, 320, 20));
}
return jComboBoxHobType;
}
/**
This method initializes jRadioButtonEnable
@return javax.swing.JRadioButton jRadioButtonHobEnable
**/
private JRadioButton getJRadioButtonHobEnable() {
if (jRadioButtonHobEnable == null) {
jRadioButtonHobEnable = new JRadioButton();
jRadioButtonHobEnable.setText("Enable");
jRadioButtonHobEnable.setBounds(new java.awt.Rectangle(160, 135, 90, 20));
jRadioButtonHobEnable.setSelected(true);
jRadioButtonHobEnable.addActionListener(this);
}
return jRadioButtonHobEnable;
}
/**
This method initializes jRadioButtonDisable
@return javax.swing.JRadioButton jRadioButtonHobDisable
**/
private JRadioButton getJRadioButtonHobDisable() {
if (jRadioButtonHobDisable == null) {
jRadioButtonHobDisable = new JRadioButton();
jRadioButtonHobDisable.setText("Disable");
jRadioButtonHobDisable.setBounds(new java.awt.Rectangle(320, 135, 90, 20));
jRadioButtonHobDisable.addActionListener(this);
}
return jRadioButtonHobDisable;
}
/**
This method initializes jButtonOk
@return javax.swing.JButton jButtonOk
**/
private JButton getJButtonOk() {
if (jButtonOk == null) {
jButtonOk = new JButton();
jButtonOk.setText("OK");
jButtonOk.setBounds(new java.awt.Rectangle(290, 190, 90, 20));
jButtonOk.addActionListener(this);
}
return jButtonOk;
}
/**
This method initializes jButtonCancel
@return javax.swing.JButton jButtonCancel
**/
private JButton getJButtonCancel() {
if (jButtonCancel == null) {
jButtonCancel = new JButton();
jButtonCancel.setText("Cancel");
jButtonCancel.setBounds(new java.awt.Rectangle(390, 190, 90, 20));
jButtonCancel.addActionListener(this);
}
return jButtonCancel;
}
/**
This method initializes jButtonGenerateGuid
@return javax.swing.JButton jButtonGenerateGuid
**/
private JButton getJButtonGenerateGuid() {
if (jButtonGenerateGuid == null) {
jButtonGenerateGuid = new JButton();
jButtonGenerateGuid.setBounds(new java.awt.Rectangle(405, 60, 75, 20));
jButtonGenerateGuid.setText("GEN");
jButtonGenerateGuid.addActionListener(this);
}
return jButtonGenerateGuid;
}
/**
This method initializes jTextFieldOverrideID
@return javax.swing.JTextField jTextFieldOverrideID
**/
private JTextField getJTextFieldOverrideID() {
if (jTextFieldOverrideID == null) {
jTextFieldOverrideID = new JTextField();
jTextFieldOverrideID.setBounds(new java.awt.Rectangle(160, 160, 320, 20));
}
return jTextFieldOverrideID;
}
public static void main(String[] args) {
}
/**
This is the default constructor
**/
public ModuleHobs() {
super();
init();
this.setVisible(true);
}
/**
This is the override edit constructor
@param inHobs The input data of HobsDocument.Hobs
**/
public ModuleHobs(HobsDocument.Hobs inHobs) {
super();
init(inHobs);
this.setVisible(true);
}
/**
This is the override edit constructor
@param inHobs The input data of HobsDocument.Hobs
@param type The input data of node type
@param index The input data of node index
**/
public ModuleHobs(HobsDocument.Hobs inHobs, int type, int index) {
super();
init(inHobs, type, index);
this.setVisible(true);
}
/**
This method initializes this
@param inHobs The input data of HobsDocument.Hobs
**/
private void init(HobsDocument.Hobs inHobs) {
init();
this.setHobs(inHobs);
}
/**
This method initializes this
Fill values to all fields if these values are not empty
@param inHobs The input data of HobsDocument.Hobs
@param type The input data of node type
@param index The input data of node index
**/
private void init(HobsDocument.Hobs inHobs, int type, int index) {
init(inHobs);
this.location = index;
if (this.hobs.getHobList().size() > 0) {
if (this.hobs.getHobArray(index).getName() != null) {
this.jTextFieldName.setText(this.hobs.getHobArray(index).getName());
}
if (this.hobs.getHobArray(index).getCName() != null) {
this.jTextFieldC_Name.setText(this.hobs.getHobArray(index).getCName());
}
if (this.hobs.getHobArray(index).getGuid() != null) {
this.jTextFieldGuid.setText(this.hobs.getHobArray(index).getGuid().getStringValue());
}
if (this.hobs.getHobArray(index).getUsage() != null) {
this.jComboBoxUsage.setSelectedItem(this.hobs.getHobArray(index).getUsage().toString());
}
this.jRadioButtonHobEnable.setSelected(this.hobs.getHobArray(index).getHobEnabled());
this.jRadioButtonHobDisable.setSelected(!this.hobs.getHobArray(index).getHobEnabled());
this.jTextFieldOverrideID.setText(String.valueOf(this.hobs.getHobArray(index).getOverrideID()));
}
}
/**
This method initializes this
**/
private void init() {
this.setSize(500, 515);
this.setContentPane(getJContentPane());
this.setTitle("Hobs");
initFrame();
this.setViewMode(false);
}
/**
Disable all components when the mode is view
@param isView true - The view mode; false - The non-view mode
**/
public void setViewMode(boolean isView) {
this.jButtonOk.setVisible(false);
this.jButtonCancel.setVisible(false);
if (isView) {
this.jTextFieldName.setEnabled(!isView);
this.jTextFieldC_Name.setEnabled(!isView);
this.jTextFieldGuid.setEnabled(!isView);
this.jComboBoxUsage.setEnabled(!isView);
this.jComboBoxHobType.setEnabled(!isView);
this.jRadioButtonHobEnable.setEnabled(!isView);
this.jRadioButtonHobDisable.setEnabled(!isView);
this.jTextFieldOverrideID.setEnabled(!isView);
this.jButtonCancel.setEnabled(!isView);
this.jButtonGenerateGuid.setEnabled(!isView);
this.jButtonOk.setEnabled(!isView);
}
}
/**
This method initializes jContentPane
@return javax.swing.JPanel jContentPane
**/
public JPanel getJContentPane() {
if (jContentPane == null) {
jLabelOverrideID = new JLabel();
jLabelOverrideID.setBounds(new java.awt.Rectangle(15, 160, 140, 20));
jLabelOverrideID.setText("Override ID");
jLabelHobEnabled = new JLabel();
jLabelHobEnabled.setText("Hob Enabled");
jLabelHobEnabled.setBounds(new java.awt.Rectangle(15, 135, 140, 20));
jLabelHobType = new JLabel();
jLabelHobType.setText("Hob Type");
jLabelHobType.setBounds(new java.awt.Rectangle(15, 110, 140, 20));
jLabelUsage = new JLabel();
jLabelUsage.setText("Usage");
jLabelUsage.setBounds(new java.awt.Rectangle(15, 85, 140, 20));
jLabelName = new JLabel();
jLabelName.setText("Name");
jLabelName.setBounds(new java.awt.Rectangle(15, 10, 140, 20));
jLabelGuid = new JLabel();
jLabelGuid.setText("Guid");
jLabelGuid.setBounds(new java.awt.Rectangle(15, 60, 140, 20));
jLabel = new JLabel();
jLabel.setText("C_Name");
jLabel.setBounds(new java.awt.Rectangle(15, 35, 140, 20));
jContentPane = new JPanel();
jContentPane.setLayout(null);
jContentPane.add(jLabel, null);
jContentPane.add(getJTextFieldC_Name(), null);
jContentPane.add(getJTextFieldGuid(), null);
jContentPane.add(jLabelUsage, null);
jContentPane.add(jLabelName, null);
jContentPane.add(getJTextFieldName(), null);
jContentPane.add(jLabelGuid, null);
jContentPane.add(jLabelHobType, null);
jContentPane.add(getJComboBoxUsage(), null);
jContentPane.add(getJComboBoxHobType(), null);
jContentPane.add(jLabelHobEnabled, null);
jContentPane.add(getJRadioButtonHobEnable(), null);
jContentPane.add(getJRadioButtonHobDisable(), null);
jContentPane.add(getJButtonOk(), null);
jContentPane.add(getJButtonCancel(), null);
jContentPane.add(getJButtonGenerateGuid(), null);
jContentPane.add(jLabelOverrideID, null);
jContentPane.add(getJTextFieldOverrideID(), null);
jStarLabel1 = new StarLabel();
jStarLabel1.setLocation(new java.awt.Point(0, 10));
jContentPane.add(jStarLabel1, null);
}
return jContentPane;
}
/**
This method initializes Usage type and Hob type
**/
private void initFrame() {
jComboBoxHobType.addItem("PHIT");
jComboBoxHobType.addItem("MEMORY_ALLOCATION");
jComboBoxHobType.addItem("RESOURCE_DESCRIPTOR");
jComboBoxHobType.addItem("GUID_EXTENSION");
jComboBoxHobType.addItem("FIRMWARE_VOLUME");
jComboBoxHobType.addItem("CPU");
jComboBoxHobType.addItem("POOL");
jComboBoxHobType.addItem("CAPSULE_VOLUME");
jComboBoxUsage.addItem("ALWAYS_CONSUMED");
jComboBoxUsage.addItem("SOMETIMES_CONSUMED");
jComboBoxUsage.addItem("ALWAYS_PRODUCED");
jComboBoxUsage.addItem("SOMETIMES_PRODUCED");
jComboBoxUsage.addItem("PRIVATE");
}
/* (non-Javadoc)
* @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
*
* Override actionPerformed to listen all actions
*
*/
public void actionPerformed(ActionEvent arg0) {
if (arg0.getSource() == jButtonOk) {
this.setEdited(true);
this.save();
this.dispose();
}
if (arg0.getSource() == jButtonCancel) {
this.dispose();
}
//
// Contorl the selected status when click RadionButton
// Do not use Radio Button Group
//
if (arg0.getSource() == jRadioButtonHobEnable) {
if (jRadioButtonHobEnable.isSelected()) {
jRadioButtonHobDisable.setSelected(false);
}
if (!jRadioButtonHobDisable.isSelected() && !jRadioButtonHobEnable.isSelected()) {
jRadioButtonHobEnable.setSelected(true);
}
}
if (arg0.getSource() == jRadioButtonHobDisable) {
if (jRadioButtonHobDisable.isSelected()) {
jRadioButtonHobEnable.setSelected(false);
}
if (!jRadioButtonHobDisable.isSelected() && !jRadioButtonHobEnable.isSelected()) {
jRadioButtonHobDisable.setSelected(true);
}
}
if (arg0.getSource() == jButtonGenerateGuid) {
jTextFieldGuid.setText(Tools.generateUuidString());
}
}
/**
Get HobsDocument.Hobs
@return HobsDocument.Hobs
**/
public HobsDocument.Hobs getHobs() {
return hobs;
}
/**
Set HobsDocument.Hobs
@param hobs The input data of HobsDocument.Hobs
**/
public void setHobs(HobsDocument.Hobs hobs) {
this.hobs = hobs;
}
/**
Data validation for all fields
@retval true - All datas are valid
@retval false - At least one data is invalid
**/
public boolean check() {
//
// Check if all required fields are not empty
//
if (isEmpty(this.jTextFieldName.getText())) {
Log.err("Name couldn't be empty");
return false;
}
//
// Check if all fields have correct data types
//
if (!DataValidation.isCName(this.jTextFieldC_Name.getText())) {
Log.err("Incorrect data type for C_Name");
return false;
}
if (!isEmpty(this.jTextFieldGuid.getText()) && !DataValidation.isGuid(this.jTextFieldGuid.getText())) {
Log.err("Incorrect data type for Guid");
return false;
}
if (!isEmpty(this.jTextFieldOverrideID.getText())
&& !DataValidation.isOverrideID(this.jTextFieldOverrideID.getText())) {
Log.err("Incorrect data type for Override ID");
return false;
}
return true;
}
/**
Save all components of Hobs
if exists hobs, set the value directly
if not exists hobs, new an instance first
**/
public void save() {
try {
if (this.hobs == null) {
hobs = HobsDocument.Hobs.Factory.newInstance();
}
HobsDocument.Hobs.Hob hob = HobsDocument.Hobs.Hob.Factory.newInstance();
if (!isEmpty(this.jTextFieldName.getText())) {
hob.setName(this.jTextFieldName.getText());
}
if (!isEmpty(this.jTextFieldC_Name.getText())) {
hob.setCName(this.jTextFieldC_Name.getText());
}
if (!isEmpty(this.jTextFieldGuid.getText())) {
GuidDocument.Guid guid = GuidDocument.Guid.Factory.newInstance();
guid.setStringValue(this.jTextFieldGuid.getText());
hob.setGuid(guid);
}
hob.setUsage(HobUsage.Enum.forString(jComboBoxUsage.getSelectedItem().toString()));
hob.setHobType(HobTypes.Enum.forString(jComboBoxHobType.getSelectedItem().toString()));
hob.setHobEnabled(this.jRadioButtonHobEnable.isSelected());
if (!isEmpty(this.jTextFieldOverrideID.getText())) {
hob.setOverrideID(Integer.parseInt(this.jTextFieldOverrideID.getText()));
}
if (location > -1) {
hobs.setHobArray(location, hob);
} else {
hobs.addNewHob();
hobs.setHobArray(hobs.getHobList().size() - 1, hob);
}
} catch (Exception e) {
Log.err("Update Hobs", e.getMessage());
}
}
}

View File

@ -0,0 +1,867 @@
/** @file
The file is used to create, update Include of MSA/MBD file
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.packaging.module.ui;
import java.awt.event.ActionEvent;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.util.Vector;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import org.tianocore.IncludesDocument;
import org.tianocore.PackageNameDocument;
import org.tianocore.PackageType;
import org.tianocore.PackageUsage;
import org.tianocore.SupportedArchitectures;
import org.tianocore.common.DataValidation;
import org.tianocore.common.Log;
import org.tianocore.packaging.common.ui.IDefaultMutableTreeNode;
import org.tianocore.packaging.common.ui.IInternalFrame;
import org.tianocore.packaging.common.ui.StarLabel;
/**
The class is used to create, update Include of MSA/MBD file
It extends IInternalFrame
@since ModuleEditor 1.0
**/
public class ModuleIncludes extends IInternalFrame implements ItemListener {
///
/// Define class Serial Version UID
///
private static final long serialVersionUID = 3465193035145152131L;
//
//Define class members
//
private IncludesDocument.Includes includes = null;
private int location = -1;
private int intSelectedItemId = 0;
//
// 1 - Add; 2 - Update
//
private int operation = -1;
private Vector<String> vPackageName = new Vector<String>();
private Vector<String> vUsage = new Vector<String>();
private Vector<String> vPackageType = new Vector<String>();
private Vector<String> vUpdatedDate = new Vector<String>();
private JPanel jContentPane = null;
private JButton jButtonOk = null;
private JButton jButtonCancel = null;
private JLabel jLabelPackageName = null;
private JLabel jLabelPackageType = null;
private JComboBox jComboBoxPackageType = null;
private JLabel jLabelUsage = null;
private JComboBox jComboBoxUsage = null;
private StarLabel jStarLabel1 = null;
private JTextField jTextFieldPackageName = null;
private JComboBox jComboBoxFileList = null;
private JButton jButtonAdd = null;
private JButton jButtonUpdate = null;
private JButton jButtonRemove = null;
private JLabel jLabelUpdatedDate = null;
private JTextField jTextFieldUpdatedDate = null;
private JCheckBox jCheckBoxArch = null;
private JComboBox jComboBoxArch = null;
/**
This method initializes jButtonOk
@return javax.swing.JButton jButtonOk
**/
private JButton getJButton() {
if (jButtonOk == null) {
jButtonOk = new JButton();
jButtonOk.setText("OK");
jButtonOk.setBounds(new java.awt.Rectangle(290, 165, 90, 20));
jButtonOk.addActionListener(this);
}
return jButtonOk;
}
/**
This method initializes jButtonCancel
@return javax.swing.JButton jButtonCancel
**/
private JButton getJButton1() {
if (jButtonCancel == null) {
jButtonCancel = new JButton();
jButtonCancel.setText("Cancel");
jButtonCancel.setBounds(new java.awt.Rectangle(390, 165, 90, 20));
jButtonCancel.addActionListener(this);
}
return jButtonCancel;
}
/**
This method initializes jComboBoxPackageType
@return javax.swing.JComboBox jComboBoxPackageType
**/
private JComboBox getJComboBoxPackageType() {
if (jComboBoxPackageType == null) {
jComboBoxPackageType = new JComboBox();
jComboBoxPackageType.setBounds(new java.awt.Rectangle(160, 35, 320, 20));
}
return jComboBoxPackageType;
}
/**
This method initializes jComboBoxUsage
@return javax.swing.JComboBox jComboBoxUsage
**/
private JComboBox getJComboBoxUsage() {
if (jComboBoxUsage == null) {
jComboBoxUsage = new JComboBox();
jComboBoxUsage.setBounds(new java.awt.Rectangle(160, 60, 320, 20));
}
return jComboBoxUsage;
}
/**
This method initializes jTextFieldPackageName
@return javax.swing.JTextField jTextFieldPackageName
**/
private JTextField getJTextFieldPackageName() {
if (jTextFieldPackageName == null) {
jTextFieldPackageName = new JTextField();
jTextFieldPackageName.setBounds(new java.awt.Rectangle(160, 10, 320, 20));
}
return jTextFieldPackageName;
}
/**
This method initializes jComboBoxFileList
@return javax.swing.JComboBox jComboBoxFileList
**/
private JComboBox getJComboBoxFileList() {
if (jComboBoxFileList == null) {
jComboBoxFileList = new JComboBox();
jComboBoxFileList.setBounds(new java.awt.Rectangle(15, 110, 210, 20));
jComboBoxFileList.addActionListener(this);
jComboBoxFileList.addItemListener(this);
}
return jComboBoxFileList;
}
/**
This method initializes jButtonAdd
@return javax.swing.JButton jButtonAdd
**/
private JButton getJButtonAdd() {
if (jButtonAdd == null) {
jButtonAdd = new JButton();
jButtonAdd.setBounds(new java.awt.Rectangle(230, 110, 80, 20));
jButtonAdd.setText("Add");
jButtonAdd.addActionListener(this);
}
return jButtonAdd;
}
/**
This method initializes jButtonUpdate
@return javax.swing.JButton jButtonUpdate
**/
private JButton getJButtonUpdate() {
if (jButtonUpdate == null) {
jButtonUpdate = new JButton();
jButtonUpdate.setBounds(new java.awt.Rectangle(315, 110, 80, 20));
jButtonUpdate.setText("Update");
jButtonUpdate.addActionListener(this);
}
return jButtonUpdate;
}
/**
This method initializes jButtonRemove
@return javax.swing.JButton jButtonRemove
**/
private JButton getJButtonRemove() {
if (jButtonRemove == null) {
jButtonRemove = new JButton();
jButtonRemove.setBounds(new java.awt.Rectangle(400, 110, 80, 20));
jButtonRemove.setText("Remove");
jButtonRemove.addActionListener(this);
}
return jButtonRemove;
}
/**
This method initializes jTextFieldUpdatedDate
@return javax.swing.JTextField jTextFieldUpdatedDate
**/
private JTextField getJTextFieldUpdatedDate() {
if (jTextFieldUpdatedDate == null) {
jTextFieldUpdatedDate = new JTextField();
jTextFieldUpdatedDate.setBounds(new java.awt.Rectangle(160, 85, 320, 20));
}
return jTextFieldUpdatedDate;
}
/**
This method initializes jCheckBoxArch
@return javax.swing.JCheckBox jCheckBoxArch
**/
private JCheckBox getJCheckBoxArch() {
if (jCheckBoxArch == null) {
jCheckBoxArch = new JCheckBox();
jCheckBoxArch.setBounds(new java.awt.Rectangle(10, 135, 120, 20));
jCheckBoxArch.setText("Specific Arch");
jCheckBoxArch.addActionListener(this);
}
return jCheckBoxArch;
}
/**
This method initializes jComboBoxArch
@return javax.swing.JComboBox jComboBoxArch
**/
private JComboBox getJComboBoxArch() {
if (jComboBoxArch == null) {
jComboBoxArch = new JComboBox();
jComboBoxArch.setBounds(new java.awt.Rectangle(140, 135, 340, 20));
jComboBoxArch.setEnabled(false);
}
return jComboBoxArch;
}
public static void main(String[] args) {
}
/**
This is the default constructor
**/
public ModuleIncludes() {
super();
init();
this.setVisible(true);
}
/**
This is the override edit constructor
@param inIncludes The input data of IncludesDocument.Includes
**/
public ModuleIncludes(IncludesDocument.Includes inIncludes) {
super();
init(inIncludes);
this.setVisible(true);
}
/**
This is the override edit constructor
@param inIncludes The input data of IncludesDocument.Includes
@param type The input data of node type
@param index The input data of node index
**/
public ModuleIncludes(IncludesDocument.Includes inIncludes, int type, int index) {
super();
this.setVisible(true);
}
/**
This is the override edit constructor
@param inIncludes The input data of IncludesDocument.Includes
@param type The input data of node type
@param index The input data of node index
@param inOperation The input data of current operation type
**/
public ModuleIncludes(IncludesDocument.Includes inIncludes, int type, int index, int inOperation) {
super();
init(inIncludes, type, index, inOperation);
this.operation = inOperation;
this.setVisible(true);
}
/**
This method initializes this
@param inIncludes
**/
private void init(IncludesDocument.Includes inIncludes) {
init();
this.setIncludes(inIncludes);
}
/**
This method initializes this
Fill values to all fields if these values are not empty
@param inIncludes The input data of IncludesDocument.Includes
@param type The input data of node type
@param index The input data of node index
@param inOperation The input data of current operation type
**/
private void init(IncludesDocument.Includes inIncludes, int type, int index, int inOperation) {
init(inIncludes);
this.location = index;
this.operation = inOperation;
if (operation == 2) {
this.jCheckBoxArch.setEnabled(false);
this.jComboBoxArch.setEnabled(false);
if (type == IDefaultMutableTreeNode.INCLUDES_PACKAGENAME) {
if (this.includes.getPackageNameList().size() > 0) {
for (int indexI = 0; indexI < this.includes.getPackageNameList().size(); indexI++) {
if (this.includes.getPackageNameArray(indexI).getStringValue() != null) {
vPackageName.addElement(this.includes.getPackageNameArray(indexI).getStringValue());
} else {
vPackageName.addElement("");
}
if (this.includes.getPackageNameArray(indexI).getUsage() != null) {
vUsage.addElement(this.includes.getPackageNameArray(indexI).getUsage().toString());
} else {
vUsage.addElement("ALWAYS_CONSUMED");
}
if (this.includes.getPackageNameArray(indexI).getPackageType() != null) {
vPackageType.addElement(this.includes.getPackageNameArray(indexI).getPackageType()
.toString());
} else {
vPackageType.addElement("SOURCE");
}
if (this.includes.getPackageNameArray(indexI).getUpdatedDate() != null) {
vUpdatedDate.addElement(this.includes.getPackageNameArray(indexI).getUpdatedDate());
} else {
vUpdatedDate.addElement("");
}
jComboBoxFileList.addItem(this.includes.getPackageNameArray(indexI).getStringValue());
}
}
}
if (type == IDefaultMutableTreeNode.INCLUDES_ARCH_ITEM) {
this.jCheckBoxArch.setSelected(true);
this.jComboBoxArch.setSelectedItem(this.includes.getArchArray(index).getArchType().toString());
for (int indexI = 0; indexI < this.includes.getArchArray(index).getPackageNameList().size(); indexI++) {
if (this.includes.getArchArray(index).getPackageNameArray(indexI).getStringValue() != null) {
vPackageName.addElement(this.includes.getArchArray(index).getPackageNameArray(indexI)
.getStringValue());
} else {
vPackageName.addElement("");
}
if (this.includes.getArchArray(index).getPackageNameArray(indexI).getUsage() != null) {
vUsage.addElement(this.includes.getArchArray(index).getPackageNameArray(indexI).getUsage()
.toString());
} else {
vUsage.addElement("");
}
if (this.includes.getArchArray(index).getPackageNameArray(indexI).getPackageType() != null) {
vPackageType.addElement(this.includes.getArchArray(index).getPackageNameArray(indexI)
.getPackageType().toString());
} else {
vPackageType.addElement("");
}
if (this.includes.getArchArray(index).getPackageNameArray(indexI).getUpdatedDate() != null) {
vUpdatedDate.addElement(this.includes.getArchArray(index).getPackageNameArray(indexI)
.getUpdatedDate());
} else {
vUpdatedDate.addElement("");
}
jComboBoxFileList.addItem(this.includes.getArchArray(index).getPackageNameArray(indexI)
.getStringValue());
}
}
}
}
/**
This method initializes this
**/
private void init() {
this.setSize(500, 515);
this.setContentPane(getJContentPane());
this.setTitle("Includes");
initFrame();
this.setViewMode(false);
}
/**
Disable all components when the mode is view
@param isView true - The view mode; false - The non-view mode
**/
public void setViewMode(boolean isView) {
this.jButtonOk.setVisible(false);
this.jButtonCancel.setVisible(false);
if (isView) {
this.jComboBoxPackageType.setEnabled(!isView);
this.jComboBoxUsage.setEnabled(!isView);
this.jTextFieldPackageName.setEnabled(!isView);
this.jButtonAdd.setEnabled(!isView);
this.jButtonUpdate.setEnabled(!isView);
this.jButtonRemove.setEnabled(!isView);
this.jTextFieldUpdatedDate.setEnabled(!isView);
this.jCheckBoxArch.setEnabled(!isView);
this.jComboBoxArch.setEnabled(!isView);
this.jButtonCancel.setEnabled(!isView);
this.jButtonOk.setEnabled(!isView);
}
}
/**
This method initializes jContentPane
@return javax.swing.JPanel jContentPane
**/
private JPanel getJContentPane() {
if (jContentPane == null) {
jLabelUpdatedDate = new JLabel();
jLabelUpdatedDate.setBounds(new java.awt.Rectangle(15, 85, 140, 20));
jLabelUpdatedDate.setText("Updated Date");
jLabelUsage = new JLabel();
jLabelUsage.setBounds(new java.awt.Rectangle(15, 60, 140, 20));
jLabelUsage.setText("Usage");
jLabelPackageType = new JLabel();
jLabelPackageType.setBounds(new java.awt.Rectangle(15, 35, 140, 20));
jLabelPackageType.setText("Package Type");
jLabelPackageName = new JLabel();
jLabelPackageName.setBounds(new java.awt.Rectangle(15, 10, 140, 20));
jLabelPackageName.setText("Package Name");
jContentPane = new JPanel();
jContentPane.setLayout(null);
jContentPane.add(getJButton(), null);
jContentPane.add(getJButton1(), null);
jContentPane.add(jLabelPackageName, null);
jContentPane.add(jLabelPackageType, null);
jContentPane.add(getJComboBoxPackageType(), null);
jContentPane.add(jLabelUsage, null);
jContentPane.add(getJComboBoxUsage(), null);
jStarLabel1 = new StarLabel();
jStarLabel1.setLocation(new java.awt.Point(0, 10));
jContentPane.add(jStarLabel1, null);
jContentPane.add(getJTextFieldPackageName(), null);
jContentPane.add(getJComboBoxFileList(), null);
jContentPane.add(getJButtonAdd(), null);
jContentPane.add(getJButtonUpdate(), null);
jContentPane.add(getJButtonRemove(), null);
jContentPane.add(jLabelUpdatedDate, null);
jContentPane.add(getJTextFieldUpdatedDate(), null);
jContentPane.add(getJCheckBoxArch(), null);
jContentPane.add(getJComboBoxArch(), null);
}
return jContentPane;
}
/* (non-Javadoc)
* @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
*
* Override actionPerformed to listen all actions
*
*/
public void actionPerformed(ActionEvent arg0) {
if (arg0.getSource() == jButtonOk) {
this.setEdited(true);
this.save();
this.dispose();
}
if (arg0.getSource() == jButtonCancel) {
this.dispose();
}
if (arg0.getSource() == jButtonAdd) {
if (!checkAdd()) {
return;
}
addToList();
}
if (arg0.getSource() == jButtonRemove) {
removeFromList();
}
if (arg0.getSource() == jButtonUpdate) {
if (!checkAdd()) {
return;
}
updateForList();
}
//
//When and only when checked Arch box then can choose different arch types
//
if (arg0.getSource() == jCheckBoxArch) {
if (this.jCheckBoxArch.isSelected()) {
this.jComboBoxArch.setEnabled(true);
} else {
this.jComboBoxArch.setEnabled(false);
}
}
}
/**
This method initializes Usage type, Package type and Arch type
**/
private void initFrame() {
jComboBoxUsage.addItem("ALWAYS_CONSUMED");
jComboBoxUsage.addItem("ALWAYS_PRODUCED");
jComboBoxUsage.addItem("DEFAULT");
jComboBoxPackageType.addItem("SOURCE");
jComboBoxPackageType.addItem("BINARY");
jComboBoxPackageType.addItem("MIXED");
jComboBoxArch.addItem("ALL");
jComboBoxArch.addItem("EBC");
jComboBoxArch.addItem("ARM");
jComboBoxArch.addItem("IA32");
jComboBoxArch.addItem("X64");
jComboBoxArch.addItem("IPF");
jComboBoxArch.addItem("PPC");
}
/**
Add current item to Vector
**/
private void addToList() {
intSelectedItemId = vPackageName.size();
vPackageName.addElement(this.jTextFieldPackageName.getText());
vUsage.addElement(this.jComboBoxUsage.getSelectedItem().toString());
vPackageType.addElement(this.jComboBoxPackageType.getSelectedItem().toString());
vUpdatedDate.addElement(this.jTextFieldUpdatedDate.getText());
jComboBoxFileList.addItem(this.jTextFieldPackageName.getText());
jComboBoxFileList.setSelectedItem(this.jTextFieldPackageName.getText());
//
// Reset select item index
//
intSelectedItemId = vPackageName.size();
//
// Reload all fields of selected item
//
reloadFromList();
}
/**
Remove item from Vector
**/
private void removeFromList() {
int intTempIndex = intSelectedItemId;
if (vPackageName.size() < 1) {
return;
}
jComboBoxFileList.removeItemAt(intSelectedItemId);
vPackageName.removeElementAt(intTempIndex);
vUsage.removeElementAt(intTempIndex);
vPackageType.removeElementAt(intTempIndex);
vUpdatedDate.removeElementAt(intTempIndex);
//
// Reload all fields of selected item
//
reloadFromList();
}
/**
Update current item of Vector
**/
private void updateForList() {
//
// Backup selected item index
//
int intTempIndex = intSelectedItemId;
vPackageName.setElementAt(this.jTextFieldPackageName.getText(), intSelectedItemId);
vUsage.setElementAt(this.jComboBoxUsage.getSelectedItem().toString(), intSelectedItemId);
vPackageType.setElementAt(this.jComboBoxPackageType.getSelectedItem().toString(), intSelectedItemId);
vUpdatedDate.setElementAt(this.jTextFieldUpdatedDate.getText(), intSelectedItemId);
jComboBoxFileList.removeAllItems();
for (int index = 0; index < vPackageName.size(); index++) {
jComboBoxFileList.addItem(vPackageName.elementAt(index));
}
//
// Restore selected item index
//
intSelectedItemId = intTempIndex;
//
// Reset select item index
//
jComboBoxFileList.setSelectedIndex(intSelectedItemId);
//
// Reload all fields of selected item
//
reloadFromList();
}
/**
Refresh all fields' values of selected item of Vector
**/
private void reloadFromList() {
if (vPackageName.size() > 0) {
//
// Get selected item index
//
intSelectedItemId = jComboBoxFileList.getSelectedIndex();
this.jTextFieldPackageName.setText(vPackageName.elementAt(intSelectedItemId).toString());
this.jComboBoxUsage.setSelectedItem(vUsage.elementAt(intSelectedItemId).toString());
this.jComboBoxPackageType.setSelectedItem(vPackageType.elementAt(intSelectedItemId).toString());
this.jTextFieldUpdatedDate.setText(vUpdatedDate.elementAt(intSelectedItemId).toString());
} else {
this.jTextFieldPackageName.setText("");
this.jComboBoxUsage.setSelectedItem("");
this.jComboBoxPackageType.setSelectedItem("");
this.jTextFieldUpdatedDate.setText("");
}
}
/**
Get IncludesDocument.Includes
@return IncludesDocument.Includes
**/
public IncludesDocument.Includes getIncludes() {
return includes;
}
/**
Set IncludesDocument.Includes
@param includes IncludesDocument.Includes
**/
public void setIncludes(IncludesDocument.Includes includes) {
this.includes = includes;
}
/* (non-Javadoc)
* @see java.awt.event.ItemListener#itemStateChanged(java.awt.event.ItemEvent)
*
* Reflesh the frame when selected item changed
*
*/
public void itemStateChanged(ItemEvent arg0) {
if (arg0.getStateChange() == ItemEvent.SELECTED) {
reloadFromList();
}
}
/**
Data validation for all fields
@retval true - All datas are valid
@retval false - At least one data is invalid
**/
public boolean check() {
if (this.jComboBoxFileList.getItemCount() < 1) {
Log.err("Must have one include at least!");
return false;
}
return true;
}
/**
Data validation for all fields before add current item to Vector
@retval true - All datas are valid
@retval false - At least one data is invalid
**/
public boolean checkAdd() {
//
// Check if all required fields are not empty
//
if (isEmpty(this.jTextFieldPackageName.getText())) {
Log.err("File Name couldn't be empty");
return false;
}
//
// Check if all fields have correct data types
//
if (!DataValidation.isPackageName(this.jTextFieldPackageName.getText())) {
Log.err("Incorrect data type for Package Name");
return false;
}
if (!isEmpty(this.jTextFieldUpdatedDate.getText())
&& !DataValidation.isDateType(this.jTextFieldUpdatedDate.getText())) {
Log.err("Incorrect data type for Update Date");
return false;
}
return true;
}
/**
Save all components of Includes
if exists includes, set the value directly
if not exists includes, new an instance first
**/
public void save() {
try {
if (this.includes == null) {
includes = IncludesDocument.Includes.Factory.newInstance();
}
//
//Save as file name
//
if (!this.jCheckBoxArch.isSelected()) {
if (this.operation == 2) { //Add new packageName
//
//First remove all existed packageName
//
if (includes.getPackageNameList().size() > 0) {
for (int index = includes.getPackageNameList().size() - 1; index >= 0; index--) {
includes.removePackageName(index);
}
}
}
for (int index = 0; index < vPackageName.size(); index++) {
PackageNameDocument.PackageName packageName = PackageNameDocument.PackageName.Factory.newInstance();
if (!isEmpty(vPackageName.elementAt(index).toString())) {
packageName.setStringValue(vPackageName.elementAt(index).toString());
}
if (!isEmpty(vUsage.elementAt(index).toString())) {
packageName.setUsage(PackageUsage.Enum.forString(vUsage.elementAt(index).toString()));
}
if (!isEmpty(vPackageType.elementAt(index).toString())) {
packageName
.setPackageType(PackageType.Enum.forString(vPackageType.elementAt(index).toString()));
}
if (!isEmpty(vUpdatedDate.elementAt(index).toString())) {
packageName.setUpdatedDate(vUpdatedDate.elementAt(index).toString());
}
includes.addNewPackageName();
includes.setPackageNameArray(includes.getPackageNameList().size() - 1, packageName);
}
}
//
//Save as Arch
//
if (this.jCheckBoxArch.isSelected()) {
IncludesDocument.Includes.Arch arch = IncludesDocument.Includes.Arch.Factory.newInstance();
if (this.operation == 2) {
//
//First remove all existed filename
//
for (int index = includes.getArchArray(location).getPackageNameList().size() - 1; index >= 0; index--) {
includes.getArchArray(location).removePackageName(index);
}
}
for (int index = 0; index < vPackageName.size(); index++) {
PackageNameDocument.PackageName packageName = PackageNameDocument.PackageName.Factory.newInstance();
if (!isEmpty(vPackageName.elementAt(index).toString())) {
packageName.setStringValue(vPackageName.elementAt(index).toString());
}
if (!isEmpty(vUsage.elementAt(index).toString())) {
packageName.setUsage(PackageUsage.Enum.forString(vUsage.elementAt(index).toString()));
}
if (!isEmpty(vPackageType.elementAt(index).toString())) {
packageName
.setPackageType(PackageType.Enum.forString(vPackageType.elementAt(index).toString()));
}
if (!isEmpty(vUpdatedDate.elementAt(index).toString())) {
packageName.setUpdatedDate(vUpdatedDate.elementAt(index).toString());
}
arch.addNewPackageName();
arch.setPackageNameArray(arch.getPackageNameList().size() - 1, packageName);
}
arch
.setArchType(SupportedArchitectures.Enum.forString(this.jComboBoxArch.getSelectedItem().toString()));
if (location > -1) {
includes.setArchArray(location, arch);
} else {
includes.addNewArch();
includes.setArchArray(includes.getArchList().size() - 1, arch);
}
}
} catch (Exception e) {
Log.err("Update Source Files", e.getMessage());
}
}
}

View File

@ -0,0 +1,625 @@
/** @file
The file is used to create, update Library Class Definition of MSA/MBD file
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.packaging.module.ui;
import java.awt.event.ActionEvent;
import javax.swing.DefaultListModel;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.JScrollPane;
import javax.swing.JTextField;
import org.tianocore.LibraryClassDefinitionsDocument;
import org.tianocore.LibraryClassDocument;
import org.tianocore.LibraryUsage;
import org.tianocore.common.DataValidation;
import org.tianocore.common.Log;
import org.tianocore.packaging.common.ui.IInternalFrame;
/**
The class is used to create, update Library Class Definition of MSA/MBD file
It extends IInternalFrame
@since ModuleEditor 1.0
**/
public class ModuleLibraryClassDefinitions extends IInternalFrame {
///
/// Define class Serial Version UID
///
private static final long serialVersionUID = -1743248695411382857L;
//
//Define class members
//
private static String Separator = "::";
private DefaultListModel listItem = new DefaultListModel();
private LibraryClassDefinitionsDocument.LibraryClassDefinitions libraryClassDefinitions = null;
private JPanel jContentPane = null;
private JRadioButton jRadioButtonAdd = null;
private JRadioButton jRadioButtonSelect = null;
private JTextField jTextFieldAdd = null;
private JComboBox jComboBoxSelect = null;
private JLabel jLabelUsage = null;
private JComboBox jComboBoxUsage = null;
private JScrollPane jScrollPane = null;
private JList jListLibraryClassDefinitions = null;
private JButton jButtonAdd = null;
private JButton jButtonRemove = null;
private JButton jButtonClearAll = null;
private JButton jButtonCancel = null;
private JButton jButtonOk = null;
/**
This method initializes jRadioButtonAdd
@return javax.swing.JRadioButton jRadioButtonAdd
**/
private JRadioButton getJRadioButtonAdd() {
if (jRadioButtonAdd == null) {
jRadioButtonAdd = new JRadioButton();
jRadioButtonAdd.setBounds(new java.awt.Rectangle(15, 35, 205, 20));
jRadioButtonAdd.setText("Add a new Library Class");
jRadioButtonAdd.addActionListener(this);
jRadioButtonAdd.setSelected(false);
}
return jRadioButtonAdd;
}
/**
This method initializes jRadioButtonSelect
@return javax.swing.JRadioButton jRadioButtonSelect
**/
private JRadioButton getJRadioButtonSelect() {
if (jRadioButtonSelect == null) {
jRadioButtonSelect = new JRadioButton();
jRadioButtonSelect.setBounds(new java.awt.Rectangle(15, 10, 205, 20));
jRadioButtonSelect.setText("Select an existed Library Class");
jRadioButtonSelect.addActionListener(this);
jRadioButtonSelect.setSelected(true);
}
return jRadioButtonSelect;
}
/**
This method initializes jTextFieldAdd
@return javax.swing.JTextField jTextFieldAdd
**/
private JTextField getJTextFieldAdd() {
if (jTextFieldAdd == null) {
jTextFieldAdd = new JTextField();
jTextFieldAdd.setBounds(new java.awt.Rectangle(220, 35, 260, 20));
jTextFieldAdd.setEnabled(false);
}
return jTextFieldAdd;
}
/**
This method initializes jComboBoxSelect
@return javax.swing.JComboBox jComboBoxSelect
**/
private JComboBox getJComboBoxSelect() {
if (jComboBoxSelect == null) {
jComboBoxSelect = new JComboBox();
jComboBoxSelect.setBounds(new java.awt.Rectangle(220, 10, 260, 20));
jComboBoxSelect.setEnabled(true);
}
return jComboBoxSelect;
}
/**
This method initializes jComboBoxUsage
@return javax.swing.JComboBox jComboBoxUsage
**/
private JComboBox getJComboBoxUsage() {
if (jComboBoxUsage == null) {
jComboBoxUsage = new JComboBox();
jComboBoxUsage.setBounds(new java.awt.Rectangle(220, 60, 260, 20));
}
return jComboBoxUsage;
}
/**
This method initializes jScrollPane
@return javax.swing.JScrollPane jScrollPane
**/
private JScrollPane getJScrollPane() {
if (jScrollPane == null) {
jScrollPane = new JScrollPane();
jScrollPane.setBounds(new java.awt.Rectangle(15, 95, 350, 200));
jScrollPane.setViewportView(getJListLibraryClassDefinitions());
}
return jScrollPane;
}
/**
This method initializes jListLibraryClassDefinitions
@return javax.swing.JList jListLibraryClassDefinitions
**/
private JList getJListLibraryClassDefinitions() {
if (jListLibraryClassDefinitions == null) {
jListLibraryClassDefinitions = new JList(listItem);
}
return jListLibraryClassDefinitions;
}
/**
This method initializes jButtonAdd
@return javax.swing.JButton jButtonAdd
**/
private JButton getJButtonAdd() {
if (jButtonAdd == null) {
jButtonAdd = new JButton();
jButtonAdd.setBounds(new java.awt.Rectangle(380, 115, 90, 20));
jButtonAdd.setText("Add");
jButtonAdd.addActionListener(this);
}
return jButtonAdd;
}
/**
This method initializes jButtonRemove
@return javax.swing.JButton jButtonRemove
**/
private JButton getJButtonRemove() {
if (jButtonRemove == null) {
jButtonRemove = new JButton();
jButtonRemove.setBounds(new java.awt.Rectangle(380, 230, 90, 20));
jButtonRemove.setText("Remove");
jButtonRemove.addActionListener(this);
}
return jButtonRemove;
}
/**
This method initializes jButtonRemoveAll
@return javax.swing.JButton jButtonClearAll
**/
private JButton getJButtonClearAll() {
if (jButtonClearAll == null) {
jButtonClearAll = new JButton();
jButtonClearAll.setBounds(new java.awt.Rectangle(380, 260, 90, 20));
jButtonClearAll.setText("Clear All");
jButtonClearAll.addActionListener(this);
}
return jButtonClearAll;
}
/**
This method initializes jButtonCancel
@return javax.swing.JButton jButtonCancel
**/
private JButton getJButtonCancel() {
if (jButtonCancel == null) {
jButtonCancel = new JButton();
jButtonCancel.setPreferredSize(new java.awt.Dimension(90, 20));
jButtonCancel.setLocation(new java.awt.Point(390, 305));
jButtonCancel.setText("Cancel");
jButtonCancel.setSize(new java.awt.Dimension(90, 20));
jButtonCancel.addActionListener(this);
}
return jButtonCancel;
}
/**
This method initializes jButtonOk
@return javax.swing.JButton jButtonOk
**/
private JButton getJButtonOk() {
if (jButtonOk == null) {
jButtonOk = new JButton();
jButtonOk.setSize(new java.awt.Dimension(90, 20));
jButtonOk.setText("OK");
jButtonOk.setLocation(new java.awt.Point(290, 305));
jButtonOk.addActionListener(this);
}
return jButtonOk;
}
public static void main(String[] args) {
}
/**
This is the default constructor
**/
public ModuleLibraryClassDefinitions() {
super();
init();
this.setVisible(true);
}
/**
This is the override edit constructor
@param inLibraryClassDefinitions The input data of LibraryClassDefinitionsDocument.LibraryClassDefinitions
**/
public ModuleLibraryClassDefinitions(
LibraryClassDefinitionsDocument.LibraryClassDefinitions inLibraryClassDefinitions) {
super();
init(inLibraryClassDefinitions);
this.setVisible(true);
}
/**
This method initializes this
Fill values to all fields if these values are not empty
@param inLibraryClassDefinitions The input data of LibraryClassDefinitionsDocument.LibraryClassDefinitions
**/
private void init(LibraryClassDefinitionsDocument.LibraryClassDefinitions inLibraryClassDefinitions) {
init();
this.setLibraryClassDefinitions(inLibraryClassDefinitions);
if (this.libraryClassDefinitions != null) {
if (this.libraryClassDefinitions.getLibraryClassList().size() > 0) {
for (int index = 0; index < this.libraryClassDefinitions.getLibraryClassList().size(); index++) {
listItem.addElement(this.libraryClassDefinitions.getLibraryClassArray(index).getUsage().toString()
+ ModuleLibraryClassDefinitions.Separator
+ this.libraryClassDefinitions.getLibraryClassArray(index).getStringValue());
this.libraryClassDefinitions.getLibraryClassList();
}
}
}
}
/**
This method initializes this
**/
private void init() {
this.setContentPane(getJContentPane());
this.setTitle("Library Class Definitions");
this.setBounds(new java.awt.Rectangle(0, 0, 500, 515));
//this.centerWindow();
initFrame();
this.setViewMode(false);
}
/**
Disable all components when the mode is view
@param isView true - The view mode; false - The non-view mode
**/
public void setViewMode(boolean isView) {
this.jButtonOk.setVisible(false);
this.jButtonCancel.setVisible(false);
if (isView) {
this.jRadioButtonAdd.setEnabled(!isView);
this.jRadioButtonSelect.setEnabled(!isView);
this.jTextFieldAdd.setEnabled(!isView);
this.jComboBoxSelect.setEnabled(!isView);
this.jComboBoxUsage.setEnabled(!isView);
this.jButtonAdd.setEnabled(!isView);
this.jButtonRemove.setEnabled(!isView);
this.jButtonClearAll.setEnabled(!isView);
this.jButtonCancel.setEnabled(!isView);
this.jButtonOk.setEnabled(!isView);
}
}
/**
This method initializes jContentPane
@return javax.swing.JPanel jContentPane
**/
private JPanel getJContentPane() {
if (jContentPane == null) {
jLabelUsage = new JLabel();
jLabelUsage.setBounds(new java.awt.Rectangle(15, 60, 205, 20));
jLabelUsage.setText("Usage");
jContentPane = new JPanel();
jContentPane.setLayout(null);
jContentPane.add(getJRadioButtonAdd(), null);
jContentPane.add(getJRadioButtonSelect(), null);
jContentPane.add(getJTextFieldAdd(), null);
jContentPane.add(getJComboBoxSelect(), null);
jContentPane.add(jLabelUsage, null);
jContentPane.add(getJComboBoxUsage(), null);
jContentPane.add(getJScrollPane(), null);
jContentPane.add(getJButtonAdd(), null);
jContentPane.add(getJButtonRemove(), null);
jContentPane.add(getJButtonClearAll(), null);
jContentPane.add(getJButtonCancel(), null);
jContentPane.add(getJButtonOk(), null);
}
return jContentPane;
}
/**
This method initializes all existing libraries and usage types
**/
private void initFrame() {
jComboBoxSelect.addItem("BaseCpuICacheFlush");
jComboBoxSelect.addItem("BaseDebugLibNull");
jComboBoxSelect.addItem("BaseDebugLibReportStatusCode");
jComboBoxSelect.addItem("BaseIoLibIntrinsic");
jComboBoxSelect.addItem("BaseLib");
jComboBoxSelect.addItem("BaseMemoryLib");
jComboBoxSelect.addItem("BaseMemoryLibMmx");
jComboBoxSelect.addItem("BaseMemoryLibSse2");
jComboBoxSelect.addItem("BasePeCoffGetEntryPointLib");
jComboBoxSelect.addItem("BasePeCoffLib");
jComboBoxSelect.addItem("BasePrintLib");
jComboBoxSelect.addItem("BaseReportStatusCodeLibNull");
jComboBoxSelect.addItem("CommonPciCf8Lib");
jComboBoxSelect.addItem("CommonPciExpressLib");
jComboBoxSelect.addItem("CommonPciLibCf8");
jComboBoxSelect.addItem("CommonPciLibPciExpress");
jComboBoxSelect.addItem("DxeCoreEntryPoint");
jComboBoxSelect.addItem("DxeHobLib");
jComboBoxSelect.addItem("DxeIoLibCpuIo");
jComboBoxSelect.addItem("DxeLib");
jComboBoxSelect.addItem("DxePcdLib");
jComboBoxSelect.addItem("DxeReportStatusCodeLib");
jComboBoxSelect.addItem("DxeServicesTableLib");
jComboBoxSelect.addItem("PeiCoreEntryPoint");
jComboBoxSelect.addItem("PeiMemoryLib");
jComboBoxSelect.addItem("PeimEntryPoint");
jComboBoxSelect.addItem("PeiReportStatusCodeLib");
jComboBoxSelect.addItem("PeiServicesTablePointerLib");
jComboBoxSelect.addItem("PeiServicesTablePointerLibMm7");
jComboBoxSelect.addItem("UefiDebugLibConOut");
jComboBoxSelect.addItem("UefiDebugLibStdErr");
jComboBoxSelect.addItem("UefiDriverEntryPointMultiple");
jComboBoxSelect.addItem("UefiDriverEntryPointSingle");
jComboBoxSelect.addItem("UefiDriverEntryPointSingleUnload");
jComboBoxSelect.addItem("UefiDriverModelLib");
jComboBoxSelect.addItem("UefiDriverModelLibNoConfigNoDiag");
jComboBoxSelect.addItem("UefiLib");
jComboBoxSelect.addItem("UefiMemoryLib");
jComboBoxUsage.addItem("ALWAYS_CONSUMED");
jComboBoxUsage.addItem("SOMETIMES_CONSUMED");
jComboBoxUsage.addItem("ALWAYS_PRODUCED");
jComboBoxUsage.addItem("SOMETIMES_PRODUCED");
jComboBoxUsage.addItem("DEFAULT");
jComboBoxUsage.addItem("PRIVATE");
}
/* (non-Javadoc)
* @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
*
* Override actionPerformed to listen all actions
*
*/
public void actionPerformed(ActionEvent arg0) {
if (arg0.getSource() == jButtonOk) {
this.dispose();
this.setEdited(true);
this.save();
}
if (arg0.getSource() == jButtonCancel) {
this.dispose();
this.setEdited(false);
}
//
// Add current Library and its usage to the list
//
if (arg0.getSource() == jButtonAdd) {
if (!checkAdd()) {
return;
}
String strLibClass = "";
String strUsage = "";
if (jRadioButtonAdd.isSelected()) {
strLibClass = jTextFieldAdd.getText();
}
if (jRadioButtonSelect.isSelected()) {
strLibClass = jComboBoxSelect.getSelectedItem().toString();
}
strUsage = jComboBoxUsage.getSelectedItem().toString();
listItem.addElement(strUsage + ModuleLibraryClassDefinitions.Separator + strLibClass);
}
//
// Remove current Library and its usage of the list
//
if (arg0.getSource() == jButtonRemove) {
int intSelected[] = jListLibraryClassDefinitions.getSelectedIndices();
if (intSelected.length > 0) {
for (int index = intSelected.length - 1; index > -1; index--) {
listItem.removeElementAt(intSelected[index]);
}
}
jListLibraryClassDefinitions.getSelectionModel().clearSelection();
}
if (arg0.getSource() == jButtonClearAll) {
listItem.removeAllElements();
}
//
// Contorl the selected status when click RadionButton
// Do not use Radio Button Group
//
if (arg0.getSource() == jRadioButtonAdd) {
if (jRadioButtonAdd.isSelected()) {
jRadioButtonSelect.setSelected(false);
jTextFieldAdd.setEnabled(true);
jComboBoxSelect.setEnabled(false);
}
if (!jRadioButtonSelect.isSelected() && !jRadioButtonAdd.isSelected()) {
jRadioButtonAdd.setSelected(true);
jTextFieldAdd.setEnabled(true);
jComboBoxSelect.setEnabled(false);
}
}
if (arg0.getSource() == jRadioButtonSelect) {
if (jRadioButtonSelect.isSelected()) {
jRadioButtonAdd.setSelected(false);
jTextFieldAdd.setEnabled(false);
jComboBoxSelect.setEnabled(true);
}
if (!jRadioButtonSelect.isSelected() && !jRadioButtonAdd.isSelected()) {
jRadioButtonSelect.setSelected(true);
jTextFieldAdd.setEnabled(false);
jComboBoxSelect.setEnabled(true);
}
}
}
/**
Data validation for all fields
@retval true - All datas are valid
@retval false - At least one data is invalid
**/
public boolean check() {
if (listItem.getSize() < 1) {
Log.err("Must have one Library Class at least!");
return false;
}
return true;
}
/**
Data validation for all fields
@retval true - All datas are valid
@retval false - At least one data is invalid
**/
public boolean checkAdd() {
//
// Check if all required fields are not empty
//
if (this.jRadioButtonAdd.isSelected() && isEmpty(this.jTextFieldAdd.getText())) {
Log.err("Library Class couldn't be empty");
return false;
}
//
// Check if all fields have correct data types
//
if (this.jRadioButtonAdd.isSelected() && !DataValidation.isLibraryClass(this.jTextFieldAdd.getText())) {
Log.err("Incorrect data type for Library Class");
return false;
}
return true;
}
/**
Save all components of Mbd Header
if exists mbdHeader, set the value directly
if not exists mbdHeader, new an instance first
**/
public void save() {
try {
int intLibraryCount = listItem.getSize();
if (this.libraryClassDefinitions == null) {
libraryClassDefinitions = LibraryClassDefinitionsDocument.LibraryClassDefinitions.Factory.newInstance();
}
if (intLibraryCount > 0) {
LibraryClassDocument.LibraryClass mLibraryClass = LibraryClassDocument.LibraryClass.Factory
.newInstance();
for (int index = this.libraryClassDefinitions.getLibraryClassList().size() - 1; index > -1; index--) {
this.libraryClassDefinitions.removeLibraryClass(index);
}
for (int index = 0; index < intLibraryCount; index++) {
String strAll = listItem.get(index).toString();
String strUsage = strAll.substring(0, strAll.indexOf(ModuleLibraryClassDefinitions.Separator));
String strLibraryClass = strAll.substring(strAll.indexOf(ModuleLibraryClassDefinitions.Separator)
+ ModuleLibraryClassDefinitions.Separator.length());
mLibraryClass.setStringValue(strLibraryClass);
mLibraryClass.setUsage(LibraryUsage.Enum.forString(strUsage));
this.libraryClassDefinitions.addNewLibraryClass();
this.libraryClassDefinitions.setLibraryClassArray(index, mLibraryClass);
}
} else {
this.libraryClassDefinitions.setNil();
}
} catch (Exception e) {
Log.err("Update Library Class Definitions", e.getMessage());
}
}
/**
Get LibraryClassDefinitionsDocument.LibraryClassDefinitions
@return
**/
public LibraryClassDefinitionsDocument.LibraryClassDefinitions getLibraryClassDefinitions() {
return libraryClassDefinitions;
}
/**
Set LibraryClassDefinitionsDocument.LibraryClassDefinitions
@param libraryClassDefinitions The input data of LibraryClassDefinitionsDocument.LibraryClassDefinitions
**/
public void setLibraryClassDefinitions(
LibraryClassDefinitionsDocument.LibraryClassDefinitions libraryClassDefinitions) {
this.libraryClassDefinitions = libraryClassDefinitions;
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,519 @@
/** @file
The file is used to create, update PCD of MSA/MBD file
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.packaging.module.ui;
import java.awt.event.ActionEvent;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import org.tianocore.PCDsDocument;
import org.tianocore.PcdDataTypes;
import org.tianocore.PcdItemTypes;
import org.tianocore.PcdUsage;
import org.tianocore.common.DataValidation;
import org.tianocore.common.Log;
import org.tianocore.packaging.common.ui.IInternalFrame;
import org.tianocore.packaging.common.ui.StarLabel;
/**
The class is used to create, update PCD of MSA/MBD file
It extends IInternalFrame
@since ModuleEditor 1.0
**/
public class ModulePCDs extends IInternalFrame {
///
/// Define class Serial Version UID
///
private static final long serialVersionUID = 2227717658188438696L;
//
//Define class members
//
private PCDsDocument.PCDs pcds = null;
private int location = -1;
private JPanel jContentPane = null;
private JLabel jLabelItemType = null;
private JLabel jLabelC_Name = null;
private JComboBox jComboBoxItemType = null;
private JTextField jTextFieldC_Name = null;
private JLabel jLabelToken = null;
private JTextField jTextFieldToken = null;
private JLabel jLabelDefaultValue = null;
private JTextField jTextFieldDefaultValue = null;
private JLabel jLabelUsage = null;
private JComboBox jComboBoxUsage = null;
private JButton jButtonOk = null;
private JButton jButtonCancel = null;
private JLabel jLabelDatumType = null;
private JComboBox jComboBoxDatumType = null;
private StarLabel jStarLabel1 = null;
private StarLabel jStarLabel2 = null;
private StarLabel jStarLabel3 = null;
private StarLabel jStarLabel4 = null;
/**
This method initializes jComboBoxItemType
@return javax.swing.JComboBox jComboBoxItemType
**/
private JComboBox getJComboBoxItemType() {
if (jComboBoxItemType == null) {
jComboBoxItemType = new JComboBox();
jComboBoxItemType.setBounds(new java.awt.Rectangle(160, 110, 320, 20));
}
return jComboBoxItemType;
}
/**
This method initializes jTextFieldC_Name
@return javax.swing.JTextField jTextFieldC_Name
**/
private JTextField getJTextFieldC_Name() {
if (jTextFieldC_Name == null) {
jTextFieldC_Name = new JTextField();
jTextFieldC_Name.setBounds(new java.awt.Rectangle(160, 10, 320, 20));
}
return jTextFieldC_Name;
}
/**
This method initializes jTextFieldToken
@return javax.swing.JTextField jTextFieldToken
**/
private JTextField getJTextFieldToken() {
if (jTextFieldToken == null) {
jTextFieldToken = new JTextField();
jTextFieldToken.setBounds(new java.awt.Rectangle(160, 35, 320, 20));
}
return jTextFieldToken;
}
/**
This method initializes jTextFieldDefaultValue
@return javax.swing.JTextField jTextFieldDefaultValue
**/
private JTextField getJTextFieldDefaultValue() {
if (jTextFieldDefaultValue == null) {
jTextFieldDefaultValue = new JTextField();
jTextFieldDefaultValue.setBounds(new java.awt.Rectangle(160, 85, 320, 20));
}
return jTextFieldDefaultValue;
}
/**
This method initializes jComboBoxUsage
@return javax.swing.JComboBox jComboBoxUsage
**/
private JComboBox getJComboBoxUsage() {
if (jComboBoxUsage == null) {
jComboBoxUsage = new JComboBox();
jComboBoxUsage.setBounds(new java.awt.Rectangle(160, 135, 320, 20));
}
return jComboBoxUsage;
}
/**
This method initializes jButtonOk
@return javax.swing.JButton jButtonOk
**/
private JButton getJButtonOk() {
if (jButtonOk == null) {
jButtonOk = new JButton();
jButtonOk.setText("OK");
jButtonOk.setBounds(new java.awt.Rectangle(280, 290, 90, 20));
jButtonOk.addActionListener(this);
}
return jButtonOk;
}
/**
This method initializes jButtonCancel
@return javax.swing.JButton jButtonCancel
**/
private JButton getJButtonCancel() {
if (jButtonCancel == null) {
jButtonCancel = new JButton();
jButtonCancel.setText("Cancel");
jButtonCancel.setBounds(new java.awt.Rectangle(390, 290, 90, 20));
jButtonCancel.addActionListener(this);
}
return jButtonCancel;
}
/**
This method initializes jTextFieldDatumType
@return javax.swing.JTextField jComboBoxDatumType
**/
private JComboBox getJComboBoxDatumType() {
if (jComboBoxDatumType == null) {
jComboBoxDatumType = new JComboBox();
jComboBoxDatumType.setBounds(new java.awt.Rectangle(160, 60, 320, 20));
}
return jComboBoxDatumType;
}
public static void main(String[] args) {
}
/**
This is the default constructor
**/
public ModulePCDs() {
super();
init();
this.setVisible(true);
}
/**
This is the override edit constructor
@param inPcds The input data of PCDsDocument.PCDs
**/
public ModulePCDs(PCDsDocument.PCDs inPcds) {
super();
init(inPcds);
this.setVisible(true);
}
/**
This is the override edit constructor
@param inPcds The input data of PCDsDocument.PCDs
@param type The input data of node type
@param index The input data of node index
**/
public ModulePCDs(PCDsDocument.PCDs inPcds, int type, int index) {
super();
init(inPcds, type, index);
this.setVisible(true);
}
/**
This method initializes this
@param inPcds The input data of PCDsDocument.PCDs
**/
private void init(PCDsDocument.PCDs inPcds) {
init();
this.setPcds(inPcds);
}
/**
This method initializes this
Fill values to all fields if these values are not empty
@param inPcds The input data of PCDsDocument.PCDs
@param type The input data of node type
@param index The input data of node index
**/
private void init(PCDsDocument.PCDs inPcds, int type, int index) {
init(inPcds);
this.location = index;
if (this.pcds.getPcdDataList().size() > 0) {
if (this.pcds.getPcdDataArray(index).getCName() != null) {
this.jTextFieldC_Name.setText(this.pcds.getPcdDataArray(index).getCName());
}
if (this.pcds.getPcdDataArray(index).getToken() != null) {
this.jTextFieldToken.setText(this.pcds.getPcdDataArray(index).getToken());
}
if (this.pcds.getPcdDataArray(index).getDatumType() != null) {
this.jComboBoxDatumType.setSelectedItem(this.pcds.getPcdDataArray(index).getDatumType().toString());
}
if (this.pcds.getPcdDataArray(index).getDefaultValue() != null) {
this.jTextFieldDefaultValue.setText(this.pcds.getPcdDataArray(index).getDefaultValue());
}
if (this.pcds.getPcdDataArray(index).getPcdUsage() != null) {
this.jComboBoxUsage.setSelectedItem(this.pcds.getPcdDataArray(index).getPcdUsage().toString());
}
if (this.pcds.getPcdDataArray(index).getItemType() != null) {
this.jComboBoxItemType.setSelectedItem(this.pcds.getPcdDataArray(index).getItemType().toString());
}
}
}
/**
This method initializes this
**/
private void init() {
this.setSize(500, 515);
this.setContentPane(getJContentPane());
this.setTitle("PCDs");
initFrame();
this.setViewMode(false);
}
/**
Disable all components when the mode is view
@param isView true - The view mode; false - The non-view mode
**/
public void setViewMode(boolean isView) {
this.jButtonOk.setVisible(false);
this.jButtonCancel.setVisible(false);
if (isView) {
this.jTextFieldC_Name.setEnabled(!isView);
this.jTextFieldToken.setEnabled(!isView);
this.jComboBoxDatumType.setEnabled(!isView);
this.jTextFieldDefaultValue.setEnabled(!isView);
this.jComboBoxUsage.setEnabled(!isView);
this.jComboBoxItemType.setEnabled(!isView);
}
}
/**
This method initializes jContentPane
@return javax.swing.JPanel jContentPane
**/
private JPanel getJContentPane() {
if (jContentPane == null) {
jLabelDatumType = new JLabel();
jLabelDatumType.setBounds(new java.awt.Rectangle(15, 60, 140, 20));
jLabelDatumType.setText("Datum Type");
jLabelC_Name = new JLabel();
jLabelC_Name.setText("C_Name");
jLabelC_Name.setBounds(new java.awt.Rectangle(15, 10, 140, 20));
jLabelUsage = new JLabel();
jLabelUsage.setText("Usage");
jLabelUsage.setBounds(new java.awt.Rectangle(15, 135, 140, 20));
jLabelDefaultValue = new JLabel();
jLabelDefaultValue.setText("Default Value");
jLabelDefaultValue.setBounds(new java.awt.Rectangle(15, 85, 140, 20));
jLabelToken = new JLabel();
jLabelToken.setText("Token");
jLabelToken.setBounds(new java.awt.Rectangle(15, 35, 140, 20));
jLabelItemType = new JLabel();
jLabelItemType.setText("Item Type");
jLabelItemType.setBounds(new java.awt.Rectangle(15, 110, 140, 20));
jContentPane = new JPanel();
jContentPane.setLayout(null);
jContentPane.setSize(new java.awt.Dimension(480,336));
jContentPane.add(jLabelItemType, null);
jContentPane.add(jLabelC_Name, null);
jContentPane.add(getJTextFieldC_Name(), null);
jContentPane.add(jLabelToken, null);
jContentPane.add(getJTextFieldToken(), null);
jContentPane.add(jLabelDefaultValue, null);
jContentPane.add(getJTextFieldDefaultValue(), null);
jContentPane.add(jLabelUsage, null);
jContentPane.add(getJComboBoxUsage(), null);
jContentPane.add(getJButtonOk(), null);
jContentPane.add(getJButtonCancel(), null);
jContentPane.add(getJComboBoxItemType(), null);
jContentPane.add(jLabelDatumType, null);
jContentPane.add(getJComboBoxDatumType(), null);
jStarLabel1 = new StarLabel();
jStarLabel1.setLocation(new java.awt.Point(0, 10));
jStarLabel2 = new StarLabel();
jStarLabel2.setLocation(new java.awt.Point(0, 35));
jStarLabel3 = new StarLabel();
jStarLabel3.setLocation(new java.awt.Point(0, 60));
jStarLabel4 = new StarLabel();
jStarLabel4.setLocation(new java.awt.Point(0, 110));
jContentPane.add(jStarLabel1, null);
jContentPane.add(jStarLabel2, null);
jContentPane.add(jStarLabel3, null);
jContentPane.add(jStarLabel4, null);
}
return jContentPane;
}
/**
This method initializes Usage type, Item type and Datum type
**/
private void initFrame() {
jComboBoxUsage.addItem("ALWAYS_CONSUMED");
jComboBoxUsage.addItem("SOMETIMES_CONSUMED");
jComboBoxUsage.addItem("ALWAYS_PRODUCED");
jComboBoxUsage.addItem("SOMETIMES_PRODUCED");
jComboBoxUsage.addItem("DEFAULT");
jComboBoxItemType.addItem("FEATURE_FLAG");
jComboBoxItemType.addItem("FIXED_AT_BUILD");
jComboBoxItemType.addItem("PATCHABLE_IN_MODULE");
jComboBoxItemType.addItem("DYNAMIC");
jComboBoxItemType.addItem("DYNAMIC_EX");
jComboBoxDatumType.addItem("UINT8");
jComboBoxDatumType.addItem("UINT16");
jComboBoxDatumType.addItem("UINT32");
jComboBoxDatumType.addItem("UINT64");
jComboBoxDatumType.addItem("VOID*");
jComboBoxDatumType.addItem("BOOLEAN");
}
/* (non-Javadoc)
* @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
*
* Override actionPerformed to listen all actions
*
*/
public void actionPerformed(ActionEvent arg0) {
if (arg0.getSource() == jButtonOk) {
this.setEdited(true);
this.save();
this.dispose();
}
if (arg0.getSource() == jButtonCancel) {
this.dispose();
}
}
/**
Get PCDsDocument.PCDs
@return PCDsDocument.PCDs
**/
public PCDsDocument.PCDs getPcds() {
return pcds;
}
/**
Set PCDsDocument.PCDs
@param pcds The input data of PCDsDocument.PCDs
**/
public void setPcds(PCDsDocument.PCDs pcds) {
this.pcds = pcds;
}
/**
Data validation for all fields
@retval true - All datas are valid
@retval false - At least one data is invalid
**/
public boolean check() {
//
// Check if all required fields are not empty
//
if (isEmpty(this.jTextFieldC_Name.getText())) {
Log.err("C_Name couldn't be empty");
return false;
}
if (isEmpty(this.jTextFieldToken.getText())) {
Log.err("Token couldn't be empty");
return false;
}
//
// Check if all fields have correct data types
//
if (!isEmpty(this.jTextFieldC_Name.getText()) && !DataValidation.isCName(this.jTextFieldC_Name.getText())) {
Log.err("Incorrect data type for C_Name");
return false;
}
if (!isEmpty(this.jTextFieldToken.getText()) && !DataValidation.isToken(this.jTextFieldToken.getText())) {
Log.err("Incorrect data type for Token");
return false;
}
return true;
}
/**
Save all components of PCDs
if exists pcds, set the value directly
if not exists pcds, new an instance first
**/
public void save() {
try {
if (this.pcds == null) {
pcds = PCDsDocument.PCDs.Factory.newInstance();
}
PCDsDocument.PCDs.PcdData pcdData = PCDsDocument.PCDs.PcdData.Factory.newInstance();
if (!isEmpty(this.jTextFieldC_Name.getText())) {
pcdData.setCName(this.jTextFieldC_Name.getText());
}
if (!isEmpty(this.jTextFieldToken.getText())) {
pcdData.setToken(this.jTextFieldToken.getText());
}
pcdData.setDatumType(PcdDataTypes.Enum.forString(this.jComboBoxDatumType.getSelectedItem().toString()));
if (!isEmpty(this.jTextFieldDefaultValue.getText())) {
pcdData.setDefaultValue(this.jTextFieldDefaultValue.getText());
}
pcdData.setItemType(PcdItemTypes.Enum.forString(this.jComboBoxItemType.getSelectedItem().toString()));
pcdData.setPcdUsage(PcdUsage.Enum.forString(this.jComboBoxUsage.getSelectedItem().toString()));
if (location > -1) {
pcds.setPcdDataArray(location, pcdData);
} else {
pcds.addNewPcdData();
pcds.setPcdDataArray(pcds.getPcdDataList().size() - 1, pcdData);
}
} catch (Exception e) {
Log.err("Update Hobs", e.getMessage());
}
}
}

View File

@ -0,0 +1,711 @@
/** @file
The file is used to create, update Ppi of MSA/MBD file
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.packaging.module.ui;
import java.awt.event.ActionEvent;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.JTextField;
import org.tianocore.PPIsDocument;
import org.tianocore.PpiNotifyUsage;
import org.tianocore.PpiUsage;
import org.tianocore.common.DataValidation;
import org.tianocore.common.Log;
import org.tianocore.common.Tools;
import org.tianocore.packaging.common.ui.IDefaultMutableTreeNode;
import org.tianocore.packaging.common.ui.IInternalFrame;
import org.tianocore.packaging.common.ui.StarLabel;
/**
The class is used to create, update Ppi of MSA/MBD file
It extends IInternalFrame
@since ModuleEditor 1.0
**/
public class ModulePpis extends IInternalFrame {
///
/// Define class Serial Version UID
///
private static final long serialVersionUID = -4284901202357037724L;
//
//Define class members
//
private PPIsDocument.PPIs ppis = null;
private int location = -1;
private static int PPI = 1;
private static int PPI_NOTIFY = 2;
private JPanel jContentPane = null;
private JRadioButton jRadioButtonPpi = null;
private JRadioButton jRadioButtonPpiNotify = null;
private JLabel jLabelC_Name = null;
private JTextField jTextFieldC_Name = null;
private JLabel jLabelGuid = null;
private JTextField jTextFieldGuid = null;
private JTextField jTextFieldFeatureFlag = null;
private JLabel jLabelFeatureFlag = null;
private JLabel jLabelUsage = null;
private JComboBox jComboBoxUsage = null;
private JLabel jLabelEnableFeature = null;
private JRadioButton jRadioButtonEnableFeature = null;
private JRadioButton jRadioButtonDisableFeature = null;
private JButton jButtonOk = null;
private JButton jButtonCancel = null;
private JLabel jLabelPpiType = null;
private JButton jButtonGenerateGuid = null;
private StarLabel jStarLabel1 = null;
private StarLabel jStarLabel2 = null;
private JLabel jLabelOverrideID = null;
private JTextField jTextFieldOverrideID = null;
/**
This method initializes jRadioButtonPpi
@return javax.swing.JRadioButton jRadioButtonPpi
**/
private JRadioButton getJRadioButtonPpiType() {
if (jRadioButtonPpi == null) {
jRadioButtonPpi = new JRadioButton();
jRadioButtonPpi.setText("Ppi");
jRadioButtonPpi.setBounds(new java.awt.Rectangle(160, 10, 100, 20));
jRadioButtonPpi.addActionListener(this);
jRadioButtonPpi.setSelected(true);
}
return jRadioButtonPpi;
}
/**
This method initializes jRadioButtonPpiNotify
@return javax.swing.JRadioButton jRadioButtonPpiNotify
**/
private JRadioButton getJRadioButtonPpiNotify() {
if (jRadioButtonPpiNotify == null) {
jRadioButtonPpiNotify = new JRadioButton();
jRadioButtonPpiNotify.setText("Ppi Notify");
jRadioButtonPpiNotify.setBounds(new java.awt.Rectangle(320, 10, 100, 20));
jRadioButtonPpiNotify.addActionListener(this);
}
return jRadioButtonPpiNotify;
}
/**
This method initializes jTextFieldC_Name
@return javax.swing.JTextField jTextFieldC_Name
**/
private JTextField getJTextFieldC_Name() {
if (jTextFieldC_Name == null) {
jTextFieldC_Name = new JTextField();
jTextFieldC_Name.setBounds(new java.awt.Rectangle(160, 35, 320, 20));
}
return jTextFieldC_Name;
}
/**
This method initializes jTextFieldGuid
@return javax.swing.JTextField jTextFieldGuid
**/
private JTextField getJTextFieldGuid() {
if (jTextFieldGuid == null) {
jTextFieldGuid = new JTextField();
jTextFieldGuid.setBounds(new java.awt.Rectangle(160, 60, 240, 20));
}
return jTextFieldGuid;
}
/**
This method initializes jTextFieldFeatureFlag
@return javax.swing.JTextField jTextFieldFeatureFlag
**/
private JTextField getJTextFieldFeatureFlag() {
if (jTextFieldFeatureFlag == null) {
jTextFieldFeatureFlag = new JTextField();
jTextFieldFeatureFlag.setBounds(new java.awt.Rectangle(160, 135, 320, 20));
}
return jTextFieldFeatureFlag;
}
/**
This method initializes jComboBox
@return javax.swing.JComboBox jComboBoxUsage
**/
private JComboBox getJComboBox() {
if (jComboBoxUsage == null) {
jComboBoxUsage = new JComboBox();
jComboBoxUsage.setBounds(new java.awt.Rectangle(160, 85, 320, 20));
}
return jComboBoxUsage;
}
/**
This method initializes jRadioButtonEnableFeature
@return javax.swing.JRadioButton jRadioButtonEnableFeature
**/
private JRadioButton getJRadioButtonEnableFeature() {
if (jRadioButtonEnableFeature == null) {
jRadioButtonEnableFeature = new JRadioButton();
jRadioButtonEnableFeature.setText("Enable");
jRadioButtonEnableFeature.setBounds(new java.awt.Rectangle(160, 110, 90, 20));
jRadioButtonEnableFeature.addActionListener(this);
jRadioButtonEnableFeature.setSelected(true);
}
return jRadioButtonEnableFeature;
}
/**
This method initializes jRadioButtonDisableFeature
@return javax.swing.JRadioButton jRadioButtonDisableFeature
**/
private JRadioButton getJRadioButtonDisableFeature() {
if (jRadioButtonDisableFeature == null) {
jRadioButtonDisableFeature = new JRadioButton();
jRadioButtonDisableFeature.setText("Disable");
jRadioButtonDisableFeature.setBounds(new java.awt.Rectangle(320, 110, 90, 20));
jRadioButtonDisableFeature.addActionListener(this);
}
return jRadioButtonDisableFeature;
}
/**
This method initializes jButtonOk
@return javax.swing.JButton jButtonOk
**/
private JButton getJButtonOk() {
if (jButtonOk == null) {
jButtonOk = new JButton();
jButtonOk.setText("OK");
jButtonOk.setBounds(new java.awt.Rectangle(290, 190, 90, 20));
jButtonOk.addActionListener(this);
}
return jButtonOk;
}
/**
This method initializes jButtonCancel
@return javax.swing.JButton jButtonCancel
**/
private JButton getJButtonCancel() {
if (jButtonCancel == null) {
jButtonCancel = new JButton();
jButtonCancel.setText("Cancel");
jButtonCancel.setBounds(new java.awt.Rectangle(390, 190, 90, 20));
jButtonCancel.addActionListener(this);
}
return jButtonCancel;
}
/**
This method initializes jButtonGenerateGuid
@return javax.swing.JButton jButtonGenerateGuid
**/
private JButton getJButtonGenerateGuid() {
if (jButtonGenerateGuid == null) {
jButtonGenerateGuid = new JButton();
jButtonGenerateGuid.setBounds(new java.awt.Rectangle(405, 60, 75, 20));
jButtonGenerateGuid.setText("GEN");
jButtonGenerateGuid.addActionListener(this);
}
return jButtonGenerateGuid;
}
/**
This method initializes jTextFieldOverrideID
@return javax.swing.JTextField jTextFieldOverrideID
**/
private JTextField getJTextFieldOverrideID() {
if (jTextFieldOverrideID == null) {
jTextFieldOverrideID = new JTextField();
jTextFieldOverrideID.setBounds(new java.awt.Rectangle(160, 160, 320, 20));
}
return jTextFieldOverrideID;
}
public static void main(String[] args) {
}
/**
This is the default constructor
**/
public ModulePpis() {
super();
init();
this.setVisible(true);
}
/**
This is the override edit constructor
@param inPpis The input data of PPIsDocument.PPIs
**/
public ModulePpis(PPIsDocument.PPIs inPpis) {
super();
init(inPpis);
this.setVisible(true);
}
/**
This is the override edit constructor
@param inPpis The input data of PPIsDocument.PPIs
@param type The input data of node type
@param index The input data of node index
**/
public ModulePpis(PPIsDocument.PPIs inPpis, int type, int index) {
super();
init(inPpis, type, index);
this.setVisible(true);
}
/**
This method initializes this
@param inPpis The input data of PPIsDocument.PPIs
**/
private void init(PPIsDocument.PPIs inPpis) {
init();
this.setPpis(inPpis);
}
/**
This method initializes this
Fill values to all fields if these values are not empty
@param inPpis The input data of PPIsDocument.PPIs
@param type The input data of node type
@param index The input data of node index
**/
private void init(PPIsDocument.PPIs inPpis, int type, int index) {
init(inPpis);
this.location = index;
if (type == IDefaultMutableTreeNode.PPIS_PPI_ITEM) {
initUsage(ModulePpis.PPI);
this.jRadioButtonPpi.setSelected(true);
this.jRadioButtonPpiNotify.setSelected(false);
if (this.ppis.getPpiArray(index).getStringValue() != null) {
this.jTextFieldC_Name.setText(this.ppis.getPpiArray(index).getStringValue());
}
if (this.ppis.getPpiArray(index).getGuid() != null) {
this.jTextFieldGuid.setText(this.ppis.getPpiArray(index).getGuid());
}
if (this.ppis.getPpiArray(index).getUsage() != null) {
this.jComboBoxUsage.setSelectedItem(this.ppis.getPpiArray(index).getUsage().toString());
}
this.jRadioButtonEnableFeature.setSelected(this.ppis.getPpiArray(index).getEnableFeature());
this.jRadioButtonDisableFeature.setSelected(!this.ppis.getPpiArray(index).getEnableFeature());
if (this.ppis.getPpiArray(index).getFeatureFlag() != null) {
this.jTextFieldFeatureFlag.setText(this.ppis.getPpiArray(index).getFeatureFlag());
}
this.jTextFieldOverrideID.setText(String.valueOf(this.ppis.getPpiArray(index).getOverrideID()));
} else if (type == IDefaultMutableTreeNode.PPIS_PPINOTIFY_ITEM) {
initUsage(ModulePpis.PPI_NOTIFY);
this.jRadioButtonPpi.setSelected(false);
this.jRadioButtonPpiNotify.setSelected(true);
if (this.ppis.getPpiNotifyArray(index).getStringValue() != null) {
this.jTextFieldC_Name.setText(this.ppis.getPpiNotifyArray(index).getStringValue());
}
if (this.ppis.getPpiNotifyArray(index).getGuid() != null) {
this.jTextFieldGuid.setText(this.ppis.getPpiNotifyArray(index).getGuid());
}
if (this.ppis.getPpiNotifyArray(index).getUsage() != null) {
this.jComboBoxUsage.setSelectedItem(this.ppis.getPpiNotifyArray(index).getUsage().toString());
}
this.jRadioButtonEnableFeature.setSelected(this.ppis.getPpiNotifyArray(index).getEnableFeature());
this.jRadioButtonDisableFeature.setSelected(!this.ppis.getPpiNotifyArray(index).getEnableFeature());
if (this.ppis.getPpiNotifyArray(index).getFeatureFlag() != null) {
this.jTextFieldFeatureFlag.setText(this.ppis.getPpiNotifyArray(index).getFeatureFlag());
}
this.jTextFieldOverrideID.setText(String.valueOf(this.ppis.getPpiNotifyArray(index).getOverrideID()));
}
this.jRadioButtonPpi.setEnabled(false);
this.jRadioButtonPpiNotify.setEnabled(false);
}
/**
This method initializes this
**/
private void init() {
this.setContentPane(getJContentPane());
this.setTitle("Ppis");
this.setBounds(new java.awt.Rectangle(0, 0, 500, 515));
initFrame();
this.setViewMode(false);
}
/**
Disable all components when the mode is view
@param isView true - The view mode; false - The non-view mode
**/
public void setViewMode(boolean isView) {
this.jButtonOk.setVisible(false);
this.jButtonCancel.setVisible(false);
if (isView) {
this.jRadioButtonPpi.setEnabled(!isView);
this.jRadioButtonPpiNotify.setEnabled(!isView);
this.jTextFieldC_Name.setEnabled(!isView);
this.jTextFieldGuid.setEnabled(!isView);
this.jComboBoxUsage.setEnabled(!isView);
this.jRadioButtonEnableFeature.setEnabled(!isView);
this.jRadioButtonDisableFeature.setEnabled(!isView);
this.jTextFieldFeatureFlag.setEnabled(!isView);
this.jTextFieldOverrideID.setEnabled(!isView);
this.jButtonGenerateGuid.setEnabled(!isView);
}
}
/**
This method initializes jContentPane
@return javax.swing.JPanel jContentPane
**/
private JPanel getJContentPane() {
if (jContentPane == null) {
jLabelOverrideID = new JLabel();
jLabelOverrideID.setBounds(new java.awt.Rectangle(15, 160, 140, 20));
jLabelOverrideID.setText("Override ID");
jLabelPpiType = new JLabel();
jLabelPpiType.setBounds(new java.awt.Rectangle(15, 10, 140, 20));
jLabelPpiType.setText("Ppi Type");
jLabelEnableFeature = new JLabel();
jLabelEnableFeature.setText("Enable Feature");
jLabelEnableFeature.setBounds(new java.awt.Rectangle(15, 110, 140, 20));
jLabelUsage = new JLabel();
jLabelUsage.setText("Usage");
jLabelUsage.setBounds(new java.awt.Rectangle(15, 85, 140, 20));
jLabelFeatureFlag = new JLabel();
jLabelFeatureFlag.setText("Feature Flag");
jLabelFeatureFlag.setBounds(new java.awt.Rectangle(15, 135, 140, 20));
jLabelGuid = new JLabel();
jLabelGuid.setText("Guid");
jLabelGuid.setBounds(new java.awt.Rectangle(15, 60, 140, 20));
jLabelC_Name = new JLabel();
jLabelC_Name.setText("C_Name");
jLabelC_Name.setBounds(new java.awt.Rectangle(15, 35, 140, 20));
jContentPane = new JPanel();
jContentPane.setLayout(null);
jContentPane.add(getJRadioButtonPpiType(), null);
jContentPane.add(jLabelC_Name, null);
jContentPane.add(getJTextFieldC_Name(), null);
jContentPane.add(jLabelGuid, null);
jContentPane.add(getJTextFieldGuid(), null);
jContentPane.add(getJTextFieldFeatureFlag(), null);
jContentPane.add(jLabelFeatureFlag, null);
jContentPane.add(jLabelUsage, null);
jContentPane.add(getJComboBox(), null);
jContentPane.add(jLabelEnableFeature, null);
jContentPane.add(getJRadioButtonEnableFeature(), null);
jContentPane.add(getJRadioButtonDisableFeature(), null);
jContentPane.add(getJButtonOk(), null);
jContentPane.add(getJButtonCancel(), null);
jContentPane.add(getJRadioButtonPpiNotify(), null);
jContentPane.add(jLabelPpiType, null);
jContentPane.add(getJButtonGenerateGuid(), null);
jStarLabel1 = new StarLabel();
jStarLabel1.setBounds(new java.awt.Rectangle(0, 10, 10, 20));
jStarLabel2 = new StarLabel();
jStarLabel2.setBounds(new java.awt.Rectangle(0, 35, 10, 20));
jContentPane.add(jStarLabel1, null);
jContentPane.add(jStarLabel2, null);
jContentPane.add(jLabelOverrideID, null);
jContentPane.add(getJTextFieldOverrideID(), null);
}
return jContentPane;
}
/**
This method initializes Usage type
**/
private void initFrame() {
jComboBoxUsage.addItem("ALWAYS_CONSUMED");
jComboBoxUsage.addItem("SOMETIMES_CONSUMED");
jComboBoxUsage.addItem("ALWAYS_PRODUCED");
jComboBoxUsage.addItem("SOMETIMES_PRODUCED");
jComboBoxUsage.addItem("PRIVATE");
}
/* (non-Javadoc)
* @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
*
* Override actionPerformed to listen all actions
*
*/
public void actionPerformed(ActionEvent arg0) {
if (arg0.getSource() == jButtonOk) {
this.setEdited(true);
this.save();
this.dispose();
}
if (arg0.getSource() == jButtonCancel) {
this.dispose();
}
//
//Contorl the selected status when click RadionButton
//Do not use Radio Button Group
//
if (arg0.getSource() == jRadioButtonPpi) {
if (jRadioButtonPpi.isSelected()) {
jRadioButtonPpiNotify.setSelected(false);
initUsage(ModulePpis.PPI);
}
if (!jRadioButtonPpiNotify.isSelected() && !jRadioButtonPpi.isSelected()) {
jRadioButtonPpi.setSelected(true);
initUsage(ModulePpis.PPI);
}
}
if (arg0.getSource() == jRadioButtonPpiNotify) {
if (jRadioButtonPpiNotify.isSelected()) {
jRadioButtonPpi.setSelected(false);
initUsage(ModulePpis.PPI_NOTIFY);
}
if (!jRadioButtonPpiNotify.isSelected() && !jRadioButtonPpi.isSelected()) {
jRadioButtonPpiNotify.setSelected(true);
initUsage(ModulePpis.PPI_NOTIFY);
}
}
//
//Contorl the selected status when click RadionButton
//Do not use Radio Button Group
//
if (arg0.getSource() == jRadioButtonEnableFeature) {
if (jRadioButtonEnableFeature.isSelected()) {
jRadioButtonDisableFeature.setSelected(false);
}
if (!jRadioButtonDisableFeature.isSelected() && !jRadioButtonEnableFeature.isSelected()) {
jRadioButtonEnableFeature.setSelected(true);
}
}
if (arg0.getSource() == jRadioButtonDisableFeature) {
if (jRadioButtonDisableFeature.isSelected()) {
jRadioButtonEnableFeature.setSelected(false);
}
if (!jRadioButtonDisableFeature.isSelected() && !jRadioButtonEnableFeature.isSelected()) {
jRadioButtonDisableFeature.setSelected(true);
}
}
if (arg0.getSource() == jButtonGenerateGuid) {
jTextFieldGuid.setText(Tools.generateUuidString());
}
}
/**
Get PPIsDocument.PPIs
@return PPIsDocument.PPIs
**/
public PPIsDocument.PPIs getPpis() {
return ppis;
}
/**
Set PPIsDocument.PPIs
@param ppis The input data of PPIsDocument.PPIs
**/
public void setPpis(PPIsDocument.PPIs ppis) {
this.ppis = ppis;
}
/**
Data validation for all fields
@retval true - All datas are valid
@retval false - At least one data is invalid
**/
public boolean check() {
//
// Check if all required fields are not empty
//
if (isEmpty(this.jTextFieldC_Name.getText())) {
Log.err("C_Name couldn't be empty");
return false;
}
//
// Check if all fields have correct data types
//
if (!DataValidation.isCName(this.jTextFieldC_Name.getText())) {
Log.err("Incorrect data type for C_Name");
return false;
}
if (!isEmpty(this.jTextFieldGuid.getText()) && !DataValidation.isGuid(this.jTextFieldGuid.getText())) {
Log.err("Incorrect data type for Guid");
return false;
}
if (!isEmpty(this.jTextFieldFeatureFlag.getText())
&& !DataValidation.isFeatureFlag(this.jTextFieldFeatureFlag.getText())) {
Log.err("Incorrect data type for Feature Flag");
return false;
}
if (!isEmpty(this.jTextFieldOverrideID.getText())
&& !DataValidation.isOverrideID(this.jTextFieldOverrideID.getText())) {
Log.err("Incorrect data type for Override ID");
return false;
}
return true;
}
/**
Save all components of PPIs
if exists ppis, set the value directly
if not exists ppis, new an instance first
**/
public void save() {
try {
if (this.ppis == null) {
ppis = PPIsDocument.PPIs.Factory.newInstance();
}
if (this.jRadioButtonPpi.isSelected()) {
PPIsDocument.PPIs.Ppi ppi = PPIsDocument.PPIs.Ppi.Factory.newInstance();
ppi.setStringValue(this.jTextFieldC_Name.getText());
if (!isEmpty(this.jTextFieldGuid.getText())) {
ppi.setGuid(this.jTextFieldGuid.getText());
}
ppi.setUsage(PpiUsage.Enum.forString(jComboBoxUsage.getSelectedItem().toString()));
ppi.setEnableFeature(this.jRadioButtonEnableFeature.isSelected());
if (!isEmpty(this.jTextFieldFeatureFlag.getText())) {
ppi.setFeatureFlag(this.jTextFieldFeatureFlag.getText());
}
if (!isEmpty(this.jTextFieldOverrideID.getText())) {
ppi.setOverrideID(Integer.parseInt(this.jTextFieldOverrideID.getText()));
}
if (location > -1) {
ppis.setPpiArray(location, ppi);
} else {
ppis.addNewPpi();
ppis.setPpiArray(ppis.getPpiList().size() - 1, ppi);
}
}
if (this.jRadioButtonPpiNotify.isSelected()) {
PPIsDocument.PPIs.PpiNotify ppiNotify = PPIsDocument.PPIs.PpiNotify.Factory.newInstance();
ppiNotify.setStringValue(this.jTextFieldC_Name.getText());
if (!isEmpty(this.jTextFieldGuid.getText())) {
ppiNotify.setGuid(this.jTextFieldGuid.getText());
}
ppiNotify.setUsage(PpiNotifyUsage.Enum.forString(jComboBoxUsage.getSelectedItem().toString()));
ppiNotify.setEnableFeature(this.jRadioButtonEnableFeature.isSelected());
if (!isEmpty(this.jTextFieldFeatureFlag.getText())) {
ppiNotify.setFeatureFlag(this.jTextFieldFeatureFlag.getText());
}
if (!isEmpty(this.jTextFieldOverrideID.getText())) {
ppiNotify.setOverrideID(Integer.parseInt(this.jTextFieldOverrideID.getText()));
}
if (location > -1) {
ppis.setPpiNotifyArray(location, ppiNotify);
} else {
ppis.addNewPpiNotify();
ppis.setPpiNotifyArray(ppis.getPpiNotifyList().size() - 1, ppiNotify);
}
}
} catch (Exception e) {
Log.err("Update Protocols", e.getMessage());
}
}
/**
Enable/Disable relevant fields via different PPI types
@param intType The input data of PPI type
**/
private void initUsage(int intType) {
jComboBoxUsage.removeAllItems();
if (intType == ModulePpis.PPI) {
jComboBoxUsage.addItem("ALWAYS_CONSUMED");
jComboBoxUsage.addItem("SOMETIMES_CONSUMED");
jComboBoxUsage.addItem("ALWAYS_PRODUCED");
jComboBoxUsage.addItem("SOMETIMES_PRODUCED");
jComboBoxUsage.addItem("PRIVATE");
}
if (intType == ModulePpis.PPI_NOTIFY) {
jComboBoxUsage.addItem("SOMETIMES_CONSUMED");
}
}
}

View File

@ -0,0 +1,705 @@
/** @file
The file is used to create, update Protocol of MSA/MBD file
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.packaging.module.ui;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.JTextField;
import org.tianocore.ProtocolNotifyUsage;
import org.tianocore.ProtocolUsage;
import org.tianocore.ProtocolsDocument;
import org.tianocore.common.DataValidation;
import org.tianocore.common.Log;
import org.tianocore.common.Tools;
import org.tianocore.packaging.common.ui.IDefaultMutableTreeNode;
import org.tianocore.packaging.common.ui.IInternalFrame;
import org.tianocore.packaging.common.ui.StarLabel;
/**
The class is used to create, update Protocol of MSA/MBD file
It extends IInternalFrame
@since ModuleEditor 1.0
**/
public class ModuleProtocols extends IInternalFrame {
///
/// Define class Serial Version UID
///
private static final long serialVersionUID = -9084913640747858848L;
//
//Define class members
//
private ProtocolsDocument.Protocols protocols = null;
private int location = -1;
private JPanel jContentPane = null;
private JLabel jLabelC_Name = null;
private JTextField jTextFieldC_Name = null;
private JLabel jLabelGuid = null;
private JTextField jTextFieldGuid = null;
private JLabel jLabelFeatureFlag = null;
private JTextField jTextFieldFeatureFlag = null;
private JButton jButtonOk = null;
private JButton jButtonCancel = null;
private JLabel jLabelUsage = null;
private JComboBox jComboBoxUsage = null;
private JLabel jLabelEnableFeature = null;
private JRadioButton jRadioButtonEnableFeature = null;
private JRadioButton jRadioButtonDisableFeature = null;
private JRadioButton jRadioButtonProtocol = null;
private JRadioButton jRadioButtonProtocolNotify = null;
private JButton jButtonGenerateGuid = null;
private JLabel jLabelOverrideID = null;
private JTextField jTextFieldOverrideID = null;
private StarLabel jStarLabel1 = null;
private StarLabel jStarLabel2 = null;
private JLabel jLabelProtocolType = null;
/**
This method initializes jTextFieldC_Name
@return javax.swing.JTextField jTextFieldC_Name
**/
private JTextField getJTextFieldProtocolName() {
if (jTextFieldC_Name == null) {
jTextFieldC_Name = new JTextField();
jTextFieldC_Name.setBounds(new java.awt.Rectangle(160, 35, 320, 20));
}
return jTextFieldC_Name;
}
/**
This method initializes jTextFieldGuid
@return javax.swing.JTextField jTextFieldGuid
**/
private JTextField getJTextFieldGuid() {
if (jTextFieldGuid == null) {
jTextFieldGuid = new JTextField();
jTextFieldGuid.setBounds(new java.awt.Rectangle(160, 60, 240, 20));
}
return jTextFieldGuid;
}
/**
This method initializes jTextFieldFeatureFlag
@return javax.swing.JTextField jTextFieldFeatureFlag
**/
private JTextField getJTextFieldFeatureFlag() {
if (jTextFieldFeatureFlag == null) {
jTextFieldFeatureFlag = new JTextField();
jTextFieldFeatureFlag.setBounds(new java.awt.Rectangle(160, 135, 320, 20));
}
return jTextFieldFeatureFlag;
}
/**
This method initializes jButtonOk
@return javax.swing.JButton jButtonOk
**/
private JButton getJButtonOk() {
if (jButtonOk == null) {
jButtonOk = new JButton();
jButtonOk.setText("OK");
jButtonOk.setBounds(new java.awt.Rectangle(290, 190, 90, 20));
jButtonOk.addActionListener(this);
}
return jButtonOk;
}
/**
This method initializes jButtonCancel
@return javax.swing.JButton jButtonCancel
**/
private JButton getJButtonCancel() {
if (jButtonCancel == null) {
jButtonCancel = new JButton();
jButtonCancel.setText("Cancel");
jButtonCancel.setBounds(new java.awt.Rectangle(390, 190, 90, 20));
jButtonCancel.setPreferredSize(new Dimension(90, 20));
jButtonCancel.addActionListener(this);
}
return jButtonCancel;
}
/**
This method initializes jComboBoxUsage
@return javax.swing.JComboBox jComboBoxUsage
**/
private JComboBox getJComboBoxProtocolUsage() {
if (jComboBoxUsage == null) {
jComboBoxUsage = new JComboBox();
jComboBoxUsage.setBounds(new java.awt.Rectangle(160, 85, 320, 20));
}
return jComboBoxUsage;
}
/**
This method initializes jRadioButtonEnableFeature
@return javax.swing.JRadioButton jRadioButtonEnableFeature
**/
private JRadioButton getJRadioButtonEnableFeature() {
if (jRadioButtonEnableFeature == null) {
jRadioButtonEnableFeature = new JRadioButton();
jRadioButtonEnableFeature.setText("Enable");
jRadioButtonEnableFeature.setBounds(new java.awt.Rectangle(160, 110, 90, 20));
jRadioButtonEnableFeature.addActionListener(this);
jRadioButtonEnableFeature.setSelected(true);
}
return jRadioButtonEnableFeature;
}
/**
This method initializes jRadioButtonDisableFeature
@return javax.swing.JRadioButton jRadioButtonDisableFeature
**/
private JRadioButton getJRadioButtonDisableFeature() {
if (jRadioButtonDisableFeature == null) {
jRadioButtonDisableFeature = new JRadioButton();
jRadioButtonDisableFeature.setText("Disable");
jRadioButtonDisableFeature.setBounds(new java.awt.Rectangle(320, 110, 90, 20));
jRadioButtonDisableFeature.addActionListener(this);
}
return jRadioButtonDisableFeature;
}
/**
This method initializes jRadioButtonProtocol
@return javax.swing.JRadioButton jRadioButtonProtocol
**/
private JRadioButton getJRadioButtonProtocol() {
if (jRadioButtonProtocol == null) {
jRadioButtonProtocol = new JRadioButton();
jRadioButtonProtocol.setText("Protocol");
jRadioButtonProtocol.setBounds(new java.awt.Rectangle(160, 10, 90, 20));
jRadioButtonProtocol.setSelected(true);
jRadioButtonProtocol.addActionListener(this);
}
return jRadioButtonProtocol;
}
/**
This method initializes jRadioButtonProtocolNotify
@return javax.swing.JRadioButton jRadioButtonProtocolNotify
**/
private JRadioButton getJRadioButtonProtocolNotify() {
if (jRadioButtonProtocolNotify == null) {
jRadioButtonProtocolNotify = new JRadioButton();
jRadioButtonProtocolNotify.setText("Protocol Notify");
jRadioButtonProtocolNotify.setBounds(new java.awt.Rectangle(320, 10, 120, 20));
jRadioButtonProtocolNotify.addActionListener(this);
}
return jRadioButtonProtocolNotify;
}
/**
This method initializes jButtonGenerateGuid
@return javax.swing.JButton jButtonGenerateGuid
**/
private JButton getJButtonGenerateGuid() {
if (jButtonGenerateGuid == null) {
jButtonGenerateGuid = new JButton();
jButtonGenerateGuid.setBounds(new java.awt.Rectangle(405, 60, 75, 20));
jButtonGenerateGuid.setText("GEN");
jButtonGenerateGuid.addActionListener(this);
}
return jButtonGenerateGuid;
}
/**
This method initializes jTextFieldOverrideID
@return javax.swing.JTextField jTextFieldOverrideID
**/
private JTextField getJTextFieldOverrideID() {
if (jTextFieldOverrideID == null) {
jTextFieldOverrideID = new JTextField();
jTextFieldOverrideID.setBounds(new java.awt.Rectangle(160, 160, 320, 20));
}
return jTextFieldOverrideID;
}
public static void main(String[] args) {
}
/**
This is the default constructor
**/
public ModuleProtocols() {
super();
init();
this.setVisible(true);
}
/**
This is the override edit constructor
@param inProtocol The input data of ProtocolsDocument.Protocols
**/
public ModuleProtocols(ProtocolsDocument.Protocols inProtocol) {
super();
init(inProtocol);
this.setVisible(true);
}
/**
This is the override edit constructor
@param inProtocol The input data of ProtocolsDocument.Protocols
@param type The input data of node type
@param index The input data of node index
**/
public ModuleProtocols(ProtocolsDocument.Protocols inProtocol, int type, int index) {
super();
init(inProtocol, type, index);
this.setVisible(true);
}
/**
This method initializes this
@param inProtocol The input data of ProtocolsDocument.Protocols
**/
private void init(ProtocolsDocument.Protocols inProtocol) {
init();
this.setProtocols(inProtocol);
}
/**
This method initializes this
Fill values to all fields if these values are not empty
@param inProtocol The input data of ProtocolsDocument.Protocols
@param type The input data of node type
@param index The input data of node index
**/
private void init(ProtocolsDocument.Protocols inProtocol, int type, int index) {
init(inProtocol);
this.location = index;
if (type == IDefaultMutableTreeNode.PROTOCOLS_PROTOCOL_ITEM) {
this.jRadioButtonProtocol.setSelected(true);
this.jRadioButtonProtocolNotify.setSelected(false);
if (this.protocols.getProtocolArray(index).getStringValue() != null) {
this.jTextFieldC_Name.setText(this.protocols.getProtocolArray(index).getStringValue());
}
if (this.protocols.getProtocolArray(index).getGuid() != null) {
this.jTextFieldGuid.setText(this.protocols.getProtocolArray(index).getGuid());
}
if (this.protocols.getProtocolArray(index).getUsage() != null) {
this.jComboBoxUsage.setSelectedItem(this.protocols.getProtocolArray(index).getUsage().toString());
}
this.jRadioButtonEnableFeature.setSelected(this.protocols.getProtocolArray(index).getEnableFeature());
this.jRadioButtonDisableFeature.setSelected(!this.protocols.getProtocolArray(index).getEnableFeature());
if (this.protocols.getProtocolArray(index).getFeatureFlag() != null) {
this.jTextFieldFeatureFlag.setText(this.protocols.getProtocolArray(index).getFeatureFlag());
}
this.jTextFieldOverrideID.setText(String.valueOf(this.protocols.getProtocolArray(index).getOverrideID()));
} else if (type == IDefaultMutableTreeNode.PROTOCOLS_PROTOCOLNOTIFY_ITEM) {
this.jRadioButtonProtocol.setSelected(false);
this.jRadioButtonProtocolNotify.setSelected(true);
this.jTextFieldFeatureFlag.setEditable(false);
this.jRadioButtonDisableFeature.setEnabled(false);
this.jRadioButtonEnableFeature.setEnabled(false);
this.jComboBoxUsage.setEnabled(false);
if (this.protocols.getProtocolNotifyArray(index).getStringValue() != null) {
this.jTextFieldC_Name.setText(this.protocols.getProtocolNotifyArray(index).getStringValue());
}
if (this.protocols.getProtocolNotifyArray(index).getGuid() != null) {
this.jTextFieldGuid.setText(this.protocols.getProtocolNotifyArray(index).getGuid());
}
if (this.protocols.getProtocolNotifyArray(index).getUsage() != null) {
this.jComboBoxUsage.setSelectedItem(this.protocols.getProtocolNotifyArray(index).getUsage().toString());
}
this.jTextFieldOverrideID.setText(String.valueOf(this.protocols.getProtocolNotifyArray(index)
.getOverrideID()));
}
this.jRadioButtonProtocol.setEnabled(false);
this.jRadioButtonProtocolNotify.setEnabled(false);
}
/**
This method initializes this
**/
private void init() {
this.setSize(500, 515);
this.setName("JFrame");
this.setContentPane(getJContentPane());
this.setTitle("Protocols");
initFrame();
this.setViewMode(false);
}
/**
Disable all components when the mode is view
@param isView true - The view mode; false - The non-view mode
**/
public void setViewMode(boolean isView) {
this.jButtonOk.setVisible(false);
this.jButtonCancel.setVisible(false);
if (isView) {
this.jRadioButtonProtocol.setEnabled(!isView);
this.jRadioButtonProtocolNotify.setEnabled(!isView);
this.jTextFieldC_Name.setEnabled(!isView);
this.jTextFieldGuid.setEnabled(!isView);
this.jComboBoxUsage.setEnabled(!isView);
this.jRadioButtonEnableFeature.setEnabled(!isView);
this.jRadioButtonDisableFeature.setEnabled(!isView);
this.jTextFieldFeatureFlag.setEnabled(!isView);
this.jTextFieldOverrideID.setEnabled(!isView);
this.jButtonGenerateGuid.setEnabled(!isView);
}
}
/**
This method initializes jContentPane
@return javax.swing.JPanel jContentPane
**/
private JPanel getJContentPane() {
if (jContentPane == null) {
jLabelProtocolType = new JLabel();
jLabelProtocolType.setBounds(new java.awt.Rectangle(15, 10, 140, 20));
jLabelProtocolType.setText("Protocol Type");
jLabelOverrideID = new JLabel();
jLabelOverrideID.setBounds(new java.awt.Rectangle(15, 160, 140, 20));
jLabelOverrideID.setText("Override ID");
jLabelEnableFeature = new JLabel();
jLabelEnableFeature.setText("Enable Feature");
jLabelEnableFeature.setBounds(new java.awt.Rectangle(15, 110, 140, 20));
jLabelUsage = new JLabel();
jLabelUsage.setText("Usage");
jLabelUsage.setBounds(new java.awt.Rectangle(15, 85, 140, 20));
jLabelFeatureFlag = new JLabel();
jLabelFeatureFlag.setText("Feature Flag");
jLabelFeatureFlag.setBounds(new java.awt.Rectangle(15, 135, 140, 20));
jLabelGuid = new JLabel();
jLabelGuid.setText("Guid");
jLabelGuid.setBounds(new java.awt.Rectangle(15, 60, 140, 20));
jLabelC_Name = new JLabel();
jLabelC_Name.setText("C_Name");
jLabelC_Name.setBounds(new java.awt.Rectangle(15, 35, 140, 20));
jContentPane = new JPanel();
jContentPane.setLayout(null);
jContentPane.add(jLabelC_Name, null);
jContentPane.add(getJTextFieldProtocolName(), null);
jContentPane.add(jLabelGuid, null);
jContentPane.add(getJTextFieldGuid(), null);
jContentPane.add(jLabelFeatureFlag, null);
jContentPane.add(getJTextFieldFeatureFlag(), null);
jContentPane.add(getJButtonOk(), null);
jContentPane.add(getJButtonCancel(), null);
jContentPane.add(jLabelUsage, null);
jContentPane.add(getJComboBoxProtocolUsage(), null);
jContentPane.add(jLabelEnableFeature, null);
jContentPane.add(getJRadioButtonEnableFeature(), null);
jContentPane.add(getJRadioButtonDisableFeature(), null);
jContentPane.add(getJRadioButtonProtocol(), null);
jContentPane.add(getJRadioButtonProtocolNotify(), null);
jContentPane.add(getJButtonGenerateGuid(), null);
jContentPane.add(jLabelOverrideID, null);
jContentPane.add(getJTextFieldOverrideID(), null);
jContentPane.add(jLabelProtocolType, null);
jStarLabel1 = new StarLabel();
jStarLabel1.setBounds(new java.awt.Rectangle(0, 10, 10, 20));
jStarLabel2 = new StarLabel();
jStarLabel2.setBounds(new java.awt.Rectangle(0, 35, 10, 20));
jContentPane.add(jStarLabel1, null);
jContentPane.add(jStarLabel2, null);
}
return jContentPane;
}
/**
This method initializes Usage type
**/
private void initFrame() {
jComboBoxUsage.addItem("ALWAYS_CONSUMED");
jComboBoxUsage.addItem("SOMETIMES_CONSUMED");
jComboBoxUsage.addItem("ALWAYS_PRODUCED");
jComboBoxUsage.addItem("SOMETIMES_PRODUCED");
jComboBoxUsage.addItem("TO_START");
jComboBoxUsage.addItem("BY_START");
jComboBoxUsage.addItem("PRIVATE");
}
/* (non-Javadoc)
* @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
*
* Override actionPerformed to listen all actions
*
*/
public void actionPerformed(ActionEvent arg0) {
if (arg0.getSource() == jButtonOk) {
this.setEdited(true);
this.save();
this.dispose();
}
if (arg0.getSource() == jButtonCancel) {
this.dispose();
}
//
// Contorl the selected status when click RadionButton
// Do not use Radio Button Group
//
if (arg0.getSource() == jRadioButtonProtocol) {
if (jRadioButtonProtocol.isSelected()) {
jRadioButtonProtocolNotify.setSelected(false);
jRadioButtonEnableFeature.setEnabled(true);
jRadioButtonDisableFeature.setEnabled(true);
jTextFieldFeatureFlag.setEnabled(true);
jComboBoxUsage.setEnabled(true);
}
if (!jRadioButtonProtocolNotify.isSelected() && !jRadioButtonProtocol.isSelected()) {
jRadioButtonProtocol.setSelected(true);
jRadioButtonEnableFeature.setEnabled(true);
jRadioButtonDisableFeature.setEnabled(true);
jTextFieldFeatureFlag.setEnabled(true);
jComboBoxUsage.setEnabled(true);
}
}
if (arg0.getSource() == jRadioButtonProtocolNotify) {
if (jRadioButtonProtocolNotify.isSelected()) {
jRadioButtonProtocol.setSelected(false);
jRadioButtonEnableFeature.setEnabled(false);
jRadioButtonDisableFeature.setEnabled(false);
jTextFieldFeatureFlag.setEnabled(false);
jComboBoxUsage.setSelectedIndex(1);
jComboBoxUsage.setEnabled(false);
}
if (!jRadioButtonProtocolNotify.isSelected() && !jRadioButtonProtocol.isSelected()) {
jRadioButtonProtocolNotify.setSelected(true);
jRadioButtonEnableFeature.setEnabled(false);
jRadioButtonDisableFeature.setEnabled(false);
jTextFieldFeatureFlag.setEnabled(false);
jComboBoxUsage.setSelectedIndex(1);
jComboBoxUsage.setEnabled(false);
}
}
//
// Contorl the selected status when click RadionButton
// Do not use Radio Button Group
//
if (arg0.getSource() == jRadioButtonEnableFeature) {
if (jRadioButtonEnableFeature.isSelected()) {
jRadioButtonDisableFeature.setSelected(false);
}
if (!jRadioButtonDisableFeature.isSelected() && !jRadioButtonEnableFeature.isSelected()) {
jRadioButtonEnableFeature.setSelected(true);
}
}
if (arg0.getSource() == jRadioButtonDisableFeature) {
if (jRadioButtonDisableFeature.isSelected()) {
jRadioButtonEnableFeature.setSelected(false);
}
if (!jRadioButtonDisableFeature.isSelected() && !jRadioButtonEnableFeature.isSelected()) {
jRadioButtonDisableFeature.setSelected(true);
}
}
if (arg0.getSource() == jButtonGenerateGuid) {
jTextFieldGuid.setText(Tools.generateUuidString());
}
}
/**
Get ProtocolsDocument.Protocols
@return ProtocolsDocument.Protocols
**/
public ProtocolsDocument.Protocols getProtocols() {
return protocols;
}
/**
Set ProtocolsDocument.Protocols
@param protocols The input data of ProtocolsDocument.Protocols
**/
public void setProtocols(ProtocolsDocument.Protocols protocols) {
this.protocols = protocols;
}
/**
Data validation for all fields
@retval true - All datas are valid
@retval false - At least one data is invalid
**/
public boolean check() {
//
// Check if all required fields are not empty
//
if (isEmpty(this.jTextFieldC_Name.getText())) {
Log.err("C_Name couldn't be empty");
return false;
}
//
// Check if all fields have correct data types
//
if (!DataValidation.isCName(this.jTextFieldC_Name.getText())) {
Log.err("Incorrect data type for C_Name");
return false;
}
if (!isEmpty(this.jTextFieldGuid.getText()) && !DataValidation.isGuid(this.jTextFieldGuid.getText())) {
Log.err("Incorrect data type for Guid");
return false;
}
if (!isEmpty(this.jTextFieldFeatureFlag.getText())
&& !DataValidation.isFeatureFlag(this.jTextFieldFeatureFlag.getText())) {
Log.err("Incorrect data type for Feature Flag");
return false;
}
if (!isEmpty(this.jTextFieldOverrideID.getText())
&& !DataValidation.isOverrideID(this.jTextFieldOverrideID.getText())) {
Log.err("Incorrect data type for Override ID");
return false;
}
return true;
}
/**
Save all components of Protocols
if exists protocols, set the value directly
if not exists protocols, new an instance first
**/
public void save() {
try {
if (this.protocols == null) {
protocols = ProtocolsDocument.Protocols.Factory.newInstance();
}
if (this.jRadioButtonProtocol.isSelected()) {
ProtocolsDocument.Protocols.Protocol protocol = ProtocolsDocument.Protocols.Protocol.Factory
.newInstance();
protocol.setStringValue(this.jTextFieldC_Name.getText());
if (!isEmpty(this.jTextFieldGuid.getText())) {
protocol.setGuid(this.jTextFieldGuid.getText());
}
protocol.setUsage(ProtocolUsage.Enum.forString(jComboBoxUsage.getSelectedItem().toString()));
protocol.setEnableFeature(this.jRadioButtonEnableFeature.isSelected());
if (!isEmpty(this.jTextFieldFeatureFlag.getText())) {
protocol.setFeatureFlag(this.jTextFieldFeatureFlag.getText());
}
if (!isEmpty(this.jTextFieldOverrideID.getText())) {
protocol.setOverrideID(Integer.parseInt(this.jTextFieldOverrideID.getText()));
}
if (location > -1) {
protocols.setProtocolArray(location, protocol);
} else {
protocols.addNewProtocol();
protocols.setProtocolArray(protocols.getProtocolList().size() - 1, protocol);
}
}
if (this.jRadioButtonProtocolNotify.isSelected()) {
ProtocolsDocument.Protocols.ProtocolNotify protocolNofity = ProtocolsDocument.Protocols.ProtocolNotify.Factory
.newInstance();
protocolNofity.setStringValue(this.jTextFieldC_Name.getText());
if (!isEmpty(this.jTextFieldGuid.getText())) {
protocolNofity.setGuid(this.jTextFieldGuid.getText());
}
protocolNofity
.setUsage(ProtocolNotifyUsage.Enum.forString(jComboBoxUsage.getSelectedItem().toString()));
if (!isEmpty(this.jTextFieldOverrideID.getText())) {
protocolNofity.setOverrideID(Integer.parseInt(this.jTextFieldOverrideID.getText()));
}
if (location > -1) {
protocols.setProtocolNotifyArray(location, protocolNofity);
} else {
protocols.addNewProtocolNotify();
protocols.setProtocolNotifyArray(protocols.getProtocolNotifyList().size() - 1, protocolNofity);
}
}
} catch (Exception e) {
Log.err("Update Protocols", e.getMessage());
}
}
}

View File

@ -0,0 +1,393 @@
/** @file
The file is used to create, update SystemTable of MSA/MBD file
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.packaging.module.ui;
import java.awt.event.ActionEvent;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import org.tianocore.SystemTableUsage;
import org.tianocore.SystemTablesDocument;
import org.tianocore.common.DataValidation;
import org.tianocore.common.Log;
import org.tianocore.packaging.common.ui.IInternalFrame;
import org.tianocore.packaging.common.ui.StarLabel;
/**
The class is used to create, update SystemTable of MSA/MBD file
It extends IInternalFrame
@since ModuleEditor 1.0
**/
public class ModuleSystemTables extends IInternalFrame {
///
/// Define class Serial Version UID
///
private static final long serialVersionUID = 7488769180379442276L;
//
//Define class members
//
private SystemTablesDocument.SystemTables systemTables = null;
private int location = -1;
private JPanel jContentPane = null;
private JLabel jLabelEntry = null;
private JTextField jTextFieldEntry = null;
private JLabel jLabelUsage = null;
private JComboBox jComboBoxUsage = null;
private JButton jButtonOk = null;
private JButton jButtonCancel = null;
private JLabel jLabelOverrideID = null;
private JTextField jTextFieldOverrideID = null;
private StarLabel jStarLabel1 = null;
/**
This method initializes jTextFieldEntry
@return javax.swing.JTextField jTextFieldEntry
**/
private JTextField getJTextFieldEntry() {
if (jTextFieldEntry == null) {
jTextFieldEntry = new JTextField();
jTextFieldEntry.setBounds(new java.awt.Rectangle(160, 10, 320, 20));
}
return jTextFieldEntry;
}
/**
This method initializes jComboBoxUsage
@return javax.swing.JComboBox jComboBoxUsage
**/
private JComboBox getJComboBoxUsage() {
if (jComboBoxUsage == null) {
jComboBoxUsage = new JComboBox();
jComboBoxUsage.setBounds(new java.awt.Rectangle(160, 35, 320, 20));
}
return jComboBoxUsage;
}
/**
This method initializes jButtonOk
@return javax.swing.JButton jButtonOk
**/
private JButton getJButtonOk() {
if (jButtonOk == null) {
jButtonOk = new JButton();
jButtonOk.setText("OK");
jButtonOk.setBounds(new java.awt.Rectangle(280, 90, 90, 20));
jButtonOk.addActionListener(this);
}
return jButtonOk;
}
/**
This method initializes jButtonCancel
@return javax.swing.JButton jButtonCancel
**/
private JButton getJButtonCancel() {
if (jButtonCancel == null) {
jButtonCancel = new JButton();
jButtonCancel.setText("Cancel");
jButtonCancel.setBounds(new java.awt.Rectangle(390, 90, 90, 20));
jButtonCancel.addActionListener(this);
}
return jButtonCancel;
}
/**
This method initializes jTextFieldOverrideID
@return javax.swing.JTextField jTextFieldOverrideID
**/
private JTextField getJTextFieldOverrideID() {
if (jTextFieldOverrideID == null) {
jTextFieldOverrideID = new JTextField();
jTextFieldOverrideID.setBounds(new java.awt.Rectangle(160, 60, 320, 20));
}
return jTextFieldOverrideID;
}
public static void main(String[] args) {
}
/**
This is the default constructor
**/
public ModuleSystemTables() {
super();
init();
this.setVisible(true);
}
/**
This is the override edit constructor
@param inSystemTables The input data of SystemTablesDocument.SystemTables
**/
public ModuleSystemTables(SystemTablesDocument.SystemTables inSystemTables) {
super();
init(inSystemTables);
this.setVisible(true);
}
/**
This is the override edit constructor
@param inSystemTables The input data of SystemTablesDocument.SystemTables
@param type The input data of node type
@param index The input data of node index
**/
public ModuleSystemTables(SystemTablesDocument.SystemTables inSystemTables, int type, int index) {
super();
init(inSystemTables, type, index);
this.setVisible(true);
}
/**
This method initializes this
@param inSystemTables The input data of SystemTablesDocument.SystemTables
**/
private void init(SystemTablesDocument.SystemTables inSystemTables) {
init();
this.setSystemTables(inSystemTables);
}
/**
This method initializes this
Fill values to all fields if these values are not empty
@param inSystemTables The input data of SystemTablesDocument.SystemTables
@param type The input data of node type
@param index The input data of node index
**/
private void init(SystemTablesDocument.SystemTables inSystemTables, int type, int index) {
init(inSystemTables);
this.location = index;
if (this.systemTables.getSystemTableList().size() > 0) {
if (this.systemTables.getSystemTableArray(index).getEntry() != null) {
this.jTextFieldEntry.setText(this.systemTables.getSystemTableArray(index).getEntry());
}
if (this.systemTables.getSystemTableArray(index).getUsage() != null) {
this.jComboBoxUsage.setSelectedItem(this.systemTables.getSystemTableArray(index).getUsage().toString());
}
this.jTextFieldOverrideID.setText(String.valueOf(this.systemTables.getSystemTableArray(index)
.getOverrideID()));
}
}
/**
This method initializes this
@return void
**/
private void init() {
this.setSize(500, 515);
this.setContentPane(getJContentPane());
this.setTitle("System Tables");
initFrame();
this.setViewMode(false);
}
/**
Disable all components when the mode is view
@param isView true - The view mode; false - The non-view mode
**/
public void setViewMode(boolean isView) {
this.jButtonOk.setVisible(false);
this.jButtonCancel.setVisible(false);
if (isView) {
this.jTextFieldEntry.setEnabled(!isView);
this.jComboBoxUsage.setEnabled(!isView);
this.jTextFieldOverrideID.setEnabled(!isView);
}
}
/**
This method initializes jContentPane
@return javax.swing.JPanel jContentPane
**/
private JPanel getJContentPane() {
if (jContentPane == null) {
jLabelOverrideID = new JLabel();
jLabelOverrideID.setBounds(new java.awt.Rectangle(15, 60, 140, 20));
jLabelOverrideID.setText("Override ID");
jLabelUsage = new JLabel();
jLabelUsage.setText("Usage");
jLabelUsage.setBounds(new java.awt.Rectangle(15, 35, 140, 20));
jLabelEntry = new JLabel();
jLabelEntry.setText("Entry");
jLabelEntry.setBounds(new java.awt.Rectangle(15, 10, 140, 20));
jContentPane = new JPanel();
jContentPane.setLayout(null);
jContentPane.add(jLabelEntry, null);
jContentPane.add(getJTextFieldEntry(), null);
jContentPane.add(jLabelUsage, null);
jContentPane.add(getJComboBoxUsage(), null);
jContentPane.add(getJButtonOk(), null);
jContentPane.add(getJButtonCancel(), null);
jContentPane.add(jLabelOverrideID, null);
jContentPane.add(getJTextFieldOverrideID(), null);
jStarLabel1 = new StarLabel();
jStarLabel1.setBounds(new java.awt.Rectangle(0, 10, 10, 20));
jContentPane.add(jStarLabel1, null);
}
return jContentPane;
}
/**
This method initializes Usage type
**/
private void initFrame() {
jComboBoxUsage.addItem("ALWAYS_CONSUMED");
jComboBoxUsage.addItem("SOMETIMES_CONSUMED");
jComboBoxUsage.addItem("ALWAYS_PRODUCED");
jComboBoxUsage.addItem("SOMETIMES_PRODUCED");
jComboBoxUsage.addItem("PRIVATE");
}
/* (non-Javadoc)
* @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
*
* Override actionPerformed to listen all actions
*
*/
public void actionPerformed(ActionEvent arg0) {
if (arg0.getSource() == jButtonOk) {
this.setEdited(true);
this.save();
this.dispose();
}
if (arg0.getSource() == jButtonCancel) {
this.dispose();
}
}
/**
Get SystemTablesDocument.SystemTables
@return SystemTablesDocument.SystemTables
**/
public SystemTablesDocument.SystemTables getSystemTables() {
return systemTables;
}
/**
Set SystemTablesDocument.SystemTables
@param systemTables The input data of SystemTablesDocument.SystemTables
**/
public void setSystemTables(SystemTablesDocument.SystemTables systemTables) {
this.systemTables = systemTables;
}
/**
Data validation for all fields
@retval true - All datas are valid
@retval false - At least one data is invalid
**/
public boolean check() {
//
// Check if all required fields are not empty
//
if (isEmpty(this.jTextFieldEntry.getText())) {
Log.err("Entry couldn't be empty");
return false;
}
//
// Check if all fields have correct data types
//
if (!isEmpty(this.jTextFieldOverrideID.getText())
&& !DataValidation.isOverrideID(this.jTextFieldOverrideID.getText())) {
Log.err("Incorrect data type for Override ID");
return false;
}
return true;
}
/**
Save all components of SystemTables
if exists systemTables, set the value directly
if not exists systemTables, new an instance first
**/
public void save() {
try {
if (this.systemTables == null) {
systemTables = SystemTablesDocument.SystemTables.Factory.newInstance();
}
SystemTablesDocument.SystemTables.SystemTable systemTable = SystemTablesDocument.SystemTables.SystemTable.Factory
.newInstance();
systemTable.setEntry(this.jTextFieldEntry.getText());
systemTable.setUsage(SystemTableUsage.Enum.forString(jComboBoxUsage.getSelectedItem().toString()));
if (!isEmpty(this.jTextFieldOverrideID.getText())) {
systemTable.setOverrideID(Integer.parseInt(this.jTextFieldOverrideID.getText()));
}
if (location > -1) {
systemTables.setSystemTableArray(location, systemTable);
} else {
systemTables.addNewSystemTable();
systemTables.setSystemTableArray(systemTables.getSystemTableList().size() - 1, systemTable);
}
} catch (Exception e) {
Log.err("Update System Tables", e.getMessage());
}
}
}

View File

@ -0,0 +1,601 @@
/** @file
The file is used to create, update Variable of MSA/MBD file
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.packaging.module.ui;
import java.awt.event.ActionEvent;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import org.tianocore.GuidDocument;
import org.tianocore.VariableUsage;
import org.tianocore.VariablesDocument;
import org.tianocore.common.DataValidation;
import org.tianocore.common.Log;
import org.tianocore.common.Tools;
import org.tianocore.packaging.common.ui.IInternalFrame;
import org.tianocore.packaging.common.ui.StarLabel;
/**
The class is used to create, update Variable of MSA/MBD file
It extends IInternalFrame
@since ModuleEditor 1.0
**/
public class ModuleVariables extends IInternalFrame {
///
/// Define class Serial Version UID
///
private static final long serialVersionUID = -6998982978030439446L;
//
//Define class members
//
private VariablesDocument.Variables variables = null;
private int location = -1;
private JPanel jContentPane = null;
private JLabel jLabelGuid = null;
private JTextField jTextFieldGuid = null;
private JLabel jLabelString = null;
private JTextField jTextFieldString = null;
private JLabel jLabelBitOffset = null;
private JTextField jTextFieldBitOffset = null;
private JLabel jLabelByteOffset = null;
private JTextField jTextFieldByteOffset = null;
private JLabel jLabelOffsetBitSize = null;
private JTextField jTextFieldOffsetBitSize = null;
private JLabel jLabelUsage = null;
private JComboBox jComboBoxUsage = null;
private JButton jButtonOk = null;
private JButton jButtonCancel = null;
private JButton jButtonGenerateGuid = null;
private JLabel jLabelOverrideID = null;
private JTextField jTextFieldOverrideID = null;
private StarLabel jStarLabel1 = null;
private StarLabel jStarLabel2 = null;
private JLabel jLabelByteOffsetHint = null;
private JLabel jLabelBitOffsetHint = null;
private JLabel jLabelOffsetBitSizeHint = null;
/**
This method initializes jTextFieldGuid
@return javax.swing.JTextField jTextFieldGuid
**/
private JTextField getJTextFieldGuid() {
if (jTextFieldGuid == null) {
jTextFieldGuid = new JTextField();
jTextFieldGuid.setSize(new java.awt.Dimension(250, 20));
jTextFieldGuid.setLocation(new java.awt.Point(160, 35));
}
return jTextFieldGuid;
}
/**
This method initializes jTextFieldString
@return javax.swing.JTextField jTextFieldString
**/
private JTextField getJTextFieldString() {
if (jTextFieldString == null) {
jTextFieldString = new JTextField();
jTextFieldString.setSize(new java.awt.Dimension(320, 20));
jTextFieldString.setLocation(new java.awt.Point(160, 10));
}
return jTextFieldString;
}
/**
This method initializes jTextFieldBitOffset
@return javax.swing.JTextField jTextFieldBitOffset
**/
private JTextField getJTextFieldBitOffset() {
if (jTextFieldBitOffset == null) {
jTextFieldBitOffset = new JTextField();
jTextFieldBitOffset.setSize(new java.awt.Dimension(80, 20));
jTextFieldBitOffset.setLocation(new java.awt.Point(160, 85));
}
return jTextFieldBitOffset;
}
/**
This method initializes jTextFieldByteOffset
@return javax.swing.JTextField jTextFieldByteOffset
**/
private JTextField getJTextFieldByteOffset() {
if (jTextFieldByteOffset == null) {
jTextFieldByteOffset = new JTextField();
jTextFieldByteOffset.setLocation(new java.awt.Point(160, 60));
jTextFieldByteOffset.setSize(new java.awt.Dimension(80, 20));
}
return jTextFieldByteOffset;
}
/**
This method initializes jTextFieldBitSize
@return javax.swing.JTextField jTextFieldOffsetBitSize
**/
private JTextField getJTextFieldOffsetBitSize() {
if (jTextFieldOffsetBitSize == null) {
jTextFieldOffsetBitSize = new JTextField();
jTextFieldOffsetBitSize.setSize(new java.awt.Dimension(80, 20));
jTextFieldOffsetBitSize.setLocation(new java.awt.Point(160, 110));
}
return jTextFieldOffsetBitSize;
}
/**
This method initializes jComboBoxUsage
@return javax.swing.JComboBox jComboBoxUsage
**/
private JComboBox getJComboBoxUsage() {
if (jComboBoxUsage == null) {
jComboBoxUsage = new JComboBox();
jComboBoxUsage.setBounds(new java.awt.Rectangle(160, 135, 320, 20));
}
return jComboBoxUsage;
}
/**
This method initializes jButtonOk
@return javax.swing.JButton jButtonOk
**/
private JButton getJButtonOk() {
if (jButtonOk == null) {
jButtonOk = new JButton();
jButtonOk.setText("Ok");
jButtonOk.setBounds(new java.awt.Rectangle(290, 190, 90, 20));
jButtonOk.addActionListener(this);
}
return jButtonOk;
}
/**
This method initializes jButtonCancel
@return javax.swing.JButton jButtonCancel
**/
private JButton getJButtonCancel() {
if (jButtonCancel == null) {
jButtonCancel = new JButton();
jButtonCancel.setText("Cancel");
jButtonCancel.setBounds(new java.awt.Rectangle(390, 190, 90, 20));
jButtonCancel.addActionListener(this);
}
return jButtonCancel;
}
/**
This method initializes jButtonGenerateGuid
@return javax.swing.JButton jButtonGenerateGuid
**/
private JButton getJButtonGenerateGuid() {
if (jButtonGenerateGuid == null) {
jButtonGenerateGuid = new JButton();
jButtonGenerateGuid.setText("GEN");
jButtonGenerateGuid.addActionListener(this);
jButtonGenerateGuid.setBounds(new java.awt.Rectangle(415, 35, 65, 20));
}
return jButtonGenerateGuid;
}
/**
This method initializes jTextFieldOverrideID
@return javax.swing.JTextField jTextFieldOverrideID
**/
private JTextField getJTextFieldOverrideID() {
if (jTextFieldOverrideID == null) {
jTextFieldOverrideID = new JTextField();
jTextFieldOverrideID.setBounds(new java.awt.Rectangle(160, 160, 50, 20));
}
return jTextFieldOverrideID;
}
public static void main(String[] args) {
}
/**
This is the default constructor
**/
public ModuleVariables() {
super();
init();
this.setVisible(true);
}
/**
This is the override edit constructor
@param inVariables The input data of VariablesDocument.Variables
**/
public ModuleVariables(VariablesDocument.Variables inVariables) {
super();
init(inVariables);
this.setVisible(true);
}
/**
This is the override edit constructor
@param inVariables The input data of VariablesDocument.Variables
@param type The input data of node type
@param index The input data of node index
**/
public ModuleVariables(VariablesDocument.Variables inVariables, int type, int index) {
super();
init(inVariables, type, index);
this.setVisible(true);
}
/**
This method initializes this
@param inVariables The input data of VariablesDocument.Variables
**/
private void init(VariablesDocument.Variables inVariables) {
init();
this.setVariables(inVariables);
}
/**
This method initializes this
Fill values to all fields if these values are not empty
@param inVariables The input data of VariablesDocument.Variables
@param type The input data of node type
@param index The input data of node index
**/
private void init(VariablesDocument.Variables inVariables, int type, int index) {
init(inVariables);
this.location = index;
if (this.variables.getVariableList().size() > 0) {
if (this.variables.getVariableArray(index).getString() != null) {
this.jTextFieldString.setText(this.variables.getVariableArray(index).getString());
}
if (this.variables.getVariableArray(index).getGuid() != null) {
this.jTextFieldGuid.setText(this.variables.getVariableArray(index).getGuid().getStringValue());
}
if (this.variables.getVariableArray(index).getByteOffset() != null) {
this.jTextFieldByteOffset
.setText(String
.valueOf(this.variables.getVariableArray(index).getByteOffset()));
}
if (String.valueOf(this.variables.getVariableArray(index).getBitOffset()) != null) {
this.jTextFieldBitOffset.setText(String.valueOf(this.variables.getVariableArray(index).getBitOffset()));
}
if (String.valueOf(this.variables.getVariableArray(index).getOffsetBitSize()) != null) {
this.jTextFieldOffsetBitSize.setText(String.valueOf(this.variables.getVariableArray(index)
.getOffsetBitSize()));
}
if (this.variables.getVariableArray(index).getUsage() != null) {
this.jComboBoxUsage.setSelectedItem(this.variables.getVariableArray(index).getUsage().toString());
}
this.jTextFieldOverrideID.setText(String.valueOf(this.variables.getVariableArray(index).getOverrideID()));
}
}
/**
This method initializes this
@return void
**/
private void init() {
this.setSize(500, 515);
this.setContentPane(getJContentPane());
this.setTitle("Add Variables");
this.setViewMode(false);
}
/**
Disable all components when the mode is view
@param isView true - The view mode; false - The non-view mode
**/
public void setViewMode(boolean isView) {
this.jButtonOk.setVisible(false);
this.jButtonCancel.setVisible(false);
if (isView) {
this.jTextFieldString.setEnabled(!isView);
this.jTextFieldGuid.setEnabled(!isView);
this.jTextFieldByteOffset.setEnabled(!isView);
this.jTextFieldBitOffset.setEnabled(!isView);
this.jTextFieldOffsetBitSize.setEnabled(!isView);
this.jComboBoxUsage.setEnabled(!isView);
this.jButtonGenerateGuid.setEnabled(!isView);
this.jTextFieldOverrideID.setEnabled(!isView);
}
}
/**
This method initializes jContentPane
@return javax.swing.JPanel jContentPane
**/
private JPanel getJContentPane() {
if (jContentPane == null) {
jLabelByteOffsetHint = new JLabel();
jLabelByteOffsetHint.setBounds(new java.awt.Rectangle(245,60,235,20));
jLabelByteOffsetHint.setText("0x00");
jLabelOffsetBitSizeHint = new JLabel();
jLabelOffsetBitSizeHint.setBounds(new java.awt.Rectangle(245,110,235,20));
jLabelOffsetBitSizeHint.setText("1~7");
jLabelBitOffsetHint = new JLabel();
jLabelBitOffsetHint.setBounds(new java.awt.Rectangle(245,85,235,20));
jLabelBitOffsetHint.setText("0~7");
jLabelOverrideID = new JLabel();
jLabelOverrideID.setText("Override ID");
jLabelOverrideID.setBounds(new java.awt.Rectangle(15, 160, 140, 20));
jLabelUsage = new JLabel();
jLabelUsage.setText("Usage");
jLabelUsage.setBounds(new java.awt.Rectangle(15, 135, 140, 20));
jLabelOffsetBitSize = new JLabel();
jLabelOffsetBitSize.setText("Offset Bit Size");
jLabelOffsetBitSize.setLocation(new java.awt.Point(15, 110));
jLabelOffsetBitSize.setSize(new java.awt.Dimension(140, 20));
jLabelByteOffset = new JLabel();
jLabelByteOffset.setText("Byte Offset");
jLabelByteOffset.setLocation(new java.awt.Point(15, 60));
jLabelByteOffset.setSize(new java.awt.Dimension(140, 20));
jLabelBitOffset = new JLabel();
jLabelBitOffset.setText("Bit Offset");
jLabelBitOffset.setLocation(new java.awt.Point(15, 85));
jLabelBitOffset.setSize(new java.awt.Dimension(140, 20));
jLabelString = new JLabel();
jLabelString.setText("String");
jLabelString.setLocation(new java.awt.Point(15, 10));
jLabelString.setSize(new java.awt.Dimension(140, 20));
jLabelGuid = new JLabel();
jLabelGuid.setText("Guid");
jLabelGuid.setLocation(new java.awt.Point(15, 35));
jLabelGuid.setSize(new java.awt.Dimension(140, 20));
jContentPane = new JPanel();
jContentPane.setLayout(null);
jContentPane.add(getJButtonGenerateGuid(), null);
jContentPane.add(jLabelString, null);
jContentPane.add(getJTextFieldString(), null);
jContentPane.add(jLabelGuid, null);
jContentPane.add(getJTextFieldGuid(), null);
jContentPane.add(jLabelByteOffset, null);
jContentPane.add(getJTextFieldByteOffset(), null);
jContentPane.add(jLabelBitOffset, null);
jContentPane.add(getJTextFieldBitOffset(), null);
jContentPane.add(jLabelOffsetBitSize, null);
jContentPane.add(getJTextFieldOffsetBitSize(), null);
jContentPane.add(jLabelUsage, null);
jContentPane.add(getJComboBoxUsage(), null);
jContentPane.add(jLabelOverrideID, null);
jContentPane.add(getJTextFieldOverrideID(), null);
jContentPane.add(getJButtonOk(), null);
jContentPane.add(getJButtonCancel(), null);
jStarLabel1 = new StarLabel();
jStarLabel1.setLocation(new java.awt.Point(0, 10));
jStarLabel2 = new StarLabel();
jStarLabel2.setLocation(new java.awt.Point(0, 35));
jContentPane.add(jStarLabel1, null);
jContentPane.add(jStarLabel2, null);
jContentPane.add(jLabelByteOffsetHint, null);
jContentPane.add(jLabelBitOffsetHint, null);
jContentPane.add(jLabelOffsetBitSizeHint, null);
initFrame();
}
return jContentPane;
}
/* (non-Javadoc)
* @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
*
* Override actionPerformed to listen all actions
*
*/
public void actionPerformed(ActionEvent arg0) {
if (arg0.getSource() == jButtonOk) {
this.setEdited(true);
this.save();
this.dispose();
}
if (arg0.getSource() == jButtonCancel) {
this.dispose();
}
if (arg0.getSource() == jButtonGenerateGuid) {
jTextFieldGuid.setText(Tools.generateUuidString());
}
}
/**
This method initializes Usage type
**/
private void initFrame() {
jComboBoxUsage.addItem("ALWAYS_CONSUMED");
jComboBoxUsage.addItem("SOMETIMES_CONSUMED");
jComboBoxUsage.addItem("ALWAYS_PRODUCED");
jComboBoxUsage.addItem("SOMETIMES_PRODUCED");
jComboBoxUsage.addItem("PRIVATE");
}
/**
Get VariablesDocument.Variables
@return VariablesDocument.Variables
**/
public VariablesDocument.Variables getVariables() {
return variables;
}
/**
Set VariablesDocument.Variables
@param variables The input data of VariablesDocument.Variables
**/
public void setVariables(VariablesDocument.Variables variables) {
this.variables = variables;
}
/**
Data validation for all fields
@retval true - All datas are valid
@retval false - At least one data is invalid
**/
public boolean check() {
//
// Check if all required fields are not empty
//
if (isEmpty(this.jTextFieldString.getText())) {
Log.err("String couldn't be empty");
return false;
}
if (isEmpty(this.jTextFieldGuid.getText())) {
Log.err("Guid couldn't be empty");
return false;
}
//
// Check if all fields have correct data types
//
if (!isEmpty(this.jTextFieldGuid.getText()) && !DataValidation.isGuid(this.jTextFieldGuid.getText())) {
Log.err("Incorrect data type for Guid");
return false;
}
if (!isEmpty(this.jTextFieldByteOffset.getText())
&& !DataValidation.isByteOffset(this.jTextFieldByteOffset.getText())) {
Log.err("Incorrect data type for Byte Offset");
return false;
}
if (!isEmpty(this.jTextFieldBitOffset.getText())
&& !DataValidation.isBitOffset(this.jTextFieldBitOffset.getText())) {
Log.err("Incorrect data type for Bit Offset");
return false;
}
if (!isEmpty(this.jTextFieldOffsetBitSize.getText())
&& !DataValidation.isOffsetBitSize(this.jTextFieldOffsetBitSize.getText())) {
Log.err("Incorrect data type for Bit Offset");
return false;
}
if (!isEmpty(this.jTextFieldOverrideID.getText())
&& !DataValidation.isOverrideID(this.jTextFieldOverrideID.getText())) {
Log.err("Incorrect data type for Override ID");
return false;
}
return true;
}
/**
Save all components of Variables
if exists variables, set the value directly
if not exists variables, new an instance first
**/
public void save() {
try {
if (this.variables == null) {
variables = VariablesDocument.Variables.Factory.newInstance();
}
VariablesDocument.Variables.Variable variable = VariablesDocument.Variables.Variable.Factory.newInstance();
if (!isEmpty(this.jTextFieldString.getText())) {
variable.setString(this.jTextFieldString.getText());
}
if (!isEmpty(this.jTextFieldGuid.getText())) {
GuidDocument.Guid guid = GuidDocument.Guid.Factory.newInstance();
guid.setStringValue(this.jTextFieldGuid.getText());
variable.setGuid(guid);
}
if (!isEmpty(this.jTextFieldByteOffset.getText())) {
variable.setByteOffset(this.jTextFieldByteOffset.getText());
}
if (!isEmpty(this.jTextFieldBitOffset.getText())) {
variable.setBitOffset(Integer.parseInt(this.jTextFieldBitOffset.getText()));
}
if (!isEmpty(this.jTextFieldBitOffset.getText())) {
variable.setOffsetBitSize(Integer.parseInt(this.jTextFieldBitOffset.getText()));
}
variable.setUsage(VariableUsage.Enum.forString(jComboBoxUsage.getSelectedItem().toString()));
if (!isEmpty(this.jTextFieldOverrideID.getText())) {
variable.setOverrideID(Integer.parseInt(this.jTextFieldOverrideID.getText()));
}
if (location > -1) {
variables.setVariableArray(location, variable);
} else {
variables.addNewVariable();
variables.setVariableArray(variables.getVariableList().size() - 1, variable);
}
} catch (Exception e) {
Log.err("Update Variables", e.getMessage());
}
}
}

View File

@ -0,0 +1,843 @@
/** @file
The file is used to create, update MsaHeader of MSA file
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.packaging.module.ui;
import java.awt.event.ActionEvent;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import org.tianocore.AbstractDocument;
import org.tianocore.BaseNameDocument;
import org.tianocore.FrameworkComponentTypes;
import org.tianocore.GuidDocument;
import org.tianocore.LicenseDocument;
import org.tianocore.ModuleTypeDef;
import org.tianocore.MsaHeaderDocument;
import org.tianocore.SpecificationDocument;
import org.tianocore.common.DataValidation;
import org.tianocore.common.Log;
import org.tianocore.common.Tools;
import org.tianocore.packaging.common.ui.IInternalFrame;
import org.tianocore.packaging.common.ui.StarLabel;
/**
The class is used to create, update MsaHeader of MSA file
It extends IInternalFrame
@since ModuleEditor 1.0
**/
public class MsaHeader extends IInternalFrame {
///
/// Define class Serial Version UID
///
private static final long serialVersionUID = -8152099582923006900L;
//
//Define class members
//
private JPanel jContentPane = null;
private JLabel jLabelBaseName = null;
private JTextField jTextFieldBaseName = null;
private JLabel jLabelGuid = null;
private JTextField jTextFieldGuid = null;
private JLabel jLabelVersion = null;
private JTextField jTextFieldVersion = null;
private JButton jButtonGenerateGuid = null;
private JLabel jLabelLicense = null;
private JTextArea jTextAreaLicense = null;
private JLabel jLabelCopyright = null;
private JTextArea jTextAreaCopyright = null;
private JLabel jLabelDescription = null;
private JTextArea jTextAreaDescription = null;
private JLabel jLabelSpecification = null;
private JTextField jTextFieldSpecification = null;
private JTextField jTextFieldSpecificationVersion = null;
private JButton jButtonOk = null;
private JButton jButtonCancel = null;
private JScrollPane jScrollPaneLicense = null;
private JScrollPane jScrollPaneCopyright = null;
private JScrollPane jScrollPaneDescription = null;
private JLabel jLabelSpecVersion = null;
private JLabel jLabelAbstract = null;
private JTextField jTextFieldAbstract = null;
private JLabel jLabelModuleType = null;
private JLabel jLabelCompontentType = null;
private JComboBox jComboBoxCompontentType = null;
private JComboBox jComboBoxModuleType = null;
private StarLabel jStarLabel1 = null;
private StarLabel jStarLabel2 = null;
private StarLabel jStarLabel3 = null;
private StarLabel jStarLabel4 = null;
private StarLabel jStarLabel5 = null;
private StarLabel jStarLabel6 = null;
private StarLabel jStarLabel7 = null;
private StarLabel jStarLabel8 = null;
private StarLabel jStarLabel9 = null;
private MsaHeaderDocument.MsaHeader msaHeader = null;
private JLabel jLabelURL = null;
private JTextField jTextFieldAbstractURL = null;
/**
This method initializes jTextFieldBaseName
@return javax.swing.JTextField jTextFieldBaseName
**/
private JTextField getJTextFieldBaseName() {
if (jTextFieldBaseName == null) {
jTextFieldBaseName = new JTextField();
jTextFieldBaseName.setBounds(new java.awt.Rectangle(160, 10, 320, 20));
}
return jTextFieldBaseName;
}
/**
This method initializes jTextFieldGuid
@return javax.swing.JTextField jTextFieldGuid
**/
private JTextField getJTextFieldGuid() {
if (jTextFieldGuid == null) {
jTextFieldGuid = new JTextField();
jTextFieldGuid.setBounds(new java.awt.Rectangle(160, 35, 240, 20));
}
return jTextFieldGuid;
}
/**
This method initializes jTextFieldVersion
@return javax.swing.JTextField jTextFieldVersion
**/
private JTextField getJTextFieldVersion() {
if (jTextFieldVersion == null) {
jTextFieldVersion = new JTextField();
jTextFieldVersion.setBounds(new java.awt.Rectangle(160, 60, 320, 20));
}
return jTextFieldVersion;
}
/**
This method initializes jButtonGenerateGuid
@return javax.swing.JButton jButtonGenerateGuid
**/
private JButton getJButtonGenerateGuid() {
if (jButtonGenerateGuid == null) {
jButtonGenerateGuid = new JButton();
jButtonGenerateGuid.setBounds(new java.awt.Rectangle(405, 35, 75, 20));
jButtonGenerateGuid.setText("GEN");
jButtonGenerateGuid.addActionListener(this);
}
return jButtonGenerateGuid;
}
/**
This method initializes jTextAreaLicense
@return javax.swing.JTextArea jTextAreaLicense
**/
private JTextArea getJTextAreaLicense() {
if (jTextAreaLicense == null) {
jTextAreaLicense = new JTextArea();
jTextAreaLicense.setText("");
jTextAreaLicense.setLineWrap(true);
}
return jTextAreaLicense;
}
/**
This method initializes jTextAreaCopyright
@return javax.swing.JTextArea jTextAreaCopyright
**/
private JTextArea getJTextAreaCopyright() {
if (jTextAreaCopyright == null) {
jTextAreaCopyright = new JTextArea();
jTextAreaCopyright.setLineWrap(true);
}
return jTextAreaCopyright;
}
/**
This method initializes jTextAreaDescription
@return javax.swing.JTextArea jTextAreaDescription
**/
private JTextArea getJTextAreaDescription() {
if (jTextAreaDescription == null) {
jTextAreaDescription = new JTextArea();
jTextAreaDescription.setLineWrap(true);
}
return jTextAreaDescription;
}
/**
This method initializes jTextFieldSpecification
@return javax.swing.JTextField jTextFieldSpecification
**/
private JTextField getJTextFieldSpecification() {
if (jTextFieldSpecification == null) {
jTextFieldSpecification = new JTextField();
jTextFieldSpecification.setBounds(new java.awt.Rectangle(160, 340, 220, 20));
}
return jTextFieldSpecification;
}
/**
This method initializes jTextFieldSpecificationVersion
@return javax.swing.JTextField jTextFieldSpecificationVersion
**/
private JTextField getJTextFieldSpecificationVersion() {
if (jTextFieldSpecificationVersion == null) {
jTextFieldSpecificationVersion = new JTextField();
jTextFieldSpecificationVersion.setBounds(new java.awt.Rectangle(400, 340, 80, 20));
}
return jTextFieldSpecificationVersion;
}
/**
This method initializes jButtonOk
@return javax.swing.JButton jButtonOk
**/
private JButton getJButtonOk() {
if (jButtonOk == null) {
jButtonOk = new JButton();
jButtonOk.setText("OK");
jButtonOk.setBounds(new java.awt.Rectangle(290, 445, 90, 20));
jButtonOk.addActionListener(this);
}
return jButtonOk;
}
/**
This method initializes jButtonCancel
@return javax.swing.JButton jButtonCancel
**/
private JButton getJButtonCancel() {
if (jButtonCancel == null) {
jButtonCancel = new JButton();
jButtonCancel.setText("Cancel");
jButtonCancel.setBounds(new java.awt.Rectangle(390, 445, 90, 20));
jButtonCancel.addActionListener(this);
}
return jButtonCancel;
}
/**
This method initializes jScrollPaneLicense
@return javax.swing.JScrollPane jScrollPaneLicense
**/
private JScrollPane getJScrollPaneLicense() {
if (jScrollPaneLicense == null) {
jScrollPaneLicense = new JScrollPane();
jScrollPaneLicense.setBounds(new java.awt.Rectangle(160, 85, 320, 80));
jScrollPaneLicense.setHorizontalScrollBarPolicy(javax.swing.JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
jScrollPaneLicense.setViewportView(getJTextAreaLicense());
}
return jScrollPaneLicense;
}
/**
This method initializes jScrollPaneCopyright
@return javax.swing.JScrollPane jScrollPaneCopyright
**/
private JScrollPane getJScrollPaneCopyright() {
if (jScrollPaneCopyright == null) {
jScrollPaneCopyright = new JScrollPane();
jScrollPaneCopyright.setBounds(new java.awt.Rectangle(160, 170, 320, 80));
jScrollPaneCopyright.setHorizontalScrollBarPolicy(javax.swing.JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
jScrollPaneCopyright.setViewportView(getJTextAreaCopyright());
}
return jScrollPaneCopyright;
}
/**
This method initializes jScrollPaneDescription
@return javax.swing.JScrollPane jScrollPaneDescription
**/
private JScrollPane getJScrollPaneDescription() {
if (jScrollPaneDescription == null) {
jScrollPaneDescription = new JScrollPane();
jScrollPaneDescription.setBounds(new java.awt.Rectangle(160, 255, 320, 80));
jScrollPaneDescription.setHorizontalScrollBarPolicy(javax.swing.JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
jScrollPaneDescription.setViewportView(getJTextAreaDescription());
}
return jScrollPaneDescription;
}
/**
This method initializes jTextFieldAbstract
@return javax.swing.JTextField jTextFieldAbstract
**/
private JTextField getJTextFieldAbstract() {
if (jTextFieldAbstract == null) {
jTextFieldAbstract = new JTextField();
jTextFieldAbstract.setBounds(new java.awt.Rectangle(160, 365, 200, 20));
}
return jTextFieldAbstract;
}
/**
This method initializes jComboBoxCompontentType
@return javax.swing.JComboBox jComboBoxCompontentType
**/
private JComboBox getJComboBoxCompontentType() {
if (jComboBoxCompontentType == null) {
jComboBoxCompontentType = new JComboBox();
jComboBoxCompontentType.setBounds(new java.awt.Rectangle(160, 415, 320, 20));
}
return jComboBoxCompontentType;
}
/**
This method initializes jComboBoxModuleType
@return javax.swing.JComboBox jComboBoxModuleType
**/
private JComboBox getJComboBoxModuleType() {
if (jComboBoxModuleType == null) {
jComboBoxModuleType = new JComboBox();
jComboBoxModuleType.setBounds(new java.awt.Rectangle(160, 390, 320, 20));
}
return jComboBoxModuleType;
}
/**
This method initializes jTextFieldAbstractURL
@return javax.swing.JTextField jTextFieldAbstractURL
**/
private JTextField getJTextFieldAbstractURL() {
if (jTextFieldAbstractURL == null) {
jTextFieldAbstractURL = new JTextField();
jTextFieldAbstractURL.setBounds(new java.awt.Rectangle(390, 365, 90, 20));
}
return jTextFieldAbstractURL;
}
public static void main(String[] args) {
}
/**
This is the default constructor
**/
public MsaHeader() {
super();
init();
this.setVisible(true);
}
/**
This is the override edit constructor
@param inMsaHeader The input data of MsaHeaderDocument.MsaHeader
**/
public MsaHeader(MsaHeaderDocument.MsaHeader inMsaHeader) {
super();
init(inMsaHeader);
this.setVisible(true);
this.setViewMode(false);
}
/**
Disable all components when the mode is view
@param isView true - The view mode; false - The non-view mode
**/
public void setViewMode(boolean isView) {
this.jButtonOk.setVisible(false);
this.jButtonCancel.setVisible(false);
if (isView) {
this.jTextFieldBaseName.setEnabled(!isView);
this.jTextFieldGuid.setEnabled(!isView);
this.jTextFieldVersion.setEnabled(!isView);
this.jTextAreaLicense.setEnabled(!isView);
this.jTextAreaCopyright.setEnabled(!isView);
this.jTextAreaDescription.setEnabled(!isView);
this.jTextFieldSpecification.setEnabled(!isView);
this.jTextFieldSpecificationVersion.setEnabled(!isView);
this.jTextFieldAbstract.setEnabled(!isView);
this.jTextFieldAbstractURL.setEnabled(!isView);
this.jComboBoxModuleType.setEnabled(!isView);
this.jComboBoxCompontentType.setEnabled(!isView);
this.jButtonCancel.setEnabled(!isView);
this.jButtonGenerateGuid.setEnabled(!isView);
this.jButtonOk.setEnabled(!isView);
}
}
/**
This method initializes this
**/
private void init() {
this.setSize(500, 515);
this.setContentPane(getJContentPane());
this.setTitle("Module Surface Area Header");
initFrame();
}
/**
This method initializes this
Fill values to all fields if these values are not empty
@param inMsaHeader The input data of MsaHeaderDocument.MsaHeader
**/
private void init(MsaHeaderDocument.MsaHeader inMsaHeader) {
init();
if (inMsaHeader != null) {
setMsaHeader(inMsaHeader);
if (this.msaHeader.getBaseName() != null) {
this.jTextFieldBaseName.setText(this.msaHeader.getBaseName().getStringValue());
}
if (this.msaHeader.getGuid() != null) {
this.jTextFieldGuid.setText(this.msaHeader.getGuid().getStringValue());
}
if (this.msaHeader.getVersion() != null) {
this.jTextFieldVersion.setText(this.msaHeader.getVersion());
}
if (this.msaHeader.getLicense() != null) {
this.jTextAreaLicense.setText(this.msaHeader.getLicense().getStringValue());
}
if (this.msaHeader.getCopyright() != null) {
this.jTextAreaCopyright.setText(this.msaHeader.getCopyright());
}
if (this.msaHeader.getDescription() != null) {
this.jTextAreaDescription.setText(this.msaHeader.getDescription());
}
if (this.msaHeader.getSpecification() != null) {
this.jTextFieldSpecification.setText(this.msaHeader.getSpecification().getStringValue());
}
if (this.msaHeader.getSpecification() != null) {
this.jTextFieldSpecificationVersion.setText(this.msaHeader.getSpecification().getVersion());
}
if (this.msaHeader.getAbstract() != null) {
this.jTextFieldAbstract.setText(this.msaHeader.getAbstract().getStringValue());
this.jTextFieldAbstractURL.setText(this.msaHeader.getAbstract().getURL());
}
if (this.msaHeader.getModuleType() != null) {
this.jComboBoxModuleType.setSelectedItem(this.msaHeader.getModuleType().toString());
}
if (this.msaHeader.getComponentType() != null) {
this.jComboBoxCompontentType.setSelectedItem(this.msaHeader.getComponentType().toString());
}
}
}
/**
This method initializes jContentPane
@return javax.swing.JPanel jContentPane
**/
private JPanel getJContentPane() {
if (jContentPane == null) {
jLabelURL = new JLabel();
jLabelURL.setBounds(new java.awt.Rectangle(365, 365, 25, 20));
jLabelURL.setText("URL");
jLabelCompontentType = new JLabel();
jLabelCompontentType.setBounds(new java.awt.Rectangle(15, 415, 140, 20));
jLabelCompontentType.setText("Compontent Type");
jLabelModuleType = new JLabel();
jLabelModuleType.setBounds(new java.awt.Rectangle(15, 390, 140, 20));
jLabelModuleType.setText("Module Type");
jLabelAbstract = new JLabel();
jLabelAbstract.setBounds(new java.awt.Rectangle(15, 365, 140, 20));
jLabelAbstract.setText("Abstract");
jLabelSpecVersion = new JLabel();
jLabelSpecVersion.setBounds(new java.awt.Rectangle(382, 340, 15, 20));
jLabelSpecVersion.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
jLabelSpecVersion.setText("V");
jLabelSpecification = new JLabel();
jLabelSpecification.setText("Specification");
jLabelSpecification.setBounds(new java.awt.Rectangle(15, 340, 140, 20));
jLabelDescription = new JLabel();
jLabelDescription.setText("Description");
jLabelDescription.setBounds(new java.awt.Rectangle(15, 255, 140, 20));
jLabelCopyright = new JLabel();
jLabelCopyright.setText("Copyright");
jLabelCopyright.setBounds(new java.awt.Rectangle(15, 170, 140, 20));
jLabelLicense = new JLabel();
jLabelLicense.setText("License");
jLabelLicense.setBounds(new java.awt.Rectangle(15, 85, 140, 20));
jLabelVersion = new JLabel();
jLabelVersion.setText("Version");
jLabelVersion.setBounds(new java.awt.Rectangle(15, 60, 140, 20));
jLabelGuid = new JLabel();
jLabelGuid.setPreferredSize(new java.awt.Dimension(25, 15));
jLabelGuid.setBounds(new java.awt.Rectangle(15, 35, 140, 20));
jLabelGuid.setText("Guid");
jLabelBaseName = new JLabel();
jLabelBaseName.setText("Base Name");
jLabelBaseName.setBounds(new java.awt.Rectangle(15, 10, 140, 20));
jContentPane = new JPanel();
jContentPane.setLayout(null);
jContentPane.setLocation(new java.awt.Point(0, 0));
jContentPane.setSize(new java.awt.Dimension(500, 524));
jContentPane.add(jLabelBaseName, null);
jContentPane.add(getJTextFieldBaseName(), null);
jContentPane.add(jLabelGuid, null);
jContentPane.add(getJTextFieldGuid(), null);
jContentPane.add(jLabelVersion, null);
jContentPane.add(getJTextFieldVersion(), null);
jContentPane.add(getJButtonGenerateGuid(), null);
jContentPane.add(jLabelLicense, null);
jContentPane.add(jLabelCopyright, null);
jContentPane.add(jLabelDescription, null);
jContentPane.add(jLabelSpecification, null);
jContentPane.add(getJTextFieldSpecification(), null);
jContentPane.add(getJTextFieldSpecificationVersion(), null);
jContentPane.add(getJButtonOk(), null);
jContentPane.add(getJButtonCancel(), null);
jContentPane.add(getJScrollPaneLicense(), null);
jContentPane.add(getJScrollPaneCopyright(), null);
jContentPane.add(getJScrollPaneDescription(), null);
jContentPane.add(jLabelAbstract, null);
jContentPane.add(getJTextFieldAbstract(), null);
jContentPane.add(jLabelSpecVersion, null);
jContentPane.add(jLabelModuleType, null);
jContentPane.add(jLabelCompontentType, null);
jContentPane.add(getJComboBoxCompontentType(), null);
jContentPane.add(getJComboBoxModuleType(), null);
jStarLabel1 = new StarLabel();
jStarLabel1.setLocation(new java.awt.Point(0, 10));
jStarLabel2 = new StarLabel();
jStarLabel2.setLocation(new java.awt.Point(0, 35));
jStarLabel3 = new StarLabel();
jStarLabel3.setLocation(new java.awt.Point(0, 60));
jStarLabel4 = new StarLabel();
jStarLabel4.setLocation(new java.awt.Point(0, 85));
jStarLabel5 = new StarLabel();
jStarLabel5.setLocation(new java.awt.Point(0, 170));
jStarLabel6 = new StarLabel();
jStarLabel6.setLocation(new java.awt.Point(0, 255));
jStarLabel7 = new StarLabel();
jStarLabel7.setLocation(new java.awt.Point(0, 365));
jStarLabel8 = new StarLabel();
jStarLabel8.setLocation(new java.awt.Point(0, 390));
jStarLabel9 = new StarLabel();
jStarLabel9.setLocation(new java.awt.Point(0, 415));
jContentPane.add(jStarLabel1, null);
jContentPane.add(jStarLabel2, null);
jContentPane.add(jStarLabel3, null);
jContentPane.add(jStarLabel4, null);
jContentPane.add(jStarLabel5, null);
jContentPane.add(jStarLabel6, null);
jContentPane.add(jStarLabel7, null);
jContentPane.add(jStarLabel8, null);
jContentPane.add(jStarLabel9, null);
jContentPane.add(jLabelURL, null);
jContentPane.add(getJTextFieldAbstractURL(), null);
}
return jContentPane;
}
/* (non-Javadoc)
* @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
*
* Override actionPerformed to listen all actions
*
*/
public void actionPerformed(ActionEvent arg0) {
if (arg0.getSource() == jButtonOk) {
this.save();
this.setEdited(true);
}
if (arg0.getSource() == jButtonCancel) {
this.setEdited(false);
}
if (arg0.getSource() == jButtonGenerateGuid) {
jTextFieldGuid.setText(Tools.generateUuidString());
}
}
/**
Data validation for all fields
@retval true - All datas are valid
@retval false - At least one data is invalid
**/
public boolean check() {
//
// Check if all required fields are not empty
//
if (isEmpty(this.jTextFieldBaseName.getText())) {
Log.err("Base Name couldn't be empty");
return false;
}
if (isEmpty(this.jTextFieldGuid.getText())) {
Log.err("Guid couldn't be empty");
return false;
}
if (isEmpty(this.jTextFieldVersion.getText())) {
Log.err("Version couldn't be empty");
return false;
}
if (isEmpty(this.jTextAreaLicense.getText())) {
Log.err("License couldn't be empty");
return false;
}
if (isEmpty(this.jTextAreaCopyright.getText())) {
Log.err("Copyright couldn't be empty");
return false;
}
if (isEmpty(this.jTextAreaDescription.getText())) {
Log.err("Description couldn't be empty");
return false;
}
if (isEmpty(this.jTextFieldAbstract.getText())) {
Log.err("Abstract couldn't be empty");
return false;
}
//
// Check if all fields have correct data types
//
if (!DataValidation.isBaseName(this.jTextFieldBaseName.getText())) {
Log.err("Incorrect data type for Base Name");
return false;
}
if (!DataValidation.isGuid((this.jTextFieldGuid).getText())) {
Log.err("Incorrect data type for Guid");
return false;
}
if (!DataValidation.isAbstract(this.jTextFieldAbstract.getText())) {
Log.err("Incorrect data type for Abstract");
return false;
}
if (!DataValidation.isCopyright(this.jTextAreaCopyright.getText())) {
Log.err("Incorrect data type for Copyright");
return false;
}
return true;
}
/**
Save all components of Msa Header
if exists msaHeader, set the value directly
if not exists msaHeader, new an instance first
**/
public void save() {
try {
if (this.msaHeader == null) {
msaHeader = MsaHeaderDocument.MsaHeader.Factory.newInstance();
}
if (this.msaHeader.getBaseName() != null) {
this.msaHeader.getBaseName().setStringValue(this.jTextFieldBaseName.getText());
} else {
BaseNameDocument.BaseName mBaseName = BaseNameDocument.BaseName.Factory.newInstance();
mBaseName.setStringValue(this.jTextFieldBaseName.getText());
this.msaHeader.setBaseName(mBaseName);
}
if (this.msaHeader.getGuid() != null) {
this.msaHeader.getGuid().setStringValue(this.jTextFieldGuid.getText());
} else {
GuidDocument.Guid mGuid = GuidDocument.Guid.Factory.newInstance();
mGuid.setStringValue(this.jTextFieldGuid.getText());
this.msaHeader.setGuid(mGuid);
}
this.msaHeader.setVersion(this.jTextFieldVersion.getText());
if (this.msaHeader.getLicense() != null) {
this.msaHeader.getLicense().setStringValue(this.jTextAreaLicense.getText());
} else {
LicenseDocument.License mLicense = LicenseDocument.License.Factory.newInstance();
mLicense.setStringValue(this.jTextAreaLicense.getText());
this.msaHeader.setLicense(mLicense);
}
this.msaHeader.setCopyright(this.jTextAreaCopyright.getText());
this.msaHeader.setDescription(this.jTextAreaDescription.getText());
if (this.msaHeader.getSpecification() != null) {
this.msaHeader.getSpecification().setStringValue(this.jTextFieldSpecification.getText());
this.msaHeader.getSpecification().setVersion(this.jTextFieldSpecificationVersion.getText());
} else {
SpecificationDocument.Specification mSpecification = SpecificationDocument.Specification.Factory
.newInstance();
mSpecification.setStringValue(this.jTextFieldSpecification.getText());
mSpecification.setVersion(this.jTextFieldSpecificationVersion.getText());
this.msaHeader.setSpecification(mSpecification);
}
if (this.msaHeader.getAbstract() != null) {
this.msaHeader.getAbstract().setStringValue(this.jTextFieldAbstract.getText());
this.msaHeader.getAbstract().setURL(this.jTextFieldAbstractURL.getText());
} else {
AbstractDocument.Abstract mAbstract = AbstractDocument.Abstract.Factory.newInstance();
mAbstract.setStringValue(this.jTextFieldAbstract.getText());
mAbstract.setURL(this.jTextFieldAbstractURL.getText());
this.msaHeader.setAbstract(mAbstract);
}
this.msaHeader.setModuleType(ModuleTypeDef.Enum.forString(this.jComboBoxModuleType.getSelectedItem()
.toString()));
this.msaHeader
.setComponentType(FrameworkComponentTypes.Enum
.forString(this.jComboBoxCompontentType
.getSelectedItem()
.toString()));
if (this.msaHeader.getCreated() == null) {
this.msaHeader.setCreated(Tools.getCurrentDateTime());
} else {
this.msaHeader.setUpdated(Tools.getCurrentDateTime());
}
} catch (Exception e) {
Log.err("Save Module", e.getMessage());
}
}
/**
This method initializes Module type and Compontent type
**/
private void initFrame() {
jComboBoxModuleType.addItem("BASE");
jComboBoxModuleType.addItem("SEC");
jComboBoxModuleType.addItem("PEI_CORE");
jComboBoxModuleType.addItem("PEIM");
jComboBoxModuleType.addItem("DXE_CORE");
jComboBoxModuleType.addItem("DXE_DRIVER");
jComboBoxModuleType.addItem("DXE_RUNTIME_DRIVER");
jComboBoxModuleType.addItem("DXE_SAL_DRIVER");
jComboBoxModuleType.addItem("DXE_SMM_DRIVER");
jComboBoxModuleType.addItem("TOOLS");
jComboBoxModuleType.addItem("UEFI_DRIVER");
jComboBoxModuleType.addItem("UEFI_APPLICATION");
jComboBoxModuleType.addItem("USER_DEFINED");
jComboBoxCompontentType.addItem("APRIORI");
jComboBoxCompontentType.addItem("LIBRARY");
jComboBoxCompontentType.addItem("FV_IMAGE_FILE");
jComboBoxCompontentType.addItem("BS_DRIVER");
jComboBoxCompontentType.addItem("RT_DRIVER");
jComboBoxCompontentType.addItem("SAL_RT_DRIVER");
jComboBoxCompontentType.addItem("PE32_PEIM");
jComboBoxCompontentType.addItem("PIC_PEIM");
jComboBoxCompontentType.addItem("COMBINED_PEIM_DRIVER");
jComboBoxCompontentType.addItem("PEI_CORE");
jComboBoxCompontentType.addItem("DXE_CORE");
jComboBoxCompontentType.addItem("APPLICATION");
jComboBoxCompontentType.addItem("BS_DRIVER_EFI");
jComboBoxCompontentType.addItem("SHELLAPP");
}
/**
Get MsaHeaderDocument.MsaHeader
@return MsaHeaderDocument.MsaHeader
**/
public MsaHeaderDocument.MsaHeader getMsaHeader() {
return msaHeader;
}
/**
Set MsaHeaderDocument.MsaHeader
@param msaHeader The input data of MsaHeaderDocument.MsaHeader
**/
public void setMsaHeader(MsaHeaderDocument.MsaHeader msaHeader) {
this.msaHeader = msaHeader;
}
}

View File

@ -0,0 +1,845 @@
/** @file
The file is used to create, update MsaLibHeader of a MSA file
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.packaging.module.ui;
import java.awt.event.ActionEvent;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import org.tianocore.AbstractDocument;
import org.tianocore.BaseNameDocument;
import org.tianocore.FrameworkComponentTypes;
import org.tianocore.GuidDocument;
import org.tianocore.LicenseDocument;
import org.tianocore.ModuleTypeDef;
import org.tianocore.MsaLibHeaderDocument;
import org.tianocore.SpecificationDocument;
import org.tianocore.common.DataValidation;
import org.tianocore.common.Log;
import org.tianocore.common.Tools;
import org.tianocore.packaging.common.ui.IInternalFrame;
import org.tianocore.packaging.common.ui.StarLabel;
/**
The class is used to create, update MsaLibHeader of a MSA file
It extends IInternalFrame
@since ModuleEditor 1.0
**/
public class MsaLibHeader extends IInternalFrame {
///
/// Define class Serial Version UID
///
private static final long serialVersionUID = 5526729363068526262L;
//
//Define class members
//
private JPanel jContentPane = null;
private JLabel jLabelBaseName = null;
private JTextField jTextFieldBaseName = null;
private JLabel jLabelGuid = null;
private JTextField jTextFieldGuid = null;
private JLabel jLabelVersion = null;
private JTextField jTextFieldVersion = null;
private JButton jButtonGenerateGuid = null;
private JLabel jLabelLicense = null;
private JTextArea jTextAreaLicense = null;
private JLabel jLabelCopyright = null;
private JTextArea jTextAreaCopyright = null;
private JLabel jLabelDescription = null;
private JTextArea jTextAreaDescription = null;
private JLabel jLabelSpecification = null;
private JTextField jTextFieldSpecification = null;
private JTextField jTextFieldSpecificationVersion = null;
private JButton jButtonOk = null;
private JButton jButtonCancel = null;
private JScrollPane jScrollPaneLicense = null;
private JScrollPane jScrollPaneCopyright = null;
private JScrollPane jScrollPaneDescription = null;
private JLabel jLabelSpecVersion = null;
private JLabel jLabelAbstract = null;
private JTextField jTextFieldAbstract = null;
private JLabel jLabelModuleType = null;
private JLabel jLabelCompontentType = null;
private JComboBox jComboBoxCompontentType = null;
private JComboBox jComboBoxModuleType = null;
private StarLabel jStarLabel1 = null;
private StarLabel jStarLabel2 = null;
private StarLabel jStarLabel3 = null;
private StarLabel jStarLabel4 = null;
private StarLabel jStarLabel5 = null;
private StarLabel jStarLabel6 = null;
private StarLabel jStarLabel7 = null;
private StarLabel jStarLabel8 = null;
private StarLabel jStarLabel9 = null;
private MsaLibHeaderDocument.MsaLibHeader msaLibHeader = null;
private JLabel jLabelURL = null;
private JTextField jTextFieldAbstractURL = null;
/**
This method initializes jTextFieldBaseName
@return javax.swing.JTextField jTextFieldBaseName
**/
private JTextField getJTextFieldBaseName() {
if (jTextFieldBaseName == null) {
jTextFieldBaseName = new JTextField();
jTextFieldBaseName.setBounds(new java.awt.Rectangle(160, 10, 320, 20));
}
return jTextFieldBaseName;
}
/**
This method initializes jTextFieldGuid
@return javax.swing.JTextField jTextFieldGuid
**/
private JTextField getJTextFieldGuid() {
if (jTextFieldGuid == null) {
jTextFieldGuid = new JTextField();
jTextFieldGuid.setBounds(new java.awt.Rectangle(160, 35, 240, 20));
}
return jTextFieldGuid;
}
/**
This method initializes jTextFieldVersion
@return javax.swing.JTextField jTextFieldVersion
**/
private JTextField getJTextFieldVersion() {
if (jTextFieldVersion == null) {
jTextFieldVersion = new JTextField();
jTextFieldVersion.setBounds(new java.awt.Rectangle(160, 60, 320, 20));
}
return jTextFieldVersion;
}
/**
This method initializes jButtonGenerateGuid
@return javax.swing.JButton jButtonGenerateGuid
**/
private JButton getJButtonGenerateGuid() {
if (jButtonGenerateGuid == null) {
jButtonGenerateGuid = new JButton();
jButtonGenerateGuid.setBounds(new java.awt.Rectangle(405, 35, 75, 20));
jButtonGenerateGuid.setText("GEN");
jButtonGenerateGuid.addActionListener(this);
}
return jButtonGenerateGuid;
}
/**
This method initializes jTextAreaLicense
@return javax.swing.JTextArea jTextAreaLicense
**/
private JTextArea getJTextAreaLicense() {
if (jTextAreaLicense == null) {
jTextAreaLicense = new JTextArea();
jTextAreaLicense.setText("");
jTextAreaLicense.setLineWrap(true);
}
return jTextAreaLicense;
}
/**
This method initializes jTextAreaCopyright
@return javax.swing.JTextArea jTextAreaCopyright
**/
private JTextArea getJTextAreaCopyright() {
if (jTextAreaCopyright == null) {
jTextAreaCopyright = new JTextArea();
jTextAreaCopyright.setLineWrap(true);
}
return jTextAreaCopyright;
}
/**
This method initializes jTextAreaDescription
@return javax.swing.JTextArea jTextAreaDescription
**/
private JTextArea getJTextAreaDescription() {
if (jTextAreaDescription == null) {
jTextAreaDescription = new JTextArea();
jTextAreaDescription.setLineWrap(true);
}
return jTextAreaDescription;
}
/**
This method initializes jTextFieldSpecification
@return javax.swing.JTextField jTextFieldSpecification
**/
private JTextField getJTextFieldSpecification() {
if (jTextFieldSpecification == null) {
jTextFieldSpecification = new JTextField();
jTextFieldSpecification.setBounds(new java.awt.Rectangle(160, 340, 220, 20));
}
return jTextFieldSpecification;
}
/**
This method initializes jTextFieldSpecificationVersion
@return javax.swing.JTextField jTextFieldSpecificationVersion
**/
private JTextField getJTextFieldSpecificationVersion() {
if (jTextFieldSpecificationVersion == null) {
jTextFieldSpecificationVersion = new JTextField();
jTextFieldSpecificationVersion.setBounds(new java.awt.Rectangle(400, 340, 80, 20));
}
return jTextFieldSpecificationVersion;
}
/**
This method initializes jButtonOk
@return javax.swing.JButton jButtonOk
**/
private JButton getJButtonOk() {
if (jButtonOk == null) {
jButtonOk = new JButton();
jButtonOk.setText("OK");
jButtonOk.setBounds(new java.awt.Rectangle(290, 445, 90, 20));
jButtonOk.addActionListener(this);
}
return jButtonOk;
}
/**
This method initializes jButtonCancel
@return javax.swing.JButton jButtonCancel
**/
private JButton getJButtonCancel() {
if (jButtonCancel == null) {
jButtonCancel = new JButton();
jButtonCancel.setText("Cancel");
jButtonCancel.setBounds(new java.awt.Rectangle(390, 445, 90, 20));
jButtonCancel.addActionListener(this);
}
return jButtonCancel;
}
/**
This method initializes jScrollPaneLicense
@return javax.swing.JScrollPane jScrollPaneLicense
**/
private JScrollPane getJScrollPaneLicense() {
if (jScrollPaneLicense == null) {
jScrollPaneLicense = new JScrollPane();
jScrollPaneLicense.setBounds(new java.awt.Rectangle(160, 85, 320, 80));
jScrollPaneLicense.setHorizontalScrollBarPolicy(javax.swing.JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
jScrollPaneLicense.setViewportView(getJTextAreaLicense());
}
return jScrollPaneLicense;
}
/**
This method initializes jScrollPaneCopyright
@return javax.swing.JScrollPane jScrollPaneCopyright
**/
private JScrollPane getJScrollPaneCopyright() {
if (jScrollPaneCopyright == null) {
jScrollPaneCopyright = new JScrollPane();
jScrollPaneCopyright.setBounds(new java.awt.Rectangle(160, 170, 320, 80));
jScrollPaneCopyright.setHorizontalScrollBarPolicy(javax.swing.JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
jScrollPaneCopyright.setViewportView(getJTextAreaCopyright());
}
return jScrollPaneCopyright;
}
/**
This method initializes jScrollPaneDescription
@return javax.swing.JScrollPane jScrollPaneDescription
**/
private JScrollPane getJScrollPaneDescription() {
if (jScrollPaneDescription == null) {
jScrollPaneDescription = new JScrollPane();
jScrollPaneDescription.setBounds(new java.awt.Rectangle(160, 255, 320, 80));
jScrollPaneDescription.setHorizontalScrollBarPolicy(javax.swing.JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
jScrollPaneDescription.setViewportView(getJTextAreaDescription());
}
return jScrollPaneDescription;
}
/**
This method initializes jTextFieldAbstract
@return javax.swing.JTextField jTextFieldAbstract
**/
private JTextField getJTextFieldAbstract() {
if (jTextFieldAbstract == null) {
jTextFieldAbstract = new JTextField();
jTextFieldAbstract.setBounds(new java.awt.Rectangle(160, 365, 200, 20));
}
return jTextFieldAbstract;
}
/**
This method initializes jComboBoxCompontentType
@return javax.swing.JComboBox jComboBoxCompontentType
**/
private JComboBox getJComboBoxCompontentType() {
if (jComboBoxCompontentType == null) {
jComboBoxCompontentType = new JComboBox();
jComboBoxCompontentType.setBounds(new java.awt.Rectangle(160, 415, 320, 20));
}
return jComboBoxCompontentType;
}
/**
This method initializes jComboBoxModuleType
@return javax.swing.JComboBox jComboBoxModuleType
**/
private JComboBox getJComboBoxModuleType() {
if (jComboBoxModuleType == null) {
jComboBoxModuleType = new JComboBox();
jComboBoxModuleType.setBounds(new java.awt.Rectangle(160, 390, 320, 20));
}
return jComboBoxModuleType;
}
/**
This method initializes jTextFieldAbstractURL
@return javax.swing.JTextField jTextFieldAbstractURL
**/
private JTextField getJTextFieldAbstractURL() {
if (jTextFieldAbstractURL == null) {
jTextFieldAbstractURL = new JTextField();
jTextFieldAbstractURL.setBounds(new java.awt.Rectangle(390, 365, 90, 20));
}
return jTextFieldAbstractURL;
}
public static void main(String[] args) {
}
/**
This is the default constructor
**/
public MsaLibHeader() {
super();
init();
this.setVisible(true);
}
/**
This is the override edit constructor
@param inMsaLibHeader The input data of MsaLibHeaderDocument.MsaLibHeader
**/
public MsaLibHeader(MsaLibHeaderDocument.MsaLibHeader inMsaLibHeader) {
super();
init(inMsaLibHeader);
this.setVisible(true);
this.setViewMode(false);
}
/**
This method initializes this
**/
private void init() {
this.setSize(500, 515);
this.setContentPane(getJContentPane());
this.setTitle("Library Module");
initFrame();
}
/**
This method initializes this
Fill values to all fields if these values are not empty
@param inMsaLibHeader The input data of MsaLibHeaderDocument.MsaLibHeader
**/
private void init(MsaLibHeaderDocument.MsaLibHeader inMsaLibHeader) {
init();
this.setMsaLibHeader(inMsaLibHeader);
if (inMsaLibHeader != null) {
if (this.msaLibHeader.getBaseName() != null) {
this.jTextFieldBaseName.setText(this.msaLibHeader.getBaseName().getStringValue());
}
if (this.msaLibHeader.getGuid() != null) {
this.jTextFieldGuid.setText(this.msaLibHeader.getGuid().getStringValue());
}
if (this.msaLibHeader.getVersion() != null) {
this.jTextFieldVersion.setText(this.msaLibHeader.getVersion());
}
if (this.msaLibHeader.getLicense() != null) {
this.jTextAreaLicense.setText(this.msaLibHeader.getLicense().getStringValue());
}
if (this.msaLibHeader.getCopyright() != null) {
this.jTextAreaCopyright.setText(this.msaLibHeader.getCopyright());
}
if (this.msaLibHeader.getDescription() != null) {
this.jTextAreaDescription.setText(this.msaLibHeader.getDescription());
}
if (this.msaLibHeader.getSpecification() != null) {
this.jTextFieldSpecification.setText(this.msaLibHeader.getSpecification().getStringValue());
}
if (this.msaLibHeader.getSpecification() != null) {
this.jTextFieldSpecificationVersion.setText(this.msaLibHeader.getSpecification().getVersion());
}
if (this.msaLibHeader.getAbstract() != null) {
this.jTextFieldAbstract.setText(this.msaLibHeader.getAbstract().getStringValue());
this.jTextFieldAbstractURL.setText(this.msaLibHeader.getAbstract().getURL());
}
if (this.msaLibHeader.getModuleType() != null) {
this.jComboBoxModuleType.setSelectedItem(this.msaLibHeader.getModuleType().toString());
}
if (this.msaLibHeader.getComponentType() != null) {
this.jComboBoxCompontentType.setSelectedItem(this.msaLibHeader.getComponentType().toString());
}
}
}
/**
Disable all components when the mode is view
@param isView true - The view mode; false - The non-view mode
**/
public void setViewMode(boolean isView) {
this.jButtonOk.setVisible(false);
this.jButtonCancel.setVisible(false);
if (isView) {
this.jTextFieldBaseName.setEnabled(!isView);
this.jTextFieldGuid.setEnabled(!isView);
this.jTextFieldVersion.setEnabled(!isView);
this.jTextAreaLicense.setEnabled(!isView);
this.jTextAreaCopyright.setEnabled(!isView);
this.jTextAreaDescription.setEnabled(!isView);
this.jTextFieldSpecification.setEnabled(!isView);
this.jTextFieldSpecificationVersion.setEnabled(!isView);
this.jTextFieldAbstract.setEnabled(!isView);
this.jTextFieldAbstractURL.setEnabled(!isView);
this.jComboBoxModuleType.setEnabled(!isView);
this.jComboBoxCompontentType.setEnabled(!isView);
this.jButtonCancel.setEnabled(!isView);
this.jButtonGenerateGuid.setEnabled(!isView);
this.jButtonOk.setEnabled(!isView);
}
}
/**
This method initializes jContentPane
@return javax.swing.JPanel jContentPane
**/
private JPanel getJContentPane() {
if (jContentPane == null) {
jLabelURL = new JLabel();
jLabelURL.setBounds(new java.awt.Rectangle(365, 365, 25, 20));
jLabelURL.setText("URL");
jLabelCompontentType = new JLabel();
jLabelCompontentType.setBounds(new java.awt.Rectangle(15, 415, 140, 20));
jLabelCompontentType.setText("Compontent Type");
jLabelModuleType = new JLabel();
jLabelModuleType.setBounds(new java.awt.Rectangle(15, 390, 140, 20));
jLabelModuleType.setText("Module Type");
jLabelAbstract = new JLabel();
jLabelAbstract.setBounds(new java.awt.Rectangle(15, 365, 140, 20));
jLabelAbstract.setText("Abstract");
jLabelSpecVersion = new JLabel();
jLabelSpecVersion.setBounds(new java.awt.Rectangle(382, 340, 15, 20));
jLabelSpecVersion.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
jLabelSpecVersion.setText("V");
jLabelSpecification = new JLabel();
jLabelSpecification.setText("Specification");
jLabelSpecification.setBounds(new java.awt.Rectangle(15, 340, 140, 20));
jLabelDescription = new JLabel();
jLabelDescription.setText("Description");
jLabelDescription.setBounds(new java.awt.Rectangle(15, 255, 140, 20));
jLabelCopyright = new JLabel();
jLabelCopyright.setText("Copyright");
jLabelCopyright.setBounds(new java.awt.Rectangle(15, 170, 140, 20));
jLabelLicense = new JLabel();
jLabelLicense.setText("License");
jLabelLicense.setBounds(new java.awt.Rectangle(15, 85, 140, 20));
jLabelVersion = new JLabel();
jLabelVersion.setText("Version");
jLabelVersion.setBounds(new java.awt.Rectangle(15, 60, 140, 20));
jLabelGuid = new JLabel();
jLabelGuid.setPreferredSize(new java.awt.Dimension(25, 15));
jLabelGuid.setBounds(new java.awt.Rectangle(15, 35, 140, 20));
jLabelGuid.setText("Guid");
jLabelBaseName = new JLabel();
jLabelBaseName.setText("Base Name");
jLabelBaseName.setBounds(new java.awt.Rectangle(15, 10, 140, 20));
jContentPane = new JPanel();
jContentPane.setLayout(null);
jContentPane.setLocation(new java.awt.Point(0, 0));
jContentPane.setSize(new java.awt.Dimension(500, 524));
jContentPane.add(jLabelBaseName, null);
jContentPane.add(getJTextFieldBaseName(), null);
jContentPane.add(jLabelGuid, null);
jContentPane.add(getJTextFieldGuid(), null);
jContentPane.add(jLabelVersion, null);
jContentPane.add(getJTextFieldVersion(), null);
jContentPane.add(getJButtonGenerateGuid(), null);
jContentPane.add(jLabelLicense, null);
jContentPane.add(jLabelCopyright, null);
jContentPane.add(jLabelDescription, null);
jContentPane.add(jLabelSpecification, null);
jContentPane.add(getJTextFieldSpecification(), null);
jContentPane.add(getJTextFieldSpecificationVersion(), null);
jContentPane.add(getJButtonOk(), null);
jContentPane.add(getJButtonCancel(), null);
jContentPane.add(getJScrollPaneLicense(), null);
jContentPane.add(getJScrollPaneCopyright(), null);
jContentPane.add(getJScrollPaneDescription(), null);
jContentPane.add(jLabelAbstract, null);
jContentPane.add(getJTextFieldAbstract(), null);
jContentPane.add(jLabelSpecVersion, null);
jContentPane.add(jLabelModuleType, null);
jContentPane.add(jLabelCompontentType, null);
jContentPane.add(getJComboBoxCompontentType(), null);
jContentPane.add(getJComboBoxModuleType(), null);
jStarLabel1 = new StarLabel();
jStarLabel1.setLocation(new java.awt.Point(0, 10));
jStarLabel2 = new StarLabel();
jStarLabel2.setLocation(new java.awt.Point(0, 35));
jStarLabel3 = new StarLabel();
jStarLabel3.setLocation(new java.awt.Point(0, 60));
jStarLabel4 = new StarLabel();
jStarLabel4.setLocation(new java.awt.Point(0, 85));
jStarLabel5 = new StarLabel();
jStarLabel5.setLocation(new java.awt.Point(0, 170));
jStarLabel6 = new StarLabel();
jStarLabel6.setLocation(new java.awt.Point(0, 255));
jStarLabel7 = new StarLabel();
jStarLabel7.setLocation(new java.awt.Point(0, 365));
jStarLabel8 = new StarLabel();
jStarLabel8.setLocation(new java.awt.Point(0, 390));
jStarLabel9 = new StarLabel();
jStarLabel9.setLocation(new java.awt.Point(0, 415));
jContentPane.add(jStarLabel1, null);
jContentPane.add(jStarLabel2, null);
jContentPane.add(jStarLabel3, null);
jContentPane.add(jStarLabel4, null);
jContentPane.add(jStarLabel5, null);
jContentPane.add(jStarLabel6, null);
jContentPane.add(jStarLabel7, null);
jContentPane.add(jStarLabel8, null);
jContentPane.add(jStarLabel9, null);
jContentPane.add(jLabelURL, null);
jContentPane.add(getJTextFieldAbstractURL(), null);
}
return jContentPane;
}
/* (non-Javadoc)
* @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
*
* Override actionPerformed to listen all actions
*
*/
public void actionPerformed(ActionEvent arg0) {
if (arg0.getSource() == jButtonOk) {
this.dispose();
this.save();
this.setEdited(true);
}
if (arg0.getSource() == jButtonCancel) {
this.dispose();
this.setEdited(false);
}
if (arg0.getSource() == jButtonGenerateGuid) {
jTextFieldGuid.setText(Tools.generateUuidString());
}
}
/**
Data validation for all fields
@retval true - All datas are valid
@retval false - At least one data is invalid
**/
public boolean check() {
//
// Check if all required fields are not empty
//
if (isEmpty(this.jTextFieldBaseName.getText())) {
Log.err("Base Name couldn't be empty");
return false;
}
if (isEmpty(this.jTextFieldGuid.getText())) {
Log.err("Guid couldn't be empty");
return false;
}
if (isEmpty(this.jTextFieldVersion.getText())) {
Log.err("Version couldn't be empty");
return false;
}
if (isEmpty(this.jTextAreaLicense.getText())) {
Log.err("License couldn't be empty");
return false;
}
if (isEmpty(this.jTextAreaCopyright.getText())) {
Log.err("Copyright couldn't be empty");
return false;
}
if (isEmpty(this.jTextAreaDescription.getText())) {
Log.err("Description couldn't be empty");
return false;
}
if (isEmpty(this.jTextFieldAbstract.getText())) {
Log.err("Abstract couldn't be empty");
return false;
}
//
// Check if all fields have correct data types
//
if (!DataValidation.isBaseName(this.jTextFieldBaseName.getText())) {
Log.err("Incorrect data type for Base Name");
return false;
}
if (!DataValidation.isGuid((this.jTextFieldGuid).getText())) {
Log.err("Incorrect data type for Guid");
return false;
}
if (!DataValidation.isAbstract(this.jTextFieldAbstract.getText())) {
Log.err("Incorrect data type for Abstract");
return false;
}
if (!DataValidation.isCopyright(this.jTextAreaCopyright.getText())) {
Log.err("Incorrect data type for Copyright");
return false;
}
return true;
}
/**
Save all components of Msa Lib Header
if exists msaLibHeader, set the value directly
if not exists msaLibHeader, new an instance first
**/
public void save() {
try {
if (this.msaLibHeader == null) {
msaLibHeader = MsaLibHeaderDocument.MsaLibHeader.Factory.newInstance();
}
if (this.msaLibHeader.getBaseName() != null) {
this.msaLibHeader.getBaseName().setStringValue(this.jTextFieldBaseName.getText());
} else {
BaseNameDocument.BaseName mBaseName = BaseNameDocument.BaseName.Factory.newInstance();
mBaseName.setStringValue(this.jTextFieldBaseName.getText());
this.msaLibHeader.setBaseName(mBaseName);
}
if (this.msaLibHeader.getGuid() != null) {
this.msaLibHeader.getGuid().setStringValue(this.jTextFieldGuid.getText());
} else {
GuidDocument.Guid mGuid = GuidDocument.Guid.Factory.newInstance();
mGuid.setStringValue(this.jTextFieldGuid.getText());
this.msaLibHeader.setGuid(mGuid);
}
this.msaLibHeader.setVersion(this.jTextFieldVersion.getText());
if (this.msaLibHeader.getLicense() != null) {
this.msaLibHeader.getLicense().setStringValue(this.jTextAreaLicense.getText());
} else {
LicenseDocument.License mLicense = LicenseDocument.License.Factory.newInstance();
mLicense.setStringValue(this.jTextAreaLicense.getText());
this.msaLibHeader.setLicense(mLicense);
}
this.msaLibHeader.setCopyright(this.jTextAreaCopyright.getText());
this.msaLibHeader.setDescription(this.jTextAreaDescription.getText());
if (this.msaLibHeader.getSpecification() != null) {
this.msaLibHeader.getSpecification().setStringValue(this.jTextFieldSpecification.getText());
this.msaLibHeader.getSpecification().setVersion(this.jTextFieldSpecificationVersion.getText());
} else {
SpecificationDocument.Specification mSpecification = SpecificationDocument.Specification.Factory
.newInstance();
mSpecification.setStringValue(this.jTextFieldSpecification.getText());
mSpecification.setVersion(this.jTextFieldSpecificationVersion.getText());
this.msaLibHeader.setSpecification(mSpecification);
}
if (this.msaLibHeader.getAbstract() != null) {
this.msaLibHeader.getAbstract().setStringValue(this.jTextFieldAbstract.getText());
this.msaLibHeader.getAbstract().setURL(this.jTextFieldAbstractURL.getText());
} else {
AbstractDocument.Abstract mAbstract = AbstractDocument.Abstract.Factory.newInstance();
mAbstract.setStringValue(this.jTextFieldAbstract.getText());
mAbstract.setURL(this.jTextFieldAbstractURL.getText());
this.msaLibHeader.setAbstract(mAbstract);
}
this.msaLibHeader.setModuleType(ModuleTypeDef.Enum.forString(this.jComboBoxModuleType.getSelectedItem()
.toString()));
this.msaLibHeader
.setComponentType(FrameworkComponentTypes.Enum
.forString(this.jComboBoxCompontentType
.getSelectedItem()
.toString()));
if (this.msaLibHeader.getCreated() == null) {
this.msaLibHeader.setCreated(Tools.getCurrentDateTime());
} else {
this.msaLibHeader.setUpdated(Tools.getCurrentDateTime());
}
} catch (Exception e) {
Log.err("Save Module", e.getMessage());
}
}
/**
This method initializes module type and compontent type
**/
private void initFrame() {
jComboBoxModuleType.addItem("BASE");
jComboBoxModuleType.addItem("SEC");
jComboBoxModuleType.addItem("PEI_CORE");
jComboBoxModuleType.addItem("PEIM");
jComboBoxModuleType.addItem("DXE_CORE");
jComboBoxModuleType.addItem("DXE_DRIVER");
jComboBoxModuleType.addItem("DXE_RUNTIME_DRIVER");
jComboBoxModuleType.addItem("DXE_SMM_DRIVER");
jComboBoxModuleType.addItem("DXE_SAL_DRIVER");
jComboBoxModuleType.addItem("UEFI_DRIVER");
jComboBoxModuleType.addItem("UEFI_APPLICATION");
jComboBoxCompontentType.addItem("APRIORI");
jComboBoxCompontentType.addItem("LIBRARY");
jComboBoxCompontentType.addItem("FV_IMAGE_FILE");
jComboBoxCompontentType.addItem("BS_DRIVER");
jComboBoxCompontentType.addItem("RT_DRIVER");
jComboBoxCompontentType.addItem("SAL_RT_DRIVER");
jComboBoxCompontentType.addItem("PE32_PEIM");
jComboBoxCompontentType.addItem("PIC_PEIM");
jComboBoxCompontentType.addItem("COMBINED_PEIM_DRIVER");
jComboBoxCompontentType.addItem("PEI_CORE");
jComboBoxCompontentType.addItem("DXE_CORE");
jComboBoxCompontentType.addItem("APPLICATION");
jComboBoxCompontentType.addItem("BS_DRIVER_EFI");
jComboBoxCompontentType.addItem("SHELLAPP");
}
/**
Get MsaLibHeaderDocument.MsaLibHeader
@return MsaLibHeaderDocument.MsaLibHeader
**/
public MsaLibHeaderDocument.MsaLibHeader getMsaLibHeader() {
return msaLibHeader;
}
/**
Set MsaLibHeaderDocument.MsaLibHeader
@param msaLibHeader The input data of MsaLibHeaderDocument.MsaLibHeader
**/
public void setMsaLibHeader(MsaLibHeaderDocument.MsaLibHeader msaLibHeader) {
this.msaLibHeader = msaLibHeader;
}
}

View File

@ -0,0 +1,147 @@
/** @file
The file is used to init workspace and get basic information of workspace
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.packaging.workspace.common;
import java.io.File;
import org.apache.xmlbeans.XmlException;
import org.apache.xmlbeans.XmlObject;
import org.tianocore.FrameworkDatabaseDocument;
import org.tianocore.common.Log;
/**
The file is used to init workspace and get basic information of workspace
@since ModuleEditor 1.0
**/
public class Workspace {
//
// Define class members
//
private String currentWorkspace = null;
private FrameworkDatabaseDocument xmlFrameworkDbDoc = null;
private String strWorkspaceDatabaseFile = System.getProperty("file.separator") + "Tools"
+ System.getProperty("file.separator") + "Conf"
+ System.getProperty("file.separator") + "FrameworkDatabase.db";
public static void main(String[] args) {
}
/**
This is the default constructor
Get current WORKSPACE from system environment variable
**/
public Workspace() {
this.currentWorkspace = System.getenv("WORKSPACE");
}
/**
Check if current workspace exists of not
@retval true - The current WORKSPACE exists
@retval false - The current WORKSPACE doesn't exist
**/
public boolean checkCurrentWorkspace() {
return checkCurrentWorkspace(getCurrentWorkspace());
}
/**
Check if current workspace exists or not via input workspace path
@param strWorkspace The input data of WORKSPACE path
@retval true - The current WORKSPACE exists
@retval false - The current WORKSPACE doesn't exist
**/
public boolean checkCurrentWorkspace(String strWorkspace) {
if (strWorkspace == null || strWorkspace == "") {
return false;
}
File f = new File(strWorkspace);
if (!f.isDirectory()) {
return false;
}
if (!f.exists()) {
return false;
}
return true;
}
/**
Get Current Workspace
@return currentWorkspace
**/
public String getCurrentWorkspace() {
return currentWorkspace;
}
/**
Set Current Workspace
@param currentWorkspace The input data of currentWorkspace
**/
public void setCurrentWorkspace(String currentWorkspace) {
this.currentWorkspace = currentWorkspace;
}
/**
Open Framework Database file
**/
private void openFrameworkDb() {
String strFrameworkDbFilePath = this.getCurrentWorkspace() + strWorkspaceDatabaseFile;
try {
xmlFrameworkDbDoc = (FrameworkDatabaseDocument) XmlObject.Factory.parse(strFrameworkDbFilePath);
} catch (XmlException e) {
Log.err("Open Framework Database " + strFrameworkDbFilePath, e.getMessage());
return;
} catch (Exception e) {
Log.err("Open Framework Database " + strFrameworkDbFilePath, "Invalid file type");
return;
}
}
/**
Get FrameworkDatabaseDocument
@return FrameworkDatabaseDocument
**/
public FrameworkDatabaseDocument getXmlFrameworkDbDoc() {
openFrameworkDb();
return xmlFrameworkDbDoc;
}
/**
Set FrameworkDatabaseDocument
@param xmlFrameworkDbDoc The input data of FrameworkDatabaseDocument
**/
public void setXmlFrameworkDbDoc(FrameworkDatabaseDocument xmlFrameworkDbDoc) {
this.xmlFrameworkDbDoc = xmlFrameworkDbDoc;
}
}