For long text display for table cell.
[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.JPanel;
20 import javax.swing.JDialog;
21 import javax.swing.JTextArea;
22 import javax.swing.JButton;
23 import java.awt.FlowLayout;
24 import java.awt.event.ActionEvent;
25 import java.awt.event.ActionListener;
26 import javax.swing.JScrollPane;
27
28
29
30 /**
31 Dialog for Long Text generation.
32 @since PackageEditor 1.0
33 **/
34 public class GenLongTextDialog extends JDialog implements ActionListener{
35
36 /**
37 *
38 */
39 private static final long serialVersionUID = 1L;
40
41 private JPanel jContentPane = null;
42 private JPanel jPanelContentEast = null;
43 private JPanel jPanelContentCenter = null;
44 private JButton jButtonCancel = null;
45 private JButton jButtonOk = null;
46 private JTextArea jTextArea = null;
47
48
49 private JScrollPane jScrollPane = null;
50
51
52
53 public void actionPerformed(ActionEvent arg0) {
54
55 if (arg0.getSource() == jButtonOk){
56
57 this.dispose();
58 }
59
60 if (arg0.getSource() == jButtonCancel){
61 this.dispose();
62 }
63 }
64
65 /**
66 * This method initializes jPanel
67 *
68 * @return javax.swing.JPanel
69 */
70 private JPanel getJPanelContentEast() {
71 if (jPanelContentEast == null) {
72 FlowLayout flowLayout = new FlowLayout();
73 flowLayout.setVgap(5);
74 flowLayout.setAlignment(java.awt.FlowLayout.RIGHT);
75 jPanelContentEast = new JPanel();
76 jPanelContentEast.setLayout(flowLayout);
77 jPanelContentEast.setPreferredSize(new java.awt.Dimension(100,30));
78 jPanelContentEast.add(getJButtonOk(), null);
79 jPanelContentEast.add(getJButtonCancel(), null);
80 }
81 return jPanelContentEast;
82 }
83
84 /**
85 * This method initializes jPanel4
86 *
87 * @return javax.swing.JPanel
88 */
89 private JPanel getJPanelContentCenter() {
90 if (jPanelContentCenter == null) {
91 jPanelContentCenter = new JPanel();
92 jPanelContentCenter.setLayout(new FlowLayout());
93 jPanelContentCenter.add(getJScrollPane(), null);
94
95 }
96 return jPanelContentCenter;
97 }
98
99 /**
100 * This method initializes jButton
101 *
102 * @return javax.swing.JButton
103 */
104 private JButton getJButtonCancel() {
105 if (jButtonCancel == null) {
106 jButtonCancel = new JButton();
107 jButtonCancel.setPreferredSize(new java.awt.Dimension(80,20));
108 jButtonCancel.setText("Cancel");
109 jButtonCancel.addActionListener(this);
110 }
111 return jButtonCancel;
112 }
113
114 /**
115 * This method initializes jButton2
116 *
117 * @return javax.swing.JButton
118 */
119 private JButton getJButtonOk() {
120 if (jButtonOk == null) {
121 jButtonOk = new JButton();
122 jButtonOk.setPreferredSize(new java.awt.Dimension(80,20));
123 jButtonOk.setText("Ok");
124 jButtonOk.setActionCommand("GenGuidValue");
125 jButtonOk.addActionListener(this);
126 }
127 return jButtonOk;
128 }
129
130 /**
131 * This method initializes jScrollPane
132 *
133 * @return javax.swing.JScrollPane
134 */
135 private JScrollPane getJScrollPane() {
136 if (jScrollPane == null) {
137 jScrollPane = new JScrollPane();
138 jScrollPane.setPreferredSize(new java.awt.Dimension(600,40));
139 jScrollPane.setViewportView(getJTextArea());
140 }
141 return jScrollPane;
142 }
143
144 private JTextArea getJTextArea() {
145 if (jTextArea == null) {
146 jTextArea = new JTextArea();
147 // jTextArea.setBounds(new java.awt.Rectangle(40,20,300,54));
148
149 }
150 return jTextArea;
151 }
152
153
154 public String getText(){
155
156 return jTextArea.getText();
157 }
158
159 public void setText(String s){
160 jTextArea.setText(s);
161 }
162 /**
163 * This is the default constructor
164 */
165 public GenLongTextDialog() {
166 super();
167 initialize();
168 }
169
170 public GenLongTextDialog(ActionListener i){
171 this();
172 jButtonOk.addActionListener(i);
173
174 }
175
176 /**
177 * This method initializes this
178 *
179 * @return void
180 */
181 private void initialize() {
182 this.setSize(620, 120);
183 this.setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
184 this.setModal(true);
185 this.setTitle("Text Content");
186 this.setContentPane(getJContentPane());
187 this.centerWindow();
188 }
189
190 /**
191 * This method initializes jContentPane
192 *
193 * @return javax.swing.JPanel
194 */
195 private JPanel getJContentPane() {
196 if (jContentPane == null) {
197 jContentPane = new JPanel();
198 jContentPane.setLayout(new BorderLayout());
199 jContentPane.add(getJPanelContentEast(), java.awt.BorderLayout.SOUTH);
200 jContentPane.add(getJPanelContentCenter(), java.awt.BorderLayout.CENTER);
201 }
202 return jContentPane;
203 }
204
205 /**
206 Start the window at the center of screen
207
208 **/
209 protected void centerWindow(int intWidth, int intHeight) {
210 Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
211 this.setLocation((d.width - intWidth) / 2, (d.height - intHeight) / 2);
212 }
213
214 /**
215 Start the window at the center of screen
216
217 **/
218 protected void centerWindow() {
219 centerWindow(this.getSize().width, this.getSize().height);
220 }
221
222
223
224 } // @jve:decl-index=0:visual-constraint="10,10"