3 The file is used to clone workspace, module, package and platform
5 Copyright (c) 2006, Intel Corporation
6 All rights reserved. This program and the accompanying materials
7 are licensed and made available under the terms and conditions of the BSD License
8 which accompanies this distribution. The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
15 package org
.tianocore
.frameworkwizard
;
17 import java
.awt
.event
.ActionEvent
;
19 import java
.io
.IOException
;
20 import java
.util
.Vector
;
22 import javax
.swing
.JFileChooser
;
23 import javax
.swing
.JPanel
;
24 import javax
.swing
.JLabel
;
25 import javax
.swing
.JTextField
;
26 import javax
.swing
.JButton
;
28 import org
.apache
.xmlbeans
.XmlException
;
29 import org
.tianocore
.ModuleDefinitionsDocument
.ModuleDefinitions
;
30 import org
.tianocore
.ModuleSurfaceAreaDocument
.ModuleSurfaceArea
;
31 import org
.tianocore
.PackageDefinitionsDocument
.PackageDefinitions
;
32 import org
.tianocore
.PackageSurfaceAreaDocument
.PackageSurfaceArea
;
33 import org
.tianocore
.PlatformDefinitionsDocument
.PlatformDefinitions
;
34 import org
.tianocore
.PlatformSurfaceAreaDocument
.PlatformSurfaceArea
;
35 import org
.tianocore
.frameworkwizard
.common
.DataType
;
36 import org
.tianocore
.frameworkwizard
.common
.DataValidation
;
37 import org
.tianocore
.frameworkwizard
.common
.FileOperation
;
38 import org
.tianocore
.frameworkwizard
.common
.IFileFilter
;
39 import org
.tianocore
.frameworkwizard
.common
.Identification
;
40 import org
.tianocore
.frameworkwizard
.common
.Log
;
41 import org
.tianocore
.frameworkwizard
.common
.OpenFile
;
42 import org
.tianocore
.frameworkwizard
.common
.SaveFile
;
43 import org
.tianocore
.frameworkwizard
.common
.Tools
;
44 import org
.tianocore
.frameworkwizard
.common
.ui
.IDialog
;
45 import org
.tianocore
.frameworkwizard
.common
.ui
.IFrame
;
46 import org
.tianocore
.frameworkwizard
.module
.Identification
.ModuleIdentification
;
47 import org
.tianocore
.frameworkwizard
.packaging
.PackageIdentification
;
48 import org
.tianocore
.frameworkwizard
.platform
.PlatformIdentification
;
49 import org
.tianocore
.frameworkwizard
.workspace
.Workspace
;
50 import org
.tianocore
.frameworkwizard
.workspace
.WorkspaceTools
;
51 import javax
.swing
.JComboBox
;
53 public class Clone
extends IDialog
{
59 private static final long serialVersionUID
= -5469299324965727137L;
61 private JPanel jContentPane
= null;
63 private JLabel jLabelType
= null;
65 private JTextField jTextFieldType
= null;
67 private JLabel jLabelSource
= null;
69 private JTextField jTextFieldSource
= null;
71 private JButton jButtonBrowse
= null;
73 private JLabel jLabelDestinationFile
= null;
75 private JTextField jTextFieldFilePath
= null;
77 private JLabel jLabelBaseName
= null;
79 private JTextField jTextFieldBaseName
= null;
81 private JLabel jLabelGuid
= null;
83 private JTextField jTextFieldGuid
= null;
85 private JLabel jLabelVersion
= null;
87 private JTextField jTextFieldVersion
= null;
89 private JButton jButtonOk
= null;
91 private JButton jButtonCancel
= null;
93 private JButton jButtonGenerateGuid
= null;
95 private int mode
= -1;
97 private Vector
<PackageIdentification
> packages
= null;
99 private WorkspaceTools wt
= new WorkspaceTools();
101 private JLabel jLabelBelong
= null;
103 private JComboBox jComboBoxExistingPackage
= null;
105 private Identification oldId
= null;
107 private Identification newId
= null;
109 private ModuleIdentification mid
= null;
111 private PackageIdentification pid
= null;
113 private PlatformIdentification fid
= null;
116 * This method initializes jTextFieldType
118 * @return javax.swing.JTextField
120 private JTextField
getJTextFieldType() {
121 if (jTextFieldType
== null) {
122 jTextFieldType
= new JTextField();
123 jTextFieldType
.setBounds(new java
.awt
.Rectangle(160, 10, 320, 20));
124 jTextFieldType
.setEditable(false);
126 return jTextFieldType
;
130 * This method initializes jTextFieldSource
132 * @return javax.swing.JTextField
134 private JTextField
getJTextFieldSource() {
135 if (jTextFieldSource
== null) {
136 jTextFieldSource
= new JTextField();
137 jTextFieldSource
.setBounds(new java
.awt
.Rectangle(160, 35, 320, 20));
138 jTextFieldSource
.setEditable(false);
140 return jTextFieldSource
;
144 * This method initializes jButtonBrowse
146 * @return javax.swing.JButton
148 private JButton
getJButtonBrowse() {
149 if (jButtonBrowse
== null) {
150 jButtonBrowse
= new JButton();
151 jButtonBrowse
.setBounds(new java
.awt
.Rectangle(395, 60, 85, 20));
152 jButtonBrowse
.setText("Browse");
153 jButtonBrowse
.addActionListener(this);
155 return jButtonBrowse
;
159 * This method initializes jTextFieldDestinationFile
161 * @return javax.swing.JTextField
163 private JTextField
getJTextFieldFilePath() {
164 if (jTextFieldFilePath
== null) {
165 jTextFieldFilePath
= new JTextField();
166 jTextFieldFilePath
.setBounds(new java
.awt
.Rectangle(160, 60, 230, 20));
168 return jTextFieldFilePath
;
172 * This method initializes jTextFieldBaseName
174 * @return javax.swing.JTextField
176 private JTextField
getJTextFieldBaseName() {
177 if (jTextFieldBaseName
== null) {
178 jTextFieldBaseName
= new JTextField();
179 jTextFieldBaseName
.setBounds(new java
.awt
.Rectangle(160, 110, 320, 20));
181 return jTextFieldBaseName
;
185 * This method initializes jTextFieldGuid
187 * @return javax.swing.JTextField
189 private JTextField
getJTextFieldGuid() {
190 if (jTextFieldGuid
== null) {
191 jTextFieldGuid
= new JTextField();
192 jTextFieldGuid
.setBounds(new java
.awt
.Rectangle(160, 135, 230, 20));
194 return jTextFieldGuid
;
198 * This method initializes jTextFieldVersion
200 * @return javax.swing.JTextField
202 private JTextField
getJTextFieldVersion() {
203 if (jTextFieldVersion
== null) {
204 jTextFieldVersion
= new JTextField();
205 jTextFieldVersion
.setBounds(new java
.awt
.Rectangle(160, 160, 320, 20));
207 return jTextFieldVersion
;
211 * This method initializes jButtonOk
213 * @return javax.swing.JButton
215 private JButton
getJButtonOk() {
216 if (jButtonOk
== null) {
217 jButtonOk
= new JButton();
218 jButtonOk
.setBounds(new java
.awt
.Rectangle(235, 200, 90, 20));
219 jButtonOk
.setText("Ok");
220 jButtonOk
.addActionListener(this);
226 * This method initializes jButtonCancel
228 * @return javax.swing.JButton
230 private JButton
getJButtonCancel() {
231 if (jButtonCancel
== null) {
232 jButtonCancel
= new JButton();
233 jButtonCancel
.setBounds(new java
.awt
.Rectangle(355, 200, 90, 20));
234 jButtonCancel
.setText("Cancel");
235 jButtonCancel
.addActionListener(this);
237 return jButtonCancel
;
241 * This method initializes jButtonGenerateGuid
243 * @return javax.swing.JButton
245 private JButton
getJButtonGenerateGuid() {
246 if (jButtonGenerateGuid
== null) {
247 jButtonGenerateGuid
= new JButton();
248 jButtonGenerateGuid
.setBounds(new java
.awt
.Rectangle(395, 135, 85, 20));
249 jButtonGenerateGuid
.setText("Gen");
250 jButtonGenerateGuid
.addActionListener(this);
252 return jButtonGenerateGuid
;
256 * This method initializes jComboBoxExistingPackage
258 * @return javax.swing.JComboBox
260 private JComboBox
getJComboBoxExistingPackage() {
261 if (jComboBoxExistingPackage
== null) {
262 jComboBoxExistingPackage
= new JComboBox();
263 jComboBoxExistingPackage
.setBounds(new java
.awt
.Rectangle(160, 85, 320, 20));
265 return jComboBoxExistingPackage
;
273 public static void main(String
[] args
) {
278 * This is the default constructor
286 This is the default constructor
289 public Clone(IFrame parentFrame
, boolean modal
, int fileType
, Identification identification
) {
290 super(parentFrame
, modal
);
291 this.mode
= fileType
;
292 if (identification
!= null) {
293 this.oldId
= new Identification(identification
.getName(), identification
.getGuid(),
294 identification
.getVersion(), identification
.getPath());
295 this.newId
= new Identification(identification
.getName(), identification
.getGuid(),
296 identification
.getVersion(), identification
.getPath());
302 Query all existing packages and fill them into combox
305 private void initExistingPackage() {
306 packages
= wt
.getAllPackages();
307 for (int index
= 0; index
< packages
.size(); index
++) {
308 this.jComboBoxExistingPackage
.addItem(packages
.elementAt(index
).getName());
313 * This method initializes this
317 private void init() {
318 this.setSize(493, 260);
319 this.setContentPane(getJContentPane());
320 this.setTitle("Clone");
325 * This method initializes this
329 private void init(int mode
) {
331 if (mode
== DataType
.RETURN_TYPE_MODULE_SURFACE_AREA
) {
332 this.jTextFieldType
.setText(DataType
.MODULE_SURFACE_AREA
);
333 this.jTextFieldSource
.setText(oldId
.getPath());
334 initExistingPackage();
335 this.jButtonBrowse
.setEnabled(false);
336 this.jTextFieldFilePath
.setToolTipText("Input module name here. For example, Application\\HelloWorld\\HelloWorld.msa");
337 this.jLabelDestinationFile
.setText("Module Path\\Name");
339 if (mode
== DataType
.RETURN_TYPE_PACKAGE_SURFACE_AREA
) {
340 this.jTextFieldType
.setText(DataType
.PACKAGE_SURFACE_AREA
);
341 this.jTextFieldSource
.setText(oldId
.getPath());
342 this.jLabelBelong
.setEnabled(false);
343 this.jComboBoxExistingPackage
.setEnabled(false);
344 this.jButtonBrowse
.setEnabled(false);
345 this.jTextFieldFilePath
.setToolTipText("Input package name here. For example, MdePkg\\MdePkg.fpd");
346 this.jLabelDestinationFile
.setText("Package Path\\Name");
348 if (mode
== DataType
.RETURN_TYPE_PLATFORM_SURFACE_AREA
) {
349 this.jTextFieldType
.setText(DataType
.PLATFORM_SURFACE_AREA
);
350 this.jTextFieldSource
.setText(oldId
.getPath());
351 this.jLabelBelong
.setEnabled(false);
352 this.jComboBoxExistingPackage
.setEnabled(false);
353 this.jTextFieldFilePath
.setToolTipText("Select platform path here. For example, C:\\MyWorkspace\\EdkNt32Pkg\\Nt32.fpd");
354 this.jLabelDestinationFile
.setText("New Platform path");
356 if (mode
== DataType
.RETURN_TYPE_WORKSPACE
) {
357 this.jTextFieldType
.setText(DataType
.WORKSPACE
);
358 this.jTextFieldSource
.setText(Workspace
.getCurrentWorkspace());
359 this.jLabelBelong
.setEnabled(false);
360 this.jComboBoxExistingPackage
.setEnabled(false);
361 this.jLabelBaseName
.setEnabled(false);
362 this.jTextFieldBaseName
.setEditable(false);
363 this.jLabelGuid
.setEnabled(false);
364 this.jTextFieldGuid
.setEnabled(false);
365 this.jButtonGenerateGuid
.setEnabled(false);
366 this.jLabelVersion
.setEnabled(false);
367 this.jTextFieldVersion
.setEnabled(false);
368 this.jTextFieldFilePath
.setToolTipText("Input workspace path here. For example, C:\\MyWorkspace");
369 this.jLabelDestinationFile
.setText("New Workspace path");
374 * This method initializes jContentPane
376 * @return javax.swing.JPanel
378 private JPanel
getJContentPane() {
379 if (jContentPane
== null) {
380 jLabelBelong
= new JLabel();
381 jLabelBelong
.setBounds(new java
.awt
.Rectangle(15, 85, 140, 20));
382 jLabelBelong
.setText("Clone to Package");
383 jLabelVersion
= new JLabel();
384 jLabelVersion
.setBounds(new java
.awt
.Rectangle(15, 160, 140, 20));
385 jLabelVersion
.setText("Version");
386 jLabelGuid
= new JLabel();
387 jLabelGuid
.setBounds(new java
.awt
.Rectangle(15, 135, 140, 20));
388 jLabelGuid
.setText("Guid");
389 jLabelBaseName
= new JLabel();
390 jLabelBaseName
.setBounds(new java
.awt
.Rectangle(15, 110, 140, 20));
391 jLabelBaseName
.setText("Base Name");
392 jLabelDestinationFile
= new JLabel();
393 jLabelDestinationFile
.setBounds(new java
.awt
.Rectangle(15, 60, 140, 20));
394 jLabelDestinationFile
.setText("Destination File Name");
395 jLabelSource
= new JLabel();
396 jLabelSource
.setBounds(new java
.awt
.Rectangle(15, 35, 140, 20));
397 jLabelSource
.setText("Source");
398 jLabelType
= new JLabel();
399 jLabelType
.setBounds(new java
.awt
.Rectangle(15, 10, 140, 20));
400 jLabelType
.setText("Type");
401 jContentPane
= new JPanel();
402 jContentPane
.setLayout(null);
403 jContentPane
.setSize(new java
.awt
.Dimension(490, 227));
404 jContentPane
.add(jLabelType
, null);
405 jContentPane
.add(getJTextFieldType(), null);
406 jContentPane
.add(jLabelSource
, null);
407 jContentPane
.add(getJTextFieldSource(), null);
408 jContentPane
.add(jLabelDestinationFile
, null);
409 jContentPane
.add(getJTextFieldFilePath(), null);
410 jContentPane
.add(jLabelBaseName
, null);
411 jContentPane
.add(getJTextFieldBaseName(), null);
412 jContentPane
.add(jLabelGuid
, null);
413 jContentPane
.add(getJTextFieldGuid(), null);
414 jContentPane
.add(jLabelVersion
, null);
415 jContentPane
.add(getJTextFieldVersion(), null);
416 jContentPane
.add(getJButtonOk(), null);
417 jContentPane
.add(getJButtonCancel(), null);
418 jContentPane
.add(getJButtonBrowse(), null);
419 jContentPane
.add(getJButtonGenerateGuid(), null);
420 jContentPane
.add(jLabelBelong
, null);
421 jContentPane
.add(getJComboBoxExistingPackage(), null);
427 * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
429 * Override actionPerformed to listen all actions
431 public void actionPerformed(ActionEvent arg0
) {
432 if (arg0
.getSource() == jButtonCancel
) {
433 this.setVisible(false);
434 this.returnType
= DataType
.RETURN_TYPE_CANCEL
;
437 if (arg0
.getSource() == jButtonOk
) {
441 } catch (IOException e
) {
442 Log
.err("Clone", e
.getMessage());
445 } catch (XmlException e
) {
446 Log
.err("Clone", e
.getMessage());
449 } catch (Exception e
) {
450 Log
.err("Clone", e
.getMessage());
457 this.setVisible(false);
460 if (arg0
.getSource() == this.jButtonGenerateGuid
) {
461 this.jTextFieldGuid
.setText(Tools
.generateUuidString());
465 // Use different file ext
467 if (arg0
.getSource() == this.jButtonBrowse
) {
468 JFileChooser fc
= new JFileChooser();
469 fc
.setAcceptAllFileFilterUsed(false);
471 if (mode
== DataType
.RETURN_TYPE_WORKSPACE
) {
472 fc
.setCurrentDirectory(new File(Workspace
.getCurrentWorkspace()));
473 fc
.setFileSelectionMode(JFileChooser
.DIRECTORIES_ONLY
);
475 if (mode
== DataType
.RETURN_TYPE_MODULE_SURFACE_AREA
) {
476 fc
.setCurrentDirectory(new File(packages
.elementAt(this.jComboBoxExistingPackage
.getSelectedIndex())
478 fc
.addChoosableFileFilter(new IFileFilter(DataType
.MODULE_SURFACE_AREA_EXT
));
480 if (mode
== DataType
.RETURN_TYPE_PACKAGE_SURFACE_AREA
) {
481 fc
.setCurrentDirectory(new File(Workspace
.getCurrentWorkspace()));
482 fc
.addChoosableFileFilter(new IFileFilter(DataType
.PACKAGE_SURFACE_AREA_EXT
));
484 if (mode
== DataType
.RETURN_TYPE_PLATFORM_SURFACE_AREA
) {
485 fc
.setCurrentDirectory(new File(Workspace
.getCurrentWorkspace()));
486 fc
.addChoosableFileFilter(new IFileFilter(DataType
.PLATFORM_SURFACE_AREA_EXT
));
488 int result
= fc
.showSaveDialog(new JPanel());
489 if (result
== JFileChooser
.APPROVE_OPTION
) {
490 this.jTextFieldFilePath
.setText(Tools
.addPathExt(fc
.getSelectedFile().getPath(), mode
));
496 // Check name, guid and version
498 private boolean checkId() {
502 if (isEmpty(this.jTextFieldBaseName
.getText())) {
503 Log
.err("Base Name couldn't be empty!");
506 if (!DataValidation
.isBaseName(this.jTextFieldBaseName
.getText())) {
507 Log
.err("Incorrect data type for Base Name");
514 if (isEmpty(this.jTextFieldGuid
.getText())) {
515 Log
.err("Guid couldn't be empty!");
518 if (!DataValidation
.isGuid(this.jTextFieldGuid
.getText())) {
519 Log
.err("Incorrect data type for Guid");
526 if (isEmpty(this.jTextFieldVersion
.getText())) {
527 Log
.err("Version couldn't be empty!");
530 if (!DataValidation
.isVersion(this.jTextFieldVersion
.getText())) {
531 Log
.err("Incorrect data type for Version");
536 // Save information to id
538 newId
.setName(this.jTextFieldBaseName
.getText());
539 newId
.setGuid(this.jTextFieldGuid
.getText());
540 newId
.setVersion(this.jTextFieldVersion
.getText());
541 newId
.setPath(this.jTextFieldFilePath
.getText());
552 private boolean check() {
553 String src
= this.jTextFieldSource
.getText();
554 String trg
= this.jTextFieldFilePath
.getText();
555 File srcFile
= new File(src
);
556 File trgFile
= new File(trg
);
561 if (!srcFile
.exists()) {
562 Log
.err("The source doesn't exist");
566 Log
.err("The destination file path couldn't be empty");
569 if (src
.equals(trg
)) {
570 Log
.err("The source and destination couldn't be same");
573 if (trgFile
.exists()) {
574 Log
.err("The destination already exists");
579 // Check for workspace
581 if (mode
== DataType
.RETURN_TYPE_WORKSPACE
) {
582 if (trg
.indexOf(src
+ DataType
.FILE_SEPARATOR
) == 0) {
583 Log
.err("The new workspace couldn't be in current workspace!");
591 if (mode
== DataType
.RETURN_TYPE_MODULE_SURFACE_AREA
) {
598 if (mode
== DataType
.RETURN_TYPE_PACKAGE_SURFACE_AREA
) {
599 if (trg
.indexOf(DataType
.DOS_FILE_SEPARATOR
) == -1 && trg
.indexOf(DataType
.UNIX_FILE_SEPARATOR
) == -1) {
600 Log
.err("The package name must include a path");
603 trg
= this.getPackagePath();
604 if (Tools
.getFilePathOnly(src
).equals(Tools
.getFilePathOnly(trg
))) {
605 Log
.err("The source and destination couldn't be same");
608 trgFile
= new File(trg
);
609 if (trgFile
.exists()) {
610 Log
.err("The target package already exists");
617 // Check for Platform
619 if (mode
== DataType
.RETURN_TYPE_PLATFORM_SURFACE_AREA
) {
620 if (trg
.indexOf(Workspace
.getCurrentWorkspace()) != 0) {
621 Log
.err("The target platform must be in current workspace");
624 trgFile
= new File(trg
);
625 if (trgFile
.exists()) {
626 Log
.err("The target platform already exists");
635 private void save() throws IOException
, XmlException
, Exception
{
636 String src
= this.jTextFieldSource
.getText();
637 String trg
= this.jTextFieldFilePath
.getText();
642 if (mode
== DataType
.RETURN_TYPE_WORKSPACE
) {
644 FileOperation
.copyFolder(src
, trg
);
645 } catch (Exception e
) {
646 this.returnType
= DataType
.RETURN_TYPE_CANCEL
;
647 Log
.err("Clone Workspace", e
.getMessage());
650 this.returnType
= DataType
.RETURN_TYPE_WORKSPACE
;
654 // Clone Module Surface Area
656 if (mode
== DataType
.RETURN_TYPE_MODULE_SURFACE_AREA
) {
658 // Get target path from source path
660 trg
= getModulePath();
664 // First copy all files to new directory
666 FileOperation
.copyFolder(Tools
.getFilePathOnly(src
), Tools
.getFilePathOnly(trg
));
669 // Delete old spd file
671 FileOperation
.delFile(Tools
.getFilePathOnly(trg
) + DataType
.FILE_SEPARATOR
+ Tools
.getFileNameOnly(src
));
674 // Create new msa file
676 ModuleSurfaceArea msa
= null;
677 msa
= OpenFile
.openMsaFile(src
);
682 msa
.getMsaHeader().setModuleName(newId
.getName());
683 msa
.getMsaHeader().setGuidValue(newId
.getGuid());
684 msa
.getMsaHeader().setVersion(newId
.getVersion());
687 // Update Cloned From element
689 updateModuleClonedId(msa
, oldId
);
694 SaveFile
.saveMsaFile(trg
, msa
);
697 // Update to platformId
699 this.setMid(new ModuleIdentification(newId
, packages
.elementAt(this.jComboBoxExistingPackage
.getSelectedIndex())));
702 // Open belonging package
704 PackageSurfaceArea psa
= PackageSurfaceArea
.Factory
.newInstance();
705 psa
= OpenFile
.openSpdFile(mid
.getPackageId().getPath());
708 // Update the db file
710 wt
.addModuleToPackage(mid
, psa
);
712 this.returnType
= DataType
.RETURN_TYPE_MODULE_SURFACE_AREA
;
716 // Clone Package Surface Area
718 if (mode
== DataType
.RETURN_TYPE_PACKAGE_SURFACE_AREA
) {
720 // Get target path from source path
722 trg
= this.getPackagePath();
726 // First copy all files to new directory
728 FileOperation
.copyFolder(Tools
.getFilePathOnly(src
), Tools
.getFilePathOnly(trg
));
731 // Delete old spd file
733 FileOperation
.delFile(Tools
.getFilePathOnly(trg
) + DataType
.FILE_SEPARATOR
+ Tools
.getFileNameOnly(src
));
736 // Create new spd file
738 PackageSurfaceArea spd
= null;
739 spd
= OpenFile
.openSpdFile(src
);
744 spd
.getSpdHeader().setPackageName(newId
.getName());
745 spd
.getSpdHeader().setGuidValue(newId
.getGuid());
746 spd
.getSpdHeader().setVersion(newId
.getVersion());
749 // Update Cloned From element
751 updatePackageClonedId(spd
, oldId
);
756 SaveFile
.saveSpdFile(trg
, spd
);
759 // Update to platformId
761 this.setPid(new PackageIdentification(newId
));
764 // Update the db file
766 wt
.addPackageToDatabase(pid
);
768 this.returnType
= DataType
.RETURN_TYPE_PACKAGE_SURFACE_AREA
;
772 // Clone Platform Surface Area
774 if (mode
== DataType
.RETURN_TYPE_PLATFORM_SURFACE_AREA
) {
775 PlatformSurfaceArea fpd
= null;
776 fpd
= OpenFile
.openFpdFile(src
);
781 fpd
.getPlatformHeader().setPlatformName(newId
.getName());
782 fpd
.getPlatformHeader().setGuidValue(newId
.getGuid());
783 fpd
.getPlatformHeader().setVersion(newId
.getVersion());
786 // Update Cloned From element
788 updatePlatformClonedId(fpd
, oldId
);
793 SaveFile
.saveFpdFile(trg
, fpd
);
796 // Update to platformId
798 this.setFid(new PlatformIdentification(newId
));
801 // Update the db file
803 wt
.addPlatformToDatabase(fid
);
805 this.returnType
= DataType
.RETURN_TYPE_PLATFORM_SURFACE_AREA
;
809 private String
getSelectPackagePath() {
810 return Tools
.getFilePathOnly(packages
.elementAt(this.jComboBoxExistingPackage
.getSelectedIndex()).getPath());
813 private String
getModulePath() {
814 String trg
= this.jTextFieldFilePath
.getText();
815 trg
= Tools
.addPathExt(trg
, mode
);
816 trg
= getSelectPackagePath() + DataType
.FILE_SEPARATOR
+ trg
;
817 Tools
.convertPathToCurrentOsType(trg
);
821 private String
getPackagePath() {
822 String trg
= this.jTextFieldFilePath
.getText();
823 trg
= Tools
.addPathExt(trg
, mode
);
824 trg
= Workspace
.getCurrentWorkspace() + DataType
.FILE_SEPARATOR
+ trg
;
825 trg
= Tools
.convertPathToCurrentOsType(trg
);
830 Set target item's Cloned From element
836 private void updateModuleClonedId(ModuleSurfaceArea msa
, Identification id
) {
838 // Get PlatformDefinitions First
840 ModuleDefinitions pd
= null;
841 if (msa
.getModuleDefinitions() == null) {
842 pd
= ModuleDefinitions
.Factory
.newInstance();
843 msa
.addNewModuleDefinitions();
845 pd
= msa
.getModuleDefinitions();
849 // Get ClonedFrom then
851 ModuleDefinitions
.ClonedFrom cf
= null;
852 if (pd
.getClonedFrom() == null) {
853 cf
= ModuleDefinitions
.ClonedFrom
.Factory
.newInstance();
855 cf
= pd
.getClonedFrom();
859 // Set new Cloned item
861 ModuleDefinitions
.ClonedFrom
.Cloned c
= ModuleDefinitions
.ClonedFrom
.Cloned
.Factory
.newInstance();
862 c
.setModuleGuid(id
.getGuid());
863 c
.setModuleVersion(id
.getVersion());
866 cf
.setClonedArray(cf
.getClonedList().size() - 1, c
);
867 pd
.addNewClonedFrom();
868 pd
.setClonedFrom(cf
);
869 msa
.setModuleDefinitions(pd
);
873 Set target item's Cloned From element
879 private void updatePackageClonedId(PackageSurfaceArea spd
, Identification id
) {
881 // Get PlatformDefinitions First
883 PackageDefinitions pd
= null;
884 if (spd
.getPackageDefinitions() == null) {
885 pd
= PackageDefinitions
.Factory
.newInstance();
886 spd
.addNewPackageDefinitions();
888 pd
= spd
.getPackageDefinitions();
892 // Get ClonedFrom then
894 PackageDefinitions
.ClonedFrom cf
= null;
895 if (pd
.getClonedFrom() == null) {
896 cf
= PackageDefinitions
.ClonedFrom
.Factory
.newInstance();
898 cf
= pd
.getClonedFrom();
902 // Set new Cloned item
904 PackageDefinitions
.ClonedFrom
.Cloned c
= PackageDefinitions
.ClonedFrom
.Cloned
.Factory
.newInstance();
905 c
.setPackageGuid(id
.getGuid());
906 c
.setPackageVersion(id
.getVersion());
909 cf
.setClonedArray(cf
.getClonedList().size() - 1, c
);
910 pd
.addNewClonedFrom();
911 pd
.setClonedFrom(cf
);
912 spd
.setPackageDefinitions(pd
);
916 Set target item's Cloned From element
922 private void updatePlatformClonedId(PlatformSurfaceArea fpd
, Identification id
) {
924 // Get PlatformDefinitions First
926 PlatformDefinitions pd
= null;
927 if (fpd
.getPlatformDefinitions() == null) {
928 pd
= PlatformDefinitions
.Factory
.newInstance();
929 fpd
.addNewPlatformDefinitions();
931 pd
= fpd
.getPlatformDefinitions();
935 // Get ClonedFrom then
937 PlatformDefinitions
.ClonedFrom cf
= null;
938 if (pd
.getClonedFrom() == null) {
939 cf
= PlatformDefinitions
.ClonedFrom
.Factory
.newInstance();
941 cf
= pd
.getClonedFrom();
945 // Set new Cloned item
947 PlatformDefinitions
.ClonedFrom
.Cloned c
= PlatformDefinitions
.ClonedFrom
.Cloned
.Factory
.newInstance();
948 c
.setPlatformGuid(id
.getGuid());
949 c
.setPlatformVersion(id
.getVersion());
952 cf
.setClonedArray(cf
.getClonedList().size() - 1, c
);
953 pd
.addNewClonedFrom();
954 pd
.setClonedFrom(cf
);
955 fpd
.setPlatformDefinitions(pd
);
958 public PlatformIdentification
getFid() {
962 public void setFid(PlatformIdentification fid
) {
966 public ModuleIdentification
getMid() {
970 public void setMid(ModuleIdentification mid
) {
974 public PackageIdentification
getPid() {
978 public void setPid(PackageIdentification pid
) {