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