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