Search in sources :

Example 1 with RegionEditor

use of io.jmix.reportsui.screen.report.wizard.region.RegionEditor in project jmix by jmix-framework.

the class RegionsStepFragment method showRegionEditor.

protected void showRegionEditor(ReportRegion item, Map<String, Object> editorParams) {
    RegionEditor regionEditor = screenBuilders.editor(ReportRegion.class, getFragment().getFrameOwner()).withScreenClass(RegionEditor.class).editEntity(item).withOpenMode(OpenMode.DIALOG).withContainer(reportRegionsDc).withOptions(new MapScreenOptions(editorParams)).build();
    regionEditor.show();
}
Also used : RegionEditor(io.jmix.reportsui.screen.report.wizard.region.RegionEditor)

Example 2 with RegionEditor

use of io.jmix.reportsui.screen.report.wizard.region.RegionEditor in project jmix by jmix-framework.

the class EditFetchPlanAction method actionPerform.

@Override
public void actionPerform(Component component) {
    if (dataSetsTable.getSingleSelected() != null) {
        final DataSet dataSet = dataSetsTable.getSingleSelected();
        if (DataSetType.SINGLE == dataSet.getType() || DataSetType.MULTI == dataSet.getType()) {
            MetaClass forEntityTreeModelMetaClass = findMetaClassByAlias(dataSet);
            if (forEntityTreeModelMetaClass != null) {
                final EntityTree entityTree = reportsWizard.buildEntityTree(forEntityTreeModelMetaClass);
                ReportRegion reportRegion = dataSetToReportRegion(dataSet, entityTree);
                if (reportRegion != null) {
                    if (reportRegion.getRegionPropertiesRootNode() == null) {
                        notifications.create(Notifications.NotificationType.TRAY).withCaption(messages.getMessage(getClass(), "dataSet.entityAliasInvalid")).withDescription(getNameForEntityParameter(dataSet)).show();
                    // without that root node region editor form will not initialized correctly and became empty. just return
                    } else {
                        // Open editor and convert saved in editor ReportRegion item to Fetch plan
                        reportRegion.setReportData(dataManager.create(ReportData.class));
                        reportRegion.setBandNameFromReport(dataSet.getName());
                        Map<String, Object> editorParams = new HashMap<>();
                        editorParams.put("rootEntity", reportRegion.getRegionPropertiesRootNode());
                        editorParams.put("scalarOnly", Boolean.TRUE);
                        RegionEditor screen = screenBuilders.editor(ReportRegion.class, dataSetsTable.getFrame().getFrameOwner()).editEntity(reportRegion).withScreenClass(RegionEditor.class).withOpenMode(OpenMode.DIALOG).withOptions(new MapScreenOptions(editorParams)).build();
                        screen.setAsFetchPlanEditor(true);
                        screen.setUpdatePermission(secureOperations.isEntityUpdatePermitted(metadata.getClass(Report.class), policyStore));
                        screen.addAfterCloseListener(afterCloseEvent -> {
                            if (afterCloseEvent.closedWith(StandardOutcome.COMMIT)) {
                                RegionEditor editor = (RegionEditor) afterCloseEvent.getSource();
                                reportRegion.setRegionProperties(editor.getEditedEntity().getRegionProperties());
                                dataSet.setFetchPlan(reportRegionToFetchPlan(entityTree, reportRegion));
                            }
                        });
                        screen.show();
                    }
                }
            }
        }
    }
}
Also used : RegionEditor(io.jmix.reportsui.screen.report.wizard.region.RegionEditor) MetaClass(io.jmix.core.metamodel.model.MetaClass) HashMap(java.util.HashMap) ReportData(io.jmix.reports.entity.wizard.ReportData) MapScreenOptions(io.jmix.ui.screen.MapScreenOptions) EntityTree(io.jmix.reports.app.EntityTree) ReportRegion(io.jmix.reports.entity.wizard.ReportRegion)

Aggregations

RegionEditor (io.jmix.reportsui.screen.report.wizard.region.RegionEditor)2 MetaClass (io.jmix.core.metamodel.model.MetaClass)1 EntityTree (io.jmix.reports.app.EntityTree)1 ReportData (io.jmix.reports.entity.wizard.ReportData)1 ReportRegion (io.jmix.reports.entity.wizard.ReportRegion)1 MapScreenOptions (io.jmix.ui.screen.MapScreenOptions)1 HashMap (java.util.HashMap)1