/*
(non-Javadoc)

@see javax.faces.view.facelets.FaceletHandler#apply(javax.faces.view.facelets.FaceletContext,
javax.faces.component.UIComponent)
774855
public void apply(FaceletContext ctx, UIComponent parent) throws IOException, FacesException, FaceletException,
            ELException
    {
        if (_template != null)
        {
            VariableMapper orig = ctx.getVariableMapper();
            AbstractFaceletContext actx = (AbstractFaceletContext) ctx;
            actx.extendClient(this);
            if (_params != null)
            {
                VariableMapper vm = new VariableMapperWrapper(orig);
                ctx.setVariableMapper(vm);
                for (int i = 0; i < _params.length; i++)
                {
                    _params[i].apply(ctx, parent);
                }
            }

            try
            {
                ctx.includeFacelet(parent, _template.getValue(ctx));
            }
            finally
            {
                actx.popExtendedClient(this);
                ctx.setVariableMapper(orig);
            }
        }
        else
        {
            this.nextHandler.apply(ctx, parent);
        }
    }
1295644
public static void apply(Face type, TextView... textViews){
        if(textViews.length == 0) return;
        for (int i = 0; i < textViews.length; i++) {
            apply(textViews[i], type);
        }
    }
694203
@Override
  public void apply(ModelPropertyContext context) {
    Optional<NotNull> notNull = extractAnnotation(context);
    if (notNull.isPresent()) {
      context.getBuilder().required(notNull.isPresent());
    }
  }
12772
@Override
    protected void apply(TextView view, TypedArray typedArray) {
        String typefacePath = typedArray.getString(R.styleable.FontDecorator_decorTypefaceAsset);
        if(typefacePath == null) return;
        view.setTypeface(Typeface.createFromAsset(
                view.getResources().getAssets(), typefacePath));
    }
1102938
protected void renderTextAreaBegin(FacesContext facesContext,
            UIComponent uiComponent) throws IOException
    {
        ResponseWriter writer = facesContext.getResponseWriter();
        writer.startElement(HTML.TEXTAREA_ELEM, uiComponent);

        Map<String, List<ClientBehavior>> behaviors = null;
        if (uiComponent instanceof ClientBehaviorHolder)
        {
            behaviors = ((ClientBehaviorHolder) uiComponent).getClientBehaviors();
            if (!behaviors.isEmpty())
            {
                HtmlRendererUtils.writeIdAndName(writer, uiComponent, facesContext);
            }
            else
            {
                HtmlRendererUtils.writeIdIfNecessary(writer, uiComponent, facesContext);
                writer.writeAttribute(HTML.NAME_ATTR, uiComponent.getClientId(facesContext), null);
            }
            long commonPropertiesMarked = 0L;
            if (isCommonPropertiesOptimizationEnabled(facesContext))
            {
                commonPropertiesMarked = CommonPropertyUtils.getCommonPropertiesMarked(uiComponent);
            }
            if (behaviors.isEmpty() && isCommonPropertiesOptimizationEnabled(facesContext))
            {
                CommonPropertyUtils.renderChangeEventProperty(writer, 
                        commonPropertiesMarked, uiComponent);
                CommonPropertyUtils.renderEventProperties(writer, 
                        commonPropertiesMarked, uiComponent);
                CommonPropertyUtils.renderFieldEventPropertiesWithoutOnchange(writer, 
                        commonPropertiesMarked, uiComponent);
            }
            else
            {
                HtmlRendererUtils.renderBehaviorizedOnchangeEventHandler(facesContext, writer, uiComponent, behaviors);
                if (isCommonEventsOptimizationEnabled(facesContext))
                {
                    Long commonEventsMarked = CommonEventUtils.getCommonEventsMarked(uiComponent);
                    CommonEventUtils.renderBehaviorizedEventHandlers(facesContext, writer, 
                            commonPropertiesMarked, commonEventsMarked, uiComponent, behaviors);
                    CommonEventUtils.renderBehaviorizedFieldEventHandlersWithoutOnchange(
                        facesContext, writer, commonPropertiesMarked, commonEventsMarked, uiComponent, behaviors);
                }
                else
                {
                    HtmlRendererUtils.renderBehaviorizedEventHandlers(facesContext, writer, uiComponent, behaviors);
                    HtmlRendererUtils.renderBehaviorizedFieldEventHandlersWithoutOnchange(
                            facesContext, writer, uiComponent, behaviors);
                }
            }
            if (isCommonPropertiesOptimizationEnabled(facesContext))
            {
                CommonPropertyUtils.renderCommonFieldPassthroughPropertiesWithoutDisabledAndEvents(writer, 
                        CommonPropertyUtils.getCommonPropertiesMarked(uiComponent), uiComponent);
                HtmlRendererUtils.renderHTMLAttributes(writer, uiComponent, HTML.TEXTAREA_ATTRIBUTES);
            }
            else
            {
                HtmlRendererUtils.renderHTMLAttributes(writer, uiComponent, 
                        HTML.TEXTAREA_PASSTHROUGH_ATTRIBUTES_WITHOUT_DISABLED_AND_EVENTS);
            }
        }
        else
        {
            HtmlRendererUtils.writeIdIfNecessary(writer, uiComponent, facesContext);
            writer.writeAttribute(HTML.NAME_ATTR, uiComponent.getClientId(facesContext), null);
            if (isCommonPropertiesOptimizationEnabled(facesContext))
            {
                CommonPropertyUtils.renderCommonFieldPassthroughPropertiesWithoutDisabled(writer, 
                        CommonPropertyUtils.getCommonPropertiesMarked(uiComponent), uiComponent);
                HtmlRendererUtils.renderHTMLAttributes(writer, uiComponent, HTML.TEXTAREA_ATTRIBUTES);
            }
            else
            {
                HtmlRendererUtils.renderHTMLAttributes(writer, uiComponent, 
                        HTML.TEXTAREA_PASSTHROUGH_ATTRIBUTES_WITHOUT_DISABLED);
            }
        }

        if (isDisabled(facesContext, uiComponent))
        {
            writer.writeAttribute(org.apache.myfaces.shared.renderkit.html.HTML.DISABLED_ATTR, Boolean.TRUE, null);
        }
    }
838823
protected void renderId(
      FacesContext context,
      UIComponent  component) throws IOException
    {
      if (shouldRenderId(context, component))
      {
        String clientId = getClientId(context, component);
        context.getResponseWriter().writeAttribute(HTML.ID_ATTR, clientId, JSFAttr.ID_ATTR);
      }
    }
1195339
public static void initPartialValidationAndModelUpdate(
            UIComponent component, FacesContext facesContext)
    {
        String actionFor = (String) component.getAttributes().get("actionFor");

        if (actionFor != null)
        {
            List li = convertIdsToClientIds(actionFor, facesContext, component);

            facesContext.getExternalContext().getRequestMap()
                    .put(ACTION_FOR_LIST, li);

            String actionForPhase = (String) component.getAttributes().get(
                    "actionForPhase");

            if (actionForPhase != null)
            {
                List phaseList = convertPhasesToPhasesIds(actionForPhase);

                facesContext.getExternalContext().getRequestMap()
                        .put(ACTION_FOR_PHASE_LIST, phaseList);
            }
        }
    }
1110550
protected void applyAttributes()
            throws JspException {
        super.applyAttributes();

        if(_headerCellModel.getFilterHref() != null && _headerCellModel.getFilterAction() != null)
            throw new JspException(Bundle.getErrorString("HeaderCell_CantSetHrefAndAction"));

        if(_headerCellModel.getSortHref() != null && _headerCellModel.getSortAction() != null)
            throw new JspException(Bundle.getErrorString("HeaderCell_CantSetSortHrefAndAction"));

        if(_headerCellModel.isSortable()) {
            if(_headerCellModel.getSortExpression() == null)
                throw new JspException(Bundle.getErrorString("HeaderCell_CantEnableSorting"));

            /* set an intelligent default for the sorting HREF */
            if(_headerCellModel.getSortHref() == null && _headerCellModel.getSortAction() == null)
                _headerCellModel.setSortHref(JspUtil.getRequest(getJspContext()).getRequestURI());
        }

        if(_headerCellModel.isFilterable()) {
            if(_headerCellModel.getFilterExpression() == null)
                throw new JspException(Bundle.getErrorString("HeaderCell_CantEnableFiltering"));

            /* set an intelligent default for the filtering HREF */
            if(_headerCellModel.getFilterHref() == null && _headerCellModel.getFilterAction() == null)
                _headerCellModel.setFilterHref(JspUtil.getRequest(getJspContext()).getRequestURI());
        }
    }
