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