summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjlin16 <jlin16@6f19259b-4bc3-4df7-8a09-765794883524>2006-09-04 09:34:14 +0000
committerjlin16 <jlin16@6f19259b-4bc3-4df7-8a09-765794883524>2006-09-04 09:34:14 +0000
commitca40209e2caed3cbdd5d124a65789237f3bff95c (patch)
treebc61a70aedfb5ec9f546f2789bd2a3049187b352
parent98c207975ec9acc2a4a65fe8c5e3e4f5ab824349 (diff)
downloadedk2-platforms-ca40209e2caed3cbdd5d124a65789237f3bff95c.tar.xz
For long text display for table cell.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@1441 6f19259b-4bc3-4df7-8a09-765794883524
-rw-r--r--Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/GenLongTextDialog.java224
-rw-r--r--Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/LongTextEditor.java93
2 files changed, 317 insertions, 0 deletions
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
index 0000000000..574be8a397
--- /dev/null
+++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/GenLongTextDialog.java
@@ -0,0 +1,224 @@
+/** @file
+ Java class GenLongTextDialog.
+
+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 java.awt.Toolkit;
+
+import javax.swing.JPanel;
+import javax.swing.JDialog;
+import javax.swing.JTextArea;
+import javax.swing.JButton;
+import java.awt.FlowLayout;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import javax.swing.JScrollPane;
+
+
+
+/**
+ Dialog for Long Text generation.
+ @since PackageEditor 1.0
+**/
+public class GenLongTextDialog extends JDialog implements ActionListener{
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+
+ private JPanel jContentPane = null;
+ private JPanel jPanelContentEast = null;
+ private JPanel jPanelContentCenter = null;
+ private JButton jButtonCancel = null;
+ private JButton jButtonOk = null;
+ private JTextArea jTextArea = null;
+
+
+ private JScrollPane jScrollPane = null;
+
+
+
+ public void actionPerformed(ActionEvent arg0) {
+
+ if (arg0.getSource() == jButtonOk){
+
+ this.dispose();
+ }
+
+ if (arg0.getSource() == jButtonCancel){
+ this.dispose();
+ }
+ }
+
+ /**
+ * This method initializes jPanel
+ *
+ * @return javax.swing.JPanel
+ */
+ private JPanel getJPanelContentEast() {
+ if (jPanelContentEast == null) {
+ FlowLayout flowLayout = new FlowLayout();
+ flowLayout.setVgap(5);
+ flowLayout.setAlignment(java.awt.FlowLayout.RIGHT);
+ jPanelContentEast = new JPanel();
+ jPanelContentEast.setLayout(flowLayout);
+ jPanelContentEast.setPreferredSize(new java.awt.Dimension(100,30));
+ jPanelContentEast.add(getJButtonOk(), null);
+ jPanelContentEast.add(getJButtonCancel(), null);
+ }
+ return jPanelContentEast;
+ }
+
+ /**
+ * This method initializes jPanel4
+ *
+ * @return javax.swing.JPanel
+ */
+ private JPanel getJPanelContentCenter() {
+ if (jPanelContentCenter == null) {
+ jPanelContentCenter = new JPanel();
+ jPanelContentCenter.setLayout(new FlowLayout());
+ jPanelContentCenter.add(getJScrollPane(), null);
+
+ }
+ return jPanelContentCenter;
+ }
+
+ /**
+ * This method initializes jButton
+ *
+ * @return javax.swing.JButton
+ */
+ private JButton getJButtonCancel() {
+ if (jButtonCancel == null) {
+ jButtonCancel = new JButton();
+ jButtonCancel.setPreferredSize(new java.awt.Dimension(80,20));
+ jButtonCancel.setText("Cancel");
+ jButtonCancel.addActionListener(this);
+ }
+ return jButtonCancel;
+ }
+
+ /**
+ * This method initializes jButton2
+ *
+ * @return javax.swing.JButton
+ */
+ private JButton getJButtonOk() {
+ if (jButtonOk == null) {
+ jButtonOk = new JButton();
+ jButtonOk.setPreferredSize(new java.awt.Dimension(80,20));
+ jButtonOk.setText("Ok");
+ jButtonOk.setActionCommand("GenGuidValue");
+ jButtonOk.addActionListener(this);
+ }
+ return jButtonOk;
+ }
+
+ /**
+ * This method initializes jScrollPane
+ *
+ * @return javax.swing.JScrollPane
+ */
+ private JScrollPane getJScrollPane() {
+ if (jScrollPane == null) {
+ jScrollPane = new JScrollPane();
+ jScrollPane.setPreferredSize(new java.awt.Dimension(600,40));
+ jScrollPane.setViewportView(getJTextArea());
+ }
+ return jScrollPane;
+ }
+
+ private JTextArea getJTextArea() {
+ if (jTextArea == null) {
+ jTextArea = new JTextArea();
+// jTextArea.setBounds(new java.awt.Rectangle(40,20,300,54));
+
+ }
+ return jTextArea;
+ }
+
+
+ public String getText(){
+
+ return jTextArea.getText();
+ }
+
+ public void setText(String s){
+ jTextArea.setText(s);
+ }
+ /**
+ * This is the default constructor
+ */
+ public GenLongTextDialog() {
+ super();
+ initialize();
+ }
+
+ public GenLongTextDialog(ActionListener i){
+ this();
+ jButtonOk.addActionListener(i);
+
+ }
+
+ /**
+ * This method initializes this
+ *
+ * @return void
+ */
+ private void initialize() {
+ this.setSize(620, 120);
+ this.setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
+ this.setModal(true);
+ this.setTitle("Text Content");
+ 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(getJPanelContentEast(), java.awt.BorderLayout.SOUTH);
+ jContentPane.add(getJPanelContentCenter(), 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);
+ }
+
+
+
+} // @jve:decl-index=0:visual-constraint="10,10"
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
index 0000000000..86a2d1295b
--- /dev/null
+++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/LongTextEditor.java
@@ -0,0 +1,93 @@
+/** @file
+ Java class LongTextEditor.
+
+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.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.JTable;
+import javax.swing.table.TableCellEditor;
+
+
+/**
+ Editor for table cell with Long Text.
+ @since PackageEditor 1.0
+ **/
+public class LongTextEditor extends AbstractCellEditor implements TableCellEditor, ActionListener {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+ String text;
+ JButton button;
+ static JFrame frame;
+ GenLongTextDialog dialog;
+ protected static final String EDIT = "editLongText";
+
+ public LongTextEditor() {
+
+ button = new JButton();
+ button.setActionCommand(EDIT);
+ button.addActionListener(this);
+ button.setBorderPainted(false);
+
+ dialog = new GenLongTextDialog(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
+ text = (String)arg1;
+ return button;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.swing.CellEditor#getCellEditorValue()
+ */
+ public Object getCellEditorValue() {
+ // TODO Auto-generated method stub
+ return text;
+ }
+
+ /* (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(text);
+ dialog.setText(text);
+ dialog.setVisible(true);
+
+ //Make the renderer reappear.
+ fireEditingStopped();
+ }
+ else { //User pressed dialog's "OK" button.
+
+ text = dialog.getText().trim();
+ }
+
+ }
+
+}