code: public void updateResourceInTree(CmsObject cms, CmsUUID id) {
  
          try {
              CmsResource resource = cms.readResource(id, CmsResourceFilter.IGNORE_EXPIRATION);
              if (resource.isFile()) {
                  return;
              }
              // ensuring to only add items belonging to the current site
              if (!resource.getRootPath().startsWith(cms.getRequestContext().getSiteRoot())) {
                  m_treeContainer.removeItemRecursively(id);
                  return;
              }
  
              CmsResource parent = cms.readParentFolder(id);
              CmsUUID parentId = null;
              if (parent != null) {
                  parentId = parent.getStructureId();
              } else {
                  LOG.debug("Parent for resource '" + resource.getRootPath() + "' is null");
              }
              Item resourceItem = m_treeContainer.getItem(id);
              if (resourceItem != null) {
                  // use the root path as name in case of the root item
                  String resName = parentId == null ? resource.getRootPath() : resource.getName();
                  resourceItem.getItemProperty(CmsResourceTableProperty.PROPERTY_RESOURCE_NAME).setValue(resName);
                  CmsResourceUtil resUtil = new CmsResourceUtil(cms, resource);
                  String iconHTML = CmsResourceIcon.getTreeCaptionHTML(resName, resUtil, null, false);
                  resourceItem.getItemProperty(CmsResourceTableProperty.PROPERTY_TREE_CAPTION).setValue(iconHTML);
                  resourceItem.getItemProperty(CmsResourceTableProperty.PROPERTY_STATE).setValue(resource.getState());
                  if (parentId != null) {
                      m_treeContainer.setParent(resource.getStructureId(), parentId);
                  }
              } else {
                  addTreeItem(cms, resource, parentId, false, m_treeContainer);
              }
              m_fileTree.markAsDirty();
          } catch (CmsVfsResourceNotFoundException e) {
              m_treeContainer.removeItemRecursively(id);
              LOG.debug(e.getLocalizedMessage(), e);
          } catch (CmsException e) {
              CmsErrorDialog.showErrorDialog(e);
              LOG.error(e.getLocalizedMessage(), e);
          }
      }
docs: Updates the give tree item.<p>
  
  @param cms the cms context
  @param id the item id