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