KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tonbeller > jpivot > table > navi > DrillReplaceUI


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.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 /**
26  * Created on 03.12.2002
27  *
28  * @author av
29  */

30 public class DrillReplaceUI extends DrillExpandUI {
31
32   public static final String JavaDoc ID = "drillReplace";
33   public String JavaDoc 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 JavaDoc getCollapseImage() {
90     return "drill-replace-collapse";
91   }
92
93   protected String JavaDoc getExpandImage() {
94     return "drill-replace-expand";
95   }
96
97   protected String JavaDoc getOtherImage() {
98     return "drill-replace-other";
99   }
100
101 }
102
Popular Tags