1 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 26 public class SimpleTreeStateModel implements ITreeStateModel, Serializable { 27 28 private Set m_setExpanded; 29 private Object m_objSelectedNodeUID = null; 30 31 34 public SimpleTreeStateModel() { 35 super(); 36 initialize(); 37 } 38 private void initialize(){ 39 m_setExpanded = new HashSet (); 40 m_objSelectedNodeUID = null; 41 } 42 43 46 public Set getExpandSelection() { 47 return m_setExpanded; 48 } 49 50 53 public void expand(Object objUniqueKey) { 54 m_setExpanded.add(objUniqueKey); 55 } 57 58 61 public void expandPath(Object objUniqueKey) { 62 m_setExpanded.add(objUniqueKey); 63 } 65 66 69 public void collapse(Object objUniqueKey) { 70 m_setExpanded.remove(objUniqueKey); 71 } 73 74 77 public void collapsePath(Object objUniqueKey) { 78 m_setExpanded.remove(objUniqueKey); 79 } 81 82 85 public boolean isUniqueKeyExpanded(Object objUniqueKey) { 86 return m_setExpanded.contains(objUniqueKey); 87 } 88 91 public Object getSelectedNode() { 92 return m_objSelectedNodeUID; 93 } 94 95 public void setSelectedNode(Object objUniqueKey){ 96 if(m_objSelectedNodeUID == null || !m_objSelectedNodeUID.equals(objUniqueKey)) 97 m_objSelectedNodeUID = objUniqueKey; 98 } 99 100 103 public void resetState() { 104 initialize(); 105 } 106 107 } 108 | Popular Tags |