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