3d29cf6d9d4e740209757862c7efed3083233fa6
[mirror_edk2.git] / Tools / Source / FrameworkWizard / src / org / tianocore / frameworkwizard / packaging / ui / SpdPackageDefinitions.java
1 /** @file
2
3 The file is used to create, update Package Definitions of Spd file
4
5 Copyright (c) 2006, Intel Corporation
6 All rights reserved. This program and the accompanying materials
7 are licensed and made available under the terms and conditions of the BSD License
8 which accompanies this distribution. The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php
10
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
13
14 **/
15 package org.tianocore.frameworkwizard.packaging.ui;
16
17 import javax.swing.JPanel;
18 import javax.swing.JLabel;
19 import javax.swing.JComboBox;
20 import java.awt.Dimension;
21
22 import org.tianocore.PackageSurfaceAreaDocument;
23 import org.tianocore.frameworkwizard.common.Identifications.OpeningPackageType;
24 import org.tianocore.frameworkwizard.common.ui.IInternalFrame;
25 import org.tianocore.frameworkwizard.common.ui.StarLabel;
26
27 public class SpdPackageDefinitions extends IInternalFrame {
28
29 /**
30 *
31 */
32 private static final long serialVersionUID = 1L;
33 private JPanel jContentPane = null;
34 private JLabel jLabel = null;
35 private JComboBox jComboBoxReadOnly = null;
36 private JLabel jLabel1 = null;
37 private JComboBox jComboBoxRePackage = null;
38 private StarLabel starLabel = null;
39 private StarLabel starLabel1 = null;
40 private SpdFileContents sfc = null;
41 private OpeningPackageType docConsole = null;
42
43 /**
44 * This is the default constructor
45 */
46 public SpdPackageDefinitions() {
47 super();
48 initialize();
49 }
50
51 public SpdPackageDefinitions(PackageSurfaceAreaDocument.PackageSurfaceArea inPsa){
52 this();
53 sfc = new SpdFileContents(inPsa);
54 init(sfc);
55 }
56
57 public SpdPackageDefinitions(OpeningPackageType opt) {
58 this(opt.getXmlSpd());
59 docConsole = opt;
60 }
61
62 private void init(SpdFileContents sfc) {
63 if (sfc.getSpdPkgDefsRdOnly() != null) {
64 jComboBoxReadOnly.setSelectedItem(sfc.getSpdPkgDefsRdOnly());
65 }
66 if (sfc.getSpdPkgDefsRePkg() != null) {
67 jComboBoxRePackage.setSelectedItem(sfc.getSpdPkgDefsRePkg());
68 }
69 this.setVisible(true);
70 }
71 /**
72 * This method initializes this
73 *
74 * @return void
75 */
76 private void initialize() {
77 this.setSize(300, 200);
78 this.setTitle("Package Definitions");
79 this.setContentPane(getJContentPane());
80 }
81
82 /**
83 * This method initializes jContentPane
84 *
85 * @return javax.swing.JPanel
86 */
87 private JPanel getJContentPane() {
88 if (jContentPane == null) {
89 starLabel1 = new StarLabel();
90 starLabel1.setBounds(new java.awt.Rectangle(4,62,10,20));
91 starLabel1.setVisible(true);
92 starLabel = new StarLabel();
93 starLabel.setBounds(new java.awt.Rectangle(4,22,10,20));
94 jLabel1 = new JLabel();
95 jLabel1.setPreferredSize(new java.awt.Dimension(65,20));
96 jLabel1.setLocation(new java.awt.Point(22,62));
97 jLabel1.setSize(new java.awt.Dimension(65,20));
98 jLabel1.setText("RePackage");
99 jLabel = new JLabel();
100 jLabel.setPreferredSize(new java.awt.Dimension(57,20));
101 jLabel.setLocation(new java.awt.Point(22,22));
102 jLabel.setSize(new java.awt.Dimension(57,20));
103 jLabel.setText("Read Only");
104 jContentPane = new JPanel();
105 jContentPane.setLayout(null);
106 jContentPane.add(jLabel, null);
107 jContentPane.add(getJComboBox(), null);
108 jContentPane.add(jLabel1, null);
109 jContentPane.add(getJComboBox1(), null);
110 jContentPane.add(starLabel, null);
111 jContentPane.add(starLabel1, null);
112 }
113 return jContentPane;
114 }
115
116 /**
117 * This method initializes jComboBox
118 *
119 * @return javax.swing.JComboBox
120 */
121 private JComboBox getJComboBox() {
122 if (jComboBoxReadOnly == null) {
123 jComboBoxReadOnly = new JComboBox();
124 jComboBoxReadOnly.setBounds(new java.awt.Rectangle(95,22,117,20));
125 jComboBoxReadOnly.setPreferredSize(new Dimension(80, 20));
126 jComboBoxReadOnly.addItem("true");
127 jComboBoxReadOnly.addItem("false");
128 jComboBoxReadOnly.setSelectedIndex(1);
129 jComboBoxReadOnly.addItemListener(new java.awt.event.ItemListener() {
130 public void itemStateChanged(java.awt.event.ItemEvent e) {
131 if (docConsole != null) {
132 docConsole.setSaved(false);
133 }
134 sfc.setSpdPkgDefsRdOnly(jComboBoxReadOnly.getSelectedItem()+"");
135 }
136 });
137 }
138 return jComboBoxReadOnly;
139 }
140
141 /**
142 * This method initializes jComboBox1
143 *
144 * @return javax.swing.JComboBox
145 */
146 private JComboBox getJComboBox1() {
147 if (jComboBoxRePackage == null) {
148 jComboBoxRePackage = new JComboBox();
149 jComboBoxRePackage.setBounds(new java.awt.Rectangle(95,62,116,20));
150 jComboBoxRePackage.setPreferredSize(new Dimension(80, 20));
151 jComboBoxRePackage.addItem("false");
152 jComboBoxRePackage.addItem("true");
153 jComboBoxRePackage.setSelectedIndex(0);
154 jComboBoxRePackage.addItemListener(new java.awt.event.ItemListener() {
155 public void itemStateChanged(java.awt.event.ItemEvent e) {
156 if (docConsole != null) {
157 docConsole.setSaved(false);
158 }
159 sfc.setSpdPkgDefsRePkg(jComboBoxRePackage.getSelectedItem()+"");
160 }
161 });
162 }
163 return jComboBoxRePackage;
164 }
165
166 }