]>
Commit | Line | Data |
---|---|---|
99125b46 | 1 | /**\r |
2 | * \r | |
3 | */\r | |
4 | package org.tianocore.frameworkwizard.platform.ui;\r | |
5 | \r | |
6 | import java.awt.BorderLayout;\r | |
7 | import java.awt.Dimension;\r | |
8 | import java.awt.Toolkit;\r | |
9 | \r | |
10 | import javax.swing.JPanel;\r | |
11 | \r | |
12 | import java.awt.event.ActionEvent;\r | |
13 | import java.awt.event.ActionListener;\r | |
14 | import java.util.Vector;\r | |
15 | \r | |
16 | import javax.swing.JDialog;\r | |
17 | import javax.swing.JLabel;\r | |
18 | import javax.swing.JComboBox;\r | |
19 | import javax.swing.JTabbedPane;\r | |
20 | \r | |
21 | import org.tianocore.frameworkwizard.common.Identifications.OpeningPlatformType;\r | |
22 | import org.tianocore.frameworkwizard.module.Identifications.ModuleIdentification;\r | |
23 | import org.tianocore.frameworkwizard.platform.ui.global.WorkspaceProfile;\r | |
24 | \r | |
25 | /**\r | |
26 | * @author jlin16\r | |
27 | *\r | |
28 | */\r | |
29 | public class GenAprioriFileDialog extends JDialog implements ActionListener {\r | |
30 | \r | |
31 | /**\r | |
32 | * \r | |
33 | */\r | |
34 | private static final long serialVersionUID = 3627991301208644354L;\r | |
35 | private JPanel jContentPane = null;\r | |
36 | private JPanel jPanelN = null;\r | |
37 | private JLabel jLabelFvName = null;\r | |
38 | private JComboBox jComboBoxFvNames = null;\r | |
39 | private JTabbedPane jTabbedPane = null;\r | |
40 | private FpdFileContents ffc = null;\r | |
41 | private OpeningPlatformType docConsole = null;\r | |
42 | \r | |
43 | /**\r | |
44 | * This is the default constructor\r | |
45 | */\r | |
46 | public GenAprioriFileDialog(FpdFileContents inputFfc, OpeningPlatformType dc) {\r | |
47 | super();\r | |
48 | ffc = inputFfc;\r | |
49 | docConsole = dc;\r | |
50 | initialize();\r | |
51 | }\r | |
52 | \r | |
53 | /**\r | |
54 | * This method initializes this\r | |
55 | * \r | |
56 | * @return void\r | |
57 | */\r | |
58 | private void initialize() {\r | |
59 | this.setSize(670, 670);\r | |
60 | this.setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);\r | |
61 | this.setTitle("Apriori Files");\r | |
62 | this.setContentPane(getJContentPane());\r | |
63 | this.setResizable(false);\r | |
64 | this.setModal(true);\r | |
65 | \r | |
66 | String fvName = jComboBoxFvNames.getSelectedItem()+"";\r | |
67 | if (fvName.length() > 0) {\r | |
68 | jTabbedPane.removeAll();\r | |
69 | AprioriModuleOrderPane peiPane = new AprioriModuleOrderPane(fvName, "", GenAprioriFileDialog.this, true);\r | |
70 | peiPane.showModulesInFv(fvName);\r | |
71 | peiPane.showAllModulesInPlatform();\r | |
72 | jTabbedPane.addTab("PEIMs", peiPane);\r | |
73 | AprioriModuleOrderPane dxePane = new AprioriModuleOrderPane(fvName, "", GenAprioriFileDialog.this, false);\r | |
74 | dxePane.showModulesInFv(fvName);\r | |
75 | dxePane.showAllModulesInPlatform();\r | |
76 | jTabbedPane.addTab("DXE Drivers", dxePane);\r | |
77 | }\r | |
78 | this.centerWindow();\r | |
79 | }\r | |
80 | \r | |
81 | /**\r | |
82 | * This method initializes jContentPane\r | |
83 | * \r | |
84 | * @return javax.swing.JPanel\r | |
85 | */\r | |
86 | private JPanel getJContentPane() {\r | |
87 | if (jContentPane == null) {\r | |
88 | jContentPane = new JPanel();\r | |
89 | jContentPane.setLayout(new BorderLayout());\r | |
90 | jContentPane.add(getJPanelN(), java.awt.BorderLayout.NORTH);\r | |
91 | jContentPane.add(getJTabbedPane(), java.awt.BorderLayout.CENTER);\r | |
92 | }\r | |
93 | return jContentPane;\r | |
94 | }\r | |
95 | \r | |
96 | public void actionPerformed(ActionEvent arg0) {\r | |
97 | // TODO Auto-generated method stub\r | |
98 | if (arg0.getActionCommand().equals("ModuleOrderPaneOk")) {\r | |
99 | docConsole.setSaved(false);\r | |
100 | return;\r | |
101 | }\r | |
102 | if (arg0.getActionCommand().equals("ModuleOrderPaneCancel")) {\r | |
103 | this.dispose();\r | |
104 | }\r | |
105 | }\r | |
106 | \r | |
107 | /**\r | |
108 | Start the window at the center of screen\r | |
109 | \r | |
110 | **/\r | |
111 | protected void centerWindow(int intWidth, int intHeight) {\r | |
112 | Dimension d = Toolkit.getDefaultToolkit().getScreenSize();\r | |
113 | this.setLocation((d.width - intWidth) / 2, (d.height - intHeight) / 2);\r | |
114 | }\r | |
115 | \r | |
116 | /**\r | |
117 | Start the window at the center of screen\r | |
118 | \r | |
119 | **/\r | |
120 | protected void centerWindow() {\r | |
121 | centerWindow(this.getSize().width, this.getSize().height);\r | |
122 | }\r | |
123 | \r | |
124 | /**\r | |
125 | * This method initializes jPanelN \r | |
126 | * \r | |
127 | * @return javax.swing.JPanel \r | |
128 | */\r | |
129 | private JPanel getJPanelN() {\r | |
130 | if (jPanelN == null) {\r | |
131 | jLabelFvName = new JLabel();\r | |
132 | jLabelFvName.setText("FV Name");\r | |
133 | jPanelN = new JPanel();\r | |
134 | jPanelN.add(jLabelFvName, null);\r | |
135 | jPanelN.add(getJComboBoxFvNames(), null);\r | |
136 | }\r | |
137 | return jPanelN;\r | |
138 | }\r | |
139 | \r | |
140 | /**\r | |
141 | * This method initializes jComboBoxFvNames \r | |
142 | * \r | |
143 | * @return javax.swing.JComboBox \r | |
144 | */\r | |
145 | private JComboBox getJComboBoxFvNames() {\r | |
146 | if (jComboBoxFvNames == null) {\r | |
147 | jComboBoxFvNames = new JComboBox();\r | |
148 | jComboBoxFvNames.setPreferredSize(new java.awt.Dimension(200,20));\r | |
149 | Vector<String> vFvNames = new Vector<String>();\r | |
150 | ffc.getFvImagesFvImageFvImageNames(vFvNames);\r | |
151 | for (int i = 0; i < vFvNames.size(); ++i) {\r | |
152 | jComboBoxFvNames.addItem(vFvNames.get(i));\r | |
153 | }\r | |
154 | // if (jComboBoxFvNames.getItemCount() > 0) {\r | |
155 | // jComboBoxFvNames.setSelectedIndex(0);\r | |
156 | // \r | |
157 | // }\r | |
158 | jComboBoxFvNames.addItemListener(new java.awt.event.ItemListener() {\r | |
159 | public void itemStateChanged(java.awt.event.ItemEvent e) {\r | |
160 | String fvName = jComboBoxFvNames.getSelectedItem()+"";\r | |
161 | if (fvName.length() > 0) {\r | |
162 | jTabbedPane.removeAll();\r | |
163 | AprioriModuleOrderPane peiPane = new AprioriModuleOrderPane(fvName, "", GenAprioriFileDialog.this, true);\r | |
164 | peiPane.showModulesInFv(fvName);\r | |
165 | peiPane.showAllModulesInPlatform();\r | |
166 | jTabbedPane.addTab("PEIMs", peiPane);\r | |
167 | AprioriModuleOrderPane dxePane = new AprioriModuleOrderPane(fvName, "", GenAprioriFileDialog.this, false);\r | |
168 | dxePane.showModulesInFv(fvName);\r | |
169 | dxePane.showAllModulesInPlatform();\r | |
170 | jTabbedPane.addTab("DXE Drivers", dxePane);\r | |
171 | }\r | |
172 | \r | |
173 | }\r | |
174 | });\r | |
175 | }\r | |
176 | return jComboBoxFvNames;\r | |
177 | }\r | |
178 | \r | |
179 | /**\r | |
180 | * This method initializes jTabbedPane \r | |
181 | * \r | |
182 | * @return javax.swing.JTabbedPane \r | |
183 | */\r | |
184 | private JTabbedPane getJTabbedPane() {\r | |
185 | if (jTabbedPane == null) {\r | |
186 | jTabbedPane = new JTabbedPane();\r | |
187 | }\r | |
188 | return jTabbedPane;\r | |
189 | }\r | |
190 | \r | |
191 | private class AprioriModuleOrderPane extends ModuleOrderPane {\r | |
192 | /**\r | |
193 | * \r | |
194 | */\r | |
195 | private static final long serialVersionUID = -7952853414833230546L;\r | |
196 | private boolean forPEI = false;\r | |
197 | private String fvName = null;\r | |
198 | \r | |
199 | AprioriModuleOrderPane (String fvName, String file, ActionListener action, boolean b) {\r | |
200 | \r | |
201 | super(fvName, file, ffc, action);\r | |
202 | this.fvName = fvName;\r | |
203 | forPEI = b;\r | |
204 | getJTableModInFv().getColumnModel().getColumn(0).setHeaderValue("Modules in Apriori File");\r | |
205 | getJButtonOk().setText("Save");\r | |
206 | getJButtonCancel().setText("Close");\r | |
207 | }\r | |
208 | \r | |
209 | public void showModulesInFv (String fvName) {\r | |
253fca1d | 210 | String id = "1";\r |
99125b46 | 211 | if (forPEI) {\r |
253fca1d | 212 | id = "0";\r |
99125b46 | 213 | }\r |
214 | int size = ffc.getUserExtsIncModCount(fvName, "APRIORI", id);\r | |
215 | \r | |
216 | if (size != -1) {\r | |
217 | String[][] saa = new String[size][5];\r | |
218 | ffc.getUserExtsIncMods(fvName, "APRIORI", id, saa);\r | |
219 | \r | |
220 | for (int i = 0; i < size; ++i) {\r | |
221 | String moduleKey = saa[i][0] + " " + saa[i][1] + " " + saa[i][2] + " " + saa[i][3];\r | |
222 | ModuleIdentification mi = WorkspaceProfile.getModuleId(moduleKey);\r | |
223 | String name = "N/A";\r | |
224 | if (mi != null) {\r | |
225 | name = mi.getName();\r | |
226 | }\r | |
227 | \r | |
228 | String[] row = { name, saa[i][0] , saa[i][1], saa[i][2] , saa[i][3], saa[i][4] };\r | |
229 | getModInFvTableModel().addRow(row);\r | |
230 | }\r | |
231 | }\r | |
232 | }\r | |
233 | \r | |
234 | public void actionPerformed(ActionEvent arg0) {\r | |
235 | if (arg0.getActionCommand().equals("ModuleOrderPaneOk")) {\r | |
253fca1d | 236 | String id = "1";\r |
99125b46 | 237 | if (forPEI) {\r |
253fca1d | 238 | id = "0";\r |
99125b46 | 239 | }\r |
240 | \r | |
241 | Vector<String[]> vModInFv = new Vector<String[]>();\r | |
242 | for (int i = 0; i < getJTableModInFv().getRowCount(); ++i) {\r | |
243 | String moduleName = getModInFvTableModel().getValueAt(i, 0)+"";\r | |
244 | if (moduleName.length() == 0 || moduleName.equals("N/A")) {\r | |
245 | continue;\r | |
246 | }\r | |
247 | \r | |
248 | String mg = getModInFvTableModel().getValueAt(i, 1)+"";\r | |
249 | String mv = getModInFvTableModel().getValueAt(i, 2)+"";\r | |
250 | String pg = getModInFvTableModel().getValueAt(i, 3)+"";\r | |
251 | String pv = getModInFvTableModel().getValueAt(i, 4)+"";\r | |
252 | String arch = getModInFvTableModel().getValueAt(i, 5)+"";\r | |
253 | \r | |
254 | String[] sa = { mg, mv, pg, pv, arch};\r | |
255 | vModInFv.add(sa);\r | |
256 | \r | |
257 | }\r | |
258 | \r | |
259 | ffc.removeBuildOptionsUserExtensions(fvName, "APRIORI", id);\r | |
253fca1d | 260 | ffc.genBuildOptionsUserExtensions(fvName, "APRIORI", id, "", vModInFv);\r |
99125b46 | 261 | \r |
262 | }\r | |
263 | }\r | |
264 | }\r | |
265 | } // @jve:decl-index=0:visual-constraint="10,10"\r |