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