diff options
5 files changed, 139 insertions, 33 deletions
diff --git a/Tools/Java/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/Clone.java b/Tools/Java/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/Clone.java index 4643bb1..d8030f7 100644 --- a/Tools/Java/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/Clone.java +++ b/Tools/Java/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/Clone.java @@ -569,15 +569,19 @@ public class Clone extends IDialog { @retval false Any one of name, guid and version is invalid
**/
- private boolean checkId() {
+ private boolean checkId(int mode) {
+ String name = this.jTextFieldBaseName.getText();
+ String guid = this.jTextFieldGuid.getText();
+ String version = this.jTextFieldVersion.getText();
+
//
// Check Basename
//
- if (isEmpty(this.jTextFieldBaseName.getText())) {
+ if (isEmpty(name)) {
Log.wrn("Clone", "The Name is required!");
return false;
}
- if (!DataValidation.isBaseName(this.jTextFieldBaseName.getText())) {
+ if (!DataValidation.isBaseName(name)) {
Log
.wrn("Clone",
"<html>Incorrect data type for the Name, it must<br>be a single word, starting with an alpha character.</html>");
@@ -587,11 +591,11 @@ public class Clone extends IDialog { //
// Check Guid
//
- if (isEmpty(this.jTextFieldGuid.getText())) {
+ if (isEmpty(guid)) {
Log.wrn("Clone", "A Guid is required!!");
return false;
}
- if (!DataValidation.isGuid(this.jTextFieldGuid.getText())) {
+ if (!DataValidation.isGuid(guid)) {
Log
.wrn(
"Clone",
@@ -602,17 +606,40 @@ public class Clone extends IDialog { //
// Check Version
//
- if (isEmpty(this.jTextFieldVersion.getText())) {
+ if (isEmpty(version)) {
Log.wrn("Clone", "A Version must be entered!");
return false;
}
- if (!DataValidation.isVersion(this.jTextFieldVersion.getText())) {
+ if (!DataValidation.isVersion(version)) {
Log
.wrn(
"Clone",
"<html>Incorrect data type for Version, which must<br>be one or more digits, optionally followed by sequence<br>of one or more dot, one or more digits; examples:<br>1.0 1.0.1 12.25.256</html>");
return false;
}
+
+ 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) {
+ 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) {
+ 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) {
+ Log.wrn("Clone", "A platform with same Guid and same Version already exists, please selece a new Guid or Version!");
+ return false;
+ }
+ }
//
// Save information to id
@@ -673,7 +700,7 @@ public class Clone extends IDialog { //
if (mode == DataType.RETURN_TYPE_MODULE_SURFACE_AREA) {
trg = this.getModulePath();
- if (src.equals(trg)) {
+ if (Tools.getFilePathOnly(src).equals(Tools.getFilePathOnly(trg))) {
Log.wrn("Clone", "The source and destination paths for cloning a module must be different!");
return false;
}
@@ -682,7 +709,7 @@ public class Clone extends IDialog { Log.wrn("Clone", "The target module already exists!");
return false;
}
- return checkId();
+ return checkId(mode);
}
//
@@ -703,7 +730,7 @@ public class Clone extends IDialog { Log.wrn("Clone", "The target package already exists!");
return false;
}
- return checkId();
+ return checkId(mode);
}
//
@@ -714,12 +741,16 @@ public class Clone extends IDialog { Log.wrn("Clone", "The platform clone must be located in the current workspace!");
return false;
}
+ if (Tools.getFilePathOnly(src).equals(Tools.getFilePathOnly(trg))) {
+ Log.wrn("Clone", "The source and destination paths for cloning a platform must be different!");
+ return false;
+ }
trgFile = new File(trg);
if (trgFile.exists()) {
Log.wrn("Clone", "The target platform already exists.");
return false;
}
- return checkId();
+ return checkId(mode);
}
return true;
diff --git a/Tools/Java/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/GlobalData.java b/Tools/Java/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/GlobalData.java index b946235..83a6dd0 100644 --- a/Tools/Java/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/GlobalData.java +++ b/Tools/Java/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/GlobalData.java @@ -199,7 +199,7 @@ public class GlobalData { }
return modulePath;
}
-
+
/**
Get a module id
@@ -208,9 +208,10 @@ public class GlobalData { @param packageGuid
@param packageVersion
@return
-
- **/
- public static ModuleIdentification findIdByGuidVersion(String moduleGuid, String moduleVersion, String packageGuid, String packageVersion) {
+
+ **/
+ public static ModuleIdentification findModuleIdByGuidVersion(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)) {
@@ -220,4 +221,42 @@ public class GlobalData { }
return mid;
}
+
+ /**
+ Get a package id
+
+ @param packageGuid
+ @param packageVersion
+ @return
+
+ **/
+ public static PackageIdentification findPackageIdByGuidVersion(String packageGuid, String packageVersion) {
+ PackageIdentification pid = null;
+ for (int index = 0; index < vPackageList.size(); index++) {
+ if (vPackageList.elementAt(index).equals(packageGuid, packageVersion)) {
+ pid = vPackageList.elementAt(index);
+ break;
+ }
+ }
+ return pid;
+ }
+
+ /**
+ Get a platform id
+
+ @param platformGuid
+ @param platformVersion
+ @return
+
+ **/
+ public static PlatformIdentification findPlatformIdByGuidVersion(String platformGuid, String platformVersion) {
+ PlatformIdentification pid = null;
+ for (int index = 0; index < vPlatformList.size(); index++) {
+ if (vPlatformList.elementAt(index).equals(platformGuid, platformVersion)) {
+ pid = vPlatformList.elementAt(index);
+ break;
+ }
+ }
+ return pid;
+ }
}
diff --git a/Tools/Java/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/find/FindResultDetailInfo.java b/Tools/Java/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/find/FindResultDetailInfo.java index 472555b..1b58b67 100644 --- a/Tools/Java/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/find/FindResultDetailInfo.java +++ b/Tools/Java/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/find/FindResultDetailInfo.java @@ -286,15 +286,15 @@ public class FindResultDetailInfo extends IFrame { // Write Module Sa Info
//
ModuleIdentification moduleSaId = GlobalData
- .findIdByGuidVersion(
- msa
- .getModuleGuid(),
- msa
- .getModuleVersion(),
- msa
- .getPackageGuid(),
- msa
- .getPackageVersion());
+ .findModuleIdByGuidVersion(
+ msa
+ .getModuleGuid(),
+ msa
+ .getModuleVersion(),
+ msa
+ .getPackageGuid(),
+ msa
+ .getPackageVersion());
tmp = tmp
+ TAB
+ TAB
@@ -539,15 +539,15 @@ public class FindResultDetailInfo extends IFrame { if (mid.equals(i.getModuleGuid(), i.getModuleVersion(), i.getPackageGuid(),
i.getPackageVersion())) {
ModuleIdentification moduleSaId = GlobalData
- .findIdByGuidVersion(
- msa
- .getModuleGuid(),
- msa
- .getModuleVersion(),
- msa
- .getPackageGuid(),
- msa
- .getPackageVersion());
+ .findModuleIdByGuidVersion(
+ msa
+ .getModuleGuid(),
+ msa
+ .getModuleVersion(),
+ msa
+ .getPackageGuid(),
+ msa
+ .getPackageVersion());
if (moduleSaId != null) {
vModuleSa.addElement(moduleSaId);
}
diff --git a/Tools/Java/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/packaging/PackageIdentification.java b/Tools/Java/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/packaging/PackageIdentification.java index 23b6ff0..e986f55 100644 --- a/Tools/Java/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/packaging/PackageIdentification.java +++ b/Tools/Java/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/packaging/PackageIdentification.java @@ -43,4 +43,22 @@ public class PackageIdentification extends Identification{ public String toString() {
return getName() + " " + getVersion() + " [" + Tools.getRelativePath(getSpdFile().getPath(), Workspace.getCurrentWorkspace()) + "]";
}
+
+ public boolean equals(String packageGuid, String packageVersion) {
+ boolean b = false;
+ if (this.getGuid().equals(packageGuid)) {
+ b = true;
+ //
+ // Check Version
+ //
+ if (packageVersion != null) {
+ if (!Tools.isEmpty(packageVersion)) {
+ if (!packageVersion.equals(this.getVersion())) {
+ b = false;
+ }
+ }
+ }
+ }
+ return b;
+ }
}
diff --git a/Tools/Java/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/PlatformIdentification.java b/Tools/Java/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/PlatformIdentification.java index 2fdbdd6..bc0b3d2 100644 --- a/Tools/Java/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/PlatformIdentification.java +++ b/Tools/Java/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/PlatformIdentification.java @@ -40,4 +40,22 @@ public class PlatformIdentification extends Identification{ public String toString() {
return getName() + " " + getVersion() + " [" + Tools.getRelativePath(getFpdFile().getPath(), Workspace.getCurrentWorkspace()) + "]";
}
+
+ public boolean equals(String platformGuid, String platformVersion) {
+ boolean b = false;
+ if (this.getGuid().equals(platformGuid)) {
+ b = true;
+ //
+ // Check Version
+ //
+ if (platformVersion != null) {
+ if (!Tools.isEmpty(platformVersion)) {
+ if (!platformVersion.equals(this.getVersion())) {
+ b = false;
+ }
+ }
+ }
+ }
+ return b;
+ }
}
\ No newline at end of file |