]> git.proxmox.com Git - mirror_edk2.git/blob - Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/GenLongTextDialog.java
Changed spelling to manifest
[mirror_edk2.git] / Tools / Source / FrameworkWizard / src / org / tianocore / frameworkwizard / platform / ui / GenLongTextDialog.java
1 /** @file
2 Java class GenLongTextDialog.
3
4 Copyright (c) 2006, Intel Corporation
5 All rights reserved. This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
9
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12 **/
13 package org.tianocore.frameworkwizard.platform.ui;
14
15 import java.awt.BorderLayout;
16 import java.awt.Dimension;
17 import java.awt.Toolkit;
18
19 import javax.swing.JComponent;
20 import javax.swing.JPanel;
21 import javax.swing.JDialog;
22 import javax.swing.JTextArea;
23 import javax.swing.JButton;
24 import javax.swing.KeyStroke;
25
26 import java.awt.FlowLayout;
27 import java.awt.event.ActionEvent;
28 import java.awt.event.ActionListener;
29 import java.awt.event.KeyEvent;
30
31 import javax.swing.JScrollPane;
32
33
34
35 /**
36 Dialog for Long Text generation.
37 @since PackageEditor 1.0
38 **/
39 public class GenLongTextDialog extends JDialog implements ActionListener{
40
41 /**
42 *
43 */
44 private static final long serialVersionUID = 1L;
45
46 private JPanel jContentPane = null;
47 private JPanel jPanelContentEast = null;
48 private JPanel jPanelContentCenter = null;
49 private JButton jButtonCancel = null;
50 private JButton jButtonOk = null;
51 private JTextArea jTextArea = null;
52
53
54 private JScrollPane jScrollPane = null;
55
56 public void actionPerformed(ActionEvent arg0) {
57
58 if (arg0.getSource() == jButtonOk){
59
60 // this.dispose();
61 }
62
63 if (arg0.getSource() == jButtonCancel){
64 this.dispose();
65 }
66 }
67
68 /**
69 * This method initializes jPanel
70 *
71 * @return javax.swing.JPanel
72 */
73 private JPanel getJPanelContentEast() {
74 if (jPanelContentEast == null) {
75 FlowLayout flowLayout = new FlowLayout();
76 flowLayout.setVgap(5);
77 flowLayout.setAlignment(java.awt.FlowLayout.RIGHT);
78 jPanelContentEast = new JPanel();
79 jPanelContentEast.setLayout(flowLayout);
80 jPanelContentEast.setPreferredSize(new java.awt.Dimension(100,30));
81 jPanelContentEast.add(getJButtonOk(), null);
82 jPanelContentEast.add(getJButtonCancel(), null);
83 }
84 return jPanelContentEast;
85 }
86
87 /**
88 * This method initializes jPanel4
89 *
90 * @return javax.swing.JPanel
91 */
92 private JPanel getJPanelContentCenter() {
93 if (jPanelContentCenter == null) {
94 jPanelContentCenter = new JPanel();
95 jPanelContentCenter.setLayout(new FlowLayout());
96 jPanelContentCenter.add(getJScrollPane(), null);
97
98 }
99 return jPanelContentCenter;
100 }
101
102 /**
103 * This method initializes jButton
104 *
105 * @return javax.swing.JButton
106 */
107 private JButton getJButtonCancel() {
108 if (jButtonCancel == null) {
109 jButtonCancel = new JButton();
110 jButtonCancel.setPreferredSize(new java.awt.Dimension(80,20));
111 jButtonCancel.setText("Cancel");
112 jButtonCancel.addActionListener(this);
113 jButtonCancel.registerKeyboardAction(this, KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0, false), JComponent.WHEN_FOCUSED);
114 }
115 return jButtonCancel;
116 }
117
118 /**
119 * This method initializes jButton2
120 *
121 * @return javax.swing.JButton
122 */
123 private JButton getJButtonOk() {
124 if (jButtonOk == null) {
125 jButtonOk = new JButton();
126 jButtonOk.setPreferredSize(new java.awt.Dimension(80,20));
127 jButtonOk.setText("Ok");
128 jButtonOk.setActionCommand("GenGuidValue");
129 jButtonOk.addActionListener(this);
130 }
131 return jButtonOk;
132 }
133
134 /**
135 * This method initializes jScrollPane
136 *
137 * @return javax.swing.JScrollPane
138 */
139 private JScrollPane getJScrollPane() {
140 if (jScrollPane == null) {
141 jScrollPane = new JScrollPane();
142 jScrollPane.setPreferredSize(new java.awt.Dimension(600,40));
143 jScrollPane.setViewportView(getJTextArea());
144 }
145 return jScrollPane;
146 }
147
148 private JTextArea getJTextArea() {
149 if (jTextArea == null) {
150 jTextArea = new JTextArea();
151 // jTextArea.setBounds(new java.awt.Rectangle(40,20,300,54));
152
153 }
154 return jTextArea;
155 }
156
157
158 public String getText(){
159
160 return jTextArea.getText();
161 }
162
163 public void setText(String s){
164 jTextArea.setText(s);
165 }
166 /**
167 * This is the default constructor
168 */
169 public GenLongTextDialog() {
170 super();
171 initialize();
172 }
173
174 public GenLongTextDialog(ActionListener i){
175 this();
176 jButtonOk.addActionListener(i);
177 jButtonOk.registerKeyboardAction(i, KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0, false), JComponent.WHEN_FOCUSED);
178 }
179
180 /**
181 * This method initializes this
182 *
183 * @return void
184 */
185 private void initialize() {
186 this.setSize(620, 120);
187 this.setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
188 this.setModal(true);
189 this.setTitle("Text Content");
190 this.setContentPane(getJContentPane());
191 this.centerWindow();
192 }
193
194 /**
195 * This method initializes jContentPane
196 *
197 * @return javax.swing.JPanel
198 */
199 private JPanel getJContentPane() {
200 if (jContentPane == null) {
201 jContentPane = new JPanel();
202 jContentPane.setLayout(new BorderLayout());
203 jContentPane.add(getJPanelContentEast(), java.awt.BorderLayout.SOUTH);
204 jContentPane.add(getJPanelContentCenter(), java.awt.BorderLayout.CENTER);
205 }
206 return jContentPane;
207 }
208
209 /**
210 Start the window at the center of screen
211
212 **/
213 protected void centerWindow(int intWidth, int intHeight) {
214 Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
215 this.setLocation((d.width - intWidth) / 2, (d.height - intHeight) / 2);
216 }
217
218 /**
219 Start the window at the center of screen
220
221 **/
222 protected void centerWindow() {
223 centerWindow(this.getSize().width, this.getSize().height);
224 }
225
226
227
228 } // @jve:decl-index=0:visual-constraint="10,10"