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