1 13 package org.openi.xmla.navigator.hierarchy; 14 15 import java.util.ArrayList ; 16 import java.util.Collection ; 17 import java.util.Collections ; 18 import java.util.Iterator ; 19 import java.util.List ; 20 import java.util.Set ; 21 22 import com.tonbeller.jpivot.navigator.member.MemberSelectionModel; 23 import com.tonbeller.jpivot.olap.model.Dimension; 24 import com.tonbeller.jpivot.olap.model.Member; 25 import com.tonbeller.jpivot.olap.model.OlapException; 26 import com.tonbeller.jpivot.olap.model.OlapUtils; 27 import com.tonbeller.jpivot.olap.navi.ChangeSlicer; 28 import com.tonbeller.tbutils.res.Resources; 29 import com.tonbeller.wcf.catedit.Item; 30 import com.tonbeller.wcf.controller.RequestContext; 31 import com.tonbeller.wcf.selection.SelectionModel; 32 33 38 class SlicerCategory extends AbstractCategory { 39 public SlicerCategory(HierarchyNavigator navi, String name, String icon) throws OlapException { 40 super(navi, name, icon); 41 42 Set slicerDims = OlapUtils.getSlicerDimensions(navi.getOlapModel()); 43 for (Iterator it = slicerDims.iterator(); it.hasNext();) { 44 Dimension dim = (Dimension) it.next(); 45 HierarchyItem hi = new HierarchyItem(this, dim.getHierarchies()[0]); 46 items.add(hi); 47 } 48 Collections.sort(items); 49 } 50 51 54 public void itemClicked(RequestContext context, HierarchyItem item) { 55 MemberSelectionModel selection = new MemberSelectionModel(); 57 if (navi.getSlicerExtension() == null) 58 selection.setMode(SelectionModel.NO_SELECTION); 59 else 60 selection.setMode(SelectionModel.MULTIPLE_SELECTION); 61 62 selection.setSelection(item.getSlicerSelection()); 63 navi.itemClicked(context, item, selection, false); 64 } 65 66 void setSelection(HierarchyItem item, Collection selection) { 67 item.setSlicerSelection(selection); 68 } 69 70 public boolean isOrderSignificant() { 71 return false; 72 } 73 74 void prepareApplyChanges() { 75 } 76 77 void applyChanges() { 78 if (!isDirty()) 79 return; 80 setDirty(false); 81 82 ChangeSlicer slicerExtension = navi.getSlicerExtension(); 83 if (slicerExtension == null) 84 return; 85 86 List memberList = new ArrayList (); 87 for (Iterator it = items.iterator(); it.hasNext();) { 88 HierarchyItem hi = (HierarchyItem) it.next(); 89 memberList.addAll(hi.getSlicerSelection()); 90 } 91 Member[] memberArr = (Member[]) memberList.toArray(new Member[memberList.size()]); 92 slicerExtension.setSlicer(memberArr); 93 } 94 95 public boolean isEmptyAllowed() { 96 return true; 97 } 98 99 String validateSelection(HierarchyItem item, Collection selection) { 100 return null; 101 } 102 103 106 public void addItem(Item item) { 107 super.addItem(item); 108 Collections.sort(items); 109 } 110 111 public boolean isSlicer() { 112 return true; 113 } 114 115 } 116 | Popular Tags |