]> git.proxmox.com Git - mirror_edk2.git/blame_incremental - Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/Identifications/OpeningModuleList.java
Changed spelling to manifest
[mirror_edk2.git] / Tools / Source / FrameworkWizard / src / org / tianocore / frameworkwizard / common / Identifications / OpeningModuleList.java
... / ...
CommitLineData
1/** @file\r
2 \r
3 The file is used to define opening module list\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
15package org.tianocore.frameworkwizard.common.Identifications;\r
16\r
17import java.util.Set;\r
18import java.util.Vector;\r
19\r
20import javax.swing.tree.TreePath;\r
21\r
22import org.tianocore.ModuleSurfaceAreaDocument;\r
23import org.tianocore.frameworkwizard.module.Identifications.ModuleIdentification;\r
24\r
25public class OpeningModuleList {\r
26 private Vector<OpeningModuleType> vOpeningModuleList = new Vector<OpeningModuleType>();\r
27\r
28 public OpeningModuleList() {\r
29\r
30 }\r
31\r
32 public Vector<OpeningModuleType> getVOpeningModuleList() {\r
33 return vOpeningModuleList;\r
34 }\r
35\r
36 public void setVOpeningModuleList(Vector<OpeningModuleType> openingModuleList) {\r
37 vOpeningModuleList = openingModuleList;\r
38 }\r
39\r
40 public void insertToOpeningModuleList(ModuleIdentification id, ModuleSurfaceAreaDocument.ModuleSurfaceArea xmlMsa) {\r
41 vOpeningModuleList.addElement(new OpeningModuleType(id, xmlMsa));\r
42 }\r
43\r
44 public OpeningModuleType getOpeningModuleByIndex(int index) {\r
45 if (index > -1 && index < vOpeningModuleList.size()) {\r
46 return vOpeningModuleList.elementAt(index);\r
47 }\r
48 return null;\r
49 }\r
50\r
51 public OpeningModuleType getOpeningModuleById(ModuleIdentification id) {\r
52 int index = findIndexOfListById(id);\r
53 if (index > -1) {\r
54 return vOpeningModuleList.elementAt(index);\r
55 }\r
56 return null;\r
57 }\r
58\r
59 public int findIndexOfListById(ModuleIdentification id) {\r
60 for (int index = 0; index < vOpeningModuleList.size(); index++) {\r
61 if (vOpeningModuleList.elementAt(index).getId().equals(id)) {\r
62 return index;\r
63 }\r
64 }\r
65 return -1;\r
66 }\r
67\r
68 public void removeFromOpeningModuleListByIndex(int index) {\r
69 if (index > -1 && index < vOpeningModuleList.size()) {\r
70 vOpeningModuleList.removeElementAt(index);\r
71 }\r
72 }\r
73\r
74 public void removeFromOpeningModuleListById(ModuleIdentification id) {\r
75 int index = findIndexOfListById(id);\r
76 if (index > -1) {\r
77 vOpeningModuleList.removeElementAt(findIndexOfListById(id));\r
78 }\r
79 }\r
80\r
81 public void removeAllFromOpeningModuleList() {\r
82 vOpeningModuleList.removeAllElements();\r
83 }\r
84\r
85 public ModuleSurfaceAreaDocument.ModuleSurfaceArea getModuleSurfaceAreaFromId(ModuleIdentification id) {\r
86 int index = findIndexOfListById(id);\r
87 if (index > -1) {\r
88 return vOpeningModuleList.elementAt(index).getXmlMsa();\r
89 }\r
90 return null;\r
91 }\r
92\r
93 public boolean existsModule(ModuleIdentification id) {\r
94 int index = findIndexOfListById(id);\r
95 if (index > -1) {\r
96 return true;\r
97 }\r
98 return false;\r
99 }\r
100\r
101 public void setModuleSaved(ModuleIdentification id, boolean isSaved) {\r
102 setModuleSaved(findIndexOfListById(id), isSaved);\r
103 }\r
104\r
105 public void setModuleSaved(int index, boolean isSaved) {\r
106 if (index > -1) {\r
107 vOpeningModuleList.elementAt(index).setSaved(isSaved);\r
108 }\r
109 }\r
110\r
111 public boolean getModuleSaved(ModuleIdentification id) {\r
112 return getModuleSaved(findIndexOfListById(id));\r
113 }\r
114\r
115 public boolean getModuleSaved(int index) {\r
116 if (index > -1) {\r
117 return vOpeningModuleList.elementAt(index).isSaved();\r
118 }\r
119 return true;\r
120 }\r
121\r
122 public void setModuleOpen(ModuleIdentification id, boolean isOpen) {\r
123 setModuleOpen(findIndexOfListById(id), isOpen);\r
124 }\r
125\r
126 public void setModuleOpen(int index, boolean isOpen) {\r
127 if (index > -1) {\r
128 vOpeningModuleList.elementAt(index).setOpen(isOpen);\r
129 }\r
130 }\r
131\r
132 public boolean getModuleOpen(ModuleIdentification id) {\r
133 return getModuleOpen(findIndexOfListById(id));\r
134 }\r
135\r
136 public boolean getModuleOpen(int index) {\r
137 if (index > -1) {\r
138 return vOpeningModuleList.elementAt(index).isOpen();\r
139 }\r
140 return true;\r
141 }\r
142\r
143 public void setTreePathById(ModuleIdentification id, Set<TreePath> treePath) {\r
144 int index = findIndexOfListById(id);\r
145 if (index > -1) {\r
146 vOpeningModuleList.elementAt(index).setTreePath(treePath);\r
147 }\r
148 }\r
149\r
150 public Set<TreePath> getTreePathById(ModuleIdentification id) {\r
151 int index = findIndexOfListById(id);\r
152 if (index > -1) {\r
153 return vOpeningModuleList.elementAt(index).getTreePath();\r
154 }\r
155 return null;\r
156 }\r
157\r
158 public Set<TreePath> getTreePathByIndex(int index) {\r
159 if (index > -1) {\r
160 return vOpeningModuleList.elementAt(index).getTreePath();\r
161 }\r
162 return null;\r
163 }\r
164\r
165 public ModuleIdentification getIdByPath(String path) {\r
166 ModuleIdentification id = new ModuleIdentification(null, null, null, path);\r
167 int index = findIndexOfListById(id);\r
168 if (index > -1) {\r
169 return vOpeningModuleList.elementAt(index).getId();\r
170 }\r
171 return null;\r
172 }\r
173\r
174 public ModuleIdentification getIdByGuidVersion(String guid, String version) {\r
175 for (int index = 0; index < vOpeningModuleList.size(); index++) {\r
176 ModuleIdentification id = vOpeningModuleList.elementAt(index).getId();\r
177 if (version != null) {\r
178 if (id.getGuid().equals(guid) && id.getVersion().equals(version)) {\r
179 return id;\r
180 }\r
181 } else {\r
182 if (id.getGuid().equals(guid)) {\r
183 return id;\r
184 }\r
185 }\r
186 }\r
187 return null;\r
188 }\r
189\r
190 public void setNew(ModuleIdentification id, boolean isNew) {\r
191 int index = findIndexOfListById(id);\r
192 if (index > -1) {\r
193 vOpeningModuleList.elementAt(index).setNew(isNew);\r
194 }\r
195 }\r
196\r
197 public void closeAll() {\r
198 for (int index = 0; index < this.size(); index++) {\r
199 this.setModuleOpen(index, false);\r
200 }\r
201 }\r
202\r
203 public int size() {\r
204 return vOpeningModuleList.size();\r
205 }\r
206\r
207 public boolean isSaved() {\r
208 for (int index = 0; index < this.size(); index++) {\r
209 if (!this.getModuleSaved(index)) {\r
210 return false;\r
211 }\r
212 }\r
213 return true;\r
214 }\r
215\r
216 public boolean isOpen() {\r
217 for (int index = 0; index < this.size(); index++) {\r
218 if (this.getModuleOpen(index)) {\r
219 return true;\r
220 }\r
221 }\r
222 return false;\r
223 }\r
224}\r