From f4a250cb18e970d32d8a936b249c67608e59884d Mon Sep 17 00:00:00 2001 From: hche10x Date: Fri, 30 Jun 2006 10:06:58 +0000 Subject: [PATCH] Remove ModuleEditor and PackageEditor from Tools\Source git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@672 6f19259b-4bc3-4df7-8a09-765794883524 --- Tools/Source/ModuleEditor/MANIFEST.MF | 2 - Tools/Source/ModuleEditor/build.xml | 44 - .../src/org/tianocore/common/DataType.java | 44 - .../org/tianocore/common/DataValidation.java | 905 ---- .../src/org/tianocore/common/IFileFilter.java | 87 - .../src/org/tianocore/common/Log.java | 211 - .../src/org/tianocore/common/Tools.java | 120 - .../packaging/common/ui/ExitConfirm.java | 265 - .../packaging/common/ui/IComboBox.java | 196 - .../common/ui/IDefaultMutableTreeNode.java | 307 -- .../packaging/common/ui/IDesktopManager.java | 76 - .../packaging/common/ui/IDialog.java | 144 - .../tianocore/packaging/common/ui/IFrame.java | 204 - .../packaging/common/ui/IInternalFrame.java | 109 - .../tianocore/packaging/common/ui/ITree.java | 204 - .../packaging/common/ui/StarLabel.java | 64 - .../packaging/module/ui/MbdHeader.java | 583 --- .../packaging/module/ui/MbdLibHeader.java | 581 --- .../packaging/module/ui/MbdLibraries.java | 1048 ---- .../packaging/module/ui/ModuleAbout.java | 146 - .../packaging/module/ui/ModuleBootModes.java | 456 -- .../packaging/module/ui/ModuleDataHubs.java | 457 -- .../packaging/module/ui/ModuleEvents.java | 626 --- .../packaging/module/ui/ModuleExterns.java | 1030 ---- .../packaging/module/ui/ModuleFormsets.java | 457 -- .../packaging/module/ui/ModuleGuids.java | 675 --- .../packaging/module/ui/ModuleHobs.java | 596 --- .../packaging/module/ui/ModuleIncludes.java | 865 ---- .../ui/ModuleLibraryClassDefinitions.java | 625 --- .../packaging/module/ui/ModuleMain.java | 4422 ----------------- .../packaging/module/ui/ModulePCDs.java | 519 -- .../packaging/module/ui/ModulePpis.java | 711 --- .../packaging/module/ui/ModuleProtocols.java | 705 --- .../module/ui/ModuleSourceFiles.java | 1060 ---- .../module/ui/ModuleSystemTables.java | 393 -- .../packaging/module/ui/ModuleVariables.java | 601 --- .../packaging/module/ui/MsaHeader.java | 789 --- .../packaging/module/ui/MsaLibHeader.java | 789 --- .../packaging/workspace/common/Workspace.java | 169 - Tools/Source/PackageEditor/MANIFEST.MF | 3 - Tools/Source/PackageEditor/build.xml | 44 - .../src/org/tianocore/common/Tools.java | 159 - .../org/tianocore/packaging/CreateFdp.java | 93 - .../tianocore/packaging/DbFileContents.java | 315 -- .../tianocore/packaging/ForceInstallPkg.java | 80 - .../org/tianocore/packaging/FrameworkPkg.java | 402 -- .../tianocore/packaging/GenGuidDialog.java | 391 -- .../tianocore/packaging/GuiPkgInstall.java | 804 --- .../tianocore/packaging/GuiPkgUninstall.java | 370 -- .../org/tianocore/packaging/GuidEditor.java | 92 - .../tianocore/packaging/ManifestContents.java | 74 - .../tianocore/packaging/ModalFrameUtil.java | 107 - .../tianocore/packaging/PackageAction.java | 352 -- .../org/tianocore/packaging/PackageGuids.java | 354 -- .../packaging/PackageLibraryClass.java | 560 --- .../tianocore/packaging/PackageMsaFile.java | 371 -- .../org/tianocore/packaging/PackageNew.java | 533 -- .../org/tianocore/packaging/PackagePCD.java | 321 -- .../tianocore/packaging/PackagePkgHeader.java | 454 -- .../org/tianocore/packaging/PackagePpi.java | 41 - .../tianocore/packaging/PackageProtocols.java | 377 -- .../tianocore/packaging/PackagingMain.java | 330 -- .../packaging/PkgInstallTypeChooser.java | 373 -- .../tianocore/packaging/SpdFileContents.java | 1282 ----- .../org/tianocore/packaging/UpdateAction.java | 328 -- .../org/tianocore/packaging/UpdateGuids.java | 249 - .../packaging/UpdateLibraryClass.java | 243 - .../tianocore/packaging/UpdateMsaFile.java | 237 - .../org/tianocore/packaging/UpdateNew.java | 573 --- .../org/tianocore/packaging/UpdatePCD.java | 277 -- .../tianocore/packaging/UpdatePkgHeader.java | 257 - .../org/tianocore/packaging/UpdatePpi.java | 248 - .../tianocore/packaging/UpdateProtocols.java | 250 - .../packaging/common/ui/StarLabel.java | 41 - 74 files changed, 32270 deletions(-) delete mode 100644 Tools/Source/ModuleEditor/MANIFEST.MF delete mode 100644 Tools/Source/ModuleEditor/build.xml delete mode 100644 Tools/Source/ModuleEditor/src/org/tianocore/common/DataType.java delete mode 100644 Tools/Source/ModuleEditor/src/org/tianocore/common/DataValidation.java delete mode 100644 Tools/Source/ModuleEditor/src/org/tianocore/common/IFileFilter.java delete mode 100644 Tools/Source/ModuleEditor/src/org/tianocore/common/Log.java delete mode 100644 Tools/Source/ModuleEditor/src/org/tianocore/common/Tools.java delete mode 100644 Tools/Source/ModuleEditor/src/org/tianocore/packaging/common/ui/ExitConfirm.java delete mode 100644 Tools/Source/ModuleEditor/src/org/tianocore/packaging/common/ui/IComboBox.java delete mode 100644 Tools/Source/ModuleEditor/src/org/tianocore/packaging/common/ui/IDefaultMutableTreeNode.java delete mode 100644 Tools/Source/ModuleEditor/src/org/tianocore/packaging/common/ui/IDesktopManager.java delete mode 100644 Tools/Source/ModuleEditor/src/org/tianocore/packaging/common/ui/IDialog.java delete mode 100644 Tools/Source/ModuleEditor/src/org/tianocore/packaging/common/ui/IFrame.java delete mode 100644 Tools/Source/ModuleEditor/src/org/tianocore/packaging/common/ui/IInternalFrame.java delete mode 100644 Tools/Source/ModuleEditor/src/org/tianocore/packaging/common/ui/ITree.java delete mode 100644 Tools/Source/ModuleEditor/src/org/tianocore/packaging/common/ui/StarLabel.java delete mode 100644 Tools/Source/ModuleEditor/src/org/tianocore/packaging/module/ui/MbdHeader.java delete mode 100644 Tools/Source/ModuleEditor/src/org/tianocore/packaging/module/ui/MbdLibHeader.java delete mode 100644 Tools/Source/ModuleEditor/src/org/tianocore/packaging/module/ui/MbdLibraries.java delete mode 100644 Tools/Source/ModuleEditor/src/org/tianocore/packaging/module/ui/ModuleAbout.java delete mode 100644 Tools/Source/ModuleEditor/src/org/tianocore/packaging/module/ui/ModuleBootModes.java delete mode 100644 Tools/Source/ModuleEditor/src/org/tianocore/packaging/module/ui/ModuleDataHubs.java delete mode 100644 Tools/Source/ModuleEditor/src/org/tianocore/packaging/module/ui/ModuleEvents.java delete mode 100644 Tools/Source/ModuleEditor/src/org/tianocore/packaging/module/ui/ModuleExterns.java delete mode 100644 Tools/Source/ModuleEditor/src/org/tianocore/packaging/module/ui/ModuleFormsets.java delete mode 100644 Tools/Source/ModuleEditor/src/org/tianocore/packaging/module/ui/ModuleGuids.java delete mode 100644 Tools/Source/ModuleEditor/src/org/tianocore/packaging/module/ui/ModuleHobs.java delete mode 100644 Tools/Source/ModuleEditor/src/org/tianocore/packaging/module/ui/ModuleIncludes.java delete mode 100644 Tools/Source/ModuleEditor/src/org/tianocore/packaging/module/ui/ModuleLibraryClassDefinitions.java delete mode 100644 Tools/Source/ModuleEditor/src/org/tianocore/packaging/module/ui/ModuleMain.java delete mode 100644 Tools/Source/ModuleEditor/src/org/tianocore/packaging/module/ui/ModulePCDs.java delete mode 100644 Tools/Source/ModuleEditor/src/org/tianocore/packaging/module/ui/ModulePpis.java delete mode 100644 Tools/Source/ModuleEditor/src/org/tianocore/packaging/module/ui/ModuleProtocols.java delete mode 100644 Tools/Source/ModuleEditor/src/org/tianocore/packaging/module/ui/ModuleSourceFiles.java delete mode 100644 Tools/Source/ModuleEditor/src/org/tianocore/packaging/module/ui/ModuleSystemTables.java delete mode 100644 Tools/Source/ModuleEditor/src/org/tianocore/packaging/module/ui/ModuleVariables.java delete mode 100644 Tools/Source/ModuleEditor/src/org/tianocore/packaging/module/ui/MsaHeader.java delete mode 100644 Tools/Source/ModuleEditor/src/org/tianocore/packaging/module/ui/MsaLibHeader.java delete mode 100644 Tools/Source/ModuleEditor/src/org/tianocore/packaging/workspace/common/Workspace.java delete mode 100644 Tools/Source/PackageEditor/MANIFEST.MF delete mode 100644 Tools/Source/PackageEditor/build.xml delete mode 100644 Tools/Source/PackageEditor/src/org/tianocore/common/Tools.java delete mode 100644 Tools/Source/PackageEditor/src/org/tianocore/packaging/CreateFdp.java delete mode 100644 Tools/Source/PackageEditor/src/org/tianocore/packaging/DbFileContents.java delete mode 100644 Tools/Source/PackageEditor/src/org/tianocore/packaging/ForceInstallPkg.java delete mode 100644 Tools/Source/PackageEditor/src/org/tianocore/packaging/FrameworkPkg.java delete mode 100644 Tools/Source/PackageEditor/src/org/tianocore/packaging/GenGuidDialog.java delete mode 100644 Tools/Source/PackageEditor/src/org/tianocore/packaging/GuiPkgInstall.java delete mode 100644 Tools/Source/PackageEditor/src/org/tianocore/packaging/GuiPkgUninstall.java delete mode 100644 Tools/Source/PackageEditor/src/org/tianocore/packaging/GuidEditor.java delete mode 100644 Tools/Source/PackageEditor/src/org/tianocore/packaging/ManifestContents.java delete mode 100644 Tools/Source/PackageEditor/src/org/tianocore/packaging/ModalFrameUtil.java delete mode 100644 Tools/Source/PackageEditor/src/org/tianocore/packaging/PackageAction.java delete mode 100644 Tools/Source/PackageEditor/src/org/tianocore/packaging/PackageGuids.java delete mode 100644 Tools/Source/PackageEditor/src/org/tianocore/packaging/PackageLibraryClass.java delete mode 100644 Tools/Source/PackageEditor/src/org/tianocore/packaging/PackageMsaFile.java delete mode 100644 Tools/Source/PackageEditor/src/org/tianocore/packaging/PackageNew.java delete mode 100644 Tools/Source/PackageEditor/src/org/tianocore/packaging/PackagePCD.java delete mode 100644 Tools/Source/PackageEditor/src/org/tianocore/packaging/PackagePkgHeader.java delete mode 100644 Tools/Source/PackageEditor/src/org/tianocore/packaging/PackagePpi.java delete mode 100644 Tools/Source/PackageEditor/src/org/tianocore/packaging/PackageProtocols.java delete mode 100644 Tools/Source/PackageEditor/src/org/tianocore/packaging/PackagingMain.java delete mode 100644 Tools/Source/PackageEditor/src/org/tianocore/packaging/PkgInstallTypeChooser.java delete mode 100644 Tools/Source/PackageEditor/src/org/tianocore/packaging/SpdFileContents.java delete mode 100644 Tools/Source/PackageEditor/src/org/tianocore/packaging/UpdateAction.java delete mode 100644 Tools/Source/PackageEditor/src/org/tianocore/packaging/UpdateGuids.java delete mode 100644 Tools/Source/PackageEditor/src/org/tianocore/packaging/UpdateLibraryClass.java delete mode 100644 Tools/Source/PackageEditor/src/org/tianocore/packaging/UpdateMsaFile.java delete mode 100644 Tools/Source/PackageEditor/src/org/tianocore/packaging/UpdateNew.java delete mode 100644 Tools/Source/PackageEditor/src/org/tianocore/packaging/UpdatePCD.java delete mode 100644 Tools/Source/PackageEditor/src/org/tianocore/packaging/UpdatePkgHeader.java delete mode 100644 Tools/Source/PackageEditor/src/org/tianocore/packaging/UpdatePpi.java delete mode 100644 Tools/Source/PackageEditor/src/org/tianocore/packaging/UpdateProtocols.java delete mode 100644 Tools/Source/PackageEditor/src/org/tianocore/packaging/common/ui/StarLabel.java diff --git a/Tools/Source/ModuleEditor/MANIFEST.MF b/Tools/Source/ModuleEditor/MANIFEST.MF deleted file mode 100644 index 544cd0bae9..0000000000 --- a/Tools/Source/ModuleEditor/MANIFEST.MF +++ /dev/null @@ -1,2 +0,0 @@ -Manifest-Version: 1.0 -Main-Class: org.tianocore.packaging.module.ui.ModuleMain diff --git a/Tools/Source/ModuleEditor/build.xml b/Tools/Source/ModuleEditor/build.xml deleted file mode 100644 index 2696c71d01..0000000000 --- a/Tools/Source/ModuleEditor/build.xml +++ /dev/null @@ -1,44 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Tools/Source/ModuleEditor/src/org/tianocore/common/DataType.java b/Tools/Source/ModuleEditor/src/org/tianocore/common/DataType.java deleted file mode 100644 index ea0731b70f..0000000000 --- a/Tools/Source/ModuleEditor/src/org/tianocore/common/DataType.java +++ /dev/null @@ -1,44 +0,0 @@ -/** @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 = "----"; - -} diff --git a/Tools/Source/ModuleEditor/src/org/tianocore/common/DataValidation.java b/Tools/Source/ModuleEditor/src/org/tianocore/common/DataValidation.java deleted file mode 100644 index 4747343725..0000000000 --- a/Tools/Source/ModuleEditor/src/org/tianocore/common/DataValidation.java +++ /dev/null @@ -1,905 +0,0 @@ -/** @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 - -

All provided interfaces are in static mode

- - @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); - } -} diff --git a/Tools/Source/ModuleEditor/src/org/tianocore/common/IFileFilter.java b/Tools/Source/ModuleEditor/src/org/tianocore/common/IFileFilter.java deleted file mode 100644 index 1daf7fa867..0000000000 --- a/Tools/Source/ModuleEditor/src/org/tianocore/common/IFileFilter.java +++ /dev/null @@ -1,87 +0,0 @@ -/** @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 ""; - } - -} diff --git a/Tools/Source/ModuleEditor/src/org/tianocore/common/Log.java b/Tools/Source/ModuleEditor/src/org/tianocore/common/Log.java deleted file mode 100644 index 0759fc619c..0000000000 --- a/Tools/Source/ModuleEditor/src/org/tianocore/common/Log.java +++ /dev/null @@ -1,211 +0,0 @@ -/** @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(); - } - } -} diff --git a/Tools/Source/ModuleEditor/src/org/tianocore/common/Tools.java b/Tools/Source/ModuleEditor/src/org/tianocore/common/Tools.java deleted file mode 100644 index a11df00377..0000000000 --- a/Tools/Source/ModuleEditor/src/org/tianocore/common/Tools.java +++ /dev/null @@ -1,120 +0,0 @@ -/** @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")); - } -} diff --git a/Tools/Source/ModuleEditor/src/org/tianocore/packaging/common/ui/ExitConfirm.java b/Tools/Source/ModuleEditor/src/org/tianocore/packaging/common/ui/ExitConfirm.java deleted file mode 100644 index 2ff84b669b..0000000000 --- a/Tools/Source/ModuleEditor/src/org/tianocore/packaging/common/ui/ExitConfirm.java +++ /dev/null @@ -1,265 +0,0 @@ -/** @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 - - } -} diff --git a/Tools/Source/ModuleEditor/src/org/tianocore/packaging/common/ui/IComboBox.java b/Tools/Source/ModuleEditor/src/org/tianocore/packaging/common/ui/IComboBox.java deleted file mode 100644 index f60ebcfe33..0000000000 --- a/Tools/Source/ModuleEditor/src/org/tianocore/packaging/common/ui/IComboBox.java +++ /dev/null @@ -1,196 +0,0 @@ -/** @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); - } - } -} diff --git a/Tools/Source/ModuleEditor/src/org/tianocore/packaging/common/ui/IDefaultMutableTreeNode.java b/Tools/Source/ModuleEditor/src/org/tianocore/packaging/common/ui/IDefaultMutableTreeNode.java deleted file mode 100644 index ae51c5fa45..0000000000 --- a/Tools/Source/ModuleEditor/src/org/tianocore/packaging/common/ui/IDefaultMutableTreeNode.java +++ /dev/null @@ -1,307 +0,0 @@ -/** @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; - } -} diff --git a/Tools/Source/ModuleEditor/src/org/tianocore/packaging/common/ui/IDesktopManager.java b/Tools/Source/ModuleEditor/src/org/tianocore/packaging/common/ui/IDesktopManager.java deleted file mode 100644 index b86aa6b484..0000000000 --- a/Tools/Source/ModuleEditor/src/org/tianocore/packaging/common/ui/IDesktopManager.java +++ /dev/null @@ -1,76 +0,0 @@ -/** @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) { - - } - -} diff --git a/Tools/Source/ModuleEditor/src/org/tianocore/packaging/common/ui/IDialog.java b/Tools/Source/ModuleEditor/src/org/tianocore/packaging/common/ui/IDialog.java deleted file mode 100644 index 622b54bcca..0000000000 --- a/Tools/Source/ModuleEditor/src/org/tianocore/packaging/common/ui/IDialog.java +++ /dev/null @@ -1,144 +0,0 @@ -/** @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; - } -} diff --git a/Tools/Source/ModuleEditor/src/org/tianocore/packaging/common/ui/IFrame.java b/Tools/Source/ModuleEditor/src/org/tianocore/packaging/common/ui/IFrame.java deleted file mode 100644 index 4e36bd430a..0000000000 --- a/Tools/Source/ModuleEditor/src/org/tianocore/packaging/common/ui/IFrame.java +++ /dev/null @@ -1,204 +0,0 @@ -/** @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(); - } - } -} diff --git a/Tools/Source/ModuleEditor/src/org/tianocore/packaging/common/ui/IInternalFrame.java b/Tools/Source/ModuleEditor/src/org/tianocore/packaging/common/ui/IInternalFrame.java deleted file mode 100644 index 8fc9d9b489..0000000000 --- a/Tools/Source/ModuleEditor/src/org/tianocore/packaging/common/ui/IInternalFrame.java +++ /dev/null @@ -1,109 +0,0 @@ -/** @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 - } -} diff --git a/Tools/Source/ModuleEditor/src/org/tianocore/packaging/common/ui/ITree.java b/Tools/Source/ModuleEditor/src/org/tianocore/packaging/common/ui/ITree.java deleted file mode 100644 index eeb51fce83..0000000000 --- a/Tools/Source/ModuleEditor/src/org/tianocore/packaging/common/ui/ITree.java +++ /dev/null @@ -1,204 +0,0 @@ -/** @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(); - } -} diff --git a/Tools/Source/ModuleEditor/src/org/tianocore/packaging/common/ui/StarLabel.java b/Tools/Source/ModuleEditor/src/org/tianocore/packaging/common/ui/StarLabel.java deleted file mode 100644 index c451ac53b9..0000000000 --- a/Tools/Source/ModuleEditor/src/org/tianocore/packaging/common/ui/StarLabel.java +++ /dev/null @@ -1,64 +0,0 @@ -/** @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); - } -} diff --git a/Tools/Source/ModuleEditor/src/org/tianocore/packaging/module/ui/MbdHeader.java b/Tools/Source/ModuleEditor/src/org/tianocore/packaging/module/ui/MbdHeader.java deleted file mode 100644 index c9e65d1262..0000000000 --- a/Tools/Source/ModuleEditor/src/org/tianocore/packaging/module/ui/MbdHeader.java +++ /dev/null @@ -1,583 +0,0 @@ -/** @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 JLabel jLabelDescription = null; - - private JTextArea jTextAreaDescription = null; - - private JButton jButtonOk = null; - - private JButton jButtonCancel = null; - - private JScrollPane jScrollPaneLicense = 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; - - private JTextField jTextFieldCopyright = 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, 250, 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(415, 35, 65, 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 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 jScrollPaneDescription - - @return javax.swing.JScrollPane jScrollPaneDescription - - **/ - private JScrollPane getJScrollPaneDescription() { - if (jScrollPaneDescription == null) { - jScrollPaneDescription = new JScrollPane(); - jScrollPaneDescription.setBounds(new java.awt.Rectangle(160, 195, 320, 80)); - jScrollPaneDescription.setHorizontalScrollBarPolicy(javax.swing.JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); - jScrollPaneDescription.setViewportView(getJTextAreaDescription()); - } - return jScrollPaneDescription; - } - - /** - * This method initializes jTextFieldCopyright - * - * @return javax.swing.JTextField - */ - private JTextField getJTextFieldCopyright() { - if (jTextFieldCopyright == null) { - jTextFieldCopyright = new JTextField(); - jTextFieldCopyright.setBounds(new java.awt.Rectangle(160,170,320,20)); - } - return jTextFieldCopyright; - } - - 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.jTextFieldCopyright.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.jTextFieldCopyright.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, 195, 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(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, 195)); - - 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(getJTextFieldCopyright(), 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.jTextFieldCopyright.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.jTextFieldCopyright.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.jTextFieldCopyright.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; - } -} diff --git a/Tools/Source/ModuleEditor/src/org/tianocore/packaging/module/ui/MbdLibHeader.java b/Tools/Source/ModuleEditor/src/org/tianocore/packaging/module/ui/MbdLibHeader.java deleted file mode 100644 index 8adde849a0..0000000000 --- a/Tools/Source/ModuleEditor/src/org/tianocore/packaging/module/ui/MbdLibHeader.java +++ /dev/null @@ -1,581 +0,0 @@ -/** @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 JLabel jLabelDescription = null; - - private JTextArea jTextAreaDescription = null; - - private JButton jButtonOk = null; - - private JButton jButtonCancel = null; - - private JScrollPane jScrollPaneLicense = 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; - - private JTextField jTextFieldCopyright = 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, 250, 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(415, 35, 65, 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 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 jScrollPaneDescription - - @return javax.swing.JScrollPane jScrollPaneDescription - - **/ - private JScrollPane getJScrollPaneDescription() { - if (jScrollPaneDescription == null) { - jScrollPaneDescription = new JScrollPane(); - jScrollPaneDescription.setBounds(new java.awt.Rectangle(160, 195, 320, 80)); - jScrollPaneDescription.setHorizontalScrollBarPolicy(javax.swing.JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); - jScrollPaneDescription.setViewportView(getJTextAreaDescription()); - } - return jScrollPaneDescription; - } - - /** - This method initializes jTextFieldCopyright - - @return javax.swing.JTextField jTextFieldCopyright - - **/ - private JTextField getJTextFieldCopyright() { - if (jTextFieldCopyright == null) { - jTextFieldCopyright = new JTextField(); - jTextFieldCopyright.setBounds(new java.awt.Rectangle(160,170,320,20)); - } - return jTextFieldCopyright; - } - - 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.jTextFieldCopyright.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.jTextFieldCopyright.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, 195, 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(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, 195)); - - 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(getJTextFieldCopyright(), 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.jTextFieldCopyright.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.jTextFieldCopyright.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.jTextFieldCopyright.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; - } -} diff --git a/Tools/Source/ModuleEditor/src/org/tianocore/packaging/module/ui/MbdLibraries.java b/Tools/Source/ModuleEditor/src/org/tianocore/packaging/module/ui/MbdLibraries.java deleted file mode 100644 index ffbb3eb4ab..0000000000 --- a/Tools/Source/ModuleEditor/src/org/tianocore/packaging/module/ui/MbdLibraries.java +++ /dev/null @@ -1,1048 +0,0 @@ -/** @file - - The file is used to create, update MbdLibraries 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 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.LibrariesDocument; -import org.tianocore.LibraryUsage; -import org.tianocore.SupportedArchitectures; -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 MbdLibraries of a MBD file - It extends IInternalFrame - - @since ModuleEditor 1.0 - - **/ -public class MbdLibraries extends IInternalFrame implements ItemListener { - - /// - /// Define class Serial Version UID - /// - private static final long serialVersionUID = 8042998899875417568L; - - // - //Define class members - // - private LibrariesDocument.Libraries libraries = null; - - private int location = -1; - - private int intSelectedItemId = 0; - - // - //1 - Add; 2 - Update - // - private int operation = -1; - - private Vector vName = new Vector(); - - private Vector vGuid = new Vector(); - - private Vector vLibraryClass = new Vector(); - - private Vector vClassGuid = new Vector(); - - private Vector vVersion = new Vector(); - - private Vector vUsage = new Vector(); - - private Vector vOverrideID = new Vector(); - - private JPanel jContentPane = null; - - private JButton jButtonOk = null; - - private JButton jButtonCancel = null; - - private JLabel jLabelName = null; - - private JTextField jTextFieldFileName = null; - - private JLabel jLabelGuid = null; - - private JTextField jTextFieldGuid = null; - - private JButton jButtonGenerateGuid = null; - - private JComboBox jComboBoxArch = null; - - private JLabel jLabelLibraryClass = null; - - private JTextField jTextFieldLibraryClass = null; - - private JLabel jLabelUsage = null; - - private JLabel jLabelClassGuid = null; - - private JTextField jTextFieldClassGuid = null; - - private JLabel jLabelOverrideID = null; - - private JTextField jTextFieldOverrideID = null; - - private JComboBox jComboBoxUsage = null; - - private StarLabel jStarLabel1 = null; - - private JComboBox jComboBoxFileList = null; - - private JButton jButtonAdd = null; - - private JButton jButtonRemove = null; - - private JButton jButtonUpdate = null; - - private JCheckBox jCheckBoxArch = null; - - private JButton jButtonGenerateGuid2 = null; - - private JLabel jLabelVersion = null; - - private JTextField jTextFieldVersion = 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, 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.setPreferredSize(new java.awt.Dimension(90, 20)); - jButtonCancel.addActionListener(this); - } - return jButtonCancel; - } - - /** - This method initializes jTextFieldFileName - - @return javax.swing.JTextField jTextFieldFileName - - **/ - private JTextField getJTextFieldSourceFilesDirectory() { - if (jTextFieldFileName == null) { - jTextFieldFileName = new JTextField(); - jTextFieldFileName.setBounds(new java.awt.Rectangle(160, 10, 320, 20)); - } - return jTextFieldFileName; - } - - /** - 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, 250, 20)); - } - return jTextFieldGuid; - } - - /** - This method initializes jButtonGenerateGuid - - @return javax.swing.JButton jButtonGenerateGuid - - **/ - private JButton getJButtonGenerateGuid() { - if (jButtonGenerateGuid == null) { - jButtonGenerateGuid = new JButton(); - jButtonGenerateGuid.setBounds(new java.awt.Rectangle(415, 35, 65, 20)); - jButtonGenerateGuid.setText("GEN"); - jButtonGenerateGuid.addActionListener(this); - } - return jButtonGenerateGuid; - } - - /** - 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, 210, 340, 20)); - jComboBoxArch.setEnabled(false); - } - return jComboBoxArch; - } - - /** - This method initializes jTextFieldLibraryClass - - @return javax.swing.JTextField jTextFieldLibraryClass - - **/ - private JTextField getJTextFieldLibraryClass() { - if (jTextFieldLibraryClass == null) { - jTextFieldLibraryClass = new JTextField(); - jTextFieldLibraryClass.setBounds(new java.awt.Rectangle(160, 60, 320, 20)); - } - return jTextFieldLibraryClass; - } - - /** - This method initializes jTextFieldClassGuid - - @return javax.swing.JTextField jTextFieldClassGuid - - **/ - private JTextField getJTextFieldClassGuid() { - if (jTextFieldClassGuid == null) { - jTextFieldClassGuid = new JTextField(); - jTextFieldClassGuid.setBounds(new java.awt.Rectangle(160, 85, 250, 20)); - } - return jTextFieldClassGuid; - } - - /** - 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; - } - - /** - 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 jComboBoxFileList - - @return javax.swing.JComboBox jComboBoxFileList - - **/ - private JComboBox getJComboBoxFileList() { - if (jComboBoxFileList == null) { - jComboBoxFileList = new JComboBox(); - jComboBoxFileList.setBounds(new java.awt.Rectangle(15, 185, 210, 20)); - jComboBoxFileList.addItemListener(this); - jComboBoxFileList.addActionListener(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, 185, 80, 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(400, 185, 80, 20)); - jButtonRemove.setText("Remove"); - jButtonRemove.addActionListener(this); - } - return jButtonRemove; - } - - /** - 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, 185, 80, 20)); - jButtonUpdate.setText("Update"); - jButtonUpdate.addActionListener(this); - } - return jButtonUpdate; - } - - /** - 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, 210, 119, 20)); - jCheckBoxArch.setText("Specific Arch"); - jCheckBoxArch.addActionListener(this); - } - return jCheckBoxArch; - } - - /** - This method initializes jButtonGenerateGuid2 - - @return javax.swing.JButton jButtonGenerateGuid2 - - **/ - private JButton getJButtonGenerateGuid2() { - if (jButtonGenerateGuid2 == null) { - jButtonGenerateGuid2 = new JButton(); - jButtonGenerateGuid2.setBounds(new java.awt.Rectangle(415, 85, 65, 20)); - jButtonGenerateGuid2.setText("GEN"); - jButtonGenerateGuid2.addActionListener(this); - } - return jButtonGenerateGuid2; - } - - /** - 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, 110, 320, 20)); - } - return jTextFieldVersion; - } - - public static void main(String[] args) { - - } - - /** - This is the default constructor - - **/ - public MbdLibraries() { - super(); - init(); - this.setVisible(true); - } - - /** - This is the override edit constructor - - @param inLibraries The input LibrariesDocument.Libraries - - **/ - public MbdLibraries(LibrariesDocument.Libraries inLibraries) { - super(); - init(inLibraries); - this.setVisible(true); - } - - /** - This is the override edit constructor - - @param inLibraries The input LibrariesDocument.Libraries - @param type The input data of node type - @param index The input data of node index - - **/ - public MbdLibraries(LibrariesDocument.Libraries inLibraries, int type, int index) { - super(); - init(inLibraries); - this.setVisible(true); - } - - /** - This is the override edit constructor - - @param inLibraries The input LibrariesDocument.Libraries - @param type The input data of node type - @param index The input data of node index - @param inOperation The input data of operation type - - **/ - public MbdLibraries(LibrariesDocument.Libraries inLibraries, int type, int index, int inOperation) { - super(); - init(inLibraries, type, index, inOperation); - this.operation = inOperation; - this.setVisible(true); - } - - /** - This method initializes this - - @param inLibraries LibrariesDocument.Libraries - - **/ - private void init(LibrariesDocument.Libraries inLibraries) { - init(); - this.setLibraries(inLibraries); - } - - /** - This method initializes this - Fill values to all fields if these values are not empty - - @param inLibraries LibrariesDocument.Libraries - @param type The input data of node type - @param index The input data of node index - @param inOperation The input data of operation type - - **/ - private void init(LibrariesDocument.Libraries inLibraries, int type, int index, int inOperation) { - init(inLibraries); - this.location = index; - this.operation = inOperation; - - if (operation == 2) { - this.jCheckBoxArch.setEnabled(false); - this.jComboBoxArch.setEnabled(false); - - if (type == IDefaultMutableTreeNode.LIBRARIES_LIBRARY) { - if (this.libraries.getLibraryList().size() > 0) { - for (int indexI = 0; indexI < this.libraries.getLibraryList().size(); indexI++) { - if (this.libraries.getLibraryArray(indexI).getStringValue() != null) { - vName.addElement(this.libraries.getLibraryArray(indexI).getStringValue()); - } else { - vName.addElement(""); - } - if (this.libraries.getLibraryArray(indexI).getGuid() != null) { - vGuid.addElement(this.libraries.getLibraryArray(indexI).getGuid()); - } else { - vGuid.addElement(""); - } - if (this.libraries.getLibraryArray(indexI).getLibraryClass() != null) { - vLibraryClass.addElement(this.libraries.getLibraryArray(indexI).getLibraryClass()); - } else { - vLibraryClass.addElement(""); - } - if (this.libraries.getLibraryArray(indexI).getClassGuid() != null) { - vClassGuid.addElement(this.libraries.getLibraryArray(indexI).getClassGuid()); - } else { - vClassGuid.addElement(""); - } - if (this.libraries.getLibraryArray(indexI).getVersion() != null) { - vVersion.addElement(this.libraries.getLibraryArray(indexI).getVersion()); - } else { - vVersion.addElement(""); - } - if (this.libraries.getLibraryArray(indexI).getUsage() != null) { - vUsage.addElement(this.libraries.getLibraryArray(indexI).getUsage().toString()); - } else { - vUsage.addElement("ALWAYS_CONSUMED"); - } - vOverrideID.addElement(String.valueOf(this.libraries.getLibraryArray(indexI).getOverrideID())); - jComboBoxFileList.addItem(this.libraries.getLibraryArray(indexI).getStringValue()); - } - } - } - if (type == IDefaultMutableTreeNode.LIBRARIES_ARCH_ITEM) { - this.jCheckBoxArch.setSelected(true); - this.jComboBoxArch.setSelectedItem(this.libraries.getArchArray(index).getArchType().toString()); - for (int indexI = 0; indexI < this.libraries.getArchArray(index).getLibraryList().size(); indexI++) { - if (this.libraries.getArchArray(index).getLibraryArray(indexI).getStringValue() != null) { - vName.addElement(this.libraries.getArchArray(index).getLibraryArray(indexI).getStringValue()); - } else { - vName.addElement(""); - } - if (this.libraries.getArchArray(index).getLibraryArray(indexI).getGuid() != null) { - vGuid.addElement(this.libraries.getArchArray(index).getLibraryArray(indexI).getGuid()); - } else { - vGuid.addElement(""); - } - if (this.libraries.getArchArray(index).getLibraryArray(indexI).getLibraryClass() != null) { - vLibraryClass.addElement(this.libraries.getArchArray(index).getLibraryArray(indexI) - .getLibraryClass()); - } else { - vLibraryClass.addElement(""); - } - if (this.libraries.getArchArray(index).getLibraryArray(indexI).getClassGuid() != null) { - vClassGuid - .addElement(this.libraries.getArchArray(index).getLibraryArray(indexI).getClassGuid()); - } else { - vClassGuid.addElement(""); - } - if (this.libraries.getArchArray(index).getLibraryArray(indexI).getVersion() != null) { - vVersion.addElement(this.libraries.getArchArray(index).getLibraryArray(indexI).getVersion()); - } else { - vVersion.addElement(""); - } - if (this.libraries.getArchArray(index).getLibraryArray(indexI).getUsage() != null) { - vUsage.addElement(this.libraries.getArchArray(index).getLibraryArray(indexI).getUsage() - .toString()); - } else { - vUsage.addElement(""); - } - vOverrideID.addElement(String.valueOf(this.libraries.getArchArray(index).getLibraryArray(indexI).getOverrideID())); - jComboBoxFileList.addItem(this.libraries.getArchArray(index).getLibraryArray(indexI) - .getStringValue()); - } - } - } - } - - /** - This method initializes this - - **/ - private void init() { - this.setSize(500, 515); - this.setName("JFrame"); - this.setContentPane(getJContentPane()); - this.setTitle("Source Files"); - 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.jTextFieldFileName.setEnabled(!isView); - this.jTextFieldGuid.setEnabled(!isView); - this.jButtonGenerateGuid.setEnabled(!isView); - this.jComboBoxArch.setEnabled(!isView); - this.jTextFieldLibraryClass.setEnabled(!isView); - this.jTextFieldClassGuid.setEnabled(!isView); - this.jTextFieldOverrideID.setEnabled(!isView); - this.jComboBoxUsage.setEnabled(!isView); - this.jButtonAdd.setEnabled(!isView); - this.jButtonRemove.setEnabled(!isView); - this.jButtonUpdate.setEnabled(!isView); - this.jCheckBoxArch.setEnabled(!isView); - this.jTextFieldVersion.setEnabled(!isView); - - this.jButtonOk.setEnabled(!isView); - this.jButtonCancel.setEnabled(!isView); - this.jButtonGenerateGuid.setEnabled(!isView); - this.jButtonGenerateGuid2.setEnabled(!isView); - } - } - - /** - This method initializes jContentPane - - @return javax.swing.JPanel jContentPane - - **/ - private JPanel getJContentPane() { - if (jContentPane == null) { - jLabelVersion = new JLabel(); - jLabelVersion.setBounds(new java.awt.Rectangle(15, 110, 140, 20)); - jLabelVersion.setText("Version"); - jLabelOverrideID = new JLabel(); - jLabelOverrideID.setBounds(new java.awt.Rectangle(15, 160, 140, 20)); - jLabelOverrideID.setText("Override ID"); - jLabelClassGuid = new JLabel(); - jLabelClassGuid.setBounds(new java.awt.Rectangle(15, 85, 140, 20)); - jLabelClassGuid.setText("Class Guid"); - jLabelUsage = new JLabel(); - jLabelUsage.setBounds(new java.awt.Rectangle(15, 135, 140, 20)); - jLabelUsage.setText("Usage"); - jLabelLibraryClass = new JLabel(); - jLabelLibraryClass.setBounds(new java.awt.Rectangle(15, 60, 140, 20)); - jLabelLibraryClass.setText("Library Class"); - jLabelGuid = new JLabel(); - jLabelGuid.setBounds(new java.awt.Rectangle(15, 35, 140, 20)); - jLabelGuid.setText("Guid"); - jLabelName = new JLabel(); - jLabelName.setText("Name"); - jLabelName.setBounds(new java.awt.Rectangle(15, 10, 140, 20)); - jContentPane = new JPanel(); - jContentPane.setLayout(null); - jContentPane.add(getJButton(), null); - jContentPane.add(getJButtonCancel(), null); - jContentPane.add(jLabelName, null); - jContentPane.add(getJTextFieldSourceFilesDirectory(), null); - jContentPane.add(jLabelGuid, null); - jContentPane.add(getJTextFieldGuid(), null); - jContentPane.add(getJButtonGenerateGuid(), null); - jContentPane.add(getJComboBoxArch(), null); - jContentPane.add(jLabelLibraryClass, null); - jContentPane.add(getJTextFieldLibraryClass(), null); - jContentPane.add(jLabelUsage, null); - jContentPane.add(jLabelClassGuid, null); - jContentPane.add(getJTextFieldClassGuid(), null); - jContentPane.add(getJButtonGenerateGuid2(), null); - jContentPane.add(jLabelVersion, null); - jContentPane.add(getJTextFieldVersion(), null); - jContentPane.add(jLabelOverrideID, null); - jContentPane.add(getJTextFieldOverrideID(), null); - jContentPane.add(getJComboBoxUsage(), null); - - jStarLabel1 = new StarLabel(); - jStarLabel1.setLocation(new java.awt.Point(0, 10)); - - jContentPane.add(jStarLabel1, null); - jContentPane.add(getJComboBoxFileList(), null); - jContentPane.add(getJButtonAdd(), null); - jContentPane.add(getJButtonRemove(), null); - jContentPane.add(getJButtonUpdate(), null); - jContentPane.add(getJCheckBoxArch(), 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() == jButtonGenerateGuid) { - jTextFieldGuid.setText(Tools.generateUuidString()); - } - if (arg0.getSource() == jButtonGenerateGuid2) { - jTextFieldClassGuid.setText(Tools.generateUuidString()); - } - if (arg0.getSource() == jButtonAdd) { - if (!checkAdd()) { - return; - } - addToList(); - } - if (arg0.getSource() == jButtonRemove) { - removeFromList(); - } - if (arg0.getSource() == jButtonUpdate) { - if (!checkAdd()) { - return; - } - updateForList(); - } - if (arg0.getSource() == jCheckBoxArch) { - if (this.jCheckBoxArch.isSelected()) { - this.jComboBoxArch.setEnabled(true); - } else { - this.jComboBoxArch.setEnabled(false); - } - } - } - - /** - Init the items of Usage and Arch - - **/ - private void initFrame() { - jComboBoxUsage.addItem("ALWAYS_CONSUMED"); - jComboBoxUsage.addItem("SOMETIMES_CONSUMED"); - jComboBoxUsage.addItem("ALWAYS_PRODUCED"); - jComboBoxUsage.addItem("SOMETIMES_PRODUCED"); - jComboBoxUsage.addItem("DEFAULT"); - jComboBoxUsage.addItem("PRIVATE"); - - 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 = vName.size(); - vName.addElement(this.jTextFieldFileName.getText()); - vGuid.addElement(this.jTextFieldGuid.getText()); - vLibraryClass.addElement(this.jTextFieldLibraryClass.getText()); - vClassGuid.addElement(this.jTextFieldClassGuid.getText()); - vVersion.addElement(this.jTextFieldVersion.getText()); - vUsage.addElement(this.jComboBoxUsage.getSelectedItem().toString()); - vOverrideID.addElement(this.jTextFieldOverrideID.getText()); - jComboBoxFileList.addItem(this.jTextFieldFileName.getText()); - jComboBoxFileList.setSelectedItem(this.jTextFieldFileName.getText()); - - // - // Reset select item index - // - intSelectedItemId = vName.size(); - - // - // Reload all fields of selected item - // - reloadFromList(); - } - - /** - Remove current item from Vector - - **/ - private void removeFromList() { - int intTempIndex = intSelectedItemId; - if (vName.size() < 1) { - return; - } - - jComboBoxFileList.removeItemAt(intSelectedItemId); - - vName.removeElementAt(intTempIndex); - vGuid.removeElementAt(intTempIndex); - vLibraryClass.removeElementAt(intTempIndex); - vClassGuid.removeElementAt(intTempIndex); - vVersion.removeElementAt(intTempIndex); - vUsage.removeElementAt(intTempIndex); - vOverrideID.removeElementAt(intTempIndex); - - // - // Reload all fields of selected item - // - reloadFromList(); - } - - /** - Update current item of Vector - - **/ - private void updateForList() { - // - // Backup selected item index - // - int intTempIndex = intSelectedItemId; - vName.setElementAt(this.jTextFieldFileName.getText(), intSelectedItemId); - vGuid.setElementAt(this.jTextFieldGuid.getText(), intSelectedItemId); - vLibraryClass.setElementAt(this.jTextFieldLibraryClass.getText(), intSelectedItemId); - vClassGuid.setElementAt(this.jTextFieldClassGuid.getText(), intSelectedItemId); - vVersion.setElementAt(this.jTextFieldVersion.getText(), intSelectedItemId); - vUsage.setElementAt(this.jComboBoxUsage.getSelectedItem().toString(), intSelectedItemId); - vOverrideID.setElementAt(this.jTextFieldOverrideID.getText(), intSelectedItemId); - - jComboBoxFileList.removeAllItems(); - for (int index = 0; index < vName.size(); index++) { - jComboBoxFileList.addItem(vName.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 (vName.size() > 0) { - // - // Get selected item index - // - intSelectedItemId = jComboBoxFileList.getSelectedIndex(); - - this.jTextFieldFileName.setText(vName.elementAt(intSelectedItemId).toString()); - this.jComboBoxUsage.setSelectedItem(vUsage.elementAt(intSelectedItemId).toString()); - this.jTextFieldGuid.setText(vGuid.elementAt(intSelectedItemId).toString()); - this.jTextFieldLibraryClass.setText(vLibraryClass.elementAt(intSelectedItemId).toString()); - this.jTextFieldClassGuid.setText(vClassGuid.elementAt(intSelectedItemId).toString()); - this.jTextFieldVersion.setText(vVersion.elementAt(intSelectedItemId).toString()); - this.jTextFieldOverrideID.setText(vOverrideID.elementAt(intSelectedItemId).toString()); - } else { - this.jTextFieldFileName.setText(""); - this.jComboBoxUsage.setSelectedIndex(0); - this.jTextFieldGuid.setText(""); - this.jTextFieldLibraryClass.setText(""); - this.jTextFieldClassGuid.setText(""); - this.jTextFieldVersion.setText(""); - this.jTextFieldOverrideID.setText(""); - } - } - - /* (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 before save - - @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 Library 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.jTextFieldFileName.getText())) { - Log.err("File Name couldn't be empty"); - return false; - } - - // - // Check if all fields have correct data types - // - if (!DataValidation.isBaseName(this.jTextFieldFileName.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.jTextFieldLibraryClass.getText()) - && !DataValidation.isPath(this.jTextFieldLibraryClass.getText())) { - Log.err("Incorrect data type for Path"); - return false; - } - if (!isEmpty(this.jTextFieldClassGuid.getText()) && !DataValidation.isGuid(this.jTextFieldClassGuid.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 Libraries - if exists libraries, set the value directly - if not exists libraries, new an instance first - - **/ - public void save() { - try { - if (this.libraries == null) { - libraries = LibrariesDocument.Libraries.Factory.newInstance(); - } - // - //Save as file name - // - if (!this.jCheckBoxArch.isSelected()) { - if (this.operation == 2) { //Add new filename - // - //First remove all existed filename - // - if (libraries.getLibraryList().size() > 0) { - for (int index = libraries.getLibraryList().size() - 1; index >= 0; index--) { - libraries.removeLibrary(index); - } - } - } - LibrariesDocument.Libraries.Library library = LibrariesDocument.Libraries.Library.Factory.newInstance(); - for (int index = 0; index < vName.size(); index++) { - if (!isEmpty(vName.elementAt(index).toString())) { - library.setStringValue(vName.elementAt(index).toString()); - } - if (!isEmpty(vGuid.elementAt(index).toString())) { - library.setGuid(vGuid.elementAt(index).toString()); - } - if (!isEmpty(vLibraryClass.elementAt(index).toString())) { - library.setLibraryClass(vLibraryClass.elementAt(index).toString()); - } - if (!isEmpty(vClassGuid.elementAt(index).toString())) { - library.setClassGuid(vClassGuid.elementAt(index).toString()); - } - if (!isEmpty(vVersion.elementAt(index).toString())) { - library.setVersion(vVersion.elementAt(index).toString()); - } - if (!isEmpty(vUsage.elementAt(index).toString())) { - library.setUsage(LibraryUsage.Enum.forString(vUsage.elementAt(index).toString())); - } - if (!isEmpty(vOverrideID.elementAt(index).toString())) { - library.setOverrideID(Integer.parseInt(vOverrideID.elementAt(index).toString())); - } - libraries.addNewLibrary(); - libraries.setLibraryArray(libraries.getLibraryList().size() - 1, library); - } - } - // - //Save as Arch - // - if (this.jCheckBoxArch.isSelected()) { - LibrariesDocument.Libraries.Arch arch = LibrariesDocument.Libraries.Arch.Factory.newInstance(); - if (this.operation == 2) { - //First remove all existed filename - for (int index = libraries.getArchArray(location).getLibraryList().size() - 1; index >= 0; index--) { - libraries.getArchArray(location).removeLibrary(index); - } - } - for (int index = 0; index < vName.size(); index++) { - LibrariesDocument.Libraries.Arch.Library library = LibrariesDocument.Libraries.Arch.Library.Factory.newInstance(); - if (!isEmpty(vName.elementAt(index).toString())) { - library.setStringValue(vName.elementAt(index).toString()); - } - if (!isEmpty(vGuid.elementAt(index).toString())) { - library.setGuid(vGuid.elementAt(index).toString()); - } - if (!isEmpty(vLibraryClass.elementAt(index).toString())) { - library.setLibraryClass(vLibraryClass.elementAt(index).toString()); - } - if (!isEmpty(vClassGuid.elementAt(index).toString())) { - library.setClassGuid(vClassGuid.elementAt(index).toString()); - } - if (!isEmpty(vVersion.elementAt(index).toString())) { - library.setVersion(vVersion.elementAt(index).toString()); - } - if (!isEmpty(vUsage.elementAt(index).toString())) { - library.setUsage(LibraryUsage.Enum.forString(vUsage.elementAt(index).toString())); - } - if (!isEmpty(vOverrideID.elementAt(index).toString())) { - library.setOverrideID(Integer.parseInt(vOverrideID.elementAt(index).toString())); - } - arch.addNewLibrary(); - arch.setLibraryArray(arch.getLibraryList().size() - 1, library); - } - arch - .setArchType(SupportedArchitectures.Enum.forString(this.jComboBoxArch.getSelectedItem().toString())); - if (location > -1) { - libraries.setArchArray(location, arch); - } else { - libraries.addNewArch(); - libraries.setArchArray(libraries.getArchList().size() - 1, arch); - } - } - } catch (Exception e) { - Log.err("Update Source Files", e.getMessage()); - } - } - - /** - Get LibrariesDocument.Libraries - - @return LibrariesDocument.Libraries - - **/ - public LibrariesDocument.Libraries getLibraries() { - return libraries; - } - - /** - Set LibrariesDocument.Libraries - - @param libraries The input LibrariesDocument.Libraries - - **/ - public void setLibraries(LibrariesDocument.Libraries libraries) { - this.libraries = libraries; - } -} diff --git a/Tools/Source/ModuleEditor/src/org/tianocore/packaging/module/ui/ModuleAbout.java b/Tools/Source/ModuleEditor/src/org/tianocore/packaging/module/ui/ModuleAbout.java deleted file mode 100644 index eb217f5f0a..0000000000 --- a/Tools/Source/ModuleEditor/src/org/tianocore/packaging/module/ui/ModuleAbout.java +++ /dev/null @@ -1,146 +0,0 @@ -/** @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(); - } -} diff --git a/Tools/Source/ModuleEditor/src/org/tianocore/packaging/module/ui/ModuleBootModes.java b/Tools/Source/ModuleEditor/src/org/tianocore/packaging/module/ui/ModuleBootModes.java deleted file mode 100644 index 308b17dd8e..0000000000 --- a/Tools/Source/ModuleEditor/src/org/tianocore/packaging/module/ui/ModuleBootModes.java +++ /dev/null @@ -1,456 +0,0 @@ -/** @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, 250, 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, 50, 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(415, 35, 65, 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()); - } - } -} diff --git a/Tools/Source/ModuleEditor/src/org/tianocore/packaging/module/ui/ModuleDataHubs.java b/Tools/Source/ModuleEditor/src/org/tianocore/packaging/module/ui/ModuleDataHubs.java deleted file mode 100644 index 79613d2724..0000000000 --- a/Tools/Source/ModuleEditor/src/org/tianocore/packaging/module/ui/ModuleDataHubs.java +++ /dev/null @@ -1,457 +0,0 @@ -/** @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, 250, 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(415, 35, 65, 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, 50, 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()); - } - } -} diff --git a/Tools/Source/ModuleEditor/src/org/tianocore/packaging/module/ui/ModuleEvents.java b/Tools/Source/ModuleEditor/src/org/tianocore/packaging/module/ui/ModuleEvents.java deleted file mode 100644 index 5d6151ff13..0000000000 --- a/Tools/Source/ModuleEditor/src/org/tianocore/packaging/module/ui/ModuleEvents.java +++ /dev/null @@ -1,626 +0,0 @@ -/** @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, 250, 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(415, 60, 65, 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, 50, 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()); - } - } -} diff --git a/Tools/Source/ModuleEditor/src/org/tianocore/packaging/module/ui/ModuleExterns.java b/Tools/Source/ModuleEditor/src/org/tianocore/packaging/module/ui/ModuleExterns.java deleted file mode 100644 index 263f1b44e4..0000000000 --- a/Tools/Source/ModuleEditor/src/org/tianocore/packaging/module/ui/ModuleExterns.java +++ /dev/null @@ -1,1030 +0,0 @@ -/** @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 java.awt.event.ItemEvent; -import java.awt.event.ItemListener; - -import javax.swing.JButton; -import javax.swing.JComboBox; -import javax.swing.JLabel; -import javax.swing.JPanel; -import javax.swing.JTextField; - -import org.tianocore.ExternUsage; -import org.tianocore.ExternsDocument; -import org.tianocore.common.DataValidation; -import org.tianocore.common.Log; -import org.tianocore.packaging.common.ui.IComboBox; -import org.tianocore.packaging.common.ui.IInternalFrame; - -/** - The class is used to create, update DataHub of MSA/MBD file - It extends IInternalFrame - - @since ModuleEditor 1.0 - - **/ -public class ModuleExterns extends IInternalFrame implements ItemListener { - - /// - /// Define class Serial Version UID - /// - private static final long serialVersionUID = -7382008402932047191L; - - // - //Define class members - // - private ExternsDocument.Externs externs = null; - - private int location = -1; - - private JPanel jContentPane = null; - - private JLabel jLabelName = 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 JPanel jPanelType1 = null; - - private JLabel jLabelModuleEntryPoint = null; - - private JLabel jLabelModuleUnloadImage = null; - - private IComboBox iComboBoxModuleEntryPoint = null; - - private IComboBox iComboBoxModuleUnloadImage = null; - - private JPanel jPanelType2 = null; - - private JLabel jLabelConstructor = null; - - private JTextField jTextFieldConstructor = null; - - private JLabel jLabelDestructor = null; - - private JTextField jTextFieldDestructor = null; - - private JComboBox jComboBoxType = null; - - private JPanel jPanelType3 = null; - - private JLabel jLabelDriverBinding = null; - - private JLabel jLabelComponentName = null; - - private IComboBox iComboBoxComponentName = null; - - private IComboBox iComboBoxDriverBinding = null; - - private JLabel jLabelDriverConfig = null; - - private JLabel jLabelDriverDiag = null; - - private IComboBox iComboBoxDriverDiag = null; - - private IComboBox iComboBoxDriverConfig = null; - - private JPanel jPanelType4 = null; - - private JLabel jLabelSetVirtualAddressMapCallBack = null; - - private IComboBox iComboBoxSetVirtualAddressMapCallBack = null; - - private JLabel jLabelExitBootServicesCallBack = null; - - private IComboBox iComboBoxExitBootServicesCallBack = null; - - private JPanel jPanelType5 = null; - - private JLabel jLabelUserDefined = null; - - private IComboBox iComboBoxUserDefined = null; - - /** - 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.setLocation(new java.awt.Point(290, 215)); - jButtonOk.setSize(new java.awt.Dimension(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.setLocation(new java.awt.Point(390, 215)); - jButtonCancel.setSize(new java.awt.Dimension(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, 50, 20)); - } - return jTextFieldOverrideID; - } - - /** - This method initializes jPanelType1 - - @return javax.swing.JPanel jPanelType1 - - **/ - private JPanel getJPanelType1() { - if (jPanelType1 == null) { - jLabelModuleUnloadImage = new JLabel(); - jLabelModuleUnloadImage.setBounds(new java.awt.Rectangle(15, 30, 140, 20)); - jLabelModuleUnloadImage.setText("Module Unload Image"); - jLabelModuleEntryPoint = new JLabel(); - jLabelModuleEntryPoint.setBounds(new java.awt.Rectangle(15, 5, 140, 20)); - jLabelModuleEntryPoint.setText("Module Entry Point"); - jPanelType1 = new JPanel(); - jPanelType1.setLayout(null); - jPanelType1.setBounds(new java.awt.Rectangle(0, 105, 490, 55)); - jPanelType1.add(jLabelModuleEntryPoint, null); - jPanelType1.add(jLabelModuleUnloadImage, null); - jPanelType1.add(getIComboBoxModuleUnloadImage(), null); - jPanelType1.add(getIComboBoxModuleEntryPoint(), null); - } - return jPanelType1; - } - - /** - This method initializes jComboBoxModuleEntryPoint - - @return javax.swing.JComboBox iComboBoxModuleEntryPoint - - **/ - private IComboBox getIComboBoxModuleEntryPoint() { - if (iComboBoxModuleEntryPoint == null) { - iComboBoxModuleEntryPoint = new IComboBox(); - iComboBoxModuleEntryPoint.setBounds(new java.awt.Rectangle(160, 5, 320, 20)); - } - return iComboBoxModuleEntryPoint; - } - - /** - This method initializes jComboBoxModuleUnloadImage - - @return javax.swing.JComboBox iComboBoxModuleUnloadImage - - **/ - private IComboBox getIComboBoxModuleUnloadImage() { - if (iComboBoxModuleUnloadImage == null) { - iComboBoxModuleUnloadImage = new IComboBox(); - iComboBoxModuleUnloadImage.setBounds(new java.awt.Rectangle(160, 30, 320, 20)); - } - return iComboBoxModuleUnloadImage; - } - - /** - This method initializes jPanelType2 - - @return javax.swing.JPanel jPanelType2 - - **/ - private JPanel getJPanelType2() { - if (jPanelType2 == null) { - jLabelDestructor = new JLabel(); - jLabelDestructor.setBounds(new java.awt.Rectangle(15, 30, 140, 20)); - jLabelDestructor.setText("Destructor"); - jLabelConstructor = new JLabel(); - jLabelConstructor.setBounds(new java.awt.Rectangle(15, 5, 140, 20)); - jLabelConstructor.setText("Constructor"); - jPanelType2 = new JPanel(); - jPanelType2.setLayout(null); - jPanelType2.setBounds(new java.awt.Rectangle(0, 105, 490, 55)); - jPanelType2.add(jLabelConstructor, null); - jPanelType2.add(getJTextFieldConstructor(), null); - jPanelType2.add(jLabelDestructor, null); - jPanelType2.add(getJTextFieldDestructor(), null); - } - return jPanelType2; - } - - /** - This method initializes jTextFieldConstructor - - @return javax.swing.JTextField jTextFieldConstructor - - **/ - private JTextField getJTextFieldConstructor() { - if (jTextFieldConstructor == null) { - jTextFieldConstructor = new JTextField(); - jTextFieldConstructor.setBounds(new java.awt.Rectangle(160, 5, 320, 20)); - } - return jTextFieldConstructor; - } - - /** - This method initializes jTextFieldDestructor - - @return javax.swing.JTextField jTextFieldDestructor - - **/ - private JTextField getJTextFieldDestructor() { - if (jTextFieldDestructor == null) { - jTextFieldDestructor = new JTextField(); - jTextFieldDestructor.setBounds(new java.awt.Rectangle(160, 30, 320, 20)); - } - return jTextFieldDestructor; - } - - /** - This method initializes jComboBoxType - - @return javax.swing.JComboBox jComboBoxType - - **/ - private JComboBox getJComboBoxType() { - if (jComboBoxType == null) { - jComboBoxType = new JComboBox(); - jComboBoxType.setBounds(new java.awt.Rectangle(160, 10, 320, 20)); - jComboBoxType.addItemListener(this); - } - return jComboBoxType; - } - - /** - This method initializes jPanelType3 - - @return javax.swing.JPanel jPanelType3 - - **/ - private JPanel getJPanelType3() { - if (jPanelType3 == null) { - jLabelDriverDiag = new JLabel(); - jLabelDriverDiag.setBounds(new java.awt.Rectangle(15, 80, 140, 20)); - jLabelDriverDiag.setText("Driver Diag"); - jLabelDriverConfig = new JLabel(); - jLabelDriverConfig.setBounds(new java.awt.Rectangle(15, 55, 140, 20)); - jLabelDriverConfig.setText("Driver Config"); - jLabelComponentName = new JLabel(); - jLabelComponentName.setBounds(new java.awt.Rectangle(15, 30, 140, 20)); - jLabelComponentName.setText("Component Name"); - jLabelDriverBinding = new JLabel(); - jLabelDriverBinding.setBounds(new java.awt.Rectangle(15, 5, 140, 20)); - jLabelDriverBinding.setText("Driver Binding"); - jPanelType3 = new JPanel(); - jPanelType3.setLayout(null); - jPanelType3.setBounds(new java.awt.Rectangle(0, 105, 490, 105)); - jPanelType3.add(jLabelDriverBinding, null); - jPanelType3.add(jLabelComponentName, null); - jPanelType3.add(getIComboBoxComponentName(), null); - jPanelType3.add(getIComboBoxDriverBinding(), null); - jPanelType3.add(jLabelDriverConfig, null); - jPanelType3.add(jLabelDriverDiag, null); - jPanelType3.add(getIComboBoxDriverDiag(), null); - jPanelType3.add(getIComboBoxDriverConfig(), null); - } - return jPanelType3; - } - - /** - This method initializes jComboBoxComponentName - - @return javax.swing.JComboBox iComboBoxComponentName - - **/ - private IComboBox getIComboBoxComponentName() { - if (iComboBoxComponentName == null) { - iComboBoxComponentName = new IComboBox(); - iComboBoxComponentName.setBounds(new java.awt.Rectangle(160, 30, 320, 20)); - } - return iComboBoxComponentName; - } - - /** - This method initializes jComboBoxDriverBinding - - @return javax.swing.JComboBox iComboBoxDriverBinding - - **/ - private IComboBox getIComboBoxDriverBinding() { - if (iComboBoxDriverBinding == null) { - iComboBoxDriverBinding = new IComboBox(); - iComboBoxDriverBinding.setBounds(new java.awt.Rectangle(160, 5, 320, 20)); - } - return iComboBoxDriverBinding; - } - - /** - This method initializes jComboBoxDriverDiag - - @return javax.swing.JComboBox iComboBoxDriverDiag - - **/ - private IComboBox getIComboBoxDriverDiag() { - if (iComboBoxDriverDiag == null) { - iComboBoxDriverDiag = new IComboBox(); - iComboBoxDriverDiag.setBounds(new java.awt.Rectangle(160, 80, 320, 20)); - } - return iComboBoxDriverDiag; - } - - /** - This method initializes jComboBoxDriverConfig - - @return javax.swing.JComboBox iComboBoxDriverConfig - - */ - private IComboBox getIComboBoxDriverConfig() { - if (iComboBoxDriverConfig == null) { - iComboBoxDriverConfig = new IComboBox(); - iComboBoxDriverConfig.setBounds(new java.awt.Rectangle(160, 55, 320, 20)); - } - return iComboBoxDriverConfig; - } - - /** - This method initializes jPanelType4 - - @return javax.swing.JPanel jPanelType4 - - **/ - private JPanel getJPanelType4() { - if (jPanelType4 == null) { - jLabelExitBootServicesCallBack = new JLabel(); - jLabelExitBootServicesCallBack.setBounds(new java.awt.Rectangle(15, 30, 200, 20)); - jLabelExitBootServicesCallBack.setText("Exit Boot Services Call Back"); - jLabelSetVirtualAddressMapCallBack = new JLabel(); - jLabelSetVirtualAddressMapCallBack.setBounds(new java.awt.Rectangle(15, 5, 200, 20)); - jLabelSetVirtualAddressMapCallBack.setText("Set Virtual Address Map Call Back"); - jPanelType4 = new JPanel(); - jPanelType4.setLayout(null); - jPanelType4.setBounds(new java.awt.Rectangle(0, 105, 490, 55)); - jPanelType4.add(jLabelSetVirtualAddressMapCallBack, null); - jPanelType4.add(getIComboBoxSetVirtualAddressMapCallBack(), null); - jPanelType4.add(jLabelExitBootServicesCallBack, null); - jPanelType4.add(getIComboBoxExitBootServicesCallBack(), null); - } - return jPanelType4; - } - - /** - This method initializes jComboBoxSetVirtualAddressMapCallBack - - @return javax.swing.JComboBox iComboBoxSetVirtualAddressMapCallBack - - **/ - private IComboBox getIComboBoxSetVirtualAddressMapCallBack() { - if (iComboBoxSetVirtualAddressMapCallBack == null) { - iComboBoxSetVirtualAddressMapCallBack = new IComboBox(); - iComboBoxSetVirtualAddressMapCallBack.setBounds(new java.awt.Rectangle(220, 5, 260, 20)); - } - return iComboBoxSetVirtualAddressMapCallBack; - } - - /** - This method initializes jComboBoxExitBootServicesCallBack - - @return javax.swing.JComboBox iComboBoxExitBootServicesCallBack - - **/ - private IComboBox getIComboBoxExitBootServicesCallBack() { - if (iComboBoxExitBootServicesCallBack == null) { - iComboBoxExitBootServicesCallBack = new IComboBox(); - iComboBoxExitBootServicesCallBack.setBounds(new java.awt.Rectangle(220, 30, 260, 20)); - } - return iComboBoxExitBootServicesCallBack; - } - - /** - This method initializes jPanelType5 - - @return javax.swing.JPanel jPanelType5 - - **/ - private JPanel getJPanelType5() { - if (jPanelType5 == null) { - jLabelUserDefined = new JLabel(); - jLabelUserDefined.setBounds(new java.awt.Rectangle(15, 5, 140, 20)); - jLabelUserDefined.setText("User Defined"); - jPanelType5 = new JPanel(); - jPanelType5.setLayout(null); - jPanelType5.setBounds(new java.awt.Rectangle(0, 105, 490, 30)); - jPanelType5.add(jLabelUserDefined, null); - jPanelType5.add(getIComboBoxUserDefined(), null); - } - return jPanelType5; - } - - /** - This method initializes jComboBoxUserDefined - - @return javax.swing.JComboBox iComboBoxUserDefined - - **/ - private IComboBox getIComboBoxUserDefined() { - if (iComboBoxUserDefined == null) { - iComboBoxUserDefined = new IComboBox(); - iComboBoxUserDefined.setBounds(new java.awt.Rectangle(160, 5, 320, 20)); - } - return iComboBoxUserDefined; - } - - public static void main(String[] args) { - - } - - /** - This is the default constructor - - **/ - public ModuleExterns() { - super(); - init(); - this.setVisible(true); - } - - /** - This is the override edit constructor - - @param inExterns The input data of ExternsDocument.Externs - - **/ - public ModuleExterns(ExternsDocument.Externs inExterns) { - super(); - init(inExterns); - this.setVisible(true); - } - - /** - This is the override edit constructor - - @param inExterns The input data of ExternsDocument.Externs - @param type The input data of node type - @param index The input data of node index - - **/ - public ModuleExterns(ExternsDocument.Externs inExterns, int type, int index) { - super(); - init(inExterns, type, index); - this.setVisible(true); - } - - /** - This method initializes this - - @param inExterns The input data of ExternsDocument.Externs - - **/ - private void init(ExternsDocument.Externs inExterns) { - init(); - this.setExterns(inExterns); - } - - /** - This method initializes this - Fill values to all fields if these values are not empty - - @param inExterns The input data of ExternsDocument.Externs - @param type The input data of node type - @param index The input data of node index - - **/ - private void init(ExternsDocument.Externs inExterns, int type, int index) { - init(inExterns); - this.location = index; - if (this.externs.getExternList().size() > 0) { - // - //Get common fields - // - if (this.externs.getExternArray(index).getUsage() != null) { - this.jComboBoxUsage.setSelectedItem(this.externs.getExternArray(index).getUsage().toString()); - } - this.jTextFieldOverrideID.setText(String.valueOf(this.externs.getExternArray(index).getOverrideID())); - // - //Type 1 - // - if (this.externs.getExternArray(index).getModuleEntryPointList().size() > 0) { - this.jComboBoxType.setSelectedIndex(0); - for (int indexI = 0; indexI < this.externs.getExternArray(index).getModuleEntryPointList().size(); indexI++) { - this.iComboBoxModuleEntryPoint.addItem(this.externs.getExternArray(index) - .getModuleEntryPointArray(indexI)); - } - } - if (this.externs.getExternArray(index).getModuleUnloadImageList().size() > 0) { - this.jComboBoxType.setSelectedIndex(0); - for (int indexI = 0; indexI < this.externs.getExternArray(index).getModuleUnloadImageList().size(); indexI++) { - this.iComboBoxModuleUnloadImage.addItem(this.externs.getExternArray(index) - .getModuleUnloadImageArray(indexI)); - } - } - - // - //Type 2 - // - if (this.externs.getExternArray(index).getConstructor() != null) { - this.jComboBoxType.setSelectedIndex(1); - this.jTextFieldConstructor.setText(this.externs.getExternArray(index).getConstructor()); - } - if (this.externs.getExternArray(index).getDestructor() != null) { - this.jComboBoxType.setSelectedIndex(1); - this.jTextFieldDestructor.setText(this.externs.getExternArray(index).getDestructor()); - } - - // - //Type 3 - // - if (this.externs.getExternArray(index).getDriverBindingList().size() > 0) { - this.jComboBoxType.setSelectedIndex(2); - for (int indexI = 0; indexI < this.externs.getExternArray(index).getDriverBindingList().size(); indexI++) { - this.iComboBoxDriverBinding.addItem(this.externs.getExternArray(index) - .getDriverBindingArray(indexI)); - } - } - if (this.externs.getExternArray(index).getComponentNameList().size() > 0) { - this.jComboBoxType.setSelectedIndex(2); - for (int indexI = 0; indexI < this.externs.getExternArray(index).getComponentNameList().size(); indexI++) { - this.iComboBoxComponentName.addItem(this.externs.getExternArray(index) - .getComponentNameArray(indexI)); - } - } - if (this.externs.getExternArray(index).getDriverConfigList().size() > 0) { - this.jComboBoxType.setSelectedIndex(2); - for (int indexI = 0; indexI < this.externs.getExternArray(index).getDriverConfigList().size(); indexI++) { - this.iComboBoxDriverConfig.addItem(this.externs.getExternArray(index).getDriverConfigArray(indexI)); - } - } - if (this.externs.getExternArray(index).getDriverDiagList().size() > 0) { - this.jComboBoxType.setSelectedIndex(2); - for (int indexI = 0; indexI < this.externs.getExternArray(index).getDriverDiagList().size(); indexI++) { - this.iComboBoxDriverDiag.addItem(this.externs.getExternArray(index).getDriverDiagArray(indexI)); - } - } - - // - //Type 4 - // - if (this.externs.getExternArray(index).getSetVirtualAddressMapCallBackList().size() > 0) { - this.jComboBoxType.setSelectedIndex(3); - for (int indexI = 0; indexI < this.externs.getExternArray(index).getSetVirtualAddressMapCallBackList() - .size(); indexI++) { - this.iComboBoxSetVirtualAddressMapCallBack - .addItem(this.externs - .getExternArray(index) - .getSetVirtualAddressMapCallBackArray( - indexI)); - } - } - if (this.externs.getExternArray(index).getExitBootServicesCallBackList().size() > 0) { - this.jComboBoxType.setSelectedIndex(3); - for (int indexI = 0; indexI < this.externs.getExternArray(index).getExitBootServicesCallBackList() - .size(); indexI++) { - this.iComboBoxExitBootServicesCallBack - .addItem(this.externs - .getExternArray(index) - .getExitBootServicesCallBackArray(indexI)); - } - } - - // - //Type 5 - // - if (this.externs.getExternArray(index).getUserDefinedList().size() > 0) { - this.jComboBoxType.setSelectedIndex(4); - for (int indexI = 0; indexI < this.externs.getExternArray(index).getUserDefinedList().size(); indexI++) { - this.iComboBoxUserDefined.addItem(this.externs.getExternArray(index).getUserDefinedArray(indexI)); - } - } - - this.jComboBoxType.setEnabled(false); - switchType(); - } - } - - /** - This method initializes this - - **/ - private void init() { - this.setSize(500, 515); - this.setContentPane(getJContentPane()); - this.setTitle("Externs"); - 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.jComboBoxUsage.setEnabled(!isView); - this.jTextFieldOverrideID.setEnabled(!isView); - // - //Type 1 - // - this.iComboBoxModuleEntryPoint.setEnabled(!isView); - this.iComboBoxModuleUnloadImage.setEnabled(!isView); - - // - //Type 2 - // - this.jTextFieldConstructor.setEnabled(!isView); - this.jTextFieldDestructor.setEnabled(!isView); - - // - //Type 3 - // - this.iComboBoxDriverBinding.setEnabled(!isView); - this.iComboBoxComponentName.setEnabled(!isView); - this.iComboBoxDriverConfig.setEnabled(!isView); - this.iComboBoxDriverDiag.setEnabled(!isView); - - // - //Type 4 - // - this.iComboBoxSetVirtualAddressMapCallBack.setEnabled(!isView); - this.iComboBoxExitBootServicesCallBack.setEnabled(!isView); - - // - //Type 5 - // - this.iComboBoxUserDefined.setEnabled(!isView); - - this.jComboBoxType.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) { - 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)); - jLabelName = new JLabel(); - jLabelName.setText("Choose Type"); - jLabelName.setBounds(new java.awt.Rectangle(15, 10, 140, 20)); - jContentPane = new JPanel(); - jContentPane.setLayout(null); - jContentPane.setSize(new java.awt.Dimension(490, 244)); - jContentPane.add(getJPanelType2(), null); - jContentPane.add(jLabelName, null); - jContentPane.add(getJComboBoxType(), null); - jContentPane.add(getJPanelType3(), null); - jContentPane.add(getJPanelType4(), null); - jContentPane.add(getJPanelType5(), 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(getJPanelType1(), null); - } - return jContentPane; - } - - /** - This method initializes Usage type and Externs type - - **/ - private void initFrame() { - jComboBoxUsage.addItem("ALWAYS_CONSUMED"); - jComboBoxUsage.addItem("ALWAYS_PRODUCED"); - - jComboBoxType.addItem("Entry/Unload"); - jComboBoxType.addItem("Library"); - jComboBoxType.addItem("Driver Bindings"); - jComboBoxType.addItem("Call Backs"); - jComboBoxType.addItem("Other"); - - jPanelType1.setVisible(true); - jPanelType2.setVisible(false); - jPanelType3.setVisible(false); - jPanelType4.setVisible(false); - jPanelType5.setVisible(false); - } - - /* (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(); - } - } - - public void itemStateChanged(ItemEvent arg0) { - if (arg0.getSource() == jComboBoxType) { - if (arg0.getStateChange() == ItemEvent.SELECTED) { - switchType(); - } - } - } - - /** - Show/Hide relevant fields via select different types - - **/ - private void switchType() { - if (jComboBoxType.getSelectedIndex() == 0) { - jPanelType1.setVisible(true); - jPanelType2.setVisible(false); - jPanelType3.setVisible(false); - jPanelType4.setVisible(false); - jPanelType5.setVisible(false); - } - if (jComboBoxType.getSelectedIndex() == 1) { - jPanelType1.setVisible(false); - jPanelType2.setVisible(true); - jPanelType3.setVisible(false); - jPanelType4.setVisible(false); - jPanelType5.setVisible(false); - } - if (jComboBoxType.getSelectedIndex() == 2) { - jPanelType1.setVisible(false); - jPanelType2.setVisible(false); - jPanelType3.setVisible(true); - jPanelType4.setVisible(false); - jPanelType5.setVisible(false); - } - if (jComboBoxType.getSelectedIndex() == 3) { - jPanelType1.setVisible(false); - jPanelType2.setVisible(false); - jPanelType3.setVisible(false); - jPanelType4.setVisible(true); - jPanelType5.setVisible(false); - } - if (jComboBoxType.getSelectedIndex() == 4) { - jPanelType1.setVisible(false); - jPanelType2.setVisible(false); - jPanelType3.setVisible(false); - jPanelType4.setVisible(false); - jPanelType5.setVisible(true); - } - } - - /** - Set ExternsDocument.Externs - - @return ExternsDocument.Externs - - - **/ - public ExternsDocument.Externs getExterns() { - return externs; - } - - /** - Get ExternsDocument.Externs - - @param externs The input ExternsDocument.Externs - - **/ - public void setExterns(ExternsDocument.Externs externs) { - this.externs = externs; - } - - /** - 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 (this.jComboBoxType.getSelectedIndex() == 1) { - if (!isEmpty(this.jTextFieldConstructor.getText()) - && !DataValidation.isConstructor(this.jTextFieldConstructor.getText())) { - Log.err("Incorrect data type for Constructor"); - return false; - } - if (!isEmpty(this.jTextFieldDestructor.getText()) - && !DataValidation.isDestructor(this.jTextFieldDestructor.getText())) { - Log.err("Incorrect data type for Destructor"); - 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 Externs - if exists externs, set the value directly - if not exists externs, new an instance first - - **/ - public void save() { - try { - if (this.externs == null) { - externs = ExternsDocument.Externs.Factory.newInstance(); - } - ExternsDocument.Externs.Extern extern = ExternsDocument.Externs.Extern.Factory.newInstance(); - // - //Save common fields - // - extern.setUsage(ExternUsage.Enum.forString(jComboBoxUsage.getSelectedItem().toString())); - if (!isEmpty(this.jTextFieldOverrideID.getText())) { - extern.setOverrideID(Integer.parseInt(this.jTextFieldOverrideID.getText())); - } - - // - //Save type 1 - // - if (this.jComboBoxType.getSelectedIndex() == 0) { - if (this.iComboBoxModuleEntryPoint.getItemCount() > 0) { - for (int index = 0; index < this.iComboBoxModuleEntryPoint.getItemCount(); index++) { - extern.addNewModuleEntryPoint(); - extern.setModuleEntryPointArray(index, this.iComboBoxModuleEntryPoint.getItemAt(index) - .toString()); - } - } - if (this.iComboBoxModuleEntryPoint.getItemCount() > 0) { - for (int index = 0; index < this.iComboBoxModuleUnloadImage.getItemCount(); index++) { - extern.addNewModuleUnloadImage(); - extern.setModuleUnloadImageArray(index, this.iComboBoxModuleUnloadImage.getItemAt(index) - .toString()); - } - } - } - - // - //Save type 2 - // - if (this.jComboBoxType.getSelectedIndex() == 1) { - if (!isEmpty(this.jTextFieldConstructor.getText())) { - extern.setConstructor(this.jTextFieldConstructor.getText()); - } - if (!isEmpty(this.jTextFieldDestructor.getText())) { - extern.setDestructor(this.jTextFieldDestructor.getText()); - } - } - - // - //Save type 3 - // - if (this.jComboBoxType.getSelectedIndex() == 2) { - if (this.iComboBoxDriverBinding.getItemCount() > 0) { - for (int index = 0; index < this.iComboBoxDriverBinding.getItemCount(); index++) { - extern.addNewDriverBinding(); - extern.setDriverBindingArray(index, this.iComboBoxDriverBinding.getItemAt(index).toString()); - } - } - if (this.iComboBoxComponentName.getItemCount() > 0) { - for (int index = 0; index < this.iComboBoxComponentName.getItemCount(); index++) { - extern.addNewComponentName(); - extern.setComponentNameArray(index, this.iComboBoxComponentName.getItemAt(index).toString()); - } - } - if (this.iComboBoxDriverConfig.getItemCount() > 0) { - for (int index = 0; index < this.iComboBoxDriverConfig.getItemCount(); index++) { - extern.addNewDriverConfig(); - extern.setDriverConfigArray(index, this.iComboBoxDriverConfig.getItemAt(index).toString()); - } - } - if (this.iComboBoxDriverDiag.getItemCount() > 0) { - for (int index = 0; index < this.iComboBoxDriverDiag.getItemCount(); index++) { - extern.addNewDriverDiag(); - extern.setDriverDiagArray(index, this.iComboBoxDriverDiag.getItemAt(index).toString()); - } - } - } - - // - //Save type 4 - // - if (this.jComboBoxType.getSelectedIndex() == 3) { - if (this.iComboBoxSetVirtualAddressMapCallBack.getItemCount() > 0) { - for (int index = 0; index < this.iComboBoxSetVirtualAddressMapCallBack.getItemCount(); index++) { - extern.addNewSetVirtualAddressMapCallBack(); - extern - .setSetVirtualAddressMapCallBackArray( - index, - this.iComboBoxSetVirtualAddressMapCallBack - .getItemAt( - index) - .toString()); - } - } - if (this.iComboBoxExitBootServicesCallBack.getItemCount() > 0) { - for (int index = 0; index < this.iComboBoxExitBootServicesCallBack.getItemCount(); index++) { - extern.addNewExitBootServicesCallBack(); - extern.setExitBootServicesCallBackArray(index, - this.iComboBoxExitBootServicesCallBack.getItemAt(index) - .toString()); - } - } - } - // - //Save type 5 - // - if (this.jComboBoxType.getSelectedIndex() == 4) { - if (this.iComboBoxUserDefined.getItemCount() > 0) { - for (int index = 0; index < this.iComboBoxUserDefined.getItemCount(); index++) { - extern.addNewUserDefined(); - extern.setUserDefinedArray(index, this.iComboBoxUserDefined.getItemAt(index).toString()); - } - } - } - - if (location > -1) { - externs.setExternArray(location, extern); - } else { - externs.addNewExtern(); - externs.setExternArray(externs.getExternList().size() - 1, extern); - } - } catch (Exception e) { - Log.err("Update Externs", e.getMessage()); - } - } -} diff --git a/Tools/Source/ModuleEditor/src/org/tianocore/packaging/module/ui/ModuleFormsets.java b/Tools/Source/ModuleEditor/src/org/tianocore/packaging/module/ui/ModuleFormsets.java deleted file mode 100644 index 192c029f61..0000000000 --- a/Tools/Source/ModuleEditor/src/org/tianocore/packaging/module/ui/ModuleFormsets.java +++ /dev/null @@ -1,457 +0,0 @@ -/** @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, 250, 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(415, 35, 65, 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, 50, 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()); - } - } -} diff --git a/Tools/Source/ModuleEditor/src/org/tianocore/packaging/module/ui/ModuleGuids.java b/Tools/Source/ModuleEditor/src/org/tianocore/packaging/module/ui/ModuleGuids.java deleted file mode 100644 index c4ac34b089..0000000000 --- a/Tools/Source/ModuleEditor/src/org/tianocore/packaging/module/ui/ModuleGuids.java +++ /dev/null @@ -1,675 +0,0 @@ -/** @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, 250, 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(415, 35, 65, 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, 50, 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()); - } - } -} diff --git a/Tools/Source/ModuleEditor/src/org/tianocore/packaging/module/ui/ModuleHobs.java b/Tools/Source/ModuleEditor/src/org/tianocore/packaging/module/ui/ModuleHobs.java deleted file mode 100644 index 0ea8ac8cba..0000000000 --- a/Tools/Source/ModuleEditor/src/org/tianocore/packaging/module/ui/ModuleHobs.java +++ /dev/null @@ -1,596 +0,0 @@ -/** @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, 250, 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(415, 60, 65, 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, 50, 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()); - } - } -} diff --git a/Tools/Source/ModuleEditor/src/org/tianocore/packaging/module/ui/ModuleIncludes.java b/Tools/Source/ModuleEditor/src/org/tianocore/packaging/module/ui/ModuleIncludes.java deleted file mode 100644 index b4dcce7373..0000000000 --- a/Tools/Source/ModuleEditor/src/org/tianocore/packaging/module/ui/ModuleIncludes.java +++ /dev/null @@ -1,865 +0,0 @@ -/** @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; -import org.tianocore.packaging.workspace.common.Workspace; - -/** - 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 vPackageName = new Vector(); - - private Vector vUsage = new Vector(); - - private Vector vPackageType = new Vector(); - - private Vector vUpdatedDate = new Vector(); - - 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 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; - - private JComboBox jComboBoxPackageName = null; - - private Workspace ws = null; - - private Vector vecPackageName = 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 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; - } - - /** - * This method initializes jComboBoxPackageName - * - * @return javax.swing.JComboBox - */ - private JComboBox getJComboBoxPackageName() { - if (jComboBoxPackageName == null) { - jComboBoxPackageName = new JComboBox(); - jComboBoxPackageName.setBounds(new java.awt.Rectangle(160,10,320,20)); - } - return jComboBoxPackageName; - } - - 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.jComboBoxPackageName.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(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); - jContentPane.add(getJComboBoxPackageName(), 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() { - ws = new Workspace(); - vecPackageName = ws.getAllPackageName(); - for (int index = 0; index < vecPackageName.size(); index++) { - jComboBoxPackageName.addItem(vecPackageName.elementAt(index)); - } - - 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.jComboBoxPackageName.getSelectedItem().toString()); - vUsage.addElement(this.jComboBoxUsage.getSelectedItem().toString()); - vPackageType.addElement(this.jComboBoxPackageType.getSelectedItem().toString()); - vUpdatedDate.addElement(this.jTextFieldUpdatedDate.getText()); - jComboBoxFileList.addItem(this.jComboBoxPackageName.getSelectedItem().toString()); - jComboBoxFileList.setSelectedItem(this.jComboBoxPackageName.getSelectedItem().toString()); - - // - // 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.jComboBoxPackageName.getSelectedItem().toString(), 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.jComboBoxPackageName.setSelectedItem(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.jComboBoxPackageName.setSelectedIndex(0); - this.jComboBoxUsage.setSelectedIndex(0); - this.jComboBoxPackageType.setSelectedIndex(0); - 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 fields have correct data types - // - 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()); - } - } -} diff --git a/Tools/Source/ModuleEditor/src/org/tianocore/packaging/module/ui/ModuleLibraryClassDefinitions.java b/Tools/Source/ModuleEditor/src/org/tianocore/packaging/module/ui/ModuleLibraryClassDefinitions.java deleted file mode 100644 index ed81e8e065..0000000000 --- a/Tools/Source/ModuleEditor/src/org/tianocore/packaging/module/ui/ModuleLibraryClassDefinitions.java +++ /dev/null @@ -1,625 +0,0 @@ -/** @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 existing 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 LibraryClassDefinitionsDocument.LibraryClassDefinitions - - **/ - 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; - } -} diff --git a/Tools/Source/ModuleEditor/src/org/tianocore/packaging/module/ui/ModuleMain.java b/Tools/Source/ModuleEditor/src/org/tianocore/packaging/module/ui/ModuleMain.java deleted file mode 100644 index e47dfb795e..0000000000 --- a/Tools/Source/ModuleEditor/src/org/tianocore/packaging/module/ui/ModuleMain.java +++ /dev/null @@ -1,4422 +0,0 @@ -/** @file - - The main GUI for module editor. - - 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.MouseEvent; -import java.awt.event.MouseListener; -import java.awt.event.WindowEvent; -import java.io.File; -import java.io.IOException; - -import javax.swing.JButton; -import javax.swing.JDesktopPane; -import javax.swing.JFileChooser; -import javax.swing.JInternalFrame; -import javax.swing.JMenu; -import javax.swing.JMenuBar; -import javax.swing.JMenuItem; -import javax.swing.JOptionPane; -import javax.swing.JPanel; -import javax.swing.JPopupMenu; -import javax.swing.JScrollPane; -import javax.swing.border.BevelBorder; -import javax.swing.event.TreeSelectionEvent; -import javax.swing.event.TreeSelectionListener; - -import org.apache.xmlbeans.XmlCursor; -import org.apache.xmlbeans.XmlException; -import org.apache.xmlbeans.XmlObject; -import org.apache.xmlbeans.XmlOptions; -import org.tianocore.BootModesDocument; -import org.tianocore.BuildOptionsDocument; -import org.tianocore.DataHubsDocument; -import org.tianocore.EventsDocument; -import org.tianocore.ExternsDocument; -import org.tianocore.FormsetsDocument; -import org.tianocore.GuidsDocument; -import org.tianocore.HobsDocument; -import org.tianocore.IncludesDocument; -import org.tianocore.LibrariesDocument; -import org.tianocore.LibraryClassDefinitionsDocument; -import org.tianocore.LibraryModuleBuildDescriptionDocument; -import org.tianocore.LibraryModuleSurfaceAreaDocument; -import org.tianocore.MbdHeaderDocument; -import org.tianocore.MbdLibHeaderDocument; -import org.tianocore.ModuleBuildDescriptionDocument; -import org.tianocore.ModuleSurfaceAreaDocument; -import org.tianocore.MsaHeaderDocument; -import org.tianocore.MsaLibHeaderDocument; -import org.tianocore.PCDsDocument; -import org.tianocore.PPIsDocument; -import org.tianocore.ProtocolsDocument; -import org.tianocore.SourceFilesDocument; -import org.tianocore.SystemTablesDocument; -import org.tianocore.VariablesDocument; -import org.tianocore.common.IFileFilter; -import org.tianocore.common.Log; -import org.tianocore.packaging.common.ui.IDefaultMutableTreeNode; -import org.tianocore.packaging.common.ui.IDesktopManager; -import org.tianocore.packaging.common.ui.IFrame; -import org.tianocore.packaging.common.ui.ITree; -import org.tianocore.packaging.workspace.common.Workspace; - -/** - The class is used to show main GUI of ModuleEditor - It extends IFrame implements MouseListener, TreeSelectionListener - - @since ModuleEditor 1.0 - - **/ -public class ModuleMain extends IFrame implements MouseListener, TreeSelectionListener { - /// - /// Define class Serial Version UID - /// - private static final long serialVersionUID = -7103240960573031772L; - - // - //Define class members - // - private String currentModule = ""; - - private String saveFileName = ""; - - /// - /// 0 - reserved; 1 - msa; 2 - mbd; 3 - lmsa; 4 - lmbd; - /// - private int currentModuleType = 0; - - private int currentNodeType = -1; - - private String windowTitle = "ModuleEditor 1.0 "; - - private ModuleSurfaceAreaDocument xmlMsaDoc = null; - - private ModuleBuildDescriptionDocument xmlMbdDoc = null; - - private LibraryModuleSurfaceAreaDocument xmlMlsaDoc = null; - - private LibraryModuleBuildDescriptionDocument xmlMlbdDoc = null; - - private MsaHeaderDocument.MsaHeader xmlmh = null; - - private MbdHeaderDocument.MbdHeader xmlmbdh = null; - - private MsaLibHeaderDocument.MsaLibHeader xmlmlh = null; - - private MbdLibHeaderDocument.MbdLibHeader xmlmlbdh = null; - - private LibraryClassDefinitionsDocument.LibraryClassDefinitions xmllcd = null; - - private LibrariesDocument.Libraries xmllib = null; - - private SourceFilesDocument.SourceFiles xmlsf = null; - - private IncludesDocument.Includes xmlic = null; - - private ProtocolsDocument.Protocols xmlpl = null; - - private EventsDocument.Events xmlen = null; - - private HobsDocument.Hobs xmlhob = null; - - private PPIsDocument.PPIs xmlppi = null; - - private VariablesDocument.Variables xmlvb = null; - - private BootModesDocument.BootModes xmlbm = null; - - private SystemTablesDocument.SystemTables xmlst = null; - - private DataHubsDocument.DataHubs xmldh = null; - - private FormsetsDocument.Formsets xmlfs = null; - - private GuidsDocument.Guids xmlgu = null; - - private ExternsDocument.Externs xmlet = null; - - private PCDsDocument.PCDs xmlpcd = null; - - private BuildOptionsDocument.BuildOptions xmlbo = null; - - IDefaultMutableTreeNode dmtnRoot = null; - - private JPanel jContentPane = null; - - private JMenuBar jMenuBar = null; - - private JMenu jMenuModule = null; - - private JMenu jMenuModuleNew = null; - - private JMenuItem jMenuItemModuleNewModule = null; - - private JMenuItem jMenuItemModuleSaveAs = null; - - private JMenuItem jMenuItemModuleExit = null; - - private JMenu jMenuEdit = null; - - private JMenuItem jMenuItemEditAddLibraryClassDefinitions = null; - - private JMenuItem jMenuItemEditAddSourceFiles = null; - - private JMenuItem jMenuItemEditAddIncludes = null; - - private JMenuItem jMenuItemEditAddProtocols = null; - - private JMenuItem jMenuItemEditAddEvents = null; - - private JMenuItem jMenuItemEditAddHobs = null; - - private JMenuItem jMenuItemEditAddPPIs = null; - - private JMenuItem jMenuItemEditAddVariables = null; - - private JMenuItem jMenuItemEditAddBootModes = null; - - private JMenuItem jMenuItemEditAddSystemTables = null; - - private JMenuItem jMenuItemEditAddDataHubs = null; - - private JMenuItem jMenuItemEditAddFormsets = null; - - private JMenuItem jMenuItemEditAddGuids = null; - - private JMenuItem jMenuItemEditAddExterns = null; - - private JMenuItem jMenuItemEditAddPCDs = null; - - private JDesktopPane jDesktopPane = null; - - private IDesktopManager iDesktopManager = new IDesktopManager(); - - private JScrollPane jScrollPaneTree = null; - - private ITree iTree = null; - - private JMenu jMenuHelp = null; - - private JMenuItem jMenuItemHelpAbout = null; - - private JMenu jMenuEditAdd = null; - - private JMenuItem jMenuItemEditDelete = null; - - private JMenuItem jMenuItemEditUpdate = null; - - private JPopupMenu jPopupMenu = null; - - private JMenuItem jMenuItemPopupAdd = null; - - private JMenuItem jMenuItemPopupUpdate = null; - - private JMenuItem jMenuItemPopupDelete = null; - - private Workspace ws = new Workspace(); - - private static final int OPENED = 0; - - private static final int CLOSED = 1; - - private static final int NEW_WITHOUT_CHANGE = 2; - - private static final int NEW_WITH_CHANGE = 3; - - private static final int UPDATE_WITHOUT_CHANGE = 4; - - private static final int UPDATE_WITH_CHANGE = 5; - - private static final int SAVE_WITHOUT_CHANGE = 6; - - private static final int SAVE_WITH_CHANGE = 7; - - private static final int ADD = 1; - - private static final int UPDATE = 2; - - //private static final int DELETE = 3; - - private static final int VIEW = 4; - - private MsaHeader msa = null; - - private MbdHeader mbd = null; - - private MsaLibHeader mlsa = null; - - private MbdLibHeader mlbd = null; - - private ModuleLibraryClassDefinitions mlcd = null; - - private MbdLibraries mlib = null; - - private ModuleSourceFiles msf = null; - - private ModuleIncludes mic = null; - - private ModuleProtocols mp = null; - - private ModuleEvents mev = null; - - private ModuleHobs mh = null; - - private ModulePpis mpp = null; - - private ModuleVariables mv = null; - - private ModuleBootModes mbm = null; - - private ModuleSystemTables mst = null; - - private ModuleDataHubs mdh = null; - - private ModuleFormsets mf = null; - - private ModuleGuids mg = null; - - private ModuleExterns met = null; - - private ModulePCDs mpcd = null; - - private JMenuItem jMenuItemModuleOpenModule = null; - - private JMenuItem jMenuItemModuleNewModuleBuildDescription = null; - - private JMenuItem jMenuItemModuleNewLibraryModule = null; - - private JMenuItem jMenuItemModuleNewLibraryModuleBuildDescription = null; - - private JMenu jMenuModuleOpen = null; - - private JMenuItem jMenuItemModuleOpenModuleBuildDescription = null; - - private JMenuItem jMenuItemModuleOpenLibraryModule = null; - - private JMenuItem jMenuItemModuleOpenLibraryModuleBuildDescription = null; - - private JMenuItem jMenuItemModuleSave = null; - - private JMenuItem jMenuItemModuleClose = null; - - private JMenu jMenuTools = null; - - private JMenu jMenuWindow = null; - - private JMenuItem jMenuItemEditAddLibraries = null; - - private JPanel jPanelOperation = null; - - private JButton jButtonOk = null; - - private JButton jButtonCancel = null; - - /** - This method initializes jMenuBar - - @return javax.swing.JMenuBar Main menu bar for the entire GUI - - **/ - private JMenuBar getjJMenuBar() { - if (jMenuBar == null) { - jMenuBar = new JMenuBar(); - jMenuBar.setPreferredSize(new java.awt.Dimension(0, 18)); - jMenuBar.add(getJMenuModule()); - jMenuBar.add(getJMenuEdit()); - jMenuBar.add(getJMenuTools()); - jMenuBar.add(getJMenuWindow()); - jMenuBar.add(getJMenuHelp()); - } - return jMenuBar; - } - - /** - This method initializes jMenuFile - - @return javax.swing.JMenu jMenuModule - - **/ - private JMenu getJMenuModule() { - if (jMenuModule == null) { - jMenuModule = new JMenu(); - jMenuModule.setText("Module"); - jMenuModule.add(getJMenuModuleNew()); - jMenuModule.addSeparator(); - jMenuModule.add(getJMenuModuleOpen()); - jMenuModule.addSeparator(); - jMenuModule.add(getJMenuItemModuleSave()); - jMenuModule.add(getJMenuItemModuleSaveAs()); - jMenuModule.addSeparator(); - jMenuModule.add(getJMenuItemModuleClose()); - jMenuModule.addSeparator(); - jMenuModule.add(getJMenuItemModuleExit()); - } - return jMenuModule; - } - - /** - This method initializes jMenuItemModuleNewModule - - @return javax.swing.JMenuItem jMenuItemModuleNewModule - - **/ - private JMenuItem getJMenuItemModuleNewModule() { - if (jMenuItemModuleNewModule == null) { - jMenuItemModuleNewModule = new JMenuItem(); - jMenuItemModuleNewModule.setText("Module (.msa)"); - jMenuItemModuleNewModule.addActionListener(this); - } - return jMenuItemModuleNewModule; - } - - /** - This method initializes jMenuItemModuleSaveAs - - @return javax.swing.JMenuItem jMenuItemModuleSaveAs - - **/ - private JMenuItem getJMenuItemModuleSaveAs() { - if (jMenuItemModuleSaveAs == null) { - jMenuItemModuleSaveAs = new JMenuItem(); - jMenuItemModuleSaveAs.setText("Save As..."); - jMenuItemModuleSaveAs.addActionListener(this); - jMenuItemModuleSaveAs.setEnabled(false); - } - return jMenuItemModuleSaveAs; - } - - /** - This method initializes jMenuItemModuleExit - - @return javax.swing.JMenuItem jMenuItemModuleExit - - **/ - private JMenuItem getJMenuItemModuleExit() { - if (jMenuItemModuleExit == null) { - jMenuItemModuleExit = new JMenuItem(); - jMenuItemModuleExit.setText("Exit"); - jMenuItemModuleExit.addActionListener(this); - } - return jMenuItemModuleExit; - } - - /** - This method initializes jMenuEdit - - @return javax.swing.JMenu jMenuEdit - - **/ - private JMenu getJMenuEdit() { - if (jMenuEdit == null) { - jMenuEdit = new JMenu(); - jMenuEdit.setText("Edit"); - jMenuEdit.add(getJMenu()); - jMenuEdit.add(getJMenuItemEditUpdate()); - jMenuEdit.add(getJMenuItemEditDelete()); - } - return jMenuEdit; - } - - /** - This method initializes jMenuItemEditAddLibraryClassDefinitions - - @return javax.swing.JMenuItem jMenuItemEditAddLibraryClassDefinitions - - **/ - private JMenuItem getJMenuItemEditAddLibraryClassDefinitions() { - if (jMenuItemEditAddLibraryClassDefinitions == null) { - jMenuItemEditAddLibraryClassDefinitions = new JMenuItem(); - jMenuItemEditAddLibraryClassDefinitions.setText("Library Class Definitions"); - jMenuItemEditAddLibraryClassDefinitions.addActionListener(this); - } - return jMenuItemEditAddLibraryClassDefinitions; - } - - /** - This method initializes jMenuItemEditAddSourceFiles - - @return javax.swing.JMenuItem jMenuItemEditAddSourceFiles - - **/ - private JMenuItem getJMenuItemEditAddSourceFiles() { - if (jMenuItemEditAddSourceFiles == null) { - jMenuItemEditAddSourceFiles = new JMenuItem(); - jMenuItemEditAddSourceFiles.setText("Source Files"); - jMenuItemEditAddSourceFiles.addActionListener(this); - } - return jMenuItemEditAddSourceFiles; - } - - /** - This method initializes jMenuItemEditAddIncludes - - @return javax.swing.JMenuItem jMenuItemEditAddIncludes - - **/ - private JMenuItem getJMenuItemEditAddIncludes() { - if (jMenuItemEditAddIncludes == null) { - jMenuItemEditAddIncludes = new JMenuItem(); - jMenuItemEditAddIncludes.setText("Includes"); - jMenuItemEditAddIncludes.addActionListener(this); - } - return jMenuItemEditAddIncludes; - } - - /** - This method initializes jMenuItemEditAddProtocols - - @return javax.swing.JMenuItem jMenuItemEditAddProtocols - - **/ - private JMenuItem getJMenuItemEditAddProtocols() { - if (jMenuItemEditAddProtocols == null) { - jMenuItemEditAddProtocols = new JMenuItem(); - jMenuItemEditAddProtocols.setText("Protocols"); - jMenuItemEditAddProtocols.addActionListener(this); - } - return jMenuItemEditAddProtocols; - } - - /** - This method initializes jMenuItemEditAddEvents - - @return javax.swing.JMenuItem jMenuItemEditAddEvents - - **/ - private JMenuItem getJMenuItemEditAddEvents() { - if (jMenuItemEditAddEvents == null) { - jMenuItemEditAddEvents = new JMenuItem(); - jMenuItemEditAddEvents.setText("Events"); - jMenuItemEditAddEvents.addActionListener(this); - } - return jMenuItemEditAddEvents; - } - - /** - This method initializes jMenuItemEditAddHobs - - @return javax.swing.JMenuItem jMenuItemEditAddHobs - - **/ - private JMenuItem getJMenuItemEditAddHobs() { - if (jMenuItemEditAddHobs == null) { - jMenuItemEditAddHobs = new JMenuItem(); - jMenuItemEditAddHobs.setText("Hobs"); - jMenuItemEditAddHobs.addActionListener(this); - } - return jMenuItemEditAddHobs; - } - - /** - This method initializes jMenuItemEditAddPPIs - - @return javax.swing.JMenuItem jMenuItemEditAddPPIs - - **/ - private JMenuItem getJMenuItemEditAddPPIs() { - if (jMenuItemEditAddPPIs == null) { - jMenuItemEditAddPPIs = new JMenuItem(); - jMenuItemEditAddPPIs.setText("PPIs"); - jMenuItemEditAddPPIs.addActionListener(this); - } - return jMenuItemEditAddPPIs; - } - - /** - This method initializes jMenuItemEditAddVariables - - @return javax.swing.JMenuItem jMenuItemEditAddVariables - - **/ - private JMenuItem getJMenuItemEditAddVariables() { - if (jMenuItemEditAddVariables == null) { - jMenuItemEditAddVariables = new JMenuItem(); - jMenuItemEditAddVariables.setText("Variables"); - jMenuItemEditAddVariables.addActionListener(this); - } - return jMenuItemEditAddVariables; - } - - /** - This method initializes jMenuItemEditAddBootModes - - @return javax.swing.JMenuItem jMenuItemEditAddBootModes - - **/ - private JMenuItem getJMenuItemAddBootModes() { - if (jMenuItemEditAddBootModes == null) { - jMenuItemEditAddBootModes = new JMenuItem(); - jMenuItemEditAddBootModes.setText("Boot Modes"); - jMenuItemEditAddBootModes.addActionListener(this); - } - return jMenuItemEditAddBootModes; - } - - /** - This method initializes jMenuItemEditAddSystemTables - - @return javax.swing.JMenuItem jMenuItemEditAddSystemTables - - **/ - private JMenuItem getJMenuItemAddSystemTables() { - if (jMenuItemEditAddSystemTables == null) { - jMenuItemEditAddSystemTables = new JMenuItem(); - jMenuItemEditAddSystemTables.setText("System Tables"); - jMenuItemEditAddSystemTables.addActionListener(this); - } - return jMenuItemEditAddSystemTables; - } - - /** - This method initializes jMenuItemEditAddDataHubs - - @return javax.swing.JMenuItem jMenuItemEditAddDataHubs - - **/ - private JMenuItem getJMenuItemEditAddDataHubs() { - if (jMenuItemEditAddDataHubs == null) { - jMenuItemEditAddDataHubs = new JMenuItem(); - jMenuItemEditAddDataHubs.setText("Data Hubs"); - jMenuItemEditAddDataHubs.addActionListener(this); - } - return jMenuItemEditAddDataHubs; - } - - /** - This method initializes jMenuItemEditAddFormsets - - @return javax.swing.JMenuItem jMenuItemEditAddFormsets - - **/ - private JMenuItem getJMenuItemEditAddFormsets() { - if (jMenuItemEditAddFormsets == null) { - jMenuItemEditAddFormsets = new JMenuItem(); - jMenuItemEditAddFormsets.setText("Formsets"); - jMenuItemEditAddFormsets.addActionListener(this); - } - return jMenuItemEditAddFormsets; - } - - /** - This method initializes jMenuItemEditAddGuids - - @return javax.swing.JMenuItem jMenuItemEditAddGuids - - **/ - private JMenuItem getJMenuItemEditAddGuids() { - if (jMenuItemEditAddGuids == null) { - jMenuItemEditAddGuids = new JMenuItem(); - jMenuItemEditAddGuids.setText("Guids"); - jMenuItemEditAddGuids.addActionListener(this); - } - return jMenuItemEditAddGuids; - } - - /** - This method initializes jMenuItemEditAddExterns - - @return javax.swing.JMenuItem jMenuItemEditAddExterns - - **/ - private JMenuItem getJMenuItemEditAddExterns() { - if (jMenuItemEditAddExterns == null) { - jMenuItemEditAddExterns = new JMenuItem(); - jMenuItemEditAddExterns.setText("Externs"); - jMenuItemEditAddExterns.addActionListener(this); - } - return jMenuItemEditAddExterns; - } - - /** - This method initializes jMenuItemEditAddPCDs - - @return javax.swing.JMenuItem jMenuItemEditAddPCDs - - **/ - private JMenuItem getJMenuItemEditAddPCDs() { - if (jMenuItemEditAddPCDs == null) { - jMenuItemEditAddPCDs = new JMenuItem(); - jMenuItemEditAddPCDs.setText("PCDs"); - jMenuItemEditAddPCDs.addActionListener(this); - } - return jMenuItemEditAddPCDs; - } - - /** - This method initializes jDesktopPane - - @return javax.swing.JDesktopPane jDesktopPane - - **/ - private JDesktopPane getJDesktopPane() { - if (jDesktopPane == null) { - jDesktopPane = new JDesktopPane(); - jDesktopPane.setBounds(new java.awt.Rectangle(295, 1, 500, 515)); - jDesktopPane.setDesktopManager(iDesktopManager); - } - return jDesktopPane; - } - - /** - This method initializes jScrollPaneTree - - @return javax.swing.JScrollPane jScrollPaneTree - - **/ - private JScrollPane getJScrollPaneTree() { - if (jScrollPaneTree == null) { - jScrollPaneTree = new JScrollPane(); - jScrollPaneTree.setBounds(new java.awt.Rectangle(0, 1, 290, 545)); - jScrollPaneTree.setViewportView(getITree()); - } - return jScrollPaneTree; - } - - /** - This method initializes iTree - - @return org.tianocore.packaging.common.ui.ITree iTree - - **/ - private ITree getITree() { - // - //Before open a real module, use an empty root node for the tree - // - IDefaultMutableTreeNode root = new IDefaultMutableTreeNode("No Msa/Mbd file opened", -1, -1); - iTree = new ITree(root); - return iTree; - } - - /** - This method initializes jMenuHelp - - @return javax.swing.JMenu jMenuHelp - - **/ - private JMenu getJMenuHelp() { - if (jMenuHelp == null) { - jMenuHelp = new JMenu(); - jMenuHelp.setText("Help"); - jMenuHelp.add(getJMenuItemHelpAbout()); - } - return jMenuHelp; - } - - /** - This method initializes jMenuItemHelpAbout - - @return javax.swing.JMenuItem jMenuItemHelpAbout - - **/ - private JMenuItem getJMenuItemHelpAbout() { - if (jMenuItemHelpAbout == null) { - jMenuItemHelpAbout = new JMenuItem(); - jMenuItemHelpAbout.setText("About..."); - jMenuItemHelpAbout.addActionListener(this); - } - return jMenuItemHelpAbout; - } - - /** - This method initializes jMenuEditAdd - - @return javax.swing.JMenu jMenuEditAdd - - **/ - private JMenu getJMenu() { - if (jMenuEditAdd == null) { - jMenuEditAdd = new JMenu(); - jMenuEditAdd.setText("Add"); - // - //Add all menu items of menu "Add" - // - jMenuEditAdd.add(getJMenuItemEditAddLibraries()); - jMenuEditAdd.add(getJMenuItemEditAddLibraryClassDefinitions()); - jMenuEditAdd.add(getJMenuItemEditAddSourceFiles()); - jMenuEditAdd.add(getJMenuItemEditAddIncludes()); - jMenuEditAdd.add(getJMenuItemEditAddProtocols()); - jMenuEditAdd.add(getJMenuItemEditAddEvents()); - jMenuEditAdd.add(getJMenuItemEditAddHobs()); - jMenuEditAdd.add(getJMenuItemEditAddPPIs()); - jMenuEditAdd.add(getJMenuItemEditAddVariables()); - jMenuEditAdd.add(getJMenuItemAddBootModes()); - jMenuEditAdd.add(getJMenuItemAddSystemTables()); - jMenuEditAdd.add(getJMenuItemEditAddDataHubs()); - jMenuEditAdd.add(getJMenuItemEditAddFormsets()); - jMenuEditAdd.add(getJMenuItemEditAddGuids()); - jMenuEditAdd.add(getJMenuItemEditAddExterns()); - jMenuEditAdd.add(getJMenuItemEditAddPCDs()); - jMenuEditAdd.setEnabled(false); - } - return jMenuEditAdd; - } - - /** - This method initializes jMenuItemEditDelete - - @return javax.swing.JMenuItem jMenuItemEditDelete - - **/ - private JMenuItem getJMenuItemEditDelete() { - if (jMenuItemEditDelete == null) { - jMenuItemEditDelete = new JMenuItem(); - jMenuItemEditDelete.setText("Delete"); - jMenuItemEditDelete.addActionListener(this); - // - //Disabled when no module is open - // - jMenuItemEditDelete.setEnabled(false); - } - return jMenuItemEditDelete; - } - - /** - This method initializes jMenuItemEditUpdate - - @return javax.swing.JMenuItem jMenuItemEditUpdate - - **/ - private JMenuItem getJMenuItemEditUpdate() { - if (jMenuItemEditUpdate == null) { - jMenuItemEditUpdate = new JMenuItem(); - jMenuItemEditUpdate.setText("Update"); - jMenuItemEditUpdate.addActionListener(this); - // - //Disabled when no module is open - // - jMenuItemEditUpdate.setEnabled(false); - } - return jMenuItemEditUpdate; - } - - /** - This method initializes jPopupMenu - - @return javax.swing.JPopupMenu jPopupMenu - - **/ - private JPopupMenu getJPopupMenu() { - if (jPopupMenu == null) { - jPopupMenu = new JPopupMenu(); - // - //Add menu items of popup menu - // - jPopupMenu.add(getJMenuItemPopupAdd()); - jPopupMenu.add(getJMenuItemPopupUpdate()); - jPopupMenu.add(getJMenuItemPopupDelete()); - jPopupMenu.setBorder(new BevelBorder(BevelBorder.RAISED)); - jPopupMenu.addMouseListener(this); - } - return jPopupMenu; - } - - /** - This method initializes jMenuItemPopupAdd - - @return javax.swing.JMenuItem jMenuItemPopupAdd - - **/ - private JMenuItem getJMenuItemPopupAdd() { - if (jMenuItemPopupAdd == null) { - jMenuItemPopupAdd = new JMenuItem(); - jMenuItemPopupAdd.setText("Add"); - jMenuItemPopupAdd.addActionListener(this); - jMenuItemPopupAdd.setEnabled(false); - } - return jMenuItemPopupAdd; - } - - /** - This method initializes jMenuItemPopupUpdate - - @return javax.swing.JMenuItem jMenuItemPopupUpdate - - **/ - private JMenuItem getJMenuItemPopupUpdate() { - if (jMenuItemPopupUpdate == null) { - jMenuItemPopupUpdate = new JMenuItem(); - jMenuItemPopupUpdate.setText("Update"); - jMenuItemPopupUpdate.addActionListener(this); - jMenuItemPopupUpdate.setEnabled(false); - } - return jMenuItemPopupUpdate; - } - - /** - This method initializes jMenuItemPopupDelete - - @return javax.swing.JMenuItem jMenuItemPopupDelete - - **/ - private JMenuItem getJMenuItemPopupDelete() { - if (jMenuItemPopupDelete == null) { - jMenuItemPopupDelete = new JMenuItem(); - jMenuItemPopupDelete.setText("Delete"); - jMenuItemPopupDelete.addActionListener(this); - jMenuItemPopupDelete.setEnabled(false); - } - return jMenuItemPopupDelete; - } - - /** - This method initializes jMenuModuleNew - - @return javax.swing.JMenu jMenuModuleNew - - **/ - private JMenu getJMenuModuleNew() { - if (jMenuModuleNew == null) { - jMenuModuleNew = new JMenu(); - jMenuModuleNew.setText("New"); - jMenuModuleNew.add(getJMenuItemModuleNewModule()); - jMenuModuleNew.add(getJMenuItemModuleNewModuleBuildDescription()); - jMenuModuleNew.add(getJMenuItemModuleNewLibraryModule()); - jMenuModuleNew.add(getJMenuItemModuleNewLibraryModuleBuildDescription()); - } - return jMenuModuleNew; - } - - /** - This method initializes jMenuItemModuleOpenModule - - @return javax.swing.JMenuItem jMenuItemModuleOpenModule - - **/ - private JMenuItem getJMenuItemModuleOpenModule() { - if (jMenuItemModuleOpenModule == null) { - jMenuItemModuleOpenModule = new JMenuItem(); - jMenuItemModuleOpenModule.setText("Module (.msa)"); - jMenuItemModuleOpenModule.addActionListener(this); - } - return jMenuItemModuleOpenModule; - } - - /** - This method initializes jMenuItemFileNewModuleBuildDescription - - @return javax.swing.JMenuItem jMenuItemModuleNewModuleBuildDescription - - **/ - private JMenuItem getJMenuItemModuleNewModuleBuildDescription() { - if (jMenuItemModuleNewModuleBuildDescription == null) { - jMenuItemModuleNewModuleBuildDescription = new JMenuItem(); - jMenuItemModuleNewModuleBuildDescription.setText("Module Build Description (.mbd)"); - jMenuItemModuleNewModuleBuildDescription.addActionListener(this); - } - return jMenuItemModuleNewModuleBuildDescription; - } - - /** - This method initializes jMenuItemFileNewLibraryModule - - @return javax.swing.JMenuItem jMenuItemModuleNewLibraryModule - - **/ - private JMenuItem getJMenuItemModuleNewLibraryModule() { - if (jMenuItemModuleNewLibraryModule == null) { - jMenuItemModuleNewLibraryModule = new JMenuItem(); - jMenuItemModuleNewLibraryModule.setText("Library Module (*.msa)"); - jMenuItemModuleNewLibraryModule.addActionListener(this); - } - return jMenuItemModuleNewLibraryModule; - } - - /** - This method initializes jMenuItemFileNewLibraryModuleBuildDescription - - @return javax.swing.JMenuItem jMenuItemModuleNewLibraryModuleBuildDescription - - **/ - private JMenuItem getJMenuItemModuleNewLibraryModuleBuildDescription() { - if (jMenuItemModuleNewLibraryModuleBuildDescription == null) { - jMenuItemModuleNewLibraryModuleBuildDescription = new JMenuItem(); - jMenuItemModuleNewLibraryModuleBuildDescription.setText("Library Module Build Description (.mbd)"); - jMenuItemModuleNewLibraryModuleBuildDescription.addActionListener(this); - } - return jMenuItemModuleNewLibraryModuleBuildDescription; - } - - /** - This method initializes jMenuOpen - - @return javax.swing.JMenu jMenuModuleOpen - - **/ - private JMenu getJMenuModuleOpen() { - if (jMenuModuleOpen == null) { - jMenuModuleOpen = new JMenu(); - jMenuModuleOpen.setText("Open"); - jMenuModuleOpen.add(getJMenuItemModuleOpenModule()); - jMenuModuleOpen.add(getJMenuItemModuleOpenModuleBuildDescription()); - jMenuModuleOpen.add(getJMenuItemModuleOpenLibraryModule()); - jMenuModuleOpen.add(getJMenuItemModuleOpenLibraryModuleBuildDescription()); - } - return jMenuModuleOpen; - } - - /** - This method initializes jMenuItemFileOpenModuleBuildDescription - - @return javax.swing.JMenuItem jMenuItemModuleOpenModuleBuildDescription - - **/ - private JMenuItem getJMenuItemModuleOpenModuleBuildDescription() { - if (jMenuItemModuleOpenModuleBuildDescription == null) { - jMenuItemModuleOpenModuleBuildDescription = new JMenuItem(); - jMenuItemModuleOpenModuleBuildDescription.setText("Module Build Description (.mbd)"); - jMenuItemModuleOpenModuleBuildDescription.addActionListener(this); - } - return jMenuItemModuleOpenModuleBuildDescription; - } - - /** - This method initializes jMenuItemFileOpenLibraryModule - - @return javax.swing.JMenuItem jMenuItemModuleOpenLibraryModule - - **/ - private JMenuItem getJMenuItemModuleOpenLibraryModule() { - if (jMenuItemModuleOpenLibraryModule == null) { - jMenuItemModuleOpenLibraryModule = new JMenuItem(); - jMenuItemModuleOpenLibraryModule.setText("Library Module (.msa)"); - jMenuItemModuleOpenLibraryModule.addActionListener(this); - } - return jMenuItemModuleOpenLibraryModule; - } - - /** - This method initializes jMenuItemFileOpenLibraryModuleBuildDescription - - @return javax.swing.JMenuItem jMenuItemModuleOpenLibraryModuleBuildDescription - - **/ - private JMenuItem getJMenuItemModuleOpenLibraryModuleBuildDescription() { - if (jMenuItemModuleOpenLibraryModuleBuildDescription == null) { - jMenuItemModuleOpenLibraryModuleBuildDescription = new JMenuItem(); - jMenuItemModuleOpenLibraryModuleBuildDescription.setText("Library Module Build Description (.mbd)"); - jMenuItemModuleOpenLibraryModuleBuildDescription.addActionListener(this); - } - return jMenuItemModuleOpenLibraryModuleBuildDescription; - } - - /** - This method initializes jMenuItemFileSave - - @return javax.swing.JMenuItem jMenuItemModuleSave - - **/ - private JMenuItem getJMenuItemModuleSave() { - if (jMenuItemModuleSave == null) { - jMenuItemModuleSave = new JMenuItem(); - jMenuItemModuleSave.setText("Save"); - jMenuItemModuleSave.addActionListener(this); - jMenuItemModuleSave.setEnabled(false); - } - return jMenuItemModuleSave; - } - - /** - This method initializes jMenuItemModuleClose - - @return javax.swing.JMenuItem jMenuItemModuleClose - - **/ - private JMenuItem getJMenuItemModuleClose() { - if (jMenuItemModuleClose == null) { - jMenuItemModuleClose = new JMenuItem(); - jMenuItemModuleClose.setText("Close"); - jMenuItemModuleClose.setEnabled(false); - jMenuItemModuleClose.addActionListener(this); - } - return jMenuItemModuleClose; - } - - /** - This method initializes jMenuTools - Reserved - - @return javax.swing.JMenu jMenuTools - - **/ - private JMenu getJMenuTools() { - if (jMenuTools == null) { - jMenuTools = new JMenu(); - jMenuTools.setText("Tools"); - jMenuTools.addActionListener(this); - jMenuTools.setEnabled(false); - } - return jMenuTools; - } - - /** - This method initializes jMenuWindow - Reserved - - @return javax.swing.JMenu jMenuWindow - - **/ - private JMenu getJMenuWindow() { - if (jMenuWindow == null) { - jMenuWindow = new JMenu(); - jMenuWindow.setText("Window"); - jMenuWindow.setEnabled(false); - jMenuWindow.addActionListener(this); - } - return jMenuWindow; - } - - /** - This method initializes jMenuItemEditAddLibraries - - @return javax.swing.JMenuItem jMenuItemEditAddLibraries - - **/ - private JMenuItem getJMenuItemEditAddLibraries() { - if (jMenuItemEditAddLibraries == null) { - jMenuItemEditAddLibraries = new JMenuItem(); - jMenuItemEditAddLibraries.setText("Libraries"); - jMenuItemEditAddLibraries.addActionListener(this); - } - return jMenuItemEditAddLibraries; - } - - /** - This method initializes jPanelOperation - - @return javax.swing.JPanel jPanelOperation - - **/ - private JPanel getJPanelOperation() { - if (jPanelOperation == null) { - jPanelOperation = new JPanel(); - jPanelOperation.setLayout(null); - jPanelOperation.setBounds(new java.awt.Rectangle(295, 520, 500, 25)); - jPanelOperation.add(getJButtonOk(), null); - jPanelOperation.add(getJButtonCancel(), null); - } - return jPanelOperation; - } - - /** - This method initializes jButtonOk - - @return javax.swing.JButton jButtonOk - - **/ - private JButton getJButtonOk() { - if (jButtonOk == null) { - jButtonOk = new JButton(); - jButtonOk.setBounds(new java.awt.Rectangle(395, 2, 90, 20)); - jButtonOk.setText("Ok"); - jButtonOk.setEnabled(false); - jButtonOk.addActionListener(this); - } - return jButtonOk; - } - - /** - This method initializes jButtonCancel - - @return javax.swing.JButton jButtonCancel - - **/ - private JButton getJButtonCancel() { - if (jButtonCancel == null) { - jButtonCancel = new JButton(); - jButtonCancel.setBounds(new java.awt.Rectangle(395, 2, 90, 20)); - jButtonCancel.setText("Cancel"); - jButtonCancel.setEnabled(false); - jButtonCancel.addActionListener(this); - jButtonCancel.setVisible(false); - } - return jButtonCancel; - } - - /* (non-Javadoc) - * @see org.tianocore.packaging.common.ui.IFrame#main(java.lang.String[]) - * - * Main class, start the GUI - * - */ - public static void main(String[] args) { - ModuleMain module = new ModuleMain(); - module.setVisible(true); - } - - /** - This is the default constructor - - **/ - public ModuleMain() { - super(); - init(); - } - - /** - This method initializes this - - - **/ - private void init() { - // - // Check if exists WORKSPACE - // - // - if (!ws.checkCurrentWorkspace()) { - JOptionPane.showConfirmDialog(null, "You haven't a workspace yet. Please setup first.", "Warning", - JOptionPane.DEFAULT_OPTION, JOptionPane.WARNING_MESSAGE); - this.dispose(); - System.exit(0); - } - - this.setSize(800, 600); - this.setResizable(false); - this.setJMenuBar(getjJMenuBar()); - this.setContentPane(getJContentPane()); - this.setTitle(windowTitle + "- [" + ws.getCurrentWorkspace() + "]"); - this.setExitType(1); - this.centerWindow(); - } - - /** - This method initializes jContentPane - - @return javax.swing.JPanel jContentPane - - **/ - private JPanel getJContentPane() { - if (jContentPane == null) { - jContentPane = new JPanel(); - jContentPane.setLayout(null); - jContentPane.add(getJPanelOperation(), null); - jContentPane.add(getJDesktopPane(), null); - jContentPane.add(getJScrollPaneTree(), null); - jContentPane.add(getJPopupMenu(), 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) { - // - // Open relevant frame via clicking different menu items - // - if (arg0.getSource() == jMenuItemHelpAbout) { - ModuleAbout ma = new ModuleAbout(); - ma.setEdited(false); - } - - if (arg0.getSource() == jMenuItemEditAddLibraries) { - showLibraries(ModuleMain.ADD, IDefaultMutableTreeNode.LIBRARIES, -1); - } - - if (arg0.getSource() == jMenuItemEditAddLibraryClassDefinitions) { - showLibraryClassDefinitions(ModuleMain.ADD, IDefaultMutableTreeNode.LIBRARYCLASSDEFINITIONS); - } - - if (arg0.getSource() == jMenuItemEditAddSourceFiles) { - showSourceFiles(ModuleMain.ADD, IDefaultMutableTreeNode.SOURCEFILES, -1); - } - - if (arg0.getSource() == jMenuItemEditAddIncludes) { - showIncludes(ModuleMain.ADD, IDefaultMutableTreeNode.INCLUDES, -1); - } - - if (arg0.getSource() == jMenuItemEditAddProtocols) { - showProtocols(ModuleMain.ADD, IDefaultMutableTreeNode.PROTOCOLS, -1); - } - - if (arg0.getSource() == jMenuItemEditAddEvents) { - showEvents(ModuleMain.ADD, IDefaultMutableTreeNode.EVENTS, -1); - } - - if (arg0.getSource() == jMenuItemEditAddHobs) { - showHobs(ModuleMain.ADD, IDefaultMutableTreeNode.HOBS, -1); - } - - if (arg0.getSource() == jMenuItemEditAddPPIs) { - showPpis(ModuleMain.ADD, IDefaultMutableTreeNode.PPIS, -1); - } - - if (arg0.getSource() == jMenuItemEditAddVariables) { - showVariables(ModuleMain.ADD, IDefaultMutableTreeNode.VARIABLES, -1); - } - - if (arg0.getSource() == jMenuItemEditAddBootModes) { - showBootModes(ModuleMain.ADD, IDefaultMutableTreeNode.BOOTMODES, -1); - } - - if (arg0.getSource() == jMenuItemEditAddSystemTables) { - showSystemTables(ModuleMain.ADD, IDefaultMutableTreeNode.SYSTEMTABLES, -1); - } - - if (arg0.getSource() == jMenuItemEditAddDataHubs) { - showDataHubs(ModuleMain.ADD, IDefaultMutableTreeNode.DATAHUBS, -1); - } - - if (arg0.getSource() == jMenuItemEditAddFormsets) { - showFormsets(ModuleMain.ADD, IDefaultMutableTreeNode.FORMSETS, -1); - } - - if (arg0.getSource() == jMenuItemEditAddGuids) { - showGuids(ModuleMain.ADD, IDefaultMutableTreeNode.GUIDS, -1); - } - - if (arg0.getSource() == jMenuItemEditAddExterns) { - showExterns(ModuleMain.ADD, IDefaultMutableTreeNode.EXTERNS, -1); - } - - if (arg0.getSource() == jMenuItemEditAddPCDs) { - showPCDs(ModuleMain.ADD, IDefaultMutableTreeNode.PCDS, -1); - } - - if (arg0.getSource() == jMenuItemModuleNewModule) { - this.closeCurrentModule(); - showMsaHeader(ModuleMain.ADD); - } - - if (arg0.getSource() == jMenuItemModuleNewModuleBuildDescription) { - this.closeCurrentModule(); - showMbdHeader(ModuleMain.ADD); - } - - if (arg0.getSource() == jMenuItemModuleNewLibraryModule) { - this.closeCurrentModule(); - showMlsaHeader(ModuleMain.ADD); - } - - if (arg0.getSource() == jMenuItemModuleNewLibraryModuleBuildDescription) { - this.closeCurrentModule(); - showMlbdHeader(ModuleMain.ADD); - } - - // - // Open Msa, Mbd, Lmsa and Lmbd - // - if (arg0.getSource() == jMenuItemModuleOpenModule) { - openFile(1, 1); - } - - if (arg0.getSource() == jMenuItemModuleOpenModuleBuildDescription) { - openFile(1, 2); - } - - if (arg0.getSource() == jMenuItemModuleOpenLibraryModule) { - openFile(1, 3); - } - - if (arg0.getSource() == jMenuItemModuleOpenLibraryModuleBuildDescription) { - openFile(1, 4); - } - - // - // Listen popup menu items - // - if (arg0.getSource() == jMenuItemPopupAdd) { - int intCategory = iTree.getSelectCategory(); - int intLocation = iTree.getSelectLoaction(); - addCurrentModule(intCategory, intLocation); - } - - if (arg0.getSource() == jMenuItemPopupUpdate || arg0.getSource() == jMenuItemEditUpdate) { - int intCategory = iTree.getSelectCategory(); - int intLocation = iTree.getSelectLoaction(); - updateCurrentModule(intCategory, intLocation); - } - - if (arg0.getSource() == jMenuItemPopupDelete || arg0.getSource() == jMenuItemEditDelete) { - int intCategory = iTree.getSelectCategory(); - int intLocation = iTree.getSelectLoaction(); - deleteCurrentModule(intCategory, intLocation); - } - - if (arg0.getSource() == jMenuItemModuleExit) { - this.onExit(); - } - - if (arg0.getSource() == jMenuItemModuleClose) { - closeCurrentModule(); - } - - if (arg0.getSource() == jMenuItemModuleSaveAs) { - saveAsCurrentModule(); - } - - if (arg0.getSource() == jMenuItemModuleSave) { - saveCurrentModule(); - } - - if (arg0.getSource() == jButtonOk) { - save(); - } - - if (arg0.getSource() == jButtonCancel) { - - } - } - - /** - Open file - - @param intOperationType Open - 1 or Save - 2 - @param intFileType Msa - 1, Mbd - 2, Lmsa - 3, Lmbd - 4 - @return opened file path - - **/ - private void openFile(int intOperationType, int intFileType) { - String strCurrentPath = ""; - if (this.currentModule == "") { - strCurrentPath = ws.getCurrentWorkspace(); - } else { - strCurrentPath = this.currentModule - .substring( - 0, - this.currentModule - .lastIndexOf(System - .getProperty("file.separator"))); - } - - JFileChooser fc = new JFileChooser(strCurrentPath); - fc.setAcceptAllFileFilterUsed(false); - switch (intOperationType) { - case 1: - fc.setDialogTitle("Open"); - break; - case 2: - fc.setDialogTitle("Save As"); - break; - } - // - // Config File Filter via different file types - // - switch (intFileType) { - case 1: - fc.addChoosableFileFilter(new IFileFilter("msa")); - break; - case 2: - fc.addChoosableFileFilter(new IFileFilter("mbd")); - break; - case 3: - fc.addChoosableFileFilter(new IFileFilter("msa")); - break; - case 4: - fc.addChoosableFileFilter(new IFileFilter("mbd")); - break; - } - - int result = fc.showOpenDialog(new JPanel()); - // - // Open relevanf file after click "OK" - // - if (result == JFileChooser.APPROVE_OPTION) { - switch (intOperationType) { - case 1: - closeCurrentModule(); - switch (intFileType) { - case 1: - openMsaFile(fc.getSelectedFile().getPath()); - break; - case 2: - openMbdFile(fc.getSelectedFile().getPath()); - break; - case 3: - openMlsaFile(fc.getSelectedFile().getPath()); - break; - case 4: - openMlbdFile(fc.getSelectedFile().getPath()); - break; - } - break; - case 2: - switch (intFileType) { - case 1: - this.saveFileName = fc.getSelectedFile().getPath(); - break; - case 2: - this.saveFileName = fc.getSelectedFile().getPath(); - break; - case 3: - this.saveFileName = fc.getSelectedFile().getPath(); - break; - case 4: - this.saveFileName = fc.getSelectedFile().getPath(); - break; - } - break; - } - } else { - if (intOperationType == 2) { - this.saveFileName = ""; - } - } - } - - /** - Open specificed Msa file and read its content - - @param strMsaFilePath The input data of Msa File Path - - **/ - private void openMsaFile(String strMsaFilePath) { - Log.log("Open Msa", strMsaFilePath); - try { - File msaFile = new File(strMsaFilePath); - xmlMsaDoc = (ModuleSurfaceAreaDocument) XmlObject.Factory.parse(msaFile); - this.currentModule = strMsaFilePath; - this.saveFileName = strMsaFilePath; - this.currentModuleType = 1; - } catch (IOException e) { - Log.err("Open Msa " + strMsaFilePath, e.getMessage()); - return; - } catch (XmlException e) { - Log.err("Open Msa " + strMsaFilePath, e.getMessage()); - return; - } catch (Exception e) { - Log.err("Open Msa " + strMsaFilePath, "Invalid file type"); - return; - } - - xmlmh = xmlMsaDoc.getModuleSurfaceArea().getMsaHeader(); - xmllcd = xmlMsaDoc.getModuleSurfaceArea().getLibraryClassDefinitions(); - xmlsf = xmlMsaDoc.getModuleSurfaceArea().getSourceFiles(); - xmlic = xmlMsaDoc.getModuleSurfaceArea().getIncludes(); - xmlpl = xmlMsaDoc.getModuleSurfaceArea().getProtocols(); - xmlen = xmlMsaDoc.getModuleSurfaceArea().getEvents(); - xmlhob = xmlMsaDoc.getModuleSurfaceArea().getHobs(); - xmlppi = xmlMsaDoc.getModuleSurfaceArea().getPPIs(); - xmlvb = xmlMsaDoc.getModuleSurfaceArea().getVariables(); - xmlbm = xmlMsaDoc.getModuleSurfaceArea().getBootModes(); - xmlst = xmlMsaDoc.getModuleSurfaceArea().getSystemTables(); - xmldh = xmlMsaDoc.getModuleSurfaceArea().getDataHubs(); - xmlfs = xmlMsaDoc.getModuleSurfaceArea().getFormsets(); - xmlgu = xmlMsaDoc.getModuleSurfaceArea().getGuids(); - xmlet = xmlMsaDoc.getModuleSurfaceArea().getExterns(); - xmlpcd = xmlMsaDoc.getModuleSurfaceArea().getPCDs(); - xmlbo = xmlMsaDoc.getModuleSurfaceArea().getBuildOptions(); - - this.showMsaHeader(ModuleMain.VIEW); - reloadTreeAndTable(ModuleMain.OPENED); - jMenuEditAdd.setEnabled(true); - } - - /** - Open specificed Mbd file and read its content - - @param strMbdFilePath The input data of Mbd File Path - - **/ - private void openMbdFile(String strMbdFilePath) { - Log.log("Open Mbd", strMbdFilePath); - try { - File mbdFile = new File(strMbdFilePath); - xmlMbdDoc = (ModuleBuildDescriptionDocument) XmlObject.Factory.parse(mbdFile); - this.currentModule = strMbdFilePath; - this.saveFileName = strMbdFilePath; - this.currentModuleType = 2; - } catch (IOException e) { - Log.err("Open Mbd " + strMbdFilePath, e.getMessage()); - return; - } catch (XmlException e) { - Log.err("Open Mbd " + strMbdFilePath, e.getMessage()); - return; - } catch (Exception e) { - Log.err("Open Mbd " + strMbdFilePath, "Invalid file type"); - return; - } - - xmlmbdh = xmlMbdDoc.getModuleBuildDescription().getMbdHeader(); - xmllib = xmlMbdDoc.getModuleBuildDescription().getLibraries(); - xmlsf = xmlMbdDoc.getModuleBuildDescription().getSourceFiles(); - xmlic = xmlMbdDoc.getModuleBuildDescription().getIncludes(); - xmlpl = xmlMbdDoc.getModuleBuildDescription().getProtocols(); - xmlen = xmlMbdDoc.getModuleBuildDescription().getEvents(); - xmlhob = xmlMbdDoc.getModuleBuildDescription().getHobs(); - xmlppi = xmlMbdDoc.getModuleBuildDescription().getPPIs(); - xmlvb = xmlMbdDoc.getModuleBuildDescription().getVariables(); - xmlbm = xmlMbdDoc.getModuleBuildDescription().getBootModes(); - xmlst = xmlMbdDoc.getModuleBuildDescription().getSystemTables(); - xmldh = xmlMbdDoc.getModuleBuildDescription().getDataHubs(); - xmlfs = xmlMbdDoc.getModuleBuildDescription().getFormsets(); - xmlgu = xmlMbdDoc.getModuleBuildDescription().getGuids(); - xmlet = xmlMbdDoc.getModuleBuildDescription().getExterns(); - xmlpcd = xmlMbdDoc.getModuleBuildDescription().getPCDs(); - xmlbo = xmlMbdDoc.getModuleBuildDescription().getBuildOptions(); - - this.showMbdHeader(ModuleMain.VIEW); - reloadTreeAndTable(ModuleMain.OPENED); - jMenuEditAdd.setEnabled(true); - } - - /** - Open specificed Mlsa file and read its content - - @param strMlsaFilePath The input data of Mlsa File Path - - **/ - private void openMlsaFile(String strMlsaFilePath) { - Log.log("Open Mlsa", strMlsaFilePath); - try { - File mlsaFile = new File(strMlsaFilePath); - xmlMlsaDoc = (LibraryModuleSurfaceAreaDocument) XmlObject.Factory.parse(mlsaFile); - this.currentModule = strMlsaFilePath; - this.saveFileName = strMlsaFilePath; - this.currentModuleType = 3; - } catch (IOException e) { - Log.err("Open Mlsa " + strMlsaFilePath, e.getMessage()); - return; - } catch (XmlException e) { - Log.err("Open Mlsa " + strMlsaFilePath, e.getMessage()); - return; - } catch (Exception e) { - Log.err("Open Mlsa " + strMlsaFilePath, "Invalid file type"); - return; - } - - xmlmlh = xmlMlsaDoc.getLibraryModuleSurfaceArea().getMsaLibHeader(); - xmllcd = xmlMlsaDoc.getLibraryModuleSurfaceArea().getLibraryClassDefinitions(); - xmlsf = xmlMlsaDoc.getLibraryModuleSurfaceArea().getSourceFiles(); - xmlic = xmlMlsaDoc.getLibraryModuleSurfaceArea().getIncludes(); - xmlpl = xmlMlsaDoc.getLibraryModuleSurfaceArea().getProtocols(); - xmlen = xmlMlsaDoc.getLibraryModuleSurfaceArea().getEvents(); - xmlhob = xmlMlsaDoc.getLibraryModuleSurfaceArea().getHobs(); - xmlppi = xmlMlsaDoc.getLibraryModuleSurfaceArea().getPPIs(); - xmlvb = xmlMlsaDoc.getLibraryModuleSurfaceArea().getVariables(); - xmlbm = xmlMlsaDoc.getLibraryModuleSurfaceArea().getBootModes(); - xmlst = xmlMlsaDoc.getLibraryModuleSurfaceArea().getSystemTables(); - xmldh = xmlMlsaDoc.getLibraryModuleSurfaceArea().getDataHubs(); - xmlfs = xmlMlsaDoc.getLibraryModuleSurfaceArea().getFormsets(); - xmlgu = xmlMlsaDoc.getLibraryModuleSurfaceArea().getGuids(); - xmlet = xmlMlsaDoc.getLibraryModuleSurfaceArea().getExterns(); - xmlpcd = xmlMlsaDoc.getLibraryModuleSurfaceArea().getPCDs(); - xmlbo = xmlMlsaDoc.getLibraryModuleSurfaceArea().getBuildOptions(); - - this.showMlsaHeader(ModuleMain.VIEW); - reloadTreeAndTable(ModuleMain.OPENED); - jMenuEditAdd.setEnabled(true); - } - - /** - Open specificed Mlbd file and read its content - - @param strMlbdFilePath The input data of Mlbd File Path - - **/ - private void openMlbdFile(String strMlbdFilePath) { - Log.log("Open Mlbd", strMlbdFilePath); - try { - File mlbdFile = new File(strMlbdFilePath); - xmlMlbdDoc = (LibraryModuleBuildDescriptionDocument) XmlObject.Factory.parse(mlbdFile); - this.currentModule = strMlbdFilePath; - this.saveFileName = strMlbdFilePath; - this.currentModuleType = 4; - } catch (IOException e) { - Log.err("Open Mlbd " + strMlbdFilePath, e.getMessage()); - return; - } catch (XmlException e) { - Log.err("Open Mlbd " + strMlbdFilePath, e.getMessage()); - return; - } catch (Exception e) { - Log.err("Open Mlbd " + strMlbdFilePath, "Invalid file type"); - return; - } - - xmlmlbdh = xmlMlbdDoc.getLibraryModuleBuildDescription().getMbdLibHeader(); - xmllib = xmlMlbdDoc.getLibraryModuleBuildDescription().getLibraries(); - xmlsf = xmlMlbdDoc.getLibraryModuleBuildDescription().getSourceFiles(); - xmlic = xmlMlbdDoc.getLibraryModuleBuildDescription().getIncludes(); - xmlpl = xmlMlbdDoc.getLibraryModuleBuildDescription().getProtocols(); - xmlen = xmlMlbdDoc.getLibraryModuleBuildDescription().getEvents(); - xmlhob = xmlMlbdDoc.getLibraryModuleBuildDescription().getHobs(); - xmlppi = xmlMlbdDoc.getLibraryModuleBuildDescription().getPPIs(); - xmlvb = xmlMlbdDoc.getLibraryModuleBuildDescription().getVariables(); - xmlbm = xmlMlbdDoc.getLibraryModuleBuildDescription().getBootModes(); - xmlst = xmlMlbdDoc.getLibraryModuleBuildDescription().getSystemTables(); - xmldh = xmlMlbdDoc.getLibraryModuleBuildDescription().getDataHubs(); - xmlfs = xmlMlbdDoc.getLibraryModuleBuildDescription().getFormsets(); - xmlgu = xmlMlbdDoc.getLibraryModuleBuildDescription().getGuids(); - xmlet = xmlMlbdDoc.getLibraryModuleBuildDescription().getExterns(); - xmlpcd = xmlMlbdDoc.getLibraryModuleBuildDescription().getPCDs(); - xmlbo = xmlMlbdDoc.getLibraryModuleBuildDescription().getBuildOptions(); - - this.showMlbdHeader(ModuleMain.VIEW); - reloadTreeAndTable(ModuleMain.OPENED); - jMenuEditAdd.setEnabled(true); - } - - /** - Create an empty tree if no file is open - - **/ - private void makeEmptyTree() { - dmtnRoot = new IDefaultMutableTreeNode("No Msa/Mbd file opened", -1, -1); - iTree = new ITree(dmtnRoot); - jScrollPaneTree.setViewportView(iTree); - } - - /** - Create the tree to display all components of current open file. - First to check if the component is null or not - If not null, hangs it to the tree - If null, skip it - - **/ - private void makeTree() { - iTree.removeAll(); - - // - //Make an empty tree when closing - // - if (this.currentModuleType == 0) { - makeEmptyTree(); - return; - } - - // - //Msa File - // - if (this.currentModuleType == 1) { - // - //Add MsaHeader Node - // - if (xmlmh != null) { - dmtnRoot = new IDefaultMutableTreeNode(xmlmh.getBaseName().getStringValue(), - IDefaultMutableTreeNode.MSA_HEADER, - IDefaultMutableTreeNode.OPERATION_UPDATE_DELETE); - } else { - makeEmptyTree(); - return; - } - - // - //Add LibraryClassDefinitions Node - // - if (xmllcd != null && xmllcd.getLibraryClassList().size() > 0) { - IDefaultMutableTreeNode libraryClassDefinitions = new IDefaultMutableTreeNode( - "Library Class Definitions", - IDefaultMutableTreeNode.LIBRARYCLASSDEFINITIONS, - IDefaultMutableTreeNode.OPERATION_UPDATE_DELETE); - for (int indexI = 0; indexI < xmllcd.getLibraryClassList().size(); indexI++) { - libraryClassDefinitions - .add(new IDefaultMutableTreeNode( - xmllcd.getLibraryClassArray(indexI) - .getStringValue(), - IDefaultMutableTreeNode.LIBRARY_CLASS_DEFINITION, - IDefaultMutableTreeNode.OPERATION_NULL)); - } - dmtnRoot.add(libraryClassDefinitions); - } - } - - // - //Mbd File - // - if (this.currentModuleType == 2) { - // - //Add MsaHeader Node - // - if (xmlmbdh != null) { - dmtnRoot = new IDefaultMutableTreeNode(xmlmbdh.getBaseName().getStringValue(), - IDefaultMutableTreeNode.MBD_HEADER, - IDefaultMutableTreeNode.OPERATION_UPDATE_DELETE); - } else { - makeEmptyTree(); - return; - } - - // - //Add Libraries Node - // - if (xmllib != null) { - IDefaultMutableTreeNode libraries = new IDefaultMutableTreeNode( - "Libraries", - IDefaultMutableTreeNode.LIBRARIES, - IDefaultMutableTreeNode.OPERATION_ADD_DELETE); - if (xmllib.getArchList().size() > 0) { - IDefaultMutableTreeNode librariesArch = new IDefaultMutableTreeNode( - "Arch", - IDefaultMutableTreeNode.LIBRARIES_ARCH, - IDefaultMutableTreeNode.OPERATION_ADD_DELETE); - for (int indexI = 0; indexI < xmllib.getArchList().size(); indexI++) { - librariesArch.add(new IDefaultMutableTreeNode(xmllib.getArchArray(indexI).getArchType() - .toString(), - IDefaultMutableTreeNode.LIBRARIES_ARCH_ITEM, - IDefaultMutableTreeNode.OPERATION_UPDATE_DELETE, - indexI)); - } - libraries.add(librariesArch); - } - if (xmllib.getLibraryList().size() > 0) { - IDefaultMutableTreeNode library = new IDefaultMutableTreeNode( - "Library", - IDefaultMutableTreeNode.LIBRARIES_LIBRARY, - IDefaultMutableTreeNode.OPERATION_ADD_UPDATE_DELETE); - for (int indexI = 0; indexI < xmllib.getLibraryList().size(); indexI++) { - library.add(new IDefaultMutableTreeNode(xmllib.getLibraryArray(indexI).getStringValue(), - IDefaultMutableTreeNode.LIBRARIES_LIBRARY_ITEM, - IDefaultMutableTreeNode.OPERATION_DELETE)); - } - libraries.add(library); - } - dmtnRoot.add(libraries); - } - } - - // - //MLsa File - // - if (this.currentModuleType == 3) { - // - //Add MsaHeader Node - // - if (xmlmlh != null) { - dmtnRoot = new IDefaultMutableTreeNode(xmlmlh.getBaseName().getStringValue(), - IDefaultMutableTreeNode.MLSA_HEADER, - IDefaultMutableTreeNode.OPERATION_UPDATE_DELETE); - } else { - makeEmptyTree(); - return; - } - - // - //Add LibraryClassDefinitions Node - // - if (xmllcd != null && xmllcd.getLibraryClassList().size() > 0) { - IDefaultMutableTreeNode libraryClassDefinitions = new IDefaultMutableTreeNode( - "Library Class Definitions", - IDefaultMutableTreeNode.LIBRARYCLASSDEFINITIONS, - IDefaultMutableTreeNode.OPERATION_UPDATE_DELETE); - for (int indexI = 0; indexI < xmllcd.getLibraryClassList().size(); indexI++) { - libraryClassDefinitions - .add(new IDefaultMutableTreeNode( - xmllcd.getLibraryClassArray(indexI) - .getStringValue(), - IDefaultMutableTreeNode.LIBRARY_CLASS_DEFINITION, - IDefaultMutableTreeNode.OPERATION_NULL)); - } - dmtnRoot.add(libraryClassDefinitions); - } - } - - // - //Mlbd File - // - if (this.currentModuleType == 4) { - // - //Add MsaHeader Node - // - if (xmlmlbdh != null) { - dmtnRoot = new IDefaultMutableTreeNode(xmlmlbdh.getBaseName().getStringValue(), - IDefaultMutableTreeNode.MLBD_HEADER, - IDefaultMutableTreeNode.OPERATION_UPDATE_DELETE); - } else { - makeEmptyTree(); - return; - } - - // - //Add Libraries Node - // - if (xmllib != null) { - IDefaultMutableTreeNode libraries = new IDefaultMutableTreeNode( - "Libraries", - IDefaultMutableTreeNode.LIBRARIES, - IDefaultMutableTreeNode.OPERATION_ADD_DELETE); - if (xmllib.getArchList().size() > 0) { - IDefaultMutableTreeNode librariesArch = new IDefaultMutableTreeNode( - "Arch", - IDefaultMutableTreeNode.LIBRARIES_ARCH, - IDefaultMutableTreeNode.OPERATION_ADD_DELETE); - for (int indexI = 0; indexI < xmllib.getArchList().size(); indexI++) { - librariesArch.add(new IDefaultMutableTreeNode(xmllib.getArchArray(indexI).getArchType() - .toString(), - IDefaultMutableTreeNode.LIBRARIES_ARCH_ITEM, - IDefaultMutableTreeNode.OPERATION_UPDATE_DELETE, - indexI)); - } - libraries.add(librariesArch); - } - if (xmllib.getLibraryList().size() > 0) { - IDefaultMutableTreeNode library = new IDefaultMutableTreeNode( - "Library", - IDefaultMutableTreeNode.LIBRARIES_LIBRARY, - IDefaultMutableTreeNode.OPERATION_ADD_UPDATE_DELETE); - for (int indexI = 0; indexI < xmllib.getLibraryList().size(); indexI++) { - library.add(new IDefaultMutableTreeNode(xmllib.getLibraryArray(indexI).getStringValue(), - IDefaultMutableTreeNode.LIBRARIES_LIBRARY_ITEM, - IDefaultMutableTreeNode.OPERATION_DELETE)); - } - libraries.add(library); - } - dmtnRoot.add(libraries); - } - } - - // - //Add SourceFiles Node - // - if (xmlsf != null) { - IDefaultMutableTreeNode sourceFiles = new IDefaultMutableTreeNode( - "Source Files", - IDefaultMutableTreeNode.SOURCEFILES, - IDefaultMutableTreeNode.OPERATION_ADD_DELETE); - if (xmlsf.getArchList().size() > 0) { - IDefaultMutableTreeNode sourceFilesArch = new IDefaultMutableTreeNode( - "Arch", - IDefaultMutableTreeNode.SOURCEFILES_ARCH, - IDefaultMutableTreeNode.OPERATION_ADD_DELETE); - for (int indexI = 0; indexI < xmlsf.getArchList().size(); indexI++) { - sourceFilesArch - .add(new IDefaultMutableTreeNode( - xmlsf.getArchArray(indexI).getArchType().toString(), - IDefaultMutableTreeNode.SOURCEFILES_ARCH_ITEM, - IDefaultMutableTreeNode.OPERATION_UPDATE_DELETE, - indexI)); - } - sourceFiles.add(sourceFilesArch); - } - if (xmlsf.getFilenameList().size() > 0) { - IDefaultMutableTreeNode sourceFilesFileName = new IDefaultMutableTreeNode( - "File Name", - IDefaultMutableTreeNode.SOURCEFILES_FILENAME, - IDefaultMutableTreeNode.OPERATION_ADD_UPDATE_DELETE); - for (int indexI = 0; indexI < xmlsf.getFilenameList().size(); indexI++) { - sourceFilesFileName - .add(new IDefaultMutableTreeNode( - xmlsf.getFilenameArray(indexI).getStringValue(), - IDefaultMutableTreeNode.SOURCEFILES_FILENAME_ITEM, - IDefaultMutableTreeNode.OPERATION_DELETE)); - } - sourceFiles.add(sourceFilesFileName); - } - dmtnRoot.add(sourceFiles); - } - - // - //Add includes - // - if (xmlic != null) { - IDefaultMutableTreeNode includes = new IDefaultMutableTreeNode("Includes", - IDefaultMutableTreeNode.INCLUDES, - IDefaultMutableTreeNode.OPERATION_ADD_DELETE); - if (xmlic.getArchList().size() > 0) { - IDefaultMutableTreeNode includesArch = new IDefaultMutableTreeNode( - "Arch", - IDefaultMutableTreeNode.INCLUDES_ARCH, - IDefaultMutableTreeNode.OPERATION_ADD_DELETE); - for (int indexI = 0; indexI < xmlic.getArchList().size(); indexI++) { - includesArch.add(new IDefaultMutableTreeNode(xmlic.getArchArray(indexI).getArchType().toString(), - IDefaultMutableTreeNode.INCLUDES_ARCH_ITEM, - IDefaultMutableTreeNode.OPERATION_UPDATE_DELETE, - indexI)); - } - includes.add(includesArch); - } - if (xmlic.getPackageNameList().size() > 0) { - IDefaultMutableTreeNode includesPackageName = new IDefaultMutableTreeNode( - "Package Name", - IDefaultMutableTreeNode.INCLUDES_PACKAGENAME, - IDefaultMutableTreeNode.OPERATION_ADD_UPDATE_DELETE); - for (int indexI = 0; indexI < xmlic.getPackageNameList().size(); indexI++) { - includesPackageName - .add(new IDefaultMutableTreeNode( - xmlic.getPackageNameArray(indexI) - .getStringValue(), - IDefaultMutableTreeNode.INCLUDES_PACKAGENAME_ITEM, - IDefaultMutableTreeNode.OPERATION_DELETE)); - } - includes.add(includesPackageName); - } - dmtnRoot.add(includes); - } - - // - //Add protocols - // - if (xmlpl != null) { - IDefaultMutableTreeNode dmtnProtocols = new IDefaultMutableTreeNode( - "Protocols", - IDefaultMutableTreeNode.PROTOCOLS, - IDefaultMutableTreeNode.OPERATION_ADD_DELETE); - IDefaultMutableTreeNode dmtnProtocol = new IDefaultMutableTreeNode( - "Protocol", - IDefaultMutableTreeNode.PROTOCOLS_PROTOCOL, - IDefaultMutableTreeNode.OPERATION_ADD_DELETE); - IDefaultMutableTreeNode dmtnProtocolNotify = new IDefaultMutableTreeNode( - "Protocol Notify", - IDefaultMutableTreeNode.PROTOCOLS_PROTOCOLNOTIFY, - IDefaultMutableTreeNode.OPERATION_ADD_DELETE); - if (xmlpl.getProtocolList().size() > 0) { - for (int indexI = 0; indexI < xmlpl.getProtocolList().size(); indexI++) { - dmtnProtocol.add(new IDefaultMutableTreeNode(xmlpl.getProtocolArray(indexI).getStringValue(), - IDefaultMutableTreeNode.PROTOCOLS_PROTOCOL_ITEM, - IDefaultMutableTreeNode.OPERATION_UPDATE_DELETE, - indexI)); - } - dmtnProtocols.add(dmtnProtocol); - } - if (xmlpl.getProtocolNotifyList().size() > 0) { - for (int indexI = 0; indexI < xmlpl.getProtocolNotifyList().size(); indexI++) { - dmtnProtocolNotify - .add(new IDefaultMutableTreeNode( - xmlpl.getProtocolNotifyArray(indexI) - .getStringValue(), - IDefaultMutableTreeNode.PROTOCOLS_PROTOCOLNOTIFY_ITEM, - IDefaultMutableTreeNode.OPERATION_UPDATE_DELETE, - indexI)); - } - dmtnProtocols.add(dmtnProtocolNotify); - } - dmtnRoot.add(dmtnProtocols); - } - - // - //Add events - // - if (xmlen != null) { - IDefaultMutableTreeNode dmtnEvents = new IDefaultMutableTreeNode( - "Events", - IDefaultMutableTreeNode.EVENTS, - IDefaultMutableTreeNode.OPERATION_ADD_DELETE); - IDefaultMutableTreeNode dmtnCreateEvents = new IDefaultMutableTreeNode( - "Create", - IDefaultMutableTreeNode.EVENTS_CREATEEVENTS, - IDefaultMutableTreeNode.OPERATION_ADD_DELETE); - IDefaultMutableTreeNode dmtnSignalEvents = new IDefaultMutableTreeNode( - "Signal", - IDefaultMutableTreeNode.EVENTS_SIGNALEVENTS, - IDefaultMutableTreeNode.OPERATION_ADD_DELETE); - if (xmlen.getCreateEvents() != null && xmlen.getCreateEvents().getEventList().size() > 0) { - for (int indexI = 0; indexI < xmlen.getCreateEvents().getEventList().size(); indexI++) { - dmtnCreateEvents.add(new IDefaultMutableTreeNode(xmlen.getCreateEvents().getEventArray(indexI) - .getCName(), - IDefaultMutableTreeNode.EVENTS_CREATEEVENTS_ITEM, - IDefaultMutableTreeNode.OPERATION_UPDATE_DELETE, - indexI)); - } - dmtnEvents.add(dmtnCreateEvents); - } - if (xmlen.getSignalEvents() != null && xmlen.getSignalEvents().getEventList().size() > 0) { - for (int indexI = 0; indexI < xmlen.getSignalEvents().getEventList().size(); indexI++) { - dmtnSignalEvents.add(new IDefaultMutableTreeNode(xmlen.getSignalEvents().getEventArray(indexI) - .getCName(), - IDefaultMutableTreeNode.EVENTS_SIGNALEVENTS_ITEM, - IDefaultMutableTreeNode.OPERATION_UPDATE_DELETE, - indexI)); - } - dmtnEvents.add(dmtnSignalEvents); - } - dmtnRoot.add(dmtnEvents); - } - - // - //Add hobs - // - if (xmlhob != null) { - IDefaultMutableTreeNode dmtnHobs = new IDefaultMutableTreeNode("Hobs", IDefaultMutableTreeNode.HOBS, - IDefaultMutableTreeNode.OPERATION_ADD_DELETE); - if (xmlhob.getHobList().size() > 0) { - for (int indexI = 0; indexI < xmlhob.getHobList().size(); indexI++) { - dmtnHobs.add(new IDefaultMutableTreeNode(xmlhob.getHobArray(indexI).getName(), - IDefaultMutableTreeNode.HOBS_HOB_ITEM, - IDefaultMutableTreeNode.OPERATION_UPDATE_DELETE, indexI)); - } - } - dmtnRoot.add(dmtnHobs); - } - - // - //Add ppis - // - if (xmlppi != null) { - IDefaultMutableTreeNode dmtnPpis = new IDefaultMutableTreeNode("Ppis", IDefaultMutableTreeNode.PPIS, - IDefaultMutableTreeNode.OPERATION_ADD_DELETE); - IDefaultMutableTreeNode dmtnPpi = new IDefaultMutableTreeNode("Ppi", IDefaultMutableTreeNode.PPIS_PPI, - IDefaultMutableTreeNode.OPERATION_ADD_DELETE); - IDefaultMutableTreeNode dmtnPpiNotify = new IDefaultMutableTreeNode( - "Ppi Notify", - IDefaultMutableTreeNode.PPIS_PPINOTIFY, - IDefaultMutableTreeNode.OPERATION_ADD_DELETE); - if (xmlppi.getPpiList().size() > 0) { - for (int indexI = 0; indexI < xmlppi.getPpiList().size(); indexI++) { - dmtnPpi.add(new IDefaultMutableTreeNode(xmlppi.getPpiArray(indexI).getStringValue(), - IDefaultMutableTreeNode.PPIS_PPI_ITEM, - IDefaultMutableTreeNode.OPERATION_UPDATE_DELETE, indexI)); - } - dmtnPpis.add(dmtnPpi); - } - if (xmlppi.getPpiNotifyList().size() > 0) { - for (int indexI = 0; indexI < xmlppi.getPpiNotifyList().size(); indexI++) { - dmtnPpiNotify.add(new IDefaultMutableTreeNode(xmlppi.getPpiNotifyArray(indexI).getStringValue(), - IDefaultMutableTreeNode.PPIS_PPINOTIFY_ITEM, - IDefaultMutableTreeNode.OPERATION_UPDATE_DELETE, - indexI)); - } - dmtnPpis.add(dmtnPpiNotify); - } - dmtnRoot.add(dmtnPpis); - } - - // - //Add variables - // - if (xmlvb != null) { - IDefaultMutableTreeNode dmtnVariables = new IDefaultMutableTreeNode( - "Variables", - IDefaultMutableTreeNode.VARIABLES, - IDefaultMutableTreeNode.OPERATION_ADD_DELETE); - if (xmlvb.getVariableList().size() > 0) { - for (int indexI = 0; indexI < xmlvb.getVariableList().size(); indexI++) { - dmtnVariables.add(new IDefaultMutableTreeNode(xmlvb.getVariableArray(indexI).getString(), - IDefaultMutableTreeNode.VARIABLES_VARIABLE_ITEM, - IDefaultMutableTreeNode.OPERATION_UPDATE_DELETE, - indexI)); - } - } - dmtnRoot.add(dmtnVariables); - } - - // - //Add bootmodes - // - if (xmlbm != null) { - IDefaultMutableTreeNode dmtnBootModes = new IDefaultMutableTreeNode( - "BootModes", - IDefaultMutableTreeNode.BOOTMODES, - IDefaultMutableTreeNode.OPERATION_ADD_DELETE); - if (xmlbm.getBootModeList().size() > 0) { - for (int indexI = 0; indexI < xmlbm.getBootModeList().size(); indexI++) { - dmtnBootModes.add(new IDefaultMutableTreeNode(xmlbm.getBootModeArray(indexI).getBootModeName() - .toString(), - IDefaultMutableTreeNode.BOOTMODES_BOOTMODE_ITEM, - IDefaultMutableTreeNode.OPERATION_UPDATE_DELETE, - indexI)); - } - } - dmtnRoot.add(dmtnBootModes); - } - - // - //Add systemtables - // - if (xmlst != null) { - IDefaultMutableTreeNode dmtnSystemTables = new IDefaultMutableTreeNode( - "SystemTables", - IDefaultMutableTreeNode.SYSTEMTABLES, - IDefaultMutableTreeNode.OPERATION_ADD_DELETE); - if (xmlst.getSystemTableList().size() > 0) { - for (int indexI = 0; indexI < xmlst.getSystemTableList().size(); indexI++) { - dmtnSystemTables - .add(new IDefaultMutableTreeNode( - xmlst.getSystemTableArray(indexI).getEntryList().get(0), - IDefaultMutableTreeNode.SYSTEMTABLES_SYSTEMTABLE_ITEM, - IDefaultMutableTreeNode.OPERATION_UPDATE_DELETE, - indexI)); - } - } - dmtnRoot.add(dmtnSystemTables); - } - - // - //Add datahubs - // - if (xmldh != null) { - IDefaultMutableTreeNode dmtnDataHubs = new IDefaultMutableTreeNode( - "DataHubs", - IDefaultMutableTreeNode.DATAHUBS, - IDefaultMutableTreeNode.OPERATION_ADD_DELETE); - if (xmldh.getDataHubRecordList().size() > 0) { - for (int indexI = 0; indexI < xmldh.getDataHubRecordList().size(); indexI++) { - dmtnDataHubs.add(new IDefaultMutableTreeNode(xmldh.getDataHubRecordArray(indexI).getStringValue(), - IDefaultMutableTreeNode.DATAHUBS_DATAHUB_ITEM, - IDefaultMutableTreeNode.OPERATION_UPDATE_DELETE, - indexI)); - } - } - dmtnRoot.add(dmtnDataHubs); - } - - // - //Add formsets - // - if (xmlfs != null) { - IDefaultMutableTreeNode dmtnFormsets = new IDefaultMutableTreeNode( - "Formsets", - IDefaultMutableTreeNode.FORMSETS, - IDefaultMutableTreeNode.OPERATION_ADD_DELETE); - if (xmlfs.getFormsetList().size() > 0) { - for (int indexI = 0; indexI < xmlfs.getFormsetList().size(); indexI++) { - dmtnFormsets.add(new IDefaultMutableTreeNode(xmlfs.getFormsetArray(indexI).getStringValue(), - IDefaultMutableTreeNode.FORMSETS_FORMSET_ITEM, - IDefaultMutableTreeNode.OPERATION_UPDATE_DELETE, - indexI)); - } - } - dmtnRoot.add(dmtnFormsets); - } - - // - //Add guids - // - if (xmlgu != null) { - IDefaultMutableTreeNode dmtnGuids = new IDefaultMutableTreeNode( - "Guids", - IDefaultMutableTreeNode.GUIDS, - IDefaultMutableTreeNode.OPERATION_ADD_DELETE); - if (xmlgu.getGuidEntryList().size() > 0) { - for (int indexI = 0; indexI < xmlgu.getGuidEntryList().size(); indexI++) { - dmtnGuids.add(new IDefaultMutableTreeNode(xmlgu.getGuidEntryArray(indexI).getCName(), - IDefaultMutableTreeNode.GUIDS_GUIDENTRY_ITEM, - IDefaultMutableTreeNode.OPERATION_UPDATE_DELETE, indexI)); - } - } - dmtnRoot.add(dmtnGuids); - } - - // - //Add externs - // - if (xmlet != null) { - IDefaultMutableTreeNode dmtnExterns = new IDefaultMutableTreeNode( - "Externs", - IDefaultMutableTreeNode.EXTERNS, - IDefaultMutableTreeNode.OPERATION_ADD_DELETE); - if (xmlet.getExternList().size() > 0) { - for (int indexI = 0; indexI < xmlet.getExternList().size(); indexI++) { - dmtnExterns - .add(new IDefaultMutableTreeNode("Extern " + Integer.valueOf(indexI + 1), - IDefaultMutableTreeNode.EXTERNS_EXTERN_ITEM, - IDefaultMutableTreeNode.OPERATION_UPDATE_DELETE, indexI)); - } - } - dmtnRoot.add(dmtnExterns); - } - - // - //Add pcds - // - if (xmlpcd != null) { - IDefaultMutableTreeNode dmtnPCDs = new IDefaultMutableTreeNode("PCDs", IDefaultMutableTreeNode.PCDS, - IDefaultMutableTreeNode.OPERATION_ADD_DELETE); - if (xmlpcd.getPcdDataList().size() > 0) { - for (int indexI = 0; indexI < xmlpcd.getPcdDataList().size(); indexI++) { - dmtnPCDs.add(new IDefaultMutableTreeNode(xmlpcd.getPcdDataArray(indexI).getCName(), - IDefaultMutableTreeNode.PCDS_PCDDATA_ITEM, - IDefaultMutableTreeNode.OPERATION_UPDATE_DELETE, indexI)); - } - } - dmtnRoot.add(dmtnPCDs); - } - - iTree = new ITree(dmtnRoot); - iTree.addMouseListener(this); - iTree.addTreeSelectionListener(this); - jScrollPaneTree.setViewportView(iTree); - } - - /* (non-Javadoc) - * @see java.awt.event.WindowListener#windowClosing(java.awt.event.WindowEvent) - * - * Override windowClosing to popup warning message to confirm quit - * - */ - public void windowClosing(WindowEvent arg0) { - this.onExit(); - } - - /* (non-Javadoc) - * @see java.awt.event.MouseListener#mouseClicked(java.awt.event.MouseEvent) - * - * Override mouseClicked to check if need display popup menu - * - */ - public void mouseClicked(MouseEvent arg0) { - if (arg0.getButton() == MouseEvent.BUTTON1) { - - } - if (arg0.getButton() == MouseEvent.BUTTON3) { - jPopupMenu.show(arg0.getComponent(), arg0.getX(), arg0.getY()); - } - } - - 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 - } - - /** - Init popup menu - - **/ - public void valueChanged(TreeSelectionEvent arg0) { - int intOperation = iTree.getSelectOperation(); - if (intOperation == IDefaultMutableTreeNode.OPERATION_NULL) { - setMenuItemAddEnabled(false); - setMenuItemUpdateEnabled(false); - setMenuItemDeleteEnabled(false); - } - if (intOperation == IDefaultMutableTreeNode.OPERATION_ADD) { - setMenuItemAddEnabled(true); - setMenuItemUpdateEnabled(false); - setMenuItemDeleteEnabled(false); - } - if (intOperation == IDefaultMutableTreeNode.OPERATION_UPDATE) { - setMenuItemAddEnabled(false); - setMenuItemUpdateEnabled(true); - setMenuItemDeleteEnabled(false); - } - if (intOperation == IDefaultMutableTreeNode.OPERATION_DELETE) { - setMenuItemAddEnabled(false); - setMenuItemUpdateEnabled(false); - setMenuItemDeleteEnabled(true); - } - if (intOperation == IDefaultMutableTreeNode.OPERATION_ADD_UPDATE) { - setMenuItemAddEnabled(true); - setMenuItemUpdateEnabled(true); - setMenuItemDeleteEnabled(false); - } - if (intOperation == IDefaultMutableTreeNode.OPERATION_ADD_DELETE) { - setMenuItemAddEnabled(true); - setMenuItemUpdateEnabled(false); - setMenuItemDeleteEnabled(true); - } - if (intOperation == IDefaultMutableTreeNode.OPERATION_UPDATE_DELETE) { - setMenuItemAddEnabled(false); - setMenuItemUpdateEnabled(true); - setMenuItemDeleteEnabled(true); - } - if (intOperation == IDefaultMutableTreeNode.OPERATION_ADD_UPDATE_DELETE) { - setMenuItemAddEnabled(true); - setMenuItemUpdateEnabled(true); - setMenuItemDeleteEnabled(true); - } - viewCurrentModule(); - } - - /** - Enable/Disable add menu item - - **/ - private void setMenuItemAddEnabled(boolean isEnable) { - jMenuItemPopupAdd.setEnabled(isEnable); - } - - /** - Enable/Disable update menu item - - **/ - private void setMenuItemUpdateEnabled(boolean isEnable) { - jMenuItemPopupUpdate.setEnabled(isEnable); - jMenuItemEditUpdate.setEnabled(isEnable); - } - - /** - Enable/Disable delete menu item - - **/ - private void setMenuItemDeleteEnabled(boolean isEnable) { - jMenuItemPopupDelete.setEnabled(isEnable); - jMenuItemEditDelete.setEnabled(isEnable); - } - - /** - Close current open module - - **/ - private void closeCurrentModule() { - cleanAllXml(); - - reloadTreeAndTable(ModuleMain.CLOSED); - setMenuItemAddEnabled(false); - setMenuItemUpdateEnabled(false); - setMenuItemDeleteEnabled(false); - cleanDesktopPane(); - } - - /** - Remove all Internal Frame of Desktop Pane - - **/ - private void cleanDesktopPane() { - JInternalFrame[] iif = this.jDesktopPane.getAllFrames(); - for (int index = 0; index < iif.length; index++) { - iif[index].dispose(); - } - } - - /** - Set all xml document null - - **/ - private void cleanAllXml() { - this.currentModule = ""; - this.saveFileName = ""; - this.currentModuleType = 0; - this.currentNodeType = 0; - - xmlMsaDoc = null; - xmlMbdDoc = null; - xmlMlsaDoc = null; - xmlMlbdDoc = null; - xmlmh = null; - xmllcd = null; - xmllib = null; - xmlsf = null; - xmlic = null; - xmlpl = null; - xmlen = null; - xmlhob = null; - xmlppi = null; - xmlvb = null; - xmlbm = null; - xmlst = null; - xmldh = null; - xmlfs = null; - xmlgu = null; - xmlet = null; - xmlpcd = null; - xmlbo = null; - } - - /** - Execute add operation for current node - - @param intCategory The category of current node - @param intLocation The location of current node - - **/ - private void addCurrentModule(int intCategory, int intLocation) { - // - //Add new libraries - // - if (intCategory == IDefaultMutableTreeNode.LIBRARIES - || intCategory == IDefaultMutableTreeNode.LIBRARIES_LIBRARY - || intCategory == IDefaultMutableTreeNode.LIBRARIES_ARCH) { - showLibraries(ModuleMain.ADD, intCategory, -1); - } - - // - //Add new sourcefiles - // - if (intCategory == IDefaultMutableTreeNode.SOURCEFILES - || intCategory == IDefaultMutableTreeNode.SOURCEFILES_FILENAME - || intCategory == IDefaultMutableTreeNode.SOURCEFILES_ARCH) { - showSourceFiles(ModuleMain.ADD, intCategory, -1); - } - - // - //Add new includes - // - if (intCategory == IDefaultMutableTreeNode.INCLUDES - || intCategory == IDefaultMutableTreeNode.INCLUDES_PACKAGENAME - || intCategory == IDefaultMutableTreeNode.INCLUDES_ARCH) { - showIncludes(ModuleMain.ADD, intCategory, -1); - } - - // - //Add new protocols - // - if (intCategory == IDefaultMutableTreeNode.PROTOCOLS - || intCategory == IDefaultMutableTreeNode.PROTOCOLS_PROTOCOL - || intCategory == IDefaultMutableTreeNode.PROTOCOLS_PROTOCOLNOTIFY) { - showProtocols(ModuleMain.ADD, intCategory, -1); - } - - // - //Add new events - // - if (intCategory == IDefaultMutableTreeNode.EVENTS || intCategory == IDefaultMutableTreeNode.EVENTS_CREATEEVENTS - || intCategory == IDefaultMutableTreeNode.EVENTS_SIGNALEVENTS) { - showEvents(ModuleMain.ADD, intCategory, -1); - } - - // - //Add new hobs - // - if (intCategory == IDefaultMutableTreeNode.HOBS || intCategory == IDefaultMutableTreeNode.HOBS_HOB_ITEM) { - showHobs(ModuleMain.ADD, intCategory, -1); - } - - // - //Add new ppis - // - if (intCategory == IDefaultMutableTreeNode.PPIS || intCategory == IDefaultMutableTreeNode.PPIS_PPI - || intCategory == IDefaultMutableTreeNode.PPIS_PPINOTIFY) { - showPpis(ModuleMain.ADD, intCategory, -1); - } - - // - //Add new variables - // - if (intCategory == IDefaultMutableTreeNode.VARIABLES - || intCategory == IDefaultMutableTreeNode.VARIABLES_VARIABLE_ITEM) { - showVariables(ModuleMain.ADD, intCategory, -1); - } - - // - //Add new BootModes - // - if (intCategory == IDefaultMutableTreeNode.BOOTMODES - || intCategory == IDefaultMutableTreeNode.BOOTMODES_BOOTMODE_ITEM) { - showBootModes(ModuleMain.ADD, intCategory, -1); - } - - // - //Add new SystemTables - // - if (intCategory == IDefaultMutableTreeNode.SYSTEMTABLES - || intCategory == IDefaultMutableTreeNode.SYSTEMTABLES_SYSTEMTABLE_ITEM) { - showSystemTables(ModuleMain.ADD, intCategory, -1); - } - - // - //Add new DataHubs - // - if (intCategory == IDefaultMutableTreeNode.DATAHUBS - || intCategory == IDefaultMutableTreeNode.DATAHUBS_DATAHUB_ITEM) { - showDataHubs(ModuleMain.ADD, intCategory, -1); - } - - // - //Add new Formsets - // - if (intCategory == IDefaultMutableTreeNode.FORMSETS - || intCategory == IDefaultMutableTreeNode.FORMSETS_FORMSET_ITEM) { - showFormsets(ModuleMain.ADD, intCategory, -1); - } - - // - //Add new Guids - // - if (intCategory == IDefaultMutableTreeNode.GUIDS || intCategory == IDefaultMutableTreeNode.GUIDS_GUIDENTRY_ITEM) { - showGuids(ModuleMain.ADD, intCategory, -1); - } - - // - //Add new Externs - // - if (intCategory == IDefaultMutableTreeNode.EXTERNS - || intCategory == IDefaultMutableTreeNode.EXTERNS_EXTERN_ITEM) { - showExterns(ModuleMain.ADD, intCategory, -1); - } - - // - //Add new PCDs - // - if (intCategory == IDefaultMutableTreeNode.PCDS || intCategory == IDefaultMutableTreeNode.PCDS_PCDDATA_ITEM) { - showPCDs(ModuleMain.ADD, intCategory, -1); - } - } - - /** - Execute delete operation of current node - - @param intCategory The category of current node - @param intLocation The location of current node - - **/ - private void deleteCurrentModule(int intCategory, int intLocation) { - // - // Delete Msa Header - // - if (intCategory == IDefaultMutableTreeNode.MSA_HEADER || intCategory == IDefaultMutableTreeNode.MBD_HEADER - || intCategory == IDefaultMutableTreeNode.MLSA_HEADER || intCategory == IDefaultMutableTreeNode.MLBD_HEADER) { - if (JOptionPane.showConfirmDialog(null, "The module will be deleted permanently, do you want to continue?") == JOptionPane.YES_OPTION) { - try { - File f = new File(currentModule); - f.delete(); - closeCurrentModule(); - } catch (Exception e) { - Log.err("Delete " + currentModule, e.getMessage()); - } - } else { - return; - } - } - - // - //Delete LIBRARY CLASS DEFINITIONS - // - if (intCategory == IDefaultMutableTreeNode.LIBRARYCLASSDEFINITIONS) { - xmllcd = null; - } - - // - //Delete Libraries - // - if (intCategory == IDefaultMutableTreeNode.LIBRARIES) { - xmllib = null; - } - if (intCategory == IDefaultMutableTreeNode.LIBRARIES_LIBRARY) { - for (int indexI = xmllib.getLibraryList().size() - 1; indexI > -1; indexI--) { - xmllib.removeLibrary(indexI); - } - if (xmllib.getArchList().size() < 1 && xmllib.getLibraryList().size() < 1) { - xmllib = null; - } - } - if (intCategory == IDefaultMutableTreeNode.LIBRARIES_ARCH) { - for (int indexI = xmllib.getArchList().size() - 1; indexI > -1; indexI--) { - xmllib.removeArch(indexI); - } - if (xmllib.getArchList().size() < 1 && xmllib.getLibraryList().size() < 1) { - xmllib = null; - } - } - if (intCategory == IDefaultMutableTreeNode.LIBRARIES_ARCH_ITEM) { - xmllib.removeArch(intLocation); - } - if (intCategory == IDefaultMutableTreeNode.LIBRARIES_LIBRARY_ITEM) { - xmllib.removeLibrary(intLocation); - } - - // - //Delete SourceFiles - // - if (intCategory == IDefaultMutableTreeNode.SOURCEFILES) { - xmlsf = null; - } - if (intCategory == IDefaultMutableTreeNode.SOURCEFILES_FILENAME) { - for (int indexI = xmlsf.getFilenameList().size() - 1; indexI > -1; indexI--) { - xmlsf.removeFilename(indexI); - } - if (xmlsf.getArchList().size() < 1 && xmlsf.getFilenameList().size() < 1) { - xmlsf = null; - } - } - if (intCategory == IDefaultMutableTreeNode.SOURCEFILES_ARCH) { - for (int indexI = xmlsf.getArchList().size() - 1; indexI > -1; indexI--) { - xmlsf.removeArch(indexI); - } - if (xmlsf.getArchList().size() < 1 && xmlsf.getFilenameList().size() < 1) { - xmlsf = null; - } - } - if (intCategory == IDefaultMutableTreeNode.SOURCEFILES_ARCH_ITEM) { - xmlsf.removeArch(intLocation); - } - if (intCategory == IDefaultMutableTreeNode.SOURCEFILES_FILENAME_ITEM) { - xmlsf.removeFilename(intLocation); - } - - // - //Delete Includes - // - if (intCategory == IDefaultMutableTreeNode.INCLUDES) { - xmlic = null; - } - if (intCategory == IDefaultMutableTreeNode.INCLUDES_PACKAGENAME) { - for (int indexI = xmlic.getPackageNameList().size() - 1; indexI > -1; indexI--) { - xmlic.removePackageName(indexI); - } - if (xmlic.getArchList().size() < 1 && xmlic.getPackageNameList().size() < 1) { - xmlic = null; - } - } - if (intCategory == IDefaultMutableTreeNode.INCLUDES_ARCH) { - for (int indexI = xmlic.getArchList().size() - 1; indexI > -1; indexI--) { - xmlic.removeArch(indexI); - } - if (xmlic.getArchList().size() < 1 && xmlic.getPackageNameList().size() < 1) { - xmlic = null; - } - } - if (intCategory == IDefaultMutableTreeNode.INCLUDES_ARCH_ITEM) { - xmlic.removeArch(intLocation); - } - if (intCategory == IDefaultMutableTreeNode.INCLUDES_PACKAGENAME_ITEM) { - xmlic.removePackageName(intLocation); - } - - // - //Delete Protocols - // - if (intCategory == IDefaultMutableTreeNode.PROTOCOLS) { - xmlpl = null; - } - if (intCategory == IDefaultMutableTreeNode.PROTOCOLS_PROTOCOL) { - for (int indexI = xmlpl.getProtocolList().size() - 1; indexI > -1; indexI--) { - xmlpl.removeProtocol(indexI); - } - if (xmlpl.getProtocolList().size() < 1 && xmlpl.getProtocolNotifyList().size() < 1) { - xmlpl = null; - } - } - if (intCategory == IDefaultMutableTreeNode.PROTOCOLS_PROTOCOLNOTIFY) { - for (int indexI = xmlpl.getProtocolList().size() - 1; indexI > -1; indexI--) { - xmlpl.removeProtocolNotify(indexI); - } - if (xmlpl.getProtocolList().size() < 1 && xmlpl.getProtocolNotifyList().size() < 1) { - xmlpl = null; - } - } - if (intCategory == IDefaultMutableTreeNode.PROTOCOLS_PROTOCOL_ITEM) { - xmlpl.removeProtocol(intLocation); - } - if (intCategory == IDefaultMutableTreeNode.PROTOCOLS_PROTOCOLNOTIFY_ITEM) { - xmlpl.removeProtocolNotify(intLocation); - } - - // - //Delete Events - // - if (intCategory == IDefaultMutableTreeNode.EVENTS) { - xmlen = null; - } - if (intCategory == IDefaultMutableTreeNode.EVENTS_CREATEEVENTS) { - for (int indexI = xmlen.getCreateEvents().getEventList().size() - 1; indexI > -1; indexI--) { - xmlen.getCreateEvents().removeEvent(indexI); - } - if (xmlen.getCreateEvents().getEventList().size() < 1 && xmlen.getSignalEvents().getEventList().size() < 1) { - xmlen = null; - } - } - if (intCategory == IDefaultMutableTreeNode.EVENTS_SIGNALEVENTS) { - for (int indexI = xmlen.getSignalEvents().getEventList().size() - 1; indexI > -1; indexI--) { - xmlen.getSignalEvents().removeEvent(indexI); - } - if (xmlen.getCreateEvents().getEventList().size() < 1 && xmlen.getSignalEvents().getEventList().size() < 1) { - xmlen = null; - } - } - if (intCategory == IDefaultMutableTreeNode.EVENTS_CREATEEVENTS_ITEM) { - xmlen.getCreateEvents().removeEvent(intLocation); - } - if (intCategory == IDefaultMutableTreeNode.EVENTS_SIGNALEVENTS_ITEM) { - xmlen.getSignalEvents().removeEvent(intLocation); - } - - // - //Delete Hobs - // - if (intCategory == IDefaultMutableTreeNode.HOBS) { - xmlhob = null; - } - if (intCategory == IDefaultMutableTreeNode.HOBS_HOB_ITEM) { - xmlhob.removeHob(intLocation); - if (xmlhob.getHobList().size() < 1) { - xmlhob = null; - } - } - - // - //Delete Ppis - // - if (intCategory == IDefaultMutableTreeNode.PPIS) { - xmlppi = null; - } - if (intCategory == IDefaultMutableTreeNode.PPIS_PPI) { - for (int indexI = xmlppi.getPpiList().size() - 1; indexI > -1; indexI--) { - xmlppi.removePpi(indexI); - } - if (xmlppi.getPpiList().size() < 1 && xmlppi.getPpiNotifyList().size() < 1) { - xmlppi = null; - } - } - if (intCategory == IDefaultMutableTreeNode.PPIS_PPINOTIFY) { - for (int indexI = xmlppi.getPpiNotifyList().size() - 1; indexI > -1; indexI--) { - xmlppi.removePpiNotify(indexI); - } - if (xmlppi.getPpiList().size() < 1 && xmlppi.getPpiNotifyList().size() < 1) { - xmlppi = null; - } - } - if (intCategory == IDefaultMutableTreeNode.PPIS_PPI_ITEM) { - xmlppi.removePpi(intLocation); - } - if (intCategory == IDefaultMutableTreeNode.PPIS_PPINOTIFY_ITEM) { - xmlppi.removePpiNotify(intLocation); - } - - // - //Delete Variables - // - if (intCategory == IDefaultMutableTreeNode.VARIABLES) { - xmlvb = null; - } - if (intCategory == IDefaultMutableTreeNode.VARIABLES_VARIABLE_ITEM) { - xmlvb.removeVariable(intLocation); - if (xmlvb.getVariableList().size() < 1) { - xmlvb = null; - } - } - - // - //Delete BootModes - // - if (intCategory == IDefaultMutableTreeNode.BOOTMODES) { - xmlbm = null; - } - if (intCategory == IDefaultMutableTreeNode.BOOTMODES_BOOTMODE_ITEM) { - xmlbm.removeBootMode(intLocation); - if (xmlbm.getBootModeList().size() < 1) { - xmlbm = null; - } - } - - // - //Delete SystemTables - // - if (intCategory == IDefaultMutableTreeNode.SYSTEMTABLES) { - xmlst = null; - } - if (intCategory == IDefaultMutableTreeNode.SYSTEMTABLES_SYSTEMTABLE_ITEM) { - xmlst.removeSystemTable(intLocation); - if (xmlst.getSystemTableList().size() < 1) { - xmlst = null; - } - } - - // - //Delete DataHubs - // - if (intCategory == IDefaultMutableTreeNode.DATAHUBS) { - xmldh = null; - } - if (intCategory == IDefaultMutableTreeNode.DATAHUBS_DATAHUB_ITEM) { - xmldh.removeDataHubRecord(intLocation); - if (xmldh.getDataHubRecordList().size() < 1) { - xmldh = null; - } - } - - // - //Delete Formsets - // - if (intCategory == IDefaultMutableTreeNode.FORMSETS) { - xmlfs = null; - } - if (intCategory == IDefaultMutableTreeNode.FORMSETS_FORMSET_ITEM) { - xmlfs.removeFormset(intLocation); - if (xmlfs.getFormsetList().size() < 1) { - xmlfs = null; - } - } - - // - //Delete Guids - // - if (intCategory == IDefaultMutableTreeNode.GUIDS) { - xmlgu = null; - } - if (intCategory == IDefaultMutableTreeNode.GUIDS_GUIDENTRY_ITEM) { - xmlgu.removeGuidEntry(intLocation); - if (xmlgu.getGuidEntryList().size() < 1) { - xmlgu = null; - } - } - - // - //Delete Externs - // - if (intCategory == IDefaultMutableTreeNode.EXTERNS) { - xmlet = null; - } - if (intCategory == IDefaultMutableTreeNode.EXTERNS_EXTERN_ITEM) { - xmlet.removeExtern(intLocation); - if (xmlet.getExternList().size() < 1) { - xmlet = null; - } - } - - // - //Delete PCDs - // - if (intCategory == IDefaultMutableTreeNode.PCDS) { - xmlpcd = null; - } - if (intCategory == IDefaultMutableTreeNode.PCDS_PCDDATA_ITEM) { - xmlpcd.removePcdData(intLocation); - if (xmlpcd.getPcdDataList().size() < 1) { - xmlpcd = null; - } - } - this.cleanDesktopPane(); - reloadTreeAndTable(UPDATE_WITH_CHANGE); - } - - /** - View current Module - - **/ - private void viewCurrentModule() { - int intCategory = iTree.getSelectCategory(); - int intLocation = iTree.getSelectLoaction(); - // - //View Msa Header - // - if (intCategory == IDefaultMutableTreeNode.MSA_HEADER) { - showMsaHeader(ModuleMain.VIEW); - } - - // - //View Mbd Header - // - if (intCategory == IDefaultMutableTreeNode.MBD_HEADER) { - showMbdHeader(ModuleMain.VIEW); - } - - // - //View Msa Lib Header - // - if (intCategory == IDefaultMutableTreeNode.MLSA_HEADER) { - showMlsaHeader(ModuleMain.VIEW); - } - - // - //View Mbd Lib Header - // - if (intCategory == IDefaultMutableTreeNode.MLBD_HEADER) { - showMlbdHeader(ModuleMain.VIEW); - } - - // - //View Libraries - // - if (intCategory == IDefaultMutableTreeNode.LIBRARIES_LIBRARY - || intCategory == IDefaultMutableTreeNode.LIBRARIES_ARCH_ITEM) { - showLibraries(ModuleMain.VIEW, intCategory, intLocation); - } - - // - //View LIBRARY CLASS DEFINITIONS - // - if (intCategory == IDefaultMutableTreeNode.LIBRARYCLASSDEFINITIONS) { - showLibraryClassDefinitions(ModuleMain.VIEW, intCategory); - } - - // - //View Source Files - // - if (intCategory == IDefaultMutableTreeNode.SOURCEFILES_FILENAME - || intCategory == IDefaultMutableTreeNode.SOURCEFILES_ARCH_ITEM) { - showSourceFiles(ModuleMain.VIEW, intCategory, intLocation); - } - - // - //View Includes - // - if (intCategory == IDefaultMutableTreeNode.INCLUDES_PACKAGENAME - || intCategory == IDefaultMutableTreeNode.INCLUDES_ARCH_ITEM) { - showIncludes(ModuleMain.VIEW, intCategory, intLocation); - } - - // - //View Protocols - // - if (intCategory == IDefaultMutableTreeNode.PROTOCOLS_PROTOCOL_ITEM - || intCategory == IDefaultMutableTreeNode.PROTOCOLS_PROTOCOLNOTIFY_ITEM) { - showProtocols(ModuleMain.VIEW, intCategory, intLocation); - } - - // - //View Hobs - // - if (intCategory == IDefaultMutableTreeNode.HOBS_HOB_ITEM) { - showHobs(ModuleMain.VIEW, intCategory, intLocation); - } - - // - //View Events - // - if (intCategory == IDefaultMutableTreeNode.EVENTS_CREATEEVENTS_ITEM - || intCategory == IDefaultMutableTreeNode.EVENTS_SIGNALEVENTS_ITEM) { - showEvents(ModuleMain.VIEW, intCategory, intLocation); - } - - // - //View Ppis - // - if (intCategory == IDefaultMutableTreeNode.PPIS_PPI_ITEM - || intCategory == IDefaultMutableTreeNode.PPIS_PPINOTIFY_ITEM) { - showPpis(ModuleMain.VIEW, intCategory, intLocation); - } - - // - //View Variables - // - if (intCategory == IDefaultMutableTreeNode.VARIABLES_VARIABLE_ITEM) { - showVariables(ModuleMain.VIEW, intCategory, intLocation); - } - - // - //View BootModes - // - if (intCategory == IDefaultMutableTreeNode.BOOTMODES_BOOTMODE_ITEM) { - showBootModes(ModuleMain.VIEW, intCategory, intLocation); - } - - // - //View SystemTables - // - if (intCategory == IDefaultMutableTreeNode.SYSTEMTABLES_SYSTEMTABLE_ITEM) { - showSystemTables(ModuleMain.VIEW, intCategory, intLocation); - } - - // - //View DataHubs - // - if (intCategory == IDefaultMutableTreeNode.DATAHUBS_DATAHUB_ITEM) { - showDataHubs(ModuleMain.VIEW, intCategory, intLocation); - } - - // - //View Formsets - // - if (intCategory == IDefaultMutableTreeNode.FORMSETS_FORMSET_ITEM) { - showFormsets(ModuleMain.VIEW, intCategory, intLocation); - } - - // - //View Guids - // - if (intCategory == IDefaultMutableTreeNode.GUIDS_GUIDENTRY_ITEM) { - showGuids(ModuleMain.VIEW, intCategory, intLocation); - } - - // - //View Externs - // - if (intCategory == IDefaultMutableTreeNode.EXTERNS_EXTERN_ITEM) { - showExterns(ModuleMain.VIEW, intCategory, intLocation); - } - - // - //View PCDs - // - if (intCategory == IDefaultMutableTreeNode.PCDS_PCDDATA_ITEM) { - showPCDs(ModuleMain.VIEW, intCategory, intLocation); - } - } - - /** - Execute update operation of current module - - @param intCategory The category of current node - @param intLocation The location of current node - - **/ - private void updateCurrentModule(int intCategory, int intLocation) { - // - //Update Msa Header - // - if (intCategory == IDefaultMutableTreeNode.MSA_HEADER) { - showMsaHeader(ModuleMain.UPDATE); - } - - // - //Update Mbd Header - // - if (intCategory == IDefaultMutableTreeNode.MBD_HEADER) { - showMbdHeader(ModuleMain.UPDATE); - } - - // - //Update Msa Lib Header - // - if (intCategory == IDefaultMutableTreeNode.MLSA_HEADER) { - showMlsaHeader(ModuleMain.UPDATE); - } - - // - //Update Mbd Lib Header - // - if (intCategory == IDefaultMutableTreeNode.MLBD_HEADER) { - showMlbdHeader(ModuleMain.UPDATE); - } - - // - //Update Libraries - // - if (intCategory == IDefaultMutableTreeNode.LIBRARIES_LIBRARY - || intCategory == IDefaultMutableTreeNode.LIBRARIES_ARCH_ITEM) { - showLibraries(ModuleMain.UPDATE, intCategory, intLocation); - } - - // - //Update LIBRARY CLASS DEFINITIONS - // - if (intCategory == IDefaultMutableTreeNode.LIBRARYCLASSDEFINITIONS) { - showLibraryClassDefinitions(ModuleMain.UPDATE, intCategory); - } - - // - //Update Source Files - // - if (intCategory == IDefaultMutableTreeNode.SOURCEFILES_FILENAME - || intCategory == IDefaultMutableTreeNode.SOURCEFILES_ARCH_ITEM) { - showSourceFiles(ModuleMain.UPDATE, intCategory, intLocation); - } - - // - //Update Includes - // - if (intCategory == IDefaultMutableTreeNode.INCLUDES_PACKAGENAME - || intCategory == IDefaultMutableTreeNode.INCLUDES_ARCH_ITEM) { - showIncludes(ModuleMain.UPDATE, intCategory, intLocation); - } - - // - //Update Protocols - // - if (intCategory == IDefaultMutableTreeNode.PROTOCOLS_PROTOCOL_ITEM - || intCategory == IDefaultMutableTreeNode.PROTOCOLS_PROTOCOLNOTIFY_ITEM) { - showProtocols(ModuleMain.UPDATE, intCategory, intLocation); - } - - // - //Update Hobs - // - if (intCategory == IDefaultMutableTreeNode.HOBS_HOB_ITEM) { - showHobs(ModuleMain.UPDATE, intCategory, intLocation); - } - - // - //Update Events - // - if (intCategory == IDefaultMutableTreeNode.EVENTS_CREATEEVENTS_ITEM - || intCategory == IDefaultMutableTreeNode.EVENTS_SIGNALEVENTS_ITEM) { - showEvents(ModuleMain.UPDATE, intCategory, intLocation); - } - - // - //Update Ppis - // - if (intCategory == IDefaultMutableTreeNode.PPIS_PPI_ITEM - || intCategory == IDefaultMutableTreeNode.PPIS_PPINOTIFY_ITEM) { - showPpis(ModuleMain.UPDATE, intCategory, intLocation); - } - - // - //Update Variables - // - if (intCategory == IDefaultMutableTreeNode.VARIABLES_VARIABLE_ITEM) { - showVariables(ModuleMain.UPDATE, intCategory, intLocation); - } - - // - //Update BootModes - // - if (intCategory == IDefaultMutableTreeNode.BOOTMODES_BOOTMODE_ITEM) { - showBootModes(ModuleMain.UPDATE, intCategory, intLocation); - } - - // - //Update SystemTables - // - if (intCategory == IDefaultMutableTreeNode.SYSTEMTABLES_SYSTEMTABLE_ITEM) { - showSystemTables(ModuleMain.UPDATE, intCategory, intLocation); - } - - // - //Update DataHubs - // - if (intCategory == IDefaultMutableTreeNode.DATAHUBS_DATAHUB_ITEM) { - showDataHubs(ModuleMain.UPDATE, intCategory, intLocation); - } - - // - //Update Formsets - // - if (intCategory == IDefaultMutableTreeNode.FORMSETS_FORMSET_ITEM) { - showFormsets(ModuleMain.UPDATE, intCategory, intLocation); - } - - // - //Update Guids - // - if (intCategory == IDefaultMutableTreeNode.GUIDS_GUIDENTRY_ITEM) { - showGuids(ModuleMain.UPDATE, intCategory, intLocation); - } - - // - //Update Externs - // - if (intCategory == IDefaultMutableTreeNode.EXTERNS_EXTERN_ITEM) { - showExterns(ModuleMain.UPDATE, intCategory, intLocation); - } - - // - //Update PCDs - // - if (intCategory == IDefaultMutableTreeNode.PCDS_PCDDATA_ITEM) { - showPCDs(ModuleMain.UPDATE, intCategory, intLocation); - } - } - - /** - Save current module - Call relevant function via different file types - - **/ - private void saveCurrentModule() { - if (this.saveFileName == "") { - openFile(2, this.currentModuleType); - } - if (this.saveFileName == "") { - this.saveFileName = this.currentModule; - return; - } else { - switch (this.currentModuleType) { - case 1: - saveMsa(); - break; - case 2: - saveMbd(); - break; - case 3: - saveMlsa(); - break; - case 4: - saveMlbd(); - break; - } - - } - - reloadTreeAndTable(SAVE_WITH_CHANGE); - } - - /** - Save current module as - - **/ - private void saveAsCurrentModule() { - this.saveFileName = ""; - saveCurrentModule(); - } - - /** - Save file as msa - - **/ - private void saveMsa() { - File f = new File(this.saveFileName); - ModuleSurfaceAreaDocument msaDoc = ModuleSurfaceAreaDocument.Factory.newInstance(); - ModuleSurfaceAreaDocument.ModuleSurfaceArea msa = ModuleSurfaceAreaDocument.ModuleSurfaceArea.Factory - .newInstance(); - - // - //Add all components into xml doc file - // - if (xmlmh != null) { - msa.setMsaHeader(xmlmh); - } - if (xmllcd != null) { - msa.setLibraryClassDefinitions(xmllcd); - } - if (xmlsf != null) { - msa.setSourceFiles(xmlsf); - } - if (xmlic != null) { - msa.setIncludes(xmlic); - } - if (xmlpl != null) { - msa.setProtocols(xmlpl); - } - if (xmlen != null) { - msa.setEvents(xmlen); - } - if (xmlhob != null) { - msa.setHobs(xmlhob); - } - if (xmlppi != null) { - msa.setPPIs(xmlppi); - } - if (xmlvb != null) { - msa.setVariables(xmlvb); - } - if (xmlbm != null) { - msa.setBootModes(xmlbm); - } - if (xmlst != null) { - msa.setSystemTables(xmlst); - } - if (xmldh != null) { - msa.setDataHubs(xmldh); - } - if (xmlfs != null) { - msa.setFormsets(xmlfs); - } - if (xmlgu != null) { - msa.setGuids(xmlgu); - } - if (xmlet != null) { - msa.setExterns(xmlet); - } - if (xmlpcd != null) { - msa.setPCDs(xmlpcd); - } - if (xmlbo != null) { - msa.setBuildOptions(xmlbo); - } - // - //Init namespace - // - XmlCursor cursor = msa.newCursor(); - String uri = "http://www.TianoCore.org/2006/Edk2.0"; - cursor.push(); - cursor.toNextToken(); - cursor.insertNamespace("", uri); - cursor.insertNamespace("xsi", "http://www.w3.org/2001/XMLSchema-instance"); - cursor.pop(); - - // - //Config file format - // - XmlOptions options = new XmlOptions(); - options.setCharacterEncoding("UTF-8"); - options.setSavePrettyPrint(); - options.setSavePrettyPrintIndent(2); - - // - //Create finial doc - // - msaDoc.addNewModuleSurfaceArea(); - msaDoc.setModuleSurfaceArea((ModuleSurfaceAreaDocument.ModuleSurfaceArea) cursor.getObject()); - try { - // - //Save the file - // - msaDoc.save(f, options); - this.currentModule = this.saveFileName; - } catch (Exception e) { - Log.err("Save Msa", e.getMessage()); - } - } - - /** - Save file as mbd - - **/ - private void saveMbd() { - File f = new File(this.saveFileName); - ModuleBuildDescriptionDocument mbdDoc = ModuleBuildDescriptionDocument.Factory.newInstance(); - ModuleBuildDescriptionDocument.ModuleBuildDescription mbd = ModuleBuildDescriptionDocument.ModuleBuildDescription.Factory - .newInstance(); - // - //Add all components into xml doc file - // - if (xmlmbdh != null) { - mbd.setMbdHeader(xmlmbdh); - } - if (xmllib != null) { - mbd.setLibraries(xmllib); - } - if (xmlsf != null) { - mbd.setSourceFiles(xmlsf); - } - if (xmlic != null) { - mbd.setIncludes(xmlic); - } - if (xmlpl != null) { - mbd.setProtocols(xmlpl); - } - if (xmlen != null) { - mbd.setEvents(xmlen); - } - if (xmlhob != null) { - mbd.setHobs(xmlhob); - } - if (xmlppi != null) { - mbd.setPPIs(xmlppi); - } - if (xmlvb != null) { - mbd.setVariables(xmlvb); - } - if (xmlbm != null) { - mbd.setBootModes(xmlbm); - } - if (xmlst != null) { - mbd.setSystemTables(xmlst); - } - if (xmldh != null) { - mbd.setDataHubs(xmldh); - } - if (xmlfs != null) { - mbd.setFormsets(xmlfs); - } - if (xmlgu != null) { - mbd.setGuids(xmlgu); - } - if (xmlet != null) { - mbd.setExterns(xmlet); - } - if (xmlpcd != null) { - mbd.setPCDs(xmlpcd); - } - if (xmlbo != null) { - mbd.setBuildOptions(xmlbo); - } - // - //Init namespace - // - XmlCursor cursor = mbd.newCursor(); - String uri = "http://www.TianoCore.org/2006/Edk2.0"; - cursor.push(); - cursor.toNextToken(); - cursor.insertNamespace("", uri); - cursor.insertNamespace("xsi", "http://www.w3.org/2001/XMLSchema-instance"); - cursor.pop(); - - // - //Config file format - // - XmlOptions options = new XmlOptions(); - options.setCharacterEncoding("UTF-8"); - options.setSavePrettyPrint(); - options.setSavePrettyPrintIndent(2); - - // - //Create finial doc - // - mbdDoc.addNewModuleBuildDescription(); - mbdDoc.setModuleBuildDescription((ModuleBuildDescriptionDocument.ModuleBuildDescription) cursor.getObject()); - try { - // - //Save the file - // - mbdDoc.save(f, options); - this.currentModule = this.saveFileName; - } catch (Exception e) { - Log.err("Save Mbd", e.getMessage()); - } - } - - /** - Save file as mlsa - - **/ - private void saveMlsa() { - File f = new File(this.saveFileName); - LibraryModuleSurfaceAreaDocument mlsaDoc = LibraryModuleSurfaceAreaDocument.Factory.newInstance(); - LibraryModuleSurfaceAreaDocument.LibraryModuleSurfaceArea mlsa = LibraryModuleSurfaceAreaDocument.LibraryModuleSurfaceArea.Factory - .newInstance(); - // - //Add all components into xml doc file - // - if (xmlmlh != null) { - mlsa.setMsaLibHeader(xmlmlh); - } - if (xmllcd != null) { - mlsa.setLibraryClassDefinitions(xmllcd); - } - if (xmlsf != null) { - mlsa.setSourceFiles(xmlsf); - } - if (xmlic != null) { - mlsa.setIncludes(xmlic); - } - if (xmlpl != null) { - mlsa.setProtocols(xmlpl); - } - if (xmlen != null) { - mlsa.setEvents(xmlen); - } - if (xmlhob != null) { - mlsa.setHobs(xmlhob); - } - if (xmlppi != null) { - mlsa.setPPIs(xmlppi); - } - if (xmlvb != null) { - mlsa.setVariables(xmlvb); - } - if (xmlbm != null) { - mlsa.setBootModes(xmlbm); - } - if (xmlst != null) { - mlsa.setSystemTables(xmlst); - } - if (xmldh != null) { - mlsa.setDataHubs(xmldh); - } - if (xmlfs != null) { - mlsa.setFormsets(xmlfs); - } - if (xmlgu != null) { - mlsa.setGuids(xmlgu); - } - if (xmlet != null) { - mlsa.setExterns(xmlet); - } - if (xmlpcd != null) { - mlsa.setPCDs(xmlpcd); - } - if (xmlbo != null) { - mlsa.setBuildOptions(xmlbo); - } - // - //Init namespace - // - XmlCursor cursor = mlsa.newCursor(); - String uri = "http://www.TianoCore.org/2006/Edk2.0"; - cursor.push(); - cursor.toNextToken(); - cursor.insertNamespace("", uri); - cursor.insertNamespace("xsi", "http://www.w3.org/2001/XMLSchema-instance"); - cursor.pop(); - - // - //Config file format - // - XmlOptions options = new XmlOptions(); - options.setCharacterEncoding("UTF-8"); - options.setSavePrettyPrint(); - options.setSavePrettyPrintIndent(2); - - // - //Create finial doc - // - mlsaDoc.addNewLibraryModuleSurfaceArea(); - mlsaDoc - .setLibraryModuleSurfaceArea((LibraryModuleSurfaceAreaDocument.LibraryModuleSurfaceArea) cursor - .getObject()); - try { - // - //Save the file - // - mlsaDoc.save(f, options); - this.currentModule = this.saveFileName; - } catch (Exception e) { - Log.err("Save Mlsa", e.getMessage()); - } - } - - /** - Save file as mbd - - **/ - private void saveMlbd() { - File f = new File(this.saveFileName); - LibraryModuleBuildDescriptionDocument mlbdDoc = LibraryModuleBuildDescriptionDocument.Factory.newInstance(); - LibraryModuleBuildDescriptionDocument.LibraryModuleBuildDescription mlbd = LibraryModuleBuildDescriptionDocument.LibraryModuleBuildDescription.Factory - .newInstance(); - // - //Add all components into xml doc file - // - if (xmlmlbdh != null) { - mlbd.setMbdLibHeader(xmlmlbdh); - } - if (xmllib != null) { - mlbd.setLibraries(xmllib); - } - if (xmlsf != null) { - mlbd.setSourceFiles(xmlsf); - } - if (xmlic != null) { - mlbd.setIncludes(xmlic); - } - if (xmlpl != null) { - mlbd.setProtocols(xmlpl); - } - if (xmlen != null) { - mlbd.setEvents(xmlen); - } - if (xmlhob != null) { - mlbd.setHobs(xmlhob); - } - if (xmlppi != null) { - mlbd.setPPIs(xmlppi); - } - if (xmlvb != null) { - mlbd.setVariables(xmlvb); - } - if (xmlbm != null) { - mlbd.setBootModes(xmlbm); - } - if (xmlst != null) { - mlbd.setSystemTables(xmlst); - } - if (xmldh != null) { - mlbd.setDataHubs(xmldh); - } - if (xmlfs != null) { - mlbd.setFormsets(xmlfs); - } - if (xmlgu != null) { - mlbd.setGuids(xmlgu); - } - if (xmlet != null) { - mlbd.setExterns(xmlet); - } - if (xmlpcd != null) { - mlbd.setPCDs(xmlpcd); - } - if (xmlbo != null) { - mlbd.setBuildOptions(xmlbo); - } - // - //Init namespace - // - XmlCursor cursor = mlbd.newCursor(); - String uri = "http://www.TianoCore.org/2006/Edk2.0"; - cursor.push(); - cursor.toNextToken(); - cursor.insertNamespace("", uri); - cursor.insertNamespace("xsi", "http://www.w3.org/2001/XMLSchema-instance"); - cursor.pop(); - - // - //Config file format - // - XmlOptions options = new XmlOptions(); - options.setCharacterEncoding("UTF-8"); - options.setSavePrettyPrint(); - options.setSavePrettyPrintIndent(2); - - // - //Create finial doc - // - mlbdDoc.addNewLibraryModuleBuildDescription(); - mlbdDoc - .setLibraryModuleBuildDescription((LibraryModuleBuildDescriptionDocument.LibraryModuleBuildDescription) cursor - .getObject()); - try { - // - //Save the file - // - mlbdDoc.save(f, options); - this.currentModule = this.saveFileName; - } catch (Exception e) { - Log.err("Save Mbd", e.getMessage()); - } - } - - /** - Reflash the tree via current value of xml documents. - - @param intMode The input data of current operation type - - **/ - private void reloadTreeAndTable(int intMode) { - makeTree(); - if (intMode == ModuleMain.OPENED) { - this.jMenuItemModuleClose.setEnabled(true); - this.jMenuItemModuleSaveAs.setEnabled(true); - this.jMenuEditAdd.setEnabled(true); - this.setTitle(windowTitle + "- [" + this.currentModule + "]"); - this.jButtonOk.setEnabled(false); - this.jButtonCancel.setEnabled(false); - } - if (intMode == ModuleMain.CLOSED) { - this.jMenuItemModuleClose.setEnabled(false); - this.jMenuItemModuleSave.setEnabled(false); - this.jMenuItemModuleSaveAs.setEnabled(false); - this.jMenuEditAdd.setEnabled(false); - this.setTitle(windowTitle + "- [" + ws.getCurrentWorkspace() + "]"); - this.setButtonEnable(false); - } - if (intMode == ModuleMain.NEW_WITHOUT_CHANGE) { - - } - - if (intMode == ModuleMain.NEW_WITH_CHANGE) { - this.jMenuItemModuleClose.setEnabled(true); - this.jMenuItemModuleSave.setEnabled(true); - this.jMenuItemModuleSaveAs.setEnabled(true); - this.jMenuEditAdd.setEnabled(true); - setButtonEnable(false); - } - if (intMode == ModuleMain.UPDATE_WITHOUT_CHANGE) { - - } - if (intMode == ModuleMain.UPDATE_WITH_CHANGE) { - this.jMenuItemModuleClose.setEnabled(true); - this.jMenuItemModuleSave.setEnabled(true); - this.jMenuItemModuleSaveAs.setEnabled(true); - } - if (intMode == ModuleMain.SAVE_WITHOUT_CHANGE) { - this.jMenuItemModuleClose.setEnabled(true); - this.jMenuItemModuleSave.setEnabled(true); - this.jMenuItemModuleSaveAs.setEnabled(true); - this.jButtonOk.setEnabled(false); - this.jButtonCancel.setEnabled(false); - } - if (intMode == ModuleMain.SAVE_WITH_CHANGE) { - this.jMenuItemModuleClose.setEnabled(true); - this.jMenuItemModuleSave.setEnabled(false); - this.jMenuItemModuleSaveAs.setEnabled(true); - this.jMenuItemEditUpdate.setEnabled(false); - this.jMenuItemEditDelete.setEnabled(false); - this.setTitle(windowTitle + "- [" + this.currentModule + "]"); - this.jButtonOk.setEnabled(false); - this.jButtonCancel.setEnabled(false); - } - - if (this.currentModuleType == 1 || this.currentModuleType == 3) { - this.jMenuItemEditAddLibraries.setEnabled(false); - this.jMenuItemEditAddLibraryClassDefinitions.setEnabled(true); - } - if (this.currentModuleType == 2 || this.currentModuleType == 4) { - this.jMenuItemEditAddLibraries.setEnabled(true); - this.jMenuItemEditAddLibraryClassDefinitions.setEnabled(false); - } - } - - /** - Enable/Disable button Ok and Cancel - - @param isEnabled The input data to indicate if button is enabled or not - - **/ - private void setButtonEnable(boolean isEnabled) { - this.jButtonCancel.setEnabled(isEnabled); - this.jButtonOk.setEnabled(isEnabled); - } - - /** - Show msa header - When the operation is VIEW, disable all fields of internal frame - - @param type The input data of operation type - - **/ - private void showMsaHeader(int type) { - msa = null; - msa = new MsaHeader(this.xmlmh); - this.jDesktopPane.removeAll(); - this.jDesktopPane.add(msa, 1); - this.currentNodeType = IDefaultMutableTreeNode.MSA_HEADER; - this.currentModuleType = 1; - if (type == ModuleMain.VIEW) { - setButtonEnable(false); - msa.setViewMode(true); - } else { - setButtonEnable(true); - } - } - - /** - Show MbdHeader - When the operation is VIEW, disable all fields of internal frame - - @param type The input data of operation type - - **/ - private void showMbdHeader(int type) { - mbd = null; - mbd = new MbdHeader(this.xmlmbdh); - this.jDesktopPane.removeAll(); - this.jDesktopPane.add(mbd, 1); - this.currentNodeType = IDefaultMutableTreeNode.MBD_HEADER; - this.currentModuleType = 2; - if (type == ModuleMain.VIEW) { - setButtonEnable(false); - mbd.setViewMode(true); - } else { - setButtonEnable(true); - } - } - - /** - Show MlsaHeader - When the operation is VIEW, disable all fields of internal frame - - @param type The input data of operation type - - **/ - private void showMlsaHeader(int type) { - mlsa = null; - mlsa = new MsaLibHeader(this.xmlmlh); - this.jDesktopPane.removeAll(); - this.jDesktopPane.add(mlsa, 1); - this.currentNodeType = IDefaultMutableTreeNode.MLSA_HEADER; - this.currentModuleType = 3; - if (type == ModuleMain.VIEW) { - setButtonEnable(false); - mlsa.setViewMode(true); - } else { - setButtonEnable(true); - } - } - - /** - Show MlbdHeader - When the operation is VIEW, disable all fields of internal frame - - @param type The input data of operation type - - **/ - private void showMlbdHeader(int type) { - mlbd = null; - mlbd = new MbdLibHeader(this.xmlmlbdh); - this.jDesktopPane.removeAll(); - this.jDesktopPane.add(mlbd, 1); - this.currentNodeType = IDefaultMutableTreeNode.MLBD_HEADER; - this.currentModuleType = 4; - if (type == ModuleMain.VIEW) { - setButtonEnable(false); - mlbd.setViewMode(true); - } else { - setButtonEnable(true); - } - } - - /** - Show Libraries - When the operation is VIEW, disable all fields of internal frame - - @param type The input data of operation type - - **/ - private void showLibraries(int operationType, int nodeType, int location) { - mlib = null; - if (operationType == ModuleMain.ADD) { - mlib = new MbdLibraries(this.xmllib, -1, -1, 1); - } - if (operationType == ModuleMain.UPDATE || operationType == ModuleMain.VIEW) { - mlib = new MbdLibraries(this.xmllib, nodeType, location, 2); - } - this.jDesktopPane.removeAll(); - this.jDesktopPane.add(mlib, 1); - this.currentNodeType = nodeType; - if (operationType == ModuleMain.VIEW) { - setButtonEnable(false); - mlib.setViewMode(true); - } else { - setButtonEnable(true); - } - } - - /** - Show LibraryClassDefinitions - When the operation is VIEW, disable all fields of internal frame - - @param type The input data of operation type - - **/ - private void showLibraryClassDefinitions(int operationType, int nodeType) { - mlcd = null; - if (operationType == ModuleMain.ADD) { - mlcd = new ModuleLibraryClassDefinitions(this.xmllcd); - } - if (operationType == ModuleMain.UPDATE || operationType == ModuleMain.VIEW) { - mlcd = new ModuleLibraryClassDefinitions(this.xmllcd); - } - this.jDesktopPane.removeAll(); - this.jDesktopPane.add(mlcd, 1); - this.currentNodeType = nodeType; - if (operationType == ModuleMain.VIEW) { - setButtonEnable(false); - mlcd.setViewMode(true); - } else { - setButtonEnable(true); - } - } - - /** - Show SourceFiles - When the operation is VIEW, disable all fields of internal frame - - @param type The input data of operation type - - **/ - private void showSourceFiles(int operationType, int nodeType, int location) { - msf = null; - if (operationType == ModuleMain.ADD) { - msf = new ModuleSourceFiles(this.xmlsf, -1, -1, 1); - } - if (operationType == ModuleMain.UPDATE || operationType == ModuleMain.VIEW) { - msf = new ModuleSourceFiles(this.xmlsf, nodeType, location, 2); - } - this.jDesktopPane.removeAll(); - this.jDesktopPane.add(msf, 1); - this.currentNodeType = nodeType; - if (operationType == ModuleMain.VIEW) { - setButtonEnable(false); - msf.setViewMode(true); - } else { - setButtonEnable(true); - } - } - - /** - Show Includes - When the operation is VIEW, disable all fields of internal frame - - @param type The input data of operation type - - **/ - private void showIncludes(int operationType, int nodeType, int location) { - mic = null; - if (operationType == ModuleMain.ADD) { - mic = new ModuleIncludes(this.xmlic, -1, -1, 1); - } - if (operationType == ModuleMain.UPDATE || operationType == ModuleMain.VIEW) { - mic = new ModuleIncludes(this.xmlic, nodeType, location, 2); - } - this.jDesktopPane.removeAll(); - this.jDesktopPane.add(mic, 1); - this.currentNodeType = nodeType; - if (operationType == ModuleMain.VIEW) { - setButtonEnable(false); - mic.setViewMode(true); - } else { - setButtonEnable(true); - } - } - - /** - Show Protocols - When the operation is VIEW, disable all fields of internal frame - - @param type The input data of operation type - - **/ - private void showProtocols(int operationType, int nodeType, int location) { - mp = null; - if (operationType == ModuleMain.ADD) { - mp = new ModuleProtocols(this.xmlpl); - } - if (operationType == ModuleMain.UPDATE || operationType == ModuleMain.VIEW) { - mp = new ModuleProtocols(this.xmlpl, nodeType, location); - } - this.jDesktopPane.removeAll(); - this.jDesktopPane.add(mp, 1); - this.currentNodeType = nodeType; - if (operationType == ModuleMain.VIEW) { - setButtonEnable(false); - mp.setViewMode(true); - } else { - setButtonEnable(true); - } - } - - /** - Show Events - When the operation is VIEW, disable all fields of internal frame - - @param type The input data of operation type - - **/ - private void showEvents(int operationType, int nodeType, int location) { - mev = null; - if (operationType == ModuleMain.ADD) { - mev = new ModuleEvents(this.xmlen); - } - if (operationType == ModuleMain.UPDATE || operationType == ModuleMain.VIEW) { - mev = new ModuleEvents(this.xmlen, nodeType, location); - } - this.jDesktopPane.removeAll(); - this.jDesktopPane.add(mev, 1); - this.currentNodeType = nodeType; - if (operationType == ModuleMain.VIEW) { - setButtonEnable(false); - mev.setViewMode(true); - } else { - setButtonEnable(true); - } - } - - /** - Show Hobs - When the operation is VIEW, disable all fields of internal frame - - @param type The input data of operation type - - **/ - private void showHobs(int operationType, int nodeType, int location) { - mh = null; - if (operationType == ModuleMain.ADD) { - mh = new ModuleHobs(this.xmlhob); - } - if (operationType == ModuleMain.UPDATE || operationType == ModuleMain.VIEW) { - mh = new ModuleHobs(this.xmlhob, nodeType, location); - } - this.jDesktopPane.removeAll(); - this.jDesktopPane.add(mh, 1); - this.currentNodeType = nodeType; - if (operationType == ModuleMain.VIEW) { - setButtonEnable(false); - mh.setViewMode(true); - } else { - setButtonEnable(true); - } - } - - /** - Show Ppis - When the operation is VIEW, disable all fields of internal frame - - @param type The input data of operation type - - **/ - private void showPpis(int operationType, int nodeType, int location) { - mpp = null; - if (operationType == ModuleMain.ADD) { - mpp = new ModulePpis(this.xmlppi); - } - if (operationType == ModuleMain.UPDATE || operationType == ModuleMain.VIEW) { - mpp = new ModulePpis(this.xmlppi, nodeType, location); - } - this.jDesktopPane.removeAll(); - this.jDesktopPane.add(mpp, 1); - this.currentNodeType = nodeType; - if (operationType == ModuleMain.VIEW) { - setButtonEnable(false); - mpp.setViewMode(true); - } else { - setButtonEnable(true); - } - } - - /** - Show Variables - When the operation is VIEW, disable all fields of internal frame - - @param type The input data of operation type - - **/ - private void showVariables(int operationType, int nodeType, int location) { - mv = null; - if (operationType == ModuleMain.ADD) { - mv = new ModuleVariables(this.xmlvb); - } - if (operationType == ModuleMain.UPDATE || operationType == ModuleMain.VIEW) { - mv = new ModuleVariables(this.xmlvb, nodeType, location); - } - this.jDesktopPane.removeAll(); - this.jDesktopPane.add(mv, 1); - this.currentNodeType = nodeType; - if (operationType == ModuleMain.VIEW) { - setButtonEnable(false); - mv.setViewMode(true); - } else { - setButtonEnable(true); - } - } - - /** - Show BootModes - When the operation is VIEW, disable all fields of internal frame - - @param type The input data of operation type - - **/ - private void showBootModes(int operationType, int nodeType, int location) { - mbm = null; - if (operationType == ModuleMain.ADD) { - mbm = new ModuleBootModes(this.xmlbm); - } - if (operationType == ModuleMain.UPDATE || operationType == ModuleMain.VIEW) { - mbm = new ModuleBootModes(this.xmlbm, nodeType, location); - } - this.jDesktopPane.removeAll(); - this.jDesktopPane.add(mbm, 1); - this.currentNodeType = nodeType; - if (operationType == ModuleMain.VIEW) { - setButtonEnable(false); - mbm.setViewMode(true); - } else { - setButtonEnable(true); - } - } - - /** - Show SystemTables - When the operation is VIEW, disable all fields of internal frame - - @param type The input data of operation type - - **/ - private void showSystemTables(int operationType, int nodeType, int location) { - mst = null; - if (operationType == ModuleMain.ADD) { - mst = new ModuleSystemTables(this.xmlst); - } - if (operationType == ModuleMain.UPDATE || operationType == ModuleMain.VIEW) { - mst = new ModuleSystemTables(this.xmlst, nodeType, location); - } - this.jDesktopPane.removeAll(); - this.jDesktopPane.add(mst, 1); - this.currentNodeType = nodeType; - if (operationType == ModuleMain.VIEW) { - setButtonEnable(false); - mst.setViewMode(true); - } else { - setButtonEnable(true); - } - } - - /** - Show DataHubs - When the operation is VIEW, disable all fields of internal frame - - @param type The input data of operation type - - **/ - private void showDataHubs(int operationType, int nodeType, int location) { - mdh = null; - if (operationType == ModuleMain.ADD) { - mdh = new ModuleDataHubs(this.xmldh); - } - if (operationType == ModuleMain.UPDATE || operationType == ModuleMain.VIEW) { - mdh = new ModuleDataHubs(this.xmldh, nodeType, location); - } - this.jDesktopPane.removeAll(); - this.jDesktopPane.add(mdh, 1); - this.currentNodeType = nodeType; - if (operationType == ModuleMain.VIEW) { - setButtonEnable(false); - mdh.setViewMode(true); - } else { - setButtonEnable(true); - } - } - - /** - Show Formsets - When the operation is VIEW, disable all fields of internal frame - - @param type The input data of operation type - - **/ - private void showFormsets(int operationType, int nodeType, int location) { - mf = null; - if (operationType == ModuleMain.ADD) { - mf = new ModuleFormsets(this.xmlfs); - } - if (operationType == ModuleMain.UPDATE || operationType == ModuleMain.VIEW) { - mf = new ModuleFormsets(this.xmlfs, nodeType, location); - } - this.jDesktopPane.removeAll(); - this.jDesktopPane.add(mf, 1); - this.currentNodeType = nodeType; - if (operationType == ModuleMain.VIEW) { - setButtonEnable(false); - mf.setViewMode(true); - } else { - setButtonEnable(true); - } - } - - /** - Show Show Guids - When the operation is VIEW, disable all fields of internal frame - - @param type The input data of operation type - - **/ - private void showGuids(int operationType, int nodeType, int location) { - mg = null; - if (operationType == ModuleMain.ADD || operationType == ModuleMain.VIEW) { - mg = new ModuleGuids(this.xmlgu); - } - if (operationType == ModuleMain.UPDATE || operationType == ModuleMain.VIEW) { - mg = new ModuleGuids(this.xmlgu, nodeType, location); - } - this.jDesktopPane.removeAll(); - this.jDesktopPane.add(mg, 1); - this.currentNodeType = nodeType; - if (operationType == ModuleMain.VIEW) { - setButtonEnable(false); - mg.setViewMode(true); - } else { - setButtonEnable(true); - } - } - - /** - Show Externs - When the operation is VIEW, disable all fields of internal frame - - @param type The input data of operation type - - **/ - private void showExterns(int operationType, int nodeType, int location) { - met = null; - if (operationType == ModuleMain.ADD) { - met = new ModuleExterns(this.xmlet); - } - if (operationType == ModuleMain.UPDATE || operationType == ModuleMain.VIEW) { - met = new ModuleExterns(this.xmlet, nodeType, location); - } - this.jDesktopPane.removeAll(); - this.jDesktopPane.add(met, 1); - this.currentNodeType = nodeType; - if (operationType == ModuleMain.VIEW) { - setButtonEnable(false); - met.setViewMode(true); - } else { - setButtonEnable(true); - } - } - - /** - Show PCDs - When the operation is VIEW, disable all fields of internal frame - - @param type The input data of operation type - - **/ - private void showPCDs(int operationType, int nodeType, int location) { - mpcd = null; - if (operationType == ModuleMain.ADD) { - mpcd = new ModulePCDs(this.xmlpcd); - } - if (operationType == ModuleMain.UPDATE || operationType == ModuleMain.VIEW) { - mpcd = new ModulePCDs(this.xmlpcd, nodeType, location); - } - this.jDesktopPane.removeAll(); - this.jDesktopPane.add(mpcd, 1); - this.currentNodeType = nodeType; - if (operationType == ModuleMain.VIEW) { - setButtonEnable(false); - mpcd.setViewMode(true); - } else { - setButtonEnable(true); - } - } - - /** - Save currentModule when press button OK - - **/ - private void save() { - if (this.currentNodeType == IDefaultMutableTreeNode.MSA_HEADER) { - if (!msa.check()) { - return; - } - msa.save(); - msa.setViewMode(true); - this.xmlmh = msa.getMsaHeader(); - } - - if (this.currentNodeType == IDefaultMutableTreeNode.MBD_HEADER) { - if (!mbd.check()) { - return; - } - mbd.save(); - mbd.setViewMode(true); - this.xmlmbdh = mbd.getMbdHeader(); - } - - if (this.currentNodeType == IDefaultMutableTreeNode.MLSA_HEADER) { - if (!mlsa.check()) { - return; - } - mlsa.save(); - mlsa.setViewMode(true); - this.xmlmlh = mlsa.getMsaLibHeader(); - } - - if (this.currentNodeType == IDefaultMutableTreeNode.MLBD_HEADER) { - if (!mlbd.check()) { - return; - } - mlbd.save(); - mlbd.setViewMode(true); - this.xmlmlbdh = mlbd.getMbdLibHeader(); - } - - if (this.currentNodeType == IDefaultMutableTreeNode.LIBRARIES - || this.currentNodeType == IDefaultMutableTreeNode.LIBRARIES_ARCH - || this.currentNodeType == IDefaultMutableTreeNode.LIBRARIES_ARCH_ITEM - || this.currentNodeType == IDefaultMutableTreeNode.LIBRARIES_LIBRARY - || this.currentNodeType == IDefaultMutableTreeNode.LIBRARIES_LIBRARY_ITEM) { - if (!mlib.check()) { - return; - } - mlib.save(); - mlib.setViewMode(true); - this.xmllib = mlib.getLibraries(); - } - - if (this.currentNodeType == IDefaultMutableTreeNode.LIBRARYCLASSDEFINITIONS - || this.currentNodeType == IDefaultMutableTreeNode.LIBRARY_CLASS_DEFINITION) { - if (!mlcd.check()) { - return; - } - mlcd.save(); - mlcd.setViewMode(true); - this.xmllcd = mlcd.getLibraryClassDefinitions(); - } - - if (this.currentNodeType == IDefaultMutableTreeNode.SOURCEFILES - || this.currentNodeType == IDefaultMutableTreeNode.SOURCEFILES_ARCH - || this.currentNodeType == IDefaultMutableTreeNode.SOURCEFILES_ARCH_ITEM - || this.currentNodeType == IDefaultMutableTreeNode.SOURCEFILES_FILENAME - || this.currentNodeType == IDefaultMutableTreeNode.SOURCEFILES_FILENAME_ITEM) { - if (!msf.check()) { - return; - } - msf.save(); - msf.setViewMode(true); - this.xmlsf = msf.getSourceFiles(); - } - - if (this.currentNodeType == IDefaultMutableTreeNode.INCLUDES - || this.currentNodeType == IDefaultMutableTreeNode.INCLUDES_ARCH - || this.currentNodeType == IDefaultMutableTreeNode.INCLUDES_ARCH_ITEM - || this.currentNodeType == IDefaultMutableTreeNode.INCLUDES_PACKAGENAME - || this.currentNodeType == IDefaultMutableTreeNode.INCLUDES_PACKAGENAME_ITEM) { - if (!mic.check()) { - return; - } - mic.save(); - mic.setViewMode(true); - this.xmlic = mic.getIncludes(); - } - - if (this.currentNodeType == IDefaultMutableTreeNode.PROTOCOLS - || this.currentNodeType == IDefaultMutableTreeNode.PROTOCOLS_PROTOCOL - || this.currentNodeType == IDefaultMutableTreeNode.PROTOCOLS_PROTOCOL_ITEM - || this.currentNodeType == IDefaultMutableTreeNode.PROTOCOLS_PROTOCOLNOTIFY - || this.currentNodeType == IDefaultMutableTreeNode.PROTOCOLS_PROTOCOLNOTIFY_ITEM) { - if (!mp.check()) { - return; - } - mp.save(); - mp.setViewMode(true); - this.xmlpl = mp.getProtocols(); - } - - if (this.currentNodeType == IDefaultMutableTreeNode.EVENTS - || this.currentNodeType == IDefaultMutableTreeNode.EVENTS_CREATEEVENTS - || this.currentNodeType == IDefaultMutableTreeNode.EVENTS_CREATEEVENTS_ITEM - || this.currentNodeType == IDefaultMutableTreeNode.EVENTS_SIGNALEVENTS - || this.currentNodeType == IDefaultMutableTreeNode.EVENTS_SIGNALEVENTS_ITEM) { - if (!mev.check()) { - return; - } - mev.save(); - mev.setViewMode(true); - this.xmlen = mev.getEvents(); - } - - if (this.currentNodeType == IDefaultMutableTreeNode.HOBS - || this.currentNodeType == IDefaultMutableTreeNode.HOBS_HOB_ITEM) { - if (!mh.check()) { - return; - } - mh.save(); - mh.setViewMode(true); - this.xmlhob = mh.getHobs(); - } - - if (this.currentNodeType == IDefaultMutableTreeNode.PPIS - || this.currentNodeType == IDefaultMutableTreeNode.PPIS_PPI - || this.currentNodeType == IDefaultMutableTreeNode.PPIS_PPI_ITEM - || this.currentNodeType == IDefaultMutableTreeNode.PPIS_PPINOTIFY - || this.currentNodeType == IDefaultMutableTreeNode.PPIS_PPINOTIFY_ITEM) { - if (!mpp.check()) { - return; - } - mpp.save(); - mpp.setViewMode(true); - this.xmlppi = mpp.getPpis(); - } - - if (this.currentNodeType == IDefaultMutableTreeNode.VARIABLES - || this.currentNodeType == IDefaultMutableTreeNode.VARIABLES_VARIABLE_ITEM) { - if (!mv.check()) { - return; - } - mv.save(); - mv.setViewMode(true); - this.xmlvb = mv.getVariables(); - } - - if (this.currentNodeType == IDefaultMutableTreeNode.BOOTMODES - || this.currentNodeType == IDefaultMutableTreeNode.BOOTMODES_BOOTMODE_ITEM) { - if (!mbm.check()) { - return; - } - mbm.save(); - mbm.setViewMode(true); - this.xmlbm = mbm.getBootModes(); - } - - if (this.currentNodeType == IDefaultMutableTreeNode.SYSTEMTABLES - || this.currentNodeType == IDefaultMutableTreeNode.SYSTEMTABLES_SYSTEMTABLE_ITEM) { - if (!mst.check()) { - return; - } - mst.save(); - mst.setViewMode(true); - this.xmlst = mst.getSystemTables(); - } - - if (this.currentNodeType == IDefaultMutableTreeNode.DATAHUBS - || this.currentNodeType == IDefaultMutableTreeNode.DATAHUBS_DATAHUB_ITEM) { - if (!mdh.check()) { - return; - } - mdh.save(); - mdh.setViewMode(true); - this.xmldh = mdh.getDataHubs(); - } - - if (this.currentNodeType == IDefaultMutableTreeNode.FORMSETS - || this.currentNodeType == IDefaultMutableTreeNode.FORMSETS_FORMSET_ITEM) { - if (!mf.check()) { - return; - } - mf.save(); - mf.setViewMode(true); - this.xmlfs = mf.getFormsets(); - } - - if (this.currentNodeType == IDefaultMutableTreeNode.GUIDS - || this.currentNodeType == IDefaultMutableTreeNode.GUIDS_GUIDENTRY_ITEM) { - if (!mg.check()) { - return; - } - mg.save(); - mg.setViewMode(true); - this.xmlgu = mg.getGuids(); - } - - if (this.currentNodeType == IDefaultMutableTreeNode.EXTERNS - || this.currentNodeType == IDefaultMutableTreeNode.EXTERNS_EXTERN_ITEM) { - if (!met.check()) { - return; - } - met.save(); - met.setViewMode(true); - this.xmlet = met.getExterns(); - } - - if (this.currentNodeType == IDefaultMutableTreeNode.PCDS - || this.currentNodeType == IDefaultMutableTreeNode.PCDS_PCDDATA_ITEM) { - if (!mpcd.check()) { - return; - } - mpcd.save(); - mpcd.setViewMode(true); - this.xmlpcd = mpcd.getPcds(); - } - - reloadTreeAndTable(NEW_WITH_CHANGE); - } -} diff --git a/Tools/Source/ModuleEditor/src/org/tianocore/packaging/module/ui/ModulePCDs.java b/Tools/Source/ModuleEditor/src/org/tianocore/packaging/module/ui/ModulePCDs.java deleted file mode 100644 index 827efe9f3f..0000000000 --- a/Tools/Source/ModuleEditor/src/org/tianocore/packaging/module/ui/ModulePCDs.java +++ /dev/null @@ -1,519 +0,0 @@ -/** @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()); - } - } -} diff --git a/Tools/Source/ModuleEditor/src/org/tianocore/packaging/module/ui/ModulePpis.java b/Tools/Source/ModuleEditor/src/org/tianocore/packaging/module/ui/ModulePpis.java deleted file mode 100644 index 42d0fb8d70..0000000000 --- a/Tools/Source/ModuleEditor/src/org/tianocore/packaging/module/ui/ModulePpis.java +++ /dev/null @@ -1,711 +0,0 @@ -/** @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, 250, 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(415, 60, 65, 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, 50, 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"); - } - } -} diff --git a/Tools/Source/ModuleEditor/src/org/tianocore/packaging/module/ui/ModuleProtocols.java b/Tools/Source/ModuleEditor/src/org/tianocore/packaging/module/ui/ModuleProtocols.java deleted file mode 100644 index 46955ce68f..0000000000 --- a/Tools/Source/ModuleEditor/src/org/tianocore/packaging/module/ui/ModuleProtocols.java +++ /dev/null @@ -1,705 +0,0 @@ -/** @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, 250, 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(415, 60, 65, 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, 50, 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()); - } - } -} diff --git a/Tools/Source/ModuleEditor/src/org/tianocore/packaging/module/ui/ModuleSourceFiles.java b/Tools/Source/ModuleEditor/src/org/tianocore/packaging/module/ui/ModuleSourceFiles.java deleted file mode 100644 index 036ca9a709..0000000000 --- a/Tools/Source/ModuleEditor/src/org/tianocore/packaging/module/ui/ModuleSourceFiles.java +++ /dev/null @@ -1,1060 +0,0 @@ -/** @file - - The file is used to create, update SourceFile 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.JFileChooser; -import javax.swing.JLabel; -import javax.swing.JPanel; -import javax.swing.JTextField; - -import org.tianocore.FilenameDocument; -import org.tianocore.SourceFilesDocument; -import org.tianocore.SupportedArchitectures; -import org.tianocore.ToolChains; -import org.tianocore.common.DataType; -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; -import org.tianocore.packaging.workspace.common.Workspace; -import javax.swing.JScrollPane; -import javax.swing.JTextArea; - -/** - The class is used to create, update SourceFile of MSA/MBD file - It extends IInternalFrame - - @since ModuleEditor 1.0 - - **/ -public class ModuleSourceFiles extends IInternalFrame implements ItemListener { - - /// - /// Define class Serial Version UID - /// - private static final long serialVersionUID = -6765742852142775378L; - - // - // Define class members - // - private SourceFilesDocument.SourceFiles sourceFiles = null; - - private int location = -1; - - private int intSelectedItemId = 0; - - // - // 1 - Add; 2 - Update - // - private int operation = -1; - - private Workspace ws = new Workspace(); - - private Vector vFileName = new Vector(); - - private Vector vGuid = new Vector(); - - private Vector vPath = new Vector(); - - private Vector vFileType = new Vector(); - - private Vector vToolChain = new Vector(); - - private Vector vOverrideID = new Vector(); - - private JPanel jContentPane = null; - - private JButton jButtonOk = null; - - private JButton jButtonCancel = null; - - private JLabel jLabelFileName = null; - - private JTextField jTextFieldFileName = null; - - private JButton jButtonOpenFile = null; - - private JLabel jLabelGuid = null; - - private JTextField jTextFieldGuid = null; - - private JButton jButtonGenerateGuid = null; - - private JComboBox jComboBoxArch = null; - - private JLabel jLabelPath = null; - - private JTextField jTextFieldPath = null; - - private JLabel jLabelFileType = null; - - private JTextField jTextFieldFileType = null; - - private JLabel jLabelOverrideID = null; - - private JTextField jTextFieldOverrideID = null; - - private StarLabel jStarLabel1 = null; - - private JComboBox jComboBoxFileList = null; - - private JButton jButtonAdd = null; - - private JButton jButtonRemove = null; - - private JButton jButtonUpdate = null; - - private JCheckBox jCheckBoxArch = null; - - private JLabel jLabelToolChain = null; - - private JComboBox jComboBoxToolChain = null; - - private JScrollPane jScrollPaneFileList = null; - - private JTextArea jTextAreaFileList = 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, 340, 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, 340, 90, 20)); - jButtonCancel.setPreferredSize(new java.awt.Dimension(90, 20)); - jButtonCancel.addActionListener(this); - } - return jButtonCancel; - } - - /** - This method initializes jTextFieldFileName - - @return javax.swing.JTextField jTextFieldFileName - - **/ - private JTextField getJTextFieldSourceFilesDirectory() { - if (jTextFieldFileName == null) { - jTextFieldFileName = new JTextField(); - jTextFieldFileName.setBounds(new java.awt.Rectangle(140,10,250,20)); - } - return jTextFieldFileName; - } - - /** - This method initializes jButtonOpenFile - - @return javax.swing.JButton jButtonOpenFile - - **/ - private JButton getJButtonOpenFile() { - if (jButtonOpenFile == null) { - jButtonOpenFile = new JButton(); - jButtonOpenFile.setText("Browse"); - jButtonOpenFile.setBounds(new java.awt.Rectangle(395,10,85,20)); - jButtonOpenFile.addActionListener(this); - } - return jButtonOpenFile; - } - - /** - This method initializes jTextFieldGuid - - @return javax.swing.JTextField jTextFieldGuid - - **/ - private JTextField getJTextFieldGuid() { - if (jTextFieldGuid == null) { - jTextFieldGuid = new JTextField(); - jTextFieldGuid.setBounds(new java.awt.Rectangle(140,35,250,20)); - } - return jTextFieldGuid; - } - - /** - This method initializes jButtonGenerateGuid - - @return javax.swing.JButton jButtonGenerateGuid - - **/ - private JButton getJButtonGenerateGuid() { - if (jButtonGenerateGuid == null) { - jButtonGenerateGuid = new JButton(); - jButtonGenerateGuid.setBounds(new java.awt.Rectangle(395,35,85,20)); - jButtonGenerateGuid.setText("GEN"); - jButtonGenerateGuid.addActionListener(this); - } - return jButtonGenerateGuid; - } - - /** - 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, 160, 340, 20)); - jComboBoxArch.setEnabled(false); - } - return jComboBoxArch; - } - - /** - This method initializes jTextFieldPath - - @return javax.swing.JTextField jTextFieldPath - - **/ - private JTextField getJTextFieldPath() { - if (jTextFieldPath == null) { - jTextFieldPath = new JTextField(); - jTextFieldPath.setBounds(new java.awt.Rectangle(140, 60, 340, 20)); - } - return jTextFieldPath; - } - - /** - This method initializes jTextFieldFileType - - @return javax.swing.JTextField jTextFieldFileType - - **/ - private JTextField getJTextFieldFileType() { - if (jTextFieldFileType == null) { - jTextFieldFileType = new JTextField(); - jTextFieldFileType.setBounds(new java.awt.Rectangle(140, 85, 340, 20)); - } - return jTextFieldFileType; - } - - /** - This method initializes jTextFieldOverrideID - - @return javax.swing.JTextField jTextFieldOverrideID - - **/ - private JTextField getJTextFieldOverrideID() { - if (jTextFieldOverrideID == null) { - jTextFieldOverrideID = new JTextField(); - jTextFieldOverrideID.setBounds(new java.awt.Rectangle(140, 135, 50, 20)); - } - return jTextFieldOverrideID; - } - - /** - 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, 185, 210, 20)); - jComboBoxFileList.addItemListener(this); - jComboBoxFileList.addActionListener(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, 185, 80, 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(400, 185, 80, 20)); - jButtonRemove.setText("Remove"); - jButtonRemove.addActionListener(this); - } - return jButtonRemove; - } - - /** - 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, 185, 80, 20)); - jButtonUpdate.setText("Update"); - jButtonUpdate.addActionListener(this); - } - return jButtonUpdate; - } - - /** - This method initializes jCheckBoxArch - - @return javax.swing.JCheckBox jCheckBoxArch - - **/ - private JCheckBox getJCheckBoxArch() { - if (jCheckBoxArch == null) { - jCheckBoxArch = new JCheckBox(); - jCheckBoxArch.setBounds(new java.awt.Rectangle(15, 160, 120, 20)); - jCheckBoxArch.setText("Specific Arch"); - jCheckBoxArch.addActionListener(this); - } - return jCheckBoxArch; - } - - /** - This method initializes jComboBoxToolChain - - @return javax.swing.JComboBox jComboBoxToolChain - - **/ - private JComboBox getJComboBoxToolChain() { - if (jComboBoxToolChain == null) { - jComboBoxToolChain = new JComboBox(); - jComboBoxToolChain.setBounds(new java.awt.Rectangle(140, 110, 340, 20)); - } - return jComboBoxToolChain; - } - - /** - * This method initializes jScrollPaneFileList - * - * @return javax.swing.JScrollPane - */ - private JScrollPane getJScrollPaneFileList() { - if (jScrollPaneFileList == null) { - jScrollPaneFileList = new JScrollPane(); - jScrollPaneFileList.setBounds(new java.awt.Rectangle(15,210,465,240)); - jScrollPaneFileList.setViewportView(getJTextAreaFileList()); - } - return jScrollPaneFileList; - } - - /** - * This method initializes jTextAreaFileList - * - * @return javax.swing.JTextArea - */ - private JTextArea getJTextAreaFileList() { - if (jTextAreaFileList == null) { - jTextAreaFileList = new JTextArea(); - jTextAreaFileList.setEditable(false); - } - return jTextAreaFileList; - } - - public static void main(String[] args) { - - } - - /** - This is the default constructor - - **/ - public ModuleSourceFiles() { - super(); - init(); - this.setVisible(true); - } - - /** - This is the override edit constructor - - @param inSourceFiles The input data of SourceFilesDocument.SourceFiles - - **/ - public ModuleSourceFiles(SourceFilesDocument.SourceFiles inSourceFiles) { - super(); - init(inSourceFiles); - this.setVisible(true); - } - - /** - This is the override edit constructor - - @param inSourceFiles The input data of SourceFilesDocument.SourceFiles - @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 ModuleSourceFiles(SourceFilesDocument.SourceFiles inSourceFiles, int type, int index, int inOperation) { - super(); - init(inSourceFiles, type, index, inOperation); - this.operation = inOperation; - this.setVisible(true); - } - - /** - This method initializes this - - @param inSourceFiles The input data of SourceFilesDocument.SourceFiles - - **/ - private void init(SourceFilesDocument.SourceFiles inSourceFiles) { - init(); - this.setSourceFiles(inSourceFiles); - } - - /** - This method initializes this - Fill values to all fields if these values are not empty - - - @param inSourceFiles The input data of SourceFilesDocument.SourceFiles - @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(SourceFilesDocument.SourceFiles inSourceFiles, int type, int index, int inOperation) { - init(inSourceFiles); - this.location = index; - this.operation = inOperation; - - // - // When update - // - if (operation == 2) { - this.jCheckBoxArch.setEnabled(false); - this.jComboBoxArch.setEnabled(false); - - if (type == IDefaultMutableTreeNode.SOURCEFILES_FILENAME) { - if (this.sourceFiles.getFilenameList().size() > 0) { - for (int indexI = 0; indexI < this.sourceFiles.getFilenameList().size(); indexI++) { - if (this.sourceFiles.getFilenameArray(indexI).getStringValue() != null) { - vFileName.addElement(this.sourceFiles.getFilenameArray(indexI).getStringValue()); - } else { - vFileName.addElement(""); - } - if (this.sourceFiles.getFilenameArray(indexI).getGuid() != null) { - vGuid.addElement(this.sourceFiles.getFilenameArray(indexI).getGuid()); - } else { - vGuid.addElement(""); - } - if (this.sourceFiles.getFilenameArray(indexI).getPath() != null) { - vPath.addElement(this.sourceFiles.getFilenameArray(indexI).getPath()); - } else { - vPath.addElement(""); - } - if (this.sourceFiles.getFilenameArray(indexI).getFileType() != null) { - vFileType.addElement(this.sourceFiles.getFilenameArray(indexI).getFileType()); - } else { - vFileType.addElement(""); - } - if (this.sourceFiles.getFilenameArray(indexI).getToolChain() != null) { - vToolChain.addElement(this.sourceFiles.getFilenameArray(indexI).getToolChain().toString()); - } else { - vToolChain.addElement(DataType.EMPTY_SELECT_ITEM); - } - vOverrideID.addElement(String.valueOf(this.sourceFiles.getFilenameArray(indexI).getOverrideID())); - jComboBoxFileList.addItem(this.sourceFiles.getFilenameArray(indexI).getStringValue()); - } - } - } - if (type == IDefaultMutableTreeNode.SOURCEFILES_ARCH_ITEM) { - this.jCheckBoxArch.setSelected(true); - this.jComboBoxArch.setSelectedItem(this.sourceFiles.getArchArray(index).getArchType().toString()); - for (int indexI = 0; indexI < this.sourceFiles.getArchArray(index).getFilenameList().size(); indexI++) { - if (this.sourceFiles.getArchArray(index).getFilenameArray(indexI).getStringValue() != null) { - vFileName.addElement(this.sourceFiles.getArchArray(index).getFilenameArray(indexI) - .getStringValue()); - } else { - vFileName.addElement(""); - } - if (this.sourceFiles.getArchArray(index).getFilenameArray(indexI).getGuid() != null) { - vGuid.addElement(this.sourceFiles.getArchArray(index).getFilenameArray(indexI).getGuid()); - } else { - vGuid.addElement(""); - } - if (this.sourceFiles.getArchArray(index).getFilenameArray(indexI).getPath() != null) { - vPath.addElement(this.sourceFiles.getArchArray(index).getFilenameArray(indexI).getPath()); - } else { - vPath.addElement(""); - } - if (this.sourceFiles.getArchArray(index).getFilenameArray(indexI).getFileType() != null) { - vFileType.addElement(this.sourceFiles.getArchArray(index).getFilenameArray(indexI) - .getFileType()); - } else { - vFileType.addElement(""); - } - if (this.sourceFiles.getArchArray(index).getFilenameArray(indexI).getToolChain() != null) { - vToolChain.addElement(this.sourceFiles.getArchArray(index).getFilenameArray(indexI) - .getToolChain().toString()); - } else { - vToolChain.addElement(""); - } - vOverrideID.addElement(String.valueOf(this.sourceFiles.getArchArray(index).getFilenameArray(indexI) - .getOverrideID())); - jComboBoxFileList.addItem(this.sourceFiles.getArchArray(index).getFilenameArray(indexI) - .getStringValue()); - } - } - // - // Update the file list - // - reloadFileListArea(); - } - } - - /** - This method initializes this - - **/ - private void init() { - this.setSize(500, 515); - this.setContentPane(getJContentPane()); - this.setTitle("Source Files"); - 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.jButtonOk.setEnabled(!isView); - this.jButtonCancel.setEnabled(!isView); - this.jTextFieldFileName.setEnabled(!isView); - this.jButtonOpenFile.setEnabled(!isView); - this.jTextFieldGuid.setEnabled(!isView); - this.jButtonGenerateGuid.setEnabled(!isView); - this.jTextFieldPath.setEnabled(!isView); - this.jTextFieldFileType.setEnabled(!isView); - this.jComboBoxToolChain.setEnabled(!isView); - this.jTextFieldOverrideID.setEnabled(!isView); - - this.jButtonAdd.setEnabled(!isView); - this.jButtonRemove.setEnabled(!isView); - this.jButtonUpdate.setEnabled(!isView); - this.jCheckBoxArch.setEnabled(!isView); - } - } - - /** - This method initializes jContentPane - - @return javax.swing.JPanel jContentPane - - **/ - private JPanel getJContentPane() { - if (jContentPane == null) { - jLabelToolChain = new JLabel(); - jLabelToolChain.setBounds(new java.awt.Rectangle(15, 110, 120, 20)); - jLabelToolChain.setText("Tool Chain"); - jLabelOverrideID = new JLabel(); - jLabelOverrideID.setBounds(new java.awt.Rectangle(15, 135, 120, 20)); - jLabelOverrideID.setText("Override ID"); - jLabelFileType = new JLabel(); - jLabelFileType.setBounds(new java.awt.Rectangle(15, 85, 120, 20)); - jLabelFileType.setText("File Type"); - jLabelPath = new JLabel(); - jLabelPath.setBounds(new java.awt.Rectangle(15, 60, 120, 20)); - jLabelPath.setText("Path"); - jLabelGuid = new JLabel(); - jLabelGuid.setBounds(new java.awt.Rectangle(15, 35, 120, 20)); - jLabelGuid.setText("Guid"); - jLabelFileName = new JLabel(); - jLabelFileName.setText("File Name"); - jLabelFileName.setBounds(new java.awt.Rectangle(15, 10, 120, 20)); - jContentPane = new JPanel(); - jContentPane.setLayout(null); - jContentPane.setSize(new java.awt.Dimension(480,400)); - jContentPane.add(getJButton(), null); - jContentPane.add(getJButton1(), null); - jContentPane.add(jLabelFileName, null); - jContentPane.add(getJTextFieldSourceFilesDirectory(), null); - jContentPane.add(getJButtonOpenFile(), null); - jContentPane.add(jLabelGuid, null); - jContentPane.add(getJTextFieldGuid(), null); - jContentPane.add(getJButtonGenerateGuid(), null); - jContentPane.add(getJComboBoxArch(), null); - jContentPane.add(jLabelPath, null); - jContentPane.add(getJTextFieldPath(), null); - jContentPane.add(jLabelFileType, null); - jContentPane.add(getJTextFieldFileType(), null); - jContentPane.add(jLabelOverrideID, null); - jContentPane.add(getJTextFieldOverrideID(), null); - jStarLabel1 = new StarLabel(); - jStarLabel1.setLocation(new java.awt.Point(0, 10)); - - jContentPane.add(jStarLabel1, null); - jContentPane.add(getJComboBoxFileList(), null); - jContentPane.add(getJButtonAdd(), null); - jContentPane.add(getJButtonRemove(), null); - jContentPane.add(getJButtonUpdate(), null); - jContentPane.add(getJCheckBoxArch(), null); - jContentPane.add(jLabelToolChain, null); - jContentPane.add(getJComboBoxToolChain(), null); - - jContentPane.add(getJScrollPaneFileList(), 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() == jButtonGenerateGuid) { - jTextFieldGuid.setText(Tools.generateUuidString()); - } - if (arg0.getSource() == jButtonOpenFile) { - selectFile(); - } - 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 and Arch type - - **/ - private void initFrame() { - jComboBoxArch.addItem("ALL"); - jComboBoxArch.addItem("EBC"); - jComboBoxArch.addItem("ARM"); - jComboBoxArch.addItem("IA32"); - jComboBoxArch.addItem("X64"); - jComboBoxArch.addItem("IPF"); - jComboBoxArch.addItem("PPC"); - - jComboBoxToolChain.addItem(DataType.EMPTY_SELECT_ITEM); - jComboBoxToolChain.addItem("MSFT"); - jComboBoxToolChain.addItem("INTEL"); - jComboBoxToolChain.addItem("GCC"); - jComboBoxToolChain.addItem("CYGWIN"); - } - - /** - Add current item to Vector - - **/ - private void addToList() { - intSelectedItemId = vFileName.size(); - vFileName.addElement(this.jTextFieldFileName.getText()); - vGuid.addElement(this.jTextFieldGuid.getText()); - vPath.addElement(this.jTextFieldPath.getText()); - vFileType.addElement(this.jTextFieldFileType.getText()); - vToolChain.addElement(this.jComboBoxToolChain.getSelectedItem().toString()); - vOverrideID.addElement(this.jTextFieldOverrideID.getText()); - jComboBoxFileList.addItem(this.jTextFieldFileName.getText()); - jComboBoxFileList.setSelectedItem(this.jTextFieldFileName.getText()); - - // - // Reset select item index - // - intSelectedItemId = vFileName.size(); - - // - // Reload all fields of selected item - // - reloadFromList(); - } - - /** - Remove current item from Vector - - **/ - private void removeFromList() { - int intTempIndex = intSelectedItemId; - if (vFileName.size() < 1) { - return; - } - - jComboBoxFileList.removeItemAt(intSelectedItemId); - - vFileName.removeElementAt(intTempIndex); - vGuid.removeElementAt(intTempIndex); - vPath.removeElementAt(intTempIndex); - vFileType.removeElementAt(intTempIndex); - vToolChain.removeElementAt(intTempIndex); - vOverrideID.removeElementAt(intTempIndex); - - // - // Reload all fields of selected item - // - reloadFromList(); - } - - /** - Update current item of Vector - - **/ - private void updateForList() { - // - // Backup selected item index - // - int intTempIndex = intSelectedItemId; - vFileName.setElementAt(this.jTextFieldFileName.getText(), intSelectedItemId); - vGuid.setElementAt(this.jTextFieldGuid.getText(), intSelectedItemId); - vPath.setElementAt(this.jTextFieldPath.getText(), intSelectedItemId); - vFileType.setElementAt(this.jTextFieldFileType.getText(), intSelectedItemId); - vToolChain.setElementAt(this.jComboBoxToolChain.getSelectedItem().toString(), intSelectedItemId); - vOverrideID.setElementAt(this.jTextFieldOverrideID.getText(), intSelectedItemId); - jComboBoxFileList.removeAllItems(); - for (int index = 0; index < vFileName.size(); index++) { - jComboBoxFileList.addItem(vFileName.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 (vFileName.size() > 0) { - // - // Get selected item index - // - intSelectedItemId = jComboBoxFileList.getSelectedIndex(); - - this.jTextFieldFileName.setText(vFileName.elementAt(intSelectedItemId).toString()); - this.jTextFieldGuid.setText(vGuid.elementAt(intSelectedItemId).toString()); - this.jTextFieldPath.setText(vPath.elementAt(intSelectedItemId).toString()); - this.jTextFieldFileType.setText(vFileType.elementAt(intSelectedItemId).toString()); - this.jComboBoxToolChain.setSelectedItem(vToolChain.elementAt(intSelectedItemId).toString()); - this.jTextFieldOverrideID.setText(vOverrideID.elementAt(intSelectedItemId).toString()); - } else { - this.jTextFieldFileName.setText(""); - this.jTextFieldGuid.setText(""); - this.jTextFieldPath.setText(""); - this.jTextFieldFileType.setText(""); - this.jComboBoxToolChain.setSelectedItem(DataType.EMPTY_SELECT_ITEM); - this.jTextFieldOverrideID.setText(""); - } - - reloadFileListArea(); - } - - /* (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(); - } - } - - /** - Get SourceFilesDocument.SourceFiles - - @return SourceFilesDocument.SourceFiles - - **/ - public SourceFilesDocument.SourceFiles getSourceFiles() { - return sourceFiles; - } - - /** - Set SourceFilesDocument.SourceFiles - - @param sourceFiles The input data of SourceFilesDocument.SourceFiles - - **/ - public void setSourceFiles(SourceFilesDocument.SourceFiles sourceFiles) { - this.sourceFiles = sourceFiles; - } - - /** - 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 file 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 (isEmpty(this.jTextFieldFileName.getText())) { - Log.err("File Name couldn't be empty"); - return false; - } - - // - // Check if all fields have correct data types - // - if (!DataValidation.isFileName(this.jTextFieldFileName.getText())) { - Log.err("Incorrect data type for File 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.jTextFieldPath.getText()) && !DataValidation.isPath(this.jTextFieldPath.getText())) { - Log.err("Incorrect data type for Path"); - 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 SourceFiles - if exists sourceFiles, set the value directly - if not exists sourceFiles, new an instance first - - **/ - public void save() { - try { - if (this.sourceFiles == null) { - sourceFiles = SourceFilesDocument.SourceFiles.Factory.newInstance(); - } - // - //Save as file name - // - if (!this.jCheckBoxArch.isSelected()) { - if (this.operation == 2) { //Add new filename - // - //First remove all existed filename - // - if (sourceFiles.getFilenameList().size() > 0) { - for (int index = sourceFiles.getFilenameList().size() - 1; index >= 0; index--) { - sourceFiles.removeFilename(index); - } - } - } - for (int index = 0; index < vFileName.size(); index++) { - FilenameDocument.Filename filename = FilenameDocument.Filename.Factory.newInstance(); - if (!isEmpty(vFileName.elementAt(index).toString())) { - filename.setStringValue(vFileName.elementAt(index).toString()); - } - if (!isEmpty(vGuid.elementAt(index).toString())) { - filename.setGuid(vGuid.elementAt(index).toString()); - } - if (!isEmpty(vPath.elementAt(index).toString())) { - filename.setPath(vPath.elementAt(index).toString()); - } - if (!isEmpty(vFileType.elementAt(index).toString())) { - filename.setFileType(vFileType.elementAt(index).toString()); - } - if (!vToolChain.elementAt(index).toString().equals(DataType.EMPTY_SELECT_ITEM)) { - filename.setToolChain(ToolChains.Enum.forString(vToolChain.elementAt(index).toString())); - } - if (!isEmpty(vOverrideID.elementAt(index).toString())) { - filename.setOverrideID(Integer.parseInt(vOverrideID.elementAt(index).toString())); - } - sourceFiles.addNewFilename(); - sourceFiles.setFilenameArray(sourceFiles.getFilenameList().size() - 1, filename); - } - } - // - //Save as Arch - // - if (this.jCheckBoxArch.isSelected()) { - SourceFilesDocument.SourceFiles.Arch arch = SourceFilesDocument.SourceFiles.Arch.Factory.newInstance(); - if (this.operation == 2) { - // - //First remove all existed filename - // - for (int index = sourceFiles.getArchArray(location).getFilenameList().size() - 1; index >= 0; index--) { - sourceFiles.getArchArray(location).removeFilename(index); - } - } - for (int index = 0; index < vFileName.size(); index++) { - FilenameDocument.Filename filename = FilenameDocument.Filename.Factory.newInstance(); - if (!isEmpty(vFileName.elementAt(index).toString())) { - filename.setStringValue(vFileName.elementAt(index).toString()); - } - if (!isEmpty(vGuid.elementAt(index).toString())) { - filename.setGuid(vGuid.elementAt(index).toString()); - } - if (!isEmpty(vPath.elementAt(index).toString())) { - filename.setPath(vPath.elementAt(index).toString()); - } - if (!isEmpty(vFileType.elementAt(index).toString())) { - filename.setFileType(vFileType.elementAt(index).toString()); - } - if (!vToolChain.elementAt(index).toString().equals(DataType.EMPTY_SELECT_ITEM)) { - filename.setToolChain(ToolChains.Enum.forString(vToolChain.elementAt(index).toString())); - } - if (!isEmpty(vOverrideID.elementAt(index).toString())) { - filename.setOverrideID(Integer.parseInt(vOverrideID.elementAt(index).toString())); - } - arch.addNewFilename(); - arch.setFilenameArray(arch.getFilenameList().size() - 1, filename); - } - arch - .setArchType(SupportedArchitectures.Enum.forString(this.jComboBoxArch.getSelectedItem().toString())); - if (location > -1) { - sourceFiles.setArchArray(location, arch); - } else { - sourceFiles.addNewArch(); - sourceFiles.setArchArray(sourceFiles.getArchList().size() - 1, arch); - } - } - } catch (Exception e) { - Log.err("Update Source Files", e.getMessage()); - } - } - - /** - Display a file open browser to let user select file - - **/ - private void selectFile() { - JFileChooser fc = new JFileChooser(ws.getCurrentWorkspace()); - - int result = fc.showOpenDialog(new JPanel()); - if (result == JFileChooser.APPROVE_OPTION) { - this.jTextFieldFileName.setText(fc.getSelectedFile().getName()); - } - } - - /** - Update file list pane via the elements of Vector - - **/ - private void reloadFileListArea() { - String strFileList = ""; - for (int index = 0; index < vFileName.size(); index++) { - strFileList = strFileList + vFileName.elementAt(index).toString() + DataType.UNXI_LINE_SEPARATOR; - } - this.jTextAreaFileList.setText(strFileList); - } -} diff --git a/Tools/Source/ModuleEditor/src/org/tianocore/packaging/module/ui/ModuleSystemTables.java b/Tools/Source/ModuleEditor/src/org/tianocore/packaging/module/ui/ModuleSystemTables.java deleted file mode 100644 index 185ace3493..0000000000 --- a/Tools/Source/ModuleEditor/src/org/tianocore/packaging/module/ui/ModuleSystemTables.java +++ /dev/null @@ -1,393 +0,0 @@ -/** @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, 50, 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).getEntryList() != null) { - this.jTextFieldEntry.setText(this.systemTables.getSystemTableArray(index).getEntryList().get(0)); - } - 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()); - } - } -} diff --git a/Tools/Source/ModuleEditor/src/org/tianocore/packaging/module/ui/ModuleVariables.java b/Tools/Source/ModuleEditor/src/org/tianocore/packaging/module/ui/ModuleVariables.java deleted file mode 100644 index 90a28591f5..0000000000 --- a/Tools/Source/ModuleEditor/src/org/tianocore/packaging/module/ui/ModuleVariables.java +++ /dev/null @@ -1,601 +0,0 @@ -/** @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()); - } - } -} diff --git a/Tools/Source/ModuleEditor/src/org/tianocore/packaging/module/ui/MsaHeader.java b/Tools/Source/ModuleEditor/src/org/tianocore/packaging/module/ui/MsaHeader.java deleted file mode 100644 index 7edf49a3ff..0000000000 --- a/Tools/Source/ModuleEditor/src/org/tianocore/packaging/module/ui/MsaHeader.java +++ /dev/null @@ -1,789 +0,0 @@ -/** @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 JLabel jLabelDescription = null; - - private JTextArea jTextAreaDescription = null; - - private JLabel jLabelSpecification = null; - - private JTextField jTextFieldSpecification = null; - - private JButton jButtonOk = null; - - private JButton jButtonCancel = null; - - private JScrollPane jScrollPaneLicense = null; - - private JScrollPane jScrollPaneDescription = 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; - - private JTextField jTextFieldCopyright = 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, 250, 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(415, 35, 65, 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 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, 280, 320, 20)); - } - return jTextFieldSpecification; - } - - /** - 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 jScrollPaneDescription - - @return javax.swing.JScrollPane jScrollPaneDescription - - **/ - private JScrollPane getJScrollPaneDescription() { - if (jScrollPaneDescription == null) { - jScrollPaneDescription = new JScrollPane(); - jScrollPaneDescription.setBounds(new java.awt.Rectangle(160, 195, 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, 305, 320, 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, 380, 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, 355, 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(160, 330, 320, 20)); - } - return jTextFieldAbstractURL; - } - - /** - This method initializes jTextFieldCopyright - - @return javax.swing.JTextField jTextFieldCopyright - - **/ - private JTextField getJTextFieldCopyright() { - if (jTextFieldCopyright == null) { - jTextFieldCopyright = new JTextField(); - jTextFieldCopyright.setBounds(new java.awt.Rectangle(160,170,320, 20)); - } - return jTextFieldCopyright; - } - - 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.jTextFieldCopyright.setEnabled(!isView); - this.jTextAreaDescription.setEnabled(!isView); - this.jTextFieldSpecification.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.jTextFieldCopyright.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()); - } - if (this.msaHeader.getAbstract() != null) { - this.jTextFieldAbstract.setText(this.msaHeader.getAbstract()); - } - 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(15,330,140,20)); - jLabelURL.setText("URL"); - jLabelCompontentType = new JLabel(); - jLabelCompontentType.setBounds(new java.awt.Rectangle(15, 380, 140, 20)); - jLabelCompontentType.setText("Compontent Type"); - jLabelModuleType = new JLabel(); - jLabelModuleType.setBounds(new java.awt.Rectangle(15, 355, 140, 20)); - jLabelModuleType.setText("Module Type"); - jLabelAbstract = new JLabel(); - jLabelAbstract.setBounds(new java.awt.Rectangle(15, 305, 140, 20)); - jLabelAbstract.setText("Abstract"); - jLabelSpecification = new JLabel(); - jLabelSpecification.setText("Specification"); - jLabelSpecification.setBounds(new java.awt.Rectangle(15, 280, 140, 20)); - jLabelDescription = new JLabel(); - jLabelDescription.setText("Description"); - jLabelDescription.setBounds(new java.awt.Rectangle(15, 195, 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(getJButtonOk(), null); - jContentPane.add(getJButtonCancel(), null); - jContentPane.add(getJScrollPaneLicense(), null); - jContentPane.add(getJScrollPaneDescription(), null); - jContentPane.add(jLabelAbstract, null); - jContentPane.add(getJTextFieldAbstract(), 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, 195)); - jStarLabel7 = new StarLabel(); - jStarLabel7.setLocation(new java.awt.Point(0, 305)); - jStarLabel8 = new StarLabel(); - jStarLabel8.setLocation(new java.awt.Point(0, 355)); - jStarLabel9 = new StarLabel(); - jStarLabel9.setLocation(new java.awt.Point(0, 380)); - - 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); - jContentPane.add(getJTextFieldCopyright(), 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.jTextFieldCopyright.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.jTextFieldCopyright.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.jTextFieldCopyright.getText()); - this.msaHeader.setDescription(this.jTextAreaDescription.getText()); - - if (this.msaHeader.getSpecification() != null) { - this.msaHeader.setSpecification(this.jTextFieldSpecification.getText()); - } else { - - this.msaHeader.setSpecification(this.jTextFieldSpecification.getText()); - } - - if (this.msaHeader.getAbstract() != null) { - this.msaHeader.setAbstract(this.jTextFieldAbstract.getText()); - } else { - - this.msaHeader.setAbstract(this.jTextFieldAbstract.getText()); - } - 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; - } -} diff --git a/Tools/Source/ModuleEditor/src/org/tianocore/packaging/module/ui/MsaLibHeader.java b/Tools/Source/ModuleEditor/src/org/tianocore/packaging/module/ui/MsaLibHeader.java deleted file mode 100644 index 9940f75f47..0000000000 --- a/Tools/Source/ModuleEditor/src/org/tianocore/packaging/module/ui/MsaLibHeader.java +++ /dev/null @@ -1,789 +0,0 @@ -/** @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 JLabel jLabelDescription = null; - - private JTextArea jTextAreaDescription = null; - - private JLabel jLabelSpecification = null; - - private JTextField jTextFieldSpecification = null; - - private JButton jButtonOk = null; - - private JButton jButtonCancel = null; - - private JScrollPane jScrollPaneLicense = null; - - private JScrollPane jScrollPaneDescription = 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; - - private JTextField jTextFieldCopyright = 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, 250, 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(415, 35, 65, 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 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, 280, 320, 20)); - } - return jTextFieldSpecification; - } - - /** - 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 jScrollPaneDescription - - @return javax.swing.JScrollPane jScrollPaneDescription - - **/ - private JScrollPane getJScrollPaneDescription() { - if (jScrollPaneDescription == null) { - jScrollPaneDescription = new JScrollPane(); - jScrollPaneDescription.setBounds(new java.awt.Rectangle(160, 195, 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, 305, 320, 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, 380, 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, 355, 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(160,330,320,20)); - } - return jTextFieldAbstractURL; - } - - /** - * This method initializes jTextFieldCopyright - * - * @return javax.swing.JTextField - */ - private JTextField getJTextFieldCopyright() { - if (jTextFieldCopyright == null) { - jTextFieldCopyright = new JTextField(); - jTextFieldCopyright.setBounds(new java.awt.Rectangle(160,170,320,20)); - } - return jTextFieldCopyright; - } - - 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.jTextFieldCopyright.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()); - } - if (this.msaLibHeader.getAbstract() != null) { - this.jTextFieldAbstract.setText(this.msaLibHeader.getAbstract()); - } - 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.jTextFieldCopyright.setEnabled(!isView); - this.jTextAreaDescription.setEnabled(!isView); - this.jTextFieldSpecification.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(15,330,140,20)); - jLabelURL.setText("URL"); - jLabelCompontentType = new JLabel(); - jLabelCompontentType.setBounds(new java.awt.Rectangle(15, 380, 140, 20)); - jLabelCompontentType.setText("Compontent Type"); - jLabelModuleType = new JLabel(); - jLabelModuleType.setBounds(new java.awt.Rectangle(15, 355, 140, 20)); - jLabelModuleType.setText("Module Type"); - jLabelAbstract = new JLabel(); - jLabelAbstract.setBounds(new java.awt.Rectangle(15, 305, 140, 20)); - jLabelAbstract.setText("Abstract"); - jLabelSpecification = new JLabel(); - jLabelSpecification.setText("Specification"); - jLabelSpecification.setBounds(new java.awt.Rectangle(15, 280, 140, 20)); - jLabelDescription = new JLabel(); - jLabelDescription.setText("Description"); - jLabelDescription.setBounds(new java.awt.Rectangle(15, 195, 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(getJButtonOk(), null); - jContentPane.add(getJButtonCancel(), null); - jContentPane.add(getJScrollPaneLicense(), null); - jContentPane.add(getJScrollPaneDescription(), null); - jContentPane.add(jLabelAbstract, null); - jContentPane.add(getJTextFieldAbstract(), 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, 195)); - jStarLabel7 = new StarLabel(); - jStarLabel7.setLocation(new java.awt.Point(0, 305)); - jStarLabel8 = new StarLabel(); - jStarLabel8.setLocation(new java.awt.Point(0, 355)); - jStarLabel9 = new StarLabel(); - jStarLabel9.setLocation(new java.awt.Point(0, 380)); - - 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); - jContentPane.add(getJTextFieldCopyright(), 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.jTextFieldCopyright.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.jTextFieldCopyright.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.jTextFieldCopyright.getText()); - this.msaLibHeader.setDescription(this.jTextAreaDescription.getText()); - - if (this.msaLibHeader.getSpecification() != null) { - this.msaLibHeader.setSpecification(this.jTextFieldSpecification.getText()); - } else { - this.msaLibHeader.setSpecification(this.jTextFieldSpecification.getText()); - } - - if (this.msaLibHeader.getAbstract() != null) { - this.msaLibHeader.setAbstract(this.jTextFieldAbstract.getText()); - } else { - - this.msaLibHeader.setAbstract(this.jTextFieldAbstract.getText()); - } - - 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; - } - -} diff --git a/Tools/Source/ModuleEditor/src/org/tianocore/packaging/workspace/common/Workspace.java b/Tools/Source/ModuleEditor/src/org/tianocore/packaging/workspace/common/Workspace.java deleted file mode 100644 index fd27f182a6..0000000000 --- a/Tools/Source/ModuleEditor/src/org/tianocore/packaging/workspace/common/Workspace.java +++ /dev/null @@ -1,169 +0,0 @@ -/** @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 java.util.Vector; - -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 PackageDocument xmlPackage = 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; - File db = new File(strFrameworkDbFilePath); - try { - xmlFrameworkDbDoc = (FrameworkDatabaseDocument) XmlObject.Factory.parse(db); - } 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; - } - - /** - Get all package name form the FrameworkDatabase.db file - - @return vPackageName A vector includes all package names - - **/ - public Vector getAllPackageName() { - Vector vPackageName = new Vector(); - openFrameworkDb(); - - for (int index = 0; index < xmlFrameworkDbDoc.getFrameworkDatabase().getPackageList().sizeOfPackageArray(); index++) { - vPackageName.addElement(xmlFrameworkDbDoc.getFrameworkDatabase().getPackageList().getPackageArray(index) - .getPackageNameArray(0).getStringValue()); - } - - return vPackageName; - } -} diff --git a/Tools/Source/PackageEditor/MANIFEST.MF b/Tools/Source/PackageEditor/MANIFEST.MF deleted file mode 100644 index 8a92b4ff87..0000000000 --- a/Tools/Source/PackageEditor/MANIFEST.MF +++ /dev/null @@ -1,3 +0,0 @@ -Manifest-Version: 1.0 -Main-Class: org.tianocore.packaging.PackagingMain - diff --git a/Tools/Source/PackageEditor/build.xml b/Tools/Source/PackageEditor/build.xml deleted file mode 100644 index 982e159a52..0000000000 --- a/Tools/Source/PackageEditor/build.xml +++ /dev/null @@ -1,44 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Tools/Source/PackageEditor/src/org/tianocore/common/Tools.java b/Tools/Source/PackageEditor/src/org/tianocore/common/Tools.java deleted file mode 100644 index 311370d85d..0000000000 --- a/Tools/Source/PackageEditor/src/org/tianocore/common/Tools.java +++ /dev/null @@ -1,159 +0,0 @@ -/** @file - Java class Tools contains common use procedures. - -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.Calendar; -import java.util.Date; -import java.util.UUID; - -/** - This class contains static methods for some common operations - - @since PackageEditor 1.0 -**/ -public class Tools { - - public static final String guidArrayPat = "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}( )*(\\})?"; - public static final String guidRegistryPat = "[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}"; - /** - get current date and time, then return - @return String - **/ - 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 strFolderName - @return boolean - **/ - 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()) { - blnIsDeleted = deleteFolder(aryAllFiles[indexI]); - } else if (aryAllFiles[indexI].isFile()) { - if (!aryAllFiles[indexI].delete()) { - blnIsDeleted = false; - } - } - } - } - if (blnIsDeleted) { - fleFolderName.delete(); - } - return blnIsDeleted; - } - - /** - Get a new GUID - - @return String - **/ - public static String generateUuidString() { - return UUID.randomUUID().toString(); - } - - public static String formatGuidString (String guidNameConv) { - String[] strList; - String guid = ""; - int index = 0; - if (guidNameConv - .matches(Tools.guidRegistryPat)) { - strList = guidNameConv.split("-"); - guid = "0x" + strList[0] + ", "; - guid = guid + "0x" + strList[1] + ", "; - guid = guid + "0x" + strList[2] + ", "; -// guid = guid + "{"; - guid = guid + "0x" + strList[3].substring(0, 2) + ", "; - guid = guid + "0x" + strList[3].substring(2, 4); - - while (index < strList[4].length()) { - guid = guid + ", "; - guid = guid + "0x" + strList[4].substring(index, index + 2); - index = index + 2; - } -// guid = guid + "}"; - return guid; - } - else if (guidNameConv - .matches(Tools.guidArrayPat)) { - strList = guidNameConv.split(","); - - // - // chang ANSI c form to registry form - // - for (int i = 0; i < strList.length; i++){ - strList[i] = strList[i].substring(strList[i].lastIndexOf("x") + 1); - } - if (strList[strList.length - 1].endsWith("}")) { - strList[strList.length -1] = strList[strList.length-1].substring(0, strList[strList.length-1].length()-1); - } - // - //inserting necessary leading zeros - // - - int segLen = strList[0].length(); - if (segLen < 8){ - for (int i = 0; i < 8 - segLen; ++i){ - strList[0] = "0" + strList[0]; - } - } - - segLen = strList[1].length(); - if (segLen < 4){ - for (int i = 0; i < 4 - segLen; ++i){ - strList[1] = "0" + strList[1]; - } - } - segLen = strList[2].length(); - if (segLen < 4){ - for (int i = 0; i < 4 - segLen; ++i){ - strList[2] = "0" + strList[2]; - } - } - for (int i = 3; i < 11; ++i) { - segLen = strList[i].length(); - if (segLen < 2){ - strList[i] = "0" + strList[i]; - } - } - - for (int i = 0; i < 3; i++){ - guid += strList[i] + "-"; - } - - guid += strList[3]; - guid += strList[4] + "-"; - - for (int i = 5; i < strList.length; ++i){ - guid += strList[i]; - } - - - return guid; - } else { - - return "0"; - - } - } -} diff --git a/Tools/Source/PackageEditor/src/org/tianocore/packaging/CreateFdp.java b/Tools/Source/PackageEditor/src/org/tianocore/packaging/CreateFdp.java deleted file mode 100644 index 6988b5ae01..0000000000 --- a/Tools/Source/PackageEditor/src/org/tianocore/packaging/CreateFdp.java +++ /dev/null @@ -1,93 +0,0 @@ -/** @file - Java class CreateFdp is used to create a distributable package containing - FDPManifest.xml file in its root directory. - -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; - -import java.io.*; -import java.util.jar.*; - -/** - This class contains static method create to generate *.fdp format package. - - @since PackageEditor 1.0 -**/ -public class CreateFdp { - - /** - recursively add contents under dir into output package. - - @param dir The directory with files that will be put into package - @param jos Stream used to create output package - @param wkDir The position of source directory - @throws Exception Any exception occurred during this process - **/ - public static void create(File dir, JarOutputStream jos, String wkDir) throws Exception { - - String[] list = dir.list(); - - try { - byte[] buffer = new byte[1024]; - int bytesRead; - - // - // Loop through the file names provided. - // - for (int i = 0; i < list.length; i++) { - - File f = new File(dir, list[i]); - if (f.getName().equals("..")) { - continue; - } - if (f.isDirectory()) { - // - // Call this method recursively for directory - // - CreateFdp.create(f, jos, wkDir); - continue; - } - - try { - // - // Open the file - // - FileInputStream fis = new FileInputStream(f); - - try { - // - // Create a Jar entry and add it, keep relative path only. - // - JarEntry entry = new JarEntry(f.getPath().substring(wkDir.length() + 1)); - jos.putNextEntry(entry); - - // - // Read the file and write it to the Jar. - // - while ((bytesRead = fis.read(buffer)) != -1) { - jos.write(buffer, 0, bytesRead); - } - - System.out.println(entry.getName() + " added."); - } catch (Exception ex) { - System.out.println(ex); - } finally { - fis.close(); - } - } catch (IOException ex) { - System.out.println(ex); - } - } - } finally { - System.out.println(dir.getPath() + " processed."); - } - } -} diff --git a/Tools/Source/PackageEditor/src/org/tianocore/packaging/DbFileContents.java b/Tools/Source/PackageEditor/src/org/tianocore/packaging/DbFileContents.java deleted file mode 100644 index 4f5fb37f71..0000000000 --- a/Tools/Source/PackageEditor/src/org/tianocore/packaging/DbFileContents.java +++ /dev/null @@ -1,315 +0,0 @@ -/** @file - Java class DbFileContents is used to deal with FrameworkDatabase.db file cotents. - -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; - -import java.io.File; -import java.io.IOException; -import java.util.LinkedList; -import java.util.List; -import java.util.ListIterator; -import java.util.Date; -import java.text.SimpleDateFormat; - -import org.apache.xmlbeans.XmlCursor; -import org.apache.xmlbeans.XmlObject; -import org.apache.xmlbeans.XmlOptions; - -import org.tianocore.*; - -/** - This class provides methods for add, remove, query FrameworkDatabase.db file. - - @since PackageEditor 1.0 -**/ -public class DbFileContents { - - /// - /// return values for various conditions. - /// - static final int BASE_PACKAGE_NOT_INSTALLED = 1; - - static final int VERSION_NOT_EQUAL = 2; - - static final int GUID_NOT_EQUAL = 3; - - static final int SAME_ALL = 4; - - private File dbFile = null; - - private FrameworkDatabaseDocument fdd = null; - - private FrameworkDatabaseDocument.FrameworkDatabase fddRoot = null; - - private PackageListDocument.PackageList pkgList = null; - - public DbFileContents() { - super(); - // TODO Auto-generated constructor stub - } - - /** - Parse file f, store its xml data in fdd, store root xml element in fddRoot. - - @param f DB file to parse - **/ - public DbFileContents(File f) { - try { - dbFile = f; - if (fdd == null) { - fdd = ((FrameworkDatabaseDocument) XmlObject.Factory.parse(dbFile)); - } - fddRoot = fdd.getFrameworkDatabase(); - } catch (Exception e) { - System.out.println(e.toString()); - } - } - - /** - Generate the Package element in FrameworkDatabase.db - - @param baseName Base name of package - @param ver Version of package - @param guid GUID of package - @param path Where the package installed - @param installDate When the package installed - **/ - public void genPackage (String baseName, String ver, String guid, String path, String installDate) { - if (getPkgList() == null) { - pkgList = fddRoot.addNewPackageList(); - } - PackageListDocument.PackageList.Package p = pkgList.addNewPackage(); - p.addNewPackageName().setStringValue(baseName); - p.addNewGuid().setStringValue(guid); - p.addVersion(ver); - p.addNewPath().setStringValue(path); - p.addNewInstalledDate().setStringValue(installDate); - } - - /** - Get PackageList - - @return PackageListDocument.PackageList - **/ - public PackageListDocument.PackageList getPkgList() { - if (pkgList == null) { - pkgList = fddRoot.getPackageList(); - } - return pkgList; - } - - /** - Remove PackageList and all elements under it. - **/ - public void removePackageList() { - XmlObject o = fddRoot.getPackageList(); - if (o == null) - return; - XmlCursor cursor = o.newCursor(); - cursor.removeXml(); - } - /** - Get the number of Package elements. - - @return int - **/ - public int getPackageCount () { - return fddRoot.getPackageList().getPackageList().size(); - } - - /** - Get all Package contents into String array - - @param pkg Two dimentional array to store Package info. - **/ - public void getPackageList(String[][] pkg) { - List l = fddRoot.getPackageList().getPackageList(); - int i = 0; - ListIterator li = l.listIterator(); - while (li.hasNext()) { - PackageListDocument.PackageList.Package p = (PackageListDocument.PackageList.Package) li - .next(); - if (p.getPackageNameArray(0)!= null) { - pkg[i][0] = p.getPackageNameArray(0).getStringValue(); - } - - pkg[i][1] = p.getVersionArray(0); - - if (p.getGuidArray(0) != null) { - pkg[i][2] = p.getGuidArray(0).getStringValue(); - } - if (p.getPathArray(0) != null) { - pkg[i][3] = p.getPathArray(0).getStringValue(); - } - if (p.getInstalledDateArray(0) != null) { - pkg[i][4] = p.getInstalledDateArray(0); - } - i++; - } - } - /** - Check whether destDir has been used by one Package - - @param destDir The directory to check. - @retval <1> destDir has been used - @retval <0> destDir has not been used - @return int - **/ - public int checkDir(String destDir) { - List lp = fddRoot.getPackageList().getPackageList(); - - ListIterator lpi = lp.listIterator(); - while (lpi.hasNext()) { - PackageListDocument.PackageList.Package p = (PackageListDocument.PackageList.Package) lpi.next(); - if (p.getPathArray(0).getStringValue().equals(destDir)) { - return 1; - } - } - return 0; - } - - /** - Find the package info. and store results into list of same base name or list - of same version. - - @param base The base name of package - @param version The version of package - @param guid the GUID of package - @param lpSameBase The list to store package info with the same base name with "base" - @param lpSameVersion The list to store package info from lpSameBase and same version - with "version" - @retval <0> No package installed has base name "base" - @retval At least one package installed with "base" but no "version" - @retval At least one package installed with "base" and "version" but no "guid" - @retval One installed package has the same base, version and guid - @return int - **/ - public int query(String base, String version, String guid, - List lpSameBase, - List lpSameVersion) { - - List lp = fddRoot.getPackageList().getPackageList(); - - ListIterator lpi = lp.listIterator(); - while (lpi.hasNext()) { - PackageListDocument.PackageList.Package p = (PackageListDocument.PackageList.Package) lpi.next(); - if (p.getPackageNameArray(0).getStringValue().equals(base)) { - lpSameBase.add(p); - } - } - - if (lpSameBase.size() == 0) { - return 0; - } - - for (ListIterator li = lpSameBase.listIterator(); li.hasNext();) { - PackageListDocument.PackageList.Package p = (PackageListDocument.PackageList.Package) li.next(); - if (p.getVersionArray(0).equals(version)) { - lpSameVersion.add(p); - } - } - - if (lpSameVersion.size() == 0) { - return VERSION_NOT_EQUAL; - } - - for (ListIterator li = lpSameVersion.listIterator(); li.hasNext();) { - PackageListDocument.PackageList.Package p = (PackageListDocument.PackageList.Package) li.next(); - if (!p.getGuidArray(0).getStringValue().equals(guid)) { - return GUID_NOT_EQUAL; - } - } - - return SAME_ALL; - - } - - /** - Update package info (name, version, guid) with installDir, newVer, newGuid. - And update install date with current date. if no package info available, add - a new entry. - - @param name Original base name - @param version Original version - @param guid Original GUID - @param installDir original path - @param newVer Version value of package to be installed - @param newGuid GUID value of package to be installed - @throws IOException Exception during file operation - **/ - public void updatePkgInfo(String name, String version, String guid, String installDir, String newVer, String newGuid) - throws IOException { - List lp = fddRoot.getPackageList().getPackageList(); - - ListIterator lpi = lp.listIterator(); - while (lpi.hasNext()) { - PackageListDocument.PackageList.Package p = (PackageListDocument.PackageList.Package) lpi.next(); - if (p.getPackageNameArray(0).getStringValue().equals(name)) { - if (p.getVersionArray(0).equals(version)) { - if (p.getGuidArray(0).getStringValue().equals(guid)) { - p.setVersionArray(0, newVer); - p.getGuidArray(0).setStringValue(newGuid); - p.getPathArray(0).setStringValue(installDir); - SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm"); - Date date = new Date(); - p.setInstalledDateArray(0, format.format(date)); - saveAs(); - return; - - } - } - } - } - - addNewPkgInfo(name, newVer, newGuid, installDir); - } - - /** - Add one new package entry. - - @param name Package base name - @param version Package version - @param guid Package Guid - @param installDir Package path - @throws IOException Exception during file operation - **/ - public void addNewPkgInfo(String name, String version, String guid, String installDir) throws IOException { - - PackageListDocument.PackageList.Package p = fddRoot.getPackageList().addNewPackage(); - p.addNewPackageName().setStringValue(name); - p.addNewGuid().setStringValue(guid); - p.addNewVersion().setStringValue(version); - p.addNewPath().setStringValue(installDir + "/"); - - SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm"); - Date date = new Date(); - p.addNewInstalledDate().setStringValue(format.format(date)); - saveAs(); - } - - /** - Save the fdd into file with format options - **/ - public void saveAs() { - XmlOptions options = new XmlOptions(); - - options.setCharacterEncoding("UTF-8"); - options.setSavePrettyPrint(); - options.setSavePrettyPrintIndent(2); - try { - fdd.save(dbFile, options); - } catch (IOException e) { - e.printStackTrace(); - } - } - -} diff --git a/Tools/Source/PackageEditor/src/org/tianocore/packaging/ForceInstallPkg.java b/Tools/Source/PackageEditor/src/org/tianocore/packaging/ForceInstallPkg.java deleted file mode 100644 index 4fe88b49fd..0000000000 --- a/Tools/Source/PackageEditor/src/org/tianocore/packaging/ForceInstallPkg.java +++ /dev/null @@ -1,80 +0,0 @@ -/** @file - Java class ForceInstallPkg is used to install a package without DB check. - -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; - -import java.io.*; -import java.util.jar.*; -import org.apache.xmlbeans.XmlException; - -/** - Derived class from FrameworkPkg, installation skipping some checks. - - @since PackageEditor 1.0 -**/ -public class ForceInstallPkg extends FrameworkPkg { - - private String oldVer = null; - - private String oldGuid = null; - - /** - Constructor with parameters - - @param s Package path to be installed - @param d Destination directory - **/ - public ForceInstallPkg(String s, String d) { - super(s, d); - - } - - public void setOldVersion(String v) { - oldVer = v; - } - - public void setOldGuid(String guid) { - oldGuid = guid; - } - - /** - Set jar file to package name to be installed - **/ - protected void pre_install() throws DirSame, IOException { - setJf(new JarFile(getPkg())); - - } - - /** - Update database file contents after install - **/ - protected void post_install() throws IOException, XmlException { - // - // Get package info. from FDPManifest.xml file - // - setJf(new JarFile(getPkg())); - ManifestContents manFile = new ManifestContents(getManifestInputStream(getJf())); - setBName(manFile.getBaseName()); - setPVer(manFile.getVersion()); - setPGuid(manFile.getGuid()); - getJf().close(); - - // - // Add force installed package info. into database file - // - setDbFile(new File(getWkSpace() + System.getProperty("file.separator") + FrameworkPkg.dbConfigFile)); - setDfc(new DbFileContents(new File(getWkSpace() + System.getProperty("file.separator") + dbConfigFile))); - getDfc().updatePkgInfo(getBName(), oldVer, oldGuid, getWkDir().substring(getWkSpace().length() + 1), getPVer(), - getPGuid()); - } - -} diff --git a/Tools/Source/PackageEditor/src/org/tianocore/packaging/FrameworkPkg.java b/Tools/Source/PackageEditor/src/org/tianocore/packaging/FrameworkPkg.java deleted file mode 100644 index b184cf9364..0000000000 --- a/Tools/Source/PackageEditor/src/org/tianocore/packaging/FrameworkPkg.java +++ /dev/null @@ -1,402 +0,0 @@ -/** @file - Java class FrameworkPkg is used to do package related operations. - -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; - -import java.io.*; -import java.util.Enumeration; -import java.util.LinkedList; -import java.util.List; -import java.util.jar.*; -import org.apache.xmlbeans.*; - -import org.tianocore.PackageListDocument; - -/** - This class deals with package related operations - - @since PackageEditor 1.0 -**/ -public class FrameworkPkg { - - private String pkg = null; - - private JarFile jf = null; - - /// - /// where the package will be extracted to - /// - private String wkDir = null; - - private String bName = null; - - private String pVer = null; - - private String pGuid = null; - - /// - /// current WORKSPACE location - /// - private String wkSpace = null; - - private File dbFile = null; - - private DbFileContents dfc = null; - - /// - /// relative path of FrameworkDatabase.db file - /// - final static String dbConfigFile = "Tools" + System.getProperty("file.separator") + "Conf" - + System.getProperty("file.separator") + "FrameworkDatabase.db"; - - - public FrameworkPkg() { - - } - - public FrameworkPkg(String package_name, String work_space) { - pkg = package_name; - wkSpace = work_space; - } - - /** - install package (*.fdp file) to dir - - @param dir Destination directory - @retval <0> Install successfully - @return int - @throws IOException - @throws XmlException Xml file exception - @throws DirSame One package already installed to dir - @throws BasePkgNotInstalled Some package must be installed first - @throws VerNotEqual At least one package info with same base name but version different - @throws GuidNotEqual At least one package info with same base name and version but guid different - @throws SameAll At least one package info with same base name, version and guid same - **/ - public int install(final String dir) throws IOException, XmlException, DirSame, BasePkgNotInstalled, VerNotEqual, - GuidNotEqual, SameAll { - wkDir = dir; - pre_install(); - extract(wkDir); - post_install(); - return 0; - } - - public int uninstall() { - - return 0; - } - - /** - Check package info. against Frameworkdatabase.db - - @throws IOException - @throws XmlException Xml file exception - @throws DirSame One package already installed to dir - @throws BasePkgNotInstalled Some package must be installed first - @throws VerNotEqual At least one package info with same base name but version different - @throws GuidNotEqual At least one package info with same base name and version but guid different - @throws SameAll At least one package info with same base name, version and guid same - **/ - protected void pre_install() throws IOException, XmlException, DirSame, BasePkgNotInstalled, VerNotEqual, - GuidNotEqual, SameAll { - - jf = new JarFile(pkg); - - ManifestContents manFile = new ManifestContents(getManifestInputStream(jf)); - - String baseName = manFile.getBaseName(); - String pkgVersion = manFile.getVersion(); - String pkgGuid = manFile.getGuid(); - bName = baseName; - pVer = pkgVersion; - pGuid = pkgGuid; - - if (dbFile == null) { - dbFile = new File(wkSpace + System.getProperty("file.separator") + dbConfigFile); - } - // - // the db file should exist if base packages have been installed - // - if (!dbFile.exists()) { - throw new BasePkgNotInstalled(); - } - - if (dfc == null) { - dfc = new DbFileContents(dbFile); - } - if (dfc.checkDir(wkDir) != 0) { - throw new DirSame(); - } - - // - // Get database info into lists - // - List lpSameBase = new LinkedList(); - List lpSameVersion = new LinkedList(); - int i = dfc.query(baseName, pkgVersion, pkgGuid, lpSameBase, lpSameVersion); - - // - // throw various kind of exceptions according to query return value. - // - if (i == DbFileContents.VERSION_NOT_EQUAL) { - - jf.close(); - throw new VerNotEqual(lpSameBase); - } - if (i == DbFileContents.GUID_NOT_EQUAL) { - - jf.close(); - throw new GuidNotEqual(lpSameVersion); - } - if (i == DbFileContents.SAME_ALL) { - jf.close(); - throw new SameAll(lpSameVersion); - } - - } - - /** - Add package info into db file. - - @throws IOException - @throws XmlException - **/ - protected void post_install() throws IOException, XmlException { - - dfc.addNewPkgInfo(bName, pVer, pGuid, wkDir.substring(wkSpace.length() + 1)); - - } - - /** - Extract package to dir - - @param dir Destination directory - @throws DirSame - @throws IOException - **/ - private void extract(String dir) throws DirSame, IOException { - - new File(dir).mkdirs(); - dir += System.getProperty("file.separator"); - try { - for (Enumeration e = jf.entries(); e.hasMoreElements();) { - JarEntry je = (JarEntry) e.nextElement(); - - // - // jar entry contains directory only, make these directories - // - if (je.isDirectory()) { - new File(dir + je.getName()).mkdirs(); - continue; - } - - // - // jar entry contains relative path and file name, make relative directories - // under destination dir - // - int index = je.getName().lastIndexOf(System.getProperty("file.separator")); - if (index != -1) { - String dirPath = je.getName().substring(0, index); - new File(dir + dirPath).mkdirs(); - } - - if (je != null) { - // - // Get an input stream for this entry. - // - InputStream entryStream = jf.getInputStream(je); - - try { - // - // Create the output file (clobbering the file if it exists). - // - FileOutputStream file = new FileOutputStream(dir + je.getName()); - - try { - - byte[] buffer = new byte[1024]; - int bytesRead; - // - // Read the entry data and write it to the output file. - // - while ((bytesRead = entryStream.read(buffer)) != -1) { - file.write(buffer, 0, bytesRead); - } - - System.out.println(je.getName() + " extracted."); - } finally { - file.close(); - } - } finally { - entryStream.close(); - } - } - - } - - } finally { - jf.close(); - - } - - } - - public String getBName() { - return bName; - } - - public void setBName(String name) { - bName = name; - } - - public File getDbFile() { - return dbFile; - } - - public void setDbFile(File dbFile) { - this.dbFile = dbFile; - } - - public DbFileContents getDfc() { - return dfc; - } - - public void setDfc(DbFileContents dfc) { - this.dfc = dfc; - } - - public String getPGuid() { - return pGuid; - } - - public void setPGuid(String guid) { - pGuid = guid; - } - - public String getPVer() { - return pVer; - } - - public void setPVer(String ver) { - pVer = ver; - } - - public String getWkDir() { - return wkDir; - } - - public void setWkDir(String wkDir) { - this.wkDir = wkDir; - } - - public String getWkSpace() { - return wkSpace; - } - - public void setWkSpace(String wkSpace) { - this.wkSpace = wkSpace; - } - - public JarFile getJf() { - return jf; - } - - public void setJf(JarFile jf) { - this.jf = jf; - } - - public String getPkg() { - return pkg; - } - - public void setPkg(String pkg) { - this.pkg = pkg; - } - - /** - Get the input stream of FDPManifest.xml file from jar entry - - @param jf The Jar file that contains FDPManifest.xml file - @return InputStream - @throws IOException - **/ - protected InputStream getManifestInputStream(JarFile jf) throws IOException { - JarEntry je = null; - for (Enumeration e = jf.entries(); e.hasMoreElements();) { - je = (JarEntry) e.nextElement(); - if (je.getName().contains("FDPManifest.xml")) - return jf.getInputStream(je); - } - - return null; - } - -} - - -/** - Various Exception classes for what happened when database info and package info - are compared. - - @since PackageEditor 1.0 -**/ -class DirSame extends Exception { - final static long serialVersionUID = 0; -} - -class BasePkgNotInstalled extends Exception { - final static long serialVersionUID = 0; -} - -class VerNotEqual extends Exception { - final static long serialVersionUID = 0; - - //private String version = null; - List lppSameBase = null; - - VerNotEqual(List ver) { - lppSameBase = ver; - } - - public List getVersion() { - return lppSameBase; - } -} - -class GuidNotEqual extends Exception { - final static long serialVersionUID = 0; - - private List lppSameVer = null; - - GuidNotEqual(List ver) { - lppSameVer = ver; - } - - public List getGuid() { - return lppSameVer; - } -} - -class SameAll extends Exception { - final static long serialVersionUID = 0; - - private List version = null; - - SameAll(List ver) { - version = ver; - } - - public List getVersion() { - return version; - } -} diff --git a/Tools/Source/PackageEditor/src/org/tianocore/packaging/GenGuidDialog.java b/Tools/Source/PackageEditor/src/org/tianocore/packaging/GenGuidDialog.java deleted file mode 100644 index c58010a9d7..0000000000 --- a/Tools/Source/PackageEditor/src/org/tianocore/packaging/GenGuidDialog.java +++ /dev/null @@ -1,391 +0,0 @@ -/** @file - Java class GenGuidDialog. - -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; - -import java.awt.BorderLayout; -import java.awt.Dimension; -import java.awt.Toolkit; - -import javax.swing.JPanel; -import javax.swing.JDialog; -import java.awt.GridLayout; - -import javax.swing.JFrame; -import javax.swing.JOptionPane; -import javax.swing.JTextField; -import javax.swing.JLabel; -import javax.swing.JRadioButton; -import javax.swing.ButtonGroup; -import javax.swing.JButton; - -import org.tianocore.common.Tools; - -import java.awt.FlowLayout; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.WindowAdapter; -import java.awt.event.WindowEvent; - -/** - Dialog for GUID generation. - @since PackageEditor 1.0 -**/ -public class GenGuidDialog extends JDialog implements ActionListener{ - - static private JFrame frame; - private JPanel jContentPane = null; - private JPanel jPanel = null; - private JPanel jPanel1 = null; - private JPanel jPanel2 = null; - private JPanel jPanel3 = null; - private JPanel jPanel4 = null; - private JTextField jTextField = null; - private JLabel jLabel = null; - private JRadioButton jRadioButton = null; - private JRadioButton jRadioButton1 = null; - private JButton jButton = null; - private JButton jButton1 = null; - private JButton jButton2 = null; - -// private String guid = null; - - public void actionPerformed(ActionEvent arg0) { - // TODO Auto-generated method stub - if (arg0.getSource() == jButton1){ - String uuid = Tools.generateUuidString(); - if (jRadioButton1.isSelected()) { - jTextField.setText(uuid); - } - else { - //ToDo: transform to comma-sep guid - String s = Tools.formatGuidString(uuid); - if (s.equals("0")) { - JOptionPane.showMessageDialog(frame, "Check GUID Value, it don't conform to the schema."); - return; - } - jTextField.setText(s); - } - } - - if (arg0.getSource() == jRadioButton1){ - - //ToDo: check text field value against RegExp and transform if needed - if (jTextField.getText().matches(Tools.guidRegistryPat)){ - return; - } - if (jTextField.getText().matches(Tools.guidArrayPat)) { - jTextField.setText(Tools.formatGuidString(jTextField.getText())); - return; - } - - JOptionPane.showMessageDialog(frame, "Check GUID Value, it don't conform to the schema."); - - } - - if (arg0.getSource() == jRadioButton){ - - //ToDo: check text field value against RegExp and transform if needed - if (jTextField.getText().matches(Tools.guidArrayPat)){ - return; - } - if (jTextField.getText().matches(Tools.guidRegistryPat)) { - jTextField.setText(Tools.formatGuidString(jTextField.getText())); - return; - } - - JOptionPane.showMessageDialog(frame, "Check GUID Value, it don't conform to the schema."); - - } - - if (arg0.getSource() == jButton2){ -// if (jTextField.getText().matches(Tools.guidArrayPat) -// || jTextField.getText().matches(Tools.guidRegistryPat)){ -// this.setVisible(false); -// } -// else { -// JOptionPane.showMessageDialog(frame, "Incorrect GUID Value Format."); -// } - this.dispose(); - } - - if (arg0.getSource() == jButton){ - this.dispose(); - } - } - - /** - * This method initializes jPanel - * - * @return javax.swing.JPanel - */ - private JPanel getJPanel() { - if (jPanel == null) { - FlowLayout flowLayout = new FlowLayout(); - flowLayout.setVgap(10); - jPanel = new JPanel(); - jPanel.setLayout(flowLayout); - jPanel.setPreferredSize(new java.awt.Dimension(100,30)); - jPanel.add(getJButton1(), null); - jPanel.add(getJButton2(), null); - jPanel.add(getJButton(), null); - } - return jPanel; - } - - /** - * This method initializes jPanel1 - * - * @return javax.swing.JPanel - */ - private JPanel getJPanel1() { - if (jPanel1 == null) { - jPanel1 = new JPanel(); - } - return jPanel1; - } - - /** - * This method initializes jPanel2 - * - * @return javax.swing.JPanel - */ - private JPanel getJPanel2() { - if (jPanel2 == null) { - jPanel2 = new JPanel(); - } - return jPanel2; - } - - /** - * This method initializes jPanel3 - * - * @return javax.swing.JPanel - */ - private JPanel getJPanel3() { - if (jPanel3 == null) { - jPanel3 = new JPanel(); - } - return jPanel3; - } - - /** - * This method initializes jPanel4 - * - * @return javax.swing.JPanel - */ - private JPanel getJPanel4() { - if (jPanel4 == null) { - jLabel = new JLabel(); - jLabel.setText("GUID Value"); - GridLayout gridLayout = new GridLayout(); - gridLayout.setRows(4); - jPanel4 = new JPanel(); - jPanel4.setLayout(gridLayout); - jPanel4.add(getJRadioButton1(), null); - jPanel4.add(getJRadioButton(), null); - jPanel4.add(jLabel, null); - jPanel4.add(getJTextField(), null); - ButtonGroup bg = new ButtonGroup(); - bg.add(jRadioButton1); - bg.add(jRadioButton); - } - return jPanel4; - } - - /** - * This method initializes jTextField - * - * @return javax.swing.JTextField - */ - private JTextField getJTextField() { - if (jTextField == null) { - jTextField = new JTextField(); - jTextField.setHorizontalAlignment(JTextField.LEADING); - jTextField.setPreferredSize(new java.awt.Dimension(100,20)); - } - return jTextField; - } - - /** - * This method initializes jRadioButton - * - * @return javax.swing.JRadioButton - */ - private JRadioButton getJRadioButton() { - if (jRadioButton == null) { - jRadioButton = new JRadioButton(); - jRadioButton.setText("Comma-Seperated Format"); - jRadioButton.addActionListener(this); - } - return jRadioButton; - } - - /** - * This method initializes jRadioButton1 - * - * @return javax.swing.JRadioButton - */ - private JRadioButton getJRadioButton1() { - if (jRadioButton1 == null) { - jRadioButton1 = new JRadioButton(); - jRadioButton1.setText("Registry Format"); - jRadioButton1.setSelected(true); - jRadioButton1.addActionListener(this); - } - return jRadioButton1; - } - - /** - * This method initializes jButton - * - * @return javax.swing.JButton - */ - private JButton getJButton() { - if (jButton == null) { - jButton = new JButton(); - jButton.setPreferredSize(new java.awt.Dimension(80,20)); - jButton.setText("Cancel"); - jButton.addActionListener(this); - } - return jButton; - } - - /** - * This method initializes jButton1 - * - * @return javax.swing.JButton - */ - private JButton getJButton1() { - if (jButton1 == null) { - jButton1 = new JButton(); - jButton1.setPreferredSize(new java.awt.Dimension(80,20)); - jButton1.setHorizontalTextPosition(javax.swing.SwingConstants.LEADING); - jButton1.setText("New"); - jButton1.addActionListener(this); - } - return jButton1; - } - - /** - * This method initializes jButton2 - * - * @return javax.swing.JButton - */ - private JButton getJButton2() { - if (jButton2 == null) { - jButton2 = new JButton(); - jButton2.setPreferredSize(new java.awt.Dimension(80,20)); - jButton2.setText("Ok"); - jButton2.addActionListener(this); - } - return jButton2; - } - - /** - - @param args - **/ - public static void main(String[] args) { - // TODO Auto-generated method stub - new GenGuidDialog().setVisible(true); - } - - public String getGuid(){ - return jTextField.getText(); - } - - public void setGuid(String s){ - jTextField.setText(s); - } - /** - * This is the default constructor - */ - public GenGuidDialog() { - super(); - initialize(); - } - - public GenGuidDialog(ActionListener i){ - super(); - initialize(); - jButton2.addActionListener(i); - this.addWindowListener(new WindowAdapter(){ - - @Override - public void windowActivated(WindowEvent arg0) { - // TODO Auto-generated method stub - super.windowActivated(arg0); - if ((jRadioButton1.isSelected() && jTextField.getText().matches(Tools.guidArrayPat)) - || (jRadioButton.isSelected() && jTextField.getText().matches(Tools.guidRegistryPat))) { - jTextField.setText(Tools.formatGuidString(jTextField.getText())); - } - -// if (!jTextField.getText().matches(Tools.guidArrayPat) || !jTextField.getText().matches(Tools.guidRegistryPat)) { -// JOptionPane.showMessageDialog(frame, "InitVal: Incorrect GUID Value Format."); -// return; -// } - } - - }); - } - - /** - * This method initializes this - * - * @return void - */ - private void initialize() { - this.setSize(466, 157); - this.setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); - this.setModal(true); - this.setTitle("Editing GUID Value"); - this.setContentPane(getJContentPane()); - this.centerWindow(); - } - - /** - * This method initializes jContentPane - * - * @return javax.swing.JPanel - */ - private JPanel getJContentPane() { - if (jContentPane == null) { - jContentPane = new JPanel(); - jContentPane.setLayout(new BorderLayout()); - jContentPane.add(getJPanel(), java.awt.BorderLayout.EAST); - jContentPane.add(getJPanel1(), java.awt.BorderLayout.WEST); - jContentPane.add(getJPanel2(), java.awt.BorderLayout.NORTH); - jContentPane.add(getJPanel3(), java.awt.BorderLayout.SOUTH); - jContentPane.add(getJPanel4(), java.awt.BorderLayout.CENTER); - } - return jContentPane; - } - - /** - Start the window at the center of screen - - **/ - protected void centerWindow(int intWidth, int intHeight) { - Dimension d = Toolkit.getDefaultToolkit().getScreenSize(); - this.setLocation((d.width - intWidth) / 2, (d.height - intHeight) / 2); - } - - /** - Start the window at the center of screen - - **/ - protected void centerWindow() { - centerWindow(this.getSize().width, this.getSize().height); - } - -} // @jve:decl-index=0:visual-constraint="10,10" diff --git a/Tools/Source/PackageEditor/src/org/tianocore/packaging/GuiPkgInstall.java b/Tools/Source/PackageEditor/src/org/tianocore/packaging/GuiPkgInstall.java deleted file mode 100644 index 3e757206f7..0000000000 --- a/Tools/Source/PackageEditor/src/org/tianocore/packaging/GuiPkgInstall.java +++ /dev/null @@ -1,804 +0,0 @@ -/** @file - Java class GuiPkgInstall is GUI for package installation. - -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; - - -import javax.swing.JPanel; -import javax.swing.JFrame; -import javax.swing.JButton; -import javax.swing.JFileChooser; -import javax.swing.JLabel; -import javax.swing.JOptionPane; -import javax.swing.JTextField; - -import java.awt.Dimension; -import java.awt.GridLayout; -import java.awt.Toolkit; - -import java.awt.FlowLayout; -import java.awt.event.MouseEvent; -import java.awt.event.MouseListener; -import java.awt.event.WindowAdapter; -import java.awt.event.WindowEvent; - -import java.awt.ComponentOrientation; -import java.io.File; -import java.util.Hashtable; - -import javax.swing.SwingConstants; -import javax.swing.JProgressBar; -import javax.swing.filechooser.FileFilter; - -import org.apache.xmlbeans.XmlException; - - -/** - GUI for package installation. - - @since PackageEditor 1.0 -**/ -public class GuiPkgInstall extends JFrame implements MouseListener { - - final static long serialVersionUID = 0; - - static JFrame frame; - - /// - /// backup of "this". As we cannot use "this" to refer outer class inside inner class - /// - private JFrame pThis = null; - - private JFileChooser chooser = null; - - private JPanel jPanel = null; - - private JPanel jPanel1 = null; - - private JTextField jTextField = null; - - private JButton jButton = null; - - private JPanel jPanel2 = null; - - private JLabel jLabel1 = null; - - private JPanel jPanel4 = null; - - private JTextField jTextField1 = null; - - private JButton jButton1 = null; - - private JPanel jPanel5 = null; - - private JPanel jPanel6 = null; - - private JPanel jPanel7 = null; - - private JLabel jLabel2 = null; - - private JTextField jTextField2 = null; - - private JButton jButton2 = null; - - private JButton jButton3 = null; - - private JPanel jPanel3 = null; - - private JLabel jLabel = null; - - private JProgressBar jProgressBar = null; - - private JButton jButton4 = null; - - - public GuiPkgInstall() { - super(); - initialize(); - - } - - /** - GUI initialization - **/ - private void initialize() { - this.setSize(new java.awt.Dimension(454, 313)); - this.setContentPane(getJPanel()); - this.setTitle("Package Installation"); - this.addWindowListener(new GuiPkgInstallAdapter(this)); - this.setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE); - this.centerWindow(); - pThis = this; - } - - /** - make window appear center of screen - - @param intWidth - @param intHeight - **/ - protected void centerWindow(int intWidth, int intHeight) { - Dimension d = Toolkit.getDefaultToolkit().getScreenSize(); - this.setLocation((d.width - intWidth) / 2, (d.height - intHeight) / 2); - } - - /** - Start the window at the center of screen - **/ - protected void centerWindow() { - centerWindow(this.getSize().width, this.getSize().height); - } - - /** - This method initializes jPanel - @return javax.swing.JPanel - **/ - private JPanel getJPanel() { - if (jPanel == null) { - GridLayout gridLayout = new GridLayout(); - gridLayout.setRows(7); - gridLayout.setColumns(1); - jPanel = new JPanel(); - jPanel.setLayout(gridLayout); - jPanel.add(getJPanel3(), null); - jPanel.add(getJPanel1(), null); - jPanel.add(getJPanel2(), null); - jPanel.add(getJPanel4(), null); - jPanel.add(getJPanel5(), null); - jPanel.add(getJPanel6(), null); - jPanel.add(getJPanel7(), null); - } - return jPanel; - } - - /** - This method initializes jPanel1 - - @return javax.swing.JPanel - **/ - private JPanel getJPanel1() { - if (jPanel1 == null) { - FlowLayout flowLayout = new FlowLayout(); - flowLayout.setAlignment(java.awt.FlowLayout.LEFT); - jPanel1 = new JPanel(); - jPanel1.setLayout(flowLayout); - jPanel1.add(getJTextField(), null); - jPanel1.add(getJButton(), null); - } - return jPanel1; - } - - /** - This method initializes jTextField - - @return javax.swing.JTextField - **/ - private JTextField getJTextField() { - if (jTextField == null) { - jTextField = new JTextField(); - jTextField.setHorizontalAlignment(javax.swing.JTextField.LEFT); - jTextField.setPreferredSize(new java.awt.Dimension(350, 20)); - } - return jTextField; - } - - /** - This method initializes jButton - - @return javax.swing.JButton - **/ - private JButton getJButton() { - if (jButton == null) { - jButton = new JButton(); - jButton.setHorizontalAlignment(javax.swing.SwingConstants.LEFT); - jButton.setText("Browse"); - jButton.setComponentOrientation(java.awt.ComponentOrientation.LEFT_TO_RIGHT); - jButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); - jButton.setToolTipText("Where is the package?"); - jButton.setFont(new java.awt.Font("Dialog", java.awt.Font.BOLD, 12)); - - jButton.setPreferredSize(new java.awt.Dimension(80, 20)); - jButton.addMouseListener(new java.awt.event.MouseAdapter() { - public void mouseClicked(java.awt.event.MouseEvent e) { - if (chooser == null) { - chooser = new JFileChooser(); - } - // - // disable multi-selection, you can only select one item each time. - // - chooser.setMultiSelectionEnabled(false); - chooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES); - chooser.setFileFilter(new PkgFileFilter("fdp")); - int retval = chooser.showOpenDialog(frame); - if (retval == JFileChooser.APPROVE_OPTION) { - - File theFile = chooser.getSelectedFile(); - jTextField.setText(theFile.getPath()); - // - // set a default directory for installation (WORKSPACE\PackageFileName) - // - if (jTextField1.getText().length() > 0) { - int indexbegin = jTextField.getText().lastIndexOf(System.getProperty("file.separator")); - int indexend = jTextField.getText().lastIndexOf('.'); - if (indexbegin >= 0 && indexend >= 0) { - jTextField2.setText(jTextField1.getText() - + jTextField.getText().substring(indexbegin, indexend)); - } else { - JOptionPane.showMessageDialog(frame, "Wrong Path:" + jTextField.getText()); - } - } - } - } - }); - } - return jButton; - } - - /** - This method initializes jPanel2 - - @return javax.swing.JPanel - **/ - private JPanel getJPanel2() { - if (jPanel2 == null) { - FlowLayout flowLayout1 = new FlowLayout(); - flowLayout1.setAlignment(java.awt.FlowLayout.LEFT); - flowLayout1.setVgap(20); - jLabel1 = new JLabel(); - jLabel1.setText("Enter Workspace Location"); - jLabel1.setComponentOrientation(java.awt.ComponentOrientation.UNKNOWN); - jLabel1.setHorizontalTextPosition(javax.swing.SwingConstants.TRAILING); - jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING); - jPanel2 = new JPanel(); - jPanel2.setLayout(flowLayout1); - jPanel2.add(jLabel1, null); - } - return jPanel2; - } - - /** - This method initializes jPanel4 - - @return javax.swing.JPanel - **/ - private JPanel getJPanel4() { - if (jPanel4 == null) { - FlowLayout flowLayout2 = new FlowLayout(); - flowLayout2.setAlignment(java.awt.FlowLayout.LEFT); - jPanel4 = new JPanel(); - jPanel4.setLayout(flowLayout2); - jPanel4.add(getJTextField1(), null); - jPanel4.add(getJButton1(), null); - } - return jPanel4; - } - - /** - This method initializes jTextField1 - - @return javax.swing.JTextField - **/ - private JTextField getJTextField1() { - if (jTextField1 == null) { - jTextField1 = new JTextField(); - jTextField1.setPreferredSize(new java.awt.Dimension(350, 20)); - - } - // - // default value is WORKSPACE environmental variable value - // - jTextField1.setText(System.getenv("WORKSPACE")); - return jTextField1; - } - - /** - This method initializes jButton1 - - @return javax.swing.JButton - **/ - private JButton getJButton1() { - if (jButton1 == null) { - jButton1 = new JButton(); - jButton1.setComponentOrientation(java.awt.ComponentOrientation.LEFT_TO_RIGHT); - - jButton1.setHorizontalAlignment(javax.swing.SwingConstants.LEADING); - jButton1.setHorizontalTextPosition(javax.swing.SwingConstants.TRAILING); - jButton1.setText("Browse"); - jButton1.setPreferredSize(new java.awt.Dimension(80, 20)); - jButton1.addMouseListener(new java.awt.event.MouseAdapter() { - public void mouseClicked(java.awt.event.MouseEvent e) { - if (chooser == null) { - chooser = new JFileChooser(); - } - // - // only directories can be selected for workspace location. - // - chooser.setMultiSelectionEnabled(false); - chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); - - int retval = chooser.showOpenDialog(frame); - if (retval == JFileChooser.APPROVE_OPTION) { - - File theFile = chooser.getSelectedFile(); - jTextField1.setText(theFile.getPath()); - // - // set a default directory for installation (WORKSPACE\PackageFileName) - // - if (jTextField.getText().length() > 0) { - int indexbegin = jTextField.getText().lastIndexOf(System.getProperty("file.separator")); - int indexend = jTextField.getText().lastIndexOf('.'); - if (indexbegin >= 0 && indexend >= 0) { - jTextField2.setText(jTextField1.getText() - + jTextField.getText().substring(indexbegin, indexend)); - } else { - JOptionPane.showMessageDialog(frame, "Wrong Path:" + jTextField.getText()); - } - } - } - - } - }); - } - return jButton1; - } - - /** - This method initializes jButton4 - - @return javax.swing.JButton - **/ - private JButton getJButton4() { - if (jButton4 == null) { - jButton4 = new JButton(); - jButton4.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT); - - jButton4.setHorizontalAlignment(SwingConstants.LEADING); - jButton4.setHorizontalTextPosition(SwingConstants.TRAILING); - jButton4.setText("Browse"); - jButton4.setPreferredSize(new Dimension(80, 20)); - jButton4.addMouseListener(new java.awt.event.MouseAdapter() { - public void mouseClicked(java.awt.event.MouseEvent e) { - JFileChooser chooser = new JFileChooser(jTextField1.getText()); - - chooser.setMultiSelectionEnabled(false); - chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); - - int retval = chooser.showOpenDialog(frame); - if (retval == JFileChooser.APPROVE_OPTION) { - // - // specify installation directory from file chooser - // - File theFile = chooser.getSelectedFile(); - jTextField2.setText(theFile.getPath()); - - } - } - }); - - } - return jButton4; - } - /** - This method initializes jPanel5 - - @return javax.swing.JPanel - **/ - private JPanel getJPanel5() { - if (jPanel5 == null) { - FlowLayout flowLayout3 = new FlowLayout(); - flowLayout3.setAlignment(java.awt.FlowLayout.LEFT); - flowLayout3.setVgap(20); - jLabel2 = new JLabel(); - jLabel2.setComponentOrientation(java.awt.ComponentOrientation.UNKNOWN); - jLabel2.setHorizontalTextPosition(javax.swing.SwingConstants.TRAILING); - jLabel2.setText("Enter Installation Location Within Workspace"); - jLabel2.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING); - jPanel5 = new JPanel(); - jPanel5.setLayout(flowLayout3); - jPanel5.add(jLabel2, null); - } - return jPanel5; - } - - /** - This method initializes jPanel6 - - @return javax.swing.JPanel - **/ - private JPanel getJPanel6() { - if (jPanel6 == null) { - FlowLayout flowLayout4 = new FlowLayout(); - flowLayout4.setAlignment(java.awt.FlowLayout.LEFT); - jPanel6 = new JPanel(); - jPanel6.setLayout(flowLayout4); - jPanel6.add(getJTextField2(), null); - jPanel6.add(getJButton4(), null); - } - return jPanel6; - } - - /** - This method initializes jPanel7 - - @return javax.swing.JPanel - **/ - private JPanel getJPanel7() { - if (jPanel7 == null) { - FlowLayout flowLayout5 = new FlowLayout(); - flowLayout5.setAlignment(java.awt.FlowLayout.RIGHT); - jPanel7 = new JPanel(); - jPanel7.setLayout(flowLayout5); - jPanel7.add(getJProgressBar(), null); - jPanel7.add(getJButton2(), null); - jPanel7.add(getJButton3(), null); - } - return jPanel7; - } - - /** - This method initializes jTextField2 - - @return javax.swing.JTextField - **/ - private JTextField getJTextField2() { - if (jTextField2 == null) { - jTextField2 = new JTextField(); - jTextField2.setPreferredSize(new java.awt.Dimension(350, 20)); - } - return jTextField2; - } - - /** - This method initializes jButton2 - - @return javax.swing.JButton - **/ - private JButton getJButton2() { - if (jButton2 == null) { - jButton2 = new JButton(); - jButton2.setPreferredSize(new java.awt.Dimension(80, 20)); - jButton2.setText("Ok"); - jButton2.addMouseListener(new java.awt.event.MouseAdapter() { - public void mouseClicked(java.awt.event.MouseEvent e) { - try { - // - // The installation directory must under workspace directory - // - locationcheck(jTextField.getText(), jTextField1.getText(), jTextField2.getText()); - } catch (Exception ee) { - JOptionPane.showMessageDialog(frame, "Package Location Error!"); - return; - } - - try { - // - // create a new FrameworkPkg object with user-selected package, current workspace location. - // install the package to dest dir from jTextField2 - // - int i = new FrameworkPkg(jTextField.getText(), jTextField1.getText()) - .install(jTextField2 - .getText()); - // - // the package is installed smoothly - // - if (i == 0) { - JOptionPane.showMessageDialog(frame, "Package" + jTextField.getText() - + " Installed Successfully!"); - } - } catch (BasePkgNotInstalled bpni) { - // - // exception no base package installed - // - JOptionPane - .showMessageDialog(frame, - "The Edk package needs to be installed before installing any other packages."); - } catch (VerNotEqual vne) { - // - // show modal GUI PkgInstallTypeChooser with user selected package name, - // current workspace location and the list of package info with same base name - // - ModalFrameUtil.showAsModal(new PkgInstallTypeChooser(jTextField.getText(), - jTextField1.getText(), vne.getVersion()), - pThis); - - } catch (GuidNotEqual gne) { - // - // show modal GUI PkgInstallTypeChooser with user selected package name, - // current workspace location and the list of package info with same base name and version - // - ModalFrameUtil.showAsModal(new PkgInstallTypeChooser(jTextField.getText(), - jTextField1.getText(), gne.getGuid()), - pThis); - - } catch (SameAll sa) { - // - // the package with same (base, version, guid) already exists. confirm user action. - // quit or replace the original info. (So only one package info entry in db file that may be triple same) - // - int retVal = JOptionPane - .showConfirmDialog( - frame, - "Package already exists. Would you like to replace it?", - "Package Installation", JOptionPane.YES_NO_OPTION); - if (retVal == JOptionPane.YES_OPTION) { - String installDir = sa.getVersion().listIterator().next().getPathArray(0).getStringValue(); - try { - ForceInstallPkg f = new ForceInstallPkg(jTextField.getText(), jTextField1.getText()); - // - // Get old packag info to meet the calling parameter layout of DbFileContents.updatePkgInfo - // ForceInstallPkg will call it after installation to update package info. - // - f.setOldVersion(sa.getVersion().listIterator().next().getVersionArray(0)); - f.setOldGuid(sa.getVersion().listIterator().next().getGuidArray(0).getStringValue()); - int i = f.install(jTextField1.getText() + System.getProperty("file.separator") + installDir); - if (i == 0) { - JOptionPane.showMessageDialog(frame, "Package" + jTextField.getText() - + " Installed Successfully!"); - } - } catch (Exception sae) { - System.out.println(sae.toString()); - JOptionPane.showMessageDialog(frame, "Extraction Error!"); - } - } - return; - } catch (XmlException xmle) { - System.out.println(xmle.toString()); - JOptionPane.showMessageDialog(frame, "Package Format Error!"); - } catch (DirSame ds) { - // - // You cannot install different packages into the same directory. - // - System.out.println(ds.toString()); - JOptionPane.showMessageDialog(frame, - "Another Package Exists There, Please Select Another Directory!"); - } catch (Exception ext) { - System.out.println(ext.toString()); - JOptionPane.showMessageDialog(frame, "Extraction Error!"); - } - } - }); - } - return jButton2; - } - - /** - * This method initializes jButton3 - * - * @return javax.swing.JButton - */ - private JButton getJButton3() { - if (jButton3 == null) { - jButton3 = new JButton(); - jButton3.setPreferredSize(new java.awt.Dimension(80, 20)); - jButton3.setText("Cancel"); - jButton3.addMouseListener(this); - } - return jButton3; - - } - - /** - This method initializes jPanel3 - - @return javax.swing.JPanel - */ - private JPanel getJPanel3() { - if (jPanel3 == null) { - jLabel = new JLabel(); - jLabel.setComponentOrientation(ComponentOrientation.UNKNOWN); - jLabel.setHorizontalTextPosition(SwingConstants.TRAILING); - jLabel.setText("Enter Package Location"); - jLabel.setHorizontalAlignment(SwingConstants.TRAILING); - FlowLayout flowLayout6 = new FlowLayout(); - flowLayout6.setVgap(20); - flowLayout6.setAlignment(FlowLayout.LEFT); - jPanel3 = new JPanel(); - jPanel3.setLayout(flowLayout6); - jPanel3.add(jLabel, null); - } - return jPanel3; - } - - /** - check user input validity - - @param s package path - @param s1 workspace path - @param s2 installation path - @throws Exception - **/ - private void locationcheck(String s, String s1, String s2) throws Exception { - if (new File(s).isFile() == false) - throw new Exception(); - if (new File(s1).isDirectory() == false) - throw new Exception(); - if (s2.startsWith(s1) == false) - throw new Exception(); - } - - - public void mouseClicked(MouseEvent arg0) { - // TODO Auto-generated method stub - int retVal = JOptionPane.showConfirmDialog(frame, "Are you sure to exit?", "Quit", JOptionPane.YES_NO_OPTION); - if (retVal == JOptionPane.YES_OPTION) { - this.dispose(); - } - return; - } - - 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 - - } - - /** - This method initializes jProgressBar - - @return javax.swing.JProgressBar - **/ - private JProgressBar getJProgressBar() { - if (jProgressBar == null) { - jProgressBar = new JProgressBar(); - jProgressBar.setComponentOrientation(java.awt.ComponentOrientation.LEFT_TO_RIGHT); - jProgressBar.setVisible(false); - } - return jProgressBar; - } - - - -} // @jve:decl-index=0:visual-constraint="24,82" - -/** -Derived from WindowAdapter, Event adapter for windowClosing event - -@since PackageEditor 1.0 -**/ -class GuiPkgInstallAdapter extends WindowAdapter { - - private JFrame frame = null; - - GuiPkgInstallAdapter(JFrame f) { - super(); - frame = f; - } - - /* (non-Javadoc) - * @see java.awt.event.WindowAdapter#windowClosing(java.awt.event.WindowEvent) - */ - @Override - public void windowClosing(WindowEvent arg0) { - // TODO Auto-generated method stub - super.windowClosing(arg0); - int retVal = JOptionPane.showConfirmDialog(frame, "Are you sure to exit?", "Quit", - JOptionPane.YES_NO_OPTION); - if (retVal == JOptionPane.YES_OPTION) { - frame.dispose(); - } - - } - -} - -/** - Filter out some specific type of file - - @since PackageEditor 1.0 -**/ -class PkgFileFilter extends FileFilter { - - /// - /// hash table used to store filter info. - /// - private Hashtable filters = null; - - - public PkgFileFilter() { - this.filters = new Hashtable(); - } - - /** - Create filter and add extension to hash table - - @param extension file extension string (e.g. "exe") - **/ - public PkgFileFilter(String extension) { - this(); - if(extension!=null) { - addExtension(extension); - } - - } - - public PkgFileFilter(String[] fileFilters) { - this(); - int i = 0; - while (i < fileFilters.length) { - // add filters one by one - addExtension(fileFilters[i]); - i++; - } - - } - - - /* (non-Javadoc) - * @see javax.swing.filechooser.FileFilter#accept(java.io.File) - */ - public boolean accept(File f) { - if (f != null) { - if (f.isDirectory()) { - return true; - } - - if (getExtension(f) != null && filters.get(getExtension(f)) != null) { - return true; - } - } - return false; - } - - - /** - Get the extension string of file - - @param f target file - @return String - **/ - public String getExtension(File f) { - if (f != null) { - int i = f.getName().lastIndexOf('.'); - if (i>0 && i(5); - } - filters.put(ext.toLowerCase(), "ext"); - - } - - /* (non-Javadoc) - * @see javax.swing.filechooser.FileFilter#getDescription() - */ - public String getDescription() { - return null; - } - -} - diff --git a/Tools/Source/PackageEditor/src/org/tianocore/packaging/GuiPkgUninstall.java b/Tools/Source/PackageEditor/src/org/tianocore/packaging/GuiPkgUninstall.java deleted file mode 100644 index 667f65bf29..0000000000 --- a/Tools/Source/PackageEditor/src/org/tianocore/packaging/GuiPkgUninstall.java +++ /dev/null @@ -1,370 +0,0 @@ -/** @file - Java class GuiPkgUninstall is GUI for package installation. - -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; - -import javax.swing.JPanel; -import javax.swing.JFrame; -import java.awt.FlowLayout; -//import java.awt.GridLayout; -import javax.swing.JLabel; -import javax.swing.JTextField; -import java.awt.Dimension; -import javax.swing.JButton; -import java.awt.ComponentOrientation; -import java.awt.Font; -import java.awt.Toolkit; -import java.io.File; - -import javax.swing.JFileChooser; -import javax.swing.JOptionPane; -import javax.swing.SwingConstants; -import javax.swing.JList; -import javax.swing.JTextPane; -import javax.swing.JScrollPane; -import javax.swing.JTable; -import javax.swing.table.DefaultTableModel; - -/** - GUI for package uninstallation. - - @since PackageEditor 1.0 -**/ -public class GuiPkgUninstall extends JFrame { - - final static long serialVersionUID = 0; - - static JFrame frame; - - private JPanel jPanel = null; - - private JLabel jLabel = null; - - private JTextField jTextField = null; - - private JButton jButton = null; - - private JLabel jLabel1 = null; - - private JPanel jPanel1 = null; - - private JButton jButton1 = null; - - private JButton jButton2 = null; - - private JScrollPane jScrollPane = null; - - private JTable jTable = null; - - private JButton jButton3 = null; - - private PkgRemoveTableModel model = null; - - private DbFileContents dfc = null; - - private JFrame pThis = null; - - - public GuiPkgUninstall() { - super(); - initialize(); - } - - - private void initialize() { - this.setSize(481, 404); - this.setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); - this.setContentPane(getJPanel()); - this.setTitle("Package Uninstallation"); - this.centerWindow(); - pThis = this; - } - - /** - Start the window at the center of screen - - **/ - protected void centerWindow(int intWidth, int intHeight) { - Dimension d = Toolkit.getDefaultToolkit().getScreenSize(); - this.setLocation((d.width - intWidth) / 2, (d.height - intHeight) / 2); - } - - /** - Start the window at the center of screen - - **/ - protected void centerWindow() { - centerWindow(this.getSize().width, this.getSize().height); - } - - /** - initialize table contents from db file - - @param f FrameworkDatabase.db file under workspace - **/ - protected void loadDB(File f) { - if (!f.exists()) { - JOptionPane.showMessageDialog(frame, - "No FrameworkDatabase.db File!"); - return; - } - dfc = new DbFileContents(f); - if (dfc.getPackageCount() == 0) { - return; - } - // - // Get package list info. and add them one by one into table - // - String[][] saa = new String[dfc.getPackageCount()][5]; - dfc.getPackageList(saa); - int i = 0; - while (i < saa.length) { - model.addRow(saa[i]); - i++; - } - - } - /** - save package info. from table to db file - **/ - protected void save() { - dfc.removePackageList(); - int rowCount = jTable.getRowCount(); - int i = 0; - while (i < rowCount) { - - dfc.genPackage(jTable.getValueAt(i, 0).toString(), jTable.getValueAt(i, 1).toString(), - jTable.getValueAt(i, 2).toString(), jTable.getValueAt(i, 3).toString(), - jTable.getValueAt(i, 4).toString()); - i++; - } - dfc.saveAs(); - } - - private JPanel getJPanel() { - if (jPanel == null) { - jLabel1 = new JLabel(); - jLabel1.setBounds(new java.awt.Rectangle(20, 83, 141, 16)); - jLabel1.setText(" Packages Installed"); - jLabel = new JLabel(); - jLabel.setBounds(new java.awt.Rectangle(17, 16, 171, 16)); - jLabel.setText(" Enter Workspace Location"); - jPanel = new JPanel(); - jPanel.setLayout(null); - jPanel.add(jLabel, null); - jPanel.add(getJTextField(), null); - jPanel.add(getJButton(), null); - jPanel.add(jLabel1, null); - jPanel.add(getJPanel1(), null); - jPanel.add(getJScrollPane(), null); - } - return jPanel; - } - - /** - This method initializes jTextField - - @return javax.swing.JTextField - **/ - private JTextField getJTextField() { - if (jTextField == null) { - jTextField = new JTextField(); - jTextField.setBounds(new java.awt.Rectangle(16, 41, 350, 20)); - jTextField.setHorizontalAlignment(JTextField.LEFT); - jTextField.setEditable(false); - jTextField.setText(System.getenv("WORKSPACE")); - jTextField.setPreferredSize(new Dimension(350, 20)); - } - return jTextField; - } - - /** - This method initializes jButton - - @return javax.swing.JButton - **/ - private JButton getJButton() { - if (jButton == null) { - jButton = new JButton(); - jButton.setBounds(new java.awt.Rectangle(372,40,78,20)); - jButton.setFont(new Font("Dialog", Font.BOLD, 12)); - jButton.setPreferredSize(new Dimension(80, 20)); - jButton.setToolTipText("Where is the package?"); - jButton.setHorizontalAlignment(SwingConstants.LEFT); - jButton.setHorizontalTextPosition(SwingConstants.CENTER); - jButton.setText("Browse"); - jButton.addMouseListener(new java.awt.event.MouseAdapter() { - public void mouseClicked(java.awt.event.MouseEvent e) { - // - // user can select another workspace directory - // - JFileChooser chooser = new JFileChooser(); - chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); - chooser.setMultiSelectionEnabled(false); - int retval = chooser.showOpenDialog(frame); - if (retval == JFileChooser.APPROVE_OPTION) { - // - // update table when user selects a new workspace directory - // - jTextField.setText(chooser.getSelectedFile().getPath()); - File f = new File(chooser.getSelectedFile(), FrameworkPkg.dbConfigFile); - loadDB(f); - } - } - }); - } - return jButton; - } - - /** - This method initializes jPanel1 - - @return javax.swing.JPanel - **/ - private JPanel getJPanel1() { - if (jPanel1 == null) { - FlowLayout flowLayout = new FlowLayout(); - flowLayout.setAlignment(java.awt.FlowLayout.LEFT); - flowLayout.setHgap(20); - jPanel1 = new JPanel(); - jPanel1.setLayout(flowLayout); - jPanel1.setBounds(new java.awt.Rectangle(133,310,318,53)); - jPanel1.add(getJButton3(), null); - jPanel1.add(getJButton1(), null); - jPanel1.add(getJButton2(), null); - } - return jPanel1; - } - - /** - This method initializes jButton1 - - @return javax.swing.JButton - **/ - private JButton getJButton1() { - if (jButton1 == null) { - jButton1 = new JButton(); - jButton1.setPreferredSize(new java.awt.Dimension(85, 20)); - jButton1.setText("Ok"); - jButton1.setHorizontalTextPosition(javax.swing.SwingConstants.LEFT); - jButton1.setEnabled(true); - jButton1.addMouseListener(new java.awt.event.MouseAdapter() { - public void mouseClicked(java.awt.event.MouseEvent e) { - if (dfc != null) { - // - // save package info. to file before exit - // - save(); - } - pThis.dispose(); - } - }); - } - return jButton1; - } - - /** - This method initializes jButton2 - - @return javax.swing.JButton - **/ - private JButton getJButton2() { - if (jButton2 == null) { - jButton2 = new JButton(); - jButton2.setPreferredSize(new java.awt.Dimension(85, 20)); - jButton2.setText("Cancel"); - jButton2.addMouseListener(new java.awt.event.MouseAdapter() { - public void mouseClicked(java.awt.event.MouseEvent e) { - pThis.dispose(); - } - }); - } - return jButton2; - } - - /** - This method initializes jScrollPane - - @return javax.swing.JScrollPane - **/ - private JScrollPane getJScrollPane() { - if (jScrollPane == null) { - jScrollPane = new JScrollPane(); - jScrollPane.setBounds(new java.awt.Rectangle(20,108,431,194)); - jScrollPane.setViewportView(getJTable()); - } - return jScrollPane; - } - - /** - This method initializes jTable - - @return javax.swing.JTable - **/ - private JTable getJTable() { - if (jTable == null) { - model = new PkgRemoveTableModel(); - jTable = new JTable(model); - jTable.setRowHeight(20); - jTable.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION); - jTable.setRowSelectionAllowed(true); - model.addColumn("PackageName"); - model.addColumn("Version"); - model.addColumn("GUID"); - model.addColumn("Path"); - model.addColumn("InstallDate"); - File f = new File(jTextField.getText(), FrameworkPkg.dbConfigFile); - loadDB(f); - } - return jTable; - } - - /** - This method initializes jButton3 - - @return javax.swing.JButton - **/ - private JButton getJButton3() { - if (jButton3 == null) { - jButton3 = new JButton(); - jButton3.setText("Remove"); - jButton3.setPreferredSize(new java.awt.Dimension(85,20)); - jButton3.addMouseListener(new java.awt.event.MouseAdapter() { - public void mouseClicked(java.awt.event.MouseEvent e) { - if (model != null){ - int index = jTable.getSelectedRow(); - if (index > -1) { - model.removeRow(index); - } - } - } - }); - } - return jButton3; - } - -} // @jve:decl-index=0:visual-constraint="10,10" - -/** - Derived table model which disables table edit - - @since PackageEditor 1.0 -**/ -class PkgRemoveTableModel extends DefaultTableModel { - PkgRemoveTableModel() { - super(); - } - - public boolean isCellEditable (int row, int col) { - return false; - } -} diff --git a/Tools/Source/PackageEditor/src/org/tianocore/packaging/GuidEditor.java b/Tools/Source/PackageEditor/src/org/tianocore/packaging/GuidEditor.java deleted file mode 100644 index 3057f17bab..0000000000 --- a/Tools/Source/PackageEditor/src/org/tianocore/packaging/GuidEditor.java +++ /dev/null @@ -1,92 +0,0 @@ -/** @file - Java class GuidEditor. - -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; - -import java.awt.Component; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; - -import javax.swing.AbstractCellEditor; -import javax.swing.JButton; -import javax.swing.JFrame; -import javax.swing.JOptionPane; -import javax.swing.JTable; -import javax.swing.table.TableCellEditor; - -import org.tianocore.common.Tools; - -/** - Editor for table cell with GUID value. - @since PackageEditor 1.0 - **/ -public class GuidEditor extends AbstractCellEditor implements TableCellEditor, ActionListener { - - String currentGuid; - JButton button; - static JFrame frame; - GenGuidDialog dialog; - protected static final String EDIT = "edit"; - - public GuidEditor() { - - button = new JButton(); - button.setActionCommand(EDIT); - button.addActionListener(this); - button.setBorderPainted(false); - - - dialog = new GenGuidDialog(this); - - } - - /* (non-Javadoc) - * @see javax.swing.table.TableCellEditor#getTableCellEditorComponent(javax.swing.JTable, java.lang.Object, boolean, int, int) - */ - public Component getTableCellEditorComponent(JTable arg0, Object arg1, boolean arg2, int arg3, int arg4) { - // TODO Auto-generated method stub - currentGuid = (String)arg1; - return button; - } - - /* (non-Javadoc) - * @see javax.swing.CellEditor#getCellEditorValue() - */ - public Object getCellEditorValue() { - // TODO Auto-generated method stub - return currentGuid; - } - - /* (non-Javadoc) - * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent) - */ - public void actionPerformed(ActionEvent arg0) { - // TODO Auto-generated method stub - if (EDIT.equals(arg0.getActionCommand())) { - //The user has clicked the cell, so - //bring up the dialog. - button.setText(currentGuid); - dialog.setGuid(currentGuid); - dialog.setVisible(true); - - //Make the renderer reappear. - fireEditingStopped(); - } - else { //User pressed dialog's "OK" button. - currentGuid = dialog.getGuid(); - - } - - } - -} diff --git a/Tools/Source/PackageEditor/src/org/tianocore/packaging/ManifestContents.java b/Tools/Source/PackageEditor/src/org/tianocore/packaging/ManifestContents.java deleted file mode 100644 index 7bebc627a2..0000000000 --- a/Tools/Source/PackageEditor/src/org/tianocore/packaging/ManifestContents.java +++ /dev/null @@ -1,74 +0,0 @@ -/** @file - Java class ManifestContents is used to deal with FDPManifest.xml file related - operations. - -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; - -import org.apache.xmlbeans.XmlException; - -import org.tianocore.*; -import java.io.*; - -/** - This class operates on FDPManifest.xml file - - @since PackageEditor 1.0 -**/ -public class ManifestContents { - - /// - /// it is more convenient to get input stream from Jar entry of to-be-installed package file. - /// so i use InputStream instead of File - /// - private InputStream manIs = null; - - FrameworkDevPkgManifestDocument manDoc = null; - - HeaderDocument hdr = null; - - FrameworkDevPkgManifestDocument.FrameworkDevPkgManifest manRoot = null; - - public ManifestContents(InputStream fis) throws XmlException, IOException { - - manIs = fis; - manDoc = FrameworkDevPkgManifestDocument.Factory.parse(manIs); - manRoot = manDoc.getFrameworkDevPkgManifest(); - - } - - /** - Get package name from manifest file header. - - @return String - **/ - public String getBaseName() { - return manRoot.getHeader().getPackageName().getStringValue(); - } - - /** - Get package version from manifest file header. - - @return String - **/ - public String getVersion() { - return manRoot.getHeader().getVersion(); - } - - /** - Get package GUID from manifest file header. - - @return String - **/ - public String getGuid() { - return manRoot.getHeader().getGuid().getStringValue(); - } -} diff --git a/Tools/Source/PackageEditor/src/org/tianocore/packaging/ModalFrameUtil.java b/Tools/Source/PackageEditor/src/org/tianocore/packaging/ModalFrameUtil.java deleted file mode 100644 index a748a82f76..0000000000 --- a/Tools/Source/PackageEditor/src/org/tianocore/packaging/ModalFrameUtil.java +++ /dev/null @@ -1,107 +0,0 @@ -/** @file - Java class ModalFrameUtil is used to show modal frame. - -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; - -import javax.swing.*; -import java.awt.*; -import java.awt.event.WindowAdapter; -import java.awt.event.WindowEvent; -import java.lang.reflect.InvocationHandler; -import java.lang.reflect.Method; -import java.lang.reflect.Proxy; - -/** - This class is used to show modal frame. - - @since PackageEditor 1.0 -**/ -public class ModalFrameUtil { - /** - Invocation handler for event threads - - @since PackageEditor 1.0 - **/ - static class EventPump implements InvocationHandler { - Frame frame; - - public EventPump(Frame frame) { - this.frame = frame; - } - - /** - Invocation handler invoked by Method.invoke - **/ - public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { - // - // return frame showing status for Conditional.evaluate() - // - return frame.isShowing() ? Boolean.TRUE : Boolean.FALSE; - } - - public void start() throws Exception { - Class clazz = Class.forName("java.awt.Conditional"); - // - // Conditional proxy instance will invoke "this" InvocationHandler.invoke when calling its methods - // - Object conditional = Proxy.newProxyInstance(clazz.getClassLoader(), new Class[] { clazz }, this); - // - // EventDisaptchThread.pumpEvents will be called under Conditional "conditional" - // - Method pumpMethod = Class.forName("java.awt.EventDispatchThread").getDeclaredMethod("pumpEvents", - new Class[] { clazz }); - pumpMethod.setAccessible(true); - // - // pumpEvents when conditional.evaluate() == true (frame.isShowing() in EventPump.invoke) - // - pumpMethod.invoke(Thread.currentThread(), new Object[] { conditional }); - } - } - - /** - Show modal frame, return only when frame closed. - - @param frame Frame to be modal - @param owner Parent Frame - **/ - public static void showAsModal(final Frame frame, final Frame owner) { - frame.addWindowListener(new WindowAdapter() { - public void windowOpened(WindowEvent e) { - owner.setEnabled(false); - } - - public void windowClosed(WindowEvent e) { - owner.setEnabled(true); - owner.setVisible(true); - owner.removeWindowListener(this); - } - }); - - owner.addWindowListener(new WindowAdapter() { - public void windowActivated(WindowEvent e) { - if (frame.isShowing()) { - frame.setExtendedState(JFrame.NORMAL); - frame.toFront(); - } else { - owner.removeWindowListener(this); - } - } - }); - - frame.setVisible(true); - try { - new EventPump(frame).start(); - } catch (Throwable throwable) { - throw new RuntimeException(throwable); - } - } -} diff --git a/Tools/Source/PackageEditor/src/org/tianocore/packaging/PackageAction.java b/Tools/Source/PackageEditor/src/org/tianocore/packaging/PackageAction.java deleted file mode 100644 index 03e1607626..0000000000 --- a/Tools/Source/PackageEditor/src/org/tianocore/packaging/PackageAction.java +++ /dev/null @@ -1,352 +0,0 @@ -/** @file - Java class PackageAction is GUI for create spd 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; - -import java.awt.BorderLayout; -import java.awt.Dimension; -import java.awt.Toolkit; - -import javax.swing.JFileChooser; -import javax.swing.JOptionPane; -import javax.swing.JPanel; -import javax.swing.JFrame; -import java.awt.GridLayout; -import java.io.File; - -import javax.swing.JButton; -import javax.swing.filechooser.FileFilter; - -/** - GUI for create spd file - - @since PackageEditor 1.0 -**/ -public class PackageAction extends JFrame { - - static JFrame frame; - - private JPanel jContentPane = null; - - private JButton jButton = null; - - private JButton jButton1 = null; - - private JButton jButton2 = null; - - private JButton jButton3 = null; - - private JButton jButton4 = null; - - private JButton jButton5 = null; - - private JButton jButton6 = null; - - private JButton jButton7 = null; - - /// - /// SpdFileContents object passed from main - /// - private SpdFileContents sfc = null; - - private JFrame pThis = null; // @jve:decl-index=0:visual-constraint="304,10" - - private JButton jButton8 = null; - - private JButton jButton9 = null; // @jve:decl-index=0:visual-constraint="116,388" - - /** - This is the default constructor - **/ - public PackageAction(SpdFileContents sfc) { - super(); - initialize(); - this.sfc = sfc; - } - - /** - This method initializes this - - @return void - **/ - private void initialize() { - this.setSize(305, 385); - this.setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); - this.setContentPane(getJContentPane()); - this.setTitle("Please Choose an Action"); - this.centerWindow(); - this.pThis = this; - - } - - /** - Start the window at the center of screen - - **/ - protected void centerWindow(int intWidth, int intHeight) { - Dimension d = Toolkit.getDefaultToolkit().getScreenSize(); - this.setLocation((d.width - intWidth) / 2, (d.height - intHeight) / 2); - } - - /** - Start the window at the center of screen - - **/ - protected void centerWindow() { - centerWindow(this.getSize().width, this.getSize().height); - } - - /** - This method initializes jContentPane - - @return javax.swing.JPanel - **/ - private JPanel getJContentPane() { - if (jContentPane == null) { - GridLayout gridLayout = new GridLayout(); - gridLayout.setRows(10); - gridLayout.setColumns(1); - jContentPane = new JPanel(); - jContentPane.setPreferredSize(new java.awt.Dimension(200,300)); - jContentPane.setLayout(gridLayout); - jContentPane.add(getJButton8(), null); - jContentPane.add(getJButton7(), null); - jContentPane.add(getJButton6(), null); - jContentPane.add(getJButton5(), null); - jContentPane.add(getJButton4(), null); - jContentPane.add(getJButton3(), null); - jContentPane.add(getJButton2(), null); - jContentPane.add(getJButton1(), null); - jContentPane.add(getJButton(), null); - jContentPane.add(getJButton9(), null); - } - return jContentPane; - } - - /** - This method initializes jButton - - @return javax.swing.JButton - **/ - private JButton getJButton() { - final FileFilter filter = new PkgFileFilter("spd"); - - if (jButton == null) { - jButton = new JButton(); - jButton.setText("Save"); - jButton.addMouseListener(new java.awt.event.MouseAdapter() { - public void mouseClicked(java.awt.event.MouseEvent e) { - // - // save sfc contents to file - // - JFileChooser chooser = new JFileChooser(PackagingMain.dirForNewSpd); - chooser.setMultiSelectionEnabled(false); - chooser.setFileFilter(filter); - - int retval = chooser.showSaveDialog(frame); - if (retval == JFileChooser.APPROVE_OPTION) { - try { - File theFile = chooser.getSelectedFile(); - if (theFile.exists()) { - int retVal = JOptionPane.showConfirmDialog(frame, "Are you sure to replace the exising one?", "File Exists", - JOptionPane.YES_NO_OPTION); - if (retVal == JOptionPane.NO_OPTION) { - return; - } - } - sfc.saveAs(theFile); - - } catch (Exception ee) { - System.out.println(ee.toString()); - } -// pThis.dispose(); - } - - } - }); - } - return jButton; - } - - /** - This method initializes jButton1 - - @return javax.swing.JButton - **/ - private JButton getJButton1() { - if (jButton1 == null) { - jButton1 = new JButton(); - jButton1.setText("Add PCD Information"); - jButton1.addMouseListener(new java.awt.event.MouseAdapter() { - public void mouseClicked(java.awt.event.MouseEvent e) { - // - // Add PCD frame show modal - // - ModalFrameUtil.showAsModal(new PackagePCD(sfc), pThis); - } - }); - } - return jButton1; - } - - /** - This method initializes jButton2 - - @return javax.swing.JButton - **/ - private JButton getJButton2() { - if (jButton2 == null) { - jButton2 = new JButton(); - jButton2.setText("Add PPI Declarations"); - jButton2.addMouseListener(new java.awt.event.MouseAdapter() { - public void mouseClicked(java.awt.event.MouseEvent e) { - // - // Add PPI frame show modal - // - ModalFrameUtil.showAsModal(new PackagePpi(sfc), pThis); - } - }); - } - return jButton2; - } - - /** - This method initializes jButton3 - - @return javax.swing.JButton - **/ - private JButton getJButton3() { - if (jButton3 == null) { - jButton3 = new JButton(); - jButton3.setText("Add Protocol Declarations"); - jButton3.addMouseListener(new java.awt.event.MouseAdapter() { - public void mouseClicked(java.awt.event.MouseEvent e) { - ModalFrameUtil.showAsModal(new PackageProtocols(sfc), pThis); - } - }); - } - return jButton3; - } - - /** - This method initializes jButton4 - - @return javax.swing.JButton - **/ - private JButton getJButton4() { - if (jButton4 == null) { - jButton4 = new JButton(); - jButton4.setText("Add GUID Declarations"); - jButton4.addMouseListener(new java.awt.event.MouseAdapter() { - public void mouseClicked(java.awt.event.MouseEvent e) { - ModalFrameUtil.showAsModal(new PackageGuids(sfc), pThis); - } - }); - } - return jButton4; - } - - /** - This method initializes jButton5 - - @return javax.swing.JButton - **/ - private JButton getJButton5() { - if (jButton5 == null) { - jButton5 = new JButton(); - jButton5.setText("Add Package Headers"); - jButton5.addMouseListener(new java.awt.event.MouseAdapter() { - public void mouseClicked(java.awt.event.MouseEvent e) { - ModalFrameUtil.showAsModal(new PackagePkgHeader(sfc), pThis); - } - }); - } - return jButton5; - } - - /** - This method initializes jButton6 - - @return javax.swing.JButton - **/ - private JButton getJButton6() { - if (jButton6 == null) { - jButton6 = new JButton(); - jButton6.setText("Add MSA Files"); - jButton6.addMouseListener(new java.awt.event.MouseAdapter() { - public void mouseClicked(java.awt.event.MouseEvent e) { - ModalFrameUtil.showAsModal(new PackageMsaFile(sfc), pThis); - } - }); - } - return jButton6; - } - - /** - This method initializes jButton7 - - @return javax.swing.JButton - **/ - private JButton getJButton7() { - if (jButton7 == null) { - jButton7 = new JButton(); - jButton7.setText("Add Library Classes"); - jButton7.addMouseListener(new java.awt.event.MouseAdapter() { - public void mouseClicked(java.awt.event.MouseEvent e) { - ModalFrameUtil.showAsModal(new PackageLibraryClass(sfc), pThis); - } - }); - } - return jButton7; - } - - /** - This method initializes jButton8 - - @return javax.swing.JButton - **/ - private JButton getJButton8() { - if (jButton8 == null) { - jButton8 = new JButton(); - jButton8.setText("Add SPD Header"); - jButton8.addMouseListener(new java.awt.event.MouseAdapter() { - public void mouseClicked(java.awt.event.MouseEvent e) { - ModalFrameUtil.showAsModal(new PackageNew(sfc), pThis); - } - }); - } - return jButton8; - } - - /** - This method initializes jButton9 - - @return javax.swing.JButton - **/ - private JButton getJButton9() { - if (jButton9 == null) { - jButton9 = new JButton(); - jButton9.setText("Done"); - jButton9.addMouseListener(new java.awt.event.MouseAdapter() { - public void mouseClicked(java.awt.event.MouseEvent e) { - // - // quit current frame - // - pThis.dispose(); - - } - }); - } - return jButton9; - } - -} // @jve:decl-index=0:visual-constraint="104,41" diff --git a/Tools/Source/PackageEditor/src/org/tianocore/packaging/PackageGuids.java b/Tools/Source/PackageEditor/src/org/tianocore/packaging/PackageGuids.java deleted file mode 100644 index 6562a2772f..0000000000 --- a/Tools/Source/PackageEditor/src/org/tianocore/packaging/PackageGuids.java +++ /dev/null @@ -1,354 +0,0 @@ -/** @file - Java class PackageGuids is GUI for create GUID elements of spd 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; - -import java.awt.Dimension; -import java.awt.Toolkit; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; - -import javax.swing.DefaultListModel; -import javax.swing.JPanel; -import javax.swing.JLabel; -import javax.swing.JTextField; -import javax.swing.JRadioButton; -import javax.swing.JComboBox; -import javax.swing.JButton; -import javax.swing.JFrame; - -import javax.swing.JScrollPane; -import javax.swing.JList; - -import org.tianocore.common.Tools; -import org.tianocore.packaging.common.ui.StarLabel; - -/** - GUI for create GUID elements of spd file - - @since PackageEditor 1.0 -**/ -public class PackageGuids extends JFrame implements ActionListener { - - private SpdFileContents sfc = null; - - private static String separator = "::"; - - private JPanel jContentPane = null; - - private JLabel jLabelC_Name = null; - - private JTextField jTextFieldC_Name = null; - - private JLabel jLabelGuidValue = null; - - private JTextField jTextFieldGuidValue = null; - - private JLabel jLabelHelpText = null; - - private JTextField jTextFieldName = null; - - private JLabel jLabelEnableFeature = null; - - private JRadioButton jRadioButtonEnableFeature = null; - - private JRadioButton jRadioButtonDisableFeature = null; - - private JButton jButtonOk = null; - - private JButton jButtonCancel = null; - - private JButton jButtonGenerateGuid = null; - - private StarLabel starLabel = null; - - private StarLabel starLabel1 = null; - - /** - This method initializes this - - **/ - private void initialize() { - this.setTitle("Guid Declarations"); - this.setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); - - } - - /** - This method initializes jTextFieldC_Name - - @return javax.swing.JTextField - **/ - 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 - **/ - private JTextField getJTextFieldGuidValsue() { - if (jTextFieldGuidValue == null) { - jTextFieldGuidValue = new JTextField(); - jTextFieldGuidValue.setBounds(new java.awt.Rectangle(160, 35, 240, 20)); - } - return jTextFieldGuidValue; - } - - /** - This method initializes jTextFieldName - - @return javax.swing.JTextField - **/ - private JTextField getJTextFieldName() { - if (jTextFieldName == null) { - jTextFieldName = new JTextField(); - jTextFieldName.setBounds(new java.awt.Rectangle(160, 70, 320, 20)); - } - return jTextFieldName; - } - - /** - This method initializes jRadioButtonEnableFeature - - @return javax.swing.JRadioButton - **/ - private JRadioButton getJRadioButtonEnableFeature() { - if (jRadioButtonEnableFeature == null) { - jRadioButtonEnableFeature = new JRadioButton(); - jRadioButtonEnableFeature.setText("Enable"); - jRadioButtonEnableFeature.setBounds(new java.awt.Rectangle(160, 104, 90, 20)); - jRadioButtonEnableFeature.setEnabled(false); - jRadioButtonEnableFeature.setSelected(true); - } - return jRadioButtonEnableFeature; - } - - /** - This method initializes jRadioButtonDisableFeature - - @return javax.swing.JRadioButton - **/ - private JRadioButton getJRadioButtonDisableFeature() { - if (jRadioButtonDisableFeature == null) { - jRadioButtonDisableFeature = new JRadioButton(); - jRadioButtonDisableFeature.setText("Disable"); - jRadioButtonDisableFeature.setEnabled(false); - jRadioButtonDisableFeature.setBounds(new java.awt.Rectangle(250, 104, 90, 20)); - } - return jRadioButtonDisableFeature; - } - - /** - This method initializes jButtonOk - - @return javax.swing.JButton - **/ - private JButton getJButtonOk() { - if (jButtonOk == null) { - jButtonOk = new JButton(); - jButtonOk.setText("OK"); - jButtonOk.setBounds(new java.awt.Rectangle(300, 240, 75, 20)); - jButtonOk.addActionListener(this); - } - return jButtonOk; - } - - /** - This method initializes jButtonCancel - - @return javax.swing.JButton - **/ - private JButton getJButtonCancel() { - if (jButtonCancel == null) { - jButtonCancel = new JButton(); - jButtonCancel.setText("Cancel"); - jButtonCancel.setBounds(new java.awt.Rectangle(390, 240, 74, 20)); - jButtonCancel.addActionListener(this); - } - return jButtonCancel; - } - - /** - This method initializes jButtonGenerateGuid - - @return javax.swing.JButton - **/ - 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 is the default constructor - **/ - public PackageGuids(SpdFileContents sfc) { - super(); - initialize(); - init(); - this.setVisible(true); - this.sfc = sfc; - } - - /** - Start the window at the center of screen - - **/ - protected void centerWindow(int intWidth, int intHeight) { - Dimension d = Toolkit.getDefaultToolkit().getScreenSize(); - this.setLocation((d.width - intWidth) / 2, (d.height - intHeight) / 2); - } - - /** - Start the window at the center of screen - - **/ - protected void centerWindow() { - centerWindow(this.getSize().width, this.getSize().height); - } - - /** - This method initializes this - - @return void - **/ - private void init() { - this.setSize(500, 300); - this.setContentPane(getJContentPane()); - this.setTitle("Add Guids"); - this.centerWindow(); - initFrame(); - } - - /** - This method initializes jContentPane - - @return javax.swing.JPanel - **/ - private JPanel getJContentPane() { - if (jContentPane == null) { - starLabel1 = new StarLabel(); - starLabel1.setBounds(new java.awt.Rectangle(5, 34, 10, 20)); - starLabel = new StarLabel(); - starLabel.setBounds(new java.awt.Rectangle(6, 10, 10, 20)); - jLabelEnableFeature = new JLabel(); - jLabelEnableFeature.setText("Enable Feature"); - jLabelEnableFeature.setEnabled(false); - jLabelEnableFeature.setBounds(new java.awt.Rectangle(15, 104, 140, 20)); - jLabelHelpText = new JLabel(); - jLabelHelpText.setText("Name"); - jLabelHelpText.setBounds(new java.awt.Rectangle(15, 70, 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(jLabelHelpText, null); - jContentPane.add(getJTextFieldName(), null); - jContentPane.add(jLabelEnableFeature, null); - jContentPane.add(getJRadioButtonEnableFeature(), null); - jContentPane.add(getJRadioButtonDisableFeature(), null); - jContentPane.add(getJButtonOk(), null); - jContentPane.add(getJButtonCancel(), null); - jContentPane.add(getJButtonGenerateGuid(), null); - - jContentPane.add(starLabel, null); - jContentPane.add(starLabel1, null); - - initFrame(); - - } - return jContentPane; - } - - /** - This method initializes events groups and usage type - - **/ - private void initFrame() { - - } - - public void actionPerformed(ActionEvent arg0) { - // - // save and exit - // - if (arg0.getSource() == jButtonOk) { - - this.save(); - this.dispose(); - } - // - // exit - // - if (arg0.getSource() == jButtonCancel) { - this.dispose(); - } - // - // generate a new GUID - // - if (arg0.getSource() == jButtonGenerateGuid) { - jTextFieldGuidValue.setText(Tools.generateUuidString()); - } - - 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); - } - } - } - - /** - Add GUID entry to SpdFileContents object with element values from jTextFields* - **/ - protected void save() { - try { - String strName = jTextFieldName.getText(); - String strCName = jTextFieldC_Name.getText(); - String strGuid = jTextFieldGuidValue.getText(); - sfc.genSpdGuidDeclarations(strName, strCName, strGuid, null); - - } catch (Exception e) { - System.out.println(e.toString()); - } - } -} // @jve:decl-index=0:visual-constraint="10,10" diff --git a/Tools/Source/PackageEditor/src/org/tianocore/packaging/PackageLibraryClass.java b/Tools/Source/PackageEditor/src/org/tianocore/packaging/PackageLibraryClass.java deleted file mode 100644 index bf8c70b3df..0000000000 --- a/Tools/Source/PackageEditor/src/org/tianocore/packaging/PackageLibraryClass.java +++ /dev/null @@ -1,560 +0,0 @@ -/** @file - Java class PackageLibraryClass is GUI for create library definition elements of spd 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; - -import java.awt.BorderLayout; -import java.awt.Dimension; -import java.awt.Toolkit; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.io.File; -import java.util.Vector; - -import javax.swing.DefaultListModel; -import javax.swing.JFileChooser; -import javax.swing.JOptionPane; -import javax.swing.JPanel; -import javax.swing.JRadioButton; -import javax.swing.JTextField; -import javax.swing.JComboBox; -import javax.swing.JLabel; -import javax.swing.JList; -import javax.swing.JScrollPane; -import javax.swing.JButton; -import javax.swing.JFrame; - -/** - GUI for create library definition elements of spd file. - - @since PackageEditor 1.0 -**/ -public class PackageLibraryClass extends JFrame implements ActionListener { - static JFrame frame; - - private static String Separator = "::"; - - private DefaultListModel listItem = new DefaultListModel(); - - private SpdFileContents sfc = 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; - - private JLabel jLabel = null; - - private JTextField jTextField = null; - - private JButton jButtonBrowse = null; - - /** - This method initializes this - - **/ - private void initialize() { - this.setTitle("Library Declarations"); - this.setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); - - } - - /** - This method initializes jRadioButtonAdd - - @return javax.swing.JRadioButton - **/ - private JRadioButton getJRadioButtonAdd() { - if (jRadioButtonAdd == null) { - jRadioButtonAdd = new JRadioButton(); - jRadioButtonAdd.setBounds(new java.awt.Rectangle(10, 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 - **/ - private JRadioButton getJRadioButtonSelect() { - if (jRadioButtonSelect == null) { - jRadioButtonSelect = new JRadioButton(); - jRadioButtonSelect.setBounds(new java.awt.Rectangle(10, 10, 205, 20)); - jRadioButtonSelect.setText("Select Existing Library Class"); - jRadioButtonSelect.addActionListener(this); - jRadioButtonSelect.setSelected(true); - } - return jRadioButtonSelect; - } - - /** - This method initializes jTextFieldAdd - - @return javax.swing.JTextField - **/ - 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 - **/ - 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 - **/ - private JComboBox getJComboBoxUsage() { - if (jComboBoxUsage == null) { - jComboBoxUsage = new JComboBox(); - jComboBoxUsage.setBounds(new java.awt.Rectangle(220, 60, 260, 20)); - jComboBoxUsage.setEnabled(false); - } - return jComboBoxUsage; - } - - /** - This method initializes jScrollPane - - @return javax.swing.JScrollPane - **/ - private JScrollPane getJScrollPane() { - if (jScrollPane == null) { - jScrollPane = new JScrollPane(); - jScrollPane.setBounds(new java.awt.Rectangle(10,149,350,146)); - jScrollPane.setViewportView(getJListLibraryClassDefinitions()); - } - return jScrollPane; - } - - /** - This method initializes jListLibraryClassDefinitions - - @return javax.swing.JList - **/ - private JList getJListLibraryClassDefinitions() { - if (jListLibraryClassDefinitions == null) { - jListLibraryClassDefinitions = new JList(listItem); - } - return jListLibraryClassDefinitions; - } - - /** - This method initializes jButtonAdd - - @return javax.swing.JButton - **/ - private JButton getJButtonAdd() { - if (jButtonAdd == null) { - jButtonAdd = new JButton(); - jButtonAdd.setBounds(new java.awt.Rectangle(375,152,90,20)); - jButtonAdd.setText("Add"); - jButtonAdd.addActionListener(this); - } - return jButtonAdd; - } - - /** - This method initializes jButtonRemove - - @return javax.swing.JButton - **/ - private JButton getJButtonRemove() { - if (jButtonRemove == null) { - jButtonRemove = new JButton(); - jButtonRemove.setBounds(new java.awt.Rectangle(375, 230, 90, 20)); - jButtonRemove.setText("Remove"); - jButtonRemove.addActionListener(this); - } - return jButtonRemove; - } - - /** - This method initializes jButtonRemoveAll - - @return javax.swing.JButton - **/ - private JButton getJButtonClearAll() { - if (jButtonClearAll == null) { - jButtonClearAll = new JButton(); - jButtonClearAll.setBounds(new java.awt.Rectangle(375, 260, 90, 20)); - jButtonClearAll.setText("Clear All"); - jButtonClearAll.addActionListener(this); - } - return jButtonClearAll; - } - - /** - This method initializes jButtonCancel - - @return javax.swing.JButton - **/ - 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 jButton - - @return javax.swing.JButton - **/ - 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; - } - - /** - This is the default constructor - **/ - public PackageLibraryClass(SpdFileContents sfc) { - super(); - initialize(); - init(); - this.sfc = sfc; - } - - /** - Start the window at the center of screen - - **/ - protected void centerWindow(int intWidth, int intHeight) { - Dimension d = Toolkit.getDefaultToolkit().getScreenSize(); - this.setLocation((d.width - intWidth) / 2, (d.height - intHeight) / 2); - } - - /** - Start the window at the center of screen - - **/ - protected void centerWindow() { - centerWindow(this.getSize().width, this.getSize().height); - } - - /** - This method initializes this - - @return void - **/ - private void init() { - this.setContentPane(getJContentPane()); - this.setTitle("Library Class Declarations"); - this.setBounds(new java.awt.Rectangle(0, 0, 500, 370)); - this.centerWindow(); - initFrame(); - } - - /** - This method initializes jContentPane - - @return javax.swing.JPanel - **/ - private JPanel getJContentPane() { - if (jContentPane == null) { - jLabel = new JLabel(); - jLabel.setBounds(new java.awt.Rectangle(14, 85, 201, 22)); - jLabel.setText("Include Header for Selected Class"); - jLabelUsage = new JLabel(); - jLabelUsage.setBounds(new java.awt.Rectangle(15, 60, 200, 20)); - jLabelUsage.setEnabled(false); - 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); - jContentPane.add(jLabel, null); - jContentPane.add(getJTextField(), null); - jContentPane.add(getJButtonBrowse(), null); - } - return jContentPane; - } - - /** - fill ComboBoxes with pre-defined contents - **/ - 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) - */ - public void actionPerformed(ActionEvent arg0) { - if (arg0.getSource() == jButtonOk) { - this.save(); - this.dispose(); - - } - if (arg0.getSource() == jButtonCancel) { - this.dispose(); - } - - if (arg0.getSource() == jButtonAdd) { - String strLibClass = ""; - if (jRadioButtonAdd.isSelected()) { - strLibClass = jTextFieldAdd.getText(); - } - if (jRadioButtonSelect.isSelected()) { - strLibClass = jComboBoxSelect.getSelectedItem().toString(); - } - listItem.addElement(jTextField.getText().replace('\\', '/') + this.Separator + strLibClass); - } - // - // remove selected line - // - 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(); - } - - 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); - } - } - } - - /** - Add contents in list to sfc - **/ - protected void save() { - try { - int intLibraryCount = listItem.getSize(); - - if (intLibraryCount > 0) { - - for (int index = 0; index < intLibraryCount; index++) { - String strAll = listItem.get(index).toString(); - String strInclude = strAll.substring(0, strAll.indexOf(Separator)); - String strLibraryClass = strAll.substring(strAll.indexOf(Separator) + Separator.length()); - sfc.genSpdLibClassDeclarations(strLibraryClass, null, strInclude, null, null, null, null, null, - null, null); - } - } else { - - } - - } catch (Exception e) { - System.out.println(e.toString()); - } - } - - /** - This method initializes jTextField - - @return javax.swing.JTextField - **/ - private JTextField getJTextField() { - if (jTextField == null) { - jTextField = new JTextField(); - jTextField.setBounds(new java.awt.Rectangle(12,112,346,21)); - } - return jTextField; - } - - /** - This method initializes jButtonBrowse - - @return javax.swing.JButton - **/ - private JButton getJButtonBrowse() { - if (jButtonBrowse == null) { - jButtonBrowse = new JButton(); - jButtonBrowse.setBounds(new java.awt.Rectangle(374,111,92,21)); - jButtonBrowse.setText("Browse"); - jButtonBrowse.setPreferredSize(new java.awt.Dimension(34,20)); - jButtonBrowse.addMouseListener(new java.awt.event.MouseAdapter() { - public void mouseClicked(java.awt.event.MouseEvent e) { - // - // Select files from current workspace - // - JFileChooser chooser = new JFileChooser(System.getenv("WORKSPACE")); - File theFile = null; - String headerDest = null; - - chooser.setMultiSelectionEnabled(false); - chooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES); - int retval = chooser.showOpenDialog(frame); - if (retval == JFileChooser.APPROVE_OPTION) { - - theFile = chooser.getSelectedFile(); - String file = theFile.getPath(); - if (!file.startsWith(System.getenv("WORKSPACE"))) { - JOptionPane.showMessageDialog(frame, "You can only select files in current workspace!"); - return; - } - - - } - else { - return; - } - - if (!theFile.getPath().startsWith(PackagingMain.dirForNewSpd)) { - // - //ToDo: copy elsewhere header file to new pkg dir, prompt user to chooser a location - // - JOptionPane.showMessageDialog(frame, "You must copy header file into current package directory!"); - return; - } - - headerDest = theFile.getPath(); - int fileIndex = headerDest.indexOf(System.getProperty("file.separator"), PackagingMain.dirForNewSpd.length()); - - jTextField.setText(headerDest.substring(fileIndex + 1).replace('\\', '/')); - - } - }); - } - return jButtonBrowse; - } - -} diff --git a/Tools/Source/PackageEditor/src/org/tianocore/packaging/PackageMsaFile.java b/Tools/Source/PackageEditor/src/org/tianocore/packaging/PackageMsaFile.java deleted file mode 100644 index 824c372d53..0000000000 --- a/Tools/Source/PackageEditor/src/org/tianocore/packaging/PackageMsaFile.java +++ /dev/null @@ -1,371 +0,0 @@ -/** @file - Java class PackageMsaFile is GUI for create MsaFile elements of spd 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; - -import java.awt.BorderLayout; -import java.awt.Dimension; -import java.awt.Toolkit; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.io.File; -import java.util.Vector; - -import javax.swing.DefaultListModel; -import javax.swing.JFileChooser; -import javax.swing.JOptionPane; -import javax.swing.JPanel; -import javax.swing.JRadioButton; -import javax.swing.JTextField; -import javax.swing.JComboBox; -import javax.swing.JLabel; -import javax.swing.JList; -import javax.swing.JScrollPane; -import javax.swing.JButton; -import javax.swing.JFrame; -import javax.swing.filechooser.FileFilter; - -/** - GUI for create MsaFile elements of spd file - - @since PackageEditor 1.0 -**/ -public class PackageMsaFile extends JFrame implements ActionListener { - static JFrame frame; - - private DefaultListModel listItem = new DefaultListModel(); - - private SpdFileContents sfc = null; - - private JPanel jContentPane = 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; - - private JLabel jLabel = null; - - private JTextField jTextField = null; - - private JButton jButton = null; - - /** - This method initializes this - - **/ - private void initialize() { - this.setTitle("MSA Files"); - this.setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); - - } - - /** - This method initializes jScrollPane - - @return javax.swing.JScrollPane - **/ - private JScrollPane getJScrollPane() { - if (jScrollPane == null) { - jScrollPane = new JScrollPane(); - jScrollPane.setBounds(new java.awt.Rectangle(10, 85, 350, 210)); - jScrollPane.setViewportView(getJListLibraryClassDefinitions()); - } - return jScrollPane; - } - - /** - This method initializes jListLibraryClassDefinitions - - @return javax.swing.JList - **/ - private JList getJListLibraryClassDefinitions() { - if (jListLibraryClassDefinitions == null) { - jListLibraryClassDefinitions = new JList(listItem); - } - return jListLibraryClassDefinitions; - } - - /** - This method initializes jButtonAdd - - @return javax.swing.JButton - **/ - private JButton getJButtonAdd() { - if (jButtonAdd == null) { - jButtonAdd = new JButton(); - jButtonAdd.setBounds(new java.awt.Rectangle(375, 132, 90, 20)); - jButtonAdd.setText("Add"); - jButtonAdd.addActionListener(this); - } - return jButtonAdd; - } - - /** - This method initializes jButtonRemove - - @return javax.swing.JButton - **/ - private JButton getJButtonRemove() { - if (jButtonRemove == null) { - jButtonRemove = new JButton(); - jButtonRemove.setBounds(new java.awt.Rectangle(375, 230, 90, 20)); - jButtonRemove.setText("Remove"); - jButtonRemove.addActionListener(this); - } - return jButtonRemove; - } - - /** - This method initializes jButtonRemoveAll - - @return javax.swing.JButton - **/ - private JButton getJButtonClearAll() { - if (jButtonClearAll == null) { - jButtonClearAll = new JButton(); - jButtonClearAll.setBounds(new java.awt.Rectangle(375, 260, 90, 20)); - jButtonClearAll.setText("Clear All"); - jButtonClearAll.addActionListener(this); - } - return jButtonClearAll; - } - - /** - This method initializes jButtonCancel - - @return javax.swing.JButton - **/ - 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 jButton - - @return javax.swing.JButton - **/ - 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; - } - - /** - This is the default constructor - **/ - public PackageMsaFile(SpdFileContents sfc) { - super(); - initialize(); - init(); - this.sfc = sfc; - } - - /** - Start the window at the center of screen - - */ - protected void centerWindow(int intWidth, int intHeight) { - Dimension d = Toolkit.getDefaultToolkit().getScreenSize(); - this.setLocation((d.width - intWidth) / 2, (d.height - intHeight) / 2); - } - - /** - Start the window at the center of screen - - **/ - protected void centerWindow() { - centerWindow(this.getSize().width, this.getSize().height); - } - - /** - This method initializes this - - @return void - **/ - private void init() { - this.setContentPane(getJContentPane()); - this.setTitle("Library Class Declarations"); - this.setBounds(new java.awt.Rectangle(0, 0, 500, 370)); - this.centerWindow(); - initFrame(); - } - - /** - This method initializes jContentPane - - @return javax.swing.JPanel - **/ - private JPanel getJContentPane() { - if (jContentPane == null) { - jLabel = new JLabel(); - jLabel.setBounds(new java.awt.Rectangle(11,20,143,22)); - jLabel.setText("Msa File Path and Name"); - jContentPane = new JPanel(); - jContentPane.setLayout(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); - jContentPane.add(jLabel, null); - jContentPane.add(getJTextField(), null); - jContentPane.add(getJButton(), null); - } - return jContentPane; - } - - private void initFrame() { - - } - - public void actionPerformed(ActionEvent arg0) { - if (arg0.getSource() == jButtonOk) { - this.dispose(); - this.save(); - } - if (arg0.getSource() == jButtonCancel) { - this.dispose(); - } - - if (arg0.getSource() == jButtonAdd) { - - listItem.addElement(jTextField.getText()); - } - - 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(); - } - - } - - protected void save() { - try { - int intLibraryCount = listItem.getSize(); - - if (intLibraryCount > 0) { - - for (int index = 0; index < intLibraryCount; index++) { - String strAll = listItem.get(index).toString(); - sfc.genSpdMsaFiles(strAll, null); - } - } else { - - } - - } catch (Exception e) { - System.out.println(e.toString()); - } - } - - /** - This method initializes jTextField - - @return javax.swing.JTextField - **/ - private JTextField getJTextField() { - if (jTextField == null) { - jTextField = new JTextField(); - jTextField.setBounds(new java.awt.Rectangle(11,44,349,21)); - } - return jTextField; - } - - /** - This method initializes jButton - - @return javax.swing.JButton - **/ - private JButton getJButton() { - final FileFilter filter = new PkgFileFilter("msa"); - - if (jButton == null) { - jButton = new JButton(); - jButton.setBounds(new java.awt.Rectangle(377,46,89,20)); - jButton.setText("Browse"); - jButton.setPreferredSize(new java.awt.Dimension(34,20)); - jButton.addMouseListener(new java.awt.event.MouseAdapter() { - public void mouseClicked(java.awt.event.MouseEvent e) { - JFileChooser chooser = new JFileChooser(System.getenv("WORKSPACE")); - File theFile = null; - String msaDest = null; - - chooser.setMultiSelectionEnabled(false); - chooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES); - chooser.setFileFilter(filter); - int retval = chooser.showOpenDialog(frame); - if (retval == JFileChooser.APPROVE_OPTION) { - - theFile = chooser.getSelectedFile(); - String file = theFile.getPath(); - if (!file.startsWith(System.getenv("WORKSPACE"))) { - JOptionPane.showMessageDialog(frame, "You can only select files in current workspace!"); - return; - } - - } - else { - return; - } - - if (!theFile.getPath().startsWith(PackagingMain.dirForNewSpd)) { - // - //ToDo: copy elsewhere msa to new pkg dir, prompt user to chooser a location - // - JOptionPane.showMessageDialog(frame, "You must copy msa file into current package directory!"); - return; - } - - msaDest = theFile.getPath(); - int fileIndex = msaDest.indexOf(System.getProperty("file.separator"), PackagingMain.dirForNewSpd.length()); - - jTextField.setText(msaDest.substring(fileIndex + 1).replace('\\', '/')); - } - }); - } - return jButton; - } - -} diff --git a/Tools/Source/PackageEditor/src/org/tianocore/packaging/PackageNew.java b/Tools/Source/PackageEditor/src/org/tianocore/packaging/PackageNew.java deleted file mode 100644 index 85676a4b84..0000000000 --- a/Tools/Source/PackageEditor/src/org/tianocore/packaging/PackageNew.java +++ /dev/null @@ -1,533 +0,0 @@ -/** @file - Java class PackageNew is the top level GUI for create spd 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; - -import java.awt.Dimension; -import java.awt.Toolkit; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.text.SimpleDateFormat; -import java.util.Date; - -import javax.swing.JFrame; -import javax.swing.JPanel; -import javax.swing.JLabel; -import javax.swing.JTextField; -import javax.swing.JButton; -import javax.swing.JTextArea; -import javax.swing.JScrollPane; -import javax.swing.JComboBox; - -import org.tianocore.common.Tools; -import org.tianocore.packaging.common.ui.StarLabel; - -/** - This class contains GUI components to show various GUIs for creating spd file elements - - @since PackageEditor 1.0 -**/ -public class PackageNew extends JFrame implements ActionListener { - - private JPanel jContentPane = null; // @jve:decl-index=0:visual-constraint="128,4" - - 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 jScrollPaneDescription = null; - - private JLabel jLabelAbstract = null; - - private JTextField jTextFieldAbstract = null; - - private JLabel jLabelModuleType = null; - - private JLabel jLabelCompontentType = null; - - private JComboBox jComboBox1 = 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 JLabel jLabelURL = null; - - private JTextField jTextFieldAbstractURL = null; - - private JLabel jLabel = null; - - private JComboBox jComboBox = null; - - private SpdFileContents sfc = null; - - /** - This method initializes this - - **/ - private void initialize() { - this.setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); - - } - - /** - This method initializes jTextFieldBaseName - - @return javax.swing.JTextField - **/ - 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 - **/ - 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 - **/ - 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 - **/ - 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 - **/ - private JTextArea getJTextAreaLicense() { - if (jTextAreaLicense == null) { - jTextAreaLicense = new JTextArea(); - jTextAreaLicense.setText(""); - jTextAreaLicense.setLineWrap(true); - } - return jTextAreaLicense; - } - - /** - This method initializes jTextAreaCopyright - - @return javax.swing.JTextArea - **/ - private JTextArea getJTextAreaCopyright() { - if (jTextAreaCopyright == null) { - jTextAreaCopyright = new JTextArea(); - jTextAreaCopyright.setLineWrap(true); - jTextAreaCopyright.setBounds(new java.awt.Rectangle(160,172,319,20)); - } - return jTextAreaCopyright; - } - - /** - This method initializes jTextAreaDescription - - @return javax.swing.JTextArea - **/ - private JTextArea getJTextAreaDescription() { - if (jTextAreaDescription == null) { - jTextAreaDescription = new JTextArea(); - jTextAreaDescription.setLineWrap(true); - } - return jTextAreaDescription; - } - - /** - This method initializes jButtonNext - - @return javax.swing.JButton - **/ - private JButton getJButtonOk() { - if (jButtonOk == null) { - jButtonOk = new JButton(); - jButtonOk.setText("OK"); - jButtonOk.setBounds(new java.awt.Rectangle(290, 481, 90, 20)); - jButtonOk.addActionListener(this); - } - return jButtonOk; - } - - /** - This method initializes jButtonCancel - - @return javax.swing.JButton - **/ - private JButton getJButtonCancel() { - if (jButtonCancel == null) { - jButtonCancel = new JButton(); - jButtonCancel.setText("Cancel"); - jButtonCancel.setBounds(new java.awt.Rectangle(390, 481, 90, 20)); - jButtonCancel.addActionListener(this); - } - return jButtonCancel; - } - - /** - This method initializes jScrollPane - - @return javax.swing.JScrollPane - **/ - 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 jScrollPane2 - - @return javax.swing.JScrollPane - **/ - private JScrollPane getJScrollPaneDescription() { - if (jScrollPaneDescription == null) { - jScrollPaneDescription = new JScrollPane(); - jScrollPaneDescription.setBounds(new java.awt.Rectangle(160, 322, 320, 80)); - jScrollPaneDescription.setViewportView(getJTextAreaDescription()); - jScrollPaneDescription.setHorizontalScrollBarPolicy(javax.swing.JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); - } - return jScrollPaneDescription; - } - - /** - This method initializes jTextFieldAbstract - - @return javax.swing.JTextField - **/ - private JTextField getJTextFieldAbstract() { - if (jTextFieldAbstract == null) { - jTextFieldAbstract = new JTextField(); - jTextFieldAbstract.setBounds(new java.awt.Rectangle(159,218,318,70)); - } - return jTextFieldAbstract; - } - - /** - This method initializes jComboBoxCompontentType - - @return javax.swing.JComboBox - **/ - private JComboBox getJComboBox1() { - if (jComboBox1 == null) { - jComboBox1 = new JComboBox(); - jComboBox1.setBounds(new java.awt.Rectangle(160, 465, 91, 20)); - } - return jComboBox1; - } - - /** - This method initializes jComboBoxModuleType - - @return javax.swing.JComboBox - **/ - private JComboBox getJComboBoxModuleType() { - if (jComboBoxModuleType == null) { - jComboBoxModuleType = new JComboBox(); - jComboBoxModuleType.setBounds(new java.awt.Rectangle(160, 440, 91, 20)); - } - return jComboBoxModuleType; - } - - /** - This method initializes jTextFieldAbstractURL - - @return javax.swing.JTextField - **/ - private JTextField getJTextFieldAbstractURL() { - if (jTextFieldAbstractURL == null) { - jTextFieldAbstractURL = new JTextField(); - jTextFieldAbstractURL.setBounds(new java.awt.Rectangle(159, 414, 320, 20)); - } - return jTextFieldAbstractURL; - } - - public PackageNew(SpdFileContents sfc) { - super(); - initialize(); - init(); - this.setVisible(true); - this.sfc = sfc; - - } - - /** - Start the window at the center of screen - - **/ - protected void centerWindow(int intWidth, int intHeight) { - Dimension d = Toolkit.getDefaultToolkit().getScreenSize(); - this.setLocation((d.width - intWidth) / 2, (d.height - intHeight) / 2); - } - - /** - Start the window at the center of screen - - **/ - protected void centerWindow() { - centerWindow(this.getSize().width, this.getSize().height); - } - - /** - This method initializes this - - @return void - **/ - private void init() { - this.setSize(500, 560); - this.setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); - this.setContentPane(getJContentPane()); - this.setTitle("SPD File Header"); - this.centerWindow(); - //this.getRootPane().setDefaultButton(jButtonOk); - initFrame(); - } - - /** - This method initializes jContentPane - - @return javax.swing.JPanel - **/ - private JPanel getJContentPane() { - if (jContentPane == null) { - jLabel = new JLabel(); - jLabel.setBounds(new java.awt.Rectangle(15, 490, 140, 21)); - jLabel.setText("Re-Package"); - jLabelURL = new JLabel(); - jLabelURL.setBounds(new java.awt.Rectangle(16, 414, 25, 20)); - jLabelURL.setText("URL"); - jLabelCompontentType = new JLabel(); - jLabelCompontentType.setBounds(new java.awt.Rectangle(15, 465, 140, 20)); - jLabelCompontentType.setText("Read Only"); - jLabelModuleType = new JLabel(); - jLabelModuleType.setBounds(new java.awt.Rectangle(15, 440, 140, 20)); - jLabelModuleType.setText("Package Type"); - jLabelAbstract = new JLabel(); - jLabelAbstract.setBounds(new java.awt.Rectangle(15,218,140,20)); - jLabelAbstract.setText("Abstract"); - jLabelDescription = new JLabel(); - jLabelDescription.setText("Description"); - jLabelDescription.setBounds(new java.awt.Rectangle(16, 325, 140, 20)); - jLabelCopyright = new JLabel(); - jLabelCopyright.setText("Copyright"); - jLabelCopyright.setBounds(new java.awt.Rectangle(15, 171, 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("Package 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(getJScrollPaneDescription(), null); - jContentPane.add(jLabelAbstract, null); - jContentPane.add(getJTextFieldAbstract(), null); - jContentPane.add(jLabelModuleType, null); - jContentPane.add(jLabelCompontentType, null); - jContentPane.add(getJComboBox1(), 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, 171)); - jStarLabel6 = new StarLabel(); - jStarLabel6.setLocation(new java.awt.Point(1, 325)); - jStarLabel7 = new StarLabel(); - jStarLabel7.setLocation(new java.awt.Point(0,218)); - jStarLabel8 = new StarLabel(); - jStarLabel8.setLocation(new java.awt.Point(0, 440)); - - 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(jLabelURL, null); - jContentPane.add(getJTextFieldAbstractURL(), null); - jContentPane.add(jLabel, null); - jContentPane.add(getJComboBox(), null); - jContentPane.add(getJTextAreaCopyright(), null); - } - return jContentPane; - } - - public void actionPerformed(ActionEvent arg0) { - if (arg0.getSource() == jButtonOk) { - this.save(); - this.dispose(); - } - - if (arg0.getSource() == jButtonCancel) { - this.dispose(); - } - - if (arg0.getSource() == jButtonGenerateGuid) { - jTextFieldGuid.setText(Tools.generateUuidString()); - } - } - - /** - Save all components of Msa Header - if exist, set the value directly - if not exist, new instance first - - **/ - private void save() { - SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm"); - Date date = new Date(); - sfc.genSpdHeader(jTextFieldBaseName.getText(), jTextFieldGuid.getText(), jTextFieldVersion.getText(), - jTextFieldAbstract.getText(), jTextAreaDescription.getText(), jTextAreaCopyright.getText(), - jTextAreaLicense.getText(), format.format(date), format.format(date), - jTextFieldAbstractURL.getText(), jComboBoxModuleType.getSelectedItem().toString(), - jComboBox1.getSelectedItem().toString(), jComboBox.getSelectedItem().toString(), null, null); - } - - /** - This method initializes module type and compontent type - - **/ - private void initFrame() { - jComboBoxModuleType.addItem("SOURCE"); - jComboBoxModuleType.addItem("BINARY"); - jComboBoxModuleType.addItem("MIXED"); - - jComboBox1.addItem("true"); - jComboBox1.addItem("false"); - - jComboBox.addItem("false"); - jComboBox.addItem("true"); - - } - - /** - This method initializes jComboBox - - @return javax.swing.JComboBox - **/ - private JComboBox getJComboBox() { - if (jComboBox == null) { - jComboBox = new JComboBox(); - jComboBox.setBounds(new java.awt.Rectangle(160, 490, 90, 20)); - } - return jComboBox; - } - -} // @jve:decl-index=0:visual-constraint="38,-22" diff --git a/Tools/Source/PackageEditor/src/org/tianocore/packaging/PackagePCD.java b/Tools/Source/PackageEditor/src/org/tianocore/packaging/PackagePCD.java deleted file mode 100644 index 910540c4eb..0000000000 --- a/Tools/Source/PackageEditor/src/org/tianocore/packaging/PackagePCD.java +++ /dev/null @@ -1,321 +0,0 @@ -/** @file - Java class PackagePCD is GUI for create PCD definition elements of spd 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; - -import java.awt.Dimension; -import java.awt.Toolkit; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; - -import javax.swing.ButtonGroup; -import javax.swing.JPanel; -import javax.swing.JRadioButton; -import javax.swing.JLabel; -import javax.swing.JTextField; -import javax.swing.JComboBox; -import javax.swing.JButton; -import javax.swing.JFrame; - -import org.tianocore.common.Tools; -import org.tianocore.packaging.common.ui.StarLabel; - -/** - GUI for create PCD definition elements of spd file - - @since PackageEditor 1.0 -**/ -public class PackagePCD extends JFrame implements ActionListener { - - 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 jLabelDataType = null; - - private JButton jButtonOk = null; - - private JButton jButtonCancel = null; - - private JComboBox jComboBoxDataType = null; - - private JLabel jLabelOverrideID = null; - - private JTextField jTextFieldOverrideID = null; - - private ButtonGroup bg1 = null; - - private ButtonGroup bg2 = null; - - private ButtonGroup bg3 = null; - - private StarLabel jStarLabel2 = null; - - private StarLabel jStarLabel3 = null; - - private SpdFileContents sfc = null; - - private StarLabel jStarLabel = null; - - private StarLabel jStarLabel1 = null; - - /** - This method initializes this - - **/ - private void initialize() { - this.setTitle("PCD Definition"); - this.setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); - - } - - /** - This method initializes jComboBoxItemType - - @return javax.swing.JComboBox - **/ - 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 - **/ - private JTextField getJTextFieldC_Name() { - if (jTextFieldC_Name == null) { - jTextFieldC_Name = new JTextField(); - jTextFieldC_Name.setBounds(new java.awt.Rectangle(160, 60, 320, 20)); - } - return jTextFieldC_Name; - } - - /** - This method initializes jTextFieldToken - - @return javax.swing.JTextField - **/ - private JTextField getJTextFieldToken() { - if (jTextFieldToken == null) { - jTextFieldToken = new JTextField(); - jTextFieldToken.setBounds(new java.awt.Rectangle(160, 135, 320, 20)); - } - return jTextFieldToken; - } - - /** - This method initializes jButtonOk - - @return javax.swing.JButton - **/ - private JButton getJButtonOk() { - if (jButtonOk == null) { - jButtonOk = new JButton(); - jButtonOk.setText("OK"); - jButtonOk.setBounds(new java.awt.Rectangle(279,247,90,20)); - jButtonOk.addActionListener(this); - } - return jButtonOk; - } - - /** - This method initializes jButtonCancel - - @return javax.swing.JButton - **/ - private JButton getJButtonCancel() { - if (jButtonCancel == null) { - jButtonCancel = new JButton(); - jButtonCancel.setText("Cancel"); - jButtonCancel.setBounds(new java.awt.Rectangle(389,247,90,20)); - jButtonCancel.addActionListener(this); - } - return jButtonCancel; - } - - /** - This method initializes jComboBoxDataType - - @return javax.swing.JComboBox - **/ - private JComboBox getJComboBoxDataType() { - if (jComboBoxDataType == null) { - jComboBoxDataType = new JComboBox(); - jComboBoxDataType.setBounds(new java.awt.Rectangle(160, 160, 320, 20)); - } - return jComboBoxDataType; - } - - /** - This method initializes jTextFieldOverrideID - - @return javax.swing.JTextField - **/ - private JTextField getJTextFieldOverrideID() { - if (jTextFieldOverrideID == null) { - jTextFieldOverrideID = new JTextField(); - jTextFieldOverrideID.setBounds(new java.awt.Rectangle(159,198,320,20)); - } - return jTextFieldOverrideID; - } - - /** - This is the default constructor - **/ - public PackagePCD(SpdFileContents sfc) { - super(); - init(); - initialize(); - this.sfc = sfc; - } - - /** - This method initializes this - - @return void - **/ - private void init() { - this.setSize(500, 450); - this.setContentPane(getJContentPane()); - this.setTitle("Add PCDs"); - this.centerWindow(); - this.getRootPane().setDefaultButton(jButtonOk); - initFrame(); - this.setVisible(true); - } - - /** - Start the window at the center of screen - * - **/ - protected void centerWindow(int intWidth, int intHeight) { - Dimension d = Toolkit.getDefaultToolkit().getScreenSize(); - this.setLocation((d.width - intWidth) / 2, (d.height - intHeight) / 2); - } - - /** - Start the window at the center of screen - * - **/ - protected void centerWindow() { - centerWindow(this.getSize().width, this.getSize().height); - } - - private JPanel getJContentPane() { - if (jContentPane == null) { - jLabelOverrideID = new JLabel(); - jLabelOverrideID.setBounds(new java.awt.Rectangle(14,197,140,20)); - jLabelOverrideID.setText("Default Value"); - jLabelC_Name = new JLabel(); - jLabelC_Name.setText("C_Name"); - jLabelC_Name.setBounds(new java.awt.Rectangle(15, 60, 140, 20)); - jLabelDataType = new JLabel(); - jLabelDataType.setText("Data Type"); - jLabelDataType.setBounds(new java.awt.Rectangle(15, 160, 140, 20)); - jLabelToken = new JLabel(); - jLabelToken.setText("Token"); - jLabelToken.setBounds(new java.awt.Rectangle(15, 135, 140, 20)); - jLabelItemType = new JLabel(); - jLabelItemType.setText("Item Type"); - jLabelItemType.setBounds(new java.awt.Rectangle(15, 110, 140, 20)); - bg1 = new ButtonGroup(); - bg2 = new ButtonGroup(); - bg3 = new ButtonGroup(); - //bg1.add(getJRadioButtonPCData()); - //bg2.add(getJRadioButtonPcdBuildData()); - jContentPane = new JPanel(); - jContentPane.setLayout(null); - //jContentPane.add(bg1); - jContentPane.add(jLabelItemType, null); - jContentPane.add(jLabelC_Name, null); - jContentPane.add(getJTextFieldC_Name(), null); - jContentPane.add(jLabelToken, null); - jContentPane.add(getJTextFieldToken(), null); - jContentPane.add(jLabelDataType, null); - jContentPane.add(getJButtonOk(), null); - jContentPane.add(getJButtonCancel(), null); - jContentPane.add(getJComboBoxItemType(), null); - jContentPane.add(getJComboBoxDataType(), null); - jContentPane.add(jLabelOverrideID, null); - jContentPane.add(getJTextFieldOverrideID(), null); - - jStarLabel = new StarLabel(); - jStarLabel1 = new StarLabel(); - jStarLabel1.setBounds(new java.awt.Rectangle(6, 59, 10, 20)); - jStarLabel2 = new StarLabel(); - jStarLabel3 = new StarLabel(); - jStarLabel.setLocation(new java.awt.Point(6, 110)); - jStarLabel.setLocation(new java.awt.Point(5, 85)); - jStarLabel2.setLocation(new java.awt.Point(5, 134)); - jStarLabel3.setLocation(new java.awt.Point(5, 159)); - jContentPane.add(jStarLabel2, null); - jContentPane.add(jStarLabel3, null); - jContentPane.add(jStarLabel, null); - jContentPane.add(jStarLabel1, null); - } - return jContentPane; - } - - /** - This method initializes comboboxes - - **/ - private void initFrame() { - - jComboBoxItemType.addItem("FEATURE_FLAG"); - jComboBoxItemType.addItem("FIXED_AT_BUILD"); - jComboBoxItemType.addItem("PATCHABLE_IN_MODULE"); - jComboBoxItemType.addItem("DYNAMIC"); - jComboBoxItemType.addItem("DYNAMIC_EX"); - - jComboBoxDataType.addItem("UINT8"); - jComboBoxDataType.addItem("UINT16"); - jComboBoxDataType.addItem("UINT32"); - jComboBoxDataType.addItem("UINT64"); - jComboBoxDataType.addItem("VOID*"); - jComboBoxDataType.addItem("BOOLEAN"); - } - - public void actionPerformed(ActionEvent arg0) { - if (arg0.getSource() == jButtonOk) { - save(); - this.dispose(); - } - if (arg0.getSource() == jButtonCancel) { - this.dispose(); - } - - - } - - protected void save() { - - sfc.genSpdPcdDefinitions(jComboBoxItemType.getSelectedItem().toString(), jTextFieldC_Name.getText(), - jTextFieldToken.getText(), jComboBoxDataType.getSelectedItem().toString(), null, - null, null, null, null, null, jTextFieldOverrideID.getText()); - } -} // @jve:decl-index=0:visual-constraint="22,11" diff --git a/Tools/Source/PackageEditor/src/org/tianocore/packaging/PackagePkgHeader.java b/Tools/Source/PackageEditor/src/org/tianocore/packaging/PackagePkgHeader.java deleted file mode 100644 index 8d0eb7dc89..0000000000 --- a/Tools/Source/PackageEditor/src/org/tianocore/packaging/PackagePkgHeader.java +++ /dev/null @@ -1,454 +0,0 @@ -/** @file - Java class PackagePkgHeader is GUI for create Package header elements of spd 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; - -import java.awt.BorderLayout; -import java.awt.Dimension; -import java.awt.Toolkit; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.util.Vector; - -import javax.swing.DefaultListModel; -import javax.swing.JPanel; -import javax.swing.JRadioButton; -import javax.swing.JTextField; -import javax.swing.JComboBox; -import javax.swing.JLabel; -import javax.swing.JList; -import javax.swing.JScrollPane; -import javax.swing.JButton; -import javax.swing.JFrame; - -import org.tianocore.packaging.common.ui.StarLabel; - -/** - GUI for create Package header elements of spd file - - @since PackageEditor 1.0 -**/ -public class PackagePkgHeader extends JFrame implements ActionListener { - private static String Separator = "::"; - - private DefaultListModel listItem = new DefaultListModel(); - - private SpdFileContents sfc = null; - - private JPanel jContentPane = null; - - private JRadioButton jRadioButtonAdd = null; - - private JRadioButton jRadioButtonSelect = null; - - private JTextField jTextFieldAdd = null; - - private JComboBox jComboBoxSelect = 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; - - private JLabel jLabel = null; - - private JTextField jTextField = null; - - private StarLabel starLabel = null; - - /** - This method initializes this - - **/ - private void initialize() { - this.setTitle("Package Headers"); - this.setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); - - } - - /** - This method initializes jRadioButtonAdd - - @return javax.swing.JRadioButton - **/ - private JRadioButton getJRadioButtonAdd() { - if (jRadioButtonAdd == null) { - jRadioButtonAdd = new JRadioButton(); - jRadioButtonAdd.setBounds(new java.awt.Rectangle(10, 35, 205, 20)); - jRadioButtonAdd.setText("Add a new Module Type"); - jRadioButtonAdd.setEnabled(false); - jRadioButtonAdd.addActionListener(this); - jRadioButtonAdd.setSelected(false); - } - return jRadioButtonAdd; - } - - /** - This method initializes jRadioButtonSelect - - @return javax.swing.JRadioButton - **/ - private JRadioButton getJRadioButtonSelect() { - if (jRadioButtonSelect == null) { - jRadioButtonSelect = new JRadioButton(); - jRadioButtonSelect.setBounds(new java.awt.Rectangle(10, 10, 205, 20)); - jRadioButtonSelect.setText("Select an existed Module Type"); - jRadioButtonSelect.setActionCommand("Select an existed Module Type"); - jRadioButtonSelect.addActionListener(this); - jRadioButtonSelect.setSelected(true); - } - return jRadioButtonSelect; - } - - /** - This method initializes jTextFieldAdd - - @return javax.swing.JTextField - **/ - private JTextField getJTextFieldAdd() { - if (jTextFieldAdd == null) { - jTextFieldAdd = new JTextField(); - jTextFieldAdd.setBounds(new java.awt.Rectangle(220, 35, 260, 20)); - jTextFieldAdd.setEditable(false); - jTextFieldAdd.setEnabled(false); - } - return jTextFieldAdd; - } - - /** - This method initializes jComboBoxSelect - - @return javax.swing.JComboBox - **/ - 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 jScrollPane - - @return javax.swing.JScrollPane - **/ - private JScrollPane getJScrollPane() { - if (jScrollPane == null) { - jScrollPane = new JScrollPane(); - jScrollPane.setBounds(new java.awt.Rectangle(10, 121, 350, 174)); - jScrollPane.setViewportView(getJListLibraryClassDefinitions()); - } - return jScrollPane; - } - - /** - This method initializes jListLibraryClassDefinitions - - @return javax.swing.JList - **/ - private JList getJListLibraryClassDefinitions() { - if (jListLibraryClassDefinitions == null) { - jListLibraryClassDefinitions = new JList(listItem); - } - return jListLibraryClassDefinitions; - } - - /** - This method initializes jButtonAdd - - @return javax.swing.JButton - **/ - private JButton getJButtonAdd() { - if (jButtonAdd == null) { - jButtonAdd = new JButton(); - jButtonAdd.setBounds(new java.awt.Rectangle(375, 132, 90, 20)); - jButtonAdd.setText("Add"); - jButtonAdd.addActionListener(this); - } - return jButtonAdd; - } - - /** - This method initializes jButtonRemove - - @return javax.swing.JButton - **/ - private JButton getJButtonRemove() { - if (jButtonRemove == null) { - jButtonRemove = new JButton(); - jButtonRemove.setBounds(new java.awt.Rectangle(375, 230, 90, 20)); - jButtonRemove.setText("Remove"); - jButtonRemove.addActionListener(this); - } - return jButtonRemove; - } - - /** - This method initializes jButtonRemoveAll - - @return javax.swing.JButton - **/ - private JButton getJButtonClearAll() { - if (jButtonClearAll == null) { - jButtonClearAll = new JButton(); - jButtonClearAll.setBounds(new java.awt.Rectangle(375, 260, 90, 20)); - jButtonClearAll.setText("Clear All"); - jButtonClearAll.addActionListener(this); - } - return jButtonClearAll; - } - - /** - This method initializes jButtonCancel - - @return javax.swing.JButton - **/ - 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 jButton - - @return javax.swing.JButton - **/ - 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; - } - - /** - This is the default constructor - **/ - public PackagePkgHeader(SpdFileContents sfc) { - super(); - initialize(); - init(); - this.sfc = sfc; - } - - /** - Start the window at the center of screen - * - **/ - protected void centerWindow(int intWidth, int intHeight) { - Dimension d = Toolkit.getDefaultToolkit().getScreenSize(); - this.setLocation((d.width - intWidth) / 2, (d.height - intHeight) / 2); - } - - /** - Start the window at the center of screen - * - **/ - protected void centerWindow() { - centerWindow(this.getSize().width, this.getSize().height); - } - - // private void init(LibraryClassDefinitionsDocument.LibraryClassDefinitions inLibraryClassDefinitions) { - // init(); - // this.setLibraryClassDefinitions(inLibraryClassDefinitions); - // int intLibraryCount = this.libraryClassDefinitions.getLibraryClassArray().length; - // if (intLibraryCount > 0) { - // for (int index = 0; index < intLibraryCount; index++) { - // listItem.addElement(this.libraryClassDefinitions.getLibraryClassArray(index).getUsage().toString() + - // this.Separator + - // this.libraryClassDefinitions.getLibraryClassArray(index).getStringValue()); - // this.libraryClassDefinitions.getLibraryClassArray(); - // } - // } - // } - - /** - This method initializes this - - @return void - **/ - private void init() { - this.setContentPane(getJContentPane()); - this.setTitle("Library Class Declarations"); - this.setBounds(new java.awt.Rectangle(0, 0, 500, 370)); - this.centerWindow(); - initFrame(); - } - - /** - This method initializes jContentPane - - @return javax.swing.JPanel - **/ - private JPanel getJContentPane() { - if (jContentPane == null) { - starLabel = new StarLabel(); - starLabel.setBounds(new java.awt.Rectangle(5, 85, 10, 20)); - jLabel = new JLabel(); - jLabel.setBounds(new java.awt.Rectangle(14, 85, 201, 22)); - jLabel.setText("Include Header for Selected Type"); - jContentPane = new JPanel(); - jContentPane.setLayout(null); - jContentPane.add(getJRadioButtonAdd(), null); - jContentPane.add(getJRadioButtonSelect(), null); - jContentPane.add(getJTextFieldAdd(), null); - jContentPane.add(getJComboBoxSelect(), 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); - jContentPane.add(jLabel, null); - jContentPane.add(getJTextField(), null); - jContentPane.add(starLabel, null); - } - return jContentPane; - } - - private void initFrame() { - jComboBoxSelect.addItem("BASE"); - jComboBoxSelect.addItem("SEC"); - jComboBoxSelect.addItem("PEI_CORE"); - jComboBoxSelect.addItem("PEIM"); - jComboBoxSelect.addItem("DXE_CORE"); - jComboBoxSelect.addItem("DXE_DRIVER"); - jComboBoxSelect.addItem("DXE_RUNTIME_DRIVER"); - jComboBoxSelect.addItem("DXE_SAL_DRIVER"); - jComboBoxSelect.addItem("DXE_SMM_DRIVER"); - jComboBoxSelect.addItem("TOOLS"); - jComboBoxSelect.addItem("UEFI_DRIVER"); - jComboBoxSelect.addItem("UEFI_APPLICATION"); - jComboBoxSelect.addItem("USER_DEFINED"); - - } - - public void actionPerformed(ActionEvent arg0) { - if (arg0.getSource() == jButtonOk) { - this.save(); - this.dispose(); - - } - if (arg0.getSource() == jButtonCancel) { - this.dispose(); - } - - if (arg0.getSource() == jButtonAdd) { - String strLibClass = ""; - - if (jRadioButtonAdd.isSelected()) { - strLibClass = jTextFieldAdd.getText(); - } - if (jRadioButtonSelect.isSelected()) { - strLibClass = jComboBoxSelect.getSelectedItem().toString(); - } - - listItem.addElement(jTextField.getText().replace('\\', '/') + Separator + strLibClass); - } - - 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(); - } - - 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); - } - } - } - - private void save() { - try { - int intLibraryCount = listItem.getSize(); - - if (intLibraryCount > 0) { - - for (int index = 0; index < intLibraryCount; index++) { - String strAll = listItem.get(index).toString(); - String strInclude = strAll.substring(0, strAll.indexOf(Separator)); - String strType = strAll.substring(strAll.indexOf(Separator) + Separator.length()); - sfc.genSpdModuleHeaders(strType, strInclude, null, null, null, null, null, null); - } - } else { - - } - - } catch (Exception e) { - System.out.println(e.toString()); - } - } - - /** - This method initializes jTextField - - @return javax.swing.JTextField - **/ - private JTextField getJTextField() { - if (jTextField == null) { - jTextField = new JTextField(); - jTextField.setBounds(new java.awt.Rectangle(221, 86, 257, 21)); - } - return jTextField; - } - -} diff --git a/Tools/Source/PackageEditor/src/org/tianocore/packaging/PackagePpi.java b/Tools/Source/PackageEditor/src/org/tianocore/packaging/PackagePpi.java deleted file mode 100644 index 7b62d804e5..0000000000 --- a/Tools/Source/PackageEditor/src/org/tianocore/packaging/PackagePpi.java +++ /dev/null @@ -1,41 +0,0 @@ -/** @file - Java class PackagePpi is GUI for create Ppi definition elements of spd 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; - -/** - GUI derived from PackageProtocols class, override save() method - - @since PackageEditor 1.0 -**/ -public class PackagePpi extends PackageProtocols { - - private SpdFileContents sfc = null; - - public PackagePpi(SpdFileContents sfc) { - super(sfc); - // TODO Auto-generated constructor stub - this.sfc = sfc; - } - - /** - add ppi definitions from GUI to SpdFileContents object passed in. - **/ - protected void save() { - try { - sfc.genSpdPpiDeclarations(getJTextField().getText(), getJTextFieldC_Name().getText(), - getJTextFieldGuid().getText(), null); - } catch (Exception e) { - System.out.println(e.toString()); - } - } -} diff --git a/Tools/Source/PackageEditor/src/org/tianocore/packaging/PackageProtocols.java b/Tools/Source/PackageEditor/src/org/tianocore/packaging/PackageProtocols.java deleted file mode 100644 index d99d18b4e6..0000000000 --- a/Tools/Source/PackageEditor/src/org/tianocore/packaging/PackageProtocols.java +++ /dev/null @@ -1,377 +0,0 @@ -/** @file - Java class PackageProtocols is GUI for create Protocol definition elements of spd 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; - -import javax.swing.JPanel; -import javax.swing.JLabel; -import javax.swing.JTextField; -import javax.swing.JButton; -import java.awt.Dimension; -import java.awt.Toolkit; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; - -import javax.swing.JComboBox; -import javax.swing.JRadioButton; -import javax.swing.JFrame; - -import org.tianocore.common.Tools; -import org.tianocore.packaging.common.ui.StarLabel; - -/** - GUI for create Protocol definition elements of spd file. - - @since PackageEditor 1.0 -**/ -public class PackageProtocols extends JFrame implements ActionListener { - - private int location = -1; - - private SpdFileContents sfc = null; - - 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 jLabelEnableFeature = null; - - private JRadioButton jRadioButtonEnableFeature = null; - - private JRadioButton jRadioButtonDisableFeature = null; - - private JButton jButtonGenerateGuid = null; - - private StarLabel jStarLabel2 = null; - - private StarLabel starLabel = null; - - private JLabel jLabel = null; - - private JTextField jTextField = null; - - /** - This method initializes this - - **/ - private void initialize() { - this.setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); - - } - - /** - This method initializes jTextFieldProtocolName - - @return javax.swing.JTextField - **/ - 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 - **/ - public 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 - **/ - private JTextField getJTextFieldFeatureFlag() { - if (jTextFieldFeatureFlag == null) { - jTextFieldFeatureFlag = new JTextField(); - jTextFieldFeatureFlag.setBounds(new java.awt.Rectangle(160, 135, 320, 20)); - jTextFieldFeatureFlag.setEnabled(false); - } - return jTextFieldFeatureFlag; - } - - /** - This method initializes jButton - - @return javax.swing.JButton - **/ - 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 jButton1 - - @return javax.swing.JButton - **/ - 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 jRadioButtonEnableFeature - - @return javax.swing.JRadioButton - **/ - private JRadioButton getJRadioButtonEnableFeature() { - if (jRadioButtonEnableFeature == null) { - jRadioButtonEnableFeature = new JRadioButton(); - jRadioButtonEnableFeature.setText("Enable"); - jRadioButtonEnableFeature.setBounds(new java.awt.Rectangle(160, 110, 90, 20)); - jRadioButtonEnableFeature.setEnabled(false); - jRadioButtonEnableFeature.addActionListener(this); - jRadioButtonEnableFeature.setSelected(true); - } - return jRadioButtonEnableFeature; - } - - /** - This method initializes jRadioButtonDisableFeature - - @return javax.swing.JRadioButton - **/ - private JRadioButton getJRadioButtonDisableFeature() { - if (jRadioButtonDisableFeature == null) { - jRadioButtonDisableFeature = new JRadioButton(); - jRadioButtonDisableFeature.setText("Disable"); - jRadioButtonDisableFeature.setEnabled(false); - jRadioButtonDisableFeature.setBounds(new java.awt.Rectangle(320, 110, 90, 20)); - jRadioButtonDisableFeature.addActionListener(this); - } - return jRadioButtonDisableFeature; - } - - /** - This method initializes jButtonGenerateGuid - - @return javax.swing.JButton - **/ - 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 is the default constructor - **/ - public PackageProtocols(SpdFileContents sfc) { - super(); - initialize(); - init(); - this.setVisible(true); - this.sfc = sfc; - } - - /** - This method initializes this - - @return void - **/ - private void init() { - this.setSize(500, 250); - this.setName("JFrame"); - this.setContentPane(getJContentPane()); - this.setTitle("Add Protocols"); - this.centerWindow(); - //this.getRootPane().setDefaultButton(jButtonOk); - initFrame(); - } - - /** - Start the window at the center of screen - - **/ - protected void centerWindow(int intWidth, int intHeight) { - Dimension d = Toolkit.getDefaultToolkit().getScreenSize(); - this.setLocation((d.width - intWidth) / 2, (d.height - intHeight) / 2); - } - - /** - Start the window at the center of screen - - **/ - protected void centerWindow() { - centerWindow(this.getSize().width, this.getSize().height); - } - - /** - This method initializes jContentPane - - @return javax.swing.JPanel - **/ - private JPanel getJContentPane() { - if (jContentPane == null) { - jLabel = new JLabel(); - jLabel.setBounds(new java.awt.Rectangle(16, 10, 138, 16)); - jLabel.setText("Name"); - starLabel = new StarLabel(); - starLabel.setBounds(new java.awt.Rectangle(0, 9, 10, 20)); - jLabelEnableFeature = new JLabel(); - jLabelEnableFeature.setText("Enable Feature"); - jLabelEnableFeature.setEnabled(false); - jLabelEnableFeature.setBounds(new java.awt.Rectangle(15, 110, 140, 20)); - jLabelFeatureFlag = new JLabel(); - jLabelFeatureFlag.setText("Feature Flag"); - jLabelFeatureFlag.setEnabled(false); - 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(jLabelEnableFeature, null); - jContentPane.add(getJRadioButtonEnableFeature(), null); - jContentPane.add(getJRadioButtonDisableFeature(), null); - jContentPane.add(getJButtonGenerateGuid(), null); - - jStarLabel2 = new StarLabel(); - jStarLabel2.setBounds(new java.awt.Rectangle(0, 35, 10, 20)); - - jContentPane.add(jStarLabel2, null); - jContentPane.add(starLabel, null); - jContentPane.add(jLabel, null); - jContentPane.add(getJTextField(), null); - } - return jContentPane; - } - - /** - This method initializes protocol usage type - - **/ - private void initFrame() { - - } - - public void actionPerformed(ActionEvent arg0) { - if (arg0.getSource() == jButtonOk) { - - this.save(); - this.dispose(); - } - if (arg0.getSource() == jButtonCancel) { - this.dispose(); - } - - 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()); - } - } - - protected void save() { - try { - sfc.genSpdProtocolDeclarations(jTextField.getText(), jTextFieldC_Name.getText(), jTextFieldGuid.getText(), - null); - } catch (Exception e) { - System.out.println(e.toString()); - } - } - - /** - This method initializes jTextField - - @return javax.swing.JTextField - **/ - public JTextField getJTextField() { - if (jTextField == null) { - jTextField = new JTextField(); - jTextField.setBounds(new java.awt.Rectangle(160, 8, 319, 23)); - } - return jTextField; - } - - public JTextField getJTextFieldC_Name() { - return jTextFieldC_Name; - } - - public void setJTextFieldC_Name(JTextField textFieldC_Name) { - jTextFieldC_Name = textFieldC_Name; - } - - public void setJTextField(JTextField textField) { - jTextField = textField; - } - - public void setJTextFieldGuid(JTextField textFieldGuid) { - jTextFieldGuid = textFieldGuid; - } -} // @jve:decl-index=0:visual-constraint="10,10" diff --git a/Tools/Source/PackageEditor/src/org/tianocore/packaging/PackagingMain.java b/Tools/Source/PackageEditor/src/org/tianocore/packaging/PackagingMain.java deleted file mode 100644 index 7d4654ab00..0000000000 --- a/Tools/Source/PackageEditor/src/org/tianocore/packaging/PackagingMain.java +++ /dev/null @@ -1,330 +0,0 @@ -/** @file - Java class PackagingMain is top level GUI for PackageEditor. - -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; - -import java.awt.BorderLayout; -import java.awt.Dimension; -import java.awt.Toolkit; - -import javax.swing.JFileChooser; -import javax.swing.JOptionPane; -import javax.swing.JPanel; -import javax.swing.JFrame; -import java.awt.FlowLayout; -import javax.swing.JButton; -import java.awt.GridLayout; -import java.io.File; -import java.io.FileOutputStream; -import java.util.jar.JarOutputStream; - -/** - GUI for show various GUI wizards for create, update spd file; install, remove package; - create distributable package file. - - @since PackageEditor 1.0 -**/ -public class PackagingMain extends JFrame { - - static JFrame frame; - - static String dirForNewSpd = null; - - private JPanel jContentPane = null; - - private JButton jButton = null; - - private JButton jButton1 = null; - - private JButton jButton2 = null; - - private JButton jButton3 = null; - - private JButton jButton4 = null; - - private JButton jButton5 = null; - - private JFrame pThis = null; - - /** - This method initializes jButton - - @return javax.swing.JButton - **/ - private JButton getJButton() { - if (jButton == null) { - jButton = new JButton(); - jButton.setEnabled(true); - jButton.setText("Exit"); - jButton.addMouseListener(new java.awt.event.MouseAdapter() { - public void mouseClicked(java.awt.event.MouseEvent e) { - pThis.dispose(); - } - }); - } - return jButton; - } - - /** - This method initializes jButton1 - - @return javax.swing.JButton - **/ - private JButton getJButton1() { - if (jButton1 == null) { - jButton1 = new JButton(); - jButton1.setText("Create an Installable Package"); - jButton1.setEnabled(true); - jButton1.addMouseListener(new java.awt.event.MouseAdapter() { - public void mouseClicked(java.awt.event.MouseEvent e) { - File theFile = null; - JFileChooser chooser = new JFileChooser(); - // - // select the directory that contains files to be distribute - // - chooser.setMultiSelectionEnabled(false); - chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); - int retval = chooser.showOpenDialog(frame); - if (retval == JFileChooser.APPROVE_OPTION) { - try { - theFile = chooser.getSelectedFile(); - // - // find the FDPManifest.xml file that should exist - // in the root directory of package - // - String[] list = theFile.list(); - boolean manifestExists = false; - for (int i = 0; i < list.length; i++) { - if (list[i].equals("FDPManifest.xml")) { - manifestExists = true; - break; - } - } - if (!manifestExists) { - JOptionPane.showMessageDialog(frame, - "Please Put the FDPManifest.xml File under the Directory You Selected!"); - return; - } - // - // create the distribute package .fdp file in the same directory with - // the package root directory selected above. - // - JarOutputStream jos = new JarOutputStream(new FileOutputStream(theFile.getPath() + ".fdp")); - CreateFdp.create(theFile, jos, theFile.getPath()); - jos.close(); - JOptionPane.showMessageDialog(frame, - "FDP File Created Successfully!"); - - - } catch (Exception ee) { - System.out.println(ee.toString()); - } - } else { - return; - } - } - }); - } - return jButton1; - } - - /** - This method initializes jButton2 - - @return javax.swing.JButton - **/ - private JButton getJButton2() { - if (jButton2 == null) { - jButton2 = new JButton(); - jButton2.setText("Remove Package"); - jButton2.setEnabled(true); - jButton2.addMouseListener(new java.awt.event.MouseAdapter() { - public void mouseClicked(java.awt.event.MouseEvent e) { - ModalFrameUtil.showAsModal(new GuiPkgUninstall(), pThis); - } - }); - } - return jButton2; - } - - /** - This method initializes jButton3 - - @return javax.swing.JButton - **/ - private JButton getJButton3() { - if (jButton3 == null) { - jButton3 = new JButton(); - jButton3.setText("Install Package"); - jButton3.addMouseListener(new java.awt.event.MouseAdapter() { - public void mouseClicked(java.awt.event.MouseEvent e) { - ModalFrameUtil.showAsModal(new GuiPkgInstall(), pThis); - } - }); - } - return jButton3; - } - - /** - This method initializes jButton4 - - @return javax.swing.JButton - **/ - private JButton getJButton4() { - if (jButton4 == null) { - jButton4 = new JButton(); - jButton4.setText("Update Package Description File"); - jButton4.addMouseListener(new java.awt.event.MouseAdapter() { - public void mouseClicked(java.awt.event.MouseEvent e) { - File theFile = null; - JFileChooser chooser = new JFileChooser(); - // - // select the spd file to be updated first - // - chooser.setMultiSelectionEnabled(false); - chooser.setFileFilter(new PkgFileFilter("spd")); - int retval = chooser.showOpenDialog(frame); - if (retval == JFileChooser.APPROVE_OPTION) { - try { - theFile = chooser.getSelectedFile(); - if (!theFile.isFile()) { - JOptionPane.showMessageDialog(frame, "Please Select one Spd File!"); - return; - } - - } catch (Exception ee) { - System.out.println(ee.toString()); - } - } else { - return; - } - // - // create a SpdFileContents for this file and pass it to GUI - // - SpdFileContents sfc = new SpdFileContents(theFile); - ModalFrameUtil.showAsModal(new UpdateAction(sfc), pThis); - } - }); - } - return jButton4; - } - - /** - This method initializes jButton5 - - @return javax.swing.JButton - **/ - private JButton getJButton5() { - if (jButton5 == null) { - jButton5 = new JButton(); - jButton5.setText("Create Package Description File"); - jButton5.addMouseListener(new java.awt.event.MouseAdapter() { - public void mouseClicked(java.awt.event.MouseEvent e) { - JFileChooser chooser = new JFileChooser(System.getenv("WORKSPACE")); - chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); - chooser.setMultiSelectionEnabled(false); - chooser.setDialogTitle("Please specify where to save the new spd file"); - - int retval = chooser.showSaveDialog(frame); - if (retval == JFileChooser.APPROVE_OPTION) { - try { - File theFile = chooser.getSelectedFile(); - PackagingMain.dirForNewSpd = theFile.getPath(); - - } catch (Exception ee) { - System.out.println(ee.toString()); - } -// pThis.dispose(); - } - else { - return; - } - SpdFileContents sfc = new SpdFileContents(); - ModalFrameUtil.showAsModal(new PackageAction(sfc), pThis); - } - }); - } - return jButton5; - } - - /** - Main for all package editor - - @param args - **/ - public static void main(String[] args) { - // TODO Auto-generated method stub - new PackagingMain().setVisible(true); - } - - /** - This is the default constructor - **/ - public PackagingMain() { - super(); - initialize(); - pThis = this; - } - - /** - This method initializes this - - @return void - **/ - private void initialize() { - this.setSize(300, 357); - this.setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); - this.setTitle("Packaging"); - this.setContentPane(getJContentPane()); - this.centerWindow(); - } - - /** - Start the window at the center of screen - - **/ - protected void centerWindow(int intWidth, int intHeight) { - Dimension d = Toolkit.getDefaultToolkit().getScreenSize(); - this.setLocation((d.width - intWidth) / 2, (d.height - intHeight) / 2); - } - - /** - Start the window at the center of screen - - **/ - protected void centerWindow() { - centerWindow(this.getSize().width, this.getSize().height); - } - - /** - This method initializes jContentPane - - @return javax.swing.JPanel - **/ - private JPanel getJContentPane() { - if (jContentPane == null) { - GridLayout gridLayout = new GridLayout(); - gridLayout.setRows(6); - gridLayout.setColumns(1); - jContentPane = new JPanel(); - jContentPane.setLayout(gridLayout); - jContentPane.add(getJButton5(), null); - jContentPane.add(getJButton4(), null); - jContentPane.add(getJButton3(), null); - jContentPane.add(getJButton2(), null); - jContentPane.add(getJButton1(), null); - jContentPane.add(getJButton(), null); - } - return jContentPane; - } - -} // @jve:decl-index=0:visual-constraint="125,31" diff --git a/Tools/Source/PackageEditor/src/org/tianocore/packaging/PkgInstallTypeChooser.java b/Tools/Source/PackageEditor/src/org/tianocore/packaging/PkgInstallTypeChooser.java deleted file mode 100644 index 099c55ae40..0000000000 --- a/Tools/Source/PackageEditor/src/org/tianocore/packaging/PkgInstallTypeChooser.java +++ /dev/null @@ -1,373 +0,0 @@ -/** @file - Java class PkgInstallTypeChooser is GUI for upgrade package installation. - -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; - -import java.awt.Dimension; -import java.awt.Toolkit; -import java.awt.event.MouseEvent; -import java.awt.event.MouseListener; -import java.io.File; -import java.util.List; -import java.util.ListIterator; -import java.util.Vector; - -import javax.swing.JFileChooser; -import javax.swing.JFrame; -import javax.swing.JOptionPane; -import javax.swing.JPanel; -import javax.swing.JDialog; -import javax.swing.JRadioButton; -import javax.swing.JButton; - -import org.tianocore.PackageListDocument; -import javax.swing.JList; -import javax.swing.JTextField; -import javax.swing.JScrollPane; - -/** - GUI for speicial circumstances of package installation. - - @since PackageEditor 1.0 -**/ -public class PkgInstallTypeChooser extends JFrame implements MouseListener { - - final static long serialVersionUID = 0; - - static JFrame frame; - - private JPanel jContentPane = null; - - private JRadioButton jRadioButton = null; - - private JRadioButton jRadioButton1 = null; - - private JButton jButton = null; - - private JButton jButton1 = null; - - private String pn = null; - - /// - /// list of package info from db file - /// - private List dd = null; - - private String wk = null; - - private JList jList = null; - - private JScrollPane jScrollPane = null; - - private JTextField jTextField = null; - - private JButton jButton2 = null; - - private JFileChooser chooser = null; - - /** - This is the default constructor - **/ - public PkgInstallTypeChooser(String pkgName, String wkSpace, List destDir) { - super(); - pn = pkgName; - dd = destDir; - wk = wkSpace; - initialize(); - } - - /** - This method initializes this - - @return void - **/ - private void initialize() { - this.setSize(359, 328); - this.setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); - this.setTitle("Chooser Installation Type"); - this.setContentPane(getJContentPane()); - this.centerWindow(); - this.insertList(); - } - - /** - Start the window at the center of screen - - **/ - protected void centerWindow(int intWidth, int intHeight) { - Dimension d = Toolkit.getDefaultToolkit().getScreenSize(); - this.setLocation((d.width - intWidth) / 2, (d.height - intHeight) / 2); - } - - /** - Start the window at the center of screen - - **/ - protected void centerWindow() { - centerWindow(this.getSize().width, this.getSize().height); - } - - /** - initialize jList with package info. from db file - **/ - private void insertList() { - - Vector v = new Vector(); - - ListIterator lpi = dd.listIterator(); - while (lpi.hasNext()) { - PackageListDocument.PackageList.Package p = (PackageListDocument.PackageList.Package) lpi.next(); - v.addElement(p.getPackageNameArray(0).getStringValue() + " " + p.getVersionArray(0) + " " - + p.getGuidArray(0).getStringValue()); - } - jList.setListData(v); - } - - /** - This method initializes jContentPane - - @return javax.swing.JPanel - **/ - private JPanel getJContentPane() { - if (jContentPane == null) { - jContentPane = new JPanel(); - jContentPane.setLayout(null); - jContentPane.add(getJRadioButton(), null); - jContentPane.add(getJRadioButton1(), null); - jContentPane.add(getJButton(), null); - jContentPane.add(getJButton1(), null); - jContentPane.add(getJScrollPane(), null); - jContentPane.add(getJTextField(), null); - jContentPane.add(getJButton2(), null); - } - return jContentPane; - } - - - private JRadioButton getJRadioButton() { - if (jRadioButton == null) { - jRadioButton = new JRadioButton(); - jRadioButton.setBounds(new java.awt.Rectangle(17, 39, 186, 21)); - jRadioButton.setSelected(true); - jRadioButton.setText("Reinstall Existing Package"); - jRadioButton.addMouseListener(new java.awt.event.MouseAdapter() { - public void mouseClicked(java.awt.event.MouseEvent e) { - if (jRadioButton.isSelected()) { - jRadioButton1.setSelected(false); - jButton2.setEnabled(false); - jTextField.setEnabled(false); - jList.setEnabled(true); - return; - } - if (jRadioButton1.isSelected()) { - jRadioButton.setSelected(true); - jRadioButton1.setSelected(false); - jList.setEnabled(true); - return; - } - - } - }); - } - return jRadioButton; - } - - private JRadioButton getJRadioButton1() { - if (jRadioButton1 == null) { - jRadioButton1 = new JRadioButton(); - jRadioButton1.setBounds(new java.awt.Rectangle(17, 155, 176, 21)); - jRadioButton1.setText("Install to Directory"); - jRadioButton1.addMouseListener(new java.awt.event.MouseAdapter() { - public void mouseClicked(java.awt.event.MouseEvent e) { - if (jRadioButton1.isSelected()) { - jRadioButton.setSelected(false); - jList.setEnabled(false); - jButton2.setEnabled(true); - jTextField.setEnabled(true); - return; - } - if (jRadioButton.isSelected()) { - jRadioButton1.setSelected(true); - jRadioButton.setSelected(false); - jButton2.setEnabled(true); - jTextField.setEnabled(true); - return; - } - } - }); - } - return jRadioButton1; - } - - private JButton getJButton() { - if (jButton == null) { - jButton = new JButton(); - jButton.setPreferredSize(new java.awt.Dimension(34, 20)); - jButton.setSize(new java.awt.Dimension(76, 20)); - jButton.setText("Ok"); - jButton.setLocation(new java.awt.Point(141, 241)); - jButton.addMouseListener(new java.awt.event.MouseAdapter() { - public void mouseClicked(java.awt.event.MouseEvent e) { - try { - int i = -1; - // - // user selects replace existing package - // - if (jRadioButton.isSelected()) { - int j = jList.getSelectedIndex(); - if (j == -1) { - JOptionPane.showMessageDialog(JOptionPane.getRootFrame(), - "Please Select One Package to Replace!"); - return; - } - // - // the sequence of jList is the same with List - // - String destDir = dd.get(j).getPathArray(0).getStringValue(); - ForceInstallPkg f = new ForceInstallPkg(pn, wk); - // - // record the package info. to be replaced - // - f.setOldVersion(dd.get(j).getVersionArray(0)); - f.setOldGuid(dd.get(j).getGuidArray(0).getStringValue()); - i = f.install(wk + System.getProperty("file.separator") + destDir); - } else { - // - // user selects install to another directory - // - File f = new File(wk + System.getProperty("file.separator") + FrameworkPkg.dbConfigFile); - if (new DbFileContents(f).checkDir(jTextField.getText().substring(wk.length() + 1)) != 0) { - throw new DirSame(); - } - i = new ForceInstallPkg(pn, wk).install(jTextField.getText()); - } - if (i == 0) { - JOptionPane.showMessageDialog(JOptionPane.getRootFrame(), "Package " + pn - + " Installed Successfully!"); - } - } catch (DirSame ds) { - System.out.println(ds.toString()); - JOptionPane.showMessageDialog(frame, - "Another Package Exists There, Please Select Another Directory!"); - } catch (Exception ee) { - System.out.println(ee.toString()); - } - } - }); - } - return jButton; - } - - /** - * This method initializes jButton1 - * - * @return javax.swing.JButton - */ - private JButton getJButton1() { - if (jButton1 == null) { - jButton1 = new JButton(); - jButton1.setBounds(new java.awt.Rectangle(238, 241, 78, 20)); - jButton1.setText("Cancel"); - jButton1.setPreferredSize(new java.awt.Dimension(34, 20)); - jButton1.addMouseListener(this); - } - return jButton1; - } - - public void mouseClicked(MouseEvent arg0) { - // TODO Auto-generated method stub - this.dispose(); - } - - 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 - - } - - private JScrollPane getJScrollPane() { - if (jScrollPane == null) { - jScrollPane = new JScrollPane(); - jScrollPane.setBounds(new java.awt.Rectangle(22, 68, 318, 58)); - jScrollPane.setHorizontalScrollBarPolicy(javax.swing.JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); - jScrollPane.setViewportView(getJList()); - } - return jScrollPane; - } - - private JList getJList() { - if (jList == null) { - jList = new JList(); - - jList.setBounds(new java.awt.Rectangle(22, 68, 318, 58)); - - } - return jList; - } - - /** - * This method initializes jTextField - * - * @return javax.swing.JTextField - */ - private JTextField getJTextField() { - if (jTextField == null) { - jTextField = new JTextField(); - jTextField.setBounds(new java.awt.Rectangle(22, 184, 224, 20)); - jTextField.setEnabled(false); - jTextField.setText(wk); - } - return jTextField; - } - - private JButton getJButton2() { - if (jButton2 == null) { - jButton2 = new JButton(); - jButton2.setLocation(new java.awt.Point(259, 183)); - jButton2.setText("Browse"); - jButton2.setEnabled(false); - jButton2.setSize(new java.awt.Dimension(81, 20)); - jButton2.addMouseListener(new java.awt.event.MouseAdapter() { - public void mouseClicked(java.awt.event.MouseEvent e) { - if (chooser == null) { - chooser = new JFileChooser(wk); - } - chooser.setMultiSelectionEnabled(false); - chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); - - int retval = chooser.showOpenDialog(frame); - if (retval == JFileChooser.APPROVE_OPTION) { - jTextField.setText(chooser.getSelectedFile().getPath()); - - } - - } - }); - } - return jButton2; - } - -} // @jve:decl-index=0:visual-constraint="134,45" diff --git a/Tools/Source/PackageEditor/src/org/tianocore/packaging/SpdFileContents.java b/Tools/Source/PackageEditor/src/org/tianocore/packaging/SpdFileContents.java deleted file mode 100644 index d8b69e8d2f..0000000000 --- a/Tools/Source/PackageEditor/src/org/tianocore/packaging/SpdFileContents.java +++ /dev/null @@ -1,1282 +0,0 @@ -/** @file - Java class SpdFileContents is used to parse spd xml 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; - -import java.io.File; -import java.io.IOException; -import java.util.List; -import java.util.ListIterator; -import java.math.*; -import org.apache.xmlbeans.XmlObject; -import org.apache.xmlbeans.XmlOptions; -import org.apache.xmlbeans.XmlCursor; - -import org.tianocore.AbstractDocument; -import org.tianocore.GuidDeclarationsDocument; -import org.tianocore.GuidDocument; -import org.tianocore.IncludeHeaderDocument; -import org.tianocore.LibraryClassDeclarationDocument; -import org.tianocore.LibraryClassDeclarationsDocument; -import org.tianocore.LibraryClassDocument; -import org.tianocore.LibraryUsage; -import org.tianocore.LicenseDocument; -import org.tianocore.ModuleTypeDef; -import org.tianocore.MsaFilesDocument; -import org.tianocore.OutputDirectoryDocument; -import org.tianocore.PackageDependenciesDocument; -import org.tianocore.PackageHeadersDocument; -import org.tianocore.PackageNameDocument; -import org.tianocore.PackageSurfaceAreaDocument; -import org.tianocore.PackageType; -import org.tianocore.PackageUsage; -import org.tianocore.PcdDataTypes; -import org.tianocore.PcdDefinitionsDocument; -import org.tianocore.PcdItemTypes; -import org.tianocore.PpiDeclarationsDocument; -import org.tianocore.ProtocolDeclarationsDocument; -import org.tianocore.SpdHeaderDocument; -import org.tianocore.SpecificationDocument; -import org.tianocore.GuidDeclarationsDocument.GuidDeclarations; - -/** - This class processes spd file contents such as add remove xml elements. - - @since PackageEditor 1.0 -**/ -public class SpdFileContents { - - private File file = null; - - private PackageSurfaceAreaDocument psad = null; - - private PackageSurfaceAreaDocument.PackageSurfaceArea psaRoot = null; - - private SpdHeaderDocument.SpdHeader spdHdr = null; - - private String spdHdrPkgName = null; - - private GuidDocument.Guid spdHdrGuid = null; - - private LicenseDocument.License spdHdrLicense = null; - - private OutputDirectoryDocument.OutputDirectory spdHdrOutDir = null; - - private LibraryClassDeclarationsDocument.LibraryClassDeclarations spdLibClassDeclarations = null; - - private PackageDependenciesDocument.PackageDependencies spdPkgDeps = null; - - private MsaFilesDocument.MsaFiles spdMsaFiles = null; - - private PackageHeadersDocument.PackageHeaders spdModHdrs = null; - - private GuidDeclarationsDocument.GuidDeclarations spdGuidDeclarations = null; - - private ProtocolDeclarationsDocument.ProtocolDeclarations spdProtocolDeclarations = null; - - private PpiDeclarationsDocument.PpiDeclarations spdPpiDeclarations = null; - - private PcdDefinitionsDocument.PcdDefinitions spdPcdDefinitions = null; - - /** - Constructor to create a new spd file - **/ - public SpdFileContents() { - - psad = PackageSurfaceAreaDocument.Factory.newInstance(); - psaRoot = psad.addNewPackageSurfaceArea(); - - } - - /** - Constructor based on an existing spd file - - @param f Existing spd file - **/ - public SpdFileContents(File f) { - try { - psad = PackageSurfaceAreaDocument.Factory.parse(f); - psaRoot = psad.getPackageSurfaceArea(); - file = f; - } catch (Exception e) { - System.out.println(e.toString()); - } - } - - /** - Remove existing pcd definitions elements using XmlCursor - **/ - public void removeSpdPcdDefinition() { - XmlObject o = psaRoot.getPcdDefinitions(); - if (o == null) - return; - XmlCursor cursor = o.newCursor(); - cursor.removeXml(); - spdPcdDefinitions = null; - } - - /** - Remove existing ppi declarations using XmlCursor - **/ - public void removeSpdPpiDeclaration() { - XmlObject o = psaRoot.getPpiDeclarations(); - if (o == null) - return; - XmlCursor cursor = o.newCursor(); - cursor.removeXml(); - spdPpiDeclarations = null; - } - - /** - Remove existing protocols declarations using XmlCursor - **/ - public void removeSpdProtocolDeclaration() { - XmlObject o = psaRoot.getProtocolDeclarations(); - if (o == null) - return; - XmlCursor cursor = o.newCursor(); - cursor.removeXml(); - spdProtocolDeclarations = null; - } - - /** - Remove existing GUID declarations using XmlCursor - **/ - public void removeSpdGuidDeclaration() { - XmlObject o = psaRoot.getGuidDeclarations(); - if (o == null) - return; - XmlCursor cursor = o.newCursor(); - cursor.removeXml(); - spdGuidDeclarations = null; - } - - /** - Remove existing spd package include files using XmlCursor - **/ - public void removeSpdPkgHeader() { - XmlObject o = psaRoot.getPackageHeaders(); - if (o == null) - return; - XmlCursor cursor = o.newCursor(); - cursor.removeXml(); - spdModHdrs = null; - } - - /** - Remove existing msa files using XmlCursor - **/ - public void removeSpdMsaFile() { - XmlObject o = psaRoot.getMsaFiles(); - if (o == null) - return; - XmlCursor cursor = o.newCursor(); - cursor.removeXml(); - spdMsaFiles = null; - } - - /** - Remove existing library class declarations using XmlCursor - **/ - public void removeSpdLibClass() { - XmlObject o = psaRoot.getLibraryClassDeclarations(); - if (o == null) - return; - XmlCursor cursor = o.newCursor(); - cursor.removeXml(); - spdLibClassDeclarations = null; - } - - /** - Get spd file header contents into String array - - @param s Caller allocated String array - **/ - public void getSpdHdrDetails(String[] s) { - if (getSpdHdr() == null) { - spdHdr = psaRoot.addNewSpdHeader(); - } - s[0] = getSpdHdrPkgName(); - s[1] = getSpdHdrGuid().getStringValue(); - s[2] = getSpdHdrVer(); - s[3] = getSpdHdrAbs(); - s[4] = getSpdHdr().getDescription(); - s[5] = getSpdHdr().getCopyright(); - s[6] = getSpdHdrLicense().getStringValue(); - s[7] = getSpdHdr().getCreated(); - s[8] = getSpdHdr().getURL(); - if (getSpdHdr().getPackageType() != null) { - s[9] = getSpdHdr().getPackageType().toString(); - } - // - // convert boolean to String by adding empty String "" - // - s[10] = getSpdHdr().getReadOnly() + ""; - s[11] = getSpdHdr().getReadOnly() + ""; - } - - /** - Get the number of library class declarations from the size of List - - @return int - **/ - public int getSpdLibClassDeclarationCount() { - if (psaRoot.getLibraryClassDeclarations() == null - || psaRoot.getLibraryClassDeclarations().getLibraryClassDeclarationList() == null) { - return 0; - } - return psaRoot.getLibraryClassDeclarations().getLibraryClassDeclarationList().size(); - } - - /** - Get available library class declaration into String array - @param libClass Caller allocated two-dimentional String array - **/ - public void getSpdLibClassDeclarations(String[][] libClass) { - if (psaRoot.getLibraryClassDeclarations() == null){ - return; - } - List l = psaRoot.getLibraryClassDeclarations() - .getLibraryClassDeclarationList(); - int i = 0; - ListIterator li = l.listIterator(); - while (li.hasNext()) { - LibraryClassDeclarationDocument.LibraryClassDeclaration lcd = (LibraryClassDeclarationDocument.LibraryClassDeclaration) li - .next(); - if (lcd.getLibraryClass() != null) { - libClass[i][0] = lcd.getLibraryClass().getStringValue(); - } - if (lcd.getIncludeHeader() != null) { - libClass[i][1] = lcd.getIncludeHeader().getStringValue(); - } - - i++; - } - - } - - /** - Get the number of Msa files from the size of List - - @return int - **/ - public int getSpdMsaFileCount() { - if (psaRoot.getMsaFiles() == null || psaRoot.getMsaFiles().getMsaFileList() == null) { - return 0; - } - return psaRoot.getMsaFiles().getMsaFileList().size(); - } - - /** - Get available Msa file into String array - - @param msaFile Caller allocated two-dimentional String array - **/ - public void getSpdMsaFiles(String[][] msaFile) { - if (psaRoot.getMsaFiles() == null) { - return; - } - List l = psaRoot.getMsaFiles().getMsaFileList(); - int i = 0; - ListIterator li = l.listIterator(); - while (li.hasNext()) { - MsaFilesDocument.MsaFiles.MsaFile m = (MsaFilesDocument.MsaFiles.MsaFile) li.next(); - if (m.getFilename() != null) { - msaFile[i][0] = m.getFilename().getStringValue(); - } - - i++; - } - } - - /** - Get the number of include header files in PackageHeaders from the size of List - - @return int - **/ - public int getSpdPackageHeaderCount() { - if (psaRoot.getPackageHeaders() == null || psaRoot.getPackageHeaders().getIncludeHeaderList() == null) { - return 0; - } - return psaRoot.getPackageHeaders().getIncludeHeaderList().size(); - } - - /** - Get available package header contents into String array - - @param pkgHeader Caller allocated two-dimentional String array - **/ - public void getSpdPackageHeaders(String[][] pkgHeader) { - if (psaRoot.getPackageHeaders() == null) { - return; - } - - List l = psaRoot.getPackageHeaders().getIncludeHeaderList(); - int i = 0; - ListIterator li = l.listIterator(); - while (li.hasNext()) { - IncludeHeaderDocument.IncludeHeader ih = (IncludeHeaderDocument.IncludeHeader) li.next(); - if (ih.getModuleType() != null) { - pkgHeader[i][0] = ih.getModuleType().toString(); - } - - pkgHeader[i][1] = ih.getStringValue(); - i++; - } - } - - /** - Get the number of GUID declarations from the size of List - - @return int - **/ - public int getSpdGuidDeclarationCount() { - if (psaRoot.getGuidDeclarations() == null || psaRoot.getGuidDeclarations().getEntryList() == null) { - return 0; - } - return psaRoot.getGuidDeclarations().getEntryList().size(); - } - - /** - Get available Guid declaration contents into String array - - @param guid Caller allocated two-dimentional String array - **/ - public void getSpdGuidDeclarations(String[][] guid) { - if (psaRoot.getGuidDeclarations() == null) { - return; - } - - List l = psaRoot.getGuidDeclarations().getEntryList(); - int i = 0; - ListIterator li = l.listIterator(); - while (li.hasNext()) { - GuidDeclarationsDocument.GuidDeclarations.Entry e = (GuidDeclarationsDocument.GuidDeclarations.Entry) li - .next(); - guid[i][0] = e.getName(); - guid[i][1] = e.getCName(); - if (e.getGuid() != null) { - guid[i][2] = e.getGuid().getStringValue(); - } - i++; - } - } - - /** - Get the number of protocol declarations from the size of List - - @return int - **/ - public int getSpdProtocolDeclarationCount() { - if (psaRoot.getProtocolDeclarations() == null || psaRoot.getProtocolDeclarations().getEntryList() == null) { - return 0; - } - return psaRoot.getProtocolDeclarations().getEntryList().size(); - } - - /** - Get available protocol declaration contents into String array - - @param protocol Caller allocated two-dimentional String array - **/ - public void getSpdProtocolDeclarations(String[][] protocol) { - if (psaRoot.getProtocolDeclarations() == null) { - return; - } - - List l = psaRoot.getProtocolDeclarations() - .getEntryList(); - int i = 0; - ListIterator li = l.listIterator(); - while (li.hasNext()) { - ProtocolDeclarationsDocument.ProtocolDeclarations.Entry e = (ProtocolDeclarationsDocument.ProtocolDeclarations.Entry) li - .next(); - protocol[i][0] = e.getName(); - protocol[i][1] = e.getCName(); - if (e.getGuid() != null) { - protocol[i][2] = e.getGuid().getStringValue(); - } - i++; - } - } - - /** - Get the number of Ppi declarations from the size of List - - @return int - **/ - public int getSpdPpiDeclarationCount() { - if (psaRoot.getPpiDeclarations() == null || psaRoot.getPpiDeclarations().getEntryList() == null) { - return 0; - } - return psaRoot.getPpiDeclarations().getEntryList().size(); - } - - /** - Get available Ppi declaration contents into String array - - @param ppi Caller allocated two-dimentional String array - **/ - public void getSpdPpiDeclarations(String[][] ppi) { - if (psaRoot.getPpiDeclarations() == null) { - return; - } - - List l = psaRoot.getPpiDeclarations().getEntryList(); - int i = 0; - ListIterator li = l.listIterator(); - while (li.hasNext()) { - PpiDeclarationsDocument.PpiDeclarations.Entry e = (PpiDeclarationsDocument.PpiDeclarations.Entry) li.next(); - ppi[i][0] = e.getName(); - ppi[i][1] = e.getCName(); - if (e.getGuid() != null) { - ppi[i][2] = e.getGuid().getStringValue(); - } - - i++; - } - } - - /** - Get the number of Pcd definitions from the size of List - - @return int - **/ - public int getSpdPcdDefinitionCount() { - if (psaRoot.getPcdDefinitions() == null || psaRoot.getPcdDefinitions().getPcdEntryList() == null) { - return 0; - } - return psaRoot.getPcdDefinitions().getPcdEntryList().size(); - } - - /** - Get available Pcd definition contents into String array - - @param pcd Caller allocated two-dimentional String array - **/ - public void getSpdPcdDefinitions(String[][] pcd) { - if (psaRoot.getPcdDefinitions() == null) { - return; - } - - List l = psaRoot.getPcdDefinitions().getPcdEntryList(); - int i = 0; - ListIterator li = l.listIterator(); - while (li.hasNext()) { - PcdDefinitionsDocument.PcdDefinitions.PcdEntry e = (PcdDefinitionsDocument.PcdDefinitions.PcdEntry) li - .next(); - if (e.getItemType() != null) { - pcd[i][0] = e.getItemType().toString(); - } - - pcd[i][1] = e.getCName(); - pcd[i][2] = e.getToken(); - if (e.getDatumType() != null) { - pcd[i][3] = e.getDatumType().toString(); - } - - if (e.getDefaultValue() != null) { - pcd[i][4] = e.getDefaultValue().toString(); - } - - i++; - } - } - - /** - Save the processed xml contents to file - - @param spdFile The file to save xml contents - @throws IOException Exceptions during file operation - **/ - public void saveAs(File spdFile) throws IOException { - - XmlOptions options = new XmlOptions(); - - options.setCharacterEncoding("UTF-8"); - options.setSavePrettyPrint(); - options.setSavePrettyPrintIndent(2); - try { - psad.save(spdFile, options); - } catch (IOException e) { - e.printStackTrace(); - } - - } - - /** - Generate SpdHeader contents using parameters passed in. - - @param pkgName PackageName - @param pkgGuid Guid - @param pkgVer Version - @param pkgAbs Abstract - @param pkgDes Description - @param pkgCpRight Copyright - @param pkgLicense License - @param pkgCreateDate Created - @param pkgUpdateDate Updated - @param pkgURL URL - @param pkgType PackageType - @param pkgRdOnly ReadOnly - @param pkgRePkg RePackage - @param pkgSpec Reserved - @param pkgOutDir Reserved - **/ - public void genSpdHeader(String pkgName, String pkgGuid, String pkgVer, String pkgAbs, String pkgDes, - String pkgCpRight, String pkgLicense, String pkgCreateDate, String pkgUpdateDate, - String pkgURL, String pkgType, String pkgRdOnly, String pkgRePkg, String pkgSpec, - String pkgOutDir) { - if (getSpdHdr() == null) { - spdHdr = psaRoot.addNewSpdHeader(); - } - - setSpdHdrPkgName(pkgName); - setSpdHdrGuid(pkgGuid); - setSpdHdrVer(pkgVer); - setSpdHdrAbs(pkgAbs); - setSpdHdrDes(pkgDes); - setSpdHdrCpRit(pkgCpRight); - setSpdHdrLicense(pkgLicense); - setSpdHdrCreateDate(pkgCreateDate); - setSpdHdrUpdateDate(pkgUpdateDate); - setSpdHdrURL(pkgURL); - setSpdHdrPkgType(pkgType); - setSpdHdrRdOnly(pkgRdOnly); - setSpdHdrRePkg(pkgRePkg); - setSpdHdrSpec(pkgSpec); - setSpdHdrOutDir(pkgOutDir); - } - - /** - Generate library class declaration element using parameters passed in - - @param libClassBaseName LibraryClass element value - @param libClassUsage Reserved - @param incHdrFileName IncludeHeader element value - @param incHdrAttribGuid Reserved - @param incHdrAttribArch Reserved - @param incHdrAttribPath Reserved - @param incHdrAttribClass Reserved - @param incHdrAttribVer Reserved - @param incHdrAttribOverrideID Reserved - @param incHdrAttribModuleType Reserved - **/ - public void genSpdLibClassDeclarations(String libClassBaseName, String libClassUsage, String incHdrFileName, - String incHdrAttribGuid, String incHdrAttribArch, String incHdrAttribPath, - String incHdrAttribClass, String incHdrAttribVer, - String incHdrAttribOverrideID, String incHdrAttribModuleType) { - if (getSpdLibClassDeclarations() == null) { - spdLibClassDeclarations = psaRoot.addNewLibraryClassDeclarations(); - } - // - // add contents under LibraryClassDeclarations tag - // - setSpdLibClassDeclaration(libClassBaseName, libClassUsage, incHdrFileName, incHdrAttribGuid, incHdrAttribArch, - incHdrAttribPath, incHdrAttribClass, incHdrAttribVer, incHdrAttribOverrideID, - incHdrAttribModuleType, spdLibClassDeclarations); - } - - /** - Set library class declaration contents under parent tag - - @param clsName LibraryClass element value - @param clsUsage Reserved - @param hdrFile IncludeHeader element value - @param hdrAttribGuid Reserved - @param hdrAttribArch Reserved - @param hdrAttribPath Reserved - @param hdrAttribClass Reserved - @param hdrAttribVer Reserved - @param hdrAttribOverID Reserved - @param hdrAttribModType Reserved - @param parent The tag under which library class declaration goes to - **/ - public void setSpdLibClassDeclaration(String clsName, String clsUsage, String hdrFile, String hdrAttribGuid, - String hdrAttribArch, String hdrAttribPath, String hdrAttribClass, - String hdrAttribVer, String hdrAttribOverID, String hdrAttribModType, - XmlObject parent) { - - LibraryClassDeclarationDocument.LibraryClassDeclaration lcd = ((LibraryClassDeclarationsDocument.LibraryClassDeclarations) parent) - .addNewLibraryClassDeclaration(); - - setSpdLibraryClass(clsName, clsUsage, lcd); - - setSpdIncludeHeader(null, hdrFile, hdrAttribGuid, hdrAttribArch, hdrAttribPath, hdrAttribClass, hdrAttribVer, - hdrAttribOverID, lcd); - } - - /** - Set the contents of LibraryClass under parent element - - @param clsName LibraryClass element value - @param clsUsage Reserved - @param parent The tag under which library class declaration goes to - **/ - public void setSpdLibraryClass(String clsName, String clsUsage, XmlObject parent) { - LibraryClassDeclarationDocument.LibraryClassDeclaration.LibraryClass lc = ((LibraryClassDeclarationDocument.LibraryClassDeclaration) parent).addNewLibraryClass(); - lc.setStringValue(clsName); - } - - /** - Set contents of IncludeHeader under parent element - - @param modType Reserved - @param hdrFile IncludeHeader element value - @param hdrAttribGuid Reserved - @param hdrAttribArch Reserved - @param hdrAttribPath Reserved - @param hdrAttribClass Reserved - @param hdrAttribVer Reserved - @param hdrAttribOverID Reserved - @param parent The tag under which library class declaration goes to - **/ - public void setSpdIncludeHeader(String modType, String hdrFile, String hdrAttribGuid, String hdrAttribArch, - String hdrAttribPath, String hdrAttribClass, String hdrAttribVer, - String hdrAttribOverID, XmlObject parent) { - IncludeHeaderDocument.IncludeHeader ih = null; - if (parent instanceof LibraryClassDeclarationDocument.LibraryClassDeclaration) { - ih = ((LibraryClassDeclarationDocument.LibraryClassDeclaration) parent).addNewIncludeHeader(); - } else if (parent instanceof PackageHeadersDocument.PackageHeaders) { - ih = ((PackageHeadersDocument.PackageHeaders) parent).addNewIncludeHeader(); - } else { - return; - } - - ih.setStringValue(hdrFile); - if (hdrAttribGuid != null) { - ih.setGuid(hdrAttribGuid); - } - if (hdrAttribPath != null) { - ih.setPath(hdrAttribPath); - } - if (hdrAttribClass != null) { - ih.setClass1(hdrAttribClass); - } - if (hdrAttribVer != null) { - ih.setVersion(hdrAttribVer); - } - if (hdrAttribOverID != null) { - ih.setOverrideID(Integer.parseInt(hdrAttribOverID)); - } - if (modType != null) { - ih.setModuleType(ModuleTypeDef.Enum.forString(modType)); - - } - - } - - /** - Reserved method - - @param pkgDepPkgName - @param pkgDepPkgAttribGuid - @param pkgDepPkgAttribVer - @param pkgDepPkgAttribType - @param pkgDepPkgAttribUsage - @param pkgDepPkgAttribInstallDate - @param pkgDepPkgAttribUpdateDate - @param pkgDepPkgAttribPath - **/ - public void genSpdPackageDependencies(String pkgDepPkgName, String pkgDepPkgAttribGuid, String pkgDepPkgAttribVer, - String pkgDepPkgAttribType, String pkgDepPkgAttribUsage, - String pkgDepPkgAttribInstallDate, String pkgDepPkgAttribUpdateDate, - String pkgDepPkgAttribPath) { - if (spdPkgDeps == null) { - spdPkgDeps = psaRoot.addNewPackageDependencies(); - } - - setSpdPackageName(pkgDepPkgName, pkgDepPkgAttribGuid, pkgDepPkgAttribVer, pkgDepPkgAttribType, - pkgDepPkgAttribUsage, pkgDepPkgAttribInstallDate, pkgDepPkgAttribUpdateDate, - pkgDepPkgAttribPath, spdPkgDeps); - } - - /** - Reserved method - - @param pkgName - @param pkgAttribGuid - @param pkgAttribVer - @param pkgAttribType - @param pkgAttribUsage - @param pkgAttribInstallDate - @param pkgAttribUpdateDate - @param pkgAttribPath - @param parent - **/ - public void setSpdPackageName(String pkgName, String pkgAttribGuid, String pkgAttribVer, String pkgAttribType, - String pkgAttribUsage, String pkgAttribInstallDate, String pkgAttribUpdateDate, - String pkgAttribPath, XmlObject parent) { - - PackageNameDocument.PackageName pn = ((PackageDependenciesDocument.PackageDependencies) parent) - .addNewPackageName(); - pn.setStringValue(pkgName); - pn.setPackageType(PackageType.Enum.forString(pkgAttribType)); - pn.setUsage(PackageUsage.Enum.forString(pkgAttribUsage)); - pn.setUpdatedDate(pkgAttribUpdateDate); - } - - /** - Generate MsaFile element. - - @param msaFileName MsaFile element value - @param archType Reserved - **/ - public void genSpdMsaFiles(String msaFileName, String archType) { - if (getSpdMsaFiles() == null) { - spdMsaFiles = psaRoot.addNewMsaFiles(); - } - setSpdMsaFile(msaFileName, spdMsaFiles); - - } - - /** - Set MsaFile contents under parent element. - - @param msaFileName MsaFile element value - @param parent Element under which MsaFile goes to - **/ - public void setSpdMsaFile(String msaFileName, XmlObject parent) { - - ((MsaFilesDocument.MsaFiles) parent).addNewMsaFile().addNewFilename().setStringValue(msaFileName); - } - - /** - Generate PackageHeader element using parameters passed in. - - @param ModHdrModType ModuleType attribute of IncludeHeader element - @param hdrFile IncludeHeader element value - @param hdrAttribGuid Reserved - @param hdrAttribArch Reserved - @param hdrAttribPath Reserved - @param hdrAttribClass Reserved - @param hdrAttribVer Reserved - @param hdrAttribOverID Reserved - **/ - public void genSpdModuleHeaders(String ModHdrModType, String hdrFile, String hdrAttribGuid, String hdrAttribArch, - String hdrAttribPath, String hdrAttribClass, String hdrAttribVer, - String hdrAttribOverID) { - if (getSpdModHdrs() == null) { - spdModHdrs = psaRoot.addNewPackageHeaders(); - } - - // - // add IncludeHeader under PackageHeaders element - // - setSpdIncludeHeader(ModHdrModType, hdrFile, hdrAttribGuid, hdrAttribArch, hdrAttribPath, hdrAttribClass, - hdrAttribVer, hdrAttribOverID, spdModHdrs); - } - - /** - Generate GUID declaration element using parameters passed in. - - @param guidDeclEntryName Name attribute of Entry element - @param guidDeclCName CName element value - @param guidDeclGuid Guid element value - @param guidDeclFeatureFlag Reserved - **/ - public void genSpdGuidDeclarations(String guidDeclEntryName, String guidDeclCName, String guidDeclGuid, - String guidDeclFeatureFlag) { - if (getSpdGuidDeclarations() == null) { - spdGuidDeclarations = psaRoot.addNewGuidDeclarations(); - } - - setSpdEntry(guidDeclEntryName, guidDeclCName, guidDeclGuid, guidDeclFeatureFlag, spdGuidDeclarations); - } - - /** - Generate protocol declaration element using parameters passed in. - - @param protocolDeclEntryName Name attribute of Entry element - @param protocolDeclCName CName element value - @param protocolDeclGuid Guid element value - @param protocolDeclFeatureFlag Reserved - **/ - public void genSpdProtocolDeclarations(String protocolDeclEntryName, String protocolDeclCName, - String protocolDeclGuid, String protocolDeclFeatureFlag) { - if (getSpdProtocolDeclarations() == null) { - spdProtocolDeclarations = psaRoot.addNewProtocolDeclarations(); - } - - setSpdEntry(protocolDeclEntryName, protocolDeclCName, protocolDeclGuid, protocolDeclFeatureFlag, - spdProtocolDeclarations); - } - - /** - Generate PPI declaration element using parameters passed in. - - @param ppiDeclEntryName Name attribute of Entry element - @param ppiDeclCName CName element value - @param ppiDeclGuid Guid element value - @param ppiDeclFeatureFlag Reserved - **/ - public void genSpdPpiDeclarations(String ppiDeclEntryName, String ppiDeclCName, String ppiDeclGuid, - String ppiDeclFeatureFlag) { - if (getSpdPpiDeclarations() == null) { - spdPpiDeclarations = psaRoot.addNewPpiDeclarations(); - } - - setSpdEntry(ppiDeclEntryName, ppiDeclCName, ppiDeclGuid, ppiDeclFeatureFlag, spdPpiDeclarations); - } - - /** - Set Entry contents using parameters passed in - - @param entryName Name attribute of Entry element - @param cName CName element value - @param guid Guid element value - @param featureFlag Reserved - @param parent The tag under which Entry element goes to - **/ - public void setSpdEntry(String entryName, String cName, String guid, String featureFlag, XmlObject parent) { - - if (parent instanceof GuidDeclarationsDocument.GuidDeclarations) { - GuidDeclarationsDocument.GuidDeclarations.Entry e = ((GuidDeclarations) parent).addNewEntry(); - e.setName(entryName); - e.setCName(cName); - e.addNewGuid().setStringValue(guid); - - return; - } - if (parent instanceof ProtocolDeclarationsDocument.ProtocolDeclarations) { - ProtocolDeclarationsDocument.ProtocolDeclarations.Entry pe = ((ProtocolDeclarationsDocument.ProtocolDeclarations) parent) - .addNewEntry(); - pe.setName(entryName); - pe.setCName(cName); - pe.addNewGuid().setStringValue(guid); - - } - if (parent instanceof PpiDeclarationsDocument.PpiDeclarations) { - PpiDeclarationsDocument.PpiDeclarations.Entry ppe = ((PpiDeclarationsDocument.PpiDeclarations) parent) - .addNewEntry(); - ppe.setName(entryName); - ppe.setCName(cName); - ppe.addNewGuid().setStringValue(guid); - - return; - } - - return; - - } - - /** - Generate Pcd definition using parameters passed in - - @param pcdItemTypes ItemType attribute of PcdEntry element - @param cName C_Name element value - @param token Token element value - @param dataType DatumType element value - @param skuEnable Reserved - @param sku Reserved - @param maxSku Reserved - @param hiiEnable Reserved - @param varGuid Reserved - @param varName Reserved - @param defaultString DefaultString element value - **/ - public void genSpdPcdDefinitions(String pcdItemTypes, String cName, String token, String dataType, - String skuEnable, String sku, String maxSku, String hiiEnable, String varGuid, - String varName, String defaultString) { - if (getSpdPcdDefinitions() == null) { - spdPcdDefinitions = psaRoot.addNewPcdDefinitions(); - } - - setSpdPcdEntry(pcdItemTypes, cName, token, dataType, skuEnable, sku, maxSku, hiiEnable, varGuid, varName, - defaultString, spdPcdDefinitions); - } - - /** - Set Pcd entry contents under parent tag - - @param pcdItemTypes ItemType attribute of PcdEntry element - @param cName C_Name element value - @param token Token element value - @param dataType DatumType element value - @param skuEnable Reserved - @param sku Reserved - @param maxSku Reserved - @param hiiEnable Reserved - @param varGuid Reserved - @param varName Reserved - @param defaultString DefaultString element value - @param parent Tag under which PcdEntry goes to - **/ - public void setSpdPcdEntry(String pcdItemTypes, String cName, String token, String dataType, String skuEnable, - String sku, String maxSku, String hiiEnable, String varGuid, String varName, - String defaultString, XmlObject parent) { - - PcdDefinitionsDocument.PcdDefinitions.PcdEntry pe = ((PcdDefinitionsDocument.PcdDefinitions) parent) - .addNewPcdEntry(); - pe.setItemType(PcdItemTypes.Enum.forString(pcdItemTypes)); - pe.setCName(cName); - pe.setToken(token); - pe.setDatumType(PcdDataTypes.Enum.forString(dataType)); - pe.setDefaultValue(defaultString); - - } - - /** - Get PpiDeclarations element - - @return PpiDeclarationsDocument.PpiDeclarations - **/ - public PpiDeclarationsDocument.PpiDeclarations getSpdPpiDeclarations() { - if (spdPpiDeclarations == null) { - spdPpiDeclarations = psaRoot.getPpiDeclarations(); - } - return spdPpiDeclarations; - } - - /** - Get ProtocolDeclarations element - - @return ProtocolDeclarationsDocument.ProtocolDeclarations - **/ - public ProtocolDeclarationsDocument.ProtocolDeclarations getSpdProtocolDeclarations() { - if (spdProtocolDeclarations == null) { - spdProtocolDeclarations = psaRoot.getProtocolDeclarations(); - } - return spdProtocolDeclarations; - } - - /** - Get GuidDeclarations element - - @return GuidDeclarationsDocument.GuidDeclarations - **/ - public GuidDeclarationsDocument.GuidDeclarations getSpdGuidDeclarations() { - if (spdGuidDeclarations == null) { - spdGuidDeclarations = psaRoot.getGuidDeclarations(); - } - return spdGuidDeclarations; - } - - /** - Get PcdDefinitions element - - @return PcdDefinitionsDocument.PcdDefinitions - **/ - public PcdDefinitionsDocument.PcdDefinitions getSpdPcdDefinitions() { - if (spdPcdDefinitions == null) { - spdPcdDefinitions = psaRoot.getPcdDefinitions(); - } - return spdPcdDefinitions; - } - - /** - Get PackageHeaders element - - @return PackageHeadersDocument.PackageHeaders - **/ - public PackageHeadersDocument.PackageHeaders getSpdModHdrs() { - if (spdModHdrs == null) { - spdModHdrs = psaRoot.getPackageHeaders(); - } - return spdModHdrs; - } - - /** - Get MsaFiles element - - @return MsaFilesDocument.MsaFiles - **/ - public MsaFilesDocument.MsaFiles getSpdMsaFiles() { - if (spdMsaFiles == null) { - spdMsaFiles = psaRoot.getMsaFiles(); - } - return spdMsaFiles; - } - - /** - Get LibraryClassDeclarations element - - @return LibraryClassDeclarationsDocument.LibraryClassDeclarations - **/ - public LibraryClassDeclarationsDocument.LibraryClassDeclarations getSpdLibClassDeclarations() { - if (spdLibClassDeclarations == null) { - spdLibClassDeclarations = psaRoot.getLibraryClassDeclarations(); - } - return spdLibClassDeclarations; - } - - /** - Get SpdHeader element - - @return SpdHeaderDocument.SpdHeader - **/ - public SpdHeaderDocument.SpdHeader getSpdHdr() { - if (spdHdr == null) { - spdHdr = psaRoot.getSpdHeader(); - } - return spdHdr; - } - - /** - Get Abstract element under tag SpdHeader - - @return AbstractDocument.Abstract - **/ - public String getSpdHdrAbs() { - - return getSpdHdr().getAbstract(); - } - - /** - Set value to Abstract element - - @param abs The value set to Abstract element - **/ - public void setSpdHdrAbs(String abs) { - getSpdHdr().setAbstract(abs); - } - - /** - Set value to Copyright element - - @param cpRit The value set to Copyright element - **/ - public void setSpdHdrCpRit(String cpRit) { - - getSpdHdr().setCopyright(cpRit); - - } - - /** - Set value to Created element - - @param createDate The value set to Created element - **/ - public void setSpdHdrCreateDate(String createDate) { - - getSpdHdr().setCreated(createDate); - - } - - /** - Set value to Description element - - @param des The value set to Description element - **/ - public void setSpdHdrDes(String des) { - getSpdHdr().setDescription(des); - } - - /** - Get Guid element under SpdHdr - - @return GuidDocument.Guid - **/ - public GuidDocument.Guid getSpdHdrGuid() { - if (spdHdrGuid == null) { - spdHdrGuid = getSpdHdr().getGuid(); - } - return spdHdrGuid; - } - - /** - Set value to Guid element - - @param guid The value set to Guid element - **/ - public void setSpdHdrGuid(String guid) { - if (getSpdHdrGuid() != null) { - getSpdHdrGuid().setStringValue(guid); - } else { - spdHdrGuid = getSpdHdr().addNewGuid(); - spdHdrGuid.setStringValue(guid); - } - } - - /** - Get Version element under SpdHdr - - @return String - **/ - public String getSpdHdrVer() { - if (spdHdr != null) - return spdHdr.getVersion() + ""; - else - return null; - } - - /** - Set value to Version element - - @param ver The value set to Version element - **/ - public void setSpdHdrVer(String ver) { - if (spdHdr != null) { - spdHdr.setVersion(ver); - } - - } - - /** - Get License element under SpdHdr - - @return LicenseDocument.License - **/ - public LicenseDocument.License getSpdHdrLicense() { - if (spdHdrLicense == null) { - spdHdrLicense = getSpdHdr().getLicense(); - } - return spdHdrLicense; - } - - /** - Set value to License element - - @param license The value set to License element - **/ - public void setSpdHdrLicense(String license) { - if (getSpdHdrLicense() != null) { - getSpdHdrLicense().setStringValue(license); - } else { - spdHdrLicense = getSpdHdr().addNewLicense(); - spdHdrLicense.setStringValue(license); - } - } - - /** - Reserved method - - @return - **/ - public OutputDirectoryDocument.OutputDirectory getSpdHdrOutDir() { - return spdHdrOutDir; - } - - /** - Reserved method - - @param outdir - **/ - public void setSpdHdrOutDir(String outdir) { - if (outdir == null) { - return; - } - if (getSpdHdrOutDir() != null) { - getSpdHdrOutDir().setStringValue(outdir); - } else { - spdHdrOutDir = getSpdHdr().addNewOutputDirectory(); - spdHdrOutDir.setStringValue(outdir); - } - } - - /** - Get PackageName element under SpdHdr - - @return PackageNameDocument.PackageName - **/ - public String getSpdHdrPkgName() { - if (spdHdrPkgName == null) { - spdHdrPkgName = getSpdHdr().getPackageName(); - } - return spdHdrPkgName; - } - - /** - Set value to PackageName element - - @param pkgName The value set to PackageName element - **/ - public void setSpdHdrPkgName(String pkgName) { - - if (getSpdHdrPkgName() != null) { - getSpdHdr().setPackageName(pkgName); - } else { - getSpdHdr().setPackageName(pkgName); - } - } - - - /** - Reserved method - - @param spec - **/ - public void setSpdHdrSpec(String spec) { - if (spec == null) { - return; - } - - getSpdHdr().setSpecification(spec); - - } - - /** - Set value to PackageType element - - @param pkgType The value set to PackageType element - **/ - public void setSpdHdrPkgType(String pkgType) { - getSpdHdr().setPackageType(PackageType.Enum.forString(pkgType)); - } - - /** - Set value to ReadOnly element - - @param rdOnly The value set to ReadOnly element - **/ - public void setSpdHdrRdOnly(String rdOnly) { - - getSpdHdr().setReadOnly(new Boolean(rdOnly)); - } - - /** - Set value to RePackage element - - @param rePkg The value set to RePackage element - **/ - public void setSpdHdrRePkg(String rePkg) { - - getSpdHdr().setRePackage(new Boolean(rePkg)); - } - - /** - Set value to Updated element - - @param updateDate The value set to Updated element - **/ - public void setSpdHdrUpdateDate(String updateDate) { - getSpdHdr().setUpdated(updateDate); - } - - /** - Set value to URL element - - @param url The value set to URL element - **/ - public void setSpdHdrURL(String url) { - getSpdHdr().setURL(url); - } - - /** - Get xml file - - @return File - **/ - public File getFile() { - return file; - } - - /** - Set file - - @param file File with xml format - **/ - public void setFile(File file) { - this.file = file; - } - -} diff --git a/Tools/Source/PackageEditor/src/org/tianocore/packaging/UpdateAction.java b/Tools/Source/PackageEditor/src/org/tianocore/packaging/UpdateAction.java deleted file mode 100644 index a7ff0160e4..0000000000 --- a/Tools/Source/PackageEditor/src/org/tianocore/packaging/UpdateAction.java +++ /dev/null @@ -1,328 +0,0 @@ -/** @file - Java class UpdateAction is GUI for update spd 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; - -import java.awt.BorderLayout; -import java.awt.Dimension; -import java.awt.Toolkit; - -import javax.swing.JFileChooser; -import javax.swing.JOptionPane; -import javax.swing.JPanel; -import javax.swing.JFrame; -import java.awt.GridLayout; -import java.io.File; - -import javax.swing.JButton; - -/** -GUI for update spd file - -@since PackageEditor 1.0 -**/ -public class UpdateAction extends JFrame { - - static JFrame frame; - - private JPanel jContentPane = null; - - private JButton jButton = null; - - private JButton jButton1 = null; - - private JButton jButton2 = null; - - private JButton jButton3 = null; - - private JButton jButton4 = null; - - private JButton jButton5 = null; - - private JButton jButton6 = null; - - private JButton jButton7 = null; - - private SpdFileContents sfc = null; - - private JFrame pThis = null; // @jve:decl-index=0:visual-constraint="322,10" - - private JButton jButton8 = null; - - private JButton jButton9 = null; - - /** - This is the default constructor - **/ - public UpdateAction(SpdFileContents sfc) { - super(); - initialize(); - this.sfc = sfc; - } - - /** - This method initializes this - - @return void - **/ - private void initialize() { - this.setSize(300, 333); - this.setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); - this.setContentPane(getJContentPane()); - this.setTitle("Please Choose an Action"); - this.centerWindow(); - this.pThis = this; - pThis.setSize(new java.awt.Dimension(316,399)); - } - - /** - Start the window at the center of screen - - **/ - protected void centerWindow(int intWidth, int intHeight) { - Dimension d = Toolkit.getDefaultToolkit().getScreenSize(); - this.setLocation((d.width - intWidth) / 2, (d.height - intHeight) / 2); - } - - /** - Start the window at the center of screen - - **/ - protected void centerWindow() { - centerWindow(this.getSize().width, this.getSize().height); - } - - /** - This method initializes jContentPane - - @return javax.swing.JPanel - **/ - private JPanel getJContentPane() { - if (jContentPane == null) { - GridLayout gridLayout = new GridLayout(); - gridLayout.setRows(10); - gridLayout.setColumns(1); - jContentPane = new JPanel(); - jContentPane.setLayout(gridLayout); - jContentPane.add(getJButton8(), null); - jContentPane.add(getJButton7(), null); - jContentPane.add(getJButton6(), null); - jContentPane.add(getJButton5(), null); - jContentPane.add(getJButton4(), null); - jContentPane.add(getJButton3(), null); - jContentPane.add(getJButton2(), null); - jContentPane.add(getJButton1(), null); - jContentPane.add(getJButton(), null); - jContentPane.add(getJButton9(), null); - } - return jContentPane; - } - - /** - This method initializes jButton - - @return javax.swing.JButton - **/ - private JButton getJButton() { - if (jButton == null) { - jButton = new JButton(); - jButton.setText("Save"); - jButton.addMouseListener(new java.awt.event.MouseAdapter() { - public void mouseClicked(java.awt.event.MouseEvent e) { - JFileChooser chooser = new JFileChooser(sfc.getFile()); - chooser.setMultiSelectionEnabled(false); - - int retval = chooser.showSaveDialog(frame); - if (retval == JFileChooser.APPROVE_OPTION) { - try { - File theFile = chooser.getSelectedFile(); - if (theFile.exists()) { - int retVal = JOptionPane.showConfirmDialog(frame, "Are you sure to replace the exising one?", "File Exists", - JOptionPane.YES_NO_OPTION); - if (retVal == JOptionPane.NO_OPTION) { - return; - } - } - sfc.saveAs(theFile); - - } catch (Exception ee) { - System.out.println(ee.toString()); - } -// pThis.dispose(); - } - - } - }); - } - return jButton; - } - - /** - This method initializes jButton1 - - @return javax.swing.JButton - **/ - private JButton getJButton1() { - if (jButton1 == null) { - jButton1 = new JButton(); - jButton1.setText("Update PCD Information"); - jButton1.addMouseListener(new java.awt.event.MouseAdapter() { - public void mouseClicked(java.awt.event.MouseEvent e) { - ModalFrameUtil.showAsModal(new UpdatePCD(sfc), pThis); - } - }); - } - return jButton1; - } - - /** - This method initializes jButton2 - - @return javax.swing.JButton - **/ - private JButton getJButton2() { - if (jButton2 == null) { - jButton2 = new JButton(); - jButton2.setText("Update PPI Declarations"); - jButton2.addMouseListener(new java.awt.event.MouseAdapter() { - public void mouseClicked(java.awt.event.MouseEvent e) { - ModalFrameUtil.showAsModal(new UpdatePpi(sfc), pThis); - } - }); - } - return jButton2; - } - - /** - This method initializes jButton3 - - @return javax.swing.JButton - **/ - private JButton getJButton3() { - if (jButton3 == null) { - jButton3 = new JButton(); - jButton3.setText("Update Protocol Declarations"); - jButton3.addMouseListener(new java.awt.event.MouseAdapter() { - public void mouseClicked(java.awt.event.MouseEvent e) { - ModalFrameUtil.showAsModal(new UpdateProtocols(sfc), pThis); - } - }); - } - return jButton3; - } - - /** - This method initializes jButton4 - - @return javax.swing.JButton - **/ - private JButton getJButton4() { - if (jButton4 == null) { - jButton4 = new JButton(); - jButton4.setText("Update GUID Declarations"); - jButton4.addMouseListener(new java.awt.event.MouseAdapter() { - public void mouseClicked(java.awt.event.MouseEvent e) { - ModalFrameUtil.showAsModal(new UpdateGuids(sfc), pThis); - } - }); - } - return jButton4; - } - - /** - This method initializes jButton5 - - @return javax.swing.JButton - **/ - private JButton getJButton5() { - if (jButton5 == null) { - jButton5 = new JButton(); - jButton5.setText("Update Package Headers"); - jButton5.addMouseListener(new java.awt.event.MouseAdapter() { - public void mouseClicked(java.awt.event.MouseEvent e) { - ModalFrameUtil.showAsModal(new UpdatePkgHeader(sfc), pThis); - } - }); - } - return jButton5; - } - - /** - This method initializes jButton6 - - @return javax.swing.JButton - **/ - private JButton getJButton6() { - if (jButton6 == null) { - jButton6 = new JButton(); - jButton6.setText("Update MSA Files"); - jButton6.addMouseListener(new java.awt.event.MouseAdapter() { - public void mouseClicked(java.awt.event.MouseEvent e) { - ModalFrameUtil.showAsModal(new UpdateMsaFile(sfc), pThis); - } - }); - } - return jButton6; - } - - /** - This method initializes jButton7 - - @return javax.swing.JButton - **/ - private JButton getJButton7() { - if (jButton7 == null) { - jButton7 = new JButton(); - jButton7.setText("Update Library Classes"); - jButton7.addMouseListener(new java.awt.event.MouseAdapter() { - public void mouseClicked(java.awt.event.MouseEvent e) { - ModalFrameUtil.showAsModal(new UpdateLibraryClass(sfc), pThis); - } - }); - } - return jButton7; - } - - /** - This method initializes jButton8 - - @return javax.swing.JButton - **/ - private JButton getJButton8() { - if (jButton8 == null) { - jButton8 = new JButton(); - jButton8.setText("Update SPD Header"); - jButton8.addMouseListener(new java.awt.event.MouseAdapter() { - public void mouseClicked(java.awt.event.MouseEvent e) { - ModalFrameUtil.showAsModal(new UpdateNew(sfc), pThis); - } - }); - } - return jButton8; - } - - private JButton getJButton9() { - if (jButton9 == null) { - jButton9 = new JButton(); - jButton9.setText("Done"); - jButton9.addMouseListener(new java.awt.event.MouseAdapter() { - public void mouseClicked(java.awt.event.MouseEvent e) { - - pThis.dispose(); - - } - }); - } - return jButton9; - } - -} // @jve:decl-index=0:visual-constraint="104,41" diff --git a/Tools/Source/PackageEditor/src/org/tianocore/packaging/UpdateGuids.java b/Tools/Source/PackageEditor/src/org/tianocore/packaging/UpdateGuids.java deleted file mode 100644 index 6193073473..0000000000 --- a/Tools/Source/PackageEditor/src/org/tianocore/packaging/UpdateGuids.java +++ /dev/null @@ -1,249 +0,0 @@ -/** @file - Java class UpdateGuids is GUI for update GUID declarations in spd 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; - -import javax.swing.JPanel; -import javax.swing.JFrame; -import javax.swing.JLabel; -import javax.swing.JTextField; -import javax.swing.JButton; - -import javax.swing.JScrollPane; -import javax.swing.JTable; -import javax.swing.table.*; - -import org.tianocore.common.Tools; - -import java.awt.Dimension; -import java.awt.Toolkit; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.io.*; - -/** - GUI for update GUID declarations in spd file - - @since PackageEditor 1.0 -**/ -public class UpdateGuids extends JFrame implements ActionListener { - - private JPanel jContentPane = null; - - private JScrollPane jScrollPane = null; - - private JTable jTable = null; - - private SpdFileContents sfc = null; - - private JButton jButtonOk = null; - - private JButton jButtonCancel = null; - - private DefaultTableModel model = null; - - private JButton jButton = null; - - /** - This is the default constructor - **/ - public UpdateGuids(SpdFileContents sfc) { - super(); - this.sfc = sfc; - initialize(); - - } - - public void actionPerformed(ActionEvent arg0) { - if (arg0.getSource() == jButtonOk) { - this.save(); - this.dispose(); - - } - if (arg0.getSource() == jButtonCancel) { - this.dispose(); - - } - if (arg0.getSource() == jButton) { - String[] o = { "", "", "" }; - model.addRow(o); - } - } - - /** - This method initializes this - - @return void - **/ - private void initialize() { - this.setSize(669, 568); - this.setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); - this.setTitle("Update GUID Declarations"); - this.setContentPane(getJContentPane()); - this.centerWindow(); - } - - /** - This method initializes jContentPane - - @return javax.swing.JPanel - **/ - private JPanel getJContentPane() { - if (jContentPane == null) { - jContentPane = new JPanel(); - jContentPane.setLayout(null); - jContentPane.add(getJScrollPane(), null); - jContentPane.add(getJButtonOk(), null); - jContentPane.add(getJButtonCancel(), null); - jContentPane.add(getJButton(), null); - } - return jContentPane; - } - - /** - This method initializes jScrollPane - - @return javax.swing.JScrollPane - **/ - private JScrollPane getJScrollPane() { - if (jScrollPane == null) { - jScrollPane = new JScrollPane(); - jScrollPane.setBounds(new java.awt.Rectangle(38,45,586,315)); - jScrollPane.setViewportView(getJTable()); - } - return jScrollPane; - } - - /** - This method initializes jTable - - @return javax.swing.JTable - **/ - private JTable getJTable() { - if (jTable == null) { - model = new DefaultTableModel(); - jTable = new JTable(model); - jTable.setRowHeight(20); - model.addColumn("Name"); - model.addColumn("C_Name"); - model.addColumn("GUID"); - if (sfc.getSpdGuidDeclarationCount() == 0) { - return jTable; - } - // - // initialize table using SpdFileContents object - // - String[][] saa = new String[sfc.getSpdGuidDeclarationCount()][3]; - sfc.getSpdGuidDeclarations(saa); - int i = 0; - while (i < saa.length) { - model.addRow(saa[i]); - i++; - } - - jTable.getColumnModel().getColumn(2).setCellEditor(new GuidEditor()); - } - return jTable; - } - - /** - Remove original GUID declarations before saving updated ones - **/ - protected void save() { - if (jTable.isEditing()) { - jTable.getCellEditor().stopCellEditing(); - } - sfc.removeSpdGuidDeclaration(); - int rowCount = model.getRowCount(); - int i = 0; - - while (i < rowCount) { - String name = null; - if (model.getValueAt(i, 0) != null) { - name = model.getValueAt(i, 0).toString(); - } - String cName = null; - if (model.getValueAt(i, 1) != null) { - cName = model.getValueAt(i, 1).toString(); - } - String guid = null; - if (model.getValueAt(i, 2) != null) { - guid = model.getValueAt(i, 2).toString(); - } - sfc.genSpdGuidDeclarations(name, cName, guid, null); - i++; - } - } - - /** - This method initializes jButtonOk - - @return javax.swing.JButton - **/ - private JButton getJButtonOk() { - if (jButtonOk == null) { - jButtonOk = new JButton(); - jButtonOk.setText("Ok"); - jButtonOk.setSize(new java.awt.Dimension(84, 20)); - jButtonOk.setLocation(new java.awt.Point(316, 486)); - jButtonOk.addActionListener(this); - } - return jButtonOk; - } - - /** - This method initializes jButtonCancel - - @return javax.swing.JButton - **/ - private JButton getJButtonCancel() { - if (jButtonCancel == null) { - jButtonCancel = new JButton(); - jButtonCancel.setText("Cancel"); - jButtonCancel.setSize(new java.awt.Dimension(82, 20)); - jButtonCancel.setLocation(new java.awt.Point(411, 486)); - jButtonCancel.addActionListener(this); - } - return jButtonCancel; - } - - /** - This method initializes jButton - - @return javax.swing.JButton - **/ - private JButton getJButton() { - if (jButton == null) { - jButton = new JButton(); - jButton.setBounds(new java.awt.Rectangle(219, 487, 78, 18)); - jButton.setText("Insert"); - jButton.addActionListener(this); - } - return jButton; - } - /** - Start the window at the center of screen - - **/ - protected void centerWindow(int intWidth, int intHeight) { - Dimension d = Toolkit.getDefaultToolkit().getScreenSize(); - this.setLocation((d.width - intWidth) / 2, (d.height - intHeight) / 2); - } - - /** - Start the window at the center of screen - - **/ - protected void centerWindow() { - centerWindow(this.getSize().width, this.getSize().height); - } -} // @jve:decl-index=0:visual-constraint="11,7" diff --git a/Tools/Source/PackageEditor/src/org/tianocore/packaging/UpdateLibraryClass.java b/Tools/Source/PackageEditor/src/org/tianocore/packaging/UpdateLibraryClass.java deleted file mode 100644 index 4bd6a13630..0000000000 --- a/Tools/Source/PackageEditor/src/org/tianocore/packaging/UpdateLibraryClass.java +++ /dev/null @@ -1,243 +0,0 @@ -/** @file - Java class UpdateLibraryClass is GUI for update library class in spd 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; - -import javax.swing.JPanel; -import javax.swing.JFrame; -import javax.swing.JLabel; -import javax.swing.JTextField; -import javax.swing.JButton; - -import javax.swing.JScrollPane; -import javax.swing.JTable; -import javax.swing.table.*; - -import org.tianocore.common.Tools; - -import java.awt.Dimension; -import java.awt.Toolkit; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.io.*; - -/** - GUI for update library class in spd file - - @since PackageEditor 1.0 -**/ -public class UpdateLibraryClass extends JFrame implements ActionListener { - - private JPanel jContentPane = null; - - private JScrollPane jScrollPane = null; - - private JTable jTable = null; - - private SpdFileContents sfc = null; - - private JButton jButtonOk = null; - - private JButton jButtonCancel = null; - - private DefaultTableModel model = null; - - private JButton jButton = null; - - /** - This is the default constructor - **/ - public UpdateLibraryClass(SpdFileContents sfc) { - super(); - this.sfc = sfc; - initialize(); - - } - - public void actionPerformed(ActionEvent arg0) { - if (arg0.getSource() == jButtonOk) { - this.save(); - this.dispose(); - - } - if (arg0.getSource() == jButtonCancel) { - this.dispose(); - - } - - if (arg0.getSource() == jButton) { - String[] o = { "", "" }; - model.addRow(o); - } - } - - /** - This method initializes this - - @return void - **/ - private void initialize() { - this.setSize(604, 553); - this.setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); - this.setTitle("Update Library Class Declarations"); - this.setContentPane(getJContentPane()); - this.centerWindow(); - } - /** - Start the window at the center of screen - - **/ - protected void centerWindow(int intWidth, int intHeight) { - Dimension d = Toolkit.getDefaultToolkit().getScreenSize(); - this.setLocation((d.width - intWidth) / 2, (d.height - intHeight) / 2); - } - - /** - Start the window at the center of screen - - **/ - protected void centerWindow() { - centerWindow(this.getSize().width, this.getSize().height); - } - - /** - This method initializes jContentPane - - @return javax.swing.JPanel - **/ - private JPanel getJContentPane() { - if (jContentPane == null) { - jContentPane = new JPanel(); - jContentPane.setLayout(null); - jContentPane.add(getJScrollPane(), null); - jContentPane.add(getJButtonOk(), null); - jContentPane.add(getJButtonCancel(), null); - jContentPane.add(getJButton(), null); - } - return jContentPane; - } - - /** - This method initializes jScrollPane - - @return javax.swing.JScrollPane - **/ - private JScrollPane getJScrollPane() { - if (jScrollPane == null) { - jScrollPane = new JScrollPane(); - jScrollPane.setBounds(new java.awt.Rectangle(38, 45, 453, 419)); - jScrollPane.setViewportView(getJTable()); - } - return jScrollPane; - } - - /** - This method initializes jTable - - @return javax.swing.JTable - **/ - private JTable getJTable() { - if (jTable == null) { - model = new DefaultTableModel(); - jTable = new JTable(model); - jTable.setRowHeight(20); - model.addColumn("LibraryClass"); - model.addColumn("IncludeHeader"); - if (sfc.getSpdLibClassDeclarationCount() == 0) { - return jTable; - } - // - // initialize table using SpdFileContents object - // - String[][] saa = new String[sfc.getSpdLibClassDeclarationCount()][2]; - sfc.getSpdLibClassDeclarations(saa); - int i = 0; - while (i < saa.length) { - model.addRow(saa[i]); - i++; - } - - } - return jTable; - } - - /** - Remove original library classes before saving updated ones - **/ - protected void save() { - if (jTable.isEditing()) { - jTable.getCellEditor().stopCellEditing(); - } - sfc.removeSpdLibClass(); - int rowCount = model.getRowCount(); - int i = 0; - while (i < rowCount) { - String libClass = null; - if (model.getValueAt(i, 0) != null) { - libClass = model.getValueAt(i, 0).toString(); - } - String headerFile = null; - if (model.getValueAt(i, 1) != null) { - headerFile = model.getValueAt(i, 1).toString(); - } - sfc.genSpdLibClassDeclarations(libClass, null, headerFile, null, null, null, null, null, null, null); - i++; - } - } - - /** - This method initializes jButtonOk - - @return javax.swing.JButton - **/ - private JButton getJButtonOk() { - if (jButtonOk == null) { - jButtonOk = new JButton(); - jButtonOk.setText("Ok"); - jButtonOk.setSize(new java.awt.Dimension(84, 20)); - jButtonOk.setLocation(new java.awt.Point(316, 486)); - jButtonOk.addActionListener(this); - } - return jButtonOk; - } - - /** - This method initializes jButtonCancel - - @return javax.swing.JButton - **/ - private JButton getJButtonCancel() { - if (jButtonCancel == null) { - jButtonCancel = new JButton(); - jButtonCancel.setText("Cancel"); - jButtonCancel.setSize(new java.awt.Dimension(82, 20)); - jButtonCancel.setLocation(new java.awt.Point(411, 486)); - jButtonCancel.addActionListener(this); - } - return jButtonCancel; - } - - /** - This method initializes jButton - - @return javax.swing.JButton - **/ - private JButton getJButton() { - if (jButton == null) { - jButton = new JButton(); - jButton.setBounds(new java.awt.Rectangle(221, 486, 79, 19)); - jButton.setText("Insert"); - jButton.addActionListener(this); - } - return jButton; - } -} // @jve:decl-index=0:visual-constraint="11,7" diff --git a/Tools/Source/PackageEditor/src/org/tianocore/packaging/UpdateMsaFile.java b/Tools/Source/PackageEditor/src/org/tianocore/packaging/UpdateMsaFile.java deleted file mode 100644 index 4327fd565d..0000000000 --- a/Tools/Source/PackageEditor/src/org/tianocore/packaging/UpdateMsaFile.java +++ /dev/null @@ -1,237 +0,0 @@ -/** @file - Java class UpdateLibraryClass is GUI for msa files in spd 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; - -import javax.swing.JPanel; -import javax.swing.JFrame; -import javax.swing.JLabel; -import javax.swing.JTextField; -import javax.swing.JButton; - -import javax.swing.JScrollPane; -import javax.swing.JTable; -import javax.swing.table.*; - -import org.tianocore.common.Tools; - -import java.awt.Dimension; -import java.awt.Toolkit; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; - -/** - GUI for msa files in spd file - - @since PackageEditor 1.0 -**/ -public class UpdateMsaFile extends JFrame implements ActionListener { - - private JPanel jContentPane = null; - - private JScrollPane jScrollPane = null; - - private JTable jTable = null; - - private SpdFileContents sfc = null; - - private JButton jButtonOk = null; - - private JButton jButtonCancel = null; - - private DefaultTableModel model = null; - - private JButton jButton = null; - - /** - This is the default constructor - **/ - public UpdateMsaFile(SpdFileContents sfc) { - super(); - this.sfc = sfc; - initialize(); - - } - - public void actionPerformed(ActionEvent arg0) { - if (arg0.getSource() == jButtonOk) { - this.save(); - this.dispose(); - - } - if (arg0.getSource() == jButtonCancel) { - this.dispose(); - - } - if (arg0.getSource() == jButton) { - String[] o = { "" }; - model.addRow(o); - } - } - - /** - This method initializes this - - @return void - **/ - private void initialize() { - this.setSize(604, 553); - this.setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); - this.setTitle("Update MSA Files"); - this.setContentPane(getJContentPane()); - this.centerWindow(); - } - /** - Start the window at the center of screen - - **/ - protected void centerWindow(int intWidth, int intHeight) { - Dimension d = Toolkit.getDefaultToolkit().getScreenSize(); - this.setLocation((d.width - intWidth) / 2, (d.height - intHeight) / 2); - } - - /** - Start the window at the center of screen - - **/ - protected void centerWindow() { - centerWindow(this.getSize().width, this.getSize().height); - } - /** - This method initializes jContentPane - - @return javax.swing.JPanel - **/ - private JPanel getJContentPane() { - if (jContentPane == null) { - jContentPane = new JPanel(); - jContentPane.setLayout(null); - jContentPane.add(getJScrollPane(), null); - jContentPane.add(getJButtonOk(), null); - jContentPane.add(getJButtonCancel(), null); - jContentPane.add(getJButton(), null); - } - return jContentPane; - } - - /** - This method initializes jScrollPane - - @return javax.swing.JScrollPane - **/ - private JScrollPane getJScrollPane() { - if (jScrollPane == null) { - jScrollPane = new JScrollPane(); - jScrollPane.setBounds(new java.awt.Rectangle(38, 45, 453, 419)); - jScrollPane.setViewportView(getJTable()); - } - return jScrollPane; - } - - /** - This method initializes jTable - - @return javax.swing.JTable - **/ - private JTable getJTable() { - if (jTable == null) { - model = new DefaultTableModel(); - jTable = new JTable(model); - jTable.setRowHeight(20); - model.addColumn("MSA File"); - - if (sfc.getSpdMsaFileCount() == 0) { - return jTable; - } - // - // initialize table using SpdFileContents object - // - String[][] saa = new String[sfc.getSpdMsaFileCount()][1]; - sfc.getSpdMsaFiles(saa); - int i = 0; - while (i < saa.length) { - model.addRow(saa[i]); - i++; - } - } - return jTable; - } - - /** - Remove original Msa files before saving updated ones - **/ - protected void save() { - if (jTable.isEditing()) { - jTable.getCellEditor().stopCellEditing(); - } - sfc.removeSpdMsaFile(); - int rowCount = jTable.getRowCount(); - int i = 0; - while (i < rowCount) { - String msaFile = null; - if (jTable.getValueAt(i, 0) != null) { - msaFile = jTable.getValueAt(i, 0).toString(); - } - sfc.genSpdMsaFiles(msaFile, null); - i++; - } - } - - /** - This method initializes jButtonOk - - @return javax.swing.JButton - **/ - private JButton getJButtonOk() { - if (jButtonOk == null) { - jButtonOk = new JButton(); - jButtonOk.setText("Ok"); - jButtonOk.setSize(new java.awt.Dimension(84, 20)); - jButtonOk.setLocation(new java.awt.Point(316, 486)); - jButtonOk.addActionListener(this); - } - return jButtonOk; - } - - /** - This method initializes jButtonCancel - - @return javax.swing.JButton - **/ - private JButton getJButtonCancel() { - if (jButtonCancel == null) { - jButtonCancel = new JButton(); - jButtonCancel.setText("Cancel"); - jButtonCancel.setSize(new java.awt.Dimension(82, 20)); - jButtonCancel.setLocation(new java.awt.Point(411, 486)); - jButtonCancel.addActionListener(this); - } - return jButtonCancel; - } - - /** - This method initializes jButton - - @return javax.swing.JButton - **/ - private JButton getJButton() { - if (jButton == null) { - jButton = new JButton(); - jButton.setBounds(new java.awt.Rectangle(219, 486, 79, 19)); - jButton.setText("Insert"); - jButton.addActionListener(this); - } - return jButton; - } - -} // @jve:decl-index=0:visual-constraint="11,7" - diff --git a/Tools/Source/PackageEditor/src/org/tianocore/packaging/UpdateNew.java b/Tools/Source/PackageEditor/src/org/tianocore/packaging/UpdateNew.java deleted file mode 100644 index 46ba748784..0000000000 --- a/Tools/Source/PackageEditor/src/org/tianocore/packaging/UpdateNew.java +++ /dev/null @@ -1,573 +0,0 @@ -/** @file - Java class UpdateNew is GUI for SpdHeader in spd 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; - -import java.awt.Dimension; -import java.awt.Toolkit; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.text.SimpleDateFormat; -import java.util.Date; - -import javax.swing.JFrame; -import javax.swing.JPanel; -import javax.swing.JLabel; -import javax.swing.JTextField; -import javax.swing.JButton; -import javax.swing.JTextArea; -import javax.swing.JScrollPane; - -import javax.swing.JComboBox; - -import org.tianocore.common.Tools; -import org.tianocore.packaging.common.ui.StarLabel; - -/** - GUI for update SpdHeader contents - - @since PackageEditor 1.0 -**/ -public class UpdateNew extends JFrame implements ActionListener { - - private JPanel jContentPane = null; // @jve:decl-index=0:visual-constraint="128,4" - - 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 JLabel jLabelAbstract = null; - - private JTextField jTextFieldAbstract = null; - - private JLabel jLabelModuleType = null; - - private JLabel jLabelCompontentType = null; - - private JComboBox jComboBox1 = 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 JLabel jLabelURL = null; - - private JTextField jTextFieldAbstractURL = null; - - private JLabel jLabel = null; - - private JComboBox jComboBox = null; - - private SpdFileContents sfc = null; - - private String createTime = null; - - /** - This method initializes this - - **/ - private void initialize() { - this.setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); - - } - - /** - This method initializes jTextFieldBaseName - - @return javax.swing.JTextField - **/ - 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 - **/ - 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 - **/ - 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 - **/ - 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 - **/ - private JTextArea getJTextAreaLicense() { - if (jTextAreaLicense == null) { - jTextAreaLicense = new JTextArea(); - jTextAreaLicense.setText(""); - jTextAreaLicense.setLineWrap(true); - } - return jTextAreaLicense; - } - - /** - This method initializes jTextAreaCopyright - - @return javax.swing.JTextArea - **/ - private JTextArea getJTextAreaCopyright() { - if (jTextAreaCopyright == null) { - jTextAreaCopyright = new JTextArea(); - jTextAreaCopyright.setLineWrap(true); - } - return jTextAreaCopyright; - } - - /** - This method initializes jTextAreaDescription - - @return javax.swing.JTextArea - **/ - private JTextArea getJTextAreaDescription() { - if (jTextAreaDescription == null) { - jTextAreaDescription = new JTextArea(); - jTextAreaDescription.setLineWrap(true); - } - return jTextAreaDescription; - } - - /** - This method initializes jButtonNext - - @return javax.swing.JButton - **/ - private JButton getJButtonOk() { - if (jButtonOk == null) { - jButtonOk = new JButton(); - jButtonOk.setText("OK"); - jButtonOk.setBounds(new java.awt.Rectangle(290, 481, 90, 20)); - jButtonOk.addActionListener(this); - } - return jButtonOk; - } - - /** - This method initializes jButtonCancel - - @return javax.swing.JButton - **/ - private JButton getJButtonCancel() { - if (jButtonCancel == null) { - jButtonCancel = new JButton(); - jButtonCancel.setText("Cancel"); - jButtonCancel.setBounds(new java.awt.Rectangle(390, 481, 90, 20)); - jButtonCancel.addActionListener(this); - } - return jButtonCancel; - } - - /** - This method initializes jScrollPane - - @return javax.swing.JScrollPane - **/ - 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 jScrollPane1 - - @return javax.swing.JScrollPane - **/ - private JScrollPane getJScrollPaneCopyright() { - if (jScrollPaneCopyright == null) { - jScrollPaneCopyright = new JScrollPane(); - jScrollPaneCopyright.setBounds(new java.awt.Rectangle(160,170,320,26)); - jScrollPaneCopyright.setViewportView(getJTextAreaCopyright()); - jScrollPaneCopyright.setHorizontalScrollBarPolicy(javax.swing.JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); - } - return jScrollPaneCopyright; - } - - /** - This method initializes jScrollPane2 - - @return javax.swing.JScrollPane - **/ - private JScrollPane getJScrollPaneDescription() { - if (jScrollPaneDescription == null) { - jScrollPaneDescription = new JScrollPane(); - jScrollPaneDescription.setBounds(new java.awt.Rectangle(160, 322, 320, 80)); - jScrollPaneDescription.setViewportView(getJTextAreaDescription()); - jScrollPaneDescription.setHorizontalScrollBarPolicy(javax.swing.JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); - } - return jScrollPaneDescription; - } - - /** - This method initializes jTextFieldAbstract - - @return javax.swing.JTextField - **/ - private JTextField getJTextFieldAbstract() { - if (jTextFieldAbstract == null) { - jTextFieldAbstract = new JTextField(); - jTextFieldAbstract.setBounds(new java.awt.Rectangle(161,216,318,73)); - } - return jTextFieldAbstract; - } - - /** - This method initializes jComboBoxCompontentType - - @return javax.swing.JComboBox - **/ - private JComboBox getJComboBox1() { - if (jComboBox1 == null) { - jComboBox1 = new JComboBox(); - jComboBox1.setBounds(new java.awt.Rectangle(160, 465, 91, 20)); - } - return jComboBox1; - } - - /** - This method initializes jComboBoxModuleType - - @return javax.swing.JComboBox - **/ - private JComboBox getJComboBoxModuleType() { - if (jComboBoxModuleType == null) { - jComboBoxModuleType = new JComboBox(); - jComboBoxModuleType.setBounds(new java.awt.Rectangle(160, 440, 91, 20)); - } - return jComboBoxModuleType; - } - - /** - This method initializes jTextFieldAbstractURL - - @return javax.swing.JTextField - **/ - private JTextField getJTextFieldAbstractURL() { - if (jTextFieldAbstractURL == null) { - jTextFieldAbstractURL = new JTextField(); - jTextFieldAbstractURL.setBounds(new java.awt.Rectangle(159, 414, 320, 20)); - } - return jTextFieldAbstractURL; - } - - public UpdateNew(SpdFileContents sfc) { - super(); - initialize(); - init(); - this.setVisible(true); - this.sfc = sfc; - initShow(); - } - - /** - Start the window at the center of screen - - **/ - protected void centerWindow(int intWidth, int intHeight) { - Dimension d = Toolkit.getDefaultToolkit().getScreenSize(); - this.setLocation((d.width - intWidth) / 2, (d.height - intHeight) / 2); - } - - /** - Start the window at the center of screen - - **/ - protected void centerWindow() { - centerWindow(this.getSize().width, this.getSize().height); - } - - /** - This method initializes this - - @return void - **/ - private void init() { - this.setSize(500, 560); - this.setContentPane(getJContentPane()); - this.setTitle("SPD File Header"); - this.centerWindow(); - //this.getRootPane().setDefaultButton(jButtonOk); - initFrame(); - } - - /** - This method initializes jContentPane - - @return javax.swing.JPanel - **/ - private JPanel getJContentPane() { - if (jContentPane == null) { - jLabel = new JLabel(); - jLabel.setBounds(new java.awt.Rectangle(15, 490, 140, 21)); - jLabel.setText("Re-Package"); - jLabelURL = new JLabel(); - jLabelURL.setBounds(new java.awt.Rectangle(16, 414, 25, 20)); - jLabelURL.setText("URL"); - jLabelCompontentType = new JLabel(); - jLabelCompontentType.setBounds(new java.awt.Rectangle(15, 465, 140, 20)); - jLabelCompontentType.setText("Read Only"); - jLabelModuleType = new JLabel(); - jLabelModuleType.setBounds(new java.awt.Rectangle(15, 440, 140, 20)); - jLabelModuleType.setText("Package Type"); - jLabelAbstract = new JLabel(); - jLabelAbstract.setBounds(new java.awt.Rectangle(17,216,140,20)); - jLabelAbstract.setText("Abstract"); - jLabelDescription = new JLabel(); - jLabelDescription.setText("Description"); - jLabelDescription.setBounds(new java.awt.Rectangle(16, 325, 140, 20)); - jLabelCopyright = new JLabel(); - jLabelCopyright.setText("Copyright"); - jLabelCopyright.setBounds(new java.awt.Rectangle(15, 171, 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("Package 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); - jContentPane.add(jLabelAbstract, null); - jContentPane.add(getJTextFieldAbstract(), null); - jContentPane.add(jLabelModuleType, null); - jContentPane.add(jLabelCompontentType, null); - jContentPane.add(getJComboBox1(), 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, 171)); - jStarLabel6 = new StarLabel(); - jStarLabel6.setLocation(new java.awt.Point(1, 325)); - jStarLabel7 = new StarLabel(); - jStarLabel7.setLocation(new java.awt.Point(2,216)); - jStarLabel8 = new StarLabel(); - jStarLabel8.setLocation(new java.awt.Point(0, 440)); - - 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(jLabelURL, null); - jContentPane.add(getJTextFieldAbstractURL(), null); - jContentPane.add(jLabel, null); - jContentPane.add(getJComboBox(), null); - } - return jContentPane; - } - - public void actionPerformed(ActionEvent arg0) { - if (arg0.getSource() == jButtonOk) { - this.save(); - this.dispose(); - - } - if (arg0.getSource() == jButtonCancel) { - this.dispose(); - - } - if (arg0.getSource() == jButtonGenerateGuid) { - jTextFieldGuid.setText(Tools.generateUuidString()); - } - } - - /** - Save all components of Msa Header, update time modified. - - **/ - private void save() { - // sfc.removeSpdHdr(); - SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm"); - Date date = new Date(); - sfc.genSpdHeader(jTextFieldBaseName.getText(), jTextFieldGuid.getText(), jTextFieldVersion.getText(), - jTextFieldAbstract.getText(), jTextAreaDescription.getText(), jTextAreaCopyright.getText(), - jTextAreaLicense.getText(), createTime, format.format(date), jTextFieldAbstractURL.getText(), - jComboBoxModuleType.getSelectedItem().toString(), jComboBox1.getSelectedItem().toString(), - jComboBox.getSelectedItem().toString(), null, null); - // ModalFrameUtil.showAsModal(new PackageAction(sfc), pThis); - } - - /** - This method initializes module type and compontent type - - **/ - private void initFrame() { - jComboBoxModuleType.addItem("SOURCE"); - jComboBoxModuleType.addItem("BINARY"); - jComboBoxModuleType.addItem("MIXED"); - - jComboBox1.addItem("true"); - jComboBox1.addItem("false"); - - jComboBox.addItem("false"); - jComboBox.addItem("true"); - - } - - /** - Display original SpdHeader contents during init - **/ - private void initShow() { - String[] s = new String[12]; - - sfc.getSpdHdrDetails(s); - jTextFieldBaseName.setText(s[0]); - jTextFieldGuid.setText(s[1]); - jTextFieldVersion.setText(s[2]); - jTextFieldAbstract.setText(s[3]); - jTextAreaDescription.setText(s[4]); - jTextAreaCopyright.setText(s[5]); - jTextAreaLicense.setText(s[6]); - createTime = s[7]; - jTextFieldAbstractURL.setText(s[8]); - jComboBoxModuleType.setSelectedItem(s[9]); - jComboBox1.setSelectedIndex(s[10].equals("true") ? 0 : 1); - jComboBox.setSelectedIndex(s[11].equals("true") ? 0 : 1); - - } - - /** - This method initializes jComboBox - - @return javax.swing.JComboBox - **/ - private JComboBox getJComboBox() { - if (jComboBox == null) { - jComboBox = new JComboBox(); - jComboBox.setBounds(new java.awt.Rectangle(160, 490, 90, 20)); - } - return jComboBox; - } - -} // @jve:decl-index=0:visual-constraint="38,-22" diff --git a/Tools/Source/PackageEditor/src/org/tianocore/packaging/UpdatePCD.java b/Tools/Source/PackageEditor/src/org/tianocore/packaging/UpdatePCD.java deleted file mode 100644 index 765e331432..0000000000 --- a/Tools/Source/PackageEditor/src/org/tianocore/packaging/UpdatePCD.java +++ /dev/null @@ -1,277 +0,0 @@ -/** @file - Java class UpdatePCD is GUI for update PCD definitions in spd 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; - -import javax.swing.DefaultCellEditor; -import javax.swing.JComboBox; -import javax.swing.JPanel; -import javax.swing.JFrame; -import javax.swing.JLabel; -import javax.swing.JTextField; -import javax.swing.JButton; - -import javax.swing.JScrollPane; -import javax.swing.JTable; -import javax.swing.table.*; - -import org.tianocore.common.Tools; - -import java.awt.Dimension; -import java.awt.Toolkit; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.io.*; - -/** - GUI for update PCD definitions in spd file - - @since PackageEditor 1.0 -**/ -public class UpdatePCD extends JFrame implements ActionListener { - - private JPanel jContentPane = null; - - private SpdFileContents sfc = null; - - private JButton jButtonOk = null; - - private JButton jButtonCancel = null; - - private DefaultTableModel model = null; - - private String[][] saa = null; - - private JScrollPane jScrollPane = null; - - private JTable jTable = null; - - private JButton jButton = null; - - /** - This is the default constructor - **/ - public UpdatePCD(SpdFileContents sfc) { - super(); - this.sfc = sfc; - initialize(); - - } - - public void actionPerformed(ActionEvent arg0) { - if (arg0.getSource() == jButtonOk) { - this.save(); - this.dispose(); - - } - if (arg0.getSource() == jButtonCancel) { - this.dispose(); - - } - if (arg0.getSource() == jButton) { - String[] o = { "FEATURE_FLAG", "", "", "UINT8", "0" }; - model.addRow(o); - } - - } - - /** - This method initializes this - - @return void - **/ - private void initialize() { - this.setSize(916, 486); - this.setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); - this.setTitle("Update PCD Definitions"); - this.setContentPane(getJContentPane()); - this.centerWindow(); - } - /** - Start the window at the center of screen - - **/ - protected void centerWindow(int intWidth, int intHeight) { - Dimension d = Toolkit.getDefaultToolkit().getScreenSize(); - this.setLocation((d.width - intWidth) / 2, (d.height - intHeight) / 2); - } - - /** - Start the window at the center of screen - - **/ - protected void centerWindow() { - centerWindow(this.getSize().width, this.getSize().height); - } - /** - This method initializes jContentPane - - @return javax.swing.JPanel - **/ - private JPanel getJContentPane() { - if (jContentPane == null) { - jContentPane = new JPanel(); - jContentPane.setLayout(null); - jContentPane.add(getJButtonOk(), null); - jContentPane.add(getJButtonCancel(), null); - jContentPane.add(getJScrollPane(), null); - jContentPane.add(getJButton(), null); - } - return jContentPane; - } - - /** - Remove original Pcd definitions before saving updated ones - **/ - protected void save() { - if (jTable.isEditing()) { - jTable.getCellEditor().stopCellEditing(); - } - sfc.removeSpdPcdDefinition(); - int rowCount = model.getRowCount(); - int i = 0; - while (i < rowCount) { - String cName = null; - if (model.getValueAt(i, 1) != null) { - cName = model.getValueAt(i, 1).toString(); - } - String token = null; - if (model.getValueAt(i, 2) != null) { - token = model.getValueAt(i, 2).toString(); - } - String defaultVal = null; - if (model.getValueAt(i, 4) != null) { - defaultVal = model.getValueAt(i, 4).toString(); - } - sfc.genSpdPcdDefinitions(model.getValueAt(i, 0).toString(), cName, token, - model.getValueAt(i, 3).toString(), null, null, null, null, null, null, defaultVal); - i++; - } - } - - /** - This method initializes jButtonOk - - @return javax.swing.JButton - **/ - private JButton getJButtonOk() { - if (jButtonOk == null) { - jButtonOk = new JButton(); - jButtonOk.setText("Ok"); - jButtonOk.setSize(new java.awt.Dimension(84, 20)); - jButtonOk.setLocation(new java.awt.Point(605, 404)); - jButtonOk.addActionListener(this); - } - return jButtonOk; - } - - /** - This method initializes jButtonCancel - - @return javax.swing.JButton - **/ - private JButton getJButtonCancel() { - if (jButtonCancel == null) { - jButtonCancel = new JButton(); - jButtonCancel.setText("Cancel"); - jButtonCancel.setSize(new java.awt.Dimension(82, 20)); - jButtonCancel.setLocation(new java.awt.Point(712, 404)); - jButtonCancel.addActionListener(this); - } - return jButtonCancel; - } - - /** - This method initializes jScrollPane - - @return javax.swing.JScrollPane - **/ - private JScrollPane getJScrollPane() { - if (jScrollPane == null) { - jScrollPane = new JScrollPane(); - jScrollPane.setHorizontalScrollBarPolicy(javax.swing.JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); - jScrollPane.setBounds(new java.awt.Rectangle(51, 62, 782, 304)); - jScrollPane.setViewportView(getJTable2()); - } - return jScrollPane; - } - - /** - This method initializes jTable - - @return javax.swing.JTable - **/ - private JTable getJTable2() { - if (jTable == null) { - model = new DefaultTableModel(); - jTable = new JTable(model); - jTable.setRowHeight(20); - model.addColumn("ItemType"); - model.addColumn("C_Name"); - model.addColumn("Token"); - model.addColumn("DataType"); - model.addColumn("DefaultValue"); - // - // Using combobox to display ItemType in table - // - JComboBox jComboBoxItemType = new JComboBox(); - jComboBoxItemType.addItem("FEATURE_FLAG"); - jComboBoxItemType.addItem("FIXED_AT_BUILD"); - jComboBoxItemType.addItem("PATCHABLE_IN_MODULE"); - jComboBoxItemType.addItem("DYNAMIC"); - jComboBoxItemType.addItem("DYNAMIC_EX"); - TableColumn itemTypeColumn = jTable.getColumnModel().getColumn(0); - itemTypeColumn.setCellEditor(new DefaultCellEditor(jComboBoxItemType)); - // - // Using combobox to display data type in table - // - JComboBox jComboBoxDataType = new JComboBox(); - jComboBoxDataType.addItem("UINT8"); - jComboBoxDataType.addItem("UINT16"); - jComboBoxDataType.addItem("UINT32"); - jComboBoxDataType.addItem("UINT64"); - jComboBoxDataType.addItem("VOID*"); - jComboBoxDataType.addItem("BOOLEAN"); - TableColumn dataTypeColumn = jTable.getColumnModel().getColumn(3); - dataTypeColumn.setCellEditor(new DefaultCellEditor(jComboBoxDataType)); - - if (sfc.getSpdPcdDefinitionCount() == 0) { - - return jTable; - } - saa = new String[sfc.getSpdPcdDefinitionCount()][5]; - sfc.getSpdPcdDefinitions(saa); - int i = 0; - while (i < saa.length) { - model.addRow(saa[i]); - i++; - } - - } - return jTable; - } - - /** - This method initializes jButton - - @return javax.swing.JButton - **/ - private JButton getJButton() { - if (jButton == null) { - jButton = new JButton(); - jButton.setBounds(new java.awt.Rectangle(499, 404, 77, 20)); - jButton.setText("Insert"); - jButton.addActionListener(this); - } - return jButton; - } -} // @jve:decl-index=0:visual-constraint="11,7" diff --git a/Tools/Source/PackageEditor/src/org/tianocore/packaging/UpdatePkgHeader.java b/Tools/Source/PackageEditor/src/org/tianocore/packaging/UpdatePkgHeader.java deleted file mode 100644 index 5f9356cf8d..0000000000 --- a/Tools/Source/PackageEditor/src/org/tianocore/packaging/UpdatePkgHeader.java +++ /dev/null @@ -1,257 +0,0 @@ -/** @file - Java class UpdatePkgHeader is GUI for update Package Header in spd 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; - -import javax.swing.DefaultCellEditor; -import javax.swing.JComboBox; -import javax.swing.JPanel; -import javax.swing.JFrame; -import javax.swing.JLabel; -import javax.swing.JTextField; -import javax.swing.JButton; - -import javax.swing.JScrollPane; -import javax.swing.JTable; -import javax.swing.table.*; - -import org.tianocore.common.Tools; - -import java.awt.Dimension; -import java.awt.Toolkit; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.io.*; - -/** - GUI for update Package Header in spd file - - @since PackageEditor 1.0 -**/ -public class UpdatePkgHeader extends JFrame implements ActionListener { - - private JPanel jContentPane = null; - - private JScrollPane jScrollPane = null; - - private JTable jTable = null; - - private SpdFileContents sfc = null; - - private JButton jButtonOk = null; - - private JButton jButtonCancel = null; - - private DefaultTableModel model = null; - - private JButton jButton = null; - - /** - This is the default constructor - **/ - public UpdatePkgHeader(SpdFileContents sfc) { - super(); - this.sfc = sfc; - initialize(); - - } - - public void actionPerformed(ActionEvent arg0) { - if (arg0.getSource() == jButtonOk) { - this.save(); - this.dispose(); - - } - if (arg0.getSource() == jButtonCancel) { - this.dispose(); - - } - - if (arg0.getSource() == jButton) { - String[] o = { "BASE", "" }; - model.addRow(o); - } - } - - /** - This method initializes this - - @return void - **/ - private void initialize() { - this.setSize(604, 553); - this.setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); - this.setTitle("Update Package Headers"); - this.setContentPane(getJContentPane()); - this.centerWindow(); - } - /** - Start the window at the center of screen - - **/ - protected void centerWindow(int intWidth, int intHeight) { - Dimension d = Toolkit.getDefaultToolkit().getScreenSize(); - this.setLocation((d.width - intWidth) / 2, (d.height - intHeight) / 2); - } - - /** - Start the window at the center of screen - - **/ - protected void centerWindow() { - centerWindow(this.getSize().width, this.getSize().height); - } - /** - This method initializes jContentPane - - @return javax.swing.JPanel - **/ - private JPanel getJContentPane() { - if (jContentPane == null) { - jContentPane = new JPanel(); - jContentPane.setLayout(null); - jContentPane.add(getJScrollPane(), null); - jContentPane.add(getJButtonOk(), null); - jContentPane.add(getJButtonCancel(), null); - jContentPane.add(getJButton(), null); - } - return jContentPane; - } - - /** - This method initializes jScrollPane - - @return javax.swing.JScrollPane - **/ - private JScrollPane getJScrollPane() { - if (jScrollPane == null) { - jScrollPane = new JScrollPane(); - jScrollPane.setBounds(new java.awt.Rectangle(38, 45, 453, 419)); - jScrollPane.setViewportView(getJTable()); - } - return jScrollPane; - } - - /** - This method initializes jTable - - @return javax.swing.JTable - **/ - private JTable getJTable() { - if (jTable == null) { - model = new DefaultTableModel(); - jTable = new JTable(model); - jTable.setRowHeight(20); - model.addColumn("ModuleType"); - model.addColumn("IncludeHeader"); - // - // Using combobox to display ModuleType in table - // - TableColumn typeColumn = jTable.getColumnModel().getColumn(0); - JComboBox jComboBoxSelect = new JComboBox(); - jComboBoxSelect.addItem("BASE"); - jComboBoxSelect.addItem("SEC"); - jComboBoxSelect.addItem("PEI_CORE"); - jComboBoxSelect.addItem("PEIM"); - jComboBoxSelect.addItem("DXE_CORE"); - jComboBoxSelect.addItem("DXE_DRIVER"); - jComboBoxSelect.addItem("DXE_RUNTIME_DRIVER"); - jComboBoxSelect.addItem("DXE_SAL_DRIVER"); - jComboBoxSelect.addItem("DXE_SMM_DRIVER"); - jComboBoxSelect.addItem("TOOLS"); - jComboBoxSelect.addItem("UEFI_DRIVER"); - jComboBoxSelect.addItem("UEFI_APPLICATION"); - jComboBoxSelect.addItem("USER_DEFINED"); - typeColumn.setCellEditor(new DefaultCellEditor(jComboBoxSelect)); - - if (sfc.getSpdPackageHeaderCount() == 0) { - return jTable; - } - String[][] saa = new String[sfc.getSpdPackageHeaderCount()][2]; - sfc.getSpdPackageHeaders(saa); - int i = 0; - while (i < saa.length) { - model.addRow(saa[i]); - i++; - } - - } - return jTable; - } - - /** - Remove original package headers before saving updated ones - **/ - protected void save() { - if (jTable.isEditing()) { - jTable.getCellEditor().stopCellEditing(); - } - sfc.removeSpdPkgHeader(); - int rowCount = model.getRowCount(); - int i = 0; - while (i < rowCount) { - String headFile = null; - if (model.getValueAt(i, 1) != null) { - headFile = model.getValueAt(i, 1).toString(); - } - sfc.genSpdModuleHeaders(model.getValueAt(i, 0).toString(), headFile, null, null, null, null, null, null); - i++; - } - } - - /** - This method initializes jButtonOk - - @return javax.swing.JButton - **/ - private JButton getJButtonOk() { - if (jButtonOk == null) { - jButtonOk = new JButton(); - jButtonOk.setText("Ok"); - jButtonOk.setSize(new java.awt.Dimension(84, 20)); - jButtonOk.setLocation(new java.awt.Point(316, 486)); - jButtonOk.addActionListener(this); - } - return jButtonOk; - } - - /** - This method initializes jButtonCancel - - @return javax.swing.JButton - **/ - private JButton getJButtonCancel() { - if (jButtonCancel == null) { - jButtonCancel = new JButton(); - jButtonCancel.setText("Cancel"); - jButtonCancel.setSize(new java.awt.Dimension(82, 20)); - jButtonCancel.setLocation(new java.awt.Point(411, 486)); - jButtonCancel.addActionListener(this); - } - return jButtonCancel; - } - - /** - This method initializes jButton - - @return javax.swing.JButton - **/ - private JButton getJButton() { - if (jButton == null) { - jButton = new JButton(); - jButton.setBounds(new java.awt.Rectangle(220, 486, 85, 20)); - jButton.setText("Insert"); - jButton.addActionListener(this); - } - return jButton; - } -} // @jve:decl-index=0:visual-constraint="11,7" diff --git a/Tools/Source/PackageEditor/src/org/tianocore/packaging/UpdatePpi.java b/Tools/Source/PackageEditor/src/org/tianocore/packaging/UpdatePpi.java deleted file mode 100644 index be58e1c848..0000000000 --- a/Tools/Source/PackageEditor/src/org/tianocore/packaging/UpdatePpi.java +++ /dev/null @@ -1,248 +0,0 @@ -/** @file - Java class UpdatePpi is GUI for update Ppi declarations in spd 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; - -import javax.swing.JPanel; -import javax.swing.JFrame; -import javax.swing.JLabel; -import javax.swing.JTextField; -import javax.swing.JButton; - -import javax.swing.JScrollPane; -import javax.swing.JTable; -import javax.swing.table.*; - -import org.tianocore.common.Tools; - -import java.awt.Dimension; -import java.awt.Toolkit; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.io.*; - -/** - GUI for update Ppi declarations in spd file. - - @since PackageEditor 1.0 -**/ -public class UpdatePpi extends JFrame implements ActionListener { - - private JPanel jContentPane = null; - - private JScrollPane jScrollPane = null; - - private JTable jTable = null; - - private SpdFileContents sfc = null; - - private JButton jButtonOk = null; - - private JButton jButtonCancel = null; - - private DefaultTableModel model = null; - - private JButton jButton = null; - - /** - This is the default constructor - **/ - public UpdatePpi(SpdFileContents sfc) { - super(); - this.sfc = sfc; - initialize(); - - } - - public void actionPerformed(ActionEvent arg0) { - if (arg0.getSource() == jButtonOk) { - this.save(); - this.dispose(); - - } - if (arg0.getSource() == jButtonCancel) { - this.dispose(); - - } - - if (arg0.getSource() == jButton) { - String[] o = { "", "", "" }; - model.addRow(o); - } - } - - /** - This method initializes this - - @return void - **/ - private void initialize() { - this.setSize(604, 553); - this.setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); - this.setTitle("Update PPI Declarations"); - this.setContentPane(getJContentPane()); - this.centerWindow(); - } - /** - Start the window at the center of screen - - **/ - protected void centerWindow(int intWidth, int intHeight) { - Dimension d = Toolkit.getDefaultToolkit().getScreenSize(); - this.setLocation((d.width - intWidth) / 2, (d.height - intHeight) / 2); - } - - /** - Start the window at the center of screen - - **/ - protected void centerWindow() { - centerWindow(this.getSize().width, this.getSize().height); - } - /** - This method initializes jContentPane - - @return javax.swing.JPanel - **/ - private JPanel getJContentPane() { - if (jContentPane == null) { - jContentPane = new JPanel(); - jContentPane.setLayout(null); - jContentPane.add(getJScrollPane(), null); - jContentPane.add(getJButtonOk(), null); - jContentPane.add(getJButtonCancel(), null); - jContentPane.add(getJButton(), null); - } - return jContentPane; - } - - /** - This method initializes jScrollPane - - @return javax.swing.JScrollPane - **/ - private JScrollPane getJScrollPane() { - if (jScrollPane == null) { - jScrollPane = new JScrollPane(); - jScrollPane.setBounds(new java.awt.Rectangle(38, 45, 453, 419)); - jScrollPane.setViewportView(getJTable()); - } - return jScrollPane; - } - - /** - This method initializes jTable - - @return javax.swing.JTable - **/ - private JTable getJTable() { - if (jTable == null) { - model = new DefaultTableModel(); - jTable = new JTable(model); - jTable.setRowHeight(20); - model.addColumn("Name"); - model.addColumn("C_Name"); - model.addColumn("GUID"); - // - // initialize table using SpdFileContents object - // - if (sfc.getSpdPpiDeclarationCount() == 0) { - return jTable; - } - String[][] saa = new String[sfc.getSpdPpiDeclarationCount()][3]; - sfc.getSpdPpiDeclarations(saa); - int i = 0; - while (i < saa.length) { - model.addRow(saa[i]); - i++; - } - - jTable.getColumnModel().getColumn(2).setCellEditor(new GuidEditor()); - } - return jTable; - } - - /** - Remove original ppi declarations before saving updated ones - **/ - protected void save() { - if (jTable.isEditing()) { - jTable.getCellEditor().stopCellEditing(); - } - sfc.removeSpdPpiDeclaration(); - int rowCount = model.getRowCount(); - int i = 0; - while (i < rowCount) { - String name = null; - if (model.getValueAt(i, 0) != null) { - name = model.getValueAt(i, 0).toString(); - } - String cName = null; - if (model.getValueAt(i, 1) != null) { - cName = model.getValueAt(i, 1).toString(); - } - String guid = null; - if (model.getValueAt(i, 2) != null) { - guid = model.getValueAt(i, 2).toString(); - } - sfc.genSpdPpiDeclarations(name, cName, guid, null); - i++; - } - } - - /** - This method initializes jButtonOk - - @return javax.swing.JButton - **/ - private JButton getJButtonOk() { - if (jButtonOk == null) { - jButtonOk = new JButton(); - jButtonOk.setText("Ok"); - jButtonOk.setSize(new java.awt.Dimension(84, 20)); - jButtonOk.setLocation(new java.awt.Point(316, 486)); - jButtonOk.addActionListener(this); - } - return jButtonOk; - } - - /** - This method initializes jButtonCancel - - @return javax.swing.JButton - **/ - private JButton getJButtonCancel() { - if (jButtonCancel == null) { - jButtonCancel = new JButton(); - jButtonCancel.setText("Cancel"); - jButtonCancel.setSize(new java.awt.Dimension(82, 20)); - jButtonCancel.setLocation(new java.awt.Point(411, 486)); - jButtonCancel.addActionListener(this); - } - return jButtonCancel; - } - - /** - This method initializes jButton - - @return javax.swing.JButton - **/ - private JButton getJButton() { - if (jButton == null) { - jButton = new JButton(); - jButton.setBounds(new java.awt.Rectangle(224, 488, 72, 18)); - jButton.setText("Insert"); - jButton.addActionListener(this); - } - return jButton; - } -} // @jve:decl-index=0:visual-constraint="11,7" diff --git a/Tools/Source/PackageEditor/src/org/tianocore/packaging/UpdateProtocols.java b/Tools/Source/PackageEditor/src/org/tianocore/packaging/UpdateProtocols.java deleted file mode 100644 index 4408ec1ffc..0000000000 --- a/Tools/Source/PackageEditor/src/org/tianocore/packaging/UpdateProtocols.java +++ /dev/null @@ -1,250 +0,0 @@ -/** @file - Java class UpdateProtocols is GUI for update protocol declarations in spd 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; - -import javax.swing.JPanel; -import javax.swing.JFrame; -import javax.swing.JLabel; -import javax.swing.JTextField; -import javax.swing.JButton; - -import javax.swing.JScrollPane; -import javax.swing.JTable; -import javax.swing.table.*; - -import org.tianocore.common.Tools; - -import java.awt.Dimension; -import java.awt.Toolkit; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.io.*; - -/** - GUI for update protocol declarations in spd file - - @since PackageEditor 1.0 -**/ -public class UpdateProtocols extends JFrame implements ActionListener { - - private JPanel jContentPane = null; - - private JScrollPane jScrollPane = null; - - private JTable jTable = null; - - private SpdFileContents sfc = null; - - private JButton jButtonOk = null; - - private JButton jButtonCancel = null; - - private DefaultTableModel model = null; - - private JButton jButton = null; - - /** - This is the default constructor - **/ - public UpdateProtocols(SpdFileContents sfc) { - super(); - this.sfc = sfc; - initialize(); - - } - - public void actionPerformed(ActionEvent arg0) { - if (arg0.getSource() == jButtonOk) { - this.save(); - this.dispose(); - - } - if (arg0.getSource() == jButtonCancel) { - this.dispose(); - - } - - if (arg0.getSource() == jButton) { - String[] o = { "", "", "" }; - model.addRow(o); - } - } - - /** - This method initializes this - - @return void - **/ - private void initialize() { - this.setSize(604, 553); - this.setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); - this.setTitle("Update Protocol Declarations"); - this.setContentPane(getJContentPane()); - this.centerWindow(); - } - - /** - Start the window at the center of screen - - **/ - protected void centerWindow(int intWidth, int intHeight) { - Dimension d = Toolkit.getDefaultToolkit().getScreenSize(); - this.setLocation((d.width - intWidth) / 2, (d.height - intHeight) / 2); - } - - /** - Start the window at the center of screen - - **/ - protected void centerWindow() { - centerWindow(this.getSize().width, this.getSize().height); - } - /** - This method initializes jContentPane - - @return javax.swing.JPanel - **/ - private JPanel getJContentPane() { - if (jContentPane == null) { - jContentPane = new JPanel(); - jContentPane.setLayout(null); - jContentPane.add(getJScrollPane(), null); - jContentPane.add(getJButtonOk(), null); - jContentPane.add(getJButtonCancel(), null); - jContentPane.add(getJButton(), null); - } - return jContentPane; - } - - /** - This method initializes jScrollPane - - @return javax.swing.JScrollPane - **/ - private JScrollPane getJScrollPane() { - if (jScrollPane == null) { - jScrollPane = new JScrollPane(); - jScrollPane.setBounds(new java.awt.Rectangle(38, 45, 453, 419)); - jScrollPane.setViewportView(getJTable()); - } - return jScrollPane; - } - - /** - This method initializes jTable - - @return javax.swing.JTable - **/ - private JTable getJTable() { - if (jTable == null) { - model = new DefaultTableModel(); - jTable = new JTable(model); - jTable.setRowHeight(20); - model.addColumn("Name"); - model.addColumn("C_Name"); - model.addColumn("GUID"); - // - // initialize table using SpdFileContents object - // - if (sfc.getSpdProtocolDeclarationCount() == 0) { - return jTable; - } - String[][] saa = new String[sfc.getSpdProtocolDeclarationCount()][3]; - sfc.getSpdProtocolDeclarations(saa); - int i = 0; - while (i < saa.length) { - model.addRow(saa[i]); - i++; - } - - jTable.getColumnModel().getColumn(2).setCellEditor(new GuidEditor()); - - } - return jTable; - } - - /** - Remove original protocol declarations before saving updated ones - **/ - protected void save() { - if (jTable.isEditing()) { - jTable.getCellEditor().stopCellEditing(); - } - sfc.removeSpdProtocolDeclaration(); - int rowCount = model.getRowCount(); - int i = 0; - while (i < rowCount) { - String name = null; - if (model.getValueAt(i, 0) != null) { - name = model.getValueAt(i, 0).toString(); - } - String cName = null; - if (model.getValueAt(i, 1) != null) { - cName = model.getValueAt(i, 1).toString(); - } - String guid = null; - if (model.getValueAt(i, 2) != null) { - guid = model.getValueAt(i, 2).toString(); - } - sfc.genSpdProtocolDeclarations(name, cName, guid, null); - i++; - } - } - - /** - This method initializes jButtonOk - - @return javax.swing.JButton - **/ - private JButton getJButtonOk() { - if (jButtonOk == null) { - jButtonOk = new JButton(); - jButtonOk.setText("Ok"); - jButtonOk.setSize(new java.awt.Dimension(84, 20)); - jButtonOk.setLocation(new java.awt.Point(316, 486)); - jButtonOk.addActionListener(this); - } - return jButtonOk; - } - - /** - This method initializes jButtonCancel - - @return javax.swing.JButton - **/ - private JButton getJButtonCancel() { - if (jButtonCancel == null) { - jButtonCancel = new JButton(); - jButtonCancel.setText("Cancel"); - jButtonCancel.setSize(new java.awt.Dimension(82, 20)); - jButtonCancel.setLocation(new java.awt.Point(411, 486)); - jButtonCancel.addActionListener(this); - } - return jButtonCancel; - } - - /** - This method initializes jButton - - @return javax.swing.JButton - **/ - private JButton getJButton() { - if (jButton == null) { - jButton = new JButton(); - jButton.setBounds(new java.awt.Rectangle(232, 486, 71, 19)); - jButton.setText("Insert"); - jButton.addActionListener(this); - } - return jButton; - } -} // @jve:decl-index=0:visual-constraint="11,7" diff --git a/Tools/Source/PackageEditor/src/org/tianocore/packaging/common/ui/StarLabel.java b/Tools/Source/PackageEditor/src/org/tianocore/packaging/common/ui/StarLabel.java deleted file mode 100644 index ad19472e5d..0000000000 --- a/Tools/Source/PackageEditor/src/org/tianocore/packaging/common/ui/StarLabel.java +++ /dev/null @@ -1,41 +0,0 @@ -/** @file - Java class StarLabel is used to create star label. - -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; - -/** - Derived from JLabel class to have a red star on it. - - @since PackageEditor 1.0 -**/ -public class StarLabel extends JLabel{ - /** - * This is the default constructor - */ - public StarLabel() { - super(); - init(); - } - - /** - Create a label with red star * appear on it - **/ - 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); - } -} -- 2.39.5