]> git.proxmox.com Git - mirror_edk2.git/blob - Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/packaging/ui/SpdPpiDecls.java
Add Data Validations for SPD editor.
[mirror_edk2.git] / Tools / 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
20 /**
21 GUI for create library definition elements of spd file.
22
23 @since PackageEditor 1.0
24 **/
25 public class SpdPpiDecls extends SpdGuidDecls {
26
27 /**
28 *
29 */
30 private static final long serialVersionUID = 1L;
31 private SpdFileContents sfc = null;
32
33 public SpdPpiDecls() {
34 super();
35 // TODO Auto-generated constructor stub
36 }
37
38 public SpdPpiDecls(PackageSurfaceAreaDocument.PackageSurfaceArea inPsa) {
39 this();
40 sfc = new SpdFileContents(inPsa);
41 init(sfc);
42 }
43
44 protected void initFrame() {
45
46 this.setTitle("PPI 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.getSpdPpiDeclarationCount() == 0) {
61 return ;
62 }
63 String[][] saa = new String[sfc.getSpdPpiDeclarationCount()][6];
64 sfc.getSpdPpiDeclarations(saa);
65 int i = 0;
66 while (i < saa.length) {
67 model.addRow(saa[i]);
68 i++;
69 }
70 }
71
72 protected void updateRow(int row, TableModel m){
73 String name = m.getValueAt(row, 0) + "";
74 String cName = m.getValueAt(row, 1) + "";
75 String guid = m.getValueAt(row, 2) + "";
76 String help = m.getValueAt(row, 3) + "";
77 String archList = null;
78 if (m.getValueAt(row, 4) != null) {
79 archList = m.getValueAt(row, 4).toString();
80 }
81 String modTypeList = null;
82 if (m.getValueAt(row, 5) != null) {
83 modTypeList = m.getValueAt(row, 5).toString();
84 }
85 String[] rowData = {name, cName, guid, help};
86 if (!dataValidation(rowData)){
87 return;
88 }
89 sfc.updateSpdPpiDecl(row, name, cName, guid, help, archList, modTypeList);
90 }
91
92 protected void addRow(String[] row) {
93
94 if (!dataValidation(row)){
95 return;
96 }
97 sfc.genSpdPpiDeclarations(row[0], row[1], row[2], row[3], stringToVector(row[4]), stringToVector(row[5]));
98 }
99
100 protected void removeRow(int i){
101 sfc.removeSpdPpiDeclaration(i);
102 }
103
104 protected void clearAllRow(){
105 sfc.removeSpdPpiDeclaration();
106 }
107 }