1 package org
.tianocore
.migration
;
4 import java
.awt
.event
.*;
9 public class FirstPanel
extends JPanel
implements ActionListener
, UI
{
11 * Define class Serial Version UID
13 private static final long serialVersionUID
= 207759413522910399L;
15 private String modulepath
;
17 private JButton moduleButton
, goButton
;
18 private JTextField moduletext
;
19 private JTextArea log
;
20 private JFileChooser fc
;
21 private JCheckBox filebox
, screenbox
;
23 private boolean tofile
= true, toscreen
= true;
24 private PrintWriter logfile
;
26 FirstPanel() throws Exception
{
27 goButton
= new JButton("Go");
28 goButton
.addActionListener(this);
29 goButton
.setActionCommand("go");
31 moduleButton
= new JButton("Choose ModulePath");
32 moduleButton
.addActionListener(this);
34 moduletext
= new JTextField(30);
36 filebox
= new JCheckBox("Output to logfile", true);
37 screenbox
= new JCheckBox("Specify logfile", false);
39 JPanel modulePanel
= new JPanel();
40 modulePanel
.add(moduleButton
);
41 modulePanel
.add(moduletext
);
42 modulePanel
.add(filebox
);
43 modulePanel
.add(screenbox
);
44 modulePanel
.add(goButton
);
47 log
= new JTextArea(50,25);
48 log
.setMargin(new Insets(5,5,5,5));
49 log
.setEditable(false);
50 JScrollPane logScrollPane
= new JScrollPane(log
);
53 fc
= new JFileChooser();
54 fc
.setFileSelectionMode(JFileChooser
.FILES_AND_DIRECTORIES
);
57 //---------------------------------------------------------------------------------------//
59 public boolean yesOrNo(String question
) {
60 return JOptionPane
.showConfirmDialog(this, question
, "Yes or No", JOptionPane
.YES_NO_OPTION
) == JOptionPane
.YES_OPTION
;
63 public void print(String message
) {
64 if (toscreen
== true) {
66 System
.out
.print(message
);
69 logfile
.append(message
);
73 public void println(String message
) {
74 print(message
+ "\n");
77 public void println(Set
<String
> hash
) {
78 if (toscreen
== true) {
79 log
.append(hash
+ "\n");
80 System
.out
.println(hash
);
83 logfile
.append(hash
+ "\n");
87 //---------------------------------------------------------------------------------------//
90 public boolean getOption(String item) {
91 if (item.matches("file")) {
96 public void actionPerformed(ActionEvent e
) {
97 if ( e
.getSource() == moduleButton
) {
98 int ret
= fc
.showOpenDialog(this);
99 if (ret
== JFileChooser
.APPROVE_OPTION
) {
100 modulepath
= fc
.getSelectedFile().getAbsolutePath();
101 moduletext
.setText(modulepath
);
102 log
.append("ModulePath: " + modulepath
+ "\n");
105 if ( e
.getSource() == goButton
) {
107 logfile
= new PrintWriter(new BufferedWriter(new FileWriter(modulepath
+ File
.separator
+ "migration.log")));
108 println("Project MsaGen");
109 println("Copyright (c) 2006, Intel Corporation");
110 new ModuleInfo(modulepath
, this, new Database());
112 } catch (Exception en
) {
113 println(en
.getMessage());
118 public void itemStateChanged(ItemEvent e
) {
119 if (e
.getStateChange() == ItemEvent
.DESELECTED
) {
120 System
.out
.println("changed");
124 //---------------------------------------------------------------------------------------//
126 public static void init() throws Exception
{
127 JFrame
.setDefaultLookAndFeelDecorated(true);
128 JFrame frame
= new JFrame("FrameDemo");
129 frame
.setDefaultCloseOperation(JFrame
.EXIT_ON_CLOSE
);
131 FirstPanel fp
= new FirstPanel();
132 fp
.setLayout(new BoxLayout(fp
, BoxLayout
.Y_AXIS
));
134 frame
.setContentPane(fp
);
136 frame
.setSize(800,600);
137 frame
.setVisible(true);