]> git.proxmox.com Git - mirror_edk2.git/blob - Tools/Java/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/SelectModuleBelong.java
1. Fix EDKT463: When wizard new or clone a msa/spd/fpd, should follow these rules
[mirror_edk2.git] / Tools / Java / Source / FrameworkWizard / src / org / tianocore / frameworkwizard / SelectModuleBelong.java
1 /** @file
2
3 The file is used to let user choose to create module in an existing package
4 or to create a new package first.
5
6 Copyright (c) 2006, Intel Corporation
7 All rights reserved. This program and the accompanying materials
8 are licensed and made available under the terms and conditions of the BSD License
9 which accompanies this distribution. The full text of the license may be found at
10 http://opensource.org/licenses/bsd-license.php
11
12 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
13 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
14
15 **/
16 package org.tianocore.frameworkwizard;
17
18 import java.awt.Component;
19 import java.awt.event.ActionEvent;
20 import java.io.File;
21 import java.util.Vector;
22
23 import javax.swing.ButtonGroup;
24 import javax.swing.JButton;
25 import javax.swing.JComboBox;
26 import javax.swing.JFileChooser;
27 import javax.swing.JLabel;
28 import javax.swing.JPanel;
29 import javax.swing.JTextField;
30
31 import org.tianocore.ModuleTypeDef;
32 import org.tianocore.MsaHeaderDocument;
33 import org.tianocore.SpdHeaderDocument;
34 import org.tianocore.ModuleSurfaceAreaDocument.ModuleSurfaceArea;
35 import org.tianocore.PackageSurfaceAreaDocument.PackageSurfaceArea;
36 import org.tianocore.PlatformHeaderDocument.PlatformHeader;
37 import org.tianocore.PlatformSurfaceAreaDocument.PlatformSurfaceArea;
38 import org.tianocore.frameworkwizard.common.DataType;
39 import org.tianocore.frameworkwizard.common.DataValidation;
40 import org.tianocore.frameworkwizard.common.GlobalData;
41 import org.tianocore.frameworkwizard.common.IFileFilter;
42 import org.tianocore.frameworkwizard.common.Log;
43 import org.tianocore.frameworkwizard.common.SaveFile;
44 import org.tianocore.frameworkwizard.common.Tools;
45 import org.tianocore.frameworkwizard.common.ui.IDialog;
46 import org.tianocore.frameworkwizard.common.ui.IFrame;
47 import org.tianocore.frameworkwizard.common.ui.StarLabel;
48 import org.tianocore.frameworkwizard.module.Identifications.ModuleIdentification;
49 import org.tianocore.frameworkwizard.packaging.PackageIdentification;
50 import org.tianocore.frameworkwizard.platform.PlatformIdentification;
51 import org.tianocore.frameworkwizard.workspace.Workspace;
52 import org.tianocore.frameworkwizard.workspace.WorkspaceTools;
53 import javax.swing.JRadioButton;
54
55 public class SelectModuleBelong extends IDialog {
56
57 /**
58 Define class members
59
60 **/
61 private static final long serialVersionUID = 4171355136991448972L;
62
63 private JPanel jContentPane = null;
64
65 private JComboBox jComboBoxExistingPackage = null;
66
67 private JButton jButtonOk = null;
68
69 private JButton jButtonCancel = null;
70
71 private Vector<PackageIdentification> packages = null;
72
73 private JLabel jLabelPackage = null;
74
75 private JLabel jLabelFilePath = null;
76
77 private JTextField jTextFieldFilePath = null;
78
79 private JButton jButtonBrowse = null;
80
81 private JLabel jLabelName = null;
82
83 private JTextField jTextFieldName = null;
84
85 private JLabel jLabelGuid = null;
86
87 private JTextField jTextFieldGuid = null;
88
89 private JButton jButtonGen = null;
90
91 private JLabel jLabelVersion = null;
92
93 private JTextField jTextFieldVersion = null;
94
95 private StarLabel jStarLabel1 = null;
96
97 private StarLabel jStarLabel2 = null;
98
99 private StarLabel jStarLabel3 = null;
100
101 private StarLabel jStarLabel4 = null;
102
103 private StarLabel jStarLabel5 = null;
104
105 private ButtonGroup bg = new ButtonGroup();
106
107 private WorkspaceTools wt = new WorkspaceTools();
108
109 private ModuleIdentification mid = null;
110
111 private PackageIdentification pid = null;
112
113 private PlatformIdentification fid = null;
114
115 private ModuleSurfaceArea msa = null;
116
117 private PackageSurfaceArea spd = null;
118
119 private PlatformSurfaceArea fpd = null;
120
121 private int mode = -1;
122
123 private JLabel jLabelIsLibrary = null;
124
125 private JRadioButton jRadioButtonYes = null;
126
127 private JRadioButton jRadioButtonNo = null;
128
129 /**
130 * This method initializes jComboBoxExistingPackage
131 *
132 * @return javax.swing.JComboBox
133 */
134 private JComboBox getJComboBoxExistingPackage() {
135 if (jComboBoxExistingPackage == null) {
136 jComboBoxExistingPackage = new JComboBox();
137 jComboBoxExistingPackage.setBounds(new java.awt.Rectangle(140, 10, 340, 20));
138 }
139 return jComboBoxExistingPackage;
140 }
141
142 /**
143 * This method initializes jButtonNext
144 *
145 * @return javax.swing.JButton
146 */
147 private JButton getJButtonOk() {
148 if (jButtonOk == null) {
149 jButtonOk = new JButton();
150 jButtonOk.setBounds(new java.awt.Rectangle(310, 165, 80, 20));
151 jButtonOk.setText("Ok");
152 jButtonOk.addActionListener(this);
153 }
154 return jButtonOk;
155 }
156
157 /**
158 * This method initializes jButtonCancel
159 *
160 * @return javax.swing.JButton
161 */
162 private JButton getJButtonCancel() {
163 if (jButtonCancel == null) {
164 jButtonCancel = new JButton();
165 jButtonCancel.setBounds(new java.awt.Rectangle(395, 165, 80, 20));
166 jButtonCancel.setText("Cancel");
167 jButtonCancel.addActionListener(this);
168 }
169 return jButtonCancel;
170 }
171
172 /**
173 * This method initializes jTextFieldFilePath
174 *
175 * @return javax.swing.JTextField
176 */
177 private JTextField getJTextFieldFilePath() {
178 if (jTextFieldFilePath == null) {
179 jTextFieldFilePath = new JTextField();
180 jTextFieldFilePath.setBounds(new java.awt.Rectangle(140, 60, 250, 20));
181 }
182 return jTextFieldFilePath;
183 }
184
185 /**
186 * This method initializes jButtonBrowse
187 *
188 * @return javax.swing.JButton
189 */
190 private JButton getJButtonBrowse() {
191 if (jButtonBrowse == null) {
192 jButtonBrowse = new JButton();
193 jButtonBrowse.setBounds(new java.awt.Rectangle(395, 60, 85, 20));
194 jButtonBrowse.setText("Browse");
195 jButtonBrowse.addActionListener(this);
196 }
197 return jButtonBrowse;
198 }
199
200 /**
201 * This method initializes jTextFieldModuleName
202 *
203 * @return javax.swing.JTextField
204 */
205 private JTextField getJTextFieldName() {
206 if (jTextFieldName == null) {
207 jTextFieldName = new JTextField();
208 jTextFieldName.setBounds(new java.awt.Rectangle(140, 85, 340, 20));
209 }
210 return jTextFieldName;
211 }
212
213 /**
214 * This method initializes jTextFieldGuid
215 *
216 * @return javax.swing.JTextField
217 */
218 private JTextField getJTextFieldGuid() {
219 if (jTextFieldGuid == null) {
220 jTextFieldGuid = new JTextField();
221 jTextFieldGuid.setBounds(new java.awt.Rectangle(140, 110, 250, 20));
222 }
223 return jTextFieldGuid;
224 }
225
226 /**
227 * This method initializes jButtonGen
228 *
229 * @return javax.swing.JButton
230 */
231 private JButton getJButtonGen() {
232 if (jButtonGen == null) {
233 jButtonGen = new JButton();
234 jButtonGen.setBounds(new java.awt.Rectangle(395, 110, 85, 20));
235 jButtonGen.setText("GEN");
236 jButtonGen.addActionListener(this);
237 }
238 return jButtonGen;
239 }
240
241 /**
242 * This method initializes jTextFieldVersion
243 *
244 * @return javax.swing.JTextField
245 */
246 private JTextField getJTextFieldVersion() {
247 if (jTextFieldVersion == null) {
248 jTextFieldVersion = new JTextField();
249 jTextFieldVersion.setBounds(new java.awt.Rectangle(140, 135, 340, 20));
250 }
251 return jTextFieldVersion;
252 }
253
254 /**
255 * This method initializes jRadioButtonYes
256 *
257 * @return javax.swing.JRadioButton
258 */
259 private JRadioButton getJRadioButtonYes() {
260 if (jRadioButtonYes == null) {
261 jRadioButtonYes = new JRadioButton();
262 jRadioButtonYes.setBounds(new java.awt.Rectangle(140, 35, 100, 20));
263 jRadioButtonYes.setSelected(false);
264 jRadioButtonYes.setText("Yes");
265 }
266 return jRadioButtonYes;
267 }
268
269 /**
270 * This method initializes jRadioButtonNo
271 *
272 * @return javax.swing.JRadioButton
273 */
274 private JRadioButton getJRadioButtonNo() {
275 if (jRadioButtonNo == null) {
276 jRadioButtonNo = new JRadioButton();
277 jRadioButtonNo.setBounds(new java.awt.Rectangle(300, 35, 110, 20));
278 jRadioButtonNo.setSelected(true);
279 jRadioButtonNo.setText("No");
280 }
281 return jRadioButtonNo;
282 }
283
284 /**
285 * @param args
286 */
287 public static void main(String[] args) {
288 SelectModuleBelong smb = new SelectModuleBelong();
289 smb.setVisible(true);
290 }
291
292 /**
293 * This is the default constructor
294 */
295 public SelectModuleBelong() {
296 super();
297 init();
298 }
299
300 /**
301 * This is the default constructor
302 */
303 public SelectModuleBelong(IFrame parentFrame, boolean modal, int fileType) {
304 super(parentFrame, modal);
305 this.mode = fileType;
306 init();
307 initExistingPackage();
308 if (mode != DataType.RETURN_TYPE_MODULE_SURFACE_AREA) {
309 this.jStarLabel1.setVisible(false);
310 this.jLabelPackage.setVisible(false);
311 this.jComboBoxExistingPackage.setVisible(false);
312 this.jLabelIsLibrary.setVisible(false);
313 this.jRadioButtonYes.setVisible(false);
314 this.jRadioButtonNo.setVisible(false);
315 upLocation(this.jStarLabel2, 50);
316 upLocation(this.jStarLabel3, 50);
317 upLocation(this.jStarLabel4, 50);
318 upLocation(this.jStarLabel5, 50);
319 upLocation(this.jLabelFilePath, 50);
320 upLocation(this.jLabelName, 50);
321 upLocation(this.jLabelGuid, 50);
322 upLocation(this.jLabelVersion, 50);
323 upLocation(this.jTextFieldFilePath, 50);
324 upLocation(this.jTextFieldName, 50);
325 upLocation(this.jTextFieldGuid, 50);
326 upLocation(this.jTextFieldVersion, 50);
327 upLocation(this.jButtonBrowse, 50);
328 upLocation(this.jButtonGen, 50);
329 }
330 }
331
332 /**
333 * This method initializes this
334 *
335 * @return void
336 */
337 private void init() {
338 this.setSize(500, 230);
339 this.setContentPane(getJContentPane());
340 this.setTitle("New");
341 this.centerWindow();
342 }
343
344 /**
345 * This method initializes jContentPane
346 *
347 * @return javax.swing.JPanel
348 */
349 private JPanel getJContentPane() {
350 if (jContentPane == null) {
351 jLabelIsLibrary = new JLabel();
352 jLabelIsLibrary.setBounds(new java.awt.Rectangle(15, 35, 120, 20));
353 jLabelIsLibrary.setText("Is this a Library");
354 jLabelVersion = new JLabel();
355 jLabelVersion.setBounds(new java.awt.Rectangle(15, 135, 120, 20));
356 jLabelVersion.setText("Version");
357 jLabelGuid = new JLabel();
358 jLabelGuid.setBounds(new java.awt.Rectangle(15, 110, 120, 20));
359 jLabelGuid.setText("Guid");
360 jLabelName = new JLabel();
361 jLabelName.setBounds(new java.awt.Rectangle(15, 85, 120, 20));
362 jLabelName.setText("Module Name");
363 jLabelFilePath = new JLabel();
364 jLabelFilePath.setBounds(new java.awt.Rectangle(15, 60, 120, 20));
365 jLabelFilePath.setText("File Path");
366 jLabelPackage = new JLabel();
367 jLabelPackage.setBounds(new java.awt.Rectangle(15, 10, 120, 20));
368 jLabelPackage.setText("Choose a Package");
369 jContentPane = new JPanel();
370 jContentPane.setLayout(null);
371 jContentPane.setSize(new java.awt.Dimension(490, 198));
372 jContentPane.add(getJComboBoxExistingPackage(), null);
373 jContentPane.add(getJButtonOk(), null);
374 jContentPane.add(getJButtonCancel(), null);
375 jContentPane.add(jLabelPackage, null);
376 jContentPane.add(jLabelFilePath, null);
377 jContentPane.add(getJTextFieldFilePath(), null);
378 jContentPane.add(getJButtonBrowse(), null);
379 jContentPane.add(jLabelName, null);
380 jContentPane.add(getJTextFieldName(), null);
381 jContentPane.add(jLabelGuid, null);
382 jContentPane.add(getJTextFieldGuid(), null);
383 jContentPane.add(getJButtonGen(), null);
384 jContentPane.add(jLabelVersion, null);
385 jContentPane.add(getJTextFieldVersion(), null);
386
387 jStarLabel1 = new StarLabel();
388 jStarLabel1.setLocation(new java.awt.Point(0, 10));
389 jStarLabel2 = new StarLabel();
390 jStarLabel2.setLocation(new java.awt.Point(0, 60));
391 jStarLabel3 = new StarLabel();
392 jStarLabel3.setLocation(new java.awt.Point(0, 85));
393 jStarLabel4 = new StarLabel();
394 jStarLabel4.setLocation(new java.awt.Point(0, 110));
395 jStarLabel5 = new StarLabel();
396 jStarLabel5.setLocation(new java.awt.Point(0, 135));
397 jContentPane.add(jStarLabel1, null);
398 jContentPane.add(jStarLabel2, null);
399 jContentPane.add(jStarLabel3, null);
400 jContentPane.add(jStarLabel4, null);
401 jContentPane.add(jStarLabel5, null);
402 jContentPane.add(jLabelIsLibrary, null);
403 jContentPane.add(getJRadioButtonYes(), null);
404 jContentPane.add(getJRadioButtonNo(), null);
405 bg.add(getJRadioButtonNo());
406 bg.add(getJRadioButtonYes());
407 }
408 return jContentPane;
409 }
410
411 /**
412 Query all existing packages and fill them into combox
413
414 **/
415 private void initExistingPackage() {
416 packages = wt.getAllPackages();
417 for (int index = 0; index < packages.size(); index++) {
418 this.jComboBoxExistingPackage.addItem(packages.elementAt(index).getName());
419 }
420 }
421
422 /* (non-Javadoc)
423 * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
424 *
425 * Override actionPerformed to listen all actions
426 */
427 public void actionPerformed(ActionEvent arg0) {
428 if (arg0.getSource() == jButtonCancel) {
429 this.setVisible(false);
430 this.returnType = DataType.RETURN_TYPE_CANCEL;
431 }
432
433 if (arg0.getSource() == jButtonOk) {
434 if (this.check()) {
435 this.save();
436 } else {
437 return;
438 }
439 this.setVisible(false);
440 this.returnType = DataType.RETURN_TYPE_OK;
441 }
442
443 if (arg0.getSource() == this.jButtonGen) {
444 this.jTextFieldGuid.setText(Tools.generateUuidString());
445 }
446
447 if (arg0.getSource() == this.jButtonBrowse) {
448 JFileChooser fc = new JFileChooser();
449 fc.setAcceptAllFileFilterUsed(false);
450
451 if (mode == DataType.RETURN_TYPE_MODULE_SURFACE_AREA) {
452 fc.setCurrentDirectory(new File(packages.elementAt(this.jComboBoxExistingPackage.getSelectedIndex())
453 .getPath()));
454 fc.addChoosableFileFilter(new IFileFilter(DataType.MODULE_SURFACE_AREA_EXT));
455 }
456 if (mode == DataType.RETURN_TYPE_PACKAGE_SURFACE_AREA) {
457 fc.setCurrentDirectory(new File(Workspace.getCurrentWorkspace()));
458 fc.addChoosableFileFilter(new IFileFilter(DataType.PACKAGE_SURFACE_AREA_EXT));
459 }
460 if (mode == DataType.RETURN_TYPE_PLATFORM_SURFACE_AREA) {
461 fc.setCurrentDirectory(new File(Workspace.getCurrentWorkspace()));
462 fc.addChoosableFileFilter(new IFileFilter(DataType.PLATFORM_SURFACE_AREA_EXT));
463 }
464 int result = fc.showSaveDialog(new JPanel());
465 if (result == JFileChooser.APPROVE_OPTION) {
466 this.jTextFieldFilePath.setText(Tools.addPathExt(fc.getSelectedFile().getPath(), mode));
467 }
468 }
469 }
470
471 /**
472 Data validation for all fields
473
474 @retval true - All datas are valid
475 @retval false - At least one data is invalid
476
477 **/
478 public boolean check() {
479 String path = this.jTextFieldFilePath.getText();
480 String guid = this.jTextFieldGuid.getText();
481 String version = this.jTextFieldVersion.getText();
482
483 //
484 // Check if all required fields are not empty
485 //
486 if (isEmpty(path)) {
487 Log.wrn("New File", "A File Path must be entered!");
488 return false;
489 }
490 if (isEmpty(this.jTextFieldName.getText())) {
491 Log.wrn("New File", "A Name must be entered");
492 return false;
493 }
494 if (isEmpty(guid)) {
495 Log.wrn("New File", "The Guid must be entered!");
496 return false;
497 }
498 if (isEmpty(version)) {
499 Log.wrn("New File", "A Version number must be entered!");
500 return false;
501 }
502
503 //
504 // Check if all fields have correct data types
505 //
506 if (!DataValidation.isBaseName(this.jTextFieldName.getText())) {
507 Log.wrn("New File", "Incorrect data type for the Name!");
508 return false;
509 }
510 if (!DataValidation.isGuid((guid))) {
511 Log.wrn("New File", "Incorrect data type for Guid, which must be in registry format! (8-4-4-4-12)");
512 return false;
513 }
514
515
516
517 if (mode == DataType.RETURN_TYPE_MODULE_SURFACE_AREA) {
518 //
519 // Check if the module is already existed in current package
520 //
521 String packagePath = packages.elementAt(this.jComboBoxExistingPackage.getSelectedIndex()).getPath();
522 String modulePath = Tools.convertPathToCurrentOsType(path);
523 Vector<String> msaFile = wt.getAllModulesOfPackage(packagePath);
524
525 for (int index = 0; index < msaFile.size(); index++) {
526 if (msaFile.elementAt(index).equals(modulePath)) {
527 Log.wrn("New File", "This module is already exists in the selected package!");
528 return false;
529 }
530 }
531
532 //
533 // Check if path already exists
534 //
535 if (GlobalData.isDuplicateRelativePath(Tools.getFilePathOnly(modulePath), mode)) {
536 Log.wrn("New File", "There already exists a same directory with a module");
537 return false;
538 }
539
540 //
541 // Check if Guid+Version is unique
542 //
543 String packageGuid = packages.elementAt(this.jComboBoxExistingPackage.getSelectedIndex()).getGuid();
544 String packageVersion = packages.elementAt(this.jComboBoxExistingPackage.getSelectedIndex()).getVersion();
545 if (GlobalData.findModuleId(guid, version, packageGuid, packageVersion) != null) {
546 Log.wrn("New File", "A module with same Guid and same Version already exists, please selece a new Guid or Version!");
547 return false;
548 }
549 }
550
551 if (mode == DataType.RETURN_TYPE_PACKAGE_SURFACE_AREA) {
552 //
553 // Check if the package is already existed in database
554 //
555 path = Tools.convertPathToCurrentOsType(path);
556 Vector<PackageIdentification> vPackageList = wt.getAllPackages();
557 if (vPackageList != null && vPackageList.size() > 0) {
558 for (int index = 0; index < vPackageList.size(); index++) {
559 if (vPackageList.get(index).getPath().equals(path)) {
560 Log.wrn("New File", "This package is already exists in this workspace!");
561 return false;
562 }
563 }
564 }
565
566 //
567 // Check if path already exists
568 //
569 if (GlobalData.isDuplicateRelativePath(Tools.getFilePathOnly(path), mode)) {
570 Log.wrn("New File", "There already exists a same directory with a package");
571 return false;
572 }
573
574 //
575 // Check if Guid+Version is unique
576 //
577 if (GlobalData.findPackageId(guid, version) != null) {
578 Log.wrn("New File", "A package with same Guid and same Version already exists, please selece a new Guid or Version!");
579 return false;
580 }
581 }
582
583 if (mode == DataType.RETURN_TYPE_PLATFORM_SURFACE_AREA) {
584 //
585 // Check if the platform is already existed in database
586 //
587 path = Tools.convertPathToCurrentOsType(path);
588 Vector<PlatformIdentification> vPlatfromList = wt.getAllPlatforms();
589 if (vPlatfromList != null && vPlatfromList.size() > 0) {
590 for (int index = 0; index < vPlatfromList.size(); index++) {
591 if (vPlatfromList.get(index).getPath().equals(path)) {
592 Log.wrn("New File", "This platform is already exists in this workspace!");
593 return false;
594 }
595 }
596 }
597
598 //
599 // Check if path already exists
600 //
601 if (GlobalData.isDuplicateRelativePath(Tools.getFilePathOnly(path), mode)) {
602 Log.wrn("New File", "There already exists a same directory with a platform");
603 return false;
604 }
605
606 //
607 // Check if Guid+Version is unique
608 //
609 if (GlobalData.findPlatformId(guid, version) != null) {
610 Log.wrn("New File", "A platform with same Guid and same Version already exists, please selece a new Guid or Version!");
611 return false;
612 }
613 }
614
615 return true;
616 }
617
618 /**
619 Save file
620
621 **/
622 public void save() {
623 if (mode == DataType.RETURN_TYPE_MODULE_SURFACE_AREA) {
624 this.saveModule();
625 }
626 if (mode == DataType.RETURN_TYPE_PACKAGE_SURFACE_AREA) {
627 this.savePackage();
628 }
629 if (mode == DataType.RETURN_TYPE_PLATFORM_SURFACE_AREA) {
630 this.savePlatform();
631 }
632 }
633
634 /**
635 Save all components of Msa Header
636
637 **/
638 private void saveModule() {
639 msa = null;
640 String path = Tools.convertPathToCurrentOsType(this.jTextFieldFilePath.getText());
641
642 //
643 // Save to memory
644 //
645 try {
646 MsaHeaderDocument.MsaHeader msaHeader = null;
647
648 msa = ModuleSurfaceArea.Factory.newInstance();
649 msaHeader = MsaHeaderDocument.MsaHeader.Factory.newInstance();
650
651 msaHeader.setModuleName(this.jTextFieldName.getText());
652 msaHeader.setGuidValue(this.jTextFieldGuid.getText());
653 msaHeader.setVersion(this.jTextFieldVersion.getText());
654 msaHeader.setModuleType(ModuleTypeDef.BASE);
655
656 msa.setMsaHeader(msaHeader);
657 } catch (Exception e) {
658 Log.err("Save ModuleSurfaceArea Document", e.getMessage());
659 return;
660 }
661
662 //
663 // Save to real file
664 //
665 try {
666 SaveFile.saveMsaFile(path, msa);
667 } catch (Exception e) {
668 Log.wrn("Save Module to file system", e.getMessage());
669 Log.err("Save Module to file system", e.getMessage());
670 return;
671 }
672
673 //
674 // Save to identification
675 //
676 mid = new ModuleIdentification(this.jTextFieldName.getText(), this.jTextFieldGuid.getText(),
677 this.jTextFieldVersion.getText(), path, jRadioButtonYes.isSelected());
678 mid.setPackageId(packages.elementAt(this.jComboBoxExistingPackage.getSelectedIndex()));
679 }
680
681 /**
682 Save all components of Spd Header
683
684 **/
685 private void savePackage() {
686 spd = null;
687 String path = Tools.convertPathToCurrentOsType(this.jTextFieldFilePath.getText());
688
689 //
690 // Save to memory
691 //
692 try {
693 SpdHeaderDocument.SpdHeader spdHeader = null;
694
695 spd = PackageSurfaceArea.Factory.newInstance();
696 spdHeader = SpdHeaderDocument.SpdHeader.Factory.newInstance();
697
698 spdHeader.setPackageName(this.jTextFieldName.getText());
699 spdHeader.setGuidValue(this.jTextFieldGuid.getText());
700 spdHeader.setVersion(this.jTextFieldVersion.getText());
701
702 spd.setSpdHeader(spdHeader);
703 } catch (Exception e) {
704 Log.wrn("Save Package Surface Area Description Document", e.getMessage());
705 return;
706 }
707
708 //
709 // Save to real file
710 //
711 try {
712 SaveFile.saveSpdFile(path, spd);
713
714 } catch (Exception e) {
715 Log.wrn("Save Package to file system", e.getMessage());
716 Log.err("Save Package to file system", e.getMessage());
717 return;
718 }
719
720 //
721 // Save to identification
722 //
723 pid = new PackageIdentification(this.jTextFieldName.getText(), this.jTextFieldGuid.getText(),
724 this.jTextFieldVersion.getText(), path);
725 }
726
727 /**
728 Save all components of Fpd Header
729
730 **/
731 private void savePlatform() {
732 fpd = null;
733 String path = Tools.convertPathToCurrentOsType(this.jTextFieldFilePath.getText());
734
735 //
736 // Save to memory
737 //
738 try {
739 PlatformHeader fpdHeader = null;
740
741 fpd = PlatformSurfaceArea.Factory.newInstance();
742 fpdHeader = PlatformHeader.Factory.newInstance();
743
744 fpdHeader.setPlatformName(this.jTextFieldName.getText());
745 fpdHeader.setGuidValue(this.jTextFieldGuid.getText());
746 fpdHeader.setVersion(this.jTextFieldVersion.getText());
747
748 fpd.setPlatformHeader(fpdHeader);
749 } catch (Exception e) {
750 Log.wrn("Save Framework Platform Description Document", e.getMessage());
751 return;
752 }
753
754 //
755 // Save to real file
756 //
757 try {
758 SaveFile.saveFpdFile(path, fpd);
759
760 } catch (Exception e) {
761 Log.wrn("Save Platform to file system", e.getMessage());
762 Log.err("Save Platform to file system", e.getMessage());
763 return;
764 }
765
766 //
767 // Save to identification
768 //
769 fid = new PlatformIdentification(this.jTextFieldName.getText(), this.jTextFieldGuid.getText(),
770 this.jTextFieldVersion.getText(), path);
771 }
772
773 public ModuleIdentification getMid() {
774 return mid;
775 }
776
777 public PlatformIdentification getFid() {
778 return fid;
779 }
780
781 public PackageIdentification getPid() {
782 return pid;
783 }
784
785 private void upLocation(Component c, int size) {
786 c.setLocation(c.getLocation().x, c.getLocation().y - size);
787 }
788
789 public PlatformSurfaceArea getFpd() {
790 return fpd;
791 }
792
793 public ModuleSurfaceArea getMsa() {
794 return msa;
795 }
796
797 public PackageSurfaceArea getSpd() {
798 return spd;
799 }
800 }