Add two files for List editor.
authorjlin16 <jlin16@6f19259b-4bc3-4df7-8a09-765794883524>
Wed, 5 Jul 2006 04:11:04 +0000 (04:11 +0000)
committerjlin16 <jlin16@6f19259b-4bc3-4df7-8a09-765794883524>
Wed, 5 Jul 2006 04:11:04 +0000 (04:11 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@756 6f19259b-4bc3-4df7-8a09-765794883524

Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/GenListDialog.java [new file with mode: 0644]
Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/ListEditor.java [new file with mode: 0644]

diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/GenListDialog.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/GenListDialog.java
new file mode 100644 (file)
index 0000000..6ca63c5
--- /dev/null
@@ -0,0 +1,314 @@
+/** @file\r
+  Java class GenListDialog.\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
+package org.tianocore.frameworkwizard.platform.ui;\r
+\r
+import java.awt.BorderLayout;\r
+import java.awt.Dimension;\r
+import java.awt.Toolkit;\r
+\r
+import javax.swing.JPanel;\r
+import javax.swing.JDialog;\r
+\r
+import javax.swing.JButton;\r
+\r
+\r
+import java.awt.FlowLayout;\r
+import java.awt.event.ActionEvent;\r
+import java.awt.event.ActionListener;\r
+import java.util.Vector;\r
+\r
+import javax.swing.JScrollPane;\r
+\r
+import org.tianocore.frameworkwizard.common.ui.iCheckBoxList.ICheckBoxList;\r
+\r
+\r
+/**\r
+ Dialog for List generation. \r
+ @since PackageEditor 1.0\r
+**/\r
+public class GenListDialog extends JDialog implements ActionListener{\r
+\r
+    /**\r
+     * \r
+     */\r
+    private static final long serialVersionUID = 1L;\r
+\r
+    private JPanel jContentPane = null;\r
+    private JPanel jPanel = null;\r
+    private JPanel jPanel1 = null;\r
+    private JPanel jPanel2 = null;\r
+    private JPanel jPanel3 = null;\r
+    private JPanel jPanel4 = null;\r
+    private JButton jButton = null;\r
+    private JButton jButton1 = null;\r
+    private JButton jButton2 = null;\r
+    private ICheckBoxList checkBoxList = null;\r
+\r
+\r
+    private JScrollPane jScrollPane = null;\r
+\r
+\r
+\r
+    public void actionPerformed(ActionEvent arg0) {\r
+        // TODO Auto-generated method stub\r
+        if (arg0.getSource() == jButton1){\r
+            checkBoxList.setAllItemsUnchecked();\r
+        }\r
+        \r
+        if (arg0.getSource() == jButton2){\r
+\r
+            this.dispose();\r
+        }\r
+        \r
+        if (arg0.getSource() == jButton){\r
+            this.dispose();\r
+        }\r
+    }\r
+\r
+    /**\r
+     * This method initializes jPanel  \r
+     *         \r
+     * @return javax.swing.JPanel      \r
+     */\r
+    private JPanel getJPanel() {\r
+        if (jPanel == null) {\r
+            FlowLayout flowLayout = new FlowLayout();\r
+            flowLayout.setVgap(10);\r
+            jPanel = new JPanel();\r
+            jPanel.setLayout(flowLayout);\r
+            jPanel.setPreferredSize(new java.awt.Dimension(100,30));\r
+            jPanel.add(getJButton1(), null);\r
+            jPanel.add(getJButton2(), null);\r
+            jPanel.add(getJButton(), null);\r
+        }\r
+        return jPanel;\r
+    }\r
+\r
+    /**\r
+     * This method initializes jPanel1 \r
+     *         \r
+     * @return javax.swing.JPanel      \r
+     */\r
+    private JPanel getJPanel1() {\r
+        if (jPanel1 == null) {\r
+            jPanel1 = new JPanel();\r
+        }\r
+        return jPanel1;\r
+    }\r
+\r
+    /**\r
+     * This method initializes jPanel2 \r
+     *         \r
+     * @return javax.swing.JPanel      \r
+     */\r
+    private JPanel getJPanel2() {\r
+        if (jPanel2 == null) {\r
+            jPanel2 = new JPanel();\r
+        }\r
+        return jPanel2;\r
+    }\r
+\r
+    /**\r
+     * This method initializes jPanel3 \r
+     *         \r
+     * @return javax.swing.JPanel      \r
+     */\r
+    private JPanel getJPanel3() {\r
+        if (jPanel3 == null) {\r
+            jPanel3 = new JPanel();\r
+        }\r
+        return jPanel3;\r
+    }\r
+\r
+    /**\r
+     * This method initializes jPanel4 \r
+     *         \r
+     * @return javax.swing.JPanel      \r
+     */\r
+    private JPanel getJPanel4() {\r
+        if (jPanel4 == null) {\r
+            jPanel4 = new JPanel();\r
+            jPanel4.setLayout(new FlowLayout());\r
+            jPanel4.add(getJScrollPane(), null);\r
+            \r
+        }\r
+        return jPanel4;\r
+    }\r
+\r
+    /**\r
+     * This method initializes jButton \r
+     *         \r
+     * @return javax.swing.JButton     \r
+     */\r
+    private JButton getJButton() {\r
+        if (jButton == null) {\r
+            jButton = new JButton();\r
+            jButton.setPreferredSize(new java.awt.Dimension(80,20));\r
+            jButton.setText("Cancel");\r
+            jButton.addActionListener(this);\r
+        }\r
+        return jButton;\r
+    }\r
+\r
+    /**\r
+     * This method initializes jButton1        \r
+     *         \r
+     * @return javax.swing.JButton     \r
+     */\r
+    private JButton getJButton1() {\r
+        if (jButton1 == null) {\r
+            jButton1 = new JButton();\r
+            jButton1.setPreferredSize(new java.awt.Dimension(80,20));\r
+            jButton1.setHorizontalTextPosition(javax.swing.SwingConstants.LEADING);\r
+            jButton1.setText("Clear");\r
+            jButton1.setVisible(false);\r
+            jButton1.addActionListener(this);\r
+        }\r
+        return jButton1;\r
+    }\r
+\r
+    /**\r
+     * This method initializes jButton2        \r
+     *         \r
+     * @return javax.swing.JButton     \r
+     */\r
+    private JButton getJButton2() {\r
+        if (jButton2 == null) {\r
+            jButton2 = new JButton();\r
+            jButton2.setPreferredSize(new java.awt.Dimension(80,20));\r
+            jButton2.setText("Ok");\r
+            jButton2.setActionCommand("GenGuidValue");\r
+            jButton2.addActionListener(this);\r
+        }\r
+        return jButton2;\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.setPreferredSize(new java.awt.Dimension(300,100));\r
+            jScrollPane.setViewportView(getICheckBoxList());\r
+        }\r
+        return jScrollPane;\r
+    }\r
+\r
+    private ICheckBoxList getICheckBoxList() {\r
+        if (checkBoxList == null) {\r
+            checkBoxList = new ICheckBoxList();\r
+            checkBoxList.setBounds(new java.awt.Rectangle(40,20,177,74));\r
+//            Vector<String> v = new Vector<String>();\r
+//            v.add("DATA_HUB_RECORD");\r
+//            v.add("EFI_EVENT");\r
+//            v.add("EFI_SYSTEM_CONFIGURATION_TABLE");\r
+//            v.add("EFI_VARIABLE");\r
+//            v.add("GUID");\r
+//            v.add("HII_PACKAGE_LIST");\r
+//            v.add("HOB");\r
+//            v.add("TOKEN_SPACE_GUID");\r
+//          \r
+//            checkBoxList.setAllItems(v);\r
+        }\r
+        return checkBoxList;\r
+    }\r
+\r
+    public void initList(Vector<String> v){\r
+        checkBoxList.setAllItems(v);\r
+    }\r
+    public Vector<String> getList(){\r
+        Vector<String> v = checkBoxList.getAllCheckedItemsString();\r
+        return v;\r
+    }\r
+    \r
+    public void setList(String s){\r
+        Vector<String> v = new Vector<String>();\r
+        if (s == null) {\r
+            checkBoxList.setAllItemsUnchecked();\r
+            return;\r
+        }\r
+        String[] sArray = s.split(" ");\r
+        for (int i = 0; i < sArray.length; ++i){\r
+            v.add(sArray[i]);\r
+        }\r
+        checkBoxList.initCheckedItem(true, v);\r
+    }\r
+    /**\r
+     * This is the default constructor\r
+     */\r
+    public GenListDialog() {\r
+        super();\r
+        initialize();\r
+    }\r
+    \r
+    public GenListDialog(ActionListener i){\r
+        this();\r
+        jButton2.addActionListener(i);\r
+        \r
+    }\r
+\r
+    /**\r
+     * This method initializes this\r
+     * \r
+     * @return void\r
+     */\r
+    private void initialize() {\r
+        this.setSize(466, 157);\r
+        this.setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);\r
+        this.setModal(true);\r
+        this.setTitle("List");\r
+        this.setContentPane(getJContentPane());\r
+        this.centerWindow();\r
+    }\r
+\r
+    /**\r
+     * This method initializes jContentPane\r
+     * \r
+     * @return javax.swing.JPanel\r
+     */\r
+    private JPanel getJContentPane() {\r
+        if (jContentPane == null) {\r
+            jContentPane = new JPanel();\r
+            jContentPane.setLayout(new BorderLayout());\r
+            jContentPane.add(getJPanel(), java.awt.BorderLayout.EAST);\r
+            jContentPane.add(getJPanel1(), java.awt.BorderLayout.WEST);\r
+            jContentPane.add(getJPanel2(), java.awt.BorderLayout.NORTH);\r
+            jContentPane.add(getJPanel3(), java.awt.BorderLayout.SOUTH);\r
+            jContentPane.add(getJPanel4(), java.awt.BorderLayout.CENTER);\r
+        }\r
+        return jContentPane;\r
+    }\r
+\r
+    /**\r
+     Start the window at the center of screen\r
+     \r
+     **/\r
+    protected void centerWindow(int intWidth, int intHeight) {\r
+        Dimension d = Toolkit.getDefaultToolkit().getScreenSize();\r
+        this.setLocation((d.width - intWidth) / 2, (d.height - intHeight) / 2);\r
+    }\r
+\r
+    /**\r
+     Start the window at the center of screen\r
+     \r
+     **/\r
+    protected void centerWindow() {\r
+        centerWindow(this.getSize().width, this.getSize().height);\r
+    }\r
+    \r
+    \r
+    \r
+}  //  @jve:decl-index=0:visual-constraint="10,10"\r
diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/ListEditor.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/ListEditor.java
new file mode 100644 (file)
index 0000000..e604e1f
--- /dev/null
@@ -0,0 +1,105 @@
+/** @file\r
+ Java class GuidEditor.\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.platform.ui;\r
+\r
+import java.awt.Component;\r
+import java.awt.event.ActionEvent;\r
+import java.awt.event.ActionListener;\r
+import java.util.Vector;\r
+\r
+import javax.swing.AbstractCellEditor;\r
+import javax.swing.JButton;\r
+import javax.swing.JFrame;\r
+import javax.swing.JTable;\r
+import javax.swing.table.TableCellEditor;\r
+\r
+\r
+/**\r
+ Editor for table cell with GUID value.\r
+ @since PackageEditor 1.0\r
+ **/\r
+public class ListEditor extends AbstractCellEditor implements TableCellEditor, ActionListener {\r
+\r
+    /**\r
+     * \r
+     */\r
+    private static final long serialVersionUID = 1L;\r
+    String archs;\r
+    JButton button;\r
+    static JFrame frame;\r
+    GenListDialog dialog;\r
+    protected static final String EDIT = "edit";\r
+\r
+    public ListEditor() {\r
+        \r
+        button = new JButton();\r
+        button.setActionCommand(EDIT);\r
+        button.addActionListener(this);\r
+        button.setBorderPainted(false);\r
+\r
+        \r
+        dialog = new GenListDialog(this);\r
+        \r
+    }\r
+    \r
+    public ListEditor(Vector<String> v) {\r
+        this();\r
+        dialog.initList(v);\r
+    }\r
+\r
+    /* (non-Javadoc)\r
+     * @see javax.swing.table.TableCellEditor#getTableCellEditorComponent(javax.swing.JTable, java.lang.Object, boolean, int, int)\r
+     */\r
+    public Component getTableCellEditorComponent(JTable arg0, Object arg1, boolean arg2, int arg3, int arg4) {\r
+        // TODO Auto-generated method stub\r
+        archs = (String)arg1;\r
+        return button;\r
+    }\r
+\r
+    /* (non-Javadoc)\r
+     * @see javax.swing.CellEditor#getCellEditorValue()\r
+     */\r
+    public Object getCellEditorValue() {\r
+        // TODO Auto-generated method stub\r
+        return archs;\r
+    }\r
+\r
+    /* (non-Javadoc)\r
+     * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)\r
+     */\r
+    public void actionPerformed(ActionEvent arg0) {\r
+        // TODO Auto-generated method stub\r
+        if (EDIT.equals(arg0.getActionCommand())) {\r
+            //The user has clicked the cell, so\r
+            //bring up the dialog.\r
+            button.setText(archs);\r
+            dialog.setList(archs);\r
+            dialog.setVisible(true);\r
+\r
+            //Make the renderer reappear.\r
+            fireEditingStopped();\r
+        }\r
+        else { //User pressed dialog's "OK" button.\r
+            Vector<String> v = dialog.getList();\r
+            String s = " ";\r
+            for (int i = 0; i < v.size(); ++i) {\r
+                s += v.get(i);\r
+                s += " ";\r
+            }\r
+            archs = s.trim();\r
+        }\r
+\r
+    }\r
+\r
+}\r