KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tonbeller > jpivot > navigator > hierarchy > HierarchyItemRenderer


1 /*
2  * ====================================================================
3  * This software is subject to the terms of the Common Public License
4  * Agreement, available at the following URL:
5  * http://www.opensource.org/licenses/cpl.html .
6  * Copyright (C) 2003-2004 TONBELLER AG.
7  * All Rights Reserved.
8  * You must accept the terms of that agreement to use this software.
9  * ====================================================================
10  *
11  *
12  */

13 package com.tonbeller.jpivot.navigator.hierarchy;
14
15 import org.w3c.dom.Document JavaDoc;
16 import org.w3c.dom.Element JavaDoc;
17
18 import com.tonbeller.jpivot.olap.model.Member;
19 import com.tonbeller.wcf.catedit.Category;
20 import com.tonbeller.wcf.catedit.DefaultItemElementRenderer;
21 import com.tonbeller.wcf.catedit.Item;
22 import com.tonbeller.wcf.controller.RequestContext;
23 import com.tonbeller.wcf.utils.DomUtils;
24
25 /**
26  * renders a Hierarchy
27  * @author av
28  */

29 public class HierarchyItemRenderer extends DefaultItemElementRenderer {
30
31   public Element JavaDoc render(RequestContext context, Document JavaDoc factory, Category cat, Item item) {
32     Element JavaDoc elem = super.render(context, factory, cat, item);
33     HierarchyItem hi = (HierarchyItem)item;
34     if (hi.isClickable())
35       elem.setAttribute("id", hi.getId());
36
37     if (!hi.getSlicerSelection().isEmpty()) {
38       Member m = (Member)hi.getSlicerSelection().get(0);
39       Element JavaDoc e = DomUtils.appendElement(elem, "slicer-value");
40       e.setAttribute("label", m.getLabel());
41       e.setAttribute("level", m.getLevel().getLabel());
42     }
43     
44     return elem;
45     
46   }
47 }
48
Popular Tags