]>
Commit | Line | Data |
---|---|---|
79cb6fdb | 1 | /** @file\r |
2 | \r | |
3 | The file is used to define opening module list\r | |
4 | \r | |
5 | Copyright (c) 2006, Intel Corporation\r | |
6 | All rights reserved. This program and the accompanying materials\r | |
7 | are licensed and made available under the terms and conditions of the BSD License\r | |
8 | which accompanies this distribution. The full text of the license may be found at\r | |
9 | http://opensource.org/licenses/bsd-license.php\r | |
10 | \r | |
11 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
12 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
13 | \r | |
14 | **/\r | |
15 | package org.tianocore.frameworkwizard.common.Identifications;\r | |
16 | \r | |
17 | import java.util.Vector;\r | |
18 | \r | |
19 | import javax.swing.tree.TreePath;\r | |
20 | \r | |
21 | import org.tianocore.ModuleSurfaceAreaDocument;\r | |
22 | \r | |
23 | public class OpeningModuleList {\r | |
24 | private Vector<OpeningModuleType> vOpeningModuleList = new Vector<OpeningModuleType>();\r | |
25 | \r | |
26 | public OpeningModuleList() {\r | |
27 | \r | |
28 | }\r | |
29 | public Vector<OpeningModuleType> getVOpeningModuleList() {\r | |
30 | return vOpeningModuleList;\r | |
31 | }\r | |
32 | \r | |
33 | public void setVOpeningModuleList(Vector<OpeningModuleType> openingModuleList) {\r | |
34 | vOpeningModuleList = openingModuleList;\r | |
35 | }\r | |
36 | \r | |
37 | public void insertToOpeningModuleList(Identification id, ModuleSurfaceAreaDocument.ModuleSurfaceArea xmlMsa) {\r | |
38 | vOpeningModuleList.addElement(new OpeningModuleType(id, xmlMsa));\r | |
39 | }\r | |
40 | \r | |
41 | public OpeningModuleType getOpeningModuleByIndex(int index) {\r | |
42 | if (index > -1 && index < vOpeningModuleList.size()) {\r | |
43 | return vOpeningModuleList.elementAt(index);\r | |
44 | }\r | |
45 | return null;\r | |
46 | }\r | |
47 | \r | |
48 | public OpeningModuleType getOpeningModuleById(Identification id) {\r | |
49 | int index = findIndexOfListById(id);\r | |
50 | if (index > -1) {\r | |
51 | return vOpeningModuleList.elementAt(index);\r | |
52 | }\r | |
53 | return null;\r | |
54 | }\r | |
55 | \r | |
56 | public int findIndexOfListById(Identification id) {\r | |
57 | for (int index = 0; index < vOpeningModuleList.size(); index++) {\r | |
58 | if (vOpeningModuleList.elementAt(index).getId().equals(id)) {\r | |
59 | return index;\r | |
60 | }\r | |
61 | }\r | |
62 | return -1;\r | |
63 | }\r | |
64 | \r | |
65 | public void removeFromOpeningModuleListByIndex(int index) {\r | |
66 | if (index > -1 && index < vOpeningModuleList.size()) {\r | |
67 | vOpeningModuleList.removeElementAt(index);\r | |
68 | }\r | |
69 | }\r | |
70 | \r | |
71 | public void removeFromOpeningModuleListById(Identification id) {\r | |
72 | int index = findIndexOfListById(id);\r | |
73 | if (index > -1) {\r | |
74 | vOpeningModuleList.removeElementAt(findIndexOfListById(id));\r | |
75 | }\r | |
76 | }\r | |
77 | \r | |
78 | public void removeAllFromOpeningModuleList() {\r | |
79 | vOpeningModuleList.removeAllElements();\r | |
80 | }\r | |
81 | \r | |
82 | public ModuleSurfaceAreaDocument.ModuleSurfaceArea getModuleSurfaceAreaFromId(Identification id) {\r | |
83 | int index = findIndexOfListById(id);\r | |
84 | if (index > -1) {\r | |
85 | return vOpeningModuleList.elementAt(index).getXmlMsa();\r | |
86 | }\r | |
87 | return null;\r | |
88 | }\r | |
89 | \r | |
90 | public boolean existsModule(Identification id) {\r | |
91 | int index = findIndexOfListById(id);\r | |
92 | if (index > -1) {\r | |
93 | return true;\r | |
94 | }\r | |
95 | return false;\r | |
96 | }\r | |
97 | \r | |
98 | public void setModuleSaved(Identification id, boolean isSaved) {\r | |
99 | setModuleSaved(findIndexOfListById(id), isSaved);\r | |
100 | }\r | |
101 | \r | |
102 | public void setModuleSaved(int index, boolean isSaved) {\r | |
103 | if (index > -1) {\r | |
104 | vOpeningModuleList.elementAt(index).setSaved(isSaved);\r | |
105 | }\r | |
106 | }\r | |
107 | \r | |
108 | public boolean getModuleSaved(Identification id) {\r | |
109 | return getModuleSaved(findIndexOfListById(id));\r | |
110 | }\r | |
111 | \r | |
112 | public boolean getModuleSaved(int index) {\r | |
113 | if (index > -1) {\r | |
114 | return vOpeningModuleList.elementAt(index).isSaved();\r | |
115 | }\r | |
116 | return true;\r | |
117 | }\r | |
118 | \r | |
119 | public void setTreePathById(Identification id, TreePath treePath) {\r | |
120 | int index = findIndexOfListById(id);\r | |
121 | if (index > -1) {\r | |
122 | vOpeningModuleList.elementAt(index).setTreePath(treePath);\r | |
123 | }\r | |
124 | }\r | |
125 | \r | |
126 | public TreePath getTreePathById(Identification id) {\r | |
127 | int index = findIndexOfListById(id);\r | |
128 | if (index > -1) {\r | |
129 | return vOpeningModuleList.elementAt(index).getTreePath();\r | |
130 | }\r | |
131 | return null;\r | |
132 | }\r | |
133 | \r | |
134 | public TreePath getTreePathByIndex(int index) {\r | |
135 | if (index > -1) {\r | |
136 | return vOpeningModuleList.elementAt(index).getTreePath();\r | |
137 | }\r | |
138 | return null;\r | |
139 | }\r | |
140 | \r | |
141 | public void setNew(Identification id, boolean isNew) {\r | |
142 | int index = findIndexOfListById(id);\r | |
143 | if (index > -1) {\r | |
144 | vOpeningModuleList.elementAt(index).setNew(isNew);\r | |
145 | }\r | |
146 | }\r | |
147 | \r | |
148 | public int size() {\r | |
149 | return vOpeningModuleList.size();\r | |
150 | }\r | |
151 | \r | |
152 | public boolean isSaved() {\r | |
153 | for (int index = 0; index < this.size(); index++) {\r | |
154 | if (!this.getModuleSaved(index)) {\r | |
155 | return false;\r | |
156 | }\r | |
157 | }\r | |
158 | return true;\r | |
159 | }\r | |
160 | \r | |
161 | public boolean isOpend() {\r | |
162 | if (this.size() > 0 ) {\r | |
163 | return true;\r | |
164 | }\r | |
165 | return false;\r | |
166 | }\r | |
167 | }\r |