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