320185
@Override
    public boolean applyAction(Model c) {
        Mapping map = c.getMapping();
        return !map.isOffline(node) && map.addOfflineNode(node);
    }
1181753
public static void decorateFacetComponent(UIComponent parent, UIComponent comp, FacesContext ctx, ResponseWriter rw)
			throws IOException {
		/*
		 * System.out.println("COMPONENT CLASS = " + comp.getClass().getName());
		 * System.out.println("FAMILY = " + comp.getFamily());
		 * System.out.println("CHILD COUNT = " + comp.getChildCount());
		 * System.out.println("PARENT CLASS = " + comp.getParent().getClass());
		 * 
		 * 
		 * if (app.getClass().getName().endsWith("Button") ||
		 * (app.getChildCount() > 0 &&
		 * app.getChildren().get(0).getClass().getName().endsWith("Button"))) {
		 * rw.startElement("div", inputText); rw.writeAttribute("class",
		 * "input-group-btn", "class"); app.encodeAll(context);
		 * rw.endElement("div"); } else { if (app instanceof Icon) ((Icon)
		 * app).setAddon(true); rw.startElement("span", inputText);
		 * rw.writeAttribute("class", "input-group-addon", "class");
		 * app.encodeAll(context); rw.endElement("span"); }
		 */
		if (comp.getChildCount() >= 1 && comp.getClass().getName().endsWith("Panel")) {
			for (UIComponent child : comp.getChildren()) {
				decorateComponent(parent, child, ctx, rw);
			}
		} else {
			decorateComponent(parent, comp, ctx, rw);
		}
	}
