For long text display for table cell.
authorjlin16 <jlin16@6f19259b-4bc3-4df7-8a09-765794883524>
Mon, 4 Sep 2006 09:34:14 +0000 (09:34 +0000)
committerjlin16 <jlin16@6f19259b-4bc3-4df7-8a09-765794883524>
Mon, 4 Sep 2006 09:34:14 +0000 (09:34 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@1441 6f19259b-4bc3-4df7-8a09-765794883524

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

diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/GenLongTextDialog.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/GenLongTextDialog.java
new file mode 100644 (file)
index 0000000..574be8a
--- /dev/null
@@ -0,0 +1,224 @@
+/** @file\r
+  Java class GenLongTextDialog.\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
+import javax.swing.JTextArea;\r
+import javax.swing.JButton;\r
+import java.awt.FlowLayout;\r
+import java.awt.event.ActionEvent;\r
+import java.awt.event.ActionListener;\r
+import javax.swing.JScrollPane;\r
+\r
+\r
+\r
+/**\r
+ Dialog for Long Text generation. \r
+ @since PackageEditor 1.0\r
+**/\r
+public class GenLongTextDialog extends JDialog implements ActionListener{\r
+\r
+    /**\r
+     * \r
+     */\r
+    private static final long serialVersionUID = 1L;\r
+\r
+    private JPanel jContentPane = null;\r
+    private JPanel jPanelContentEast = null;\r
+    private JPanel jPanelContentCenter = null;\r
+    private JButton jButtonCancel = null;\r
+    private JButton jButtonOk = null;\r
+    private JTextArea jTextArea = null;\r
+\r
+\r
+    private JScrollPane jScrollPane = null;\r
+\r
+\r
+\r
+    public void actionPerformed(ActionEvent arg0) {\r
+        \r
+        if (arg0.getSource() == jButtonOk){\r
+\r
+            this.dispose();\r
+        }\r
+        \r
+        if (arg0.getSource() == jButtonCancel){\r
+            this.dispose();\r
+        }\r
+    }\r
+\r
+    /**\r
+     * This method initializes jPanel  \r
+     *         \r
+     * @return javax.swing.JPanel      \r
+     */\r
+    private JPanel getJPanelContentEast() {\r
+        if (jPanelContentEast == null) {\r
+            FlowLayout flowLayout = new FlowLayout();\r
+            flowLayout.setVgap(5);\r
+            flowLayout.setAlignment(java.awt.FlowLayout.RIGHT);\r
+            jPanelContentEast = new JPanel();\r
+            jPanelContentEast.setLayout(flowLayout);\r
+            jPanelContentEast.setPreferredSize(new java.awt.Dimension(100,30));\r
+            jPanelContentEast.add(getJButtonOk(), null);\r
+            jPanelContentEast.add(getJButtonCancel(), null);\r
+        }\r
+        return jPanelContentEast;\r
+    }\r
+\r
+    /**\r
+     * This method initializes jPanel4 \r
+     *         \r
+     * @return javax.swing.JPanel      \r
+     */\r
+    private JPanel getJPanelContentCenter() {\r
+        if (jPanelContentCenter == null) {\r
+            jPanelContentCenter = new JPanel();\r
+            jPanelContentCenter.setLayout(new FlowLayout());\r
+            jPanelContentCenter.add(getJScrollPane(), null);\r
+            \r
+        }\r
+        return jPanelContentCenter;\r
+    }\r
+\r
+    /**\r
+     * This method initializes jButton \r
+     *         \r
+     * @return javax.swing.JButton     \r
+     */\r
+    private JButton getJButtonCancel() {\r
+        if (jButtonCancel == null) {\r
+            jButtonCancel = new JButton();\r
+            jButtonCancel.setPreferredSize(new java.awt.Dimension(80,20));\r
+            jButtonCancel.setText("Cancel");\r
+            jButtonCancel.addActionListener(this);\r
+        }\r
+        return jButtonCancel;\r
+    }\r
+\r
+    /**\r
+     * This method initializes jButton2        \r
+     *         \r
+     * @return javax.swing.JButton     \r
+     */\r
+    private JButton getJButtonOk() {\r
+        if (jButtonOk == null) {\r
+            jButtonOk = new JButton();\r
+            jButtonOk.setPreferredSize(new java.awt.Dimension(80,20));\r
+            jButtonOk.setText("Ok");\r
+            jButtonOk.setActionCommand("GenGuidValue");\r
+            jButtonOk.addActionListener(this);\r
+        }\r
+        return jButtonOk;\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(600,40));\r
+            jScrollPane.setViewportView(getJTextArea());\r
+        }\r
+        return jScrollPane;\r
+    }\r
+\r
+    private JTextArea getJTextArea() {\r
+        if (jTextArea == null) {\r
+            jTextArea = new JTextArea();\r
+//            jTextArea.setBounds(new java.awt.Rectangle(40,20,300,54));\r
+\r
+        }\r
+        return jTextArea;\r
+    }\r
+\r
+    \r
+    public String getText(){\r
+       \r
+        return jTextArea.getText();\r
+    }\r
+    \r
+    public void setText(String s){\r
+        jTextArea.setText(s);\r
+    }\r
+    /**\r
+     * This is the default constructor\r
+     */\r
+    public GenLongTextDialog() {\r
+        super();\r
+        initialize();\r
+    }\r
+    \r
+    public GenLongTextDialog(ActionListener i){\r
+        this();\r
+        jButtonOk.addActionListener(i);\r
+        \r
+    }\r
+\r
+    /**\r
+     * This method initializes this\r
+     * \r
+     * @return void\r
+     */\r
+    private void initialize() {\r
+        this.setSize(620, 120);\r
+        this.setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);\r
+        this.setModal(true);\r
+        this.setTitle("Text Content");\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(getJPanelContentEast(), java.awt.BorderLayout.SOUTH);\r
+            jContentPane.add(getJPanelContentCenter(), 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/LongTextEditor.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/LongTextEditor.java
new file mode 100644 (file)
index 0000000..86a2d12
--- /dev/null
@@ -0,0 +1,93 @@
+/** @file\r
+ Java class LongTextEditor.\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
+\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 Long Text.\r
+ @since PackageEditor 1.0\r
+ **/\r
+public class LongTextEditor extends AbstractCellEditor implements TableCellEditor, ActionListener {\r
+\r
+    /**\r
+     * \r
+     */\r
+    private static final long serialVersionUID = 1L;\r
+    String text;\r
+    JButton button;\r
+    static JFrame frame;\r
+    GenLongTextDialog dialog;\r
+    protected static final String EDIT = "editLongText";\r
+\r
+    public LongTextEditor() {\r
+        \r
+        button = new JButton();\r
+        button.setActionCommand(EDIT);\r
+        button.addActionListener(this);\r
+        button.setBorderPainted(false);\r
+        \r
+        dialog = new GenLongTextDialog(this);\r
+        \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
+        text = (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 text;\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(text);\r
+            dialog.setText(text);\r
+            dialog.setVisible(true);\r
+\r
+            //Make the renderer reappear.\r
+            fireEditingStopped();\r
+        }\r
+        else { //User pressed dialog's "OK" button.\r
+            \r
+            text = dialog.getText().trim();\r
+        }\r
+\r
+    }\r
+\r
+}\r