KickJava   Java API By Example, From Geeks To Geeks.

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


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.table.AxisConfig;
16 import com.tonbeller.jpivot.table.ColumnAxisConfig;
17 import com.tonbeller.jpivot.table.RowAxisConfig;
18 import com.tonbeller.jpivot.table.TableComponent;
19 import com.tonbeller.jpivot.table.TableComponentExtensionSupport;
20 import com.tonbeller.wcf.controller.RequestContext;
21
22 /**
23  * Created on 06.12.2002
24  *
25  * @author av
26  */

27 public class AxisStyleUI extends TableComponentExtensionSupport {
28
29   public static final String JavaDoc ID = "axisStyle";
30
31   // defaults
32
boolean levelStyle = false;
33   boolean hideSpans = false;
34
35   public String JavaDoc getId() {
36     return ID;
37   }
38
39   /**
40    * Returns the hideSpans.
41    * @return boolean
42    */

43   public boolean isHideSpans() {
44     return hideSpans;
45   }
46
47   /**
48    * Returns the levelStyle.
49    * @return boolean
50    */

51   public boolean isLevelStyle() {
52     return levelStyle;
53   }
54
55   /**
56    * Sets the hideSpans.
57    * @param hideSpans The hideSpans to set
58    */

59   public void setHideSpans(boolean hideSpans) {
60     if (table == null)
61       return;
62
63     this.hideSpans = hideSpans;
64     RowAxisConfig rac = (RowAxisConfig) table.getRowAxisBuilder().getAxisConfig();
65     ColumnAxisConfig cac = (ColumnAxisConfig) table.getColumnAxisBuilder().getAxisConfig();
66
67     if (hideSpans) {
68       rac.setMemberSpan(AxisConfig.HIERARCHY_SPAN);
69       cac.setMemberSpan(AxisConfig.HIERARCHY_SPAN);
70     } else {
71       rac.setMemberSpan(AxisConfig.HIERARCHY_THEN_POSITION_SPAN);
72       cac.setMemberSpan(AxisConfig.HIERARCHY_THEN_POSITION_SPAN);
73     }
74   }
75
76   /**
77    * Sets the levelStyle.
78    * @param levelStyle The levelStyle to set
79    */

80   public void setLevelStyle(boolean levelStyle) {
81     if (table == null)
82       return;
83
84     this.levelStyle = levelStyle;
85     // indent on columnaxis does not look really good
86
RowAxisConfig rac = (RowAxisConfig) table.getRowAxisBuilder().getAxisConfig();
87     ColumnAxisConfig cac = (ColumnAxisConfig) table.getColumnAxisBuilder().getAxisConfig();
88     if (levelStyle) {
89       rac.setShowParentMembers(true);
90       cac.setShowParentMembers(true);
91       rac.setMemberIndent(false);
92       rac.setPositionHeader(AxisConfig.HIERARCHY_LEVEL_HEADER);
93       //cac.setHierarchyHeader(AxisConfig.LEVEL_HEADER);
94
} else {
95       rac.setShowParentMembers(false);
96       cac.setShowParentMembers(false);
97       rac.setMemberIndent(true);
98       rac.setPositionHeader(AxisConfig.HIERARCHY_HEADER);
99       //cac.setHierarchyHeader(AxisConfig.HIERARCHY_HEADER);
100
}
101   }
102
103   public boolean isAvailable() {
104     return true;
105   }
106
107   /**
108    * initializes axis style
109    */

110   public void initialize(RequestContext context, TableComponent table) throws Exception JavaDoc {
111     super.initialize(context, table);
112     setLevelStyle(levelStyle);
113     setHideSpans(hideSpans);
114   }
115
116   public static class BookmarkState {
117     boolean levelStyle = false;
118     boolean hideSpans = false;
119     /**
120      * @return
121      */

122     public boolean isHideSpans() {
123       return hideSpans;
124     }
125
126     /**
127      * @return
128      */

129     public boolean isLevelStyle() {
130       return levelStyle;
131     }
132
133     /**
134      * @param b
135      */

136     public void setHideSpans(boolean b) {
137       hideSpans = b;
138     }
139
140     /**
141      * @param b
142      */

143     public void setLevelStyle(boolean b) {
144       levelStyle = b;
145     }
146
147   }
148
149   /**
150    * returns the bookmark state
151    */

152   public Object JavaDoc getBookmarkState(int levelOfDetail) {
153     BookmarkState x = new BookmarkState();
154     x.setLevelStyle(isLevelStyle());
155     x.setHideSpans(isHideSpans());
156     return x;
157   }
158
159   /**
160    * restores boomarkstat
161    */

162   public void setBookmarkState(Object JavaDoc state) {
163     if (!(state instanceof BookmarkState))
164       return;
165     BookmarkState x = (BookmarkState) state;
166     setLevelStyle(x.isLevelStyle());
167     setHideSpans(x.isHideSpans());
168   }
169 }
170
Popular Tags