summaryrefslogtreecommitdiff
path: root/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/packaging/ui/SpdPackageDefinitions.java
blob: 39313818884d310b69907dea5b99bc9af1428d9b (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
/** @file
 
 The file is used to create, update Package Definitions 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 javax.swing.JPanel;
import javax.swing.JLabel;
import javax.swing.JComboBox;
import java.awt.Dimension;

import org.tianocore.PackageSurfaceAreaDocument;
import org.tianocore.frameworkwizard.common.Identifications.OpeningPackageType;
import org.tianocore.frameworkwizard.common.ui.IInternalFrame;
import org.tianocore.frameworkwizard.common.ui.StarLabel;

public class SpdPackageDefinitions extends IInternalFrame {

    /**
     * 
     */
    private static final long serialVersionUID = 1L;
    private JPanel jContentPane = null;
    private JLabel jLabelRdOnly = null;
    private JComboBox jComboBoxReadOnly = null;
    private JLabel jLabelRePkg = null;
    private JComboBox jComboBoxRePackage = null;
    private StarLabel starLabel = null;
    private StarLabel starLabel1 = null;
    private SpdFileContents sfc = null;
    private OpeningPackageType docConsole = null;

    /**
     * This is the default constructor
     */
    public SpdPackageDefinitions() {
        super();
        initialize();
    }
    
    public SpdPackageDefinitions(PackageSurfaceAreaDocument.PackageSurfaceArea inPsa){
        this();
        sfc = new SpdFileContents(inPsa);
        init(sfc);
    }
    
    public SpdPackageDefinitions(OpeningPackageType opt) {
        this(opt.getXmlSpd());
        docConsole = opt;
    }

    private void init(SpdFileContents sfc) {
        if (sfc.getSpdPkgDefsRdOnly() != null) {
            jComboBoxReadOnly.setSelectedItem(sfc.getSpdPkgDefsRdOnly());
        }
        if (sfc.getSpdPkgDefsRePkg() != null) {
            jComboBoxRePackage.setSelectedItem(sfc.getSpdPkgDefsRePkg());
        }
        this.setVisible(true);
    }
    /**
     * This method initializes this
     * 
     * @return void
     */
    private void initialize() {
        this.setSize(300, 200);
        this.setTitle("Package Definitions");
        this.setContentPane(getJContentPane());
    }

    /**
     * This method initializes jContentPane
     * 
     * @return javax.swing.JPanel
     */
    private JPanel getJContentPane() {
        if (jContentPane == null) {
            starLabel1 = new StarLabel();
            starLabel1.setBounds(new java.awt.Rectangle(4,62,10,20));
            starLabel1.setVisible(true);
            starLabel = new StarLabel();
            starLabel.setBounds(new java.awt.Rectangle(4,22,10,20));
            jLabelRePkg = new JLabel();
            jLabelRePkg.setPreferredSize(new java.awt.Dimension(65,20));
            jLabelRePkg.setLocation(new java.awt.Point(22,62));
            jLabelRePkg.setSize(new java.awt.Dimension(65,20));
            jLabelRePkg.setText("RePackage");
            jLabelRdOnly = new JLabel();
            jLabelRdOnly.setPreferredSize(new java.awt.Dimension(57,20));
            jLabelRdOnly.setLocation(new java.awt.Point(22,22));
            jLabelRdOnly.setSize(new java.awt.Dimension(57,20));
            jLabelRdOnly.setText("Read Only");
            jContentPane = new JPanel();
            jContentPane.setLayout(null);
            jContentPane.add(jLabelRdOnly, null);
            jContentPane.add(getJComboBox(), null);
            jContentPane.add(jLabelRePkg, null);
            jContentPane.add(getJComboBox1(), null);
            jContentPane.add(starLabel, null);
            jContentPane.add(starLabel1, null);
        }
        return jContentPane;
    }

    /**
     * This method initializes jComboBox	
     * 	
     * @return javax.swing.JComboBox	
     */
    private JComboBox getJComboBox() {
        if (jComboBoxReadOnly == null) {
            jComboBoxReadOnly = new JComboBox();
            jComboBoxReadOnly.setBounds(new java.awt.Rectangle(95,22,117,20));
            jComboBoxReadOnly.setPreferredSize(new Dimension(80, 20));
            jComboBoxReadOnly.addItem("true");
            jComboBoxReadOnly.addItem("false");
            jComboBoxReadOnly.setSelectedIndex(1);
            jComboBoxReadOnly.addItemListener(new java.awt.event.ItemListener() {
                public void itemStateChanged(java.awt.event.ItemEvent e) {
                    if (jComboBoxReadOnly.getSelectedItem().equals(sfc.getSpdPkgDefsRdOnly())) {
                        return;
                    }
                    if (docConsole != null) {
                        docConsole.setSaved(false);
                    }
                    sfc.setSpdPkgDefsRdOnly(jComboBoxReadOnly.getSelectedItem()+"");
                }
            });
        }
        return jComboBoxReadOnly;
    }

    /**
     * This method initializes jComboBox1	
     * 	
     * @return javax.swing.JComboBox	
     */
    private JComboBox getJComboBox1() {
        if (jComboBoxRePackage == null) {
            jComboBoxRePackage = new JComboBox();
            jComboBoxRePackage.setBounds(new java.awt.Rectangle(95,62,116,20));
            jComboBoxRePackage.setPreferredSize(new Dimension(80, 20));
            jComboBoxRePackage.addItem("false");
            jComboBoxRePackage.addItem("true");
            jComboBoxRePackage.setSelectedIndex(0);
            jComboBoxRePackage.addItemListener(new java.awt.event.ItemListener() {
                public void itemStateChanged(java.awt.event.ItemEvent e) {
                    if (jComboBoxRePackage.getSelectedItem().equals(sfc.getSpdPkgDefsRePkg())) {
                        return;
                    }
                    if (docConsole != null) {
                        docConsole.setSaved(false);
                    }
                    sfc.setSpdPkgDefsRePkg(jComboBoxRePackage.getSelectedItem()+"");
                }
            });
        }
        return jComboBoxRePackage;
    }

}