]> git.proxmox.com Git - mirror_edk2.git/blob - 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
1 /** @file
2
3 The file is used to define opening package list
4
5 Copyright (c) 2006, Intel Corporation
6 All rights reserved. This program and the accompanying materials
7 are licensed and made available under the terms and conditions of the BSD License
8 which accompanies this distribution. The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php
10
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
13
14 **/
15 package org.tianocore.frameworkwizard.common.Identifications;
16
17 import java.util.Vector;
18
19 import javax.swing.tree.TreePath;
20
21 import org.tianocore.PlatformSurfaceAreaDocument;
22 import org.tianocore.frameworkwizard.platform.PlatformIdentification;
23
24 public class OpeningPlatformList {
25
26 private Vector<OpeningPlatformType> vOpeningPlatformList = new Vector<OpeningPlatformType>();
27
28 public OpeningPlatformList() {
29
30 }
31
32 public Vector<OpeningPlatformType> getVOpeningPlatformList() {
33 return vOpeningPlatformList;
34 }
35
36 public void setVOpeningPlatformList(Vector<OpeningPlatformType> openingPlatformList) {
37 vOpeningPlatformList = openingPlatformList;
38 }
39
40 public void insertToOpeningPlatformList(PlatformIdentification id, PlatformSurfaceAreaDocument.PlatformSurfaceArea xmlFpd) {
41 vOpeningPlatformList.addElement(new OpeningPlatformType(id, xmlFpd));
42 }
43
44 public OpeningPlatformType getOpeningPlatformByIndex(int index) {
45 if (index > -1 && index < vOpeningPlatformList.size()) {
46 return vOpeningPlatformList.elementAt(index);
47 }
48 return null;
49 }
50
51 public OpeningPlatformType getOpeningPlatformById(PlatformIdentification id) {
52 int index = findIndexOfListById(id);
53 if (index > -1) {
54 return vOpeningPlatformList.elementAt(index);
55 }
56 return null;
57 }
58
59 public int findIndexOfListById(PlatformIdentification id) {
60 for (int index = 0; index < vOpeningPlatformList.size(); index++) {
61 if (vOpeningPlatformList.elementAt(index).getId().equals(id)) {
62 return index;
63 }
64 }
65 return -1;
66 }
67
68 public void removeFromOpeningPlatformListByIndex(int index) {
69 if (index > -1 && index < vOpeningPlatformList.size()) {
70 vOpeningPlatformList.removeElementAt(index);
71 }
72 }
73
74 public void removeFromOpeningPlatformListById(PlatformIdentification id) {
75 int index = findIndexOfListById(id);
76 if (index > -1) {
77 vOpeningPlatformList.removeElementAt(findIndexOfListById(id));
78 }
79 }
80
81 public void removeAllFromOpeningPlatformList() {
82 vOpeningPlatformList.removeAllElements();
83 }
84
85 public PlatformSurfaceAreaDocument.PlatformSurfaceArea getPlatformSurfaceAreaFromId(PlatformIdentification id) {
86 int index = findIndexOfListById(id);
87 if (index > -1) {
88 return vOpeningPlatformList.elementAt(index).getXmlFpd();
89 }
90 return null;
91 }
92
93 public boolean existsPlatform(PlatformIdentification id) {
94 int index = findIndexOfListById(id);
95 if (index > -1) {
96 return true;
97 }
98 return false;
99 }
100
101
102 public void setPlatformSaved(PlatformIdentification id, boolean isSaved) {
103 setPlatformSaved(findIndexOfListById(id), isSaved);
104 }
105
106 public void setPlatformSaved(int index, boolean isSaved) {
107 if (index > -1) {
108 vOpeningPlatformList.elementAt(index).setSaved(isSaved);
109 }
110 }
111
112 public boolean getPlatformSaved(PlatformIdentification id) {
113 return getPlatformSaved(findIndexOfListById(id));
114 }
115
116 public boolean getPlatformSaved(int index) {
117 if (index > -1) {
118 return vOpeningPlatformList.elementAt(index).isSaved();
119 }
120 return true;
121 }
122
123 public void setPlatformOpen(PlatformIdentification id, boolean isOpen) {
124 setPlatformOpen(findIndexOfListById(id), isOpen);
125 }
126
127 public void setPlatformOpen(int index, boolean isOpen) {
128 if (index > -1) {
129 vOpeningPlatformList.elementAt(index).setOpen(isOpen);
130 }
131 }
132
133 public boolean getPlatformOpen(PlatformIdentification id) {
134 return getPlatformOpen(findIndexOfListById(id));
135 }
136
137 public boolean getPlatformOpen(int index) {
138 if (index > -1) {
139 return vOpeningPlatformList.elementAt(index).isOpen();
140 }
141 return true;
142 }
143
144 public void setTreePathById(PlatformIdentification id, TreePath treePath) {
145 int index = findIndexOfListById(id);
146 if (index > -1) {
147 vOpeningPlatformList.elementAt(index).setTreePath(treePath);
148 }
149 }
150
151 public TreePath getTreePathById(PlatformIdentification id) {
152 int index = findIndexOfListById(id);
153 if (index > -1) {
154 return vOpeningPlatformList.elementAt(index).getTreePath();
155 }
156 return null;
157 }
158
159 public TreePath getTreePathByIndex(int index) {
160 if (index > -1) {
161 return vOpeningPlatformList.elementAt(index).getTreePath();
162 }
163 return null;
164 }
165
166 public PlatformIdentification getIdByPath(String path) {
167 PlatformIdentification id = new PlatformIdentification(null, null, null, path);
168 int index = findIndexOfListById(id);
169 if (index > -1) {
170 return vOpeningPlatformList.elementAt(index).getId();
171 }
172 return null;
173 }
174
175 public void setNew(PlatformIdentification id, boolean isNew) {
176 int index = findIndexOfListById(id);
177 if (index > -1) {
178 vOpeningPlatformList.elementAt(index).setNew(isNew);
179 }
180 }
181
182 public void closeAll() {
183 for (int index = 0; index < this.size(); index++) {
184 this.setPlatformOpen(index, false);
185 }
186 }
187
188 public int size() {
189 return vOpeningPlatformList.size();
190 }
191
192 public boolean isSaved() {
193 for (int index = 0; index < this.size(); index++) {
194 if (!this.getPlatformSaved(index)) {
195 return false;
196 }
197 }
198 return true;
199 }
200
201 public boolean isOpen() {
202 for (int index = 0; index < this.size(); index++) {
203 if (this.getPlatformOpen(index)) {
204 return true;
205 }
206 }
207 return false;
208 }
209 }