]> git.proxmox.com Git - mirror_edk2.git/blame - Tools/Java/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/Clone.java
1. Fix EDKT408: Clone a library class does not copy the library head
[mirror_edk2.git] / Tools / Java / Source / FrameworkWizard / src / org / tianocore / frameworkwizard / Clone.java
CommitLineData
a13899c5 1/** @file\r
2 \r
3 The file is used to clone workspace, module, package and platform\r
4 \r
5 Copyright (c) 2006, Intel Corporation\r
6 All rights reserved. This program and the accompanying materials\r
7 are licensed and made available under the terms and conditions of the BSD License\r
8 which accompanies this distribution. The full text of the license may be found at\r
9 http://opensource.org/licenses/bsd-license.php\r
10 \r
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
13 \r
14 **/\r
15package org.tianocore.frameworkwizard;\r
16\r
17import java.awt.event.ActionEvent;\r
18import java.io.File;\r
19import java.io.IOException;\r
79cb6fdb 20import java.math.BigInteger;\r
a13899c5 21import java.util.Vector;\r
22\r
23import javax.swing.JFileChooser;\r
24import javax.swing.JPanel;\r
25import javax.swing.JLabel;\r
26import javax.swing.JTextField;\r
27import javax.swing.JButton;\r
28\r
29import org.apache.xmlbeans.XmlException;\r
30import org.tianocore.ModuleDefinitionsDocument.ModuleDefinitions;\r
31import org.tianocore.ModuleSurfaceAreaDocument.ModuleSurfaceArea;\r
32import org.tianocore.PackageDefinitionsDocument.PackageDefinitions;\r
33import org.tianocore.PackageSurfaceAreaDocument.PackageSurfaceArea;\r
34import org.tianocore.PlatformDefinitionsDocument.PlatformDefinitions;\r
35import org.tianocore.PlatformSurfaceAreaDocument.PlatformSurfaceArea;\r
36import org.tianocore.frameworkwizard.common.DataType;\r
37import org.tianocore.frameworkwizard.common.DataValidation;\r
38import org.tianocore.frameworkwizard.common.FileOperation;\r
09ef9242 39import org.tianocore.frameworkwizard.common.GlobalData;\r
a13899c5 40import org.tianocore.frameworkwizard.common.IFileFilter;\r
a13899c5 41import org.tianocore.frameworkwizard.common.Log;\r
f9d0ab92 42import org.tianocore.frameworkwizard.common.OpenFile;\r
a13899c5 43import org.tianocore.frameworkwizard.common.SaveFile;\r
44import org.tianocore.frameworkwizard.common.Tools;\r
79cb6fdb 45import org.tianocore.frameworkwizard.common.Identifications.Identification;\r
a13899c5 46import org.tianocore.frameworkwizard.common.ui.IDialog;\r
47import org.tianocore.frameworkwizard.common.ui.IFrame;\r
79cb6fdb 48import org.tianocore.frameworkwizard.module.Identifications.ModuleIdentification;\r
a13899c5 49import org.tianocore.frameworkwizard.packaging.PackageIdentification;\r
50import org.tianocore.frameworkwizard.platform.PlatformIdentification;\r
51import org.tianocore.frameworkwizard.workspace.Workspace;\r
52import org.tianocore.frameworkwizard.workspace.WorkspaceTools;\r
53import javax.swing.JComboBox;\r
54\r
43dc3851 55/**\r
56 The class is used to provide functions to clone workspace, module, package and platform\r
57 It extends IDialog\r
58\r
59 **/\r
a13899c5 60public class Clone extends IDialog {\r
61\r
43dc3851 62 ///\r
63 /// Define Class Serial Version UID\r
64 ///\r
a13899c5 65 private static final long serialVersionUID = -5469299324965727137L;\r
66\r
43dc3851 67 ///\r
68 /// Define Class Members\r
69 ///\r
a13899c5 70 private JPanel jContentPane = null;\r
71\r
72 private JLabel jLabelType = null;\r
73\r
74 private JTextField jTextFieldType = null;\r
75\r
76 private JLabel jLabelSource = null;\r
77\r
78 private JTextField jTextFieldSource = null;\r
79\r
80 private JButton jButtonBrowse = null;\r
81\r
82 private JLabel jLabelDestinationFile = null;\r
83\r
84 private JTextField jTextFieldFilePath = null;\r
85\r
86 private JLabel jLabelBaseName = null;\r
87\r
88 private JTextField jTextFieldBaseName = null;\r
89\r
90 private JLabel jLabelGuid = null;\r
91\r
92 private JTextField jTextFieldGuid = null;\r
93\r
94 private JLabel jLabelVersion = null;\r
95\r
96 private JTextField jTextFieldVersion = null;\r
97\r
98 private JButton jButtonOk = null;\r
99\r
100 private JButton jButtonCancel = null;\r
101\r
102 private JButton jButtonGenerateGuid = null;\r
103\r
43dc3851 104 private JLabel jLabelBelong = null;\r
105\r
106 private JComboBox jComboBoxExistingPackage = null;\r
107\r
108 ///\r
109 /// Define members not for UI\r
110 ///\r
111\r
a13899c5 112 private int mode = -1;\r
113\r
114 private Vector<PackageIdentification> packages = null;\r
115\r
116 private WorkspaceTools wt = new WorkspaceTools();\r
117\r
a13899c5 118 private Identification oldId = null;\r
119\r
120 private Identification newId = null;\r
121\r
122 private ModuleIdentification mid = null;\r
123\r
124 private PackageIdentification pid = null;\r
125\r
126 private PlatformIdentification fid = null;\r
127\r
128 /**\r
43dc3851 129 This method initializes jTextFieldType \r
130 \r
131 @return javax.swing.JTextField\r
132 \r
133 **/\r
a13899c5 134 private JTextField getJTextFieldType() {\r
135 if (jTextFieldType == null) {\r
136 jTextFieldType = new JTextField();\r
55a2762d 137 jTextFieldType.setBounds(new java.awt.Rectangle(210, 10, 320, 20));\r
a13899c5 138 jTextFieldType.setEditable(false);\r
139 }\r
140 return jTextFieldType;\r
141 }\r
142\r
143 /**\r
43dc3851 144 This method initializes jTextFieldSource \r
145 \r
146 @return javax.swing.JTextField \r
147 \r
148 **/\r
a13899c5 149 private JTextField getJTextFieldSource() {\r
150 if (jTextFieldSource == null) {\r
151 jTextFieldSource = new JTextField();\r
55a2762d 152 jTextFieldSource.setBounds(new java.awt.Rectangle(210, 35, 320, 20));\r
a13899c5 153 jTextFieldSource.setEditable(false);\r
154 }\r
155 return jTextFieldSource;\r
156 }\r
157\r
158 /**\r
43dc3851 159 This method initializes jButtonBrowse \r
160 \r
161 @return javax.swing.JButton \r
162 \r
163 **/\r
a13899c5 164 private JButton getJButtonBrowse() {\r
165 if (jButtonBrowse == null) {\r
166 jButtonBrowse = new JButton();\r
55a2762d 167 jButtonBrowse.setBounds(new java.awt.Rectangle(445, 85, 85, 20));\r
a13899c5 168 jButtonBrowse.setText("Browse");\r
169 jButtonBrowse.addActionListener(this);\r
170 }\r
171 return jButtonBrowse;\r
172 }\r
173\r
174 /**\r
43dc3851 175 This method initializes jTextFieldDestinationFile \r
176 \r
177 @return javax.swing.JTextField \r
178 \r
179 **/\r
a13899c5 180 private JTextField getJTextFieldFilePath() {\r
181 if (jTextFieldFilePath == null) {\r
182 jTextFieldFilePath = new JTextField();\r
55a2762d 183 jTextFieldFilePath.setBounds(new java.awt.Rectangle(210, 85, 230, 20));\r
a13899c5 184 }\r
185 return jTextFieldFilePath;\r
186 }\r
187\r
188 /**\r
43dc3851 189 This method initializes jTextFieldBaseName \r
190 \r
191 @return javax.swing.JTextField \r
192 \r
193 **/\r
a13899c5 194 private JTextField getJTextFieldBaseName() {\r
195 if (jTextFieldBaseName == null) {\r
196 jTextFieldBaseName = new JTextField();\r
55a2762d 197 jTextFieldBaseName.setBounds(new java.awt.Rectangle(210, 110, 320, 20));\r
a13899c5 198 }\r
199 return jTextFieldBaseName;\r
200 }\r
201\r
202 /**\r
43dc3851 203 This method initializes jTextFieldGuid \r
204 \r
205 @return javax.swing.JTextField \r
206 \r
207 **/\r
a13899c5 208 private JTextField getJTextFieldGuid() {\r
209 if (jTextFieldGuid == null) {\r
210 jTextFieldGuid = new JTextField();\r
55a2762d 211 jTextFieldGuid.setBounds(new java.awt.Rectangle(210, 135, 230, 20));\r
a13899c5 212 }\r
213 return jTextFieldGuid;\r
214 }\r
215\r
216 /**\r
43dc3851 217 This method initializes jTextFieldVersion \r
218 \r
219 @return javax.swing.JTextField \r
220 \r
221 **/\r
a13899c5 222 private JTextField getJTextFieldVersion() {\r
223 if (jTextFieldVersion == null) {\r
224 jTextFieldVersion = new JTextField();\r
55a2762d 225 jTextFieldVersion.setBounds(new java.awt.Rectangle(210, 160, 320, 20));\r
a13899c5 226 }\r
227 return jTextFieldVersion;\r
228 }\r
229\r
230 /**\r
43dc3851 231 This method initializes jButtonOk \r
232 \r
233 @return javax.swing.JButton \r
234 \r
235 **/\r
a13899c5 236 private JButton getJButtonOk() {\r
237 if (jButtonOk == null) {\r
238 jButtonOk = new JButton();\r
55a2762d 239 jButtonOk.setBounds(new java.awt.Rectangle(285, 200, 90, 20));\r
a13899c5 240 jButtonOk.setText("Ok");\r
241 jButtonOk.addActionListener(this);\r
242 }\r
243 return jButtonOk;\r
244 }\r
245\r
246 /**\r
43dc3851 247 This method initializes jButtonCancel \r
248 \r
249 @return javax.swing.JButton \r
250 \r
251 **/\r
a13899c5 252 private JButton getJButtonCancel() {\r
253 if (jButtonCancel == null) {\r
254 jButtonCancel = new JButton();\r
55a2762d 255 jButtonCancel.setBounds(new java.awt.Rectangle(405, 200, 90, 20));\r
a13899c5 256 jButtonCancel.setText("Cancel");\r
257 jButtonCancel.addActionListener(this);\r
258 }\r
259 return jButtonCancel;\r
260 }\r
261\r
262 /**\r
43dc3851 263 This method initializes jButtonGenerateGuid \r
264 \r
265 @return javax.swing.JButton \r
266 \r
267 **/\r
a13899c5 268 private JButton getJButtonGenerateGuid() {\r
269 if (jButtonGenerateGuid == null) {\r
270 jButtonGenerateGuid = new JButton();\r
55a2762d 271 jButtonGenerateGuid.setBounds(new java.awt.Rectangle(445, 135, 85, 20));\r
a13899c5 272 jButtonGenerateGuid.setText("Gen");\r
273 jButtonGenerateGuid.addActionListener(this);\r
274 }\r
275 return jButtonGenerateGuid;\r
276 }\r
277\r
278 /**\r
43dc3851 279 This method initializes jComboBoxExistingPackage \r
280 \r
281 @return javax.swing.JComboBox \r
282 \r
283 **/\r
a13899c5 284 private JComboBox getJComboBoxExistingPackage() {\r
285 if (jComboBoxExistingPackage == null) {\r
286 jComboBoxExistingPackage = new JComboBox();\r
55a2762d 287 jComboBoxExistingPackage.setBounds(new java.awt.Rectangle(210, 60, 320, 20));\r
a13899c5 288 }\r
289 return jComboBoxExistingPackage;\r
290 }\r
291\r
292 /**\r
43dc3851 293 This is the default constructor\r
a13899c5 294 \r
295 **/\r
a13899c5 296 public Clone() {\r
297 super();\r
298 init();\r
299 }\r
300\r
301 /**\r
43dc3851 302 This is the override constructor\r
303 \r
304 @param parentFrame The parent frame which starts this frame\r
305 @param modal To identify the frame's modal\r
306 @param fileType To identify the clone target type\r
307 @param identification The clone target's identification\r
a13899c5 308 \r
309 **/\r
310 public Clone(IFrame parentFrame, boolean modal, int fileType, Identification identification) {\r
311 super(parentFrame, modal);\r
312 this.mode = fileType;\r
313 if (identification != null) {\r
314 this.oldId = new Identification(identification.getName(), identification.getGuid(),\r
315 identification.getVersion(), identification.getPath());\r
316 this.newId = new Identification(identification.getName(), identification.getGuid(),\r
317 identification.getVersion(), identification.getPath());\r
318 }\r
319 init(mode);\r
320 }\r
321\r
322 /**\r
323 Query all existing packages and fill them into combox\r
324 \r
325 **/\r
326 private void initExistingPackage() {\r
327 packages = wt.getAllPackages();\r
328 for (int index = 0; index < packages.size(); index++) {\r
329 this.jComboBoxExistingPackage.addItem(packages.elementAt(index).getName());\r
330 }\r
331 }\r
332\r
333 /**\r
43dc3851 334 This method initializes this\r
335 \r
336 **/\r
a13899c5 337 private void init() {\r
55a2762d 338 this.setSize(550, 260);\r
a13899c5 339 this.setContentPane(getJContentPane());\r
340 this.setTitle("Clone");\r
341 this.centerWindow();\r
342 }\r
343\r
344 /**\r
43dc3851 345 This method initializes this with given clone target type.\r
346 Customize the frame interface via different clone target type.\r
347 \r
348 @param mode To identify the clone target type\r
349 \r
350 **/\r
a13899c5 351 private void init(int mode) {\r
352 init();\r
43dc3851 353 //\r
354 // For MODULE_SURFACE_AREA\r
355 //\r
a13899c5 356 if (mode == DataType.RETURN_TYPE_MODULE_SURFACE_AREA) {\r
357 this.jTextFieldType.setText(DataType.MODULE_SURFACE_AREA);\r
55a2762d 358 String s = oldId.getPath();\r
359 s = Tools.getRelativePath(s, Tools.getFilePathOnly(wt.getPackageIdByModuleId(oldId).getPath()));\r
360 this.jTextFieldSource.setText(Tools.convertPathToCurrentOsType(s));\r
a13899c5 361 initExistingPackage();\r
55a2762d 362 this.jButtonBrowse.setVisible(false);\r
ed1665f2 363 this.jTextFieldFilePath\r
72a0d8e6 364 .setToolTipText("<html>Input the module's relative path and filename, for example:<br>Application\\HelloWorld\\HelloWorld.msa</html>");\r
55a2762d 365 this.jTextFieldFilePath.setSize(320, this.jTextFieldFilePath.getSize().height);\r
366 this.jLabelDestinationFile.setText("New Module Path and Filename");\r
a13899c5 367 }\r
43dc3851 368 //\r
369 // For PACKAGE_SURFACE_AREA\r
370 //\r
a13899c5 371 if (mode == DataType.RETURN_TYPE_PACKAGE_SURFACE_AREA) {\r
372 this.jTextFieldType.setText(DataType.PACKAGE_SURFACE_AREA);\r
55a2762d 373 String s = oldId.getPath();\r
374 s = Tools.getRelativePath(oldId.getPath(), Workspace.getCurrentWorkspace());\r
375 this.jTextFieldSource.setText(Tools.convertPathToCurrentOsType(s));\r
a13899c5 376 this.jLabelBelong.setEnabled(false);\r
377 this.jComboBoxExistingPackage.setEnabled(false);\r
55a2762d 378 this.jButtonBrowse.setVisible(false);\r
37bd8fbb 379 this.jTextFieldFilePath\r
380 .setToolTipText("<html>Input the package's relative path and file name, for example:<br>MdePkg\\MdePkg.spd</html>");\r
55a2762d 381 this.jTextFieldFilePath.setSize(320, this.jTextFieldFilePath.getSize().height);\r
382 this.jLabelDestinationFile.setText("New Package Path and Filename");\r
a13899c5 383 }\r
43dc3851 384 //\r
385 // For PLATFORM_SURFACE_AREA\r
386 //\r
a13899c5 387 if (mode == DataType.RETURN_TYPE_PLATFORM_SURFACE_AREA) {\r
388 this.jTextFieldType.setText(DataType.PLATFORM_SURFACE_AREA);\r
389 this.jTextFieldSource.setText(oldId.getPath());\r
390 this.jLabelBelong.setEnabled(false);\r
391 this.jComboBoxExistingPackage.setEnabled(false);\r
ed1665f2 392 this.jTextFieldFilePath\r
72a0d8e6 393 .setToolTipText("<html>Select the platform's relative path and filename. For example:<br>C:\\MyWorkspace\\EdkNt32Pkg\\Nt32.fpd</html>");\r
55a2762d 394 this.jLabelDestinationFile.setText("New Platform Path and Filename");\r
a13899c5 395 }\r
43dc3851 396 //\r
397 // For WORKSPACE\r
398 //\r
a13899c5 399 if (mode == DataType.RETURN_TYPE_WORKSPACE) {\r
400 this.jTextFieldType.setText(DataType.WORKSPACE);\r
401 this.jTextFieldSource.setText(Workspace.getCurrentWorkspace());\r
402 this.jLabelBelong.setEnabled(false);\r
403 this.jComboBoxExistingPackage.setEnabled(false);\r
404 this.jLabelBaseName.setEnabled(false);\r
405 this.jTextFieldBaseName.setEditable(false);\r
406 this.jLabelGuid.setEnabled(false);\r
407 this.jTextFieldGuid.setEnabled(false);\r
408 this.jButtonGenerateGuid.setEnabled(false);\r
409 this.jLabelVersion.setEnabled(false);\r
410 this.jTextFieldVersion.setEnabled(false);\r
37bd8fbb 411 this.jTextFieldFilePath\r
412 .setToolTipText("<html>Input the workspace path, for example:<br>C:\\MyWorkspace</html>");\r
55a2762d 413 this.jLabelDestinationFile.setText("New Workspace Path");\r
a13899c5 414 }\r
415 }\r
416\r
417 /**\r
43dc3851 418 This method initializes jContentPane\r
419 \r
420 @return javax.swing.JPanel\r
421 \r
422 **/\r
a13899c5 423 private JPanel getJContentPane() {\r
424 if (jContentPane == null) {\r
425 jLabelBelong = new JLabel();\r
55a2762d 426 jLabelBelong.setBounds(new java.awt.Rectangle(15, 60, 190, 20));\r
72a0d8e6 427 jLabelBelong.setText("Clone Package");\r
a13899c5 428 jLabelVersion = new JLabel();\r
55a2762d 429 jLabelVersion.setBounds(new java.awt.Rectangle(15, 160, 190, 20));\r
a13899c5 430 jLabelVersion.setText("Version");\r
431 jLabelGuid = new JLabel();\r
55a2762d 432 jLabelGuid.setBounds(new java.awt.Rectangle(15, 135, 190, 20));\r
a13899c5 433 jLabelGuid.setText("Guid");\r
434 jLabelBaseName = new JLabel();\r
55a2762d 435 jLabelBaseName.setBounds(new java.awt.Rectangle(15, 110, 190, 20));\r
a13899c5 436 jLabelBaseName.setText("Base Name");\r
437 jLabelDestinationFile = new JLabel();\r
55a2762d 438 jLabelDestinationFile.setBounds(new java.awt.Rectangle(15, 85, 190, 20));\r
a13899c5 439 jLabelDestinationFile.setText("Destination File Name");\r
440 jLabelSource = new JLabel();\r
55a2762d 441 jLabelSource.setBounds(new java.awt.Rectangle(15, 35, 190, 20));\r
a13899c5 442 jLabelSource.setText("Source");\r
443 jLabelType = new JLabel();\r
55a2762d 444 jLabelType.setBounds(new java.awt.Rectangle(15, 10, 190, 20));\r
a13899c5 445 jLabelType.setText("Type");\r
446 jContentPane = new JPanel();\r
447 jContentPane.setLayout(null);\r
55a2762d 448 jContentPane.setSize(new java.awt.Dimension(540, 227));\r
a13899c5 449 jContentPane.add(jLabelType, null);\r
450 jContentPane.add(getJTextFieldType(), null);\r
451 jContentPane.add(jLabelSource, null);\r
452 jContentPane.add(getJTextFieldSource(), null);\r
453 jContentPane.add(jLabelDestinationFile, null);\r
454 jContentPane.add(getJTextFieldFilePath(), null);\r
455 jContentPane.add(jLabelBaseName, null);\r
456 jContentPane.add(getJTextFieldBaseName(), null);\r
457 jContentPane.add(jLabelGuid, null);\r
458 jContentPane.add(getJTextFieldGuid(), null);\r
459 jContentPane.add(jLabelVersion, null);\r
460 jContentPane.add(getJTextFieldVersion(), null);\r
461 jContentPane.add(getJButtonOk(), null);\r
462 jContentPane.add(getJButtonCancel(), null);\r
463 jContentPane.add(getJButtonBrowse(), null);\r
464 jContentPane.add(getJButtonGenerateGuid(), null);\r
465 jContentPane.add(jLabelBelong, null);\r
466 jContentPane.add(getJComboBoxExistingPackage(), null);\r
467 }\r
468 return jContentPane;\r
469 }\r
470\r
471 /* (non-Javadoc)\r
472 * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)\r
473 * \r
474 * Override actionPerformed to listen all actions\r
475 */\r
476 public void actionPerformed(ActionEvent arg0) {\r
477 if (arg0.getSource() == jButtonCancel) {\r
478 this.setVisible(false);\r
479 this.returnType = DataType.RETURN_TYPE_CANCEL;\r
480 }\r
481\r
482 if (arg0.getSource() == jButtonOk) {\r
483 if (this.check()) {\r
484 try {\r
43dc3851 485 //\r
486 // Save to file\r
487 //\r
a13899c5 488 this.save();\r
489 } catch (IOException e) {\r
ed1665f2 490 Log.wrn("Clone", e.getMessage());\r
a13899c5 491 Log.err("Clone", e.getMessage());\r
a13899c5 492 return;\r
493 } catch (XmlException e) {\r
ed1665f2 494 Log.wrn("Clone", e.getMessage());\r
a13899c5 495 Log.err("Clone", e.getMessage());\r
a13899c5 496 return;\r
497 } catch (Exception e) {\r
ed1665f2 498 Log.wrn("Clone", e.getMessage());\r
a13899c5 499 Log.err("Clone", e.getMessage());\r
a13899c5 500 return;\r
501 }\r
502 } else {\r
503 return;\r
504 }\r
505 this.setVisible(false);\r
506 }\r
507\r
508 if (arg0.getSource() == this.jButtonGenerateGuid) {\r
509 this.jTextFieldGuid.setText(Tools.generateUuidString());\r
510 }\r
511\r
512 //\r
43dc3851 513 // Use different file ext for different clone target type\r
a13899c5 514 //\r
515 if (arg0.getSource() == this.jButtonBrowse) {\r
516 JFileChooser fc = new JFileChooser();\r
517 fc.setAcceptAllFileFilterUsed(false);\r
518\r
519 if (mode == DataType.RETURN_TYPE_WORKSPACE) {\r
520 fc.setCurrentDirectory(new File(Workspace.getCurrentWorkspace()));\r
521 fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);\r
522 }\r
523 if (mode == DataType.RETURN_TYPE_MODULE_SURFACE_AREA) {\r
524 fc.setCurrentDirectory(new File(packages.elementAt(this.jComboBoxExistingPackage.getSelectedIndex())\r
525 .getPath()));\r
526 fc.addChoosableFileFilter(new IFileFilter(DataType.MODULE_SURFACE_AREA_EXT));\r
527 }\r
528 if (mode == DataType.RETURN_TYPE_PACKAGE_SURFACE_AREA) {\r
529 fc.setCurrentDirectory(new File(Workspace.getCurrentWorkspace()));\r
530 fc.addChoosableFileFilter(new IFileFilter(DataType.PACKAGE_SURFACE_AREA_EXT));\r
531 }\r
532 if (mode == DataType.RETURN_TYPE_PLATFORM_SURFACE_AREA) {\r
533 fc.setCurrentDirectory(new File(Workspace.getCurrentWorkspace()));\r
534 fc.addChoosableFileFilter(new IFileFilter(DataType.PLATFORM_SURFACE_AREA_EXT));\r
535 }\r
536 int result = fc.showSaveDialog(new JPanel());\r
537 if (result == JFileChooser.APPROVE_OPTION) {\r
538 this.jTextFieldFilePath.setText(Tools.addPathExt(fc.getSelectedFile().getPath(), mode));\r
539 }\r
540 }\r
541 }\r
542\r
43dc3851 543 /**\r
544 Check name, guid and version.\r
545 If all of them are valid, save information to new id\r
546 \r
547 @retval true All name, guid and version are valid\r
548 @retval false Any one of name, guid and version is invalid\r
549 \r
550 **/\r
a13899c5 551 private boolean checkId() {\r
552 //\r
553 // Check Basename\r
554 //\r
555 if (isEmpty(this.jTextFieldBaseName.getText())) {\r
72a0d8e6 556 Log.wrn("Clone", "The Name is required!");\r
a13899c5 557 return false;\r
558 }\r
559 if (!DataValidation.isBaseName(this.jTextFieldBaseName.getText())) {\r
37bd8fbb 560 Log\r
561 .wrn("Clone",\r
562 "<html>Incorrect data type for the Name, it must<br>be a single word, starting with an alpha character.</html>");\r
a13899c5 563 return false;\r
564 }\r
565\r
566 //\r
567 // Check Guid\r
568 //\r
569 if (isEmpty(this.jTextFieldGuid.getText())) {\r
72a0d8e6 570 Log.wrn("Clone", "A Guid is required!!");\r
a13899c5 571 return false;\r
572 }\r
573 if (!DataValidation.isGuid(this.jTextFieldGuid.getText())) {\r
37bd8fbb 574 Log\r
575 .wrn(\r
576 "Clone",\r
577 "<html>Incorrect data type for Guid, which must<br>be in registry format (8-4-4-4-12) for example:<br>d3adb123-eef1-466d-39ac-02febcaf5997</html>");\r
a13899c5 578 return false;\r
579 }\r
580\r
581 //\r
582 // Check Version\r
583 //\r
584 if (isEmpty(this.jTextFieldVersion.getText())) {\r
72a0d8e6 585 Log.wrn("Clone", "A Version must be entered!");\r
a13899c5 586 return false;\r
587 }\r
588 if (!DataValidation.isVersion(this.jTextFieldVersion.getText())) {\r
37bd8fbb 589 Log\r
590 .wrn(\r
591 "Clone",\r
592 "<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>");\r
a13899c5 593 return false;\r
594 }\r
595\r
596 //\r
597 // Save information to id\r
598 //\r
599 newId.setName(this.jTextFieldBaseName.getText());\r
600 newId.setGuid(this.jTextFieldGuid.getText());\r
601 newId.setVersion(this.jTextFieldVersion.getText());\r
602 newId.setPath(this.jTextFieldFilePath.getText());\r
603\r
604 return true;\r
605 }\r
606\r
607 /**\r
608 Check before save\r
609 \r
43dc3851 610 @retval true All check points are passed\r
611 @retval false Any one of check points is failed\r
a13899c5 612 \r
613 **/\r
614 private boolean check() {\r
55a2762d 615 String src = this.oldId.getPath();\r
a13899c5 616 String trg = this.jTextFieldFilePath.getText();\r
617 File srcFile = new File(src);\r
618 File trgFile = new File(trg);\r
619\r
620 //\r
621 // Common Check\r
622 //\r
623 if (!srcFile.exists()) {\r
72a0d8e6 624 Log.wrn("Clone", "The source file does not exist!");\r
a13899c5 625 return false;\r
626 }\r
627 if (isEmpty(trg)) {\r
72a0d8e6 628 Log.wrn("Clone", "The destination file path must be entered!");\r
a13899c5 629 return false;\r
630 }\r
631 if (src.equals(trg)) {\r
72a0d8e6 632 Log.wrn("Clone", "The source and destination can not be same!");\r
a13899c5 633 return false;\r
634 }\r
635 if (trgFile.exists()) {\r
72a0d8e6 636 Log.wrn("Clone", "The destination already exists!");\r
a13899c5 637 return false;\r
638 }\r
639\r
640 //\r
641 // Check for workspace\r
642 //\r
643 if (mode == DataType.RETURN_TYPE_WORKSPACE) {\r
644 if (trg.indexOf(src + DataType.FILE_SEPARATOR) == 0) {\r
72a0d8e6 645 Log.wrn("Clone", "The new workspace can not be located within the current workspace!");\r
a13899c5 646 return false;\r
647 }\r
648 }\r
649\r
650 //\r
651 // Check for Module\r
652 //\r
653 if (mode == DataType.RETURN_TYPE_MODULE_SURFACE_AREA) {\r
79cb6fdb 654 trg = this.getModulePath();\r
655 if (src.equals(trg)) {\r
72a0d8e6 656 Log.wrn("Clone", "The source and destination paths for cloning a module must be different!");\r
79cb6fdb 657 return false;\r
658 }\r
659 trgFile = new File(trg);\r
660 if (trgFile.exists()) {\r
72a0d8e6 661 Log.wrn("Clone", "The target module already exists!");\r
79cb6fdb 662 return false;\r
663 }\r
a13899c5 664 return checkId();\r
665 }\r
666\r
667 //\r
668 // Check for Package\r
669 //\r
670 if (mode == DataType.RETURN_TYPE_PACKAGE_SURFACE_AREA) {\r
671 if (trg.indexOf(DataType.DOS_FILE_SEPARATOR) == -1 && trg.indexOf(DataType.UNIX_FILE_SEPARATOR) == -1) {\r
72a0d8e6 672 Log.wrn("Clone", "The package name must include a path!");\r
a13899c5 673 return false;\r
674 }\r
675 trg = this.getPackagePath();\r
676 if (Tools.getFilePathOnly(src).equals(Tools.getFilePathOnly(trg))) {\r
72a0d8e6 677 Log.wrn("Clone", "The source and destination paths for cloning a package must be different!");\r
a13899c5 678 return false;\r
679 }\r
680 trgFile = new File(trg);\r
681 if (trgFile.exists()) {\r
72a0d8e6 682 Log.wrn("Clone", "The target package already exists!");\r
a13899c5 683 return false;\r
684 }\r
685 return checkId();\r
686 }\r
687\r
688 //\r
689 // Check for Platform\r
690 //\r
691 if (mode == DataType.RETURN_TYPE_PLATFORM_SURFACE_AREA) {\r
692 if (trg.indexOf(Workspace.getCurrentWorkspace()) != 0) {\r
72a0d8e6 693 Log.wrn("Clone", "The platform clone must be located in the current workspace!");\r
a13899c5 694 return false;\r
695 }\r
696 trgFile = new File(trg);\r
697 if (trgFile.exists()) {\r
72a0d8e6 698 Log.wrn("Clone", "The target platform already exists.");\r
a13899c5 699 return false;\r
700 }\r
701 return checkId();\r
702 }\r
703\r
704 return true;\r
705 }\r
706\r
43dc3851 707 /**\r
708 Save clone target to new location\r
709 \r
710 @throws IOException\r
711 @throws XmlException\r
712 @throws Exception\r
713 \r
714 **/\r
a13899c5 715 private void save() throws IOException, XmlException, Exception {\r
55a2762d 716 String src = this.oldId.getPath();\r
a13899c5 717 String trg = this.jTextFieldFilePath.getText();\r
79cb6fdb 718 Vector<String> vFiles = new Vector<String>();\r
ed1665f2 719\r
a13899c5 720 //\r
721 // Clone Workspace\r
722 //\r
723 if (mode == DataType.RETURN_TYPE_WORKSPACE) {\r
ed1665f2 724 FileOperation.copyFolder(src, trg);\r
a13899c5 725 this.returnType = DataType.RETURN_TYPE_WORKSPACE;\r
726 }\r
727\r
728 //\r
729 // Clone Module Surface Area\r
730 //\r
731 if (mode == DataType.RETURN_TYPE_MODULE_SURFACE_AREA) {\r
732 //\r
733 // Get target path from source path\r
734 //\r
735 trg = getModulePath();\r
736 newId.setPath(trg);\r
739c6b04 737 vFiles = wt.getAllFilesPathOfModule(src);\r
ed1665f2 738\r
37bd8fbb 739 String oldPackagePath = GlobalData.openingModuleList.getIdByPath(src).getPackageId().getPath();\r
740 String newPackagePath = packages.elementAt(this.jComboBoxExistingPackage.getSelectedIndex()).getPath();\r
741\r
a13899c5 742 //\r
743 // First copy all files to new directory\r
744 //\r
79cb6fdb 745 FileOperation.copyFile(src, trg);\r
746 for (int index = 1; index < vFiles.size(); index++) {\r
747 String oldFile = vFiles.get(index);\r
37bd8fbb 748 String newFile = "";\r
749 if (oldFile.indexOf(Tools.getFilePathOnly(src)) > -1) {\r
750 //\r
751 // The file is not include header\r
752 //\r
753 newFile = oldFile.replace(Tools.getFilePathOnly(src), Tools.getFilePathOnly(trg));\r
754 } else if (oldFile.indexOf(Tools.getFilePathOnly(oldPackagePath)) > -1) {\r
755 //\r
756 // The file is include header\r
757 //\r
758 newFile = oldFile.replace(Tools.getFilePathOnly(oldPackagePath),\r
759 Tools.getFilePathOnly(newPackagePath));\r
760 }\r
761\r
79cb6fdb 762 FileOperation.copyFile(oldFile, newFile);\r
763 }\r
a13899c5 764\r
765 //\r
766 // Create new msa file\r
767 //\r
768 ModuleSurfaceArea msa = null;\r
769 msa = OpenFile.openMsaFile(src);\r
770\r
771 //\r
772 // Update to memory\r
773 //\r
774 msa.getMsaHeader().setModuleName(newId.getName());\r
775 msa.getMsaHeader().setGuidValue(newId.getGuid());\r
776 msa.getMsaHeader().setVersion(newId.getVersion());\r
777\r
778 //\r
43dc3851 779 // Update <Cloned> Section\r
a13899c5 780 //\r
781 updateModuleClonedId(msa, oldId);\r
37bd8fbb 782\r
a13899c5 783 //\r
784 // Save to file\r
785 //\r
786 SaveFile.saveMsaFile(trg, msa);\r
787\r
788 //\r
789 // Update to platformId\r
790 //\r
ed1665f2 791 this.setMid(new ModuleIdentification(newId,\r
792 packages.elementAt(this.jComboBoxExistingPackage.getSelectedIndex())));\r
a13899c5 793\r
794 //\r
795 // Open belonging package\r
796 //\r
797 PackageSurfaceArea psa = PackageSurfaceArea.Factory.newInstance();\r
798 psa = OpenFile.openSpdFile(mid.getPackageId().getPath());\r
ed1665f2 799\r
a13899c5 800 //\r
801 // Update the db file\r
802 //\r
803 wt.addModuleToPackage(mid, psa);\r
37bd8fbb 804\r
09ef9242 805 //\r
806 // Update GlobalData\r
807 //\r
808 GlobalData.vModuleList.addElement(mid);\r
809 GlobalData.openingModuleList.insertToOpeningModuleList(mid, msa);\r
a13899c5 810\r
811 this.returnType = DataType.RETURN_TYPE_MODULE_SURFACE_AREA;\r
812 }\r
813\r
814 //\r
815 // Clone Package Surface Area\r
816 //\r
817 if (mode == DataType.RETURN_TYPE_PACKAGE_SURFACE_AREA) {\r
818 //\r
819 // Get target path from source path\r
820 //\r
821 trg = this.getPackagePath();\r
822 newId.setPath(trg);\r
739c6b04 823 vFiles = wt.getAllFilesPathOfPakcage(src);\r
ed1665f2 824\r
43dc3851 825 //\r
826 // First copy all files to new directory\r
827 //\r
79cb6fdb 828 FileOperation.copyFile(src, trg);\r
829 for (int index = 1; index < vFiles.size(); index++) {\r
830 String oldFile = vFiles.get(index);\r
831 String newFile = vFiles.get(index).replace(Tools.getFilePathOnly(src), Tools.getFilePathOnly(trg));\r
832 FileOperation.copyFile(oldFile, newFile);\r
833 }\r
ed1665f2 834\r
a13899c5 835 //\r
836 // Create new spd file\r
837 //\r
838 PackageSurfaceArea spd = null;\r
839 spd = OpenFile.openSpdFile(src);\r
840\r
841 //\r
842 // Update to memory\r
843 //\r
844 spd.getSpdHeader().setPackageName(newId.getName());\r
845 spd.getSpdHeader().setGuidValue(newId.getGuid());\r
846 spd.getSpdHeader().setVersion(newId.getVersion());\r
847\r
848 //\r
43dc3851 849 // Update <Cloned> Section\r
a13899c5 850 //\r
851 updatePackageClonedId(spd, oldId);\r
ed1665f2 852\r
a13899c5 853 //\r
854 // Save to file\r
855 //\r
856 SaveFile.saveSpdFile(trg, spd);\r
857\r
858 //\r
859 // Update to platformId\r
860 //\r
861 this.setPid(new PackageIdentification(newId));\r
862\r
863 //\r
864 // Update the db file\r
865 //\r
866 wt.addPackageToDatabase(pid);\r
37bd8fbb 867\r
09ef9242 868 //\r
869 // Update GlobalData\r
870 //\r
871 GlobalData.vPackageList.addElement(pid);\r
872 GlobalData.openingPackageList.insertToOpeningPackageList(pid, spd);\r
37bd8fbb 873\r
4917d9dd 874 //\r
875 // Add all cloned modules\r
876 //\r
877 Vector<String> modulePaths = GlobalData.getAllModulesOfPackage(pid.getPath());\r
878 String modulePath = null;\r
879 ModuleSurfaceArea msa = null;\r
37bd8fbb 880\r
4917d9dd 881 for (int indexJ = 0; indexJ < modulePaths.size(); indexJ++) {\r
882 try {\r
883 modulePath = modulePaths.get(indexJ);\r
884 msa = OpenFile.openMsaFile(modulePath);\r
885 } catch (IOException e) {\r
886 Log.err("Open Module Surface Area " + modulePath, e.getMessage());\r
887 continue;\r
888 } catch (XmlException e) {\r
889 Log.err("Open Module Surface Area " + modulePath, e.getMessage());\r
890 continue;\r
891 } catch (Exception e) {\r
892 Log.err("Open Module Surface Area " + modulePath, "Invalid file type");\r
893 continue;\r
894 }\r
895 Identification id = Tools.getId(modulePath, msa);\r
896 mid = new ModuleIdentification(id, pid);\r
897 GlobalData.vModuleList.addElement(mid);\r
898 GlobalData.openingModuleList.insertToOpeningModuleList(mid, msa);\r
899 }\r
37bd8fbb 900\r
a13899c5 901 this.returnType = DataType.RETURN_TYPE_PACKAGE_SURFACE_AREA;\r
902 }\r
903\r
904 //\r
905 // Clone Platform Surface Area\r
906 //\r
907 if (mode == DataType.RETURN_TYPE_PLATFORM_SURFACE_AREA) {\r
908 PlatformSurfaceArea fpd = null;\r
909 fpd = OpenFile.openFpdFile(src);\r
910\r
911 //\r
912 // Update to memory\r
913 //\r
914 fpd.getPlatformHeader().setPlatformName(newId.getName());\r
915 fpd.getPlatformHeader().setGuidValue(newId.getGuid());\r
916 fpd.getPlatformHeader().setVersion(newId.getVersion());\r
917\r
918 //\r
919 // Update Cloned From element\r
920 //\r
921 updatePlatformClonedId(fpd, oldId);\r
922\r
923 //\r
924 // Save to file\r
925 //\r
926 SaveFile.saveFpdFile(trg, fpd);\r
927\r
928 //\r
929 // Update to platformId\r
930 //\r
931 this.setFid(new PlatformIdentification(newId));\r
932\r
933 //\r
934 // Update the db file\r
935 //\r
936 wt.addPlatformToDatabase(fid);\r
37bd8fbb 937\r
09ef9242 938 //\r
939 // Update GlobalData\r
940 //\r
941 GlobalData.vPlatformList.addElement(fid);\r
942 GlobalData.openingPlatformList.insertToOpeningPlatformList(fid, fpd);\r
a13899c5 943\r
944 this.returnType = DataType.RETURN_TYPE_PLATFORM_SURFACE_AREA;\r
945 }\r
79cb6fdb 946 vFiles = null;\r
a13899c5 947 }\r
ed1665f2 948\r
43dc3851 949 /**\r
950 Get the path of selected package\r
951 \r
952 @return String The path of selected package\r
953 \r
954 **/\r
a13899c5 955 private String getSelectPackagePath() {\r
956 return Tools.getFilePathOnly(packages.elementAt(this.jComboBoxExistingPackage.getSelectedIndex()).getPath());\r
957 }\r
958\r
43dc3851 959 /**\r
960 Get the path of source module\r
961 Since the path of source module is relative, make it up to full path.\r
962 \r
963 @return String The full path of source module\r
964 \r
965 **/\r
a13899c5 966 private String getModulePath() {\r
967 String trg = this.jTextFieldFilePath.getText();\r
968 trg = Tools.addPathExt(trg, mode);\r
79cb6fdb 969 trg = Tools.addFileSeparator(getSelectPackagePath()) + trg;\r
a13899c5 970 Tools.convertPathToCurrentOsType(trg);\r
971 return trg;\r
972 }\r
ed1665f2 973\r
43dc3851 974 /**\r
975 Get the path of source package\r
976 Since the path of source package is relative, make it up to full path.\r
977 \r
978 @return String The full path of source package\r
979 \r
980 **/\r
a13899c5 981 private String getPackagePath() {\r
982 String trg = this.jTextFieldFilePath.getText();\r
983 trg = Tools.addPathExt(trg, mode);\r
79cb6fdb 984 trg = Tools.addFileSeparator(Workspace.getCurrentWorkspace()) + trg;\r
a13899c5 985 trg = Tools.convertPathToCurrentOsType(trg);\r
986 return trg;\r
987 }\r
ed1665f2 988\r
a13899c5 989 /**\r
43dc3851 990 Set msa file's <Cloned> section via given identification\r
991 \r
992 @param msa ModuleSurfaceArea for clone target\r
993 @param id Identification of clone source\r
994 \r
a13899c5 995 **/\r
996 private void updateModuleClonedId(ModuleSurfaceArea msa, Identification id) {\r
997 //\r
998 // Get PlatformDefinitions First\r
999 //\r
1000 ModuleDefinitions pd = null;\r
1001 if (msa.getModuleDefinitions() == null) {\r
1002 pd = ModuleDefinitions.Factory.newInstance();\r
1003 msa.addNewModuleDefinitions();\r
1004 } else {\r
1005 pd = msa.getModuleDefinitions();\r
1006 }\r
1007\r
1008 //\r
1009 // Get ClonedFrom then\r
1010 //\r
1011 ModuleDefinitions.ClonedFrom cf = null;\r
79cb6fdb 1012 BigInteger count = new BigInteger("-1");\r
a13899c5 1013 if (pd.getClonedFrom() == null) {\r
1014 cf = ModuleDefinitions.ClonedFrom.Factory.newInstance();\r
1015 } else {\r
1016 cf = pd.getClonedFrom();\r
79cb6fdb 1017 if (cf != null) {\r
1018 for (int index = 0; index < cf.getClonedList().size(); index++) {\r
1019 if (cf.getClonedList().get(index).getId() != null) {\r
1020 count = count.max(cf.getClonedList().get(index).getId());\r
1021 }\r
1022 }\r
1023 }\r
a13899c5 1024 }\r
1025\r
1026 //\r
1027 // Set new Cloned item\r
1028 //\r
1029 ModuleDefinitions.ClonedFrom.Cloned c = ModuleDefinitions.ClonedFrom.Cloned.Factory.newInstance();\r
1030 c.setModuleGuid(id.getGuid());\r
1031 c.setModuleVersion(id.getVersion());\r
79cb6fdb 1032 c.setPackageGuid(wt.getPackageIdByModuleId(oldId).getGuid());\r
1033 c.setPackageVersion(wt.getPackageIdByModuleId(oldId).getVersion());\r
1034 c.setId(count.add(new BigInteger("1")));\r
55a2762d 1035 String guid = wt.getModuleFarGuid(oldId);\r
1036 if (guid != null && !guid.equals("")) {\r
ed1665f2 1037 c.setFarGuid(guid);\r
55a2762d 1038 }\r
a13899c5 1039\r
1040 cf.addNewCloned();\r
1041 cf.setClonedArray(cf.getClonedList().size() - 1, c);\r
1042 pd.addNewClonedFrom();\r
1043 pd.setClonedFrom(cf);\r
1044 msa.setModuleDefinitions(pd);\r
1045 }\r
1046\r
1047 /**\r
43dc3851 1048 Set spd file's <Cloned> section via given identification\r
a13899c5 1049 \r
43dc3851 1050 @param spd PackageSurfaceArea for clone target\r
1051 @param id Identification of clone source\r
a13899c5 1052 \r
1053 **/\r
1054 private void updatePackageClonedId(PackageSurfaceArea spd, Identification id) {\r
1055 //\r
1056 // Get PlatformDefinitions First\r
1057 //\r
1058 PackageDefinitions pd = null;\r
1059 if (spd.getPackageDefinitions() == null) {\r
1060 pd = PackageDefinitions.Factory.newInstance();\r
1061 spd.addNewPackageDefinitions();\r
1062 } else {\r
1063 pd = spd.getPackageDefinitions();\r
1064 }\r
1065\r
1066 //\r
1067 // Get ClonedFrom then\r
1068 //\r
1069 PackageDefinitions.ClonedFrom cf = null;\r
79cb6fdb 1070 BigInteger count = new BigInteger("-1");\r
a13899c5 1071 if (pd.getClonedFrom() == null) {\r
1072 cf = PackageDefinitions.ClonedFrom.Factory.newInstance();\r
1073 } else {\r
1074 cf = pd.getClonedFrom();\r
79cb6fdb 1075 if (cf != null) {\r
1076 for (int index = 0; index < cf.getClonedList().size(); index++) {\r
1077 if (cf.getClonedList().get(index).getId() != null) {\r
1078 count = count.max(cf.getClonedList().get(index).getId());\r
1079 }\r
1080 }\r
1081 }\r
a13899c5 1082 }\r
1083\r
1084 //\r
1085 // Set new Cloned item\r
1086 //\r
1087 PackageDefinitions.ClonedFrom.Cloned c = PackageDefinitions.ClonedFrom.Cloned.Factory.newInstance();\r
1088 c.setPackageGuid(id.getGuid());\r
1089 c.setPackageVersion(id.getVersion());\r
79cb6fdb 1090 c.setId(count.add(new BigInteger("1")));\r
09ef9242 1091 String guid = wt.getPackageFarGuid(oldId);\r
55a2762d 1092 if (guid != null && !guid.equals("")) {\r
ed1665f2 1093 c.setFarGuid(guid);\r
55a2762d 1094 }\r
a13899c5 1095\r
1096 cf.addNewCloned();\r
1097 cf.setClonedArray(cf.getClonedList().size() - 1, c);\r
1098 pd.addNewClonedFrom();\r
1099 pd.setClonedFrom(cf);\r
1100 spd.setPackageDefinitions(pd);\r
1101 }\r
1102\r
1103 /**\r
43dc3851 1104 Set fpd file's <Cloned> section via given identification\r
a13899c5 1105 \r
43dc3851 1106 @param fpd PlatformSurfaceArea for clone target\r
1107 @param id Identification of clone source\r
a13899c5 1108 \r
1109 **/\r
1110 private void updatePlatformClonedId(PlatformSurfaceArea fpd, Identification id) {\r
1111 //\r
1112 // Get PlatformDefinitions First\r
1113 //\r
1114 PlatformDefinitions pd = null;\r
1115 if (fpd.getPlatformDefinitions() == null) {\r
1116 pd = PlatformDefinitions.Factory.newInstance();\r
1117 fpd.addNewPlatformDefinitions();\r
1118 } else {\r
1119 pd = fpd.getPlatformDefinitions();\r
1120 }\r
1121\r
1122 //\r
1123 // Get ClonedFrom then\r
1124 //\r
1125 PlatformDefinitions.ClonedFrom cf = null;\r
79cb6fdb 1126 BigInteger count = new BigInteger("-1");\r
a13899c5 1127 if (pd.getClonedFrom() == null) {\r
1128 cf = PlatformDefinitions.ClonedFrom.Factory.newInstance();\r
1129 } else {\r
1130 cf = pd.getClonedFrom();\r
79cb6fdb 1131 if (cf != null) {\r
1132 for (int index = 0; index < cf.getClonedList().size(); index++) {\r
1133 if (cf.getClonedList().get(index).getId() != null) {\r
1134 count = count.max(cf.getClonedList().get(index).getId());\r
1135 }\r
1136 }\r
1137 }\r
a13899c5 1138 }\r
1139\r
1140 //\r
1141 // Set new Cloned item\r
1142 //\r
1143 PlatformDefinitions.ClonedFrom.Cloned c = PlatformDefinitions.ClonedFrom.Cloned.Factory.newInstance();\r
1144 c.setPlatformGuid(id.getGuid());\r
1145 c.setPlatformVersion(id.getVersion());\r
79cb6fdb 1146 c.setId(count.add(new BigInteger("1")));\r
09ef9242 1147 String guid = wt.getPlatformFarGuid(oldId);\r
55a2762d 1148 if (guid != null && !guid.equals("")) {\r
ed1665f2 1149 c.setFarGuid(guid);\r
55a2762d 1150 }\r
ed1665f2 1151\r
a13899c5 1152 cf.addNewCloned();\r
1153 cf.setClonedArray(cf.getClonedList().size() - 1, c);\r
1154 pd.addNewClonedFrom();\r
1155 pd.setClonedFrom(cf);\r
1156 fpd.setPlatformDefinitions(pd);\r
1157 }\r
1158\r
43dc3851 1159 /**\r
1160 Get PlatformIdentification\r
1161 \r
1162 @return PlatformIdentification\r
1163 \r
1164 **/\r
a13899c5 1165 public PlatformIdentification getFid() {\r
1166 return fid;\r
1167 }\r
1168\r
43dc3851 1169 /**\r
1170 Set PlatformIdentification\r
1171 \r
1172 @param fid PlatformIdentification\r
1173 \r
1174 **/\r
a13899c5 1175 public void setFid(PlatformIdentification fid) {\r
1176 this.fid = fid;\r
1177 }\r
1178\r
43dc3851 1179 /**\r
1180 Get ModuleIdentification\r
1181 \r
1182 @return ModuleIdentification\r
1183 \r
1184 **/\r
a13899c5 1185 public ModuleIdentification getMid() {\r
1186 return mid;\r
1187 }\r
1188\r
43dc3851 1189 /**\r
1190 Set ModuleIdentification\r
1191 \r
1192 @param mid ModuleIdentification\r
1193 \r
1194 **/\r
a13899c5 1195 public void setMid(ModuleIdentification mid) {\r
1196 this.mid = mid;\r
1197 }\r
1198\r
43dc3851 1199 /**\r
1200 Get PackageIdentification\r
1201 \r
1202 @return PackageIdentification\r
1203 \r
1204 **/\r
a13899c5 1205 public PackageIdentification getPid() {\r
1206 return pid;\r
1207 }\r
1208\r
43dc3851 1209 /**\r
1210 Set PackageIdentification\r
1211 \r
1212 @param pid PackageIdentification\r
1213 \r
1214 **/\r
a13899c5 1215 public void setPid(PackageIdentification pid) {\r
1216 this.pid = pid;\r
1217 }\r
1218}\r