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