/** Returns the language definition that {@link #getComponentDefinition} * belongs to, or null if the component definition is temporary. */ public LanguageDefinition getLanguageDefinition() { return _compdef.getLanguageDefinition(); }
/** Returns the language definition that {@link #getComponentDefinition} * belongs to, or null if the component definition is temporary. */ public LanguageDefinition getLanguageDefinition() { return _compdef.getLanguageDefinition(); }
private synchronized void writeObject(java.io.ObjectOutputStream s) throws java.io.IOException { s.defaultWriteObject(); final LanguageDefinition langdef = _compdef.getLanguageDefinition(); if (langdef != null) { s.writeObject(langdef.getName()); s.writeObject(_compdef.getName()); } else { s.writeObject(_compdef); } }
public void addComponent(Component comp) { //to avoid misuse, check whether new comp belongs to the same device type final LanguageDefinition langdef = comp.getDefinition().getLanguageDefinition(); if (langdef != null && !_devType.equals(langdef.getDeviceType())) throw new UiException( "Component, " + comp + ", does not belong to the same device type of the desktop, " + _devType); final String uuid = comp.getUuid(); final Component old = _comps.put(uuid, comp); if (old != comp && old != null) { _comps.put(uuid, old); //recover throw new InternalError("Caller shall prevent it: Register a component twice: " + comp); } /* For performance reason, we don't check if a component is detached and attached back (in another execution). Rather, reset _uuid when it is recycled (refer to AbstractComponent.setPage0 (the caller of removeComponent has to reset) else if (_uuidRecycle != null && !_uuidRecycle.isEmpty()) { for (RecycleInfo ri: _uuidRecycle) { final List<String> uuids = ri.uuids; if (uuids.remove(uuid)) { if (uuids.isEmpty()) it.remove(); break; } } }*/ }
/** Adds a component definition belonging to this page definition only. * * <p>It is the same as calling {@link ComponentDefinitionMap#add} * against {@link #getComponentDefinitionMap} */ public void addComponentDefinition(ComponentDefinition compdef) { final LanguageDefinition langdef = compdef.getLanguageDefinition(); if (langdef != null) { final LanguageDefinition ld2 = getLanguageDefinition(); if (langdef != ld2 && !langdef.getDeviceType().equals(ld2.getDeviceType())) throw new UiException("Component definition, " + compdef + ", does not belong to the same device type of the page definition, " + ld2.getDeviceType()); } _compdefs.add(compdef); }
s.writeObject(null); } else { LanguageDefinition langdef = _def.getLanguageDefinition(); if (langdef != null) { s.writeObject(langdef.getName());
compdef = (ComponentDefinitionImpl) ref; } else { compdef = (ComponentDefinitionImpl) ref.clone(ref.getLanguageDefinition(), name); compdef.setDeclarationURL(url); compdef = (ComponentDefinitionImpl) ref; } else { compdef = (ComponentDefinitionImpl) ref.clone(ref.getLanguageDefinition(), name); compdef.setDeclarationURL(url);
/** Returns the component definition of the specified class, or null * if not found. */ /*package*/ static ComponentDefinition getDefinition(Execution exec, Class<? extends Component> cls) { if (exec != null) { final ExecutionCtrl execCtrl = (ExecutionCtrl) exec; final PageDefinition pgdef = execCtrl.getCurrentPageDefinition(); final Page page = execCtrl.getCurrentPage(); final ComponentDefinition compdef = pgdef != null ? pgdef.getComponentDefinition(cls, true) : page != null ? page.getComponentDefinition(cls, true) : null; if (compdef != null && compdef.getLanguageDefinition() != null) return compdef; //already from langdef (not from pgdef) final ComponentDefinition compdef2 = Components.getDefinitionByDeviceType(exec.getDesktop().getDeviceType(), cls); return compdef != null && (compdef2 == null || !Objects.equals(compdef.getImplementationClass(), compdef2.getImplementationClass())) ? compdef : compdef2; //Feature 2816083: use compdef2 if same class } for (String deviceType : LanguageDefinition.getDeviceTypes()) { final ComponentDefinition compdef = Components.getDefinitionByDeviceType(deviceType, cls); if (compdef != null) return compdef; } return null; }