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