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