3 The file is used to define opening package list
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
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.
15 package org
.tianocore
.frameworkwizard
.common
.Identifications
;
18 import java
.util
.Vector
;
20 import javax
.swing
.tree
.TreePath
;
22 import org
.tianocore
.PackageSurfaceAreaDocument
;
23 import org
.tianocore
.frameworkwizard
.packaging
.PackageIdentification
;
25 public class OpeningPackageList
{
26 private Vector
<OpeningPackageType
> vOpeningPackageList
= new Vector
<OpeningPackageType
>();
28 public OpeningPackageList() {
32 public Vector
<OpeningPackageType
> getVOpeningPackageList() {
33 return vOpeningPackageList
;
36 public void setVOpeningPackageList(Vector
<OpeningPackageType
> openingPackageList
) {
37 vOpeningPackageList
= openingPackageList
;
40 public void insertToOpeningPackageList(PackageIdentification id
, PackageSurfaceAreaDocument
.PackageSurfaceArea xmlMsa
) {
41 vOpeningPackageList
.addElement(new OpeningPackageType(id
, xmlMsa
));
44 public OpeningPackageType
getOpeningPackageByIndex(int index
) {
45 if (index
> -1 && index
< vOpeningPackageList
.size()) {
46 return vOpeningPackageList
.elementAt(index
);
51 public OpeningPackageType
getOpeningPackageById(PackageIdentification id
) {
52 int index
= findIndexOfListById(id
);
54 return vOpeningPackageList
.elementAt(index
);
59 public int findIndexOfListById(PackageIdentification id
) {
60 for (int index
= 0; index
< vOpeningPackageList
.size(); index
++) {
61 if (vOpeningPackageList
.elementAt(index
).getId().equals(id
)) {
68 public void removeFromOpeningPackageListByIndex(int index
) {
69 if (index
> -1 && index
< vOpeningPackageList
.size()) {
70 vOpeningPackageList
.removeElementAt(index
);
74 public void removeFromOpeningPackageListById(PackageIdentification id
) {
75 int index
= findIndexOfListById(id
);
77 vOpeningPackageList
.removeElementAt(findIndexOfListById(id
));
81 public void removeAllFromOpeningPackageList() {
82 vOpeningPackageList
.removeAllElements();
85 public PackageSurfaceAreaDocument
.PackageSurfaceArea
getPackageSurfaceAreaFromId(PackageIdentification id
) {
86 int index
= findIndexOfListById(id
);
88 return vOpeningPackageList
.elementAt(index
).getXmlSpd();
93 public boolean existsPackage(PackageIdentification id
) {
94 int index
= findIndexOfListById(id
);
101 public void setPackageSaved(PackageIdentification id
, boolean isSaved
) {
102 setPackageSaved(findIndexOfListById(id
), isSaved
);
105 public void setPackageSaved(int index
, boolean isSaved
) {
107 vOpeningPackageList
.elementAt(index
).setSaved(isSaved
);
111 public boolean getPackageSaved(PackageIdentification id
) {
112 return getPackageSaved(findIndexOfListById(id
));
115 public boolean getPackageSaved(int index
) {
117 return vOpeningPackageList
.elementAt(index
).isSaved();
122 public void setPackageOpen(PackageIdentification id
, boolean isOpem
) {
123 setPackageOpen(findIndexOfListById(id
), isOpem
);
126 public void setPackageOpen(int index
, boolean isOpem
) {
128 vOpeningPackageList
.elementAt(index
).setOpen(isOpem
);
132 public boolean getPackageOpen(PackageIdentification id
) {
133 return getPackageOpen(findIndexOfListById(id
));
136 public boolean getPackageOpen(int index
) {
138 return vOpeningPackageList
.elementAt(index
).isOpen();
143 public void setTreePathById(PackageIdentification id
, Set
<TreePath
> treePath
) {
144 int index
= findIndexOfListById(id
);
146 vOpeningPackageList
.elementAt(index
).setTreePath(treePath
);
150 public Set
<TreePath
> getTreePathById(PackageIdentification id
) {
151 int index
= findIndexOfListById(id
);
153 return vOpeningPackageList
.elementAt(index
).getTreePath();
158 public Set
<TreePath
> getTreePathByIndex(int index
) {
160 return vOpeningPackageList
.elementAt(index
).getTreePath();
165 public PackageIdentification
getIdByPath(String path
) {
166 PackageIdentification id
= new PackageIdentification(null, null, null, path
);
167 int index
= findIndexOfListById(id
);
169 return vOpeningPackageList
.elementAt(index
).getId();
174 public PackageIdentification
getIdByGuidVersion(String guid
, String version
) {
175 for (int index
= 0; index
< vOpeningPackageList
.size(); index
++) {
176 PackageIdentification id
= vOpeningPackageList
.elementAt(index
).getId();
177 if (version
!= null) {
178 if (id
.getGuid().equals(guid
) && id
.getVersion().equals(version
)) {
182 if (id
.getGuid().equals(guid
)) {
190 public void setNew(PackageIdentification id
, boolean isNew
) {
191 int index
= findIndexOfListById(id
);
193 vOpeningPackageList
.elementAt(index
).setNew(isNew
);
197 public void closeAll() {
198 for (int index
= 0; index
< this.size(); index
++) {
199 this.setPackageOpen(index
, false);
204 return vOpeningPackageList
.size();
207 public boolean isSaved() {
208 for (int index
= 0; index
< this.size(); index
++) {
209 if (!this.getPackageSaved(index
)) {
216 public boolean isOpen() {
217 for (int index
= 0; index
< this.size(); index
++) {
218 if (this.getPackageOpen(index
)) {