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