TBItemAnActionButton (@NotNull AnAction action) { TBItemAnActionButton cached = myActionButtonPool.remove(action); if (cached != null) { cached.setAnAction(action); return cached; } // try find action with the same template-text for(Iterator<Map.Entry<AnAction, TBItemAnActionButton>> it = myActionButtonPool.entrySet().iterator(); it.hasNext(); ) { Map.Entry<AnAction, TBItemAnActionButton> entry = it.next(); final TBItemAnActionButton butt = entry.getValue(); if (Objects.equals(action.getTemplateText(), butt.getAnAction().getTemplateText())) { it.remove(); butt.setAnAction(action); return butt; } } return super.createActionButton(action); }