]> git.proxmox.com Git - mirror_edk2.git/blob - Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/ui/IInternalFrame.java
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@671 6f19259b...
[mirror_edk2.git] / Tools / Source / FrameworkWizard / src / org / tianocore / frameworkwizard / common / ui / IInternalFrame.java
1 /** @file
2
3 The file is used to override JInternalFrame to provides customized interfaces
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
16 package org.tianocore.frameworkwizard.common.ui;
17
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
28 import javax.swing.JDesktopPane;
29 import javax.swing.JFrame;
30 import javax.swing.JInternalFrame;
31 import javax.swing.JPanel;
32
33 import org.tianocore.frameworkwizard.common.DataType;
34
35 /**
36 * The class is used to override JInternalFrame to provides customized
37 * interfaces It extends JInternalFrame implements ActionListener
38 *
39 *
40 *
41 */
42 public class IInternalFrame extends JInternalFrame implements ActionListener, ComponentListener, ItemListener, FocusListener {
43
44 // /
45 // / Define class Serial Version UID
46 // /
47 private static final long serialVersionUID = -609841772384875886L;
48
49 //
50 // Define class members
51 //
52 private boolean isEdited = false;
53
54 /**
55 * Main class, used for test
56 *
57 * @param args
58 *
59 */
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();
65 jdp.add(itf, 1);
66 jf.setContentPane(jp);
67 jf.setVisible(true);
68 }
69
70 /**
71 * This is the default constructor
72 *
73 */
74 public IInternalFrame() {
75 super();
76 initialize();
77 }
78
79 /**
80 * This method initializes this
81 *
82 */
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);
87 }
88
89 /**
90 * Get if the InternalFrame has been edited
91 *
92 * @retval true - The InternalFrame has been edited
93 * @retval false - The InternalFrame hasn't been edited
94 *
95 */
96 public boolean isEdited() {
97 return isEdited;
98 }
99
100 /**
101 * Set if the InternalFrame has been edited
102 *
103 * @param isEdited
104 * The input data which identify if the InternalFrame has been
105 * edited
106 *
107 */
108 public void setEdited(boolean isEdited) {
109 this.isEdited = isEdited;
110 }
111
112 /**
113 * Check the input data is empty or not
114 *
115 * @param strValue
116 * The input data which need be checked
117 *
118 * @retval true - The input data is empty
119 * @retval fals - The input data is not empty
120 *
121 */
122 public boolean isEmpty(String strValue) {
123 if (strValue.length() > 0) {
124 return false;
125 }
126 return true;
127 }
128
129 public void actionPerformed(ActionEvent arg0) {
130 // TODO Auto-generated method stub
131 }
132
133 public void componentHidden(ComponentEvent arg0) {
134 // TODO Auto-generated method stub
135
136 }
137
138 public void componentMoved(ComponentEvent arg0) {
139 // TODO Auto-generated method stub
140
141 }
142
143 public void componentResized(ComponentEvent arg0) {
144 // TODO Auto-generated method stub
145 }
146
147 public void componentShown(ComponentEvent arg0) {
148 // TODO Auto-generated method stub
149
150 }
151
152 /**
153 * To reset the width of input component via container width
154 *
155 * @param c
156 * @param containerWidth
157 *
158 */
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;
164 }
165 c.setSize(new java.awt.Dimension(newWidth, c.getHeight()));
166 c.validate();
167 }
168
169 /**
170 * To reset the height of input component via container height
171 *
172 * @param c
173 * @param containerHeight
174 *
175 */
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;
180 }
181 c.setSize(new java.awt.Dimension(c.getWidth(), newHeight));
182 c.validate();
183 }
184
185 /**
186 * To reset the size of input component via container size
187 *
188 * @param c
189 * @param containerWidth
190 * @param containerHeight
191 *
192 */
193 public void resizeComponent(Component c, int containerWidth, int containerHeight, int preferredWidth, int preferredHeight) {
194 resizeComponentWidth(c, containerWidth, preferredWidth);
195 resizeComponentHeight(c, containerHeight, preferredHeight);
196 }
197
198 /**
199 * To relocate the input component
200 *
201 * @param c
202 * @param containerWidth
203 * @param spaceToRight
204 *
205 */
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;
211 }
212 c.setLocation(newLocationX, c.getLocation().y);
213 c.validate();
214 }
215
216 /**
217 * To relocate the input component
218 *
219 * @param c
220 * @param containerHeight
221 * @param spaceToBottom
222 *
223 */
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;
228 }
229 c.setLocation(c.getLocation().x, newLocationY);
230 c.validate();
231 }
232
233 /**
234 * To relocate the input component
235 *
236 * @param c
237 * @param containerWidth
238 * @param containerHeight
239 * @param spaceToBottom
240 * @param spaceToRight
241 *
242 */
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);
247 }
248
249 public void showStandard() {
250
251 }
252
253 public void showAdvanced() {
254
255 }
256
257 public void showXML() {
258
259 }
260
261 public void itemStateChanged(ItemEvent arg0) {
262 // TODO Auto-generated method stub
263
264 }
265
266 public void focusGained(FocusEvent arg0) {
267 // TODO Auto-generated method stub
268
269 }
270
271 public void focusLost(FocusEvent arg0) {
272 // TODO Auto-generated method stub
273
274 }
275 }