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