]>
git.proxmox.com Git - mirror_edk2.git/blob - Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/ui/IInternalFrame.java
b5f09da0835ceab63005e78053b0238c96445e98
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
;
27 import java
.awt
.event
.MouseEvent
;
28 import java
.awt
.event
.MouseListener
;
30 import javax
.swing
.JDesktopPane
;
31 import javax
.swing
.JFrame
;
32 import javax
.swing
.JInternalFrame
;
33 import javax
.swing
.JPanel
;
34 import javax
.swing
.event
.ListSelectionEvent
;
35 import javax
.swing
.event
.ListSelectionListener
;
36 import javax
.swing
.event
.TableModelEvent
;
37 import javax
.swing
.event
.TableModelListener
;
40 * The class is used to override JInternalFrame to provides customized
41 * interfaces It extends JInternalFrame implements ActionListener
46 public class IInternalFrame
extends JInternalFrame
implements ActionListener
, ComponentListener
, ItemListener
,
47 FocusListener
, ListSelectionListener
, TableModelListener
, MouseListener
{
50 // / Define class Serial Version UID
52 private static final long serialVersionUID
= -609841772384875886L;
55 // Define class members
57 private boolean isEdited
= false;
60 * Main class, used for test
65 public static void main(String
[] args
) {
66 JFrame jf
= new JFrame();
67 JPanel jp
= new JPanel();
68 JDesktopPane jdp
= new JDesktopPane();
69 IInternalFrame itf
= new IInternalFrame();
71 jf
.setContentPane(jp
);
76 * This is the default constructor
79 public IInternalFrame() {
85 * This method initializes this
88 private void initialize() {
89 this.setBounds(new java
.awt
.Rectangle(0, 0, 520, 545));
90 this.setMinimumSize(new java
.awt
.Dimension(520, 545));
91 this.addComponentListener(this);
95 * Get if the InternalFrame has been edited
97 * @retval true - The InternalFrame has been edited
98 * @retval false - The InternalFrame hasn't been edited
101 public boolean isEdited() {
106 * Set if the InternalFrame has been edited
109 * The input data which identify if the InternalFrame has been
113 public void setEdited(boolean isEdited
) {
114 this.isEdited
= isEdited
;
118 * Check the input data is empty or not
121 * The input data which need be checked
123 * @retval true - The input data is empty
124 * @retval fals - The input data is not empty
127 public boolean isEmpty(String strValue
) {
128 if (strValue
.length() > 0) {
134 public void actionPerformed(ActionEvent arg0
) {
135 // TODO Auto-generated method stub
138 public void componentHidden(ComponentEvent arg0
) {
139 // TODO Auto-generated method stub
143 public void componentMoved(ComponentEvent arg0
) {
144 // TODO Auto-generated method stub
148 public void componentResized(ComponentEvent arg0
) {
149 // TODO Auto-generated method stub
152 public void componentShown(ComponentEvent arg0
) {
153 // TODO Auto-generated method stub
158 * To reset the width of input component via container width
161 * @param containerWidth
164 public void resizeComponentWidth(Component c
, int containerWidth
, int preferredWidth
) {
165 int newWidth
= c
.getPreferredSize().width
+ (containerWidth
- preferredWidth
);
166 if (newWidth
< c
.getPreferredSize().width
) {
167 newWidth
= c
.getPreferredSize().width
;
169 c
.setSize(new java
.awt
.Dimension(newWidth
, c
.getHeight()));
174 * To reset the height of input component via container height
177 * @param containerHeight
180 public void resizeComponentHeight(Component c
, int containerHeight
, int preferredHeight
) {
181 int newHeight
= c
.getPreferredSize().height
+ (containerHeight
- preferredHeight
);
182 if (newHeight
< c
.getPreferredSize().height
) {
183 newHeight
= c
.getPreferredSize().height
;
185 c
.setSize(new java
.awt
.Dimension(c
.getWidth(), newHeight
));
190 * To reset the size of input component via container size
193 * @param containerWidth
194 * @param containerHeight
197 public void resizeComponent(Component c
, int containerWidth
, int containerHeight
, int preferredWidth
,
198 int preferredHeight
) {
199 resizeComponentWidth(c
, containerWidth
, preferredWidth
);
200 resizeComponentHeight(c
, containerHeight
, preferredHeight
);
204 * To relocate the input component
207 * @param containerWidth
208 * @param spaceToRight
211 public void relocateComponentX(Component c
, int containerWidth
, int preferredWidth
, int spaceToRight
) {
212 int intGapToRight
= spaceToRight
+ c
.getPreferredSize().width
;
213 int newLocationX
= containerWidth
- intGapToRight
;
214 if (newLocationX
< preferredWidth
- intGapToRight
) {
215 newLocationX
= preferredWidth
- intGapToRight
;
217 c
.setLocation(newLocationX
, c
.getLocation().y
);
222 * To relocate the input component
225 * @param containerHeight
226 * @param spaceToBottom
229 public void relocateComponentY(Component c
, int containerHeight
, int preferredHeight
, int spaceToBottom
) {
230 int intGapToBottom
= spaceToBottom
+ c
.getPreferredSize().height
;
231 int newLocationY
= containerHeight
- intGapToBottom
;
232 if (newLocationY
< preferredHeight
- spaceToBottom
) {
233 newLocationY
= preferredHeight
- spaceToBottom
;
235 c
.setLocation(c
.getLocation().x
, newLocationY
);
240 * To relocate the input component
243 * @param containerWidth
244 * @param containerHeight
245 * @param spaceToBottom
246 * @param spaceToRight
249 public void relocateComponent(Component c
, int containerWidth
, int containerHeight
, int preferredWidht
,
250 int preferredHeight
, int spaceToRight
, int spaceToBottom
) {
251 relocateComponentX(c
, containerWidth
, preferredWidht
, spaceToRight
);
252 relocateComponentY(c
, containerHeight
, preferredHeight
, spaceToBottom
);
255 public void showStandard() {
259 public void showAdvanced() {
263 public void showXML() {
267 public void itemStateChanged(ItemEvent arg0
) {
268 // TODO Auto-generated method stub
272 public void focusGained(FocusEvent arg0
) {
273 // TODO Auto-generated method stub
277 public void focusLost(FocusEvent arg0
) {
278 // TODO Auto-generated method stub
282 public void valueChanged(ListSelectionEvent arg0
) {
283 // TODO Auto-generated method stub
287 public void tableChanged(TableModelEvent arg0
) {
288 // TODO Auto-generated method stub
292 public void mouseClicked(MouseEvent arg0
) {
293 // TODO Auto-generated method stub
297 public void mouseEntered(MouseEvent arg0
) {
298 // TODO Auto-generated method stub
302 public void mouseExited(MouseEvent arg0
) {
303 // TODO Auto-generated method stub
307 public void mousePressed(MouseEvent arg0
) {
308 // TODO Auto-generated method stub
312 public void mouseReleased(MouseEvent arg0
) {
313 // TODO Auto-generated method stub