]> git.proxmox.com Git - mirror_edk2.git/blame - Tools/Source/MigrationTools/org/tianocore/migration/FirstPanel.java
Many Many Modifies
[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
5ea254f6 21public final class FirstPanel extends JPanel implements ActionListener, UI {\r
0dc8c589 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
90503bad 28 private ModuleInfo mi;\r
0dc8c589 29 \r
fed802b1 30 private JButton moduleButton, goButton, msaEditorButton, criticButton;\r
0dc8c589 31 private JTextField moduletext;\r
32 private JTextArea log;\r
33 private JFileChooser fc;\r
34 private JCheckBox filebox, screenbox;\r
35 \r
36 private boolean tofile = true, toscreen = true;\r
37 private PrintWriter logfile;\r
38\r
39 FirstPanel() throws Exception {\r
40 goButton = new JButton("Go");\r
41 goButton.addActionListener(this);\r
42 goButton.setActionCommand("go");\r
43 \r
44 moduleButton = new JButton("Choose ModulePath");\r
45 moduleButton.addActionListener(this);\r
46\r
90503bad 47 msaEditorButton = new JButton("MsaEditor");\r
48 msaEditorButton.addActionListener(this);\r
49 \r
fed802b1 50 criticButton = new JButton("Critic");\r
51 criticButton.addActionListener(this);\r
52 \r
0dc8c589 53 moduletext = new JTextField(30);\r
54 \r
55 filebox = new JCheckBox("Output to logfile", true);\r
56 screenbox = new JCheckBox("Specify logfile", false);\r
57 \r
58 JPanel modulePanel = new JPanel();\r
59 modulePanel.add(moduleButton);\r
60 modulePanel.add(moduletext);\r
61 modulePanel.add(filebox);\r
62 modulePanel.add(screenbox);\r
63 modulePanel.add(goButton);\r
5ea254f6 64 //modulePanel.add(msaEditorButton);\r
fed802b1 65 modulePanel.add(criticButton);\r
0dc8c589 66 add(modulePanel);\r
67\r
90503bad 68 log = new JTextArea(20,25);\r
0dc8c589 69 log.setMargin(new Insets(5,5,5,5));\r
70 log.setEditable(false);\r
71 JScrollPane logScrollPane = new JScrollPane(log);\r
72 add(logScrollPane);\r
73 \r
74 fc = new JFileChooser();\r
75 fc.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);\r
76 }\r
77 \r
78 //---------------------------------------------------------------------------------------//\r
79 \r
80 public boolean yesOrNo(String question) {\r
81 return JOptionPane.showConfirmDialog(this, question, "Yes or No", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION;\r
82 }\r
83 \r
84 public void print(String message) {\r
85 if (toscreen == true) {\r
86 log.append(message);\r
87 System.out.print(message);\r
88 }\r
89 if (tofile == true) {\r
90 logfile.append(message);\r
91 }\r
92 }\r
93 \r
94 public void println(String message) {\r
95 print(message + "\n");\r
96 }\r
97\r
98 public void println(Set<String> hash) {\r
99 if (toscreen == true) {\r
100 log.append(hash + "\n");\r
101 System.out.println(hash);\r
102 }\r
103 if (tofile == true) {\r
104 logfile.append(hash + "\n");\r
105 }\r
106 }\r
107\r
e6a5df3b 108 public String choose(String message, Object[] choicelist) {\r
109 return (String)JOptionPane.showInputDialog(this, message,"Choose",JOptionPane.PLAIN_MESSAGE,null,choicelist,choicelist[0]);\r
110 }\r
0dc8c589 111 \r
90503bad 112 public String getInput(String message) {\r
113 return (String)JOptionPane.showInputDialog(message);\r
0dc8c589 114 }\r
90503bad 115\r
116 //---------------------------------------------------------------------------------------//\r
117\r
5ea254f6 118 public String getFilepath() {\r
119 if (fc.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) {\r
120 log.append(fc.getSelectedFile().getAbsolutePath() + "\n");\r
121 return fc.getSelectedFile().getAbsolutePath();\r
122 }\r
123 return null;\r
124 }\r
125\r
126 //---------------------------------------------------------------------------------------//\r
127\r
0dc8c589 128 public void actionPerformed(ActionEvent e) {\r
129 if ( e.getSource() == moduleButton ) {\r
5ea254f6 130 modulepath = getFilepath();\r
131 /*\r
0dc8c589 132 int ret = fc.showOpenDialog(this);\r
133 if (ret == JFileChooser.APPROVE_OPTION) {\r
134 modulepath = fc.getSelectedFile().getAbsolutePath();\r
135 moduletext.setText(modulepath);\r
136 log.append("ModulePath: " + modulepath + "\n");\r
137 }\r
5ea254f6 138 */\r
0dc8c589 139 }\r
140 if ( e.getSource() == goButton ) {\r
141 try {\r
142 logfile = new PrintWriter(new BufferedWriter(new FileWriter(modulepath + File.separator + "migration.log")));\r
143 println("Project MsaGen");\r
144 println("Copyright (c) 2006, Intel Corporation");\r
5ea254f6 145 Common.toDoAll(modulepath, ModuleInfo.class.getMethod("seekModule", String.class), null, null, Common.DIR);\r
0dc8c589 146 logfile.flush();\r
147 } catch (Exception en) {\r
148 println(en.getMessage());\r
149 }\r
150 }\r
90503bad 151 if ( e.getSource() == msaEditorButton) {\r
152 try {\r
153 MsaTreeEditor.init(mi, this);\r
154 } catch (Exception en) {\r
155 println(en.getMessage());\r
156 }\r
157 }\r
fed802b1 158 if ( e.getSource() == criticButton) {\r
159 try {\r
160 Critic.fireAt(modulepath);\r
161 } catch (Exception en) {\r
162 println(en.getMessage());\r
163 }\r
164 }\r
0dc8c589 165 }\r
166 \r
167 public void itemStateChanged(ItemEvent e) {\r
168 if (e.getStateChange() == ItemEvent.DESELECTED) {\r
169 System.out.println("changed");\r
170 }\r
171 }\r
172\r
173 //---------------------------------------------------------------------------------------//\r
174 \r
5ea254f6 175 public static FirstPanel init() throws Exception {\r
b48e3710 176 \r
177 //UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());\r
178 UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());\r
179 //UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");\r
180 //UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");\r
181 //UIManager.setLookAndFeel("com.sun.java.swing.plaf.gtk.GTKLookAndFeel");\r
182 //UIManager.setLookAndFeel("com.sun.java.swing.plaf.motif.MotifLookAndFeel");\r
183 \r
184 JFrame frame = new JFrame("MigrationTools");\r
0dc8c589 185 frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);\r
186\r
187 FirstPanel fp = new FirstPanel();\r
188 fp.setLayout(new BoxLayout(fp, BoxLayout.Y_AXIS));\r
189 fp.setOpaque(true);\r
190 frame.setContentPane(fp);\r
191\r
90503bad 192 frame.pack();\r
0dc8c589 193 frame.setVisible(true);\r
5ea254f6 194 \r
195 return fp;\r
0dc8c589 196 }\r
197}