]> git.proxmox.com Git - mirror_edk2.git/blob - Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/ListEditor.java
sort modules by name alphabetically when start; make column width resizable and remov...
[mirror_edk2.git] / Tools / Source / FrameworkWizard / src / org / tianocore / frameworkwizard / platform / ui / ListEditor.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.platform.ui;
15
16 import java.awt.Component;
17 import java.awt.event.ActionEvent;
18 import java.awt.event.ActionListener;
19 import java.util.Vector;
20
21 import javax.swing.AbstractCellEditor;
22 import javax.swing.JButton;
23 import javax.swing.JFrame;
24 import javax.swing.JTable;
25 import javax.swing.table.TableCellEditor;
26
27
28 /**
29 Editor for table cell with GUID value.
30 @since PackageEditor 1.0
31 **/
32 public class ListEditor extends AbstractCellEditor implements TableCellEditor, ActionListener {
33
34 /**
35 *
36 */
37 private static final long serialVersionUID = 1L;
38 String archs;
39 JButton button;
40 static JFrame frame;
41 GenListDialog dialog;
42 protected static final String EDIT = "edit";
43
44 public ListEditor() {
45
46 button = new JButton();
47 button.setActionCommand(EDIT);
48 button.addActionListener(this);
49 button.setBorderPainted(false);
50
51
52 dialog = new GenListDialog(this);
53
54 }
55
56 public ListEditor(Vector<String> v) {
57 this();
58 dialog.initList(v);
59 }
60
61 /* (non-Javadoc)
62 * @see javax.swing.table.TableCellEditor#getTableCellEditorComponent(javax.swing.JTable, java.lang.Object, boolean, int, int)
63 */
64 public Component getTableCellEditorComponent(JTable arg0, Object arg1, boolean arg2, int arg3, int arg4) {
65 // TODO Auto-generated method stub
66 archs = (String)arg1;
67 return button;
68 }
69
70 /* (non-Javadoc)
71 * @see javax.swing.CellEditor#getCellEditorValue()
72 */
73 public Object getCellEditorValue() {
74 // TODO Auto-generated method stub
75 return archs;
76 }
77
78 /* (non-Javadoc)
79 * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
80 */
81 public void actionPerformed(ActionEvent arg0) {
82 // TODO Auto-generated method stub
83 if (EDIT.equals(arg0.getActionCommand())) {
84 //The user has clicked the cell, so
85 //bring up the dialog.
86 button.setText(archs);
87 dialog.setList(archs);
88 dialog.setVisible(true);
89
90 //Make the renderer reappear.
91 fireEditingStopped();
92 }
93 else { //User pressed dialog's "OK" button.
94 Vector<String> v = dialog.getList();
95 String s = " ";
96 for (int i = 0; i < v.size(); ++i) {
97 s += v.get(i);
98 s += " ";
99 }
100 archs = s.trim();
101 }
102
103 }
104
105 }