]>
Commit | Line | Data |
---|---|---|
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 | |
17 | import java.util.Set;\r | |
18 | import java.util.Vector;\r | |
19 | \r | |
20 | import javax.swing.tree.TreePath;\r | |
21 | \r | |
22 | import org.tianocore.PackageSurfaceAreaDocument;\r | |
23 | import org.tianocore.frameworkwizard.packaging.PackageIdentification;\r | |
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 | |
40 | public void insertToOpeningPackageList(PackageIdentification id, PackageSurfaceAreaDocument.PackageSurfaceArea xmlMsa) {\r | |
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 | |
51 | public OpeningPackageType getOpeningPackageById(PackageIdentification id) {\r | |
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 | |
59 | public int findIndexOfListById(PackageIdentification id) {\r | |
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 | |
74 | public void removeFromOpeningPackageListById(PackageIdentification id) {\r | |
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 | |
85 | public PackageSurfaceAreaDocument.PackageSurfaceArea getPackageSurfaceAreaFromId(PackageIdentification id) {\r | |
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 | |
93 | public boolean existsPackage(PackageIdentification 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 setPackageSaved(PackageIdentification id, boolean isSaved) {\r | |
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 | |
111 | public boolean getPackageSaved(PackageIdentification id) {\r | |
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 | |
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 | |
140 | return false;\r | |
141 | }\r | |
142 | \r | |
143 | public void setTreePathById(PackageIdentification id, Set<TreePath> treePath) {\r | |
144 | int index = findIndexOfListById(id);\r | |
145 | if (index > -1) {\r | |
146 | vOpeningPackageList.elementAt(index).setTreePath(treePath);\r | |
147 | }\r | |
148 | }\r | |
149 | \r | |
150 | public Set<TreePath> getTreePathById(PackageIdentification id) {\r | |
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 | |
158 | public Set<TreePath> getTreePathByIndex(int index) {\r | |
159 | if (index > -1) {\r | |
160 | return vOpeningPackageList.elementAt(index).getTreePath();\r | |
161 | }\r | |
162 | return null;\r | |
163 | }\r | |
164 | \r | |
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 | |
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 | |
190 | public void setNew(PackageIdentification id, boolean isNew) {\r | |
191 | int index = findIndexOfListById(id);\r | |
192 | if (index > -1) {\r | |
193 | vOpeningPackageList.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.setPackageOpen(index, false);\r | |
200 | this.setPackageSaved(index, true);\r | |
201 | }\r | |
202 | }\r | |
203 | \r | |
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 | |
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 | |
222 | }\r | |
223 | return false;\r | |
224 | }\r | |
225 | }\r |