use of io.jmix.reports.app.EntityTree in project jmix by jmix-framework.
the class EntityTreeModelBuilder method buildEntityTree.
public EntityTree buildEntityTree(MetaClass metaClass) {
EntityTreeStructureInfo entityTreeStructureInfo = new EntityTreeStructureInfo();
EntityTreeNode root = createRootNode(metaClass);
fillChildNodes(root, 1, new HashSet<>(), entityTreeStructureInfo);
return new EntityTree(root, entityTreeStructureInfo);
}
use of io.jmix.reports.app.EntityTree 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();
}
}
}
}
}
}
use of io.jmix.reports.app.EntityTree in project jmix by jmix-framework.
the class ReportWizardCreator method onNextBtnClick.
@Subscribe("nextBtn")
public void onNextBtnClick(Button.ClickEvent event) {
MetaClass metaClass = metadata.findClass(getItem().getEntityName());
if (metaClass == null) {
notifications.create(Notifications.NotificationType.TRAY).withCaption(messages.getMessage(getClass(), "fillEntityMsg")).show();
return;
}
if (detailsFragment.isNeedUpdateEntityModel()) {
EntityTree entityTree = reportWizard.buildEntityTree(metaClass);
regionsStepFragment.setEntityTreeHasSimpleAttrs(entityTree.getEntityTreeStructureInfo().isEntityTreeHasSimpleAttrs());
regionsStepFragment.setEntityTreeHasCollections(entityTree.getEntityTreeStructureInfo().isEntityTreeRootHasCollections());
getItem().setEntityTreeRootNode(entityTree.getEntityTreeRootNode());
detailsFragment.setNeedUpdateEntityModel(false);
}
stepFragmentManager.nextFragment();
centerWindow();
}
Aggregations