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