]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Enhance Installation, removing and creating FAR functionality.
authorqouyang <qouyang@6f19259b-4bc3-4df7-8a09-765794883524>
Thu, 13 Jul 2006 08:06:16 +0000 (08:06 +0000)
committerqouyang <qouyang@6f19259b-4bc3-4df7-8a09-765794883524>
Thu, 13 Jul 2006 08:06:16 +0000 (08:06 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@964 6f19259b-4bc3-4df7-8a09-765794883524

Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/far/DistributeRule.java
Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/far/Far.java
Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/far/FarIdentification.java
Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/far/Mainfest.java
Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/far/updateui/UpdateStepOne.java
Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/far/updateui/UpdateStepTwo.java

index e6b19b3be1ebc592ab45645d4a2fd8e4c2f265b4..801cea6b3f0400e720e5f8865e58c2e88ce9dea9 100644 (file)
@@ -59,17 +59,8 @@ public class DistributeRule {
                                                                             AggregationOperation.union(farPkgList,\r
                                                                                                        dbPkgList));\r
 \r
-        //\r
-        //  If dependencies don't meet, print the error message and return.\r
-        // \r
-        //        if (resultList != null || resultList.size()> 0){\r
-        //            Iterator resItem = resultList.iterator();\r
-        //            while (resItem.hasNext()){\r
-        //                System.out.println("Missing package:" + resItem.next().toString() + " !");\r
-        //            }\r
-        //        }\r
-        return resultList;\r
-\r
+        return resultList; \r
+        \r
     }\r
 \r
     //    public void installPackgCheck (PackageIdentification pkgId, String pkgPath){\r
index 21a86f5789651dbd8830c8d427ef87240964ee66..d550d220ac0b200719a4d007047d5b2dc497c261 100644 (file)
@@ -62,9 +62,10 @@ public class Far {
         jf = farFile;\r
         this.mainfest = new Mainfest(getMainfestFile());\r
     }\r
