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