protected DataContext getDataContext() { DataLoader loader = container instanceof HasLoader ? ((HasLoader) container).getLoader() : null; return loader != null ? loader.getDataContext() : null; }
/** * Returns the loader of the edit form's data container. */ @SuppressWarnings("unchecked") protected InstanceLoader<T> getEditLoader() { DataLoader loader = ((HasLoader) getEditContainer()).getLoader(); if (loader == null) throw new IllegalStateException("Cannot find loader of editing container"); return (InstanceLoader<T>) loader; }
protected Adapter createLoaderAdapter(CollectionContainer container) { DataLoader loader = null; if (container instanceof HasLoader) { loader = ((HasLoader) container).getLoader(); } if (loader != null && !(loader instanceof BaseCollectionLoader)) { throw new IllegalStateException("RowsCount component currently supports only BaseCollectionLoader"); } return new LoaderAdapter(container, (BaseCollectionLoader) loader); }
protected InstanceLoader getEditedEntityLoader() { InstanceContainer<T> container = getEditedEntityContainer(); if (container == null) { throw new IllegalStateException("Edited entity container not defined"); } DataLoader loader = null; if (container instanceof HasLoader) { loader = ((HasLoader) container).getLoader(); } if (loader == null) { throw new IllegalStateException("Loader of edited entity container not found"); } if (!(loader instanceof InstanceLoader)) { throw new IllegalStateException(String.format( "Loader %s of edited entity container %s must implement InstanceLoader", loader, container)); } return (InstanceLoader) loader; }
protected <E extends Entity> void refreshItems(DataUnit dataSource) { CollectionContainer<E> container = dataSource instanceof ContainerDataUnit ? ((ContainerDataUnit) dataSource).getContainer() : null; if (container != null) { DataLoader loader = null; if (container instanceof HasLoader) { loader = ((HasLoader) container).getLoader(); } if (loader != null) { loader.load(); } else { log.warn("Target container has no loader, refresh is impossible"); } } }
public ContainerOptions(CollectionContainer<E> container) { this.container = container; if (container instanceof HasLoader) { this.loader = ((HasLoader) container).getLoader(); } this.container.addCollectionChangeListener(this::containerCollectionChanged); this.container.addItemPropertyChangeListener(this::containerItemPropertyChanged); }
@Override public void actionPerform(Component component) { if (!hasSubscriptions(ActionPerformedEvent.class)) { if (!(target.getItems() instanceof ContainerDataUnit)) { throw new IllegalStateException("RefreshAction target is null or does not implement SupportsContainerBinding"); } CollectionContainer container = ((ContainerDataUnit) target.getItems()).getContainer(); if (container == null) { throw new IllegalStateException("RefreshAction target is not bound to CollectionContainer"); } DataLoader loader = null; if (container instanceof HasLoader) { loader = ((HasLoader) container).getLoader(); } if (loader != null) { loader.load(); } else { log.warn("RefreshAction '{}' target container has no loader, refresh is impossible", getId()); } } else { super.actionPerform(component); } } }
/** * 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(); } } } } } }
dataLoader = ((HasLoader) collectionContainer).getLoader();
DataLoader dataLoader = ((HasLoader) instanceContainer).getLoader(); if (dataLoader instanceof InstanceLoader) { ((InstanceLoader) dataLoader).setLoadDynamicAttributes(true);
dataLoader = ((HasLoader) collectionContainer).getLoader();
InstanceContainer<T> editedEntityContainer = getEditedEntityContainer(); if (editedEntityContainer instanceof HasLoader) { if (((HasLoader) editedEntityContainer).getLoader() instanceof InstanceLoader) { instanceLoader = getEditedEntityLoader(); if (tools.screenContainsDynamicAttributes(editedEntityContainer.getView(), screenId)) {
InstanceContainer<T> editedEntityContainer = getEditContainer(); if (editedEntityContainer instanceof HasLoader) { if (((HasLoader) editedEntityContainer).getLoader() instanceof InstanceLoader) { instanceLoader = getEditLoader(); if (tools.screenContainsDynamicAttributes(editedEntityContainer.getView(), screenId)) {
protected void printAll() { MetaClass metaClass; LoadContext loadContext; if (listComponent.getItems() instanceof ContainerDataUnit) { ContainerDataUnit unit = (ContainerDataUnit) listComponent.getItems(); CollectionContainer container = unit.getContainer(); CollectionLoader loader = (CollectionLoader) ((HasLoader) unit.getContainer()).getLoader(); metaClass = container.getEntityMetaClass(); loadContext = loader.createLoadContext(); } else { CollectionDatasource ds = listComponent.getDatasource(); metaClass = ds.getMetaClass(); loadContext = ds.getCompiledLoadContext(); } ParameterPrototype parameterPrototype = new ParameterPrototype(metaClass.getName()); parameterPrototype.setMetaClassName(metaClass.getName()); LoadContext.Query query = loadContext.getQuery(); parameterPrototype.setQueryString(query.getQueryString()); parameterPrototype.setQueryParams(query.getParameters()); parameterPrototype.setViewName(loadContext.getView().getName()); Window window = ComponentsHelper.getWindowNN(listComponent); openRunReportScreen(window.getFrameOwner(), parameterPrototype, metaClass); } }