public UIJointContainer evolveSelect(UISelect toevolve) { UIJointContainer joint = new UIJointContainer(toevolve.parent, toevolve.ID, COMPONENT_ID); toevolve.parent.remove(toevolve); toevolve.ID = "select"; joint.addComponent(toevolve); return joint; } }
/** * @see UIJointContainer#UIJointContainer(UIContainer, String, String) * @param localID The localID, used to distinguish repeated replicates of this * joint which occur in the same scope (in just the same way as plain branches) */ public UIJointContainer(UIContainer parent, String ID, String jointID, String localID) { this.ID = ID; this.jointID = jointID; this.localID = localID; parent.addComponent(this); }
if (toadd.parent != null) { throw new IllegalArgumentException("Cannot add " + toadd.debugString() + " as a child of " + debugString() + " since component is already attached to the tree." + "\n Please detach it first using the remove method."); if (childmap.get(childkey) != null) { throw new IllegalArgumentException("Cannot add leaf " + toadd.debugString() + " as a child of " + debugString() + " since it would displace an existing child of the same name. " + "\n Please remove the existing component first.");
private void cloneChildren(UIContainer target, UIContainer source, RemapState state) { ComponentList children = source.flattenChildren(); for (int i = 0; i < children.size(); ++i) { UIComponent child = (UIComponent) children.get(i); if (child instanceof UIReplicator) { expandReplicator(target, (UIReplicator) child, state); } else { UIComponent cloned = cloneComponent(child, state); target.addComponent(cloned); } } }
/** Render a template message into an "ad hoc" UIMessage component * */ public UIMessage renderMessage(UIContainer basecontainer, String id, String key) { // attach to base container so that full ID can be computed by default algorithm - // RSF-71 String addId = id == null? "" : id; UIComponent existing = basecontainer.getComponent(addId); if (existing != null) { basecontainer.remove(existing); } UIMessage togo = UIMessage.make(basecontainer, addId, key); String message = messagelocator.getMessage(togo.messagekeys, togo.arguments); if (message == null) { message = MessageUtil.renderDefaultMessage(key); } togo.setValue(message); return togo; }
basecontainer.addComponent(messageFlyweight.rsfMessages); messagerenderer.renderMessageList(basecontainer, messageFlyweight, messages); renderContainer(messageFlyweight.rsfMessages, messagelump); basecontainer.remove(messageFlyweight.rsfMessages); UIComponent[] flatchildren = basecontainer.flatChildren(); for (int i = 0; i < flatchildren.length; ++i) { UIComponent child = flatchildren[i];
private void resolveRecurse(UIContainer basecontainer, XMLLump parentlump) { UIComponent[] flatchildren = basecontainer.flatChildren(); for (int i = 0; i < flatchildren.length; ++i) { if (flatchildren[i] instanceof UIContainer) { if (Logger.log.isDebugEnabled()) { Logger.log.debug("Resolving call for component " + branch.getClass().getName() + " fullID " + branch.getFullID()); if (resolved == null) { Logger.log.debug("No target found!"); rewritemap.put( RenderUtil.getRewriteKey(parentlump.parent, basecontainer, id), branch .getFullID());
/** * Returns a flattened array of all children of this container. Note that this * method will trigger the creation of a cached internal array on its first * use, which cannot be recreated. It is essential therefore that it only be * used once ALL modifications to the component tree have concluded (i.e. once * rendering starts). */ public UIComponent[] flatChildren() { if (flatchildren == null) { ComponentList children = flattenChildren(); flatchildren = (UIComponent[]) children.toArray(new UIComponent[children .size()]); } return flatchildren; }
private int evalDeficit(UIContainer container, XMLLump lump) { int deficit = 0; UIComponent[] children = container.flatChildren(); doneprefix.clear(); for (int i = 0; i < children.length; ++i) {
private XMLLump resolveCall(XMLLump sourcescope, UIContainer child) { String searchID = child instanceof UIJointContainer ? ((UIJointContainer) child).jointID : child.ID; SplitID split = new SplitID(searchID); String defprefix = split.prefix + SplitID.SEPARATOR; BestMatch bestmatch = new BestMatch(); if (Logger.log.isDebugEnabled()) { Logger.log.debug("Resolving call for ID " + searchID + " from container " + child.debugChildren()); } // first get lumps in THIS SCOPE with EXACTLY MATCHING ID. resolveInScope(searchID, defprefix, bestmatch, sourcescope.downmap, child); if (bestmatch.deficit == 0) { return bestmatch.bestlump; } // only enable global resolution if it is a branch if (child instanceof UIBranchContainer) { if (sourcescope.parent.isstatictemplate) { // make sure we can resolve local (intra-template) branches in the static case resolveInScope(searchID, defprefix, bestmatch, sourcescope.parent.globalmap, child); } resolveInScope(searchID, defprefix, bestmatch, globalmap, child); } return bestmatch.bestlump; }
private void registerContainer(UIForm toprocess, UIContainer toregister) { ComponentList children = toregister.flattenChildren(); for (int i = 0; i < children.size(); ++i) { UIComponent child = children.componentAt(i); registerComponent(toprocess, child); } } }
public String debugChildren() { CharWrap togo = new CharWrap(); togo.append("Child IDs: ("); UIComponent[] children = flatChildren(); for (int i = 0; i < children.length; ++i) { if (i != 0) { togo.append(", "); } togo.append(children[i].ID); } togo.append(")"); return togo.toString(); }
public UIJointContainer evolveTextInput(UIInput toevolve) { UIJointContainer joint = new UIJointContainer(toevolve.parent, toevolve.ID, COMPONENT_ID); toevolve.parent.remove(toevolve); toevolve.ID = SEED_ID; joint.addComponent(toevolve); return joint; } }
/** * Create a new UIJointContainer and add it to the component tree. * * @param parent The container to receive this newly created joint container. * @param ID The "client ID" or "source ID" of this container, that is, the * rsf:id under which the host template and producer refer to the * component. * @param jointID The "joint ID" or "target ID" of this container, that is, * the rsf:id under which the implementing or component template * refer to the component. */ public UIJointContainer(UIContainer parent, String ID, String jointID) { this.ID = ID; this.jointID = jointID; parent.addComponent(this); }
private ComponentIterator iteriseComponent(UIComponent parent) { if (parent instanceof UIContainer) { return ((UIContainer) parent).flattenChildren().iterate(); } else { ConcreteChildIterator cci = new ConcreteChildIterator(parent, smc); return new ComponentList(cci.children()).iterate(); } }
toevolve.parent.remove(toevolve); UIJointContainer joint = new UIJointContainer(parent, toevolve.ID, COMPONENT_ID);
public static UIBasicListMember makeBasic(UIContainer tofill, String ID, String parentFullID, int choiceindex) { UIBasicListMember togo = new UIBasicListMember(); togo.ID = ID; togo.parentFullID = parentFullID; togo.choiceindex = choiceindex; togo.willinput = true; tofill.addComponent(togo); return togo; } }
private void appendContainer(UIContainer toappend) { ComponentList thischildren = toappend.flattenChildren();
toevolve.parent.remove(toevolve); UIJointContainer joint = new UIJointContainer(parent, toevolve.ID, COMPONENT_ID);
public static UISelectChoice make(UIContainer tofill, String ID, String parentFullID, int choiceindex) { UISelectChoice togo = new UISelectChoice(); togo.ID = ID; togo.parentFullID = parentFullID; togo.choiceindex = choiceindex; togo.willinput = true; tofill.addComponent(togo); return togo; } }