-/** @file\r
- \r
- The file is used to create, update Module Definitions of MSA file\r
- \r
- Copyright (c) 2006, Intel Corporation\r
- All rights reserved. This program and the accompanying materials\r
- are licensed and made available under the terms and conditions of the BSD License\r
- which accompanies this distribution. The full text of the license may be found at\r
- http://opensource.org/licenses/bsd-license.php\r
- \r
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
- \r
- **/\r
-package org.tianocore.frameworkwizard.module.ui;\r
-\r
-import java.awt.event.ComponentEvent;\r
-import java.awt.event.FocusEvent;\r
-\r
-import javax.swing.JPanel;\r
-import javax.swing.JScrollPane;\r
-import javax.swing.JLabel;\r
-import javax.swing.JTextField;\r
-import javax.swing.JComboBox;\r
-\r
-import org.tianocore.ModuleDefinitionsDocument;\r
-import org.tianocore.ModuleSurfaceAreaDocument;\r
-import org.tianocore.ModuleDefinitionsDocument.ModuleDefinitions.ClonedFrom;\r
-import org.tianocore.frameworkwizard.common.DataValidation;\r
-import org.tianocore.frameworkwizard.common.EnumerationData;\r
-import org.tianocore.frameworkwizard.common.Log;\r
-import org.tianocore.frameworkwizard.common.Tools;\r
-import org.tianocore.frameworkwizard.common.Identifications.OpeningModuleType;\r
-import org.tianocore.frameworkwizard.common.ui.IInternalFrame;\r
-import org.tianocore.frameworkwizard.common.ui.StarLabel;\r
-import org.tianocore.frameworkwizard.common.ui.iCheckBoxList.ICheckBoxList;\r
-\r
-public class ModuleDefinitions extends IInternalFrame {\r
-\r
- ///\r
- /// Define class Serial Version UID\r
- ///\r
- private static final long serialVersionUID = 5860378543553036323L;\r
-\r
- private JScrollPane jScrollPane = null;\r
-\r
- private JPanel jContentPane = null;\r
-\r
- private JLabel jLabelArch = null;\r
-\r
- private ICheckBoxList iCheckBoxListArch = null;\r
-\r
- private JLabel jLabelBinaryModule = null;\r
-\r
- private JComboBox jComboBoxBinaryModule = null;\r
-\r
- private JLabel jLabelOutputFileBasename = null;\r
-\r
- private JTextField jTextFieldOutputFileBasename = null;\r
-\r
- private JScrollPane jScrollPaneArch = null;\r
-\r
- private StarLabel jStarLabel1 = null;\r
-\r
- private StarLabel jStarLabel2 = null;\r
-\r
- private StarLabel jStarLabel3 = null;\r
-\r
- private OpeningModuleType omt = null;\r
-\r
- private ClonedFrom cf = null;\r
-\r
- private ModuleSurfaceAreaDocument.ModuleSurfaceArea msa = null;\r
-\r
- private ModuleDefinitionsDocument.ModuleDefinitions md = null;\r
-\r
- /**\r
- * This method initializes jScrollPane \r
- * \r
- * @return javax.swing.JScrollPane \r
- */\r
- private JScrollPane getJScrollPane() {\r
- if (jScrollPane == null) {\r
- jScrollPane = new JScrollPane();\r
- jScrollPane.setViewportView(getJContentPane());\r
- }\r
- return jScrollPane;\r
- }\r
-\r
- /**\r
- * This method initializes jPanel \r
- * \r
- * @return javax.swing.JPanel \r
- */\r
- private JPanel getJContentPane() {\r
- if (jContentPane == null) {\r
- jLabelOutputFileBasename = new JLabel();\r
- jLabelOutputFileBasename.setBounds(new java.awt.Rectangle(15, 10, 140, 20));\r
- jLabelOutputFileBasename.setText("Output File Basename");\r
- jLabelBinaryModule = new JLabel();\r
- jLabelBinaryModule.setBounds(new java.awt.Rectangle(15, 35, 140, 20));\r
- jLabelBinaryModule.setText("Binary Module");\r
- jLabelArch = new JLabel();\r
- jLabelArch.setBounds(new java.awt.Rectangle(15, 60, 140, 20));\r
- jLabelArch.setText("Supported Architectures");\r
- jStarLabel1 = new StarLabel();\r
- jStarLabel1.setLocation(new java.awt.Point(0, 10));\r
- jStarLabel2 = new StarLabel();\r
- jStarLabel2.setLocation(new java.awt.Point(0, 35));\r
- jStarLabel3 = new StarLabel();\r
- jStarLabel3.setLocation(new java.awt.Point(0, 60));\r
-\r
- jContentPane = new JPanel();\r
- jContentPane.setLayout(null);\r
- jContentPane.setPreferredSize(new java.awt.Dimension(490, 150));\r
-\r
- jContentPane.add(jLabelArch, null);\r
- jContentPane.add(getJScrollPaneArch(), null);\r
- jContentPane.add(jLabelBinaryModule, null);\r
- jContentPane.add(getJComboBoxBinaryModule(), null);\r
- jContentPane.add(jLabelOutputFileBasename, null);\r
- jContentPane.add(getJTextFieldOutputFileBasename(), null);\r
- jContentPane.add(jStarLabel1, null);\r
- jContentPane.add(jStarLabel2, null);\r
- jContentPane.add(jStarLabel3, null);\r
- }\r
- return jContentPane;\r
- }\r
-\r
- /**\r
- This method initializes iCheckBoxListArch \r
- \r
- @return ICheckBoxList \r
- **/\r
- private ICheckBoxList getICheckBoxListSupportedArchitectures() {\r
- if (iCheckBoxListArch == null) {\r
- iCheckBoxListArch = new ICheckBoxList();\r
- iCheckBoxListArch.addFocusListener(this);\r
- iCheckBoxListArch.setToolTipText("<html>Deselecting a checkbox will restrict this module<br>"\r
- + "for use with the selected architectures, <br>"\r
- + "based on the list of items that are checked. <br>"\r
- + "If all boxes are checked, <br>"\r
- + "then the module will support all <br>"\r
- + "current AND FUTURE architectures</html>");\r
- }\r
- return iCheckBoxListArch;\r
- }\r
-\r
- /**\r
- * This method initializes jComboBoxBinaryModule \r
- * \r
- * @return javax.swing.JComboBox \r
- */\r
- private JComboBox getJComboBoxBinaryModule() {\r
- if (jComboBoxBinaryModule == null) {\r
- jComboBoxBinaryModule = new JComboBox();\r
- jComboBoxBinaryModule.setBounds(new java.awt.Rectangle(160, 35, 320, 20));\r
- jComboBoxBinaryModule.setPreferredSize(new java.awt.Dimension(320, 20));\r
- jComboBoxBinaryModule.addFocusListener(this);\r
- jComboBoxBinaryModule.setToolTipText("<html>Modules are either source modules <br>"\r
- + "which can be compiled or binary <br>"\r
- + "modules which are linked. <br>"\r
- + "A module cannot contain both. <br>"\r
- + "The GUID numbers should be identical <br>"\r
- + "for a binary and source MSA, <br>"\r
- + "but the BINARY MSA should have <br>"\r
- + "a higher version number.</html>");\r
- }\r
- return jComboBoxBinaryModule;\r
- }\r
-\r
- /**\r
- * This method initializes jTextFieldOutputFileBasename \r
- * \r
- * @return javax.swing.JTextField \r
- */\r
- private JTextField getJTextFieldOutputFileBasename() {\r
- if (jTextFieldOutputFileBasename == null) {\r
- jTextFieldOutputFileBasename = new JTextField();\r
- jTextFieldOutputFileBasename.setBounds(new java.awt.Rectangle(160, 10, 320, 20));\r
- jTextFieldOutputFileBasename.setPreferredSize(new java.awt.Dimension(320, 20));\r
- jTextFieldOutputFileBasename.addFocusListener(this);\r
- jTextFieldOutputFileBasename.setToolTipText("Enter a single word for generated output file names");\r
- }\r
- return jTextFieldOutputFileBasename;\r
- }\r
-\r
- /**\r
- This method initializes jScrollPaneArch \r
- \r
- @return javax.swing.JScrollPane \r
- \r
- **/\r
- private JScrollPane getJScrollPaneArch() {\r
- if (jScrollPaneArch == null) {\r
- jScrollPaneArch = new JScrollPane();\r
- jScrollPaneArch.setBounds(new java.awt.Rectangle(160, 60, 320, 80));\r
- jScrollPaneArch.setPreferredSize(new java.awt.Dimension(320, 60));\r
- jScrollPaneArch.setViewportView(getICheckBoxListSupportedArchitectures());\r
- }\r
- return jScrollPaneArch;\r
- }\r
-\r
- /**\r
- \r
- @param args\r
- \r
- **/\r
- public static void main(String[] args) {\r
- // TODO Auto-generated method stub\r
-\r
- }\r
-\r
- /**\r
- * This is the default constructor\r
- */\r
- public ModuleDefinitions() {\r
- super();\r
- init();\r
- this.setVisible(true);\r
- }\r
-\r
- /**\r
- This is the override edit constructor\r
- \r
- @param inMsa\r
- \r
- **/\r
- public ModuleDefinitions(OpeningModuleType inOmt) {\r
- super();\r
- this.omt = inOmt;\r
- this.msa = omt.getXmlMsa();\r
- if (msa.getModuleDefinitions() != null) {\r
- this.cf = msa.getModuleDefinitions().getClonedFrom();\r
- }\r
- init(msa.getModuleDefinitions());\r
- this.setVisible(true);\r
- }\r
-\r
- /**\r
- * This method initializes this\r
- * \r
- * @return void\r
- */\r
- private void init() {\r
- this.setContentPane(getJScrollPane());\r
- this.setTitle("Module Definitions");\r
- initFrame();\r
- this.setPreferredSize(new java.awt.Dimension(490, 520));\r
- }\r
-\r
- /**\r
- This method initializes this\r
- Fill values to all fields if these values are not empty\r
- \r
- @param inMsaHeader The input data of MsaHeaderDocument.MsaHeader\r
- \r
- **/\r
- private void init(ModuleDefinitionsDocument.ModuleDefinitions inMd) {\r
- init();\r
- if (inMd != null) {\r
- this.md = inMd;\r
- if (md.getSupportedArchitectures() != null) {\r
- this.iCheckBoxListArch.initCheckedItem(true, Tools.convertListToVector(md.getSupportedArchitectures()));\r
- }\r
- if (md.getBinaryModule()) {\r
- this.jComboBoxBinaryModule.setSelectedIndex(1);\r
- } else {\r
- this.jComboBoxBinaryModule.setSelectedIndex(0);\r
- }\r
- if (md.getOutputFileBasename() != null) {\r
- this.jTextFieldOutputFileBasename.setText(md.getOutputFileBasename());\r
- }\r
- }\r
- }\r
-\r
- /**\r
- This method initializes Module type and Compontent type\r
- \r
- **/\r
- private void initFrame() {\r
- EnumerationData ed = new EnumerationData();\r
- this.iCheckBoxListArch.setAllItems(ed.getVSupportedArchitectures());\r
- Tools.generateComboBoxByVector(jComboBoxBinaryModule, ed.getVBoolean());\r
- }\r
-\r
- private boolean check() {\r
- if (isEmpty(this.jTextFieldOutputFileBasename.getText())) {\r
- Log.wrn("Update Definitions", "Output File Basename couldn't be empty!");\r
- return false;\r
- }\r
- if (!DataValidation.isOutputFileBasename(this.jTextFieldOutputFileBasename.getText())) {\r
- Log.wrn("Update Definitions", "Incorrect data type for Output File Basename");\r
- return false;\r
- }\r
- return true;\r
- }\r
-\r
- /* (non-Javadoc)\r
- * @see java.awt.event.ComponentListener#componentResized(java.awt.event.ComponentEvent)\r
- * \r
- * Override componentResized to resize all components when frame's size is changed\r
- */\r
- public void componentResized(ComponentEvent arg0) {\r
- int intCurrentWidth = this.getJContentPane().getWidth();\r
- int intPreferredWidth = this.getJContentPane().getPreferredSize().width;\r
-\r
- resizeComponentWidth(this.jScrollPaneArch, intCurrentWidth, intPreferredWidth);\r
- resizeComponentWidth(this.jComboBoxBinaryModule, intCurrentWidth, intPreferredWidth);\r
- resizeComponentWidth(this.jTextFieldOutputFileBasename, intCurrentWidth, intPreferredWidth);\r
- }\r
-\r
- /**\r
- Save all components of Module Definitions\r
- if exists Module Definitions, set the value directly\r
- if not exists Module Definitions, new an instance first\r
- \r
- **/\r
- public void save() {\r
- check();\r
- try {\r
- if (this.md == null) {\r
- md = ModuleDefinitionsDocument.ModuleDefinitions.Factory.newInstance();\r
- }\r
-\r
- if (!isEmpty(this.jTextFieldOutputFileBasename.getText())) {\r
- md.setOutputFileBasename(this.jTextFieldOutputFileBasename.getText());\r
- }\r
-\r
- if (this.jComboBoxBinaryModule.getSelectedIndex() == 0) {\r
- md.setBinaryModule(false);\r
- } else {\r
- md.setBinaryModule(true);\r
- }\r
-\r
- //\r
- // Set ClonedFrom field\r
- //\r
- if (this.cf != null) {\r
- md.setClonedFrom(this.cf);\r
- }\r
-\r
- //\r
- // Save Arch list\r
- //\r
- md.setSupportedArchitectures(this.iCheckBoxListArch.getAllCheckedItemsString());\r
-\r
- msa.setModuleDefinitions(md);\r
-\r
- this.omt.setSaved(false);\r
-\r
- } catch (Exception e) {\r
- Log.err("Save Module Definitions", e.getMessage());\r
- }\r
- }\r
-\r
- public void focusLost(FocusEvent arg0) {\r
- this.save();\r
- if (arg0.getSource() == this.jTextFieldOutputFileBasename) {\r
- }\r
- }\r
-}\r