3 The file is used to create, update Module Definitions of MSA file
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
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.
15 package org
.tianocore
.frameworkwizard
.module
.ui
;
17 import java
.awt
.event
.ComponentEvent
;
18 import java
.awt
.event
.FocusEvent
;
20 import javax
.swing
.JPanel
;
21 import javax
.swing
.JScrollPane
;
22 import javax
.swing
.JLabel
;
23 import javax
.swing
.JTextField
;
24 import javax
.swing
.JComboBox
;
26 import org
.tianocore
.ModuleDefinitionsDocument
;
27 import org
.tianocore
.ModuleSurfaceAreaDocument
;
28 import org
.tianocore
.ModuleDefinitionsDocument
.ModuleDefinitions
.ClonedFrom
;
29 import org
.tianocore
.frameworkwizard
.common
.DataType
;
30 import org
.tianocore
.frameworkwizard
.common
.DataValidation
;
31 import org
.tianocore
.frameworkwizard
.common
.EnumerationData
;
32 import org
.tianocore
.frameworkwizard
.common
.Log
;
33 import org
.tianocore
.frameworkwizard
.common
.Tools
;
34 import org
.tianocore
.frameworkwizard
.common
.Identifications
.OpeningModuleType
;
35 import org
.tianocore
.frameworkwizard
.common
.ui
.IInternalFrame
;
36 import org
.tianocore
.frameworkwizard
.common
.ui
.StarLabel
;
37 import org
.tianocore
.frameworkwizard
.common
.ui
.iCheckBoxList
.ICheckBoxList
;
39 public class ModuleDefinitions
extends IInternalFrame
{
42 /// Define class Serial Version UID
44 private static final long serialVersionUID
= 5860378543553036323L;
46 private JScrollPane jScrollPane
= null;
48 private JPanel jContentPane
= null;
50 private JLabel jLabelArch
= null;
52 private ICheckBoxList iCheckBoxListArch
= null;
54 private JLabel jLabelBinaryModule
= null;
56 private JComboBox jComboBoxBinaryModule
= null;
58 private JLabel jLabelOutputFileBasename
= null;
60 private JTextField jTextFieldOutputFileBasename
= null;
62 private JScrollPane jScrollPaneArch
= null;
64 private StarLabel jStarLabel1
= null;
66 private StarLabel jStarLabel2
= null;
68 private StarLabel jStarLabel3
= null;
70 private OpeningModuleType omt
= null;
72 private ClonedFrom cf
= null;
74 private ModuleSurfaceAreaDocument
.ModuleSurfaceArea msa
= null;
76 private ModuleDefinitionsDocument
.ModuleDefinitions md
= null;
79 * This method initializes jScrollPane
81 * @return javax.swing.JScrollPane
83 private JScrollPane
getJScrollPane() {
84 if (jScrollPane
== null) {
85 jScrollPane
= new JScrollPane();
86 jScrollPane
.setViewportView(getJContentPane());
92 * This method initializes jPanel
94 * @return javax.swing.JPanel
96 private JPanel
getJContentPane() {
97 if (jContentPane
== null) {
98 jLabelOutputFileBasename
= new JLabel();
99 jLabelOutputFileBasename
.setBounds(new java
.awt
.Rectangle(15, 10, 140, 20));
100 jLabelOutputFileBasename
.setText("Output File Basename");
101 jLabelBinaryModule
= new JLabel();
102 jLabelBinaryModule
.setBounds(new java
.awt
.Rectangle(15, 35, 140, 20));
103 jLabelBinaryModule
.setText("Binary Module");
104 jLabelArch
= new JLabel();
105 jLabelArch
.setBounds(new java
.awt
.Rectangle(15, 60, 140, 20));
106 jLabelArch
.setText("Supported Architectures");
107 jStarLabel1
= new StarLabel();
108 jStarLabel1
.setLocation(new java
.awt
.Point(0, 10));
109 jStarLabel2
= new StarLabel();
110 jStarLabel2
.setLocation(new java
.awt
.Point(0, 35));
111 jStarLabel3
= new StarLabel();
112 jStarLabel3
.setLocation(new java
.awt
.Point(0, 60));
114 jContentPane
= new JPanel();
115 jContentPane
.setLayout(null);
116 jContentPane
.setPreferredSize(new java
.awt
.Dimension(490, 150));
118 jContentPane
.add(jLabelArch
, null);
119 jContentPane
.add(getJScrollPaneArch(), null);
120 jContentPane
.add(jLabelBinaryModule
, null);
121 jContentPane
.add(getJComboBoxBinaryModule(), null);
122 jContentPane
.add(jLabelOutputFileBasename
, null);
123 jContentPane
.add(getJTextFieldOutputFileBasename(), null);
124 jContentPane
.add(jStarLabel1
, null);
125 jContentPane
.add(jStarLabel2
, null);
126 jContentPane
.add(jStarLabel3
, null);
132 This method initializes iCheckBoxListArch
134 @return ICheckBoxList
136 private ICheckBoxList
getICheckBoxListSupportedArchitectures() {
137 if (iCheckBoxListArch
== null) {
138 iCheckBoxListArch
= new ICheckBoxList();
139 iCheckBoxListArch
.addFocusListener(this);
140 iCheckBoxListArch
.setToolTipText(DataType
.SUP_ARCH_LIST_HELP_TEXT
);
142 return iCheckBoxListArch
;
146 * This method initializes jComboBoxBinaryModule
148 * @return javax.swing.JComboBox
150 private JComboBox
getJComboBoxBinaryModule() {
151 if (jComboBoxBinaryModule
== null) {
152 jComboBoxBinaryModule
= new JComboBox();
153 jComboBoxBinaryModule
.setBounds(new java
.awt
.Rectangle(160, 35, 320, 20));
154 jComboBoxBinaryModule
.setPreferredSize(new java
.awt
.Dimension(320, 20));
155 jComboBoxBinaryModule
.addFocusListener(this);
156 jComboBoxBinaryModule
.setToolTipText("Modules are either source modules which can be compiled or binary modules which are linked. A module cannot contain both. The GUID numbers should be identical for a binary and source MSA, but the BINARY MSA should have a higher version number.");
158 return jComboBoxBinaryModule
;
162 * This method initializes jTextFieldOutputFileBasename
164 * @return javax.swing.JTextField
166 private JTextField
getJTextFieldOutputFileBasename() {
167 if (jTextFieldOutputFileBasename
== null) {
168 jTextFieldOutputFileBasename
= new JTextField();
169 jTextFieldOutputFileBasename
.setBounds(new java
.awt
.Rectangle(160, 10, 320, 20));
170 jTextFieldOutputFileBasename
.setPreferredSize(new java
.awt
.Dimension(320, 20));
171 jTextFieldOutputFileBasename
.addFocusListener(this);
172 jTextFieldOutputFileBasename
.setToolTipText("Enter a single word for generated output file names");
174 return jTextFieldOutputFileBasename
;
178 This method initializes jScrollPaneArch
180 @return javax.swing.JScrollPane
183 private JScrollPane
getJScrollPaneArch() {
184 if (jScrollPaneArch
== null) {
185 jScrollPaneArch
= new JScrollPane();
186 jScrollPaneArch
.setBounds(new java
.awt
.Rectangle(160, 60, 320, 80));
187 jScrollPaneArch
.setPreferredSize(new java
.awt
.Dimension(320, 60));
188 jScrollPaneArch
.setViewportView(getICheckBoxListSupportedArchitectures());
190 return jScrollPaneArch
;
198 public static void main(String
[] args
) {
199 // TODO Auto-generated method stub
204 * This is the default constructor
206 public ModuleDefinitions() {
209 this.setVisible(true);
213 This is the override edit constructor
218 public ModuleDefinitions(OpeningModuleType inOmt
) {
221 this.msa
= omt
.getXmlMsa();
222 if (msa
.getModuleDefinitions() != null) {
223 this.cf
= msa
.getModuleDefinitions().getClonedFrom();
225 init(msa
.getModuleDefinitions());
226 this.setVisible(true);
230 * This method initializes this
234 private void init() {
235 this.setContentPane(getJScrollPane());
236 this.setTitle("Module Definitions");
238 this.setPreferredSize(new java
.awt
.Dimension(490, 520));
242 This method initializes this
243 Fill values to all fields if these values are not empty
245 @param inMsaHeader The input data of MsaHeaderDocument.MsaHeader
248 private void init(ModuleDefinitionsDocument
.ModuleDefinitions inMd
) {
252 if (md
.getSupportedArchitectures() != null) {
253 this.iCheckBoxListArch
.initCheckedItem(true, Tools
.convertListToVector(md
.getSupportedArchitectures()));
255 if (md
.getBinaryModule()) {
256 this.jComboBoxBinaryModule
.setSelectedIndex(1);
258 this.jComboBoxBinaryModule
.setSelectedIndex(0);
260 if (md
.getOutputFileBasename() != null) {
261 this.jTextFieldOutputFileBasename
.setText(md
.getOutputFileBasename());
267 This method initializes Module type and Compontent type
270 private void initFrame() {
271 EnumerationData ed
= new EnumerationData();
272 this.iCheckBoxListArch
.setAllItems(ed
.getVSupportedArchitectures());
273 Tools
.generateComboBoxByVector(jComboBoxBinaryModule
, ed
.getVBoolean());
276 private boolean check() {
277 if (isEmpty(this.jTextFieldOutputFileBasename
.getText())) {
278 Log
.err("Output File Basename couldn't be empty!");
281 if (!DataValidation
.isOutputFileBasename(this.jTextFieldOutputFileBasename
.getText())) {
282 Log
.err("Incorrect data type for Output File Basename");
289 * @see java.awt.event.ComponentListener#componentResized(java.awt.event.ComponentEvent)
291 * Override componentResized to resize all components when frame's size is changed
293 public void componentResized(ComponentEvent arg0
) {
294 int intCurrentWidth
= this.getJContentPane().getWidth();
295 int intPreferredWidth
= this.getJContentPane().getPreferredSize().width
;
297 resizeComponentWidth(this.jScrollPaneArch
, intCurrentWidth
, intPreferredWidth
);
298 resizeComponentWidth(this.jComboBoxBinaryModule
, intCurrentWidth
, intPreferredWidth
);
299 resizeComponentWidth(this.jTextFieldOutputFileBasename
, intCurrentWidth
, intPreferredWidth
);
303 Save all components of Module Definitions
304 if exists Module Definitions, set the value directly
305 if not exists Module Definitions, new an instance first
311 if (this.md
== null) {
312 md
= ModuleDefinitionsDocument
.ModuleDefinitions
.Factory
.newInstance();
315 if (!isEmpty(this.jTextFieldOutputFileBasename
.getText())) {
316 md
.setOutputFileBasename(this.jTextFieldOutputFileBasename
.getText());
319 if (this.jComboBoxBinaryModule
.getSelectedIndex() == 0) {
320 md
.setBinaryModule(false);
322 md
.setBinaryModule(true);
326 // Set ClonedFrom field
328 if (this.cf
!= null) {
329 md
.setClonedFrom(this.cf
);
335 md
.setSupportedArchitectures(this.iCheckBoxListArch
.getAllCheckedItemsString());
337 msa
.setModuleDefinitions(md
);
339 this.omt
.setSaved(false);
341 } catch (Exception e
) {
342 Log
.err("Save Module Definitions", e
.getMessage());
346 public void focusLost(FocusEvent arg0
) {
348 if (arg0
.getSource() == this.jTextFieldOutputFileBasename
) {