]> git.proxmox.com Git - mirror_edk2.git/blob - Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/packaging/ui/GuidEditor.java
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@671 6f19259b...
[mirror_edk2.git] / Tools / Source / FrameworkWizard / src / org / tianocore / frameworkwizard / packaging / ui / GuidEditor.java
1 /** @file
2 Java class GuidEditor.
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.packaging.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.JOptionPane;
24 import javax.swing.JTable;
25 import javax.swing.table.TableCellEditor;
26
27 import org.tianocore.frameworkwizard.common.Tools;
28
29 /**
30 Editor for table cell with GUID value.
31 @since PackageEditor 1.0
32 **/
33 public class GuidEditor extends AbstractCellEditor implements TableCellEditor, ActionListener {
34
35 String currentGuid;
36 JButton button;
37 static JFrame frame;
38 GenGuidDialog dialog;
39 protected static final String EDIT = "edit";
40
41 public GuidEditor() {
42
43 button = new JButton();
44 button.setActionCommand(EDIT);
45 button.addActionListener(this);
46 button.setBorderPainted(false);
47
48
49 dialog = new GenGuidDialog(this);
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 currentGuid = (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 currentGuid;
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(currentGuid);
79 dialog.setGuid(currentGuid);
80 dialog.setVisible(true);
81
82 //Make the renderer reappear.
83 fireEditingStopped();
84 }
85 else { //User pressed dialog's "OK" button.
86 currentGuid = dialog.getGuid();
87
88 }
89
90 }
91
92 }