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