1 5 package com.tonbeller.jpivot.table.navi; 6 7 import java.text.MessageFormat ; 8 9 import com.tonbeller.jpivot.core.ModelChangeEvent; 10 import com.tonbeller.jpivot.olap.model.Displayable; 11 import com.tonbeller.jpivot.olap.model.Member; 12 import com.tonbeller.jpivot.table.SpanBuilder.SBContext; 13 import com.tonbeller.wcf.charset.CharsetFilter; 14 import com.tonbeller.wcf.controller.RequestContext; 15 16 23 public class UrlClickableMember extends AbstractClickableMember { 24 28 private String urlPattern; 29 private String menuLabel; 30 31 37 38 protected UrlClickableMember(String uniqueName, String menuLabel, String urlPattern) { 39 super(uniqueName); 40 this.menuLabel = menuLabel; 41 this.urlPattern = urlPattern; 42 } 43 44 47 private String getPatternUrl(Member member) { 48 String pattern = urlPattern == null ? "?param={0}" : urlPattern; 49 String uname = CharsetFilter.urlEncode(parser.unparse(member)); 50 Object [] args = new Object [] { uname}; 51 return MessageFormat.format(pattern, args); 52 } 53 54 public void decorate(SBContext sbctx, Displayable obj) { 55 if (!(obj instanceof Member)) 56 return; 57 58 Member m = (Member) obj; 59 if (match(m)) { 60 sbctx.addClickable(getPatternUrl(m), menuLabel); 61 } 62 } 63 64 67 public void request(RequestContext context) throws Exception { 68 } 69 70 73 public void modelChanged(ModelChangeEvent e) { 74 } 75 76 79 public void structureChanged(ModelChangeEvent e) { 80 } 81 82 } 83 | Popular Tags |