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