3 The file is used to override JInternalFrame to provides customized interfaces
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.
16 package org
.tianocore
.frameworkwizard
.common
.ui
;
18 import java
.awt
.Component
;
19 import java
.awt
.event
.ActionEvent
;
20 import java
.awt
.event
.ActionListener
;
21 import java
.awt
.event
.ComponentEvent
;
22 import java
.awt
.event
.ComponentListener
;
23 import java
.awt
.event
.FocusEvent
;
24 import java
.awt
.event
.FocusListener
;
25 import java
.awt
.event
.ItemEvent
;
26 import java
.awt
.event
.ItemListener
;
28 import javax
.swing
.JDesktopPane
;
29 import javax
.swing
.JFrame
;
30 import javax
.swing
.JInternalFrame
;
31 import javax
.swing
.JPanel
;
33 import org
.tianocore
.frameworkwizard
.common
.DataType
;
36 * The class is used to override JInternalFrame to provides customized
37 * interfaces It extends JInternalFrame implements ActionListener
42 public class IInternalFrame
extends JInternalFrame
implements ActionListener
, ComponentListener
, ItemListener
, FocusListener
{
45 // / Define class Serial Version UID
47 private static final long serialVersionUID
= -609841772384875886L;
50 // Define class members
52 private boolean isEdited
= false;
55 * Main class, used for test
60 public static void main(String
[] args
) {
61 JFrame jf
= new JFrame();
62 JPanel jp
= new JPanel();
63 JDesktopPane jdp
= new JDesktopPane();
64 IInternalFrame itf
= new IInternalFrame();
66 jf
.setContentPane(jp
);
71 * This is the default constructor
74 public IInternalFrame() {
80 * This method initializes this
83 private void initialize() {
84 this.setBounds(new java
.awt
.Rectangle(0, 0, 520, 545));
85 this.setMinimumSize(new java
.awt
.Dimension(520, 545));
86 this.addComponentListener(this);
90 * Get if the InternalFrame has been edited
92 * @retval true - The InternalFrame has been edited
93 * @retval false - The InternalFrame hasn't been edited
96 public boolean isEdited() {
101 * Set if the InternalFrame has been edited
104 * The input data which identify if the InternalFrame has been
108 public void setEdited(boolean isEdited
) {
109 this.isEdited
= isEdited
;
113 * Check the input data is empty or not
116 * The input data which need be checked
118 * @retval true - The input data is empty
119 * @retval fals - The input data is not empty
122 public boolean isEmpty(String strValue
) {
123 if (strValue
.length() > 0) {
129 public void actionPerformed(ActionEvent arg0
) {
130 // TODO Auto-generated method stub
133 public void componentHidden(ComponentEvent arg0
) {
134 // TODO Auto-generated method stub
138 public void componentMoved(ComponentEvent arg0
) {
139 // TODO Auto-generated method stub
143 public void componentResized(ComponentEvent arg0
) {
144 // TODO Auto-generated method stub
147 public void componentShown(ComponentEvent arg0
) {
148 // TODO Auto-generated method stub
153 * To reset the width of input component via container width
156 * @param containerWidth
159 public void resizeComponentWidth(Component c
, int containerWidth
, int preferredWidth
) {
160 int newWidth
= c
.getPreferredSize().width
161 + (containerWidth
- preferredWidth
);
162 if (newWidth
< c
.getPreferredSize().width
) {
163 newWidth
= c
.getPreferredSize().width
;
165 c
.setSize(new java
.awt
.Dimension(newWidth
, c
.getHeight()));
170 * To reset the height of input component via container height
173 * @param containerHeight
176 public void resizeComponentHeight(Component c
, int containerHeight
, int preferredHeight
) {
177 int newHeight
= c
.getPreferredSize().height
+ (containerHeight
- preferredHeight
);
178 if (newHeight
< c
.getPreferredSize().height
) {
179 newHeight
= c
.getPreferredSize().height
;
181 c
.setSize(new java
.awt
.Dimension(c
.getWidth(), newHeight
));
186 * To reset the size of input component via container size
189 * @param containerWidth
190 * @param containerHeight
193 public void resizeComponent(Component c
, int containerWidth
, int containerHeight
, int preferredWidth
, int preferredHeight
) {
194 resizeComponentWidth(c
, containerWidth
, preferredWidth
);
195 resizeComponentHeight(c
, containerHeight
, preferredHeight
);
199 * To relocate the input component
202 * @param containerWidth
203 * @param spaceToRight
206 public void relocateComponentX(Component c
, int containerWidth
, int preferredWidth
, int spaceToRight
) {
207 int intGapToRight
= spaceToRight
+ c
.getPreferredSize().width
;
208 int newLocationX
= containerWidth
- intGapToRight
;
209 if (newLocationX
< preferredWidth
-intGapToRight
) {
210 newLocationX
= preferredWidth
- intGapToRight
;
212 c
.setLocation(newLocationX
, c
.getLocation().y
);
217 * To relocate the input component
220 * @param containerHeight
221 * @param spaceToBottom
224 public void relocateComponentY(Component c
, int containerHeight
, int spaceToBottom
) {
225 int newLocationY
= containerHeight
- spaceToBottom
;
226 if (newLocationY
< DataType
.MAIN_FRAME_EDITOR_PANEL_PREFERRED_SIZE_HEIGHT
- spaceToBottom
) {
227 newLocationY
= DataType
.MAIN_FRAME_EDITOR_PANEL_PREFERRED_SIZE_HEIGHT
- spaceToBottom
;
229 c
.setLocation(c
.getLocation().x
, newLocationY
);
234 * To relocate the input component
237 * @param containerWidth
238 * @param containerHeight
239 * @param spaceToBottom
240 * @param spaceToRight
243 public void relocateComponent(Component c
, int containerWidth
, int containerHeight
, int spaceToBottom
,
244 int spaceToRight
, int preferredWidht
, int preferredHeight
) {
245 relocateComponentX(c
, containerWidth
, preferredWidht
, spaceToBottom
);
246 relocateComponentY(c
, containerHeight
, spaceToRight
);
249 public void showStandard() {
253 public void showAdvanced() {
257 public void showXML() {
261 public void itemStateChanged(ItemEvent arg0
) {
262 // TODO Auto-generated method stub
266 public void focusGained(FocusEvent arg0
) {
267 // TODO Auto-generated method stub
271 public void focusLost(FocusEvent arg0
) {
272 // TODO Auto-generated method stub