]>
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.PlatformSurfaceAreaDocument;\r | |
739c6b04 | 23 | import org.tianocore.frameworkwizard.platform.PlatformIdentification;\r |
79cb6fdb | 24 | \r |
25 | public class OpeningPlatformList {\r | |
26 | \r | |
27 | private Vector<OpeningPlatformType> vOpeningPlatformList = new Vector<OpeningPlatformType>();\r | |
28 | \r | |
29 | public OpeningPlatformList() {\r | |
30 | \r | |
31 | }\r | |
32 | \r | |
33 | public Vector<OpeningPlatformType> getVOpeningPlatformList() {\r | |
34 | return vOpeningPlatformList;\r | |
35 | }\r | |
36 | \r | |
37 | public void setVOpeningPlatformList(Vector<OpeningPlatformType> openingPlatformList) {\r | |
38 | vOpeningPlatformList = openingPlatformList;\r | |
39 | }\r | |
40 | \r | |
739c6b04 | 41 | public void insertToOpeningPlatformList(PlatformIdentification id, PlatformSurfaceAreaDocument.PlatformSurfaceArea xmlFpd) {\r |
79cb6fdb | 42 | vOpeningPlatformList.addElement(new OpeningPlatformType(id, xmlFpd));\r |
43 | }\r | |
44 | \r | |
45 | public OpeningPlatformType getOpeningPlatformByIndex(int index) {\r | |
46 | if (index > -1 && index < vOpeningPlatformList.size()) {\r | |
47 | return vOpeningPlatformList.elementAt(index);\r | |
48 | }\r | |
49 | return null;\r | |
50 | }\r | |
51 | \r | |
739c6b04 | 52 | public OpeningPlatformType getOpeningPlatformById(PlatformIdentification id) {\r |
79cb6fdb | 53 | int index = findIndexOfListById(id);\r |
54 | if (index > -1) {\r | |
55 | return vOpeningPlatformList.elementAt(index);\r | |
56 | }\r | |
57 | return null;\r | |
58 | }\r | |
59 | \r | |
739c6b04 | 60 | public int findIndexOfListById(PlatformIdentification id) {\r |
79cb6fdb | 61 | for (int index = 0; index < vOpeningPlatformList.size(); index++) {\r |
62 | if (vOpeningPlatformList.elementAt(index).getId().equals(id)) {\r | |
63 | return index;\r | |
64 | }\r | |
65 | }\r | |
66 | return -1;\r | |
67 | }\r | |
68 | \r | |
69 | public void removeFromOpeningPlatformListByIndex(int index) {\r | |
70 | if (index > -1 && index < vOpeningPlatformList.size()) {\r | |
71 | vOpeningPlatformList.removeElementAt(index);\r | |
72 | }\r | |
73 | }\r | |
74 | \r | |
739c6b04 | 75 | public void removeFromOpeningPlatformListById(PlatformIdentification id) {\r |
79cb6fdb | 76 | int index = findIndexOfListById(id);\r |
77 | if (index > -1) {\r | |
78 | vOpeningPlatformList.removeElementAt(findIndexOfListById(id));\r | |
79 | }\r | |
80 | }\r | |
81 | \r | |
82 | public void removeAllFromOpeningPlatformList() {\r | |
83 | vOpeningPlatformList.removeAllElements();\r | |
84 | }\r | |
85 | \r | |
739c6b04 | 86 | public PlatformSurfaceAreaDocument.PlatformSurfaceArea getPlatformSurfaceAreaFromId(PlatformIdentification id) {\r |
79cb6fdb | 87 | int index = findIndexOfListById(id);\r |
88 | if (index > -1) {\r | |
89 | return vOpeningPlatformList.elementAt(index).getXmlFpd();\r | |
90 | }\r | |
91 | return null;\r | |
92 | }\r | |
93 | \r | |
739c6b04 | 94 | public boolean existsPlatform(PlatformIdentification id) {\r |
79cb6fdb | 95 | int index = findIndexOfListById(id);\r |
96 | if (index > -1) {\r | |
97 | return true;\r | |
98 | }\r | |
99 | return false;\r | |
100 | }\r | |
101 | \r | |
102 | \r | |
739c6b04 | 103 | public void setPlatformSaved(PlatformIdentification id, boolean isSaved) {\r |
79cb6fdb | 104 | setPlatformSaved(findIndexOfListById(id), isSaved);\r |
105 | }\r | |
106 | \r | |
107 | public void setPlatformSaved(int index, boolean isSaved) {\r | |
108 | if (index > -1) {\r | |
109 | vOpeningPlatformList.elementAt(index).setSaved(isSaved);\r | |
110 | }\r | |
111 | }\r | |
112 | \r | |
739c6b04 | 113 | public boolean getPlatformSaved(PlatformIdentification id) {\r |
79cb6fdb | 114 | return getPlatformSaved(findIndexOfListById(id));\r |
115 | }\r | |
116 | \r | |
117 | public boolean getPlatformSaved(int index) {\r | |
118 | if (index > -1) {\r | |
119 | return vOpeningPlatformList.elementAt(index).isSaved();\r | |
120 | }\r | |
121 | return true;\r | |
122 | }\r | |
123 | \r | |
739c6b04 | 124 | public void setPlatformOpen(PlatformIdentification id, boolean isOpen) {\r |
125 | setPlatformOpen(findIndexOfListById(id), isOpen);\r | |
126 | }\r | |
127 | \r | |
128 | public void setPlatformOpen(int index, boolean isOpen) {\r | |
129 | if (index > -1) {\r | |
130 | vOpeningPlatformList.elementAt(index).setOpen(isOpen);\r | |
131 | }\r | |
132 | }\r | |
133 | \r | |
134 | public boolean getPlatformOpen(PlatformIdentification id) {\r | |
135 | return getPlatformOpen(findIndexOfListById(id));\r | |
136 | }\r | |
137 | \r | |
138 | public boolean getPlatformOpen(int index) {\r | |
139 | if (index > -1) {\r | |
140 | return vOpeningPlatformList.elementAt(index).isOpen();\r | |
141 | }\r | |
e421fb25 | 142 | return false;\r |
739c6b04 | 143 | }\r |
144 | \r | |
09ef9242 | 145 | public void setTreePathById(PlatformIdentification id, Set<TreePath> treePath) {\r |
79cb6fdb | 146 | int index = findIndexOfListById(id);\r |
147 | if (index > -1) {\r | |
148 | vOpeningPlatformList.elementAt(index).setTreePath(treePath);\r | |
149 | }\r | |
150 | }\r | |
151 | \r | |
09ef9242 | 152 | public Set<TreePath> getTreePathById(PlatformIdentification id) {\r |
79cb6fdb | 153 | int index = findIndexOfListById(id);\r |
154 | if (index > -1) {\r | |
155 | return vOpeningPlatformList.elementAt(index).getTreePath();\r | |
156 | }\r | |
157 | return null;\r | |
158 | }\r | |
159 | \r | |
09ef9242 | 160 | public Set<TreePath> getTreePathByIndex(int index) {\r |
79cb6fdb | 161 | if (index > -1) {\r |
162 | return vOpeningPlatformList.elementAt(index).getTreePath();\r | |
163 | }\r | |
164 | return null;\r | |
165 | }\r | |
166 | \r | |
739c6b04 | 167 | public PlatformIdentification getIdByPath(String path) {\r |
168 | PlatformIdentification id = new PlatformIdentification(null, null, null, path);\r | |
169 | int index = findIndexOfListById(id);\r | |
170 | if (index > -1) {\r | |
171 | return vOpeningPlatformList.elementAt(index).getId();\r | |
172 | }\r | |
173 | return null;\r | |
174 | }\r | |
175 | \r | |
176 | public void setNew(PlatformIdentification id, boolean isNew) {\r | |
79cb6fdb | 177 | int index = findIndexOfListById(id);\r |
178 | if (index > -1) {\r | |
179 | vOpeningPlatformList.elementAt(index).setNew(isNew);\r | |
180 | }\r | |
181 | }\r | |
182 | \r | |
739c6b04 | 183 | public void closeAll() {\r |
184 | for (int index = 0; index < this.size(); index++) {\r | |
185 | this.setPlatformOpen(index, false);\r | |
cc95b47b | 186 | this.setPlatformSaved(index, true);\r |
739c6b04 | 187 | }\r |
188 | }\r | |
189 | \r | |
79cb6fdb | 190 | public int size() {\r |
191 | return vOpeningPlatformList.size();\r | |
192 | }\r | |
193 | \r | |
194 | public boolean isSaved() {\r | |
195 | for (int index = 0; index < this.size(); index++) {\r | |
196 | if (!this.getPlatformSaved(index)) {\r | |
197 | return false;\r | |
198 | }\r | |
199 | }\r | |
200 | return true;\r | |
201 | }\r | |
202 | \r | |
739c6b04 | 203 | public boolean isOpen() {\r |
204 | for (int index = 0; index < this.size(); index++) {\r | |
205 | if (this.getPlatformOpen(index)) {\r | |
206 | return true;\r | |
207 | }\r | |
79cb6fdb | 208 | }\r |
209 | return false;\r | |
210 | }\r | |
211 | }\r |