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