git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@671 6f19259b-4bc3-4df7-8a09-765794883524

This commit is contained in:
hche10x
2006-06-30 09:59:54 +00:00
parent 30817eb4e4
commit a13899c5ac
113 changed files with 45968 additions and 18 deletions

View File

@@ -0,0 +1,2 @@
Manifest-Version: 1.0
Main-Class: org.tianocore.frameworkwizard.FrameworkWizardUI

View File

@@ -0,0 +1,44 @@
<?xml version="1.0"?>
<!--
Copyright (c) 2006, Intel Corporation
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-->
<project name="FrameworkWizard" default="all" basedir=".">
<taskdef resource="net/sf/antcontrib/antlib.xml"/>
<property environment="env"/>
<property name="WORKSPACE" value="${env.WORKSPACE}"/>
<path id="classpath">
<fileset dir="${WORKSPACE}/Tools/Jars" includes="*.jar"/>
<fileset dir="${env.XMLBEANS_HOME}/lib" includes="*.jar"/>
</path>
<property name="buildDir" value="build"/>
<property name="installLocation" value="${WORKSPACE}/Tools/bin"/>
<target name="all" depends="install"/>
<target name="source">
<mkdir dir="${buildDir}"/>
<javac srcdir="src" destdir="${buildDir}">
<classpath refid="classpath"/>
<!-- <compilerarg value="-Xlint"/> -->
</javac>
</target>
<target name="clean">
<delete dir="${buildDir}"/>
</target>
<target name="cleanall">
<delete dir="${buildDir}"/>
<delete file="${installLocation}/FrameworkWizard.jar"/>
</target>
<target name="install" depends="source">
<jar destfile="${installLocation}/FrameworkWizard.jar"
basedir="${buildDir}"
includes="**"
manifest="MANIFEST.MF"
/>
</target>
</project>

View File

@@ -0,0 +1,157 @@
/** @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.frameworkwizard;
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.frameworkwizard.common.DataType;
import org.tianocore.frameworkwizard.common.ui.IDialog;
import org.tianocore.frameworkwizard.common.ui.IFrame;
/**
The class is used to show a about window with copyright information
It extends IDialog
**/
public class About 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) {
About a = new About();
a.setVisible(true);
}
/**
This is the default constructor
**/
public About() {
super();
init();
}
/**
This is the default constructor
**/
public About(IFrame parentFrame, boolean modal) {
super(parentFrame, modal);
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 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) {
returnType = DataType.RETURN_TYPE_OK;
this.setVisible(false);
}
}
/**
Dispose when windows is closing
@param arg0
**/
public void windowClosing(WindowEvent arg0) {
this.dispose();
}
}

View File

@@ -0,0 +1,981 @@
/** @file
The file is used to clone workspace, module, package and platform
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.frameworkwizard;
import java.awt.event.ActionEvent;
import java.io.File;
import java.io.IOException;
import java.util.Vector;
import javax.swing.JFileChooser;
import javax.swing.JPanel;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.JButton;
import org.apache.xmlbeans.XmlException;
import org.tianocore.ModuleDefinitionsDocument.ModuleDefinitions;
import org.tianocore.ModuleSurfaceAreaDocument.ModuleSurfaceArea;
import org.tianocore.PackageDefinitionsDocument.PackageDefinitions;
import org.tianocore.PackageSurfaceAreaDocument.PackageSurfaceArea;
import org.tianocore.PlatformDefinitionsDocument.PlatformDefinitions;
import org.tianocore.PlatformSurfaceAreaDocument.PlatformSurfaceArea;
import org.tianocore.frameworkwizard.common.DataType;
import org.tianocore.frameworkwizard.common.DataValidation;
import org.tianocore.frameworkwizard.common.FileOperation;
import org.tianocore.frameworkwizard.common.IFileFilter;
import org.tianocore.frameworkwizard.common.Identification;
import org.tianocore.frameworkwizard.common.Log;
import org.tianocore.frameworkwizard.common.OpenFile;
import org.tianocore.frameworkwizard.common.SaveFile;
import org.tianocore.frameworkwizard.common.Tools;
import org.tianocore.frameworkwizard.common.ui.IDialog;
import org.tianocore.frameworkwizard.common.ui.IFrame;
import org.tianocore.frameworkwizard.module.Identification.ModuleIdentification;
import org.tianocore.frameworkwizard.packaging.PackageIdentification;
import org.tianocore.frameworkwizard.platform.PlatformIdentification;
import org.tianocore.frameworkwizard.workspace.Workspace;
import org.tianocore.frameworkwizard.workspace.WorkspaceTools;
import javax.swing.JComboBox;
public class Clone extends IDialog {
/**
Define class members
**/
private static final long serialVersionUID = -5469299324965727137L;
private JPanel jContentPane = null;
private JLabel jLabelType = null;
private JTextField jTextFieldType = null;
private JLabel jLabelSource = null;
private JTextField jTextFieldSource = null;
private JButton jButtonBrowse = null;
private JLabel jLabelDestinationFile = null;
private JTextField jTextFieldFilePath = 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 jButtonOk = null;
private JButton jButtonCancel = null;
private JButton jButtonGenerateGuid = null;
private int mode = -1;
private Vector<PackageIdentification> packages = null;
private WorkspaceTools wt = new WorkspaceTools();
private JLabel jLabelBelong = null;
private JComboBox jComboBoxExistingPackage = null;
private Identification oldId = null;
private Identification newId = null;
private ModuleIdentification mid = null;
private PackageIdentification pid = null;
private PlatformIdentification fid = null;
/**
* This method initializes jTextFieldType
*
* @return javax.swing.JTextField
*/
private JTextField getJTextFieldType() {
if (jTextFieldType == null) {
jTextFieldType = new JTextField();
jTextFieldType.setBounds(new java.awt.Rectangle(160, 10, 320, 20));
jTextFieldType.setEditable(false);
}
return jTextFieldType;
}
/**
* This method initializes jTextFieldSource
*
* @return javax.swing.JTextField
*/
private JTextField getJTextFieldSource() {
if (jTextFieldSource == null) {
jTextFieldSource = new JTextField();
jTextFieldSource.setBounds(new java.awt.Rectangle(160, 35, 320, 20));
jTextFieldSource.setEditable(false);
}
return jTextFieldSource;
}
/**
* This method initializes jButtonBrowse
*
* @return javax.swing.JButton
*/
private JButton getJButtonBrowse() {
if (jButtonBrowse == null) {
jButtonBrowse = new JButton();
jButtonBrowse.setBounds(new java.awt.Rectangle(395, 60, 85, 20));
jButtonBrowse.setText("Browse");
jButtonBrowse.addActionListener(this);
}
return jButtonBrowse;
}
/**
* This method initializes jTextFieldDestinationFile
*
* @return javax.swing.JTextField
*/
private JTextField getJTextFieldFilePath() {
if (jTextFieldFilePath == null) {
jTextFieldFilePath = new JTextField();
jTextFieldFilePath.setBounds(new java.awt.Rectangle(160, 60, 230, 20));
}
return jTextFieldFilePath;
}
/**
* This method initializes jTextFieldBaseName
*
* @return javax.swing.JTextField
*/
private JTextField getJTextFieldBaseName() {
if (jTextFieldBaseName == null) {
jTextFieldBaseName = new JTextField();
jTextFieldBaseName.setBounds(new java.awt.Rectangle(160, 110, 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, 135, 230, 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, 160, 320, 20));
}
return jTextFieldVersion;
}
/**
* This method initializes jButtonOk
*
* @return javax.swing.JButton
*/
private JButton getJButtonOk() {
if (jButtonOk == null) {
jButtonOk = new JButton();
jButtonOk.setBounds(new java.awt.Rectangle(235, 200, 90, 20));
jButtonOk.setText("Ok");
jButtonOk.addActionListener(this);
}
return jButtonOk;
}
/**
* This method initializes jButtonCancel
*
* @return javax.swing.JButton
*/
private JButton getJButtonCancel() {
if (jButtonCancel == null) {
jButtonCancel = new JButton();
jButtonCancel.setBounds(new java.awt.Rectangle(355, 200, 90, 20));
jButtonCancel.setText("Cancel");
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(395, 135, 85, 20));
jButtonGenerateGuid.setText("Gen");
jButtonGenerateGuid.addActionListener(this);
}
return jButtonGenerateGuid;
}
/**
* This method initializes jComboBoxExistingPackage
*
* @return javax.swing.JComboBox
*/
private JComboBox getJComboBoxExistingPackage() {
if (jComboBoxExistingPackage == null) {
jComboBoxExistingPackage = new JComboBox();
jComboBoxExistingPackage.setBounds(new java.awt.Rectangle(160, 85, 320, 20));
}
return jComboBoxExistingPackage;
}
/**
@param args
**/
public static void main(String[] args) {
}
/**
* This is the default constructor
*/
public Clone() {
super();
init();
}
/**
This is the default constructor
**/
public Clone(IFrame parentFrame, boolean modal, int fileType, Identification identification) {
super(parentFrame, modal);
this.mode = fileType;
if (identification != null) {
this.oldId = new Identification(identification.getName(), identification.getGuid(),
identification.getVersion(), identification.getPath());
this.newId = new Identification(identification.getName(), identification.getGuid(),
identification.getVersion(), identification.getPath());
}
init(mode);
}
/**
Query all existing packages and fill them into combox
**/
private void initExistingPackage() {
packages = wt.getAllPackages();
for (int index = 0; index < packages.size(); index++) {
this.jComboBoxExistingPackage.addItem(packages.elementAt(index).getName());
}
}
/**
* This method initializes this
*
* @return void
*/
private void init() {
this.setSize(493, 260);
this.setContentPane(getJContentPane());
this.setTitle("Clone");
this.centerWindow();
}
/**
* This method initializes this
*
* @return void
*/
private void init(int mode) {
init();
if (mode == DataType.RETURN_TYPE_MODULE_SURFACE_AREA) {
this.jTextFieldType.setText(DataType.MODULE_SURFACE_AREA);
this.jTextFieldSource.setText(oldId.getPath());
initExistingPackage();
this.jButtonBrowse.setEnabled(false);
this.jTextFieldFilePath.setToolTipText("Input module name here. For example, Application\\HelloWorld\\HelloWorld.msa");
this.jLabelDestinationFile.setText("Module Path\\Name");
}
if (mode == DataType.RETURN_TYPE_PACKAGE_SURFACE_AREA) {
this.jTextFieldType.setText(DataType.PACKAGE_SURFACE_AREA);
this.jTextFieldSource.setText(oldId.getPath());
this.jLabelBelong.setEnabled(false);
this.jComboBoxExistingPackage.setEnabled(false);
this.jButtonBrowse.setEnabled(false);
this.jTextFieldFilePath.setToolTipText("Input package name here. For example, MdePkg\\MdePkg.fpd");
this.jLabelDestinationFile.setText("Package Path\\Name");
}
if (mode == DataType.RETURN_TYPE_PLATFORM_SURFACE_AREA) {
this.jTextFieldType.setText(DataType.PLATFORM_SURFACE_AREA);
this.jTextFieldSource.setText(oldId.getPath());
this.jLabelBelong.setEnabled(false);
this.jComboBoxExistingPackage.setEnabled(false);
this.jTextFieldFilePath.setToolTipText("Select platform path here. For example, C:\\MyWorkspace\\EdkNt32Pkg\\Nt32.fpd");
this.jLabelDestinationFile.setText("New Platform path");
}
if (mode == DataType.RETURN_TYPE_WORKSPACE) {
this.jTextFieldType.setText(DataType.WORKSPACE);
this.jTextFieldSource.setText(Workspace.getCurrentWorkspace());
this.jLabelBelong.setEnabled(false);
this.jComboBoxExistingPackage.setEnabled(false);
this.jLabelBaseName.setEnabled(false);
this.jTextFieldBaseName.setEditable(false);
this.jLabelGuid.setEnabled(false);
this.jTextFieldGuid.setEnabled(false);
this.jButtonGenerateGuid.setEnabled(false);
this.jLabelVersion.setEnabled(false);
this.jTextFieldVersion.setEnabled(false);
this.jTextFieldFilePath.setToolTipText("Input workspace path here. For example, C:\\MyWorkspace");
this.jLabelDestinationFile.setText("New Workspace path");
}
}
/**
* This method initializes jContentPane
*
* @return javax.swing.JPanel
*/
private JPanel getJContentPane() {
if (jContentPane == null) {
jLabelBelong = new JLabel();
jLabelBelong.setBounds(new java.awt.Rectangle(15, 85, 140, 20));
jLabelBelong.setText("Clone to Package");
jLabelVersion = new JLabel();
jLabelVersion.setBounds(new java.awt.Rectangle(15, 160, 140, 20));
jLabelVersion.setText("Version");
jLabelGuid = new JLabel();
jLabelGuid.setBounds(new java.awt.Rectangle(15, 135, 140, 20));
jLabelGuid.setText("Guid");
jLabelBaseName = new JLabel();
jLabelBaseName.setBounds(new java.awt.Rectangle(15, 110, 140, 20));
jLabelBaseName.setText("Base Name");
jLabelDestinationFile = new JLabel();
jLabelDestinationFile.setBounds(new java.awt.Rectangle(15, 60, 140, 20));
jLabelDestinationFile.setText("Destination File Name");
jLabelSource = new JLabel();
jLabelSource.setBounds(new java.awt.Rectangle(15, 35, 140, 20));
jLabelSource.setText("Source");
jLabelType = new JLabel();
jLabelType.setBounds(new java.awt.Rectangle(15, 10, 140, 20));
jLabelType.setText("Type");
jContentPane = new JPanel();
jContentPane.setLayout(null);
jContentPane.setSize(new java.awt.Dimension(490, 227));
jContentPane.add(jLabelType, null);
jContentPane.add(getJTextFieldType(), null);
jContentPane.add(jLabelSource, null);
jContentPane.add(getJTextFieldSource(), null);
jContentPane.add(jLabelDestinationFile, null);
jContentPane.add(getJTextFieldFilePath(), null);
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(getJButtonOk(), null);
jContentPane.add(getJButtonCancel(), null);
jContentPane.add(getJButtonBrowse(), null);
jContentPane.add(getJButtonGenerateGuid(), null);
jContentPane.add(jLabelBelong, null);
jContentPane.add(getJComboBoxExistingPackage(), 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() == jButtonCancel) {
this.setVisible(false);
this.returnType = DataType.RETURN_TYPE_CANCEL;
}
if (arg0.getSource() == jButtonOk) {
if (this.check()) {
try {
this.save();
} catch (IOException e) {
Log.err("Clone", e.getMessage());
e.printStackTrace();
return;
} catch (XmlException e) {
Log.err("Clone", e.getMessage());
e.printStackTrace();
return;
} catch (Exception e) {
Log.err("Clone", e.getMessage());
e.printStackTrace();
return;
}
} else {
return;
}
this.setVisible(false);
}
if (arg0.getSource() == this.jButtonGenerateGuid) {
this.jTextFieldGuid.setText(Tools.generateUuidString());
}
//
// Use different file ext
//
if (arg0.getSource() == this.jButtonBrowse) {
JFileChooser fc = new JFileChooser();
fc.setAcceptAllFileFilterUsed(false);
if (mode == DataType.RETURN_TYPE_WORKSPACE) {
fc.setCurrentDirectory(new File(Workspace.getCurrentWorkspace()));
fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
}
if (mode == DataType.RETURN_TYPE_MODULE_SURFACE_AREA) {
fc.setCurrentDirectory(new File(packages.elementAt(this.jComboBoxExistingPackage.getSelectedIndex())
.getPath()));
fc.addChoosableFileFilter(new IFileFilter(DataType.MODULE_SURFACE_AREA_EXT));
}
if (mode == DataType.RETURN_TYPE_PACKAGE_SURFACE_AREA) {
fc.setCurrentDirectory(new File(Workspace.getCurrentWorkspace()));
fc.addChoosableFileFilter(new IFileFilter(DataType.PACKAGE_SURFACE_AREA_EXT));
}
if (mode == DataType.RETURN_TYPE_PLATFORM_SURFACE_AREA) {
fc.setCurrentDirectory(new File(Workspace.getCurrentWorkspace()));
fc.addChoosableFileFilter(new IFileFilter(DataType.PLATFORM_SURFACE_AREA_EXT));
}
int result = fc.showSaveDialog(new JPanel());
if (result == JFileChooser.APPROVE_OPTION) {
this.jTextFieldFilePath.setText(Tools.addPathExt(fc.getSelectedFile().getPath(), mode));
}
}
}
//
// Check name, guid and version
//
private boolean checkId() {
//
// Check Basename
//
if (isEmpty(this.jTextFieldBaseName.getText())) {
Log.err("Base Name couldn't be empty!");
return false;
}
if (!DataValidation.isBaseName(this.jTextFieldBaseName.getText())) {
Log.err("Incorrect data type for Base Name");
return false;
}
//
// Check Guid
//
if (isEmpty(this.jTextFieldGuid.getText())) {
Log.err("Guid couldn't be empty!");
return false;
}
if (!DataValidation.isGuid(this.jTextFieldGuid.getText())) {
Log.err("Incorrect data type for Guid");
return false;
}
//
// Check Version
//
if (isEmpty(this.jTextFieldVersion.getText())) {
Log.err("Version couldn't be empty!");
return false;
}
if (!DataValidation.isVersion(this.jTextFieldVersion.getText())) {
Log.err("Incorrect data type for Version");
return false;
}
//
// Save information to id
//
newId.setName(this.jTextFieldBaseName.getText());
newId.setGuid(this.jTextFieldGuid.getText());
newId.setVersion(this.jTextFieldVersion.getText());
newId.setPath(this.jTextFieldFilePath.getText());
return true;
}
/**
Check before save
@return
**/
private boolean check() {
String src = this.jTextFieldSource.getText();
String trg = this.jTextFieldFilePath.getText();
File srcFile = new File(src);
File trgFile = new File(trg);
//
// Common Check
//
if (!srcFile.exists()) {
Log.err("The source doesn't exist");
return false;
}
if (isEmpty(trg)) {
Log.err("The destination file path couldn't be empty");
return false;
}
if (src.equals(trg)) {
Log.err("The source and destination couldn't be same");
return false;
}
if (trgFile.exists()) {
Log.err("The destination already exists");
return false;
}
//
// Check for workspace
//
if (mode == DataType.RETURN_TYPE_WORKSPACE) {
if (trg.indexOf(src + DataType.FILE_SEPARATOR) == 0) {
Log.err("The new workspace couldn't be in current workspace!");
return false;
}
}
//
// Check for Module
//
if (mode == DataType.RETURN_TYPE_MODULE_SURFACE_AREA) {
return checkId();
}
//
// Check for Package
//
if (mode == DataType.RETURN_TYPE_PACKAGE_SURFACE_AREA) {
if (trg.indexOf(DataType.DOS_FILE_SEPARATOR) == -1 && trg.indexOf(DataType.UNIX_FILE_SEPARATOR) == -1) {
Log.err("The package name must include a path");
return false;
}
trg = this.getPackagePath();
if (Tools.getFilePathOnly(src).equals(Tools.getFilePathOnly(trg))) {
Log.err("The source and destination couldn't be same");
return false;
}
trgFile = new File(trg);
if (trgFile.exists()) {
Log.err("The target package already exists");
return false;
}
return checkId();
}
//
// Check for Platform
//
if (mode == DataType.RETURN_TYPE_PLATFORM_SURFACE_AREA) {
if (trg.indexOf(Workspace.getCurrentWorkspace()) != 0) {
Log.err("The target platform must be in current workspace");
return false;
}
trgFile = new File(trg);
if (trgFile.exists()) {
Log.err("The target platform already exists");
return false;
}
return checkId();
}
return true;
}
private void save() throws IOException, XmlException, Exception {
String src = this.jTextFieldSource.getText();
String trg = this.jTextFieldFilePath.getText();
//
// Clone Workspace
//
if (mode == DataType.RETURN_TYPE_WORKSPACE) {
try {
FileOperation.copyFolder(src, trg);
} catch (Exception e) {
this.returnType = DataType.RETURN_TYPE_CANCEL;
Log.err("Clone Workspace", e.getMessage());
e.printStackTrace();
}
this.returnType = DataType.RETURN_TYPE_WORKSPACE;
}
//
// Clone Module Surface Area
//
if (mode == DataType.RETURN_TYPE_MODULE_SURFACE_AREA) {
//
// Get target path from source path
//
trg = getModulePath();
newId.setPath(trg);
//
// First copy all files to new directory
//
FileOperation.copyFolder(Tools.getFilePathOnly(src), Tools.getFilePathOnly(trg));
//
// Delete old spd file
//
FileOperation.delFile(Tools.getFilePathOnly(trg) + DataType.FILE_SEPARATOR + Tools.getFileNameOnly(src));
//
// Create new msa file
//
ModuleSurfaceArea msa = null;
msa = OpenFile.openMsaFile(src);
//
// Update to memory
//
msa.getMsaHeader().setModuleName(newId.getName());
msa.getMsaHeader().setGuidValue(newId.getGuid());
msa.getMsaHeader().setVersion(newId.getVersion());
//
// Update Cloned From element
//
updateModuleClonedId(msa, oldId);
//
// Save to file
//
SaveFile.saveMsaFile(trg, msa);
//
// Update to platformId
//
this.setMid(new ModuleIdentification(newId, packages.elementAt(this.jComboBoxExistingPackage.getSelectedIndex())));
//
// Open belonging package
//
PackageSurfaceArea psa = PackageSurfaceArea.Factory.newInstance();
psa = OpenFile.openSpdFile(mid.getPackageId().getPath());
//
// Update the db file
//
wt.addModuleToPackage(mid, psa);
this.returnType = DataType.RETURN_TYPE_MODULE_SURFACE_AREA;
}
//
// Clone Package Surface Area
//
if (mode == DataType.RETURN_TYPE_PACKAGE_SURFACE_AREA) {
//
// Get target path from source path
//
trg = this.getPackagePath();
newId.setPath(trg);
//
// First copy all files to new directory
//
FileOperation.copyFolder(Tools.getFilePathOnly(src), Tools.getFilePathOnly(trg));
//
// Delete old spd file
//
FileOperation.delFile(Tools.getFilePathOnly(trg) + DataType.FILE_SEPARATOR + Tools.getFileNameOnly(src));
//
// Create new spd file
//
PackageSurfaceArea spd = null;
spd = OpenFile.openSpdFile(src);
//
// Update to memory
//
spd.getSpdHeader().setPackageName(newId.getName());
spd.getSpdHeader().setGuidValue(newId.getGuid());
spd.getSpdHeader().setVersion(newId.getVersion());
//
// Update Cloned From element
//
updatePackageClonedId(spd, oldId);
//
// Save to file
//
SaveFile.saveSpdFile(trg, spd);
//
// Update to platformId
//
this.setPid(new PackageIdentification(newId));
//
// Update the db file
//
wt.addPackageToDatabase(pid);
this.returnType = DataType.RETURN_TYPE_PACKAGE_SURFACE_AREA;
}
//
// Clone Platform Surface Area
//
if (mode == DataType.RETURN_TYPE_PLATFORM_SURFACE_AREA) {
PlatformSurfaceArea fpd = null;
fpd = OpenFile.openFpdFile(src);
//
// Update to memory
//
fpd.getPlatformHeader().setPlatformName(newId.getName());
fpd.getPlatformHeader().setGuidValue(newId.getGuid());
fpd.getPlatformHeader().setVersion(newId.getVersion());
//
// Update Cloned From element
//
updatePlatformClonedId(fpd, oldId);
//
// Save to file
//
SaveFile.saveFpdFile(trg, fpd);
//
// Update to platformId
//
this.setFid(new PlatformIdentification(newId));
//
// Update the db file
//
wt.addPlatformToDatabase(fid);
this.returnType = DataType.RETURN_TYPE_PLATFORM_SURFACE_AREA;
}
}
private String getSelectPackagePath() {
return Tools.getFilePathOnly(packages.elementAt(this.jComboBoxExistingPackage.getSelectedIndex()).getPath());
}
private String getModulePath() {
String trg = this.jTextFieldFilePath.getText();
trg = Tools.addPathExt(trg, mode);
trg = getSelectPackagePath() + DataType.FILE_SEPARATOR + trg;
Tools.convertPathToCurrentOsType(trg);
return trg;
}
private String getPackagePath() {
String trg = this.jTextFieldFilePath.getText();
trg = Tools.addPathExt(trg, mode);
trg = Workspace.getCurrentWorkspace() + DataType.FILE_SEPARATOR + trg;
trg = Tools.convertPathToCurrentOsType(trg);
return trg;
}
/**
Set target item's Cloned From element
@param id
@return
**/
private void updateModuleClonedId(ModuleSurfaceArea msa, Identification id) {
//
// Get PlatformDefinitions First
//
ModuleDefinitions pd = null;
if (msa.getModuleDefinitions() == null) {
pd = ModuleDefinitions.Factory.newInstance();
msa.addNewModuleDefinitions();
} else {
pd = msa.getModuleDefinitions();
}
//
// Get ClonedFrom then
//
ModuleDefinitions.ClonedFrom cf = null;
if (pd.getClonedFrom() == null) {
cf = ModuleDefinitions.ClonedFrom.Factory.newInstance();
} else {
cf = pd.getClonedFrom();
}
//
// Set new Cloned item
//
ModuleDefinitions.ClonedFrom.Cloned c = ModuleDefinitions.ClonedFrom.Cloned.Factory.newInstance();
c.setModuleGuid(id.getGuid());
c.setModuleVersion(id.getVersion());
cf.addNewCloned();
cf.setClonedArray(cf.getClonedList().size() - 1, c);
pd.addNewClonedFrom();
pd.setClonedFrom(cf);
msa.setModuleDefinitions(pd);
}
/**
Set target item's Cloned From element
@param id
@return
**/
private void updatePackageClonedId(PackageSurfaceArea spd, Identification id) {
//
// Get PlatformDefinitions First
//
PackageDefinitions pd = null;
if (spd.getPackageDefinitions() == null) {
pd = PackageDefinitions.Factory.newInstance();
spd.addNewPackageDefinitions();
} else {
pd = spd.getPackageDefinitions();
}
//
// Get ClonedFrom then
//
PackageDefinitions.ClonedFrom cf = null;
if (pd.getClonedFrom() == null) {
cf = PackageDefinitions.ClonedFrom.Factory.newInstance();
} else {
cf = pd.getClonedFrom();
}
//
// Set new Cloned item
//
PackageDefinitions.ClonedFrom.Cloned c = PackageDefinitions.ClonedFrom.Cloned.Factory.newInstance();
c.setPackageGuid(id.getGuid());
c.setPackageVersion(id.getVersion());
cf.addNewCloned();
cf.setClonedArray(cf.getClonedList().size() - 1, c);
pd.addNewClonedFrom();
pd.setClonedFrom(cf);
spd.setPackageDefinitions(pd);
}
/**
Set target item's Cloned From element
@param id
@return
**/
private void updatePlatformClonedId(PlatformSurfaceArea fpd, Identification id) {
//
// Get PlatformDefinitions First
//
PlatformDefinitions pd = null;
if (fpd.getPlatformDefinitions() == null) {
pd = PlatformDefinitions.Factory.newInstance();
fpd.addNewPlatformDefinitions();
} else {
pd = fpd.getPlatformDefinitions();
}
//
// Get ClonedFrom then
//
PlatformDefinitions.ClonedFrom cf = null;
if (pd.getClonedFrom() == null) {
cf = PlatformDefinitions.ClonedFrom.Factory.newInstance();
} else {
cf = pd.getClonedFrom();
}
//
// Set new Cloned item
//
PlatformDefinitions.ClonedFrom.Cloned c = PlatformDefinitions.ClonedFrom.Cloned.Factory.newInstance();
c.setPlatformGuid(id.getGuid());
c.setPlatformVersion(id.getVersion());
cf.addNewCloned();
cf.setClonedArray(cf.getClonedList().size() - 1, c);
pd.addNewClonedFrom();
pd.setClonedFrom(cf);
fpd.setPlatformDefinitions(pd);
}
public PlatformIdentification getFid() {
return fid;
}
public void setFid(PlatformIdentification fid) {
this.fid = fid;
}
public ModuleIdentification getMid() {
return mid;
}
public void setMid(ModuleIdentification mid) {
this.mid = mid;
}
public PackageIdentification getPid() {
return pid;
}
public void setPid(PackageIdentification pid) {
this.pid = pid;
}
}

View File

@@ -0,0 +1,228 @@
/** @file
The file is used to show a new file chooser dialog
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.frameworkwizard;
import java.awt.event.ActionEvent;
import javax.swing.ButtonGroup;
import javax.swing.JPanel;
import javax.swing.JButton;
import javax.swing.JRadioButton;
import org.tianocore.frameworkwizard.common.DataType;
import org.tianocore.frameworkwizard.common.ui.IDialog;
import org.tianocore.frameworkwizard.common.ui.IFrame;
public class NewFileChooser extends IDialog {
/**
Define class members
**/
private static final long serialVersionUID = -3657926400683618281L;
private JPanel jContentPane = null;
private JButton jButtonNext = null;
private JButton jButtonCancel = null;
private JRadioButton jRadioButtonModule = null;
private JRadioButton jRadioButtonPackage = null;
private JRadioButton jRadioButtonPlatform = null;
private JRadioButton jRadioButtonBuildXml = null;
private final ButtonGroup buttonGroup = new ButtonGroup();
/**
This is the default constructor
**/
public NewFileChooser() {
super();
init();
}
/**
This is the default constructor
**/
public NewFileChooser(IFrame parentFrame, boolean modal) {
super(parentFrame, modal);
init();
}
/**
* This method initializes jButtonOk
*
* @return javax.swing.JButton
*/
private JButton getJButtonOk() {
if (jButtonNext == null) {
jButtonNext = new JButton();
jButtonNext.setBounds(new java.awt.Rectangle(90, 150, 80, 20));
jButtonNext.setText("Next");
jButtonNext.addActionListener(this);
}
return jButtonNext;
}
/**
* This method initializes jButtonCancel
*
* @return javax.swing.JButton
*/
private JButton getJButtonCancel() {
if (jButtonCancel == null) {
jButtonCancel = new JButton();
jButtonCancel.setBounds(new java.awt.Rectangle(180, 150, 80, 20));
jButtonCancel.setText("Cancel");
jButtonCancel.addActionListener(this);
}
return jButtonCancel;
}
/**
* This method initializes jRadioButtonModule
*
* @return javax.swing.JRadioButton
*/
private JRadioButton getJRadioButtonModule() {
if (jRadioButtonModule == null) {
jRadioButtonModule = new JRadioButton();
jRadioButtonModule.setText(DataType.MODULE_SURFACE_AREA);
jRadioButtonModule.setBounds(new java.awt.Rectangle(20, 20, 240, 20));
jRadioButtonModule.setSelected(true);
}
return jRadioButtonModule;
}
/**
* This method initializes jRadioButtonPackage
*
* @return javax.swing.JRadioButton
*/
private JRadioButton getJRadioButtonPackage() {
if (jRadioButtonPackage == null) {
jRadioButtonPackage = new JRadioButton();
jRadioButtonPackage.setText(DataType.PACKAGE_SURFACE_AREA);
jRadioButtonPackage.setBounds(new java.awt.Rectangle(20, 50, 240, 20));
}
return jRadioButtonPackage;
}
/**
* This method initializes jRadioButtonPlatform
*
* @return javax.swing.JRadioButton
*/
private JRadioButton getJRadioButtonPlatform() {
if (jRadioButtonPlatform == null) {
jRadioButtonPlatform = new JRadioButton();
jRadioButtonPlatform.setText(DataType.PACKAGE_SURFACE_AREA);
jRadioButtonPlatform.setBounds(new java.awt.Rectangle(20, 80, 240, 20));
}
return jRadioButtonPlatform;
}
/**
* This method initializes jRadioButtonBuildXml
*
* @return javax.swing.JRadioButton
*/
private JRadioButton getJRadioButtonBuildXml() {
if (jRadioButtonBuildXml == null) {
jRadioButtonBuildXml = new JRadioButton();
jRadioButtonBuildXml.setText(DataType.ANT_BUILD_FILE);
jRadioButtonBuildXml.setBounds(new java.awt.Rectangle(20, 110, 240, 20));
jRadioButtonBuildXml.setVisible(false);
}
return jRadioButtonBuildXml;
}
/**
* @param args
*/
public static void main(String[] args) {
NewFileChooser nfc = new NewFileChooser();
nfc.setVisible(true);
}
/**
* This method initializes this
*
* @return void
*/
private void init() {
this.setSize(310, 220);
this.setContentPane(getJContentPane());
this.setTitle("New Framework File");
this.centerWindow();
}
/**
* 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(getJRadioButtonModule(), null);
jContentPane.add(getJRadioButtonPackage(), null);
jContentPane.add(getJRadioButtonPlatform(), null);
jContentPane.add(getJRadioButtonBuildXml(), null);
buttonGroup.add(this.getJRadioButtonModule());
buttonGroup.add(this.getJRadioButtonPackage());
buttonGroup.add(this.getJRadioButtonPlatform());
buttonGroup.add(this.getJRadioButtonBuildXml());
}
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() == jButtonCancel) {
this.setVisible(false);
returnType = DataType.RETURN_TYPE_CANCEL;
}
if (arg0.getSource() == jButtonNext) {
this.setVisible(false);
if (this.jRadioButtonModule.isSelected()) {
returnType = DataType.RETURN_TYPE_MODULE_SURFACE_AREA;
}
if (this.jRadioButtonPackage.isSelected()) {
returnType = DataType.RETURN_TYPE_PACKAGE_SURFACE_AREA;
}
if (this.jRadioButtonPlatform.isSelected()) {
returnType = DataType.RETURN_TYPE_PLATFORM_SURFACE_AREA;
}
if (this.jRadioButtonBuildXml.isSelected()) {
returnType = DataType.RETURN_TYPE_BUILD_XML;
}
}
}
}

View File

@@ -0,0 +1,665 @@
/** @file
The file is used to let user choose to create module in an existing package
or to create a new package first.
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.frameworkwizard;
import java.awt.event.ActionEvent;
import java.io.File;
import java.util.Vector;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFileChooser;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import org.tianocore.ModuleSurfaceAreaDocument;
import org.tianocore.MsaHeaderDocument;
import org.tianocore.SpdHeaderDocument;
import org.tianocore.PackageSurfaceAreaDocument.PackageSurfaceArea;
import org.tianocore.PlatformHeaderDocument.PlatformHeader;
import org.tianocore.PlatformSurfaceAreaDocument.PlatformSurfaceArea;
import org.tianocore.frameworkwizard.common.DataType;
import org.tianocore.frameworkwizard.common.DataValidation;
import org.tianocore.frameworkwizard.common.IFileFilter;
import org.tianocore.frameworkwizard.common.Log;
import org.tianocore.frameworkwizard.common.SaveFile;
import org.tianocore.frameworkwizard.common.Tools;
import org.tianocore.frameworkwizard.common.ui.IDialog;
import org.tianocore.frameworkwizard.common.ui.IFrame;
import org.tianocore.frameworkwizard.common.ui.StarLabel;
import org.tianocore.frameworkwizard.module.Identification.ModuleIdentification;
import org.tianocore.frameworkwizard.packaging.PackageIdentification;
import org.tianocore.frameworkwizard.platform.PlatformIdentification;
import org.tianocore.frameworkwizard.workspace.Workspace;
import org.tianocore.frameworkwizard.workspace.WorkspaceTools;
public class SelectModuleBelong extends IDialog {
/**
Define class members
**/
private static final long serialVersionUID = 4171355136991448972L;
private JPanel jContentPane = null;
private JComboBox jComboBoxExistingPackage = null;
private JButton jButtonOk = null;
private JButton jButtonCancel = null;
private Vector<PackageIdentification> packages = null;
private JLabel jLabelPackage = null;
private JLabel jLabelFilePath = null;
private JTextField jTextFieldFilePath = null;
private JButton jButtonBrowse = null;
private JLabel jLabelName = null;
private JTextField jTextFieldName = null;
private JLabel jLabelGuid = null;
private JTextField jTextFieldGuid = null;
private JButton jButtonGen = null;
private JLabel jLabelVersion = null;
private JTextField jTextFieldVersion = null;
private StarLabel jStarLabel1 = null;
private StarLabel jStarLabel2 = null;
private StarLabel jStarLabel3 = null;
private StarLabel jStarLabel4 = null;
private StarLabel jStarLabel5 = null;
private WorkspaceTools wt = new WorkspaceTools();
private ModuleIdentification mid = null;
private PackageIdentification pid = null;
private PlatformIdentification fid = null;
private int mode = -1;
/**
* This method initializes jComboBoxExistingPackage
*
* @return javax.swing.JComboBox
*/
private JComboBox getJComboBoxExistingPackage() {
if (jComboBoxExistingPackage == null) {
jComboBoxExistingPackage = new JComboBox();
jComboBoxExistingPackage.setBounds(new java.awt.Rectangle(140, 10, 340, 20));
}
return jComboBoxExistingPackage;
}
/**
* This method initializes jButtonNext
*
* @return javax.swing.JButton
*/
private JButton getJButtonOk() {
if (jButtonOk == null) {
jButtonOk = new JButton();
jButtonOk.setBounds(new java.awt.Rectangle(310, 140, 80, 20));
jButtonOk.setText("Ok");
jButtonOk.addActionListener(this);
}
return jButtonOk;
}
/**
* This method initializes jButtonCancel
*
* @return javax.swing.JButton
*/
private JButton getJButtonCancel() {
if (jButtonCancel == null) {
jButtonCancel = new JButton();
jButtonCancel.setBounds(new java.awt.Rectangle(395, 140, 80, 20));
jButtonCancel.setText("Cancel");
jButtonCancel.addActionListener(this);
}
return jButtonCancel;
}
/**
* This method initializes jTextFieldFilePath
*
* @return javax.swing.JTextField
*/
private JTextField getJTextFieldFilePath() {
if (jTextFieldFilePath == null) {
jTextFieldFilePath = new JTextField();
jTextFieldFilePath.setBounds(new java.awt.Rectangle(140, 35, 250, 20));
}
return jTextFieldFilePath;
}
/**
* This method initializes jButtonBrowse
*
* @return javax.swing.JButton
*/
private JButton getJButtonBrowse() {
if (jButtonBrowse == null) {
jButtonBrowse = new JButton();
jButtonBrowse.setBounds(new java.awt.Rectangle(395, 35, 85, 20));
jButtonBrowse.setText("Browse");
jButtonBrowse.addActionListener(this);
}
return jButtonBrowse;
}
/**
* This method initializes jTextFieldModuleName
*
* @return javax.swing.JTextField
*/
private JTextField getJTextFieldName() {
if (jTextFieldName == null) {
jTextFieldName = new JTextField();
jTextFieldName.setBounds(new java.awt.Rectangle(140, 60, 340, 20));
}
return jTextFieldName;
}
/**
* This method initializes jTextFieldGuid
*
* @return javax.swing.JTextField
*/
private JTextField getJTextFieldGuid() {
if (jTextFieldGuid == null) {
jTextFieldGuid = new JTextField();
jTextFieldGuid.setBounds(new java.awt.Rectangle(140, 85, 250, 20));
}
return jTextFieldGuid;
}
/**
* This method initializes jButtonGen
*
* @return javax.swing.JButton
*/
private JButton getJButtonGen() {
if (jButtonGen == null) {
jButtonGen = new JButton();
jButtonGen.setBounds(new java.awt.Rectangle(395, 85, 85, 20));
jButtonGen.setText("GEN");
jButtonGen.addActionListener(this);
}
return jButtonGen;
}
/**
* This method initializes jTextFieldVersion
*
* @return javax.swing.JTextField
*/
private JTextField getJTextFieldVersion() {
if (jTextFieldVersion == null) {
jTextFieldVersion = new JTextField();
jTextFieldVersion.setBounds(new java.awt.Rectangle(140, 110, 340, 20));
}
return jTextFieldVersion;
}
/**
* @param args
*/
public static void main(String[] args) {
SelectModuleBelong smb = new SelectModuleBelong();
smb.setVisible(true);
}
/**
* This is the default constructor
*/
public SelectModuleBelong() {
super();
init();
}
/**
* This is the default constructor
*/
public SelectModuleBelong(IFrame parentFrame, boolean modal, int fileType) {
super(parentFrame, modal);
this.mode = fileType;
init();
initExistingPackage();
if (mode != DataType.RETURN_TYPE_MODULE_SURFACE_AREA) {
this.jStarLabel1.setVisible(false);
this.jLabelPackage.setVisible(false);
this.jComboBoxExistingPackage.setVisible(false);
}
}
/**
* This method initializes this
*
* @return void
*/
private void init() {
this.setSize(500, 200);
this.setContentPane(getJContentPane());
this.setTitle("New Module");
this.centerWindow();
}
/**
* This method initializes jContentPane
*
* @return javax.swing.JPanel
*/
private JPanel getJContentPane() {
if (jContentPane == null) {
jLabelVersion = new JLabel();
jLabelVersion.setBounds(new java.awt.Rectangle(15, 110, 120, 20));
jLabelVersion.setText("Version");
jLabelGuid = new JLabel();
jLabelGuid.setBounds(new java.awt.Rectangle(15, 85, 120, 20));
jLabelGuid.setText("Guid");
jLabelName = new JLabel();
jLabelName.setBounds(new java.awt.Rectangle(15, 60, 120, 20));
jLabelName.setText("Name");
jLabelFilePath = new JLabel();
jLabelFilePath.setBounds(new java.awt.Rectangle(15, 35, 120, 20));
jLabelFilePath.setText("File Path");
jLabelPackage = new JLabel();
jLabelPackage.setBounds(new java.awt.Rectangle(15, 10, 120, 20));
jLabelPackage.setText("Choose Package");
jContentPane = new JPanel();
jContentPane.setLayout(null);
jContentPane.setSize(new java.awt.Dimension(490, 175));
jContentPane.add(getJComboBoxExistingPackage(), null);
jContentPane.add(getJButtonOk(), null);
jContentPane.add(getJButtonCancel(), null);
jContentPane.add(jLabelPackage, null);
jContentPane.add(jLabelFilePath, null);
jContentPane.add(getJTextFieldFilePath(), null);
jContentPane.add(getJButtonBrowse(), null);
jContentPane.add(jLabelName, null);
jContentPane.add(getJTextFieldName(), null);
jContentPane.add(jLabelGuid, null);
jContentPane.add(getJTextFieldGuid(), null);
jContentPane.add(getJButtonGen(), null);
jContentPane.add(jLabelVersion, null);
jContentPane.add(getJTextFieldVersion(), 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, 110));
jContentPane.add(jStarLabel1, null);
jContentPane.add(jStarLabel2, null);
jContentPane.add(jStarLabel3, null);
jContentPane.add(jStarLabel4, null);
jContentPane.add(jStarLabel5, null);
}
return jContentPane;
}
/**
Query all existing packages and fill them into combox
**/
private void initExistingPackage() {
packages = wt.getAllPackages();
for (int index = 0; index < packages.size(); index++) {
this.jComboBoxExistingPackage.addItem(packages.elementAt(index).getName());
}
}
/* (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() == jButtonCancel) {
this.setVisible(false);
this.returnType = DataType.RETURN_TYPE_CANCEL;
}
if (arg0.getSource() == jButtonOk) {
if (this.check()) {
this.save();
} else {
return;
}
this.setVisible(false);
this.returnType = DataType.RETURN_TYPE_OK;
}
if (arg0.getSource() == this.jButtonGen) {
this.jTextFieldGuid.setText(Tools.generateUuidString());
}
if (arg0.getSource() == this.jButtonBrowse) {
JFileChooser fc = new JFileChooser();
fc.setAcceptAllFileFilterUsed(false);
if (mode == DataType.RETURN_TYPE_MODULE_SURFACE_AREA) {
fc.setCurrentDirectory(new File(packages.elementAt(this.jComboBoxExistingPackage.getSelectedIndex())
.getPath()));
fc.addChoosableFileFilter(new IFileFilter(DataType.MODULE_SURFACE_AREA_EXT));
}
if (mode == DataType.RETURN_TYPE_PACKAGE_SURFACE_AREA) {
fc.setCurrentDirectory(new File(Workspace.getCurrentWorkspace()));
fc.addChoosableFileFilter(new IFileFilter(DataType.PACKAGE_SURFACE_AREA_EXT));
}
if (mode == DataType.RETURN_TYPE_PLATFORM_SURFACE_AREA) {
fc.setCurrentDirectory(new File(Workspace.getCurrentWorkspace()));
fc.addChoosableFileFilter(new IFileFilter(DataType.PLATFORM_SURFACE_AREA_EXT));
}
int result = fc.showSaveDialog(new JPanel());
if (result == JFileChooser.APPROVE_OPTION) {
this.jTextFieldFilePath.setText(Tools.addPathExt(fc.getSelectedFile().getPath(), mode));
}
}
}
/**
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.jTextFieldFilePath.getText())) {
Log.err("File Path couldn't be empty");
return false;
}
if (isEmpty(this.jTextFieldName.getText())) {
Log.err("Name couldn't be empty");
return false;
}
if (isEmpty(this.jTextFieldGuid.getText())) {
Log.err("Guid Value couldn't be empty");
return false;
}
if (isEmpty(this.jTextFieldVersion.getText())) {
Log.err("Version couldn't be empty");
return false;
}
//
// Check if all fields have correct data types
//
if (!DataValidation.isBaseName(this.jTextFieldName.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 (mode == DataType.RETURN_TYPE_MODULE_SURFACE_AREA) {
//
// Check if the module is already existed in current package
//
String packagePath = packages.elementAt(this.jComboBoxExistingPackage.getSelectedIndex()).getPath();
String modulePath = Tools.convertPathToCurrentOsType(this.jTextFieldFilePath.getText());
Vector<String> msaFile = wt.getAllModulesOfPackage(packagePath);
packagePath = packagePath.substring(0, packagePath.lastIndexOf(DataType.FILE_SEPARATOR));
String path = Tools.getRelativePath(modulePath, packagePath);
for (int index = 0; index < msaFile.size(); index++) {
if (msaFile.elementAt(index).equals(path)) {
Log.err("This module is already existing in selected package");
return false;
}
}
}
if (mode == DataType.RETURN_TYPE_PACKAGE_SURFACE_AREA) {
//
// Check if the package is already existed in database
//
String path = Tools.convertPathToCurrentOsType(this.jTextFieldFilePath.getText());
Vector<PackageIdentification> vPackageList = wt.getAllPackages();
if (vPackageList != null && vPackageList.size() > 0) {
for (int index = 0; index < vPackageList.size(); index++) {
if (vPackageList.get(index).getPath().equals(path)) {
Log.err("This package is already existing in database");
return false;
}
}
}
}
if (mode == DataType.RETURN_TYPE_PLATFORM_SURFACE_AREA) {
//
// Check if the platform is already existed in database
//
String path = Tools.convertPathToCurrentOsType(this.jTextFieldFilePath.getText());
Vector<PlatformIdentification> vPlatfromList = wt.getAllPlatforms();
if (vPlatfromList != null && vPlatfromList.size() > 0) {
for (int index = 0; index < vPlatfromList.size(); index++) {
if (vPlatfromList.get(index).getPath().equals(path)) {
Log.err("This platform is already existing in database");
return false;
}
}
}
}
return true;
}
/**
Save file
**/
public void save() {
if (mode == DataType.RETURN_TYPE_MODULE_SURFACE_AREA) {
this.saveModule();
}
if (mode == DataType.RETURN_TYPE_PACKAGE_SURFACE_AREA) {
this.savePackage();
}
if (mode == DataType.RETURN_TYPE_PLATFORM_SURFACE_AREA) {
this.savePlatform();
}
}
/**
Save all components of Msa Header
**/
private void saveModule() {
ModuleSurfaceAreaDocument.ModuleSurfaceArea msa = null;
String path = Tools.convertPathToCurrentOsType(this.jTextFieldFilePath.getText());
//
// Save to memory
//
try {
MsaHeaderDocument.MsaHeader msaHeader = null;
msa = ModuleSurfaceAreaDocument.ModuleSurfaceArea.Factory.newInstance();
msaHeader = MsaHeaderDocument.MsaHeader.Factory.newInstance();
msaHeader.setModuleName(this.jTextFieldName.getText());
msaHeader.setGuidValue(this.jTextFieldGuid.getText());
msaHeader.setVersion(this.jTextFieldVersion.getText());
msa.setMsaHeader(msaHeader);
} catch (Exception e) {
Log.err("Save ModuleSurfaceArea Document", e.getMessage());
return;
}
//
// Save to real file
//
try {
SaveFile.saveMsaFile(path, msa);
} catch (Exception e) {
Log.err("Save Module to file system", e.getMessage());
return;
}
//
// Save to identification
//
mid = new ModuleIdentification(this.jTextFieldName.getText(), this.jTextFieldGuid.getText(),
this.jTextFieldVersion.getText(), path);
mid.setPackageId(packages.elementAt(this.jComboBoxExistingPackage.getSelectedIndex()));
}
/**
Save all components of Spd Header
**/
private void savePackage() {
PackageSurfaceArea spd = null;
String path = Tools.convertPathToCurrentOsType(this.jTextFieldFilePath.getText());
//
// Save to memory
//
try {
SpdHeaderDocument.SpdHeader spdHeader = null;
spd = PackageSurfaceArea.Factory.newInstance();
spdHeader = SpdHeaderDocument.SpdHeader.Factory.newInstance();
spdHeader.setPackageName(this.jTextFieldName.getText());
spdHeader.setGuidValue(this.jTextFieldGuid.getText());
spdHeader.setVersion(this.jTextFieldVersion.getText());
spd.setSpdHeader(spdHeader);
} catch (Exception e) {
Log.err("Save PackageSurfaceArea Document", e.getMessage());
return;
}
//
// Save to real file
//
try {
SaveFile.saveSpdFile(path, spd);
} catch (Exception e) {
Log.err("Save Package to file system", e.getMessage());
return;
}
//
// Save to identification
//
pid = new PackageIdentification(this.jTextFieldName.getText(), this.jTextFieldGuid.getText(),
this.jTextFieldVersion.getText(), path);
}
/**
Save all components of Fpd Header
**/
private void savePlatform() {
PlatformSurfaceArea fpd = null;
String path = Tools.convertPathToCurrentOsType(this.jTextFieldFilePath.getText());
//
// Save to memory
//
try {
PlatformHeader fpdHeader = null;
fpd = PlatformSurfaceArea.Factory.newInstance();
fpdHeader = PlatformHeader.Factory.newInstance();
fpdHeader.setPlatformName(this.jTextFieldName.getText());
fpdHeader.setGuidValue(this.jTextFieldGuid.getText());
fpdHeader.setVersion(this.jTextFieldVersion.getText());
fpd.setPlatformHeader(fpdHeader);
} catch (Exception e) {
Log.err("Save FrameworkPlatformDescription Document", e.getMessage());
return;
}
//
// Save to real file
//
try {
SaveFile.saveFpdFile(path, fpd);
} catch (Exception e) {
Log.err("Save Platform to file system", e.getMessage());
return;
}
//
// Save to identification
//
fid = new PlatformIdentification(this.jTextFieldName.getText(), this.jTextFieldGuid.getText(),
this.jTextFieldVersion.getText(), path);
}
public ModuleIdentification getMid() {
return mid;
}
public void setMid(ModuleIdentification mid) {
this.mid = mid;
}
public PlatformIdentification getFid() {
return fid;
}
public void setFid(PlatformIdentification fid) {
this.fid = fid;
}
public PackageIdentification getPid() {
return pid;
}
public void setPid(PackageIdentification pid) {
this.pid = pid;
}
}

View File

@@ -0,0 +1,166 @@
/** @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.frameworkwizard.common;
/**
The class is used to define all used final variables
**/
public class DataType {
/**
@param args
**/
public static void main(String[] args) {
}
//
// Define all return types
//
public static final int RETURN_TYPE_OK = 1;
public static final int RETURN_TYPE_CANCEL = 2;
public static final int RETURN_TYPE_NEXT = 3;
public static final int RETURN_TYPE_BACK = 4;
public static final int RETURN_TYPE_MODULE_SURFACE_AREA = 11;
public static final int RETURN_TYPE_PACKAGE_SURFACE_AREA = 12;
public static final int RETURN_TYPE_PLATFORM_SURFACE_AREA = 13;
public static final int RETURN_TYPE_BUILD_XML = 14;
public static final int RETURN_TYPE_WORKSPACE = 15;
//
// Define all used final variables
//
public static final String DOS_LINE_SEPARATOR = "\r\n";
public static final String UNIX_LINE_SEPARATOR = "\n";
public static final String EMPTY_SELECT_ITEM = "----";
public static final String DOS_FILE_SEPARATOR = "\\";
public static final String UNIX_FILE_SEPARATOR = "/";
//
// Define xml files ext
//
public static final String COPY_OF = "Copy of ";
public static final String FILE_EXT_SEPARATOR = ".";
public static final String WORKSPACE = "Workspace";
public static final String MODULE_SURFACE_AREA = "Module Surface Area Description";
public static final String MODULE_SURFACE_AREA_EXT = "msa";
public static final String MODULE_SURFACE_AREA_EXT_DESCRIPTION = MODULE_SURFACE_AREA + " (*." + MODULE_SURFACE_AREA_EXT + ")";
public static final String PACKAGE_SURFACE_AREA = "Package Surface Area Description";
public static final String PACKAGE_SURFACE_AREA_EXT = "spd";
public static final String PACKAGE_SURFACE_AREA_EXT_DESCRIPTION = PACKAGE_SURFACE_AREA + " (*." + PACKAGE_SURFACE_AREA_EXT + ")";
public static final String PLATFORM_SURFACE_AREA = "Platform Surface Area Description";
public static final String PLATFORM_SURFACE_AREA_EXT = "fpd";
public static final String PLATFORM_SURFACE_AREA_EXT_DESCRIPTION = PLATFORM_SURFACE_AREA + " (*." + PLATFORM_SURFACE_AREA_EXT + ")";
public static final String ANT_BUILD_FILE = "ANT Build File";
public static final String ANT_BUILD_FILE_EXT = "xml";
public static final String ANT_BUILD_FILE_EXT_DESCRIPTION = ANT_BUILD_FILE + " (*." + ANT_BUILD_FILE_EXT + ")";
//
// Define file separator for current OS
//
public static String FILE_SEPARATOR = System.getProperty("file.separator");
//
// Defien all used frame, container component's sizes
//
public static final int MAIN_FRAME_PREFERRED_SIZE_WIDTH = 800;
public static final int MAIN_FRAME_PREFERRED_SIZE_HEIGHT = 600;
public static final int MAIN_FRAME_MAX_SIZE_WIDTH = 1920;
public static final int MAIN_FRAME_MAX_SIZE_HEIGHT = 1200;
public static final int MAIN_FRAME_SPLIT_PANEL_PREFERRED_SIZE_WIDTH = 790;
public static final int MAIN_FRAME_SPLIT_PANEL_PREFERRED_SIZE_HEIGHT = 545;
public static final int MAIN_FRAME_WIDTH_SPACING = MAIN_FRAME_PREFERRED_SIZE_WIDTH - MAIN_FRAME_SPLIT_PANEL_PREFERRED_SIZE_WIDTH;
public static final int MAIN_FRAME_HEIGHT_SPACING = MAIN_FRAME_PREFERRED_SIZE_HEIGHT - MAIN_FRAME_SPLIT_PANEL_PREFERRED_SIZE_HEIGHT;
public static final int MAIN_FRAME_TREE_PANEL_PREFERRED_SIZE_WIDTH = 273;
public static final int MAIN_FRAME_TREE_PANEL_PREFERRED_SIZE_HEIGHT = 545;
public static final int MAIN_FRAME_EDITOR_PANEL_PREFERRED_SIZE_WIDTH = 515;
public static final int MAIN_FRAME_EDITOR_PANEL_PREFERRED_SIZE_HEIGHT = 545;
public static final int MAIN_FRAME_EDITOR_PANEL_LOCATION_X = 260;
public static final int MAIN_FRAME_EDITOR_PANEL_LOCATION_Y = 1;
public static final int SPACE_TO_RIGHT_FOR_GENERATE_BUTTON = 10;
public static final int SPACE_TO_RIGHT_FOR_OK_BUTTON = 10;
public static final int SPACE_TO_RIGHT_FOR_ADD_BUTTON = 180;
public static final int SPACE_TO_RIGHT_FOR_REMOVE_BUTTON = 95;
public static final int SPACE_TO_RIGHT_FOR_UPDATE_BUTTON = 10;
public static final int SPACE_TO_RIGHT_FOR_PROTOCOL_NOTIFY = 25;
public static final int LEFT_WIDTH = 160;
public static final int LEFT_HEIGHT = 20;
public static final int RIGHT_WIDTH = 320;
public static final int RIGHT_HEIGHT = 20;
public static final int RIGHT_MULTIPLE_HEIGHT = 4 * RIGHT_HEIGHT;
public static final int BUTTON_GEN_WIDTH = 65;
public static final int BUTTON_GEN_HEIGHT = 20;
public static final int BUTTON_BROWSE_WIDTH = 65;
public static final int BUTTON_BROWSE_HEIGHT = 20;
public static final int BUTTON_ADD_WIDTH = 80;
public static final int BUTTON_ADD_HEIGHT = 20;
public static final int BUTTON_UPDATE_WIDTH = 80;
public static final int BUTTON_UPDATE_HEIGHT = 20;
public static final int BUTTON_REMOVE_WIDTH = 80;
public static final int BUTTON_REMOVE_HEIGHT = 20;
public static final int SCROLLBAR_WIDTH = 18;
public static final int SCROLLBAR_HEIGHT = 18;
//
// Common Help Text
// First defined here
// Will be replaced by resource file later
//
public static final String SUP_ARCH_LIST_HELP_TEXT = "Deselecting a checkbox will restrict this module for use with the selected architectures, based on the list of items that are checked. If all boxes are checked, then the module will support all current AND FUTURE architectures";
}

View File

@@ -0,0 +1,712 @@
/** @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.frameworkwizard.common;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
The class is used to provides all kinds of data validation interface
<p>All provided interfaces are in static mode</p>
**/
public class DataValidation {
/**
Reserved for test
@param args
**/
public static void main(String[] args) {
}
//
// 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 UiNameType
@param arg0 The input string need be checked
@retval true - The input is UiNameType
@retval false - The input is not UiNameType
**/
public static boolean isUiNameType(String arg0) {
if (arg0.length() < 1) {
return false;
}
return isMatch("[^ ].*", arg0);
}
/**
Check if the input data is GuidType2
@param arg0 The input string need be checked
@retval true - The input is GuidType2
@retval false - The input is not GuidType2
**/
public static boolean isGuidType2(String arg0) {
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}", arg0);
}
/**
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 arg0) {
return isGuidType2(arg0);
}
/**
Check if the input data is Version
@param arg0 The input string need be checked
@retval true - The input is Version
@retval false - The input is not Version
**/
public static boolean isVersionDataType(String arg0) {
return isMatch("(\\d)+(.)?(\\d)+", arg0);
}
/**
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 arg0) {
return isMatch("(\\w+\\W*)+( )+(\\W*\\w*\\W*\\s*)*", arg0);
}
/**
Check if the input data is FileNameConventio
@param strSentence The input string need be checked
@retval true - The input is FileNameConventio
@retval false - The input is not FileNameConventio
**/
public static boolean isFileNameConvention(String arg0) {
return isMatch("[a-zA-Z][a-zA-Z0-9]*((_)*(-)*(.)*[a-zA-Z0-9]*)*", arg0);
}
/**
Check if the input data is KeywordType
@param strSentence The input string need be checked
@retval true - The input is KeywordType
@retval false - The input is not KeywordType
**/
public static boolean isKeywordType(String arg0) {
return isMatch("[a-zA-Z]+(_*[a-zA-Z0-9]*)*", arg0);
}
/**
Check if the input data is FeatureFlagExpressionType
@param strSentence The input string need be checked
@retval true - The input is FeatureFlagExpressionType
@retval false - The input is not FeatureFlagExpressionType
**/
public static boolean isFeatureFlagExpressionType(String arg0) {
return (arg0.length() >= 1);
}
/**
Check if the input data is FeatureFlag
@param strSentence The input string need be checked
@retval true - The input is FeatureFlag
@retval false - The input is not FeatureFlag
**/
public static boolean isFeatureFlag(String arg0) {
return isFeatureFlagExpressionType(arg0);
}
/**
Check if the input data is PathAndFilename
@param strSentence The input string need be checked
@retval true - The input is PathAndFilename
@retval false - The input is not PathAndFilename
**/
public static boolean isPathAndFilename(String arg0) {
return !arg0.equals("");
}
/**
Check if the input data is ToolsNameConvention
@param strSentence The input string need be checked
@retval true - The input is ToolsNameConvention
@retval false - The input is not ToolsNameConvention
**/
public static boolean isToolsNameConvention(String arg0) {
return isMatch("[a-zA-Z][a-zA-Z0-9]*", arg0);
}
/**
Check if the input data is C_NameType
@param strSentence The input string need be checked
@retval true - The input is C_NameType
@retval false - The input is not C_NameType
**/
public static boolean isC_NameType(String arg0) {
return isMatch("(_)*[a-zA-Z]+((_)*[a-zA-Z0-9]*)*", arg0);
}
/**
Check if the input data is HexWordArrayType
@param strSentence The input string need be checked
@retval true - The input is HexWordArrayType
@retval false - The input is not HexWordArrayType
**/
public static boolean isHexWordArrayType(String arg0) {
return isMatch("((\\s)*0x([a-fA-F0-9]){4}(,)?(\\s)*)+", arg0);
}
/**
Check if the input data is Hex64BitDataType
@param strSentence The input string need be checked
@retval true - The input is Hex64BitDataType
@retval false - The input is not Hex64BitDataType
**/
public static boolean isHex64BitDataType(String arg0) {
return isMatch("(0x)?[a-fA-F0-9]{1,16}", arg0);
}
/**
Check if the input data is UnicodeString
@param strSentence The input string need be checked
@retval true - The input is UnicodeString
@retval false - The input is not UnicodeString
**/
public static boolean isUnicodeString(String arg0) {
return arg0.length() >= 3 && isMatch("(\\s)*L(\\:)?\"[^\"]*\"(\\s)*", arg0);
}
/**
Check if the input data is HexByteArrayType
@param strSentence The input string need be checked
@retval true - The input is HexByteArrayType
@retval false - The input is not HexByteArrayType
**/
public static boolean isHexByteArrayType(String arg0) {
return arg0.length() >= 4 && isMatch("((\\s)*0x([a-fA-F0-9]){2}(,)?(\\s)*)+", arg0);
}
/**
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 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 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);
}
/**
Check if the input data is Supported Architectures
@param strSupportedArchitectures
@retval true - The input is Supported Architectures
@retval false - The input isn't Supported Architectures
*/
public static boolean isSupportedArchitectures(String strSupportedArchitectures) {
return isMatch("(ALL){1}|(((IA32)|((X64)|(IPF)|(EBC)){1}((,((IA32)|(X64)|(IPF)|(EBC)){1} ){0,2}))){1}",
strSupportedArchitectures);
}
//
//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 arg0) {
return isUiNameType(arg0);
}
/**
Check if the input data is Version
@param arg0 The input string need be checked
@retval true - The input is Version
@retval false - The input is not Version
**/
public static boolean isVersion(String arg0) {
return isVersionDataType(arg0);
}
/**
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 arg0) {
return isSentence(arg0);
}
/**
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 arg0) {
return !arg0.equals("");
}
/**
Check if the input data is Specification
@param strCopyright The input string need be checked
@retval true - The input is Specification
@retval false - The input is not Specification
**/
public static boolean isSpecification(String arg0) {
return isSentence(arg0);
}
//
// The below is used to check ModuleDefinitions data types
//
/**
Check if the input data is OutputFileBasename
@param strCopyright The input string need be checked
@retval true - The input is OutputFileBasename
@retval false - The input is not OutputFileBasename
**/
public static boolean isOutputFileBasename(String arg0) {
return isFileNameConvention(arg0);
}
//
// The below is used to check LibraryClass data types
//
/**
Check if the input data is LibraryClass
@param strCopyright The input string need be checked
@retval true - The input is LibraryClass
@retval false - The input is not LibraryClass
**/
public static boolean isLibraryClass(String arg0) {
return isKeywordType(arg0);
}
/**
Check if the input data is RecommendedInstanceVersion
@param strCopyright The input string need be checked
@retval true - The input is RecommendedInstanceVersion
@retval false - The input is not RecommendedInstanceVersion
**/
public static boolean isRecommendedInstanceVersion(String arg0) {
return isVersionDataType(arg0);
}
//
// The below is used to check sourcefiles data types
//
/**
Check if the input data is Filename
@param strPath The input string need be checked
@retval true - The input is Filename
@retval false - The input is not Filename
**/
public static boolean isFilename(String arg0) {
return isPathAndFilename(arg0);
}
/**
Check if the input data is TagName
@param strPath The input string need be checked
@retval true - The input is TagName
@retval false - The input is not TagName
**/
public static boolean isTagName(String arg0) {
return isToolsNameConvention(arg0);
}
/**
Check if the input data is ToolCode
@param strPath The input string need be checked
@retval true - The input is ToolCode
@retval false - The input is not ToolCode
**/
public static boolean isToolCode(String arg0) {
return isToolsNameConvention(arg0);
}
/**
Check if the input data is ToolChainFamily
@param strPath The input string need be checked
@retval true - The input is ToolChainFamily
@retval false - The input is not ToolChainFamily
**/
public static boolean isToolChainFamily(String arg0) {
return isToolsNameConvention(arg0);
}
//
// The below is used to check pcdcoded data types
//
/**
Check if the input data is DefaultValueType
@param strPath The input string need be checked
@retval true - The input is DefaultValueType
@retval false - The input is not DefaultValueType
**/
public static boolean isDefaultValueType(String arg0) {
return isHex64BitDataType(arg0) || isUnicodeString(arg0) || isHexByteArrayType(arg0);
}
}

View File

@@ -0,0 +1,203 @@
/** @file
The file is used to provides interfaces for file 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.frameworkwizard.common;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStream;
public class FileOperation {
/**
@param args
* @throws Exception
**/
public static void main(String[] args) throws Exception {
FileOperation.newFolder("C:\\aaa\\bbb\\ccc\\ddd\\eee");
}
/**
To new a folder
@param folderPath The folder path to be created
@throws Exception
**/
public static void newFolder(String folderPath) throws Exception {
folderPath = Tools.convertPathToCurrentOsType(folderPath);
String temp = "";
while (folderPath.length() > 0) {
if (folderPath.indexOf(DataType.FILE_SEPARATOR) > -1) {
temp = temp + folderPath.substring(0, folderPath.indexOf(DataType.FILE_SEPARATOR));
if (temp.endsWith(":")) {
temp = temp + DataType.FILE_SEPARATOR;
folderPath = folderPath.substring(folderPath.indexOf(DataType.FILE_SEPARATOR) + DataType.FILE_SEPARATOR.length());
continue;
}
temp = temp + DataType.FILE_SEPARATOR;
folderPath = folderPath.substring(folderPath.indexOf(DataType.FILE_SEPARATOR) + DataType.FILE_SEPARATOR.length());
} else {
temp = temp + DataType.FILE_SEPARATOR + folderPath;
folderPath = "";
}
File f = new File(temp);
if (!f.exists()) {
f.mkdir();
}
}
}
/**
Delete a file
@param filePath The file path to be deleted
@throws Exception
**/
public static void delFile(String filePath) throws Exception {
File f = new File(filePath);
if (f.exists()) {
f.delete();
}
}
/**
Delete a folder and all its files
@param filePath The name of the folder which need be deleted
@throws Exception
**/
public static void delFolder(String filePath) throws Exception {
File f = new File(filePath);
if (!f.exists()) {
return;
}
if (!f.isDirectory()) {
return;
}
delFolder(f);
}
/**
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
**/
private static boolean delFolder(File fileName) throws Exception {
boolean blnIsDeleted = true;
File[] aryAllFiles = fileName.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 = delFolder(aryAllFiles[indexI]);
} else if (aryAllFiles[indexI].isFile()) {
//
//If is a file, delete it
//
if (!aryAllFiles[indexI].delete()) {
blnIsDeleted = false;
}
}
}
}
if (blnIsDeleted) {
fileName.delete();
}
return blnIsDeleted;
}
/**
Copy a file
@param oldPath
@param newPath
@throws Exception
**/
public static void copyFile(String oldPath, String newPath) throws Exception {
int byteCount = 0;
File oldFile = new File(oldPath);
if (oldFile.exists()) {
InputStream is = new FileInputStream(oldPath);
FileOutputStream fos = new FileOutputStream(newPath);
byte[] buffer = new byte[1024];
while ((byteCount = is.read(buffer)) != -1) {
fos.write(buffer, 0, byteCount);
}
is.close();
}
}
/**
Copy a folder
@param oldPath
@param newPath
@throws Exception
**/
public static void copyFolder(String oldPath, String newPath) throws Exception {
File oldFile = new File(oldPath);
//
// Create new file path first
//
newFolder(newPath);
String[] files = oldFile.list();
File temp = null;
for (int index = 0; index < files.length; index++) {
if (oldPath.endsWith(DataType.FILE_SEPARATOR)) {
temp = new File(oldPath + files[index]);
} else {
temp = new File(oldPath + DataType.FILE_SEPARATOR + files[index]);
}
if (temp.isFile()) {
FileInputStream fis = new FileInputStream(temp);
FileOutputStream fos = new FileOutputStream(newPath + DataType.FILE_SEPARATOR
+ (temp.getName()).toString());
byte[] b = new byte[1024 * 5];
int len;
while ((len = fis.read(b)) != -1) {
fos.write(b, 0, len);
}
fos.flush();
fos.close();
fis.close();
}
if (temp.isDirectory()) {
copyFolder(oldPath + DataType.FILE_SEPARATOR + files[index], newPath + DataType.FILE_SEPARATOR
+ files[index]);
}
}
}
}

View File

@@ -0,0 +1,87 @@
/** @file
The file is used to override FileFilter to provides customized interfaces
Copyright (c) 2006, Intel Corporation
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
package org.tianocore.frameworkwizard.common;
import java.io.File;
import javax.swing.filechooser.FileFilter;
/**
The class is used to override FileFilter to provides customized interfaces
**/
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(DataType.MODULE_SURFACE_AREA_EXT))
return DataType.MODULE_SURFACE_AREA_EXT_DESCRIPTION;
if (strExt.equals(DataType.PACKAGE_SURFACE_AREA_EXT))
return DataType.PACKAGE_SURFACE_AREA_EXT_DESCRIPTION;
if (strExt.equals(DataType.PLATFORM_SURFACE_AREA_EXT))
return DataType.PLATFORM_SURFACE_AREA_EXT_DESCRIPTION;
return "";
}
}

View File

@@ -0,0 +1,209 @@
/** @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.frameworkwizard.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
**/
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.UNIX_LINE_SEPARATOR;
} else if (strErr.length() <= intMaxLength) {
strReturn = strReturn + strErr;
strErr = "";
}
}
JOptionPane.showConfirmDialog(null, strReturn, "Error", JOptionPane.DEFAULT_OPTION, JOptionPane.ERROR_MESSAGE);
}
/**
Open log file and write log information
@param strLog The log information
@throws IOException
**/
private static void writeToLogFile(String strLog) throws IOException {
try {
if (fleLogFile == null) {
fleLogFile = new File(strLogFileName);
fleLogFile.createNewFile();
}
FileOutputStream fos = new FileOutputStream(fleLogFile, true);
fos.write((Tools.getCurrentDateTime() + DataType.DOS_LINE_SEPARATOR).getBytes());
fos.write((strLog + DataType.DOS_LINE_SEPARATOR).getBytes());
fos.flush();
fos.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
/**
Open err file and write err information
@param strLog The log information
@throws IOException
**/
private static void writeToErrFile(String strLog) throws IOException {
try {
if (fleErrFile == null) {
fleErrFile = new File(strErrFileName);
fleErrFile.createNewFile();
}
FileOutputStream fos = new FileOutputStream(fleErrFile, true);
fos.write((Tools.getCurrentDateTime() + DataType.DOS_LINE_SEPARATOR).getBytes());
fos.write((strLog + DataType.DOS_LINE_SEPARATOR).getBytes());
fos.flush();
fos.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
}

View File

@@ -0,0 +1,158 @@
/** @file
The file provides interface to save 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.frameworkwizard.common;
import java.io.File;
import org.apache.xmlbeans.XmlCursor;
import org.apache.xmlbeans.XmlOptions;
import org.tianocore.FrameworkDatabaseDocument;
import org.tianocore.ModuleSurfaceAreaDocument;
import org.tianocore.PackageSurfaceAreaDocument;
import org.tianocore.PlatformSurfaceAreaDocument;
import org.tianocore.FrameworkDatabaseDocument.FrameworkDatabase;
import org.tianocore.ModuleSurfaceAreaDocument.ModuleSurfaceArea;
import org.tianocore.PackageSurfaceAreaDocument.PackageSurfaceArea;
import org.tianocore.PlatformSurfaceAreaDocument.PlatformSurfaceArea;
public class SaveFile {
/**
@param args
**/
public static void main(String[] args) {
// TODO Auto-generated method stub
}
/**
Save file as msa
**/
public static void saveMsaFile(String path, ModuleSurfaceArea msa) throws Exception {
ModuleSurfaceAreaDocument msaDoc = ModuleSurfaceAreaDocument.Factory.newInstance();
File f = new File(path);
//
//Init namespace
//
XmlCursor cursor = XmlConfig.setupXmlCursor(msa.newCursor());
//
//Config file format
//
XmlOptions options = XmlConfig.setupXmlOptions();
//
//Create finial doc
//
msaDoc.addNewModuleSurfaceArea();
msaDoc.setModuleSurfaceArea((ModuleSurfaceArea) cursor.getObject());
//
//Save the file
//
msaDoc.save(f, options);
}
/**
Save file as spd
**/
public static void saveSpdFile(String path, PackageSurfaceArea spd) throws Exception {
PackageSurfaceAreaDocument spdDoc = PackageSurfaceAreaDocument.Factory.newInstance();
File f = new File(path);
//
//Init namespace
//
XmlCursor cursor = XmlConfig.setupXmlCursor(spd.newCursor());
//
//Config file format
//
XmlOptions options = XmlConfig.setupXmlOptions();
//
//Create finial doc
//
spdDoc.addNewPackageSurfaceArea();
spdDoc.setPackageSurfaceArea((PackageSurfaceArea) cursor.getObject());
//
//Save the file
//
spdDoc.save(f, options);
}
/**
Save file as fpd
**/
public static void saveFpdFile(String path, PlatformSurfaceArea fpd) throws Exception {
PlatformSurfaceAreaDocument fpdDoc = PlatformSurfaceAreaDocument.Factory.newInstance();
File f = new File(path);
//
//Init namespace
//
XmlCursor cursor = XmlConfig.setupXmlCursor(fpd.newCursor());
//
//Config file format
//
XmlOptions options = XmlConfig.setupXmlOptions();
//
//Create finial doc
//
fpdDoc.addNewPlatformSurfaceArea();
fpdDoc.setPlatformSurfaceArea((PlatformSurfaceArea) cursor.getObject());
//
//Save the file
//
fpdDoc.save(f, options);
}
/**
Save file as framework db
**/
public static void saveDbFile(String path, FrameworkDatabase db) throws Exception {
FrameworkDatabaseDocument dbDoc = FrameworkDatabaseDocument.Factory.newInstance();
File f = new File(path);
//
//Init namespace
//
XmlCursor cursor = XmlConfig.setupXmlCursor(db.newCursor());
//
//Config file format
//
XmlOptions options = XmlConfig.setupXmlOptions();
//
//Create finial doc
//
dbDoc.addNewFrameworkDatabase();
dbDoc.setFrameworkDatabase((FrameworkDatabase) cursor.getObject());
//
//Save the file
//
dbDoc.save(f, options);
}
}

View File

@@ -0,0 +1,278 @@
/** @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.frameworkwizard.common;
import java.io.File;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.UUID;
import java.util.Vector;
import javax.swing.JComboBox;
import javax.swing.JOptionPane;
/**
The class is used to provides some useful interfaces
**/
public class Tools {
//
// The dir user selected to create new package in
//
public static String dirForNewSpd = null;
/**
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);
}
/**
Generate a UUID
@return the created UUID
**/
public static String generateUuidString() {
return UUID.randomUUID().toString();
}
/**
Use current file separator in the path
@param strPath
@return
**/
public static String convertPathToCurrentOsType(String strPath) {
strPath = strPath.replace(DataType.DOS_FILE_SEPARATOR, DataType.FILE_SEPARATOR);
strPath = strPath.replace(DataType.UNIX_FILE_SEPARATOR, DataType.FILE_SEPARATOR);
return strPath;
}
/**
Use Unix file separator in the path
@param strPath
@return
**/
public static String convertPathToUnixType(String strPath) {
strPath = strPath.replace(DataType.DOS_FILE_SEPARATOR, DataType.UNIX_FILE_SEPARATOR);
return strPath;
}
/**
Use Dos file separator in the path
@param strPath
@return
**/
public static String convertPathToDosType(String strPath) {
strPath = strPath.replace(DataType.UNIX_FILE_SEPARATOR, DataType.DOS_FILE_SEPARATOR);
return strPath;
}
/**
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"));
}
/**
Generate selection items for JComboBox by input vector
**/
public static void generateComboBoxByVector(JComboBox jcb, Vector<String> vector) {
if (jcb != null) {
jcb.removeAllItems();
}
if (vector != null) {
for (int index = 0; index < vector.size(); index++) {
jcb.addItem(vector.elementAt(index));
}
}
}
/**
Get path only from a path
@param filePath
@return
**/
public static String getFilePathOnly(String filePath) {
String path = filePath.substring(0, filePath.length() - getFileNameOnly(filePath).length());
if (path.endsWith(DataType.FILE_SEPARATOR)) {
path = path.substring(0, path.length() - DataType.FILE_SEPARATOR.length());
}
return path;
}
/**
Get file name from a path
@param filePath
@return
**/
public static String getFileNameOnly(String filePath) {
File f = new File(filePath);
return f.getAbsoluteFile().getName();
}
public static String getFileNameWithoutExt(String filePath) {
filePath = getFileNameOnly(filePath);
filePath = filePath.substring(0, filePath.lastIndexOf(DataType.FILE_EXT_SEPARATOR));
return filePath;
}
/**
Get relative path
@param wholePath
@param commonPath
@return wholePath - commonPath
**/
public static String getRelativePath(String wholePath, String commonPath) {
String path = "";
int i = 0;
i = wholePath.indexOf(commonPath);
if (i > -1) {
i = i + commonPath.length();
} else {
return "";
}
path = wholePath.substring(i);
//
// remove file separator of head
//
if (path.indexOf(DataType.DOS_FILE_SEPARATOR) == 0) {
path = path.substring(0 + DataType.DOS_FILE_SEPARATOR.length());
}
if (path.indexOf(DataType.UNIX_FILE_SEPARATOR) == 0) {
path = path.substring(0 + DataType.DOS_FILE_SEPARATOR.length());
}
//
// remove file separator of rear
//
if (path.indexOf(DataType.DOS_FILE_SEPARATOR) == path.length() - DataType.DOS_FILE_SEPARATOR.length()) {
path = path.substring(0, path.length() - DataType.DOS_FILE_SEPARATOR.length());
}
if (path.indexOf(DataType.UNIX_FILE_SEPARATOR) == path.length() - DataType.UNIX_FILE_SEPARATOR.length()) {
path = path.substring(0, path.length() - DataType.DOS_FILE_SEPARATOR.length());
}
//
// convert to UNIX format
//
path = Tools.convertPathToUnixType(path);
return path;
}
/**
Convert List ot Vector
@param list
@return
**/
public static Vector<String> convertListToVector(List list) {
Vector<String> v = new Vector<String>();
if (list != null && list.size() > 0) {
for (int index = 0; index < list.size(); index++) {
v.addElement(list.get(index).toString());
}
}
return v;
}
/**
If the input path missing ext, append the ext to the path
@param path
@param type
@return
**/
public static String addPathExt(String path, int type) {
String match = "";
if (type == DataType.RETURN_TYPE_MODULE_SURFACE_AREA) {
match = DataType.FILE_EXT_SEPARATOR + DataType.MODULE_SURFACE_AREA_EXT;
}
if (type == DataType.RETURN_TYPE_PACKAGE_SURFACE_AREA) {
match = DataType.FILE_EXT_SEPARATOR + DataType.PACKAGE_SURFACE_AREA_EXT;
}
if (type == DataType.RETURN_TYPE_PLATFORM_SURFACE_AREA) {
match = DataType.FILE_EXT_SEPARATOR + DataType.PLATFORM_SURFACE_AREA_EXT;
}
if (path.length() <= match.length()) {
path = path + match;
return path;
}
if (!(path.substring(path.length() - match.length())).equals(match)) {
path = path + match;
}
return path;
}
/**
Show a message box
@param arg0
**/
public static void showInformationMessage(String arg0) {
JOptionPane.showConfirmDialog(null, arg0, "Error", JOptionPane.DEFAULT_OPTION, JOptionPane.INFORMATION_MESSAGE);
}
}

View File

@@ -0,0 +1,40 @@
/** @file
The file is used to config XML file format
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.frameworkwizard.common;
import org.apache.xmlbeans.XmlCursor;
import org.apache.xmlbeans.XmlOptions;
public class XmlConfig {
public static XmlCursor setupXmlCursor(XmlCursor cursor) {
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();
return cursor;
}
public static XmlOptions setupXmlOptions() {
XmlOptions options = new XmlOptions();
options.setCharacterEncoding("UTF-8");
options.setSavePrettyPrint();
options.setSavePrettyPrintIndent(2);
return options;
}
}

View File

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

View File

@@ -0,0 +1,197 @@
/** @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.frameworkwizard.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
**/
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);
this.setToolTipText("Double Click to add an entry and finished by press ENTER. Press DELETE can remove selected entry.");
}
public void keyPressed(KeyEvent arg0) {
// TODO Auto-generated method stub
}
/* (non-Javadoc)
* @see java.awt.event.KeyListener#keyReleased(java.awt.event.KeyEvent)
*
* Override keyReleased to listen key action
*
*/
public void keyReleased(KeyEvent arg0) {
//
//Add new item to list when press ENTER
//
if (arg0.getSource() == this.getEditor().getEditorComponent()) {
if (arg0.getKeyCode() == KeyEvent.VK_ENTER) {
String strCurrentText = this.getEditor().getItem().toString().trim();
if (strCurrentText.length() == 0) {
if (this.getItemCount() > 0) {
this.setSelectedIndex(0);
}
} else {
this.addItem(strCurrentText);
this.setSelectedItem(strCurrentText);
}
this.setEditable(false);
}
if (arg0.getKeyCode() == KeyEvent.VK_ESCAPE) {
closeEdit();
}
}
if (arg0.getSource() == this) {
//
//Remove item from the list when press DEL
//
if (arg0.getKeyCode() == KeyEvent.VK_DELETE) {
int intSelected = this.getSelectedIndex();
if (intSelected > -1) {
this.removeItemAt(this.getSelectedIndex());
if (this.getItemCount() > 0) {
this.setSelectedIndex(0);
} else {
this.removeAllItems();
}
}
}
}
}
public void keyTyped(KeyEvent arg0) {
// TODO Auto-generated method stub
}
/* (non-Javadoc)
* @see java.awt.event.MouseListener#mouseClicked(java.awt.event.MouseEvent)
*
* Override mouseClicked to enter edit mode when double click mouse
*
*/
public void mouseClicked(MouseEvent arg0) {
if (arg0.getClickCount() == 2) {
this.setEditable(true);
this.getEditor().setItem("");
}
}
public void mouseEntered(MouseEvent arg0) {
// TODO Auto-generated method stub
}
public void mouseExited(MouseEvent arg0) {
// TODO Auto-generated method stub
}
public void mousePressed(MouseEvent arg0) {
// TODO Auto-generated method stub
}
public void mouseReleased(MouseEvent arg0) {
// TODO Auto-generated method stub
}
/**
Exit edit mode
**/
private void closeEdit() {
this.setEditable(false);
this.getEditor().setItem("");
if (this.getItemCount() > 0) {
this.setSelectedIndex(0);
}
}
}

View File

@@ -0,0 +1,344 @@
/** @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.frameworkwizard.common.ui;
import javax.swing.tree.DefaultMutableTreeNode;
import org.tianocore.frameworkwizard.common.Identification;
/**
The class is used to override DefaultMutableTreeNode to provides customized interfaces
It extends DefaultMutableTreeNode
**/
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 = 100;
public static final int MSA_LIBRARYCLASSDEFINITIONS = 101;
public static final int MSA_PACKAGEDEPENDENCIES = 102;
public static final int MSA_SOURCEFILES = 103;
public static final int MSA_PROTOCOLS = 104;
public static final int MSA_EVENTS = 105;
public static final int MSA_HOBS = 106;
public static final int MSA_PPIS = 107;
public static final int MSA_VARIABLES = 108;
public static final int MSA_BOOTMODES = 109;
public static final int MSA_SYSTEMTABLES = 110;
public static final int MSA_DATAHUBS = 111;
//public static final int MSA_FORMSETS = 112;
public static final int MSA_HIIPACKAGES = 112;
public static final int MSA_GUIDS = 113;
public static final int MSA_EXTERNS = 114;
public static final int MSA_PCDS = 115;
public static final int MSA_BUILDOPTIONS = 117;
public static final int MSA_USEREXTENSIONS = 118;
public static final int MSA_MODULEDEFINITIONS = 119;
public static final int SPD_HEADER = 200;
public static final int SPD_LIBRARYCLASSDECLARATIONS = 201;
public static final int SPD_MSAFILES = 202;
public static final int SPD_PACKAGEHEADERS = 203;
public static final int SPD_GUIDDECLARATIONS = 204;
public static final int SPD_PROTOCOLDECLARATIONS = 205;
public static final int SPD_PPIDECLARATIONS = 206;
public static final int SPD_PCDDECLARATIONS = 207;
public static final int SPD_PACKAGEDEFINITIONS = 208;
public static final int SPD_INDUSTRYSTDINCLUDES = 209;
public static final int FPD_PLATFORMHEADER = 300;
public static final int FPD_FLASH = 301;
public static final int FPD_FRAMEWORKMODULES = 302;
public static final int FPD_PCDDYNAMICBUILDDECLARATIONS = 303;
public static final int FPD_BUILDOPTIONS = 304;
public static final int FPD_PLATFORMDEFINITIONS = 305;
public static final int WORKSPACE = 0;
public static final int MODULE = 1;
public static final int PACKAGE = 2;
public static final int PLATFORM = 3;
//
//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 = "";
private boolean isOpening = false;
private Identification id = null;
/**
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 bolIsOpened to identify if the node is opening or not
@param identification The Identification of node
**/
public IDefaultMutableTreeNode(String strNodeName, int intCategory, boolean bolIsOpening,
Identification identification) {
super(strNodeName);
this.nodeName = strNodeName;
this.category = intCategory;
this.isOpening = bolIsOpening;
this.id = identification;
}
/**
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;
}
/**
Get identification of node
@return
**/
public Identification getId() {
return id;
}
/**
Set identification of node
@param id
**/
public void setId(Identification id) {
this.id = id;
}
/**
get isOpening of node
@return
**/
public boolean isOpening() {
return isOpening;
}
/**
Set isOpening of node
@param isOpening
**/
public void setOpening(boolean isOpening) {
this.isOpening = isOpening;
}
}

View File

@@ -0,0 +1,76 @@
/** @file
The file is used to override DefaultDesktopManager to provides customized interfaces
Copyright (c) 2006, Intel Corporation
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
package org.tianocore.frameworkwizard.common.ui;
import javax.swing.DefaultDesktopManager;
import javax.swing.JComponent;
/**
The class is used to override DefaultDesktopManager to provides customized interfaces
It extends DefaultDesktopManager
**/
public class IDesktopManager extends DefaultDesktopManager {
///
/// Define class Serial Version UID
///
private static final long serialVersionUID = -4596986878722011062L;
/**
Main class, reserved for test
@param args
**/
public static void main(String[] args) {
// TODO Auto-generated method stub
}
/* (non-Javadoc)
* @see javax.swing.DesktopManager#dragFrame(javax.swing.JComponent, int, int)
*
* Override dragFrame to do nothing to forbid internalframe to be draged
*
*/
public void dragFrame(JComponent f, int newX, int newY) {
}
/* (non-Javadoc)
* @see javax.swing.DesktopManager#endDraggingFrame(javax.swing.JComponent)
*
* Override endDraggingFrame to do nothing to forbid internalframe to be draged
*
*/
public void endDraggingFrame(JComponent f) {
}
/* (non-Javadoc)
* @see javax.swing.DesktopManager#beginResizingFrame(javax.swing.JComponent, int)
*
* Override beginResizingFrame to do nothing to forbid internalframe to be draged
*
*/
public void beginResizingFrame(JComponent f, int direction) {
}
}

View File

@@ -0,0 +1,157 @@
/** @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.frameworkwizard.common.ui;
import java.awt.Dimension;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JDialog;
import org.tianocore.frameworkwizard.common.DataType;
/**
The class is used to override Dialog to provides customized interfaces
It extends JDialog implements ActionListener
**/
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 int returnType = DataType.RETURN_TYPE_CANCEL;
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;
}
/**
Display the dialog
**/
public int showDialog() {
this.setVisible(true);
return returnType;
}
}

View File

@@ -0,0 +1,217 @@
/** @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.frameworkwizard.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;
import javax.swing.JOptionPane;
/**
The class is used to override Frame to provides customized interfaces
It extends JFrame implements ActionListener and WindowListener
**/
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 window full of the screen
**/
protected void maxWindow() {
Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
this.setLocation(0, 0);
this.setSize(d);
}
/**
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();
}
}
public int showSaveDialog() {
return JOptionPane.showConfirmDialog(null, "Save all changed files?", "Save", JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE);
}
}

View File

@@ -0,0 +1,275 @@
/** @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.frameworkwizard.common.ui;
import java.awt.Component;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ComponentEvent;
import java.awt.event.ComponentListener;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import javax.swing.JDesktopPane;
import javax.swing.JFrame;
import javax.swing.JInternalFrame;
import javax.swing.JPanel;
import org.tianocore.frameworkwizard.common.DataType;
/**
* The class is used to override JInternalFrame to provides customized
* interfaces It extends JInternalFrame implements ActionListener
*
*
*
*/
public class IInternalFrame extends JInternalFrame implements ActionListener, ComponentListener, ItemListener, FocusListener {
// /
// / Define class Serial Version UID
// /
private static final long serialVersionUID = -609841772384875886L;
//
// Define class members
//
private boolean isEdited = false;
/**
* Main class, used for test
*
* @param args
*
*/
public static void main(String[] args) {
JFrame jf = new JFrame();
JPanel jp = new JPanel();
JDesktopPane jdp = new JDesktopPane();
IInternalFrame itf = new IInternalFrame();
jdp.add(itf, 1);
jf.setContentPane(jp);
jf.setVisible(true);
}
/**
* This is the default constructor
*
*/
public IInternalFrame() {
super();
initialize();
}
/**
* This method initializes this
*
*/
private void initialize() {
this.setBounds(new java.awt.Rectangle(0, 0, 520, 545));
this.setMinimumSize(new java.awt.Dimension(520, 545));
this.addComponentListener(this);
}
/**
* 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
}
public void componentHidden(ComponentEvent arg0) {
// TODO Auto-generated method stub
}
public void componentMoved(ComponentEvent arg0) {
// TODO Auto-generated method stub
}
public void componentResized(ComponentEvent arg0) {
// TODO Auto-generated method stub
}
public void componentShown(ComponentEvent arg0) {
// TODO Auto-generated method stub
}
/**
* To reset the width of input component via container width
*
* @param c
* @param containerWidth
*
*/
public void resizeComponentWidth(Component c, int containerWidth, int preferredWidth) {
int newWidth = c.getPreferredSize().width
+ (containerWidth - preferredWidth);
if (newWidth < c.getPreferredSize().width) {
newWidth = c.getPreferredSize().width;
}
c.setSize(new java.awt.Dimension(newWidth, c.getHeight()));
c.validate();
}
/**
* To reset the height of input component via container height
*
* @param c
* @param containerHeight
*
*/
public void resizeComponentHeight(Component c, int containerHeight, int preferredHeight) {
int newHeight = c.getPreferredSize().height + (containerHeight - preferredHeight);
if (newHeight < c.getPreferredSize().height) {
newHeight = c.getPreferredSize().height;
}
c.setSize(new java.awt.Dimension(c.getWidth(), newHeight));
c.validate();
}
/**
* To reset the size of input component via container size
*
* @param c
* @param containerWidth
* @param containerHeight
*
*/
public void resizeComponent(Component c, int containerWidth, int containerHeight, int preferredWidth, int preferredHeight) {
resizeComponentWidth(c, containerWidth, preferredWidth);
resizeComponentHeight(c, containerHeight, preferredHeight);
}
/**
* To relocate the input component
*
* @param c
* @param containerWidth
* @param spaceToRight
*
*/
public void relocateComponentX(Component c, int containerWidth, int preferredWidth, int spaceToRight) {
int intGapToRight = spaceToRight + c.getPreferredSize().width;
int newLocationX = containerWidth - intGapToRight;
if (newLocationX < preferredWidth -intGapToRight) {
newLocationX = preferredWidth - intGapToRight;
}
c.setLocation(newLocationX, c.getLocation().y);
c.validate();
}
/**
* To relocate the input component
*
* @param c
* @param containerHeight
* @param spaceToBottom
*
*/
public void relocateComponentY(Component c, int containerHeight, int spaceToBottom) {
int newLocationY = containerHeight - spaceToBottom;
if (newLocationY < DataType.MAIN_FRAME_EDITOR_PANEL_PREFERRED_SIZE_HEIGHT - spaceToBottom) {
newLocationY = DataType.MAIN_FRAME_EDITOR_PANEL_PREFERRED_SIZE_HEIGHT - spaceToBottom;
}
c.setLocation(c.getLocation().x, newLocationY);
c.validate();
}
/**
* To relocate the input component
*
* @param c
* @param containerWidth
* @param containerHeight
* @param spaceToBottom
* @param spaceToRight
*
*/
public void relocateComponent(Component c, int containerWidth, int containerHeight, int spaceToBottom,
int spaceToRight, int preferredWidht, int preferredHeight) {
relocateComponentX(c, containerWidth, preferredWidht, spaceToBottom);
relocateComponentY(c, containerHeight, spaceToRight);
}
public void showStandard() {
}
public void showAdvanced() {
}
public void showXML() {
}
public void itemStateChanged(ItemEvent arg0) {
// TODO Auto-generated method stub
}
public void focusGained(FocusEvent arg0) {
// TODO Auto-generated method stub
}
public void focusLost(FocusEvent arg0) {
// TODO Auto-generated method stub
}
}

View File

@@ -0,0 +1,249 @@
/** @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.frameworkwizard.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;
import org.tianocore.frameworkwizard.common.Identification;
/**
The class is used to override JTree to provides customized interfaces
It extends JTree
**/
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);
treeModel = (DefaultTreeModel)this.getModel();
}
/**
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()));
}
/**
Add input node as child node for current selected node
@param newNode The node need be added
**/
public void addNode(IDefaultMutableTreeNode parentNode, IDefaultMutableTreeNode newNode) {
treeModel.insertNodeInto(newNode, parentNode, parentNode.getChildCount());
this.scrollPathToVisible(new TreePath(newNode.getPath()));
}
/**
Remove the selected node
@param strRemovedNode
**/
public void removeSelectedNode() {
TreePath treePath = this.getSelectionPath();
removeNodeByPath(treePath);
}
/**
Remove the node by tree path
@param strRemovedNode
**/
public void removeNodeByPath(TreePath treePath) {
if (treePath != null) {
DefaultMutableTreeNode selectionNode = (DefaultMutableTreeNode) treePath.getLastPathComponent();
TreeNode parent = (TreeNode) selectionNode.getParent();
if (parent != null) {
treeModel.removeNodeFromParent(selectionNode);
}
}
}
/**
Remove all child nodes under current node
**/
public void removeNodeChildrenByPath(TreePath treePath) {
if (treePath != null) {
DefaultMutableTreeNode currentNode = (DefaultMutableTreeNode) treePath.getLastPathComponent();
for (int index = currentNode.getChildCount() - 1; index > -1; index--) {
treeModel.removeNodeFromParent((DefaultMutableTreeNode)currentNode.getChildAt(index));
}
}
}
/**
Remove all nodes of the tree
**/
public void removeAllNode() {
DefaultMutableTreeNode rootNode = (DefaultMutableTreeNode) treeModel.getRoot();
rootNode.removeAllChildren();
treeModel.reload();
}
public IDefaultMutableTreeNode getSelectNode() {
TreePath treepath = this.getSelectionPath();
IDefaultMutableTreeNode selectionNode = null;
if (treepath != null) {
selectionNode = (IDefaultMutableTreeNode) treepath.getLastPathComponent();
}
return selectionNode;
}
public IDefaultMutableTreeNode getNodeById(IDefaultMutableTreeNode node, Identification id) {
for (int index = 0; index < node.getChildCount(); index++) {
IDefaultMutableTreeNode iNode = (IDefaultMutableTreeNode) node.getChildAt(index);
if (iNode.getId().equals(id)) {
return iNode;
}
}
return null;
}
public IDefaultMutableTreeNode getNodeById(IDefaultMutableTreeNode node, Identification id, int category) {
for (int index = 0; index < node.getChildCount(); index++) {
IDefaultMutableTreeNode iNode = (IDefaultMutableTreeNode) node.getChildAt(index);
if (iNode.getId().equals(id) && iNode.getCategory() == category) {
return iNode;
}
}
return null;
}
public TreePath getPathOfNode(IDefaultMutableTreeNode node) {
TreePath treePath = new TreePath(treeModel.getPathToRoot(node));
return treePath;
}
}

View File

@@ -0,0 +1,64 @@
/** @file
The file is used to override JLabel to provides customized interfaces
Copyright (c) 2006, Intel Corporation
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
package org.tianocore.frameworkwizard.common.ui;
import javax.swing.JLabel;
/**
The class is used to override JLabel to provides customized interfaces
**/
public class StarLabel extends JLabel {
///
/// Define class Serial Version UID
///
private static final long serialVersionUID = -6702981027831543919L;
/**
Main class, reserved for test
@param args
**/
public static void main(String[] args) {
// TODO Auto-generated method stub
}
/**
This is the default constructor
**/
public StarLabel() {
super();
init();
}
/**
To create a RED, BOLD and 14 size "*"
**/
private void init() {
this.setText("*");
this.setSize(new java.awt.Dimension(10, 20));
this.setForeground(java.awt.Color.red);
this.setFont(new java.awt.Font("DialogInput", java.awt.Font.BOLD, 14));
this.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
}
}

View File

@@ -0,0 +1,162 @@
/** @file
The file is used to override JList to create a List with CheckBox item
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.frameworkwizard.common.ui.iCheckBoxList;
import java.util.Vector;
import javax.swing.JList;
public class ICheckBoxList extends JList {
///
/// Define class Serial Version UID
///
private static final long serialVersionUID = -2843059688070447632L;
protected ICheckBoxListCellRenderer cellrenderer = new ICheckBoxListCellRenderer();
protected ICheckBoxListener listener = new ICheckBoxListener(this);
protected ICheckBoxListModel model = new ICheckBoxListModel();
/**
This the default Constructor
**/
public ICheckBoxList() {
this(null);
}
/**
This the override constructor to create checkbox item with input vector
@param options
**/
public ICheckBoxList(Vector<ICheckBoxListItem> items) {
if (items != null) {
for (int index = 0; index < items.size(); index++) {
model.addElement(items.elementAt(index));
}
}
this.setCellRenderer(cellrenderer);
this.setModel(model);
this.addMouseListener(listener);
this.addKeyListener(listener);
}
/**
Set all items of the CheckBoxList component.
@param items
**/
public void setAllItems(Vector<String> items) {
if (items != null) {
model.removeAllElements();
for (int index = 0; index < items.size(); index++) {
model.addElement(new ICheckBoxListItem(items.elementAt(index)));
}
}
}
/**
Get All Checked Items of the CheckBoxList component.
@return All Checked Items
**/
public Vector<ICheckBoxListItem> getAllCheckedItems() {
Vector<ICheckBoxListItem> result = new Vector<ICheckBoxListItem>();
for (int i = 0; i < this.getModel().getSize(); i++) {
if (((ICheckBoxListItem) this.getModel().getElementAt(i)).isChecked()) {
result.addElement((ICheckBoxListItem) this.getModel().getElementAt(i));
}
}
return result;
}
/**
Get All Checked Items String of the CheckBoxList component.
@return Vector
**/
public Vector<String> getAllCheckedItemsString() {
Vector<String> result = new Vector<String>();
for (int i = 0; i < this.getModel().getSize(); i++) {
if (((ICheckBoxListItem) this.getModel().getElementAt(i)).isChecked()) {
result.addElement(((ICheckBoxListItem) this.getModel().getElementAt(i)).text);
}
}
return result;
}
/**
Get All Items String of the CheckBoxList component.
@return Vector
**/
public Vector<String> getAllItemsString() {
Vector<String> result = new Vector<String>();
for (int i = 0; i < this.getModel().getSize(); i++) {
result.addElement(((ICheckBoxListItem) this.getModel().getElementAt(i)).text);
}
return result;
}
/**
Set Checked status for all input items.
**/
public void initCheckedItem(boolean bool, Vector<String> items) {
if (items != null && items.size() != 0) {
for (int indexI = 0; indexI < items.size(); indexI++) {
for (int indexJ = 0; indexJ < model.size(); indexJ++) {
if (items.elementAt(indexI).equals(model.getAllElements().elementAt(indexJ).getText())) {
ICheckBoxListItem listItem = (ICheckBoxListItem) model.get(indexJ);
listItem.setChecked(bool);
break;
}
}
}
}
this.validate();
}
/**
Set all items of the compontent checked
**/
public void setAllItemsChecked() {
initCheckedItem(true, this.getAllItemsString());
}
/**
Set all items of the compontent unchecked
**/
public void setAllItemsUnchecked() {
initCheckedItem(false, this.getAllItemsString());
}
/**
Remove all items of list
**/
public void removeAllItem() {
model.removeAllElements();
}
}

View File

@@ -0,0 +1,76 @@
/** @file
The file is used to create cell renderer for CheckBoxList Item
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.frameworkwizard.common.ui.iCheckBoxList;
import java.awt.*;
import javax.swing.*;
import javax.swing.border.*;
class ICheckBoxListCellRenderer extends JCheckBox implements ListCellRenderer {
///
/// Define class Serial Version UID
///
private static final long serialVersionUID = -1718072217181674870L;
protected static Border noFocusBorder = new EmptyBorder(1, 1, 1, 1);
/**
This is the default Constructor
**/
public ICheckBoxListCellRenderer() {
super();
setOpaque(true);
setBorder(noFocusBorder);
}
/* (non-Javadoc)
* @see javax.swing.ListCellRenderer#getListCellRendererComponent(javax.swing.JList, java.lang.Object, int, boolean, boolean)
* Override to get attribute of the ICheckListCellRenderer
*
*/
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected,
boolean cellHasFocus) {
ICheckBoxListItem item = (ICheckBoxListItem) value;
setComponentOrientation(list.getComponentOrientation());
if (item.isChecked()) {
setBackground(list.getSelectionBackground());
setForeground(list.getSelectionForeground());
} else {
if (isSelected) {
setBackground(Color.LIGHT_GRAY);
setForeground(list.getForeground());
} else {
setBackground(list.getBackground());
setForeground(list.getForeground());
}
}
if (value instanceof ICheckBoxListItem) {
setText(item.getText());
setSelected(item.isChecked());
} else {
setIcon(null);
setText((value == null) ? "" : value.toString());
}
setEnabled(list.isEnabled());
setFont(list.getFont());
return this;
}
}

View File

@@ -0,0 +1,74 @@
/** @file
The file is used to create list item for CheckBox list
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.frameworkwizard.common.ui.iCheckBoxList;
public class ICheckBoxListItem {
//
// Define Class Members
//
protected String text;
protected boolean checked;
/**
This is the default constructor to set check box item string
@param text
**/
public ICheckBoxListItem(String text) {
this.text = text;
}
/**
This is the override constructor to set check box item string and checked status
@param text
@param checked
**/
public ICheckBoxListItem(String text, boolean checked) {
this.text = text;
this.checked = checked;
}
/**
set the checked status
if true, set false
if false, set true
**/
public void invertChecked() {
checked = !checked;
}
public boolean isChecked() {
return checked;
}
public void setChecked(boolean checked) {
this.checked = checked;
}
public String getText() {
return text;
}
public void setText(String text) {
this.text = text;
}
}

View File

@@ -0,0 +1,67 @@
/** @file
The file is used to override DefaultListModel to create ICheckBoxListModel
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.frameworkwizard.common.ui.iCheckBoxList;
import javax.swing.*;
import java.util.Vector;
public class ICheckBoxListModel extends DefaultListModel {
///
/// Define class Serial Version UID
///
private static final long serialVersionUID = -8617800969723991017L;
/**
This is the default Constructor for the CheckBoxListModel object
**/
public ICheckBoxListModel() {
}
/**
override DefaultListModel's add method
@param index
@param item
**/
public void add(int index, ICheckBoxListItem item) {
super.add(index, item);
}
/**
Add one item at tail
@param item
**/
public void addElement(ICheckBoxListItem item) {
super.addElement(item);
}
/**
Get all elements of the list
**/
public Vector<ICheckBoxListItem> getAllElements() {
Vector<ICheckBoxListItem> items = new Vector<ICheckBoxListItem>();
ICheckBoxListItem[] objs = new ICheckBoxListItem[this.size()];
this.copyInto(objs);
for (int i = 0; i < size(); i++) {
items.addElement(objs[i]);
}
return items;
}
}

View File

@@ -0,0 +1,104 @@
/** @file
The file is used to create listener for Checkbox List
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.frameworkwizard.common.ui.iCheckBoxList;
import java.awt.event.*;
class ICheckBoxListener implements MouseListener, KeyListener {
protected ICheckBoxList iCheckboxlist;
/**
This is the default constructor
@param parent
**/
public ICheckBoxListener(ICheckBoxList parent) {
iCheckboxlist = parent;
}
/* (non-Javadoc)
* @see java.awt.event.KeyListener#keyReleased(java.awt.event.KeyEvent)
* Override to deal with keyReleased event
*
*
*/
public void keyReleased(KeyEvent e) {
Object[] selectedValues = iCheckboxlist.getSelectedValues();
int[] selectedIndices = iCheckboxlist.getSelectedIndices();
for (int index = 0; index < selectedValues.length; index++) {
ICheckBoxListItem item = (ICheckBoxListItem) selectedValues[index];
if (iCheckboxlist.isEnabled()) {
if (e.getKeyCode() == KeyEvent.VK_SPACE) {
//
//if press space key, then reverse all selected item.
//
item.invertChecked();
}
((ICheckBoxListModel) iCheckboxlist.getModel()).setElementAt(item, selectedIndices[index]);
}
}
}
/* (non-Javadoc)
* @see java.awt.event.MouseListener#mouseClicked(java.awt.event.MouseEvent)
* Override to deal with mouse clicked event
*
*/
public void mouseClicked(MouseEvent e) {
int index = iCheckboxlist.locationToIndex(e.getPoint());
ICheckBoxListItem item = null;
item = (ICheckBoxListItem) iCheckboxlist.getModel().getElementAt(index);
if (item != null && iCheckboxlist.isEnabled()) {
item.invertChecked();
((ICheckBoxListModel) iCheckboxlist.getModel()).setElementAt(item, index);
}
}
public void mousePressed(MouseEvent arg0) {
// TODO Auto-generated method stub
}
public void mouseReleased(MouseEvent arg0) {
// TODO Auto-generated method stub
}
public void mouseEntered(MouseEvent arg0) {
// TODO Auto-generated method stub
}
public void mouseExited(MouseEvent arg0) {
// TODO Auto-generated method stub
}
public void keyPressed(KeyEvent arg0) {
// TODO Auto-generated method stub
}
public void keyTyped(KeyEvent arg0) {
// TODO Auto-generated method stub
}
}

View File

@@ -0,0 +1,89 @@
/** @file
The file is used to define Package Dependencies Identification
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.frameworkwizard.module.Identification.BootModes;
import java.util.Vector;
public class BootModesIdentification {
//
// Define class members
//
private String name = null;
private String usage = null;
private Vector<String> supArchList = null;
private String featureFlag = null;
private String help = null;
public BootModesIdentification(String arg0, String arg1, String arg2, Vector<String> arg3, String arg4) {
this.name = (arg0 == null ? "" : arg0);
this.usage = (arg1 == null ? "" : arg1);
this.featureFlag = (arg2 == null ? "" : arg2);
this.supArchList = arg3;
this.help = (arg4 == null ? "" : arg4);
}
public String getFeatureFlag() {
return featureFlag;
}
public void setFeatureFlag(String featureFlag) {
this.featureFlag = featureFlag;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Vector<String> getSupArchList() {
return supArchList;
}
public void setSupArchList(Vector<String> supArchList) {
this.supArchList = supArchList;
}
public boolean equals(BootModesIdentification pi) {
if (this.name.equals(pi.name)) {
return true;
}
return false;
}
public String getUsage() {
return usage;
}
public void setUsage(String usage) {
this.usage = usage;
}
public String getHelp() {
return help;
}
public void setHelp(String help) {
this.help = help;
}
}

View File

@@ -0,0 +1,90 @@
/** @file
The file is used to define Package Dependencies Vector
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.frameworkwizard.module.Identification.BootModes;
import java.util.Vector;
public class BootModesVector {
private Vector<BootModesIdentification> vBootModes = new Vector<BootModesIdentification>();
public int findBootModes(BootModesIdentification sfi) {
for (int index = 0; index < vBootModes.size(); index++) {
if (vBootModes.elementAt(index).equals(sfi)) {
return index;
}
}
return -1;
}
public int findBootModes(String name) {
for (int index = 0; index < vBootModes.size(); index++) {
if (vBootModes.elementAt(index).getName().equals(name)) {
return index;
}
}
return -1;
}
public BootModesIdentification getBootModes(int index) {
if (index > -1) {
return vBootModes.elementAt(index);
} else {
return null;
}
}
public void addBootModes(BootModesIdentification arg0) {
vBootModes.addElement(arg0);
}
public void updateBootModes(BootModesIdentification arg0, int arg1) {
vBootModes.setElementAt(arg0, arg1);
}
public void removeBootModes(BootModesIdentification arg0) {
int index = findBootModes(arg0);
if (index > -1) {
vBootModes.removeElementAt(index);
}
}
public void removeBootModes(int index) {
if (index > -1 && index < this.size()) {
vBootModes.removeElementAt(index);
}
}
public Vector<BootModesIdentification> getvBootModes() {
return vBootModes;
}
public void setvBootModes(Vector<BootModesIdentification> BootModes) {
vBootModes = BootModes;
}
public Vector<String> getBootModesName() {
Vector<String> v = new Vector<String>();
for (int index = 0; index < this.vBootModes.size(); index++) {
v.addElement(vBootModes.get(index).getName());
}
return v;
}
public int size() {
return this.vBootModes.size();
}
}

View File

@@ -0,0 +1,89 @@
/** @file
The file is used to define Package Dependencies Identification
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.frameworkwizard.module.Identification.DataHubs;
import java.util.Vector;
public class DataHubsIdentification {
//
// Define class members
//
private String name = null;
private String usage = null;
private Vector<String> supArchList = null;
private String featureFlag = null;
private String help = null;
public DataHubsIdentification(String arg0, String arg1, String arg2, Vector<String> arg3, String arg4) {
this.name = (arg0 == null ? "" : arg0);
this.usage = (arg1 == null ? "" : arg1);
this.featureFlag = (arg2 == null ? "" : arg2);
this.supArchList = arg3;
this.help = (arg4 == null ? "" : arg4);
}
public String getFeatureFlag() {
return featureFlag;
}
public void setFeatureFlag(String featureFlag) {
this.featureFlag = featureFlag;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Vector<String> getSupArchList() {
return supArchList;
}
public void setSupArchList(Vector<String> supArchList) {
this.supArchList = supArchList;
}
public boolean equals(DataHubsIdentification pi) {
if (this.name.equals(pi.name)) {
return true;
}
return false;
}
public String getUsage() {
return usage;
}
public void setUsage(String usage) {
this.usage = usage;
}
public String getHelp() {
return help;
}
public void setHelp(String help) {
this.help = help;
}
}

View File

@@ -0,0 +1,90 @@
/** @file
The file is used to define Package Dependencies Vector
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.frameworkwizard.module.Identification.DataHubs;
import java.util.Vector;
public class DataHubsVector {
private Vector<DataHubsIdentification> vDataHubs = new Vector<DataHubsIdentification>();
public int findDataHubs(DataHubsIdentification sfi) {
for (int index = 0; index < vDataHubs.size(); index++) {
if (vDataHubs.elementAt(index).equals(sfi)) {
return index;
}
}
return -1;
}
public int findDataHubs(String name) {
for (int index = 0; index < vDataHubs.size(); index++) {
if (vDataHubs.elementAt(index).getName().equals(name)) {
return index;
}
}
return -1;
}
public DataHubsIdentification getDataHubs(int index) {
if (index > -1) {
return vDataHubs.elementAt(index);
} else {
return null;
}
}
public void addDataHubs(DataHubsIdentification arg0) {
vDataHubs.addElement(arg0);
}
public void updateDataHubs(DataHubsIdentification arg0, int arg1) {
vDataHubs.setElementAt(arg0, arg1);
}
public void removeDataHubs(DataHubsIdentification arg0) {
int index = findDataHubs(arg0);
if (index > -1) {
vDataHubs.removeElementAt(index);
}
}
public void removeDataHubs(int index) {
if (index > -1 && index < this.size()) {
vDataHubs.removeElementAt(index);
}
}
public Vector<DataHubsIdentification> getvDataHubs() {
return vDataHubs;
}
public void setvDataHubs(Vector<DataHubsIdentification> DataHubs) {
vDataHubs = DataHubs;
}
public Vector<String> getDataHubsName() {
Vector<String> v = new Vector<String>();
for (int index = 0; index < this.vDataHubs.size(); index++) {
v.addElement(vDataHubs.get(index).getName());
}
return v;
}
public int size() {
return this.vDataHubs.size();
}
}

View File

@@ -0,0 +1,100 @@
/** @file
The file is used to define Package Dependencies Identification
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.frameworkwizard.module.Identification.Events;
import java.util.Vector;
public class EventsIdentification {
//
// Define class members
//
private String name = null;
private String type = null;
private String usage = null;
private Vector<String> supArchList = null;
private String featureFlag = null;
private String help = null;
public EventsIdentification(String arg0, String arg1, String arg2, String arg3, Vector<String> arg4, String arg5) {
this.name = (arg0 == null ? "" : arg0);
this.type = (arg1 == null ? "" : arg1);
this.usage = (arg2 == null ? "" : arg2);
this.featureFlag = (arg3 == null ? "" : arg3);
this.supArchList = arg4;
this.help = (arg5 == null ? "" : arg5);
}
public String getFeatureFlag() {
return featureFlag;
}
public void setFeatureFlag(String featureFlag) {
this.featureFlag = featureFlag;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Vector<String> getSupArchList() {
return supArchList;
}
public void setSupArchList(Vector<String> supArchList) {
this.supArchList = supArchList;
}
public boolean equals(EventsIdentification pi) {
if (this.name.equals(pi.name)) {
return true;
}
return false;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getUsage() {
return usage;
}
public void setUsage(String usage) {
this.usage = usage;
}
public String getHelp() {
return help;
}
public void setHelp(String help) {
this.help = help;
}
}

View File

@@ -0,0 +1,90 @@
/** @file
The file is used to define Package Dependencies Vector
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.frameworkwizard.module.Identification.Events;
import java.util.Vector;
public class EventsVector {
private Vector<EventsIdentification> vEvents = new Vector<EventsIdentification>();
public int findEvents(EventsIdentification sfi) {
for (int index = 0; index < vEvents.size(); index++) {
if (vEvents.elementAt(index).equals(sfi)) {
return index;
}
}
return -1;
}
public int findEvents(String name) {
for (int index = 0; index < vEvents.size(); index++) {
if (vEvents.elementAt(index).getName().equals(name)) {
return index;
}
}
return -1;
}
public EventsIdentification getEvents(int index) {
if (index > -1) {
return vEvents.elementAt(index);
} else {
return null;
}
}
public void addEvents(EventsIdentification arg0) {
vEvents.addElement(arg0);
}
public void updateEvents(EventsIdentification arg0, int arg1) {
vEvents.setElementAt(arg0, arg1);
}
public void removeEvents(EventsIdentification arg0) {
int index = findEvents(arg0);
if (index > -1) {
vEvents.removeElementAt(index);
}
}
public void removeEvents(int index) {
if (index > -1 && index < this.size()) {
vEvents.removeElementAt(index);
}
}
public Vector<EventsIdentification> getvEvents() {
return vEvents;
}
public void setvEvents(Vector<EventsIdentification> Events) {
vEvents = Events;
}
public Vector<String> getEventsName() {
Vector<String> v = new Vector<String>();
for (int index = 0; index < this.vEvents.size(); index++) {
v.addElement(vEvents.get(index).getName());
}
return v;
}
public int size() {
return this.vEvents.size();
}
}

View File

@@ -0,0 +1,78 @@
/** @file
The file is used to define Package Dependencies Identification
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.frameworkwizard.module.Identification.Externs;
import java.util.Vector;
public class ExternsIdentification {
//
// Define class members
//
private String name = null;
private String type = null;
private Vector<String> supArchList = null;
private String featureFlag = null;
public ExternsIdentification(String arg0, String arg1, String arg2, Vector<String> arg3) {
this.name = (arg0 == null ? "" : arg0);
this.type = (arg1 == null ? "" : arg1);
this.featureFlag = (arg2 == null ? "" : arg2);
this.supArchList = arg3;
}
public String getFeatureFlag() {
return featureFlag;
}
public void setFeatureFlag(String featureFlag) {
this.featureFlag = featureFlag;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Vector<String> getSupArchList() {
return supArchList;
}
public void setSupArchList(Vector<String> supArchList) {
this.supArchList = supArchList;
}
public boolean equals(ExternsIdentification pi) {
if (this.name.equals(pi.name)) {
return true;
}
return false;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
}

View File

@@ -0,0 +1,90 @@
/** @file
The file is used to define Package Dependencies Vector
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.frameworkwizard.module.Identification.Externs;
import java.util.Vector;
public class ExternsVector {
private Vector<ExternsIdentification> vExterns = new Vector<ExternsIdentification>();
public int findExterns(ExternsIdentification sfi) {
for (int index = 0; index < vExterns.size(); index++) {
if (vExterns.elementAt(index).equals(sfi)) {
return index;
}
}
return -1;
}
public int findExterns(String name) {
for (int index = 0; index < vExterns.size(); index++) {
if (vExterns.elementAt(index).getName().equals(name)) {
return index;
}
}
return -1;
}
public ExternsIdentification getExterns(int index) {
if (index > -1) {
return vExterns.elementAt(index);
} else {
return null;
}
}
public void addExterns(ExternsIdentification arg0) {
vExterns.addElement(arg0);
}
public void updateExterns(ExternsIdentification arg0, int arg1) {
vExterns.setElementAt(arg0, arg1);
}
public void removeExterns(ExternsIdentification arg0) {
int index = findExterns(arg0);
if (index > -1) {
vExterns.removeElementAt(index);
}
}
public void removeExterns(int index) {
if (index > -1 && index < this.size()) {
vExterns.removeElementAt(index);
}
}
public Vector<ExternsIdentification> getvExterns() {
return vExterns;
}
public void setvExterns(Vector<ExternsIdentification> Externs) {
vExterns = Externs;
}
public Vector<String> getExternsName() {
Vector<String> v = new Vector<String>();
for (int index = 0; index < this.vExterns.size(); index++) {
v.addElement(vExterns.get(index).getName());
}
return v;
}
public int size() {
return this.vExterns.size();
}
}

View File

@@ -0,0 +1,89 @@
/** @file
The file is used to define Package Dependencies Identification
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.frameworkwizard.module.Identification.Guids;
import java.util.Vector;
public class GuidsIdentification {
//
// Define class members
//
private String name = null;
private String usage = null;
private Vector<String> supArchList = null;
private String featureFlag = null;
private String help = null;
public GuidsIdentification(String arg0, String arg1, String arg2, Vector<String> arg3, String arg4) {
this.name = (arg0 == null ? "" : arg0);
this.usage = (arg1 == null ? "" : arg1);
this.featureFlag = (arg2 == null ? "" : arg2);
this.supArchList = arg3;
this.help = (arg4 == null ? "" : arg4);
}
public String getFeatureFlag() {
return featureFlag;
}
public void setFeatureFlag(String featureFlag) {
this.featureFlag = featureFlag;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Vector<String> getSupArchList() {
return supArchList;
}
public void setSupArchList(Vector<String> supArchList) {
this.supArchList = supArchList;
}
public boolean equals(GuidsIdentification pi) {
if (this.name.equals(pi.name)) {
return true;
}
return false;
}
public String getUsage() {
return usage;
}
public void setUsage(String usage) {
this.usage = usage;
}
public String getHelp() {
return help;
}
public void setHelp(String help) {
this.help = help;
}
}

View File

@@ -0,0 +1,90 @@
/** @file
The file is used to define Package Dependencies Vector
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.frameworkwizard.module.Identification.Guids;
import java.util.Vector;
public class GuidsVector {
private Vector<GuidsIdentification> vGuids = new Vector<GuidsIdentification>();
public int findGuids(GuidsIdentification sfi) {
for (int index = 0; index < vGuids.size(); index++) {
if (vGuids.elementAt(index).equals(sfi)) {
return index;
}
}
return -1;
}
public int findGuids(String name) {
for (int index = 0; index < vGuids.size(); index++) {
if (vGuids.elementAt(index).getName().equals(name)) {
return index;
}
}
return -1;
}
public GuidsIdentification getGuids(int index) {
if (index > -1) {
return vGuids.elementAt(index);
} else {
return null;
}
}
public void addGuids(GuidsIdentification arg0) {
vGuids.addElement(arg0);
}
public void updateGuids(GuidsIdentification arg0, int arg1) {
vGuids.setElementAt(arg0, arg1);
}
public void removeGuids(GuidsIdentification arg0) {
int index = findGuids(arg0);
if (index > -1) {
vGuids.removeElementAt(index);
}
}
public void removeGuids(int index) {
if (index > -1 && index < this.size()) {
vGuids.removeElementAt(index);
}
}
public Vector<GuidsIdentification> getvGuids() {
return vGuids;
}
public void setvGuids(Vector<GuidsIdentification> Guids) {
vGuids = Guids;
}
public Vector<String> getGuidsName() {
Vector<String> v = new Vector<String>();
for (int index = 0; index < this.vGuids.size(); index++) {
v.addElement(vGuids.get(index).getName());
}
return v;
}
public int size() {
return this.vGuids.size();
}
}

View File

@@ -0,0 +1,89 @@
/** @file
The file is used to define Package Dependencies Identification
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.frameworkwizard.module.Identification.HiiPackages;
import java.util.Vector;
public class HiiPackagesIdentification {
//
// Define class members
//
private String name = null;
private String usage = null;
private Vector<String> supArchList = null;
private String featureFlag = null;
private String help = null;
public HiiPackagesIdentification(String arg0, String arg1, String arg2, Vector<String> arg3, String arg4) {
this.name = (arg0 == null ? "" : arg0);
this.usage = (arg1 == null ? "" : arg1);
this.featureFlag = (arg2 == null ? "" : arg2);
this.supArchList = arg3;
this.help = (arg4 == null ? "" : arg4);
}
public String getFeatureFlag() {
return featureFlag;
}
public void setFeatureFlag(String featureFlag) {
this.featureFlag = featureFlag;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Vector<String> getSupArchList() {
return supArchList;
}
public void setSupArchList(Vector<String> supArchList) {
this.supArchList = supArchList;
}
public boolean equals(HiiPackagesIdentification pi) {
if (this.name.equals(pi.name)) {
return true;
}
return false;
}
public String getUsage() {
return usage;
}
public void setUsage(String usage) {
this.usage = usage;
}
public String getHelp() {
return help;
}
public void setHelp(String help) {
this.help = help;
}
}

View File

@@ -0,0 +1,90 @@
/** @file
The file is used to define Package Dependencies Vector
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.frameworkwizard.module.Identification.HiiPackages;
import java.util.Vector;
public class HiiPackagesVector {
private Vector<HiiPackagesIdentification> vHiiPackages = new Vector<HiiPackagesIdentification>();
public int findHiiPackages(HiiPackagesIdentification sfi) {
for (int index = 0; index < vHiiPackages.size(); index++) {
if (vHiiPackages.elementAt(index).equals(sfi)) {
return index;
}
}
return -1;
}
public int findHiiPackages(String name) {
for (int index = 0; index < vHiiPackages.size(); index++) {
if (vHiiPackages.elementAt(index).getName().equals(name)) {
return index;
}
}
return -1;
}
public HiiPackagesIdentification getHiiPackages(int index) {
if (index > -1) {
return vHiiPackages.elementAt(index);
} else {
return null;
}
}
public void addHiiPackages(HiiPackagesIdentification arg0) {
vHiiPackages.addElement(arg0);
}
public void updateHiiPackages(HiiPackagesIdentification arg0, int arg1) {
vHiiPackages.setElementAt(arg0, arg1);
}
public void removeHiiPackages(HiiPackagesIdentification arg0) {
int index = findHiiPackages(arg0);
if (index > -1) {
vHiiPackages.removeElementAt(index);
}
}
public void removeHiiPackages(int index) {
if (index > -1 && index < this.size()) {
vHiiPackages.removeElementAt(index);
}
}
public Vector<HiiPackagesIdentification> getvHiiPackages() {
return vHiiPackages;
}
public void setvHiiPackages(Vector<HiiPackagesIdentification> HiiPackages) {
vHiiPackages = HiiPackages;
}
public Vector<String> getHiiPackagesName() {
Vector<String> v = new Vector<String>();
for (int index = 0; index < this.vHiiPackages.size(); index++) {
v.addElement(vHiiPackages.get(index).getName());
}
return v;
}
public int size() {
return this.vHiiPackages.size();
}
}

View File

@@ -0,0 +1,100 @@
/** @file
The file is used to define Package Dependencies Identification
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.frameworkwizard.module.Identification.Hobs;
import java.util.Vector;
public class HobsIdentification {
//
// Define class members
//
private String name = null;
private String type = null;
private String usage = null;
private Vector<String> supArchList = null;
private String featureFlag = null;
private String help = null;
public HobsIdentification(String arg0, String arg1, String arg2, String arg3, Vector<String> arg4, String arg5) {
this.name = (arg0 == null ? "" : arg0);
this.type = (arg1 == null ? "" : arg1);
this.usage = (arg2 == null ? "" : arg2);
this.featureFlag = (arg3 == null ? "" : arg3);
this.supArchList = arg4;
this.help = (arg5 == null ? "" : arg5);
}
public String getFeatureFlag() {
return featureFlag;
}
public void setFeatureFlag(String featureFlag) {
this.featureFlag = featureFlag;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Vector<String> getSupArchList() {
return supArchList;
}
public void setSupArchList(Vector<String> supArchList) {
this.supArchList = supArchList;
}
public boolean equals(HobsIdentification pi) {
if (this.name.equals(pi.name)) {
return true;
}
return false;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getUsage() {
return usage;
}
public void setUsage(String usage) {
this.usage = usage;
}
public String getHelp() {
return help;
}
public void setHelp(String help) {
this.help = help;
}
}

View File

@@ -0,0 +1,90 @@
/** @file
The file is used to define Package Dependencies Vector
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.frameworkwizard.module.Identification.Hobs;
import java.util.Vector;
public class HobsVector {
private Vector<HobsIdentification> vHobs = new Vector<HobsIdentification>();
public int findHobs(HobsIdentification sfi) {
for (int index = 0; index < vHobs.size(); index++) {
if (vHobs.elementAt(index).equals(sfi)) {
return index;
}
}
return -1;
}
public int findHobs(String name) {
for (int index = 0; index < vHobs.size(); index++) {
if (vHobs.elementAt(index).getName().equals(name)) {
return index;
}
}
return -1;
}
public HobsIdentification getHobs(int index) {
if (index > -1) {
return vHobs.elementAt(index);
} else {
return null;
}
}
public void addHobs(HobsIdentification arg0) {
vHobs.addElement(arg0);
}
public void updateHobs(HobsIdentification arg0, int arg1) {
vHobs.setElementAt(arg0, arg1);
}
public void removeHobs(HobsIdentification arg0) {
int index = findHobs(arg0);
if (index > -1) {
vHobs.removeElementAt(index);
}
}
public void removeHobs(int index) {
if (index > -1 && index < this.size()) {
vHobs.removeElementAt(index);
}
}
public Vector<HobsIdentification> getvHobs() {
return vHobs;
}
public void setvHobs(Vector<HobsIdentification> Hobs) {
vHobs = Hobs;
}
public Vector<String> getHobsName() {
Vector<String> v = new Vector<String>();
for (int index = 0; index < this.vHobs.size(); index++) {
v.addElement(vHobs.get(index).getName());
}
return v;
}
public int size() {
return this.vHobs.size();
}
}

View File

@@ -0,0 +1,124 @@
/** @file
The file is used to define Library Class Identification
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.frameworkwizard.module.Identification.LibraryClass;
import java.util.Vector;
public class LibraryClassIdentification {
private String libraryClassName = null;
private String usage = null;
private String recommendedInstanceVersion = null;
private String recommendedInstanceGuid = null;
private Vector<String> supArchList = null;
private String featureFlag = null;
private Vector<String> supModuleList = null;
private String help = null;
public LibraryClassIdentification() {
}
public LibraryClassIdentification(String strName, String strUsage, String strRecommendedInstanceVersion,
String strRecommendedInstanceGuid, Vector<String> vSupArchList,
String strFeatureFlag, Vector<String> vSupModuleList, String strHelp) {
this.libraryClassName = (strName == null ? "" : strName);
this.usage = (strUsage == null ? "" : strUsage);
this.recommendedInstanceVersion = (strRecommendedInstanceVersion == null ? "" : strRecommendedInstanceVersion);
this.recommendedInstanceGuid = (strRecommendedInstanceGuid == null ? "" : strRecommendedInstanceGuid);
this.supArchList = vSupArchList;
this.featureFlag = (strFeatureFlag == null ? "" : strFeatureFlag);
this.supModuleList = vSupModuleList;
this.help = (strHelp == null ? "" : strHelp);
}
public String getLibraryClassName() {
return libraryClassName;
}
public void setLibraryClassName(String libraryClassName) {
this.libraryClassName = libraryClassName;
}
public String getUsage() {
return usage;
}
public void setUsage(String usage) {
this.usage = usage;
}
public String getFeatureFlag() {
return featureFlag;
}
public void setFeatureFlag(String featureFlag) {
this.featureFlag = featureFlag;
}
public String getRecommendedInstanceGuid() {
return recommendedInstanceGuid;
}
public void setRecommendedInstanceGuid(String recommendedInstanceGuid) {
this.recommendedInstanceGuid = recommendedInstanceGuid;
}
public String getRecommendedInstanceVersion() {
return recommendedInstanceVersion;
}
public void setRecommendedInstanceVersion(String recommendedInstanceVersion) {
this.recommendedInstanceVersion = recommendedInstanceVersion;
}
public Vector<String> getSupArchList() {
return supArchList;
}
public void setSupArchList(Vector<String> supArchList) {
this.supArchList = supArchList;
}
public boolean equals(LibraryClassIdentification lib) {
if (this.libraryClassName.equals(lib.libraryClassName) && this.usage.equals(lib.getUsage())) {
return true;
}
return false;
}
public Vector<String> getSupModuleList() {
return supModuleList;
}
public void setSupModuleList(Vector<String> supModuleList) {
this.supModuleList = supModuleList;
}
public String getHelp() {
return help;
}
public void setHelp(String help) {
this.help = help;
}
}

View File

@@ -0,0 +1,89 @@
/** @file
The file is used to define Library Class Vector
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.frameworkwizard.module.Identification.LibraryClass;
import java.util.Vector;
public class LibraryClassVector {
private Vector<LibraryClassIdentification> vLibraryClass = new Vector<LibraryClassIdentification>();
public int findLibraryClass(LibraryClassIdentification lib) {
for (int index = 0; index < vLibraryClass.size(); index++) {
if (vLibraryClass.elementAt(index).equals(lib)) {
return index;
}
}
return -1;
}
public int findLibraryClass(String name) {
for (int index = 0; index < vLibraryClass.size(); index++) {
if (vLibraryClass.elementAt(index).getLibraryClassName().equals(name)) {
return index;
}
}
return -1;
}
public LibraryClassIdentification getLibraryClass(int index) {
if (index > -1) {
return vLibraryClass.elementAt(index);
} else {
return null;
}
}
public void addLibraryClass(LibraryClassIdentification lib) {
vLibraryClass.addElement(lib);
}
public void updateLibraryClass(LibraryClassIdentification lib, int index) {
vLibraryClass.setElementAt(lib, index);
}
public void removeLibraryClass(LibraryClassIdentification lib) {
int index = findLibraryClass(lib);
if (index > -1) {
vLibraryClass.removeElementAt(index);
}
}
public void removeLibraryClass(int index) {
if (index > -1 && index < this.size()) {
vLibraryClass.removeElementAt(index);
}
}
public Vector<LibraryClassIdentification> getVLibraryClass() {
return vLibraryClass;
}
public void setVLibraryClass(Vector<LibraryClassIdentification> libraryClass) {
vLibraryClass = libraryClass;
}
public Vector<String> getLibraryClassName() {
Vector<String> v = new Vector<String>();
for (int index = 0; index < this.vLibraryClass.size(); index++) {
v.addElement(vLibraryClass.get(index).getLibraryClassName());
}
return v;
}
public int size() {
return this.vLibraryClass.size();
}
}

View File

@@ -0,0 +1,69 @@
/** @file
The file is used to save basic information of module
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.frameworkwizard.module.Identification;
import org.tianocore.frameworkwizard.common.Identification;
import org.tianocore.frameworkwizard.packaging.PackageIdentification;
public class ModuleIdentification extends Identification {
private PackageIdentification packageId;
public ModuleIdentification(String name, String guid, String version, String path) {
super(name, guid, version, path);
}
public ModuleIdentification(Identification id) {
super(id.getName(), id.getGuid(), id.getVersion(), id.getPath());
}
public ModuleIdentification(String name, String guid, String version, String path, PackageIdentification packageId){
super(name, guid, version, path);
this.packageId = packageId;
}
public ModuleIdentification(Identification id, PackageIdentification packageId) {
super(id.getName(), id.getGuid(), id.getVersion(), id.getPath());
this.packageId = packageId;
}
// public boolean equals(Object obj) {
// if (obj instanceof Identification) {
// Identification id = (Identification)obj;
// if ( this.getName().equalsIgnoreCase(id.getName())) {
// return true;
// }
// // and package is the same one
// return false;
// }
// else {
// return super.equals(obj);
// }
// }
public String toString(){
return "Module " + this.getName() + "[" + this.getGuid() + "] in package " + packageId;
}
public PackageIdentification getPackageId() {
return packageId;
}
public void setPackageId(PackageIdentification packageId) {
this.packageId = packageId;
}
}

View File

@@ -0,0 +1,89 @@
/** @file
The file is used to define Package Dependencies Identification
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.frameworkwizard.module.Identification.PackageDependencies;
import java.util.Vector;
public class PackageDependenciesIdentification {
//
// Define class members
//
private String name = null;
private String version = null;
private String guid = null;
private Vector<String> supArchList = null;
private String featureFlag = null;
public PackageDependenciesIdentification(String arg0, String arg1, String arg2, String arg3, Vector<String> arg4) {
this.name = (arg0 == null ? "" : arg0);
this.version = (arg1 == null ? "" : arg1);
this.guid = (arg2 == null ? "" : arg2);
this.featureFlag = (arg3 == null ? "" : arg3);
this.supArchList = arg4;
}
public String getFeatureFlag() {
return featureFlag;
}
public void setFeatureFlag(String featureFlag) {
this.featureFlag = featureFlag;
}
public String getGuid() {
return guid;
}
public void setGuid(String guid) {
this.guid = guid;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Vector<String> getSupArchList() {
return supArchList;
}
public void setSupArchList(Vector<String> supArchList) {
this.supArchList = supArchList;
}
public String getVersion() {
return version;
}
public void setVersion(String version) {
this.version = version;
}
public boolean equals(PackageDependenciesIdentification pdi) {
if (this.guid.equals(pdi.guid)) {
return true;
}
return false;
}
}

View File

@@ -0,0 +1,90 @@
/** @file
The file is used to define Package Dependencies Vector
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.frameworkwizard.module.Identification.PackageDependencies;
import java.util.Vector;
public class PackageDependenciesVector {
private Vector<PackageDependenciesIdentification> vPackageDependencies = new Vector<PackageDependenciesIdentification>();
public int findPackageDependencies(PackageDependenciesIdentification sfi) {
for (int index = 0; index < vPackageDependencies.size(); index++) {
if (vPackageDependencies.elementAt(index).equals(sfi)) {
return index;
}
}
return -1;
}
public int findPackageDependencies(String name) {
for (int index = 0; index < vPackageDependencies.size(); index++) {
if (vPackageDependencies.elementAt(index).getName().equals(name)) {
return index;
}
}
return -1;
}
public PackageDependenciesIdentification getPackageDependencies(int index) {
if (index > -1) {
return vPackageDependencies.elementAt(index);
} else {
return null;
}
}
public void addPackageDependencies(PackageDependenciesIdentification arg0) {
vPackageDependencies.addElement(arg0);
}
public void updatePackageDependencies(PackageDependenciesIdentification arg0, int arg1) {
vPackageDependencies.setElementAt(arg0, arg1);
}
public void removePackageDependencies(PackageDependenciesIdentification arg0) {
int index = findPackageDependencies(arg0);
if (index > -1) {
vPackageDependencies.removeElementAt(index);
}
}
public void removePackageDependencies(int index) {
if (index > -1 && index < this.size()) {
vPackageDependencies.removeElementAt(index);
}
}
public Vector<PackageDependenciesIdentification> getvPackageDependencies() {
return vPackageDependencies;
}
public void setvPackageDependencies(Vector<PackageDependenciesIdentification> PackageDependencies) {
vPackageDependencies = PackageDependencies;
}
public Vector<String> getPackageDependenciesName() {
Vector<String> v = new Vector<String>();
for (int index = 0; index < this.vPackageDependencies.size(); index++) {
v.addElement(vPackageDependencies.get(index).getName());
}
return v;
}
public int size() {
return this.vPackageDependencies.size();
}
}

View File

@@ -0,0 +1,111 @@
/** @file
The file is used to define Package Dependencies Identification
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.frameworkwizard.module.Identification.PcdCoded;
import java.util.Vector;
public class PcdCodedIdentification {
//
// Define class members
//
private String name = null;
private String guid = null;
private String featureFlag = null;
private Vector<String> supArchList = null;
private String value = null;
private String help = null;
private String type = null;
public PcdCodedIdentification(String arg0, String arg1, String arg2, Vector<String> arg3, String arg4, String arg5, String arg6) {
this.name = (arg0 == null ? "" : arg0);
this.guid = (arg1 == null ? "" : arg1);
this.featureFlag = (arg2 == null ? "" : arg2);
this.supArchList = arg3;
this.value = (arg4 == null ? "" : arg4);
this.help = (arg5 == null ? "" : arg5);
this.type = (arg6 == null ? "" : arg6);
}
public String getFeatureFlag() {
return featureFlag;
}
public void setFeatureFlag(String featureFlag) {
this.featureFlag = featureFlag;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Vector<String> getSupArchList() {
return supArchList;
}
public void setSupArchList(Vector<String> supArchList) {
this.supArchList = supArchList;
}
public boolean equals(PcdCodedIdentification pi) {
if (this.name.equals(pi.name)) {
return true;
}
return false;
}
public String getGuid() {
return guid;
}
public void setGuid(String guid) {
this.guid = guid;
}
public String getHelp() {
return help;
}
public void setHelp(String help) {
this.help = help;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
}

View File

@@ -0,0 +1,90 @@
/** @file
The file is used to define Package Dependencies Vector
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.frameworkwizard.module.Identification.PcdCoded;
import java.util.Vector;
public class PcdCodedVector {
private Vector<PcdCodedIdentification> vPcdCoded = new Vector<PcdCodedIdentification>();
public int findPcdCoded(PcdCodedIdentification sfi) {
for (int index = 0; index < vPcdCoded.size(); index++) {
if (vPcdCoded.elementAt(index).equals(sfi)) {
return index;
}
}
return -1;
}
public int findPcdCoded(String name) {
for (int index = 0; index < vPcdCoded.size(); index++) {
if (vPcdCoded.elementAt(index).getName().equals(name)) {
return index;
}
}
return -1;
}
public PcdCodedIdentification getPcdCoded(int index) {
if (index > -1) {
return vPcdCoded.elementAt(index);
} else {
return null;
}
}
public void addPcdCoded(PcdCodedIdentification arg0) {
vPcdCoded.addElement(arg0);
}
public void updatePcdCoded(PcdCodedIdentification arg0, int arg1) {
vPcdCoded.setElementAt(arg0, arg1);
}
public void removePcdCoded(PcdCodedIdentification arg0) {
int index = findPcdCoded(arg0);
if (index > -1) {
vPcdCoded.removeElementAt(index);
}
}
public void removePcdCoded(int index) {
if (index > -1 && index < this.size()) {
vPcdCoded.removeElementAt(index);
}
}
public Vector<PcdCodedIdentification> getvPcdCoded() {
return vPcdCoded;
}
public void setvPcdCoded(Vector<PcdCodedIdentification> PcdCoded) {
vPcdCoded = PcdCoded;
}
public Vector<String> getPcdCodedName() {
Vector<String> v = new Vector<String>();
for (int index = 0; index < this.vPcdCoded.size(); index++) {
v.addElement(vPcdCoded.get(index).getName());
}
return v;
}
public int size() {
return this.vPcdCoded.size();
}
}

View File

@@ -0,0 +1,100 @@
/** @file
The file is used to define Package Dependencies Identification
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.frameworkwizard.module.Identification.Ppis;
import java.util.Vector;
public class PpisIdentification {
//
// Define class members
//
private String name = null;
private String type = null;
private String usage = null;
private Vector<String> supArchList = null;
private String featureFlag = null;
private String help = null;
public PpisIdentification(String arg0, String arg1, String arg2, String arg3, Vector<String> arg4, String arg5) {
this.name = (arg0 == null ? "" : arg0);
this.type = (arg1 == null ? "" : arg1);
this.usage = (arg2 == null ? "" : arg2);
this.featureFlag = (arg3 == null ? "" : arg3);
this.supArchList = arg4;
this.help = (arg5 == null ? "" : arg5);
}
public String getFeatureFlag() {
return featureFlag;
}
public void setFeatureFlag(String featureFlag) {
this.featureFlag = featureFlag;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Vector<String> getSupArchList() {
return supArchList;
}
public void setSupArchList(Vector<String> supArchList) {
this.supArchList = supArchList;
}
public boolean equals(PpisIdentification pi) {
if (this.name.equals(pi.name)) {
return true;
}
return false;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getUsage() {
return usage;
}
public void setUsage(String usage) {
this.usage = usage;
}
public String getHelp() {
return help;
}
public void setHelp(String help) {
this.help = help;
}
}

View File

@@ -0,0 +1,90 @@
/** @file
The file is used to define Package Dependencies Vector
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.frameworkwizard.module.Identification.Ppis;
import java.util.Vector;
public class PpisVector {
private Vector<PpisIdentification> vPpis = new Vector<PpisIdentification>();
public int findPpis(PpisIdentification sfi) {
for (int index = 0; index < vPpis.size(); index++) {
if (vPpis.elementAt(index).equals(sfi)) {
return index;
}
}
return -1;
}
public int findPpis(String name) {
for (int index = 0; index < vPpis.size(); index++) {
if (vPpis.elementAt(index).getName().equals(name)) {
return index;
}
}
return -1;
}
public PpisIdentification getPpis(int index) {
if (index > -1) {
return vPpis.elementAt(index);
} else {
return null;
}
}
public void addPpis(PpisIdentification arg0) {
vPpis.addElement(arg0);
}
public void updatePpis(PpisIdentification arg0, int arg1) {
vPpis.setElementAt(arg0, arg1);
}
public void removePpis(PpisIdentification arg0) {
int index = findPpis(arg0);
if (index > -1) {
vPpis.removeElementAt(index);
}
}
public void removePpis(int index) {
if (index > -1 && index < this.size()) {
vPpis.removeElementAt(index);
}
}
public Vector<PpisIdentification> getvPpis() {
return vPpis;
}
public void setvPpis(Vector<PpisIdentification> Ppis) {
vPpis = Ppis;
}
public Vector<String> getPpisName() {
Vector<String> v = new Vector<String>();
for (int index = 0; index < this.vPpis.size(); index++) {
v.addElement(vPpis.get(index).getName());
}
return v;
}
public int size() {
return this.vPpis.size();
}
}

View File

@@ -0,0 +1,100 @@
/** @file
The file is used to define Package Dependencies Identification
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.frameworkwizard.module.Identification.Protocols;
import java.util.Vector;
public class ProtocolsIdentification {
//
// Define class members
//
private String name = null;
private String type = null;
private String usage = null;
private Vector<String> supArchList = null;
private String featureFlag = null;
private String help = null;
public ProtocolsIdentification(String arg0, String arg1, String arg2, String arg3, Vector<String> arg4, String arg5) {
this.name = (arg0 == null ? "" : arg0);
this.type = (arg1 == null ? "" : arg1);
this.usage = (arg2 == null ? "" : arg2);
this.featureFlag = (arg3 == null ? "" : arg3);
this.supArchList = arg4;
this.help = (arg5 == null ? "" : arg5);
}
public String getFeatureFlag() {
return featureFlag;
}
public void setFeatureFlag(String featureFlag) {
this.featureFlag = featureFlag;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Vector<String> getSupArchList() {
return supArchList;
}
public void setSupArchList(Vector<String> supArchList) {
this.supArchList = supArchList;
}
public boolean equals(ProtocolsIdentification pi) {
if (this.name.equals(pi.name)) {
return true;
}
return false;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getUsage() {
return usage;
}
public void setUsage(String usage) {
this.usage = usage;
}
public String getHelp() {
return help;
}
public void setHelp(String help) {
this.help = help;
}
}

View File

@@ -0,0 +1,90 @@
/** @file
The file is used to define Package Dependencies Vector
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.frameworkwizard.module.Identification.Protocols;
import java.util.Vector;
public class ProtocolsVector {
private Vector<ProtocolsIdentification> vProtocols = new Vector<ProtocolsIdentification>();
public int findProtocols(ProtocolsIdentification sfi) {
for (int index = 0; index < vProtocols.size(); index++) {
if (vProtocols.elementAt(index).equals(sfi)) {
return index;
}
}
return -1;
}
public int findProtocols(String name) {
for (int index = 0; index < vProtocols.size(); index++) {
if (vProtocols.elementAt(index).getName().equals(name)) {
return index;
}
}
return -1;
}
public ProtocolsIdentification getProtocols(int index) {
if (index > -1) {
return vProtocols.elementAt(index);
} else {
return null;
}
}
public void addProtocols(ProtocolsIdentification arg0) {
vProtocols.addElement(arg0);
}
public void updateProtocols(ProtocolsIdentification arg0, int arg1) {
vProtocols.setElementAt(arg0, arg1);
}
public void removeProtocols(ProtocolsIdentification arg0) {
int index = findProtocols(arg0);
if (index > -1) {
vProtocols.removeElementAt(index);
}
}
public void removeProtocols(int index) {
if (index > -1 && index < this.size()) {
vProtocols.removeElementAt(index);
}
}
public Vector<ProtocolsIdentification> getvProtocols() {
return vProtocols;
}
public void setvProtocols(Vector<ProtocolsIdentification> Protocols) {
vProtocols = Protocols;
}
public Vector<String> getProtocolsName() {
Vector<String> v = new Vector<String>();
for (int index = 0; index < this.vProtocols.size(); index++) {
v.addElement(vProtocols.get(index).getName());
}
return v;
}
public int size() {
return this.vProtocols.size();
}
}

View File

@@ -0,0 +1,97 @@
/** @file
The file is used to define Source Files Identification
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.frameworkwizard.module.Identification.SourceFiles;
import java.util.Vector;
public class SourceFilesIdentification {
private String filename = null;
private String tagName = null;
private String toolCode = null;
private String toolChainFamily = null;
private Vector<String> supArchList = null;
private String featureFlag = null;
public SourceFilesIdentification(String strFilename, String strTagName, String strToolCode, String strToolChainFamily,
String strFeatureFlag, Vector<String> arch) {
this.filename = (strFilename == null ? "" : strFilename);
this.tagName = (strTagName == null ? "" : strTagName);
this.toolCode = (strToolCode == null ? "" : strToolCode);
this.toolChainFamily = (strToolChainFamily == null ? "" : strToolChainFamily);
this.featureFlag = (strFeatureFlag == null ? "" : strFeatureFlag);
this.supArchList = arch;
}
public String getFeatureFlag() {
return featureFlag;
}
public void setFeatureFlag(String featureFlag) {
this.featureFlag = featureFlag;
}
public String getFilename() {
return filename;
}
public void setFilename(String filename) {
this.filename = filename;
}
public Vector<String> getSupArchList() {
return supArchList;
}
public void setSupArchList(Vector<String> supArchList) {
this.supArchList = supArchList;
}
public String getTagName() {
return tagName;
}
public void setTagName(String tagName) {
this.tagName = tagName;
}
public String getToolChainFamily() {
return toolChainFamily;
}
public void setToolChainFamily(String toolChainFamily) {
this.toolChainFamily = toolChainFamily;
}
public String getToolCode() {
return toolCode;
}
public void setToolCode(String toolCode) {
this.toolCode = toolCode;
}
public boolean equals(SourceFilesIdentification sfid) {
if (this.filename.equals(sfid.filename)) {
return true;
}
return false;
}
}

View File

@@ -0,0 +1,89 @@
/** @file
The file is used to define Source Files Vector
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.frameworkwizard.module.Identification.SourceFiles;
import java.util.Vector;
public class SourceFilesVector {
private Vector<SourceFilesIdentification> vSourceFiles = new Vector<SourceFilesIdentification>();
public int findSourceFiles(SourceFilesIdentification sfi) {
for (int index = 0; index < vSourceFiles.size(); index++) {
if (vSourceFiles.elementAt(index).equals(sfi)) {
return index;
}
}
return -1;
}
public int findSourceFiles(String name) {
for (int index = 0; index < vSourceFiles.size(); index++) {
if (vSourceFiles.elementAt(index).getFilename().equals(name)) {
return index;
}
}
return -1;
}
public SourceFilesIdentification getSourceFiles(int index) {
if (index > -1) {
return vSourceFiles.elementAt(index);
} else {
return null;
}
}
public void addSourceFiles(SourceFilesIdentification sfi) {
vSourceFiles.addElement(sfi);
}
public void updateSourceFiles(SourceFilesIdentification sfi, int index) {
vSourceFiles.setElementAt(sfi, index);
}
public void removeSourceFiles(SourceFilesIdentification sfi) {
int index = findSourceFiles(sfi);
if (index > -1) {
vSourceFiles.removeElementAt(index);
}
}
public void removeSourceFiles(int index) {
if (index > -1 && index < this.size()) {
vSourceFiles.removeElementAt(index);
}
}
public Vector<SourceFilesIdentification> getvSourceFiles() {
return vSourceFiles;
}
public void setvSourceFiles(Vector<SourceFilesIdentification> SourceFiles) {
vSourceFiles = SourceFiles;
}
public Vector<String> getSourceFilesName() {
Vector<String> v = new Vector<String>();
for (int index = 0; index < this.vSourceFiles.size(); index++) {
v.addElement(vSourceFiles.get(index).getFilename());
}
return v;
}
public int size() {
return this.vSourceFiles.size();
}
}

View File

@@ -0,0 +1,89 @@
/** @file
The file is used to define Package Dependencies Identification
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.frameworkwizard.module.Identification.SystemTables;
import java.util.Vector;
public class SystemTablesIdentification {
//
// Define class members
//
private String name = null;
private String usage = null;
private Vector<String> supArchList = null;
private String featureFlag = null;
private String help = null;
public SystemTablesIdentification(String arg0, String arg1, String arg2, Vector<String> arg3, String arg4) {
this.name = (arg0 == null ? "" : arg0);
this.usage = (arg1 == null ? "" : arg1);
this.featureFlag = (arg2 == null ? "" : arg2);
this.supArchList = arg3;
this.help = (arg4 == null ? "" : arg4);
}
public String getFeatureFlag() {
return featureFlag;
}
public void setFeatureFlag(String featureFlag) {
this.featureFlag = featureFlag;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Vector<String> getSupArchList() {
return supArchList;
}
public void setSupArchList(Vector<String> supArchList) {
this.supArchList = supArchList;
}
public boolean equals(SystemTablesIdentification pi) {
if (this.name.equals(pi.name)) {
return true;
}
return false;
}
public String getUsage() {
return usage;
}
public void setUsage(String usage) {
this.usage = usage;
}
public String getHelp() {
return help;
}
public void setHelp(String help) {
this.help = help;
}
}

View File

@@ -0,0 +1,90 @@
/** @file
The file is used to define Package Dependencies Vector
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.frameworkwizard.module.Identification.SystemTables;
import java.util.Vector;
public class SystemTablesVector {
private Vector<SystemTablesIdentification> vSystemTables = new Vector<SystemTablesIdentification>();
public int findSystemTables(SystemTablesIdentification sfi) {
for (int index = 0; index < vSystemTables.size(); index++) {
if (vSystemTables.elementAt(index).equals(sfi)) {
return index;
}
}
return -1;
}
public int findSystemTables(String name) {
for (int index = 0; index < vSystemTables.size(); index++) {
if (vSystemTables.elementAt(index).getName().equals(name)) {
return index;
}
}
return -1;
}
public SystemTablesIdentification getSystemTables(int index) {
if (index > -1) {
return vSystemTables.elementAt(index);
} else {
return null;
}
}
public void addSystemTables(SystemTablesIdentification arg0) {
vSystemTables.addElement(arg0);
}
public void updateSystemTables(SystemTablesIdentification arg0, int arg1) {
vSystemTables.setElementAt(arg0, arg1);
}
public void removeSystemTables(SystemTablesIdentification arg0) {
int index = findSystemTables(arg0);
if (index > -1) {
vSystemTables.removeElementAt(index);
}
}
public void removeSystemTables(int index) {
if (index > -1 && index < this.size()) {
vSystemTables.removeElementAt(index);
}
}
public Vector<SystemTablesIdentification> getvSystemTables() {
return vSystemTables;
}
public void setvSystemTables(Vector<SystemTablesIdentification> SystemTables) {
vSystemTables = SystemTables;
}
public Vector<String> getSystemTablesName() {
Vector<String> v = new Vector<String>();
for (int index = 0; index < this.vSystemTables.size(); index++) {
v.addElement(vSystemTables.get(index).getName());
}
return v;
}
public int size() {
return this.vSystemTables.size();
}
}

View File

@@ -0,0 +1,100 @@
/** @file
The file is used to define Package Dependencies Identification
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.frameworkwizard.module.Identification.Variables;
import java.util.Vector;
public class VariablesIdentification {
//
// Define class members
//
private String name = null;
private String guid = null;
private String usage = null;
private Vector<String> supArchList = null;
private String featureFlag = null;
private String help = null;
public VariablesIdentification(String arg0, String arg1, String arg2, String arg3, Vector<String> arg4, String arg5) {
this.name = (arg0 == null ? "" : arg0);
this.guid = (arg1 == null ? "" : arg1);
this.usage = (arg2 == null ? "" : arg2);
this.featureFlag = (arg3 == null ? "" : arg3);
this.supArchList = arg4;
this.help = (arg5 == null ? "" : arg5);
}
public String getFeatureFlag() {
return featureFlag;
}
public void setFeatureFlag(String featureFlag) {
this.featureFlag = featureFlag;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Vector<String> getSupArchList() {
return supArchList;
}
public void setSupArchList(Vector<String> supArchList) {
this.supArchList = supArchList;
}
public boolean equals(VariablesIdentification pi) {
if (this.name.equals(pi.name)) {
return true;
}
return false;
}
public String getUsage() {
return usage;
}
public void setUsage(String usage) {
this.usage = usage;
}
public String getGuid() {
return guid;
}
public void setGuid(String guid) {
this.guid = guid;
}
public String getHelp() {
return help;
}
public void setHelp(String help) {
this.help = help;
}
}

View File

@@ -0,0 +1,90 @@
/** @file
The file is used to define Package Dependencies Vector
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.frameworkwizard.module.Identification.Variables;
import java.util.Vector;
public class VariablesVector {
private Vector<VariablesIdentification> vVariables = new Vector<VariablesIdentification>();
public int findVariables(VariablesIdentification sfi) {
for (int index = 0; index < vVariables.size(); index++) {
if (vVariables.elementAt(index).equals(sfi)) {
return index;
}
}
return -1;
}
public int findVariables(String name) {
for (int index = 0; index < vVariables.size(); index++) {
if (vVariables.elementAt(index).getName().equals(name)) {
return index;
}
}
return -1;
}
public VariablesIdentification getVariables(int index) {
if (index > -1) {
return vVariables.elementAt(index);
} else {
return null;
}
}
public void addVariables(VariablesIdentification arg0) {
vVariables.addElement(arg0);
}
public void updateVariables(VariablesIdentification arg0, int arg1) {
vVariables.setElementAt(arg0, arg1);
}
public void removeVariables(VariablesIdentification arg0) {
int index = findVariables(arg0);
if (index > -1) {
vVariables.removeElementAt(index);
}
}
public void removeVariables(int index) {
if (index > -1 && index < this.size()) {
vVariables.removeElementAt(index);
}
}
public Vector<VariablesIdentification> getvVariables() {
return vVariables;
}
public void setvVariables(Vector<VariablesIdentification> Variables) {
vVariables = Variables;
}
public Vector<String> getVariablesName() {
Vector<String> v = new Vector<String>();
for (int index = 0; index < this.vVariables.size(); index++) {
v.addElement(vVariables.get(index).getName());
}
return v;
}
public int size() {
return this.vVariables.size();
}
}

View File

@@ -0,0 +1,759 @@
/** @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.frameworkwizard.module.ui;
import java.awt.event.ActionEvent;
import java.awt.event.ComponentEvent;
import java.awt.event.ItemEvent;
import java.util.Vector;
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.BootModeNames;
import org.tianocore.BootModeUsage;
import org.tianocore.BootModesDocument;
import org.tianocore.BootModesDocument.BootModes;
import org.tianocore.BootModesDocument.BootModes.BootMode;
import org.tianocore.ModuleSurfaceAreaDocument.ModuleSurfaceArea;
import org.tianocore.frameworkwizard.common.DataType;
import org.tianocore.frameworkwizard.common.DataValidation;
import org.tianocore.frameworkwizard.common.EnumerationData;
import org.tianocore.frameworkwizard.common.Log;
import org.tianocore.frameworkwizard.common.OpeningModuleType;
import org.tianocore.frameworkwizard.common.Tools;
import org.tianocore.frameworkwizard.common.ui.IInternalFrame;
import org.tianocore.frameworkwizard.common.ui.StarLabel;
import org.tianocore.frameworkwizard.common.ui.iCheckBoxList.ICheckBoxList;
import org.tianocore.frameworkwizard.module.Identification.BootModes.BootModesIdentification;
import org.tianocore.frameworkwizard.module.Identification.BootModes.BootModesVector;
/**
The class is used to create, update BootModes of MSA/MBD file
It extends IInternalFrame
**/
public class ModuleBootModes extends IInternalFrame {
///
/// Define class Serial Version UID
///
private static final long serialVersionUID = -3888558623432442561L;
//
//Define class members
//
private JPanel jContentPane = null;
private JLabel jLabelBootModeName = null;
private JComboBox jComboBoxBootModeName = null;
private JLabel jLabelUsage = null;
private JComboBox jComboBoxUsage = null;
private StarLabel jStarLabel1 = null;
private StarLabel jStarLabel2 = null;
private JLabel jLabelFeatureFlag = null;
private JTextField jTextFieldFeatureFlag = null;
private JLabel jLabelArch = null;
private JTextArea jTextAreaList = null;
private JComboBox jComboBoxList = null;
private JButton jButtonAdd = null;
private JButton jButtonRemove = null;
private JButton jButtonUpdate = null;
private JScrollPane jScrollPane = null;
private JScrollPane jScrollPaneList = null;
private ICheckBoxList iCheckBoxListArch = null;
private JScrollPane jScrollPaneArch = null;
private JLabel jLabelHelpText = null;
private JTextField jTextFieldHelpText = null;
//
// Not used by UI
//
private int intSelectedItemId = 0;
private OpeningModuleType omt = null;
private ModuleSurfaceArea msa = null;
private BootModesDocument.BootModes bootModes = null;
private BootModesIdentification id = null;
private BootModesVector vid = new BootModesVector();
private EnumerationData ed = new EnumerationData();
/**
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));
jComboBoxBootModeName.setPreferredSize(new java.awt.Dimension(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, 35, 320, 20));
jComboBoxUsage.setPreferredSize(new java.awt.Dimension(320, 20));
}
return jComboBoxUsage;
}
/**
* This method initializes jTextFieldFeatureFlag
*
* @return javax.swing.JTextField
*/
private JTextField getJTextFieldFeatureFlag() {
if (jTextFieldFeatureFlag == null) {
jTextFieldFeatureFlag = new JTextField();
jTextFieldFeatureFlag.setBounds(new java.awt.Rectangle(160, 85, 320, 20));
jTextFieldFeatureFlag.setPreferredSize(new java.awt.Dimension(320, 20));
}
return jTextFieldFeatureFlag;
}
/**
This method initializes jComboBoxFileList
@return javax.swing.JComboBox jComboBoxFileList
**/
private JComboBox getJComboBoxList() {
if (jComboBoxList == null) {
jComboBoxList = new JComboBox();
jComboBoxList.setBounds(new java.awt.Rectangle(15, 195, 210, 20));
jComboBoxList.addItemListener(this);
jComboBoxList.addActionListener(this);
jComboBoxList.setPreferredSize(new java.awt.Dimension(210, 20));
}
return jComboBoxList;
}
/**
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, 195, 80, 20));
jButtonAdd.setText("Add");
jButtonAdd.addActionListener(this);
jButtonAdd.setPreferredSize(new java.awt.Dimension(80, 20));
}
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, 195, 80, 20));
jButtonRemove.setText("Remove");
jButtonRemove.addActionListener(this);
jButtonRemove.setPreferredSize(new java.awt.Dimension(80, 20));
}
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, 195, 80, 20));
jButtonUpdate.setPreferredSize(new java.awt.Dimension(80, 20));
jButtonUpdate.setText("Update");
jButtonUpdate.addActionListener(this);
}
return jButtonUpdate;
}
/**
* This method initializes jScrollPaneFileList
*
* @return javax.swing.JScrollPane
*/
private JScrollPane getJScrollPaneList() {
if (jScrollPaneList == null) {
jScrollPaneList = new JScrollPane();
jScrollPaneList.setBounds(new java.awt.Rectangle(15, 220, 465, 240));
jScrollPaneList.setViewportView(getJTextAreaList());
jScrollPaneList.setPreferredSize(new java.awt.Dimension(465, 240));
}
return jScrollPaneList;
}
/**
This method initializes jScrollPane
@return javax.swing.JScrollPane
*/
private JScrollPane getJScrollPane() {
if (jScrollPane == null) {
jScrollPane = new JScrollPane();
jScrollPane.setViewportView(getJContentPane());
}
return jScrollPane;
}
/**
* This method initializes jTextAreaFileList
*
* @return javax.swing.JTextArea
*/
private JTextArea getJTextAreaList() {
if (jTextAreaList == null) {
jTextAreaList = new JTextArea();
jTextAreaList.setEditable(false);
}
return jTextAreaList;
}
/**
This method initializes iCheckBoxListArch
@return ICheckBoxList
**/
private ICheckBoxList getICheckBoxListSupportedArchitectures() {
if (iCheckBoxListArch == null) {
iCheckBoxListArch = new ICheckBoxList();
iCheckBoxListArch.addFocusListener(this);
iCheckBoxListArch.setToolTipText(DataType.SUP_ARCH_LIST_HELP_TEXT);
}
return iCheckBoxListArch;
}
/**
This method initializes jScrollPaneArch
@return javax.swing.JScrollPane
**/
private JScrollPane getJScrollPaneArch() {
if (jScrollPaneArch == null) {
jScrollPaneArch = new JScrollPane();
jScrollPaneArch.setBounds(new java.awt.Rectangle(160, 110, 320, 80));
jScrollPaneArch.setPreferredSize(new java.awt.Dimension(320, 80));
jScrollPaneArch.setViewportView(getICheckBoxListSupportedArchitectures());
}
return jScrollPaneArch;
}
/**
This method initializes jTextFieldHelpText
@return javax.swing.JTextField
**/
private JTextField getJTextFieldHelpText() {
if (jTextFieldHelpText == null) {
jTextFieldHelpText = new JTextField();
jTextFieldHelpText.setBounds(new java.awt.Rectangle(160, 60, 320, 20));
jTextFieldHelpText.setPreferredSize(new java.awt.Dimension(320, 20));
}
return jTextFieldHelpText;
}
public static void main(String[] args) {
}
/**
This method initializes this
**/
private void init() {
this.setSize(500, 515);
this.setContentPane(getJScrollPane());
this.setTitle("Boot Modes");
initFrame();
this.setViewMode(false);
}
/**
This method initializes this
Fill values to all fields if these values are not empty
@param inPackageDependencies
**/
private void init(BootModes inBootModes) {
init();
this.bootModes = inBootModes;
if (this.bootModes != null) {
if (this.bootModes.getBootModeList().size() > 0) {
for (int index = 0; index < this.bootModes.getBootModeList().size(); index++) {
String arg0 = null;
if (bootModes.getBootModeList().get(index).getBootModeName() != null) {
arg0 = bootModes.getBootModeList().get(index).getBootModeName().toString();
}
String arg1 = null;
if (bootModes.getBootModeList().get(index).getUsage() != null) {
arg1 = bootModes.getBootModeList().get(index).getUsage().toString();
}
String arg2 = bootModes.getBootModeList().get(index).getFeatureFlag();
Vector<String> arg3 = Tools.convertListToVector(bootModes.getBootModeList().get(index).getSupArchList());
String arg4 = bootModes.getBootModeList().get(index).getHelpText();
id = new BootModesIdentification(arg0, arg1, arg2, arg3, arg4);
vid.addBootModes(id);
}
}
}
//
// Update the list
//
Tools.generateComboBoxByVector(jComboBoxList, vid.getBootModesName());
reloadListArea();
}
/**
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(OpeningModuleType inOmt) {
super();
this.omt = inOmt;
this.msa = omt.getXmlMsa();
init(msa.getBootModes());
this.setVisible(true);
}
/**
Disable all components when the mode is view
@param isView true - The view mode; false - The non-view mode
**/
public void setViewMode(boolean isView) {
if (isView) {
this.jComboBoxBootModeName.setEnabled(!isView);
this.jComboBoxUsage.setEnabled(!isView);
}
}
/**
This method initializes jContentPane
@return javax.swing.JPanel jContentPane
**/
private JPanel getJContentPane() {
if (jContentPane == null) {
jLabelArch = new JLabel();
jLabelArch.setBounds(new java.awt.Rectangle(15, 110, 140, 20));
jLabelArch.setText("Arch");
jLabelFeatureFlag = new JLabel();
jLabelFeatureFlag.setBounds(new java.awt.Rectangle(15, 85, 140, 20));
jLabelFeatureFlag.setText("Feature Flag");
jLabelUsage = new JLabel();
jLabelUsage.setText("Usage");
jLabelUsage.setBounds(new java.awt.Rectangle(15, 35, 140, 20));
jLabelBootModeName = new JLabel();
jLabelBootModeName.setText("Boot Mode Name");
jLabelBootModeName.setBounds(new java.awt.Rectangle(15, 10, 140, 20));
jLabelHelpText = new JLabel();
jLabelHelpText.setBounds(new java.awt.Rectangle(14, 60, 140, 20));
jLabelHelpText.setText("Help Text");
jContentPane = new JPanel();
jContentPane.setLayout(null);
jContentPane.setPreferredSize(new java.awt.Dimension(490, 475));
jContentPane.add(jLabelBootModeName, null);
jContentPane.add(getJComboBoxBootModeName(), null);
jContentPane.add(jLabelUsage, null);
jContentPane.add(getJComboBoxUsage(), 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(jLabelFeatureFlag, null);
jContentPane.add(getJTextFieldFeatureFlag(), null);
jContentPane.add(jLabelArch, null);
jContentPane.add(getJComboBoxList(), null);
jContentPane.add(getJButtonAdd(), null);
jContentPane.add(getJButtonRemove(), null);
jContentPane.add(getJButtonUpdate(), null);
jContentPane.add(getJScrollPaneList(), null);
jContentPane.add(getJScrollPaneArch(), null);
jContentPane.add(jLabelHelpText, null);
jContentPane.add(getJTextFieldHelpText(), null);
}
return jContentPane;
}
/**
This method initializes BootModeName groups and Usage type
**/
private void initFrame() {
Tools.generateComboBoxByVector(jComboBoxBootModeName, ed.getVBootModeNames());
Tools.generateComboBoxByVector(jComboBoxUsage, ed.getVPpiUsage());
this.iCheckBoxListArch.setAllItems(ed.getVSupportedArchitectures());
}
/* (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() == jButtonAdd) {
if (!checkAdd()) {
return;
}
addToList();
}
if (arg0.getSource() == jButtonRemove) {
removeFromList();
}
if (arg0.getSource() == jButtonUpdate) {
if (!checkAdd()) {
return;
}
updateForList();
}
}
/**
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 fields have correct data types
//
//
// Check FeatureFlag
//
if (!isEmpty(this.jTextFieldFeatureFlag.getText())) {
if (!DataValidation.isFeatureFlag(this.jTextFieldFeatureFlag.getText())) {
Log.err("Incorrect data type for Feature Flag");
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 {
int count = this.vid.size();
this.bootModes = BootModes.Factory.newInstance();
if (count > 0) {
for (int index = 0; index < count; index++) {
BootMode p = BootMode.Factory.newInstance();
if (!isEmpty(vid.getBootModes(index).getName())) {
p.setBootModeName(BootModeNames.Enum.forString(vid.getBootModes(index).getName()));
}
if (!isEmpty(vid.getBootModes(index).getUsage())) {
p.setUsage(BootModeUsage.Enum.forString(vid.getBootModes(index).getUsage()));
}
if (!isEmpty(vid.getBootModes(index).getFeatureFlag())) {
p.setFeatureFlag(vid.getBootModes(index).getFeatureFlag());
}
if (vid.getBootModes(index).getSupArchList() != null && vid.getBootModes(index).getSupArchList().size() > 0) {
p.setSupArchList(vid.getBootModes(index).getSupArchList());
}
if (!isEmpty(vid.getBootModes(index).getHelp())) {
p.setHelpText(vid.getBootModes(index).getHelp());
}
this.bootModes.addNewBootMode();
this.bootModes.setBootModeArray(bootModes.getBootModeList().size() - 1, p);
}
}
this.msa.setBootModes(bootModes);
this.omt.setSaved(false);
} catch (Exception e) {
Log.err("Update Boot Modes", e.getMessage());
}
}
/* (non-Javadoc)
* @see java.awt.event.ComponentListener#componentResized(java.awt.event.ComponentEvent)
*
* Override componentResized to resize all components when frame's size is changed
*/
public void componentResized(ComponentEvent arg0) {
int intCurrentWidth = this.getJContentPane().getWidth();
int intCurrentHeight = this.getJContentPane().getHeight();
int intPreferredWidth = this.getJContentPane().getPreferredSize().width;
int intPreferredHeight = this.getJContentPane().getPreferredSize().height;
resizeComponentWidth(jComboBoxBootModeName, intCurrentWidth, intPreferredWidth);
resizeComponentWidth(jComboBoxUsage, intCurrentWidth, intPreferredWidth);
resizeComponentWidth(jTextFieldHelpText, intCurrentWidth, intPreferredWidth);
resizeComponentWidth(jTextFieldFeatureFlag, intCurrentWidth, intPreferredWidth);
resizeComponentWidth(jScrollPaneArch, intCurrentWidth, intPreferredWidth);
resizeComponentWidth(jComboBoxList, intCurrentWidth, intPreferredWidth);
resizeComponent(jScrollPaneList, intCurrentWidth, intCurrentHeight, intPreferredWidth, intPreferredHeight);
relocateComponentX(jButtonAdd, intCurrentWidth, intPreferredWidth, DataType.SPACE_TO_RIGHT_FOR_ADD_BUTTON);
relocateComponentX(jButtonRemove, intCurrentWidth, intPreferredWidth, DataType.SPACE_TO_RIGHT_FOR_REMOVE_BUTTON);
relocateComponentX(jButtonUpdate, intCurrentWidth, intPreferredWidth, DataType.SPACE_TO_RIGHT_FOR_UPDATE_BUTTON);
}
private BootModesIdentification getCurrentBootModes() {
String arg0 = this.jComboBoxBootModeName.getSelectedItem().toString();
String arg1 = this.jComboBoxUsage.getSelectedItem().toString();
String arg2 = this.jTextFieldFeatureFlag.getText();
Vector<String> arg3 = this.iCheckBoxListArch.getAllCheckedItemsString();
String arg4 = this.jTextFieldHelpText.getText();
id = new BootModesIdentification(arg0, arg1, arg2, arg3, arg4);
return id;
}
/**
Add current item to Vector
**/
private void addToList() {
intSelectedItemId = vid.size();
vid.addBootModes(getCurrentBootModes());
jComboBoxList.addItem(id.getName());
jComboBoxList.setSelectedItem(id.getName());
//
// Reset select item index
//
intSelectedItemId = vid.size();
//
// Reload all fields of selected item
//
reloadFromList();
//
// Save to memory
//
save();
}
/**
Remove current item from Vector
**/
private void removeFromList() {
//
// Check if exist items
//
if (this.vid.size() < 1) {
return;
}
int intTempIndex = intSelectedItemId;
jComboBoxList.removeItemAt(intSelectedItemId);
vid.removeBootModes(intTempIndex);
//
// Reload all fields of selected item
//
reloadFromList();
//
// Save to memory
//
save();
}
/**
Update current item of Vector
**/
private void updateForList() {
//
// Check if exist items
//
if (this.vid.size() < 1) {
return;
}
//
// Backup selected item index
//
int intTempIndex = intSelectedItemId;
vid.updateBootModes(getCurrentBootModes(), intTempIndex);
jComboBoxList.removeAllItems();
for (int index = 0; index < vid.size(); index++) {
jComboBoxList.addItem(vid.getBootModes(index).getName());
}
//
// Restore selected item index
//
intSelectedItemId = intTempIndex;
//
// Reset select item index
//
jComboBoxList.setSelectedIndex(intSelectedItemId);
//
// Reload all fields of selected item
//
reloadFromList();
//
// Save to memory
//
save();
}
/**
Refresh all fields' values of selected item of Vector
**/
private void reloadFromList() {
if (vid.size() > 0) {
//
// Get selected item index
//
intSelectedItemId = jComboBoxList.getSelectedIndex();
this.jComboBoxBootModeName.setSelectedItem(vid.getBootModes(intSelectedItemId).getName());
this.jComboBoxUsage.setSelectedItem(vid.getBootModes(intSelectedItemId).getUsage());
this.jTextFieldHelpText.setText(vid.getBootModes(intSelectedItemId).getHelp());
jTextFieldFeatureFlag.setText(vid.getBootModes(intSelectedItemId).getFeatureFlag());
iCheckBoxListArch.setAllItemsUnchecked();
iCheckBoxListArch.initCheckedItem(true, vid.getBootModes(intSelectedItemId).getSupArchList());
} else {
}
reloadListArea();
}
/**
Update list area pane via the elements of Vector
**/
private void reloadListArea() {
String strListItem = "";
for (int index = 0; index < vid.size(); index++) {
strListItem = strListItem + vid.getBootModes(index).getName() + DataType.UNIX_LINE_SEPARATOR;
}
this.jTextAreaList.setText(strListItem);
}
/* (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.getSource() == this.jComboBoxList && arg0.getStateChange() == ItemEvent.SELECTED) {
reloadFromList();
}
}
}

View File

@@ -0,0 +1,772 @@
/** @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.frameworkwizard.module.ui;
import java.awt.event.ActionEvent;
import java.awt.event.ComponentEvent;
import java.awt.event.ItemEvent;
import java.util.Vector;
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.DataHubUsage;
import org.tianocore.DataHubsDocument;
import org.tianocore.DataHubsDocument.DataHubs;
import org.tianocore.DataHubsDocument.DataHubs.DataHubRecord;
import org.tianocore.ModuleSurfaceAreaDocument.ModuleSurfaceArea;
import org.tianocore.frameworkwizard.common.DataType;
import org.tianocore.frameworkwizard.common.DataValidation;
import org.tianocore.frameworkwizard.common.EnumerationData;
import org.tianocore.frameworkwizard.common.Log;
import org.tianocore.frameworkwizard.common.OpeningModuleType;
import org.tianocore.frameworkwizard.common.Tools;
import org.tianocore.frameworkwizard.common.ui.IInternalFrame;
import org.tianocore.frameworkwizard.common.ui.StarLabel;
import org.tianocore.frameworkwizard.common.ui.iCheckBoxList.ICheckBoxList;
import org.tianocore.frameworkwizard.module.Identification.DataHubs.DataHubsIdentification;
import org.tianocore.frameworkwizard.module.Identification.DataHubs.DataHubsVector;
/**
The class is used to create, update DataHub of MSA/MBD file
It extends IInternalFrame
**/
public class ModuleDataHubs extends IInternalFrame {
///
/// Define class Serial Version UID
///
private static final long serialVersionUID = -3667906991966638892L;
//
//Define class members
//
private JPanel jContentPane = null;
private JLabel jLabelUsage = null;
private JComboBox jComboBoxUsage = null;
private JLabel jLabelDataHubRecord = null;
private JTextField jTextFieldDataHubRecord = null;
private StarLabel jStarLabel1 = null;
private StarLabel jStarLabel2 = null;
private JLabel jLabelFeatureFlag = null;
private JTextField jTextFieldFeatureFlag = null;
private JLabel jLabelArch = null;
private JTextArea jTextAreaList = null;
private JComboBox jComboBoxList = null;
private JButton jButtonAdd = null;
private JButton jButtonRemove = null;
private JButton jButtonUpdate = null;
private JScrollPane jScrollPane = null;
private JScrollPane jScrollPaneList = null;
private ICheckBoxList iCheckBoxListArch = null;
private JScrollPane jScrollPaneArch = null;
private JLabel jLabelHelpText = null;
private JTextField jTextFieldHelpText = null;
//
// Not used by UI
//
private int intSelectedItemId = 0;
private OpeningModuleType omt = null;
private ModuleSurfaceArea msa = null;
private DataHubsDocument.DataHubs dataHubs = null;
private DataHubsIdentification id = null;
private DataHubsVector vid = new DataHubsVector();
private EnumerationData ed = new EnumerationData();
/**
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));
jComboBoxUsage.setPreferredSize(new java.awt.Dimension(320, 20));
}
return jComboBoxUsage;
}
/**
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));
jTextFieldDataHubRecord.setPreferredSize(new java.awt.Dimension(320, 20));
}
return jTextFieldDataHubRecord;
}
/**
* This method initializes jTextFieldFeatureFlag
*
* @return javax.swing.JTextField
*/
private JTextField getJTextFieldFeatureFlag() {
if (jTextFieldFeatureFlag == null) {
jTextFieldFeatureFlag = new JTextField();
jTextFieldFeatureFlag.setBounds(new java.awt.Rectangle(160, 85, 320, 20));
jTextFieldFeatureFlag.setPreferredSize(new java.awt.Dimension(320, 20));
}
return jTextFieldFeatureFlag;
}
/**
This method initializes jComboBoxFileList
@return javax.swing.JComboBox jComboBoxFileList
**/
private JComboBox getJComboBoxList() {
if (jComboBoxList == null) {
jComboBoxList = new JComboBox();
jComboBoxList.setBounds(new java.awt.Rectangle(15, 195, 210, 20));
jComboBoxList.addItemListener(this);
jComboBoxList.addActionListener(this);
jComboBoxList.setPreferredSize(new java.awt.Dimension(210, 20));
}
return jComboBoxList;
}
/**
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, 195, 80, 20));
jButtonAdd.setText("Add");
jButtonAdd.addActionListener(this);
jButtonAdd.setPreferredSize(new java.awt.Dimension(80, 20));
}
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, 195, 80, 20));
jButtonRemove.setText("Remove");
jButtonRemove.addActionListener(this);
jButtonRemove.setPreferredSize(new java.awt.Dimension(80, 20));
}
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, 195, 80, 20));
jButtonUpdate.setPreferredSize(new java.awt.Dimension(80, 20));
jButtonUpdate.setText("Update");
jButtonUpdate.addActionListener(this);
}
return jButtonUpdate;
}
/**
* This method initializes jScrollPaneFileList
*
* @return javax.swing.JScrollPane
*/
private JScrollPane getJScrollPaneList() {
if (jScrollPaneList == null) {
jScrollPaneList = new JScrollPane();
jScrollPaneList.setBounds(new java.awt.Rectangle(15, 220, 465, 240));
jScrollPaneList.setViewportView(getJTextAreaList());
jScrollPaneList.setPreferredSize(new java.awt.Dimension(465, 240));
}
return jScrollPaneList;
}
/**
This method initializes jScrollPane
@return javax.swing.JScrollPane
*/
private JScrollPane getJScrollPane() {
if (jScrollPane == null) {
jScrollPane = new JScrollPane();
jScrollPane.setViewportView(getJContentPane());
}
return jScrollPane;
}
/**
* This method initializes jTextAreaFileList
*
* @return javax.swing.JTextArea
*/
private JTextArea getJTextAreaList() {
if (jTextAreaList == null) {
jTextAreaList = new JTextArea();
jTextAreaList.setEditable(false);
}
return jTextAreaList;
}
/**
This method initializes iCheckBoxListArch
@return ICheckBoxList
**/
private ICheckBoxList getICheckBoxListSupportedArchitectures() {
if (iCheckBoxListArch == null) {
iCheckBoxListArch = new ICheckBoxList();
iCheckBoxListArch.addFocusListener(this);
iCheckBoxListArch.setToolTipText(DataType.SUP_ARCH_LIST_HELP_TEXT);
}
return iCheckBoxListArch;
}
/**
This method initializes jScrollPaneArch
@return javax.swing.JScrollPane
**/
private JScrollPane getJScrollPaneArch() {
if (jScrollPaneArch == null) {
jScrollPaneArch = new JScrollPane();
jScrollPaneArch.setBounds(new java.awt.Rectangle(160, 110, 320, 80));
jScrollPaneArch.setPreferredSize(new java.awt.Dimension(320, 80));
jScrollPaneArch.setViewportView(getICheckBoxListSupportedArchitectures());
}
return jScrollPaneArch;
}
/**
This method initializes jTextFieldHelpText
@return javax.swing.JTextField
**/
private JTextField getJTextFieldHelpText() {
if (jTextFieldHelpText == null) {
jTextFieldHelpText = new JTextField();
jTextFieldHelpText.setBounds(new java.awt.Rectangle(160, 60, 320, 20));
jTextFieldHelpText.setPreferredSize(new java.awt.Dimension(320, 20));
}
return jTextFieldHelpText;
}
public static void main(String[] args) {
}
/**
This method initializes this
**/
private void init() {
this.setSize(500, 515);
this.setContentPane(getJScrollPane());
this.setTitle("Data Hubs");
initFrame();
this.setViewMode(false);
}
/**
This method initializes this
Fill values to all fields if these values are not empty
@param inPackageDependencies
**/
private void init(DataHubs inDataHubs) {
init();
this.dataHubs = inDataHubs;
if (this.dataHubs != null) {
if (this.dataHubs.getDataHubRecordList().size() > 0) {
for (int index = 0; index < this.dataHubs.getDataHubRecordList().size(); index++) {
String arg0 = dataHubs.getDataHubRecordList().get(index).getDataHubCName();
String arg1 = null;
if (dataHubs.getDataHubRecordList().get(index).getUsage() != null) {
arg1 = dataHubs.getDataHubRecordList().get(index).getUsage().toString();
}
String arg2 = dataHubs.getDataHubRecordList().get(index).getFeatureFlag();
Vector<String> arg3 = Tools.convertListToVector(dataHubs.getDataHubRecordList().get(index)
.getSupArchList());
String arg4 = dataHubs.getDataHubRecordList().get(index).getHelpText();
id = new DataHubsIdentification(arg0, arg1, arg2, arg3, arg4);
vid.addDataHubs(id);
}
}
}
//
// Update the list
//
Tools.generateComboBoxByVector(jComboBoxList, vid.getDataHubsName());
reloadListArea();
}
/**
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(OpeningModuleType inOmt) {
super();
this.omt = inOmt;
this.msa = omt.getXmlMsa();
init(msa.getDataHubs());
this.setVisible(true);
}
/**
Disable all components when the mode is view
@param isView true - The view mode; false - The non-view mode
**/
public void setViewMode(boolean isView) {
if (isView) {
this.jTextFieldDataHubRecord.setEnabled(!isView);
this.jComboBoxUsage.setEnabled(!isView);
}
}
/**
This method initializes jContentPane
@return javax.swing.JPanel jContentPane
**/
private JPanel getJContentPane() {
if (jContentPane == null) {
jLabelDataHubRecord = new JLabel();
jLabelDataHubRecord.setBounds(new java.awt.Rectangle(15, 10, 140, 20));
jLabelDataHubRecord.setText("Data Hub Record");
jLabelUsage = new JLabel();
jLabelUsage.setText("Usage");
jLabelUsage.setBounds(new java.awt.Rectangle(15, 35, 140, 20));
jLabelArch = new JLabel();
jLabelArch.setBounds(new java.awt.Rectangle(15, 110, 140, 20));
jLabelArch.setText("Arch");
jLabelFeatureFlag = new JLabel();
jLabelFeatureFlag.setBounds(new java.awt.Rectangle(15, 85, 140, 20));
jLabelFeatureFlag.setText("Feature Flag");
jLabelHelpText = new JLabel();
jLabelHelpText.setBounds(new java.awt.Rectangle(14, 60, 140, 20));
jLabelHelpText.setText("Help Text");
jContentPane = new JPanel();
jContentPane.setLayout(null);
jContentPane.setPreferredSize(new java.awt.Dimension(490, 475));
jContentPane.add(jLabelDataHubRecord, null);
jContentPane.add(jLabelUsage, null);
jContentPane.add(jLabelFeatureFlag, null);
jContentPane.add(jLabelArch, null);
jContentPane.add(getJTextFieldDataHubRecord(), null);
jContentPane.add(getJComboBoxUsage(), null);
jContentPane.add(getJTextFieldFeatureFlag(), 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(getJComboBoxList(), null);
jContentPane.add(getJButtonAdd(), null);
jContentPane.add(getJButtonRemove(), null);
jContentPane.add(getJButtonUpdate(), null);
jContentPane.add(getJScrollPaneList(), null);
jContentPane.add(getJScrollPaneArch(), null);
jContentPane.add(jLabelHelpText, null);
jContentPane.add(getJTextFieldHelpText(), null);
}
return jContentPane;
}
/**
This method initializes Usage type
**/
private void initFrame() {
Tools.generateComboBoxByVector(jComboBoxUsage, ed.getVDataHubUsage());
this.iCheckBoxListArch.setAllItems(ed.getVSupportedArchitectures());
}
/* (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() == jButtonAdd) {
if (!checkAdd()) {
return;
}
addToList();
}
if (arg0.getSource() == jButtonRemove) {
removeFromList();
}
if (arg0.getSource() == jButtonUpdate) {
if (!checkAdd()) {
return;
}
updateForList();
}
}
/**
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 fields have correct data types
//
//
// Check DataHubRecord
//
if (isEmpty(this.jTextFieldDataHubRecord.getText())) {
Log.err("Data Hub Record couldn't be empty");
return false;
}
if (!isEmpty(this.jTextFieldDataHubRecord.getText())) {
if (!DataValidation.isC_NameType(this.jTextFieldDataHubRecord.getText())) {
Log.err("Incorrect data type for Data Hub Record");
return false;
}
}
//
// Check FeatureFlag
//
if (!isEmpty(this.jTextFieldFeatureFlag.getText())) {
if (!DataValidation.isFeatureFlag(this.jTextFieldFeatureFlag.getText())) {
Log.err("Incorrect data type for Feature Flag");
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 {
int count = this.vid.size();
this.dataHubs = DataHubs.Factory.newInstance();
if (count > 0) {
for (int index = 0; index < count; index++) {
DataHubRecord p = DataHubRecord.Factory.newInstance();
if (!isEmpty(vid.getDataHubs(index).getName())) {
p.setDataHubCName(vid.getDataHubs(index).getName());
}
if (!isEmpty(vid.getDataHubs(index).getUsage())) {
p.setUsage(DataHubUsage.Enum.forString(vid.getDataHubs(index).getUsage()));
}
if (!isEmpty(vid.getDataHubs(index).getFeatureFlag())) {
p.setFeatureFlag(vid.getDataHubs(index).getFeatureFlag());
}
if (vid.getDataHubs(index).getSupArchList() != null
&& vid.getDataHubs(index).getSupArchList().size() > 0) {
p.setSupArchList(vid.getDataHubs(index).getSupArchList());
}
if (!isEmpty(vid.getDataHubs(index).getHelp())) {
p.setHelpText(vid.getDataHubs(index).getHelp());
}
this.dataHubs.addNewDataHubRecord();
this.dataHubs.setDataHubRecordArray(dataHubs.getDataHubRecordList().size() - 1, p);
}
}
this.msa.setDataHubs(dataHubs);
this.omt.setSaved(false);
} catch (Exception e) {
Log.err("Update Data Hubs", e.getMessage());
}
}
/* (non-Javadoc)
* @see java.awt.event.ComponentListener#componentResized(java.awt.event.ComponentEvent)
*
* Override componentResized to resize all components when frame's size is changed
*/
public void componentResized(ComponentEvent arg0) {
int intCurrentWidth = this.getJContentPane().getWidth();
int intCurrentHeight = this.getJContentPane().getHeight();
int intPreferredWidth = this.getJContentPane().getPreferredSize().width;
int intPreferredHeight = this.getJContentPane().getPreferredSize().height;
resizeComponentWidth(jTextFieldDataHubRecord, intCurrentWidth, intPreferredWidth);
resizeComponentWidth(jComboBoxUsage, intCurrentWidth, intPreferredWidth);
resizeComponentWidth(jTextFieldHelpText, intCurrentWidth, intPreferredWidth);
resizeComponentWidth(jTextFieldFeatureFlag, intCurrentWidth, intPreferredWidth);
resizeComponentWidth(jScrollPaneArch, intCurrentWidth, intPreferredWidth);
resizeComponentWidth(jComboBoxList, intCurrentWidth, intPreferredWidth);
resizeComponent(jScrollPaneList, intCurrentWidth, intCurrentHeight, intPreferredWidth, intPreferredHeight);
relocateComponentX(jButtonAdd, intCurrentWidth, intPreferredWidth, DataType.SPACE_TO_RIGHT_FOR_ADD_BUTTON);
relocateComponentX(jButtonRemove, intCurrentWidth, intPreferredWidth, DataType.SPACE_TO_RIGHT_FOR_REMOVE_BUTTON);
relocateComponentX(jButtonUpdate, intCurrentWidth, intPreferredWidth, DataType.SPACE_TO_RIGHT_FOR_UPDATE_BUTTON);
}
private DataHubsIdentification getCurrentDataHubs() {
String arg0 = this.jTextFieldDataHubRecord.getText();
String arg1 = this.jComboBoxUsage.getSelectedItem().toString();
String arg2 = this.jTextFieldFeatureFlag.getText();
Vector<String> arg3 = this.iCheckBoxListArch.getAllCheckedItemsString();
String arg4 = this.jTextFieldHelpText.getText();
id = new DataHubsIdentification(arg0, arg1, arg2, arg3, arg4);
return id;
}
/**
Add current item to Vector
**/
private void addToList() {
intSelectedItemId = vid.size();
vid.addDataHubs(getCurrentDataHubs());
jComboBoxList.addItem(id.getName());
jComboBoxList.setSelectedItem(id.getName());
//
// Reset select item index
//
intSelectedItemId = vid.size();
//
// Reload all fields of selected item
//
reloadFromList();
//
// Save to memory
//
save();
}
/**
Remove current item from Vector
**/
private void removeFromList() {
//
// Check if exist items
//
if (this.vid.size() < 1) {
return;
}
int intTempIndex = intSelectedItemId;
jComboBoxList.removeItemAt(intSelectedItemId);
vid.removeDataHubs(intTempIndex);
//
// Reload all fields of selected item
//
reloadFromList();
//
// Save to memory
//
save();
}
/**
Update current item of Vector
**/
private void updateForList() {
//
// Check if exist items
//
if (this.vid.size() < 1) {
return;
}
//
// Backup selected item index
//
int intTempIndex = intSelectedItemId;
vid.updateDataHubs(getCurrentDataHubs(), intTempIndex);
jComboBoxList.removeAllItems();
for (int index = 0; index < vid.size(); index++) {
jComboBoxList.addItem(vid.getDataHubs(index).getName());
}
//
// Restore selected item index
//
intSelectedItemId = intTempIndex;
//
// Reset select item index
//
jComboBoxList.setSelectedIndex(intSelectedItemId);
//
// Reload all fields of selected item
//
reloadFromList();
//
// Save to memory
//
save();
}
/**
Refresh all fields' values of selected item of Vector
**/
private void reloadFromList() {
if (vid.size() > 0) {
//
// Get selected item index
//
intSelectedItemId = jComboBoxList.getSelectedIndex();
this.jTextFieldDataHubRecord.setText(vid.getDataHubs(intSelectedItemId).getName());
this.jComboBoxUsage.setSelectedItem(vid.getDataHubs(intSelectedItemId).getUsage());
this.jTextFieldHelpText.setText(vid.getDataHubs(intSelectedItemId).getHelp());
jTextFieldFeatureFlag.setText(vid.getDataHubs(intSelectedItemId).getFeatureFlag());
iCheckBoxListArch.setAllItemsUnchecked();
iCheckBoxListArch.initCheckedItem(true, vid.getDataHubs(intSelectedItemId).getSupArchList());
} else {
}
reloadListArea();
}
/**
Update list area pane via the elements of Vector
**/
private void reloadListArea() {
String strListItem = "";
for (int index = 0; index < vid.size(); index++) {
strListItem = strListItem + vid.getDataHubs(index).getName() + DataType.UNIX_LINE_SEPARATOR;
}
this.jTextAreaList.setText(strListItem);
}
/* (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.getSource() == this.jComboBoxList && arg0.getStateChange() == ItemEvent.SELECTED) {
reloadFromList();
}
}
}

View File

@@ -0,0 +1,347 @@
/** @file
The file is used to create, update Module Definitions 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.frameworkwizard.module.ui;
import java.awt.event.ComponentEvent;
import java.awt.event.FocusEvent;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.JComboBox;
import org.tianocore.ModuleDefinitionsDocument;
import org.tianocore.ModuleSurfaceAreaDocument;
import org.tianocore.ModuleDefinitionsDocument.ModuleDefinitions.ClonedFrom;
import org.tianocore.frameworkwizard.common.DataValidation;
import org.tianocore.frameworkwizard.common.EnumerationData;
import org.tianocore.frameworkwizard.common.Log;
import org.tianocore.frameworkwizard.common.OpeningModuleType;
import org.tianocore.frameworkwizard.common.Tools;
import org.tianocore.frameworkwizard.common.ui.IInternalFrame;
import org.tianocore.frameworkwizard.common.ui.StarLabel;
import org.tianocore.frameworkwizard.common.ui.iCheckBoxList.ICheckBoxList;
public class ModuleDefinitions extends IInternalFrame {
///
/// Define class Serial Version UID
///
private static final long serialVersionUID = 5860378543553036323L;
private JScrollPane jScrollPane = null;
private JPanel jContentPane = null;
private JLabel jLabelArch = null;
private ICheckBoxList iCheckBoxListArch = null;
private JLabel jLabelBinaryModule = null;
private JComboBox jComboBoxBinaryModule = null;
private JLabel jLabelOutputFileBasename = null;
private JTextField jTextFieldOutputFileBasename = null;
private JScrollPane jScrollPaneArch = null;
private StarLabel jStarLabel1 = null;
private StarLabel jStarLabel2 = null;
private StarLabel jStarLabel3 = null;
private OpeningModuleType omt = null;
private ClonedFrom cf = null;
private ModuleSurfaceAreaDocument.ModuleSurfaceArea msa = null;
private ModuleDefinitionsDocument.ModuleDefinitions md = null;
/**
* This method initializes jScrollPane
*
* @return javax.swing.JScrollPane
*/
private JScrollPane getJScrollPane() {
if (jScrollPane == null) {
jScrollPane = new JScrollPane();
jScrollPane.setViewportView(getJContentPane());
}
return jScrollPane;
}
/**
* This method initializes jPanel
*
* @return javax.swing.JPanel
*/
private JPanel getJContentPane() {
if (jContentPane == null) {
jLabelOutputFileBasename = new JLabel();
jLabelOutputFileBasename.setBounds(new java.awt.Rectangle(15, 10, 140, 20));
jLabelOutputFileBasename.setText("Output File Basename");
jLabelBinaryModule = new JLabel();
jLabelBinaryModule.setBounds(new java.awt.Rectangle(15, 35, 140, 20));
jLabelBinaryModule.setText("Binary Module");
jLabelArch = new JLabel();
jLabelArch.setBounds(new java.awt.Rectangle(15, 60, 140, 20));
jLabelArch.setText("Supported Architectures");
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));
jContentPane = new JPanel();
jContentPane.setLayout(null);
jContentPane.setPreferredSize(new java.awt.Dimension(490, 150));
jContentPane.add(jLabelArch, null);
jContentPane.add(getJScrollPaneArch(), null);
jContentPane.add(jLabelBinaryModule, null);
jContentPane.add(getJComboBoxBinaryModule(), null);
jContentPane.add(jLabelOutputFileBasename, null);
jContentPane.add(getJTextFieldOutputFileBasename(), null);
jContentPane.add(jStarLabel1, null);
jContentPane.add(jStarLabel2, null);
jContentPane.add(jStarLabel3, null);
}
return jContentPane;
}
/**
This method initializes iCheckBoxListArch
@return ICheckBoxList
**/
private ICheckBoxList getICheckBoxListSupportedArchitectures() {
if (iCheckBoxListArch == null) {
iCheckBoxListArch = new ICheckBoxList();
iCheckBoxListArch.addFocusListener(this);
}
return iCheckBoxListArch;
}
/**
* This method initializes jComboBoxBinaryModule
*
* @return javax.swing.JComboBox
*/
private JComboBox getJComboBoxBinaryModule() {
if (jComboBoxBinaryModule == null) {
jComboBoxBinaryModule = new JComboBox();
jComboBoxBinaryModule.setBounds(new java.awt.Rectangle(160, 35, 320, 20));
jComboBoxBinaryModule.setPreferredSize(new java.awt.Dimension(320, 20));
jComboBoxBinaryModule.addFocusListener(this);
jComboBoxBinaryModule.setToolTipText("Modules are either source modules which can be compiled or binary modules which are linked. A module cannot contain both. The GUID numbers should be identical for a binary and source MSA, but the BINARY MSA should have a higher version number.");
}
return jComboBoxBinaryModule;
}
/**
* This method initializes jTextFieldOutputFileBasename
*
* @return javax.swing.JTextField
*/
private JTextField getJTextFieldOutputFileBasename() {
if (jTextFieldOutputFileBasename == null) {
jTextFieldOutputFileBasename = new JTextField();
jTextFieldOutputFileBasename.setBounds(new java.awt.Rectangle(160, 10, 320, 20));
jTextFieldOutputFileBasename.setPreferredSize(new java.awt.Dimension(320, 20));
jTextFieldOutputFileBasename.addFocusListener(this);
jTextFieldOutputFileBasename.setToolTipText("Enter a single word for generated output file names");
}
return jTextFieldOutputFileBasename;
}
/**
This method initializes jScrollPaneArch
@return javax.swing.JScrollPane
**/
private JScrollPane getJScrollPaneArch() {
if (jScrollPaneArch == null) {
jScrollPaneArch = new JScrollPane();
jScrollPaneArch.setBounds(new java.awt.Rectangle(160, 60, 320, 80));
jScrollPaneArch.setPreferredSize(new java.awt.Dimension(320, 60));
jScrollPaneArch.setViewportView(getICheckBoxListSupportedArchitectures());
}
return jScrollPaneArch;
}
/**
@param args
**/
public static void main(String[] args) {
// TODO Auto-generated method stub
}
/**
* This is the default constructor
*/
public ModuleDefinitions() {
super();
init();
this.setVisible(true);
}
/**
This is the override edit constructor
@param inMsa
**/
public ModuleDefinitions(OpeningModuleType inOmt) {
super();
this.omt = inOmt;
this.msa = omt.getXmlMsa();
if (msa.getModuleDefinitions() != null) {
this.cf = msa.getModuleDefinitions().getClonedFrom();
}
init(msa.getModuleDefinitions());
this.setVisible(true);
}
/**
* This method initializes this
*
* @return void
*/
private void init() {
this.setContentPane(getJScrollPane());
this.setTitle("Module Definitions");
initFrame();
this.setPreferredSize(new java.awt.Dimension(490, 520));
}
/**
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(ModuleDefinitionsDocument.ModuleDefinitions inMd) {
init();
if (inMd != null) {
this.md = inMd;
if (md.getSupportedArchitectures() != null) {
this.iCheckBoxListArch.initCheckedItem(true, Tools.convertListToVector(md.getSupportedArchitectures()));
}
if (md.getBinaryModule()) {
this.jComboBoxBinaryModule.setSelectedIndex(1);
} else {
this.jComboBoxBinaryModule.setSelectedIndex(0);
}
if (md.getOutputFileBasename() != null) {
this.jTextFieldOutputFileBasename.setText(md.getOutputFileBasename());
}
}
}
/**
This method initializes Module type and Compontent type
**/
private void initFrame() {
EnumerationData ed = new EnumerationData();
this.iCheckBoxListArch.setAllItems(ed.getVSupportedArchitectures());
Tools.generateComboBoxByVector(jComboBoxBinaryModule, ed.getVBoolean());
}
private boolean check() {
if (isEmpty(this.jTextFieldOutputFileBasename.getText())) {
Log.err("Output File Basename couldn't be empty!");
return false;
}
if (!DataValidation.isOutputFileBasename(this.jTextFieldOutputFileBasename.getText())) {
Log.err("Incorrect data type for Output File Basename");
return false;
}
return true;
}
/* (non-Javadoc)
* @see java.awt.event.ComponentListener#componentResized(java.awt.event.ComponentEvent)
*
* Override componentResized to resize all components when frame's size is changed
*/
public void componentResized(ComponentEvent arg0) {
int intCurrentWidth = this.getJContentPane().getWidth();
int intPreferredWidth = this.getJContentPane().getPreferredSize().width;
resizeComponentWidth(this.jScrollPaneArch, intCurrentWidth, intPreferredWidth);
resizeComponentWidth(this.jComboBoxBinaryModule, intCurrentWidth, intPreferredWidth);
resizeComponentWidth(this.jTextFieldOutputFileBasename, intCurrentWidth, intPreferredWidth);
}
/**
Save all components of Module Definitions
if exists Module Definitions, set the value directly
if not exists Module Definitions, new an instance first
**/
public void save() {
check();
try {
if (this.md == null) {
md = ModuleDefinitionsDocument.ModuleDefinitions.Factory.newInstance();
}
if (!isEmpty(this.jTextFieldOutputFileBasename.getText())) {
md.setOutputFileBasename(this.jTextFieldOutputFileBasename.getText());
}
if (this.jComboBoxBinaryModule.getSelectedIndex() == 0) {
md.setBinaryModule(false);
} else {
md.setBinaryModule(true);
}
//
// Set ClonedFrom field
//
if (this.cf != null) {
md.setClonedFrom(this.cf);
}
//
// Save Arch list
//
md.setSupportedArchitectures(this.iCheckBoxListArch.getAllCheckedItemsString());
msa.setModuleDefinitions(md);
this.omt.setSaved(false);
} catch (Exception e) {
Log.err("Save Module Definitions", e.getMessage());
}
}
public void focusLost(FocusEvent arg0) {
this.save();
}
}

View File

@@ -0,0 +1,852 @@
/** @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.frameworkwizard.module.ui;
import java.awt.event.ActionEvent;
import java.awt.event.ComponentEvent;
import java.awt.event.ItemEvent;
import java.util.Vector;
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.EventsDocument;
import org.tianocore.ProtocolNotifyUsage;
import org.tianocore.ProtocolUsage;
import org.tianocore.EventsDocument.Events;
import org.tianocore.EventsDocument.Events.CreateEvents;
import org.tianocore.EventsDocument.Events.SignalEvents;
import org.tianocore.ModuleSurfaceAreaDocument.ModuleSurfaceArea;
import org.tianocore.frameworkwizard.common.DataType;
import org.tianocore.frameworkwizard.common.DataValidation;
import org.tianocore.frameworkwizard.common.EnumerationData;
import org.tianocore.frameworkwizard.common.Log;
import org.tianocore.frameworkwizard.common.OpeningModuleType;
import org.tianocore.frameworkwizard.common.Tools;
import org.tianocore.frameworkwizard.common.ui.IInternalFrame;
import org.tianocore.frameworkwizard.common.ui.StarLabel;
import org.tianocore.frameworkwizard.common.ui.iCheckBoxList.ICheckBoxList;
import org.tianocore.frameworkwizard.module.Identification.Events.EventsIdentification;
import org.tianocore.frameworkwizard.module.Identification.Events.EventsVector;
/**
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 JPanel jContentPane = null;
private JLabel jLabelEventType = null;
private JLabel jLabelC_Name = null;
private JTextField jTextFieldC_Name = null;
private JLabel jLabelUsage = null;
private JComboBox jComboBoxUsage = null;
private StarLabel jStarLabel1 = null;
private StarLabel jStarLabel2 = null;
private JComboBox jComboBoxEventsType = null;
private JTextArea jTextAreaList = null;
private JComboBox jComboBoxList = null;
private JButton jButtonAdd = null;
private JButton jButtonRemove = null;
private JButton jButtonUpdate = null;
private JScrollPane jScrollPane = null;
private JScrollPane jScrollPaneList = null;
private JLabel jLabelArch = null;
private ICheckBoxList iCheckBoxListArch = null;
private JScrollPane jScrollPaneArch = null;
private JLabel jLabelHelpText = null;
private JTextField jTextFieldHelpText = null;
private JLabel jLabelFeatureFlag = null;
private JTextField jTextFieldFeatureFlag = null;
//
// Not used by UI
//
private int intSelectedItemId = 0;
private OpeningModuleType omt = null;
private ModuleSurfaceArea msa = null;
private EventsDocument.Events events = null;
private EventsIdentification id = null;
private EventsVector vid = new EventsVector();
private EnumerationData ed = new EnumerationData();
/**
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));
jTextFieldC_Name.setPreferredSize(new java.awt.Dimension(320, 20));
}
return jTextFieldC_Name;
}
/**
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));
jComboBoxUsage.setPreferredSize(new java.awt.Dimension(320, 20));
}
return jComboBoxUsage;
}
/**
* This method initializes jComboBoxEventsType
*
* @return javax.swing.JComboBox
*/
private JComboBox getJComboBoxEventsType() {
if (jComboBoxEventsType == null) {
jComboBoxEventsType = new JComboBox();
jComboBoxEventsType.setBounds(new java.awt.Rectangle(160, 10, 320, 20));
jComboBoxEventsType.setPreferredSize(new java.awt.Dimension(320, 20));
}
return jComboBoxEventsType;
}
/**
This method initializes jComboBoxFileList
@return javax.swing.JComboBox jComboBoxFileList
**/
private JComboBox getJComboBoxList() {
if (jComboBoxList == null) {
jComboBoxList = new JComboBox();
jComboBoxList.setBounds(new java.awt.Rectangle(15, 220, 210, 20));
jComboBoxList.addItemListener(this);
jComboBoxList.addActionListener(this);
jComboBoxList.setPreferredSize(new java.awt.Dimension(210, 20));
}
return jComboBoxList;
}
/**
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, 220, 80, 20));
jButtonAdd.setText("Add");
jButtonAdd.addActionListener(this);
jButtonAdd.setPreferredSize(new java.awt.Dimension(80, 20));
}
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, 220, 80, 20));
jButtonRemove.setText("Remove");
jButtonRemove.addActionListener(this);
jButtonRemove.setPreferredSize(new java.awt.Dimension(80, 20));
}
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, 220, 80, 20));
jButtonUpdate.setPreferredSize(new java.awt.Dimension(80, 20));
jButtonUpdate.setText("Update");
jButtonUpdate.addActionListener(this);
}
return jButtonUpdate;
}
/**
* This method initializes jScrollPaneFileList
*
* @return javax.swing.JScrollPane
*/
private JScrollPane getJScrollPaneList() {
if (jScrollPaneList == null) {
jScrollPaneList = new JScrollPane();
jScrollPaneList.setBounds(new java.awt.Rectangle(15, 245, 465, 240));
jScrollPaneList.setViewportView(getJTextAreaList());
jScrollPaneList.setPreferredSize(new java.awt.Dimension(465, 240));
}
return jScrollPaneList;
}
/**
This method initializes jScrollPane
@return javax.swing.JScrollPane
*/
private JScrollPane getJScrollPane() {
if (jScrollPane == null) {
jScrollPane = new JScrollPane();
jScrollPane.setViewportView(getJContentPane());
}
return jScrollPane;
}
/**
* This method initializes jTextAreaFileList
*
* @return javax.swing.JTextArea
*/
private JTextArea getJTextAreaList() {
if (jTextAreaList == null) {
jTextAreaList = new JTextArea();
jTextAreaList.setEditable(false);
}
return jTextAreaList;
}
/**
This method initializes iCheckBoxListArch
@return ICheckBoxList
**/
private ICheckBoxList getICheckBoxListSupportedArchitectures() {
if (iCheckBoxListArch == null) {
iCheckBoxListArch = new ICheckBoxList();
iCheckBoxListArch.addFocusListener(this);
iCheckBoxListArch.setToolTipText(DataType.SUP_ARCH_LIST_HELP_TEXT);
}
return iCheckBoxListArch;
}
/**
This method initializes jScrollPaneArch
@return javax.swing.JScrollPane
**/
private JScrollPane getJScrollPaneArch() {
if (jScrollPaneArch == null) {
jScrollPaneArch = new JScrollPane();
jScrollPaneArch.setBounds(new java.awt.Rectangle(160, 135, 320, 80));
jScrollPaneArch.setPreferredSize(new java.awt.Dimension(320, 80));
jScrollPaneArch.setViewportView(getICheckBoxListSupportedArchitectures());
}
return jScrollPaneArch;
}
/**
* This method initializes jTextFieldFeatureFlag
*
* @return javax.swing.JTextField
*/
private JTextField getJTextFieldFeatureFlag() {
if (jTextFieldFeatureFlag == null) {
jTextFieldFeatureFlag = new JTextField();
jTextFieldFeatureFlag.setBounds(new java.awt.Rectangle(160,110,320,20));
jTextFieldFeatureFlag.setPreferredSize(new java.awt.Dimension(320,20));
}
return jTextFieldFeatureFlag;
}
/**
This method initializes jTextFieldHelpText
@return javax.swing.JTextField
**/
private JTextField getJTextFieldHelpText() {
if (jTextFieldHelpText == null) {
jTextFieldHelpText = new JTextField();
jTextFieldHelpText.setBounds(new java.awt.Rectangle(160, 85, 320, 20));
jTextFieldHelpText.setPreferredSize(new java.awt.Dimension(320, 20));
}
return jTextFieldHelpText;
}
public static void main(String[] args) {
}
/**
This method initializes this
**/
private void init() {
this.setSize(500, 515);
this.setContentPane(getJScrollPane());
this.setTitle("Events");
initFrame();
this.setViewMode(false);
}
/**
This method initializes this
Fill values to all fields if these values are not empty
@param inPackageDependencies
**/
private void init(Events inEvents) {
init();
this.events = inEvents;
if (this.events != null) {
if (this.events.getCreateEvents() != null) {
if (this.events.getCreateEvents().getEventTypesList().size() > 0) {
for (int index = 0; index < this.events.getCreateEvents().getEventTypesList().size(); index++) {
String arg0 = events.getCreateEvents().getEventTypesList().get(index).getEventGuidCName();
String arg1 = ed.getVEventType().get(0);
String arg2 = null;
if (events.getCreateEvents().getEventTypesList().get(index).getUsage() != null) {
arg2 = events.getCreateEvents().getEventTypesList().get(index).getUsage().toString();
}
String arg3 = events.getCreateEvents().getEventTypesList().get(index).getFeatureFlag();
Vector<String> arg4 = Tools.convertListToVector(events.getCreateEvents().getEventTypesList().get(index)
.getSupArchList());
String arg5 = events.getCreateEvents().getEventTypesList().get(index).getHelpText();
id = new EventsIdentification(arg0, arg1, arg2, arg3, arg4, arg5);
vid.addEvents(id);
}
}
}
if (this.events.getSignalEvents() != null) {
if (this.events.getSignalEvents().getEventTypesList().size() > 0) {
for (int index = 0; index < this.events.getSignalEvents().getEventTypesList().size(); index++) {
String arg0 = events.getSignalEvents().getEventTypesList().get(index).getEventGuidCName();
String arg1 = ed.getVEventType().get(1);
String arg2 = null;
if (events.getSignalEvents().getEventTypesList().get(index).getUsage() != null) {
arg2 = events.getSignalEvents().getEventTypesList().get(index).getUsage().toString();
}
String arg3 = events.getSignalEvents().getEventTypesList().get(index).getFeatureFlag();
Vector<String> arg4 = Tools.convertListToVector(events.getSignalEvents().getEventTypesList().get(index)
.getSupArchList());
String arg5 = events.getSignalEvents().getEventTypesList().get(index).getHelpText();
id = new EventsIdentification(arg0, arg1, arg2, arg3, arg4, arg5);
vid.addEvents(id);
}
}
}
}
//
// Update the list
//
Tools.generateComboBoxByVector(jComboBoxList, vid.getEventsName());
reloadListArea();
}
/**
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(OpeningModuleType inOmt) {
super();
this.omt = inOmt;
this.msa = omt.getXmlMsa();
init(msa.getEvents());
this.setVisible(true);
}
/**
Disable all components when the mode is view
@param isView true - The view mode; false - The non-view mode
**/
public void setViewMode(boolean isView) {
if (isView) {
this.jTextFieldC_Name.setEnabled(!isView);
this.jComboBoxUsage.setEnabled(!isView);
}
}
/**
This method initializes jContentPane
@return javax.swing.JPanel jContentPane
**/
private JPanel getJContentPane() {
if (jContentPane == null) {
jLabelFeatureFlag = new JLabel();
jLabelFeatureFlag.setBounds(new java.awt.Rectangle(15,110,140,20));
jLabelFeatureFlag.setText("Feature Flag");
jLabelArch = new JLabel();
jLabelArch.setBounds(new java.awt.Rectangle(15, 135, 140, 20));
jLabelArch.setText("Arch");
jLabelUsage = new JLabel();
jLabelUsage.setText("Usage");
jLabelUsage.setBounds(new java.awt.Rectangle(15, 60, 140, 20));
jLabelC_Name = new JLabel();
jLabelC_Name.setText("Guid 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));
jLabelHelpText = new JLabel();
jLabelHelpText.setBounds(new java.awt.Rectangle(14, 85, 140, 20));
jLabelHelpText.setText("Help Text");
jContentPane = new JPanel();
jContentPane.setLayout(null);
jContentPane.setPreferredSize(new java.awt.Dimension(490, 490));
jContentPane.add(jLabelEventType, null);
jContentPane.add(jLabelC_Name, null);
jContentPane.add(getJTextFieldC_Name(), null);
jContentPane.add(jLabelUsage, null);
jContentPane.add(getJComboBoxUsage(), 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(getJComboBoxEventsType(), null);
jContentPane.add(getJComboBoxList(), null);
jContentPane.add(getJButtonAdd(), null);
jContentPane.add(getJButtonRemove(), null);
jContentPane.add(getJButtonUpdate(), null);
jContentPane.add(getJScrollPaneList(), null);
jContentPane.add(jLabelArch, null);
jContentPane.add(getJScrollPaneArch(), null);
jContentPane.add(jLabelFeatureFlag, null);
jContentPane.add(getJTextFieldFeatureFlag(), null);
jContentPane.add(jLabelHelpText, null);
jContentPane.add(getJTextFieldHelpText(), null);
}
return jContentPane;
}
/**
This method initializes events groups and usage type
**/
private void initFrame() {
Tools.generateComboBoxByVector(jComboBoxEventsType, ed.getVEventType());
Tools.generateComboBoxByVector(jComboBoxUsage, ed.getVEventUsage());
this.iCheckBoxListArch.setAllItems(ed.getVSupportedArchitectures());
}
/* (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() == jButtonAdd) {
if (!checkAdd()) {
return;
}
addToList();
}
if (arg0.getSource() == jButtonRemove) {
removeFromList();
}
if (arg0.getSource() == jButtonUpdate) {
if (!checkAdd()) {
return;
}
updateForList();
}
}
/**
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 fields have correct data types
//
//
// Check Name
//
if (isEmpty(this.jTextFieldC_Name.getText())) {
Log.err("Event Name couldn't be empty");
return false;
}
if (!isEmpty(this.jTextFieldC_Name.getText())) {
if (!DataValidation.isC_NameType(this.jTextFieldC_Name.getText())) {
Log.err("Incorrect data type for Event Name");
return false;
}
}
//
// Check FeatureFlag
//
if (!isEmpty(this.jTextFieldFeatureFlag.getText())) {
if (!DataValidation.isFeatureFlag(this.jTextFieldFeatureFlag.getText())) {
Log.err("Incorrect data type for Feature Flag");
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 {
int count = this.vid.size();
this.events = Events.Factory.newInstance();
CreateEvents ce = CreateEvents.Factory.newInstance();
SignalEvents se = SignalEvents.Factory.newInstance();
if (count > 0) {
for (int index = 0; index < count; index++) {
if (vid.getEvents(index).getType().equals(ed.getVEventType().get(0))) {
CreateEvents.EventTypes e = CreateEvents.EventTypes.Factory.newInstance();
if (!isEmpty(vid.getEvents(index).getName())) {
e.setEventGuidCName(vid.getEvents(index).getName());
}
if (!isEmpty(vid.getEvents(index).getUsage())) {
e.setUsage(ProtocolUsage.Enum.forString(vid.getEvents(index).getUsage()));
}
if (!isEmpty(vid.getEvents(index).getFeatureFlag())) {
e.setFeatureFlag(vid.getEvents(index).getFeatureFlag());
}
if (vid.getEvents(index).getSupArchList() != null
&& vid.getEvents(index).getSupArchList().size() > 0) {
e.setSupArchList(vid.getEvents(index).getSupArchList());
}
if (!isEmpty(vid.getEvents(index).getHelp())) {
e.setHelpText(vid.getEvents(index).getHelp());
}
ce.addNewEventTypes();
ce.setEventTypesArray(ce.getEventTypesList().size() - 1, e);
}
if (vid.getEvents(index).getType().equals("Protocol Notify")) {
SignalEvents.EventTypes e = SignalEvents.EventTypes.Factory.newInstance();
if (!isEmpty(vid.getEvents(index).getName())) {
e.setEventGuidCName(vid.getEvents(index).getName());
}
if (!isEmpty(vid.getEvents(index).getUsage())) {
e.setUsage(ProtocolNotifyUsage.Enum.forString(vid.getEvents(index).getUsage()));
}
if (!isEmpty(vid.getEvents(index).getFeatureFlag())) {
e.setFeatureFlag(vid.getEvents(index).getFeatureFlag());
}
if (vid.getEvents(index).getSupArchList() != null
&& vid.getEvents(index).getSupArchList().size() > 0) {
e.setSupArchList(vid.getEvents(index).getSupArchList());
}
if (!isEmpty(vid.getEvents(index).getHelp())) {
e.setHelpText(vid.getEvents(index).getHelp());
}
se.addNewEventTypes();
se.setEventTypesArray(ce.getEventTypesList().size() - 1, e);
}
}
}
if (ce.getEventTypesList().size() > 0) {
events.addNewCreateEvents();
events.setCreateEvents(ce);
}
if (se.getEventTypesList().size() > 0) {
events.addNewSignalEvents();
events.setSignalEvents(se);
}
this.msa.setEvents(events);
this.omt.setSaved(false);
} catch (Exception e) {
e.printStackTrace();
Log.err("Update Events", e.getMessage());
}
}
/* (non-Javadoc)
* @see java.awt.event.ComponentListener#componentResized(java.awt.event.ComponentEvent)
*
* Override componentResized to resize all components when frame's size is changed
*/
public void componentResized(ComponentEvent arg0) {
int intCurrentWidth = this.getJContentPane().getWidth();
int intCurrentHeight = this.getJContentPane().getHeight();
int intPreferredWidth = this.getJContentPane().getPreferredSize().width;
int intPreferredHeight = this.getJContentPane().getPreferredSize().height;
resizeComponentWidth(jComboBoxEventsType, intCurrentWidth, intPreferredWidth);
resizeComponentWidth(jTextFieldC_Name, intCurrentWidth, intPreferredWidth);
resizeComponentWidth(jComboBoxUsage, intCurrentWidth, intPreferredWidth);
resizeComponentWidth(jTextFieldHelpText, intCurrentWidth, intPreferredWidth);
resizeComponentWidth(jTextFieldFeatureFlag, intCurrentWidth, intPreferredWidth);
resizeComponentWidth(jScrollPaneArch, intCurrentWidth, intPreferredWidth);
resizeComponentWidth(jComboBoxList, intCurrentWidth, intPreferredWidth);
resizeComponent(jScrollPaneList, intCurrentWidth, intCurrentHeight, intPreferredWidth, intPreferredHeight);
relocateComponentX(jButtonAdd, intCurrentWidth, intPreferredWidth, DataType.SPACE_TO_RIGHT_FOR_ADD_BUTTON);
relocateComponentX(jButtonRemove, intCurrentWidth, intPreferredWidth, DataType.SPACE_TO_RIGHT_FOR_REMOVE_BUTTON);
relocateComponentX(jButtonUpdate, intCurrentWidth, intPreferredWidth, DataType.SPACE_TO_RIGHT_FOR_UPDATE_BUTTON);
}
private EventsIdentification getCurrentEvents() {
String arg0 = this.jTextFieldC_Name.getText();
String arg1 = this.jComboBoxEventsType.getSelectedItem().toString();
String arg2 = this.jComboBoxUsage.getSelectedItem().toString();
String arg3 = this.jTextFieldFeatureFlag.getText();
Vector<String> arg4 = this.iCheckBoxListArch.getAllCheckedItemsString();
String arg5 = this.jTextFieldHelpText.getText();
id = new EventsIdentification(arg0, arg1, arg2, arg3, arg4, arg5);
return id;
}
/**
Add current item to Vector
**/
private void addToList() {
intSelectedItemId = vid.size();
vid.addEvents(getCurrentEvents());
jComboBoxList.addItem(id.getName());
jComboBoxList.setSelectedItem(id.getName());
//
// Reset select item index
//
intSelectedItemId = vid.size();
//
// Reload all fields of selected item
//
reloadFromList();
//
// Save to memory
//
save();
}
/**
Remove current item from Vector
**/
private void removeFromList() {
//
// Check if exist items
//
if (this.vid.size() < 1) {
return;
}
int intTempIndex = intSelectedItemId;
jComboBoxList.removeItemAt(intSelectedItemId);
vid.removeEvents(intTempIndex);
//
// Reload all fields of selected item
//
reloadFromList();
//
// Save to memory
//
save();
}
/**
Update current item of Vector
**/
private void updateForList() {
//
// Check if exist items
//
if (this.vid.size() < 1) {
return;
}
//
// Backup selected item index
//
int intTempIndex = intSelectedItemId;
vid.updateEvents(getCurrentEvents(), intTempIndex);
jComboBoxList.removeAllItems();
for (int index = 0; index < vid.size(); index++) {
jComboBoxList.addItem(vid.getEvents(index).getName());
}
//
// Restore selected item index
//
intSelectedItemId = intTempIndex;
//
// Reset select item index
//
jComboBoxList.setSelectedIndex(intSelectedItemId);
//
// Reload all fields of selected item
//
reloadFromList();
//
// Save to memory
//
save();
}
/**
Refresh all fields' values of selected item of Vector
**/
private void reloadFromList() {
if (vid.size() > 0) {
//
// Get selected item index
//
intSelectedItemId = jComboBoxList.getSelectedIndex();
this.jTextFieldC_Name.setText(vid.getEvents(intSelectedItemId).getName());
this.jComboBoxEventsType.setSelectedItem(vid.getEvents(intSelectedItemId).getType());
this.jComboBoxUsage.setSelectedItem(vid.getEvents(intSelectedItemId).getUsage());
this.jTextFieldHelpText.setText(vid.getEvents(intSelectedItemId).getHelp());
jTextFieldFeatureFlag.setText(vid.getEvents(intSelectedItemId).getFeatureFlag());
iCheckBoxListArch.setAllItemsUnchecked();
iCheckBoxListArch.initCheckedItem(true, vid.getEvents(intSelectedItemId).getSupArchList());
} else {
}
reloadListArea();
}
/**
Update list area pane via the elements of Vector
**/
private void reloadListArea() {
String strListItem = "";
for (int index = 0; index < vid.size(); index++) {
strListItem = strListItem + vid.getEvents(index).getName() + DataType.UNIX_LINE_SEPARATOR;
}
this.jTextAreaList.setText(strListItem);
}
/* (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.getSource() == this.jComboBoxList && arg0.getStateChange() == ItemEvent.SELECTED) {
reloadFromList();
}
}
}

View File

@@ -0,0 +1,894 @@
/** @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.frameworkwizard.module.ui;
import java.awt.event.ActionEvent;
import java.awt.event.ComponentEvent;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.util.Vector;
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.ExternsDocument;
import org.tianocore.PcdDriverTypes;
import org.tianocore.ExternsDocument.Externs;
import org.tianocore.ExternsDocument.Externs.Extern;
import org.tianocore.ModuleSurfaceAreaDocument.ModuleSurfaceArea;
import org.tianocore.frameworkwizard.common.DataType;
import org.tianocore.frameworkwizard.common.DataValidation;
import org.tianocore.frameworkwizard.common.EnumerationData;
import org.tianocore.frameworkwizard.common.Log;
import org.tianocore.frameworkwizard.common.OpeningModuleType;
import org.tianocore.frameworkwizard.common.Tools;
import org.tianocore.frameworkwizard.common.ui.IInternalFrame;
import org.tianocore.frameworkwizard.common.ui.iCheckBoxList.ICheckBoxList;
import org.tianocore.frameworkwizard.module.Identification.Externs.ExternsIdentification;
import org.tianocore.frameworkwizard.module.Identification.Externs.ExternsVector;
/**
The class is used to create, update DataHub of MSA/MBD file
It extends IInternalFrame
**/
public class ModuleExterns extends IInternalFrame implements ItemListener {
///
/// Define class Serial Version UID
///
private static final long serialVersionUID = -7382008402932047191L;
//
//Define class members
//
private JPanel jContentPane = null;
private JLabel jLabelName = null;
private JComboBox jComboBoxType = null;
private JTextArea jTextAreaList = null;
private JComboBox jComboBoxList = null;
private JButton jButtonAdd = null;
private JButton jButtonRemove = null;
private JButton jButtonUpdate = null;
private JScrollPane jScrollPane = null;
private JScrollPane jScrollPaneList = null;
private JLabel jLabelPcdIsDriver = null;
private JComboBox jComboBoxPcdIsDriver = null;
private JLabel jLabelC_Name = null;
private JTextField jTextFieldC_Name = null;
private JLabel jLabelFeatureFlag = null;
private JLabel jLabelArch = null;
private JTextField jTextFieldFeatureFlag = null;
private ICheckBoxList iCheckBoxListArch = null;
private JScrollPane jScrollPaneArch = null;
//
// Not used by UI
//
private int intSelectedItemId = 0;
private OpeningModuleType omt = null;
private ModuleSurfaceArea msa = null;
private ExternsDocument.Externs externs = null;
private ExternsIdentification id = null;
private ExternsVector vid = new ExternsVector();
private EnumerationData ed = new EnumerationData();
/**
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, 35, 320, 20));
jComboBoxType.setPreferredSize(new java.awt.Dimension(320, 20));
}
return jComboBoxType;
}
/**
This method initializes jComboBoxFileList
@return javax.swing.JComboBox jComboBoxFileList
**/
private JComboBox getJComboBoxList() {
if (jComboBoxList == null) {
jComboBoxList = new JComboBox();
jComboBoxList.setBounds(new java.awt.Rectangle(15, 195, 210, 20));
jComboBoxList.addItemListener(this);
jComboBoxList.addActionListener(this);
jComboBoxList.setPreferredSize(new java.awt.Dimension(210, 20));
}
return jComboBoxList;
}
/**
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, 195, 80, 20));
jButtonAdd.setText("Add");
jButtonAdd.addActionListener(this);
jButtonAdd.setPreferredSize(new java.awt.Dimension(80, 20));
}
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, 195, 80, 20));
jButtonRemove.setText("Remove");
jButtonRemove.addActionListener(this);
jButtonRemove.setPreferredSize(new java.awt.Dimension(80, 20));
}
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, 195, 80, 20));
jButtonUpdate.setPreferredSize(new java.awt.Dimension(80, 20));
jButtonUpdate.setText("Update");
jButtonUpdate.addActionListener(this);
}
return jButtonUpdate;
}
/**
* This method initializes jScrollPaneFileList
*
* @return javax.swing.JScrollPane
*/
private JScrollPane getJScrollPaneList() {
if (jScrollPaneList == null) {
jScrollPaneList = new JScrollPane();
jScrollPaneList.setBounds(new java.awt.Rectangle(15, 220, 465, 240));
jScrollPaneList.setViewportView(getJTextAreaList());
jScrollPaneList.setPreferredSize(new java.awt.Dimension(465, 240));
}
return jScrollPaneList;
}
/**
This method initializes jScrollPane
@return javax.swing.JScrollPane
*/
private JScrollPane getJScrollPane() {
if (jScrollPane == null) {
jScrollPane = new JScrollPane();
jScrollPane.setViewportView(getJContentPane());
}
return jScrollPane;
}
/**
* This method initializes jTextAreaFileList
*
* @return javax.swing.JTextArea
*/
private JTextArea getJTextAreaList() {
if (jTextAreaList == null) {
jTextAreaList = new JTextArea();
jTextAreaList.setEditable(false);
}
return jTextAreaList;
}
/**
* This method initializes jComboBoxPcdIsDriver
*
* @return javax.swing.JComboBox
*/
private JComboBox getJComboBoxPcdIsDriver() {
if (jComboBoxPcdIsDriver == null) {
jComboBoxPcdIsDriver = new JComboBox();
jComboBoxPcdIsDriver.setLocation(new java.awt.Point(160, 10));
jComboBoxPcdIsDriver.setPreferredSize(new java.awt.Dimension(320, 20));
jComboBoxPcdIsDriver.setSize(new java.awt.Dimension(320, 20));
jComboBoxPcdIsDriver.addItemListener(this);
}
return jComboBoxPcdIsDriver;
}
/**
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));
jTextFieldC_Name.setPreferredSize(new java.awt.Dimension(320,20));
}
return jTextFieldC_Name;
}
/**
This method initializes jTextFieldFeatureFlag
@return javax.swing.JTextField
**/
private JTextField getJTextFieldFeatureFlag() {
if (jTextFieldFeatureFlag == null) {
jTextFieldFeatureFlag = new JTextField();
jTextFieldFeatureFlag.setBounds(new java.awt.Rectangle(160, 85, 320, 20));
jTextFieldFeatureFlag.setPreferredSize(new java.awt.Dimension(320, 20));
}
return jTextFieldFeatureFlag;
}
/**
This method initializes iCheckBoxListArch
@return ICheckBoxList
**/
private ICheckBoxList getICheckBoxListSupportedArchitectures() {
if (iCheckBoxListArch == null) {
iCheckBoxListArch = new ICheckBoxList();
iCheckBoxListArch.addFocusListener(this);
iCheckBoxListArch.setToolTipText(DataType.SUP_ARCH_LIST_HELP_TEXT);
}
return iCheckBoxListArch;
}
/**
This method initializes jScrollPaneArch
@return javax.swing.JScrollPane
**/
private JScrollPane getJScrollPaneArch() {
if (jScrollPaneArch == null) {
jScrollPaneArch = new JScrollPane();
jScrollPaneArch.setBounds(new java.awt.Rectangle(160, 110, 320, 80));
jScrollPaneArch.setPreferredSize(new java.awt.Dimension(320, 80));
jScrollPaneArch.setViewportView(getICheckBoxListSupportedArchitectures());
}
return jScrollPaneArch;
}
public static void main(String[] args) {
}
/**
This method initializes this
**/
private void init() {
this.setSize(500, 515);
this.setContentPane(getJScrollPane());
this.setTitle("Externs");
initFrame();
}
/**
This method initializes this
Fill values to all fields if these values are not empty
@param inPackageDependencies
**/
private void init(Externs inExterns) {
init();
this.externs = inExterns;
if (this.externs != null) {
//
// Get PcdIsDriver
//
if (this.externs.getPcdIsDriver() != null) {
this.jComboBoxPcdIsDriver.setSelectedItem(this.externs.getPcdIsDriver().toString());
}
//
// Get specification
//
if (this.externs.getSpecificationList().size() > 0) {
for (int index = 0; index < this.externs.getSpecificationList().size(); index++) {
String arg0 = externs.getSpecificationList().get(index);
String arg1 = EnumerationData.EXTERNS_SPECIFICATION;
id = new ExternsIdentification(arg0, arg1, null, null);
vid.addExterns(id);
}
}
//
// Get Externs list
//
if (this.externs.getExternList().size() > 0) {
for (int index = 0; index < this.externs.getExternList().size(); index++) {
String arg0 = null;
String arg1 = null;
if (this.externs.getExternList().get(index).getModuleEntryPoint() != null) {
arg0 = this.externs.getExternList().get(index).getModuleEntryPoint();
arg1 = EnumerationData.EXTERNS_MODULE_ENTRY_POINT;
}
if (this.externs.getExternList().get(index).getModuleUnloadImage() != null) {
arg0 = this.externs.getExternList().get(index).getModuleUnloadImage();
arg1 = EnumerationData.EXTERNS_MODULE_UNLOAD_IMAGE;
}
if (this.externs.getExternList().get(index).getConstructor() != null) {
arg0 = this.externs.getExternList().get(index).getConstructor();
arg1 = EnumerationData.EXTERNS_CONSTRUCTOR;
}
if (this.externs.getExternList().get(index).getDestructor() != null) {
arg0 = this.externs.getExternList().get(index).getDestructor();
arg1 = EnumerationData.EXTERNS_DESTRUCTOR;
}
if (this.externs.getExternList().get(index).getDriverBinding() != null) {
arg0 = this.externs.getExternList().get(index).getDriverBinding();
arg1 = EnumerationData.EXTERNS_DRIVER_BINDING;
}
if (this.externs.getExternList().get(index).getComponentName() != null) {
arg0 = this.externs.getExternList().get(index).getComponentName();
arg1 = EnumerationData.EXTERNS_COMPONENT_NAME;
}
if (this.externs.getExternList().get(index).getDriverConfig() != null) {
arg0 = this.externs.getExternList().get(index).getDriverConfig();
arg1 = EnumerationData.EXTERNS_DRIVER_CONFIG;
}
if (this.externs.getExternList().get(index).getDriverDiag() != null) {
arg0 = this.externs.getExternList().get(index).getDriverDiag();
arg1 = EnumerationData.EXTERNS_DRIVER_DIAG;
}
if (this.externs.getExternList().get(index).getSetVirtualAddressMapCallBack() != null) {
arg0 = this.externs.getExternList().get(index).getSetVirtualAddressMapCallBack();
arg1 = EnumerationData.EXTERNS_SET_VIRTUAL_ADDRESS_MAP_CALL_BACK;
}
if (this.externs.getExternList().get(index).getExitBootServicesCallBack() != null) {
arg0 = this.externs.getExternList().get(index).getExitBootServicesCallBack();
arg1 = EnumerationData.EXTERNS_EXIT_BOOT_SERVICES_CALL_BACK;
}
String arg2 = externs.getExternList().get(index).getFeatureFlag();
Vector<String> arg3 = Tools
.convertListToVector(externs.getExternList().get(index).getSupArchList());
id = new ExternsIdentification(arg0, arg1, arg2, arg3);
vid.addExterns(id);
}
}
}
//
// Update the list
//
Tools.generateComboBoxByVector(jComboBoxList, vid.getExternsName());
reloadListArea();
}
/**
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(OpeningModuleType inOmt) {
super();
this.omt = inOmt;
this.msa = omt.getXmlMsa();
init(msa.getExterns());
this.setVisible(true);
}
/**
This method initializes jContentPane
@return javax.swing.JPanel jContentPane
**/
private JPanel getJContentPane() {
if (jContentPane == null) {
jLabelC_Name = new JLabel();
jLabelC_Name.setBounds(new java.awt.Rectangle(15, 60, 140, 20));
jLabelC_Name.setText("Value");
jLabelPcdIsDriver = new JLabel();
jLabelPcdIsDriver.setBounds(new java.awt.Rectangle(15, 10, 140, 20));
jLabelPcdIsDriver.setText("Pcd Is Driver");
jLabelName = new JLabel();
jLabelName.setText("Choose Type");
jLabelName.setBounds(new java.awt.Rectangle(15, 35, 140, 20));
jLabelArch = new JLabel();
jLabelArch.setBounds(new java.awt.Rectangle(15, 110, 140, 20));
jLabelArch.setText("Arch");
jLabelFeatureFlag = new JLabel();
jLabelFeatureFlag.setBounds(new java.awt.Rectangle(15, 85, 140, 20));
jLabelFeatureFlag.setText("Feature Flag");
jContentPane = new JPanel();
jContentPane.setLayout(null);
jContentPane.setPreferredSize(new java.awt.Dimension(490, 475));
jContentPane.add(jLabelName, null);
jContentPane.add(getJComboBoxType(), null);
jContentPane.add(jLabelFeatureFlag, null);
jContentPane.add(jLabelArch, null);
jContentPane.add(getJTextFieldFeatureFlag(), null);
jContentPane.add(getJScrollPaneArch(), null);
jContentPane.add(getJComboBoxList(), null);
jContentPane.add(getJButtonAdd(), null);
jContentPane.add(getJButtonRemove(), null);
jContentPane.add(getJButtonUpdate(), null);
jContentPane.add(getJScrollPaneList(), null);
jContentPane.add(jLabelPcdIsDriver, null);
jContentPane.add(getJComboBoxPcdIsDriver(), null);
jContentPane.add(jLabelC_Name, null);
jContentPane.add(getJTextFieldC_Name(), null);
}
return jContentPane;
}
/**
This method initializes Usage type and Externs type
**/
private void initFrame() {
Tools.generateComboBoxByVector(this.jComboBoxType, ed.getVExternTypes());
Tools.generateComboBoxByVector(this.jComboBoxPcdIsDriver, ed.getVPcdDriverTypes());
this.iCheckBoxListArch.setAllItems(ed.getVSupportedArchitectures());
}
/* (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() == jButtonAdd) {
if (!checkAdd()) {
return;
}
addToList();
}
if (arg0.getSource() == jButtonRemove) {
removeFromList();
}
if (arg0.getSource() == jButtonUpdate) {
if (!checkAdd()) {
return;
}
updateForList();
}
}
/**
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 fields have correct data types
//
//
// Check CName
//
if (isEmpty(this.jTextFieldC_Name.getText())) {
Log.err("Value couldn't be empty");
return false;
}
if (!isEmpty(this.jTextFieldC_Name.getText())) {
if (this.jComboBoxType.getSelectedItem().toString().equals(EnumerationData.EXTERNS_SPECIFICATION)) {
if (!DataValidation.isSentence(this.jTextFieldC_Name.getText())) {
Log.err("Incorrect data type for Specification");
return false;
}
} else {
if (!DataValidation.isC_NameType(this.jTextFieldC_Name.getText())) {
Log.err("Incorrect data type for C_Name");
return false;
}
}
}
//
// Check FeatureFlag
//
if (!isEmpty(this.jTextFieldFeatureFlag.getText())) {
if (!DataValidation.isFeatureFlag(this.jTextFieldFeatureFlag.getText())) {
Log.err("Incorrect data type for Feature Flag");
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 {
int count = this.vid.size();
this.externs = Externs.Factory.newInstance();
//
// Save PcdIsDriver first
//
if (!this.jComboBoxPcdIsDriver.getSelectedItem().toString().equals(DataType.EMPTY_SELECT_ITEM)) {
externs.setPcdIsDriver(PcdDriverTypes.Enum.forString(this.jComboBoxPcdIsDriver.getSelectedItem()
.toString()));
}
if (count > 0) {
for (int index = 0; index < count; index++) {
//
// Save specfication
//
if (vid.getExterns(index).getType().equals(EnumerationData.EXTERNS_SPECIFICATION)) {
if (!isEmpty(vid.getExterns(index).getName())) {
this.externs.addNewSpecification();
this.externs.setSpecificationArray(externs.getSpecificationList().size() - 1,
vid.getExterns(index).getName());
}
} else {
//
// Save extern
//
Extern e = Extern.Factory.newInstance();
if (vid.getExterns(index).getType().equals(EnumerationData.EXTERNS_MODULE_ENTRY_POINT)) {
if (!isEmpty(vid.getExterns(index).getName())) {
e.setModuleEntryPoint(vid.getExterns(index).getName());
}
}
if (vid.getExterns(index).getType().equals(EnumerationData.EXTERNS_MODULE_UNLOAD_IMAGE)) {
if (!isEmpty(vid.getExterns(index).getName())) {
e.setModuleUnloadImage(vid.getExterns(index).getName());
}
}
if (vid.getExterns(index).getType().equals(EnumerationData.EXTERNS_CONSTRUCTOR)) {
if (!isEmpty(vid.getExterns(index).getName())) {
e.setConstructor(vid.getExterns(index).getName());
}
}
if (vid.getExterns(index).getType().equals(EnumerationData.EXTERNS_DESTRUCTOR)) {
if (!isEmpty(vid.getExterns(index).getName())) {
e.setDestructor(vid.getExterns(index).getName());
}
}
if (vid.getExterns(index).getType().equals(EnumerationData.EXTERNS_DRIVER_BINDING)) {
if (!isEmpty(vid.getExterns(index).getName())) {
e.setDriverBinding(vid.getExterns(index).getName());
}
}
if (vid.getExterns(index).getType().equals(EnumerationData.EXTERNS_COMPONENT_NAME)) {
if (!isEmpty(vid.getExterns(index).getName())) {
e.setComponentName(vid.getExterns(index).getName());
}
}
if (vid.getExterns(index).getType().equals(EnumerationData.EXTERNS_DRIVER_CONFIG)) {
if (!isEmpty(vid.getExterns(index).getName())) {
e.setDriverConfig(vid.getExterns(index).getName());
}
}
if (vid.getExterns(index).getType().equals(EnumerationData.EXTERNS_DRIVER_DIAG)) {
if (!isEmpty(vid.getExterns(index).getName())) {
e.setDriverDiag(vid.getExterns(index).getName());
}
}
if (vid.getExterns(index).getType()
.equals(EnumerationData.EXTERNS_SET_VIRTUAL_ADDRESS_MAP_CALL_BACK)) {
if (!isEmpty(vid.getExterns(index).getName())) {
e.setSetVirtualAddressMapCallBack(vid.getExterns(index).getName());
}
}
if (vid.getExterns(index).getType()
.equals(EnumerationData.EXTERNS_EXIT_BOOT_SERVICES_CALL_BACK)) {
if (!isEmpty(vid.getExterns(index).getName())) {
e.setExitBootServicesCallBack(vid.getExterns(index).getName());
}
}
if (!isEmpty(vid.getExterns(index).getFeatureFlag())) {
e.setFeatureFlag(vid.getExterns(index).getFeatureFlag());
}
if (vid.getExterns(index).getSupArchList() != null
&& vid.getExterns(index).getSupArchList().size() > 0) {
e.setSupArchList(vid.getExterns(index).getSupArchList());
}
this.externs.addNewExtern();
this.externs.setExternArray(this.externs.getExternList().size() - 1, e);
}
}
}
this.msa.setExterns(externs);
this.omt.setSaved(false);
} catch (Exception e) {
Log.err("Update Externs", e.getMessage());
}
}
/* (non-Javadoc)
* @see java.awt.event.ComponentListener#componentResized(java.awt.event.ComponentEvent)
*
* Override componentResized to resize all components when frame's size is changed
*/
public void componentResized(ComponentEvent arg0) {
int intCurrentWidth = this.getJContentPane().getWidth();
int intCurrentHeight = this.getJContentPane().getHeight();
int intPreferredWidth = this.getJContentPane().getPreferredSize().width;
int intPreferredHeight = this.getJContentPane().getPreferredSize().height;
resizeComponentWidth(this.jComboBoxPcdIsDriver, intCurrentWidth, intPreferredWidth);
resizeComponentWidth(this.jComboBoxType, intCurrentWidth, intPreferredWidth);
resizeComponentWidth(this.jTextFieldC_Name, intCurrentWidth, intPreferredWidth);
resizeComponentWidth(this.jTextFieldFeatureFlag, intCurrentWidth, intPreferredWidth);
resizeComponentWidth(this.jScrollPaneArch, intCurrentWidth, intPreferredWidth);
resizeComponentWidth(jComboBoxList, intCurrentWidth, intPreferredWidth);
resizeComponent(jScrollPaneList, intCurrentWidth, intCurrentHeight, intPreferredWidth, intPreferredHeight);
relocateComponentX(jButtonAdd, intCurrentWidth, intPreferredWidth, DataType.SPACE_TO_RIGHT_FOR_ADD_BUTTON);
relocateComponentX(jButtonRemove, intCurrentWidth, intPreferredWidth, DataType.SPACE_TO_RIGHT_FOR_REMOVE_BUTTON);
relocateComponentX(jButtonUpdate, intCurrentWidth, intPreferredWidth, DataType.SPACE_TO_RIGHT_FOR_UPDATE_BUTTON);
}
private ExternsIdentification getCurrentExterns() {
String arg0 = this.jTextFieldC_Name.getText();
String arg1 = this.jComboBoxType.getSelectedItem().toString();
String arg2 = this.jTextFieldFeatureFlag.getText();
Vector<String> arg3 = this.iCheckBoxListArch.getAllCheckedItemsString();
id = new ExternsIdentification(arg0, arg1, arg2, arg3);
return id;
}
/**
Add current item to Vector
**/
private void addToList() {
intSelectedItemId = vid.size();
vid.addExterns(getCurrentExterns());
jComboBoxList.addItem(id.getName());
jComboBoxList.setSelectedItem(id.getName());
//
// Reset select item index
//
intSelectedItemId = vid.size();
//
// Reload all fields of selected item
//
reloadFromList();
//
// Save to memory
//
save();
}
/**
Remove current item from Vector
**/
private void removeFromList() {
//
// Check if exist items
//
if (this.vid.size() < 1) {
return;
}
int intTempIndex = intSelectedItemId;
jComboBoxList.removeItemAt(intSelectedItemId);
vid.removeExterns(intTempIndex);
//
// Reload all fields of selected item
//
reloadFromList();
//
// Save to memory
//
save();
}
/**
Update current item of Vector
**/
private void updateForList() {
//
// Check if exist items
//
if (this.vid.size() < 1) {
return;
}
//
// Backup selected item index
//
int intTempIndex = intSelectedItemId;
vid.updateExterns(getCurrentExterns(), intTempIndex);
jComboBoxList.removeAllItems();
for (int index = 0; index < vid.size(); index++) {
jComboBoxList.addItem(vid.getExterns(index).getName());
}
//
// Restore selected item index
//
intSelectedItemId = intTempIndex;
//
// Reset select item index
//
jComboBoxList.setSelectedIndex(intSelectedItemId);
//
// Reload all fields of selected item
//
reloadFromList();
//
// Save to memory
//
save();
}
/**
Refresh all fields' values of selected item of Vector
**/
private void reloadFromList() {
if (vid.size() > 0) {
//
// Get selected item index
//
intSelectedItemId = jComboBoxList.getSelectedIndex();
this.jTextFieldC_Name.setText(vid.getExterns(intSelectedItemId).getName());
this.jComboBoxType.setSelectedItem(vid.getExterns(intSelectedItemId).getType());
jTextFieldFeatureFlag.setText(vid.getExterns(intSelectedItemId).getFeatureFlag());
iCheckBoxListArch.setAllItemsUnchecked();
iCheckBoxListArch.initCheckedItem(true, vid.getExterns(intSelectedItemId).getSupArchList());
} else {
}
reloadListArea();
}
/**
Update list area pane via the elements of Vector
**/
private void reloadListArea() {
String strListItem = "";
for (int index = 0; index < vid.size(); index++) {
strListItem = strListItem + vid.getExterns(index).getName() + DataType.UNIX_LINE_SEPARATOR;
}
this.jTextAreaList.setText(strListItem);
}
/* (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.getSource() == this.jComboBoxList && arg0.getStateChange() == ItemEvent.SELECTED) {
reloadFromList();
}
if (arg0.getSource() == this.jComboBoxPcdIsDriver && arg0.getStateChange() == ItemEvent.SELECTED && externs != null) {
String s = this.jComboBoxPcdIsDriver.getSelectedItem().toString();
if (s.equals(DataType.EMPTY_SELECT_ITEM)) {
this.externs.setPcdIsDriver(null);
} else {
this.externs.setPcdIsDriver(PcdDriverTypes.Enum.forString(s));
}
this.msa.setExterns(externs);
this.omt.setSaved(false);
}
}
}

View File

@@ -0,0 +1,771 @@
/** @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.frameworkwizard.module.ui;
import java.awt.event.ActionEvent;
import java.awt.event.ComponentEvent;
import java.awt.event.ItemEvent;
import java.util.Vector;
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.GuidUsage;
import org.tianocore.GuidsDocument;
import org.tianocore.GuidsDocument.Guids;
import org.tianocore.GuidsDocument.Guids.GuidCNames;
import org.tianocore.ModuleSurfaceAreaDocument.ModuleSurfaceArea;
import org.tianocore.frameworkwizard.common.DataType;
import org.tianocore.frameworkwizard.common.DataValidation;
import org.tianocore.frameworkwizard.common.EnumerationData;
import org.tianocore.frameworkwizard.common.Log;
import org.tianocore.frameworkwizard.common.OpeningModuleType;
import org.tianocore.frameworkwizard.common.Tools;
import org.tianocore.frameworkwizard.common.ui.IInternalFrame;
import org.tianocore.frameworkwizard.common.ui.StarLabel;
import org.tianocore.frameworkwizard.common.ui.iCheckBoxList.ICheckBoxList;
import org.tianocore.frameworkwizard.module.Identification.Guids.GuidsIdentification;
import org.tianocore.frameworkwizard.module.Identification.Guids.GuidsVector;
import org.tianocore.frameworkwizard.workspace.WorkspaceTools;
/**
The class is used to create, update Guids of MSA/MBD file
It extends IInternalFrame
**/
public class ModuleGuids extends IInternalFrame {
///
/// Define class Serial Version UID
///
private static final long serialVersionUID = 6710858997766979803L;
//
//Define class members
//
private JPanel jContentPane = null;
private JLabel jLabelC_Name = null;
private JComboBox jComboBoxCName = null;
private JLabel jLabelUsage = null;
private JComboBox jComboBoxUsage = null;
private StarLabel jStarLabel1 = null;
private StarLabel jStarLabel2 = null;
private JLabel jLabelFeatureFlag = null;
private JTextField jTextFieldFeatureFlag = null;
private JLabel jLabelArch = null;
private JTextArea jTextAreaList = null;
private JComboBox jComboBoxList = null;
private JButton jButtonAdd = null;
private JButton jButtonRemove = null;
private JButton jButtonUpdate = null;
private JScrollPane jScrollPane = null;
private JScrollPane jScrollPaneList = null;
private ICheckBoxList iCheckBoxListArch = null;
private JScrollPane jScrollPaneArch = null;
private JLabel jLabelHelpText = null;
private JTextField jTextFieldHelpText = null;
//
// Not used by UI
//
private int intSelectedItemId = 0;
private OpeningModuleType omt = null;
private ModuleSurfaceArea msa = null;
private GuidsDocument.Guids guids = null;
private GuidsIdentification id = null;
private GuidsVector vid = new GuidsVector();
private EnumerationData ed = new EnumerationData();
private WorkspaceTools wt = new WorkspaceTools();
/**
This method initializes jTextFieldC_Name
@return javax.swing.JTextField jTextFieldC_Name
**/
private JComboBox getJComboBoxCName() {
if (jComboBoxCName == null) {
jComboBoxCName = new JComboBox();
jComboBoxCName.setBounds(new java.awt.Rectangle(160, 10, 320, 20));
jComboBoxCName.setPreferredSize(new java.awt.Dimension(320, 20));
}
return jComboBoxCName;
}
/**
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));
jComboBoxUsage.setPreferredSize(new java.awt.Dimension(320, 20));
}
return jComboBoxUsage;
}
/**
This method initializes jTextFieldFeatureFlag
@return javax.swing.JTextField
**/
private JTextField getJTextFieldFeatureFlag() {
if (jTextFieldFeatureFlag == null) {
jTextFieldFeatureFlag = new JTextField();
jTextFieldFeatureFlag.setBounds(new java.awt.Rectangle(160, 85, 320, 20));
jTextFieldFeatureFlag.setPreferredSize(new java.awt.Dimension(320, 20));
}
return jTextFieldFeatureFlag;
}
/**
This method initializes jComboBoxFileList
@return javax.swing.JComboBox jComboBoxFileList
**/
private JComboBox getJComboBoxList() {
if (jComboBoxList == null) {
jComboBoxList = new JComboBox();
jComboBoxList.setBounds(new java.awt.Rectangle(15, 195, 210, 20));
jComboBoxList.addItemListener(this);
jComboBoxList.addActionListener(this);
jComboBoxList.setPreferredSize(new java.awt.Dimension(210, 20));
}
return jComboBoxList;
}
/**
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, 195, 80, 20));
jButtonAdd.setText("Add");
jButtonAdd.addActionListener(this);
jButtonAdd.setPreferredSize(new java.awt.Dimension(80, 20));
}
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, 195, 80, 20));
jButtonRemove.setText("Remove");
jButtonRemove.addActionListener(this);
jButtonRemove.setPreferredSize(new java.awt.Dimension(80, 20));
}
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, 195, 80, 20));
jButtonUpdate.setPreferredSize(new java.awt.Dimension(80, 20));
jButtonUpdate.setText("Update");
jButtonUpdate.addActionListener(this);
}
return jButtonUpdate;
}
/**
* This method initializes jScrollPaneFileList
*
* @return javax.swing.JScrollPane
*/
private JScrollPane getJScrollPaneList() {
if (jScrollPaneList == null) {
jScrollPaneList = new JScrollPane();
jScrollPaneList.setBounds(new java.awt.Rectangle(15, 220, 465, 240));
jScrollPaneList.setViewportView(getJTextAreaList());
jScrollPaneList.setPreferredSize(new java.awt.Dimension(465, 240));
}
return jScrollPaneList;
}
/**
This method initializes jScrollPane
@return javax.swing.JScrollPane
*/
private JScrollPane getJScrollPane() {
if (jScrollPane == null) {
jScrollPane = new JScrollPane();
jScrollPane.setViewportView(getJContentPane());
}
return jScrollPane;
}
/**
* This method initializes jTextAreaFileList
*
* @return javax.swing.JTextArea
*/
private JTextArea getJTextAreaList() {
if (jTextAreaList == null) {
jTextAreaList = new JTextArea();
jTextAreaList.setEditable(false);
}
return jTextAreaList;
}
/**
This method initializes iCheckBoxListArch
@return ICheckBoxList
**/
private ICheckBoxList getICheckBoxListSupportedArchitectures() {
if (iCheckBoxListArch == null) {
iCheckBoxListArch = new ICheckBoxList();
iCheckBoxListArch.addFocusListener(this);
iCheckBoxListArch.setToolTipText(DataType.SUP_ARCH_LIST_HELP_TEXT);
}
return iCheckBoxListArch;
}
/**
This method initializes jScrollPaneArch
@return javax.swing.JScrollPane
**/
private JScrollPane getJScrollPaneArch() {
if (jScrollPaneArch == null) {
jScrollPaneArch = new JScrollPane();
jScrollPaneArch.setBounds(new java.awt.Rectangle(160, 110, 320, 80));
jScrollPaneArch.setPreferredSize(new java.awt.Dimension(320, 80));
jScrollPaneArch.setViewportView(getICheckBoxListSupportedArchitectures());
}
return jScrollPaneArch;
}
/**
This method initializes jTextFieldHelpText
@return javax.swing.JTextField
**/
private JTextField getJTextFieldHelpText() {
if (jTextFieldHelpText == null) {
jTextFieldHelpText = new JTextField();
jTextFieldHelpText.setBounds(new java.awt.Rectangle(160, 60, 320, 20));
jTextFieldHelpText.setPreferredSize(new java.awt.Dimension(320, 20));
}
return jTextFieldHelpText;
}
public static void main(String[] args) {
}
/**
This method initializes this
**/
private void init() {
this.setSize(500, 515);
this.setContentPane(getJScrollPane());
this.setTitle("Guids");
initFrame();
this.setViewMode(false);
}
/**
This method initializes this
Fill values to all fields if these values are not empty
@param inPackageDependencies
**/
private void init(Guids inGuids) {
init();
this.guids = inGuids;
if (this.guids != null) {
if (this.guids.getGuidCNamesList().size() > 0) {
for (int index = 0; index < this.guids.getGuidCNamesList().size(); index++) {
String arg0 = guids.getGuidCNamesList().get(index).getGuidCName();
String arg1 = null;
if (guids.getGuidCNamesList().get(index).getUsage() != null) {
arg1 = guids.getGuidCNamesList().get(index).getUsage().toString();
}
String arg2 = guids.getGuidCNamesList().get(index).getFeatureFlag();
Vector<String> arg3 = Tools.convertListToVector(guids.getGuidCNamesList().get(index)
.getSupArchList());
String arg4 = guids.getGuidCNamesList().get(index).getHelpText();
id = new GuidsIdentification(arg0, arg1, arg2, arg3, arg4);
vid.addGuids(id);
}
}
}
//
// Update the list
//
Tools.generateComboBoxByVector(jComboBoxList, vid.getGuidsName());
reloadListArea();
}
/**
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(OpeningModuleType inOmt) {
super();
this.omt = inOmt;
this.msa = omt.getXmlMsa();
init(msa.getGuids());
this.setVisible(true);
}
/**
Disable all components when the mode is view
@param isView true - The view mode; false - The non-view mode
**/
public void setViewMode(boolean isView) {
if (isView) {
this.jComboBoxUsage.setEnabled(!isView);
}
}
/**
This method initializes jContentPane
@return javax.swing.JPanel jContentPane
**/
private JPanel getJContentPane() {
if (jContentPane == null) {
jLabelUsage = new JLabel();
jLabelUsage.setText("Usage");
jLabelUsage.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));
jLabelArch = new JLabel();
jLabelArch.setBounds(new java.awt.Rectangle(15, 110, 140, 20));
jLabelArch.setText("Arch");
jLabelFeatureFlag = new JLabel();
jLabelFeatureFlag.setBounds(new java.awt.Rectangle(15, 85, 140, 20));
jLabelFeatureFlag.setText("Feature Flag");
jLabelHelpText = new JLabel();
jLabelHelpText.setBounds(new java.awt.Rectangle(14, 60, 140, 20));
jLabelHelpText.setText("Help Text");
jContentPane = new JPanel();
jContentPane.setLayout(null);
jContentPane.setPreferredSize(new java.awt.Dimension(490, 475));
jContentPane.add(jLabelC_Name, null);
jContentPane.add(getJComboBoxCName(), null);
jContentPane.add(jLabelUsage, null);
jContentPane.add(getJComboBoxUsage(), null);
jContentPane.add(jLabelFeatureFlag, null);
jContentPane.add(jLabelArch, null);
jContentPane.add(getJTextFieldFeatureFlag(), 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(getJComboBoxList(), null);
jContentPane.add(getJButtonAdd(), null);
jContentPane.add(getJButtonRemove(), null);
jContentPane.add(getJButtonUpdate(), null);
jContentPane.add(getJScrollPaneList(), null);
jContentPane.add(getJScrollPaneArch(), null);
jContentPane.add(jLabelHelpText, null);
jContentPane.add(getJTextFieldHelpText(), null);
initFrame();
}
return jContentPane;
}
/**
This method initializes Usage type
**/
private void initFrame() {
Tools.generateComboBoxByVector(jComboBoxCName, wt.getAllGuidDeclarationsFromWorkspace());
Tools.generateComboBoxByVector(jComboBoxUsage, ed.getVGuidUsage());
this.iCheckBoxListArch.setAllItems(ed.getVSupportedArchitectures());
}
/* (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() == jButtonAdd) {
if (!checkAdd()) {
return;
}
addToList();
}
if (arg0.getSource() == jButtonRemove) {
removeFromList();
}
if (arg0.getSource() == jButtonUpdate) {
if (!checkAdd()) {
return;
}
updateForList();
}
}
/**
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 fields have correct data types
//
//
// Check Name
//
if (!isEmpty(this.jComboBoxCName.getSelectedItem().toString())) {
if (!DataValidation.isC_NameType(this.jComboBoxCName.getSelectedItem().toString())) {
Log.err("Incorrect data type for Guid Name");
return false;
}
}
//
// Check FeatureFlag
//
if (!isEmpty(this.jTextFieldFeatureFlag.getText())) {
if (!DataValidation.isFeatureFlag(this.jTextFieldFeatureFlag.getText())) {
Log.err("Incorrect data type for Feature Flag");
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 {
int count = this.vid.size();
this.guids = Guids.Factory.newInstance();
if (count > 0) {
for (int index = 0; index < count; index++) {
GuidCNames p = GuidCNames.Factory.newInstance();
if (!isEmpty(vid.getGuids(index).getName())) {
p.setGuidCName(vid.getGuids(index).getName());
}
if (!isEmpty(vid.getGuids(index).getUsage())) {
p.setUsage(GuidUsage.Enum.forString(vid.getGuids(index).getUsage()));
}
if (!isEmpty(vid.getGuids(index).getFeatureFlag())) {
p.setFeatureFlag(vid.getGuids(index).getFeatureFlag());
}
if (vid.getGuids(index).getSupArchList() != null && vid.getGuids(index).getSupArchList().size() > 0) {
p.setSupArchList(vid.getGuids(index).getSupArchList());
}
if (!isEmpty(vid.getGuids(index).getHelp())) {
p.setHelpText(vid.getGuids(index).getHelp());
}
this.guids.addNewGuidCNames();
this.guids.setGuidCNamesArray(guids.getGuidCNamesList().size() - 1, p);
}
}
this.msa.setGuids(guids);
this.omt.setSaved(false);
} catch (Exception e) {
Log.err("Update Guids", e.getMessage());
}
}
/* (non-Javadoc)
* @see java.awt.event.ComponentListener#componentResized(java.awt.event.ComponentEvent)
*
* Override componentResized to resize all components when frame's size is changed
*/
public void componentResized(ComponentEvent arg0) {
int intCurrentWidth = this.getJContentPane().getWidth();
int intCurrentHeight = this.getJContentPane().getHeight();
int intPreferredWidth = this.getJContentPane().getPreferredSize().width;
int intPreferredHeight = this.getJContentPane().getPreferredSize().height;
resizeComponentWidth(jComboBoxCName, intCurrentWidth, intPreferredWidth);
resizeComponentWidth(jComboBoxUsage, intCurrentWidth, intPreferredWidth);
resizeComponentWidth(jTextFieldHelpText, intCurrentWidth, intPreferredWidth);
resizeComponentWidth(jTextFieldFeatureFlag, intCurrentWidth, intPreferredWidth);
resizeComponentWidth(jScrollPaneArch, intCurrentWidth, intPreferredWidth);
resizeComponentWidth(jComboBoxList, intCurrentWidth, intPreferredWidth);
resizeComponent(jScrollPaneList, intCurrentWidth, intCurrentHeight, intPreferredWidth, intPreferredHeight);
relocateComponentX(jButtonAdd, intCurrentWidth, intPreferredWidth, DataType.SPACE_TO_RIGHT_FOR_ADD_BUTTON);
relocateComponentX(jButtonRemove, intCurrentWidth, intPreferredWidth, DataType.SPACE_TO_RIGHT_FOR_REMOVE_BUTTON);
relocateComponentX(jButtonUpdate, intCurrentWidth, intPreferredWidth, DataType.SPACE_TO_RIGHT_FOR_UPDATE_BUTTON);
}
private GuidsIdentification getCurrentGuids() {
String arg0 = this.jComboBoxCName.getSelectedItem().toString();
String arg1 = this.jComboBoxUsage.getSelectedItem().toString();
String arg2 = this.jTextFieldFeatureFlag.getText();
Vector<String> arg3 = this.iCheckBoxListArch.getAllCheckedItemsString();
String arg4 = this.jTextFieldHelpText.getText();
id = new GuidsIdentification(arg0, arg1, arg2, arg3, arg4);
return id;
}
/**
Add current item to Vector
**/
private void addToList() {
intSelectedItemId = vid.size();
vid.addGuids(getCurrentGuids());
jComboBoxList.addItem(id.getName());
jComboBoxList.setSelectedItem(id.getName());
//
// Reset select item index
//
intSelectedItemId = vid.size();
//
// Reload all fields of selected item
//
reloadFromList();
//
// Save to memory
//
save();
}
/**
Remove current item from Vector
**/
private void removeFromList() {
//
// Check if exist items
//
if (this.vid.size() < 1) {
return;
}
int intTempIndex = intSelectedItemId;
jComboBoxList.removeItemAt(intSelectedItemId);
vid.removeGuids(intTempIndex);
//
// Reload all fields of selected item
//
reloadFromList();
//
// Save to memory
//
save();
}
/**
Update current item of Vector
**/
private void updateForList() {
//
// Check if exist items
//
if (this.vid.size() < 1) {
return;
}
//
// Backup selected item index
//
int intTempIndex = intSelectedItemId;
vid.updateGuids(getCurrentGuids(), intTempIndex);
jComboBoxList.removeAllItems();
for (int index = 0; index < vid.size(); index++) {
jComboBoxList.addItem(vid.getGuids(index).getName());
}
//
// Restore selected item index
//
intSelectedItemId = intTempIndex;
//
// Reset select item index
//
jComboBoxList.setSelectedIndex(intSelectedItemId);
//
// Reload all fields of selected item
//
reloadFromList();
//
// Save to memory
//
save();
}
/**
Refresh all fields' values of selected item of Vector
**/
private void reloadFromList() {
if (vid.size() > 0) {
//
// Get selected item index
//
intSelectedItemId = jComboBoxList.getSelectedIndex();
this.jComboBoxCName.setSelectedItem(vid.getGuids(intSelectedItemId).getName());
this.jComboBoxUsage.setSelectedItem(vid.getGuids(intSelectedItemId).getUsage());
this.jTextFieldHelpText.setText(vid.getGuids(intSelectedItemId).getHelp());
jTextFieldFeatureFlag.setText(vid.getGuids(intSelectedItemId).getFeatureFlag());
iCheckBoxListArch.setAllItemsUnchecked();
iCheckBoxListArch.initCheckedItem(true, vid.getGuids(intSelectedItemId).getSupArchList());
} else {
}
reloadListArea();
}
/**
Update list area pane via the elements of Vector
**/
private void reloadListArea() {
String strListItem = "";
for (int index = 0; index < vid.size(); index++) {
strListItem = strListItem + vid.getGuids(index).getName() + DataType.UNIX_LINE_SEPARATOR;
}
this.jTextAreaList.setText(strListItem);
}
/* (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.getSource() == this.jComboBoxList && arg0.getStateChange() == ItemEvent.SELECTED) {
reloadFromList();
}
}
}

View File

@@ -0,0 +1,774 @@
/** @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.frameworkwizard.module.ui;
import java.awt.event.ActionEvent;
import java.awt.event.ComponentEvent;
import java.awt.event.ItemEvent;
import java.util.Vector;
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.HiiPackageUsage;
import org.tianocore.HiiPackagesDocument;
import org.tianocore.HiiPackagesDocument.HiiPackages;
import org.tianocore.HiiPackagesDocument.HiiPackages.HiiPackage;
import org.tianocore.ModuleSurfaceAreaDocument.ModuleSurfaceArea;
import org.tianocore.frameworkwizard.common.DataType;
import org.tianocore.frameworkwizard.common.DataValidation;
import org.tianocore.frameworkwizard.common.EnumerationData;
import org.tianocore.frameworkwizard.common.Log;
import org.tianocore.frameworkwizard.common.OpeningModuleType;
import org.tianocore.frameworkwizard.common.Tools;
import org.tianocore.frameworkwizard.common.ui.IInternalFrame;
import org.tianocore.frameworkwizard.common.ui.StarLabel;
import org.tianocore.frameworkwizard.common.ui.iCheckBoxList.ICheckBoxList;
import org.tianocore.frameworkwizard.module.Identification.HiiPackages.HiiPackagesIdentification;
import org.tianocore.frameworkwizard.module.Identification.HiiPackages.HiiPackagesVector;
/**
The class is used to create, update Formset of MSA/MBD file
It extends IInternalFrame
**/
public class ModuleHiiPackages extends IInternalFrame {
///
/// Define class Serial Version UID
///
private static final long serialVersionUID = -6851574146786158116L;
//
//Define class members
//
private JPanel jContentPane = null;
private JLabel jLabelName = null;
private JTextField jTextFieldName = null;
private JLabel jLabelUsage = null;
private JComboBox jComboBoxUsage = null;
private StarLabel jStarLabel1 = null;
private StarLabel jStarLabel2 = null;
private JLabel jLabelFeatureFlag = null;
private JTextField jTextFieldFeatureFlag = null;
private JLabel jLabelArch = null;
private JTextArea jTextAreaList = null;
private JComboBox jComboBoxList = null;
private JButton jButtonAdd = null;
private JButton jButtonRemove = null;
private JButton jButtonUpdate = null;
private JScrollPane jScrollPane = null;
private JScrollPane jScrollPaneList = null;
private ICheckBoxList iCheckBoxListArch = null;
private JScrollPane jScrollPaneArch = null;
private JLabel jLabelHelpText = null;
private JTextField jTextFieldHelpText = null;
//
// Not used by UI
//
private int intSelectedItemId = 0;
private OpeningModuleType omt = null;
private ModuleSurfaceArea msa = null;
private HiiPackagesDocument.HiiPackages hiiPackages = null;
private HiiPackagesIdentification id = null;
private HiiPackagesVector vid = new HiiPackagesVector();
private EnumerationData ed = new EnumerationData();
/**
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));
jTextFieldName.setPreferredSize(new java.awt.Dimension(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, 35, 320, 20));
jComboBoxUsage.setPreferredSize(new java.awt.Dimension(320, 20));
}
return jComboBoxUsage;
}
/**
* This method initializes jTextFieldFeatureFlag
*
* @return javax.swing.JTextField
*/
private JTextField getJTextFieldFeatureFlag() {
if (jTextFieldFeatureFlag == null) {
jTextFieldFeatureFlag = new JTextField();
jTextFieldFeatureFlag.setBounds(new java.awt.Rectangle(160, 85, 320, 20));
jTextFieldFeatureFlag.setPreferredSize(new java.awt.Dimension(320, 20));
}
return jTextFieldFeatureFlag;
}
/**
This method initializes jComboBoxFileList
@return javax.swing.JComboBox jComboBoxFileList
**/
private JComboBox getJComboBoxList() {
if (jComboBoxList == null) {
jComboBoxList = new JComboBox();
jComboBoxList.setBounds(new java.awt.Rectangle(15, 195, 210, 20));
jComboBoxList.addItemListener(this);
jComboBoxList.addActionListener(this);
jComboBoxList.setPreferredSize(new java.awt.Dimension(210, 20));
}
return jComboBoxList;
}
/**
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, 195, 80, 20));
jButtonAdd.setText("Add");
jButtonAdd.addActionListener(this);
jButtonAdd.setPreferredSize(new java.awt.Dimension(80, 20));
}
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, 195, 80, 20));
jButtonRemove.setText("Remove");
jButtonRemove.addActionListener(this);
jButtonRemove.setPreferredSize(new java.awt.Dimension(80, 20));
}
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, 195, 80, 20));
jButtonUpdate.setPreferredSize(new java.awt.Dimension(80, 20));
jButtonUpdate.setText("Update");
jButtonUpdate.addActionListener(this);
}
return jButtonUpdate;
}
/**
* This method initializes jScrollPaneFileList
*
* @return javax.swing.JScrollPane
*/
private JScrollPane getJScrollPaneList() {
if (jScrollPaneList == null) {
jScrollPaneList = new JScrollPane();
jScrollPaneList.setBounds(new java.awt.Rectangle(15, 220, 465, 240));
jScrollPaneList.setViewportView(getJTextAreaList());
jScrollPaneList.setPreferredSize(new java.awt.Dimension(465, 240));
}
return jScrollPaneList;
}
/**
This method initializes jScrollPane
@return javax.swing.JScrollPane
*/
private JScrollPane getJScrollPane() {
if (jScrollPane == null) {
jScrollPane = new JScrollPane();
jScrollPane.setViewportView(getJContentPane());
}
return jScrollPane;
}
/**
* This method initializes jTextAreaFileList
*
* @return javax.swing.JTextArea
*/
private JTextArea getJTextAreaList() {
if (jTextAreaList == null) {
jTextAreaList = new JTextArea();
jTextAreaList.setEditable(false);
}
return jTextAreaList;
}
/**
This method initializes jTextFieldHelpText
@return javax.swing.JTextField
**/
private JTextField getJTextFieldHelpText() {
if (jTextFieldHelpText == null) {
jTextFieldHelpText = new JTextField();
jTextFieldHelpText.setBounds(new java.awt.Rectangle(160, 60, 320, 20));
jTextFieldHelpText.setPreferredSize(new java.awt.Dimension(320, 20));
}
return jTextFieldHelpText;
}
/**
This method initializes iCheckBoxListArch
@return ICheckBoxList
**/
private ICheckBoxList getICheckBoxListSupportedArchitectures() {
if (iCheckBoxListArch == null) {
iCheckBoxListArch = new ICheckBoxList();
iCheckBoxListArch.addFocusListener(this);
iCheckBoxListArch.setToolTipText(DataType.SUP_ARCH_LIST_HELP_TEXT);
}
return iCheckBoxListArch;
}
/**
This method initializes jScrollPaneArch
@return javax.swing.JScrollPane
**/
private JScrollPane getJScrollPaneArch() {
if (jScrollPaneArch == null) {
jScrollPaneArch = new JScrollPane();
jScrollPaneArch.setBounds(new java.awt.Rectangle(160, 110, 320, 80));
jScrollPaneArch.setPreferredSize(new java.awt.Dimension(320, 80));
jScrollPaneArch.setViewportView(getICheckBoxListSupportedArchitectures());
}
return jScrollPaneArch;
}
public static void main(String[] args) {
}
/**
This method initializes this
**/
private void init() {
this.setSize(500, 515);
this.setContentPane(getJScrollPane());
this.setTitle("Hii Packages");
initFrame();
this.setViewMode(false);
}
/**
This method initializes this
Fill values to all fields if these values are not empty
@param inPackageDependencies
**/
private void init(HiiPackages inHiiPackages) {
init();
this.hiiPackages = inHiiPackages;
if (this.hiiPackages != null) {
if (this.hiiPackages.getHiiPackageList().size() > 0) {
for (int index = 0; index < this.hiiPackages.getHiiPackageList().size(); index++) {
String arg0 = hiiPackages.getHiiPackageList().get(index).getHiiCName();
String arg1 = null;
if (hiiPackages.getHiiPackageList().get(index).getUsage() != null) {
arg1 = hiiPackages.getHiiPackageList().get(index).getUsage().toString();
}
String arg2 = hiiPackages.getHiiPackageList().get(index).getFeatureFlag();
Vector<String> arg3 = Tools.convertListToVector(hiiPackages.getHiiPackageList().get(index)
.getSupArchList());
String arg4 = hiiPackages.getHiiPackageList().get(index).getHelpText();
id = new HiiPackagesIdentification(arg0, arg1, arg2, arg3, arg4);
vid.addHiiPackages(id);
}
}
}
//
// Update the list
//
Tools.generateComboBoxByVector(jComboBoxList, vid.getHiiPackagesName());
reloadListArea();
}
/**
This is the default constructor
**/
public ModuleHiiPackages() {
super();
init();
this.setVisible(true);
}
/**
*
*/
/**
This is the override edit constructor
@param inFormsets The input data of HiiPackagesDocument.HiiPackages
**/
public ModuleHiiPackages(OpeningModuleType inOmt) {
super();
this.omt = inOmt;
this.msa = omt.getXmlMsa();
init(msa.getHiiPackages());
this.setVisible(true);
}
/**
Disable all components when the mode is view
@param isView true - The view mode; false - The non-view mode
**/
public void setViewMode(boolean isView) {
if (isView) {
this.jTextFieldName.setEnabled(!isView);
this.jComboBoxUsage.setEnabled(!isView);
}
}
/**
This method initializes jContentPane
@return javax.swing.JPanel jContentPane
**/
private JPanel getJContentPane() {
if (jContentPane == null) {
jLabelUsage = new JLabel();
jLabelUsage.setText("Usage");
jLabelUsage.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));
jLabelArch = new JLabel();
jLabelArch.setBounds(new java.awt.Rectangle(15, 110, 140, 20));
jLabelArch.setText("Arch");
jLabelFeatureFlag = new JLabel();
jLabelFeatureFlag.setBounds(new java.awt.Rectangle(15, 85, 140, 20));
jLabelFeatureFlag.setText("Feature Flag");
jLabelHelpText = new JLabel();
jLabelHelpText.setBounds(new java.awt.Rectangle(14, 60, 140, 20));
jLabelHelpText.setText("Help Text");
jContentPane = new JPanel();
jContentPane.setLayout(null);
jContentPane.setPreferredSize(new java.awt.Dimension(490, 475));
jContentPane.add(jLabelName, null);
jContentPane.add(jLabelUsage, null);
jContentPane.add(getJTextFieldName(), null);
jContentPane.add(getJComboBoxUsage(), null);
jContentPane.add(jLabelFeatureFlag, null);
jContentPane.add(jLabelArch, null);
jContentPane.add(getJTextFieldFeatureFlag(), 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(getJComboBoxList(), null);
jContentPane.add(getJButtonAdd(), null);
jContentPane.add(getJButtonRemove(), null);
jContentPane.add(getJButtonUpdate(), null);
jContentPane.add(getJScrollPaneList(), null);
jContentPane.add(getJScrollPaneArch(), null);
jContentPane.add(jLabelHelpText, null);
jContentPane.add(getJTextFieldHelpText(), null);
}
return jContentPane;
}
/**
This method initializes Usage type
**/
private void initFrame() {
Tools.generateComboBoxByVector(jComboBoxUsage, ed.getVHiiPackageUsage());
this.iCheckBoxListArch.setAllItems(ed.getVSupportedArchitectures());
}
/* (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() == jButtonAdd) {
if (!checkAdd()) {
return;
}
addToList();
}
if (arg0.getSource() == jButtonRemove) {
removeFromList();
}
if (arg0.getSource() == jButtonUpdate) {
if (!checkAdd()) {
return;
}
updateForList();
}
}
/**
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 fields have correct data types
//
//
// Check Hii Package Name
//
if (isEmpty(this.jTextFieldName.getText())) {
Log.err("Hii Package Name Record couldn't be empty");
return false;
}
if (!isEmpty(this.jTextFieldName.getText())) {
if (!DataValidation.isC_NameType(this.jTextFieldName.getText())) {
Log.err("Incorrect data type for Hii Package Name");
return false;
}
}
//
// Check FeatureFlag
//
if (!isEmpty(this.jTextFieldFeatureFlag.getText())) {
if (!DataValidation.isFeatureFlag(this.jTextFieldFeatureFlag.getText())) {
Log.err("Incorrect data type for Feature Flag");
return false;
}
}
return true;
}
/**
Save all components of hiiPackages
if exists formset, set the value directly
if not exists formset, new an instance first
**/
public void save() {
try {
int count = this.vid.size();
this.hiiPackages = HiiPackages.Factory.newInstance();
if (count > 0) {
for (int index = 0; index < count; index++) {
HiiPackage p = HiiPackage.Factory.newInstance();
if (!isEmpty(vid.getHiiPackages(index).getName())) {
p.setHiiCName(vid.getHiiPackages(index).getName());
}
if (!isEmpty(vid.getHiiPackages(index).getUsage())) {
p.setUsage(HiiPackageUsage.Enum.forString(vid.getHiiPackages(index).getUsage()));
}
if (!isEmpty(vid.getHiiPackages(index).getFeatureFlag())) {
p.setFeatureFlag(vid.getHiiPackages(index).getFeatureFlag());
}
if (vid.getHiiPackages(index).getSupArchList() != null
&& vid.getHiiPackages(index).getSupArchList().size() > 0) {
p.setSupArchList(vid.getHiiPackages(index).getSupArchList());
}
if (!isEmpty(vid.getHiiPackages(index).getHelp())) {
p.setHelpText(vid.getHiiPackages(index).getHelp());
}
this.hiiPackages.addNewHiiPackage();
this.hiiPackages.setHiiPackageArray(hiiPackages.getHiiPackageList().size() - 1, p);
}
}
this.msa.setHiiPackages(hiiPackages);
this.omt.setSaved(false);
} catch (Exception e) {
Log.err("Update hiiPackages", e.getMessage());
}
}
/* (non-Javadoc)
* @see java.awt.event.ComponentListener#componentResized(java.awt.event.ComponentEvent)
*
* Override componentResized to resize all components when frame's size is changed
*/
public void componentResized(ComponentEvent arg0) {
int intCurrentWidth = this.getJContentPane().getWidth();
int intCurrentHeight = this.getJContentPane().getHeight();
int intPreferredWidth = this.getJContentPane().getPreferredSize().width;
int intPreferredHeight = this.getJContentPane().getPreferredSize().height;
resizeComponentWidth(jTextFieldName, intCurrentWidth, intPreferredWidth);
resizeComponentWidth(jComboBoxUsage, intCurrentWidth, intPreferredWidth);
resizeComponentWidth(jTextFieldHelpText, intCurrentWidth, intPreferredWidth);
resizeComponentWidth(jTextFieldFeatureFlag, intCurrentWidth, intPreferredWidth);
resizeComponentWidth(jScrollPaneArch, intCurrentWidth, intPreferredWidth);
resizeComponentWidth(jComboBoxList, intCurrentWidth, intPreferredWidth);
resizeComponent(jScrollPaneList, intCurrentWidth, intCurrentHeight, intPreferredWidth, intPreferredHeight);
relocateComponentX(jButtonAdd, intCurrentWidth, intPreferredWidth, DataType.SPACE_TO_RIGHT_FOR_ADD_BUTTON);
relocateComponentX(jButtonRemove, intCurrentWidth, intPreferredWidth, DataType.SPACE_TO_RIGHT_FOR_REMOVE_BUTTON);
relocateComponentX(jButtonUpdate, intCurrentWidth, intPreferredWidth, DataType.SPACE_TO_RIGHT_FOR_UPDATE_BUTTON);
}
private HiiPackagesIdentification getCurrentHiiPackages() {
String arg0 = this.jTextFieldName.getText();
String arg1 = this.jComboBoxUsage.getSelectedItem().toString();
String arg2 = this.jTextFieldFeatureFlag.getText();
Vector<String> arg3 = this.iCheckBoxListArch.getAllCheckedItemsString();
String arg4 = this.jTextFieldHelpText.getText();
id = new HiiPackagesIdentification(arg0, arg1, arg2, arg3, arg4);
return id;
}
/**
Add current item to Vector
**/
private void addToList() {
intSelectedItemId = vid.size();
vid.addHiiPackages(getCurrentHiiPackages());
jComboBoxList.addItem(id.getName());
jComboBoxList.setSelectedItem(id.getName());
//
// Reset select item index
//
intSelectedItemId = vid.size();
//
// Reload all fields of selected item
//
reloadFromList();
//
// Save to memory
//
save();
}
/**
Remove current item from Vector
**/
private void removeFromList() {
//
// Check if exist items
//
if (this.vid.size() < 1) {
return;
}
int intTempIndex = intSelectedItemId;
jComboBoxList.removeItemAt(intSelectedItemId);
vid.removeHiiPackages(intTempIndex);
//
// Reload all fields of selected item
//
reloadFromList();
//
// Save to memory
//
save();
}
/**
Update current item of Vector
**/
private void updateForList() {
//
// Check if exist items
//
if (this.vid.size() < 1) {
return;
}
//
// Backup selected item index
//
int intTempIndex = intSelectedItemId;
vid.updateHiiPackages(getCurrentHiiPackages(), intTempIndex);
jComboBoxList.removeAllItems();
for (int index = 0; index < vid.size(); index++) {
jComboBoxList.addItem(vid.getHiiPackages(index).getName());
}
//
// Restore selected item index
//
intSelectedItemId = intTempIndex;
//
// Reset select item index
//
jComboBoxList.setSelectedIndex(intSelectedItemId);
//
// Reload all fields of selected item
//
reloadFromList();
//
// Save to memory
//
save();
}
/**
Refresh all fields' values of selected item of Vector
**/
private void reloadFromList() {
if (vid.size() > 0) {
//
// Get selected item index
//
intSelectedItemId = jComboBoxList.getSelectedIndex();
this.jTextFieldName.setText(vid.getHiiPackages(intSelectedItemId).getName());
this.jComboBoxUsage.setSelectedItem(vid.getHiiPackages(intSelectedItemId).getUsage());
this.jTextFieldHelpText.setText(vid.getHiiPackages(intSelectedItemId).getHelp());
jTextFieldFeatureFlag.setText(vid.getHiiPackages(intSelectedItemId).getFeatureFlag());
iCheckBoxListArch.setAllItemsUnchecked();
iCheckBoxListArch.initCheckedItem(true, vid.getHiiPackages(intSelectedItemId).getSupArchList());
} else {
}
reloadListArea();
}
/**
Update list area pane via the elements of Vector
**/
private void reloadListArea() {
String strListItem = "";
for (int index = 0; index < vid.size(); index++) {
strListItem = strListItem + vid.getHiiPackages(index).getName() + DataType.UNIX_LINE_SEPARATOR;
}
this.jTextAreaList.setText(strListItem);
}
/* (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.getSource() == this.jComboBoxList && arg0.getStateChange() == ItemEvent.SELECTED) {
reloadFromList();
}
}
}

View File

@@ -0,0 +1,795 @@
/** @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.frameworkwizard.module.ui;
import java.awt.event.ActionEvent;
import java.awt.event.ComponentEvent;
import java.awt.event.ItemEvent;
import java.util.Vector;
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.HobTypes;
import org.tianocore.HobUsage;
import org.tianocore.HobsDocument;
import org.tianocore.HobsDocument.Hobs;
import org.tianocore.ModuleSurfaceAreaDocument.ModuleSurfaceArea;
import org.tianocore.frameworkwizard.common.DataType;
import org.tianocore.frameworkwizard.common.DataValidation;
import org.tianocore.frameworkwizard.common.EnumerationData;
import org.tianocore.frameworkwizard.common.Log;
import org.tianocore.frameworkwizard.common.OpeningModuleType;
import org.tianocore.frameworkwizard.common.Tools;
import org.tianocore.frameworkwizard.common.ui.IInternalFrame;
import org.tianocore.frameworkwizard.common.ui.StarLabel;
import org.tianocore.frameworkwizard.common.ui.iCheckBoxList.ICheckBoxList;
import org.tianocore.frameworkwizard.module.Identification.Hobs.HobsIdentification;
import org.tianocore.frameworkwizard.module.Identification.Hobs.HobsVector;
/**
The class is used to create, update Hob of MSA/MBD file
It extends IInternalFrame
**/
public class ModuleHobs extends IInternalFrame {
///
/// Define class Serial Version UID
///
private static final long serialVersionUID = -553473437579358325L;
//
//Define class members
//
private JPanel jContentPane = null;
private JLabel jLabel = null;
private JTextField jTextFieldC_Name = null;
private JLabel jLabelUsage = null;
private JLabel jLabelHobType = null;
private JComboBox jComboBoxUsage = null;
private JComboBox jComboBoxHobType = null;
private StarLabel jStarLabel1 = null;
private JLabel jLabelArch = null;
private JTextArea jTextAreaList = null;
private JComboBox jComboBoxList = null;
private JButton jButtonAdd = null;
private JButton jButtonRemove = null;
private JButton jButtonUpdate = null;
private JScrollPane jScrollPane = null;
private JScrollPane jScrollPaneList = null;
private JLabel jLabelFeatureFlag = null;
private JTextField jTextFieldFeatureFlag = null;
private ICheckBoxList iCheckBoxListArch = null;
private JScrollPane jScrollPaneArch = null;
private JLabel jLabelHelpText = null;
private JTextField jTextFieldHelpText = null;
//
// Not used by UI
//
private int intSelectedItemId = 0;
private OpeningModuleType omt = null;
private ModuleSurfaceArea msa = null;
private HobsDocument.Hobs hobs = null;
private HobsIdentification id = null;
private HobsVector vid = new HobsVector();
private EnumerationData ed = new EnumerationData();
/**
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, 10, 320, 20));
jTextFieldC_Name.setPreferredSize(new java.awt.Dimension(320, 20));
}
return jTextFieldC_Name;
}
/**
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));
jComboBoxUsage.setPreferredSize(new java.awt.Dimension(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, 35, 320, 20));
jComboBoxHobType.setPreferredSize(new java.awt.Dimension(320, 20));
}
return jComboBoxHobType;
}
/**
This method initializes jComboBoxFileList
@return javax.swing.JComboBox jComboBoxFileList
**/
private JComboBox getJComboBoxList() {
if (jComboBoxList == null) {
jComboBoxList = new JComboBox();
jComboBoxList.setBounds(new java.awt.Rectangle(15, 220, 210, 20));
jComboBoxList.addItemListener(this);
jComboBoxList.addActionListener(this);
jComboBoxList.setPreferredSize(new java.awt.Dimension(210, 20));
}
return jComboBoxList;
}
/**
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, 220, 80, 20));
jButtonAdd.setText("Add");
jButtonAdd.addActionListener(this);
jButtonAdd.setPreferredSize(new java.awt.Dimension(80, 20));
}
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, 220, 80, 20));
jButtonRemove.setText("Remove");
jButtonRemove.addActionListener(this);
jButtonRemove.setPreferredSize(new java.awt.Dimension(80, 20));
}
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, 220, 80, 20));
jButtonUpdate.setPreferredSize(new java.awt.Dimension(80, 20));
jButtonUpdate.setText("Update");
jButtonUpdate.addActionListener(this);
}
return jButtonUpdate;
}
/**
* This method initializes jScrollPaneFileList
*
* @return javax.swing.JScrollPane
*/
private JScrollPane getJScrollPaneList() {
if (jScrollPaneList == null) {
jScrollPaneList = new JScrollPane();
jScrollPaneList.setBounds(new java.awt.Rectangle(15, 245, 465, 240));
jScrollPaneList.setViewportView(getJTextAreaList());
jScrollPaneList.setPreferredSize(new java.awt.Dimension(465, 240));
}
return jScrollPaneList;
}
/**
This method initializes jScrollPane
@return javax.swing.JScrollPane
*/
private JScrollPane getJScrollPane() {
if (jScrollPane == null) {
jScrollPane = new JScrollPane();
jScrollPane.setViewportView(getJContentPane());
}
return jScrollPane;
}
/**
* This method initializes jTextAreaFileList
*
* @return javax.swing.JTextArea
*/
private JTextArea getJTextAreaList() {
if (jTextAreaList == null) {
jTextAreaList = new JTextArea();
jTextAreaList.setEditable(false);
}
return jTextAreaList;
}
/**
* This method initializes jTextFieldFeatureFlag
*
* @return javax.swing.JTextField
*/
private JTextField getJTextFieldFeatureFlag() {
if (jTextFieldFeatureFlag == null) {
jTextFieldFeatureFlag = new JTextField();
jTextFieldFeatureFlag.setBounds(new java.awt.Rectangle(160, 110, 320, 20));
jTextFieldFeatureFlag.setPreferredSize(new java.awt.Dimension(320, 20));
}
return jTextFieldFeatureFlag;
}
/**
This method initializes iCheckBoxListArch
@return ICheckBoxList
**/
private ICheckBoxList getICheckBoxListSupportedArchitectures() {
if (iCheckBoxListArch == null) {
iCheckBoxListArch = new ICheckBoxList();
iCheckBoxListArch.addFocusListener(this);
iCheckBoxListArch.setToolTipText(DataType.SUP_ARCH_LIST_HELP_TEXT);
}
return iCheckBoxListArch;
}
/**
This method initializes jScrollPaneArch
@return javax.swing.JScrollPane
**/
private JScrollPane getJScrollPaneArch() {
if (jScrollPaneArch == null) {
jScrollPaneArch = new JScrollPane();
jScrollPaneArch.setBounds(new java.awt.Rectangle(160, 135, 320, 80));
jScrollPaneArch.setPreferredSize(new java.awt.Dimension(320, 80));
jScrollPaneArch.setViewportView(getICheckBoxListSupportedArchitectures());
}
return jScrollPaneArch;
}
/**
This method initializes jTextFieldHelpText
@return javax.swing.JTextField
**/
private JTextField getJTextFieldHelpText() {
if (jTextFieldHelpText == null) {
jTextFieldHelpText = new JTextField();
jTextFieldHelpText.setBounds(new java.awt.Rectangle(160, 85, 320, 20));
jTextFieldHelpText.setPreferredSize(new java.awt.Dimension(320, 20));
}
return jTextFieldHelpText;
}
public static void main(String[] args) {
}
/**
This method initializes this
**/
private void init() {
this.setSize(500, 515);
this.setContentPane(getJScrollPane());
this.setTitle("Hobs");
initFrame();
this.setViewMode(false);
}
/**
This method initializes this
Fill values to all fields if these values are not empty
@param inPackageDependencies
**/
private void init(Hobs inHobs) {
init();
this.hobs = inHobs;
if (this.hobs != null) {
if (this.hobs.getHobTypesList().size() > 0) {
for (int index = 0; index < this.hobs.getHobTypesList().size(); index++) {
String arg0 = hobs.getHobTypesList().get(index).getHobGuidCName();
String arg1 = null;
if (hobs.getHobTypesList().get(index).getHobType() != null) {
arg1 = hobs.getHobTypesList().get(index).getHobType().toString();
}
String arg2 = null;
if (hobs.getHobTypesList().get(index).getUsage() != null) {
arg2 = hobs.getHobTypesList().get(index).getUsage().toString();
}
String arg3 = hobs.getHobTypesList().get(index).getFeatureFlag();
Vector<String> arg4 = Tools.convertListToVector(hobs.getHobTypesList().get(index).getSupArchList());
String arg5 = hobs.getHobTypesList().get(index).getHelpText();
id = new HobsIdentification(arg0, arg1, arg2, arg3, arg4, arg5);
vid.addHobs(id);
}
}
}
//
// Update the list
//
Tools.generateComboBoxByVector(jComboBoxList, vid.getHobsName());
reloadListArea();
}
/**
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(OpeningModuleType inOmt) {
super();
this.omt = inOmt;
this.msa = omt.getXmlMsa();
init(msa.getHobs());
this.setVisible(true);
}
/**
Disable all components when the mode is view
@param isView true - The view mode; false - The non-view mode
**/
public void setViewMode(boolean isView) {
if (isView) {
this.jTextFieldC_Name.setEnabled(!isView);
this.jComboBoxUsage.setEnabled(!isView);
this.jComboBoxHobType.setEnabled(!isView);
}
}
/**
This method initializes jContentPane
@return javax.swing.JPanel jContentPane
**/
public JPanel getJContentPane() {
if (jContentPane == null) {
jLabelFeatureFlag = new JLabel();
jLabelFeatureFlag.setBounds(new java.awt.Rectangle(15, 110, 140, 20));
jLabelFeatureFlag.setText("Feature Flag");
jLabelArch = new JLabel();
jLabelArch.setBounds(new java.awt.Rectangle(15, 135, 140, 20));
jLabelArch.setText("Arch");
jLabelHobType = new JLabel();
jLabelHobType.setText("Hob Type");
jLabelHobType.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));
jLabel = new JLabel();
jLabel.setText("C_Name");
jLabel.setBounds(new java.awt.Rectangle(15, 10, 140, 20));
jLabelHelpText = new JLabel();
jLabelHelpText.setBounds(new java.awt.Rectangle(14, 85, 140, 20));
jLabelHelpText.setText("Help Text");
jContentPane = new JPanel();
jContentPane.setLayout(null);
jContentPane.setPreferredSize(new java.awt.Dimension(490, 495));
jContentPane.add(jLabel, null);
jContentPane.add(getJTextFieldC_Name(), null);
jContentPane.add(jLabelUsage, null);
jContentPane.add(jLabelHobType, null);
jContentPane.add(getJComboBoxUsage(), null);
jContentPane.add(getJComboBoxHobType(), null);
jStarLabel1 = new StarLabel();
jStarLabel1.setLocation(new java.awt.Point(0, 10));
jContentPane.add(jStarLabel1, null);
jContentPane.add(jLabelArch, null);
jContentPane.add(getJComboBoxList(), null);
jContentPane.add(getJButtonAdd(), null);
jContentPane.add(getJButtonRemove(), null);
jContentPane.add(getJButtonUpdate(), null);
jContentPane.add(getJScrollPaneList(), null);
jContentPane.add(jLabelFeatureFlag, null);
jContentPane.add(getJTextFieldFeatureFlag(), null);
jContentPane.add(getJScrollPaneArch(), null);
jContentPane.add(jLabelHelpText, null);
jContentPane.add(getJTextFieldHelpText(), null);
}
return jContentPane;
}
/**
This method initializes Usage type and Hob type
**/
private void initFrame() {
Tools.generateComboBoxByVector(jComboBoxUsage, ed.getVHobUsage());
Tools.generateComboBoxByVector(jComboBoxHobType, ed.getVHobType());
this.iCheckBoxListArch.setAllItems(ed.getVSupportedArchitectures());
}
/* (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() == jButtonAdd) {
if (!checkAdd()) {
return;
}
addToList();
}
if (arg0.getSource() == jButtonRemove) {
removeFromList();
}
if (arg0.getSource() == jButtonUpdate) {
if (!checkAdd()) {
return;
}
updateForList();
}
}
/**
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 fields have correct data types
//
//
// Check Name
//
if (isEmpty(this.jTextFieldC_Name.getText())) {
Log.err("Hob Name couldn't be empty");
return false;
}
if (!isEmpty(this.jTextFieldC_Name.getText())) {
if (!DataValidation.isC_NameType(this.jTextFieldC_Name.getText())) {
Log.err("Incorrect data type for Hob Name");
return false;
}
}
//
// Check FeatureFlag
//
if (!isEmpty(this.jTextFieldFeatureFlag.getText())) {
if (!DataValidation.isFeatureFlag(this.jTextFieldFeatureFlag.getText())) {
Log.err("Incorrect data type for Feature Flag");
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 {
int count = this.vid.size();
this.hobs = Hobs.Factory.newInstance();
if (count > 0) {
for (int index = 0; index < count; index++) {
HobsDocument.Hobs.HobTypes p = HobsDocument.Hobs.HobTypes.Factory.newInstance();
if (!isEmpty(vid.getHobs(index).getName())) {
p.setHobGuidCName(vid.getHobs(index).getName());
}
if (!isEmpty(vid.getHobs(index).getUsage())) {
p.setUsage(HobUsage.Enum.forString(vid.getHobs(index).getUsage()));
}
if (!isEmpty(vid.getHobs(index).getType())) {
p.setHobType(HobTypes.Enum.forString(vid.getHobs(index).getType()));
}
if (!isEmpty(vid.getHobs(index).getFeatureFlag())) {
p.setFeatureFlag(vid.getHobs(index).getFeatureFlag());
}
if (vid.getHobs(index).getSupArchList() != null && vid.getHobs(index).getSupArchList().size() > 0) {
p.setSupArchList(vid.getHobs(index).getSupArchList());
}
this.hobs.addNewHobTypes();
this.hobs.setHobTypesArray(hobs.getHobTypesList().size() - 1, p);
}
}
this.msa.setHobs(hobs);
this.omt.setSaved(false);
} catch (Exception e) {
e.printStackTrace();
Log.err("Update Hobs", e.getMessage());
}
}
/* (non-Javadoc)
* @see java.awt.event.ComponentListener#componentResized(java.awt.event.ComponentEvent)
*
* Override componentResized to resize all components when frame's size is changed
*/
public void componentResized(ComponentEvent arg0) {
int intCurrentWidth = this.getJContentPane().getWidth();
int intCurrentHeight = this.getJContentPane().getHeight();
int intPreferredWidth = this.getJContentPane().getPreferredSize().width;
int intPreferredHeight = this.getJContentPane().getPreferredSize().height;
resizeComponentWidth(jTextFieldC_Name, intCurrentWidth, intPreferredWidth);
resizeComponentWidth(jComboBoxHobType, intCurrentWidth, intPreferredWidth);
resizeComponentWidth(jComboBoxUsage, intCurrentWidth, intPreferredWidth);
resizeComponentWidth(jTextFieldHelpText, intCurrentWidth, intPreferredWidth);
resizeComponentWidth(jTextFieldFeatureFlag, intCurrentWidth, intPreferredWidth);
resizeComponentWidth(jScrollPaneArch, intCurrentWidth, intPreferredWidth);
resizeComponentWidth(jComboBoxList, intCurrentWidth, intPreferredWidth);
resizeComponent(jScrollPaneList, intCurrentWidth, intCurrentHeight, intPreferredWidth, intPreferredHeight);
relocateComponentX(jButtonAdd, intCurrentWidth, intPreferredWidth, DataType.SPACE_TO_RIGHT_FOR_ADD_BUTTON);
relocateComponentX(jButtonRemove, intCurrentWidth, intPreferredWidth, DataType.SPACE_TO_RIGHT_FOR_REMOVE_BUTTON);
relocateComponentX(jButtonUpdate, intCurrentWidth, intPreferredWidth, DataType.SPACE_TO_RIGHT_FOR_UPDATE_BUTTON);
}
private HobsIdentification getCurrentHobs() {
String arg0 = this.jTextFieldC_Name.getText();
String arg1 = this.jComboBoxHobType.getSelectedItem().toString();
String arg2 = this.jComboBoxUsage.getSelectedItem().toString();
String arg3 = this.jTextFieldFeatureFlag.getText();
Vector<String> arg4 = this.iCheckBoxListArch.getAllCheckedItemsString();
String arg5 = this.jTextFieldHelpText.getText();
id = new HobsIdentification(arg0, arg1, arg2, arg3, arg4, arg5);
return id;
}
/**
Add current item to Vector
**/
private void addToList() {
intSelectedItemId = vid.size();
vid.addHobs(getCurrentHobs());
jComboBoxList.addItem(id.getName());
jComboBoxList.setSelectedItem(id.getName());
//
// Reset select item index
//
intSelectedItemId = vid.size();
//
// Reload all fields of selected item
//
reloadFromList();
//
// Save to memory
//
save();
}
/**
Remove current item from Vector
**/
private void removeFromList() {
//
// Check if exist items
//
if (this.vid.size() < 1) {
return;
}
int intTempIndex = intSelectedItemId;
jComboBoxList.removeItemAt(intSelectedItemId);
vid.removeHobs(intTempIndex);
//
// Reload all fields of selected item
//
reloadFromList();
//
// Save to memory
//
save();
}
/**
Update current item of Vector
**/
private void updateForList() {
//
// Check if exist items
//
if (this.vid.size() < 1) {
return;
}
//
// Backup selected item index
//
int intTempIndex = intSelectedItemId;
vid.updateHobs(getCurrentHobs(), intTempIndex);
jComboBoxList.removeAllItems();
for (int index = 0; index < vid.size(); index++) {
jComboBoxList.addItem(vid.getHobs(index).getName());
}
//
// Restore selected item index
//
intSelectedItemId = intTempIndex;
//
// Reset select item index
//
jComboBoxList.setSelectedIndex(intSelectedItemId);
//
// Reload all fields of selected item
//
reloadFromList();
//
// Save to memory
//
save();
}
/**
Refresh all fields' values of selected item of Vector
**/
private void reloadFromList() {
if (vid.size() > 0) {
//
// Get selected item index
//
intSelectedItemId = jComboBoxList.getSelectedIndex();
this.jTextFieldC_Name.setText(vid.getHobs(intSelectedItemId).getName());
this.jComboBoxHobType.setSelectedItem(vid.getHobs(intSelectedItemId).getType());
this.jComboBoxUsage.setSelectedItem(vid.getHobs(intSelectedItemId).getUsage());
this.jTextFieldHelpText.setText(vid.getHobs(intSelectedItemId).getHelp());
jTextFieldFeatureFlag.setText(vid.getHobs(intSelectedItemId).getFeatureFlag());
iCheckBoxListArch.setAllItemsUnchecked();
iCheckBoxListArch.initCheckedItem(true, vid.getHobs(intSelectedItemId).getSupArchList());
} else {
}
reloadListArea();
}
/**
Update list area pane via the elements of Vector
**/
private void reloadListArea() {
String strListItem = "";
for (int index = 0; index < vid.size(); index++) {
strListItem = strListItem + vid.getHobs(index).getName() + DataType.UNIX_LINE_SEPARATOR;
}
this.jTextAreaList.setText(strListItem);
}
/* (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.getSource() == this.jComboBoxList && arg0.getStateChange() == ItemEvent.SELECTED) {
reloadFromList();
}
}
}

View File

@@ -0,0 +1,952 @@
/** @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.frameworkwizard.module.ui;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ComponentEvent;
import java.awt.event.ItemEvent;
import java.util.Vector;
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.LibraryClassDefinitionsDocument;
import org.tianocore.LibraryUsage;
import org.tianocore.ModuleSurfaceAreaDocument;
import org.tianocore.LibraryClassDefinitionsDocument.LibraryClassDefinitions;
import org.tianocore.LibraryClassDocument.LibraryClass;
import org.tianocore.frameworkwizard.common.DataType;
import org.tianocore.frameworkwizard.common.DataValidation;
import org.tianocore.frameworkwizard.common.EnumerationData;
import org.tianocore.frameworkwizard.common.Log;
import org.tianocore.frameworkwizard.common.OpeningModuleType;
import org.tianocore.frameworkwizard.common.Tools;
import org.tianocore.frameworkwizard.common.ui.IInternalFrame;
import org.tianocore.frameworkwizard.common.ui.StarLabel;
import org.tianocore.frameworkwizard.common.ui.iCheckBoxList.ICheckBoxList;
import org.tianocore.frameworkwizard.module.Identification.LibraryClass.LibraryClassIdentification;
import org.tianocore.frameworkwizard.module.Identification.LibraryClass.LibraryClassVector;
import org.tianocore.frameworkwizard.workspace.WorkspaceTools;
/**
The class is used to create, update Library Class Definition of MSA/MBD file
It extends IInternalFrame
**/
public class ModuleLibraryClassDefinitions extends IInternalFrame {
///
/// Define class Serial Version UID
///
private static final long serialVersionUID = -1743248695411382857L;
//
//Define class members
//
private JPanel jContentPane = null;
private JComboBox jComboBoxLibraryClassName = null;
private JLabel jLabelUsage = null;
private JComboBox jComboBoxUsage = null;
private JComboBox jComboBoxList = null;
private JButton jButtonAdd = null;
private JButton jButtonRemove = null;
private JButton jButtonUpdate = null;
private JLabel jLabelLibraryClassName = null;
private JScrollPane jScrollPaneList = null;
private JScrollPane jScrollPane = null;
private JTextArea jTextAreaList = null;
private StarLabel jStarLabel1 = null;
private StarLabel jStarLabel2 = null;
private ICheckBoxList iCheckBoxListArch = null;
private JScrollPane jScrollPaneArch = null;
private JLabel jLabelRecommendedInstanceVersion = null;
private JTextField jTextFieldRecommendedInstanceVersion = null;
private JLabel jLabelRecommendedInstanceGuid = null;
private JTextField jTextFieldRecommendedInstanceGuid = null;
private JButton jButtonGenerateGuid = null;
private JLabel jLabelFeatureFlag = null;
private JTextField jTextFieldFeatureFlag = null;
private JLabel jLabelArch = null;
private JLabel jLabelModuleList = null;
private JScrollPane jScrollPaneModuleList = null;
private ICheckBoxList iCheckBoxListModule = null;
private JLabel jLabelHelpText = null;
private JTextField jTextFieldHelpText = null;
//
// Not for UI
//
private ModuleSurfaceAreaDocument.ModuleSurfaceArea msa = null;
private LibraryClassDefinitions lcd = null;
private LibraryClassVector vLibraryClass = new LibraryClassVector();
private EnumerationData ed = new EnumerationData();
private Vector<String> vLib = new Vector<String>();
private int intSelectedItemId = 0;
private WorkspaceTools wt = new WorkspaceTools();
private LibraryClassIdentification lcid = null;
private OpeningModuleType omt = null;
/**
This method initializes jComboBoxSelect
@return javax.swing.JComboBox jComboBoxSelect
**/
private JComboBox getJComboBoxLibraryClassName() {
if (jComboBoxLibraryClassName == null) {
jComboBoxLibraryClassName = new JComboBox();
jComboBoxLibraryClassName.setBounds(new java.awt.Rectangle(160, 10, 320, 20));
jComboBoxLibraryClassName.setPreferredSize(new Dimension(320, 20));
jComboBoxLibraryClassName.setEnabled(true);
}
return jComboBoxLibraryClassName;
}
/**
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));
jComboBoxUsage.setPreferredSize(new Dimension(320, 20));
}
return jComboBoxUsage;
}
/**
This method initializes jComboBoxFileList
@return javax.swing.JComboBox jComboBoxFileList
**/
private JComboBox getJComboBoxList() {
if (jComboBoxList == null) {
jComboBoxList = new JComboBox();
jComboBoxList.setBounds(new java.awt.Rectangle(15, 330, 210, 20));
jComboBoxList.setPreferredSize(new Dimension(210, 20));
jComboBoxList.addItemListener(this);
jComboBoxList.addActionListener(this);
}
return jComboBoxList;
}
/**
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, 330, 80, 20));
jButtonAdd.setPreferredSize(new Dimension(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, 330, 80, 20));
jButtonRemove.setText("Remove");
jButtonRemove.setPreferredSize(new Dimension(80, 20));
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, 330, 80, 20));
jButtonUpdate.setText("Update");
jButtonUpdate.setPreferredSize(new Dimension(80, 20));
jButtonUpdate.addActionListener(this);
}
return jButtonUpdate;
}
/**
This method initializes jScrollPane
@return javax.swing.JScrollPane
*/
private JScrollPane getJScrollPaneList() {
if (jScrollPaneList == null) {
jScrollPaneList = new JScrollPane();
jScrollPaneList.setBounds(new java.awt.Rectangle(15, 355, 465, 100));
jScrollPaneList.setPreferredSize(new Dimension(465, 260));
jScrollPaneList.setViewportView(getJTextAreaList());
}
return jScrollPaneList;
}
/**
This method initializes jScrollPane
@return javax.swing.JScrollPane
*/
private JScrollPane getJScrollPane() {
if (jScrollPane == null) {
jScrollPane = new JScrollPane();
jScrollPane.setViewportView(getJContentPane());
}
return jScrollPane;
}
/**
* This method initializes jTextAreaList
*
* @return javax.swing.JTextArea
*/
private JTextArea getJTextAreaList() {
if (jTextAreaList == null) {
jTextAreaList = new JTextArea();
jTextAreaList.setEditable(false);
}
return jTextAreaList;
}
/**
* This method initializes jTextFieldRecommendedInstanceVersion
*
* @return javax.swing.JTextField
*/
private JTextField getJTextFieldRecommendedInstanceVersion() {
if (jTextFieldRecommendedInstanceVersion == null) {
jTextFieldRecommendedInstanceVersion = new JTextField();
jTextFieldRecommendedInstanceVersion.setPreferredSize(new java.awt.Dimension(260, 20));
jTextFieldRecommendedInstanceVersion.setSize(new java.awt.Dimension(260, 20));
jTextFieldRecommendedInstanceVersion.setLocation(new java.awt.Point(220, 85));
}
return jTextFieldRecommendedInstanceVersion;
}
/**
* This method initializes jTextFieldRecommendedInstanceGuid
*
* @return javax.swing.JTextField
*/
private JTextField getJTextFieldRecommendedInstanceGuid() {
if (jTextFieldRecommendedInstanceGuid == null) {
jTextFieldRecommendedInstanceGuid = new JTextField();
jTextFieldRecommendedInstanceGuid.setBounds(new java.awt.Rectangle(220, 110, 190, 20));
jTextFieldRecommendedInstanceGuid.setPreferredSize(new java.awt.Dimension(190, 20));
}
return jTextFieldRecommendedInstanceGuid;
}
/**
* This method initializes jButtonGenerateGuid
*
* @return javax.swing.JButton
*/
private JButton getJButtonGenerateGuid() {
if (jButtonGenerateGuid == null) {
jButtonGenerateGuid = new JButton();
jButtonGenerateGuid.setBounds(new java.awt.Rectangle(415, 110, 65, 20));
jButtonGenerateGuid.setPreferredSize(new java.awt.Dimension(65, 20));
jButtonGenerateGuid.setText("GEN");
jButtonGenerateGuid.addActionListener(this);
}
return jButtonGenerateGuid;
}
/**
* 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.setPreferredSize(new java.awt.Dimension(320, 20));
}
return jTextFieldFeatureFlag;
}
/**
This method initializes iCheckBoxListArch
@return ICheckBoxList
**/
private ICheckBoxList getICheckBoxListSupportedArchitectures() {
if (iCheckBoxListArch == null) {
iCheckBoxListArch = new ICheckBoxList();
iCheckBoxListArch.addFocusListener(this);
}
return iCheckBoxListArch;
}
/**
This method initializes iCheckBoxListArch
@return ICheckBoxList
**/
private ICheckBoxList getICheckBoxListSupModuleList() {
if (iCheckBoxListModule == null) {
iCheckBoxListModule = new ICheckBoxList();
}
return iCheckBoxListModule;
}
/**
This method initializes jScrollPaneArch
@return javax.swing.JScrollPane
**/
private JScrollPane getJScrollPaneArch() {
if (jScrollPaneArch == null) {
jScrollPaneArch = new JScrollPane();
jScrollPaneArch.setBounds(new java.awt.Rectangle(160, 160, 320, 80));
jScrollPaneArch.setPreferredSize(new java.awt.Dimension(320, 80));
jScrollPaneArch.setViewportView(getICheckBoxListSupportedArchitectures());
}
return jScrollPaneArch;
}
/**
This method initializes jScrollPaneModuleList
@return javax.swing.JScrollPane
**/
private JScrollPane getJScrollPaneModuleList() {
if (jScrollPaneModuleList == null) {
jScrollPaneModuleList = new JScrollPane();
jScrollPaneModuleList.setBounds(new java.awt.Rectangle(160, 245, 320, 80));
jScrollPaneModuleList.setPreferredSize(new java.awt.Dimension(320, 80));
jScrollPaneModuleList.setViewportView(getICheckBoxListSupModuleList());
}
return jScrollPaneModuleList;
}
/**
This method initializes jTextFieldHelpText
@return javax.swing.JTextField
**/
private JTextField getJTextFieldHelpText() {
if (jTextFieldHelpText == null) {
jTextFieldHelpText = new JTextField();
jTextFieldHelpText.setBounds(new java.awt.Rectangle(160, 60, 320, 20));
jTextFieldHelpText.setPreferredSize(new java.awt.Dimension(320, 20));
}
return jTextFieldHelpText;
}
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
**/
public ModuleLibraryClassDefinitions(OpeningModuleType inOmt) {
super();
this.omt = inOmt;
this.msa = omt.getXmlMsa();
initLibraryClass();
init(msa.getLibraryClassDefinitions());
this.setVisible(true);
}
// private void initLibraryClass(MsaHeaderDocument.MsaHeader msaHeader) {
// Enum e = msaHeader.getModuleType();
// if (e == ModuleTypeDef.BASE) {
// vLib = ed.getVLibClassDefBase();
// } else if (e == ModuleTypeDef.PEI_CORE) {
// vLib = ed.getVLibClassDefPei();
// } else if (e == ModuleTypeDef.PEIM) {
// vLib = ed.getVLibClassDefPeim();
// } else if (e == ModuleTypeDef.DXE_CORE) {
// vLib = ed.getVLibClassDefDxeCore();
// } else if (e == ModuleTypeDef.DXE_DRIVER) {
// vLib = ed.getVLibClassDefDxeDriver();
// } else if (e == ModuleTypeDef.DXE_SMM_DRIVER) {
// vLib = ed.getVLibClassDefDxeSmmDriver();
// } else if (e == ModuleTypeDef.UEFI_DRIVER) {
// vLib = ed.getVLibClassDefUefiDriver();
// } else {
// //vLib = ed.getVLibClassDef();
// }
// }
/**
**/
private void initLibraryClass() {
vLib = wt.getAllLibraryClassDefinitionsFromWorkspace();
}
/**
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.lcd = inLibraryClassDefinitions;
if (this.lcd != null) {
if (this.lcd.getLibraryClassList().size() > 0) {
for (int index = 0; index < this.lcd.getLibraryClassList().size(); index++) {
String name = lcd.getLibraryClassList().get(index).getKeyword();
String usage = null;
if (lcd.getLibraryClassList().get(index).getUsage() != null) {
usage = lcd.getLibraryClassList().get(index).getUsage().toString();
}
String version = lcd.getLibraryClassList().get(index).getRecommendedInstanceVersion();
String guid = lcd.getLibraryClassList().get(index).getRecommendedInstanceGuid();
String featureFlag = lcd.getLibraryClassList().get(index).getFeatureFlag();
Vector<String> arch = Tools.convertListToVector(lcd.getLibraryClassList().get(index)
.getSupArchList());
Vector<String> module = Tools.convertListToVector(lcd.getLibraryClassList().get(index)
.getSupModuleList());
String help = lcd.getLibraryClassList().get(index).getHelpText();
LibraryClassIdentification lcid = new LibraryClassIdentification(name, usage, version, guid, arch,
featureFlag, module, help);
vLibraryClass.addLibraryClass(lcid);
}
}
}
//
// Update the list
//
Tools.generateComboBoxByVector(jComboBoxList, vLibraryClass.getLibraryClassName());
reloadListArea();
}
/**
This method initializes this
**/
private void init() {
this.setContentPane(getJScrollPane());
this.setTitle("Library Class Definitions");
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) {
if (isView) {
this.jComboBoxLibraryClassName.setEnabled(!isView);
this.jComboBoxUsage.setEnabled(!isView);
}
}
/**
This method initializes jContentPane
@return javax.swing.JPanel jContentPane
**/
private JPanel getJContentPane() {
if (jContentPane == null) {
jLabelHelpText = new JLabel();
jLabelHelpText.setBounds(new java.awt.Rectangle(14, 60, 140, 20));
jLabelHelpText.setText("Help Text");
jLabelModuleList = new JLabel();
jLabelModuleList.setBounds(new java.awt.Rectangle(15, 245, 140, 20));
jLabelModuleList.setText("Sup Module List");
jLabelArch = new JLabel();
jLabelArch.setBounds(new java.awt.Rectangle(15, 160, 140, 20));
jLabelArch.setText("Sup Arch List");
jLabelFeatureFlag = new JLabel();
jLabelFeatureFlag.setBounds(new java.awt.Rectangle(15, 135, 140, 20));
jLabelFeatureFlag.setText("Feature Flag");
jLabelRecommendedInstanceGuid = new JLabel();
jLabelRecommendedInstanceGuid.setBounds(new java.awt.Rectangle(15, 110, 200, 20));
jLabelRecommendedInstanceGuid.setText("Recommended Instance Guid");
jLabelRecommendedInstanceVersion = new JLabel();
jLabelRecommendedInstanceVersion.setBounds(new java.awt.Rectangle(15, 85, 200, 20));
jLabelRecommendedInstanceVersion.setText("Recommended Instance Version");
jLabelLibraryClassName = new JLabel();
jLabelLibraryClassName.setBounds(new java.awt.Rectangle(15, 10, 140, 20));
jLabelLibraryClassName.setText("Library Class Name");
jLabelUsage = new JLabel();
jLabelUsage.setBounds(new java.awt.Rectangle(15, 35, 140, 20));
jLabelUsage.setText("Usage");
jContentPane = new JPanel();
jContentPane.setLayout(null);
jContentPane.setPreferredSize(new java.awt.Dimension(490, 465));
jContentPane.add(getJComboBoxLibraryClassName(), null);
jContentPane.add(jLabelUsage, null);
jContentPane.add(getJComboBoxUsage(), null);
jContentPane.add(jLabelLibraryClassName, null);
jContentPane.add(getJScrollPaneList(), null);
jContentPane.add(getJComboBoxList(), null);
jContentPane.add(getJButtonAdd(), null);
jContentPane.add(getJButtonRemove(), null);
jContentPane.add(getJButtonUpdate(), null);
jContentPane.add(jLabelRecommendedInstanceVersion, null);
jContentPane.add(getJTextFieldRecommendedInstanceVersion(), null);
jContentPane.add(jLabelRecommendedInstanceGuid, null);
jContentPane.add(getJTextFieldRecommendedInstanceGuid(), null);
jContentPane.add(getJButtonGenerateGuid(), null);
jContentPane.add(jLabelFeatureFlag, null);
jContentPane.add(getJTextFieldFeatureFlag(), null);
jContentPane.add(jLabelArch, null);
jContentPane.add(getJScrollPaneArch(), 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(jLabelModuleList, null);
jContentPane.add(getJScrollPaneModuleList(), null);
jContentPane.add(jLabelHelpText, null);
jContentPane.add(getJTextFieldHelpText(), null);
}
return jContentPane;
}
/**
This method initializes all existing libraries and usage types
**/
private void initFrame() {
Tools.generateComboBoxByVector(jComboBoxLibraryClassName, vLib);
Tools.generateComboBoxByVector(jComboBoxUsage, ed.getVLibraryUsage());
this.iCheckBoxListArch.setAllItems(ed.getVSupportedArchitectures());
this.iCheckBoxListModule.setAllItems(ed.getVFrameworkModuleTypes());
}
/* (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() == jButtonAdd) {
if (!checkAdd()) {
return;
}
addToList();
}
if (arg0.getSource() == jButtonRemove) {
removeFromList();
}
if (arg0.getSource() == jButtonUpdate) {
updateForList();
}
if (arg0.getSource() == jButtonGenerateGuid) {
this.jTextFieldRecommendedInstanceGuid.setText(Tools.generateUuidString());
}
}
/**
Data validation for all fields
@retval true - All datas are valid
@retval false - At least one data is invalid
**/
public boolean checkAdd() {
//
// Check LibraryClass
//
if (this.jComboBoxLibraryClassName.getSelectedItem() == null) {
Log.err("No Library Class can be added");
return false;
}
if (!DataValidation.isLibraryClass(this.jComboBoxLibraryClassName.getSelectedItem().toString())) {
Log.err("Incorrect data type for Library Class");
return false;
}
//
// Check RecommendedInstanceVersion
//
if (!isEmpty(this.jTextFieldRecommendedInstanceVersion.getText())) {
if (!DataValidation.isRecommendedInstanceVersion(this.jTextFieldRecommendedInstanceVersion.getText())) {
Log.err("Incorrect data type for Recommended Instance Version");
return false;
}
}
//
// Check RecommendedInstanceGuid
//
if (!isEmpty(this.jTextFieldRecommendedInstanceGuid.getText())) {
if (!DataValidation.isGuid(this.jTextFieldRecommendedInstanceGuid.getText())) {
Log.err("Incorrect data type for Recommended Instance Guid");
return false;
}
}
//
// Check FeatureFlag
//
if (!isEmpty(this.jTextFieldFeatureFlag.getText())) {
if (!DataValidation.isFeatureFlag(this.jTextFieldFeatureFlag.getText())) {
Log.err("Incorrect data type for Feature Flag");
return false;
}
}
if (this.vLibraryClass.findLibraryClass(this.jComboBoxLibraryClassName.getSelectedItem().toString()) > -1) {
Log.err("The Library Class has been added already!");
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 = this.vLibraryClass.size();
lcd = LibraryClassDefinitions.Factory.newInstance();
if (intLibraryCount > 0) {
for (int index = 0; index < intLibraryCount; index++) {
LibraryClass mLibraryClass = LibraryClass.Factory.newInstance();
mLibraryClass.setKeyword(vLibraryClass.getLibraryClass(index).getLibraryClassName());
mLibraryClass
.setUsage(LibraryUsage.Enum.forString(vLibraryClass.getLibraryClass(index).getUsage()));
if (!isEmpty(vLibraryClass.getLibraryClass(index).getRecommendedInstanceVersion())) {
mLibraryClass.setRecommendedInstanceVersion(vLibraryClass.getLibraryClass(index)
.getRecommendedInstanceVersion());
}
if (!isEmpty(vLibraryClass.getLibraryClass(index).getRecommendedInstanceGuid())) {
mLibraryClass.setRecommendedInstanceGuid(vLibraryClass.getLibraryClass(index)
.getRecommendedInstanceGuid());
}
if (!isEmpty(vLibraryClass.getLibraryClass(index).getFeatureFlag())) {
mLibraryClass.setFeatureFlag(vLibraryClass.getLibraryClass(index).getFeatureFlag());
}
if (vLibraryClass.getLibraryClass(index).getSupArchList() != null
&& vLibraryClass.getLibraryClass(index).getSupArchList().size() > 0) {
mLibraryClass.setSupArchList(vLibraryClass.getLibraryClass(index).getSupArchList());
}
if (!isEmpty(vLibraryClass.getLibraryClass(index).getHelp())) {
mLibraryClass.setHelpText(vLibraryClass.getLibraryClass(index).getHelp());
}
this.lcd.addNewLibraryClass();
this.lcd.setLibraryClassArray(index, mLibraryClass);
}
}
if (msa.getLibraryClassDefinitions() == null) {
this.msa.addNewLibraryClassDefinitions();
}
this.msa.setLibraryClassDefinitions(this.lcd);
this.omt.setSaved(false);
} catch (Exception e) {
Log.err("Update Library Class Definitions", e.getMessage());
}
}
private LibraryClassIdentification getCurrentLibraryClass() {
String name = this.jComboBoxLibraryClassName.getSelectedItem().toString();
String usage = this.jComboBoxUsage.getSelectedItem().toString();
String version = this.jTextFieldRecommendedInstanceVersion.getText();
String guid = this.jTextFieldRecommendedInstanceGuid.getText();
String featureFlag = this.jTextFieldFeatureFlag.getText();
Vector<String> arch = this.iCheckBoxListArch.getAllCheckedItemsString();
Vector<String> module = this.iCheckBoxListModule.getAllCheckedItemsString();
String help = this.jTextFieldHelpText.getText();
lcid = new LibraryClassIdentification(name, usage, version, guid, arch, featureFlag, module, help);
return lcid;
}
/**
Add current item to Vector
**/
private void addToList() {
intSelectedItemId = vLibraryClass.size();
vLibraryClass.addLibraryClass(getCurrentLibraryClass());
jComboBoxList.addItem(lcid.getLibraryClassName());
jComboBoxList.setSelectedItem(lcid.getLibraryClassName());
//
// Reset select item index
//
intSelectedItemId = vLibraryClass.size();
//
// Reload all fields of selected item
//
reloadFromList();
//
// Save to memory
//
save();
}
/**
Remove current item from Vector
**/
private void removeFromList() {
//
// Check if exist items
//
if (this.vLibraryClass.size() < 1) {
return;
}
int intTempIndex = intSelectedItemId;
jComboBoxList.removeItemAt(intSelectedItemId);
vLibraryClass.removeLibraryClass(intTempIndex);
//
// Reload all fields of selected item
//
reloadFromList();
//
// Save to memory
//
save();
}
/**
Update current item of Vector
**/
private void updateForList() {
//
// Check if exist items
//
if (this.vLibraryClass.size() < 1) {
return;
}
//
// Backup selected item index
//
int intTempIndex = intSelectedItemId;
vLibraryClass.updateLibraryClass(getCurrentLibraryClass(), intTempIndex);
jComboBoxList.removeAllItems();
for (int index = 0; index < vLibraryClass.size(); index++) {
jComboBoxList.addItem(vLibraryClass.getLibraryClass(index).getLibraryClassName());
}
//
// Restore selected item index
//
intSelectedItemId = intTempIndex;
//
// Reset select item index
//
jComboBoxList.setSelectedIndex(intSelectedItemId);
//
// Reload all fields of selected item
//
reloadFromList();
//
// Save to memory
//
save();
}
/**
Refresh all fields' values of selected item of Vector
**/
private void reloadFromList() {
if (vLibraryClass.size() > 0) {
//
// Get selected item index
//
intSelectedItemId = jComboBoxList.getSelectedIndex();
this.jComboBoxLibraryClassName.setSelectedItem(vLibraryClass.getLibraryClass(intSelectedItemId)
.getLibraryClassName());
this.jComboBoxUsage.setSelectedItem(vLibraryClass.getLibraryClass(intSelectedItemId).getUsage());
this.jTextFieldRecommendedInstanceVersion.setText(vLibraryClass.getLibraryClass(intSelectedItemId)
.getRecommendedInstanceVersion());
this.jTextFieldRecommendedInstanceGuid.setText(vLibraryClass.getLibraryClass(intSelectedItemId)
.getRecommendedInstanceGuid());
this.jTextFieldFeatureFlag.setText(vLibraryClass.getLibraryClass(intSelectedItemId).getFeatureFlag());
this.iCheckBoxListArch.setAllItemsUnchecked();
this.iCheckBoxListArch.initCheckedItem(true, vLibraryClass.getLibraryClass(intSelectedItemId)
.getSupArchList());
this.iCheckBoxListModule.setAllItemsUnchecked();
this.iCheckBoxListModule.initCheckedItem(true, vLibraryClass.getLibraryClass(intSelectedItemId)
.getSupModuleList());
this.jTextFieldHelpText.setText(vLibraryClass.getLibraryClass(intSelectedItemId).getHelp());
} else {
}
reloadListArea();
}
/**
Update list area pane via the elements of Vector
**/
private void reloadListArea() {
String strListItem = "";
for (int index = 0; index < vLibraryClass.size(); index++) {
strListItem = strListItem + vLibraryClass.getLibraryClass(index).getLibraryClassName()
+ DataType.UNIX_LINE_SEPARATOR;
}
this.jTextAreaList.setText(strListItem);
}
/* (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();
}
}
/* (non-Javadoc)
* @see java.awt.event.ComponentListener#componentResized(java.awt.event.ComponentEvent)
*
* Override componentResized to resize all components when frame's size is changed
*/
public void componentResized(ComponentEvent arg0) {
int intCurrentWidth = this.getJContentPane().getWidth();
int intCurrentHeight = this.getJContentPane().getHeight();
int intPreferredWidth = this.getJContentPane().getPreferredSize().width;
int intPreferredHeight = this.getJContentPane().getPreferredSize().height;
resizeComponentWidth(this.jComboBoxLibraryClassName, intCurrentWidth, intPreferredWidth);
resizeComponentWidth(this.jComboBoxUsage, intCurrentWidth, intPreferredWidth);
resizeComponentWidth(this.jTextFieldHelpText, intCurrentWidth, intPreferredWidth);
resizeComponentWidth(this.jTextFieldRecommendedInstanceVersion, intCurrentWidth, intPreferredWidth);
resizeComponentWidth(this.jTextFieldRecommendedInstanceGuid, intCurrentWidth, intPreferredWidth);
resizeComponentWidth(this.jTextFieldFeatureFlag, intCurrentWidth, intPreferredWidth);
resizeComponentWidth(this.jScrollPaneArch, intCurrentWidth, intPreferredWidth);
resizeComponentWidth(this.jScrollPaneModuleList, intCurrentWidth, intPreferredWidth);
relocateComponentX(this.jButtonGenerateGuid, intCurrentWidth, intPreferredWidth,
DataType.SPACE_TO_RIGHT_FOR_GENERATE_BUTTON);
resizeComponentWidth(this.jComboBoxList, intCurrentWidth, intPreferredWidth);
resizeComponent(this.jScrollPaneList, intCurrentWidth, intCurrentHeight, intPreferredWidth, intPreferredHeight);
relocateComponentX(this.jButtonAdd, intCurrentWidth, intPreferredWidth, DataType.SPACE_TO_RIGHT_FOR_ADD_BUTTON);
relocateComponentX(this.jButtonRemove, intCurrentWidth, intPreferredWidth,
DataType.SPACE_TO_RIGHT_FOR_REMOVE_BUTTON);
relocateComponentX(this.jButtonUpdate, intCurrentWidth, intPreferredWidth,
DataType.SPACE_TO_RIGHT_FOR_UPDATE_BUTTON);
}
}

View File

@@ -0,0 +1,862 @@
/** @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.frameworkwizard.module.ui;
import java.awt.event.ActionEvent;
import java.awt.event.ComponentEvent;
import java.awt.event.ItemEvent;
import java.util.Vector;
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.PcdCodedDocument;
import org.tianocore.PcdItemTypes;
import org.tianocore.ModuleSurfaceAreaDocument.ModuleSurfaceArea;
import org.tianocore.PcdCodedDocument.PcdCoded;
import org.tianocore.PcdCodedDocument.PcdCoded.PcdEntry;
import org.tianocore.frameworkwizard.common.DataType;
import org.tianocore.frameworkwizard.common.DataValidation;
import org.tianocore.frameworkwizard.common.EnumerationData;
import org.tianocore.frameworkwizard.common.Log;
import org.tianocore.frameworkwizard.common.OpeningModuleType;
import org.tianocore.frameworkwizard.common.Tools;
import org.tianocore.frameworkwizard.common.ui.IInternalFrame;
import org.tianocore.frameworkwizard.common.ui.StarLabel;
import org.tianocore.frameworkwizard.common.ui.iCheckBoxList.ICheckBoxList;
import org.tianocore.frameworkwizard.module.Identification.PcdCoded.PcdCodedIdentification;
import org.tianocore.frameworkwizard.module.Identification.PcdCoded.PcdCodedVector;
import org.tianocore.frameworkwizard.workspace.WorkspaceTools;
/**
The class is used to create, update PCD of MSA/MBD file
It extends IInternalFrame
**/
public class ModulePCDs extends IInternalFrame {
///
/// Define class Serial Version UID
///
private static final long serialVersionUID = 2227717658188438696L;
//
//Define class members
//
private JPanel jContentPane = null;
private JLabel jLabelItemType = null;
private JLabel jLabelC_Name = null;
private JComboBox jComboBoxItemType = null;
private JComboBox jComboBoxCName = null;
private JLabel jLabelDefaultValue = null;
private JTextField jTextFieldDefaultValue = null;
private StarLabel jStarLabel1 = null;
private StarLabel jStarLabel2 = null;
private StarLabel jStarLabel3 = null;
private JLabel jLabelHelpText = null;
private JTextField jTextFieldHelpText = null;
private JTextArea jTextAreaList = null;
private JComboBox jComboBoxList = null;
private JButton jButtonAdd = null;
private JButton jButtonRemove = null;
private JButton jButtonUpdate = null;
private JScrollPane jScrollPane = null;
private JScrollPane jScrollPaneList = null;
private JLabel jLabelTokenSpaceGuid = null;
private JTextField jTextFieldTokenSpaceGuid = null;
private JLabel jLabelFeatureFlag = null;
private JTextField jTextFieldFeatureFlag = null;
private JLabel jLabelArch = null;
private ICheckBoxList iCheckBoxListArch = null;
private JScrollPane jScrollPaneArch = null;
//
// Not used by UI
//
private int intSelectedItemId = 0;
private OpeningModuleType omt = null;
private ModuleSurfaceArea msa = null;
private PcdCodedDocument.PcdCoded pcds = null;
private PcdCodedIdentification id = null;
private PcdCodedVector vid = new PcdCodedVector();
private EnumerationData ed = new EnumerationData();
private WorkspaceTools wt = new WorkspaceTools();
/**
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, 35, 320, 20));
jComboBoxItemType.setPreferredSize(new java.awt.Dimension(320, 20));
}
return jComboBoxItemType;
}
/**
This method initializes jTextFieldC_Name
@return javax.swing.JTextField jTextFieldC_Name
**/
private JComboBox getJComboBoxCName() {
if (jComboBoxCName == null) {
jComboBoxCName = new JComboBox();
jComboBoxCName.setBounds(new java.awt.Rectangle(160, 10, 320, 20));
jComboBoxCName.setPreferredSize(new java.awt.Dimension(320, 20));
}
return jComboBoxCName;
}
/**
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));
jTextFieldDefaultValue.setPreferredSize(new java.awt.Dimension(320, 20));
}
return jTextFieldDefaultValue;
}
/**
* This method initializes jTextFieldHelpText
*
* @return javax.swing.JTextField
*/
private JTextField getJTextFieldHelpText() {
if (jTextFieldHelpText == null) {
jTextFieldHelpText = new JTextField();
jTextFieldHelpText.setBounds(new java.awt.Rectangle(160, 110, 320, 20));
jTextFieldHelpText.setPreferredSize(new java.awt.Dimension(320, 20));
}
return jTextFieldHelpText;
}
/**
This method initializes jComboBoxFileList
@return javax.swing.JComboBox jComboBoxFileList
**/
private JComboBox getJComboBoxList() {
if (jComboBoxList == null) {
jComboBoxList = new JComboBox();
jComboBoxList.setBounds(new java.awt.Rectangle(15, 245, 210, 20));
jComboBoxList.addItemListener(this);
jComboBoxList.addActionListener(this);
jComboBoxList.setPreferredSize(new java.awt.Dimension(210, 20));
}
return jComboBoxList;
}
/**
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, 245, 80, 20));
jButtonAdd.setText("Add");
jButtonAdd.addActionListener(this);
jButtonAdd.setPreferredSize(new java.awt.Dimension(80, 20));
}
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, 245, 80, 20));
jButtonRemove.setText("Remove");
jButtonRemove.addActionListener(this);
jButtonRemove.setPreferredSize(new java.awt.Dimension(80, 20));
}
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, 245, 80, 20));
jButtonUpdate.setPreferredSize(new java.awt.Dimension(80, 20));
jButtonUpdate.setText("Update");
jButtonUpdate.addActionListener(this);
}
return jButtonUpdate;
}
/**
* This method initializes jScrollPaneFileList
*
* @return javax.swing.JScrollPane
*/
private JScrollPane getJScrollPaneList() {
if (jScrollPaneList == null) {
jScrollPaneList = new JScrollPane();
jScrollPaneList.setBounds(new java.awt.Rectangle(15, 270, 465, 240));
jScrollPaneList.setViewportView(getJTextAreaList());
jScrollPaneList.setPreferredSize(new java.awt.Dimension(465, 240));
}
return jScrollPaneList;
}
/**
This method initializes jScrollPane
@return javax.swing.JScrollPane
*/
private JScrollPane getJScrollPane() {
if (jScrollPane == null) {
jScrollPane = new JScrollPane();
jScrollPane.setViewportView(getJContentPane());
}
return jScrollPane;
}
/**
* This method initializes jTextAreaFileList
*
* @return javax.swing.JTextArea
*/
private JTextArea getJTextAreaList() {
if (jTextAreaList == null) {
jTextAreaList = new JTextArea();
jTextAreaList.setEditable(false);
}
return jTextAreaList;
}
/**
* This method initializes jTextFieldTokenSpaceGuid
*
* @return javax.swing.JTextField
*/
private JTextField getJTextFieldTokenSpaceGuid() {
if (jTextFieldTokenSpaceGuid == null) {
jTextFieldTokenSpaceGuid = new JTextField();
jTextFieldTokenSpaceGuid.setBounds(new java.awt.Rectangle(160, 60, 320, 20));
jTextFieldTokenSpaceGuid.setPreferredSize(new java.awt.Dimension(320, 20));
}
return jTextFieldTokenSpaceGuid;
}
/**
* 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.setPreferredSize(new java.awt.Dimension(320, 20));
}
return jTextFieldFeatureFlag;
}
/**
This method initializes iCheckBoxListArch
@return ICheckBoxList
**/
private ICheckBoxList getICheckBoxListSupportedArchitectures() {
if (iCheckBoxListArch == null) {
iCheckBoxListArch = new ICheckBoxList();
iCheckBoxListArch.addFocusListener(this);
iCheckBoxListArch.setToolTipText(DataType.SUP_ARCH_LIST_HELP_TEXT);
}
return iCheckBoxListArch;
}
/**
This method initializes jScrollPaneArch
@return javax.swing.JScrollPane
**/
private JScrollPane getJScrollPaneArch() {
if (jScrollPaneArch == null) {
jScrollPaneArch = new JScrollPane();
jScrollPaneArch.setBounds(new java.awt.Rectangle(160, 160, 320, 80));
jScrollPaneArch.setPreferredSize(new java.awt.Dimension(320, 80));
jScrollPaneArch.setViewportView(getICheckBoxListSupportedArchitectures());
}
return jScrollPaneArch;
}
public static void main(String[] args) {
}
/**
This method initializes this
**/
private void init() {
this.setSize(500, 515);
this.setContentPane(getJScrollPane());
this.setTitle("Pcd Coded");
initFrame();
this.setViewMode(false);
}
/**
This method initializes this
Fill values to all fields if these values are not empty
@param inPackageDependencies
**/
private void init(PcdCoded inPcdCodeds) {
init();
this.pcds = inPcdCodeds;
if (this.pcds != null) {
if (this.pcds.getPcdEntryList().size() > 0) {
for (int index = 0; index < this.pcds.getPcdEntryList().size(); index++) {
String arg0 = pcds.getPcdEntryList().get(index).getCName();
String arg1 = pcds.getPcdEntryList().get(index).getTokenSpaceGuidCName();
String arg2 = pcds.getPcdEntryList().get(index).getFeatureFlag();
Vector<String> arg3 = Tools.convertListToVector(pcds.getPcdEntryList().get(index).getSupArchList());
String arg4 = pcds.getPcdEntryList().get(index).getDefaultValue();
String arg5 = pcds.getPcdEntryList().get(index).getHelpText();
String arg6 = null;
if (pcds.getPcdEntryList().get(index).getPcdItemType() != null) {
arg6 = pcds.getPcdEntryList().get(index).getPcdItemType().toString();
}
id = new PcdCodedIdentification(arg0, arg1, arg2, arg3, arg4, arg5, arg6);
vid.addPcdCoded(id);
}
}
}
//
// Update the list
//
Tools.generateComboBoxByVector(jComboBoxList, vid.getPcdCodedName());
reloadListArea();
}
/**
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(OpeningModuleType inOmt) {
super();
this.omt = inOmt;
this.msa = omt.getXmlMsa();
init(msa.getPcdCoded());
this.setVisible(true);
}
/**
Disable all components when the mode is view
@param isView true - The view mode; false - The non-view mode
**/
public void setViewMode(boolean isView) {
if (isView) {
this.jTextFieldDefaultValue.setEnabled(!isView);
this.jComboBoxItemType.setEnabled(!isView);
}
}
/**
This method initializes jContentPane
@return javax.swing.JPanel jContentPane
**/
private JPanel getJContentPane() {
if (jContentPane == null) {
jLabelArch = new JLabel();
jLabelArch.setBounds(new java.awt.Rectangle(15, 160, 140, 20));
jLabelArch.setText("Sup Arch List");
jLabelFeatureFlag = new JLabel();
jLabelFeatureFlag.setBounds(new java.awt.Rectangle(15, 135, 140, 20));
jLabelFeatureFlag.setText("Feature Flag");
jLabelTokenSpaceGuid = new JLabel();
jLabelTokenSpaceGuid.setBounds(new java.awt.Rectangle(15, 60, 140, 20));
jLabelTokenSpaceGuid.setText("Token Space C_Name");
jLabelHelpText = new JLabel();
jLabelHelpText.setBounds(new java.awt.Rectangle(15, 110, 137, 19));
jLabelHelpText.setText("Help Text");
jLabelC_Name = new JLabel();
jLabelC_Name.setText("C_Name");
jLabelC_Name.setBounds(new java.awt.Rectangle(15, 10, 140, 20));
jLabelDefaultValue = new JLabel();
jLabelDefaultValue.setText("Default Value");
jLabelDefaultValue.setBounds(new java.awt.Rectangle(15, 85, 140, 20));
jLabelItemType = new JLabel();
jLabelItemType.setText("Item Type");
jLabelItemType.setBounds(new java.awt.Rectangle(15, 35, 140, 20));
jContentPane = new JPanel();
jContentPane.setLayout(null);
jContentPane.setPreferredSize(new java.awt.Dimension(490, 520));
jContentPane.add(jLabelItemType, null);
jContentPane.add(jLabelC_Name, null);
jContentPane.add(getJComboBoxCName(), null);
jContentPane.add(jLabelDefaultValue, null);
jContentPane.add(getJTextFieldDefaultValue(), null);
jContentPane.add(getJComboBoxItemType(), 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, 110));
jContentPane.add(jStarLabel1, null);
jContentPane.add(jStarLabel2, null);
jContentPane.add(jStarLabel3, null);
jContentPane.add(jLabelHelpText, null);
jContentPane.add(getJTextFieldHelpText(), null);
jContentPane.add(getJComboBoxList(), null);
jContentPane.add(getJButtonAdd(), null);
jContentPane.add(getJButtonRemove(), null);
jContentPane.add(getJButtonUpdate(), null);
jContentPane.add(getJScrollPaneList(), null);
jContentPane.add(jLabelTokenSpaceGuid, null);
jContentPane.add(getJTextFieldTokenSpaceGuid(), null);
jContentPane.add(jLabelFeatureFlag, null);
jContentPane.add(getJTextFieldFeatureFlag(), null);
jContentPane.add(jLabelArch, null);
jContentPane.add(getJScrollPaneArch(), null);
}
return jContentPane;
}
/**
This method initializes Usage type, Item type and Datum type
**/
private void initFrame() {
Tools.generateComboBoxByVector(jComboBoxCName, wt.getAllPcdDeclarationsFromWorkspace());
Tools.generateComboBoxByVector(jComboBoxItemType, ed.getVPcdItemTypes());
this.iCheckBoxListArch.setAllItems(ed.getVSupportedArchitectures());
}
/* (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() == jButtonAdd) {
if (!checkAdd()) {
return;
}
addToList();
}
if (arg0.getSource() == jButtonRemove) {
removeFromList();
}
if (arg0.getSource() == jButtonUpdate) {
if (!checkAdd()) {
return;
}
updateForList();
}
}
/**
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 fields have correct data types
//
//
// Check C_Name
//
if (!isEmpty(this.jComboBoxCName.getSelectedItem().toString())) {
if (!DataValidation.isC_NameType(this.jComboBoxCName.getSelectedItem().toString())) {
Log.err("Incorrect data type for C_Name");
return false;
}
}
//
// Check TokenSpaceGuid
//
if (!isEmpty(this.jTextFieldTokenSpaceGuid.getText())) {
if (!DataValidation.isGuid(this.jTextFieldTokenSpaceGuid.getText())) {
Log.err("Incorrect data type for Token Space C_Name");
return false;
}
}
//
// Check DefaultValue
//
if (!isEmpty(this.jTextFieldDefaultValue.getText())) {
if (!DataValidation.isDefaultValueType(this.jTextFieldDefaultValue.getText())) {
Log.err("Incorrect data type for Default Value");
return false;
}
}
//
// Check HelpText
//
if (isEmpty(this.jTextFieldHelpText.getText())) {
Log.err("Help Text couldn't be empty");
return false;
}
//
// Check FeatureFlag
//
if (!isEmpty(this.jTextFieldFeatureFlag.getText())) {
if (!DataValidation.isFeatureFlag(this.jTextFieldFeatureFlag.getText())) {
Log.err("Incorrect data type for Feature Flag");
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 {
int count = this.vid.size();
this.pcds = PcdCoded.Factory.newInstance();
if (count > 0) {
for (int index = 0; index < count; index++) {
PcdEntry p = PcdEntry.Factory.newInstance();
if (!isEmpty(vid.getPcdCoded(index).getName())) {
p.setCName(vid.getPcdCoded(index).getName());
}
if (!isEmpty(vid.getPcdCoded(index).getGuid())) {
p.setTokenSpaceGuidCName(vid.getPcdCoded(index).getGuid());
}
if (!isEmpty(vid.getPcdCoded(index).getFeatureFlag())) {
p.setFeatureFlag(vid.getPcdCoded(index).getFeatureFlag());
}
if (vid.getPcdCoded(index).getSupArchList() != null && vid.getPcdCoded(index).getSupArchList().size() > 0) {
p.setSupArchList(vid.getPcdCoded(index).getSupArchList());
}
if (!isEmpty(vid.getPcdCoded(index).getValue())) {
p.setDefaultValue(vid.getPcdCoded(index).getValue());
}
if (!isEmpty(vid.getPcdCoded(index).getHelp())) {
p.setHelpText(vid.getPcdCoded(index).getHelp());
}
if (!isEmpty(vid.getPcdCoded(index).getType())) {
p.setPcdItemType(PcdItemTypes.Enum.forString(vid.getPcdCoded(index).getType()));
}
this.pcds.addNewPcdEntry();
this.pcds.setPcdEntryArray(pcds.getPcdEntryList().size() - 1, p);
}
}
this.msa.setPcdCoded(pcds);
this.omt.setSaved(false);
} catch (Exception e) {
Log.err("Update Hobs", e.getMessage());
}
}
/* (non-Javadoc)
* @see java.awt.event.ComponentListener#componentResized(java.awt.event.ComponentEvent)
*
* Override componentResized to resize all components when frame's size is changed
*/
public void componentResized(ComponentEvent arg0) {
int intCurrentWidth = this.getJContentPane().getWidth();
int intCurrentHeight = this.getJContentPane().getHeight();
int intPreferredWidth = this.getJContentPane().getPreferredSize().width;
int intPreferredHeight = this.getJContentPane().getPreferredSize().height;
resizeComponentWidth(jComboBoxCName, intCurrentWidth, intPreferredWidth);
resizeComponentWidth(jTextFieldTokenSpaceGuid, intCurrentWidth, intPreferredWidth);
resizeComponentWidth(jComboBoxItemType, intCurrentWidth, intPreferredWidth);
resizeComponentWidth(jTextFieldDefaultValue, intCurrentWidth, intPreferredWidth);
resizeComponentWidth(jTextFieldHelpText, intCurrentWidth, intPreferredWidth);
resizeComponentWidth(jTextFieldFeatureFlag, intCurrentWidth, intPreferredWidth);
resizeComponentWidth(jScrollPaneArch, intCurrentWidth, intPreferredWidth);
resizeComponentWidth(jComboBoxList, intCurrentWidth, intPreferredWidth);
resizeComponent(jScrollPaneList, intCurrentWidth, intCurrentHeight, intPreferredWidth, intPreferredHeight);
relocateComponentX(jButtonAdd, intCurrentWidth, intPreferredWidth, DataType.SPACE_TO_RIGHT_FOR_ADD_BUTTON);
relocateComponentX(jButtonRemove, intCurrentWidth, intPreferredWidth, DataType.SPACE_TO_RIGHT_FOR_REMOVE_BUTTON);
relocateComponentX(jButtonUpdate, intCurrentWidth, intPreferredWidth, DataType.SPACE_TO_RIGHT_FOR_UPDATE_BUTTON);
}
private PcdCodedIdentification getCurrentPcdCoded() {
String arg0 = this.jComboBoxCName.getSelectedItem().toString();
String arg1 = this.jTextFieldTokenSpaceGuid.getText();
String arg2 = this.jTextFieldFeatureFlag.getText();
Vector<String> arg3 = this.iCheckBoxListArch.getAllCheckedItemsString();
String arg4 = this.jTextFieldDefaultValue.getText();
String arg5 = this.jTextFieldHelpText.getText();
String arg6 = this.jComboBoxItemType.getSelectedItem().toString();
id = new PcdCodedIdentification(arg0, arg1, arg2, arg3, arg4, arg5, arg6);
return id;
}
/**
Add current item to Vector
**/
private void addToList() {
intSelectedItemId = vid.size();
vid.addPcdCoded(getCurrentPcdCoded());
jComboBoxList.addItem(id.getName());
jComboBoxList.setSelectedItem(id.getName());
//
// Reset select item index
//
intSelectedItemId = vid.size();
//
// Reload all fields of selected item
//
reloadFromList();
//
// Save to memory
//
save();
}
/**
Remove current item from Vector
**/
private void removeFromList() {
//
// Check if exist items
//
if (this.vid.size() < 1) {
return;
}
int intTempIndex = intSelectedItemId;
jComboBoxList.removeItemAt(intSelectedItemId);
vid.removePcdCoded(intTempIndex);
//
// Reload all fields of selected item
//
reloadFromList();
//
// Save to memory
//
save();
}
/**
Update current item of Vector
**/
private void updateForList() {
//
// Check if exist items
//
if (this.vid.size() < 1) {
return;
}
//
// Backup selected item index
//
int intTempIndex = intSelectedItemId;
vid.updatePcdCoded(getCurrentPcdCoded(), intTempIndex);
jComboBoxList.removeAllItems();
for (int index = 0; index < vid.size(); index++) {
jComboBoxList.addItem(vid.getPcdCoded(index).getName());
}
//
// Restore selected item index
//
intSelectedItemId = intTempIndex;
//
// Reset select item index
//
jComboBoxList.setSelectedIndex(intSelectedItemId);
//
// Reload all fields of selected item
//
reloadFromList();
//
// Save to memory
//
save();
}
/**
Refresh all fields' values of selected item of Vector
**/
private void reloadFromList() {
if (vid.size() > 0) {
//
// Get selected item index
//
intSelectedItemId = jComboBoxList.getSelectedIndex();
this.jComboBoxCName.setSelectedItem(vid.getPcdCoded(intSelectedItemId).getName());
this.jTextFieldTokenSpaceGuid.setText(vid.getPcdCoded(intSelectedItemId).getGuid());
this.jTextFieldDefaultValue.setText(vid.getPcdCoded(intSelectedItemId).getValue());
this.jTextFieldHelpText.setText(vid.getPcdCoded(intSelectedItemId).getHelp());
this.jComboBoxItemType.setSelectedItem(vid.getPcdCoded(intSelectedItemId).getType());
jTextFieldFeatureFlag.setText(vid.getPcdCoded(intSelectedItemId).getFeatureFlag());
iCheckBoxListArch.setAllItemsUnchecked();
iCheckBoxListArch.initCheckedItem(true, vid.getPcdCoded(intSelectedItemId).getSupArchList());
} else {
}
reloadListArea();
}
/**
Update list area pane via the elements of Vector
**/
private void reloadListArea() {
String strListItem = "";
for (int index = 0; index < vid.size(); index++) {
strListItem = strListItem + vid.getPcdCoded(index).getName() + DataType.UNIX_LINE_SEPARATOR;
}
this.jTextAreaList.setText(strListItem);
}
/* (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.getSource() == this.jComboBoxList && arg0.getStateChange() == ItemEvent.SELECTED) {
reloadFromList();
}
}
}

View File

@@ -0,0 +1,827 @@
/** @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.frameworkwizard.module.ui;
import java.awt.event.ActionEvent;
import java.awt.event.ComponentEvent;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.util.Vector;
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.PackageDependenciesDocument;
import org.tianocore.ModuleSurfaceAreaDocument.ModuleSurfaceArea;
import org.tianocore.PackageDependenciesDocument.PackageDependencies;
import org.tianocore.PackageDependenciesDocument.PackageDependencies.Package;
import org.tianocore.frameworkwizard.common.DataType;
import org.tianocore.frameworkwizard.common.DataValidation;
import org.tianocore.frameworkwizard.common.EnumerationData;
import org.tianocore.frameworkwizard.common.Log;
import org.tianocore.frameworkwizard.common.OpeningModuleType;
import org.tianocore.frameworkwizard.common.Tools;
import org.tianocore.frameworkwizard.common.ui.IInternalFrame;
import org.tianocore.frameworkwizard.common.ui.StarLabel;
import org.tianocore.frameworkwizard.common.ui.iCheckBoxList.ICheckBoxList;
import org.tianocore.frameworkwizard.module.Identification.PackageDependencies.PackageDependenciesIdentification;
import org.tianocore.frameworkwizard.module.Identification.PackageDependencies.PackageDependenciesVector;
import org.tianocore.frameworkwizard.packaging.PackageIdentification;
import org.tianocore.frameworkwizard.workspace.WorkspaceTools;
/**
The class is used to create, update Include of MSA/MBD file
It extends IInternalFrame
**/
public class ModulePackageDependencies extends IInternalFrame implements ItemListener {
///
/// Define class Serial Version UID
///
private static final long serialVersionUID = 3465193035145152131L;
//
//Define class members
//
private JPanel jContentPane = null;
private JLabel jLabelPackageName = null;
private StarLabel jStarLabel1 = null;
private JComboBox jComboBoxPackageName = null;
private JLabel jLabelPackageGuid = null;
private JTextField jTextFieldPackageGuid = null;
private JButton jButtonGenerateGuid = null;
private JLabel jLabelPackageVersion = null;
private JTextField jTextFieldPackageVersion = null;
private JLabel jLabelFeatureFlag = null;
private JTextField jTextFieldFeatureFlag = null;
private JTextArea jTextAreaList = null;
private JComboBox jComboBoxList = null;
private JButton jButtonAdd = null;
private JButton jButtonRemove = null;
private JButton jButtonUpdate = null;
private JScrollPane jScrollPane = null;
private JScrollPane jScrollPaneList = null;
private JLabel jLabelArch = null;
private ICheckBoxList iCheckBoxListArch = null;
private JScrollPane jScrollPaneArch = null;
//
// Not used by UI
//
private int intSelectedItemId = 0;
private OpeningModuleType omt = null;
private ModuleSurfaceArea msa = null;
private PackageDependenciesIdentification id = null;
private PackageDependenciesVector vid = new PackageDependenciesVector();
private PackageDependenciesDocument.PackageDependencies packageDependencies = null;
private WorkspaceTools wt = new WorkspaceTools();
private Vector<PackageIdentification> vPackage = wt.getAllPackages();
/**
* 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));
jComboBoxPackageName.setPreferredSize(new java.awt.Dimension(320, 20));
jComboBoxPackageName.setToolTipText("If your Module requires a package list that here.");
jComboBoxPackageName.addItemListener(this);
}
return jComboBoxPackageName;
}
/**
* This method initializes jTextFieldPackageGuid
*
* @return javax.swing.JTextField
*/
private JTextField getJTextFieldPackageGuid() {
if (jTextFieldPackageGuid == null) {
jTextFieldPackageGuid = new JTextField();
jTextFieldPackageGuid.setBounds(new java.awt.Rectangle(160, 35, 320, 20));
jTextFieldPackageGuid.setPreferredSize(new java.awt.Dimension(320, 20));
jTextFieldPackageGuid.setEditable(false);
}
return jTextFieldPackageGuid;
}
/**
* This method initializes jButtonGenerateGuid
*
* @return javax.swing.JButton
*/
private JButton getJButtonGenerateGuid() {
if (jButtonGenerateGuid == null) {
jButtonGenerateGuid = new JButton();
jButtonGenerateGuid.setBounds(new java.awt.Rectangle(415, 35, 65, 20));
jButtonGenerateGuid.setPreferredSize(new java.awt.Dimension(65, 20));
jButtonGenerateGuid.setText("GEN");
jButtonGenerateGuid.addActionListener(this);
jButtonGenerateGuid.setVisible(false);
}
return jButtonGenerateGuid;
}
/**
* This method initializes jTextFieldPackageVersion
*
* @return javax.swing.JTextField
*/
private JTextField getJTextFieldPackageVersion() {
if (jTextFieldPackageVersion == null) {
jTextFieldPackageVersion = new JTextField();
jTextFieldPackageVersion.setBounds(new java.awt.Rectangle(160, 60, 320, 20));
jTextFieldPackageVersion.setPreferredSize(new java.awt.Dimension(320, 20));
jTextFieldPackageVersion
.setToolTipText("If this module depends on a specific version of a package, enter the package version here. If the module can use the latest version that does not break backward compatibility, leave this field blank");
}
return jTextFieldPackageVersion;
}
/**
* This method initializes jTextFieldFeatureFlag
*
* @return javax.swing.JTextField
*/
private JTextField getJTextFieldFeatureFlag() {
if (jTextFieldFeatureFlag == null) {
jTextFieldFeatureFlag = new JTextField();
jTextFieldFeatureFlag.setBounds(new java.awt.Rectangle(160, 85, 320, 20));
jTextFieldFeatureFlag.setPreferredSize(new java.awt.Dimension(320, 20));
}
return jTextFieldFeatureFlag;
}
/**
This method initializes jComboBoxFileList
@return javax.swing.JComboBox jComboBoxFileList
**/
private JComboBox getJComboBoxList() {
if (jComboBoxList == null) {
jComboBoxList = new JComboBox();
jComboBoxList.setBounds(new java.awt.Rectangle(15, 195, 210, 20));
jComboBoxList.addItemListener(this);
jComboBoxList.addActionListener(this);
jComboBoxList.setPreferredSize(new java.awt.Dimension(210, 20));
}
return jComboBoxList;
}
/**
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, 195, 80, 20));
jButtonAdd.setText("Add");
jButtonAdd.addActionListener(this);
jButtonAdd.setPreferredSize(new java.awt.Dimension(80, 20));
}
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, 195, 80, 20));
jButtonRemove.setText("Remove");
jButtonRemove.addActionListener(this);
jButtonRemove.setPreferredSize(new java.awt.Dimension(80, 20));
}
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, 195, 80, 20));
jButtonUpdate.setPreferredSize(new java.awt.Dimension(80, 20));
jButtonUpdate.setText("Update");
jButtonUpdate.addActionListener(this);
}
return jButtonUpdate;
}
/**
* This method initializes jScrollPaneFileList
*
* @return javax.swing.JScrollPane
*/
private JScrollPane getJScrollPaneList() {
if (jScrollPaneList == null) {
jScrollPaneList = new JScrollPane();
jScrollPaneList.setBounds(new java.awt.Rectangle(15, 220, 465, 240));
jScrollPaneList.setViewportView(getJTextAreaList());
jScrollPaneList.setPreferredSize(new java.awt.Dimension(465, 240));
}
return jScrollPaneList;
}
/**
This method initializes jScrollPane
@return javax.swing.JScrollPane
*/
private JScrollPane getJScrollPane() {
if (jScrollPane == null) {
jScrollPane = new JScrollPane();
jScrollPane.setViewportView(getJContentPane());
}
return jScrollPane;
}
/**
* This method initializes jTextAreaFileList
*
* @return javax.swing.JTextArea
*/
private JTextArea getJTextAreaList() {
if (jTextAreaList == null) {
jTextAreaList = new JTextArea();
jTextAreaList.setEditable(false);
}
return jTextAreaList;
}
/**
This method initializes iCheckBoxListArch
@return ICheckBoxList
**/
private ICheckBoxList getICheckBoxListSupportedArchitectures() {
if (iCheckBoxListArch == null) {
iCheckBoxListArch = new ICheckBoxList();
iCheckBoxListArch.addFocusListener(this);
iCheckBoxListArch.setToolTipText(DataType.SUP_ARCH_LIST_HELP_TEXT);
}
return iCheckBoxListArch;
}
/**
This method initializes jScrollPaneArch
@return javax.swing.JScrollPane
**/
private JScrollPane getJScrollPaneArch() {
if (jScrollPaneArch == null) {
jScrollPaneArch = new JScrollPane();
jScrollPaneArch.setBounds(new java.awt.Rectangle(160, 110, 320, 80));
jScrollPaneArch.setPreferredSize(new java.awt.Dimension(320, 80));
jScrollPaneArch.setViewportView(getICheckBoxListSupportedArchitectures());
}
return jScrollPaneArch;
}
public static void main(String[] args) {
}
/**
This method initializes this
**/
private void init() {
this.setSize(500, 515);
this.setContentPane(getJScrollPane());
this.setTitle("Includes");
initFrame();
this.setViewMode(false);
}
/**
This method initializes this
Fill values to all fields if these values are not empty
@param inPackageDependencies
**/
private void init(PackageDependencies inPackageDependencies) {
init();
this.packageDependencies = inPackageDependencies;
if (this.packageDependencies != null) {
if (this.packageDependencies.getPackageList().size() > 0) {
for (int index = 0; index < this.packageDependencies.getPackageList().size(); index++) {
String arg0 = "";
String arg1 = packageDependencies.getPackageList().get(index).getPackageVersion();
String arg2 = packageDependencies.getPackageList().get(index).getPackageGuid();
//
// If no guid, skip current item
//
if (arg2 == null) {
continue;
}
for (int indexJ = 0; indexJ < this.vPackage.size(); indexJ++) {
if (vPackage.get(indexJ).getGuid().equals(arg2)) {
arg0 = vPackage.get(indexJ).getName();
}
}
String arg3 = packageDependencies.getPackageList().get(index).getFeatureFlag();
Vector<String> arg4 = Tools.convertListToVector(packageDependencies.getPackageList().get(index)
.getSupArchList());
id = new PackageDependenciesIdentification(arg0, arg1, arg2, arg3, arg4);
vid.addPackageDependencies(id);
}
}
}
//
// Update the list
//
Tools.generateComboBoxByVector(jComboBoxList, vid.getPackageDependenciesName());
reloadListArea();
}
/**
This is the default constructor
**/
public ModulePackageDependencies() {
super();
init();
this.setVisible(true);
}
/**
This is the override constructor
**/
public ModulePackageDependencies(OpeningModuleType inOmt) {
super();
this.omt = inOmt;
this.msa = omt.getXmlMsa();
init(msa.getPackageDependencies());
this.setVisible(true);
}
/**
Disable all components when the mode is view
@param isView true - The view mode; false - The non-view mode
**/
public void setViewMode(boolean isView) {
if (isView) {
this.jComboBoxPackageName.setEnabled(!isView);
this.jButtonAdd.setEnabled(!isView);
this.jButtonUpdate.setEnabled(!isView);
this.jButtonRemove.setEnabled(!isView);
}
}
/**
This method initializes jContentPane
@return javax.swing.JPanel jContentPane
**/
private JPanel getJContentPane() {
if (jContentPane == null) {
jLabelArch = new JLabel();
jLabelArch.setBounds(new java.awt.Rectangle(15, 110, 140, 20));
jLabelArch.setText("Sup Arch List");
jLabelPackageVersion = new JLabel();
jLabelPackageVersion.setBounds(new java.awt.Rectangle(15, 60, 140, 20));
jLabelPackageVersion.setText("Package Version");
jLabelPackageGuid = new JLabel();
jLabelPackageGuid.setBounds(new java.awt.Rectangle(15, 35, 140, 20));
jLabelPackageGuid.setText("Package Guid");
jLabelPackageName = new JLabel();
jLabelPackageName.setBounds(new java.awt.Rectangle(15, 10, 140, 20));
jLabelPackageName.setText("Package Name");
jContentPane = new JPanel();
jContentPane.setLayout(null);
jContentPane.setPreferredSize(new java.awt.Dimension(490, 470));
jContentPane.add(jLabelPackageName, null);
jStarLabel1 = new StarLabel();
jStarLabel1.setLocation(new java.awt.Point(0, 35));
jContentPane.add(jStarLabel1, null);
jContentPane.add(getJComboBoxPackageName(), null);
jContentPane.add(jLabelPackageGuid, null);
jContentPane.add(getJTextFieldPackageGuid(), null);
jContentPane.add(getJButtonGenerateGuid(), null);
jContentPane.add(jLabelPackageVersion, null);
jContentPane.add(getJTextFieldPackageVersion(), null);
jLabelFeatureFlag = new JLabel();
jLabelFeatureFlag.setBounds(new java.awt.Rectangle(15, 85, 140, 20));
jLabelFeatureFlag.setText("Feature Flag");
jContentPane.add(jLabelFeatureFlag, null);
jContentPane.add(getJTextFieldFeatureFlag(), null);
jContentPane.add(getJComboBoxList(), null);
jContentPane.add(getJButtonAdd(), null);
jContentPane.add(getJButtonRemove(), null);
jContentPane.add(getJButtonUpdate(), null);
jContentPane.add(getJScrollPaneList(), null);
jContentPane.add(jLabelArch, null);
jContentPane.add(getJScrollPaneArch(), 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() == jButtonAdd) {
if (!checkAdd()) {
return;
}
addToList();
}
if (arg0.getSource() == jButtonRemove) {
removeFromList();
}
if (arg0.getSource() == jButtonUpdate) {
if (!checkAdd()) {
return;
}
updateForList();
}
}
/**
This method initializes Usage type, Package type and Arch type
**/
private void initFrame() {
EnumerationData ed = new EnumerationData();
this.iCheckBoxListArch.setAllItems(ed.getVSupportedArchitectures());
for (int index = 0; index < vPackage.size(); index++) {
jComboBoxPackageName.addItem(vPackage.elementAt(index).getName());
}
//jComboBoxPackageName.addItemListener(this);
}
/**
Data validation for all fields
@retval true - All datas are valid
@retval false - At least one data is invalid
**/
public boolean check() {
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
//
//
// Check PackageGuid
//
if (!isEmpty(this.jTextFieldPackageGuid.getText())) {
if (!DataValidation.isGuid(this.jTextFieldPackageGuid.getText())) {
Log.err("Incorrect data type for Package Guid");
return false;
}
}
//
// Check PackageVersion
//
if (!isEmpty(this.jTextFieldPackageVersion.getText())) {
if (!DataValidation.isVersion(this.jTextFieldPackageVersion.getText())) {
Log.err("Incorrect data type for Package Version");
return false;
}
}
//
// Check FeatureFlag
//
if (!isEmpty(this.jTextFieldFeatureFlag.getText())) {
if (!DataValidation.isFeatureFlag(this.jTextFieldFeatureFlag.getText())) {
Log.err("Incorrect data type for Feature Flag");
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 {
//
//Save as file name
//
int count = this.vid.size();
this.packageDependencies = PackageDependencies.Factory.newInstance();
if (count > 0) {
for (int index = 0; index < count; index++) {
Package p = Package.Factory.newInstance();
if (!isEmpty(vid.getPackageDependencies(index).getVersion())) {
p.setPackageVersion(vid.getPackageDependencies(index).getVersion());
}
if (!isEmpty(vid.getPackageDependencies(index).getGuid())) {
p.setPackageGuid(vid.getPackageDependencies(index).getGuid());
}
if (!isEmpty(vid.getPackageDependencies(index).getFeatureFlag())) {
p.setFeatureFlag(vid.getPackageDependencies(index).getFeatureFlag());
}
if (vid.getPackageDependencies(index).getSupArchList() != null
&& vid.getPackageDependencies(index).getSupArchList().size() > 0) {
p.setSupArchList(vid.getPackageDependencies(index).getSupArchList());
}
this.packageDependencies.addNewPackage();
this.packageDependencies.setPackageArray(index, p);
}
}
this.msa.setPackageDependencies(packageDependencies);
this.omt.setSaved(false);
} catch (Exception e) {
e.printStackTrace();
Log.err("Update Package Dependencies", e.getMessage());
}
}
/* (non-Javadoc)
* @see java.awt.event.ComponentListener#componentResized(java.awt.event.ComponentEvent)
*
* Override componentResized to resize all components when frame's size is changed
*/
public void componentResized(ComponentEvent arg0) {
int intCurrentWidth = this.getJContentPane().getWidth();
int intCurrentHeight = this.getJContentPane().getHeight();
int intPreferredWidth = this.getJContentPane().getPreferredSize().width;
int intPreferredHeight = this.getJContentPane().getPreferredSize().height;
resizeComponentWidth(this.jComboBoxPackageName, intCurrentWidth, intPreferredWidth);
resizeComponentWidth(this.jTextFieldPackageGuid, intCurrentWidth, intPreferredWidth);
resizeComponentWidth(this.jTextFieldPackageVersion, intCurrentWidth, intPreferredWidth);
resizeComponentWidth(this.jTextFieldFeatureFlag, intCurrentWidth, intPreferredWidth);
resizeComponentWidth(this.jScrollPaneArch, intCurrentWidth, intPreferredWidth);
resizeComponentWidth(jComboBoxList, intCurrentWidth, intPreferredWidth);
resizeComponent(jScrollPaneList, intCurrentWidth, intCurrentHeight, intPreferredWidth, intPreferredHeight);
relocateComponentX(jButtonAdd, intCurrentWidth, intPreferredWidth, DataType.SPACE_TO_RIGHT_FOR_ADD_BUTTON);
relocateComponentX(jButtonRemove, intCurrentWidth, intPreferredWidth, DataType.SPACE_TO_RIGHT_FOR_REMOVE_BUTTON);
relocateComponentX(jButtonUpdate, intCurrentWidth, intPreferredWidth, DataType.SPACE_TO_RIGHT_FOR_UPDATE_BUTTON);
relocateComponentX(this.jButtonGenerateGuid, intCurrentWidth, intPreferredWidth,
DataType.SPACE_TO_RIGHT_FOR_GENERATE_BUTTON);
}
private PackageDependenciesIdentification getCurrentPackageDependencies() {
String arg0 = this.jComboBoxPackageName.getSelectedItem().toString();
String arg1 = this.jTextFieldPackageVersion.getText();
String arg2 = this.jTextFieldPackageGuid.getText();
String arg3 = this.jTextFieldFeatureFlag.getText();
Vector<String> arg4 = this.iCheckBoxListArch.getAllCheckedItemsString();
id = new PackageDependenciesIdentification(arg0, arg1, arg2, arg3, arg4);
return id;
}
/**
Add current item to Vector
**/
private void addToList() {
intSelectedItemId = vid.size();
vid.addPackageDependencies(getCurrentPackageDependencies());
jComboBoxList.addItem(id.getName());
jComboBoxList.setSelectedItem(id.getName());
//
// Reset select item index
//
intSelectedItemId = vid.size();
//
// Reload all fields of selected item
//
reloadFromList();
//
// Save to memory
//
save();
}
/**
Remove current item from Vector
**/
private void removeFromList() {
//
// Check if exist items
//
if (this.vid.size() < 1) {
return;
}
int intTempIndex = intSelectedItemId;
jComboBoxList.removeItemAt(intSelectedItemId);
vid.removePackageDependencies(intTempIndex);
//
// Reload all fields of selected item
//
reloadFromList();
//
// Save to memory
//
save();
}
/**
Update current item of Vector
**/
private void updateForList() {
//
// Check if exist items
//
if (this.vid.size() < 1) {
return;
}
//
// Backup selected item index
//
int intTempIndex = intSelectedItemId;
vid.updatePackageDependencies(getCurrentPackageDependencies(), intTempIndex);
jComboBoxList.removeAllItems();
for (int index = 0; index < vid.size(); index++) {
jComboBoxList.addItem(vid.getPackageDependencies(index).getName());
}
//
// Restore selected item index
//
intSelectedItemId = intTempIndex;
//
// Reset select item index
//
jComboBoxList.setSelectedIndex(intSelectedItemId);
//
// Reload all fields of selected item
//
reloadFromList();
//
// Save to memory
//
save();
}
/**
Refresh all fields' values of selected item of Vector
**/
private void reloadFromList() {
if (vid.size() > 0) {
//
// Get selected item index
//
intSelectedItemId = jComboBoxList.getSelectedIndex();
this.jComboBoxPackageName.setSelectedItem(vid.getPackageDependencies(intSelectedItemId).getName());
this.jTextFieldPackageVersion.setText(vid.getPackageDependencies(intSelectedItemId).getVersion());
this.jTextFieldPackageGuid.setText(vid.getPackageDependencies(intSelectedItemId).getGuid());
jTextFieldFeatureFlag.setText(vid.getPackageDependencies(intSelectedItemId).getFeatureFlag());
iCheckBoxListArch.setAllItemsUnchecked();
iCheckBoxListArch.initCheckedItem(true, vid.getPackageDependencies(intSelectedItemId).getSupArchList());
} else {
}
reloadListArea();
}
/**
Update list area pane via the elements of Vector
**/
private void reloadListArea() {
String strListItem = "";
for (int index = 0; index < vid.size(); index++) {
strListItem = strListItem + vid.getPackageDependencies(index).getName() + DataType.UNIX_LINE_SEPARATOR;
}
this.jTextAreaList.setText(strListItem);
}
/* (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.getSource() == this.jComboBoxList && arg0.getStateChange() == ItemEvent.SELECTED) {
reloadFromList();
}
if (arg0.getSource() == this.jComboBoxPackageName && arg0.getStateChange() == ItemEvent.SELECTED) {
for (int index = 0; index < vPackage.size(); index++) {
if (this.jComboBoxPackageName.getSelectedItem().toString().equals(vPackage.get(index).getName())) {
this.jTextFieldPackageGuid.setText(vPackage.get(index).getGuid());
}
}
}
}
}

View File

@@ -0,0 +1,850 @@
/** @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.frameworkwizard.module.ui;
import java.awt.event.ActionEvent;
import java.awt.event.ComponentEvent;
import java.awt.event.ItemEvent;
import java.util.Vector;
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.PPIsDocument;
import org.tianocore.PpiNotifyUsage;
import org.tianocore.PpiUsage;
import org.tianocore.ModuleSurfaceAreaDocument.ModuleSurfaceArea;
import org.tianocore.PPIsDocument.PPIs;
import org.tianocore.PPIsDocument.PPIs.Ppi;
import org.tianocore.PPIsDocument.PPIs.PpiNotify;
import org.tianocore.frameworkwizard.common.DataType;
import org.tianocore.frameworkwizard.common.DataValidation;
import org.tianocore.frameworkwizard.common.EnumerationData;
import org.tianocore.frameworkwizard.common.Log;
import org.tianocore.frameworkwizard.common.OpeningModuleType;
import org.tianocore.frameworkwizard.common.Tools;
import org.tianocore.frameworkwizard.common.ui.IInternalFrame;
import org.tianocore.frameworkwizard.common.ui.StarLabel;
import org.tianocore.frameworkwizard.common.ui.iCheckBoxList.ICheckBoxList;
import org.tianocore.frameworkwizard.module.Identification.Ppis.PpisIdentification;
import org.tianocore.frameworkwizard.module.Identification.Ppis.PpisVector;
import org.tianocore.frameworkwizard.workspace.WorkspaceTools;
/**
The class is used to create, update Ppi of MSA/MBD file
It extends IInternalFrame
**/
public class ModulePpis extends IInternalFrame {
///
/// Define class Serial Version UID
///
private static final long serialVersionUID = -4284901202357037724L;
//
//Define class members
//
private JPanel jContentPane = null;
private JLabel jLabelC_Name = null;
private JComboBox jComboBoxCName = null;
private JTextField jTextFieldFeatureFlag = null;
private JLabel jLabelFeatureFlag = null;
private JLabel jLabelUsage = null;
private JComboBox jComboBoxUsage = null;
private JLabel jLabelPpiType = null;
private StarLabel jStarLabel1 = null;
private StarLabel jStarLabel2 = null;
private JComboBox jComboBoxPpiType = null;
private JLabel jLabelArch = null;
private JTextArea jTextAreaList = null;
private JComboBox jComboBoxList = null;
private JButton jButtonAdd = null;
private JButton jButtonRemove = null;
private JButton jButtonUpdate = null;
private JScrollPane jScrollPane = null;
private JScrollPane jScrollPaneList = null;
private ICheckBoxList iCheckBoxListArch = null;
private JScrollPane jScrollPaneArch = null;
private JLabel jLabelHelpText = null;
private JTextField jTextFieldHelpText = null;
//
// Not used by UI
//
private int intSelectedItemId = 0;
private OpeningModuleType omt = null;
private ModuleSurfaceArea msa = null;
private PPIsDocument.PPIs ppis = null;
private PpisIdentification id = null;
private PpisVector vid = new PpisVector();
private WorkspaceTools wt = new WorkspaceTools();
private EnumerationData ed = new EnumerationData();
/**
This method initializes jTextFieldC_Name
@return javax.swing.JTextField jTextFieldC_Name
**/
private JComboBox getJComboBoxCName() {
if (jComboBoxCName == null) {
jComboBoxCName = new JComboBox();
jComboBoxCName.setBounds(new java.awt.Rectangle(160, 35, 320, 20));
jComboBoxCName.setPreferredSize(new java.awt.Dimension(320, 20));
}
return jComboBoxCName;
}
/**
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, 110, 320, 20));
jTextFieldFeatureFlag.setPreferredSize(new java.awt.Dimension(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, 60, 320, 20));
jComboBoxUsage.setPreferredSize(new java.awt.Dimension(320, 20));
}
return jComboBoxUsage;
}
/**
* This method initializes jComboBoxPpiType
*
* @return javax.swing.JComboBox
*/
private JComboBox getJComboBoxPpiType() {
if (jComboBoxPpiType == null) {
jComboBoxPpiType = new JComboBox();
jComboBoxPpiType.setBounds(new java.awt.Rectangle(160, 10, 320, 20));
jComboBoxPpiType.setPreferredSize(new java.awt.Dimension(320, 20));
jComboBoxPpiType.addItemListener(this);
}
return jComboBoxPpiType;
}
/**
This method initializes jComboBoxFileList
@return javax.swing.JComboBox jComboBoxFileList
**/
private JComboBox getJComboBoxList() {
if (jComboBoxList == null) {
jComboBoxList = new JComboBox();
jComboBoxList.setBounds(new java.awt.Rectangle(15, 220, 210, 20));
jComboBoxList.addItemListener(this);
jComboBoxList.addActionListener(this);
jComboBoxList.setPreferredSize(new java.awt.Dimension(210, 20));
}
return jComboBoxList;
}
/**
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, 220, 80, 20));
jButtonAdd.setText("Add");
jButtonAdd.addActionListener(this);
jButtonAdd.setPreferredSize(new java.awt.Dimension(80, 20));
}
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, 220, 80, 20));
jButtonRemove.setText("Remove");
jButtonRemove.addActionListener(this);
jButtonRemove.setPreferredSize(new java.awt.Dimension(80, 20));
}
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, 220, 80, 20));
jButtonUpdate.setPreferredSize(new java.awt.Dimension(80, 20));
jButtonUpdate.setText("Update");
jButtonUpdate.addActionListener(this);
}
return jButtonUpdate;
}
/**
* This method initializes jScrollPaneFileList
*
* @return javax.swing.JScrollPane
*/
private JScrollPane getJScrollPaneList() {
if (jScrollPaneList == null) {
jScrollPaneList = new JScrollPane();
jScrollPaneList.setBounds(new java.awt.Rectangle(15, 245, 465, 240));
jScrollPaneList.setViewportView(getJTextAreaList());
jScrollPaneList.setPreferredSize(new java.awt.Dimension(465, 240));
}
return jScrollPaneList;
}
/**
This method initializes jScrollPane
@return javax.swing.JScrollPane
*/
private JScrollPane getJScrollPane() {
if (jScrollPane == null) {
jScrollPane = new JScrollPane();
jScrollPane.setViewportView(getJContentPane());
}
return jScrollPane;
}
/**
* This method initializes jTextAreaFileList
*
* @return javax.swing.JTextArea
*/
private JTextArea getJTextAreaList() {
if (jTextAreaList == null) {
jTextAreaList = new JTextArea();
jTextAreaList.setEditable(false);
}
return jTextAreaList;
}
/**
This method initializes iCheckBoxListArch
@return ICheckBoxList
**/
private ICheckBoxList getICheckBoxListSupportedArchitectures() {
if (iCheckBoxListArch == null) {
iCheckBoxListArch = new ICheckBoxList();
iCheckBoxListArch.addFocusListener(this);
iCheckBoxListArch.setToolTipText(DataType.SUP_ARCH_LIST_HELP_TEXT);
}
return iCheckBoxListArch;
}
/**
This method initializes jScrollPaneArch
@return javax.swing.JScrollPane
**/
private JScrollPane getJScrollPaneArch() {
if (jScrollPaneArch == null) {
jScrollPaneArch = new JScrollPane();
jScrollPaneArch.setBounds(new java.awt.Rectangle(160, 135, 320, 80));
jScrollPaneArch.setPreferredSize(new java.awt.Dimension(320, 80));
jScrollPaneArch.setViewportView(getICheckBoxListSupportedArchitectures());
}
return jScrollPaneArch;
}
/**
This method initializes jTextFieldHelpText
@return javax.swing.JTextField
**/
private JTextField getJTextFieldHelpText() {
if (jTextFieldHelpText == null) {
jTextFieldHelpText = new JTextField();
jTextFieldHelpText.setBounds(new java.awt.Rectangle(160, 85, 320, 20));
jTextFieldHelpText.setPreferredSize(new java.awt.Dimension(320, 20));
}
return jTextFieldHelpText;
}
public static void main(String[] args) {
}
/**
This method initializes this
**/
private void init() {
this.setSize(500, 515);
this.setContentPane(getJScrollPane());
this.setTitle("Ppis");
initFrame();
this.setViewMode(false);
}
/**
This method initializes this
Fill values to all fields if these values are not empty
@param inPackageDependencies
**/
private void init(PPIs inPpis) {
init();
this.ppis = inPpis;
if (this.ppis != null) {
if (this.ppis.getPpiList().size() > 0) {
for (int index = 0; index < this.ppis.getPpiList().size(); index++) {
String arg0 = ppis.getPpiList().get(index).getPpiCName();
String arg1 = ed.getVPpiType().get(0);
String arg2 = null;
if (ppis.getPpiList().get(index).getUsage() != null) {
arg2 = ppis.getPpiList().get(index).getUsage().toString();
}
String arg3 = ppis.getPpiList().get(index).getFeatureFlag();
Vector<String> arg4 = Tools.convertListToVector(ppis.getPpiList().get(index)
.getSupArchList());
String arg5 = ppis.getPpiList().get(index).getHelpText();
id = new PpisIdentification(arg0, arg1, arg2, arg3, arg4, arg5);
vid.addPpis(id);
}
}
if (this.ppis.getPpiNotifyList().size() > 0) {
for (int index = 0; index < this.ppis.getPpiNotifyList().size(); index++) {
String arg0 = ppis.getPpiNotifyList().get(index).getPpiNotifyCName();
String arg1 = ed.getVPpiType().get(1);
String arg2 = null;
if (ppis.getPpiNotifyList().get(index).getUsage() != null) {
arg2 = ppis.getPpiNotifyList().get(index).getUsage().toString();
}
String arg3 = ppis.getPpiNotifyList().get(index).getFeatureFlag();
Vector<String> arg4 = Tools.convertListToVector(ppis.getPpiNotifyList().get(index)
.getSupArchList());
String arg5 = ppis.getPpiNotifyList().get(index).getHelpText();
id = new PpisIdentification(arg0, arg1, arg2, arg3, arg4, arg5);
vid.addPpis(id);
}
}
}
//
// Update the list
//
Tools.generateComboBoxByVector(jComboBoxList, vid.getPpisName());
reloadListArea();
}
/**
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(OpeningModuleType inOmt) {
super();
this.omt = inOmt;
this.msa = omt.getXmlMsa();
init(msa.getPPIs());
this.setVisible(true);
}
/**
Disable all components when the mode is view
@param isView true - The view mode; false - The non-view mode
**/
public void setViewMode(boolean isView) {
if (isView) {
this.jComboBoxCName.setEnabled(!isView);
this.jComboBoxUsage.setEnabled(!isView);
this.jTextFieldFeatureFlag.setEnabled(!isView);
}
}
/**
This method initializes jContentPane
@return javax.swing.JPanel jContentPane
**/
private JPanel getJContentPane() {
if (jContentPane == null) {
jLabelArch = new JLabel();
jLabelArch.setBounds(new java.awt.Rectangle(15, 135, 140, 20));
jLabelArch.setText("Arch");
jLabelPpiType = new JLabel();
jLabelPpiType.setBounds(new java.awt.Rectangle(15, 10, 140, 20));
jLabelPpiType.setText("Ppi Type");
jLabelUsage = new JLabel();
jLabelUsage.setText("Usage");
jLabelUsage.setBounds(new java.awt.Rectangle(15, 60, 140, 20));
jLabelFeatureFlag = new JLabel();
jLabelFeatureFlag.setText("Feature Flag");
jLabelFeatureFlag.setBounds(new java.awt.Rectangle(15, 110, 140, 20));
jLabelC_Name = new JLabel();
jLabelC_Name.setText("C_Name Type");
jLabelC_Name.setBounds(new java.awt.Rectangle(15, 35, 140, 20));
jLabelHelpText = new JLabel();
jLabelHelpText.setBounds(new java.awt.Rectangle(14, 85, 140, 20));
jLabelHelpText.setText("Help Text");
jContentPane = new JPanel();
jContentPane.setLayout(null);
jContentPane.setPreferredSize(new java.awt.Dimension(490, 495));
jContentPane.add(jLabelC_Name, null);
jContentPane.add(getJComboBoxCName(), null);
jContentPane.add(getJTextFieldFeatureFlag(), null);
jContentPane.add(jLabelFeatureFlag, null);
jContentPane.add(jLabelUsage, null);
jContentPane.add(getJComboBox(), null);
jContentPane.add(getJComboBoxPpiType(), null);
jContentPane.add(jLabelArch, null);
jContentPane.add(jLabelPpiType, 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(getJComboBoxList(), null);
jContentPane.add(getJButtonAdd(), null);
jContentPane.add(getJButtonRemove(), null);
jContentPane.add(getJButtonUpdate(), null);
jContentPane.add(getJScrollPaneList(), null);
jContentPane.add(getJScrollPaneArch(), null);
jContentPane.add(jLabelHelpText, null);
jContentPane.add(getJTextFieldHelpText(), null);
}
return jContentPane;
}
/**
This method initializes Usage type
**/
private void initFrame() {
EnumerationData ed = new EnumerationData();
Tools.generateComboBoxByVector(jComboBoxCName, wt.getAllPpiDeclarationsFromWorkspace());
Tools.generateComboBoxByVector(jComboBoxPpiType, ed.getVPpiType());
Tools.generateComboBoxByVector(jComboBoxUsage, ed.getVPpiUsage());
this.iCheckBoxListArch.setAllItems(ed.getVSupportedArchitectures());
}
/* (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() == jButtonAdd) {
if (!checkAdd()) {
return;
}
addToList();
}
if (arg0.getSource() == jButtonRemove) {
removeFromList();
}
if (arg0.getSource() == jButtonUpdate) {
if (!checkAdd()) {
return;
}
updateForList();
}
}
/**
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 fields have correct data types
//
//
// Check Name
//
if (!isEmpty(this.jComboBoxCName.getSelectedItem().toString())) {
if (!DataValidation.isC_NameType(this.jComboBoxCName.getSelectedItem().toString())) {
Log.err("Incorrect data type for Ppi/PpiNotify Name");
return false;
}
}
//
// Check FeatureFlag
//
if (!isEmpty(this.jTextFieldFeatureFlag.getText())) {
if (!DataValidation.isFeatureFlag(this.jTextFieldFeatureFlag.getText())) {
Log.err("Incorrect data type for Feature Flag");
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 {
int count = this.vid.size();
this.ppis = PPIs.Factory.newInstance();
if (count > 0) {
for (int index = 0; index < count; index++) {
if (vid.getPpis(index).getType().equals(ed.getVPpiType().get(0))) {
Ppi p = Ppi.Factory.newInstance();
if (!isEmpty(vid.getPpis(index).getName())) {
p.setPpiCName(vid.getPpis(index).getName());
}
if (!isEmpty(vid.getPpis(index).getUsage())) {
p.setUsage(PpiUsage.Enum.forString(vid.getPpis(index).getUsage()));
}
if (!isEmpty(vid.getPpis(index).getFeatureFlag())) {
p.setFeatureFlag(vid.getPpis(index).getFeatureFlag());
}
if (vid.getPpis(index).getSupArchList() != null
&& vid.getPpis(index).getSupArchList().size() > 0) {
p.setSupArchList(vid.getPpis(index).getSupArchList());
}
if (!isEmpty(vid.getPpis(index).getHelp())) {
p.setHelpText(vid.getPpis(index).getHelp());
}
this.ppis.addNewPpi();
this.ppis.setPpiArray(ppis.getPpiList().size() - 1, p);
}
if (vid.getPpis(index).getType().equals(ed.getVPpiType().get(1))) {
PpiNotify p = PpiNotify.Factory.newInstance();
if (!isEmpty(vid.getPpis(index).getName())) {
p.setPpiNotifyCName(vid.getPpis(index).getName());
}
if (!isEmpty(vid.getPpis(index).getUsage())) {
p.setUsage(PpiNotifyUsage.Enum.forString(vid.getPpis(index).getUsage()));
}
if (!isEmpty(vid.getPpis(index).getFeatureFlag())) {
p.setFeatureFlag(vid.getPpis(index).getFeatureFlag());
}
if (vid.getPpis(index).getSupArchList() != null
&& vid.getPpis(index).getSupArchList().size() > 0) {
p.setSupArchList(vid.getPpis(index).getSupArchList());
}
if (!isEmpty(vid.getPpis(index).getHelp())) {
p.setHelpText(vid.getPpis(index).getHelp());
}
this.ppis.addNewPpiNotify();
this.ppis.setPpiNotifyArray(ppis.getPpiNotifyList().size() - 1, p);
}
}
}
this.msa.setPPIs(ppis);
this.omt.setSaved(false);
} catch (Exception e) {
e.printStackTrace();
Log.err("Update Ppis", e.getMessage());
}
}
/* (non-Javadoc)
* @see java.awt.event.ComponentListener#componentResized(java.awt.event.ComponentEvent)
*
* Override componentResized to resize all components when frame's size is changed
*/
public void componentResized(ComponentEvent arg0) {
int intCurrentWidth = this.getJContentPane().getWidth();
int intCurrentHeight = this.getJContentPane().getHeight();
int intPreferredWidth = this.getJContentPane().getPreferredSize().width;
int intPreferredHeight = this.getJContentPane().getPreferredSize().height;
resizeComponentWidth(jComboBoxPpiType, intCurrentWidth, intPreferredWidth);
resizeComponentWidth(jComboBoxCName, intCurrentWidth, intPreferredWidth);
resizeComponentWidth(jComboBoxUsage, intCurrentWidth, intPreferredWidth);
resizeComponentWidth(jTextFieldHelpText, intCurrentWidth, intPreferredWidth);
resizeComponentWidth(jTextFieldFeatureFlag, intCurrentWidth, intPreferredWidth);
resizeComponentWidth(jScrollPaneArch, intCurrentWidth, intPreferredWidth);
resizeComponentWidth(jComboBoxList, intCurrentWidth, intPreferredWidth);
resizeComponent(jScrollPaneList, intCurrentWidth, intCurrentHeight, intPreferredWidth, intPreferredHeight);
relocateComponentX(jButtonAdd, intCurrentWidth, intPreferredWidth, DataType.SPACE_TO_RIGHT_FOR_ADD_BUTTON);
relocateComponentX(jButtonRemove, intCurrentWidth, intPreferredWidth, DataType.SPACE_TO_RIGHT_FOR_REMOVE_BUTTON);
relocateComponentX(jButtonUpdate, intCurrentWidth, intPreferredWidth, DataType.SPACE_TO_RIGHT_FOR_UPDATE_BUTTON);
}
private PpisIdentification getCurrentPpis() {
String arg0 = this.jComboBoxCName.getSelectedItem().toString();
String arg1 = this.jComboBoxPpiType.getSelectedItem().toString();
String arg2 = this.jComboBoxUsage.getSelectedItem().toString();
String arg3 = this.jTextFieldFeatureFlag.getText();
Vector<String> arg4 = this.iCheckBoxListArch.getAllCheckedItemsString();
String arg5 = this.jTextFieldHelpText.getText();
id = new PpisIdentification(arg0, arg1, arg2, arg3, arg4, arg5);
return id;
}
/**
Add current item to Vector
**/
private void addToList() {
intSelectedItemId = vid.size();
vid.addPpis(getCurrentPpis());
jComboBoxList.addItem(id.getName());
jComboBoxList.setSelectedItem(id.getName());
//
// Reset select item index
//
intSelectedItemId = vid.size();
//
// Reload all fields of selected item
//
reloadFromList();
//
// Save to memory
//
save();
}
/**
Remove current item from Vector
**/
private void removeFromList() {
//
// Check if exist items
//
if (this.vid.size() < 1) {
return;
}
int intTempIndex = intSelectedItemId;
jComboBoxList.removeItemAt(intSelectedItemId);
vid.removePpis(intTempIndex);
//
// Reload all fields of selected item
//
reloadFromList();
//
// Save to memory
//
save();
}
/**
Update current item of Vector
**/
private void updateForList() {
//
// Check if exist items
//
if (this.vid.size() < 1) {
return;
}
//
// Backup selected item index
//
int intTempIndex = intSelectedItemId;
vid.updatePpis(getCurrentPpis(), intTempIndex);
jComboBoxList.removeAllItems();
for (int index = 0; index < vid.size(); index++) {
jComboBoxList.addItem(vid.getPpis(index).getName());
}
//
// Restore selected item index
//
intSelectedItemId = intTempIndex;
//
// Reset select item index
//
jComboBoxList.setSelectedIndex(intSelectedItemId);
//
// Reload all fields of selected item
//
reloadFromList();
//
// Save to memory
//
save();
}
/**
Refresh all fields' values of selected item of Vector
**/
private void reloadFromList() {
if (vid.size() > 0) {
//
// Get selected item index
//
intSelectedItemId = jComboBoxList.getSelectedIndex();
this.jComboBoxCName.setSelectedItem(vid.getPpis(intSelectedItemId).getName());
this.jComboBoxPpiType.setSelectedItem(vid.getPpis(intSelectedItemId).getType());
this.jComboBoxUsage.setSelectedItem(vid.getPpis(intSelectedItemId).getUsage());
this.jTextFieldHelpText.setText(vid.getPpis(intSelectedItemId).getHelp());
jTextFieldFeatureFlag.setText(vid.getPpis(intSelectedItemId).getFeatureFlag());
iCheckBoxListArch.setAllItemsUnchecked();
iCheckBoxListArch.initCheckedItem(true, vid.getPpis(intSelectedItemId).getSupArchList());
} else {
}
reloadListArea();
}
/**
Update list area pane via the elements of Vector
**/
private void reloadListArea() {
String strListItem = "";
for (int index = 0; index < vid.size(); index++) {
strListItem = strListItem + vid.getPpis(index).getName() + DataType.UNIX_LINE_SEPARATOR;
}
this.jTextAreaList.setText(strListItem);
}
/* (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.getSource() == this.jComboBoxList && arg0.getStateChange() == ItemEvent.SELECTED) {
reloadFromList();
}
if (arg0.getSource() == this.jComboBoxPpiType && arg0.getStateChange() == ItemEvent.SELECTED) {
if (this.jComboBoxPpiType.getSelectedItem().toString().equals(ed.getVPpiType().get(0))) {
Tools.generateComboBoxByVector(this.jComboBoxUsage, ed.getVPpiUsage());
} else {
Tools.generateComboBoxByVector(this.jComboBoxUsage, ed.getVPpiNotifyUsage());
}
}
}
}

View File

@@ -0,0 +1,852 @@
/** @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.frameworkwizard.module.ui;
import java.awt.event.ActionEvent;
import java.awt.event.ComponentEvent;
import java.awt.event.ItemEvent;
import java.util.Vector;
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.ProtocolNotifyUsage;
import org.tianocore.ProtocolUsage;
import org.tianocore.ProtocolsDocument;
import org.tianocore.ModuleSurfaceAreaDocument.ModuleSurfaceArea;
import org.tianocore.ProtocolsDocument.Protocols;
import org.tianocore.ProtocolsDocument.Protocols.Protocol;
import org.tianocore.ProtocolsDocument.Protocols.ProtocolNotify;
import org.tianocore.frameworkwizard.common.DataType;
import org.tianocore.frameworkwizard.common.DataValidation;
import org.tianocore.frameworkwizard.common.EnumerationData;
import org.tianocore.frameworkwizard.common.Log;
import org.tianocore.frameworkwizard.common.OpeningModuleType;
import org.tianocore.frameworkwizard.common.Tools;
import org.tianocore.frameworkwizard.common.ui.IInternalFrame;
import org.tianocore.frameworkwizard.common.ui.StarLabel;
import org.tianocore.frameworkwizard.common.ui.iCheckBoxList.ICheckBoxList;
import org.tianocore.frameworkwizard.module.Identification.Protocols.ProtocolsIdentification;
import org.tianocore.frameworkwizard.module.Identification.Protocols.ProtocolsVector;
import org.tianocore.frameworkwizard.workspace.WorkspaceTools;
/**
The class is used to create, update Protocol of MSA/MBD file
It extends IInternalFrame
**/
public class ModuleProtocols extends IInternalFrame {
///
/// Define class Serial Version UID
///
private static final long serialVersionUID = -9084913640747858848L;
//
//Define class members
//
private JPanel jContentPane = null;
private JLabel jLabelC_Name = null;
private JLabel jLabelFeatureFlag = null;
private JTextField jTextFieldFeatureFlag = null;
private JLabel jLabelUsage = null;
private JComboBox jComboBoxUsage = null;
private StarLabel jStarLabel1 = null;
private StarLabel jStarLabel2 = null;
private JLabel jLabelProtocolType = null;
private JLabel jLabelArch = null;
private JTextArea jTextAreaList = null;
private JComboBox jComboBoxList = null;
private JButton jButtonAdd = null;
private JButton jButtonRemove = null;
private JButton jButtonUpdate = null;
private JScrollPane jScrollPane = null;
private JScrollPane jScrollPaneList = null;
private JComboBox jComboBoxProtocolType = null;
private JComboBox jComboBoxCName = null;
private ICheckBoxList iCheckBoxListArch = null;
private JScrollPane jScrollPaneArch = null;
private JLabel jLabelHelpText = null;
private JTextField jTextFieldHelpText = null;
//
// Not used by UI
//
private int intSelectedItemId = 0;
private OpeningModuleType omt = null;
private ModuleSurfaceArea msa = null;
private ProtocolsDocument.Protocols protocols = null;
private ProtocolsIdentification id = null;
private ProtocolsVector vid = new ProtocolsVector();
private WorkspaceTools wt = new WorkspaceTools();
private EnumerationData ed = new EnumerationData();
/**
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, 110, 320, 20));
jTextFieldFeatureFlag.setPreferredSize(new java.awt.Dimension(320, 20));
}
return jTextFieldFeatureFlag;
}
/**
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, 60, 320, 20));
jComboBoxUsage.setPreferredSize(new java.awt.Dimension(320, 20));
}
return jComboBoxUsage;
}
/**
This method initializes jComboBoxFileList
@return javax.swing.JComboBox jComboBoxFileList
**/
private JComboBox getJComboBoxList() {
if (jComboBoxList == null) {
jComboBoxList = new JComboBox();
jComboBoxList.setBounds(new java.awt.Rectangle(15, 220, 210, 20));
jComboBoxList.addItemListener(this);
jComboBoxList.addActionListener(this);
jComboBoxList.setPreferredSize(new java.awt.Dimension(210, 20));
}
return jComboBoxList;
}
/**
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, 220, 80, 20));
jButtonAdd.setText("Add");
jButtonAdd.addActionListener(this);
jButtonAdd.setPreferredSize(new java.awt.Dimension(80, 20));
}
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, 220, 80, 20));
jButtonRemove.setText("Remove");
jButtonRemove.addActionListener(this);
jButtonRemove.setPreferredSize(new java.awt.Dimension(80, 20));
}
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, 220, 80, 20));
jButtonUpdate.setPreferredSize(new java.awt.Dimension(80, 20));
jButtonUpdate.setText("Update");
jButtonUpdate.addActionListener(this);
}
return jButtonUpdate;
}
/**
* This method initializes jScrollPaneFileList
*
* @return javax.swing.JScrollPane
*/
private JScrollPane getJScrollPaneList() {
if (jScrollPaneList == null) {
jScrollPaneList = new JScrollPane();
jScrollPaneList.setBounds(new java.awt.Rectangle(15, 245, 465, 240));
jScrollPaneList.setViewportView(getJTextAreaList());
jScrollPaneList.setPreferredSize(new java.awt.Dimension(465, 240));
}
return jScrollPaneList;
}
/**
This method initializes jScrollPane
@return javax.swing.JScrollPane
*/
private JScrollPane getJScrollPane() {
if (jScrollPane == null) {
jScrollPane = new JScrollPane();
jScrollPane.setViewportView(getJContentPane());
}
return jScrollPane;
}
/**
* This method initializes jTextAreaFileList
*
* @return javax.swing.JTextArea
*/
private JTextArea getJTextAreaList() {
if (jTextAreaList == null) {
jTextAreaList = new JTextArea();
jTextAreaList.setEditable(false);
}
return jTextAreaList;
}
/**
* This method initializes jComboBoxProtocolType
*
* @return javax.swing.JComboBox
*/
private JComboBox getJComboBoxProtocolType() {
if (jComboBoxProtocolType == null) {
jComboBoxProtocolType = new JComboBox();
jComboBoxProtocolType.setBounds(new java.awt.Rectangle(160, 10, 320, 20));
jComboBoxProtocolType.setPreferredSize(new java.awt.Dimension(320, 20));
jComboBoxProtocolType.addItemListener(this);
}
return jComboBoxProtocolType;
}
/**
* This method initializes jComboBoxCName
*
* @return javax.swing.JComboBox
*/
private JComboBox getJComboBoxCName() {
if (jComboBoxCName == null) {
jComboBoxCName = new JComboBox();
jComboBoxCName.setBounds(new java.awt.Rectangle(160, 35, 320, 20));
jComboBoxCName.setPreferredSize(new java.awt.Dimension(320, 20));
}
return jComboBoxCName;
}
/**
This method initializes iCheckBoxListArch
@return ICheckBoxList
**/
private ICheckBoxList getICheckBoxListSupportedArchitectures() {
if (iCheckBoxListArch == null) {
iCheckBoxListArch = new ICheckBoxList();
iCheckBoxListArch.addFocusListener(this);
iCheckBoxListArch.setToolTipText(DataType.SUP_ARCH_LIST_HELP_TEXT);
}
return iCheckBoxListArch;
}
/**
This method initializes jScrollPaneArch
@return javax.swing.JScrollPane
**/
private JScrollPane getJScrollPaneArch() {
if (jScrollPaneArch == null) {
jScrollPaneArch = new JScrollPane();
jScrollPaneArch.setBounds(new java.awt.Rectangle(160, 135, 320, 80));
jScrollPaneArch.setPreferredSize(new java.awt.Dimension(320, 80));
jScrollPaneArch.setViewportView(getICheckBoxListSupportedArchitectures());
}
return jScrollPaneArch;
}
/**
This method initializes jTextFieldHelpText
@return javax.swing.JTextField
**/
private JTextField getJTextFieldHelpText() {
if (jTextFieldHelpText == null) {
jTextFieldHelpText = new JTextField();
jTextFieldHelpText.setBounds(new java.awt.Rectangle(160, 85, 320, 20));
jTextFieldHelpText.setPreferredSize(new java.awt.Dimension(320, 20));
}
return jTextFieldHelpText;
}
public static void main(String[] args) {
}
/**
This method initializes this
**/
private void init() {
this.setSize(500, 515);
this.setContentPane(getJScrollPane());
this.setTitle("Protocols");
initFrame();
this.setViewMode(false);
}
/**
This method initializes this
Fill values to all fields if these values are not empty
@param inPackageDependencies
**/
private void init(Protocols inProtocols) {
init();
this.protocols = inProtocols;
if (this.protocols != null) {
if (this.protocols.getProtocolList().size() > 0) {
for (int index = 0; index < this.protocols.getProtocolList().size(); index++) {
String arg0 = protocols.getProtocolList().get(index).getProtocolCName();
String arg1 = ed.getVProtocolType().get(0);
String arg2 = null;
if (protocols.getProtocolList().get(index).getUsage() != null) {
arg2 = protocols.getProtocolList().get(index).getUsage().toString();
}
String arg3 = protocols.getProtocolList().get(index).getFeatureFlag();
Vector<String> arg4 = Tools.convertListToVector(protocols.getProtocolList().get(index)
.getSupArchList());
String arg5 = protocols.getProtocolList().get(index).getHelpText();
id = new ProtocolsIdentification(arg0, arg1, arg2, arg3, arg4, arg5);
vid.addProtocols(id);
}
}
if (this.protocols.getProtocolNotifyList().size() > 0) {
for (int index = 0; index < this.protocols.getProtocolNotifyList().size(); index++) {
String arg0 = protocols.getProtocolNotifyList().get(index).getProtocolNotifyCName();
String arg1 = ed.getVProtocolType().get(1);
String arg2 = null;
if (protocols.getProtocolNotifyList().get(index).getUsage() != null) {
arg2 = protocols.getProtocolNotifyList().get(index).getUsage().toString();
}
String arg3 = protocols.getProtocolNotifyList().get(index).getFeatureFlag();
Vector<String> arg4 = Tools.convertListToVector(protocols.getProtocolNotifyList().get(index)
.getSupArchList());
String arg5 = protocols.getProtocolNotifyList().get(index).getHelpText();
id = new ProtocolsIdentification(arg0, arg1, arg2, arg3, arg4, arg5);
vid.addProtocols(id);
}
}
}
//
// Update the list
//
Tools.generateComboBoxByVector(jComboBoxList, vid.getProtocolsName());
reloadListArea();
}
/**
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(OpeningModuleType inOmt) {
super();
this.omt = inOmt;
this.msa = omt.getXmlMsa();
init(msa.getProtocols());
this.setVisible(true);
}
/**
Disable all components when the mode is view
@param isView true - The view mode; false - The non-view mode
**/
public void setViewMode(boolean isView) {
if (isView) {
this.jComboBoxUsage.setEnabled(!isView);
this.jTextFieldFeatureFlag.setEnabled(!isView);
}
}
/**
This method initializes jContentPane
@return javax.swing.JPanel jContentPane
**/
private JPanel getJContentPane() {
if (jContentPane == null) {
jLabelHelpText = new JLabel();
jLabelHelpText.setBounds(new java.awt.Rectangle(14, 85, 140, 20));
jLabelHelpText.setText("Help Text");
jLabelArch = new JLabel();
jLabelArch.setBounds(new java.awt.Rectangle(15, 135, 140, 20));
jLabelArch.setText("Arch Type");
jLabelProtocolType = new JLabel();
jLabelProtocolType.setBounds(new java.awt.Rectangle(15, 10, 140, 20));
jLabelProtocolType.setText("Protocol Type");
jLabelUsage = new JLabel();
jLabelUsage.setText("Usage");
jLabelUsage.setBounds(new java.awt.Rectangle(15, 60, 140, 20));
jLabelFeatureFlag = new JLabel();
jLabelFeatureFlag.setText("Feature Flag");
jLabelFeatureFlag.setBounds(new java.awt.Rectangle(15, 110, 140, 20));
jLabelC_Name = new JLabel();
jLabelC_Name.setText("C_Name Type");
jLabelC_Name.setBounds(new java.awt.Rectangle(15, 35, 140, 20));
jContentPane = new JPanel();
jContentPane.setLayout(null);
jContentPane.setPreferredSize(new java.awt.Dimension(490, 495));
jContentPane.add(jLabelC_Name, null);
jContentPane.add(jLabelFeatureFlag, null);
jContentPane.add(getJTextFieldFeatureFlag(), null);
jContentPane.add(jLabelUsage, null);
jContentPane.add(getJComboBoxProtocolUsage(), 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);
jContentPane.add(jLabelArch, null);
jContentPane.add(getJComboBoxList(), null);
jContentPane.add(getJButtonAdd(), null);
jContentPane.add(getJButtonRemove(), null);
jContentPane.add(getJButtonUpdate(), null);
jContentPane.add(getJScrollPaneList(), null);
jContentPane.add(getJComboBoxProtocolType(), null);
jContentPane.add(getJComboBoxCName(), null);
jContentPane.add(getJScrollPaneArch(), null);
jContentPane.add(jLabelHelpText, null);
jContentPane.add(getJTextFieldHelpText(), null);
}
return jContentPane;
}
/**
This method initializes Usage type
**/
private void initFrame() {
Tools.generateComboBoxByVector(jComboBoxProtocolType, ed.getVProtocolType());
Tools.generateComboBoxByVector(jComboBoxCName, wt.getAllProtocolDeclarationsFromWorkspace());
Tools.generateComboBoxByVector(jComboBoxUsage, ed.getVProtocolUsage());
this.iCheckBoxListArch.setAllItems(ed.getVSupportedArchitectures());
}
/* (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() == jButtonAdd) {
if (!checkAdd()) {
return;
}
addToList();
}
if (arg0.getSource() == jButtonRemove) {
removeFromList();
}
if (arg0.getSource() == jButtonUpdate) {
if (!checkAdd()) {
return;
}
updateForList();
}
}
/**
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 fields have correct data types
//
//
// Check Name
//
if (!isEmpty(this.jComboBoxCName.getSelectedItem().toString())) {
if (!DataValidation.isC_NameType(this.jComboBoxCName.getSelectedItem().toString())) {
Log.err("Incorrect data type for Protocol/ProtocolNotify Name");
return false;
}
}
//
// Check FeatureFlag
//
if (!isEmpty(this.jTextFieldFeatureFlag.getText())) {
if (!DataValidation.isFeatureFlag(this.jTextFieldFeatureFlag.getText())) {
Log.err("Incorrect data type for Feature Flag");
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 {
int count = this.vid.size();
this.protocols = Protocols.Factory.newInstance();
if (count > 0) {
for (int index = 0; index < count; index++) {
if (vid.getProtocols(index).getType().equals(ed.getVProtocolType().get(0))) {
Protocol p = Protocol.Factory.newInstance();
if (!isEmpty(vid.getProtocols(index).getName())) {
p.setProtocolCName(vid.getProtocols(index).getName());
}
if (!isEmpty(vid.getProtocols(index).getUsage())) {
p.setUsage(ProtocolUsage.Enum.forString(vid.getProtocols(index).getUsage()));
}
if (!isEmpty(vid.getProtocols(index).getFeatureFlag())) {
p.setFeatureFlag(vid.getProtocols(index).getFeatureFlag());
}
if (vid.getProtocols(index).getSupArchList() != null
&& vid.getProtocols(index).getSupArchList().size() > 0) {
p.setSupArchList(vid.getProtocols(index).getSupArchList());
}
if (!isEmpty(vid.getProtocols(index).getHelp())) {
p.setHelpText(vid.getProtocols(index).getHelp());
}
this.protocols.addNewProtocol();
this.protocols.setProtocolArray(protocols.getProtocolList().size() - 1, p);
}
if (vid.getProtocols(index).getType().equals(ed.getVProtocolType().get(1))) {
ProtocolNotify p = ProtocolNotify.Factory.newInstance();
if (!isEmpty(vid.getProtocols(index).getName())) {
p.setProtocolNotifyCName(vid.getProtocols(index).getName());
}
if (!isEmpty(vid.getProtocols(index).getUsage())) {
p.setUsage(ProtocolNotifyUsage.Enum.forString(vid.getProtocols(index).getUsage()));
}
if (!isEmpty(vid.getProtocols(index).getFeatureFlag())) {
p.setFeatureFlag(vid.getProtocols(index).getFeatureFlag());
}
if (vid.getProtocols(index).getSupArchList() != null
&& vid.getProtocols(index).getSupArchList().size() > 0) {
p.setSupArchList(vid.getProtocols(index).getSupArchList());
}
if (!isEmpty(vid.getProtocols(index).getHelp())) {
p.setHelpText(vid.getProtocols(index).getHelp());
}
this.protocols.addNewProtocolNotify();
this.protocols.setProtocolNotifyArray(protocols.getProtocolNotifyList().size() - 1, p);
}
}
}
this.msa.setProtocols(protocols);
this.omt.setSaved(false);
} catch (Exception e) {
e.printStackTrace();
Log.err("Update Protocols", e.getMessage());
}
}
/* (non-Javadoc)
* @see java.awt.event.ComponentListener#componentResized(java.awt.event.ComponentEvent)
*
* Override componentResized to resize all components when frame's size is changed
*/
public void componentResized(ComponentEvent arg0) {
int intCurrentWidth = this.getJContentPane().getWidth();
int intCurrentHeight = this.getJContentPane().getHeight();
int intPreferredWidth = this.getJContentPane().getPreferredSize().width;
int intPreferredHeight = this.getJContentPane().getPreferredSize().height;
resizeComponentWidth(this.jComboBoxProtocolType, intCurrentWidth, intPreferredWidth);
resizeComponentWidth(this.jComboBoxCName, intCurrentWidth, intPreferredWidth);
resizeComponentWidth(this.jComboBoxUsage, intCurrentWidth, intPreferredWidth);
resizeComponentWidth(this.jTextFieldHelpText, intCurrentWidth, intPreferredWidth);
resizeComponentWidth(this.jTextFieldFeatureFlag, intCurrentWidth, intPreferredWidth);
resizeComponentWidth(this.jScrollPaneArch, intCurrentWidth, intPreferredWidth);
resizeComponentWidth(this.jComboBoxList, intCurrentWidth, intPreferredWidth);
resizeComponent(this.jScrollPaneList, intCurrentWidth, intCurrentHeight, intPreferredWidth, intPreferredHeight);
relocateComponentX(this.jButtonAdd, intCurrentWidth, intPreferredWidth, DataType.SPACE_TO_RIGHT_FOR_ADD_BUTTON);
relocateComponentX(this.jButtonRemove, intCurrentWidth, intPreferredWidth,
DataType.SPACE_TO_RIGHT_FOR_REMOVE_BUTTON);
relocateComponentX(this.jButtonUpdate, intCurrentWidth, intPreferredWidth,
DataType.SPACE_TO_RIGHT_FOR_UPDATE_BUTTON);
}
private ProtocolsIdentification getCurrentProtocols() {
String arg0 = this.jComboBoxCName.getSelectedItem().toString();
String arg1 = this.jComboBoxProtocolType.getSelectedItem().toString();
String arg2 = this.jComboBoxUsage.getSelectedItem().toString();
String arg3 = this.jTextFieldFeatureFlag.getText();
Vector<String> arg4 = this.iCheckBoxListArch.getAllCheckedItemsString();
String arg5 = this.jTextFieldHelpText.getText();
id = new ProtocolsIdentification(arg0, arg1, arg2, arg3, arg4, arg5);
return id;
}
/**
Add current item to Vector
**/
private void addToList() {
intSelectedItemId = vid.size();
vid.addProtocols(getCurrentProtocols());
jComboBoxList.addItem(id.getName());
jComboBoxList.setSelectedItem(id.getName());
//
// Reset select item index
//
intSelectedItemId = vid.size();
//
// Reload all fields of selected item
//
reloadFromList();
//
// Save to memory
//
save();
}
/**
Remove current item from Vector
**/
private void removeFromList() {
//
// Check if exist items
//
if (this.vid.size() < 1) {
return;
}
int intTempIndex = intSelectedItemId;
jComboBoxList.removeItemAt(intSelectedItemId);
vid.removeProtocols(intTempIndex);
//
// Reload all fields of selected item
//
reloadFromList();
//
// Save to memory
//
save();
}
/**
Update current item of Vector
**/
private void updateForList() {
//
// Check if exist items
//
if (this.vid.size() < 1) {
return;
}
//
// Backup selected item index
//
int intTempIndex = intSelectedItemId;
vid.updateProtocols(getCurrentProtocols(), intTempIndex);
jComboBoxList.removeAllItems();
for (int index = 0; index < vid.size(); index++) {
jComboBoxList.addItem(vid.getProtocols(index).getName());
}
//
// Restore selected item index
//
intSelectedItemId = intTempIndex;
//
// Reset select item index
//
jComboBoxList.setSelectedIndex(intSelectedItemId);
//
// Reload all fields of selected item
//
reloadFromList();
//
// Save to memory
//
save();
}
/**
Refresh all fields' values of selected item of Vector
**/
private void reloadFromList() {
if (vid.size() > 0) {
//
// Get selected item index
//
intSelectedItemId = jComboBoxList.getSelectedIndex();
this.jComboBoxCName.setSelectedItem(vid.getProtocols(intSelectedItemId).getName());
this.jComboBoxProtocolType.setSelectedItem(vid.getProtocols(intSelectedItemId).getType());
this.jComboBoxUsage.setSelectedItem(vid.getProtocols(intSelectedItemId).getUsage());
this.jTextFieldHelpText.setText(vid.getProtocols(intSelectedItemId).getHelp());
jTextFieldFeatureFlag.setText(vid.getProtocols(intSelectedItemId).getFeatureFlag());
iCheckBoxListArch.setAllItemsUnchecked();
iCheckBoxListArch.initCheckedItem(true, vid.getProtocols(intSelectedItemId).getSupArchList());
} else {
}
reloadListArea();
}
/**
Update list area pane via the elements of Vector
**/
private void reloadListArea() {
String strListItem = "";
for (int index = 0; index < vid.size(); index++) {
strListItem = strListItem + vid.getProtocols(index).getName() + DataType.UNIX_LINE_SEPARATOR;
}
this.jTextAreaList.setText(strListItem);
}
/* (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.getSource() == this.jComboBoxList && arg0.getStateChange() == ItemEvent.SELECTED) {
reloadFromList();
}
if (arg0.getSource() == this.jComboBoxProtocolType && arg0.getStateChange() == ItemEvent.SELECTED) {
if (this.jComboBoxProtocolType.getSelectedItem().toString().equals(ed.getVProtocolType().get(0))) {
Tools.generateComboBoxByVector(this.jComboBoxUsage, ed.getVProtocolUsage());
} else {
Tools.generateComboBoxByVector(this.jComboBoxUsage, ed.getVProtocolNotifyUsage());
}
}
}
}

View File

@@ -0,0 +1,864 @@
/** @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.frameworkwizard.module.ui;
import java.awt.event.ActionEvent;
import java.awt.event.ComponentEvent;
import java.awt.event.ItemEvent;
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.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import org.tianocore.SourceFilesDocument;
import org.tianocore.FilenameDocument.Filename;
import org.tianocore.ModuleSurfaceAreaDocument.ModuleSurfaceArea;
import org.tianocore.SourceFilesDocument.SourceFiles;
import org.tianocore.frameworkwizard.common.DataType;
import org.tianocore.frameworkwizard.common.DataValidation;
import org.tianocore.frameworkwizard.common.EnumerationData;
import org.tianocore.frameworkwizard.common.Log;
import org.tianocore.frameworkwizard.common.OpeningModuleType;
import org.tianocore.frameworkwizard.common.Tools;
import org.tianocore.frameworkwizard.common.ui.IInternalFrame;
import org.tianocore.frameworkwizard.common.ui.StarLabel;
import org.tianocore.frameworkwizard.common.ui.iCheckBoxList.ICheckBoxList;
import org.tianocore.frameworkwizard.module.Identification.SourceFiles.SourceFilesIdentification;
import org.tianocore.frameworkwizard.module.Identification.SourceFiles.SourceFilesVector;
import org.tianocore.frameworkwizard.workspace.Workspace;
/**
The class is used to create, update SourceFile of MSA/MBD file
It extends IInternalFrame
**/
public class ModuleSourceFiles extends IInternalFrame {
///
/// Define class Serial Version UID
///
private static final long serialVersionUID = -6765742852142775378L;
//
// Define class members
//
private SourceFilesDocument.SourceFiles sourceFiles = null;
private int intSelectedItemId = 0;
private JPanel jContentPane = null;
private JLabel jLabelFileName = null;
private JTextField jTextFieldFileName = null;
private JButton jButtonOpenFile = null;
private JLabel jLabelToolChainFamily = null;
private StarLabel jStarLabel1 = null;
private JComboBox jComboBoxList = null;
private JButton jButtonAdd = null;
private JButton jButtonRemove = null;
private JButton jButtonUpdate = null;
private JCheckBox jCheckBoxArch = null;
private JScrollPane jScrollPaneList = null;
private JTextArea jTextAreaList = null;
private JLabel jLabelArch = null;
private JScrollPane jScrollPane = null;
private JLabel jLabelTagName = null;
private JTextField jTextFieldTagName = null;
private JLabel jLabelToolCode = null;
private JTextField jTextFieldToolCode = null;
private JTextField jTextFieldToolChainFamily = null;
private JLabel jLabelFeatureFlag = null;
private JTextField jTextFieldFeatureFlag = null;
private ICheckBoxList iCheckBoxListArch = null;
private JScrollPane jScrollPaneArch = null;
//
// Not used by UI
//
private OpeningModuleType omt = null;
private ModuleSurfaceArea msa = null;
private SourceFilesIdentification sfid = null;
private SourceFilesVector vSourceFiles = new SourceFilesVector();
/**
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));
jTextFieldFileName.setPreferredSize(new java.awt.Dimension(250, 20));
jTextFieldFileName.setToolTipText("Path is relative to the MSA file and must include the file name");
}
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.setPreferredSize(new java.awt.Dimension(85, 20));
jButtonOpenFile.addActionListener(this);
}
return jButtonOpenFile;
}
/**
This method initializes jComboBoxFileList
@return javax.swing.JComboBox jComboBoxFileList
**/
private JComboBox getJComboBoxList() {
if (jComboBoxList == null) {
jComboBoxList = new JComboBox();
jComboBoxList.setBounds(new java.awt.Rectangle(15, 220, 210, 20));
jComboBoxList.addItemListener(this);
jComboBoxList.addActionListener(this);
jComboBoxList.setPreferredSize(new java.awt.Dimension(210, 20));
}
return jComboBoxList;
}
/**
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, 220, 80, 20));
jButtonAdd.setText("Add");
jButtonAdd.addActionListener(this);
jButtonAdd.setPreferredSize(new java.awt.Dimension(80, 20));
}
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, 220, 80, 20));
jButtonRemove.setText("Remove");
jButtonRemove.addActionListener(this);
jButtonRemove.setPreferredSize(new java.awt.Dimension(80, 20));
}
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, 220, 80, 20));
jButtonUpdate.setPreferredSize(new java.awt.Dimension(80, 20));
jButtonUpdate.setText("Update");
jButtonUpdate.addActionListener(this);
}
return jButtonUpdate;
}
/**
* This method initializes jScrollPaneFileList
*
* @return javax.swing.JScrollPane
*/
private JScrollPane getJScrollPaneList() {
if (jScrollPaneList == null) {
jScrollPaneList = new JScrollPane();
jScrollPaneList.setBounds(new java.awt.Rectangle(15, 245, 465, 240));
jScrollPaneList.setViewportView(getJTextAreaList());
jScrollPaneList.setPreferredSize(new java.awt.Dimension(465, 240));
}
return jScrollPaneList;
}
/**
* This method initializes jTextAreaFileList
*
* @return javax.swing.JTextArea
*/
private JTextArea getJTextAreaList() {
if (jTextAreaList == null) {
jTextAreaList = new JTextArea();
jTextAreaList.setEditable(false);
}
return jTextAreaList;
}
/**
This method initializes jScrollPane
@return javax.swing.JScrollPane
*/
private JScrollPane getJScrollPane() {
if (jScrollPane == null) {
jScrollPane = new JScrollPane();
jScrollPane.setViewportView(getJContentPane());
}
return jScrollPane;
}
/**
* This method initializes jTextFieldTagName
*
* @return javax.swing.JTextField
*/
private JTextField getJTextFieldTagName() {
if (jTextFieldTagName == null) {
jTextFieldTagName = new JTextField();
jTextFieldTagName.setBounds(new java.awt.Rectangle(140, 35, 340, 20));
jTextFieldTagName.setPreferredSize(new java.awt.Dimension(340, 20));
jTextFieldTagName.setToolTipText("You may specify a specific tool chain tag name, such as BILL1");
}
return jTextFieldTagName;
}
/**
* This method initializes jTextFieldToolCode
*
* @return javax.swing.JTextField
*/
private JTextField getJTextFieldToolCode() {
if (jTextFieldToolCode == null) {
jTextFieldToolCode = new JTextField();
jTextFieldToolCode.setBounds(new java.awt.Rectangle(140, 60, 340, 20));
jTextFieldToolCode.setPreferredSize(new java.awt.Dimension(340, 20));
jTextFieldToolCode.setToolTipText("You may specify a specific tool command, such as ASM");
}
return jTextFieldToolCode;
}
/**
* This method initializes jTextFieldToolChainFamily
*
* @return javax.swing.JTextField
*/
private JTextField getJTextFieldToolChainFamily() {
if (jTextFieldToolChainFamily == null) {
jTextFieldToolChainFamily = new JTextField();
jTextFieldToolChainFamily.setBounds(new java.awt.Rectangle(140, 85, 340, 20));
jTextFieldToolChainFamily.setPreferredSize(new java.awt.Dimension(340, 20));
jTextFieldToolChainFamily.setToolTipText("You may specify a specific tool chain family, such as GCC");
}
return jTextFieldToolChainFamily;
}
/**
* This method initializes jTextFieldFeatureFlag
*
* @return javax.swing.JTextField
*/
private JTextField getJTextFieldFeatureFlag() {
if (jTextFieldFeatureFlag == null) {
jTextFieldFeatureFlag = new JTextField();
jTextFieldFeatureFlag.setBounds(new java.awt.Rectangle(140, 110, 340, 20));
jTextFieldFeatureFlag.setPreferredSize(new java.awt.Dimension(340, 20));
jTextFieldFeatureFlag.setToolTipText("RESERVED FOR FUTURE USE");
}
return jTextFieldFeatureFlag;
}
/**
This method initializes iCheckBoxListArch
@return ICheckBoxList
**/
private ICheckBoxList getICheckBoxListSupportedArchitectures() {
if (iCheckBoxListArch == null) {
iCheckBoxListArch = new ICheckBoxList();
iCheckBoxListArch.addFocusListener(this);
iCheckBoxListArch.setToolTipText(DataType.SUP_ARCH_LIST_HELP_TEXT);
}
return iCheckBoxListArch;
}
/**
This method initializes jScrollPaneArch
@return javax.swing.JScrollPane
**/
private JScrollPane getJScrollPaneArch() {
if (jScrollPaneArch == null) {
jScrollPaneArch = new JScrollPane();
jScrollPaneArch.setBounds(new java.awt.Rectangle(140, 135, 340, 80));
jScrollPaneArch.setPreferredSize(new java.awt.Dimension(340, 80));
jScrollPaneArch.setViewportView(getICheckBoxListSupportedArchitectures());
}
return jScrollPaneArch;
}
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
**/
public ModuleSourceFiles(OpeningModuleType inOmt) {
super();
this.omt = inOmt;
this.msa = inOmt.getXmlMsa();
init(msa.getSourceFiles());
this.setVisible(true);
}
/**
This method initializes this
Fill values to all fields if these values are not empty
@param inSourceFiles The input data of SourceFilesDocument.SourceFiles
**/
private void init(SourceFilesDocument.SourceFiles inSourceFiles) {
init();
this.sourceFiles = inSourceFiles;
if (this.sourceFiles != null) {
if (this.sourceFiles.getFilenameList().size() > 0) {
for (int index = 0; index < this.sourceFiles.getFilenameList().size(); index++) {
String name = sourceFiles.getFilenameList().get(index).getStringValue();
String tagName = sourceFiles.getFilenameList().get(index).getTagName();
String toolCode = sourceFiles.getFilenameList().get(index).getToolCode();
String tcf = sourceFiles.getFilenameList().get(index).getToolChainFamily();
String featureFlag = sourceFiles.getFilenameList().get(index).getFeatureFlag();
Vector<String> arch = Tools.convertListToVector(sourceFiles.getFilenameList().get(index)
.getSupArchList());
SourceFilesIdentification sfid = new SourceFilesIdentification(name, tagName, toolCode, tcf,
featureFlag, arch);
vSourceFiles.addSourceFiles(sfid);
}
}
}
//
// Update the list
//
Tools.generateComboBoxByVector(jComboBoxList, vSourceFiles.getSourceFilesName());
reloadListArea();
}
/**
This method initializes this
**/
private void init() {
this.setSize(500, 515);
this.setContentPane(getJScrollPane());
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) {
if (isView) {
this.jTextFieldFileName.setEnabled(!isView);
this.jButtonOpenFile.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) {
jLabelFeatureFlag = new JLabel();
jLabelFeatureFlag.setBounds(new java.awt.Rectangle(15, 110, 120, 20));
jLabelFeatureFlag.setText("Feature Flag");
jLabelToolCode = new JLabel();
jLabelToolCode.setBounds(new java.awt.Rectangle(15, 60, 120, 20));
jLabelToolCode.setText("Tool Code");
jLabelTagName = new JLabel();
jLabelTagName.setBounds(new java.awt.Rectangle(15, 35, 120, 20));
jLabelTagName.setText("Tag Name");
jLabelArch = new JLabel();
jLabelArch.setBounds(new java.awt.Rectangle(15, 135, 120, 20));
jLabelArch.setText("Sup Arch List");
jLabelToolChainFamily = new JLabel();
jLabelToolChainFamily.setBounds(new java.awt.Rectangle(15, 85, 120, 20));
jLabelToolChainFamily.setText("Tool Chain Family");
jLabelFileName = new JLabel();
jLabelFileName.setText("File Name");
jLabelFileName.setBounds(new java.awt.Rectangle(15, 10, 120, 20));
jContentPane = new JPanel();
jContentPane.setLayout(null);
jContentPane.setPreferredSize(new java.awt.Dimension(490, 490));
jContentPane.add(jLabelFileName, null);
jContentPane.add(getJTextFieldSourceFilesDirectory(), null);
jContentPane.add(getJButtonOpenFile(), null);
jContentPane.add(jLabelToolChainFamily, null);
jStarLabel1 = new StarLabel();
jStarLabel1.setLocation(new java.awt.Point(0, 10));
jContentPane.add(jStarLabel1, null);
jContentPane.add(getJComboBoxList(), null);
jContentPane.add(getJButtonAdd(), null);
jContentPane.add(getJButtonRemove(), null);
jContentPane.add(getJButtonUpdate(), null);
jContentPane.add(getJScrollPaneList(), null);
jContentPane.add(jLabelArch, null);
jContentPane.add(jLabelTagName, null);
jContentPane.add(getJTextFieldTagName(), null);
jContentPane.add(jLabelToolCode, null);
jContentPane.add(getJTextFieldToolCode(), null);
jContentPane.add(getJTextFieldToolChainFamily(), null);
jContentPane.add(jLabelFeatureFlag, null);
jContentPane.add(getJTextFieldFeatureFlag(), null);
jContentPane.add(getJScrollPaneArch(), 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() == jButtonOpenFile) {
selectFile();
}
if (arg0.getSource() == jButtonAdd) {
if (!checkAdd()) {
return;
}
addToList();
}
if (arg0.getSource() == jButtonRemove) {
removeFromList();
}
if (arg0.getSource() == jButtonUpdate) {
if (!checkAdd()) {
return;
}
updateForList();
}
}
/**
This method initializes Usage type and Arch type
**/
private void initFrame() {
EnumerationData ed = new EnumerationData();
this.iCheckBoxListArch.setAllItems(ed.getVSupportedArchitectures());
}
private SourceFilesIdentification getCurrentSourceFiles() {
String name = this.jTextFieldFileName.getText();
String tagName = this.jTextFieldTagName.getText();
String toolCode = this.jTextFieldToolCode.getText();
String tcf = this.jTextFieldToolChainFamily.getText();
String featureFlag = this.jTextFieldFeatureFlag.getText();
Vector<String> arch = this.iCheckBoxListArch.getAllCheckedItemsString();
sfid = new SourceFilesIdentification(name, tagName, toolCode, tcf, featureFlag, arch);
return sfid;
}
/**
Add current item to Vector
**/
private void addToList() {
intSelectedItemId = vSourceFiles.size();
vSourceFiles.addSourceFiles(getCurrentSourceFiles());
jComboBoxList.addItem(sfid.getFilename());
jComboBoxList.setSelectedItem(sfid.getFilename());
//
// Reset select item index
//
intSelectedItemId = vSourceFiles.size();
//
// Reload all fields of selected item
//
reloadFromList();
//
// Save to memory
//
save();
}
/**
Remove current item from Vector
**/
private void removeFromList() {
//
// Check if exist items
//
if (this.vSourceFiles.size() < 1) {
return;
}
int intTempIndex = intSelectedItemId;
jComboBoxList.removeItemAt(intSelectedItemId);
vSourceFiles.removeSourceFiles(intTempIndex);
//
// Reload all fields of selected item
//
reloadFromList();
//
// Save to memory
//
save();
}
/**
Update current item of Vector
**/
private void updateForList() {
//
// Check if exist items
//
if (this.vSourceFiles.size() < 1) {
return;
}
//
// Backup selected item index
//
int intTempIndex = intSelectedItemId;
vSourceFiles.updateSourceFiles(getCurrentSourceFiles(), intTempIndex);
jComboBoxList.removeAllItems();
for (int index = 0; index < vSourceFiles.size(); index++) {
jComboBoxList.addItem(vSourceFiles.getSourceFiles(index).getFilename());
}
//
// Restore selected item index
//
intSelectedItemId = intTempIndex;
//
// Reset select item index
//
jComboBoxList.setSelectedIndex(intSelectedItemId);
//
// Reload all fields of selected item
//
reloadFromList();
//
// Save to memory
//
save();
}
/**
Refresh all fields' values of selected item of Vector
**/
private void reloadFromList() {
if (vSourceFiles.size() > 0) {
//
// Get selected item index
//
intSelectedItemId = jComboBoxList.getSelectedIndex();
this.jTextFieldFileName.setText(vSourceFiles.getSourceFiles(intSelectedItemId).getFilename());
this.jTextFieldTagName.setText(vSourceFiles.getSourceFiles(intSelectedItemId).getTagName());
this.jTextFieldToolCode.setText(vSourceFiles.getSourceFiles(intSelectedItemId).getToolCode());
this.jTextFieldToolChainFamily.setText(vSourceFiles.getSourceFiles(intSelectedItemId).getToolChainFamily());
jTextFieldFeatureFlag.setText(vSourceFiles.getSourceFiles(intSelectedItemId).getFeatureFlag());
iCheckBoxListArch.setAllItemsUnchecked();
iCheckBoxListArch.initCheckedItem(true, vSourceFiles.getSourceFiles(intSelectedItemId).getSupArchList());
} else {
}
reloadListArea();
}
/**
Update list area pane via the elements of Vector
**/
private void reloadListArea() {
String strListItem = "";
for (int index = 0; index < vSourceFiles.size(); index++) {
strListItem = strListItem + vSourceFiles.getSourceFiles(index).getFilename() + DataType.UNIX_LINE_SEPARATOR;
}
this.jTextAreaList.setText(strListItem);
}
/* (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 checkAdd() {
//
// Check Filename
//
if (isEmpty(this.jTextFieldFileName.getText())) {
Log.err("File Name couldn't be empty");
return false;
}
if (!DataValidation.isFilename(this.jTextFieldFileName.getText())) {
Log.err("Incorrect data type for File Name");
return false;
}
//
// Check TagName
//
if (!isEmpty(this.jTextFieldTagName.getText())) {
if (!DataValidation.isTagName(this.jTextFieldTagName.getText())) {
Log.err("Incorrect data type for Tag Name");
return false;
}
}
//
// Check ToolCode
//
if (!isEmpty(this.jTextFieldToolCode.getText())) {
if (!DataValidation.isToolCode(this.jTextFieldToolCode.getText())) {
Log.err("Incorrect data type for Tool Code");
return false;
}
}
//
// Check ToolChainFamily
//
if (!isEmpty(this.jTextFieldToolChainFamily.getText())) {
if (!DataValidation.isToolChainFamily(this.jTextFieldToolChainFamily.getText())) {
Log.err("Incorrect data type for Tool Chain Family");
return false;
}
}
//
// Check FeatureFlag
//
if (!isEmpty(this.jTextFieldFeatureFlag.getText())) {
if (!DataValidation.isFeatureFlag(this.jTextFieldFeatureFlag.getText())) {
Log.err("Incorrect data type for Feature Flag");
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 {
//
//Save as file name
//
int count = this.vSourceFiles.size();
this.sourceFiles = SourceFiles.Factory.newInstance();
if (count > 0) {
for (int index = 0; index < count; index++) {
Filename mFilename = Filename.Factory.newInstance();
if (!isEmpty(vSourceFiles.getSourceFiles(index).getFilename())) {
mFilename.setStringValue(vSourceFiles.getSourceFiles(index).getFilename());
}
if (!isEmpty(vSourceFiles.getSourceFiles(index).getTagName())) {
mFilename.setTagName(vSourceFiles.getSourceFiles(index).getTagName());
}
if (!isEmpty(vSourceFiles.getSourceFiles(index).getToolCode())) {
mFilename.setToolCode(vSourceFiles.getSourceFiles(index).getToolCode());
}
if (!isEmpty(vSourceFiles.getSourceFiles(index).getToolChainFamily())) {
mFilename.setToolChainFamily(vSourceFiles.getSourceFiles(index).getToolChainFamily());
}
if (!isEmpty(vSourceFiles.getSourceFiles(index).getFeatureFlag())) {
mFilename.setFeatureFlag(vSourceFiles.getSourceFiles(index).getFeatureFlag());
}
if (vSourceFiles.getSourceFiles(index).getSupArchList() != null
&& vSourceFiles.getSourceFiles(index).getSupArchList().size() > 0) {
mFilename.setSupArchList(vSourceFiles.getSourceFiles(index).getSupArchList());
}
this.sourceFiles.addNewFilename();
this.sourceFiles.setFilenameArray(index, mFilename);
}
}
this.msa.setSourceFiles(sourceFiles);
this.omt.setSaved(false);
} catch (Exception e) {
e.printStackTrace();
Log.err("Update Source Files", e.getMessage());
}
}
/**
Display a file open browser to let user select file
**/
private void selectFile() {
JFileChooser fc = new JFileChooser(Workspace.getCurrentWorkspace());
int result = fc.showOpenDialog(new JPanel());
if (result == JFileChooser.APPROVE_OPTION) {
this.jTextFieldFileName.setText(fc.getSelectedFile().getName());
}
}
/* (non-Javadoc)
* @see java.awt.event.ComponentListener#componentResized(java.awt.event.ComponentEvent)
*
* Override componentResized to resize all components when frame's size is changed
*/
public void componentResized(ComponentEvent arg0) {
int intCurrentWidth = this.getJContentPane().getWidth();
int intCurrentHeight = this.getJContentPane().getHeight();
int intPreferredWidth = this.getJContentPane().getPreferredSize().width;
int intPreferredHeight = this.getJContentPane().getPreferredSize().height;
resizeComponentWidth(this.jTextFieldFileName, intCurrentWidth, intPreferredWidth);
resizeComponentWidth(this.jTextFieldTagName, intCurrentWidth, intPreferredWidth);
resizeComponentWidth(this.jTextFieldToolCode, intCurrentWidth, intPreferredWidth);
resizeComponentWidth(this.jTextFieldToolChainFamily, intCurrentWidth, intPreferredWidth);
resizeComponentWidth(this.jTextFieldFeatureFlag, intCurrentWidth, intPreferredWidth);
resizeComponentWidth(this.jScrollPaneArch, intCurrentWidth, intPreferredWidth);
resizeComponentWidth(this.jComboBoxList, intCurrentWidth, intPreferredWidth);
resizeComponent(this.jScrollPaneList, intCurrentWidth, intCurrentHeight, intPreferredWidth, intPreferredHeight);
relocateComponentX(this.jButtonAdd, intCurrentWidth, intPreferredWidth, DataType.SPACE_TO_RIGHT_FOR_ADD_BUTTON);
relocateComponentX(this.jButtonOpenFile, intCurrentWidth, intPreferredWidth,
DataType.SPACE_TO_RIGHT_FOR_GENERATE_BUTTON);
relocateComponentX(this.jButtonRemove, intCurrentWidth, intPreferredWidth,
DataType.SPACE_TO_RIGHT_FOR_REMOVE_BUTTON);
relocateComponentX(this.jButtonUpdate, intCurrentWidth, intPreferredWidth,
DataType.SPACE_TO_RIGHT_FOR_UPDATE_BUTTON);
}
}

View File

@@ -0,0 +1,768 @@
/** @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.frameworkwizard.module.ui;
import java.awt.event.ActionEvent;
import java.awt.event.ComponentEvent;
import java.awt.event.ItemEvent;
import java.util.Vector;
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.SystemTableUsage;
import org.tianocore.SystemTablesDocument;
import org.tianocore.ModuleSurfaceAreaDocument.ModuleSurfaceArea;
import org.tianocore.SystemTablesDocument.SystemTables;
import org.tianocore.SystemTablesDocument.SystemTables.SystemTableCNames;
import org.tianocore.frameworkwizard.common.DataType;
import org.tianocore.frameworkwizard.common.DataValidation;
import org.tianocore.frameworkwizard.common.EnumerationData;
import org.tianocore.frameworkwizard.common.Log;
import org.tianocore.frameworkwizard.common.OpeningModuleType;
import org.tianocore.frameworkwizard.common.Tools;
import org.tianocore.frameworkwizard.common.ui.IInternalFrame;
import org.tianocore.frameworkwizard.common.ui.StarLabel;
import org.tianocore.frameworkwizard.common.ui.iCheckBoxList.ICheckBoxList;
import org.tianocore.frameworkwizard.module.Identification.SystemTables.SystemTablesIdentification;
import org.tianocore.frameworkwizard.module.Identification.SystemTables.SystemTablesVector;
/**
The class is used to create, update SystemTable of MSA/MBD file
It extends IInternalFrame
**/
public class ModuleSystemTables extends IInternalFrame {
///
/// Define class Serial Version UID
///
private static final long serialVersionUID = 7488769180379442276L;
//
//Define class members
//
private JPanel jContentPane = null;
private JLabel jLabelEntry = null;
private JTextField jTextFieldGuidC_Name = null;
private JLabel jLabelUsage = null;
private JComboBox jComboBoxUsage = null;
private StarLabel jStarLabel1 = null;
private StarLabel jStarLabel2 = null;
private JLabel jLabelFeatureFlag = null;
private JTextField jTextFieldFeatureFlag = null;
private JLabel jLabelArch = null;
private JTextArea jTextAreaList = null;
private JComboBox jComboBoxList = null;
private JButton jButtonAdd = null;
private JButton jButtonRemove = null;
private JButton jButtonUpdate = null;
private JScrollPane jScrollPane = null;
private JScrollPane jScrollPaneList = null;
private ICheckBoxList iCheckBoxListArch = null;
private JScrollPane jScrollPaneArch = null;
private JLabel jLabelHelpText = null;
private JTextField jTextFieldHelpText = null;
//
// Not used by UI
//
private int intSelectedItemId = 0;
private OpeningModuleType omt = null;
private ModuleSurfaceArea msa = null;
private SystemTablesDocument.SystemTables systemTables = null;
private SystemTablesIdentification id = null;
private SystemTablesVector vid = new SystemTablesVector();
private EnumerationData ed = new EnumerationData();
/**
This method initializes jTextFieldEntry
@return javax.swing.JTextField jTextFieldEntry
**/
private JTextField getJTextFieldEntry() {
if (jTextFieldGuidC_Name == null) {
jTextFieldGuidC_Name = new JTextField();
jTextFieldGuidC_Name.setBounds(new java.awt.Rectangle(160, 10, 320, 20));
jTextFieldGuidC_Name.setPreferredSize(new java.awt.Dimension(320,20));
}
return jTextFieldGuidC_Name;
}
/**
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));
jComboBoxUsage.setPreferredSize(new java.awt.Dimension(320,20));
}
return jComboBoxUsage;
}
/**
* This method initializes jTextFieldFeatureFlag
*
* @return javax.swing.JTextField
*/
private JTextField getJTextFieldFeatureFlag() {
if (jTextFieldFeatureFlag == null) {
jTextFieldFeatureFlag = new JTextField();
jTextFieldFeatureFlag.setBounds(new java.awt.Rectangle(160, 85, 320, 20));
jTextFieldFeatureFlag.setPreferredSize(new java.awt.Dimension(320,20));
}
return jTextFieldFeatureFlag;
}
/**
This method initializes jComboBoxFileList
@return javax.swing.JComboBox jComboBoxFileList
**/
private JComboBox getJComboBoxList() {
if (jComboBoxList == null) {
jComboBoxList = new JComboBox();
jComboBoxList.setBounds(new java.awt.Rectangle(15, 195, 210, 20));
jComboBoxList.addItemListener(this);
jComboBoxList.addActionListener(this);
jComboBoxList.setPreferredSize(new java.awt.Dimension(210, 20));
}
return jComboBoxList;
}
/**
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, 195, 80, 20));
jButtonAdd.setText("Add");
jButtonAdd.addActionListener(this);
jButtonAdd.setPreferredSize(new java.awt.Dimension(80, 20));
}
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, 195, 80, 20));
jButtonRemove.setText("Remove");
jButtonRemove.addActionListener(this);
jButtonRemove.setPreferredSize(new java.awt.Dimension(80, 20));
}
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, 195, 80, 20));
jButtonUpdate.setPreferredSize(new java.awt.Dimension(80, 20));
jButtonUpdate.setText("Update");
jButtonUpdate.addActionListener(this);
}
return jButtonUpdate;
}
/**
* This method initializes jScrollPaneFileList
*
* @return javax.swing.JScrollPane
*/
private JScrollPane getJScrollPaneList() {
if (jScrollPaneList == null) {
jScrollPaneList = new JScrollPane();
jScrollPaneList.setBounds(new java.awt.Rectangle(15, 220, 465, 240));
jScrollPaneList.setViewportView(getJTextAreaList());
jScrollPaneList.setPreferredSize(new java.awt.Dimension(465, 240));
}
return jScrollPaneList;
}
/**
This method initializes jScrollPane
@return javax.swing.JScrollPane
*/
private JScrollPane getJScrollPane() {
if (jScrollPane == null) {
jScrollPane = new JScrollPane();
jScrollPane.setViewportView(getJContentPane());
}
return jScrollPane;
}
/**
* This method initializes jTextAreaFileList
*
* @return javax.swing.JTextArea
*/
private JTextArea getJTextAreaList() {
if (jTextAreaList == null) {
jTextAreaList = new JTextArea();
jTextAreaList.setEditable(false);
}
return jTextAreaList;
}
/**
This method initializes iCheckBoxListArch
@return ICheckBoxList
**/
private ICheckBoxList getICheckBoxListSupportedArchitectures() {
if (iCheckBoxListArch == null) {
iCheckBoxListArch = new ICheckBoxList();
iCheckBoxListArch.addFocusListener(this);
iCheckBoxListArch.setToolTipText(DataType.SUP_ARCH_LIST_HELP_TEXT);
}
return iCheckBoxListArch;
}
/**
This method initializes jScrollPaneArch
@return javax.swing.JScrollPane
**/
private JScrollPane getJScrollPaneArch() {
if (jScrollPaneArch == null) {
jScrollPaneArch = new JScrollPane();
jScrollPaneArch.setBounds(new java.awt.Rectangle(160, 110, 320, 80));
jScrollPaneArch.setPreferredSize(new java.awt.Dimension(320, 80));
jScrollPaneArch.setViewportView(getICheckBoxListSupportedArchitectures());
}
return jScrollPaneArch;
}
/**
This method initializes jTextFieldHelpText
@return javax.swing.JTextField
**/
private JTextField getJTextFieldHelpText() {
if (jTextFieldHelpText == null) {
jTextFieldHelpText = new JTextField();
jTextFieldHelpText.setBounds(new java.awt.Rectangle(160, 60, 320, 20));
jTextFieldHelpText.setPreferredSize(new java.awt.Dimension(320, 20));
}
return jTextFieldHelpText;
}
public static void main(String[] args) {
}
/**
This method initializes this
**/
private void init() {
this.setSize(500, 515);
this.setContentPane(getJScrollPane());
this.setTitle("System Tables");
initFrame();
this.setViewMode(false);
}
/**
This method initializes this
Fill values to all fields if these values are not empty
@param inPackageDependencies
**/
private void init(SystemTables inSystemTables) {
init();
this.systemTables = inSystemTables;
if (this.systemTables != null) {
if (this.systemTables.getSystemTableCNamesList().size() > 0) {
for (int index = 0; index < this.systemTables.getSystemTableCNamesList().size(); index++) {
String arg0 = systemTables.getSystemTableCNamesList().get(index).getSystemTableCName();
String arg1 = null;
if (systemTables.getSystemTableCNamesList().get(index).getUsage() != null) {
arg1 = systemTables.getSystemTableCNamesList().get(index).getUsage().toString();
}
String arg2 = systemTables.getSystemTableCNamesList().get(index).getFeatureFlag();
Vector<String> arg3 = Tools.convertListToVector(systemTables.getSystemTableCNamesList().get(index).getSupArchList());
String arg4 = systemTables.getSystemTableCNamesList().get(index).getHelpText();
id = new SystemTablesIdentification(arg0, arg1, arg2, arg3, arg4);
vid.addSystemTables(id);
}
}
}
//
// Update the list
//
Tools.generateComboBoxByVector(jComboBoxList, vid.getSystemTablesName());
reloadListArea();
}
/**
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(OpeningModuleType inOmt) {
super();
this.omt = inOmt;
this.msa = omt.getXmlMsa();
init(msa.getSystemTables());
this.setVisible(true);
}
/**
Disable all components when the mode is view
@param isView true - The view mode; false - The non-view mode
**/
public void setViewMode(boolean isView) {
if (isView) {
this.jTextFieldGuidC_Name.setEnabled(!isView);
this.jComboBoxUsage.setEnabled(!isView);
}
}
/**
This method initializes jContentPane
@return javax.swing.JPanel jContentPane
**/
private JPanel getJContentPane() {
if (jContentPane == null) {
jLabelArch = new JLabel();
jLabelArch.setBounds(new java.awt.Rectangle(15, 110, 140, 20));
jLabelArch.setText("Arch");
jLabelFeatureFlag = new JLabel();
jLabelFeatureFlag.setBounds(new java.awt.Rectangle(15, 85, 140, 20));
jLabelFeatureFlag.setText("Feature Flag");
jLabelUsage = new JLabel();
jLabelUsage.setText("Usage");
jLabelUsage.setBounds(new java.awt.Rectangle(15, 35, 140, 20));
jLabelEntry = new JLabel();
jLabelEntry.setText("Guid C_Name");
jLabelEntry.setBounds(new java.awt.Rectangle(15, 10, 140, 20));
jLabelHelpText = new JLabel();
jLabelHelpText.setBounds(new java.awt.Rectangle(14, 60, 140, 20));
jLabelHelpText.setText("Help Text");
jContentPane = new JPanel();
jContentPane.setLayout(null);
jContentPane.setPreferredSize(new java.awt.Dimension(490, 475));
jContentPane.add(jLabelEntry, null);
jContentPane.add(getJTextFieldEntry(), null);
jContentPane.add(jLabelFeatureFlag, null);
jContentPane.add(getJTextFieldFeatureFlag(), null);
jContentPane.add(jLabelArch, null);
jContentPane.add(jLabelUsage, null);
jContentPane.add(getJComboBoxUsage(), 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(getJComboBoxList(), null);
jContentPane.add(getJButtonAdd(), null);
jContentPane.add(getJButtonRemove(), null);
jContentPane.add(getJButtonUpdate(), null);
jContentPane.add(getJScrollPaneList(), null);
jContentPane.add(getJScrollPaneArch(), null);
jContentPane.add(jLabelHelpText, null);
jContentPane.add(getJTextFieldHelpText(), null);
}
return jContentPane;
}
/**
This method initializes Usage type
**/
private void initFrame() {
Tools.generateComboBoxByVector(jComboBoxUsage, ed.getVSystemTableUsage());
this.iCheckBoxListArch.setAllItems(ed.getVSupportedArchitectures());
}
/* (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() == jButtonAdd) {
if (!checkAdd()) {
return;
}
addToList();
}
if (arg0.getSource() == jButtonRemove) {
removeFromList();
}
if (arg0.getSource() == jButtonUpdate) {
if (!checkAdd()) {
return;
}
updateForList();
}
}
/**
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 fields have correct data types
//
//
// Check GuidC_Name
//
if (isEmpty(this.jTextFieldGuidC_Name.getText())) {
Log.err("Guid C_Name couldn't be empty");
return false;
}
if (!isEmpty(this.jTextFieldGuidC_Name.getText())) {
if (!DataValidation.isC_NameType(this.jTextFieldGuidC_Name.getText())) {
Log.err("Incorrect data type for Guid C_Name");
return false;
}
}
//
// Check FeatureFlag
//
if (!isEmpty(this.jTextFieldFeatureFlag.getText())) {
if (!DataValidation.isFeatureFlag(this.jTextFieldFeatureFlag.getText())) {
Log.err("Incorrect data type for Feature Flag");
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 {
int count = this.vid.size();
this.systemTables = SystemTables.Factory.newInstance();
if (count > 0) {
for (int index = 0; index < count; index++) {
SystemTableCNames p = SystemTableCNames.Factory.newInstance();
if (!isEmpty(vid.getSystemTables(index).getName())) {
p.setSystemTableCName(vid.getSystemTables(index).getName());
}
if (!isEmpty(vid.getSystemTables(index).getUsage())) {
p.setUsage(SystemTableUsage.Enum.forString(vid.getSystemTables(index).getUsage()));
}
if (!isEmpty(vid.getSystemTables(index).getFeatureFlag())) {
p.setFeatureFlag(vid.getSystemTables(index).getFeatureFlag());
}
if (vid.getSystemTables(index).getSupArchList() != null && vid.getSystemTables(index).getSupArchList().size() > 0) {
p.setSupArchList(vid.getSystemTables(index).getSupArchList());
}
if (!isEmpty(vid.getSystemTables(index).getHelp())) {
p.setHelpText(vid.getSystemTables(index).getHelp());
}
this.systemTables.addNewSystemTableCNames();
this.systemTables.setSystemTableCNamesArray(systemTables.getSystemTableCNamesList().size() - 1, p);
}
}
this.msa.setSystemTables(systemTables);
this.omt.setSaved(false);
} catch (Exception e) {
Log.err("Update System Tables", e.getMessage());
}
}
/* (non-Javadoc)
* @see java.awt.event.ComponentListener#componentResized(java.awt.event.ComponentEvent)
*
* Override componentResized to resize all components when frame's size is changed
*/
public void componentResized(ComponentEvent arg0) {
int intCurrentWidth = this.getJContentPane().getWidth();
int intCurrentHeight = this.getJContentPane().getHeight();
int intPreferredWidth = this.getJContentPane().getPreferredSize().width;
int intPreferredHeight = this.getJContentPane().getPreferredSize().height;
resizeComponentWidth(jTextFieldGuidC_Name, intCurrentWidth, intPreferredWidth);
resizeComponentWidth(jComboBoxUsage, intCurrentWidth, intPreferredWidth);
resizeComponentWidth(jTextFieldHelpText, intCurrentWidth, intPreferredWidth);
resizeComponentWidth(jTextFieldFeatureFlag, intCurrentWidth, intPreferredWidth);
resizeComponentWidth(jScrollPaneArch, intCurrentWidth, intPreferredWidth);
resizeComponentWidth(jComboBoxList, intCurrentWidth, intPreferredWidth);
resizeComponent(jScrollPaneList, intCurrentWidth, intCurrentHeight, intPreferredWidth, intPreferredHeight);
relocateComponentX(jButtonAdd, intCurrentWidth, intPreferredWidth, DataType.SPACE_TO_RIGHT_FOR_ADD_BUTTON);
relocateComponentX(jButtonRemove, intCurrentWidth, intPreferredWidth, DataType.SPACE_TO_RIGHT_FOR_REMOVE_BUTTON);
relocateComponentX(jButtonUpdate, intCurrentWidth, intPreferredWidth, DataType.SPACE_TO_RIGHT_FOR_UPDATE_BUTTON);
}
private SystemTablesIdentification getCurrentSystemTables() {
String arg0 = this.jTextFieldGuidC_Name.getText();
String arg1 = this.jComboBoxUsage.getSelectedItem().toString();
String arg2 = this.jTextFieldFeatureFlag.getText();
Vector<String> arg3 = this.iCheckBoxListArch.getAllCheckedItemsString();
String arg4 = this.jTextFieldHelpText.getText();
id = new SystemTablesIdentification(arg0, arg1, arg2, arg3, arg4);
return id;
}
/**
Add current item to Vector
**/
private void addToList() {
intSelectedItemId = vid.size();
vid.addSystemTables(getCurrentSystemTables());
jComboBoxList.addItem(id.getName());
jComboBoxList.setSelectedItem(id.getName());
//
// Reset select item index
//
intSelectedItemId = vid.size();
//
// Reload all fields of selected item
//
reloadFromList();
//
// Save to memory
//
save();
}
/**
Remove current item from Vector
**/
private void removeFromList() {
//
// Check if exist items
//
if (this.vid.size() < 1) {
return;
}
int intTempIndex = intSelectedItemId;
jComboBoxList.removeItemAt(intSelectedItemId);
vid.removeSystemTables(intTempIndex);
//
// Reload all fields of selected item
//
reloadFromList();
//
// Save to memory
//
save();
}
/**
Update current item of Vector
**/
private void updateForList() {
//
// Check if exist items
//
if (this.vid.size() < 1) {
return;
}
//
// Backup selected item index
//
int intTempIndex = intSelectedItemId;
vid.updateSystemTables(getCurrentSystemTables(), intTempIndex);
jComboBoxList.removeAllItems();
for (int index = 0; index < vid.size(); index++) {
jComboBoxList.addItem(vid.getSystemTables(index).getName());
}
//
// Restore selected item index
//
intSelectedItemId = intTempIndex;
//
// Reset select item index
//
jComboBoxList.setSelectedIndex(intSelectedItemId);
//
// Reload all fields of selected item
//
reloadFromList();
//
// Save to memory
//
save();
}
/**
Refresh all fields' values of selected item of Vector
**/
private void reloadFromList() {
if (vid.size() > 0) {
//
// Get selected item index
//
intSelectedItemId = jComboBoxList.getSelectedIndex();
this.jTextFieldGuidC_Name.setText(vid.getSystemTables(intSelectedItemId).getName());
this.jComboBoxUsage.setSelectedItem(vid.getSystemTables(intSelectedItemId).getUsage());
this.jTextFieldHelpText.setText(vid.getSystemTables(intSelectedItemId).getHelp());
jTextFieldFeatureFlag.setText(vid.getSystemTables(intSelectedItemId).getFeatureFlag());
iCheckBoxListArch.setAllItemsUnchecked();
iCheckBoxListArch.initCheckedItem(true, vid.getSystemTables(intSelectedItemId).getSupArchList());
} else {
}
reloadListArea();
}
/**
Update list area pane via the elements of Vector
**/
private void reloadListArea() {
String strListItem = "";
for (int index = 0; index < vid.size(); index++) {
strListItem = strListItem + vid.getSystemTables(index).getName() + DataType.UNIX_LINE_SEPARATOR;
}
this.jTextAreaList.setText(strListItem);
}
/* (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.getSource() == this.jComboBoxList && arg0.getStateChange() == ItemEvent.SELECTED) {
reloadFromList();
}
}
}

View File

@@ -0,0 +1,813 @@
/** @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.frameworkwizard.module.ui;
import java.awt.event.ActionEvent;
import java.awt.event.ComponentEvent;
import java.awt.event.ItemEvent;
import java.util.Vector;
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.VariableUsage;
import org.tianocore.VariablesDocument;
import org.tianocore.ModuleSurfaceAreaDocument.ModuleSurfaceArea;
import org.tianocore.VariablesDocument.Variables;
import org.tianocore.VariablesDocument.Variables.Variable;
import org.tianocore.frameworkwizard.common.DataType;
import org.tianocore.frameworkwizard.common.DataValidation;
import org.tianocore.frameworkwizard.common.EnumerationData;
import org.tianocore.frameworkwizard.common.Log;
import org.tianocore.frameworkwizard.common.OpeningModuleType;
import org.tianocore.frameworkwizard.common.Tools;
import org.tianocore.frameworkwizard.common.ui.IInternalFrame;
import org.tianocore.frameworkwizard.common.ui.StarLabel;
import org.tianocore.frameworkwizard.common.ui.iCheckBoxList.ICheckBoxList;
import org.tianocore.frameworkwizard.module.Identification.Variables.VariablesIdentification;
import org.tianocore.frameworkwizard.module.Identification.Variables.VariablesVector;
/**
The class is used to create, update Variable of MSA/MBD file
It extends IInternalFrame
**/
public class ModuleVariables extends IInternalFrame {
///
/// Define class Serial Version UID
///
private static final long serialVersionUID = -6998982978030439446L;
//
//Define class members
//
private JPanel jContentPane = null;
private JLabel jLabelVariableName = null;
private JTextField jTextFieldVariableName = null;
private JLabel jLabelUsage = null;
private JComboBox jComboBoxUsage = null;
private StarLabel jStarLabel1 = null;
private StarLabel jStarLabel2 = null;
private JTextArea jTextAreaList = null;
private JComboBox jComboBoxList = null;
private JButton jButtonAdd = null;
private JButton jButtonRemove = null;
private JButton jButtonUpdate = null;
private JScrollPane jScrollPane = null;
private JScrollPane jScrollPaneList = null;
private JLabel jLabelGuidCName = null;
private JTextField jTextFieldGuidC_Name = null;
private JTextField jTextFieldFeatureFlag = null;
private JLabel jLabelFeatureFlag = null;
private JLabel jLabelArch = null;
private ICheckBoxList iCheckBoxListArch = null;
private JScrollPane jScrollPaneArch = null;
private JLabel jLabelHelpText = null;
private JTextField jTextFieldHelpText = null;
//
// Not used by UI
//
private int intSelectedItemId = 0;
private OpeningModuleType omt = null;
private ModuleSurfaceArea msa = null;
private VariablesDocument.Variables variables = null;
private VariablesIdentification id = null;
private VariablesVector vid = new VariablesVector();
private EnumerationData ed = new EnumerationData();
/**
This method initializes jTextFieldString
@return javax.swing.JTextField jTextFieldString
**/
private JTextField getJTextFieldString() {
if (jTextFieldVariableName == null) {
jTextFieldVariableName = new JTextField();
jTextFieldVariableName.setSize(new java.awt.Dimension(320, 20));
jTextFieldVariableName.setPreferredSize(new java.awt.Dimension(320, 20));
jTextFieldVariableName.setLocation(new java.awt.Point(160, 10));
}
return jTextFieldVariableName;
}
/**
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));
jComboBoxUsage.setPreferredSize(new java.awt.Dimension(320, 20));
}
return jComboBoxUsage;
}
/**
This method initializes jComboBoxFileList
@return javax.swing.JComboBox jComboBoxFileList
**/
private JComboBox getJComboBoxList() {
if (jComboBoxList == null) {
jComboBoxList = new JComboBox();
jComboBoxList.setBounds(new java.awt.Rectangle(15, 220, 210, 20));
jComboBoxList.addItemListener(this);
jComboBoxList.addActionListener(this);
jComboBoxList.setPreferredSize(new java.awt.Dimension(210, 20));
}
return jComboBoxList;
}
/**
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, 220, 80, 20));
jButtonAdd.setText("Add");
jButtonAdd.addActionListener(this);
jButtonAdd.setPreferredSize(new java.awt.Dimension(80, 20));
}
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, 220, 80, 20));
jButtonRemove.setText("Remove");
jButtonRemove.addActionListener(this);
jButtonRemove.setPreferredSize(new java.awt.Dimension(80, 20));
}
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, 220, 80, 20));
jButtonUpdate.setPreferredSize(new java.awt.Dimension(80, 20));
jButtonUpdate.setText("Update");
jButtonUpdate.addActionListener(this);
}
return jButtonUpdate;
}
/**
* This method initializes jScrollPaneFileList
*
* @return javax.swing.JScrollPane
*/
private JScrollPane getJScrollPaneList() {
if (jScrollPaneList == null) {
jScrollPaneList = new JScrollPane();
jScrollPaneList.setBounds(new java.awt.Rectangle(15, 245, 465, 240));
jScrollPaneList.setViewportView(getJTextAreaList());
jScrollPaneList.setPreferredSize(new java.awt.Dimension(465, 240));
}
return jScrollPaneList;
}
/**
This method initializes jScrollPane
@return javax.swing.JScrollPane
*/
private JScrollPane getJScrollPane() {
if (jScrollPane == null) {
jScrollPane = new JScrollPane();
jScrollPane.setViewportView(getJContentPane());
}
return jScrollPane;
}
/**
* This method initializes jTextAreaFileList
*
* @return javax.swing.JTextArea
*/
private JTextArea getJTextAreaList() {
if (jTextAreaList == null) {
jTextAreaList = new JTextArea();
jTextAreaList.setEditable(false);
}
return jTextAreaList;
}
/**
* This method initializes jTextFieldGuidCName
*
* @return javax.swing.JTextField
*/
private JTextField getJTextFieldGuidC_Name() {
if (jTextFieldGuidC_Name == null) {
jTextFieldGuidC_Name = new JTextField();
jTextFieldGuidC_Name.setBounds(new java.awt.Rectangle(160, 35, 320, 20));
jTextFieldGuidC_Name.setPreferredSize(new java.awt.Dimension(320, 20));
}
return jTextFieldGuidC_Name;
}
/**
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, 110, 320, 20));
jTextFieldFeatureFlag.setPreferredSize(new java.awt.Dimension(320, 20));
}
return jTextFieldFeatureFlag;
}
/**
This method initializes iCheckBoxListArch
@return ICheckBoxList
**/
private ICheckBoxList getICheckBoxListSupportedArchitectures() {
if (iCheckBoxListArch == null) {
iCheckBoxListArch = new ICheckBoxList();
iCheckBoxListArch.addFocusListener(this);
iCheckBoxListArch.setToolTipText(DataType.SUP_ARCH_LIST_HELP_TEXT);
}
return iCheckBoxListArch;
}
/**
This method initializes jScrollPaneArch
@return javax.swing.JScrollPane
**/
private JScrollPane getJScrollPaneArch() {
if (jScrollPaneArch == null) {
jScrollPaneArch = new JScrollPane();
jScrollPaneArch.setBounds(new java.awt.Rectangle(160, 135, 320, 80));
jScrollPaneArch.setPreferredSize(new java.awt.Dimension(320, 80));
jScrollPaneArch.setViewportView(getICheckBoxListSupportedArchitectures());
}
return jScrollPaneArch;
}
/**
This method initializes jTextFieldHelpText
@return javax.swing.JTextField
**/
private JTextField getJTextFieldHelpText() {
if (jTextFieldHelpText == null) {
jTextFieldHelpText = new JTextField();
jTextFieldHelpText.setBounds(new java.awt.Rectangle(160, 85, 320, 20));
jTextFieldHelpText.setPreferredSize(new java.awt.Dimension(320, 20));
}
return jTextFieldHelpText;
}
public static void main(String[] args) {
}
/**
This method initializes this
**/
private void init() {
this.setSize(500, 515);
this.setContentPane(getJScrollPane());
this.setTitle("Variables");
initFrame();
this.setViewMode(false);
}
/**
This method initializes this
Fill values to all fields if these values are not empty
@param inPackageDependencies
**/
private void init(Variables inVariables) {
init();
this.variables = inVariables;
if (this.variables != null) {
if (this.variables.getVariableList().size() > 0) {
for (int index = 0; index < this.variables.getVariableList().size(); index++) {
String arg0 = variables.getVariableList().get(index).getVariableName();
String arg1 = variables.getVariableList().get(index).getGuidCName();
String arg2 = null;
if (variables.getVariableList().get(index).getUsage() != null) {
arg2 = variables.getVariableList().get(index).getUsage().toString();
}
String arg3 = variables.getVariableList().get(index).getFeatureFlag();
Vector<String> arg4 = Tools.convertListToVector(variables.getVariableList().get(index).getSupArchList());
String arg5 = variables.getVariableList().get(index).getHelpText();
id = new VariablesIdentification(arg0, arg1, arg2, arg3, arg4, arg5);
vid.addVariables(id);
}
}
}
//
// Update the list
//
Tools.generateComboBoxByVector(jComboBoxList, vid.getVariablesName());
reloadListArea();
}
/**
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(OpeningModuleType inOmt) {
super();
this.omt = inOmt;
this.msa = omt.getXmlMsa();
init(msa.getVariables());
this.setVisible(true);
}
/**
Disable all components when the mode is view
@param isView true - The view mode; false - The non-view mode
**/
public void setViewMode(boolean isView) {
if (isView) {
this.jTextFieldVariableName.setEnabled(!isView);
this.jComboBoxUsage.setEnabled(!isView);
}
}
/**
This method initializes jContentPane
@return javax.swing.JPanel jContentPane
**/
private JPanel getJContentPane() {
if (jContentPane == null) {
jLabelGuidCName = new JLabel();
jLabelGuidCName.setBounds(new java.awt.Rectangle(15, 35, 140, 20));
jLabelGuidCName.setText("Guid C_Name");
jLabelUsage = new JLabel();
jLabelUsage.setText("Usage");
jLabelUsage.setBounds(new java.awt.Rectangle(15, 60, 140, 20));
jLabelVariableName = new JLabel();
jLabelVariableName.setText("Variable Name");
jLabelVariableName.setLocation(new java.awt.Point(15, 10));
jLabelVariableName.setSize(new java.awt.Dimension(140, 20));
jLabelArch = new JLabel();
jLabelArch.setBounds(new java.awt.Rectangle(15, 135, 140, 20));
jLabelArch.setText("Arch");
jLabelFeatureFlag = new JLabel();
jLabelFeatureFlag.setText("Feature Flag");
jLabelFeatureFlag.setBounds(new java.awt.Rectangle(15, 110, 140, 20));
jContentPane = new JPanel();
jContentPane.setLayout(null);
jContentPane.setPreferredSize(new java.awt.Dimension(490, 495));
jContentPane.add(jLabelVariableName, null);
jContentPane.add(jLabelGuidCName, null);
jContentPane.add(getJTextFieldGuidC_Name(), null);
jContentPane.add(getJTextFieldString(), null);
jContentPane.add(jLabelUsage, null);
jContentPane.add(getJComboBoxUsage(), null);
jStarLabel1 = new StarLabel();
jStarLabel1.setLocation(new java.awt.Point(0, 10));
jStarLabel2 = new StarLabel();
jStarLabel2.setLocation(new java.awt.Point(0, 35));
jLabelHelpText = new JLabel();
jLabelHelpText.setBounds(new java.awt.Rectangle(14, 85, 140, 20));
jLabelHelpText.setText("Help Text");
jContentPane.add(jStarLabel1, null);
jContentPane.add(jStarLabel2, null);
jContentPane.add(getJComboBoxList(), null);
jContentPane.add(getJButtonAdd(), null);
jContentPane.add(getJButtonRemove(), null);
jContentPane.add(getJButtonUpdate(), null);
jContentPane.add(getJScrollPaneList(), null);
jContentPane.add(jLabelArch, null);
jContentPane.add(jLabelFeatureFlag, null);
jContentPane.add(getJTextFieldFeatureFlag(), null);
jContentPane.add(getJScrollPaneArch(), null);
jContentPane.add(jLabelHelpText, null);
jContentPane.add(getJTextFieldHelpText(), 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() == jButtonAdd) {
if (!checkAdd()) {
return;
}
addToList();
}
if (arg0.getSource() == jButtonRemove) {
removeFromList();
}
if (arg0.getSource() == jButtonUpdate) {
if (!checkAdd()) {
return;
}
updateForList();
}
}
/**
This method initializes Usage type
**/
private void initFrame() {
Tools.generateComboBoxByVector(jComboBoxUsage, ed.getVPpiUsage());
this.iCheckBoxListArch.setAllItems(ed.getVSupportedArchitectures());
}
/**
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 fields have correct data types
//
//
// Check VariableName
//
if (isEmpty(this.jTextFieldVariableName.getText())) {
Log.err("Variable Name couldn't be empty");
return false;
}
if (!isEmpty(this.jTextFieldVariableName.getText())) {
if (!DataValidation.isHexWordArrayType(this.jTextFieldVariableName.getText())) {
Log.err("Incorrect data type for Variable Name");
return false;
}
}
//
// Check GuidC_Name
//
if (isEmpty(this.jTextFieldGuidC_Name.getText())) {
Log.err("Guid C_Name couldn't be empty");
return false;
}
if (!isEmpty(this.jTextFieldGuidC_Name.getText())) {
if (!DataValidation.isC_NameType(this.jTextFieldGuidC_Name.getText())) {
Log.err("Incorrect data type for Guid C_Name");
return false;
}
}
//
// Check FeatureFlag
//
if (!isEmpty(this.jTextFieldFeatureFlag.getText())) {
if (!DataValidation.isFeatureFlag(this.jTextFieldFeatureFlag.getText())) {
Log.err("Incorrect data type for Feature Flag");
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 {
int count = this.vid.size();
this.variables = Variables.Factory.newInstance();
if (count > 0) {
for (int index = 0; index < count; index++) {
Variable p = Variable.Factory.newInstance();
if (!isEmpty(vid.getVariables(index).getName())) {
p.setVariableName(vid.getVariables(index).getName());
}
if (!isEmpty(vid.getVariables(index).getGuid())) {
p.setGuidCName(vid.getVariables(index).getGuid());
}
if (!isEmpty(vid.getVariables(index).getUsage())) {
p.setUsage(VariableUsage.Enum.forString(vid.getVariables(index).getUsage()));
}
if (!isEmpty(vid.getVariables(index).getFeatureFlag())) {
p.setFeatureFlag(vid.getVariables(index).getFeatureFlag());
}
if (vid.getVariables(index).getSupArchList() != null && vid.getVariables(index).getSupArchList().size() > 0) {
p.setSupArchList(vid.getVariables(index).getSupArchList());
}
if (!isEmpty(vid.getVariables(index).getHelp())) {
p.setHelpText(vid.getVariables(index).getHelp());
}
this.variables.addNewVariable();
this.variables.setVariableArray(variables.getVariableList().size() - 1, p);
}
}
this.msa.setVariables(variables);
this.omt.setSaved(false);
} catch (Exception e) {
Log.err("Update Variables", e.getMessage());
}
}
/* (non-Javadoc)
* @see java.awt.event.ComponentListener#componentResized(java.awt.event.ComponentEvent)
*
* Override componentResized to resize all components when frame's size is changed
*/
public void componentResized(ComponentEvent arg0) {
int intCurrentWidth = this.getJContentPane().getWidth();
int intCurrentHeight = this.getJContentPane().getHeight();
int intPreferredWidth = this.getJContentPane().getPreferredSize().width;
int intPreferredHeight = this.getJContentPane().getPreferredSize().height;
resizeComponentWidth(jTextFieldVariableName, intCurrentWidth, intPreferredWidth);
resizeComponentWidth(jTextFieldGuidC_Name, intCurrentWidth, intPreferredWidth);
resizeComponentWidth(jComboBoxUsage, intCurrentWidth, intPreferredWidth);
resizeComponentWidth(jTextFieldHelpText, intCurrentWidth, intPreferredWidth);
resizeComponentWidth(jTextFieldFeatureFlag, intCurrentWidth, intPreferredWidth);
resizeComponentWidth(jScrollPaneArch, intCurrentWidth, intPreferredWidth);
resizeComponentWidth(jComboBoxList, intCurrentWidth, intPreferredWidth);
resizeComponent(jScrollPaneList, intCurrentWidth, intCurrentHeight, intPreferredWidth, intPreferredHeight);
relocateComponentX(jButtonAdd, intCurrentWidth, intPreferredWidth, DataType.SPACE_TO_RIGHT_FOR_ADD_BUTTON);
relocateComponentX(jButtonRemove, intCurrentWidth, intPreferredWidth, DataType.SPACE_TO_RIGHT_FOR_REMOVE_BUTTON);
relocateComponentX(jButtonUpdate, intCurrentWidth, intPreferredWidth, DataType.SPACE_TO_RIGHT_FOR_UPDATE_BUTTON);
}
private VariablesIdentification getCurrentVariables() {
String arg0 = this.jTextFieldVariableName.getText();
String arg1 = this.jTextFieldGuidC_Name.getText();
String arg2 = this.jComboBoxUsage.getSelectedItem().toString();
String arg3 = this.jTextFieldFeatureFlag.getText();
Vector<String> arg4 = this.iCheckBoxListArch.getAllCheckedItemsString();
String arg5 = this.jTextFieldHelpText.getText();
id = new VariablesIdentification(arg0, arg1, arg2, arg3, arg4, arg5);
return id;
}
/**
Add current item to Vector
**/
private void addToList() {
intSelectedItemId = vid.size();
vid.addVariables(getCurrentVariables());
jComboBoxList.addItem(id.getName());
jComboBoxList.setSelectedItem(id.getName());
//
// Reset select item index
//
intSelectedItemId = vid.size();
//
// Reload all fields of selected item
//
reloadFromList();
//
// Save to memory
//
save();
}
/**
Remove current item from Vector
**/
private void removeFromList() {
//
// Check if exist items
//
if (this.vid.size() < 1) {
return;
}
int intTempIndex = intSelectedItemId;
jComboBoxList.removeItemAt(intSelectedItemId);
vid.removeVariables(intTempIndex);
//
// Reload all fields of selected item
//
reloadFromList();
//
// Save to memory
//
save();
}
/**
Update current item of Vector
**/
private void updateForList() {
//
// Check if exist items
//
if (this.vid.size() < 1) {
return;
}
//
// Backup selected item index
//
int intTempIndex = intSelectedItemId;
vid.updateVariables(getCurrentVariables(), intTempIndex);
jComboBoxList.removeAllItems();
for (int index = 0; index < vid.size(); index++) {
jComboBoxList.addItem(vid.getVariables(index).getName());
}
//
// Restore selected item index
//
intSelectedItemId = intTempIndex;
//
// Reset select item index
//
jComboBoxList.setSelectedIndex(intSelectedItemId);
//
// Reload all fields of selected item
//
reloadFromList();
//
// Save to memory
//
save();
}
/**
Refresh all fields' values of selected item of Vector
**/
private void reloadFromList() {
if (vid.size() > 0) {
//
// Get selected item index
//
intSelectedItemId = jComboBoxList.getSelectedIndex();
this.jTextFieldVariableName.setText(vid.getVariables(intSelectedItemId).getName());
this.jTextFieldGuidC_Name.setText(vid.getVariables(intSelectedItemId).getGuid());
this.jComboBoxUsage.setSelectedItem(vid.getVariables(intSelectedItemId).getUsage());
this.jTextFieldHelpText.setText(vid.getVariables(intSelectedItemId).getHelp());
jTextFieldFeatureFlag.setText(vid.getVariables(intSelectedItemId).getFeatureFlag());
iCheckBoxListArch.setAllItemsUnchecked();
iCheckBoxListArch.initCheckedItem(true, vid.getVariables(intSelectedItemId).getSupArchList());
} else {
}
reloadListArea();
}
/**
Update list area pane via the elements of Vector
**/
private void reloadListArea() {
String strListItem = "";
for (int index = 0; index < vid.size(); index++) {
strListItem = strListItem + vid.getVariables(index).getName() + DataType.UNIX_LINE_SEPARATOR;
}
this.jTextAreaList.setText(strListItem);
}
/* (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.getSource() == this.jComboBoxList && arg0.getStateChange() == ItemEvent.SELECTED) {
reloadFromList();
}
}
}

View File

@@ -0,0 +1,60 @@
/** @file
The file is used to save basic information of package
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.frameworkwizard.packaging;
import java.io.File;
import org.tianocore.frameworkwizard.common.Identification;
public class PackageIdentification extends Identification{
//
// It is optional
//
private File spdFile;
public PackageIdentification(String name, String guid, String version){
super(name, guid, version);
}
public PackageIdentification(String name, String guid, String version, String path){
super(name, guid, version, path);
}
public PackageIdentification(Identification id){
super(id.getName(), id.getGuid(), id.getVersion(), id.getPath());
}
public PackageIdentification(String name, String guid, String version, File spdFile){
super(name, guid, version);
this.spdFile = spdFile;
}
public File getSpdFile() {
return spdFile;
}
public String toString(){
return "Package " + this.getName() + "[" + this.getGuid() + "]";
}
public void setSpdFile(File spdFile) {
this.spdFile = spdFile;
}
public String getPackageDir(){
return spdFile.getParent();
}
}

View File

@@ -0,0 +1,482 @@
/** @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.frameworkwizard.packaging.ui;
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.frameworkwizard.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{
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}";
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 = GenGuidDialog.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(GenGuidDialog.guidRegistryPat)){
return;
}
if (jTextField.getText().matches(GenGuidDialog.guidArrayPat)) {
jTextField.setText(GenGuidDialog.formatGuidString(jTextField.getText()));
return;
}
if (jTextField.getText().length()>0)
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(GenGuidDialog.guidArrayPat)){
return;
}
if (jTextField.getText().matches(GenGuidDialog.guidRegistryPat)) {
jTextField.setText(GenGuidDialog.formatGuidString(jTextField.getText()));
return;
}
if (jTextField.getText().length()>0)
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.setEnabled(false);
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.setActionCommand("GenGuidValue");
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(GenGuidDialog.guidArrayPat))
|| (jRadioButton.isSelected() && jTextField.getText().matches(GenGuidDialog.guidRegistryPat))) {
jTextField.setText(GenGuidDialog.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);
}
public static String formatGuidString (String guidNameConv) {
String[] strList;
String guid = "";
int index = 0;
if (guidNameConv
.matches(GenGuidDialog.guidRegistryPat)) {
strList = guidNameConv.split("-");
guid = "0x" + strList[0] + ", ";
guid = guid + "0x" + strList[1] + ", ";
guid = guid + "0x" + strList[2] + ", ";
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;
}
return guid;
}
else if (guidNameConv
.matches(GenGuidDialog.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";
}
}
} // @jve:decl-index=0:visual-constraint="10,10"

View File

@@ -0,0 +1,92 @@
/** @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.frameworkwizard.packaging.ui;
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.frameworkwizard.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();
}
}
}

View File

@@ -0,0 +1,766 @@
/** @file
Java class SpdGuidDecls 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.frameworkwizard.packaging.ui;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ComponentEvent;
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.JTable;
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.ListSelectionModel;
import javax.swing.event.InternalFrameAdapter;
import javax.swing.event.InternalFrameEvent;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import javax.swing.event.TableModelEvent;
import javax.swing.event.TableModelListener;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableModel;
import org.tianocore.PackageSurfaceAreaDocument;
import org.tianocore.frameworkwizard.common.DataType;
import org.tianocore.frameworkwizard.common.Tools;
import org.tianocore.frameworkwizard.common.ui.IInternalFrame;
import org.tianocore.frameworkwizard.common.ui.StarLabel;
import org.tianocore.frameworkwizard.common.ui.iCheckBoxList.ICheckBoxList;
/**
GUI for create library definition elements of spd file.
@since PackageEditor 1.0
**/
public class SpdGuidDecls extends IInternalFrame implements TableModelListener{
static JFrame frame;
private SpdFileContents sfc = null;
private JTable jTable = null;
private DefaultTableModel model = null;
private JPanel jContentPane = null;
private JTextField jTextFieldAdd = null;
private JScrollPane jScrollPane = null;
private JButton jButtonAdd = null;
private JButton jButtonRemove = null;
private JButton jButtonClearAll = null;
private JButton jButtonCancel = null;
private JButton jButtonOk = null;
private JButton jButtonGen = null;
private StarLabel jStarLabel1 = null;
private StarLabel jStarLabel2 = null;
private StarLabel jStarLabel3 = null;
private StarLabel jStarLabel4 = null;
protected int selectedRow = -1;
private JLabel jLabelName = null;
private JScrollPane jScrollPaneModule = null;
private JTextField jTextFieldName = null;
private JScrollPane jScrollPaneArch = null;
private JScrollPane jScrollPaneGuid = null;
private JLabel jLabelGuid = null;
private JScrollPane topScrollPane = null; // @jve:decl-index=0:visual-constraint="10,213"
private JLabel jLabelVer = null;
private GenGuidDialog guidDialog = null;
private JTextField jTextFieldVersion = null;
private JLabel jLabel = null;
private JTextField jTextField = null;
private JLabel jLabel1 = null;
private JLabel jLabel2 = null;
private ICheckBoxList iCheckBoxList = null;
private ICheckBoxList iCheckBoxList1 = null;
private ICheckBoxList iCheckBoxList2 = null;
private JLabel jLabel3 = null;
/**
This method initializes this
**/
protected void initialize() {
this.setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
}
/**
This method initializes jTextFieldAdd
@return javax.swing.JTextField
**/
protected JTextField getJTextFieldAdd() {
if (jTextFieldAdd == null) {
jTextFieldAdd = new JTextField();
jTextFieldAdd.setBounds(new java.awt.Rectangle(137,35,337,20));
jTextFieldAdd.setPreferredSize(new java.awt.Dimension(335,20));
}
return jTextFieldAdd;
}
/**
This method initializes jScrollPane
@return javax.swing.JScrollPane
**/
protected JScrollPane getJScrollPane() {
if (jScrollPane == null) {
jScrollPane = new JScrollPane();
jScrollPane.setBounds(new java.awt.Rectangle(5,256,472,196));
jScrollPane.setViewportView(getJTable());
}
return jScrollPane;
}
/**
This method initializes jTable
@return javax.swing.JTable
**/
protected JTable getJTable() {
if (jTable == null) {
model = new DefaultTableModel();
jTable = new JTable(model);
jTable.setRowHeight(20);
jTable.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_OFF);
model.addColumn("Name");
model.addColumn("C_Name");
model.addColumn("GUID Value");
model.addColumn("HelpText");
model.addColumn("SupportedArch");
model.addColumn("SupportedModuleType");
model.addColumn("GuidTypes");
jTable.getColumnModel().getColumn(2).setCellEditor(new GuidEditor());
jTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
jTable.getSelectionModel().addListSelectionListener(new ListSelectionListener(){
public void valueChanged(ListSelectionEvent e) {
if (e.getValueIsAdjusting()){
return;
}
ListSelectionModel lsm = (ListSelectionModel)e.getSource();
if (lsm.isSelectionEmpty()) {
return;
}
else{
selectedRow = lsm.getMinSelectionIndex();
}
}
});
jTable.getModel().addTableModelListener(this);
}
return jTable;
}
public void tableChanged(TableModelEvent arg0) {
// TODO Auto-generated method stub
int row = arg0.getFirstRow();
TableModel m = (TableModel)arg0.getSource();
if (arg0.getType() == TableModelEvent.UPDATE){
updateRow(row, m);
}
}
protected void updateRow(int row, TableModel m){
String name = m.getValueAt(row, 0) + "";
String cName = m.getValueAt(row, 1) + "";
String guid = m.getValueAt(row, 2) + "";
String help = m.getValueAt(row, 3) + "";
String archList = null;
if (m.getValueAt(row, 4) != null){
archList = m.getValueAt(row, 4).toString();
}
String modTypeList = null;
if (m.getValueAt(row, 5) != null) {
modTypeList = m.getValueAt(row, 5).toString();
}
String guidTypeList = null;
if (m.getValueAt(row, 6) != null){
guidTypeList = m.getValueAt(row, 6).toString();
}
sfc.updateSpdGuidDecl(row, name, cName, guid, help, archList, modTypeList, guidTypeList);
}
/**
This method initializes jButtonAdd
@return javax.swing.JButton
**/
protected JButton getJButtonAdd() {
if (jButtonAdd == null) {
jButtonAdd = new JButton();
jButtonAdd.setBounds(new java.awt.Rectangle(167,227,90,20));
jButtonAdd.setText("Add");
jButtonAdd.addActionListener(this);
}
return jButtonAdd;
}
/**
This method initializes jButtonRemove
@return javax.swing.JButton
**/
protected JButton getJButtonRemove() {
if (jButtonRemove == null) {
jButtonRemove = new JButton();
jButtonRemove.setBounds(new java.awt.Rectangle(270,227,90,20));
jButtonRemove.setText("Remove");
jButtonRemove.addActionListener(this);
}
return jButtonRemove;
}
/**
This method initializes jButtonRemoveAll
@return javax.swing.JButton
**/
protected JButton getJButtonClearAll() {
if (jButtonClearAll == null) {
jButtonClearAll = new JButton();
jButtonClearAll.setBounds(new java.awt.Rectangle(380,227,90,20));
jButtonClearAll.setText("Clear All");
jButtonClearAll.addActionListener(this);
}
return jButtonClearAll;
}
/**
This method initializes jButtonCancel
@return javax.swing.JButton
**/
protected 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.setVisible(false);
jButtonCancel.addActionListener(this);
}
return jButtonCancel;
}
/**
This method initializes jButton
@return javax.swing.JButton
**/
protected 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.setVisible(false);
jButtonOk.addActionListener(this);
}
return jButtonOk;
}
/**
This is the default constructor
**/
public SpdGuidDecls() {
super();
initialize();
init();
}
public SpdGuidDecls(PackageSurfaceAreaDocument.PackageSurfaceArea inPsa){
this();
sfc = new SpdFileContents(inPsa);
init(sfc);
}
/**
This method initializes this
@return void
**/
protected void init() {
this.setContentPane(getJContentPane());
this.addInternalFrameListener(new InternalFrameAdapter(){
public void internalFrameDeactivated(InternalFrameEvent e){
if (jTable.isEditing()) {
jTable.getCellEditor().stopCellEditing();
}
}
});
this.setBounds(new java.awt.Rectangle(0, 0, 500, 370));
this.setVisible(true);
initFrame();
}
protected void init(SpdFileContents sfc){
if (sfc.getSpdGuidDeclarationCount() == 0) {
return ;
}
//
// initialize table using SpdFileContents object
//
String[][] saa = new String[sfc.getSpdGuidDeclarationCount()][7];
sfc.getSpdGuidDeclarations(saa);
int i = 0;
while (i < saa.length) {
model.addRow(saa[i]);
i++;
}
}
protected JScrollPane getJContentPane(){
if (topScrollPane == null){
topScrollPane = new JScrollPane();
topScrollPane.setSize(new java.awt.Dimension(617,500));
topScrollPane.setPreferredSize(new java.awt.Dimension(498,500));
topScrollPane.setViewportView(getJContentPane1());
}
return topScrollPane;
}
/**
This method initializes jContentPane
@return javax.swing.JPanel
**/
protected JPanel getJContentPane1() {
if (jContentPane == null) {
jLabel3 = new JLabel();
jLabel3.setBounds(new java.awt.Rectangle(400,122,103,16));
jLabel3.setText("GUID Type List");
jLabel3.setEnabled(true);
jLabel2 = new JLabel();
jLabel2.setBounds(new java.awt.Rectangle(197,122,108,16));
jLabel2.setText("Supported Arch");
jLabel2.setEnabled(true);
jLabel1 = new JLabel();
jLabel1.setBounds(new java.awt.Rectangle(14,120,110,16));
jLabel1.setText("Supported Module");
jLabel1.setEnabled(true);
jLabel = new JLabel();
jLabel.setText("HelpText");
jLabel.setSize(new java.awt.Dimension(109,20));
jLabel.setLocation(new java.awt.Point(14,85));
jLabelVer = new JLabel();
jLabelVer.setBounds(new java.awt.Rectangle(14,60,111,20));
jLabelVer.setText("C_Name");
jLabelGuid = new JLabel();
jLabelGuid.setBounds(new java.awt.Rectangle(15,35,112,20));
jLabelGuid.setText("Guid Value");
jLabelName = new JLabel();
jLabelName.setBounds(new java.awt.Rectangle(15,10,113,20));
jLabelName.setText("Name");
jStarLabel1 = new StarLabel();
jStarLabel1.setLocation(new java.awt.Point(0, 10));
jStarLabel3 = new StarLabel();
jStarLabel3.setLocation(new java.awt.Point(0, 35));
jStarLabel4 = new StarLabel();
jStarLabel4.setLocation(new java.awt.Point(0, 60));
jStarLabel2 = new StarLabel();
jStarLabel2.setLocation(new java.awt.Point(0, 85));
jStarLabel2.setVisible(true);
jContentPane = new JPanel();
jContentPane.setLayout(null);
jContentPane.setPreferredSize(new Dimension(480, 375));
jContentPane.add(jStarLabel1, null);
jContentPane.add(jStarLabel2, null);
jContentPane.add(jStarLabel3, null);
jContentPane.add(jStarLabel4, null);
jContentPane.add(jLabelVer, null);
jContentPane.add(getJTextFieldVersion(), null);
jContentPane.add(getJTextFieldAdd(), 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(getJButtonGen(), null);
jContentPane.add(jLabelName, null);
jContentPane.add(getJTextFieldName(), null);
jContentPane.add(jLabelGuid, null);
jContentPane.add(jLabel, null);
jContentPane.add(getJTextField(), null);
jContentPane.add(jLabel1, null);
jContentPane.add(jLabel2, null);
jContentPane.add(getJScrollPaneArch(), null);
jContentPane.add(getJScrollPaneGuid(), null);
jContentPane.add(getJScrollPaneModule(), null);
jContentPane.add(jLabel3, null);
}
return jContentPane;
}
/**
fill ComboBoxes with pre-defined contents
**/
protected void initFrame() {
this.setTitle("GUID Declarations");
}
/* (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) {
//ToDo: check before add
String[] row = {"", "", "", "", "", "", null};
row[3] = jTextField.getText();
row[2] = jTextFieldAdd.getText();
row[1] = jTextFieldVersion.getText();
row[0] = jTextFieldName.getText();
row[4] = vectorToString(iCheckBoxList.getAllCheckedItemsString());
if (row[4].length() == 0) {
row[4] = null;
}
row[5] = vectorToString(iCheckBoxList2.getAllCheckedItemsString());
if (row[5].length() == 0) {
row[5] = null;
}
if (iCheckBoxList1.getAllCheckedItemsString() != null) {
row[6] = vectorToString(iCheckBoxList1.getAllCheckedItemsString());
}
model.addRow(row);
addRow(row);
}
//
// remove selected line
//
if (arg0.getSource() == jButtonRemove) {
if (jTable.isEditing()){
jTable.getCellEditor().stopCellEditing();
}
int rowSelected = selectedRow;
if (rowSelected >= 0) {
model.removeRow(rowSelected);
removeRow(rowSelected);
}
}
if (arg0.getSource() == jButtonClearAll) {
if (model.getRowCount() == 0) {
return;
}
model.setRowCount(0);
clearAllRow();
}
if (arg0.getSource() == jButtonGen) {
guidDialog = new GenGuidDialog(this);
guidDialog.setGuid(jTextFieldAdd.getText());
guidDialog.setVisible(true);
}
if (arg0.getActionCommand().equals("GenGuidValue")) {
jTextFieldAdd.setText(guidDialog.getGuid());
}
}
protected void addRow(String[] row) {
Vector<String> vArch = iCheckBoxList.getAllCheckedItemsString();
Vector<String> vModType = iCheckBoxList2.getAllCheckedItemsString();
Vector<String> vguidType = iCheckBoxList1.getAllCheckedItemsString();
sfc.genSpdGuidDeclarations(row[0], row[1], row[2], row[3], vArch, vModType, vguidType);
}
protected void removeRow(int i){
sfc.removeSpdGuidDeclaration(i);
}
protected void clearAllRow(){
sfc.removeSpdGuidDeclaration();
}
/**
Add contents in list to sfc
**/
protected void save() {
}
/**
This method initializes jButtonBrowse
@return javax.swing.JButton
**/
protected JButton getJButtonGen() {
if (jButtonGen == null) {
jButtonGen = new JButton();
jButtonGen.setBounds(new java.awt.Rectangle(379,58,92,21));
jButtonGen.setText("Gen GUID");
jButtonGen.setPreferredSize(new java.awt.Dimension(80,20));
jButtonGen.addActionListener(this);
}
return jButtonGen;
}
/**
* This method initializes jTextFieldName
*
* @return javax.swing.JTextField
*/
protected JTextField getJTextFieldName() {
if (jTextFieldName == null) {
jTextFieldName = new JTextField();
jTextFieldName.setBounds(new java.awt.Rectangle(138,10,337,20));
jTextFieldName.setPreferredSize(new java.awt.Dimension(335,20));
}
return jTextFieldName;
}
/**
* This method initializes jTextFieldVersion
*
* @return javax.swing.JTextField
*/
protected JTextField getJTextFieldVersion() {
if (jTextFieldVersion == null) {
jTextFieldVersion = new JTextField();
jTextFieldVersion.setBounds(new java.awt.Rectangle(137,60,225,20));
jTextFieldVersion.setPreferredSize(new java.awt.Dimension(225,20));
}
return jTextFieldVersion;
}
public void componentResized(ComponentEvent arg0) {
int intPreferredWidth = 500;
resizeComponentWidth(this.jTextFieldName, this.getWidth(), intPreferredWidth);
resizeComponentWidth(this.jTextFieldAdd, this.getWidth(), intPreferredWidth);
resizeComponentWidth(this.jTextFieldVersion, this.getWidth(), intPreferredWidth);
resizeComponentWidth(this.jTextField, this.getWidth(), intPreferredWidth);
resizeComponentWidth(this.jScrollPane, this.getWidth(), intPreferredWidth);
relocateComponentX(this.jButtonGen, this.getWidth(), this.getPreferredSize().width, 40);
}
/**
* This method initializes jTextField
*
* @return javax.swing.JTextField
*/
private JTextField getJTextField() {
if (jTextField == null) {
jTextField = new JTextField();
jTextField.setBounds(new java.awt.Rectangle(136,85,337,20));
jTextField.setPreferredSize(new Dimension(335, 20));
}
return jTextField;
}
private JScrollPane getJScrollPaneArch() {
if (jScrollPaneArch == null) {
jScrollPaneArch = new JScrollPane();
jScrollPaneArch.setBounds(new java.awt.Rectangle(197,142,188,74));
jScrollPaneArch.setPreferredSize(new java.awt.Dimension(188, 74));
jScrollPaneArch.setViewportView(getICheckBoxList());
}
return jScrollPaneArch;
}
/**
* This method initializes iCheckBoxList
*
* @return org.tianocore.frameworkwizard.common.ui.iCheckBoxList.ICheckBoxList
*/
private ICheckBoxList getICheckBoxList() {
if (iCheckBoxList == null) {
iCheckBoxList = new ICheckBoxList();
iCheckBoxList.setBounds(new java.awt.Rectangle(197,142,188,74));
Vector<String> v = new Vector<String>();
v.add("IA32");
v.add("X64");
v.add("IPF");
v.add("EBC");
iCheckBoxList.setAllItems(v);
}
return iCheckBoxList;
}
protected JScrollPane getJScrollPaneGuid() {
if (jScrollPaneGuid== null) {
jScrollPaneGuid = new JScrollPane();
jScrollPaneGuid.setPreferredSize(new java.awt.Dimension(190,74));
jScrollPaneGuid.setLocation(new java.awt.Point(400,142));
jScrollPaneGuid.setSize(new java.awt.Dimension(260,74));
jScrollPaneGuid.setViewportView(getICheckBoxList1());
}
return jScrollPaneGuid;
}
/**
* This method initializes iCheckBoxList1
*
* @return org.tianocore.frameworkwizard.common.ui.iCheckBoxList.ICheckBoxList
*/
private ICheckBoxList getICheckBoxList1() {
if (iCheckBoxList1 == null) {
iCheckBoxList1 = new ICheckBoxList();
iCheckBoxList1.setBounds(new java.awt.Rectangle(400,142,177,74));
Vector<String> v = new Vector<String>();
v.add("DATA_HUB_RECORD");
v.add("EFI_EVENT");
v.add("EFI_SYSTEM_CONFIGURATION_TABLE");
v.add("EFI_VARIABLE");
v.add("GUID");
v.add("HII_PACKAGE_LIST");
v.add("HOB");
v.add("TOKEN_SPACE_GUID");
iCheckBoxList1.setAllItems(v);
}
return iCheckBoxList1;
}
private JScrollPane getJScrollPaneModule() {
if (jScrollPaneModule == null) {
jScrollPaneModule = new JScrollPane();
jScrollPaneModule.setBounds(new java.awt.Rectangle(14,142,170,74));
jScrollPaneModule.setPreferredSize(new java.awt.Dimension(170, 74));
jScrollPaneModule.setViewportView(getICheckBoxList2());
}
return jScrollPaneModule;
}
/**
* This method initializes iCheckBoxList2
*
* @return org.tianocore.frameworkwizard.common.ui.iCheckBoxList.ICheckBoxList
*/
private ICheckBoxList getICheckBoxList2() {
if (iCheckBoxList2 == null) {
iCheckBoxList2 = new ICheckBoxList();
iCheckBoxList2.setBounds(new java.awt.Rectangle(14,142,170,74));
Vector<String> v = new Vector<String>();
v.add("BASE");
v.add("SEC");
v.add("PEI_CORE");
v.add("PEIM");
v.add("DXE_CORE");
v.add("DXE_DRIVER");
v.add("DXE_RUNTIME_DRIVER");
v.add("DXE_SAL_DRIVER");
v.add("DXE_SMM_DRIVER");
v.add("UEFI_DRIVER");
v.add("UEFI_APPLICATION");
v.add("USER_DEFINED");
iCheckBoxList2.setAllItems(v);
}
return iCheckBoxList2;
}
public static void main(String[] args){
new SpdGuidDecls().setVisible(true);
}
protected DefaultTableModel getModel() {
return model;
}
protected void setModel(DefaultTableModel model) {
this.model = model;
}
protected String vectorToString(Vector<String> v) {
String s = " ";
for (int i = 0; i < v.size(); ++i) {
s += v.get(i);
s += " ";
}
return s.trim();
}
protected Vector<String> stringToVector(String s){
if (s == null) {
return null;
}
String[] sArray = s.split(" ");
Vector<String> v = new Vector<String>();
for (int i = 0; i < sArray.length; ++i) {
v.add(sArray[i]);
}
return v;
}
protected JLabel getJLabel3() {
return jLabel3;
}
}

View File

@@ -0,0 +1,684 @@
/** @file
The file is used to create, update spdHeader 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.frameworkwizard.packaging.ui;
import java.awt.Rectangle;
import java.awt.event.ActionEvent;
import java.awt.event.ComponentEvent;
import java.awt.event.FocusAdapter;
import java.awt.event.FocusEvent;
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.PackageSurfaceAreaDocument;
import org.tianocore.frameworkwizard.common.DataValidation;
import org.tianocore.frameworkwizard.common.Log;
import org.tianocore.frameworkwizard.common.Tools;
import org.tianocore.frameworkwizard.common.ui.IInternalFrame;
import org.tianocore.frameworkwizard.common.ui.StarLabel;
/**
The class is used to create, update spdHeader of Spd file
It extends IInternalFrame
@since PackageEditor 1.0
**/
public class SpdHeader 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 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 jStarLabel9 = null;
private SpdFileContents sfc = null;
private JTextField jTextFieldCopyright = null;
private JScrollPane topScrollPane = null;
private JLabel jLabel = null;
private JTextField jTextField = 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));
jTextFieldBaseName.setPreferredSize(new java.awt.Dimension(320,20));
jTextFieldBaseName.addFocusListener(new FocusAdapter(){
public void focusLost(FocusEvent e){
sfc.setSpdHdrPkgName(jTextFieldBaseName.getText());
}
});
}
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));
jTextFieldGuid.setPreferredSize(new java.awt.Dimension(250,20));
jTextFieldGuid.addFocusListener(new FocusAdapter(){
public void focusLost(FocusEvent e){
sfc.setSpdHdrGuidValue(jTextFieldGuid.getText());
}
});
}
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));
jTextFieldVersion.setPreferredSize(new java.awt.Dimension(320,20));
jTextFieldVersion.addFocusListener(new FocusAdapter(){
public void focusLost(FocusEvent e){
sfc.setSpdHdrVer(jTextFieldVersion.getText());
}
});
}
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.setPreferredSize(new java.awt.Dimension(317,77));
jTextAreaLicense.setLineWrap(true);
jTextAreaLicense.addFocusListener(new FocusAdapter(){
public void focusLost(FocusEvent e){
sfc.setSpdHdrLicense(jTextAreaLicense.getText());
}
});
}
return jTextAreaLicense;
}
/**
This method initializes jTextAreaDescription
@return javax.swing.JTextArea jTextAreaDescription
**/
private JTextArea getJTextAreaDescription() {
if (jTextAreaDescription == null) {
jTextAreaDescription = new JTextArea();
jTextAreaDescription.setLineWrap(true);
jTextAreaDescription.setPreferredSize(new java.awt.Dimension(317,77));
jTextAreaDescription.addFocusListener(new FocusAdapter(){
public void focusLost(FocusEvent e){
sfc.setSpdHdrDescription(jTextAreaDescription.getText());
}
});
}
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, 305, 320, 20));
jTextFieldSpecification.setEditable(false);
jTextFieldSpecification.setPreferredSize(new java.awt.Dimension(320,20));
jTextFieldSpecification.addFocusListener(new FocusAdapter(){
public void focusLost(FocusEvent e){
sfc.setSpdHdrSpec(jTextFieldSpecification.getText());
}
});
}
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.setVisible(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.setText("Cancel");
jButtonCancel.setBounds(new java.awt.Rectangle(390, 445, 90, 20));
jButtonCancel.setVisible(false);
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.setPreferredSize(new java.awt.Dimension(320,80));
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, 220, 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,195,320,20));
jTextFieldAbstract.setPreferredSize(new java.awt.Dimension(320, 20));
jTextFieldAbstract.addFocusListener(new FocusAdapter(){
public void focusLost(FocusEvent e){
sfc.setSpdHdrAbs(jTextFieldAbstract.getText());
}
});
}
return jTextFieldAbstract;
}
/**
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,330,320, 20));
jTextFieldCopyright.setPreferredSize(new java.awt.Dimension(320,20));
jTextFieldCopyright.addFocusListener(new FocusAdapter(){
public void focusLost(FocusEvent e){
sfc.setSpdHdrCopyright(jTextFieldCopyright.getText());
}
});
}
return jTextFieldCopyright;
}
/**
* This method initializes jTextField
*
* @return javax.swing.JTextField
*/
private JTextField getJTextField() {
if (jTextField == null) {
jTextField = new JTextField();
jTextField.setBounds(new java.awt.Rectangle(160,170,320,20));
jTextField.setPreferredSize(new java.awt.Dimension(320, 20));
jTextField.addFocusListener(new FocusAdapter(){
public void focusLost(FocusEvent e){
sfc.setSpdHdrLicense(jTextAreaLicense.getText());
sfc.setSpdHdrUrl(jTextField.getText());
}
});
}
return jTextField;
}
public static void main(String[] args) {
new SpdHeader().setVisible(true);
}
/**
This is the default constructor
**/
public SpdHeader() {
super();
init();
this.setVisible(true);
}
/**
This is the override edit constructor
@param inspdHeader The input data of spdHeaderDocument.spdHeader
**/
public SpdHeader(PackageSurfaceAreaDocument.PackageSurfaceArea inPsa) {
this();
sfc = new SpdFileContents(inPsa);
init(sfc);
}
/**
This method initializes this
**/
private void init() {
this.setContentPane(getTopScrollPane());
this.setTitle("Package Surface Area Header");
initFrame();
}
/**
This method initializes this
Fill values to all fields if these values are not empty
@param inspdHeader The input data of spdHeaderDocument.spdHeader
**/
private void init(SpdFileContents sfc) {
if (sfc.getSpdHdrPkgName() != null) {
jTextFieldBaseName.setText(sfc.getSpdHdrPkgName());
}
if (sfc.getSpdHdrGuidValue() != null) {
jTextFieldGuid.setText(sfc.getSpdHdrGuidValue());
}
if (sfc.getSpdHdrVer() != null) {
jTextFieldVersion.setText(sfc.getSpdHdrVer());
}
if (sfc.getSpdHdrLicense() != null) {
jTextAreaLicense.setText(sfc.getSpdHdrLicense());
}
if (sfc.getSpdHdrUrl() != null) {
jTextField.setText(sfc.getSpdHdrUrl());
}
if (sfc.getSpdHdrCopyright() != null) {
jTextFieldCopyright.setText(sfc.getSpdHdrCopyright());
}
if (sfc.getSpdHdrAbs() != null) {
jTextFieldAbstract.setText(sfc.getSpdHdrAbs());
}
if (sfc.getSpdHdrDescription() != null) {
jTextAreaDescription.setText(sfc.getSpdHdrDescription());
}
if (sfc.getSpdHdrSpec() != null) {
jTextFieldSpecification.setText(sfc.getSpdHdrSpec());
}
}
/**
This method initializes jContentPane
@return javax.swing.JPanel jContentPane
**/
private JPanel getJContentPane() {
if (jContentPane == null) {
jLabel = new JLabel();
jLabel.setBounds(new java.awt.Rectangle(15,170,140,20));
jLabel.setText("URL");
jContentPane = new JPanel();
jContentPane.setLayout(null);
jContentPane.setLocation(new java.awt.Point(0, 0));
jContentPane.setPreferredSize(new java.awt.Dimension(500, 524));
jLabelAbstract = new JLabel();
jLabelAbstract.setBounds(new java.awt.Rectangle(15, 220, 140, 20));
jLabelAbstract.setText("Description");
jLabelSpecification = new JLabel();
jLabelSpecification.setText("Specification");
jLabelSpecification.setBounds(new java.awt.Rectangle(15, 305, 140, 20));
jLabelDescription = new JLabel();
jLabelDescription.setText("Abstract");
jLabelDescription.setBounds(new java.awt.Rectangle(15, 195, 140, 20));
jLabelCopyright = new JLabel();
jLabelCopyright.setText("Copyright");
jLabelCopyright.setBounds(new java.awt.Rectangle(15, 330, 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.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);
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, 330));
jStarLabel6 = new StarLabel();
jStarLabel6.setLocation(new java.awt.Point(0, 195));
jStarLabel7 = new StarLabel();
jStarLabel7.setLocation(new java.awt.Point(0, 305));
jStarLabel7.setEnabled(false);
jStarLabel9 = new StarLabel();
jStarLabel9.setLocation(new java.awt.Point(0, 220));
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(jStarLabel9, null);
jContentPane.add(getJTextFieldCopyright(), null);
jContentPane.add(jLabel, null);
jContentPane.add(getJTextField(), 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) {
//ToDo: invoke GuidValueEditor
jTextFieldGuid.setText(Tools.generateUuidString());
sfc.setSpdHdrGuidValue(jTextFieldGuid.getText());
}
}
/**
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 Spd Header
if exists spdHeader, set the value directly
if not exists spdHeader, new an instance first
**/
public void save() {
try {
} catch (Exception e) {
Log.err("Save Package", e.getMessage());
}
}
/**
This method initializes Package type and Compontent type
**/
private void initFrame() {
}
/* (non-Javadoc)
* @see java.awt.event.ComponentListener#componentResized(java.awt.event.ComponentEvent)
*
* Override componentResized to resize all components when frame's size is changed
*/
public void componentResized(ComponentEvent arg0) {
int intPreferredWidth = 500;
int intCurrentWidth = this.getJContentPane().getWidth();
resizeComponentWidth(this.jTextFieldBaseName, intCurrentWidth,intPreferredWidth);
resizeComponentWidth(this.jTextFieldGuid, intCurrentWidth,intPreferredWidth);
resizeComponentWidth(this.jTextFieldVersion, intCurrentWidth,intPreferredWidth);
resizeComponentWidth(this.jScrollPaneLicense, intCurrentWidth,intPreferredWidth);
resizeComponentWidth(this.jTextFieldCopyright, intCurrentWidth,intPreferredWidth);
resizeComponentWidth(this.jScrollPaneDescription, intCurrentWidth,intPreferredWidth);
resizeComponentWidth(this.jTextFieldSpecification, intCurrentWidth,intPreferredWidth);
resizeComponentWidth(this.jTextFieldAbstract, intCurrentWidth,intPreferredWidth);
relocateComponentX(this.jButtonGenerateGuid, intCurrentWidth, jButtonGenerateGuid.getWidth(),30);
}
private JScrollPane getTopScrollPane() {
if (topScrollPane == null){
topScrollPane = new JScrollPane();
topScrollPane.setViewportView(getJContentPane());
}
return topScrollPane;
}
}

View File

@@ -0,0 +1,891 @@
/** @file
Java class SpdLibClassDecls 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.frameworkwizard.packaging.ui;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ComponentEvent;
import java.awt.event.FocusAdapter;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
import java.io.File;
import java.util.Vector;
import javax.swing.AbstractAction;
import javax.swing.DefaultListModel;
import javax.swing.JFileChooser;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.JTable;
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.ListSelectionModel;
import javax.swing.event.InternalFrameAdapter;
import javax.swing.event.InternalFrameEvent;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import javax.swing.event.TableModelEvent;
import javax.swing.event.TableModelListener;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableModel;
import org.tianocore.PackageSurfaceAreaDocument;
import org.tianocore.frameworkwizard.common.DataType;
import org.tianocore.frameworkwizard.common.Tools;
import org.tianocore.frameworkwizard.common.ui.IInternalFrame;
import org.tianocore.frameworkwizard.common.ui.StarLabel;
import org.tianocore.frameworkwizard.common.ui.iCheckBoxList.ICheckBoxList;
import javax.swing.JCheckBox;
/**
GUI for create library definition elements of spd file.
@since PackageEditor 1.0
**/
public class SpdLibClassDecls extends IInternalFrame implements TableModelListener{
static JFrame frame;
private JTable jTable = null;
private DefaultTableModel model = 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 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;
private StarLabel jStarLabel1 = null;
private StarLabel jStarLabel2 = null;
private SpdFileContents sfc = null;
private JLabel jLabel1 = null;
private JScrollPane topScrollPane = null; // @jve:decl-index=0:visual-constraint="10,53"
private int selectedRow = -1;
private StarLabel starLabel = null;
private JLabel jLabel2 = null;
private JTextField jTextFieldHelp = null;
private JLabel jLabel3 = null;
private JTextField jTextField1 = null;
private JLabel jLabel4 = null;
private JTextField jTextField2 = null;
private JLabel jLabel5 = null;
private JCheckBox jCheckBox = null;
private JCheckBox jCheckBox1 = null;
private JCheckBox jCheckBox2 = null;
private JCheckBox jCheckBox3 = null;
private JLabel jLabel6 = null;
private JScrollPane jScrollPaneArch = null;
private ICheckBoxList iCheckBoxListArch = null;
/**
This method initializes this
**/
private void initialize() {
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(9,63,197,20));
jRadioButtonAdd.setText("Library Class Name");
jRadioButtonAdd.addActionListener(this);
jRadioButtonAdd.setSelected(true);
jRadioButtonAdd.setVisible(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(9,10,198,20));
jRadioButtonSelect.setText("Select Existing Library Class");
jRadioButtonSelect.addActionListener(this);
jRadioButtonSelect.setSelected(true);
jRadioButtonSelect.setVisible(false);
}
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(122,6,343,20));
jTextFieldAdd.setPreferredSize(new java.awt.Dimension(260,20));
jTextFieldAdd.setEnabled(true);
}
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.setPreferredSize(new java.awt.Dimension(260,22));
jComboBoxSelect.setEnabled(true);
jComboBoxSelect.setVisible(false);
}
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(12,302,351,164));
jScrollPane.setPreferredSize(new java.awt.Dimension(330,150));
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);
jTable.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_OFF);
model.addColumn("LibraryClass");
model.addColumn("IncludeHeader");
model.addColumn("HelpText");
model.addColumn("RecommendedInstance");
model.addColumn("InstanceVersion");
model.addColumn("SupportedArch");
model.addColumn("SupportedModule");
jTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
jTable.getSelectionModel().addListSelectionListener(new ListSelectionListener(){
public void valueChanged(ListSelectionEvent e) {
if (e.getValueIsAdjusting()){
return;
}
ListSelectionModel lsm = (ListSelectionModel)e.getSource();
if (lsm.isSelectionEmpty()) {
return;
}
else{
selectedRow = lsm.getMinSelectionIndex();
}
}
});
jTable.getModel().addTableModelListener(this);
}
return jTable;
}
public void tableChanged(TableModelEvent arg0) {
// TODO Auto-generated method stub
int row = arg0.getFirstRow();
TableModel m = (TableModel)arg0.getSource();
if (arg0.getType() == TableModelEvent.UPDATE){
String lib = m.getValueAt(row, 0) + "";
String hdr = m.getValueAt(row, 1) + "";
String hlp = m.getValueAt(row, 2) + "";
String guid = m.getValueAt(row, 3) + "";
String ver = m.getValueAt(row, 4) + "";
String arch = null;
if (m.getValueAt(row, 5) != null) {
arch = m.getValueAt(row, 5).toString();
}
String module = null;
if (m.getValueAt(row, 6) != null) {
module = m.getValueAt(row, 6).toString();
}
sfc.updateSpdLibClass(row, lib, hdr, hlp, guid, ver, arch, module);
}
}
/**
This method initializes jButtonAdd
@return javax.swing.JButton
**/
private JButton getJButtonAdd() {
if (jButtonAdd == null) {
jButtonAdd = new JButton();
jButtonAdd.setBounds(new java.awt.Rectangle(374,303,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(374,381,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(374,411,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.setVisible(false);
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.setVisible(false);
jButtonOk.addActionListener(this);
}
return jButtonOk;
}
/**
This is the default constructor
**/
public SpdLibClassDecls() {
super();
initialize();
init();
}
public SpdLibClassDecls(PackageSurfaceAreaDocument.PackageSurfaceArea inPsa){
this();
sfc = new SpdFileContents(inPsa);
init(sfc);
}
/**
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.setVisible(true);
this.addInternalFrameListener(new InternalFrameAdapter(){
public void internalFrameDeactivated(InternalFrameEvent e){
if (jTable.isEditing()) {
jTable.getCellEditor().stopCellEditing();
}
}
});
initFrame();
}
private void init(SpdFileContents sfc) {
if (sfc.getSpdLibClassDeclarationCount() == 0) {
return ;
}
//
// initialize table using SpdFileContents object
//
String[][] saa = new String[sfc.getSpdLibClassDeclarationCount()][7];
sfc.getSpdLibClassDeclarations(saa);
int i = 0;
while (i < saa.length) {
model.addRow(saa[i]);
i++;
}
}
private JScrollPane getJContentPane(){
if (topScrollPane == null){
topScrollPane = new JScrollPane();
topScrollPane.setSize(new java.awt.Dimension(483,500));
topScrollPane.setViewportView(getJContentPane1());
}
return topScrollPane;
}
/**
This method initializes jContentPane
@return javax.swing.JPanel
**/
private JPanel getJContentPane1() {
if (jContentPane == null) {
jLabel6 = new JLabel();
jLabel6.setBounds(new java.awt.Rectangle(16,252,108,16));
jLabel6.setText("Supported Module");
jLabel6.setEnabled(true);
jLabel5 = new JLabel();
jLabel5.setBounds(new java.awt.Rectangle(16,215,93,16));
jLabel5.setText("Supported Arch");
jLabel5.setEnabled(true);
jLabel4 = new JLabel();
jLabel4.setBounds(new java.awt.Rectangle(16,160,196,16));
jLabel4.setEnabled(true);
jLabel4.setText("Recommended Instance Version");
jLabel3 = new JLabel();
jLabel3.setBounds(new java.awt.Rectangle(17,112,175,16));
jLabel3.setEnabled(true);
jLabel3.setText("Recommended Instance GUID");
jLabel2 = new JLabel();
jLabel2.setBounds(new java.awt.Rectangle(16,33,82,20));
jLabel2.setText("Help Text");
starLabel = new StarLabel();
starLabel.setBounds(new java.awt.Rectangle(1,33,10,20));
jLabel1 = new JLabel();
jLabel1.setBounds(new java.awt.Rectangle(16,6,82,20));
jLabel1.setText("Library Class");
jStarLabel1 = new StarLabel();
jStarLabel1.setLocation(new java.awt.Point(1,7));
jStarLabel2 = new StarLabel();
jStarLabel2.setLocation(new java.awt.Point(1,56));
jLabel = new JLabel();
jLabel.setBounds(new java.awt.Rectangle(16,56,199,22));
jLabel.setText("Include Header for Specified Class");
jContentPane = new JPanel();
jContentPane.setPreferredSize(new Dimension(480, 400));
jContentPane.setLayout(null);
jContentPane.add(jLabel, null);
jContentPane.add(jStarLabel1, null);
jContentPane.add(jStarLabel2, 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(getJTextField(), null);
jContentPane.add(getJButtonBrowse(), null);
jContentPane.add(jLabel1, null);
jContentPane.add(starLabel, null);
jContentPane.add(jLabel2, null);
jContentPane.add(getJTextFieldHelp(), null);
jContentPane.add(jLabel3, null);
jContentPane.add(getJTextField1(), null);
jContentPane.add(jLabel4, null);
jContentPane.add(getJTextField2(), null);
jContentPane.add(jLabel5, null);
jContentPane.add(getJCheckBox(), null);
jContentPane.add(getJCheckBox1(), null);
jContentPane.add(getJCheckBox2(), null);
jContentPane.add(getJCheckBox3(), null);
jContentPane.add(jLabel6, null);
jContentPane.add(getJScrollPaneArch(), 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");
}
/* (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) {
//ToDo: check before add
String[] row = {null, null, null, jTextField1.getText(), jTextField2.getText(), null, null};
row[0] = jTextFieldAdd.getText();
row[1] = jTextField.getText().replace('\\', '/');
row[2] = jTextFieldHelp.getText();
row[5] = booleanToString(jCheckBox.isSelected(), jCheckBox1.isSelected(), jCheckBox2.isSelected(), jCheckBox3.isSelected());
if (row[5].length() == 0){
row[5] = null;
}
row[6] = vectorToString(iCheckBoxListArch.getAllCheckedItemsString());
if (row[6].length() == 0){
row[6] = null;
}
model.addRow(row);
sfc.genSpdLibClassDeclarations(row[0], row[3], row[1], row[2], row[5], null, null, row[4], null, row[6]);
}
//
// remove selected line
//
if (arg0.getSource() == jButtonRemove) {
if (jTable.isEditing()){
jTable.getCellEditor().stopCellEditing();
}
int rowSelected = selectedRow;
if (rowSelected >= 0) {
model.removeRow(rowSelected);
sfc.removeSpdLibClass(rowSelected);
}
}
if (arg0.getSource() == jButtonClearAll) {
if (model.getRowCount() == 0) {
return;
}
model.setRowCount(0);
sfc.removeSpdLibClass();
}
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() {
}
/**
This method initializes jTextField
@return javax.swing.JTextField
**/
private JTextField getJTextField() {
if (jTextField == null) {
jTextField = new JTextField();
jTextField.setBounds(new java.awt.Rectangle(16,83,346,21));
jTextField.setPreferredSize(new java.awt.Dimension(260,20));
}
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(376,82,90,20));
jButtonBrowse.setText("Browse");
jButtonBrowse.setPreferredSize(new java.awt.Dimension(80,20));
jButtonBrowse.addActionListener(new AbstractAction() {
public void actionPerformed(ActionEvent arg0) {
//
// Select files from current pkg
//
String dirPrefix = Tools.dirForNewSpd.substring(0, Tools.dirForNewSpd.lastIndexOf(File.separator));
JFileChooser chooser = new JFileChooser(dirPrefix);
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(dirPrefix)) {
JOptionPane.showMessageDialog(frame, "You can only select files in current package!");
return;
}
}
else {
return;
}
headerDest = theFile.getPath();
int fileIndex = headerDest.indexOf(System.getProperty("file.separator"), dirPrefix.length());
jTextField.setText(headerDest.substring(fileIndex + 1).replace('\\', '/'));
}
});
}
return jButtonBrowse;
}
public void componentResized(ComponentEvent arg0) {
int intPreferredWidth = 500;
resizeComponentWidth(this.jTextFieldAdd, this.getWidth(), intPreferredWidth);
resizeComponentWidth(this.jTextFieldHelp, this.getWidth(), intPreferredWidth);
resizeComponentWidth(this.jScrollPane, this.getWidth(), intPreferredWidth);
relocateComponentX(this.jButtonBrowse, this.getWidth(), this.getPreferredSize().width,25);
relocateComponentX(this.jButtonClearAll, this.getWidth(), this.getPreferredSize().width,25);
relocateComponentX(this.jButtonRemove, this.getWidth(), this.getPreferredSize().width,25);
relocateComponentX(this.jButtonAdd, this.getWidth(), this.getPreferredSize().width,50);
}
/**
* This method initializes jTextFieldHelp
*
* @return javax.swing.JTextField
*/
private JTextField getJTextFieldHelp() {
if (jTextFieldHelp == null) {
jTextFieldHelp = new JTextField();
jTextFieldHelp.setBounds(new java.awt.Rectangle(122,33,343,20));
jTextFieldHelp.setPreferredSize(new java.awt.Dimension(260,20));
}
return jTextFieldHelp;
}
/**
* This method initializes jTextField1
*
* @return javax.swing.JTextField
*/
private JTextField getJTextField1() {
if (jTextField1 == null) {
jTextField1 = new JTextField();
jTextField1.setBounds(new java.awt.Rectangle(16,135,344,20));
jTextField1.setEnabled(true);
}
return jTextField1;
}
/**
* This method initializes jTextField2
*
* @return javax.swing.JTextField
*/
private JTextField getJTextField2() {
if (jTextField2 == null) {
jTextField2 = new JTextField();
jTextField2.setBounds(new java.awt.Rectangle(16,184,344,20));
jTextField2.setEnabled(true);
}
return jTextField2;
}
/**
* This method initializes jCheckBox
*
* @return javax.swing.JCheckBox
*/
private JCheckBox getJCheckBox() {
if (jCheckBox == null) {
jCheckBox = new JCheckBox();
jCheckBox.setBounds(new java.awt.Rectangle(123,213,57,21));
jCheckBox.setText("IA32");
jCheckBox.setPreferredSize(new java.awt.Dimension(21,20));
}
return jCheckBox;
}
/**
* This method initializes jCheckBox1
*
* @return javax.swing.JCheckBox
*/
private JCheckBox getJCheckBox1() {
if (jCheckBox1 == null) {
jCheckBox1 = new JCheckBox();
jCheckBox1.setBounds(new java.awt.Rectangle(197,213,49,20));
jCheckBox1.setText("X64");
jCheckBox1.setPreferredSize(new java.awt.Dimension(21,20));
}
return jCheckBox1;
}
/**
* This method initializes jCheckBox2
*
* @return javax.swing.JCheckBox
*/
private JCheckBox getJCheckBox2() {
if (jCheckBox2 == null) {
jCheckBox2 = new JCheckBox();
jCheckBox2.setText("IPF");
jCheckBox2.setSize(new java.awt.Dimension(50,20));
jCheckBox2.setLocation(new java.awt.Point(258,213));
jCheckBox2.setPreferredSize(new java.awt.Dimension(21,20));
}
return jCheckBox2;
}
/**
* This method initializes jCheckBox3
*
* @return javax.swing.JCheckBox
*/
private JCheckBox getJCheckBox3() {
if (jCheckBox3 == null) {
jCheckBox3 = new JCheckBox();
jCheckBox3.setBounds(new java.awt.Rectangle(319,213,59,20));
jCheckBox3.setText("EBC");
jCheckBox3.setPreferredSize(new java.awt.Dimension(21,20));
}
return jCheckBox3;
}
private JScrollPane getJScrollPaneArch() {
if (jScrollPaneArch == null) {
jScrollPaneArch = new JScrollPane();
jScrollPaneArch.setBounds(new java.awt.Rectangle(130,252,230,45));
jScrollPaneArch.setPreferredSize(new java.awt.Dimension(320, 80));
jScrollPaneArch.setViewportView(getICheckBoxListSupportedArchitectures());
}
return jScrollPaneArch;
}
private ICheckBoxList getICheckBoxListSupportedArchitectures() {
if (iCheckBoxListArch == null) {
iCheckBoxListArch = new ICheckBoxList();
Vector<String> v = new Vector<String>();
v.add("BASE");
v.add("SEC");
v.add("PEI_CORE");
v.add("PEIM");
v.add("DXE_CORE");
v.add("DXE_DRIVER");
v.add("DXE_RUNTIME_DRIVER");
v.add("DXE_SAL_DRIVER");
v.add("DXE_SMM_DRIVER");
v.add("UEFI_DRIVER");
v.add("UEFI_APPLICATION");
v.add("USER_DEFINED");
iCheckBoxListArch.setAllItems(v);
}
return iCheckBoxListArch;
}
private String booleanToString(boolean b1, boolean b2, boolean b3, boolean b4){
String s = " ";
if (b1){
s += "IA32 ";
}
if (b2){
s += "X64 ";
}
if (b3){
s += "IPF ";
}
if (b4){
s += "EBC ";
}
return s.trim();
}
private String vectorToString(Vector<String> v) {
String s = " ";
for (int i = 0; i < v.size(); ++i) {
s += v.get(i);
s += " ";
}
return s.trim();
}
public static void main(String[] args){
new SpdLibClassDecls().setVisible(true);
}
}

View File

@@ -0,0 +1,466 @@
/** @file
Java class SpdMsaFiles 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.frameworkwizard.packaging.ui;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ComponentEvent;
import java.io.File;
import java.util.Vector;
import javax.swing.AbstractAction;
import javax.swing.DefaultListModel;
import javax.swing.JFileChooser;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.JTable;
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.ListSelectionModel;
import javax.swing.event.InternalFrameAdapter;
import javax.swing.event.InternalFrameEvent;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import javax.swing.event.TableModelEvent;
import javax.swing.event.TableModelListener;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableModel;
import org.tianocore.PackageSurfaceAreaDocument;
import org.tianocore.frameworkwizard.common.DataType;
import org.tianocore.frameworkwizard.common.Tools;
import org.tianocore.frameworkwizard.common.ui.IInternalFrame;
import org.tianocore.frameworkwizard.common.ui.StarLabel;
/**
GUI for create library definition elements of spd file.
@since PackageEditor 1.0
**/
public class SpdMsaFiles extends IInternalFrame implements TableModelListener{
static JFrame frame;
private JScrollPane jScrollPane = null; // @jve:decl-index=0:visual-constraint="10,95"
private JTable jTable = null;
private DefaultTableModel model = null;
private JPanel jContentPane = null;
private JScrollPane jScrollPane1 = 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;
private StarLabel jStarLabel2 = null;
private SpdFileContents sfc = null;
private int selectedRow = -1;
/**
This method initializes this
**/
private void initialize() {
this.setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
}
/**
This method initializes jScrollPane
@return javax.swing.JScrollPane
**/
private JScrollPane getJScrollPane1() {
if (jScrollPane1 == null) {
jScrollPane1 = new JScrollPane();
jScrollPane1.setBounds(new java.awt.Rectangle(13,177,461,139));
jScrollPane1.setViewportView(getJTable());
}
return jScrollPane1;
}
/**
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("MsaFile");
jTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
jTable.getSelectionModel().addListSelectionListener(new ListSelectionListener(){
public void valueChanged(ListSelectionEvent e) {
if (e.getValueIsAdjusting()){
return;
}
ListSelectionModel lsm = (ListSelectionModel)e.getSource();
if (lsm.isSelectionEmpty()) {
return;
}
else{
selectedRow = lsm.getMinSelectionIndex();
}
}
});
jTable.getModel().addTableModelListener(this);
}
return jTable;
}
/**
This method initializes jButtonAdd
@return javax.swing.JButton
**/
private JButton getJButtonAdd() {
if (jButtonAdd == null) {
jButtonAdd = new JButton();
jButtonAdd.setBounds(new java.awt.Rectangle(163,148,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(266,148,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(374,148,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.setVisible(false);
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.setVisible(false);
jButtonOk.addActionListener(this);
}
return jButtonOk;
}
/**
This is the default constructor
**/
public SpdMsaFiles() {
super();
initialize();
init();
}
public SpdMsaFiles(PackageSurfaceAreaDocument.PackageSurfaceArea inPsa){
this();
sfc = new SpdFileContents(inPsa);
init(sfc);
}
/**
This method initializes this
@return void
**/
private void init() {
this.setBounds(new java.awt.Rectangle(0, 0, 500, 370));
this.setPreferredSize(new Dimension(490, 400));
this.setContentPane(getJScrollPane());
this.setTitle("Msa Files");
this.addInternalFrameListener(new InternalFrameAdapter(){
public void internalFrameDeactivated(InternalFrameEvent e){
if (jTable.isEditing()) {
jTable.getCellEditor().stopCellEditing();
}
}
});
this.setVisible(true);
initFrame();
}
private void init(SpdFileContents sfc){
if (sfc.getSpdMsaFileCount() == 0) {
return ;
}
//
// initialize table using SpdFileContents object
//
String[][] saa = new String[sfc.getSpdMsaFileCount()][4];
sfc.getSpdMsaFiles(saa);
int i = 0;
while (i < saa.length) {
model.addRow(saa[i]);
i++;
}
}
private JScrollPane getJScrollPane(){
if (jScrollPane == null){
jScrollPane = new JScrollPane();
jScrollPane.setViewportView(getJContentPane());
}
return jScrollPane;
}
/**
This method initializes jContentPane
@return javax.swing.JPanel
**/
private JPanel getJContentPane() {
if (jContentPane == null) {
jStarLabel2 = new StarLabel();
jStarLabel2.setLocation(new java.awt.Point(2,24));
jLabel = new JLabel();
jLabel.setBounds(new java.awt.Rectangle(17,24,111,22));
jLabel.setText("Msa File ");
jContentPane = new JPanel();
jContentPane.setPreferredSize(new Dimension(480, 325));
jContentPane.setLayout(null);
jContentPane.add(jLabel, null);
jContentPane.add(jStarLabel2, null);
jContentPane.add(getJScrollPane1(), null);
jContentPane.add(getJButtonAdd(), null);
jContentPane.add(getJButtonRemove(), null);
jContentPane.add(getJButtonClearAll(), null);
jContentPane.add(getJButtonCancel(), null);
jContentPane.add(getJButtonOk(), null);
jContentPane.add(getJTextField(), null);
jContentPane.add(getJButtonBrowse(), null);
}
return jContentPane;
}
/**
fill ComboBoxes with pre-defined contents
**/
private void initFrame() {
}
/* (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) {
//ToDo: check before add
String[] row = {jTextField.getText().replace('\\', '/')};
model.addRow(row);
sfc.genSpdMsaFiles(row[0], null, null, null);
}
//
// remove selected line
//
if (arg0.getSource() == jButtonRemove) {
if (jTable.isEditing()){
jTable.getCellEditor().stopCellEditing();
}
int rowSelected = selectedRow;
if (rowSelected >= 0) {
model.removeRow(rowSelected);
sfc.removeSpdMsaFile(rowSelected);
}
}
if (arg0.getSource() == jButtonClearAll) {
if (model.getRowCount() == 0) {
return;
}
model.setRowCount(0);
sfc.removeSpdMsaFile();
}
}
public void tableChanged(TableModelEvent arg0) {
// TODO Auto-generated method stub
int row = arg0.getFirstRow();
TableModel m = (TableModel)arg0.getSource();
if (arg0.getType() == TableModelEvent.UPDATE){
String file = m.getValueAt(row, 0) + "";
sfc.updateSpdMsaFile(row, file, null, null, null);
}
}
/**
Add contents in list to sfc
**/
protected void save() {
}
/**
This method initializes jTextField
@return javax.swing.JTextField
**/
private JTextField getJTextField() {
if (jTextField == null) {
jTextField = new JTextField();
jTextField.setBounds(new java.awt.Rectangle(14,51,346,21));
jTextField.setPreferredSize(new java.awt.Dimension(345,20));
}
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(376,50,92,21));
jButtonBrowse.setText("Browse");
jButtonBrowse.setPreferredSize(new java.awt.Dimension(90,20));
jButtonBrowse.addActionListener(new AbstractAction() {
public void actionPerformed(ActionEvent e) {
//
// Select files from current workspace
//
String dirPrefix = Tools.dirForNewSpd.substring(0, Tools.dirForNewSpd.lastIndexOf(File.separator));
JFileChooser chooser = new JFileChooser(dirPrefix);
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(dirPrefix)) {
JOptionPane.showMessageDialog(frame, "You can only select files in current package!");
return;
}
}
else {
return;
}
headerDest = theFile.getPath();
int fileIndex = headerDest.indexOf(System.getProperty("file.separator"), dirPrefix.length());
jTextField.setText(headerDest.substring(fileIndex + 1).replace('\\', '/'));
}
});
}
return jButtonBrowse;
}
public void componentResized(ComponentEvent arg0) {
int intPreferredWidth = 500;
resizeComponentWidth(this.jScrollPane1, this.getWidth(), intPreferredWidth);
resizeComponentWidth(this.jTextField, this.getWidth(), intPreferredWidth);
relocateComponentX(this.jButtonBrowse, this.getWidth(), this.getPreferredSize().width, 25);
}
public static void main(String[] args){
new SpdMsaFiles().setVisible(true);
}
}

View File

@@ -0,0 +1,150 @@
/** @file
The file is used to create, update Package Definitions 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.frameworkwizard.packaging.ui;
import javax.swing.JPanel;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JComboBox;
import java.awt.Dimension;
import org.tianocore.PackageSurfaceAreaDocument;
import org.tianocore.frameworkwizard.common.ui.IInternalFrame;
import org.tianocore.frameworkwizard.common.ui.StarLabel;
public class SpdPackageDefinitions extends IInternalFrame {
private JPanel jContentPane = null;
private JLabel jLabel = null;
private JComboBox jComboBoxReadOnly = null;
private JLabel jLabel1 = null;
private JComboBox jComboBoxRePackage = null;
private StarLabel starLabel = null;
private StarLabel starLabel1 = null;
private SpdFileContents sfc = null;
/**
* This is the default constructor
*/
public SpdPackageDefinitions() {
super();
initialize();
}
public SpdPackageDefinitions(PackageSurfaceAreaDocument.PackageSurfaceArea inPsa){
this();
sfc = new SpdFileContents(inPsa);
init(sfc);
}
private void init(SpdFileContents sfc) {
if (sfc.getSpdPkgDefsRdOnly() != null) {
jComboBoxReadOnly.setSelectedItem(sfc.getSpdPkgDefsRdOnly());
}
if (sfc.getSpdPkgDefsRePkg() != null) {
jComboBoxRePackage.setSelectedItem(sfc.getSpdPkgDefsRePkg());
}
this.setVisible(true);
}
/**
* This method initializes this
*
* @return void
*/
private void initialize() {
this.setSize(300, 200);
this.setTitle("Package Definitions");
this.setContentPane(getJContentPane());
}
/**
* This method initializes jContentPane
*
* @return javax.swing.JPanel
*/
private JPanel getJContentPane() {
if (jContentPane == null) {
starLabel1 = new StarLabel();
starLabel1.setBounds(new java.awt.Rectangle(4,62,10,20));
starLabel1.setVisible(true);
starLabel = new StarLabel();
starLabel.setBounds(new java.awt.Rectangle(4,22,10,20));
jLabel1 = new JLabel();
jLabel1.setPreferredSize(new java.awt.Dimension(65,20));
jLabel1.setLocation(new java.awt.Point(22,62));
jLabel1.setSize(new java.awt.Dimension(65,20));
jLabel1.setText("RePackage");
jLabel = new JLabel();
jLabel.setPreferredSize(new java.awt.Dimension(57,20));
jLabel.setLocation(new java.awt.Point(22,22));
jLabel.setSize(new java.awt.Dimension(57,20));
jLabel.setText("Read Only");
jContentPane = new JPanel();
jContentPane.setLayout(null);
jContentPane.add(jLabel, null);
jContentPane.add(getJComboBox(), null);
jContentPane.add(jLabel1, null);
jContentPane.add(getJComboBox1(), null);
jContentPane.add(starLabel, null);
jContentPane.add(starLabel1, null);
}
return jContentPane;
}
/**
* This method initializes jComboBox
*
* @return javax.swing.JComboBox
*/
private JComboBox getJComboBox() {
if (jComboBoxReadOnly == null) {
jComboBoxReadOnly = new JComboBox();
jComboBoxReadOnly.setBounds(new java.awt.Rectangle(95,22,117,20));
jComboBoxReadOnly.setPreferredSize(new Dimension(80, 20));
jComboBoxReadOnly.addItem("TRUE");
jComboBoxReadOnly.addItem("FALSE");
jComboBoxReadOnly.setSelectedIndex(1);
jComboBoxReadOnly.addItemListener(new java.awt.event.ItemListener() {
public void itemStateChanged(java.awt.event.ItemEvent e) {
sfc.setSpdPkgDefsRdOnly(jComboBoxReadOnly.getSelectedItem()+"");
}
});
}
return jComboBoxReadOnly;
}
/**
* This method initializes jComboBox1
*
* @return javax.swing.JComboBox
*/
private JComboBox getJComboBox1() {
if (jComboBoxRePackage == null) {
jComboBoxRePackage = new JComboBox();
jComboBoxRePackage.setBounds(new java.awt.Rectangle(95,62,116,20));
jComboBoxRePackage.setPreferredSize(new Dimension(80, 20));
jComboBoxRePackage.addItem("FALSE");
jComboBoxRePackage.addItem("TRUE");
jComboBoxRePackage.setSelectedIndex(0);
jComboBoxRePackage.addItemListener(new java.awt.event.ItemListener() {
public void itemStateChanged(java.awt.event.ItemEvent e) {
sfc.setSpdPkgDefsRePkg(jComboBoxRePackage.getSelectedItem()+"");
}
});
}
return jComboBoxRePackage;
}
}

View File

@@ -0,0 +1,627 @@
/** @file
Java class SpdPackageHeaders 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.frameworkwizard.packaging.ui;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ComponentEvent;
import java.io.File;
import java.util.Vector;
import javax.swing.DefaultCellEditor;
import javax.swing.DefaultListModel;
import javax.swing.JFileChooser;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.JTable;
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.ListSelectionModel;
import javax.swing.event.InternalFrameAdapter;
import javax.swing.event.InternalFrameEvent;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import javax.swing.event.TableModelEvent;
import javax.swing.event.TableModelListener;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableColumn;
import javax.swing.table.TableModel;
import org.tianocore.PackageSurfaceAreaDocument;
import org.tianocore.frameworkwizard.common.DataType;
import org.tianocore.frameworkwizard.common.Tools;
import org.tianocore.frameworkwizard.common.ui.IInternalFrame;
import org.tianocore.frameworkwizard.common.ui.StarLabel;
/**
GUI for create library definition elements of spd file.
@since PackageEditor 1.0
**/
public class SpdPackageHeaders extends IInternalFrame implements TableModelListener{
static JFrame frame;
private SpdFileContents sfc = null;
private DefaultTableModel model = null;
private JPanel jContentPane = null;
private JRadioButton jRadioButtonAdd = null;
private JRadioButton jRadioButtonSelect = null;
private JTextField jTextFieldAdd = null;
private JComboBox jComboBoxSelect = 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;
private StarLabel jStarLabel1 = null;
private StarLabel jStarLabel2 = null;
private JScrollPane jScrollPane = null;
private JScrollPane jScrollPane1 = null;
private int selectedRow = -1;
private JTable jTable = null;
/**
This method initializes this
**/
private void initialize() {
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(9,35,197,20));
jRadioButtonAdd.setText("Add a new ModuleType");
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(9,10,198,20));
jRadioButtonSelect.setText("Select Existing ModuleType");
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.setPreferredSize(new java.awt.Dimension(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.setPreferredSize(new java.awt.Dimension(260,20));
jComboBoxSelect.setEnabled(true);
}
return jComboBoxSelect;
}
/**
This method initializes jTable
@return javax.swing.JTable
*
private JTable getJTable() {
if (jTable == null) {
model = new PackageHeaderTableModel();
model.addColumn("ModuleType");
model.addColumn("IncludeHeader");
}
return jTable;
}*/
/**
This method initializes jButtonAdd
@return javax.swing.JButton
**/
private JButton getJButtonAdd() {
if (jButtonAdd == null) {
jButtonAdd = new JButton();
jButtonAdd.setBounds(new java.awt.Rectangle(189,119,73,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(271,119,87,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(374,119,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.setVisible(false);
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.setVisible(false);
jButtonOk.addActionListener(this);
}
return jButtonOk;
}
/**
This is the default constructor
**/
public SpdPackageHeaders() {
super();
initialize();
init();
}
public SpdPackageHeaders(PackageSurfaceAreaDocument.PackageSurfaceArea inPsa){
this();
sfc = new SpdFileContents(inPsa);
init(sfc);
}
/**
This method initializes this
@return void
**/
private void init() {
this.setContentPane(getJScrollPane());
this.setTitle("Library Class Declarations");
this.setBounds(new java.awt.Rectangle(0, 0, 500, 370));
this.setVisible(true);
this.addInternalFrameListener(new InternalFrameAdapter(){
public void internalFrameDeactivated(InternalFrameEvent e){
if (jTable.isEditing()) {
jTable.getCellEditor().stopCellEditing();
}
}
});
initFrame();
}
private void init(SpdFileContents sfc){
if (sfc.getSpdPackageHeaderCount() == 0) {
return ;
}
String[][] saa = new String[sfc.getSpdPackageHeaderCount()][2];
sfc.getSpdPackageHeaders(saa);
int i = 0;
while (i < saa.length) {
model.addRow(saa[i]);
i++;
}
}
private JScrollPane getJScrollPane(){
if (jScrollPane == null){
jScrollPane = new JScrollPane();
jScrollPane.setViewportView(getJContentPane());
}
return jScrollPane;
}
/**
This method initializes jContentPane
@return javax.swing.JPanel
**/
private JPanel getJContentPane() {
if (jContentPane == null) {
jStarLabel1 = new StarLabel();
jStarLabel1.setLocation(new java.awt.Point(0, 10));
jStarLabel2 = new StarLabel();
jStarLabel2.setLocation(new java.awt.Point(0,62));
jLabel = new JLabel();
jLabel.setBounds(new java.awt.Rectangle(14,62,199,22));
jLabel.setText("Include Header for Module Type");
jContentPane = new JPanel();
jContentPane.setPreferredSize(new Dimension(480, 325));
jContentPane.setLayout(null);
jContentPane.add(jLabel, null);
jContentPane.add(jStarLabel1, null);
jContentPane.add(jStarLabel2, null);
jContentPane.add(getJRadioButtonAdd(), null);
jContentPane.add(getJRadioButtonSelect(), null);
jContentPane.add(getJTextFieldAdd(), null);
jContentPane.add(getJComboBoxSelect(), null);
jContentPane.add(getJButtonAdd(), null);
jContentPane.add(getJButtonRemove(), null);
jContentPane.add(getJButtonClearAll(), null);
jContentPane.add(getJButtonCancel(), null);
jContentPane.add(getJButtonOk(), null);
jContentPane.add(getJTextField(), null);
jContentPane.add(getJButtonBrowse(), null);
jContentPane.add(getJScrollPane1(), null);
}
return jContentPane;
}
/**
fill ComboBoxes with pre-defined contents
**/
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");
jComboBoxSelect.setSelectedIndex(0);
}
/* (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();
}
//ToDo: check before add
String[] row = {"", ""};
row[0] = strLibClass;
row[1] = jTextField.getText().replace('\\', '/');
model.addRow(row);
sfc.genSpdModuleHeaders(row[0], row[1], null, null, null, null, null, null);
}
//
// remove selected line
//
if (arg0.getSource() == jButtonRemove) {
if (jTable.isEditing()){
jTable.getCellEditor().stopCellEditing();
}
int rowSelected = selectedRow;
if (rowSelected >= 0) {
model.removeRow(rowSelected);
sfc.removeSpdPkgHeader(rowSelected);
}
}
if (arg0.getSource() == jButtonClearAll) {
if (model.getRowCount() == 0) {
return;
}
model.setRowCount(0);
sfc.removeSpdPkgHeader();
}
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() {
}
/**
This method initializes jTextField
@return javax.swing.JTextField
**/
private JTextField getJTextField() {
if (jTextField == null) {
jTextField = new JTextField();
jTextField.setBounds(new java.awt.Rectangle(13,90,346,21));
jTextField.setPreferredSize(new java.awt.Dimension(345,20));
}
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,89,92,21));
jButtonBrowse.setText("Browse");
jButtonBrowse.setPreferredSize(new java.awt.Dimension(92,20));
jButtonBrowse.addActionListener(new javax.swing.AbstractAction() {
public void actionPerformed(ActionEvent e) {
//
// Select files from current workspace
//
String dirPrefix = Tools.dirForNewSpd.substring(0, Tools.dirForNewSpd.lastIndexOf(File.separator));
JFileChooser chooser = new JFileChooser(dirPrefix);
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(dirPrefix)) {
JOptionPane.showMessageDialog(frame, "You can only select files in current package!");
return;
}
}
else {
return;
}
headerDest = theFile.getPath();
int fileIndex = headerDest.indexOf(System.getProperty("file.separator"), dirPrefix.length());
jTextField.setText(headerDest.substring(fileIndex + 1).replace('\\', '/'));
}
});
}
return jButtonBrowse;
}
/**
* This method initializes jScrollPane
*
* @return javax.swing.JScrollPane
*/
private JScrollPane getJScrollPane1() {
if (jScrollPane1 == null) {
jScrollPane1 = new JScrollPane();
jScrollPane1.setBounds(new java.awt.Rectangle(13,149,453,165));
jScrollPane1.setViewportView(getJTable());
}
return jScrollPane1;
}
/**
* This method initializes jTable
*
* @return javax.swing.JTable
*/
private JTable getJTable() {
if (jTable == null) {
model = new DefaultTableModel();
jTable = new JTable(model);
model.addColumn("ModuleType");
model.addColumn("IncludeHeader");
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));
jTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
jTable.getSelectionModel().addListSelectionListener(new ListSelectionListener(){
public void valueChanged(ListSelectionEvent e) {
if (e.getValueIsAdjusting()){
return;
}
ListSelectionModel lsm = (ListSelectionModel)e.getSource();
if (lsm.isSelectionEmpty()) {
return;
}
else{
selectedRow = lsm.getMinSelectionIndex();
}
}
});
jTable.getModel().addTableModelListener(this);
}
return jTable;
}
public void tableChanged(TableModelEvent arg0) {
// TODO Auto-generated method stub
int row = arg0.getFirstRow();
TableModel m = (TableModel)arg0.getSource();
if (arg0.getType() == TableModelEvent.UPDATE){
String pkg = m.getValueAt(row, 0) + "";
String hdr = m.getValueAt(row, 1) + "";
sfc.updateSpdPkgHdr(row, pkg, hdr);
}
}
public void componentResized(ComponentEvent arg0) {
int intPreferredWidth = 500;
resizeComponentWidth(this.jComboBoxSelect, this.getWidth(), intPreferredWidth);
resizeComponentWidth(this.jTextFieldAdd, this.getWidth(), intPreferredWidth);
resizeComponentWidth(this.jTextField, this.getWidth(), intPreferredWidth);
resizeComponentWidth(this.jScrollPane, this.getWidth(), intPreferredWidth);
relocateComponentX(this.jButtonBrowse, this.getWidth(), this.getPreferredSize().width, 30);
}
public static void main(String[] args){
new SpdPackageHeaders().setVisible(true);
}
}

View File

@@ -0,0 +1,935 @@
/** @file
Java class SpdPcdDefs 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.frameworkwizard.packaging.ui;
import java.awt.Dimension;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ComponentEvent;
import javax.swing.ButtonGroup;
import javax.swing.DefaultCellEditor;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
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.ListSelectionModel;
import javax.swing.event.InternalFrameAdapter;
import javax.swing.event.InternalFrameEvent;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import javax.swing.event.TableModelEvent;
import javax.swing.event.TableModelListener;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableColumn;
import javax.swing.table.TableModel;
import org.tianocore.PackageSurfaceAreaDocument;
import org.tianocore.frameworkwizard.common.DataType;
import org.tianocore.frameworkwizard.common.ui.IInternalFrame;
import org.tianocore.frameworkwizard.common.ui.StarLabel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JCheckBox;
import org.tianocore.frameworkwizard.common.ui.iCheckBoxList.ICheckBoxList;
import java.awt.Rectangle;
import java.util.Vector;
/**
GUI for create PCD definition elements of spd file
@since PackageEditor 1.0
**/
public class SpdPcdDefs extends IInternalFrame implements TableModelListener{
static JFrame frame;
private JPanel jContentPane = null;
private JLabel jLabelItemType = null;
private JLabel jLabelC_Name = 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 SpdFileContents sfc = null;
private StarLabel jStarLabel2 = null;
private StarLabel jStarLabel3 = null;
private StarLabel jStarLabel4 = null;
private StarLabel jStarLabel = null;
private StarLabel jStarLabel1 = null;
private JLabel jLabelTokenSpace = null;
private JTextField jTextFieldTsGuid = null;
private JLabel jLabelVarVal = null;
private JTextField jTextField = null;
private JLabel jLabelDefVal = null;
private JTextField jTextFieldDefaultValue = null;
private JButton jButtonAdd = null;
private CheckboxTableModel model = null;
private JButton jButtonRemove = null;
private JButton jButtonClearAll = null;
private JButton jButtonGen = null;
private GenGuidDialog guidDialog = null;
private JScrollPane jScrollPane = null;
private JTable jTable = null;
private JScrollPane topScrollPane = null; // @jve:decl-index=0:visual-constraint="390,10"
private int selectedRow = -1;
private StarLabel starLabel = null;
private JCheckBox jCheckBox = null;
private JCheckBox jCheckBox1 = null;
private JCheckBox jCheckBox2 = null;
private JCheckBox jCheckBox3 = null;
private JCheckBox jCheckBox4 = null;
private JScrollPane jScrollPane1 = null;
private ICheckBoxList iCheckBoxList = null;
private JScrollPane jScrollPane2 = null;
private ICheckBoxList iCheckBoxList1 = null;
private JLabel jLabel = null;
private JLabel jLabel1 = null;
/**
This method initializes this
**/
private void initialize() {
this.setTitle("PCD Definition");
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(156,9,317,20));
jTextFieldC_Name.setPreferredSize(new java.awt.Dimension(315,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(156,33,317,20));
jTextFieldToken.setPreferredSize(new java.awt.Dimension(315,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,276,90,20));
jButtonOk.setVisible(false);
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,276,82,20));
jButtonCancel.setVisible(false);
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(156,84,110,20));
}
return jComboBoxDataType;
}
/**
This is the default constructor
**/
public SpdPcdDefs() {
super();
init();
initialize();
}
public SpdPcdDefs(PackageSurfaceAreaDocument.PackageSurfaceArea inPsa) {
this();
sfc = new SpdFileContents(inPsa);
init(sfc);
}
/**
This method initializes this
@return void
**/
private void init() {
this.setSize(500, 650);
this.setContentPane(getJContentPane());
this.addInternalFrameListener(new InternalFrameAdapter(){
public void internalFrameDeactivated(InternalFrameEvent e){
if (jTable.isEditing()) {
jTable.getCellEditor().stopCellEditing();
}
}
});
initFrame();
this.setVisible(true);
}
private void init(SpdFileContents sfc){
if (sfc.getSpdPcdDefinitionCount() == 0) {
return ;
}
String[][] saa = new String[sfc.getSpdPcdDefinitionCount()][8];
String[][] usage = new String[sfc.getSpdPcdDefinitionCount()][5];
Object[] rowData = new Object[13];
sfc.getSpdPcdDefinitions(saa, usage);
int i = 0;
while (i < saa.length) {
for (int k = 0; k < 6; ++k) {
rowData[k] = saa[i][k];
}
for (int m = 7; m < 11; ++m) {
rowData[m] = new Boolean("false");
}
int j = 0;
while (j < 5) {
if (usage[i][j] == null || usage[i][j].length()==0){
++j;
continue;
}
if (usage[i][j].equals("FEATURE_FLAG")){
rowData[6] = new Boolean("true");
}
if (usage[i][j].equals("FIXED_AT_BUILD")){
rowData[7] = new Boolean("true");
}
if (usage[i][j].equals("PATCHABLE_IN_MODULE")){
rowData[8] = new Boolean("true");
}
if (usage[i][j].equals("DYNAMIC")){
rowData[9] = new Boolean("true");
}
if (usage[i][j].equals("DYNAMIC_EX")){
rowData[10] = new Boolean("true");
}
++j;
}
rowData[11] = saa[i][6];
rowData[12] = saa[i][7];
model.addRow(rowData);
i++;
}
}
private JScrollPane getJContentPane(){
if (topScrollPane == null){
topScrollPane = new JScrollPane();
topScrollPane.setSize(new java.awt.Dimension(482,451));
topScrollPane.setViewportView(getJContentPane1());
}
return topScrollPane;
}
private JPanel getJContentPane1() {
if (jContentPane == null) {
jLabel1 = new JLabel();
jLabel1.setBounds(new java.awt.Rectangle(241,192,89,16));
jLabel1.setText("Supported Arch");
jLabel1.setEnabled(true);
jLabel = new JLabel();
jLabel.setBounds(new java.awt.Rectangle(15,193,103,16));
jLabel.setText("Supported Module");
jLabel.setEnabled(true);
starLabel = new StarLabel();
starLabel.setBounds(new java.awt.Rectangle(2,134,10,20));
jLabelDefVal = new JLabel();
jLabelDefVal.setBounds(new java.awt.Rectangle(277,84,80,20));
jLabelDefVal.setText("Default Value");
jLabelVarVal = new JLabel();
jLabelVarVal.setBounds(new java.awt.Rectangle(11,133,84,20));
jLabelVarVal.setText("Valid Usage");
jLabelC_Name = new JLabel();
jLabelC_Name.setText("C_Name");
jLabelC_Name.setBounds(new java.awt.Rectangle(11,9,140,20));
jLabelTokenSpace = new JLabel();
jLabelTokenSpace.setBounds(new java.awt.Rectangle(11,58,140,20));
jLabelTokenSpace.setText("Token Space");
jLabelDataType = new JLabel();
jLabelDataType.setText("Data Type");
jLabelDataType.setBounds(new java.awt.Rectangle(11,83,140,20));
jLabelToken = new JLabel();
jLabelToken.setText("Token");
jLabelToken.setBounds(new java.awt.Rectangle(11,33,140,20));
jLabelItemType = new JLabel();
jLabelItemType.setText("Help Text");
jLabelItemType.setBounds(new java.awt.Rectangle(11,108,140,20));
jContentPane = new JPanel();
jContentPane.setLayout(null);
jContentPane.setPreferredSize(new java.awt.Dimension(479,375));
jContentPane.add(jLabelItemType, null);
jContentPane.add(jLabelC_Name, null);
jContentPane.add(jLabelTokenSpace, null);
jContentPane.add(getJTextFieldTsGuid(), null);
jContentPane.add(jLabelVarVal, 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(getJComboBoxDataType(), null);
jStarLabel = new StarLabel();
jStarLabel1 = new StarLabel();
jStarLabel1.setBounds(new java.awt.Rectangle(2,8,10,20));
jStarLabel2 = new StarLabel();
jStarLabel3 = new StarLabel();
jStarLabel4 = new StarLabel();
jStarLabel.setLocation(new java.awt.Point(2,84));
jStarLabel4.setLocation(new java.awt.Point(2, 109));
jStarLabel2.setLocation(new java.awt.Point(2,33));
jStarLabel3.setLocation(new java.awt.Point(2, 58));
jStarLabel3.setSize(new java.awt.Dimension(8,20));
jContentPane.add(jStarLabel2, null);
jContentPane.add(jStarLabel3, null);
jContentPane.add(jStarLabel, null);
jContentPane.add(jStarLabel1, null);
jContentPane.add(jStarLabel4, null);
jContentPane.add(getJTextField(), null);
jContentPane.add(jLabelDefVal, null);
jContentPane.add(getJTextFieldDefaultValue(), null);
jContentPane.add(getJButtonAdd(), null);
jContentPane.add(getJButtonRemove(), null);
jContentPane.add(getJButtonClearAll(), null);
jContentPane.add(getJButtonGen(), null);
jContentPane.add(getJScrollPane(), null);
jContentPane.add(starLabel, null);
jContentPane.add(getJCheckBox(), null);
jContentPane.add(getJCheckBox1(), null);
jContentPane.add(getJCheckBox2(), null);
jContentPane.add(getJCheckBox3(), null);
jContentPane.add(getJCheckBox4(), null);
jContentPane.add(getJScrollPane1(), null);
jContentPane.add(getJScrollPane2(), null);
jContentPane.add(jLabel, null);
jContentPane.add(jLabel1, null);
}
return jContentPane;
}
/**
This method initializes comboboxes
jContentPane.add(jLabelTokenSpace, null);
**/
private void initFrame() {
jComboBoxDataType.addItem("UINT8");
jComboBoxDataType.addItem("UINT16");
jComboBoxDataType.addItem("UINT32");
jComboBoxDataType.addItem("UINT64");
jComboBoxDataType.addItem("VOID*");
jComboBoxDataType.addItem("BOOLEAN");
jComboBoxDataType.setSelectedIndex(0);
}
public void actionPerformed(ActionEvent arg0) {
if (arg0.getSource() == jButtonOk) {
this.save();
this.dispose();
}
if (arg0.getSource() == jButtonCancel) {
this.dispose();
}
if (arg0.getSource() == jButtonAdd) {
//ToDo: check before add
if (!checkValid()) {
return;
}
String archList = vectorToString(iCheckBoxList.getAllCheckedItemsString());
if (archList.length() == 0) {
archList = null;
}
String modTypeList = vectorToString(iCheckBoxList1.getAllCheckedItemsString());
if (modTypeList.length() == 0) {
modTypeList = null;
}
Object[] row = {jTextFieldC_Name.getText(), jTextFieldToken.getText(),
jTextFieldTsGuid.getText(), jComboBoxDataType.getSelectedItem(),
jTextFieldDefaultValue.getText(), jTextField.getText(),
jCheckBox.isSelected(), jCheckBox1.isSelected(),
jCheckBox2.isSelected(), jCheckBox3.isSelected(), jCheckBox4.isSelected(),
archList, modTypeList};
model.addRow(row);
String usage = getValidUsage(jCheckBox.isSelected(), jCheckBox1.isSelected(), jCheckBox2.isSelected(), jCheckBox3.isSelected(), jCheckBox4.isSelected());
if (usage.length() == 0) {
usage = null;
}
sfc.genSpdPcdDefinitions(row[0]+"", row[1]+"", row[3]+"", usage, row[2]+"", row[4]+"", row[5]+"", archList, modTypeList);
}
//
// remove selected line
//
if (arg0.getSource() == jButtonRemove) {
if (jTable.isEditing()){
jTable.getCellEditor().stopCellEditing();
}
int rowSelected = selectedRow;
if (rowSelected >= 0) {
model.removeRow(rowSelected);
sfc.removeSpdPcdDefinition(rowSelected);
}
}
if (arg0.getSource() == jButtonClearAll) {
if (model.getRowCount() == 0) {
return;
}
model.setRowCount(0);
sfc.removeSpdPcdDefinition();
}
if (arg0.getSource() == jButtonGen) {
guidDialog = new GenGuidDialog(this);
guidDialog.setGuid(jTextFieldTsGuid.getText());
guidDialog.setVisible(true);
}
if (arg0.getActionCommand().equals("GenGuidValue")) {
jTextFieldTsGuid.setText(guidDialog.getGuid());
}
}
protected void save() {
}
/**
* This method initializes jTextFieldTsGuid
*
* @return javax.swing.JTextField
*/
private JTextField getJTextFieldTsGuid() {
if (jTextFieldTsGuid == null) {
jTextFieldTsGuid = new JTextField();
jTextFieldTsGuid.setBounds(new java.awt.Rectangle(156,58,249,20));
jTextFieldTsGuid.setPreferredSize(new java.awt.Dimension(250,20));
}
return jTextFieldTsGuid;
}
/**
* This method initializes jTextField
*
* @return javax.swing.JTextField
*/
private JTextField getJTextField() {
if (jTextField == null) {
jTextField = new JTextField();
jTextField.setBounds(new java.awt.Rectangle(156,108,317,20));
jTextField.setPreferredSize(new java.awt.Dimension(315,20));
}
return jTextField;
}
/**
* This method initializes jTextFieldDefaultValue
*
* @return javax.swing.JTextField
*/
private JTextField getJTextFieldDefaultValue() {
if (jTextFieldDefaultValue == null) {
jTextFieldDefaultValue = new JTextField();
jTextFieldDefaultValue.setBounds(new java.awt.Rectangle(368,84,105,20));
jTextFieldDefaultValue.setPreferredSize(new java.awt.Dimension(104,20));
}
return jTextFieldDefaultValue;
}
/**
* This method initializes jButtonAdd
*
* @return javax.swing.JButton
*/
private JButton getJButtonAdd() {
if (jButtonAdd == null) {
jButtonAdd = new JButton();
jButtonAdd.setBounds(new java.awt.Rectangle(195,277,71,20));
jButtonAdd.setPreferredSize(new java.awt.Dimension(70,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(278,277,81,20));
jButtonRemove.setPreferredSize(new java.awt.Dimension(70,20));
jButtonRemove.setText("Delete");
jButtonRemove.addActionListener(this);
}
return jButtonRemove;
}
/**
* This method initializes jButtonClearAll
*
* @return javax.swing.JButton
*/
private JButton getJButtonClearAll() {
if (jButtonClearAll == null) {
jButtonClearAll = new JButton();
jButtonClearAll.setBounds(new java.awt.Rectangle(382,277,90,20));
jButtonClearAll.setPreferredSize(new java.awt.Dimension(81,20));
jButtonClearAll.setText("Clear All");
jButtonClearAll.addActionListener(this);
}
return jButtonClearAll;
}
/**
* This method initializes jButtonGen
*
* @return javax.swing.JButton
*/
private JButton getJButtonGen() {
if (jButtonGen == null) {
jButtonGen = new JButton();
jButtonGen.setBounds(new java.awt.Rectangle(414,57,58,20));
jButtonGen.setPreferredSize(new java.awt.Dimension(56,20));
jButtonGen.setText("Gen");
jButtonGen.addActionListener(this);
}
return jButtonGen;
}
public void componentResized(ComponentEvent arg0) {
int intPreferredWidth = 500;
resizeComponentWidth(this.jTextFieldC_Name, this.getWidth(), intPreferredWidth);
resizeComponentWidth(this.jTextFieldToken, this.getWidth(), intPreferredWidth);
resizeComponentWidth(this.jTextFieldTsGuid, this.getWidth(), intPreferredWidth);
resizeComponentWidth(this.jTextFieldDefaultValue, this.getWidth(), intPreferredWidth);
resizeComponentWidth(this.jTextField, this.getWidth(), intPreferredWidth);
resizeComponentWidth(this.jScrollPane, this.getWidth(), intPreferredWidth);
resizeComponentWidth(this.jTextField, this.getWidth(), intPreferredWidth);
resizeComponentWidth(this.jTextFieldDefaultValue, this.getWidth(), intPreferredWidth);
// relocateComponentX(this.jButtonClearAll, this.getWidth(), DataType.SPACE_TO_RIGHT_FOR_GENERATE_BUTTON);
// relocateComponentX(this.jButtonRemove, this.getWidth(), DataType.SPACE_TO_RIGHT_FOR_GENERATE_BUTTON);
// relocateComponentX(this.jButtonAdd, this.getWidth(), DataType.SPACE_TO_RIGHT_FOR_GENERATE_BUTTON);
relocateComponentX(this.jButtonGen, this.getWidth(), this.getPreferredSize().width, 30);
}
/**
* This method initializes jScrollPane
*
* @return javax.swing.JScrollPane
*/
private JScrollPane getJScrollPane() {
if (jScrollPane == null) {
jScrollPane = new JScrollPane();
jScrollPane.setBounds(new java.awt.Rectangle(5,301,1473,137));
jScrollPane.setViewportView(getJTable());
}
return jScrollPane;
}
/**
* This method initializes jTable
*
* @return javax.swing.JTable
*/
private JTable getJTable() {
if (jTable == null) {
model = new CheckboxTableModel();
jTable = new JTable(model);
jTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
jTable.setSize(new Dimension(1000, 300));
model.addColumn("C_Name");
model.addColumn("Token");
model.addColumn("TokenSpace");
model.addColumn("DatumType");
model.addColumn("DefaultValue");
model.addColumn("HelpText");
model.addColumn("FeatureFlag");
model.addColumn("FixedAtBuild");
model.addColumn("PatchableInModule");
model.addColumn("Dynamic");
model.addColumn("DynamicEx");
model.addColumn("SupportedArch");
model.addColumn("SupportedModule");
jTable.getColumnModel().getColumn(2).setCellEditor(new GuidEditor());
//ToDo: add a valid usage editor
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));
jTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
jTable.getSelectionModel().addListSelectionListener(new ListSelectionListener(){
public void valueChanged(ListSelectionEvent e) {
if (e.getValueIsAdjusting()){
return;
}
ListSelectionModel lsm = (ListSelectionModel)e.getSource();
if (lsm.isSelectionEmpty()) {
return;
}
else{
selectedRow = lsm.getMinSelectionIndex();
}
}
});
jTable.getModel().addTableModelListener(this);
}
return jTable;
}
public void tableChanged(TableModelEvent arg0) {
// TODO Auto-generated method stub
int row = arg0.getFirstRow();
TableModel m = (TableModel)arg0.getSource();
if (arg0.getType() == TableModelEvent.UPDATE){
String cName = m.getValueAt(row, 0) + "";
String token = m.getValueAt(row, 1) + "";
String ts = m.getValueAt(row, 2) + "";
String dataType = m.getValueAt(row, 3) + "";
String defaultVal = m.getValueAt(row, 4) + "";
String help = m.getValueAt(row, 5) + "";
String usage = getValidUsage(new Boolean(m.getValueAt(row, 6)+""), new Boolean(m.getValueAt(row, 7)+""), new Boolean(m.getValueAt(row, 8)+""), new Boolean(m.getValueAt(row, 9)+""), new Boolean(m.getValueAt(row, 10)+""));
String archList = vectorToString(iCheckBoxList.getAllCheckedItemsString());
String modTypeList = vectorToString(iCheckBoxList1.getAllCheckedItemsString());
sfc.updateSpdPcdDefinition(row, cName, token, dataType, usage, ts, defaultVal, help, archList, modTypeList);
}
}
/**
* This method initializes jCheckBox
*
* @return javax.swing.JCheckBox
*/
private JCheckBox getJCheckBox() {
if (jCheckBox == null) {
jCheckBox = new JCheckBox();
jCheckBox.setBounds(new java.awt.Rectangle(156,161,100,21));
jCheckBox.setText("Feature Flag");
jCheckBox.setPreferredSize(new java.awt.Dimension(21,20));
}
return jCheckBox;
}
/**
* This method initializes jCheckBox1
*
* @return javax.swing.JCheckBox
*/
private JCheckBox getJCheckBox1() {
if (jCheckBox1 == null) {
jCheckBox1 = new JCheckBox();
jCheckBox1.setBounds(new java.awt.Rectangle(302,133,108,20));
jCheckBox1.setText("Fixed at Build");
jCheckBox1.setPreferredSize(new java.awt.Dimension(21,20));
}
return jCheckBox1;
}
/**
* This method initializes jCheckBox2
*
* @return javax.swing.JCheckBox
*/
private JCheckBox getJCheckBox2() {
if (jCheckBox2 == null) {
jCheckBox2 = new JCheckBox();
jCheckBox2.setBounds(new java.awt.Rectangle(156,133,154,20));
jCheckBox2.setText("Patchable in Module");
jCheckBox2.setPreferredSize(new java.awt.Dimension(21,20));
}
return jCheckBox2;
}
/**
* This method initializes jCheckBox3
*
* @return javax.swing.JCheckBox
*/
private JCheckBox getJCheckBox3() {
if (jCheckBox3 == null) {
jCheckBox3 = new JCheckBox();
jCheckBox3.setBounds(new java.awt.Rectangle(278,161,80,20));
jCheckBox3.setText("Dynamic");
jCheckBox3.setPreferredSize(new java.awt.Dimension(21,20));
}
return jCheckBox3;
}
/**
* This method initializes jCheckBox4
*
* @return javax.swing.JCheckBox
*/
private JCheckBox getJCheckBox4() {
if (jCheckBox4 == null) {
jCheckBox4 = new JCheckBox();
jCheckBox4.setBounds(new java.awt.Rectangle(371,161,99,20));
jCheckBox4.setText("DynamicEx");
jCheckBox4.setPreferredSize(new java.awt.Dimension(21,20));
}
return jCheckBox4;
}
private String getValidUsage(boolean ff, boolean fab, boolean pim, boolean d, boolean de) {
String usage = "";
if (ff){
usage += "FEATURE_FLAG ";
}
if (fab){
usage += "FIXED_AT_BUILD ";
}
if (pim){
usage += "PATCHABLE_IN_MODULE ";
}
if (d){
usage += "DYNAMIC ";
}
if (de){
usage += "DYNAMIC_EX ";
}
return usage.trim();
}
private boolean checkValid() {
if (!(jCheckBox.isSelected() || jCheckBox1.isSelected() || jCheckBox2.isSelected() || jCheckBox3.isSelected() || jCheckBox4.isSelected())){
JOptionPane.showMessageDialog(frame, "You must specify at least one usage.");
return false;
}
return true;
}
/**
* This method initializes jScrollPane1
*
* @return javax.swing.JScrollPane
*/
private JScrollPane getJScrollPane1() {
if (jScrollPane1 == null) {
jScrollPane1 = new JScrollPane();
jScrollPane1.setBounds(new java.awt.Rectangle(242,213,188,54));
jScrollPane1.setViewportView(getICheckBoxList());
jScrollPane1.setPreferredSize(new Dimension(188, 74));
}
return jScrollPane1;
}
/**
* This method initializes iCheckBoxList
*
* @return org.tianocore.frameworkwizard.common.ui.iCheckBoxList.ICheckBoxList
*/
private ICheckBoxList getICheckBoxList() {
if (iCheckBoxList == null) {
iCheckBoxList = new ICheckBoxList();
iCheckBoxList.setBounds(new Rectangle(197, 142, 188, 74));
Vector<String> v = new Vector<String>();
v.add("IA32");
v.add("X64");
v.add("IPF");
v.add("EBC");
iCheckBoxList.setAllItems(v);
}
return iCheckBoxList;
}
/**
* This method initializes jScrollPane2
*
* @return javax.swing.JScrollPane
*/
private JScrollPane getJScrollPane2() {
if (jScrollPane2 == null) {
jScrollPane2 = new JScrollPane();
jScrollPane2.setBounds(new java.awt.Rectangle(15,213,199,55));
jScrollPane2.setViewportView(getICheckBoxList1());
jScrollPane2.setPreferredSize(new Dimension(170, 74));
}
return jScrollPane2;
}
/**
* This method initializes iCheckBoxList1
*
* @return org.tianocore.frameworkwizard.common.ui.iCheckBoxList.ICheckBoxList
*/
private ICheckBoxList getICheckBoxList1() {
if (iCheckBoxList1 == null) {
iCheckBoxList1 = new ICheckBoxList();
iCheckBoxList1.setBounds(new Rectangle(14, 142, 170, 74));
Vector<String> v = new Vector<String>();
v.add("BASE");
v.add("SEC");
v.add("PEI_CORE");
v.add("PEIM");
v.add("DXE_CORE");
v.add("DXE_DRIVER");
v.add("DXE_RUNTIME_DRIVER");
v.add("DXE_SAL_DRIVER");
v.add("DXE_SMM_DRIVER");
v.add("UEFI_DRIVER");
v.add("UEFI_APPLICATION");
v.add("USER_DEFINED");
iCheckBoxList1.setAllItems(v);
}
return iCheckBoxList1;
}
protected String vectorToString(Vector<String> v) {
if (v == null) {
return null;
}
String s = " ";
for (int i = 0; i < v.size(); ++i) {
s += v.get(i);
s += " ";
}
return s.trim();
}
} // @jve:decl-index=0:visual-constraint="22,11"
class CheckboxTableModel extends DefaultTableModel {
public Class getColumnClass (int c) {
if (getValueAt(0, c) != null){
return getValueAt(0, c).getClass();
}
return String.class;
}
}

View File

@@ -0,0 +1,96 @@
/** @file
Java class SpdProtocolDecls 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.frameworkwizard.packaging.ui;
import javax.swing.event.TableModelEvent;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableModel;
import org.tianocore.PackageSurfaceAreaDocument;
/**
GUI for create library definition elements of spd file.
@since PackageEditor 1.0
**/
public class SpdPpiDecls extends SpdGuidDecls {
private SpdFileContents sfc = null;
public SpdPpiDecls() {
super();
// TODO Auto-generated constructor stub
}
public SpdPpiDecls(PackageSurfaceAreaDocument.PackageSurfaceArea inPsa) {
this();
sfc = new SpdFileContents(inPsa);
init(sfc);
}
protected void initFrame() {
this.setTitle("PPI Declarations");
getJScrollPaneGuid().setVisible(false);
getJLabel3().setVisible(false);
getJTable().getColumn("GuidTypes").setPreferredWidth(0);
getJTable().getColumn("GuidTypes").setWidth(0);
getJTable().getColumn("GuidTypes").setHeaderValue(" ");
}
protected void init(SpdFileContents sfc){
//
// initialize table using SpdFileContents object
//
DefaultTableModel model = getModel();
if (sfc.getSpdPpiDeclarationCount() == 0) {
return ;
}
String[][] saa = new String[sfc.getSpdPpiDeclarationCount()][6];
sfc.getSpdPpiDeclarations(saa);
int i = 0;
while (i < saa.length) {
model.addRow(saa[i]);
i++;
}
}
protected void updateRow(int row, TableModel m){
String name = m.getValueAt(row, 0) + "";
String cName = m.getValueAt(row, 1) + "";
String guid = m.getValueAt(row, 2) + "";
String help = m.getValueAt(row, 3) + "";
String archList = null;
if (m.getValueAt(row, 4) != null) {
archList = m.getValueAt(row, 4).toString();
}
String modTypeList = null;
if (m.getValueAt(row, 5) != null) {
modTypeList = m.getValueAt(row, 5).toString();
}
sfc.updateSpdPpiDecl(row, name, cName, guid, help, archList, modTypeList);
}
protected void addRow(String[] row) {
sfc.genSpdPpiDeclarations(row[0], row[1], row[2], row[3], stringToVector(row[4]), stringToVector(row[5]));
}
protected void removeRow(int i){
sfc.removeSpdPpiDeclaration(i);
}
protected void clearAllRow(){
sfc.removeSpdPpiDeclaration();
}
}

View File

@@ -0,0 +1,97 @@
/** @file
Java class SpdProtocolDecls 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.frameworkwizard.packaging.ui;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableModel;
import org.tianocore.PackageSurfaceAreaDocument;
/**
GUI for create library definition elements of spd file.
@since PackageEditor 1.0
**/
public class SpdProtocolDecls extends SpdGuidDecls {
private SpdFileContents sfc = null;
public SpdProtocolDecls() {
super();
// TODO Auto-generated constructor stub
}
public SpdProtocolDecls(PackageSurfaceAreaDocument.PackageSurfaceArea inPsa) {
this();
sfc = new SpdFileContents(inPsa);
init(sfc);
}
protected void initFrame() {
this.setTitle("Protocol Declarations");
getJScrollPaneGuid().setVisible(false);
getJLabel3().setVisible(false);
getJTable().getColumn("GuidTypes").setPreferredWidth(0);
getJTable().getColumn("GuidTypes").setWidth(0);
getJTable().getColumn("GuidTypes").setHeaderValue(" ");
}
protected void init(SpdFileContents sfc){
//
// initialize table using SpdFileContents object
//
DefaultTableModel model = getModel();
if (sfc.getSpdProtocolDeclarationCount() == 0) {
return ;
}
String[][] saa = new String[sfc.getSpdProtocolDeclarationCount()][6];
sfc.getSpdProtocolDeclarations(saa);
int i = 0;
while (i < saa.length) {
model.addRow(saa[i]);
i++;
}
}
protected void updateRow(int row, TableModel m){
String name = m.getValueAt(row, 0) + "";
String cName = m.getValueAt(row, 1) + "";
String guid = m.getValueAt(row, 2) + "";
String help = m.getValueAt(row, 3) + "";
String archList = null;
if (m.getValueAt(row, 4) != null) {
archList = m.getValueAt(row, 4).toString();
}
String modTypeList = null;
if (m.getValueAt(row, 5) != null) {
modTypeList = m.getValueAt(row, 5).toString();
}
sfc.updateSpdProtocolDecl(row, name, cName, guid, help, archList, modTypeList);
}
protected void addRow(String[] row) {
sfc.genSpdProtocolDeclarations(row[0], row[1], row[2], row[3], stringToVector(row[4]), stringToVector(row[5]));
}
protected void removeRow(int i){
sfc.removeSpdProtocolDeclaration(i);
}
protected void clearAllRow(){
sfc.removeSpdProtocolDeclaration();
}
}

View File

@@ -0,0 +1,50 @@
/** @file
The file is used to save basic information of platform
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.frameworkwizard.platform;
import java.io.File;
import org.tianocore.frameworkwizard.common.Identification;
public class PlatformIdentification extends Identification{
private File fpdFile;
public PlatformIdentification(String name, String guid, String version, String path){
super(name, guid, version, path);
}
public PlatformIdentification(String name, String guid, String version, File fpdFile){
super(name, guid, version);
this.fpdFile = fpdFile;
}
public PlatformIdentification(Identification id){
super(id.getName(), id.getGuid(), id.getVersion(), id.getPath());
}
public String toString(){
return "Platform " + this.getName() + "[" + this.getGuid() + "]";
}
public void setFpdFile(File fpdFile) {
this.fpdFile = fpdFile;
}
public File getFpdFile() {
return fpdFile;
}
}

View File

@@ -0,0 +1,160 @@
/** @file
The file is used to create tree view sections
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.frameworkwizard.platform.ui;
import java.awt.GridLayout;
import java.awt.Toolkit;
import javax.swing.ImageIcon;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTree;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.DefaultTreeCellRenderer;
import javax.swing.tree.DefaultTreeModel;
import javax.swing.tree.MutableTreeNode;
import javax.swing.tree.TreePath;
import javax.swing.tree.TreeSelectionModel;
import javax.swing.event.TreeModelEvent;
import javax.swing.event.TreeModelListener;
public class DynamicTree extends JPanel {
protected DefaultMutableTreeNode rootNode;
protected DefaultTreeModel treeModel;
protected JTree tree;
private Toolkit toolkit = Toolkit.getDefaultToolkit();
public DynamicTree() {
super(new GridLayout(1,0));
rootNode = new DefaultMutableTreeNode("Sections");
treeModel = new DefaultTreeModel(rootNode);
treeModel.addTreeModelListener(new MyTreeModelListener());
tree = new JTree(treeModel);
DefaultTreeCellRenderer renderer = (DefaultTreeCellRenderer) tree.getCellRenderer();
renderer.setOpenIcon(new ImageIcon("junk.gif"));
renderer.setClosedIcon(new ImageIcon("junk.gif"));
renderer.setLeafIcon(new ImageIcon("junk.gif"));
tree.setEditable(true);
tree.getSelectionModel().setSelectionMode
(TreeSelectionModel.SINGLE_TREE_SELECTION);
tree.setShowsRootHandles(true);
JScrollPane scrollPane = new JScrollPane(tree);
add(scrollPane);
}
/** Remove all nodes except the root node. */
public void clear() {
rootNode.removeAllChildren();
treeModel.reload();
}
public String getCurrentNodeText() {
DefaultMutableTreeNode currentNode = (DefaultMutableTreeNode)tree.getLastSelectedPathComponent();
if (currentNode != null){
return (String)currentNode.getUserObject();
}
return null;
}
/** Remove the currently selected node. */
public void removeCurrentNode() {
TreePath currentSelection = tree.getSelectionPath();
if (currentSelection != null) {
DefaultMutableTreeNode currentNode = (DefaultMutableTreeNode)
(currentSelection.getLastPathComponent());
MutableTreeNode parent = (MutableTreeNode)(currentNode.getParent());
if (parent != null) {
treeModel.removeNodeFromParent(currentNode);
return;
}
}
// Either there was no selection, or the root was selected.
toolkit.beep();
}
/** Add child to the currently selected node. */
public DefaultMutableTreeNode addObject(Object child) {
DefaultMutableTreeNode parentNode = null;
TreePath parentPath = tree.getSelectionPath();
if (parentPath == null) {
parentNode = rootNode;
} else {
parentNode = (DefaultMutableTreeNode)
(parentPath.getLastPathComponent());
}
return addObject(parentNode, child, true);
}
public DefaultMutableTreeNode addObject(DefaultMutableTreeNode parent,
Object child) {
return addObject(parent, child, false);
}
public DefaultMutableTreeNode addObject(DefaultMutableTreeNode parent,
Object child,
boolean shouldBeVisible) {
DefaultMutableTreeNode childNode =
new DefaultMutableTreeNode(child);
if (parent == null) {
parent = rootNode;
}
treeModel.insertNodeInto(childNode, parent,
parent.getChildCount());
//Make sure the user can see the lovely new node.
if (shouldBeVisible) {
tree.scrollPathToVisible(new TreePath(childNode.getPath()));
}
return childNode;
}
class MyTreeModelListener implements TreeModelListener {
public void treeNodesChanged(TreeModelEvent e) {
DefaultMutableTreeNode node;
node = (DefaultMutableTreeNode)
(e.getTreePath().getLastPathComponent());
/*
* If the event lists children, then the changed
* node is the child of the node we've already
* gotten. Otherwise, the changed node and the
* specified node are the same.
*/
try {
int index = e.getChildIndices()[0];
node = (DefaultMutableTreeNode)
(node.getChildAt(index));
} catch (NullPointerException exc) {}
System.out.println("The user has finished editing the node.");
System.out.println("New value: " + node.getUserObject());
}
public void treeNodesInserted(TreeModelEvent e) {
}
public void treeNodesRemoved(TreeModelEvent e) {
}
public void treeStructureChanged(TreeModelEvent e) {
}
}
}

View File

@@ -0,0 +1,669 @@
package org.tianocore.frameworkwizard.platform.ui;
import java.awt.BorderLayout;
import javax.swing.ButtonGroup;
import javax.swing.JPanel;
import javax.swing.JDialog;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.ListSelectionModel;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import javax.swing.table.DefaultTableModel;
import org.tianocore.PlatformSurfaceAreaDocument;
import org.tianocore.frameworkwizard.common.ui.IInternalFrame;
import javax.swing.JCheckBox;
import java.awt.FlowLayout;
import javax.swing.JRadioButton;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JTextField;
public class FpdDynamicPcdBuildDefinitions extends IInternalFrame {
private JPanel jContentPane = null;
private JPanel jPanel = null;
private JPanel jPanel1 = null;
private JPanel jPanel2 = null;
private JScrollPane jScrollPane = null;
private JTable jTable = null;
private DynPcdTableModel model = null;
private DynPcdTableModel model1 = null;
private FpdFileContents ffc = null;
private JPanel jPanel3 = null;
private JCheckBox jCheckBox = null;
private JPanel jPanel4 = null;
private JRadioButton jRadioButton = null;
private JRadioButton jRadioButton1 = null;
private JScrollPane jScrollPane1 = null;
private JTable jTable1 = null;
private JButton jButton = null;
private JLabel jLabel = null;
private JTextField jTextField = null;
private JLabel jLabel1 = null;
private JTextField jTextField1 = null;
private JLabel jLabel2 = null;
private JLabel jLabel3 = null;
private JTextField jTextField2 = null;
private JLabel jLabel4 = null;
private JTextField jTextField3 = null;
private JTextField jTextField4 = null;
private JLabel jLabel5 = null;
private JTextField jTextField5 = null;
private JRadioButton jRadioButton2 = null;
private ButtonGroup bg = new ButtonGroup();
private JLabel jLabel6 = null;
/**
* This is the default constructor
*/
public FpdDynamicPcdBuildDefinitions() {
super();
initialize();
}
public FpdDynamicPcdBuildDefinitions(PlatformSurfaceAreaDocument.PlatformSurfaceArea fpd){
this();
init(fpd);
}
public void init(PlatformSurfaceAreaDocument.PlatformSurfaceArea fpd) {
if (ffc == null) {
ffc = new FpdFileContents(fpd);
}
String[][] saa = new String[ffc.getDynamicPcdBuildDataCount()][5];
ffc.getDynamicPcdBuildData(saa);
for (int i = 0; i < saa.length; ++i) {
model.addRow(saa[i]);
}
saa = new String[ffc.getPlatformDefsSkuInfoCount()][2];
ffc.getPlatformDefsSkuInfos(saa);
for (int i = 0; i < saa.length; ++i) {
model1.addRow(saa[i]);
}
}
/**
* This method initializes this
*
* @return void
*/
private void initialize() {
this.setSize(661, 558);
this.setTitle("Dynamic PCD Build Definitions");
this.setContentPane(getJContentPane());
this.setVisible(true);
}
/**
* 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.NORTH);
jContentPane.add(getJPanel1(), java.awt.BorderLayout.CENTER);
jContentPane.add(getJPanel2(), java.awt.BorderLayout.SOUTH);
}
return jContentPane;
}
/**
* This method initializes jPanel
*
* @return javax.swing.JPanel
*/
private JPanel getJPanel() {
if (jPanel == null) {
jPanel = new JPanel();
}
return jPanel;
}
/**
* This method initializes jPanel1
*
* @return javax.swing.JPanel
*/
private JPanel getJPanel1() {
if (jPanel1 == null) {
jPanel1 = new JPanel();
jPanel1.add(getJScrollPane(), null);
jPanel1.add(getJPanel3(), null);
jPanel1.add(getJPanel4(), null);
}
return jPanel1;
}
/**
* This method initializes jPanel2
*
* @return javax.swing.JPanel
*/
private JPanel getJPanel2() {
if (jPanel2 == null) {
jPanel2 = new JPanel();
}
return jPanel2;
}
/**
* This method initializes jScrollPane
*
* @return javax.swing.JScrollPane
*/
private JScrollPane getJScrollPane() {
if (jScrollPane == null) {
jScrollPane = new JScrollPane();
jScrollPane.setPreferredSize(new java.awt.Dimension(600,200));
jScrollPane.setViewportView(getJTable());
}
return jScrollPane;
}
/**
* This method initializes jTable
*
* @return javax.swing.JTable
*/
private JTable getJTable() {
if (jTable == null) {
model = new DynPcdTableModel();
model.addColumn("CName");
model.addColumn("Token");
model.addColumn("TokenSpaceGuid");
model.addColumn("MaxDatumSize");
model.addColumn("DatumType");
jTable = new JTable(model);
jTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
jTable.getSelectionModel().addListSelectionListener(new ListSelectionListener(){
public void valueChanged(ListSelectionEvent e) {
if (e.getValueIsAdjusting()){
return;
}
ListSelectionModel lsm = (ListSelectionModel)e.getSource();
if (lsm.isSelectionEmpty()) {
return;
}
else{
int selectedRow = lsm.getMinSelectionIndex();
displayDetails(selectedRow);
}
}
});
}
return jTable;
}
//
// should display default sku info here, as no selection event of table1 will be triggered when change selection of rows in table.
//
private void displayDetails(int i) {
jTable1.changeSelection(0, 1, false, false);
int skuCount = ffc.getDynamicPcdSkuInfoCount(i);
String defaultVal = ffc.getDynamicPcdBuildDataValue(i);
if (defaultVal != null) {
jRadioButton2.setSelected(true);
jTextField5.setText(defaultVal);
if ( skuCount == 1) {
jCheckBox.setSelected(false);
}
else{
jCheckBox.setSelected(true);
}
}
else if (ffc.getDynamicPcdBuildDataVpdOffset(i) != null) {
jRadioButton1.setSelected(true);
jTextField4.setText(ffc.getDynamicPcdBuildDataVpdOffset(i));
if (skuCount ==1) {
jCheckBox.setSelected(false);
}
else{
jCheckBox.setSelected(true);
}
}
else {
jRadioButton.setSelected(true);
String[][] saa = new String[ffc.getDynamicPcdSkuInfoCount(i)][7];
ffc.getDynamicPcdSkuInfos(i, saa);
jTextField.setText(saa[0][1]);
jTextField1.setText(saa[0][2]);
jTextField2.setText(saa[0][3]);
jTextField3.setText(saa[0][4]);
if (skuCount ==1) {
jCheckBox.setSelected(false);
}
else{
jCheckBox.setSelected(true);
}
}
}
private void displaySkuInfoDetails(int i) {
int pcdSelected = jTable.getSelectedRow();
if (pcdSelected < 0) {
return;
}
String[][] saa = new String[ffc.getDynamicPcdSkuInfoCount(pcdSelected)][7];
ffc.getDynamicPcdSkuInfos(pcdSelected, saa);
if (saa[i][5] != null){
jRadioButton1.setSelected(true);
jTextField4.setText(saa[i][5]);
}
else if (saa[i][1] != null) {
jRadioButton.setSelected(true);
jTextField.setText(saa[i][1]);
jTextField1.setText(saa[i][2]);
jTextField2.setText(saa[i][3]);
jTextField3.setText(saa[i][4]);
}
else{
jRadioButton2.setSelected(true);
jTextField5.setText(saa[i][6]);
}
}
/**
* This method initializes jPanel3
*
* @return javax.swing.JPanel
*/
private JPanel getJPanel3() {
if (jPanel3 == null) {
FlowLayout flowLayout = new FlowLayout();
flowLayout.setAlignment(java.awt.FlowLayout.LEFT);
jPanel3 = new JPanel();
jPanel3.setBorder(javax.swing.BorderFactory.createEtchedBorder(javax.swing.border.EtchedBorder.RAISED));
jPanel3.setLayout(flowLayout);
jPanel3.setPreferredSize(new java.awt.Dimension(600,100));
jPanel3.add(getJCheckBox(), null);
jPanel3.add(getJScrollPane1(), null);
jPanel3.add(getJButton(), null);
}
return jPanel3;
}
/**
* This method initializes jCheckBox
*
* @return javax.swing.JCheckBox
*/
private JCheckBox getJCheckBox() {
if (jCheckBox == null) {
jCheckBox = new JCheckBox();
jCheckBox.setText("SKU Enable");
jCheckBox.addItemListener(new java.awt.event.ItemListener() {
public void itemStateChanged(java.awt.event.ItemEvent e) {
jTable1.setEnabled(jCheckBox.isSelected());
}
});
}
return jCheckBox;
}
/**
* This method initializes jPanel4
*
* @return javax.swing.JPanel
*/
private JPanel getJPanel4() {
if (jPanel4 == null) {
jLabel5 = new JLabel();
jLabel5.setPreferredSize(new java.awt.Dimension(80,20));
jLabel5.setText("VPD Offset");
jLabel4 = new JLabel();
jLabel4.setPreferredSize(new java.awt.Dimension(100,20));
jLabel4.setText("HII Default Value");
jLabel3 = new JLabel();
jLabel3.setText("Variable Offset");
jLabel3.setPreferredSize(new java.awt.Dimension(90,20));
jLabel2 = new JLabel();
jLabel2.setText(" ");
jLabel1 = new JLabel();
jLabel1.setText("Variable GUID");
jLabel1.setPreferredSize(new java.awt.Dimension(100,20));
jLabel = new JLabel();
jLabel.setText("Variable Name");
jLabel.setToolTipText("");
jLabel.setPreferredSize(new java.awt.Dimension(90,20));
FlowLayout flowLayout1 = new FlowLayout();
flowLayout1.setAlignment(java.awt.FlowLayout.LEFT);
jPanel4 = new JPanel();
jPanel4.setBorder(javax.swing.BorderFactory.createEtchedBorder(javax.swing.border.EtchedBorder.LOWERED));
jPanel4.setLayout(flowLayout1);
jPanel4.setPreferredSize(new java.awt.Dimension(600,120));
jPanel4.add(getJRadioButton(), null);
jPanel4.add(jLabel, null);
jPanel4.add(getJTextField(), null);
jPanel4.add(jLabel1, null);
jPanel4.add(getJTextField1(), null);
jPanel4.add(jLabel2, null);
jPanel4.add(jLabel3, null);
jPanel4.add(getJTextField2(), null);
jPanel4.add(jLabel4, null);
jPanel4.add(getJTextField3(), null);
jPanel4.add(getJRadioButton1(), null);
jPanel4.add(jLabel5, null);
jPanel4.add(getJTextField4(), null);
jLabel6 = new JLabel();
jLabel6.setText(" ");
jPanel4.add(jLabel6, null);
jLabel.setEnabled(false);
jLabel1.setEnabled(false);
jLabel4.setEnabled(false);
jLabel3.setEnabled(false);
jLabel5.setEnabled(false);
jPanel4.add(getJRadioButton2(), null);
jPanel4.add(getJTextField5(), null);
bg.add(jRadioButton);
bg.add(jRadioButton1);
}
return jPanel4;
}
/**
* This method initializes jRadioButton
*
* @return javax.swing.JRadioButton
*/
private JRadioButton getJRadioButton() {
if (jRadioButton == null) {
jRadioButton = new JRadioButton();
jRadioButton.setText("HII Enable");
jRadioButton.addItemListener(new java.awt.event.ItemListener() {
public void itemStateChanged(java.awt.event.ItemEvent e) {
boolean selected = jRadioButton.isSelected();
jLabel.setEnabled(selected);
jLabel1.setEnabled(selected);
jLabel2.setEnabled(selected);
jLabel3.setEnabled(selected);
jLabel4.setEnabled(selected);
jTextField.setEnabled(selected);
jTextField1.setEnabled(selected);
jTextField2.setEnabled(selected);
jTextField3.setEnabled(selected);
}
});
}
return jRadioButton;
}
/**
* This method initializes jRadioButton1
*
* @return javax.swing.JRadioButton
*/
private JRadioButton getJRadioButton1() {
if (jRadioButton1 == null) {
jRadioButton1 = new JRadioButton();
jRadioButton1.setText("VPD Enable");
jRadioButton1.addItemListener(new java.awt.event.ItemListener() {
public void itemStateChanged(java.awt.event.ItemEvent e) {
boolean selected = jRadioButton1.isSelected();
jTextField4.setEnabled(selected);
jLabel5.setEnabled(selected);
}
});
}
return jRadioButton1;
}
/**
* This method initializes jScrollPane1
*
* @return javax.swing.JScrollPane
*/
private JScrollPane getJScrollPane1() {
if (jScrollPane1 == null) {
jScrollPane1 = new JScrollPane();
jScrollPane1.setPreferredSize(new java.awt.Dimension(300,80));
jScrollPane1.setViewportView(getJTable1());
}
return jScrollPane1;
}
/**
* This method initializes jTable1
*
* @return javax.swing.JTable
*/
private JTable getJTable1() {
if (jTable1 == null) {
model1 = new DynPcdTableModel();
jTable1 = new JTable(model1);
model1.addColumn("SKU ID");
model1.addColumn("SKU Name");
jTable1.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
jTable1.getSelectionModel().addListSelectionListener(new ListSelectionListener(){
public void valueChanged(ListSelectionEvent e) {
if (jTable.getSelectedRow() < 0) {
return;
}
if (e.getValueIsAdjusting()){
return;
}
ListSelectionModel lsm = (ListSelectionModel)e.getSource();
if (lsm.isSelectionEmpty()) {
return;
}
else{
int selected = lsm.getMinSelectionIndex();
}
}
});
}
return jTable1;
}
/**
* This method initializes jButton
*
* @return javax.swing.JButton
*/
private JButton getJButton() {
if (jButton == null) {
jButton = new JButton();
jButton.setPreferredSize(new java.awt.Dimension(180,20));
jButton.setText(" Update SKU Information");
jButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent e) {
int pcdSelected = jTable.getSelectedRow();
if (pcdSelected < 0) {
return;
}
updateSkuInfo(pcdSelected);
}
});
}
return jButton;
}
private void updateSkuInfo (int pcdSelected) {
int skuCount = ffc.getDynamicPcdSkuInfoCount(pcdSelected);
String varName = null;
String varGuid = null;
String varOffset = null;
String hiiDefault = null;
String value = null;
String vpdOffset = null;
if (jRadioButton.isSelected()) {
varName = jTextField.getText();
varGuid = jTextField1.getText();
varOffset = jTextField2.getText();
hiiDefault = jTextField3.getText();
}
if (jRadioButton1.isSelected()) {
vpdOffset = jTextField4.getText();
}
if (jRadioButton2.isSelected()) {
value = jTextField5.getText();
}
//
// SKU disabled. only modify data for default SKU.
//
if (!jCheckBox.isSelected()) {
if (true) {
ffc.removeDynamicPcdBuildDataSkuInfo(pcdSelected);
if (jRadioButton.isSelected()) {
ffc.genDynamicPcdBuildDataSkuInfo("0", varName, varGuid, varOffset, hiiDefault, null, null, pcdSelected);
}
else if (jRadioButton1.isSelected()){
ffc.genDynamicPcdBuildDataSkuInfo("0", null, null, null, null, vpdOffset, null, pcdSelected);
}
else{
ffc.genDynamicPcdBuildDataSkuInfo("0", null, null, null, null, null, value, pcdSelected);
}
}
}
//
// SKU Enabled, need add data to all SKUs.
//
if (jCheckBox.isSelected()) {
if (skuCount == 1) {
for (int i = 1; i < jTable1.getRowCount(); ++i) {
ffc.genDynamicPcdBuildDataSkuInfo(jTable1.getValueAt(i, 0)+"", varName, varGuid, varOffset, hiiDefault, vpdOffset, value, pcdSelected);
}
}
else {
int row = jTable1.getSelectedRow();
if (row < 0) {
return;
}
ffc.updateDynamicPcdBuildDataSkuInfo(jTable1.getValueAt(row, 0)+"", varName, varGuid, varOffset, hiiDefault, vpdOffset, value, pcdSelected);
}
}
}
/**
* This method initializes jTextField
*
* @return javax.swing.JTextField
*/
private JTextField getJTextField() {
if (jTextField == null) {
jTextField = new JTextField();
jTextField.setPreferredSize(new java.awt.Dimension(150,20));
jTextField.setEnabled(false);
}
return jTextField;
}
/**
* This method initializes jTextField1
*
* @return javax.swing.JTextField
*/
private JTextField getJTextField1() {
if (jTextField1 == null) {
jTextField1 = new JTextField();
jTextField1.setPreferredSize(new java.awt.Dimension(150,20));
jTextField1.setEnabled(false);
}
return jTextField1;
}
/**
* This method initializes jTextField2
*
* @return javax.swing.JTextField
*/
private JTextField getJTextField2() {
if (jTextField2 == null) {
jTextField2 = new JTextField();
jTextField2.setPreferredSize(new java.awt.Dimension(150,20));
jTextField2.setEnabled(false);
}
return jTextField2;
}
/**
* This method initializes jTextField3
*
* @return javax.swing.JTextField
*/
private JTextField getJTextField3() {
if (jTextField3 == null) {
jTextField3 = new JTextField();
jTextField3.setPreferredSize(new java.awt.Dimension(150,20));
jTextField3.setEnabled(false);
}
return jTextField3;
}
/**
* This method initializes jTextField4
*
* @return javax.swing.JTextField
*/
private JTextField getJTextField4() {
if (jTextField4 == null) {
jTextField4 = new JTextField();
jTextField4.setPreferredSize(new java.awt.Dimension(150,20));
jTextField4.setEnabled(false);
}
return jTextField4;
}
/**
* This method initializes jTextField5
*
* @return javax.swing.JTextField
*/
private JTextField getJTextField5() {
if (jTextField5 == null) {
jTextField5 = new JTextField();
jTextField5.setPreferredSize(new java.awt.Dimension(150,20));
}
return jTextField5;
}
/**
* This method initializes jRadioButton2
*
* @return javax.swing.JRadioButton
*/
private JRadioButton getJRadioButton2() {
if (jRadioButton2 == null) {
jRadioButton2 = new JRadioButton();
jRadioButton2.setText("Default PCD Value");
jRadioButton2.setSelected(true);
jRadioButton2.setPreferredSize(new java.awt.Dimension(175,20));
jRadioButton2.addItemListener(new java.awt.event.ItemListener() {
public void itemStateChanged(java.awt.event.ItemEvent e) {
jTextField5.setEnabled(jRadioButton2.isSelected());
}
});
bg.add(jRadioButton2);
}
return jRadioButton2;
}
} // @jve:decl-index=0:visual-constraint="10,10"
class DynPcdTableModel extends DefaultTableModel {
public boolean isCellEditable(int row, int col) {
return false;
}
}

View File

@@ -0,0 +1,438 @@
package org.tianocore.frameworkwizard.platform.ui;
import java.awt.BorderLayout;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JDialog;
import javax.swing.JSplitPane;
import javax.swing.JLabel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JButton;
import javax.swing.ListSelectionModel;
import javax.swing.table.DefaultTableModel;
import org.tianocore.PlatformSurfaceAreaDocument;
import org.tianocore.frameworkwizard.common.ui.IInternalFrame;
import org.tianocore.frameworkwizard.platform.ui.global.GlobalData;
import org.tianocore.frameworkwizard.platform.ui.id.ModuleIdentification;
import org.tianocore.frameworkwizard.platform.ui.id.PackageIdentification;
import java.awt.FlowLayout;
import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
public class FpdFrameworkModules extends IInternalFrame {
static JFrame frame;
private JSplitPane jSplitPane = null;
private JPanel jPanel = null;
private JPanel jPanel1 = null;
private JLabel jLabel = null;
private JScrollPane jScrollPane = null;
private JTable jTable = null;
private JPanel jPanel2 = null;
private JButton jButton = null;
private JLabel jLabel1 = null;
private JPanel jPanel3 = null;
private JScrollPane jScrollPane1 = null;
private JTable jTable1 = null;
private JButton jButton1 = null;
private JButton jButton2 = null;
private NonEditableTableModel model = null;
private NonEditableTableModel model1 = null;
private FpdModuleSA settingDlg = null;
private FpdFileContents ffc = null;
private Map<String, String> fpdMsa = null;
private ArrayList<ModuleIdentification> miList = null;
/**
* This method initializes jSplitPane
*
* @return javax.swing.JSplitPane
*/
private JSplitPane getJSplitPane() {
if (jSplitPane == null) {
jSplitPane = new JSplitPane();
jSplitPane.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT);
jSplitPane.setDividerLocation(250);
jSplitPane.setBottomComponent(getJPanel1());
jSplitPane.setTopComponent(getJPanel());
}
return jSplitPane;
}
/**
* This method initializes jPanel
*
* @return javax.swing.JPanel
*/
private JPanel getJPanel() {
if (jPanel == null) {
jLabel = new JLabel();
jLabel.setText("Modules in Workspace");
jPanel = new JPanel();
jPanel.setLayout(new BorderLayout());
jPanel.add(jLabel, java.awt.BorderLayout.NORTH);
jPanel.add(getJScrollPane(), java.awt.BorderLayout.CENTER);
jPanel.add(getJPanel2(), java.awt.BorderLayout.SOUTH);
}
return jPanel;
}
/**
* This method initializes jPanel1
*
* @return javax.swing.JPanel
*/
private JPanel getJPanel1() {
if (jPanel1 == null) {
jLabel1 = new JLabel();
jLabel1.setText("Modules Added");
jPanel1 = new JPanel();
jPanel1.setLayout(new BorderLayout());
jPanel1.add(jLabel1, java.awt.BorderLayout.NORTH);
jPanel1.add(getJPanel3(), java.awt.BorderLayout.SOUTH);
jPanel1.add(getJScrollPane1(), java.awt.BorderLayout.CENTER);
}
return jPanel1;
}
/**
* This method initializes jScrollPane
*
* @return javax.swing.JScrollPane
*/
private JScrollPane getJScrollPane() {
if (jScrollPane == null) {
jScrollPane = new JScrollPane();
jScrollPane.setPreferredSize(new java.awt.Dimension(600,200));
jScrollPane.setViewportView(getJTable());
}
return jScrollPane;
}
/**
* This method initializes jTable
*
* @return javax.swing.JTable
*/
private JTable getJTable() {
if (jTable == null) {
model = new NonEditableTableModel();
jTable = new JTable(model);
model.addColumn("ModuleName");
model.addColumn("ModuleGUID");
model.addColumn("ModuleVersion");
model.addColumn("PackageGUID");
model.addColumn("PackageVersion");
jTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
}
return jTable;
}
/**
* This method initializes jPanel2
*
* @return javax.swing.JPanel
*/
private JPanel getJPanel2() {
if (jPanel2 == null) {
FlowLayout flowLayout = new FlowLayout();
flowLayout.setAlignment(java.awt.FlowLayout.RIGHT);
jPanel2 = new JPanel();
jPanel2.setLayout(flowLayout);
jPanel2.add(getJButton(), null);
}
return jPanel2;
}
/**
* This method initializes jButton
*
* @return javax.swing.JButton
*/
private JButton getJButton() {
if (jButton == null) {
jButton = new JButton();
jButton.setPreferredSize(new java.awt.Dimension(130,20));
jButton.setText("Add a Module");
jButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent e) {
int selectedRow = jTable.getSelectedRow();
if (selectedRow < 0){
return;
}
String mg = (String)model.getValueAt(selectedRow, 1);
String mv = (String)model.getValueAt(selectedRow, 2);
String pg = (String)model.getValueAt(selectedRow, 3);
String pv = (String)model.getValueAt(selectedRow, 4);
if (fpdMsa.containsKey(mg + mv + pg + pv)) {
JOptionPane.showMessageDialog(frame, "This Module Already Added.");
return;
}
//ToDo put Arch instead of null
fpdMsa.put(mg + mv + pg + pv, null);
String[] row = {" ", mg, mv, pg, pv};
if (getModuleId(mg + " " + mv + " " + pg + " " + pv) != null) {
row[0] = getModuleId(mg + " " + mv + " " + pg + " " + pv).getName();
}
model1.addRow(row);
ffc.addFrameworkModulesPcdBuildDefs(miList.get(selectedRow), null);
}
});
}
return jButton;
}
/**
* This method initializes jPanel3
*
* @return javax.swing.JPanel
*/
private JPanel getJPanel3() {
if (jPanel3 == null) {
FlowLayout flowLayout1 = new FlowLayout();
flowLayout1.setAlignment(java.awt.FlowLayout.RIGHT);
jPanel3 = new JPanel();
jPanel3.setLayout(flowLayout1);
jPanel3.add(getJButton1(), null);
jPanel3.add(getJButton2(), null);
}
return jPanel3;
}
/**
* This method initializes jScrollPane1
*
* @return javax.swing.JScrollPane
*/
private JScrollPane getJScrollPane1() {
if (jScrollPane1 == null) {
jScrollPane1 = new JScrollPane();
jScrollPane1.setPreferredSize(new java.awt.Dimension(453,200));
jScrollPane1.setViewportView(getJTable1());
}
return jScrollPane1;
}
/**
* This method initializes jTable1
*
* @return javax.swing.JTable
*/
private JTable getJTable1() {
if (jTable1 == null) {
model1 = new NonEditableTableModel();
jTable1 = new JTable(model1);
model1.addColumn("ModuleName");
model1.addColumn("ModuleGUID");
model1.addColumn("ModuleVersion");
model1.addColumn("PackageGUID");
model1.addColumn("PackageVersion");
// model1.addColumn("SupportedArch");
jTable1.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
}
return jTable1;
}
/**
* This method initializes jButton1
*
* @return javax.swing.JButton
*/
private JButton getJButton1() {
if (jButton1 == null) {
jButton1 = new JButton();
jButton1.setPreferredSize(new java.awt.Dimension(130,20));
jButton1.setText("Settings");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent e) {
int selectedRow = jTable1.getSelectedRow();
if (selectedRow < 0){
return;
}
if (settingDlg == null) {
settingDlg = new FpdModuleSA(ffc);
}
String mg = model1.getValueAt(selectedRow, 1).toString();
String mv = model1.getValueAt(selectedRow, 2).toString();
String pg = model1.getValueAt(selectedRow, 3).toString();
String pv = model1.getValueAt(selectedRow, 4).toString();
settingDlg.setKey(mg + " " + mv + " " + pg + " " + pv);
settingDlg.setVisible(true);
}
});
}
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(130,20));
jButton2.setText("Remove Module");
jButton2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent e) {
int selectedRow = jTable1.getSelectedRow();
if (selectedRow < 0){
return;
}
String mg = model1.getValueAt(selectedRow, 1).toString();
String mv = model1.getValueAt(selectedRow, 2).toString();
String pg = model1.getValueAt(selectedRow, 3).toString();
String pv = model1.getValueAt(selectedRow, 4).toString();
model1.removeRow(selectedRow);
fpdMsa.remove(mg+mv+pg+pv);
ffc.removeModuleSA(selectedRow);
}
});
}
return jButton2;
}
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
new FpdFrameworkModules().setVisible(true);
}
/**
* This is the default constructor
*/
public FpdFrameworkModules() {
super();
initialize();
}
public FpdFrameworkModules(PlatformSurfaceAreaDocument.PlatformSurfaceArea fpd){
this();
init(fpd);
}
private void init(PlatformSurfaceAreaDocument.PlatformSurfaceArea fpd) {
try {
GlobalData.initInfo("Tools" + File.separator + "Conf" + File.separator + "FrameworkDatabase.db", System.getenv("WORKSPACE"));
}
catch(Exception e){
JOptionPane.showMessageDialog(frame, "FrameworkDatabase Corrupted.");
}
if (ffc == null){
ffc = new FpdFileContents(fpd);
ffc.initDynPcdMap();
}
if (fpdMsa == null) {
fpdMsa = new HashMap<String, String>();
}
if (ffc.getFrameworkModulesCount() > 0) {
String[][] saa = new String[ffc.getFrameworkModulesCount()][5];
ffc.getFrameworkModulesInfo(saa);
for (int i = 0; i < saa.length; ++i) {
if (getModuleId(saa[i][1]+ " "+saa[i][2]+" "+saa[i][3]+" "+saa[i][4]) != null) {
saa[i][0] = getModuleId(saa[i][1]+ " "+saa[i][2]+" "+saa[i][3]+" "+saa[i][4]).getName();
}
model1.addRow(saa[i]);
fpdMsa.put(saa[i][1]+saa[i][2]+saa[i][3]+saa[i][4], saa[i][0]);
}
}
showAllModules();
}
private void showAllModules() {
if (miList == null) {
miList = new ArrayList<ModuleIdentification>();
}
Set<PackageIdentification> spi = GlobalData.getPackageList();
Iterator ispi = spi.iterator();
while(ispi.hasNext()) {
PackageIdentification pi = (PackageIdentification)ispi.next();
String[] s = {"", "", "", "", ""};
s[3] = pi.getGuid();
s[4] = pi.getVersion();
Set<ModuleIdentification> smi = GlobalData.getModules(pi);
Iterator ismi = smi.iterator();
while(ismi.hasNext()) {
ModuleIdentification mi = (ModuleIdentification)ismi.next();
s[0] = mi.getName();
s[1] = mi.getGuid();
s[2] = mi.getVersion();
model.addRow(s);
miList.add(mi);
}
}
}
/**
* This method initializes this
*
* @return void
*/
private void initialize() {
this.setSize(633, 533);
this.setTitle("Framework Modules");
this.setContentPane(getJSplitPane());
this.setVisible(true);
}
private ModuleIdentification getModuleId(String key){
//
// Get ModuleGuid, ModuleVersion, PackageGuid, PackageVersion into string array.
//
String[] keyPart = key.split(" ");
Set<PackageIdentification> spi = GlobalData.getPackageList();
Iterator ispi = spi.iterator();
while(ispi.hasNext()) {
PackageIdentification pi = (PackageIdentification)ispi.next();
if ( !pi.getGuid().equals(keyPart[2]) || !pi.getVersion().equals(keyPart[3])){
continue;
}
Set<ModuleIdentification> smi = GlobalData.getModules(pi);
Iterator ismi = smi.iterator();
while(ismi.hasNext()) {
ModuleIdentification mi = (ModuleIdentification)ismi.next();
if (mi.getGuid().equals(keyPart[0]) && mi.getVersion().equals(keyPart[1])){
return mi;
}
}
}
return null;
}
} // @jve:decl-index=0:visual-constraint="10,10"
class NonEditableTableModel extends DefaultTableModel {
public boolean isCellEditable(int row, int col) {
return false;
}
}

View File

@@ -0,0 +1,687 @@
/** @file
The file is used to create, update FpdHeader of Fpd 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.frameworkwizard.platform.ui;
import java.awt.Dimension;
import java.awt.Rectangle;
import java.awt.event.ActionEvent;
import java.awt.event.ComponentEvent;
import java.awt.event.FocusAdapter;
import java.awt.event.FocusEvent;
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.LicenseDocument;
import org.tianocore.PlatformSurfaceAreaDocument;
import org.tianocore.PlatformHeaderDocument;
import org.tianocore.frameworkwizard.common.DataType;
import org.tianocore.frameworkwizard.common.DataValidation;
import org.tianocore.frameworkwizard.common.Log;
import org.tianocore.frameworkwizard.common.Tools;
import org.tianocore.frameworkwizard.common.ui.IInternalFrame;
import org.tianocore.frameworkwizard.common.ui.StarLabel;
/**
The class is used to create, update FpdHeader of Fpd file
It extends IInternalFrame
@since PackageEditor 1.0
**/
public class FpdHeader extends IInternalFrame {
///
/// Define class Serial Version UID
///
private static final long serialVersionUID = -8152099582923006900L;
//
//Define class members
//
private JPanel jContentPane = null; // @jve:decl-index=0:visual-constraint="10,53"
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 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 JTextField jTextFieldCopyright = null;
private JLabel jLabel = null;
private JTextField jTextField = null;
private FpdFileContents ffc = 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));
jTextFieldBaseName.setPreferredSize(new java.awt.Dimension(320,20));
jTextFieldBaseName.addFocusListener(new FocusAdapter(){
public void focusLost(FocusEvent e) {
ffc.setFpdHdrPlatformName(jTextFieldBaseName.getText());
}
});
}
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));
jTextFieldGuid.setPreferredSize(new java.awt.Dimension(250,20));
jTextFieldGuid.addFocusListener(new FocusAdapter(){
public void focusLost(FocusEvent e) {
ffc.setFpdHdrGuidValue(jTextFieldGuid.getText());
}
});
}
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));
jTextFieldVersion.setPreferredSize(new java.awt.Dimension(320,20));
jTextFieldVersion.addFocusListener(new FocusAdapter(){
public void focusLost(FocusEvent e) {
ffc.setFpdHdrVer(jTextFieldVersion.getText());
}
});
}
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.setPreferredSize(new java.awt.Dimension(317,77));
jTextAreaLicense.setLineWrap(true);
jTextAreaLicense.addFocusListener(new FocusAdapter(){
public void focusLost(FocusEvent e) {
ffc.setFpdHdrLicense(jTextAreaLicense.getText());
}
});
}
return jTextAreaLicense;
}
/**
This method initializes jTextAreaDescription
@return javax.swing.JTextArea jTextAreaDescription
**/
private JTextArea getJTextAreaDescription() {
if (jTextAreaDescription == null) {
jTextAreaDescription = new JTextArea();
jTextAreaDescription.setLineWrap(true);
jTextAreaDescription.setPreferredSize(new java.awt.Dimension(317,77));
jTextAreaDescription.addFocusListener(new FocusAdapter(){
public void focusLost(FocusEvent e) {
ffc.setFpdHdrDescription(jTextAreaDescription.getText());
}
});
}
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, 305, 320, 20));
jTextFieldSpecification.setEditable(false);
jTextFieldSpecification.setPreferredSize(new java.awt.Dimension(320,20));
jTextFieldSpecification.addFocusListener(new FocusAdapter(){
public void focusLost(FocusEvent e) {
ffc.setFpdHdrSpec(jTextFieldSpecification.getText());
}
});
}
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,351,90,20));
jButtonOk.setVisible(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.setText("Cancel");
jButtonCancel.setBounds(new java.awt.Rectangle(390,351,90,20));
jButtonCancel.setVisible(false);
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.setPreferredSize(new java.awt.Dimension(320,80));
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, 220, 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,195,320,20));
jTextFieldAbstract.setPreferredSize(new java.awt.Dimension(320, 20));
jTextFieldAbstract.addFocusListener(new FocusAdapter(){
public void focusLost(FocusEvent e) {
ffc.setFpdHdrAbs(jTextFieldAbstract.getText());
}
});
}
return jTextFieldAbstract;
}
/**
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,330,320, 20));
jTextFieldCopyright.setPreferredSize(new java.awt.Dimension(320,20));
jTextFieldCopyright.addFocusListener(new FocusAdapter(){
public void focusLost(FocusEvent e) {
ffc.setFpdHdrCopyright(jTextFieldCopyright.getText());
}
});
}
return jTextFieldCopyright;
}
/**
* This method initializes jTextField
*
* @return javax.swing.JTextField
*/
private JTextField getJTextField() {
if (jTextField == null) {
jTextField = new JTextField();
jTextField.setBounds(new java.awt.Rectangle(160,170,320,20));
jTextField.setPreferredSize(new Dimension(320, 20));
jTextField.addFocusListener(new FocusAdapter(){
public void focusLost(FocusEvent e){
ffc.setFpdHdrLicense(jTextAreaLicense.getText());
ffc.setFpdHdrUrl(jTextField.getText());
}
});
}
return jTextField;
}
public static void main(String[] args) {
new FpdHeader().setVisible(true);
}
/**
This is the default constructor
**/
public FpdHeader() {
super();
init();
this.setVisible(true);
}
/**
This is the override edit constructor
@param inFpdHeader The input data of FpdHeaderDocument.FpdHeader
**/
public FpdHeader(PlatformSurfaceAreaDocument.PlatformSurfaceArea inFpd) {
this();
ffc = new FpdFileContents(inFpd);
init(ffc);
}
/**
This method initializes this
**/
private void init() {
//this.setSize(500, 515);
this.setContentPane(getJContentPane());
this.setTitle("Package Surface Area Header");
initFrame();
}
/**
This method initializes this
Fill values to all fields if these values are not empty
@param inFpdHeader The input data of FpdHeaderDocument.FpdHeader
**/
private void init(FpdFileContents ffc) {
if (ffc.getFpdHdrPlatformName() != null) {
jTextFieldBaseName.setText(ffc.getFpdHdrPlatformName());
}
if (ffc.getFpdHdrGuidValue() != null) {
jTextFieldGuid.setText(ffc.getFpdHdrGuidValue());
}
if (ffc.getFpdHdrVer() != null) {
jTextFieldVersion.setText(ffc.getFpdHdrVer());
}
if (ffc.getFpdHdrLicense() != null) {
jTextAreaLicense.setText(ffc.getFpdHdrLicense());
}
if (ffc.getFpdHdrUrl() != null) {
jTextField.setText(ffc.getFpdHdrUrl());
}
if (ffc.getFpdHdrCopyright() != null) {
jTextFieldCopyright.setText(ffc.getFpdHdrCopyright());
}
if (ffc.getFpdHdrDescription() != null) {
jTextAreaDescription.setText(ffc.getFpdHdrDescription());
}
if (ffc.getFpdHdrSpec() != null) {
jTextFieldSpecification.setText(ffc.getFpdHdrSpec());
}
}
/**
This method initializes jContentPane
@return javax.swing.JPanel jContentPane
**/
private JPanel getJContentPane() {
if (jContentPane == null) {
jLabel = new JLabel();
jLabel.setBounds(new java.awt.Rectangle(15,170,140,20));
jLabel.setText("URL");
jContentPane = new JPanel();
jContentPane.setLayout(null);
jContentPane.setLocation(new java.awt.Point(0, 0));
jContentPane.setSize(new java.awt.Dimension(500,423));
jLabelAbstract = new JLabel();
jLabelAbstract.setBounds(new java.awt.Rectangle(15, 195, 140, 20));
jLabelAbstract.setText("Abstract");
jLabelSpecification = new JLabel();
jLabelSpecification.setText("Specification");
jLabelSpecification.setBounds(new java.awt.Rectangle(15, 305, 140, 20));
jLabelDescription = new JLabel();
jLabelDescription.setText("Description");
jLabelDescription.setBounds(new java.awt.Rectangle(15, 220, 140, 20));
jLabelCopyright = new JLabel();
jLabelCopyright.setText("Copyright");
jLabelCopyright.setBounds(new java.awt.Rectangle(15, 330, 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("Platform Name");
jLabelBaseName.setBounds(new java.awt.Rectangle(15, 10, 140, 20));
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);
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, 330));
jStarLabel6 = new StarLabel();
jStarLabel6.setLocation(new java.awt.Point(0, 195));
jStarLabel7 = new StarLabel();
jStarLabel7.setLocation(new java.awt.Point(0, 305));
jStarLabel7.setEnabled(false);
jStarLabel8 = new StarLabel();
jStarLabel8.setLocation(new java.awt.Point(0, 220));
jStarLabel9 = new StarLabel();
jStarLabel9.setLocation(new java.awt.Point(0, 280));
jStarLabel9.setVisible(false);
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(getJTextFieldCopyright(), null);
jContentPane.add(jLabel, null);
jContentPane.add(getJTextField(), 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) {
//ToDo: invoke GuidValueEditor
jTextFieldGuid.setText(Tools.generateUuidString());
ffc.setFpdHdrGuidValue(jTextFieldGuid.getText());
}
}
/**
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 Fpd Header
if exists FpdHeader, set the value directly
if not exists FpdHeader, new an instance first
**/
public void save() {
}
/**
This method initializes Package type and Compontent type
**/
private void initFrame() {
}
/* (non-Javadoc)
* @see java.awt.event.ComponentListener#componentResized(java.awt.event.ComponentEvent)
*
* Override componentResized to resize all components when frame's size is changed
*/
public void componentResized(ComponentEvent arg0) {
int intPreferredWidth = 500;
resizeComponentWidth(this.jTextFieldBaseName, this.getWidth(), intPreferredWidth);
resizeComponentWidth(this.jTextFieldGuid, this.getWidth(), intPreferredWidth);
resizeComponentWidth(this.jTextFieldVersion, this.getWidth(), intPreferredWidth);
resizeComponentWidth(this.jScrollPaneLicense, this.getWidth(), intPreferredWidth);
resizeComponentWidth(this.jTextFieldCopyright, this.getWidth(), intPreferredWidth);
resizeComponentWidth(this.jScrollPaneDescription, this.getWidth(), intPreferredWidth);
resizeComponentWidth(this.jTextFieldSpecification, this.getWidth(), intPreferredWidth);
resizeComponentWidth(this.jTextFieldAbstract, this.getWidth(), intPreferredWidth);
relocateComponentX(this.jButtonGenerateGuid, this.getWidth(), jButtonGenerateGuid.getWidth(), 25);
}
}

View File

@@ -0,0 +1,988 @@
package org.tianocore.frameworkwizard.platform.ui;
import java.awt.BorderLayout;
import javax.swing.DefaultCellEditor;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JDialog;
import javax.swing.JTabbedPane;
import javax.swing.JLabel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JTextPane;
import javax.swing.JTextArea;
import javax.swing.JSplitPane;
import javax.swing.JButton;
import javax.swing.ListSelectionModel;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import javax.swing.event.TableModelEvent;
import javax.swing.event.TableModelListener;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableColumn;
import javax.swing.table.TableModel;
import org.apache.xmlbeans.XmlObject;
import org.tianocore.frameworkwizard.platform.ui.global.GlobalData;
import org.tianocore.frameworkwizard.platform.ui.global.SurfaceAreaQuery;
import org.tianocore.frameworkwizard.platform.ui.id.ModuleIdentification;
import org.tianocore.frameworkwizard.platform.ui.id.PackageIdentification;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.ListIterator;
import java.util.Map;
import java.util.Set;
public class FpdModuleSA extends JDialog implements ActionListener {
static JFrame frame;
private JPanel jContentPane = null;
private JTabbedPane jTabbedPane = null;
private JPanel jPanel = null;
private JPanel jPanel1 = null;
private JLabel jLabel = null;
private JScrollPane jScrollPane = null;
private JTable jTable = null;
private JPanel jPanel2 = null;
private JScrollPane jScrollPane1 = null;
private JTextArea jTextArea = null;
private JPanel jPanel3 = null;
private JSplitPane jSplitPane = null;
private JPanel jPanel4 = null;
private JPanel jPanel5 = null;
private JLabel jLabel1 = null;
private JLabel jLabel2 = null;
private JScrollPane jScrollPane2 = null;
private JTable jTable1 = null;
private JScrollPane jScrollPane3 = null;
private JTable jTable2 = null;
private JScrollPane jScrollPane4 = null;
private JTable jTable3 = null;
private JPanel jPanel6 = null;
private JPanel jPanel7 = null;
private JScrollPane jScrollPane5 = null;
private JTextArea jTextArea1 = null;
private JLabel jLabel3 = null;
private JLabel jLabel4 = null;
private JButton jButton = null;
private JButton jButton1 = null;
private JLabel jLabel5 = null;
private JButton jButton2 = null;
private JButton jButton3 = null;
private PartialEditableTableModel model = null;
private LibraryTableModel model1 = null;
private LibraryTableModel model2 = null;
private LibraryTableModel model3 = null;
private FpdFileContents ffc = null;
private String moduleKey = null;
// private int selectedRow = -1;
private HashMap<String, String> instancePreferMap = null;
private HashMap<String, ArrayList<String>> classInstanceMap = null;
private ArrayList<String> classProduced = null;
// private ArrayList<String> classConsumed = null;
private HashMap<String, ArrayList<String>> classConsumed = null;
/**
* This is the default constructor
*/
public FpdModuleSA() {
super();
initialize();
}
public FpdModuleSA(FpdFileContents ffc) {
this();
this.ffc = ffc;
}
public void setKey(String k){
this.moduleKey = k;
}
/**
init will be called each time FpdModuleSA object is to be shown.
@param key Module information.
**/
public void init(String key) {
//
// display pcd for key.
//
model.setRowCount(0);
int pcdCount = ffc.getPcdDataCount(key);
if (pcdCount != 0) {
String[][] saa = new String[pcdCount][6];
ffc.getPcdData(key, saa);
for (int i = 0; i < saa.length; ++i) {
model.addRow(saa[i]);
}
}
//
// display lib instances already selected for key
//
model1.setRowCount(0);
int instanceCount = ffc.getLibraryInstancesCount(key);
if (instanceCount != 0) {
String[][] saa = new String[instanceCount][5];
ffc.getLibraryInstances(key, saa);
for (int i = 0; i < saa.length; ++i) {
if (getModuleId(saa[i][1] + " " + saa[i][2] + " " + saa[i][3] + " " + saa[i][4]) != null) {
saa[i][0] = getModuleId(saa[i][1] + " " + saa[i][2] + " " + saa[i][3] + " " + saa[i][4]).getName();
}
model1.addRow(saa[i]);
}
}
//
// display library classes that need to be resolved. also potential instances for them.
//
resolveLibraryInstances(key);
}
private void resolveLibraryInstances(String key) {
ModuleIdentification mi = getModuleId(key);
PackageIdentification[] depPkgList = null;
try{
Map<String, XmlObject> m = GlobalData.getNativeMsa(mi);
SurfaceAreaQuery.setDoc(m);
//
// Get dependency pkg list into which we will search lib instances.
//
depPkgList = SurfaceAreaQuery.getDependencePkg(null);
//
// Get the lib class consumed, produced by this module itself.
//
String[] classConsumed = SurfaceAreaQuery.getLibraryClasses("ALWAYS_CONSUMED");
if (this.classConsumed == null) {
this.classConsumed = new HashMap<String, ArrayList<String>>();
}
for(int i = 0; i < classConsumed.length; ++i){
ArrayList<String> consumedBy = this.classConsumed.get(classConsumed[i]);
if (consumedBy == null) {
consumedBy = new ArrayList<String>();
}
consumedBy.add(key);
this.classConsumed.put(classConsumed[i], consumedBy);
}
String[] classProduced = SurfaceAreaQuery.getLibraryClasses("ALWAYS_PRODUCED");
if (this.classProduced == null) {
this.classProduced = new ArrayList<String>();
}
for(int i = 0; i < classProduced.length; ++i){
if (!this.classProduced.contains(classProduced[i])){
this.classProduced.add(classProduced[i]);
}
}
//
// Get classes unresolved
//
// Iterator<String> lip = this.classProduced.listIterator();
// while(lip.hasNext()){
// String clsProduced = lip.next();
// this.classConsumed.remove(clsProduced);
//
// }
//
// find potential instances in all dependency pkgs for classes still in classConsumed.
//
if (classInstanceMap == null){
classInstanceMap = new HashMap<String, ArrayList<String>>();
}
Iterator<String> lic = this.classConsumed.keySet().iterator();
while(lic.hasNext()){
String cls = lic.next();
if (this.classProduced.contains(cls) || classInstanceMap.containsKey(cls)) {
continue;
}
ArrayList<String> instances = getInstancesForClass(cls, depPkgList);
if (instances.size() == 0){
JOptionPane.showMessageDialog(frame, "No Applicable Instance for Library Class " +
cls + ", Platform Build will Fail.");
}
classInstanceMap.put(cls, instances);
}
showClassToResolved();
}
catch(Exception e) {
e.printStackTrace();
}
}
private ArrayList<String> getInstancesForClass(String cls, PackageIdentification[] depPkgList) throws Exception{
ArrayList<String> al = new ArrayList<String>();
for (int i = 0; i < depPkgList.length; ++i) {
Set<ModuleIdentification> smi = GlobalData.getModules(depPkgList[i]);
Iterator ismi = smi.iterator();
while(ismi.hasNext()) {
ModuleIdentification mi = (ModuleIdentification)ismi.next();
String[] clsProduced = getClassProduced(mi);
boolean isPotential = false;
for (int j = 0; j < clsProduced.length; ++j) {
if (clsProduced[j] == null) {
continue;
}
if (clsProduced[j].equals(cls)){
isPotential = true;
}
if (classProduced.contains(clsProduced[j])) {
isPotential = false;
break;
}
}
if (isPotential) {
al.add(mi.getGuid() + " " + mi.getVersion() + " " +
depPkgList[i].getGuid() + " " + depPkgList[i].getVersion());
}
}
}
return al;
}
private void removeInstance(String key) {
ModuleIdentification mi = getModuleId(key);
//
// remove pcd information of instance from current ModuleSA
//
ffc.removePcdDataFromLibraryInstance(moduleKey, key);
//
// remove class produced by this instance and add back these produced class to be bound.
//
String[] clsProduced = getClassProduced(mi);
for (int i = 0; i < clsProduced.length; ++i) {
classProduced.remove(clsProduced[i]);
}
//
// remove class consumed by this instance. we do not need to bound it now.
//
String[] clsConsumed = getClassConsumed(mi);
for (int i = 0; i < clsConsumed.length; ++i) {
ArrayList<String> al = classConsumed.get(clsConsumed[i]);
if (al == null ) {
classConsumed.remove(clsConsumed[i]);
continue;
}
al.remove(key);
if (al.size() == 0) {
classConsumed.remove(clsConsumed[i]);
}
}
showClassToResolved();
}
private ModuleIdentification getModuleId(String key){
//
// Get ModuleGuid, ModuleVersion, PackageGuid, PackageVersion into string array.
//
String[] keyPart = key.split(" ");
Set<PackageIdentification> spi = GlobalData.getPackageList();
Iterator ispi = spi.iterator();
while(ispi.hasNext()) {
PackageIdentification pi = (PackageIdentification)ispi.next();
if ( !pi.getGuid().equals(keyPart[2]) || !pi.getVersion().equals(keyPart[3])){
continue;
}
Set<ModuleIdentification> smi = GlobalData.getModules(pi);
Iterator ismi = smi.iterator();
while(ismi.hasNext()) {
ModuleIdentification mi = (ModuleIdentification)ismi.next();
if (mi.getGuid().equals(keyPart[0]) && mi.getVersion().equals(keyPart[1])){
return mi;
}
}
}
return null;
}
private String[] getClassProduced(ModuleIdentification mi){
try{
Map<String, XmlObject> m = GlobalData.getNativeMsa(mi);
SurfaceAreaQuery.setDoc(m);
String[] clsProduced = SurfaceAreaQuery.getLibraryClasses("ALWAYS_PRODUCED");
return clsProduced;
}catch (Exception e) {
e.printStackTrace();
}
return new String[0];
}
private String[] getClassConsumed(ModuleIdentification mi){
String[] clsConsumed = null;
try{
Map<String, XmlObject> m = GlobalData.getNativeMsa(mi);
SurfaceAreaQuery.setDoc(m);
clsConsumed = SurfaceAreaQuery.getLibraryClasses("ALWAYS_CONSUMED");
}catch (Exception e) {
e.printStackTrace();
}
return clsConsumed;
}
private void showClassToResolved(){
model2.setRowCount(0);
if (classConsumed.size() == 0) {
return;
}
Iterator<String> li = classConsumed.keySet().iterator();
while(li.hasNext()){
String[] s = {li.next()};
if (classConsumed.get(s[0]) == null) {
continue;
}
if (classConsumed.get(s[0]).size() == 0) {
continue;
}
if (!classProduced.contains(s[0])){
model2.addRow(s);
}
}
model3.setRowCount(0);
}
/**
* This method initializes this
*
* @return void
*/
private void initialize() {
this.setSize(664, 515);
this.setModal(true);
this.setTitle("Module Settings");
this.setContentPane(getJContentPane());
}
/**
* This method initializes jContentPane
*
* @return javax.swing.JPanel
*/
private JPanel getJContentPane() {
if (jContentPane == null) {
jContentPane = new JPanel();
jContentPane.setLayout(new BorderLayout());
jContentPane.add(getJTabbedPane(), java.awt.BorderLayout.CENTER);
jContentPane.add(getJPanel3(), java.awt.BorderLayout.SOUTH);
}
return jContentPane;
}
/**
* This method initializes jTabbedPane
*
* @return javax.swing.JTabbedPane
*/
private JTabbedPane getJTabbedPane() {
if (jTabbedPane == null) {
jTabbedPane = new JTabbedPane();
jTabbedPane.addTab("PCD Build Definition", null, getJPanel(), null);
jTabbedPane.addTab("Libraries", null, getJPanel1(), null);
}
return jTabbedPane;
}
/**
* This method initializes jPanel
*
* @return javax.swing.JPanel
*/
private JPanel getJPanel() {
if (jPanel == null) {
jLabel = new JLabel();
jLabel.setText("PcdData");
jPanel = new JPanel();
jPanel.setLayout(new BorderLayout());
jPanel.add(jLabel, java.awt.BorderLayout.NORTH);
jPanel.add(getJScrollPane(), java.awt.BorderLayout.CENTER);
jPanel.add(getJPanel2(), java.awt.BorderLayout.SOUTH);
jPanel.addComponentListener(new java.awt.event.ComponentAdapter() {
public void componentShown(java.awt.event.ComponentEvent e) {
init(moduleKey);
}
});
}
return jPanel;
}
/**
* This method initializes jPanel1
*
* @return javax.swing.JPanel
*/
private JPanel getJPanel1() {
if (jPanel1 == null) {
jPanel1 = new JPanel();
jPanel1.setLayout(new BorderLayout());
jPanel1.add(getJSplitPane(), java.awt.BorderLayout.NORTH);
jPanel1.add(getJPanel6(), java.awt.BorderLayout.SOUTH);
jPanel1.add(getJPanel7(), java.awt.BorderLayout.CENTER);
jPanel1.addComponentListener(new java.awt.event.ComponentAdapter() {
public void componentShown(java.awt.event.ComponentEvent e) {
}
});
}
return jPanel1;
}
/**
* This method initializes jScrollPane
*
* @return javax.swing.JScrollPane
*/
private JScrollPane getJScrollPane() {
if (jScrollPane == null) {
jScrollPane = new JScrollPane();
jScrollPane.setViewportView(getJTable());
}
return jScrollPane;
}
/**
* This method initializes jTable
*
* @return javax.swing.JTable
*/
private JTable getJTable() {
if (jTable == null) {
model = new PartialEditableTableModel();
jTable = new JTable(model);
model.addColumn("CName");
model.addColumn("TokenSpaceGUID");
model.addColumn("ItemType");
model.addColumn("Token");
model.addColumn("DataType");
model.addColumn("DefaultValue");
jTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
jTable.getSelectionModel().addListSelectionListener(new ListSelectionListener(){
public void valueChanged(ListSelectionEvent e) {
int selectedRow = -1;
if (e.getValueIsAdjusting()){
return;
}
ListSelectionModel lsm = (ListSelectionModel)e.getSource();
if (lsm.isSelectionEmpty()) {
return;
}
else{
selectedRow = lsm.getMinSelectionIndex();
}
}
});
jTable.getModel().addTableModelListener(new TableModelListener() {
public void tableChanged(TableModelEvent arg0) {
// TODO Auto-generated method stub
int row = arg0.getFirstRow();
TableModel m = (TableModel)arg0.getSource();
if (arg0.getType() == TableModelEvent.INSERT) {
//
// Set combo box values for item type according to pcd values added.
//
}
if (arg0.getType() == TableModelEvent.UPDATE){
//ToDo Data Validition check.
}
}
});
}
return jTable;
}
/**
* This method initializes jPanel2
*
* @return javax.swing.JPanel
*/
private JPanel getJPanel2() {
if (jPanel2 == null) {
jLabel5 = new JLabel();
jLabel5.setText("PCD Description");
jPanel2 = new JPanel();
jPanel2.add(jLabel5, null);
jPanel2.add(getJScrollPane1(), null);
}
return jPanel2;
}
/**
* This method initializes jScrollPane1
*
* @return javax.swing.JScrollPane
*/
private JScrollPane getJScrollPane1() {
if (jScrollPane1 == null) {
jScrollPane1 = new JScrollPane();
jScrollPane1.setPreferredSize(new java.awt.Dimension(500,100));
jScrollPane1.setViewportView(getJTextArea());
}
return jScrollPane1;
}
/**
* This method initializes jTextArea
*
* @return javax.swing.JTextArea
*/
private JTextArea getJTextArea() {
if (jTextArea == null) {
jTextArea = new JTextArea();
jTextArea.setEditable(false);
}
return jTextArea;
}
/**
* This method initializes jPanel3
*
* @return javax.swing.JPanel
*/
private JPanel getJPanel3() {
if (jPanel3 == null) {
FlowLayout flowLayout = new FlowLayout();
flowLayout.setAlignment(java.awt.FlowLayout.RIGHT);
jPanel3 = new JPanel();
jPanel3.setLayout(flowLayout);
jPanel3.add(getJButton2(), null);
jPanel3.add(getJButton3(), null);
}
return jPanel3;
}
/**
* This method initializes jSplitPane
*
* @return javax.swing.JSplitPane
*/
private JSplitPane getJSplitPane() {
if (jSplitPane == null) {
jSplitPane = new JSplitPane();
jSplitPane.setDividerLocation(200);
jSplitPane.setLeftComponent(getJPanel4());
jSplitPane.setRightComponent(getJPanel5());
jSplitPane.setPreferredSize(new java.awt.Dimension(202,200));
}
return jSplitPane;
}
/**
* This method initializes jPanel4
*
* @return javax.swing.JPanel
*/
private JPanel getJPanel4() {
if (jPanel4 == null) {
jLabel1 = new JLabel();
jLabel1.setText("Library Classes Consumed");
jPanel4 = new JPanel();
jPanel4.add(jLabel1, null);
jPanel4.add(getJScrollPane3(), null);
}
return jPanel4;
}
/**
* This method initializes jPanel5
*
* @return javax.swing.JPanel
*/
private JPanel getJPanel5() {
if (jPanel5 == null) {
jLabel2 = new JLabel();
jLabel2.setText("Instances Available");
jPanel5 = new JPanel();
jPanel5.add(jLabel2, null);
jPanel5.add(getJScrollPane4(), null);
}
return jPanel5;
}
/**
* This method initializes jScrollPane2
*
* @return javax.swing.JScrollPane
*/
private JScrollPane getJScrollPane2() {
if (jScrollPane2 == null) {
jScrollPane2 = new JScrollPane();
jScrollPane2.setPreferredSize(new java.awt.Dimension(453,150));
jScrollPane2.setViewportView(getJTable1());
}
return jScrollPane2;
}
/**
* This method initializes jTable1
*
* @return javax.swing.JTable
*/
private JTable getJTable1() {
if (jTable1 == null) {
model1 = new LibraryTableModel();
model1.addColumn("Name");
model1.addColumn("ModuleGUID");
model1.addColumn("ModuleVersion");
model1.addColumn("PackageGUID");
model1.addColumn("PackageVersion");
jTable1 = new JTable(model1);
jTable1.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
jTable1.getSelectionModel().addListSelectionListener(new ListSelectionListener(){
public void valueChanged(ListSelectionEvent e) {
int selectedRow1 = -1;
if (e.getValueIsAdjusting()){
return;
}
ListSelectionModel lsm = (ListSelectionModel)e.getSource();
if (lsm.isSelectionEmpty()) {
return;
}
else{
selectedRow1 = lsm.getMinSelectionIndex();
}
}
});
}
return jTable1;
}
/**
* This method initializes jScrollPane3
*
* @return javax.swing.JScrollPane
*/
private JScrollPane getJScrollPane3() {
if (jScrollPane3 == null) {
jScrollPane3 = new JScrollPane();
jScrollPane3.setPreferredSize(new java.awt.Dimension(200,170));
jScrollPane3.setViewportView(getJTable2());
}
return jScrollPane3;
}
/**
* This method initializes jTable2
*
* @return javax.swing.JTable
*/
private JTable getJTable2() {
if (jTable2 == null) {
model2 = new LibraryTableModel();
model2.addColumn("LibraryClass");
jTable2 = new JTable(model2);
jTable2.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
jTable2.getSelectionModel().addListSelectionListener(new ListSelectionListener(){
public void valueChanged(ListSelectionEvent e) {
if (e.getValueIsAdjusting()){
return;
}
ListSelectionModel lsm = (ListSelectionModel)e.getSource();
if (lsm.isSelectionEmpty()) {
return;
}
else{
int selectedRow2 = lsm.getMinSelectionIndex();
if (selectedRow2 < 0) {
return;
}
//
// display potential lib instances according to class selection
//
model3.setRowCount(0);
String cls = model2.getValueAt(selectedRow2, 0).toString();
ArrayList<String> al = classInstanceMap.get(cls);
ListIterator<String> li = al.listIterator();
while(li.hasNext()) {
String instance = li.next();
String[] s = {"", "", "", "", ""};
if (getModuleId(instance) != null) {
s[0] = getModuleId(instance).getName();
}
String[] instancePart = instance.split(" ");
for (int i = 0; i < instancePart.length; ++i){
s[i+1] = instancePart[i];
}
model3.addRow(s);
}
}
}
});
}
return jTable2;
}
/**
* This method initializes jScrollPane4
*
* @return javax.swing.JScrollPane
*/
private JScrollPane getJScrollPane4() {
if (jScrollPane4 == null) {
jScrollPane4 = new JScrollPane();
jScrollPane4.setPreferredSize(new java.awt.Dimension(450,170));
jScrollPane4.setViewportView(getJTable3());
}
return jScrollPane4;
}
/**
* This method initializes jTable3
*
* @return javax.swing.JTable
*/
private JTable getJTable3() {
if (jTable3 == null) {
model3 = new LibraryTableModel();
model3.addColumn("Name");
model3.addColumn("ModuleGUID");
model3.addColumn("ModuleVersion");
model3.addColumn("PackageGUID");
model3.addColumn("PackageVersion");
jTable3 = new JTable(model3);
jTable3.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
jTable3.getSelectionModel().addListSelectionListener(new ListSelectionListener(){
public void valueChanged(ListSelectionEvent e) {
int selectedRow3 = -1;
if (e.getValueIsAdjusting()){
return;
}
ListSelectionModel lsm = (ListSelectionModel)e.getSource();
if (lsm.isSelectionEmpty()) {
return;
}
else{
selectedRow3 = lsm.getMinSelectionIndex();
}
}
});
}
return jTable3;
}
/**
* This method initializes jPanel6
*
* @return javax.swing.JPanel
*/
private JPanel getJPanel6() {
if (jPanel6 == null) {
jPanel6 = new JPanel();
}
return jPanel6;
}
/**
* This method initializes jPanel7
*
* @return javax.swing.JPanel
*/
private JPanel getJPanel7() {
if (jPanel7 == null) {
jLabel4 = new JLabel();
jLabel4.setText("Instance Description");
jLabel3 = new JLabel();
jLabel3.setText("Selected Instances");
jPanel7 = new JPanel();
jPanel7.add(jLabel4, null);
jPanel7.add(getJScrollPane5(), null);
jPanel7.add(getJButton(), null);
jPanel7.add(getJButton1(), null);
jPanel7.add(jLabel3, null);
jPanel7.add(getJScrollPane2(), null);
}
return jPanel7;
}
/**
* This method initializes jScrollPane5
*
* @return javax.swing.JScrollPane
*/
private JScrollPane getJScrollPane5() {
if (jScrollPane5 == null) {
jScrollPane5 = new JScrollPane();
jScrollPane5.setPreferredSize(new java.awt.Dimension(300,50));
jScrollPane5.setViewportView(getJTextArea1());
}
return jScrollPane5;
}
/**
* This method initializes jTextArea1
*
* @return javax.swing.JTextArea
*/
private JTextArea getJTextArea1() {
if (jTextArea1 == null) {
jTextArea1 = new JTextArea();
jTextArea1.setEditable(false);
}
return jTextArea1;
}
/**
* 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("Add");
jButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent e) {
int row = jTable3.getSelectedRow();
if (row < 0) {
return;
}
Object[] s = {model3.getValueAt(row, 0), model3.getValueAt(row, 1),
model3.getValueAt(row, 2), model3.getValueAt(row, 3),
model3.getValueAt(row, 4)};
model1.addRow(s);
String instanceValue = model3.getValueAt(row, 1) + " " +
model3.getValueAt(row, 2) + " " +
model3.getValueAt(row, 3) + " " +
model3.getValueAt(row, 4);
//
// Add pcd information of selected instance to current moduleSA
//
ffc.addFrameworkModulesPcdBuildDefs(getModuleId(instanceValue), ffc.getModuleSA(moduleKey));
resolveLibraryInstances(instanceValue);
}
});
}
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.setText("Delete");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent e) {
int row = jTable1.getSelectedRow();
if (row < 0) {
return;
}
removeInstance(model1.getValueAt(row, 1) + " " +
model1.getValueAt(row, 2) + " " +
model1.getValueAt(row, 3) + " " +
model1.getValueAt(row, 4));
model1.removeRow(row);
}
});
}
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;
}
/**
* 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.setVisible(false);
}
return jButton3;
}
public void actionPerformed(ActionEvent arg0) {
if (arg0.getSource() == jButton2) {
ffc.removeLibraryInstances(moduleKey);
for (int i = 0; i < model1.getRowCount(); ++i) {
String mg = model1.getValueAt(i, 1)+"";
String mv = model1.getValueAt(i, 2)+"";
String pg = model1.getValueAt(i, 3)+"";
String pv = model1.getValueAt(i, 4)+"";
ffc.genLibraryInstance(mg, mv, pg, pv, moduleKey);
}
this.setVisible(false);
}
}
} // @jve:decl-index=0:visual-constraint="10,10"
class PartialEditableTableModel extends DefaultTableModel {
public boolean isCellEditable(int row, int col) {
switch (col){
case 2:
return true;
default:
return false;
}
}
}
class LibraryTableModel extends DefaultTableModel {
public boolean isCellEditable(int row, int col) {
return false;
}
}

Some files were not shown because too many files have changed in this diff Show More