X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;ds=sidebyside;f=Tools%2FSource%2FFrameworkWizard%2Fsrc%2Forg%2Ftianocore%2Fframeworkwizard%2FClone.java;h=9253793ca966d137311af29b506413fff59a26a9;hb=a19466adcb3939cd5fb8f919f000c04a0fe0b6f1;hp=baf03795ee463b5de41dbbb95f28c32e144a4037;hpb=a13899c5acad2f5e125abdae972b4c3d1e522f69;p=mirror_edk2.git diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/Clone.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/Clone.java index baf03795ee..9253793ca9 100644 --- a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/Clone.java +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/Clone.java @@ -17,6 +17,7 @@ package org.tianocore.frameworkwizard; import java.awt.event.ActionEvent; import java.io.File; import java.io.IOException; +import java.math.BigInteger; import java.util.Vector; import javax.swing.JFileChooser; @@ -36,14 +37,14 @@ import org.tianocore.frameworkwizard.common.DataType; import org.tianocore.frameworkwizard.common.DataValidation; import org.tianocore.frameworkwizard.common.FileOperation; import org.tianocore.frameworkwizard.common.IFileFilter; -import org.tianocore.frameworkwizard.common.Identification; import org.tianocore.frameworkwizard.common.Log; import org.tianocore.frameworkwizard.common.OpenFile; import org.tianocore.frameworkwizard.common.SaveFile; import org.tianocore.frameworkwizard.common.Tools; +import org.tianocore.frameworkwizard.common.Identifications.Identification; import org.tianocore.frameworkwizard.common.ui.IDialog; import org.tianocore.frameworkwizard.common.ui.IFrame; -import org.tianocore.frameworkwizard.module.Identification.ModuleIdentification; +import org.tianocore.frameworkwizard.module.Identifications.ModuleIdentification; import org.tianocore.frameworkwizard.packaging.PackageIdentification; import org.tianocore.frameworkwizard.platform.PlatformIdentification; import org.tianocore.frameworkwizard.workspace.Workspace; @@ -120,7 +121,7 @@ public class Clone extends IDialog { private JTextField getJTextFieldType() { if (jTextFieldType == null) { jTextFieldType = new JTextField(); - jTextFieldType.setBounds(new java.awt.Rectangle(160, 10, 320, 20)); + jTextFieldType.setBounds(new java.awt.Rectangle(210, 10, 320, 20)); jTextFieldType.setEditable(false); } return jTextFieldType; @@ -134,7 +135,7 @@ public class Clone extends IDialog { private JTextField getJTextFieldSource() { if (jTextFieldSource == null) { jTextFieldSource = new JTextField(); - jTextFieldSource.setBounds(new java.awt.Rectangle(160, 35, 320, 20)); + jTextFieldSource.setBounds(new java.awt.Rectangle(210, 35, 320, 20)); jTextFieldSource.setEditable(false); } return jTextFieldSource; @@ -148,7 +149,7 @@ public class Clone extends IDialog { private JButton getJButtonBrowse() { if (jButtonBrowse == null) { jButtonBrowse = new JButton(); - jButtonBrowse.setBounds(new java.awt.Rectangle(395, 60, 85, 20)); + jButtonBrowse.setBounds(new java.awt.Rectangle(445, 85, 85, 20)); jButtonBrowse.setText("Browse"); jButtonBrowse.addActionListener(this); } @@ -163,7 +164,7 @@ public class Clone extends IDialog { private JTextField getJTextFieldFilePath() { if (jTextFieldFilePath == null) { jTextFieldFilePath = new JTextField(); - jTextFieldFilePath.setBounds(new java.awt.Rectangle(160, 60, 230, 20)); + jTextFieldFilePath.setBounds(new java.awt.Rectangle(210, 85, 230, 20)); } return jTextFieldFilePath; } @@ -176,7 +177,7 @@ public class Clone extends IDialog { private JTextField getJTextFieldBaseName() { if (jTextFieldBaseName == null) { jTextFieldBaseName = new JTextField(); - jTextFieldBaseName.setBounds(new java.awt.Rectangle(160, 110, 320, 20)); + jTextFieldBaseName.setBounds(new java.awt.Rectangle(210, 110, 320, 20)); } return jTextFieldBaseName; } @@ -189,7 +190,7 @@ public class Clone extends IDialog { private JTextField getJTextFieldGuid() { if (jTextFieldGuid == null) { jTextFieldGuid = new JTextField(); - jTextFieldGuid.setBounds(new java.awt.Rectangle(160, 135, 230, 20)); + jTextFieldGuid.setBounds(new java.awt.Rectangle(210, 135, 230, 20)); } return jTextFieldGuid; } @@ -202,7 +203,7 @@ public class Clone extends IDialog { private JTextField getJTextFieldVersion() { if (jTextFieldVersion == null) { jTextFieldVersion = new JTextField(); - jTextFieldVersion.setBounds(new java.awt.Rectangle(160, 160, 320, 20)); + jTextFieldVersion.setBounds(new java.awt.Rectangle(210, 160, 320, 20)); } return jTextFieldVersion; } @@ -215,7 +216,7 @@ public class Clone extends IDialog { private JButton getJButtonOk() { if (jButtonOk == null) { jButtonOk = new JButton(); - jButtonOk.setBounds(new java.awt.Rectangle(235, 200, 90, 20)); + jButtonOk.setBounds(new java.awt.Rectangle(285, 200, 90, 20)); jButtonOk.setText("Ok"); jButtonOk.addActionListener(this); } @@ -230,7 +231,7 @@ public class Clone extends IDialog { private JButton getJButtonCancel() { if (jButtonCancel == null) { jButtonCancel = new JButton(); - jButtonCancel.setBounds(new java.awt.Rectangle(355, 200, 90, 20)); + jButtonCancel.setBounds(new java.awt.Rectangle(405, 200, 90, 20)); jButtonCancel.setText("Cancel"); jButtonCancel.addActionListener(this); } @@ -245,7 +246,7 @@ public class Clone extends IDialog { private JButton getJButtonGenerateGuid() { if (jButtonGenerateGuid == null) { jButtonGenerateGuid = new JButton(); - jButtonGenerateGuid.setBounds(new java.awt.Rectangle(395, 135, 85, 20)); + jButtonGenerateGuid.setBounds(new java.awt.Rectangle(445, 135, 85, 20)); jButtonGenerateGuid.setText("Gen"); jButtonGenerateGuid.addActionListener(this); } @@ -260,7 +261,7 @@ public class Clone extends IDialog { private JComboBox getJComboBoxExistingPackage() { if (jComboBoxExistingPackage == null) { jComboBoxExistingPackage = new JComboBox(); - jComboBoxExistingPackage.setBounds(new java.awt.Rectangle(160, 85, 320, 20)); + jComboBoxExistingPackage.setBounds(new java.awt.Rectangle(210, 60, 320, 20)); } return jComboBoxExistingPackage; } @@ -315,7 +316,7 @@ public class Clone extends IDialog { * @return void */ private void init() { - this.setSize(493, 260); + this.setSize(550, 260); this.setContentPane(getJContentPane()); this.setTitle("Clone"); this.centerWindow(); @@ -330,28 +331,36 @@ public class Clone extends IDialog { init(); if (mode == DataType.RETURN_TYPE_MODULE_SURFACE_AREA) { this.jTextFieldType.setText(DataType.MODULE_SURFACE_AREA); - this.jTextFieldSource.setText(oldId.getPath()); + String s = oldId.getPath(); + s = Tools.getRelativePath(s, Tools.getFilePathOnly(wt.getPackageIdByModuleId(oldId).getPath())); + this.jTextFieldSource.setText(Tools.convertPathToCurrentOsType(s)); initExistingPackage(); - this.jButtonBrowse.setEnabled(false); - this.jTextFieldFilePath.setToolTipText("Input module name here. For example, Application\\HelloWorld\\HelloWorld.msa"); - this.jLabelDestinationFile.setText("Module Path\\Name"); + this.jButtonBrowse.setVisible(false); + this.jTextFieldFilePath + .setToolTipText("Input module name here. For example, Application\\HelloWorld\\HelloWorld.msa"); + this.jTextFieldFilePath.setSize(320, this.jTextFieldFilePath.getSize().height); + this.jLabelDestinationFile.setText("New Module Path and Filename"); } if (mode == DataType.RETURN_TYPE_PACKAGE_SURFACE_AREA) { this.jTextFieldType.setText(DataType.PACKAGE_SURFACE_AREA); - this.jTextFieldSource.setText(oldId.getPath()); + String s = oldId.getPath(); + s = Tools.getRelativePath(oldId.getPath(), Workspace.getCurrentWorkspace()); + this.jTextFieldSource.setText(Tools.convertPathToCurrentOsType(s)); this.jLabelBelong.setEnabled(false); this.jComboBoxExistingPackage.setEnabled(false); - this.jButtonBrowse.setEnabled(false); + this.jButtonBrowse.setVisible(false); this.jTextFieldFilePath.setToolTipText("Input package name here. For example, MdePkg\\MdePkg.fpd"); - this.jLabelDestinationFile.setText("Package Path\\Name"); + this.jTextFieldFilePath.setSize(320, this.jTextFieldFilePath.getSize().height); + this.jLabelDestinationFile.setText("New Package Path and Filename"); } if (mode == DataType.RETURN_TYPE_PLATFORM_SURFACE_AREA) { this.jTextFieldType.setText(DataType.PLATFORM_SURFACE_AREA); this.jTextFieldSource.setText(oldId.getPath()); this.jLabelBelong.setEnabled(false); this.jComboBoxExistingPackage.setEnabled(false); - this.jTextFieldFilePath.setToolTipText("Select platform path here. For example, C:\\MyWorkspace\\EdkNt32Pkg\\Nt32.fpd"); - this.jLabelDestinationFile.setText("New Platform path"); + this.jTextFieldFilePath + .setToolTipText("Select platform path here. For example, C:\\MyWorkspace\\EdkNt32Pkg\\Nt32.fpd"); + this.jLabelDestinationFile.setText("New Platform Path and Filename"); } if (mode == DataType.RETURN_TYPE_WORKSPACE) { this.jTextFieldType.setText(DataType.WORKSPACE); @@ -366,7 +375,7 @@ public class Clone extends IDialog { this.jLabelVersion.setEnabled(false); this.jTextFieldVersion.setEnabled(false); this.jTextFieldFilePath.setToolTipText("Input workspace path here. For example, C:\\MyWorkspace"); - this.jLabelDestinationFile.setText("New Workspace path"); + this.jLabelDestinationFile.setText("New Workspace Path"); } } @@ -378,29 +387,29 @@ public class Clone extends IDialog { private JPanel getJContentPane() { if (jContentPane == null) { jLabelBelong = new JLabel(); - jLabelBelong.setBounds(new java.awt.Rectangle(15, 85, 140, 20)); + jLabelBelong.setBounds(new java.awt.Rectangle(15, 60, 190, 20)); jLabelBelong.setText("Clone to Package"); jLabelVersion = new JLabel(); - jLabelVersion.setBounds(new java.awt.Rectangle(15, 160, 140, 20)); + jLabelVersion.setBounds(new java.awt.Rectangle(15, 160, 190, 20)); jLabelVersion.setText("Version"); jLabelGuid = new JLabel(); - jLabelGuid.setBounds(new java.awt.Rectangle(15, 135, 140, 20)); + jLabelGuid.setBounds(new java.awt.Rectangle(15, 135, 190, 20)); jLabelGuid.setText("Guid"); jLabelBaseName = new JLabel(); - jLabelBaseName.setBounds(new java.awt.Rectangle(15, 110, 140, 20)); + jLabelBaseName.setBounds(new java.awt.Rectangle(15, 110, 190, 20)); jLabelBaseName.setText("Base Name"); jLabelDestinationFile = new JLabel(); - jLabelDestinationFile.setBounds(new java.awt.Rectangle(15, 60, 140, 20)); + jLabelDestinationFile.setBounds(new java.awt.Rectangle(15, 85, 190, 20)); jLabelDestinationFile.setText("Destination File Name"); jLabelSource = new JLabel(); - jLabelSource.setBounds(new java.awt.Rectangle(15, 35, 140, 20)); + jLabelSource.setBounds(new java.awt.Rectangle(15, 35, 190, 20)); jLabelSource.setText("Source"); jLabelType = new JLabel(); - jLabelType.setBounds(new java.awt.Rectangle(15, 10, 140, 20)); + jLabelType.setBounds(new java.awt.Rectangle(15, 10, 190, 20)); jLabelType.setText("Type"); jContentPane = new JPanel(); jContentPane.setLayout(null); - jContentPane.setSize(new java.awt.Dimension(490, 227)); + jContentPane.setSize(new java.awt.Dimension(540, 227)); jContentPane.add(jLabelType, null); jContentPane.add(getJTextFieldType(), null); jContentPane.add(jLabelSource, null); @@ -439,16 +448,16 @@ public class Clone extends IDialog { try { this.save(); } catch (IOException e) { + Log.wrn("Clone", e.getMessage()); Log.err("Clone", e.getMessage()); - e.printStackTrace(); return; } catch (XmlException e) { + Log.wrn("Clone", e.getMessage()); Log.err("Clone", e.getMessage()); - e.printStackTrace(); return; } catch (Exception e) { + Log.wrn("Clone", e.getMessage()); Log.err("Clone", e.getMessage()); - e.printStackTrace(); return; } } else { @@ -500,11 +509,11 @@ public class Clone extends IDialog { // Check Basename // if (isEmpty(this.jTextFieldBaseName.getText())) { - Log.err("Base Name couldn't be empty!"); + Log.wrn("Clone", "Base Name couldn't be empty!"); return false; } if (!DataValidation.isBaseName(this.jTextFieldBaseName.getText())) { - Log.err("Incorrect data type for Base Name"); + Log.wrn("Clone", "Incorrect data type for Base Name"); return false; } @@ -512,11 +521,11 @@ public class Clone extends IDialog { // Check Guid // if (isEmpty(this.jTextFieldGuid.getText())) { - Log.err("Guid couldn't be empty!"); + Log.wrn("Clone", "Guid couldn't be empty!"); return false; } if (!DataValidation.isGuid(this.jTextFieldGuid.getText())) { - Log.err("Incorrect data type for Guid"); + Log.wrn("Clone", "Incorrect data type for Guid"); return false; } @@ -524,11 +533,11 @@ public class Clone extends IDialog { // Check Version // if (isEmpty(this.jTextFieldVersion.getText())) { - Log.err("Version couldn't be empty!"); + Log.wrn("Clone", "Version couldn't be empty!"); return false; } if (!DataValidation.isVersion(this.jTextFieldVersion.getText())) { - Log.err("Incorrect data type for Version"); + Log.wrn("Clone", "Incorrect data type for Version"); return false; } @@ -550,7 +559,7 @@ public class Clone extends IDialog { **/ private boolean check() { - String src = this.jTextFieldSource.getText(); + String src = this.oldId.getPath(); String trg = this.jTextFieldFilePath.getText(); File srcFile = new File(src); File trgFile = new File(trg); @@ -559,19 +568,19 @@ public class Clone extends IDialog { // Common Check // if (!srcFile.exists()) { - Log.err("The source doesn't exist"); + Log.wrn("Clone", "The source doesn't exist"); return false; } if (isEmpty(trg)) { - Log.err("The destination file path couldn't be empty"); + Log.wrn("Clone", "The destination file path couldn't be empty"); return false; } if (src.equals(trg)) { - Log.err("The source and destination couldn't be same"); + Log.wrn("Clone", "The source and destination couldn't be same"); return false; } if (trgFile.exists()) { - Log.err("The destination already exists"); + Log.wrn("Clone", "The destination already exists"); return false; } @@ -580,7 +589,7 @@ public class Clone extends IDialog { // if (mode == DataType.RETURN_TYPE_WORKSPACE) { if (trg.indexOf(src + DataType.FILE_SEPARATOR) == 0) { - Log.err("The new workspace couldn't be in current workspace!"); + Log.wrn("Clone", "The new workspace couldn't be in current workspace!"); return false; } } @@ -589,6 +598,20 @@ public class Clone extends IDialog { // Check for Module // if (mode == DataType.RETURN_TYPE_MODULE_SURFACE_AREA) { + // if (trg.indexOf(DataType.DOS_FILE_SEPARATOR) == -1 && trg.indexOf(DataType.UNIX_FILE_SEPARATOR) == -1) { + // Log.err("The module name must include a path"); + // return false; + // } + trg = this.getModulePath(); + if (src.equals(trg)) { + Log.wrn("Clone", "The source and destination couldn't be same"); + return false; + } + trgFile = new File(trg); + if (trgFile.exists()) { + Log.wrn("Clone", "The target module already exists"); + return false; + } return checkId(); } @@ -597,17 +620,17 @@ public class Clone extends IDialog { // if (mode == DataType.RETURN_TYPE_PACKAGE_SURFACE_AREA) { if (trg.indexOf(DataType.DOS_FILE_SEPARATOR) == -1 && trg.indexOf(DataType.UNIX_FILE_SEPARATOR) == -1) { - Log.err("The package name must include a path"); + Log.wrn("Clone", "The package name must include a path"); return false; } trg = this.getPackagePath(); if (Tools.getFilePathOnly(src).equals(Tools.getFilePathOnly(trg))) { - Log.err("The source and destination couldn't be same"); + Log.wrn("Clone", "The source and destination couldn't be same"); return false; } trgFile = new File(trg); if (trgFile.exists()) { - Log.err("The target package already exists"); + Log.wrn("Clone", "The target package already exists"); return false; } return checkId(); @@ -618,12 +641,12 @@ public class Clone extends IDialog { // if (mode == DataType.RETURN_TYPE_PLATFORM_SURFACE_AREA) { if (trg.indexOf(Workspace.getCurrentWorkspace()) != 0) { - Log.err("The target platform must be in current workspace"); + Log.wrn("Clone", "The target platform must be in current workspace"); return false; } trgFile = new File(trg); if (trgFile.exists()) { - Log.err("The target platform already exists"); + Log.wrn("Clone", "The target platform already exists"); return false; } return checkId(); @@ -633,20 +656,15 @@ public class Clone extends IDialog { } private void save() throws IOException, XmlException, Exception { - String src = this.jTextFieldSource.getText(); + String src = this.oldId.getPath(); String trg = this.jTextFieldFilePath.getText(); - + Vector vFiles = new Vector(); + // // Clone Workspace // if (mode == DataType.RETURN_TYPE_WORKSPACE) { - try { - FileOperation.copyFolder(src, trg); - } catch (Exception e) { - this.returnType = DataType.RETURN_TYPE_CANCEL; - Log.err("Clone Workspace", e.getMessage()); - e.printStackTrace(); - } + FileOperation.copyFolder(src, trg); this.returnType = DataType.RETURN_TYPE_WORKSPACE; } @@ -659,16 +677,17 @@ public class Clone extends IDialog { // trg = getModulePath(); newId.setPath(trg); - - // - // First copy all files to new directory - // - FileOperation.copyFolder(Tools.getFilePathOnly(src), Tools.getFilePathOnly(trg)); + vFiles = wt.getAllModuleFilesPath(src); // - // Delete old spd file + // First copy all files to new directory // - FileOperation.delFile(Tools.getFilePathOnly(trg) + DataType.FILE_SEPARATOR + Tools.getFileNameOnly(src)); + FileOperation.copyFile(src, trg); + for (int index = 1; index < vFiles.size(); index++) { + String oldFile = vFiles.get(index); + String newFile = vFiles.get(index).replace(Tools.getFilePathOnly(src), Tools.getFilePathOnly(trg)); + FileOperation.copyFile(oldFile, newFile); + } // // Create new msa file @@ -687,7 +706,7 @@ public class Clone extends IDialog { // Update Cloned From element // updateModuleClonedId(msa, oldId); - + // // Save to file // @@ -696,14 +715,15 @@ public class Clone extends IDialog { // // Update to platformId // - this.setMid(new ModuleIdentification(newId, packages.elementAt(this.jComboBoxExistingPackage.getSelectedIndex()))); + this.setMid(new ModuleIdentification(newId, + packages.elementAt(this.jComboBoxExistingPackage.getSelectedIndex()))); // // Open belonging package // PackageSurfaceArea psa = PackageSurfaceArea.Factory.newInstance(); psa = OpenFile.openSpdFile(mid.getPackageId().getPath()); - + // // Update the db file // @@ -721,16 +741,24 @@ public class Clone extends IDialog { // trg = this.getPackagePath(); newId.setPath(trg); - + vFiles = wt.getAllPakcageFilesPath(src); + + FileOperation.copyFile(src, trg); + for (int index = 1; index < vFiles.size(); index++) { + String oldFile = vFiles.get(index); + String newFile = vFiles.get(index).replace(Tools.getFilePathOnly(src), Tools.getFilePathOnly(trg)); + FileOperation.copyFile(oldFile, newFile); + } + // // First copy all files to new directory // - FileOperation.copyFolder(Tools.getFilePathOnly(src), Tools.getFilePathOnly(trg)); + //FileOperation.copyFolder(Tools.getFilePathOnly(src), Tools.getFilePathOnly(trg)); // // Delete old spd file // - FileOperation.delFile(Tools.getFilePathOnly(trg) + DataType.FILE_SEPARATOR + Tools.getFileNameOnly(src)); + //FileOperation.delFile(Tools.getFilePathOnly(trg) + DataType.FILE_SEPARATOR + Tools.getFileNameOnly(src)); // // Create new spd file @@ -749,7 +777,7 @@ public class Clone extends IDialog { // Update Cloned From element // updatePackageClonedId(spd, oldId); - + // // Save to file // @@ -804,8 +832,9 @@ public class Clone extends IDialog { this.returnType = DataType.RETURN_TYPE_PLATFORM_SURFACE_AREA; } + vFiles = null; } - + private String getSelectPackagePath() { return Tools.getFilePathOnly(packages.elementAt(this.jComboBoxExistingPackage.getSelectedIndex()).getPath()); } @@ -813,19 +842,19 @@ public class Clone extends IDialog { private String getModulePath() { String trg = this.jTextFieldFilePath.getText(); trg = Tools.addPathExt(trg, mode); - trg = getSelectPackagePath() + DataType.FILE_SEPARATOR + trg; + trg = Tools.addFileSeparator(getSelectPackagePath()) + trg; Tools.convertPathToCurrentOsType(trg); return trg; } - + private String getPackagePath() { String trg = this.jTextFieldFilePath.getText(); trg = Tools.addPathExt(trg, mode); - trg = Workspace.getCurrentWorkspace() + DataType.FILE_SEPARATOR + trg; + trg = Tools.addFileSeparator(Workspace.getCurrentWorkspace()) + trg; trg = Tools.convertPathToCurrentOsType(trg); return trg; } - + /** Set target item's Cloned From element @@ -849,10 +878,18 @@ public class Clone extends IDialog { // Get ClonedFrom then // ModuleDefinitions.ClonedFrom cf = null; + BigInteger count = new BigInteger("-1"); if (pd.getClonedFrom() == null) { cf = ModuleDefinitions.ClonedFrom.Factory.newInstance(); } else { cf = pd.getClonedFrom(); + if (cf != null) { + for (int index = 0; index < cf.getClonedList().size(); index++) { + if (cf.getClonedList().get(index).getId() != null) { + count = count.max(cf.getClonedList().get(index).getId()); + } + } + } } // @@ -861,6 +898,13 @@ public class Clone extends IDialog { ModuleDefinitions.ClonedFrom.Cloned c = ModuleDefinitions.ClonedFrom.Cloned.Factory.newInstance(); c.setModuleGuid(id.getGuid()); c.setModuleVersion(id.getVersion()); + c.setPackageGuid(wt.getPackageIdByModuleId(oldId).getGuid()); + c.setPackageVersion(wt.getPackageIdByModuleId(oldId).getVersion()); + c.setId(count.add(new BigInteger("1"))); + String guid = wt.getModuleFarGuid(oldId); + if (guid != null && !guid.equals("")) { + c.setFarGuid(guid); + } cf.addNewCloned(); cf.setClonedArray(cf.getClonedList().size() - 1, c); @@ -892,10 +936,18 @@ public class Clone extends IDialog { // Get ClonedFrom then // PackageDefinitions.ClonedFrom cf = null; + BigInteger count = new BigInteger("-1"); if (pd.getClonedFrom() == null) { cf = PackageDefinitions.ClonedFrom.Factory.newInstance(); } else { cf = pd.getClonedFrom(); + if (cf != null) { + for (int index = 0; index < cf.getClonedList().size(); index++) { + if (cf.getClonedList().get(index).getId() != null) { + count = count.max(cf.getClonedList().get(index).getId()); + } + } + } } // @@ -904,6 +956,11 @@ public class Clone extends IDialog { PackageDefinitions.ClonedFrom.Cloned c = PackageDefinitions.ClonedFrom.Cloned.Factory.newInstance(); c.setPackageGuid(id.getGuid()); c.setPackageVersion(id.getVersion()); + c.setId(count.add(new BigInteger("1"))); + String guid = wt.getModuleFarGuid(oldId); + if (guid != null && !guid.equals("")) { + c.setFarGuid(guid); + } cf.addNewCloned(); cf.setClonedArray(cf.getClonedList().size() - 1, c); @@ -935,10 +992,18 @@ public class Clone extends IDialog { // Get ClonedFrom then // PlatformDefinitions.ClonedFrom cf = null; + BigInteger count = new BigInteger("-1"); if (pd.getClonedFrom() == null) { cf = PlatformDefinitions.ClonedFrom.Factory.newInstance(); } else { cf = pd.getClonedFrom(); + if (cf != null) { + for (int index = 0; index < cf.getClonedList().size(); index++) { + if (cf.getClonedList().get(index).getId() != null) { + count = count.max(cf.getClonedList().get(index).getId()); + } + } + } } // @@ -947,6 +1012,11 @@ public class Clone extends IDialog { PlatformDefinitions.ClonedFrom.Cloned c = PlatformDefinitions.ClonedFrom.Cloned.Factory.newInstance(); c.setPlatformGuid(id.getGuid()); c.setPlatformVersion(id.getVersion()); + c.setId(count.add(new BigInteger("1"))); + String guid = wt.getModuleFarGuid(oldId); + if (guid != null && !guid.equals("")) { + c.setFarGuid(guid); + } cf.addNewCloned(); cf.setClonedArray(cf.getClonedList().size() - 1, c);