]> git.proxmox.com Git - mirror_edk2.git/blame - Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/packaging/ui/SpdProtocolDecls.java
Change radio button in package header editor to a label.
[mirror_edk2.git] / Tools / 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
15import javax.swing.table.DefaultTableModel;\r
16import javax.swing.table.TableModel;\r
17\r
18import org.tianocore.PackageSurfaceAreaDocument;\r
d6d24759 19import org.tianocore.frameworkwizard.common.Identifications.OpeningPackageType;\r
a13899c5 20\r
21/**\r
22GUI for create library definition elements of spd file.\r
23 \r
24@since PackageEditor 1.0\r
25**/\r
26public class SpdProtocolDecls extends SpdGuidDecls {\r
27\r
ce73a791 28 /**\r
29 * \r
30 */\r
31 private static final long serialVersionUID = 1L;\r
a13899c5 32 private SpdFileContents sfc = null;\r
d6d24759 33 private OpeningPackageType docConsole = null;\r
a13899c5 34 \r
35 public SpdProtocolDecls() {\r
36 super();\r
37 // TODO Auto-generated constructor stub\r
38 }\r
39\r
40 public SpdProtocolDecls(PackageSurfaceAreaDocument.PackageSurfaceArea inPsa) {\r
41 this();\r
42 sfc = new SpdFileContents(inPsa);\r
43 init(sfc);\r
44 }\r
45 \r
d6d24759 46 public SpdProtocolDecls(OpeningPackageType opt) {\r
47 this(opt.getXmlSpd());\r
48 docConsole = opt;\r
49 }\r
50 \r
a13899c5 51 protected void initFrame() {\r
52 \r
53 this.setTitle("Protocol Declarations");\r
a13899c5 54 \r
a13899c5 55 }\r
56 \r
57 protected void init(SpdFileContents sfc){\r
58 //\r
59 // initialize table using SpdFileContents object\r
60 //\r
61 DefaultTableModel model = getModel();\r
62 if (sfc.getSpdProtocolDeclarationCount() == 0) {\r
63 return ;\r
64 }\r
a490bca8 65 saa = new String[sfc.getSpdProtocolDeclarationCount()][7];\r
a13899c5 66 sfc.getSpdProtocolDeclarations(saa);\r
67 int i = 0;\r
68 while (i < saa.length) {\r
69 model.addRow(saa[i]);\r
70 i++;\r
71 }\r
72 \r
73 }\r
74 \r
a490bca8 75 protected void updateRow(int row, int column, TableModel m){\r
76 String[] sa = new String[7];\r
77 sfc.getSpdProtocolDeclaration(sa, row);\r
78 Object cellData = m.getValueAt(row, column);\r
79 if (cellData == null) {\r
80 cellData = "";\r
81 }\r
82 if (cellData.equals(sa[column])) {\r
83 return;\r
84 }\r
85 if (cellData.toString().length() == 0 && sa[column] == null) {\r
86 return;\r
87 }\r
88 \r
a13899c5 89 String name = m.getValueAt(row, 0) + "";\r
90 String cName = m.getValueAt(row, 1) + "";\r
91 String guid = m.getValueAt(row, 2) + "";\r
92 String help = m.getValueAt(row, 3) + "";\r
93 String archList = null;\r
94 if (m.getValueAt(row, 4) != null) {\r
95 archList = m.getValueAt(row, 4).toString();\r
96 }\r
97 String modTypeList = null;\r
98 if (m.getValueAt(row, 5) != null) {\r
99 modTypeList = m.getValueAt(row, 5).toString();\r
100 }\r
1be13d3f 101 String guidTypeList = null;\r
102 if (m.getValueAt(row, 6) != null) {\r
103 guidTypeList = m.getValueAt(row, 6).toString();\r
104 }\r
ce73a791 105 String[] rowData = {name, cName, guid, help};\r
106 if (!dataValidation(rowData)){\r
107 return;\r
108 }\r
d6d24759 109 docConsole.setSaved(false);\r
1be13d3f 110 sfc.updateSpdProtocolDecl(row, name, cName, guid, help, archList, modTypeList, guidTypeList);\r
a13899c5 111 }\r
112 \r
5f97c029 113 protected int addRow(String[] row) {\r
ce73a791 114 if (!dataValidation(row)){\r
5f97c029 115 return -1;\r
ce73a791 116 }\r
2c85fbc8 117 docConsole.setSaved(false);\r
1be13d3f 118 sfc.genSpdProtocolDeclarations(row[0], row[1], row[2], row[3], stringToVector(row[4]), stringToVector(row[5]), stringToVector(row[6]));\r
5f97c029 119 return 0;\r
a13899c5 120 }\r
121 \r
122 protected void removeRow(int i){\r
123 sfc.removeSpdProtocolDeclaration(i);\r
2c85fbc8 124 docConsole.setSaved(false);\r
a13899c5 125 }\r
126 \r
127 protected void clearAllRow(){\r
128 sfc.removeSpdProtocolDeclaration();\r
2c85fbc8 129 docConsole.setSaved(false);\r
a13899c5 130 }\r
131}\r