]> git.proxmox.com Git - mirror_edk2.git/blame - Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/packaging/ui/SpdPpiDecls.java
Add Data Validations for SPD editor.
[mirror_edk2.git] / Tools / Source / FrameworkWizard / src / org / tianocore / frameworkwizard / packaging / ui / SpdPpiDecls.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
a13899c5 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 SpdPpiDecls 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 SpdPpiDecls() {\r
34 super();\r
35 // TODO Auto-generated constructor stub\r
36 }\r
37\r
38 public SpdPpiDecls(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("PPI 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.getSpdPpiDeclarationCount() == 0) {\r
61 return ;\r
62 }\r
63 String[][] saa = new String[sfc.getSpdPpiDeclarationCount()][6];\r
64 sfc.getSpdPpiDeclarations(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 protected void updateRow(int row, TableModel m){\r
73 String name = m.getValueAt(row, 0) + "";\r
74 String cName = m.getValueAt(row, 1) + "";\r
75 String guid = m.getValueAt(row, 2) + "";\r
76 String help = m.getValueAt(row, 3) + "";\r
77 String archList = null;\r
78 if (m.getValueAt(row, 4) != null) {\r
79 archList = m.getValueAt(row, 4).toString();\r
80 }\r
81 String modTypeList = null;\r
82 if (m.getValueAt(row, 5) != null) {\r
83 modTypeList = m.getValueAt(row, 5).toString();\r
84 }\r
ce73a791 85 String[] rowData = {name, cName, guid, help};\r
86 if (!dataValidation(rowData)){\r
87 return;\r
88 }\r
a13899c5 89 sfc.updateSpdPpiDecl(row, name, cName, guid, help, archList, modTypeList);\r
90 }\r
91 \r
92 protected void addRow(String[] row) {\r
ce73a791 93 \r
94 if (!dataValidation(row)){\r
95 return;\r
96 }\r
a13899c5 97 sfc.genSpdPpiDeclarations(row[0], row[1], row[2], row[3], stringToVector(row[4]), stringToVector(row[5]));\r
98 }\r
99 \r
100 protected void removeRow(int i){\r
101 sfc.removeSpdPpiDeclaration(i);\r
102 }\r
103 \r
104 protected void clearAllRow(){\r
105 sfc.removeSpdPpiDeclaration();\r
106 }\r
107}\r