code: public static boolean isEditRestricted(@NotNull ComponentContext wcmComponentContext) {
      Page page = wcmComponentContext.getPage();
      if (page == null) {
        return false;
      }
      ResourceResolver resourceResolver = wcmComponentContext.getResource().getResourceResolver();
      Template template = page.getTemplate();
  
      if (template == null || isPageInTemplateDefinition(page) || !isEditableTemplate(template)) {
        return false;
      }
  
      // check if the current resource path already points to a structure path in the editable template
      String resourcePath = wcmComponentContext.getResource().getPath();
      String templateStructurePath = template.getPath() + "/" + NN_EDITABLE_TEMPLATE_STRUCTURE + "/" + JCR_CONTENT;
      String resourcePathInStructure = null;
      if (StringUtils.startsWith(resourcePath, templateStructurePath + "/")) {
        resourcePathInStructure = resourcePath;
      }
      else {
        // resource path points to the current page, build structure path from path in page
        String relativePathInPage = StringUtils.substringAfter(resourcePath, page.getContentResource().getPath());
        if (StringUtils.isNotEmpty(relativePathInPage)) {
          resourcePathInStructure = templateStructurePath + relativePathInPage;
        }
      }
      if (resourcePathInStructure == null) {
        return false;
      }
  
      Resource resourceInStructure = resourceResolver.getResource(resourcePathInStructure);
      if (resourceInStructure == null) {
        return false;
      }
      return !resourceInStructure.getValueMap().get(PN_EDITABLE, false);
    }
docs: Checks if editing of the given component in edit mode is forbidden due to a lock in the template editor
  for this component.
  @param wcmComponentContext WCM component context
  @return true if editing the component is forbidden