]> git.proxmox.com Git - mirror_edk2.git/blame - Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/ui/IInternalFrame.java
1. Restructure module description on main UI
[mirror_edk2.git] / Tools / Source / FrameworkWizard / src / org / tianocore / frameworkwizard / common / ui / IInternalFrame.java
CommitLineData
a13899c5 1/** @file\r
2 \r
3 The file is used to override JInternalFrame to provides customized interfaces \r
4 \r
5 Copyright (c) 2006, Intel Corporation\r
6 All rights reserved. This program and the accompanying materials\r
7 are licensed and made available under the terms and conditions of the BSD License\r
8 which accompanies this distribution. The full text of the license may be found at\r
9 http://opensource.org/licenses/bsd-license.php\r
10 \r
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
13 \r
14 **/\r
15\r
16package org.tianocore.frameworkwizard.common.ui;\r
17\r
18import java.awt.Component;\r
19import java.awt.event.ActionEvent;\r
20import java.awt.event.ActionListener;\r
21import java.awt.event.ComponentEvent;\r
22import java.awt.event.ComponentListener;\r
23import java.awt.event.FocusEvent;\r
24import java.awt.event.FocusListener;\r
25import java.awt.event.ItemEvent;\r
26import java.awt.event.ItemListener;\r
92e29378 27import java.awt.event.MouseEvent;\r
28import java.awt.event.MouseListener;\r
a13899c5 29\r
30import javax.swing.JDesktopPane;\r
31import javax.swing.JFrame;\r
32import javax.swing.JInternalFrame;\r
33import javax.swing.JPanel;\r
92e29378 34import javax.swing.event.ListSelectionEvent;\r
35import javax.swing.event.ListSelectionListener;\r
36import javax.swing.event.TableModelEvent;\r
37import javax.swing.event.TableModelListener;\r
a13899c5 38\r
39/**\r
40 * The class is used to override JInternalFrame to provides customized\r
41 * interfaces It extends JInternalFrame implements ActionListener\r
42 * \r
43 *\r
44 * \r
45 */\r
92e29378 46public class IInternalFrame extends JInternalFrame implements ActionListener, ComponentListener, ItemListener,\r
47 FocusListener, ListSelectionListener, TableModelListener, MouseListener {\r
a13899c5 48\r
49 // /\r
50 // / Define class Serial Version UID\r
51 // /\r
52 private static final long serialVersionUID = -609841772384875886L;\r
53\r
54 //\r
55 // Define class members\r
56 //\r
57 private boolean isEdited = false;\r
58\r
59 /**\r
60 * Main class, used for test\r
61 * \r
62 * @param args\r
63 * \r
64 */\r
65 public static void main(String[] args) {\r
66 JFrame jf = new JFrame();\r
67 JPanel jp = new JPanel();\r
68 JDesktopPane jdp = new JDesktopPane();\r
69 IInternalFrame itf = new IInternalFrame();\r
70 jdp.add(itf, 1);\r
71 jf.setContentPane(jp);\r
72 jf.setVisible(true);\r
73 }\r
74\r
75 /**\r
76 * This is the default constructor\r
77 * \r
78 */\r
79 public IInternalFrame() {\r
80 super();\r
81 initialize();\r
82 }\r
83\r
84 /**\r
85 * This method initializes this\r
86 * \r
87 */\r
88 private void initialize() {\r
89 this.setBounds(new java.awt.Rectangle(0, 0, 520, 545));\r
90 this.setMinimumSize(new java.awt.Dimension(520, 545));\r
91 this.addComponentListener(this);\r
92 }\r
93\r
94 /**\r
95 * Get if the InternalFrame has been edited\r
96 * \r
97 * @retval true - The InternalFrame has been edited\r
98 * @retval false - The InternalFrame hasn't been edited\r
99 * \r
100 */\r
101 public boolean isEdited() {\r
102 return isEdited;\r
103 }\r
104\r
105 /**\r
106 * Set if the InternalFrame has been edited\r
107 * \r
108 * @param isEdited\r
109 * The input data which identify if the InternalFrame has been\r
110 * edited\r
111 * \r
112 */\r
113 public void setEdited(boolean isEdited) {\r
114 this.isEdited = isEdited;\r
115 }\r
116\r
117 /**\r
118 * Check the input data is empty or not\r
119 * \r
120 * @param strValue\r
121 * The input data which need be checked\r
122 * \r
123 * @retval true - The input data is empty\r
124 * @retval fals - The input data is not empty\r
125 * \r
126 */\r
127 public boolean isEmpty(String strValue) {\r
128 if (strValue.length() > 0) {\r
129 return false;\r
130 }\r
131 return true;\r
132 }\r
133\r
134 public void actionPerformed(ActionEvent arg0) {\r
135 // TODO Auto-generated method stub\r
136 }\r
137\r
138 public void componentHidden(ComponentEvent arg0) {\r
139 // TODO Auto-generated method stub\r
140\r
141 }\r
142\r
143 public void componentMoved(ComponentEvent arg0) {\r
144 // TODO Auto-generated method stub\r
145\r
146 }\r
147\r
148 public void componentResized(ComponentEvent arg0) {\r
149 // TODO Auto-generated method stub\r
150 }\r
151\r
152 public void componentShown(ComponentEvent arg0) {\r
153 // TODO Auto-generated method stub\r
154\r
155 }\r
156\r
157 /**\r
158 * To reset the width of input component via container width\r
159 * \r
160 * @param c\r
161 * @param containerWidth\r
162 * \r
163 */\r
164 public void resizeComponentWidth(Component c, int containerWidth, int preferredWidth) {\r
92e29378 165 int newWidth = c.getPreferredSize().width + (containerWidth - preferredWidth);\r
a13899c5 166 if (newWidth < c.getPreferredSize().width) {\r
167 newWidth = c.getPreferredSize().width;\r
168 }\r
169 c.setSize(new java.awt.Dimension(newWidth, c.getHeight()));\r
170 c.validate();\r
171 }\r
172\r
173 /**\r
174 * To reset the height of input component via container height\r
175 * \r
176 * @param c\r
177 * @param containerHeight\r
178 * \r
179 */\r
180 public void resizeComponentHeight(Component c, int containerHeight, int preferredHeight) {\r
181 int newHeight = c.getPreferredSize().height + (containerHeight - preferredHeight);\r
182 if (newHeight < c.getPreferredSize().height) {\r
183 newHeight = c.getPreferredSize().height;\r
184 }\r
185 c.setSize(new java.awt.Dimension(c.getWidth(), newHeight));\r
186 c.validate();\r
187 }\r
188\r
189 /**\r
190 * To reset the size of input component via container size\r
191 * \r
192 * @param c\r
193 * @param containerWidth\r
194 * @param containerHeight\r
195 * \r
196 */\r
92e29378 197 public void resizeComponent(Component c, int containerWidth, int containerHeight, int preferredWidth,\r
198 int preferredHeight) {\r
a13899c5 199 resizeComponentWidth(c, containerWidth, preferredWidth);\r
200 resizeComponentHeight(c, containerHeight, preferredHeight);\r
201 }\r
202\r
203 /**\r
204 * To relocate the input component\r
205 * \r
206 * @param c\r
207 * @param containerWidth\r
208 * @param spaceToRight\r
209 * \r
210 */\r
211 public void relocateComponentX(Component c, int containerWidth, int preferredWidth, int spaceToRight) {\r
212 int intGapToRight = spaceToRight + c.getPreferredSize().width;\r
213 int newLocationX = containerWidth - intGapToRight;\r
92e29378 214 if (newLocationX < preferredWidth - intGapToRight) {\r
a13899c5 215 newLocationX = preferredWidth - intGapToRight;\r
216 }\r
217 c.setLocation(newLocationX, c.getLocation().y);\r
218 c.validate();\r
219 }\r
220\r
221 /**\r
222 * To relocate the input component\r
223 * \r
224 * @param c\r
225 * @param containerHeight\r
226 * @param spaceToBottom\r
227 * \r
228 */\r
92e29378 229 public void relocateComponentY(Component c, int containerHeight, int preferredHeight, int spaceToBottom) {\r
230 int intGapToBottom = spaceToBottom + c.getPreferredSize().height;\r
231 int newLocationY = containerHeight - intGapToBottom;\r
232 if (newLocationY < preferredHeight - spaceToBottom) {\r
233 newLocationY = preferredHeight - spaceToBottom;\r
a13899c5 234 }\r
235 c.setLocation(c.getLocation().x, newLocationY);\r
236 c.validate();\r
237 }\r
238\r
239 /**\r
240 * To relocate the input component\r
241 * \r
242 * @param c\r
243 * @param containerWidth\r
244 * @param containerHeight\r
245 * @param spaceToBottom\r
246 * @param spaceToRight\r
247 * \r
248 */\r
92e29378 249 public void relocateComponent(Component c, int containerWidth, int containerHeight, int preferredWidht,\r
250 int preferredHeight, int spaceToRight, int spaceToBottom) {\r
251 relocateComponentX(c, containerWidth, preferredWidht, spaceToRight);\r
252 relocateComponentY(c, containerHeight, preferredHeight, spaceToBottom);\r
a13899c5 253 }\r
254\r
255 public void showStandard() {\r
256\r
257 }\r
258\r
259 public void showAdvanced() {\r
260\r
261 }\r
262\r
263 public void showXML() {\r
264\r
265 }\r
266\r
267 public void itemStateChanged(ItemEvent arg0) {\r
268 // TODO Auto-generated method stub\r
92e29378 269\r
a13899c5 270 }\r
271\r
272 public void focusGained(FocusEvent arg0) {\r
273 // TODO Auto-generated method stub\r
92e29378 274\r
a13899c5 275 }\r
276\r
277 public void focusLost(FocusEvent arg0) {\r
278 // TODO Auto-generated method stub\r
92e29378 279\r
280 }\r
281\r
282 public void valueChanged(ListSelectionEvent arg0) {\r
283 // TODO Auto-generated method stub\r
284\r
285 }\r
286\r
287 public void tableChanged(TableModelEvent arg0) {\r
288 // TODO Auto-generated method stub\r
289\r
290 }\r
291\r
292 public void mouseClicked(MouseEvent arg0) {\r
293 // TODO Auto-generated method stub\r
294 \r
295 }\r
296\r
297 public void mouseEntered(MouseEvent arg0) {\r
298 // TODO Auto-generated method stub\r
299 \r
300 }\r
301\r
302 public void mouseExited(MouseEvent arg0) {\r
303 // TODO Auto-generated method stub\r
304 \r
305 }\r
306\r
307 public void mousePressed(MouseEvent arg0) {\r
308 // TODO Auto-generated method stub\r
309 \r
310 }\r
311\r
312 public void mouseReleased(MouseEvent arg0) {\r
313 // TODO Auto-generated method stub\r
a13899c5 314 \r
315 }\r
316}\r