1 13 package com.tonbeller.jpivot.test.olap; 14 15 import java.util.HashSet ; 16 import java.util.Iterator ; 17 18 import com.tonbeller.jpivot.olap.model.Member; 19 import com.tonbeller.jpivot.olap.navi.DrillExpandMember; 20 21 26 public class TestDrillExpandMember extends TestExtensionSupport implements DrillExpandMember { 27 28 HashSet expanded = new HashSet (); 29 30 protected TestOlapModel model() { 31 return (TestOlapModel) super.getModel(); 32 } 33 34 37 public boolean canExpand(Member member) { 38 TestMember tm = (TestMember) member; 39 return tm.hasChildren() && !expanded.contains(member); 40 } 41 42 45 public boolean canCollapse(Member member) { 46 TestMember tm = (TestMember) member; 47 return tm.hasChildren() && expanded.contains(member); 48 } 49 50 53 54 public void expand(Member member) { 55 expanded.add(member); 56 TestMember tm = (TestMember) member; 57 for (Iterator it = tm.getChildMember().iterator(); it.hasNext();) 58 ((TestMember) it.next()).setVisible(true); 59 TestOlapModelUtils.rebuildAxis(model(), tm); 60 fireModelChanged(); 61 } 62 63 public void collapse(Member member) { 64 recurseCollapse((TestMember) member); 65 TestOlapModelUtils.rebuildAxis(model(), (TestMember)member); 66 fireModelChanged(); 67 } 68 69 70 private void recurseCollapse(TestMember tm) { 71 if (!expanded.contains(tm)) 72 return; 73 expanded.remove(tm); 74 for (Iterator it = tm.getChildMember().iterator(); it.hasNext();) { 75 TestMember child = (TestMember) it.next(); 76 recurseCollapse(child); 77 child.setVisible(false); 78 } 79 } 80 81 82 } 83 | Popular Tags |