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