@Nullable protected CollectionContainer findOptionsContainer(Table.Column columnConf) { String optDcName = columnConf.getXmlDescriptor() != null ? columnConf.getXmlDescriptor().attributeValue("optionsContainer") : null; if (Strings.isNullOrEmpty(optDcName)) { return null; } else { ScreenData screenData = UiControllerUtils.getScreenData(webTable.getFrame().getFrameOwner()); InstanceContainer container = screenData.getContainer(optDcName); if (container instanceof CollectionContainer) { return (CollectionContainer) container; } throw new IllegalStateException( String.format("'%s' is not an instance of CollectionContainer", optDcName)); } }
eventTarget = screenData.getContainer(target);
protected void loadDataContainer(Form resultComponent, Element element) { String containerId = element.attributeValue("dataContainer"); if (!Strings.isNullOrEmpty(containerId)) { FrameOwner frameOwner = context.getFrame().getFrameOwner(); ScreenData screenData = UiControllerUtils.getScreenData(frameOwner); InstanceContainer container = screenData.getContainer(containerId); //noinspection unchecked resultComponent.setValueSourceProvider(new ContainerValueSourceProvider(container)); } }
protected InstanceContainer<T> getEditedEntityContainer() { EditedEntityContainer annotation = getClass().getAnnotation(EditedEntityContainer.class); if (annotation == null || Strings.isNullOrEmpty(annotation.value())) { throw new IllegalStateException( String.format("StandardEditor %s does not declare @EditedEntityContainer", getClass()) ); } String[] parts = annotation.value().split("\\."); ScreenData screenData; if (parts.length == 1) { screenData = getScreenData(); } else { Frame frame = getWindow(); for (int i = 0; i < parts.length - 1; i++) { String part = parts[i]; Component component = frame.getComponent(part); if (!(component instanceof Frame)) { throw new IllegalStateException("Path to EditedEntityContainer must include frames only"); } frame = (Frame) component; } screenData = UiControllerUtils.getScreenData(frame.getFrameOwner()); } return screenData.getContainer(parts[parts.length - 1]); }
protected void loadKeyValueCollectionContainer(ScreenData screenData, Element element, @Nullable ScreenData hostScreenData) { String containerId = getRequiredAttr(element, "id"); KeyValueCollectionContainer container; if (checkProvided(element, hostScreenData)) { //noinspection ConstantConditions container = hostScreenData.getContainer(containerId); } else { container = factory.createKeyValueCollectionContainer(); loadProperties(element, container); String idName = element.attributeValue("idName"); if (!Strings.isNullOrEmpty(idName)) container.setIdName(idName); } screenData.registerContainer(containerId, container); Element loaderEl = element.element("loader"); if (loaderEl != null) { loadKeyValueCollectionLoader(screenData, loaderEl, container, hostScreenData); } }
protected void loadKeyValueInstanceContainer(ScreenData screenData, Element element, ScreenData hostScreenData) { String containerId = getRequiredAttr(element, "id"); KeyValueContainer container; if (checkProvided(element, hostScreenData)) { container = hostScreenData.getContainer(containerId); } else { container = factory.createKeyValueContainer(); loadProperties(element, container); String idName = element.attributeValue("idName"); if (!Strings.isNullOrEmpty(idName)) container.setIdName(idName); } screenData.registerContainer(containerId, container); Element loaderEl = element.element("loader"); if (loaderEl != null) { loadKeyValueInstanceLoader(screenData, loaderEl, container, hostScreenData); } }
@SuppressWarnings("unchecked") protected void loadContainer(T component, Element element) { String containerId = element.attributeValue("dataContainer"); String property = element.attributeValue("property"); // In case a component has only a property, // we try to obtain `dataContainer` from a parent element. // For instance, a component is placed within the Form component if (Strings.isNullOrEmpty(containerId) && property != null) { containerId = getParentDataContainer(element); } if (!Strings.isNullOrEmpty(containerId)) { if (property == null) { throw new GuiDevelopmentException( String.format("Can't set container '%s' for component '%s' because 'property' " + "attribute is not defined", containerId, component.getId()), context.getFullFrameId()); } FrameOwner frameOwner = context.getFrame().getFrameOwner(); ScreenData screenData = UiControllerUtils.getScreenData(frameOwner); InstanceContainer container = screenData.getContainer(containerId); if (component instanceof HasValueSource) { ((HasValueSource) component).setValueSource(new ContainerValueSource<>(container, property)); } } }
FrameOwner frameOwner = context.getFrame().getFrameOwner(); ScreenData screenData = UiControllerUtils.getScreenData(frameOwner); InstanceContainer container = screenData.getContainer(containerId); CollectionContainer collectionContainer; if (container instanceof CollectionContainer) {
protected void loadDataContainer(Calendar component, Element element) { String containerId = element.attributeValue("dataContainer"); FrameOwner frameOwner = context.getFrame().getFrameOwner(); ScreenData screenData = UiControllerUtils.getScreenData(frameOwner); InstanceContainer container = screenData.getContainer(containerId); if (!(container instanceof CollectionContainer)) { throw new GuiDevelopmentException("Not a CollectionContainer: " + containerId, context.getCurrentFrameId()); } component.setEventProvider(new ContainerCalendarEventProvider<>(((CollectionContainer) container))); }
protected void loadDataContainer(PivotTable pivotTable, Element element) { String dataContainerId = element.attributeValue("dataContainer"); if (StringUtils.isNotEmpty(dataContainerId)) { FrameOwner frameOwner = context.getFrame().getFrameOwner(); ScreenData screenData = UiControllerUtils.getScreenData(frameOwner); CollectionContainer dataContainer; InstanceContainer container = screenData.getContainer(dataContainerId); if (container instanceof CollectionContainer) { dataContainer = (CollectionContainer) container; } else { throw new GuiDevelopmentException("Not a CollectionContainer: " + dataContainerId, context.getCurrentFrameId()); } pivotTable.setDataProvider(new ContainerDataProvider(dataContainer)); } else { loadDatasource(pivotTable, element); } }
protected void loadInstanceContainer(ScreenData screenData, Element element, @Nullable ScreenData hostScreenData) { String containerId = getRequiredAttr(element, "id"); InstanceContainer<Entity> container; if (checkProvided(element, hostScreenData)) { //noinspection ConstantConditions container = hostScreenData.getContainer(containerId); } else { container = factory.createInstanceContainer(getEntityClass(element)); loadView(element, getEntityClass(element), container); } screenData.registerContainer(containerId, container); Element loaderEl = element.element("loader"); if (loaderEl != null) { loadInstanceLoader(screenData, loaderEl, container, hostScreenData); } for (Element collectionEl : element.elements()) { loadNestedContainer(screenData, collectionEl, container, hostScreenData); } }
protected void loadOptionsContainer(TwinColumn component, Element element) { String containerId = element.attributeValue("optionsContainer"); if (containerId != null) { FrameOwner frameOwner = context.getFrame().getFrameOwner(); ScreenData screenData = UiControllerUtils.getScreenData(frameOwner); InstanceContainer container = screenData.getContainer(containerId); if (!(container instanceof CollectionContainer)) { throw new GuiDevelopmentException("Not a CollectionContainer: " + containerId, context.getCurrentFrameId()); } //noinspection unchecked component.setOptions(new ContainerOptions((CollectionContainer) container)); } } }
protected void loadDataContainer(Chart chart, Element element) { String dataContainerId = element.attributeValue("dataContainer"); if (StringUtils.isNotEmpty(dataContainerId)) { FrameOwner frameOwner = context.getFrame().getFrameOwner(); ScreenData screenData = UiControllerUtils.getScreenData(frameOwner); CollectionContainer dataContainer; InstanceContainer container = screenData.getContainer(dataContainerId); if (container instanceof CollectionContainer) { dataContainer = (CollectionContainer) container; } else { throw new GuiDevelopmentException("Not a CollectionContainer: " + dataContainerId, context.getCurrentFrameId()); } chart.setDataProvider(new ContainerDataProvider(dataContainer)); } else { loadDatasource(resultComponent, element); } }
protected void loadCollectionContainer(ScreenData screenData, Element element, @Nullable ScreenData hostScreenData) { String containerId = getRequiredAttr(element, "id"); CollectionContainer<Entity> container; if (checkProvided(element, hostScreenData)) { //noinspection ConstantConditions container = hostScreenData.getContainer(containerId); } else { container = factory.createCollectionContainer(getEntityClass(element)); loadView(element, getEntityClass(element), container); } screenData.registerContainer(containerId, container); Element loaderEl = element.element("loader"); if (loaderEl != null) { loadCollectionLoader(screenData, loaderEl, container, hostScreenData); } for (Element collectionEl : element.elements()) { loadNestedContainer(screenData, collectionEl, container, hostScreenData); } }
protected void loadOptionsContainer(TokenList component, Element element) { String containerId = element.attributeValue("optionsContainer"); if (containerId != null) { FrameOwner frameOwner = context.getFrame().getFrameOwner(); ScreenData screenData = UiControllerUtils.getScreenData(frameOwner); InstanceContainer container = screenData.getContainer(containerId); if (!(container instanceof CollectionContainer)) { throw new GuiDevelopmentException("Not a CollectionContainer: " + containerId, context.getCurrentFrameId()); } //noinspection unchecked component.setOptions(new ContainerOptions((CollectionContainer) container)); } } }
InstanceContainer container = screenData.getContainer(dataContainerId); if (container instanceof CollectionContainer) { dataContainer = (CollectionContainer) container;
@SuppressWarnings("unchecked") @Override protected void loadContainer(T component, Element element) { super.loadContainer(component, element); String containerId = element.attributeValue("optionsContainer"); if (containerId != null) { FrameOwner frameOwner = context.getFrame().getFrameOwner(); ScreenData screenData = UiControllerUtils.getScreenData(frameOwner); InstanceContainer container = screenData.getContainer(containerId); if (!(container instanceof CollectionContainer)) { throw new GuiDevelopmentException("Not a CollectionContainer: " + containerId, context.getCurrentFrameId()); } component.setOptions(new ContainerOptions((CollectionContainer) container)); } } }
@SuppressWarnings("unchecked") @Override protected void loadContainer(LookupField component, Element element) { super.loadContainer(component, element); String containerId = element.attributeValue("optionsContainer"); if (containerId != null) { FrameOwner frameOwner = context.getFrame().getFrameOwner(); ScreenData screenData = UiControllerUtils.getScreenData(frameOwner); InstanceContainer container = screenData.getContainer(containerId); if (!(container instanceof CollectionContainer)) { throw new GuiDevelopmentException("Not a CollectionContainer: " + containerId, context.getCurrentFrameId()); } component.setOptions(new ContainerOptions((CollectionContainer) container)); } }
nestedContainer = hostScreenData.getContainer(containerId); } else { if (element.getName().equals("collection")) {
FrameOwner frameOwner = context.getFrame().getFrameOwner(); ScreenData screenData = UiControllerUtils.getScreenData(frameOwner); InstanceContainer container = screenData.getContainer(containerId); if (container instanceof CollectionContainer) { collectionContainer = (CollectionContainer) container;