]> git.proxmox.com Git - mirror_edk2.git/blame - Tools/Java/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/packaging/ui/SpdProtocolDecls.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 / packaging / ui / SpdProtocolDecls.java
CommitLineData
a13899c5 1/** @file\r
2 Java class SpdProtocolDecls is GUI for create library definition elements of spd file.\r
3 \r
4Copyright (c) 2006, Intel Corporation\r
5All rights reserved. This program and the accompanying materials\r
6are licensed and made available under the terms and conditions of the BSD License\r
7which accompanies this distribution. The full text of the license may be found at\r
8http://opensource.org/licenses/bsd-license.php\r
9\r
10THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
12**/\r
13package org.tianocore.frameworkwizard.packaging.ui;\r
14\r
82484861 15import javax.swing.JFrame;\r
62df8efa 16import javax.swing.JOptionPane;\r
a13899c5 17import javax.swing.table.DefaultTableModel;\r
18import javax.swing.table.TableModel;\r
19\r
20import org.tianocore.PackageSurfaceAreaDocument;\r
d6d24759 21import org.tianocore.frameworkwizard.common.Identifications.OpeningPackageType;\r
fbf730ff 22import org.tianocore.frameworkwizard.platform.ui.ListEditor;\r
a13899c5 23\r
24/**\r
25GUI for create library definition elements of spd file.\r
26 \r
27@since PackageEditor 1.0\r
28**/\r
29public class SpdProtocolDecls extends SpdGuidDecls {\r
30\r
ce73a791 31 /**\r
32 * \r
33 */\r
34 private static final long serialVersionUID = 1L;\r
a13899c5 35 private SpdFileContents sfc = null;\r
d6d24759 36 private OpeningPackageType docConsole = null;\r
a13899c5 37 \r
82484861 38 public SpdProtocolDecls(JFrame frame) {\r
39 super(frame);\r
a13899c5 40 // TODO Auto-generated constructor stub\r
41 }\r
42\r
82484861 43 public SpdProtocolDecls(PackageSurfaceAreaDocument.PackageSurfaceArea inPsa, JFrame frame) {\r
44 this(frame);\r
a13899c5 45 sfc = new SpdFileContents(inPsa);\r
46 init(sfc);\r
47 }\r
48 \r
82484861 49 public SpdProtocolDecls(OpeningPackageType opt, JFrame frame) {\r
50 this(opt.getXmlSpd(), frame);\r
d6d24759 51 docConsole = opt;\r
62df8efa 52 if (sfc.getSpdPkgDefsRdOnly().equals("true")) {\r
82484861 53 JOptionPane.showMessageDialog(this, "This is a read-only package. You will not be able to edit contents in table.");\r
62df8efa 54 }\r
55 initFrame();\r
d6d24759 56 }\r
57 \r
a13899c5 58 protected void initFrame() {\r
62df8efa 59 super.initFrame();\r
a13899c5 60 this.setTitle("Protocol Declarations");\r
fbf730ff 61 starLabel.setVisible(false);\r
62 ((ListEditor)getJTable().getColumnModel().getColumn(6).getCellEditor()).setCanNotBeEmpty(false);\r
a13899c5 63 }\r
64 \r
65 protected void init(SpdFileContents sfc){\r
66 //\r
67 // initialize table using SpdFileContents object\r
68 //\r
69 DefaultTableModel model = getModel();\r
70 if (sfc.getSpdProtocolDeclarationCount() == 0) {\r
71 return ;\r
72 }\r
a490bca8 73 saa = new String[sfc.getSpdProtocolDeclarationCount()][7];\r
a13899c5 74 sfc.getSpdProtocolDeclarations(saa);\r
75 int i = 0;\r
76 while (i < saa.length) {\r
77 model.addRow(saa[i]);\r
78 i++;\r
79 }\r
80 \r
81 }\r
82 \r
a490bca8 83 protected void updateRow(int row, int column, TableModel m){\r
84 String[] sa = new String[7];\r
85 sfc.getSpdProtocolDeclaration(sa, row);\r
86 Object cellData = m.getValueAt(row, column);\r
87 if (cellData == null) {\r
88 cellData = "";\r
89 }\r
90 if (cellData.equals(sa[column])) {\r
91 return;\r
92 }\r
93 if (cellData.toString().length() == 0 && sa[column] == null) {\r
94 return;\r
95 }\r
96 \r
a13899c5 97 String name = m.getValueAt(row, 0) + "";\r
98 String cName = m.getValueAt(row, 1) + "";\r
99 String guid = m.getValueAt(row, 2) + "";\r
100 String help = m.getValueAt(row, 3) + "";\r
101 String archList = null;\r
102 if (m.getValueAt(row, 4) != null) {\r
103 archList = m.getValueAt(row, 4).toString();\r
104 }\r
105 String modTypeList = null;\r
106 if (m.getValueAt(row, 5) != null) {\r
107 modTypeList = m.getValueAt(row, 5).toString();\r
108 }\r
1be13d3f 109 String guidTypeList = null;\r
110 if (m.getValueAt(row, 6) != null) {\r
111 guidTypeList = m.getValueAt(row, 6).toString();\r
112 }\r
ce73a791 113 String[] rowData = {name, cName, guid, help};\r
114 if (!dataValidation(rowData)){\r
115 return;\r
116 }\r
d6d24759 117 docConsole.setSaved(false);\r
1be13d3f 118 sfc.updateSpdProtocolDecl(row, name, cName, guid, help, archList, modTypeList, guidTypeList);\r
a13899c5 119 }\r
120 \r
5f97c029 121 protected int addRow(String[] row) {\r
ce73a791 122 if (!dataValidation(row)){\r
5f97c029 123 return -1;\r
ce73a791 124 }\r
2c85fbc8 125 docConsole.setSaved(false);\r
1be13d3f 126 sfc.genSpdProtocolDeclarations(row[0], row[1], row[2], row[3], stringToVector(row[4]), stringToVector(row[5]), stringToVector(row[6]));\r
5f97c029 127 return 0;\r
a13899c5 128 }\r
129 \r
130 protected void removeRow(int i){\r
131 sfc.removeSpdProtocolDeclaration(i);\r
2c85fbc8 132 docConsole.setSaved(false);\r
a13899c5 133 }\r
134 \r
135 protected void clearAllRow(){\r
136 sfc.removeSpdProtocolDeclaration();\r
2c85fbc8 137 docConsole.setSaved(false);\r
a13899c5 138 }\r
62df8efa 139 \r
140 /**\r
141 * @return Returns the sfc.\r
142 */\r
143 protected SpdFileContents getSfc() {\r
144 return sfc;\r
145 }\r
a13899c5 146}\r