]> git.proxmox.com Git - mirror_edk2.git/blob - Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/far/createui/CreateStepThree.java
1. Adjust UI for far operations
[mirror_edk2.git] / Tools / Source / FrameworkWizard / src / org / tianocore / frameworkwizard / far / createui / CreateStepThree.java
1 /** @file
2
3 Copyright (c) 2006, Intel Corporation
4 All rights reserved. This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
8
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
11
12 **/
13 package org.tianocore.frameworkwizard.far.createui;
14
15 import java.awt.event.MouseEvent;
16 import java.awt.event.MouseListener;
17 import java.util.Iterator;
18 import java.util.LinkedHashSet;
19 import java.util.Set;
20 import java.util.Vector;
21
22 import javax.swing.JPanel;
23 import javax.swing.JTextArea;
24 import javax.swing.JButton;
25 import javax.swing.JLabel;
26
27 import org.tianocore.frameworkwizard.common.ui.IDialog;
28 import org.tianocore.frameworkwizard.common.ui.iCheckBoxList.ICheckBoxList;
29 import javax.swing.JScrollPane;
30 import javax.swing.JTextField;
31
32 public class CreateStepThree extends IDialog implements MouseListener {
33
34 /**
35 *
36 */
37 private static final long serialVersionUID = 7559888600474043337L;
38
39 private JPanel jContentPane = null;
40
41 private JTextArea jTextArea = null;
42
43 private JButton jButtonNext = null;
44
45 private JButton jButtonCancel = null;
46
47 private JButton jButtonPrevious = null;
48
49 private JLabel jLabel = null;
50
51 private ICheckBoxList jComboBoxFileFilter = null;
52
53 private JScrollPane jScrollPane = null;
54
55 private JLabel jLabel1 = null;
56
57 private JTextField jTextField = null;
58
59 Vector<String> v = new Vector<String>();
60
61 private CreateStepTwo stepTwo = null;
62
63 private CreateStepFour stepFour = null;
64
65 public CreateStepThree(IDialog iDialog, boolean modal, CreateStepTwo stepTwo) {
66 this(iDialog, modal);
67 this.stepTwo = stepTwo;
68 }
69
70 /**
71 * This method initializes jTextArea
72 *
73 * @return javax.swing.JTextArea
74 */
75 private JTextArea getJTextArea() {
76 if (jTextArea == null) {
77 jTextArea = new JTextArea();
78 jTextArea.setBounds(new java.awt.Rectangle(30, 7, 642, 50));
79 jTextArea.setText("Step 2: Set File Filter\n");
80 jTextArea.append("Add more file filter regular expressions in text field separated with space. \n");
81 jTextArea.append("Note that regular expressions please reference PERL language. ");
82 jTextArea.setEditable(false);
83 }
84 return jTextArea;
85 }
86
87 /**
88 * This method initializes jButtonNext
89 *
90 * @return javax.swing.JButton
91 */
92 private JButton getJButtonNext() {
93 if (jButtonNext == null) {
94 jButtonNext = new JButton();
95 jButtonNext.setBounds(new java.awt.Rectangle(470, 330, 90, 20));
96 jButtonNext.setText("Next");
97 jButtonNext.addMouseListener(this);
98 }
99 return jButtonNext;
100 }
101
102 /**
103 * This method initializes jButtonCancel
104 *
105 * @return javax.swing.JButton
106 */
107 private JButton getJButtonCancel() {
108 if (jButtonCancel == null) {
109 jButtonCancel = new JButton();
110 jButtonCancel.setBounds(new java.awt.Rectangle(570, 330, 90, 20));
111 jButtonCancel.setText("Cancel");
112 jButtonCancel.addMouseListener(this);
113 }
114 return jButtonCancel;
115 }
116
117 /**
118 * This method initializes jButtonPrevious
119 *
120 * @return javax.swing.JButton
121 */
122 private JButton getJButtonPrevious() {
123 if (jButtonPrevious == null) {
124 jButtonPrevious = new JButton();
125 jButtonPrevious.setBounds(new java.awt.Rectangle(370, 330, 90, 20));
126 jButtonPrevious.setText("Previous");
127 jButtonPrevious.addMouseListener(this);
128 }
129 return jButtonPrevious;
130 }
131
132 /**
133 * This method initializes jComboBox
134 *
135 * @return javax.swing.JComboBox
136 */
137 private ICheckBoxList getJComboBoxFileFilter() {
138 if (jComboBoxFileFilter == null) {
139 jComboBoxFileFilter = new ICheckBoxList();
140 v.addElement(".svn");
141 v.addElement("CVS");
142 jComboBoxFileFilter.setAllItems(v);
143 jComboBoxFileFilter.initCheckedItem(true, v);
144 }
145 return jComboBoxFileFilter;
146 }
147
148 /**
149 * This method initializes jScrollPane
150 *
151 * @return javax.swing.JScrollPane
152 */
153 private JScrollPane getJScrollPane() {
154 if (jScrollPane == null) {
155 jScrollPane = new JScrollPane();
156 jScrollPane.setBounds(new java.awt.Rectangle(30, 85, 640, 130));
157 jScrollPane.setViewportView(getJComboBoxFileFilter());
158 }
159 return jScrollPane;
160 }
161
162 /**
163 * This method initializes jTextField
164 *
165 * @return javax.swing.JTextField
166 */
167 private JTextField getJTextField() {
168 if (jTextField == null) {
169 jTextField = new JTextField();
170 jTextField.setBounds(new java.awt.Rectangle(30, 250, 640, 20));
171 }
172 return jTextField;
173 }
174
175 /**
176 * @param args
177 */
178 public static void main(String[] args) {
179 // TODO Auto-generated method stub
180 }
181
182 /**
183 * This is the default constructor
184 */
185 public CreateStepThree(IDialog iDialog, boolean modal) {
186 super(iDialog, modal);
187 initialize();
188 }
189
190 /**
191 * This method initializes this
192 *
193 * @return void
194 */
195 private void initialize() {
196 this.setSize(700, 400);
197 this.setContentPane(getJContentPane());
198 this.setTitle("Create Framework Archive(FAR) - Step 3: Set File Filter");
199 this.centerWindow();
200 }
201
202 /**
203 * This method initializes jContentPane
204 *
205 * @return javax.swing.JPanel
206 */
207 private JPanel getJContentPane() {
208 if (jContentPane == null) {
209 jLabel1 = new JLabel();
210 jLabel1.setBounds(new java.awt.Rectangle(30, 220, 260, 20));
211 jLabel1.setText("Input File Filter Pattern (Ref to ...)");
212 jLabel = new JLabel();
213 jLabel.setBounds(new java.awt.Rectangle(30, 64, 160, 20));
214 jLabel.setText("File Filter Pattern: ");
215 jContentPane = new JPanel();
216 jContentPane.setLayout(null);
217 jContentPane.add(getJTextArea(), null);
218 jContentPane.add(getJButtonNext(), null);
219 jContentPane.add(getJButtonCancel(), null);
220 jContentPane.add(getJButtonPrevious(), null);
221 jContentPane.add(jLabel, null);
222 jContentPane.add(getJScrollPane(), null);
223 jContentPane.add(jLabel1, null);
224 jContentPane.add(getJTextField(), null);
225 }
226 return jContentPane;
227 }
228
229 public void mouseClicked(MouseEvent e) {
230 if (e.getSource() == jButtonCancel) {
231 this.setVisible(false);
232 } else if (e.getSource() == jButtonNext) {
233 //
234 // Add some logic process here
235 //
236
237 if (stepFour == null) {
238 stepFour = new CreateStepFour(this, true, this);
239 stepFour.setVisible(true);
240 } else {
241 stepFour.setVisible(true);
242 }
243 this.setVisible(false);
244 } else if (e.getSource() == jButtonPrevious) {
245 this.setVisible(false);
246 stepTwo.setVisible(true);
247 }
248 }
249
250 public void mousePressed(MouseEvent e) {
251 // TODO Auto-generated method stub
252
253 }
254
255 public void mouseReleased(MouseEvent e) {
256 // TODO Auto-generated method stub
257
258 }
259
260 public void mouseEntered(MouseEvent e) {
261 // TODO Auto-generated method stub
262
263 }
264
265 public void mouseExited(MouseEvent e) {
266 // TODO Auto-generated method stub
267
268 }
269
270 public Set<String> getFileFilter() {
271 Set<String> result = new LinkedHashSet<String>();
272 Vector<Integer> selected = jComboBoxFileFilter.getAllCheckedItemsIndex();
273
274 Iterator<Integer> iter = selected.iterator();
275
276 while (iter.hasNext()) {
277 result.add(v.get(iter.next().intValue()));
278 }
279
280 String[] userdefined = jTextField.getText().split(" ");
281
282 for (int i = 0; i < userdefined.length; i++) {
283 if (!userdefined[i].trim().equalsIgnoreCase("")) {
284 result.add(userdefined[i]);
285 }
286 }
287
288 return result;
289 }
290
291 public CreateStepTwo getPreviousStep() {
292 return stepTwo;
293 }
294 }