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