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