]> git.proxmox.com Git - mirror_edk2.git/blob - Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/ui/IInternalFrame.java
b5f09da0835ceab63005e78053b0238c96445e98
[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 import java.awt.event.MouseEvent;
28 import java.awt.event.MouseListener;
29
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;
38
39 /**
40 * The class is used to override JInternalFrame to provides customized
41 * interfaces It extends JInternalFrame implements ActionListener
42 *
43 *
44 *
45 */
46 public class IInternalFrame extends JInternalFrame implements ActionListener, ComponentListener, ItemListener,
47 FocusListener, ListSelectionListener, TableModelListener, MouseListener {
48
49 // /
50 // / Define class Serial Version UID
51 // /
52 private static final long serialVersionUID = -609841772384875886L;
53
54 //
55 // Define class members
56 //
57 private boolean isEdited = false;
58
59 /**
60 * Main class, used for test
61 *
62 * @param args
63 *
64 */
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();
70 jdp.add(itf, 1);
71 jf.setContentPane(jp);
72 jf.setVisible(true);
73 }
74
75 /**
76 * This is the default constructor
77 *
78 */
79 public IInternalFrame() {
80 super();
81 initialize();
82 }
83
84 /**
85 * This method initializes this
86 *
87 */
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);
92 }
93
94 /**
95 * Get if the InternalFrame has been edited
96 *
97 * @retval true - The InternalFrame has been edited
98 * @retval false - The InternalFrame hasn't been edited
99 *
100 */
101 public boolean isEdited() {
102 return isEdited;
103 }
104
105 /**
106 * Set if the InternalFrame has been edited
107 *
108 * @param isEdited
109 * The input data which identify if the InternalFrame has been
110 * edited
111 *
112 */
113 public void setEdited(boolean isEdited) {
114 this.isEdited = isEdited;
115 }
116
117 /**
118 * Check the input data is empty or not
119 *
120 * @param strValue
121 * The input data which need be checked
122 *
123 * @retval true - The input data is empty
124 * @retval fals - The input data is not empty
125 *
126 */
127 public boolean isEmpty(String strValue) {
128 if (strValue.length() > 0) {
129 return false;
130 }
131 return true;
132 }
133
134 public void actionPerformed(ActionEvent arg0) {
135 // TODO Auto-generated method stub
136 }
137
138 public void componentHidden(ComponentEvent arg0) {
139 // TODO Auto-generated method stub
140
141 }
142
143 public void componentMoved(ComponentEvent arg0) {
144 // TODO Auto-generated method stub
145
146 }
147
148 public void componentResized(ComponentEvent arg0) {
149 // TODO Auto-generated method stub
150 }
151
152 public void componentShown(ComponentEvent arg0) {
153 // TODO Auto-generated method stub
154
155 }
156
157 /**
158 * To reset the width of input component via container width
159 *
160 * @param c
161 * @param containerWidth
162 *
163 */
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;
168 }
169 c.setSize(new java.awt.Dimension(newWidth, c.getHeight()));
170 c.validate();
171 }
172
173 /**
174 * To reset the height of input component via container height
175 *
176 * @param c
177 * @param containerHeight
178 *
179 */
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;
184 }
185 c.setSize(new java.awt.Dimension(c.getWidth(), newHeight));
186 c.validate();
187 }
188
189 /**
190 * To reset the size of input component via container size
191 *
192 * @param c
193 * @param containerWidth
194 * @param containerHeight
195 *
196 */
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);
201 }
202
203 /**
204 * To relocate the input component
205 *
206 * @param c
207 * @param containerWidth
208 * @param spaceToRight
209 *
210 */
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;
216 }
217 c.setLocation(newLocationX, c.getLocation().y);
218 c.validate();
219 }
220
221 /**
222 * To relocate the input component
223 *
224 * @param c
225 * @param containerHeight
226 * @param spaceToBottom
227 *
228 */
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;
234 }
235 c.setLocation(c.getLocation().x, newLocationY);
236 c.validate();
237 }
238
239 /**
240 * To relocate the input component
241 *
242 * @param c
243 * @param containerWidth
244 * @param containerHeight
245 * @param spaceToBottom
246 * @param spaceToRight
247 *
248 */
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);
253 }
254
255 public void showStandard() {
256
257 }
258
259 public void showAdvanced() {
260
261 }
262
263 public void showXML() {
264
265 }
266
267 public void itemStateChanged(ItemEvent arg0) {
268 // TODO Auto-generated method stub
269
270 }
271
272 public void focusGained(FocusEvent arg0) {
273 // TODO Auto-generated method stub
274
275 }
276
277 public void focusLost(FocusEvent arg0) {
278 // TODO Auto-generated method stub
279
280 }
281
282 public void valueChanged(ListSelectionEvent arg0) {
283 // TODO Auto-generated method stub
284
285 }
286
287 public void tableChanged(TableModelEvent arg0) {
288 // TODO Auto-generated method stub
289
290 }
291
292 public void mouseClicked(MouseEvent arg0) {
293 // TODO Auto-generated method stub
294
295 }
296
297 public void mouseEntered(MouseEvent arg0) {
298 // TODO Auto-generated method stub
299
300 }
301
302 public void mouseExited(MouseEvent arg0) {
303 // TODO Auto-generated method stub
304
305 }
306
307 public void mousePressed(MouseEvent arg0) {
308 // TODO Auto-generated method stub
309
310 }
311
312 public void mouseReleased(MouseEvent arg0) {
313 // TODO Auto-generated method stub
314
315 }
316 }