@Nullable @Override public String getTemplate(WindowInfo windowInfo) { return resolveWindowInfo(windowInfo).getTemplate(); }
protected List<Element> getFrameElements(Element frameElement) { String src = frameElement.attributeValue("src"); if (Strings.isNullOrEmpty(src)) { String screenId = frameElement.attributeValue("screen"); if (!Strings.isNullOrEmpty(screenId)) { src = windowConfig.getWindowInfo(screenId).getTemplate(); } } if (!Strings.isNullOrEmpty(src)) { try { Element layoutElement = getRootLayoutElement(src); if (layoutElement != null) { return layoutElement.elements(); } } catch (FileNotFoundException e) { log.error(e.getMessage()); } } return Collections.emptyList(); }
@Nullable protected Element loadScreenXml(WindowInfo windowInfo, ScreenOptions options) { String templatePath = windowInfo.getTemplate(); if (StringUtils.isNotEmpty(templatePath)) { Map<String, Object> params = Collections.emptyMap(); if (options instanceof MapScreenOptions) { params = ((MapScreenOptions) options).getParams(); } return screenXmlLoader.load(templatePath, windowInfo.getId(), params); } return null; }
protected boolean isLookupWindow(WindowInfo winInfo) { Element element = screenXmlLoader.load(winInfo.getTemplate(), winInfo.getId(), ParamsMap.empty()); String screenClassName = element.attributeValue("class"); try { Class<?> screenClass = Class.forName(screenClassName); if (AbstractLookup.class.isAssignableFrom(screenClass)) { return true; } } catch (NullPointerException | ClassNotFoundException e) { return false; } return false; }
@Nullable public String getScreenCaption(WindowInfo windowInfo, Locale locale) throws FileNotFoundException { String src = windowInfo.getTemplate(); if (StringUtils.isNotEmpty(src)) { String key = getCaptionCacheKey(src, locale); String caption = captionCache.get(key); if (caption != null) { return caption; } Element window = getWindowElement(src); if (window != null) { return getScreenCaption(window, src); } } Class screenClass = windowInfo.getControllerClass(); return screenClass.getSimpleName(); }
for (WindowInfo windowInfo : windowConfig.getWindows()) { DocumentBuilder documentBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder(); if (StringUtils.isNoneEmpty(windowInfo.getTemplate())) { try { InputStream resource = resources.getResourceAsStream(windowInfo.getTemplate()); if (resource != null) { Document document = documentBuilder.parse(resource); windowInfo.getId(), windowInfo.getTemplate(), className)); } catch (Exception e) { log.error(String.format("Unexpected error on initialization screen %s, template %s, class %s", windowInfo.getId(), windowInfo.getTemplate(), className), e); windowInfo.getId(), windowInfo.getTemplate())); windowInfo.getId(), windowInfo.getTemplate()), e);
protected List<String> getAllLookupIds() { Collection<WindowInfo> allWindows = windowConfig.getWindows(); List<String> lookupIds = new ArrayList<>(); for (WindowInfo winInfo : allWindows) { if (isNotBlank(winInfo.getTemplate()) && isLookupWindow(winInfo)) { lookupIds.add(winInfo.getId()); } else if (winInfo.getScreenClass() != null && AbstractLookup.class.isAssignableFrom(winInfo.getScreenClass())) { lookupIds.add(winInfo.getId()); } } filterLookupFields(lookupIds); return lookupIds; }
try { params.put("XML descriptor", windowConfig.getWindowInfo(guiDevException.getFrameId()).getTemplate()); } catch (Exception e) { params.put("XML descriptor", "not found for " + guiDevException.getFrameId());
public List<ScreenComponentDescriptor> getScreenComponents(String screenId) { String key = getScreenComponentsCacheKey(screenId, userSessionSource.getLocale()); List<ScreenComponentDescriptor> screenComponents = screenComponentsCache.get(key); if (screenComponents != null) { return screenComponents; } List<ScreenComponentDescriptor> components = new ArrayList<>(); WindowInfo windowInfo = windowConfig.findWindowInfo(screenId); if (windowInfo != null) { String template = windowInfo.getTemplate(); try { Element layoutElement = getRootLayoutElement(template); if (layoutElement != null) { findScreenComponents(components, null, layoutElement); } } catch (FileNotFoundException e) { log.error("Can't obtain screen's root layout: ", e); } } components = ImmutableList.copyOf(components); cacheScreenComponents(key, components); return components; }
String src = windowInfo.getTemplate(); if (StringUtils.isNotEmpty(src)) { try {
@Override public void createComponent() { metadata = AppBeans.get(Metadata.class); frameId = element.attributeValue("id"); WindowConfig windowConfig = AppBeans.get(WindowConfig.NAME); WindowInfo windowInfo = windowConfig.getWindowInfo("dashboard$DashboardComponent"); String template = windowInfo.getTemplate(); DashboardLayoutLoader layoutLoader = new DashboardLayoutLoader(context, factory, LayoutLoaderConfig.getFrameLoaders()); layoutLoader.setLocale(getLocale()); layoutLoader.setMessagesPack(getMessagesPack()); String currentFrameId = context.getCurrentFrameId(); context.setCurrentFrameId(frameId); try { Pair<ComponentLoader, Element> loaderElementPair = layoutLoader.createFrameComponent(template, frameId, context.getParams()); frameLoader = loaderElementPair.getFirst(); resultComponent = (DashboardFrame) frameLoader.getResultComponent(); } finally { context.setCurrentFrameId(currentFrameId); } }
protected <T extends Screen> void loadWindowFromXml(Element element, WindowInfo windowInfo, Window window, T controller, ComponentLoaderContext componentLoaderContext) { LayoutLoader layoutLoader = beanLocator.getPrototype(LayoutLoader.NAME, componentLoaderContext); layoutLoader.setLocale(getLocale()); layoutLoader.setMessagesPack(getMessagePack(windowInfo.getTemplate())); ComponentLoader<Window> windowLoader = layoutLoader.createWindowContent(window, element, windowInfo.getId()); if (controller instanceof LegacyFrame) { screenViewsLoader.deployViews(element); initDsContext(window, element, componentLoaderContext); DsContext dsContext = ((LegacyFrame) controller).getDsContext(); if (dsContext != null) { dsContext.setFrameContext(window.getContext()); } } windowLoader.loadComponent(); }
if (windowInfo.getTemplate() == null) { throw new GuiDevelopmentException( String.format("Screen %s doesn't have template path configured", screenId), if (windowInfo.getTemplate() != null) { String frameId = fragmentId; if (parentContext.getFullFrameId() != null) { layoutLoader.setMessagesPack(getMessagePack(windowInfo.getTemplate())); Element windowElement = screenXmlLoader.load(windowInfo.getTemplate(), windowInfo.getId(), getContext().getParams());
if (windowInfo.getTemplate() != null) { String frameId = fragmentId; if (parentContext.getFullFrameId() != null) { layoutLoader.setMessagesPack(getMessagePack(windowInfo.getTemplate())); Element windowElement = screenXmlLoader.load(windowInfo.getTemplate(), windowInfo.getId(), getContext().getParams());
if (windowInfo.getTemplate() != null) { ComponentLoaderContext innerContext = new ComponentLoaderContext(options); innerContext.setCurrentFrameId(windowInfo.getId()); layoutLoader.setMessagesPack(getMessagePack(windowInfo.getTemplate())); Element windowElement = screenXmlLoader.load(windowInfo.getTemplate(), windowInfo.getId(), innerContext.getParams());