4 package org
.tianocore
.frameworkwizard
.platform
.ui
;
6 import java
.awt
.BorderLayout
;
7 import java
.awt
.Dimension
;
8 import java
.awt
.Toolkit
;
10 import javax
.swing
.JPanel
;
12 import java
.awt
.event
.ActionEvent
;
13 import java
.awt
.event
.ActionListener
;
14 import java
.util
.Vector
;
16 import javax
.swing
.JDialog
;
17 import javax
.swing
.JLabel
;
18 import javax
.swing
.JComboBox
;
19 import javax
.swing
.JTabbedPane
;
21 import org
.tianocore
.frameworkwizard
.common
.Identifications
.OpeningPlatformType
;
22 import org
.tianocore
.frameworkwizard
.module
.Identifications
.ModuleIdentification
;
23 import org
.tianocore
.frameworkwizard
.platform
.ui
.global
.WorkspaceProfile
;
29 public class GenAprioriFileDialog
extends JDialog
implements ActionListener
{
34 private static final long serialVersionUID
= 3627991301208644354L;
35 private JPanel jContentPane
= null;
36 private JPanel jPanelN
= null;
37 private JLabel jLabelFvName
= null;
38 private JComboBox jComboBoxFvNames
= null;
39 private JTabbedPane jTabbedPane
= null;
40 private FpdFileContents ffc
= null;
41 private OpeningPlatformType docConsole
= null;
44 * This is the default constructor
46 public GenAprioriFileDialog(FpdFileContents inputFfc
, OpeningPlatformType dc
) {
54 * This method initializes this
58 private void initialize() {
59 this.setSize(670, 670);
60 this.setDefaultCloseOperation(javax
.swing
.WindowConstants
.DISPOSE_ON_CLOSE
);
61 this.setTitle("Apriori Files");
62 this.setContentPane(getJContentPane());
63 this.setResizable(false);
66 String fvName
= jComboBoxFvNames
.getSelectedItem()+"";
67 if (fvName
.length() > 0) {
68 jTabbedPane
.removeAll();
69 AprioriModuleOrderPane peiPane
= new AprioriModuleOrderPane(fvName
, "", GenAprioriFileDialog
.this, true);
70 peiPane
.showModulesInFv(fvName
);
71 peiPane
.showAllModulesInPlatform();
72 jTabbedPane
.addTab("PEIMs", peiPane
);
73 AprioriModuleOrderPane dxePane
= new AprioriModuleOrderPane(fvName
, "", GenAprioriFileDialog
.this, false);
74 dxePane
.showModulesInFv(fvName
);
75 dxePane
.showAllModulesInPlatform();
76 jTabbedPane
.addTab("DXE Drivers", dxePane
);
82 * This method initializes jContentPane
84 * @return javax.swing.JPanel
86 private JPanel
getJContentPane() {
87 if (jContentPane
== null) {
88 jContentPane
= new JPanel();
89 jContentPane
.setLayout(new BorderLayout());
90 jContentPane
.add(getJPanelN(), java
.awt
.BorderLayout
.NORTH
);
91 jContentPane
.add(getJTabbedPane(), java
.awt
.BorderLayout
.CENTER
);
96 public void actionPerformed(ActionEvent arg0
) {
97 // TODO Auto-generated method stub
98 if (arg0
.getActionCommand().equals("ModuleOrderPaneOk")) {
99 docConsole
.setSaved(false);
102 if (arg0
.getActionCommand().equals("ModuleOrderPaneCancel")) {
108 Start the window at the center of screen
111 protected void centerWindow(int intWidth
, int intHeight
) {
112 Dimension d
= Toolkit
.getDefaultToolkit().getScreenSize();
113 this.setLocation((d
.width
- intWidth
) / 2, (d
.height
- intHeight
) / 2);
117 Start the window at the center of screen
120 protected void centerWindow() {
121 centerWindow(this.getSize().width
, this.getSize().height
);
125 * This method initializes jPanelN
127 * @return javax.swing.JPanel
129 private JPanel
getJPanelN() {
130 if (jPanelN
== null) {
131 jLabelFvName
= new JLabel();
132 jLabelFvName
.setText("FV Name");
133 jPanelN
= new JPanel();
134 jPanelN
.add(jLabelFvName
, null);
135 jPanelN
.add(getJComboBoxFvNames(), null);
141 * This method initializes jComboBoxFvNames
143 * @return javax.swing.JComboBox
145 private JComboBox
getJComboBoxFvNames() {
146 if (jComboBoxFvNames
== null) {
147 jComboBoxFvNames
= new JComboBox();
148 jComboBoxFvNames
.setPreferredSize(new java
.awt
.Dimension(200,20));
149 Vector
<String
> vFvNames
= new Vector
<String
>();
150 ffc
.getFvImagesFvImageFvImageNames(vFvNames
);
151 for (int i
= 0; i
< vFvNames
.size(); ++i
) {
152 jComboBoxFvNames
.addItem(vFvNames
.get(i
));
154 // if (jComboBoxFvNames.getItemCount() > 0) {
155 // jComboBoxFvNames.setSelectedIndex(0);
158 jComboBoxFvNames
.addItemListener(new java
.awt
.event
.ItemListener() {
159 public void itemStateChanged(java
.awt
.event
.ItemEvent e
) {
160 String fvName
= jComboBoxFvNames
.getSelectedItem()+"";
161 if (fvName
.length() > 0) {
162 jTabbedPane
.removeAll();
163 AprioriModuleOrderPane peiPane
= new AprioriModuleOrderPane(fvName
, "", GenAprioriFileDialog
.this, true);
164 peiPane
.showModulesInFv(fvName
);
165 peiPane
.showAllModulesInPlatform();
166 jTabbedPane
.addTab("PEIMs", peiPane
);
167 AprioriModuleOrderPane dxePane
= new AprioriModuleOrderPane(fvName
, "", GenAprioriFileDialog
.this, false);
168 dxePane
.showModulesInFv(fvName
);
169 dxePane
.showAllModulesInPlatform();
170 jTabbedPane
.addTab("DXE Drivers", dxePane
);
176 return jComboBoxFvNames
;
180 * This method initializes jTabbedPane
182 * @return javax.swing.JTabbedPane
184 private JTabbedPane
getJTabbedPane() {
185 if (jTabbedPane
== null) {
186 jTabbedPane
= new JTabbedPane();
191 private class AprioriModuleOrderPane
extends ModuleOrderPane
{
195 private static final long serialVersionUID
= -7952853414833230546L;
196 private boolean forPEI
= false;
197 private String fvName
= null;
199 AprioriModuleOrderPane (String fvName
, String file
, ActionListener action
, boolean b
) {
201 super(fvName
, file
, ffc
, action
);
202 this.fvName
= fvName
;
204 getJTableModInFv().getColumnModel().getColumn(0).setHeaderValue("Modules in Apriori File");
205 getJButtonOk().setText("Save");
206 getJButtonCancel().setText("Close");
209 public void showModulesInFv (String fvName
) {
214 int size
= ffc
.getUserExtsIncModCount(fvName
, "APRIORI", id
);
217 String
[][] saa
= new String
[size
][5];
218 ffc
.getUserExtsIncMods(fvName
, "APRIORI", id
, saa
);
220 for (int i
= 0; i
< size
; ++i
) {
221 String moduleKey
= saa
[i
][0] + " " + saa
[i
][1] + " " + saa
[i
][2] + " " + saa
[i
][3];
222 ModuleIdentification mi
= WorkspaceProfile
.getModuleId(moduleKey
);
228 String
[] row
= { name
, saa
[i
][0] , saa
[i
][1], saa
[i
][2] , saa
[i
][3], saa
[i
][4] };
229 getModInFvTableModel().addRow(row
);
234 public void actionPerformed(ActionEvent arg0
) {
235 if (arg0
.getActionCommand().equals("ModuleOrderPaneOk")) {
241 Vector
<String
[]> vModInFv
= new Vector
<String
[]>();
242 for (int i
= 0; i
< getJTableModInFv().getRowCount(); ++i
) {
243 String moduleName
= getModInFvTableModel().getValueAt(i
, 0)+"";
244 if (moduleName
.length() == 0 || moduleName
.equals("N/A")) {
248 String mg
= getModInFvTableModel().getValueAt(i
, 1)+"";
249 String mv
= getModInFvTableModel().getValueAt(i
, 2)+"";
250 String pg
= getModInFvTableModel().getValueAt(i
, 3)+"";
251 String pv
= getModInFvTableModel().getValueAt(i
, 4)+"";
252 String arch
= getModInFvTableModel().getValueAt(i
, 5)+"";
254 String
[] sa
= { mg
, mv
, pg
, pv
, arch
};
259 ffc
.removeBuildOptionsUserExtensions(fvName
, "APRIORI", id
);
260 ffc
.genBuildOptionsUserExtensions(fvName
, "APRIORI", id
, "", vModInFv
);
265 } // @jve:decl-index=0:visual-constraint="10,10"