]> git.proxmox.com Git - mirror_edk2.git/blobdiff - Tools/Source/MigrationTools/org/tianocore/migration/FirstPanel.java
let critic prepared
[mirror_edk2.git] / Tools / Source / MigrationTools / org / tianocore / migration / FirstPanel.java
index 438625380ecf6908700e158c1a421e6991e80f87..e99a76edf421e44985af6b11cea5458c17158a38 100644 (file)
@@ -24,19 +24,20 @@ public final class FirstPanel extends JPanel implements ActionListener, ItemList
         */\r
        private static final long serialVersionUID = 207759413522910399L;\r
        \r
-       private String modulepath;\r
-       private ModuleInfo mi;\r
+       private static final FirstPanel INSTANCE = FirstPanel.init();\r
        \r
-       private JButton moduleButton, goButton, msaEditorButton, criticButton;\r
+       private String startpath;\r
+       \r
+       private JButton moduleButton, goButton, msaEditorButton, criticButton, specifyCommentButton;\r
        private JTextField moduletext;\r
        private JTextArea log;\r
-       private JFileChooser fc;\r
+       private JFileChooser fc = new JFileChooser();\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
+       FirstPanel() {\r
         GridBagLayout gridbag = new GridBagLayout();\r
         setLayout(gridbag);\r
         \r
@@ -55,6 +56,9 @@ public final class FirstPanel extends JPanel implements ActionListener, ItemList
                criticButton = new JButton("Critic");\r
                criticButton.addActionListener(this);\r
                \r
+               specifyCommentButton = new JButton("Comment Style");\r
+               specifyCommentButton.addActionListener(this);\r
+               \r
                moduletext = new JTextField(30);\r
                \r
                filebox = new JCheckBox("Output to logfile", true);\r
@@ -65,14 +69,15 @@ public final class FirstPanel extends JPanel implements ActionListener, ItemList
                \r
                mibox = new JCheckBox("Print ModuleInfo", false);\r
                mibox.addItemListener(this);\r
-               ModuleInfo.printModuleInfo = false;\r
+               MigrationTool.printModuleInfo = false;\r
                \r
                criticbox = new JCheckBox("Run Critic", true);\r
                criticbox.addItemListener(this);\r
-               ModuleInfo.doCritic = true;\r
+               MigrationTool.doCritic = true;\r
                \r
                defaultpathbox = new JCheckBox("Use Default Output Path", true);\r
                defaultpathbox.addItemListener(this);\r
+               MigrationTool.defaultoutput = true;\r
                \r
         JPanel modulePanel = new JPanel();\r
         modulePanel.add(moduleButton);\r
@@ -87,7 +92,9 @@ public final class FirstPanel extends JPanel implements ActionListener, ItemList
 \r
         cst.gridx = 1;\r
         cst.gridy = 0;\r
-        gridbag.setConstraints(criticButton, cst);\r
+        gridbag.setConstraints(specifyCommentButton, cst);\r
+        add(specifyCommentButton);\r
+        //gridbag.setConstraints(criticButton, cst);\r
         //add(criticButton);\r
         \r
         JPanel checkboxPanel = new JPanel();\r
@@ -112,9 +119,6 @@ public final class FirstPanel extends JPanel implements ActionListener, ItemList
         cst.fill = GridBagConstraints.BOTH;\r
         gridbag.setConstraints(logScrollPane, cst);\r
         add(logScrollPane);\r
-        \r
-               fc = new JFileChooser();\r
-        fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);\r
        }\r
        \r
        //---------------------------------------------------------------------------------------//\r
@@ -157,7 +161,9 @@ public final class FirstPanel extends JPanel implements ActionListener, ItemList
 \r
        //---------------------------------------------------------------------------------------//\r
 \r
