/** * Pessimistic lock before start of editing, if it is configured for the entity. */ protected boolean lockIfNeeded(Entity entity) { LockService lockService = getBeanLocator().get(LockService.class); LockInfo lockInfo = lockService.lock(getLockName(), entity.getId().toString()); if (lockInfo == null) { justLocked = true; } else if (!(lockInfo instanceof LockNotSupported)) { Messages messages = getBeanLocator().get(Messages.class); DatatypeFormatter datatypeFormatter = getBeanLocator().get(DatatypeFormatter.class); Notifications notifications = getScreenContext().getNotifications(); notifications.create(NotificationType.HUMANIZED) .withCaption(messages.getMainMessage("entityLocked.msg")) .withDescription(String.format(messages.getMainMessage("entityLocked.desc"), lockInfo.getUser().getLogin(), datatypeFormatter.formatDateTime(lockInfo.getSince()))) .show(); return false; } return true; }
/** * Adds a listener that reloads the selected record and sets it to editCt. */ protected void initBrowseItemChangeListener() { getBrowseContainer().addItemChangeListener(e -> { if (e.getItem() != null) { InstanceLoader<T> editLoader = getEditLoader(); DynamicAttributesGuiTools tools = getBeanLocator().get(DynamicAttributesGuiTools.NAME); String screenId = getScreenContext().getWindowInfo().getId(); if (tools.screenContainsDynamicAttributes(getEditContainer().getView(), screenId)) { editLoader.setLoadDynamicAttributes(true); } editLoader.setEntityId(e.getItem().getId()); editLoader.load(); } else { if (!editing) { getEditContainer().setItem(null); } } }); }
String screenId = getScreenContext().getWindowInfo().getId();