|
|||||||||||||||||||
Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
SimpleTreeStateModel.java | 0% | 0% | 0% | 0% |
|
1 | // Copyright 2004, 2005 The Apache Software Foundation | |
2 | // | |
3 | // Licensed under the Apache License, Version 2.0 (the "License"); | |
4 | // you may not use this file except in compliance with the License. | |
5 | // You may obtain a copy of the License at | |
6 | // | |
7 | // http://www.apache.org/licenses/LICENSE-2.0 | |
8 | // | |
9 | // Unless required by applicable law or agreed to in writing, software | |
10 | // distributed under the License is distributed on an "AS IS" BASIS, | |
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
12 | // See the License for the specific language governing permissions and | |
13 | // limitations under the License. | |
14 | ||
15 | package org.apache.tapestry.contrib.tree.simple; | |
16 | ||
17 | import java.io.Serializable; | |
18 | import java.util.HashSet; | |
19 | import java.util.Set; | |
20 | ||
21 | import org.apache.tapestry.contrib.tree.model.ITreeStateModel; | |
22 | ||
23 | /** | |
24 | * @author ceco | |
25 | */ | |
26 | public class SimpleTreeStateModel implements ITreeStateModel, Serializable | |
27 | { | |
28 | private static final long serialVersionUID = 9206852255511734400L; | |
29 | ||
30 | private Set m_setExpanded; | |
31 | private Object m_objSelectedNodeUID = null; | |
32 | ||
33 | /** | |
34 | * Constructor for SimpleTreeStateModel. | |
35 | */ | |
36 | 0 | public SimpleTreeStateModel() { |
37 | 0 | super(); |
38 | 0 | initialize(); |
39 | } | |
40 | 0 | private void initialize(){ |
41 | 0 | m_setExpanded = new HashSet(); |
42 | 0 | m_objSelectedNodeUID = null; |
43 | } | |
44 | ||
45 | /** | |
46 | * @see org.apache.tapestry.contrib.tree.model.ITreeStateModel#getExpandSelection() | |
47 | */ | |
48 | 0 | public Set getExpandSelection() { |
49 | 0 | return m_setExpanded; |
50 | } | |
51 | ||
52 | /** | |
53 | * @see org.apache.tapestry.contrib.tree.model.ITreeStateModel#expand(Object) | |
54 | */ | |
55 | 0 | public void expand(Object objUniqueKey) { |
56 | 0 | m_setExpanded.add(objUniqueKey); |
57 | //setSelectedNode(objUniqueKey); | |
58 | } | |
59 | ||
60 | /** | |
61 | * @see org.apache.tapestry.contrib.tree.model.ITreeStateModel#expandPath(Object) | |
62 | */ | |
63 | 0 | public void expandPath(Object objUniqueKey) { |
64 | 0 | m_setExpanded.add(objUniqueKey); |
65 | //setSelectedNode(objUniqueKey); | |
66 | } | |
67 | ||
68 | /** | |
69 | * @see org.apache.tapestry.contrib.tree.model.ITreeStateModel#collapse(Object) | |
70 | */ | |
71 | 0 | public void collapse(Object objUniqueKey) { |
72 | 0 | m_setExpanded.remove(objUniqueKey); |
73 | //setSelectedNode(objUniqueKey); | |
74 | } | |
75 | ||
76 | /** | |
77 | * @see org.apache.tapestry.contrib.tree.model.ITreeStateModel#collapsePath(Object) | |
78 | */ | |
79 | 0 | public void collapsePath(Object objUniqueKey) { |
80 | 0 | m_setExpanded.remove(objUniqueKey); |
81 | //setSelectedNode(objUniqueKey); | |
82 | } | |
83 | ||
84 | /** | |
85 | * @see org.apache.tapestry.contrib.tree.model.ITreeStateModel#isUniqueKeyExpanded(Object) | |
86 | */ | |
87 | 0 | public boolean isUniqueKeyExpanded(Object objUniqueKey) { |
88 | 0 | return m_setExpanded.contains(objUniqueKey); |
89 | } | |
90 | /** | |
91 | * @see org.apache.tapestry.contrib.tree.model.ITreeStateModel#getSelectedNode() | |
92 | */ | |
93 | 0 | public Object getSelectedNode() { |
94 | 0 | return m_objSelectedNodeUID; |
95 | } | |
96 | ||
97 | 0 | public void setSelectedNode(Object objUniqueKey){ |
98 | 0 | if(m_objSelectedNodeUID == null || !m_objSelectedNodeUID.equals(objUniqueKey)) |
99 | 0 | m_objSelectedNodeUID = objUniqueKey; |
100 | } | |
101 | ||
102 | /** | |
103 | * @see org.apache.tapestry.contrib.tree.model.ITreeStateModel#resetState() | |
104 | */ | |
105 | 0 | public void resetState() { |
106 | 0 | initialize(); |
107 | } | |
108 | ||
109 | } |
|