-       public String getFilepath() {\r
+       public String getFilepath(String title, int mode) {\r
+               fc.setDialogTitle(title);\r
+               fc.setFileSelectionMode(mode);\r
                if (fc.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) {\r
                        log.append(fc.getSelectedFile().getAbsolutePath() + "\n");\r
                        return fc.getSelectedFile().getAbsolutePath();\r
@@ -169,12 +175,13 @@ public final class FirstPanel extends JPanel implements ActionListener, ItemList
 \r
     public void actionPerformed(ActionEvent e) {\r
         if ( e.getSource() == moduleButton ) {\r
-               modulepath = getFilepath();\r
+               startpath = getFilepath("Please choose a starting path", JFileChooser.DIRECTORIES_ONLY);\r
+               moduletext.setText(startpath);\r
         }\r
         if ( e.getSource() == goButton ) {\r
                try {\r
-                       logfile = new PrintWriter(new BufferedWriter(new FileWriter(modulepath + File.separator + "migration.log")));\r
-                       ModuleInfo.triger(modulepath);\r
+                       logfile = new PrintWriter(new BufferedWriter(new FileWriter(startpath.replaceAll(Common.strseparate, "$1") + File.separator + "migration.log")));\r
+                       MigrationTool.startMigrateAll(startpath);\r
                        logfile.flush();\r
                } catch (Exception en) {\r
                        println(en.getMessage());\r
@@ -182,14 +189,22 @@ public final class FirstPanel extends JPanel implements ActionListener, ItemList
         }\r
         if ( e.getSource() == msaEditorButton) {\r
                try {\r
-               MsaTreeEditor.init(mi, this);\r
+               MsaTreeEditor.init();\r
                } catch (Exception en) {\r
                        println(en.getMessage());\r
                }\r
         }\r
         if ( e.getSource() == criticButton) {\r
                try {\r
-                       Critic.fireAt(modulepath);\r
+                       Critic.fireAt(startpath);\r
+               } catch (Exception en) {\r
+                       println(en.getMessage());\r
+               }\r
+        }\r
+        if ( e.getSource() == specifyCommentButton) {\r
+               try {                                                                                   // input examine is not imposed but should be added\r
+                       MigrationTool.MIGRATIONCOMMENT = getInput("Please type in wanted comment style used by the tool\nbe sure to start with '//', or you won't enjoy the result");\r
+                       //MsaWriter.parse("C:\\tianocore\\edk2\\MdePkg\\Library\\BaseLib\\BaseLib.msa");\r
                } catch (Exception en) {\r
                        println(en.getMessage());\r
                }\r
@@ -211,37 +226,38 @@ public final class FirstPanel extends JPanel implements ActionListener, ItemList
                }\r
        } else if (e.getSource() == mibox) {\r
                if (e.getStateChange() == ItemEvent.DESELECTED) {\r
-                       ModuleInfo.printModuleInfo = false;\r
+                       MigrationTool.printModuleInfo = false;\r
                } else if (e.getStateChange() == ItemEvent.SELECTED) {\r
-                       ModuleInfo.printModuleInfo = true;\r
+                       MigrationTool.printModuleInfo = true;\r
                }\r
        } else if (e.getSource() == criticbox) {\r
                if (e.getStateChange() == ItemEvent.DESELECTED) {\r
-                       ModuleInfo.doCritic = false;\r
-                       System.out.println("criticbox DESELECTED");\r
+                       MigrationTool.doCritic = false;\r
                } else if (e.getStateChange() == ItemEvent.SELECTED) {\r
-                       ModuleInfo.doCritic = true;\r
-                       System.out.println("criticbox SELECTED");\r
+                       MigrationTool.doCritic = true;\r
                }\r
        } else if (e.getSource() == defaultpathbox) {\r
                if (e.getStateChange() == ItemEvent.DESELECTED) {\r
-                       System.out.println("defaultpathbox DESELECTED");\r
+                       MigrationTool.defaultoutput = false;\r
                } else if (e.getStateChange() == ItemEvent.SELECTED) {\r
-                       System.out.println("defaultpathbox SELECTED");\r
+                       MigrationTool.defaultoutput = true;\r
                }\r
        }\r
     }\r
 \r
     //---------------------------------------------------------------------------------------//\r
     \r
-    public static FirstPanel init() throws Exception {\r
-       \r
-       //UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());\r
-       UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());\r
-       //UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");\r
-       //UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");\r
-       //UIManager.setLookAndFeel("com.sun.java.swing.plaf.gtk.GTKLookAndFeel");\r
-       //UIManager.setLookAndFeel("com.sun.java.swing.plaf.motif.MotifLookAndFeel");\r
+    private static final FirstPanel init() {\r
+       try {\r
+               UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());\r
+               //UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());\r
+               //UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");\r
+               //UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");\r
+               //UIManager.setLookAndFeel("com.sun.java.swing.plaf.gtk.GTKLookAndFeel");\r
+               //UIManager.setLookAndFeel("com.sun.java.swing.plaf.motif.MotifLookAndFeel");\r
+       } catch (Exception e) {\r
+               System.out.println(e.getMessage());\r
+       }\r
        \r
                JFrame frame = new JFrame("MigrationTools");\r
                frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);\r
@@ -257,4 +273,8 @@ public final class FirstPanel extends JPanel implements ActionListener, ItemList
                \r
                return fp;\r
     }\r
+    \r
+    public static final FirstPanel getInstance() {\r
+       return INSTANCE;\r
+    }\r
 }
\ No newline at end of file