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