]> git.proxmox.com Git - mirror_edk2.git/blob - Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/packaging/ui/SpdPpiDecls.java
Fix the bug of leaving empty GuidTypeList, SupArchList attributes in xml file.
[mirror_edk2.git] / Tools / Source / FrameworkWizard / src / org / tianocore / frameworkwizard / packaging / ui / SpdPpiDecls.java
1 /** @file
2 Java class SpdProtocolDecls is GUI for create library definition elements of spd file.
3
4 Copyright (c) 2006, Intel Corporation
5 All rights reserved. This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
9
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12 **/
13 package org.tianocore.frameworkwizard.packaging.ui;
14
15 import javax.swing.table.DefaultTableModel;
16 import javax.swing.table.TableModel;
17
18 import org.tianocore.PackageSurfaceAreaDocument;
19 import org.tianocore.frameworkwizard.common.Identifications.OpeningPackageType;
20
21 /**
22 GUI for create library definition elements of spd file.
23
24 @since PackageEditor 1.0
25 **/
26 public class SpdPpiDecls extends SpdGuidDecls {
27
28 /**
29 *
30 */
31 private static final long serialVersionUID = 1L;
32 private SpdFileContents sfc = null;
33 private OpeningPackageType docConsole = null;
34
35 public SpdPpiDecls() {
36 super();
37 // TODO Auto-generated constructor stub
38 }
39
40 public SpdPpiDecls(PackageSurfaceAreaDocument.PackageSurfaceArea inPsa) {
41 this();
42 sfc = new SpdFileContents(inPsa);
43 init(sfc);
44 }
45
46 public SpdPpiDecls(OpeningPackageType opt) {
47 this(opt.getXmlSpd());
48 docConsole = opt;
49 }
50
51 protected void initFrame() {
52
53 this.setTitle("PPI Declarations");
54 getJScrollPaneGuid().setVisible(false);
55 getJLabel3().setVisible(false);
56
57 getJTable().getColumn("GuidTypes").setPreferredWidth(0);
58 getJTable().getColumn("GuidTypes").setWidth(0);
59 getJTable().getColumn("GuidTypes").setHeaderValue(" ");
60 }
61
62 protected void init(SpdFileContents sfc){
63 //
64 // initialize table using SpdFileContents object
65 //
66 DefaultTableModel model = getModel();
67 if (sfc.getSpdPpiDeclarationCount() == 0) {
68 return ;
69 }
70 String[][] saa = new String[sfc.getSpdPpiDeclarationCount()][6];
71 sfc.getSpdPpiDeclarations(saa);
72 int i = 0;
73 while (i < saa.length) {
74 model.addRow(saa[i]);
75 i++;
76 }
77 }
78
79 protected void updateRow(int row, TableModel m){
80 String name = m.getValueAt(row, 0) + "";
81 String cName = m.getValueAt(row, 1) + "";
82 String guid = m.getValueAt(row, 2) + "";
83 String help = m.getValueAt(row, 3) + "";
84 String archList = null;
85 if (m.getValueAt(row, 4) != null) {
86 archList = m.getValueAt(row, 4).toString();
87 }
88 String modTypeList = null;
89 if (m.getValueAt(row, 5) != null) {
90 modTypeList = m.getValueAt(row, 5).toString();
91 }
92 String[] rowData = {name, cName, guid, help};
93 if (!dataValidation(rowData)){
94 return;
95 }
96 docConsole.setSaved(false);
97 sfc.updateSpdPpiDecl(row, name, cName, guid, help, archList, modTypeList);
98 }
99
100 protected void addRow(String[] row) {
101
102 if (!dataValidation(row)){
103 return;
104 }
105 docConsole.setSaved(false);
106 sfc.genSpdPpiDeclarations(row[0], row[1], row[2], row[3], stringToVector(row[4]), stringToVector(row[5]));
107 }
108
109 protected void removeRow(int i){
110 sfc.removeSpdPpiDeclaration(i);
111 docConsole.setSaved(false);
112 }
113
114 protected void clearAllRow(){
115 sfc.removeSpdPpiDeclaration();
116 docConsole.setSaved(false);
117 }
118 }