]> git.proxmox.com Git - mirror_edk2.git/blame - 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
79cb6fdb 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
09ef9242 17import java.util.Set;\r
79cb6fdb 18import java.util.Vector;\r
19\r
20import javax.swing.tree.TreePath;\r
21\r
22import org.tianocore.ModuleSurfaceAreaDocument;\r
739c6b04 23import org.tianocore.frameworkwizard.module.Identifications.ModuleIdentification;\r
79cb6fdb 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
09ef9242 31\r
79cb6fdb 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
09ef9242 39\r
739c6b04 40 public void insertToOpeningModuleList(ModuleIdentification id, ModuleSurfaceAreaDocument.ModuleSurfaceArea xmlMsa) {\r
79cb6fdb 41 vOpeningModuleList.addElement(new OpeningModuleType(id, xmlMsa));\r
42 }\r
09ef9242 43\r
79cb6fdb 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
09ef9242 50\r
739c6b04 51 public OpeningModuleType getOpeningModuleById(ModuleIdentification id) {\r
79cb6fdb 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
09ef9242 58\r
739c6b04 59 public int findIndexOfListById(ModuleIdentification id) {\r
79cb6fdb 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
09ef9242 67\r
79cb6fdb 68 public void removeFromOpeningModuleListByIndex(int index) {\r
69 if (index > -1 && index < vOpeningModuleList.size()) {\r
70 vOpeningModuleList.removeElementAt(index);\r
71 }\r
72 }\r
09ef9242 73\r
739c6b04 74 public void removeFromOpeningModuleListById(ModuleIdentification id) {\r
79cb6fdb 75 int index = findIndexOfListById(id);\r
76 if (index > -1) {\r
77 vOpeningModuleList.removeElementAt(findIndexOfListById(id));\r
78 }\r
79 }\r
09ef9242 80\r
79cb6fdb 81 public void removeAllFromOpeningModuleList() {\r
82 vOpeningModuleList.removeAllElements();\r
83 }\r
09ef9242 84\r
739c6b04 85 public ModuleSurfaceAreaDocument.ModuleSurfaceArea getModuleSurfaceAreaFromId(ModuleIdentification id) {\r
79cb6fdb 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
09ef9242 92\r
739c6b04 93 public boolean existsModule(ModuleIdentification id) {\r
79cb6fdb 94 int index = findIndexOfListById(id);\r
95 if (index > -1) {\r
96 return true;\r
97 }\r
98 return false;\r
99 }\r
09ef9242 100\r
739c6b04 101 public void setModuleSaved(ModuleIdentification id, boolean isSaved) {\r
79cb6fdb 102 setModuleSaved(findIndexOfListById(id), isSaved);\r
103 }\r
09ef9242 104\r
79cb6fdb 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
09ef9242 110\r
739c6b04 111 public boolean getModuleSaved(ModuleIdentification id) {\r
79cb6fdb 112 return getModuleSaved(findIndexOfListById(id));\r
113 }\r
09ef9242 114\r
79cb6fdb 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
09ef9242 121\r
739c6b04 122 public void setModuleOpen(ModuleIdentification id, boolean isOpen) {\r
123 setModuleOpen(findIndexOfListById(id), isOpen);\r
124 }\r
09ef9242 125\r
739c6b04 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
09ef9242 131\r
739c6b04 132 public boolean getModuleOpen(ModuleIdentification id) {\r
133 return getModuleOpen(findIndexOfListById(id));\r
134 }\r
09ef9242 135\r
739c6b04 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
09ef9242 142\r
143 public void setTreePathById(ModuleIdentification id, Set<TreePath> treePath) {\r
79cb6fdb 144 int index = findIndexOfListById(id);\r
145 if (index > -1) {\r
146 vOpeningModuleList.elementAt(index).setTreePath(treePath);\r
147 }\r
148 }\r
09ef9242 149\r
150 public Set<TreePath> getTreePathById(ModuleIdentification id) {\r
79cb6fdb 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
09ef9242 157\r
158 public Set<TreePath> getTreePathByIndex(int index) {\r
79cb6fdb 159 if (index > -1) {\r
160 return vOpeningModuleList.elementAt(index).getTreePath();\r
161 }\r
162 return null;\r
163 }\r
09ef9242 164\r
739c6b04 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
09ef9242 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
739c6b04 190 public void setNew(ModuleIdentification id, boolean isNew) {\r
79cb6fdb 191 int index = findIndexOfListById(id);\r
192 if (index > -1) {\r
193 vOpeningModuleList.elementAt(index).setNew(isNew);\r
194 }\r
195 }\r
09ef9242 196\r
739c6b04 197 public void closeAll() {\r
198 for (int index = 0; index < this.size(); index++) {\r
09ef9242 199 this.setModuleOpen(index, false);\r
739c6b04 200 }\r
201 }\r
09ef9242 202\r
79cb6fdb 203 public int size() {\r
204 return vOpeningModuleList.size();\r
205 }\r
09ef9242 206\r
79cb6fdb 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
09ef9242 215\r
739c6b04 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
79cb6fdb 221 }\r
222 return false;\r
223 }\r
224}\r