1. Fix EDKT463: When wizard new or clone a msa/spd/fpd, should follow these rules

2. Fix EDKT465: The content in memory should be reloaded when a modified msa/fpd/spd is closed without saving

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@1896 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
hche10x 2006-11-03 08:42:47 +00:00
parent b53fedc961
commit fc87d0ba58
12 changed files with 252 additions and 55 deletions

@ -621,21 +621,21 @@ public class Clone extends IDialog {
if (mode == DataType.RETURN_TYPE_MODULE_SURFACE_AREA) {
String packageGuid = packages.elementAt(this.jComboBoxExistingPackage.getSelectedIndex()).getGuid();
String packageVersion = packages.elementAt(this.jComboBoxExistingPackage.getSelectedIndex()).getVersion();
if (GlobalData.findModuleIdByGuidVersion(guid, version, packageGuid, packageVersion) != null) {
if (GlobalData.findModuleId(guid, version, packageGuid, packageVersion) != null) {
Log.wrn("Clone", "A module with same Guid and same Version already exists, please selece a new Guid or Version!");
return false;
}
}
if (mode == DataType.RETURN_TYPE_PACKAGE_SURFACE_AREA) {
if (GlobalData.findPackageIdByGuidVersion(guid, version) != null) {
if (GlobalData.findPackageId(guid, version) != null) {
Log.wrn("Clone", "A package with same Guid and same Version already exists, please selece a new Guid or Version!");
return false;
}
}
if (mode == DataType.RETURN_TYPE_PLATFORM_SURFACE_AREA) {
if (GlobalData.findPlatformIdByGuidVersion(guid, version) != null) {
if (GlobalData.findPlatformId(guid, version) != null) {
Log.wrn("Clone", "A platform with same Guid and same Version already exists, please selece a new Guid or Version!");
return false;
}
@ -709,6 +709,11 @@ public class Clone extends IDialog {
Log.wrn("Clone", "The target module already exists!");
return false;
}
if (GlobalData.isDuplicateRelativePath(Tools.getFilePathOnly(trg), mode)) {
Log.wrn("Clone", "There already exists a same directory with a module");
return false;
}
return checkId(mode);
}
@ -730,6 +735,11 @@ public class Clone extends IDialog {
Log.wrn("Clone", "The target package already exists!");
return false;
}
if (GlobalData.isDuplicateRelativePath(Tools.getFilePathOnly(trg), mode)) {
Log.wrn("Clone", "There already exists a same directory with a package");
return false;
}
return checkId(mode);
}
@ -750,6 +760,11 @@ public class Clone extends IDialog {
Log.wrn("Clone", "The target platform already exists.");
return false;
}
if (GlobalData.isDuplicateRelativePath(Tools.getFilePathOnly(trg), mode)) {
Log.wrn("Clone", "There already exists a same directory with a platform");
return false;
}
return checkId(mode);
}

@ -1887,6 +1887,7 @@ public class FrameworkWizardUI extends IFrame implements KeyListener, MouseListe
if (arg0.getSource() == this.jMenuItemFileCloseAll) {
this.closeAll();
this.refresh();
this.makeEmptyTree();
}
@ -3108,8 +3109,10 @@ public class FrameworkWizardUI extends IFrame implements KeyListener, MouseListe
iTree.removeNodeChildrenByPath(item);
}
GlobalData.openingModuleList.reload(this.currentOpeningModuleIndex);
GlobalData.openingModuleList.setModuleOpen(this.currentOpeningModuleIndex, false);
GlobalData.openingModuleList.setModuleSaved(this.currentOpeningModuleIndex, true);
this.cleanDesktopPaneModule();
this.currentOpeningModuleIndex = -1;
}
@ -3144,6 +3147,7 @@ public class FrameworkWizardUI extends IFrame implements KeyListener, MouseListe
iTree.removeNodeChildrenByPath(item);
}
GlobalData.openingPackageList.reload(this.currentOpeningPackageIndex);
GlobalData.openingPackageList.setPackageOpen(this.currentOpeningPackageIndex, false);
GlobalData.openingPackageList.setPackageSaved(this.currentOpeningPackageIndex, true);
this.cleanDesktopPanePackage();
@ -3180,6 +3184,7 @@ public class FrameworkWizardUI extends IFrame implements KeyListener, MouseListe
iTree.removeNodeChildrenByPath(item);
}
GlobalData.openingPlatformList.reload(this.currentOpeningPlatformIndex);
GlobalData.openingPlatformList.setPlatformOpen(this.currentOpeningPlatformIndex, false);
GlobalData.openingPlatformList.setPlatformSaved(this.currentOpeningPlatformIndex, true);
this.cleanDesktopPanePlatform();

