use of com.haulmont.cuba.gui.components.Component.HasXmlDescriptor in project cuba by cuba-platform.
the class FakeFilterSupport method createFakeFilter.
public Filter createFakeFilter() {
if (filter != null) {
return filter;
}
Filter fakeFilter = AppBeans.get(ComponentsFactory.NAME, ComponentsFactory.class).createComponent(Filter.class);
Dom4jTools dom4JTools = AppBeans.get(Dom4jTools.NAME);
((HasXmlDescriptor) fakeFilter).setXmlDescriptor(dom4JTools.readDocument("<filter/>").getRootElement());
CollectionDatasourceImpl fakeDatasource = new CollectionDatasourceImpl();
LegacyFrame legacyFrame = (LegacyFrame) this.frameOwner;
DsContextImpl fakeDsContext = new DsContextImpl(legacyFrame.getDsContext().getDataSupplier());
FrameContextImpl fakeFrameContext = new FrameContextImpl((Frame) legacyFrame);
fakeDsContext.setFrameContext(fakeFrameContext);
fakeDatasource.setDsContext(fakeDsContext);
// Attention: this query should match the logic in com.haulmont.reports.wizard.ReportingWizardBean.createJpqlDataSet()
fakeDatasource.setQuery("select queryEntity from " + metaClass.getName() + " queryEntity");
fakeDatasource.setMetaClass(metaClass);
fakeFilter.setDatasource(fakeDatasource);
fakeFilter.setFrame(UiControllerUtils.getFrame(frameOwner));
return fakeFilter;
}
use of com.haulmont.cuba.gui.components.Component.HasXmlDescriptor in project cuba by cuba-platform.
the class UiControllerDependencyInjector method createMessageBundle.
protected MessageBundle createMessageBundle(@SuppressWarnings("unused") AnnotatedElement element, FrameOwner frameOwner, Frame frame) {
MessageBundle messageBundle = beanLocator.getPrototype(MessageBundle.NAME);
Class<? extends FrameOwner> screenClass = frameOwner.getClass();
String packageName = UiControllerUtils.getPackage(screenClass);
messageBundle.setMessagesPack(packageName);
if (frame instanceof HasXmlDescriptor) {
Element xmlDescriptor = ((HasXmlDescriptor) frame).getXmlDescriptor();
if (xmlDescriptor != null) {
String messagePack = xmlDescriptor.attributeValue("messagesPack");
if (messagePack != null) {
messageBundle.setMessagesPack(messagePack);
}
}
}
return messageBundle;
}
Aggregations