]> git.proxmox.com Git - mirror_edk2.git/blob - Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/packaging/ui/SpdPackageDefinitions.java
Add Data Validations for SPD editor.
[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.ui.IInternalFrame;
24 import org.tianocore.frameworkwizard.common.ui.StarLabel;
25
26 public class SpdPackageDefinitions extends IInternalFrame {
27
28 /**
29 *
30 */
31 private static final long serialVersionUID = 1L;
32 private JPanel jContentPane = null;
33 private JLabel jLabel = null;
34 private JComboBox jComboBoxReadOnly = null;
35 private JLabel jLabel1 = null;
36 private JComboBox jComboBoxRePackage = null;
37 private StarLabel starLabel = null;
38 private StarLabel starLabel1 = null;
39 private SpdFileContents sfc = null;
40
41 /**
42 * This is the default constructor
43 */
44 public SpdPackageDefinitions() {
45 super();
46 initialize();
47 }
48
49 public SpdPackageDefinitions(PackageSurfaceAreaDocument.PackageSurfaceArea inPsa){
50 this();
51 sfc = new SpdFileContents(inPsa);
52 init(sfc);
53 }
54
55 private void init(SpdFileContents sfc) {
56 if (sfc.getSpdPkgDefsRdOnly() != null) {
57 jComboBoxReadOnly.setSelectedItem(sfc.getSpdPkgDefsRdOnly());
58 }
59 if (sfc.getSpdPkgDefsRePkg() != null) {
60 jComboBoxRePackage.setSelectedItem(sfc.getSpdPkgDefsRePkg());
61 }
62 this.setVisible(true);
63 }
64 /**
65 * This method initializes this
66 *
67 * @return void
68 */
69 private void initialize() {
70 this.setSize(300, 200);
71 this.setTitle("Package Definitions");
72 this.setContentPane(getJContentPane());
73 }
74
75 /**
76 * This method initializes jContentPane
77 *
78 * @return javax.swing.JPanel
79 */
80 private JPanel getJContentPane() {
81 if (jContentPane == null) {
82 starLabel1 = new StarLabel();
83 starLabel1.setBounds(new java.awt.Rectangle(4,62,10,20));
84 starLabel1.setVisible(true);
85 starLabel = new StarLabel();
86 starLabel.setBounds(new java.awt.Rectangle(4,22,10,20));
87 jLabel1 = new JLabel();
88 jLabel1.setPreferredSize(new java.awt.Dimension(65,20));
89 jLabel1.setLocation(new java.awt.Point(22,62));
90 jLabel1.setSize(new java.awt.Dimension(65,20));
91 jLabel1.setText("RePackage");
92 jLabel = new JLabel();
93 jLabel.setPreferredSize(new java.awt.Dimension(57,20));
94 jLabel.setLocation(new java.awt.Point(22,22));
95 jLabel.setSize(new java.awt.Dimension(57,20));
96 jLabel.setText("Read Only");
97 jContentPane = new JPanel();
98 jContentPane.setLayout(null);
99 jContentPane.add(jLabel, null);
100 jContentPane.add(getJComboBox(), null);
101 jContentPane.add(jLabel1, null);
102 jContentPane.add(getJComboBox1(), null);
103 jContentPane.add(starLabel, null);
104 jContentPane.add(starLabel1, null);
105 }
106 return jContentPane;
107 }
108
109 /**
110 * This method initializes jComboBox
111 *
112 * @return javax.swing.JComboBox
113 */
114 private JComboBox getJComboBox() {
115 if (jComboBoxReadOnly == null) {
116 jComboBoxReadOnly = new JComboBox();
117 jComboBoxReadOnly.setBounds(new java.awt.Rectangle(95,22,117,20));
118 jComboBoxReadOnly.setPreferredSize(new Dimension(80, 20));
119 jComboBoxReadOnly.addItem("true");
120 jComboBoxReadOnly.addItem("false");
121 jComboBoxReadOnly.setSelectedIndex(1);
122 jComboBoxReadOnly.addItemListener(new java.awt.event.ItemListener() {
123 public void itemStateChanged(java.awt.event.ItemEvent e) {
124 sfc.setSpdPkgDefsRdOnly(jComboBoxReadOnly.getSelectedItem()+"");
125 }
126 });
127 }
128 return jComboBoxReadOnly;
129 }
130
131 /**
132 * This method initializes jComboBox1
133 *
134 * @return javax.swing.JComboBox
135 */
136 private JComboBox getJComboBox1() {
137 if (jComboBoxRePackage == null) {
138 jComboBoxRePackage = new JComboBox();
139 jComboBoxRePackage.setBounds(new java.awt.Rectangle(95,62,116,20));
140 jComboBoxRePackage.setPreferredSize(new Dimension(80, 20));
141 jComboBoxRePackage.addItem("false");
142 jComboBoxRePackage.addItem("true");
143 jComboBoxRePackage.setSelectedIndex(0);
144 jComboBoxRePackage.addItemListener(new java.awt.event.ItemListener() {
145 public void itemStateChanged(java.awt.event.ItemEvent e) {
146 sfc.setSpdPkgDefsRePkg(jComboBoxRePackage.getSelectedItem()+"");
147 }
148 });
149 }
150 return jComboBoxRePackage;
151 }
152
153 }