protected boolean doSetIcon(
      DefaultMutableTreeNode node, @Nullable String path, Component component) {
    if (StringUtil.isNotEmpty(path) && !new File(path).isFile()) {
      Messages.showErrorDialog(
          component,
          IdeBundle.message("error.file.not.found.message", path),
          IdeBundle.message("title.choose.action.icon"));
      return false;
    }

    String actionId = getActionId(node);
    if (actionId == null) return false;

    final AnAction action = ActionManager.getInstance().getAction(actionId);
    if (action != null && action.getTemplatePresentation() != null) {
      if (StringUtil.isNotEmpty(path)) {
        Image image = null;
        try {
          image =
              ImageLoader.loadFromStream(
                  VfsUtil.convertToURL(VfsUtil.pathToUrl(path.replace(File.separatorChar, '/')))
                      .openStream());
        } catch (IOException e) {
          LOG.debug(e);
        }
        Icon icon = new File(path).exists() ? IconLoader.getIcon(image) : null;
        if (icon != null) {
          if (icon.getIconWidth() > EmptyIcon.ICON_18.getIconWidth()
              || icon.getIconHeight() > EmptyIcon.ICON_18.getIconHeight()) {
            Messages.showErrorDialog(
                component,
                IdeBundle.message("custom.icon.validation.message"),
                IdeBundle.message("title.choose.action.icon"));
            return false;
          }
          node.setUserObject(Pair.create(actionId, icon));
          mySelectedSchema.addIconCustomization(actionId, path);
        }
      } else {
        node.setUserObject(Pair.create(actionId, null));
        mySelectedSchema.removeIconCustomization(actionId);
        final DefaultMutableTreeNode nodeOnToolbar = findNodeOnToolbar(actionId);
        if (nodeOnToolbar != null) {
          editToolbarIcon(actionId, nodeOnToolbar);
          node.setUserObject(nodeOnToolbar.getUserObject());
        }
      }
      return true;
    }
    return false;
  }
 private void editToolbarIcon(String actionId, DefaultMutableTreeNode node) {
   final AnAction anAction = ActionManager.getInstance().getAction(actionId);
   if (isToolbarAction(node)
       && anAction.getTemplatePresentation() != null
       && anAction.getTemplatePresentation().getIcon() == null) {
     final int exitCode =
         Messages.showOkCancelDialog(
             IdeBundle.message("error.adding.action.without.icon.to.toolbar"),
             IdeBundle.message("title.unable.to.add.action.without.icon.to.toolbar"),
             Messages.getInformationIcon());
     if (exitCode == Messages.OK) {
       mySelectedSchema.addIconCustomization(actionId, null);
       anAction.getTemplatePresentation().setIcon(AllIcons.Toolbar.Unknown);
       anAction.setDefaultIcon(false);
       node.setUserObject(Pair.create(actionId, AllIcons.Toolbar.Unknown));
       myActionsTree.repaint();
       setCustomizationSchemaForCurrentProjects();
     }
   }
 }