]> git.proxmox.com Git - mirror_edk2.git/blob - Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/LongTextEditor.java
86a2d1295bb9fbae6054e47831925dcda3045bc3
[mirror_edk2.git] / Tools / Source / FrameworkWizard / src / org / tianocore / frameworkwizard / platform / ui / LongTextEditor.java
1 /** @file
2 Java class LongTextEditor.
3
4 Copyright (c) 2006, Intel Corporation
5 All rights reserved. This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
9
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12
13 **/
14 package org.tianocore.frameworkwizard.platform.ui;
15
16 import java.awt.Component;
17 import java.awt.event.ActionEvent;
18 import java.awt.event.ActionListener;
19
20 import javax.swing.AbstractCellEditor;
21 import javax.swing.JButton;
22 import javax.swing.JFrame;
23 import javax.swing.JTable;
24 import javax.swing.table.TableCellEditor;
25
26
27 /**
28 Editor for table cell with Long Text.
29 @since PackageEditor 1.0
30 **/
31 public class LongTextEditor extends AbstractCellEditor implements TableCellEditor, ActionListener {
32
33 /**
34 *
35 */
36 private static final long serialVersionUID = 1L;
37 String text;
38 JButton button;
39 static JFrame frame;
40 GenLongTextDialog dialog;
41 protected static final String EDIT = "editLongText";
42
43 public LongTextEditor() {
44
45 button = new JButton();
46 button.setActionCommand(EDIT);
47 button.addActionListener(this);
48 button.setBorderPainted(false);
49
50 dialog = new GenLongTextDialog(this);
51
52 }
53
54 /* (non-Javadoc)
55 * @see javax.swing.table.TableCellEditor#getTableCellEditorComponent(javax.swing.JTable, java.lang.Object, boolean, int, int)
56 */
57 public Component getTableCellEditorComponent(JTable arg0, Object arg1, boolean arg2, int arg3, int arg4) {
58 // TODO Auto-generated method stub
59 text = (String)arg1;
60 return button;
61 }
62
63 /* (non-Javadoc)
64 * @see javax.swing.CellEditor#getCellEditorValue()
65 */
66 public Object getCellEditorValue() {
67 // TODO Auto-generated method stub
68 return text;
69 }
70
71 /* (non-Javadoc)
72 * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
73 */
74 public void actionPerformed(ActionEvent arg0) {
75 // TODO Auto-generated method stub
76 if (EDIT.equals(arg0.getActionCommand())) {
77 //The user has clicked the cell, so
78 //bring up the dialog.
79 button.setText(text);
80 dialog.setText(text);
81 dialog.setVisible(true);
82
83 //Make the renderer reappear.
84 fireEditingStopped();
85 }
86 else { //User pressed dialog's "OK" button.
87
88 text = dialog.getText().trim();
89 }
90
91 }
92
93 }