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