]> git.proxmox.com Git - mirror_edk2.git/blobdiff - Tools/Source/MigrationTools/org/tianocore/migration/MigrationTool.java
enhance ForDoAll
[mirror_edk2.git] / Tools / Source / MigrationTools / org / tianocore / migration / MigrationTool.java
index e1e769f62dc4a810bab49cb466b5304db1aa6d7c..cbb49a13daa06953406b0afaef9c8f37cf6918bd 100644 (file)
@@ -1,21 +1,38 @@
+/** @file\r
\r
+ Copyright (c) 2006, Intel Corporation\r
+ All rights reserved. This program and the accompanying materials\r
+ are licensed and made available under the terms and conditions of the BSD License\r
+ which accompanies this distribution.  The full text of the license may be found at\r
+ http://opensource.org/licenses/bsd-license.php\r
\r
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
\r
+ **/\r
 package org.tianocore.migration;\r
 \r
 import java.io.File;\r
-import java.util.Set;\r
+import java.util.*;\r
+\r
+import javax.swing.JFileChooser;\r
 \r
 public class MigrationTool {\r
        public static UI ui = null;\r
        public static Database db = null;\r
 \r
-       public static final String MIGRATIONCOMMENT = "//%$//";\r
+       public static String MIGRATIONCOMMENT = "//%$//";\r
 \r
        public static boolean printModuleInfo = false;\r
        public static boolean doCritic = false;\r
        public static boolean defaultoutput = false;\r
+       \r
+       public static final HashMap<ModuleInfo, String> ModuleInfoMap = new HashMap<ModuleInfo, String>();\r
 \r
-       private static final void manipulate(ModuleInfo mi) throws Exception {\r
+       private static final void mainFlow(ModuleInfo mi) throws Exception {\r
 \r
                ModuleReader.ModuleScan(mi);\r
+               \r
                //MigrationTool.ui.yesOrNo("go on replace?");\r
                SourceFileReplacer.flush(mi);   // some adding library actions are taken here,so it must be put before "MsaWriter"\r
 \r
@@ -40,7 +57,7 @@ public class MigrationTool {
                //MigrationTool.ui.yesOrNo("go on critic?");\r
 \r
                if (MigrationTool.doCritic) {\r
-                       Critic.fireAt(mi.outputpath + File.separator + "Migration_" + mi.modulename);\r
+                       Critic.fireAt(ModuleInfoMap.get(mi) + File.separator + "Migration_" + mi.modulename);\r
                }\r
 \r
                //MigrationTool.ui.yesOrNo("go on delete?");\r
@@ -57,16 +74,31 @@ public class MigrationTool {
                MigrationTool.ui.println(hash);\r
        }\r
 \r
+       private static final String assignOutPutPath(String inputpath) {\r
+               if (MigrationTool.defaultoutput) {\r
+                       return inputpath.replaceAll(Common.strseparate, "$1");\r
+               } else {\r
+                       return MigrationTool.ui.getFilepath("Please choose where to place the output module", JFileChooser.DIRECTORIES_ONLY);\r
+               }\r
+       }\r
+       \r
        public static final void seekModule(String filepath) throws Exception {\r
                if (ModuleInfo.isModule(filepath)) {\r
-                       manipulate(new ModuleInfo(filepath));\r
+                       ModuleInfoMap.put(new ModuleInfo(filepath), assignOutPutPath(filepath));\r
                }\r
        }\r
 \r
-       public static final void triger(String path) throws Exception {\r
+       public static final void startMigrateAll(String path) throws Exception {\r
                MigrationTool.ui.println("Project Migration");\r
                MigrationTool.ui.println("Copyright (c) 2006, Intel Corporation");\r
                Common.toDoAll(path, MigrationTool.class.getMethod("seekModule", String.class), null, null, Common.DIR);\r
+               \r
+               Iterator<ModuleInfo> miit = ModuleInfoMap.keySet().iterator();\r
+               while (miit.hasNext()) {\r
+                       mainFlow(miit.next());\r
+               }\r
+               \r
+               ModuleInfoMap.clear();\r
        }\r
 \r
        public static void main(String[] args) throws Exception {\r