@ -37,6 +37,7 @@ import org.tianocore.PlatformHeaderDocument.PlatformHeader;
import org.tianocore.PlatformSurfaceAreaDocument.PlatformSurfaceArea;
import org.tianocore.frameworkwizard.common.DataType;
import org.tianocore.frameworkwizard.common.DataValidation;
import org.tianocore.frameworkwizard.common.GlobalData;
import org.tianocore.frameworkwizard.common.IFileFilter;
import org.tianocore.frameworkwizard.common.Log;
import org.tianocore.frameworkwizard.common.SaveFile;
@ -475,10 +476,14 @@ public class SelectModuleBelong extends IDialog {
**/
public boolean check() {
String path = this.jTextFieldFilePath.getText();
String guid = this.jTextFieldGuid.getText();
String version = this.jTextFieldVersion.getText();
//
// Check if all required fields are not empty
//
if (isEmpty(this.jTextFieldFilePath.getText())) {
if (isEmpty(path)) {
Log.wrn("New File", "A File Path must be entered!");
return false;
}
@ -486,11 +491,11 @@ public class SelectModuleBelong extends IDialog {
Log.wrn("New File", "A Name must be entered");
return false;
}
if (isEmpty(this.jTextFieldGuid.getText())) {
if (isEmpty(guid)) {
Log.wrn("New File", "The Guid must be entered!");
return false;
}
if (isEmpty(this.jTextFieldVersion.getText())) {
if (isEmpty(version)) {
Log.wrn("New File", "A Version number must be entered!");
return false;
}
@ -502,17 +507,19 @@ public class SelectModuleBelong extends IDialog {
Log.wrn("New File", "Incorrect data type for the Name!");
return false;
}
if (!DataValidation.isGuid((this.jTextFieldGuid).getText())) {
if (!DataValidation.isGuid((guid))) {
Log.wrn("New File", "Incorrect data type for Guid, which must be in registry format! (8-4-4-4-12)");
return false;
}
if (mode == DataType.RETURN_TYPE_MODULE_SURFACE_AREA) {
//
// Check if the module is already existed in current package
//
String packagePath = packages.elementAt(this.jComboBoxExistingPackage.getSelectedIndex()).getPath();
String modulePath = Tools.convertPathToCurrentOsType(this.jTextFieldFilePath.getText());
String modulePath = Tools.convertPathToCurrentOsType(path);
Vector<String> msaFile = wt.getAllModulesOfPackage(packagePath);
for (int index = 0; index < msaFile.size(); index++) {
@ -521,13 +528,31 @@ public class SelectModuleBelong extends IDialog {
return false;
}
}
//
// Check if path already exists
//
if (GlobalData.isDuplicateRelativePath(Tools.getFilePathOnly(modulePath), mode)) {
Log.wrn("New File", "There already exists a same directory with a module");
return false;
}
//
// Check if Guid+Version is unique
//
String packageGuid = packages.elementAt(this.jComboBoxExistingPackage.getSelectedIndex()).getGuid();
String packageVersion = packages.elementAt(this.jComboBoxExistingPackage.getSelectedIndex()).getVersion();
if (GlobalData.findModuleId(guid, version, packageGuid, packageVersion) != null) {
Log.wrn("New File", "A module with same Guid and same Version already exists, please selece a new Guid or Version!");
return false;
}
}
if (mode == DataType.RETURN_TYPE_PACKAGE_SURFACE_AREA) {
//
// Check if the package is already existed in database
//
String path = Tools.convertPathToCurrentOsType(this.jTextFieldFilePath.getText());
path = Tools.convertPathToCurrentOsType(path);
Vector<PackageIdentification> vPackageList = wt.getAllPackages();
if (vPackageList != null && vPackageList.size() > 0) {
for (int index = 0; index < vPackageList.size(); index++) {
@ -537,13 +562,29 @@ public class SelectModuleBelong extends IDialog {
}
}
}
//
// Check if path already exists
//
if (GlobalData.isDuplicateRelativePath(Tools.getFilePathOnly(path), mode)) {
Log.wrn("New File", "There already exists a same directory with a package");
return false;
}
//
// Check if Guid+Version is unique
//
if (GlobalData.findPackageId(guid, version) != null) {
Log.wrn("New File", "A package with same Guid and same Version already exists, please selece a new Guid or Version!");
return false;
}
}
if (mode == DataType.RETURN_TYPE_PLATFORM_SURFACE_AREA) {
//
// Check if the platform is already existed in database
//
String path = Tools.convertPathToCurrentOsType(this.jTextFieldFilePath.getText());
path = Tools.convertPathToCurrentOsType(path);
Vector<PlatformIdentification> vPlatfromList = wt.getAllPlatforms();
if (vPlatfromList != null && vPlatfromList.size() > 0) {
for (int index = 0; index < vPlatfromList.size(); index++) {
@ -553,6 +594,22 @@ public class SelectModuleBelong extends IDialog {
}
}
}
//
// Check if path already exists
//
if (GlobalData.isDuplicateRelativePath(Tools.getFilePathOnly(path), mode)) {
Log.wrn("New File", "There already exists a same directory with a platform");
return false;
}
//
// Check if Guid+Version is unique
//
if (GlobalData.findPlatformId(guid, version) != null) {
Log.wrn("New File", "A platform with same Guid and same Version already exists, please selece a new Guid or Version!");
return false;
}
}
return true;

@ -210,8 +210,8 @@ public class GlobalData {
@return
**/
public static ModuleIdentification findModuleIdByGuidVersion(String moduleGuid, String moduleVersion,
String packageGuid, String packageVersion) {
public static ModuleIdentification findModuleId(String moduleGuid, String moduleVersion, String packageGuid,
String packageVersion) {
ModuleIdentification mid = null;
for (int index = 0; index < vModuleList.size(); index++) {
if (vModuleList.elementAt(index).equals(moduleGuid, moduleVersion, packageGuid, packageVersion)) {
@ -230,7 +230,7 @@ public class GlobalData {
@return
**/
public static PackageIdentification findPackageIdByGuidVersion(String packageGuid, String packageVersion) {
public static PackageIdentification findPackageId(String packageGuid, String packageVersion) {
PackageIdentification pid = null;
for (int index = 0; index < vPackageList.size(); index++) {
if (vPackageList.elementAt(index).equals(packageGuid, packageVersion)) {
@ -249,7 +249,7 @@ public class GlobalData {
@return
**/
public static PlatformIdentification findPlatformIdByGuidVersion(String platformGuid, String platformVersion) {
public static PlatformIdentification findPlatformId(String platformGuid, String platformVersion) {
PlatformIdentification pid = null;
for (int index = 0; index < vPlatformList.size(); index++) {
if (vPlatformList.elementAt(index).equals(platformGuid, platformVersion)) {
@ -259,4 +259,42 @@ public class GlobalData {
}
return pid;
}
/**
@param relativePath
@param mode
@return
**/
public static boolean isDuplicateRelativePath(String relativePath, int mode) {
if (mode == DataType.RETURN_TYPE_MODULE_SURFACE_AREA) {
for (int index = 0; index < vModuleList.size(); index++) {
String path = vModuleList.elementAt(index).getPath();
if (Tools.getFilePathOnly(path).equals(relativePath)) {
return true;
}
}
}
if (mode == DataType.RETURN_TYPE_PACKAGE_SURFACE_AREA) {
for (int index = 0; index < vPackageList.size(); index++) {
String path = vPackageList.elementAt(index).getPath();
if (Tools.getFilePathOnly(path).equals(relativePath)) {
return true;
}
}
}
if (mode == DataType.RETURN_TYPE_PLATFORM_SURFACE_AREA) {
for (int index = 0; index < vPlatformList.size(); index++) {
String path = vPlatformList.elementAt(index).getPath();
if (Tools.getFilePathOnly(path).equals(relativePath)) {
return true;
}
}
}
return false;
}
}

@ -222,4 +222,10 @@ public class OpeningModuleList {
}
return false;
}
public void reload(int index) {
if (index > -1) {
vOpeningModuleList.elementAt(index).reload();
}
}
}

@ -15,7 +15,12 @@
package org.tianocore.frameworkwizard.common.Identifications;
import java.io.IOException;
import org.apache.xmlbeans.XmlException;
import org.tianocore.ModuleSurfaceAreaDocument;
import org.tianocore.frameworkwizard.common.Log;
import org.tianocore.frameworkwizard.common.OpenFile;
import org.tianocore.frameworkwizard.module.Identifications.ModuleIdentification;
public class OpeningModuleType extends OpeningFileType{
@ -50,4 +55,21 @@ public class OpeningModuleType extends OpeningFileType{
public void setId(ModuleIdentification id) {
this.id = id;
}
public void reload() {
if (this.id != null) {
String path = id.getPath();
if (path.length() > 0) {
try {
this.xmlMsa = OpenFile.openMsaFile(id.getPath());
} catch (IOException e) {
Log.err("Open Module Surface Area " + path, e.getMessage());
} catch (XmlException e) {
Log.err("Open Module Surface Area " + path, e.getMessage());
} catch (Exception e) {
Log.err("Open Module Surface Area " + path, "Invalid file type");
}
}
}
}
}

@ -222,4 +222,10 @@ public class OpeningPackageList {
}
return false;
}
public void reload(int index) {
if (index > -1) {
vOpeningPackageList.elementAt(index).reload();
}
}
}

@ -14,7 +14,12 @@
**/
package org.tianocore.frameworkwizard.common.Identifications;
import java.io.IOException;
import org.apache.xmlbeans.XmlException;
import org.tianocore.PackageSurfaceAreaDocument;
import org.tianocore.frameworkwizard.common.Log;
import org.tianocore.frameworkwizard.common.OpenFile;
import org.tianocore.frameworkwizard.packaging.PackageIdentification;
public class OpeningPackageType extends OpeningFileType {
@ -49,4 +54,21 @@ public class OpeningPackageType extends OpeningFileType {
public void setId(PackageIdentification id) {
this.id = id;
}
public void reload() {
if (this.id != null) {
String path = id.getPath();
if (path.length() > 0) {
try {
this.xmlSpd = OpenFile.openSpdFile(id.getPath());
} catch (IOException e) {
Log.err("Open Package Surface Area " + path, e.getMessage());
} catch (XmlException e) {
Log.err("Open Package Surface Area " + path, e.getMessage());
} catch (Exception e) {
Log.err("Open Package Surface Area " + path, "Invalid file type");
}
}
}
}
}

@ -208,4 +208,10 @@ public class OpeningPlatformList {
}
return false;
}
public void reload(int index) {
if (index > -1) {
vOpeningPlatformList.elementAt(index).reload();
}
}
}

@ -14,7 +14,12 @@
**/
package org.tianocore.frameworkwizard.common.Identifications;
import java.io.IOException;
import org.apache.xmlbeans.XmlException;
import org.tianocore.PlatformSurfaceAreaDocument;
import org.tianocore.frameworkwizard.common.Log;
import org.tianocore.frameworkwizard.common.OpenFile;
import org.tianocore.frameworkwizard.platform.PlatformIdentification;
public class OpeningPlatformType extends OpeningFileType {
@ -49,4 +54,21 @@ public class OpeningPlatformType extends OpeningFileType {
public void setId(PlatformIdentification id) {
this.id = id;
}
public void reload() {
if (this.id != null) {
String path = id.getPath();
if (path.length() > 0) {
try {
this.xmlFpd = OpenFile.openFpdFile(id.getPath());
} catch (IOException e) {
Log.err("Open Platform Surface Area " + path, e.getMessage());
} catch (XmlException e) {
Log.err("Open Platform Surface Area " + path, e.getMessage());
} catch (Exception e) {
Log.err("Open Platform Surface Area " + path, "Invalid file type");
}
}
}
}
}

@ -286,15 +286,13 @@ public class FindResultDetailInfo extends IFrame {
// Write Module Sa Info
//
ModuleIdentification moduleSaId = GlobalData
.findModuleIdByGuidVersion(
msa
.getModuleGuid(),
msa
.getModuleVersion(),
msa
.getPackageGuid(),
msa
.getPackageVersion());
.findModuleId(
msa.getModuleGuid(),
msa
.getModuleVersion(),
msa.getPackageGuid(),
msa
.getPackageVersion());
tmp = tmp
+ TAB
+ TAB
@ -539,15 +537,15 @@ public class FindResultDetailInfo extends IFrame {
if (mid.equals(i.getModuleGuid(), i.getModuleVersion(), i.getPackageGuid(),
i.getPackageVersion())) {
ModuleIdentification moduleSaId = GlobalData
.findModuleIdByGuidVersion(
msa
.getModuleGuid(),
msa
.getModuleVersion(),
msa
.getPackageGuid(),
msa
.getPackageVersion());
.findModuleId(
msa
.getModuleGuid(),
msa
.getModuleVersion(),
msa
.getPackageGuid(),
msa
.getPackageVersion());
if (moduleSaId != null) {
vModuleSa.addElement(moduleSaId);
}

@ -15,7 +15,6 @@
package org.tianocore.frameworkwizard.module.Identifications;
import java.io.IOException;
import org.apache.xmlbeans.XmlException;
@ -29,63 +28,64 @@ import org.tianocore.frameworkwizard.common.Identifications.Identification;
import org.tianocore.frameworkwizard.packaging.PackageIdentification;
public class ModuleIdentification extends Identification {
private PackageIdentification packageId;
private String moduleType;
private boolean isLibrary;
public ModuleIdentification(String name, String guid, String version, String path) {
super(name, guid, version, path);
super(name, guid, version, path);
setModuleType();
}
public ModuleIdentification(String name, String guid, String version, String path, boolean library) {
super(name, guid, version, path);
this.isLibrary = library;
}
public ModuleIdentification(Identification id) {
super(id.getName(), id.getGuid(), id.getVersion(), id.getPath());
}
public ModuleIdentification(Identification id, boolean library) {
super(id.getName(), id.getGuid(), id.getVersion(), id.getPath());
this.isLibrary = library;
}
public ModuleIdentification(String name, String guid, String version, String path, PackageIdentification packageId){
public ModuleIdentification(String name, String guid, String version, String path, PackageIdentification packageId) {
super(name, guid, version, path);
this.packageId = packageId;
setModuleType();
}
public ModuleIdentification(String name, String guid, String version, String path, PackageIdentification packageId, String type){
public ModuleIdentification(String name, String guid, String version, String path, PackageIdentification packageId,
String type) {
super(name, guid, version, path);
this.packageId = packageId;
this.moduleType = type;
}
public ModuleIdentification(Identification id, PackageIdentification packageId) {
super(id.getName(), id.getGuid(), id.getVersion(), id.getPath());
this.packageId = packageId;
setModuleType();
}
public ModuleIdentification(Identification id, PackageIdentification packageId, boolean library) {
super(id.getName(), id.getGuid(), id.getVersion(), id.getPath());
this.packageId = packageId;
this.isLibrary = library;
}
public ModuleIdentification(Identification id, PackageIdentification packageId, String type) {
super(id.getName(), id.getGuid(), id.getVersion(), id.getPath());
this.packageId = packageId;
this.moduleType = type;
}
public String toString(){
public String toString() {
return "Module " + this.getName() + "[" + this.getGuid() + "] in package " + packageId;
}
@ -104,20 +104,20 @@ public class ModuleIdentification extends Identification {
public void setModuleType(String moduleType) {
this.moduleType = moduleType;
}
private void setModuleType() {
ModuleSurfaceArea msa = null;
try {
msa = OpenFile.openMsaFile(this.getPath());
} catch (IOException e) {
// TODO Auto-generated catch block
} catch (XmlException e) {
// TODO Auto-generated catch block
} catch (Exception e) {
// TODO Auto-generated catch block
}
setModuleType(DataType.MODULE_TYPE_MODULE);
setLibrary(false);
@ -134,7 +134,7 @@ public class ModuleIdentification extends Identification {
}
}
}
public boolean equals(String moduleGuid, String moduleVersion, String packageGuid, String packageVersion) {
boolean b = false;
if (this.getGuid().equals(moduleGuid) && this.getPackageId().getGuid().equals(packageGuid)) {