]> git.proxmox.com Git - mirror_edk2.git/blame - Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/packaging/ui/SpdProtocolDecls.java
Add Data Validations for SPD editor.
[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
19\r
20/**\r
21GUI for create library definition elements of spd file.\r
22 \r
23@since PackageEditor 1.0\r
24**/\r
25public class SpdProtocolDecls extends SpdGuidDecls {\r
26\r
ce73a791 27 /**\r
28 * \r
29 */\r
30 private static final long serialVersionUID = 1L;\r
a13899c5 31 private SpdFileContents sfc = null;\r
32 \r
33 public SpdProtocolDecls() {\r
34 super();\r
35 // TODO Auto-generated constructor stub\r
36 }\r
37\r
38 public SpdProtocolDecls(PackageSurfaceAreaDocument.PackageSurfaceArea inPsa) {\r
39 this();\r
40 sfc = new SpdFileContents(inPsa);\r
41 init(sfc);\r
42 }\r
43 \r
44 protected void initFrame() {\r
45 \r
46 this.setTitle("Protocol Declarations");\r
47 getJScrollPaneGuid().setVisible(false);\r
48 getJLabel3().setVisible(false);\r
49 \r
50 getJTable().getColumn("GuidTypes").setPreferredWidth(0);\r
51 getJTable().getColumn("GuidTypes").setWidth(0);\r
52 getJTable().getColumn("GuidTypes").setHeaderValue(" ");\r
53 }\r
54 \r
55 protected void init(SpdFileContents sfc){\r
56 //\r
57 // initialize table using SpdFileContents object\r
58 //\r
59 DefaultTableModel model = getModel();\r
60 if (sfc.getSpdProtocolDeclarationCount() == 0) {\r
61 return ;\r
62 }\r
63 String[][] saa = new String[sfc.getSpdProtocolDeclarationCount()][6];\r
64 sfc.getSpdProtocolDeclarations(saa);\r
65 int i = 0;\r
66 while (i < saa.length) {\r
67 model.addRow(saa[i]);\r
68 i++;\r
69 }\r
70 \r
71 }\r
72 \r
73 protected void updateRow(int row, TableModel m){\r
74 String name = m.getValueAt(row, 0) + "";\r
75 String cName = m.getValueAt(row, 1) + "";\r
76 String guid = m.getValueAt(row, 2) + "";\r
77 String help = m.getValueAt(row, 3) + "";\r
78 String archList = null;\r
79 if (m.getValueAt(row, 4) != null) {\r
80 archList = m.getValueAt(row, 4).toString();\r
81 }\r
82 String modTypeList = null;\r
83 if (m.getValueAt(row, 5) != null) {\r
84 modTypeList = m.getValueAt(row, 5).toString();\r
85 }\r
ce73a791 86 String[] rowData = {name, cName, guid, help};\r
87 if (!dataValidation(rowData)){\r
88 return;\r
89 }\r
a13899c5 90 \r
91 sfc.updateSpdProtocolDecl(row, name, cName, guid, help, archList, modTypeList);\r
92 }\r
93 \r
94 protected void addRow(String[] row) {\r
ce73a791 95 if (!dataValidation(row)){\r
96 return;\r
97 }\r
a13899c5 98 sfc.genSpdProtocolDeclarations(row[0], row[1], row[2], row[3], stringToVector(row[4]), stringToVector(row[5]));\r
99 }\r
100 \r
101 protected void removeRow(int i){\r
102 sfc.removeSpdProtocolDeclaration(i);\r
103 }\r
104 \r
105 protected void clearAllRow(){\r
106 sfc.removeSpdProtocolDeclaration();\r
107 }\r
108}\r