3 The file is used to define opening module 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
.ModuleSurfaceAreaDocument
;
23 import org
.tianocore
.frameworkwizard
.module
.Identifications
.ModuleIdentification
;
25 public class OpeningModuleList
{
26 private Vector
<OpeningModuleType
> vOpeningModuleList
= new Vector
<OpeningModuleType
>();
28 public OpeningModuleList() {
32 public Vector
<OpeningModuleType
> getVOpeningModuleList() {
33 return vOpeningModuleList
;
36 public void setVOpeningModuleList(Vector
<OpeningModuleType
> openingModuleList
) {
37 vOpeningModuleList
= openingModuleList
;
40 public void insertToOpeningModuleList(ModuleIdentification id
, ModuleSurfaceAreaDocument
.ModuleSurfaceArea xmlMsa
) {
41 vOpeningModuleList
.addElement(new OpeningModuleType(id
, xmlMsa
));
44 public OpeningModuleType
getOpeningModuleByIndex(int index
) {
45 if (index
> -1 && index
< vOpeningModuleList
.size()) {
46 return vOpeningModuleList
.elementAt(index
);
51 public OpeningModuleType
getOpeningModuleById(ModuleIdentification id
) {
52 int index
= findIndexOfListById(id
);
54 return vOpeningModuleList
.elementAt(index
);
59 public int findIndexOfListById(ModuleIdentification id
) {
60 for (int index
= 0; index
< vOpeningModuleList
.size(); index
++) {
61 if (vOpeningModuleList
.elementAt(index
).getId().equals(id
)) {
68 public void removeFromOpeningModuleListByIndex(int index
) {
69 if (index
> -1 && index
< vOpeningModuleList
.size()) {
70 vOpeningModuleList
.removeElementAt(index
);
74 public void removeFromOpeningModuleListById(ModuleIdentification id
) {
75 int index
= findIndexOfListById(id
);
77 vOpeningModuleList
.removeElementAt(findIndexOfListById(id
));
81 public void removeAllFromOpeningModuleList() {
82 vOpeningModuleList
.removeAllElements();
85 public ModuleSurfaceAreaDocument
.ModuleSurfaceArea
getModuleSurfaceAreaFromId(ModuleIdentification id
) {
86 int index
= findIndexOfListById(id
);
88 return vOpeningModuleList
.elementAt(index
).getXmlMsa();
93 public boolean existsModule(ModuleIdentification id
) {
94 int index
= findIndexOfListById(id
);
101 public void setModuleSaved(ModuleIdentification id
, boolean isSaved
) {
102 setModuleSaved(findIndexOfListById(id
), isSaved
);
105 public void setModuleSaved(int index
, boolean isSaved
) {
107 vOpeningModuleList
.elementAt(index
).setSaved(isSaved
);
111 public boolean getModuleSaved(ModuleIdentification id
) {
112 return getModuleSaved(findIndexOfListById(id
));
115 public boolean getModuleSaved(int index
) {
117 return vOpeningModuleList
.elementAt(index
).isSaved();
122 public void setModuleOpen(ModuleIdentification id
, boolean isOpen
) {
123 setModuleOpen(findIndexOfListById(id
), isOpen
);
126 public void setModuleOpen(int index
, boolean isOpen
) {
128 vOpeningModuleList
.elementAt(index
).setOpen(isOpen
);
132 public boolean getModuleOpen(ModuleIdentification id
) {
133 return getModuleOpen(findIndexOfListById(id
));
136 public boolean getModuleOpen(int index
) {
138 return vOpeningModuleList
.elementAt(index
).isOpen();
143 public void setTreePathById(ModuleIdentification id
, Set
<TreePath
> treePath
) {
144 int index
= findIndexOfListById(id
);
146 vOpeningModuleList
.elementAt(index
).setTreePath(treePath
);
150 public Set
<TreePath
> getTreePathById(ModuleIdentification id
) {
151 int index
= findIndexOfListById(id
);
153 return vOpeningModuleList
.elementAt(index
).getTreePath();
158 public Set
<TreePath
> getTreePathByIndex(int index
) {
160 return vOpeningModuleList
.elementAt(index
).getTreePath();
165 public ModuleIdentification
getIdByPath(String path
) {
166 ModuleIdentification id
= new ModuleIdentification(null, null, null, path
);
167 int index
= findIndexOfListById(id
);
169 return vOpeningModuleList
.elementAt(index
).getId();
174 public ModuleIdentification
getIdByGuidVersion(String guid
, String version
) {
175 for (int index
= 0; index
< vOpeningModuleList
.size(); index
++) {
176 ModuleIdentification id
= vOpeningModuleList
.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(ModuleIdentification id
, boolean isNew
) {
191 int index
= findIndexOfListById(id
);
193 vOpeningModuleList
.elementAt(index
).setNew(isNew
);
197 public void closeAll() {
198 for (int index
= 0; index
< this.size(); index
++) {
199 this.setModuleOpen(index
, false);
200 this.setModuleSaved(index
, true);
205 return vOpeningModuleList
.size();
208 public boolean isSaved() {
209 for (int index
= 0; index
< this.size(); index
++) {
210 if (!this.getModuleSaved(index
)) {
217 public boolean isOpen() {
218 for (int index
= 0; index
< this.size(); index
++) {
219 if (this.getModuleOpen(index
)) {
226 public void reload(int index
) {
228 vOpeningModuleList
.elementAt(index
).reload();