import java.awt.event.ActionEvent;\r
import java.io.File;\r
import java.io.IOException;\r
+import java.math.BigInteger;\r
import java.util.Vector;\r
\r
import javax.swing.JFileChooser;\r
import org.tianocore.frameworkwizard.common.DataValidation;\r
import org.tianocore.frameworkwizard.common.FileOperation;\r
import org.tianocore.frameworkwizard.common.IFileFilter;\r
-import org.tianocore.frameworkwizard.common.Identification;\r
import org.tianocore.frameworkwizard.common.Log;\r
-import org.tianocore.frameworkwizard.common.OpenFile;\r
import org.tianocore.frameworkwizard.common.SaveFile;\r
import org.tianocore.frameworkwizard.common.Tools;\r
+import org.tianocore.frameworkwizard.common.Identifications.Identification;\r
+import org.tianocore.frameworkwizard.common.Identifications.OpenFile;\r
import org.tianocore.frameworkwizard.common.ui.IDialog;\r
import org.tianocore.frameworkwizard.common.ui.IFrame;\r
-import org.tianocore.frameworkwizard.module.Identification.ModuleIdentification;\r
+import org.tianocore.frameworkwizard.module.Identifications.ModuleIdentification;\r
import org.tianocore.frameworkwizard.packaging.PackageIdentification;\r
import org.tianocore.frameworkwizard.platform.PlatformIdentification;\r
import org.tianocore.frameworkwizard.workspace.Workspace;\r
// Check for Module\r
//\r
if (mode == DataType.RETURN_TYPE_MODULE_SURFACE_AREA) {\r
+// if (trg.indexOf(DataType.DOS_FILE_SEPARATOR) == -1 && trg.indexOf(DataType.UNIX_FILE_SEPARATOR) == -1) {\r
+// Log.err("The module name must include a path");\r
+// return false;\r
+// }\r
+ trg = this.getModulePath();\r
+ if (src.equals(trg)) {\r
+ Log.err("The source and destination couldn't be same");\r
+ return false;\r
+ }\r
+ trgFile = new File(trg);\r
+ if (trgFile.exists()) {\r
+ Log.err("The target module already exists");\r
+ return false;\r
+ }\r
return checkId();\r
}\r
\r
private void save() throws IOException, XmlException, Exception {\r
String src = this.jTextFieldSource.getText();\r
String trg = this.jTextFieldFilePath.getText();\r
+ Vector<String> vFiles = new Vector<String>();\r
\r
//\r
// Clone Workspace\r
//\r
trg = getModulePath();\r
newId.setPath(trg);\r
+ vFiles = wt.getAllModuleFilesPath(src);\r
\r
//\r
// First copy all files to new directory\r
//\r
- FileOperation.copyFolder(Tools.getFilePathOnly(src), Tools.getFilePathOnly(trg));\r
-\r
- //\r
- // Delete old spd file\r
- //\r
- FileOperation.delFile(Tools.getFilePathOnly(trg) + DataType.FILE_SEPARATOR + Tools.getFileNameOnly(src));\r
+ FileOperation.copyFile(src, trg);\r
+ for (int index = 1; index < vFiles.size(); index++) {\r
+ String oldFile = vFiles.get(index);\r
+ String newFile = vFiles.get(index).replace(Tools.getFilePathOnly(src), Tools.getFilePathOnly(trg));\r
+ FileOperation.copyFile(oldFile, newFile);\r
+ }\r
\r
//\r
// Create new msa file\r
//\r
trg = this.getPackagePath();\r
newId.setPath(trg);\r
+ vFiles = wt.getAllPakcageFilesPath(src);\r
+ \r
+ FileOperation.copyFile(src, trg);\r
+ for (int index = 1; index < vFiles.size(); index++) {\r
+ String oldFile = vFiles.get(index);\r
+ String newFile = vFiles.get(index).replace(Tools.getFilePathOnly(src), Tools.getFilePathOnly(trg));\r
+ FileOperation.copyFile(oldFile, newFile);\r
+ }\r
\r
//\r
// First copy all files to new directory\r
//\r
- FileOperation.copyFolder(Tools.getFilePathOnly(src), Tools.getFilePathOnly(trg));\r
+ //FileOperation.copyFolder(Tools.getFilePathOnly(src), Tools.getFilePathOnly(trg));\r
\r
//\r
// Delete old spd file\r
//\r
- FileOperation.delFile(Tools.getFilePathOnly(trg) + DataType.FILE_SEPARATOR + Tools.getFileNameOnly(src));\r
+ //FileOperation.delFile(Tools.getFilePathOnly(trg) + DataType.FILE_SEPARATOR + Tools.getFileNameOnly(src));\r
\r
//\r
// Create new spd file\r
\r
this.returnType = DataType.RETURN_TYPE_PLATFORM_SURFACE_AREA;\r
}\r
+ vFiles = null;\r
}\r
\r
private String getSelectPackagePath() {\r
private String getModulePath() {\r
String trg = this.jTextFieldFilePath.getText();\r
trg = Tools.addPathExt(trg, mode);\r
- trg = getSelectPackagePath() + DataType.FILE_SEPARATOR + trg;\r
+ trg = Tools.addFileSeparator(getSelectPackagePath()) + trg;\r
Tools.convertPathToCurrentOsType(trg);\r
return trg;\r
}\r
private String getPackagePath() {\r
String trg = this.jTextFieldFilePath.getText();\r
trg = Tools.addPathExt(trg, mode);\r
- trg = Workspace.getCurrentWorkspace() + DataType.FILE_SEPARATOR + trg;\r
+ trg = Tools.addFileSeparator(Workspace.getCurrentWorkspace()) + trg;\r
trg = Tools.convertPathToCurrentOsType(trg);\r
return trg;\r
}\r
// Get ClonedFrom then\r
//\r
ModuleDefinitions.ClonedFrom cf = null;\r
+ BigInteger count = new BigInteger("-1");\r
if (pd.getClonedFrom() == null) {\r
cf = ModuleDefinitions.ClonedFrom.Factory.newInstance();\r
} else {\r
cf = pd.getClonedFrom();\r
+ if (cf != null) {\r
+ for (int index = 0; index < cf.getClonedList().size(); index++) {\r
+ if (cf.getClonedList().get(index).getId() != null) {\r
+ count = count.max(cf.getClonedList().get(index).getId());\r
+ }\r
+ }\r
+ }\r
}\r
\r
//\r
ModuleDefinitions.ClonedFrom.Cloned c = ModuleDefinitions.ClonedFrom.Cloned.Factory.newInstance();\r
c.setModuleGuid(id.getGuid());\r
c.setModuleVersion(id.getVersion());\r
+ c.setPackageGuid(wt.getPackageIdByModuleId(oldId).getGuid());\r
+ c.setPackageVersion(wt.getPackageIdByModuleId(oldId).getVersion());\r
+ c.setId(count.add(new BigInteger("1")));\r
\r
cf.addNewCloned();\r
cf.setClonedArray(cf.getClonedList().size() - 1, c);\r
// Get ClonedFrom then\r
//\r
PackageDefinitions.ClonedFrom cf = null;\r
+ BigInteger count = new BigInteger("-1");\r
if (pd.getClonedFrom() == null) {\r
cf = PackageDefinitions.ClonedFrom.Factory.newInstance();\r
} else {\r
cf = pd.getClonedFrom();\r
+ if (cf != null) {\r
+ for (int index = 0; index < cf.getClonedList().size(); index++) {\r
+ if (cf.getClonedList().get(index).getId() != null) {\r
+ count = count.max(cf.getClonedList().get(index).getId());\r
+ }\r
+ }\r
+ }\r
}\r
\r
//\r
PackageDefinitions.ClonedFrom.Cloned c = PackageDefinitions.ClonedFrom.Cloned.Factory.newInstance();\r
c.setPackageGuid(id.getGuid());\r
c.setPackageVersion(id.getVersion());\r
+ c.setId(count.add(new BigInteger("1")));\r
\r
cf.addNewCloned();\r
cf.setClonedArray(cf.getClonedList().size() - 1, c);\r
// Get ClonedFrom then\r
//\r
PlatformDefinitions.ClonedFrom cf = null;\r
+ BigInteger count = new BigInteger("-1");\r
if (pd.getClonedFrom() == null) {\r
cf = PlatformDefinitions.ClonedFrom.Factory.newInstance();\r
} else {\r
cf = pd.getClonedFrom();\r
+ if (cf != null) {\r
+ for (int index = 0; index < cf.getClonedList().size(); index++) {\r
+ if (cf.getClonedList().get(index).getId() != null) {\r
+ count = count.max(cf.getClonedList().get(index).getId());\r
+ }\r
+ }\r
+ }\r
}\r
\r
//\r
PlatformDefinitions.ClonedFrom.Cloned c = PlatformDefinitions.ClonedFrom.Cloned.Factory.newInstance();\r
c.setPlatformGuid(id.getGuid());\r
c.setPlatformVersion(id.getVersion());\r
+ c.setId(count.add(new BigInteger("1")));\r
\r
cf.addNewCloned();\r
cf.setClonedArray(cf.getClonedList().size() - 1, c);\r