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
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.
13 package org
.tianocore
.migration
;
16 import java
.awt
.event
.*;
21 public class FirstPanel
extends JPanel
implements ActionListener
, UI
{
23 * Define class Serial Version UID
25 private static final long serialVersionUID
= 207759413522910399L;
27 private String modulepath
;
29 private JButton moduleButton
, goButton
;
30 private JTextField moduletext
;
31 private JTextArea log
;
32 private JFileChooser fc
;
33 private JCheckBox filebox
, screenbox
;
35 private boolean tofile
= true, toscreen
= true;
36 private PrintWriter logfile
;
38 FirstPanel() throws Exception
{
39 goButton
= new JButton("Go");
40 goButton
.addActionListener(this);
41 goButton
.setActionCommand("go");
43 moduleButton
= new JButton("Choose ModulePath");
44 moduleButton
.addActionListener(this);
46 moduletext
= new JTextField(30);
48 filebox
= new JCheckBox("Output to logfile", true);
49 screenbox
= new JCheckBox("Specify logfile", false);
51 JPanel modulePanel
= new JPanel();
52 modulePanel
.add(moduleButton
);
53 modulePanel
.add(moduletext
);
54 modulePanel
.add(filebox
);
55 modulePanel
.add(screenbox
);
56 modulePanel
.add(goButton
);
59 log
= new JTextArea(50,25);
60 log
.setMargin(new Insets(5,5,5,5));
61 log
.setEditable(false);
62 JScrollPane logScrollPane
= new JScrollPane(log
);
65 fc
= new JFileChooser();
66 fc
.setFileSelectionMode(JFileChooser
.FILES_AND_DIRECTORIES
);
69 //---------------------------------------------------------------------------------------//
71 public boolean yesOrNo(String question
) {
72 return JOptionPane
.showConfirmDialog(this, question
, "Yes or No", JOptionPane
.YES_NO_OPTION
) == JOptionPane
.YES_OPTION
;
75 public void print(String message
) {
76 if (toscreen
== true) {
78 System
.out
.print(message
);
81 logfile
.append(message
);
85 public void println(String message
) {
86 print(message
+ "\n");
89 public void println(Set
<String
> hash
) {
90 if (toscreen
== true) {
91 log
.append(hash
+ "\n");
92 System
.out
.println(hash
);
95 logfile
.append(hash
+ "\n");
99 public String
choose(String message
, Object
[] choicelist
) {
100 return (String
)JOptionPane
.showInputDialog(this, message
,"Choose",JOptionPane
.PLAIN_MESSAGE
,null,choicelist
,choicelist
[0]);
103 //---------------------------------------------------------------------------------------//
106 public boolean getOption(String item) {
107 if (item.matches("file")) {
112 public void actionPerformed(ActionEvent e
) {
113 if ( e
.getSource() == moduleButton
) {
114 int ret
= fc
.showOpenDialog(this);
115 if (ret
== JFileChooser
.APPROVE_OPTION
) {
116 modulepath
= fc
.getSelectedFile().getAbsolutePath();
117 moduletext
.setText(modulepath
);
118 log
.append("ModulePath: " + modulepath
+ "\n");
121 if ( e
.getSource() == goButton
) {
123 logfile
= new PrintWriter(new BufferedWriter(new FileWriter(modulepath
+ File
.separator
+ "migration.log")));
124 println("Project MsaGen");
125 println("Copyright (c) 2006, Intel Corporation");
126 new ModuleInfo(modulepath
, this, new Database());
128 } catch (Exception en
) {
129 println(en
.getMessage());
134 public void itemStateChanged(ItemEvent e
) {
135 if (e
.getStateChange() == ItemEvent
.DESELECTED
) {
136 System
.out
.println("changed");
140 //---------------------------------------------------------------------------------------//
142 public static void init() throws Exception
{
144 //UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
145 UIManager
.setLookAndFeel(UIManager
.getSystemLookAndFeelClassName());
146 //UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");
147 //UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
148 //UIManager.setLookAndFeel("com.sun.java.swing.plaf.gtk.GTKLookAndFeel");
149 //UIManager.setLookAndFeel("com.sun.java.swing.plaf.motif.MotifLookAndFeel");
151 JFrame frame
= new JFrame("MigrationTools");
152 frame
.setDefaultCloseOperation(JFrame
.EXIT_ON_CLOSE
);
154 FirstPanel fp
= new FirstPanel();
155 fp
.setLayout(new BoxLayout(fp
, BoxLayout
.Y_AXIS
));
157 frame
.setContentPane(fp
);
159 frame
.setSize(800,600);
160 frame
.setVisible(true);