]> git.proxmox.com Git - mirror_edk2.git/blob - Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/id/ModuleIdentification.java
913a65a45e1db283faa069036fc4f6665697db3d
[mirror_edk2.git] / Tools / Source / FrameworkWizard / src / org / tianocore / frameworkwizard / platform / ui / id / ModuleIdentification.java
1 package org.tianocore.frameworkwizard.platform.ui.id;
2
3 import java.io.File;
4
5 import org.tianocore.frameworkwizard.platform.ui.global.WorkspaceProfile;
6
7 public class ModuleIdentification extends Identification {
8
9 private PackageIdentification packageId;
10
11 private File msaFile;
12
13 private String moduleType;
14
15 private boolean isLibrary = false;
16
17 public boolean isLibrary() {
18 return isLibrary;
19 }
20
21 public void setLibrary(boolean isLibrary) {
22 this.isLibrary = isLibrary;
23 }
24
25 public File getMsaFile() throws Exception{
26 prepareMsaFile();
27 return msaFile;
28 }
29
30 public String getModuleRelativePath() throws Exception{
31 prepareMsaFile();
32 return msaFile.getParent().substring(packageId.getPackageDir().length() + 1);
33 }
34
35 private void prepareMsaFile()throws Exception{
36 if (msaFile == null) {
37 msaFile = WorkspaceProfile.getModuleFile(this);
38 }
39 }
40 public void setMsaFile(File msaFile) {
41 this.msaFile = msaFile;
42 }
43
44 public ModuleIdentification(String name, String guid, String version){
45 super(name, guid, version);
46 }
47
48 public ModuleIdentification(String name, String guid, String version, PackageIdentification packageId){
49 super(name, guid, version);
50 this.packageId = packageId;
51 }
52
53 public boolean equals(Object obj) {
54 if (obj instanceof ModuleIdentification) {
55 ModuleIdentification id = (ModuleIdentification)obj;
56 if (guid.equals(id.getGuid()) && packageId.equals(id.getPackage())) {
57 if (version == null || id.version == null) {
58 updateName(name, id.name);
59 return true;
60 }
61 else if (version.trim().equalsIgnoreCase("") || id.version.trim().equalsIgnoreCase("")){
62 updateName(name, id.name);
63 return true;
64 }
65 else if (version.equalsIgnoreCase(id.version)) {
66 updateName(name, id.name);
67 return true;
68 }
69 }
70 return false;
71 }
72 else {
73 return super.equals(obj);
74 }
75 }
76
77 public String toString(){
78 if (version == null || version.trim().equalsIgnoreCase("")) {
79 return "Module [" + name + "] in " + packageId;
80 }
81 else {
82 return "Module [" + name + " " + version + "] in " + packageId;
83 }
84 }
85
86 public void setPackage(PackageIdentification packageId) {
87 this.packageId = packageId;
88 }
89
90 public PackageIdentification getPackage() {
91 return packageId;
92 }
93
94 public String getModuleType() {
95 return moduleType;
96 }
97
98 public void setModuleType(String moduleType) {
99 this.moduleType = moduleType;
100 }
101 }