use of org.compiere.model.GridTabVO in project metasfresh-webui-api by metasfresh.
the class DefaultDocumentDescriptorLoader method load.
public DocumentDescriptor load() {
// Mark as executed
if (_executed) {
throw new IllegalStateException("Already executed");
}
_executed = true;
if (AD_Window_ID <= 0) {
throw new DocumentLayoutBuildException("No window found for AD_Window_ID=" + AD_Window_ID);
}
final Stopwatch stopwatch = Stopwatch.createStarted();
final GridWindowVO gridWindowVO = GridWindowVO.builder().ctx(Env.getCtx()).windowNo(// TODO: get rid of WindowNo from GridWindowVO
0).adWindowId(AD_Window_ID).adMenuId(// N/A
-1).loadAllLanguages(true).applyRolePermissions(false).build();
// shall never happen
Check.assumeNotNull(gridWindowVO, "Parameter gridWindowVO is not null");
final DocumentDescriptor.Builder documentBuilder = DocumentDescriptor.builder();
final DocumentLayoutDescriptor.Builder layoutBuilder = DocumentLayoutDescriptor.builder().setWindowId(WindowId.of(gridWindowVO.getAD_Window_ID())).setStopwatch(stopwatch).putDebugProperty("generator-name", toString());
//
// Layout: Create UI sections from main tab
final GridTabVO mainTabVO = gridWindowVO.getTab(GridTabVO.MAIN_TabNo);
final LayoutFactory rootLayoutFactory = LayoutFactory.ofMainTab(gridWindowVO, mainTabVO);
{
layoutBuilder.setCaption(rootLayoutFactory.getWindowCaption());
layoutBuilder.setSingleRowLayout(rootLayoutFactory.layoutSingleRow());
layoutBuilder.setGridView(rootLayoutFactory.layoutGridView());
layoutBuilder.setSideListView(rootLayoutFactory.layoutSideListView());
// Set special field names
// IMPORTANT: do this after you created all layouts
layoutBuilder.setDocumentSummaryElement(rootLayoutFactory.createSpecialElement_DocumentSummary()).setDocActionElement(rootLayoutFactory.createSpecialElement_DocStatusAndDocAction());
}
// Layout: Create UI details from child tabs
for (final GridTabVO detailTabVO : gridWindowVO.getChildTabs(mainTabVO.getTabNo())) {
// Skip sort tabs because they are not supported
if (detailTabVO.IsSortTab) {
continue;
}
// Skip tabs which were already used/embedded in root layout
if (rootLayoutFactory.isSkipAD_Tab_ID(detailTabVO.getAD_Tab_ID())) {
continue;
}
final LayoutFactory detailLayoutFactory = LayoutFactory.ofIncludedTab(gridWindowVO, mainTabVO, detailTabVO);
final DocumentLayoutDetailDescriptor.Builder layoutDetail = detailLayoutFactory.layoutDetail();
layoutBuilder.addDetailIfValid(layoutDetail);
final DocumentEntityDescriptor.Builder detailEntityBuilder = detailLayoutFactory.documentEntity();
rootLayoutFactory.documentEntity().addIncludedEntity(detailEntityBuilder.build());
}
//
// Build & return the final descriptor
final DocumentDescriptor descriptor = documentBuilder.setLayout(layoutBuilder.build()).setEntityDescriptor(rootLayoutFactory.documentEntity().build()).build();
logger.debug("Descriptor loaded in {}: {}", stopwatch, descriptor);
return descriptor;
}
Aggregations