]>
Commit | Line | Data |
---|---|---|
79cb6fdb | 1 | /** @file\r |
2 | \r | |
3 | The file is used to define opening package 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 | |
15 | package org.tianocore.frameworkwizard.common.Identifications;\r | |
16 | \r | |
09ef9242 | 17 | import java.util.Set;\r |
79cb6fdb | 18 | import java.util.Vector;\r |
19 | \r | |
20 | import javax.swing.tree.TreePath;\r | |
21 | \r | |
22 | import org.tianocore.PackageSurfaceAreaDocument;\r | |
739c6b04 | 23 | import org.tianocore.frameworkwizard.packaging.PackageIdentification;\r |
79cb6fdb | 24 | \r |
25 | public class OpeningPackageList {\r | |
26 | private Vector<OpeningPackageType> vOpeningPackageList = new Vector<OpeningPackageType>();\r | |
27 | \r | |
28 | public OpeningPackageList() {\r | |
29 | \r | |
30 | }\r | |
31 | \r | |
32 | public Vector<OpeningPackageType> getVOpeningPackageList() {\r | |
33 | return vOpeningPackageList;\r | |
34 | }\r | |
35 | \r | |
36 | public void setVOpeningPackageList(Vector<OpeningPackageType> openingPackageList) {\r | |
37 | vOpeningPackageList = openingPackageList;\r | |
38 | }\r | |
39 | \r | |
739c6b04 | 40 | public void insertToOpeningPackageList(PackageIdentification id, PackageSurfaceAreaDocument.PackageSurfaceArea xmlMsa) {\r |
79cb6fdb | 41 | vOpeningPackageList.addElement(new OpeningPackageType(id, xmlMsa));\r |
42 | }\r | |
43 | \r | |
44 | public OpeningPackageType getOpeningPackageByIndex(int index) {\r | |
45 | if (index > -1 && index < vOpeningPackageList.size()) {\r | |
46 | return vOpeningPackageList.elementAt(index);\r | |
47 | }\r | |
48 | return null;\r | |
49 | }\r | |
50 | \r | |
739c6b04 | 51 | public OpeningPackageType getOpeningPackageById(PackageIdentification id) {\r |
79cb6fdb | 52 | int index = findIndexOfListById(id);\r |
53 | if (index > -1) {\r | |
54 | return vOpeningPackageList.elementAt(index);\r | |
55 | }\r | |
56 | return null;\r | |
57 | }\r | |
58 | \r | |
739c6b04 | 59 | public int findIndexOfListById(PackageIdentification id) {\r |
79cb6fdb | 60 | for (int index = 0; index < vOpeningPackageList.size(); index++) {\r |
61 | if (vOpeningPackageList.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 removeFromOpeningPackageListByIndex(int index) {\r | |
69 | if (index > -1 && index < vOpeningPackageList.size()) {\r | |
70 | vOpeningPackageList.removeElementAt(index);\r | |
71 | }\r | |
72 | }\r | |
73 | \r | |
739c6b04 | 74 | public void removeFromOpeningPackageListById(PackageIdentification id) {\r |
79cb6fdb | 75 | int index = findIndexOfListById(id);\r |
76 | if (index > -1) {\r | |
77 | vOpeningPackageList.removeElementAt(findIndexOfListById(id));\r | |
78 | }\r | |
79 | }\r | |
80 | \r | |
81 | public void removeAllFromOpeningPackageList() {\r | |
82 | vOpeningPackageList.removeAllElements();\r | |
83 | }\r | |
84 | \r | |
739c6b04 | 85 | public PackageSurfaceAreaDocument.PackageSurfaceArea getPackageSurfaceAreaFromId(PackageIdentification id) {\r |
79cb6fdb | 86 | int index = findIndexOfListById(id);\r |
87 | if (index > -1) {\r | |
88 | return vOpeningPackageList.elementAt(index).getXmlSpd();\r | |
89 | }\r | |
90 | return null;\r | |
91 | }\r | |
92 | \r | |
739c6b04 | 93 | public boolean existsPackage(PackageIdentification 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 | |
100 | \r | |
739c6b04 | 101 | public void setPackageSaved(PackageIdentification id, boolean isSaved) {\r |
79cb6fdb | 102 | setPackageSaved(findIndexOfListById(id), isSaved);\r |
103 | }\r | |
104 | \r | |
105 | public void setPackageSaved(int index, boolean isSaved) {\r | |
106 | if (index > -1) {\r | |
107 | vOpeningPackageList.elementAt(index).setSaved(isSaved);\r | |
108 | }\r | |
109 | }\r | |
110 | \r | |
739c6b04 | 111 | public boolean getPackageSaved(PackageIdentification id) {\r |
79cb6fdb | 112 | return getPackageSaved(findIndexOfListById(id));\r |
113 | }\r | |
114 | \r | |
115 | public boolean getPackageSaved(int index) {\r | |
116 | if (index > -1) {\r | |
117 | return vOpeningPackageList.elementAt(index).isSaved();\r | |
118 | }\r | |
119 | return true;\r | |
120 | }\r | |
121 | \r | |
739c6b04 | 122 | public void setPackageOpen(PackageIdentification id, boolean isOpem) {\r |
123 | setPackageOpen(findIndexOfListById(id), isOpem);\r | |
124 | }\r | |
125 | \r | |
126 | public void setPackageOpen(int index, boolean isOpem) {\r | |
127 | if (index > -1) {\r | |
128 | vOpeningPackageList.elementAt(index).setOpen(isOpem);\r | |
129 | }\r | |
130 | }\r | |
131 | \r | |
132 | public boolean getPackageOpen(PackageIdentification id) {\r | |
133 | return getPackageOpen(findIndexOfListById(id));\r | |
134 | }\r | |
135 | \r | |
136 | public boolean getPackageOpen(int index) {\r | |
137 | if (index > -1) {\r | |
138 | return vOpeningPackageList.elementAt(index).isOpen();\r | |
139 | }\r | |
e421fb25 | 140 | return false;\r |
739c6b04 | 141 | }\r |
142 | \r | |
09ef9242 | 143 | public void setTreePathById(PackageIdentification id, Set<TreePath> treePath) {\r |
79cb6fdb | 144 | int index = findIndexOfListById(id);\r |
145 | if (index > -1) {\r | |
146 | vOpeningPackageList.elementAt(index).setTreePath(treePath);\r | |
147 | }\r | |
148 | }\r | |
149 | \r | |
09ef9242 | 150 | public Set<TreePath> getTreePathById(PackageIdentification id) {\r |
79cb6fdb | 151 | int index = findIndexOfListById(id);\r |
152 | if (index > -1) {\r | |
153 | return vOpeningPackageList.elementAt(index).getTreePath();\r | |
154 | }\r | |
155 | return null;\r | |
156 | }\r | |
157 | \r | |
09ef9242 | 158 | public Set<TreePath> getTreePathByIndex(int index) {\r |
79cb6fdb | 159 | if (index > -1) {\r |
160 | return vOpeningPackageList.elementAt(index).getTreePath();\r | |
161 | }\r | |
162 | return null;\r | |
163 | }\r | |
164 | \r | |
739c6b04 | 165 | public PackageIdentification getIdByPath(String path) {\r |
166 | PackageIdentification id = new PackageIdentification(null, null, null, path);\r | |
167 | int index = findIndexOfListById(id);\r | |
168 | if (index > -1) {\r | |
169 | return vOpeningPackageList.elementAt(index).getId();\r | |
170 | }\r | |
171 | return null;\r | |
172 | }\r | |
173 | \r | |
c25ad66c | 174 | public PackageIdentification getIdByGuidVersion(String guid, String version) {\r |
175 | for (int index = 0; index < vOpeningPackageList.size(); index++) {\r | |
176 | PackageIdentification id = vOpeningPackageList.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(PackageIdentification id, boolean isNew) {\r |
79cb6fdb | 191 | int index = findIndexOfListById(id);\r |
192 | if (index > -1) {\r | |
193 | vOpeningPackageList.elementAt(index).setNew(isNew);\r | |
194 | }\r | |
195 | }\r | |
196 | \r | |
739c6b04 | 197 | public void closeAll() {\r |
198 | for (int index = 0; index < this.size(); index++) {\r | |
199 | this.setPackageOpen(index, false);\r | |
cc95b47b | 200 | this.setPackageSaved(index, true);\r |
739c6b04 | 201 | }\r |
202 | }\r | |
203 | \r | |
79cb6fdb | 204 | public int size() {\r |
205 | return vOpeningPackageList.size();\r | |
206 | }\r | |
207 | \r | |
208 | public boolean isSaved() {\r | |
209 | for (int index = 0; index < this.size(); index++) {\r | |
210 | if (!this.getPackageSaved(index)) {\r | |
211 | return false;\r | |
212 | }\r | |
213 | }\r | |
214 | return true;\r | |
215 | }\r | |
216 | \r | |
739c6b04 | 217 | public boolean isOpen() {\r |
218 | for (int index = 0; index < this.size(); index++) {\r | |
219 | if (this.getPackageOpen(index)) {\r | |
220 | return true;\r | |
221 | }\r | |
79cb6fdb | 222 | }\r |
223 | return false;\r | |
224 | }\r | |
225 | }\r |