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