]> git.proxmox.com Git - mirror_edk2.git/blob - Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/Identifications/OpeningPackageList.java
1. Restructure some folders and files
[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
23 public class OpeningPackageList {
24 private Vector<OpeningPackageType> vOpeningPackageList = new Vector<OpeningPackageType>();
25
26 public OpeningPackageList() {
27
28 }
29
30 public Vector<OpeningPackageType> getVOpeningPackageList() {
31 return vOpeningPackageList;
32 }
33
34 public void setVOpeningPackageList(Vector<OpeningPackageType> openingPackageList) {
35 vOpeningPackageList = openingPackageList;
36 }
37
38 public void insertToOpeningPackageList(Identification id, PackageSurfaceAreaDocument.PackageSurfaceArea xmlMsa) {
39 vOpeningPackageList.addElement(new OpeningPackageType(id, xmlMsa));
40 }
41
42 public OpeningPackageType getOpeningPackageByIndex(int index) {
43 if (index > -1 && index < vOpeningPackageList.size()) {
44 return vOpeningPackageList.elementAt(index);
45 }
46 return null;
47 }
48
49 public OpeningPackageType getOpeningPackageById(Identification id) {
50 int index = findIndexOfListById(id);
51 if (index > -1) {
52 return vOpeningPackageList.elementAt(index);
53 }
54 return null;
55 }
56
57 public int findIndexOfListById(Identification id) {
58 for (int index = 0; index < vOpeningPackageList.size(); index++) {
59 if (vOpeningPackageList.elementAt(index).getId().equals(id)) {
60 return index;
61 }
62 }
63 return -1;
64 }
65
66 public void removeFromOpeningPackageListByIndex(int index) {
67 if (index > -1 && index < vOpeningPackageList.size()) {
68 vOpeningPackageList.removeElementAt(index);
69 }
70 }
71
72 public void removeFromOpeningPackageListById(Identification id) {
73 int index = findIndexOfListById(id);
74 if (index > -1) {
75 vOpeningPackageList.removeElementAt(findIndexOfListById(id));
76 }
77 }
78
79 public void removeAllFromOpeningPackageList() {
80 vOpeningPackageList.removeAllElements();
81 }
82
83 public PackageSurfaceAreaDocument.PackageSurfaceArea getPackageSurfaceAreaFromId(Identification id) {
84 int index = findIndexOfListById(id);
85 if (index > -1) {
86 return vOpeningPackageList.elementAt(index).getXmlSpd();
87 }
88 return null;
89 }
90
91 public boolean existsPackage(Identification id) {
92 int index = findIndexOfListById(id);
93 if (index > -1) {
94 return true;
95 }
96 return false;
97 }
98
99 public void setPackageSaved(Identification id, boolean isSaved) {
100 setPackageSaved(findIndexOfListById(id), isSaved);
101 }
102
103 public void setPackageSaved(int index, boolean isSaved) {
104 if (index > -1) {
105 vOpeningPackageList.elementAt(index).setSaved(isSaved);
106 }
107 }
108
109 public boolean getPackageSaved(Identification id) {
110 return getPackageSaved(findIndexOfListById(id));
111 }
112
113 public boolean getPackageSaved(int index) {
114 if (index > -1) {
115 return vOpeningPackageList.elementAt(index).isSaved();
116 }
117 return true;
118 }
119
120 public void setTreePathById(Identification id, TreePath treePath) {
121 int index = findIndexOfListById(id);
122 if (index > -1) {
123 vOpeningPackageList.elementAt(index).setTreePath(treePath);
124 }
125 }
126
127 public TreePath getTreePathById(Identification id) {
128 int index = findIndexOfListById(id);
129 if (index > -1) {
130 return vOpeningPackageList.elementAt(index).getTreePath();
131 }
132 return null;
133 }
134
135 public TreePath getTreePathByIndex(int index) {
136 if (index > -1) {
137 return vOpeningPackageList.elementAt(index).getTreePath();
138 }
139 return null;
140 }
141
142 public void setNew(Identification id, boolean isNew) {
143 int index = findIndexOfListById(id);
144 if (index > -1) {
145 vOpeningPackageList.elementAt(index).setNew(isNew);
146 }
147 }
148
149 public int size() {
150 return vOpeningPackageList.size();
151 }
152
153 public boolean isSaved() {
154 for (int index = 0; index < this.size(); index++) {
155 if (!this.getPackageSaved(index)) {
156 return false;
157 }
158 }
159 return true;
160 }
161
162 public boolean isOpend() {
163 if (this.size() > 0 ) {
164 return true;
165 }
166 return false;
167 }
168 }