/** * Returns the edit form's data container. */ @SuppressWarnings("unchecked") protected InstanceContainer<T> getEditContainer() { return ((ContainerValueSourceProvider) getForm().getValueSourceProvider()).getContainer(); }
/** * Enables controls for editing. * @param creating indicates that a new instance is being created */ protected void enableEditControls(boolean creating) { this.editing = true; this.creating = creating; initEditComponents(true); getForm().focusFirstComponent(); }
/** * Validates visible and enabled UI components. <br> * Can be overridden in subclasses. * * @return validation errors */ protected ValidationErrors validateUiComponents() { ScreenValidation screenValidation = getBeanLocator().get(ScreenValidation.NAME); return screenValidation.validateUiComponents(getForm().getComponents()); }
/** * 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(); } } } } } }
/** * Initializes edit controls, depending on if they should be enabled or disabled. * @param enabled if true - enables edit controls and disables controls on the left side of the splitter * if false - vice versa */ protected void initEditComponents(boolean enabled) { TabSheet tabSheet = getTabSheet(); if (tabSheet != null) { ComponentsHelper.walkComponents(tabSheet, (component, name) -> { if (component instanceof FieldGroup) { ((FieldGroup) component).setEditable(enabled); } else if (component instanceof Table) { ((Table) component).getActions().forEach(action -> action.setEnabled(enabled)); } else if (!(component instanceof ComponentContainer)) { component.setEnabled(enabled); } }); } else { getForm().setEditable(enabled); } getActionsPane().setVisible(enabled); getLookupBox().setEnabled(!enabled); }