1. Support to Create/Update/Delete/Install far file
authorwuyizhong <wuyizhong@6f19259b-4bc3-4df7-8a09-765794883524>
Thu, 13 Jul 2006 05:37:22 +0000 (05:37 +0000)
committerwuyizhong <wuyizhong@6f19259b-4bc3-4df7-8a09-765794883524>
Thu, 13 Jul 2006 05:37:22 +0000 (05:37 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@950 6f19259b-4bc3-4df7-8a09-765794883524

34 files changed:
Tools/Source/FrameworkWizard/rsc/resources/images/No.JPG [new file with mode: 0644]
Tools/Source/FrameworkWizard/rsc/resources/images/Yes.JPG [new file with mode: 0644]
Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/FrameworkWizardUI.java
Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/DataType.java
Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/IFileFilter.java
Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/Identifications/Identification.java
Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/Tools.java
Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/far/AggregationOperation.java [new file with mode: 0644]
Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/far/DistributeRule.java [new file with mode: 0644]
Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/far/Far.java [new file with mode: 0644]
Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/far/FarFileItem.java [new file with mode: 0644]
Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/far/FarHeader.java [new file with mode: 0644]
Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/far/FarIdentification.java [new file with mode: 0644]
Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/far/FarInterface.java [new file with mode: 0644]
Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/far/FarMd5.java [new file with mode: 0644]
Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/far/FarPackage.java [new file with mode: 0644]
Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/far/FarPlatformItem.java [new file with mode: 0644]
Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/far/Mainfest.java [new file with mode: 0644]
Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/far/ManifestInterface.java [new file with mode: 0644]
Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/far/PackageQuery.java [new file with mode: 0644]
Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/far/PackageQueryInterface.java [new file with mode: 0644]
Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/far/createui/CreateStepFour.java [new file with mode: 0644]
Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/far/createui/CreateStepOne.java [new file with mode: 0644]
Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/far/createui/CreateStepThree.java [new file with mode: 0644]
Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/far/createui/CreateStepTwo.java [new file with mode: 0644]
Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/far/deleteui/DeleteStepOne.java [new file with mode: 0644]
Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/far/deleteui/DeleteStepTwo.java [new file with mode: 0644]
Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/far/installui/InstallStepOne.java [new file with mode: 0644]
Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/far/installui/InstallStepTwo.java [new file with mode: 0644]
Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/far/updateui/UpdateStepOne.java [new file with mode: 0644]
Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/far/updateui/UpdateStepTwo.java [new file with mode: 0644]
Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/packaging/PackageIdentification.java
Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/PlatformIdentification.java
Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/workspace/WorkspaceTools.java

diff --git a/Tools/Source/FrameworkWizard/rsc/resources/images/No.JPG b/Tools/Source/FrameworkWizard/rsc/resources/images/No.JPG
new file mode 100644 (file)
index 0000000..c3f312b
Binary files /dev/null and b/Tools/Source/FrameworkWizard/rsc/resources/images/No.JPG differ
diff --git a/Tools/Source/FrameworkWizard/rsc/resources/images/Yes.JPG b/Tools/Source/FrameworkWizard/rsc/resources/images/Yes.JPG
new file mode 100644 (file)
index 0000000..67d6539
Binary files /dev/null and b/Tools/Source/FrameworkWizard/rsc/resources/images/Yes.JPG differ
index 589a97e09bef261b13405b75dd1460055fe9c9df..6426f6b0e54c7d30ffa77341b83ef46dc6ccd57c 100644 (file)
@@ -64,6 +64,10 @@ import org.tianocore.frameworkwizard.common.ui.IDefaultMutableTreeNode;
 import org.tianocore.frameworkwizard.common.ui.IDesktopManager;\r
 import org.tianocore.frameworkwizard.common.ui.IFrame;\r
 import org.tianocore.frameworkwizard.common.ui.ITree;\r
+import org.tianocore.frameworkwizard.far.createui.CreateStepOne;\r
+import org.tianocore.frameworkwizard.far.deleteui.DeleteStepOne;\r
+import org.tianocore.frameworkwizard.far.installui.InstallStepOne;\r
+import org.tianocore.frameworkwizard.far.updateui.UpdateStepOne;\r
 import org.tianocore.frameworkwizard.module.Identifications.ModuleIdentification;\r
 import org.tianocore.frameworkwizard.module.ui.ModuleBootModes;\r
 import org.tianocore.frameworkwizard.module.ui.ModuleDataHubs;\r
@@ -1786,19 +1790,39 @@ public class FrameworkWizardUI extends IFrame implements MouseListener, TreeSele
         }\r
 \r
         if (arg0.getSource() == jMenuItemProjectCreateFar) {\r
-\r
+            CreateStepOne cso = new CreateStepOne(this, true);\r
+            int result = cso.showDialog();\r
+            if (result == DataType.RETURN_TYPE_OK) {\r
+                this.closeAll();\r
+            }\r
+            cso.dispose();\r
         }\r
 \r
         if (arg0.getSource() == jMenuItemProjectInstallFar) {\r
-            this.closeAll();\r
+            InstallStepOne iso = new InstallStepOne(this, true);\r
+            int result = iso.showDialog();\r
+            if (result == DataType.RETURN_TYPE_OK) {\r
+                this.closeAll();\r
+            }\r
+            iso.dispose();\r
         }\r
 \r
         if (arg0.getSource() == jMenuItemProjectRemoveFar) {\r
-            this.closeAll();\r
+            DeleteStepOne dso = new DeleteStepOne(this, true);\r
+            int result = dso.showDialog();\r
+            if (result == DataType.RETURN_TYPE_OK) {\r
+                this.closeAll();\r
+            }\r
+            dso.dispose();\r
         }\r
 \r
         if (arg0.getSource() == jMenuItemProjectUpdateFar) {\r
-            this.closeAll();\r
+            UpdateStepOne uso = new UpdateStepOne(this, true);\r
+            int result = uso.showDialog();\r
+            if (result == DataType.RETURN_TYPE_OK) {\r
+                this.closeAll();\r
+            }\r
+            uso.dispose();\r
         }\r
 \r
         if (arg0.getSource() == jMenuItemToolsClone) {\r
index ba50465c6b2522166739803e865811602f909b2f..cd432b1bf70fb9b5c2b87d9824708151c2b03d5e 100644 (file)
@@ -52,6 +52,9 @@ public class DataType {
 \r
     public static final int RETURN_TYPE_TEXT = 16;\r
 \r
+    public static final int RETURN_TYPE_FAR_SURFACE_AREA = 17;\r
+    \r
+    \r
     //\r
     // Define all used final variables\r
     //\r
@@ -107,6 +110,11 @@ public class DataType {
 \r
     public static final String TEXT_FILE_EXT_DESCRIPTION = TEXT_FILE + " (*." + TEXT_FILE_EXT + ")";\r
 \r
+    public static final String FAR_SURFACE_AREA = "Framework Archive";\r
+    \r
+    public static final String FAR_SURFACE_AREA_EXT = "far";\r
+    \r
+    public static final String FAR_SURFACE_AREA_EXT_DESCRIPTION = FAR_SURFACE_AREA + " (*." + FAR_SURFACE_AREA_EXT + ")";\r
     //\r
     // Define file separator for current OS\r
     //\r
index 854155adb9b01800436bdbc60a2cc3bd416f64b9..b2d2bbe9dacfd5f2c2c4d2b6a08adb900d9b32e8 100644 (file)
@@ -83,6 +83,8 @@ public class IFileFilter extends FileFilter {
             return DataType.PLATFORM_SURFACE_AREA_EXT_DESCRIPTION;\r
         if (strExt.equals(DataType.TEXT_FILE_EXT))\r
             return DataType.TEXT_FILE_EXT_DESCRIPTION;\r
+        if (strExt.equals(DataType.FAR_SURFACE_AREA_EXT))\r
+          return DataType.FAR_SURFACE_AREA_EXT_DESCRIPTION;\r
         return "";\r
     }\r
 \r
index 3a8420ce297f1b1e2f54e40c8b73201f9e74be5d..4affb03afec9d537c8cbb48b8a66a118eff5d493 100644 (file)
@@ -46,18 +46,39 @@ public class Identification {
     }\r
     \r
     public boolean equals(Object obj) {\r
-        if (obj instanceof Identification) {\r
-            Identification id = (Identification)obj;\r
-            if (path.equals(id.path)) {\r
-            //if ( name.equals(id.name) && guid.equals(id.guid) && version.equals(id.version)) {\r
-                return true;\r
-            }\r
-            return false;\r
-        }\r
-        else {\r
-            return super.equals(obj);\r
-        }\r
-    }\r
+      if (obj instanceof Identification) {\r
+          Identification id = (Identification)obj;\r
+          if (path.equals(id.path)) {\r
+          //if ( name.equals(id.name) && guid.equals(id.guid) && version.equals(id.version)) {\r
+              return true;\r
+          }\r
+          return false;\r
+      }\r
+      else {\r
+          return super.equals(obj);\r
+      }\r
+  }\r
+    \r
+    public boolean equalsWithGuid(Object obj) {\r
+      if (obj instanceof Identification) {\r
+          Identification id = (Identification)obj;\r
+          if ( guid.equalsIgnoreCase(id.guid)) {\r
+              if (version == null || id.version == null) {\r
+                  return true;\r
+              }\r
+              else if (version.trim().equalsIgnoreCase("") || id.version.trim().equalsIgnoreCase("")){\r
+                  return true;\r
+              }\r
+              else if (version.equalsIgnoreCase(id.version)) {\r
+                  return true;\r
+              }\r
+          }\r
+          return false;\r
+      }\r
+      else {\r
+          return super.equals(obj);\r
+      }\r
+   }\r
     \r
     public void setName(String name) {\r
         this.name = name;\r
@@ -90,4 +111,8 @@ public class Identification {
        public String getPath() {\r
                return path;\r
        }\r
\r
+ public int hashCode(){\r
+   return guid.toLowerCase().hashCode();\r
+ }\r
 }\r
index 021c2373a04cd8c1d52a91da232238331d239839..517c4b1b3a8d6496d1e932c278f0bf02054866ff 100644 (file)
@@ -304,6 +304,9 @@ public class Tools {
         if (type == DataType.RETURN_TYPE_TEXT) {\r
             match = DataType.FILE_EXT_SEPARATOR + DataType.TEXT_FILE_EXT;\r
         }\r
+        if (type == DataType.RETURN_TYPE_FAR_SURFACE_AREA) {\r
+          match = DataType.FILE_EXT_SEPARATOR + DataType.FAR_SURFACE_AREA_EXT;\r
+      }\r
         if (path.length() <= match.length()) {\r
             path = path + match;\r
             return path;\r
diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/far/AggregationOperation.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/far/AggregationOperation.java
new file mode 100644 (file)
index 0000000..b8a6d40
--- /dev/null
@@ -0,0 +1,86 @@
+/** @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
+\r
+package org.tianocore.frameworkwizard.far;\r
+\r
+import java.util.ArrayList;\r
+import java.util.Iterator;\r
+import java.util.List;\r
+\r
+import org.tianocore.frameworkwizard.packaging.PackageIdentification;\r
+\r
+public class AggregationOperation {\r
+\r
+    public static synchronized List<PackageIdentification> union(List<PackageIdentification> list1,\r
+                                                                 List<PackageIdentification> list2) {\r
+        List<PackageIdentification> result = new ArrayList<PackageIdentification>();\r
+        result.addAll(list1);\r
+        Iterator<PackageIdentification> iter = list2.iterator();\r
+        while (iter.hasNext()) {\r
+            PackageIdentification item = iter.next();\r
+            if (!belongs(item, result)) {\r
+                result.add(item);\r
+            }\r
+        }\r
+        return result;\r
+    }\r
+\r
+    public static synchronized List<PackageIdentification> intersection(List<PackageIdentification> list1,\r
+                                                                        List<PackageIdentification> list2) {\r
+        List<PackageIdentification> result = new ArrayList<PackageIdentification>();\r
+        Iterator<PackageIdentification> iter = list1.iterator();\r
+        while (iter.hasNext()) {\r
+            PackageIdentification item = iter.next();\r
+            if (belongs(item, list2)) {\r
+                result.add(item);\r
+            }\r
+        }\r
+        return result;\r
+    }\r
+\r
+    public static synchronized List<PackageIdentification> minus(List<PackageIdentification> list1,\r
+                                                                 List<PackageIdentification> list2) {\r
+        List<PackageIdentification> result = new ArrayList<PackageIdentification>();\r
+        Iterator<PackageIdentification> iter = list1.iterator();\r
+        while (iter.hasNext()) {\r
+            PackageIdentification item = iter.next();\r
+            if (!belongs(item, list2)) {\r
+                result.add(item);\r
+            }\r
+        }\r
+        return result;\r
+    }\r
+\r
+    public static synchronized boolean belongs(PackageIdentification o, List<PackageIdentification> list) {\r
+        Iterator<PackageIdentification> iter = list.iterator();\r
+        while (iter.hasNext()) {\r
+            if (iter.next().equalsWithGuid(o)) {\r
+                return true;\r
+            }\r
+        }\r
+        return false;\r
+    }\r
+\r
+    public static synchronized List<PackageIdentification> getExistedItems(PackageIdentification o,\r
+                                                                           List<PackageIdentification> list) {\r
+        List<PackageIdentification> result = new ArrayList<PackageIdentification>();\r
+        Iterator<PackageIdentification> iter = list.iterator();\r
+        while (iter.hasNext()) {\r
+            PackageIdentification item = iter.next();\r
+            if (item.equalsWithGuid(o)) {\r
+                result.add(item);\r
+            }\r
+        }\r
+        return result;\r
+    }\r
+}\r
diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/far/DistributeRule.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/far/DistributeRule.java
new file mode 100644 (file)
index 0000000..e6b19b3
--- /dev/null
@@ -0,0 +1,99 @@
+/** @file\r
\r
+ The file is used to distribute Far\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
+import java.util.ArrayList;\r
+import java.util.Iterator;\r
+import java.util.List;\r
+import java.util.Vector;\r
+\r
+import org.tianocore.frameworkwizard.packaging.PackageIdentification;\r
+import org.tianocore.frameworkwizard.workspace.WorkspaceTools;\r
+\r
+public class DistributeRule {\r
+    static PackageQuery pkgQ = new PackageQuery();\r
+\r
+    static WorkspaceTools wsTools = new WorkspaceTools();\r
+\r
+    static List<PackageIdentification> farPkgList = new ArrayList<PackageIdentification>();\r
+\r
+    public static List<PackageIdentification> installFarCheck(Far far) {\r
+\r
+        Far myFar = far;\r
+        List<PackageIdentification> pkgDepList = new ArrayList<PackageIdentification>();\r
+        List<PackageIdentification> dbPkgList = new ArrayList<PackageIdentification>();\r
+        List<PackageIdentification> depResultList = new ArrayList<PackageIdentification>();\r
+        //\r
+        // Get Far packages list;\r
+        // \r
+        try {\r
+            farPkgList = myFar.mainfest.getPackageList();\r
+            Iterator pkgItems = farPkgList.iterator();\r
+            while (pkgItems.hasNext()) {\r
+                PackageIdentification id = (PackageIdentification) pkgItems.next();\r
+                pkgDepList = myFar.getPackageDependencies(id);\r
+                depResultList = AggregationOperation.union(depResultList, pkgDepList);\r
+            }\r
+            dbPkgList = vectorToList(wsTools.getAllPackages());\r
+\r
+        } catch (Exception e) {\r
+            System.out.println(e.getMessage());\r
+        }\r
+\r
+        //\r
+        // Check does the dependence meet the requirement.\r
+        //\r
+        List<PackageIdentification> resultList = AggregationOperation.minus(depResultList,\r
+                                                                            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
+    }\r
+\r
+    //    public void installPackgCheck (PackageIdentification pkgId, String pkgPath){\r
+    //        List<PackageIdentification> dbPkgList = new ArrayList<PackageIdentification>();\r
+    //        dbPkgList = vectorToList(wsTools.getAllPackages());\r
+    //        //\r
+    //        // Install far's package one by one.\r
+    //        //\r
+    //        if ((AggregationOperation.getExistItems(pkgId, dbPkgList))){\r
+    //            \r
+    //        }\r
+    //    }\r
+\r
+    public void UpdatCheck(String orgFar, String destFar) {\r
+\r
+    }\r
+\r
+    public static List<PackageIdentification> vectorToList(Vector vec) {\r
+        List<PackageIdentification> set = new ArrayList<PackageIdentification>();\r
+        Iterator vecItem = vec.iterator();\r
+        while (vecItem.hasNext()) {\r
+            set.add((PackageIdentification) vecItem.next());\r
+        }\r
+        return set;\r
+    }\r
+\r
+}\r
diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/far/Far.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/far/Far.java
new file mode 100644 (file)
index 0000000..21a86f5
--- /dev/null
@@ -0,0 +1,259 @@
+/** @file\r
\r
+ The file is used to create far 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.frameworkwizard.far;\r
+\r
+import java.io.File;\r
+import java.io.FileInputStream;\r
+import java.io.FileOutputStream;\r
+import java.io.InputStream;\r
+import java.util.ArrayList;\r
+import java.util.Enumeration;\r
+import java.util.Iterator;\r
+import java.util.List;\r
+import java.util.Map;\r
+import java.util.Set;\r
+import java.util.jar.JarEntry;\r
+import java.util.jar.JarFile;\r
+import java.util.jar.JarOutputStream;\r
+\r
+import org.tianocore.frameworkwizard.common.Tools;\r
+import org.tianocore.frameworkwizard.packaging.PackageIdentification;\r
+import org.tianocore.frameworkwizard.platform.PlatformIdentification;\r
+import org.tianocore.frameworkwizard.workspace.Workspace;\r
+\r
+public class Far {\r
+    //\r
+    // Class member Mainfest\r
+    //\r
+    public Mainfest mainfest = null;\r
+\r
+    //\r
+    // Jar file\r
+    //\r
+    private JarFile jf = null;\r
+\r
+    private File jarFile = null;\r
+\r
+    //\r
+    // Jar outputStream.\r
+    //\r
+    static public JarOutputStream jos = null;\r
+\r
+    public Far(File jarFile) {\r
+        this.jarFile = jarFile;\r
+    }\r
+\r
+    //\r
+    // For install/updat jar\r
+    //\r
+    public Far(JarFile farFile) throws Exception {\r
+        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
+        jos = new JarOutputStream(new FileOutputStream(jarFile));\r
+\r
+        //\r
+        // Generate Manifest and get file lists\r
+        //\r
+        this.mainfest = new Mainfest();\r
+        this.mainfest.setFarHeader(fHeader);\r
+        this.mainfest.createManifest(pkgList, plfList, fileFilter);\r
+\r
+        this.mainfest.hibernateToFile();\r
+\r
+        //\r
+        // Write Mainifest file to JAR.\r
+        //\r
+        if (this.mainfest.mfFile != null) {\r
+            writeToJar(this.mainfest.mfFile, jos);\r
+        }\r
+\r
+        //\r
+        // Write all files to JAR\r
+        //\r
+        Set<File> files = this.mainfest.files;\r
+        Iterator<File> iter = files.iterator();\r
+        while (iter.hasNext()) {\r
+            writeToJar(iter.next(), jos);\r
+        }\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
+\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
+        Set<PlatformIdentification> plfKeys = plfMap.keySet();\r
+        Iterator<PlatformIdentification> plfIter = plfKeys.iterator();\r
+        while (plfIter.hasNext()) {\r
+            PlatformIdentification item = plfIter.next();\r
+            extract(this.mainfest.getPlatformContents(item), plfMap.get(item).getPath());\r
+        }\r
+\r
+        Set<PackageIdentification> pkgKeys = pkgMap.keySet();\r
+        Iterator<PackageIdentification> pkgIter = pkgKeys.iterator();\r
+        while (pkgIter.hasNext()) {\r
+            PackageIdentification item = pkgIter.next();\r
+            installPackage(item, pkgMap.get(item));\r
+        }\r
+        jf.close();\r
+    }\r
+\r
+    public void installPackage(PackageIdentification packageId, File installPath) throws Exception {\r
+        List<FarFileItem> contents = this.mainfest.getPackageContents(packageId);\r
+        extract(contents, installPath.getPath());\r
+    }\r
+\r
+    public InputStream getMainfestFile() throws Exception {\r
+        JarEntry je = null;\r
+        for (Enumeration e = jf.entries(); e.hasMoreElements();) {\r
+            je = (JarEntry) e.nextElement();\r
+            if (je.getName().equalsIgnoreCase(Mainfest.mfFileName))\r
+                return jf.getInputStream(je);\r
+        }\r
+        return null;\r
+    }\r
+\r
+    public void createFar() {\r
+\r
+    }\r
+\r
+    public boolean hibernateToFile() {\r
+        return true;\r
+    }\r
+\r
+    public void extract(List<FarFileItem> allFile, String dir) throws Exception {\r
+\r
+        Iterator filesItem = allFile.iterator();\r
+        FarFileItem ffItem;\r
+        JarEntry je;\r
+        new File(dir).mkdirs();\r
+        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
+                je = jf.getJarEntry(Tools.convertPathToUnixType(ffItem.getDefaultPath()));\r
+                InputStream entryStream = jf.getInputStream(je);\r
+                File file = new File(dir + ffItem.getRelativeFilename());\r
+                file.getParentFile().mkdirs();\r
+                try {\r
+                    //\r
+                    // Create the output file (clobbering the file if it\r
+                    // exists).\r
+                    //\r
+                    FileOutputStream outputStream = new FileOutputStream(file);\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
+                    } finally {\r
+                        outputStream.close();\r
+                    }\r
+                } finally {\r
+                    entryStream.close();\r
+                }\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
+     * @param pkgId\r
+     * @return\r
+     */\r
+    public List<PackageIdentification> getPackageDependencies(PackageIdentification pkgId) {\r
+        String[] entry = new String[2];\r
+        PackageQuery pkgQ = new PackageQuery();\r
+        List<PackageIdentification> result = new ArrayList<PackageIdentification>();\r
+\r
+        entry = this.mainfest.getPackgeSpd(pkgId);\r
+        if (entry[0] != null) {\r
+            try {\r
+                JarEntry je;\r
+                je = jf.getJarEntry(Tools.convertPathToUnixType(entry[1] + File.separatorChar + entry[0]));\r
+                List<String> masList = pkgQ.getPackageMsaList(jf.getInputStream(je));\r
+                Iterator item = masList.iterator();\r
+                while (item.hasNext()) {\r
+                    je = jf.getJarEntry(Tools.convertPathToUnixType(entry[1] + File.separatorChar + item.next()));\r
+                    List<PackageIdentification> pkgIdList = pkgQ.getModuleDependencies(jf.getInputStream(je));\r
+                    Iterator pkgItem = pkgIdList.iterator();\r
+                    while (pkgItem.hasNext()) {\r
+                        PackageIdentification id = (PackageIdentification) pkgItem.next();\r
+                        if (!AggregationOperation.belongs(id, result)) {\r
+                            result.add(id);\r
+                        }\r
+                    }\r
+                }\r
+            } catch (Exception e) {\r
+                System.out.println(e.getMessage());\r
+            }\r
+        }\r
+        return result;\r
+    }\r
+}\r
diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/far/FarFileItem.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/far/FarFileItem.java
new file mode 100644 (file)
index 0000000..0e6cc4a
--- /dev/null
@@ -0,0 +1,54 @@
+/** @file\r
\r
+ The file is used to save information of <FarFile> 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 FarFileItem {\r
+\r
+    private String relativeFilename;\r
+\r
+    private String md5Value;\r
+\r
+    private String defaultPath;\r
+\r
+    public FarFileItem(String relativeFilename, String md5Value) {\r
+        this.relativeFilename = relativeFilename;\r
+        this.md5Value = md5Value;\r
+    }\r
+\r
+    public String getMd5Value() {\r
+        return md5Value;\r
+    }\r
+\r
+    public String getRelativeFilename() {\r
+        return relativeFilename;\r
+    }\r
+\r
+    public void setMd5Value(String md5Value) {\r
+        this.md5Value = md5Value;\r
+    }\r
+\r
+    public void setRelativeFilename(String relativeFilename) {\r
+        this.relativeFilename = relativeFilename;\r
+    }\r
+\r
+    public String getDefaultPath() {\r
+        return defaultPath;\r
+    }\r
+\r
+    public void setDefaultPath(String defaultPath) {\r
+        this.defaultPath = defaultPath;\r
+    }\r
+\r
+}\r
diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/far/FarHeader.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/far/FarHeader.java
new file mode 100644 (file)
index 0000000..dd4f226
--- /dev/null
@@ -0,0 +1,100 @@
+/** @file\r
\r
+ The file is used to save <farPackage> information.\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 FarHeader {\r
+    //\r
+    // class member\r
+    //\r
+    private String farName;\r
+\r
+    private String guidValue;\r
+\r
+    private String version;\r
+\r
+    private String abstractStr;\r
+\r
+    private String description;\r
+\r
+    private String copyright;\r
+\r
+    private String license;\r
+\r
+    private String specification;\r
+\r
+    public String getAbstractStr() {\r
+        return abstractStr;\r
+    }\r
+\r
+    public void setAbstractStr(String abstractStr) {\r
+        this.abstractStr = abstractStr;\r
+    }\r
+\r
+    public String getCopyright() {\r
+        return copyright;\r
+    }\r
+\r
+    public void setCopyright(String copyright) {\r
+        this.copyright = copyright;\r
+    }\r
+\r
+    public String getDescription() {\r
+        return description;\r
+    }\r
+\r
+    public void setDescription(String description) {\r
+        this.description = description;\r
+    }\r
+\r
+    public String getFarName() {\r
+        return farName;\r
+    }\r
+\r
+    public void setFarName(String farName) {\r
+        this.farName = farName;\r
+    }\r
+\r
+    public String getGuidValue() {\r
+        return guidValue;\r
+    }\r
+\r
+    public void setGuidValue(String guidValue) {\r
+        this.guidValue = guidValue;\r
+    }\r
+\r
+    public String getLicense() {\r
+        return license;\r
+    }\r
+\r
+    public void setLicense(String license) {\r
+        this.license = license;\r
+    }\r
+\r
+    public String getSpecification() {\r
+        return specification;\r
+    }\r
+\r
+    public void setSpecification(String specification) {\r
+        this.specification = specification;\r
+    }\r
+\r
+    public String getVersion() {\r
+        return version;\r
+    }\r
+\r
+    public void setVersion(String version) {\r
+        this.version = version;\r
+    }\r
+}\r
diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/far/FarIdentification.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/far/FarIdentification.java
new file mode 100644 (file)
index 0000000..bd9d362
--- /dev/null
@@ -0,0 +1,44 @@
+package org.tianocore.frameworkwizard.far;\r
+\r
+public class FarIdentification {\r
+\r
+    private String guid;\r
+\r
+    private String md5Value;\r
+\r
+    private String path;\r
+\r
+    public FarIdentification(String guid, String md5Value, String path) {\r
+        this.guid = guid;\r
+        this.md5Value = md5Value;\r
+        this.path = path;\r
+    }\r
+\r
+    public String getGuid() {\r
+        return guid;\r
+    }\r
+\r
+    public void setGuid(String guid) {\r
+        this.guid = guid;\r
+    }\r
+\r
+    public String getMd5Value() {\r
+        return md5Value;\r
+    }\r
+\r
+    public void setMd5Value(String md5Value) {\r
+        this.md5Value = md5Value;\r
+    }\r
+\r
+    public String getPath() {\r
+        return path;\r
+    }\r
+\r
+    public void setPath(String path) {\r
+        this.path = path;\r
+    }\r
+\r
+    public String toString() {\r
+        return path + " [" + guid + "]";\r
+    }\r
+}\r
diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/far/FarInterface.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/far/FarInterface.java
new file mode 100644 (file)
index 0000000..04a2fb0
--- /dev/null
@@ -0,0 +1,21 @@
+package org.tianocore.frameworkwizard.far;\r
+\r
+import java.io.Reader;\r
+import java.util.Map;\r
+import java.util.Set;\r
+\r
+import org.tianocore.frameworkwizard.packaging.PackageIdentification;\r
+import org.tianocore.frameworkwizard.platform.PlatformIdentification;\r
+\r
+public interface FarInterface {\r
+\r
+    public Reader getManifestFile();\r
+\r
+    public void hibernateToFile();\r
+\r
+    public boolean extract(Map<PackageIdentification, String> packagePathes,\r
+                           Map<PlatformIdentification, String> platformPathes);\r
+\r
+    public Set<PackageIdentification> getPackageDependencies(PackageIdentification packageId);\r
+\r
+}\r
diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/far/FarMd5.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/far/FarMd5.java
new file mode 100644 (file)
index 0000000..c7b97c5
--- /dev/null
@@ -0,0 +1,40 @@
+/** @file\r
\r
+ The file is used to caculate file MD5 value.\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
+import java.io.File;\r
+import java.io.FileInputStream;\r
+import java.security.MessageDigest;\r
+\r
+public class FarMd5 {\r
+\r
+    static public String md5(File file) throws Exception {\r
+        byte[] buffer = new byte[(int) file.length()];\r
+        FileInputStream fInput = new FileInputStream(file);\r
+        fInput.read(buffer);\r
+        fInput.close();\r
+        return md5(buffer);\r
+\r
+    }\r
+\r
+    static public String md5(byte[] buffer) throws Exception {\r
+        MessageDigest md = MessageDigest.getInstance("MD5");\r
+        byte[] md5 = md.digest(buffer);\r
+        return new String(String.format("%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s", md5[0], md5[1], md5[2], md5[3], md5[4],\r
+                                        md5[5], md5[6], md5[7], md5[8], md5[9], md5[10], md5[11], md5[12], md5[13],\r
+                                        md5[14], md5[15]));\r
+\r
+    }\r
+}\r
diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/far/FarPackage.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/far/FarPackage.java
new file mode 100644 (file)
index 0000000..0eaa0df
--- /dev/null
@@ -0,0 +1,94 @@
+/** @file\r
\r
+ The file is used to save <farPackage> information.\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
+import java.io.File;\r
+import java.util.List;\r
+\r
+import org.tianocore.frameworkwizard.packaging.PackageIdentification;\r
+\r
+public class FarPackage {\r
+    //\r
+    // Class member\r
+    //\r
+    private FarFileItem farFile;\r
+\r
+    private String guidValue;\r
+\r
+    private String version;\r
+\r
+    private String defaultPath;\r
+\r
+    private List<FarPlatformItem> farPlatformList;\r
+\r
+    private List<FarFileItem> contentList;\r
+\r
+    public String getDefaultPath() {\r
+        return defaultPath;\r
+    }\r
+\r
+    public void setDefaultPath(String defaultPath) {\r
+        this.defaultPath = defaultPath;\r
+    }\r
+\r
+    public FarFileItem getFarFile() {\r
+        return farFile;\r
+    }\r
+\r
+    public void setFarFile(FarFileItem farFile) {\r
+        this.farFile = farFile;\r
+    }\r
+\r
+    public List<FarPlatformItem> getFarPlatformList() {\r
+        return farPlatformList;\r
+    }\r
+\r
+    public void setFarPlatformList(List<FarPlatformItem> farPlatformList) {\r
+        this.farPlatformList = farPlatformList;\r
+    }\r
+\r
+    public String getGuidValue() {\r
+        return guidValue;\r
+    }\r
+\r
+    public void setGuidValue(String guidValue) {\r
+        this.guidValue = guidValue;\r
+    }\r
+\r
+    public String getVersion() {\r
+        return version;\r
+    }\r
+\r
+    public void setVersion(String version) {\r
+        this.version = version;\r
+    }\r
+\r
+    public List<FarFileItem> getContentList() {\r
+        return this.contentList;\r
+    }\r
+\r
+    public void setContentList(List<FarFileItem> contentList) {\r
+        this.contentList = contentList;\r
+    }\r
+\r
+    public boolean isIdentityPkg(PackageIdentification pkgId) {\r
+        File file = new File(farFile.getRelativeFilename());\r
+        if (pkgId.getName() == file.getName() && pkgId.getGuid() == guidValue && pkgId.getVersion() == version) {\r
+            return true;\r
+        }\r
+        return false;\r
+\r
+    }\r
+}\r
diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/far/FarPlatformItem.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/far/FarPlatformItem.java
new file mode 100644 (file)
index 0000000..e3c2f1c
--- /dev/null
@@ -0,0 +1,60 @@
+/** @file\r
\r
+ The file is used to save <farPlatform> information.\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
+import org.tianocore.frameworkwizard.platform.PlatformIdentification;\r
+\r
+public class FarPlatformItem {\r
+    //\r
+    // class member\r
+    //\r
+    private FarFileItem farFile;\r
+\r
+    private String guidValue;\r
+\r
+    private String version;\r
+\r
+    public FarFileItem getFarFile() {\r
+        return farFile;\r
+    }\r
+\r
+    public void setFarFile(FarFileItem farFile) {\r
+        this.farFile = farFile;\r
+    }\r
+\r
+    public String getGuidValue() {\r
+        return guidValue;\r
+    }\r
+\r
+    public void setGuidValue(String guidValue) {\r
+        this.guidValue = guidValue;\r
+    }\r
+\r
+    public String getVersion() {\r
+        return version;\r
+    }\r
+\r
+    public void setVersion(String version) {\r
+        this.version = version;\r
+    }\r
+\r
+    public boolean isIdentityPlf(PlatformIdentification plfId) {\r
+        if (plfId.getGuid() == guidValue && plfId.getVersion() == version) {\r
+            return true;\r
+        }\r
+        return false;\r
+\r
+    }\r
+}\r
diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/far/Mainfest.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/far/Mainfest.java
new file mode 100644 (file)
index 0000000..430cb36
--- /dev/null
@@ -0,0 +1,955 @@
+/** @file\r
\r
+ The file is used to create Far's mainfest 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.frameworkwizard.far;\r
+\r
+import java.io.File;\r
+import java.io.FileInputStream;\r
+import java.io.IOException;\r
+import java.io.InputStream;\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.regex.Matcher;\r
+import java.util.regex.Pattern;\r
+\r
+import javax.xml.parsers.DocumentBuilder;\r
+import javax.xml.parsers.DocumentBuilderFactory;\r
+import javax.xml.transform.OutputKeys;\r
+import javax.xml.transform.Result;\r
+import javax.xml.transform.Source;\r
+import javax.xml.transform.Transformer;\r
+import javax.xml.transform.TransformerFactory;\r
+import javax.xml.transform.dom.DOMSource;\r
+import javax.xml.transform.stream.StreamResult;\r
+\r
+import org.apache.xmlbeans.XmlException;\r
+import org.tianocore.frameworkwizard.common.Tools;\r
+import org.tianocore.frameworkwizard.packaging.PackageIdentification;\r
+import org.tianocore.frameworkwizard.platform.PlatformIdentification;\r
+import org.tianocore.frameworkwizard.workspace.Workspace;\r
+import org.w3c.dom.Document;\r
+import org.w3c.dom.Element;\r
+import org.w3c.dom.NamedNodeMap;\r
+import org.w3c.dom.Node;\r
+import org.w3c.dom.NodeList;\r
+\r
+public class Mainfest implements ManifestInterface {\r
+    // /\r
+    // / mainfest document\r
+    // /\r
+    Document mainfestDoc = null;\r
+\r
+    // /\r
+    // / Mainfest file element name\r
+    // /\r
+    final static String mfFileName = "FarMainfest.MF";\r
+\r
+    //\r
+    // Header\r
+    //\r
+    final static String farHeader = "FarHeader";\r
+\r
+    final static String farHeader_FarName = "FarName";\r
+\r
+    final static String farHeader_Abstract = "Abstract";\r
+\r
+    final static String farHeader_Description = "Description";\r
+\r
+    final static String farHeader_CopyRight = "CopyRight";\r
+\r
+    final static String farHeader_License = "Licese";\r
+\r
+    final static String farHeader_Specification = "Specification";\r
+\r
+    //\r
+    // Package list\r
+    //\r
+    final static String farPackageList = "FarPackageList";\r
+\r
+    final static String farPlatformList = "FarPlatformList";\r
+\r
+    final static String contents = "Contents";\r
+\r
+    final static String userExtensions = "UserExtensions";\r
+\r
+    //\r
+    // Common node name\r
+    //\r
+\r
+    final static String guidValue = "GuidValue";\r
+\r
+    final static String version = "Version";\r
+\r
+    //\r
+    // FarPackage node name\r
+    //\r
+    final static String farPackageList_FarPackage = "FarPackage";\r
+\r
+    final static String farPackage_FarfileName = "FarFileName";\r
+\r
+    final static String farPackage_DefaultPath = "DefaultPath";\r
+\r
+    final static String farPlatformList_FarPlatform = "FarPlatform";\r
+\r
+    final static String farFileName_FarGuid = "FarGuid";\r
+\r
+    final static String farFileName_Md5sum = "Md5sum";\r
+\r
+    //\r
+    // mainfest header information.\r
+    //\r
+    FarHeader fhInfo = new FarHeader();\r
+\r
+    //\r
+    // FarPackage list\r
+    //\r
+    List<FarPackage> fPkgList = new ArrayList<FarPackage>();\r
+\r
+    //\r
+    // FarPlatform list\r
+    //\r
+    List<FarPlatformItem> fPlfList = new ArrayList<FarPlatformItem>();\r
+\r
+    Set<File> files = new LinkedHashSet<File>();\r
+\r
+    //\r
+    // Mainfest file\r
+    //\r
+    File mfFile = null;\r
+\r
+    public FarHeader getHeader() {\r
+        return fhInfo;\r
+    }\r
+\r
+    public Mainfest() throws Exception {\r
+        DocumentBuilderFactory domfac = DocumentBuilderFactory.newInstance();\r
+        DocumentBuilder dombuilder = domfac.newDocumentBuilder();\r
+        Document document = dombuilder.newDocument();\r
+        this.mainfestDoc = document;\r
+\r
+    }\r
+\r
+    public Mainfest(InputStream mainfestInputStream) throws Exception {\r
+        DocumentBuilderFactory domfac = DocumentBuilderFactory.newInstance();\r
+        try {\r
+            if (mainfestInputStream != null) {\r
+                DocumentBuilder dombuilder = domfac.newDocumentBuilder();\r
+                this.mainfestDoc = dombuilder.parse(mainfestInputStream);\r
+                parseMainfest();\r
+            }\r
+\r
+        } catch (Exception e) {\r
+            //\r
+            // Will change to throw Wizader exception.\r
+            //\r
+            throw new Exception(e.getMessage());\r
+        }\r
+    }\r
+\r
+    public void setFarHeader(FarHeader fHeader) {\r
+        this.fhInfo = fHeader;\r
+    }\r
+\r
+    public void createManifest(List<PackageIdentification> pkgList, List<PlatformIdentification> plfList,\r
+                               Set<String> fileFilter) throws Exception {\r
+\r
+        //\r
+        // Add Package and it's contents to FarPackageList.\r
+        //\r
+        Iterator<PackageIdentification> pkgItem = pkgList.iterator();\r
+        while (pkgItem.hasNext()) {\r
+            PackageIdentification pkgId = pkgItem.next();\r
+\r
+            //\r
+            // Add package and it's contents to <FarPackageList>.\r
+            //\r
+            addPkgToPkgList(pkgId, fileFilter);\r
+        }\r
+\r
+        //\r
+        // Add FarPlatform to this.farPlatformList.\r
+        //\r
+        Iterator<PlatformIdentification> plfItem = plfList.iterator();\r
+        while (plfItem.hasNext()) {\r
+            PlatformIdentification plfId = plfItem.next();\r
+\r
+            //\r
+            // Add platform to Mainifest.\r
+            //\r
+            addPlatformIdToFarPlatformItemList(plfId);\r
+        }\r
+    }\r
+\r
+    public void setManifestFile(File mainfestFile) throws Exception {\r
+        DocumentBuilderFactory domfac = DocumentBuilderFactory.newInstance();\r
+        DocumentBuilder dombuilder = domfac.newDocumentBuilder();\r
+        InputStream is = new FileInputStream(mainfestFile);\r
+        this.mainfestDoc = dombuilder.parse(is);\r
+    }\r
+\r
+    public void addPkgToPkgList(PackageIdentification packageId, Set<String> fileFilter) throws Exception {\r
+        files.add(packageId.getSpdFile());\r
+\r
+        FarPackage farPackage = new FarPackage();\r
+        //\r
+        // Add SPD file to FarPackage\r
+        //\r
+        File spdFile = new File(packageId.getPath());\r
+\r
+        FarFileItem ffItem = new FarFileItem(spdFile.getName(), FarMd5.md5(spdFile));\r
+        farPackage.setFarFile(ffItem);\r
+\r
+        //\r
+        // Add package guid value.\r
+        //\r
+        farPackage.setGuidValue(packageId.getGuid());\r
+\r
+        //\r
+        // Add package version\r
+        //\r
+        farPackage.setVersion(packageId.getVersion());\r
+\r
+        //\r
+        // Add DefaultPat: Package absoulte path - Workspace absolut\r
+        // path.\r
+        //\r
+        String pkgDir = Tools.getFilePathOnly(packageId.getPath());\r
+        File rootDir = new File(pkgDir);\r
+        farPackage.setDefaultPath(Tools.getRelativePath(rootDir.getPath(), Workspace.getCurrentWorkspace()));\r
+\r
+        //\r
+        // Get package root dir contains.\r
+        //\r
+        Set<File> fileSet = new LinkedHashSet<File>();\r
+        Set<File> fpdFileSet = new LinkedHashSet<File>();\r
+\r
+        //\r
+        // Get all files and fpd files\r
+        //\r
+        recursiveDirectory(fileSet, fpdFileSet, rootDir, fileFilter);\r
+\r
+        //\r
+        // Remove current package's SPD file\r
+        //\r
+        fileSet.remove(packageId.getSpdFile());\r
+\r
+        files.addAll(fileSet);\r
+\r
+        Iterator<File> iter = fileSet.iterator();\r
+        List<FarFileItem> contents = new ArrayList<FarFileItem>();\r
+        while (iter.hasNext()) {\r
+            File normalFile = iter.next();\r
+            String fileRelativePath = Tools.getRelativePath(normalFile.getPath(), pkgDir);\r
+            ffItem = new FarFileItem(fileRelativePath, FarMd5.md5(normalFile));\r
+            contents.add(ffItem);\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
+        fPkgList.add(farPackage);\r
+    }\r
+\r
+    private void recursiveDirectory(Set<File> files, Set<File> fpds, File dir, Set<String> fileFilter) {\r
+        if (isFilter(dir, fileFilter)) {\r
+            return;\r
+        }\r
+        File[] allFilesInDir = dir.listFiles();\r
+        for (int i = 0; i < allFilesInDir.length; i++) {\r
+            if (allFilesInDir[i].isFile()) {\r
+                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
+            } else {\r
+                recursiveDirectory(files, fpds, allFilesInDir[i], fileFilter);\r
+            }\r
+        }\r
+    }\r
+\r
+    public void addPlatformIdToFarPlatformItemList(PlatformIdentification platformId) throws Exception {\r
+        files.add(platformId.getFpdFile());\r
+\r
+        FarPlatformItem fpfItem = new FarPlatformItem();\r
+        FarFileItem ffItem;\r
+        String fpfPath = platformId.getPath();\r
+        File fpfFile = new File(fpfPath);\r
+        //\r
+        // Add farFileName\r
+        //\r
+        ffItem = new FarFileItem(Tools.getRelativePath(fpfFile.getPath(), Workspace.getCurrentWorkspace()),\r
+                                 FarMd5.md5(fpfFile));\r
+        fpfItem.setFarFile(ffItem);\r
+\r
+        //\r
+        // Add guid value\r
+        //\r
+        fpfItem.setGuidValue(platformId.getGuid());\r
+\r
+        //\r
+        // Add version\r
+        //\r
+        fpfItem.setVersion(platformId.getVersion());\r
+\r
+        fPlfList.add(fpfItem);\r
+    }\r
+\r
+    /**\r
+     * \r
+     * @param\r
+     * @return Set<PackageIdentification> list of PackageIdentification.\r
+     */\r
+    public List<PackageIdentification> getPackageList() throws Exception {\r
+        //\r
+        // PackageIdentification set.\r
+        //\r
+        List<PackageIdentification> pkgList = new ArrayList<PackageIdentification>();\r
+        //\r
+        // \r
+        //\r
+        Iterator pkgItem = this.fPkgList.iterator();\r
+        while (pkgItem.hasNext()) {\r
+            FarPackage fPkg = (FarPackage) pkgItem.next();\r
+            //\r
+            // Get package information from SPD file and create a package\r
+            // 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
+            pkgList.add(pkgId);\r
+        }\r
+        return pkgList;\r
+    }\r
+\r
+    /**\r
+     * \r
+     */\r
+    public List<PlatformIdentification> getPlatformList() throws Exception, IOException, XmlException {\r
+        //\r
+        // PlatformIdentification set.\r
+        //\r
+        List<PlatformIdentification> plfList = new ArrayList<PlatformIdentification>();\r
+        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
+            //\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
+            plfList.add(plfId);\r
+        }\r
+        return plfList;\r
+    }\r
+\r
+    public List<FarFileItem> getPlatformContents(PlatformIdentification platformId) {\r
+        List<FarFileItem> result = new ArrayList<FarFileItem>();\r
+        Iterator<FarPlatformItem> iter = this.fPlfList.iterator();\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
+                result.add(farFileItem);\r
+                break;\r
+            }\r
+        }\r
+        return result;\r
+    }\r
+\r
+    public List<FarFileItem> getPackageContents(PackageIdentification packageId) {\r
+        List<FarFileItem> farFileList = new ArrayList<FarFileItem>();\r
+        Iterator pkgItem = this.fPkgList.iterator();\r
+        while (pkgItem.hasNext()) {\r
+            FarPackage pkg = (FarPackage) pkgItem.next();\r
+            if (pkg.isIdentityPkg(packageId)) {\r
+                //\r
+                // Add spd far file to list.\r
+                //\r
+                farFileList.add(pkg.getFarFile());\r
+                //\r
+                // Add all files in contents to list.\r
+                //\r
+                farFileList.addAll(pkg.getContentList());\r
+                //\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
+                Iterator<FarFileItem> ffIter = farFileList.iterator();\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
+        return farFileList;\r
+    }\r
+\r
+    /**\r
+     * \r
+     * @param pkgId\r
+     * @return String: return string represent jar file entry; \r
+     */\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
+                return entryStr;\r
+            }\r
+        }\r
+        return null;\r
+    }\r
+\r
+    public List<FarFileItem> getPackageContents() {\r
+        //\r
+        // In this farFilelist,all FarFileItem's relativeFileName should be\r
+        // set as absolutely path.\r
+        //\r
+        List<FarFileItem> farFileList = new ArrayList<FarFileItem>();\r
+        Iterator pkgItem = this.fPkgList.iterator();\r
+        FarFileItem ffItem = null;\r
+\r
+        while (pkgItem.hasNext()) {\r
+            FarPackage pkg = (FarPackage) pkgItem.next();\r
+\r
+            //\r
+            // Add spd far file to list.\r
+            //\r
+            ffItem = pkg.getFarFile();\r
+            //\r
+            // Set farFileItem relativeFileName = absolutePath + file Name.\r
+            //\r
+            farFileList.add(new FarFileItem(pkg.getDefaultPath() + File.separatorChar + ffItem.getRelativeFilename(),\r
+                                            ffItem.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
+            }\r
+            //\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
+                ffItem = ((FarPlatformItem) plfItem.next()).getFarFile();\r
+                farFileList.add(new FarFileItem(pkg.getDefaultPath() + File.separator + ffItem.getRelativeFilename(),\r
+                                                ffItem.getMd5Value()));\r
+            }\r
+        }\r
+        return farFileList;\r
+    }\r
+\r
+    public String getPackageDefaultPath(PackageIdentification packageId) {\r
+        Iterator pkgItr = this.fPkgList.iterator();\r
+        while (pkgItr.hasNext()) {\r
+            FarPackage farPackage = (FarPackage) pkgItr.next();\r
+            if (farPackage.isIdentityPkg(packageId)) {\r
+                return farPackage.getDefaultPath();\r
+            }\r
+        }\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
+    public List<FarFileItem> getAllFileItem() {\r
+        //\r
+        // The farFileName in this list are all abosulte path.\r
+        //\r
+        List<FarFileItem> ffiList = new ArrayList<FarFileItem>();\r
+        //\r
+        // Add far files in <FarPackageList> to list.\r
+        //\r
+        ffiList = this.getPackageContents();\r
+\r
+        //\r
+        // Add far files in <FarPlatformList> to list\r
+        //\r
+        NodeList elementList = this.mainfestDoc.getElementsByTagName(farPlatformList);\r
+        for (int i = 0; i < elementList.getLength(); i++) {\r
+            //\r
+            // Get <farPlatform> node list.\r
+            //\r
+            Node item = elementList.item(i);\r
+            NodeList plfElements = item.getChildNodes();\r
+            for (int j = 0; j < plfElements.getLength(); j++) {\r
+                //\r
+                // Get each <FarPlatform> content.\r
+                //\r
+                NodeList plfChildNode = plfElements.item(i).getChildNodes();\r
+                Node tempNode = null;\r
+                for (int t = 0; t < plfChildNode.getLength(); t++) {\r
+                    tempNode = plfChildNode.item(t);\r
+                    //\r
+                    // Get child node value and set to platformIdentification.\r
+                    //\r
+                    if (tempNode.getNodeName().equalsIgnoreCase(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
+                        ffiList.add(farFile);\r
+                    }\r
+                }\r
+            }\r
+        }\r
+        return ffiList;\r
+    }\r
+\r
+    public void hibernateToFile() throws Exception {\r
+        //\r
+        // create mainfest root node\r
+        //\r
+        Element rootNode = this.mainfestDoc.createElement("FrameworkArchiveManifest");\r
+        this.mainfestDoc.appendChild(rootNode);\r
+\r
+        //\r
+        // create mainfest header node\r
+        //\r
+        Element headerNode = this.mainfestDoc.createElement(farHeader);\r
+        rootNode.appendChild(headerNode);\r
+        //\r
+        // Add FarHeader to headerNode.\r
+        //\r
+        Element farName = this.mainfestDoc.createElement(farHeader_FarName);\r
+        farName.setTextContent(this.fhInfo.getFarName());\r
+        headerNode.appendChild(farName);\r
+\r
+        Element gv = this.mainfestDoc.createElement(guidValue);\r
+        gv.setTextContent(this.fhInfo.getGuidValue());\r
+        headerNode.appendChild(gv);\r
+\r
+        Element ver = this.mainfestDoc.createElement(version);\r
+        ver.setTextContent(this.fhInfo.getVersion());\r
+        headerNode.appendChild(ver);\r
+\r
+        Element abstra = this.mainfestDoc.createElement(farHeader_Abstract);\r
+        abstra.setTextContent(this.fhInfo.getAbstractStr());\r
+        headerNode.appendChild(abstra);\r
+\r
+        Element descr = this.mainfestDoc.createElement(farHeader_Description);\r
+        descr.setTextContent(this.fhInfo.getDescription());\r
+        headerNode.appendChild(descr);\r
+\r
+        Element copyright = this.mainfestDoc.createElement(farHeader_CopyRight);\r
+        copyright.setTextContent(this.fhInfo.getCopyright());\r
+        headerNode.appendChild(copyright);\r
+\r
+        Element license = this.mainfestDoc.createElement(farHeader_License);\r
+        license.setTextContent(this.fhInfo.getLicense());\r
+        headerNode.appendChild(license);\r
+\r
+        Element spec = this.mainfestDoc.createElement(farHeader_Specification);\r
+        spec.setTextContent(this.fhInfo.getSpecification());\r
+        System.out.println(this.fhInfo.getSpecification());\r
+        headerNode.appendChild(spec);\r
+\r
+        //\r
+        // create mainfest FarPackageList node\r
+        //\r
+        Element pkgListNode = this.mainfestDoc.createElement(farPackageList);\r
+        rootNode.appendChild(pkgListNode);\r
+\r
+        //\r
+        // Save each item in farPackage list to <FarPackage>.\r
+        //\r
+        Iterator pkgItem = this.fPkgList.iterator();\r
+        while (pkgItem.hasNext()) {\r
+            pkgToFarPkgNode(pkgListNode, (FarPackage) pkgItem.next());\r
+\r
+        }\r
+\r
+        //\r
+        // create mainfest FarPlatformList node\r
+        //\r
+        Element plfListNode = this.mainfestDoc.createElement(farPlatformList);\r
+        rootNode.appendChild(plfListNode);\r
+\r
+        //\r
+        // Save farPakcage list info to <FarPackageList> node\r
+        //\r
+        Iterator plfItem = this.fPlfList.iterator();\r
+        while (plfItem.hasNext()) {\r
+            FarPlatformItem plfIterator = (FarPlatformItem) plfItem.next();\r
+            PlfToPlatformNode(plfListNode, plfIterator);\r
+        }\r
+\r
+        //\r
+        // 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(OutputKeys.INDENT, "yes");\r
+\r
+        //\r
+        // Prepare the DOM document for writing\r
+        //\r
+        Source source = new DOMSource(this.mainfestDoc);\r
+        //\r
+        // 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
+        //\r
+        // generate all directory path\r
+        //\r
+        Result result = new StreamResult(this.mfFile);\r
+        xformer.transform(source, result);\r
+    }\r
+\r
+    public void pkgToFarPkgNode(Element parentNode, FarPackage pkgItem) {\r
+        Element pkgNode = this.mainfestDoc.createElement(farPackageList_FarPackage);\r
+        //\r
+        // Add <FarFileName>\r
+        //\r
+        ffiToFfNode(pkgNode, pkgItem.getFarFile());\r
+        //\r
+        // Add <GuidValue>\r
+        //\r
+        setStrItemToNode(pkgNode, pkgItem.getGuidValue(), guidValue);\r
+        //\r
+        // Add <Version>\r
+        //\r
+        setStrItemToNode(pkgNode, pkgItem.getVersion(), version);\r
+        //\r
+        // Add <DefaultPath>\r
+        //\r
+        setStrItemToNode(pkgNode, pkgItem.getDefaultPath(), farPackage_DefaultPath);\r
+\r
+        //\r
+        // Add <Contents>\r
+        //\r
+        Element contentNode = this.mainfestDoc.createElement(contents);\r
+        Iterator iterator = pkgItem.getContentList().iterator();\r
+        while (iterator.hasNext()) {\r
+            ffiToFfNode(contentNode, (FarFileItem) iterator.next());\r
+        }\r
+        pkgNode.appendChild(contentNode);\r
+        parentNode.appendChild(pkgNode);\r
+    }\r
+\r
+    public void PlfToPlatformNode(Element parentNode, FarPlatformItem fplItem) {\r
+        Element fplNode = this.mainfestDoc.createElement(farPlatformList_FarPlatform);\r
+        //\r
+        // Add <FarFileName>\r
+        //\r
+        ffiToFfNode(fplNode, fplItem.getFarFile());\r
+        //\r
+        // Add <GuidValue>\r
+        //\r
+        setStrItemToNode(fplNode, fplItem.getGuidValue(), guidValue);\r
+        //\r
+        // Add <Version>\r
+        //\r
+        setStrItemToNode(fplNode, fplItem.getVersion(), version);\r
+        //\r
+        // Add to <PlatformList>\r
+        //\r
+        parentNode.appendChild(fplNode);\r
+\r
+    }\r
+\r
+    public void ffiToFfNode(Element parentNode, FarFileItem ffi) {\r
+        Element farFileName = this.mainfestDoc.createElement(farPackage_FarfileName);\r
+        farFileName.setTextContent(ffi.getRelativeFilename());\r
+        System.out.println(farFileName.getTextContent());\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
+        Element node = this.mainfestDoc.createElement(strName);\r
+        node.setTextContent(strValue);\r
+        parentNode.appendChild(node);\r
+    }\r
+\r
+    private void parseMainfest() {\r
+\r
+        //\r
+        // Parse header\r
+        //\r
+        parseMfHeader();\r
+        //\r
+        // parse <farPackageList>\r
+        //\r
+        parseHeaderFarPackageList();\r
+\r
+        //\r
+        // parse <farPlatformList>\r
+        //\r
+        NodeList ele = this.mainfestDoc.getElementsByTagName(farPlatformList);\r
+        Node plfNode;\r
+        if (ele.getLength() > 0) {\r
+            //\r
+            // Only have one <FarPlatformList> node under mainfest root node.\r
+            //\r
+            plfNode = ele.item(0);\r
+            parseFarPlatformList(plfNode, this.fPlfList);\r
+        }\r
+    }\r
+\r
+    private void parseMfHeader() {\r
+        Node headerNode;\r
+        NodeList ele = this.mainfestDoc.getElementsByTagName(farHeader);\r
+        if (ele.getLength() > 0) {\r
+            //\r
+            // For mainfest file only have one <FarHeader>\r
+            //\r
+            headerNode = ele.item(0);\r
+        } else {\r
+            return;\r
+        }\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
+                String nodeValue = node.getTextContent();\r
+                this.fhInfo.setFarName(nodeValue);\r
+            } else if (nodeName.equalsIgnoreCase(guidValue)) {\r
+                this.fhInfo.setGuidValue(node.getTextContent());\r
+            } else if (nodeName.equalsIgnoreCase(version)) {\r
+                this.fhInfo.setVersion(node.getTextContent());\r
+            } else if (nodeName.equalsIgnoreCase(farHeader_Abstract)) {\r
+                this.fhInfo.setAbstractStr(node.getTextContent());\r
+            } else if (nodeName.equalsIgnoreCase(farHeader_Description)) {\r
+                this.fhInfo.setDescription(node.getTextContent());\r
+            } else if (nodeName.equalsIgnoreCase(farHeader_CopyRight)) {\r
+                this.fhInfo.setCopyright(node.getTextContent());\r
+            } else if (nodeName.equalsIgnoreCase(farHeader_License)) {\r
+                this.fhInfo.setLicense(node.getTextContent());\r
+            } else if (nodeName.equalsIgnoreCase(farHeader_Specification)) {\r
+                this.fhInfo.setSpecification(node.getTextContent());\r
+            }\r
+        }\r
+    }\r
+\r
+    public void parseHeaderFarPackageList() {\r
+        Node farPkgNode;\r
+        NodeList ele = this.mainfestDoc.getElementsByTagName(farPackageList);\r
+        if (ele.getLength() > 0) {\r
+            //\r
+            // For mainfest file only have one <FarHeader>\r
+            //\r
+            farPkgNode = ele.item(0);\r
+        } else {\r
+            return;\r
+        }\r
+        NodeList fpnList = farPkgNode.getChildNodes();\r
+        for (int i = 0; i < fpnList.getLength(); i++) {\r
+            if (fpnList.item(i).getNodeType() == Node.TEXT_NODE) {\r
+                continue;\r
+            }\r
+            FarPackage fpItem = new FarPackage();\r
+            parseFarPackage(fpnList.item(i), fpItem);\r
+            this.fPkgList.add(fpItem);\r
+        }\r
+    }\r
+\r
+    public void parseFarPackage(Node farPkgNode, FarPackage fpItem) {\r
+        NodeList childList = farPkgNode.getChildNodes();\r
+        Node childNode;\r
+        String childName;\r
+        for (int i = 0; i < childList.getLength(); i++) {\r
+            childNode = childList.item(i);\r
+            childName = childNode.getNodeName();\r
+            if (childName.equalsIgnoreCase(farPackage_FarfileName)) {\r
+                fpItem.setFarFile(parseFarFile(childNode));\r
+            } else if (childName.equalsIgnoreCase(guidValue)) {\r
+                fpItem.setGuidValue(childNode.getTextContent());\r
+            } else if (childName.equalsIgnoreCase(version)) {\r
+                fpItem.setVersion(childNode.getTextContent());\r
+            } else if (childName.equalsIgnoreCase(farPackage_DefaultPath)) {\r
+                fpItem.setDefaultPath(childNode.getTextContent());\r
+            } else if (childName.equalsIgnoreCase(farPlatformList)) {\r
+                List<FarPlatformItem> plfList = new ArrayList<FarPlatformItem>();\r
+                parseFarPlatformList(childNode, plfList);\r
+                fpItem.setFarPlatformList(plfList);\r
+            } else if (childName.equalsIgnoreCase(contents)) {\r
+                List<FarFileItem> ffList = new ArrayList<FarFileItem>();\r
+                parseContents(childNode, ffList);\r
+                fpItem.setContentList(ffList);\r
+            }\r
+        }\r
+    }\r
+\r
+    /**\r
+     * \r
+     * @param fpfListNode\r
+     * @param plfList\r
+     */\r
+    public void parseFarPlatformList(Node fpfListNode, 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
+                continue;\r
+            }\r
+            farPlfNode = child.item(i);\r
+            plfList.add(parseFarPlatform(farPlfNode));\r
+        }\r
+    }\r
+\r
+    /**\r
+     * \r
+     * @param fpfNode\r
+     * @return\r
+     */\r
+    public FarPlatformItem parseFarPlatform(Node fpfNode) {\r
+        //\r
+        // New FarPlatformItem.\r
+        //\r
+        FarPlatformItem fplItem = new FarPlatformItem();\r
+        //\r
+        // Get <FarPlatform> elements;\r
+        //\r
+        NodeList childList = fpfNode.getChildNodes();\r
+        Node child;\r
+        String nodeName;\r
+        for (int i = 0; i < childList.getLength(); i++) {\r
+            child = childList.item(i);\r
+            nodeName = child.getNodeName();\r
+            if (nodeName.equalsIgnoreCase(farPackage_FarfileName)) {\r
+                fplItem.setFarFile(parseFarFile(child));\r
+            } else if (nodeName.equalsIgnoreCase(guidValue)) {\r
+                fplItem.setGuidValue(child.getTextContent());\r
+            } else if (nodeName.equalsIgnoreCase(version)) {\r
+                fplItem.setVersion(child.getTextContent());\r
+            }\r
+        }\r
+\r
+        return fplItem;\r
+    }\r
+\r
+    public void parseContents(Node contentsNode, List<FarFileItem> ffList) {\r
+        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
+                continue;\r
+            }\r
+            contentNode = contentList.item(i);\r
+            //\r
+            // Parse each  <FarFileName>.\r
+            //\r
+            ffList.add(parseFarFile(contentNode));\r
+        }\r
+    }\r
+\r
+    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
+        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
+            }\r
+        }\r
+        return false;\r
+    }\r
+\r
+}\r
diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/far/ManifestInterface.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/far/ManifestInterface.java
new file mode 100644 (file)
index 0000000..28af114
--- /dev/null
@@ -0,0 +1,40 @@
+/** @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
+\r
+package org.tianocore.frameworkwizard.far;\r
+\r
+import java.io.File;\r
+import java.io.IOException;\r
+import java.util.List;\r
+import java.util.Set;\r
+\r
+import org.apache.xmlbeans.XmlException;\r
+import org.tianocore.frameworkwizard.packaging.PackageIdentification;\r
+import org.tianocore.frameworkwizard.platform.PlatformIdentification;\r
+\r
+public interface ManifestInterface {\r
+\r
+    public void createManifest(List<PackageIdentification> pkgList, List<PlatformIdentification> plfList,\r
+                               Set<String> fileFilter) throws Exception;\r
+\r
+    public void setManifestFile(File manifestFile) throws Exception;\r
+\r
+    public List<PackageIdentification> getPackageList() throws Exception;\r
+\r
+    public List<PlatformIdentification> getPlatformList() throws Exception, IOException, XmlException;\r
+\r
+    public List<FarFileItem> getPackageContents(PackageIdentification packageId);\r
+\r
+    public String getPackageDefaultPath(PackageIdentification packageId);\r
+\r
+}\r
diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/far/PackageQuery.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/far/PackageQuery.java
new file mode 100644 (file)
index 0000000..f2a5263
--- /dev/null
@@ -0,0 +1,127 @@
+/** @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
+\r
+package org.tianocore.frameworkwizard.far;\r
+\r
+import java.io.File;\r
+import java.io.InputStream;\r
+import java.util.ArrayList;\r
+import java.util.Iterator;\r
+import java.util.List;\r
+import java.util.Vector;\r
+\r
+import org.apache.xmlbeans.XmlObject;\r
+import org.tianocore.ModuleSurfaceAreaDocument;\r
+import org.tianocore.PackageDependenciesDocument;\r
+import org.tianocore.PackageSurfaceAreaDocument;\r
+import org.tianocore.ModuleSurfaceAreaDocument.ModuleSurfaceArea;\r
+import org.tianocore.frameworkwizard.common.Identifications.OpenFile;\r
+import org.tianocore.frameworkwizard.packaging.PackageIdentification;\r
+import org.tianocore.frameworkwizard.workspace.WorkspaceTools;\r
+\r
+public class PackageQuery implements PackageQueryInterface {\r
+\r
+    public PackageIdentification getPackageIdentification(File spdFile) {\r
+        PackageIdentification packageId = null;\r
+        try {\r
+            String path = spdFile.getPath();\r
+            WorkspaceTools wt = new WorkspaceTools();\r
+            packageId = new PackageIdentification(wt.getId(path, OpenFile.openSpdFile(path)));\r
+        } catch (Exception e) {\r
+            e.printStackTrace();\r
+        }\r
+        return packageId;\r
+    }\r
+\r
+    public List<String> getPackageMsaList(InputStream spdInput) {\r
+        List<String> result = new ArrayList<String>();\r
+        try {\r
+            PackageSurfaceAreaDocument spd = (PackageSurfaceAreaDocument) XmlObject.Factory.parse(spdInput);\r
+            result = spd.getPackageSurfaceArea().getMsaFiles().getFilenameList();\r
+        } catch (Exception e) {\r
+            e.printStackTrace();\r
+        }\r
+        return result;\r
+    }\r
+\r
+    public List<PackageIdentification> getModuleDependencies(InputStream msaInput) {\r
+        List<PackageIdentification> result = new ArrayList<PackageIdentification>();\r
+        try {\r
+            ModuleSurfaceAreaDocument msa = (ModuleSurfaceAreaDocument) XmlObject.Factory.parse(msaInput);\r
+            ModuleSurfaceAreaDocument.ModuleSurfaceArea sa = msa.getModuleSurfaceArea();\r
+            if (sa == null) {\r
+                return result;\r
+            }\r
+            PackageDependenciesDocument.PackageDependencies pkgDep = sa.getPackageDependencies();\r
+            if (pkgDep == null) {\r
+                return result;\r
+            }\r
+            List<PackageDependenciesDocument.PackageDependencies.Package> list = pkgDep.getPackageList();\r
+            Iterator<PackageDependenciesDocument.PackageDependencies.Package> iter = list.iterator();\r
+            while (iter.hasNext()) {\r
+                PackageDependenciesDocument.PackageDependencies.Package item = iter.next();\r
+                PackageIdentification packageId = new PackageIdentification(null, item.getPackageGuid(),\r
+                                                                            item.getPackageVersion());\r
+                result.add(packageId);\r
+            }\r
+        } catch (Exception e) {\r
+            e.printStackTrace();\r
+        }\r
+        return result;\r
+    }\r
+\r
+    public List<File> getPackageMsaList(File spdFile) {\r
+        List<File> result = new Vector<File>();\r
+        WorkspaceTools wt = new WorkspaceTools();\r
+        List<String> v = wt.getAllModulesOfPackage(spdFile.getPath());\r
+        Iterator<String> iter = v.iterator();\r
+        while (iter.hasNext()) {\r
+            result.add(new File(iter.next()));\r
+        }\r
+        return result;\r
+    }\r
+\r
+    public List<PackageIdentification> getPackageDependencies(File spdFile) {\r
+        List<File> msaFiles = getPackageMsaList(spdFile);\r
+        return getPackageDependencies(msaFiles);\r
+    }\r
+\r
+    public List<PackageIdentification> getPackageDependencies(List<File> msaFiles) {\r
+        List<PackageIdentification> result = new ArrayList<PackageIdentification>();\r
+        Iterator<File> iter = msaFiles.iterator();\r
+        while (iter.hasNext()) {\r
+            result = AggregationOperation.union(result, getModuleDependencies(iter.next()));\r
+        }\r
+        return result;\r
+    }\r
+\r
+    public List<PackageIdentification> getModuleDependencies(File msaFile) {\r
+        List<PackageIdentification> result = new ArrayList<PackageIdentification>();\r
+        try {\r
+            ModuleSurfaceArea msa = OpenFile.openMsaFile(msaFile.getPath());\r
+            List<PackageDependenciesDocument.PackageDependencies.Package> p = msa.getPackageDependencies()\r
+                                                                                 .getPackageList();\r
+            Iterator<PackageDependenciesDocument.PackageDependencies.Package> iter = p.iterator();\r
+            while (iter.hasNext()) {\r
+                PackageDependenciesDocument.PackageDependencies.Package item = iter.next();\r
+                PackageIdentification packageId = new PackageIdentification(null, item.getPackageGuid(),\r
+                                                                            item.getPackageVersion());\r
+                if (!AggregationOperation.belongs(packageId, result)) {\r
+                    result.add(packageId);\r
+                }\r
+            }\r
+        } catch (Exception e) {\r
+        }\r
+        return result;\r
+    }\r
+}\r
diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/far/PackageQueryInterface.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/far/PackageQueryInterface.java
new file mode 100644 (file)
index 0000000..e8644eb
--- /dev/null
@@ -0,0 +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
+\r
+package org.tianocore.frameworkwizard.far;\r
+\r
+import java.io.File;\r
+import java.io.InputStream;\r
+import java.util.List;\r
+\r
+import org.tianocore.frameworkwizard.packaging.PackageIdentification;\r
+\r
+public interface PackageQueryInterface {\r
+\r
+    public PackageIdentification getPackageIdentification(File spdFile);\r
+\r
+    public List<File> getPackageMsaList(File spdFile);\r
+\r
+    public List<String> getPackageMsaList(InputStream spdInput);\r
+\r
+    public List<PackageIdentification> getPackageDependencies(File spdFile);\r
+\r
+    public List<PackageIdentification> getPackageDependencies(List<File> msaFiles);\r
+\r
+    public List<PackageIdentification> getModuleDependencies(InputStream msaInput);\r
+\r
+    public List<PackageIdentification> getModuleDependencies(File msaFile);\r
+\r
+}\r
diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/far/createui/CreateStepFour.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/far/createui/CreateStepFour.java
new file mode 100644 (file)
index 0000000..5547543
--- /dev/null
@@ -0,0 +1,367 @@
+/** @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
+\r
+package org.tianocore.frameworkwizard.far.createui;\r
+\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.List;\r
+\r
+import javax.swing.JButton;\r
+import javax.swing.JFileChooser;\r
+import javax.swing.JLabel;\r
+import javax.swing.JPanel;\r
+import javax.swing.JTextArea;\r
+import javax.swing.JTextField;\r
+import javax.swing.table.DefaultTableModel;\r
+\r
+import org.tianocore.frameworkwizard.common.DataType;\r
+import org.tianocore.frameworkwizard.common.IFileFilter;\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.Far;\r
+import org.tianocore.frameworkwizard.far.PackageQuery;\r
+import org.tianocore.frameworkwizard.far.PackageQueryInterface;\r
+import org.tianocore.frameworkwizard.packaging.PackageIdentification;\r
+import org.tianocore.frameworkwizard.workspace.Workspace;\r
+\r
+public class CreateStepFour extends IDialog implements MouseListener {\r
+\r
+    /**\r
+     * \r
+     */\r
+    private static final long serialVersionUID = -7397213364965470902L;\r
+\r
+    private JPanel jContentPane = null;\r
+\r
+    private JTextArea jTextAreaInstruction = null;\r
+\r
+    private JLabel jLabel = null;\r
+\r
+    private JLabel jLabel2 = null;\r
+\r
+    private JTextField jTextFieldSaveToFile = null;\r
+\r
+    private JButton jButtonBrowser = null;\r
+\r
+    //  private JScrollPane jScrollPane = null;\r
+    private JButton jButtonCancel = null;\r
+\r
+    private JButton jButtonFinish = null;\r
+\r
+    private JButton jButtonPrevious = null;\r
+\r
+    private PartialTableModel model = null;\r
+\r
+    private CreateStepThree stepThree = null;\r
+\r
+    //  private JTable jTable = null;\r
+    public CreateStepFour(IDialog iDialog, boolean modal, CreateStepThree stepThree) {\r
+        this(iDialog, modal);\r
+        this.stepThree = stepThree;\r
+    }\r
+\r
+    /**\r
+     * This method initializes jTextArea       \r
+     *         \r
+     * @return javax.swing.JTextArea   \r
+     */\r
+    private JTextArea getJTextArea() {\r
+        if (jTextAreaInstruction == null) {\r
+            jTextAreaInstruction = new JTextArea();\r
+            jTextAreaInstruction.setBounds(new java.awt.Rectangle(30, 7, 642, 50));\r
+            jTextAreaInstruction.setText("Step 4: Choose a file \n");\r
+            jTextAreaInstruction.setEditable(false);\r
+        }\r
+        return jTextAreaInstruction;\r
+    }\r
+\r
+    /**\r
+     * This method initializes jTextField1     \r
+     *         \r
+     * @return javax.swing.JTextField  \r
+     */\r
+    private JTextField getJTextField1() {\r
+        if (jTextFieldSaveToFile == null) {\r
+            jTextFieldSaveToFile = new JTextField();\r
+            jTextFieldSaveToFile.setBounds(new java.awt.Rectangle(139, 70, 400, 20));\r
+        }\r
+        return jTextFieldSaveToFile;\r
+    }\r
+\r
+    /**\r
+     * This method initializes jButtonBrowser  \r
+     *         \r
+     * @return javax.swing.JButton     \r
+     */\r
+    private JButton getJButtonBrower() {\r
+        if (jButtonBrowser == null) {\r
+            jButtonBrowser = new JButton();\r
+            jButtonBrowser.setBounds(new java.awt.Rectangle(542, 70, 97, 20));\r
+            jButtonBrowser.setText("Browser...");\r
+            jButtonBrowser.addMouseListener(this);\r
+        }\r
+        return jButtonBrowser;\r
+    }\r
+\r
+    /**\r
+     * This method initializes jScrollPane     \r
+     *         \r
+     * @return javax.swing.JScrollPane \r
+     */\r
+    //  private JScrollPane getJScrollPane() {\r
+    //    if (jScrollPane == null) {\r
+    //      jScrollPane = new JScrollPane();\r
+    //      jScrollPane.setBounds(new java.awt.Rectangle(139,85,500,100));\r
+    //      jScrollPane.setViewportView(getJTable());\r
+    //    }\r
+    //    return jScrollPane;\r
+    //  }\r
+    /**\r
+     * This method initializes jButtonCancel   \r
+     *         \r
+     * @return javax.swing.JButton     \r
+     */\r
+    private JButton getJButtonCancel() {\r
+        if (jButtonCancel == null) {\r
+            jButtonCancel = new JButton();\r
+            jButtonCancel.setBounds(new java.awt.Rectangle(570, 330, 90, 20));\r
+            jButtonCancel.setText("Cancel");\r
+            jButtonCancel.addMouseListener(this);\r
+        }\r
+        return jButtonCancel;\r
+    }\r
+\r
+    /**\r
+     * This method initializes jButtonFinish   \r
+     *         \r
+     * @return javax.swing.JButton     \r
+     */\r
+    private JButton getJButtonFinish() {\r
+        if (jButtonFinish == null) {\r
+            jButtonFinish = new JButton();\r
+            jButtonFinish.setBounds(new java.awt.Rectangle(470, 330, 90, 20));\r
+            jButtonFinish.setText("Finish");\r
+            jButtonFinish.addMouseListener(this);\r
+        }\r
+        return jButtonFinish;\r
+    }\r
+\r
+    /**\r
+     * This method initializes jButtonPrevious \r
+     *         \r
+     * @return javax.swing.JButton     \r
+     */\r
+    private JButton getJButtonPrevious() {\r
+        if (jButtonPrevious == null) {\r
+            jButtonPrevious = new JButton();\r
+            jButtonPrevious.setBounds(new java.awt.Rectangle(370, 330, 90, 20));\r
+            jButtonPrevious.setText("Previous");\r
+            jButtonPrevious.addMouseListener(this);\r
+        }\r
+        return jButtonPrevious;\r
+    }\r
+\r
+    /**\r
+     * This is the default constructor\r
+     */\r
+    public CreateStepFour(IDialog iDialog, boolean modal) {\r
+        super(iDialog, modal);\r
+        initialize();\r
+    }\r
+\r
+    /**\r
+     * This method initializes this\r
+     * \r
+     * @return void\r
+     */\r
+    private void initialize() {\r
+        this.setSize(700, 400);\r
+        this.setContentPane(getJContentPane());\r
+        this.setTitle("Create Framework Archive(FAR) - Step 4: Summary");\r
+        this.centerWindow();\r
+    }\r
+\r
+    /**\r
+     * This method initializes jContentPane\r
+     * \r
+     * @return javax.swing.JPanel\r
+     */\r
+    private JPanel getJContentPane() {\r
+        if (jContentPane == null) {\r
+            jLabel2 = new JLabel();\r
+            jLabel2.setBounds(new java.awt.Rectangle(30, 70, 220, 18));\r
+            jLabel2.setText("Select File to Save:  ");\r
+            jLabel = new JLabel();\r
+            jLabel.setBounds(new java.awt.Rectangle(30, 64, 320, 20));\r
+            jLabel.setText("This FAR will depend on following packages: ");\r
+            jLabel.setVisible(false);\r
+            jContentPane = new JPanel();\r
+            jContentPane.setLayout(null);\r
+            jContentPane.add(getJTextArea(), null);\r
+            jContentPane.add(jLabel, null);\r
+            //      jContentPane.add(getJScrollPane(), null);\r
+            jContentPane.add(getJButtonCancel(), null);\r
+            jContentPane.add(getJButtonFinish(), null);\r
+            jContentPane.add(getJButtonPrevious(), null);\r
+            jContentPane.add(jLabel2, null);\r
+            jContentPane.add(getJTextField1(), null);\r
+            jContentPane.add(getJButtonBrower(), null);\r
+        }\r
+        return jContentPane;\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
+            // Add some logic process here\r
+            // Guid Check, File Check etc.\r
+            //\r
+            if (this.jTextFieldSaveToFile.getText() == null) {\r
+                Log.err("Please input the Far name!");\r
+            }\r
+            try {\r
+                //\r
+                // Create an output stream for JAR\r
+                //\r
+\r
+                Far far = new Far(new File(this.jTextFieldSaveToFile.getText()));\r
+\r
+                far.creatFar(this.getPreviousStep().getPreviousStep().getSelectedPackages(),\r
+                             this.getPreviousStep().getPreviousStep().getSelectedPlatforms(), this.getPreviousStep()\r
+                                                                                                  .getFileFilter(),\r
+                             this.getPreviousStep().getPreviousStep().getPreviousStep().getFarHeader());\r
+            } catch (Exception exp) {\r
+                Log.err("Create error! ");\r
+                return;\r
+            }\r
+            getPreviousStep().getPreviousStep().getPreviousStep().returnType = DataType.RETURN_TYPE_OK;\r
+            getPreviousStep().getPreviousStep().dispose();\r
+            getPreviousStep().dispose();\r
+            this.setVisible(false);\r
+            this.dispose();\r
+        } else if (e.getSource() == jButtonPrevious) {\r
+            this.setVisible(false);\r
+            stepThree.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
+            int result = fc.showSaveDialog(new JPanel());\r
+            if (result == JFileChooser.APPROVE_OPTION) {\r
+                this.jTextFieldSaveToFile.setText(Tools.addPathExt(fc.getSelectedFile().getPath(),\r
+                                                                   DataType.RETURN_TYPE_FAR_SURFACE_AREA));\r
+            }\r
+        }\r
+    }\r
+\r
+    public void mousePressed(MouseEvent e) {\r
+        // TODO Auto-generated method stub\r
+\r
+    }\r
+\r
+    public void mouseReleased(MouseEvent e) {\r
+        // TODO Auto-generated method stub\r
+\r
+    }\r
+\r
+    public void mouseEntered(MouseEvent e) {\r
+        // TODO Auto-generated method stub\r
+\r
+    }\r
+\r
+    public void mouseExited(MouseEvent e) {\r
+        // TODO Auto-generated method stub\r
+\r
+    }\r
+\r
+    public CreateStepThree getPreviousStep() {\r
+        return stepThree;\r
+    }\r
+\r
+    /**\r
+     * This method initializes jTable  \r
+     *         \r
+     * @return javax.swing.JTable      \r
+     */\r
+    //  private JTable getJTable() {\r
+    //    if (jTable == null) {\r
+    //      jTable = new JTable();\r
+    //      model = new PartialTableModel();\r
+    //      jTable = new JTable(model);\r
+    //      jTable.setRowHeight(20);\r
+    //      jTable.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS);\r
+    //      model.addColumn("GUID");\r
+    //      model.addColumn("Version");\r
+    //      model.addColumn("Name");\r
+    //      \r
+    //      jTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);\r
+    //    }\r
+    //    if (this.stepThree != null) {\r
+    //      prepareTable();\r
+    //    }\r
+    //    return jTable;\r
+    //  }\r
+    public void prepareTable() {\r
+        model.setRowCount(0);\r
+\r
+        List<PackageIdentification> packageList = new ArrayList<PackageIdentification>();\r
+        //\r
+        // Change here to get packages and platforms from FAR\r
+        //\r
+        List<PackageIdentification> selectedPackages = getPreviousStep().getPreviousStep().getSelectedPackages();\r
+        PackageQueryInterface pq = new PackageQuery();\r
+\r
+        Iterator<PackageIdentification> iter = selectedPackages.iterator();\r
+        while (iter.hasNext()) {\r
+            PackageIdentification item = iter.next();\r
+            List<PackageIdentification> list = pq.getPackageDependencies(item.getSpdFile());\r
+            packageList = AggregationOperation.union(list, packageList);\r
+        }\r
+\r
+        packageList = AggregationOperation.minus(packageList, selectedPackages);\r
+\r
+        iter = packageList.iterator();\r
+        while (iter.hasNext()) {\r
+            String[] str = new String[3];\r
+            PackageIdentification item = iter.next();\r
+            str[2] = item.getName();\r
+            str[1] = item.getVersion();\r
+            str[0] = item.getGuid();\r
+            model.addRow(str);\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
+        default:\r
+            return false;\r
+        }\r
+    }\r
+}\r
diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/far/createui/CreateStepOne.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/far/createui/CreateStepOne.java
new file mode 100644 (file)
index 0000000..25b4b9e
--- /dev/null
@@ -0,0 +1,624 @@
+/** @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
+\r
+package org.tianocore.frameworkwizard.far.createui;\r
+\r
+import java.awt.event.MouseEvent;\r
+import java.awt.event.MouseListener;\r
+\r
+import javax.swing.JButton;\r
+import javax.swing.JLabel;\r
+import javax.swing.JPanel;\r
+import javax.swing.JScrollPane;\r
+import javax.swing.JTextArea;\r
+import javax.swing.JTextField;\r
+\r
+import org.tianocore.frameworkwizard.common.DataValidation;\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.common.ui.IFrame;\r
+import org.tianocore.frameworkwizard.common.ui.StarLabel;\r
+import org.tianocore.frameworkwizard.far.FarHeader;\r
+\r
+public class CreateStepOne extends IDialog implements MouseListener {\r
+\r
+    // /\r
+    // / Define class Serial Version UID\r
+    // /\r
+    private static final long serialVersionUID = -8152099582923006900L;\r
+\r
+    //\r
+    // Define class members\r
+    //\r
+    private JPanel jContentPane = null;\r
+\r
+    private JLabel jLabelBaseName = null;\r
+\r
+    private JTextField jTextFieldBaseName = null;\r
+\r
+    private JLabel jLabelGuid = null;\r
+\r
+    private JTextField jTextFieldGuid = null;\r
+\r
+    private JLabel jLabelVersion = null;\r
+\r
+    private JTextField jTextFieldVersion = null;\r
+\r
+    private JButton jButtonGenerateGuid = null;\r
+\r
+    private JLabel jLabelLicense = null;\r
+\r
+    private JTextArea jTextAreaLicense = null;\r
+\r
+    private JLabel jLabelCopyright = null;\r
+\r
+    private JLabel jLabelDescription = null;\r
+\r
+    private JTextArea jTextAreaDescription = null;\r
+\r
+    private JLabel jLabelSpecification = null;\r
+\r
+    private JTextField jTextFieldSpecification = null;\r
+\r
+    private JButton jButtonOk = null;\r
+\r
+    private JScrollPane jScrollPaneLicense = null;\r
+\r
+    private JScrollPane jScrollPaneDescription = null;\r
+\r
+    private JLabel jLabelAbstract = null;\r
+\r
+    private JTextField jTextFieldAbstract = null;\r
+\r
+    private StarLabel jStarLabel1 = null;\r
+\r
+    private StarLabel jStarLabel4 = null;\r
+\r
+    private StarLabel jStarLabel5 = null;\r
+\r
+    private StarLabel jStarLabel6 = null;\r
+\r
+    private StarLabel jStarLabel7 = null;\r
+\r
+    private StarLabel jStarLabel8 = null;\r
+\r
+    private StarLabel jStarLabel10 = null;\r
+\r
+    private StarLabel jStarLabel12 = null;\r
+\r
+    private JTextField jTextFieldCopyright = null;\r
+\r
+    private JLabel jLabelURL = null;\r
+\r
+    private JTextField jTextFieldURL = null;\r
+\r
+    private JScrollPane jScrollPane = null;\r
+\r
+    private CreateStepTwo stepTwo = null;\r
+\r
+    private JButton jButtonCancel = null;\r
+\r
+    private JButton jButtonNext = null;\r
+\r
+    private FarHeader farHeader = new FarHeader();\r
+\r
+    /**\r
+     * This method initializes jTextFieldBaseName\r
+     * \r
+     * @return javax.swing.JTextField jTextFieldBaseName\r
+     * \r
+     */\r
+    private JTextField getJTextFieldBaseName() {\r
+        if (jTextFieldBaseName == null) {\r
+            jTextFieldBaseName = new JTextField();\r
+            jTextFieldBaseName.setBounds(new java.awt.Rectangle(160, 10, 260, 20));\r
+            jTextFieldBaseName.setToolTipText("An brief Identifier, such as USB I/O Library, of the module");\r
+        }\r
+        return jTextFieldBaseName;\r
+    }\r
+\r
+    /**\r
+     * This method initializes jTextFieldGuid\r
+     * \r
+     * @return javax.swing.JTextField jTextFieldGuid\r
+     * \r
+     */\r
+    private JTextField getJTextFieldGuid() {\r
+        if (jTextFieldGuid == null) {\r
+            jTextFieldGuid = new JTextField();\r
+            jTextFieldGuid.setBounds(new java.awt.Rectangle(160, 35, 260, 20));\r
+            jTextFieldGuid.setToolTipText("Guaranteed Unique Identification Number (8-4-4-4-12)");\r
+        }\r
+        return jTextFieldGuid;\r
+    }\r
+\r
+    /**\r
+     * This method initializes jTextFieldVersion\r
+     * \r
+     * @return javax.swing.JTextField jTextFieldVersion\r
+     * \r
+     */\r
+    private JTextField getJTextFieldVersion() {\r
+        if (jTextFieldVersion == null) {\r
+            jTextFieldVersion = new JTextField();\r
+            jTextFieldVersion.setBounds(new java.awt.Rectangle(160, 60, 260, 20));\r
+            jTextFieldVersion.setToolTipText("A Version Number, 1.0, 1, 1.01");\r
+        }\r
+        return jTextFieldVersion;\r
+    }\r
+\r
+    /**\r
+     * This method initializes jButtonGenerateGuid\r
+     * \r
+     * @return javax.swing.JButton jButtonGenerateGuid\r
+     * \r
+     */\r
+    private JButton getJButtonGenerateGuid() {\r
+        if (jButtonGenerateGuid == null) {\r
+            jButtonGenerateGuid = new JButton();\r
+            jButtonGenerateGuid.setBounds(new java.awt.Rectangle(440, 35, 90, 20));\r
+            jButtonGenerateGuid.setText("Generate");\r
+            jButtonGenerateGuid.addMouseListener(this);\r
+        }\r
+        return jButtonGenerateGuid;\r
+    }\r
+\r
+    /**\r
+     * This method initializes jTextAreaLicense\r
+     * \r
+     * @return javax.swing.JTextArea jTextAreaLicense\r
+     * \r
+     */\r
+    private JTextArea getJTextAreaLicense() {\r
+        if (jTextAreaLicense == null) {\r
+            jTextAreaLicense = new JTextArea();\r
+            jTextAreaLicense.setText("");\r
+            jTextAreaLicense.setLineWrap(true);\r
+            jTextAreaLicense.setToolTipText("The License for this file");\r
+        }\r
+        return jTextAreaLicense;\r
+    }\r
+\r
+    /**\r
+     * This method initializes jTextAreaDescription\r
+     * \r
+     * @return javax.swing.JTextArea jTextAreaDescription\r
+     * \r
+     */\r
+    private JTextArea getJTextAreaDescription() {\r
+        if (jTextAreaDescription == null) {\r
+            jTextAreaDescription = new JTextArea();\r
+            jTextAreaDescription.setLineWrap(true);\r
+            jTextAreaDescription.setToolTipText("A verbose description of the module");\r
+        }\r
+        return jTextAreaDescription;\r
+    }\r
+\r
+    /**\r
+     * This method initializes jTextFieldSpecification\r
+     * \r
+     * @return javax.swing.JTextField jTextFieldSpecification\r
+     * \r
+     */\r
+    private JTextField getJTextFieldSpecification() {\r
+        if (jTextFieldSpecification == null) {\r
+            jTextFieldSpecification = new JTextField();\r
+            jTextFieldSpecification.setText("FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052");\r
+            jTextFieldSpecification.setBounds(new java.awt.Rectangle(160, 290, 420, 20));\r
+            jTextFieldSpecification.setEditable(false);\r
+        }\r
+        return jTextFieldSpecification;\r
+    }\r
+\r
+    /**\r
+     * This method initializes jScrollPaneLicense\r
+     * \r
+     * @return javax.swing.JScrollPane jScrollPaneLicense\r
+     * \r
+     */\r
+    private JScrollPane getJScrollPaneLicense() {\r
+        if (jScrollPaneLicense == null) {\r
+            jScrollPaneLicense = new JScrollPane();\r
+            jScrollPaneLicense.setHorizontalScrollBarPolicy(javax.swing.JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);\r
+            jScrollPaneLicense.setBounds(new java.awt.Rectangle(160, 200, 420, 60));\r
+            jScrollPaneLicense.setViewportView(getJTextAreaLicense());\r
+        }\r
+        return jScrollPaneLicense;\r
+    }\r
+\r
+    /**\r
+     * This method initializes jScrollPaneDescription\r
+     * \r
+     * @return javax.swing.JScrollPane jScrollPaneDescription\r
+     * \r
+     */\r
+    private JScrollPane getJScrollPaneDescription() {\r
+        if (jScrollPaneDescription == null) {\r
+            jScrollPaneDescription = new JScrollPane();\r
+            jScrollPaneDescription.setHorizontalScrollBarPolicy(javax.swing.JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);\r
+            jScrollPaneDescription.setBounds(new java.awt.Rectangle(160, 110, 420, 60));\r
+            jScrollPaneDescription.setViewportView(getJTextAreaDescription());\r
+        }\r
+        return jScrollPaneDescription;\r
+    }\r
+\r
+    /**\r
+     * This method initializes jTextFieldAbstract\r
+     * \r
+     * @return javax.swing.JTextField jTextFieldAbstract\r
+     * \r
+     */\r
+    private JTextField getJTextFieldAbstract() {\r
+        if (jTextFieldAbstract == null) {\r
+            jTextFieldAbstract = new JTextField();\r
+            jTextFieldAbstract.setBounds(new java.awt.Rectangle(160, 85, 420, 20));\r
+            jTextFieldAbstract.setToolTipText("A one sentence description of this module");\r
+        }\r
+        return jTextFieldAbstract;\r
+    }\r
+\r
+    /**\r
+     * This method initializes jTextFieldCopyright\r
+     * \r
+     * @return javax.swing.JTextField jTextFieldCopyright\r
+     * \r
+     */\r
+    private JTextField getJTextFieldCopyright() {\r
+        if (jTextFieldCopyright == null) {\r
+            jTextFieldCopyright = new JTextField();\r
+            jTextFieldCopyright.setBounds(new java.awt.Rectangle(160, 175, 420, 20));\r
+            jTextFieldCopyright.setToolTipText("One or more copyright lines");\r
+        }\r
+        return jTextFieldCopyright;\r
+    }\r
+\r
+    /**\r
+     * This method initializes jTextFieldURL\r
+     * \r
+     * @return javax.swing.JTextField\r
+     */\r
+    private JTextField getJTextFieldURL() {\r
+        if (jTextFieldURL == null) {\r
+            jTextFieldURL = new JTextField();\r
+            jTextFieldURL.setBounds(new java.awt.Rectangle(160, 265, 420, 20));\r
+            jTextFieldURL.setToolTipText("A URL for the latest version of the license");\r
+        }\r
+        return jTextFieldURL;\r
+    }\r
+\r
+    /**\r
+     * This method initializes jScrollPane\r
+     * \r
+     * @return javax.swing.JScrollPane\r
+     */\r
+    private JScrollPane getJScrollPane() {\r
+        if (jScrollPane == null) {\r
+            jScrollPane = new JScrollPane();\r
+            jScrollPane.setViewportView(getJContentPane());\r
+        }\r
+        return jScrollPane;\r
+    }\r
+\r
+    /**\r
+     * This method initializes jButtonCancel1\r
+     * \r
+     * @return javax.swing.JButton\r
+     */\r
+    private JButton getJButtonCancel() {\r
+        if (jButtonCancel == null) {\r
+            jButtonCancel = new JButton();\r
+            jButtonCancel.setBounds(new java.awt.Rectangle(570, 330, 90, 20));\r
+            jButtonCancel.setText("Cancel");\r
+            jButtonCancel.addMouseListener(this);\r
+        }\r
+        return jButtonCancel;\r
+    }\r
+\r
+    /**\r
+     * This method initializes jButtonNext\r
+     * \r
+     * @return javax.swing.JButton\r
+     */\r
+    private JButton getJButtonNext() {\r
+        if (jButtonNext == null) {\r
+            jButtonNext = new JButton();\r
+            jButtonNext.setBounds(new java.awt.Rectangle(470, 330, 90, 20));\r
+            jButtonNext.setText("Next");\r
+            jButtonNext.addMouseListener(this);\r
+        }\r
+        return jButtonNext;\r
+    }\r
+\r
+    public static void main(String[] args) {\r
+        CreateStepOne c = new CreateStepOne(new IFrame(), true);\r
+        c.setVisible(true);\r
+    }\r
+\r
+    /**\r
+     * This is the default constructor\r
+     * \r
+     */\r
+    public CreateStepOne(IFrame iFrame, boolean modal) {\r
+        super(iFrame, modal);\r
+        initialize();\r
+    }\r
+\r
+    /**\r
+     * Disable all components when the mode is view\r
+     * \r
+     * @param isView\r
+     *          true - The view mode; false - The non-view mode\r
+     * \r
+     */\r
+    public void setViewMode(boolean isView) {\r
+        if (isView) {\r
+            this.jTextFieldBaseName.setEnabled(!isView);\r
+            this.jTextFieldGuid.setEnabled(!isView);\r
+            this.jTextFieldVersion.setEnabled(!isView);\r
+            this.jTextAreaLicense.setEnabled(!isView);\r
+            this.jTextFieldCopyright.setEnabled(!isView);\r
+            this.jTextAreaDescription.setEnabled(!isView);\r
+            this.jTextFieldSpecification.setEnabled(!isView);\r
+            this.jTextFieldAbstract.setEnabled(!isView);\r
+            this.jButtonGenerateGuid.setEnabled(!isView);\r
+            this.jButtonOk.setEnabled(!isView);\r
+        }\r
+    }\r
+\r
+    /**\r
+     * This method initializes this\r
+     * \r
+     */\r
+    private void initialize() {\r
+        this.setSize(700, 400);\r
+        this.setContentPane(getJScrollPane());\r
+        this.setTitle("Create Framework Archive(FAR) - Step 1: Set FAR's baseic information");\r
+        this.centerWindow();\r
+    }\r
+\r
+    /**\r
+     * This method initializes jContentPane\r
+     * \r
+     * @return javax.swing.JPanel jContentPane\r
+     * \r
+     */\r
+    private JPanel getJContentPane() {\r
+        if (jContentPane == null) {\r
+\r
+            jLabelURL = new JLabel();\r
+            jLabelURL.setText("License URL");\r
+            jLabelURL.setBounds(new java.awt.Rectangle(35, 265, 140, 20));\r
+            jLabelBaseName = new JLabel();\r
+            jLabelBaseName.setText("FAR Name");\r
+            jLabelBaseName.setBounds(new java.awt.Rectangle(35, 10, 140, 20));\r
+            jLabelGuid = new JLabel();\r
+            jLabelGuid.setText("Guid Value");\r
+            jLabelGuid.setBounds(new java.awt.Rectangle(35, 35, 140, 20));\r
+            jLabelVersion = new JLabel();\r
+            jLabelVersion.setText("Version");\r
+            jLabelVersion.setBounds(new java.awt.Rectangle(35, 60, 140, 20));\r
+            jLabelAbstract = new JLabel();\r
+            jLabelAbstract.setText("Abstract");\r
+            jLabelAbstract.setBounds(new java.awt.Rectangle(35, 85, 140, 20));\r
+            jLabelDescription = new JLabel();\r
+            jLabelDescription.setText("Description");\r
+            jLabelDescription.setBounds(new java.awt.Rectangle(35, 110, 140, 20));\r
+            jLabelCopyright = new JLabel();\r
+            jLabelCopyright.setText("Copyright");\r
+            jLabelCopyright.setBounds(new java.awt.Rectangle(35, 175, 140, 20));\r
+            jLabelLicense = new JLabel();\r
+            jLabelLicense.setText("License");\r
+            jLabelLicense.setBounds(new java.awt.Rectangle(35, 200, 140, 20));\r
+            jLabelSpecification = new JLabel();\r
+            jLabelSpecification.setText("Specification");\r
+            jLabelSpecification.setBounds(new java.awt.Rectangle(35, 290, 140, 20));\r
+\r
+            jContentPane = new JPanel();\r
+            jContentPane.setLayout(null);\r
+\r
+            jContentPane.add(jLabelBaseName, null);\r
+            jContentPane.add(getJTextFieldBaseName(), null);\r
+            jContentPane.add(jLabelGuid, null);\r
+            jContentPane.add(getJTextFieldGuid(), null);\r
+            jContentPane.add(jLabelVersion, null);\r
+            jContentPane.add(getJTextFieldVersion(), null);\r
+            jContentPane.add(getJButtonGenerateGuid(), null);\r
+            jContentPane.add(jLabelLicense, null);\r
+            jContentPane.add(jLabelCopyright, null);\r
+            jContentPane.add(jLabelDescription, null);\r
+            jContentPane.add(jLabelSpecification, null);\r
+            jContentPane.add(getJTextFieldSpecification(), null);\r
+            jContentPane.add(getJScrollPaneLicense(), null);\r
+            jContentPane.add(getJScrollPaneDescription(), null);\r
+            jContentPane.add(jLabelAbstract, null);\r
+            jContentPane.add(getJTextFieldAbstract(), null);\r
+            jContentPane.add(jLabelURL, null);\r
+            jContentPane.add(getJTextFieldURL(), null);\r
+            jContentPane.add(getJTextFieldCopyright(), null);\r
+            jStarLabel1 = new StarLabel();\r
+            jStarLabel1.setLocation(new java.awt.Point(20, 10));\r
+            jStarLabel4 = new StarLabel();\r
+            jStarLabel4.setLocation(new java.awt.Point(20, 35));\r
+            jStarLabel5 = new StarLabel();\r
+            jStarLabel5.setLocation(new java.awt.Point(20, 60));\r
+            jStarLabel6 = new StarLabel();\r
+            jStarLabel6.setLocation(new java.awt.Point(20, 110));\r
+            jStarLabel7 = new StarLabel();\r
+            jStarLabel7.setLocation(new java.awt.Point(20, 175));\r
+            jStarLabel8 = new StarLabel();\r
+            jStarLabel8.setLocation(new java.awt.Point(20, 200));\r
+            jStarLabel10 = new StarLabel();\r
+            jStarLabel10.setLocation(new java.awt.Point(20, 85));\r
+            jStarLabel12 = new StarLabel();\r
+            jStarLabel12.setLocation(new java.awt.Point(20, 290));\r
+\r
+            jContentPane.add(jStarLabel1, null);\r
+            jContentPane.add(jStarLabel4, null);\r
+            jContentPane.add(jStarLabel5, null);\r
+            jContentPane.add(jStarLabel6, null);\r
+            jContentPane.add(jStarLabel7, null);\r
+            jContentPane.add(jStarLabel8, null);\r
+            jContentPane.add(jStarLabel10, null);\r
+            jContentPane.add(jStarLabel12, null);\r
+            jContentPane.add(getJButtonCancel(), null);\r
+            jContentPane.add(getJButtonNext(), null);\r
+        }\r
+        return jContentPane;\r
+    }\r
+\r
+    public boolean valid() {\r
+        //\r
+        // Check BaseName\r
+        //\r
+        if (isEmpty(this.jTextFieldBaseName.getText())) {\r
+            Log.err("Base Name couldn't be empty");\r
+            return false;\r
+        }\r
+        if (!DataValidation.isBaseName(this.jTextFieldBaseName.getText())) {\r
+            Log.err("Incorrect data type for Base Name");\r
+            return false;\r
+        }\r
+        farHeader.setFarName(this.jTextFieldBaseName.getText());\r
+\r
+        //\r
+        // Check Guid\r
+        //\r
+        if (isEmpty(this.jTextFieldGuid.getText())) {\r
+            Log.err("Guid Value couldn't be empty");\r
+            return false;\r
+        }\r
+        if (!DataValidation.isGuid((this.jTextFieldGuid).getText())) {\r
+            Log.err("Incorrect data type for Guid");\r
+            return false;\r
+        }\r
+        farHeader.setGuidValue(this.jTextFieldGuid.getText());\r
+\r
+        //\r
+        // Check Version\r
+        //\r
+        if (isEmpty(this.jTextFieldVersion.getText())) {\r
+            Log.err("Version couldn't be empty");\r
+            return false;\r
+        }\r
+        if (!DataValidation.isVersion(this.jTextFieldVersion.getText())) {\r
+            Log.err("Incorrect data type for Version");\r
+            return false;\r
+        }\r
+        farHeader.setVersion(this.jTextFieldVersion.getText());\r
+\r
+        //\r
+        // Check Abstact\r
+        //\r
+        if (isEmpty(this.jTextFieldAbstract.getText())) {\r
+            Log.err("Abstract couldn't be empty");\r
+            return false;\r
+        }\r
+        if (!DataValidation.isAbstract(this.jTextFieldAbstract.getText())) {\r
+            Log.err("Incorrect data type for Abstract");\r
+            return false;\r
+        }\r
+        farHeader.setAbstractStr(this.jTextFieldAbstract.getText());\r
+\r
+        //\r
+        // Check Description\r
+        //\r
+        if (isEmpty(this.jTextAreaDescription.getText())) {\r
+            Log.err("Description couldn't be empty");\r
+            return false;\r
+        }\r
+        farHeader.setDescription(this.jTextAreaDescription.getText());\r
+\r
+        //\r
+        // Check Copyright\r
+        //\r
+        if (isEmpty(this.jTextFieldCopyright.getText())) {\r
+            Log.err("Copyright couldn't be empty");\r
+            return false;\r
+        }\r
+        farHeader.setCopyright(this.jTextFieldCopyright.getText());\r
+\r
+        //\r
+        // Check License\r
+        //\r
+        if (isEmpty(this.jTextAreaLicense.getText())) {\r
+            Log.err("License couldn't be empty");\r
+            return false;\r
+        }\r
+        farHeader.setLicense(this.jTextAreaLicense.getText());\r
+\r
+        farHeader.setSpecification(this.jTextFieldSpecification.getText());\r
+        return true;\r
+    }\r
+\r
+    /**\r
+     * Check the input data is empty or not\r
+     * \r
+     * @param strValue\r
+     *          The input data which need be checked\r
+     * \r
+     * @retval true - The input data is empty\r
+     * @retval fals - The input data is not empty\r
+     * \r
+     */\r
+    public boolean isEmpty(String strValue) {\r
+        if (strValue.length() > 0) {\r
+            return false;\r
+        }\r
+        return true;\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
+            // Add some logic process here\r
+            //\r
+            if (!valid()) {\r
+                return;\r
+            }\r
+            if (stepTwo == null) {\r
+                stepTwo = new CreateStepTwo(this, true, this);\r
+            }\r
+            this.setVisible(false);\r
+            stepTwo.setVisible(true);\r
+        } else if (e.getSource() == jButtonGenerateGuid) {\r
+            this.jTextFieldGuid.setText(Tools.generateUuidString());\r
+        }\r
+    }\r
+\r
+    public void mousePressed(MouseEvent e) {\r
+        // TODO Auto-generated method stub\r
+\r
+    }\r
+\r
+    public void mouseReleased(MouseEvent e) {\r
+        // TODO Auto-generated method stub\r
+\r
+    }\r
+\r
+    public void mouseEntered(MouseEvent e) {\r
+        // TODO Auto-generated method stub\r
+\r
+    }\r
+\r
+    public void mouseExited(MouseEvent e) {\r
+        // TODO Auto-generated method stub\r
+\r
+    }\r
+\r
+    public FarHeader getFarHeader() {\r
+        return farHeader;\r
+    }\r
+}\r
diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/far/createui/CreateStepThree.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/far/createui/CreateStepThree.java
new file mode 100644 (file)
index 0000000..fd7def7
--- /dev/null
@@ -0,0 +1,294 @@
+/** @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.frameworkwizard.far.createui;\r
+\r
+import java.awt.event.MouseEvent;\r
+import java.awt.event.MouseListener;\r
+import java.util.Iterator;\r
+import java.util.LinkedHashSet;\r
+import java.util.Set;\r
+import java.util.Vector;\r
+\r
+import javax.swing.JPanel;\r
+import javax.swing.JTextArea;\r
+import javax.swing.JButton;\r
+import javax.swing.JLabel;\r
+\r
+import org.tianocore.frameworkwizard.common.ui.IDialog;\r
+import org.tianocore.frameworkwizard.common.ui.iCheckBoxList.ICheckBoxList;\r
+import javax.swing.JScrollPane;\r
+import javax.swing.JTextField;\r
+\r
+public class CreateStepThree extends IDialog implements MouseListener {\r
+\r
+    /**\r
+     * \r
+     */\r
+    private static final long serialVersionUID = 7559888600474043337L;\r
+\r
+    private JPanel jContentPane = null;\r
+\r
+    private JTextArea jTextArea = null;\r
+\r
+    private JButton jButtonNext = null;\r
+\r
+    private JButton jButtonCancel = null;\r
+\r
+    private JButton jButtonPrevious = null;\r
+\r
+    private JLabel jLabel = null;\r
+\r
+    private ICheckBoxList jComboBoxFileFilter = null;\r
+\r
+    private JScrollPane jScrollPane = null;\r
+\r
+    private JLabel jLabel1 = null;\r
+\r
+    private JTextField jTextField = null;\r
+\r
+    Vector<String> v = new Vector<String>();\r
+\r
+    private CreateStepTwo stepTwo = null;\r
+\r
+    private CreateStepFour stepFour = null;\r
+\r
+    public CreateStepThree(IDialog iDialog, boolean modal, CreateStepTwo stepTwo) {\r
+        this(iDialog, modal);\r
+        this.stepTwo = stepTwo;\r
+    }\r
+\r
+    /**\r
+     * This method initializes jTextArea       \r
+     *         \r
+     * @return javax.swing.JTextArea   \r
+     */\r
+    private JTextArea getJTextArea() {\r
+        if (jTextArea == null) {\r
+            jTextArea = new JTextArea();\r
+            jTextArea.setBounds(new java.awt.Rectangle(30, 7, 642, 50));\r
+            jTextArea.setText("Step 2: Set File Filter\n");\r
+            jTextArea.append("Add more file filter regular expressions in text field separated with space. \n");\r
+            jTextArea.append("Note that regular expressions please reference PERL language. ");\r
+            jTextArea.setEditable(false);\r
+        }\r
+        return jTextArea;\r
+    }\r
+\r
+    /**\r
+     * This method initializes jButtonNext     \r
+     *         \r
+     * @return javax.swing.JButton     \r
+     */\r
+    private JButton getJButtonNext() {\r
+        if (jButtonNext == null) {\r
+            jButtonNext = new JButton();\r
+            jButtonNext.setBounds(new java.awt.Rectangle(470, 330, 90, 20));\r
+            jButtonNext.setText("Next");\r
+            jButtonNext.addMouseListener(this);\r
+        }\r
+        return jButtonNext;\r
+    }\r
+\r
+    /**\r
+     * This method initializes jButtonCancel   \r
+     *         \r
+     * @return javax.swing.JButton     \r
+     */\r
+    private JButton getJButtonCancel() {\r
+        if (jButtonCancel == null) {\r
+            jButtonCancel = new JButton();\r
+            jButtonCancel.setBounds(new java.awt.Rectangle(570, 330, 90, 20));\r
+            jButtonCancel.setText("Cancel");\r
+            jButtonCancel.addMouseListener(this);\r
+        }\r
+        return jButtonCancel;\r
+    }\r
+\r
+    /**\r
+     * This method initializes jButtonPrevious \r
+     *         \r
+     * @return javax.swing.JButton     \r
+     */\r
+    private JButton getJButtonPrevious() {\r
+        if (jButtonPrevious == null) {\r
+            jButtonPrevious = new JButton();\r
+            jButtonPrevious.setBounds(new java.awt.Rectangle(370, 330, 90, 20));\r
+            jButtonPrevious.setText("Previous");\r
+            jButtonPrevious.addMouseListener(this);\r
+        }\r
+        return jButtonPrevious;\r
+    }\r
+\r
+    /**\r
+     * This method initializes jComboBox       \r
+     *         \r
+     * @return javax.swing.JComboBox   \r
+     */\r
+    private ICheckBoxList getJComboBoxFileFilter() {\r
+        if (jComboBoxFileFilter == null) {\r
+            jComboBoxFileFilter = new ICheckBoxList();\r
+            v.addElement(".svn");\r
+            v.addElement("CVS");\r
+            jComboBoxFileFilter.setAllItems(v);\r
+            jComboBoxFileFilter.initCheckedItem(true, v);\r
+        }\r
+        return jComboBoxFileFilter;\r
+    }\r
+\r
+    /**\r
+     * This method initializes jScrollPane     \r
+     *         \r
+     * @return javax.swing.JScrollPane \r
+     */\r
+    private JScrollPane getJScrollPane() {\r
+        if (jScrollPane == null) {\r
+            jScrollPane = new JScrollPane();\r
+            jScrollPane.setBounds(new java.awt.Rectangle(139, 85, 500, 130));\r
+            jScrollPane.setViewportView(getJComboBoxFileFilter());\r
+        }\r
+        return jScrollPane;\r
+    }\r
+\r
+    /**\r
+     * This method initializes jTextField      \r
+     *         \r
+     * @return javax.swing.JTextField  \r
+     */\r
+    private JTextField getJTextField() {\r
+        if (jTextField == null) {\r
+            jTextField = new JTextField();\r
+            jTextField.setBounds(new java.awt.Rectangle(139, 250, 500, 20));\r
+        }\r
+        return jTextField;\r
+    }\r
+\r
+    /**\r
+     * @param args\r
+     */\r
+    public static void main(String[] args) {\r
+        // TODO Auto-generated method stub\r
+    }\r
+\r
+    /**\r
+     * This is the default constructor\r
+     */\r
+    public CreateStepThree(IDialog iDialog, boolean modal) {\r
+        super(iDialog, modal);\r
+        initialize();\r
+    }\r
+\r
+    /**\r
+     * This method initializes this\r
+     * \r
+     * @return void\r
+     */\r
+    private void initialize() {\r
+        this.setSize(700, 400);\r
+        this.setContentPane(getJContentPane());\r
+        this.setTitle("Create Framework Archive(FAR) - Step 3: Set File Filter");\r
+        this.centerWindow();\r
+    }\r
+\r
+    /**\r
+     * This method initializes jContentPane\r
+     * \r
+     * @return javax.swing.JPanel\r
+     */\r
+    private JPanel getJContentPane() {\r
+        if (jContentPane == null) {\r
+            jLabel1 = new JLabel();\r
+            jLabel1.setBounds(new java.awt.Rectangle(30, 220, 260, 20));\r
+            jLabel1.setText("Input File Filter Pattern (Ref to ...)");\r
+            jLabel = new JLabel();\r
+            jLabel.setBounds(new java.awt.Rectangle(30, 64, 160, 20));\r
+            jLabel.setText("File Filter Pattern: ");\r
+            jContentPane = new JPanel();\r
+            jContentPane.setLayout(null);\r
+            jContentPane.add(getJTextArea(), null);\r
+            jContentPane.add(getJButtonNext(), null);\r
+            jContentPane.add(getJButtonCancel(), null);\r
+            jContentPane.add(getJButtonPrevious(), null);\r
+            jContentPane.add(jLabel, null);\r
+            jContentPane.add(getJScrollPane(), null);\r
+            jContentPane.add(jLabel1, null);\r
+            jContentPane.add(getJTextField(), null);\r
+        }\r
+        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
+            // Add some logic process here\r
+            //\r
+\r
+            if (stepFour == null) {\r
+                stepFour = new CreateStepFour(this, true, this);\r
+                stepFour.setVisible(true);\r
+            } else {\r
+                stepFour.setVisible(true);\r
+            }\r
+            this.setVisible(false);\r
+        } else if (e.getSource() == jButtonPrevious) {\r
+            this.setVisible(false);\r
+            stepTwo.setVisible(true);\r
+        }\r
+    }\r
+\r
+    public void mousePressed(MouseEvent e) {\r
+        // TODO Auto-generated method stub\r
+\r
+    }\r
+\r
+    public void mouseReleased(MouseEvent e) {\r
+        // TODO Auto-generated method stub\r
+\r
+    }\r
+\r
+    public void mouseEntered(MouseEvent e) {\r
+        // TODO Auto-generated method stub\r
+\r
+    }\r
+\r
+    public void mouseExited(MouseEvent e) {\r
+        // TODO Auto-generated method stub\r
+\r
+    }\r
+\r
+    public Set<String> getFileFilter() {\r
+        Set<String> result = new LinkedHashSet<String>();\r
+        Vector<Integer> selected = jComboBoxFileFilter.getAllCheckedItemsIndex();\r
+\r
+        Iterator<Integer> iter = selected.iterator();\r
+\r
+        while (iter.hasNext()) {\r
+            result.add(v.get(iter.next().intValue()));\r
+        }\r
+\r
+        String[] userdefined = jTextField.getText().split(" ");\r
+\r
+        for (int i = 0; i < userdefined.length; i++) {\r
+            if (!userdefined[i].trim().equalsIgnoreCase("")) {\r
+                result.add(userdefined[i]);\r
+            }\r
+        }\r
+\r
+        return result;\r
+    }\r
+\r
+    public CreateStepTwo getPreviousStep() {\r
+        return stepTwo;\r
+    }\r
+}\r
diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/far/createui/CreateStepTwo.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/far/createui/CreateStepTwo.java
new file mode 100644 (file)
index 0000000..c1d1d3a
--- /dev/null
@@ -0,0 +1,322 @@
+/** @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
+\r
+package org.tianocore.frameworkwizard.far.createui;\r
+\r
+import java.awt.event.MouseEvent;\r
+import java.awt.event.MouseListener;\r
+import java.util.ArrayList;\r
+import java.util.Iterator;\r
+import java.util.List;\r
+import java.util.Vector;\r
+\r
+import javax.swing.JButton;\r
+import javax.swing.JLabel;\r
+import javax.swing.JPanel;\r
+import javax.swing.JScrollPane;\r
+import javax.swing.JTextArea;\r
+\r
+import org.tianocore.frameworkwizard.common.Log;\r
+import org.tianocore.frameworkwizard.common.ui.IDialog;\r
+import org.tianocore.frameworkwizard.common.ui.iCheckBoxList.ICheckBoxList;\r
+import org.tianocore.frameworkwizard.packaging.PackageIdentification;\r
+import org.tianocore.frameworkwizard.platform.PlatformIdentification;\r
+import org.tianocore.frameworkwizard.workspace.WorkspaceTools;\r
+\r
+public class CreateStepTwo extends IDialog implements MouseListener {\r
+\r
+    /**\r
+     * \r
+     */\r
+    private static final long serialVersionUID = 3003841865197005528L;\r
+\r
+    private JPanel jContentPane = null;\r
+\r
+    private JTextArea jTextArea = null;\r
+\r
+    private JLabel jLabel = null;\r
+\r
+    private JLabel jLabel1 = null;\r
+\r
+    private ICheckBoxList jComboBoxPackage = null;\r
+\r
+    private ICheckBoxList jComboBoxPlatform = null;\r
+\r
+    private JButton jButtonNext = null;\r
+\r
+    private JButton jButtonCancel = null;\r
+\r
+    private JScrollPane jScrollPanePackage = null;\r
+\r
+    private JScrollPane jScrollPanePlatform = null;\r
+\r
+    private CreateStepThree stepThree = null;\r
+\r
+    private Vector<PlatformIdentification> platformVector = null;\r
+\r
+    private Vector<PackageIdentification> packageVector = null;\r
+\r
+    private CreateStepOne stepOne = null;\r
+\r
+    private JButton jButtonPrevious = null;\r
+\r
+    public CreateStepTwo(IDialog iDialog, boolean modal, CreateStepOne stepOne) {\r
+        this(iDialog, modal);\r
+        this.stepOne = stepOne;\r
+    }\r
+\r
+    /**\r
+     * This method initializes jTextArea       \r
+     *         \r
+     * @return javax.swing.JTextArea   \r
+     */\r
+    private JTextArea getJTextArea() {\r
+        if (jTextArea == null) {\r
+            jTextArea = new JTextArea();\r
+            jTextArea.setBounds(new java.awt.Rectangle(30, 7, 642, 50));\r
+            jTextArea.setText("Step 1: Choose Packages and Platforms\n");\r
+            jTextArea.append("Choose at least one package or platform. ");\r
+            jTextArea.setEditable(false);\r
+        }\r
+        return jTextArea;\r
+    }\r
+\r
+    /**\r
+     * This method initializes jComboBox       \r
+     *         \r
+     * @return javax.swing.JComboBox   \r
+     */\r
+    private ICheckBoxList getJComboBoxPackage() {\r
+        if (jComboBoxPackage == null) {\r
+            jComboBoxPackage = new ICheckBoxList();\r
+            WorkspaceTools wt = new WorkspaceTools();\r
+            Vector<String> v = new Vector<String>();\r
+            packageVector = wt.getAllPackages();\r
+            Iterator<PackageIdentification> iter = packageVector.iterator();\r
+            while (iter.hasNext()) {\r
+                PackageIdentification item = iter.next();\r
+                String str = item.getName() + " " + item.getVersion() + " [" + item.getPath() + "]";\r
+                v.addElement(str);\r
+            }\r
+            jComboBoxPackage.setAllItems(v);\r
+        }\r
+        return jComboBoxPackage;\r
+    }\r
+\r
+    /**\r
+     * This method initializes jComboBox1      \r
+     *         \r
+     * @return javax.swing.JComboBox   \r
+     */\r
+    private ICheckBoxList getJComboBoxPlatform() {\r
+        if (jComboBoxPlatform == null) {\r
+            jComboBoxPlatform = new ICheckBoxList();\r
+            WorkspaceTools wt = new WorkspaceTools();\r
+            Vector<String> v = new Vector<String>();\r
+            platformVector = wt.getAllPlatforms();\r
+            Iterator<PlatformIdentification> iter = platformVector.iterator();\r
+            while (iter.hasNext()) {\r
+                PlatformIdentification item = iter.next();\r
+                String str = item.getName() + " " + item.getVersion() + " [" + item.getPath() + "]";\r
+                v.addElement(str);\r
+            }\r
+            jComboBoxPlatform.setAllItems(v);\r
+        }\r
+        return jComboBoxPlatform;\r
+    }\r
+\r
+    /**\r
+     * This method initializes jButtonNext     \r
+     *         \r
+     * @return javax.swing.JButton     \r
+     */\r
+    private JButton getJButtonNext() {\r
+        if (jButtonNext == null) {\r
+            jButtonNext = new JButton();\r
+            jButtonNext.setBounds(new java.awt.Rectangle(470, 330, 90, 20));\r
+            jButtonNext.setText("Next");\r
+            jButtonNext.addMouseListener(this);\r
+        }\r
+        return jButtonNext;\r
+    }\r
+\r
+    /**\r
+     * This method initializes jButtonCancel   \r
+     *         \r
+     * @return javax.swing.JButton     \r
+     */\r
+    private JButton getJButtonCancel() {\r
+        if (jButtonCancel == null) {\r
+            jButtonCancel = new JButton();\r
+            jButtonCancel.setBounds(new java.awt.Rectangle(570, 330, 90, 20));\r
+            jButtonCancel.setText("Cancel");\r
+            jButtonCancel.addMouseListener(this);\r
+        }\r
+        return jButtonCancel;\r
+    }\r
+\r
+    /**\r
+     * This method initializes jScrollPane     \r
+     *         \r
+     * @return javax.swing.JScrollPane \r
+     */\r
+    private JScrollPane getJScrollPanePackage() {\r
+        if (jScrollPanePackage == null) {\r
+            jScrollPanePackage = new JScrollPane();\r
+            jScrollPanePackage.setBounds(new java.awt.Rectangle(139, 64, 500, 130));\r
+            jScrollPanePackage.setViewportView(getJComboBoxPackage());\r
+        }\r
+        return jScrollPanePackage;\r
+    }\r
+\r
+    /**\r
+     * This method initializes jScrollPane1    \r
+     *         \r
+     * @return javax.swing.JScrollPane \r
+     */\r
+    private JScrollPane getJScrollPanePlatform() {\r
+        if (jScrollPanePlatform == null) {\r
+            jScrollPanePlatform = new JScrollPane();\r
+            jScrollPanePlatform.setBounds(new java.awt.Rectangle(139, 200, 500, 100));\r
+            jScrollPanePlatform.setViewportView(getJComboBoxPlatform());\r
+        }\r
+        return jScrollPanePlatform;\r
+    }\r
+\r
+    /**\r
+     * This is the default constructor\r
+     */\r
+    public CreateStepTwo(IDialog iDialog, boolean modal) {\r
+        super(iDialog, modal);\r
+        initialize();\r
+    }\r
+\r
+    /**\r
+     * This method initializes this\r
+     * \r
+     * @return void\r
+     */\r
+    private void initialize() {\r
+        this.setSize(700, 400);\r
+        this.setContentPane(getJContentPane());\r
+        this.setTitle("Create Framework Archive(FAR) - Step 2: Choose Packages and Platform");\r
+        this.centerWindow();\r
+    }\r
+\r
+    /**\r
+     * This method initializes jContentPane\r
+     * \r
+     * @return javax.swing.JPanel\r
+     */\r
+    private JPanel getJContentPane() {\r
+        if (jContentPane == null) {\r
+            jLabel1 = new JLabel();\r
+            jLabel1.setBounds(new java.awt.Rectangle(30, 200, 100, 20));\r
+            jLabel1.setText("Platforms: ");\r
+            jLabel = new JLabel();\r
+            jLabel.setBounds(new java.awt.Rectangle(30, 64, 100, 20));\r
+            jLabel.setText("Packages:");\r
+            jContentPane = new JPanel();\r
+            jContentPane.setLayout(null);\r
+            jContentPane.add(getJTextArea(), null);\r
+            jContentPane.add(jLabel, null);\r
+            jContentPane.add(jLabel1, null);\r
+            jContentPane.add(getJButtonNext(), null);\r
+            jContentPane.add(getJButtonCancel(), null);\r
+            jContentPane.add(getJScrollPanePackage(), null);\r
+            jContentPane.add(getJScrollPanePlatform(), null);\r
+            jContentPane.add(getJButtonPrevious(), null);\r
+        }\r
+        return jContentPane;\r
+    }\r
+\r
+    public void mouseClicked(MouseEvent e) {\r
+        if (e.getSource() == jButtonCancel) {\r
+            this.setVisible(false);\r
+        } else if (e.getSource() == jButtonPrevious) {\r
+            this.setVisible(false);\r
+            stepOne.setVisible(true);\r
+        } else if (e.getSource() == jButtonNext) {\r
+            //\r
+            // Add some logic process here\r
+            //\r
+            if (jComboBoxPlatform.getAllCheckedItemsIndex().size() == 0\r
+                && jComboBoxPackage.getAllCheckedItemsIndex().size() == 0) {\r
+                Log.err("At least choose one of packages and platforms. ");\r
+                return;\r
+            }\r
+            if (stepThree == null) {\r
+                stepThree = new CreateStepThree(this, true, this);\r
+            }\r
+            this.setVisible(false);\r
+            stepThree.setVisible(true);\r
+        }\r
+    }\r
+\r
+    public void mousePressed(MouseEvent e) {\r
+        // TODO Auto-generated method stub\r
+\r
+    }\r
+\r
+    public void mouseReleased(MouseEvent e) {\r
+        // TODO Auto-generated method stub\r
+\r
+    }\r
+\r
+    public void mouseEntered(MouseEvent e) {\r
+        // TODO Auto-generated method stub\r
+\r
+    }\r
+\r
+    public void mouseExited(MouseEvent e) {\r
+        // TODO Auto-generated method stub\r
+\r
+    }\r
+\r
+    /**\r
+     * This method initializes jButtonPrevious \r
+     *         \r
+     * @return javax.swing.JButton     \r
+     */\r
+    private JButton getJButtonPrevious() {\r
+        if (jButtonPrevious == null) {\r
+            jButtonPrevious = new JButton();\r
+            jButtonPrevious.setBounds(new java.awt.Rectangle(370, 330, 90, 20));\r
+            jButtonPrevious.setText("Previous");\r
+            jButtonPrevious.addMouseListener(this);\r
+        }\r
+        return jButtonPrevious;\r
+    }\r
+\r
+    public List<PackageIdentification> getSelectedPackages() {\r
+        Vector<Integer> v = jComboBoxPackage.getAllCheckedItemsIndex();\r
+        List<PackageIdentification> result = new ArrayList<PackageIdentification>();\r
+        for (int i = 0; i < v.size(); i++) {\r
+            result.add(packageVector.get(v.get(i).intValue()));\r
+        }\r
+        return result;\r
+    }\r
+\r
+    public List<PlatformIdentification> getSelectedPlatforms() {\r
+        Vector<Integer> v = jComboBoxPlatform.getAllCheckedItemsIndex();\r
+        List<PlatformIdentification> result = new ArrayList<PlatformIdentification>();\r
+        for (int i = 0; i < v.size(); i++) {\r
+            result.add(platformVector.get(v.get(i).intValue()));\r
+        }\r
+        return result;\r
+    }\r
+\r
+    public CreateStepOne getPreviousStep() {\r
+        return stepOne;\r
+    }\r
+}\r
diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/far/deleteui/DeleteStepOne.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/far/deleteui/DeleteStepOne.java
new file mode 100644 (file)
index 0000000..ecb71c3
--- /dev/null
@@ -0,0 +1,396 @@
+/** @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
+\r
+package org.tianocore.frameworkwizard.far.deleteui;\r
+\r
+import javax.swing.ImageIcon;\r
+import javax.swing.JPanel;\r
+import javax.swing.JButton;\r
+import javax.swing.JTextArea;\r
+import javax.swing.JLabel;\r
+import javax.swing.JScrollPane;\r
+\r
+import org.tianocore.frameworkwizard.common.ui.IDialog;\r
+import org.tianocore.frameworkwizard.common.ui.IFrame;\r
+import org.tianocore.frameworkwizard.far.AggregationOperation;\r
+import org.tianocore.frameworkwizard.far.FarIdentification;\r
+import org.tianocore.frameworkwizard.far.PackageQuery;\r
+import org.tianocore.frameworkwizard.far.PackageQueryInterface;\r
+import org.tianocore.frameworkwizard.packaging.PackageIdentification;\r
+import org.tianocore.frameworkwizard.platform.PlatformIdentification;\r
+import org.tianocore.frameworkwizard.workspace.WorkspaceTools;\r
+\r
+import java.awt.Color;\r
+import java.awt.Dimension;\r
+import java.awt.Toolkit;\r
+import java.awt.event.MouseEvent;\r
+import java.awt.event.MouseListener;\r
+import java.util.Iterator;\r
+import java.util.List;\r
+import java.util.Vector;\r
+\r
+import javax.swing.JList;\r
+import javax.swing.event.ListSelectionEvent;\r
+import javax.swing.event.ListSelectionListener;\r
+\r
+public class DeleteStepOne extends IDialog implements ListSelectionListener, MouseListener {\r
+\r
+    /**\r
+     * \r
+     */\r
+    private static final long serialVersionUID = 636773964435618476L;\r
+\r
+    private JPanel jContentPane = null;\r
+\r
+    private JButton jButtonCancel = null;\r
+\r
+    private JButton jButtonNext = null;\r
+\r
+    private JTextArea jTextAreaInstruction = null;\r
+\r
+    private JLabel jLabel = null;\r
+\r
+    private JScrollPane jScrollPane = null;\r
+\r
+    private JLabel jLabel2 = null;\r
+\r
+    private JLabel jLabel3 = null;\r
+\r
+    private JScrollPane jScrollPane1 = null;\r
+\r
+    private JScrollPane jScrollPane2 = null;\r
+\r
+    private JList jListPlatform = null;\r
+\r
+    private JList jListPackage = null;\r
+\r
+    private JLabel jLabel4 = null;\r
+\r
+    private JButton jButtonDetail = null;\r
+\r
+    private JList jListFar = null;\r
+\r
+    private JLabel jLabelImage = null;\r
+\r
+    private Vector<FarIdentification> farVector = null;\r
+\r
+    Vector<PackageIdentification> removePackages = null;\r
+\r
+    Vector<PlatformIdentification> removePlatforms = null;\r
+\r
+    private DeleteStepTwo stepTwo = null;\r
+\r
+    /**\r
+     * This method initializes jButtonCancel\r
+     * \r
+     * @return javax.swing.JButton\r
+     */\r
+    private JButton getJButtonCancel() {\r
+        if (jButtonCancel == null) {\r
+            jButtonCancel = new JButton();\r
+            jButtonCancel.setBounds(new java.awt.Rectangle(570, 330, 90, 20));\r
+            jButtonCancel.setText("Cancel");\r
+            jButtonCancel.addMouseListener(this);\r
+        }\r
+        return jButtonCancel;\r
+    }\r
+\r
+    /**\r
+     * This method initializes jButtonFinish\r
+     * \r
+     * @return javax.swing.JButton\r
+     */\r
+    private JButton getJButtonNext() {\r
+        if (jButtonNext == null) {\r
+            jButtonNext = new JButton();\r
+            jButtonNext.setBounds(new java.awt.Rectangle(470, 330, 90, 20));\r
+            jButtonNext.setText("Next");\r
+            jButtonNext.setEnabled(false);\r
+        }\r
+        return jButtonNext;\r
+    }\r
+\r
+    /**\r
+     * This method initializes jTextArea1\r
+     * \r
+     * @return javax.swing.JTextArea\r
+     */\r
+    private JTextArea getJTextArea1() {\r
+        if (jTextAreaInstruction == null) {\r
+            jTextAreaInstruction = new JTextArea();\r
+            jTextAreaInstruction.setBounds(new java.awt.Rectangle(30, 7, 642, 50));\r
+            jTextAreaInstruction.setText("Step 1: Choose FAR from framework database. \n");\r
+            jTextAreaInstruction.setCaretColor(Color.RED);\r
+            jTextAreaInstruction\r
+                                .append("After choose FAR, the packages and platforms which belong to the FAR will display. \n");\r
+            jTextAreaInstruction.append("Picture \"Okay\" or \"No\" indicates whether FAR can be removed or not. ");\r
+            jTextAreaInstruction.setEditable(false);\r
+        }\r
+        return jTextAreaInstruction;\r
+    }\r
+\r
+    /**\r
+     * This method initializes jScrollPane\r
+     * \r
+     * @return javax.swing.JScrollPane\r
+     */\r
+    private JScrollPane getJScrollPane() {\r
+        if (jScrollPane == null) {\r
+            jScrollPane = new JScrollPane();\r
+            jScrollPane.setBounds(new java.awt.Rectangle(139, 64, 500, 104));\r
+            jScrollPane.setViewportView(getJListFar());\r
+        }\r
+        return jScrollPane;\r
+    }\r
+\r
+    /**\r
+     * This method initializes jScrollPane1\r
+     * \r
+     * @return javax.swing.JScrollPane\r
+     */\r
+    private JScrollPane getJScrollPane1() {\r
+        if (jScrollPane1 == null) {\r
+            jScrollPane1 = new JScrollPane();\r
+            jScrollPane1.setBounds(new java.awt.Rectangle(40, 195, 300, 115));\r
+            jScrollPane1.setViewportView(getJListPackage());\r
+        }\r
+        return jScrollPane1;\r
+    }\r
+\r
+    /**\r
+     * This method initializes jScrollPane2\r
+     * \r
+     * @return javax.swing.JScrollPane\r
+     */\r
+    private JScrollPane getJScrollPane2() {\r
+        if (jScrollPane2 == null) {\r
+            jScrollPane2 = new JScrollPane();\r
+            jScrollPane2.setBounds(new java.awt.Rectangle(360, 195, 300, 115));\r
+            jScrollPane2.setViewportView(getJListPlatform());\r
+        }\r
+        return jScrollPane2;\r
+    }\r
+\r
+    /**\r
+     * This method initializes jList\r
+     * \r
+     * @return javax.swing.JList\r
+     */\r
+    private JList getJListPlatform() {\r
+        if (jListPlatform == null) {\r
+            jListPlatform = new JList();\r
+            jListPlatform.setEnabled(false);\r
+        }\r
+        return jListPlatform;\r
+    }\r
+\r
+    /**\r
+     * This method initializes jList1\r
+     * \r
+     * @return javax.swing.JList\r
+     */\r
+    private JList getJListPackage() {\r
+        if (jListPackage == null) {\r
+            jListPackage = new JList();\r
+            jListPackage.setEnabled(false);\r
+        }\r
+        return jListPackage;\r
+    }\r
+\r
+    /**\r
+     * This method initializes jButtonDetail\r
+     * \r
+     * @return javax.swing.JButton\r
+     */\r
+    private JButton getJButtonDetail() {\r
+        if (jButtonDetail == null) {\r
+            jButtonDetail = new JButton();\r
+            jButtonDetail.setBounds(new java.awt.Rectangle(367, 325, 69, 20));\r
+            jButtonDetail.setText("Detail");\r
+            jButtonDetail.setVisible(false);\r
+            jButtonDetail.addMouseListener(this);\r
+        }\r
+        return jButtonDetail;\r
+    }\r
+\r
+    /**\r
+     * This method initializes jListFar\r
+     * \r
+     * @return javax.swing.JList\r
+     */\r
+    private JList getJListFar() {\r
+        if (jListFar == null) {\r
+            jListFar = new JList();\r
+            WorkspaceTools wt = new WorkspaceTools();\r
+            farVector = wt.getAllFars();\r
+            jListFar.setListData(farVector);\r
+            jListFar.addListSelectionListener(this);\r
+        }\r
+        return jListFar;\r
+    }\r
+\r
+    /**\r
+     * This is the default constructor\r
+     */\r
+    public DeleteStepOne(IFrame iFrame, boolean modal) {\r
+        super(iFrame, modal);\r
+        initialize();\r
+    }\r
+\r
+    /**\r
+     * This method initializes this\r
+     * \r
+     * @return void\r
+     */\r
+    private void initialize() {\r
+        this.setSize(700, 400);\r
+        this.setContentPane(getJContentPane());\r
+        this.setTitle("Delete Framework Archive(FAR) - Step 1: Choose FAR from framework database");\r
+        Dimension d = Toolkit.getDefaultToolkit().getScreenSize();\r
+        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
+            jLabelImage = new JLabel();\r
+            jLabelImage.setBounds(new java.awt.Rectangle(30, 319, 36, 36));\r
+            jLabel4 = new JLabel();\r
+            jLabel4.setBounds(new java.awt.Rectangle(71, 325, 289, 20));\r
+            jLabel3 = new JLabel();\r
+            jLabel3.setBounds(new java.awt.Rectangle(360, 170, 113, 20));\r
+            jLabel3.setText("FAR's Platforms");\r
+            jLabel2 = new JLabel();\r
+            jLabel2.setBounds(new java.awt.Rectangle(40, 170, 113, 20));\r
+            jLabel2.setText("FAR's Packages");\r
+            jLabel = new JLabel();\r
+            jLabel.setBounds(new java.awt.Rectangle(30, 64, 100, 20));\r
+            jLabel.setText("Select one FAR: ");\r
+            jContentPane = new JPanel();\r
+            jContentPane.setLayout(null);\r
+            jContentPane.add(getJButtonCancel(), null);\r
+            jContentPane.add(getJButtonNext(), null);\r
+            jContentPane.add(getJTextArea1(), null);\r
+            jContentPane.add(jLabel, null);\r
+            jContentPane.add(getJScrollPane(), null);\r
+            jContentPane.add(jLabel2, null);\r
+            jContentPane.add(jLabel3, null);\r
+            jContentPane.add(getJScrollPane1(), null);\r
+            jContentPane.add(getJScrollPane2(), null);\r
+            jContentPane.add(jLabel4, null);\r
+            jContentPane.add(getJButtonDetail(), null);\r
+            jContentPane.add(jLabelImage, null);\r
+        }\r
+        return jContentPane;\r
+    }\r
+\r
+    public void valueChanged(ListSelectionEvent e) {\r
+        //\r
+        // Add logic for FAR list value changed\r
+        //\r
+        if (e.getSource() == jListFar) {\r
+            boolean flag = true;\r
+            FarIdentification far = (FarIdentification) jListFar.getSelectedValue();\r
+            WorkspaceTools wt = new WorkspaceTools();\r
+\r
+            removePackages = wt.getPackagesByFar(far);\r
+            jListPackage.setListData(removePackages);\r
+            removePlatforms = wt.getPlatformsByFar(far);\r
+            jListPlatform.setListData(removePlatforms);\r
+\r
+            //\r
+            // Get Dependencies Info for current FAR\r
+            //\r
+            List<PackageIdentification> allPackages = wt.getAllPackages();\r
+\r
+            //\r
+            // Remain packages\r
+            //\r
+            allPackages.removeAll(removePackages);\r
+\r
+            Iterator<PackageIdentification> iter = allPackages.iterator();\r
+\r
+            PackageQueryInterface pq = new PackageQuery();\r
+            while (iter.hasNext()) {\r
+                PackageIdentification item = iter.next();\r
+                List<PackageIdentification> list = pq.getPackageDependencies(item.getSpdFile());\r
+                List<PackageIdentification> result = AggregationOperation.minus(list, allPackages);\r
+                if (result.size() > 0) {\r
+                    if (AggregationOperation.intersection(result, removePackages).size() > 0) {\r
+                        flag = false;\r
+                        break;\r
+                    }\r
+                }\r
+            }\r
+\r
+            if (flag) {\r
+                jLabelImage.setIcon(new ImageIcon(getClass().getResource("/resources/images/Yes.JPG")));\r
+                jLabel4.setText("Without any remain packages depend on this FAR. ");\r
+                jButtonDetail.setVisible(false);\r
+                jButtonNext.setEnabled(true);\r
+                jButtonNext.addMouseListener(this);\r
+            } else {\r
+                jLabelImage.setIcon(new ImageIcon(getClass().getResource("/resources/images/No.JPG")));\r
+                jLabel4.setText("Some remain packages still depend on this FAR. ");\r
+                //        jButtonDetail.setVisible(true);\r
+                jButtonNext.setEnabled(false);\r
+                jButtonNext.removeMouseListener(this);\r
+            }\r
+        }\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
+            // Add some logic process here\r
+            //\r
+\r
+            if (stepTwo == null) {\r
+                stepTwo = new DeleteStepTwo(this, true, this);\r
+            }\r
+            this.setVisible(false);\r
+            stepTwo.setVisible(true);\r
+        }\r
+    }\r
+\r
+    public void mousePressed(MouseEvent e) {\r
+        // TODO Auto-generated method stub\r
+\r
+    }\r
+\r
+    public void mouseReleased(MouseEvent e) {\r
+        // TODO Auto-generated method stub\r
+\r
+    }\r
+\r
+    public void mouseEntered(MouseEvent e) {\r
+        // TODO Auto-generated method stub\r
+\r
+    }\r
+\r
+    public void mouseExited(MouseEvent e) {\r
+        // TODO Auto-generated method stub\r
+\r
+    }\r
+\r
+    public FarIdentification getSelecedFar() {\r
+        return (FarIdentification) jListFar.getSelectedValue();\r
+    }\r
+\r
+}\r
diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/far/deleteui/DeleteStepTwo.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/far/deleteui/DeleteStepTwo.java
new file mode 100644 (file)
index 0000000..17a565d
--- /dev/null
@@ -0,0 +1,350 @@
+/** @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
+\r
+package org.tianocore.frameworkwizard.far.deleteui;\r
+\r
+import java.awt.Dimension;\r
+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.Iterator;\r
+import java.util.LinkedHashSet;\r
+import java.util.Set;\r
+import java.util.Vector;\r
+\r
+import javax.swing.ButtonGroup;\r
+import javax.swing.JPanel;\r
+import javax.swing.JButton;\r
+import javax.swing.JTextArea;\r
+import javax.swing.JLabel;\r
+import javax.swing.JRadioButton;\r
+\r
+import org.tianocore.frameworkwizard.common.DataType;\r
+import org.tianocore.frameworkwizard.common.ui.IDialog;\r
+import org.tianocore.frameworkwizard.far.FarIdentification;\r
+import org.tianocore.frameworkwizard.packaging.PackageIdentification;\r
+import org.tianocore.frameworkwizard.platform.PlatformIdentification;\r
+import org.tianocore.frameworkwizard.workspace.WorkspaceTools;\r
+\r
+public class DeleteStepTwo extends IDialog implements MouseListener {\r
+\r
+    /**\r
+     * \r
+     */\r
+    private static final long serialVersionUID = -1333748185798962746L;\r
+\r
+    private JPanel jContentPane = null;\r
+\r
+    private JButton jButtonCancel = null;\r
+\r
+    private JButton jButtonFinish = null;\r
+\r
+    private JButton jButtonPrevious = null;\r
+\r
+    private JTextArea jTextArea = null;\r
+\r
+    private JLabel jLabel = null;\r
+\r
+    private JRadioButton jRadioButton = null;\r
+\r
+    private JRadioButton jRadioButton1 = null;\r
+\r
+    private DeleteStepOne stepOne = null;\r
+\r
+    public DeleteStepTwo(IDialog iDialog, boolean modal, DeleteStepOne stepOne) {\r
+        this(iDialog, modal);\r
+        this.stepOne = stepOne;\r
+    }\r
+\r
+    /**\r
+     * This method initializes jButtonCancel   \r
+     *         \r
+     * @return javax.swing.JButton     \r
+     */\r
+    private JButton getJButtonCancel() {\r
+        if (jButtonCancel == null) {\r
+            jButtonCancel = new JButton();\r
+            jButtonCancel.setBounds(new java.awt.Rectangle(570, 330, 90, 20));\r
+            jButtonCancel.setText("Cancel");\r
+            jButtonCancel.addMouseListener(this);\r
+        }\r
+        return jButtonCancel;\r
+    }\r
+\r
+    /**\r
+     * This method initializes jButtonFinish   \r
+     *         \r
+     * @return javax.swing.JButton     \r
+     */\r
+    private JButton getJButtonFinish() {\r
+        if (jButtonFinish == null) {\r
+            jButtonFinish = new JButton();\r
+            jButtonFinish.setBounds(new java.awt.Rectangle(470, 330, 90, 20));\r
+            jButtonFinish.setText("Finish");\r
+            jButtonFinish.addMouseListener(this);\r
+        }\r
+        return jButtonFinish;\r
+    }\r
+\r
+    /**\r
+     * This method initializes jButtonPrevious \r
+     *         \r
+     * @return javax.swing.JButton     \r
+     */\r
+    private JButton getJButtonPrevious() {\r
+        if (jButtonPrevious == null) {\r
+            jButtonPrevious = new JButton();\r
+            jButtonPrevious.setBounds(new java.awt.Rectangle(370, 330, 90, 20));\r
+            jButtonPrevious.setText("Previous");\r
+            jButtonPrevious.addMouseListener(this);\r
+        }\r
+        return jButtonPrevious;\r
+    }\r
+\r
+    /**\r
+     * This method initializes jTextArea       \r
+     *         \r
+     * @return javax.swing.JTextArea   \r
+     */\r
+    private JTextArea getJTextArea() {\r
+        if (jTextArea == null) {\r
+            jTextArea = new JTextArea();\r
+            jTextArea.setBounds(new java.awt.Rectangle(30, 7, 642, 50));\r
+            jTextArea.setText("Step 2: Choose Delete Mode. \n");\r
+            jTextArea.append("Mode 1 only remove register information from framework database. \n");\r
+            jTextArea.append("Mode 2 also delete all files from file system. ");\r
+            jTextArea.setEditable(false);\r
+        }\r
+        return jTextArea;\r
+    }\r
+\r
+    /**\r
+     * This method initializes jRadioButton    \r
+     *         \r
+     * @return javax.swing.JRadioButton        \r
+     */\r
+    private JRadioButton getJRadioButton() {\r
+        if (jRadioButton == null) {\r
+            jRadioButton = new JRadioButton();\r
+            jRadioButton.setBounds(new java.awt.Rectangle(100, 100, 340, 20));\r
+            jRadioButton.setSelected(true);\r
+            jRadioButton.setText("Mode 1: Only remove from framework database");\r
+        }\r
+        return jRadioButton;\r
+    }\r
+\r
+    /**\r
+     * This method initializes jRadioButton1   \r
+     *         \r
+     * @return javax.swing.JRadioButton        \r
+     */\r
+    private JRadioButton getJRadioButton1() {\r
+        if (jRadioButton1 == null) {\r
+            jRadioButton1 = new JRadioButton();\r
+            jRadioButton1.setBounds(new java.awt.Rectangle(100, 140, 358, 20));\r
+            jRadioButton1.setText("Mode 2: Delete all related files from workspace");\r
+        }\r
+        return jRadioButton1;\r
+    }\r
+\r
+    /**\r
+     * This is the default constructor\r
+     */\r
+    public DeleteStepTwo(IDialog iDialog, boolean modal) {\r
+        super(iDialog, modal);\r
+        initialize();\r
+    }\r
+\r
+    /**\r
+     * This method initializes this\r
+     * \r
+     * @return void\r
+     */\r
+    private void initialize() {\r
+        this.setSize(700, 400);\r
+        this.setContentPane(getJContentPane());\r
+        this.setTitle("Delete Framework Archive(FAR) - Step 2: Choose Delete Mode");\r
+        Dimension d = Toolkit.getDefaultToolkit().getScreenSize();\r
+        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, 200, 20));\r
+            jLabel.setText("Select delete mode: ");\r
+            jContentPane = new JPanel();\r
+            jContentPane.setLayout(null);\r
+            jContentPane.add(getJButtonCancel(), null);\r
+            jContentPane.add(getJButtonFinish(), null);\r
+            jContentPane.add(getJButtonPrevious(), null);\r
+            jContentPane.add(getJTextArea(), null);\r
+            jContentPane.add(jLabel, null);\r
+            ButtonGroup group = new ButtonGroup();\r
+            group.add(getJRadioButton());\r
+            group.add(getJRadioButton1());\r
+            jContentPane.add(getJRadioButton(), null);\r
+            jContentPane.add(getJRadioButton1(), null);\r
+        }\r
+        return jContentPane;\r
+    }\r
+\r
+    public void mouseClicked(MouseEvent e) {\r
+        if (e.getSource() == jButtonCancel) {\r
+            this.setVisible(false);\r
+            this.dispose();\r
+        } else if (e.getSource() == jButtonFinish) {\r
+            FarIdentification far = stepOne.getSelecedFar();\r
+            WorkspaceTools wt = new WorkspaceTools();\r
+            //\r
+            // If remove all source files\r
+            //\r
+            if (jRadioButton1.isSelected()) {\r
+\r
+                Vector<PackageIdentification> removePackages = wt.getPackagesByFar(far);\r
+                Vector<PlatformIdentification> removePlatforms = wt.getPlatformsByFar(far);\r
+\r
+                Vector<PlatformIdentification> allPlatforms = wt.getAllPlatforms();\r
+                Set<File> allPlatformFiles = new LinkedHashSet<File>();\r
+\r
+                Iterator<PlatformIdentification> iter = allPlatforms.iterator();\r
+                while (iter.hasNext()) {\r
+                    allPlatformFiles.add(iter.next().getFpdFile());\r
+                }\r
+\r
+                //\r
+                // For all platforms, only remove its FPD file\r
+                //\r
+                Iterator<PlatformIdentification> platfomrIter = removePlatforms.iterator();\r
+                while (platfomrIter.hasNext()) {\r
+                    PlatformIdentification item = platfomrIter.next();\r
+                    allPlatformFiles.remove(item.getFpdFile());\r
+                    File parentDir = item.getFpdFile().getParentFile();\r
+                    item.getFpdFile().delete();\r
+                    //\r
+                    // Remove all empty parent dir\r
+                    //\r
+                    while (parentDir.listFiles().length == 0) {\r
+                        File tempFile = parentDir;\r
+                        parentDir = parentDir.getParentFile();\r
+                        tempFile.delete();\r
+                    }\r
+                }\r
+\r
+                //\r
+                // For all packages, remove all files. \r
+                // Exception FPD file still in DB\r
+                //\r
+\r
+                Iterator<PackageIdentification> packageIter = removePackages.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
+            //\r
+            // Update DB file\r
+            //\r
+            wt.removeFarFromDb(far);\r
+\r
+            this.setVisible(false);\r
+            this.stepOne.returnType = DataType.RETURN_TYPE_OK;\r
+            this.dispose();\r
+        } else if (e.getSource() == jButtonPrevious) {\r
+            this.setVisible(false);\r
+            stepOne.setVisible(true);\r
+        }\r
+    }\r
+\r
+    public void mousePressed(MouseEvent e) {\r
+        // TODO Auto-generated method stub\r
+\r
+    }\r
+\r
+    public void mouseReleased(MouseEvent e) {\r
+        // TODO Auto-generated method stub\r
+\r
+    }\r
+\r
+    public void mouseEntered(MouseEvent e) {\r
+        // TODO Auto-generated method stub\r
+\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
+            } else {\r
+                if (isContain(fileList[i], platformFiles)) {\r
+                    recursiveDir(files, fileList[i], platformFiles);\r
+                } else {\r
+                    files.add(fileList[i]);\r
+                }\r
+            }\r
+        }\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
+    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
diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/far/installui/InstallStepOne.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/far/installui/InstallStepOne.java
new file mode 100644 (file)
index 0000000..aa8afcd
--- /dev/null
@@ -0,0 +1,361 @@
+/** @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
+\r
+package org.tianocore.frameworkwizard.far.installui;\r
+\r
+import java.awt.Dimension;\r
+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.List;\r
+import java.util.jar.JarFile;\r
+import java.util.Iterator;\r
+\r
+import javax.swing.JFileChooser;\r
+import javax.swing.JPanel;\r
+import javax.swing.JButton;\r
+import javax.swing.JTextArea;\r
+import javax.swing.JLabel;\r
+import javax.swing.JTextField;\r
+import javax.swing.ListSelectionModel;\r
+\r
+import org.tianocore.frameworkwizard.common.DataType;\r
+import org.tianocore.frameworkwizard.common.IFileFilter;\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.common.ui.IFrame;\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.workspace.Workspace;\r
+\r
+import javax.swing.JScrollPane;\r
+import javax.swing.JTable;\r
+import javax.swing.table.DefaultTableModel;\r
+\r
+public class InstallStepOne extends IDialog implements MouseListener {\r
+\r
+    /**\r
+     * \r
+     */\r
+    private static final long serialVersionUID = -8821906198791949544L;\r
+\r
+    private JPanel jContentPane = null;\r
+\r
+    private JButton jButtonCancel = null;\r
+\r
+    private JButton jButtonNext = null;\r
+\r
+    private JTextArea jTextArea = null;\r
+\r
+    private JLabel jLabel = null;\r
+\r
+    private JTextField jTextFieldFarFile = null;\r
+\r
+    private JButton jButtonBrowser = null;\r
+\r
+    private InstallStepTwo stepTwo = null;\r
+\r
+    Far far = null;\r
+\r
+    private JLabel jLabelWarning = null;\r
+\r
+    private JScrollPane jScrollPane = null;\r
+\r
+    private JTable jTable = null;\r
+\r
+    private PartialTableModel model = null;\r
+\r
+    /**\r
+     * This method initializes jButtonCancel   \r
+     *         \r
+     * @return javax.swing.JButton     \r
+     */\r
+    private JButton getJButtonCancel() {\r
+        if (jButtonCancel == null) {\r
+            jButtonCancel = new JButton();\r
+            jButtonCancel.setBounds(new java.awt.Rectangle(570, 330, 90, 20));\r
+            jButtonCancel.setText("Cancel");\r
+            jButtonCancel.addMouseListener(this);\r
+        }\r
+        return jButtonCancel;\r
+    }\r
+\r
+    /**\r
+     * This method initializes jButtonNext     \r
+     *         \r
+     * @return javax.swing.JButton     \r
+     */\r
+    private JButton getJButtonNext() {\r
+        if (jButtonNext == null) {\r
+            jButtonNext = new JButton();\r
+            jButtonNext.setBounds(new java.awt.Rectangle(470, 330, 90, 20));\r
+            jButtonNext.setText("Next");\r
+            jButtonNext.addMouseListener(this);\r
+        }\r
+        return jButtonNext;\r
+    }\r
+\r
+    /**\r
+     * This method initializes jTextArea       \r
+     *         \r
+     * @return javax.swing.JTextArea   \r
+     */\r
+    private JTextArea getJTextArea() {\r
+        if (jTextArea == null) {\r
+            jTextArea = new JTextArea();\r
+            jTextArea.setBounds(new java.awt.Rectangle(30, 7, 642, 50));\r
+            jTextArea.setText("Step 1: Choose a framework archive(FAR) file. \n");\r
+            jTextArea.setEditable(false);\r
+        }\r
+        return jTextArea;\r
+    }\r
+\r
+    /**\r
+     * This method initializes jTextField      \r
+     *         \r
+     * @return javax.swing.JTextField  \r
+     */\r
+    private JTextField getJTextFieldFarFile() {\r
+        if (jTextFieldFarFile == null) {\r
+            jTextFieldFarFile = new JTextField();\r
+            jTextFieldFarFile.setBounds(new java.awt.Rectangle(139, 100, 400, 20));\r
+        }\r
+        return jTextFieldFarFile;\r
+    }\r
+\r
+    /**\r
+     * This method initializes jButtonBrowser  \r
+     *         \r
+     * @return javax.swing.JButton     \r
+     */\r
+    private JButton getJButtonBrowser() {\r
+        if (jButtonBrowser == null) {\r
+            jButtonBrowser = new JButton();\r
+            jButtonBrowser.setBounds(new java.awt.Rectangle(542, 100, 97, 20));\r
+            jButtonBrowser.setText("Browser...");\r
+            jButtonBrowser.addMouseListener(this);\r
+        }\r
+        return jButtonBrowser;\r
+    }\r
+\r
+    /**\r
+     * This method initializes jScrollPane     \r
+     *         \r
+     * @return javax.swing.JScrollPane \r
+     */\r
+    private JScrollPane getJScrollPane() {\r
+        if (jScrollPane == null) {\r
+            jScrollPane = new JScrollPane();\r
+            jScrollPane.setBounds(new java.awt.Rectangle(27, 166, 511, 143));\r
+            jScrollPane.setViewportView(getJTable());\r
+        }\r
+        jScrollPane.setVisible(false);\r
+        return jScrollPane;\r
+    }\r
+\r
+    /**\r
+     * This method initializes jTable  \r
+     *         \r
+     * @return javax.swing.JTable      \r
+     */\r
+    private JTable getJTable() {\r
+        if (jTable == null) {\r
+            jTable = new JTable();\r
+            model = new PartialTableModel();\r
+            jTable = new JTable(model);\r
+            jTable.setRowHeight(20);\r
+            jTable.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS);\r
+            model.addColumn("Name");\r
+            model.addColumn("Version");\r
+            model.addColumn("GUID");\r
+\r
+            jTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);\r
+        }\r
+        jTable.setVisible(false);\r
+        return jTable;\r
+    }\r
+\r
+    public void prepareTable(List<PackageIdentification> packageList) {\r
+        model.setRowCount(0);\r
+        //\r
+        // Change here to get packages and platforms from FAR\r
+        //\r
+        Iterator<PackageIdentification> iter = packageList.iterator();\r
+        while (iter.hasNext()) {\r
+            String[] str = new String[3];\r
+            PackageIdentification item = iter.next();\r
+            str[0] = item.getName();\r
+            str[1] = item.getVersion();\r
+            str[2] = item.getGuid();\r
+            model.addRow(str);\r
+        }\r
+    }\r
+\r
+    /**\r
+     * This is the default constructor\r
+     */\r
+    public InstallStepOne(IFrame iFrame, boolean modal) {\r
+        super(iFrame, modal);\r
+        initialize();\r
+    }\r
+\r
+    /**\r
+     * This method initializes this\r
+     * \r
+     * @return void\r
+     */\r
+    private void initialize() {\r
+        this.setSize(700, 400);\r
+        this.setContentPane(getJContentPane());\r
+        this.setTitle("Install Framework Archive(FAR) - Step 1: Choose FAR file");\r
+        Dimension d = Toolkit.getDefaultToolkit().getScreenSize();\r
+        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
+            jLabelWarning = new JLabel();\r
+            jLabelWarning.setBounds(new java.awt.Rectangle(29, 134, 410, 20));\r
+            jLabelWarning.setText("Can't install this FAR, lack following packages in current workspace");\r
+            jLabelWarning.setVisible(false);\r
+            jLabel = new JLabel();\r
+            jLabel.setBounds(new java.awt.Rectangle(30, 80, 220, 20));\r
+            jLabel.setText("Choose FAR file: ");\r
+            jContentPane = new JPanel();\r
+            jContentPane.setLayout(null);\r
+            jContentPane.add(getJButtonCancel(), null);\r
+            jContentPane.add(getJButtonNext(), null);\r
+            jContentPane.add(getJTextArea(), null);\r
+            jContentPane.add(jLabel, null);\r
+            jContentPane.add(getJTextFieldFarFile(), null);\r
+            jContentPane.add(getJButtonBrowser(), null);\r
+            jContentPane.add(jLabelWarning, null);\r
+            jContentPane.add(getJScrollPane(), null);\r
+        }\r
+        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
+            // Add some logic process here\r
+            //\r
+            File 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
+            // Verify Far\r
+            //\r
+            JarFile jarFar;\r
+            try {\r
+                jarFar = new JarFile(farFile);\r
+                far = new Far(jarFar);\r
+\r
+                //\r
+                // Far dependency check\r
+                //\r
+                List<PackageIdentification> pkgIdList = DistributeRule.installFarCheck(far);\r
+\r
+                if (pkgIdList.size() > 0) {\r
+                    prepareTable(pkgIdList);\r
+                    jLabelWarning.setVisible(true);\r
+                    jTable.setVisible(true);\r
+                    jScrollPane.setVisible(true);\r
+                    return;\r
+                }\r
+\r
+            } catch (Exception exp) {\r
+                exp.printStackTrace();\r
+                Log.err("Far file invaild! The error message as follow:" + exp.getMessage());\r
+            }\r
+\r
+            if (stepTwo == null) {\r
+                stepTwo = new InstallStepTwo(this, true, this);\r
+            }\r
+            this.setVisible(false);\r
+\r
+            //\r
+            // Refresh table\r
+            //\r
+            stepTwo.preparePackageTable();\r
+            stepTwo.preparePlatformTable();\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
+            int result = fc.showSaveDialog(new JPanel());\r
+            if (result == JFileChooser.APPROVE_OPTION) {\r
+                jLabelWarning.setVisible(false);\r
+                jTable.setVisible(false);\r
+                jScrollPane.setVisible(false);\r
+                this.jTextFieldFarFile.setText(Tools.addPathExt(fc.getSelectedFile().getPath(),\r
+                                                                DataType.RETURN_TYPE_FAR_SURFACE_AREA));\r
+            }\r
+        }\r
+    }\r
+\r
+    public void mousePressed(MouseEvent e) {\r
+        // TODO Auto-generated method stub\r
+\r
+    }\r
+\r
+    public void mouseReleased(MouseEvent e) {\r
+        // TODO Auto-generated method stub\r
+\r
+    }\r
+\r
+    public void mouseEntered(MouseEvent e) {\r
+        // TODO Auto-generated method stub\r
+\r
+    }\r
+\r
+    public void mouseExited(MouseEvent e) {\r
+        // TODO Auto-generated method stub\r
+\r
+    }\r
+\r
+    public Far getFar() {\r
+        return far;\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
+        default:\r
+            return false;\r
+        }\r
+    }\r
+}\r
diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/far/installui/InstallStepTwo.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/far/installui/InstallStepTwo.java
new file mode 100644 (file)
index 0000000..33b4073
--- /dev/null
@@ -0,0 +1,467 @@
+/** @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
+\r
+package org.tianocore.frameworkwizard.far.installui;\r
+\r
+import java.awt.Color;\r
+import java.awt.Dimension;\r
+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.LinkedHashMap;\r
+import java.util.LinkedHashSet;\r
+import java.util.List;\r
+import java.util.Map;\r
+import java.util.Set;\r
+\r
+import javax.swing.JPanel;\r
+import javax.swing.JTextArea;\r
+import javax.swing.JButton;\r
+import javax.swing.JLabel;\r
+import javax.swing.JScrollPane;\r
+import javax.swing.ListSelectionModel;\r
+import javax.swing.table.DefaultTableModel;\r
+import javax.swing.JTable;\r
+\r
+import org.tianocore.frameworkwizard.common.DataType;\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.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
+public class InstallStepTwo extends IDialog implements MouseListener {\r
+\r
+    /**\r
+     * \r
+     */\r
+    private static final long serialVersionUID = 4583090421587036969L;\r
+\r
+    private JPanel jContentPane = null;\r
+\r
+    private JTextArea jTextArea = null;\r
+\r
+    private PartialEditableTableModel packageModel = null;\r
+\r
+    private PartialEditableTableModel platformModel = null;\r
+\r
+    private InstallStepOne stepOne = null;\r
+\r
+    private JButton jButtonCancel = null;\r
+\r
+    private JButton jButtonFinish = null;\r
+\r
+    private JButton jButtonPrevious = null;\r
+\r
+    private JLabel jLabel = null;\r
+\r
+    private JScrollPane jScrollPane = null;\r
+\r
+    private JTable jTablePackage = null;\r
+\r
+    private JLabel jLabel1 = null;\r
+\r
+    private JScrollPane jScrollPane1 = null;\r
+\r
+    private JTable jTablePlatform = null;\r
+\r
+    List<PlatformIdentification> platformVector = null;\r
+\r
+    List<PackageIdentification> packageVector = null;\r
+\r
+    public InstallStepTwo(IDialog iDialog, boolean modal, InstallStepOne stepOne) {\r
+        this(iDialog, modal);\r
+        this.stepOne = stepOne;\r
+    }\r
+\r
+    /**\r
+     * This method initializes jTextArea       \r
+     *         \r
+     * @return javax.swing.JTextArea   \r
+     */\r
+    private JTextArea getJTextArea() {\r
+        if (jTextArea == null) {\r
+            jTextArea = new JTextArea();\r
+            jTextArea.setBounds(new java.awt.Rectangle(30, 7, 642, 50));\r
+            jTextArea.setText("Step 2: Set Path for Packages and Platforms. \n");\r
+            jTextArea.setCaretColor(Color.RED);\r
+            jTextArea.append("Note that path is relative to WORKSPACE. ");\r
+            jTextArea.setEditable(false);\r
+        }\r
+        return jTextArea;\r
+    }\r
+\r
+    /**\r
+     * This method initializes jButtonCancel   \r
+     *         \r
+     * @return javax.swing.JButton     \r
+     */\r
+    private JButton getJButtonCancel() {\r
+        if (jButtonCancel == null) {\r
+            jButtonCancel = new JButton();\r
+            jButtonCancel.setBounds(new java.awt.Rectangle(570, 330, 90, 20));\r
+            jButtonCancel.setText("Cancel");\r
+            jButtonCancel.addMouseListener(this);\r
+        }\r
+        return jButtonCancel;\r
+    }\r
+\r
+    /**\r
+     * This method initializes jButtonFinish   \r
+     *         \r
+     * @return javax.swing.JButton     \r
+     */\r
+    private JButton getJButtonFinish() {\r
+        if (jButtonFinish == null) {\r
+            jButtonFinish = new JButton();\r
+            jButtonFinish.setBounds(new java.awt.Rectangle(470, 330, 90, 20));\r
+            jButtonFinish.setText("Finish");\r
+            jButtonFinish.addMouseListener(this);\r
+        }\r
+        return jButtonFinish;\r
+    }\r
+\r
+    /**\r
+     * This method initializes jButtonPrevious \r
+     *         \r
+     * @return javax.swing.JButton     \r
+     */\r
+    private JButton getJButtonPrevious() {\r
+        if (jButtonPrevious == null) {\r
+            jButtonPrevious = new JButton();\r
+            jButtonPrevious.setBounds(new java.awt.Rectangle(370, 330, 90, 20));\r
+            jButtonPrevious.setText("Previous");\r
+            jButtonPrevious.addMouseListener(this);\r
+        }\r
+        return jButtonPrevious;\r
+    }\r
+\r
+    /**\r
+     * This method initializes jScrollPane     \r
+     *         \r
+     * @return javax.swing.JScrollPane \r
+     */\r
+    private JScrollPane getJScrollPane() {\r
+        if (jScrollPane == null) {\r
+            jScrollPane = new JScrollPane();\r
+            jScrollPane.setBounds(new java.awt.Rectangle(35, 81, 600, 113));\r
+            jScrollPane.setViewportView(getJTablePackage());\r
+        }\r
+        return jScrollPane;\r
+    }\r
+\r
+    /**\r
+     * This method initializes jTable  \r
+     *         \r
+     * @return javax.swing.JTable      \r
+     */\r
+    private JTable getJTablePackage() {\r
+        if (jTablePackage == null) {\r
+            jTablePackage = new JTable();\r
+            packageModel = new PartialEditableTableModel();\r
+            jTablePackage = new JTable(packageModel);\r
+            jTablePackage.setRowHeight(20);\r
+            jTablePackage.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS);\r
+            packageModel.addColumn("Name");\r
+            packageModel.addColumn("Version");\r
+            packageModel.addColumn("Default Path");\r
+            packageModel.addColumn("Install To");\r
+\r
+            jTablePackage.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);\r
+        }\r
+        return jTablePackage;\r
+    }\r
+\r
+    public void preparePackageTable() {\r
+        packageModel.setRowCount(0);\r
+        //\r
+        // Change here to get packages and platforms from FAR\r
+        //\r
+        try {\r
+            Far far = stepOne.getFar();\r
+\r
+            packageVector = far.mainfest.getPackageList();\r
+            Iterator<PackageIdentification> iter = packageVector.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] = Tools.getFilePathOnly(Tools.getRelativePath(item.getPath(), Workspace.getCurrentWorkspace()));\r
+                str[3] = Tools.getFilePathOnly(Tools.getRelativePath(item.getPath(), Workspace.getCurrentWorkspace()));\r
+                packageModel.addRow(str);\r
+            }\r
+        } catch (Exception e) {\r
+        }\r
+    }\r
+\r
+    /**\r
+     * This method initializes jScrollPane1    \r
+     *         \r
+     * @return javax.swing.JScrollPane \r
+     */\r
+    private JScrollPane getJScrollPane1() {\r
+        if (jScrollPane1 == null) {\r
+            jScrollPane1 = new JScrollPane();\r
+            jScrollPane1.setBounds(new java.awt.Rectangle(35, 214, 596, 112));\r
+            jScrollPane1.setViewportView(getJTablePlatform());\r
+        }\r
+        return jScrollPane1;\r
+    }\r
+\r
+    /**\r
+     * This method initializes jTablePlatform  \r
+     *         \r
+     * @return javax.swing.JTable      \r
+     */\r
+    private JTable getJTablePlatform() {\r
+        if (jTablePlatform == null) {\r
+            jTablePlatform = new JTable();\r
+            platformModel = new PartialEditableTableModel();\r
+            jTablePlatform = new JTable(platformModel);\r
+            jTablePlatform.setRowHeight(20);\r
+            jTablePlatform.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS);\r
+            platformModel.addColumn("Name");\r
+            platformModel.addColumn("Version");\r
+            platformModel.addColumn("Default Path");\r
+            platformModel.addColumn("Install To");\r
+\r
+            jTablePlatform.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);\r
+            preparePlatformTable();\r
+        }\r
+        return jTablePlatform;\r
+    }\r
+\r
+    public void preparePlatformTable() {\r
+        platformModel.setRowCount(0);\r
+        //\r
+        // Change here to get packages and platforms from FAR\r
+        //\r
+        try {\r
+            Far far = stepOne.getFar();\r
+\r
+            platformVector = far.mainfest.getPlatformList();\r
+            Iterator<PlatformIdentification> iter = platformVector.iterator();\r
+            while (iter.hasNext()) {\r
+                String[] str = new String[4];\r
+                PlatformIdentification item = iter.next();\r
+                str[0] = item.getName();\r
+                str[1] = item.getVersion();\r
+                str[2] = Tools.getFilePathOnly(Tools.getRelativePath(item.getPath(), Workspace.getCurrentWorkspace()));\r
+                str[3] = Tools.getFilePathOnly(Tools.getRelativePath(item.getPath(), Workspace.getCurrentWorkspace()));\r
+                platformModel.addRow(str);\r
+            }\r
+        } catch (Exception e) {\r
+        }\r
+    }\r
+\r
+    /**\r
+     * This is the default constructor\r
+     */\r
+    public InstallStepTwo(IDialog iDialog, boolean modal) {\r
+        super(iDialog, modal);\r
+        initialize();\r
+    }\r
+\r
+    /**\r
+     * This method initializes this\r
+     * \r
+     * @return void\r
+     */\r
+    private void initialize() {\r
+        this.setSize(700, 400);\r
+        this.setContentPane(getJContentPane());\r
+        this.setTitle("Install Framework Archive(FAR) - Step 2: Set Path for Packages and Platforms");\r
+        Dimension d = Toolkit.getDefaultToolkit().getScreenSize();\r
+        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
+            jLabel1 = new JLabel();\r
+            jLabel1.setBounds(new java.awt.Rectangle(30, 195, 348, 18));\r
+            jLabel1.setText("Edit pathes for platforms: ");\r
+            jLabel = new JLabel();\r
+            jLabel.setBounds(new java.awt.Rectangle(29, 60, 366, 20));\r
+            jLabel.setText("Edit pathes for packages");\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(jLabel, null);\r
+            jContentPane.add(getJScrollPane(), null);\r
+            jContentPane.add(jLabel1, null);\r
+            jContentPane.add(getJScrollPane1(), null);\r
+        }\r
+        return jContentPane;\r
+    }\r
+\r
+    public void mouseClicked(MouseEvent e) {\r
+        if (e.getSource() == jButtonCancel) {\r
+            this.setVisible(false);\r
+            this.dispose();\r
+        } else if (e.getSource() == jButtonFinish) {\r
+            List<String> packageList = new ArrayList<String>();\r
+            List<String> platformList = new ArrayList<String>();\r
+            //\r
+            // Add some logic process here\r
+            // Guid Check, File Check etc.\r
+            //\r
+            Set<File> allNewPath = new LinkedHashSet<File>();\r
+            Map<PackageIdentification, File> packageMap = new LinkedHashMap<PackageIdentification, File>();\r
+            for (int i = 0; i < packageModel.getRowCount(); i++) {\r
+                File toFile = new File(Workspace.getCurrentWorkspace() + File.separatorChar\r
+                                       + packageModel.getValueAt(i, 3));\r
+                if (!isPackagePathValid(toFile)) {\r
+                    Log.err(packageVector.get(i) + " path already has package now. ");\r
+                    return;\r
+                }\r
+                if (allNewPath.contains(toFile)) {\r
+                    Log.err("Path " + packageModel.getValueAt(i, 3) + " is specified by twice. ");\r
+                    return;\r
+                }\r
+                allNewPath.add(toFile);\r
+                File spdFile = new File((String) packageModel.getValueAt(i, 3) + File.separatorChar\r
+                                        + packageVector.get(i).getSpdFile().getName());\r
+                packageList.add(spdFile.getPath());\r
+                packageMap.put(packageVector.get(i), toFile);\r
+            }\r
+\r
+            Map<PlatformIdentification, File> platformMap = new LinkedHashMap<PlatformIdentification, File>();\r
+            for (int i = 0; i < platformModel.getRowCount(); i++) {\r
+                File toFile = new File(Workspace.getCurrentWorkspace() + File.separatorChar\r
+                                       + platformModel.getValueAt(i, 3));\r
+                if (!isPlatformPathValid(toFile)) {\r
+                    Log.err(platformVector.get(i) + " path already has platform now. ");\r
+                    return;\r
+                }\r
+                File fpdFile = new File((String) platformModel.getValueAt(i, 3) + File.separatorChar\r
+                                        + platformVector.get(i).getFpdFile().getName());\r
+                platformList.add(fpdFile.getPath());\r
+                platformMap.put(platformVector.get(i), toFile);\r
+            }\r
+\r
+            //\r
+            //\r
+            //\r
+            Far far = stepOne.getFar();\r
+            try {\r
+                far.InstallFar(platformMap, packageMap);\r
+                //\r
+                // Add to database\r
+                //\r
+                WorkspaceTools wt = new WorkspaceTools();\r
+                wt.addFarToDb(packageList, platformList, far.mainfest.getHeader());\r
+            } catch (Exception ex) {\r
+                ex.printStackTrace();\r
+                Log.err("Install error. ");\r
+                return;\r
+            }\r
+\r
+            this.setVisible(false);\r
+            this.stepOne.returnType = DataType.RETURN_TYPE_OK;\r
+            this.dispose();\r
+        } else if (e.getSource() == jButtonPrevious) {\r
+            this.setVisible(false);\r
+            stepOne.setVisible(true);\r
+        }\r
+    }\r
+\r
+    private boolean isPackagePathValid(File spdFile) {\r
+        WorkspaceTools wt = new WorkspaceTools();\r
+        List<PackageIdentification> allPackages = wt.getAllPackages();\r
+        Iterator<PackageIdentification> iter = allPackages.iterator();\r
+\r
+        while (iter.hasNext()) {\r
+            PackageIdentification item = iter.next();\r
+            if (isPathContainMutual(spdFile, item.getSpdFile())) {\r
+                return false;\r
+            }\r
+        }\r
+        return true;\r
+    }\r
+\r
+    private boolean isPlatformPathValid(File fpdFile) {\r
+        WorkspaceTools wt = new WorkspaceTools();\r
+        List<PlatformIdentification> allPlatforms = wt.getAllPlatforms();\r
+        Iterator<PlatformIdentification> iter = allPlatforms.iterator();\r
+\r
+        while (iter.hasNext()) {\r
+            PlatformIdentification item = iter.next();\r
+            if (isPathContainMutual(fpdFile, item.getFpdFile())) {\r
+                return false;\r
+            }\r
+        }\r
+        return true;\r
+    }\r
+\r
+    private boolean isPathContainMutual(File path1, File path2) {\r
+        if (path1.getPath().startsWith(path2.getParent())) {\r
+            return true;\r
+        }\r
+        if (path2.getPath().startsWith(path1.getPath())) {\r
+            return true;\r
+        }\r
+        return false;\r
+    }\r
+\r
+    public void mousePressed(MouseEvent e) {\r
+        // TODO Auto-generated method stub\r
+\r
+    }\r
+\r
+    public void mouseReleased(MouseEvent e) {\r
+        // TODO Auto-generated method stub\r
+\r
+    }\r
+\r
+    public void mouseEntered(MouseEvent e) {\r
+        // TODO Auto-generated method stub\r
+\r
+    }\r
+\r
+    public void mouseExited(MouseEvent e) {\r
+        // TODO Auto-generated method stub\r
+\r
+    }\r
+\r
+}\r
+\r
+class PartialEditableTableModel 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 true;\r
+        default:\r
+            return false;\r
+        }\r
+    }\r
+}\r
diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/far/updateui/UpdateStepOne.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/far/updateui/UpdateStepOne.java
new file mode 100644 (file)
index 0000000..755dbf3
--- /dev/null
@@ -0,0 +1,305 @@
+/** @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
+\r
+package org.tianocore.frameworkwizard.far.updateui;\r
+\r
+import java.awt.Dimension;\r
+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.Vector;\r
+\r
+import javax.swing.JFileChooser;\r
+import javax.swing.JPanel;\r
+import javax.swing.JTextArea;\r
+import javax.swing.JButton;\r
+import javax.swing.JLabel;\r
+import javax.swing.JTextField;\r
+\r
+import org.tianocore.frameworkwizard.common.DataType;\r
+import org.tianocore.frameworkwizard.common.IFileFilter;\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.common.ui.IFrame;\r
+import org.tianocore.frameworkwizard.far.Far;\r
+import org.tianocore.frameworkwizard.far.FarIdentification;\r
+import org.tianocore.frameworkwizard.workspace.Workspace;\r
+import org.tianocore.frameworkwizard.workspace.WorkspaceTools;\r
+\r
+import javax.swing.JScrollPane;\r
+import javax.swing.JList;\r
+\r
+public class UpdateStepOne extends IDialog implements MouseListener {\r
+\r
+    /**\r
+     * \r
+     */\r
+    private static final long serialVersionUID = 735554907464539931L;\r
+\r
+    private JPanel jContentPane = null;\r
+\r
+    private JTextArea jTextArea = null;\r
+\r
+    private JButton jButtonCancel = null;\r
+\r
+    private JButton jButtonNext = null;\r
+\r
+    private JLabel jLabel = null;\r
+\r
+    private JTextField jTextFieldFarFile = null;\r
+\r
+    private JButton jButtonBrowser = null;\r
+\r
+    private UpdateStepTwo stepTwo = null;\r
+\r
+    private Far far = null;\r
+\r
+    private Vector<FarIdentification> farVector = null;\r
+\r
+    private JLabel jLabel1 = null;\r
+\r
+    private JScrollPane jScrollPane = null;\r
+\r
+    private JList jListFarFromDb = null;\r
+\r
+    private File farFile = null;\r
+\r
+    public File getFarFile() {\r
+        return farFile;\r
+    }\r
+\r
+    /**\r
+     * This method initializes jTextArea       \r
+     *         \r
+     * @return javax.swing.JTextArea   \r
+     */\r
+    private JTextArea getJTextArea() {\r
+        if (jTextArea == null) {\r
+            jTextArea = new JTextArea();\r
+            jTextArea.setBounds(new java.awt.Rectangle(30, 7, 642, 50));\r
+            jTextArea.setText("Step 1: Choose framework archive (FAR) file. \n");\r
+            jTextArea.setEditable(false);\r
+        }\r
+        return jTextArea;\r
+    }\r
+\r
+    /**\r
+     * This method initializes jButtonCancel   \r
+     *         \r
+     * @return javax.swing.JButton     \r
+     */\r
+    private JButton getJButtonCancel() {\r
+        if (jButtonCancel == null) {\r
+            jButtonCancel = new JButton();\r
+            jButtonCancel.setBounds(new java.awt.Rectangle(570, 330, 90, 20));\r
+            jButtonCancel.setText("Cancel");\r
+            jButtonCancel.addMouseListener(this);\r
+        }\r
+        return jButtonCancel;\r
+    }\r
+\r
+    /**\r
+     * This method initializes jButtonNext     \r
+     *         \r
+     * @return javax.swing.JButton     \r
+     */\r
+    private JButton getJButtonNext() {\r
+        if (jButtonNext == null) {\r
+            jButtonNext = new JButton();\r
+            jButtonNext.setBounds(new java.awt.Rectangle(470, 330, 90, 20));\r
+            jButtonNext.setText("Next");\r
+            jButtonNext.addMouseListener(this);\r
+        }\r
+        return jButtonNext;\r
+    }\r
+\r
+    /**\r
+     * This method initializes jTextField      \r
+     *         \r
+     * @return javax.swing.JTextField  \r
+     */\r
+    private JTextField getJTextFieldFarFile() {\r
+        if (jTextFieldFarFile == null) {\r
+            jTextFieldFarFile = new JTextField();\r
+            jTextFieldFarFile.setBounds(new java.awt.Rectangle(130, 100, 400, 20));\r
+        }\r
+        return jTextFieldFarFile;\r
+    }\r
+\r
+    /**\r
+     * This method initializes jButton \r
+     *         \r
+     * @return javax.swing.JButton     \r
+     */\r
+    private JButton getJButtonBrowser() {\r
+        if (jButtonBrowser == null) {\r
+            jButtonBrowser = new JButton();\r
+            jButtonBrowser.setBounds(new java.awt.Rectangle(542, 100, 97, 20));\r
+            jButtonBrowser.setText("Browser...");\r
+            jButtonBrowser.addMouseListener(this);\r
+        }\r
+        return jButtonBrowser;\r
+    }\r
+\r
+    /**\r
+     * This method initializes jScrollPane     \r
+     *         \r
+     * @return javax.swing.JScrollPane \r
+     */\r
+    private JScrollPane getJScrollPane() {\r
+        if (jScrollPane == null) {\r
+            jScrollPane = new JScrollPane();\r
+            jScrollPane.setBounds(new java.awt.Rectangle(130, 164, 500, 160));\r
+            jScrollPane.setViewportView(getJListFarFromDb());\r
+        }\r
+        return jScrollPane;\r
+    }\r
+\r
+    /**\r
+     * This method initializes jListFarFromDb  \r
+     *         \r
+     * @return javax.swing.JList       \r
+     */\r
+    private JList getJListFarFromDb() {\r
+        if (jListFarFromDb == null) {\r
+            jListFarFromDb = new JList();\r
+            WorkspaceTools wt = new WorkspaceTools();\r
+            farVector = wt.getAllFars();\r
+            jListFarFromDb.setListData(farVector);\r
+        }\r
+        return jListFarFromDb;\r
+    }\r
+\r
+    /**\r
+     * This is the default constructor\r
+     */\r
+    public UpdateStepOne(IFrame iFrame, boolean modal) {\r
+        super(iFrame, modal);\r
+        initialize();\r
+    }\r
+\r
+    /**\r
+     * This method initializes this\r
+     * \r
+     * @return void\r
+     */\r
+    private void initialize() {\r
+        this.setSize(700, 400);\r
+        this.setContentPane(getJContentPane());\r
+        this.setTitle("Update Framework Archive(FAR) - Step 1: Choose FAR File");\r
+        Dimension d = Toolkit.getDefaultToolkit().getScreenSize();\r
+        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
+            jLabel1 = new JLabel();\r
+            jLabel1.setBounds(new java.awt.Rectangle(30, 138, 355, 18));\r
+            jLabel1.setText("Choose FAR from current framework database");\r
+            jLabel = new JLabel();\r
+            jLabel.setBounds(new java.awt.Rectangle(30, 80, 220, 20));\r
+            jLabel.setText("Choose FAR file: ");\r
+            jContentPane = new JPanel();\r
+            jContentPane.setLayout(null);\r
+            jContentPane.add(getJTextArea(), null);\r
+            jContentPane.add(getJButtonCancel(), null);\r
+            jContentPane.add(getJButtonNext(), null);\r
+            jContentPane.add(jLabel, null);\r
+            jContentPane.add(getJTextFieldFarFile(), null);\r
+            jContentPane.add(getJButtonBrowser(), null);\r
+            jContentPane.add(jLabel1, null);\r
+            jContentPane.add(getJScrollPane(), null);\r
+        }\r
+        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
+                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
+            int result = fc.showSaveDialog(new JPanel());\r
+            if (result == JFileChooser.APPROVE_OPTION) {\r
+                this.jTextFieldFarFile.setText(Tools.addPathExt(fc.getSelectedFile().getPath(),\r
+                                                                DataType.RETURN_TYPE_FAR_SURFACE_AREA));\r
+            }\r
+        }\r
+    }\r
+\r
+    public void mousePressed(MouseEvent e) {\r
+        // TODO Auto-generated method stub\r
+\r
+    }\r
+\r
+    public void mouseReleased(MouseEvent e) {\r
+        // TODO Auto-generated method stub\r
+\r
+    }\r
+\r
+    public void mouseEntered(MouseEvent e) {\r
+        // TODO Auto-generated method stub\r
+\r
+    }\r
+\r
+    public void mouseExited(MouseEvent e) {\r
+        // TODO Auto-generated method stub\r
+\r
+    }\r
+\r
+    public FarIdentification getSelecedDbFar() {\r
+        return (FarIdentification) jListFarFromDb.getSelectedValue();\r
+    }\r
+\r
+    public Far getFar() {\r
+        return far;\r
+    }\r
+}\r
diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/far/updateui/UpdateStepTwo.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/far/updateui/UpdateStepTwo.java
new file mode 100644 (file)
index 0000000..1dd4c48
--- /dev/null
@@ -0,0 +1,298 @@
+/** @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
+\r
+package org.tianocore.frameworkwizard.far.updateui;\r
+\r
+import java.awt.Dimension;\r
+import java.awt.Toolkit;\r
+import java.awt.event.MouseEvent;\r
+import java.awt.event.MouseListener;\r
+import java.util.Iterator;\r
+import java.util.List;\r
+\r
+import javax.swing.JPanel;\r
+import javax.swing.JTextArea;\r
+import javax.swing.JButton;\r
+import javax.swing.JScrollPane;\r
+import javax.swing.JLabel;\r
+import javax.swing.JTable;\r
+import javax.swing.ListSelectionModel;\r
+import javax.swing.table.DefaultTableModel;\r
+\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.Far;\r
+import org.tianocore.frameworkwizard.packaging.PackageIdentification;\r
+import org.tianocore.frameworkwizard.workspace.Workspace;\r
+import org.tianocore.frameworkwizard.workspace.WorkspaceTools;\r
+\r
+public class UpdateStepTwo extends IDialog implements MouseListener {\r
+\r
+    /**\r
+     * \r
+     */\r
+    private static final long serialVersionUID = -4400145363721213110L;\r
+\r
+    private JPanel jContentPane = null;\r
+\r
+    private JTextArea jTextArea = null;\r
+\r
+    private UpdateStepOne stepOne = null;\r
+\r
+    private JButton jButtonCancel = null;\r
+\r
+    private JButton jButtonFinish = null;\r
+\r
+    private JButton jButtonPrevious = null;\r
+\r
+    private JScrollPane jScrollPane = null;\r
+\r
+    private JLabel jLabel = null;\r
+\r
+    private JTable jTablePackage = null;\r
+\r
+    private PartialTableModel model = null;\r
+\r
+    public UpdateStepTwo(IDialog iDialog, boolean modal, UpdateStepOne stepOne) {\r
+        this(iDialog, modal);\r
+        this.stepOne = stepOne;\r
+    }\r
+\r
+    /**\r
+     * This method initializes jTextArea       \r
+     *         \r
+     * @return javax.swing.JTextArea   \r
+     */\r
+    private JTextArea getJTextArea() {\r
+        if (jTextArea == null) {\r
+            jTextArea = new JTextArea();\r
+            jTextArea.setBounds(new java.awt.Rectangle(30, 7, 642, 50));\r
+            jTextArea.setText("Step 2: Summary. \n");\r
+            jTextArea.setEditable(false);\r
+        }\r
+        return jTextArea;\r
+    }\r
+\r
+    /**\r
+     * This method initializes jButtonCancel   \r
+     *         \r
+     * @return javax.swing.JButton     \r
+     */\r
+    private JButton getJButtonCancel() {\r
+        if (jButtonCancel == null) {\r
+            jButtonCancel = new JButton();\r
+            jButtonCancel.setBounds(new java.awt.Rectangle(570, 330, 90, 20));\r
+            jButtonCancel.setText("Cancel");\r
+            jButtonCancel.addMouseListener(this);\r
+        }\r
+        return jButtonCancel;\r
+    }\r
+\r
+    /**\r
+     * This method initializes jButtonFinish   \r
+     *         \r
+     * @return javax.swing.JButton     \r
+     */\r
+    private JButton getJButtonFinish() {\r
+        if (jButtonFinish == null) {\r
+            jButtonFinish = new JButton();\r
+            jButtonFinish.setBounds(new java.awt.Rectangle(470, 330, 90, 20));\r
+            jButtonFinish.setText("Finish");\r
+            jButtonFinish.addMouseListener(this);\r
+        }\r
+        return jButtonFinish;\r
+    }\r
+\r
+    /**\r
+     * This method initializes jButtonPrevious \r
+     *         \r
+     * @return javax.swing.JButton     \r
+     */\r
+    private JButton getJButtonPrevious() {\r
+        if (jButtonPrevious == null) {\r
+            jButtonPrevious = new JButton();\r
+            jButtonPrevious.setBounds(new java.awt.Rectangle(370, 330, 90, 20));\r
+            jButtonPrevious.setText("Previous");\r
+            jButtonPrevious.addMouseListener(this);\r
+        }\r
+        return jButtonPrevious;\r
+    }\r
+\r
+    /**\r
+     * This method initializes jScrollPane     \r
+     *         \r
+     * @return javax.swing.JScrollPane \r
+     */\r
+    private JScrollPane getJScrollPane() {\r
+        if (jScrollPane == null) {\r
+            jScrollPane = new JScrollPane();\r
+            jScrollPane.setBounds(new java.awt.Rectangle(30, 98, 570, 170));\r
+            jScrollPane.setViewportView(getJTablePackage());\r
+        }\r
+        return jScrollPane;\r
+    }\r
+\r
+    /**\r
+     * This method initializes jTablePackage   \r
+     *         \r
+     * @return javax.swing.JTable      \r
+     */\r
+    private JTable getJTablePackage() {\r
+        if (jTablePackage == null) {\r
+            jTablePackage = new JTable();\r
+            model = new PartialTableModel();\r
+            jTablePackage = new JTable(model);\r
+            jTablePackage.setRowHeight(20);\r
+            jTablePackage.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS);\r
+            model.addColumn("Name");\r
+            model.addColumn("Version");\r
+            model.addColumn("Guid");\r
+            model.addColumn("Path");\r
+\r
+            jTablePackage.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);\r
+        }\r
+        return jTablePackage;\r
+    }\r
+\r
+    public void prepareTable() {\r
+        model.setRowCount(0);\r
+        try {\r
+            Far far = stepOne.getFar();\r
+            List<PackageIdentification> packagesInFar = far.mainfest.getPackageList();\r
+\r
+            WorkspaceTools wt = new WorkspaceTools();\r
+            List<PackageIdentification> packagesInDb = wt.getAllPackages();\r
+\r
+            List<PackageIdentification> result = 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
+    }\r
+\r
+    /**\r
+     * This is the default constructor\r
+     */\r
+    public UpdateStepTwo(IDialog iDialog, boolean modal) {\r
+        super(iDialog, modal);\r
+        initialize();\r
+    }\r
+\r
+    /**\r
+     * This method initializes this\r
+     * \r
+     * @return void\r
+     */\r
+    private void initialize() {\r
+        this.setSize(700, 400);\r
+        this.setContentPane(getJContentPane());\r
+        this.setTitle("Update Framework Archive(FAR) - Step 2: Summary");\r
+        Dimension d = Toolkit.getDefaultToolkit().getScreenSize();\r
+        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
+\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
+        }\r
+    }\r
+\r
+    public void mousePressed(MouseEvent e) {\r
+        // TODO Auto-generated method stub\r
+\r
+    }\r
+\r
+    public void mouseReleased(MouseEvent e) {\r
+        // TODO Auto-generated method stub\r
+\r
+    }\r
+\r
+    public void mouseEntered(MouseEvent e) {\r
+        // TODO Auto-generated method stub\r
+\r
+    }\r
+\r
+    public void mouseExited(MouseEvent e) {\r
+        // TODO Auto-generated method stub\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
index 711f9b91c0fc0a0304c1aa9845d380433e1daf20..23b6ff0290f53c4a48bcafd464f9ccbf31778cd9 100644 (file)
 \r
 package org.tianocore.frameworkwizard.packaging;\r
 \r
+import java.io.File;\r
+\r
+import org.tianocore.frameworkwizard.common.Tools;\r
 import org.tianocore.frameworkwizard.common.Identifications.Identification;\r
+import org.tianocore.frameworkwizard.workspace.Workspace;\r
 \r
 public class PackageIdentification extends Identification{\r
     \r
@@ -30,4 +34,13 @@ public class PackageIdentification extends Identification{
     public PackageIdentification(Identification id){\r
         super(id.getName(), id.getGuid(), id.getVersion(), id.getPath());\r
     }\r
+    \r
+    public File getSpdFile(){\r
+        File spdFile = new File(this.getPath());\r
+        return spdFile;\r
+    }\r
+    \r
+    public String toString() {\r
+      return getName() + " " + getVersion() + " [" + Tools.getRelativePath(getSpdFile().getPath(), Workspace.getCurrentWorkspace()) + "]";\r
+    }\r
 }\r
index 0604dae95461a4640fb5e9f177f1510b308c33ad..ced7c921521bdfc792f3e29e37b59eacb2f239b6 100644 (file)
 \r
 package org.tianocore.frameworkwizard.platform;\r
 \r
+\r
+import java.io.File;\r
+\r
+import org.tianocore.frameworkwizard.common.Tools;\r
 import org.tianocore.frameworkwizard.common.Identifications.Identification;\r
+import org.tianocore.frameworkwizard.workspace.Workspace;\r
 \r
 public class PlatformIdentification extends Identification{\r
     \r
+    \r
     public PlatformIdentification(String name, String guid, String version, String path){\r
         super(name, guid, version, path);\r
     }\r
@@ -26,4 +32,13 @@ public class PlatformIdentification extends Identification{
     public PlatformIdentification(Identification id){\r
         super(id.getName(), id.getGuid(), id.getVersion(), id.getPath());\r
     }\r
+    \r
+    public File getFpdFile(){\r
+      File fpdFile = new File(this.getPath());\r
+      return fpdFile;\r
+  }\r
+    \r
+    public String toString() {\r
+      return getName() + " " + getVersion() + " [" + Tools.getRelativePath(getFpdFile().getPath(), Workspace.getCurrentWorkspace()) + "]";\r
+    }\r
 }
\ No newline at end of file
index e4800816cb6264b9e8ab66d188addc5a4fc6c1c4..dda8844495e07b054947554a0aac52a34e713343 100644 (file)
  **/\r
 package org.tianocore.frameworkwizard.workspace;\r
 \r
+import java.io.File;\r
 import java.io.IOException;\r
+import java.util.List;\r
 import java.util.Vector;\r
 \r
+import org.apache.xmlbeans.XmlCursor;\r
 import org.apache.xmlbeans.XmlException;\r
 import org.tianocore.DbPathAndFilename;\r
-import org.tianocore.FrameworkDatabaseDocument;\r
+import org.tianocore.FrameworkDatabaseDocument.FrameworkDatabase;\r
 import org.tianocore.IndustryStdIncludesDocument.IndustryStdIncludes;\r
 import org.tianocore.ModuleSurfaceAreaDocument.ModuleSurfaceArea;\r
 import org.tianocore.MsaFilesDocument.MsaFiles;\r
@@ -35,6 +38,8 @@ import org.tianocore.frameworkwizard.common.SaveFile;
 import org.tianocore.frameworkwizard.common.Tools;\r
 import org.tianocore.frameworkwizard.common.Identifications.Identification;\r
 import org.tianocore.frameworkwizard.common.Identifications.OpenFile;\r
+import org.tianocore.frameworkwizard.far.FarHeader;\r
+import org.tianocore.frameworkwizard.far.FarIdentification;\r
 import org.tianocore.frameworkwizard.module.Identifications.ModuleIdentification;\r
 import org.tianocore.frameworkwizard.packaging.PackageIdentification;\r
 import org.tianocore.frameworkwizard.platform.PlatformIdentification;\r
@@ -43,7 +48,7 @@ public class WorkspaceTools {
     //\r
     // Define class members\r
     //\r
-    private FrameworkDatabaseDocument.FrameworkDatabase fdb = null;\r
+    private FrameworkDatabase fdb = null;\r
 \r
     private Vector<ModuleIdentification> vModuleList = new Vector<ModuleIdentification>();\r
 \r
@@ -56,20 +61,147 @@ public class WorkspaceTools {
      Open Framework Database file\r
      \r
      */\r
-    private void openFrameworkDb() {\r
+    private FrameworkDatabase openFrameworkDb() {\r
         String strFrameworkDbFilePath = Workspace.getCurrentWorkspace() + Workspace.getStrWorkspaceDatabaseFile();\r
         strFrameworkDbFilePath = Tools.convertPathToCurrentOsType(strFrameworkDbFilePath);\r
         try {\r
             fdb = OpenFile.openFrameworkDb(strFrameworkDbFilePath);\r
         } catch (XmlException e) {\r
             Log.err("Open Framework Database " + strFrameworkDbFilePath, e.getMessage());\r
-            return;\r
+            return null;\r
         } catch (Exception e) {\r
             Log.err("Open Framework Database " + strFrameworkDbFilePath, "Invalid file type");\r
-            return;\r
+            return null;\r
         }\r
+        return fdb;\r
     }\r
 \r
+    public void addFarToDb(List<String> packageList, List<String> platformList, FarHeader far) {\r
+      FrameworkDatabase fdb = openFrameworkDb();\r
+      \r
+      for (int i = 0; i < packageList.size(); i++) {\r
+        DbPathAndFilename item = DbPathAndFilename.Factory.newInstance();\r
+        item.setFarGuid(far.getGuidValue());\r
+        item.setStringValue(packageList.get(i));\r
+        fdb.getPackageList().getFilenameList().add(item);\r
+      }\r
+      \r
+      for (int i = 0; i < platformList.size(); i++) {\r
+        DbPathAndFilename item = DbPathAndFilename.Factory.newInstance();\r
+        item.setFarGuid(far.getGuidValue());\r
+        item.setStringValue(platformList.get(i));\r
+        fdb.getPlatformList().getFilenameList().add(item);\r
+      }\r
+      \r
+      DbPathAndFilename farItem = DbPathAndFilename.Factory.newInstance();\r
+      farItem.setFarGuid(far.getGuidValue());\r
+      farItem.setStringValue(far.getFarName());\r
+      fdb.getFarList().getFilenameList().add(farItem);\r
+      \r
+      String strFrameworkDbFilePath = Workspace.getCurrentWorkspace() + Workspace.getStrWorkspaceDatabaseFile();\r
+      strFrameworkDbFilePath = Tools.convertPathToCurrentOsType(strFrameworkDbFilePath);\r
+      \r
+      try {\r
+        SaveFile.saveDbFile(strFrameworkDbFilePath, fdb);\r
+      }\r
+      catch (Exception e) {\r
+        e.printStackTrace();\r
+      }\r
+    }\r
+    \r
+    \r
+    public void removeFarFromDb(FarIdentification far) {\r
+        FrameworkDatabase fdb = openFrameworkDb();\r
+        //\r
+        // Remove Packages\r
+        //\r
+        XmlCursor cursor = fdb.getPackageList().newCursor();\r
+        cursor.toFirstChild();\r
+        do {\r
+          DbPathAndFilename item = (DbPathAndFilename)cursor.getObject();\r
+          \r
+          if (item.getFarGuid() != null && item.getFarGuid().equalsIgnoreCase(far.getGuid())) {\r
+            cursor.removeXml();\r
+          }\r
+        } while (cursor.toNextSibling());\r
+        cursor.dispose();\r
+        \r
+        //\r
+        // Remove Platforms\r
+        //\r
+        cursor = fdb.getPlatformList().newCursor();\r
+        cursor.toFirstChild();\r
+        do {\r
+          DbPathAndFilename item = (DbPathAndFilename)cursor.getObject();\r
+          if (item.getFarGuid() != null && item.getFarGuid().equalsIgnoreCase(far.getGuid())) {\r
+            cursor.removeXml();\r
+          }\r
+        } while (cursor.toNextSibling());\r
+        \r
+        //\r
+        // Remove Far\r
+        //\r
+        cursor = fdb.getFarList().newCursor();\r
+        cursor.toFirstChild();\r
+        do {\r
+          DbPathAndFilename item = (DbPathAndFilename)cursor.getObject();\r
+          if (item.getFarGuid() != null && item.getFarGuid().equalsIgnoreCase(far.getGuid())) {\r
+            cursor.removeXml();\r
+          }\r
+        } while (cursor.toNextSibling());\r
+        cursor.dispose();\r
+        \r
+        String strFrameworkDbFilePath = Workspace.getCurrentWorkspace() + Workspace.getStrWorkspaceDatabaseFile();\r
+        strFrameworkDbFilePath = Tools.convertPathToCurrentOsType(strFrameworkDbFilePath);\r
+        try {\r
+          SaveFile.saveDbFile(strFrameworkDbFilePath, fdb);\r
+        }\r
+        catch (Exception e) {\r
+          e.printStackTrace();\r
+        }\r
+    }\r
+    \r
+    public String getPackageFarGuid(PackageIdentification packageId) {\r
+      openFrameworkDb();\r
+      \r
+      for (int index = 0; index < fdb.getPackageList().getFilenameList().size(); index++) {\r
+        DbPathAndFilename item = fdb.getPackageList().getFilenameArray(index);\r
+        String path = Workspace.getCurrentWorkspace() + DataType.FILE_SEPARATOR\r
+                      + item.getStringValue();\r
+        File tempFile = new File(path);\r
+        if (tempFile.getPath().equalsIgnoreCase(packageId.getSpdFile().getPath())) {\r
+          return fdb.getPackageList().getFilenameArray(index).getFarGuid();\r
+        }\r
+      }\r
+      \r
+      return null;\r
+    }\r
+    \r
+    public String getPlatformFarGuid(PlatformIdentification platformId) {\r
+      openFrameworkDb();\r
+      \r
+      for (int index = 0; index < fdb.getPlatformList().getFilenameList().size(); index++) {\r
+        DbPathAndFilename item = fdb.getPlatformList().getFilenameArray(index);\r
+        String path = Workspace.getCurrentWorkspace() + DataType.FILE_SEPARATOR\r
+                      + item.getStringValue();\r
+        File tempFile = new File(path);\r
+        if (tempFile.getPath().equalsIgnoreCase(platformId.getFpdFile().getPath())) {\r
+          return fdb.getPlatformList().getFilenameArray(index).getFarGuid();\r
+        }\r
+      }\r
+      \r
+      return null;\r
+    }\r
+    \r
+    public String getModuleFarGuid(ModuleIdentification moduleId) {\r
+      PackageIdentification packageId = getPackageIdByModuleId(moduleId);\r
+      if (packageId != null) {\r
+          return getPackageFarGuid(packageId);\r
+      }\r
+      else {\r
+        return null;\r
+      }\r
+    }\r
     /**\r
      Get all modules' paths from one package\r
      \r
@@ -159,7 +291,79 @@ public class WorkspaceTools {
         Tools.sortPackages(vPackageList, DataType.SORT_TYPE_ASCENDING);\r
         return vPackageList;\r
     }\r
+\r
+    public Vector<FarIdentification> getAllFars() {\r
+      openFrameworkDb();\r
+      Vector<FarIdentification> v = new Vector<FarIdentification>();\r
+      for (int index = 0; index < fdb.getFarList().getFilenameList().size(); index++) {\r
+        DbPathAndFilename item = fdb.getFarList().getFilenameList().get(index);\r
+        FarIdentification far = new FarIdentification(item.getFarGuid(), item.getMd5Sum(), item.getStringValue());\r
+        v.addElement(far);\r
+      }\r
+      return v;\r
+    }\r
     \r
+    public Vector<PackageIdentification> getPackagesByFar(FarIdentification far) {\r
+      Identification id = null;\r
+      openFrameworkDb();\r
+      Vector<PackageIdentification> v = new Vector<PackageIdentification>();\r
+      \r
+      for (int index = 0; index < fdb.getPackageList().getFilenameList().size(); index++) {\r
+        DbPathAndFilename item = fdb.getPackageList().getFilenameArray(index);\r
+        String path = Workspace.getCurrentWorkspace() + DataType.FILE_SEPARATOR\r
+                      + item.getStringValue();\r
+        path = Tools.convertPathToCurrentOsType(path);\r
+        \r
+        if (item.getFarGuid() != null && item.getFarGuid().equalsIgnoreCase(far.getGuid())) {\r
+        \r
+          try {\r
+            id = getId(path, OpenFile.openSpdFile(path));\r
+            v.addElement(new PackageIdentification(id));\r
+          } catch (IOException e) {\r
+            Log.err("Open Package Surface Area " + path, e.getMessage());\r
+            e.printStackTrace();\r
+          } catch (XmlException e) {\r
+            Log.err("Open Package Surface Area " + path, e.getMessage());\r
+            e.printStackTrace();\r
+          } catch (Exception e) {\r
+            Log.err("Open Package Surface Area " + path, "Invalid file type");\r
+            e.printStackTrace();\r
+          }\r
+        }\r
+      }\r
+      return v;\r
+    }\r
+    \r
+    public Vector<PlatformIdentification> getPlatformsByFar(FarIdentification far) {\r
+      Identification id = null;\r
+      openFrameworkDb();\r
+      Vector<PlatformIdentification> v = new Vector<PlatformIdentification>();\r
+      \r
+      for (int index = 0; index < fdb.getPlatformList().getFilenameList().size(); index++) {\r
+        DbPathAndFilename item = fdb.getPlatformList().getFilenameArray(index);\r
+        String path = Workspace.getCurrentWorkspace() + DataType.FILE_SEPARATOR\r
+                      + item.getStringValue();\r
+        path = Tools.convertPathToCurrentOsType(path);\r
+        \r
+        if (item.getFarGuid() != null && item.getFarGuid().equalsIgnoreCase(far.getGuid())) {\r
+          try {\r
+            id = getId(path, OpenFile.openFpdFile(path));\r
+            v.addElement(new PlatformIdentification(id));\r
+          } catch (IOException e) {\r
+            Log.err("Open Platform Surface Area " + path, e.getMessage());\r
+            e.printStackTrace();\r
+          } catch (XmlException e) {\r
+            Log.err("Open Platform Surface Area " + path, e.getMessage());\r
+            e.printStackTrace();\r
+          } catch (Exception e) {\r
+            Log.err("Open Platform Surface Area " + path, "Invalid file type");\r
+            e.printStackTrace();\r
+          }\r
+        }\r
+    }\r
+      return v;\r
+    }\r
+\r
     /**\r
      Get all module basic information from a package\r
     \r