summaryrefslogtreecommitdiff
path: root/Tools/Java/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/packaging/ui/SpdLibClassDecls.java
blob: 9aac2464c94d8f23b38f5055679d12de32110e8c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
/** @file
  Java class SpdLibClassDecls is GUI for create library definition elements of spd file.
 
Copyright (c) 2006, Intel Corporation
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution.  The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php

THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
package org.tianocore.frameworkwizard.packaging.ui;

import java.awt.Dimension;
import java.awt.FontMetrics;
import java.awt.event.ActionEvent;
import java.awt.event.ComponentEvent;
import java.io.File;
import java.util.HashMap;
//import java.util.Iterator;
//import java.util.Set;
import java.util.Vector;

import javax.swing.AbstractAction;
import javax.swing.JFileChooser;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.JTextArea;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JScrollPane;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.ListSelectionModel;
import javax.swing.event.InternalFrameAdapter;
import javax.swing.event.InternalFrameEvent;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import javax.swing.event.TableModelEvent;
import javax.swing.event.TableModelListener;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableColumn;
import javax.swing.table.TableModel;
import org.tianocore.PackageSurfaceAreaDocument;
import org.tianocore.frameworkwizard.common.DataType;
import org.tianocore.frameworkwizard.common.DataValidation;
//import org.tianocore.frameworkwizard.common.GlobalData;
import org.tianocore.frameworkwizard.common.Tools;
import org.tianocore.frameworkwizard.common.Identifications.OpeningPackageType;
import org.tianocore.frameworkwizard.common.ui.IInternalFrame;
import org.tianocore.frameworkwizard.common.ui.StarLabel;
import org.tianocore.frameworkwizard.common.ui.iCheckBoxList.ICheckBoxList;
import org.tianocore.frameworkwizard.platform.ui.ListEditor;
import org.tianocore.frameworkwizard.platform.ui.LongTextEditor;
//import org.tianocore.frameworkwizard.platform.ui.global.SurfaceAreaQuery;
//import org.tianocore.frameworkwizard.module.Identifications.ModuleIdentification;


/**
 GUI for create library definition elements of spd file.
  
 @since PackageEditor 1.0
**/
public class SpdLibClassDecls extends IInternalFrame implements TableModelListener{
    /**
     * 
     */
    private static final long serialVersionUID = 1L;

    private JFrame topFrame;
    
    private JTable jTable = null;

    private DefaultTableModel model = null;

    private JPanel jContentPane = null;

    private JTextField jTextFieldAddClass = null;

    private JComboBox jComboBoxSelect = null;

    private JScrollPane jScrollPaneTable = null;

    private JButton jButtonAdd = null;

    private JButton jButtonRemove = null;

    private JButton jButtonRemoveAll = null;

    private JLabel jLabelHdr = null;

    private JTextField jTextFieldHdr = null;

    private JButton jButtonBrowse = null;
    
    private StarLabel starLabel1 = null;
    
    private StarLabel starLabel3 = null;
    
    private SpdFileContents sfc = null;
    
    private OpeningPackageType docConsole = null;

    private JLabel jLabel1ClassName = null;
    
    private JScrollPane topScrollPane = null;  //  @jve:decl-index=0:visual-constraint="10,53"
    
    private int selectedRow = -1;

    private StarLabel starLabel2 = null;

    private JLabel jLabel2HelpText = null;

    private JTextArea jTextAreaHelp = null;

    private JScrollPane jHelpTextScrollPane = null;

    private JLabel jLabel5SupArchList = null;

    private JLabel jLabel6SupModList = null;
    
    private JScrollPane jScrollPaneModules = null;
    
    private JScrollPane jScrollPane1Arch = null;
    
    private ICheckBoxList iCheckBoxListModules = null;

    private ICheckBoxList iCheckBoxListArch = null;

    private int cnClassName = 0;
    private int cnHdrFile = 1;
    private int cnHelpText = 2;
//    private int cnRecInstName = 3;
//    private int cnRecInstVer = 4;
    private int cnSupArch = 5;
    private int cnSupMod = 6;
    
