X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=Tools%2FSource%2FMigrationTools%2Forg%2Ftianocore%2Fmigration%2FFirstPanel.java;h=8c428087d669283ac0aa5870697c62ede84ef008;hp=30085d449edd0770bc1fd7c5ab4712334da39fa5;hb=778d35c92a569812c3b2f6d0b913315bdce4c874;hpb=e6a5df3bbd1d371ce18eebd0a692a50298cb31f3 diff --git a/Tools/Source/MigrationTools/org/tianocore/migration/FirstPanel.java b/Tools/Source/MigrationTools/org/tianocore/migration/FirstPanel.java index 30085d449e..8c428087d6 100644 --- a/Tools/Source/MigrationTools/org/tianocore/migration/FirstPanel.java +++ b/Tools/Source/MigrationTools/org/tianocore/migration/FirstPanel.java @@ -18,24 +18,30 @@ import java.io.*; import java.util.*; import javax.swing.*; -public class FirstPanel extends JPanel implements ActionListener, UI { +public final class FirstPanel extends JPanel implements ActionListener, ItemListener, UI { /** * Define class Serial Version UID */ private static final long serialVersionUID = 207759413522910399L; private String modulepath; + private ModuleInfo mi; - private JButton moduleButton , goButton; + private JButton moduleButton, goButton, msaEditorButton, criticButton; private JTextField moduletext; private JTextArea log; private JFileChooser fc; - private JCheckBox filebox, screenbox; + private JCheckBox filebox, screenbox, mibox, criticbox, defaultpathbox; private boolean tofile = true, toscreen = true; private PrintWriter logfile; FirstPanel() throws Exception { + GridBagLayout gridbag = new GridBagLayout(); + setLayout(gridbag); + + GridBagConstraints cst = new GridBagConstraints(); + goButton = new JButton("Go"); goButton.addActionListener(this); goButton.setActionCommand("go"); @@ -43,23 +49,62 @@ public class FirstPanel extends JPanel implements ActionListener, UI { moduleButton = new JButton("Choose ModulePath"); moduleButton.addActionListener(this); + msaEditorButton = new JButton("MsaEditor"); + msaEditorButton.addActionListener(this); + + criticButton = new JButton("Critic"); + criticButton.addActionListener(this); + moduletext = new JTextField(30); filebox = new JCheckBox("Output to logfile", true); + filebox.addItemListener(this); screenbox = new JCheckBox("Specify logfile", false); + screenbox.addItemListener(this); + mibox = new JCheckBox("Show ModuleInfo", false); + mibox.addItemListener(this); + criticbox = new JCheckBox("Run Critic", true); + criticbox.addItemListener(this); + defaultpathbox = new JCheckBox("Use Default Output Path", true); + defaultpathbox.addItemListener(this); JPanel modulePanel = new JPanel(); modulePanel.add(moduleButton); modulePanel.add(moduletext); - modulePanel.add(filebox); - modulePanel.add(screenbox); modulePanel.add(goButton); + //modulePanel.add(msaEditorButton); + cst.gridx = 0; + cst.gridy = 0; + //cst.gridwidth = GridBagConstraints.REMAINDER; + gridbag.setConstraints(modulePanel, cst); add(modulePanel); - log = new JTextArea(50,25); + cst.gridx = 1; + cst.gridy = 0; + gridbag.setConstraints(criticButton, cst); + add(criticButton); + + JPanel checkboxPanel = new JPanel(); + checkboxPanel.setLayout(new BoxLayout(checkboxPanel, BoxLayout.Y_AXIS)); + checkboxPanel.add(filebox); + checkboxPanel.add(screenbox); + checkboxPanel.add(mibox); + checkboxPanel.add(criticbox); + checkboxPanel.add(defaultpathbox); + cst.gridx = 1; + cst.gridy = 1; + //cst.gridheight = 2; + gridbag.setConstraints(checkboxPanel, cst); + add(checkboxPanel); + + log = new JTextArea(10,20); log.setMargin(new Insets(5,5,5,5)); log.setEditable(false); JScrollPane logScrollPane = new JScrollPane(log); + cst.gridx = 0; + cst.gridy = 1; + cst.fill = GridBagConstraints.BOTH; + gridbag.setConstraints(logScrollPane, cst); add(logScrollPane); fc = new JFileChooser(); @@ -99,47 +144,89 @@ public class FirstPanel extends JPanel implements ActionListener, UI { public String choose(String message, Object[] choicelist) { return (String)JOptionPane.showInputDialog(this, message,"Choose",JOptionPane.PLAIN_MESSAGE,null,choicelist,choicelist[0]); } + + public String getInput(String message) { + return (String)JOptionPane.showInputDialog(message); + } //---------------------------------------------------------------------------------------// - - /* - public boolean getOption(String item) { - if (item.matches("file")) { + + public String getFilepath() { + if (fc.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) { + log.append(fc.getSelectedFile().getAbsolutePath() + "\n"); + return fc.getSelectedFile().getAbsolutePath(); } + return null; } - */ - + + //---------------------------------------------------------------------------------------// + public void actionPerformed(ActionEvent e) { if ( e.getSource() == moduleButton ) { - int ret = fc.showOpenDialog(this); - if (ret == JFileChooser.APPROVE_OPTION) { - modulepath = fc.getSelectedFile().getAbsolutePath(); - moduletext.setText(modulepath); - log.append("ModulePath: " + modulepath + "\n"); - } + modulepath = getFilepath(); } if ( e.getSource() == goButton ) { try { logfile = new PrintWriter(new BufferedWriter(new FileWriter(modulepath + File.separator + "migration.log"))); - println("Project MsaGen"); - println("Copyright (c) 2006, Intel Corporation"); - new ModuleInfo(modulepath, this, new Database()); + ModuleInfo.triger(modulepath); logfile.flush(); } catch (Exception en) { println(en.getMessage()); } } + if ( e.getSource() == msaEditorButton) { + try { + MsaTreeEditor.init(mi, this); + } catch (Exception en) { + println(en.getMessage()); + } + } + if ( e.getSource() == criticButton) { + try { + Critic.fireAt(modulepath); + } catch (Exception en) { + println(en.getMessage()); + } + } } public void itemStateChanged(ItemEvent e) { - if (e.getStateChange() == ItemEvent.DESELECTED) { - System.out.println("changed"); + if (e.getSource() == filebox) { + if (e.getStateChange() == ItemEvent.DESELECTED) { + System.out.println("filebox DESELECTED"); + } else if (e.getStateChange() == ItemEvent.SELECTED) { + System.out.println("filebox SELECTED"); + } + } else if (e.getSource() == screenbox) { + if (e.getStateChange() == ItemEvent.DESELECTED) { + System.out.println("screenbox DESELECTED"); + } else if (e.getStateChange() == ItemEvent.SELECTED) { + System.out.println("screenbox SELECTED"); + } + } else if (e.getSource() == mibox) { + if (e.getStateChange() == ItemEvent.DESELECTED) { + System.out.println("mibox DESELECTED"); + } else if (e.getStateChange() == ItemEvent.SELECTED) { + System.out.println("mibox SELECTED"); + } + } else if (e.getSource() == criticbox) { + if (e.getStateChange() == ItemEvent.DESELECTED) { + System.out.println("criticbox DESELECTED"); + } else if (e.getStateChange() == ItemEvent.SELECTED) { + System.out.println("criticbox SELECTED"); + } + } else if (e.getSource() == defaultpathbox) { + if (e.getStateChange() == ItemEvent.DESELECTED) { + System.out.println("defaultpathbox DESELECTED"); + } else if (e.getStateChange() == ItemEvent.SELECTED) { + System.out.println("defaultpathbox SELECTED"); + } } } //---------------------------------------------------------------------------------------// - public static void init() throws Exception { + public static FirstPanel init() throws Exception { //UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName()); UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); @@ -152,11 +239,14 @@ public class FirstPanel extends JPanel implements ActionListener, UI { frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); FirstPanel fp = new FirstPanel(); - fp.setLayout(new BoxLayout(fp, BoxLayout.Y_AXIS)); + //fp.setLayout(new GridBagLayout()); + //fp.setLayout(new BoxLayout(fp, BoxLayout.Y_AXIS)); fp.setOpaque(true); frame.setContentPane(fp); - frame.setSize(800,600); + frame.pack(); frame.setVisible(true); + + return fp; } } \ No newline at end of file