]>
Commit | Line | Data |
---|---|---|
a13899c5 | 1 | /** @file\r |
2 | \r | |
3 | The file is used to override Dialog 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 | |
16 | package org.tianocore.frameworkwizard.common.ui;\r | |
17 | \r | |
18 | import java.awt.Dimension;\r | |
19 | import java.awt.Toolkit;\r | |
20 | import java.awt.event.ActionEvent;\r | |
21 | import java.awt.event.ActionListener;\r | |
22 | \r | |
23 | import javax.swing.JDialog;\r | |
24 | \r | |
25 | import org.tianocore.frameworkwizard.common.DataType;\r | |
26 | \r | |
27 | /**\r | |
28 | The class is used to override Dialog to provides customized interfaces\r | |
29 | It extends JDialog implements ActionListener\r | |
30 | \r | |
31 | \r | |
32 | \r | |
33 | **/\r | |
34 | public class IDialog extends JDialog implements ActionListener {\r | |
35 | ///\r | |
36 | /// Define class Serial Version UID\r | |
37 | ///\r | |
38 | private static final long serialVersionUID = -7692623863358631984L;\r | |
39 | //\r | |
40 | //Define class members\r | |
41 | //\r | |
42 | private boolean isEdited = false;\r | |
43 | \r | |
44 | public int returnType = DataType.RETURN_TYPE_CANCEL;\r | |
45 | \r | |
46 | public void actionPerformed(ActionEvent arg0) {\r | |
47 | // TODO Auto-generated method stub\r | |
48 | \r | |
49 | }\r | |
50 | \r | |
51 | /**\r | |
52 | Main class, used for test\r | |
53 | \r | |
54 | @param args\r | |
55 | \r | |
56 | **/\r | |
57 | public static void main(String[] args) {\r | |
58 | IDialog id = new IDialog();\r | |
59 | id.setVisible(true);\r | |
60 | }\r | |
61 | \r | |
62 | /**\r | |
63 | This is the default constructor\r | |
64 | **/\r | |
65 | public IDialog() {\r | |
66 | super();\r | |
67 | initialize();\r | |
68 | }\r | |
69 | \r | |
a13899c5 | 70 | /**\r |
71 | This is the override constructor\r | |
72 | \r | |
73 | @param parentFrame The parent frame which open the dialog\r | |
74 | @param modal true means the dialog is modal dialog; false means the dialog is not modal dialog\r | |
75 | **/\r | |
76 | public IDialog(IFrame parentFrame, boolean modal) {\r | |
77 | super(parentFrame, modal);\r | |
78 | initialize();\r | |
79 | }\r | |
8f9acbd7 | 80 | \r |
81 | /**\r | |
82 | This is the override constructor\r | |
83 | \r | |
84 | @param parentFrame The parent frame which open the dialog\r | |
85 | @param modal true means the dialog is modal dialog; false means the dialog is not modal dialog\r | |
86 | **/\r | |
87 | public IDialog(IDialog parentFrame, boolean modal) {\r | |
88 | super(parentFrame, modal);\r | |
89 | initialize();\r | |
90 | }\r | |
a13899c5 | 91 | \r |
92 | /**\r | |
93 | This method initializes this\r | |
94 | \r | |
95 | **/\r | |
96 | private void initialize() {\r | |
97 | this.setResizable(false);\r | |
98 | }\r | |
99 | \r | |
100 | /**\r | |
101 | Start the dialog at the center of screen\r | |
102 | \r | |
103 | @param intWidth The width of the dialog\r | |
104 | @param intHeight The height of the dialog\r | |
105 | \r | |
106 | **/\r | |
107 | protected void centerWindow(int intWidth, int intHeight) {\r | |
108 | Dimension d = Toolkit.getDefaultToolkit().getScreenSize();\r | |
109 | this.setLocation((d.width - intWidth) / 2, (d.height - intHeight) / 2);\r | |
110 | }\r | |
111 | \r | |
112 | /**\r | |
113 | Start the dialog at the center of screen\r | |
114 | \r | |
115 | **/\r | |
116 | protected void centerWindow() {\r | |
117 | centerWindow(this.getSize().width, this.getSize().height);\r | |
118 | }\r | |
119 | \r | |
120 | /**\r | |
121 | Get if the dialog has been edited\r | |
122 | \r | |
123 | @retval true - The dialog has been edited\r | |
124 | @retval false - The dialog hasn't been edited\r | |
125 | \r | |
126 | **/\r | |
127 | public boolean isEdited() {\r | |
128 | return isEdited;\r | |
129 | }\r | |
130 | \r | |
131 | /**\r | |
132 | Set if the dialog has been edited\r | |
133 | \r | |
134 | @param isEdited The input data which identify if the dialog has been edited\r | |
135 | \r | |
136 | **/\r | |
137 | public void setEdited(boolean isEdited) {\r | |
138 | this.isEdited = isEdited;\r | |
139 | }\r | |
140 | \r | |
141 | /**\r | |
142 | Check the input data is empty or not\r | |
143 | \r | |
144 | @param strValue The input data which need be checked\r | |
145 | \r | |
146 | @retval true - The input data is empty\r | |
147 | @retval fals - The input data is not empty\r | |
148 | \r | |
149 | **/\r | |
150 | public boolean isEmpty(String strValue) {\r | |
151 | if (strValue.length() > 0) {\r | |
152 | return false;\r | |
153 | }\r | |
154 | return true;\r | |
155 | }\r | |
156 | \r | |
157 | /**\r | |
158 | Display the dialog\r | |
159 | \r | |
160 | **/\r | |
161 | public int showDialog() {\r | |
162 | this.setVisible(true);\r | |
163 | return returnType;\r | |
164 | }\r | |
165 | }\r |