]> git.proxmox.com Git - mirror_edk2.git/blob - Tools/Java/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/SelectModuleBelong.java
70342e73cdc2098f999613f599282dfaff69068b
[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 path = Tools.addPathExt(path, mode);
481 String guid = this.jTextFieldGuid.getText();
482 String version = this.jTextFieldVersion.getText();
483
484 //
485 // Check if all required fields are not empty
486 //
487 if (isEmpty(path)) {
488 Log.wrn("New File", "A File Path must be entered!");
489 return false;
490 }
491 if (isEmpty(this.jTextFieldName.getText())) {
492 Log.wrn("New File", "A Name must be entered");
493 return false;
494 }
495 if (isEmpty(guid)) {
496 Log.wrn("New File", "The Guid must be entered!");
497 return false;
498 }
499 if (isEmpty(version)) {
500 Log.wrn("New File", "A Version number must be entered!");
501 return false;
502 }
503
504 //
505 // Check if all fields have correct data types
506 //
507 if (!DataValidation.isBaseName(this.jTextFieldName.getText())) {
508 Log.wrn("New File", "Incorrect data type for the Name!");
509 return false;
510 }
511 if (!DataValidation.isGuid((guid))) {
512 Log.wrn("New File", "Incorrect data type for Guid, which must be in registry format! (8-4-4-4-12)");
513 return false;
514 }
515
516 //
517 // Check if path is valid
518 //
519 File f = new File(path);
520 if (!f.isFile()) {
521 Log.wrn("New File", "Please type a complete file path!");
522 return false;
523 }
524 f = null;
525
526 if (mode == DataType.RETURN_TYPE_MODULE_SURFACE_AREA) {
527 //
528 // Check if the module is already existed in current package
529 //
530 String packagePath = packages.elementAt(this.jComboBoxExistingPackage.getSelectedIndex()).getPath();
531 String modulePath = Tools.convertPathToCurrentOsType(path);
532 Vector<String> msaFile = wt.getAllModulesOfPackage(packagePath);
533
534 for (int index = 0; index < msaFile.size(); index++) {
535 if (msaFile.elementAt(index).equals(modulePath)) {
536 Log.wrn("New File", "This module is already exists in the selected package!");
537 return false;
538 }
539 }
540
541 //
542 // Check if path already exists
543 //
544 if (GlobalData.isDuplicateRelativePath(Tools.getFilePathOnly(modulePath), mode)) {
545 Log.wrn("New File", "There already exists a same directory with a module");
546 return false;
547 }
548
549 //
550 // Check if Guid+Version is unique
551 //
552 String packageGuid = packages.elementAt(this.jComboBoxExistingPackage.getSelectedIndex()).getGuid();
553 String packageVersion = packages.elementAt(this.jComboBoxExistingPackage.getSelectedIndex()).getVersion();
554 if (GlobalData.findModuleId(guid, version, packageGuid, packageVersion) != null) {
555 Log.wrn("New File", "A module with same Guid and same Version already exists, please selece a new Guid or Version!");
556 return false;
557 }
558 }
559
560 if (mode == DataType.RETURN_TYPE_PACKAGE_SURFACE_AREA) {
561 //
562 // Check if the package is already existed in database
563 //
564 path = Tools.convertPathToCurrentOsType(path);
565 Vector<PackageIdentification> vPackageList = wt.getAllPackages();
566 if (vPackageList != null && vPackageList.size() > 0) {
567 for (int index = 0; index < vPackageList.size(); index++) {
568 if (vPackageList.get(index).getPath().equals(path)) {
569 Log.wrn("New File", "This package is already exists in this workspace!");
570 return false;
571 }
572 }
573 }
574
575 //
576 // Check if path already exists
577 //
578 if (GlobalData.isDuplicateRelativePath(Tools.getFilePathOnly(path), mode)) {
579 Log.wrn("New File", "There already exists a same directory with a package");
580 return false;
581 }
582
583 //
584 // Check if Guid+Version is unique
585 //
586 if (GlobalData.findPackageId(guid, version) != null) {
587 Log.wrn("New File", "A package with same Guid and same Version already exists, please selece a new Guid or Version!");
588 return false;
589 }
590 }
591
592 if (mode == DataType.RETURN_TYPE_PLATFORM_SURFACE_AREA) {
593 //
594 // Check if the platform is already existed in database
595 //
596 path = Tools.convertPathToCurrentOsType(path);
597 Vector<PlatformIdentification> vPlatfromList = wt.getAllPlatforms();
598 if (vPlatfromList != null && vPlatfromList.size() > 0) {
599 for (int index = 0; index < vPlatfromList.size(); index++) {
600 if (vPlatfromList.get(index).getPath().equals(path)) {
601 Log.wrn("New File", "This platform is already exists in this workspace!");
602 return false;
603 }
604 }
605 }
606
607 //
608 // Check if path already exists
609 //
610 if (GlobalData.isDuplicateRelativePath(Tools.getFilePathOnly(path), mode)) {
611 Log.wrn("New File", "There already exists a same directory with a platform");
612 return false;
613 }
614
615 //
616 // Check if Guid+Version is unique
617 //
618 if (GlobalData.findPlatformId(guid, version) != null) {
619 Log.wrn("New File", "A platform with same Guid and same Version already exists, please selece a new Guid or Version!");
620 return false;
621 }
622 }
623
624 return true;
625 }
626
627 /**
628 Save file
629
630 **/
631 public void save() {
632 if (mode == DataType.RETURN_TYPE_MODULE_SURFACE_AREA) {
633 this.saveModule();
634 }
635 if (mode == DataType.RETURN_TYPE_PACKAGE_SURFACE_AREA) {
636 this.savePackage();
637 }
638 if (mode == DataType.RETURN_TYPE_PLATFORM_SURFACE_AREA) {
639 this.savePlatform();
640 }
641 }
642
643 /**
644 Save all components of Msa Header
645
646 **/
647 private void saveModule() {
648 msa = null;
649 String path = Tools.convertPathToCurrentOsType(this.jTextFieldFilePath.getText());
650
651 //
652 // Save to memory
653 //
654 try {
655 MsaHeaderDocument.MsaHeader msaHeader = null;
656
657 msa = ModuleSurfaceArea.Factory.newInstance();
658 msaHeader = MsaHeaderDocument.MsaHeader.Factory.newInstance();
659
660 msaHeader.setModuleName(this.jTextFieldName.getText());
661 msaHeader.setGuidValue(this.jTextFieldGuid.getText());
662 msaHeader.setVersion(this.jTextFieldVersion.getText());
663 msaHeader.setModuleType(ModuleTypeDef.BASE);
664
665 msa.setMsaHeader(msaHeader);
666 } catch (Exception e) {
667 Log.err("Save ModuleSurfaceArea Document", e.getMessage());
668 return;
669 }
670
671 //
672 // Save to real file
673 //
674 try {
675 SaveFile.saveMsaFile(path, msa);
676 } catch (Exception e) {
677 Log.wrn("Save Module to file system", e.getMessage());
678 Log.err("Save Module to file system", e.getMessage());
679 return;
680 }
681
682 //
683 // Save to identification
684 //
685 mid = new ModuleIdentification(this.jTextFieldName.getText(), this.jTextFieldGuid.getText(),
686 this.jTextFieldVersion.getText(), path, jRadioButtonYes.isSelected());
687 mid.setPackageId(packages.elementAt(this.jComboBoxExistingPackage.getSelectedIndex()));
688 }
689
690 /**
691 Save all components of Spd Header
692
693 **/
694 private void savePackage() {
695 spd = null;
696 String path = Tools.convertPathToCurrentOsType(this.jTextFieldFilePath.getText());
697
698 //
699 // Save to memory
700 //
701 try {
702 SpdHeaderDocument.SpdHeader spdHeader = null;
703
704 spd = PackageSurfaceArea.Factory.newInstance();
705 spdHeader = SpdHeaderDocument.SpdHeader.Factory.newInstance();
706
707 spdHeader.setPackageName(this.jTextFieldName.getText());
708 spdHeader.setGuidValue(this.jTextFieldGuid.getText());
709 spdHeader.setVersion(this.jTextFieldVersion.getText());
710
711 spd.setSpdHeader(spdHeader);
712 } catch (Exception e) {
713 Log.wrn("Save Package Surface Area Description Document", e.getMessage());
714 return;
715 }
716
717 //
718 // Save to real file
719 //
720 try {
721 SaveFile.saveSpdFile(path, spd);
722
723 } catch (Exception e) {
724 Log.wrn("Save Package to file system", e.getMessage());
725 Log.err("Save Package to file system", e.getMessage());
726 return;
727 }
728
729 //
730 // Save to identification
731 //
732 pid = new PackageIdentification(this.jTextFieldName.getText(), this.jTextFieldGuid.getText(),
733 this.jTextFieldVersion.getText(), path);
734 }
735
736 /**
737 Save all components of Fpd Header
738
739 **/
740 private void savePlatform() {
741 fpd = null;
742 String path = Tools.convertPathToCurrentOsType(this.jTextFieldFilePath.getText());
743
744 //
745 // Save to memory
746 //
747 try {
748 PlatformHeader fpdHeader = null;
749
750 fpd = PlatformSurfaceArea.Factory.newInstance();
751 fpdHeader = PlatformHeader.Factory.newInstance();
752
753 fpdHeader.setPlatformName(this.jTextFieldName.getText());
754 fpdHeader.setGuidValue(this.jTextFieldGuid.getText());
755 fpdHeader.setVersion(this.jTextFieldVersion.getText());
756
757 fpd.setPlatformHeader(fpdHeader);
758 } catch (Exception e) {
759 Log.wrn("Save Framework Platform Description Document", e.getMessage());
760 return;
761 }
762
763 //
764 // Save to real file
765 //
766 try {
767 SaveFile.saveFpdFile(path, fpd);
768
769 } catch (Exception e) {
770 Log.wrn("Save Platform to file system", e.getMessage());
771 Log.err("Save Platform to file system", e.getMessage());
772 return;
773 }
774
775 //
776 // Save to identification
777 //
778 fid = new PlatformIdentification(this.jTextFieldName.getText(), this.jTextFieldGuid.getText(),
779 this.jTextFieldVersion.getText(), path);
780 }
781
782 public ModuleIdentification getMid() {
783 return mid;
784 }
785
786 public PlatformIdentification getFid() {
787 return fid;
788 }
789
790 public PackageIdentification getPid() {
791 return pid;
792 }
793
794 private void upLocation(Component c, int size) {
795 c.setLocation(c.getLocation().x, c.getLocation().y - size);
796 }
797
798 public PlatformSurfaceArea getFpd() {
799 return fpd;
800 }
801
802 public ModuleSurfaceArea getMsa() {
803 return msa;
804 }
805
806 public PackageSurfaceArea getSpd() {
807 return spd;
808 }
809 }