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