]> git.proxmox.com Git - mirror_edk2.git/blob - Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/GenListDialog.java
change table column positions in tables of FrameworkModules and horizontal scrollbar...
[mirror_edk2.git] / Tools / Source / FrameworkWizard / src / org / tianocore / frameworkwizard / platform / ui / GenListDialog.java
1 /** @file
2 Java class GenListDialog.
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
22 import javax.swing.JButton;
23
24
25 import java.awt.FlowLayout;
26 import java.awt.event.ActionEvent;
27 import java.awt.event.ActionListener;
28 import java.util.Vector;
29
30 import javax.swing.JScrollPane;
31
32 import org.tianocore.frameworkwizard.common.ui.iCheckBoxList.ICheckBoxList;
33
34
35 /**
36 Dialog for List generation.
37 @since PackageEditor 1.0
38 **/
39 public class GenListDialog 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 ICheckBoxList checkBoxList = null;
52
53
54 private JScrollPane jScrollPane = null;
55
56
57
58 public void actionPerformed(ActionEvent arg0) {
59
60 if (arg0.getSource() == jButtonOk){
61
62 this.dispose();
63 }
64
65 if (arg0.getSource() == jButtonCancel){
66 this.dispose();
67 }
68 }
69
70 /**
71 * This method initializes jPanel
72 *
73 * @return javax.swing.JPanel
74 */
75 private JPanel getJPanelContentEast() {
76 if (jPanelContentEast == null) {
77 FlowLayout flowLayout = new FlowLayout();
78 flowLayout.setVgap(10);
79 jPanelContentEast = new JPanel();
80 jPanelContentEast.setLayout(flowLayout);
81 jPanelContentEast.setPreferredSize(new java.awt.Dimension(100,30));
82 jPanelContentEast.add(getJButtonOk(), null);
83 jPanelContentEast.add(getJButtonCancel(), null);
84 }
85 return jPanelContentEast;
86 }
87
88 /**
89 * This method initializes jPanel4
90 *
91 * @return javax.swing.JPanel
92 */
93 private JPanel getJPanelContentCenter() {
94 if (jPanelContentCenter == null) {
95 jPanelContentCenter = new JPanel();
96 jPanelContentCenter.setLayout(new FlowLayout());
97 jPanelContentCenter.add(getJScrollPane(), null);
98
99 }
100 return jPanelContentCenter;
101 }
102
103 /**
104 * This method initializes jButton
105 *
106 * @return javax.swing.JButton
107 */
108 private JButton getJButtonCancel() {
109 if (jButtonCancel == null) {
110 jButtonCancel = new JButton();
111 jButtonCancel.setPreferredSize(new java.awt.Dimension(80,20));
112 jButtonCancel.setText("Cancel");
113 jButtonCancel.addActionListener(this);
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(300,100));
143 jScrollPane.setViewportView(getICheckBoxList());
144 }
145 return jScrollPane;
146 }
147
148 private ICheckBoxList getICheckBoxList() {
149 if (checkBoxList == null) {
150 checkBoxList = new ICheckBoxList();
151 checkBoxList.setBounds(new java.awt.Rectangle(40,20,177,74));
152
153 }
154 return checkBoxList;
155 }
156
157 public void initList(Vector<String> v){
158 checkBoxList.setAllItems(v);
159 }
160 public Vector<String> getList(){
161 Vector<String> v = checkBoxList.getAllCheckedItemsString();
162 return v;
163 }
164
165 public void setList(String s){
166 Vector<String> v = new Vector<String>();
167 if (s == null) {
168 checkBoxList.setAllItemsUnchecked();
169 return;
170 }
171 String[] sArray = s.split(" ");
172 for (int i = 0; i < sArray.length; ++i){
173 v.add(sArray[i]);
174 }
175 checkBoxList.initCheckedItem(true, v);
176 }
177 /**
178 * This is the default constructor
179 */
180 public GenListDialog() {
181 super();
182 initialize();
183 }
184
185 public GenListDialog(ActionListener i){
186 this();
187 jButtonOk.addActionListener(i);
188
189 }
190
191 /**
192 * This method initializes this
193 *
194 * @return void
195 */
196 private void initialize() {
197 this.setSize(466, 157);
198 this.setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
199 this.setModal(true);
200 this.setTitle("List");
201 this.setContentPane(getJContentPane());
202 this.centerWindow();
203 }
204
205 /**
206 * This method initializes jContentPane
207 *
208 * @return javax.swing.JPanel
209 */
210 private JPanel getJContentPane() {
211 if (jContentPane == null) {
212 jContentPane = new JPanel();
213 jContentPane.setLayout(new BorderLayout());
214 jContentPane.add(getJPanelContentEast(), java.awt.BorderLayout.EAST);
215 jContentPane.add(getJPanelContentCenter(), java.awt.BorderLayout.CENTER);
216 }
217 return jContentPane;
218 }
219
220 /**
221 Start the window at the center of screen
222
223 **/
224 protected void centerWindow(int intWidth, int intHeight) {
225 Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
226 this.setLocation((d.width - intWidth) / 2, (d.height - intHeight) / 2);
227 }
228
229 /**
230 Start the window at the center of screen
231
232 **/
233 protected void centerWindow() {
234 centerWindow(this.getSize().width, this.getSize().height);
235 }
236
237
238
239 } // @jve:decl-index=0:visual-constraint="10,10"