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