]> git.proxmox.com Git - mirror_edk2.git/blob - Tools/Java/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/LongTextEditor.java
Make opening dialogs re-gain focus when user switch back to main UI from other window...
[mirror_edk2.git] / Tools / Java / 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 GenLongTextDialog dialog;
40 protected static final String EDIT = "editLongText";
41
42 public LongTextEditor(JFrame frame) {
43
44 button = new JButton();
45 button.setActionCommand(EDIT);
46 button.addActionListener(this);
47 button.setBorderPainted(false);
48
49 dialog = new GenLongTextDialog(this, frame);
50
51 }
52
53 /* (non-Javadoc)
54 * @see javax.swing.table.TableCellEditor#getTableCellEditorComponent(javax.swing.JTable, java.lang.Object, boolean, int, int)
55 */
56 public Component getTableCellEditorComponent(JTable arg0, Object arg1, boolean arg2, int arg3, int arg4) {
57 // TODO Auto-generated method stub
58 text = (String)arg1;
59 return button;
60 }
61
62 /* (non-Javadoc)
63 * @see javax.swing.CellEditor#getCellEditorValue()
64 */
65 public Object getCellEditorValue() {
66 // TODO Auto-generated method stub
67 return text;
68 }
69
70 /* (non-Javadoc)
71 * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
72 */
73 public void actionPerformed(ActionEvent arg0) {
74 // TODO Auto-generated method stub
75 if (EDIT.equals(arg0.getActionCommand())) {
76 //The user has clicked the cell, so
77 //bring up the dialog.
78 button.setText(text);
79 dialog.setText(text);
80 dialog.setVisible(true);
81
82 //Make the renderer reappear.
83 fireEditingStopped();
84 }
85 else { //User pressed dialog's "OK" button.
86
87 text = dialog.getText().trim();
88 dialog.dispose();
89 }
90
91 }
92
93 }