Package org.richfaces.component

Examples of org.richfaces.component.AbstractTree


        writer.writeAttribute(HtmlConstants.NAME_ATTRIBUTE, selectionStateInputId, null);
        writer.writeAttribute(HtmlConstants.ID_ATTRIBUTE, selectionStateInputId, null);
        writer.writeAttribute(HtmlConstants.CLASS_ATTRIBUTE, "rf-tr-sel-inp", null);

        String selectedNodeId = "";
        AbstractTree tree = (AbstractTree) component;

        Iterator<Object> selectedKeys = tree.getSelection().iterator();

        if (selectedKeys.hasNext()) {
            Object selectionKey = selectedKeys.next();
            Object initialKey = tree.getRowKey();
            try {
                tree.setRowKey(context, selectionKey);
                if (tree.isRowAvailable()) {
                    selectedNodeId = tree.findTreeNodeComponent().getClientId(context);
                }
            } finally {
                try {
                    tree.setRowKey(context, initialKey);
                } catch (Exception e) {
                    LOGGER.error(e.getMessage(), e);
                }
            }
        }
View Full Code Here


    protected String getSelectionStateInputId(FacesContext context, UIComponent component) {
        return component.getClientId(context) + SELECTION_STATE;
    }

    protected SwitchType getSelectionType(FacesContext context, UIComponent component) {
        AbstractTree tree = (AbstractTree) component;

        SwitchType selectionType = getSelectionTypeOrDefault(tree);
        if (selectionType != SwitchType.ajax && selectionType != SwitchType.client) {
            // TODO - better message
            throw new IllegalArgumentException(String.valueOf(selectionType));
View Full Code Here

    public void decode(FacesContext context, UIComponent component) {
        super.decode(context, component);

        Map<String, String> map = context.getExternalContext().getRequestParameterMap();
        String selectedNode = map.get(getSelectionStateInputId(context, component));
        AbstractTree tree = (AbstractTree) component;

        Object selectionRowKey = null;

        if (!Strings.isNullOrEmpty(selectedNode)) {
            RowKeyContextCallback rowKeyContextCallback = new RowKeyContextCallback();
            tree.invokeOnComponent(context, selectedNode, rowKeyContextCallback);
            selectionRowKey = rowKeyContextCallback.getRowKey();
        }

        Collection<Object> selection = tree.getSelection();

        Collection<Object> newSelection = null;

        if (selectionRowKey == null) {
            if (!selection.isEmpty()) {
                newSelection = Collections.emptySet();
            }
        } else {
            if (!selection.contains(selectionRowKey)) {
                newSelection = Collections.singleton(selectionRowKey);
            }
        }

        if (newSelection != null) {
            new TreeSelectionChangeEvent(component, Sets.newHashSet(selection), newSelection).queue();
        }

        PartialViewContext pvc = context.getPartialViewContext();
        if (pvc.isAjaxRequest()) {
            pvc.getRenderIds().add(
                tree.getClientId(context) + MetaComponentResolver.META_COMPONENT_SEPARATOR_CHAR
                    + AbstractTree.SELECTION_META_COMPONENT_ID);
        }
    }
View Full Code Here

    protected void encodeIcon(FacesContext context, UIComponent component) throws IOException {
        TreeNodeState nodeState = getNodeState(context);

        AbstractTreeNode treeNode = (AbstractTreeNode) component;

        AbstractTree tree = treeNode.findTreeComponent();

        if (nodeState.isLeaf()) {
            String iconLeaf = (String) getFirstNonEmptyAttribute("iconLeaf", treeNode, tree);
            encodeIconForNodeState(context, tree, treeNode, nodeState, iconLeaf);
        } else {
View Full Code Here

    }

    protected UIComponent getHandleLoadingFacetIfApplicable(UIComponent component) {
        AbstractTreeNode treeNode = (AbstractTreeNode) component;

        AbstractTree tree = treeNode.findTreeComponent();

        if (getToggleTypeOrDefault(tree) != SwitchType.ajax) {
            return null;
        }

        UIComponent facet = treeNode.getFacet(HANDLE_LOADING_FACET_NAME);
        if (facet == null) {
            facet = tree.getFacet(HANDLE_LOADING_FACET_NAME);
        }

        if (facet != null && facet.isRendered()) {
            return facet;
        }
View Full Code Here

            return null;
        }

        Iterator<String> split = SEPARATOR_SPLITTER.split(value).iterator();

        AbstractTree tree = (AbstractTree) component;

        List<DeclarativeModelKey> declarativeKeys = Lists.newArrayList();

        while (split.hasNext()) {
            String modelId = unescape(split.next());
            String modelKeyAsString = unescape(split.next());

            DeclarativeModelKey declarativeKey = tree.convertDeclarativeKeyFromString(context, modelId, modelKeyAsString);

            declarativeKeys.add(declarativeKey);
        }

        return new SequenceRowKey((Object[]) declarativeKeys.toArray(new DeclarativeModelKey[declarativeKeys.size()]));
View Full Code Here

        }

        SequenceRowKey sequenceRowKey = (SequenceRowKey) value;

        Object[] declarativeKeys = sequenceRowKey.getSimpleKeys();
        AbstractTree tree = (AbstractTree) component;

        StringBuilder result = new StringBuilder();

        for (Object declarativeKeyObject : declarativeKeys) {
            DeclarativeModelKey declarativeKey = (DeclarativeModelKey) declarativeKeyObject;
            String modelId = escape(declarativeKey.getModelId());

            String modelKeyAsString = escape(tree.convertDeclarativeKeyToString(context, declarativeKey));

            if (result.length() != 0) {
                result.append(SEPARATOR_CHAR);
            }
View Full Code Here

TOP

Related Classes of org.richfaces.component.AbstractTree

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.