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 //---------------------------------------------------------------------------------------//
102 public boolean getOption(String item) {
103 if (item.matches("file")) {
108 public void actionPerformed(ActionEvent e
) {
109 if ( e
.getSource() == moduleButton
) {
110 int ret
= fc
.showOpenDialog(this);
111 if (ret
== JFileChooser
.APPROVE_OPTION
) {
112 modulepath
= fc
.getSelectedFile().getAbsolutePath();
113 moduletext
.setText(modulepath
);
114 log
.append("ModulePath: " + modulepath
+ "\n");
117 if ( e
.getSource() == goButton
) {
119 logfile
= new PrintWriter(new BufferedWriter(new FileWriter(modulepath
+ File
.separator
+ "migration.log")));
120 println("Project MsaGen");
121 println("Copyright (c) 2006, Intel Corporation");
122 new ModuleInfo(modulepath
, this, new Database());
124 } catch (Exception en
) {
125 println(en
.getMessage());
130 public void itemStateChanged(ItemEvent e
) {
131 if (e
.getStateChange() == ItemEvent
.DESELECTED
) {
132 System
.out
.println("changed");
136 //---------------------------------------------------------------------------------------//
138 public static void init() throws Exception
{
140 //UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
141 UIManager
.setLookAndFeel(UIManager
.getSystemLookAndFeelClassName());
142 //UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");
143 //UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
144 //UIManager.setLookAndFeel("com.sun.java.swing.plaf.gtk.GTKLookAndFeel");
145 //UIManager.setLookAndFeel("com.sun.java.swing.plaf.motif.MotifLookAndFeel");
147 JFrame frame
= new JFrame("MigrationTools");
148 frame
.setDefaultCloseOperation(JFrame
.EXIT_ON_CLOSE
);
150 FirstPanel fp
= new FirstPanel();
151 fp
.setLayout(new BoxLayout(fp
, BoxLayout
.Y_AXIS
));
153 frame
.setContentPane(fp
);
155 frame
.setSize(800,600);
156 frame
.setVisible(true);