2 Java class SpdProtocolDecls is GUI for create library definition elements of spd file.
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
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.
13 package org
.tianocore
.frameworkwizard
.packaging
.ui
;
15 import javax
.swing
.JFrame
;
16 import javax
.swing
.JOptionPane
;
17 import javax
.swing
.table
.DefaultTableModel
;
18 import javax
.swing
.table
.TableModel
;
20 import org
.tianocore
.PackageSurfaceAreaDocument
;
21 import org
.tianocore
.frameworkwizard
.common
.Identifications
.OpeningPackageType
;
22 import org
.tianocore
.frameworkwizard
.platform
.ui
.ListEditor
;
25 GUI for create library definition elements of spd file.
27 @since PackageEditor 1.0
29 public class SpdProtocolDecls
extends SpdGuidDecls
{
34 private static final long serialVersionUID
= 1L;
35 private SpdFileContents sfc
= null;
36 private OpeningPackageType docConsole
= null;
38 public SpdProtocolDecls(JFrame frame
) {
40 // TODO Auto-generated constructor stub
43 public SpdProtocolDecls(PackageSurfaceAreaDocument
.PackageSurfaceArea inPsa
, JFrame frame
) {
45 sfc
= new SpdFileContents(inPsa
);
49 public SpdProtocolDecls(OpeningPackageType opt
, JFrame frame
) {
50 this(opt
.getXmlSpd(), frame
);
52 if (sfc
.getSpdPkgDefsRdOnly().equals("true")) {
53 JOptionPane
.showMessageDialog(this, "This is a read-only package. You will not be able to edit contents in table.");
58 protected void initFrame() {
60 this.setTitle("Protocol Declarations");
61 starLabel
.setVisible(false);
62 ((ListEditor
)getJTable().getColumnModel().getColumn(6).getCellEditor()).setCanNotBeEmpty(false);
65 protected void init(SpdFileContents sfc
){
67 // initialize table using SpdFileContents object
69 DefaultTableModel model
= getModel();
70 if (sfc
.getSpdProtocolDeclarationCount() == 0) {
73 saa
= new String
[sfc
.getSpdProtocolDeclarationCount()][7];
74 sfc
.getSpdProtocolDeclarations(saa
);
76 while (i
< saa
.length
) {
83 protected void updateRow(int row
, int column
, TableModel m
){
84 String
[] sa
= new String
[7];
85 sfc
.getSpdProtocolDeclaration(sa
, row
);
86 Object cellData
= m
.getValueAt(row
, column
);
87 if (cellData
== null) {
90 if (cellData
.equals(sa
[column
])) {
93 if (cellData
.toString().length() == 0 && sa
[column
] == null) {
97 String name
= m
.getValueAt(row
, 0) + "";
98 String cName
= m
.getValueAt(row
, 1) + "";
99 String guid
= m
.getValueAt(row
, 2) + "";
100 String help
= m
.getValueAt(row
, 3) + "";
101 String archList
= null;
102 if (m
.getValueAt(row
, 4) != null) {
103 archList
= m
.getValueAt(row
, 4).toString();
105 String modTypeList
= null;
106 if (m
.getValueAt(row
, 5) != null) {
107 modTypeList
= m
.getValueAt(row
, 5).toString();
109 String guidTypeList
= null;
110 if (m
.getValueAt(row
, 6) != null) {
111 guidTypeList
= m
.getValueAt(row
, 6).toString();
113 String
[] rowData
= {name
, cName
, guid
, help
};
114 if (!dataValidation(rowData
)){
117 docConsole
.setSaved(false);
118 sfc
.updateSpdProtocolDecl(row
, name
, cName
, guid
, help
, archList
, modTypeList
, guidTypeList
);
121 protected int addRow(String
[] row
) {
122 if (!dataValidation(row
)){
125 docConsole
.setSaved(false);
126 sfc
.genSpdProtocolDeclarations(row
[0], row
[1], row
[2], row
[3], stringToVector(row
[4]), stringToVector(row
[5]), stringToVector(row
[6]));
130 protected void removeRow(int i
){
131 sfc
.removeSpdProtocolDeclaration(i
);
132 docConsole
.setSaved(false);
135 protected void clearAllRow(){
136 sfc
.removeSpdProtocolDeclaration();
137 docConsole
.setSaved(false);
141 * @return Returns the sfc.
143 protected SpdFileContents
getSfc() {