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