]> git.proxmox.com Git - mirror_edk2.git/blame - Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/Identifications/ModuleIdentification.java
1. Restructure module description on main UI
[mirror_edk2.git] / Tools / Source / FrameworkWizard / src / org / tianocore / frameworkwizard / module / Identifications / ModuleIdentification.java
CommitLineData
a13899c5 1/** @file\r
2 \r
3 The file is used to save basic information of module\r
4 \r
5 Copyright (c) 2006, Intel Corporation\r
6 All rights reserved. This program and the accompanying materials\r
7 are licensed and made available under the terms and conditions of the BSD License\r
8 which accompanies this distribution. The full text of the license may be found at\r
9 http://opensource.org/licenses/bsd-license.php\r
10 \r
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
13 \r
14 **/\r
15\r
79cb6fdb 16package org.tianocore.frameworkwizard.module.Identifications;\r
a13899c5 17\r
18\r
92e29378 19import java.io.IOException;\r
20\r
21import org.apache.xmlbeans.XmlException;\r
22import org.tianocore.LibraryUsage;\r
23import org.tianocore.LibraryClassDefinitionsDocument.LibraryClassDefinitions;\r
24import org.tianocore.ModuleSurfaceAreaDocument.ModuleSurfaceArea;\r
25import org.tianocore.frameworkwizard.common.DataType;\r
79cb6fdb 26import org.tianocore.frameworkwizard.common.Identifications.Identification;\r
92e29378 27import org.tianocore.frameworkwizard.common.Identifications.OpenFile;\r
a13899c5 28import org.tianocore.frameworkwizard.packaging.PackageIdentification;\r
29\r
30public class ModuleIdentification extends Identification {\r
31 \r
32 private PackageIdentification packageId;\r
33 \r
92e29378 34 private String moduleType;\r
35 \r
36 private boolean isLibrary;\r
37 \r
a13899c5 38 public ModuleIdentification(String name, String guid, String version, String path) {\r
39 super(name, guid, version, path);\r
92e29378 40 setModuleType();\r
a13899c5 41 }\r
42 \r
92e29378 43 public ModuleIdentification(String name, String guid, String version, String path, boolean library) {\r
44 super(name, guid, version, path);\r
45 this.isLibrary = library;\r
46 }\r
47 \r
48 public ModuleIdentification(Identification id, boolean library) {\r
a13899c5 49 super(id.getName(), id.getGuid(), id.getVersion(), id.getPath());\r
92e29378 50 this.isLibrary = library;\r
a13899c5 51 }\r
52 \r
53 public ModuleIdentification(String name, String guid, String version, String path, PackageIdentification packageId){\r
54 super(name, guid, version, path);\r
55 this.packageId = packageId;\r
92e29378 56 setModuleType();\r
57 }\r
58 \r
59 public ModuleIdentification(String name, String guid, String version, String path, PackageIdentification packageId, String type){\r
60 super(name, guid, version, path);\r
61 this.packageId = packageId;\r
62 this.moduleType = type;\r
a13899c5 63 }\r
64 \r
65 public ModuleIdentification(Identification id, PackageIdentification packageId) {\r
66 super(id.getName(), id.getGuid(), id.getVersion(), id.getPath());\r
67 this.packageId = packageId;\r
92e29378 68 setModuleType();\r
a13899c5 69 }\r
70 \r
92e29378 71 public ModuleIdentification(Identification id, PackageIdentification packageId, boolean library) {\r
72 super(id.getName(), id.getGuid(), id.getVersion(), id.getPath());\r
73 this.packageId = packageId;\r
74 this.isLibrary = library;\r
75 }\r
76 \r
77 public ModuleIdentification(Identification id, PackageIdentification packageId, String type) {\r
78 super(id.getName(), id.getGuid(), id.getVersion(), id.getPath());\r
79 this.packageId = packageId;\r
80 this.moduleType = type;\r
81 }\r
a13899c5 82 \r
83 public String toString(){\r
84 return "Module " + this.getName() + "[" + this.getGuid() + "] in package " + packageId;\r
85 }\r
86\r
87 public PackageIdentification getPackageId() {\r
88 return packageId;\r
89 }\r
90\r
91 public void setPackageId(PackageIdentification packageId) {\r
92 this.packageId = packageId;\r
93 }\r
92e29378 94\r
95 public String getModuleType() {\r
96 return moduleType;\r
97 }\r
98\r
99 public void setModuleType(String moduleType) {\r
100 this.moduleType = moduleType;\r
101 }\r
102 \r
103 private void setModuleType() {\r
104 ModuleSurfaceArea msa = null;\r
105 try {\r
106 msa = OpenFile.openMsaFile(this.getPath());\r
107 } catch (IOException e) {\r
108 // TODO Auto-generated catch block\r
109 \r
110 } catch (XmlException e) {\r
111 // TODO Auto-generated catch block\r
112 \r
113 } catch (Exception e) {\r
114 // TODO Auto-generated catch block\r
115 \r
116 }\r
117 setModuleType(DataType.MODULE_TYPE_MODULE);\r
118 setLibrary(false);\r
119 if (msa != null) {\r
120 LibraryClassDefinitions lib = msa.getLibraryClassDefinitions();\r
121 if (lib != null) {\r
122 for (int index = 0; index < lib.getLibraryClassList().size(); index++) {\r
123 if (lib.getLibraryClassList().get(index).getUsage().equals(LibraryUsage.ALWAYS_PRODUCED)) {\r
124 setModuleType(DataType.MODULE_TYPE_LIBRARY);\r
125 setLibrary(true);\r
126 break;\r
127 }\r
128 }\r
129 }\r
130 }\r
131 }\r
132\r
133 public boolean isLibrary() {\r
134 return isLibrary;\r
135 }\r
136\r
137 public void setLibrary(boolean isLibrary) {\r
138 this.isLibrary = isLibrary;\r
139 }\r
a13899c5 140}\r