]> git.proxmox.com Git - mirror_edk2.git/blob - Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/packaging/ui/SpdProtocolDecls.java
cc0584e340d9aad940a3a384b818787490c29955
[mirror_edk2.git] / Tools / 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
20 /**
21 GUI for create library definition elements of spd file.
22
23 @since PackageEditor 1.0
24 **/
25 public class SpdProtocolDecls extends SpdGuidDecls {
26
27 /**
28 *
29 */
30 private static final long serialVersionUID = 1L;
31 private SpdFileContents sfc = null;
32
33 public SpdProtocolDecls() {
34 super();
35 // TODO Auto-generated constructor stub
36 }
37
38 public SpdProtocolDecls(PackageSurfaceAreaDocument.PackageSurfaceArea inPsa) {
39 this();
40 sfc = new SpdFileContents(inPsa);
41 init(sfc);
42 }
43
44 protected void initFrame() {
45
46 this.setTitle("Protocol Declarations");
47 getJScrollPaneGuid().setVisible(false);
48 getJLabel3().setVisible(false);
49
50 getJTable().getColumn("GuidTypes").setPreferredWidth(0);
51 getJTable().getColumn("GuidTypes").setWidth(0);
52 getJTable().getColumn("GuidTypes").setHeaderValue(" ");
53 }
54
55 protected void init(SpdFileContents sfc){
56 //
57 // initialize table using SpdFileContents object
58 //
59 DefaultTableModel model = getModel();
60 if (sfc.getSpdProtocolDeclarationCount() == 0) {
61 return ;
62 }
63 String[][] saa = new String[sfc.getSpdProtocolDeclarationCount()][6];
64 sfc.getSpdProtocolDeclarations(saa);
65 int i = 0;
66 while (i < saa.length) {
67 model.addRow(saa[i]);
68 i++;
69 }
70
71 }
72
73 protected void updateRow(int row, TableModel m){
74 String name = m.getValueAt(row, 0) + "";
75 String cName = m.getValueAt(row, 1) + "";
76 String guid = m.getValueAt(row, 2) + "";
77 String help = m.getValueAt(row, 3) + "";
78 String archList = null;
79 if (m.getValueAt(row, 4) != null) {
80 archList = m.getValueAt(row, 4).toString();
81 }
82 String modTypeList = null;
83 if (m.getValueAt(row, 5) != null) {
84 modTypeList = m.getValueAt(row, 5).toString();
85 }
86 String[] rowData = {name, cName, guid, help};
87 if (!dataValidation(rowData)){
88 return;
89 }
90
91 sfc.updateSpdProtocolDecl(row, name, cName, guid, help, archList, modTypeList);
92 }
93
94 protected void addRow(String[] row) {
95 if (!dataValidation(row)){
96 return;
97 }
98 sfc.genSpdProtocolDeclarations(row[0], row[1], row[2], row[3], stringToVector(row[4]), stringToVector(row[5]));
99 }
100
101 protected void removeRow(int i){
102 sfc.removeSpdProtocolDeclaration(i);
103 }
104
105 protected void clearAllRow(){
106 sfc.removeSpdProtocolDeclaration();
107 }
108 }