    private final int classNameMinWidth = 200;
    private final int hdrFileMinWidth = 300;
    private final int helpTextMinWidth = 300;
    private final int supArchMinWidth = 200;
    private final int supModMinWidth = 200;

    private final int shortLabel = 90;
    private final int longLabel = 220;
    private final int labelCol = 12;
    private final int shortValueCol = labelCol + shortLabel + 6;
    private final int longValueCol = labelCol + longLabel + 6;
    private final int longValueWidth = 347;
    private final int shortWidth = 140;
    private final int medWidth = 240;
   
    private final int buttonWidth = 99;

    private final int addButtonCol = shortValueCol + 10;
    private final int removeButtonCol = addButtonCol + buttonWidth + 10;
    private final int removeAllButtonCol = removeButtonCol + buttonWidth + 10;

    private final int rowOne = 12;
    private final int rowTwo = rowOne + 25;
    private final int rowThree = rowTwo + 60 + 25;
    private final int rowFour = rowThree + 25;
    private final int rowFive = rowFour + 40 + 25;
    private final int rowSix = rowFive + 40 + 25;
    private final int rowSeven = rowSix;
    private final int rowEight = rowSeven + 30;

    HashMap<String, String> libNameGuidMap = new HashMap<String, String>();


    /**
      This method initializes this
     
     **/
    private void initialize() {
        
        this.setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);

    }

    /**
      This method initializes jTextFieldAddClass	
      	
      @return javax.swing.JTextField	
     **/
    private JTextField getJTextFieldAddClass() {
        if (jTextFieldAddClass == null) {
            jTextFieldAddClass = new JTextField();
            jTextFieldAddClass.setBounds(new java.awt.Rectangle(shortValueCol,rowOne,longValueWidth,20));
            jTextFieldAddClass.setPreferredSize(new java.awt.Dimension(longValueWidth,20));
            jTextFieldAddClass.setEnabled(true);
        }
        return jTextFieldAddClass;
    }

    /**
      This method initializes jComboBoxSelect	
      	
      @return javax.swing.JComboBox	
     **/
    private JComboBox getJComboBoxSelect() {
        if (jComboBoxSelect == null) {
            jComboBoxSelect = new JComboBox();
            jComboBoxSelect.setBounds(new java.awt.Rectangle(220, 10, 260, 20));
            jComboBoxSelect.setPreferredSize(new java.awt.Dimension(260,22));
            jComboBoxSelect.setEnabled(true);
            jComboBoxSelect.setVisible(false);
        }
        return jComboBoxSelect;
    }

    /**
      This method initializes jScrollPaneTable	
      	
      @return javax.swing.JScrollPane	

      Used for the Table of Library Classes that are provided by this package

     **/
    private JScrollPane getJScrollPaneTable() {
        if (jScrollPaneTable == null) {
            jScrollPaneTable = new JScrollPane();
            jScrollPaneTable.setBounds(new java.awt.Rectangle(labelCol,rowEight,400,253));
            jScrollPaneTable.setViewportView(getJTable());
        }
        return jScrollPaneTable;
    }

    /**
    This method initializes jTable  
        
    @return javax.swing.JTable  
    **/
   private JTable getJTable() {
       if (jTable == null) {
           model = new DefaultTableModel();
           jTable = new JTable(model);
           jTable.setRowHeight(20);
           jTable.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_OFF);
           jTable.setColumnSelectionAllowed(false);
           model.addColumn("Class Name");
           model.addColumn("Header");
           model.addColumn("Help Text");
           model.addColumn("Recommended Instance");
           model.addColumn("Version");
           model.addColumn("Supported Architectures");
           model.addColumn("Supported Module Types");
           
           jTable.getColumnModel().getColumn(cnHelpText).setCellEditor(new LongTextEditor(topFrame));
           
           jTable.removeColumn(jTable.getColumnModel().getColumn(3));
           jTable.removeColumn(jTable.getColumnModel().getColumn(3));
           
           Vector<String> vArch = new Vector<String>();
           vArch.add("IA32");
           vArch.add("X64");
           vArch.add("IPF");
           vArch.add("EBC");
           vArch.add("ARM");
           vArch.add("PPC");
           jTable.getColumnModel().getColumn(cnSupArch - 2).setCellEditor(new ListEditor(vArch, topFrame));
           
           Vector<String> vModule = new Vector<String>();
           vModule.add("BASE");
           vModule.add("SEC");
           vModule.add("PEI_CORE");
           vModule.add("PEIM");
           vModule.add("DXE_CORE");
           vModule.add("DXE_DRIVER");
           vModule.add("DXE_RUNTIME_DRIVER");
           vModule.add("DXE_SAL_DRIVER");
           vModule.add("DXE_SMM_DRIVER");
           vModule.add("UEFI_DRIVER");
           vModule.add("UEFI_APPLICATION");
           vModule.add("USER_DEFINED");

           jTable.getColumnModel().getColumn(cnSupMod - 2).setCellEditor(new ListEditor(vModule, topFrame));
           
           TableColumn column = jTable.getColumnModel().getColumn(this.cnClassName);
           column.setMinWidth(this.classNameMinWidth);
           column = jTable.getColumnModel().getColumn(this.cnHdrFile);
           column.setMinWidth(this.hdrFileMinWidth);
           column = jTable.getColumnModel().getColumn(this.cnHelpText);
           column.setMinWidth(this.helpTextMinWidth);
           column = jTable.getColumnModel().getColumn(this.cnSupArch - 2);
           column.setMinWidth(this.supArchMinWidth);
           column = jTable.getColumnModel().getColumn(this.cnSupMod - 2);
           column.setMinWidth(this.supModMinWidth);
           
           jTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
           jTable.getSelectionModel().addListSelectionListener(new ListSelectionListener(){
               public void valueChanged(ListSelectionEvent e) {
                   if (e.getValueIsAdjusting()){
                       return;
                   }
                   ListSelectionModel lsm = (ListSelectionModel)e.getSource();
                   if (lsm.isSelectionEmpty()) {
                       return;
                   }
                   else{
                       selectedRow = lsm.getMinSelectionIndex();
                   }
               }
           });
           
           jTable.getModel().addTableModelListener(this);

       }
       return jTable;
   }
   
   
    public void tableChanged(TableModelEvent arg0) {
        // TODO Auto-generated method stub
        int row = arg0.getFirstRow();
        int column = arg0.getColumn();
        TableModel m = (TableModel)arg0.getSource();
        if (arg0.getType() == TableModelEvent.UPDATE){
            
            String lib = m.getValueAt(row, cnClassName) + "";
            String hdr = m.getValueAt(row, cnHdrFile) + "";
            String hlp = m.getValueAt(row, cnHelpText) + "";
            String name = null;
//            if (m.getValueAt(row, cnRecInstName) != null) {
//                name = m.getValueAt(row, cnRecInstName).toString();
//            } 
//            String ver = null;
//            if (m.getValueAt(row, cnRecInstVer) != null){
//                ver = m.getValueAt(row, cnRecInstVer).toString();
//            }
            String arch = null;
            if (m.getValueAt(row, cnSupArch) != null) {
               arch = m.getValueAt(row, cnSupArch).toString();
            }
            String module = null;
            if (m.getValueAt(row, cnSupMod) != null) {
                module = m.getValueAt(row, cnSupMod).toString();
            }
            String[] rowData = {lib, hdr, hlp, name};
            if (!dataValidation(rowData)) {
                return;
            }
            
            String guid = null;
//            if (name != null && name.length() > 0) {
//                getLibInstances(lib);
//                guid = nameToGuid(name);
//                if (guid == null){
//                  JOptionPane.showMessageDialog(frame, "Recommended Instance does not exist.");
//                  return;
//                }
//            }
            
            String[] sa = new String[7];
            sfc.getSpdLibClassDeclaration(sa, row);
            Object cellData = m.getValueAt(row, column);
            if (cellData == null) {
                cellData = "";
            }
//            if (column == cnRecInstName) {
//                if (guid == null) {
//                    if (sa[cnRecInstName] == null) {
//                        return;
//                    }
//                }
//                else {
//                    if (guid.equals(sa[cnRecInstName])) {
//                        return;
//                    }
//                }
//            }
            if (cellData.equals(sa[column])) {
                return;
            }
            if (cellData.toString().length() == 0 && sa[column] == null) {
                return;
            }
            docConsole.setSaved(false);
            sfc.updateSpdLibClass(row, lib, hdr, hlp, guid, null, arch, module);
        }
    }

    /**
      This method initializes jButtonAdd	
      	
      @return javax.swing.JButton	
     **/
    private JButton getJButtonAdd() {
        if (jButtonAdd == null) {
            jButtonAdd = new JButton();
            jButtonAdd.setText("Add");
            jButtonAdd.setSize(new java.awt.Dimension(buttonWidth,20));
            jButtonAdd.setBounds(new java.awt.Rectangle(addButtonCol,rowSeven,buttonWidth,20));
            jButtonAdd.addActionListener(this);
        }
        return jButtonAdd;
    }

    /**
      This method initializes jButtonRemove	
      	
      @return javax.swing.JButton	
     **/
    private JButton getJButtonRemove() {
        if (jButtonRemove == null) {
            jButtonRemove = new JButton();
            jButtonRemove.setText("Delete");
            jButtonRemove.setSize(new java.awt.Dimension(buttonWidth,20));
            jButtonRemove.setBounds(new java.awt.Rectangle(removeButtonCol,rowSeven,buttonWidth,20));
            jButtonRemove.addActionListener(this);
        }
        return jButtonRemove;
    }

    /**
      This method initializes jButtonRemoveAll	
      	
      @return javax.swing.JButton	
     **/
    private JButton getJButtonRemoveAll() {
        if (jButtonRemoveAll == null) {
            jButtonRemoveAll = new JButton();
            jButtonRemoveAll.setText("Clear All");
            jButtonRemoveAll.setLocation(removeAllButtonCol,rowSeven);
            FontMetrics fm = jButtonRemoveAll.getFontMetrics(jButtonRemoveAll.getFont());
            jButtonRemoveAll.setSize(fm.stringWidth(jButtonRemoveAll.getText()) + 50, 20);
            jButtonRemoveAll.addActionListener(this);
        }
        return jButtonRemoveAll;
    }

    /**
      This is the default constructor
     **/
    public SpdLibClassDecls(JFrame frame) {
        super();
        topFrame = frame;
        initialize();
        init();
        
    }

    public SpdLibClassDecls(PackageSurfaceAreaDocument.PackageSurfaceArea inPsa, JFrame frame){
        this(frame);
        sfc = new SpdFileContents(inPsa);
        init(sfc);
    }
    
    public SpdLibClassDecls(OpeningPackageType opt, JFrame frame) {
        this(opt.getXmlSpd(), frame);
        docConsole = opt;
    }
    /**
      This method initializes this
      
      @return void
     **/
    private void init() {
        
        this.setContentPane(getJContentPane());
        this.setTitle("Library Class Declarations");
        this.setBounds(new java.awt.Rectangle(0, 0, 500, 370));
        this.setVisible(true);
        this.addInternalFrameListener(new InternalFrameAdapter(){
            public void internalFrameDeactivated(InternalFrameEvent e){
                if (jTable.isEditing()) {
                    jTable.getCellEditor().stopCellEditing();
                }
            }
        });
    }

    private void init(SpdFileContents sfc) {

        if (sfc.getSpdPkgDefsRdOnly().equals("true")) {
            JOptionPane.showMessageDialog(topFrame, "This is a read-only package. You will not be able to edit contents in table.");
        }
        initFrame();
        
        if (sfc.getSpdLibClassDeclarationCount() == 0) {
            return ;
        }
        //
        // initialize table using SpdFileContents object
        //
        String[][] saa = new String[sfc.getSpdLibClassDeclarationCount()][7];
        sfc.getSpdLibClassDeclarations(saa);
        int i = 0;
        while (i < saa.length) {
//            if (saa[i][3] != null && saa[i][3].length() > 0) {
//                getLibInstances(saa[i][0]);
//                saa[i][3] = guidToName(saa[i][3]);
//            }
            
            model.addRow(saa[i]);
            i++;
        }
        
    }
    
    private void initFrame() {
        boolean editable = true;
        if (sfc.getSpdPkgDefsRdOnly().equals("true")) {
            editable = false;
        }
        
        jButtonAdd.setEnabled(editable);
        jButtonRemove.setEnabled(editable);
        jButtonRemoveAll.setEnabled(editable);
        jTable.setEnabled(editable);
    }

    private JScrollPane getJContentPane(){
        if (topScrollPane == null){
          topScrollPane = new JScrollPane();
          topScrollPane.setViewportView(getJContentPane1());
        }
        return topScrollPane;
    }
    /**
      This method initializes jContentPane
      
      @return javax.swing.JPanel
     **/
    private JPanel getJContentPane1() {
        if (jContentPane == null) {
            // Library Class
            starLabel1 = new StarLabel();
            starLabel1.setLocation(new java.awt.Point(1,rowOne));
            jLabel1ClassName = new JLabel();
            jLabel1ClassName.setBounds(new java.awt.Rectangle(labelCol,rowOne,shortLabel,20));
            jLabel1ClassName.setText("Library Class");

            // Help Text
            starLabel2 = new StarLabel();
            starLabel2.setBounds(new java.awt.Rectangle(1,rowTwo,10,20));
            jLabel2HelpText = new JLabel();
            jLabel2HelpText.setBounds(new java.awt.Rectangle(labelCol,rowTwo,shortLabel,20));
            jLabel2HelpText.setText("Help Text");

            // Header File
            starLabel3 = new StarLabel();
            starLabel3.setLocation(new java.awt.Point(1,rowThree));
            jLabelHdr = new JLabel();
            jLabelHdr.setBounds(new java.awt.Rectangle(labelCol,rowThree,longLabel,20));
            jLabelHdr.setText("Include Header for Specified Class");

            jLabel6SupModList = new JLabel();
            jLabel6SupModList.setBounds(new java.awt.Rectangle(labelCol,rowFive,longLabel,20));
            jLabel6SupModList.setText("Supported Module Types");
            jLabel6SupModList.setEnabled(true);

            jLabel5SupArchList = new JLabel();
            jLabel5SupArchList.setBounds(new java.awt.Rectangle(labelCol,rowFour,longLabel,20));
            jLabel5SupArchList.setText("Supported Architectures");
            jLabel5SupArchList.setEnabled(true);

            jContentPane = new JPanel();
            jContentPane.setPreferredSize(new Dimension(680, 600));
            jContentPane.setLayout(null);
            jContentPane.add(jLabelHdr, null);
            jContentPane.add(starLabel1, null);
            jContentPane.add(starLabel3, null);
            jContentPane.add(getJTextFieldAddClass(), null);
            jContentPane.add(getJComboBoxSelect(), null);
            jContentPane.add(getJScrollPaneTable(), null);
            jContentPane.add(getJButtonAdd(), null);
            jContentPane.add(getJButtonRemove(), null);
            jContentPane.add(getJButtonRemoveAll(), null);
            
            jContentPane.add(getJTextFieldHdr(), null);
            jContentPane.add(getJButtonBrowse(), null);
            jContentPane.add(jLabel1ClassName, null);
            jContentPane.add(starLabel2, null);
            jContentPane.add(jLabel2HelpText, null);
            jContentPane.add(getJHelpTextScrollPane(), null);

            jContentPane.add(jLabel5SupArchList, null);
            jContentPane.add(jLabel6SupModList, null);
            
            jContentPane.add(getJScrollPaneModules(), null);
            jContentPane.add(getJScrollPane1Arch(), null);
            
        }
        
        return jContentPane;
    }


    /* (non-Javadoc)
     * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
     */
    public void actionPerformed(ActionEvent arg0) {
        
        if (arg0.getSource() == jButtonAdd) {
            
            //ToDo: check before add
            // LAH WAS String[] row = {null, null, null, jComboBox.getSelectedItem()+"", jTextField2RecInstVer.getText(), null, null};
            String[] row = {null, null, null, null, null, null, null};
            row[cnClassName] = jTextFieldAddClass.getText();
            row[cnHdrFile] = jTextFieldHdr.getText().replace('\\', '/');
            row[cnHelpText] = jTextAreaHelp.getText();
//            row[cnRecInstName] = jComboBox.getSelectedItem()+"";
//            row[cnRecInstVer] = jTextField2RecInstVer.getText();
            row[cnSupArch] = vectorToString(iCheckBoxListArch.getAllCheckedItemsString());
            if (row[cnSupArch].length() == 0) {
                row[cnSupArch] = null;
            }
            row[cnSupMod] = vectorToString(iCheckBoxListModules.getAllCheckedItemsString());
            if (row[cnSupMod].length() == 0){
                row[cnSupMod] = null;
            }
            if (!dataValidation(row)) {
                return;
            }
            //
            //convert to GUID before storing recommended lib instance.
            //
//            getLibInstances(row[cnClassName]);
//            String recommendGuid = nameToGuid(row[cnRecInstName]);
//            if (row[cnRecInstName].equals("null")) {
//                row[cnRecInstName] = null;
//            }
//            else{
//                if (recommendGuid == null) {
//                  JOptionPane.showMessageDialog(frame, "Recommended Instance does not exist.");
//                  return;
//                }
//            }

            sfc.genSpdLibClassDeclarations(row[cnClassName], null, row[cnHdrFile], row[cnHelpText], row[cnSupArch], null, null, null, null, row[cnSupMod]);
            model.addRow(row);
            jTable.changeSelection(model.getRowCount()-1, 0, false, false);
            docConsole.setSaved(false);
        }
        //
        // remove selected line
        //
        if (arg0.getSource() == jButtonRemove) {
            if (jTable.isEditing()){
                jTable.getCellEditor().stopCellEditing();
            }
            int rowSelected = selectedRow;
            if (rowSelected >= 0) {
                model.removeRow(rowSelected);
                docConsole.setSaved(false);
                sfc.removeSpdLibClass(rowSelected);
            }
        }

        if (arg0.getSource() == jButtonRemoveAll) {
            if (model.getRowCount() == 0) {
                return;
            }
            docConsole.setSaved(false);
            model.setRowCount(0);
            sfc.removeSpdLibClass();
        }
    }

    private boolean dataValidation(String[] row) {
        if (!DataValidation.isKeywordType(row[cnClassName])) {
            JOptionPane.showMessageDialog(this, "Library Class name entered does not match KeyWord datatype.");
            return false;
        }
        if (!DataValidation.isPathAndFilename(row[cnHdrFile])) {
            JOptionPane.showMessageDialog(this, "Include Header does not match the PathAndFilename datatype.");
            return false;
        }
        if (row[cnHelpText].length() == 0) {
            JOptionPane.showMessageDialog(this, "Help Text must be entered!");
            return false;
        }
//        if (row[cnRecInstVer] != null && row[cnRecInstVer].length() > 0) {
//            if (row[cnRecInstName] == null || row[cnRecInstName].length() == 0) {
//                JOptionPane.showMessageDialog(frame, "Recommended Instance Version must associate with the Instance Name.");
//                return false;
//            }
//            
//            if (!DataValidation.isVersionDataType(row[cnRecInstVer])) {
//                JOptionPane.showMessageDialog(frame, "Recommended Instance Version does not match Version datatype.");
//                return false;
//            }
//        }
        return true;
    }
    /**
     Add contents in list to sfc
    **/
    protected void save() {
        
    }

    /**
      This method initializes jTextField	
      	
      @return javax.swing.JTextField	
     **/
    private JTextField getJTextFieldHdr() {
        if (jTextFieldHdr == null) {
            jTextFieldHdr = new JTextField();
            jTextFieldHdr.setPreferredSize(new java.awt.Dimension(shortWidth,20));
            jTextFieldHdr.setLocation(new java.awt.Point(longValueCol,rowThree));
            jTextFieldHdr.setSize(new java.awt.Dimension(shortWidth,20));
        }
        return jTextFieldHdr;
    }

    /**
      This method initializes jButtonBrowse	
      	
      @return javax.swing.JButton	
     **/
    private JButton getJButtonBrowse() {
        if (jButtonBrowse == null) {
            jButtonBrowse = new JButton();
            jButtonBrowse.setBounds(new java.awt.Rectangle(longValueCol + shortWidth + 7,rowThree,90,20));
            jButtonBrowse.setText("Browse");
            jButtonBrowse.setPreferredSize(new java.awt.Dimension(99,20));
            jButtonBrowse.addActionListener(new AbstractAction() {
                
                /**
                 * 
                 */
                private static final long serialVersionUID = 1L;

                public void actionPerformed(ActionEvent arg0) {
                    //
                    // Select files from current pkg
                    //
                    String dirPrefix = Tools.dirForNewSpd.substring(0, Tools.dirForNewSpd.lastIndexOf(File.separator));
                    JFileChooser chooser = new JFileChooser(dirPrefix);
                    File theFile = null;
                    String headerDest = null;
                    
                    chooser.setMultiSelectionEnabled(false);
                    chooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
                    int retval = chooser.showOpenDialog(topFrame);
                    if (retval == JFileChooser.APPROVE_OPTION) {

                        theFile = chooser.getSelectedFile();
                        String file = theFile.getPath();
                        if (!file.startsWith(dirPrefix)) {
                            JOptionPane.showMessageDialog(topFrame, "You can only select files in current package directory structure!");
                            return;
                        }
                        
                        
                    }
                    else {
                        return;
                    }
                    
                    headerDest = theFile.getPath();
                    int fileIndex = headerDest.indexOf(System.getProperty("file.separator"), dirPrefix.length());
                    jTextFieldHdr.setText(headerDest.substring(fileIndex + 1).replace('\\', '/'));
               
                }

            });
        }
        return jButtonBrowse;
    }
    
    public void componentResized(ComponentEvent arg0) {
        int intPreferredWidth = 500;
        
        Tools.resizeComponentWidth(this.jTextFieldAddClass, this.getWidth(), intPreferredWidth-28);
        Tools.resizeComponentWidth(this.jHelpTextScrollPane, this.getWidth(), intPreferredWidth-28);
        Tools.resizeComponentWidth(this.jScrollPaneTable, this.getWidth(), intPreferredWidth-10);
        Tools.resizeComponentWidth(this.jTextFieldHdr, this.getWidth(), intPreferredWidth - 7);
        Tools.relocateComponentX(this.jButtonBrowse, this.getWidth(), intPreferredWidth,
                                  DataType.SPACE_TO_RIGHT_FOR_GENERATE_BUTTON); 
    }

    /**
     * This method initializes jHelpTextScrollPane
     *
     * @return javax.swing.JScrollPane jHelpTextScrollPane
     */
    private JScrollPane getJHelpTextScrollPane() {
        if (jHelpTextScrollPane == null) {
            jHelpTextScrollPane = new JScrollPane();
            jHelpTextScrollPane.setHorizontalScrollBarPolicy(javax.swing.JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
            jHelpTextScrollPane.setPreferredSize(new java.awt.Dimension(longValueWidth, 80));
            jHelpTextScrollPane.setSize(new java.awt.Dimension(longValueWidth, 80));
            jHelpTextScrollPane.setLocation(new java.awt.Point(shortValueCol,rowTwo));
            jHelpTextScrollPane.setViewportView(getJTextAreaHelp());
        }
        return jHelpTextScrollPane;
    }

    /**
     * This method initializes jTextAreaHelp	
     * 	
     * @return javax.swing.JTextArea	
     */
    private JTextArea getJTextAreaHelp() {
        if (jTextAreaHelp == null) {
            jTextAreaHelp = new JTextArea();
            jTextAreaHelp.setLineWrap(true);
            jTextAreaHelp.setWrapStyleWord(true);
        }
        return jTextAreaHelp;
    }

    private JScrollPane getJScrollPaneModules() {
        if (jScrollPaneModules == null) {
            jScrollPaneModules = new JScrollPane();
            jScrollPaneModules.setBounds(new java.awt.Rectangle(longValueCol,rowFive,medWidth,60));
            jScrollPaneModules.setPreferredSize(new java.awt.Dimension(medWidth, 60));
            jScrollPaneModules.setViewportView(getICheckBoxListSupportedModules());
        }
        return jScrollPaneModules;
    }
    
    private ICheckBoxList getICheckBoxListSupportedModules() {
        if (iCheckBoxListModules == null) {
            iCheckBoxListModules = new ICheckBoxList();
            iCheckBoxListModules.setBounds(new java.awt.Rectangle(longValueCol,rowFour,medWidth,60));
            Vector<String> v = new Vector<String>();
            v.add("BASE");
            v.add("SEC");
            v.add("PEI_CORE");
            v.add("PEIM");
            v.add("DXE_CORE");
            v.add("DXE_DRIVER");
            v.add("DXE_RUNTIME_DRIVER");
            v.add("DXE_SAL_DRIVER");
            v.add("DXE_SMM_DRIVER");
            v.add("UEFI_DRIVER");
            v.add("UEFI_APPLICATION");
            v.add("USER_DEFINED");
            iCheckBoxListModules.setAllItems(v);
        }
        return iCheckBoxListModules;
    }
    
    private String vectorToString(Vector<String> v) {
        String s = " ";
        for (int i = 0; i < v.size(); ++i) {
            s += v.get(i);
            s += " ";
        }
        return s.trim();
    }
    
    private JScrollPane getJScrollPane1Arch() {
        if (jScrollPane1Arch == null) {
            jScrollPane1Arch = new JScrollPane();
            jScrollPane1Arch.setBounds(new java.awt.Rectangle(longValueCol,rowFour,medWidth,60));
            jScrollPane1Arch.setPreferredSize(new java.awt.Dimension(medWidth, 60));
            jScrollPane1Arch.setViewportView(getICheckBoxListArch());
        }
        return jScrollPane1Arch;
    }
    /**
     * This method initializes iCheckBoxList	
     * 	
     * @return org.tianocore.frameworkwizard.common.ui.iCheckBoxList.ICheckBoxList	
     */
    private ICheckBoxList getICheckBoxListArch() {
        if (iCheckBoxListArch == null) {
            iCheckBoxListArch = new ICheckBoxList();
            iCheckBoxListArch.setBounds(new java.awt.Rectangle(longValueCol,rowFour,medWidth,60));
            Vector<String> v = new Vector<String>();
            v.add("IA32");
            v.add("X64");
            v.add("IPF");
            v.add("EBC");
            v.add("ARM");
            v.add("PPC");
            iCheckBoxListArch.setAllItems(v);
        }
        return iCheckBoxListArch;
    }

//    private void getLibInstances(String libClass){
//        libNameGuidMap.clear();
//        try {
//                Iterator ismi = GlobalData.vModuleList.iterator();
//                while (ismi.hasNext()) {
//                    ModuleIdentification mi = (ModuleIdentification) ismi.next();
//                    
//                    Vector<String> classProduced = SurfaceAreaQuery.getLibraryClasses("ALWAYS_PRODUCED", mi);
//                    for (int i = 0; i < classProduced.size(); ++i) {
//                        if (classProduced.get(i).equals(libClass)) {
//                            libNameGuidMap.put(mi.getName(), mi.getGuid());
//                        }
//                    }
//                }
//           
//        }
//        catch(Exception e){
//            JOptionPane.showMessageDialog(frame, "Search Instances Failed.");
//        }
//        
//    }

//    private String nameToGuid(String name) {
//        String s = null;
//        if (!libNameGuidMap.containsKey(name)) {
//            return s;
//        }
//        
//        s = libNameGuidMap.get(name);
//        return s;
//    }
    
//    private String guidToName(String guid){
//        String s = "";
//        if (!libNameGuidMap.containsValue(guid)) {
//            return s;
//        }
//        Set<String> key = libNameGuidMap.keySet();
//        Iterator<String> is = key.iterator();
//        while(is.hasNext()) {
//            s = is.next();
//            if (libNameGuidMap.get(s).equals(guid)) {
//                break;
//            }
//        }
//        return s;
//    }

}