]> git.proxmox.com Git - mirror_edk2.git/blob - Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/FpdModuleSA.java
Adjust Platform Definition and Module SA operations in FPD editor.
[mirror_edk2.git] / Tools / Source / FrameworkWizard / src / org / tianocore / frameworkwizard / platform / ui / FpdModuleSA.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.JDialog;
9 import javax.swing.JTabbedPane;
10 import javax.swing.JLabel;
11 import javax.swing.JScrollPane;
12 import javax.swing.JTable;
13 import javax.swing.JTextArea;
14 import javax.swing.JSplitPane;
15 import javax.swing.JButton;
16 import javax.swing.ListSelectionModel;
17 import javax.swing.event.ListSelectionEvent;
18 import javax.swing.event.ListSelectionListener;
19 import javax.swing.event.TableModelEvent;
20 import javax.swing.event.TableModelListener;
21 import javax.swing.table.DefaultTableModel;
22 import javax.swing.table.TableModel;
23
24 import org.apache.xmlbeans.XmlObject;
25 import org.tianocore.frameworkwizard.platform.ui.global.GlobalData;
26 import org.tianocore.frameworkwizard.platform.ui.global.SurfaceAreaQuery;
27 import org.tianocore.frameworkwizard.platform.ui.id.ModuleIdentification;
28 import org.tianocore.frameworkwizard.platform.ui.id.PackageIdentification;
29
30 import java.awt.FlowLayout;
31 import java.awt.event.ActionEvent;
32 import java.awt.event.ActionListener;
33 import java.util.ArrayList;
34 import java.util.HashMap;
35 import java.util.Iterator;
36 import java.util.ListIterator;
37 import java.util.Map;
38 import java.util.Set;
39 import javax.swing.JTextField;
40
41 public class FpdModuleSA extends JDialog implements ActionListener {
42
43 /**
44 *
45 */
46 private static final long serialVersionUID = 1L;
47 static JFrame frame;
48 private JPanel jContentPane = null;
49 private JTabbedPane jTabbedPane = null;
50 private JPanel jPanel = null;
51 private JPanel jPanel1 = null;
52 private JLabel jLabel = null;
53 private JScrollPane jScrollPane = null;
54 private JTable jTable = null;
55 private JPanel jPanel2 = null;
56 private JScrollPane jScrollPane1 = null;
57 private JTextArea jTextArea = null;
58 private JPanel jPanel3 = null;
59 private JSplitPane jSplitPane = null;
60 private JPanel jPanel4 = null;
61 private JPanel jPanel5 = null;
62 private JLabel jLabel1 = null;
63 private JLabel jLabel2 = null;
64 private JScrollPane jScrollPane2 = null;
65 private JTable jTable1 = null;
66 private JScrollPane jScrollPane3 = null;
67 private JTable jTable2 = null;
68 private JScrollPane jScrollPane4 = null;
69 private JTable jTable3 = null;
70 private JPanel jPanel6 = null;
71 private JPanel jPanel7 = null;
72 private JScrollPane jScrollPane5 = null;
73 private JTextArea jTextArea1 = null;
74 private JLabel jLabel3 = null;
75 private JLabel jLabel4 = null;
76 private JButton jButton = null;
77 private JButton jButton1 = null;
78 private JLabel jLabel5 = null;
79 private JButton jButton2 = null;
80 private JButton jButton3 = null;
81 private PartialEditableTableModel model = null;
82 private LibraryTableModel model1 = null;
83 private LibraryTableModel model2 = null;
84 private LibraryTableModel model3 = null;
85 private FpdFileContents ffc = null;
86 private String moduleKey = null;
87 private HashMap<String, ArrayList<String>> classInstanceMap = null;
88 private ArrayList<String> classProduced = null;
89 private HashMap<String, ArrayList<String>> classConsumed = null;
90 private JPanel jPanel8 = null;
91 private JLabel jLabel6 = null;
92 private JTextField jTextField = null;
93 private JLabel jLabel7 = null;
94 private JTextField jTextField1 = null;
95 private JLabel jLabel8 = null;
96 private JTextField jTextField2 = null;
97 private JScrollPane jScrollPane6 = null;
98 private JTable jTable4 = null;
99 /**
100 * This is the default constructor
101 */
102 public FpdModuleSA() {
103 super();
104 initialize();
105 }
106 public FpdModuleSA(FpdFileContents ffc) {
107 this();
108 this.ffc = ffc;
109 }
110
111 public void setKey(String k){
112 this.moduleKey = k;
113 }
114
115 /**
116 init will be called each time FpdModuleSA object is to be shown.
117 @param key Module information.
118 **/
119 public void init(String key) {
120 //
121 // display pcd for key.
122 //
123 model.setRowCount(0);
124 int pcdCount = ffc.getPcdDataCount(key);
125 if (pcdCount != 0) {
126 String[][] saa = new String[pcdCount][6];
127 ffc.getPcdData(key, saa);
128 for (int i = 0; i < saa.length; ++i) {
129 model.addRow(saa[i]);
130 }
131 }
132
133 //
134 // display lib instances already selected for key
135 //
136 model1.setRowCount(0);
137 int instanceCount = ffc.getLibraryInstancesCount(key);
138 if (instanceCount != 0) {
139 String[][] saa = new String[instanceCount][5];
140 ffc.getLibraryInstances(key, saa);
141 for (int i = 0; i < saa.length; ++i) {
142 if (getModuleId(saa[i][1] + " " + saa[i][2] + " " + saa[i][3] + " " + saa[i][4]) != null) {
143 saa[i][0] = getModuleId(saa[i][1] + " " + saa[i][2] + " " + saa[i][3] + " " + saa[i][4]).getName();
144 }
145
146 model1.addRow(saa[i]);
147 }
148 }
149 //
150 // display library classes that need to be resolved. also potential instances for them.
151 //
152 resolveLibraryInstances(key);
153 }
154
155 private void resolveLibraryInstances(String key) {
156 ModuleIdentification mi = getModuleId(key);
157 PackageIdentification[] depPkgList = null;
158 try{
159 Map<String, XmlObject> m = GlobalData.getNativeMsa(mi);
160 SurfaceAreaQuery.setDoc(m);
161 //
162 // Get dependency pkg list into which we will search lib instances.
163 //
164 depPkgList = SurfaceAreaQuery.getDependencePkg(null);
165 //
166 // Get the lib class consumed, produced by this module itself.
167 //
168 String[] classConsumed = SurfaceAreaQuery.getLibraryClasses("ALWAYS_CONSUMED");
169
170 if (this.classConsumed == null) {
171 this.classConsumed = new HashMap<String, ArrayList<String>>();
172 }
173
174 for(int i = 0; i < classConsumed.length; ++i){
175 ArrayList<String> consumedBy = this.classConsumed.get(classConsumed[i]);
176 if (consumedBy == null) {
177 consumedBy = new ArrayList<String>();
178 }
179 consumedBy.add(key);
180 this.classConsumed.put(classConsumed[i], consumedBy);
181 }
182
183 String[] classProduced = SurfaceAreaQuery.getLibraryClasses("ALWAYS_PRODUCED");
184 if (this.classProduced == null) {
185 this.classProduced = new ArrayList<String>();
186 }
187 for(int i = 0; i < classProduced.length; ++i){
188 if (!this.classProduced.contains(classProduced[i])){
189 this.classProduced.add(classProduced[i]);
190 }
191 }
192 //
193 // Get classes unresolved
194 //
195 // Iterator<String> lip = this.classProduced.listIterator();
196 // while(lip.hasNext()){
197 // String clsProduced = lip.next();
198 // this.classConsumed.remove(clsProduced);
199 //
200 // }
201 //
202 // find potential instances in all dependency pkgs for classes still in classConsumed.
203 //
204 if (classInstanceMap == null){
205 classInstanceMap = new HashMap<String, ArrayList<String>>();
206 }
207 Iterator<String> lic = this.classConsumed.keySet().iterator();
208 while(lic.hasNext()){
209 String cls = lic.next();
210 if (this.classProduced.contains(cls) || classInstanceMap.containsKey(cls)) {
211 continue;
212 }
213 ArrayList<String> instances = getInstancesForClass(cls, depPkgList);
214 if (instances.size() == 0){
215 JOptionPane.showMessageDialog(frame, "No Applicable Instance for Library Class " +
216 cls + ", Platform Build will Fail.");
217 }
218 classInstanceMap.put(cls, instances);
219
220 }
221
222 showClassToResolved();
223 }
224 catch(Exception e) {
225 e.printStackTrace();
226 }
227 }
228
229 private ArrayList<String> getInstancesForClass(String cls, PackageIdentification[] depPkgList) throws Exception{
230 ArrayList<String> al = new ArrayList<String>();
231
232 for (int i = 0; i < depPkgList.length; ++i) {
233 Set<ModuleIdentification> smi = GlobalData.getModules(depPkgList[i]);
234 Iterator ismi = smi.iterator();
235 while(ismi.hasNext()) {
236 ModuleIdentification mi = (ModuleIdentification)ismi.next();
237
238 String[] clsProduced = getClassProduced(mi);
239
240 boolean isPotential = false;
241 for (int j = 0; j < clsProduced.length; ++j) {
242 if (clsProduced[j] == null) {
243 continue;
244 }
245 if (clsProduced[j].equals(cls)){
246 isPotential = true;
247 }
248 if (classProduced.contains(clsProduced[j])) {
249 isPotential = false;
250 break;
251 }
252 }
253 if (isPotential) {
254 al.add(mi.getGuid() + " " + mi.getVersion() + " " +
255 depPkgList[i].getGuid() + " " + depPkgList[i].getVersion());
256 }
257 }
258 }
259
260 return al;
261 }
262
263 private void removeInstance(String key) {
264 ModuleIdentification mi = getModuleId(key);
265 //
266 // remove pcd information of instance from current ModuleSA
267 //
268 ffc.removePcdDataFromLibraryInstance(moduleKey, key);
269 //
270 // remove class produced by this instance and add back these produced class to be bound.
271 //
272 String[] clsProduced = getClassProduced(mi);
273 for (int i = 0; i < clsProduced.length; ++i) {
274
275 classProduced.remove(clsProduced[i]);
276 }
277 //
278 // remove class consumed by this instance. we do not need to bound it now.
279 //
280 String[] clsConsumed = getClassConsumed(mi);
281 for (int i = 0; i < clsConsumed.length; ++i) {
282 ArrayList<String> al = classConsumed.get(clsConsumed[i]);
283
284 if (al == null ) {
285 classConsumed.remove(clsConsumed[i]);
286 continue;
287 }
288 al.remove(key);
289 if (al.size() == 0) {
290 classConsumed.remove(clsConsumed[i]);
291 }
292
293 }
294
295 showClassToResolved();
296
297 }
298
299 private ModuleIdentification getModuleId(String key){
300 //
301 // Get ModuleGuid, ModuleVersion, PackageGuid, PackageVersion into string array.
302 //
303 String[] keyPart = key.split(" ");
304 Set<PackageIdentification> spi = GlobalData.getPackageList();
305 Iterator ispi = spi.iterator();
306
307 while(ispi.hasNext()) {
308 PackageIdentification pi = (PackageIdentification)ispi.next();
309 if ( !pi.getGuid().equals(keyPart[2]) || !pi.getVersion().equals(keyPart[3])){
310 continue;
311 }
312 Set<ModuleIdentification> smi = GlobalData.getModules(pi);
313 Iterator ismi = smi.iterator();
314 while(ismi.hasNext()) {
315 ModuleIdentification mi = (ModuleIdentification)ismi.next();
316 if (mi.getGuid().equals(keyPart[0]) && mi.getVersion().equals(keyPart[1])){
317 return mi;
318 }
319 }
320 }
321 return null;
322 }
323
324 private String[] getClassProduced(ModuleIdentification mi){
325
326 try{
327 Map<String, XmlObject> m = GlobalData.getNativeMsa(mi);
328 SurfaceAreaQuery.setDoc(m);
329 String[] clsProduced = SurfaceAreaQuery.getLibraryClasses("ALWAYS_PRODUCED");
330 return clsProduced;
331
332 }catch (Exception e) {
333 e.printStackTrace();
334 }
335 return new String[0];
336
337 }
338
339 private String[] getClassConsumed(ModuleIdentification mi){
340
341 String[] clsConsumed = null;
342 try{
343 Map<String, XmlObject> m = GlobalData.getNativeMsa(mi);
344 SurfaceAreaQuery.setDoc(m);
345 clsConsumed = SurfaceAreaQuery.getLibraryClasses("ALWAYS_CONSUMED");
346
347 }catch (Exception e) {
348 e.printStackTrace();
349 }
350 return clsConsumed;
351 }
352
353 private void showClassToResolved(){
354 model2.setRowCount(0);
355 if (classConsumed.size() == 0) {
356 return;
357 }
358 Iterator<String> li = classConsumed.keySet().iterator();
359 while(li.hasNext()){
360
361 String[] s = {li.next()};
362 if (classConsumed.get(s[0]) == null) {
363 continue;
364 }
365 if (classConsumed.get(s[0]).size() == 0) {
366 continue;
367 }
368 if (!classProduced.contains(s[0])){
369 model2.addRow(s);
370 }
371 }
372 model3.setRowCount(0);
373 }
374 /**
375 * This method initializes this
376 *
377 * @return void
378 */
379 private void initialize() {
380 this.setSize(664, 515);
381 this.setModal(true);
382 this.setTitle("Module Settings");
383 this.setContentPane(getJContentPane());
384 }
385
386 /**
387 * This method initializes jContentPane
388 *
389 * @return javax.swing.JPanel
390 */
391 private JPanel getJContentPane() {
392 if (jContentPane == null) {
393 jContentPane = new JPanel();
394 jContentPane.setLayout(new BorderLayout());
395 jContentPane.add(getJTabbedPane(), java.awt.BorderLayout.CENTER);
396 jContentPane.add(getJPanel3(), java.awt.BorderLayout.SOUTH);
397 }
398 return jContentPane;
399 }
400
401 /**
402 * This method initializes jTabbedPane
403 *
404 * @return javax.swing.JTabbedPane
405 */
406 private JTabbedPane getJTabbedPane() {
407 if (jTabbedPane == null) {
408 jTabbedPane = new JTabbedPane();
409 jTabbedPane.addTab("PCD Build Definition", null, getJPanel(), null);
410 jTabbedPane.addTab("Module SA Options", null, getJPanel8(), null);
411 jTabbedPane.addTab("Libraries", null, getJPanel1(), null);
412 }
413 return jTabbedPane;
414 }
415
416 /**
417 * This method initializes jPanel
418 *
419 * @return javax.swing.JPanel
420 */
421 private JPanel getJPanel() {
422 if (jPanel == null) {
423 jLabel = new JLabel();
424 jLabel.setText("PcdData");
425 jPanel = new JPanel();
426 jPanel.setLayout(new BorderLayout());
427 jPanel.add(jLabel, java.awt.BorderLayout.NORTH);
428 jPanel.add(getJScrollPane(), java.awt.BorderLayout.CENTER);
429 jPanel.add(getJPanel2(), java.awt.BorderLayout.SOUTH);
430 jPanel.addComponentListener(new java.awt.event.ComponentAdapter() {
431 public void componentShown(java.awt.event.ComponentEvent e) {
432 init(moduleKey);
433 }
434 });
435
436 }
437 return jPanel;
438 }
439
440 /**
441 * This method initializes jPanel1
442 *
443 * @return javax.swing.JPanel
444 */
445 private JPanel getJPanel1() {
446 if (jPanel1 == null) {
447 jPanel1 = new JPanel();
448 jPanel1.setLayout(new BorderLayout());
449 jPanel1.add(getJSplitPane(), java.awt.BorderLayout.NORTH);
450 jPanel1.add(getJPanel6(), java.awt.BorderLayout.SOUTH);
451 jPanel1.add(getJPanel7(), java.awt.BorderLayout.CENTER);
452 jPanel1.addComponentListener(new java.awt.event.ComponentAdapter() {
453 public void componentShown(java.awt.event.ComponentEvent e) {
454 }
455 });
456 }
457 return jPanel1;
458 }
459
460 /**
461 * This method initializes jScrollPane
462 *
463 * @return javax.swing.JScrollPane
464 */
465 private JScrollPane getJScrollPane() {
466 if (jScrollPane == null) {
467 jScrollPane = new JScrollPane();
468 jScrollPane.setViewportView(getJTable());
469 }
470 return jScrollPane;
471 }
472
473 /**
474 * This method initializes jTable
475 *
476 * @return javax.swing.JTable
477 */
478 private JTable getJTable() {
479 if (jTable == null) {
480 model = new PartialEditableTableModel();
481 jTable = new JTable(model);
482 model.addColumn("CName");
483 model.addColumn("TokenSpaceGUID");
484 model.addColumn("ItemType");
485 model.addColumn("Token");
486 model.addColumn("DataType");
487 model.addColumn("DefaultValue");
488
489 jTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
490 jTable.getSelectionModel().addListSelectionListener(new ListSelectionListener(){
491 public void valueChanged(ListSelectionEvent e) {
492
493 if (e.getValueIsAdjusting()){
494 return;
495 }
496 ListSelectionModel lsm = (ListSelectionModel)e.getSource();
497 if (lsm.isSelectionEmpty()) {
498 return;
499 }
500 else{
501 // int selectedRow = lsm.getMinSelectionIndex();
502
503
504 }
505 }
506 });
507
508 jTable.getModel().addTableModelListener(new TableModelListener() {
509 public void tableChanged(TableModelEvent arg0) {
510 // TODO Auto-generated method stub
511 int row = arg0.getFirstRow();
512 TableModel m = (TableModel)arg0.getSource();
513 if (arg0.getType() == TableModelEvent.INSERT) {
514 //
515 // Set combo box values for item type according to pcd values added.
516 //
517
518 }
519 if (arg0.getType() == TableModelEvent.UPDATE){
520 //ToDo Data Validition check.
521
522 }
523 }
524 });
525 }
526 return jTable;
527 }
528
529 /**
530 * This method initializes jPanel2
531 *
532 * @return javax.swing.JPanel
533 */
534 private JPanel getJPanel2() {
535 if (jPanel2 == null) {
536 jLabel5 = new JLabel();
537 jLabel5.setText("PCD Description");
538 jPanel2 = new JPanel();
539 jPanel2.add(jLabel5, null);
540 jPanel2.add(getJScrollPane1(), null);
541 }
542 return jPanel2;
543 }
544
545 /**
546 * This method initializes jScrollPane1
547 *
548 * @return javax.swing.JScrollPane
549 */
550 private JScrollPane getJScrollPane1() {
551 if (jScrollPane1 == null) {
552 jScrollPane1 = new JScrollPane();
553 jScrollPane1.setPreferredSize(new java.awt.Dimension(500,100));
554 jScrollPane1.setViewportView(getJTextArea());
555 }
556 return jScrollPane1;
557 }
558
559 /**
560 * This method initializes jTextArea
561 *
562 * @return javax.swing.JTextArea
563 */
564 private JTextArea getJTextArea() {
565 if (jTextArea == null) {
566 jTextArea = new JTextArea();
567 jTextArea.setEditable(false);
568 }
569 return jTextArea;
570 }
571
572 /**
573 * This method initializes jPanel3
574 *
575 * @return javax.swing.JPanel
576 */
577 private JPanel getJPanel3() {
578 if (jPanel3 == null) {
579 FlowLayout flowLayout = new FlowLayout();
580 flowLayout.setAlignment(java.awt.FlowLayout.RIGHT);
581 jPanel3 = new JPanel();
582 jPanel3.setLayout(flowLayout);
583 jPanel3.add(getJButton2(), null);
584 jPanel3.add(getJButton3(), null);
585 }
586 return jPanel3;
587 }
588
589 /**
590 * This method initializes jSplitPane
591 *
592 * @return javax.swing.JSplitPane
593 */
594 private JSplitPane getJSplitPane() {
595 if (jSplitPane == null) {
596 jSplitPane = new JSplitPane();
597 jSplitPane.setDividerLocation(200);
598 jSplitPane.setLeftComponent(getJPanel4());
599 jSplitPane.setRightComponent(getJPanel5());
600 jSplitPane.setPreferredSize(new java.awt.Dimension(202,200));
601 }
602 return jSplitPane;
603 }
604
605 /**
606 * This method initializes jPanel4
607 *
608 * @return javax.swing.JPanel
609 */
610 private JPanel getJPanel4() {
611 if (jPanel4 == null) {
612 jLabel1 = new JLabel();
613 jLabel1.setText("Library Classes Consumed");
614 jPanel4 = new JPanel();
615 jPanel4.add(jLabel1, null);
616 jPanel4.add(getJScrollPane3(), null);
617 }
618 return jPanel4;
619 }
620
621 /**
622 * This method initializes jPanel5
623 *
624 * @return javax.swing.JPanel
625 */
626 private JPanel getJPanel5() {
627 if (jPanel5 == null) {
628 jLabel2 = new JLabel();
629 jLabel2.setText("Instances Available");
630 jPanel5 = new JPanel();
631 jPanel5.add(jLabel2, null);
632 jPanel5.add(getJScrollPane4(), null);
633 }
634 return jPanel5;
635 }
636
637 /**
638 * This method initializes jScrollPane2
639 *
640 * @return javax.swing.JScrollPane
641 */
642 private JScrollPane getJScrollPane2() {
643 if (jScrollPane2 == null) {
644 jScrollPane2 = new JScrollPane();
645 jScrollPane2.setPreferredSize(new java.awt.Dimension(453,150));
646 jScrollPane2.setViewportView(getJTable1());
647 }
648 return jScrollPane2;
649 }
650
651 /**
652 * This method initializes jTable1
653 *
654 * @return javax.swing.JTable
655 */
656 private JTable getJTable1() {
657 if (jTable1 == null) {
658 model1 = new LibraryTableModel();
659 model1.addColumn("Name");
660 model1.addColumn("ModuleGUID");
661 model1.addColumn("ModuleVersion");
662 model1.addColumn("PackageGUID");
663 model1.addColumn("PackageVersion");
664 jTable1 = new JTable(model1);
665
666 jTable1.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
667 jTable1.getSelectionModel().addListSelectionListener(new ListSelectionListener(){
668 public void valueChanged(ListSelectionEvent e) {
669 int selectedRow1 = -1;
670 if (e.getValueIsAdjusting()){
671 return;
672 }
673 ListSelectionModel lsm = (ListSelectionModel)e.getSource();
674 if (lsm.isSelectionEmpty()) {
675 return;
676 }
677 else{
678 selectedRow1 = lsm.getMinSelectionIndex();
679
680
681 }
682 }
683 });
684
685
686 }
687 return jTable1;
688 }
689
690 /**
691 * This method initializes jScrollPane3
692 *
693 * @return javax.swing.JScrollPane
694 */
695 private JScrollPane getJScrollPane3() {
696 if (jScrollPane3 == null) {
697 jScrollPane3 = new JScrollPane();
698 jScrollPane3.setPreferredSize(new java.awt.Dimension(200,170));
699 jScrollPane3.setViewportView(getJTable2());
700 }
701 return jScrollPane3;
702 }
703
704 /**
705 * This method initializes jTable2
706 *
707 * @return javax.swing.JTable
708 */
709 private JTable getJTable2() {
710 if (jTable2 == null) {
711 model2 = new LibraryTableModel();
712 model2.addColumn("LibraryClass");
713 jTable2 = new JTable(model2);
714
715 jTable2.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
716 jTable2.getSelectionModel().addListSelectionListener(new ListSelectionListener(){
717 public void valueChanged(ListSelectionEvent e) {
718 if (e.getValueIsAdjusting()){
719 return;
720 }
721 ListSelectionModel lsm = (ListSelectionModel)e.getSource();
722 if (lsm.isSelectionEmpty()) {
723 return;
724 }
725 else{
726 int selectedRow2 = lsm.getMinSelectionIndex();
727 if (selectedRow2 < 0) {
728 return;
729 }
730 //
731 // display potential lib instances according to class selection
732 //
733 model3.setRowCount(0);
734 String cls = model2.getValueAt(selectedRow2, 0).toString();
735 ArrayList<String> al = classInstanceMap.get(cls);
736 ListIterator<String> li = al.listIterator();
737 while(li.hasNext()) {
738 String instance = li.next();
739 String[] s = {"", "", "", "", ""};
740 if (getModuleId(instance) != null) {
741 s[0] = getModuleId(instance).getName();
742 }
743
744 String[] instancePart = instance.split(" ");
745 for (int i = 0; i < instancePart.length; ++i){
746 s[i+1] = instancePart[i];
747 }
748 model3.addRow(s);
749 }
750
751 }
752 }
753 });
754 }
755 return jTable2;
756 }
757
758 /**
759 * This method initializes jScrollPane4
760 *
761 * @return javax.swing.JScrollPane
762 */
763 private JScrollPane getJScrollPane4() {
764 if (jScrollPane4 == null) {
765 jScrollPane4 = new JScrollPane();
766 jScrollPane4.setPreferredSize(new java.awt.Dimension(450,170));
767 jScrollPane4.setViewportView(getJTable3());
768 }
769 return jScrollPane4;
770 }
771
772 /**
773 * This method initializes jTable3
774 *
775 * @return javax.swing.JTable
776 */
777 private JTable getJTable3() {
778 if (jTable3 == null) {
779 model3 = new LibraryTableModel();
780 model3.addColumn("Name");
781 model3.addColumn("ModuleGUID");
782 model3.addColumn("ModuleVersion");
783 model3.addColumn("PackageGUID");
784 model3.addColumn("PackageVersion");
785 jTable3 = new JTable(model3);
786
787 jTable3.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
788 jTable3.getSelectionModel().addListSelectionListener(new ListSelectionListener(){
789 public void valueChanged(ListSelectionEvent e) {
790 int selectedRow3 = -1;
791 if (e.getValueIsAdjusting()){
792 return;
793 }
794 ListSelectionModel lsm = (ListSelectionModel)e.getSource();
795 if (lsm.isSelectionEmpty()) {
796 return;
797 }
798 else{
799 selectedRow3 = lsm.getMinSelectionIndex();
800
801
802 }
803 }
804 });
805 }
806 return jTable3;
807 }
808
809 /**
810 * This method initializes jPanel6
811 *
812 * @return javax.swing.JPanel
813 */
814 private JPanel getJPanel6() {
815 if (jPanel6 == null) {
816 jPanel6 = new JPanel();
817 }
818 return jPanel6;
819 }
820
821 /**
822 * This method initializes jPanel7
823 *
824 * @return javax.swing.JPanel
825 */
826 private JPanel getJPanel7() {
827 if (jPanel7 == null) {
828 jLabel4 = new JLabel();
829 jLabel4.setText("Instance Description");
830 jLabel3 = new JLabel();
831 jLabel3.setText("Selected Instances");
832 jPanel7 = new JPanel();
833 jPanel7.add(jLabel4, null);
834 jPanel7.add(getJScrollPane5(), null);
835 jPanel7.add(getJButton(), null);
836 jPanel7.add(getJButton1(), null);
837 jPanel7.add(jLabel3, null);
838 jPanel7.add(getJScrollPane2(), null);
839 }
840 return jPanel7;
841 }
842
843 /**
844 * This method initializes jScrollPane5
845 *
846 * @return javax.swing.JScrollPane
847 */
848 private JScrollPane getJScrollPane5() {
849 if (jScrollPane5 == null) {
850 jScrollPane5 = new JScrollPane();
851 jScrollPane5.setPreferredSize(new java.awt.Dimension(300,50));
852 jScrollPane5.setViewportView(getJTextArea1());
853 }
854 return jScrollPane5;
855 }
856
857 /**
858 * This method initializes jTextArea1
859 *
860 * @return javax.swing.JTextArea
861 */
862 private JTextArea getJTextArea1() {
863 if (jTextArea1 == null) {
864 jTextArea1 = new JTextArea();
865 jTextArea1.setEditable(false);
866 }
867 return jTextArea1;
868 }
869
870 /**
871 * This method initializes jButton
872 *
873 * @return javax.swing.JButton
874 */
875 private JButton getJButton() {
876 if (jButton == null) {
877 jButton = new JButton();
878 jButton.setPreferredSize(new java.awt.Dimension(80,20));
879 jButton.setText("Add");
880 jButton.addActionListener(new java.awt.event.ActionListener() {
881 public void actionPerformed(java.awt.event.ActionEvent e) {
882 int row = jTable3.getSelectedRow();
883 if (row < 0) {
884 return;
885 }
886 Object[] s = {model3.getValueAt(row, 0), model3.getValueAt(row, 1),
887 model3.getValueAt(row, 2), model3.getValueAt(row, 3),
888 model3.getValueAt(row, 4)};
889 model1.addRow(s);
890 String instanceValue = model3.getValueAt(row, 1) + " " +
891 model3.getValueAt(row, 2) + " " +
892 model3.getValueAt(row, 3) + " " +
893 model3.getValueAt(row, 4);
894 //
895 // Add pcd information of selected instance to current moduleSA
896 //
897 ffc.addFrameworkModulesPcdBuildDefs(getModuleId(instanceValue), ffc.getModuleSA(moduleKey));
898
899 resolveLibraryInstances(instanceValue);
900 }
901 });
902 }
903 return jButton;
904 }
905
906 /**
907 * This method initializes jButton1
908 *
909 * @return javax.swing.JButton
910 */
911 private JButton getJButton1() {
912 if (jButton1 == null) {
913 jButton1 = new JButton();
914 jButton1.setPreferredSize(new java.awt.Dimension(80,20));
915 jButton1.setText("Delete");
916 jButton1.addActionListener(new java.awt.event.ActionListener() {
917 public void actionPerformed(java.awt.event.ActionEvent e) {
918 int row = jTable1.getSelectedRow();
919 if (row < 0) {
920 return;
921 }
922 removeInstance(model1.getValueAt(row, 1) + " " +
923 model1.getValueAt(row, 2) + " " +
924 model1.getValueAt(row, 3) + " " +
925 model1.getValueAt(row, 4));
926 model1.removeRow(row);
927
928 }
929 });
930 }
931 return jButton1;
932 }
933
934 /**
935 * This method initializes jButton2
936 *
937 * @return javax.swing.JButton
938 */
939 private JButton getJButton2() {
940 if (jButton2 == null) {
941 jButton2 = new JButton();
942 jButton2.setPreferredSize(new java.awt.Dimension(80,20));
943 jButton2.setText("Ok");
944 jButton2.addActionListener(this);
945 }
946 return jButton2;
947 }
948
949 /**
950 * This method initializes jButton3
951 *
952 * @return javax.swing.JButton
953 */
954 private JButton getJButton3() {
955 if (jButton3 == null) {
956 jButton3 = new JButton();
957 jButton3.setPreferredSize(new java.awt.Dimension(80,20));
958 jButton3.setText("Cancel");
959 jButton3.setVisible(false);
960 }
961 return jButton3;
962 }
963 public void actionPerformed(ActionEvent arg0) {
964
965 if (arg0.getSource() == jButton2) {
966 ffc.removeLibraryInstances(moduleKey);
967 for (int i = 0; i < model1.getRowCount(); ++i) {
968 String mg = model1.getValueAt(i, 1)+"";
969 String mv = model1.getValueAt(i, 2)+"";
970 String pg = model1.getValueAt(i, 3)+"";
971 String pv = model1.getValueAt(i, 4)+"";
972 ffc.genLibraryInstance(mg, mv, pg, pv, moduleKey);
973 }
974 this.setVisible(false);
975 }
976 }
977 /**
978 * This method initializes jPanel8
979 *
980 * @return javax.swing.JPanel
981 */
982 private JPanel getJPanel8() {
983 if (jPanel8 == null) {
984 jLabel8 = new JLabel();
985 jLabel8.setText("FFS Format Key");
986 jLabel7 = new JLabel();
987 jLabel7.setText("FFS File GUID");
988 jLabel6 = new JLabel();
989 jLabel6.setText("FV Binding");
990 jPanel8 = new JPanel();
991 jPanel8.add(jLabel6, null);
992 jPanel8.add(getJTextField(), null);
993 jPanel8.add(jLabel7, null);
994 jPanel8.add(getJTextField1(), null);
995 jPanel8.add(jLabel8, null);
996 jPanel8.add(getJTextField2(), null);
997 jPanel8.add(getJScrollPane6(), null);
998 }
999 return jPanel8;
1000 }
1001 /**
1002 * This method initializes jTextField
1003 *
1004 * @return javax.swing.JTextField
1005 */
1006 private JTextField getJTextField() {
1007 if (jTextField == null) {
1008 jTextField = new JTextField();
1009 jTextField.setPreferredSize(new java.awt.Dimension(100,20));
1010 }
1011 return jTextField;
1012 }
1013 /**
1014 * This method initializes jTextField1
1015 *
1016 * @return javax.swing.JTextField
1017 */
1018 private JTextField getJTextField1() {
1019 if (jTextField1 == null) {
1020 jTextField1 = new JTextField();
1021 jTextField1.setPreferredSize(new java.awt.Dimension(100,20));
1022 }
1023 return jTextField1;
1024 }
1025 /**
1026 * This method initializes jTextField2
1027 *
1028 * @return javax.swing.JTextField
1029 */
1030 private JTextField getJTextField2() {
1031 if (jTextField2 == null) {
1032 jTextField2 = new JTextField();
1033 jTextField2.setPreferredSize(new java.awt.Dimension(100,20));
1034 }
1035 return jTextField2;
1036 }
1037 /**
1038 * This method initializes jScrollPane6
1039 *
1040 * @return javax.swing.JScrollPane
1041 */
1042 private JScrollPane getJScrollPane6() {
1043 if (jScrollPane6 == null) {
1044 jScrollPane6 = new JScrollPane();
1045 jScrollPane6.setPreferredSize(new java.awt.Dimension(600,200));
1046 jScrollPane6.setViewportView(getJTable4());
1047 }
1048 return jScrollPane6;
1049 }
1050 /**
1051 * This method initializes jTable4
1052 *
1053 * @return javax.swing.JTable
1054 */
1055 private JTable getJTable4() {
1056 if (jTable4 == null) {
1057 jTable4 = new JTable();
1058 }
1059 return jTable4;
1060 }
1061
1062 } // @jve:decl-index=0:visual-constraint="10,10"
1063
1064 class PartialEditableTableModel extends DefaultTableModel {
1065 /**
1066 *
1067 */
1068 private static final long serialVersionUID = 1L;
1069
1070 public boolean isCellEditable(int row, int col) {
1071 switch (col){
1072 case 2:
1073 return true;
1074 default:
1075 return false;
1076 }
1077
1078 }
1079 }
1080
1081 class LibraryTableModel extends DefaultTableModel {
1082 /**
1083 *
1084 */
1085 private static final long serialVersionUID = 1L;
1086
1087 public boolean isCellEditable(int row, int col) {
1088 return false;
1089 }
1090 }