public String getValue(Component cmp) { return cmp.getId(); } });
public String getId() { return comp.getId(); }
/*package*/ static boolean matchID(Component component, String id) { if(id == null) return true; return id.equals(component.getId()); }
/*package*/ static boolean matchID(Component component, String id) { if (id == null) return true; return id.equals(component.getId()); }
/** Bind comp to this ID space (owned by this component). * Called only if IdSpace is implemented. * comp's ID must be unique (and not auto id) */ private void bindToIdSpace(Component comp) { _auxinf.spaceInfo.fellows.put(comp.getId(), comp); }
private static void removeFromShadowIdMap(Component host, Component comp) { if (host != null && comp instanceof ShadowElement) { String id = comp.getId(); AbstractComponent ac = (AbstractComponent) host; if (ac._shadowIdMap != null) { ac._shadowIdMap.remove(id); } } } }
/*package*/ void addFellow(Component comp) { final String compId = comp.getId(); final Component old = _fellows.put(compId, comp); if (old != comp) { //possible due to recursive call if (old != null) { _fellows.put(old.getId(), old); //recover throw new InternalError("Called shall prevent replicated ID for roots"); } } }
/*package*/ void removeFellow(Component comp) { _fellows.remove(comp.getId()); }
private static final String getId(Component comp, String uuid) { if (comp instanceof StubComponent) return ((StubComponent) comp).getId(uuid); if (comp != null) { String id = comp.getId(); if (id != null && id.length() > 0) return id; } return null; }
private static void addToShadowIdMap(Component comp) { if (comp instanceof ShadowElementCtrl) { Component host = ((ShadowElementCtrl) comp).getShadowHostIfAny(); if (host != null) { String id = comp.getId(); AbstractComponent ac = (AbstractComponent) host; if (ac._shadowIdMap != null) { if (ac._shadowIdMap.get(id) != null) throw new InternalError("Caller shall prevent duplicated ID for shadow hosts"); ac._shadowIdMap.put(id, (ShadowElement) comp); } } } }
private void injectFellow(Object arg) { //try setXxx final String fdname = (arg instanceof Page) ? ((Page) arg).getId() : ((Component) arg).getId(); if (fdname.length() > 0) { injectByName(arg, fdname, false); } }
private final void fixFellows(Collection<Component> c) { for (Component comp : c) { final String compId = comp.getId(); if (compId.length() > 0) addFellow(comp); if (!(comp instanceof IdSpace)) fixFellows(comp.getChildren()); //recursive } }
private static void init(Map<String, Component> fellows, Component comp) { if (!(comp instanceof NonFellow)) { final String compId = comp.getId(); if (!AbstractComponent.isAutoId(compId)) fellows.put(compId, comp); } if (!(comp instanceof IdSpace)) for (Component child = comp.getFirstChild(); child != null; child = child.getNextSibling()) init(fellows, child); //recursive }
private static void removeFellow(Component comp, IdSpace owner) { if (owner instanceof Component) ((AbstractComponent) owner).unbindFromIdSpace(comp.getId()); else if (owner instanceof Page) ((AbstractPage) owner).removeFellow(comp); if (owner == null && comp instanceof ShadowElement) removeFromShadowIdMap(comp); }
private static void checkIdSpacesDown(Component comp, IdSpace owner) { final String compId = comp.getId(); if (!(comp instanceof NonFellow) && !isAutoId(compId) && (owner instanceof Component ? ((AbstractComponent) owner)._auxinf.spaceInfo.fellows.containsKey(compId) : owner.hasFellow(compId))) throw new UiException("Not unique in the ID space of " + owner + ": " + compId); if (!(comp instanceof IdSpace)) for (AbstractComponent ac = (AbstractComponent) comp.getFirstChild(); ac != null; ac = ac._next) checkIdSpacesDown(ac, owner); //recursive }
/** Adds to the ID spaces, if any, when ID is changed. * Caller has to make sure the uniqueness (and not auto id). */ private static void addToIdSpaces(final Component comp) { final String compId = comp.getId(); if (comp instanceof NonFellow || isAutoId(compId)) return; //nothing to do if (comp instanceof IdSpace) ((AbstractComponent) comp).bindToIdSpace(comp); addFellow(comp, getSpaceOwnerOfParent(comp)); }
/** Removes from the ID spaces, if any, when ID is changed. */ private static void removeFromIdSpaces(final Component comp) { final String compId = comp.getId(); if (comp instanceof NonFellow || isAutoId(compId)) return; //nothing to do if (comp instanceof IdSpace) ((AbstractComponent) comp).unbindFromIdSpace(compId); removeFellow(comp, getSpaceOwnerOfParent(comp)); }
private static void removeFromIdSpacesDown(Component comp, IdSpace owner) { if (!(comp instanceof NonFellow) && !isAutoId(comp.getId())) removeFellow(comp, owner); if (!(comp instanceof IdSpace)) for (AbstractComponent ac = (AbstractComponent) comp.getFirstChild(); ac != null; ac = ac._next) removeFromIdSpacesDown(ac, owner); //recursive ((AbstractComponent) comp).notifyIdSpaceChanged(null); }
private static void addToIdSpacesDown(Component comp, IdSpace owner) { if (!(comp instanceof NonFellow) && !isAutoId(comp.getId())) addFellow(comp, owner); if (!(comp instanceof IdSpace)) for (AbstractComponent ac = (AbstractComponent) comp.getFirstChild(); ac != null; ac = ac._next) addToIdSpacesDown(ac, owner); //recursive ((AbstractComponent) comp).notifyIdSpaceChanged(owner); }
public JSONObject toJSON() { JSONObject json = new JSONObject(); putEssential(json, "type", _type); if (_comp != null) { put(json, "widget", _comp.getDefinition().getName()); put(json, "uuid", _comp.getUuid()); put(json, "id", _comp.getId()); } put(json, "subtype", _subtype); put(json, "note", toString(_note, 300)); put(json, "location", _location); return json; }