]> git.proxmox.com Git - mirror_edk2.git/blame - Tools/Source/MigrationTools/org/tianocore/migration/FirstPanel.java
Fix PCD declaration error in DxeStatusCode.msa
[mirror_edk2.git] / Tools / Source / MigrationTools / org / tianocore / migration / FirstPanel.java
CommitLineData
b0282412 1/** @file\r
2 \r
3 Copyright (c) 2006, Intel Corporation\r
4 All rights reserved. This program and the accompanying materials\r
5 are licensed and made available under the terms and conditions of the BSD License\r
6 which accompanies this distribution. The full text of the license may be found at\r
7 http://opensource.org/licenses/bsd-license.php\r
8 \r
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
11 \r
12 **/\r
0dc8c589 13package org.tianocore.migration;\r
14\r
15import java.awt.*;\r
16import java.awt.event.*;\r
17import java.io.*;\r
18import java.util.*;\r
19import javax.swing.*;\r
20\r
21public class FirstPanel extends JPanel implements ActionListener, UI {\r
22 /**\r
23 * Define class Serial Version UID\r
24 */\r
25 private static final long serialVersionUID = 207759413522910399L;\r
26 \r
27 private String modulepath;\r
28 \r
29 private JButton moduleButton , goButton;\r
30 private JTextField moduletext;\r
31 private JTextArea log;\r
32 private JFileChooser fc;\r
33 private JCheckBox filebox, screenbox;\r
34 \r
35 private boolean tofile = true, toscreen = true;\r
36 private PrintWriter logfile;\r
37\r
38 FirstPanel() throws Exception {\r
39 goButton = new JButton("Go");\r
40 goButton.addActionListener(this);\r
41 goButton.setActionCommand("go");\r
42 \r
43 moduleButton = new JButton("Choose ModulePath");\r
44 moduleButton.addActionListener(this);\r
45\r
46 moduletext = new JTextField(30);\r
47 \r
48 filebox = new JCheckBox("Output to logfile", true);\r
49 screenbox = new JCheckBox("Specify logfile", false);\r
50 \r
51 JPanel modulePanel = new JPanel();\r
52 modulePanel.add(moduleButton);\r
53 modulePanel.add(moduletext);\r
54 modulePanel.add(filebox);\r
55 modulePanel.add(screenbox);\r
56 modulePanel.add(goButton);\r
57 add(modulePanel);\r
58\r
59 log = new JTextArea(50,25);\r
60 log.setMargin(new Insets(5,5,5,5));\r
61 log.setEditable(false);\r
62 JScrollPane logScrollPane = new JScrollPane(log);\r
63 add(logScrollPane);\r
64 \r
65 fc = new JFileChooser();\r
66 fc.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);\r
67 }\r
68 \r
69 //---------------------------------------------------------------------------------------//\r
70 \r
71 public boolean yesOrNo(String question) {\r
72 return JOptionPane.showConfirmDialog(this, question, "Yes or No", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION;\r
73 }\r
74 \r
75 public void print(String message) {\r
76 if (toscreen == true) {\r
77 log.append(message);\r
78 System.out.print(message);\r
79 }\r
80 if (tofile == true) {\r
81 logfile.append(message);\r
82 }\r
83 }\r
84 \r
85 public void println(String message) {\r
86 print(message + "\n");\r
87 }\r
88\r
89 public void println(Set<String> hash) {\r
90 if (toscreen == true) {\r
91 log.append(hash + "\n");\r
92 System.out.println(hash);\r
93 }\r
94 if (tofile == true) {\r
95 logfile.append(hash + "\n");\r
96 }\r
97 }\r
98\r
e6a5df3b 99 public String choose(String message, Object[] choicelist) {\r
100 return (String)JOptionPane.showInputDialog(this, message,"Choose",JOptionPane.PLAIN_MESSAGE,null,choicelist,choicelist[0]);\r
101 }\r
102\r
0dc8c589 103 //---------------------------------------------------------------------------------------//\r
104 \r
105 /*\r
106 public boolean getOption(String item) {\r
107 if (item.matches("file")) {\r
108 }\r
109 }\r
110 */\r
111 \r
112 public void actionPerformed(ActionEvent e) {\r
113 if ( e.getSource() == moduleButton ) {\r
114 int ret = fc.showOpenDialog(this);\r
115 if (ret == JFileChooser.APPROVE_OPTION) {\r
116 modulepath = fc.getSelectedFile().getAbsolutePath();\r
117 moduletext.setText(modulepath);\r
118 log.append("ModulePath: " + modulepath + "\n");\r
119 }\r
120 }\r
121 if ( e.getSource() == goButton ) {\r
122 try {\r
123 logfile = new PrintWriter(new BufferedWriter(new FileWriter(modulepath + File.separator + "migration.log")));\r
124 println("Project MsaGen");\r
125 println("Copyright (c) 2006, Intel Corporation");\r
126 new ModuleInfo(modulepath, this, new Database());\r
127 logfile.flush();\r
128 } catch (Exception en) {\r
129 println(en.getMessage());\r
130 }\r
131 }\r
132 }\r
133 \r
134 public void itemStateChanged(ItemEvent e) {\r
135 if (e.getStateChange() == ItemEvent.DESELECTED) {\r
136 System.out.println("changed");\r
137 }\r
138 }\r
139\r
140 //---------------------------------------------------------------------------------------//\r
141 \r
142 public static void init() throws Exception {\r
b48e3710 143 \r
144 //UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());\r
145 UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());\r
146 //UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");\r
147 //UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");\r
148 //UIManager.setLookAndFeel("com.sun.java.swing.plaf.gtk.GTKLookAndFeel");\r
149 //UIManager.setLookAndFeel("com.sun.java.swing.plaf.motif.MotifLookAndFeel");\r
150 \r
151 JFrame frame = new JFrame("MigrationTools");\r
0dc8c589 152 frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);\r
153\r
154 FirstPanel fp = new FirstPanel();\r
155 fp.setLayout(new BoxLayout(fp, BoxLayout.Y_AXIS));\r
156 fp.setOpaque(true);\r
157 frame.setContentPane(fp);\r
158\r
159 frame.setSize(800,600);\r
160 frame.setVisible(true);\r
161 }\r
162}