1 13 package com.tonbeller.jpivot.table.navi; 14 15 import com.tonbeller.jpivot.olap.model.Hierarchy; 16 import com.tonbeller.jpivot.olap.model.Level; 17 import com.tonbeller.jpivot.olap.model.Member; 18 import com.tonbeller.jpivot.olap.model.OlapModel; 19 import com.tonbeller.jpivot.olap.model.VisitorSupportSloppy; 20 import com.tonbeller.jpivot.olap.navi.DrillReplace; 21 import com.tonbeller.jpivot.table.span.PropertyHeading; 22 import com.tonbeller.jpivot.table.span.Span; 23 import com.tonbeller.jpivot.table.span.SpanVisitor; 24 25 30 public class DrillReplaceUI extends DrillExpandUI { 31 32 public static final String ID = "drillReplace"; 33 public String getId() { 34 return ID; 35 } 36 37 DrillReplace extension; 38 39 class CanCollapse extends VisitorSupportSloppy implements SpanVisitor { 40 boolean result = false; 41 public void visitHierarchy(Hierarchy v) { 42 result = extension.canDrillUp(v); 43 } 44 public void visitLevel(Level v) { 45 result = extension.canDrillUp(v.getHierarchy()); 46 } 47 public void visitPropertyHeading(PropertyHeading heading) { 48 } 49 } 50 51 protected boolean canCollapse(Span span) { 52 CanCollapse cc = new CanCollapse(); 53 span.getObject().accept(cc); 54 return cc.result; 55 } 56 57 class DoCollapse extends VisitorSupportSloppy implements SpanVisitor { 58 public void visitHierarchy(Hierarchy v) { 59 extension.drillUp(v); 60 } 61 public void visitLevel(Level v) { 62 extension.drillUp(v.getHierarchy()); 63 } 64 public void visitPropertyHeading(PropertyHeading heading) { 65 } 66 } 67 68 protected void collapse(Span span) { 69 DoCollapse dc = new DoCollapse(); 70 span.getObject().accept(dc); 71 } 72 73 protected boolean canExpand(Span span) { 74 if (positionContainsMember(span)) 75 return extension.canDrillDown((Member) span.getMember().getRootDecoree()); 76 return false; 77 } 78 79 protected void expand(Span span) { 80 extension.drillDown((Member) span.getMember().getRootDecoree()); 81 } 82 83 protected boolean initializeExtension() { 84 OlapModel om = table.getOlapModel(); 85 extension = (DrillReplace) om.getExtension(DrillReplace.ID); 86 return extension != null; 87 } 88 89 protected String getCollapseImage() { 90 return "drill-replace-collapse"; 91 } 92 93 protected String getExpandImage() { 94 return "drill-replace-expand"; 95 } 96 97 protected String getOtherImage() { 98 return "drill-replace-other"; 99 } 100 101 } 102 | Popular Tags |