a13899c5 |
1 | /** @file\r |
2 | Java class SpdProtocolDecls is GUI for create library definition elements of spd file.\r |
3 | \r |
4 | Copyright (c) 2006, Intel Corporation\r |
5 | All rights reserved. This program and the accompanying materials\r |
6 | are licensed and made available under the terms and conditions of the BSD License\r |
7 | which accompanies this distribution. The full text of the license may be found at\r |
8 | http://opensource.org/licenses/bsd-license.php\r |
9 | \r |
10 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r |
11 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r |
12 | **/\r |
13 | package org.tianocore.frameworkwizard.packaging.ui;\r |
14 | \r |
15 | import javax.swing.table.DefaultTableModel;\r |
16 | import javax.swing.table.TableModel;\r |
17 | \r |
18 | import org.tianocore.PackageSurfaceAreaDocument;\r |
d6d24759 |
19 | import org.tianocore.frameworkwizard.common.Identifications.OpeningPackageType;\r |
a13899c5 |
20 | \r |
21 | /**\r |
22 | GUI for create library definition elements of spd file.\r |
23 | \r |
24 | @since PackageEditor 1.0\r |
25 | **/\r |
26 | public 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 |
54 | getJScrollPaneGuid().setVisible(false);\r |
55 | getJLabel3().setVisible(false);\r |
56 | \r |
57 | getJTable().getColumn("GuidTypes").setPreferredWidth(0);\r |
58 | getJTable().getColumn("GuidTypes").setWidth(0);\r |
59 | getJTable().getColumn("GuidTypes").setHeaderValue(" ");\r |
60 | }\r |
61 | \r |
62 | protected void init(SpdFileContents sfc){\r |
63 | //\r |
64 | // initialize table using SpdFileContents object\r |
65 | //\r |
66 | DefaultTableModel model = getModel();\r |
67 | if (sfc.getSpdProtocolDeclarationCount() == 0) {\r |
68 | return ;\r |
69 | }\r |
70 | String[][] saa = new String[sfc.getSpdProtocolDeclarationCount()][6];\r |
71 | sfc.getSpdProtocolDeclarations(saa);\r |
72 | int i = 0;\r |
73 | while (i < saa.length) {\r |
74 | model.addRow(saa[i]);\r |
75 | i++;\r |
76 | }\r |
77 | \r |
78 | }\r |
79 | \r |
80 | protected void updateRow(int row, TableModel m){\r |
81 | String name = m.getValueAt(row, 0) + "";\r |
82 | String cName = m.getValueAt(row, 1) + "";\r |
83 | String guid = m.getValueAt(row, 2) + "";\r |
84 | String help = m.getValueAt(row, 3) + "";\r |
85 | String archList = null;\r |
86 | if (m.getValueAt(row, 4) != null) {\r |
87 | archList = m.getValueAt(row, 4).toString();\r |
88 | }\r |
89 | String modTypeList = null;\r |
90 | if (m.getValueAt(row, 5) != null) {\r |
91 | modTypeList = m.getValueAt(row, 5).toString();\r |
92 | }\r |
ce73a791 |
93 | String[] rowData = {name, cName, guid, help};\r |
94 | if (!dataValidation(rowData)){\r |
95 | return;\r |
96 | }\r |
d6d24759 |
97 | docConsole.setSaved(false);\r |
a13899c5 |
98 | sfc.updateSpdProtocolDecl(row, name, cName, guid, help, archList, modTypeList);\r |
99 | }\r |
100 | \r |
101 | protected void addRow(String[] row) {\r |
ce73a791 |
102 | if (!dataValidation(row)){\r |
103 | return;\r |
104 | }\r |
a13899c5 |
105 | sfc.genSpdProtocolDeclarations(row[0], row[1], row[2], row[3], stringToVector(row[4]), stringToVector(row[5]));\r |
106 | }\r |
107 | \r |
108 | protected void removeRow(int i){\r |
109 | sfc.removeSpdProtocolDeclaration(i);\r |
110 | }\r |
111 | \r |
112 | protected void clearAllRow(){\r |
113 | sfc.removeSpdProtocolDeclaration();\r |
114 | }\r |
115 | }\r |