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