]> git.proxmox.com Git - mirror_edk2.git/blobdiff - Tools/Java/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/dialog/BuildOptionsDlg.java
1. Fix EDKT461 [Framework Wizard] Can't change ModuleBuildOptions for MSA file
[mirror_edk2.git] / Tools / Java / Source / FrameworkWizard / src / org / tianocore / frameworkwizard / module / ui / dialog / BuildOptionsDlg.java
diff --git a/Tools/Java/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/dialog/BuildOptionsDlg.java b/Tools/Java/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/dialog/BuildOptionsDlg.java
new file mode 100644 (file)
index 0000000..a4bad7e
--- /dev/null
@@ -0,0 +1,495 @@
+/** @file\r
\r
+ The file is used to create, update SourceFiles section of the 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.dialog;\r
+\r
+import java.awt.event.ActionEvent;\r
+import java.util.Vector;\r
+\r
+import javax.swing.JButton;\r
+import javax.swing.JLabel;\r
+import javax.swing.JPanel;\r
+import javax.swing.JScrollPane;\r
+import javax.swing.JTextField;\r
+\r
+import org.tianocore.frameworkwizard.common.DataType;\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.ui.ArchCheckBox;\r
+import org.tianocore.frameworkwizard.common.ui.IComboBox;\r
+import org.tianocore.frameworkwizard.common.ui.IDialog;\r
+import org.tianocore.frameworkwizard.common.ui.IFrame;\r
+import org.tianocore.frameworkwizard.common.ui.StarLabel;\r
+import org.tianocore.frameworkwizard.common.ui.iCheckBoxList.ICheckBoxList;\r
+import org.tianocore.frameworkwizard.module.Identifications.ModuleIdentification;\r
+import org.tianocore.frameworkwizard.module.Identifications.BuildOptions.BuildOptionsIdentification;\r
+import org.tianocore.frameworkwizard.workspace.WorkspaceTools;\r
+\r
+/**\r
+ * The class is used to create, update SourceFiles section of the MSA file\r
+ *\r
+ * It extends IDialog\r
+ * \r
+ **/\r
+public class BuildOptionsDlg extends IDialog {\r
+\r
+    ///\r
+    /// Define class Serial Version UID\r
+    ///\r
+    private static final long serialVersionUID = -6765742852142775378L;\r
+\r
+    //\r
+    // Define class members\r
+    //\r
+    private JPanel jContentPane = null;\r
+\r
+    private JLabel jLabelFileName = null;\r
+\r
+    private JTextField jTextFieldFileOption = null;\r
+\r
+    private JLabel jLabelToolChainFamily = null;\r
+\r
+    private StarLabel jStarLabel1 = null;\r
+\r
+    private JLabel jLabelArch = null;\r
+\r
+    private JScrollPane jScrollPane = null;\r
+\r
+    private JLabel jLabelTagName = null;\r
+\r
+    private JTextField jTextFieldTagName = null;\r
+\r
+    private JLabel jLabelToolCode = null;\r
+\r
+    private JTextField jTextFieldToolCode = null;\r
+\r
+    private IComboBox iComboBoxToolCode = null;\r
+\r
+    private JTextField jTextFieldToolChainFamily = null;\r
+\r
+    private ArchCheckBox jArchCheckBox = null;\r
+\r
+    private JButton jButtonOk = null;\r
+\r
+    private JButton jButtonCancel = null;\r
+\r
+    private JScrollPane jScrollPaneBuildTargets = null;\r
+\r
+    private ICheckBoxList iCheckBoxListBuildTargets = null;\r
+\r
+    //\r
+    // Not used by UI\r
+    //\r
+    private BuildOptionsIdentification id = null;\r
+\r
+    private EnumerationData ed = new EnumerationData();\r
+\r
+    private WorkspaceTools wt = new WorkspaceTools();\r
+\r
+    private JLabel jLabelBuildTargets = null;\r
+\r
+    /**\r
+     This method initializes jTextFieldFileOption \r
+     \r
+     @return javax.swing.JTextField jTextFieldFileOption\r
+     \r
+     **/\r
+    private JTextField getJTextFieldSourceFilesDirectory() {\r
+        if (jTextFieldFileOption == null) {\r
+            jTextFieldFileOption = new JTextField();\r
+            jTextFieldFileOption.setBounds(new java.awt.Rectangle(168, 12, 340, 20));\r
+            jTextFieldFileOption.setPreferredSize(new java.awt.Dimension(340, 20));\r
+            jTextFieldFileOption.setToolTipText("Path is relative to the MSA file and must include the file name");\r
+        }\r
+        return jTextFieldFileOption;\r
+    }\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 jTextFieldTagName    \r
+     *  \r
+     * @return javax.swing.JTextField   \r
+     */\r
+    private JTextField getJTextFieldTagName() {\r
+        if (jTextFieldTagName == null) {\r
+            jTextFieldTagName = new JTextField();\r
+            jTextFieldTagName.setBounds(new java.awt.Rectangle(168, 37, 340, 20));\r
+            jTextFieldTagName.setPreferredSize(new java.awt.Dimension(340, 20));\r
+            jTextFieldTagName.setToolTipText("You may specify a specific tool chain tag name, such as BILL1");\r
+        }\r
+        return jTextFieldTagName;\r
+    }\r
+\r
+    private IComboBox getIComboBoxToolCode() {\r
+        if (iComboBoxToolCode == null) {\r
+            iComboBoxToolCode = new IComboBox();\r
+            iComboBoxToolCode.setBounds(new java.awt.Rectangle(168, 62, 340, 20));\r
+            iComboBoxToolCode.setPreferredSize(new java.awt.Dimension(340, 20));\r
+            iComboBoxToolCode.setToolTipText("<html>You may select a specific tool command from drop down list,<br>"\r
+                                             + "or you can DOUBLE-CLICK this field to enter your customized<br>"\r
+                                             + "tool command.<br>"\r
+                                             + "Press ENTER to save your input or press ESCAPE to quit</html>");\r
+        }\r
+        return iComboBoxToolCode;\r
+    }\r
+\r
+    /**\r
+     * This method initializes jTextFieldToolCode   \r
+     *  \r
+     * @return javax.swing.JTextField   \r
+     */\r
+    private JTextField getJTextFieldToolCode() {\r
+        if (jTextFieldToolCode == null) {\r
+            jTextFieldToolCode = new JTextField();\r
+            jTextFieldToolCode.setBounds(new java.awt.Rectangle(168, 62, 340, 20));\r
+            jTextFieldToolCode.setPreferredSize(new java.awt.Dimension(340, 20));\r
+            jTextFieldToolCode.setToolTipText("You may specify a specific tool command, such as ASM");\r
+            jTextFieldToolCode.setVisible(false);\r
+        }\r
+        return jTextFieldToolCode;\r
+    }\r
+\r
+    /**\r
+     * This method initializes jTextFieldToolChainFamily    \r
+     *  \r
+     * @return javax.swing.JTextField   \r
+     */\r
+    private JTextField getJTextFieldToolChainFamily() {\r
+        if (jTextFieldToolChainFamily == null) {\r
+            jTextFieldToolChainFamily = new JTextField();\r
+            jTextFieldToolChainFamily.setBounds(new java.awt.Rectangle(168, 87, 340, 20));\r
+            jTextFieldToolChainFamily.setPreferredSize(new java.awt.Dimension(340, 20));\r
+            jTextFieldToolChainFamily.setToolTipText("You may specify a specific tool chain family, such as GCC");\r
+        }\r
+        return jTextFieldToolChainFamily;\r
+    }\r
+\r
+    /**\r
+     This method initializes jButtonOk    \r
+     \r
+     @return javax.swing.JButton  \r
+     \r
+     **/\r
+    private JButton getJButtonOk() {\r
+        if (jButtonOk == null) {\r
+            jButtonOk = new JButton();\r
+            jButtonOk.setBounds(new java.awt.Rectangle(317, 202, 90, 20));\r
+            jButtonOk.setText("Ok");\r
+            jButtonOk.addActionListener(this);\r
+        }\r
+        return jButtonOk;\r
+    }\r
+\r
+    /**\r
+     This method initializes jButtonCancel    \r
+     \r
+     @return javax.swing.JButton  \r
+     \r
+     **/\r
+    private JButton getJButtonCancel() {\r
+        if (jButtonCancel == null) {\r
+            jButtonCancel = new JButton();\r
+            jButtonCancel.setBounds(new java.awt.Rectangle(412, 202, 90, 20));\r
+            jButtonCancel.setText("Cancel");\r
+            jButtonCancel.addActionListener(this);\r
+        }\r
+        return jButtonCancel;\r
+    }\r
+\r
+    /**\r
+     This method initializes iCheckBoxListArch   \r
+     \r
+     @return ICheckBoxList   \r
+     **/\r
+    private ICheckBoxList getICheckBoxListSupModuleList() {\r
+        if (iCheckBoxListBuildTargets == null) {\r
+            iCheckBoxListBuildTargets = new ICheckBoxList();\r
+        }\r
+        return iCheckBoxListBuildTargets;\r
+    }\r
+\r
+    /**\r
+     This method initializes jScrollPaneBuildTargets    \r
+     \r
+     @return javax.swing.JScrollPane  \r
+     \r
+     **/\r
+    private JScrollPane getJScrollPaneBuildTargets() {\r
+        if (jScrollPaneBuildTargets == null) {\r
+            jScrollPaneBuildTargets = new JScrollPane();\r
+            jScrollPaneBuildTargets.setBounds(new java.awt.Rectangle(168, 137, 340, 40));\r
+            jScrollPaneBuildTargets.setPreferredSize(new java.awt.Dimension(340, 40));\r
+            jScrollPaneBuildTargets.setViewportView(getICheckBoxListSupModuleList());\r
+        }\r
+        return jScrollPaneBuildTargets;\r
+    }\r
+\r
+    public static void main(String[] args) {\r
+\r
+    }\r
+\r
+    /**\r
+     This is the default constructor\r
+     \r
+     **/\r
+    public BuildOptionsDlg(BuildOptionsIdentification inBuildOptionsIdentification, IFrame iFrame,\r
+                           ModuleIdentification mid) {\r
+        super(iFrame, true);\r
+        init(inBuildOptionsIdentification, mid);\r
+    }\r
+\r
+    /**\r
+     This method initializes this\r
+     \r
+     **/\r
+    private void init() {\r
+        this.setSize(525, 270);\r
+        this.setContentPane(getJScrollPane());\r
+        this.setTitle("Source Files");\r
+        this.setViewMode(false);\r
+        this.centerWindow();\r
+        Tools.generateComboBoxByVector(iComboBoxToolCode, ed.getVToolCode());\r
+        this.iCheckBoxListBuildTargets.setAllItems(ed.getVBuildTargets());\r
+    }\r
+\r
+    /**         \r
+     This method initializes this\r
+     Fill values to all fields if these values are not empty\r
+     \r
+     \r
+     @param inSourceFiles The input data of SourceFilesDocument.SourceFiles\r
+     \r
+     **/\r
+    private void init(BuildOptionsIdentification inBuildOptionsIdentification, ModuleIdentification mid) {\r
+        init();\r
+\r
+        //\r
+        // Init arch with module's arch\r
+        //\r
+        this.jArchCheckBox.setEnabledItems(wt.getModuleArch(mid));\r
+\r
+        if (inBuildOptionsIdentification != null) {\r
+            this.jTextFieldFileOption.setText(inBuildOptionsIdentification.getOption());\r
+            this.jTextFieldTagName.setText(inBuildOptionsIdentification.getTagName());\r
+\r
+            //\r
+            // Generate Tool Code selection list\r
+            //\r
+            Vector<String> v = ed.getVToolCode();\r
+            boolean isFind = false;\r
+            String strToolCode = inBuildOptionsIdentification.getToolCode();\r
+\r
+            //\r
+            // If the input value is not in the default list, add it to the list\r
+            //\r
+            if (strToolCode != null) {\r
+                for (int index = 0; index < v.size(); index++) {\r
+                    if (v.elementAt(index).equals(strToolCode)) {\r
+                        isFind = true;\r
+                        break;\r
+                    }\r
+                }\r
+                if (!isFind && !isEmpty(strToolCode)) {\r
+                    v.addElement(strToolCode);\r
+                }\r
+            }\r
+\r
+            Tools.generateComboBoxByVector(iComboBoxToolCode, v);\r
+            this.iComboBoxToolCode.setSelectedItem(strToolCode);\r
+\r
+            this.jTextFieldToolChainFamily.setText(inBuildOptionsIdentification.getToolChainFamily());\r
+\r
+            this.jArchCheckBox.setSelectedItems(inBuildOptionsIdentification.getSupArchList());\r
+\r
+            this.iCheckBoxListBuildTargets.setAllItemsUnchecked();\r
+            this.iCheckBoxListBuildTargets.initCheckedItem(true, inBuildOptionsIdentification.getBuildTargets());\r
+        }\r
+    }\r
+\r
+    /**\r
+     Disable all components when the mode is view\r
+     \r
+     @param isView true - The view mode; false - The non-view mode\r
+     \r
+     **/\r
+    public void setViewMode(boolean isView) {\r
+        if (isView) {\r
+            this.jTextFieldFileOption.setEnabled(!isView);\r
+        }\r
+    }\r
+\r
+    /**\r
+     This method initializes jContentPane\r
+     \r
+     @return javax.swing.JPanel jContentPane\r
+     \r
+     **/\r
+    private JPanel getJContentPane() {\r
+        if (jContentPane == null) {\r
+            jLabelBuildTargets = new JLabel();\r
+            jLabelBuildTargets.setBounds(new java.awt.Rectangle(12, 137, 155, 20));\r
+            jLabelBuildTargets.setText("Build Targets");\r
+            jArchCheckBox = new ArchCheckBox();\r
+            jArchCheckBox.setBounds(new java.awt.Rectangle(168, 112, 340, 20));\r
+            jArchCheckBox.setPreferredSize(new java.awt.Dimension(340, 20));\r
+            jLabelToolCode = new JLabel();\r
+            jLabelToolCode.setBounds(new java.awt.Rectangle(12, 62, 155, 20));\r
+            jLabelToolCode.setText("Tool Code");\r
+            jLabelTagName = new JLabel();\r
+            jLabelTagName.setBounds(new java.awt.Rectangle(12, 37, 155, 20));\r
+            jLabelTagName.setText("Tag Name");\r
+            jLabelArch = new JLabel();\r
+            jLabelArch.setBounds(new java.awt.Rectangle(12, 112, 155, 20));\r
+            jLabelArch.setText("Supported Architectures");\r
+            jLabelToolChainFamily = new JLabel();\r
+            jLabelToolChainFamily.setBounds(new java.awt.Rectangle(12, 87, 155, 20));\r
+            jLabelToolChainFamily.setText("Tool Chain Family");\r
+            jLabelFileName = new JLabel();\r
+            jLabelFileName.setText("Option String");\r
+            jLabelFileName.setBounds(new java.awt.Rectangle(12, 12, 155, 20));\r
+\r
+            jContentPane = new JPanel();\r
+            jContentPane.setLayout(null);\r
+            jContentPane.setPreferredSize(new java.awt.Dimension(505, 222));\r
+\r
+            jContentPane.add(jLabelFileName, null);\r
+            jContentPane.add(getJTextFieldSourceFilesDirectory(), null);\r
+            jContentPane.add(jLabelToolChainFamily, null);\r
+            jStarLabel1 = new StarLabel();\r
+            jStarLabel1.setLocation(new java.awt.Point(0, 10));\r
+\r
+            jContentPane.add(jStarLabel1, null);\r
+            jContentPane.add(jLabelArch, null);\r
+            jContentPane.add(jLabelTagName, null);\r
+            jContentPane.add(getJTextFieldTagName(), null);\r
+            jContentPane.add(jLabelToolCode, null);\r
+            jContentPane.add(getJTextFieldToolCode(), null);\r
+            jContentPane.add(getIComboBoxToolCode(), null);\r
+            jContentPane.add(getJTextFieldToolChainFamily(), null);\r
+            jContentPane.add(jArchCheckBox, null);\r
+            jContentPane.add(getJButtonOk(), null);\r
+            jContentPane.add(getJButtonCancel(), null);\r
+            jContentPane.add(jLabelBuildTargets, null);\r
+            jContentPane.add(getJScrollPaneBuildTargets(), null);\r
+        }\r
+        return jContentPane;\r
+    }\r
+\r
+    /* (non-Javadoc)\r
+     * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)\r
+     *\r
+     * Override actionPerformed to listen all actions\r
+     *  \r
+     */\r
+    public void actionPerformed(ActionEvent arg0) {\r
+        if (arg0.getSource() == jButtonOk) {\r
+            if (checkAdd()) {\r
+                getCurrentId();\r
+                this.returnType = DataType.RETURN_TYPE_OK;\r
+                this.setVisible(false);\r
+            }\r
+        }\r
+\r
+        if (arg0.getSource() == jButtonCancel) {\r
+            this.returnType = DataType.RETURN_TYPE_CANCEL;\r
+            this.setVisible(false);\r
+        }\r
+    }\r
+\r
+    private BuildOptionsIdentification getCurrentId() {\r
+        String arg0 = this.jTextFieldFileOption.getText();\r
+        Vector<String> arg1 = this.iCheckBoxListBuildTargets.getAllCheckedItemsString();\r
+        String arg2 = this.jTextFieldToolChainFamily.getText();\r
+        String arg3 = this.jTextFieldTagName.getText();\r
+        String arg4 = this.iComboBoxToolCode.getSelectedItem().toString();\r
+        if (arg4.equals(DataType.EMPTY_SELECT_ITEM)) {\r
+            arg4 = "";\r
+        }\r
+        Vector<String> arg5 = this.jArchCheckBox.getSelectedItemsVector();\r
+        \r
+        id = new BuildOptionsIdentification(arg0, arg1, arg2, arg3, arg4, arg5);\r
+        return id;\r
+    }\r
+\r
+    /**\r
+     Data validation for all fields\r
+     \r
+     @retval true - All datas are valid\r
+     @retval false - At least one data is invalid\r
+     \r
+     **/\r
+    public boolean checkAdd() {\r
+        //\r
+        // Check Option\r
+        //\r
+        if (isEmpty(this.jTextFieldFileOption.getText())) {\r
+            Log.wrn("Update Build Options", "Option String must be entered!");\r
+            return false;\r
+        }\r
+\r
+        //\r
+        // Check TagName \r
+        //\r
+        if (!isEmpty(this.jTextFieldTagName.getText())) {\r
+            if (!DataValidation.isTagName(this.jTextFieldTagName.getText())) {\r
+                Log.wrn("Update Build Options", "Incorrect data type for Tag Name");\r
+                return false;\r
+            }\r
+        }\r
+\r
+        //\r
+        // Check ToolCode \r
+        //\r
+        if (!isEmpty(this.jTextFieldToolCode.getText())) {\r
+            if (!DataValidation.isToolCode(this.jTextFieldToolCode.getText())) {\r
+                Log.wrn("Update Build Options", "Incorrect data type for Tool Code");\r
+                return false;\r
+            }\r
+        }\r
+\r
+        //\r
+        // Check ToolChainFamily \r
+        //\r
+        if (!isEmpty(this.jTextFieldToolChainFamily.getText())) {\r
+            if (!DataValidation.isToolChainFamily(this.jTextFieldToolChainFamily.getText())) {\r
+                Log.wrn("Update Build Options", "Incorrect data type for Tool Chain Family");\r
+                return false;\r
+            }\r
+        }\r
+\r
+        return true;\r
+    }\r
+\r
+    public BuildOptionsIdentification getId() {\r
+        return id;\r
+    }\r
+\r
+    public void setId(BuildOptionsIdentification id) {\r
+        this.id = id;\r
+    }\r
+}\r