private void addAttribute(ComponentInfo compInfo, Attribute attr, String name, String value) { if (compInfo instanceof NativeInfo || isNative(attr.getNamespaceURI())) { compInfo.addProperty(name, value, null); } else { compInfo.addWidgetListener(name, value, null); } }
private ComponentInfo newComponentInfo(NodeInfo parent, String text) { if (_compdef == null) //no sync since racing is OK _compdef = getComponentDefinition(_name); final ComponentInfo info = new ComponentInfo(parent, _compdef, null); info.addProperty(_prop, text, null); return info; } }
/** Applies the annotations defined in this helper to the specified * instance definition. * * @param compInfo the instance definition to update * @param propName the property name * @param clear whether to clear all definitions before returning * @see #clear * @since 6.0.1 */ public void applyAnnotations(ComponentInfo compInfo, String propName, boolean clear) { for (AnnotInfo info : _annots) { compInfo.addAnnotation(propName, info.name, info.attrs, info.loc); } if (clear) _annots.clear(); }
ComponentDefinition compdef = defaultNS ? pgdef.getComponentDefinitionMap().get(nm) : null; if (compdef != null) { compInfo = new ComponentInfo(parent, compdef, nm); } else if (complangdef.hasComponentDefinition(nm)) { compdef = complangdef.getComponentDefinition(nm); compInfo = new ComponentInfo(parent, compdef, nm); langdef = complangdef; } else { throw new DefinitionNotFoundException( message("Component definition not found: " + nm + " in " + complangdef, el)); compInfo = new ComponentInfo(parent, compdef, nm); langdef = complangdef; use = use.trim(); if (use.length() != 0) compInfo.setImplementation(use); compInfo.addProperty(attr.getName(), attval, null); compInfo.addProperty(attnm, attval, null); continue; compInfo.setApply(attval); } else if ("forward".equals(attnm) && isZkAttr(langdef, attrns)) { compInfo.setForward(attval); } else if ("if".equals(attnm) && isZkAttr(langdef, attrns)) { ifc = attval;
final String uri = attrns.getURI(); if (LanguageDefinition.CLIENT_NAMESPACE.equals(uri) || "client".equals(uri)) { compInfo.addWidgetListener(name, value, cond); return; compInfo.addWidgetAttribute(name, value, cond); return; LanguageDefinition langdef = compInfo.getLanguageDefinition(); ComponentDefinition compdef = compInfo.getComponentDefinition(); final ZScript zscript = ZScript.parseContent(value, lno); if (zscript.getLanguage() == null) zscript.setLanguage(compInfo.getPageDefinition().getZScriptLanguage()); compInfo.addEventHandler(name, zscript, cond); return; //done if (cond != null) throw new UnsupportedOperationException(message("if and unless not allowed for w:use", xl)); compInfo.setWidgetClass(value); } else { compInfo.addWidgetOverride(name, value, cond); compInfo.addWidgetAttribute(name, value, cond); return; compInfo.addProperty(name, value, cond);
if (p instanceof ComponentInfo) { pi = (ComponentInfo) p; textAs = pi.getTextAs(); if (textAs != null && pi == parent) //only direct child textAsBuffer = new StringBuilder(); String label = "<!--" + ((Item) o).getText() + "-->"; final ComponentInfo labelInfo = parentlang.newLabelInfo(parent, label); labelInfo.addProperty("encode", "false", null); for (Property prop : ((ComponentInfo) children.get(children.size() - 1)).getProperties()) { if (prop.getName().equals(labelAttr)) { prop.setRawValue(prop.getRawValue() + trimLabel); } else if (isEmpty(trimLabel) && (pi != null && !pi.isBlankPreserved() && !isNativeText(pi))) continue; //Ignore blank text if no need to preserved else if (isEmpty(label.trim()) && !isAllBlankPreserved) final ComponentInfo labelInfo = parentlang.newLabelInfo(parent, label); if (isEmpty(trimLabel)) labelInfo.setReplaceableText(" "); //yes, it can be replaced by a text, and it's possible to replace multiple whitespace characters with single space if (pi == null || !pi.isBlankPreserved()) trimLabel = trimLabel.trim(); pi.addProperty(textAs, trimLabel, null);
/** Parses the items as if they are native and they will become a property * rather than child components. */ private void parseAsProperty(PageDefinition pgdef, ComponentInfo compInfo, String name, Collection items, AnnotationHelper annHelper, ConditionImpl cond) throws Exception { final NativeInfo nativeInfo = new NativeInfo(compInfo.getEvaluatorRef(), pgdef.getLanguageDefinition().getNativeDefinition(), ""); //Note: nativeInfo can not be a child. Rather, it will be a property parseItems(pgdef, nativeInfo, items, annHelper, true); compInfo.addProperty(name, nativeInfo, cond); }
String tag = null; if(compInfo != null){ tag = compInfo.getTag();
public Component newComponent(Page page, Component parent, ComponentInfo compInfo, Component insertBefore) { final Component comp = compInfo.newInstance(page, parent); Utils.setComponentInfo(comp, compInfo); if (parent != null) parent.insertBefore(comp, insertBefore); else comp.setPageBefore(page, insertBefore); if (comp instanceof BeforeCompose) ((BeforeCompose) comp).beforeCompose(); compInfo.applyProperties(comp); //include comp's definition Utils.setComponentInfo(comp, null); return comp; }
/** Used only by {@link DupComponentInfo}. */ private ComponentInfo(ComponentInfo compInfo) { super(compInfo); _compdef = compInfo._compdef; _impl = compInfo._impl; _tag = compInfo._tag; _fulfill = compInfo._fulfill; _apply = compInfo._apply; _forward = compInfo._forward; _replaceableText = compInfo._replaceableText; dupProps(compInfo); }
if (nodes != null && nodes.size() > 0) { NodeInfo firstNode = nodes.get(0); if (firstNode instanceof ComponentInfo && "html".equals(((ComponentInfo) firstNode).getTag())) throw new UiException( "Root element <html> and DOCTYPE are not allowed in included file: [" + _src + "]");