]> git.proxmox.com Git - mirror_edk2.git/blame - Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/FpdFrameworkModules.java
fix EDKT189.
[mirror_edk2.git] / Tools / Source / FrameworkWizard / src / org / tianocore / frameworkwizard / platform / ui / FpdFrameworkModules.java
CommitLineData
a13899c5 1package org.tianocore.frameworkwizard.platform.ui;\r
2\r
3import java.awt.BorderLayout;\r
4\r
5import javax.swing.JFrame;\r
6import javax.swing.JOptionPane;\r
7import javax.swing.JPanel;\r
a13899c5 8import javax.swing.JSplitPane;\r
9import javax.swing.JLabel;\r
10import javax.swing.JScrollPane;\r
11import javax.swing.JTable;\r
12import javax.swing.JButton;\r
13import javax.swing.ListSelectionModel;\r
14import javax.swing.table.DefaultTableModel;\r
15\r
16import org.tianocore.PlatformSurfaceAreaDocument;\r
d6d24759 17import org.tianocore.frameworkwizard.common.Identifications.OpeningPlatformType;\r
a13899c5 18import org.tianocore.frameworkwizard.common.ui.IInternalFrame;\r
19import org.tianocore.frameworkwizard.platform.ui.global.GlobalData;\r
20import org.tianocore.frameworkwizard.platform.ui.id.ModuleIdentification;\r
21import org.tianocore.frameworkwizard.platform.ui.id.PackageIdentification;\r
22\r
23import java.awt.FlowLayout;\r
24import java.io.File;\r
25import java.util.ArrayList;\r
26import java.util.HashMap;\r
27import java.util.Iterator;\r
28import java.util.Map;\r
29import java.util.Set;\r
bf5abaff 30import java.util.Vector;\r
a13899c5 31\r
32public class FpdFrameworkModules extends IInternalFrame {\r
33\r
44053733 34 /**\r
df4b9c3e 35 * Initialize Globals\r
44053733 36 */\r
37 private static final long serialVersionUID = 1L;\r
a8a9de7c 38\r
a13899c5 39 static JFrame frame;\r
a8a9de7c 40\r
a13899c5 41 private JSplitPane jSplitPane = null;\r
a8a9de7c 42\r
4da2e625 43 private JPanel jPanelTop = null;\r
a8a9de7c 44\r
4da2e625 45 private JPanel jPanelBottom = null;\r
a8a9de7c 46\r
a13899c5 47 private JLabel jLabel = null;\r
a8a9de7c 48\r
4da2e625 49 private JScrollPane jScrollPaneAllModules = null;\r
a8a9de7c 50\r
4da2e625 51 private JTable jTableAllModules = null;\r
a8a9de7c 52\r
4da2e625 53 private JPanel jPanelTopSouth = null;\r
a8a9de7c 54\r
4da2e625 55 private JButton jButtonAddModule = null;\r
a8a9de7c 56\r
4da2e625 57 private JLabel jLabelModulesAdded = null;\r
a8a9de7c 58\r
4da2e625 59 private JPanel jPanelBottomSouth = null;\r
a8a9de7c 60\r
4da2e625 61 private JScrollPane jScrollPaneFpdModules = null;\r
a8a9de7c 62\r
4da2e625 63 private JTable jTableFpdModules = null;\r
a8a9de7c 64\r
4da2e625 65 private JButton jButtonSettings = null;\r
a8a9de7c 66\r
4da2e625 67 private JButton jButtonRemoveModule = null;\r
a8a9de7c 68\r
4da2e625 69 private NonEditableTableModel modelAllModules = null;\r
a8a9de7c 70\r
4da2e625 71 private NonEditableTableModel modelFpdModules = null;\r
a8a9de7c 72\r
a13899c5 73 private FpdModuleSA settingDlg = null;\r
a8a9de7c 74\r
a13899c5 75 private FpdFileContents ffc = null;\r
a8a9de7c 76\r
d6d24759 77 private OpeningPlatformType docConsole = null;\r
a8a9de7c 78\r
bf5abaff 79 private Map<String, ArrayList<String>> fpdMsa = null;\r
a8a9de7c 80\r
a13899c5 81 private ArrayList<ModuleIdentification> miList = null;\r
df4b9c3e 82 \r
83 /**\r
84 * Column settings for displaying all modules in workspace\r
85 */\r
d208e1e2 86 private final int modNameColForAllModTable = 0;\r
93fd07b1 87 \r
d208e1e2 88 private final int pkgNameColForAllModTable = 1;\r
93fd07b1 89 \r
d208e1e2 90 private final int pathColForAllModTable = 2;\r
93fd07b1 91 \r
df4b9c3e 92 private final int typeColForAllModTable = 3;\r
93 \r
94 private final int pkgVerColForAllModTable = 5;\r
93fd07b1 95 \r
d208e1e2 96 private final int modVerColForAllModTable = 4;\r
93fd07b1 97 \r
df4b9c3e 98 /**\r
99 * Column settings for display modules in the FPD file\r
100 */\r
d208e1e2 101 private final int modNameColForFpdModTable = 0;\r
93fd07b1 102 \r
d208e1e2 103 private final int pkgNameColForFpdModTable = 1;\r
93fd07b1 104 \r
d208e1e2 105 private final int pathColForFpdModTable = 2;\r
93fd07b1 106 \r
d208e1e2 107 private final int archColForFpdModTable = 3;\r
93fd07b1 108 \r
4cd31580 109 private final int pkgVerColForFpdModTable = 6;\r
a8a9de7c 110\r
4cd31580 111 private final int modVerColForFpdModTable = 5;\r
112 \r
113 private final int typeColForFpdModTable = 4;\r
d208e1e2 114 \r
df4b9c3e 115 /**\r
116 * FpdFileContents structure\r
117 */\r
d208e1e2 118 private final int ffcModGuid = 0;\r
119 \r
120 private final int ffcModVer = 1;\r
121 \r
122 private final int ffcPkgGuid = 2;\r
123 \r
124 private final int ffcPkgVer = 3;\r
125 \r
126 private final int ffcModArch = 4;\r
df4b9c3e 127 \r
128 /**\r
129 * Set Column Widths, Only the PATH should not have a max width.\r
130 */\r
d208e1e2 131 private final int modNameMinWidth = 168;\r
a8a9de7c 132 \r
d208e1e2 133 private final int modNamePrefWidth = 200;\r
df4b9c3e 134 \r
135 private final int modNameMaxWidth = 350;\r
a8a9de7c 136\r
d208e1e2 137 private final int pkgNameMinWidth = 100;\r
a8a9de7c 138 \r
df4b9c3e 139 private final int pkgNamePrefWidth = 130;\r
a8a9de7c 140 \r
d208e1e2 141 private final int pkgNameMaxWidth = 150;\r
a8a9de7c 142 \r
df4b9c3e 143 private final int verMinWidth = 60;\r
a8a9de7c 144 \r
d208e1e2 145 private final int verMaxWidth = 80;\r
a8a9de7c 146 \r
df4b9c3e 147 private final int verPrefWidth = 70;\r
a8a9de7c 148 \r
d208e1e2 149 private final int pathPrefWidth = 320;\r
a8a9de7c 150 \r
d208e1e2 151 private final int pathMinWidth = 280;\r
a8a9de7c 152 \r
d208e1e2 153 private final int archPrefWidth = 80;\r
a8a9de7c 154 \r
d208e1e2 155 private final int archMinWidth = 60;\r
a8a9de7c 156 \r
d208e1e2 157 private final int archMaxWidth = 100;\r
a8a9de7c 158 \r
df4b9c3e 159 private final int typePrefWidth = 145;\r
160 \r
161 private final int typeMinWidth = 100;\r
162 \r
163 private final int typeMaxWidth = 155;\r
164 \r
a13899c5 165 /**\r
df4b9c3e 166 * This method initializes jSplitPane\r
167 * \r
168 * This is the main edit window\r
a13899c5 169 * \r
df4b9c3e 170 * @return javax.swing.JSplitPane jSplitPane \r
a13899c5 171 */\r
172 private JSplitPane getJSplitPane() {\r
173 if (jSplitPane == null) {\r
174 jSplitPane = new JSplitPane();\r
175 jSplitPane.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT);\r
176 jSplitPane.setDividerLocation(250);\r
4da2e625 177 jSplitPane.setBottomComponent(getJPanelBottom());\r
178 jSplitPane.setTopComponent(getJPanelTop());\r
a13899c5 179 }\r
180 return jSplitPane;\r
181 }\r
182\r
183 /**\r
df4b9c3e 184 * This method initializes jPanelTop\r
185 * \r
186 * This panel contains the All Modules Table \r
a13899c5 187 * \r
df4b9c3e 188 * @return javax.swing.JPanel jPanelTop\r
a13899c5 189 */\r
4da2e625 190 private JPanel getJPanelTop() {\r
191 if (jPanelTop == null) {\r
a13899c5 192 jLabel = new JLabel();\r
193 jLabel.setText("Modules in Workspace");\r
4da2e625 194 jPanelTop = new JPanel();\r
195 jPanelTop.setLayout(new BorderLayout());\r
196 jPanelTop.add(jLabel, java.awt.BorderLayout.NORTH);\r
197 jPanelTop.add(getJScrollPaneAllModules(), java.awt.BorderLayout.CENTER);\r
198 jPanelTop.add(getJPanelTopSouth(), java.awt.BorderLayout.SOUTH);\r
a13899c5 199 }\r
4da2e625 200 return jPanelTop;\r
a13899c5 201 }\r
202\r
203 /**\r
df4b9c3e 204 * This method initializes jPanelBottom\r
a13899c5 205 * \r
df4b9c3e 206 * This panel contains the FPD Modules Table\r
207 * \r
208 * @return javax.swing.JPanel jPanelBottom\r
a13899c5 209 */\r
4da2e625 210 private JPanel getJPanelBottom() {\r
211 if (jPanelBottom == null) {\r
212 jLabelModulesAdded = new JLabel();\r
213 jLabelModulesAdded.setText("Modules Added");\r
214 jPanelBottom = new JPanel();\r
215 jPanelBottom.setLayout(new BorderLayout());\r
216 jPanelBottom.add(jLabelModulesAdded, java.awt.BorderLayout.NORTH);\r
217 jPanelBottom.add(getJPanelBottomSouth(), java.awt.BorderLayout.SOUTH);\r
218 jPanelBottom.add(getJScrollPaneFpdModules(), java.awt.BorderLayout.CENTER);\r
a13899c5 219 }\r
4da2e625 220 return jPanelBottom;\r
a13899c5 221 }\r
222\r
223 /**\r
df4b9c3e 224 * This method initializes jScrollPaneAllModules \r
a13899c5 225 * \r
df4b9c3e 226 * @return javax.swing.JScrollPane jScrollPaneAllModules\r
a13899c5 227 */\r
4da2e625 228 private JScrollPane getJScrollPaneAllModules() {\r
229 if (jScrollPaneAllModules == null) {\r
230 jScrollPaneAllModules = new JScrollPane();\r
a8a9de7c 231 jScrollPaneAllModules.setPreferredSize(new java.awt.Dimension(600, 200));\r
4da2e625 232 jScrollPaneAllModules.setViewportView(getJTableAllModules());\r
a13899c5 233 }\r
4da2e625 234 return jScrollPaneAllModules;\r
a13899c5 235 }\r
236\r
237 /**\r
df4b9c3e 238 * This method initializes jTableAllModules\r
a13899c5 239 * \r
df4b9c3e 240 * @return javax.swing.JTable jTableAllModules\r
a13899c5 241 */\r
4da2e625 242 private JTable getJTableAllModules() {\r
243 if (jTableAllModules == null) {\r
244 modelAllModules = new NonEditableTableModel();\r
add40ab2 245 TableSorter sorter = new TableSorter(modelAllModules);\r
246 jTableAllModules = new JTable(sorter);\r
247 sorter.setTableHeader(jTableAllModules.getTableHeader());\r
4da2e625 248 jTableAllModules.setRowHeight(20);\r
a8a9de7c 249 modelAllModules.addColumn("<html>Module<br>Name</html>");\r
a8a9de7c 250 modelAllModules.addColumn("<html>Package<br>Name</html>");\r
4da2e625 251 modelAllModules.addColumn("Path");\r
df4b9c3e 252 modelAllModules.addColumn("<html>Module<br>Type</html>");\r
93fd07b1 253 modelAllModules.addColumn("<html>Module<br>Version</html>");\r
df4b9c3e 254 modelAllModules.addColumn("<html>Package<br>Version</html>");\r
93fd07b1 255 \r
a8a9de7c 256 javax.swing.table.TableColumn column = null;\r
d208e1e2 257 column = jTableAllModules.getColumnModel().getColumn(modNameColForAllModTable);\r
258 column.setPreferredWidth(modNamePrefWidth);\r
259 column.setMinWidth(modNameMinWidth);\r
df4b9c3e 260 column.setMaxWidth(modNameMaxWidth);\r
d208e1e2 261 column = jTableAllModules.getColumnModel().getColumn(modVerColForAllModTable);\r
262 column.setPreferredWidth(verPrefWidth);\r
263 column.setMaxWidth(verMaxWidth);\r
264 column.setMinWidth(verMinWidth);\r
265 column = jTableAllModules.getColumnModel().getColumn(pkgNameColForAllModTable);\r
266 column.setPreferredWidth(pkgNamePrefWidth);\r
267 column.setMinWidth(pkgNameMinWidth);\r
268 column.setMaxWidth(pkgNameMaxWidth);\r
269 column = jTableAllModules.getColumnModel().getColumn(pkgVerColForAllModTable);\r
270 column.setPreferredWidth(verPrefWidth);\r
271 column.setMaxWidth(verMaxWidth);\r
272 column.setMinWidth(verMinWidth);\r
df4b9c3e 273 column = jTableAllModules.getColumnModel().getColumn(typeColForAllModTable);\r
274 column.setPreferredWidth(typePrefWidth);\r
275 column.setMaxWidth(typeMaxWidth);\r
276 column.setMinWidth(typeMinWidth);\r
d208e1e2 277 column = jTableAllModules.getColumnModel().getColumn(pathColForAllModTable);\r
278 column.setPreferredWidth(pathPrefWidth);\r
279 column.setMinWidth(pathMinWidth);\r
a8a9de7c 280\r
4da2e625 281 jTableAllModules.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);\r
4cd31580 282\r
a13899c5 283 }\r
4da2e625 284 return jTableAllModules;\r
a13899c5 285 }\r
286\r
287 /**\r
df4b9c3e 288 * This method initializes jPanelTopSouth\r
289 * \r
290 * This panel contains the ADD button\r
291 * \r
292 * @return javax.swing.JPanel jPanelTopSouth\r
a13899c5 293 */\r
4da2e625 294 private JPanel getJPanelTopSouth() {\r
295 if (jPanelTopSouth == null) {\r
a13899c5 296 FlowLayout flowLayout = new FlowLayout();\r
297 flowLayout.setAlignment(java.awt.FlowLayout.RIGHT);\r
4da2e625 298 jPanelTopSouth = new JPanel();\r
299 jPanelTopSouth.setLayout(flowLayout);\r
300 jPanelTopSouth.add(getJButtonAddModule(), null);\r
a13899c5 301 }\r
4da2e625 302 return jPanelTopSouth;\r
a13899c5 303 }\r
304\r
305 /**\r
df4b9c3e 306 * This method initializes jButtonAddModule \r
a13899c5 307 * \r
df4b9c3e 308 * @return javax.swing.JButton jButtonAddModule\r
a13899c5 309 */\r
4da2e625 310 private JButton getJButtonAddModule() {\r
311 if (jButtonAddModule == null) {\r
312 jButtonAddModule = new JButton();\r
a8a9de7c 313 jButtonAddModule.setPreferredSize(new java.awt.Dimension(130, 20));\r
4da2e625 314 jButtonAddModule.setText("Add a Module");\r
315 jButtonAddModule.addActionListener(new java.awt.event.ActionListener() {\r
a13899c5 316 public void actionPerformed(java.awt.event.ActionEvent e) {\r
4da2e625 317 int selectedRow = jTableAllModules.getSelectedRow();\r
a8a9de7c 318 if (selectedRow < 0) {\r
a13899c5 319 return;\r
320 }\r
a8a9de7c 321\r
322 TableSorter sorter = (TableSorter) jTableAllModules.getModel();\r
add40ab2 323 selectedRow = sorter.modelIndex(selectedRow);\r
d208e1e2 324 String path = modelAllModules.getValueAt(selectedRow, pathColForAllModTable) + "";\r
bf5abaff 325 ModuleIdentification mi = miList.get(selectedRow);\r
326 Vector<String> vArchs = null;\r
327 try {\r
328 vArchs = GlobalData.getModuleSupArchs(mi);\r
329 }\r
330 catch (Exception exp) {\r
331 JOptionPane.showMessageDialog(frame, exp.getMessage());\r
a13899c5 332 }\r
a8a9de7c 333\r
bf5abaff 334 if (vArchs == null) {\r
a8a9de7c 335 JOptionPane.showMessageDialog(frame, "No Supported Architectures specified in MSA file.");\r
bf5abaff 336 return;\r
a13899c5 337 }\r
a8a9de7c 338\r
bf5abaff 339 String archsAdded = "";\r
340 String mg = mi.getGuid();\r
341 String mv = mi.getVersion();\r
342 String pg = mi.getPackage().getGuid();\r
343 String pv = mi.getPackage().getVersion();\r
4cd31580 344 String mType = mi.getModuleType();\r
a8a9de7c 345\r
bf5abaff 346 ArrayList<String> al = fpdMsa.get(mg + mv + pg + pv);\r
347 if (al == null) {\r
d96d701f 348 //\r
349 // if existing ModuleSA does not specify version info.\r
350 //\r
351 al = fpdMsa.get(mg + "null" + pg + "null");\r
352 if (al == null) {\r
353 al = fpdMsa.get(mg + "null" + pg + pv);\r
354 if (al == null){\r
355 al = fpdMsa.get(mg + mv + pg + "null");\r
356 if (al == null) {\r
357 al = new ArrayList<String>();\r
358 fpdMsa.put(mg + mv + pg + pv, al); \r
359 }\r
360 }\r
361 }\r
bf5abaff 362 }\r
d96d701f 363 //\r
364 // filter from module SupArchs what archs has been added.\r
365 //\r
bf5abaff 366 for (int i = 0; i < al.size(); ++i) {\r
367 vArchs.remove(al.get(i));\r
368 }\r
369 //\r
d96d701f 370 // check whether archs conform to SupArch of platform.\r
371 //\r
372 Vector<Object> platformSupArch = new Vector<Object>();\r
373 ffc.getPlatformDefsSupportedArchs(platformSupArch);\r
374 vArchs.retainAll(platformSupArch);\r
375 //\r
bf5abaff 376 // Archs this Module supported have already been added.\r
377 //\r
378 if (vArchs.size() == 0) {\r
a8a9de7c 379 JOptionPane.showMessageDialog(frame, "This Module has already been added.");\r
bf5abaff 380 return;\r
af25df16 381 }\r
bf5abaff 382 //ToDo put Arch instead of null\r
34c614e1 383 boolean errorOccurred = false;\r
bf5abaff 384 for (int i = 0; i < vArchs.size(); ++i) {\r
385 String arch = vArchs.get(i);\r
386 al.add(arch);\r
387 archsAdded += arch + " ";\r
4cd31580 388 String[] row = { "", "", "", "", "", "", "" };\r
a8a9de7c 389\r
390 if (mi != null) {\r
d208e1e2 391 row[modNameColForFpdModTable] = mi.getName();\r
392 row[pkgNameColForFpdModTable] = mi.getPackage().getName();\r
393 row[pathColForFpdModTable] = path;\r
394 row[archColForFpdModTable] = arch;\r
395 row[pkgVerColForFpdModTable] = pv;\r
396 row[modVerColForFpdModTable] = mv;\r
4cd31580 397 row[typeColForFpdModTable] = mType;\r
a8a9de7c 398\r
399 }\r
400 modelFpdModules.addRow(row);\r
401\r
402 docConsole.setSaved(false);\r
403 try {\r
404 //ToDo : specify archs need to add.\r
405 ffc.addFrameworkModulesPcdBuildDefs(mi, arch, null);\r
406 } catch (Exception exception) {\r
4cd31580 407 JOptionPane.showMessageDialog(frame, "Adding " + row[modNameColForFpdModTable] + " with Supporting Architectures: " + arch\r
a8a9de7c 408 + ": " + exception.getMessage());\r
409 errorOccurred = true;\r
410 }\r
82961247 411 }\r
a8a9de7c 412\r
413 String s = "This Module with Architecture " + archsAdded;\r
34c614e1 414 if (errorOccurred) {\r
a8a9de7c 415 s += " was added with Error. Platform may NOT Build.";\r
416 } else {\r
417 s += " was added Successfully.";\r
34c614e1 418 }\r
a8a9de7c 419 JOptionPane.showMessageDialog(frame, s);\r
420 jTableFpdModules.changeSelection(modelFpdModules.getRowCount() - 1, 0, false, false);\r
82961247 421 }\r
a13899c5 422 });\r
423 }\r
4da2e625 424 return jButtonAddModule;\r
a13899c5 425 }\r
426\r
427 /**\r
df4b9c3e 428 * This method initializes jPanelBottomSouth\r
429 * \r
430 * This panel contains the Settings and Remove Buttons\r
a13899c5 431 * \r
df4b9c3e 432 * @return javax.swing.JPanel jPanelBottomSouth\r
a13899c5 433 */\r
4da2e625 434 private JPanel getJPanelBottomSouth() {\r
435 if (jPanelBottomSouth == null) {\r
a13899c5 436 FlowLayout flowLayout1 = new FlowLayout();\r
437 flowLayout1.setAlignment(java.awt.FlowLayout.RIGHT);\r
4da2e625 438 jPanelBottomSouth = new JPanel();\r
439 jPanelBottomSouth.setLayout(flowLayout1);\r
440 jPanelBottomSouth.add(getJButtonSettings(), null);\r
441 jPanelBottomSouth.add(getJButtonRemoveModule(), null);\r
a13899c5 442 }\r
4da2e625 443 return jPanelBottomSouth;\r
a13899c5 444 }\r
445\r
446 /**\r
df4b9c3e 447 * This method initializes jScrollPaneFpdModules\r
a13899c5 448 * \r
df4b9c3e 449 * @return javax.swing.JScrollPane jScrollPaneFpdModules\r
a13899c5 450 */\r
4da2e625 451 private JScrollPane getJScrollPaneFpdModules() {\r
452 if (jScrollPaneFpdModules == null) {\r
453 jScrollPaneFpdModules = new JScrollPane();\r
a8a9de7c 454 jScrollPaneFpdModules.setPreferredSize(new java.awt.Dimension(453, 200));\r
4da2e625 455 jScrollPaneFpdModules.setViewportView(getJTableFpdModules());\r
a13899c5 456 }\r
4da2e625 457 return jScrollPaneFpdModules;\r
a13899c5 458 }\r
459\r
460 /**\r
df4b9c3e 461 * This method initializes jTableFpdModules\r
a13899c5 462 * \r
df4b9c3e 463 * @return javax.swing.JTable jTableFpdModules\r
a13899c5 464 */\r
4da2e625 465 private JTable getJTableFpdModules() {\r
466 if (jTableFpdModules == null) {\r
467 modelFpdModules = new NonEditableTableModel();\r
add40ab2 468 TableSorter sorter = new TableSorter(modelFpdModules);\r
469 jTableFpdModules = new JTable(sorter);\r
470 sorter.setTableHeader(jTableFpdModules.getTableHeader());\r
4da2e625 471 jTableFpdModules.setRowHeight(20);\r
a8a9de7c 472 modelFpdModules.addColumn("<html>Module<br>Name</html>");\r
a8a9de7c 473 modelFpdModules.addColumn("<html>Package<br>Name</html>");\r
4da2e625 474 modelFpdModules.addColumn("Path");\r
93fd07b1 475 modelFpdModules.addColumn("<html>Supported<br>Architectures</html>");\r
4cd31580 476 modelFpdModules.addColumn("<html>Module<br>Type</html>");\r
93fd07b1 477 modelFpdModules.addColumn("<html>Module<br>Version</html>");\r
df4b9c3e 478 modelFpdModules.addColumn("<html>Package<br>Version</html>");\r
4cd31580 479\r
93fd07b1 480 \r
a8a9de7c 481 javax.swing.table.TableColumn column = null;\r
d208e1e2 482 column = jTableFpdModules.getColumnModel().getColumn(modNameColForFpdModTable);\r
483 column.setPreferredWidth(modNamePrefWidth);\r
484 column.setMinWidth(modNameMinWidth);\r
df4b9c3e 485 column.setMaxWidth(modNameMaxWidth);\r
d208e1e2 486 column = jTableFpdModules.getColumnModel().getColumn(modVerColForFpdModTable);\r
487 column.setPreferredWidth(verPrefWidth);\r
488 column.setMaxWidth(verMaxWidth);\r
489 column.setMinWidth(verMinWidth);\r
490 column = jTableFpdModules.getColumnModel().getColumn(pkgNameColForFpdModTable);\r
491 column.setPreferredWidth(pkgNamePrefWidth);\r
492 column.setMinWidth(pkgNameMinWidth);\r
493 column.setMaxWidth(pkgNameMaxWidth);\r
494 column = jTableFpdModules.getColumnModel().getColumn(pkgVerColForFpdModTable);\r
495 column.setPreferredWidth(verPrefWidth);\r
496 column.setMaxWidth(verMaxWidth);\r
497 column.setMinWidth(verMinWidth);\r
498 column = jTableFpdModules.getColumnModel().getColumn(archColForFpdModTable);\r
499 column.setPreferredWidth(archPrefWidth);\r
500 column.setMaxWidth(archMaxWidth);\r
501 column.setMinWidth(archMinWidth);\r
502 column = jTableFpdModules.getColumnModel().getColumn(pathColForFpdModTable);\r
503 column.setPreferredWidth(pathPrefWidth);\r
504 column.setMinWidth(pathMinWidth);\r
4cd31580 505 column = jTableFpdModules.getColumnModel().getColumn(typeColForFpdModTable);\r
506 column.setPreferredWidth(typePrefWidth);\r
507 column.setMaxWidth(typeMaxWidth);\r
508 column.setMinWidth(typeMinWidth);\r
a8a9de7c 509\r
4da2e625 510 jTableFpdModules.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);\r
4cd31580 511\r
a13899c5 512 }\r
4da2e625 513 return jTableFpdModules;\r
a13899c5 514 }\r
515\r
516 /**\r
df4b9c3e 517 * This method initializes jButtonSettings\r
a13899c5 518 * \r
df4b9c3e 519 * @return javax.swing.JButton jButtonSettings\r
a13899c5 520 */\r
4da2e625 521 private JButton getJButtonSettings() {\r
522 if (jButtonSettings == null) {\r
523 jButtonSettings = new JButton();\r
524 jButtonSettings.setPreferredSize(new java.awt.Dimension(130,20));\r
525 jButtonSettings.setText("Settings");\r
526 jButtonSettings.addActionListener(new java.awt.event.ActionListener() {\r
a13899c5 527 public void actionPerformed(java.awt.event.ActionEvent e) {\r
4da2e625 528 int selectedRow = jTableFpdModules.getSelectedRow();\r
a8a9de7c 529 if (selectedRow < 0) {\r
a13899c5 530 return;\r
531 }\r
a8a9de7c 532\r
533 TableSorter sorter = (TableSorter) jTableFpdModules.getModel();\r
add40ab2 534 selectedRow = sorter.modelIndex(selectedRow);\r
1dac04ab 535 try {\r
536 if (ffc.adjustPcd(selectedRow)) {\r
537 docConsole.setSaved(false);\r
538 }\r
539 }\r
540 catch (Exception exp) {\r
541 JOptionPane.showMessageDialog(frame, exp.getMessage());\r
542 return;\r
543 }\r
add40ab2 544 \r
a13899c5 545 if (settingDlg == null) {\r
546 settingDlg = new FpdModuleSA(ffc);\r
547 }\r
a8a9de7c 548\r
bf5abaff 549 String[] sa = new String[5];\r
550 ffc.getFrameworkModuleInfo(selectedRow, sa);\r
d208e1e2 551 String mg = sa[ffcModGuid];\r
552 String mv = sa[ffcModVer];\r
553 String pg = sa[ffcPkgGuid];\r
554 String pv = sa[ffcPkgVer];\r
555 String arch = sa[ffcModArch];\r
8f55ea73 556 settingDlg.setKey(mg + " " + mv + " " + pg + " " + pv + " " + arch, selectedRow, docConsole);\r
a13899c5 557 settingDlg.setVisible(true);\r
558 }\r
559 });\r
560 }\r
4da2e625 561 return jButtonSettings;\r
a13899c5 562 }\r
563\r
564 /**\r
df4b9c3e 565 * This method initializes jButtonRemoveModule\r
a13899c5 566 * \r
df4b9c3e 567 * @return javax.swing.JButton jButtonRemoveModule\r
a13899c5 568 */\r
4da2e625 569 private JButton getJButtonRemoveModule() {\r
570 if (jButtonRemoveModule == null) {\r
571 jButtonRemoveModule = new JButton();\r
a8a9de7c 572 jButtonRemoveModule.setPreferredSize(new java.awt.Dimension(130, 20));\r
4da2e625 573 jButtonRemoveModule.setText("Remove Module");\r
574 jButtonRemoveModule.addActionListener(new java.awt.event.ActionListener() {\r
a13899c5 575 public void actionPerformed(java.awt.event.ActionEvent e) {\r
4da2e625 576 int selectedRow = jTableFpdModules.getSelectedRow();\r
a8a9de7c 577 if (selectedRow < 0) {\r
a13899c5 578 return;\r
579 }\r
a8a9de7c 580\r
581 TableSorter sorter = (TableSorter) jTableFpdModules.getModel();\r
add40ab2 582 selectedRow = sorter.modelIndex(selectedRow);\r
a8a9de7c 583\r
bf5abaff 584 String[] sa = new String[5];\r
585 ffc.getFrameworkModuleInfo(selectedRow, sa);\r
d208e1e2 586 String mg = sa[ffcModGuid];\r
587 String mv = sa[ffcModVer];\r
588 String pg = sa[ffcPkgGuid];\r
589 String pv = sa[ffcPkgVer];\r
590 String arch = sa[ffcModArch];\r
591 ModuleIdentification mi = GlobalData.getModuleId(mg + " " + mv + " " + pg + " " + pv + " " + arch);\r
bf5abaff 592 mv = mi.getVersion();\r
593 pv = mi.getPackage().getVersion();\r
4da2e625 594 modelFpdModules.removeRow(selectedRow);\r
bf5abaff 595 if (arch == null) {\r
596 // if no arch specified in ModuleSA\r
a8a9de7c 597 fpdMsa.remove(mg + mv + pg + pv);\r
d96d701f 598 \r
a8a9de7c 599 } else {\r
600 ArrayList<String> al = fpdMsa.get(mg + mv + pg + pv);\r
bf5abaff 601 al.remove(arch);\r
602 if (al.size() == 0) {\r
a8a9de7c 603 fpdMsa.remove(mg + mv + pg + pv);\r
bf5abaff 604 }\r
605 }\r
a8a9de7c 606\r
d6d24759 607 docConsole.setSaved(false);\r
a13899c5 608 ffc.removeModuleSA(selectedRow);\r
609 }\r
610 });\r
611 }\r
4da2e625 612 return jButtonRemoveModule;\r
a13899c5 613 }\r
614\r
615 /**\r
df4b9c3e 616 * \r
a13899c5 617 * @param args\r
618 */\r
619 public static void main(String[] args) {\r
4cd31580 620 // Set the pane visable\r
a13899c5 621 new FpdFrameworkModules().setVisible(true);\r
622 }\r
623\r
624 /**\r
625 * This is the default constructor\r
626 */\r
627 public FpdFrameworkModules() {\r
628 super();\r
629 initialize();\r
630 }\r
631\r
a8a9de7c 632 public FpdFrameworkModules(PlatformSurfaceAreaDocument.PlatformSurfaceArea fpd) {\r
a13899c5 633 this();\r
634 init(fpd);\r
a8a9de7c 635\r
a13899c5 636 }\r
a8a9de7c 637\r
d6d24759 638 public FpdFrameworkModules(OpeningPlatformType opt) {\r
639 this(opt.getXmlFpd());\r
640 docConsole = opt;\r
641 }\r
a8a9de7c 642\r
a13899c5 643 private void init(PlatformSurfaceAreaDocument.PlatformSurfaceArea fpd) {\r
644 try {\r
645 GlobalData.initInfo("Tools" + File.separator + "Conf" + File.separator + "FrameworkDatabase.db", System.getenv("WORKSPACE"));\r
646 }\r
647 catch(Exception e){\r
410e0e9f 648 JOptionPane.showMessageDialog(frame, "Error occurred when getting module data.");\r
a13899c5 649 }\r
a8a9de7c 650\r
651 if (ffc == null) {\r
a13899c5 652 ffc = new FpdFileContents(fpd);\r
653 ffc.initDynPcdMap();\r
654 }\r
a8a9de7c 655\r
a13899c5 656 if (fpdMsa == null) {\r
bf5abaff 657 fpdMsa = new HashMap<String, ArrayList<String>>();\r
a13899c5 658 }\r
a8a9de7c 659\r
a13899c5 660 if (ffc.getFrameworkModulesCount() > 0) {\r
661 String[][] saa = new String[ffc.getFrameworkModulesCount()][5];\r
662 ffc.getFrameworkModulesInfo(saa);\r
663 for (int i = 0; i < saa.length; ++i) {\r
d208e1e2 664 ModuleIdentification mi = GlobalData.getModuleId(saa[i][ffcModGuid] + " " + saa[i][ffcModVer] + " "\r
665 + saa[i][ffcPkgGuid] + " " + saa[i][ffcPkgVer]);\r
4cd31580 666 String[] row = { "", "", "", "", "", "", "" };\r
f3b0ed9a 667 if (mi != null) {\r
d208e1e2 668 row[modNameColForFpdModTable] = mi.getName();\r
669 row[modVerColForFpdModTable] = mi.getVersion();\r
4cd31580 670 row[typeColForFpdModTable] = mi.getModuleType();\r
d208e1e2 671 row[pkgNameColForFpdModTable] = mi.getPackage().getName();\r
672 row[pkgVerColForFpdModTable] = mi.getPackage().getVersion();\r
d96d701f 673 row[archColForFpdModTable] = saa[i][ffcModArch];\r
a8a9de7c 674 try {\r
d208e1e2 675 row[pathColForFpdModTable] = GlobalData.getMsaFile(mi).getPath().substring(\r
a8a9de7c 676 System.getenv("WORKSPACE")\r
677 .length() + 1);\r
678 } catch (Exception e) {\r
679 JOptionPane.showMessageDialog(frame, "Show FPD Modules:" + e.getMessage());\r
bf5abaff 680 }\r
d96d701f 681 \r
682 modelFpdModules.addRow(row);\r
683 String fpdMsaKey = saa[i][ffcModGuid] + row[modVerColForFpdModTable]\r
684 + saa[i][ffcPkgGuid] + row[pkgVerColForFpdModTable];\r
685 ArrayList<String> al = fpdMsa.get(fpdMsaKey);\r
686 if (al == null) {\r
687 al = new ArrayList<String>();\r
688 fpdMsa.put(fpdMsaKey, al);\r
689 }\r
690 al.add(saa[i][ffcModArch]);\r
bf5abaff 691 }\r
d96d701f 692 \r
a8a9de7c 693\r
a13899c5 694 }\r
f4c4325b 695 TableSorter sorter = (TableSorter)jTableFpdModules.getModel();\r
696 sorter.setSortingStatus(modNameColForFpdModTable, TableSorter.ASCENDING);\r
a13899c5 697 }\r
a8a9de7c 698\r
a13899c5 699 showAllModules();\r
a8a9de7c 700\r
a13899c5 701 }\r
a8a9de7c 702\r
a13899c5 703 private void showAllModules() {\r
a8a9de7c 704\r
a13899c5 705 if (miList == null) {\r
706 miList = new ArrayList<ModuleIdentification>();\r
707 }\r
708 Set<PackageIdentification> spi = GlobalData.getPackageList();\r
709 Iterator ispi = spi.iterator();\r
a8a9de7c 710\r
711 while (ispi.hasNext()) {\r
712 PackageIdentification pi = (PackageIdentification) ispi.next();\r
df4b9c3e 713 String[] s = { "", "", "", "", "", "" };\r
a8a9de7c 714\r
a13899c5 715 Set<ModuleIdentification> smi = GlobalData.getModules(pi);\r
716 Iterator ismi = smi.iterator();\r
a8a9de7c 717 while (ismi.hasNext()) {\r
718 ModuleIdentification mi = (ModuleIdentification) ismi.next();\r
d208e1e2 719 s[modNameColForAllModTable] = mi.getName();\r
720 s[modVerColForAllModTable] = mi.getVersion();\r
df4b9c3e 721 s[typeColForAllModTable] = mi.getModuleType();\r
d208e1e2 722 s[pkgNameColForAllModTable] = pi.getName();\r
723 s[pkgVerColForAllModTable] = pi.getVersion();\r
bf5abaff 724 try {\r
d208e1e2 725 s[pathColForAllModTable] = GlobalData.getMsaFile(mi).getPath()\r
a8a9de7c 726 .substring(System.getenv("WORKSPACE").length() + 1);\r
727 } catch (Exception e) {\r
728 JOptionPane.showMessageDialog(frame, "Show All Modules:" + e.getMessage());\r
bf5abaff 729 }\r
4da2e625 730 modelAllModules.addRow(s);\r
a13899c5 731 miList.add(mi);\r
732 }\r
733 }\r
f4c4325b 734 \r
735 TableSorter sorter = (TableSorter)jTableAllModules.getModel();\r
736 sorter.setSortingStatus(modNameColForAllModTable, TableSorter.ASCENDING);\r
a13899c5 737 }\r
a8a9de7c 738\r
a13899c5 739 /**\r
740 * This method initializes this\r
741 * \r
742 * @return void\r
743 */\r
744 private void initialize() {\r
745 this.setSize(633, 533);\r
746 this.setTitle("Framework Modules");\r
747 this.setContentPane(getJSplitPane());\r
748 this.setVisible(true);\r
a8a9de7c 749\r
a13899c5 750 }\r
a13899c5 751\r
a8a9de7c 752} // @jve:decl-index=0:visual-constraint="10,10"\r
a13899c5 753\r
754class NonEditableTableModel extends DefaultTableModel {\r
44053733 755 /**\r
756 * \r
757 */\r
758 private static final long serialVersionUID = 1L;\r
759\r
a13899c5 760 public boolean isCellEditable(int row, int col) {\r
761 return false;\r
762 }\r
763}\r