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