protected void loadDataBeforeShow(Screen screen) { LoadDataBeforeShow annotation = screen.getClass().getAnnotation(LoadDataBeforeShow.class); if (annotation != null && annotation.value()) { UiControllerUtils.getScreenData(screen).loadAll(); } }
@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)); } }
protected <E extends Entity> void removeItems(RemoveBuilder<E> builder, List<E> selectedItems) { FrameOwner origin = builder.getOrigin(); ScreenData screenData = UiControllerUtils.getScreenData(origin); CollectionContainer<E> container = getCollectionContainer(builder); commitIfNeeded(selectedItems, container, screenData); if (selectedItems.size() == 1) { container.getMutableItems().remove(selectedItems.get(0)); } else { container.getMutableItems().removeAll(selectedItems); } focusListComponent(builder); }
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 void loadScreenData(Window window, Element element) { Element dataEl = element.element("data"); if (dataEl != null) { ScreenDataXmlLoader screenDataXmlLoader = beanLocator.get(ScreenDataXmlLoader.class); ScreenData screenData = UiControllerUtils.getScreenData(window.getFrameOwner()); screenDataXmlLoader.load(screenData, dataEl, null); ((ComponentLoaderContext) context).setScreenData(screenData); } }
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]); }
@Nullable protected DataContext setupParentDataContext(FrameOwner origin, Screen screen, InstanceContainer container, DataContext parentContext) { DataContext dataContext = parentContext; if (dataContext == null && container instanceof Nested) { InstanceContainer masterContainer = ((Nested) container).getMaster(); String property = ((Nested) container).getProperty(); MetaClass masterMetaClass = masterContainer.getEntityMetaClass(); MetaProperty metaProperty = masterMetaClass.getPropertyNN(property); if (metaProperty.getType() == MetaProperty.Type.COMPOSITION) { dataContext = UiControllerUtils.getScreenData(origin).getDataContext(); } } if (dataContext != null) { UiControllerUtils.getScreenData(screen).getDataContext().setParent(dataContext); } return dataContext; }
@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)); } } }
targetInstance = UiControllerUtils.getScreenData(frameOwner).getDataContext(); break; targetInstance = UiControllerUtils.getScreenData(frameOwner).getLoader(target); } else { targetInstance = findInstallTarget(target, frame);
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 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))); }
if (containerId != null) { FrameOwner frameOwner = context.getFrame().getFrameOwner(); ScreenData screenData = UiControllerUtils.getScreenData(frameOwner); InstanceContainer container = screenData.getContainer(containerId); CollectionContainer collectionContainer;
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 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)); } } }
if (StringUtils.isNotEmpty(dataContainerId)) { FrameOwner frameOwner = context.getFrame().getFrameOwner(); ScreenData screenData = UiControllerUtils.getScreenData(frameOwner);
@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)); } }
@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)); } } }
protected void loadScreenData(Element dataEl) { ScreenData hostScreenData = null; Context parent = context.getParent(); while (hostScreenData == null && parent != null) { hostScreenData = parent.getScreenData(); parent = parent.getParent(); } ScreenDataXmlLoader screenDataXmlLoader = beanLocator.get(ScreenDataXmlLoader.class); ScreenData screenData = UiControllerUtils.getScreenData(resultComponent.getFrameOwner()); screenDataXmlLoader.load(screenData, dataEl, hostScreenData); ((ComponentLoaderContext) context).setScreenData(screenData); }
DataContext dataContext = UiControllerUtils.getScreenData(builder.getOrigin()).getDataContext();