1 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 27 public class AxisStyleUI extends TableComponentExtensionSupport { 28 29 public static final String ID = "axisStyle"; 30 31 boolean levelStyle = false; 33 boolean hideSpans = false; 34 35 public String getId() { 36 return ID; 37 } 38 39 43 public boolean isHideSpans() { 44 return hideSpans; 45 } 46 47 51 public boolean isLevelStyle() { 52 return levelStyle; 53 } 54 55 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 80 public void setLevelStyle(boolean levelStyle) { 81 if (table == null) 82 return; 83 84 this.levelStyle = levelStyle; 85 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 } else { 95 rac.setShowParentMembers(false); 96 cac.setShowParentMembers(false); 97 rac.setMemberIndent(true); 98 rac.setPositionHeader(AxisConfig.HIERARCHY_HEADER); 99 } 101 } 102 103 public boolean isAvailable() { 104 return true; 105 } 106 107 110 public void initialize(RequestContext context, TableComponent table) throws Exception { 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 122 public boolean isHideSpans() { 123 return hideSpans; 124 } 125 126 129 public boolean isLevelStyle() { 130 return levelStyle; 131 } 132 133 136 public void setHideSpans(boolean b) { 137 hideSpans = b; 138 } 139 140 143 public void setLevelStyle(boolean b) { 144 levelStyle = b; 145 } 146 147 } 148 149 152 public Object getBookmarkState(int levelOfDetail) { 153 BookmarkState x = new BookmarkState(); 154 x.setLevelStyle(isLevelStyle()); 155 x.setHideSpans(isHideSpans()); 156 return x; 157 } 158 159 162 public void setBookmarkState(Object 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 |