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