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