mirror of https://github.com/acidanthera/audk.git
1. Update release note to use jdk1.5.0_06 to take place of jdk1.5.0_04
2. Support "Update Far" function 3. Fix bugs in Far operations git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@985 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
parent
06a9243705
commit
ef6e2efe66
|
@ -64,7 +64,7 @@ Assembler Tool Chain
|
|||
GNU binutils 2.16.1 or later
|
||||
|
||||
Java Development Kit ( Java 5.0 or later)
|
||||
Sun* jdk-1.5.0_04 or later (http://java.sun.com)
|
||||
Sun* jdk-1.5.0_06 or later (http://java.sun.com)
|
||||
or
|
||||
Bea Systems* jrockit-25.2.0-jdk1.5.0_03 or later (http://www.bea.com)
|
||||
|
||||
|
|
|
@ -1637,7 +1637,7 @@ public class FrameworkWizardUI extends IFrame implements MouseListener, TreeSele
|
|||
jMenuItemProjectUpdateFar.setMnemonic('U');
|
||||
jMenuItemProjectUpdateFar.setEnabled(true);
|
||||
jMenuItemProjectUpdateFar.addActionListener(this);
|
||||
jMenuItemProjectUpdateFar.setVisible(false);
|
||||
jMenuItemProjectUpdateFar.setVisible(true);
|
||||
}
|
||||
return jMenuItemProjectUpdateFar;
|
||||
}
|
||||
|
|
|
@ -59,8 +59,8 @@ public class DistributeRule {
|
|||
AggregationOperation.union(farPkgList,
|
||||
dbPkgList));
|
||||
|
||||
return resultList;
|
||||
|
||||
return resultList;
|
||||
|
||||
}
|
||||
|
||||
// public void installPackgCheck (PackageIdentification pkgId, String pkgPath){
|
||||
|
@ -86,5 +86,4 @@ public class DistributeRule {
|
|||
}
|
||||
return set;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -62,10 +62,9 @@ public class Far {
|
|||
jf = farFile;
|
||||
this.mainfest = new Mainfest(getMainfestFile());
|
||||
}
|
||||
|
||||
public void creatFar (List<PackageIdentification> pkgList,
|
||||
List<PlatformIdentification> plfList, Set<String> fileFilter,
|
||||
FarHeader fHeader) throws Exception{
|
||||
|
||||
public void creatFar(List<PackageIdentification> pkgList, List<PlatformIdentification> plfList,
|
||||
Set<String> fileFilter, FarHeader fHeader) throws Exception {
|
||||
jos = new JarOutputStream(new FileOutputStream(jarFile));
|
||||
|
||||
//
|
||||
|
@ -94,23 +93,28 @@ public class Far {
|
|||
}
|
||||
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();
|
||||
|
||||
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{
|
||||
|
||||
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()) {
|
||||
|
@ -149,39 +153,40 @@ public class Far {
|
|||
public boolean hibernateToFile() {
|
||||
return true;
|
||||
}
|
||||
// public static void main(String[] args){
|
||||
// try {
|
||||
// JarFile jarFile = new JarFile(new File("C:\\cvswork\\newEdk\\jar.jar.far"));
|
||||
// JarEntry je= jarFile.getJarEntry("MdePkg/MdePkg.spd");
|
||||
// InputStream is = jarFile.getInputStream(je);
|
||||
// byte[] buffer = new byte[1];
|
||||
// File tempFile = new File("C:\\cvswork\\newEdk\\tempFile");
|
||||
// File tfile2 = new File("C:\\cvswork\\newEdk\\tempFile1");
|
||||
// FileOutputStream fos1 = new FileOutputStream(tfile2);
|
||||
// FileOutputStream fos = new FileOutputStream(tempFile);
|
||||
// int size = is.read(buffer);
|
||||
// int totoalSize = size;
|
||||
// while ( size >= 0) {
|
||||
// fos.write(buffer);
|
||||
// size = is.read(buffer);
|
||||
// totoalSize = totoalSize + size;
|
||||
// }
|
||||
//
|
||||
//
|
||||
//// is = jarFile.getInputStream(je);
|
||||
//// is.read(totalbuffer);
|
||||
//// fos.write(totalbuffer);
|
||||
// fos.close();
|
||||
// byte[] totalbuffer = new byte[(int)tempFile.length()];
|
||||
// FileInputStream fis = new FileInputStream(tempFile);
|
||||
// fis.read(totalbuffer);
|
||||
// fos1.write(totalbuffer);
|
||||
// fos1.close();
|
||||
// }catch(Exception e){
|
||||
//
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
// public static void main(String[] args){
|
||||
// try {
|
||||
// JarFile jarFile = new JarFile(new File("C:\\cvswork\\newEdk\\jar.jar.far"));
|
||||
// JarEntry je= jarFile.getJarEntry("MdePkg/MdePkg.spd");
|
||||
// InputStream is = jarFile.getInputStream(je);
|
||||
// byte[] buffer = new byte[1];
|
||||
// File tempFile = new File("C:\\cvswork\\newEdk\\tempFile");
|
||||
// File tfile2 = new File("C:\\cvswork\\newEdk\\tempFile1");
|
||||
// FileOutputStream fos1 = new FileOutputStream(tfile2);
|
||||
// FileOutputStream fos = new FileOutputStream(tempFile);
|
||||
// int size = is.read(buffer);
|
||||
// int totoalSize = size;
|
||||
// while ( size >= 0) {
|
||||
// fos.write(buffer);
|
||||
// size = is.read(buffer);
|
||||
// totoalSize = totoalSize + size;
|
||||
// }
|
||||
//
|
||||
//
|
||||
//// is = jarFile.getInputStream(je);
|
||||
//// is.read(totalbuffer);
|
||||
//// fos.write(totalbuffer);
|
||||
// fos.close();
|
||||
// byte[] totalbuffer = new byte[(int)tempFile.length()];
|
||||
// FileInputStream fis = new FileInputStream(tempFile);
|
||||
// fis.read(totalbuffer);
|
||||
// fos1.write(totalbuffer);
|
||||
// fos1.close();
|
||||
// }catch(Exception e){
|
||||
//
|
||||
// }
|
||||
// }
|
||||
|
||||
public void extract(List<FarFileItem> allFile, String dir) throws Exception {
|
||||
|
||||
Iterator filesItem = allFile.iterator();
|
||||
|
@ -191,7 +196,7 @@ public class Far {
|
|||
dir += File.separatorChar;
|
||||
while (filesItem.hasNext()) {
|
||||
try {
|
||||
ffItem = (FarFileItem)filesItem.next();
|
||||
ffItem = (FarFileItem) filesItem.next();
|
||||
je = jf.getJarEntry(Tools.convertPathToUnixType(ffItem.getDefaultPath()));
|
||||
InputStream entryStream = jf.getInputStream(je);
|
||||
File file = new File(dir + ffItem.getRelativeFilename());
|
||||
|
@ -202,24 +207,23 @@ public class Far {
|
|||
// exists).
|
||||
//
|
||||
FileOutputStream outputStream = new FileOutputStream(file);
|
||||
|
||||
|
||||
try {
|
||||
//
|
||||
// Read the entry data and write it to the output
|
||||
// file.
|
||||
//
|
||||
byte[] buffer = new byte[1];
|
||||
byte[] buffer = new byte[1];
|
||||
File tempFile = new File("tempFile");
|
||||
FileOutputStream fos = new FileOutputStream(tempFile);
|
||||
int size = entryStream.read(buffer);
|
||||
while ( size >= 0) {
|
||||
while (size >= 0) {
|
||||
fos.write(buffer);
|
||||
size = entryStream.read(buffer);
|
||||
}
|
||||
|
||||
|
||||
fos.close();
|
||||
byte[] totalBuffer = new byte[(int)tempFile.length()];
|
||||
byte[] totalBuffer = new byte[(int) tempFile.length()];
|
||||
FileInputStream fis = new FileInputStream(tempFile);
|
||||
fis.read(totalBuffer);
|
||||
outputStream.write(totalBuffer);
|
||||
|
@ -235,12 +239,11 @@ public class Far {
|
|||
} finally {
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void addFileToFar (File file, JarOutputStream farOuputStream, String workDir){
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void addFileToFar(File file, JarOutputStream farOuputStream, String workDir) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -254,6 +257,9 @@ public class Far {
|
|||
List<PackageIdentification> result = new ArrayList<PackageIdentification>();
|
||||
|
||||
entry = this.mainfest.getPackgeSpd(pkgId);
|
||||
if (entry == null) {
|
||||
return result;
|
||||
}
|
||||
if (entry[0] != null) {
|
||||
try {
|
||||
JarEntry je;
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
**/
|
||||
package org.tianocore.frameworkwizard.far;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
|
||||
import org.tianocore.frameworkwizard.packaging.PackageIdentification;
|
||||
|
@ -84,8 +83,8 @@ public class FarPackage {
|
|||
}
|
||||
|
||||
public boolean isIdentityPkg(PackageIdentification pkgId) {
|
||||
File file = new File(farFile.getRelativeFilename());
|
||||
if (pkgId.getName() == file.getName() && pkgId.getGuid() == guidValue && pkgId.getVersion() == version) {
|
||||
//File file = new File(farFile.getRelativeFilename());
|
||||
if (pkgId.getGuid().equalsIgnoreCase(guidValue) && pkgId.getVersion().equalsIgnoreCase(version)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
|
@ -57,6 +57,7 @@ public class Mainfest implements ManifestInterface {
|
|||
// / Mainfest file element name
|
||||
// /
|
||||
final static String mfFileName = "FarMainfest.MF";
|
||||
|
||||
//
|
||||
// Header
|
||||
//
|
||||
|
@ -131,9 +132,9 @@ public class Mainfest implements ManifestInterface {
|
|||
File mfFile = null;
|
||||
|
||||
public FarHeader getHeader() {
|
||||
return fhInfo;
|
||||
return fhInfo;
|
||||
}
|
||||
|
||||
|
||||
public Mainfest() throws Exception {
|
||||
DocumentBuilderFactory domfac = DocumentBuilderFactory.newInstance();
|
||||
DocumentBuilder dombuilder = domfac.newDocumentBuilder();
|
||||
|
@ -163,8 +164,8 @@ public class Mainfest implements ManifestInterface {
|
|||
this.fhInfo = fHeader;
|
||||
}
|
||||
|
||||
public void createManifest(List<PackageIdentification> pkgList,
|
||||
List<PlatformIdentification> plfList, Set<String> fileFilter) throws Exception {
|
||||
public void createManifest(List<PackageIdentification> pkgList, List<PlatformIdentification> plfList,
|
||||
Set<String> fileFilter) throws Exception {
|
||||
|
||||
//
|
||||
// Add Package and it's contents to FarPackageList.
|
||||
|
@ -202,7 +203,7 @@ public class Mainfest implements ManifestInterface {
|
|||
|
||||
public void addPkgToPkgList(PackageIdentification packageId, Set<String> fileFilter) throws Exception {
|
||||
files.add(packageId.getSpdFile());
|
||||
|
||||
|
||||
FarPackage farPackage = new FarPackage();
|
||||
//
|
||||
// Add SPD file to FarPackage
|
||||
|
@ -211,17 +212,17 @@ public class Mainfest implements ManifestInterface {
|
|||
|
||||
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.
|
||||
|
@ -245,7 +246,7 @@ public class Mainfest implements ManifestInterface {
|
|||
// Remove current package's SPD file
|
||||
//
|
||||
fileSet.remove(packageId.getSpdFile());
|
||||
|
||||
|
||||
files.addAll(fileSet);
|
||||
|
||||
Iterator<File> iter = fileSet.iterator();
|
||||
|
@ -256,26 +257,25 @@ public class Mainfest implements ManifestInterface {
|
|||
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);
|
||||
|
||||
// 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) {
|
||||
private void recursiveDirectory(Set<File> files, Set<File> fpds, File dir, Set<String> fileFilter) {
|
||||
if (isFilter(dir, fileFilter)) {
|
||||
return;
|
||||
}
|
||||
|
@ -285,11 +285,11 @@ public class Mainfest implements ManifestInterface {
|
|||
if (isFilter(allFilesInDir[i], fileFilter)) {
|
||||
continue;
|
||||
}
|
||||
// if (allFilesInDir[i].getPath().toLowerCase().endsWith(".fpd")) {
|
||||
// fpds.add(allFilesInDir[i]);
|
||||
// } else {
|
||||
files.add(allFilesInDir[i]);
|
||||
// }
|
||||
// if (allFilesInDir[i].getPath().toLowerCase().endsWith(".fpd")) {
|
||||
// fpds.add(allFilesInDir[i]);
|
||||
// } else {
|
||||
files.add(allFilesInDir[i]);
|
||||
// }
|
||||
} else {
|
||||
recursiveDirectory(files, fpds, allFilesInDir[i], fileFilter);
|
||||
}
|
||||
|
@ -298,7 +298,7 @@ public class Mainfest implements ManifestInterface {
|
|||
|
||||
public void addPlatformIdToFarPlatformItemList(PlatformIdentification platformId) throws Exception {
|
||||
files.add(platformId.getFpdFile());
|
||||
|
||||
|
||||
FarPlatformItem fpfItem = new FarPlatformItem();
|
||||
FarFileItem ffItem;
|
||||
String fpfPath = platformId.getPath();
|
||||
|
@ -306,7 +306,8 @@ public class Mainfest implements ManifestInterface {
|
|||
//
|
||||
// Add farFileName
|
||||
//
|
||||
ffItem = new FarFileItem(Tools.getRelativePath(fpfFile.getPath(),Workspace.getCurrentWorkspace()), FarMd5.md5(fpfFile));
|
||||
ffItem = new FarFileItem(Tools.getRelativePath(fpfFile.getPath(), Workspace.getCurrentWorkspace()),
|
||||
FarMd5.md5(fpfFile));
|
||||
fpfItem.setFarFile(ffItem);
|
||||
|
||||
//
|
||||
|
@ -343,16 +344,18 @@ public class Mainfest implements ManifestInterface {
|
|||
// 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()));
|
||||
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;
|
||||
|
@ -361,8 +364,7 @@ public class Mainfest implements ManifestInterface {
|
|||
/**
|
||||
*
|
||||
*/
|
||||
public List<PlatformIdentification> getPlatformList() throws Exception,
|
||||
IOException, XmlException {
|
||||
public List<PlatformIdentification> getPlatformList() throws Exception, IOException, XmlException {
|
||||
//
|
||||
// PlatformIdentification set.
|
||||
//
|
||||
|
@ -370,21 +372,21 @@ public class Mainfest implements ManifestInterface {
|
|||
Iterator plfItem = this.fPlfList.iterator();
|
||||
while (plfItem.hasNext()) {
|
||||
FarPlatformItem fpfItem = (FarPlatformItem) plfItem.next();
|
||||
File file = new File(Workspace.getCurrentWorkspace()
|
||||
+ File.separatorChar
|
||||
+ fpfItem.getFarFile().getRelativeFilename());
|
||||
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()));
|
||||
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;
|
||||
|
@ -393,7 +395,7 @@ public class Mainfest implements ManifestInterface {
|
|||
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)) {
|
||||
|
@ -401,12 +403,12 @@ public class Mainfest implements ManifestInterface {
|
|||
farFileItem.setDefaultPath(farFileItem.getRelativeFilename());
|
||||
farFileItem.setRelativeFilename(Tools.getFileNameOnly(farFileItem.getRelativeFilename()));
|
||||
result.add(farFileItem);
|
||||
break ;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
public List<FarFileItem> getPackageContents(PackageIdentification packageId) {
|
||||
List<FarFileItem> farFileList = new ArrayList<FarFileItem>();
|
||||
Iterator pkgItem = this.fPkgList.iterator();
|
||||
|
@ -424,23 +426,22 @@ public class Mainfest implements ManifestInterface {
|
|||
//
|
||||
// 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());
|
||||
// }
|
||||
|
||||
// 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();
|
||||
while (ffIter.hasNext()) {
|
||||
FarFileItem ffItem = ffIter.next();
|
||||
ffItem.setDefaultPath(pkg.getDefaultPath() + File.separatorChar + ffItem.getRelativeFilename());
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return farFileList;
|
||||
}
|
||||
|
||||
|
@ -449,20 +450,20 @@ public class Mainfest implements ManifestInterface {
|
|||
* @param pkgId
|
||||
* @return String: return string represent jar file entry;
|
||||
*/
|
||||
public String[] getPackgeSpd(PackageIdentification pkgId){
|
||||
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() ;
|
||||
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
|
||||
|
@ -482,18 +483,16 @@ public class Mainfest implements ManifestInterface {
|
|||
//
|
||||
// Set farFileItem relativeFileName = absolutePath + file Name.
|
||||
//
|
||||
farFileList.add(new FarFileItem(pkg.getDefaultPath()
|
||||
+ File.separatorChar + ffItem.getRelativeFilename(), ffItem
|
||||
.getMd5Value()));
|
||||
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()));
|
||||
farFileList.add(new FarFileItem(pkg.getDefaultPath() + File.separator + ffItem.getRelativeFilename(),
|
||||
ffItem.getMd5Value()));
|
||||
}
|
||||
//
|
||||
// Add all farfiles in <FarPlatformList> to list.
|
||||
|
@ -502,9 +501,8 @@ public class Mainfest implements ManifestInterface {
|
|||
Iterator plfItem = plfList.iterator();
|
||||
while (plfItem.hasNext()) {
|
||||
ffItem = ((FarPlatformItem) plfItem.next()).getFarFile();
|
||||
farFileList.add(new FarFileItem(pkg.getDefaultPath()
|
||||
+ File.separator + ffItem.getRelativeFilename(), ffItem
|
||||
.getMd5Value()));
|
||||
farFileList.add(new FarFileItem(pkg.getDefaultPath() + File.separator + ffItem.getRelativeFilename(),
|
||||
ffItem.getMd5Value()));
|
||||
}
|
||||
}
|
||||
return farFileList;
|
||||
|
@ -520,29 +518,29 @@ public class Mainfest implements ManifestInterface {
|
|||
}
|
||||
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 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.
|
||||
|
@ -556,8 +554,7 @@ public class Mainfest implements ManifestInterface {
|
|||
//
|
||||
// Add far files in <FarPlatformList> to list
|
||||
//
|
||||
NodeList elementList = this.mainfestDoc
|
||||
.getElementsByTagName(farPlatformList);
|
||||
NodeList elementList = this.mainfestDoc.getElementsByTagName(farPlatformList);
|
||||
for (int i = 0; i < elementList.getLength(); i++) {
|
||||
//
|
||||
// Get <farPlatform> node list.
|
||||
|
@ -575,15 +572,13 @@ public class Mainfest implements ManifestInterface {
|
|||
//
|
||||
// Get child node value and set to platformIdentification.
|
||||
//
|
||||
if (tempNode.getNodeName().equalsIgnoreCase(
|
||||
farPackage_FarfileName)) {
|
||||
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());
|
||||
FarFileItem farFile = new FarFileItem(tempNode.getTextContent(),
|
||||
farAttr.getNamedItem(farFileName_Md5sum).getTextContent());
|
||||
ffiList.add(farFile);
|
||||
}
|
||||
}
|
||||
|
@ -596,8 +591,7 @@ public class Mainfest implements ManifestInterface {
|
|||
//
|
||||
// create mainfest root node
|
||||
//
|
||||
Element rootNode = this.mainfestDoc
|
||||
.createElement("FrameworkArchiveManifest");
|
||||
Element rootNode = this.mainfestDoc.createElement("FrameworkArchiveManifest");
|
||||
this.mainfestDoc.appendChild(rootNode);
|
||||
|
||||
//
|
||||
|
@ -675,8 +669,7 @@ public class Mainfest implements ManifestInterface {
|
|||
// Write the DOM document to the file
|
||||
//
|
||||
Transformer xformer = TransformerFactory.newInstance().newTransformer();
|
||||
xformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount",
|
||||
"2");
|
||||
xformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2");
|
||||
xformer.setOutputProperty(OutputKeys.INDENT, "yes");
|
||||
|
||||
//
|
||||
|
@ -687,8 +680,7 @@ public class Mainfest implements ManifestInterface {
|
|||
// Prepare the output file, get the Mainifest file name from <FarHeader>
|
||||
// /<FarName>.
|
||||
//
|
||||
this.mfFile = new File(Workspace.getCurrentWorkspace()
|
||||
+ File.separatorChar + mfFileName);
|
||||
this.mfFile = new File(Workspace.getCurrentWorkspace() + File.separatorChar + mfFileName);
|
||||
//
|
||||
// generate all directory path
|
||||
//
|
||||
|
@ -697,8 +689,7 @@ public class Mainfest implements ManifestInterface {
|
|||
}
|
||||
|
||||
public void pkgToFarPkgNode(Element parentNode, FarPackage pkgItem) {
|
||||
Element pkgNode = this.mainfestDoc
|
||||
.createElement(farPackageList_FarPackage);
|
||||
Element pkgNode = this.mainfestDoc.createElement(farPackageList_FarPackage);
|
||||
//
|
||||
// Add <FarFileName>
|
||||
//
|
||||
|
@ -714,8 +705,7 @@ public class Mainfest implements ManifestInterface {
|
|||
//
|
||||
// Add <DefaultPath>
|
||||
//
|
||||
setStrItemToNode(pkgNode, pkgItem.getDefaultPath(),
|
||||
farPackage_DefaultPath);
|
||||
setStrItemToNode(pkgNode, pkgItem.getDefaultPath(), farPackage_DefaultPath);
|
||||
|
||||
//
|
||||
// Add <Contents>
|
||||
|
@ -730,8 +720,7 @@ public class Mainfest implements ManifestInterface {
|
|||
}
|
||||
|
||||
public void PlfToPlatformNode(Element parentNode, FarPlatformItem fplItem) {
|
||||
Element fplNode = this.mainfestDoc
|
||||
.createElement(farPlatformList_FarPlatform);
|
||||
Element fplNode = this.mainfestDoc.createElement(farPlatformList_FarPlatform);
|
||||
//
|
||||
// Add <FarFileName>
|
||||
//
|
||||
|
@ -752,17 +741,15 @@ public class Mainfest implements ManifestInterface {
|
|||
}
|
||||
|
||||
public void ffiToFfNode(Element parentNode, FarFileItem ffi) {
|
||||
Element farFileName = this.mainfestDoc
|
||||
.createElement(farPackage_FarfileName);
|
||||
Element farFileName = this.mainfestDoc.createElement(farPackage_FarfileName);
|
||||
farFileName.setTextContent(ffi.getRelativeFilename());
|
||||
System.out.println(farFileName.getTextContent());
|
||||
System.out.println(ffi.getRelativeFilename());
|
||||
System.out.println(ffi.getRelativeFilename());
|
||||
farFileName.setAttribute(farFileName_Md5sum, ffi.getMd5Value());
|
||||
parentNode.appendChild(farFileName);
|
||||
}
|
||||
|
||||
public void setStrItemToNode(Element parentNode, String strValue,
|
||||
String strName) {
|
||||
public void setStrItemToNode(Element parentNode, String strValue, String strName) {
|
||||
Element node = this.mainfestDoc.createElement(strName);
|
||||
node.setTextContent(strValue);
|
||||
parentNode.appendChild(node);
|
||||
|
@ -804,13 +791,13 @@ public class Mainfest implements ManifestInterface {
|
|||
} else {
|
||||
return;
|
||||
}
|
||||
NodeList childList = headerNode.getChildNodes();
|
||||
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)) {
|
||||
if (nodeName.equalsIgnoreCase(farHeader_FarName)) {
|
||||
String nodeValue = node.getTextContent();
|
||||
this.fhInfo.setFarName(nodeValue);
|
||||
} else if (nodeName.equalsIgnoreCase(guidValue)) {
|
||||
|
@ -844,7 +831,7 @@ public class Mainfest implements ManifestInterface {
|
|||
}
|
||||
NodeList fpnList = farPkgNode.getChildNodes();
|
||||
for (int i = 0; i < fpnList.getLength(); i++) {
|
||||
if (fpnList.item(i).getNodeType()== Node.TEXT_NODE){
|
||||
if (fpnList.item(i).getNodeType() == Node.TEXT_NODE) {
|
||||
continue;
|
||||
}
|
||||
FarPackage fpItem = new FarPackage();
|
||||
|
@ -885,15 +872,14 @@ public class Mainfest implements ManifestInterface {
|
|||
* @param fpfListNode
|
||||
* @param plfList
|
||||
*/
|
||||
public void parseFarPlatformList(Node fpfListNode,
|
||||
List<FarPlatformItem> 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){
|
||||
if (child.item(i).getNodeType() == Node.TEXT_NODE) {
|
||||
continue;
|
||||
}
|
||||
farPlfNode = child.item(i);
|
||||
|
@ -936,7 +922,7 @@ public class Mainfest implements ManifestInterface {
|
|||
NodeList contentList = contentsNode.getChildNodes();
|
||||
Node contentNode;
|
||||
for (int i = 0; i < contentList.getLength(); i++) {
|
||||
if (contentList.item(i).getNodeType()== Node.TEXT_NODE){
|
||||
if (contentList.item(i).getNodeType() == Node.TEXT_NODE) {
|
||||
continue;
|
||||
}
|
||||
contentNode = contentList.item(i);
|
||||
|
@ -950,21 +936,20 @@ public class Mainfest implements ManifestInterface {
|
|||
public FarFileItem parseFarFile(Node farFileNode) {
|
||||
String ffName = farFileNode.getTextContent();
|
||||
NamedNodeMap attr = farFileNode.getAttributes();
|
||||
FarFileItem ffItem = new FarFileItem(ffName, attr.getNamedItem(
|
||||
farFileName_Md5sum).getTextContent());
|
||||
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;
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
|
@ -324,6 +324,15 @@ public class InstallStepTwo extends IDialog implements MouseListener {
|
|||
this.setVisible(false);
|
||||
this.dispose();
|
||||
} else if (e.getSource() == jButtonFinish) {
|
||||
|
||||
if (jTablePackage.isEditing()) {
|
||||
jTablePackage.getCellEditor().stopCellEditing();
|
||||
}
|
||||
|
||||
if (jTablePlatform.isEditing()) {
|
||||
jTablePlatform.getCellEditor().stopCellEditing();
|
||||
}
|
||||
|
||||
List<String> packageList = new ArrayList<String>();
|
||||
List<String> platformList = new ArrayList<String>();
|
||||
//
|
||||
|
@ -419,11 +428,17 @@ public class InstallStepTwo extends IDialog implements MouseListener {
|
|||
}
|
||||
|
||||
private boolean isPathContainMutual(File path1, File path2) {
|
||||
if (path1.getPath().startsWith(path2.getParent())) {
|
||||
return true;
|
||||
}
|
||||
if (path2.getPath().startsWith(path1.getPath())) {
|
||||
return true;
|
||||
String s1 = Tools.addFileSeparator(path1.getPath());
|
||||
String s2 = Tools.addFileSeparator(path2.getParent());
|
||||
|
||||
if (s1.length() > s2.length()) {
|
||||
if (s1.substring(0, s2.length()).equalsIgnoreCase(s2)) {
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
if (s2.substring(0, s1.length()).equalsIgnoreCase(s1)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -134,7 +134,7 @@ public class UpdateStepOne extends IDialog implements MouseListener {
|
|||
private JTextField getJTextFieldFarFile() {
|
||||
if (jTextFieldFarFile == null) {
|
||||
jTextFieldFarFile = new JTextField();
|
||||
jTextFieldFarFile.setBounds(new java.awt.Rectangle(130,80,436,20));
|
||||
jTextFieldFarFile.setBounds(new java.awt.Rectangle(130, 80, 436, 20));
|
||||
}
|
||||
return jTextFieldFarFile;
|
||||
}
|
||||
|
@ -179,6 +179,7 @@ public class UpdateStepOne extends IDialog implements MouseListener {
|
|||
WorkspaceTools wt = new WorkspaceTools();
|
||||
farVector = wt.getAllFars();
|
||||
jListFarFromDb.setListData(farVector);
|
||||
jListFarFromDb.setSelectionMode(0);
|
||||
}
|
||||
return jListFarFromDb;
|
||||
}
|
||||
|
@ -215,7 +216,7 @@ public class UpdateStepOne extends IDialog implements MouseListener {
|
|||
jLabel1.setBounds(new java.awt.Rectangle(30, 110, 355, 18));
|
||||
jLabel1.setText("Choose FAR from current framework database");
|
||||
jLabel = new JLabel();
|
||||
jLabel.setBounds(new java.awt.Rectangle(30,80,97,20));
|
||||
jLabel.setBounds(new java.awt.Rectangle(30, 80, 97, 20));
|
||||
jLabel.setText("Choose FAR file: ");
|
||||
jContentPane = new JPanel();
|
||||
jContentPane.setLayout(null);
|
||||
|
@ -231,51 +232,48 @@ public class UpdateStepOne extends IDialog implements MouseListener {
|
|||
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
|
||||
//
|
||||
try{
|
||||
JarFile file = new JarFile(farFile);
|
||||
this.far = new Far(file);
|
||||
} catch (Exception ex){
|
||||
Log.err(ex.getMessage());
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Add more logic process here
|
||||
//
|
||||
if (jListFarFromDb.getSelectedValue() == null) {
|
||||
Log.err("Please choose a FAR from framework database. ");
|
||||
return ;
|
||||
}
|
||||
|
||||
if (stepTwo == null) {
|
||||
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
|
||||
//
|
||||
try {
|
||||
JarFile file = new JarFile(farFile);
|
||||
this.far = new Far(file);
|
||||
} catch (Exception ex) {
|
||||
Log.err(ex.getMessage());
|
||||
}
|
||||
|
||||
//
|
||||
// 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()));
|
||||
}
|
||||
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) {
|
||||
|
|
|
@ -34,6 +34,7 @@ import javax.swing.JTable;
|
|||
import javax.swing.ListSelectionModel;
|
||||
import javax.swing.table.DefaultTableModel;
|
||||
|
||||
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;
|
||||
|
@ -71,7 +72,8 @@ public class UpdateStepTwo extends IDialog implements MouseListener {
|
|||
private JTable jTablePackage = null;
|
||||
|
||||
private PartialTableModel model = null;
|
||||
List<PackageIdentification> updatPkgList = new ArrayList<PackageIdentification>();
|
||||
|
||||
List<PackageIdentification> updatPkgList = new ArrayList<PackageIdentification>();
|
||||
|
||||
public UpdateStepTwo(IDialog iDialog, boolean modal, UpdateStepOne stepOne) {
|
||||
this(iDialog, modal);
|
||||
|
@ -183,25 +185,24 @@ public class UpdateStepTwo extends IDialog implements MouseListener {
|
|||
WorkspaceTools wt = new WorkspaceTools();
|
||||
List<PackageIdentification> packagesInDb = wt.getAllPackages();
|
||||
|
||||
updatPkgList = AggregationOperation.intersection(packagesInDb, packagesInFar);
|
||||
updatPkgList = AggregationOperation.intersection(packagesInDb, packagesInFar);
|
||||
//
|
||||
// Change here to get packages and platforms from FAR
|
||||
//
|
||||
Iterator<PackageIdentification> iter = updatPkgList.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);
|
||||
}
|
||||
Iterator<PackageIdentification> iter = updatPkgList.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();
|
||||
}
|
||||
}
|
||||
catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This is the default constructor
|
||||
|
@ -224,184 +225,191 @@ public class UpdateStepTwo extends IDialog implements MouseListener {
|
|||
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 ?
|
||||
//
|
||||
WorkspaceTools wsTools = new WorkspaceTools();
|
||||
|
||||
Iterator<PackageIdentification> iter = updatPkgList.iterator();
|
||||
List<PackageIdentification> depResultList = new ArrayList<PackageIdentification>();
|
||||
while (iter.hasNext()){
|
||||
List<PackageIdentification> depPkgList = stepOne.getFar().getPackageDependencies(iter.next());
|
||||
depResultList = AggregationOperation.union(depResultList, depPkgList);
|
||||
}
|
||||
|
||||
List<PackageIdentification> dbPkgList = DistributeRule.vectorToList(wsTools.getAllPackages());
|
||||
List<PackageIdentification> resultList = AggregationOperation.minus(depResultList, AggregationOperation.union(
|
||||
this.updatPkgList, dbPkgList));
|
||||
Iterator resultIter = resultList.iterator();
|
||||
while (resultIter.hasNext()){
|
||||
Log.err("Missing dependency package " + ((PackageIdentification)resultIter.next()).toString() + "in workspace!");
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
// Remove all update packages
|
||||
//
|
||||
//
|
||||
// For all packages, remove all files.
|
||||
// Exception FPD file still in DB
|
||||
//
|
||||
Vector<PlatformIdentification> allPlatforms = wsTools.getAllPlatforms();
|
||||
Set<File> allPlatformFiles = new LinkedHashSet<File>();
|
||||
|
||||
Iterator<PlatformIdentification> allPlfIter = allPlatforms.iterator();
|
||||
while (iter.hasNext()) {
|
||||
allPlatformFiles.add(allPlfIter.next().getFpdFile());
|
||||
}
|
||||
|
||||
Iterator<PackageIdentification> packageIter = this.updatPkgList.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());
|
||||
/**
|
||||
* 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);
|
||||
}
|
||||
//
|
||||
// Remove all empty parent dir
|
||||
//
|
||||
File parentDir = item.getSpdFile().getParentFile();
|
||||
while (parentDir.listFiles().length == 0) {
|
||||
File tempFile = parentDir;
|
||||
parentDir = parentDir.getParentFile();
|
||||
tempFile.delete();
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Install all update packages
|
||||
//
|
||||
Iterator<PackageIdentification> updataIter = this.updatPkgList.iterator();
|
||||
while (updataIter.hasNext()){
|
||||
PackageIdentification pkgId = updataIter.next();
|
||||
try{
|
||||
stepOne.getFar().installPackage(pkgId, pkgId.getSpdFile());
|
||||
}catch (Exception ex){
|
||||
Log.err("Can install " + pkgId.toString() + " pakcage, please check it!");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
this.setVisible(false);
|
||||
return jContentPane;
|
||||
}
|
||||
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]);
|
||||
}
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
if (e.getSource() == jButtonCancel) {
|
||||
this.setVisible(false);
|
||||
} else if (e.getSource() == jButtonFinish) {
|
||||
//
|
||||
// Check depedency ?
|
||||
//
|
||||
WorkspaceTools wsTools = new WorkspaceTools();
|
||||
|
||||
Iterator<PackageIdentification> iter = updatPkgList.iterator();
|
||||
List<PackageIdentification> depResultList = new ArrayList<PackageIdentification>();
|
||||
while (iter.hasNext()) {
|
||||
List<PackageIdentification> depPkgList = stepOne.getFar().getPackageDependencies(iter.next());
|
||||
depResultList = AggregationOperation.union(depResultList, depPkgList);
|
||||
}
|
||||
|
||||
List<PackageIdentification> dbPkgList = DistributeRule.vectorToList(wsTools.getAllPackages());
|
||||
List<PackageIdentification> resultList = AggregationOperation
|
||||
.minus(
|
||||
depResultList,
|
||||
AggregationOperation
|
||||
.union(
|
||||
this.updatPkgList,
|
||||
dbPkgList));
|
||||
Iterator resultIter = resultList.iterator();
|
||||
while (resultIter.hasNext()) {
|
||||
Log.err("Missing dependency package " + ((PackageIdentification) resultIter.next()).toString()
|
||||
+ "in workspace!");
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
// Remove all update packages
|
||||
//
|
||||
//
|
||||
// For all packages, remove all files.
|
||||
// Exception FPD file still in DB
|
||||
//
|
||||
Vector<PlatformIdentification> allPlatforms = wsTools.getAllPlatforms();
|
||||
Set<File> allPlatformFiles = new LinkedHashSet<File>();
|
||||
|
||||
Iterator<PlatformIdentification> allPlfIter = allPlatforms.iterator();
|
||||
while (iter.hasNext()) {
|
||||
allPlatformFiles.add(allPlfIter.next().getFpdFile());
|
||||
}
|
||||
|
||||
Iterator<PackageIdentification> packageIter = this.updatPkgList.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();
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Install all update packages
|
||||
//
|
||||
Iterator<PackageIdentification> updataIter = this.updatPkgList.iterator();
|
||||
while (updataIter.hasNext()) {
|
||||
PackageIdentification pkgId = updataIter.next();
|
||||
try {
|
||||
stepOne.getFar().installPackage(pkgId, new File(pkgId.getSpdFile().getParent()));
|
||||
} catch (Exception ex) {
|
||||
Log.err("Can install " + pkgId.toString() + " pakcage, please check it!");
|
||||
}
|
||||
|
||||
}
|
||||
this.stepOne.returnType = DataType.RETURN_TYPE_OK;
|
||||
|
||||
this.setVisible(false);
|
||||
this.dispose();
|
||||
} else if (e.getSource() == jButtonPrevious) {
|
||||
this.setVisible(false);
|
||||
stepOne.setVisible(true);
|
||||
}
|
||||
else {
|
||||
if (isContain(fileList[i], platformFiles)) {
|
||||
recursiveDir(files, fileList[i], platformFiles);
|
||||
}
|
||||
else {
|
||||
files.add(fileList[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
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]);
|
||||
if (file.isDirectory()) {
|
||||
File[] files = file.listFiles();
|
||||
for (int i = 0; i < files.length; i++) {
|
||||
deleteFiles(files[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
file.delete();
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
class PartialTableModel extends DefaultTableModel {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public boolean isCellEditable(int row, int col) {
|
||||
switch (col){
|
||||
case 3:
|
||||
return false;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
public boolean isCellEditable(int row, int col) {
|
||||
switch (col) {
|
||||
case 3:
|
||||
return false;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue