]> git.proxmox.com Git - mirror_edk2.git/blob - Tools/Java/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/packaging/ui/SpdProtocolDecls.java
b188d128d5e4849dcdd5c1e6735337b2d346da4a
[mirror_edk2.git] / Tools / Java / Source / FrameworkWizard / src / org / tianocore / frameworkwizard / packaging / ui / SpdProtocolDecls.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 SpdProtocolDecls 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 SpdProtocolDecls() {
36 super();
37 // TODO Auto-generated constructor stub
38 }
39
40 public SpdProtocolDecls(PackageSurfaceAreaDocument.PackageSurfaceArea inPsa) {
41 this();
42 sfc = new SpdFileContents(inPsa);
43 init(sfc);
44 }
45
46 public SpdProtocolDecls(OpeningPackageType opt) {
47 this(opt.getXmlSpd());
48 docConsole = opt;
49 }
50
51 protected void initFrame() {
52
53 this.setTitle("Protocol Declarations");
54
55 }
56
57 protected void init(SpdFileContents sfc){
58 //
59 // initialize table using SpdFileContents object
60 //
61 DefaultTableModel model = getModel();
62 if (sfc.getSpdProtocolDeclarationCount() == 0) {
63 return ;
64 }
65 saa = new String[sfc.getSpdProtocolDeclarationCount()][7];
66 sfc.getSpdProtocolDeclarations(saa);
67 int i = 0;
68 while (i < saa.length) {
69 model.addRow(saa[i]);
70 i++;
71 }
72
73 }
74
75 protected void updateRow(int row, int column, TableModel m){
76 String[] sa = new String[7];
77 sfc.getSpdProtocolDeclaration(sa, row);
78 Object cellData = m.getValueAt(row, column);
79 if (cellData == null) {
80 cellData = "";
81 }
82 if (cellData.equals(sa[column])) {
83 return;
84 }
85 if (cellData.toString().length() == 0 && sa[column] == null) {
86 return;
87 }
88
89 String name = m.getValueAt(row, 0) + "";
90 String cName = m.getValueAt(row, 1) + "";
91 String guid = m.getValueAt(row, 2) + "";
92 String help = m.getValueAt(row, 3) + "";
93 String archList = null;
94 if (m.getValueAt(row, 4) != null) {
95 archList = m.getValueAt(row, 4).toString();
96 }
97 String modTypeList = null;
98 if (m.getValueAt(row, 5) != null) {
99 modTypeList = m.getValueAt(row, 5).toString();
100 }
101 String guidTypeList = null;
102 if (m.getValueAt(row, 6) != null) {
103 guidTypeList = m.getValueAt(row, 6).toString();
104 }
105 String[] rowData = {name, cName, guid, help};
106 if (!dataValidation(rowData)){
107 return;
108 }
109 docConsole.setSaved(false);
110 sfc.updateSpdProtocolDecl(row, name, cName, guid, help, archList, modTypeList, guidTypeList);
111 }
112
113 protected int addRow(String[] row) {
114 if (!dataValidation(row)){
115 return -1;
116 }
117 docConsole.setSaved(false);
118 sfc.genSpdProtocolDeclarations(row[0], row[1], row[2], row[3], stringToVector(row[4]), stringToVector(row[5]), stringToVector(row[6]));
119 return 0;
120 }
121
122 protected void removeRow(int i){
123 sfc.removeSpdProtocolDeclaration(i);
124 docConsole.setSaved(false);
125 }
126
127 protected void clearAllRow(){
128 sfc.removeSpdProtocolDeclaration();
129 docConsole.setSaved(false);
130 }
131 }