Ejemplo n.º 1
0
  /** @return the filterNode */
  public TreeNode getFilterNode() {
    if (model != null && model.isInitialized()) {
      Hierarchy hierarchy = getHierarchy();

      if (filterNode == null && hierarchy != null) {
        this.filterNode = new DefaultTreeNode();

        filterNode.setExpanded(true);

        List<Member> members;
        boolean isMeasure;

        try {
          members = hierarchy.getRootMembers();
          isMeasure = hierarchy.getDimension().getDimensionType() == Type.MEASURE;
        } catch (OlapException e) {
          throw new FacesException(e);
        }

        for (Member member : members) {
          if (isMeasure && !member.isVisible()) {
            continue;
          }

          MemberNode node = new MemberNode(member);

          node.setNodeFilter(this);
          node.setExpanded(true);
          node.setSelectable(true);
          node.setSelected(isSelected(member));

          filterNode.getChildren().add(node);
        }

        List<TreeNode> initialSelection =
            ((DefaultTreeNode) filterNode)
                .collectNodes(
                    new NodeCollector() {

                      @Override
                      public boolean collectNode(TreeNode node) {
                        return node.isSelected();
                      }

                      @Override
                      public boolean searchNode(TreeNode node) {
                        return node.isExpanded();
                      }
                    });

        this.selection = initialSelection.toArray(new TreeNode[initialSelection.size()]);
      }
    } else {
      this.filterNode = null;
    }

    return filterNode;
  }
Ejemplo n.º 2
0
  public void apply() {
    List<Member> members = null;

    if (selection != null) {
      members = new ArrayList<Member>(selection.length);

      for (TreeNode node : selection) {
        MemberNode memberNode = (MemberNode) node;
        members.add(memberNode.getObject());
      }
    }

    ChangeSlicer transform = model.getTransform(ChangeSlicer.class);
    transform.setSlicer(getHierarchy(), members);
  }