/** 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); }
public Desktop newDesktop(RequestInfo ri, String updateURI, String path) { String deviceType = null; if (path != null) { //convert to directory //though UiEngine.execNewPage will set the device type later, //we 'guess' a value first by use of the extension //reason: less dependent of how UiEngine is implemented final int k = path.lastIndexOf('.') + 1; if (k > 0 && path.indexOf('/', k) < 0 && k < path.length()) { final String ext = path.substring(k); try { deviceType = LanguageDefinition.getByExtension(ext).getDeviceType(); } catch (DefinitionNotFoundException ex) { //ignore } } } return new DesktopImpl(ri.getWebApp(), updateURI, path, deviceType, ri.getNativeRequest()); }
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; } } }*/ }
ref = pgdef.getComponentDefinition(cls, true); if (ref == null) //return null if not found ref = Components.getDefinitionByDeviceType(langdef.getDeviceType(), cls);
log.debug("Addon language to " + lang + " from " + root.getElementValue("addon-name", true)); langdef = LanguageDefinition.lookup(lang); device = Devices.getDevice(langdef.getDeviceType());
pagedef != null ? pagedef.getLanguageDefinition() : richlet != null ? richlet.getLanguageDefinition() : null; if (langdef != null) desktop.setDeviceType(langdef.getDeviceType()); //set and check!