Added module type column to the FPD module table, and also removed AUTO_RESIZE_OFF...
[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
348 al = new ArrayList<String>();\r
349 fpdMsa.put(mg + mv + pg + pv, al);\r
350 }\r
351 for (int i = 0; i < al.size(); ++i) {\r
352 vArchs.remove(al.get(i));\r
353 }\r
354 //\r
355 // Archs this Module supported have already been added.\r
356 //\r
357 if (vArchs.size() == 0) {\r
a8a9de7c 358 JOptionPane.showMessageDialog(frame, "This Module has already been added.");\r
bf5abaff 359 return;\r
af25df16 360 }\r
bf5abaff 361 //ToDo put Arch instead of null\r
34c614e1 362 boolean errorOccurred = false;\r
bf5abaff 363 for (int i = 0; i < vArchs.size(); ++i) {\r
364 String arch = vArchs.get(i);\r
365 al.add(arch);\r
366 archsAdded += arch + " ";\r
4cd31580 367 String[] row = { "", "", "", "", "", "", "" };\r
a8a9de7c 368\r
369 if (mi != null) {\r
d208e1e2 370 row[modNameColForFpdModTable] = mi.getName();\r
371 row[pkgNameColForFpdModTable] = mi.getPackage().getName();\r
372 row[pathColForFpdModTable] = path;\r
373 row[archColForFpdModTable] = arch;\r
374 row[pkgVerColForFpdModTable] = pv;\r
375 row[modVerColForFpdModTable] = mv;\r
4cd31580 376 row[typeColForFpdModTable] = mType;\r
a8a9de7c 377\r
378 }\r
379 modelFpdModules.addRow(row);\r
380\r
381 docConsole.setSaved(false);\r
382 try {\r
383 //ToDo : specify archs need to add.\r
384 ffc.addFrameworkModulesPcdBuildDefs(mi, arch, null);\r
385 } catch (Exception exception) {\r
4cd31580 386 JOptionPane.showMessageDialog(frame, "Adding " + row[modNameColForFpdModTable] + " with Supporting Architectures: " + arch\r
a8a9de7c 387 + ": " + exception.getMessage());\r
388 errorOccurred = true;\r
389 }\r
82961247 390 }\r
a8a9de7c 391\r
392 String s = "This Module with Architecture " + archsAdded;\r
34c614e1 393 if (errorOccurred) {\r
a8a9de7c 394 s += " was added with Error. Platform may NOT Build.";\r
395 } else {\r
396 s += " was added Successfully.";\r
34c614e1 397 }\r
a8a9de7c 398 JOptionPane.showMessageDialog(frame, s);\r
399 jTableFpdModules.changeSelection(modelFpdModules.getRowCount() - 1, 0, false, false);\r
82961247 400 }\r
a13899c5 401 });\r
402 }\r
4da2e625 403 return jButtonAddModule;\r
a13899c5 404 }\r
405\r
406 /**\r
df4b9c3e 407 * This method initializes jPanelBottomSouth\r
408 * \r
409 * This panel contains the Settings and Remove Buttons\r
a13899c5 410 * \r
df4b9c3e 411 * @return javax.swing.JPanel jPanelBottomSouth\r
a13899c5 412 */\r
4da2e625 413 private JPanel getJPanelBottomSouth() {\r
414 if (jPanelBottomSouth == null) {\r
a13899c5 415 FlowLayout flowLayout1 = new FlowLayout();\r
416 flowLayout1.setAlignment(java.awt.FlowLayout.RIGHT);\r
4da2e625 417 jPanelBottomSouth = new JPanel();\r
418 jPanelBottomSouth.setLayout(flowLayout1);\r
419 jPanelBottomSouth.add(getJButtonSettings(), null);\r
420 jPanelBottomSouth.add(getJButtonRemoveModule(), null);\r
a13899c5 421 }\r
4da2e625 422 return jPanelBottomSouth;\r
a13899c5 423 }\r
424\r
425 /**\r
df4b9c3e 426 * This method initializes jScrollPaneFpdModules\r
a13899c5 427 * \r
df4b9c3e 428 * @return javax.swing.JScrollPane jScrollPaneFpdModules\r
a13899c5 429 */\r
4da2e625 430 private JScrollPane getJScrollPaneFpdModules() {\r
431 if (jScrollPaneFpdModules == null) {\r
432 jScrollPaneFpdModules = new JScrollPane();\r
a8a9de7c 433 jScrollPaneFpdModules.setPreferredSize(new java.awt.Dimension(453, 200));\r
4da2e625 434 jScrollPaneFpdModules.setViewportView(getJTableFpdModules());\r
a13899c5 435 }\r
4da2e625 436 return jScrollPaneFpdModules;\r
a13899c5 437 }\r
438\r
439 /**\r
df4b9c3e 440 * This method initializes jTableFpdModules\r
a13899c5 441 * \r
df4b9c3e 442 * @return javax.swing.JTable jTableFpdModules\r
a13899c5 443 */\r
4da2e625 444 private JTable getJTableFpdModules() {\r
445 if (jTableFpdModules == null) {\r
446 modelFpdModules = new NonEditableTableModel();\r
add40ab2 447 TableSorter sorter = new TableSorter(modelFpdModules);\r
448 jTableFpdModules = new JTable(sorter);\r
449 sorter.setTableHeader(jTableFpdModules.getTableHeader());\r
4da2e625 450 jTableFpdModules.setRowHeight(20);\r
a8a9de7c 451 modelFpdModules.addColumn("<html>Module<br>Name</html>");\r
a8a9de7c 452 modelFpdModules.addColumn("<html>Package<br>Name</html>");\r
4da2e625 453 modelFpdModules.addColumn("Path");\r
93fd07b1 454 modelFpdModules.addColumn("<html>Supported<br>Architectures</html>");\r
4cd31580 455 modelFpdModules.addColumn("<html>Module<br>Type</html>");\r
93fd07b1 456 modelFpdModules.addColumn("<html>Module<br>Version</html>");\r
df4b9c3e 457 modelFpdModules.addColumn("<html>Package<br>Version</html>");\r
4cd31580 458\r
93fd07b1 459 \r
a8a9de7c 460 javax.swing.table.TableColumn column = null;\r
d208e1e2 461 column = jTableFpdModules.getColumnModel().getColumn(modNameColForFpdModTable);\r
462 column.setPreferredWidth(modNamePrefWidth);\r
463 column.setMinWidth(modNameMinWidth);\r
df4b9c3e 464 column.setMaxWidth(modNameMaxWidth);\r
d208e1e2 465 column = jTableFpdModules.getColumnModel().getColumn(modVerColForFpdModTable);\r
466 column.setPreferredWidth(verPrefWidth);\r
467 column.setMaxWidth(verMaxWidth);\r
468 column.setMinWidth(verMinWidth);\r
469 column = jTableFpdModules.getColumnModel().getColumn(pkgNameColForFpdModTable);\r
470 column.setPreferredWidth(pkgNamePrefWidth);\r
471 column.setMinWidth(pkgNameMinWidth);\r
472 column.setMaxWidth(pkgNameMaxWidth);\r
473 column = jTableFpdModules.getColumnModel().getColumn(pkgVerColForFpdModTable);\r
474 column.setPreferredWidth(verPrefWidth);\r
475 column.setMaxWidth(verMaxWidth);\r
476 column.setMinWidth(verMinWidth);\r
477 column = jTableFpdModules.getColumnModel().getColumn(archColForFpdModTable);\r
478 column.setPreferredWidth(archPrefWidth);\r
479 column.setMaxWidth(archMaxWidth);\r
480 column.setMinWidth(archMinWidth);\r
481 column = jTableFpdModules.getColumnModel().getColumn(pathColForFpdModTable);\r
482 column.setPreferredWidth(pathPrefWidth);\r
483 column.setMinWidth(pathMinWidth);\r
4cd31580 484 column = jTableFpdModules.getColumnModel().getColumn(typeColForFpdModTable);\r
485 column.setPreferredWidth(typePrefWidth);\r
486 column.setMaxWidth(typeMaxWidth);\r
487 column.setMinWidth(typeMinWidth);\r
a8a9de7c 488\r
4da2e625 489 jTableFpdModules.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);\r
4cd31580 490\r
a13899c5 491 }\r
4da2e625 492 return jTableFpdModules;\r
a13899c5 493 }\r
494\r
495 /**\r
df4b9c3e 496 * This method initializes jButtonSettings\r
a13899c5 497 * \r
df4b9c3e 498 * @return javax.swing.JButton jButtonSettings\r
a13899c5 499 */\r
4da2e625 500 private JButton getJButtonSettings() {\r
501 if (jButtonSettings == null) {\r
502 jButtonSettings = new JButton();\r
503 jButtonSettings.setPreferredSize(new java.awt.Dimension(130,20));\r
504 jButtonSettings.setText("Settings");\r
505 jButtonSettings.addActionListener(new java.awt.event.ActionListener() {\r
a13899c5 506 public void actionPerformed(java.awt.event.ActionEvent e) {\r
4da2e625 507 int selectedRow = jTableFpdModules.getSelectedRow();\r
a8a9de7c 508 if (selectedRow < 0) {\r
a13899c5 509 return;\r
510 }\r
a8a9de7c 511\r
512 TableSorter sorter = (TableSorter) jTableFpdModules.getModel();\r
add40ab2 513 selectedRow = sorter.modelIndex(selectedRow);\r
1dac04ab 514 try {\r
515 if (ffc.adjustPcd(selectedRow)) {\r
516 docConsole.setSaved(false);\r
517 }\r
518 }\r
519 catch (Exception exp) {\r
520 JOptionPane.showMessageDialog(frame, exp.getMessage());\r
521 return;\r
522 }\r
add40ab2 523 \r
a13899c5 524 if (settingDlg == null) {\r
525 settingDlg = new FpdModuleSA(ffc);\r
526 }\r
a8a9de7c 527\r
bf5abaff 528 String[] sa = new String[5];\r
529 ffc.getFrameworkModuleInfo(selectedRow, sa);\r
d208e1e2 530 String mg = sa[ffcModGuid];\r
531 String mv = sa[ffcModVer];\r
532 String pg = sa[ffcPkgGuid];\r
533 String pv = sa[ffcPkgVer];\r
534 String arch = sa[ffcModArch];\r
8f55ea73 535 settingDlg.setKey(mg + " " + mv + " " + pg + " " + pv + " " + arch, selectedRow, docConsole);\r
a13899c5 536 settingDlg.setVisible(true);\r
537 }\r
538 });\r
539 }\r
4da2e625 540 return jButtonSettings;\r
a13899c5 541 }\r
542\r
543 /**\r
df4b9c3e 544 * This method initializes jButtonRemoveModule\r
a13899c5 545 * \r
df4b9c3e 546 * @return javax.swing.JButton jButtonRemoveModule\r
a13899c5 547 */\r
4da2e625 548 private JButton getJButtonRemoveModule() {\r
549 if (jButtonRemoveModule == null) {\r
550 jButtonRemoveModule = new JButton();\r
a8a9de7c 551 jButtonRemoveModule.setPreferredSize(new java.awt.Dimension(130, 20));\r
4da2e625 552 jButtonRemoveModule.setText("Remove Module");\r
553 jButtonRemoveModule.addActionListener(new java.awt.event.ActionListener() {\r
a13899c5 554 public void actionPerformed(java.awt.event.ActionEvent e) {\r
4da2e625 555 int selectedRow = jTableFpdModules.getSelectedRow();\r
a8a9de7c 556 if (selectedRow < 0) {\r
a13899c5 557 return;\r
558 }\r
a8a9de7c 559\r
560 TableSorter sorter = (TableSorter) jTableFpdModules.getModel();\r
add40ab2 561 selectedRow = sorter.modelIndex(selectedRow);\r
a8a9de7c 562\r
bf5abaff 563 String[] sa = new String[5];\r
564 ffc.getFrameworkModuleInfo(selectedRow, sa);\r
d208e1e2 565 String mg = sa[ffcModGuid];\r
566 String mv = sa[ffcModVer];\r
567 String pg = sa[ffcPkgGuid];\r
568 String pv = sa[ffcPkgVer];\r
569 String arch = sa[ffcModArch];\r
570 ModuleIdentification mi = GlobalData.getModuleId(mg + " " + mv + " " + pg + " " + pv + " " + arch);\r
bf5abaff 571 mv = mi.getVersion();\r
572 pv = mi.getPackage().getVersion();\r
4da2e625 573 modelFpdModules.removeRow(selectedRow);\r
bf5abaff 574 if (arch == null) {\r
575 // if no arch specified in ModuleSA\r
a8a9de7c 576 fpdMsa.remove(mg + mv + pg + pv);\r
577 } else {\r
578 ArrayList<String> al = fpdMsa.get(mg + mv + pg + pv);\r
bf5abaff 579 al.remove(arch);\r
580 if (al.size() == 0) {\r
a8a9de7c 581 fpdMsa.remove(mg + mv + pg + pv);\r
bf5abaff 582 }\r
583 }\r
a8a9de7c 584\r
d6d24759 585 docConsole.setSaved(false);\r
a13899c5 586 ffc.removeModuleSA(selectedRow);\r
587 }\r
588 });\r
589 }\r
4da2e625 590 return jButtonRemoveModule;\r
a13899c5 591 }\r
592\r
593 /**\r
df4b9c3e 594 * \r
a13899c5 595 * @param args\r
596 */\r
597 public static void main(String[] args) {\r
4cd31580 598 // Set the pane visable\r
a13899c5 599 new FpdFrameworkModules().setVisible(true);\r
600 }\r
601\r
602 /**\r
603 * This is the default constructor\r
604 */\r
605 public FpdFrameworkModules() {\r
606 super();\r
607 initialize();\r
608 }\r
609\r
a8a9de7c 610 public FpdFrameworkModules(PlatformSurfaceAreaDocument.PlatformSurfaceArea fpd) {\r
a13899c5 611 this();\r
612 init(fpd);\r
a8a9de7c 613\r
a13899c5 614 }\r
a8a9de7c 615\r
d6d24759 616 public FpdFrameworkModules(OpeningPlatformType opt) {\r
617 this(opt.getXmlFpd());\r
618 docConsole = opt;\r
619 }\r
a8a9de7c 620\r
a13899c5 621 private void init(PlatformSurfaceAreaDocument.PlatformSurfaceArea fpd) {\r
622 try {\r
623 GlobalData.initInfo("Tools" + File.separator + "Conf" + File.separator + "FrameworkDatabase.db", System.getenv("WORKSPACE"));\r
624 }\r
625 catch(Exception e){\r
410e0e9f 626 JOptionPane.showMessageDialog(frame, "Error occurred when getting module data.");\r
a13899c5 627 }\r
a8a9de7c 628\r
629 if (ffc == null) {\r
a13899c5 630 ffc = new FpdFileContents(fpd);\r
631 ffc.initDynPcdMap();\r
632 }\r
a8a9de7c 633\r
a13899c5 634 if (fpdMsa == null) {\r
bf5abaff 635 fpdMsa = new HashMap<String, ArrayList<String>>();\r
a13899c5 636 }\r
a8a9de7c 637\r
a13899c5 638 if (ffc.getFrameworkModulesCount() > 0) {\r
639 String[][] saa = new String[ffc.getFrameworkModulesCount()][5];\r
640 ffc.getFrameworkModulesInfo(saa);\r
641 for (int i = 0; i < saa.length; ++i) {\r
d208e1e2 642 ModuleIdentification mi = GlobalData.getModuleId(saa[i][ffcModGuid] + " " + saa[i][ffcModVer] + " "\r
643 + saa[i][ffcPkgGuid] + " " + saa[i][ffcPkgVer]);\r
4cd31580 644 String[] row = { "", "", "", "", "", "", "" };\r
f3b0ed9a 645 if (mi != null) {\r
d208e1e2 646 row[modNameColForFpdModTable] = mi.getName();\r
647 row[modVerColForFpdModTable] = mi.getVersion();\r
4cd31580 648 row[typeColForFpdModTable] = mi.getModuleType();\r
d208e1e2 649 row[pkgNameColForFpdModTable] = mi.getPackage().getName();\r
650 row[pkgVerColForFpdModTable] = mi.getPackage().getVersion();\r
651 row[archColForFpdModTable] = saa[i][4];\r
a8a9de7c 652 try {\r
d208e1e2 653 row[pathColForFpdModTable] = GlobalData.getMsaFile(mi).getPath().substring(\r
a8a9de7c 654 System.getenv("WORKSPACE")\r
655 .length() + 1);\r
656 } catch (Exception e) {\r
657 JOptionPane.showMessageDialog(frame, "Show FPD Modules:" + e.getMessage());\r
bf5abaff 658 }\r
659 }\r
4da2e625 660 modelFpdModules.addRow(row);\r
d208e1e2 661 ArrayList<String> al = fpdMsa.get(saa[i][ffcModGuid] + saa[i][ffcModVer]\r
662 + saa[i][ffcPkgGuid] + saa[i][ffcPkgVer]);\r
bf5abaff 663 if (al == null) {\r
664 al = new ArrayList<String>();\r
d208e1e2 665 fpdMsa.put(saa[i][ffcModGuid] + saa[i][ffcModVer] + saa[i][ffcPkgGuid] + saa[i][ffcPkgVer], al);\r
a13899c5 666 }\r
d208e1e2 667 al.add(saa[i][ffcModArch]);\r
a8a9de7c 668\r
a13899c5 669 }\r
f4c4325b 670 TableSorter sorter = (TableSorter)jTableFpdModules.getModel();\r
671 sorter.setSortingStatus(modNameColForFpdModTable, TableSorter.ASCENDING);\r
a13899c5 672 }\r
a8a9de7c 673\r
a13899c5 674 showAllModules();\r
a8a9de7c 675\r
a13899c5 676 }\r
a8a9de7c 677\r
a13899c5 678 private void showAllModules() {\r
a8a9de7c 679\r
a13899c5 680 if (miList == null) {\r
681 miList = new ArrayList<ModuleIdentification>();\r
682 }\r
683 Set<PackageIdentification> spi = GlobalData.getPackageList();\r
684 Iterator ispi = spi.iterator();\r
a8a9de7c 685\r
686 while (ispi.hasNext()) {\r
687 PackageIdentification pi = (PackageIdentification) ispi.next();\r
df4b9c3e 688 String[] s = { "", "", "", "", "", "" };\r
a8a9de7c 689\r
a13899c5 690 Set<ModuleIdentification> smi = GlobalData.getModules(pi);\r
691 Iterator ismi = smi.iterator();\r
a8a9de7c 692 while (ismi.hasNext()) {\r
693 ModuleIdentification mi = (ModuleIdentification) ismi.next();\r
d208e1e2 694 s[modNameColForAllModTable] = mi.getName();\r
695 s[modVerColForAllModTable] = mi.getVersion();\r
df4b9c3e 696 s[typeColForAllModTable] = mi.getModuleType();\r
d208e1e2 697 s[pkgNameColForAllModTable] = pi.getName();\r
698 s[pkgVerColForAllModTable] = pi.getVersion();\r
bf5abaff 699 try {\r
d208e1e2 700 s[pathColForAllModTable] = GlobalData.getMsaFile(mi).getPath()\r
a8a9de7c 701 .substring(System.getenv("WORKSPACE").length() + 1);\r
702 } catch (Exception e) {\r
703 JOptionPane.showMessageDialog(frame, "Show All Modules:" + e.getMessage());\r
bf5abaff 704 }\r
4da2e625 705 modelAllModules.addRow(s);\r
a13899c5 706 miList.add(mi);\r
707 }\r
708 }\r
f4c4325b 709 \r
710 TableSorter sorter = (TableSorter)jTableAllModules.getModel();\r
711 sorter.setSortingStatus(modNameColForAllModTable, TableSorter.ASCENDING);\r
a13899c5 712 }\r
a8a9de7c 713\r
a13899c5 714 /**\r
715 * This method initializes this\r
716 * \r
717 * @return void\r
718 */\r
719 private void initialize() {\r
720 this.setSize(633, 533);\r
721 this.setTitle("Framework Modules");\r
722 this.setContentPane(getJSplitPane());\r
723 this.setVisible(true);\r
a8a9de7c 724\r
a13899c5 725 }\r
a13899c5 726\r
a8a9de7c 727} // @jve:decl-index=0:visual-constraint="10,10"\r
a13899c5 728\r
729class NonEditableTableModel extends DefaultTableModel {\r
44053733 730 /**\r
731 * \r
732 */\r
733 private static final long serialVersionUID = 1L;\r
734\r
a13899c5 735 public boolean isCellEditable(int row, int col) {\r
736 return false;\r
737 }\r
738}\r