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