@SuppressWarnings("unchecked") @Nullable @Override protected Options getOptions(EntityValueSource valueSource, String property) { MetaClass metaClass = valueSource.getEntityMetaClass(); MetaPropertyPath metaPropertyPath = metadataTools.resolveMetaPropertyPath(metaClass, property); Table.Column columnConf = webTable.getColumnsInternal().get(metaPropertyPath); CollectionContainer collectionContainer = findOptionsContainer(columnConf); if (collectionContainer != null) { return new ContainerOptions(collectionContainer); } CollectionDatasource ds = findOptionsDatasource(columnConf, property); if (ds != null) { return new DatasourceOptions(ds); } return null; }
@Override protected void componentValueChanged(Object newComponentValue, boolean userOriginated) { if (userOriginated) { CollectionContainer collectionContainer = null; if (optionsBinding.getSource() instanceof ContainerOptions) { collectionContainer = ((ContainerOptions) optionsBinding.getSource()).getContainer(); collectionContainer.mute(); } super.componentValueChanged(newComponentValue, userOriginated); if (collectionContainer != null) { collectionContainer.unmute(CollectionContainer.UnmuteEventsMode.FIRE_REFRESH_EVENT); } } }
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)); } } }
/** * Loads options of LookupFields if any. */ protected void refreshOptionsForLookupFields() { for (Component component : getForm().getOwnComponents()) { if (component instanceof LookupField) { Options options = ((LookupField) component).getOptions(); if (options instanceof ContainerOptions) { CollectionContainer container = ((ContainerOptions) options).getContainer(); if (container instanceof HasLoader) { DataLoader optionsLoader = ((HasLoader) container).getLoader(); if (optionsLoader != null) { optionsLoader.load(); } } } } } }
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)); } } }
@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)); } }