private EntityStates getEntityStates() { return getBeanLocator().get(EntityStates.NAME); }
/** * 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(getWindow()); }
protected String getLockName() { InstanceContainer<T> container = getEditedEntityContainer(); return getBeanLocator().get(ExtendedEntities.class) .getOriginalOrThisMetaClass(container.getEntityMetaClass()) .getName(); }
protected void releaseLock() { if (isLocked()) { Entity entity = getEditedEntityContainer().getItemOrNull(); if (entity != null) { getBeanLocator().get(LockService.class).unlock(getLockName(), entity.getId().toString()); } } }
protected void validateAdditionalRules(ValidationErrors errors) { // all previous validations return no errors if (isCrossFieldValidate() && errors.isEmpty()) { ScreenValidation screenValidation = getBeanLocator().get(ScreenValidation.NAME); ValidationErrors validationErrors = screenValidation.validateCrossFieldRules(this, getEditedEntity()); errors.addAll(validationErrors); } }
/** * Validates screen and commits data context. * * @return operation result */ protected OperationResult commitChanges() { ValidationErrors validationErrors = validateScreen(); if (!validationErrors.isEmpty()) { ScreenValidation screenValidation = getBeanLocator().get(ScreenValidation.class); screenValidation.showValidationErrors(this, validationErrors); return OperationResult.fail(); } getScreenData().getDataContext().commit(); return OperationResult.success(); }
protected void setupLock() { InstanceContainer<T> container = getEditedEntityContainer(); Security security = getBeanLocator().get(Security.class); this.readOnly = false; LockService lockService = getBeanLocator().get(LockService.class); ); } else if (!(lockInfo instanceof LockNotSupported)) { Messages messages = getBeanLocator().get(Messages.class); DatatypeFormatter datatypeFormatter = getBeanLocator().get(DatatypeFormatter.class);
protected void initActions(@SuppressWarnings("unused") InitEvent event) { Window window = getWindow(); Configuration configuration = getBeanLocator().get(Configuration.NAME); Messages messages = getBeanLocator().get(Messages.NAME); Icons icons = getBeanLocator().get(Icons.NAME); String commitShortcut = configuration.getConfig(ClientConfig.class).getCommitShortcut(); Action commitAndCloseAction = new BaseAction(WINDOW_COMMIT_AND_CLOSE) .withCaption(messages.getMainMessage("actions.Ok")) .withIcon(icons.get(CubaIcon.EDITOR_OK)) .withPrimary(true) .withShortcut(commitShortcut) .withHandler(this::commitAndClose); window.addAction(commitAndCloseAction); Action commitAction = new BaseAction(WINDOW_COMMIT) .withCaption(messages.getMainMessage("actions.Save")) .withHandler(this::commit); window.addAction(commitAction); Action closeAction = new BaseAction(WINDOW_CLOSE) .withIcon(icons.get(CubaIcon.EDITOR_CANCEL)) .withCaption(messages.getMainMessage("actions.Cancel")) .withHandler(this::cancel); window.addAction(closeAction); }
protected void preventUnsavedChanges(BeforeCloseEvent event) { CloseAction action = event.getCloseAction(); if (action instanceof ChangeTrackerCloseAction && ((ChangeTrackerCloseAction) action).isCheckForUnsavedChanges() && hasUnsavedChanges()) { Configuration configuration = getBeanLocator().get(Configuration.NAME); ClientConfig clientConfig = configuration.getConfig(ClientConfig.class); ScreenValidation screenValidation = getBeanLocator().get(ScreenValidation.NAME); UnknownOperationResult result = new UnknownOperationResult(); if (clientConfig.getUseSaveConfirmation()) { screenValidation.showSaveConfirmationDialog(this, action) .onCommit(() -> result.resolveWith(closeWithCommit())) .onDiscard(() -> result.resolveWith(closeWithDiscard())) .onCancel(result::fail); } else { screenValidation.showUnsavedChangesDialog(this, action) .onDiscard(() -> result.resolveWith(closeWithDiscard())) .onCancel(result::fail); } event.preventWindowClose(result); } }
DynamicAttributesGuiTools tools = getBeanLocator().get(DynamicAttributesGuiTools.NAME); String screenId = getScreenContext().getWindowInfo().getId();