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