-\r
-    public void creatFar(List<PackageIdentification> pkgList, List<PlatformIdentification> plfList,\r
-                         Set<String> fileFilter, FarHeader fHeader) throws Exception {\r
+    \r
+    public void creatFar (List<PackageIdentification> pkgList,\r
+            List<PlatformIdentification> plfList, Set<String> fileFilter,\r
+            FarHeader fHeader) throws Exception{\r
         jos = new JarOutputStream(new FileOutputStream(jarFile));\r
 \r
         //\r
@@ -93,28 +94,23 @@ public class Far {
         }\r
         jos.close();\r
     }\r
-\r
-    private void writeToJar(File file, JarOutputStream jos) throws Exception {\r
-        byte[] buffer = new byte[(int) file.length()];\r
-        FileInputStream fInput = new FileInputStream(file);\r
-        JarEntry entry = new JarEntry(\r
-                                      Tools\r
-                                           .convertPathToUnixType(Tools\r
-                                                                       .getRelativePath(file.getPath(),\r
-                                                                                        Workspace.getCurrentWorkspace())));\r
-        jos.putNextEntry(entry);\r
-        fInput.read(buffer);\r
-        jos.write(buffer);\r
-        fInput.close();\r
+    \r
+    private void writeToJar(File file, JarOutputStream jos) throws Exception{\r
+      byte[] buffer = new byte[(int)file.length()];\r
+      FileInputStream fInput = new FileInputStream(file);\r
+      JarEntry entry = new JarEntry(Tools.convertPathToUnixType(Tools.getRelativePath(file.getPath(),Workspace.getCurrentWorkspace())));\r
+      jos.putNextEntry(entry);\r
+      fInput.read(buffer);\r
+      jos.write(buffer);\r
+      fInput.close();\r
     }\r
 \r
     public void InstallFar(String dir) throws Exception {\r
         List<FarFileItem> allFile = mainfest.getAllFileItem();\r
         extract(allFile, dir);\r
     }\r
-\r
-    public void InstallFar(Map<PlatformIdentification, File> plfMap, Map<PackageIdentification, File> pkgMap)\r
-                                                                                                             throws Exception {\r
+    \r
+    public void InstallFar (Map<PlatformIdentification, File> plfMap, Map<PackageIdentification, File> pkgMap) throws Exception{\r
         Set<PlatformIdentification> plfKeys = plfMap.keySet();\r
         Iterator<PlatformIdentification> plfIter = plfKeys.iterator();\r
         while (plfIter.hasNext()) {\r
@@ -153,7 +149,39 @@ public class Far {
     public boolean hibernateToFile() {\r
         return true;\r
     }\r
-\r
+//    public static void main(String[] args){\r
+//        try {\r
+//            JarFile jarFile = new JarFile(new File("C:\\cvswork\\newEdk\\jar.jar.far"));\r
+//            JarEntry je= jarFile.getJarEntry("MdePkg/MdePkg.spd");\r
+//            InputStream is = jarFile.getInputStream(je);\r
+//            byte[] buffer = new byte[1];      \r
+//            File tempFile = new File("C:\\cvswork\\newEdk\\tempFile");\r
+//            File tfile2 = new File("C:\\cvswork\\newEdk\\tempFile1");\r
+//            FileOutputStream fos1 = new FileOutputStream(tfile2);\r
+//            FileOutputStream fos = new FileOutputStream(tempFile);\r
+//            int size = is.read(buffer);\r
+//            int totoalSize = size;\r
+//            while ( size >=  0) {\r
+//                fos.write(buffer);\r
+//                size = is.read(buffer);\r
+//                totoalSize = totoalSize + size;\r
+//            }\r
+//            \r
+//            \r
+////            is = jarFile.getInputStream(je);\r
+////            is.read(totalbuffer);\r
+////            fos.write(totalbuffer);\r
+//            fos.close();\r
+//            byte[] totalbuffer = new byte[(int)tempFile.length()];\r
+//            FileInputStream fis = new FileInputStream(tempFile);\r
+//            fis.read(totalbuffer);\r
+//            fos1.write(totalbuffer);\r
+//            fos1.close();\r
+//        }catch(Exception e){\r
+//            \r
+//        }\r
+//    }\r
+    \r
     public void extract(List<FarFileItem> allFile, String dir) throws Exception {\r
 \r
         Iterator filesItem = allFile.iterator();\r
@@ -163,11 +191,7 @@ public class Far {
         dir += File.separatorChar;\r
         while (filesItem.hasNext()) {\r
             try {\r
-                ffItem = (FarFileItem) filesItem.next();\r
-                //                Enumeration<JarEntry> a = jf.entries();\r
-                //                while (a.hasMoreElements()) {\r
-                //                    System.out.println("##" + a.nextElement().getName());\r
-                //                }\r
+                ffItem = (FarFileItem)filesItem.next();\r
                 je = jf.getJarEntry(Tools.convertPathToUnixType(ffItem.getDefaultPath()));\r
                 InputStream entryStream = jf.getInputStream(je);\r
                 File file = new File(dir + ffItem.getRelativeFilename());\r
@@ -178,20 +202,29 @@ public class Far {
                     // exists).\r
                     //\r
                     FileOutputStream outputStream = new FileOutputStream(file);\r
+                    \r
 \r
                     try {\r
                         //\r
                         // Read the entry data and write it to the output\r
                         // file.\r
                         //\r
-                        int size = entryStream.available();\r
-                        byte[] buffer = new byte[size];\r
-                        outputStream.write(buffer);\r
-                        //                        if (!(FarMd5.md5(buffer)).equalsIgnoreCase(ffItem.getMd5Value())){\r
-                        //                            throw new Exception (je.getName() + " Md5 is invalided!");\r
-                        //                        }\r
-\r
-                        //                        System.out.println(je.getName() + " extracted.");\r
+                        byte[] buffer = new byte[1];      \r
+                        File tempFile = new File("tempFile");\r
+                        FileOutputStream fos = new FileOutputStream(tempFile);\r
+                        int size = entryStream.read(buffer);\r
+                        while ( size >=  0) {\r
+                            fos.write(buffer);\r
+                            size = entryStream.read(buffer);\r
+                        }\r
+                        \r
+                        fos.close();\r
+                        byte[] totalBuffer = new byte[(int)tempFile.length()];\r
+                        FileInputStream fis = new FileInputStream(tempFile);\r
+                        fis.read(totalBuffer);\r
+                        outputStream.write(totalBuffer);\r
+                        fis.close();\r
+                        tempFile.delete();\r
                     } finally {\r
                         outputStream.close();\r
                     }\r
@@ -200,26 +233,14 @@ public class Far {
                 }\r
 \r
             } finally {\r
-                //jf.close();\r
             }\r
         }\r
-\r
-    }\r
-\r
-    //    public void installFarPackage (PackageIdentification pkgId, String dir) throws Exception{\r
-    //        String pkgDir = null;\r
-    //        List<FarFileItem> farFileList = new ArrayList<FarFileItem>();\r
-    //        farFileList = this.mainfest.getPackageContents(pkgId);\r
-    //        if (dir == null){\r
-    //            pkgDir = this.mainfest.getPackageDefaultPath(pkgId);\r
-    //        }else {\r
-    //            pkgDir = dir;\r
-    //        }\r
-    //        extract(farFileList,pkgDir);\r
-    //    }\r
-\r
-    public void addFileToFar(File file, JarOutputStream farOuputStream, String workDir) {\r
-\r
+                        \r
+     }\r
+    \r
+    \r
+    public void addFileToFar (File file, JarOutputStream farOuputStream, String workDir){\r
+        \r
     }\r
 \r
     /**\r
index bd9d362f525adf037ef19b6bb0fcd168ebd08d05..babc9e3d92cf9638a372f1ff8d0ee938ab2b15d2 100644 (file)
@@ -1,3 +1,17 @@
+/** @file\r
\r
+ The file is used to save information of Far item.\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.frameworkwizard.far;\r
 \r
 public class FarIdentification {\r
index 430cb366523a11fc763d276906f500e4e25d1f0c..04dbf407193bc3a22be798d6cff4b43c45cac6df 100644 (file)
@@ -57,7 +57,6 @@ public class Mainfest implements ManifestInterface {
     // / Mainfest file element name\r
     // /\r
     final static String mfFileName = "FarMainfest.MF";\r
-\r
     //\r
     // Header\r
     //\r
@@ -132,9 +131,9 @@ public class Mainfest implements ManifestInterface {
     File mfFile = null;\r
 \r
     public FarHeader getHeader() {\r
-        return fhInfo;\r
+      return fhInfo;\r
     }\r
-\r
+    \r
     public Mainfest() throws Exception {\r
         DocumentBuilderFactory domfac = DocumentBuilderFactory.newInstance();\r
         DocumentBuilder dombuilder = domfac.newDocumentBuilder();\r
@@ -164,8 +163,8 @@ public class Mainfest implements ManifestInterface {
         this.fhInfo = fHeader;\r
     }\r
 \r
-    public void createManifest(List<PackageIdentification> pkgList, List<PlatformIdentification> plfList,\r
-                               Set<String> fileFilter) throws Exception {\r
+    public void createManifest(List<PackageIdentification> pkgList,\r
+            List<PlatformIdentification> plfList, Set<String> fileFilter) throws Exception {\r
 \r
         //\r
         // Add Package and it's contents to FarPackageList.\r
@@ -203,7 +202,7 @@ public class Mainfest implements ManifestInterface {
 \r
     public void addPkgToPkgList(PackageIdentification packageId, Set<String> fileFilter) throws Exception {\r
         files.add(packageId.getSpdFile());\r
-\r
+        \r
         FarPackage farPackage = new FarPackage();\r
         //\r
         // Add SPD file to FarPackage\r
@@ -212,17 +211,17 @@ public class Mainfest implements ManifestInterface {
 \r
         FarFileItem ffItem = new FarFileItem(spdFile.getName(), FarMd5.md5(spdFile));\r
         farPackage.setFarFile(ffItem);\r
-\r
+        \r
         //\r
         // Add package guid value.\r
         //\r
         farPackage.setGuidValue(packageId.getGuid());\r
-\r
+        \r
         //\r
         // Add package version\r
         //\r
         farPackage.setVersion(packageId.getVersion());\r
-\r
+        \r
         //\r
         // Add DefaultPat: Package absoulte path - Workspace absolut\r
         // path.\r
@@ -246,7 +245,7 @@ public class Mainfest implements ManifestInterface {
         // Remove current package's SPD file\r
         //\r
         fileSet.remove(packageId.getSpdFile());\r
-\r
+        \r
         files.addAll(fileSet);\r
 \r
         Iterator<File> iter = fileSet.iterator();\r
@@ -257,25 +256,26 @@ public class Mainfest implements ManifestInterface {
             ffItem = new FarFileItem(fileRelativePath, FarMd5.md5(normalFile));\r
             contents.add(ffItem);\r
         }\r
-\r
+        \r
         farPackage.setContentList(contents);\r
-\r
-        //        List<FarPlatformItem> fpfList = new ArrayList<FarPlatformItem>();\r
-        //\r
-        //        iter = fpdFileSet.iterator();\r
-        //\r
-        //        while (iter.hasNext()) {\r
-        //            File fpdFile = iter.next();\r
-        //            PlatformIdentification platformId = new PlatformIdentification(wsTool\r
-        //                    .getId(fpdFile.getPath(), OpenFile.openFpdFile(fpdFile\r
-        //                            .getPath())));\r
-        //            addPlatformIdToFarPlatformItemList(fpfList, platformId);\r
-        //        }\r
-        //        farPackage.setFarPlatformList(fpfList);\r
+        \r
+//        List<FarPlatformItem> fpfList = new ArrayList<FarPlatformItem>();\r
+//\r
+//        iter = fpdFileSet.iterator();\r
+//\r
+//        while (iter.hasNext()) {\r
+//            File fpdFile = iter.next();\r
+//            PlatformIdentification platformId = new PlatformIdentification(wsTool\r
+//                    .getId(fpdFile.getPath(), OpenFile.openFpdFile(fpdFile\r
+//                            .getPath())));\r
+//            addPlatformIdToFarPlatformItemList(fpfList, platformId);\r
+//        }\r
+//        farPackage.setFarPlatformList(fpfList);\r
         fPkgList.add(farPackage);\r
     }\r
 \r
-    private void recursiveDirectory(Set<File> files, Set<File> fpds, File dir, Set<String> fileFilter) {\r
+    private void recursiveDirectory(Set<File> files, Set<File> fpds, File dir,\r
+            Set<String> fileFilter) {\r
         if (isFilter(dir, fileFilter)) {\r
             return;\r
         }\r
@@ -285,11 +285,11 @@ public class Mainfest implements ManifestInterface {
                 if (isFilter(allFilesInDir[i], fileFilter)) {\r
                     continue;\r
                 }\r
-                //                if (allFilesInDir[i].getPath().toLowerCase().endsWith(".fpd")) {\r
-                //                    fpds.add(allFilesInDir[i]);\r
-                //                } else {\r
-                files.add(allFilesInDir[i]);\r
-                //                }\r
+//                if (allFilesInDir[i].getPath().toLowerCase().endsWith(".fpd")) {\r
+//                    fpds.add(allFilesInDir[i]);\r
+//                } else {\r
+                    files.add(allFilesInDir[i]);\r
+//                }\r
             } else {\r
                 recursiveDirectory(files, fpds, allFilesInDir[i], fileFilter);\r
             }\r
@@ -298,7 +298,7 @@ public class Mainfest implements ManifestInterface {
 \r
     public void addPlatformIdToFarPlatformItemList(PlatformIdentification platformId) throws Exception {\r
         files.add(platformId.getFpdFile());\r
-\r
+        \r
         FarPlatformItem fpfItem = new FarPlatformItem();\r
         FarFileItem ffItem;\r
         String fpfPath = platformId.getPath();\r
@@ -306,8 +306,7 @@ public class Mainfest implements ManifestInterface {
         //\r
         // Add farFileName\r
         //\r
-        ffItem = new FarFileItem(Tools.getRelativePath(fpfFile.getPath(), Workspace.getCurrentWorkspace()),\r
-                                 FarMd5.md5(fpfFile));\r
+        ffItem = new FarFileItem(Tools.getRelativePath(fpfFile.getPath(),Workspace.getCurrentWorkspace()), FarMd5.md5(fpfFile));\r
         fpfItem.setFarFile(ffItem);\r
 \r
         //\r
@@ -344,18 +343,16 @@ public class Mainfest implements ManifestInterface {
             // identification.\r
             //\r
 \r
-            PackageIdentification pkgId = new PackageIdentification(fPkg.getFarFile().getRelativeFilename(),\r
-                                                                    fPkg.getGuidValue(), fPkg.getVersion());\r
-            pkgId.setPath(Workspace.getCurrentWorkspace() + File.separatorChar + fPkg.getDefaultPath()\r
-                          + File.separatorChar + fPkg.getFarFile().getRelativeFilename());\r
-            //            wsTool.getId(\r
-            //                    Workspace.getCurrentWorkspace() + File.separatorChar\r
-            //                            + fPkg.getDefaultPath(), OpenFile\r
-            //                            .openFpdFile(Workspace.getCurrentWorkspace()\r
-            //                                    + File.separatorChar\r
-            //                                    + fPkg.getDefaultPath()\r
-            //                                    + File.separatorChar\r
-            //                                    + fPkg.getFarFile().getRelativeFilename()));\r
+            PackageIdentification pkgId = new PackageIdentification(fPkg.getFarFile().getRelativeFilename(), fPkg.getGuidValue(), fPkg.getVersion());\r
+            pkgId.setPath(Workspace.getCurrentWorkspace() + File.separatorChar + fPkg.getDefaultPath() + File.separatorChar + fPkg.getFarFile().getRelativeFilename());\r
+//            wsTool.getId(\r
+//                    Workspace.getCurrentWorkspace() + File.separatorChar\r
+//                            + fPkg.getDefaultPath(), OpenFile\r
+//                            .openFpdFile(Workspace.getCurrentWorkspace()\r
+//                                    + File.separatorChar\r
+//                                    + fPkg.getDefaultPath()\r
+//                                    + File.separatorChar\r
+//                                    + fPkg.getFarFile().getRelativeFilename()));\r
             pkgList.add(pkgId);\r
         }\r
         return pkgList;\r
@@ -364,7 +361,8 @@ public class Mainfest implements ManifestInterface {
     /**\r
      * \r
      */\r
-    public List<PlatformIdentification> getPlatformList() throws Exception, IOException, XmlException {\r
+    public List<PlatformIdentification> getPlatformList() throws Exception,\r
+            IOException, XmlException {\r
         //\r
         // PlatformIdentification set.\r
         //\r
@@ -372,21 +370,21 @@ public class Mainfest implements ManifestInterface {
         Iterator plfItem = this.fPlfList.iterator();\r
         while (plfItem.hasNext()) {\r
             FarPlatformItem fpfItem = (FarPlatformItem) plfItem.next();\r
-            File file = new File(Workspace.getCurrentWorkspace() + File.separatorChar\r
-                                 + fpfItem.getFarFile().getRelativeFilename());\r
+            File file = new File(Workspace.getCurrentWorkspace()\r
+                    + File.separatorChar \r
+                    + fpfItem.getFarFile().getRelativeFilename());\r
             //\r
             // Set platformIdentificaiton's path as absolutly path (include\r
             // workspace and FPD relatively path)\r
             //\r
-            PlatformIdentification plfId = new PlatformIdentification(fpfItem.getFarFile().getRelativeFilename(),\r
-                                                                      fpfItem.getGuidValue(), fpfItem.getVersion(),\r
-                                                                      file.getPath());\r
-\r
-            //                (PlatformIdentification) wsTool\r
-            //                    .getId(file.getParent(), OpenFile.openFpdFile(Workspace\r
-            //                            .getCurrentWorkspace()\r
-            //                            + File.separatorChar\r
-            //                            + fpfItem.getFarFile().getRelativeFilename()));\r
+            PlatformIdentification plfId = new PlatformIdentification (fpfItem.getFarFile().getRelativeFilename(), fpfItem.getGuidValue(),fpfItem.getVersion(),\r
+                    file.getPath());\r
+            \r
+//                (PlatformIdentification) wsTool\r
+//                    .getId(file.getParent(), OpenFile.openFpdFile(Workspace\r
+//                            .getCurrentWorkspace()\r
+//                            + File.separatorChar\r
+//                            + fpfItem.getFarFile().getRelativeFilename()));\r
             plfList.add(plfId);\r
         }\r
         return plfList;\r
@@ -395,19 +393,20 @@ public class Mainfest implements ManifestInterface {
     public List<FarFileItem> getPlatformContents(PlatformIdentification platformId) {\r
         List<FarFileItem> result = new ArrayList<FarFileItem>();\r
         Iterator<FarPlatformItem> iter = this.fPlfList.iterator();\r
-\r
+        \r
         while (iter.hasNext()) {\r
             FarPlatformItem item = iter.next();\r
             if (item.isIdentityPlf(platformId)) {\r
                 FarFileItem farFileItem = item.getFarFile();\r
                 farFileItem.setDefaultPath(farFileItem.getRelativeFilename());\r
+                farFileItem.setRelativeFilename(Tools.getFileNameOnly(farFileItem.getRelativeFilename()));\r
                 result.add(farFileItem);\r
-                break;\r
+                break ;\r
             }\r
         }\r
         return result;\r
     }\r
-\r
+    \r
     public List<FarFileItem> getPackageContents(PackageIdentification packageId) {\r
         List<FarFileItem> farFileList = new ArrayList<FarFileItem>();\r
         Iterator pkgItem = this.fPkgList.iterator();\r
@@ -425,22 +424,23 @@ public class Mainfest implements ManifestInterface {
                 //\r
                 // Add all farfiles in <FarPlatformList> to list.\r
                 //\r
-                //                List<FarPlatformItem> plfList = pkg.getFarPlatformList();\r
-                //                Iterator plfItem = plfList.iterator();\r
-                //                while (plfItem.hasNext()) {\r
-                //                    farFileList.add(((FarPlatformItem) plfItem.next())\r
-                //                            .getFarFile());\r
-                //                }\r
-\r
+//                List<FarPlatformItem> plfList = pkg.getFarPlatformList();\r
+//                Iterator plfItem = plfList.iterator();\r
+//                while (plfItem.hasNext()) {\r
+//                    farFileList.add(((FarPlatformItem) plfItem.next())\r
+//                            .getFarFile());\r
+//                }\r
+                \r
                 Iterator<FarFileItem> ffIter = farFileList.iterator();\r
-                while (ffIter.hasNext()) {\r
-                    FarFileItem ffItem = ffIter.next();\r
+                while(ffIter.hasNext()){\r
+                    FarFileItem  ffItem = ffIter.next();\r
                     ffItem.setDefaultPath(pkg.getDefaultPath() + File.separatorChar + ffItem.getRelativeFilename());\r
                 }\r
                 break;\r
             }\r
         }\r
 \r
+        \r
         return farFileList;\r
     }\r
 \r
@@ -449,20 +449,20 @@ public class Mainfest implements ManifestInterface {
      * @param pkgId\r
      * @return String: return string represent jar file entry; \r
      */\r
-    public String[] getPackgeSpd(PackageIdentification pkgId) {\r
+    public String[] getPackgeSpd(PackageIdentification pkgId){\r
         Iterator pkgItem = this.fPkgList.iterator();\r
         String[] entryStr = new String[2];\r
         while (pkgItem.hasNext()) {\r
             FarPackage pkg = (FarPackage) pkgItem.next();\r
             if (pkg.isIdentityPkg(pkgId)) {\r
-                entryStr[0] = pkg.getFarFile().getRelativeFilename();\r
-                entryStr[1] = pkg.getDefaultPath();\r
+                entryStr[0] =  pkg.getFarFile().getRelativeFilename();\r
+                entryStr[1] = pkg.getDefaultPath() ;\r
                 return entryStr;\r
             }\r
         }\r
         return null;\r
-    }\r
-\r
+    } \r
+    \r
     public List<FarFileItem> getPackageContents() {\r
         //\r
         // In this farFilelist,all FarFileItem's relativeFileName should be\r
@@ -482,16 +482,18 @@ public class Mainfest implements ManifestInterface {
             //\r
             // Set farFileItem relativeFileName = absolutePath + file Name.\r
             //\r
-            farFileList.add(new FarFileItem(pkg.getDefaultPath() + File.separatorChar + ffItem.getRelativeFilename(),\r
-                                            ffItem.getMd5Value()));\r
+            farFileList.add(new FarFileItem(pkg.getDefaultPath()\r
+                    + File.separatorChar + ffItem.getRelativeFilename(), ffItem\r
+                    .getMd5Value()));\r
             //\r
             // Add all files in contents to list.\r
             //\r
             Iterator contentsItem = pkg.getContentList().iterator();\r
             while (contentsItem.hasNext()) {\r
                 ffItem = (FarFileItem) contentsItem.next();\r
-                farFileList.add(new FarFileItem(pkg.getDefaultPath() + File.separator + ffItem.getRelativeFilename(),\r
-                                                ffItem.getMd5Value()));\r
+                farFileList.add(new FarFileItem(pkg.getDefaultPath()\r
+                        + File.separator + ffItem.getRelativeFilename(), ffItem\r
+                        .getMd5Value()));\r
             }\r
             //\r
             // Add all farfiles in <FarPlatformList> to list.\r
@@ -500,8 +502,9 @@ public class Mainfest implements ManifestInterface {
             Iterator plfItem = plfList.iterator();\r
             while (plfItem.hasNext()) {\r
                 ffItem = ((FarPlatformItem) plfItem.next()).getFarFile();\r
-                farFileList.add(new FarFileItem(pkg.getDefaultPath() + File.separator + ffItem.getRelativeFilename(),\r
-                                                ffItem.getMd5Value()));\r
+                farFileList.add(new FarFileItem(pkg.getDefaultPath()\r
+                        + File.separator + ffItem.getRelativeFilename(), ffItem\r
+                        .getMd5Value()));\r
             }\r
         }\r
         return farFileList;\r
@@ -517,29 +520,29 @@ public class Mainfest implements ManifestInterface {
         }\r
         return null;\r
     }\r
-\r
-    //    public void setPackageInstallPath(PackageIdentification packageId, String path) {\r
-    //        Iterator<FarPackage> pkgItr = this.fPkgList.iterator();\r
-    //        while (pkgItr.hasNext()) {\r
-    //            FarPackage farPackage = pkgItr.next();\r
-    //            if (farPackage.isIdentityPkg(packageId)) {\r
-    //                farPackage.setDefaultPath(path);\r
-    //                return ;\r
-    //            }\r
-    //        }\r
-    //    }\r
-    //\r
-    //    public void setPlatformInstallPath(PlatformIdentification platformId, String path) {\r
-    //        Iterator<FarPlatformItem> plfItr = this.fPlfList.iterator();\r
-    //        while (plfItr.hasNext()) {\r
-    //            FarPlatformItem farPlatform = plfItr.next();\r
-    //            if (farPlatform.i.isIdentity(platformId)) {\r
-    //                farPackage.setDefaultPath(path);\r
-    //                return ;\r
-    //            }\r
-    //        }\r
-    //    }\r
-\r
+    \r
+//    public void setPackageInstallPath(PackageIdentification packageId, String path) {\r
+//        Iterator<FarPackage> pkgItr = this.fPkgList.iterator();\r
+//        while (pkgItr.hasNext()) {\r
+//            FarPackage farPackage = pkgItr.next();\r
+//            if (farPackage.isIdentityPkg(packageId)) {\r
+//                farPackage.setDefaultPath(path);\r
+//                return ;\r
+//            }\r
+//        }\r
+//    }\r
+//\r
+//    public void setPlatformInstallPath(PlatformIdentification platformId, String path) {\r
+//        Iterator<FarPlatformItem> plfItr = this.fPlfList.iterator();\r
+//        while (plfItr.hasNext()) {\r
+//            FarPlatformItem farPlatform = plfItr.next();\r
+//            if (farPlatform.i.isIdentity(platformId)) {\r
+//                farPackage.setDefaultPath(path);\r
+//                return ;\r
+//            }\r
+//        }\r
+//    }\r
+    \r
     public List<FarFileItem> getAllFileItem() {\r
         //\r
         // The farFileName in this list are all abosulte path.\r
@@ -553,7 +556,8 @@ public class Mainfest implements ManifestInterface {
         //\r
         // Add far files in <FarPlatformList> to list\r
         //\r
-        NodeList elementList = this.mainfestDoc.getElementsByTagName(farPlatformList);\r
+        NodeList elementList = this.mainfestDoc\r
+                .getElementsByTagName(farPlatformList);\r
         for (int i = 0; i < elementList.getLength(); i++) {\r
             //\r
             // Get <farPlatform> node list.\r
@@ -571,13 +575,15 @@ public class Mainfest implements ManifestInterface {
                     //\r
                     // Get child node value and set to platformIdentification.\r
                     //\r
-                    if (tempNode.getNodeName().equalsIgnoreCase(farPackage_FarfileName)) {\r
+                    if (tempNode.getNodeName().equalsIgnoreCase(\r
+                            farPackage_FarfileName)) {\r
                         NamedNodeMap farAttr = tempNode.getAttributes();\r
                         //\r
                         // Change relative path to absolute one\r
                         //\r
-                        FarFileItem farFile = new FarFileItem(tempNode.getTextContent(),\r
-                                                              farAttr.getNamedItem(farFileName_Md5sum).getTextContent());\r
+                        FarFileItem farFile = new FarFileItem(tempNode\r
+                                .getTextContent(), farAttr.getNamedItem(\r
+                                farFileName_Md5sum).getTextContent());\r
                         ffiList.add(farFile);\r
                     }\r
                 }\r
@@ -590,7 +596,8 @@ public class Mainfest implements ManifestInterface {
         //\r
         // create mainfest root node\r
         //\r
-        Element rootNode = this.mainfestDoc.createElement("FrameworkArchiveManifest");\r
+        Element rootNode = this.mainfestDoc\r
+                .createElement("FrameworkArchiveManifest");\r
         this.mainfestDoc.appendChild(rootNode);\r
 \r
         //\r
@@ -668,7 +675,8 @@ public class Mainfest implements ManifestInterface {
         // Write the DOM document to the file\r
         //\r
         Transformer xformer = TransformerFactory.newInstance().newTransformer();\r
-        xformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2");\r
+        xformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount",\r
+                "2");\r
         xformer.setOutputProperty(OutputKeys.INDENT, "yes");\r
 \r
         //\r
@@ -679,7 +687,8 @@ public class Mainfest implements ManifestInterface {
         // Prepare the output file, get the Mainifest file name from <FarHeader>\r
         // /<FarName>.\r
         //\r
-        this.mfFile = new File(Workspace.getCurrentWorkspace() + File.separatorChar + mfFileName);\r
+        this.mfFile = new File(Workspace.getCurrentWorkspace()\r
+                + File.separatorChar + mfFileName);\r
         //\r
         // generate all directory path\r
         //\r
@@ -688,7 +697,8 @@ public class Mainfest implements ManifestInterface {
     }\r
 \r
     public void pkgToFarPkgNode(Element parentNode, FarPackage pkgItem) {\r
-        Element pkgNode = this.mainfestDoc.createElement(farPackageList_FarPackage);\r
+        Element pkgNode = this.mainfestDoc\r
+                .createElement(farPackageList_FarPackage);\r
         //\r
         // Add <FarFileName>\r
         //\r
@@ -704,7 +714,8 @@ public class Mainfest implements ManifestInterface {
         //\r
         // Add <DefaultPath>\r
         //\r
-        setStrItemToNode(pkgNode, pkgItem.getDefaultPath(), farPackage_DefaultPath);\r
+        setStrItemToNode(pkgNode, pkgItem.getDefaultPath(),\r
+                farPackage_DefaultPath);\r
 \r
         //\r
         // Add <Contents>\r
@@ -719,7 +730,8 @@ public class Mainfest implements ManifestInterface {
     }\r
 \r
     public void PlfToPlatformNode(Element parentNode, FarPlatformItem fplItem) {\r
-        Element fplNode = this.mainfestDoc.createElement(farPlatformList_FarPlatform);\r
+        Element fplNode = this.mainfestDoc\r
+                .createElement(farPlatformList_FarPlatform);\r
         //\r
         // Add <FarFileName>\r
         //\r
@@ -740,15 +752,17 @@ public class Mainfest implements ManifestInterface {
     }\r
 \r
     public void ffiToFfNode(Element parentNode, FarFileItem ffi) {\r
-        Element farFileName = this.mainfestDoc.createElement(farPackage_FarfileName);\r
+        Element farFileName = this.mainfestDoc\r
+                .createElement(farPackage_FarfileName);\r
         farFileName.setTextContent(ffi.getRelativeFilename());\r
         System.out.println(farFileName.getTextContent());\r
-        System.out.println(ffi.getRelativeFilename());\r
+        System.out.println(ffi.getRelativeFilename()); \r
         farFileName.setAttribute(farFileName_Md5sum, ffi.getMd5Value());\r
         parentNode.appendChild(farFileName);\r
     }\r
 \r
-    public void setStrItemToNode(Element parentNode, String strValue, String strName) {\r
+    public void setStrItemToNode(Element parentNode, String strValue,\r
+            String strName) {\r
         Element node = this.mainfestDoc.createElement(strName);\r
         node.setTextContent(strValue);\r
         parentNode.appendChild(node);\r
@@ -790,13 +804,13 @@ public class Mainfest implements ManifestInterface {
         } else {\r
             return;\r
         }\r
-        NodeList childList = headerNode.getChildNodes();\r
+               NodeList childList = headerNode.getChildNodes();\r
         Node node = null;\r
         String nodeName = null;\r
         for (int i = 0; i < childList.getLength(); i++) {\r
             node = childList.item(i);\r
             nodeName = node.getNodeName();\r
-            if (nodeName.equalsIgnoreCase(farHeader_FarName)) {\r
+          if (nodeName.equalsIgnoreCase(farHeader_FarName)) {\r
                 String nodeValue = node.getTextContent();\r
                 this.fhInfo.setFarName(nodeValue);\r
             } else if (nodeName.equalsIgnoreCase(guidValue)) {\r
@@ -830,7 +844,7 @@ public class Mainfest implements ManifestInterface {
         }\r
         NodeList fpnList = farPkgNode.getChildNodes();\r
         for (int i = 0; i < fpnList.getLength(); i++) {\r
-            if (fpnList.item(i).getNodeType() == Node.TEXT_NODE) {\r
+            if (fpnList.item(i).getNodeType()== Node.TEXT_NODE){\r
                 continue;\r
             }\r
             FarPackage fpItem = new FarPackage();\r
@@ -871,14 +885,15 @@ public class Mainfest implements ManifestInterface {
      * @param fpfListNode\r
      * @param plfList\r
      */\r
-    public void parseFarPlatformList(Node fpfListNode, List<FarPlatformItem> plfList) {\r
+    public void parseFarPlatformList(Node fpfListNode,\r
+            List<FarPlatformItem> plfList) {\r
         //\r
         // Get <FarPlatform> list.\r
         //\r
         NodeList child = fpfListNode.getChildNodes();\r
         Node farPlfNode;\r
         for (int i = 0; i < child.getLength(); i++) {\r
-            if (child.item(i).getNodeType() == Node.TEXT_NODE) {\r
+            if (child.item(i).getNodeType()== Node.TEXT_NODE){\r
                 continue;\r
             }\r
             farPlfNode = child.item(i);\r
@@ -921,7 +936,7 @@ public class Mainfest implements ManifestInterface {
         NodeList contentList = contentsNode.getChildNodes();\r
         Node contentNode;\r
         for (int i = 0; i < contentList.getLength(); i++) {\r
-            if (contentList.item(i).getNodeType() == Node.TEXT_NODE) {\r
+            if (contentList.item(i).getNodeType()== Node.TEXT_NODE){\r
                 continue;\r
             }\r
             contentNode = contentList.item(i);\r
@@ -935,20 +950,21 @@ public class Mainfest implements ManifestInterface {
     public FarFileItem parseFarFile(Node farFileNode) {\r
         String ffName = farFileNode.getTextContent();\r
         NamedNodeMap attr = farFileNode.getAttributes();\r
-        FarFileItem ffItem = new FarFileItem(ffName, attr.getNamedItem(farFileName_Md5sum).getTextContent());\r
+        FarFileItem ffItem = new FarFileItem(ffName, attr.getNamedItem(\r
+                farFileName_Md5sum).getTextContent());\r
         return ffItem;\r
     }\r
 \r
     public boolean isFilter(File file, Set<String> fileter) {\r
-        Iterator<String> iter = fileter.iterator();\r
-        while (iter.hasNext()) {\r
-            Pattern pattern = Pattern.compile(iter.next());\r
-            Matcher matcher = pattern.matcher(file.getName());\r
-\r
-            if (matcher.find()) {\r
-                return true;\r
+      Iterator<String> iter = fileter.iterator();\r
+      while (iter.hasNext()) {\r
+        Pattern pattern = Pattern.compile(iter.next());\r
+        Matcher matcher = pattern.matcher(file.getName());\r
+        \r
+        if(matcher.find()) {\r
+                    return true;\r
+                }\r
             }\r
-        }\r
         return false;\r
     }\r
 \r
index 755dbf33690dbeb48afd4c10e82934ae3ab41fed..f6864cb891340edf70c92dc5d52241b32046e7a8 100644 (file)
@@ -19,6 +19,7 @@ import java.awt.event.MouseEvent;
 import java.awt.event.MouseListener;\r
 import java.io.File;\r
 import java.util.Vector;\r
+import java.util.jar.JarFile;\r
 \r
 import javax.swing.JFileChooser;\r
 import javax.swing.JPanel;\r
@@ -230,42 +231,51 @@ public class UpdateStepOne extends IDialog implements MouseListener {
         return jContentPane;\r
     }\r
 \r
-    public void mouseClicked(MouseEvent e) {\r
-        if (e.getSource() == jButtonCancel) {\r
-            this.setVisible(false);\r
-        } else if (e.getSource() == jButtonNext) {\r
-            //\r
-            // Judge if FAR file is existed\r
-            //\r
-            farFile = new File(jTextFieldFarFile.getText());\r
-            if (!farFile.exists() || !farFile.isFile()) {\r
-                Log.err("Please choose a FAR file already exists. ");\r
-                return;\r
-            }\r
-\r
-            //\r
-            // Judge FAR is valid\r
-            //\r
-\r
-            //\r
-            // Add more logic process here\r
-            //\r
-            if (jListFarFromDb.getSelectedValue() == null) {\r
-                Log.err("Please choose a FAR from framework database. ");\r
-                return;\r
-            }\r
-\r
-            if (stepTwo == null) {\r
+  public void mouseClicked(MouseEvent e) {\r
+    if (e.getSource() == jButtonCancel) {\r
+      this.setVisible(false);\r
+    }\r
+    else if (e.getSource() == jButtonNext) {\r
+      //\r
+      // Judge if FAR file is existed\r
+      //\r
+      farFile = new File(jTextFieldFarFile.getText());\r
+      if ( ! farFile.exists() || ! farFile.isFile()) {\r
+        Log.err("Please choose a FAR file already exists. ");\r
+        return ;\r
+      } \r
+      \r
+      //\r
+      // Judge FAR is valid\r
+      //\r
+      try{\r
+          JarFile file = new JarFile(farFile);\r
+          this.far  = new Far(file);\r
+      } catch (Exception ex){\r
+          Log.err(ex.getMessage());\r
+      }\r
+      \r
+      \r
+      //\r
+      // Add more logic process here\r
+      //\r
+      if (jListFarFromDb.getSelectedValue() == null) {\r
+        Log.err("Please choose a FAR from framework database. ");\r
+        return ;\r
+      }\r
+      \r
+      if (stepTwo == null) {\r
                 stepTwo = new UpdateStepTwo(this, true, this);\r
-            }\r
-            this.setVisible(false);\r
-            stepTwo.prepareTable();\r
-            stepTwo.setVisible(true);\r
-        } else if (e.getSource() == jButtonBrowser) {\r
-            JFileChooser fc = new JFileChooser();\r
-            fc.setAcceptAllFileFilterUsed(false);\r
-            fc.addChoosableFileFilter(new IFileFilter(DataType.FAR_SURFACE_AREA_EXT));\r
-            fc.setCurrentDirectory(new File(Workspace.getCurrentWorkspace()));\r
+      }\r
+      this.setVisible(false);\r
+      stepTwo.prepareTable();\r
+      stepTwo.setVisible(true);\r
+    }\r
+    else if (e.getSource() == jButtonBrowser) {\r
+      JFileChooser fc = new JFileChooser();\r
+      fc.setAcceptAllFileFilterUsed(false);\r
+      fc.addChoosableFileFilter(new IFileFilter(DataType.FAR_SURFACE_AREA_EXT));\r
+      fc.setCurrentDirectory(new File(Workspace.getCurrentWorkspace()));\r
 \r
             int result = fc.showSaveDialog(new JPanel());\r
             if (result == JFileChooser.APPROVE_OPTION) {\r
index 1dd4c4877f043af31f8eec95a6ae084f59f18360..f455604f6215d80c9249e741abe7e121f753f963 100644 (file)
@@ -17,8 +17,13 @@ import java.awt.Dimension;
 import java.awt.Toolkit;\r
 import java.awt.event.MouseEvent;\r
 import java.awt.event.MouseListener;\r
+import java.io.File;\r
+import java.util.ArrayList;\r
 import java.util.Iterator;\r
+import java.util.LinkedHashSet;\r
 import java.util.List;\r
+import java.util.Set;\r
+import java.util.Vector;\r
 \r
 import javax.swing.JPanel;\r
 import javax.swing.JTextArea;\r
@@ -29,11 +34,14 @@ import javax.swing.JTable;
 import javax.swing.ListSelectionModel;\r
 import javax.swing.table.DefaultTableModel;\r
 \r
+import org.tianocore.frameworkwizard.common.Log;\r
 import org.tianocore.frameworkwizard.common.Tools;\r
 import org.tianocore.frameworkwizard.common.ui.IDialog;\r
 import org.tianocore.frameworkwizard.far.AggregationOperation;\r
+import org.tianocore.frameworkwizard.far.DistributeRule;\r
 import org.tianocore.frameworkwizard.far.Far;\r
 import org.tianocore.frameworkwizard.packaging.PackageIdentification;\r
+import org.tianocore.frameworkwizard.platform.PlatformIdentification;\r
 import org.tianocore.frameworkwizard.workspace.Workspace;\r
 import org.tianocore.frameworkwizard.workspace.WorkspaceTools;\r
 \r
@@ -63,6 +71,7 @@ public class UpdateStepTwo extends IDialog implements MouseListener {
     private JTable jTablePackage = null;\r
 \r
     private PartialTableModel model = null;\r
+  List<PackageIdentification> updatPkgList = new ArrayList<PackageIdentification>();\r
 \r
     public UpdateStepTwo(IDialog iDialog, boolean modal, UpdateStepOne stepOne) {\r
         this(iDialog, modal);\r
@@ -174,24 +183,25 @@ public class UpdateStepTwo extends IDialog implements MouseListener {
             WorkspaceTools wt = new WorkspaceTools();\r
             List<PackageIdentification> packagesInDb = wt.getAllPackages();\r
 \r
-            List<PackageIdentification> result = AggregationOperation.intersection(packagesInDb, packagesInFar);\r
+      updatPkgList = AggregationOperation.intersection(packagesInDb, packagesInFar);\r
             //\r
             // Change here to get packages and platforms from FAR\r
             //\r
-            Iterator<PackageIdentification> iter = result.iterator();//packageList.iterator();\r
-            while (iter.hasNext()) {\r
-                String[] str = new String[4];\r
-                PackageIdentification item = iter.next();\r
-                str[0] = item.getName();\r
-                str[1] = item.getVersion();\r
-                str[2] = item.getGuid();\r
-                str[3] = Tools.getFilePathOnly(Tools.getRelativePath(item.getPath(), Workspace.getCurrentWorkspace()));\r
-                model.addRow(str);\r
-            }\r
-        } catch (Exception ex) {\r
-            ex.printStackTrace();\r
-        }\r
+      Iterator<PackageIdentification> iter = updatPkgList.iterator() ;//packageList.iterator();\r
+      while (iter.hasNext()) {\r
+        String[] str = new String[4];\r
+        PackageIdentification item = iter.next();\r
+        str[0] = item.getName();\r
+        str[1] = item.getVersion();\r
+        str[2] = item.getGuid();\r
+        str[3] = Tools.getFilePathOnly(Tools.getRelativePath(item.getPath(), Workspace.getCurrentWorkspace()));\r
+        model.addRow(str);\r
+      } \r
+    }\r
+    catch (Exception ex) {\r
+      ex.printStackTrace();\r
     }\r
+  }\r
 \r
     /**\r
      * This is the default constructor\r
@@ -214,85 +224,184 @@ public class UpdateStepTwo extends IDialog implements MouseListener {
         this.setLocation((d.width - this.getSize().width) / 2, (d.height - this.getSize().height) / 2);\r
     }\r
 \r
-    /**\r
-     * This method initializes jContentPane\r
-     * \r
-     * @return javax.swing.JPanel\r
-     */\r
-    private JPanel getJContentPane() {\r
-        if (jContentPane == null) {\r
-            jLabel = new JLabel();\r
-            jLabel.setBounds(new java.awt.Rectangle(30, 70, 281, 20));\r
-            jLabel.setText("Following packages will be updated: ");\r
-            jContentPane = new JPanel();\r
-            jContentPane.setLayout(null);\r
-            jContentPane.add(getJTextArea(), null);\r
-            jContentPane.add(getJButtonCancel(), null);\r
-            jContentPane.add(getJButtonFinish(), null);\r
-            jContentPane.add(getJButtonPrevious(), null);\r
-            jContentPane.add(getJScrollPane(), null);\r
-            jContentPane.add(jLabel, null);\r
-        }\r
-        return jContentPane;\r
+  /**\r
+   * This method initializes jContentPane\r
+   * \r
+   * @return javax.swing.JPanel\r
+   */\r
+  private JPanel getJContentPane() {\r
+    if (jContentPane == null) {\r
+      jLabel = new JLabel();\r
+      jLabel.setBounds(new java.awt.Rectangle(30,70,281,20));\r
+      jLabel.setText("Following packages will be updated: ");\r
+      jContentPane = new JPanel();\r
+      jContentPane.setLayout(null);\r
+      jContentPane.add(getJTextArea(), null);\r
+      jContentPane.add(getJButtonCancel(), null);\r
+      jContentPane.add(getJButtonFinish(), null);\r
+      jContentPane.add(getJButtonPrevious(), null);\r
+      jContentPane.add(getJScrollPane(), null);\r
+      jContentPane.add(jLabel, null);\r
     }\r
-\r
-    public void mouseClicked(MouseEvent e) {\r
-        if (e.getSource() == jButtonCancel) {\r
-            this.setVisible(false);\r
-        } else if (e.getSource() == jButtonFinish) {\r
-            //\r
-            // Check depedency ?\r
-            //\r
-\r
-            //\r
-            // Remove all update packages\r
-            //\r
-\r
-            //\r
-            // Install all update packages\r
-            //\r
-\r
-            this.setVisible(false);\r
-        } else if (e.getSource() == jButtonPrevious) {\r
-            this.setVisible(false);\r
-            stepOne.setVisible(true);\r
+    return jContentPane;\r
+  }\r
+  public void mouseClicked(MouseEvent e) {\r
+    if (e.getSource() == jButtonCancel) {\r
+      this.setVisible(false);\r
+    }\r
+    else if (e.getSource() == jButtonFinish) {\r
+      //\r
+      // Check depedency ?\r
+      //\r
+      WorkspaceTools wsTools = new WorkspaceTools();\r
+      \r
+      Iterator<PackageIdentification> iter = updatPkgList.iterator();\r
+      List<PackageIdentification> depResultList = new ArrayList<PackageIdentification>();\r
+      while (iter.hasNext()){\r
+          List<PackageIdentification> depPkgList = stepOne.getFar().getPackageDependencies(iter.next());\r
+          depResultList = AggregationOperation.union(depResultList, depPkgList);\r
+      }\r
+      \r
+      List<PackageIdentification> dbPkgList = DistributeRule.vectorToList(wsTools.getAllPackages());\r
+      List<PackageIdentification> resultList = AggregationOperation.minus(depResultList, AggregationOperation.union(\r
+              this.updatPkgList, dbPkgList));\r
+      Iterator resultIter = resultList.iterator();\r
+      while (resultIter.hasNext()){\r
+          Log.err("Missing dependency package " + ((PackageIdentification)resultIter.next()).toString() + "in workspace!");\r
+          return;\r
+      }\r
+      \r
+      //\r
+      // Remove all update packages\r
+      //\r
+      //\r
+      // For all packages, remove all files. \r
+      // Exception FPD file still in DB\r
+      //\r
+      Vector<PlatformIdentification> allPlatforms = wsTools.getAllPlatforms();\r
+      Set<File> allPlatformFiles = new LinkedHashSet<File>();\r
+      \r
+      Iterator<PlatformIdentification> allPlfIter = allPlatforms.iterator();\r
+      while (iter.hasNext()) {\r
+        allPlatformFiles.add(allPlfIter.next().getFpdFile());\r
+      }\r
+      \r
+      Iterator<PackageIdentification> packageIter = this.updatPkgList.iterator();\r
+      while (packageIter.hasNext()) {\r
+        PackageIdentification item = packageIter.next();\r
+        Set<File> deleteFiles = new LinkedHashSet<File>();\r
+        recursiveDir(deleteFiles, item.getSpdFile().getParentFile(), allPlatformFiles);\r
+        Iterator<File> iterDeleteFile = deleteFiles.iterator();\r
+        while (iterDeleteFile.hasNext()){\r
+          deleteFiles(iterDeleteFile.next());\r
+        }\r
+        //\r
+        // Remove all empty parent dir\r
+        //\r
+        File parentDir = item.getSpdFile().getParentFile();\r
+        while (parentDir.listFiles().length == 0) {\r
+          File tempFile = parentDir;\r
+          parentDir = parentDir.getParentFile();\r
+          tempFile.delete();\r
         }\r
+      }\r
+      \r
+      //\r
+      // Install all update packages\r
+      //\r
+      Iterator<PackageIdentification> updataIter = this.updatPkgList.iterator();\r
+      while (updataIter.hasNext()){\r
+          PackageIdentification pkgId = updataIter.next();\r
+          try{\r
+              stepOne.getFar().installPackage(pkgId, pkgId.getSpdFile());\r
+          }catch (Exception ex){\r
+              Log.err("Can install " + pkgId.toString() + " pakcage, please check it!");\r
+          }\r
+          \r
+      }\r
+      \r
+      \r
+      this.setVisible(false);\r
     }\r
-\r
-    public void mousePressed(MouseEvent e) {\r
-        // TODO Auto-generated method stub\r
-\r
+    else if (e.getSource() == jButtonPrevious) {\r
+      this.setVisible(false);\r
+      stepOne.setVisible(true);\r
     }\r
-\r
-    public void mouseReleased(MouseEvent e) {\r
-        // TODO Auto-generated method stub\r
-\r
+  }\r
+  public void mousePressed(MouseEvent e) {\r
+    // TODO Auto-generated method stub\r
+    \r
+  }\r
+  public void mouseReleased(MouseEvent e) {\r
+    // TODO Auto-generated method stub\r
+    \r
+  }\r
+  public void mouseEntered(MouseEvent e) {\r
+    // TODO Auto-generated method stub\r
+    \r
+  }\r
+  public void mouseExited(MouseEvent e) {\r
+    // TODO Auto-generated method stub\r
+    \r
+  }\r
+\r
+  private void recursiveDir(Set<File> files, File dir, Set<File> platformFiles) {\r
+      File[] fileList = dir.listFiles();\r
+      for (int i = 0; i < fileList.length; i ++) {\r
+        if (fileList[i].isFile()) {\r
+          if( ! platformFiles.contains(fileList[i])) {\r
+            files.add(fileList[i]);\r
+          }\r
+        }\r
+        else {\r
+          if (isContain(fileList[i], platformFiles)) {\r
+            recursiveDir(files, fileList[i], platformFiles);\r
+          }\r
+          else {\r
+            files.add(fileList[i]);\r
+          }\r
+        }\r
+      }\r
     }\r
-\r
-    public void mouseEntered(MouseEvent e) {\r
-        // TODO Auto-generated method stub\r
-\r
+    \r
+    private void deleteFiles(File file) {\r
+      if (file.isDirectory()) {\r
+        File[] files = file.listFiles();\r
+        for (int i = 0; i < files.length; i ++) {\r
+          deleteFiles(files[i]);\r
+        }\r
+      }\r
+      file.delete();\r
     }\r
-\r
-    public void mouseExited(MouseEvent e) {\r
-        // TODO Auto-generated method stub\r
-\r
+    \r
+    private boolean isContain(File dir, Set<File> platformFiles) {\r
+      Iterator<File> iter = platformFiles.iterator();\r
+      while (iter.hasNext()) {\r
+        File file = iter.next();\r
+        if (file.getPath().startsWith(dir.getPath())) {\r
+          //\r
+          // continue this FPD file\r
+          //\r
+          return true;\r
+        }\r
+      }\r
+      return false;\r
     }\r
+  }\r
 \r
-}\r
 \r
 class PartialTableModel extends DefaultTableModel {\r
-    /**\r
-     \r
-     */\r
-    private static final long serialVersionUID = 1L;\r
-\r
-    public boolean isCellEditable(int row, int col) {\r
-        switch (col) {\r
-        case 3:\r
-            return false;\r
-        default:\r
-            return false;\r
-        }\r
-    }\r
+  /**\r
+   * \r
+   */\r
+  private static final long serialVersionUID = 1L;\r
+\r
+  public boolean isCellEditable(int row, int col) {\r
+      switch (col){\r
+      case 3:\r
+          return false;\r
+      default:\r
+          return false; \r
+      }\r
+  }\r
 }\r