392835
@Override
    public void decode(FacesContext context, UIComponent component) {
        Tree tree = (Tree) component;
        super.decode(context, tree);

        final TreeNodeEventListener nodeSelectionListener = tree.getNodeSelectionListener();
        String params = context.getExternalContext().getRequestParameterMap().get("params");

        if (params != null) {
            params = params.replace("BsFEvent=", "");
            String[] pair = params.split(":", 2);
            String key = pair[0];
            Integer value = null;
            if (pair.length == 2)
                value = Integer.valueOf(pair[1]);
            
            if (value != null) {
                Node n = TreeModelUtils.searchNodeById(tree.getValue(), value);

                if (nodeSelectionListener != null && n != null) {
                    // execute listener only for listened events
                    if ("nodeSelected".equals(key)) {
                        n.setSelected(true);
                        nodeSelectionListener.processValueSelected(new TreeNodeSelectionEvent(n, true));
                    } else if ("nodeUnselected".equals(key)) {
                        n.setSelected(false);
                        nodeSelectionListener.processValueSelected(new TreeNodeSelectionEvent(n, false));
                    } else if ("nodeChecked".equals(key)) {
                        n.setChecked(true);
                        nodeSelectionListener.processValueChecked(new TreeNodeCheckedEvent(n, true));
                    } else if ("nodeUnchecked".equals(key)) {
                        n.setChecked(false);
                        nodeSelectionListener.processValueChecked(new TreeNodeCheckedEvent(n, false));
                    } else if ("nodeExpanded".equals(key)) {
                        n.setExpanded(true);
                        nodeSelectionListener.processValueExpanded(new TreeNodeExpandedEvent(n, true));
                    } else if ("nodeCollapsed".equals(key)) {
                        n.setExpanded(false);
                        nodeSelectionListener.processValueExpanded(new TreeNodeExpandedEvent(n, false));
                    }
                }
            }
        }
    }
1183169
public void focus(String expression, UIComponent base) {
        if (LangUtils.isValueBlank(expression)) {
            return;
        }

        FacesContext facesContext = getFacesContext();

        String clientId = SearchExpressionFacade.resolveClientId(facesContext,
                base,
                expression);
        executeScript("PrimeFaces.focus('" + clientId + "');");
    }
933512
@Override
	public void apply(final App app, final Page sourcePage, final Page newPage) throws FrameworkException {

		final InsertPosition insertPosition = findInsertPosition(sourcePage, parentHash, siblingHashes, newNode);
		if (insertPosition != null) {

			final DOMNode parent  = insertPosition.getParent();
			final DOMNode sibling = insertPosition.getSibling();

			if (parent != null && !parent.isSynced()) {

				if (sourcePage != null) {
					sourcePage.adoptNode(newNode);
				}

				parent.insertBefore(newNode, sibling);

				// make existing node known to other operations
				hashMappedExistingNodes.put(newNode.getIdHashOrProperty(), newNode);

				// remove children of new node so that existing nodes can be moved later
				for (final RelationshipInterface childRel : newNode.getChildRelationships()) {
					app.delete(childRel);
				}
			}
		}
	}
546058
@Override
	public void apply(final App app, final Page sourcePage, final Page newPage) throws FrameworkException {
		existingNode.updateFromNode(newNode);
	}
7158
public void encodeEnd(FacesContext facesContext, UIComponent component)
            throws IOException
    {
        RendererUtils.checkParamValidity(facesContext, component, null);
        
        Map<String, List<ClientBehavior>> behaviors = null;
        if (component instanceof ClientBehaviorHolder)
        {
            behaviors = ((ClientBehaviorHolder) component).getClientBehaviors();
            if (!behaviors.isEmpty())
            {
                ResourceUtils.renderDefaultJsfJsInlineIfNecessary(
                        facesContext, facesContext.getResponseWriter());
            }
        }

        if (component instanceof UISelectMany)
        {
            renderMenu(facesContext,
                                         (UISelectMany)component,
                                         isDisabled(facesContext, component),
                                         getConverter(facesContext, component));
        }
        else if (component instanceof UISelectOne)
        {
            renderMenu(facesContext,
                                         (UISelectOne)component,
                                         isDisabled(facesContext, component),
                                         getConverter(facesContext, component));
        }
        else
        {
            throw new IllegalArgumentException("Unsupported component class " + component.getClass().getName());
        }
    }
895940
public static void addClass2FacetComponent(UIComponent f, String cname, String aclass) {
		// If the facet contains only one component, getChildCount()=0 and the
		// Facet is the UIComponent
		if (f.getClass().getName().endsWith(cname)) {
			addClass2Component(f, aclass);
		} else {
			if (f.getChildCount() > 0) {
				for (UIComponent c : f.getChildren()) {
					if (c.getClass().getName().endsWith(cname)) {
						addClass2Component(c, aclass);
					}
				}
			}
		}
	}
1177119
@Override
    public boolean applyAction(Model c) {
        if (c.getMapping().isOffline(node)) {
            c.getMapping().addOnlineNode(node);
            return true;
        }
        return false;
    }