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