From: hche10x Date: Fri, 30 Jun 2006 09:59:54 +0000 (+0000) Subject: git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@671 6f19259b... X-Git-Tag: edk2-stable201903~25161 X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=commitdiff_plain;h=a13899c5acad2f5e125abdae972b4c3d1e522f69 git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@671 6f19259b-4bc3-4df7-8a09-765794883524 --- diff --git a/Tools/Source/FrameworkWizard/MANIFEST.MF b/Tools/Source/FrameworkWizard/MANIFEST.MF new file mode 100644 index 0000000000..cfce7f7552 --- /dev/null +++ b/Tools/Source/FrameworkWizard/MANIFEST.MF @@ -0,0 +1,2 @@ +Manifest-Version: 1.0 +Main-Class: org.tianocore.frameworkwizard.FrameworkWizardUI diff --git a/Tools/Source/FrameworkWizard/build.xml b/Tools/Source/FrameworkWizard/build.xml new file mode 100644 index 0000000000..a9b00a3935 --- /dev/null +++ b/Tools/Source/FrameworkWizard/build.xml @@ -0,0 +1,44 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/About.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/About.java new file mode 100644 index 0000000000..0e4cfd2a98 --- /dev/null +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/About.java @@ -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(); + } +} diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/Clone.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/Clone.java new file mode 100644 index 0000000000..baf03795ee --- /dev/null +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/Clone.java @@ -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 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; + } +} diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/FrameworkWizardUI.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/FrameworkWizardUI.java new file mode 100644 index 0000000000..6b33cd6c36 --- /dev/null +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/FrameworkWizardUI.java @@ -0,0 +1,3016 @@ +/** @file + + The main GUI for module editor. + + Copyright (c) 2006, Intel Corporation + All rights reserved. This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + **/ + +package org.tianocore.frameworkwizard; + +import java.awt.event.ActionEvent; +import java.awt.event.ComponentEvent; +import java.awt.event.ComponentListener; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; +import java.awt.event.WindowEvent; +import java.io.IOException; +import java.util.Vector; + +import javax.swing.JButton; +import javax.swing.JCheckBoxMenuItem; +import javax.swing.JDesktopPane; +import javax.swing.JFileChooser; +import javax.swing.JFrame; +import javax.swing.JInternalFrame; +import javax.swing.JMenu; +import javax.swing.JMenuBar; +import javax.swing.JMenuItem; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JSplitPane; +import javax.swing.JTabbedPane; +import javax.swing.event.MenuEvent; +import javax.swing.event.MenuListener; +import javax.swing.event.TreeSelectionEvent; +import javax.swing.event.TreeSelectionListener; + +import org.apache.xmlbeans.XmlException; +import org.tianocore.ModuleSurfaceAreaDocument; +import org.tianocore.PackageSurfaceAreaDocument; +import org.tianocore.PlatformSurfaceAreaDocument; +import org.tianocore.frameworkwizard.common.DataType; +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.OpeningModuleList; +import org.tianocore.frameworkwizard.common.OpeningModuleType; +import org.tianocore.frameworkwizard.common.OpeningPackageList; +import org.tianocore.frameworkwizard.common.OpeningPackageType; +import org.tianocore.frameworkwizard.common.OpeningPlatformList; +import org.tianocore.frameworkwizard.common.OpeningPlatformType; +import org.tianocore.frameworkwizard.common.SaveFile; +import org.tianocore.frameworkwizard.common.Tools; +import org.tianocore.frameworkwizard.common.ui.IDefaultMutableTreeNode; +import org.tianocore.frameworkwizard.common.ui.IDesktopManager; +import org.tianocore.frameworkwizard.common.ui.IFrame; +import org.tianocore.frameworkwizard.common.ui.ITree; +import org.tianocore.frameworkwizard.module.Identification.ModuleIdentification; +import org.tianocore.frameworkwizard.module.ui.ModuleBootModes; +import org.tianocore.frameworkwizard.module.ui.ModuleDataHubs; +import org.tianocore.frameworkwizard.module.ui.ModuleDefinitions; +import org.tianocore.frameworkwizard.module.ui.ModuleEvents; +import org.tianocore.frameworkwizard.module.ui.ModuleExterns; +import org.tianocore.frameworkwizard.module.ui.ModuleGuids; +import org.tianocore.frameworkwizard.module.ui.ModuleHiiPackages; +import org.tianocore.frameworkwizard.module.ui.ModuleHobs; +import org.tianocore.frameworkwizard.module.ui.ModuleLibraryClassDefinitions; +import org.tianocore.frameworkwizard.module.ui.ModulePCDs; +import org.tianocore.frameworkwizard.module.ui.ModulePackageDependencies; +import org.tianocore.frameworkwizard.module.ui.ModulePpis; +import org.tianocore.frameworkwizard.module.ui.ModuleProtocols; +import org.tianocore.frameworkwizard.module.ui.ModuleSourceFiles; +import org.tianocore.frameworkwizard.module.ui.ModuleSystemTables; +import org.tianocore.frameworkwizard.module.ui.ModuleVariables; +import org.tianocore.frameworkwizard.module.ui.MsaHeader; +import org.tianocore.frameworkwizard.packaging.PackageIdentification; +import org.tianocore.frameworkwizard.packaging.ui.SpdGuidDecls; +import org.tianocore.frameworkwizard.packaging.ui.SpdHeader; +import org.tianocore.frameworkwizard.packaging.ui.SpdLibClassDecls; +import org.tianocore.frameworkwizard.packaging.ui.SpdMsaFiles; +import org.tianocore.frameworkwizard.packaging.ui.SpdPackageDefinitions; +import org.tianocore.frameworkwizard.packaging.ui.SpdPackageHeaders; +import org.tianocore.frameworkwizard.packaging.ui.SpdPcdDefs; +import org.tianocore.frameworkwizard.packaging.ui.SpdPpiDecls; +import org.tianocore.frameworkwizard.packaging.ui.SpdProtocolDecls; +import org.tianocore.frameworkwizard.platform.PlatformIdentification; +import org.tianocore.frameworkwizard.platform.ui.FpdBuildOptions; +import org.tianocore.frameworkwizard.platform.ui.FpdDynamicPcdBuildDefinitions; +import org.tianocore.frameworkwizard.platform.ui.FpdFlash; +import org.tianocore.frameworkwizard.platform.ui.FpdFrameworkModules; +import org.tianocore.frameworkwizard.platform.ui.FpdHeader; +import org.tianocore.frameworkwizard.platform.ui.FpdPlatformDefs; +import org.tianocore.frameworkwizard.workspace.Workspace; +import org.tianocore.frameworkwizard.workspace.WorkspaceTools; +import org.tianocore.frameworkwizard.workspace.ui.SwitchWorkspace; + +/** + The class is used to show main GUI of ModuleEditor + It extends IFrame implements MouseListener, TreeSelectionListener + + **/ +public class FrameworkWizardUI extends IFrame implements MouseListener, TreeSelectionListener, ComponentListener, + MenuListener { + /// + /// Define class Serial Version UID + /// + private static final long serialVersionUID = -7103240960573031772L; + + // + // To save information of all files + // + private Vector vModuleList = new Vector(); + + private Vector vPackageList = new Vector(); + + private Vector vPlatformList = new Vector(); + + private OpeningModuleList openingModuleList = new OpeningModuleList(); + + private OpeningPackageList openingPackageList = new OpeningPackageList(); + + private OpeningPlatformList openingPlatformList = new OpeningPlatformList(); + + private int currentOpeningModuleIndex = -1; + + private int currentOpeningPackageIndex = -1; + + private int currentOpeningPlatformIndex = -1; + + private String windowTitle = "FrameworkWizard 1.0 "; + + private IDefaultMutableTreeNode dmtnRoot = null; + + private IDefaultMutableTreeNode dmtnModuleDescription = null; + + private IDefaultMutableTreeNode dmtnPackageDescription = null; + + private IDefaultMutableTreeNode dmtnPlatformDescription = null; + + private JPanel jContentPane = null; + + private JMenuBar jMenuBar = null; + + private JMenu jMenuFile = null; + + private JMenuItem jMenuItemFileNew = null; + + private JMenuItem jMenuItemFileSaveAs = null; + + private JMenuItem jMenuItemFileExit = null; + + private JMenu jMenuEdit = null; + + private JDesktopPane jDesktopPaneModule = null; + + private JDesktopPane jDesktopPanePackage = null; + + private JDesktopPane jDesktopPanePlatform = null; + + private JTabbedPane jTabbedPaneTree = null; + + private JTabbedPane jTabbedPaneEditor = null; + + private IDesktopManager iDesktopManager = new IDesktopManager(); + + private JScrollPane jScrollPaneTree = null; + + private ITree iTree = null; + + private JMenu jMenuHelp = null; + + private JMenuItem jMenuItemHelpAbout = null; + + private JMenuItem jMenuItemEditDelete = null; + + private WorkspaceTools wt = new WorkspaceTools(); + + private JMenuItem jMenuItemFileSave = null; + + private JMenuItem jMenuItemFileClose = null; + + private JMenu jMenuTools = null; + + private JMenu jMenuWindow = null; + + private JPanel jPanelOperation = null; + + private JButton jButtonOk = null; + + private JButton jButtonCancel = null; + + private JMenuItem jMenuItemFileOpen = null; + + private JMenuItem jMenuItemFileCloseAll = null; + + private JMenuItem jMenuItemFileSaveAll = null; + + private JMenuItem jMenuItemFilePageSetup = null; + + private JMenuItem jMenuItemFilePrint = null; + + private JMenuItem jMenuItemFileImport = null; + + private JMenuItem jMenuItemFileProperties = null; + + private JMenu jMenuFileRecentFiles = null; + + private JSplitPane jSplitPane = null; + + private JMenuItem jMenuItemEditUndo = null; + + private JMenuItem jMenuItemEditRedo = null; + + private JMenuItem jMenuItemEditCut = null; + + private JMenuItem jMenuItemEditCopy = null; + + private JMenuItem jMenuItemEditPaste = null; + + private JMenuItem jMenuItemEditSelectAll = null; + + private JMenuItem jMenuItemEditFind = null; + + private JMenuItem jMenuItemEditFindNext = null; + + private JMenu jMenuView = null; + + private JMenu jMenuViewToolbars = null; + + private JCheckBoxMenuItem jCheckBoxMenuItemViewToolbarsFile = null; + + private JCheckBoxMenuItem jCheckBoxMenuItemViewToolbarsEdit = null; + + private JCheckBoxMenuItem jCheckBoxMenuItemViewToolbarsWindow = null; + + private JMenuItem jMenuItemViewStandard = null; + + private JMenuItem jMenuItemViewAdvanced = null; + + private JMenu jMenuProject = null; + + private JMenuItem jMenuItemProjectAdmin = null; + + private JMenuItem jMenuItemProjectChangeWorkspace = null; + + private JMenu jMenuProjectBuildTargets = null; + + private JCheckBoxMenuItem jCheckBoxMenuItemProjectBuildTargetsDebug = null; + + private JCheckBoxMenuItem jCheckBoxMenuItemProjectBuildTargetsRelease = null; + + private JMenuItem jMenuItemToolsToolChainConfiguration = null; + + private JMenuItem jMenuItemToolsClone = null; + + private JMenuItem jMenuItemToolsCodeScan = null; + + private JMenuItem jMenuItemWindowDisplaySide = null; + + private JMenuItem jMenuItemWindowDisplayTopBottom = null; + + private JMenuItem jMenuItemViewXML = null; + + private JMenuItem jMenuItemWindowTabView = null; + + private JMenuItem jMenuItemWindowSource = null; + + private JMenuItem jMenuItemWindowXML = null; + + private JMenuItem jMenuItemWindowPreferences = null; + + private JMenuItem jMenuItemHelpContents = null; + + private JMenuItem jMenuItemHelpIndex = null; + + private JMenuItem jMenuItemHelpSearch = null; + + private JMenuItem jMenuItemProjectInstallPackage = null; + + private JMenuItem jMenuItemProjectUpdatePackage = null; + + private JMenuItem jMenuItemProjectRemovePackage = null; + + //private JToolBar jToolBarFile = null; + + //private JToolBar jToolBarEdit = null; + + //private JToolBar jToolBarWindow = null; + + /** + This method initializes jMenuBar + + @return javax.swing.JMenuBar Main menu bar for the entire GUI + + **/ + private JMenuBar getjJMenuBar() { + if (jMenuBar == null) { + jMenuBar = new JMenuBar(); + jMenuBar.setPreferredSize(new java.awt.Dimension(0, 18)); + jMenuBar.add(getJMenuFile()); + jMenuBar.add(getJMenuEdit()); + jMenuBar.add(getJMenuView()); + jMenuBar.add(getJMenuProject()); + jMenuBar.add(getJMenuTools()); + jMenuBar.add(getJMenuWindow()); + jMenuBar.add(getJMenuHelp()); + } + return jMenuBar; + } + + /** + This method initializes jSplitPane + + @return javax.swing.JSplitPane + + **/ + private JSplitPane getJSplitPane() { + if (jSplitPane == null) { + jSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, getJTabbedPaneTree(), getJTabbedPaneEditor()); + jSplitPane.setBounds(new java.awt.Rectangle(0, 1, DataType.MAIN_FRAME_SPLIT_PANEL_PREFERRED_SIZE_WIDTH, + DataType.MAIN_FRAME_SPLIT_PANEL_PREFERRED_SIZE_HEIGHT)); + jSplitPane.addComponentListener(this); + } + return jSplitPane; + } + + /** + This method initializes jTabbedPaneEditor + + @return javax.swing.JTabbedPane + + */ + private JTabbedPane getJTabbedPaneEditor() { + if (jTabbedPaneEditor == null) { + jTabbedPaneEditor = new JTabbedPane(); + jTabbedPaneEditor.setBounds(new java.awt.Rectangle(DataType.MAIN_FRAME_EDITOR_PANEL_LOCATION_X, + DataType.MAIN_FRAME_EDITOR_PANEL_LOCATION_Y, + DataType.MAIN_FRAME_EDITOR_PANEL_PREFERRED_SIZE_WIDTH, + DataType.MAIN_FRAME_EDITOR_PANEL_PREFERRED_SIZE_HEIGHT)); + jTabbedPaneEditor + .setMinimumSize(new java.awt.Dimension( + DataType.MAIN_FRAME_EDITOR_PANEL_PREFERRED_SIZE_WIDTH, + DataType.MAIN_FRAME_EDITOR_PANEL_PREFERRED_SIZE_HEIGHT)); + //jTabbedPaneEditor.addChangeListener(this); + jTabbedPaneEditor.addTab("Module", null, getJDesktopPaneModule(), null); + jTabbedPaneEditor.addTab("Package", null, getJDesktopPanePackage(), null); + jTabbedPaneEditor.addTab("Platform", null, getJDesktopPanePlatform(), null); + } + return jTabbedPaneEditor; + } + + /** + This method initializes jTabbedPaneTree + + @return javax.swing.JTabbedPane + + */ + private JTabbedPane getJTabbedPaneTree() { + if (jTabbedPaneTree == null) { + jTabbedPaneTree = new JTabbedPane(); + jTabbedPaneTree + .setPreferredSize(new java.awt.Dimension( + DataType.MAIN_FRAME_TREE_PANEL_PREFERRED_SIZE_WIDTH, + DataType.MAIN_FRAME_TREE_PANEL_PREFERRED_SIZE_HEIGHT)); + jTabbedPaneTree + .setMinimumSize(new java.awt.Dimension(DataType.MAIN_FRAME_TREE_PANEL_PREFERRED_SIZE_WIDTH, + DataType.MAIN_FRAME_TREE_PANEL_PREFERRED_SIZE_HEIGHT)); + jTabbedPaneTree.addTab("Workspace Explorer", null, getJScrollPaneTree(), null); + } + return jTabbedPaneTree; + } + + /** + This method initializes jMenuFile + + @return javax.swing.JMenu jMenuModule + + **/ + private JMenu getJMenuFile() { + if (jMenuFile == null) { + jMenuFile = new JMenu(); + jMenuFile.setText("File"); + jMenuFile.setMnemonic('F'); + jMenuFile.add(getJMenuItemFileNew()); + jMenuFile.add(getJMenuItemFileOpen()); + jMenuFile.add(getJMenuItemFileClose()); + jMenuFile.add(getJMenuItemFileCloseAll()); + jMenuFile.addSeparator(); + jMenuFile.add(getJMenuFileRecentFiles()); + //jMenuFile.addSeparator(); + jMenuFile.add(getJMenuItemFileSave()); + jMenuFile.add(getJMenuItemFileSaveAs()); + jMenuFile.add(getJMenuItemFileSaveAll()); + jMenuFile.addSeparator(); + jMenuFile.add(getJMenuItemFilePageSetup()); + jMenuFile.add(getJMenuItemFilePrint()); + //jMenuFile.addSeparator(); + jMenuFile.add(getJMenuItemFileImport()); + //jMenuFile.addSeparator(); + jMenuFile.add(getJMenuItemFileProperties()); + //jMenuFile.addSeparator(); + jMenuFile.add(getJMenuItemFileExit()); + jMenuFile.addMenuListener(this); + } + return jMenuFile; + } + + /** + This method initializes jMenuItemFileSaveAs + + @return javax.swing.JMenuItem jMenuItemFileSaveAs + + **/ + private JMenuItem getJMenuItemFileSaveAs() { + if (jMenuItemFileSaveAs == null) { + jMenuItemFileSaveAs = new JMenuItem(); + jMenuItemFileSaveAs.setText("Save As..."); + jMenuItemFileSaveAs.setMnemonic('a'); + jMenuItemFileSaveAs.addActionListener(this); + jMenuItemFileSaveAs.setEnabled(false); + jMenuItemFileSaveAs.setVisible(false); + } + return jMenuItemFileSaveAs; + } + + /** + This method initializes jMenuItemModuleExit + + @return javax.swing.JMenuItem jMenuItemModuleExit + + **/ + private JMenuItem getJMenuItemFileExit() { + if (jMenuItemFileExit == null) { + jMenuItemFileExit = new JMenuItem(); + jMenuItemFileExit.setText("Exit"); + jMenuItemFileExit.setMnemonic('x'); + jMenuItemFileExit.addActionListener(this); + } + return jMenuItemFileExit; + } + + /** + This method initializes jMenuEdit + + @return javax.swing.JMenu jMenuEdit + + **/ + private JMenu getJMenuEdit() { + if (jMenuEdit == null) { + jMenuEdit = new JMenu(); + jMenuEdit.setText("Edit"); + jMenuEdit.setMnemonic('E'); + jMenuEdit.add(getJMenuItemEditUndo()); + jMenuEdit.add(getJMenuItemEditRedo()); + jMenuEdit.addSeparator(); + jMenuEdit.add(getJMenuItemEditCut()); + jMenuEdit.add(getJMenuItemEditCopy()); + jMenuEdit.add(getJMenuItemEditPaste()); + jMenuEdit.add(getJMenuItemEditDelete()); + jMenuEdit.addSeparator(); + jMenuEdit.add(getJMenuItemEditSelectAll()); + jMenuEdit.add(getJMenuItemEditFind()); + jMenuEdit.add(getJMenuItemEditFindNext()); + jMenuEdit.addSeparator(); + jMenuEdit.setVisible(false); + } + return jMenuEdit; + } + + /** + This method initializes jDesktopPane + + @return javax.swing.JDesktopPane jDesktopPane + + **/ + private JDesktopPane getJDesktopPaneModule() { + if (jDesktopPaneModule == null) { + jDesktopPaneModule = new JDesktopPane(); + jDesktopPaneModule + .setBounds(new java.awt.Rectangle(DataType.MAIN_FRAME_EDITOR_PANEL_LOCATION_X, + DataType.MAIN_FRAME_EDITOR_PANEL_LOCATION_Y, + DataType.MAIN_FRAME_EDITOR_PANEL_PREFERRED_SIZE_WIDTH, + DataType.MAIN_FRAME_EDITOR_PANEL_PREFERRED_SIZE_HEIGHT)); + jDesktopPaneModule + .setMinimumSize(new java.awt.Dimension( + DataType.MAIN_FRAME_EDITOR_PANEL_PREFERRED_SIZE_WIDTH, + DataType.MAIN_FRAME_EDITOR_PANEL_PREFERRED_SIZE_HEIGHT)); + jDesktopPaneModule.setDesktopManager(iDesktopManager); + jDesktopPaneModule.addComponentListener(this); + } + return jDesktopPaneModule; + } + + /** + This method initializes jDesktopPane + + @return javax.swing.JDesktopPane jDesktopPane + + **/ + private JDesktopPane getJDesktopPanePackage() { + if (jDesktopPanePackage == null) { + jDesktopPanePackage = new JDesktopPane(); + jDesktopPanePackage + .setBounds(new java.awt.Rectangle(DataType.MAIN_FRAME_EDITOR_PANEL_LOCATION_X, + DataType.MAIN_FRAME_EDITOR_PANEL_LOCATION_Y, + DataType.MAIN_FRAME_EDITOR_PANEL_PREFERRED_SIZE_WIDTH, + DataType.MAIN_FRAME_EDITOR_PANEL_PREFERRED_SIZE_HEIGHT)); + jDesktopPanePackage + .setMinimumSize(new java.awt.Dimension( + DataType.MAIN_FRAME_EDITOR_PANEL_PREFERRED_SIZE_WIDTH, + DataType.MAIN_FRAME_EDITOR_PANEL_PREFERRED_SIZE_HEIGHT)); + jDesktopPanePackage.setDesktopManager(iDesktopManager); + jDesktopPanePackage.addComponentListener(this); + } + return jDesktopPanePackage; + } + + /** + This method initializes jDesktopPane + + @return javax.swing.JDesktopPane jDesktopPane + + **/ + private JDesktopPane getJDesktopPanePlatform() { + if (jDesktopPanePlatform == null) { + jDesktopPanePlatform = new JDesktopPane(); + jDesktopPanePlatform + .setBounds(new java.awt.Rectangle( + DataType.MAIN_FRAME_EDITOR_PANEL_LOCATION_X, + DataType.MAIN_FRAME_EDITOR_PANEL_LOCATION_Y, + DataType.MAIN_FRAME_EDITOR_PANEL_PREFERRED_SIZE_WIDTH, + DataType.MAIN_FRAME_EDITOR_PANEL_PREFERRED_SIZE_HEIGHT)); + jDesktopPanePlatform + .setMinimumSize(new java.awt.Dimension( + DataType.MAIN_FRAME_EDITOR_PANEL_PREFERRED_SIZE_WIDTH, + DataType.MAIN_FRAME_EDITOR_PANEL_PREFERRED_SIZE_HEIGHT)); + jDesktopPanePlatform.setDesktopManager(iDesktopManager); + jDesktopPanePlatform.addComponentListener(this); + } + return jDesktopPanePlatform; + } + + /** + This method initializes jScrollPaneTree + + @return javax.swing.JScrollPane jScrollPaneTree + + **/ + private JScrollPane getJScrollPaneTree() { + if (jScrollPaneTree == null) { + jScrollPaneTree = new JScrollPane(); + //jScrollPaneTree.setBounds(new java.awt.Rectangle(0, 1, 290, 545)); + jScrollPaneTree + .setPreferredSize(new java.awt.Dimension( + DataType.MAIN_FRAME_TREE_PANEL_PREFERRED_SIZE_WIDTH, + DataType.MAIN_FRAME_TREE_PANEL_PREFERRED_SIZE_HEIGHT)); + jScrollPaneTree + .setMinimumSize(new java.awt.Dimension( + DataType.MAIN_FRAME_TREE_PANEL_PREFERRED_SIZE_WIDTH / 2, + DataType.MAIN_FRAME_TREE_PANEL_PREFERRED_SIZE_HEIGHT)); + jScrollPaneTree.setViewportView(getITree()); + } + return jScrollPaneTree; + } + + /** + This method initializes iTree + + @return org.tianocore.packaging.common.ui.ITree iTree + + **/ + private ITree getITree() { + // + //Before open a real module, use an empty root node for the tree + // + makeEmptyTree(); + return iTree; + } + + /** + This method initializes jMenuHelp + + @return javax.swing.JMenu jMenuHelp + + **/ + private JMenu getJMenuHelp() { + if (jMenuHelp == null) { + jMenuHelp = new JMenu(); + jMenuHelp.setText("Help"); + jMenuHelp.add(getJMenuItemHelpContents()); + jMenuHelp.add(getJMenuItemHelpIndex()); + jMenuHelp.add(getJMenuItemHelpSearch()); + //jMenuHelp.addSeparator(); + jMenuHelp.add(getJMenuItemHelpAbout()); + } + return jMenuHelp; + } + + /** + This method initializes jMenuItemHelpAbout + + @return javax.swing.JMenuItem jMenuItemHelpAbout + + **/ + private JMenuItem getJMenuItemHelpAbout() { + if (jMenuItemHelpAbout == null) { + jMenuItemHelpAbout = new JMenuItem(); + jMenuItemHelpAbout.setText("About..."); + jMenuItemHelpAbout.addActionListener(this); + } + return jMenuItemHelpAbout; + } + + /** + This method initializes jMenuItemEditDelete + + @return javax.swing.JMenuItem jMenuItemEditDelete + + **/ + private JMenuItem getJMenuItemEditDelete() { + if (jMenuItemEditDelete == null) { + jMenuItemEditDelete = new JMenuItem(); + jMenuItemEditDelete.setText("Delete"); + jMenuItemEditDelete.setMnemonic('D'); + jMenuItemEditDelete.addActionListener(this); + // + //Disabled when no module is open + // + jMenuItemEditDelete.setEnabled(false); + } + return jMenuItemEditDelete; + } + + // /** + // This method initializes jPopupMenu + // + // @return javax.swing.JPopupMenu jPopupMenu + // + // **/ + // private JPopupMenu getJPopupMenu() { + // if (jPopupMenu == null) { + // jPopupMenu = new JPopupMenu(); + // // + // //Add menu items of popup menu + // // + // jPopupMenu.add(getJMenuItemPopupAdd()); + // jPopupMenu.add(getJMenuItemPopupUpdate()); + // jPopupMenu.add(getJMenuItemPopupDelete()); + // jPopupMenu.setBorder(new BevelBorder(BevelBorder.RAISED)); + // jPopupMenu.addMouseListener(this); + // } + // return jPopupMenu; + // } + // + // /** + // This method initializes jMenuItemPopupAdd + // + // @return javax.swing.JMenuItem jMenuItemPopupAdd + // + // **/ + // private JMenuItem getJMenuItemPopupAdd() { + // if (jMenuItemPopupAdd == null) { + // jMenuItemPopupAdd = new JMenuItem(); + // jMenuItemPopupAdd.setText("Add"); + // jMenuItemPopupAdd.addActionListener(this); + // jMenuItemPopupAdd.setEnabled(false); + // } + // return jMenuItemPopupAdd; + // } + // + // /** + // This method initializes jMenuItemPopupUpdate + // + // @return javax.swing.JMenuItem jMenuItemPopupUpdate + // + // **/ + // private JMenuItem getJMenuItemPopupUpdate() { + // if (jMenuItemPopupUpdate == null) { + // jMenuItemPopupUpdate = new JMenuItem(); + // jMenuItemPopupUpdate.setText("Update"); + // jMenuItemPopupUpdate.addActionListener(this); + // jMenuItemPopupUpdate.setEnabled(false); + // } + // return jMenuItemPopupUpdate; + // } + // + // /** + // This method initializes jMenuItemPopupDelete + // + // @return javax.swing.JMenuItem jMenuItemPopupDelete + // + // **/ + // private JMenuItem getJMenuItemPopupDelete() { + // if (jMenuItemPopupDelete == null) { + // jMenuItemPopupDelete = new JMenuItem(); + // jMenuItemPopupDelete.setText("Delete"); + // jMenuItemPopupDelete.addActionListener(this); + // jMenuItemPopupDelete.setEnabled(false); + // } + // return jMenuItemPopupDelete; + // } + + /** + This method initializes jMenuFileNew + + @return javax.swing.JMenuItem jMenuFileNew + + **/ + private JMenuItem getJMenuItemFileNew() { + if (jMenuItemFileNew == null) { + jMenuItemFileNew = new JMenuItem(); + jMenuItemFileNew.setText("New..."); + jMenuItemFileNew.setMnemonic('N'); + jMenuItemFileNew.addActionListener(this); + } + return jMenuItemFileNew; + } + + /** + This method initializes jMenuItemFileSave + + @return javax.swing.JMenuItem jMenuItemModuleSave + + **/ + private JMenuItem getJMenuItemFileSave() { + if (jMenuItemFileSave == null) { + jMenuItemFileSave = new JMenuItem(); + jMenuItemFileSave.setText("Save"); + jMenuItemFileSave.setMnemonic('S'); + jMenuItemFileSave.addActionListener(this); + jMenuItemFileSave.setEnabled(true); + } + return jMenuItemFileSave; + } + + /** + This method initializes jMenuItemModuleClose + + @return javax.swing.JMenuItem jMenuItemModuleClose + + **/ + private JMenuItem getJMenuItemFileClose() { + if (jMenuItemFileClose == null) { + jMenuItemFileClose = new JMenuItem(); + jMenuItemFileClose.setText("Close"); + jMenuItemFileClose.setMnemonic('C'); + jMenuItemFileClose.setEnabled(true); + jMenuItemFileClose.addActionListener(this); + } + return jMenuItemFileClose; + } + + /** + This method initializes jMenuTools + Reserved + + @return javax.swing.JMenu jMenuTools + + **/ + private JMenu getJMenuTools() { + if (jMenuTools == null) { + jMenuTools = new JMenu(); + jMenuTools.setText("Tools"); + jMenuTools.setMnemonic('T'); + jMenuTools.add(getJMenuItemToolsToolChainConfiguration()); + //jMenuTools.addSeparator(); + jMenuTools.add(getJMenuItemToolsClone()); + //jMenuTools.addSeparator(); + jMenuTools.add(getJMenuItemToolsCodeScan()); + jMenuTools.addMenuListener(this); + } + return jMenuTools; + } + + /** + This method initializes jMenuWindow + Reserved + + @return javax.swing.JMenu jMenuWindow + + **/ + private JMenu getJMenuWindow() { + if (jMenuWindow == null) { + jMenuWindow = new JMenu(); + jMenuWindow.setText("Window"); + jMenuWindow.setMnemonic('W'); + jMenuWindow.add(getJMenuItemWindowDisplaySide()); + jMenuWindow.add(getJMenuItemWindowDisplayTopBottom()); + jMenuWindow.addSeparator(); + jMenuWindow.add(getJMenuItemWindowTabView()); + jMenuWindow.addSeparator(); + jMenuWindow.add(getJMenuItemWindowSource()); + jMenuWindow.add(getJMenuItemWindowXML()); + jMenuWindow.addSeparator(); + jMenuWindow.add(getJMenuItemWindowPreferences()); + jMenuWindow.setVisible(false); + } + return jMenuWindow; + } + + /** + This method initializes jPanelOperation + + @return javax.swing.JPanel jPanelOperation + + **/ + private JPanel getJPanelOperation() { + if (jPanelOperation == null) { + jPanelOperation = new JPanel(); + jPanelOperation.setLayout(null); + jPanelOperation.setBounds(new java.awt.Rectangle(295, 520, 500, 25)); + jPanelOperation.add(getJButtonOk(), null); + jPanelOperation.add(getJButtonCancel(), null); + jPanelOperation.setVisible(false); + } + return jPanelOperation; + } + + /** + This method initializes jButtonOk + + @return javax.swing.JButton jButtonOk + + **/ + private JButton getJButtonOk() { + if (jButtonOk == null) { + jButtonOk = new JButton(); + jButtonOk.setBounds(new java.awt.Rectangle(395, 2, 90, 20)); + jButtonOk.setText("Ok"); + jButtonOk.setEnabled(false); + jButtonOk.addActionListener(this); + } + return jButtonOk; + } + + /** + This method initializes jButtonCancel + + @return javax.swing.JButton jButtonCancel + + **/ + private JButton getJButtonCancel() { + if (jButtonCancel == null) { + jButtonCancel = new JButton(); + jButtonCancel.setBounds(new java.awt.Rectangle(395, 2, 90, 20)); + jButtonCancel.setText("Cancel"); + jButtonCancel.setEnabled(false); + jButtonCancel.addActionListener(this); + jButtonCancel.setVisible(false); + } + return jButtonCancel; + } + + /** + This method initializes jMenuItemFileOpen + + @return javax.swing.JMenuItem jMenuItemFileOpen + */ + private JMenuItem getJMenuItemFileOpen() { + if (jMenuItemFileOpen == null) { + jMenuItemFileOpen = new JMenuItem(); + jMenuItemFileOpen.setText("Open..."); + jMenuItemFileOpen.setMnemonic('O'); + jMenuItemFileOpen.addActionListener(this); + } + return jMenuItemFileOpen; + } + + /** + This method initializes jMenuItemFileCloseAll + + @return javax.swing.JMenuItem jMenuItemFileOpen + */ + private JMenuItem getJMenuItemFileCloseAll() { + if (jMenuItemFileCloseAll == null) { + jMenuItemFileCloseAll = new JMenuItem(); + jMenuItemFileCloseAll.setText("Close All"); + jMenuItemFileCloseAll.setEnabled(true); + jMenuItemFileCloseAll.addActionListener(this); + } + return jMenuItemFileCloseAll; + } + + /** + This method initializes jMenuItemFileSaveAll + + @return javax.swing.JMenuItem jMenuItemFileSaveAll + */ + private JMenuItem getJMenuItemFileSaveAll() { + if (jMenuItemFileSaveAll == null) { + jMenuItemFileSaveAll = new JMenuItem(); + jMenuItemFileSaveAll.setText("Save All"); + jMenuItemFileSaveAll.setMnemonic('v'); + jMenuItemFileSaveAll.setEnabled(true); + jMenuItemFileSaveAll.addActionListener(this); + } + return jMenuItemFileSaveAll; + } + + /** + This method initializes jMenuItemFilePageSetup + + @return javax.swing.JMenuItem + */ + private JMenuItem getJMenuItemFilePageSetup() { + if (jMenuItemFilePageSetup == null) { + jMenuItemFilePageSetup = new JMenuItem(); + jMenuItemFilePageSetup.setText("Page Setup"); + jMenuItemFilePageSetup.setMnemonic('u'); + jMenuItemFilePageSetup.setEnabled(false); + jMenuItemFilePageSetup.addActionListener(this); + jMenuItemFilePageSetup.setVisible(false); + } + return jMenuItemFilePageSetup; + } + + /** + This method initializes jMenuItemFilePrint + + @return javax.swing.JMenuItem + */ + private JMenuItem getJMenuItemFilePrint() { + if (jMenuItemFilePrint == null) { + jMenuItemFilePrint = new JMenuItem(); + jMenuItemFilePrint.setText("Print"); + jMenuItemFilePrint.setMnemonic('P'); + jMenuItemFilePrint.setEnabled(false); + jMenuItemFilePrint.addActionListener(this); + jMenuItemFilePrint.setVisible(false); + } + return jMenuItemFilePrint; + } + + /** + This method initializes jMenuItemFileImport + + @return javax.swing.JMenuItem + */ + private JMenuItem getJMenuItemFileImport() { + if (jMenuItemFileImport == null) { + jMenuItemFileImport = new JMenuItem(); + jMenuItemFileImport.setText("Import"); + jMenuItemFileImport.setMnemonic('I'); + jMenuItemFileImport.setEnabled(false); + jMenuItemFileImport.addActionListener(this); + jMenuItemFileImport.setVisible(false); + } + return jMenuItemFileImport; + } + + /** + * This method initializes jMenuItemFileProperties + * + * @return javax.swing.JMenuItem + */ + private JMenuItem getJMenuItemFileProperties() { + if (jMenuItemFileProperties == null) { + jMenuItemFileProperties = new JMenuItem(); + jMenuItemFileProperties.setText("Properties"); + jMenuItemFileProperties.setMnemonic('t'); + jMenuItemFileProperties.setEnabled(false); + jMenuItemFileProperties.addActionListener(this); + jMenuItemFileProperties.setVisible(false); + } + return jMenuItemFileProperties; + } + + /** + * This method initializes jMenuFileRecentFiles + * + * @return javax.swing.JMenu + */ + private JMenu getJMenuFileRecentFiles() { + if (jMenuFileRecentFiles == null) { + jMenuFileRecentFiles = new JMenu(); + jMenuFileRecentFiles.setText("Recent Files"); + jMenuFileRecentFiles.setMnemonic('F'); + jMenuFileRecentFiles.setEnabled(false); + jMenuFileRecentFiles.addActionListener(this); + jMenuFileRecentFiles.setVisible(false); + } + return jMenuFileRecentFiles; + } + + /** + This method initializes jMenuItemEditUndo + + @return javax.swing.JMenuItem + */ + private JMenuItem getJMenuItemEditUndo() { + if (jMenuItemEditUndo == null) { + jMenuItemEditUndo = new JMenuItem(); + jMenuItemEditUndo.setText("Undo"); + jMenuItemEditUndo.setMnemonic('U'); + jMenuItemEditUndo.setEnabled(false); + jMenuItemEditUndo.addActionListener(this); + } + return jMenuItemEditUndo; + } + + /** + This method initializes jMenuItemEditRedo + + @return javax.swing.JMenuItem + */ + private JMenuItem getJMenuItemEditRedo() { + if (jMenuItemEditRedo == null) { + jMenuItemEditRedo = new JMenuItem(); + jMenuItemEditRedo.setText("Redo"); + jMenuItemEditRedo.setMnemonic('R'); + jMenuItemEditRedo.setEnabled(false); + jMenuItemEditRedo.addActionListener(this); + } + return jMenuItemEditRedo; + } + + /** + This method initializes jMenuItemEditCut + + @return javax.swing.JMenuItem + */ + private JMenuItem getJMenuItemEditCut() { + if (jMenuItemEditCut == null) { + jMenuItemEditCut = new JMenuItem(); + jMenuItemEditCut.setText("Cut"); + jMenuItemEditCut.setMnemonic('t'); + jMenuItemEditCut.setEnabled(false); + jMenuItemEditCut.addActionListener(this); + } + return jMenuItemEditCut; + } + + /** + This method initializes jMenuItemEditCopy + + @return javax.swing.JMenuItem + */ + private JMenuItem getJMenuItemEditCopy() { + if (jMenuItemEditCopy == null) { + jMenuItemEditCopy = new JMenuItem(); + jMenuItemEditCopy.setText("Copy"); + jMenuItemEditCopy.setMnemonic('C'); + jMenuItemEditCopy.setEnabled(false); + jMenuItemEditCopy.addActionListener(this); + } + return jMenuItemEditCopy; + } + + /** + This method initializes jMenuItemEditPaste + + return javax.swing.JMenuItem + */ + private JMenuItem getJMenuItemEditPaste() { + if (jMenuItemEditPaste == null) { + jMenuItemEditPaste = new JMenuItem(); + jMenuItemEditPaste.setText("Paste"); + jMenuItemEditPaste.setMnemonic('P'); + jMenuItemEditPaste.setEnabled(false); + jMenuItemEditPaste.addActionListener(this); + } + return jMenuItemEditPaste; + } + + /** + This method initializes jMenuItem + + @return javax.swing.JMenuItem + */ + private JMenuItem getJMenuItemEditSelectAll() { + if (jMenuItemEditSelectAll == null) { + jMenuItemEditSelectAll = new JMenuItem(); + jMenuItemEditSelectAll.setText("Select All"); + jMenuItemEditSelectAll.setMnemonic('A'); + jMenuItemEditSelectAll.setEnabled(false); + jMenuItemEditSelectAll.addActionListener(this); + } + return jMenuItemEditSelectAll; + } + + /** + This method initializes jMenuItemEditFind + + @return javax.swing.JMenuItem + */ + private JMenuItem getJMenuItemEditFind() { + if (jMenuItemEditFind == null) { + jMenuItemEditFind = new JMenuItem(); + jMenuItemEditFind.setText("Find"); + jMenuItemEditFind.setMnemonic('F'); + jMenuItemEditFind.setEnabled(false); + jMenuItemEditFind.addActionListener(this); + } + return jMenuItemEditFind; + } + + /** + This method initializes jMenuItemEditFindNext + + @return javax.swing.JMenuItem + + */ + private JMenuItem getJMenuItemEditFindNext() { + if (jMenuItemEditFindNext == null) { + jMenuItemEditFindNext = new JMenuItem(); + jMenuItemEditFindNext.setText("Find Next"); + jMenuItemEditFindNext.setMnemonic('n'); + jMenuItemEditFindNext.setEnabled(false); + jMenuItemEditFindNext.addActionListener(this); + } + return jMenuItemEditFindNext; + } + + /** + This method initializes jMenuView + + @return javax.swing.JMenu + + */ + private JMenu getJMenuView() { + if (jMenuView == null) { + jMenuView = new JMenu(); + jMenuView.setText("View"); + jMenuView.setMnemonic('V'); + jMenuView.add(getJMenuViewToolbars()); + jMenuView.add(getJMenuItemViewAdvanced()); + jMenuView.add(getJMenuItemViewStandard()); + jMenuView.add(getJMenuItemViewXML()); + jMenuView.setVisible(false); + } + return jMenuView; + } + + /** + This method initializes jMenuViewToolbars + + @return javax.swing.JMenu + + */ + private JMenu getJMenuViewToolbars() { + if (jMenuViewToolbars == null) { + jMenuViewToolbars = new JMenu(); + jMenuViewToolbars.setText("Toolbars"); + jMenuViewToolbars.setMnemonic('T'); + jMenuViewToolbars.add(getJCheckBoxMenuItemViewToolbarsFile()); + jMenuViewToolbars.add(getJCheckBoxMenuItemViewToolbarsEdit()); + jMenuViewToolbars.add(getJCheckBoxMenuItemViewToolbarsWindow()); + } + return jMenuViewToolbars; + } + + /** + This method initializes jCheckBoxMenuItemViewToolbarsFile + + @return javax.swing.JCheckBoxMenuItem + + */ + private JCheckBoxMenuItem getJCheckBoxMenuItemViewToolbarsFile() { + if (jCheckBoxMenuItemViewToolbarsFile == null) { + jCheckBoxMenuItemViewToolbarsFile = new JCheckBoxMenuItem(); + jCheckBoxMenuItemViewToolbarsFile.setText("File"); + jCheckBoxMenuItemViewToolbarsFile.setEnabled(false); + jCheckBoxMenuItemViewToolbarsFile.addActionListener(this); + } + return jCheckBoxMenuItemViewToolbarsFile; + } + + /** + This method initializes jCheckBoxMenuItemViewToolbarsEdit + + @return javax.swing.JCheckBoxMenuItem + + */ + private JCheckBoxMenuItem getJCheckBoxMenuItemViewToolbarsEdit() { + if (jCheckBoxMenuItemViewToolbarsEdit == null) { + jCheckBoxMenuItemViewToolbarsEdit = new JCheckBoxMenuItem(); + jCheckBoxMenuItemViewToolbarsEdit.setText("Edit"); + jCheckBoxMenuItemViewToolbarsEdit.setEnabled(false); + jCheckBoxMenuItemViewToolbarsEdit.addActionListener(this); + } + return jCheckBoxMenuItemViewToolbarsEdit; + } + + /** + This method initializes jCheckBoxMenuItemViewToolbarsWindow + + @return javax.swing.JCheckBoxMenuItem + + */ + private JCheckBoxMenuItem getJCheckBoxMenuItemViewToolbarsWindow() { + if (jCheckBoxMenuItemViewToolbarsWindow == null) { + jCheckBoxMenuItemViewToolbarsWindow = new JCheckBoxMenuItem(); + jCheckBoxMenuItemViewToolbarsWindow.setText("Window"); + jCheckBoxMenuItemViewToolbarsWindow.setEnabled(false); + jCheckBoxMenuItemViewToolbarsWindow.addActionListener(this); + } + return jCheckBoxMenuItemViewToolbarsWindow; + } + + /** + This method initializes jMenuItemStandard + + @return javax.swing.JMenuItem + + */ + private JMenuItem getJMenuItemViewStandard() { + if (jMenuItemViewStandard == null) { + jMenuItemViewStandard = new JMenuItem(); + jMenuItemViewStandard.setText("Standard"); + jMenuItemViewStandard.setMnemonic('S'); + jMenuItemViewStandard.setEnabled(false); + jMenuItemViewStandard.addActionListener(this); + } + return jMenuItemViewStandard; + } + + /** + This method initializes jMenuItemAdvanced + + @return javax.swing.JMenuItem + + */ + private JMenuItem getJMenuItemViewAdvanced() { + if (jMenuItemViewAdvanced == null) { + jMenuItemViewAdvanced = new JMenuItem(); + jMenuItemViewAdvanced.setText("Advanced"); + jMenuItemViewAdvanced.setMnemonic('A'); + jMenuItemViewAdvanced.setEnabled(false); + jMenuItemViewAdvanced.addActionListener(this); + } + return jMenuItemViewAdvanced; + } + + /** + This method initializes jMenuProject + + @return javax.swing.JMenu + + */ + private JMenu getJMenuProject() { + if (jMenuProject == null) { + jMenuProject = new JMenu(); + jMenuProject.setText("Project"); + jMenuProject.setMnemonic('P'); + jMenuProject.add(getJMenuItemProjectAdmin()); + //jMenuProject.addSeparator(); + jMenuProject.add(getJMenuItemProjectChangeWorkspace()); + jMenuProject.addSeparator(); + jMenuProject.add(getJMenuItemProjectInstallPackage()); + jMenuProject.add(getJMenuItemProjectUpdatePackage()); + jMenuProject.add(getJMenuItemProjectRemovePackage()); + //jMenuProject.addSeparator(); + jMenuProject.add(getJMenuProjectBuildTargets()); + } + return jMenuProject; + } + + /** + This method initializes jMenuItemProjectAdmin + + @return javax.swing.JMenuItem + + */ + private JMenuItem getJMenuItemProjectAdmin() { + if (jMenuItemProjectAdmin == null) { + jMenuItemProjectAdmin = new JMenuItem(); + jMenuItemProjectAdmin.setText("Admin..."); + jMenuItemProjectAdmin.setMnemonic('A'); + jMenuItemProjectAdmin.setEnabled(false); + jMenuItemProjectAdmin.addActionListener(this); + jMenuItemProjectAdmin.setVisible(false); + } + return jMenuItemProjectAdmin; + } + + /** + This method initializes jMenuItemProjectChangeWorkspace + + @return javax.swing.JMenuItem + + */ + private JMenuItem getJMenuItemProjectChangeWorkspace() { + if (jMenuItemProjectChangeWorkspace == null) { + jMenuItemProjectChangeWorkspace = new JMenuItem(); + jMenuItemProjectChangeWorkspace.setText("Change WORKSPACE..."); + jMenuItemProjectChangeWorkspace.setMnemonic('W'); + jMenuItemProjectChangeWorkspace.setEnabled(true); + jMenuItemProjectChangeWorkspace.addActionListener(this); + } + return jMenuItemProjectChangeWorkspace; + } + + /** + This method initializes jMenuProjectBuildTargets + + @return javax.swing.JMenu + + */ + private JMenu getJMenuProjectBuildTargets() { + if (jMenuProjectBuildTargets == null) { + jMenuProjectBuildTargets = new JMenu(); + jMenuProjectBuildTargets.setText("Build Targets"); + jMenuProjectBuildTargets.setMnemonic('T'); + jMenuProjectBuildTargets.add(getJCheckBoxMenuItemProjectBuildTargetsDebug()); + jMenuProjectBuildTargets.add(getJCheckBoxMenuItemProjectBuildTargetsRelease()); + jMenuProjectBuildTargets.setVisible(false); + } + return jMenuProjectBuildTargets; + } + + /** + This method initializes jCheckBoxMenuItemProjectBuildTargetsDebug + + @return javax.swing.JCheckBoxMenuItem + + */ + private JCheckBoxMenuItem getJCheckBoxMenuItemProjectBuildTargetsDebug() { + if (jCheckBoxMenuItemProjectBuildTargetsDebug == null) { + jCheckBoxMenuItemProjectBuildTargetsDebug = new JCheckBoxMenuItem(); + jCheckBoxMenuItemProjectBuildTargetsDebug.setText("Debug"); + jCheckBoxMenuItemProjectBuildTargetsDebug.setEnabled(false); + } + return jCheckBoxMenuItemProjectBuildTargetsDebug; + } + + /** + This method initializes jCheckBoxMenuItemProjectBuildTargetsRelease + + @return javax.swing.JCheckBoxMenuItem + + */ + private JCheckBoxMenuItem getJCheckBoxMenuItemProjectBuildTargetsRelease() { + if (jCheckBoxMenuItemProjectBuildTargetsRelease == null) { + jCheckBoxMenuItemProjectBuildTargetsRelease = new JCheckBoxMenuItem(); + jCheckBoxMenuItemProjectBuildTargetsRelease.setText("Release"); + jCheckBoxMenuItemProjectBuildTargetsRelease.setEnabled(false); + } + return jCheckBoxMenuItemProjectBuildTargetsRelease; + } + + /** + This method initializes jMenuItemToolsToolChainConfiguration + + @return javax.swing.JMenuItem + + */ + private JMenuItem getJMenuItemToolsToolChainConfiguration() { + if (jMenuItemToolsToolChainConfiguration == null) { + jMenuItemToolsToolChainConfiguration = new JMenuItem(); + jMenuItemToolsToolChainConfiguration.setText("Tool Chain Configuration..."); + jMenuItemToolsToolChainConfiguration.setMnemonic('C'); + jMenuItemToolsToolChainConfiguration.addActionListener(this); + jMenuItemToolsToolChainConfiguration.setVisible(false); + } + return jMenuItemToolsToolChainConfiguration; + } + + /** + This method initializes jMenuItemToolsClone + + @return javax.swing.JMenuItem + + */ + private JMenuItem getJMenuItemToolsClone() { + if (jMenuItemToolsClone == null) { + jMenuItemToolsClone = new JMenuItem(); + jMenuItemToolsClone.setText("Clone..."); + jMenuItemToolsClone.setMnemonic('l'); + jMenuItemToolsClone.setEnabled(true); + jMenuItemToolsClone.addActionListener(this); + } + return jMenuItemToolsClone; + } + + /** + This method initializes jMenuItemToolsCodeScan + + @return javax.swing.JMenuItem + + */ + private JMenuItem getJMenuItemToolsCodeScan() { + if (jMenuItemToolsCodeScan == null) { + jMenuItemToolsCodeScan = new JMenuItem(); + jMenuItemToolsCodeScan.setText("Code Scan..."); + jMenuItemToolsCodeScan.setMnemonic('S'); + jMenuItemToolsCodeScan.setEnabled(false); + jMenuItemToolsCodeScan.addActionListener(this); + jMenuItemToolsCodeScan.setVisible(false); + } + return jMenuItemToolsCodeScan; + } + + /** + This method initializes jMenuItemWindowSplitVertical + + @return javax.swing.JMenuItem + + */ + private JMenuItem getJMenuItemWindowDisplaySide() { + if (jMenuItemWindowDisplaySide == null) { + jMenuItemWindowDisplaySide = new JMenuItem(); + jMenuItemWindowDisplaySide.setText("Display Side by Side"); + jMenuItemWindowDisplaySide.setMnemonic('S'); + jMenuItemWindowDisplaySide.setEnabled(false); + jMenuItemWindowDisplaySide.addActionListener(this); + } + return jMenuItemWindowDisplaySide; + } + + /** + This method initializes jMenuItemWindowSplitHorizontal + + @return javax.swing.JMenuItem + + */ + private JMenuItem getJMenuItemWindowDisplayTopBottom() { + if (jMenuItemWindowDisplayTopBottom == null) { + jMenuItemWindowDisplayTopBottom = new JMenuItem(); + jMenuItemWindowDisplayTopBottom.setText("Display Top and Bottom"); + jMenuItemWindowDisplayTopBottom.setMnemonic('B'); + jMenuItemWindowDisplayTopBottom.setEnabled(false); + jMenuItemWindowDisplayTopBottom.addActionListener(this); + } + return jMenuItemWindowDisplayTopBottom; + } + + /** + This method initializes jMenuItemViewXML + + @return javax.swing.JMenuItem + + */ + private JMenuItem getJMenuItemViewXML() { + if (jMenuItemViewXML == null) { + jMenuItemViewXML = new JMenuItem(); + jMenuItemViewXML.setText("XML"); + jMenuItemViewXML.setMnemonic('X'); + jMenuItemViewXML.setEnabled(false); + jMenuItemViewXML.addActionListener(this); + } + return jMenuItemViewXML; + } + + /** + This method initializes jMenuItemWindowTabView + + @return javax.swing.JMenuItem + + */ + private JMenuItem getJMenuItemWindowTabView() { + if (jMenuItemWindowTabView == null) { + jMenuItemWindowTabView = new JMenuItem(); + jMenuItemWindowTabView.setText("Tab View"); + jMenuItemWindowTabView.setMnemonic('T'); + jMenuItemWindowTabView.setEnabled(false); + jMenuItemWindowTabView.addActionListener(this); + } + return jMenuItemWindowTabView; + } + + /** + This method initializes jMenuItemWindowSource + + @return javax.swing.JMenuItem + + */ + private JMenuItem getJMenuItemWindowSource() { + if (jMenuItemWindowSource == null) { + jMenuItemWindowSource = new JMenuItem(); + jMenuItemWindowSource.setText("Source"); + jMenuItemWindowSource.setMnemonic('S'); + jMenuItemWindowSource.setEnabled(false); + jMenuItemWindowSource.addActionListener(this); + } + return jMenuItemWindowSource; + } + + /** + This method initializes jMenuItemWindowXML + + @return javax.swing.JMenuItem + + */ + private JMenuItem getJMenuItemWindowXML() { + if (jMenuItemWindowXML == null) { + jMenuItemWindowXML = new JMenuItem(); + jMenuItemWindowXML.setText("XML"); + jMenuItemWindowXML.setMnemonic('X'); + jMenuItemWindowXML.setEnabled(false); + jMenuItemWindowXML.addActionListener(this); + } + return jMenuItemWindowXML; + } + + /** + This method initializes jMenuItemWindowPreferences + + @return javax.swing.JMenuItem + + */ + private JMenuItem getJMenuItemWindowPreferences() { + if (jMenuItemWindowPreferences == null) { + jMenuItemWindowPreferences = new JMenuItem(); + jMenuItemWindowPreferences.setText("Preferences"); + jMenuItemWindowPreferences.setMnemonic('P'); + jMenuItemWindowPreferences.setEnabled(false); + jMenuItemWindowPreferences.addActionListener(this); + } + return jMenuItemWindowPreferences; + } + + /** + This method initializes jMenuItemHelpContents + + @return javax.swing.JMenuItem + + */ + private JMenuItem getJMenuItemHelpContents() { + if (jMenuItemHelpContents == null) { + jMenuItemHelpContents = new JMenuItem(); + jMenuItemHelpContents.setText("Contents"); + jMenuItemHelpContents.setMnemonic('C'); + jMenuItemHelpContents.setEnabled(false); + jMenuItemHelpContents.addActionListener(this); + jMenuItemHelpContents.setVisible(false); + } + return jMenuItemHelpContents; + } + + /** + This method initializes jMenuItemHelpIndex + + @return javax.swing.JMenuItem + + */ + private JMenuItem getJMenuItemHelpIndex() { + if (jMenuItemHelpIndex == null) { + jMenuItemHelpIndex = new JMenuItem(); + jMenuItemHelpIndex.setText("Index"); + jMenuItemHelpIndex.setMnemonic('I'); + jMenuItemHelpIndex.setEnabled(false); + jMenuItemHelpIndex.addActionListener(this); + jMenuItemHelpIndex.setVisible(false); + } + return jMenuItemHelpIndex; + } + + /** + This method initializes jMenuItemHelpSearch + + @return javax.swing.JMenuItem + + */ + private JMenuItem getJMenuItemHelpSearch() { + if (jMenuItemHelpSearch == null) { + jMenuItemHelpSearch = new JMenuItem(); + jMenuItemHelpSearch.setText("Search"); + jMenuItemHelpSearch.setMnemonic('S'); + jMenuItemHelpSearch.setEnabled(false); + jMenuItemHelpSearch.addActionListener(this); + jMenuItemHelpSearch.setVisible(false); + } + return jMenuItemHelpSearch; + } + + /** + * This method initializes jToolBar + * + * @return javax.swing.JToolBar + */ + // private JToolBar getJToolBarFile() { + // if (jToolBarFile == null) { + // jToolBarFile = new JToolBar(); + // jToolBarFile.setFloatable(false); + // } + // return jToolBarFile; + // } + /** + * This method initializes jToolBarEdit + * + * @return javax.swing.JToolBar + */ + // private JToolBar getJToolBarEdit() { + // if (jToolBarEdit == null) { + // jToolBarEdit = new JToolBar(); + // jToolBarEdit.setFloatable(false); + // } + // return jToolBarEdit; + // } + /** + * This method initializes jMenuItemToolsInstallPackage + * + * @return javax.swing.JMenuItem + */ + private JMenuItem getJMenuItemProjectInstallPackage() { + if (jMenuItemProjectInstallPackage == null) { + jMenuItemProjectInstallPackage = new JMenuItem(); + jMenuItemProjectInstallPackage.setText("Install Distribution Package"); + jMenuItemProjectInstallPackage.setMnemonic('I'); + jMenuItemProjectInstallPackage.setEnabled(false); + jMenuItemProjectInstallPackage.addActionListener(this); + } + return jMenuItemProjectInstallPackage; + } + + /** + * This method initializes jMenuItemToolsUpdatePackage + * + * @return javax.swing.JMenuItem + */ + private JMenuItem getJMenuItemProjectUpdatePackage() { + if (jMenuItemProjectUpdatePackage == null) { + jMenuItemProjectUpdatePackage = new JMenuItem(); + jMenuItemProjectUpdatePackage.setText("Update Disstribution Package"); + jMenuItemProjectUpdatePackage.setMnemonic('U'); + jMenuItemProjectUpdatePackage.setEnabled(false); + jMenuItemProjectUpdatePackage.addActionListener(this); + } + return jMenuItemProjectUpdatePackage; + } + + /** + * This method initializes jMenuItemRemovePackage + * + * @return javax.swing.JMenuItem + */ + private JMenuItem getJMenuItemProjectRemovePackage() { + if (jMenuItemProjectRemovePackage == null) { + jMenuItemProjectRemovePackage = new JMenuItem(); + jMenuItemProjectRemovePackage.setText("Remove Distribution Package"); + jMenuItemProjectRemovePackage.setMnemonic('R'); + jMenuItemProjectRemovePackage.setEnabled(false); + jMenuItemProjectRemovePackage.addActionListener(this); + } + return jMenuItemProjectRemovePackage; + } + + /* (non-Javadoc) + * @see org.tianocore.packaging.common.ui.IFrame#main(java.lang.String[]) + * + * Main class, start the GUI + * + */ + public static void main(String[] args) { + FrameworkWizardUI module = new FrameworkWizardUI(); + module.setVisible(true); + } + + /** + This is the default constructor + + **/ + public FrameworkWizardUI() { + super(); + init(); + } + + /** + This method initializes this + + + **/ + private void init() { + // + // Set current workspace and check + // Check if exists WORKSPACE + // + // + Workspace.setCurrentWorkspace(System.getenv("WORKSPACE")); + if (!Workspace.checkCurrentWorkspace()) { + JOptionPane.showConfirmDialog(null, "Workspace is not setup correctly. Please setup first.", "Warning", + JOptionPane.DEFAULT_OPTION, JOptionPane.WARNING_MESSAGE); + this.dispose(); + System.exit(0); + } + + this.setSize(DataType.MAIN_FRAME_PREFERRED_SIZE_WIDTH, DataType.MAIN_FRAME_PREFERRED_SIZE_HEIGHT); + this.setResizable(true); + this.setJMenuBar(getjJMenuBar()); + this.addComponentListener(this); + this.getCompontentsFromFrameworkDatabase(); + this.setContentPane(getJContentPane()); + this.setTitle(windowTitle + "- [" + Workspace.getCurrentWorkspace() + "]"); + this.setExitType(1); + // + // max the window + // + this.setExtendedState(JFrame.MAXIMIZED_BOTH); + } + + /** + This method initializes jContentPane + + @return javax.swing.JPanel jContentPane + + **/ + private JPanel getJContentPane() { + if (jContentPane == null) { + jContentPane = new JPanel(); + jContentPane.setLayout(null); + jContentPane.add(getJPanelOperation(), null); + jContentPane.add(getJSplitPane(), 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) { + // + // Operations of Menu + // + if (arg0.getSource() == jMenuItemFileNew) { + this.fileNew(); + } + + if (arg0.getSource() == jMenuItemFileOpen) { + this.open(); + } + + if (arg0.getSource() == jMenuItemFileClose) { + this.close(); + } + + if (arg0.getSource() == jMenuItemFileCloseAll) { + this.closeAll(); + } + + if (arg0.getSource() == jMenuItemFileSave) { + this.save(); + } + + if (arg0.getSource() == jMenuItemFileSaveAs) { + this.saveAs(); + } + + if (arg0.getSource() == jMenuItemFileSaveAll) { + this.saveAll(); + } + + if (arg0.getSource() == jMenuItemFileExit) { + this.exit(); + } + + if (arg0.getSource() == jMenuItemProjectChangeWorkspace) { + changeWorkspace(); + } + + if (arg0.getSource() == jMenuItemToolsClone) { + cloneItem(); + } + + if (arg0.getSource() == jMenuItemHelpAbout) { + About a = new About(this, true); + int result = a.showDialog(); + if (result == DataType.RETURN_TYPE_OK) { + a.dispose(); + } + } + } + + /** + Create an empty tree if no file is open + + **/ + private void makeEmptyTree() { + // Make root + dmtnRoot = new IDefaultMutableTreeNode("WORKSPACE", IDefaultMutableTreeNode.WORKSPACE, -1); + + // Make Module Description + dmtnModuleDescription = new IDefaultMutableTreeNode("ModuleDescription", IDefaultMutableTreeNode.MODULE, -1); + + if (this.vModuleList.size() > 0) { + for (int index = 0; index < this.vModuleList.size(); index++) { + dmtnModuleDescription.add(new IDefaultMutableTreeNode(this.vModuleList.elementAt(index).getName(), + IDefaultMutableTreeNode.MSA_HEADER, false, + this.vModuleList.elementAt(index))); + } + } + + // Make Package Description + dmtnPackageDescription = new IDefaultMutableTreeNode("PackageDescription", IDefaultMutableTreeNode.PACKAGE, -1); + if (this.vPackageList.size() > 0) { + for (int index = 0; index < this.vPackageList.size(); index++) { + dmtnPackageDescription.add(new IDefaultMutableTreeNode(this.vPackageList.elementAt(index).getName(), + IDefaultMutableTreeNode.SPD_HEADER, false, + this.vPackageList.elementAt(index))); + } + } + + // Make Platform Description + dmtnPlatformDescription = new IDefaultMutableTreeNode("PlatformDescription", IDefaultMutableTreeNode.PLATFORM, + -1); + if (this.vPlatformList.size() > 0) { + for (int index = 0; index < this.vPlatformList.size(); index++) { + dmtnPlatformDescription.add(new IDefaultMutableTreeNode(this.vPlatformList.elementAt(index).getName(), + IDefaultMutableTreeNode.FPD_PLATFORMHEADER, + false, this.vPlatformList.elementAt(index))); + } + } + + dmtnRoot.add(dmtnModuleDescription); + dmtnRoot.add(dmtnPackageDescription); + dmtnRoot.add(dmtnPlatformDescription); + iTree = new ITree(dmtnRoot); + iTree.addMouseListener(this); + jScrollPaneTree.setViewportView(iTree); + } + + /* (non-Javadoc) + * @see java.awt.event.WindowListener#windowClosing(java.awt.event.WindowEvent) + * + * Override windowClosing to popup warning message to confirm quit + * + */ + public void windowClosing(WindowEvent arg0) { + this.exit(); + } + + /* (non-Javadoc) + * @see java.awt.event.MouseListener#mouseClicked(java.awt.event.MouseEvent) + * + * Override mouseClicked to check if need display popup menu + * + */ + public void mouseClicked(MouseEvent arg0) { + if (arg0.getButton() == MouseEvent.BUTTON1) { + } + if (arg0.getButton() == MouseEvent.BUTTON3) { + } + // + // When double click + // + if (arg0.getClickCount() == 2) { + doubleClickModuleTreeNode(); + } + } + + 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 + } + + /** + Remove all Internal Frame of Module Desktop Pane + + **/ + private void cleanDesktopPaneModule() { + if (jDesktopPaneModule != null) { + JInternalFrame[] iif = this.jDesktopPaneModule.getAllFrames(); + for (int index = 0; index < iif.length; index++) { + iif[index].dispose(); + } + } + } + + /** + Remove all Internal Frame of package Desktop Pane + + **/ + private void cleanDesktopPanePackage() { + if (jDesktopPanePlatform != null) { + JInternalFrame[] iif = this.jDesktopPanePackage.getAllFrames(); + for (int index = 0; index < iif.length; index++) { + iif[index].dispose(); + } + } + } + + /** + Remove all Internal Frame of platform Desktop Pane + + **/ + private void cleanDesktopPanePlatform() { + if (jDesktopPanePlatform != null) { + JInternalFrame[] iif = this.jDesktopPanePlatform.getAllFrames(); + for (int index = 0; index < iif.length; index++) { + iif[index].dispose(); + } + } + } + + /** + Remove all Internal Frame of all Desktop Panes + + **/ + private void cleanDesktopPane() { + cleanDesktopPaneModule(); + cleanDesktopPanePackage(); + cleanDesktopPanePlatform(); + } + + /** + Set file filter as input ext + + @param ext + @return + + **/ + private int getNewFilePath(String ext) { + JFileChooser fc = new JFileChooser(Workspace.getCurrentWorkspace()); + fc.setAcceptAllFileFilterUsed(false); + fc.addChoosableFileFilter(new IFileFilter(ext)); + return fc.showSaveDialog(new JPanel()); + } + + /** + Open Module + + @param path input file path + + **/ + private void openModule(String path) { + ModuleSurfaceAreaDocument.ModuleSurfaceArea msa = null; + try { + msa = OpenFile.openMsaFile(path); + } catch (IOException e) { + Log.err("Open Module Surface Area " + path, e.getMessage()); + return; + } catch (XmlException e) { + Log.err("Open Module Surface Area " + path, e.getMessage()); + return; + } catch (Exception e) { + Log.err("Open Module Surface Area " + path, "Invalid file type"); + return; + } + Identification id = new Identification(msa.getMsaHeader().getModuleName(), msa.getMsaHeader().getGuidValue(), + msa.getMsaHeader().getVersion(), path); + // + // Generate module id + // + PackageIdentification pid = wt.getPackageIdByModuleId(id); + if (pid != null) { + // + // To judge if the module existed in vModuleList + // If not, add it to vModuleList + // + boolean isFind = false; + for (int index = 0; index < vModuleList.size(); index++) { + if (vModuleList.elementAt(index).equals(id)) { + isFind = true; + break; + } + } + if (!isFind) { + vModuleList.addElement(new ModuleIdentification(id, pid)); + // + // Add new MsaHeader node to the tree + // + IDefaultMutableTreeNode node = new IDefaultMutableTreeNode(vModuleList.lastElement().getName(), + IDefaultMutableTreeNode.MSA_HEADER, true, + vModuleList.lastElement()); + iTree.addNode(dmtnModuleDescription, node); + } + } else { + // + // The module is not in existing packages + // + Log.err("The module hasn't been added to any package of current workspace!"); + return; + } + + // Make the node selected + // + iTree.setSelectionPath(iTree.getPathOfNode(iTree.getNodeById(this.dmtnModuleDescription, id, + IDefaultMutableTreeNode.MSA_HEADER))); + // + // Update opening Module list information + // + if (!openingModuleList.existsModule(id)) { + // + // Insert sub node of module + // + insertModuleTreeNode(id); + iTree.getSelectNode().setOpening(true); + + // + // Update opening module list + // + openingModuleList.insertToOpeningModuleList(id, msa); + openingModuleList.setTreePathById(id, iTree.getSelectionPath()); + } + // + // Show msa header in editor panel + // + showModuleElement(IDefaultMutableTreeNode.MSA_HEADER, openingModuleList.getOpeningModuleById(id)); + this.currentOpeningModuleIndex = openingModuleList.findIndexOfListById(id); + } + + /** + Open Package + + @param path input file path + + **/ + private void openPackage(String path) { + PackageSurfaceAreaDocument.PackageSurfaceArea spd = null; + try { + spd = OpenFile.openSpdFile(path); + } catch (IOException e) { + Log.err("Open Package Surface Area " + path, e.getMessage()); + return; + } catch (XmlException e) { + Log.err("Open Package Surface Area " + path, e.getMessage()); + return; + } catch (Exception e) { + Log.err("Open Package Surface Area " + path, "Invalid file type"); + return; + } + Identification id = new Identification(spd.getSpdHeader().getPackageName(), spd.getSpdHeader().getGuidValue(), + spd.getSpdHeader().getVersion(), path); + // + // To judge if the package existed in vPackageList + // If not, add it to vPackageList + // + boolean isFind = false; + for (int index = 0; index < vPackageList.size(); index++) { + if (vPackageList.elementAt(index).equals(id)) { + isFind = true; + break; + } + } + if (!isFind) { + // + // The module is not in existing packages + // + Log.err("The package hasn't been added to current workspace!"); + return; + } + + // + // Make the node selected + // + iTree.setSelectionPath(iTree.getPathOfNode(iTree.getNodeById(this.dmtnPackageDescription, id, + IDefaultMutableTreeNode.SPD_HEADER))); + // + // Update opening package list information + // + if (!openingPackageList.existsPackage(id)) { + // + // Insert sub node of module + // + insertPackageTreeNode(id); + iTree.getSelectNode().setOpening(true); + + // + // Update opening module list + // + openingPackageList.insertToOpeningPackageList(id, spd); + openingPackageList.setTreePathById(id, iTree.getSelectionPath()); + } + // + // Show spd header in editor panel + // + showPackageElement(IDefaultMutableTreeNode.SPD_HEADER, openingPackageList.getOpeningPackageById(id)); + this.currentOpeningPackageIndex = openingPackageList.findIndexOfListById(id); + } + + /** + Open Package + + @param path input file path + + **/ + private void openPlatform(String path) { + PlatformSurfaceAreaDocument.PlatformSurfaceArea fpd = null; + try { + fpd = OpenFile.openFpdFile(path); + } catch (IOException e) { + Log.err("Open Platform Surface Area " + path, e.getMessage()); + return; + } catch (XmlException e) { + Log.err("Open Platform Surface Area " + path, e.getMessage()); + return; + } catch (Exception e) { + Log.err("Open Platform Surface Area " + path, "Invalid file type"); + return; + } + Identification id = new Identification(fpd.getPlatformHeader().getPlatformName(), fpd.getPlatformHeader() + .getGuidValue(), + fpd.getPlatformHeader().getVersion(), path); + // + // To judge if the platform existed in vPlatformList + // If not, add it to vPlatformList + // + boolean isFind = false; + for (int index = 0; index < vPlatformList.size(); index++) { + if (vPlatformList.elementAt(index).equals(id)) { + isFind = true; + break; + } + } + if (!isFind) { + // + // The module is not in existing packages + // + Log.err("The platform hasn't been added to current workspace!"); + return; + } + + // + // Make the node selected + // + iTree.setSelectionPath(iTree.getPathOfNode(iTree.getNodeById(this.dmtnPlatformDescription, id, + IDefaultMutableTreeNode.FPD_PLATFORMHEADER))); + // + // Update opening package list information + // + if (!openingPlatformList.existsPlatform(id)) { + // + // Insert sub node of module + // + insertPlatformTreeNode(id); + iTree.getSelectNode().setOpening(true); + + // + // Update opening module list + // + openingPlatformList.insertToOpeningPlatformList(id, fpd); + openingPlatformList.setTreePathById(id, iTree.getSelectionPath()); + } + // + // Show fpd header in editor panel + // + showPlatformElement(IDefaultMutableTreeNode.FPD_PLATFORMHEADER, openingPlatformList.getOpeningPlatformById(id)); + this.currentOpeningPlatformIndex = openingPlatformList.findIndexOfListById(id); + } + + /** + Save module + + **/ + private void saveModule(int index) { + OpeningModuleType omt = openingModuleList.getOpeningModuleByIndex(index); + if (omt.isNew()) { + if (getNewFilePath(DataType.MODULE_SURFACE_AREA_EXT) != JFileChooser.APPROVE_OPTION) { + return; + } + } + try { + SaveFile.saveMsaFile(omt.getId().getPath(), omt.getXmlMsa()); + openingModuleList.setNew(omt.getId(), false); + openingModuleList.setModuleSaved(omt.getId(), true); + } catch (Exception e) { + Log.err("Save Module", e.getMessage()); + } + } + + /** + Save package + + **/ + private void savePackage(int index) { + OpeningPackageType opt = openingPackageList.getOpeningPackageByIndex(index); + if (opt.isNew()) { + if (getNewFilePath(DataType.PACKAGE_SURFACE_AREA_EXT) != JFileChooser.APPROVE_OPTION) { + return; + } + } + try { + SaveFile.saveSpdFile(opt.getId().getPath(), opt.getXmlSpd()); + openingPackageList.setNew(opt.getId(), false); + openingPackageList.setPackageSaved(opt.getId(), true); + } catch (Exception e) { + Log.err("Save Package", e.getMessage()); + } + } + + /** + Save platform + + **/ + private void savePlatform(int index) { + OpeningPlatformType opt = openingPlatformList.getOpeningPlatformByIndex(index); + if (opt.isNew()) { + if (getNewFilePath(DataType.PACKAGE_SURFACE_AREA_EXT) != JFileChooser.APPROVE_OPTION) { + return; + } + } + try { + SaveFile.saveFpdFile(opt.getId().getPath(), opt.getXmlFpd()); + openingPlatformList.setNew(opt.getId(), false); + openingPlatformList.setPlatformSaved(opt.getId(), true); + } catch (Exception e) { + Log.err("Save Package", e.getMessage()); + } + } + + 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) { + this.jSplitPane.setSize(this.getWidth() - DataType.MAIN_FRAME_WIDTH_SPACING, + this.getHeight() - DataType.MAIN_FRAME_HEIGHT_SPACING); + this.jSplitPane.validate(); + resizeDesktopPanel(); + } + + public void componentShown(ComponentEvent arg0) { + // TODO Auto-generated method stub + + } + + /** + Resize JDesktopPanel + + */ + private void resizeDesktopPanel() { + resizeDesktopPanel(this.jDesktopPaneModule); + resizeDesktopPanel(this.jDesktopPanePackage); + resizeDesktopPanel(this.jDesktopPanePlatform); + } + + /** + Resize JDesktopPanel + + */ + private void resizeDesktopPanel(JDesktopPane jdk) { + JInternalFrame[] iif = jdk.getAllFrames(); + for (int index = 0; index < iif.length; index++) { + iif[index].setSize(jdk.getWidth(), jdk.getHeight()); + } + } + + private void getCompontentsFromFrameworkDatabase() { + this.vModuleList = wt.getAllModules(); + this.vPackageList = wt.getAllPackages(); + this.vPlatformList = wt.getAllPlatforms(); + } + + private void insertModuleTreeNode(Identification id) { + iTree.addNode(new IDefaultMutableTreeNode("Module Definitions", IDefaultMutableTreeNode.MSA_MODULEDEFINITIONS, + true, id)); + iTree.addNode(new IDefaultMutableTreeNode("Library Class Definitions", + IDefaultMutableTreeNode.MSA_LIBRARYCLASSDEFINITIONS, true, id)); + iTree.addNode(new IDefaultMutableTreeNode("Source Files", IDefaultMutableTreeNode.MSA_SOURCEFILES, true, id)); + iTree.addNode(new IDefaultMutableTreeNode("Package Dependencies", + IDefaultMutableTreeNode.MSA_PACKAGEDEPENDENCIES, true, id)); + iTree.addNode(new IDefaultMutableTreeNode("Protocols", IDefaultMutableTreeNode.MSA_PROTOCOLS, true, id)); + iTree.addNode(new IDefaultMutableTreeNode("Events", IDefaultMutableTreeNode.MSA_EVENTS, true, id)); + iTree.addNode(new IDefaultMutableTreeNode("Hobs", IDefaultMutableTreeNode.MSA_HOBS, true, id)); + iTree.addNode(new IDefaultMutableTreeNode("Ppis", IDefaultMutableTreeNode.MSA_PPIS, true, id)); + iTree.addNode(new IDefaultMutableTreeNode("Variables", IDefaultMutableTreeNode.MSA_VARIABLES, true, id)); + iTree.addNode(new IDefaultMutableTreeNode("Boot Modes", IDefaultMutableTreeNode.MSA_BOOTMODES, true, id)); + iTree.addNode(new IDefaultMutableTreeNode("System Tables", IDefaultMutableTreeNode.MSA_SYSTEMTABLES, true, id)); + iTree.addNode(new IDefaultMutableTreeNode("Data Hubs", IDefaultMutableTreeNode.MSA_DATAHUBS, true, id)); + iTree.addNode(new IDefaultMutableTreeNode("Hii Packages", IDefaultMutableTreeNode.MSA_HIIPACKAGES, true, id)); + iTree.addNode(new IDefaultMutableTreeNode("Guids", IDefaultMutableTreeNode.MSA_GUIDS, true, id)); + iTree.addNode(new IDefaultMutableTreeNode("Externs", IDefaultMutableTreeNode.MSA_EXTERNS, true, id)); + iTree.addNode(new IDefaultMutableTreeNode("PcdCoded", IDefaultMutableTreeNode.MSA_PCDS, true, id)); + } + + private void insertPackageTreeNode(Identification id) { + iTree.addNode(new IDefaultMutableTreeNode("Package Definitions", + IDefaultMutableTreeNode.SPD_PACKAGEDEFINITIONS, true, id)); + iTree.addNode(new IDefaultMutableTreeNode("Library Class Declarations", + IDefaultMutableTreeNode.SPD_LIBRARYCLASSDECLARATIONS, true, id)); + iTree.addNode(new IDefaultMutableTreeNode("Msa Files", IDefaultMutableTreeNode.SPD_MSAFILES, false, id)); + iTree.addNode(new IDefaultMutableTreeNode("Package Headers", IDefaultMutableTreeNode.SPD_PACKAGEHEADERS, true, + id)); + iTree.addNode(new IDefaultMutableTreeNode("Guid Declarations", IDefaultMutableTreeNode.SPD_GUIDDECLARATIONS, + true, id)); + iTree.addNode(new IDefaultMutableTreeNode("Protocol Declarations", + IDefaultMutableTreeNode.SPD_PROTOCOLDECLARATIONS, true, id)); + iTree.addNode(new IDefaultMutableTreeNode("Ppi Declarations", IDefaultMutableTreeNode.SPD_PPIDECLARATIONS, + true, id)); + iTree.addNode(new IDefaultMutableTreeNode("Pcd Declarations", IDefaultMutableTreeNode.SPD_PCDDECLARATIONS, + true, id)); + } + + private void insertPlatformTreeNode(Identification id) { + iTree.addNode(new IDefaultMutableTreeNode("Platform Definitions", IDefaultMutableTreeNode.FPD_PLATFORMDEFINITIONS, true, id)); + iTree.addNode(new IDefaultMutableTreeNode("Flash", IDefaultMutableTreeNode.FPD_FLASH, true, id)); + iTree.addNode(new IDefaultMutableTreeNode("Framework Modules", IDefaultMutableTreeNode.FPD_FRAMEWORKMODULES, + true, id)); + iTree.addNode(new IDefaultMutableTreeNode("Pcd Dynamic Build Declarations", + IDefaultMutableTreeNode.FPD_PCDDYNAMICBUILDDECLARATIONS, true, id)); + iTree.addNode(new IDefaultMutableTreeNode("Build Options", IDefaultMutableTreeNode.FPD_BUILDOPTIONS, true, id)); + } + + /** + Operate when double click a tree node + + **/ + private void doubleClickModuleTreeNode() { + Identification id = iTree.getSelectNode().getId(); + int intCategory = iTree.getSelectCategory(); + String path = null; + // + // If the node is not opened yet + // Insert top level elements first + // + //if (intCategory == IDefaultMutableTreeNode.MSA_HEADER || intCategory == IDefaultMutableTreeNode.SPD_MSAFILES) { + if (intCategory == IDefaultMutableTreeNode.MSA_HEADER) { + + if (intCategory == IDefaultMutableTreeNode.MSA_HEADER) { + path = iTree.getSelectNode().getId().getPath(); + } + if (intCategory == IDefaultMutableTreeNode.SPD_MSAFILES) { + path = iTree.getSelectNode().getId().getPath(); + } + openModule(path); + return; + } + if (intCategory == IDefaultMutableTreeNode.SPD_HEADER) { + path = iTree.getSelectNode().getId().getPath(); + openPackage(path); + return; + } + if (intCategory == IDefaultMutableTreeNode.FPD_PLATFORMHEADER) { + path = iTree.getSelectNode().getId().getPath(); + openPlatform(path); + return; + } + // + // Show editor panel + // + if (intCategory >= IDefaultMutableTreeNode.MSA_HEADER && intCategory < IDefaultMutableTreeNode.SPD_HEADER) { + showModuleElement(intCategory, openingModuleList.getOpeningModuleById(id)); + this.currentOpeningModuleIndex = openingModuleList.findIndexOfListById(id); + } + if (intCategory >= IDefaultMutableTreeNode.SPD_HEADER + && intCategory < IDefaultMutableTreeNode.FPD_PLATFORMHEADER) { + showPackageElement(intCategory, openingPackageList.getOpeningPackageById(id)); + this.currentOpeningPackageIndex = openingPackageList.findIndexOfListById(id); + } + if (intCategory >= IDefaultMutableTreeNode.FPD_PLATFORMHEADER) { + showPlatformElement(intCategory, openingPlatformList.getOpeningPlatformById(id)); + this.currentOpeningPlatformIndex = openingPlatformList.findIndexOfListById(id); + } + } + + /** + Show content of editor panel via selected element + + @param elementType + @param fpd + + **/ + private void showPlatformElement(int elementType, OpeningPlatformType fpd) { + this.cleanDesktopPanePlatform(); + switch (elementType) { + case IDefaultMutableTreeNode.FPD_PLATFORMDEFINITIONS: + FpdPlatformDefs frmFpdPlatformDefs = new FpdPlatformDefs(fpd.getXmlFpd()); + getJDesktopPanePlatform().add(frmFpdPlatformDefs, 1); + break; + case IDefaultMutableTreeNode.FPD_PLATFORMHEADER: + FpdHeader frmFpdHeader = new FpdHeader(fpd.getXmlFpd()); + getJDesktopPanePlatform().add(frmFpdHeader, 1); + break; + case IDefaultMutableTreeNode.FPD_FLASH: + FpdFlash frmFpdFlash = new FpdFlash(fpd.getXmlFpd()); + getJDesktopPanePlatform().add(frmFpdFlash, 1); + break; + case IDefaultMutableTreeNode.FPD_FRAMEWORKMODULES: + FpdFrameworkModules frmFpdFrameworkModules = new FpdFrameworkModules(fpd.getXmlFpd()); + getJDesktopPanePlatform().add(frmFpdFrameworkModules, 1); + break; + case IDefaultMutableTreeNode.FPD_PCDDYNAMICBUILDDECLARATIONS: + FpdDynamicPcdBuildDefinitions frmFpdDynamicPcdBuildDefinitions = new FpdDynamicPcdBuildDefinitions( + fpd + .getXmlFpd()); + getJDesktopPanePlatform().add(frmFpdDynamicPcdBuildDefinitions, 1); + break; + case IDefaultMutableTreeNode.FPD_BUILDOPTIONS: + FpdBuildOptions frmFpdBuildOptions = new FpdBuildOptions(fpd.getXmlFpd()); + getJDesktopPanePlatform().add(frmFpdBuildOptions, 1); + break; + } + this.jTabbedPaneEditor.setSelectedIndex(2); + resizeDesktopPanel(); + } + + /** + Show content of editor panel via selected element + + @param elementType + @param spd + + */ + private void showPackageElement(int elementType, OpeningPackageType spd) { + this.cleanDesktopPanePackage(); + Tools.dirForNewSpd = spd.getId().getPath(); + switch (elementType) { + case IDefaultMutableTreeNode.SPD_HEADER: + SpdHeader frmSpdHeader = new SpdHeader(spd.getXmlSpd()); + getJDesktopPanePackage().add(frmSpdHeader, 1); + break; + case IDefaultMutableTreeNode.SPD_PACKAGEDEFINITIONS: + SpdPackageDefinitions frmSpdPackageDefinitions = new SpdPackageDefinitions(spd.getXmlSpd()); + getJDesktopPanePackage().add(frmSpdPackageDefinitions, 1); + break; + case IDefaultMutableTreeNode.SPD_LIBRARYCLASSDECLARATIONS: + SpdLibClassDecls frmSlcd = new SpdLibClassDecls(spd.getXmlSpd()); + getJDesktopPanePackage().add(frmSlcd, 1); + break; + case IDefaultMutableTreeNode.SPD_MSAFILES: + SpdMsaFiles frmSmf = new SpdMsaFiles(spd.getXmlSpd()); + getJDesktopPanePackage().add(frmSmf, 1); + break; + case IDefaultMutableTreeNode.SPD_PACKAGEHEADERS: + SpdPackageHeaders frmSph = new SpdPackageHeaders(spd.getXmlSpd()); + getJDesktopPanePackage().add(frmSph, 1); + break; + case IDefaultMutableTreeNode.SPD_GUIDDECLARATIONS: + SpdGuidDecls frmSgd = new SpdGuidDecls(spd.getXmlSpd()); + getJDesktopPanePackage().add(frmSgd, 1); + break; + case IDefaultMutableTreeNode.SPD_PROTOCOLDECLARATIONS: + SpdProtocolDecls frmSprod = new SpdProtocolDecls(spd.getXmlSpd()); + getJDesktopPanePackage().add(frmSprod, 1); + break; + case IDefaultMutableTreeNode.SPD_PPIDECLARATIONS: + SpdPpiDecls frmSppid = new SpdPpiDecls(spd.getXmlSpd()); + getJDesktopPanePackage().add(frmSppid, 1); + break; + case IDefaultMutableTreeNode.SPD_PCDDECLARATIONS: + SpdPcdDefs frmSpcdd = new SpdPcdDefs(spd.getXmlSpd()); + getJDesktopPanePackage().add(frmSpcdd, 1); + break; + } + this.jTabbedPaneEditor.setSelectedIndex(1); + resizeDesktopPanel(); + } + + /** + Show content of editor panel via selected element + + @param elementType + @param msa + + */ + private void showModuleElement(int elementType, OpeningModuleType msa) { + this.cleanDesktopPaneModule(); + switch (elementType) { + case IDefaultMutableTreeNode.MSA_HEADER: + MsaHeader frmMsaHeader = new MsaHeader(msa); + getJDesktopPaneModule().add(frmMsaHeader, 1); + break; + case IDefaultMutableTreeNode.MSA_MODULEDEFINITIONS: + ModuleDefinitions frmMd = new ModuleDefinitions(msa); + getJDesktopPaneModule().add(frmMd, 1); + break; + case IDefaultMutableTreeNode.MSA_LIBRARYCLASSDEFINITIONS: + ModuleLibraryClassDefinitions frmMlcd = new ModuleLibraryClassDefinitions(msa); + getJDesktopPaneModule().add(frmMlcd, 1); + break; + case IDefaultMutableTreeNode.MSA_PACKAGEDEPENDENCIES: + ModulePackageDependencies frmMpd = new ModulePackageDependencies(msa); + getJDesktopPaneModule().add(frmMpd, 1); + break; + case IDefaultMutableTreeNode.MSA_SOURCEFILES: + ModuleSourceFiles frmMsf = new ModuleSourceFiles(msa); + getJDesktopPaneModule().add(frmMsf, 1); + break; + case IDefaultMutableTreeNode.MSA_PROTOCOLS: + ModuleProtocols frmMp = new ModuleProtocols(msa); + getJDesktopPaneModule().add(frmMp, 1); + break; + case IDefaultMutableTreeNode.MSA_EVENTS: + ModuleEvents frmMe = new ModuleEvents(msa); + getJDesktopPaneModule().add(frmMe, 1); + break; + case IDefaultMutableTreeNode.MSA_HOBS: + ModuleHobs frmMh = new ModuleHobs(msa); + getJDesktopPaneModule().add(frmMh, 1); + break; + case IDefaultMutableTreeNode.MSA_PPIS: + ModulePpis frmMpp = new ModulePpis(msa); + getJDesktopPaneModule().add(frmMpp, 1); + break; + case IDefaultMutableTreeNode.MSA_VARIABLES: + ModuleVariables frmMv = new ModuleVariables(msa); + getJDesktopPaneModule().add(frmMv, 1); + break; + case IDefaultMutableTreeNode.MSA_BOOTMODES: + ModuleBootModes frmMbm = new ModuleBootModes(msa); + getJDesktopPaneModule().add(frmMbm, 1); + break; + case IDefaultMutableTreeNode.MSA_SYSTEMTABLES: + ModuleSystemTables frmMst = new ModuleSystemTables(msa); + getJDesktopPaneModule().add(frmMst, 1); + break; + case IDefaultMutableTreeNode.MSA_DATAHUBS: + ModuleDataHubs frmMdh = new ModuleDataHubs(msa); + getJDesktopPaneModule().add(frmMdh, 1); + break; + case IDefaultMutableTreeNode.MSA_HIIPACKAGES: + ModuleHiiPackages frmMf = new ModuleHiiPackages(msa); + getJDesktopPaneModule().add(frmMf, 1); + break; + case IDefaultMutableTreeNode.MSA_GUIDS: + ModuleGuids frmGuid = new ModuleGuids(msa); + getJDesktopPaneModule().add(frmGuid, 1); + break; + case IDefaultMutableTreeNode.MSA_EXTERNS: + ModuleExterns frmMex = new ModuleExterns(msa); + getJDesktopPaneModule().add(frmMex, 1); + break; + case IDefaultMutableTreeNode.MSA_PCDS: + ModulePCDs frmPcd = new ModulePCDs(msa); + getJDesktopPaneModule().add(frmPcd, 1); + break; + } + this.jTabbedPaneEditor.setSelectedIndex(0); + resizeDesktopPanel(); + } + + // + // Define operations of menu + // + /** + New a file + + **/ + private void fileNew() { + int result = -1; + // + // Selece new file type + // + NewFileChooser nfc = new NewFileChooser(this, true); + result = nfc.showDialog(); + + if (result == DataType.RETURN_TYPE_CANCEL) { + nfc.dispose(); + return; + } else if (result == DataType.RETURN_TYPE_MODULE_SURFACE_AREA) { + // + // To new a module + // + SelectModuleBelong smb = new SelectModuleBelong(this, true, result); + result = smb.showDialog(); + + if (result == DataType.RETURN_TYPE_CANCEL) { + nfc.dispose(); + smb.dispose(); + return; + } else if (result == DataType.RETURN_TYPE_OK) { + PackageSurfaceAreaDocument.PackageSurfaceArea psa = null; + if (this.openingPackageList.existsPackage(smb.getMid().getPackageId())) { + psa = openingPackageList.getPackageSurfaceAreaFromId(smb.getMid().getPackageId()); + } + try { + wt.addModuleToPackage(smb.getMid(), psa); + } catch (IOException e) { + Log.err("Upddate MsaFiles of Package", e.getMessage()); + e.printStackTrace(); + return; + } catch (XmlException e) { + Log.err("Upddate MsaFiles of Package", e.getMessage()); + e.printStackTrace(); + return; + } catch (Exception e) { + Log.err("Upddate MsaFiles of Package", e.getMessage()); + e.printStackTrace(); + return; + } + this.openModule(smb.getMid().getPath()); + } + } else if (result == DataType.RETURN_TYPE_PACKAGE_SURFACE_AREA) { + // + // To new a package + // + SelectModuleBelong smb = new SelectModuleBelong(this, true, result); + result = smb.showDialog(); + + if (result == DataType.RETURN_TYPE_CANCEL) { + nfc.dispose(); + smb.dispose(); + return; + } else if (result == DataType.RETURN_TYPE_OK) { + try { + wt.addPackageToDatabase(smb.getPid()); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + vPackageList.addElement(smb.getPid()); + // + // Add new SpdHeader node to the tree + // + IDefaultMutableTreeNode node = new IDefaultMutableTreeNode(vPackageList.lastElement().getName(), + IDefaultMutableTreeNode.SPD_HEADER, true, + vPackageList.lastElement()); + iTree.addNode(dmtnPackageDescription, node); + this.openPackage(smb.getPid().getPath()); + } + } else if (result == DataType.RETURN_TYPE_PLATFORM_SURFACE_AREA) { + // + // To new a platform + // + SelectModuleBelong smb = new SelectModuleBelong(this, true, result); + result = smb.showDialog(); + + if (result == DataType.RETURN_TYPE_CANCEL) { + nfc.dispose(); + smb.dispose(); + return; + } else if (result == DataType.RETURN_TYPE_OK) { + try { + wt.addPlatformToDatabase(smb.getFid()); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + vPlatformList.addElement(smb.getFid()); + // + // Add new SpdHeader node to the tree + // + IDefaultMutableTreeNode node = new IDefaultMutableTreeNode(vPlatformList.lastElement().getName(), + IDefaultMutableTreeNode.FPD_PLATFORMHEADER, + true, vPlatformList.lastElement()); + iTree.addNode(dmtnPlatformDescription, node); + this.openPlatform(smb.getFid().getPath()); + } + } + } + + /** + Open a file + + **/ + private void open() { + JFileChooser fc = new JFileChooser(Workspace.getCurrentWorkspace()); + fc.setAcceptAllFileFilterUsed(false); + IFileFilter iffM = new IFileFilter(DataType.MODULE_SURFACE_AREA_EXT); + IFileFilter iffP = new IFileFilter(DataType.PACKAGE_SURFACE_AREA_EXT); + IFileFilter iffF = new IFileFilter(DataType.PLATFORM_SURFACE_AREA_EXT); + fc.addChoosableFileFilter(iffM); + fc.addChoosableFileFilter(iffP); + fc.addChoosableFileFilter(iffF); + fc.setFileFilter(iffM); + + int result = fc.showOpenDialog(new JPanel()); + + if (result == JFileChooser.APPROVE_OPTION) { + String path = fc.getSelectedFile().getPath(); + String match = path.substring(path.length() - 4); + if (match.equals(DataType.FILE_EXT_SEPARATOR + DataType.MODULE_SURFACE_AREA_EXT)) { + openModule(path); + } else if (match.equals(DataType.FILE_EXT_SEPARATOR + DataType.PACKAGE_SURFACE_AREA_EXT)) { + openPackage(path); + } else if (match.equals(DataType.FILE_EXT_SEPARATOR + DataType.PLATFORM_SURFACE_AREA_EXT)) { + openPlatform(path); + } + } + } + + /** + Close files + + **/ + private void close() { + switch (this.jTabbedPaneEditor.getSelectedIndex()) { + // + // Current is module + // + case 0: + if (this.currentOpeningModuleIndex > -1) { + if (!openingModuleList.getModuleSaved(currentOpeningModuleIndex)) { + int result = showSaveDialog(); + if (result == JOptionPane.YES_OPTION) { + this.saveAll(); + } + if (result == JOptionPane.NO_OPTION) { + // Do nothing + } + if (result == JOptionPane.CANCEL_OPTION) { + return; + } + } + iTree.removeNodeChildrenByPath(openingModuleList.getTreePathByIndex(currentOpeningModuleIndex)); + this.openingModuleList.removeFromOpeningModuleListByIndex(this.currentOpeningModuleIndex); + this.cleanDesktopPaneModule(); + this.currentOpeningModuleIndex = -1; + } + break; + // + // Current is package + // + case 1: + if (this.currentOpeningPackageIndex > -1) { + if (!openingPackageList.getPackageSaved(currentOpeningPackageIndex)) { + int result = showSaveDialog(); + if (result == JOptionPane.YES_OPTION) { + this.saveAll(); + } + if (result == JOptionPane.NO_OPTION) { + // Do nothing + } + if (result == JOptionPane.CANCEL_OPTION) { + return; + } + } + iTree.removeNodeChildrenByPath(openingPackageList.getTreePathByIndex(currentOpeningPackageIndex)); + this.openingPackageList.removeFromOpeningPackageListByIndex(this.currentOpeningPackageIndex); + this.cleanDesktopPanePackage(); + this.currentOpeningPackageIndex = -1; + } + break; + // + // Current is platform + // + case 2: + if (this.currentOpeningPlatformIndex > -1) { + if (!openingPlatformList.getPlatformSaved(currentOpeningPlatformIndex)) { + int result = showSaveDialog(); + if (result == JOptionPane.YES_OPTION) { + this.saveAll(); + } + if (result == JOptionPane.NO_OPTION) { + // Do nothing + } + if (result == JOptionPane.CANCEL_OPTION) { + return; + } + } + iTree.removeNodeChildrenByPath(openingPlatformList.getTreePathByIndex(currentOpeningPlatformIndex)); + this.openingPlatformList.removeFromOpeningPlatformListByIndex(this.currentOpeningPlatformIndex); + this.cleanDesktopPanePlatform(); + this.currentOpeningPlatformIndex = -1; + } + break; + } + } + + /** + Close all opening files and clean all showing internal frame + + **/ + private void closeAll() { + int result = -1; + if (!openingModuleList.isSaved() || !openingPackageList.isSaved() || !openingPlatformList.isSaved()) { + result = showSaveDialog(); + } + if (result == JOptionPane.YES_OPTION) { + this.saveAll(); + } + if (result == JOptionPane.NO_OPTION) { + // Do nothing + } + if (result == JOptionPane.CANCEL_OPTION) { + return; + } + this.cleanDesktopPane(); + this.getCompontentsFromFrameworkDatabase(); + openingModuleList.removeAllFromOpeningModuleList(); + openingPackageList.removeAllFromOpeningPackageList(); + openingPlatformList.removeAllFromOpeningPlatformList(); + this.makeEmptyTree(); + } + + /** + Save currentModule when press button OK + + **/ + private void save() { + switch (this.jTabbedPaneEditor.getSelectedIndex()) { + case 0: + if (this.currentOpeningModuleIndex > -1) { + saveModule(this.currentOpeningModuleIndex); + } + break; + case 1: + if (this.currentOpeningPackageIndex > -1) { + savePackage(this.currentOpeningPackageIndex); + } + break; + case 2: + if (this.currentOpeningPlatformIndex > -1) { + savePlatform(this.currentOpeningPlatformIndex); + } + break; + } + } + + private void saveAs() { + + } + + private void saveAll() { + // + // Save all modules + // + for (int index = 0; index < openingModuleList.size(); index++) { + if (!openingModuleList.getModuleSaved(index)) { + saveModule(index); + } + } + + // + // Save all packages + // + for (int index = 0; index < openingPackageList.size(); index++) { + if (!openingPackageList.getPackageSaved(index)) { + savePackage(index); + } + } + + // + // Save all platforms + // + for (int index = 0; index < openingPlatformList.size(); index++) { + if (!openingPlatformList.getPlatformSaved(index)) { + savePlatform(index); + } + } + } + + /** + To save changed items before exit. + + **/ + private void exit() { + int result = -1; + if (!openingModuleList.isSaved() || !openingPackageList.isSaved() || !openingPlatformList.isSaved()) { + result = showSaveDialog(); + } + if (result == JOptionPane.YES_OPTION) { + this.saveAll(); + } + if (result == JOptionPane.NO_OPTION) { + // Do nothing + } + if (result == JOptionPane.CANCEL_OPTION) { + return; + } + this.dispose(); + System.exit(0); + } + + /** + Switch current workspace to others + + **/ + private void changeWorkspace() { + SwitchWorkspace sw = new SwitchWorkspace(this, true); + int result = sw.showDialog(); + if (result == DataType.RETURN_TYPE_CANCEL) { + return; + } else if (result == DataType.RETURN_TYPE_OK) { + // + // Reinit whole window + // + closeAll(); + this.setTitle(windowTitle + "- [" + Workspace.getCurrentWorkspace() + "]"); + } + sw.dispose(); + } + + /** + Clone selected item + + **/ + private void cloneItem() { + int mode = -1; + + // + // Check if there is any item can be cloned + // + if (iTree.getSelectionPath() == null) { + Log.err("Please select a target to clone!"); + return; + } + int category = iTree.getSelectCategory(); + Identification id = iTree.getSelectNode().getId(); + if (category == IDefaultMutableTreeNode.MODULE || category == IDefaultMutableTreeNode.PACKAGE + || category == IDefaultMutableTreeNode.PLATFORM) { + Log.err("Please select a target to clone!"); + return; + } + + if (category == IDefaultMutableTreeNode.WORKSPACE) { + mode = DataType.RETURN_TYPE_WORKSPACE; + id = null; + } + if (category >= IDefaultMutableTreeNode.MSA_HEADER && category < IDefaultMutableTreeNode.SPD_HEADER) { + mode = DataType.RETURN_TYPE_MODULE_SURFACE_AREA; + } + if (category >= IDefaultMutableTreeNode.SPD_HEADER && category < IDefaultMutableTreeNode.FPD_PLATFORMHEADER) { + mode = DataType.RETURN_TYPE_PACKAGE_SURFACE_AREA; + } + if (category >= IDefaultMutableTreeNode.FPD_PLATFORMHEADER) { + mode = DataType.RETURN_TYPE_PLATFORM_SURFACE_AREA; + } + Clone c = new Clone(this, true, mode, id); + int result = c.showDialog(); + + if (result == DataType.RETURN_TYPE_CANCEL) { + c.dispose(); + } + if (result == DataType.RETURN_TYPE_WORKSPACE) { + Tools.showInformationMessage("Workspace Clone Finished"); + } + if (result == DataType.RETURN_TYPE_MODULE_SURFACE_AREA) { + Tools.showInformationMessage("Module Surface Area Clone Finished"); + vModuleList.addElement(c.getMid()); + // + // Add new MsaHeader node to the tree + // + IDefaultMutableTreeNode node = new IDefaultMutableTreeNode(vModuleList.lastElement().getName(), + IDefaultMutableTreeNode.MSA_HEADER, true, + vModuleList.lastElement()); + iTree.addNode(dmtnModuleDescription, node); + } + if (result == DataType.RETURN_TYPE_PACKAGE_SURFACE_AREA) { + Tools.showInformationMessage("Package Surface Area Clone Finished"); + vPackageList.addElement(c.getPid()); + // + // Add new SpdHeader node to the tree + // + IDefaultMutableTreeNode node = new IDefaultMutableTreeNode(vPackageList.lastElement().getName(), + IDefaultMutableTreeNode.SPD_HEADER, true, + vPackageList.lastElement()); + iTree.addNode(dmtnPackageDescription, node); + } + if (result == DataType.RETURN_TYPE_PLATFORM_SURFACE_AREA) { + Tools.showInformationMessage("Platform Surface Area Clone Finished"); + vPlatformList.addElement(c.getFid()); + // + // Add new SpdHeader node to the tree + // + IDefaultMutableTreeNode node = new IDefaultMutableTreeNode(vPlatformList.lastElement().getName(), + IDefaultMutableTreeNode.FPD_PLATFORMHEADER, + true, vPlatformList.lastElement()); + iTree.addNode(dmtnPlatformDescription, node); + //this.openPlatform(c.getFid().getPath()); + } + if (result == DataType.RETURN_TYPE_OK) { + + } + } + + public void valueChanged(TreeSelectionEvent arg0) { + // TODO Auto-generated method stub + + } + + public void menuCanceled(MenuEvent arg0) { + // TODO Auto-generated method stub + + } + + public void menuDeselected(MenuEvent arg0) { + // TODO Auto-generated method stub + + } + + public void menuSelected(MenuEvent arg0) { + if (arg0.getSource() == jMenuFile) { + // + // Enable close/close all if some files are opened + // + jMenuItemFileClose.setEnabled(openingModuleList.isOpend() || openingPackageList.isOpend() + || openingPlatformList.isOpend()); + jMenuItemFileCloseAll.setEnabled(openingModuleList.isOpend() || openingPackageList.isOpend() + || openingPlatformList.isOpend()); + + // + // Enable save/save all if some files are changed + // + jMenuItemFileSave.setEnabled(!openingModuleList.isSaved() || !openingPackageList.isSaved() + || !openingPlatformList.isSaved()); + jMenuItemFileSaveAll.setEnabled(!openingModuleList.isSaved() || !openingPackageList.isSaved() + || !openingPlatformList.isSaved()); + } + + if (arg0.getSource() == jMenuTools) { + // + // Enable clone when select some items + // + if (iTree.getSelectionPath() == null) { + jMenuItemToolsClone.setEnabled(false); + } else { + int category = iTree.getSelectCategory(); + if (category == IDefaultMutableTreeNode.MODULE || category == IDefaultMutableTreeNode.PACKAGE + || category == IDefaultMutableTreeNode.PLATFORM) { + jMenuItemToolsClone.setEnabled(false); + } else { + jMenuItemToolsClone.setEnabled(true); + } + } + } + } +} diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/NewFileChooser.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/NewFileChooser.java new file mode 100644 index 0000000000..9924d56a3a --- /dev/null +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/NewFileChooser.java @@ -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; + } + } + } +} diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/SelectModuleBelong.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/SelectModuleBelong.java new file mode 100644 index 0000000000..c33e8ebec4 --- /dev/null +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/SelectModuleBelong.java @@ -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 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 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 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 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; + } +} diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/DataType.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/DataType.java new file mode 100644 index 0000000000..c096b72416 --- /dev/null +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/DataType.java @@ -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"; +} diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/DataValidation.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/DataValidation.java new file mode 100644 index 0000000000..db568a6445 --- /dev/null +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/DataValidation.java @@ -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 + +

All provided interfaces are in static mode

+ + **/ +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); + } + +} diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/EnumerationData.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/EnumerationData.java new file mode 100644 index 0000000000..2fc8b0268b --- /dev/null +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/EnumerationData.java @@ -0,0 +1,1006 @@ +/** @file + + The file is used to init all JComboBox items + + 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.Vector; + +public class EnumerationData { + // + // Static data + // + public final static String EXTERNS_SPECIFICATION = "Specification"; + + public final static String EXTERNS_MODULE_ENTRY_POINT = "ModuleEntryPoint"; + public final static String EXTERNS_MODULE_UNLOAD_IMAGE = "ModuleUnloadImage"; + + public final static String EXTERNS_CONSTRUCTOR = "Constructor"; + public final static String EXTERNS_DESTRUCTOR = "Destructor"; + + public final static String EXTERNS_DRIVER_BINDING = "DriverBinding"; + public final static String EXTERNS_COMPONENT_NAME = "ComponentName"; + public final static String EXTERNS_DRIVER_CONFIG = "DriverConfig"; + public final static String EXTERNS_DRIVER_DIAG = "DriverDiag"; + + public final static String EXTERNS_SET_VIRTUAL_ADDRESS_MAP_CALL_BACK = "SetVirtualAddressMapCallBack"; + public final static String EXTERNS_EXIT_BOOT_SERVICES_CALL_BACK = "ExitBootServicesCallBack"; + + // + // Common data + // + public Vector vSupportedArchitectures = new Vector(); + + public Vector vEnabled = new Vector(); + + public Vector vBoolean = new Vector(); + + // + // Used by Msa Header + // + public Vector vModuleType = new Vector(); + + public Vector vCompontentType = new Vector(); + + // + // Used by Library Class Definitions + // + public Vector vLibraryUsage = new Vector(); + + public Vector vFrameworkModuleTypes = new Vector(); + + public Vector vLibClassDef = new Vector(); + + public Vector vLibClassDefBase = new Vector(); + + public Vector vLibClassDefPei = new Vector(); + + public Vector vLibClassDefPeim = new Vector(); + + public Vector vLibClassDefDxeCore = new Vector(); + + public Vector vLibClassDefDxeDriver = new Vector(); + + public Vector vLibClassDefDxeSmmDriver = new Vector(); + + public Vector vLibClassDefUefiDriver = new Vector(); + + // + // Used by Source Files + // + public Vector vSourceFilesToolChainFamily = new Vector(); + + public Vector vSourceFilesFileType = new Vector(); + + // + // Used by Package Dependencies + // + public Vector vPackageUsage = new Vector(); + + // + // Used by Protocols + // + public Vector vProtocolUsage = new Vector(); + + public Vector vProtocolNotifyUsage = new Vector(); + + public Vector vProtocolType = new Vector(); + + // + // Used by Events + // + public Vector vEventType = new Vector(); + + public Vector vEventUsage = new Vector(); + + public Vector vEventGroup = new Vector(); + + // + // Used by Hobs + // + public Vector vHobType = new Vector(); + + public Vector vHobUsage = new Vector(); + + // + // Used by Ppis + // + public Vector vPpiType = new Vector(); + + public Vector vPpiUsage = new Vector(); + + public Vector vPpiNotifyUsage = new Vector(); + + // + // Used by Variable + // + public Vector vVariableUsage = new Vector(); + + // + // Used by Boot Mode + // + public Vector vBootModeNames = new Vector(); + + public Vector vBootModeUsage = new Vector(); + + // + // Used by System Tables + // + public Vector vSystemTableUsage = new Vector(); + + // + // Used by Data Hubs + // + public Vector vDataHubUsage = new Vector(); + + // + // Used by Hii Packages + // + public Vector vHiiPackageUsage = new Vector(); + + // + // Used by Guid + // + public Vector vGuidUsage = new Vector(); + + // + // Used by Externs + // + public Vector vExternTypes = new Vector(); + + public Vector vPcdDriverTypes = new Vector(); + + // + // Used by Pcd + // + public Vector vPcdItemTypes = new Vector(); + + public EnumerationData() { + init(); + } + + private void init() { + // + // Init common data first + // + initSupportedArchitectures(); + initEnabled(); + initBoolean(); + + // + // Used by Msa header + // + initModuleType(); + + // + // Used by Library Class Definitions + // + initLibraryUsage(); + initFrameworkModuleTypes(); + initLibClassDefBase(); + initLibClassDefPei(); + initLibClassDefPeim(); + initLibClassDefDxeCore(); + initLibClassDefDxeDriver(); + initLibClassDefDxeSmmDriver(); + initLibClassDefUefiDriver(); + initLibClassDef(); + + // + // Used by Library Class Definitions + // + initSourceFilesToolChainFamily(); + initSourceFilesFileType(); + + // + // Used by Package Dependencies + // + initPackageUsage(); + + // + // Used by Protocols + // + initProtocolType(); + initProtocolUsage(); + initProtocolNotifyUsage(); + + // + // Used by Events + // + initEventType(); + initEventUsage(); + initEventGroup(); + + // + // Used by Hobs + // + initHobType(); + initHobUsage(); + + // + // Used by Ppis + // + initPpiType(); + initPpiUsage(); + initPpiNotifyUsage(); + + // + // Used by Variable + // + initVariableUsage(); + + // + // Used by Boot Mode + // + initBootModeNames(); + initBootModeUsage(); + + // + // Used by System Tables + // + initSystemTableUsage(); + + // + // Used by Data Hubs + // + initDataHubUsage(); + + // + // Used by Hii Packages + // + initHiiPackages(); + + // + // Used by Guid + // + initGuidUsage(); + + // + // Used by Externs + // + initExternTypes(); + initPcdDriverTypes(); + + // + // Used by Pcd + // + initPcdItemTypes(); + + } + + private void initEnabled() { + vEnabled.removeAllElements(); + vEnabled.addElement("Disabled"); + vEnabled.addElement("Enabled"); + } + + private void initBoolean() { + vBoolean.removeAllElements(); + vBoolean.addElement("False"); + vBoolean.addElement("True"); + } + + private void initModuleType() { + vModuleType.removeAllElements(); + vModuleType.addElement("BASE"); + vModuleType.addElement("SEC"); + vModuleType.addElement("PEI_CORE"); + vModuleType.addElement("PEIM"); + vModuleType.addElement("DXE_CORE"); + vModuleType.addElement("DXE_DRIVER"); + vModuleType.addElement("DXE_RUNTIME_DRIVER"); + vModuleType.addElement("DXE_SAL_DRIVER"); + vModuleType.addElement("DXE_SMM_DRIVER"); + vModuleType.addElement("TOOLS"); + vModuleType.addElement("UEFI_DRIVER"); + vModuleType.addElement("UEFI_APPLICATION"); + vModuleType.addElement("USER_DEFINED"); + } + +// private void initComponentType() { +// vCompontentType.removeAllElements(); +// vCompontentType.addElement("APRIORI"); +// vCompontentType.addElement("LIBRARY"); +// vCompontentType.addElement("FV_IMAGE_FILE"); +// vCompontentType.addElement("BS_DRIVER"); +// vCompontentType.addElement("RT_DRIVER"); +// vCompontentType.addElement("SAL_RT_DRIVER"); +// vCompontentType.addElement("PE32_PEIM"); +// vCompontentType.addElement("PIC_PEIM"); +// vCompontentType.addElement("COMBINED_PEIM_DRIVER"); +// vCompontentType.addElement("PEI_CORE"); +// vCompontentType.addElement("DXE_CORE"); +// vCompontentType.addElement("APPLICATION"); +// vCompontentType.addElement("BS_DRIVER_EFI"); +// vCompontentType.addElement("SHELLAPP"); +// } + + private void initSupportedArchitectures() { + vSupportedArchitectures.removeAllElements(); + vSupportedArchitectures.addElement("EBC"); + vSupportedArchitectures.addElement("IA32"); + vSupportedArchitectures.addElement("X64"); + vSupportedArchitectures.addElement("IPF"); + vSupportedArchitectures.addElement("ARM"); + vSupportedArchitectures.addElement("PPC"); + } + + private void initLibraryUsage() { + vLibraryUsage.removeAllElements(); + vLibraryUsage.addElement("ALWAYS_CONSUMED"); + vLibraryUsage.addElement("SOMETIMES_CONSUMED"); + vLibraryUsage.addElement("ALWAYS_PRODUCED"); + vLibraryUsage.addElement("SOMETIMES_PRODUCED"); + vLibraryUsage.addElement("DEFAULT"); + vLibraryUsage.addElement("PRIVATE"); + } + + private void initFrameworkModuleTypes() { + vFrameworkModuleTypes.removeAllElements(); + vFrameworkModuleTypes.addElement("BASE"); + vFrameworkModuleTypes.addElement("SEC"); + vFrameworkModuleTypes.addElement("PEI_CORE"); + vFrameworkModuleTypes.addElement("PEIM"); + vFrameworkModuleTypes.addElement("DXE_CORE"); + vFrameworkModuleTypes.addElement("DXE_DRIVER"); + vFrameworkModuleTypes.addElement("DXE_RUNTIME_DRIVER"); + vFrameworkModuleTypes.addElement("DXE_SAL_DRIVER"); + vFrameworkModuleTypes.addElement("DXE_SMM_DRIVER"); + vFrameworkModuleTypes.addElement("TOOLS"); + vFrameworkModuleTypes.addElement("UEFI_DRIVER"); + vFrameworkModuleTypes.addElement("UEFI_APPLICATION"); + vFrameworkModuleTypes.addElement("USER_DEFINED"); + } + + private void initLibClassDef() { + vLibClassDef.removeAllElements(); + for (int index = 0; index < vLibClassDefBase.size(); index++) { + vLibClassDef.addElement(vLibClassDefBase.elementAt(index)); + } + for (int index = 0; index < vLibClassDefPei.size(); index++) { + vLibClassDef.addElement(vLibClassDefPei.elementAt(index)); + } + for (int index = 0; index < vLibClassDefPeim.size(); index++) { + vLibClassDef.addElement(vLibClassDefPeim.elementAt(index)); + } + for (int index = 0; index < vLibClassDefDxeCore.size(); index++) { + vLibClassDef.addElement(vLibClassDefDxeCore.elementAt(index)); + } + for (int index = 0; index < vLibClassDefDxeDriver.size(); index++) { + vLibClassDef.addElement(vLibClassDefDxeDriver.elementAt(index)); + } + for (int index = 0; index < vLibClassDefDxeSmmDriver.size(); index++) { + vLibClassDef.addElement(vLibClassDefDxeSmmDriver.elementAt(index)); + } + for (int index = 0; index < vLibClassDefUefiDriver.size(); index++) { + vLibClassDef.addElement(vLibClassDefUefiDriver.elementAt(index)); + } + } + + private void initLibClassDefBase() { + vLibClassDefBase.removeAllElements(); + vLibClassDefBase.addElement("BaseLib"); + vLibClassDefBase.addElement("BaseMemoryLib"); + vLibClassDefBase.addElement("CacheMaintenanceLib"); + vLibClassDefBase.addElement("DebugLib"); + vLibClassDefBase.addElement("IoLib"); + vLibClassDefBase.addElement("PcdLib"); + vLibClassDefBase.addElement("PciCf8Lib"); + vLibClassDefBase.addElement("PciExpressLib"); + vLibClassDefBase.addElement("PciLib"); + vLibClassDefBase.addElement("PeCoffGetEntryPointLib"); + vLibClassDefBase.addElement("PeCoffLib"); + vLibClassDefBase.addElement("PerformanceLib"); + vLibClassDefBase.addElement("PrintLib"); + vLibClassDefBase.addElement("SmbusLib"); + vLibClassDefBase.addElement("TimerLib"); + } + + private void initLibClassDefPei() { + vLibClassDefPei.removeAllElements(); + vLibClassDefPei.addElement("PeiCoreEntryPoint"); + } + + private void initLibClassDefPeim() { + vLibClassDefPeim.removeAllElements(); + vLibClassDefPeim.addElement("BaseMemoryLib"); + vLibClassDefPeim.addElement("DebugLib"); + vLibClassDefPeim.addElement("HobLib"); + vLibClassDefPeim.addElement("IoLib"); + vLibClassDefPeim.addElement("MemoryAllocationLib"); + vLibClassDefPeim.addElement("PcdLib"); + vLibClassDefPeim.addElement("PeiCoreLib"); + vLibClassDefPeim.addElement("PeiServicesTablePointerLib"); + vLibClassDefPeim.addElement("PeimEntryPoint"); + vLibClassDefPeim.addElement("ReportStatusCodeLib"); + vLibClassDefPeim.addElement("ResourcePublicationLib"); + vLibClassDefPeim.addElement("SmbusLib"); + } + + private void initLibClassDefDxeCore() { + vLibClassDefDxeCore.removeAllElements(); + vLibClassDefDxeCore.addElement("DxeCoreEntryPoint"); + vLibClassDefDxeCore.addElement("HobLib"); + } + + private void initLibClassDefDxeDriver() { + vLibClassDefDxeDriver.removeAllElements(); + vLibClassDefDxeDriver.addElement("DxeServicesTableLib"); + vLibClassDefDxeDriver.addElement("HiiLib"); + vLibClassDefDxeDriver.addElement("HobLib"); + vLibClassDefDxeDriver.addElement("IoLib"); + vLibClassDefDxeDriver.addElement("MemoryAllocationLib"); + vLibClassDefDxeDriver.addElement("PcdLib"); + vLibClassDefDxeDriver.addElement("ReportStatusCodeLib"); + vLibClassDefDxeDriver.addElement("SmbusLib"); + vLibClassDefDxeDriver.addElement("UefiBootServicesTableLib"); + vLibClassDefDxeDriver.addElement("UefiDecompressLib"); + vLibClassDefDxeDriver.addElement("UefiRuntimeServicesTableLib"); + } + + private void initLibClassDefDxeSmmDriver() { + vLibClassDefDxeSmmDriver.removeAllElements(); + vLibClassDefDxeSmmDriver.addElement("DxeSmmDriverEntryPoint"); + } + + private void initLibClassDefUefiDriver() { + vLibClassDefUefiDriver.removeAllElements(); + vLibClassDefUefiDriver.addElement("BaseMemoryLib"); + vLibClassDefUefiDriver.addElement("DebugLib"); + vLibClassDefUefiDriver.addElement("DevicePathLib"); + vLibClassDefUefiDriver.addElement("UefiDriverEntryPoint"); + vLibClassDefUefiDriver.addElement("UefiDriverModelLib"); + vLibClassDefUefiDriver.addElement("UefiLib"); + } + + private void initSourceFilesToolChainFamily() { + vSourceFilesToolChainFamily.removeAllElements(); + vSourceFilesToolChainFamily.addElement("MSFT"); + vSourceFilesToolChainFamily.addElement("INTC"); + vSourceFilesToolChainFamily.addElement("GCC"); + } + + private void initSourceFilesFileType() { + vSourceFilesFileType.removeAllElements(); + vSourceFilesFileType.addElement("CCODE"); + vSourceFilesFileType.addElement("CHEADER"); + vSourceFilesFileType.addElement("ASMHEADER"); + vSourceFilesFileType.addElement("ASM"); + vSourceFilesFileType.addElement("UNI"); + vSourceFilesFileType.addElement("TXT"); + vSourceFilesFileType.addElement("DXS"); + vSourceFilesFileType.addElement("BMP"); + vSourceFilesFileType.addElement("VFR"); + vSourceFilesFileType.addElement("BINARY"); + vSourceFilesFileType.addElement("FV"); + vSourceFilesFileType.addElement("FFS"); + vSourceFilesFileType.addElement("EFI"); + } + + private void initPackageUsage() { + vPackageUsage.removeAllElements(); + vPackageUsage.addElement("ALWAYS_CONSUMED"); + vPackageUsage.addElement("ALWAYS_PRODUCED"); + vPackageUsage.addElement("DEFAULT"); + } + + private void initProtocolUsage() { + vProtocolUsage.removeAllElements(); + vProtocolUsage.addElement("ALWAYS_CONSUMED"); + vProtocolUsage.addElement("SOMETIMES_CONSUMED"); + vProtocolUsage.addElement("ALWAYS_PRODUCED"); + vProtocolUsage.addElement("SOMETIMES_PRODUCED"); + vProtocolUsage.addElement("TO_START"); + vProtocolUsage.addElement("BY_START"); + vProtocolUsage.addElement("PRIVATE"); + } + + private void initProtocolType() { + vProtocolType.removeAllElements(); + vProtocolType.addElement("Protocol"); + vProtocolType.addElement("Protocol Notify"); + } + + private void initEventType() { + vEventType.removeAllElements(); + vEventType.addElement("CreateEvents"); + vEventType.addElement("SignalEvents"); + } + + private void initEventUsage() { + vEventUsage.removeAllElements(); + vEventUsage.addElement("ALWAYS_CONSUMED"); + vEventUsage.addElement("SOMETIMES_CONSUMED"); + vEventUsage.addElement("ALWAYS_PRODUCED"); + vEventUsage.addElement("SOMETIMES_PRODUCED"); + vEventUsage.addElement("PRIVATE"); + } + + private void initEventGroup() { + vEventGroup.removeAllElements(); + vEventGroup.addElement("EVENT_GROUP_GUID"); + vEventGroup.addElement("EVENT_TYPE_PERIODIC_TIMER"); + vEventGroup.addElement("EVENT_TYPE_RELATIVE_TIMER"); + } + + private void initHobType() { + vHobType.removeAllElements(); + vHobType.addElement("PHIT"); + vHobType.addElement("MEMORY_ALLOCATION"); + vHobType.addElement("RESOURCE_DESCRIPTOR"); + vHobType.addElement("GUID_EXTENSION"); + vHobType.addElement("FIRMWARE_VOLUME"); + vHobType.addElement("CPU"); + vHobType.addElement("POOL"); + vHobType.addElement("CAPSULE_VOLUME"); + } + + private void initHobUsage() { + vHobUsage.removeAllElements(); + vHobUsage.addElement("ALWAYS_CONSUMED"); + vHobUsage.addElement("SOMETIMES_CONSUMED"); + vHobUsage.addElement("ALWAYS_PRODUCED"); + vHobUsage.addElement("SOMETIMES_PRODUCED"); + vHobUsage.addElement("PRIVATE"); + } + + private void initPpiType() { + vPpiType.removeAllElements(); + vPpiType.addElement("Ppi"); + vPpiType.addElement("Ppi Notify"); + } + + private void initPpiUsage() { + vPpiUsage.removeAllElements(); + vPpiUsage.addElement("ALWAYS_CONSUMED"); + vPpiUsage.addElement("SOMETIMES_CONSUMED"); + vPpiUsage.addElement("ALWAYS_PRODUCED"); + vPpiUsage.addElement("SOMETIMES_PRODUCED"); + vPpiUsage.addElement("PRIVATE"); + } + + private void initPpiNotifyUsage() { + vPpiNotifyUsage.removeAllElements(); + vPpiNotifyUsage.addElement("SOMETIMES_CONSUMED"); + } + + private void initProtocolNotifyUsage() { + vProtocolNotifyUsage.addElement("SOMETIMES_CONSUMED"); + } + + private void initVariableUsage() { + vVariableUsage.removeAllElements(); + vVariableUsage.addElement("ALWAYS_CONSUMED"); + vVariableUsage.addElement("SOMETIMES_CONSUMED"); + vVariableUsage.addElement("ALWAYS_PRODUCED"); + vVariableUsage.addElement("SOMETIMES_PRODUCED"); + vVariableUsage.addElement("PRIVATE"); + } + + private void initBootModeNames() { + vBootModeNames.removeAllElements(); + vBootModeNames.addElement("FULL"); + vBootModeNames.addElement("MINIMAL"); + vBootModeNames.addElement("NO_CHANGE"); + vBootModeNames.addElement("DIAGNOSTICS"); + vBootModeNames.addElement("DEFAULT"); + vBootModeNames.addElement("S2_RESUME"); + vBootModeNames.addElement("S3_RESUME"); + vBootModeNames.addElement("S4_RESUME"); + vBootModeNames.addElement("S5_RESUME"); + vBootModeNames.addElement("FLASH_UPDATE"); + vBootModeNames.addElement("RECOVERY"); + } + + private void initBootModeUsage() { + vBootModeUsage.removeAllElements(); + vBootModeUsage.addElement("ALWAYS_CONSUMED"); + vBootModeUsage.addElement("SOMETIMES_CONSUMED"); + vBootModeUsage.addElement("ALWAYS_PRODUCED"); + vBootModeUsage.addElement("SOMETIMES_PRODUCED"); + } + + private void initSystemTableUsage() { + vSystemTableUsage.removeAllElements(); + vSystemTableUsage.addElement("ALWAYS_CONSUMED"); + vSystemTableUsage.addElement("SOMETIMES_CONSUMED"); + vSystemTableUsage.addElement("ALWAYS_PRODUCED"); + vSystemTableUsage.addElement("SOMETIMES_PRODUCED"); + vSystemTableUsage.addElement("PRIVATE"); + } + + private void initDataHubUsage() { + vDataHubUsage.removeAllElements(); + vDataHubUsage.addElement("ALWAYS_CONSUMED"); + vDataHubUsage.addElement("SOMETIMES_CONSUMED"); + vDataHubUsage.addElement("ALWAYS_PRODUCED"); + vDataHubUsage.addElement("SOMETIMES_PRODUCED"); + vDataHubUsage.addElement("PRIVATE"); + } + + private void initHiiPackages() { + vHiiPackageUsage.removeAllElements(); + vHiiPackageUsage.addElement("ALWAYS_PRODUCED"); + vHiiPackageUsage.addElement("SOMETIMES_PRODUCED"); + vHiiPackageUsage.addElement("PRIVATE"); + } + + private void initGuidUsage() { + vGuidUsage.removeAllElements(); + vGuidUsage.addElement("ALWAYS_CONSUMED"); + vGuidUsage.addElement("SOMETIMES_CONSUMED"); + vGuidUsage.addElement("ALWAYS_PRODUCED"); + vGuidUsage.addElement("SOMETIMES_PRODUCED"); + vGuidUsage.addElement("DEFAULT"); + vGuidUsage.addElement("PRIVATE"); + } + + private void initExternTypes() { + vExternTypes.removeAllElements(); + vExternTypes.addElement(EnumerationData.EXTERNS_SPECIFICATION); + + vExternTypes.addElement(EnumerationData.EXTERNS_MODULE_ENTRY_POINT); + vExternTypes.addElement(EnumerationData.EXTERNS_MODULE_UNLOAD_IMAGE); + + vExternTypes.addElement(EnumerationData.EXTERNS_CONSTRUCTOR); + vExternTypes.addElement(EnumerationData.EXTERNS_DESTRUCTOR); + + vExternTypes.addElement(EnumerationData.EXTERNS_DRIVER_BINDING); + vExternTypes.addElement(EnumerationData.EXTERNS_COMPONENT_NAME); + vExternTypes.addElement(EnumerationData.EXTERNS_DRIVER_CONFIG); + vExternTypes.addElement(EnumerationData.EXTERNS_DRIVER_DIAG); + + vExternTypes.addElement(EnumerationData.EXTERNS_SET_VIRTUAL_ADDRESS_MAP_CALL_BACK); + vExternTypes.addElement(EnumerationData.EXTERNS_EXIT_BOOT_SERVICES_CALL_BACK); + } + + private void initPcdDriverTypes() { + vPcdDriverTypes.removeAllElements(); + vPcdDriverTypes.addElement(DataType.EMPTY_SELECT_ITEM); + vPcdDriverTypes.addElement("PEI_PCD_DRIVER"); + vPcdDriverTypes.addElement("DXE_PCD_DRIVER"); + } + + private void initPcdItemTypes() { + vPcdItemTypes.removeAllElements(); + vPcdItemTypes.addElement("FEATURE_FLAG"); + vPcdItemTypes.addElement("FIXED_AT_BUILD"); + vPcdItemTypes.addElement("PATCHABLE_IN_MODULE"); + vPcdItemTypes.addElement("DYNAMIC"); + vPcdItemTypes.addElement("DYNAMIC_EX"); + } + + public Vector getvCompontentType() { + return vCompontentType; + } + + public void setvCompontentType(Vector componentType) { + vCompontentType = componentType; + } + + public Vector getVModuleType() { + return vModuleType; + } + + public void setVModuleType(Vector moduleType) { + vModuleType = moduleType; + } + + public Vector getVLibraryUsage() { + return vLibraryUsage; + } + + public void setVLibClassDefUsage(Vector libClassDefUsage) { + vLibraryUsage = libClassDefUsage; + } + + public Vector getVLibClassDef() { + return vLibClassDef; + } + + public void setVLibClassDef(Vector libClassDef) { + vLibClassDef = libClassDef; + } + + public Vector getVCompontentType() { + return vCompontentType; + } + + public void setVCompontentType(Vector compontentType) { + vCompontentType = compontentType; + } + + public Vector getVLibClassDefBase() { + return vLibClassDefBase; + } + + public void setVLibClassDefBase(Vector libClassDefBase) { + vLibClassDefBase = libClassDefBase; + } + + public Vector getVLibClassDefDxeCore() { + return vLibClassDefDxeCore; + } + + public void setVLibClassDefDxeCore(Vector libClassDefDxeCore) { + vLibClassDefDxeCore = libClassDefDxeCore; + } + + public Vector getVLibClassDefDxeDriver() { + return vLibClassDefDxeDriver; + } + + public void setVLibClassDefDxeDriver(Vector libClassDefDxeDriver) { + vLibClassDefDxeDriver = libClassDefDxeDriver; + } + + public Vector getVLibClassDefDxeSmmDriver() { + return vLibClassDefDxeSmmDriver; + } + + public void setVLibClassDefDxeSmmDriver(Vector libClassDefDxeSmmDriver) { + vLibClassDefDxeSmmDriver = libClassDefDxeSmmDriver; + } + + public Vector getVLibClassDefPei() { + return vLibClassDefPei; + } + + public void setVLibClassDefPei(Vector libClassDefPei) { + vLibClassDefPei = libClassDefPei; + } + + public Vector getVLibClassDefPeim() { + return vLibClassDefPeim; + } + + public void setVLibClassDefPeim(Vector libClassDefPeim) { + vLibClassDefPeim = libClassDefPeim; + } + + public Vector getVLibClassDefUefiDriver() { + return vLibClassDefUefiDriver; + } + + public void setVLibClassDefUefiDriver(Vector libClassDefUefiDriver) { + vLibClassDefUefiDriver = libClassDefUefiDriver; + } + + public Vector getVSourceFilesFileType() { + return vSourceFilesFileType; + } + + public void setVSourceFilesFileType(Vector sourceFilesFileType) { + vSourceFilesFileType = sourceFilesFileType; + } + + public Vector getVSourceFilesToolChainFamily() { + return vSourceFilesToolChainFamily; + } + + public void setVSourceFilesToolChainFamily(Vector sourceFilesToolChainFamily) { + vSourceFilesToolChainFamily = sourceFilesToolChainFamily; + } + + public void setVLibraryUsage(Vector libraryUsage) { + vLibraryUsage = libraryUsage; + } + + public Vector getVProtocolNotifyUsage() { + return vProtocolNotifyUsage; + } + + public void setVProtocolNotifyUsage(Vector protocolNotifyUsage) { + vProtocolNotifyUsage = protocolNotifyUsage; + } + + public Vector getVProtocolUsage() { + return vProtocolUsage; + } + + public void setVProtocolUsage(Vector protocolUsage) { + vProtocolUsage = protocolUsage; + } + + public Vector getVSupportedArchitectures() { + return vSupportedArchitectures; + } + + public void setVSupportedArchitectures(Vector supportedArchitectures) { + vSupportedArchitectures = supportedArchitectures; + } + + public Vector getVProtocolType() { + return vProtocolType; + } + + public void setVProtocolType(Vector protocolType) { + vProtocolType = protocolType; + } + + public Vector getVEventGroup() { + return vEventGroup; + } + + public void setVEventGroup(Vector eventGroup) { + vEventGroup = eventGroup; + } + + public Vector getVEventType() { + return vEventType; + } + + public void setVEventType(Vector eventType) { + vEventType = eventType; + } + + public Vector getVEventUsage() { + return vEventUsage; + } + + public void setVEventUsage(Vector eventUsage) { + vEventUsage = eventUsage; + } + + public Vector getVEnabled() { + return vEnabled; + } + + public void setVEnabled(Vector enabled) { + vEnabled = enabled; + } + + public Vector getVHobType() { + return vHobType; + } + + public void setVHobType(Vector hobType) { + vHobType = hobType; + } + + public Vector getVHobUsage() { + return vHobUsage; + } + + public void setVHobUsage(Vector hobUsage) { + vHobUsage = hobUsage; + } + + public Vector getVPpiNotifyUsage() { + return vPpiNotifyUsage; + } + + public void setVPpiNotifyUsage(Vector ppiNotifyUsage) { + vPpiNotifyUsage = ppiNotifyUsage; + } + + public Vector getVPpiType() { + return vPpiType; + } + + public void setVPpiType(Vector ppiType) { + vPpiType = ppiType; + } + + public Vector getVPpiUsage() { + return vPpiUsage; + } + + public void setVPpiUsage(Vector ppiUsage) { + vPpiUsage = ppiUsage; + } + + public Vector getVVariableUsage() { + return vVariableUsage; + } + + public void setVVariableUsage(Vector variableUsage) { + vVariableUsage = variableUsage; + } + + public Vector getVBootModeNames() { + return vBootModeNames; + } + + public void setVBootModeNames(Vector bootModeNames) { + vBootModeNames = bootModeNames; + } + + public Vector getVBootModeUsage() { + return vBootModeUsage; + } + + public void setVBootModeUsage(Vector bootModeUsage) { + vBootModeUsage = bootModeUsage; + } + + public Vector getVSystemTableUsage() { + return vSystemTableUsage; + } + + public void setVSystemTableUsage(Vector systemTableUsage) { + vSystemTableUsage = systemTableUsage; + } + + public Vector getVDataHubUsage() { + return vDataHubUsage; + } + + public void setVDataHubUsage(Vector dataHubUsage) { + vDataHubUsage = dataHubUsage; + } + + public Vector getVGuidUsage() { + return vGuidUsage; + } + + public void setVGuidUsage(Vector guidUsage) { + vGuidUsage = guidUsage; + } + + public Vector getVHiiPackageUsage() { + return vHiiPackageUsage; + } + + public void setVHiiPackageUsage(Vector hiiPackageUsage) { + vHiiPackageUsage = hiiPackageUsage; + } + + public Vector getVPcdItemTypes() { + return vPcdItemTypes; + } + + public void setVPcdItemTypes(Vector pcdItemTypes) { + vPcdItemTypes = pcdItemTypes; + } + + public Vector getVExternTypes() { + return vExternTypes; + } + + public void setVExternTypes(Vector externTypes) { + vExternTypes = externTypes; + } + + public Vector getVPcdDriverTypes() { + return vPcdDriverTypes; + } + + public void setVPcdDriverTypes(Vector pcdDriverTypes) { + vPcdDriverTypes = pcdDriverTypes; + } + + public Vector getVBoolean() { + return vBoolean; + } + + public void setVBoolean(Vector boolean1) { + vBoolean = boolean1; + } + + public Vector getVFrameworkModuleTypes() { + return vFrameworkModuleTypes; + } + + public void setVFrameworkModuleTypes(Vector frameworkModuleTypes) { + vFrameworkModuleTypes = frameworkModuleTypes; + } + + public Vector getVPackageUsage() { + return vPackageUsage; + } + + public void setVPackageUsage(Vector packageUsage) { + vPackageUsage = packageUsage; + } +} diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/FileOperation.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/FileOperation.java new file mode 100644 index 0000000000..21d6cfa596 --- /dev/null +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/FileOperation.java @@ -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]); + } + } + } +} diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/IFileFilter.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/IFileFilter.java new file mode 100644 index 0000000000..d13a8c48ef --- /dev/null +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/IFileFilter.java @@ -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 ""; + } + +} diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/Log.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/Log.java new file mode 100644 index 0000000000..d85fbf5a96 --- /dev/null +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/Log.java @@ -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(); + } + } +} diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/SaveFile.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/SaveFile.java new file mode 100644 index 0000000000..ec587bb5be --- /dev/null +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/SaveFile.java @@ -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); + } +} diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/Tools.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/Tools.java new file mode 100644 index 0000000000..e63a0f5cf9 --- /dev/null +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/Tools.java @@ -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 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 convertListToVector(List list) { + Vector v = new Vector(); + 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); + } +} diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/XmlConfig.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/XmlConfig.java new file mode 100644 index 0000000000..db7b58d1d9 --- /dev/null +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/XmlConfig.java @@ -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; + } + +} diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/ui/ExitConfirm.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/ui/ExitConfirm.java new file mode 100644 index 0000000000..d5298df38b --- /dev/null +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/ui/ExitConfirm.java @@ -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 + + } +} diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/ui/IComboBox.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/ui/IComboBox.java new file mode 100644 index 0000000000..13d7771e3a --- /dev/null +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/ui/IComboBox.java @@ -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); + } + } +} diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/ui/IDefaultMutableTreeNode.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/ui/IDefaultMutableTreeNode.java new file mode 100644 index 0000000000..6814741a5c --- /dev/null +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/ui/IDefaultMutableTreeNode.java @@ -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; + } +} diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/ui/IDesktopManager.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/ui/IDesktopManager.java new file mode 100644 index 0000000000..dc668e7ed3 --- /dev/null +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/ui/IDesktopManager.java @@ -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) { + + } + +} diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/ui/IDialog.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/ui/IDialog.java new file mode 100644 index 0000000000..57f3b4e2dc --- /dev/null +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/ui/IDialog.java @@ -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; + } +} diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/ui/IFrame.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/ui/IFrame.java new file mode 100644 index 0000000000..4778133a41 --- /dev/null +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/ui/IFrame.java @@ -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); + } +} diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/ui/IInternalFrame.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/ui/IInternalFrame.java new file mode 100644 index 0000000000..0d15a014ee --- /dev/null +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/ui/IInternalFrame.java @@ -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 + + } +} diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/ui/ITree.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/ui/ITree.java new file mode 100644 index 0000000000..3d6a65bb83 --- /dev/null +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/ui/ITree.java @@ -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; + } +} diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/ui/StarLabel.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/ui/StarLabel.java new file mode 100644 index 0000000000..3641df0373 --- /dev/null +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/ui/StarLabel.java @@ -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); + } +} diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/ui/iCheckBoxList/ICheckBoxList.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/ui/iCheckBoxList/ICheckBoxList.java new file mode 100644 index 0000000000..5ad0533eec --- /dev/null +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/ui/iCheckBoxList/ICheckBoxList.java @@ -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 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 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 getAllCheckedItems() { + Vector result = new Vector(); + + 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 getAllCheckedItemsString() { + Vector result = new Vector(); + + 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 getAllItemsString() { + Vector result = new Vector(); + + 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 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(); + } +} diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/ui/iCheckBoxList/ICheckBoxListCellRenderer.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/ui/iCheckBoxList/ICheckBoxListCellRenderer.java new file mode 100644 index 0000000000..1b022fc908 --- /dev/null +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/ui/iCheckBoxList/ICheckBoxListCellRenderer.java @@ -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; + } +} diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/ui/iCheckBoxList/ICheckBoxListItem.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/ui/iCheckBoxList/ICheckBoxListItem.java new file mode 100644 index 0000000000..39fa641d0e --- /dev/null +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/ui/iCheckBoxList/ICheckBoxListItem.java @@ -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; + } + +} diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/ui/iCheckBoxList/ICheckBoxListModel.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/ui/iCheckBoxList/ICheckBoxListModel.java new file mode 100644 index 0000000000..f3bbe8a3a0 --- /dev/null +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/ui/iCheckBoxList/ICheckBoxListModel.java @@ -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 getAllElements() { + Vector items = new Vector(); + ICheckBoxListItem[] objs = new ICheckBoxListItem[this.size()]; + this.copyInto(objs); + for (int i = 0; i < size(); i++) { + items.addElement(objs[i]); + } + return items; + } +} diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/ui/iCheckBoxList/ICheckBoxListener.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/ui/iCheckBoxList/ICheckBoxListener.java new file mode 100644 index 0000000000..e95d279e59 --- /dev/null +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/ui/iCheckBoxList/ICheckBoxListener.java @@ -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 + + } +} diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/Identification/BootModes/BootModesIdentification.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/Identification/BootModes/BootModesIdentification.java new file mode 100644 index 0000000000..45944d5771 --- /dev/null +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/Identification/BootModes/BootModesIdentification.java @@ -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 supArchList = null; + + private String featureFlag = null; + + private String help = null; + + public BootModesIdentification(String arg0, String arg1, String arg2, Vector 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 getSupArchList() { + return supArchList; + } + + public void setSupArchList(Vector 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; + } +} diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/Identification/BootModes/BootModesVector.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/Identification/BootModes/BootModesVector.java new file mode 100644 index 0000000000..c7c02e9f4b --- /dev/null +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/Identification/BootModes/BootModesVector.java @@ -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 vBootModes = new Vector(); + + 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 getvBootModes() { + return vBootModes; + } + + public void setvBootModes(Vector BootModes) { + vBootModes = BootModes; + } + + public Vector getBootModesName() { + Vector v = new Vector(); + for (int index = 0; index < this.vBootModes.size(); index++) { + v.addElement(vBootModes.get(index).getName()); + } + return v; + } + + public int size() { + return this.vBootModes.size(); + } + +} diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/Identification/DataHubs/DataHubsIdentification.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/Identification/DataHubs/DataHubsIdentification.java new file mode 100644 index 0000000000..deb72d3479 --- /dev/null +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/Identification/DataHubs/DataHubsIdentification.java @@ -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 supArchList = null; + + private String featureFlag = null; + + private String help = null; + + public DataHubsIdentification(String arg0, String arg1, String arg2, Vector 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 getSupArchList() { + return supArchList; + } + + public void setSupArchList(Vector 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; + } +} diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/Identification/DataHubs/DataHubsVector.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/Identification/DataHubs/DataHubsVector.java new file mode 100644 index 0000000000..4348eb3697 --- /dev/null +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/Identification/DataHubs/DataHubsVector.java @@ -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 vDataHubs = new Vector(); + + 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 getvDataHubs() { + return vDataHubs; + } + + public void setvDataHubs(Vector DataHubs) { + vDataHubs = DataHubs; + } + + public Vector getDataHubsName() { + Vector v = new Vector(); + for (int index = 0; index < this.vDataHubs.size(); index++) { + v.addElement(vDataHubs.get(index).getName()); + } + return v; + } + + public int size() { + return this.vDataHubs.size(); + } + +} diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/Identification/Events/EventsIdentification.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/Identification/Events/EventsIdentification.java new file mode 100644 index 0000000000..4258226af1 --- /dev/null +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/Identification/Events/EventsIdentification.java @@ -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 supArchList = null; + + private String featureFlag = null; + + private String help = null; + + public EventsIdentification(String arg0, String arg1, String arg2, String arg3, Vector 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 getSupArchList() { + return supArchList; + } + + public void setSupArchList(Vector 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; + } +} diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/Identification/Events/EventsVector.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/Identification/Events/EventsVector.java new file mode 100644 index 0000000000..a2f597a0e4 --- /dev/null +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/Identification/Events/EventsVector.java @@ -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 vEvents = new Vector(); + + 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 getvEvents() { + return vEvents; + } + + public void setvEvents(Vector Events) { + vEvents = Events; + } + + public Vector getEventsName() { + Vector v = new Vector(); + for (int index = 0; index < this.vEvents.size(); index++) { + v.addElement(vEvents.get(index).getName()); + } + return v; + } + + public int size() { + return this.vEvents.size(); + } + +} diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/Identification/Externs/ExternsIdentification.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/Identification/Externs/ExternsIdentification.java new file mode 100644 index 0000000000..b925698109 --- /dev/null +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/Identification/Externs/ExternsIdentification.java @@ -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 supArchList = null; + + private String featureFlag = null; + + public ExternsIdentification(String arg0, String arg1, String arg2, Vector 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 getSupArchList() { + return supArchList; + } + + public void setSupArchList(Vector 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; + } +} diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/Identification/Externs/ExternsVector.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/Identification/Externs/ExternsVector.java new file mode 100644 index 0000000000..ac5ce34e16 --- /dev/null +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/Identification/Externs/ExternsVector.java @@ -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 vExterns = new Vector(); + + 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 getvExterns() { + return vExterns; + } + + public void setvExterns(Vector Externs) { + vExterns = Externs; + } + + public Vector getExternsName() { + Vector v = new Vector(); + for (int index = 0; index < this.vExterns.size(); index++) { + v.addElement(vExterns.get(index).getName()); + } + return v; + } + + public int size() { + return this.vExterns.size(); + } + +} diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/Identification/Guids/GuidsIdentification.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/Identification/Guids/GuidsIdentification.java new file mode 100644 index 0000000000..7b11e2ca3f --- /dev/null +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/Identification/Guids/GuidsIdentification.java @@ -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 supArchList = null; + + private String featureFlag = null; + + private String help = null; + + public GuidsIdentification(String arg0, String arg1, String arg2, Vector 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 getSupArchList() { + return supArchList; + } + + public void setSupArchList(Vector 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; + } +} diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/Identification/Guids/GuidsVector.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/Identification/Guids/GuidsVector.java new file mode 100644 index 0000000000..68c2d88592 --- /dev/null +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/Identification/Guids/GuidsVector.java @@ -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 vGuids = new Vector(); + + 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 getvGuids() { + return vGuids; + } + + public void setvGuids(Vector Guids) { + vGuids = Guids; + } + + public Vector getGuidsName() { + Vector v = new Vector(); + for (int index = 0; index < this.vGuids.size(); index++) { + v.addElement(vGuids.get(index).getName()); + } + return v; + } + + public int size() { + return this.vGuids.size(); + } + +} diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/Identification/HiiPackages/HiiPackagesIdentification.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/Identification/HiiPackages/HiiPackagesIdentification.java new file mode 100644 index 0000000000..546f4b809f --- /dev/null +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/Identification/HiiPackages/HiiPackagesIdentification.java @@ -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 supArchList = null; + + private String featureFlag = null; + + private String help = null; + + public HiiPackagesIdentification(String arg0, String arg1, String arg2, Vector 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 getSupArchList() { + return supArchList; + } + + public void setSupArchList(Vector 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; + } +} diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/Identification/HiiPackages/HiiPackagesVector.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/Identification/HiiPackages/HiiPackagesVector.java new file mode 100644 index 0000000000..c4a4bbbe3d --- /dev/null +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/Identification/HiiPackages/HiiPackagesVector.java @@ -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 vHiiPackages = new Vector(); + + 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 getvHiiPackages() { + return vHiiPackages; + } + + public void setvHiiPackages(Vector HiiPackages) { + vHiiPackages = HiiPackages; + } + + public Vector getHiiPackagesName() { + Vector v = new Vector(); + for (int index = 0; index < this.vHiiPackages.size(); index++) { + v.addElement(vHiiPackages.get(index).getName()); + } + return v; + } + + public int size() { + return this.vHiiPackages.size(); + } + +} diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/Identification/Hobs/HobsIdentification.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/Identification/Hobs/HobsIdentification.java new file mode 100644 index 0000000000..f577724d77 --- /dev/null +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/Identification/Hobs/HobsIdentification.java @@ -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 supArchList = null; + + private String featureFlag = null; + + private String help = null; + + public HobsIdentification(String arg0, String arg1, String arg2, String arg3, Vector 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 getSupArchList() { + return supArchList; + } + + public void setSupArchList(Vector 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; + } +} diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/Identification/Hobs/HobsVector.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/Identification/Hobs/HobsVector.java new file mode 100644 index 0000000000..5e37245677 --- /dev/null +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/Identification/Hobs/HobsVector.java @@ -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 vHobs = new Vector(); + + 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 getvHobs() { + return vHobs; + } + + public void setvHobs(Vector Hobs) { + vHobs = Hobs; + } + + public Vector getHobsName() { + Vector v = new Vector(); + for (int index = 0; index < this.vHobs.size(); index++) { + v.addElement(vHobs.get(index).getName()); + } + return v; + } + + public int size() { + return this.vHobs.size(); + } + +} diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/Identification/LibraryClass/LibraryClassIdentification.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/Identification/LibraryClass/LibraryClassIdentification.java new file mode 100644 index 0000000000..7f88a97cee --- /dev/null +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/Identification/LibraryClass/LibraryClassIdentification.java @@ -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 supArchList = null; + + private String featureFlag = null; + + private Vector supModuleList = null; + + private String help = null; + + public LibraryClassIdentification() { + + } + + public LibraryClassIdentification(String strName, String strUsage, String strRecommendedInstanceVersion, + String strRecommendedInstanceGuid, Vector vSupArchList, + String strFeatureFlag, Vector 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 getSupArchList() { + return supArchList; + } + + public void setSupArchList(Vector 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 getSupModuleList() { + return supModuleList; + } + + public void setSupModuleList(Vector supModuleList) { + this.supModuleList = supModuleList; + } + + public String getHelp() { + return help; + } + + public void setHelp(String help) { + this.help = help; + } +} diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/Identification/LibraryClass/LibraryClassVector.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/Identification/LibraryClass/LibraryClassVector.java new file mode 100644 index 0000000000..ddacdda841 --- /dev/null +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/Identification/LibraryClass/LibraryClassVector.java @@ -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 vLibraryClass = new Vector(); + + 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 getVLibraryClass() { + return vLibraryClass; + } + + public void setVLibraryClass(Vector libraryClass) { + vLibraryClass = libraryClass; + } + + public Vector getLibraryClassName() { + Vector v = new Vector(); + for (int index = 0; index < this.vLibraryClass.size(); index++) { + v.addElement(vLibraryClass.get(index).getLibraryClassName()); + } + return v; + } + + public int size() { + return this.vLibraryClass.size(); + } +} diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/Identification/ModuleIdentification.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/Identification/ModuleIdentification.java new file mode 100644 index 0000000000..95ada64f9f --- /dev/null +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/Identification/ModuleIdentification.java @@ -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; + } +} diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/Identification/PackageDependencies/PackageDependenciesIdentification.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/Identification/PackageDependencies/PackageDependenciesIdentification.java new file mode 100644 index 0000000000..98a0245797 --- /dev/null +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/Identification/PackageDependencies/PackageDependenciesIdentification.java @@ -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 supArchList = null; + + private String featureFlag = null; + + public PackageDependenciesIdentification(String arg0, String arg1, String arg2, String arg3, Vector 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 getSupArchList() { + return supArchList; + } + + public void setSupArchList(Vector 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; + } +} diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/Identification/PackageDependencies/PackageDependenciesVector.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/Identification/PackageDependencies/PackageDependenciesVector.java new file mode 100644 index 0000000000..7c09710941 --- /dev/null +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/Identification/PackageDependencies/PackageDependenciesVector.java @@ -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 vPackageDependencies = new Vector(); + + 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 getvPackageDependencies() { + return vPackageDependencies; + } + + public void setvPackageDependencies(Vector PackageDependencies) { + vPackageDependencies = PackageDependencies; + } + + public Vector getPackageDependenciesName() { + Vector v = new Vector(); + for (int index = 0; index < this.vPackageDependencies.size(); index++) { + v.addElement(vPackageDependencies.get(index).getName()); + } + return v; + } + + public int size() { + return this.vPackageDependencies.size(); + } + +} diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/Identification/PcdCoded/PcdCodedIdentification.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/Identification/PcdCoded/PcdCodedIdentification.java new file mode 100644 index 0000000000..f605add248 --- /dev/null +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/Identification/PcdCoded/PcdCodedIdentification.java @@ -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 supArchList = null; + + private String value = null; + + private String help = null; + + private String type = null; + + public PcdCodedIdentification(String arg0, String arg1, String arg2, Vector 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 getSupArchList() { + return supArchList; + } + + public void setSupArchList(Vector 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; + } +} diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/Identification/PcdCoded/PcdCodedVector.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/Identification/PcdCoded/PcdCodedVector.java new file mode 100644 index 0000000000..db2a8dcaf2 --- /dev/null +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/Identification/PcdCoded/PcdCodedVector.java @@ -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 vPcdCoded = new Vector(); + + 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 getvPcdCoded() { + return vPcdCoded; + } + + public void setvPcdCoded(Vector PcdCoded) { + vPcdCoded = PcdCoded; + } + + public Vector getPcdCodedName() { + Vector v = new Vector(); + for (int index = 0; index < this.vPcdCoded.size(); index++) { + v.addElement(vPcdCoded.get(index).getName()); + } + return v; + } + + public int size() { + return this.vPcdCoded.size(); + } + +} diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/Identification/Ppis/PpisIdentification.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/Identification/Ppis/PpisIdentification.java new file mode 100644 index 0000000000..3df5c080f7 --- /dev/null +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/Identification/Ppis/PpisIdentification.java @@ -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 supArchList = null; + + private String featureFlag = null; + + private String help = null; + + public PpisIdentification(String arg0, String arg1, String arg2, String arg3, Vector 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 getSupArchList() { + return supArchList; + } + + public void setSupArchList(Vector 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; + } +} diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/Identification/Ppis/PpisVector.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/Identification/Ppis/PpisVector.java new file mode 100644 index 0000000000..85149189af --- /dev/null +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/Identification/Ppis/PpisVector.java @@ -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 vPpis = new Vector(); + + 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 getvPpis() { + return vPpis; + } + + public void setvPpis(Vector Ppis) { + vPpis = Ppis; + } + + public Vector getPpisName() { + Vector v = new Vector(); + for (int index = 0; index < this.vPpis.size(); index++) { + v.addElement(vPpis.get(index).getName()); + } + return v; + } + + public int size() { + return this.vPpis.size(); + } + +} diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/Identification/Protocols/ProtocolsIdentification.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/Identification/Protocols/ProtocolsIdentification.java new file mode 100644 index 0000000000..79567e47d2 --- /dev/null +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/Identification/Protocols/ProtocolsIdentification.java @@ -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 supArchList = null; + + private String featureFlag = null; + + private String help = null; + + public ProtocolsIdentification(String arg0, String arg1, String arg2, String arg3, Vector 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 getSupArchList() { + return supArchList; + } + + public void setSupArchList(Vector 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; + } +} diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/Identification/Protocols/ProtocolsVector.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/Identification/Protocols/ProtocolsVector.java new file mode 100644 index 0000000000..e9e0106add --- /dev/null +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/Identification/Protocols/ProtocolsVector.java @@ -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 vProtocols = new Vector(); + + 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 getvProtocols() { + return vProtocols; + } + + public void setvProtocols(Vector Protocols) { + vProtocols = Protocols; + } + + public Vector getProtocolsName() { + Vector v = new Vector(); + for (int index = 0; index < this.vProtocols.size(); index++) { + v.addElement(vProtocols.get(index).getName()); + } + return v; + } + + public int size() { + return this.vProtocols.size(); + } + +} diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/Identification/SourceFiles/SourceFilesIdentification.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/Identification/SourceFiles/SourceFilesIdentification.java new file mode 100644 index 0000000000..31e95d32f9 --- /dev/null +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/Identification/SourceFiles/SourceFilesIdentification.java @@ -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 supArchList = null; + + private String featureFlag = null; + + public SourceFilesIdentification(String strFilename, String strTagName, String strToolCode, String strToolChainFamily, + String strFeatureFlag, Vector 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 getSupArchList() { + return supArchList; + } + + public void setSupArchList(Vector 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; + } +} diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/Identification/SourceFiles/SourceFilesVector.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/Identification/SourceFiles/SourceFilesVector.java new file mode 100644 index 0000000000..0b9623261e --- /dev/null +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/Identification/SourceFiles/SourceFilesVector.java @@ -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 vSourceFiles = new Vector(); + + 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 getvSourceFiles() { + return vSourceFiles; + } + + public void setvSourceFiles(Vector SourceFiles) { + vSourceFiles = SourceFiles; + } + + public Vector getSourceFilesName() { + Vector v = new Vector(); + for (int index = 0; index < this.vSourceFiles.size(); index++) { + v.addElement(vSourceFiles.get(index).getFilename()); + } + return v; + } + + public int size() { + return this.vSourceFiles.size(); + } +} diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/Identification/SystemTables/SystemTablesIdentification.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/Identification/SystemTables/SystemTablesIdentification.java new file mode 100644 index 0000000000..354e10b40e --- /dev/null +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/Identification/SystemTables/SystemTablesIdentification.java @@ -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 supArchList = null; + + private String featureFlag = null; + + private String help = null; + + public SystemTablesIdentification(String arg0, String arg1, String arg2, Vector 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 getSupArchList() { + return supArchList; + } + + public void setSupArchList(Vector 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; + } +} diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/Identification/SystemTables/SystemTablesVector.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/Identification/SystemTables/SystemTablesVector.java new file mode 100644 index 0000000000..eea0280ebf --- /dev/null +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/Identification/SystemTables/SystemTablesVector.java @@ -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 vSystemTables = new Vector(); + + 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 getvSystemTables() { + return vSystemTables; + } + + public void setvSystemTables(Vector SystemTables) { + vSystemTables = SystemTables; + } + + public Vector getSystemTablesName() { + Vector v = new Vector(); + for (int index = 0; index < this.vSystemTables.size(); index++) { + v.addElement(vSystemTables.get(index).getName()); + } + return v; + } + + public int size() { + return this.vSystemTables.size(); + } + +} diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/Identification/Variables/VariablesIdentification.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/Identification/Variables/VariablesIdentification.java new file mode 100644 index 0000000000..bfa4c127d2 --- /dev/null +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/Identification/Variables/VariablesIdentification.java @@ -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 supArchList = null; + + private String featureFlag = null; + + private String help = null; + + public VariablesIdentification(String arg0, String arg1, String arg2, String arg3, Vector 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 getSupArchList() { + return supArchList; + } + + public void setSupArchList(Vector 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; + } +} diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/Identification/Variables/VariablesVector.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/Identification/Variables/VariablesVector.java new file mode 100644 index 0000000000..543ebe6054 --- /dev/null +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/Identification/Variables/VariablesVector.java @@ -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 vVariables = new Vector(); + + 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 getvVariables() { + return vVariables; + } + + public void setvVariables(Vector Variables) { + vVariables = Variables; + } + + public Vector getVariablesName() { + Vector v = new Vector(); + for (int index = 0; index < this.vVariables.size(); index++) { + v.addElement(vVariables.get(index).getName()); + } + return v; + } + + public int size() { + return this.vVariables.size(); + } + +} diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/ModuleBootModes.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/ModuleBootModes.java new file mode 100644 index 0000000000..4e0652cb4e --- /dev/null +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/ModuleBootModes.java @@ -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 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 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(); + } + } +} diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/ModuleDataHubs.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/ModuleDataHubs.java new file mode 100644 index 0000000000..8905518a71 --- /dev/null +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/ModuleDataHubs.java @@ -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 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 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(); + } + } +} diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/ModuleDefinitions.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/ModuleDefinitions.java new file mode 100644 index 0000000000..f3bc5e70c6 --- /dev/null +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/ModuleDefinitions.java @@ -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(); + } +} diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/ModuleEvents.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/ModuleEvents.java new file mode 100644 index 0000000000..165fbd6068 --- /dev/null +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/ModuleEvents.java @@ -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 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 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 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(); + } + } +} diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/ModuleExterns.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/ModuleExterns.java new file mode 100644 index 0000000000..6654e06e22 --- /dev/null +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/ModuleExterns.java @@ -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 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 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); + } + } +} diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/ModuleGuids.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/ModuleGuids.java new file mode 100644 index 0000000000..b8d085104b --- /dev/null +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/ModuleGuids.java @@ -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 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 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(); + } + } +} diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/ModuleHiiPackages.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/ModuleHiiPackages.java new file mode 100644 index 0000000000..008ea5d109 --- /dev/null +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/ModuleHiiPackages.java @@ -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 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 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(); + } + } +} diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/ModuleHobs.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/ModuleHobs.java new file mode 100644 index 0000000000..81f2df92ff --- /dev/null +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/ModuleHobs.java @@ -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 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 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(); + } + } +} diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/ModuleLibraryClassDefinitions.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/ModuleLibraryClassDefinitions.java new file mode 100644 index 0000000000..6b060cb3ed --- /dev/null +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/ModuleLibraryClassDefinitions.java @@ -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 vLib = new Vector(); + + 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 arch = Tools.convertListToVector(lcd.getLibraryClassList().get(index) + .getSupArchList()); + Vector 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 arch = this.iCheckBoxListArch.getAllCheckedItemsString(); + Vector 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); + } +} diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/ModulePCDs.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/ModulePCDs.java new file mode 100644 index 0000000000..f2cd162245 --- /dev/null +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/ModulePCDs.java @@ -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 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 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(); + } + } +} diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/ModulePackageDependencies.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/ModulePackageDependencies.java new file mode 100644 index 0000000000..beefb879da --- /dev/null +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/ModulePackageDependencies.java @@ -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 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 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 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()); + } + } + } + } + +} diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/ModulePpis.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/ModulePpis.java new file mode 100644 index 0000000000..941c05acbe --- /dev/null +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/ModulePpis.java @@ -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 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 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 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()); + } + } + } +} diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/ModuleProtocols.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/ModuleProtocols.java new file mode 100644 index 0000000000..e591292883 --- /dev/null +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/ModuleProtocols.java @@ -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 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 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 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()); + } + } + } +} diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/ModuleSourceFiles.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/ModuleSourceFiles.java new file mode 100644 index 0000000000..739fec0119 --- /dev/null +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/ModuleSourceFiles.java @@ -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 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 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); + } +} diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/ModuleSystemTables.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/ModuleSystemTables.java new file mode 100644 index 0000000000..64f1137b54 --- /dev/null +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/ModuleSystemTables.java @@ -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 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 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(); + } + } +} diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/ModuleVariables.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/ModuleVariables.java new file mode 100644 index 0000000000..2b56122f13 --- /dev/null +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/ModuleVariables.java @@ -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 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 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(); + } + } +} diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/MsaHeader.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/MsaHeader.java new file mode 100644 index 0000000000..c4576a8327 --- /dev/null +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/MsaHeader.java @@ -0,0 +1,1002 @@ +/** @file + + The file is used to create, update MsaHeader of MSA file + + Copyright (c) 2006, Intel Corporation + All rights reserved. This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + **/ + +package org.tianocore.frameworkwizard.module.ui; + +import java.awt.event.ActionEvent; +import java.awt.event.ComponentEvent; +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.ModuleSurfaceAreaDocument; +import org.tianocore.ModuleTypeDef; +import org.tianocore.MsaHeaderDocument; +import org.tianocore.LicenseDocument.License; +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; + +/** + The class is used to create, update MsaHeader of MSA file + It extends IInternalFrame + + + + **/ +public class MsaHeader extends IInternalFrame { + + /// + /// Define class Serial Version UID + /// + private static final long serialVersionUID = -8152099582923006900L; + + // + //Define class members + // + private JPanel jContentPane = null; + + private JLabel jLabelBaseName = null; + + private JTextField jTextFieldBaseName = null; + + private JLabel jLabelGuid = null; + + private JTextField jTextFieldGuid = null; + + private JLabel jLabelVersion = null; + + private JTextField jTextFieldVersion = null; + + private JButton jButtonGenerateGuid = null; + + private JLabel jLabelLicense = null; + + private JTextArea jTextAreaLicense = null; + + private JLabel jLabelCopyright = null; + + private JLabel jLabelDescription = null; + + private JTextArea jTextAreaDescription = null; + + private JLabel jLabelSpecification = null; + + private JTextField jTextFieldSpecification = null; + + private JButton jButtonOk = null; + + private JButton jButtonCancel = null; + + private JScrollPane jScrollPaneLicense = null; + + private JScrollPane jScrollPaneDescription = null; + + private JLabel jLabelAbstract = null; + + private JTextField jTextFieldAbstract = null; + + private JLabel jLabelModuleType = null; + + private JComboBox jComboBoxModuleType = null; + + private StarLabel jStarLabel1 = null; + + private StarLabel jStarLabel2 = null; + + private StarLabel jStarLabel4 = null; + + private StarLabel jStarLabel5 = null; + + private StarLabel jStarLabel6 = null; + + private StarLabel jStarLabel7 = null; + + private StarLabel jStarLabel8 = null; + + private StarLabel jStarLabel10 = null; + + private StarLabel jStarLabel12 = null; + + private MsaHeaderDocument.MsaHeader msaHeader = null; + + private ModuleSurfaceAreaDocument.ModuleSurfaceArea msa = null; + + private JTextField jTextFieldCopyright = null; + + private JLabel jLabelURL = null; + + private JTextField jTextFieldURL = null; + + private JScrollPane jScrollPane = null; + + private OpeningModuleType omt = 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(this); + jTextFieldBaseName.setToolTipText("An brief Identifier, such as USB I/O Library, of the module"); + } + return jTextFieldBaseName; + } + + /** + This method initializes jTextFieldGuid + + @return javax.swing.JTextField jTextFieldGuid + + **/ + private JTextField getJTextFieldGuid() { + if (jTextFieldGuid == null) { + jTextFieldGuid = new JTextField(); + jTextFieldGuid.setPreferredSize(new java.awt.Dimension(250, 20)); + jTextFieldGuid.setLocation(new java.awt.Point(160, 60)); + jTextFieldGuid.setSize(new java.awt.Dimension(250, 20)); + jTextFieldGuid.addFocusListener(this); + jTextFieldGuid.setToolTipText("Guaranteed Unique Identification Number (8-4-4-4-12)"); + } + return jTextFieldGuid; + } + + /** + This method initializes jTextFieldVersion + + @return javax.swing.JTextField jTextFieldVersion + + **/ + private JTextField getJTextFieldVersion() { + if (jTextFieldVersion == null) { + jTextFieldVersion = new JTextField(); + jTextFieldVersion.setPreferredSize(new java.awt.Dimension(320, 20)); + jTextFieldVersion.setLocation(new java.awt.Point(160, 85)); + jTextFieldVersion.setSize(new java.awt.Dimension(320, 20)); + jTextFieldVersion.addFocusListener(this); + jTextFieldVersion.setToolTipText("A Version Number, 1.0, 1, 1.01"); + } + return jTextFieldVersion; + } + + /** + This method initializes jButtonGenerateGuid + + @return javax.swing.JButton jButtonGenerateGuid + + **/ + private JButton getJButtonGenerateGuid() { + if (jButtonGenerateGuid == null) { + jButtonGenerateGuid = new JButton(); + jButtonGenerateGuid.setPreferredSize(new java.awt.Dimension(65, 20)); + jButtonGenerateGuid.setSize(new java.awt.Dimension(65, 20)); + jButtonGenerateGuid.setLocation(new java.awt.Point(415, 60)); + jButtonGenerateGuid.setText("GEN"); + jButtonGenerateGuid.addActionListener(this); + } + return jButtonGenerateGuid; + } + + /** + This method initializes jTextAreaLicense + + @return javax.swing.JTextArea jTextAreaLicense + + **/ + private JTextArea getJTextAreaLicense() { + if (jTextAreaLicense == null) { + jTextAreaLicense = new JTextArea(); + jTextAreaLicense.setText(""); + jTextAreaLicense.setLineWrap(true); + jTextAreaLicense.addFocusListener(this); + jTextAreaLicense.setToolTipText("The License for this file"); + } + return jTextAreaLicense; + } + + /** + This method initializes jTextAreaDescription + + @return javax.swing.JTextArea jTextAreaDescription + + **/ + private JTextArea getJTextAreaDescription() { + if (jTextAreaDescription == null) { + jTextAreaDescription = new JTextArea(); + jTextAreaDescription.setLineWrap(true); + jTextAreaDescription.addFocusListener(this); + jTextAreaDescription.setToolTipText("A verbose description of the module"); + } + return jTextAreaDescription; + } + + /** + This method initializes jTextFieldSpecification + + @return javax.swing.JTextField jTextFieldSpecification + + **/ + private JTextField getJTextFieldSpecification() { + if (jTextFieldSpecification == null) { + jTextFieldSpecification = new JTextField(); + jTextFieldSpecification.setPreferredSize(new java.awt.Dimension(320, 20)); + jTextFieldSpecification.setText("FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052"); + jTextFieldSpecification.setSize(new java.awt.Dimension(320, 20)); + jTextFieldSpecification.setLocation(new java.awt.Point(160, 435)); + jTextFieldSpecification.setEditable(false); + jTextFieldSpecification.addFocusListener(this); + jTextFieldSpecification + .setToolTipText("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"); + } + return jTextFieldSpecification; + } + + /** + This method initializes jButtonOk + + @return javax.swing.JButton jButtonOk + + **/ + private JButton getJButtonOk() { + if (jButtonOk == null) { + jButtonOk = new JButton(); + jButtonOk.setText("OK"); + jButtonOk.setPreferredSize(new java.awt.Dimension(90, 20)); + jButtonOk.setBounds(new java.awt.Rectangle(390, 455, 90, 20)); + jButtonOk.addActionListener(this); + jButtonOk.setVisible(false); + } + return jButtonOk; + } + + /** + This method initializes jButtonCancel + + @return javax.swing.JButton jButtonCancel + + **/ + private JButton getJButtonCancel() { + if (jButtonCancel == null) { + jButtonCancel = new JButton(); + jButtonCancel.setText("Cancel"); + jButtonCancel.setBounds(new java.awt.Rectangle(390, 445, 90, 20)); + jButtonCancel.addActionListener(this); + jButtonCancel.setPreferredSize(new java.awt.Dimension(90, 20)); + jButtonCancel.setVisible(false); + } + return jButtonCancel; + } + + /** + This method initializes jScrollPaneLicense + + @return javax.swing.JScrollPane jScrollPaneLicense + + **/ + private JScrollPane getJScrollPaneLicense() { + if (jScrollPaneLicense == null) { + jScrollPaneLicense = new JScrollPane(); + jScrollPaneLicense.setHorizontalScrollBarPolicy(javax.swing.JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); + jScrollPaneLicense.setSize(new java.awt.Dimension(320, 120)); + jScrollPaneLicense.setLocation(new java.awt.Point(160, 285)); + jScrollPaneLicense.setViewportView(getJTextAreaLicense()); + jScrollPaneLicense.setPreferredSize(new java.awt.Dimension(320, 120)); + } + return jScrollPaneLicense; + } + + /** + This method initializes jScrollPaneDescription + + @return javax.swing.JScrollPane jScrollPaneDescription + + **/ + private JScrollPane getJScrollPaneDescription() { + if (jScrollPaneDescription == null) { + jScrollPaneDescription = new JScrollPane(); + jScrollPaneDescription.setHorizontalScrollBarPolicy(javax.swing.JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); + jScrollPaneDescription.setSize(new java.awt.Dimension(320, 120)); + jScrollPaneDescription.setLocation(new java.awt.Point(160, 135)); + jScrollPaneDescription.setViewportView(getJTextAreaDescription()); + jScrollPaneDescription.setPreferredSize(new java.awt.Dimension(320, 120)); + } + return jScrollPaneDescription; + } + + /** + This method initializes jTextFieldAbstract + + @return javax.swing.JTextField jTextFieldAbstract + + **/ + private JTextField getJTextFieldAbstract() { + if (jTextFieldAbstract == null) { + jTextFieldAbstract = new JTextField(); + jTextFieldAbstract.setPreferredSize(new java.awt.Dimension(320, 20)); + jTextFieldAbstract.setLocation(new java.awt.Point(160, 110)); + jTextFieldAbstract.setSize(new java.awt.Dimension(320, 20)); + jTextFieldAbstract.addFocusListener(this); + jTextFieldAbstract.setToolTipText("A one sentence description of this module"); + } + return jTextFieldAbstract; + } + + /** + This method initializes jComboBoxModuleType + + @return javax.swing.JComboBox jComboBoxModuleType + + **/ + private JComboBox getJComboBoxModuleType() { + if (jComboBoxModuleType == null) { + jComboBoxModuleType = new JComboBox(); + jComboBoxModuleType.setBounds(new java.awt.Rectangle(160, 35, 320, 20)); + jComboBoxModuleType.setPreferredSize(new java.awt.Dimension(320, 20)); + jComboBoxModuleType.addFocusListener(this); + } + return jComboBoxModuleType; + } + + /** + This method initializes jTextFieldCopyright + + @return javax.swing.JTextField jTextFieldCopyright + + **/ + private JTextField getJTextFieldCopyright() { + if (jTextFieldCopyright == null) { + jTextFieldCopyright = new JTextField(); + jTextFieldCopyright.setPreferredSize(new java.awt.Dimension(320, 20)); + jTextFieldCopyright.setLocation(new java.awt.Point(160, 260)); + jTextFieldCopyright.setSize(new java.awt.Dimension(320, 20)); + jTextFieldCopyright.addFocusListener(this); + jTextFieldCopyright.setToolTipText("One or more copyright lines"); + } + return jTextFieldCopyright; + } + + /** + * This method initializes jTextFieldURL + * + * @return javax.swing.JTextField + */ + private JTextField getJTextFieldURL() { + if (jTextFieldURL == null) { + jTextFieldURL = new JTextField(); + jTextFieldURL.setPreferredSize(new java.awt.Dimension(320, 20)); + jTextFieldURL.setLocation(new java.awt.Point(160, 410)); + jTextFieldURL.setSize(new java.awt.Dimension(320, 20)); + jTextFieldURL.addFocusListener(this); + jTextFieldURL.setToolTipText("A URL for the latest version of the license"); + } + return jTextFieldURL; + } + + /** + * This method initializes jScrollPane + * + * @return javax.swing.JScrollPane + */ + private JScrollPane getJScrollPane() { + if (jScrollPane == null) { + jScrollPane = new JScrollPane(); + jScrollPane.setViewportView(getJContentPane()); + } + return jScrollPane; + } + + public static void main(String[] args) { + + } + + /** + This is the default constructor + + **/ + public MsaHeader() { + super(); + init(); + this.setVisible(true); + } + + /** + This is the override edit constructor + + @param inMsaHeader The input data of MsaHeaderDocument.MsaHeader + + **/ + public MsaHeader(OpeningModuleType inMsa) { + super(); + this.omt = inMsa; + this.msa = omt.getXmlMsa(); + init(msa.getMsaHeader()); + this.setVisible(true); + this.setViewMode(false); + } + + /** + Disable all components when the mode is view + + @param isView true - The view mode; false - The non-view mode + + **/ + public void setViewMode(boolean isView) { + //this.jButtonOk.setVisible(false); + //this.jButtonCancel.setVisible(false); + if (isView) { + this.jTextFieldBaseName.setEnabled(!isView); + this.jTextFieldGuid.setEnabled(!isView); + this.jTextFieldVersion.setEnabled(!isView); + this.jTextAreaLicense.setEnabled(!isView); + this.jTextFieldCopyright.setEnabled(!isView); + this.jTextAreaDescription.setEnabled(!isView); + this.jTextFieldSpecification.setEnabled(!isView); + this.jTextFieldAbstract.setEnabled(!isView); + this.jComboBoxModuleType.setEnabled(!isView); + this.jButtonCancel.setEnabled(!isView); + this.jButtonGenerateGuid.setEnabled(!isView); + this.jButtonOk.setEnabled(!isView); + } + } + + /** + This method initializes this + + **/ + private void init() { + this.setSize(500, 515); + this.setPreferredSize(new java.awt.Dimension(490, 520)); + this.setContentPane(getJScrollPane()); + this.setTitle("Module Surface Area Header"); + initFrame(); + } + + /** + This method initializes this + Fill values to all fields if these values are not empty + + @param inMsaHeader The input data of MsaHeaderDocument.MsaHeader + + **/ + private void init(MsaHeaderDocument.MsaHeader inMsaHeader) { + init(); + if (inMsaHeader != null) { + setMsaHeader(inMsaHeader); + if (this.msaHeader.getModuleName() != null) { + this.jTextFieldBaseName.setText(this.msaHeader.getModuleName()); + } + if (this.msaHeader.getModuleType() != null) { + this.jComboBoxModuleType.setSelectedItem(this.msaHeader.getModuleType().toString()); + } + if (this.msaHeader.getGuidValue() != null) { + this.jTextFieldGuid.setText(this.msaHeader.getGuidValue()); + } + if (this.msaHeader.getVersion() != null) { + this.jTextFieldVersion.setText(this.msaHeader.getVersion()); + } + if (this.msaHeader.getAbstract() != null) { + this.jTextFieldAbstract.setText(this.msaHeader.getAbstract()); + } + if (this.msaHeader.getDescription() != null) { + this.jTextAreaDescription.setText(this.msaHeader.getDescription()); + } + if (this.msaHeader.getCopyright() != null) { + this.jTextFieldCopyright.setText(this.msaHeader.getCopyright()); + } + if (this.msaHeader.getLicense() != null) { + this.jTextAreaLicense.setText(this.msaHeader.getLicense().getStringValue()); + } + if (this.msaHeader.getLicense() != null && this.msaHeader.getLicense().getURL() != null) { + this.jTextFieldURL.setText(this.msaHeader.getLicense().getURL()); + } + if (this.msaHeader.getSpecification() != null) { + this.jTextFieldSpecification.setText(this.msaHeader.getSpecification()); + } + } + } + + /** + This method initializes jContentPane + + @return javax.swing.JPanel jContentPane + + **/ + private JPanel getJContentPane() { + if (jContentPane == null) { + + jLabelURL = new JLabel(); + jLabelURL.setText("License URL"); + jLabelURL.setLocation(new java.awt.Point(15, 410)); + jLabelURL.setSize(new java.awt.Dimension(140, 20)); + jLabelBaseName = new JLabel(); + jLabelBaseName.setText("Module Name"); + jLabelBaseName.setBounds(new java.awt.Rectangle(15, 10, 140, 20)); + jLabelModuleType = new JLabel(); + jLabelModuleType.setBounds(new java.awt.Rectangle(15, 35, 140, 20)); + jLabelModuleType.setText("Module Type"); + jLabelGuid = new JLabel(); + jLabelGuid.setText("Guid Value"); + jLabelGuid.setLocation(new java.awt.Point(15, 60)); + jLabelGuid.setSize(new java.awt.Dimension(140, 20)); + jLabelVersion = new JLabel(); + jLabelVersion.setText("Version"); + jLabelVersion.setLocation(new java.awt.Point(15, 85)); + jLabelVersion.setSize(new java.awt.Dimension(140, 20)); + jLabelAbstract = new JLabel(); + jLabelAbstract.setText("Abstract"); + jLabelAbstract.setLocation(new java.awt.Point(15, 110)); + jLabelAbstract.setSize(new java.awt.Dimension(140, 20)); + jLabelDescription = new JLabel(); + jLabelDescription.setText("Description"); + jLabelDescription.setLocation(new java.awt.Point(15, 135)); + jLabelDescription.setSize(new java.awt.Dimension(140, 20)); + jLabelCopyright = new JLabel(); + jLabelCopyright.setText("Copyright"); + jLabelCopyright.setLocation(new java.awt.Point(15, 260)); + jLabelCopyright.setSize(new java.awt.Dimension(140, 20)); + jLabelLicense = new JLabel(); + jLabelLicense.setText("License"); + jLabelLicense.setLocation(new java.awt.Point(15, 285)); + jLabelLicense.setSize(new java.awt.Dimension(140, 20)); + jLabelSpecification = new JLabel(); + jLabelSpecification.setText("Specification"); + jLabelSpecification.setLocation(new java.awt.Point(14, 435)); + jLabelSpecification.setSize(new java.awt.Dimension(140, 20)); + + jContentPane = new JPanel(); + jContentPane.setLayout(null); + jContentPane.setPreferredSize(new java.awt.Dimension(490, 470)); + + jContentPane.add(jLabelBaseName, null); + jContentPane.add(getJTextFieldBaseName(), null); + jContentPane.add(jLabelGuid, null); + jContentPane.add(getJTextFieldGuid(), null); + jContentPane.add(jLabelVersion, null); + jContentPane.add(getJTextFieldVersion(), null); + jContentPane.add(getJButtonGenerateGuid(), null); + jContentPane.add(jLabelLicense, null); + jContentPane.add(jLabelCopyright, null); + jContentPane.add(jLabelDescription, null); + jContentPane.add(jLabelSpecification, null); + jContentPane.add(getJTextFieldSpecification(), null); + jContentPane.add(getJButtonOk(), null); + jContentPane.add(getJButtonCancel(), null); + jContentPane.add(getJScrollPaneLicense(), null); + jContentPane.add(getJScrollPaneDescription(), null); + jContentPane.add(jLabelAbstract, null); + jContentPane.add(getJTextFieldAbstract(), null); + jContentPane.add(jLabelModuleType, null); + jContentPane.add(getJComboBoxModuleType(), null); + jContentPane.add(jLabelURL, null); + jContentPane.add(getJTextFieldURL(), null); + jContentPane.add(getJTextFieldCopyright(), null); + jStarLabel1 = new StarLabel(); + jStarLabel1.setLocation(new java.awt.Point(0, 10)); + jStarLabel2 = new StarLabel(); + jStarLabel2.setLocation(new java.awt.Point(0, 35)); + jStarLabel4 = new StarLabel(); + jStarLabel4.setLocation(new java.awt.Point(0, 60)); + jStarLabel5 = new StarLabel(); + jStarLabel5.setLocation(new java.awt.Point(0, 85)); + jStarLabel6 = new StarLabel(); + jStarLabel6.setLocation(new java.awt.Point(0, 135)); + jStarLabel7 = new StarLabel(); + jStarLabel7.setLocation(new java.awt.Point(0, 260)); + jStarLabel8 = new StarLabel(); + jStarLabel8.setLocation(new java.awt.Point(0, 285)); + jStarLabel10 = new StarLabel(); + jStarLabel10.setLocation(new java.awt.Point(0, 110)); + jStarLabel12 = new StarLabel(); + jStarLabel12.setLocation(new java.awt.Point(0, 435)); + + jContentPane.add(jStarLabel1, null); + jContentPane.add(jStarLabel2, null); + jContentPane.add(jStarLabel4, null); + jContentPane.add(jStarLabel5, null); + jContentPane.add(jStarLabel6, null); + jContentPane.add(jStarLabel7, null); + jContentPane.add(jStarLabel8, null); + jContentPane.add(jStarLabel10, null); + jContentPane.add(jStarLabel12, 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) { + if (this.check()) { + this.save(); + } else { + return; + } + this.setEdited(true); + this.dispose(); + } + if (arg0.getSource() == jButtonCancel) { + this.setEdited(false); + } + if (arg0.getSource() == jButtonGenerateGuid) { + jTextFieldGuid.setText(Tools.generateUuidString()); + } + } + + /** + Data validation for all fields + + @retval true - All datas are valid + @retval false - At least one data is invalid + + **/ + public boolean check() { + // + // Check if all required fields are not empty + // and check if all data fields values are valid + // + + // + // Check Base Name + // + if (isEmpty(this.jTextFieldBaseName.getText())) { + Log.err("Base Name couldn't be empty"); + //this.jTextFieldBaseName.requestFocus(); + return false; + } + if (!DataValidation.isBaseName(this.jTextFieldBaseName.getText())) { + Log.err("Incorrect data type for Base Name"); + //this.jTextFieldBaseName.requestFocus(); + return false; + } + + // + // Check Guid + // + if (isEmpty(this.jTextFieldGuid.getText())) { + Log.err("Guid Value couldn't be empty"); + //this.jTextFieldGuid.requestFocus(); + return false; + } + if (!DataValidation.isGuid((this.jTextFieldGuid).getText())) { + Log.err("Incorrect data type for Guid"); + //this.jTextFieldGuid.requestFocus(); + return false; + } + + // + // Check Version + // + if (isEmpty(this.jTextFieldVersion.getText())) { + Log.err("Version couldn't be empty"); + //this.jTextFieldVersion.requestFocus(); + return false; + } + if (!DataValidation.isVersion(this.jTextFieldVersion.getText())) { + Log.err("Incorrect data type for Version"); + //this.jTextFieldVersion.requestFocus(); + return false; + } + + // + // Check Abstact + // + if (isEmpty(this.jTextFieldAbstract.getText())) { + Log.err("Abstract couldn't be empty"); + //this.jTextFieldAbstract.requestFocus(); + return false; + } + if (!DataValidation.isAbstract(this.jTextFieldAbstract.getText())) { + Log.err("Incorrect data type for Abstract"); + //this.jTextFieldAbstract.requestFocus(); + return false; + } + + // + // Check Description + // + if (isEmpty(this.jTextAreaDescription.getText())) { + Log.err("Description couldn't be empty"); + //this.jTextAreaDescription.requestFocus(); + return false; + } + + // + // Check Copyright + // + if (isEmpty(this.jTextFieldCopyright.getText())) { + Log.err("Copyright couldn't be empty"); + //this.jTextFieldCopyright.requestFocus(); + return false; + } + + // + // Check License + // + if (isEmpty(this.jTextAreaLicense.getText())) { + Log.err("License couldn't be empty"); + //this.jTextAreaLicense.requestFocus(); + return false; + } + + // + // Check Specification + // + if (isEmpty(this.jTextFieldSpecification.getText())) { + Log.err("Specification couldn't be empty"); + //this.jTextFieldSpecification.requestFocus(); + return false; + } + if (!DataValidation.isSpecification(this.jTextFieldSpecification.getText())) { + Log.err("Incorrect data type for Specification"); + //this.jTextFieldSpecification.requestFocus(); + return false; + } + + return true; + } + + /** + Save all components of Msa Header + if exists msaHeader, set the value directly + if not exists msaHeader, new an instance first + + **/ + public void save() { + try { + // this.msaHeader.setModuleName(this.jTextFieldBaseName.getText()); + // this.msaHeader.setModuleType(ModuleTypeDef.Enum.forString(this.jComboBoxModuleType.getSelectedItem() + // .toString())); + // this.msaHeader.setGuidValue(this.jTextFieldGuid.getText()); + // this.msaHeader.setVersion(this.jTextFieldVersion.getText()); + // this.msaHeader.setAbstract(this.jTextFieldAbstract.getText()); + // this.msaHeader.setDescription(this.jTextAreaDescription.getText()); + // this.msaHeader.setCopyright(this.jTextFieldCopyright.getText()); + // if (this.msaHeader.getLicense() != null) { + // this.msaHeader.getLicense().setStringValue(this.jTextAreaLicense.getText()); + // } else { + // License mLicense = License.Factory.newInstance(); + // mLicense.setStringValue(this.jTextAreaLicense.getText()); + // this.msaHeader.setLicense(mLicense); + // } + // if (!isEmpty(this.jTextFieldURL.getText())) { + // this.msaHeader.getLicense().setURL(this.jTextFieldURL.getText()); + // } + // this.msaHeader.setSpecification(this.jTextFieldSpecification.getText()); + + msa.setMsaHeader(msaHeader); + this.omt.setSaved(false); + } catch (Exception e) { + Log.err("Save Module", e.getMessage()); + } + } + + /** + This method initializes Module type and Compontent type + + **/ + private void initFrame() { + EnumerationData ed = new EnumerationData(); + Tools.generateComboBoxByVector(jComboBoxModuleType, ed.getVModuleType()); + } + + /** + Get MsaHeaderDocument.MsaHeader + + @return MsaHeaderDocument.MsaHeader + + **/ + public MsaHeaderDocument.MsaHeader getMsaHeader() { + return msaHeader; + } + + /** + Set MsaHeaderDocument.MsaHeader + + @param msaHeader The input data of MsaHeaderDocument.MsaHeader + + **/ + public void setMsaHeader(MsaHeaderDocument.MsaHeader msaHeader) { + this.msaHeader = msaHeader; + } + + /* (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.jTextFieldBaseName, intCurrentWidth, intPreferredWidth); + resizeComponentWidth(this.jTextFieldGuid, intCurrentWidth, intPreferredWidth); + resizeComponentWidth(this.jTextFieldVersion, intCurrentWidth, intPreferredWidth); + resizeComponentWidth(this.jScrollPaneLicense, intCurrentWidth, intPreferredWidth); + resizeComponentWidth(this.jTextFieldURL, intCurrentWidth, intPreferredWidth); + resizeComponentWidth(this.jTextFieldCopyright, intCurrentWidth, intPreferredWidth); + resizeComponentWidth(this.jScrollPaneDescription, intCurrentWidth, intPreferredWidth); + resizeComponentWidth(this.jTextFieldSpecification, intCurrentWidth, intPreferredWidth); + resizeComponentWidth(this.jTextFieldAbstract, intCurrentWidth, intPreferredWidth); + resizeComponentWidth(this.jComboBoxModuleType, intCurrentWidth, intPreferredWidth); + relocateComponentX(this.jButtonGenerateGuid, intCurrentWidth, intPreferredWidth, + DataType.SPACE_TO_RIGHT_FOR_GENERATE_BUTTON); + } + + public void focusLost(FocusEvent arg0) { + if (this.msaHeader == null) { + msaHeader = MsaHeaderDocument.MsaHeader.Factory.newInstance(); + } + + // + // Check BaseName + // + if (arg0.getSource() == this.jTextFieldBaseName) { + if (isEmpty(this.jTextFieldBaseName.getText())) { + Log.err("Base Name couldn't be empty"); + //this.jTextFieldBaseName.requestFocus(); + return; + } + if (!DataValidation.isBaseName(this.jTextFieldBaseName.getText())) { + Log.err("Incorrect data type for Base Name"); + //this.jTextFieldBaseName.requestFocus(); + return; + } + this.msaHeader.setModuleName(this.jTextFieldBaseName.getText()); + } + + // + // Check Module Type + // + if (arg0.getSource() == this.jComboBoxModuleType) { + msaHeader.setModuleType(ModuleTypeDef.Enum.forString(jComboBoxModuleType.getSelectedItem().toString())); + } + + // + // Check Guid + // + if (arg0.getSource() == this.jTextFieldGuid) { + if (isEmpty(this.jTextFieldGuid.getText())) { + Log.err("Guid Value couldn't be empty"); + //this.jTextFieldGuid.requestFocus(); + return; + } + if (!DataValidation.isGuid((this.jTextFieldGuid).getText())) { + Log.err("Incorrect data type for Guid"); + //this.jTextFieldGuid.requestFocus(); + return; + } + this.msaHeader.setGuidValue(jTextFieldGuid.getText()); + } + + // + // Check Version + // + if (arg0.getSource() == this.jTextFieldVersion) { + + if (isEmpty(this.jTextFieldVersion.getText())) { + Log.err("Version couldn't be empty"); + //this.jTextFieldVersion.requestFocus(); + return; + } + if (!DataValidation.isVersion(this.jTextFieldVersion.getText())) { + Log.err("Incorrect data type for Version"); + //this.jTextFieldVersion.requestFocus(); + return; + } + this.msaHeader.setVersion(this.jTextFieldVersion.getText()); + } + + // + // Check Abstact + // + if (arg0.getSource() == this.jTextFieldAbstract) { + if (isEmpty(this.jTextFieldAbstract.getText())) { + Log.err("Abstract couldn't be empty"); + //this.jTextFieldAbstract.requestFocus(); + return; + } + if (!DataValidation.isAbstract(this.jTextFieldAbstract.getText())) { + Log.err("Incorrect data type for Abstract"); + //this.jTextFieldAbstract.requestFocus(); + return; + } + this.msaHeader.setAbstract(this.jTextFieldAbstract.getText()); + } + + // + // Check Description + // + if (arg0.getSource() == this.jTextAreaDescription) { + if (isEmpty(this.jTextAreaDescription.getText())) { + Log.err("Description couldn't be empty"); + //this.jTextAreaDescription.requestFocus(); + return; + } + this.msaHeader.setDescription(this.jTextAreaDescription.getText()); + } + + // + // Check Copyright + // + if (arg0.getSource() == this.jTextFieldCopyright) { + if (isEmpty(this.jTextFieldCopyright.getText())) { + Log.err("Copyright couldn't be empty"); + //this.jTextFieldCopyright.requestFocus(); + return; + } + this.msaHeader.setDescription(this.jTextFieldCopyright.getText()); + } + + // + // Check License + // + if (arg0.getSource() == this.jTextAreaLicense) { + if (isEmpty(this.jTextAreaLicense.getText())) { + Log.err("License couldn't be empty"); + //this.jTextAreaLicense.requestFocus(); + return; + } + if (this.msaHeader.getLicense() != null) { + this.msaHeader.getLicense().setStringValue(this.jTextAreaLicense.getText()); + } else { + License mLicense = License.Factory.newInstance(); + mLicense.setStringValue(this.jTextAreaLicense.getText()); + this.msaHeader.setLicense(mLicense); + } + } + + // + // Check License URL + // + if (arg0.getSource() == this.jTextFieldURL) { + if (!isEmpty(this.jTextFieldURL.getText())) { + if (this.msaHeader.getLicense() == null) { + License mLicense = License.Factory.newInstance(); + mLicense.setURL(this.jTextFieldURL.getText()); + this.msaHeader.setLicense(mLicense); + } else { + this.msaHeader.getLicense().setURL(this.jTextFieldURL.getText()); + } + } + } + + this.save(); + } +} diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/packaging/PackageIdentification.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/packaging/PackageIdentification.java new file mode 100644 index 0000000000..3599621ac6 --- /dev/null +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/packaging/PackageIdentification.java @@ -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(); + } +} diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/packaging/ui/GenGuidDialog.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/packaging/ui/GenGuidDialog.java new file mode 100644 index 0000000000..68453587d2 --- /dev/null +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/packaging/ui/GenGuidDialog.java @@ -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" diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/packaging/ui/GuidEditor.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/packaging/ui/GuidEditor.java new file mode 100644 index 0000000000..9ac041add9 --- /dev/null +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/packaging/ui/GuidEditor.java @@ -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(); + + } + + } + +} diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/packaging/ui/SpdFileContents.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/packaging/ui/SpdFileContents.java new file mode 100644 index 0000000000..061833b899 --- /dev/null +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/packaging/ui/SpdFileContents.java @@ -0,0 +1,1537 @@ +/** @file + Java class SpdFileContents is used to parse spd xml file. + +Copyright (c) 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +**/ +package org.tianocore.frameworkwizard.packaging.ui; + +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import java.util.ListIterator; +import java.util.Vector; + +import javax.xml.namespace.QName; + +import org.apache.xmlbeans.XmlObject; +import org.apache.xmlbeans.XmlOptions; +import org.apache.xmlbeans.XmlCursor; + +import org.tianocore.FilenameDocument; +import org.tianocore.GuidDeclarationsDocument; + +import org.tianocore.LibraryClassDeclarationsDocument; + +import org.tianocore.ModuleTypeDef; +import org.tianocore.MsaFilesDocument; +import org.tianocore.PackageDefinitionsDocument; +import org.tianocore.PackageHeadersDocument; +import org.tianocore.PackageSurfaceAreaDocument; +import org.tianocore.PcdDataTypes; +import org.tianocore.PcdDeclarationsDocument; +import org.tianocore.PcdItemTypes; +import org.tianocore.PpiDeclarationsDocument; +import org.tianocore.ProtocolDeclarationsDocument; +import org.tianocore.SpdHeaderDocument; +import org.tianocore.GuidDeclarationsDocument.GuidDeclarations; +import org.tianocore.PackageHeadersDocument.PackageHeaders.IncludePkgHeader; + +/** + This class processes spd file contents such as add remove xml elements. + + @since PackageEditor 1.0 +**/ + +public class SpdFileContents { + + private File file = null; + + private PackageSurfaceAreaDocument psad = null; + + private PackageSurfaceAreaDocument.PackageSurfaceArea psaRoot = null; + + private SpdHeaderDocument.SpdHeader spdHdr = null; + + private PackageDefinitionsDocument.PackageDefinitions spdPkgDefs = null; + + private LibraryClassDeclarationsDocument.LibraryClassDeclarations spdLibClassDeclarations = null; + + private MsaFilesDocument.MsaFiles spdMsaFiles = null; + + private PackageHeadersDocument.PackageHeaders spdModHdrs = null; + + private GuidDeclarationsDocument.GuidDeclarations spdGuidDeclarations = null; + + private ProtocolDeclarationsDocument.ProtocolDeclarations spdProtocolDeclarations = null; + + private PpiDeclarationsDocument.PpiDeclarations spdPpiDeclarations = null; + + private PcdDeclarationsDocument.PcdDeclarations spdPcdDefinitions = null; + + /** + Constructor to create a new spd file + **/ + public SpdFileContents() { + + psad = PackageSurfaceAreaDocument.Factory.newInstance(); + psaRoot = psad.addNewPackageSurfaceArea(); + + } + + /** + Constructor for existing document object + @param psa + **/ + public SpdFileContents(PackageSurfaceAreaDocument.PackageSurfaceArea psa) { + psaRoot = psa; + spdHdr = psaRoot.getSpdHeader(); + spdPkgDefs = psaRoot.getPackageDefinitions(); + } + /** + Constructor based on an existing spd file + + @param f Existing spd file + **/ + public SpdFileContents(File f) { + try { + psad = PackageSurfaceAreaDocument.Factory.parse(f); + psaRoot = psad.getPackageSurfaceArea(); + file = f; + } catch (Exception e) { + System.out.println(e.toString()); + } + } + + /** + Remove existing pcd definitions elements using XmlCursor + **/ + public void removeSpdPcdDefinition() { + XmlObject o = psaRoot.getPcdDeclarations(); + if (o == null) + return; + XmlCursor cursor = o.newCursor(); + cursor.removeXml(); + spdPcdDefinitions = null; + cursor.dispose(); + } + + public void removeSpdPcdDefinition(int i){ + XmlObject o = psaRoot.getPcdDeclarations(); + if (o == null) + return; + XmlCursor cursor = o.newCursor(); + if (cursor.toFirstChild()) { + for (int j = 0; j < i; ++j) { + cursor.toNextSibling(); + } + cursor.removeXml(); + } + cursor.dispose(); + } + + /** + Remove existing ppi declarations using XmlCursor + **/ + public void removeSpdPpiDeclaration() { + XmlObject o = psaRoot.getPpiDeclarations(); + if (o == null) + return; + XmlCursor cursor = o.newCursor(); + cursor.removeXml(); + spdPpiDeclarations = null; + cursor.dispose(); + } + + public void removeSpdPpiDeclaration(int i){ + XmlObject o = psaRoot.getPpiDeclarations(); + if (o == null) + return; + XmlCursor cursor = o.newCursor(); + if (cursor.toFirstChild()) { + for (int j = 0; j < i; ++j) { + cursor.toNextSibling(); + } + cursor.removeXml(); + } + cursor.dispose(); + } + /** + Remove existing protocols declarations using XmlCursor + **/ + public void removeSpdProtocolDeclaration() { + XmlObject o = psaRoot.getProtocolDeclarations(); + if (o == null) + return; + XmlCursor cursor = o.newCursor(); + cursor.removeXml(); + spdProtocolDeclarations = null; + cursor.dispose(); + } + + public void removeSpdProtocolDeclaration(int i) { + XmlObject o = psaRoot.getProtocolDeclarations(); + if (o == null) + return; + XmlCursor cursor = o.newCursor(); + if (cursor.toFirstChild()) { + for (int j = 0; j < i; ++j) { + cursor.toNextSibling(); + } + cursor.removeXml(); + } + cursor.dispose(); + } + /** + Remove existing GUID declarations using XmlCursor + **/ + public void removeSpdGuidDeclaration() { + XmlObject o = psaRoot.getGuidDeclarations(); + if (o == null) + return; + XmlCursor cursor = o.newCursor(); + cursor.removeXml(); + spdGuidDeclarations = null; + cursor.dispose(); + } + + public void removeSpdGuidDeclaration(int i) { + XmlObject o = psaRoot.getGuidDeclarations(); + if (o == null) + return; + XmlCursor cursor = o.newCursor(); + if (cursor.toFirstChild()) { + for (int j = 0; j < i; ++j) { + cursor.toNextSibling(); + } + cursor.removeXml(); + + } + cursor.dispose(); + } + + /** + Remove existing spd package include files using XmlCursor + **/ + public void removeSpdPkgHeader() { + XmlObject o = psaRoot.getPackageHeaders(); + if (o == null) + return; + XmlCursor cursor = o.newCursor(); + cursor.removeXml(); + spdModHdrs = null; + cursor.dispose(); + } + + public void removeSpdPkgHeader(int i){ + XmlObject o = psaRoot.getPackageHeaders(); + if (o == null) + return; + XmlCursor cursor = o.newCursor(); + if (cursor.toFirstChild()) { + for (int j = 0; j < i; ++j) { + cursor.toNextSibling(); + } + cursor.removeXml(); + } + cursor.dispose(); + } + + /** + Remove existing msa files using XmlCursor + **/ + public void removeSpdMsaFile() { + XmlObject o = psaRoot.getMsaFiles(); + if (o == null) + return; + XmlCursor cursor = o.newCursor(); + cursor.removeXml(); + spdMsaFiles = null; + cursor.dispose(); + } + + public void removeSpdMsaFile(int i){ + XmlObject o = psaRoot.getMsaFiles(); + if (o == null) + return; + XmlCursor cursor = o.newCursor(); + if (cursor.toFirstChild()) { + for (int j = 0; j < i; ++j) { + cursor.toNextSibling(); + } + cursor.removeXml(); + } + cursor.dispose(); + } + + /** + Remove existing library class declarations using XmlCursor + **/ + public void removeSpdLibClass() { + XmlObject o = psaRoot.getLibraryClassDeclarations(); + if (o == null) + return; + XmlCursor cursor = o.newCursor(); + cursor.removeXml(); + spdLibClassDeclarations = null; + cursor.dispose(); + } + + public void removeSpdLibClass(int i) { + XmlObject o = psaRoot.getLibraryClassDeclarations(); + if (o == null) + return; + XmlCursor cursor = o.newCursor(); + if (cursor.toFirstChild()) { + for (int j = 0; j < i; ++j) { + cursor.toNextSibling(); + } + cursor.removeXml(); + } + cursor.dispose(); + } + + public void updateSpdLibClass(int i, String lib, String hdr, String hlp, String clsUsage, String instanceVer, String hdrAttribArch, String hdrAttribModType) { + XmlObject o = psaRoot.getLibraryClassDeclarations(); + if (o == null) + return; + + XmlCursor cursor = o.newCursor(); + if (cursor.toFirstChild()) { + for (int j = 0; j < i; ++j) { + cursor.toNextSibling(); + } + LibraryClassDeclarationsDocument.LibraryClassDeclarations.LibraryClass lc = (LibraryClassDeclarationsDocument.LibraryClassDeclarations.LibraryClass)cursor.getObject(); + lc.setName(lib); + lc.setIncludeHeader(hdr); + lc.setHelpText(hlp); + if (clsUsage != null) { + lc.setRecommendedInstanceGuid(clsUsage); + } + if (instanceVer != null){ + lc.setRecommendedInstanceVersion(instanceVer); + } + if (stringToList(hdrAttribArch) != null){ + lc.setSupArchList(stringToList(hdrAttribArch)); + } + if (stringToList(hdrAttribModType) != null){ + lc.setSupModuleList(stringToList(hdrAttribModType)); + } + } + + cursor.dispose(); + } + + public void updateSpdMsaFile(int i, String msaFile, String mName, String v, String g){ + XmlObject o = psaRoot.getMsaFiles(); + if (o == null) + return; + + XmlCursor cursor = o.newCursor(); + if (cursor.toFirstChild()) { + for (int j = 0; j < i; ++j) { + cursor.toNextSibling(); + } + cursor.setTextValue(msaFile); + + } + + cursor.dispose(); + } + + public void updateSpdGuidDecl(int i, String name, String cName, String guid, String hlp, String archList, + String modTypeList, String guidTypeList){ + XmlObject o = psaRoot.getGuidDeclarations(); + if (o == null){ + return; + } + + XmlCursor cursor = o.newCursor(); + if (cursor.toFirstChild()) { + for (int j = 0; j < i; ++j) { + cursor.toNextSibling(); + } + GuidDeclarationsDocument.GuidDeclarations.Entry e = (GuidDeclarationsDocument.GuidDeclarations.Entry)cursor.getObject(); + e.setName(name); + e.setCName(cName); + e.setGuidValue(guid); + e.setHelpText(hlp); + if (stringToList(guidTypeList) != null && !guidTypeList.equals("")) { + e.setGuidTypeList(stringToList(guidTypeList)); + } + if (stringToList(archList) != null){ + e.setSupArchList(stringToList(archList)); + } + if (stringToList(modTypeList) != null) { + e.setSupModuleList(stringToList(modTypeList)); + } + + } + cursor.dispose(); + } + + public void updateSpdPpiDecl(int i, String name, String cName, String guid, String hlp, String archList, + String modTypeList){ + XmlObject o = psaRoot.getPpiDeclarations(); + if (o == null){ + return; + } + + XmlCursor cursor = o.newCursor(); + if (cursor.toFirstChild()) { + for (int j = 0; j < i; ++j) { + cursor.toNextSibling(); + } + PpiDeclarationsDocument.PpiDeclarations.Entry e = (PpiDeclarationsDocument.PpiDeclarations.Entry)cursor.getObject(); + e.setName(name); + e.setCName(cName); + e.setGuidValue(guid); + e.setHelpText(hlp); + if (stringToList(archList) != null){ + e.setSupArchList(stringToList(archList)); + } + if (stringToList(modTypeList) != null) { + e.setSupModuleList(stringToList(modTypeList)); + } + } + cursor.dispose(); + } + + public void updateSpdProtocolDecl(int i, String name, String cName, String guid, String hlp, String archList, + String modTypeList){ + XmlObject o = psaRoot.getProtocolDeclarations(); + if (o == null){ + return; + } + + XmlCursor cursor = o.newCursor(); + if (cursor.toFirstChild()) { + for (int j = 0; j < i; ++j) { + cursor.toNextSibling(); + } + ProtocolDeclarationsDocument.ProtocolDeclarations.Entry e = (ProtocolDeclarationsDocument.ProtocolDeclarations.Entry)cursor.getObject(); + e.setName(name); + e.setCName(cName); + e.setGuidValue(guid); + e.setHelpText(hlp); + if (stringToList(archList) != null){ + e.setSupArchList(stringToList(archList)); + } + if (stringToList(modTypeList) != null) { + e.setSupModuleList(stringToList(modTypeList)); + } + } + cursor.dispose(); + } + + public void updateSpdPkgHdr(int i, String pkgName, String hdrName){ + XmlObject o = psaRoot.getPackageHeaders(); + if (o == null){ + return; + } + + XmlCursor cursor = o.newCursor(); + if (cursor.toFirstChild()) { + for (int j = 0; j < i; ++j) { + cursor.toNextSibling(); + } + + PackageHeadersDocument.PackageHeaders.IncludePkgHeader iph = (PackageHeadersDocument.PackageHeaders.IncludePkgHeader)cursor.getObject(); + iph.setModuleType(ModuleTypeDef.Enum.forString(pkgName)); + iph.setStringValue(hdrName); + } + cursor.dispose(); + } + + public void updateSpdPcdDefinition(int i, String cName, String token, String dataType, String pcdItemTypes, + String spaceGuid, String defaultString, String help, String archList, String modTypeList){ + XmlObject o = psaRoot.getPcdDeclarations(); + if (o == null) + return; + XmlCursor cursor = o.newCursor(); + if (cursor.toFirstChild()) { + for (int j = 0; j < i; ++j) { + cursor.toNextSibling(); + } + PcdDeclarationsDocument.PcdDeclarations.PcdEntry e = (PcdDeclarationsDocument.PcdDeclarations.PcdEntry)cursor.getObject(); + e.setCName(cName); + e.setToken(token); + e.setDatumType(PcdDataTypes.Enum.forString(dataType)); + if (pcdItemTypes != null && pcdItemTypes.length() > 0) { + String usage[] = pcdItemTypes.split("( )+"); + List l = new ArrayList(); + for (int k = 0; k < usage.length; ++k) { + l.add(usage[k]); + } + e.setValidUsage(l); + } + + e.setTokenSpaceGuidCName(spaceGuid); + e.setDefaultValue(defaultString); + e.setHelpText(help); + if (archList != null && archList.length() > 0){ + e.setSupArchList(stringToList(archList)); + } + if (modTypeList != null && modTypeList.length() > 0){ + e.setSupModuleList(stringToList(modTypeList)); + } + } + cursor.dispose(); + } + /** + Get spd file header contents into String array + + @param s Caller allocated String array + **/ + public void getSpdHdrDetails(String[] s) { + if (getSpdHdr() == null) { + spdHdr = psaRoot.addNewSpdHeader(); + } + s[0] = getSpdHdrPkgName(); + s[1] = getSpdHdr().getGuidValue(); + s[2] = getSpdHdrVer(); +// s[3] = getSpdHdr().getAbstract(); + s[4] = getSpdHdr().getDescription(); + s[5] = getSpdHdr().getCopyright(); + s[6] = getSpdHdrLicense(); + + } + + /** + Get the number of library class declarations from the size of List + + @return int + **/ + public int getSpdLibClassDeclarationCount() { + if (psaRoot.getLibraryClassDeclarations() == null + || psaRoot.getLibraryClassDeclarations().getLibraryClassList() == null) { + return 0; + } + return psaRoot.getLibraryClassDeclarations().getLibraryClassList().size(); + } + + /** + Get available library class declaration into String array + @param libClass Caller allocated two-dimentional String array + **/ + public void getSpdLibClassDeclarations(String[][] libClass) { + if (psaRoot.getLibraryClassDeclarations() == null){ + return; + } + + List l = psaRoot.getLibraryClassDeclarations().getLibraryClassList(); + int i = 0; + ListIterator li = l.listIterator(); + while (li.hasNext()) { + LibraryClassDeclarationsDocument.LibraryClassDeclarations.LibraryClass lc = (LibraryClassDeclarationsDocument.LibraryClassDeclarations.LibraryClass) li.next(); + if (lc != null) { + libClass[i][0] = lc.getName(); + libClass[i][1] = lc.getIncludeHeader(); + libClass[i][2] = lc.getHelpText(); + libClass[i][3] = lc.getRecommendedInstanceGuid(); + libClass[i][4] = lc.getRecommendedInstanceVersion(); + if (lc.getSupArchList() != null) { + libClass[i][5] = listToString(lc.getSupArchList()); + } + if (lc.getSupModuleList() != null) { + libClass[i][6] = listToString(lc.getSupModuleList()); + } + + } + + i++; + } + + } + + /** + Get the number of Msa files from the size of List + + @return int + **/ + public int getSpdMsaFileCount() { + if (psaRoot.getMsaFiles() == null || psaRoot.getMsaFiles().getFilenameList() == null) { + return 0; + } + return psaRoot.getMsaFiles().getFilenameList().size(); + } + + /** + Get available Msa file into String array + + @param msaFile Caller allocated two-dimentional String array + **/ + public void getSpdMsaFiles(String[][] msaFile) { + if (psaRoot.getMsaFiles() == null) { + return; + } + List l = psaRoot.getMsaFiles().getFilenameList(); + int i = 0; + ListIterator li = l.listIterator(); + while (li.hasNext()) { + msaFile[i][0] = (String)li.next(); + + i++; + } + } + + /** + Get the number of include header files in PackageHeaders from the size of List + + @return int + **/ + public int getSpdPackageHeaderCount() { + if (psaRoot.getPackageHeaders() == null || psaRoot.getPackageHeaders().getIncludePkgHeaderList() == null) { + return 0; + } + return psaRoot.getPackageHeaders().getIncludePkgHeaderList().size(); + } + + /** + Get available package header contents into String array + + @param pkgHeader Caller allocated two-dimentional String array + **/ + public void getSpdPackageHeaders(String[][] pkgHeader) { + if (psaRoot.getPackageHeaders() == null) { + return; + } + + List l = psaRoot.getPackageHeaders().getIncludePkgHeaderList(); + int i = 0; + ListIterator li = l.listIterator(); + while (li.hasNext()) { + PackageHeadersDocument.PackageHeaders.IncludePkgHeader ih = (PackageHeadersDocument.PackageHeaders.IncludePkgHeader) li.next(); + if (ih.getModuleType() != null) { + pkgHeader[i][0] = ih.getModuleType().toString(); + } + + pkgHeader[i][1] = ih.getStringValue(); + i++; + } + } + + /** + Get the number of GUID declarations from the size of List + + @return int + **/ + public int getSpdGuidDeclarationCount() { + if (psaRoot.getGuidDeclarations() == null || psaRoot.getGuidDeclarations().getEntryList() == null) { + return 0; + } + return psaRoot.getGuidDeclarations().getEntryList().size(); + } + + /** + Get available Guid declaration contents into String array + + @param guid Caller allocated two-dimentional String array + **/ + public void getSpdGuidDeclarations(String[][] guid) { + if (psaRoot.getGuidDeclarations() == null) { + return; + } + + List l = psaRoot.getGuidDeclarations().getEntryList(); + int i = 0; + ListIterator li = l.listIterator(); + while (li.hasNext()) { + GuidDeclarationsDocument.GuidDeclarations.Entry e = (GuidDeclarationsDocument.GuidDeclarations.Entry) li + .next(); + guid[i][0] = e.getName(); + guid[i][1] = e.getCName(); + if (e.getGuidValue() != null) { + guid[i][2] = e.getGuidValue(); + } + guid[i][3] = e.getHelpText(); + guid[i][4] = listToString(e.getSupArchList()); + guid[i][5] = listToString(e.getSupModuleList()); + guid[i][6] = listToString(e.getGuidTypeList()); + i++; + } + } + + /** + Get the number of protocol declarations from the size of List + + @return int + **/ + public int getSpdProtocolDeclarationCount() { + if (psaRoot.getProtocolDeclarations() == null || psaRoot.getProtocolDeclarations().getEntryList() == null) { + return 0; + } + return psaRoot.getProtocolDeclarations().getEntryList().size(); + } + + /** + Get available protocol declaration contents into String array + + @param protocol Caller allocated two-dimentional String array + **/ + public void getSpdProtocolDeclarations(String[][] protocol) { + if (psaRoot.getProtocolDeclarations() == null) { + return; + } + + List l = psaRoot.getProtocolDeclarations() + .getEntryList(); + int i = 0; + ListIterator li = l.listIterator(); + while (li.hasNext()) { + ProtocolDeclarationsDocument.ProtocolDeclarations.Entry e = (ProtocolDeclarationsDocument.ProtocolDeclarations.Entry) li + .next(); + protocol[i][0] = e.getName(); + protocol[i][1] = e.getCName(); + if (e.getGuidValue() != null) { + protocol[i][2] = e.getGuidValue(); + } + protocol[i][3] = e.getHelpText(); + protocol[i][4] = listToString(e.getSupArchList()); + protocol[i][5] = listToString(e.getSupModuleList()); + i++; + } + } + + /** + Get the number of Ppi declarations from the size of List + + @return int + **/ + public int getSpdPpiDeclarationCount() { + if (psaRoot.getPpiDeclarations() == null || psaRoot.getPpiDeclarations().getEntryList() == null) { + return 0; + } + return psaRoot.getPpiDeclarations().getEntryList().size(); + } + + /** + Get available Ppi declaration contents into String array + + @param ppi Caller allocated two-dimentional String array + **/ + public void getSpdPpiDeclarations(String[][] ppi) { + if (psaRoot.getPpiDeclarations() == null) { + return; + } + + List l = psaRoot.getPpiDeclarations().getEntryList(); + int i = 0; + ListIterator li = l.listIterator(); + while (li.hasNext()) { + PpiDeclarationsDocument.PpiDeclarations.Entry e = (PpiDeclarationsDocument.PpiDeclarations.Entry) li.next(); + ppi[i][0] = e.getName(); + ppi[i][1] = e.getCName(); + if (e.getGuidValue() != null) { + ppi[i][2] = e.getGuidValue(); + } + ppi[i][3] = e.getHelpText(); + ppi[i][4] = listToString(e.getSupArchList()); + ppi[i][5] = listToString(e.getSupModuleList()); + + i++; + } + } + + /** + Get the number of Pcd definitions from the size of List + + @return int + **/ + public int getSpdPcdDefinitionCount() { + if (psaRoot.getPcdDeclarations() == null || psaRoot.getPcdDeclarations().getPcdEntryList() == null) { + return 0; + } + return psaRoot.getPcdDeclarations().getPcdEntryList().size(); + } + + /** + Get available Pcd definition contents into String array + + @param pcd Caller allocated two-dimentional String array + **/ + public void getSpdPcdDefinitions(String[][] pcd, String pcdUsage[][]) { + if (psaRoot.getPcdDeclarations() == null) { + return; + } + + List l = psaRoot.getPcdDeclarations().getPcdEntryList(); + int i = 0; + while (i < l.size()) { + PcdDeclarationsDocument.PcdDeclarations.PcdEntry e = (PcdDeclarationsDocument.PcdDeclarations.PcdEntry)l.get(i); + pcd[i][0] = e.getCName(); + pcd[i][1] = e.getToken() + ""; + pcd[i][2] = e.getTokenSpaceGuidCName(); + if (e.getDatumType() != null) { + pcd[i][3] = e.getDatumType().toString(); + } + pcd[i][4] = e.getDefaultValue()+""; + pcd[i][5] = e.getHelpText(); + String archList = listToString(e.getSupArchList()); + if (archList != null) { + pcd[i][6] = archList; + } + String modTypeList = listToString(e.getSupModuleList()); + if (modTypeList != null) { + pcd[i][7] = modTypeList; + } + + int j = 0; + while (j < e.getValidUsage().size() && j < 5) { + pcdUsage[i][j] = (String)e.getValidUsage().get(j); + ++j; + } + i++; + } + } + + /** + Save the processed xml contents to file + + @param spdFile The file to save xml contents + @throws IOException Exceptions during file operation + **/ + public void saveAs(File spdFile) throws IOException { + + XmlOptions options = new XmlOptions(); + + options.setCharacterEncoding("UTF-8"); + options.setSavePrettyPrint(); + options.setSavePrettyPrintIndent(2); + try { + psad.save(spdFile, options); + } catch (IOException e) { + e.printStackTrace(); + } + + } + + /** + Generate SpdHeader contents using parameters passed in. + + @param pkgName PackageName + @param pkgGuid Guid + @param pkgVer Version + @param pkgAbs Abstract + @param pkgDes Description + @param pkgCpRight Copyright + @param pkgLicense License + @param pkgCreateDate Created + @param pkgUpdateDate Updated + @param pkgURL URL + @param pkgType PackageType + @param pkgRdOnly ReadOnly + @param pkgRePkg RePackage + @param pkgSpec Reserved + @param pkgOutDir Reserved + **/ + public void genSpdHeader(String pkgName, String pkgGuid, String pkgVer, String pkgAbs, String pkgDes, + String pkgCpRight, String pkgLicense, String pkgCreateDate, String pkgUpdateDate, + String pkgURL, String pkgType, String pkgRdOnly, String pkgRePkg, String pkgSpec, + String pkgOutDir) { + if (getSpdHdr() == null) { + spdHdr = psaRoot.addNewSpdHeader(); + } + + setSpdHdrPkgName(pkgName); + setSpdHdrGuidValue(pkgGuid); + setSpdHdrVer(pkgVer); + setSpdHdrAbs(pkgAbs); + setSpdHdrDescription(pkgDes); + setSpdHdrCopyright(pkgCpRight); + setSpdHdrLicense(pkgLicense); + + + setSpdHdrSpec(pkgSpec); + } + + /** + Generate library class declaration element using parameters passed in + + @param libClassBaseName LibraryClass element value + @param libClassUsage Reserved + @param incHdrFileName IncludeHeader element value + @param incHdrAttribGuid Reserved + @param incHdrAttribArch Reserved + @param incHdrAttribPath Reserved + @param incHdrAttribClass Reserved + @param incHdrAttribVer Reserved + @param incHdrAttribOverrideID Reserved + @param incHdrAttribModuleType Reserved + **/ + public void genSpdLibClassDeclarations(String libClassBaseName, String instanceUsage, String incHdrFileName, + String help, String incHdrAttribArch, String incHdrAttribPath, + String incHdrAttribClass, String incHdrAttribVer, + String incHdrAttribOverrideID, String incHdrAttribModuleType) { + if (getSpdLibClassDeclarations() == null) { + spdLibClassDeclarations = psaRoot.addNewLibraryClassDeclarations(); + } + // + // add contents under LibraryClassDeclarations tag + // + setSpdLibClassDeclaration(libClassBaseName, instanceUsage, incHdrFileName, help, incHdrAttribArch, + incHdrAttribPath, incHdrAttribClass, incHdrAttribVer, incHdrAttribOverrideID, + incHdrAttribModuleType, spdLibClassDeclarations); + } + + /** + Set library class declaration contents under parent tag + + @param clsName LibraryClass element value + @param clsUsage Reserved + @param hdrFile IncludeHeader element value + @param hdrAttribGuid Reserved + @param hdrAttribArch Reserved + @param hdrAttribPath Reserved + @param hdrAttribClass Reserved + @param hdrAttribVer Reserved + @param hdrAttribOverID Reserved + @param hdrAttribModType Reserved + @param parent The tag under which library class declaration goes to + **/ + public void setSpdLibClassDeclaration(String clsName, String clsUsage, String hdrFile, String help, + String hdrAttribArch, String hdrAttribPath, String hdrAttribClass, + String instanceVer, String hdrAttribOverID, String hdrAttribModType, + XmlObject parent) { + + setSpdLibraryClass(clsName, hdrFile, help, clsUsage, instanceVer, hdrAttribArch, hdrAttribModType, parent); + + } + + /** + Set the contents of LibraryClass under parent element + + @param clsName LibraryClass element value + @param clsUsage Reserved + @param parent The tag under which library class declaration goes to + **/ + public void setSpdLibraryClass(String clsName, String clsIncludeFile, String help, String clsUsage, String instanceVer, String hdrAttribArch, String hdrAttribModType, XmlObject parent) { + LibraryClassDeclarationsDocument.LibraryClassDeclarations.LibraryClass lc = ((LibraryClassDeclarationsDocument.LibraryClassDeclarations) parent).addNewLibraryClass(); + lc.setName(clsName); + lc.setIncludeHeader(clsIncludeFile); + lc.setHelpText(help); + lc.setRecommendedInstanceGuid(clsUsage); + lc.setRecommendedInstanceVersion(instanceVer); + if (hdrAttribArch != null) { + lc.setSupArchList(stringToList(hdrAttribArch)); + } + if (hdrAttribModType != null) { + lc.setSupModuleList(stringToList(hdrAttribModType)); + } + + } + + /** + Set contents of IncludeHeader under parent element + + @param modType Reserved + @param hdrFile IncludeHeader element value + @param hdrAttribGuid Reserved + @param hdrAttribArch Reserved + @param hdrAttribPath Reserved + @param hdrAttribClass Reserved + @param hdrAttribVer Reserved + @param hdrAttribOverID Reserved + @param parent The tag under which library class declaration goes to + **/ + public void setSpdIncludeHeader(String modType, String hdrFile, String hdrAttribGuid, String hdrAttribArch, + String hdrAttribPath, String hdrAttribClass, String hdrAttribVer, + String hdrAttribOverID, XmlObject parent) { + + if (parent instanceof LibraryClassDeclarationsDocument.LibraryClassDeclarations) { + } else if (parent instanceof PackageHeadersDocument.PackageHeaders) { + PackageHeadersDocument.PackageHeaders.IncludePkgHeader ih = null; + ih = ((PackageHeadersDocument.PackageHeaders) parent).addNewIncludePkgHeader(); + ih.setStringValue(hdrFile); + ih.setModuleType(ModuleTypeDef.Enum.forString(modType)); + } else { + return; + } + + if (hdrAttribGuid != null) { + } + if (hdrAttribPath != null) { + } + if (hdrAttribClass != null) { + } + if (hdrAttribVer != null) { + } + if (hdrAttribOverID != null) { + } + + } + + /** + Generate MsaFile element. + + @param msaFileName MsaFile element value + @param archType Reserved + **/ + public void genSpdMsaFiles(String msaFileName, String moduleName, String ver, String guid) { + if (getSpdMsaFiles() == null) { + spdMsaFiles = psaRoot.addNewMsaFiles(); + } + setSpdMsaFile(msaFileName, moduleName, ver, guid, spdMsaFiles); + + } + + /** + Set MsaFile contents under parent element. + + @param msaFileName MsaFile element value + @param parent Element under which MsaFile goes to + **/ + public void setSpdMsaFile(String msaFileName, String moduleName, String ver, String guid, XmlObject parent) { + MsaFilesDocument.MsaFiles f = (MsaFilesDocument.MsaFiles)parent; + f.addNewFilename().setStringValue(msaFileName); +// f.setFilename(msaFileName); +// f.setModuleName(moduleName); +// f.setModuleVersion(ver); +// f.setModuleGuid(guid); + } + + /** + Generate PackageHeader element using parameters passed in. + + @param ModHdrModType ModuleType attribute of IncludeHeader element + @param hdrFile IncludeHeader element value + @param hdrAttribGuid Reserved + @param hdrAttribArch Reserved + @param hdrAttribPath Reserved + @param hdrAttribClass Reserved + @param hdrAttribVer Reserved + @param hdrAttribOverID Reserved + **/ + public void genSpdModuleHeaders(String ModHdrModType, String hdrFile, String hdrAttribGuid, String hdrAttribArch, + String hdrAttribPath, String hdrAttribClass, String hdrAttribVer, + String hdrAttribOverID) { + if (getSpdModHdrs() == null) { + spdModHdrs = psaRoot.addNewPackageHeaders(); + } + + // + // add IncludeHeader under PackageHeaders element + // + setSpdIncludeHeader(ModHdrModType, hdrFile, hdrAttribGuid, hdrAttribArch, hdrAttribPath, hdrAttribClass, + hdrAttribVer, hdrAttribOverID, spdModHdrs); + } + + /** + Generate GUID declaration element using parameters passed in. + + @param guidDeclEntryName Name attribute of Entry element + @param guidDeclCName CName element value + @param guidDeclGuid Guid element value + @param guidDeclFeatureFlag Reserved + **/ + public void genSpdGuidDeclarations(String guidDeclEntryName, String guidDeclCName, String guidDeclGuid, + String guidDeclHelp, Vector archList, Vector modTypeList, + Vector guidTypeList) { + if (getSpdGuidDeclarations() == null) { + spdGuidDeclarations = psaRoot.addNewGuidDeclarations(); + } + + setSpdEntry(guidDeclEntryName, guidDeclCName, guidDeclGuid, guidDeclHelp, archList, modTypeList, guidTypeList, spdGuidDeclarations); + } + + /** + Generate protocol declaration element using parameters passed in. + + @param protocolDeclEntryName Name attribute of Entry element + @param protocolDeclCName CName element value + @param protocolDeclGuid Guid element value + @param protocolDeclFeatureFlag Reserved + **/ + public void genSpdProtocolDeclarations(String protocolDeclEntryName, String protocolDeclCName, + String protocolDeclGuid, String protocolDeclFeatureFlag, + Vector archList, Vector modTypeList) { + if (getSpdProtocolDeclarations() == null) { + spdProtocolDeclarations = psaRoot.addNewProtocolDeclarations(); + } + + setSpdEntry(protocolDeclEntryName, protocolDeclCName, protocolDeclGuid, protocolDeclFeatureFlag, + archList, modTypeList, null, spdProtocolDeclarations); + } + + /** + Generate PPI declaration element using parameters passed in. + + @param ppiDeclEntryName Name attribute of Entry element + @param ppiDeclCName CName element value + @param ppiDeclGuid Guid element value + @param ppiDeclFeatureFlag Reserved + **/ + public void genSpdPpiDeclarations(String ppiDeclEntryName, String ppiDeclCName, String ppiDeclGuid, + String ppiDeclFeatureFlag, Vector archList, Vector modTypeList) { + if (getSpdPpiDeclarations() == null) { + spdPpiDeclarations = psaRoot.addNewPpiDeclarations(); + } + + setSpdEntry(ppiDeclEntryName, ppiDeclCName, ppiDeclGuid, ppiDeclFeatureFlag, archList, modTypeList, null, spdPpiDeclarations); + } + + /** + Set Entry contents using parameters passed in + + @param entryName Name attribute of Entry element + @param cName CName element value + @param guid Guid element value + @param featureFlag Reserved + @param parent The tag under which Entry element goes to + **/ + public void setSpdEntry(String entryName, String cName, String guid, String help, + Vector archList, Vector modTypeList, + Vector guidTypeList, XmlObject parent) { + + if (parent instanceof GuidDeclarationsDocument.GuidDeclarations) { + GuidDeclarationsDocument.GuidDeclarations.Entry e = ((GuidDeclarations) parent).addNewEntry(); + e.setName(entryName); + e.setCName(cName); + e.setGuidValue(guid); + e.setHelpText(help); + if (guidTypeList != null && guidTypeList.size() > 0) { + e.setGuidTypeList(new ArrayList(guidTypeList)); + } + if (archList != null && archList.size() > 0){ + e.setSupArchList(new ArrayList(archList)); + } + if (modTypeList != null && modTypeList.size() > 0) { + e.setSupModuleList(new ArrayList(modTypeList)); + } + return; + } + if (parent instanceof ProtocolDeclarationsDocument.ProtocolDeclarations) { + ProtocolDeclarationsDocument.ProtocolDeclarations.Entry pe = ((ProtocolDeclarationsDocument.ProtocolDeclarations) parent) + .addNewEntry(); + pe.setName(entryName); + pe.setCName(cName); + pe.setGuidValue(guid); + pe.setHelpText(help); + if (archList != null && archList.size() > 0){ + pe.setSupArchList(new ArrayList(archList)); + } + if (modTypeList != null && modTypeList.size() > 0) { + pe.setSupModuleList(new ArrayList(modTypeList)); + } + return; + } + if (parent instanceof PpiDeclarationsDocument.PpiDeclarations) { + PpiDeclarationsDocument.PpiDeclarations.Entry ppe = ((PpiDeclarationsDocument.PpiDeclarations) parent) + .addNewEntry(); + ppe.setName(entryName); + ppe.setCName(cName); + ppe.setGuidValue(guid); + ppe.setHelpText(help); + if (archList != null && archList.size() > 0){ + ppe.setSupArchList(new ArrayList(archList)); + } + if (archList != null && modTypeList.size() > 0) { + ppe.setSupModuleList(new ArrayList(modTypeList)); + } + return; + } + + return; + + } + + /** + Generate Pcd definition using parameters passed in + + @param pcdItemTypes ItemType attribute of PcdEntry element + @param cName C_Name element value + @param token Token element value + @param dataType DatumType element value + @param skuEnable Reserved + @param sku Reserved + @param maxSku Reserved + @param hiiEnable Reserved + @param varGuid Reserved + @param varName Reserved + @param defaultString DefaultString element value + **/ + public void genSpdPcdDefinitions(String cName, String token, String dataType, String pcdItemTypes, + String spaceGuid, String defaultString, String help, String archList, + String modTypeList) { + if (getSpdPcdDefinitions() == null) { + spdPcdDefinitions = psaRoot.addNewPcdDeclarations(); + } + + setSpdPcdEntry(pcdItemTypes, cName, token, dataType, spaceGuid, help, + defaultString, archList, modTypeList, spdPcdDefinitions); + } + + /** + Set Pcd entry contents under parent tag + + @param pcdItemTypes ItemType attribute of PcdEntry element + @param cName C_Name element value + @param token Token element value + @param dataType DatumType element value + @param spaceGuid Reserved + @param help Reserved + @param defaultString DefaultString element value + @param parent Tag under which PcdEntry goes to + **/ + public void setSpdPcdEntry(String pcdItemTypes, String cName, String token, String dataType, String spaceGuid, String help, + String defaultString, String archList, String modTypeList, XmlObject parent) { + + PcdDeclarationsDocument.PcdDeclarations.PcdEntry pe = ((PcdDeclarationsDocument.PcdDeclarations) parent).addNewPcdEntry(); + + //ToDo: maybe multiple types in, need parse pcdItemTypes. + String usage[] = pcdItemTypes.split("( )+"); + List l = new ArrayList(); + for (int i = 0; i < usage.length; ++i) { + l.add(usage[i]); + } + pe.setValidUsage(l); + pe.setCName(cName); + pe.setToken(token); + pe.setDatumType(PcdDataTypes.Enum.forString(dataType)); + pe.setDefaultValue(defaultString); + pe.setTokenSpaceGuidCName(spaceGuid); + pe.setHelpText(help); + if (archList != null){ + pe.setSupArchList(stringToList(archList)); + } + if (modTypeList != null){ + pe.setSupModuleList(stringToList(modTypeList)); + } + } + + /** + Get PpiDeclarations element + + @return PpiDeclarationsDocument.PpiDeclarations + **/ + public PpiDeclarationsDocument.PpiDeclarations getSpdPpiDeclarations() { + if (spdPpiDeclarations == null) { + spdPpiDeclarations = psaRoot.getPpiDeclarations(); + } + return spdPpiDeclarations; + } + + /** + Get ProtocolDeclarations element + + @return ProtocolDeclarationsDocument.ProtocolDeclarations + **/ + public ProtocolDeclarationsDocument.ProtocolDeclarations getSpdProtocolDeclarations() { + if (spdProtocolDeclarations == null) { + spdProtocolDeclarations = psaRoot.getProtocolDeclarations(); + } + return spdProtocolDeclarations; + } + + /** + Get GuidDeclarations element + + @return GuidDeclarationsDocument.GuidDeclarations + **/ + public GuidDeclarationsDocument.GuidDeclarations getSpdGuidDeclarations() { + if (spdGuidDeclarations == null) { + spdGuidDeclarations = psaRoot.getGuidDeclarations(); + } + return spdGuidDeclarations; + } + + /** + Get PcdDefinitions element + + @return PcdDefinitionsDocument.PcdDefinitions + **/ + public PcdDeclarationsDocument.PcdDeclarations getSpdPcdDefinitions() { + if (spdPcdDefinitions == null) { + spdPcdDefinitions = psaRoot.getPcdDeclarations(); + } + return spdPcdDefinitions; + } + + /** + Get PackageHeaders element + + @return PackageHeadersDocument.PackageHeaders + **/ + public PackageHeadersDocument.PackageHeaders getSpdModHdrs() { + if (spdModHdrs == null) { + spdModHdrs = psaRoot.getPackageHeaders(); + } + return spdModHdrs; + } + + /** + Get MsaFiles element + + @return MsaFilesDocument.MsaFiles + **/ + public MsaFilesDocument.MsaFiles getSpdMsaFiles() { + if (spdMsaFiles == null) { + spdMsaFiles = psaRoot.getMsaFiles(); + } + return spdMsaFiles; + } + + /** + Get LibraryClassDeclarations element + + @return LibraryClassDeclarationsDocument.LibraryClassDeclarations + **/ + public LibraryClassDeclarationsDocument.LibraryClassDeclarations getSpdLibClassDeclarations() { + if (spdLibClassDeclarations == null) { + spdLibClassDeclarations = psaRoot.getLibraryClassDeclarations(); + } + return spdLibClassDeclarations; + } + + public PackageDefinitionsDocument.PackageDefinitions getSpdPkgDefs() { + if (spdPkgDefs == null) { + spdPkgDefs = psaRoot.addNewPackageDefinitions(); + } + return spdPkgDefs; + } + /** + Get SpdHeader element + + @return SpdHeaderDocument.SpdHeader + **/ + public SpdHeaderDocument.SpdHeader getSpdHdr() { + if (spdHdr == null) { + spdHdr = psaRoot.addNewSpdHeader(); + } + return spdHdr; + } + + /** + Set value to Guid element + + @param guid The value set to Guid element + **/ + public void setSpdHdrGuidValue(String guid) { + getSpdHdr().setGuidValue(guid); + } + + /** + Get Version element under SpdHdr + + @return String + **/ + public String getSpdHdrVer() { + return getSpdHdr().getVersion(); + } + + /** + Set value to Version element + + @param ver The value set to Version element + **/ + public void setSpdHdrVer(String ver) { + getSpdHdr().setVersion(ver); + } + + public String getSpdHdrAbs(){ + return getSpdHdr().getAbstract(); + + } + + /** + Set value to Abstract element + + @param abs The value set to Abstract element + **/ + public void setSpdHdrAbs(String abs) { + + getSpdHdr().setAbstract(abs); + } + + public String getSpdHdrDescription(){ + return getSpdHdr().getDescription(); + } + /** + Set value to Description element + + @param des The value set to Description element + **/ + public void setSpdHdrDescription(String des) { + getSpdHdr().setDescription(des); + } + + public String getSpdHdrCopyright(){ + return getSpdHdr().getCopyright(); + } + /** + Set value to Copyright element + + @param cpRit The value set to Copyright element + **/ + public void setSpdHdrCopyright(String cpRit) { + + getSpdHdr().setCopyright(cpRit); + + } + /** + Get License element under SpdHdr + + @return String + **/ + public String getSpdHdrLicense() { + if (getSpdHdr().getLicense() != null) { + return getSpdHdr().getLicense().getStringValue(); + } + return null; + } + + /** + Set value to License element + + @param license The value set to License element + **/ + public void setSpdHdrLicense(String license) { + if (getSpdHdr().getLicense() == null){ + getSpdHdr().addNewLicense().setStringValue(license); + } + else { + getSpdHdr().getLicense().setStringValue(license); + } + } + + public String getSpdHdrUrl(){ + if (getSpdHdr().getLicense() != null) { + return getSpdHdr().getLicense().getURL(); + } + return null; + } + + public void setSpdHdrUrl(String url){ + getSpdHdr().getLicense().setURL(url); + } + + /** + Get PackageName element under SpdHdr + + @return String + **/ + public String getSpdHdrPkgName() { + + return getSpdHdr().getPackageName(); + } + + /** + Set value to PackageName element + + @param pkgName The value set to PackageName element + **/ + public void setSpdHdrPkgName(String pkgName) { + getSpdHdr().setPackageName(pkgName); + } + + public String getSpdHdrGuidValue(){ + return getSpdHdr().getGuidValue(); + } + + /** + Reserved method + + @return SpecificationDocument.Specification + **/ + public String getSpdHdrSpec() { + return "FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052"; +// return getSpdHdr().getSpecification(); + } + + /** + Reserved method + + @param spec + **/ + public void setSpdHdrSpec(String spec) { + spec = "FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052"; + getSpdHdr().setSpecification(spec); + + } + + public String getSpdPkgDefsRdOnly(){ + return getSpdPkgDefs().getReadOnly() + ""; + } + /** + Set value to ReadOnly element + + @param rdOnly The value set to ReadOnly element + **/ + public void setSpdPkgDefsRdOnly(String rdOnly) { + + getSpdPkgDefs().setReadOnly(new Boolean(rdOnly)); + } + + public String getSpdPkgDefsRePkg(){ + return getSpdPkgDefs().getRePackage() + ""; + } + /** + Set value to RePackage element + + @param rePkg The value set to RePackage element + **/ + public void setSpdPkgDefsRePkg(String rePkg) { + + getSpdPkgDefs().setRePackage(new Boolean(rePkg)); + } + + /** + Set value to URL element + + @param url The value set to URL element + **/ +// public void setSpdHdrURL(String url) { +// getSpdHdr().setURL(url); +// } + + /** + Get xml file + + @return File + **/ + public File getFile() { + return file; + } + + /** + Set file + + @param file File with xml format + **/ + public void setFile(File file) { + this.file = file; + } + + private List stringToList(String s){ + if (s == null) { + return null; + } + ArrayList al = new ArrayList(); + String[] sArray = s.split(" "); + for(int i = 0; i < sArray.length; ++i){ + al.add(sArray[i]); + } + return al; + } + + private String listToString(List l) { + if (l == null) { + return null; + } + String s = " "; + ListIterator li = l.listIterator(); + while(li.hasNext()) { + s += li.next(); + s += " "; + } + return s.trim(); + } + +} diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/packaging/ui/SpdGuidDecls.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/packaging/ui/SpdGuidDecls.java new file mode 100644 index 0000000000..2eaf87054c --- /dev/null +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/packaging/ui/SpdGuidDecls.java @@ -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 vArch = iCheckBoxList.getAllCheckedItemsString(); + Vector vModType = iCheckBoxList2.getAllCheckedItemsString(); + Vector 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 v = new Vector(); + 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 v = new Vector(); + 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 v = new Vector(); + 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 v) { + String s = " "; + for (int i = 0; i < v.size(); ++i) { + s += v.get(i); + s += " "; + } + return s.trim(); + } + + protected Vector stringToVector(String s){ + if (s == null) { + return null; + } + String[] sArray = s.split(" "); + Vector v = new Vector(); + for (int i = 0; i < sArray.length; ++i) { + v.add(sArray[i]); + } + return v; + } + + protected JLabel getJLabel3() { + return jLabel3; + } +} + + diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/packaging/ui/SpdHeader.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/packaging/ui/SpdHeader.java new file mode 100644 index 0000000000..0d482e83e3 --- /dev/null +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/packaging/ui/SpdHeader.java @@ -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; + } +} diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/packaging/ui/SpdLibClassDecls.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/packaging/ui/SpdLibClassDecls.java new file mode 100644 index 0000000000..fd5c552720 --- /dev/null +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/packaging/ui/SpdLibClassDecls.java @@ -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 v = new Vector(); + 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 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); + } +} + + diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/packaging/ui/SpdMsaFiles.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/packaging/ui/SpdMsaFiles.java new file mode 100644 index 0000000000..f21ddd716c --- /dev/null +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/packaging/ui/SpdMsaFiles.java @@ -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); + } +} + + diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/packaging/ui/SpdPackageDefinitions.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/packaging/ui/SpdPackageDefinitions.java new file mode 100644 index 0000000000..7df0d35e5f --- /dev/null +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/packaging/ui/SpdPackageDefinitions.java @@ -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; + } + +} diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/packaging/ui/SpdPackageHeaders.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/packaging/ui/SpdPackageHeaders.java new file mode 100644 index 0000000000..9deba4c4dd --- /dev/null +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/packaging/ui/SpdPackageHeaders.java @@ -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); + } +} + + diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/packaging/ui/SpdPcdDefs.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/packaging/ui/SpdPcdDefs.java new file mode 100644 index 0000000000..2a22aa91fb --- /dev/null +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/packaging/ui/SpdPcdDefs.java @@ -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 v = new Vector(); + 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 v = new Vector(); + 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 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; + } +} diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/packaging/ui/SpdPpiDecls.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/packaging/ui/SpdPpiDecls.java new file mode 100644 index 0000000000..b16dd37fb9 --- /dev/null +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/packaging/ui/SpdPpiDecls.java @@ -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(); + } +} diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/packaging/ui/SpdProtocolDecls.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/packaging/ui/SpdProtocolDecls.java new file mode 100644 index 0000000000..5c70c1769c --- /dev/null +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/packaging/ui/SpdProtocolDecls.java @@ -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(); + } +} diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/PlatformIdentification.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/PlatformIdentification.java new file mode 100644 index 0000000000..11212818cc --- /dev/null +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/PlatformIdentification.java @@ -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; + } +} \ No newline at end of file diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/DynamicTree.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/DynamicTree.java new file mode 100644 index 0000000000..bd3d4feb52 --- /dev/null +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/DynamicTree.java @@ -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) { + } + } +} + + diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/FpdBuildOptions.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/FpdBuildOptions.java new file mode 100644 index 0000000000..60780744d1 --- /dev/null +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/FpdBuildOptions.java @@ -0,0 +1,1509 @@ +/** @file + + The file is used to create, update BuildOptions 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.BorderLayout; +import java.awt.Dimension; + +import javax.swing.JPanel; +import javax.swing.JDialog; +import javax.swing.JTabbedPane; +import javax.swing.JCheckBox; +import javax.swing.JLabel; +import java.awt.FlowLayout; +import javax.swing.AbstractAction; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; + +import javax.swing.ButtonGroup; +import javax.swing.DefaultCellEditor; +import javax.swing.DefaultListModel; +import javax.swing.JTextField; +import javax.swing.JButton; +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.JComboBox; +import javax.swing.JRadioButton; +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 javax.swing.JList; + +import org.tianocore.PlatformSurfaceAreaDocument; +import org.tianocore.frameworkwizard.common.ui.IInternalFrame; +import java.awt.CardLayout; +import javax.swing.JTree; + +public class FpdBuildOptions extends IInternalFrame { + + private static final long serialVersionUID = 1L; + private JPanel jContentPane = null; + private JPanel jPanel = null; + private JPanel jPanel1 = null; + private JPanel jPanel2 = null; + private JPanel jPanel3 = null; + private JTabbedPane jTabbedPane = null; + private JPanel jPanel8 = null; + private JPanel jPanel9 = null; + private JPanel jPanel10 = null; + private JPanel jPanel11 = null; + private JRadioButton jRadioButton = null; + private JTextField jTextField2 = null; + private JLabel jLabel3 = null; + private JTextField jTextField3 = null; + private JButton jButton4 = null; + private JButton jButton5 = null; + private JRadioButton jRadioButton1 = null; + private JLabel jLabel4 = null; + private JTextField jTextField4 = null; + private JScrollPane jScrollPane2 = null; + private JTable jTable2 = null; + private DefaultTableModel fileNameTableModel = null; + private DefaultTableModel imageEntryPointTableModel = null; + private DefaultTableModel outputDirectoryTableModel = null; + private DefaultTableModel antTaskTableModel = null; + private DefaultTableModel ffsAttributesTableModel = null; + private DefaultTableModel optionsTableModel = null; + private JPanel jPanel13 = null; + private JPanel jPanel14 = null; + private JPanel jPanel18 = null; + private JScrollPane jScrollPane4 = null; + private JLabel jLabel6 = null; + private JList jList = null; + private JPanel jPanel15 = null; + private JPanel jPanel16 = null; + private JPanel jPanel17 = null; + private JLabel jLabel7 = null; + private JTextField jTextField6 = null; + private JButton jButton8 = null; + private JButton jButton9 = null; + private JCheckBox jCheckBox5 = null; + private JScrollPane jScrollPane5 = null; + private JTable jTable4 = null; + private JPanel jPanel19 = null; + private JPanel jPanel20 = null; + private JLabel jLabel9 = null; + private JTextField jTextField7 = null; + private JLabel jLabel10 = null; + private JComboBox jComboBox2 = null; + private JLabel jLabel11 = null; + private JLabel jLabel12 = null; + private JTextField jTextField8 = null; + private JScrollPane jScrollPane6 = null; + private JTable jTable5 = null; + private JButton jButton10 = null; + private JButton jButton11 = null; + private JPanel jPanel21 = null; + private JButton jButton12 = null; + private JButton jButton13 = null; + private JLabel jLabel8 = null; + private JTextField jTextField9 = null; + private JLabel jLabel13 = null; + private JTextField jTextField10 = null; + private JPanel jPanel22 = null; + private JCheckBox jCheckBox6 = null; + private JComboBox jComboBox4 = null; + private JCheckBox jCheckBox7 = null; + private JComboBox jComboBox5 = null; + private JCheckBox jCheckBox8 = null; + private JTextField jTextField11 = null; + private JButton jButton14 = null; + private JButton jButton15 = null; + private JButton jButton16 = null; + private DefaultListModel listModel = new DefaultListModel(); + private JScrollPane jScrollPane7 = null; + private JTree jTree = null; + private JButton jButton17 = null; + private JButton jButton18 = null; + private FpdFileContents ffc = null; + private JButton jButton19 = null; + private JCheckBox jCheckBox9 = null; + private JCheckBox jCheckBox10 = null; + private JCheckBox jCheckBox11 = null; + private JCheckBox jCheckBox12 = null; + private JCheckBox jCheckBox13 = null; + private JCheckBox jCheckBox14 = null; + private JLabel jLabel14 = null; + private JTextField jTextField12 = null; + private JTextField jTextField13 = null; + private JLabel jLabel15 = null; + private int selectedRow = -1; + /** + * 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(); + } + 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 jTabbedPane + * + * @return javax.swing.JTabbedPane + */ + private JTabbedPane getJTabbedPane() { + if (jTabbedPane == null) { + jTabbedPane = new JTabbedPane(); + jTabbedPane.addTab("FFS", null, getJPanel13(), null); + jTabbedPane.addTab("Options", null, getJPanel20(), null); + jTabbedPane.addTab("User Defined ANT Tasks", null, getJPanel8(), null); + } + return jTabbedPane; + } + + + /** + * This method initializes jPanel8 + * + * @return javax.swing.JPanel + */ + private JPanel getJPanel8() { + if (jPanel8 == null) { + jPanel8 = new JPanel(); + jPanel8.setLayout(new BorderLayout()); + jPanel8.add(getJPanel9(), java.awt.BorderLayout.NORTH); + jPanel8.add(getJPanel10(), java.awt.BorderLayout.SOUTH); + jPanel8.add(getJPanel11(), java.awt.BorderLayout.CENTER); + ButtonGroup bg = new ButtonGroup(); + bg.add(jRadioButton); + bg.add(jRadioButton1); + } + return jPanel8; + } + + /** + * This method initializes jPanel9 + * + * @return javax.swing.JPanel + */ + private JPanel getJPanel9() { + if (jPanel9 == null) { + FlowLayout flowLayout8 = new FlowLayout(); + flowLayout8.setAlignment(java.awt.FlowLayout.LEFT); + jLabel3 = new JLabel(); + jLabel3.setText("ID"); + jPanel9 = new JPanel(); + jPanel9.setLayout(flowLayout8); + jPanel9.add(getJRadioButton(), null); + jPanel9.add(getJTextField2(), null); + jPanel9.add(jLabel3, null); + jPanel9.add(getJTextField3(), null); + jPanel9.add(getJButton4(), null); + jPanel9.add(getJButton5(), null); + } + return jPanel9; + } + + /** + * This method initializes jPanel10 + * + * @return javax.swing.JPanel + */ + private JPanel getJPanel10() { + if (jPanel10 == null) { + jPanel10 = new JPanel(); + } + return jPanel10; + } + + /** + * This method initializes jPanel11 + * + * @return javax.swing.JPanel + */ + private JPanel getJPanel11() { + if (jPanel11 == null) { + FlowLayout flowLayout3 = new FlowLayout(); + flowLayout3.setHgap(5); + flowLayout3.setAlignment(java.awt.FlowLayout.LEFT); + jLabel4 = new JLabel(); + jLabel4.setText("Execution Order"); + jLabel4.setEnabled(false); + jLabel4.setPreferredSize(new java.awt.Dimension(100,16)); + jPanel11 = new JPanel(); + jPanel11.setLayout(flowLayout3); + jPanel11.add(getJRadioButton1(), null); + jPanel11.add(jLabel4, null); + jPanel11.add(getJTextField4(), null); + jPanel11.add(getJScrollPane2(), null); + } + return jPanel11; + } + + /** + * This method initializes jRadioButton + * + * @return javax.swing.JRadioButton + */ + private JRadioButton getJRadioButton() { + if (jRadioButton == null) { + jRadioButton = new JRadioButton(); + jRadioButton.setText("ANT tasks File"); + jRadioButton.setSelected(true); + jRadioButton.addItemListener(new ItemListener() { + public void itemStateChanged(ItemEvent arg0) { + boolean selected = jRadioButton.isSelected(); + jTextField2.setEnabled(selected); + } + }); + } + return jRadioButton; + } + + /** + * This method initializes jTextField2 + * + * @return javax.swing.JTextField + */ + private JTextField getJTextField2() { + if (jTextField2 == null) { + jTextField2 = new JTextField(); + jTextField2.setPreferredSize(new java.awt.Dimension(200,20)); + } + 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(100,20)); + } + return jTextField3; + } + + /** + * This method initializes jButton4 + * + * @return javax.swing.JButton + */ + private JButton getJButton4() { + if (jButton4 == null) { + jButton4 = new JButton(); + jButton4.setPreferredSize(new java.awt.Dimension(70,20)); + jButton4.setText("Add"); + jButton4.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + Object[] o = {jTextField3.getText(), null, null}; + if (jRadioButton.isSelected()) { + o[1] = jTextField2.getText(); + ffc.genBuildOptionsUserDefAntTask(o[0]+"", o[1]+"", null); + } + if (jRadioButton1.isSelected()) { + o[2] = jTextField4.getText(); + ffc.genBuildOptionsUserDefAntTask(o[0]+"", null, o[2]+""); + } + antTaskTableModel.addRow(o); + + } + }); + } + return jButton4; + } + + /** + * This method initializes jButton5 + * + * @return javax.swing.JButton + */ + private JButton getJButton5() { + if (jButton5 == null) { + jButton5 = new JButton(); + jButton5.setPreferredSize(new java.awt.Dimension(70,20)); + jButton5.setText("Delete"); + jButton5.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + if (selectedRow >= 0) { + antTaskTableModel.removeRow(selectedRow); + ffc.removeBuildOptionsUserDefAntTask(selectedRow); + } + } + }); + } + return jButton5; + } + + /** + * This method initializes jRadioButton1 + * + * @return javax.swing.JRadioButton + */ + private JRadioButton getJRadioButton1() { + if (jRadioButton1 == null) { + jRadioButton1 = new JRadioButton(); + jRadioButton1.setText("ANT Command"); + jRadioButton1.setPreferredSize(new java.awt.Dimension(180,24)); + jRadioButton1.addItemListener(new ItemListener() { + public void itemStateChanged(ItemEvent arg0) { + boolean selected = jRadioButton1.isSelected(); + jLabel4.setEnabled(selected); + jTextField4.setEnabled(selected); + } + }); + } + return jRadioButton1; + } + + /** + * This method initializes jTextField4 + * + * @return javax.swing.JTextField + */ + private JTextField getJTextField4() { + if (jTextField4 == null) { + jTextField4 = new JTextField(); + jTextField4.setPreferredSize(new java.awt.Dimension(100,20)); + jTextField4.setEnabled(false); + } + return jTextField4; + } + + /** + * This method initializes jScrollPane2 + * + * @return javax.swing.JScrollPane + */ + private JScrollPane getJScrollPane2() { + if (jScrollPane2 == null) { + jScrollPane2 = new JScrollPane(); + jScrollPane2.setPreferredSize(new java.awt.Dimension(600,100)); + jScrollPane2.setViewportView(getJTable2()); + } + return jScrollPane2; + } + + /** + * This method initializes jTable2 + * + * @return javax.swing.JTable + */ + private JTable getJTable2() { + if (jTable2 == null) { + antTaskTableModel = new DefaultTableModel(); + jTable2 = new JTable(antTaskTableModel); + antTaskTableModel.addColumn("ID"); + antTaskTableModel.addColumn("Filename"); + antTaskTableModel.addColumn("ExecutionOrder"); + + jTable2.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); + jTable2.getSelectionModel().addListSelectionListener(new ListSelectionListener(){ + public void valueChanged(ListSelectionEvent e) { + selectedRow = -1; + if (e.getValueIsAdjusting()){ + return; + } + ListSelectionModel lsm = (ListSelectionModel)e.getSource(); + if (lsm.isSelectionEmpty()) { + return; + } + else{ + selectedRow = lsm.getMinSelectionIndex(); + } + } + }); + + jTable2.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.UPDATE){ + //ToDo Data Validition check. + String id = m.getValueAt(row, 0) + ""; + String file = m.getValueAt(row, 1) + ""; + String execOrder = m.getValueAt(row, 2) + ""; + if (id.length() == 0) { + return; + } + if (file.length() == 0 && execOrder.length() == 0){ + return; + } + if (file.length() == 0) { + file = null; + } + if (execOrder.length() == 0) { + execOrder = null; + } + ffc.updateBuildOptionsUserDefAntTask(row, id, file, execOrder); + + } + } + }); + } + return jTable2; + } + + /** + * This method initializes jPanel13 + * + * @return javax.swing.JPanel + */ + private JPanel getJPanel13() { + if (jPanel13 == null) { + jPanel13 = new JPanel(); + jPanel13.setLayout(new BorderLayout()); + jPanel13.add(getJPanel14(), java.awt.BorderLayout.WEST); + jPanel13.add(getJPanel18(), java.awt.BorderLayout.CENTER); + } + return jPanel13; + } + + /** + * This method initializes jPanel14 + * + * @return javax.swing.JPanel + */ + private JPanel getJPanel14() { + if (jPanel14 == null) { + jLabel6 = new JLabel(); + jLabel6.setText("FFS Types"); + jPanel14 = new JPanel(); + jPanel14.setPreferredSize(new java.awt.Dimension(120,300)); + jPanel14.add(jLabel6, null); + jPanel14.add(getJScrollPane4(), null); + } + return jPanel14; + } + + /** + * This method initializes jPanel18 + * + * @return javax.swing.JPanel + */ + private JPanel getJPanel18() { + if (jPanel18 == null) { + jPanel18 = new JPanel(); + jPanel18.setLayout(new BorderLayout()); + jPanel18.add(getJPanel15(), java.awt.BorderLayout.NORTH); + jPanel18.add(getJPanel16(), java.awt.BorderLayout.SOUTH); + jPanel18.add(getJPanel17(), java.awt.BorderLayout.EAST); + jPanel18.add(getJPanel19(), java.awt.BorderLayout.CENTER); + } + return jPanel18; + } + + /** + * This method initializes jScrollPane4 + * + * @return javax.swing.JScrollPane + */ + private JScrollPane getJScrollPane4() { + if (jScrollPane4 == null) { + jScrollPane4 = new JScrollPane(); + jScrollPane4.setPreferredSize(new java.awt.Dimension(120,330)); + jScrollPane4.setViewportView(getJList()); + } + return jScrollPane4; + } + + /** + * This method initializes jList + * + * @return javax.swing.JList + */ + private JList getJList() { + if (jList == null) { + jList = new JList(listModel); + } + return jList; + } + + /** + * This method initializes jPanel15 + * + * @return javax.swing.JPanel + */ + private JPanel getJPanel15() { + if (jPanel15 == null) { + FlowLayout flowLayout5 = new FlowLayout(); + flowLayout5.setAlignment(java.awt.FlowLayout.RIGHT); + jLabel7 = new JLabel(); + jLabel7.setText("Type"); + jPanel15 = new JPanel(); + jPanel15.setLayout(flowLayout5); + jPanel15.add(jLabel7, null); + jPanel15.add(getJTextField6(), null); + jPanel15.add(getJButton8(), null); + jPanel15.add(getJButton9(), null); + } + return jPanel15; + } + + /** + * This method initializes jPanel16 + * + * @return javax.swing.JPanel + */ + private JPanel getJPanel16() { + if (jPanel16 == null) { + FlowLayout flowLayout6 = new FlowLayout(); + flowLayout6.setHgap(5); + flowLayout6.setAlignment(java.awt.FlowLayout.LEFT); + jPanel16 = new JPanel(); + jPanel16.setPreferredSize(new java.awt.Dimension(491,130)); + jPanel16.setLayout(flowLayout6); + jPanel16.add(getJCheckBox5(), null); + jPanel16.add(getJButton17(), null); + jPanel16.add(getJButton18(), null); + jPanel16.add(getJScrollPane5(), null); + } + return jPanel16; + } + + /** + * This method initializes jPanel17 + * + * @return javax.swing.JPanel + */ + private JPanel getJPanel17() { + if (jPanel17 == null) { + jPanel17 = new JPanel(); + jPanel17.add(getJScrollPane7(), null); + } + return jPanel17; + } + + /** + * This method initializes jTextField6 + * + * @return javax.swing.JTextField + */ + private JTextField getJTextField6() { + if (jTextField6 == null) { + jTextField6 = new JTextField(); + jTextField6.setPreferredSize(new java.awt.Dimension(150,20)); + } + return jTextField6; + } + + /** + * This method initializes jButton8 + * + * @return javax.swing.JButton + */ + private JButton getJButton8() { + if (jButton8 == null) { + jButton8 = new JButton(); + jButton8.setPreferredSize(new java.awt.Dimension(70,20)); + jButton8.setText("Add"); + jButton8.addActionListener(new AbstractAction() { + public void actionPerformed(java.awt.event.ActionEvent e) { + if (jTextField6.getText().length() > 0) { + listModel.addElement(jTextField6.getText()); + } + } + }); + } + return jButton8; + } + + /** + * This method initializes jButton9 + * + * @return javax.swing.JButton + */ + private JButton getJButton9() { + if (jButton9 == null) { + jButton9 = new JButton(); + jButton9.setPreferredSize(new java.awt.Dimension(70,20)); + jButton9.setText("Delete"); + jButton9.addActionListener(new AbstractAction() { + public void actionPerformed(ActionEvent arg0){ + listModel.remove(jList.getSelectedIndex()); + } + }); + } + return jButton9; + } + + /** + * This method initializes jCheckBox5 + * + * @return javax.swing.JCheckBox + */ + private JCheckBox getJCheckBox5() { + if (jCheckBox5 == null) { + jCheckBox5 = new JCheckBox(); + jCheckBox5.setText("Attributes"); + jCheckBox5.setPreferredSize(new java.awt.Dimension(81,20)); + } + return jCheckBox5; + } + + /** + * This method initializes jScrollPane5 + * + * @return javax.swing.JScrollPane + */ + private JScrollPane getJScrollPane5() { + if (jScrollPane5 == null) { + jScrollPane5 = new JScrollPane(); + jScrollPane5.setPreferredSize(new java.awt.Dimension(350,100)); + jScrollPane5.setViewportView(getJTable4()); + } + return jScrollPane5; + } + + /** + * This method initializes jTable4 + * + * @return javax.swing.JTable + */ + private JTable getJTable4() { + if (jTable4 == null) { + ffsAttributesTableModel = new DefaultTableModel(); + jTable4 = new JTable(ffsAttributesTableModel); + jTable4.setPreferredSize(new java.awt.Dimension(400,80)); + ffsAttributesTableModel.addColumn("Name"); + ffsAttributesTableModel.addColumn("Value"); + } + return jTable4; + } + + /** + * This method initializes jPanel19 + * + * @return javax.swing.JPanel + */ + private JPanel getJPanel19() { + if (jPanel19 == null) { + jPanel19 = new JPanel(); + jPanel19.setLayout(new CardLayout()); + jPanel19.add(getJPanel21(), getJPanel21().getName()); + jPanel19.add(getJPanel22(), getJPanel22().getName()); + } + return jPanel19; + } + + /** + * This method initializes jPanel20 + * + * @return javax.swing.JPanel + */ + private JPanel getJPanel20() { + if (jPanel20 == null) { + jLabel15 = new JLabel(); + jLabel15.setText("Tag Name"); + FlowLayout flowLayout9 = new FlowLayout(); + flowLayout9.setAlignment(java.awt.FlowLayout.LEFT); + jLabel14 = new JLabel(); + jLabel14.setText("Build Targets"); + jLabel12 = new JLabel(); + jLabel12.setText("Tool Command"); + jLabel11 = new JLabel(); + jLabel11.setText("Supported Arch"); + jLabel10 = new JLabel(); + jLabel10.setText("Tool Chain Family"); + jLabel9 = new JLabel(); + jLabel9.setText("Option Contents"); + jPanel20 = new JPanel(); + jPanel20.setLayout(flowLayout9); + jPanel20.add(jLabel14, null); + jPanel20.add(getJTextField12(), null); + jPanel20.add(jLabel10, null); + jPanel20.add(getJComboBox2(), null); + jPanel20.add(jLabel12, null); + jPanel20.add(getJTextField8(), null); + jPanel20.add(jLabel11, null); + jPanel20.add(getJCheckBox9(), null); + jPanel20.add(getJCheckBox10(), null); + jPanel20.add(getJCheckBox11(), null); + jPanel20.add(getJCheckBox12(), null); + jPanel20.add(getJCheckBox13(), null); + jPanel20.add(getJCheckBox14(), null); + jPanel20.add(jLabel15, null); + jPanel20.add(getJTextField13(), null); + jPanel20.add(jLabel9, null); + jPanel20.add(getJTextField7(), null); + jPanel20.add(getJButton10(), null); + jPanel20.add(getJButton11(), null); + jPanel20.add(getJButton19(), null); + jPanel20.add(getJScrollPane6(), null); + } + return jPanel20; + } + + /** + * This method initializes jTextField7 + * + * @return javax.swing.JTextField + */ + private JTextField getJTextField7() { + if (jTextField7 == null) { + jTextField7 = new JTextField(); + jTextField7.setPreferredSize(new java.awt.Dimension(300,20)); + } + return jTextField7; + } + + /** + * This method initializes jComboBox2 + * + * @return javax.swing.JComboBox + */ + private JComboBox getJComboBox2() { + if (jComboBox2 == null) { + jComboBox2 = new JComboBox(); + jComboBox2.setPreferredSize(new java.awt.Dimension(80,20)); + jComboBox2.addItem("MSFT"); + jComboBox2.addItem("GCC"); + jComboBox2.addItem("CYGWIN"); + jComboBox2.addItem("INTEL"); + jComboBox2.setSelectedIndex(0); + } + return jComboBox2; + } + + /** + * This method initializes jTextField8 + * + * @return javax.swing.JTextField + */ + private JTextField getJTextField8() { + if (jTextField8 == null) { + jTextField8 = new JTextField(); + jTextField8.setPreferredSize(new java.awt.Dimension(110,20)); + } + return jTextField8; + } + + /** + * This method initializes jScrollPane6 + * + * @return javax.swing.JScrollPane + */ + private JScrollPane getJScrollPane6() { + if (jScrollPane6 == null) { + jScrollPane6 = new JScrollPane(); + jScrollPane6.setPreferredSize(new java.awt.Dimension(630,200)); + jScrollPane6.setViewportView(getJTable5()); + } + return jScrollPane6; + } + + /** + * This method initializes jTable5 + * + * @return javax.swing.JTable + */ + private JTable getJTable5() { + if (jTable5 == null) { + optionsTableModel = new DefaultTableModel(); + jTable5 = new JTable(optionsTableModel); + optionsTableModel.addColumn("BuildTargets"); + optionsTableModel.addColumn("ToolChainFamily"); + optionsTableModel.addColumn("SupportedArch"); + optionsTableModel.addColumn("ToolCommand"); + optionsTableModel.addColumn("TagName"); + optionsTableModel.addColumn("Contents"); + + TableColumn toolFamilyCol = jTable5.getColumnModel().getColumn(1); + JComboBox cb = new JComboBox(); + cb.addItem("MSFT"); + cb.addItem("GCC"); + cb.addItem("CYGWIN"); + cb.addItem("INTEL"); + toolFamilyCol.setCellEditor(new DefaultCellEditor(cb)); + + jTable5.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); + jTable5.getSelectionModel().addListSelectionListener(new ListSelectionListener(){ + public void valueChanged(ListSelectionEvent e) { + selectedRow = -1; + if (e.getValueIsAdjusting()){ + return; + } + ListSelectionModel lsm = (ListSelectionModel)e.getSource(); + if (lsm.isSelectionEmpty()) { + return; + } + else{ + selectedRow = lsm.getMinSelectionIndex(); + } + } + }); + + jTable5.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.UPDATE){ + //ToDo Data Validition check. + String targetName = m.getValueAt(row, 0) + ""; + String toolChain = m.getValueAt(row, 1) + ""; + String supArch = m.getValueAt(row, 2) + ""; + String toolCmd = m.getValueAt(row, 3) + ""; + String tagName = m.getValueAt(row, 4) + ""; + String contents = m.getValueAt(row, 5) + ""; + ffc.updateBuildOptionsOpt(row, targetName, toolChain, tagName, toolCmd, supArch, contents); + } + } + }); + } + return jTable5; + } + + /** + * This method initializes jButton10 + * + * @return javax.swing.JButton + */ + private JButton getJButton10() { + if (jButton10 == null) { + jButton10 = new JButton(); + jButton10.setText("Add"); + jButton10.setPreferredSize(new java.awt.Dimension(70,20)); + jButton10.addActionListener(new AbstractAction() { + public void actionPerformed(java.awt.event.ActionEvent e) { + boolean[] boolArray = {jCheckBox9.isSelected(),jCheckBox10.isSelected(),jCheckBox11.isSelected(), + jCheckBox12.isSelected(),jCheckBox13.isSelected(),jCheckBox14.isSelected()}; + String s = boolToList(boolArray); + Object[] o = {jTextField12.getText(), jComboBox2.getSelectedItem(), s, + jTextField8.getText(), jTextField13.getText(), jTextField7.getText()}; + optionsTableModel.addRow(o); + ffc.genBuildOptionsOpt(jTextField12.getText(), jComboBox2.getSelectedItem()+"", jTextField13.getText(), jTextField8.getText(), s, jTextField7.getText()); + } + }); + } + return jButton10; + } + + private String boolToList (boolean[] bool) { + String s = " "; + if (bool[0]) { + s += "IA32 "; + } + if (bool[1]) { + s += "IPF "; + } + if (bool[2]) { + s += "X64 "; + } + if (bool[3]) { + s += "EBC "; + } + if (bool[4]) { + s += "ARM "; + } + if (bool[5]) { + s += "PPC "; + } + + return s.trim(); + } + + /** + * This method initializes jButton11 + * + * @return javax.swing.JButton + */ + private JButton getJButton11() { + if (jButton11 == null) { + jButton11 = new JButton(); + jButton11.setText("Delete"); + jButton11.setPreferredSize(new java.awt.Dimension(70,20)); + jButton11.addActionListener(new AbstractAction() { + public void actionPerformed(java.awt.event.ActionEvent e) { + if (selectedRow >= 0) { + optionsTableModel.removeRow(selectedRow); + ffc.removeBuildOptionsOpt(selectedRow); + } + } + }); + } + return jButton11; + } + + /** + * This method initializes jPanel21 + * + * @return javax.swing.JPanel + */ + private JPanel getJPanel21() { + if (jPanel21 == null) { + jLabel13 = new JLabel(); + jLabel13.setText("EncapsulationTag"); + jLabel8 = new JLabel(); + jLabel8.setText("EncapsulationType"); + jPanel21 = new JPanel(); + jPanel21.setName("jPanel21"); + jPanel21.add(jLabel8, null); + jPanel21.add(getJTextField9(), null); + jPanel21.add(jLabel13, null); + jPanel21.add(getJTextField10(), null); + jPanel21.add(getJButton12(), null); + jPanel21.add(getJButton13(), null); + jPanel21.add(getJButton16(), null); + } + return jPanel21; + } + + /** + * This method initializes jButton12 + * + * @return javax.swing.JButton + */ + private JButton getJButton12() { + if (jButton12 == null) { + jButton12 = new JButton(); + jButton12.setText("Add Sections"); + jButton12.setPreferredSize(new java.awt.Dimension(109,20)); + jButton12.addActionListener(new AbstractAction(){ + public void actionPerformed(ActionEvent arg0){ + } + }); + } + return jButton12; + } + + /** + * This method initializes jButton13 + * + * @return javax.swing.JButton + */ + private JButton getJButton13() { + if (jButton13 == null) { + jButton13 = new JButton(); + jButton13.setText("Add Section"); + jButton13.setPreferredSize(new java.awt.Dimension(102,20)); + jButton13.addActionListener(new AbstractAction(){ + public void actionPerformed(ActionEvent arg0){ + CardLayout cl = (CardLayout)jPanel19.getLayout(); + cl.last(jPanel19); + } + }); + } + return jButton13; + } + + /** + * This method initializes jTextField9 + * + * @return javax.swing.JTextField + */ + private JTextField getJTextField9() { + if (jTextField9 == null) { + jTextField9 = new JTextField(); + jTextField9.setPreferredSize(new java.awt.Dimension(250,20)); + } + return jTextField9; + } + + /** + * This method initializes jTextField10 + * + * @return javax.swing.JTextField + */ + private JTextField getJTextField10() { + if (jTextField10 == null) { + jTextField10 = new JTextField(); + jTextField10.setPreferredSize(new java.awt.Dimension(250,20)); + } + return jTextField10; + } + + /** + * This method initializes jPanel22 + * + * @return javax.swing.JPanel + */ + private JPanel getJPanel22() { + if (jPanel22 == null) { + FlowLayout flowLayout7 = new FlowLayout(); + flowLayout7.setAlignment(java.awt.FlowLayout.LEFT); + jPanel22 = new JPanel(); + jPanel22.setLayout(flowLayout7); + jPanel22.setName("jPanel22"); + jPanel22.add(getJCheckBox6(), null); + jPanel22.add(getJComboBox4(), null); + jPanel22.add(getJCheckBox7(), null); + jPanel22.add(getJComboBox5(), null); + jPanel22.add(getJCheckBox8(), null); + jPanel22.add(getJTextField11(), null); + jPanel22.add(getJButton14(), null); + jPanel22.add(getJButton15(), null); + } + return jPanel22; + } + + /** + * This method initializes jCheckBox6 + * + * @return javax.swing.JCheckBox + */ + private JCheckBox getJCheckBox6() { + if (jCheckBox6 == null) { + jCheckBox6 = new JCheckBox(); + jCheckBox6.setText("Section Type"); + jCheckBox6.setPreferredSize(new java.awt.Dimension(98,20)); + } + return jCheckBox6; + } + + /** + * This method initializes jComboBox4 + * + * @return javax.swing.JComboBox + */ + private JComboBox getJComboBox4() { + if (jComboBox4 == null) { + jComboBox4 = new JComboBox(); + jComboBox4.setPreferredSize(new java.awt.Dimension(260,20)); + + jComboBox4.addItem("EFI_SECTION_FREEFORM_SUBTYPE_GUID"); + jComboBox4.addItem("EFI_SECTION_VERSION"); + jComboBox4.addItem("EFI_SECTION_USER_INTERFACE"); + jComboBox4.addItem("EFI_SECTION_DXE_DEPEX"); + jComboBox4.addItem("EFI_SECTION_PEI_DEPEX"); + jComboBox4.addItem("EFI_SECTION_PE32"); + jComboBox4.addItem("EFI_SECTION_PIC"); + jComboBox4.addItem("EFI_SECTION_TE"); + jComboBox4.addItem("EFI_SECTION_RAW"); + jComboBox4.addItem("EFI_SECTION_COMPRESSION"); + jComboBox4.addItem("EFI_SECTION_GUID_DEFINED"); + jComboBox4.addItem("EFI_SECTION_COMPATIBILITY16"); + jComboBox4.addItem("EFI_SECTION_FIRMWARE_VOLUME_IMAGE"); + jComboBox4.setSelectedIndex(0); + } + return jComboBox4; + } + + /** + * This method initializes jCheckBox7 + * + * @return javax.swing.JCheckBox + */ + private JCheckBox getJCheckBox7() { + if (jCheckBox7 == null) { + jCheckBox7 = new JCheckBox(); + jCheckBox7.setPreferredSize(new java.awt.Dimension(120,20)); + jCheckBox7.setText("Compressible"); + } + return jCheckBox7; + } + + /** + * This method initializes jComboBox5 + * + * @return javax.swing.JComboBox + */ + private JComboBox getJComboBox5() { + if (jComboBox5 == null) { + jComboBox5 = new JComboBox(); + jComboBox5.setPreferredSize(new java.awt.Dimension(80,20)); + + jComboBox5.addItem("false"); + jComboBox5.addItem("true"); + jComboBox5.setSelectedIndex(0); + } + return jComboBox5; + } + + /** + * This method initializes jCheckBox8 + * + * @return javax.swing.JCheckBox + */ + private JCheckBox getJCheckBox8() { + if (jCheckBox8 == null) { + jCheckBox8 = new JCheckBox(); + jCheckBox8.setText("Binding Order"); + jCheckBox8.setPreferredSize(new java.awt.Dimension(103,20)); + } + return jCheckBox8; + } + + /** + * This method initializes jTextField11 + * + * @return javax.swing.JTextField + */ + private JTextField getJTextField11() { + if (jTextField11 == null) { + jTextField11 = new JTextField(); + jTextField11.setPreferredSize(new java.awt.Dimension(150,20)); + } + return jTextField11; + } + + /** + * This method initializes jButton14 + * + * @return javax.swing.JButton + */ + private JButton getJButton14() { + if (jButton14 == null) { + jButton14 = new JButton(); + jButton14.setText("Add"); + jButton14.setPreferredSize(new java.awt.Dimension(70,20)); + jButton14.addActionListener(new AbstractAction(){ + public void actionPerformed(ActionEvent arg0){ + } + }); + } + return jButton14; + } + + /** + * This method initializes jButton15 + * + * @return javax.swing.JButton + */ + private JButton getJButton15() { + if (jButton15 == null) { + jButton15 = new JButton(); + jButton15.setPreferredSize(new java.awt.Dimension(70,20)); + jButton15.setText("Delete"); + } + return jButton15; + } + + /** + * This method initializes jButton16 + * + * @return javax.swing.JButton + */ + private JButton getJButton16() { + if (jButton16 == null) { + jButton16 = new JButton(); + jButton16.setText("Delete"); + jButton16.setPreferredSize(new java.awt.Dimension(70,20)); + } + return jButton16; + } + + /** + * This method initializes jScrollPane7 + * + * @return javax.swing.JScrollPane + */ + private JScrollPane getJScrollPane7() { + if (jScrollPane7 == null) { + jScrollPane7 = new JScrollPane(); + jScrollPane7.setPreferredSize(new java.awt.Dimension(110,200)); + jScrollPane7.setViewportView(getJTree()); + } + return jScrollPane7; + } + + /** + * This method initializes jTree + * + * @return javax.swing.JTree + */ + private JTree getJTree() { + if (jTree == null) { + jTree = new JTree(); + } + return jTree; + } + + /** + * This method initializes jButton17 + * + * @return javax.swing.JButton + */ + private JButton getJButton17() { + if (jButton17 == null) { + jButton17 = new JButton(); + jButton17.setPreferredSize(new java.awt.Dimension(70,20)); + jButton17.setText("Add"); + jButton17.addActionListener(new AbstractAction() { + public void actionPerformed(ActionEvent arg0){ + Object[] o = {"", ""}; + ffsAttributesTableModel.addRow(o); + } + }); + } + return jButton17; + } + + /** + * This method initializes jButton18 + * + * @return javax.swing.JButton + */ + private JButton getJButton18() { + if (jButton18 == null) { + jButton18 = new JButton(); + jButton18.setPreferredSize(new java.awt.Dimension(70,20)); + jButton18.setText("Delete"); + jButton18.addActionListener(new AbstractAction(){ + public void actionPerformed(ActionEvent arg0){ + if (jTable4.getSelectedRow() >= 0){ + ffsAttributesTableModel.removeRow(jTable4.getSelectedRow()); + } + } + }); + } + return jButton18; + } + + /** + * This method initializes jButton19 + * + * @return javax.swing.JButton + */ + private JButton getJButton19() { + if (jButton19 == null) { + jButton19 = new JButton(); + jButton19.setPreferredSize(new java.awt.Dimension(75,20)); + jButton19.setEnabled(false); + jButton19.setText("Update"); + } + return jButton19; + } + + /** + * This method initializes jCheckBox9 + * + * @return javax.swing.JCheckBox + */ + private JCheckBox getJCheckBox9() { + if (jCheckBox9 == null) { + jCheckBox9 = new JCheckBox(); + jCheckBox9.setPreferredSize(new java.awt.Dimension(50,20)); + jCheckBox9.setText("IA32"); + } + return jCheckBox9; + } + + /** + * This method initializes jCheckBox10 + * + * @return javax.swing.JCheckBox + */ + private JCheckBox getJCheckBox10() { + if (jCheckBox10 == null) { + jCheckBox10 = new JCheckBox(); + jCheckBox10.setPreferredSize(new java.awt.Dimension(50,20)); + jCheckBox10.setText("IPF"); + } + return jCheckBox10; + } + + /** + * This method initializes jCheckBox11 + * + * @return javax.swing.JCheckBox + */ + private JCheckBox getJCheckBox11() { + if (jCheckBox11 == null) { + jCheckBox11 = new JCheckBox(); + jCheckBox11.setText("X64"); + jCheckBox11.setPreferredSize(new java.awt.Dimension(47,20)); + } + return jCheckBox11; + } + + /** + * This method initializes jCheckBox12 + * + * @return javax.swing.JCheckBox + */ + private JCheckBox getJCheckBox12() { + if (jCheckBox12 == null) { + jCheckBox12 = new JCheckBox(); + jCheckBox12.setPreferredSize(new java.awt.Dimension(50,20)); + jCheckBox12.setText("EBC"); + } + return jCheckBox12; + } + + /** + * This method initializes jCheckBox13 + * + * @return javax.swing.JCheckBox + */ + private JCheckBox getJCheckBox13() { + if (jCheckBox13 == null) { + jCheckBox13 = new JCheckBox(); + jCheckBox13.setPreferredSize(new java.awt.Dimension(55,20)); + jCheckBox13.setText("ARM"); + } + return jCheckBox13; + } + + /** + * This method initializes jCheckBox14 + * + * @return javax.swing.JCheckBox + */ + private JCheckBox getJCheckBox14() { + if (jCheckBox14 == null) { + jCheckBox14 = new JCheckBox(); + jCheckBox14.setPreferredSize(new java.awt.Dimension(50,20)); + jCheckBox14.setText("PPC"); + } + return jCheckBox14; + } + + /** + * This method initializes jTextField12 + * + * @return javax.swing.JTextField + */ + private JTextField getJTextField12() { + if (jTextField12 == null) { + jTextField12 = new JTextField(); + jTextField12.setPreferredSize(new java.awt.Dimension(150,20)); + } + return jTextField12; + } + + /** + * This method initializes jTextField13 + * + * @return javax.swing.JTextField + */ + private JTextField getJTextField13() { + if (jTextField13 == null) { + jTextField13 = new JTextField(); + jTextField13.setPreferredSize(new java.awt.Dimension(140,20)); + } + return jTextField13; + } + + /** + * @param args + */ + public static void main(String[] args) { + // TODO Auto-generated method stub + new FpdBuildOptions().setVisible(true); + } + + /** + * This is the default constructor + */ + public FpdBuildOptions() { + super(); + initialize(); + this.setVisible(true); + } + + public FpdBuildOptions(PlatformSurfaceAreaDocument.PlatformSurfaceArea fpd) { + this(); + ffc = new FpdFileContents(fpd); + init(ffc); + } + + private void init(FpdFileContents ffc) { + initOptionTable(); + initAntTaskTable(); + } + + private void initOptionTable() { + if (ffc.getBuildOptionsOptCount() == 0) { + //ToDo get default options from *.txt file + return; + } + String[][] saa = new String[ffc.getBuildOptionsOptCount()][6]; + ffc.getBuildOptionsOpts(saa); + for (int i = 0; i < saa.length; ++i) { + optionsTableModel.addRow(saa[i]); + } + } + + private void initAntTaskTable() { + if (ffc.getBuildOptionsUserDefAntTaskCount() == 0) { + return; + } + String[][] saa = new String[ffc.getBuildOptionsUserDefAntTaskCount()][3]; + ffc.getBuildOptionsUserDefAntTasks(saa); + for (int i = 0; i < saa.length; ++i) { + antTaskTableModel.addRow(saa[i]); + } + } + /** + * This method initializes this + * + * @return void + */ + private void initialize() { + this.setSize(722, 439); + this.setTitle("FPD Build Options"); + 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(getJPanel(), java.awt.BorderLayout.SOUTH); + jContentPane.add(getJPanel1(), java.awt.BorderLayout.NORTH); + jContentPane.add(getJPanel2(), java.awt.BorderLayout.WEST); + jContentPane.add(getJPanel3(), java.awt.BorderLayout.EAST); + jContentPane.add(getJTabbedPane(), java.awt.BorderLayout.CENTER); + } + return jContentPane; + } + +} // @jve:decl-index=0:visual-constraint="10,10" diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/FpdDynamicPcdBuildDefinitions.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/FpdDynamicPcdBuildDefinitions.java new file mode 100644 index 0000000000..155f4f48d4 --- /dev/null +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/FpdDynamicPcdBuildDefinitions.java @@ -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; + } +} diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/FpdFileContents.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/FpdFileContents.java new file mode 100644 index 0000000000..7d086f46e7 --- /dev/null +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/FpdFileContents.java @@ -0,0 +1,1591 @@ +/** @file + Java class FpdFileContents is used to parse fpd 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.platform.ui; + +import java.io.File; +import java.io.IOException; +import java.math.BigInteger; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.ListIterator; +import java.util.Map; +import java.util.Set; + +import javax.xml.namespace.QName; + +import org.apache.xmlbeans.XmlCursor; +import org.apache.xmlbeans.XmlObject; +import org.apache.xmlbeans.XmlOptions; +import org.tianocore.AntTaskDocument; +import org.tianocore.BuildOptionsDocument; +import org.tianocore.DynamicPcdBuildDefinitionsDocument; +import org.tianocore.FlashDefinitionFileDocument; +import org.tianocore.FlashDeviceDefinitionsDocument; +import org.tianocore.FlashDocument; +import org.tianocore.FrameworkModulesDocument; +import org.tianocore.FvRegionNameDocument; +import org.tianocore.LibrariesDocument; +import org.tianocore.ModuleSADocument; +import org.tianocore.ModuleSurfaceAreaDocument; +import org.tianocore.OptionDocument; +import org.tianocore.OptionsDocument; +import org.tianocore.PcdBuildDefinitionDocument; +import org.tianocore.PcdCodedDocument; +import org.tianocore.PcdDataTypes; +import org.tianocore.PcdDeclarationsDocument; +import org.tianocore.PcdItemTypes; +import org.tianocore.PlatformDefinitionsDocument; +import org.tianocore.PlatformSurfaceAreaDocument; +import org.tianocore.FvImageTypes; +import org.tianocore.FvImagesDocument; +import org.tianocore.LicenseDocument; +import org.tianocore.PlatformHeaderDocument; +import org.tianocore.SkuInfoDocument; +import org.tianocore.UserDefinedAntTasksDocument; +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; + +/** + This class processes fpd file contents such as add remove xml elements. + @since PackageEditor 1.0 +**/ +public class FpdFileContents { + + static final String xmlNs = "http://www.TianoCore.org/2006/Edk2.0"; + + private PlatformSurfaceAreaDocument fpdd = null; + + private PlatformSurfaceAreaDocument.PlatformSurfaceArea fpdRoot = null; + + private PlatformHeaderDocument.PlatformHeader fpdHdr = null; + + private PlatformDefinitionsDocument.PlatformDefinitions fpdPlatformDefs = null; + + private FlashDocument.Flash fpdFlash = null; + + private BuildOptionsDocument.BuildOptions fpdBuildOpts = null; + + private FrameworkModulesDocument.FrameworkModules fpdFrameworkModules = null; + + private DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions fpdDynPcdBuildDefs = null; + + public static HashMap> dynPcdMap = null; + + /** + * look through all pcd data in all ModuleSA, create pcd -> ModuleSA mappings. + */ + public void initDynPcdMap() { + if (dynPcdMap == null) { + dynPcdMap = new HashMap>(); + List l = getfpdFrameworkModules().getModuleSAList(); + if (l == null) { + return; + } + ListIterator li = l.listIterator(); + while (li.hasNext()) { + ModuleSADocument.ModuleSA msa = li.next(); + if (msa.getPcdBuildDefinition() == null || msa.getPcdBuildDefinition().getPcdDataList() == null) { + continue; + } + String ModuleInfo = msa.getModuleGuid() + " " + msa.getModuleVersion() + + " " + msa.getPackageGuid() + " " + msa.getPackageVersion(); + List lp = msa.getPcdBuildDefinition().getPcdDataList(); + ListIterator lpi = lp.listIterator(); + while (lpi.hasNext()) { + PcdBuildDefinitionDocument.PcdBuildDefinition.PcdData pcdData = lpi.next(); + String pcdKey = pcdData.getCName() + " " + pcdData.getTokenSpaceGuidCName(); + if (dynPcdMap.get(pcdKey) == null) { + ArrayList al = new ArrayList(); + al.add(ModuleInfo + " " + pcdData.getItemType().toString()); + dynPcdMap.put(pcdKey, al); + } + else{ + dynPcdMap.get(pcdKey).add(ModuleInfo + " " + pcdData.getItemType().toString()); + } + } + } + } + } + /** + Constructor to create a new spd file + **/ + public FpdFileContents() { + + fpdd = PlatformSurfaceAreaDocument.Factory.newInstance(); + fpdRoot = fpdd.addNewPlatformSurfaceArea(); + + } + + /** + Constructor for existing document object + @param psa + **/ + public FpdFileContents(PlatformSurfaceAreaDocument.PlatformSurfaceArea fpd) { + fpdRoot = fpd; + fpdHdr = fpdRoot.getPlatformHeader(); + fpdPlatformDefs = fpdRoot.getPlatformDefinitions(); + fpdBuildOpts = fpdRoot.getBuildOptions(); + fpdFrameworkModules = fpdRoot.getFrameworkModules(); + fpdDynPcdBuildDefs = fpdRoot.getDynamicPcdBuildDefinitions(); + fpdFlash = fpdRoot.getFlash(); + } + + /** + Constructor based on an existing spd file + + @param f Existing spd file + **/ + public FpdFileContents(File f) { + try { + fpdd = PlatformSurfaceAreaDocument.Factory.parse(f); + fpdRoot = fpdd.getPlatformSurfaceArea(); + } catch (Exception e) { + System.out.println(e.toString()); + } + } + + public DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions getfpdDynPcdBuildDefs() { + if (fpdDynPcdBuildDefs == null){ + fpdDynPcdBuildDefs = fpdRoot.addNewDynamicPcdBuildDefinitions(); + } + return fpdDynPcdBuildDefs; + } + + public FrameworkModulesDocument.FrameworkModules getfpdFrameworkModules() { + if (fpdFrameworkModules == null){ + fpdFrameworkModules = fpdRoot.addNewFrameworkModules(); + } + return fpdFrameworkModules; + } + + public int getPlatformDefsSkuInfoCount(){ + if (getfpdPlatformDefs().getSkuInfo() == null || getfpdPlatformDefs().getSkuInfo().getUiSkuNameList() == null) { + return 0; + } + return getfpdPlatformDefs().getSkuInfo().getUiSkuNameList().size(); + } + + public void getPlatformDefsSkuInfos(String[][] saa){ + if (getfpdPlatformDefs().getSkuInfo() == null || getfpdPlatformDefs().getSkuInfo().getUiSkuNameList() == null) { + return ; + } + + List l = getfpdPlatformDefs().getSkuInfo().getUiSkuNameList(); + ListIterator li = l.listIterator(); + int i = 0; + while(li.hasNext()) { + SkuInfoDocument.SkuInfo.UiSkuName sku = li.next(); + saa[i][0] = sku.getSkuID()+""; + saa[i][1] = sku.getStringValue(); + ++i; + } + } + + public int getFrameworkModulesCount() { + if (getfpdFrameworkModules().getModuleSAList() == null){ + return 0; + } + return getfpdFrameworkModules().getModuleSAList().size(); + } + + public void getFrameworkModulesInfo(String[][] saa) { + if (getFrameworkModulesCount() == 0){ + return; + } + + ListIterator li = getfpdFrameworkModules().getModuleSAList().listIterator(); + int i = 0; + while(li.hasNext()) { + ModuleSADocument.ModuleSA msa = (ModuleSADocument.ModuleSA)li.next(); + saa[i][1] = msa.getModuleGuid(); + saa[i][2] = msa.getModuleVersion(); + + saa[i][3] = msa.getPackageGuid(); + saa[i][4] = msa.getPackageVersion(); +// saa[i][4] = listToString(msa.getSupArchList()); + ++i; + } + } + + public ModuleSADocument.ModuleSA getModuleSA(String key) { + String[] s = key.split(" "); + if (getfpdFrameworkModules().getModuleSAList() == null) { + return null; + } + ListIterator li = getfpdFrameworkModules().getModuleSAList().listIterator(); + while(li.hasNext()) { + ModuleSADocument.ModuleSA msa = (ModuleSADocument.ModuleSA)li.next(); + if (msa.getModuleGuid().equals(s[0]) && msa.getModuleVersion().equals(s[1]) + && msa.getPackageGuid().equals(s[2]) && msa.getPackageVersion().equals(s[3])) { + + return msa; + } + } + return null; + } + public void removeModuleSA(int i) { + XmlObject o = getfpdFrameworkModules(); + if (o == null) { + return; + } + + XmlCursor cursor = o.newCursor(); + if (cursor.toFirstChild()) { + for (int j = 0; j < i; ++j) { + cursor.toNextSibling(); + } + // + // remove pcd from dynPcdMap, if DynamicPcdBuildData exists, remove them too. + // + ModuleSADocument.ModuleSA moduleSa = (ModuleSADocument.ModuleSA)cursor.getObject(); + String moduleInfo = moduleSa.getModuleGuid() + " " + moduleSa.getModuleVersion() + " " + + moduleSa.getPackageGuid()+ " " + moduleSa.getPackageVersion(); + PcdBuildDefinitionDocument.PcdBuildDefinition pcdBuildDef = moduleSa.getPcdBuildDefinition(); + if (pcdBuildDef != null) { + maintainDynPcdMap(pcdBuildDef, moduleInfo); + } + cursor.removeXml(); + } + cursor.dispose(); + } + + private void maintainDynPcdMap(PcdBuildDefinitionDocument.PcdBuildDefinition o, String moduleInfo) { + XmlCursor cursor = o.newCursor(); + boolean fromLibInstance = false; + if (!cursor.toFirstChild()){ + return; + } + // + // deal with first child, same process in the while loop below for siblings. + // + PcdBuildDefinitionDocument.PcdBuildDefinition.PcdData pcdData = (PcdBuildDefinitionDocument.PcdBuildDefinition.PcdData)cursor.getObject(); + String pcdKey = pcdData.getCName() + " " + pcdData.getTokenSpaceGuidCName(); + ArrayList al = dynPcdMap.get(pcdKey); + for(int i = 0; i < al.size(); ++i){ + if (al.get(i).startsWith(moduleInfo)){ + fromLibInstance = true; + break; + } + } + al.remove(moduleInfo + " " + pcdData.getItemType().toString()); + if (al.size() == 0) { + dynPcdMap.remove(pcdKey); + } + + if (pcdData.getItemType().toString().equals("DYNAMIC")) { + if (dynPcdMap.get(pcdKey) == null) { + removeDynamicPcdBuildData(pcdData.getCName(), pcdData.getTokenSpaceGuidCName()); + } + } + if (fromLibInstance){ + cursor.removeXml(); + } + while(cursor.toNextSibling()) { + fromLibInstance = false; + pcdData = (PcdBuildDefinitionDocument.PcdBuildDefinition.PcdData)cursor.getObject(); + // + // remove each pcd record from dynPcdMap + // + pcdKey = pcdData.getCName() + " " + pcdData.getTokenSpaceGuidCName(); + al = dynPcdMap.get(pcdKey); + for(int i = 0; i < al.size(); ++i){ + if (al.get(i).startsWith(moduleInfo)){ + fromLibInstance = true; + break; + } + } + al.remove(moduleInfo + " " + pcdData.getItemType().toString()); + if (al.size() == 0) { + dynPcdMap.remove(pcdKey); + } + + if (pcdData.getItemType().toString().equals("DYNAMIC")) { + // + // First check whether this is the only consumer of this dyn pcd. + // + if (dynPcdMap.get(pcdKey) == null) { + // + // delete corresponding entry in DynamicPcdBuildData + // + removeDynamicPcdBuildData(pcdData.getCName(), pcdData.getTokenSpaceGuidCName()); + } + } + if (fromLibInstance){ + cursor.removeXml(); + } + } + } + // + // key for ModuleSA : "ModuleGuid ModuleVer PackageGuid PackageVer" + // + public int getPcdDataCount(String key){ + ModuleSADocument.ModuleSA msa = getModuleSA(key); + if (msa == null || msa.getPcdBuildDefinition() == null || msa.getPcdBuildDefinition().getPcdDataList() == null){ + return 0; + } + return msa.getPcdBuildDefinition().getPcdDataList().size(); + } + + public void getPcdData(String key, String[][] saa) { + ModuleSADocument.ModuleSA msa = getModuleSA(key); + if (msa == null || msa.getPcdBuildDefinition() == null || msa.getPcdBuildDefinition().getPcdDataList() == null){ + return; + } + ListIteratorli = msa.getPcdBuildDefinition().getPcdDataList().listIterator(); + for (int i = 0; i < saa.length; ++i) { + PcdBuildDefinitionDocument.PcdBuildDefinition.PcdData pcdData = li.next(); + saa[i][0] = pcdData.getCName(); + saa[i][1] = pcdData.getTokenSpaceGuidCName(); + saa[i][2] = pcdData.getItemType().toString(); + saa[i][3] = pcdData.getToken().toString(); + saa[i][4] = pcdData.getDatumType().toString(); + saa[i][5] = pcdData.getValue(); + + } + } + // + // key for ModuleSA : "ModuleGuid ModuleVer PackageGuid PackageVer" + // + public int getLibraryInstancesCount(String key) { + ModuleSADocument.ModuleSA msa = getModuleSA(key); + if (msa == null || msa.getLibraries() == null || msa.getLibraries().getInstanceList() == null){ + return 0; + } + return msa.getLibraries().getInstanceList().size(); + } + + public void getLibraryInstances(String key, String[][] saa){ + ModuleSADocument.ModuleSA msa = getModuleSA(key); + if (msa == null || msa.getLibraries() == null || msa.getLibraries().getInstanceList() == null){ + return ; + } + + ListIterator li = msa.getLibraries().getInstanceList().listIterator(); + for (int i = 0; i < saa.length; ++i) { + LibrariesDocument.Libraries.Instance instance = li.next(); + saa[i][1] = instance.getModuleGuid(); + saa[i][2] = instance.getModuleVersion(); + saa[i][3] = instance.getPackageGuid(); + saa[i][4] = instance.getPackageVersion(); + } + } + + public void removeLibraryInstances(String key) { + ModuleSADocument.ModuleSA msa = getModuleSA(key); + if (msa == null || msa.getLibraries() == null){ + return ; + } + + XmlCursor cursor = msa.getLibraries().newCursor(); + cursor.removeXml(); + cursor.dispose(); + } + + public void genLibraryInstance(String mg, String mv, String pg, String pv, String key) { + ModuleSADocument.ModuleSA msa = getModuleSA(key); + if (msa == null){ + msa = getfpdFrameworkModules().addNewModuleSA(); + } + LibrariesDocument.Libraries libs = msa.getLibraries(); + if(libs == null){ + libs = msa.addNewLibraries(); + } + + LibrariesDocument.Libraries.Instance instance = libs.addNewInstance(); + instance.setModuleGuid(mg); + instance.setModuleVersion(mv); + instance.setPackageGuid(pg); + instance.setPackageVersion(pv); + + } + /**add pcd information of module mi to a ModuleSA. + * @param mi + * @param moduleSa if null, generate a new ModuleSA. + */ + public void addFrameworkModulesPcdBuildDefs(ModuleIdentification mi, ModuleSADocument.ModuleSA moduleSa){ + //ToDo add Arch filter + + try { + ModuleSurfaceAreaDocument.ModuleSurfaceArea msa = (ModuleSurfaceAreaDocument.ModuleSurfaceArea)GlobalData.getModuleXmlObject(mi); + if (msa.getPcdCoded() == null) { + return; + } + if (moduleSa == null) { + moduleSa = genModuleSA(mi); + } + Map m = new HashMap(); + m.put("ModuleSurfaceArea", msa); + SurfaceAreaQuery.setDoc(m); + PackageIdentification[] depPkgs = SurfaceAreaQuery.getDependencePkg(null); + // + // Implementing InitializePlatformPcdBuildDefinitions + // + List l = msa.getPcdCoded().getPcdEntryList(); + ListIterator li = l.listIterator(); + while(li.hasNext()) { + PcdCodedDocument.PcdCoded.PcdEntry msaPcd = (PcdCodedDocument.PcdCoded.PcdEntry)li.next(); + PcdDeclarationsDocument.PcdDeclarations.PcdEntry spdPcd = LookupPcdDeclaration(msaPcd, depPkgs); + if (spdPcd == null) { + // + // ToDo Error + // + break; + } + // + // AddItem to ModuleSA PcdBuildDefinitions + // + String defaultVal = msaPcd.getDefaultValue() == null ? spdPcd.getDefaultValue() : msaPcd.getDefaultValue(); + genPcdData(msaPcd.getCName(), spdPcd.getToken(), msaPcd.getTokenSpaceGuidCName(), msaPcd.getPcdItemType().toString(), spdPcd.getDatumType()+"", defaultVal, moduleSa); + } + + } + catch (Exception e){ + e.printStackTrace(); + } + + } + + private PcdDeclarationsDocument.PcdDeclarations.PcdEntry LookupPcdDeclaration (PcdCodedDocument.PcdCoded.PcdEntry msaPcd, PackageIdentification[] depPkgs) { + + Map m = new HashMap(); + PcdDeclarationsDocument.PcdDeclarations.PcdEntry spdPcd = null; + for (int i = 0; i < depPkgs.length; ++i) { + m.put("PackageSurfaceArea", GlobalData.getPackageXmlObject(depPkgs[i])); + SurfaceAreaQuery.setDoc(m); + XmlObject[] xo = SurfaceAreaQuery.getSpdPcdDeclarations(); + if (xo == null) { + continue; + } + for (int j = 0; j < xo.length; ++j) { + spdPcd = (PcdDeclarationsDocument.PcdDeclarations.PcdEntry)xo[j]; + if (msaPcd.getTokenSpaceGuidCName() == null) { + if (spdPcd.getCName().equals(msaPcd.getCName())) { + return spdPcd; + } + } + else{ + if (spdPcd.getCName().equals(msaPcd.getCName()) && spdPcd.getTokenSpaceGuidCName().equals(msaPcd.getTokenSpaceGuidCName())) { + return spdPcd; + } + } + + } + + } + return null; + } + + private ModuleSADocument.ModuleSA genModuleSA (ModuleIdentification mi) { + PackageIdentification pi = GlobalData.getPackageForModule(mi); + ModuleSADocument.ModuleSA msa = getfpdFrameworkModules().addNewModuleSA(); + msa.setModuleGuid(mi.getGuid()); + msa.setModuleVersion(mi.getVersion()); + msa.setPackageGuid(pi.getGuid()); + msa.setPackageVersion(pi.getVersion()); + + return msa; + } + + private void genPcdData (String cName, Object token, String tsGuid, String itemType, String dataType, String defaultVal, ModuleSADocument.ModuleSA moduleSa) { + if (moduleSa.getPcdBuildDefinition() == null){ + moduleSa.addNewPcdBuildDefinition(); + } + // + // constructe pcd to modulesa mapping first. + // Attention : for any error condition, remove from map this pcd. + // + ArrayList pcdConsumer = LookupPlatformPcdData(cName + " " + tsGuid); + if (pcdConsumer == null) { + pcdConsumer = new ArrayList(); + } + String listValue = moduleSa.getModuleGuid() + " " + moduleSa.getModuleVersion() + + " " + moduleSa.getPackageGuid() + " " + moduleSa.getPackageVersion() + + " " + itemType; + pcdConsumer.add(listValue); + dynPcdMap.put(cName + " " + tsGuid, pcdConsumer); + // + // Special dynamic type, if this pcd already exists in other ModuleSA + // + if (itemType.equals("DYNAMIC")) { + + ListIterator li = pcdConsumer.listIterator(); + while(li.hasNext()) { + String value = li.next().toString(); + String[] valuePart= value.split(" "); + if (!valuePart[4].equals("DYNAMIC")) { + //ToDo error for same pcd, other type than dynamic + pcdConsumer.remove(listValue); + return; + } + } + } + else { + ListIterator li = pcdConsumer.listIterator(); + while(li.hasNext()) { + String value = li.next().toString(); + String[] valuePart= value.split(" "); + if (valuePart[4].equals("DYNAMIC")) { + //ToDo error for same pcd, other type than non-dynamic + pcdConsumer.remove(listValue); + return; + } + } + } + + PcdBuildDefinitionDocument.PcdBuildDefinition.PcdData fpdPcd = moduleSa.getPcdBuildDefinition().addNewPcdData(); + fpdPcd.setCName(cName); + fpdPcd.setToken(token); + fpdPcd.setTokenSpaceGuidCName(tsGuid); + fpdPcd.setDatumType(PcdDataTypes.Enum.forString(dataType)); + fpdPcd.setItemType(PcdItemTypes.Enum.forString(itemType)); + + if (itemType.equals("DYNAMIC") || itemType.equals("DYNAMIC_EX")) { + ArrayList al = LookupDynamicPcdBuildDefinition(cName + " " + tsGuid); + // + // if only one module mapped to this pcd, then the one is myself. so no other module mapped. + // so need to add one dyn pcd. + // + if (al.size() == 1) { + addDynamicPcdBuildData(cName, token, tsGuid, itemType, dataType, defaultVal); + } + } + else { + if (defaultVal != null){ + fpdPcd.setValue(defaultVal); + } + else { + if (dataType.equals("UINT8") || dataType.equals("UINT16") || dataType.equals("UINT32") || dataType.equals("UINT64")) { + fpdPcd.setValue("0"); + } + if (dataType.equals("BOOLEAN")){ + fpdPcd.setValue("false"); + } + if (dataType.equals("VOID*")) { + fpdPcd.setValue(""); + } + } + if (dataType.equals("UINT8")){ + fpdPcd.setMaxDatumSize(1); + } + if (dataType.equals("UINT16")) { + fpdPcd.setMaxDatumSize(2); + } + if (dataType.equals("UINT32")) { + fpdPcd.setMaxDatumSize(4); + } + if (dataType.equals("UINT64")){ + fpdPcd.setMaxDatumSize(8); + } + if (dataType.equals("BOOLEAN")){ + fpdPcd.setMaxDatumSize(1); + } + if (dataType.equals("VOID*")) { + int maxSize = setMaxSizeForPointer(fpdPcd.getValue()); + fpdPcd.setMaxDatumSize(maxSize); + } + } + } + + private int setMaxSizeForPointer(String datum) { + if (datum == null) { + return 0; + } + char ch = datum.charAt(0); + int start, end; + String strValue; + // + // For void* type PCD, only three datum is support: + // 1) Unicode: string with start char is "L" + // 2) Ansci: String is "" + // 3) byte array: String start char "{" + // + if (ch == 'L') { + start = datum.indexOf('\"'); + end = datum.lastIndexOf('\"'); + if ((start > end) || + (end > datum.length())|| + ((start == end) && (datum.length() > 0))) { + //ToDo Error handling here + } + + strValue = datum.substring(start + 1, end); + return strValue.length() * 2; + } else if (ch == '\"'){ + start = datum.indexOf('\"'); + end = datum.lastIndexOf('\"'); + if ((start > end) || + (end > datum.length())|| + ((start == end) && (datum.length() > 0))) { + + } + strValue = datum.substring(start + 1, end); + return strValue.length(); + } else if (ch =='{') { + String[] strValueArray; + + start = datum.indexOf('{'); + end = datum.lastIndexOf('}'); + strValue = datum.substring(start + 1, end); + strValue = strValue.trim(); + if (strValue.length() == 0) { + return 0; + } + strValueArray = strValue.split(","); + for (int index = 0; index < strValueArray.length; index ++) { + Integer value = Integer.decode(strValueArray[index].trim()); + + if (value > 0xFF) { +// "[FPD file error] The datum type of PCD %s in %s is VOID*, "+ +// "it is byte array in fact. But the element of %s exceed the byte range", + + } + } + return strValueArray.length; + + + } else { +// "[FPD file error] The datum type of PCD %s in %s is VOID*. For VOID* type, you have three format choise:\n "+ +// "1) UNICODE string: like L\"xxxx\";\r\n"+ +// "2) ANSIC string: like \"xxx\";\r\n"+ +// "3) Byte array: like {0x2, 0x45, 0x23}\r\n"+ +// "but the datum in seems does not following above format!", + return -1; + + } + } + + private ArrayList LookupDynamicPcdBuildDefinition(String dynPcdKey) { + ArrayList al = dynPcdMap.get(dynPcdKey); + + return al; + } + + private ArrayList LookupPlatformPcdData(String pcdKey) { + + return dynPcdMap.get("pcdKey"); + } + + public int getDynamicPcdBuildDataCount() { + if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null) { + return 0; + } + return getfpdDynPcdBuildDefs().getPcdBuildDataList().size(); + } + + public void getDynamicPcdBuildData(String[][] saa) { + if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null) { + return ; + } + List l = getfpdDynPcdBuildDefs().getPcdBuildDataList(); + ListIterator li = l.listIterator(); + int i = 0; + while(li.hasNext()) { + DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData dynPcd = li.next(); + saa[i][0] = dynPcd.getCName(); + saa[i][1] = dynPcd.getToken().toString(); + saa[i][2] = dynPcd.getTokenSpaceGuidCName(); + saa[i][3] = dynPcd.getMaxDatumSize()+""; + saa[i][4] = dynPcd.getDatumType().toString(); + + ++i; + } + } + + private void addDynamicPcdBuildData(String cName, Object token, String tsGuid, String itemType, String dataType, String defaultVal) { + DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData dynPcdData = getfpdDynPcdBuildDefs().addNewPcdBuildData(); + dynPcdData.setItemType(PcdItemTypes.Enum.forString(itemType)); + dynPcdData.setCName(cName); + dynPcdData.setToken(token); + dynPcdData.setTokenSpaceGuidCName(tsGuid); + dynPcdData.setDatumType(PcdDataTypes.Enum.forString(dataType)); + + BigInteger bigInt = new BigInteger("0"); + DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData.SkuInfo skuInfo = dynPcdData.addNewSkuInfo(); + skuInfo.setSkuId(bigInt); + if (defaultVal != null){ + skuInfo.setValue(defaultVal); + } + else { + if (dataType.equals("UINT8")){ + skuInfo.setValue("0"); + } + if (dataType.equals("UINT16")) { + skuInfo.setValue("0"); + } + if (dataType.equals("UINT32")) { + skuInfo.setValue("0"); + } + if (dataType.equals("UINT64")){ + skuInfo.setValue("0"); + } + if (dataType.equals("BOOLEAN")){ + skuInfo.setValue("false"); + } + if (dataType.equals("VOID*")) { + skuInfo.setValue(""); + } + } + if (dataType.equals("UINT8")){ + dynPcdData.setMaxDatumSize(1); + } + if (dataType.equals("UINT16")) { + dynPcdData.setMaxDatumSize(2); + } + if (dataType.equals("UINT32")) { + dynPcdData.setMaxDatumSize(4); + } + if (dataType.equals("UINT64")){ + dynPcdData.setMaxDatumSize(8); + } + if (dataType.equals("BOOLEAN")){ + dynPcdData.setMaxDatumSize(1); + } + if (dataType.equals("VOID*")) { + int maxSize = setMaxSizeForPointer(defaultVal); + dynPcdData.setMaxDatumSize(maxSize); + } + } + + private void removeDynamicPcdBuildData(String cName, String tsGuid) { + XmlObject o = getfpdDynPcdBuildDefs(); + + XmlCursor cursor = o.newCursor(); + if (cursor.toFirstChild()) { + DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData pcdBuildData = + (DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData)cursor.getObject(); + while (!(pcdBuildData.getCName().equals(cName) && pcdBuildData.getTokenSpaceGuidCName().equals(tsGuid))) { + cursor.toNextSibling(); + pcdBuildData = (DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData)cursor.getObject(); + } + + cursor.removeXml(); + } + cursor.dispose(); + } + // + // Get the Sku Info count of ith dyn pcd element. + // + public int getDynamicPcdSkuInfoCount(int i){ + if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) { + return 0; + } + + int skuInfoCount = 0; + XmlCursor cursor = getfpdDynPcdBuildDefs().newCursor(); + if (cursor.toFirstChild()) { + for (int j = 0; j < i; ++j) { + cursor.toNextSibling(); + } + DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData pcdData = (DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData)cursor.getObject(); + if (pcdData.getSkuInfoList() == null) { + skuInfoCount = 0; + } + else { + skuInfoCount = pcdData.getSkuInfoList().size(); + } + } + cursor.dispose(); + return skuInfoCount; + } + + public void getDynamicPcdSkuInfos(int i, String[][] saa){ + if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) { + return; + } + + XmlCursor cursor = getfpdDynPcdBuildDefs().newCursor(); + if (cursor.toFirstChild()) { + for (int j = 0; j < i; ++j) { + cursor.toNextSibling(); + } + DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData pcdData = (DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData)cursor.getObject(); + if (pcdData.getSkuInfoList() == null) { + cursor.dispose(); + return; + } + else { + ListIterator li = pcdData.getSkuInfoList().listIterator(); + int k = 0; + while (li.hasNext()) { + DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData.SkuInfo skuInfo = li.next(); + saa[k][0] = skuInfo.getSkuId()+""; + saa[k][1] = skuInfo.getVariableName(); + saa[k][2] = skuInfo.getVariableGuid(); + saa[k][3] = skuInfo.getVariableOffset(); + saa[k][4] = skuInfo.getHiiDefaultValue(); + saa[k][5] = skuInfo.getVpdOffset(); + saa[k][6] = skuInfo.getValue(); + ++k; + } + + } + } + cursor.dispose(); + + } + + public String getDynamicPcdBuildDataValue(int i){ + String value = null; + if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) { + return value; + } + + XmlCursor cursor = getfpdDynPcdBuildDefs().newCursor(); + if (cursor.toFirstChild()) { + for (int j = 0; j < i; ++j) { + cursor.toNextSibling(); + } + DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData pcdData = (DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData)cursor.getObject(); + if (pcdData.getSkuInfoList() == null) { + value = null; + } + else { + value = pcdData.getSkuInfoArray(0).getValue(); + } + } + cursor.dispose(); + return value; + } + + public String getDynamicPcdBuildDataVpdOffset(int i){ + String vpdOffset = null; + if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) { + return vpdOffset; + } + + XmlCursor cursor = getfpdDynPcdBuildDefs().newCursor(); + if (cursor.toFirstChild()) { + for (int j = 0; j < i; ++j) { + cursor.toNextSibling(); + } + DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData pcdData = (DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData)cursor.getObject(); + if (pcdData.getSkuInfoList() == null) { + vpdOffset = null; + } + else { + vpdOffset = pcdData.getSkuInfoArray(0).getVpdOffset(); + } + } + cursor.dispose(); + return vpdOffset; + } + + public void removeDynamicPcdBuildDataSkuInfo(int i) { + if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) { + return; + } + + XmlCursor cursor = getfpdDynPcdBuildDefs().newCursor(); + if (cursor.toFirstChild()) { + for (int j = 0; j < i; ++j) { + cursor.toNextSibling(); + } + DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData pcdData = (DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData)cursor.getObject(); + if (pcdData.getSkuInfoList() == null) { + cursor.dispose(); + return; + } + else { + QName qSkuInfo = new QName(xmlNs, "SkuInfo"); + cursor.toChild(qSkuInfo); + cursor.removeXml(); + } + } + cursor.dispose(); + } + // + // generate sku info for ith dyn pcd build data. + // + public void genDynamicPcdBuildDataSkuInfo(String id, String varName, String varGuid, String varOffset, + String hiiDefault, String vpdOffset, String value, int i) { + if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) { + return; + } + + XmlCursor cursor = getfpdDynPcdBuildDefs().newCursor(); + if (cursor.toFirstChild()) { + for (int j = 0; j < i; ++j) { + cursor.toNextSibling(); + } + DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData pcdData = (DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData)cursor.getObject(); + DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData.SkuInfo skuInfo = pcdData.addNewSkuInfo(); + skuInfo.setSkuId(new BigInteger(id)); + if (varName != null){ + skuInfo.setVariableName(varName); + skuInfo.setVariableGuid(varGuid); + skuInfo.setVariableOffset(varOffset); + skuInfo.setHiiDefaultValue(hiiDefault); + } + else if (vpdOffset != null){ + skuInfo.setVpdOffset(vpdOffset); + } + else{ + skuInfo.setValue(value); + } + } + } + + public void updateDynamicPcdBuildDataSkuInfo(String id, String varName, String varGuid, String varOffset, + String hiiDefault, String vpdOffset, String value, int i){ + if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) { + return; + } + + XmlCursor cursor = getfpdDynPcdBuildDefs().newCursor(); + if (cursor.toFirstChild()) { + for (int j = 0; j < i; ++j) { + cursor.toNextSibling(); + } + DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData pcdData = (DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData)cursor.getObject(); + ListIterator li = pcdData.getSkuInfoList().listIterator(); + while (li.hasNext()) { + DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData.SkuInfo skuInfo = li.next(); + if (skuInfo.getSkuId().toString().equals(id)){ + if (varName != null){ + skuInfo.setVariableName(varName); + skuInfo.setVariableGuid(varGuid); + skuInfo.setVariableOffset(varOffset); + skuInfo.setHiiDefaultValue(hiiDefault); + } + else if (vpdOffset != null){ + skuInfo.setVpdOffset(vpdOffset); + } + else{ + skuInfo.setValue(value); + } + break; + } + } + } + } + + public void removePcdDataFromLibraryInstance(String moduleKey, String libInstanceKey){ + ModuleSADocument.ModuleSA moduleSa = getModuleSA(moduleKey); + // + // should better maintain pcd from lib instance only, but maintain all is acceptable now. + // + maintainDynPcdMap(moduleSa.getPcdBuildDefinition(), libInstanceKey); + + } + + public BuildOptionsDocument.BuildOptions getfpdBuildOpts() { + if (fpdBuildOpts == null) { + fpdBuildOpts = fpdRoot.addNewBuildOptions(); + } + return fpdBuildOpts; + } + + public void genBuildOptionsUserDefAntTask (String id, String fileName, String execOrder) { + UserDefinedAntTasksDocument.UserDefinedAntTasks udats = getfpdBuildOpts().getUserDefinedAntTasks(); + if (udats == null) { + udats = getfpdBuildOpts().addNewUserDefinedAntTasks(); + } + + AntTaskDocument.AntTask at = udats.addNewAntTask(); + setBuildOptionsUserDefAntTask(id, fileName, execOrder, at); + } + + private void setBuildOptionsUserDefAntTask(String id, String fileName, String execOrder, AntTaskDocument.AntTask at) { + at.setId(new Integer(id)); + if (fileName != null){ + at.setFilename(fileName); + } + else { + at.setAntCmdOptions(execOrder); + } + } + + public void removeBuildOptionsUserDefAntTask(int i) { + XmlObject o = getfpdBuildOpts().getUserDefinedAntTasks(); + if (o == null) { + return; + } + XmlCursor cursor = o.newCursor(); + if (cursor.toFirstChild()) { + for (int j = 0; j < i; ++j) { + cursor.toNextSibling(); + } + cursor.removeXml(); + } + cursor.dispose(); + } + + public void updateBuildOptionsUserDefAntTask(int i, String id, String fileName, String execOrder){ + XmlObject o = getfpdBuildOpts().getUserDefinedAntTasks(); + if (o == null) { + return; + } + XmlCursor cursor = o.newCursor(); + if (cursor.toFirstChild()) { + for (int j = 0; j < i; ++j) { + cursor.toNextSibling(); + } + AntTaskDocument.AntTask at = (AntTaskDocument.AntTask)cursor.getObject(); + setBuildOptionsUserDefAntTask(id, fileName, execOrder, at); + } + cursor.dispose(); + } + + public int getBuildOptionsUserDefAntTaskCount() { + UserDefinedAntTasksDocument.UserDefinedAntTasks udats = getfpdBuildOpts().getUserDefinedAntTasks(); + if (udats == null || udats.getAntTaskList() == null) { + return 0; + } + + return udats.getAntTaskList().size(); + } + + public void getBuildOptionsUserDefAntTasks(String[][] saa) { + UserDefinedAntTasksDocument.UserDefinedAntTasks udats = getfpdBuildOpts().getUserDefinedAntTasks(); + if (udats == null || udats.getAntTaskList() == null) { + return ; + } + + List l = udats.getAntTaskList(); + ListIterator li = l.listIterator(); + int i = 0; + while (li.hasNext()) { + AntTaskDocument.AntTask at = (AntTaskDocument.AntTask)li.next(); + saa[i][0] = at.getId() + ""; + saa[i][1] = saa[i][2] = ""; + if (at.getFilename() != null){ + saa[i][1] = at.getFilename(); + } + if (at.getAntCmdOptions() != null) { + saa[i][2] = at.getAntCmdOptions(); + } + ++i; + } + } + public void genBuildOptionsOpt(String buildTargets, String toolChain, String tagName, String toolCmd, String archList, String contents) { + OptionsDocument.Options opts = getfpdBuildOpts().getOptions(); + if (opts == null) { + opts = getfpdBuildOpts().addNewOptions(); + } + OptionDocument.Option opt = opts.addNewOption(); + setBuildOptionsOpt(buildTargets, toolChain, tagName, toolCmd, archList, contents, opt); + } + + private void setBuildOptionsOpt(String buildTargets, String toolChain, String tagName, String toolCmd, String archList, String contents, OptionDocument.Option opt){ + opt.setStringValue(contents); +// opt.setBuildTargets(buildTargets); + opt.setToolChainFamily(toolChain); + opt.setTagName(tagName); + opt.setToolCode(toolCmd); + String[] s = archList.split(" "); + ArrayList al = new ArrayList(); + for (int i = 0; i < s.length; ++i) { + al.add(s[i]); + } + opt.setSupArchList(al); + } + + public void removeBuildOptionsOpt(int i){ + + XmlObject o = getfpdBuildOpts().getOptions(); + if (o == null) { + return; + } + + XmlCursor cursor = o.newCursor(); + if (cursor.toFirstChild()) { + for (int j = 0; j < i; ++j) { + cursor.toNextSibling(); + } + cursor.removeXml(); + } + cursor.dispose(); + } + + public void updateBuildOptionsOpt(int i, String buildTargets, String toolChain, String tagName, String toolCmd, String archList, String contents) { + XmlObject o = getfpdBuildOpts().getOptions(); + if (o == null) { + return; + } + + XmlCursor cursor = o.newCursor(); + if (cursor.toFirstChild()) { + for (int j = 0; j < i; ++j) { + cursor.toNextSibling(); + } + OptionDocument.Option opt = (OptionDocument.Option)cursor.getObject(); + setBuildOptionsOpt(buildTargets, toolChain, tagName, toolCmd, archList, contents, opt); + } + cursor.dispose(); + } + + public int getBuildOptionsOptCount(){ + if (getfpdBuildOpts().getOptions() == null || getfpdBuildOpts().getOptions().getOptionList() == null) { + return 0; + } + return getfpdBuildOpts().getOptions().getOptionList().size(); + } + + public void getBuildOptionsOpts(String[][] saa) { + if (getfpdBuildOpts().getOptions() == null || getfpdBuildOpts().getOptions().getOptionList() == null) { + return ; + } + + List lOpt = getfpdBuildOpts().getOptions().getOptionList(); + ListIterator li = lOpt.listIterator(); + int i = 0; + while(li.hasNext()) { + OptionDocument.Option opt = (OptionDocument.Option)li.next(); +// saa[i][0] = opt.getBuildTargets(); + saa[i][1] = opt.getToolChainFamily(); + if (opt.getSupArchList() != null){ + Object[] archs = opt.getSupArchList().toArray(); + saa[i][2] = " "; + for (int j = 0; j < archs.length; ++j){ + saa[i][2] += archs[j]; + saa[i][2] += " "; + } + saa[i][2] = saa[i][2].trim(); + } + saa[i][3] = opt.getToolCode(); + saa[i][4] = opt.getTagName(); + saa[i][5] = opt.getStringValue(); + + ++i; + } + } + + public PlatformDefinitionsDocument.PlatformDefinitions getfpdPlatformDefs(){ + if (fpdPlatformDefs == null){ + fpdPlatformDefs = fpdRoot.addNewPlatformDefinitions(); + } + return fpdPlatformDefs; + } + + public FlashDocument.Flash getfpdFlash() { + if (fpdFlash == null) { + fpdFlash = fpdRoot.addNewFlash(); + } + return fpdFlash; + } + + public void genFlashDefinitionFile(String file) { + FlashDefinitionFileDocument.FlashDefinitionFile fdf = getfpdFlash().getFlashDefinitionFile(); + if (fdf == null) { + fdf = getfpdFlash().addNewFlashDefinitionFile(); + } + + fdf.setStringValue(file); + } + + public String getFlashDefinitionFile() { + FlashDefinitionFileDocument.FlashDefinitionFile fdf = getfpdFlash().getFlashDefinitionFile(); + if (fdf == null) { + return ""; + } + + return fdf.getStringValue(); + } + + + + public void genFvImagesNameValue(String name, String value) { + + FvImagesDocument.FvImages fi = getfpdFlash().getFvImages(); + if (fi == null) { + fi = getfpdFlash().addNewFvImages(); + } + + FvImagesDocument.FvImages.NameValue nv = fi.addNewNameValue(); + nv.setName(name); + nv.setValue(value); + } + + public void removeFvImagesNameValue(int i){ + + XmlObject o = getfpdFlash().getFvImages(); + if (o == null) { + return; + } + + QName qNameValue = new QName(xmlNs, "NameValue"); + XmlCursor cursor = o.newCursor(); + if (cursor.toChild(qNameValue)) { + for (int j = 0; j < i; ++j) { + cursor.toNextSibling(qNameValue); + } + cursor.removeXml(); + } + cursor.dispose(); + } + + public void updateFvImagesNameValue(int i, String name, String value){ + + XmlObject o = getfpdFlash().getFvImages(); + if (o == null) { + return; + } + + QName qNameValue = new QName(xmlNs, "NameValue"); + XmlCursor cursor = o.newCursor(); + if (cursor.toChild(qNameValue)) { + for (int j = 0; j < i; ++j) { + cursor.toNextSibling(qNameValue); + } + FvImagesDocument.FvImages.NameValue nv = (FvImagesDocument.FvImages.NameValue)cursor.getObject(); + nv.setName(name); + nv.setValue(value); + } + cursor.dispose(); + } + + public int getFvImagesNameValueCount() { + + FvImagesDocument.FvImages fi = null; + if ((fi = getfpdFlash().getFvImages()) == null || fi.getNameValueList() == null) { + return 0; + } + return fi.getNameValueList().size(); + } + + public void getFvImagesNameValues(String[][] nv) { + + FvImagesDocument.FvImages fi = getfpdFlash().getFvImages(); + if (fi == null){ + return; + } + List l = fi.getNameValueList(); + int i = 0; + ListIterator li = l.listIterator(); + while (li.hasNext()) { + FvImagesDocument.FvImages.NameValue e = (FvImagesDocument.FvImages.NameValue) li + .next(); + nv[i][0] = e.getName(); + nv[i][1] = e.getValue(); + + i++; + } + } + + public void genFvImagesFvImage(String[] names, String types, Map options) { + + FvImagesDocument.FvImages fis = null; + if ((fis = getfpdFlash().getFvImages()) == null) { + fis = getfpdFlash().addNewFvImages(); + } + + // + //gen FvImage with FvImageNames array + // + FvImagesDocument.FvImages.FvImage fi = fis.addNewFvImage(); + for (int i = 0; i < names.length; ++i) { + fi.addFvImageNames(names[i]); + } + fi.setType(FvImageTypes.Enum.forString(types)); + if (options != null){ + setFvImagesFvImageFvImageOptions(options, fi); + } + } + + private void setFvImagesFvImageFvImageOptions(Map options, FvImagesDocument.FvImages.FvImage fi){ + FvImagesDocument.FvImages.FvImage.FvImageOptions fio = fi.getFvImageOptions(); + if (fio == null){ + fio = fi.addNewFvImageOptions(); + } + + Set key = options.keySet(); + Iterator i = key.iterator(); + while (i.hasNext()) { + FvImagesDocument.FvImages.FvImage.FvImageOptions.NameValue nv = fio.addNewNameValue(); + String k = (String)i.next(); + nv.setName(k); + nv.setValue((String)options.get(k)); + + } + + } + + public void removeFvImagesFvImage(int i) { + + XmlObject o = getfpdFlash().getFvImages(); + if (o == null) { + return; + } + + QName qFvImage = new QName(xmlNs, "FvImage"); + XmlCursor cursor = o.newCursor(); + if (cursor.toChild(qFvImage)) { + for (int j = 0; j < i; ++j) { + cursor.toNextSibling(qFvImage); + } + cursor.removeXml(); + } + cursor.dispose(); + } + + public void updateFvImagesFvImage(int i, String[] names, String types, Map options){ + + XmlObject o = getfpdFlash().getFvImages(); + if (o == null) { + return; + } + XmlCursor cursor = o.newCursor(); + QName qFvImage = new QName(xmlNs, "FvImage"); + if (cursor.toChild(qFvImage)) { + for (int j = 0; j < i; ++j) { + cursor.toNextSibling(qFvImage); + } + FvImagesDocument.FvImages.FvImage fi = (FvImagesDocument.FvImages.FvImage)cursor.getObject(); + fi.setType(FvImageTypes.Enum.forString(types)); + + // + // remove old FvImageNames before adding new ones + // + QName qFvImageNames = new QName(xmlNs, "FvImageNames"); + cursor.toChild(qFvImageNames); + cursor.removeXml(); + while (cursor.toNextSibling(qFvImageNames)) { + cursor.removeXml(); + } + + for (int k = 0; k < names.length; ++k) { + fi.addFvImageNames(names[k]); + } + // + // remove old FvImageOptions before adding new options + // + QName qFvImageOptions = new QName(xmlNs, "FvImageOptions"); + cursor.toNextSibling(qFvImageOptions); + cursor.removeXml(); + + setFvImagesFvImageFvImageOptions(options, fi); + } + cursor.dispose(); + } + + public int getFvImagesFvImageCount() { + + if (getfpdFlash().getFvImages() == null || getfpdFlash().getFvImages().getFvImageList() == null) { + return 0; + } + return getfpdFlash().getFvImages().getFvImageList().size(); + } + + public void getFvImagesFvImages(String[][] saa, ArrayList> options) { + + if (getfpdFlash().getFvImages() == null) { + return; + } + List l = getfpdFlash().getFvImages().getFvImageList(); + if (l == null) { + return; + } + ListIterator li = l.listIterator(); + int i = 0; + while(li.hasNext()) { + FvImagesDocument.FvImages.FvImage fi = (FvImagesDocument.FvImages.FvImage)li.next(); + // + // get FvImageNames array, space separated + // + List lfn = fi.getFvImageNamesList(); + ListIterator lfni = lfn.listIterator(); + saa[i][0] = " "; + while (lfni.hasNext()) { + saa[i][0] += (String)lfni.next(); + saa[i][0] += " "; + } + saa[i][0] = saa[i][0].trim(); + + saa[i][1] = fi.getType()+""; + + // + // get FvImageOptions into Map[i] + // + FvImagesDocument.FvImages.FvImage.FvImageOptions fo = fi.getFvImageOptions(); + if (fo == null) { + ++i; + continue; + } + List lnv = fo.getNameValueList(); + if (lnv == null || lnv.isEmpty()) { + ++i; + continue; + } + ListIterator lnvi = lnv.listIterator(); + while (lnvi.hasNext()) { + FvImagesDocument.FvImages.FvImage.FvImageOptions.NameValue nv = (FvImagesDocument.FvImages.FvImage.FvImageOptions.NameValue)lnvi.next(); + Map m = options.get(i); + m.put(nv.getName(), nv.getValue()); + } + + ++i; + } + } + + /** + Get platform header element + @return PlatformHeaderDocument.PlatformHeader + **/ + public PlatformHeaderDocument.PlatformHeader getFpdHdr() { + if (fpdHdr == null) { + fpdHdr = fpdRoot.addNewPlatformHeader(); + } + genPlatformDefsSkuInfo("0", "DEFAULT"); + return fpdHdr; + } + + public void genPlatformDefsSkuInfo(String id, String name) { + SkuInfoDocument.SkuInfo skuInfo = null; + if (getfpdPlatformDefs().getSkuInfo() == null) { + skuInfo = getfpdPlatformDefs().addNewSkuInfo(); + } + skuInfo = getfpdPlatformDefs().getSkuInfo(); + if (skuInfo.getUiSkuNameList() == null || skuInfo.getUiSkuNameList().size() == 0) { + SkuInfoDocument.SkuInfo.UiSkuName skuName = skuInfo.addNewUiSkuName(); + skuName.setSkuID(new BigInteger("0")); + skuName.setStringValue("DEFAULT"); + } + if (id.equals("0")) { + return; + } + SkuInfoDocument.SkuInfo.UiSkuName skuName = skuInfo.addNewUiSkuName(); + skuName.setSkuID(new BigInteger(id)); + skuName.setStringValue(name); + + + } + public String getFpdHdrPlatformName() { + return getFpdHdr().getPlatformName(); + } + + public String getFpdHdrGuidValue() { + return getFpdHdr().getGuidValue(); + } + + public String getFpdHdrVer() { + return getFpdHdr().getVersion(); + } + + public String getFpdHdrAbs() { + return getFpdHdr().getAbstract(); + } + + public String getFpdHdrDescription() { + return getFpdHdr().getDescription(); + } + + public String getFpdHdrCopyright() { + return getFpdHdr().getCopyright(); + } + + public String getFpdHdrLicense() { + LicenseDocument.License l = getFpdHdr().getLicense(); + if (l == null) { + return null; + } + return l.getStringValue(); + } + + public String getFpdHdrUrl() { + LicenseDocument.License l = getFpdHdr().getLicense(); + if (l == null) { + return null; + } + return l.getURL(); + } + + public String getFpdHdrSpec() { + + return "FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052"; +// return getFpdHdr().getSpecification(); + } + + public void setFpdHdrPlatformName(String name){ + getFpdHdr().setPlatformName(name); + } + + public void setFpdHdrGuidValue(String guid){ + getFpdHdr().setGuidValue(guid); + } + + public void setFpdHdrVer(String v){ + getFpdHdr().setVersion(v); + } + + public void setFpdHdrAbs(String abs) { + getFpdHdr().setAbstract(abs); + } + + public void setFpdHdrDescription(String desc){ + getFpdHdr().setDescription(desc); + } + + public void setFpdHdrCopyright(String cr) { + getFpdHdr().setCopyright(cr); + } + + public void setFpdHdrLicense(String license){ + LicenseDocument.License l = getFpdHdr().getLicense(); + if (l == null) { + getFpdHdr().addNewLicense().setStringValue(license); + } + else { + l.setStringValue(license); + } + } + + public void setFpdHdrUrl(String url){ + LicenseDocument.License l = getFpdHdr().getLicense(); + + l.setURL(url); + + } + + public void setFpdHdrSpec(String s){ + s = "FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052"; + getFpdHdr().setSpecification(s); + } + /** + Save the processed xml contents to file + + @param fpdFile The file to save xml contents + @throws IOException Exceptions during file operation + **/ + public void saveAs(File fpdFile) throws IOException { + + XmlOptions options = new XmlOptions(); + + options.setCharacterEncoding("UTF-8"); + options.setSavePrettyPrint(); + options.setSavePrettyPrintIndent(2); + try { + fpdd.save(fpdFile, options); + } catch (IOException e) { + e.printStackTrace(); + } + + } + + private String listToString(List l) { + if (l == null) { + return null; + } + String s = " "; + ListIterator li = l.listIterator(); + while(li.hasNext()) { + s += li.next(); + s += " "; + } + return s.trim(); + } +} diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/FpdFlash.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/FpdFlash.java new file mode 100644 index 0000000000..6ad1849220 --- /dev/null +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/FpdFlash.java @@ -0,0 +1,1470 @@ +/** @file + Java class FpdFlash is GUI for Flash element operation in SPD file. + +Copyright (c) 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +**/ +package org.tianocore.frameworkwizard.platform.ui; + +import java.awt.BorderLayout; +import javax.swing.JPanel; + +import javax.swing.AbstractAction; +import javax.swing.ButtonGroup; +import javax.swing.DefaultCellEditor; +import javax.swing.DefaultListModel; +import javax.swing.JDialog; +import javax.swing.JFileChooser; +import javax.swing.JFrame; +import javax.swing.JInternalFrame; +import javax.swing.JOptionPane; +import javax.swing.JTabbedPane; +import javax.swing.JButton; +import javax.swing.ListSelectionModel; + +import org.tianocore.PlatformSurfaceAreaDocument; +import org.tianocore.frameworkwizard.common.Tools; +import org.tianocore.frameworkwizard.common.ui.IInternalFrame; +import org.tianocore.frameworkwizard.common.ui.StarLabel; + + +import java.awt.FlowLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.ComponentAdapter; +import java.awt.event.ComponentEvent; +import java.awt.event.FocusAdapter; +import java.awt.event.FocusEvent; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; +import java.awt.event.ActionEvent; +import java.io.File; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Set; + +import javax.swing.JCheckBox; +import javax.swing.JTextField; +import java.awt.GridLayout; +import javax.swing.JLabel; +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.JList; +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 javax.swing.JComboBox; +import java.awt.Dimension; +import javax.swing.JRadioButton; +import javax.swing.JTextArea; +import java.awt.CardLayout; + +public class FpdFlash extends IInternalFrame { + + static JFrame frame; + private JPanel jContentPane = null; + private JPanel jPanel = null; + private JPanel jPanel1 = null; + private JPanel jPanel2 = null; + private JPanel jPanel3 = null; + private JTabbedPane jTabbedPane = null; + private JPanel jPanelFvImages = null; + private JButton jButtonOk = null; + private JButton jButtonCancel = null; + private JPanel jPanelFvImageN = null; + private JPanel jPanelFvImageW = null; + private JPanel jPanelFvImageS = null; + private JCheckBox jCheckBox1 = null; + private JLabel jLabel = null; + private JTextField jTextField = null; + private JLabel jLabel1 = null; + private JTextField jTextField1 = null; + private JButton jButton = null; + private JScrollPane jScrollPane = null; + private JScrollPane jScrollPane1 = null; + private JTable jTable = null; + private JPanel jPanel4 = null; + private JButton jButton1 = null; + private DefaultTableModel fvPropertyTableModel = null; + private DefaultTableModel fvImageNameTableModel = null; + private ImageParaTableModel fvImageParaTableModel = null; + private JPanel jPanelFvImageC = null; + private JCheckBox jCheckBox2 = null; + private JLabel jLabel2 = null; + private JComboBox jComboBox = null; + private JLabel jLabel3 = null; + private JLabel jLabel4 = null; + private JTextField jTextField2 = null; + private JButton jButton2 = null; + private JScrollPane jScrollPane2 = null; + private JTable jTable1 = null; + private JButton jButton3 = null; + private JPanel jPanel5 = null; + private JButton jButton4 = null; + private JScrollPane jScrollPane3 = null; + private JTable jTable2 = null; + private JButton jButton6 = null; + private JCheckBox jCheckBox3 = null; + private JLabel jLabel5 = null; + private JComboBox jComboBox1 = null; + private JCheckBox jCheckBox4 = null; + private JCheckBox jCheckBox5 = null; + private JCheckBox jCheckBox6 = null; + private JCheckBox jCheckBox7 = null; + private JCheckBox jCheckBox8 = null; + private JCheckBox jCheckBox9 = null; + private JCheckBox jCheckBox10 = null; + private JCheckBox jCheckBox11 = null; + private JCheckBox jCheckBox12 = null; + private JCheckBox jCheckBox13 = null; + private JPanel jPanel6 = null; + private DefaultTableModel fdfImageDefTableModel = null; + private DefaultTableModel fdfBlocksTableModel = null; + private DefaultTableModel fdfRegionsTableModel = null; + private DefaultTableModel fdfSubRegionsTableModel = null; + + private JLabel jLabel17 = null; + private DefaultListModel listModel = new DefaultListModel(); + private FpdFileContents ffc = null; + private JPanel jPanel7 = null; + private JCheckBox jCheckBox = null; + private JTextField jTextField3 = null; + private JButton jButton5 = null; + + public FpdFlash() { + super(); + // TODO Auto-generated constructor stub + + initialize(); + this.setBounds(new java.awt.Rectangle(0, 0, 500, 370)); + this.setVisible(true); + } + + public FpdFlash(PlatformSurfaceAreaDocument.PlatformSurfaceArea fpd){ + this(); + ffc = new FpdFileContents(fpd); + init(ffc); + } + + /** + * 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) { + FlowLayout flowLayout = new FlowLayout(); + flowLayout.setAlignment(java.awt.FlowLayout.RIGHT); + flowLayout.setHgap(15); + jPanel1 = new JPanel(); + jPanel1.setLayout(flowLayout); + jPanel1.setComponentOrientation(java.awt.ComponentOrientation.LEFT_TO_RIGHT); + jPanel1.add(getJButtonCancel(), null); + jPanel1.add(getJButtonOk(), 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 jPanel3 + * + * @return javax.swing.JPanel + */ + private JPanel getJPanel3() { + if (jPanel3 == null) { + jPanel3 = new JPanel(); + } + return jPanel3; + } + + /** + * This method initializes jTabbedPane + * + * @return javax.swing.JTabbedPane + */ + private JTabbedPane getJTabbedPane() { + if (jTabbedPane == null) { + jTabbedPane = new JTabbedPane(); + jTabbedPane.addTab("FV Images", null, getJPanelFvImages(), null); + jTabbedPane.addTab("Flash Definition File", null, getJPanel7(), null); + + } + return jTabbedPane; + } + + /** + * This method initializes jPanelFvImages + * + * @return javax.swing.JPanel + */ + private JPanel getJPanelFvImages() { + if (jPanelFvImages == null) { + jPanelFvImages = new JPanel(); + jPanelFvImages.setLayout(new BorderLayout()); + jPanelFvImages.add(getJPanelFvImageN(), java.awt.BorderLayout.NORTH); +// jPanelFvImages.add(getJPanelFvImageW(), java.awt.BorderLayout.WEST); + jPanelFvImages.add(getJPanelFvImageS(), java.awt.BorderLayout.SOUTH); + jPanelFvImages.add(getJPanelFvImageC(), java.awt.BorderLayout.CENTER); + + } + return jPanelFvImages; + } + + /** + * This method initializes jButtonOk + * + * @return javax.swing.JButton + */ + private JButton getJButtonOk() { + if (jButtonOk == null) { + jButtonOk = new JButton(); + jButtonOk.setPreferredSize(new java.awt.Dimension(80,20)); + jButtonOk.setText("Cancel"); + jButtonOk.setVisible(false); + } + return jButtonOk; + } + + /** + * This method initializes jButtonCancel + * + * @return javax.swing.JButton + */ + private JButton getJButtonCancel() { + if (jButtonCancel == null) { + jButtonCancel = new JButton(); + jButtonCancel.setPreferredSize(new java.awt.Dimension(80,20)); + jButtonCancel.setText("Ok"); + jButtonCancel.setVisible(false); + } + return jButtonCancel; + } + + /** + * This method initializes jPanelFvImageN + * + * @return javax.swing.JPanel + */ + private JPanel getJPanelFvImageN() { + if (jPanelFvImageN == null) { + jLabel1 = new JLabel(); + jLabel1.setText("Value"); + jLabel1.setEnabled(false); + jLabel1.setPreferredSize(new java.awt.Dimension(38,20)); + jLabel = new JLabel(); + jLabel.setText("Name"); + jLabel.setEnabled(false); + jLabel.setPreferredSize(new java.awt.Dimension(38,20)); + FlowLayout flowLayout2 = new FlowLayout(); + flowLayout2.setAlignment(java.awt.FlowLayout.CENTER); + flowLayout2.setHgap(15); + jPanelFvImageN = new JPanel(); + jPanelFvImageN.setPreferredSize(new java.awt.Dimension(576,100)); + jPanelFvImageN.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED)); + jPanelFvImageN.setLayout(flowLayout2); + jPanelFvImageN.add(getJCheckBox1(), null); + jPanelFvImageN.add(jLabel, null); + jPanelFvImageN.add(getJTextField(), null); + jPanelFvImageN.add(jLabel1, null); + jPanelFvImageN.add(getJTextField1(), null); + jPanelFvImageN.add(getJScrollPane1(), null); + jPanelFvImageN.add(getJPanel4(), null); + } + return jPanelFvImageN; + } + + + /** + * This method initializes jPanelFvImageW + * + * @return javax.swing.JPanel + */ + private JPanel getJPanelFvImageW() { + if (jPanelFvImageW == null) { + jPanelFvImageW = new JPanel(); + jPanelFvImageW.setPreferredSize(new java.awt.Dimension(10,2)); + } + return jPanelFvImageW; + } + + + /** + * This method initializes jPanelFvImageS + * + * @return javax.swing.JPanel + */ + private JPanel getJPanelFvImageS() { + if (jPanelFvImageS == null) { + GridLayout gridLayout2 = new GridLayout(); + gridLayout2.setRows(1); + jPanelFvImageS = new JPanel(); + jPanelFvImageS.setPreferredSize(new java.awt.Dimension(480,200)); + jPanelFvImageS.setLayout(gridLayout2); + jPanelFvImageS.add(getJScrollPane3(), null); + } + return jPanelFvImageS; + } + + + /** + * This method initializes jCheckBox1 + * + * @return javax.swing.JCheckBox + */ + private JCheckBox getJCheckBox1() { + if (jCheckBox1 == null) { + jCheckBox1 = new JCheckBox(); + jCheckBox1.setText("FV Properties"); + jCheckBox1.addItemListener(new ItemListener(){ + + public void itemStateChanged(ItemEvent arg0) { + // TODO Auto-generated method stub + boolean seleted = jCheckBox1.isSelected(); + + jLabel.setEnabled(seleted); + jTextField.setEnabled(seleted); + jLabel1.setEnabled(seleted); + jTextField1.setEnabled(seleted); + jTable.setEnabled(seleted); + jButton.setEnabled(seleted); + jButton1.setEnabled(seleted); + + + } + + }); + } + return jCheckBox1; + } + + + /** + * This method initializes jTextField + * + * @return javax.swing.JTextField + */ + private JTextField getJTextField() { + if (jTextField == null) { + jTextField = new JTextField(); + jTextField.setPreferredSize(new java.awt.Dimension(100,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(100,20)); + jTextField1.setEnabled(false); + } + return jTextField1; + } + + + /** + * 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.setEnabled(false); + jButton.setText("Add"); + jButton.addActionListener(new AbstractAction() { + public void actionPerformed(ActionEvent e) { + if (jTextField.getText().length() > 0 && jTextField1.getText().length() > 0){ + String[] row = {jTextField.getText(), jTextField1.getText()}; + fvPropertyTableModel.addRow(row); + ffc.genFvImagesNameValue(row[0], row[1]); + } + } + }); + } + return jButton; + } + + + /** + * This method initializes jScrollPane1 + * + * @return javax.swing.JScrollPane + */ + private JScrollPane getJScrollPane1() { + if (jScrollPane1 == null) { + jScrollPane1 = new JScrollPane(); + jScrollPane1.setPreferredSize(new java.awt.Dimension(350,55)); + jScrollPane1.setViewportView(getJTable()); + } + return jScrollPane1; + } + + + /** + * This method initializes jTable + * + * @return javax.swing.JTable + */ + private JTable getJTable() { + if (jTable == null) { + fvPropertyTableModel = new DefaultTableModel(); + jTable = new JTable(fvPropertyTableModel); + fvPropertyTableModel.addColumn("Name"); + fvPropertyTableModel.addColumn("Value"); + jTable.setRowHeight(20); + jTable.setEnabled(false); + + 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(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.UPDATE){ + + String name = m.getValueAt(row, 0) + ""; + String value = m.getValueAt(row, 1) + ""; + + ffc.updateFvImagesNameValue(row, name, value); + } + } + }); + } + return jTable; + } + + + /** + * This method initializes jPanel4 + * + * @return javax.swing.JPanel + */ + private JPanel getJPanel4() { + if (jPanel4 == null) { + jPanel4 = new JPanel(); + jPanel4.setPreferredSize(new java.awt.Dimension(80,55)); + + jPanel4.add(getJButton(), null); + jPanel4.add(getJButton1(), null); + } + return jPanel4; + } + + + /** + * 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.setEnabled(false); + jButton1.setText("Delete"); + jButton1.addActionListener(new AbstractAction() { + public void actionPerformed(ActionEvent e) { + if (jTable.getSelectedRow() >= 0){ + fvPropertyTableModel.removeRow(jTable.getSelectedRow()); + ffc.removeFvImagesNameValue(jTable.getSelectedRow()); + } + } + }); + } + return jButton1; + } + + + /** + * This method initializes jPanelFvImageC + * + * @return javax.swing.JPanel + */ + private JPanel getJPanelFvImageC() { + if (jPanelFvImageC == null) { + jLabel4 = new JLabel(); + jLabel4.setPreferredSize(new Dimension(38, 20)); + jLabel4.setEnabled(false); + jLabel4.setText("Name"); + jLabel3 = new JLabel(); + jLabel3.setText("FV Image Names"); + jLabel3.setEnabled(false); + jLabel3.setPreferredSize(new java.awt.Dimension(150,20)); + jLabel2 = new JLabel(); + jLabel2.setText("Type"); + jLabel2.setEnabled(false); + jLabel2.setPreferredSize(new java.awt.Dimension(70,20)); + FlowLayout flowLayout3 = new FlowLayout(); + flowLayout3.setAlignment(java.awt.FlowLayout.LEFT); + flowLayout3.setHgap(5); + jPanelFvImageC = new JPanel(); + jPanelFvImageC.setLayout(flowLayout3); + jPanelFvImageC.add(getJPanel6(), null); + + jPanelFvImageC.add(getJPanel5(), null); + + } + return jPanelFvImageC; + } + + + /** + * This method initializes jCheckBox2 + * + * @return javax.swing.JCheckBox + */ + private JCheckBox getJCheckBox2() { + if (jCheckBox2 == null) { + jCheckBox2 = new JCheckBox(); + jCheckBox2.setText("FV Image Parameters"); + jCheckBox2.setPreferredSize(new java.awt.Dimension(200,20)); + jCheckBox2.addItemListener(new ItemListener(){ + + public void itemStateChanged(ItemEvent arg0) { + // TODO Auto-generated method stub + boolean seleted = jCheckBox2.isSelected(); + + jLabel2.setEnabled(seleted); + jLabel3.setEnabled(seleted); + jLabel4.setEnabled(seleted); + jComboBox.setEnabled(seleted); + jTextField2.setEnabled(seleted); + + jTable1.setEnabled(seleted); + jButton2.setEnabled(seleted); + jButton3.setEnabled(seleted); + + + } + + }); + } + return jCheckBox2; + } + + + /** + * This method initializes jComboBox + * + * @return javax.swing.JComboBox + */ + private JComboBox getJComboBox() { + if (jComboBox == null) { + jComboBox = new JComboBox(); + jComboBox.addItem("ImageName"); + jComboBox.addItem("Attributes"); + jComboBox.addItem("Options"); + jComboBox.addItem("Components"); + jComboBox.setPreferredSize(new java.awt.Dimension(180,20)); + jComboBox.setEnabled(false); + jComboBox.addItemListener(new ItemListener() { + + public void itemStateChanged(ItemEvent arg0) { + // TODO disable attribute settings when ValidImageNames selected. + + } + + }); + } + return jComboBox; + } + + + /** + * This method initializes jTextField2 + * + * @return javax.swing.JTextField + */ + private JTextField getJTextField2() { + if (jTextField2 == null) { + jTextField2 = new JTextField(); + jTextField2.setPreferredSize(new java.awt.Dimension(140,20)); + jTextField2.setEnabled(false); + } + return jTextField2; + } + + + /** + * This method initializes jButton2 + * + * @return javax.swing.JButton + */ + private JButton getJButton2() { + if (jButton2 == null) { + jButton2 = new JButton(); + jButton2.setPreferredSize(new Dimension(80, 20)); + jButton2.setEnabled(false); + jButton2.setText("Add"); + jButton2.addActionListener(new AbstractAction() { + public void actionPerformed(java.awt.event.ActionEvent e) { + if (jTextField2.getText().length() > 0){ + String[] row = {jTextField2.getText()}; + fvImageNameTableModel.addRow(row); + } + } + }); + } + return jButton2; + } + + + /** + * This method initializes jScrollPane2 + * + * @return javax.swing.JScrollPane + */ + private JScrollPane getJScrollPane2() { + if (jScrollPane2 == null) { + jScrollPane2 = new JScrollPane(); + jScrollPane2.setPreferredSize(new java.awt.Dimension(350,50)); + jScrollPane2.setViewportView(getJTable1()); + } + return jScrollPane2; + } + + + /** + * This method initializes jTable1 + * + * @return javax.swing.JTable + */ + private JTable getJTable1() { + if (jTable1 == null) { + fvImageNameTableModel = new DefaultTableModel(); + jTable1 = new JTable(fvImageNameTableModel); + jTable1.setEnabled(false); + fvImageNameTableModel.addColumn("FV Image Name"); + } + return jTable1; + } + + + /** + * This method initializes jButton3 + * + * @return javax.swing.JButton + */ + private JButton getJButton3() { + if (jButton3 == null) { + jButton3 = new JButton(); + jButton3.setPreferredSize(new Dimension(80, 20)); + jButton3.setEnabled(false); + jButton3.setText("Delete"); + jButton3.addActionListener(new AbstractAction() { + public void actionPerformed(java.awt.event.ActionEvent e) { + if (jTable1.getSelectedRow() >= 0){ + + fvImageNameTableModel.removeRow(jTable1.getSelectedRow()); + } + } + }); + } + return jButton3; + } + + + + + private JPanel getJPanel5() { + + + if (jPanel5 == null) { + //ToDo add ButtonGroup for RadioButtons + jPanel5 = new JPanel(); + jPanel5.setPreferredSize(new java.awt.Dimension(480,120)); + + GridLayout gridLayout = new GridLayout(); + gridLayout.setRows(5); + gridLayout.setColumns(3); + jPanel5.setLayout(gridLayout); + jPanel5.add(getJCheckBox3(), null); + + jLabel5 = new JLabel(); + jLabel5.setText("EFI_ERASE_POLARITY"); + jLabel5.setEnabled(false); + jPanel5.add(jLabel5, null); + jPanel5.add(getJComboBox1(), null); + jPanel5.add(getJCheckBox4(), null); + jPanel5.add(getJCheckBox5(), null); + jPanel5.add(getJCheckBox6(), null); + jPanel5.add(getJCheckBox7(), null); + jPanel5.add(getJCheckBox8(), null); + jPanel5.add(getJCheckBox9(), null); + jPanel5.add(getJCheckBox10(), null); + jPanel5.add(getJCheckBox11(), null); + jPanel5.add(getJCheckBox12(), null); + jPanel5.add(getJCheckBox13(), null); + jPanel5.add(getJButton4(), null); + jPanel5.setBorder(javax.swing.BorderFactory.createEtchedBorder(javax.swing.border.EtchedBorder.LOWERED)); + jPanel5.add(getJButton6(), null); + + + + + + } + return jPanel5; + } + + + /** + * This method initializes jButton4 + * + * @return javax.swing.JButton + */ + private JButton getJButton4() { + if (jButton4 == null) { + jButton4 = new JButton(); + jButton4.setPreferredSize(new java.awt.Dimension(80,20)); +// jButton4.setEnabled(false); + jButton4.setText("Add FV Image"); + jButton4.addActionListener(new AbstractAction() { + public void actionPerformed(java.awt.event.ActionEvent e) { + if (jTable1.getRowCount()== 0){ + return; + } + String imageName = " "; + for (int i = 0; i < jTable1.getRowCount(); ++i){ + imageName += (String)jTable1.getValueAt(i, 0); + imageName += " "; + } + imageName = imageName.trim(); + + if (!jCheckBox3.isSelected() && jComboBox.getSelectedIndex() != 0){ + return; + + } + + LinkedHashMap m = new LinkedHashMap(); + boolean[] boolArray = {jComboBox1.getSelectedIndex()==0 ? true: false, jCheckBox6.isSelected(), jCheckBox9.isSelected(), + jCheckBox11.isSelected(), jCheckBox12.isSelected(), + jCheckBox13.isSelected(),jCheckBox4.isSelected(), + jCheckBox5.isSelected(), jCheckBox7.isSelected(), + jCheckBox8.isSelected(),jCheckBox10.isSelected()}; + booleanToNameValue(boolArray, m); + ffc.genFvImagesFvImage(imageName.split(" "), jComboBox.getSelectedItem()+"", m); + + Object[] o = {imageName, jComboBox.getSelectedItem(), jComboBox1.getSelectedIndex()==0 ? true: false, + jCheckBox6.isSelected(), jCheckBox9.isSelected(), + jCheckBox11.isSelected(), jCheckBox12.isSelected(), + jCheckBox13.isSelected(),jCheckBox4.isSelected(), + jCheckBox5.isSelected(), jCheckBox7.isSelected(), + jCheckBox8.isSelected(),jCheckBox10.isSelected()}; + fvImageParaTableModel.addRow(o); + } + }); + } + return jButton4; + } + + + /** + * This method initializes jScrollPane3 + * + * @return javax.swing.JScrollPane + */ + private JScrollPane getJScrollPane3() { + if (jScrollPane3 == null) { + jScrollPane3 = new JScrollPane(); + jScrollPane3.setPreferredSize(new java.awt.Dimension(480,150)); + jScrollPane3.setViewportView(getJTable2()); + } + return jScrollPane3; + } + + + /** + * This method initializes jTable2 + * + * @return javax.swing.JTable + */ + private JTable getJTable2() { + if (jTable2 == null) { + fvImageParaTableModel = new ImageParaTableModel(); + jTable2 = new JTable(fvImageParaTableModel); + jTable2.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_OFF); + fvImageParaTableModel.addColumn("FvImageNames"); + fvImageParaTableModel.addColumn("Type"); + fvImageParaTableModel.addColumn("ErasePolarity"); + fvImageParaTableModel.addColumn("ReadStatus"); + fvImageParaTableModel.addColumn("WriteStatus"); + fvImageParaTableModel.addColumn("LockStatus"); + fvImageParaTableModel.addColumn("MemoryMapped"); + fvImageParaTableModel.addColumn("StickyWrite"); + fvImageParaTableModel.addColumn("ReadDisableCap"); + fvImageParaTableModel.addColumn("ReadEnableCap"); + fvImageParaTableModel.addColumn("WriteDisableCap"); + fvImageParaTableModel.addColumn("WriteEnableCap"); + fvImageParaTableModel.addColumn("LockCap"); + + TableColumn typeCol = jTable2.getColumnModel().getColumn(1); + JComboBox cb = new JComboBox(); + cb.addItem("ValidImageNames"); + cb.addItem("Attributes"); + cb.addItem("Options"); + cb.addItem("Components"); + typeCol.setCellEditor(new DefaultCellEditor(cb)); + +// TableColumn epCol = jTable2.getColumnModel().getColumn(2); +// JComboBox cb1 = new JComboBox(); +// cb1.addItem("1"); +// cb1.addItem("0"); +// epCol.setCellEditor(new DefaultCellEditor(cb1)); + 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{ +// selectedRow = lsm.getMinSelectionIndex(); + } + } + }); + + jTable2.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.UPDATE){ + //ToDo Check data validity before update + String name = m.getValueAt(row, 0) + ""; + String type = m.getValueAt(row, 1) + ""; + boolean[] boolArray = new boolean[11]; + for (int i = 2; i < 13; ++i) { + boolArray[i-2] = (Boolean)m.getValueAt(row, i); + } + LinkedHashMap lhm = new LinkedHashMap(); + booleanToNameValue(boolArray, lhm); + + ffc.updateFvImagesFvImage(row, name.split(" "), type, lhm); + } + } + }); + } + return jTable2; + } + + + /** + * This method initializes jButton6 + * + * @return javax.swing.JButton + */ + private JButton getJButton6() { + if (jButton6 == null) { + jButton6 = new JButton(); + jButton6.setPreferredSize(new java.awt.Dimension(150,20)); +// jButton6.setEnabled(false); + jButton6.setText("Delete Row"); + jButton6.addActionListener(new AbstractAction() { + + public void actionPerformed(ActionEvent arg0) { + // TODO Auto-generated method stub + if (jTable2.getSelectedRow() >= 0 ) { + fvImageParaTableModel.removeRow(jTable2.getSelectedRow()); + ffc.removeFvImagesFvImage(jTable2.getSelectedRow()); + } + } + + }); + } + return jButton6; + } + + + /** + * This method initializes jCheckBox3 + * + * @return javax.swing.JCheckBox + */ + private JCheckBox getJCheckBox3() { + if (jCheckBox3 == null) { + jCheckBox3 = new JCheckBox(); + jCheckBox3.setText("FV Image Options"); + jCheckBox3.addItemListener(new ItemListener(){ + + public void itemStateChanged(ItemEvent arg0) { + // TODO Auto-generated method stub + boolean seleted = jCheckBox3.isSelected(); + + if (!jCheckBox2.isSelected() || jComboBox.getSelectedIndex() == 0) { + return; + } + + jLabel5.setEnabled(seleted); + jComboBox1.setEnabled(seleted); + + jCheckBox4.setEnabled(seleted); + jCheckBox5.setEnabled(seleted); + jCheckBox6.setEnabled(seleted); + jCheckBox7.setEnabled(seleted); + jCheckBox8.setEnabled(seleted); + jCheckBox9.setEnabled(seleted); + jCheckBox10.setEnabled(seleted); + jCheckBox11.setEnabled(seleted); + jCheckBox12.setEnabled(seleted); + jCheckBox13.setEnabled(seleted); +// jButton4.setEnabled(seleted); +// jButton6.setEnabled(seleted); + } + + }); + } + return jCheckBox3; + } + + + /** + * This method initializes jComboBox1 + * + * @return javax.swing.JComboBox + */ + private JComboBox getJComboBox1() { + if (jComboBox1 == null) { + jComboBox1 = new JComboBox(); + jComboBox1.setPreferredSize(new java.awt.Dimension(20,20)); + jComboBox1.setEnabled(false); + jComboBox1.addItem("1"); + jComboBox1.addItem("0"); + jComboBox1.setSelectedIndex(0); + } + return jComboBox1; + } + + + /** + * This method initializes jCheckBox4 + * + * @return javax.swing.JCheckBox + */ + private JCheckBox getJCheckBox4() { + if (jCheckBox4 == null) { + jCheckBox4 = new JCheckBox(); + jCheckBox4.setText("Read Disable CAP"); + jCheckBox4.setEnabled(false); + } + return jCheckBox4; + } + + + /** + * This method initializes jCheckBox5 + * + * @return javax.swing.JCheckBox + */ + private JCheckBox getJCheckBox5() { + if (jCheckBox5 == null) { + jCheckBox5 = new JCheckBox(); + jCheckBox5.setText("Read Enable CAP"); + jCheckBox5.setEnabled(false); + } + return jCheckBox5; + } + + + /** + * This method initializes jCheckBox6 + * + * @return javax.swing.JCheckBox + */ + private JCheckBox getJCheckBox6() { + if (jCheckBox6 == null) { + jCheckBox6 = new JCheckBox(); + jCheckBox6.setText("Read Status"); + jCheckBox6.setEnabled(false); + } + return jCheckBox6; + } + + + /** + * This method initializes jCheckBox7 + * + * @return javax.swing.JCheckBox + */ + private JCheckBox getJCheckBox7() { + if (jCheckBox7 == null) { + jCheckBox7 = new JCheckBox(); + jCheckBox7.setText("Write Disable CAP"); + jCheckBox7.setEnabled(false); + } + return jCheckBox7; + } + + + /** + * This method initializes jCheckBox8 + * + * @return javax.swing.JCheckBox + */ + private JCheckBox getJCheckBox8() { + if (jCheckBox8 == null) { + jCheckBox8 = new JCheckBox(); + jCheckBox8.setText("Write Enable CAP"); + jCheckBox8.setEnabled(false); + } + return jCheckBox8; + } + + + /** + * This method initializes jCheckBox9 + * + * @return javax.swing.JCheckBox + */ + private JCheckBox getJCheckBox9() { + if (jCheckBox9 == null) { + jCheckBox9 = new JCheckBox(); + jCheckBox9.setText("Write Status"); + jCheckBox9.setEnabled(false); + } + return jCheckBox9; + } + + + /** + * This method initializes jCheckBox10 + * + * @return javax.swing.JCheckBox + */ + private JCheckBox getJCheckBox10() { + if (jCheckBox10 == null) { + jCheckBox10 = new JCheckBox(); + jCheckBox10.setText("Lock CAP"); + jCheckBox10.setEnabled(false); + } + return jCheckBox10; + } + + + /** + * This method initializes jCheckBox11 + * + * @return javax.swing.JCheckBox + */ + private JCheckBox getJCheckBox11() { + if (jCheckBox11 == null) { + jCheckBox11 = new JCheckBox(); + jCheckBox11.setText("Lock Status"); + jCheckBox11.setEnabled(false); + } + return jCheckBox11; + } + + + /** + * This method initializes jCheckBox12 + * + * @return javax.swing.JCheckBox + */ + private JCheckBox getJCheckBox12() { + if (jCheckBox12 == null) { + jCheckBox12 = new JCheckBox(); + jCheckBox12.setText("Memory Mapped"); + jCheckBox12.setEnabled(false); + } + return jCheckBox12; + } + + + /** + * This method initializes jCheckBox13 + * + * @return javax.swing.JCheckBox + */ + private JCheckBox getJCheckBox13() { + if (jCheckBox13 == null) { + jCheckBox13 = new JCheckBox(); + jCheckBox13.setText("Sticky Write"); + jCheckBox13.setEnabled(false); + } + return jCheckBox13; + } + + + /** + * This method initializes jPanel6 + * + * @return javax.swing.JPanel + */ + private JPanel getJPanel6() { + if (jPanel6 == null) { + StarLabel starLabel = new StarLabel(); + starLabel.setVisible(false); + jPanel6 = new JPanel(); + jPanel6.setPreferredSize(new java.awt.Dimension(480,120)); + jPanel6.setBorder(javax.swing.BorderFactory.createEtchedBorder(javax.swing.border.EtchedBorder.RAISED)); + jPanel6.add(getJCheckBox2(), null); + jPanel6.add(jLabel2, null); + jPanel6.add(getJComboBox(), null); + jPanel6.add(new StarLabel(), null); + jPanel6.add(jLabel3, null); + jPanel6.add(jLabel4, null); + jPanel6.add(getJTextField2(), null); + jPanel6.add(getJButton2(), null); + jPanel6.add(getJScrollPane2(), null); + jPanel6.add(getJButton3(), null); + } + return jPanel6; + } + + /** + * This method initializes jPanel7 + * + * @return javax.swing.JPanel + */ + private JPanel getJPanel7() { + if (jPanel7 == null) { + FlowLayout flowLayout1 = new FlowLayout(); + flowLayout1.setAlignment(FlowLayout.LEFT); + jPanel7 = new JPanel(); + jPanel7.setLayout(flowLayout1); + jPanel7.add(getJCheckBox(), null); + jPanel7.add(getJTextField3(), null); + jPanel7.add(getJButton5(), null); + jPanel7.addComponentListener(new ComponentAdapter(){ + public void componentShown(ComponentEvent e) { + if (ffc.getFlashDefinitionFile() != null) { + jTextField3.setText(ffc.getFlashDefinitionFile()); + } + } + public void componentHidden(ComponentEvent e) { + if (jCheckBox.isSelected()) { + ffc.genFlashDefinitionFile(jTextField3.getText()); + } + } + }); + } + return jPanel7; + } + + /** + * This method initializes jCheckBox + * + * @return javax.swing.JCheckBox + */ + private JCheckBox getJCheckBox() { + if (jCheckBox == null) { + jCheckBox = new JCheckBox(); + jCheckBox.setText("Flash Definition File"); + jCheckBox.addItemListener(new ItemListener() { + + public void itemStateChanged(ItemEvent arg0) { + // TODO Auto-generated method stub + if (jCheckBox.isSelected()){ + jTextField3.setEnabled(true); + jButton5.setEnabled(true); + } + else { + + jTextField3.setEnabled(false); + jButton5.setEnabled(false); + } + } + }); + } + return jCheckBox; + } + + /** + * This method initializes jTextField3 + * + * @return javax.swing.JTextField + */ + private JTextField getJTextField3() { + if (jTextField3 == null) { + jTextField3 = new JTextField(); + jTextField3.setEnabled(false); + jTextField3.setPreferredSize(new Dimension(300, 20)); + } + return jTextField3; + } + + /** + * This method initializes jButton5 + * + * @return javax.swing.JButton + */ + private JButton getJButton5() { + if (jButton5 == null) { + jButton5 = new JButton(); + jButton5.setEnabled(false); + jButton5.setText("Browse"); + jButton5.setPreferredSize(new Dimension(78, 20)); + jButton5.addActionListener(new AbstractAction(){ + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + JFileChooser chooser = new JFileChooser(); + chooser.setMultiSelectionEnabled(false); + chooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES); + int retval = chooser.showOpenDialog(frame); + if (retval == JFileChooser.APPROVE_OPTION) { + + File theFile = chooser.getSelectedFile(); + jTextField3.setText(theFile.getPath()); + } + } + + }); + } + return jButton5; + } + + /** + * @param args + */ + public static void main(String[] args) { + // TODO Auto-generated method stub + new FpdFlash().setVisible(true); + } + + /** + * This method initializes this + * + * @return void + */ + private void initialize() { + this.setSize(518, 650); + this.setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); + this.setContentPane(getJContentPane()); + this.setTitle("FPD Flash Definitions"); + } + + private void init(FpdFileContents ffc) { + if (ffc.getFvImagesFvImageCount() == 0) { + return; + } + String[][] saa = new String[ffc.getFvImagesFvImageCount()][2]; + ArrayList> options = new ArrayList>(ffc.getFvImagesFvImageCount()); + + for (int j = 0; j < ffc.getFvImagesFvImageCount(); ++j){ + options.add(new LinkedHashMap()); + } + ffc.getFvImagesFvImages(saa, options); + + Object[] rowData = new Object[13]; + int i = 0; + Boolean f = new Boolean("false"); + while (i < saa.length) { + rowData[0] = saa[i][0]; + rowData[1] = saa[i][1]; + + + //ToDo: add alignment settings + Boolean[] boolArray = new Boolean[11]; + int k = 0; + while (k < 11){ + boolArray[k] = f; + ++k; + } + namevalueToBoolean(options.get(i), boolArray); + for (k = 2; k < 13; ++k) { + rowData[k] = boolArray[k-2]; + } + fvImageParaTableModel.addRow(rowData); + ++i; + } + } + + private void namevalueToBoolean(Map m, Boolean[] boolArray){ + Set key = m.keySet(); + Iterator ki= key.iterator(); + Boolean t = new Boolean("true"); + while(ki.hasNext()) { + String k = ki.next(); + if (k.equals("EFI_ERASE_POLARITY") && m.get(k).equals("1")) { + boolArray[0] = t; + } + if (k.equals("EFI_READ_STATUS") && m.get(k).equals("1")) { + boolArray[1] = t; + } + if (k.equals("EFI_WRITE_STATUS") && m.get(k).equals("1")) { + boolArray[2] = t; + } + if (k.equals("EFI_LOCK_STATUS") && m.get(k).equals("1")) { + boolArray[3] = t; + } + if (k.equals("EFI_MEMORY_MAPPED") && m.get(k).equals("1")) { + boolArray[4] = t; + } + if (k.equals("EFI_STICKY_WRITE") && m.get(k).equals("1")) { + boolArray[5] = t; + } + if (k.equals("EFI_READ_DISABLED_CAP") && m.get(k).equals("1")) { + boolArray[6] = t; + } + if (k.equals("EFI_READ_ENABLED_CAP") && m.get(k).equals("1")) { + boolArray[7] = t; + } + if (k.equals("EFI_WRITE_DISABLED_CAP") && m.get(k).equals("1")) { + boolArray[8] = t; + } + if (k.equals("EFI_WRITE_ENABLED_CAP") && m.get(k).equals("1")) { + boolArray[9] = t; + } + if (k.equals("EFI_LOCK_CAP") && m.get(k).equals("1")) { + boolArray[10] = t; + } + } + } + + private void booleanToNameValue(boolean[] boolArray, Map m){ + if (boolArray[0]) { + m.put("EFI_ERASE_POLARITY", "1"); + } + else { + m.put("EFI_ERASE_POLARITY", "0"); + } + if (boolArray[1]) { + m.put("EFI_READ_STATUS", "1"); + } + else { + m.put("EFI_READ_STATUS", "0"); + } + if (boolArray[2]) { + m.put("EFI_WRITE_STATUS", "1"); + } + else { + m.put("EFI_WRITE_STATUS", "0"); + } + if (boolArray[3]) { + m.put("EFI_LOCK_STATUS", "1"); + } + else { + m.put("EFI_LOCK_STATUS", "0"); + } + if (boolArray[4]) { + m.put("EFI_MEMORY_MAPPED", "1"); + } + else { + m.put("EFI_MEMORY_MAPPED", "0"); + } + if (boolArray[5]) { + m.put("EFI_STICKY_WRITE", "1"); + } + else { + m.put("EFI_STICKY_WRITE", "0"); + } + if (boolArray[6]) { + m.put("EFI_READ_DISABLED_CAP", "1"); + } + else { + m.put("EFI_READ_DISABLED_CAP", "0"); + } + if (boolArray[7]) { + m.put("EFI_READ_ENABLED_CAP", "1"); + } + else { + m.put("EFI_READ_ENABLED_CAP", "0"); + } + if (boolArray[8]) { + m.put("EFI_WRITE_DISABLED_CAP", "1"); + } + else { + m.put("EFI_WRITE_DISABLED_CAP", "0"); + } + if (boolArray[9]) { + m.put("EFI_WRITE_ENABLED_CAP", "1"); + } + else { + m.put("EFI_WRITE_ENABLED_CAP", "0"); + } + if (boolArray[10]) { + m.put("EFI_LOCK_CAP", "1"); + } + else { + m.put("EFI_LOCK_CAP", "0"); + } + } + /** + * 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.SOUTH); + jContentPane.add(getJPanel2(), java.awt.BorderLayout.WEST); + jContentPane.add(getJPanel3(), java.awt.BorderLayout.NORTH); + jContentPane.add(getJTabbedPane(), java.awt.BorderLayout.CENTER); + } + return jContentPane; + } + +} // @jve:decl-index=0:visual-constraint="10,10" + +class ImageParaTableModel extends DefaultTableModel { + + public Class getColumnClass (int c) { + return getValueAt(0, c).getClass(); + } +} diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/FpdFrameworkModules.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/FpdFrameworkModules.java new file mode 100644 index 0000000000..f9abe9d017 --- /dev/null +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/FpdFrameworkModules.java @@ -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 fpdMsa = null; + + private ArrayList 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(); + } + + 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(); + } + Set 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 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 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 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; + } +} diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/FpdHeader.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/FpdHeader.java new file mode 100644 index 0000000000..dae88584a4 --- /dev/null +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/FpdHeader.java @@ -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); + } +} diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/FpdModuleSA.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/FpdModuleSA.java new file mode 100644 index 0000000000..5cf0c6dbea --- /dev/null +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/FpdModuleSA.java @@ -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 instancePreferMap = null; + private HashMap> classInstanceMap = null; + private ArrayList classProduced = null; +// private ArrayList classConsumed = null; + private HashMap> 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 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>(); + } + + for(int i = 0; i < classConsumed.length; ++i){ + ArrayList consumedBy = this.classConsumed.get(classConsumed[i]); + if (consumedBy == null) { + consumedBy = new ArrayList(); + } + consumedBy.add(key); + this.classConsumed.put(classConsumed[i], consumedBy); + } + + String[] classProduced = SurfaceAreaQuery.getLibraryClasses("ALWAYS_PRODUCED"); + if (this.classProduced == null) { + this.classProduced = new ArrayList(); + } + for(int i = 0; i < classProduced.length; ++i){ + if (!this.classProduced.contains(classProduced[i])){ + this.classProduced.add(classProduced[i]); + } + } + // + // Get classes unresolved + // +// Iterator 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>(); + } + Iterator lic = this.classConsumed.keySet().iterator(); + while(lic.hasNext()){ + String cls = lic.next(); + if (this.classProduced.contains(cls) || classInstanceMap.containsKey(cls)) { + continue; + } + ArrayList 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 getInstancesForClass(String cls, PackageIdentification[] depPkgList) throws Exception{ + ArrayList al = new ArrayList(); + + for (int i = 0; i < depPkgList.length; ++i) { + Set 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 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 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 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 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 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 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 al = classInstanceMap.get(cls); + ListIterator 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; + } +} diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/FpdPlatformDefs.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/FpdPlatformDefs.java new file mode 100644 index 0000000000..b7e5562e22 --- /dev/null +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/FpdPlatformDefs.java @@ -0,0 +1,661 @@ +/** @file + Java class FpdPlatformDefs is GUI for Flash element operation in SPD file. + +Copyright (c) 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +**/ +package org.tianocore.frameworkwizard.platform.ui; + +import java.awt.BorderLayout; +import javax.swing.JPanel; + +import javax.swing.AbstractAction; +import javax.swing.ButtonGroup; +import javax.swing.DefaultCellEditor; +import javax.swing.DefaultListModel; +import javax.swing.JDialog; +import javax.swing.JFileChooser; +import javax.swing.JFrame; +import javax.swing.JInternalFrame; +import javax.swing.JOptionPane; +import javax.swing.JTabbedPane; +import javax.swing.JButton; +import javax.swing.ListSelectionModel; + +import org.tianocore.PlatformSurfaceAreaDocument; +import org.tianocore.frameworkwizard.common.Tools; +import org.tianocore.frameworkwizard.common.ui.IInternalFrame; +import org.tianocore.frameworkwizard.common.ui.StarLabel; + + +import java.awt.FlowLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.ComponentAdapter; +import java.awt.event.ComponentEvent; +import java.awt.event.FocusAdapter; +import java.awt.event.FocusEvent; +import java.awt.event.FocusListener; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; +import java.awt.event.ActionEvent; +import java.io.File; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Set; + +import javax.swing.JCheckBox; +import javax.swing.JTextField; +import java.awt.GridLayout; +import javax.swing.JLabel; +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.JList; +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 javax.swing.JComboBox; +import java.awt.Dimension; +import javax.swing.JRadioButton; +import javax.swing.JTextArea; +import java.awt.CardLayout; + +public class FpdPlatformDefs extends IInternalFrame { + + static JFrame frame; + private JPanel jContentPane = null; + private JPanel jPanel = null; + private JPanel jPanel1 = null; + private JPanel jPanel2 = null; + private JPanel jPanel3 = null; + private JTabbedPane jTabbedPane = null; + private JButton jButtonOk = null; + private JButton jButtonCancel = null; + private JPanel jPanelFvImageW = null; + private JScrollPane jScrollPane = null; + private DefaultTableModel imageEntryPointTableModel = null; + private DefaultTableModel outputDirectoryTableModel = null; + + private DefaultTableModel skuInfoTableModel = null; + private DefaultTableModel fdfBlocksTableModel = null; + private DefaultTableModel fdfRegionsTableModel = null; + private DefaultTableModel fdfSubRegionsTableModel = null; + + private JLabel jLabel17 = null; + private DefaultListModel listModel = new DefaultListModel(); + private FpdFileContents ffc = null; + private JPanel jPanel4 = null; + private JPanel jPanel5 = null; + private JLabel jLabel = null; + private JCheckBox jCheckBox1 = null; + private JCheckBox jCheckBox2 = null; + private JCheckBox jCheckBox3 = null; + private JPanel jPanel6 = null; + private JLabel jLabel1 = null; + private JCheckBox jCheckBox4 = null; + private JComboBox jComboBox = null; + private JTextField jTextField = null; + private JTable jTable = null; + private JPanel jPanel7 = null; + private JLabel jLabel2 = null; + private JTextField jTextField1 = null; + private JButton jButton2 = null; + private JButton jButton3 = null; + private JScrollPane jScrollPane2 = null; + private JTable jTable1 = null; + private JLabel jLabel3 = null; + private JScrollPane jScrollPane3 = null; + private JTable jTable2 = null; + private JLabel jLabel4 = null; + private JTextField jTextField2 = null; + private JLabel jLabel5 = null; + private JTextField jTextField3 = null; + private JLabel jLabel6 = null; + private JButton jButton4 = null; + private JButton jButton5 = null; + private JLabel jLabel7 = null; + public FpdPlatformDefs() { + super(); + // TODO Auto-generated constructor stub + + initialize(); + this.setBounds(new java.awt.Rectangle(0, 0, 500, 370)); + this.setVisible(true); + } + + public FpdPlatformDefs(PlatformSurfaceAreaDocument.PlatformSurfaceArea fpd){ + this(); + ffc = new FpdFileContents(fpd); + init(ffc); + } + + /** + * 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) { + FlowLayout flowLayout = new FlowLayout(); + flowLayout.setAlignment(java.awt.FlowLayout.RIGHT); + flowLayout.setHgap(15); + jPanel1 = new JPanel(); + jPanel1.setLayout(flowLayout); + jPanel1.setComponentOrientation(java.awt.ComponentOrientation.LEFT_TO_RIGHT); + jPanel1.add(getJButtonCancel(), null); + jPanel1.add(getJButtonOk(), 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 jPanel3 + * + * @return javax.swing.JPanel + */ + private JPanel getJPanel3() { + if (jPanel3 == null) { + jPanel3 = new JPanel(); + } + return jPanel3; + } + + /** + * This method initializes jTabbedPane + * + * @return javax.swing.JTabbedPane + */ + private JTabbedPane getJTabbedPane() { + if (jTabbedPane == null) { + jTabbedPane = new JTabbedPane(); + + jTabbedPane.addTab("General", null, getJPanel4(), null); + + } + return jTabbedPane; + } + + /** + * This method initializes jButtonOk + * + * @return javax.swing.JButton + */ + private JButton getJButtonOk() { + if (jButtonOk == null) { + jButtonOk = new JButton(); + jButtonOk.setPreferredSize(new java.awt.Dimension(80,20)); + jButtonOk.setText("Cancel"); + jButtonOk.setVisible(false); + } + return jButtonOk; + } + + /** + * This method initializes jButtonCancel + * + * @return javax.swing.JButton + */ + private JButton getJButtonCancel() { + if (jButtonCancel == null) { + jButtonCancel = new JButton(); + jButtonCancel.setPreferredSize(new java.awt.Dimension(80,20)); + jButtonCancel.setText("Ok"); + jButtonCancel.setVisible(false); + } + return jButtonCancel; + } + + /** + * This method initializes jPanelFvImageW + * + * @return javax.swing.JPanel + */ + private JPanel getJPanelFvImageW() { + if (jPanelFvImageW == null) { + jPanelFvImageW = new JPanel(); + jPanelFvImageW.setPreferredSize(new java.awt.Dimension(10,2)); + } + return jPanelFvImageW; + } + + + /** + * This method initializes this + * + * @return void + */ + private void initialize() { + this.setSize(518, 650); + this.setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); + this.setContentPane(getJContentPane()); + this.setTitle("FPD Platform Definitions"); + } + + private void init(FpdFileContents ffc) { + + } + + + + /** + * 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.SOUTH); + jContentPane.add(getJPanel2(), java.awt.BorderLayout.WEST); + jContentPane.add(getJPanel3(), java.awt.BorderLayout.NORTH); + jContentPane.add(getJTabbedPane(), java.awt.BorderLayout.CENTER); + } + return jContentPane; + } + + /** + * This method initializes jPanel4 + * + * @return javax.swing.JPanel + */ + private JPanel getJPanel4() { + if (jPanel4 == null) { + jPanel4 = new JPanel(); + jPanel4.setLayout(new BorderLayout()); + jPanel4.add(getJPanel5(), java.awt.BorderLayout.NORTH); + jPanel4.add(getJPanel6(), java.awt.BorderLayout.SOUTH); + jPanel4.add(getJPanel7(), java.awt.BorderLayout.CENTER); + } + return jPanel4; + } + + /** + * This method initializes jPanel5 + * + * @return javax.swing.JPanel + */ + private JPanel getJPanel5() { + if (jPanel5 == null) { + jLabel = new JLabel(); + jLabel.setText("Tool Chain Families"); + FlowLayout flowLayout2 = new FlowLayout(); + flowLayout2.setAlignment(FlowLayout.LEFT); + flowLayout2.setHgap(20); + jPanel5 = new JPanel(); + jPanel5.setLayout(flowLayout2); + jPanel5.add(jLabel, null); + jPanel5.add(getJCheckBox1(), null); + jPanel5.add(getJCheckBox2(), null); + jPanel5.add(getJCheckBox3(), null); + } + return jPanel5; + } + + /** + * This method initializes jCheckBox1 + * + * @return javax.swing.JCheckBox + */ + private JCheckBox getJCheckBox1() { + if (jCheckBox1 == null) { + jCheckBox1 = new JCheckBox(); + jCheckBox1.setText("MSFT"); + } + return jCheckBox1; + } + + /** + * This method initializes jCheckBox2 + * + * @return javax.swing.JCheckBox + */ + private JCheckBox getJCheckBox2() { + if (jCheckBox2 == null) { + jCheckBox2 = new JCheckBox(); + jCheckBox2.setText("GCC"); + } + return jCheckBox2; + } + + /** + * This method initializes jCheckBox3 + * + * @return javax.swing.JCheckBox + */ + private JCheckBox getJCheckBox3() { + if (jCheckBox3 == null) { + jCheckBox3 = new JCheckBox(); + jCheckBox3.setText("INTC"); + } + return jCheckBox3; + } + + /** + * This method initializes jTable + * + * @return javax.swing.JTable + */ + private JTable getJTable() { + if (jTable == null) { + imageEntryPointTableModel = new DefaultTableModel(); + imageEntryPointTableModel.addColumn("Build Target"); + } + return jTable; + } + + /** + * This method initializes jTable1 + * + * @return javax.swing.JTable + */ + private JTable getJTable1() { + if (jTable1 == null) { + outputDirectoryTableModel = new DefaultTableModel(); + outputDirectoryTableModel.addColumn("Output Directory"); + outputDirectoryTableModel.addColumn("Intermediate Directories"); + + TableColumn imDirCol = jTable1.getColumnModel().getColumn(1); + JComboBox cb = new JComboBox(); + cb.addItem("MODULE"); + cb.addItem("UNIFIED"); + imDirCol.setCellEditor(new DefaultCellEditor(cb)); + } + return jTable1; + } + + + /** + * This method initializes jPanel6 + * + * @return javax.swing.JPanel + */ + private JPanel getJPanel6() { + if (jPanel6 == null) { + jLabel7 = new JLabel(); + jLabel7.setPreferredSize(new java.awt.Dimension(100,20)); + jLabel7.setText(""); + jLabel1 = new JLabel(); + jLabel1.setText("Output Directory"); + FlowLayout flowLayout3 = new FlowLayout(); + flowLayout3.setAlignment(FlowLayout.LEFT); + flowLayout3.setHgap(20); + jPanel6 = new JPanel(); + jPanel6.setPreferredSize(new java.awt.Dimension(10,250)); + jPanel6.setLayout(flowLayout3); + jPanel6.add(getJCheckBox4(), null); + jPanel6.add(getJComboBox(), null); + jPanel6.add(jLabel7, null); + jPanel6.add(jLabel1, null); + jPanel6.add(getJTextField(), null); + } + return jPanel6; + } + + /** + * This method initializes jCheckBox4 + * + * @return javax.swing.JCheckBox + */ + private JCheckBox getJCheckBox4() { + if (jCheckBox4 == null) { + jCheckBox4 = new JCheckBox(); + jCheckBox4.setText("Intermediate Directories"); + } + return jCheckBox4; + } + + /** + * This method initializes jComboBox + * + * @return javax.swing.JComboBox + */ + private JComboBox getJComboBox() { + if (jComboBox == null) { + jComboBox = new JComboBox(); + jComboBox.setPreferredSize(new Dimension(100, 20)); + jComboBox.addItem("MODULE"); + jComboBox.addItem("UNIFIED"); + jComboBox.setSelectedIndex(0); + } + return jComboBox; + } + + /** + * This method initializes jTextField + * + * @return javax.swing.JTextField + */ + private JTextField getJTextField() { + if (jTextField == null) { + jTextField = new JTextField(); + jTextField.setPreferredSize(new Dimension(280, 20)); + } + return jTextField; + } + + /** + * This method initializes jPanel7 + * + * @return javax.swing.JPanel + */ + private JPanel getJPanel7() { + if (jPanel7 == null) { + jLabel6 = new JLabel(); + jLabel6.setPreferredSize(new java.awt.Dimension(280,20)); + jLabel6.setText(" "); + jLabel5 = new JLabel(); + jLabel5.setPreferredSize(new java.awt.Dimension(40,20)); + jLabel5.setText("Name"); + jLabel4 = new JLabel(); + jLabel4.setPreferredSize(new java.awt.Dimension(20,20)); + jLabel4.setText("ID"); + jLabel3 = new JLabel(); + jLabel3.setPreferredSize(new java.awt.Dimension(109,20)); + jLabel3.setText("SKU Information"); + jLabel2 = new JLabel(); + jLabel2.setPreferredSize(new Dimension(109, 16)); + jLabel2.setText("Build Targets"); + FlowLayout flowLayout4 = new FlowLayout(); + flowLayout4.setAlignment(FlowLayout.LEFT); + flowLayout4.setHgap(20); + jPanel7 = new JPanel(); + jPanel7.setPreferredSize(new Dimension(972, 100)); + jPanel7.setLayout(flowLayout4); + jPanel7.add(jLabel2, null); + jPanel7.add(getJTextField1(), null); + jPanel7.add(getJButton2(), null); + jPanel7.add(getJButton3(), null); + jPanel7.add(getJScrollPane2(), null); + jPanel7.add(jLabel3, null); + jPanel7.add(jLabel4, null); + jPanel7.add(getJTextField2(), null); + jPanel7.add(jLabel5, null); + jPanel7.add(getJTextField3(), null); + jPanel7.add(getJScrollPane3(), null); + jPanel7.add(jLabel6, null); + jPanel7.add(getJButton4(), null); + jPanel7.add(getJButton5(), null); + } + return jPanel7; + } + + /** + * This method initializes jTextField1 + * + * @return javax.swing.JTextField + */ + private JTextField getJTextField1() { + if (jTextField1 == null) { + jTextField1 = new JTextField(); + jTextField1.setPreferredSize(new Dimension(150, 20)); + } + return jTextField1; + } + + /** + * This method initializes jButton2 + * + * @return javax.swing.JButton + */ + private JButton getJButton2() { + if (jButton2 == null) { + jButton2 = new JButton(); + jButton2.setPreferredSize(new Dimension(70, 20)); + jButton2.setText("Add"); + } + return jButton2; + } + + /** + * This method initializes jButton3 + * + * @return javax.swing.JButton + */ + private JButton getJButton3() { + if (jButton3 == null) { + jButton3 = new JButton(); + jButton3.setPreferredSize(new Dimension(70, 20)); + jButton3.setText("Delete"); + } + return jButton3; + } + + /** + * This method initializes jScrollPane2 + * + * @return javax.swing.JScrollPane + */ + private JScrollPane getJScrollPane2() { + if (jScrollPane2 == null) { + jScrollPane2 = new JScrollPane(); + jScrollPane2.setPreferredSize(new Dimension(453, 100)); + jScrollPane2.setViewportView(getJTable()); + } + return jScrollPane2; + } + + /** + * This method initializes jScrollPane3 + * + * @return javax.swing.JScrollPane + */ + private JScrollPane getJScrollPane3() { + if (jScrollPane3 == null) { + jScrollPane3 = new JScrollPane(); + jScrollPane3.setPreferredSize(new java.awt.Dimension(453,100)); + jScrollPane3.setViewportView(getJTable2()); + } + return jScrollPane3; + } + + /** + * This method initializes jTable2 + * + * @return javax.swing.JTable + */ + private JTable getJTable2() { + if (jTable2 == null) { + skuInfoTableModel = new DefaultTableModel(); + skuInfoTableModel.addColumn("SKU ID"); + skuInfoTableModel.addColumn("Name"); + jTable2 = new JTable(skuInfoTableModel); + } + return jTable2; + } + + /** + * This method initializes jTextField2 + * + * @return javax.swing.JTextField + */ + private JTextField getJTextField2() { + if (jTextField2 == null) { + jTextField2 = new JTextField(); + jTextField2.setPreferredSize(new java.awt.Dimension(50,20)); + } + return jTextField2; + } + + /** + * This method initializes jTextField3 + * + * @return javax.swing.JTextField + */ + private JTextField getJTextField3() { + if (jTextField3 == null) { + jTextField3 = new JTextField(); + jTextField3.setPreferredSize(new Dimension(150, 20)); + } + return jTextField3; + } + + /** + * This method initializes jButton4 + * + * @return javax.swing.JButton + */ + private JButton getJButton4() { + if (jButton4 == null) { + jButton4 = new JButton(); + jButton4.setPreferredSize(new Dimension(70, 20)); + jButton4.setText("Add"); + } + return jButton4; + } + + /** + * This method initializes jButton5 + * + * @return javax.swing.JButton + */ + private JButton getJButton5() { + if (jButton5 == null) { + jButton5 = new JButton(); + jButton5.setPreferredSize(new Dimension(70, 20)); + jButton5.setText("Delete"); + } + return jButton5; + } + + +} // @jve:decl-index=0:visual-constraint="10,10" + + diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/global/GlobalData.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/global/GlobalData.java new file mode 100644 index 0000000000..e74644fa75 --- /dev/null +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/global/GlobalData.java @@ -0,0 +1,1025 @@ +/** @file + GlobalData class. + + GlobalData provide initializing, instoring, querying and update global data. + It is a bridge to intercommunicate between multiple component, such as AutoGen, + PCD and so on. + +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.global; + +import org.apache.xmlbeans.XmlObject; +import org.tianocore.DbPathAndFilename; +import org.tianocore.FrameworkDatabaseDocument; +import org.tianocore.ModuleSurfaceAreaDocument; +import org.tianocore.ModuleSurfaceAreaDocument.ModuleSurfaceArea; +import org.tianocore.frameworkwizard.platform.ui.id.FpdModuleIdentification; +import org.tianocore.frameworkwizard.platform.ui.id.ModuleIdentification; +import org.tianocore.frameworkwizard.platform.ui.id.PackageIdentification; +import org.tianocore.frameworkwizard.platform.ui.id.PlatformIdentification; + +import java.io.File; +import java.util.Comparator; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.Stack; +import java.util.TreeMap; +import java.util.TreeSet; +import java.util.logging.Logger; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + GlobalData provide initializing, instoring, querying and update global data. + It is a bridge to intercommunicate between multiple component, such as AutoGen, + PCD and so on. + +

Note that all global information are initialized incrementally. All data will + parse and record only of necessary during build time.

+ + @since GenBuild 1.0 +**/ +public class GlobalData { + + + public static Logger log = Logger.getAnonymousLogger(); + public static KeyComparator comparator = new KeyComparator(); + /// + /// Record current WORKSPACE Directory + /// + private static String workspaceDir = ""; + + /// + /// Be used to ensure Global data will be initialized only once. + /// + private static boolean globalFlag = false; + + /// + /// Framework Database information: package list and platform list + /// + private static Set packageList = new HashSet(); + + private static Set platformList = new HashSet(); + + /// + /// Every detail SPD informations: Module list, Library class definition, + /// Package header file, GUID/PPI/Protocol definitions + /// + private static final Map spdTable = new HashMap(); + + /// + /// Build informations are divided into three parts: + /// 1. From MSA 2. From FPD 3. From FPD' ModuleSA + /// + private static Map> nativeMsa = new HashMap>(); + + private static Map> fpdModuleSA= new HashMap>(); + + private static XmlObject fpdBuildOptions; + + private static XmlObject fpdDynamicPcds; + + /// + /// Parsed modules list + /// + private static Map> parsedModules = new HashMap>(); + + /// + /// built modules list with ARCH, TARGET, TOOLCHAIN + /// + private static Set builtModules = new HashSet(); + + /// + /// PCD memory database stored all PCD information which collected from FPD,MSA and SPD. + /// +// private static final MemoryDatabaseManager pcdDbManager = new MemoryDatabaseManager(); + + /// + /// build target + tool chain family/tag name + arch + command types + command options + /// + private static Map toolChainOptions; + private static Map toolChainFamilyOptions; + private static Map toolChainDefinitions; + private static Map> moduleToolChainOptions = new HashMap>();; + private static Map> moduleToolChainFamilyOptions = new HashMap>();; + /// + /// + /// + private static Set targets; + /// + /// + /// + private static Set toolChainFamilies; + /// + /// + /// + private static Set toolChains; + /// + /// keep track which toolchain family a toolchain tag belongs to + /// + private static Map> toolChainFamilyMap; + private static Map> toolChainCommandMap; + + /// + /// list of Arch: EBC, ARM, IA32, X64, IPF, PPC + /// + private static Set archs; + + /// + /// list of Command Type: CC, LIB, LINK, ASL, ASM, ASMLINK, PP + /// + private static Set commandTypes; + + /** + Parse framework database (DB) and all SPD files listed in DB to initialize + the environment for next build. This method will only be executed only once + in the whole build process. + + @param workspaceDatabaseFile the file name of framework database + @param workspaceDir current workspace directory path + @throws Exception + Framework Dababase or SPD or MSA file is not valid + **/ + public synchronized static void initInfo(String workspaceDatabaseFile, String workspaceDir) throws Exception { + // + // ensure this method will be revoked only once + // + if (globalFlag) { + return; + } + globalFlag = true; + + // + // Backup workspace directory. It will be used by other method + // + GlobalData.workspaceDir = workspaceDir.replaceAll("(\\\\)", "/"); + File dbFile = new File(workspaceDir + File.separatorChar + workspaceDatabaseFile); + try { + FrameworkDatabaseDocument db = (FrameworkDatabaseDocument) XmlObject.Factory.parse(dbFile); + // + // validate FrameworkDatabaseFile + // +// if (! db.validate()) { +// throw new Exception("Framework Database file [" + dbFile.getPath() + "] is invalid."); +// } + // + // Get package list + // + List packages = db.getFrameworkDatabase().getPackageList().getFilenameList(); + + Iterator iter = packages.iterator(); + while (iter.hasNext()) { + DbPathAndFilename dbPath = (DbPathAndFilename)iter.next(); + String fileName = dbPath.getStringValue(); + Spd spd = new Spd(new File(workspaceDir + File.separatorChar + fileName)); + packageList.add(spd.getPackageId()); + spdTable.put(spd.getPackageId(), spd); + } + + + } catch (Exception e) { + e.printStackTrace(); + throw new Exception("Parse workspace Database [" + dbFile.getPath() + "] Error.\n" + e.getMessage()); + } + } + + /** + Get the current WORKSPACE Directory. + + @return current workspace directory + **/ + public synchronized static String getWorkspacePath() { + return workspaceDir; + } + + + /** + Get the MSA file name with absolute path + */ + public synchronized static File getMsaFile(ModuleIdentification moduleId) throws Exception { + File msaFile = null; + // + // TBD. Do only when package is null. + // + Iterator iter = packageList.iterator(); + while (iter.hasNext()) { + PackageIdentification packageId = (PackageIdentification)iter.next(); + Spd spd = spdTable.get(packageId); + msaFile = spd.getModuleFile(moduleId); + if (msaFile != null ) { + break ; + } + } + if (msaFile == null){ + throw new Exception("Can't find Module [" + moduleId.getName() + "] in all packages. "); + } + else { + return msaFile; + } + } + + public synchronized static PackageIdentification getPackageForModule(ModuleIdentification moduleId) { + // + // If package already defined in module + // + if (moduleId.getPackage() != null) { + return moduleId.getPackage(); + } + + PackageIdentification packageId = null; + Iterator iter = packageList.iterator(); + while (iter.hasNext()) { + packageId = (PackageIdentification)iter.next(); + + Spd spd = spdTable.get(packageId); + if (spd.getModuleFile(moduleId) != null ) { + moduleId.setPackage(packageId); + break ; + } + } + if (packageId == null){ + return null; + } + else { + return packageId; + } + } + + /** + Difference between build and parse: ToolChain and Target + **/ + public synchronized static boolean isModuleBuilt(FpdModuleIdentification moduleId) { + return builtModules.contains(moduleId); + } + + public synchronized static void registerBuiltModule(FpdModuleIdentification fpdModuleId) { + builtModules.add(fpdModuleId); + } + + + public synchronized static void registerFpdModuleSA(FpdModuleIdentification fpdModuleId, Map doc) throws Exception{ + Map result = new HashMap(); + Set keySet = doc.keySet(); + Iterator iter = keySet.iterator(); + while (iter.hasNext()){ + String key = (String)iter.next(); + XmlObject item = cloneXmlObject(doc.get(key), true); + result.put(key, item); + } + fpdModuleSA.put(fpdModuleId, result); + } + + /** + Query overrided module surface area information. If current is Package + or Platform build, also include the information from FPD file. + +

Note that surface area parsing is incremental. That means the method will + only parse the MSA and MBD files if necessary.

+ + @param moduleName the base name of the module + @return the overrided module surface area information + @throws Exception + MSA or MBD is not valid + **/ + public synchronized static Map getDoc(FpdModuleIdentification fpdModuleId) throws Exception { + if (parsedModules.containsKey(fpdModuleId)) { + return parsedModules.get(fpdModuleId); + } + Map doc = new HashMap(); + ModuleIdentification moduleId = fpdModuleId.getModule(); + // + // First part: get the MSA files info + // + doc = getNativeMsa(moduleId); + + // + // Second part: put build options + // + doc.put("BuildOptions", fpdBuildOptions); + + // + // Third part: get Module info from FPD, such as Library instances, PCDs + // + if (fpdModuleSA.containsKey(fpdModuleId)){ + // + // merge module info in FPD to final Doc + // For Library Module, do nothing here + // + doc.putAll(fpdModuleSA.get(fpdModuleId)); + } + parsedModules.put(fpdModuleId, doc); + return doc; + } + + public synchronized static Map getDoc(ModuleIdentification moduleId, String arch) throws Exception { + FpdModuleIdentification fpdModuleId = new FpdModuleIdentification(moduleId, arch); + return getDoc(fpdModuleId); + } + /** + Query the native MSA information with module base name. + +

Note that MSA parsing is incremental. That means the method will + only to parse the MSA files when never parsed before.

+ + @param moduleName the base name of the module + @return the native MSA information + @throws Exception + MSA file is not valid + **/ + public synchronized static Map getNativeMsa(ModuleIdentification moduleId) throws Exception { + if (nativeMsa.containsKey(moduleId)) { + return nativeMsa.get(moduleId); + } + File msaFile = getMsaFile(moduleId); + Map msaMap = getNativeMsa(msaFile); + nativeMsa.put(moduleId, msaMap); + return msaMap; + } + + public synchronized static Map getNativeMsa(File msaFile) throws Exception { + if (! msaFile.exists()) { + throw new Exception("Surface Area file [" + msaFile.getPath() + "] can't found."); + } + try { + ModuleSurfaceAreaDocument doc = (ModuleSurfaceAreaDocument)XmlObject.Factory.parse(msaFile); + // + // Validate File if they accord with XML Schema + // +// if ( ! doc.validate()){ +// throw new Exception("Module Surface Area file [" + msaFile.getPath() + "] is invalid."); +// } + // + // parse MSA file + // + ModuleSurfaceArea msa= doc.getModuleSurfaceArea(); + Map msaMap = new HashMap(); + msaMap.put("ModuleSurfaceArea", msa); + msaMap.put("MsaHeader", cloneXmlObject(msa.getMsaHeader(), true)); + msaMap.put("LibraryClassDefinitions", cloneXmlObject(msa.getLibraryClassDefinitions(), true)); + msaMap.put("SourceFiles", cloneXmlObject(msa.getSourceFiles(), true)); + msaMap.put("PackageDependencies", cloneXmlObject(msa.getPackageDependencies(), true)); + msaMap.put("Protocols", cloneXmlObject(msa.getProtocols(), true)); + msaMap.put("PPIs", cloneXmlObject(msa.getPPIs(), true)); + msaMap.put("Guids", cloneXmlObject(msa.getGuids(), true)); + msaMap.put("Externs", cloneXmlObject(msa.getExterns(), true)); + return msaMap; + } + catch (Exception ex){ + throw new Exception(ex.getMessage()); + } + } + + public static Map getFpdBuildOptions() { + Map map = new HashMap(); + map.put("BuildOptions", fpdBuildOptions); + return map; + } + + public static void setFpdBuildOptions(XmlObject fpdBuildOptions) throws Exception{ + GlobalData.fpdBuildOptions = cloneXmlObject(fpdBuildOptions, true); + } + + public static XmlObject getFpdDynamicPcds() { + return fpdDynamicPcds; + } + + public static void setFpdDynamicPcds(XmlObject fpdDynamicPcds) { + GlobalData.fpdDynamicPcds = fpdDynamicPcds; + } + + ////////////////////////////////////////////// + ////////////////////////////////////////////// + + public static Set getModules(PackageIdentification packageId){ + Spd spd = spdTable.get(packageId); + if (spd == null ) { + Set dummy = new HashSet(); + return dummy; + } + else { + return spd.getModules(); + } + } + + /** + The header file path is relative to workspace dir + **/ + public static String[] getLibraryClassHeaderFiles(PackageIdentification[] packages, String name) { + if (packages == null ){ + // throw Exception or not???? + return new String[0]; + } + String[] result = null; + for (int i = 0; i < packages.length; i++){ + Spd spd = spdTable.get(packages[i]); + // + // If find one package defined the library class + // + if( (result = spd.getLibClassIncluder(name)) != null){ + return result; + } + } + return null; + + } + + /** + The header file path is relative to workspace dir + **/ + public static String getPackageHeaderFiles(PackageIdentification packages, String moduleType) throws Exception { + if (packages == null ){ + return new String(""); + } + Spd spd = spdTable.get(packages); + // + // If can't find package header file, skip it + // + String temp = null; + if (spd != null){ + if( (temp = spd.getPackageIncluder(moduleType)) != null){ + return temp; + }else { + temp = ""; + return temp; + } + }else { + return null; + } + } + + /** + return two values: {cName, GuidValue} + **/ + public static String[] getGuid(PackageIdentification[] packages, String name) throws Exception { + if (packages == null ){ + // throw Exception or not???? + return new String[0]; + } + String[] result = null; + for (int i = 0; i < packages.length; i++){ + Spd spd = spdTable.get(packages[i]); + // + // If find one package defined the GUID + // + if( (result = spd.getGuid(name)) != null){ + return result; + } + } + return null; + } + + /** + return two values: {cName, GuidValue} + **/ + public static String[] getPpiGuid(PackageIdentification[] packages, String name) throws Exception { + if (packages == null ){ + return new String[0]; + } + String[] result = null; + for (int i = 0; i < packages.length; i++){ + Spd spd = spdTable.get(packages[i]); + // + // If find one package defined the Ppi GUID + // + if( (result = spd.getPpi(name)) != null){ + return result; + } + } + return null; + + } + + /** + return two values: {cName, GuidValue} + **/ + public static String[] getProtocolGuid(PackageIdentification[] packages, String name) throws Exception { + if (packages == null ){ + return new String[0]; + } + String[] result = null; + for (int i = 0; i < packages.length; i++){ + Spd spd = spdTable.get(packages[i]); + // + // If find one package defined the protocol GUID + // + if( (result = spd.getProtocol(name)) != null){ + return result; + } + } + return null; + + } + + /////////////////////////// Update!! Update!! Update!! +// public synchronized static MemoryDatabaseManager getPCDMemoryDBManager() { +// return pcdDbManager; +// } + /////////////////////////// + public synchronized static PlatformIdentification getPlatform(String name) throws Exception { + Iterator iter = platformList.iterator(); + while(iter.hasNext()){ + PlatformIdentification platformId = (PlatformIdentification)iter.next(); + if (platformId.getName().equalsIgnoreCase(name)) { + GlobalData.log.info("Platform: " + platformId + platformId.getFpdFile()); + return platformId; + } + } + throw new Exception("Can't find platform [" + name + "] in current workspace. "); + } + + public synchronized static File getPackageFile(PackageIdentification packageId) throws Exception { + Iterator iter = packageList.iterator(); + while(iter.hasNext()){ + PackageIdentification packageItem = (PackageIdentification)iter.next(); + if (packageItem.equals(packageId)) { + packageId.setName(packageItem.getName()); + return packageItem.getSpdFile(); + } + } + throw new Exception("Can't find " + packageId + " in current workspace. "); + } + + public synchronized static File getModuleFile(ModuleIdentification moduleId) throws Exception { + PackageIdentification packageId = getPackageForModule(moduleId); + moduleId.setPackage(packageId); + Spd spd = spdTable.get(packageId); + return spd.getModuleFile(moduleId); + } + // + // expanded by FrameworkWizard + // + public synchronized static XmlObject getModuleXmlObject(ModuleIdentification moduleId) throws Exception { + PackageIdentification packageId = getPackageForModule(moduleId); + moduleId.setPackage(packageId); + Spd spd = spdTable.get(packageId); + return spd.msaDocMap.get(moduleId); + } + + public synchronized static XmlObject getPackageXmlObject(PackageIdentification packageId) { + Spd spd = spdTable.get(packageId); + if (spd != null){ + return spd.spdDocMap.get("PackageSurfaceArea"); + } + return null; + } + + public synchronized static Set getPackageList(){ + return packageList; + } + ///// remove!! + private static XmlObject cloneXmlObject(XmlObject object, boolean deep) throws Exception { + if ( object == null) { + return null; + } + XmlObject result = null; + try { + result = XmlObject.Factory.parse(object.getDomNode() + .cloneNode(deep)); + } catch (Exception ex) { + throw new Exception(ex.getMessage()); + } + return result; + } + + ////// Tool Chain Related, try to refine and put some logic process to ToolChainFactory + public static void setBuildToolChainFamilyOptions(Map map) { + toolChainFamilyOptions = map; + } + + public static Map getToolChainFamilyOptions() { + return toolChainFamilyOptions; + } + + public static void setBuildToolChainOptions(Map map) { + toolChainOptions = map; + } + + public static Map getToolChainOptions() { + return toolChainOptions; + } + + public static void setTargets(Set targetSet) { + GlobalData.log.info("TargetSet: " + targetSet); + targets = targetSet; + } + + public static String[] getTargets() { + return (String[])targets.toArray(new String[targets.size()]); + } + + public static void setToolChains(Set toolChainSet) { + toolChains = toolChainSet; + } + + public static String[] getToolChains() { + String[] toolChainList = new String[toolChains.size()]; + return (String[])toolChains.toArray(toolChainList); + } + + public static void setToolChainFamilies(Set toolChainFamilySet) { + toolChainFamilies = toolChainFamilySet; + } + + public static void setToolChainFamiliyMap(Map> map) { + /* + Set keys = map.keySet(); + Iterator it = keys.iterator(); + while (it.hasNext()) { + String toolchain = (String)it.next(); + Set familyMap = (Set)map.get(toolchain); + Iterator fit = familyMap.iterator(); + System.out.print(toolchain + ": "); + while (fit.hasNext()) { + System.out.print((String)fit.next() + " "); + } + System.out.println(""); + } + */ + toolChainFamilyMap = map; + } + + public static String[] getToolChainFamilies() { + String[] toolChainFamilyList = new String[toolChainFamilies.size()]; + return (String[])toolChainFamilies.toArray(toolChainFamilyList); + } + + public static String[] getToolChainFamilies(String toolChain) { + Set familySet = (Set)toolChainFamilyMap.get(toolChain); + String[] toolChainFamilyList = new String[familySet.size()]; + return (String[])familySet.toArray(toolChainFamilyList); + } + + public static Set getToolChainFamilySet(String toolChain) { + return (Set)toolChainFamilyMap.get(toolChain); + } + + public static void setArchs(Set archSet) { + archs = archSet; + } + + public static String[] getArchs() { + String[] archList = new String[archs.size()]; + return (String[])archs.toArray(archList); + } + /* + + */ + public static void SetCommandTypes(Set commandTypeSet) { + commandTypes = commandTypeSet; + } + /* + + */ + public static void SetCommandTypes(Map> commandTypeMap) { + toolChainCommandMap = commandTypeMap; + } + /* + + */ + public static String[] getCommandTypes() { + String[] commandList = new String[commandTypes.size()]; + return (String[])commandTypes.toArray(commandList); + } + /* + + */ + public static String[] getCommandTypes(String toolChain) { + Set commands = (Set)toolChainCommandMap.get(toolChain); + if (commands == null) { + return new String[0]; + } + + String[] commandList = new String[commands.size()]; + return (String[])commands.toArray(commandList); + } + /* + + */ + public static String getCommandSetting(String target, String toolChain, + String arch, String command, String attribute, FpdModuleIdentification fpdModuleId) { + String[] commandDescription = new String[] {target, toolChain, arch, command, attribute}; + return getCommandSetting(commandDescription, fpdModuleId); + } + /* + + */ + public static String getCommandSetting(String[] commandDescription, FpdModuleIdentification fpdModuleId) { + if (commandDescription[4].equals("FLAGS")) { + return getCommandFlags(commandDescription, fpdModuleId); + } + + StringBuffer commandDescString = new StringBuffer(32); + + int i = 0; + while (true) { + commandDescString.append(commandDescription[i++]); + if (i >= commandDescription.length) { + break; + } + commandDescString.append("_"); + } + + return getCommandSetting(commandDescString.toString()); + } + /* + + */ + public static String getCommandSetting(String commandDescString) { + return (String)toolChainDefinitions.get(commandDescString); + } + /* + + */ + public static String getCommandFlags(String[] commandDescription, FpdModuleIdentification fpdModuleId) { + String setting = getSetting(toolChainOptions, commandDescription, fpdModuleId, false); + + if (setting == null) { + String commandDesc = commandDescription[4]; + commandDescription[4] = "FAMILY"; + String toolChainFamily = getCommandSetting(commandDescription, fpdModuleId); + commandDescription[4] = commandDesc; + + commandDesc = commandDescription[1]; + commandDescription[1] = toolChainFamily; + setting = getSetting(toolChainFamilyOptions, commandDescription, fpdModuleId, true); + commandDescription[1] = commandDesc; + } + + if (setting == null) { + setting = ""; + } + + + Set addFlagsSet = new LinkedHashSet(); + Set subFlagsSet = new LinkedHashSet(); + putFlagsToSet(addFlagsSet, setting); + + return getFlags(addFlagsSet, subFlagsSet); + } + /* + + */ + private static String getSetting(Map optionMap, String[] commandDescription, + FpdModuleIdentification fpdModuleId, boolean toolChainFamilyFlag) { + + String setting = (String)getOption(optionMap, commandDescription); + if (fpdModuleId == null) { + return setting; + } + // + // module overrides + // + // + // get module xml doc + // + Map fpdModule = (Map)fpdModuleSA.get(fpdModuleId); + if (fpdModuleId == null) { + return setting; + } + SurfaceAreaQuery.push(fpdModule); + // + // check if the module has been parsed + // + Map moduleOptions = (Map)moduleToolChainOptions.get(fpdModuleId); + if (moduleOptions == null) { + // + // get all the build options of this module + // + moduleOptions = new TreeMap(comparator); + parseBuildOptions(moduleOptions, SurfaceAreaQuery.getOptions(toolChainFamilyFlag)); + } + // + // get setting for current qualified command + // + Set addSet = new TreeSet(); + Set subSet = new TreeSet(); + putFlagsToSet(addSet, setting); + String moduleSetting = getOption(moduleOptions, commandDescription); + if (moduleSetting != null) { + moduleSetting = parseOptionString(moduleSetting, addSet, subSet); + } + // + // do necessary setting override + // + if (moduleSetting == null) { + setting = getRawFlags(addSet, subSet); + } else { + setting = moduleSetting; + } + + SurfaceAreaQuery.pop(); + return setting; + } + /* + + */ + public static void setToolChainDefinitions(Map def) { + toolChainDefinitions = def; + } + + public static Map getToolChainDefinitions() { + return toolChainDefinitions; + } + + /** + Separate the string and instore in set. + +

String is separated by Java Regulation Expression + "[^\\\\]?(\".*?[^\\\\]\")[ \t,]+".

+ +

For example:

+ +
+        "/nologo", "/W3", "/WX"
+        "/C", "/DSTRING_DEFINES_FILE=\"BdsStrDefs.h\""
+      
+ + @param set store the separated string + @param str string to separate + **/ + private static void putFlagsToSet(Set set, String str) { + if (str == null || str.length() == 0) { + return; + } + + Pattern myPattern = Pattern.compile("[^\\\\]?(\".*?[^\\\\]\")[ \t,]+"); + Matcher matcher = myPattern.matcher(str + " "); + while (matcher.find()) { + String item = str.substring(matcher.start(1), matcher.end(1)); + set.add(item); + } + } + + /** + Generate the final flags string will be used by compile command. + + @param add the add flags set + @param sub the sub flags set + @return final flags after add set substract sub set + **/ + private static String getFlags(Set add, Set sub) { + String result = ""; + add.removeAll(sub); + Iterator iter = add.iterator(); + while (iter.hasNext()) { + String str = (String) iter.next(); + result += str.substring(1, str.length() - 1) + " "; + } + return result; + } + + /** + Generate the flags string with original format. The format is defined by + Java Regulation Expression "[^\\\\]?(\".*?[^\\\\]\")[ \t,]+".

+ +

For example:

+ +
+        "/nologo", "/W3", "/WX"
+        "/C", "/DSTRING_DEFINES_FILE=\"BdsStrDefs.h\""
+      
+ + @param add the add flags set + @param sub the sub flags set + @return flags with original format + **/ + private static String getRawFlags(Set add, Set sub) { + String result = null; + add.removeAll(sub); + Iterator iter = add.iterator(); + while (iter.hasNext()) { + String str = (String) iter.next(); + result += "\"" + str.substring(1, str.length() - 1) + "\", "; + } + return result; + } + + private static String parseOptionString(String optionString, Set addSet, Set subSet) { + boolean overrideOption = false; + Pattern pattern = Pattern.compile("ADD\\.\\[(.+)\\]"); + Matcher matcher = pattern.matcher(optionString); + + while (matcher.find()) { + overrideOption = true; + String addOption = optionString.substring(matcher.start(1), matcher.end(1)).trim(); + putFlagsToSet(addSet, addOption); + + } + + pattern = Pattern.compile("SUB\\.\\[(.+)\\]"); + matcher = pattern.matcher(optionString); + + while (matcher.find()) { + overrideOption = true; + String subOption = optionString.substring(matcher.start(1), matcher.end(1)).trim(); + putFlagsToSet(subSet, subOption); + } + + if (overrideOption == true) { + return null; + } + + return optionString; + } + + public static String getOption(Map options, String[] toolDefString) { + Stack> stack = new Stack>(); + Map map = options; + Map lastMap; + String option = null; + int length = toolDefString.length - 2; + + int i = 0; + String key = null; + boolean backtrack = false; + while (true) { + if (map == null) { + if (stack.empty()) { + break; + } + map = (Map)stack.pop(); + if (backtrack) { + --i; + } + key = "*"; + backtrack = true; + } else { + if (i >= length) { + break; + } + key = toolDefString[i]; + stack.push(map); + ++i; + backtrack = false; + } + lastMap = map; + map = (Map)lastMap.get(key); + } + + if (map != null) { + option = (String)map.get(toolDefString[i]); + } + + return option; + } + + private static void parseBuildOptions(Map optionMap, String[][] options) { + Map map; + Map nextMap; + + for (int i = 0; i < options.length; ++i) { + map = optionMap; + + int flagIndex = options[i].length - 1; + int cmdIndex = flagIndex - 1; + int archIndex = cmdIndex - 1; + for (int j = 0; j < cmdIndex; ++j) { + String s = options[i][j]; + if (s == null || s.trim().length() == 0) { + s = "*"; + } + s = s.trim().toUpperCase(); + + nextMap = (Map)map.get(s); + if (nextMap == null) { + nextMap = new HashMap(); + map.put(s, nextMap); + } + + map = nextMap; + } + + String cmd = options[i][cmdIndex]; + String flag = options[i][flagIndex]; + if (cmd == null || cmd.trim().length() == 0) { + cmd = "*"; + } + if (flag == null) { + flag = ""; + } + map.put(cmd.trim().toUpperCase(), flag.trim().toUpperCase()); + } + } + +} + +final class KeyComparator implements Comparator { + public int compare(String x, String y) { + return x.compareToIgnoreCase(y); + } + +} + diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/global/Spd.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/global/Spd.java new file mode 100644 index 0000000000..11b0e073f2 --- /dev/null +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/global/Spd.java @@ -0,0 +1,237 @@ +/** @file + Spd class. + + This class is to generate a global table for the content 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.platform.ui.global; + +import java.io.File; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; +import java.util.Set; + +import org.apache.xmlbeans.XmlObject; +import org.tianocore.frameworkwizard.platform.ui.id.ModuleIdentification; +import org.tianocore.frameworkwizard.platform.ui.id.PackageIdentification; + +/** + + This class is to generate a global table for the content of spd file. + + **/ +public class Spd { + /// + /// + /// + Map msaInfo = new HashMap(); + + /// + /// Map of module info. + /// Key : moduletype + /// Value: moduletype related include file + /// + Map packageHeaderInfo = new HashMap(); + + /// + /// Map of PPI info. + /// Key : PPI name + /// value: String[] a. PPI C_NAME; b. PPI GUID; + /// + Map ppiInfo = new HashMap(); + + /// + /// Map of Protocol info. + /// Key : Protocol name + /// value: String[] a. Protocol C_NAME; b. Protocol GUID; + /// + Map protocolInfo = new HashMap(); + + /// + /// Map of Guid info. + /// Key : Guid name + /// value: String[] a. Guid C_NAME; b. Guid's GUID; + /// + Map guidInfo = new HashMap(); + + /// + /// Map of library class and its exposed header file. + /// Key : library class name + /// value : library class corresponding header file + /// + Map libClassHeaderList = new HashMap(); + + // + // Xml Doc of Spd file, Msa file + // + public Map spdDocMap = new HashMap(); + public Map msaDocMap = new HashMap(); + /// + /// Package path. + /// + PackageIdentification packageId; + + /** + Constructor function + + This function mainly initialize some member variables. + **/ + Spd(File packageFile) throws Exception { + try { + XmlObject spdDoc = XmlObject.Factory.parse(packageFile); + // + // Verify SPD file, if is invalid, throw Exception + // +// if (! spdDoc.validate()) { +// throw new Exception("Package Surface Area file [" + packageFile.getPath() + "] is invalid. "); +// } + // We can change Map to XmlObject + + spdDocMap.put("PackageSurfaceArea", spdDoc); + SurfaceAreaQuery.setDoc(spdDocMap); + // + // + // + packageId = SurfaceAreaQuery.getSpdHeader(); + packageId.setSpdFile(packageFile); + + // + // initialize Msa Files + // MSA file is absolute file path + // + String[] msaFilenames = SurfaceAreaQuery.getSpdMsaFile(); + for (int i = 0; i < msaFilenames.length; i++){ + File msaFile = new File(packageId.getPackageDir() + File.separatorChar + msaFilenames[i]); + Map msaDoc = GlobalData.getNativeMsa( msaFile ); + SurfaceAreaQuery.push(msaDoc); + ModuleIdentification moduleId = SurfaceAreaQuery.getMsaHeader(); + SurfaceAreaQuery.pop(); + moduleId.setPackage(packageId); + msaInfo.put(moduleId, msaFile); + msaDocMap.put(moduleId, msaDoc.get("ModuleSurfaceArea")); + } + // + // initialize Package header files + // +// Map packageHeaders = SurfaceAreaQuery.getSpdPackageHeaderFiles(); +// Set keys = packageHeaders.keySet(); +// Iterator iter = keys.iterator(); +// while (iter.hasNext()){ +// String moduleType = (String)iter.next(); +// String header = packageId.getPackageRelativeDir() + File.separatorChar + packageHeaders.get(moduleType); +// // +// // Change path seperator to system-dependent path separator +// // +// File file = new File (header); +// header = file.getParent(); +// packageHeaderInfo.put(moduleType, header); +// } + // + // initialize Guid Info + // + guidInfo.putAll(SurfaceAreaQuery.getSpdGuid()); + // + // initialize PPI info + // + ppiInfo.putAll(SurfaceAreaQuery.getSpdPpi()); + // + // initialize Protocol info + // + protocolInfo.putAll(SurfaceAreaQuery.getSpdProtocol()); + // + // initialize library class declaration + // + Map libraryClassHeaders = SurfaceAreaQuery.getSpdLibraryClasses(); + Set keys = libraryClassHeaders.keySet(); + Iterator iter = keys.iterator(); + while (iter.hasNext()){ + String libraryClassName = (String)iter.next(); + String[] headerFiles = libraryClassHeaders.get(libraryClassName); + for (int i = 0; i < headerFiles.length; i++){ + headerFiles[i] = packageId.getPackageRelativeDir() + File.separatorChar + headerFiles[i]; + + // + // Change path separator to system system-dependent path separator. + // + File file = new File (headerFiles[i]); + headerFiles[i] = file.getPath(); + } + libClassHeaderList.put(libraryClassName, headerFiles); + } + } + catch (Exception e) { + e.setStackTrace(e.getStackTrace()); + throw new Exception("Parse package description file [" + packageId.getSpdFile() + "] Error.\n" + + e.getMessage()); + } + } + + public PackageIdentification getPackageId() { + return packageId; + } + + public File getModuleFile(ModuleIdentification moduleId) { + return msaInfo.get(moduleId); + } + + public Set getModules(){ + return msaInfo.keySet(); + } + + /** + return two value {CName, Guid}. If not found, return null. + **/ + public String[] getPpi(String ppiName) { + return ppiInfo.get(ppiName); + } + + /** + return two value {CName, Guid}. If not found, return null. + **/ + public String[] getProtocol(String protocolName) { + return protocolInfo.get(protocolName); + } + + /** + return two value {CName, Guid}. If not found, return null. + **/ + public String[] getGuid(String guidName) { + return guidInfo.get(guidName); + } + + /** + getLibClassInclude + + This function is to get the library exposed header file name according + library class name. + + @param libName Name of library class + @return Name of header file + **/ + String[] getLibClassIncluder(String libName) { + return libClassHeaderList.get(libName); + } + + /** + getModuleTypeIncluder + + This function is to get the header file name from module info map + according to module type. + + @param moduleType Module type. + @return Name of header file. + **/ + String getPackageIncluder(String moduleType) { + return packageHeaderInfo.get(moduleType); + } +} diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/global/SurfaceAreaQuery.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/global/SurfaceAreaQuery.java new file mode 100644 index 0000000000..544263fac9 --- /dev/null +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/global/SurfaceAreaQuery.java @@ -0,0 +1,1399 @@ +/** @file + This file is for surface area information retrieval. + + 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.global; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.Stack; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import org.apache.xmlbeans.XmlNormalizedString; +import org.apache.xmlbeans.XmlObject; +import org.apache.xmlbeans.XmlString; +import org.tianocore.BuildOptionsDocument; +import org.tianocore.BuildTargetList; +import org.tianocore.DataIdDocument; +import org.tianocore.ExternsDocument; +import org.tianocore.FileNameConvention; +import org.tianocore.FvAttributeDocument; +//import org.tianocore.FvImageDocument; +import org.tianocore.FvImagesDocument; +import org.tianocore.FvOptionDocument; +import org.tianocore.GuidDeclarationsDocument; +import org.tianocore.GuidsDocument; +import org.tianocore.LibrariesDocument; +import org.tianocore.LibraryClassDeclarationsDocument; +import org.tianocore.LibraryClassDocument; +import org.tianocore.ModuleSADocument; +import org.tianocore.ModuleTypeDef; +import org.tianocore.MsaFilesDocument; +import org.tianocore.MsaHeaderDocument; +import org.tianocore.OptionDocument; +import org.tianocore.PPIsDocument; +import org.tianocore.PackageDependenciesDocument; +import org.tianocore.PackageHeadersDocument; +import org.tianocore.PlatformDefinitionsDocument; +import org.tianocore.PpiDeclarationsDocument; +import org.tianocore.ProtocolDeclarationsDocument; +import org.tianocore.SpdHeaderDocument; +import org.tianocore.FilenameDocument.Filename; +import org.tianocore.MsaHeaderDocument.MsaHeader; +import org.tianocore.ProtocolsDocument.Protocols.Protocol; +import org.tianocore.ProtocolsDocument.Protocols.ProtocolNotify; +import org.tianocore.PlatformHeaderDocument; +import org.tianocore.frameworkwizard.platform.ui.id.FpdModuleIdentification; +import org.tianocore.frameworkwizard.platform.ui.id.ModuleIdentification; +import org.tianocore.frameworkwizard.platform.ui.id.PackageIdentification; +import org.tianocore.frameworkwizard.platform.ui.id.PlatformIdentification; + +/** + * SurfaceAreaQuery class is used to query Surface Area information from msa, + * mbd, spd and fpd files. + * + * This class should not instantiated. All the public interfaces is static. + * + * @since GenBuild 1.0 + */ +public class SurfaceAreaQuery { + + public static String prefix = "http://www.TianoCore.org/2006/Edk2.0"; + + // / + // / Contains name/value pairs of Surface Area document object. The name is + // / always the top level element name. + // / + private static Map map = null; + + // / + // / mapStack is used to do nested query + // / + private static Stack> mapStack = new Stack>(); + + // / + // / prefix of name space + // / + private static String nsPrefix = "sans"; + + // / + // / xmlbeans needs a name space for each Xpath element + // / + private static String ns = null; + + // / + // / keep the namep declaration for xmlbeans Xpath query + // / + private static String queryDeclaration = null; + + /** + * Set a Surface Area document for query later + * + * @param map + * A Surface Area document in TopLevelElementName/XmlObject + * format. + */ + public static void setDoc(Map map) { + ns = prefix; + queryDeclaration = "declare namespace " + nsPrefix + "='" + ns + "'; "; + SurfaceAreaQuery.map = map; + } + + /** + * Push current used Surface Area document into query stack. The given new + * document will be used for any immediately followed getXXX() callings, + * untill pop() is called. + * + * @param newMap + * The TopLevelElementName/XmlObject format of a Surface Area + * document. + */ + public static void push(Map newMap) { + mapStack.push(SurfaceAreaQuery.map); + SurfaceAreaQuery.map = newMap; + } + + /** + * Discard current used Surface Area document and use the top document in + * stack instead. + */ + public static void pop() { + SurfaceAreaQuery.map = mapStack.pop(); + } + + // / + // / Convert xPath to be namespace qualified, which is necessary for + // XmlBeans + // / selectPath(). For example, converting /MsaHeader/ModuleType to + // / /ns:MsaHeader/ns:ModuleType + // / + private static String normalizeQueryString(String[] exp, String from) { + StringBuffer normQueryString = new StringBuffer(4096); + + int i = 0; + while (i < exp.length) { + String newExp = from + exp[i]; + Pattern pattern = Pattern.compile("([^/]*)(/|//)([^/]+)"); + Matcher matcher = pattern.matcher(newExp); + + while (matcher.find()) { + String starter = newExp.substring(matcher.start(1), matcher + .end(1)); + String seperator = newExp.substring(matcher.start(2), matcher + .end(2)); + String token = newExp.substring(matcher.start(3), matcher + .end(3)); + + normQueryString.append(starter); + normQueryString.append(seperator); + normQueryString.append(nsPrefix); + normQueryString.append(":"); + normQueryString.append(token); + } + + ++i; + if (i < exp.length) { + normQueryString.append(" | "); + } + } + + return normQueryString.toString(); + } + + /** + * Search all XML documents stored in "map" for the specified xPath, using + * relative path (starting with '$this') + * + * @param xPath + * xpath query string array + * @returns An array of XmlObject if elements are found at the specified + * xpath + * @returns NULL if nothing is at the specified xpath + */ + public static XmlObject[] get(String[] xPath) { + if (map == null) { + return null; + } + + String[] keys = (String[]) map.keySet().toArray(new String[map.size()]); + List result = new ArrayList(); + for (int i = 0; i < keys.length; ++i) { + XmlObject rootNode = (XmlObject) map.get(keys[i]); + if (rootNode == null) { + continue; + } + + String query = queryDeclaration + + normalizeQueryString(xPath, "$this/" + keys[i]); + XmlObject[] tmp = rootNode.selectPath(query); + for (int j = 0; j < tmp.length; ++j) { + result.add(tmp[j]); + } + } + + int size = result.size(); + if (size <= 0) { + return null; + } + + return (XmlObject[]) result.toArray(new XmlObject[size]); + } + + /** + * Search XML documents named by "rootName" for the given xPath, using + * relative path (starting with '$this') + * + * @param rootName + * The top level element name + * @param xPath + * The xpath query string array + * @returns An array of XmlObject if elements are found at the given xpath + * @returns NULL if nothing is found at the given xpath + */ + public static XmlObject[] get(String rootName, String[] xPath) { + if (map == null) { + return null; + } + + XmlObject root = (XmlObject) map.get(rootName); + if (root == null) { + return null; + } + + String query = queryDeclaration + + normalizeQueryString(xPath, "$this/" + rootName); + XmlObject[] result = root.selectPath(query); + if (result.length > 0) { + return result; + } + + query = queryDeclaration + normalizeQueryString(xPath, "/" + rootName); + result = root.selectPath(query); + if (result.length > 0) { + return result; + } + + return null; + } + + /** + * Retrieve SourceFiles/Filename for specified ARCH type + * + * @param arch + * architecture name + * @returns An 2 dimension string array if elements are found at the known + * xpath + * @returns NULL if nothing is found at the known xpath + */ + public static String[][] getSourceFiles(String arch) { + String[] xPath; + XmlObject[] returns; + + if (arch == null || arch.equals("")) { + xPath = new String[] { "/Filename" }; + } else { + xPath = new String[] { "/Filename[not(@SupArchList) or @SupArchList='" + + arch + "']" }; + } + + returns = get("SourceFiles", xPath); + + if (returns == null || returns.length == 0) { + return null; + } + + Filename[] sourceFileNames = (Filename[]) returns; + String[][] outputString = new String[sourceFileNames.length][2]; + for (int i = 0; i < sourceFileNames.length; i++) { + outputString[i][0] = sourceFileNames[i].getToolCode(); + outputString[i][1] = sourceFileNames[i].getStringValue(); + } + return outputString; + } + + /** + * Retrieve /PlatformDefinitions/OutputDirectory from FPD + * + * @returns Directory names array if elements are found at the known xpath + * @returns Empty if nothing is found at the known xpath + */ + public static String getFpdOutputDirectory() { + String[] xPath = new String[] { "/PlatformDefinitions/OutputDirectory" }; + + XmlObject[] returns = get("FrameworkPlatformDescription", xPath); + if (returns != null && returns.length > 0) { + // String TBD + } + + return null; + } + + public static String getFpdIntermediateDirectories() { + String[] xPath = new String[] { "/PlatformDefinitions/IntermediateDirectories" }; + + XmlObject[] returns = get("FrameworkPlatformDescription", xPath); + if (returns != null && returns.length > 0) { + // TBD + } + return "UNIFIED"; + } + + /** + * Retrieve BuildOptions/Option or Arch/Option + * + * @param toolChainFamilyFlag + * if true, retrieve options for toolchain family; otherwise for + * toolchain + * + * @returns String[][5] name, target, toolchain, arch, coommand of options + * if elements are found at the known xpath. String[0][] if dont + * find element. + * + * @returns Empty array if nothing is there + */ + public static String[][] getOptions(boolean toolChainFamilyFlag) { + String[] xPath; + String target = null; + String toolchain = null; + String toolchainFamily = null; + List archList = null; + String cmd = null; + String targetName = null; + String optionName = null; + + if (toolChainFamilyFlag == true) { + xPath = new String[] { + "/BuildOptions/Options/Option[not(@ToolChainFamily) and not(@ToolChainTag)]", + "/BuildOptions/Options/Option[@ToolChainFamily]", }; + } else { + xPath = new String[] { + "/BuildOptions/Options/Option[not(@ToolChainFamily) and not(@ToolChainTag)]", + "/BuildOptions/Options/Option[@TagName]", }; + } + + XmlObject[] returns = get("FrameworkPlatformDescription", xPath); + if (returns == null) { + return new String[0][5]; + } + + List optionList = new ArrayList(); + OptionDocument.Option option; + + for (int i = 0; i < returns.length; i++) { + option = (OptionDocument.Option) returns[i]; + + // + // Get Target, ToolChain(Family), Arch, Cmd, and Option from Option, + // then + // put to result[][5] array in above order. + // + String[] targetList; + target = null;//Auber option.getBuildTargets(); + if (target != null) { + targetList = target.split(" "); + } else { + targetList = new String[1]; + targetList[0] = null; + } + + if (toolChainFamilyFlag) { + toolchainFamily = option.getToolChainFamily(); + if (toolchainFamily != null) { + toolchain = toolchainFamily.toString(); + } else { + toolchain = null; + } + } else { + toolchain = option.getTagName(); + } + + archList = option.getSupArchList(); + if (archList == null) { + archList.add(null); + } + + cmd = option.getToolCode(); + + optionName = option.getStringValue(); + for (int t = 0; t < targetList.length; t++) { + for (int j = 0; j < archList.size(); j++) { + optionList.add(new String[] { optionName, targetList[i], + toolchain, archList.get(j), cmd }); + } + } + } + + String[][] result = new String[optionList.size()][5]; + for (int i = 0; i < optionList.size(); i++) { + result[i][0] = optionList.get(i)[0]; + result[i][1] = optionList.get(i)[1]; + result[i][2] = optionList.get(i)[2]; + result[i][3] = optionList.get(i)[3]; + result[i][4] = optionList.get(i)[4]; + } + return result; + } + + public static String getBuildTarget() { + String[] xPath = new String[] { "/PlatformDefinitions/BuildTargets" }; + + XmlObject[] returns = get("FrameworkPlatformDescription", xPath); + if (returns != null && returns.length > 0) { + return ((BuildTargetList) returns[0]).getStringValue(); + } + + return null; + } + + /** + * Retrieve /ModuleType + * + * @returns The module type name if elements are found at the known xpath + * @returns null if nothing is there + */ + public static String getModuleType() { + String[] xPath = new String[] { "/ModuleType" }; + + XmlObject[] returns = get(xPath); + if (returns != null && returns.length > 0) { + ModuleTypeDef type = (ModuleTypeDef) returns[0]; + return type.enumValue().toString(); + } + + return null; + } + + /** + * Retrieve PackageDependencies/Package + * + * @param arch + * Architecture name + * + * @returns package name list if elements are found at the known xpath + * @returns null if nothing is there + */ + public static PackageIdentification[] getDependencePkg(String arch) { + String[] xPath; + String packageGuid = null; + String packageVersion = null; + + if (arch == null || arch.equals("")) { + xPath = new String[] { "/PackageDependencies/Package" }; + } else { + xPath = new String[] { "/PackageDependencies/Package[not(@SupArchList) or @SupArchList='" + + arch + "']" }; + } + + XmlObject[] returns = get("ModuleSurfaceArea", xPath); + if (returns == null) { + return new PackageIdentification[0]; + } + PackageIdentification[] packageIdList = new PackageIdentification[returns.length]; + for (int i = 0; i < returns.length; i++) { + PackageDependenciesDocument.PackageDependencies.Package item = (PackageDependenciesDocument.PackageDependencies.Package) returns[i]; + packageGuid = item.getPackageGuid(); + packageVersion = item.getPackageVersion(); + + Set spi = GlobalData.getPackageList(); + Iterator ispi = spi.iterator(); + String ver = ""; + while(ispi.hasNext()) { + PackageIdentification pi = ispi.next(); + if (packageVersion != null) { + if (pi.getGuid().equals(packageGuid) && pi.getVersion().equals(packageVersion)) { + packageIdList[i] = pi; + break; + } + } + else { + if (pi.getGuid().equals(packageGuid)) { + if (pi.getVersion() != null && pi.getVersion().compareTo(ver) > 0){ + ver = pi.getVersion(); + packageIdList[i] = pi; + } + else if (packageIdList[i] == null){ + packageIdList[i] = pi; + } + } + } + + } + } + return packageIdList; + } + + /** + * Retrieve LibraryClassDefinitions/LibraryClass for specified usage + * + * @param usage + * Library class usage + * + * @returns LibraryClass objects list if elements are found at the known + * xpath + * @returns null if nothing is there + */ + public static String[] getLibraryClasses(String usage) { + String[] xPath; + + if (usage == null || usage.equals("")) { + xPath = new String[] { "/LibraryClass" }; + } else { + xPath = new String[] { "/LibraryClass[@Usage='" + usage + "']" }; + } + + XmlObject[] returns = get("LibraryClassDefinitions", xPath); + if (returns == null || returns.length == 0) { + return new String[0]; + } + + LibraryClassDocument.LibraryClass[] libraryClassList = (LibraryClassDocument.LibraryClass[]) returns; + String[] libraryClassName = new String[libraryClassList.length]; + for (int i = 0; i < libraryClassList.length; i++) { + libraryClassName[i] = libraryClassList[i].getKeyword(); + } + return libraryClassName; + } + + /** + * Retrieve ModuleEntryPoint names + * + * @returns ModuleEntryPoint name list if elements are found at the known + * xpath + * @returns null if nothing is there + */ + public static String[] getModuleEntryPointArray() { + String[] xPath = new String[] { "/Extern/ModuleEntryPoint" }; + + XmlObject[] returns = get("Externs", xPath); + + if (returns != null && returns.length > 0) { + String[] entryPoints = new String[returns.length]; + + for (int i = 0; i < returns.length; ++i) { + entryPoints[i] = ((XmlNormalizedString) returns[i]) + .getStringValue(); + } + + return entryPoints; + } + + return null; + } + + + + + /** + * Retrieve ModuleUnloadImage names + * + * @returns ModuleUnloadImage name list if elements are found at the known + * xpath + * @returns null if nothing is there + */ + public static String[] getModuleUnloadImageArray() { + String[] xPath = new String[] { "/Extern/ModuleUnloadImage" }; + + XmlObject[] returns = get("Externs", xPath); + if (returns != null && returns.length > 0) { + String[] stringArray = new String[returns.length]; + XmlNormalizedString[] doc = (XmlNormalizedString[]) returns; + + for (int i = 0; i < returns.length; ++i) { + stringArray[i] = doc[i].getStringValue(); + } + + return stringArray; + } + + return null; + } + + /** + * Retrieve Extern + * + * @returns Extern objects list if elements are found at the known xpath + * @returns null if nothing is there + */ + public static ExternsDocument.Externs.Extern[] getExternArray() { + String[] xPath = new String[] { "/Extern" }; + + XmlObject[] returns = get("Externs", xPath); + if (returns != null && returns.length > 0) { + return (ExternsDocument.Externs.Extern[]) returns; + } + + return null; + } + + /** + * Retrieve Library instance information + * + * @param arch + * Architecture name + * @param usage + * Library instance usage + * + * @returns library instance name list if elements are found at the known + * xpath + * @returns null if nothing is there + */ + public static ModuleIdentification[] getLibraryInstance(String arch) { + String[] xPath; + String saGuid = null; + String saVersion = null; + String pkgGuid = null; + String pkgVersion = null; + + if (arch == null || arch.equalsIgnoreCase("")) { + xPath = new String[] { "/Instance" }; + } else { + xPath = new String[] { "/Instance[not(@SupArchList) or @SupArchList='" + + arch + "']" }; + } + + XmlObject[] returns = get("Libraries", xPath); + if (returns == null || returns.length == 0) { + return new ModuleIdentification[0]; + } + + ModuleIdentification[] saIdList = new ModuleIdentification[returns.length]; + for (int i = 0; i < returns.length; i++) { + LibrariesDocument.Libraries.Instance library = (LibrariesDocument.Libraries.Instance) returns[i]; + saGuid = library.getModuleGuid(); + saVersion = library.getModuleVersion(); + + pkgGuid = library.getPackageGuid(); + pkgVersion = library.getPackageVersion(); + + ModuleIdentification saId = new ModuleIdentification(null, saGuid, + saVersion); + PackageIdentification pkgId = new PackageIdentification(null, + pkgGuid, pkgVersion); + saId.setPackage(pkgId); + + saIdList[i] = saId; + + } + return saIdList; + } + + // / + // / This method is used for retrieving the elements information which has + // / CName sub-element + // / + private static String[] getCNames(String from, String xPath[]) { + XmlObject[] returns = get(from, xPath); + if (returns == null || returns.length == 0) { + return null; + } + + String[] strings = new String[returns.length]; + for (int i = 0; i < returns.length; ++i) { + // TBD + // strings[i] = ((CName) returns[i]).getStringValue(); + } + + return strings; + } + + /** + * Retrive library's constructor name + * + * @returns constructor name list if elements are found at the known xpath + * @returns null if nothing is there + */ + public static String getLibConstructorName() { + String[] xPath = new String[] { "/Extern/Constructor" }; + + XmlObject[] returns = get("Externs", xPath); + if (returns != null && returns.length > 0) { + // CName constructor = (CName) returns[0]; + // return constructor.getStringValue(); + } + + return null; + } + + /** + * Retrive library's destructor name + * + * @returns destructor name list if elements are found at the known xpath + * @returns null if nothing is there + */ + public static String getLibDestructorName() { + String[] xPath = new String[] { "/Extern/Destructor" }; + + XmlObject[] returns = get("Externs", xPath); + if (returns != null && returns.length > 0) { + // CName destructor = (CName) returns[0]; + // return destructor.getStringValue(); + } + + return null; + } + + /** + * Retrive DriverBinding names + * + * @returns DriverBinding name list if elements are found at the known xpath + * @returns null if nothing is there + */ + public static String[] getDriverBindingArray() { + String[] xPath = new String[] { "/Extern/DriverBinding" }; + return getCNames("Externs", xPath); + } + + /** + * Retrive ComponentName names + * + * @returns ComponentName name list if elements are found at the known xpath + * @returns null if nothing is there + */ + public static String[] getComponentNameArray() { + String[] xPath = new String[] { "/Extern/ComponentName" }; + return getCNames("Externs", xPath); + } + + /** + * Retrive DriverConfig names + * + * @returns DriverConfig name list if elements are found at the known xpath + * @returns null if nothing is there + */ + public static String[] getDriverConfigArray() { + String[] xPath = new String[] { "/Extern/DriverConfig" }; + return getCNames("Externs", xPath); + } + + /** + * Retrive DriverDiag names + * + * @returns DriverDiag name list if elements are found at the known xpath + * @returns null if nothing is there + */ + public static String[] getDriverDiagArray() { + String[] xPath = new String[] { "/Extern/DriverDiag" }; + return getCNames("Externs", xPath); + } + + /** + * Retrive SetVirtualAddressMapCallBack names + * + * @returns SetVirtualAddressMapCallBack name list if elements are found at + * the known xpath + * @returns null if nothing is there + */ + public static String[] getSetVirtualAddressMapCallBackArray() { + String[] xPath = new String[] { "/Extern/SetVirtualAddressMapCallBack" }; + return getCNames("Externs", xPath); + } + + /** + * Retrive ExitBootServicesCallBack names + * + * @returns ExitBootServicesCallBack name list if elements are found at the + * known xpath + * @returns null if nothing is there + */ + public static String[] getExitBootServicesCallBackArray() { + String[] xPath = new String[] { "/Extern/ExitBootServicesCallBack" }; + return getCNames("Externs", xPath); + } + + /** + * Retrieve module surface area file information + * + * @returns ModuleSA objects list if elements are found at the known xpath + * @returns Empty ModuleSA list if nothing is there + */ + public static Map> getFpdModules() { + String[] xPath = new String[] { "/FrameworkModules/ModuleSA" }; + XmlObject[] result = get("FrameworkPlatformDescription", xPath); + String arch = null; + String fvBinding = null; + String saGuid = null; + String saVersion = null; + String pkgGuid = null; + String pkgVersion = null; + + Map> fpdModuleMap = new LinkedHashMap>(); + + if (result == null) { + return fpdModuleMap; + } + + for (int i = 0; i < result.length; i++) { + // + // Get Fpd SA Module element node and add to xmlObjectMap. + // + Map xmlObjectMap = new HashMap(); + ModuleSADocument.ModuleSA moduleSA = (ModuleSADocument.ModuleSA) result[i]; + if (((ModuleSADocument.ModuleSA) result[i]).getLibraries() != null) { + xmlObjectMap.put("Libraries", moduleSA.getLibraries()); + } + if (((ModuleSADocument.ModuleSA) result[i]).getPcdBuildDefinition() != null) { + xmlObjectMap.put("PcdBuildDefinition", moduleSA + .getPcdBuildDefinition()); + } + if (((ModuleSADocument.ModuleSA) result[i]) + .getModuleSaBuildOptions() != null) { + xmlObjectMap.put("ModuleSaBuildOptions", moduleSA + .getModuleSaBuildOptions()); + } + + // + // Get Fpd SA Module attribute and create FpdMoudleIdentification. + // + arch = moduleSA.getSupArchList().toString(); + + // TBD + fvBinding = null; + saVersion = ((ModuleSADocument.ModuleSA) result[i]) + .getModuleVersion(); + + saGuid = moduleSA.getModuleGuid(); + pkgGuid = moduleSA.getPackageGuid(); + pkgVersion = moduleSA.getPackageVersion(); + + // + // Create Module Identification which have class member of package + // identification. + // + PackageIdentification pkgId = new PackageIdentification(null, + pkgGuid, pkgVersion); + ModuleIdentification saId = new ModuleIdentification(null, saGuid, + saVersion); + + saId.setPackage(pkgId); + + // + // Create FpdModule Identification which have class member of module + // identification + // + FpdModuleIdentification fpdSaId = new FpdModuleIdentification(saId, + arch); + if (arch != null) { + fpdSaId.setArch(arch); + } + if (fvBinding != null) { + fpdSaId.setFvBinding(fvBinding); + } + + // + // Put element to Map>. + // + fpdModuleMap.put(fpdSaId, xmlObjectMap); + } + return fpdModuleMap; + } + + /** + * Retrieve valid image names + * + * @returns valid iamges name list if elements are found at the known xpath + * @returns empty list if nothing is there + */ + public static String[] getFpdValidImageNames() { + String[] xPath = new String[] { "/PlatformDefinitions/FlashDeviceDefinitions/FvImages/FvImage[@Type='ValidImageNames']/FvImageNames" }; + + XmlObject[] queryResult = get("FrameworkPlatformDescription", xPath); + if (queryResult == null) { + return new String[0]; + } + + String[] result = new String[queryResult.length]; + for (int i = 0; i < queryResult.length; i++) { + result[i] = ((XmlString) queryResult[i]).getStringValue(); + } + + return result; + } + + + + public static XmlObject getFpdBuildOptions() { + String[] xPath = new String[] { "/BuildOptions" }; + + XmlObject[] queryResult = get("FrameworkPlatformDescription", xPath); + + if (queryResult == null || queryResult.length == 0) { + return null; + } + return queryResult[0]; + } + + public static PlatformIdentification getFpdHeader() { + String[] xPath = new String[] { "/PlatformHeader" }; + + XmlObject[] returns = get("FrameworkPlatformDescription", xPath); + + if (returns == null || returns.length == 0) { + return null; + } + PlatformHeaderDocument.PlatformHeader header = (PlatformHeaderDocument.PlatformHeader) returns[0]; + + String name = header.getPlatformName(); + + String guid = header.getGuidValue(); + + String version = header.getVersion(); + + return new PlatformIdentification(name, guid, version); + } + + /** + * Retrieve flash definition file name + * + * @returns file name if elements are found at the known xpath + * @returns null if nothing is there + */ + public static String getFlashDefinitionFile() { + String[] xPath = new String[] { "/PlatformDefinitions/FlashDeviceDefinitions/FlashDefinitionFile" }; + + XmlObject[] queryResult = get("FrameworkPlatformDescription", xPath); + if (queryResult == null || queryResult.length == 0) { + return null; + } + + FileNameConvention filename = (FileNameConvention) queryResult[queryResult.length - 1]; + return filename.getStringValue(); + } + + /** + * Retrieve FV image component options + * + * @param fvName + * FV image name + * + * @returns name/value pairs list if elements are found at the known xpath + * @returns empty list if nothing is there + */ + public static String[][] getFpdComponents(String fvName) { + String[] xPath = new String[] { "/PlatformDefinitions/FlashDeviceDefinitions/DataRegions/FvDataRegion[@Name='" + + fvName.toUpperCase() + "']/DataId" }; + + XmlObject[] queryResult = get("FrameworkPlatformDescription", xPath); + if (queryResult == null) { + return new String[0][]; + } + + ArrayList list = new ArrayList(); + for (int i = 0; i < queryResult.length; i++) { + DataIdDocument.DataId item = (DataIdDocument.DataId) queryResult[i]; + list + .add(new String[] { item.getStringValue(), + item.getDataSize() }); + } + + String[][] result = new String[list.size()][2]; + for (int i = 0; i < list.size(); i++) { + result[i][0] = list.get(i)[0]; + result[i][1] = list.get(i)[1]; + } + + return result; + } + + /** + * Retrieve PCD tokens + * + * @returns CName/ItemType pairs list if elements are found at the known + * xpath + * @returns null if nothing is there + */ + public static String[][] getPcdTokenArray() { + String[] xPath = new String[] { "/PcdData" }; + + XmlObject[] returns = get("PCDs", xPath); + if (returns == null || returns.length == 0) { + return null; + } + + // PcdCoded.PcdData[] pcds = (PcdCoded.PcdData[]) returns; + // String[][] result = new String[pcds.length][2]; + // for (int i = 0; i < returns.length; ++i) { + // if (pcds[i].getItemType() != null) { + // result[i][1] = pcds[i].getItemType().toString(); + // } else { + // result[i][1] = null; + // } + // result[i][0] = pcds[i].getCName(); + // } + + return null; + } + + /** + * Get the PcdToken array from module's surface area document. The array + * should contains following data: + *

+ * ------------------------------------------------------------------- + *

+ *

+ * CName | ItemType | TokenspaceName | DefaultValue | Usage | HelpText + *

+ *

+ * ------------------------------------------------------------------- + *

+ *

+ * Note: Until new schema applying, now we can only get CName, ItemType, + *

+ * + * @return 2-array table contains all information of PCD token retrieved + * from MSA. + */ + public static Object[][] etModulePCDTokenArray() { + return null; + // int index; + // Object[][] result; + // PCDs.PcdData[] pcds; + // String[] xPath = new String[] { "/PcdData" }; + // XmlObject[] returns = get("PCDs", xPath); + // + // if ((returns == null) || (returns.length == 0)) { + // return null; + // } + // + // pcds = (PCDs.PcdData[]) returns; + // result = new Object[pcds.length][6]; + // for (index = 0; index < pcds.length; index++) { + // // + // // Get CName + // // + // result[index][0] = pcds[index].getCName(); + // // + // // Get ItemType: FEATURE_FLAG, FIXED_AT_BUILD, PATCHABLE_IN_MODLE, + // // DYNAMIC, DYNAMIC_EX + // // + // if (pcds[index].getItemType() != null) { + // result[index][1] = pcds[index].getItemType().toString(); + // } else { + // result[index][1] = null; + // } + // + // // + // // BUGBUG: following field can *not* be got from current MSA until + // // schema changed. + // // + // // result [index][2] = pcds[index].getTokenSpaceName(); + // result[index][2] = null; + // result[index][3] = pcds[index].getDefaultValue(); + // // result [index][4] = pcds[index].getUsage (); + // result[index][4] = null; + // // result [index][5] = pcds[index].getHelpText (); + // result[index][5] = null; + // } + // return result; + } + + /** + * Retrieve MAS header + * + * @return + * @return + */ + public static ModuleIdentification getMsaHeader() { + String[] xPath = new String[] { "/" }; + XmlObject[] returns = get("MsaHeader", xPath); + + if (returns == null || returns.length == 0) { + return null; + } + + MsaHeader msaHeader = (MsaHeader) returns[0]; + // + // Get BaseName, ModuleType, GuidValue, Version + // which in MsaHeader. + // + String name = msaHeader.getModuleName(); + String moduleType = msaHeader.getModuleType().toString(); + String guid = msaHeader.getGuidValue(); + String version = msaHeader.getVersion(); + + ModuleIdentification moduleId = new ModuleIdentification(name, guid, + version); + + moduleId.setModuleType(moduleType); + + return moduleId; + } + + /** + * Retrieve Extern Specification + * + * @param + * + * @return String[] If have specification element in the String[0] + * If no specification element in the + * + */ + + public static String[] getExternSpecificaiton() { + String[] xPath = new String[] { "/Specification" }; + + XmlObject[] queryResult = get("Externs", xPath); + if (queryResult == null) { + return new String[0]; + } + + String[] specificationList = new String[queryResult.length]; + for (int i = 0; i < queryResult.length; i++) { + // specificationList[i] = ((SpecificationDocument.Specification) + // queryResult[i]) + // .getStringValue(); + } + return specificationList; + } + + /** + * Retreive MsaFile which in SPD + * + * @param + * @return String[][3] The string sequence is ModuleName, ModuleGuid, + * ModuleVersion, MsaFile String[0][] If no msafile in SPD + */ + public static String[] getSpdMsaFile() { + String[] xPath = new String[] { "/MsaFiles" }; + + XmlObject[] returns = get("PackageSurfaceArea", xPath); + if (returns == null) { + return new String[0]; + } + + List filenameList = ((MsaFilesDocument.MsaFiles) returns[0]) + .getFilenameList(); + return filenameList.toArray(new String[filenameList.size()]); + } + + /** + * Reteive + */ + public static Map getSpdLibraryClasses() { + String[] xPath = new String[] { "/LibraryClassDeclarations/LibraryClass" }; + + XmlObject[] returns = get("PackageSurfaceArea", xPath); + + // + // Create Map, Key - LibraryClass, String[] - LibraryClass Header file. + // + Map libClassHeaderMap = new HashMap(); + + if (returns == null) { + return libClassHeaderMap; + } + + for (int i = 0; i < returns.length; i++) { + LibraryClassDeclarationsDocument.LibraryClassDeclarations.LibraryClass library = (LibraryClassDeclarationsDocument.LibraryClassDeclarations.LibraryClass) returns[i]; + libClassHeaderMap.put(library.getName(), new String[] { library + .getIncludeHeader() }); + } + return libClassHeaderMap; + } + + /** + * Reteive + */ + public static Map getSpdPackageHeaderFiles() { + String[] xPath = new String[] { "/PackageHeaders/IncludePkgHeader" }; + + XmlObject[] returns = get("PackageSurfaceArea", xPath); + + // + // Create Map, Key - ModuleType, String - PackageInclude Header file. + // + Map packageIncludeMap = new HashMap(); + + if (returns == null) { + return packageIncludeMap; + } + GlobalData.log.info("" + returns[0].getClass().getName()); + for (int i = 0; i < returns.length; i++) { + PackageHeadersDocument.PackageHeaders.IncludePkgHeader includeHeader = (PackageHeadersDocument.PackageHeaders.IncludePkgHeader) returns[i]; + packageIncludeMap.put(includeHeader.getModuleType().toString(), + includeHeader.getStringValue()); + } + return packageIncludeMap; + } + + public static PackageIdentification getSpdHeader() { + String[] xPath = new String[] { "/SpdHeader" }; + + XmlObject[] returns = get("PackageSurfaceArea", xPath); + + if (returns == null || returns.length == 0) { + return null; + } + + SpdHeaderDocument.SpdHeader header = (SpdHeaderDocument.SpdHeader) returns[0]; + + String name = header.getPackageName(); + + String guid = header.getGuidValue(); + + String version = header.getVersion(); + + return new PackageIdentification(name, guid, version); + } + + /** + * Reteive + */ + public static Map getSpdGuid() { + String[] xPath = new String[] { "/GuidDeclarations/Entry" }; + + XmlObject[] returns = get("PackageSurfaceArea", xPath); + + // + // Create Map, Key - GuidName, String[] - C_NAME & GUID value. + // + Map guidDeclMap = new HashMap(); + if (returns == null) { + return guidDeclMap; + } + + for (int i = 0; i < returns.length; i++) { + GuidDeclarationsDocument.GuidDeclarations.Entry entry = (GuidDeclarationsDocument.GuidDeclarations.Entry) returns[i]; + String[] guidPair = new String[2]; + guidPair[0] = entry.getCName(); + guidPair[1] = entry.getGuidValue(); + guidDeclMap.put(entry.getName(), guidPair); + } + return guidDeclMap; + } + + /** + * Reteive + */ + public static Map getSpdProtocol() { + String[] xPath = new String[] { "/ProtocolDeclarations/Entry" }; + + XmlObject[] returns = get("PackageSurfaceArea", xPath); + + // + // Create Map, Key - protocolName, String[] - C_NAME & GUID value. + // + Map protoclMap = new HashMap(); + + if (returns == null) { + return protoclMap; + } + + for (int i = 0; i < returns.length; i++) { + ProtocolDeclarationsDocument.ProtocolDeclarations.Entry entry = (ProtocolDeclarationsDocument.ProtocolDeclarations.Entry) returns[i]; + String[] protocolPair = new String[2]; + + protocolPair[0] = entry.getCName(); + protocolPair[1] = entry.getGuidValue(); + protoclMap.put(entry.getName(), protocolPair); + } + return protoclMap; + } + + /** + * getSpdPpi() Retrieve the SPD PPI Entry + * + * @param + * @return Map if get the PPI entry from SPD. Key - PPI + * Name String[0] - PPI CNAME String[1] - PPI Guid Null if no PPI + * entry in SPD. + */ + public static Map getSpdPpi() { + String[] xPath = new String[] { "/PpiDeclarations/Entry" }; + + XmlObject[] returns = get("PackageSurfaceArea", xPath); + + // + // Create Map, Key - protocolName, String[] - C_NAME & GUID value. + // + Map ppiMap = new HashMap(); + + if (returns == null) { + return ppiMap; + } + + for (int i = 0; i < returns.length; i++) { + PpiDeclarationsDocument.PpiDeclarations.Entry entry = (PpiDeclarationsDocument.PpiDeclarations.Entry) returns[i]; + String[] ppiPair = new String[2]; + ppiPair[0] = entry.getCName(); + ppiPair[1] = entry.getGuidValue(); + ppiMap.put(entry.getName(), ppiPair); + } + return ppiMap; + } + + /** + * getModuleSupportedArchs() + * + * This function is to Retrieve Archs one module supported. + * + * @param + * @return supportArch String of supporting archs. null No arch specified in + * element. + */ + public static List getModuleSupportedArchs() { + String[] xPath = new String[] { "/ModuleDefinitions/SupportedArchitectures" }; + + XmlObject[] returns = get("ModuleSurfaceArea", xPath); + + if (returns == null) { + return null; + } + + return (List)returns[0]; + } + + public static XmlObject[] getSpdPcdDeclarations() { + String[] xPath = null; +// if (tsGuid != null){ +// xPath = new String[] { "/PcdDeclarations/PcdEntry[C_Name='" + cName + "' and TokenSpaceGuid='"+ tsGuid + "']" }; +// } +// else{ +// xPath = new String[] { "/PcdDeclarations/PcdEntry[C_Name='" + cName + "']" }; +// } + xPath = new String[] { "/PcdDeclarations/PcdEntry"}; + XmlObject[] returns = get("PackageSurfaceArea", xPath); + + return returns; + } + + public static XmlObject[] getFpdPcdBuildDefinitions(String cName, String tsGuid, String type) { + String[] xPath = new String[] { "/PcdBuildDefinition/PcdData[C_Name='" + cName + "' and TokenSpaceGuid='" + + tsGuid + "' and DatumType!='" + type + "']" }; + + XmlObject[] returns = get("ModuleSA", xPath); + + return returns; + } + /** + * getToolChainFamily + * + * This function is to retrieve ToolChainFamily attribute of FPD + * + * + * @param + * @return toolChainFamily If find toolChainFamily attribute in + * Null If don't have toolChainFamily in + * . + */ + public String getToolChainFamily() { + String toolChainFamily; + String[] xPath = new String[] { "/BuildOptions" }; + + XmlObject[] result = get("FrameworkPlatformDescription", xPath); + if (result == null) { + return null; + } + // toolChainFamily = + // ((BuildOptionsDocument.BuildOptions)result[0]).getToolChainFamilies(); + // return toolChainFamily; + return null; + } + + /** + * Retrieve module Guid string + * + * @returns GUILD string if elements are found at the known xpath + * @returns null if nothing is there + */ + public static String getModuleGuid() { + String[] xPath = new String[] { "" }; + + XmlObject[] returns = get("MsaHeader", xPath); + if (returns != null && returns.length > 0) { + String guid = ((MsaHeaderDocument.MsaHeader) returns[0]) + .getGuidValue(); + return guid; + } + + return null; + } + + // + // For new Pcd + // + public static ModuleSADocument.ModuleSA[] getFpdModuleSAs() { + String[] xPath = new String[] { "/FrameworkModules/ModuleSA" }; + XmlObject[] result = get("FrameworkPlatformDescription", xPath); + if (result != null) { + return (ModuleSADocument.ModuleSA[]) result; + } + return new ModuleSADocument.ModuleSA[0]; + + } +} diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/id/FpdModuleIdentification.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/id/FpdModuleIdentification.java new file mode 100644 index 0000000000..b9bb9e5ff3 --- /dev/null +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/id/FpdModuleIdentification.java @@ -0,0 +1,108 @@ +/** @file + Java class FpdModuleIdentification is used to present a module identification + from BaseName, GUID, Version, PackageName, and ARCH. + +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.id; + + +/** + This class is used to identify a module with BaseName, GUID, Version, PackageName + and ARCH. + + @since GenBuild 1.0 + **/ +public class FpdModuleIdentification { + + private String arch; + + private String fvBinding = "NULL"; // Optional + + private String sequence = "0"; // Optional + + private ModuleIdentification module; + + private String target; // Optional + + private String toolchain; // Optional + + public FpdModuleIdentification(String arch, String fvBinding, String sequence, ModuleIdentification module){ + this.arch = arch; + this.fvBinding = fvBinding; + this.sequence = sequence; + this.module = module; + } + + public FpdModuleIdentification(ModuleIdentification module, String arch){ + this.arch = arch; + this.module = module; + } + /** + Override java.lang.Object#equals. + +

Currently, use BaseName and ARCH to identify a module. It will enhance + in the next version.

+ + @see java.lang.Object#equals(java.lang.Object) + **/ + public boolean equals(Object obj) { + if (obj instanceof FpdModuleIdentification) { + FpdModuleIdentification moduleIdObj = (FpdModuleIdentification)obj; + if ( module.equals(moduleIdObj.module) && arch.equalsIgnoreCase(moduleIdObj.arch)) { + return true; + } + return false; + } + else { + return super.equals(obj); + } + } + + public void setFvBinding(String fvBinding) { + this.fvBinding = fvBinding; + } + + public void setSequence(String sequence) { + this.sequence = sequence; + } + + public String toString(){ + return arch + ":" + module; + } + + public String getFvBinding() { + return fvBinding; + } + + public String getSequence() { + return sequence; + } + + public ModuleIdentification getModule() { + return module; + } + + public void setModule(ModuleIdentification module) { + this.module = module; + } + + public String getArch() { + return arch; + } + + public void setArch(String arch) { + this.arch = arch; + } + + public int hashCode(){ + return module.hashCode(); + } +} diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/id/Identification.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/id/Identification.java new file mode 100644 index 0000000000..f22c1241d4 --- /dev/null +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/id/Identification.java @@ -0,0 +1,77 @@ +package org.tianocore.frameworkwizard.platform.ui.id; + +public class Identification { + + String name; + + String guid; + + String version; + + String type; // Optional + + Identification(String name, String guid, String version){ + this.name = name; + this.guid = guid; + this.version = version; + } + + public boolean equals(Object obj) { + if (obj instanceof Identification) { + Identification id = (Identification)obj; + if ( guid.equalsIgnoreCase(id.guid)) { + if (version == null || id.version == null) { + updateName(name, id.name); + return true; + } + else if (version.trim().equalsIgnoreCase("") || id.version.trim().equalsIgnoreCase("")){ + return true; + } + else if (version.equalsIgnoreCase(id.version)) { + return true; + } + } + return false; + } + else { + return super.equals(obj); + } + } + + void updateName(String name1, String name2) { + if (name1 == null) { + name1 = name2; + } + if (name2 == null) { + name2 = name1; + } + } + + public void setName(String name) { + this.name = name; + } + + public void setGuid(String guid) { + this.guid = guid; + } + + public void setVersion(String version) { + this.version = version; + } + + public String getGuid() { + return guid; + } + + public String getName() { + return name; + } + + public String getVersion() { + return version; + } + + public int hashCode(){ + return guid.hashCode(); + } +} diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/id/ModuleIdentification.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/id/ModuleIdentification.java new file mode 100644 index 0000000000..7409f9a886 --- /dev/null +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/id/ModuleIdentification.java @@ -0,0 +1,101 @@ +package org.tianocore.frameworkwizard.platform.ui.id; + +import java.io.File; + +import org.tianocore.frameworkwizard.platform.ui.global.GlobalData; + +public class ModuleIdentification extends Identification { + + private PackageIdentification packageId; + + private File msaFile; + + private String moduleType; + + private boolean isLibrary = false; + + public boolean isLibrary() { + return isLibrary; + } + + public void setLibrary(boolean isLibrary) { + this.isLibrary = isLibrary; + } + + public File getMsaFile() throws Exception{ + prepareMsaFile(); + return msaFile; + } + + public String getModuleRelativePath() throws Exception{ + prepareMsaFile(); + return msaFile.getParent().substring(packageId.getPackageDir().length() + 1); + } + + private void prepareMsaFile()throws Exception{ + if (msaFile == null) { + msaFile = GlobalData.getModuleFile(this); + } + } + public void setMsaFile(File msaFile) { + this.msaFile = msaFile; + } + + public ModuleIdentification(String name, String guid, String version){ + super(name, guid, version); + } + + public ModuleIdentification(String name, String guid, String version, PackageIdentification packageId){ + super(name, guid, version); + this.packageId = packageId; + } + + public boolean equals(Object obj) { + if (obj instanceof ModuleIdentification) { + ModuleIdentification id = (ModuleIdentification)obj; + if (guid.equals(id.getGuid()) && packageId.equals(id.getPackage())) { + if (version == null || id.version == null) { + updateName(name, id.name); + return true; + } + else if (version.trim().equalsIgnoreCase("") || id.version.trim().equalsIgnoreCase("")){ + updateName(name, id.name); + return true; + } + else if (version.equalsIgnoreCase(id.version)) { + updateName(name, id.name); + return true; + } + } + return false; + } + else { + return super.equals(obj); + } + } + + public String toString(){ + if (version == null || version.trim().equalsIgnoreCase("")) { + return "Module [" + name + "] in " + packageId; + } + else { + return "Module [" + name + " " + version + "] in " + packageId; + } + } + + public void setPackage(PackageIdentification packageId) { + this.packageId = packageId; + } + + public PackageIdentification getPackage() { + return packageId; + } + + public String getModuleType() { + return moduleType; + } + + public void setModuleType(String moduleType) { + this.moduleType = moduleType; + } +} diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/id/PackageIdentification.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/id/PackageIdentification.java new file mode 100644 index 0000000000..9ba5511e66 --- /dev/null +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/id/PackageIdentification.java @@ -0,0 +1,59 @@ +package org.tianocore.frameworkwizard.platform.ui.id; +import java.io.File; + +import org.tianocore.frameworkwizard.platform.ui.global.GlobalData; + +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 spdFilename){ + super(name, guid, version); + this.spdFile = new File(spdFilename); + } + + public PackageIdentification(String name, String guid, String version, File spdFile){ + super(name, guid, version); + this.spdFile = spdFile; + } + + public void setSpdFile(File spdFile) { + this.spdFile = spdFile; + } + + public File getSpdFile() { + return spdFile; + } + + public String toString(){ + if (version == null || version.trim().equalsIgnoreCase("")) { + return "package [" + name + "]"; + } + else { + return "package [" + name + " " + version + "]"; + } + } + + public String getPackageDir()throws Exception{ + prepareSpdFile(); + return spdFile.getParent(); + } + + public String getPackageRelativeDir()throws Exception{ + prepareSpdFile(); + return spdFile.getParent().substring(GlobalData.getWorkspacePath().length() + 1); + } + + private void prepareSpdFile() throws Exception{ + if (spdFile == null) { + spdFile = GlobalData.getPackageFile(this); + } + } +} diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/id/PlatformIdentification.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/id/PlatformIdentification.java new file mode 100644 index 0000000000..499c66939d --- /dev/null +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/id/PlatformIdentification.java @@ -0,0 +1,39 @@ +package org.tianocore.frameworkwizard.platform.ui.id; +import java.io.File; + +import org.tianocore.frameworkwizard.platform.ui.global.GlobalData; + +public class PlatformIdentification extends Identification{ + + private File fpdFile; + + public PlatformIdentification(String name, String guid, String version){ + super(name, guid, version); + } + + public PlatformIdentification(String name, String guid, String version, String fpdFilename){ + super(name, guid, version); + this.fpdFile = new File(fpdFilename); + } + + public PlatformIdentification(String name, String guid, String version, File fpdFile){ + super(name, guid, version); + this.fpdFile = fpdFile; + } + + public String toString(){ + return "Platform " + name + "["+guid+"]"; + } + + public void setFpdFile(File fpdFile) { + this.fpdFile = fpdFile; + } + + public File getFpdFile() { + return fpdFile; + } + + public String getPlatformRelativeDir(){ + return fpdFile.getParent().substring(GlobalData.getWorkspacePath().length()); + } +} \ No newline at end of file diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/workspace/Workspace.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/workspace/Workspace.java new file mode 100644 index 0000000000..40692c6526 --- /dev/null +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/workspace/Workspace.java @@ -0,0 +1,115 @@ +/** @file + + The file is used to init workspace + + Copyright (c) 2006, Intel Corporation + All rights reserved. This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + **/ + +package org.tianocore.frameworkwizard.workspace; + +import java.io.File; + +import org.tianocore.frameworkwizard.common.DataType; + +public class Workspace { + // + // Define class members + // + private static String currentWorkspace = null; + + private static String strWorkspaceDatabaseFile = DataType.FILE_SEPARATOR + "Tools" + DataType.FILE_SEPARATOR + + "Conf" + DataType.FILE_SEPARATOR + "FrameworkDatabase.db"; + + /** + + @param args + + **/ + public static void main(String[] args) { + // TODO Auto-generated method stub + + } + + /** + Get Current Workspace + + @return currentWorkspace + + */ + public static String getCurrentWorkspace() { + return currentWorkspace; + } + + /** + Set Current Workspace + + @param currentWorkspace + The input data of currentWorkspace + + */ + public static void setCurrentWorkspace(String currentWorkspace) { + Workspace.currentWorkspace = currentWorkspace; + } + + /** + Check if current workspace exists of not + + @retval true - The current WORKSPACE exists + @retval false - The current WORKSPACE doesn't exist + + */ + public static boolean checkCurrentWorkspace() { + return checkWorkspace(getCurrentWorkspace()); + } + + /** + Check if current workspace exists or not via input workspace path + + @param strWorkspace + The input data of WORKSPACE path + @retval true - The current WORKSPACE exists + @retval false - The current WORKSPACE doesn't exist + + */ + public static boolean checkWorkspace(String strWorkspace) { + if (strWorkspace == null || strWorkspace == "") { + return false; + } + // + // Check workspace directory + // + File f = new File(strWorkspace); + if (!f.isDirectory()) { + return false; + } + if (!f.exists()) { + return false; + } + + // + // Check FrameworkDatabase.db + // + f = new File(strWorkspace + Workspace.getStrWorkspaceDatabaseFile()); + if (!f.exists()) { + return false; + } + + return true; + } + + public static String getStrWorkspaceDatabaseFile() { + return strWorkspaceDatabaseFile; + } + + public static void setStrWorkspaceDatabaseFile(String strWorkspaceDatabaseFile) { + //Workspace.strWorkspaceDatabaseFile = strWorkspaceDatabaseFile; + } +} diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/workspace/WorkspaceTools.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/workspace/WorkspaceTools.java new file mode 100644 index 0000000000..c6432ac284 --- /dev/null +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/workspace/WorkspaceTools.java @@ -0,0 +1,574 @@ +/** @file + + The file is used to init workspace and get basic information of workspace + + Copyright (c) 2006, Intel Corporation + All rights reserved. This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + **/ +package org.tianocore.frameworkwizard.workspace; + +import java.io.IOException; +import java.util.Vector; + +import org.apache.xmlbeans.XmlException; +import org.tianocore.DbPathAndFilename; +import org.tianocore.FrameworkDatabaseDocument; +import org.tianocore.ModuleSurfaceAreaDocument.ModuleSurfaceArea; +import org.tianocore.MsaFilesDocument.MsaFiles; +import org.tianocore.MsaHeaderDocument.MsaHeader; +import org.tianocore.PackageSurfaceAreaDocument.PackageSurfaceArea; +import org.tianocore.PlatformHeaderDocument.PlatformHeader; +import org.tianocore.PlatformSurfaceAreaDocument.PlatformSurfaceArea; +import org.tianocore.SpdHeaderDocument.SpdHeader; +import org.tianocore.frameworkwizard.common.DataType; +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.module.Identification.ModuleIdentification; +import org.tianocore.frameworkwizard.packaging.PackageIdentification; +import org.tianocore.frameworkwizard.platform.PlatformIdentification; + +public class WorkspaceTools { + // + // Define class members + // + private FrameworkDatabaseDocument.FrameworkDatabase fdb = null; + + private Vector vModuleList = new Vector(); + + private Vector vPackageList = new Vector(); + + private Vector vPlatformList = new Vector(); + + /** + + Open Framework Database file + + */ + private void openFrameworkDb() { + String strFrameworkDbFilePath = Workspace.getCurrentWorkspace() + Workspace.getStrWorkspaceDatabaseFile(); + strFrameworkDbFilePath = Tools.convertPathToCurrentOsType(strFrameworkDbFilePath); + try { + fdb = OpenFile.openFrameworkDb(strFrameworkDbFilePath); + } catch (XmlException e) { + Log.err("Open Framework Database " + strFrameworkDbFilePath, e.getMessage()); + return; + } catch (Exception e) { + Log.err("Open Framework Database " + strFrameworkDbFilePath, "Invalid file type"); + return; + } + } + + /** + Get all modules' paths from one package + + @return a Vector with all modules' path + + **/ + public Vector getAllModulesOfPackage(String path) { + Vector modulePath = new Vector(); + try { + MsaFiles files = OpenFile.openSpdFile(path).getMsaFiles(); + if (files != null) { + for (int index = 0; index < files.getFilenameList().size(); index++) { + modulePath.addElement(files.getFilenameList().get(index)); + } + } + } catch (IOException e) { + e.printStackTrace(); + } catch (XmlException e) { + e.printStackTrace(); + } catch (Exception e) { + e.printStackTrace(); + } + return modulePath; + } + + /** + Get all package basic information form the FrameworkDatabase.db file + + @return vPackageList A vector includes all packages' basic information + + */ + public Vector getAllPackages() { + Identification id = null; + vPackageList.removeAllElements(); + + openFrameworkDb(); + + for (int index = 0; index < fdb.getPackageList().getFilenameList().size(); index++) { + String path = Workspace.getCurrentWorkspace() + DataType.FILE_SEPARATOR + + fdb.getPackageList().getFilenameArray(index).getStringValue(); + path = Tools.convertPathToCurrentOsType(path); + try { + id = getId(path, OpenFile.openSpdFile(path)); + vPackageList.addElement(new PackageIdentification(id)); + } catch (IOException e) { + Log.err("Open Package Surface Area " + path, e.getMessage()); + e.printStackTrace(); + } catch (XmlException e) { + Log.err("Open Package Surface Area " + path, e.getMessage()); + e.printStackTrace(); + } catch (Exception e) { + Log.err("Open Package Surface Area " + path, "Invalid file type"); + e.printStackTrace(); + } + } + return vPackageList; + } + + /** + Get all package basic information form the FrameworkDatabase.db file + + @return vPackageList A vector includes all packages' basic information + + */ + public Vector getAllModules() { + vModuleList.removeAllElements(); + // + // First get all packages + // + getAllPackages(); + Vector modulePaths = new Vector(); + Identification id = null; + String packagePath = null; + String modulePath = null; + + // + // For each package, get all modules list + // + for (int indexI = 0; indexI < vPackageList.size(); indexI++) { + packagePath = vPackageList.elementAt(indexI).getPath(); + modulePaths = this.getAllModulesOfPackage(packagePath); + packagePath = packagePath.substring(0, packagePath.lastIndexOf(DataType.FILE_SEPARATOR) + + DataType.FILE_SEPARATOR.length()); + for (int indexJ = 0; indexJ < modulePaths.size(); indexJ++) { + modulePath = Tools.convertPathToCurrentOsType(packagePath + modulePaths.elementAt(indexJ)); + try { + id = getId(modulePath, OpenFile.openMsaFile(modulePath)); + vModuleList.addElement(new ModuleIdentification(id, vPackageList.elementAt(indexI))); + } catch (IOException e) { + Log.err("Open Module Surface Area " + modulePath, e.getMessage()); + e.printStackTrace(); + } catch (XmlException e) { + Log.err("Open Module Surface Area " + modulePath, e.getMessage()); + e.printStackTrace(); + } catch (Exception e) { + Log.err("Open Module Surface Area " + modulePath, "Invalid file type"); + e.printStackTrace(); + } + } + } + + return vModuleList; + } + + /** + Get all platform basic information form the FrameworkDatabase.db file + + @return vplatformList A vector includes all platforms' basic information + + */ + public Vector getAllPlatforms() { + Identification id = null; + vPlatformList.removeAllElements(); + + openFrameworkDb(); + + for (int index = 0; index < fdb.getPlatformList().getFilenameList().size(); index++) { + String path = Workspace.getCurrentWorkspace() + DataType.FILE_SEPARATOR + + fdb.getPlatformList().getFilenameArray(index).getStringValue(); + path = Tools.convertPathToCurrentOsType(path); + try { + id = getId(path, OpenFile.openFpdFile(path)); + vPlatformList.addElement(new PlatformIdentification(id)); + } catch (IOException e) { + Log.err("Open Platform Surface Area " + path, e.getMessage()); + e.printStackTrace(); + } catch (XmlException e) { + Log.err("Open Platform Surface Area " + path, e.getMessage()); + e.printStackTrace(); + } catch (Exception e) { + Log.err("Open Platform Surface Area " + path, "Invalid file type"); + e.printStackTrace(); + } + } + return vPlatformList; + } + + /** + Get all Library Class Definitions from a package + + @return Vector + **/ + public Vector getAllLibraryClassDefinitionsFromPackage(PackageSurfaceArea spd) { + Vector vector = new Vector(); + if (spd.getLibraryClassDeclarations() != null) { + if (spd.getLibraryClassDeclarations().getLibraryClassList().size() > 0) { + for (int index = 0; index < spd.getLibraryClassDeclarations().getLibraryClassList().size(); index++) { + vector.addElement(spd.getLibraryClassDeclarations().getLibraryClassList().get(index).getName()); + } + } + } + return vector; + } + + /** + Get all Protocol Definitions from a package + + @return Vector + **/ + public Vector getAllProtocolDeclarationsFromPackage(PackageSurfaceArea spd) { + Vector vector = new Vector(); + if (spd.getProtocolDeclarations() != null) { + if (spd.getProtocolDeclarations().getEntryList().size() > 0) { + for (int index = 0; index < spd.getProtocolDeclarations().getEntryList().size(); index++) { + vector.addElement(spd.getProtocolDeclarations().getEntryList().get(index).getCName()); + } + } + } + return vector; + } + + /** + Get all Ppi Definitions from a package + + @return Vector + **/ + public Vector getAllPpiDeclarationsFromPackage(PackageSurfaceArea spd) { + Vector vector = new Vector(); + if (spd.getPpiDeclarations() != null) { + if (spd.getPpiDeclarations().getEntryList().size() > 0) { + for (int index = 0; index < spd.getPpiDeclarations().getEntryList().size(); index++) { + vector.addElement(spd.getPpiDeclarations().getEntryList().get(index).getCName()); + } + } + } + return vector; + } + + /** + Get all Guid Definitions from a package + + @return Vector + **/ + public Vector getAllGuidDeclarationsFromPackage(PackageSurfaceArea spd) { + Vector vector = new Vector(); + if (spd.getGuidDeclarations() != null) { + if (spd.getGuidDeclarations().getEntryList().size() > 0) { + for (int index = 0; index < spd.getGuidDeclarations().getEntryList().size(); index++) { + vector.addElement(spd.getGuidDeclarations().getEntryList().get(index).getCName()); + } + } + } + return vector; + } + + /** + Get all Pcd Definitions from a package + + @return Vector + **/ + public Vector getAllPcdDeclarationsFromPackage(PackageSurfaceArea spd) { + Vector vector = new Vector(); + if (spd.getPcdDeclarations() != null) { + if (spd.getPcdDeclarations().getPcdEntryList().size() > 0) { + for (int index = 0; index < spd.getPcdDeclarations().getPcdEntryList().size(); index++) { + vector.addElement(spd.getPcdDeclarations().getPcdEntryList().get(index).getCName()); + } + } + } + return vector; + } + + public Vector getAllLibraryClassDefinitionsFromWorkspace() { + // + // First get all packages + // + this.getAllPackages(); + + Vector vector = new Vector(); + for (int index = 0; index < this.vPackageList.size(); index++) { + try { + Vector v = getAllLibraryClassDefinitionsFromPackage(OpenFile + .openSpdFile(vPackageList + .get(index) + .getPath())); + if (v != null && v.size() > 0) { + vector.addAll(v); + } + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (XmlException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + return vector; + } + + public Vector getAllProtocolDeclarationsFromWorkspace() { + // + // First get all packages + // + this.getAllPackages(); + + Vector vector = new Vector(); + for (int index = 0; index < this.vPackageList.size(); index++) { + try { + Vector v = getAllProtocolDeclarationsFromPackage(OpenFile.openSpdFile(vPackageList.get(index) + .getPath())); + if (v != null && v.size() > 0) { + vector.addAll(v); + } + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (XmlException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + return vector; + } + + public Vector getAllPpiDeclarationsFromWorkspace() { + // + // First get all packages + // + this.getAllPackages(); + + Vector vector = new Vector(); + for (int index = 0; index < this.vPackageList.size(); index++) { + try { + Vector v = getAllPpiDeclarationsFromPackage(OpenFile.openSpdFile(vPackageList.get(index) + .getPath())); + if (v != null && v.size() > 0) { + vector.addAll(v); + } + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (XmlException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + return vector; + } + + public Vector getAllGuidDeclarationsFromWorkspace() { + // + // First get all packages + // + this.getAllPackages(); + + Vector vector = new Vector(); + for (int index = 0; index < this.vPackageList.size(); index++) { + try { + Vector v = getAllGuidDeclarationsFromPackage(OpenFile.openSpdFile(vPackageList.get(index) + .getPath())); + if (v != null && v.size() > 0) { + vector.addAll(v); + } + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (XmlException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + return vector; + } + + public Vector getAllPcdDeclarationsFromWorkspace() { + // + // First get all packages + // + this.getAllPackages(); + + Vector vector = new Vector(); + for (int index = 0; index < this.vPackageList.size(); index++) { + try { + Vector v = getAllPcdDeclarationsFromPackage(OpenFile.openSpdFile(vPackageList.get(index) + .getPath())); + if (v != null && v.size() > 0) { + vector.addAll(v); + } + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (XmlException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + return vector; + } + + /** + Find a module's package's id + + @param id input module id + @return package id + + **/ + public PackageIdentification getPackageIdByModuleId(Identification id) { + getAllPackages(); + Vector modulePaths = new Vector(); + Identification mid = null; + String packagePath = null; + String modulePath = null; + + // + // For each package, get all modules list + // + for (int indexI = 0; indexI < vPackageList.size(); indexI++) { + packagePath = vPackageList.elementAt(indexI).getPath(); + modulePaths = this.getAllModulesOfPackage(packagePath); + packagePath = packagePath.substring(0, packagePath.lastIndexOf(DataType.FILE_SEPARATOR) + + DataType.FILE_SEPARATOR.length()); + for (int indexJ = 0; indexJ < modulePaths.size(); indexJ++) { + modulePath = Tools.convertPathToCurrentOsType(packagePath + modulePaths.elementAt(indexJ)); + try { + mid = getId(modulePath, OpenFile.openMsaFile(modulePath)); + // + // Check id + // + if (mid.equals(id)) { + return vPackageList.elementAt(indexI); + } + } catch (IOException e) { + e.printStackTrace(); + } catch (XmlException e) { + e.printStackTrace(); + } catch (Exception e) { + e.printStackTrace(); + } + } + } + + return null; + } + + public Identification getId(String path, ModuleSurfaceArea msa) { + MsaHeader head = msa.getMsaHeader(); + String name = head.getModuleName(); + String guid = head.getGuidValue(); + String version = head.getVersion(); + Identification id = new Identification(name, guid, version, path); + return id; + } + + public Identification getId(String path, PackageSurfaceArea spd) { + SpdHeader head = spd.getSpdHeader(); + String name = head.getPackageName(); + String guid = head.getGuidValue(); + String version = head.getVersion(); + Identification id = new Identification(name, guid, version, path); + return id; + } + + public Identification getId(String path, PlatformSurfaceArea fpd) { + PlatformHeader head = fpd.getPlatformHeader(); + String name = head.getPlatformName(); + String guid = head.getGuidValue(); + String version = head.getVersion(); + Identification id = new Identification(name, guid, version, path); + return id; + } + + /** + Add module information to package surface area + + @param mid + @throws IOException + @throws XmlException + @throws Exception + + **/ + public void addModuleToPackage(ModuleIdentification mid, PackageSurfaceArea spd) throws IOException, XmlException, + Exception { + String packagePath = mid.getPackageId().getPath(); + String modulePath = mid.getPath(); + if (spd == null) { + spd = OpenFile.openSpdFile(packagePath); + } + MsaFiles msaFile = spd.getMsaFiles(); + if (msaFile == null) { + msaFile = MsaFiles.Factory.newInstance(); + } + packagePath = packagePath.substring(0, packagePath.lastIndexOf(DataType.FILE_SEPARATOR)); + String fn = Tools.getRelativePath(modulePath, packagePath); + msaFile.addNewFilename(); + msaFile.setFilenameArray(msaFile.getFilenameList().size() - 1, fn); + spd.setMsaFiles(msaFile); + SaveFile.saveSpdFile(mid.getPackageId().getPath(), spd); + } + + /** + Add input package into database + + @param id + * @throws Exception + + **/ + public void addPackageToDatabase(PackageIdentification id) throws Exception { + String path = id.getPath(); + path = Tools.getRelativePath(path, Workspace.getCurrentWorkspace()); + this.openFrameworkDb(); + DbPathAndFilename filename = DbPathAndFilename.Factory.newInstance(); + filename.setStringValue(path); + fdb.getPackageList().addNewFilename(); + fdb.getPackageList().setFilenameArray(fdb.getPackageList().sizeOfFilenameArray() - 1, filename); + String strFrameworkDbFilePath = Workspace.getCurrentWorkspace() + Workspace.getStrWorkspaceDatabaseFile(); + strFrameworkDbFilePath = Tools.convertPathToCurrentOsType(strFrameworkDbFilePath); + SaveFile.saveDbFile(strFrameworkDbFilePath, fdb); + } + + /** + Add input package into database + + @param id + * @throws Exception + + **/ + public void addPlatformToDatabase(PlatformIdentification id) throws Exception { + String path = id.getPath(); + path = Tools.getRelativePath(path, Workspace.getCurrentWorkspace()); + this.openFrameworkDb(); + DbPathAndFilename filename = DbPathAndFilename.Factory.newInstance(); + filename.setStringValue(path); + fdb.getPlatformList().addNewFilename(); + fdb.getPlatformList().setFilenameArray(fdb.getPlatformList().sizeOfFilenameArray() - 1, filename); + String strFrameworkDbFilePath = Workspace.getCurrentWorkspace() + Workspace.getStrWorkspaceDatabaseFile(); + strFrameworkDbFilePath = Tools.convertPathToCurrentOsType(strFrameworkDbFilePath); + SaveFile.saveDbFile(strFrameworkDbFilePath, fdb); + } +} diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/workspace/ui/SwitchWorkspace.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/workspace/ui/SwitchWorkspace.java new file mode 100644 index 0000000000..0db3b435fe --- /dev/null +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/workspace/ui/SwitchWorkspace.java @@ -0,0 +1,226 @@ +package org.tianocore.frameworkwizard.workspace.ui; + +import java.awt.event.ActionEvent; + +import javax.swing.JFileChooser; +import javax.swing.JPanel; +import javax.swing.JLabel; +import javax.swing.JTextField; +import javax.swing.JButton; + +import org.tianocore.frameworkwizard.common.DataType; +import org.tianocore.frameworkwizard.common.Log; +import org.tianocore.frameworkwizard.common.Tools; +import org.tianocore.frameworkwizard.common.ui.IDialog; +import org.tianocore.frameworkwizard.common.ui.IFrame; +import org.tianocore.frameworkwizard.workspace.Workspace; + +public class SwitchWorkspace extends IDialog { + + /// + /// Define class Serial Version UID + /// + private static final long serialVersionUID = 2184556370155608202L; + + // + // Define class members + // + private JPanel jContentPane = null; + + private JLabel jLabel = null; + + private JLabel jLabel1 = null; + + private JTextField jTextFieldOld = null; + + private JTextField jTextFieldNew = null; + + private JButton jButtonOk = null; + + private JButton jButtonCancel = null; + + private JButton jButtonBrowse = null; + + /** + * This method initializes jTextFieldOld + * + * @return javax.swing.JTextField + */ + private JTextField getJTextFieldOld() { + if (jTextFieldOld == null) { + jTextFieldOld = new JTextField(); + jTextFieldOld.setBounds(new java.awt.Rectangle(140, 10, 320, 20)); + jTextFieldOld.setEditable(false); + jTextFieldOld.setText(Workspace.getCurrentWorkspace()); + } + return jTextFieldOld; + } + + /** + * This method initializes jTextFieldNew + * + * @return javax.swing.JTextField + */ + private JTextField getJTextFieldNew() { + if (jTextFieldNew == null) { + jTextFieldNew = new JTextField(); + jTextFieldNew.setBounds(new java.awt.Rectangle(140, 35, 220, 20)); + } + return jTextFieldNew; + } + + /** + * This method initializes jButtonOk + * + * @return javax.swing.JButton + */ + private JButton getJButtonOk() { + if (jButtonOk == null) { + jButtonOk = new JButton(); + jButtonOk.setBounds(new java.awt.Rectangle(290, 70, 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(380, 70, 80, 20)); + jButtonCancel.setText("Cancel"); + jButtonCancel.addActionListener(this); + } + return jButtonCancel; + } + + /** + * This method initializes jButtonBrowse + * + * @return javax.swing.JButton + */ + private JButton getJButtonBrowse() { + if (jButtonBrowse == null) { + jButtonBrowse = new JButton(); + jButtonBrowse.setBounds(new java.awt.Rectangle(370, 35, 90, 20)); + jButtonBrowse.setText("Browse"); + jButtonBrowse.addActionListener(this); + } + return jButtonBrowse; + } + + /** + + @param args + + **/ + public static void main(String[] args) { + // TODO Auto-generated method stub + + } + + /** + * This is the default constructor + * + */ + public SwitchWorkspace() { + super(); + initialize(); + } + + /** + * This is the override constructor + * + */ + public SwitchWorkspace(IFrame parentFrame, boolean modal) { + super(parentFrame, modal); + initialize(); + } + + /** + * This method initializes this + * + * @return void + */ + private void initialize() { + this.setSize(472, 132); + this.setContentPane(getJContentPane()); + this.setTitle("Change workspace"); + this.centerWindow(); + } + + /** + * This method initializes jContentPane + * + * @return javax.swing.JPanel + */ + private JPanel getJContentPane() { + if (jContentPane == null) { + jLabel1 = new JLabel(); + jLabel1.setBounds(new java.awt.Rectangle(15, 10, 120, 20)); + jLabel1.setText("Current Workspace"); + jLabel = new JLabel(); + jLabel.setBounds(new java.awt.Rectangle(15, 35, 120, 20)); + jLabel.setText("Change to "); + jContentPane = new JPanel(); + jContentPane.setLayout(null); + jContentPane.add(jLabel, null); + jContentPane.add(jLabel1, null); + jContentPane.add(getJTextFieldOld(), null); + jContentPane.add(getJTextFieldNew(), null); + jContentPane.add(getJButtonOk(), null); + jContentPane.add(getJButtonCancel(), null); + jContentPane.add(getJButtonBrowse(), null); + } + return jContentPane; + } + + private boolean check() { + if (isEmpty(this.jTextFieldNew.getText())) { + Log.err("New workspace can't be empty!"); + return false; + } + if (!Workspace.checkWorkspace(this.jTextFieldNew.getText())) { + Log.err("Please select a valid workspace!"); + return false; + } + return true; + } + + /* (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() == jButtonOk) { + if (!check()) { + return; + } else { + this.setVisible(false); + Workspace.setCurrentWorkspace(this.jTextFieldNew.getText()); + returnType = DataType.RETURN_TYPE_OK; + } + } + + if (arg0.getSource() == jButtonBrowse) { + JFileChooser fc = new JFileChooser(); + fc.setAcceptAllFileFilterUsed(false); + fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); + int result = fc.showOpenDialog(new JPanel()); + if (result == JFileChooser.APPROVE_OPTION) { + this.jTextFieldNew.setText(Tools.convertPathToCurrentOsType(fc.getSelectedFile().getPath())); + } + } + } +} diff --git a/Tools/bin/FrameworkWizard.bat b/Tools/bin/FrameworkWizard.bat new file mode 100644 index 0000000000..ef7745980c --- /dev/null +++ b/Tools/bin/FrameworkWizard.bat @@ -0,0 +1,64 @@ +@REM +@REM Copyright (c) 2006, Intel Corporation +@REM All rights reserved. This program and the accompanying materials +@REM are licensed and made available under the terms and conditions of the BSD License +@REM which accompanies this distribution. The full text of the license may be found at +@REM http://opensource.org/licenses/bsd-license.php +@REM +@REM THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +@REM WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +@REM + +@echo on + +:check_java +if "%JAVA_HOME%"=="" goto no_jdk +:check_wks +if "%WORKSPACE%"=="" goto no_wks +:check_ant +if "%ANT_HOME%"=="" goto no_ant +:check_xmlbeans +if "%XMLBEANS_HOME%"=="" goto no_xmlbeans + +set PATH=%JAVA_HOME%\bin;%ANT_HOME%\bin;%WORKSPACE%\Tools\bin;%XMLBEANS_HOME%\bin;%PATH% + +set CLASSPATH=%CLASSPATH%;%WORKSPACE%\Tools\Jars\SurfaceArea.jar;%XMLBEANS_HOME%\lib\jsr173_1.0_api.jar;%XMLBEANS_HOME%\lib\xbean.jar;%XMLBEANS_HOME%\lib\xbean_xpath.jar;%XMLBEANS_HOME%\lib\xmlpublic.jar;%XMLBEANS_HOME%\lib\saxon8.jar;%XMLBEANS_HOME%\lib\resolver.jar;%WORKSPACE%\Tools\bin\FrameworkWizard.jar;. + +@REM Build SurfaceArea first +call "ant" -f %WORKSPACE%\Tools\build.xml SurfaceArea + +@REM Build ModuleEditor +call "ant" -f %WORKSPACE%\Tools\Source\FrameworkWizard\build.xml + +@REM Run ModuleEditor +call "java" org.tianocore.frameworkwizard.FrameworkWizardUI + +goto end + +:no_jdk +echo. +echo !!! Please set JAVA_HOME !!! +echo. +goto check_wks + +:no_wks +echo. +echo !!! Please set WORKSPACE !!! +echo. +goto check_ant + +:no_ant +echo. +echo !!! Please set ANT_HOME !!! +echo. +goto check_xmlbeans + +:no_xmlbeans +echo. +echo !!! Please set XMLBEANS_HOME !!! +echo. +goto end + +:end +@echo on + diff --git a/Tools/bin/PackageEditor.bat b/Tools/bin/PackageEditor.bat deleted file mode 100644 index cf2f909ce6..0000000000 --- a/Tools/bin/PackageEditor.bat +++ /dev/null @@ -1,72 +0,0 @@ -@REM -@REM Copyright (c) 2006, Intel Corporation -@REM All rights reserved. This program and the accompanying materials -@REM are licensed and made available under the terms and conditions of the BSD License -@REM which accompanies this distribution. The full text of the license may be found at -@REM http://opensource.org/licenses/bsd-license.php -@REM -@REM THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -@REM WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -@REM - -@echo off - -:check_java -if "%JAVA_HOME%"=="" goto no_jdk - -:check_wks -if "%WORKSPACE%"=="" goto no_wks - -:check_ant -if "%ANT_HOME%"=="" goto no_ant -@REM set ANT_HOME=%WORKSPACE%\Tools\bin\apache-ant - -:check_xmlbeans -if "%XMLBEANS_HOME"=="" goto no_xmlbeans -@REM set XMLBEANS_HOME=%WORKSPACE%\Tools\bin\xmlbeans - -set Framework_Tools_Path=%WORKSPACE%\Tools\bin - -set PATH=%JAVA_HOME%\bin;%ANT_HOME%\bin;%WORKSPACE%\Tools\bin;%XMLBEANS_HOME%\bin;%PATH% - -set CLASSPATH=%WORKSPACE%\Tools\Jars\SurfaceArea.jar;%WORKSPACE%\Tools\Jars\GenBuild.jar -set CLASSPATH=%CLASSPATH%;%WORKSPACE%\Tools\Jars\cpptasks.jar;%WORKSPACE%\Tools\Jars\frameworktasks.jar -set CLASSPATH=%CLASSPATH%;%XMLBEANS_HOME%\lib\jsr173_1.0_api.jar;%XMLBEANS_HOME%\lib\xbean.jar -set CLASSPATH=%CLASSPATH%;%XMLBEANS_HOME%\lib\xbean_xpath.jar;%XMLBEANS_HOME%\lib\xmlpublic.jar -set CLASSPATH=%CLASSPATH%;%XMLBEANS_HOME%\lib\saxon8.jar;%XMLBEANS_HOME%\lib\saxon8-jdom.jar -set CLASSPATH=%CLASSPATH%;%XMLBEANS_HOME%\lib\saxon8-sql.jar;%XMLBEANS_HOME%\lib\resolver.jar -set CLASSPATH=%CLASSPATH%;%WORKSPACE%\Tools\bin\PackageEditor.jar - -call "ant" -f %WORKSPACE%\Tools\Source\PackageEditor\build.xml - -call "java" org.tianocore.packaging.PackagingMain - -goto end - -:no_jdk -echo. -echo !!! Please set JAVA_HOME !!! -echo. -goto check_wks - -:no_wks -echo. -echo !!! Please set WORKSPACE !!! -echo. -goto check_ant - -:no_ant -echo. -echo !!! Please set ANT_HOME !!! -echo. -goto check_xmlbeans - -:no_xmlbeans -echo. -echo !!! Please set XMLBEANS_HOME !!! -echo. -goto end - -:end -@echo on -